UNPKG

@hashgraphonline/standards-agent-kit

Version:

A modular SDK for building on-chain autonomous agents using Hashgraph Online Standards, including HCS-10 for agent discovery and communication. https://hol.org

1 lines 252 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("unenv/node/process"),require("unenv/node/buffer"),require("@hashgraph/sdk"),require("@hashgraphonline/standards-sdk"),require("hedera-agent-kit"),require("unenv/node/fs"),require("unenv/node/path"),require("unenv/polyfill/globalthis"),require("unenv/node/timers"),require("unenv/node/fs/promises")):"function"==typeof define&&define.amd?define(["exports","unenv/node/process","unenv/node/buffer","@hashgraph/sdk","@hashgraphonline/standards-sdk","hedera-agent-kit","unenv/node/fs","unenv/node/path","unenv/polyfill/globalthis","unenv/node/timers","unenv/node/fs/promises"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).StandardsAgentKit={},e.process,e["unenv/node/buffer"],e.HederaSDK,e.StandardsSDK,e.HederaAgentKit,e.fs,e["unenv/node/path"],e["unenv/polyfill/globalthis"],e["unenv/node/timers"],e["unenv/node/fs/promises"])}(this,function(e,t,n,i,r,s,a,o,c,d,l){"use strict";function u(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const n in e)if("default"!==n){const i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:()=>e[n]})}return t.default=e,Object.freeze(t)}const p=u(o),h=u(l);class f extends s.BaseHederaTransactionTool{constructor(e){super(e),this.namespace="hcs10",this.hcs10Builder=e.hcs10Builder}getServiceBuilder(){return this.hcs10Builder}}class g extends s.BaseHederaQueryTool{constructor(e){super(e),this.namespace="hcs10",this.hcs10Builder=e.hcs10Builder}getServiceBuilder(){return this.hcs10Builder}}var m,y,b;(y=m||(m={})).assertEqual=e=>{},y.assertIs=function(e){},y.assertNever=function(e){throw new Error},y.arrayToEnum=e=>{const t={};for(const n of e)t[n]=n;return t},y.getValidEnumValues=e=>{const t=y.objectKeys(e).filter(t=>"number"!=typeof e[e[t]]),n={};for(const i of t)n[i]=e[i];return y.objectValues(n)},y.objectValues=e=>y.objectKeys(e).map(function(t){return e[t]}),y.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},y.find=(e,t)=>{for(const n of e)if(t(n))return n},y.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,y.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},y.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t,(b||(b={})).mergeShapes=(e,t)=>({...e,...t});const w=m.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),v=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}},I=m.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class T extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(e){return e.message},n={_errors:[]},i=e=>{for(const r of e.issues)if("invalid_union"===r.code)r.unionErrors.map(i);else if("invalid_return_type"===r.code)i(r.returnTypeError);else if("invalid_arguments"===r.code)i(r.argumentsError);else if(0===r.path.length)n._errors.push(t(r));else{let e=n,i=0;for(;i<r.path.length;){const n=r.path[i];i===r.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(r))):e[n]=e[n]||{_errors:[]},e=e[n],i++}}};return i(this),n}static assert(e){if(!(e instanceof T))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,m.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t={},n=[];for(const i of this.issues)if(i.path.length>0){const n=i.path[0];t[n]=t[n]||[],t[n].push(e(i))}else n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}T.create=e=>new T(e);const A=(e,t)=>{let n;switch(e.code){case I.invalid_type:n=e.received===w.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case I.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,m.jsonStringifyReplacer)}`;break;case I.unrecognized_keys:n=`Unrecognized key(s) in object: ${m.joinValues(e.keys,", ")}`;break;case I.invalid_union:n="Invalid input";break;case I.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${m.joinValues(e.options)}`;break;case I.invalid_enum_value:n=`Invalid enum value. Expected ${m.joinValues(e.options)}, received '${e.received}'`;break;case I.invalid_arguments:n="Invalid function arguments";break;case I.invalid_return_type:n="Invalid function return type";break;case I.invalid_date:n="Invalid date";break;case I.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}"`:m.assertNever(e.validation):n="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case I.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 I.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 I.custom:n="Invalid input";break;case I.invalid_intersection_types:n="Intersection results could not be merged";break;case I.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case I.not_finite:n="Number must be finite";break;default:n=t.defaultError,m.assertNever(e)}return{message:n}};let _=A;function C(e,t){const n=_,i=(e=>{const{data:t,path:n,errorMaps:i,issueData:r}=e,s=[...n,...r.path||[]],a={...r,path:s};if(void 0!==r.message)return{...r,path:s,message:r.message};let o="";const c=i.filter(e=>!!e).slice().reverse();for(const d of c)o=d(a,{data:t,defaultError:o}).message;return{...r,path:s,message:o}})({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===A?void 0:A].filter(e=>!!e)});e.common.issues.push(i)}class E{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 i of t){if("aborted"===i.status)return S;"dirty"===i.status&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const i of t){const e=await i.key,t=await i.value;n.push({key:e,value:t})}return E.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:t,value:r}=i;if("aborted"===t.status)return S;if("aborted"===r.status)return S;"dirty"===t.status&&e.dirty(),"dirty"===r.status&&e.dirty(),"__proto__"===t.value||void 0===r.value&&!i.alwaysSet||(n[t.value]=r.value)}return{status:e.value,value:n}}}const S=Object.freeze({status:"aborted"}),R=e=>({status:"dirty",value:e}),x=e=>({status:"valid",value:e}),k=e=>"aborted"===e.status,O=e=>"dirty"===e.status,N=e=>"valid"===e.status,$=e=>"undefined"!=typeof Promise&&e instanceof Promise;var B,P;(P=B||(B={})).errToObj=e=>"string"==typeof e?{message:e}:e||{},P.toString=e=>"string"==typeof e?e:e?.message;class M{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}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(N(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new T(e.common.issues);return this._error=t,this._error}}};function F(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:i,description:r}=e;if(t&&(n||i))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:r};return{errorMap:(t,r)=>{const{message:s}=e;return"invalid_enum_value"===t.code?{message:s??r.defaultError}:void 0===r.data?{message:s??i??r.defaultError}:"invalid_type"!==t.code?{message:r.defaultError}:{message:s??n??r.defaultError}},description:r}}class D{get description(){return this._def.description}_getType(e){return v(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:v(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new E,ctx:{common:e.parent.common,data:e.data,parsedType:v(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 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:v(e)},i=this._parseSync({data:e,path:n.path,parent:n});return q(n,i)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:v(e)};if(!this["~standard"].async)try{const n=this._parseSync({data:e,path:[],parent:t});return N(n)?{value:n.value}:{issues:t.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>N(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:v(e)},i=this._parse({data:e,path:n.path,parent:n}),r=await($(i)?i:Promise.resolve(i));return q(n,r)}refine(e,t){const n=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement((t,i)=>{const r=e(t),s=()=>i.addIssue({code:I.custom,...n(t)});return"undefined"!=typeof Promise&&r instanceof Promise?r.then(e=>!!e||(s(),!1)):!!r||(s(),!1)})}refinement(e,t){return this._refinement((n,i)=>!!e(n)||(i.addIssue("function"==typeof t?t(n,i):t),!1))}_refinement(e){return new Fe({schema:this,typeName:We.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 De.create(this,this._def)}nullable(){return Le.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Te.create(this)}promise(){return qe.create(this,this._def)}or(e){return Ce.create([this,e],this._def)}and(e){return Se.create(this,e,this._def)}transform(e){return new Fe({...F(this._def),schema:this,typeName:We.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new He({...F(this._def),innerType:this,defaultValue:t,typeName:We.ZodDefault})}brand(){return new je({typeName:We.ZodBranded,type:this,...F(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new Ke({...F(this._def),innerType:this,catchValue:t,typeName:We.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return Ze.create(this,e)}readonly(){return ze.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const L=/^c[^\s-]{8,}$/i,H=/^[0-9a-z]+$/,K=/^[0-9A-HJKMNP-TV-Z]{26}$/i,U=/^[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,Z=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,z=/^[-+]?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)?)??$/,W=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let G;const V=/^(?:(?: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])$/,Q=/^(?:(?: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])$/,J=/^(([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]))$/,X=/^(([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])$/,Y=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ee=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,te="((\\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])))",ne=new RegExp(`^${te}$`);function ie(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e.precision?"+":"?"}`}function re(e){return new RegExp(`^${ie(e)}$`)}function se(e){let t=`${te}T${ie(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 ae(e,t){return!("v4"!==t&&t||!V.test(e))||!("v6"!==t&&t||!J.test(e))}function oe(e,t){if(!Z.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const i=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),r=JSON.parse(atob(i));return"object"==typeof r&&null!==r&&((!("typ"in r)||"JWT"===r?.typ)&&(!!r.alg&&(!t||r.alg===t)))}catch{return!1}}function ce(e,t){return!("v4"!==t&&t||!Q.test(e))||!("v6"!==t&&t||!X.test(e))}class de extends D{_parse(e){this._def.coerce&&(e.data=String(e.data));if(this._getType(e)!==w.string){const t=this._getOrReturnCtx(e);return C(t,{code:I.invalid_type,expected:w.string,received:t.parsedType}),S}const t=new E;let n;for(const i of this._def.checks)if("min"===i.kind)e.data.length<i.value&&(n=this._getOrReturnCtx(e,n),C(n,{code:I.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),t.dirty());else if("max"===i.kind)e.data.length>i.value&&(n=this._getOrReturnCtx(e,n),C(n,{code:I.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),t.dirty());else if("length"===i.kind){const r=e.data.length>i.value,s=e.data.length<i.value;(r||s)&&(n=this._getOrReturnCtx(e,n),r?C(n,{code:I.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):s&&C(n,{code:I.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),t.dirty())}else if("email"===i.kind)W.test(e.data)||(n=this._getOrReturnCtx(e,n),C(n,{validation:"email",code:I.invalid_string,message:i.message}),t.dirty());else if("emoji"===i.kind)G||(G=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),G.test(e.data)||(n=this._getOrReturnCtx(e,n),C(n,{validation:"emoji",code:I.invalid_string,message:i.message}),t.dirty());else if("uuid"===i.kind)U.test(e.data)||(n=this._getOrReturnCtx(e,n),C(n,{validation:"uuid",code:I.invalid_string,message:i.message}),t.dirty());else if("nanoid"===i.kind)j.test(e.data)||(n=this._getOrReturnCtx(e,n),C(n,{validation:"nanoid",code:I.invalid_string,message:i.message}),t.dirty());else if("cuid"===i.kind)L.test(e.data)||(n=this._getOrReturnCtx(e,n),C(n,{validation:"cuid",code:I.invalid_string,message:i.message}),t.dirty());else if("cuid2"===i.kind)H.test(e.data)||(n=this._getOrReturnCtx(e,n),C(n,{validation:"cuid2",code:I.invalid_string,message:i.message}),t.dirty());else if("ulid"===i.kind)K.test(e.data)||(n=this._getOrReturnCtx(e,n),C(n,{validation:"ulid",code:I.invalid_string,message:i.message}),t.dirty());else if("url"===i.kind)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),C(n,{validation:"url",code:I.invalid_string,message:i.message}),t.dirty()}else if("regex"===i.kind){i.regex.lastIndex=0;i.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),C(n,{validation:"regex",code:I.invalid_string,message:i.message}),t.dirty())}else if("trim"===i.kind)e.data=e.data.trim();else if("includes"===i.kind)e.data.includes(i.value,i.position)||(n=this._getOrReturnCtx(e,n),C(n,{code:I.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),t.dirty());else if("toLowerCase"===i.kind)e.data=e.data.toLowerCase();else if("toUpperCase"===i.kind)e.data=e.data.toUpperCase();else if("startsWith"===i.kind)e.data.startsWith(i.value)||(n=this._getOrReturnCtx(e,n),C(n,{code:I.invalid_string,validation:{startsWith:i.value},message:i.message}),t.dirty());else if("endsWith"===i.kind)e.data.endsWith(i.value)||(n=this._getOrReturnCtx(e,n),C(n,{code:I.invalid_string,validation:{endsWith:i.value},message:i.message}),t.dirty());else if("datetime"===i.kind){se(i).test(e.data)||(n=this._getOrReturnCtx(e,n),C(n,{code:I.invalid_string,validation:"datetime",message:i.message}),t.dirty())}else if("date"===i.kind){ne.test(e.data)||(n=this._getOrReturnCtx(e,n),C(n,{code:I.invalid_string,validation:"date",message:i.message}),t.dirty())}else if("time"===i.kind){re(i).test(e.data)||(n=this._getOrReturnCtx(e,n),C(n,{code:I.invalid_string,validation:"time",message:i.message}),t.dirty())}else"duration"===i.kind?z.test(e.data)||(n=this._getOrReturnCtx(e,n),C(n,{validation:"duration",code:I.invalid_string,message:i.message}),t.dirty()):"ip"===i.kind?ae(e.data,i.version)||(n=this._getOrReturnCtx(e,n),C(n,{validation:"ip",code:I.invalid_string,message:i.message}),t.dirty()):"jwt"===i.kind?oe(e.data,i.alg)||(n=this._getOrReturnCtx(e,n),C(n,{validation:"jwt",code:I.invalid_string,message:i.message}),t.dirty()):"cidr"===i.kind?ce(e.data,i.version)||(n=this._getOrReturnCtx(e,n),C(n,{validation:"cidr",code:I.invalid_string,message:i.message}),t.dirty()):"base64"===i.kind?Y.test(e.data)||(n=this._getOrReturnCtx(e,n),C(n,{validation:"base64",code:I.invalid_string,message:i.message}),t.dirty()):"base64url"===i.kind?ee.test(e.data)||(n=this._getOrReturnCtx(e,n),C(n,{validation:"base64url",code:I.invalid_string,message:i.message}),t.dirty()):m.assertNever(i);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:I.invalid_string,...B.errToObj(n)})}_addCheck(e){return new de({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...B.errToObj(e)})}url(e){return this._addCheck({kind:"url",...B.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...B.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...B.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...B.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...B.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...B.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...B.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...B.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...B.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...B.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...B.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...B.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,...B.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,...B.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...B.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...B.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...B.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...B.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...B.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...B.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...B.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...B.errToObj(t)})}nonempty(e){return this.min(1,B.errToObj(e))}trim(){return new de({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new de({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new de({...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 le(e,t){const n=(e.toString().split(".")[1]||"").length,i=(t.toString().split(".")[1]||"").length,r=n>i?n:i;return Number.parseInt(e.toFixed(r).replace(".",""))%Number.parseInt(t.toFixed(r).replace(".",""))/10**r}de.create=e=>new de({checks:[],typeName:We.ZodString,coerce:e?.coerce??!1,...F(e)});class ue extends D{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){this._def.coerce&&(e.data=Number(e.data));if(this._getType(e)!==w.number){const t=this._getOrReturnCtx(e);return C(t,{code:I.invalid_type,expected:w.number,received:t.parsedType}),S}let t;const n=new E;for(const i of this._def.checks)if("int"===i.kind)m.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),C(t,{code:I.invalid_type,expected:"integer",received:"float",message:i.message}),n.dirty());else if("min"===i.kind){(i.inclusive?e.data<i.value:e.data<=i.value)&&(t=this._getOrReturnCtx(e,t),C(t,{code:I.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty())}else if("max"===i.kind){(i.inclusive?e.data>i.value:e.data>=i.value)&&(t=this._getOrReturnCtx(e,t),C(t,{code:I.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty())}else"multipleOf"===i.kind?0!==le(e.data,i.value)&&(t=this._getOrReturnCtx(e,t),C(t,{code:I.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):"finite"===i.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),C(t,{code:I.not_finite,message:i.message}),n.dirty()):m.assertNever(i);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,B.toString(t))}gt(e,t){return this.setLimit("min",e,!1,B.toString(t))}lte(e,t){return this.setLimit("max",e,!0,B.toString(t))}lt(e,t){return this.setLimit("max",e,!1,B.toString(t))}setLimit(e,t,n,i){return new ue({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:B.toString(i)}]})}_addCheck(e){return new ue({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:B.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:B.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:B.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:B.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:B.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:B.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:B.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:B.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:B.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&&m.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)}}ue.create=e=>new ue({checks:[],typeName:We.ZodNumber,coerce:e?.coerce||!1,...F(e)});class pe extends D{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 E;for(const i of this._def.checks)if("min"===i.kind){(i.inclusive?e.data<i.value:e.data<=i.value)&&(t=this._getOrReturnCtx(e,t),C(t,{code:I.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty())}else if("max"===i.kind){(i.inclusive?e.data>i.value:e.data>=i.value)&&(t=this._getOrReturnCtx(e,t),C(t,{code:I.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty())}else"multipleOf"===i.kind?e.data%i.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),C(t,{code:I.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):m.assertNever(i);return{status:n.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return C(t,{code:I.invalid_type,expected:w.bigint,received:t.parsedType}),S}gte(e,t){return this.setLimit("min",e,!0,B.toString(t))}gt(e,t){return this.setLimit("min",e,!1,B.toString(t))}lte(e,t){return this.setLimit("max",e,!0,B.toString(t))}lt(e,t){return this.setLimit("max",e,!1,B.toString(t))}setLimit(e,t,n,i){return new pe({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:B.toString(i)}]})}_addCheck(e){return new pe({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:B.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:B.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:B.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:B.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:B.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}}pe.create=e=>new pe({checks:[],typeName:We.ZodBigInt,coerce:e?.coerce??!1,...F(e)});class he extends D{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==w.boolean){const t=this._getOrReturnCtx(e);return C(t,{code:I.invalid_type,expected:w.boolean,received:t.parsedType}),S}return x(e.data)}}he.create=e=>new he({typeName:We.ZodBoolean,coerce:e?.coerce||!1,...F(e)});class fe extends D{_parse(e){this._def.coerce&&(e.data=new Date(e.data));if(this._getType(e)!==w.date){const t=this._getOrReturnCtx(e);return C(t,{code:I.invalid_type,expected:w.date,received:t.parsedType}),S}if(Number.isNaN(e.data.getTime())){return C(this._getOrReturnCtx(e),{code:I.invalid_date}),S}const t=new E;let n;for(const i of this._def.checks)"min"===i.kind?e.data.getTime()<i.value&&(n=this._getOrReturnCtx(e,n),C(n,{code:I.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),t.dirty()):"max"===i.kind?e.data.getTime()>i.value&&(n=this._getOrReturnCtx(e,n),C(n,{code:I.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),t.dirty()):m.assertNever(i);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new fe({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:B.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:B.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}}fe.create=e=>new fe({checks:[],coerce:e?.coerce||!1,typeName:We.ZodDate,...F(e)});class ge extends D{_parse(e){if(this._getType(e)!==w.symbol){const t=this._getOrReturnCtx(e);return C(t,{code:I.invalid_type,expected:w.symbol,received:t.parsedType}),S}return x(e.data)}}ge.create=e=>new ge({typeName:We.ZodSymbol,...F(e)});class me extends D{_parse(e){if(this._getType(e)!==w.undefined){const t=this._getOrReturnCtx(e);return C(t,{code:I.invalid_type,expected:w.undefined,received:t.parsedType}),S}return x(e.data)}}me.create=e=>new me({typeName:We.ZodUndefined,...F(e)});class ye extends D{_parse(e){if(this._getType(e)!==w.null){const t=this._getOrReturnCtx(e);return C(t,{code:I.invalid_type,expected:w.null,received:t.parsedType}),S}return x(e.data)}}ye.create=e=>new ye({typeName:We.ZodNull,...F(e)});class be extends D{constructor(){super(...arguments),this._any=!0}_parse(e){return x(e.data)}}be.create=e=>new be({typeName:We.ZodAny,...F(e)});class we extends D{constructor(){super(...arguments),this._unknown=!0}_parse(e){return x(e.data)}}we.create=e=>new we({typeName:We.ZodUnknown,...F(e)});class ve extends D{_parse(e){const t=this._getOrReturnCtx(e);return C(t,{code:I.invalid_type,expected:w.never,received:t.parsedType}),S}}ve.create=e=>new ve({typeName:We.ZodNever,...F(e)});class Ie extends D{_parse(e){if(this._getType(e)!==w.undefined){const t=this._getOrReturnCtx(e);return C(t,{code:I.invalid_type,expected:w.void,received:t.parsedType}),S}return x(e.data)}}Ie.create=e=>new Ie({typeName:We.ZodVoid,...F(e)});class Te extends D{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==w.array)return C(t,{code:I.invalid_type,expected:w.array,received:t.parsedType}),S;if(null!==i.exactLength){const e=t.data.length>i.exactLength.value,r=t.data.length<i.exactLength.value;(e||r)&&(C(t,{code:e?I.too_big:I.too_small,minimum:r?i.exactLength.value:void 0,maximum:e?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(null!==i.minLength&&t.data.length<i.minLength.value&&(C(t,{code:I.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),null!==i.maxLength&&t.data.length>i.maxLength.value&&(C(t,{code:I.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>i.type._parseAsync(new M(t,e,t.path,n)))).then(e=>E.mergeArray(n,e));const r=[...t.data].map((e,n)=>i.type._parseSync(new M(t,e,t.path,n)));return E.mergeArray(n,r)}get element(){return this._def.type}min(e,t){return new Te({...this._def,minLength:{value:e,message:B.toString(t)}})}max(e,t){return new Te({...this._def,maxLength:{value:e,message:B.toString(t)}})}length(e,t){return new Te({...this._def,exactLength:{value:e,message:B.toString(t)}})}nonempty(e){return this.min(1,e)}}function Ae(e){if(e instanceof _e){const t={};for(const n in e.shape){const i=e.shape[n];t[n]=De.create(Ae(i))}return new _e({...e._def,shape:()=>t})}return e instanceof Te?new Te({...e._def,type:Ae(e.element)}):e instanceof De?De.create(Ae(e.unwrap())):e instanceof Le?Le.create(Ae(e.unwrap())):e instanceof Re?Re.create(e.items.map(e=>Ae(e))):e}Te.create=(e,t)=>new Te({type:e,minLength:null,maxLength:null,exactLength:null,typeName:We.ZodArray,...F(t)});class _e extends D{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=m.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 C(t,{code:I.invalid_type,expected:w.object,received:t.parsedType}),S}const{status:t,ctx:n}=this._processInputParams(e),{shape:i,keys:r}=this._getCached(),s=[];if(!(this._def.catchall instanceof ve&&"strip"===this._def.unknownKeys))for(const o in n.data)r.includes(o)||s.push(o);const a=[];for(const o of r){const e=i[o],t=n.data[o];a.push({key:{status:"valid",value:o},value:e._parse(new M(n,t,n.path,o)),alwaysSet:o in n.data})}if(this._def.catchall instanceof ve){const e=this._def.unknownKeys;if("passthrough"===e)for(const t of s)a.push({key:{status:"valid",value:t},value:{status:"valid",value:n.data[t]}});else if("strict"===e)s.length>0&&(C(n,{code:I.unrecognized_keys,keys:s}),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 s){const i=n.data[t];a.push({key:{status:"valid",value:t},value:e._parse(new M(n,i,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const e=[];for(const t of a){const n=await t.key,i=await t.value;e.push({key:n,value:i,alwaysSet:t.alwaysSet})}return e}).then(e=>E.mergeObjectSync(t,e)):E.mergeObjectSync(t,a)}get shape(){return this._def.shape()}strict(e){return B.errToObj,new _e({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,n)=>{const i=this._def.errorMap?.(t,n).message??n.defaultError;return"unrecognized_keys"===t.code?{message:B.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new _e({...this._def,unknownKeys:"strip"})}passthrough(){return new _e({...this._def,unknownKeys:"passthrough"})}extend(e){return new _e({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new _e({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:We.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new _e({...this._def,catchall:e})}pick(e){const t={};for(const n of m.objectKeys(e))e[n]&&this.shape[n]&&(t[n]=this.shape[n]);return new _e({...this._def,shape:()=>t})}omit(e){const t={};for(const n of m.objectKeys(this.shape))e[n]||(t[n]=this.shape[n]);return new _e({...this._def,shape:()=>t})}deepPartial(){return Ae(this)}partial(e){const t={};for(const n of m.objectKeys(this.shape)){const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}return new _e({...this._def,shape:()=>t})}required(e){const t={};for(const n of m.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let e=this.shape[n];for(;e instanceof De;)e=e._def.innerType;t[n]=e}return new _e({...this._def,shape:()=>t})}keyof(){return Be(m.objectKeys(this.shape))}}_e.create=(e,t)=>new _e({shape:()=>e,unknownKeys:"strip",catchall:ve.create(),typeName:We.ZodObject,...F(t)}),_e.strictCreate=(e,t)=>new _e({shape:()=>e,unknownKeys:"strict",catchall:ve.create(),typeName:We.ZodObject,...F(t)}),_e.lazycreate=(e,t)=>new _e({shape:e,unknownKeys:"strip",catchall:ve.create(),typeName:We.ZodObject,...F(t)});class Ce extends D{_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 i of e)if("dirty"===i.result.status)return t.common.issues.push(...i.ctx.common.issues),i.result;const n=e.map(e=>new T(e.ctx.common.issues));return C(t,{code:I.invalid_union,unionErrors:n}),S});{let e;const i=[];for(const s of n){const n={...t,common:{...t.common,issues:[]},parent:null},r=s._parseSync({data:t.data,path:t.path,parent:n});if("valid"===r.status)return r;"dirty"!==r.status||e||(e={result:r,ctx:n}),n.common.issues.length&&i.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const r=i.map(e=>new T(e));return C(t,{code:I.invalid_union,unionErrors:r}),S}}get options(){return this._def.options}}function Ee(e,t){const n=v(e),i=v(t);if(e===t)return{valid:!0,data:e};if(n===w.object&&i===w.object){const n=m.objectKeys(t),i=m.objectKeys(e).filter(e=>-1!==n.indexOf(e)),r={...e,...t};for(const s of i){const n=Ee(e[s],t[s]);if(!n.valid)return{valid:!1};r[s]=n.data}return{valid:!0,data:r}}if(n===w.array&&i===w.array){if(e.length!==t.length)return{valid:!1};const n=[];for(let i=0;i<e.length;i++){const r=Ee(e[i],t[i]);if(!r.valid)return{valid:!1};n.push(r.data)}return{valid:!0,data:n}}return n===w.date&&i===w.date&&+e===+t?{valid:!0,data:e}:{valid:!1}}Ce.create=(e,t)=>new Ce({options:e,typeName:We.ZodUnion,...F(t)});class Se extends D{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(e,i)=>{if(k(e)||k(i))return S;const r=Ee(e.value,i.value);return r.valid?((O(e)||O(i))&&t.dirty(),{status:t.value,value:r.data}):(C(n,{code:I.invalid_intersection_types}),S)};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])=>i(e,t)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}Se.create=(e,t,n)=>new Se({left:e,right:t,typeName:We.ZodIntersection,...F(n)});class Re extends D{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==w.array)return C(n,{code:I.invalid_type,expected:w.array,received:n.parsedType}),S;if(n.data.length<this._def.items.length)return C(n,{code:I.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),S;!this._def.rest&&n.data.length>this._def.items.length&&(C(n,{code:I.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...n.data].map((e,t)=>{const i=this._def.items[t]||this._def.rest;return i?i._parse(new M(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(i).then(e=>E.mergeArray(t,e)):E.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new Re({...this._def,rest:e})}}Re.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Re({items:e,typeName:We.ZodTuple,rest:null,...F(t)})};class xe extends D{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 C(n,{code:I.invalid_type,expected:w.object,received:n.parsedType}),S;const i=[],r=this._def.keyType,s=this._def.valueType;for(const a in n.data)i.push({key:r._parse(new M(n,a,n.path,a)),value:s._parse(new M(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?E.mergeObjectAsync(t,i):E.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return new xe(t instanceof D?{keyType:e,valueType:t,typeName:We.ZodRecord,...F(n)}:{keyType:de.create(),valueType:e,typeName:We.ZodRecord,...F(t)})}}class ke extends D{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 C(n,{code:I.invalid_type,expected:w.map,received:n.parsedType}),S;const i=this._def.keyType,r=this._def.valueType,s=[...n.data.entries()].map(([e,t],s)=>({key:i._parse(new M(n,e,n.path,[s,"key"])),value:r._parse(new M(n,t,n.path,[s,"value"]))}));if(n.common.async){const e=new Map;return Promise.resolve().then(async()=>{for(const n of s){const i=await n.key,r=await n.value;if("aborted"===i.status||"aborted"===r.status)return S;"dirty"!==i.status&&"dirty"!==r.status||t.dirty(),e.set(i.value,r.value)}return{status:t.value,value:e}})}{const e=new Map;for(const n of s){const i=n.key,r=n.value;if("aborted"===i.status||"aborted"===r.status)return S;"dirty"!==i.status&&"dirty"!==r.status||t.dirty(),e.set(i.value,r.value)}return{status:t.value,value:e}}}}ke.create=(e,t,n)=>new ke({valueType:t,keyType:e,typeName:We.ZodMap,...F(n)});class Oe extends D{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==w.set)return C(n,{code:I.invalid_type,expected:w.set,received:n.parsedType}),S;const i=this._def;null!==i.minSize&&n.data.size<i.minSize.value&&(C(n,{code:I.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),null!==i.maxSize&&n.data.size>i.maxSize.value&&(C(n,{code:I.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const r=this._def.valueType;function s(e){const n=new Set;for(const i of e){if("aborted"===i.status)return S;"dirty"===i.status&&t.dirty(),n.add(i.value)}return{status:t.value,value:n}}const a=[...n.data.values()].map((e,t)=>r._parse(new M(n,e,n.path,t)));return n.common.async?Promise.all(a).then(e=>s(e)):s(a)}min(e,t){return new Oe({...this._def,minSize:{value:e,message:B.toString(t)}})}max(e,t){return new Oe({...this._def,maxSize:{value:e,message:B.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Oe.create=(e,t)=>new Oe({valueType:e,minSize:null,maxSize:null,typeName:We.ZodSet,...F(t)});class Ne extends D{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})}}Ne.create=(e,t)=>new Ne({getter:e,typeName:We.ZodLazy,...F(t)});class $e extends D{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return C(t,{received:t.data,code:I.invalid_literal,expected:this._def.value}),S}return{status:"valid",value:e.data}}get value(){return this._def.value}}function Be(e,t){return new Pe({values:e,typeName:We.ZodEnum,...F(t)})}$e.create=(e,t)=>new $e({value:e,typeName:We.ZodLiteral,...F(t)});class Pe extends D{_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),n=this._def.values;return C(t,{expected:m.joinValues(n),received:t.parsedType,code:I.invalid_type}),S}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 C(t,{received:t.data,code:I.invalid_enum_value,options:n}),S}return x(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 Pe.create(e,{...this._def,...t})}exclude(e,t=this._def){return Pe.create(this.options.filter(t=>!e.includes(t)),{...this._def,...t})}}Pe.create=Be;class Me extends D{_parse(e){const t=m.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==w.string&&n.parsedType!==w.number){const e=m.objectValues(t);return C(n,{expected:m.joinValues(e),received:n.parsedType,code:I.invalid_type}),S}if(this._cache||(this._cache=new Set(m.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const e=m.objectValues(t);return C(n,{received:n.data,code:I.invalid_enum_value,options:e}),S}return x(e.data)}get enum(){return this._def.values}}Me.create=(e,t)=>new Me({values:e,typeName:We.ZodNativeEnum,...F(t)});class qe extends D{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==w.promise&&!1===t.common.async)return C(t,{code:I.invalid_type,expected:w.promise,received:t.parsedType}),S;const n=t.parsedType===w.promise?t.data:Promise.resolve(t.data);return x(n.then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}qe.create=(e,t)=>new qe({type:e,typeName:We.ZodPromise,...F(t)});class Fe extends D{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===We.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,r={addIssue:e=>{C(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(r.addIssue=r.addIssue.bind(r),"preprocess"===i.type){const e=i.transform(n.data,r);if(n.common.async)return Promise.resolve(e).then(async e=>{if("aborted"===t.value)return S;const i=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return"aborted"===i.status?S:"dirty"===i.status||"dirty"===t.value?R(i.value):i});{if("aborted"===t.value)return S;const i=this._def.schema._parseSync({data:e,path:n.path,parent:n