UNPKG

@kaibanjs/tools

Version:

A set of tools to work with LLMs and KaibanJS

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