zaileys 0.29.10-beta → 0.29.11-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +1 -1
- package/package.json +9 -4
- package/rollup.config.mjs +5 -5
- package/tsconfig.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("baileys"),t=require("node-cache"),s=require("pino"),a=require("better-sqlite3"),n=require("fs"),r=require("kysely"),i=require("mysql2"),o=require("path"),d=require("pg"),c=require("url"),u=require("crypto");const l=require("libsignal").curve,h=()=>{const{pubKey:e,privKey:t}=l.generateKeyPair();return{private:Buffer.from(t),public:Buffer.from(e.slice(1))}},p=(e,t)=>{const s=h(),a=(e=>33===e.length?e:Buffer.concat([Buffer.from([5]),e]))(s.public),n=((e,t)=>l.calculateSignature(e,t))(e.private,a);return{keyPair:s,signature:n,keyId:t}},m=e=>"string"==typeof e?parseInt(e,10):e,f=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:m(e.timestamp)};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},y=(e,t)=>"Buffer"===t?.type&&Array.isArray(t?.data)?{type:"Buffer",data:Buffer.from(t?.data).toString("base64")}:t,g=(e,t)=>"Buffer"===t?.type?Buffer.from(t?.data,"base64"):t,v=async(e,t)=>{const s="auth";await(async e=>{await e.schema.createTable("auth").ifNotExists().addColumn("session","varchar(50)",(e=>e.notNull())).addColumn("id","varchar(80)",(e=>e.notNull())).addColumn("value","text",(e=>e.defaultTo(null))).addUniqueConstraint("auth_session_id_unique",["session","id"]).execute(),await e.schema.createTable("chats").ifNotExists().addColumn("session","varchar(50)",(e=>e.notNull())).addColumn("id","varchar(80)",(e=>e.notNull())).addColumn("value","text",(e=>e.defaultTo(null))).addUniqueConstraint("chats_session_id_unique",["session","id"]).execute(),await e.schema.createTable("contacts").ifNotExists().addColumn("session","varchar(50)",(e=>e.notNull())).addColumn("id","varchar(80)",(e=>e.notNull())).addColumn("value","text",(e=>e.defaultTo(null))).addUniqueConstraint("contacts_session_id_unique",["session","id"]).execute(),await e.schema.createTable("messages").ifNotExists().addColumn("session","varchar(50)",(e=>e.notNull())).addColumn("id","varchar(80)",(e=>e.notNull())).addColumn("value","text",(e=>e.defaultTo(null))).addUniqueConstraint("messages_session_id_unique",["session","id"]).execute(),await e.schema.createIndex("auth_session_idx").ifNotExists().on("auth").column("session").execute(),await e.schema.createIndex("auth_id_idx").ifNotExists().on("auth").column("id").execute(),await e.schema.createIndex("chats_session_idx").ifNotExists().on("chats").column("session").execute(),await e.schema.createIndex("chats_id_idx").ifNotExists().on("chats").column("id").execute(),await e.schema.createIndex("contacts_session_idx").ifNotExists().on("contacts").column("session").execute(),await e.schema.createIndex("contacts_id_idx").ifNotExists().on("contacts").column("id").execute(),await e.schema.createIndex("messages_session_idx").ifNotExists().on("messages").column("session").execute(),await e.schema.createIndex("messages_id_idx").ifNotExists().on("messages").column("id").execute()})(e);const a=async e=>{for(let t=0;t<10;t++)try{return await e()}catch{await new Promise((e=>setTimeout(e,200)))}throw new Error("Max retries reached")},n=async n=>{const r=await a((()=>e.selectFrom(s).select(["value"]).where("id","=",n).where("session","=",t).executeTakeFirst()));if(!r?.value)return null;const i="object"==typeof r.value?JSON.stringify(r.value):r.value;return JSON.parse(i,g)},r=async(n,r)=>{const i=JSON.stringify(r,y);await a((()=>e.insertInto(s).values({session:t,id:n,value:i}).onConflict((e=>e.columns(["session","id"]).doUpdateSet({value:i}))).execute()))},i=async n=>{await a((()=>e.deleteFrom(s).where("id","=",n).where("session","=",t).execute()))},o=await n("creds")||(()=>{const e=h();return{noiseKey:h(),pairingEphemeralKeyPair:h(),signedIdentityKey:e,signedPreKey:p(e,1),registrationId:16383&Uint16Array.from(u.randomBytes(2))[0],advSecretKey:u.randomBytes(32).toString("base64"),processedHistoryMessages:[],nextPreKeyId:1,firstUnuploadedPreKeyId:1,accountSyncCounter:0,accountSettings:{unarchiveChats:!1},deviceId:Buffer.from(u.randomUUID().replace(/-/g,""),"hex").toString("base64url"),phoneId:u.randomUUID(),identityId:u.randomBytes(20),backupToken:u.randomBytes(20),registered:!1,registration:{},pairingCode:void 0,lastPropHash:void 0,routingInfo:void 0}})();return{state:{creds:o,keys:{get:async(e,t)=>{const s={};for(const a of t){let t=await n(`${e}-${a}`);"app-state-sync-key"===e&&t&&(t=f(t)),s[a]=t}return s},set:async e=>{for(const t in e)for(const s in e[t]){const a=e[t][s],n=`${t}-${s}`;a?await r(n,a):await i(n)}}}},saveCreds:async()=>{await r("creds",o)},clear:async()=>{await(async()=>{await a((()=>e.deleteFrom(s).where("session","=",t).where("id","!=","creds").execute()))})()},removeCreds:async()=>{await(async()=>{await a((()=>e.deleteFrom(s).where("session","=",t).execute()))})()}}};var _,x,b;(x=_||(_={})).assertEqual=e=>e,x.assertIs=function(e){},x.assertNever=function(e){throw new Error},x.arrayToEnum=e=>{const t={};for(const s of e)t[s]=s;return t},x.getValidEnumValues=e=>{const t=x.objectKeys(e).filter((t=>"number"!=typeof e[e[t]])),s={};for(const a of t)s[a]=e[a];return x.objectValues(s)},x.objectValues=e=>x.objectKeys(e).map((function(t){return e[t]})),x.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},x.find=(e,t)=>{for(const s of e)if(t(s))return s},x.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&isFinite(e)&&Math.floor(e)===e,x.joinValues=function(e,t=" | "){return e.map((e=>"string"==typeof e?`'${e}'`:e)).join(t)},x.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t,(b||(b={})).mergeShapes=(e,t)=>({...e,...t});const k=_.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 k.undefined;case"string":return k.string;case"number":return isNaN(e)?k.nan:k.number;case"boolean":return k.boolean;case"function":return k.function;case"bigint":return k.bigint;case"symbol":return k.symbol;case"object":return Array.isArray(e)?k.array:null===e?k.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?k.promise:typeof Map<"u"&&e instanceof Map?k.map:typeof Set<"u"&&e instanceof Set?k.set:typeof Date<"u"&&e instanceof Date?k.date:k.object;default:return k.unknown}},Z=_.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class T extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(e){return e.message},s={_errors:[]},a=e=>{for(const n of e.issues)if("invalid_union"===n.code)n.unionErrors.map(a);else if("invalid_return_type"===n.code)a(n.returnTypeError);else if("invalid_arguments"===n.code)a(n.argumentsError);else if(0===n.path.length)s._errors.push(t(n));else{let e=s,a=0;for(;a<n.path.length;){const s=n.path[a];a===n.path.length-1?(e[s]=e[s]||{_errors:[]},e[s]._errors.push(t(n))):e[s]=e[s]||{_errors:[]},e=e[s],a++}}};return a(this),s}static assert(e){if(!(e instanceof T))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,_.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()}}T.create=e=>new T(e);const C=(e,t)=>{let s;switch(e.code){case Z.invalid_type:s=e.received===k.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case Z.invalid_literal:s=`Invalid literal value, expected ${JSON.stringify(e.expected,_.jsonStringifyReplacer)}`;break;case Z.unrecognized_keys:s=`Unrecognized key(s) in object: ${_.joinValues(e.keys,", ")}`;break;case Z.invalid_union:s="Invalid input";break;case Z.invalid_union_discriminator:s=`Invalid discriminator value. Expected ${_.joinValues(e.options)}`;break;case Z.invalid_enum_value:s=`Invalid enum value. Expected ${_.joinValues(e.options)}, received '${e.received}'`;break;case Z.invalid_arguments:s="Invalid function arguments";break;case Z.invalid_return_type:s="Invalid function return type";break;case Z.invalid_date:s="Invalid date";break;case Z.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}"`:_.assertNever(e.validation):s="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case Z.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 Z.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 Z.custom:s="Invalid input";break;case Z.invalid_intersection_types:s="Intersection results could not be merged";break;case Z.not_multiple_of:s=`Number must be a multiple of ${e.multipleOf}`;break;case Z.not_finite:s="Number must be finite";break;default:s=t.defaultError,_.assertNever(e)}return{message:s}};let N=C;function O(){return N}const S=e=>{const{data:t,path:s,errorMaps:a,issueData:n}=e,r=[...s,...n.path||[]],i={...n,path:r};if(void 0!==n.message)return{...n,path:r,message:n.message};let o="";const d=a.filter((e=>!!e)).slice().reverse();for(const e of d)o=e(i,{data:t,defaultError:o}).message;return{...n,path:r,message:o}};function I(e,t){const s=O(),a=S({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,s,s===C?void 0:C].filter((e=>!!e))});e.common.issues.push(a)}class A{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 E;"dirty"===a.status&&e.dirty(),s.push(a.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const e of t){const t=await e.key,a=await e.value;s.push({key:t,value:a})}return A.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const a of t){const{key:t,value:n}=a;if("aborted"===t.status||"aborted"===n.status)return E;"dirty"===t.status&&e.dirty(),"dirty"===n.status&&e.dirty(),"__proto__"!==t.value&&(typeof n.value<"u"||a.alwaysSet)&&(s[t.value]=n.value)}return{status:e.value,value:s}}}const E=Object.freeze({status:"aborted"}),j=e=>({status:"dirty",value:e}),P=e=>({status:"valid",value:e}),R=e=>"aborted"===e.status,$=e=>"dirty"===e.status,M=e=>"valid"===e.status,F=e=>typeof Promise<"u"&&e instanceof Promise;function D(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)}function U(e,t,s,a,n){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,s):n?n.value=s:t.set(e,s),s}var L,q,z;"function"==typeof SuppressedError&&SuppressedError,function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:e?.message}(L||(L={}));class K{constructor(e,t,s,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=a}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const V=(e,t)=>{if(M(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 T(e.common.issues);return this._error=t,this._error}}};function B(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.');return t?{errorMap:t,description:n}:{errorMap:(t,n)=>{var r,i;const{message:o}=e;return"invalid_enum_value"===t.code?{message:o??n.defaultError}:typeof n.data>"u"?{message:null!==(r=o??a)&&void 0!==r?r:n.defaultError}:"invalid_type"!==t.code?{message:n.defaultError}:{message:null!==(i=o??s)&&void 0!==i?i:n.defaultError}},description:n}}class J{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 A,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(F(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;const a={common:{issues:[],async:null!==(s=t?.async)&&void 0!==s&&s,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:w(e)},n=this._parseSync({data:e,path:a.path,parent:a});return V(a,n)}"~validate"(e){var t,s;const a={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:w(e)};if(!this["~standard"].async)try{const t=this._parseSync({data:e,path:[],parent:a});return M(t)?{value:t.value}:{issues:a.common.issues}}catch(e){!(null===(s=null===(t=e?.message)||void 0===t?void 0:t.toLowerCase())||void 0===s)&&s.includes("encountered")&&(this["~standard"].async=!0),a.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:a}).then((e=>M(e)?{value:e.value}:{issues:a.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(F(a)?a:Promise.resolve(a));return V(s,n)}refine(e,t){const s=e=>"string"==typeof t||typeof t>"u"?{message:t}:"function"==typeof t?t(e):t;return this._refinement(((t,a)=>{const n=e(t),r=()=>a.addIssue({code:Z.custom,...s(t)});return typeof Promise<"u"&&n instanceof Promise?n.then((e=>!!e||(r(),!1))):!!n||(r(),!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 He({schema:this,typeName:dt.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 Ye.create(this,this._def)}nullable(){return Ge.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ie.create(this)}promise(){return We.create(this,this._def)}or(e){return je.create([this,e],this._def)}and(e){return Me.create(this,e,this._def)}transform(e){return new He({...B(this._def),schema:this,typeName:dt.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new Qe({...B(this._def),innerType:this,defaultValue:t,typeName:dt.ZodDefault})}brand(){return new st({typeName:dt.ZodBranded,type:this,...B(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new Xe({...B(this._def),innerType:this,catchValue:t,typeName:dt.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return at.create(this,e)}readonly(){return nt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const W=/^c[^\s-]{8,}$/i,H=/^[0-9a-z]+$/,Y=/^[0-9A-HJKMNP-TV-Z]{26}$/i,G=/^[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,Q=/^[a-z0-9_-]{21}$/i,X=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ee=/^[-+]?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)?)??$/,te=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let se;const ae=/^(?:(?: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])$/,ne=/^(?:(?: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])$/,re=/^(([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]))$/,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]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,oe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,de=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ce="((\\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])))",ue=new RegExp(`^${ce}$`);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 he(e){return new RegExp(`^${le(e)}$`)}function pe(e){let t=`${ce}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 me(e,t){return!(("v4"!==t&&t||!ae.test(e))&&("v6"!==t&&t||!re.test(e)))}function fe(e,t){if(!X.test(e))return!1;try{const[s]=e.split("."),a=s.replace(/-/g,"+").replace(/_/g,"/").padEnd(s.length+(4-s.length%4)%4,"="),n=JSON.parse(atob(a));return!("object"!=typeof n||null===n||!n.typ||!n.alg||t&&n.alg!==t)}catch{return!1}}function ye(e,t){return!(("v4"!==t&&t||!ne.test(e))&&("v6"!==t&&t||!ie.test(e)))}class ge extends J{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==k.string){const t=this._getOrReturnCtx(e);return I(t,{code:Z.invalid_type,expected:k.string,received:t.parsedType}),E}const t=new A;let s;for(const a of this._def.checks)if("min"===a.kind)e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),I(s,{code:Z.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),t.dirty());else if("max"===a.kind)e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),I(s,{code:Z.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),t.dirty());else if("length"===a.kind){const n=e.data.length>a.value,r=e.data.length<a.value;(n||r)&&(s=this._getOrReturnCtx(e,s),n?I(s,{code:Z.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):r&&I(s,{code:Z.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),t.dirty())}else if("email"===a.kind)te.test(e.data)||(s=this._getOrReturnCtx(e,s),I(s,{validation:"email",code:Z.invalid_string,message:a.message}),t.dirty());else if("emoji"===a.kind)se||(se=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),se.test(e.data)||(s=this._getOrReturnCtx(e,s),I(s,{validation:"emoji",code:Z.invalid_string,message:a.message}),t.dirty());else if("uuid"===a.kind)G.test(e.data)||(s=this._getOrReturnCtx(e,s),I(s,{validation:"uuid",code:Z.invalid_string,message:a.message}),t.dirty());else if("nanoid"===a.kind)Q.test(e.data)||(s=this._getOrReturnCtx(e,s),I(s,{validation:"nanoid",code:Z.invalid_string,message:a.message}),t.dirty());else if("cuid"===a.kind)W.test(e.data)||(s=this._getOrReturnCtx(e,s),I(s,{validation:"cuid",code:Z.invalid_string,message:a.message}),t.dirty());else if("cuid2"===a.kind)H.test(e.data)||(s=this._getOrReturnCtx(e,s),I(s,{validation:"cuid2",code:Z.invalid_string,message:a.message}),t.dirty());else if("ulid"===a.kind)Y.test(e.data)||(s=this._getOrReturnCtx(e,s),I(s,{validation:"ulid",code:Z.invalid_string,message:a.message}),t.dirty());else if("url"===a.kind)try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),I(s,{validation:"url",code:Z.invalid_string,message:a.message}),t.dirty()}else"regex"===a.kind?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),I(s,{validation:"regex",code:Z.invalid_string,message:a.message}),t.dirty())):"trim"===a.kind?e.data=e.data.trim():"includes"===a.kind?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),I(s,{code:Z.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),t.dirty()):"toLowerCase"===a.kind?e.data=e.data.toLowerCase():"toUpperCase"===a.kind?e.data=e.data.toUpperCase():"startsWith"===a.kind?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),I(s,{code:Z.invalid_string,validation:{startsWith:a.value},message:a.message}),t.dirty()):"endsWith"===a.kind?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),I(s,{code:Z.invalid_string,validation:{endsWith:a.value},message:a.message}),t.dirty()):"datetime"===a.kind?pe(a).test(e.data)||(s=this._getOrReturnCtx(e,s),I(s,{code:Z.invalid_string,validation:"datetime",message:a.message}),t.dirty()):"date"===a.kind?ue.test(e.data)||(s=this._getOrReturnCtx(e,s),I(s,{code:Z.invalid_string,validation:"date",message:a.message}),t.dirty()):"time"===a.kind?he(a).test(e.data)||(s=this._getOrReturnCtx(e,s),I(s,{code:Z.invalid_string,validation:"time",message:a.message}),t.dirty()):"duration"===a.kind?ee.test(e.data)||(s=this._getOrReturnCtx(e,s),I(s,{validation:"duration",code:Z.invalid_string,message:a.message}),t.dirty()):"ip"===a.kind?me(e.data,a.version)||(s=this._getOrReturnCtx(e,s),I(s,{validation:"ip",code:Z.invalid_string,message:a.message}),t.dirty()):"jwt"===a.kind?fe(e.data,a.alg)||(s=this._getOrReturnCtx(e,s),I(s,{validation:"jwt",code:Z.invalid_string,message:a.message}),t.dirty()):"cidr"===a.kind?ye(e.data,a.version)||(s=this._getOrReturnCtx(e,s),I(s,{validation:"cidr",code:Z.invalid_string,message:a.message}),t.dirty()):"base64"===a.kind?oe.test(e.data)||(s=this._getOrReturnCtx(e,s),I(s,{validation:"base64",code:Z.invalid_string,message:a.message}),t.dirty()):"base64url"===a.kind?de.test(e.data)||(s=this._getOrReturnCtx(e,s),I(s,{validation:"base64url",code:Z.invalid_string,message:a.message}),t.dirty()):_.assertNever(a);return{status:t.value,value:e.data}}_regex(e,t,s){return this.refinement((t=>e.test(t)),{validation:t,code:Z.invalid_string,...L.errToObj(s)})}_addCheck(e){return new ge({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...L.errToObj(e)})}url(e){return this._addCheck({kind:"url",...L.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...L.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...L.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...L.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...L.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...L.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...L.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...L.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...L.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...L.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...L.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...L.errToObj(e)})}datetime(e){var t,s;return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:null!==(t=e?.offset)&&void 0!==t&&t,local:null!==(s=e?.local)&&void 0!==s&&s,...L.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:typeof e?.precision>"u"?null:e?.precision,...L.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...L.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...L.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...L.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...L.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...L.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...L.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...L.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...L.errToObj(t)})}nonempty(e){return this.min(1,L.errToObj(e))}trim(){return new ge({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ge({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ge({...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 ve(e,t){const s=(e.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,n=s>a?s:a;return parseInt(e.toFixed(n).replace(".",""))%parseInt(t.toFixed(n).replace(".",""))/Math.pow(10,n)}ge.create=e=>{var t;return new ge({checks:[],typeName:dt.ZodString,coerce:null!==(t=e?.coerce)&&void 0!==t&&t,...B(e)})};class _e extends J{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==k.number){const t=this._getOrReturnCtx(e);return I(t,{code:Z.invalid_type,expected:k.number,received:t.parsedType}),E}let t;const s=new A;for(const a of this._def.checks)"int"===a.kind?_.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),I(t,{code:Z.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):"min"===a.kind?(a.inclusive?e.data<a.value:e.data<=a.value)&&(t=this._getOrReturnCtx(e,t),I(t,{code:Z.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):"max"===a.kind?(a.inclusive?e.data>a.value:e.data>=a.value)&&(t=this._getOrReturnCtx(e,t),I(t,{code:Z.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):"multipleOf"===a.kind?0!==ve(e.data,a.value)&&(t=this._getOrReturnCtx(e,t),I(t,{code:Z.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):"finite"===a.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),I(t,{code:Z.not_finite,message:a.message}),s.dirty()):_.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,L.toString(t))}gt(e,t){return this.setLimit("min",e,!1,L.toString(t))}lte(e,t){return this.setLimit("max",e,!0,L.toString(t))}lt(e,t){return this.setLimit("max",e,!1,L.toString(t))}setLimit(e,t,s,a){return new _e({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:L.toString(a)}]})}_addCheck(e){return new _e({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:L.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:L.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:L.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:L.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:L.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:L.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:L.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:L.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:L.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&&_.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)}}_e.create=e=>new _e({checks:[],typeName:dt.ZodNumber,coerce:e?.coerce||!1,...B(e)});class xe extends J{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)!==k.bigint)return this._getInvalidInput(e);let t;const s=new A;for(const a of this._def.checks)"min"===a.kind?(a.inclusive?e.data<a.value:e.data<=a.value)&&(t=this._getOrReturnCtx(e,t),I(t,{code:Z.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):"max"===a.kind?(a.inclusive?e.data>a.value:e.data>=a.value)&&(t=this._getOrReturnCtx(e,t),I(t,{code:Z.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):"multipleOf"===a.kind?e.data%a.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),I(t,{code:Z.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):_.assertNever(a);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return I(t,{code:Z.invalid_type,expected:k.bigint,received:t.parsedType}),E}gte(e,t){return this.setLimit("min",e,!0,L.toString(t))}gt(e,t){return this.setLimit("min",e,!1,L.toString(t))}lte(e,t){return this.setLimit("max",e,!0,L.toString(t))}lt(e,t){return this.setLimit("max",e,!1,L.toString(t))}setLimit(e,t,s,a){return new xe({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:L.toString(a)}]})}_addCheck(e){return new xe({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:L.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:L.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:L.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:L.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:L.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}}xe.create=e=>{var t;return new xe({checks:[],typeName:dt.ZodBigInt,coerce:null!==(t=e?.coerce)&&void 0!==t&&t,...B(e)})};class be extends J{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==k.boolean){const t=this._getOrReturnCtx(e);return I(t,{code:Z.invalid_type,expected:k.boolean,received:t.parsedType}),E}return P(e.data)}}be.create=e=>new be({typeName:dt.ZodBoolean,coerce:e?.coerce||!1,...B(e)});class ke extends J{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==k.date){const t=this._getOrReturnCtx(e);return I(t,{code:Z.invalid_type,expected:k.date,received:t.parsedType}),E}if(isNaN(e.data.getTime())){return I(this._getOrReturnCtx(e),{code:Z.invalid_date}),E}const t=new A;let s;for(const a of this._def.checks)"min"===a.kind?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),I(s,{code:Z.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),I(s,{code:Z.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),t.dirty()):_.assertNever(a);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ke({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:L.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:L.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}}ke.create=e=>new ke({checks:[],coerce:e?.coerce||!1,typeName:dt.ZodDate,...B(e)});class we extends J{_parse(e){if(this._getType(e)!==k.symbol){const t=this._getOrReturnCtx(e);return I(t,{code:Z.invalid_type,expected:k.symbol,received:t.parsedType}),E}return P(e.data)}}we.create=e=>new we({typeName:dt.ZodSymbol,...B(e)});class Ze extends J{_parse(e){if(this._getType(e)!==k.undefined){const t=this._getOrReturnCtx(e);return I(t,{code:Z.invalid_type,expected:k.undefined,received:t.parsedType}),E}return P(e.data)}}Ze.create=e=>new Ze({typeName:dt.ZodUndefined,...B(e)});class Te extends J{_parse(e){if(this._getType(e)!==k.null){const t=this._getOrReturnCtx(e);return I(t,{code:Z.invalid_type,expected:k.null,received:t.parsedType}),E}return P(e.data)}}Te.create=e=>new Te({typeName:dt.ZodNull,...B(e)});class Ce extends J{constructor(){super(...arguments),this._any=!0}_parse(e){return P(e.data)}}Ce.create=e=>new Ce({typeName:dt.ZodAny,...B(e)});class Ne extends J{constructor(){super(...arguments),this._unknown=!0}_parse(e){return P(e.data)}}Ne.create=e=>new Ne({typeName:dt.ZodUnknown,...B(e)});class Oe extends J{_parse(e){const t=this._getOrReturnCtx(e);return I(t,{code:Z.invalid_type,expected:k.never,received:t.parsedType}),E}}Oe.create=e=>new Oe({typeName:dt.ZodNever,...B(e)});class Se extends J{_parse(e){if(this._getType(e)!==k.undefined){const t=this._getOrReturnCtx(e);return I(t,{code:Z.invalid_type,expected:k.void,received:t.parsedType}),E}return P(e.data)}}Se.create=e=>new Se({typeName:dt.ZodVoid,...B(e)});class Ie extends J{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),a=this._def;if(t.parsedType!==k.array)return I(t,{code:Z.invalid_type,expected:k.array,received:t.parsedType}),E;if(null!==a.exactLength){const e=t.data.length>a.exactLength.value,n=t.data.length<a.exactLength.value;(e||n)&&(I(t,{code:e?Z.too_big:Z.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&&(I(t,{code:Z.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&&(I(t,{code:Z.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 K(t,e,t.path,s))))).then((e=>A.mergeArray(s,e)));const n=[...t.data].map(((e,s)=>a.type._parseSync(new K(t,e,t.path,s))));return A.mergeArray(s,n)}get element(){return this._def.type}min(e,t){return new Ie({...this._def,minLength:{value:e,message:L.toString(t)}})}max(e,t){return new Ie({...this._def,maxLength:{value:e,message:L.toString(t)}})}length(e,t){return new Ie({...this._def,exactLength:{value:e,message:L.toString(t)}})}nonempty(e){return this.min(1,e)}}function Ae(e){if(e instanceof Ee){const t={};for(const s in e.shape){const a=e.shape[s];t[s]=Ye.create(Ae(a))}return new Ee({...e._def,shape:()=>t})}return e instanceof Ie?new Ie({...e._def,type:Ae(e.element)}):e instanceof Ye?Ye.create(Ae(e.unwrap())):e instanceof Ge?Ge.create(Ae(e.unwrap())):e instanceof Fe?Fe.create(e.items.map((e=>Ae(e)))):e}Ie.create=(e,t)=>new Ie({type:e,minLength:null,maxLength:null,exactLength:null,typeName:dt.ZodArray,...B(t)});class Ee extends J{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const e=this._def.shape(),t=_.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==k.object){const t=this._getOrReturnCtx(e);return I(t,{code:Z.invalid_type,expected:k.object,received:t.parsedType}),E}const{status:t,ctx:s}=this._processInputParams(e),{shape:a,keys:n}=this._getCached(),r=[];if(!(this._def.catchall instanceof Oe&&"strip"===this._def.unknownKeys))for(const e in s.data)n.includes(e)||r.push(e);const i=[];for(const e of n){const t=a[e],n=s.data[e];i.push({key:{status:"valid",value:e},value:t._parse(new K(s,n,s.path,e)),alwaysSet:e in s.data})}if(this._def.catchall instanceof Oe){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of r)i.push({key:{status:"valid",value:e},value:{status:"valid",value:s.data[e]}});else if("strict"===e)r.length>0&&(I(s,{code:Z.unrecognized_keys,keys:r}),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 r){const a=s.data[t];i.push({key:{status:"valid",value:t},value:e._parse(new K(s,a,s.path,t)),alwaysSet:t in s.data})}}return s.common.async?Promise.resolve().then((async()=>{const e=[];for(const t of i){const s=await t.key,a=await t.value;e.push({key:s,value:a,alwaysSet:t.alwaysSet})}return e})).then((e=>A.mergeObjectSync(t,e))):A.mergeObjectSync(t,i)}get shape(){return this._def.shape()}strict(e){return new Ee({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,s)=>{var a,n,r,i;const o=null!==(r=null===(n=(a=this._def).errorMap)||void 0===n?void 0:n.call(a,t,s).message)&&void 0!==r?r:s.defaultError;return"unrecognized_keys"===t.code?{message:null!==(i=L.errToObj(e).message)&&void 0!==i?i:o}:{message:o}}}:{}})}strip(){return new Ee({...this._def,unknownKeys:"strip"})}passthrough(){return new Ee({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ee({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ee({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:dt.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ee({...this._def,catchall:e})}pick(e){const t={};return _.objectKeys(e).forEach((s=>{e[s]&&this.shape[s]&&(t[s]=this.shape[s])})),new Ee({...this._def,shape:()=>t})}omit(e){const t={};return _.objectKeys(this.shape).forEach((s=>{e[s]||(t[s]=this.shape[s])})),new Ee({...this._def,shape:()=>t})}deepPartial(){return Ae(this)}partial(e){const t={};return _.objectKeys(this.shape).forEach((s=>{const a=this.shape[s];e&&!e[s]?t[s]=a:t[s]=a.optional()})),new Ee({...this._def,shape:()=>t})}required(e){const t={};return _.objectKeys(this.shape).forEach((s=>{if(e&&!e[s])t[s]=this.shape[s];else{let e=this.shape[s];for(;e instanceof Ye;)e=e._def.innerType;t[s]=e}})),new Ee({...this._def,shape:()=>t})}keyof(){return Ve(_.objectKeys(this.shape))}}Ee.create=(e,t)=>new Ee({shape:()=>e,unknownKeys:"strip",catchall:Oe.create(),typeName:dt.ZodObject,...B(t)}),Ee.strictCreate=(e,t)=>new Ee({shape:()=>e,unknownKeys:"strict",catchall:Oe.create(),typeName:dt.ZodObject,...B(t)}),Ee.lazycreate=(e,t)=>new Ee({shape:e,unknownKeys:"strip",catchall:Oe.create(),typeName:dt.ZodObject,...B(t)});class je extends J{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;if(t.common.async)return Promise.all(s.map((async e=>{const s={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:s}),ctx:s}}))).then((function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const s of e)if("dirty"===s.result.status)return t.common.issues.push(...s.ctx.common.issues),s.result;const s=e.map((e=>new T(e.ctx.common.issues)));return I(t,{code:Z.invalid_union,unionErrors:s}),E}));{let e;const a=[];for(const n of s){const s={...t,common:{...t.common,issues:[]},parent:null},r=n._parseSync({data:t.data,path:t.path,parent:s});if("valid"===r.status)return r;"dirty"===r.status&&!e&&(e={result:r,ctx:s}),s.common.issues.length&&a.push(s.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const n=a.map((e=>new T(e)));return I(t,{code:Z.invalid_union,unionErrors:n}),E}}get options(){return this._def.options}}je.create=(e,t)=>new je({options:e,typeName:dt.ZodUnion,...B(t)});const Pe=e=>e instanceof ze?Pe(e.schema):e instanceof He?Pe(e.innerType()):e instanceof Ke?[e.value]:e instanceof Be?e.options:e instanceof Je?_.objectValues(e.enum):e instanceof Qe?Pe(e._def.innerType):e instanceof Ze?[void 0]:e instanceof Te?[null]:e instanceof Ye?[void 0,...Pe(e.unwrap())]:e instanceof Ge?[null,...Pe(e.unwrap())]:e instanceof st||e instanceof nt?Pe(e.unwrap()):e instanceof Xe?Pe(e._def.innerType):[];class Re extends J{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==k.object)return I(t,{code:Z.invalid_type,expected:k.object,received:t.parsedType}),E;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}):(I(t,{code:Z.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),E)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const a=new Map;for(const s of t){const t=Pe(s.shape[e]);if(!t.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const n of t){if(a.has(n))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(n)}`);a.set(n,s)}}return new Re({typeName:dt.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...B(s)})}}function $e(e,t){const s=w(e),a=w(t);if(e===t)return{valid:!0,data:e};if(s===k.object&&a===k.object){const s=_.objectKeys(t),a=_.objectKeys(e).filter((e=>-1!==s.indexOf(e))),n={...e,...t};for(const s of a){const a=$e(e[s],t[s]);if(!a.valid)return{valid:!1};n[s]=a.data}return{valid:!0,data:n}}if(s===k.array&&a===k.array){if(e.length!==t.length)return{valid:!1};const s=[];for(let a=0;a<e.length;a++){const n=$e(e[a],t[a]);if(!n.valid)return{valid:!1};s.push(n.data)}return{valid:!0,data:s}}return s===k.date&&a===k.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class Me extends J{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),a=(e,a)=>{if(R(e)||R(a))return E;const n=$e(e.value,a.value);return n.valid?(($(e)||$(a))&&t.dirty(),{status:t.value,value:n.data}):(I(s,{code:Z.invalid_intersection_types}),E)};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}))}}Me.create=(e,t,s)=>new Me({left:e,right:t,typeName:dt.ZodIntersection,...B(s)});class Fe extends J{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==k.array)return I(s,{code:Z.invalid_type,expected:k.array,received:s.parsedType}),E;if(s.data.length<this._def.items.length)return I(s,{code:Z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),E;!this._def.rest&&s.data.length>this._def.items.length&&(I(s,{code:Z.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 K(s,e,s.path,t)):null})).filter((e=>!!e));return s.common.async?Promise.all(a).then((e=>A.mergeArray(t,e))):A.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new Fe({...this._def,rest:e})}}Fe.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Fe({items:e,typeName:dt.ZodTuple,rest:null,...B(t)})};class De extends J{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!==k.object)return I(s,{code:Z.invalid_type,expected:k.object,received:s.parsedType}),E;const a=[],n=this._def.keyType,r=this._def.valueType;for(const e in s.data)a.push({key:n._parse(new K(s,e,s.path,e)),value:r._parse(new K(s,s.data[e],s.path,e)),alwaysSet:e in s.data});return s.common.async?A.mergeObjectAsync(t,a):A.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(e,t,s){return new De(t instanceof J?{keyType:e,valueType:t,typeName:dt.ZodRecord,...B(s)}:{keyType:ge.create(),valueType:e,typeName:dt.ZodRecord,...B(t)})}}class Ue extends J{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!==k.map)return I(s,{code:Z.invalid_type,expected:k.map,received:s.parsedType}),E;const a=this._def.keyType,n=this._def.valueType,r=[...s.data.entries()].map((([e,t],r)=>({key:a._parse(new K(s,e,s.path,[r,"key"])),value:n._parse(new K(s,t,s.path,[r,"value"]))})));if(s.common.async){const e=new Map;return Promise.resolve().then((async()=>{for(const s of r){const a=await s.key,n=await s.value;if("aborted"===a.status||"aborted"===n.status)return E;("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 r){const a=s.key,n=s.value;if("aborted"===a.status||"aborted"===n.status)return E;("dirty"===a.status||"dirty"===n.status)&&t.dirty(),e.set(a.value,n.value)}return{status:t.value,value:e}}}}Ue.create=(e,t,s)=>new Ue({valueType:t,keyType:e,typeName:dt.ZodMap,...B(s)});class Le extends J{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==k.set)return I(s,{code:Z.invalid_type,expected:k.set,received:s.parsedType}),E;const a=this._def;null!==a.minSize&&s.data.size<a.minSize.value&&(I(s,{code:Z.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),t.dirty()),null!==a.maxSize&&s.data.size>a.maxSize.value&&(I(s,{code:Z.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());const n=this._def.valueType;function r(e){const s=new Set;for(const a of e){if("aborted"===a.status)return E;"dirty"===a.status&&t.dirty(),s.add(a.value)}return{status:t.value,value:s}}const i=[...s.data.values()].map(((e,t)=>n._parse(new K(s,e,s.path,t))));return s.common.async?Promise.all(i).then((e=>r(e))):r(i)}min(e,t){return new Le({...this._def,minSize:{value:e,message:L.toString(t)}})}max(e,t){return new Le({...this._def,maxSize:{value:e,message:L.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Le.create=(e,t)=>new Le({valueType:e,minSize:null,maxSize:null,typeName:dt.ZodSet,...B(t)});class qe extends J{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==k.function)return I(t,{code:Z.invalid_type,expected:k.function,received:t.parsedType}),E;function s(e,s){return S({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,O(),C].filter((e=>!!e)),issueData:{code:Z.invalid_arguments,argumentsError:s}})}function a(e,s){return S({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,O(),C].filter((e=>!!e)),issueData:{code:Z.invalid_return_type,returnTypeError:s}})}const n={errorMap:t.common.contextualErrorMap},r=t.data;if(this._def.returns instanceof We){const e=this;return P((async function(...t){const i=new T([]),o=await e._def.args.parseAsync(t,n).catch((e=>{throw i.addIssue(s(t,e)),i})),d=await Reflect.apply(r,this,o);return await e._def.returns._def.type.parseAsync(d,n).catch((e=>{throw i.addIssue(a(d,e)),i}))}))}{const e=this;return P((function(...t){const i=e._def.args.safeParse(t,n);if(!i.success)throw new T([s(t,i.error)]);const o=Reflect.apply(r,this,i.data),d=e._def.returns.safeParse(o,n);if(!d.success)throw new T([a(o,d.error)]);return d.data}))}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new qe({...this._def,args:Fe.create(e).rest(Ne.create())})}returns(e){return new qe({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new qe({args:e||Fe.create([]).rest(Ne.create()),returns:t||Ne.create(),typeName:dt.ZodFunction,...B(s)})}}class ze extends J{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ze.create=(e,t)=>new ze({getter:e,typeName:dt.ZodLazy,...B(t)});class Ke extends J{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return I(t,{received:t.data,code:Z.invalid_literal,expected:this._def.value}),E}return{status:"valid",value:e.data}}get value(){return this._def.value}}function Ve(e,t){return new Be({values:e,typeName:dt.ZodEnum,...B(t)})}Ke.create=(e,t)=>new Ke({value:e,typeName:dt.ZodLiteral,...B(t)});class Be extends J{constructor(){super(...arguments),q.set(this,void 0)}_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),s=this._def.values;return I(t,{expected:_.joinValues(s),received:t.parsedType,code:Z.invalid_type}),E}if(D(this,q,"f")||U(this,q,new Set(this._def.values),"f"),!D(this,q,"f").has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return I(t,{received:t.data,code:Z.invalid_enum_value,options:s}),E}return P(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return Be.create(e,{...this._def,...t})}exclude(e,t=this._def){return Be.create(this.options.filter((t=>!e.includes(t))),{...this._def,...t})}}q=new WeakMap,Be.create=Ve;class Je extends J{constructor(){super(...arguments),z.set(this,void 0)}_parse(e){const t=_.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==k.string&&s.parsedType!==k.number){const e=_.objectValues(t);return I(s,{expected:_.joinValues(e),received:s.parsedType,code:Z.invalid_type}),E}if(D(this,z,"f")||U(this,z,new Set(_.getValidEnumValues(this._def.values)),"f"),!D(this,z,"f").has(e.data)){const e=_.objectValues(t);return I(s,{received:s.data,code:Z.invalid_enum_value,options:e}),E}return P(e.data)}get enum(){return this._def.values}}z=new WeakMap,Je.create=(e,t)=>new Je({values:e,typeName:dt.ZodNativeEnum,...B(t)});class We extends J{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==k.promise&&!1===t.common.async)return I(t,{code:Z.invalid_type,expected:k.promise,received:t.parsedType}),E;const s=t.parsedType===k.promise?t.data:Promise.resolve(t.data);return P(s.then((e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap}))))}}We.create=(e,t)=>new We({type:e,typeName:dt.ZodPromise,...B(t)});class He extends J{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===dt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),a=this._def.effect||null,n={addIssue:e=>{I(s,e),e.fatal?t.abort():t.dirty()},get path(){return s.path}};if(n.addIssue=n.addIssue.bind(n),"preprocess"===a.type){const e=a.transform(s.data,n);if(s.common.async)return Promise.resolve(e).then((async e=>{if("aborted"===t.value)return E;const a=await this._def.schema._parseAsync({data:e,path:s.path,parent:s});return"aborted"===a.status?E:"dirty"===a.status||"dirty"===t.value?j(a.value):a}));{if("aborted"===t.value)return E;const a=this._def.schema._parseSync({data:e,path:s.path,parent:s});return"aborted"===a.status?E:"dirty"===a.status||"dirty"===t.value?j(a.value):a}}if("refinement"===a.type){const e=e=>{const t=a.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 a=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return"aborted"===a.status?E:("dirty"===a.status&&t.dirty(),e(a.value),{status:t.value,value:a.value})}return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then((s=>"aborted"===s.status?E:("dirty"===s.status&&t.dirty(),e(s.value).then((()=>({status:t.value,value:s.value}))))))}if("transform"===a.type){if(!1===s.common.async){const e=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!M(e))return e;const r=a.transform(e.value,n);if(r instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:r}}return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then((e=>M(e)?Promise.resolve(a.transform(e.value,n)).then((e=>({status:t.value,value:e}))):e))}_.assertNever(a)}}He.create=(e,t,s)=>new He({schema:e,typeName:dt.ZodEffects,effect:t,...B(s)}),He.createWithPreprocess=(e,t,s)=>new He({schema:t,effect:{type:"preprocess",transform:e},typeName:dt.ZodEffects,...B(s)});class Ye extends J{_parse(e){return this._getType(e)===k.undefined?P(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ye.create=(e,t)=>new Ye({innerType:e,typeName:dt.ZodOptional,...B(t)});class Ge extends J{_parse(e){return this._getType(e)===k.null?P(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ge.create=(e,t)=>new Ge({innerType:e,typeName:dt.ZodNullable,...B(t)});class Qe extends J{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===k.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Qe.create=(e,t)=>new Qe({innerType:e,typeName:dt.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...B(t)});class Xe extends J{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return F(a)?a.then((e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new T(s.common.issues)},input:s.data})}))):{status:"valid",value:"valid"===a.status?a.value:this._def.catchValue({get error(){return new T(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}Xe.create=(e,t)=>new Xe({innerType:e,typeName:dt.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...B(t)});class et extends J{_parse(e){if(this._getType(e)!==k.nan){const t=this._getOrReturnCtx(e);return I(t,{code:Z.invalid_type,expected:k.nan,received:t.parsedType}),E}return{status:"valid",value:e.data}}}et.create=e=>new et({typeName:dt.ZodNaN,...B(e)});const tt=Symbol("zod_brand");class st extends J{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class at extends J{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const e=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return"aborted"===e.status?E:"dirty"===e.status?(t.dirty(),j(e.value)):this._def.out._parseAsync({data:e.value,path:s.path,parent:s})})();{const e=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return"aborted"===e.status?E:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:s.path,parent:s})}}static create(e,t){return new at({in:e,out:t,typeName:dt.ZodPipeline})}}class nt extends J{_parse(e){const t=this._def.innerType._parse(e),s=e=>(M(e)&&(e.value=Object.freeze(e.value)),e);return F(t)?t.then((e=>s(e))):s(t)}unwrap(){return this._def.innerType}}function rt(e,t){const s="function"==typeof e?e(t):"string"==typeof e?{message:e}:e;return"string"==typeof s?{message:s}:s}function it(e,t={},s){return e?Ce.create().superRefine(((a,n)=>{var r,i;const o=e(a);if(o instanceof Promise)return o.then((e=>{var r,i;if(!e){const e=rt(t,a),o=null===(i=null!==(r=e.fatal)&&void 0!==r?r:s)||void 0===i||i;n.addIssue({code:"custom",...e,fatal:o})}}));if(!o){const e=rt(t,a),o=null===(i=null!==(r=e.fatal)&&void 0!==r?r:s)||void 0===i||i;n.addIssue({code:"custom",...e,fatal:o})}})):Ce.create()}nt.create=(e,t)=>new nt({innerType:e,typeName:dt.ZodReadonly,...B(t)});const ot={object:Ee.lazycreate};var dt;!function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"}(dt||(dt={}));const ct=ge.create,ut=_e.create,lt=et.create,ht=xe.create,pt=be.create,mt=ke.create,ft=we.create,yt=Ze.create,gt=Te.create,vt=Ce.create,_t=Ne.create,xt=Oe.create,bt=Se.create,kt=Ie.create,wt=Ee.create,Zt=Ee.strictCreate,Tt=je.create,Ct=Re.create,Nt=Me.create,Ot=Fe.create,St=De.create,It=Ue.create,At=Le.create,Et=qe.create,jt=ze.create,Pt=Ke.create,Rt=Be.create,$t=Je.create,Mt=We.create,Ft=He.create,Dt=Ye.create,Ut=Ge.create,Lt=He.createWithPreprocess,qt=at.create,zt={string:e=>ge.create({...e,coerce:!0}),number:e=>_e.create({...e,coerce:!0}),boolean:e=>be.create({...e,coerce:!0}),bigint:e=>xe.create({...e,coerce:!0}),date:e=>ke.create({...e,coerce:!0})},Kt=E;var Vt=Object.freeze({__proto__:null,defaultErrorMap:C,setErrorMap:function(e){N=e},getErrorMap:O,makeIssue:S,EMPTY_PATH:[],addIssueToContext:I,ParseStatus:A,INVALID:E,DIRTY:j,OK:P,isAborted:R,isDirty:$,isValid:M,isAsync:F,get util(){return _},get objectUtil(){return b},ZodParsedType:k,getParsedType:w,ZodType:J,datetimeRegex:pe,ZodString:ge,ZodNumber:_e,ZodBigInt:xe,ZodBoolean:be,ZodDate:ke,ZodSymbol:we,ZodUndefined:Ze,ZodNull:Te,ZodAny:Ce,ZodUnknown:Ne,ZodNever:Oe,ZodVoid:Se,ZodArray:Ie,ZodObject:Ee,ZodUnion:je,ZodDiscriminatedUnion:Re,ZodIntersection:Me,ZodTuple:Fe,ZodRecord:De,ZodMap:Ue,ZodSet:Le,ZodFunction:qe,ZodLazy:ze,ZodLiteral:Ke,ZodEnum:Be,ZodNativeEnum:Je,ZodPromise:We,ZodEffects:He,ZodTransformer:He,ZodOptional:Ye,ZodNullable:Ge,ZodDefault:Qe,ZodCatch:Xe,ZodNaN:et,BRAND:tt,ZodBranded:st,ZodPipeline:at,ZodReadonly:nt,custom:it,Schema:J,ZodSchema:J,late:ot,get ZodFirstPartyTypeKind(){return dt},coerce:zt,any:vt,array:kt,bigint:ht,boolean:pt,date:mt,discriminatedUnion:Ct,effect:Ft,enum:Rt,function:Et,instanceof:(e,t={message:`Input not instance of ${e.name}`})=>it((t=>t instanceof e),t),intersection:Nt,lazy:jt,literal:Pt,map:It,nan:lt,nativeEnum:$t,never:xt,null:gt,nullable:Ut,number:ut,object:wt,oboolean:()=>pt().optional(),onumber:()=>ut().optional(),optional:Dt,ostring:()=>ct().optional(),pipeline:qt,preprocess:Lt,promise:Mt,record:St,set:At,strictObject:Zt,string:ct,symbol:ft,transformer:Ft,tuple:Ot,undefined:yt,union:Tt,unknown:_t,void:bt,NEVER:Kt,ZodIssueCode:Z,quotelessJson:e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),ZodError:T});const Bt=Vt.object({type:Vt.enum(["sqlite","postgresql","mysql"]).default("sqlite"),connection:Vt.object({url:Vt.string().default("./zaileys.db")}).optional().default({})}).optional().default({}),Jt={prefix:Vt.string().optional(),ignoreMe:Vt.boolean().optional().default(!0),showLogs:Vt.boolean().optional().default(!0),autoMentions:Vt.boolean().optional().default(!0),autoOnline:Vt.boolean().optional().default(!0),autoRead:Vt.boolean().optional().default(!0),autoRejectCall:Vt.boolean().optional().default(!0),database:Bt,citation:Vt.record(Vt.function().returns(Vt.union([Vt.number().array(),Vt.promise(Vt.number().array())]))).optional().transform((async e=>{const t={};if(e)for(const s of Object.keys(e)){const a=`is${s.charAt(0).toUpperCase()+s.slice(1)}`,n=await e[s]();t[a]=n}return t}))},Wt=Vt.object({authType:Vt.literal("pairing"),phoneNumber:Vt.number(),...Jt}),Ht=Vt.object({authType:Vt.literal("qr"),phoneNumber:Vt.undefined().optional(),...Jt}),Yt=Vt.discriminatedUnion("authType",[Wt,Ht]);var Gt=class{client;events=new Map;constructor(e){this.client=e}setup(t){t.ev.on("connection.update",(async t=>{const{connection:s,lastDisconnect:a,qr:n}=t;if(this.emit("connection",{status:s||"connecting"}),"qr"==this.client.options?.authType&&n&&console.log("Scan qrcode with your whatsapp: "),"close"===s){const t=a?.error?.output?.statusCode,s=t!==e.DisconnectReason.loggedOut;if(console.log(a?.error?.message),401==t||405==t||500==t)return;s&&await this.client.initialize()}else"open"===s&&this.emit("connection",{status:"open"})})),t.ev.on("messages.upsert",(({messages:e})=>{this.emit("messages",e)})),t.ev.on("call",(e=>{this.emit("call",e)}))}on(e,t){this.events.has(e)||this.events.set(e,[]),this.events.get(e).push(t)}emit(e,t){(this.events.get(e)||[]).forEach((e=>e(t)))}};var Qt=class{props;options;chatId="zaileys-chats";logger=s({level:"silent",enabled:!1});event;db;socket;groupCache=new t({stdTTL:300,useClones:!1});constructor(e){this.props=e,this.initialize(),this.event=new Gt(this)}async initialize(){this.options=await Yt.parseAsync(this.props),this.db=((e,t)=>{if("sqlite"===e){const e=t||"./db/zaileys.db",s=o.resolve(e);return n.mkdirSync(o.dirname(s),{recursive:!0}),n.writeFileSync(s,"",{flag:"a"}),new r.Kysely({dialect:new r.SqliteDialect({database:new a(s)})})}const s=new c.URL(t),u=s.protocol.replace(":","");if("mysql"===e)return new r.Kysely({dialect:new r.MysqlDialect({pool:i.createPool({host:s.hostname,user:s.username,password:s.password,database:s.pathname.replace("/",""),port:parseInt(s.port||"3306",10)})})});if("postgresql"===e)return new r.Kysely({dialect:new r.PostgresDialect({pool:new d.Pool({host:s.hostname,user:s.username,password:s.password,database:s.pathname.replace("/",""),port:parseInt(s.port||"5432",10)})})});throw new Error(`Unsupported database protocol: ${u}`)})(this.options.database.type,this.options.database.connection.url);const{state:s,saveCreds:u,removeCreds:l}=await v(this.db,this.chatId),h=await(async(e,t)=>({bind:s=>{s.on("messaging-history.set",(async s=>{const{chats:a,contacts:n,messages:r}=s;for(const s of a)await e.insertInto("chats").values({session:t,id:s.id,value:JSON.stringify(s)}).onConflict((e=>e.columns(["session","id"]).doUpdateSet({value:JSON.stringify(s)}))).execute();for(const s of n)await e.insertInto("contacts").values({session:t,id:s.id,value:JSON.stringify(s)}).onConflict((e=>e.columns(["session","id"]).doUpdateSet({value:JSON.stringify(s)}))).execute();for(const s of r)await e.insertInto("messages").values({session:t,id:s.key.id,value:JSON.stringify(s)}).onConflict((e=>e.columns(["session","id"]).doUpdateSet({value:JSON.stringify(s)}))).execute()})),s.on("messages.upsert",(async({messages:s})=>{for(const a of s)await e.insertInto("messages").values({session:t,id:a.key.id,value:JSON.stringify(a)}).onConflict((e=>e.columns(["session","id"]).doUpdateSet({value:JSON.stringify(a)}))).execute()})),s.on("chats.upsert",(async s=>{for(const a of s)await e.insertInto("chats").values({session:t,id:a.id,value:JSON.stringify(a)}).onConflict((e=>e.columns(["session","id"]).doUpdateSet({value:JSON.stringify(a)}))).execute()})),s.on("contacts.upsert",(async s=>{for(const a of s)await e.insertInto("contacts").values({session:t,id:a.id,value:JSON.stringify(a)}).onConflict((e=>e.columns(["session","id"]).doUpdateSet({value:JSON.stringify(a)}))).execute()}))}}))(this.db,this.chatId);this.socket=e({logger:this.logger,markOnlineOnConnect:this.options.autoOnline,syncFullHistory:!1,defaultQueryTimeoutMs:void 0,msgRetryCounterCache:new t,cachedGroupMetadata:async e=>this.groupCache.get(e),printQRInTerminal:"qr"==this.options.authType,browser:e.Browsers.ubuntu("qr"==this.options.authType?"Zaileys Library":"Firefox"),auth:{creds:s.creds,keys:e.makeCacheableSignalKeyStore(s.keys,this.logger)}}),"pairing"==this.options.authType&&this.options.phoneNumber&&!this.socket?.authState.creds.registered&&setTimeout((async()=>{try{if("pairing"==this.options?.authType){const e=await(this.socket?.requestPairingCode(this.options.phoneNumber.toString()));console.log("🚀 ~ Client.ts:53 ~ Client ~ setTimeout ~ code:",e)}}catch{console.log("Connection failed"),process.exit(1)}}),5e3),this.socket?.ev.on("creds.update",u),h.bind(this.socket?.ev),this.event.setup(this.socket)}on(e,t){this.event.on(e,t)}};module.exports=Qt;
|
|
1
|
+
"use strict";var e=require("baileys"),t=require("node-cache"),s=require("pino"),a=require("better-sqlite3"),n=require("fs"),r=require("kysely"),i=require("mysql2"),o=require("path"),d=require("pg"),c=require("url"),u=require("crypto"),l=require("libsignal");function h(e){return e&&e.__esModule?e:{default:e}}var p=h(e),m=h(t),f=h(s),y=h(a),g=h(i),v=h(o);const _=l.curve,x=()=>{const{pubKey:e,privKey:t}=_.generateKeyPair();return{private:Buffer.from(t),public:Buffer.from(e.slice(1))}},b=(e,t)=>{const s=x(),a=(e=>33===e.length?e:Buffer.concat([Buffer.from([5]),e]))(s.public),n=((e,t)=>_.calculateSignature(e,t))(e.private,a);return{keyPair:s,signature:n,keyId:t}},k=e=>"string"==typeof e?parseInt(e,10):e,w=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:k(e.timestamp)};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},Z=(e,t)=>"Buffer"===t?.type&&Array.isArray(t?.data)?{type:"Buffer",data:Buffer.from(t?.data).toString("base64")}:t,T=(e,t)=>"Buffer"===t?.type?Buffer.from(t?.data,"base64"):t,C=async(e,t)=>{const s="auth";await(async e=>{await e.schema.createTable("auth").ifNotExists().addColumn("session","varchar(50)",(e=>e.notNull())).addColumn("id","varchar(80)",(e=>e.notNull())).addColumn("value","text",(e=>e.defaultTo(null))).addUniqueConstraint("auth_session_id_unique",["session","id"]).execute(),await e.schema.createTable("chats").ifNotExists().addColumn("session","varchar(50)",(e=>e.notNull())).addColumn("id","varchar(80)",(e=>e.notNull())).addColumn("value","text",(e=>e.defaultTo(null))).addUniqueConstraint("chats_session_id_unique",["session","id"]).execute(),await e.schema.createTable("contacts").ifNotExists().addColumn("session","varchar(50)",(e=>e.notNull())).addColumn("id","varchar(80)",(e=>e.notNull())).addColumn("value","text",(e=>e.defaultTo(null))).addUniqueConstraint("contacts_session_id_unique",["session","id"]).execute(),await e.schema.createTable("messages").ifNotExists().addColumn("session","varchar(50)",(e=>e.notNull())).addColumn("id","varchar(80)",(e=>e.notNull())).addColumn("value","text",(e=>e.defaultTo(null))).addUniqueConstraint("messages_session_id_unique",["session","id"]).execute(),await e.schema.createIndex("auth_session_idx").ifNotExists().on("auth").column("session").execute(),await e.schema.createIndex("auth_id_idx").ifNotExists().on("auth").column("id").execute(),await e.schema.createIndex("chats_session_idx").ifNotExists().on("chats").column("session").execute(),await e.schema.createIndex("chats_id_idx").ifNotExists().on("chats").column("id").execute(),await e.schema.createIndex("contacts_session_idx").ifNotExists().on("contacts").column("session").execute(),await e.schema.createIndex("contacts_id_idx").ifNotExists().on("contacts").column("id").execute(),await e.schema.createIndex("messages_session_idx").ifNotExists().on("messages").column("session").execute(),await e.schema.createIndex("messages_id_idx").ifNotExists().on("messages").column("id").execute()})(e);const a=async e=>{for(let t=0;t<10;t++)try{return await e()}catch{await new Promise((e=>setTimeout(e,200)))}throw new Error("Max retries reached")},n=async n=>{const r=await a((()=>e.selectFrom(s).select(["value"]).where("id","=",n).where("session","=",t).executeTakeFirst()));if(!r?.value)return null;const i="object"==typeof r.value?JSON.stringify(r.value):r.value;return JSON.parse(i,T)},r=async(n,r)=>{const i=JSON.stringify(r,Z);await a((()=>e.insertInto(s).values({session:t,id:n,value:i}).onConflict((e=>e.columns(["session","id"]).doUpdateSet({value:i}))).execute()))},i=async n=>{await a((()=>e.deleteFrom(s).where("id","=",n).where("session","=",t).execute()))},o=await n("creds")||(()=>{const e=x();return{noiseKey:x(),pairingEphemeralKeyPair:x(),signedIdentityKey:e,signedPreKey:b(e,1),registrationId:16383&Uint16Array.from(u.randomBytes(2))[0],advSecretKey:u.randomBytes(32).toString("base64"),processedHistoryMessages:[],nextPreKeyId:1,firstUnuploadedPreKeyId:1,accountSyncCounter:0,accountSettings:{unarchiveChats:!1},deviceId:Buffer.from(u.randomUUID().replace(/-/g,""),"hex").toString("base64url"),phoneId:u.randomUUID(),identityId:u.randomBytes(20),backupToken:u.randomBytes(20),registered:!1,registration:{},pairingCode:void 0,lastPropHash:void 0,routingInfo:void 0}})();return{state:{creds:o,keys:{get:async(e,t)=>{const s={};for(const a of t){let t=await n(`${e}-${a}`);"app-state-sync-key"===e&&t&&(t=w(t)),s[a]=t}return s},set:async e=>{for(const t in e)for(const s in e[t]){const a=e[t][s],n=`${t}-${s}`;a?await r(n,a):await i(n)}}}},saveCreds:async()=>{await r("creds",o)},clear:async()=>{await(async()=>{await a((()=>e.deleteFrom(s).where("session","=",t).where("id","!=","creds").execute()))})()},removeCreds:async()=>{await(async()=>{await a((()=>e.deleteFrom(s).where("session","=",t).execute()))})()}}};var N,O,S;(O=N||(N={})).assertEqual=e=>e,O.assertIs=function(e){},O.assertNever=function(e){throw new Error},O.arrayToEnum=e=>{const t={};for(const s of e)t[s]=s;return t},O.getValidEnumValues=e=>{const t=O.objectKeys(e).filter((t=>"number"!=typeof e[e[t]])),s={};for(const a of t)s[a]=e[a];return O.objectValues(s)},O.objectValues=e=>O.objectKeys(e).map((function(t){return e[t]})),O.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},O.find=(e,t)=>{for(const s of e)if(t(s))return s},O.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&isFinite(e)&&Math.floor(e)===e,O.joinValues=function(e,t=" | "){return e.map((e=>"string"==typeof e?`'${e}'`:e)).join(t)},O.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t,(S||(S={})).mergeShapes=(e,t)=>({...e,...t});const I=N.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 I.undefined;case"string":return I.string;case"number":return isNaN(e)?I.nan:I.number;case"boolean":return I.boolean;case"function":return I.function;case"bigint":return I.bigint;case"symbol":return I.symbol;case"object":return Array.isArray(e)?I.array:null===e?I.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?I.promise:typeof Map<"u"&&e instanceof Map?I.map:typeof Set<"u"&&e instanceof Set?I.set:typeof Date<"u"&&e instanceof Date?I.date:I.object;default:return I.unknown}},E=N.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class j extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(e){return e.message},s={_errors:[]},a=e=>{for(const n of e.issues)if("invalid_union"===n.code)n.unionErrors.map(a);else if("invalid_return_type"===n.code)a(n.returnTypeError);else if("invalid_arguments"===n.code)a(n.argumentsError);else if(0===n.path.length)s._errors.push(t(n));else{let e=s,a=0;for(;a<n.path.length;){const s=n.path[a];a===n.path.length-1?(e[s]=e[s]||{_errors:[]},e[s]._errors.push(t(n))):e[s]=e[s]||{_errors:[]},e=e[s],a++}}};return a(this),s}static assert(e){if(!(e instanceof j))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,N.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t={},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);const P=(e,t)=>{let s;switch(e.code){case E.invalid_type:s=e.received===I.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case E.invalid_literal:s=`Invalid literal value, expected ${JSON.stringify(e.expected,N.jsonStringifyReplacer)}`;break;case E.unrecognized_keys:s=`Unrecognized key(s) in object: ${N.joinValues(e.keys,", ")}`;break;case E.invalid_union:s="Invalid input";break;case E.invalid_union_discriminator:s=`Invalid discriminator value. Expected ${N.joinValues(e.options)}`;break;case E.invalid_enum_value:s=`Invalid enum value. Expected ${N.joinValues(e.options)}, received '${e.received}'`;break;case E.invalid_arguments:s="Invalid function arguments";break;case E.invalid_return_type:s="Invalid function return type";break;case E.invalid_date:s="Invalid date";break;case E.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}"`:N.assertNever(e.validation):s="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case E.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 E.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 E.custom:s="Invalid input";break;case E.invalid_intersection_types:s="Intersection results could not be merged";break;case E.not_multiple_of:s=`Number must be a multiple of ${e.multipleOf}`;break;case E.not_finite:s="Number must be finite";break;default:s=t.defaultError,N.assertNever(e)}return{message:s}};let R=P;function $(){return R}const M=e=>{const{data:t,path:s,errorMaps:a,issueData:n}=e,r=[...s,...n.path||[]],i={...n,path:r};if(void 0!==n.message)return{...n,path:r,message:n.message};let o="";const d=a.filter((e=>!!e)).slice().reverse();for(const e of d)o=e(i,{data:t,defaultError:o}).message;return{...n,path:r,message:o}};function F(e,t){const s=$(),a=M({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,s,s===P?void 0:P].filter((e=>!!e))});e.common.issues.push(a)}class D{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 U;"dirty"===a.status&&e.dirty(),s.push(a.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const e of t){const t=await e.key,a=await e.value;s.push({key:t,value:a})}return D.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const a of t){const{key:t,value:n}=a;if("aborted"===t.status||"aborted"===n.status)return U;"dirty"===t.status&&e.dirty(),"dirty"===n.status&&e.dirty(),"__proto__"!==t.value&&(typeof n.value<"u"||a.alwaysSet)&&(s[t.value]=n.value)}return{status:e.value,value:s}}}const U=Object.freeze({status:"aborted"}),L=e=>({status:"dirty",value:e}),q=e=>({status:"valid",value:e}),z=e=>"aborted"===e.status,K=e=>"dirty"===e.status,V=e=>"valid"===e.status,B=e=>typeof Promise<"u"&&e instanceof Promise;function J(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)}function W(e,t,s,a,n){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,s):n?n.value=s:t.set(e,s),s}var H,Y,G;"function"==typeof SuppressedError&&SuppressedError,function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:e?.message}(H||(H={}));class Q{constructor(e,t,s,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=a}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const X=(e,t)=>{if(V(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new j(e.common.issues);return this._error=t,this._error}}};function ee(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.');return t?{errorMap:t,description:n}:{errorMap:(t,n)=>{var r,i;const{message:o}=e;return"invalid_enum_value"===t.code?{message:o??n.defaultError}:typeof n.data>"u"?{message:null!==(r=o??a)&&void 0!==r?r:n.defaultError}:"invalid_type"!==t.code?{message:n.defaultError}:{message:null!==(i=o??s)&&void 0!==i?i:n.defaultError}},description:n}}class te{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 D,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(B(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;const a={common:{issues:[],async:null!==(s=t?.async)&&void 0!==s&&s,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:A(e)},n=this._parseSync({data:e,path:a.path,parent:a});return X(a,n)}"~validate"(e){var t,s;const a={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:A(e)};if(!this["~standard"].async)try{const t=this._parseSync({data:e,path:[],parent:a});return V(t)?{value:t.value}:{issues:a.common.issues}}catch(e){!(null===(s=null===(t=e?.message)||void 0===t?void 0:t.toLowerCase())||void 0===s)&&s.includes("encountered")&&(this["~standard"].async=!0),a.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:a}).then((e=>V(e)?{value:e.value}:{issues:a.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:A(e)},a=this._parse({data:e,path:s.path,parent:s}),n=await(B(a)?a:Promise.resolve(a));return X(s,n)}refine(e,t){const s=e=>"string"==typeof t||typeof t>"u"?{message:t}:"function"==typeof t?t(e):t;return this._refinement(((t,a)=>{const n=e(t),r=()=>a.addIssue({code:E.custom,...s(t)});return typeof Promise<"u"&&n instanceof Promise?n.then((e=>!!e||(r(),!1))):!!n||(r(),!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 at({schema:this,typeName:yt.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 nt.create(this,this._def)}nullable(){return rt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Fe.create(this)}promise(){return st.create(this,this._def)}or(e){return Le.create([this,e],this._def)}and(e){return Ve.create(this,e,this._def)}transform(e){return new at({...ee(this._def),schema:this,typeName:yt.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new it({...ee(this._def),innerType:this,defaultValue:t,typeName:yt.ZodDefault})}brand(){return new ut({typeName:yt.ZodBranded,type:this,...ee(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new ot({...ee(this._def),innerType:this,catchValue:t,typeName:yt.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return lt.create(this,e)}readonly(){return ht.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const se=/^c[^\s-]{8,}$/i,ae=/^[0-9a-z]+$/,ne=/^[0-9A-HJKMNP-TV-Z]{26}$/i,re=/^[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,ie=/^[a-z0-9_-]{21}$/i,oe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,de=/^[-+]?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;let ue;const le=/^(?:(?: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])$/,he=/^(?:(?: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])$/,pe=/^(([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]))$/,me=/^(([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])$/,fe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ye=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ge="((\\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])))",ve=new RegExp(`^${ge}$`);function _e(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 xe(e){return new RegExp(`^${_e(e)}$`)}function be(e){let t=`${ge}T${_e(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 ke(e,t){return!(("v4"!==t&&t||!le.test(e))&&("v6"!==t&&t||!pe.test(e)))}function we(e,t){if(!oe.test(e))return!1;try{const[s]=e.split("."),a=s.replace(/-/g,"+").replace(/_/g,"/").padEnd(s.length+(4-s.length%4)%4,"="),n=JSON.parse(atob(a));return!("object"!=typeof n||null===n||!n.typ||!n.alg||t&&n.alg!==t)}catch{return!1}}function Ze(e,t){return!(("v4"!==t&&t||!he.test(e))&&("v6"!==t&&t||!me.test(e)))}class Te extends te{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==I.string){const t=this._getOrReturnCtx(e);return F(t,{code:E.invalid_type,expected:I.string,received:t.parsedType}),U}const t=new D;let s;for(const a of this._def.checks)if("min"===a.kind)e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),F(s,{code:E.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),t.dirty());else if("max"===a.kind)e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),F(s,{code:E.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),t.dirty());else if("length"===a.kind){const n=e.data.length>a.value,r=e.data.length<a.value;(n||r)&&(s=this._getOrReturnCtx(e,s),n?F(s,{code:E.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):r&&F(s,{code:E.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),t.dirty())}else if("email"===a.kind)ce.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"email",code:E.invalid_string,message:a.message}),t.dirty());else if("emoji"===a.kind)ue||(ue=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),ue.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"emoji",code:E.invalid_string,message:a.message}),t.dirty());else if("uuid"===a.kind)re.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"uuid",code:E.invalid_string,message:a.message}),t.dirty());else if("nanoid"===a.kind)ie.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"nanoid",code:E.invalid_string,message:a.message}),t.dirty());else if("cuid"===a.kind)se.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"cuid",code:E.invalid_string,message:a.message}),t.dirty());else if("cuid2"===a.kind)ae.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"cuid2",code:E.invalid_string,message:a.message}),t.dirty());else if("ulid"===a.kind)ne.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"ulid",code:E.invalid_string,message:a.message}),t.dirty());else if("url"===a.kind)try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),F(s,{validation:"url",code:E.invalid_string,message:a.message}),t.dirty()}else"regex"===a.kind?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"regex",code:E.invalid_string,message:a.message}),t.dirty())):"trim"===a.kind?e.data=e.data.trim():"includes"===a.kind?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),F(s,{code:E.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),t.dirty()):"toLowerCase"===a.kind?e.data=e.data.toLowerCase():"toUpperCase"===a.kind?e.data=e.data.toUpperCase():"startsWith"===a.kind?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),F(s,{code:E.invalid_string,validation:{startsWith:a.value},message:a.message}),t.dirty()):"endsWith"===a.kind?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),F(s,{code:E.invalid_string,validation:{endsWith:a.value},message:a.message}),t.dirty()):"datetime"===a.kind?be(a).test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{code:E.invalid_string,validation:"datetime",message:a.message}),t.dirty()):"date"===a.kind?ve.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{code:E.invalid_string,validation:"date",message:a.message}),t.dirty()):"time"===a.kind?xe(a).test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{code:E.invalid_string,validation:"time",message:a.message}),t.dirty()):"duration"===a.kind?de.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"duration",code:E.invalid_string,message:a.message}),t.dirty()):"ip"===a.kind?ke(e.data,a.version)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"ip",code:E.invalid_string,message:a.message}),t.dirty()):"jwt"===a.kind?we(e.data,a.alg)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"jwt",code:E.invalid_string,message:a.message}),t.dirty()):"cidr"===a.kind?Ze(e.data,a.version)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"cidr",code:E.invalid_string,message:a.message}),t.dirty()):"base64"===a.kind?fe.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"base64",code:E.invalid_string,message:a.message}),t.dirty()):"base64url"===a.kind?ye.test(e.data)||(s=this._getOrReturnCtx(e,s),F(s,{validation:"base64url",code:E.invalid_string,message:a.message}),t.dirty()):N.assertNever(a);return{status:t.value,value:e.data}}_regex(e,t,s){return this.refinement((t=>e.test(t)),{validation:t,code:E.invalid_string,...H.errToObj(s)})}_addCheck(e){return new Te({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...H.errToObj(e)})}url(e){return this._addCheck({kind:"url",...H.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...H.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...H.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...H.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...H.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...H.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...H.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...H.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...H.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...H.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...H.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...H.errToObj(e)})}datetime(e){var t,s;return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:null!==(t=e?.offset)&&void 0!==t&&t,local:null!==(s=e?.local)&&void 0!==s&&s,...H.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:typeof e?.precision>"u"?null:e?.precision,...H.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...H.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...H.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...H.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...H.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...H.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...H.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...H.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...H.errToObj(t)})}nonempty(e){return this.min(1,H.errToObj(e))}trim(){return new Te({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Te({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Te({...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 Ce(e,t){const s=(e.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,n=s>a?s:a;return parseInt(e.toFixed(n).replace(".",""))%parseInt(t.toFixed(n).replace(".",""))/Math.pow(10,n)}Te.create=e=>{var t;return new Te({checks:[],typeName:yt.ZodString,coerce:null!==(t=e?.coerce)&&void 0!==t&&t,...ee(e)})};class Ne extends te{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==I.number){const t=this._getOrReturnCtx(e);return F(t,{code:E.invalid_type,expected:I.number,received:t.parsedType}),U}let t;const s=new D;for(const a of this._def.checks)"int"===a.kind?N.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),F(t,{code:E.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):"min"===a.kind?(a.inclusive?e.data<a.value:e.data<=a.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:E.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):"max"===a.kind?(a.inclusive?e.data>a.value:e.data>=a.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:E.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):"multipleOf"===a.kind?0!==Ce(e.data,a.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:E.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):"finite"===a.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),F(t,{code:E.not_finite,message:a.message}),s.dirty()):N.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,H.toString(t))}gt(e,t){return this.setLimit("min",e,!1,H.toString(t))}lte(e,t){return this.setLimit("max",e,!0,H.toString(t))}lt(e,t){return this.setLimit("max",e,!1,H.toString(t))}setLimit(e,t,s,a){return new Ne({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:H.toString(a)}]})}_addCheck(e){return new Ne({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:H.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:H.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:H.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:H.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:H.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:H.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:H.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:H.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:H.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find((e=>"int"===e.kind||"multipleOf"===e.kind&&N.isInteger(e.value)))}get isFinite(){let e=null,t=null;for(const 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)}}Ne.create=e=>new Ne({checks:[],typeName:yt.ZodNumber,coerce:e?.coerce||!1,...ee(e)});class Oe extends te{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)!==I.bigint)return this._getInvalidInput(e);let t;const s=new D;for(const a of this._def.checks)"min"===a.kind?(a.inclusive?e.data<a.value:e.data<=a.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:E.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):"max"===a.kind?(a.inclusive?e.data>a.value:e.data>=a.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:E.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):"multipleOf"===a.kind?e.data%a.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),F(t,{code:E.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):N.assertNever(a);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return F(t,{code:E.invalid_type,expected:I.bigint,received:t.parsedType}),U}gte(e,t){return this.setLimit("min",e,!0,H.toString(t))}gt(e,t){return this.setLimit("min",e,!1,H.toString(t))}lte(e,t){return this.setLimit("max",e,!0,H.toString(t))}lt(e,t){return this.setLimit("max",e,!1,H.toString(t))}setLimit(e,t,s,a){return new Oe({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:H.toString(a)}]})}_addCheck(e){return new Oe({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:H.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:H.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:H.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:H.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:H.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}}Oe.create=e=>{var t;return new Oe({checks:[],typeName:yt.ZodBigInt,coerce:null!==(t=e?.coerce)&&void 0!==t&&t,...ee(e)})};class Se extends te{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==I.boolean){const t=this._getOrReturnCtx(e);return F(t,{code:E.invalid_type,expected:I.boolean,received:t.parsedType}),U}return q(e.data)}}Se.create=e=>new Se({typeName:yt.ZodBoolean,coerce:e?.coerce||!1,...ee(e)});class Ie extends te{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==I.date){const t=this._getOrReturnCtx(e);return F(t,{code:E.invalid_type,expected:I.date,received:t.parsedType}),U}if(isNaN(e.data.getTime())){return F(this._getOrReturnCtx(e),{code:E.invalid_date}),U}const t=new D;let s;for(const a of this._def.checks)"min"===a.kind?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),F(s,{code:E.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),F(s,{code:E.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),t.dirty()):N.assertNever(a);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ie({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:H.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:H.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}}Ie.create=e=>new Ie({checks:[],coerce:e?.coerce||!1,typeName:yt.ZodDate,...ee(e)});class Ae extends te{_parse(e){if(this._getType(e)!==I.symbol){const t=this._getOrReturnCtx(e);return F(t,{code:E.invalid_type,expected:I.symbol,received:t.parsedType}),U}return q(e.data)}}Ae.create=e=>new Ae({typeName:yt.ZodSymbol,...ee(e)});class Ee extends te{_parse(e){if(this._getType(e)!==I.undefined){const t=this._getOrReturnCtx(e);return F(t,{code:E.invalid_type,expected:I.undefined,received:t.parsedType}),U}return q(e.data)}}Ee.create=e=>new Ee({typeName:yt.ZodUndefined,...ee(e)});class je extends te{_parse(e){if(this._getType(e)!==I.null){const t=this._getOrReturnCtx(e);return F(t,{code:E.invalid_type,expected:I.null,received:t.parsedType}),U}return q(e.data)}}je.create=e=>new je({typeName:yt.ZodNull,...ee(e)});class Pe extends te{constructor(){super(...arguments),this._any=!0}_parse(e){return q(e.data)}}Pe.create=e=>new Pe({typeName:yt.ZodAny,...ee(e)});class Re extends te{constructor(){super(...arguments),this._unknown=!0}_parse(e){return q(e.data)}}Re.create=e=>new Re({typeName:yt.ZodUnknown,...ee(e)});class $e extends te{_parse(e){const t=this._getOrReturnCtx(e);return F(t,{code:E.invalid_type,expected:I.never,received:t.parsedType}),U}}$e.create=e=>new $e({typeName:yt.ZodNever,...ee(e)});class Me extends te{_parse(e){if(this._getType(e)!==I.undefined){const t=this._getOrReturnCtx(e);return F(t,{code:E.invalid_type,expected:I.void,received:t.parsedType}),U}return q(e.data)}}Me.create=e=>new Me({typeName:yt.ZodVoid,...ee(e)});class Fe extends te{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),a=this._def;if(t.parsedType!==I.array)return F(t,{code:E.invalid_type,expected:I.array,received:t.parsedType}),U;if(null!==a.exactLength){const e=t.data.length>a.exactLength.value,n=t.data.length<a.exactLength.value;(e||n)&&(F(t,{code:e?E.too_big:E.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&&(F(t,{code:E.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&&(F(t,{code:E.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 Q(t,e,t.path,s))))).then((e=>D.mergeArray(s,e)));const n=[...t.data].map(((e,s)=>a.type._parseSync(new Q(t,e,t.path,s))));return D.mergeArray(s,n)}get element(){return this._def.type}min(e,t){return new Fe({...this._def,minLength:{value:e,message:H.toString(t)}})}max(e,t){return new Fe({...this._def,maxLength:{value:e,message:H.toString(t)}})}length(e,t){return new Fe({...this._def,exactLength:{value:e,message:H.toString(t)}})}nonempty(e){return this.min(1,e)}}function De(e){if(e instanceof Ue){const t={};for(const s in e.shape){const a=e.shape[s];t[s]=nt.create(De(a))}return new Ue({...e._def,shape:()=>t})}return e instanceof Fe?new Fe({...e._def,type:De(e.element)}):e instanceof nt?nt.create(De(e.unwrap())):e instanceof rt?rt.create(De(e.unwrap())):e instanceof Be?Be.create(e.items.map((e=>De(e)))):e}Fe.create=(e,t)=>new Fe({type:e,minLength:null,maxLength:null,exactLength:null,typeName:yt.ZodArray,...ee(t)});class Ue extends te{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const e=this._def.shape(),t=N.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==I.object){const t=this._getOrReturnCtx(e);return F(t,{code:E.invalid_type,expected:I.object,received:t.parsedType}),U}const{status:t,ctx:s}=this._processInputParams(e),{shape:a,keys:n}=this._getCached(),r=[];if(!(this._def.catchall instanceof $e&&"strip"===this._def.unknownKeys))for(const e in s.data)n.includes(e)||r.push(e);const i=[];for(const e of n){const t=a[e],n=s.data[e];i.push({key:{status:"valid",value:e},value:t._parse(new Q(s,n,s.path,e)),alwaysSet:e in s.data})}if(this._def.catchall instanceof $e){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of r)i.push({key:{status:"valid",value:e},value:{status:"valid",value:s.data[e]}});else if("strict"===e)r.length>0&&(F(s,{code:E.unrecognized_keys,keys:r}),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 r){const a=s.data[t];i.push({key:{status:"valid",value:t},value:e._parse(new Q(s,a,s.path,t)),alwaysSet:t in s.data})}}return s.common.async?Promise.resolve().then((async()=>{const e=[];for(const t of i){const s=await t.key,a=await t.value;e.push({key:s,value:a,alwaysSet:t.alwaysSet})}return e})).then((e=>D.mergeObjectSync(t,e))):D.mergeObjectSync(t,i)}get shape(){return this._def.shape()}strict(e){return new Ue({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,s)=>{var a,n,r,i;const o=null!==(r=null===(n=(a=this._def).errorMap)||void 0===n?void 0:n.call(a,t,s).message)&&void 0!==r?r:s.defaultError;return"unrecognized_keys"===t.code?{message:null!==(i=H.errToObj(e).message)&&void 0!==i?i:o}:{message:o}}}:{}})}strip(){return new Ue({...this._def,unknownKeys:"strip"})}passthrough(){return new Ue({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ue({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ue({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:yt.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ue({...this._def,catchall:e})}pick(e){const t={};return N.objectKeys(e).forEach((s=>{e[s]&&this.shape[s]&&(t[s]=this.shape[s])})),new Ue({...this._def,shape:()=>t})}omit(e){const t={};return N.objectKeys(this.shape).forEach((s=>{e[s]||(t[s]=this.shape[s])})),new Ue({...this._def,shape:()=>t})}deepPartial(){return De(this)}partial(e){const t={};return N.objectKeys(this.shape).forEach((s=>{const a=this.shape[s];e&&!e[s]?t[s]=a:t[s]=a.optional()})),new Ue({...this._def,shape:()=>t})}required(e){const t={};return N.objectKeys(this.shape).forEach((s=>{if(e&&!e[s])t[s]=this.shape[s];else{let e=this.shape[s];for(;e instanceof nt;)e=e._def.innerType;t[s]=e}})),new Ue({...this._def,shape:()=>t})}keyof(){return Xe(N.objectKeys(this.shape))}}Ue.create=(e,t)=>new Ue({shape:()=>e,unknownKeys:"strip",catchall:$e.create(),typeName:yt.ZodObject,...ee(t)}),Ue.strictCreate=(e,t)=>new Ue({shape:()=>e,unknownKeys:"strict",catchall:$e.create(),typeName:yt.ZodObject,...ee(t)}),Ue.lazycreate=(e,t)=>new Ue({shape:e,unknownKeys:"strip",catchall:$e.create(),typeName:yt.ZodObject,...ee(t)});class Le extends te{_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 F(t,{code:E.invalid_union,unionErrors:s}),U}));{let e;const a=[];for(const n of s){const s={...t,common:{...t.common,issues:[]},parent:null},r=n._parseSync({data:t.data,path:t.path,parent:s});if("valid"===r.status)return r;"dirty"===r.status&&!e&&(e={result:r,ctx:s}),s.common.issues.length&&a.push(s.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const n=a.map((e=>new j(e)));return F(t,{code:E.invalid_union,unionErrors:n}),U}}get options(){return this._def.options}}Le.create=(e,t)=>new Le({options:e,typeName:yt.ZodUnion,...ee(t)});const qe=e=>e instanceof Ge?qe(e.schema):e instanceof at?qe(e.innerType()):e instanceof Qe?[e.value]:e instanceof et?e.options:e instanceof tt?N.objectValues(e.enum):e instanceof it?qe(e._def.innerType):e instanceof Ee?[void 0]:e instanceof je?[null]:e instanceof nt?[void 0,...qe(e.unwrap())]:e instanceof rt?[null,...qe(e.unwrap())]:e instanceof ut||e instanceof ht?qe(e.unwrap()):e instanceof ot?qe(e._def.innerType):[];class ze extends te{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==I.object)return F(t,{code:E.invalid_type,expected:I.object,received:t.parsedType}),U;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}):(F(t,{code:E.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),U)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const a=new Map;for(const s of t){const t=qe(s.shape[e]);if(!t.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const n of t){if(a.has(n))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(n)}`);a.set(n,s)}}return new ze({typeName:yt.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...ee(s)})}}function Ke(e,t){const s=A(e),a=A(t);if(e===t)return{valid:!0,data:e};if(s===I.object&&a===I.object){const s=N.objectKeys(t),a=N.objectKeys(e).filter((e=>-1!==s.indexOf(e))),n={...e,...t};for(const s of a){const a=Ke(e[s],t[s]);if(!a.valid)return{valid:!1};n[s]=a.data}return{valid:!0,data:n}}if(s===I.array&&a===I.array){if(e.length!==t.length)return{valid:!1};const s=[];for(let a=0;a<e.length;a++){const n=Ke(e[a],t[a]);if(!n.valid)return{valid:!1};s.push(n.data)}return{valid:!0,data:s}}return s===I.date&&a===I.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class Ve extends te{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),a=(e,a)=>{if(z(e)||z(a))return U;const n=Ke(e.value,a.value);return n.valid?((K(e)||K(a))&&t.dirty(),{status:t.value,value:n.data}):(F(s,{code:E.invalid_intersection_types}),U)};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}))}}Ve.create=(e,t,s)=>new Ve({left:e,right:t,typeName:yt.ZodIntersection,...ee(s)});class Be extends te{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==I.array)return F(s,{code:E.invalid_type,expected:I.array,received:s.parsedType}),U;if(s.data.length<this._def.items.length)return F(s,{code:E.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),U;!this._def.rest&&s.data.length>this._def.items.length&&(F(s,{code:E.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 Q(s,e,s.path,t)):null})).filter((e=>!!e));return s.common.async?Promise.all(a).then((e=>D.mergeArray(t,e))):D.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new Be({...this._def,rest:e})}}Be.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Be({items:e,typeName:yt.ZodTuple,rest:null,...ee(t)})};class Je extends te{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==I.object)return F(s,{code:E.invalid_type,expected:I.object,received:s.parsedType}),U;const a=[],n=this._def.keyType,r=this._def.valueType;for(const e in s.data)a.push({key:n._parse(new Q(s,e,s.path,e)),value:r._parse(new Q(s,s.data[e],s.path,e)),alwaysSet:e in s.data});return s.common.async?D.mergeObjectAsync(t,a):D.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(e,t,s){return new Je(t instanceof te?{keyType:e,valueType:t,typeName:yt.ZodRecord,...ee(s)}:{keyType:Te.create(),valueType:e,typeName:yt.ZodRecord,...ee(t)})}}class We extends te{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==I.map)return F(s,{code:E.invalid_type,expected:I.map,received:s.parsedType}),U;const a=this._def.keyType,n=this._def.valueType,r=[...s.data.entries()].map((([e,t],r)=>({key:a._parse(new Q(s,e,s.path,[r,"key"])),value:n._parse(new Q(s,t,s.path,[r,"value"]))})));if(s.common.async){const e=new Map;return Promise.resolve().then((async()=>{for(const s of r){const a=await s.key,n=await s.value;if("aborted"===a.status||"aborted"===n.status)return U;("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 r){const a=s.key,n=s.value;if("aborted"===a.status||"aborted"===n.status)return U;("dirty"===a.status||"dirty"===n.status)&&t.dirty(),e.set(a.value,n.value)}return{status:t.value,value:e}}}}We.create=(e,t,s)=>new We({valueType:t,keyType:e,typeName:yt.ZodMap,...ee(s)});class He extends te{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==I.set)return F(s,{code:E.invalid_type,expected:I.set,received:s.parsedType}),U;const a=this._def;null!==a.minSize&&s.data.size<a.minSize.value&&(F(s,{code:E.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),t.dirty()),null!==a.maxSize&&s.data.size>a.maxSize.value&&(F(s,{code:E.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());const n=this._def.valueType;function r(e){const s=new Set;for(const a of e){if("aborted"===a.status)return U;"dirty"===a.status&&t.dirty(),s.add(a.value)}return{status:t.value,value:s}}const i=[...s.data.values()].map(((e,t)=>n._parse(new Q(s,e,s.path,t))));return s.common.async?Promise.all(i).then((e=>r(e))):r(i)}min(e,t){return new He({...this._def,minSize:{value:e,message:H.toString(t)}})}max(e,t){return new He({...this._def,maxSize:{value:e,message:H.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}He.create=(e,t)=>new He({valueType:e,minSize:null,maxSize:null,typeName:yt.ZodSet,...ee(t)});class Ye extends te{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==I.function)return F(t,{code:E.invalid_type,expected:I.function,received:t.parsedType}),U;function s(e,s){return M({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,$(),P].filter((e=>!!e)),issueData:{code:E.invalid_arguments,argumentsError:s}})}function a(e,s){return M({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,$(),P].filter((e=>!!e)),issueData:{code:E.invalid_return_type,returnTypeError:s}})}const n={errorMap:t.common.contextualErrorMap},r=t.data;if(this._def.returns instanceof st){const e=this;return q((async function(...t){const i=new j([]),o=await e._def.args.parseAsync(t,n).catch((e=>{throw i.addIssue(s(t,e)),i})),d=await Reflect.apply(r,this,o);return await e._def.returns._def.type.parseAsync(d,n).catch((e=>{throw i.addIssue(a(d,e)),i}))}))}{const e=this;return q((function(...t){const i=e._def.args.safeParse(t,n);if(!i.success)throw new j([s(t,i.error)]);const o=Reflect.apply(r,this,i.data),d=e._def.returns.safeParse(o,n);if(!d.success)throw new j([a(o,d.error)]);return d.data}))}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ye({...this._def,args:Be.create(e).rest(Re.create())})}returns(e){return new Ye({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new Ye({args:e||Be.create([]).rest(Re.create()),returns:t||Re.create(),typeName:yt.ZodFunction,...ee(s)})}}class Ge extends te{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})}}Ge.create=(e,t)=>new Ge({getter:e,typeName:yt.ZodLazy,...ee(t)});class Qe extends te{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return F(t,{received:t.data,code:E.invalid_literal,expected:this._def.value}),U}return{status:"valid",value:e.data}}get value(){return this._def.value}}function Xe(e,t){return new et({values:e,typeName:yt.ZodEnum,...ee(t)})}Qe.create=(e,t)=>new Qe({value:e,typeName:yt.ZodLiteral,...ee(t)});class et extends te{constructor(){super(...arguments),Y.set(this,void 0)}_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),s=this._def.values;return F(t,{expected:N.joinValues(s),received:t.parsedType,code:E.invalid_type}),U}if(J(this,Y,"f")||W(this,Y,new Set(this._def.values),"f"),!J(this,Y,"f").has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return F(t,{received:t.data,code:E.invalid_enum_value,options:s}),U}return q(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return et.create(e,{...this._def,...t})}exclude(e,t=this._def){return et.create(this.options.filter((t=>!e.includes(t))),{...this._def,...t})}}Y=new WeakMap,et.create=Xe;class tt extends te{constructor(){super(...arguments),G.set(this,void 0)}_parse(e){const t=N.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==I.string&&s.parsedType!==I.number){const e=N.objectValues(t);return F(s,{expected:N.joinValues(e),received:s.parsedType,code:E.invalid_type}),U}if(J(this,G,"f")||W(this,G,new Set(N.getValidEnumValues(this._def.values)),"f"),!J(this,G,"f").has(e.data)){const e=N.objectValues(t);return F(s,{received:s.data,code:E.invalid_enum_value,options:e}),U}return q(e.data)}get enum(){return this._def.values}}G=new WeakMap,tt.create=(e,t)=>new tt({values:e,typeName:yt.ZodNativeEnum,...ee(t)});class st extends te{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==I.promise&&!1===t.common.async)return F(t,{code:E.invalid_type,expected:I.promise,received:t.parsedType}),U;const s=t.parsedType===I.promise?t.data:Promise.resolve(t.data);return q(s.then((e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap}))))}}st.create=(e,t)=>new st({type:e,typeName:yt.ZodPromise,...ee(t)});class at extends te{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===yt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),a=this._def.effect||null,n={addIssue:e=>{F(s,e),e.fatal?t.abort():t.dirty()},get path(){return s.path}};if(n.addIssue=n.addIssue.bind(n),"preprocess"===a.type){const e=a.transform(s.data,n);if(s.common.async)return Promise.resolve(e).then((async e=>{if("aborted"===t.value)return U;const a=await this._def.schema._parseAsync({data:e,path:s.path,parent:s});return"aborted"===a.status?U:"dirty"===a.status||"dirty"===t.value?L(a.value):a}));{if("aborted"===t.value)return U;const a=this._def.schema._parseSync({data:e,path:s.path,parent:s});return"aborted"===a.status?U:"dirty"===a.status||"dirty"===t.value?L(a.value):a}}if("refinement"===a.type){const e=e=>{const t=a.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 a=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return"aborted"===a.status?U:("dirty"===a.status&&t.dirty(),e(a.value),{status:t.value,value:a.value})}return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then((s=>"aborted"===s.status?U:("dirty"===s.status&&t.dirty(),e(s.value).then((()=>({status:t.value,value:s.value}))))))}if("transform"===a.type){if(!1===s.common.async){const e=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!V(e))return e;const r=a.transform(e.value,n);if(r instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:r}}return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then((e=>V(e)?Promise.resolve(a.transform(e.value,n)).then((e=>({status:t.value,value:e}))):e))}N.assertNever(a)}}at.create=(e,t,s)=>new at({schema:e,typeName:yt.ZodEffects,effect:t,...ee(s)}),at.createWithPreprocess=(e,t,s)=>new at({schema:t,effect:{type:"preprocess",transform:e},typeName:yt.ZodEffects,...ee(s)});class nt extends te{_parse(e){return this._getType(e)===I.undefined?q(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}nt.create=(e,t)=>new nt({innerType:e,typeName:yt.ZodOptional,...ee(t)});class rt extends te{_parse(e){return this._getType(e)===I.null?q(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}rt.create=(e,t)=>new rt({innerType:e,typeName:yt.ZodNullable,...ee(t)});class it extends te{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===I.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}it.create=(e,t)=>new it({innerType:e,typeName:yt.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...ee(t)});class ot extends te{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return B(a)?a.then((e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new j(s.common.issues)},input:s.data})}))):{status:"valid",value:"valid"===a.status?a.value:this._def.catchValue({get error(){return new j(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}ot.create=(e,t)=>new ot({innerType:e,typeName:yt.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...ee(t)});class dt extends te{_parse(e){if(this._getType(e)!==I.nan){const t=this._getOrReturnCtx(e);return F(t,{code:E.invalid_type,expected:I.nan,received:t.parsedType}),U}return{status:"valid",value:e.data}}}dt.create=e=>new dt({typeName:yt.ZodNaN,...ee(e)});const ct=Symbol("zod_brand");class ut extends te{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class lt extends te{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const e=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return"aborted"===e.status?U:"dirty"===e.status?(t.dirty(),L(e.value)):this._def.out._parseAsync({data:e.value,path:s.path,parent:s})})();{const e=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return"aborted"===e.status?U:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:s.path,parent:s})}}static create(e,t){return new lt({in:e,out:t,typeName:yt.ZodPipeline})}}class ht extends te{_parse(e){const t=this._def.innerType._parse(e),s=e=>(V(e)&&(e.value=Object.freeze(e.value)),e);return B(t)?t.then((e=>s(e))):s(t)}unwrap(){return this._def.innerType}}function pt(e,t){const s="function"==typeof e?e(t):"string"==typeof e?{message:e}:e;return"string"==typeof s?{message:s}:s}function mt(e,t={},s){return e?Pe.create().superRefine(((a,n)=>{var r,i;const o=e(a);if(o instanceof Promise)return o.then((e=>{var r,i;if(!e){const e=pt(t,a),o=null===(i=null!==(r=e.fatal)&&void 0!==r?r:s)||void 0===i||i;n.addIssue({code:"custom",...e,fatal:o})}}));if(!o){const e=pt(t,a),o=null===(i=null!==(r=e.fatal)&&void 0!==r?r:s)||void 0===i||i;n.addIssue({code:"custom",...e,fatal:o})}})):Pe.create()}ht.create=(e,t)=>new ht({innerType:e,typeName:yt.ZodReadonly,...ee(t)});const ft={object:Ue.lazycreate};var yt;!function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"}(yt||(yt={}));const gt=Te.create,vt=Ne.create,_t=dt.create,xt=Oe.create,bt=Se.create,kt=Ie.create,wt=Ae.create,Zt=Ee.create,Tt=je.create,Ct=Pe.create,Nt=Re.create,Ot=$e.create,St=Me.create,It=Fe.create,At=Ue.create,Et=Ue.strictCreate,jt=Le.create,Pt=ze.create,Rt=Ve.create,$t=Be.create,Mt=Je.create,Ft=We.create,Dt=He.create,Ut=Ye.create,Lt=Ge.create,qt=Qe.create,zt=et.create,Kt=tt.create,Vt=st.create,Bt=at.create,Jt=nt.create,Wt=rt.create,Ht=at.createWithPreprocess,Yt=lt.create,Gt={string:e=>Te.create({...e,coerce:!0}),number:e=>Ne.create({...e,coerce:!0}),boolean:e=>Se.create({...e,coerce:!0}),bigint:e=>Oe.create({...e,coerce:!0}),date:e=>Ie.create({...e,coerce:!0})},Qt=U;var Xt=Object.freeze({__proto__:null,defaultErrorMap:P,setErrorMap:function(e){R=e},getErrorMap:$,makeIssue:M,EMPTY_PATH:[],addIssueToContext:F,ParseStatus:D,INVALID:U,DIRTY:L,OK:q,isAborted:z,isDirty:K,isValid:V,isAsync:B,get util(){return N},get objectUtil(){return S},ZodParsedType:I,getParsedType:A,ZodType:te,datetimeRegex:be,ZodString:Te,ZodNumber:Ne,ZodBigInt:Oe,ZodBoolean:Se,ZodDate:Ie,ZodSymbol:Ae,ZodUndefined:Ee,ZodNull:je,ZodAny:Pe,ZodUnknown:Re,ZodNever:$e,ZodVoid:Me,ZodArray:Fe,ZodObject:Ue,ZodUnion:Le,ZodDiscriminatedUnion:ze,ZodIntersection:Ve,ZodTuple:Be,ZodRecord:Je,ZodMap:We,ZodSet:He,ZodFunction:Ye,ZodLazy:Ge,ZodLiteral:Qe,ZodEnum:et,ZodNativeEnum:tt,ZodPromise:st,ZodEffects:at,ZodTransformer:at,ZodOptional:nt,ZodNullable:rt,ZodDefault:it,ZodCatch:ot,ZodNaN:dt,BRAND:ct,ZodBranded:ut,ZodPipeline:lt,ZodReadonly:ht,custom:mt,Schema:te,ZodSchema:te,late:ft,get ZodFirstPartyTypeKind(){return yt},coerce:Gt,any:Ct,array:It,bigint:xt,boolean:bt,date:kt,discriminatedUnion:Pt,effect:Bt,enum:zt,function:Ut,instanceof:(e,t={message:`Input not instance of ${e.name}`})=>mt((t=>t instanceof e),t),intersection:Rt,lazy:Lt,literal:qt,map:Ft,nan:_t,nativeEnum:Kt,never:Ot,null:Tt,nullable:Wt,number:vt,object:At,oboolean:()=>bt().optional(),onumber:()=>vt().optional(),optional:Jt,ostring:()=>gt().optional(),pipeline:Yt,preprocess:Ht,promise:Vt,record:Mt,set:Dt,strictObject:Et,string:gt,symbol:wt,transformer:Bt,tuple:$t,undefined:Zt,union:jt,unknown:Nt,void:St,NEVER:Qt,ZodIssueCode:E,quotelessJson:e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),ZodError:j});const es=Xt.object({type:Xt.enum(["sqlite","postgresql","mysql"]).default("sqlite"),connection:Xt.object({url:Xt.string().default("./zaileys.db")}).optional().default({})}).optional().default({}),ts={prefix:Xt.string().optional(),ignoreMe:Xt.boolean().optional().default(!0),showLogs:Xt.boolean().optional().default(!0),autoMentions:Xt.boolean().optional().default(!0),autoOnline:Xt.boolean().optional().default(!0),autoRead:Xt.boolean().optional().default(!0),autoRejectCall:Xt.boolean().optional().default(!0),database:es,citation:Xt.record(Xt.function().returns(Xt.union([Xt.number().array(),Xt.promise(Xt.number().array())]))).optional().transform((async e=>{const t={};if(e)for(const s of Object.keys(e)){const a=`is${s.charAt(0).toUpperCase()+s.slice(1)}`,n=await e[s]();t[a]=n}return t}))},ss=Xt.object({authType:Xt.literal("pairing"),phoneNumber:Xt.number(),...ts}),as=Xt.object({authType:Xt.literal("qr"),phoneNumber:Xt.undefined().optional(),...ts}),ns=Xt.discriminatedUnion("authType",[ss,as]);var rs=class{client;events=new Map;constructor(e){this.client=e}setup(t){t.ev.on("connection.update",(async t=>{const{connection:s,lastDisconnect:a,qr:n}=t;if(this.emit("connection",{status:s||"connecting"}),"qr"==this.client.options?.authType&&n&&console.log("Scan qrcode with your whatsapp: "),"close"===s){const t=a?.error?.output?.statusCode,s=t!==e.DisconnectReason.loggedOut;if(console.log(a?.error?.message),401==t||405==t||500==t)return;s&&await this.client.initialize()}else"open"===s&&this.emit("connection",{status:"open"})})),t.ev.on("messages.upsert",(({messages:e})=>{this.emit("messages",e)})),t.ev.on("call",(e=>{this.emit("call",e)}))}on(e,t){this.events.has(e)||this.events.set(e,[]),this.events.get(e).push(t)}emit(e,t){(this.events.get(e)||[]).forEach((e=>e(t)))}};var is=class{props;options;chatId="zaileys-chats";logger=f.default({level:"silent",enabled:!1});event;db;socket;groupCache=new m.default({stdTTL:300,useClones:!1});constructor(e){this.props=e,this.initialize(),this.event=new rs(this)}async initialize(){this.options=await ns.parseAsync(this.props),this.db=((e,t)=>{if("sqlite"===e){const e=t||"./db/zaileys.db",s=v.default.resolve(e);return n.mkdirSync(v.default.dirname(s),{recursive:!0}),n.writeFileSync(s,"",{flag:"a"}),new r.Kysely({dialect:new r.SqliteDialect({database:new y.default(s)})})}const s=new c.URL(t),a=s.protocol.replace(":","");if("mysql"===e)return new r.Kysely({dialect:new r.MysqlDialect({pool:g.default.createPool({host:s.hostname,user:s.username,password:s.password,database:s.pathname.replace("/",""),port:parseInt(s.port||"3306",10)})})});if("postgresql"===e)return new r.Kysely({dialect:new r.PostgresDialect({pool:new d.Pool({host:s.hostname,user:s.username,password:s.password,database:s.pathname.replace("/",""),port:parseInt(s.port||"5432",10)})})});throw new Error(`Unsupported database protocol: ${a}`)})(this.options.database.type,this.options.database.connection.url);const{state:t,saveCreds:s,removeCreds:a}=await C(this.db,this.chatId),i=await(async(e,t)=>({bind:s=>{s.on("messaging-history.set",(async s=>{const{chats:a,contacts:n,messages:r}=s;for(const s of a)await e.insertInto("chats").values({session:t,id:s.id,value:JSON.stringify(s)}).onConflict((e=>e.columns(["session","id"]).doUpdateSet({value:JSON.stringify(s)}))).execute();for(const s of n)await e.insertInto("contacts").values({session:t,id:s.id,value:JSON.stringify(s)}).onConflict((e=>e.columns(["session","id"]).doUpdateSet({value:JSON.stringify(s)}))).execute();for(const s of r)await e.insertInto("messages").values({session:t,id:s.key.id,value:JSON.stringify(s)}).onConflict((e=>e.columns(["session","id"]).doUpdateSet({value:JSON.stringify(s)}))).execute()})),s.on("messages.upsert",(async({messages:s})=>{for(const a of s)await e.insertInto("messages").values({session:t,id:a.key.id,value:JSON.stringify(a)}).onConflict((e=>e.columns(["session","id"]).doUpdateSet({value:JSON.stringify(a)}))).execute()})),s.on("chats.upsert",(async s=>{for(const a of s)await e.insertInto("chats").values({session:t,id:a.id,value:JSON.stringify(a)}).onConflict((e=>e.columns(["session","id"]).doUpdateSet({value:JSON.stringify(a)}))).execute()})),s.on("contacts.upsert",(async s=>{for(const a of s)await e.insertInto("contacts").values({session:t,id:a.id,value:JSON.stringify(a)}).onConflict((e=>e.columns(["session","id"]).doUpdateSet({value:JSON.stringify(a)}))).execute()}))}}))(this.db,this.chatId);this.socket=p.default({logger:this.logger,markOnlineOnConnect:this.options.autoOnline,syncFullHistory:!1,defaultQueryTimeoutMs:void 0,msgRetryCounterCache:new m.default,cachedGroupMetadata:async e=>this.groupCache.get(e),printQRInTerminal:"qr"==this.options.authType,browser:e.Browsers.ubuntu("qr"==this.options.authType?"Zaileys Library":"Firefox"),auth:{creds:t.creds,keys:e.makeCacheableSignalKeyStore(t.keys,this.logger)}}),"pairing"==this.options.authType&&this.options.phoneNumber&&!this.socket?.authState.creds.registered&&setTimeout((async()=>{try{if("pairing"==this.options?.authType){const e=await(this.socket?.requestPairingCode(this.options.phoneNumber.toString()));console.log("🚀 ~ Client.ts:53 ~ Client ~ setTimeout ~ code:",e)}}catch{console.log("Connection failed"),process.exit(1)}}),5e3),this.socket?.ev.on("creds.update",s),i.bind(this.socket?.ev),this.event.setup(this.socket)}on(e,t){this.event.on(e,t)}};module.exports=is;
|
package/package.json
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zaileys",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.11-beta",
|
|
4
4
|
"description": "Zaileys - Simplify Typescript/Javascript WhatsApp NodeJS API",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"require":
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
"require": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.cjs.js"
|
|
13
|
+
},
|
|
14
|
+
"import": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.esm.js"
|
|
17
|
+
}
|
|
13
18
|
}
|
|
14
19
|
},
|
|
15
20
|
"scripts": {
|
package/rollup.config.mjs
CHANGED
|
@@ -17,13 +17,14 @@ export default [
|
|
|
17
17
|
},
|
|
18
18
|
output: [
|
|
19
19
|
{
|
|
20
|
-
file: pkg.exports['.'].require,
|
|
20
|
+
file: pkg.exports['.'].require.default,
|
|
21
21
|
format: 'cjs',
|
|
22
22
|
sourcemap: false,
|
|
23
|
-
exports: 'auto'
|
|
23
|
+
exports: 'auto',
|
|
24
|
+
interop: 'auto'
|
|
24
25
|
},
|
|
25
26
|
{
|
|
26
|
-
file: pkg.exports['.'].import,
|
|
27
|
+
file: pkg.exports['.'].import.default,
|
|
27
28
|
format: 'esm',
|
|
28
29
|
sourcemap: false
|
|
29
30
|
}
|
|
@@ -34,8 +35,7 @@ export default [
|
|
|
34
35
|
}),
|
|
35
36
|
commonjs(),
|
|
36
37
|
typescript({
|
|
37
|
-
tsconfig: './tsconfig.json'
|
|
38
|
-
declaration: false
|
|
38
|
+
tsconfig: './tsconfig.json'
|
|
39
39
|
}),
|
|
40
40
|
minify(),
|
|
41
41
|
strip({ functions: ['assert.*'] }),
|
package/tsconfig.json
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
"module": "ESNext",
|
|
5
5
|
"moduleResolution": "Node",
|
|
6
6
|
"esModuleInterop": true,
|
|
7
|
+
"allowSyntheticDefaultImports": true,
|
|
7
8
|
"strict": true,
|
|
8
9
|
"noImplicitAny": true,
|
|
9
10
|
"skipLibCheck": true,
|
|
@@ -11,8 +12,7 @@
|
|
|
11
12
|
"declarationDir": "dist",
|
|
12
13
|
"outDir": "dist",
|
|
13
14
|
"rootDir": "src",
|
|
14
|
-
"resolveJsonModule": true
|
|
15
|
-
"allowSyntheticDefaultImports": true
|
|
15
|
+
"resolveJsonModule": true
|
|
16
16
|
},
|
|
17
17
|
"include": ["src/**/*"],
|
|
18
18
|
"exclude": ["node_modules", "dist"]
|