UNPKG

@chatwork/mcp-server

Version:

MCP (Model Context Protocol) server for operating Chatwork from AI

2 lines 120 kB
#! /usr/bin/env node import sr from"node:process";var k;(function(r){r.assertEqual=a=>a;function e(a){}r.assertIs=e;function t(a){throw new Error}r.assertNever=t,r.arrayToEnum=a=>{let o={};for(let i of a)o[i]=i;return o},r.getValidEnumValues=a=>{let o=r.objectKeys(a).filter(c=>typeof a[a[c]]!="number"),i={};for(let c of o)i[c]=a[c];return r.objectValues(i)},r.objectValues=a=>r.objectKeys(a).map(function(o){return a[o]}),r.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{let o=[];for(let i in a)Object.prototype.hasOwnProperty.call(a,i)&&o.push(i);return o},r.find=(a,o)=>{for(let i of a)if(o(i))return i},r.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&isFinite(a)&&Math.floor(a)===a;function s(a,o=" | "){return a.map(i=>typeof i=="string"?`'${i}'`:i).join(o)}r.joinValues=s,r.jsonStringifyReplacer=(a,o)=>typeof o=="bigint"?o.toString():o})(k||(k={}));var gt;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(gt||(gt={}));var f=k.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),J=r=>{switch(typeof r){case"undefined":return f.undefined;case"string":return f.string;case"number":return isNaN(r)?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(r)?f.array:r===null?f.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?f.promise:typeof Map<"u"&&r instanceof Map?f.map:typeof Set<"u"&&r instanceof Set?f.set:typeof Date<"u"&&r instanceof Date?f.date:f.object;default:return f.unknown}},d=k.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"]),Vs=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),I=class r extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(o){return o.message},s={_errors:[]},a=o=>{for(let i of o.issues)if(i.code==="invalid_union")i.unionErrors.map(a);else if(i.code==="invalid_return_type")a(i.returnTypeError);else if(i.code==="invalid_arguments")a(i.argumentsError);else if(i.path.length===0)s._errors.push(t(i));else{let c=s,l=0;for(;l<i.path.length;){let u=i.path[l];l===i.path.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(t(i))):c[u]=c[u]||{_errors:[]},c=c[u],l++}}};return a(this),s}static assert(e){if(!(e instanceof r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,k.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},s=[];for(let 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()}};I.create=r=>new I(r);var xe=(r,e)=>{let t;switch(r.code){case d.invalid_type:r.received===f.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case d.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,k.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:t=`Unrecognized key(s) in object: ${k.joinValues(r.keys,", ")}`;break;case d.invalid_union:t="Invalid input";break;case d.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${k.joinValues(r.options)}`;break;case d.invalid_enum_value:t=`Invalid enum value. Expected ${k.joinValues(r.options)}, received '${r.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 r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:k.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case d.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case d.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.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 ${r.multipleOf}`;break;case d.not_finite:t="Number must be finite";break;default:t=e.defaultError,k.assertNever(r)}return{message:t}},Nt=xe;function Fs(r){Nt=r}function Ze(){return Nt}var $e=r=>{let{data:e,path:t,errorMaps:s,issueData:a}=r,o=[...t,...a.path||[]],i={...a,path:o};if(a.message!==void 0)return{...a,path:o,message:a.message};let c="",l=s.filter(u=>!!u).slice().reverse();for(let u of l)c=u(i,{data:e,defaultError:c}).message;return{...a,path:o,message:c}},Us=[];function h(r,e){let t=Ze(),s=$e({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===xe?void 0:xe].filter(a=>!!a)});r.common.issues.push(s)}var j=class r{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let s=[];for(let a of t){if(a.status==="aborted")return y;a.status==="dirty"&&e.dirty(),s.push(a.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){let s=[];for(let a of t){let o=await a.key,i=await a.value;s.push({key:o,value:i})}return r.mergeObjectSync(e,s)}static mergeObjectSync(e,t){let s={};for(let a of t){let{key:o,value:i}=a;if(o.status==="aborted"||i.status==="aborted")return y;o.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof i.value<"u"||a.alwaysSet)&&(s[o.value]=i.value)}return{status:e.value,value:s}}},y=Object.freeze({status:"aborted"}),be=r=>({status:"dirty",value:r}),E=r=>({status:"valid",value:r}),_t=r=>r.status==="aborted",yt=r=>r.status==="dirty",re=r=>r.status==="valid",Ae=r=>typeof Promise<"u"&&r instanceof Promise;function qe(r,e,t,s){if(t==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?s:t==="a"?s.call(r):s?s.value:e.get(r)}function Zt(r,e,t,s,a){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!a)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!a:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?a.call(r,t):a?a.value=t:e.set(r,t),t}var g;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message})(g||(g={}));var Ce,Ee,q=class{constructor(e,t,s,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=a}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Ot=(r,e)=>{if(re(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new I(r.common.issues);return this._error=t,this._error}}};function b(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:s,description:a}=r;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:a}:{errorMap:(i,c)=>{var l,u;let{message:p}=r;return i.code==="invalid_enum_value"?{message:p??c.defaultError}:typeof c.data>"u"?{message:(l=p??s)!==null&&l!==void 0?l:c.defaultError}:i.code!=="invalid_type"?{message:c.defaultError}:{message:(u=p??t)!==null&&u!==void 0?u:c.defaultError}},description:a}}var v=class{get description(){return this._def.description}_getType(e){return J(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:J(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new j,ctx:{common:e.parent.common,data:e.data,parsedType:J(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(Ae(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;let a={common:{issues:[],async:(s=t?.async)!==null&&s!==void 0?s:!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:J(e)},o=this._parseSync({data:e,path:a.path,parent:a});return Ot(a,o)}"~validate"(e){var t,s;let a={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:J(e)};if(!this["~standard"].async)try{let o=this._parseSync({data:e,path:[],parent:a});return re(o)?{value:o.value}:{issues:a.common.issues}}catch(o){!((s=(t=o?.message)===null||t===void 0?void 0:t.toLowerCase())===null||s===void 0)&&s.includes("encountered")&&(this["~standard"].async=!0),a.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:a}).then(o=>re(o)?{value:o.value}:{issues:a.common.issues})}async parseAsync(e,t){let s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){let s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:J(e)},a=this._parse({data:e,path:s.path,parent:s}),o=await(Ae(a)?a:Promise.resolve(a));return Ot(s,o)}refine(e,t){let s=a=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(a):t;return this._refinement((a,o)=>{let i=e(a),c=()=>o.addIssue({code:d.custom,...s(a)});return typeof Promise<"u"&&i instanceof Promise?i.then(l=>l?!0:(c(),!1)):i?!0:(c(),!1)})}refinement(e,t){return this._refinement((s,a)=>e(s)?!0:(a.addIssue(typeof t=="function"?t(s,a):t),!1))}_refinement(e){return new N({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 O.create(this,this._def)}nullable(){return U.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return X.create(this)}promise(){return Q.create(this,this._def)}or(e){return le.create([this,e],this._def)}and(e){return ue.create(this,e,this._def)}transform(e){return new N({...b(this._def),schema:this,typeName:m.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new fe({...b(this._def),innerType:this,defaultValue:t,typeName:m.ZodDefault})}brand(){return new Oe({typeName:m.ZodBranded,type:this,...b(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new ge({...b(this._def),innerType:this,catchValue:t,typeName:m.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Me.create(this,e)}readonly(){return _e.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Bs=/^c[^\s-]{8,}$/i,Gs=/^[0-9a-z]+$/,Js=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ws=/^[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,Xs=/^[a-z0-9_-]{21}$/i,Ks=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ys=/^[-+]?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)?)??$/,Qs=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ea="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",ft,ta=/^(?:(?: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])$/,ra=/^(?:(?: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])$/,sa=/^(([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]))$/,aa=/^(([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])$/,na=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,oa=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,$t="((\\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])))",ia=new RegExp(`^${$t}$`);function qt(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function ca(r){return new RegExp(`^${qt(r)}$`)}function Lt(r){let e=`${$t}T${qt(r)}`,t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function la(r,e){return!!((e==="v4"||!e)&&ta.test(r)||(e==="v6"||!e)&&sa.test(r))}function ua(r,e){if(!Ks.test(r))return!1;try{let[t]=r.split("."),s=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),a=JSON.parse(atob(s));return!(typeof a!="object"||a===null||!a.typ||!a.alg||e&&a.alg!==e)}catch{return!1}}function da(r,e){return!!((e==="v4"||!e)&&ra.test(r)||(e==="v6"||!e)&&aa.test(r))}var K=class r extends v{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){let o=this._getOrReturnCtx(e);return h(o,{code:d.invalid_type,expected:f.string,received:o.parsedType}),y}let s=new j,a;for(let o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(a=this._getOrReturnCtx(e,a),h(a,{code:d.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),s.dirty());else if(o.kind==="max")e.data.length>o.value&&(a=this._getOrReturnCtx(e,a),h(a,{code:d.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),s.dirty());else if(o.kind==="length"){let i=e.data.length>o.value,c=e.data.length<o.value;(i||c)&&(a=this._getOrReturnCtx(e,a),i?h(a,{code:d.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):c&&h(a,{code:d.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),s.dirty())}else if(o.kind==="email")Qs.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"email",code:d.invalid_string,message:o.message}),s.dirty());else if(o.kind==="emoji")ft||(ft=new RegExp(ea,"u")),ft.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"emoji",code:d.invalid_string,message:o.message}),s.dirty());else if(o.kind==="uuid")Ws.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"uuid",code:d.invalid_string,message:o.message}),s.dirty());else if(o.kind==="nanoid")Xs.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"nanoid",code:d.invalid_string,message:o.message}),s.dirty());else if(o.kind==="cuid")Bs.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"cuid",code:d.invalid_string,message:o.message}),s.dirty());else if(o.kind==="cuid2")Gs.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"cuid2",code:d.invalid_string,message:o.message}),s.dirty());else if(o.kind==="ulid")Js.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"ulid",code:d.invalid_string,message:o.message}),s.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),h(a,{validation:"url",code:d.invalid_string,message:o.message}),s.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"regex",code:d.invalid_string,message:o.message}),s.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(a=this._getOrReturnCtx(e,a),h(a,{code:d.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),s.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(a=this._getOrReturnCtx(e,a),h(a,{code:d.invalid_string,validation:{startsWith:o.value},message:o.message}),s.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(a=this._getOrReturnCtx(e,a),h(a,{code:d.invalid_string,validation:{endsWith:o.value},message:o.message}),s.dirty()):o.kind==="datetime"?Lt(o).test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{code:d.invalid_string,validation:"datetime",message:o.message}),s.dirty()):o.kind==="date"?ia.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{code:d.invalid_string,validation:"date",message:o.message}),s.dirty()):o.kind==="time"?ca(o).test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{code:d.invalid_string,validation:"time",message:o.message}),s.dirty()):o.kind==="duration"?Ys.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"duration",code:d.invalid_string,message:o.message}),s.dirty()):o.kind==="ip"?la(e.data,o.version)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"ip",code:d.invalid_string,message:o.message}),s.dirty()):o.kind==="jwt"?ua(e.data,o.alg)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"jwt",code:d.invalid_string,message:o.message}),s.dirty()):o.kind==="cidr"?da(e.data,o.version)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"cidr",code:d.invalid_string,message:o.message}),s.dirty()):o.kind==="base64"?na.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"base64",code:d.invalid_string,message:o.message}),s.dirty()):o.kind==="base64url"?oa.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"base64url",code:d.invalid_string,message:o.message}),s.dirty()):k.assertNever(o);return{status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(a=>e.test(a),{validation:t,code:d.invalid_string,...g.errToObj(s)})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...g.errToObj(e)})}url(e){return this._addCheck({kind:"url",...g.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...g.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...g.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...g.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...g.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...g.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...g.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...g.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...g.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...g.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...g.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...g.errToObj(e)})}datetime(e){var t,s;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:(s=e?.local)!==null&&s!==void 0?s:!1,...g.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,...g.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...g.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...g.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...g.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...g.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...g.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...g.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...g.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...g.errToObj(t)})}nonempty(e){return this.min(1,g.errToObj(e))}trim(){return new r({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new r({...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(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};K.create=r=>{var e;return new K({checks:[],typeName:m.ZodString,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...b(r)})};function ma(r,e){let t=(r.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,a=t>s?t:s,o=parseInt(r.toFixed(a).replace(".","")),i=parseInt(e.toFixed(a).replace(".",""));return o%i/Math.pow(10,a)}var se=class r extends v{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){let o=this._getOrReturnCtx(e);return h(o,{code:d.invalid_type,expected:f.number,received:o.parsedType}),y}let s,a=new j;for(let o of this._def.checks)o.kind==="int"?k.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:d.invalid_type,expected:"integer",received:"float",message:o.message}),a.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(s=this._getOrReturnCtx(e,s),h(s,{code:d.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),a.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(s=this._getOrReturnCtx(e,s),h(s,{code:d.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),a.dirty()):o.kind==="multipleOf"?ma(e.data,o.value)!==0&&(s=this._getOrReturnCtx(e,s),h(s,{code:d.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:d.not_finite,message:o.message}),a.dirty()):k.assertNever(o);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,g.toString(t))}gt(e,t){return this.setLimit("min",e,!1,g.toString(t))}lte(e,t){return this.setLimit("max",e,!0,g.toString(t))}lt(e,t){return this.setLimit("max",e,!1,g.toString(t))}setLimit(e,t,s,a){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:g.toString(a)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:g.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:g.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:g.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:g.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:g.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:g.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let 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"&&k.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}};se.create=r=>new se({checks:[],typeName:m.ZodNumber,coerce:r?.coerce||!1,...b(r)});var ae=class r extends v{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 s,a=new j;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(s=this._getOrReturnCtx(e,s),h(s,{code:d.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),a.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(s=this._getOrReturnCtx(e,s),h(s,{code:d.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),a.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),h(s,{code:d.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):k.assertNever(o);return{status:a.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return h(t,{code:d.invalid_type,expected:f.bigint,received:t.parsedType}),y}gte(e,t){return this.setLimit("min",e,!0,g.toString(t))}gt(e,t){return this.setLimit("min",e,!1,g.toString(t))}lte(e,t){return this.setLimit("max",e,!0,g.toString(t))}lt(e,t){return this.setLimit("max",e,!1,g.toString(t))}setLimit(e,t,s,a){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:g.toString(a)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:g.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:g.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};ae.create=r=>{var e;return new ae({checks:[],typeName:m.ZodBigInt,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...b(r)})};var ne=class extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){let s=this._getOrReturnCtx(e);return h(s,{code:d.invalid_type,expected:f.boolean,received:s.parsedType}),y}return E(e.data)}};ne.create=r=>new ne({typeName:m.ZodBoolean,coerce:r?.coerce||!1,...b(r)});var oe=class r extends v{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){let o=this._getOrReturnCtx(e);return h(o,{code:d.invalid_type,expected:f.date,received:o.parsedType}),y}if(isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return h(o,{code:d.invalid_date}),y}let s=new j,a;for(let o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(a=this._getOrReturnCtx(e,a),h(a,{code:d.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),s.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(a=this._getOrReturnCtx(e,a),h(a,{code:d.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),s.dirty()):k.assertNever(o);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:g.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:g.toString(t)})}get minDate(){let e=null;for(let 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(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};oe.create=r=>new oe({checks:[],coerce:r?.coerce||!1,typeName:m.ZodDate,...b(r)});var ke=class extends v{_parse(e){if(this._getType(e)!==f.symbol){let s=this._getOrReturnCtx(e);return h(s,{code:d.invalid_type,expected:f.symbol,received:s.parsedType}),y}return E(e.data)}};ke.create=r=>new ke({typeName:m.ZodSymbol,...b(r)});var ie=class extends v{_parse(e){if(this._getType(e)!==f.undefined){let s=this._getOrReturnCtx(e);return h(s,{code:d.invalid_type,expected:f.undefined,received:s.parsedType}),y}return E(e.data)}};ie.create=r=>new ie({typeName:m.ZodUndefined,...b(r)});var ce=class extends v{_parse(e){if(this._getType(e)!==f.null){let s=this._getOrReturnCtx(e);return h(s,{code:d.invalid_type,expected:f.null,received:s.parsedType}),y}return E(e.data)}};ce.create=r=>new ce({typeName:m.ZodNull,...b(r)});var Y=class extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return E(e.data)}};Y.create=r=>new Y({typeName:m.ZodAny,...b(r)});var W=class extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return E(e.data)}};W.create=r=>new W({typeName:m.ZodUnknown,...b(r)});var L=class extends v{_parse(e){let t=this._getOrReturnCtx(e);return h(t,{code:d.invalid_type,expected:f.never,received:t.parsedType}),y}};L.create=r=>new L({typeName:m.ZodNever,...b(r)});var Se=class extends v{_parse(e){if(this._getType(e)!==f.undefined){let s=this._getOrReturnCtx(e);return h(s,{code:d.invalid_type,expected:f.void,received:s.parsedType}),y}return E(e.data)}};Se.create=r=>new Se({typeName:m.ZodVoid,...b(r)});var X=class r extends v{_parse(e){let{ctx:t,status:s}=this._processInputParams(e),a=this._def;if(t.parsedType!==f.array)return h(t,{code:d.invalid_type,expected:f.array,received:t.parsedType}),y;if(a.exactLength!==null){let i=t.data.length>a.exactLength.value,c=t.data.length<a.exactLength.value;(i||c)&&(h(t,{code:i?d.too_big:d.too_small,minimum:c?a.exactLength.value:void 0,maximum:i?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),s.dirty())}if(a.minLength!==null&&t.data.length<a.minLength.value&&(h(t,{code:d.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),s.dirty()),a.maxLength!==null&&t.data.length>a.maxLength.value&&(h(t,{code:d.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((i,c)=>a.type._parseAsync(new q(t,i,t.path,c)))).then(i=>j.mergeArray(s,i));let o=[...t.data].map((i,c)=>a.type._parseSync(new q(t,i,t.path,c)));return j.mergeArray(s,o)}get element(){return this._def.type}min(e,t){return new r({...this._def,minLength:{value:e,message:g.toString(t)}})}max(e,t){return new r({...this._def,maxLength:{value:e,message:g.toString(t)}})}length(e,t){return new r({...this._def,exactLength:{value:e,message:g.toString(t)}})}nonempty(e){return this.min(1,e)}};X.create=(r,e)=>new X({type:r,minLength:null,maxLength:null,exactLength:null,typeName:m.ZodArray,...b(e)});function ve(r){if(r instanceof M){let e={};for(let t in r.shape){let s=r.shape[t];e[t]=O.create(ve(s))}return new M({...r._def,shape:()=>e})}else return r instanceof X?new X({...r._def,type:ve(r.element)}):r instanceof O?O.create(ve(r.unwrap())):r instanceof U?U.create(ve(r.unwrap())):r instanceof F?F.create(r.items.map(e=>ve(e))):r}var M=class r extends v{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=k.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==f.object){let u=this._getOrReturnCtx(e);return h(u,{code:d.invalid_type,expected:f.object,received:u.parsedType}),y}let{status:s,ctx:a}=this._processInputParams(e),{shape:o,keys:i}=this._getCached(),c=[];if(!(this._def.catchall instanceof L&&this._def.unknownKeys==="strip"))for(let u in a.data)i.includes(u)||c.push(u);let l=[];for(let u of i){let p=o[u],w=a.data[u];l.push({key:{status:"valid",value:u},value:p._parse(new q(a,w,a.path,u)),alwaysSet:u in a.data})}if(this._def.catchall instanceof L){let u=this._def.unknownKeys;if(u==="passthrough")for(let p of c)l.push({key:{status:"valid",value:p},value:{status:"valid",value:a.data[p]}});else if(u==="strict")c.length>0&&(h(a,{code:d.unrecognized_keys,keys:c}),s.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let p of c){let w=a.data[p];l.push({key:{status:"valid",value:p},value:u._parse(new q(a,w,a.path,p)),alwaysSet:p in a.data})}}return a.common.async?Promise.resolve().then(async()=>{let u=[];for(let p of l){let w=await p.key,ee=await p.value;u.push({key:w,value:ee,alwaysSet:p.alwaysSet})}return u}).then(u=>j.mergeObjectSync(s,u)):j.mergeObjectSync(s,l)}get shape(){return this._def.shape()}strict(e){return g.errToObj,new r({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{var a,o,i,c;let l=(i=(o=(a=this._def).errorMap)===null||o===void 0?void 0:o.call(a,t,s).message)!==null&&i!==void 0?i:s.defaultError;return t.code==="unrecognized_keys"?{message:(c=g.errToObj(e).message)!==null&&c!==void 0?c:l}:{message:l}}}:{}})}strip(){return new r({...this._def,unknownKeys:"strip"})}passthrough(){return new r({...this._def,unknownKeys:"passthrough"})}extend(e){return new r({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new r({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 r({...this._def,catchall:e})}pick(e){let t={};return k.objectKeys(e).forEach(s=>{e[s]&&this.shape[s]&&(t[s]=this.shape[s])}),new r({...this._def,shape:()=>t})}omit(e){let t={};return k.objectKeys(this.shape).forEach(s=>{e[s]||(t[s]=this.shape[s])}),new r({...this._def,shape:()=>t})}deepPartial(){return ve(this)}partial(e){let t={};return k.objectKeys(this.shape).forEach(s=>{let a=this.shape[s];e&&!e[s]?t[s]=a:t[s]=a.optional()}),new r({...this._def,shape:()=>t})}required(e){let t={};return k.objectKeys(this.shape).forEach(s=>{if(e&&!e[s])t[s]=this.shape[s];else{let o=this.shape[s];for(;o instanceof O;)o=o._def.innerType;t[s]=o}}),new r({...this._def,shape:()=>t})}keyof(){return Dt(k.objectKeys(this.shape))}};M.create=(r,e)=>new M({shape:()=>r,unknownKeys:"strip",catchall:L.create(),typeName:m.ZodObject,...b(e)});M.strictCreate=(r,e)=>new M({shape:()=>r,unknownKeys:"strict",catchall:L.create(),typeName:m.ZodObject,...b(e)});M.lazycreate=(r,e)=>new M({shape:r,unknownKeys:"strip",catchall:L.create(),typeName:m.ZodObject,...b(e)});var le=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),s=this._def.options;function a(o){for(let c of o)if(c.result.status==="valid")return c.result;for(let c of o)if(c.result.status==="dirty")return t.common.issues.push(...c.ctx.common.issues),c.result;let i=o.map(c=>new I(c.ctx.common.issues));return h(t,{code:d.invalid_union,unionErrors:i}),y}if(t.common.async)return Promise.all(s.map(async o=>{let i={...t,common:{...t.common,issues:[]},parent:null};return{result:await o._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(a);{let o,i=[];for(let l of s){let u={...t,common:{...t.common,issues:[]},parent:null},p=l._parseSync({data:t.data,path:t.path,parent:u});if(p.status==="valid")return p;p.status==="dirty"&&!o&&(o={result:p,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(o)return t.common.issues.push(...o.ctx.common.issues),o.result;let c=i.map(l=>new I(l));return h(t,{code:d.invalid_union,unionErrors:c}),y}}get options(){return this._def.options}};le.create=(r,e)=>new le({options:r,typeName:m.ZodUnion,...b(e)});var G=r=>r instanceof de?G(r.schema):r instanceof N?G(r.innerType()):r instanceof me?[r.value]:r instanceof pe?r.options:r instanceof he?k.objectValues(r.enum):r instanceof fe?G(r._def.innerType):r instanceof ie?[void 0]:r instanceof ce?[null]:r instanceof O?[void 0,...G(r.unwrap())]:r instanceof U?[null,...G(r.unwrap())]:r instanceof Oe||r instanceof _e?G(r.unwrap()):r instanceof ge?G(r._def.innerType):[],Le=class r extends v{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.object)return h(t,{code:d.invalid_type,expected:f.object,received:t.parsedType}),y;let s=this.discriminator,a=t.data[s],o=this.optionsMap.get(a);return o?t.common.async?o._parseAsync({data:t.data,path:t.path,parent:t}):o._parseSync({data:t.data,path:t.path,parent:t}):(h(t,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),y)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){let a=new Map;for(let o of t){let i=G(o.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let c of i){if(a.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);a.set(c,o)}}return new r({typeName:m.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...b(s)})}};function vt(r,e){let t=J(r),s=J(e);if(r===e)return{valid:!0,data:r};if(t===f.object&&s===f.object){let a=k.objectKeys(e),o=k.objectKeys(r).filter(c=>a.indexOf(c)!==-1),i={...r,...e};for(let c of o){let l=vt(r[c],e[c]);if(!l.valid)return{valid:!1};i[c]=l.data}return{valid:!0,data:i}}else if(t===f.array&&s===f.array){if(r.length!==e.length)return{valid:!1};let a=[];for(let o=0;o<r.length;o++){let i=r[o],c=e[o],l=vt(i,c);if(!l.valid)return{valid:!1};a.push(l.data)}return{valid:!0,data:a}}else return t===f.date&&s===f.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}var ue=class extends v{_parse(e){let{status:t,ctx:s}=this._processInputParams(e),a=(o,i)=>{if(_t(o)||_t(i))return y;let c=vt(o.value,i.value);return c.valid?((yt(o)||yt(i))&&t.dirty(),{status:t.value,value:c.data}):(h(s,{code:d.invalid_intersection_types}),y)};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(([o,i])=>a(o,i)):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}))}};ue.create=(r,e,t)=>new ue({left:r,right:e,typeName:m.ZodIntersection,...b(t)});var F=class r extends v{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.array)return h(s,{code:d.invalid_type,expected:f.array,received:s.parsedType}),y;if(s.data.length<this._def.items.length)return h(s,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),y;!this._def.rest&&s.data.length>this._def.items.length&&(h(s,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let o=[...s.data].map((i,c)=>{let l=this._def.items[c]||this._def.rest;return l?l._parse(new q(s,i,s.path,c)):null}).filter(i=>!!i);return s.common.async?Promise.all(o).then(i=>j.mergeArray(t,i)):j.mergeArray(t,o)}get items(){return this._def.items}rest(e){return new r({...this._def,rest:e})}};F.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new F({items:r,typeName:m.ZodTuple,rest:null,...b(e)})};var De=class r extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.object)return h(s,{code:d.invalid_type,expected:f.object,received:s.parsedType}),y;let a=[],o=this._def.keyType,i=this._def.valueType;for(let c in s.data)a.push({key:o._parse(new q(s,c,s.path,c)),value:i._parse(new q(s,s.data[c],s.path,c)),alwaysSet:c in s.data});return s.common.async?j.mergeObjectAsync(t,a):j.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof v?new r({keyType:e,valueType:t,typeName:m.ZodRecord,...b(s)}):new r({keyType:K.create(),valueType:e,typeName:m.ZodRecord,...b(t)})}},Re=class extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.map)return h(s,{code:d.invalid_type,expected:f.map,received:s.parsedType}),y;let a=this._def.keyType,o=this._def.valueType,i=[...s.data.entries()].map(([c,l],u)=>({key:a._parse(new q(s,c,s.path,[u,"key"])),value:o._parse(new q(s,l,s.path,[u,"value"]))}));if(s.common.async){let c=new Map;return Promise.resolve().then(async()=>{for(let l of i){let u=await l.key,p=await l.value;if(u.status==="aborted"||p.status==="aborted")return y;(u.status==="dirty"||p.status==="dirty")&&t.dirty(),c.set(u.value,p.value)}return{status:t.value,value:c}})}else{let c=new Map;for(let l of i){let u=l.key,p=l.value;if(u.status==="aborted"||p.status==="aborted")return y;(u.status==="dirty"||p.status==="dirty")&&t.dirty(),c.set(u.value,p.value)}return{status:t.value,value:c}}}};Re.create=(r,e,t)=>new Re({valueType:e,keyType:r,typeName:m.ZodMap,...b(t)});var Te=class r extends v{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.set)return h(s,{code:d.invalid_type,expected:f.set,received:s.parsedType}),y;let a=this._def;a.minSize!==null&&s.data.size<a.minSize.value&&(h(s,{code:d.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),t.dirty()),a.maxSize!==null&&s.data.size>a.maxSize.value&&(h(s,{code:d.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());let o=this._def.valueType;function i(l){let u=new Set;for(let p of l){if(p.status==="aborted")return y;p.status==="dirty"&&t.dirty(),u.add(p.value)}return{status:t.value,value:u}}let c=[...s.data.values()].map((l,u)=>o._parse(new q(s,l,s.path,u)));return s.common.async?Promise.all(c).then(l=>i(l)):i(c)}min(e,t){return new r({...this._def,minSize:{value:e,message:g.toString(t)}})}max(e,t){return new r({...this._def,maxSize:{value:e,message:g.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Te.create=(r,e)=>new Te({valueType:r,minSize:null,maxSize:null,typeName:m.ZodSet,...b(e)});var ze=class r extends v{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.function)return h(t,{code:d.invalid_type,expected:f.function,received:t.parsedType}),y;function s(c,l){return $e({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ze(),xe].filter(u=>!!u),issueData:{code:d.invalid_arguments,argumentsError:l}})}function a(c,l){return $e({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ze(),xe].filter(u=>!!u),issueData:{code:d.invalid_return_type,returnTypeError:l}})}let o={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Q){let c=this;return E(async function(...l){let u=new I([]),p=await c._def.args.parseAsync(l,o).catch(ye=>{throw u.addIssue(s(l,ye)),u}),w=await Reflect.apply(i,this,p);return await c._def.returns._def.type.parseAsync(w,o).catch(ye=>{throw u.addIssue(a(w,ye)),u})})}else{let c=this;return E(function(...l){let u=c._def.args.safeParse(l,o);if(!u.success)throw new I([s(l,u.error)]);let p=Reflect.apply(i,this,u.data),w=c._def.returns.safeParse(p,o);if(!w.success)throw new I([a(p,w.error)]);return w.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new r({...this._def,args:F.create(e).rest(W.create())})}returns(e){return new r({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new r({args:e||F.create([]).rest(W.create()),returns:t||W.create(),typeName:m.ZodFunction,...b(s)})}},de=class extends v{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};de.create=(r,e)=>new de({getter:r,typeName:m.ZodLazy,...b(e)});var me=class extends v{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return h(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}};me.create=(r,e)=>new me({value:r,typeName:m.ZodLiteral,...b(e)});function Dt(r,e){return new pe({values:r,typeName:m.ZodEnum,...b(e)})}var pe=class r extends v{constructor(){super(...arguments),Ce.set(this,void 0)}_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),s=this._def.values;return h(t,{expected:k.joinValues(s),received:t.parsedType,code:d.invalid_type}),y}if(qe(this,Ce,"f")||Zt(this,Ce,new Set(this._def.values),"f"),!qe(this,Ce,"f").has(e.data)){let t=this._getOrReturnCtx(e),s=this._def.values;return h(t,{received:t