zaileys
Version:
Zaileys - Simplified WhatsApp Node.js API
1 lines • 103 kB
JavaScript
"use strict";var e=require("baileys"),t=require("events"),s=require("figlet"),a=require("node-cache"),n=require("ora"),i=require("pino"),r=require("better-sqlite3"),o=require("fs"),d=require("kysely"),c=require("mysql2"),l=require("path"),u=require("pg"),p=require("url"),h=require("qrcode"),m=require("os"),f=require("stream"),g=require("bottleneck"),y=require("hono"),v=require("@hono/node-server"),_=require("fast-levenshtein");function w(e){return e&&e.__esModule?e:{default:e}}function b(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(s){if("default"!==s){var a=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,a.get?a:{enumerable:!0,get:function(){return e[s]}})}})),t.default=e,Object.freeze(t)}var x,k,C,T=w(s),M=w(a),I=w(n),S=w(i),N=w(r),A=w(c),O=w(l),E=w(h),L=w(m),P=w(g),Z=b(_),j=Object.defineProperty,R=e=>{const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";return Array.from({length:e},(()=>t[Math.floor(62*Math.random())])).join("")},F=(e="")=>{try{return JSON.parse(e)}catch{return JSON.parse(JSON.stringify(e))}},q=(e={})=>{try{return JSON.stringify(e)}catch{return JSON.stringify(JSON.parse(JSON.stringify(e)))}},$=(e="",t="")=>e?e.toLowerCase().includes(t.toLowerCase()):null,z=(e,t)=>e&&"object"==typeof e?Array.isArray(e)?e.map((e=>z(e,t))):Object.fromEntries(Object.entries(e).filter((([e])=>!t.includes(e))).map((([e,s])=>[e,"object"==typeof s?z(s,t):s]))):e,D=e=>{const t={...e.fingerprint,deviceIndexes:Array.isArray(e.fingerprint.deviceIndexes)?e.fingerprint.deviceIndexes:[]},s={keyData:Array.isArray(e.keyData)?e.keyData:new Uint8Array,fingerprint:{rawId:t.rawId||0,currentIndex:t.rawId||0,deviceIndexes:t.deviceIndexes},timestamp:(a=e.timestamp,"string"==typeof a?parseInt(a,10):a)};var a;return"string"==typeof e.keyData&&(s.keyData=(e=>{let t=e.length;if(!t)return new Uint8Array(1);let s=0;for(;--t%4>1&&"="===e.charAt(t);)++s;return new Uint8Array(Math.ceil(3*e.length)/4-s).fill(0)})(e.keyData)),s},U={};((e,t)=>{for(var s in t)j(e,s,{get:t[s],enumerable:!0})})(U,{BRAND:()=>bt,DIRTY:()=>re,EMPTY_PATH:()=>ee,INVALID:()=>ie,NEVER:()=>fs,OK:()=>oe,ParseStatus:()=>ne,Schema:()=>ge,ZodAny:()=>Be,ZodArray:()=>Ye,ZodBigInt:()=>$e,ZodBoolean:()=>ze,ZodBranded:()=>xt,ZodCatch:()=>_t,ZodDate:()=>De,ZodDefault:()=>vt,ZodDiscriminatedUnion:()=>tt,ZodEffects:()=>ft,ZodEnum:()=>pt,ZodError:()=>J,ZodFirstPartyTypeKind:()=>It,ZodFunction:()=>dt,ZodIntersection:()=>at,ZodIssueCode:()=>B,ZodLazy:()=>ct,ZodLiteral:()=>lt,ZodMap:()=>rt,ZodNaN:()=>wt,ZodNativeEnum:()=>ht,ZodNever:()=>Je,ZodNull:()=>We,ZodNullable:()=>yt,ZodNumber:()=>qe,ZodObject:()=>Qe,ZodOptional:()=>gt,ZodParsedType:()=>V,ZodPipeline:()=>kt,ZodPromise:()=>mt,ZodReadonly:()=>Ct,ZodRecord:()=>it,ZodSchema:()=>ge,ZodSet:()=>ot,ZodString:()=>Re,ZodSymbol:()=>Ue,ZodTransformer:()=>ft,ZodTuple:()=>nt,ZodType:()=>ge,ZodUndefined:()=>Ve,ZodUnion:()=>Xe,ZodUnknown:()=>Ke,ZodVoid:()=>Ge,addIssueToContext:()=>te,any:()=>$t,array:()=>Vt,bigint:()=>Pt,boolean:()=>Zt,coerce:()=>ms,custom:()=>Mt,date:()=>jt,datetimeRegex:()=>Pe,defaultErrorMap:()=>G,discriminatedUnion:()=>Jt,effect:()=>rs,enum:()=>as,function:()=>es,getErrorMap:()=>Q,getParsedType:()=>W,instanceof:()=>At,intersection:()=>Gt,isAborted:()=>de,isAsync:()=>ue,isDirty:()=>ce,isValid:()=>le,late:()=>Nt,lazy:()=>ts,literal:()=>ss,makeIssue:()=>X,map:()=>Qt,nan:()=>Lt,nativeEnum:()=>ns,never:()=>Dt,null:()=>qt,nullable:()=>ds,number:()=>Et,object:()=>Wt,objectUtil:()=>C,oboolean:()=>hs,onumber:()=>ps,optional:()=>os,ostring:()=>us,pipeline:()=>ls,preprocess:()=>cs,promise:()=>is,quotelessJson:()=>K,record:()=>Ht,set:()=>Xt,setErrorMap:()=>H,strictObject:()=>Bt,string:()=>Ot,symbol:()=>Rt,transformer:()=>rs,tuple:()=>Yt,undefined:()=>Ft,union:()=>Kt,unknown:()=>zt,util:()=>x,void:()=>Ut}),(k=x||(x={})).assertEqual=e=>{},k.assertIs=function(e){},k.assertNever=function(e){throw new Error},k.arrayToEnum=e=>{const t={};for(const s of e)t[s]=s;return t},k.getValidEnumValues=e=>{const t=k.objectKeys(e).filter((t=>"number"!=typeof e[e[t]])),s={};for(const a of t)s[a]=e[a];return k.objectValues(s)},k.objectValues=e=>k.objectKeys(e).map((function(t){return e[t]})),k.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.push(s);return t},k.find=(e,t)=>{for(const s of e)if(t(s))return s},k.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,k.joinValues=function(e,t=" | "){return e.map((e=>"string"==typeof e?`'${e}'`:e)).join(t)},k.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t,(C||(C={})).mergeShapes=(e,t)=>({...e,...t});var V=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),W=e=>{switch(typeof e){case"undefined":return V.undefined;case"string":return V.string;case"number":return Number.isNaN(e)?V.nan:V.number;case"boolean":return V.boolean;case"function":return V.function;case"bigint":return V.bigint;case"symbol":return V.symbol;case"object":return Array.isArray(e)?V.array:null===e?V.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?V.promise:"undefined"!=typeof Map&&e instanceof Map?V.map:"undefined"!=typeof Set&&e instanceof Set?V.set:"undefined"!=typeof Date&&e instanceof Date?V.date:V.object;default:return V.unknown}},B=x.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"]),K=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),J=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(e){return e.message},s={_errors:[]},a=e=>{for(const n of e.issues)if("invalid_union"===n.code)n.unionErrors.map(a);else if("invalid_return_type"===n.code)a(n.returnTypeError);else if("invalid_arguments"===n.code)a(n.argumentsError);else if(0===n.path.length)s._errors.push(t(n));else{let e=s,a=0;for(;a<n.path.length;){const s=n.path[a];a===n.path.length-1?(e[s]=e[s]||{_errors:[]},e[s]._errors.push(t(n))):e[s]=e[s]||{_errors:[]},e=e[s],a++}}};return a(this),s}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t={},s=[];for(const a of this.issues)a.path.length>0?(t[a.path[0]]=t[a.path[0]]||[],t[a.path[0]].push(e(a))):s.push(e(a));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}};J.create=e=>new J(e);var G=(e,t)=>{let s;switch(e.code){case B.invalid_type:s=e.received===V.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case B.invalid_literal:s=`Invalid literal value, expected ${JSON.stringify(e.expected,x.jsonStringifyReplacer)}`;break;case B.unrecognized_keys:s=`Unrecognized key(s) in object: ${x.joinValues(e.keys,", ")}`;break;case B.invalid_union:s="Invalid input";break;case B.invalid_union_discriminator:s=`Invalid discriminator value. Expected ${x.joinValues(e.options)}`;break;case B.invalid_enum_value:s=`Invalid enum value. Expected ${x.joinValues(e.options)}, received '${e.received}'`;break;case B.invalid_arguments:s="Invalid function arguments";break;case B.invalid_return_type:s="Invalid function return type";break;case B.invalid_date:s="Invalid date";break;case B.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(s=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(s=`${s} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?s=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?s=`Invalid input: must end with "${e.validation.endsWith}"`:x.assertNever(e.validation):s="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case B.too_small:s="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 B.too_big:s="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 B.custom:s="Invalid input";break;case B.invalid_intersection_types:s="Intersection results could not be merged";break;case B.not_multiple_of:s=`Number must be a multiple of ${e.multipleOf}`;break;case B.not_finite:s="Number must be finite";break;default:s=t.defaultError,x.assertNever(e)}return{message:s}},Y=G;function H(e){Y=e}function Q(){return Y}var X=e=>{const{data:t,path:s,errorMaps:a,issueData:n}=e,i=[...s,...n.path||[]],r={...n,path:i};if(void 0!==n.message)return{...n,path:i,message:n.message};let o="";const d=a.filter((e=>!!e)).slice().reverse();for(const e of d)o=e(r,{data:t,defaultError:o}).message;return{...n,path:i,message:o}},ee=[];function te(e,t){const s=Q(),a=X({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,s,s===G?void 0:G].filter((e=>!!e))});e.common.issues.push(a)}var se,ae,ne=class e{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const a of t){if("aborted"===a.status)return ie;"dirty"===a.status&&e.dirty(),s.push(a.value)}return{status:e.value,value:s}}static async mergeObjectAsync(t,s){const a=[];for(const e of s){const t=await e.key,s=await e.value;a.push({key:t,value:s})}return e.mergeObjectSync(t,a)}static mergeObjectSync(e,t){const s={};for(const a of t){const{key:t,value:n}=a;if("aborted"===t.status)return ie;if("aborted"===n.status)return ie;"dirty"===t.status&&e.dirty(),"dirty"===n.status&&e.dirty(),"__proto__"===t.value||void 0===n.value&&!a.alwaysSet||(s[t.value]=n.value)}return{status:e.value,value:s}}},ie=Object.freeze({status:"aborted"}),re=e=>({status:"dirty",value:e}),oe=e=>({status:"valid",value:e}),de=e=>"aborted"===e.status,ce=e=>"dirty"===e.status,le=e=>"valid"===e.status,ue=e=>"undefined"!=typeof Promise&&e instanceof Promise;(ae=se||(se={})).errToObj=e=>"string"==typeof e?{message:e}:e||{},ae.toString=e=>"string"==typeof e?e:e?.message;var pe=class{constructor(e,t,s,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},he=(e,t)=>{if(le(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 J(e.common.issues);return this._error=t,this._error}}};function me(e){if(!e)return{};const{errorMap:t,invalid_type_error:s,required_error:a,description:n}=e;if(t&&(s||a))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:n};return{errorMap:(t,n)=>{const{message:i}=e;return"invalid_enum_value"===t.code?{message:i??n.defaultError}:void 0===n.data?{message:i??a??n.defaultError}:"invalid_type"!==t.code?{message:n.defaultError}:{message:i??s??n.defaultError}},description:n}}var fe,ge=class{get description(){return this._def.description}_getType(e){return W(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:W(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ne,ctx:{common:e.parent.common,data:e.data,parsedType:W(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(ue(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){const s={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:W(e)},a=this._parseSync({data:e,path:s.path,parent:s});return he(s,a)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:W(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:t});return le(s)?{value:s.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then((e=>le(e)?{value:e.value}:{issues:t.common.issues}))}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:W(e)},a=this._parse({data:e,path:s.path,parent:s}),n=await(ue(a)?a:Promise.resolve(a));return he(s,n)}refine(e,t){const s=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement(((t,a)=>{const n=e(t),i=()=>a.addIssue({code:B.custom,...s(t)});return"undefined"!=typeof Promise&&n instanceof Promise?n.then((e=>!!e||(i(),!1))):!!n||(i(),!1)}))}refinement(e,t){return this._refinement(((s,a)=>!!e(s)||(a.addIssue("function"==typeof t?t(s,a):t),!1)))}_refinement(e){return new ft({schema:this,typeName:It.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return gt.create(this,this._def)}nullable(){return yt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ye.create(this)}promise(){return mt.create(this,this._def)}or(e){return Xe.create([this,e],this._def)}and(e){return at.create(this,e,this._def)}transform(e){return new ft({...me(this._def),schema:this,typeName:It.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new vt({...me(this._def),innerType:this,defaultValue:t,typeName:It.ZodDefault})}brand(){return new xt({typeName:It.ZodBranded,type:this,...me(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new _t({...me(this._def),innerType:this,catchValue:t,typeName:It.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return kt.create(this,e)}readonly(){return Ct.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},ye=/^c[^\s-]{8,}$/i,ve=/^[0-9a-z]+$/,_e=/^[0-9A-HJKMNP-TV-Z]{26}$/i,we=/^[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,be=/^[a-z0-9_-]{21}$/i,xe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ke=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Ce=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Te=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Me=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Ie=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Se=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ne=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ae=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Oe="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Ee=new RegExp(`^${Oe}$`);function Le(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e.precision?"+":"?"}`}function Pe(e){let t=`${Oe}T${Le(e)}`;const s=[];return s.push(e.local?"Z?":"Z"),e.offset&&s.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${s.join("|")})`,new RegExp(`^${t}$`)}function Ze(e,t){if(!xe.test(e))return!1;try{const[s]=e.split("."),a=s.replace(/-/g,"+").replace(/_/g,"/").padEnd(s.length+(4-s.length%4)%4,"="),n=JSON.parse(atob(a));return"object"==typeof n&&null!==n&&((!("typ"in n)||"JWT"===n?.typ)&&(!!n.alg&&(!t||n.alg===t)))}catch{return!1}}function je(e,t){return!("v4"!==t&&t||!Me.test(e))||!("v6"!==t&&t||!Se.test(e))}var Re=class e extends ge{_parse(e){this._def.coerce&&(e.data=String(e.data));if(this._getType(e)!==V.string){const t=this._getOrReturnCtx(e);return te(t,{code:B.invalid_type,expected:V.string,received:t.parsedType}),ie}const t=new ne;let s;for(const i of this._def.checks)if("min"===i.kind)e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),te(s,{code:B.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),t.dirty());else if("max"===i.kind)e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),te(s,{code:B.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),t.dirty());else if("length"===i.kind){const a=e.data.length>i.value,n=e.data.length<i.value;(a||n)&&(s=this._getOrReturnCtx(e,s),a?te(s,{code:B.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):n&&te(s,{code:B.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),t.dirty())}else if("email"===i.kind)Ce.test(e.data)||(s=this._getOrReturnCtx(e,s),te(s,{validation:"email",code:B.invalid_string,message:i.message}),t.dirty());else if("emoji"===i.kind)fe||(fe=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),fe.test(e.data)||(s=this._getOrReturnCtx(e,s),te(s,{validation:"emoji",code:B.invalid_string,message:i.message}),t.dirty());else if("uuid"===i.kind)we.test(e.data)||(s=this._getOrReturnCtx(e,s),te(s,{validation:"uuid",code:B.invalid_string,message:i.message}),t.dirty());else if("nanoid"===i.kind)be.test(e.data)||(s=this._getOrReturnCtx(e,s),te(s,{validation:"nanoid",code:B.invalid_string,message:i.message}),t.dirty());else if("cuid"===i.kind)ye.test(e.data)||(s=this._getOrReturnCtx(e,s),te(s,{validation:"cuid",code:B.invalid_string,message:i.message}),t.dirty());else if("cuid2"===i.kind)ve.test(e.data)||(s=this._getOrReturnCtx(e,s),te(s,{validation:"cuid2",code:B.invalid_string,message:i.message}),t.dirty());else if("ulid"===i.kind)_e.test(e.data)||(s=this._getOrReturnCtx(e,s),te(s,{validation:"ulid",code:B.invalid_string,message:i.message}),t.dirty());else if("url"===i.kind)try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),te(s,{validation:"url",code:B.invalid_string,message:i.message}),t.dirty()}else if("regex"===i.kind){i.regex.lastIndex=0;i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),te(s,{validation:"regex",code:B.invalid_string,message:i.message}),t.dirty())}else if("trim"===i.kind)e.data=e.data.trim();else if("includes"===i.kind)e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),te(s,{code:B.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),t.dirty());else if("toLowerCase"===i.kind)e.data=e.data.toLowerCase();else if("toUpperCase"===i.kind)e.data=e.data.toUpperCase();else if("startsWith"===i.kind)e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),te(s,{code:B.invalid_string,validation:{startsWith:i.value},message:i.message}),t.dirty());else if("endsWith"===i.kind)e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),te(s,{code:B.invalid_string,validation:{endsWith:i.value},message:i.message}),t.dirty());else if("datetime"===i.kind){Pe(i).test(e.data)||(s=this._getOrReturnCtx(e,s),te(s,{code:B.invalid_string,validation:"datetime",message:i.message}),t.dirty())}else if("date"===i.kind){Ee.test(e.data)||(s=this._getOrReturnCtx(e,s),te(s,{code:B.invalid_string,validation:"date",message:i.message}),t.dirty())}else if("time"===i.kind){new RegExp(`^${Le(i)}$`).test(e.data)||(s=this._getOrReturnCtx(e,s),te(s,{code:B.invalid_string,validation:"time",message:i.message}),t.dirty())}else"duration"===i.kind?ke.test(e.data)||(s=this._getOrReturnCtx(e,s),te(s,{validation:"duration",code:B.invalid_string,message:i.message}),t.dirty()):"ip"===i.kind?(a=e.data,("v4"!==(n=i.version)&&n||!Te.test(a))&&("v6"!==n&&n||!Ie.test(a))&&(s=this._getOrReturnCtx(e,s),te(s,{validation:"ip",code:B.invalid_string,message:i.message}),t.dirty())):"jwt"===i.kind?Ze(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),te(s,{validation:"jwt",code:B.invalid_string,message:i.message}),t.dirty()):"cidr"===i.kind?je(e.data,i.version)||(s=this._getOrReturnCtx(e,s),te(s,{validation:"cidr",code:B.invalid_string,message:i.message}),t.dirty()):"base64"===i.kind?Ne.test(e.data)||(s=this._getOrReturnCtx(e,s),te(s,{validation:"base64",code:B.invalid_string,message:i.message}),t.dirty()):"base64url"===i.kind?Ae.test(e.data)||(s=this._getOrReturnCtx(e,s),te(s,{validation:"base64url",code:B.invalid_string,message:i.message}),t.dirty()):x.assertNever(i);var a,n;return{status:t.value,value:e.data}}_regex(e,t,s){return this.refinement((t=>e.test(t)),{validation:t,code:B.invalid_string,...se.errToObj(s)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:"email",...se.errToObj(e)})}url(e){return this._addCheck({kind:"url",...se.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...se.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...se.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...se.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...se.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...se.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...se.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...se.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...se.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...se.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...se.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...se.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...se.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===e?.precision?null:e?.precision,...se.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...se.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...se.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...se.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...se.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...se.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...se.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...se.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...se.errToObj(t)})}nonempty(e){return this.min(1,se.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((e=>"datetime"===e.kind))}get isDate(){return!!this._def.checks.find((e=>"date"===e.kind))}get isTime(){return!!this._def.checks.find((e=>"time"===e.kind))}get isDuration(){return!!this._def.checks.find((e=>"duration"===e.kind))}get isEmail(){return!!this._def.checks.find((e=>"email"===e.kind))}get isURL(){return!!this._def.checks.find((e=>"url"===e.kind))}get isEmoji(){return!!this._def.checks.find((e=>"emoji"===e.kind))}get isUUID(){return!!this._def.checks.find((e=>"uuid"===e.kind))}get isNANOID(){return!!this._def.checks.find((e=>"nanoid"===e.kind))}get isCUID(){return!!this._def.checks.find((e=>"cuid"===e.kind))}get isCUID2(){return!!this._def.checks.find((e=>"cuid2"===e.kind))}get isULID(){return!!this._def.checks.find((e=>"ulid"===e.kind))}get isIP(){return!!this._def.checks.find((e=>"ip"===e.kind))}get isCIDR(){return!!this._def.checks.find((e=>"cidr"===e.kind))}get isBase64(){return!!this._def.checks.find((e=>"base64"===e.kind))}get isBase64url(){return!!this._def.checks.find((e=>"base64url"===e.kind))}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}};function Fe(e,t){const s=(e.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,n=s>a?s:a;return Number.parseInt(e.toFixed(n).replace(".",""))%Number.parseInt(t.toFixed(n).replace(".",""))/10**n}Re.create=e=>new Re({checks:[],typeName:It.ZodString,coerce:e?.coerce??!1,...me(e)});var qe=class e extends ge{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)!==V.number){const t=this._getOrReturnCtx(e);return te(t,{code:B.invalid_type,expected:V.number,received:t.parsedType}),ie}let t;const s=new ne;for(const a of this._def.checks)if("int"===a.kind)x.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),te(t,{code:B.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty());else if("min"===a.kind){(a.inclusive?e.data<a.value:e.data<=a.value)&&(t=this._getOrReturnCtx(e,t),te(t,{code:B.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty())}else if("max"===a.kind){(a.inclusive?e.data>a.value:e.data>=a.value)&&(t=this._getOrReturnCtx(e,t),te(t,{code:B.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty())}else"multipleOf"===a.kind?0!==Fe(e.data,a.value)&&(t=this._getOrReturnCtx(e,t),te(t,{code:B.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):"finite"===a.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),te(t,{code:B.not_finite,message:a.message}),s.dirty()):x.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,se.toString(t))}gt(e,t){return this.setLimit("min",e,!1,se.toString(t))}lte(e,t){return this.setLimit("max",e,!0,se.toString(t))}lt(e,t){return this.setLimit("max",e,!1,se.toString(t))}setLimit(t,s,a,n){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:s,inclusive:a,message:se.toString(n)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:"int",message:se.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:se.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:se.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:se.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:se.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:se.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:se.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:se.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:se.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&&x.isInteger(e.value)))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if("finite"===s.kind||"int"===s.kind||"multipleOf"===s.kind)return!0;"min"===s.kind?(null===t||s.value>t)&&(t=s.value):"max"===s.kind&&(null===e||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}};qe.create=e=>new qe({checks:[],typeName:It.ZodNumber,coerce:e?.coerce||!1,...me(e)});var $e=class e extends ge{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==V.bigint)return this._getInvalidInput(e);let t;const s=new ne;for(const a of this._def.checks)if("min"===a.kind){(a.inclusive?e.data<a.value:e.data<=a.value)&&(t=this._getOrReturnCtx(e,t),te(t,{code:B.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty())}else if("max"===a.kind){(a.inclusive?e.data>a.value:e.data>=a.value)&&(t=this._getOrReturnCtx(e,t),te(t,{code:B.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty())}else"multipleOf"===a.kind?e.data%a.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),te(t,{code:B.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):x.assertNever(a);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return te(t,{code:B.invalid_type,expected:V.bigint,received:t.parsedType}),ie}gte(e,t){return this.setLimit("min",e,!0,se.toString(t))}gt(e,t){return this.setLimit("min",e,!1,se.toString(t))}lte(e,t){return this.setLimit("max",e,!0,se.toString(t))}lt(e,t){return this.setLimit("max",e,!1,se.toString(t))}setLimit(t,s,a,n){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:s,inclusive:a,message:se.toString(n)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:se.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:se.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:se.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:se.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:se.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}};$e.create=e=>new $e({checks:[],typeName:It.ZodBigInt,coerce:e?.coerce??!1,...me(e)});var ze=class extends ge{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==V.boolean){const t=this._getOrReturnCtx(e);return te(t,{code:B.invalid_type,expected:V.boolean,received:t.parsedType}),ie}return oe(e.data)}};ze.create=e=>new ze({typeName:It.ZodBoolean,coerce:e?.coerce||!1,...me(e)});var De=class e extends ge{_parse(e){this._def.coerce&&(e.data=new Date(e.data));if(this._getType(e)!==V.date){const t=this._getOrReturnCtx(e);return te(t,{code:B.invalid_type,expected:V.date,received:t.parsedType}),ie}if(Number.isNaN(e.data.getTime())){return te(this._getOrReturnCtx(e),{code:B.invalid_date}),ie}const t=new ne;let s;for(const a of this._def.checks)"min"===a.kind?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),te(s,{code:B.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),t.dirty()):"max"===a.kind?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),te(s,{code:B.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),t.dirty()):x.assertNever(a);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:se.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:se.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}};De.create=e=>new De({checks:[],coerce:e?.coerce||!1,typeName:It.ZodDate,...me(e)});var Ue=class extends ge{_parse(e){if(this._getType(e)!==V.symbol){const t=this._getOrReturnCtx(e);return te(t,{code:B.invalid_type,expected:V.symbol,received:t.parsedType}),ie}return oe(e.data)}};Ue.create=e=>new Ue({typeName:It.ZodSymbol,...me(e)});var Ve=class extends ge{_parse(e){if(this._getType(e)!==V.undefined){const t=this._getOrReturnCtx(e);return te(t,{code:B.invalid_type,expected:V.undefined,received:t.parsedType}),ie}return oe(e.data)}};Ve.create=e=>new Ve({typeName:It.ZodUndefined,...me(e)});var We=class extends ge{_parse(e){if(this._getType(e)!==V.null){const t=this._getOrReturnCtx(e);return te(t,{code:B.invalid_type,expected:V.null,received:t.parsedType}),ie}return oe(e.data)}};We.create=e=>new We({typeName:It.ZodNull,...me(e)});var Be=class extends ge{constructor(){super(...arguments),this._any=!0}_parse(e){return oe(e.data)}};Be.create=e=>new Be({typeName:It.ZodAny,...me(e)});var Ke=class extends ge{constructor(){super(...arguments),this._unknown=!0}_parse(e){return oe(e.data)}};Ke.create=e=>new Ke({typeName:It.ZodUnknown,...me(e)});var Je=class extends ge{_parse(e){const t=this._getOrReturnCtx(e);return te(t,{code:B.invalid_type,expected:V.never,received:t.parsedType}),ie}};Je.create=e=>new Je({typeName:It.ZodNever,...me(e)});var Ge=class extends ge{_parse(e){if(this._getType(e)!==V.undefined){const t=this._getOrReturnCtx(e);return te(t,{code:B.invalid_type,expected:V.void,received:t.parsedType}),ie}return oe(e.data)}};Ge.create=e=>new Ge({typeName:It.ZodVoid,...me(e)});var Ye=class e extends ge{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),a=this._def;if(t.parsedType!==V.array)return te(t,{code:B.invalid_type,expected:V.array,received:t.parsedType}),ie;if(null!==a.exactLength){const e=t.data.length>a.exactLength.value,n=t.data.length<a.exactLength.value;(e||n)&&(te(t,{code:e?B.too_big:B.too_small,minimum:n?a.exactLength.value:void 0,maximum:e?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),s.dirty())}if(null!==a.minLength&&t.data.length<a.minLength.value&&(te(t,{code:B.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),s.dirty()),null!==a.maxLength&&t.data.length>a.maxLength.value&&(te(t,{code:B.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map(((e,s)=>a.type._parseAsync(new pe(t,e,t.path,s))))).then((e=>ne.mergeArray(s,e)));const n=[...t.data].map(((e,s)=>a.type._parseSync(new pe(t,e,t.path,s))));return ne.mergeArray(s,n)}get element(){return this._def.type}min(t,s){return new e({...this._def,minLength:{value:t,message:se.toString(s)}})}max(t,s){return new e({...this._def,maxLength:{value:t,message:se.toString(s)}})}length(t,s){return new e({...this._def,exactLength:{value:t,message:se.toString(s)}})}nonempty(e){return this.min(1,e)}};function He(e){if(e instanceof Qe){const t={};for(const s in e.shape){const a=e.shape[s];t[s]=gt.create(He(a))}return new Qe({...e._def,shape:()=>t})}return e instanceof Ye?new Ye({...e._def,type:He(e.element)}):e instanceof gt?gt.create(He(e.unwrap())):e instanceof yt?yt.create(He(e.unwrap())):e instanceof nt?nt.create(e.items.map((e=>He(e)))):e}Ye.create=(e,t)=>new Ye({type:e,minLength:null,maxLength:null,exactLength:null,typeName:It.ZodArray,...me(t)});var Qe=class e extends ge{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=x.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==V.object){const t=this._getOrReturnCtx(e);return te(t,{code:B.invalid_type,expected:V.object,received:t.parsedType}),ie}const{status:t,ctx:s}=this._processInputParams(e),{shape:a,keys:n}=this._getCached(),i=[];if(!(this._def.catchall instanceof Je&&"strip"===this._def.unknownKeys))for(const e in s.data)n.includes(e)||i.push(e);const r=[];for(const e of n){const t=a[e],n=s.data[e];r.push({key:{status:"valid",value:e},value:t._parse(new pe(s,n,s.path,e)),alwaysSet:e in s.data})}if(this._def.catchall instanceof Je){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of i)r.push({key:{status:"valid",value:e},value:{status:"valid",value:s.data[e]}});else if("strict"===e)i.length>0&&(te(s,{code:B.unrecognized_keys,keys:i}),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 i){const a=s.data[t];r.push({key:{status:"valid",value:t},value:e._parse(new pe(s,a,s.path,t)),alwaysSet:t in s.data})}}return s.common.async?Promise.resolve().then((async()=>{const e=[];for(const t of r){const s=await t.key,a=await t.value;e.push({key:s,value:a,alwaysSet:t.alwaysSet})}return e})).then((e=>ne.mergeObjectSync(t,e))):ne.mergeObjectSync(t,r)}get shape(){return this._def.shape()}strict(t){return se.errToObj,new e({...this._def,unknownKeys:"strict",...void 0!==t?{errorMap:(e,s)=>{const a=this._def.errorMap?.(e,s).message??s.defaultError;return"unrecognized_keys"===e.code?{message:se.errToObj(t).message??a}:{message:a}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:It.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){const s={};for(const e of x.objectKeys(t))t[e]&&this.shape[e]&&(s[e]=this.shape[e]);return new e({...this._def,shape:()=>s})}omit(t){const s={};for(const e of x.objectKeys(this.shape))t[e]||(s[e]=this.shape[e]);return new e({...this._def,shape:()=>s})}deepPartial(){return He(this)}partial(t){const s={};for(const e of x.objectKeys(this.shape)){const a=this.shape[e];t&&!t[e]?s[e]=a:s[e]=a.optional()}return new e({...this._def,shape:()=>s})}required(t){const s={};for(const e of x.objectKeys(this.shape))if(t&&!t[e])s[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof gt;)t=t._def.innerType;s[e]=t}return new e({...this._def,shape:()=>s})}keyof(){return ut(x.objectKeys(this.shape))}};Qe.create=(e,t)=>new Qe({shape:()=>e,unknownKeys:"strip",catchall:Je.create(),typeName:It.ZodObject,...me(t)}),Qe.strictCreate=(e,t)=>new Qe({shape:()=>e,unknownKeys:"strict",catchall:Je.create(),typeName:It.ZodObject,...me(t)}),Qe.lazycreate=(e,t)=>new Qe({shape:e,unknownKeys:"strip",catchall:Je.create(),typeName:It.ZodObject,...me(t)});var Xe=class extends ge{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;if(t.common.async)return Promise.all(s.map((async e=>{const s={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:s}),ctx:s}}))).then((function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const s of e)if("dirty"===s.result.status)return t.common.issues.push(...s.ctx.common.issues),s.result;const s=e.map((e=>new J(e.ctx.common.issues)));return te(t,{code:B.invalid_union,unionErrors:s}),ie}));{let e;const a=[];for(const n of s){const s={...t,common:{...t.common,issues:[]},parent:null},i=n._parseSync({data:t.data,path:t.path,parent:s});if("valid"===i.status)return i;"dirty"!==i.status||e||(e={result:i,ctx:s}),s.common.issues.length&&a.push(s.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const n=a.map((e=>new J(e)));return te(t,{code:B.invalid_union,unionErrors:n}),ie}}get options(){return this._def.options}};Xe.create=(e,t)=>new Xe({options:e,typeName:It.ZodUnion,...me(t)});var et=e=>e instanceof ct?et(e.schema):e instanceof ft?et(e.innerType()):e instanceof lt?[e.value]:e instanceof pt?e.options:e instanceof ht?x.objectValues(e.enum):e instanceof vt?et(e._def.innerType):e instanceof Ve?[void 0]:e instanceof We?[null]:e instanceof gt?[void 0,...et(e.unwrap())]:e instanceof yt?[null,...et(e.unwrap())]:e instanceof xt||e instanceof Ct?et(e.unwrap()):e instanceof _t?et(e._def.innerType):[],tt=class e extends ge{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==V.object)return te(t,{code:B.invalid_type,expected:V.object,received:t.parsedType}),ie;const s=this.discriminator,a=t.data[s],n=this.optionsMap.get(a);return n?t.common.async?n._parseAsync({data:t.data,path:t.path,parent:t}):n._parseSync({data:t.data,path:t.path,parent:t}):(te(t,{code:B.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),ie)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,s,a){const n=new Map;for(const e of s){const s=et(e.shape[t]);if(!s.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const a of s){if(n.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);n.set(a,e)}}return new e({typeName:It.ZodDiscriminatedUnion,discriminator:t,options:s,optionsMap:n,...me(a)})}};function st(e,t){const s=W(e),a=W(t);if(e===t)return{valid:!0,data:e};if(s===V.object&&a===V.object){const s=x.objectKeys(t),a=x.objectKeys(e).filter((e=>-1!==s.indexOf(e))),n={...e,...t};for(const s of a){const a=st(e[s],t[s]);if(!a.valid)return{valid:!1};n[s]=a.data}return{valid:!0,data:n}}if(s===V.array&&a===V.array){if(e.length!==t.length)return{valid:!1};const s=[];for(let a=0;a<e.length;a++){const n=st(e[a],t[a]);if(!n.valid)return{valid:!1};s.push(n.data)}return{valid:!0,data:s}}return s===V.date&&a===V.date&&+e===+t?{valid:!0,data:e}:{valid:!1}}var at=class extends ge{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),a=(e,a)=>{if(de(e)||de(a))return ie;const n=st(e.value,a.value);return n.valid?((ce(e)||ce(a))&&t.dirty(),{status:t.value,value:n.data}):(te(s,{code:B.invalid_intersection_types}),ie)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then((([e,t])=>a(e,t))):a(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}};at.create=(e,t,s)=>new at({left:e,right:t,typeName:It.ZodIntersection,...me(s)});var nt=class e extends ge{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==V.array)return te(s,{code:B.invalid_type,expected:V.array,received:s.parsedType}),ie;if(s.data.length<this._def.items.length)return te(s,{code:B.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ie;!this._def.rest&&s.data.length>this._def.items.length&&(te(s,{code:B.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...s.data].map(((e,t)=>{const a=this._def.items[t]||this._def.rest;return a?a._parse(new pe(s,e,s.path,t)):null})).filter((e=>!!e));return s.common.async?Promise.all(a).then((e=>ne.mergeArray(t,e))):ne.mergeArray(t,a)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};nt.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new nt({items:e,typeName:It.ZodTuple,rest:null,...me(t)})};var it=class e extends ge{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==V.object)return te(s,{code:B.invalid_type,expected:V.object,received:s.parsedType}),ie;const a=[],n=this._def.keyType,i=this._def.valueType;for(const e in s.data)a.push({key:n._parse(new pe(s,e,s.path,e)),value:i._parse(new pe(s,s.data[e],s.path,e)),alwaysSet:e in s.data});return s.common.async?ne.mergeObjectAsync(t,a):ne.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(t,s,a){return new e(s instanceof ge?{keyType:t,valueType:s,typeName:It.ZodRecord,...me(a)}:{keyType:Re.create(),valueType:t,typeName:It.ZodRecord,...me(s)})}},rt=class extends ge{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==V.map)return te(s,{code:B.invalid_type,expected:V.map,received:s.parsedType}),ie;const a=this._def.keyType,n=this._def.valueType,i=[...s.data.entries()].map((([e,t],i)=>({key:a._parse(new pe(s,e,s.path,[i,"key"])),value:n._parse(new pe(s,t,s.path,[i,"value"]))})));if(s.common.async){const e=new Map;return Promise.resolve().then((async()=>{for(const s of i){const a=await s.key,n=await s.value;if("aborted"===a.status||"aborted"===n.status)return ie;"dirty"!==a.status&&"dirty"!==n.status||t.dirty(),e.set(a.value,n.value)}return{status:t.value,value:e}}))}{const e=new Map;for(const s of i){const a=s.key,n=s.value;if("aborted"===a.status||"aborted"===n.status)return ie;"dirty"!==a.status&&"dirty"!==n.status||t.dirty(),e.set(a.value,n.value)}return{status:t.value,value:e}}}};rt.create=(e,t,s)=>new rt({valueType:t,keyType:e,typeName:It.ZodMap,...me(s)});var ot=class e extends ge{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==V.set)return te(s,{code:B.invalid_type,expected:V.set,received:s.parsedType}),ie;const a=this._def;null!==a.minSize&&s.data.size<a.minSize.value&&(te(s,{code:B.too_small,minimum:a.minSiz