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