UNPKG

octocode-mcp

Version:

Model Context Protocol (MCP) server for advanced GitHub repository analysis, code discovery, and npm package exploration. Provides AI assistants with powerful tools to search, analyze, and understand codebases across GitHub and npm ecosystems.

2 lines 1.36 MB
#!/usr/bin/env node import e from"node:process";import t,{EventEmitter as n}from"events";import r from"crypto";import{exec as i}from"child_process";import a,{promisify as o}from"util";import s,{platform as c}from"os";import u,{existsSync as l,statSync as p}from"fs";import d,{isAbsolute as f,join as m}from"path";import h from"http";import g from"https";import v from"url";import y,{Readable as _}from"stream";import b from"assert";import E from"tty";import x from"zlib";var A,S;!function(e){e.assertEqual=e=>{},e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const n of e)t[n]=n;return t},e.getValidEnumValues=t=>{const n=e.objectKeys(t).filter(e=>"number"!=typeof t[t[e]]),r={};for(const e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(const n of e)if(t(n))return n},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,e.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},e.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t}(A||(A={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(S||(S={}));const w=A.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),T=e=>{switch(typeof e){case"undefined":return w.undefined;case"string":return w.string;case"number":return Number.isNaN(e)?w.nan:w.number;case"boolean":return w.boolean;case"function":return w.function;case"bigint":return w.bigint;case"symbol":return w.symbol;case"object":return Array.isArray(e)?w.array:null===e?w.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?w.promise:"undefined"!=typeof Map&&e instanceof Map?w.map:"undefined"!=typeof Set&&e instanceof Set?w.set:"undefined"!=typeof Date&&e instanceof Date?w.date:w.object;default:return w.unknown}},k=A.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class C extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(const i of e.issues)if("invalid_union"===i.code)i.unionErrors.map(r);else if("invalid_return_type"===i.code)r(i.returnTypeError);else if("invalid_arguments"===i.code)r(i.argumentsError);else if(0===i.path.length)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){const n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(e){if(!(e instanceof C))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,A.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t={},n=[];for(const r of this.issues)if(r.path.length>0){const n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}C.create=e=>new C(e);const R=(e,t)=>{let n;switch(e.code){case k.invalid_type:n=e.received===w.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case k.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,A.jsonStringifyReplacer)}`;break;case k.unrecognized_keys:n=`Unrecognized key(s) in object: ${A.joinValues(e.keys,", ")}`;break;case k.invalid_union:n="Invalid input";break;case k.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${A.joinValues(e.options)}`;break;case k.invalid_enum_value:n=`Invalid enum value. Expected ${A.joinValues(e.options)}, received '${e.received}'`;break;case k.invalid_arguments:n="Invalid function arguments";break;case k.invalid_return_type:n="Invalid function return type";break;case k.invalid_date:n="Invalid date";break;case k.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:A.assertNever(e.validation):n="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case k.too_small:n="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type||"bigint"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case k.too_big:n="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case k.custom:n="Invalid input";break;case k.invalid_intersection_types:n="Intersection results could not be merged";break;case k.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case k.not_finite:n="Number must be finite";break;default:n=t.defaultError,A.assertNever(e)}return{message:n}};let O=R;function D(){return O}const P=e=>{const{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(void 0!==i.message)return{...i,path:a,message:i.message};let s="";const c=r.filter(e=>!!e).slice().reverse();for(const e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function F(e,t){const n=D(),r=P({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===R?void 0:R].filter(e=>!!e)});e.common.issues.push(r)}class M{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const r of t){if("aborted"===r.status)return I;"dirty"===r.status&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const e of t){const t=await e.key,r=await e.value;n.push({key:t,value:r})}return M.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const r of t){const{key:t,value:i}=r;if("aborted"===t.status)return I;if("aborted"===i.status)return I;"dirty"===t.status&&e.dirty(),"dirty"===i.status&&e.dirty(),"__proto__"===t.value||void 0===i.value&&!r.alwaysSet||(n[t.value]=i.value)}return{status:e.value,value:n}}}const I=Object.freeze({status:"aborted"}),N=e=>({status:"dirty",value:e}),L=e=>({status:"valid",value:e}),B=e=>"aborted"===e.status,U=e=>"dirty"===e.status,V=e=>"valid"===e.status,z=e=>"undefined"!=typeof Promise&&e instanceof Promise;var j;!function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:e?.message}(j||(j={}));class K{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const q=(e,t)=>{if(V(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new C(e.common.issues);return this._error=t,this._error}}};function H(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{const{message:a}=e;return"invalid_enum_value"===t.code?{message:a??i.defaultError}:void 0===i.data?{message:a??r??i.defaultError}:"invalid_type"!==t.code?{message:i.defaultError}:{message:a??n??i.defaultError}},description:i}}class ${get description(){return this._def.description}_getType(e){return T(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:T(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new M,ctx:{common:e.parent.common,data:e.data,parsedType:T(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(z(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 n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){const n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:T(e)},r=this._parseSync({data:e,path:n.path,parent:n});return q(n,r)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:T(e)};if(!this["~standard"].async)try{const n=this._parseSync({data:e,path:[],parent:t});return V(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>V(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:T(e)},r=this._parse({data:e,path:n.path,parent:n}),i=await(z(r)?r:Promise.resolve(r));return q(n,i)}refine(e,t){const n=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement((t,r)=>{const i=e(t),a=()=>r.addIssue({code:k.custom,...n(t)});return"undefined"!=typeof Promise&&i instanceof Promise?i.then(e=>!!e||(a(),!1)):!!i||(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>!!e(n)||(r.addIssue("function"==typeof t?t(n,r):t),!1))}_refinement(e){return new We({schema:this,typeName:st.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return Xe.create(this,this._def)}nullable(){return Ye.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Re.create(this)}promise(){return Ge.create(this,this._def)}or(e){return Pe.create([this,e],this._def)}and(e){return Ne.create(this,e,this._def)}transform(e){return new We({...H(this._def),schema:this,typeName:st.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new Ze({...H(this._def),innerType:this,defaultValue:t,typeName:st.ZodDefault})}brand(){return new tt({typeName:st.ZodBranded,type:this,...H(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new Qe({...H(this._def),innerType:this,catchValue:t,typeName:st.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return nt.create(this,e)}readonly(){return rt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const G=/^c[^\s-]{8,}$/i,W=/^[0-9a-z]+$/,X=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Y=/^[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,Z=/^[a-z0-9_-]{21}$/i,Q=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,J=/^[-+]?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)?)??$/,ee=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let te;const ne=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,re=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ie=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,ae=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,oe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,se=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ce="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",ue=new RegExp(`^${ce}$`);function le(e){let t="[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`),`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e.precision?"+":"?"}`}function pe(e){return new RegExp(`^${le(e)}$`)}function de(e){let t=`${ce}T${le(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function fe(e,t){return!("v4"!==t&&t||!ne.test(e))||!("v6"!==t&&t||!ie.test(e))}function me(e,t){if(!Q.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),i=JSON.parse(atob(r));return!("object"!=typeof i||null===i||"typ"in i&&"JWT"!==i?.typ||!i.alg||t&&i.alg!==t)}catch{return!1}}function he(e,t){return!("v4"!==t&&t||!re.test(e))||!("v6"!==t&&t||!ae.test(e))}class ge extends ${_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==w.string){const t=this._getOrReturnCtx(e);return F(t,{code:k.invalid_type,expected:w.string,received:t.parsedType}),I}const t=new M;let n;for(const r of this._def.checks)if("min"===r.kind)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:k.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if("max"===r.kind)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:k.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if("length"===r.kind){const i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?F(n,{code:k.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):a&&F(n,{code:k.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if("email"===r.kind)ee.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"email",code:k.invalid_string,message:r.message}),t.dirty());else if("emoji"===r.kind)te||(te=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),te.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"emoji",code:k.invalid_string,message:r.message}),t.dirty());else if("uuid"===r.kind)Y.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"uuid",code:k.invalid_string,message:r.message}),t.dirty());else if("nanoid"===r.kind)Z.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"nanoid",code:k.invalid_string,message:r.message}),t.dirty());else if("cuid"===r.kind)G.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"cuid",code:k.invalid_string,message:r.message}),t.dirty());else if("cuid2"===r.kind)W.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"cuid2",code:k.invalid_string,message:r.message}),t.dirty());else if("ulid"===r.kind)X.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"ulid",code:k.invalid_string,message:r.message}),t.dirty());else if("url"===r.kind)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),F(n,{validation:"url",code:k.invalid_string,message:r.message}),t.dirty()}else"regex"===r.kind?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"regex",code:k.invalid_string,message:r.message}),t.dirty())):"trim"===r.kind?e.data=e.data.trim():"includes"===r.kind?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),F(n,{code:k.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):"toLowerCase"===r.kind?e.data=e.data.toLowerCase():"toUpperCase"===r.kind?e.data=e.data.toUpperCase():"startsWith"===r.kind?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),F(n,{code:k.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):"endsWith"===r.kind?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),F(n,{code:k.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):"datetime"===r.kind?de(r).test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:k.invalid_string,validation:"datetime",message:r.message}),t.dirty()):"date"===r.kind?ue.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:k.invalid_string,validation:"date",message:r.message}),t.dirty()):"time"===r.kind?pe(r).test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{code:k.invalid_string,validation:"time",message:r.message}),t.dirty()):"duration"===r.kind?J.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"duration",code:k.invalid_string,message:r.message}),t.dirty()):"ip"===r.kind?fe(e.data,r.version)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"ip",code:k.invalid_string,message:r.message}),t.dirty()):"jwt"===r.kind?me(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"jwt",code:k.invalid_string,message:r.message}),t.dirty()):"cidr"===r.kind?he(e.data,r.version)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"cidr",code:k.invalid_string,message:r.message}),t.dirty()):"base64"===r.kind?oe.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"base64",code:k.invalid_string,message:r.message}),t.dirty()):"base64url"===r.kind?se.test(e.data)||(n=this._getOrReturnCtx(e,n),F(n,{validation:"base64url",code:k.invalid_string,message:r.message}),t.dirty()):A.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:k.invalid_string,...j.errToObj(n)})}_addCheck(e){return new ge({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...j.errToObj(e)})}url(e){return this._addCheck({kind:"url",...j.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...j.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...j.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...j.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...j.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...j.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...j.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...j.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...j.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...j.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...j.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...j.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...j.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===e?.precision?null:e?.precision,...j.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...j.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...j.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...j.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...j.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...j.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...j.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...j.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...j.errToObj(t)})}nonempty(e){return this.min(1,j.errToObj(e))}trim(){return new ge({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ge({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ge({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>"datetime"===e.kind)}get isDate(){return!!this._def.checks.find(e=>"date"===e.kind)}get isTime(){return!!this._def.checks.find(e=>"time"===e.kind)}get isDuration(){return!!this._def.checks.find(e=>"duration"===e.kind)}get isEmail(){return!!this._def.checks.find(e=>"email"===e.kind)}get isURL(){return!!this._def.checks.find(e=>"url"===e.kind)}get isEmoji(){return!!this._def.checks.find(e=>"emoji"===e.kind)}get isUUID(){return!!this._def.checks.find(e=>"uuid"===e.kind)}get isNANOID(){return!!this._def.checks.find(e=>"nanoid"===e.kind)}get isCUID(){return!!this._def.checks.find(e=>"cuid"===e.kind)}get isCUID2(){return!!this._def.checks.find(e=>"cuid2"===e.kind)}get isULID(){return!!this._def.checks.find(e=>"ulid"===e.kind)}get isIP(){return!!this._def.checks.find(e=>"ip"===e.kind)}get isCIDR(){return!!this._def.checks.find(e=>"cidr"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get isBase64url(){return!!this._def.checks.find(e=>"base64url"===e.kind)}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}function ve(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(".",""))%Number.parseInt(t.toFixed(i).replace(".",""))/10**i}ge.create=e=>new ge({checks:[],typeName:st.ZodString,coerce:e?.coerce??!1,...H(e)});class ye extends ${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)!==w.number){const t=this._getOrReturnCtx(e);return F(t,{code:k.invalid_type,expected:w.number,received:t.parsedType}),I}let t;const n=new M;for(const r of this._def.checks)"int"===r.kind?A.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),F(t,{code:k.invalid_type,expected:"integer",received:"float",message:r.message}),n.dirty()):"min"===r.kind?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:k.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):"max"===r.kind?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:k.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):"multipleOf"===r.kind?0!==ve(e.data,r.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:k.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):"finite"===r.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),F(t,{code:k.not_finite,message:r.message}),n.dirty()):A.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,j.toString(t))}gt(e,t){return this.setLimit("min",e,!1,j.toString(t))}lte(e,t){return this.setLimit("max",e,!0,j.toString(t))}lt(e,t){return this.setLimit("max",e,!1,j.toString(t))}setLimit(e,t,n,r){return new ye({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:j.toString(r)}]})}_addCheck(e){return new ye({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:j.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:j.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:j.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:j.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:j.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:j.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:j.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:j.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:j.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>"int"===e.kind||"multipleOf"===e.kind&&A.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if("finite"===n.kind||"int"===n.kind||"multipleOf"===n.kind)return!0;"min"===n.kind?(null===t||n.value>t)&&(t=n.value):"max"===n.kind&&(null===e||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}ye.create=e=>new ye({checks:[],typeName:st.ZodNumber,coerce:e?.coerce||!1,...H(e)});class _e extends ${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)!==w.bigint)return this._getInvalidInput(e);let t;const n=new M;for(const r of this._def.checks)"min"===r.kind?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:k.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):"max"===r.kind?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),F(t,{code:k.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):"multipleOf"===r.kind?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),F(t,{code:k.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):A.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return F(t,{code:k.invalid_type,expected:w.bigint,received:t.parsedType}),I}gte(e,t){return this.setLimit("min",e,!0,j.toString(t))}gt(e,t){return this.setLimit("min",e,!1,j.toString(t))}lte(e,t){return this.setLimit("max",e,!0,j.toString(t))}lt(e,t){return this.setLimit("max",e,!1,j.toString(t))}setLimit(e,t,n,r){return new _e({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:j.toString(r)}]})}_addCheck(e){return new _e({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:j.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:j.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:j.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:j.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:j.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}_e.create=e=>new _e({checks:[],typeName:st.ZodBigInt,coerce:e?.coerce??!1,...H(e)});class be extends ${_parse(e){if(this._def.coerce&&(e.data=Boolean(e.data)),this._getType(e)!==w.boolean){const t=this._getOrReturnCtx(e);return F(t,{code:k.invalid_type,expected:w.boolean,received:t.parsedType}),I}return L(e.data)}}be.create=e=>new be({typeName:st.ZodBoolean,coerce:e?.coerce||!1,...H(e)});class Ee extends ${_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==w.date){const t=this._getOrReturnCtx(e);return F(t,{code:k.invalid_type,expected:w.date,received:t.parsedType}),I}if(Number.isNaN(e.data.getTime()))return F(this._getOrReturnCtx(e),{code:k.invalid_date}),I;const t=new M;let n;for(const r of this._def.checks)"min"===r.kind?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:k.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),t.dirty()):"max"===r.kind?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),F(n,{code:k.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),t.dirty()):A.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ee({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:j.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:j.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}Ee.create=e=>new Ee({checks:[],coerce:e?.coerce||!1,typeName:st.ZodDate,...H(e)});class xe extends ${_parse(e){if(this._getType(e)!==w.symbol){const t=this._getOrReturnCtx(e);return F(t,{code:k.invalid_type,expected:w.symbol,received:t.parsedType}),I}return L(e.data)}}xe.create=e=>new xe({typeName:st.ZodSymbol,...H(e)});class Ae extends ${_parse(e){if(this._getType(e)!==w.undefined){const t=this._getOrReturnCtx(e);return F(t,{code:k.invalid_type,expected:w.undefined,received:t.parsedType}),I}return L(e.data)}}Ae.create=e=>new Ae({typeName:st.ZodUndefined,...H(e)});class Se extends ${_parse(e){if(this._getType(e)!==w.null){const t=this._getOrReturnCtx(e);return F(t,{code:k.invalid_type,expected:w.null,received:t.parsedType}),I}return L(e.data)}}Se.create=e=>new Se({typeName:st.ZodNull,...H(e)});class we extends ${constructor(){super(...arguments),this._any=!0}_parse(e){return L(e.data)}}we.create=e=>new we({typeName:st.ZodAny,...H(e)});class Te extends ${constructor(){super(...arguments),this._unknown=!0}_parse(e){return L(e.data)}}Te.create=e=>new Te({typeName:st.ZodUnknown,...H(e)});class ke extends ${_parse(e){const t=this._getOrReturnCtx(e);return F(t,{code:k.invalid_type,expected:w.never,received:t.parsedType}),I}}ke.create=e=>new ke({typeName:st.ZodNever,...H(e)});class Ce extends ${_parse(e){if(this._getType(e)!==w.undefined){const t=this._getOrReturnCtx(e);return F(t,{code:k.invalid_type,expected:w.void,received:t.parsedType}),I}return L(e.data)}}Ce.create=e=>new Ce({typeName:st.ZodVoid,...H(e)});class Re extends ${_parse(e){const{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==w.array)return F(t,{code:k.invalid_type,expected:w.array,received:t.parsedType}),I;if(null!==r.exactLength){const e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(F(t,{code:e?k.too_big:k.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(null!==r.minLength&&t.data.length<r.minLength.value&&(F(t,{code:k.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),null!==r.maxLength&&t.data.length>r.maxLength.value&&(F(t,{code:k.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new K(t,e,t.path,n)))).then(e=>M.mergeArray(n,e));const i=[...t.data].map((e,n)=>r.type._parseSync(new K(t,e,t.path,n)));return M.mergeArray(n,i)}get element(){return this._def.type}min(e,t){return new Re({...this._def,minLength:{value:e,message:j.toString(t)}})}max(e,t){return new Re({...this._def,maxLength:{value:e,message:j.toString(t)}})}length(e,t){return new Re({...this._def,exactLength:{value:e,message:j.toString(t)}})}nonempty(e){return this.min(1,e)}}function Oe(e){if(e instanceof De){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=Xe.create(Oe(r))}return new De({...e._def,shape:()=>t})}return e instanceof Re?new Re({...e._def,type:Oe(e.element)}):e instanceof Xe?Xe.create(Oe(e.unwrap())):e instanceof Ye?Ye.create(Oe(e.unwrap())):e instanceof Le?Le.create(e.items.map(e=>Oe(e))):e}Re.create=(e,t)=>new Re({type:e,minLength:null,maxLength:null,exactLength:null,typeName:st.ZodArray,...H(t)});class De extends ${constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const e=this._def.shape(),t=A.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==w.object){const t=this._getOrReturnCtx(e);return F(t,{code:k.invalid_type,expected:w.object,received:t.parsedType}),I}const{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof ke&&"strip"===this._def.unknownKeys))for(const e in n.data)i.includes(e)||a.push(e);const o=[];for(const e of i){const t=r[e],i=n.data[e];o.push({key:{status:"valid",value:e},value:t._parse(new K(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof ke){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of a)o.push({key:{status:"valid",value:e},value:{status:"valid",value:n.data[e]}});else if("strict"===e)a.length>0&&(F(n,{code:k.unrecognized_keys,keys:a}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of a){const r=n.data[t];o.push({key:{status:"valid",value:t},value:e._parse(new K(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const e=[];for(const t of o){const n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>M.mergeObjectSync(t,e)):M.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return j.errToObj,new De({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,n)=>{const r=this._def.errorMap?.(t,n).message??n.defaultError;return"unrecognized_keys"===t.code?{message:j.errToObj(e).message??r}:{message:r}}}:{}})}strip(){return new De({...this._def,unknownKeys:"strip"})}passthrough(){return new De({...this._def,unknownKeys:"passthrough"})}extend(e){return new De({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new De({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:st.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new De({...this._def,catchall:e})}pick(e){const t={};for(const n of A.objectKeys(e))e[n]&&this.shape[n]&&(t[n]=this.shape[n]);return new De({...this._def,shape:()=>t})}omit(e){const t={};for(const n of A.objectKeys(this.shape))e[n]||(t[n]=this.shape[n]);return new De({...this._def,shape:()=>t})}deepPartial(){return Oe(this)}partial(e){const t={};for(const n of A.objectKeys(this.shape)){const r=this.shape[n];e&&!e[n]?t[n]=r:t[n]=r.optional()}return new De({...this._def,shape:()=>t})}required(e){const t={};for(const n of A.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let e=this.shape[n];for(;e instanceof Xe;)e=e._def.innerType;t[n]=e}return new De({...this._def,shape:()=>t})}keyof(){return qe(A.objectKeys(this.shape))}}De.create=(e,t)=>new De({shape:()=>e,unknownKeys:"strip",catchall:ke.create(),typeName:st.ZodObject,...H(t)}),De.strictCreate=(e,t)=>new De({shape:()=>e,unknownKeys:"strict",catchall:ke.create(),typeName:st.ZodObject,...H(t)}),De.lazycreate=(e,t)=>new De({shape:e,unknownKeys:"strip",catchall:ke.create(),typeName:st.ZodObject,...H(t)});class Pe extends ${_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;if(t.common.async)return Promise.all(n.map(async e=>{const n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const n of e)if("dirty"===n.result.status)return t.common.issues.push(...n.ctx.common.issues),n.result;const n=e.map(e=>new C(e.ctx.common.issues));return F(t,{code:k.invalid_union,unionErrors:n}),I});{let e;const r=[];for(const i of n){const n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if("valid"===a.status)return a;"dirty"!==a.status||e||(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const i=r.map(e=>new C(e));return F(t,{code:k.invalid_union,unionErrors:i}),I}}get options(){return this._def.options}}Pe.create=(e,t)=>new Pe({options:e,typeName:st.ZodUnion,...H(t)});const Fe=e=>e instanceof je?Fe(e.schema):e instanceof We?Fe(e.innerType()):e instanceof Ke?[e.value]:e instanceof He?e.options:e instanceof $e?A.objectValues(e.enum):e instanceof Ze?Fe(e._def.innerType):e instanceof Ae?[void 0]:e instanceof Se?[null]:e instanceof Xe?[void 0,...Fe(e.unwrap())]:e instanceof Ye?[null,...Fe(e.unwrap())]:e instanceof tt||e instanceof rt?Fe(e.unwrap()):e instanceof Qe?Fe(e._def.innerType):[];class Me extends ${_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==w.object)return F(t,{code:k.invalid_type,expected:w.object,received:t.parsedType}),I;const n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(F(t,{code:k.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),I)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const r=new Map;for(const n of t){const t=Fe(n.shape[e]);if(!t.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const i of t){if(r.has(i))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);r.set(i,n)}}return new Me({typeName:st.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...H(n)})}}function Ie(e,t){const n=T(e),r=T(t);if(e===t)return{valid:!0,data:e};if(n===w.object&&r===w.object){const n=A.objectKeys(t),r=A.objectKeys(e).filter(e=>-1!==n.indexOf(e)),i={...e,...t};for(const n of r){const r=Ie(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}if(n===w.array&&r===w.array){if(e.length!==t.length)return{valid:!1};const n=[];for(let r=0;r<e.length;r++){const i=Ie(e[r],t[r]);if(!i.valid)return{valid:!1};n.push(i.data)}return{valid:!0,data:n}}return n===w.date&&r===w.date&&+e===+t?{valid:!0,data:e}:{valid:!1}}class Ne extends ${_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(B(e)||B(r))return I;const i=Ie(e.value,r.value);return i.valid?((U(e)||U(r))&&t.dirty(),{status:t.value,value:i.data}):(F(n,{code:k.invalid_intersection_types}),I)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}Ne.create=(e,t,n)=>new Ne({left:e,right:t,typeName:st.ZodIntersection,...H(n)});class Le extends ${_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==w.array)return F(n,{code:k.invalid_type,expected:w.array,received:n.parsedType}),I;if(n.data.length<this._def.items.length)return F(n,{code:k.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),I;!this._def.rest&&n.data.length>this._def.items.length&&(F(n,{code:k.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...n.data].map((e,t)=>{const r=this._def.items[t]||this._def.rest;return r?r._parse(new K(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>M.mergeArray(t,e)):M.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new Le({...this._def,rest:e})}}Le.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Le({items:e,typeName:st.ZodTuple,rest:null,...H(t)})};class Be extends ${get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==w.object)return F(n,{code:k.invalid_type,expected:w.object,received:n.parsedType}),I;const r=[],i=this._def.keyType,a=this._def.valueType;for(const e in n.data)r.push({key:i._parse(new K(n,e,n.path,e)),value:a._parse(new K(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?M.mergeObjectAsync(t,r):M.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,n){return new Be(t instanceof $?{keyType:e,valueType:t,typeName:st.ZodRecord,...H(n)}:{keyType:ge.create(),valueType:e,typeName:st.ZodRecord,...H(t)})}}class Ue extends ${get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==w.map)return F(n,{code:k.invalid_type,expected:w.map,received:n.parsedType}),I;const r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new K(n,e,n.path,[a,"key"])),value:i._parse(new K(n,t,n.path,[a,"value"]))}));if(n.common.async){const e=new Map;return Promise.resolve().then(async()=>{for(const n of a){const r=await n.key,i=await n.value;if("aborted"===r.status||"aborted"===i.status)return I;"dirty"!==r.status&&"dirty"!==i.status||t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}{const e=new Map;for(const n of a){const r=n.key,i=n.value;if("aborted"===r.status||"aborted"===i.status)return I;"dirty"!==r.status&&"dirty"!==i.status||t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}}Ue.create=(e,t,n)=>new Ue({valueType:t,keyType:e,typeName:st.ZodMap,...H(n)});class Ve extends ${_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==w.set)return F(n,{code:k.invalid_type,expected:w.set,received:n.parsedType}),I;const r=this._def;null!==r.minSize&&n.data.size<r.minSize.value&&(F(n,{code:k.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),null!==r.maxSize&&n.data.size>r.maxSize.value&&(F(n,{code:k.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const i=this._def.valueType;function a(e){const n=new Set;for(const r of e){if("aborted"===r.status)return I;"dirty"===r.status&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}const o=[...n.data.values()].map((e,t)=>i._parse(new K(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(e,t){return new Ve({...this._def,minSize:{value:e,message:j.toString(t)}})}max(e,t){return new Ve({...this._def,maxSize:{value:e,message:j.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Ve.create=(e,t)=>new Ve({valueType:e,minSize:null,maxSize:null,typeName:st.ZodSet,...H(t)});class ze extends ${constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==w.function)return F(t,{code:k.invalid_type,expected:w.function,received:t.parsedType}),I;function n(e,n){return P({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,D(),R].filter(e=>!!e),issueData:{code:k.invalid_arguments,argumentsError:n}})}function r(e,n){return P({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,D(),R].filter(e=>!!e),issueData:{code:k.invalid_return_type,returnTypeError:n}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof Ge){const e=this;return L(async function(...t){const o=new C([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}{const e=this;return L(function(...t){const o=e._def.args.safeParse(t,i);if(!o.success)throw new C([n(t,o.error)]);const s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new C([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ze({...this._def,args:Le.create(e).rest(Te.create())})}returns(e){return new ze({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new ze({args:e||Le.create([]).rest(Te.create()),returns:t||Te.create(),typeName:st.ZodFunction,...H(n)})}}class je extends ${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})}}je.create=(e,t)=>new je({getter:e,typeName:st.ZodLazy,...H(t)});class Ke extends ${_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return F(t,{received:t.data,code:k.invalid_literal,expected:this._def.value}),I}return{status:"valid",value:e.data}}get value(){return this._def.value}}function qe(e,t){return new He({values:e,typeName:st.ZodEnum,...H(t)})}Ke.create=(e,t)=>new Ke({value:e,typeName:st.ZodLiteral,...H(t)});class He extends ${_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),n=this._def.values;return F(t,{expected:A.joinValues(n),received:t.parsedType,code:k.invalid_type}),I}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return F(t,{received:t.data,code:k.invalid_enum_value,options:n}),I}return L(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 He.create(e,{...this._def,...t})}exclude(e,t=this._def){return He.create(this.options.fil