UNPKG

@getopenpay/openpay-js

Version:

Accept payments through OpenPay, right on your site

1 lines 180 kB
(function(Ce,He){typeof exports=="object"&&typeof module<"u"?He(exports):typeof define=="function"&&define.amd?define(["exports"],He):(Ce=typeof globalThis<"u"?globalThis:Ce||self,He(Ce.OpenPay={}))})(this,function(Ce){"use strict";var Go;const He="https://cde.getopenpay.com";var R;(function(t){t.assertEqual=o=>o;function e(o){}t.assertIs=e;function r(o){throw new Error}t.assertNever=r,t.arrayToEnum=o=>{const s={};for(const i of o)s[i]=i;return s},t.getValidEnumValues=o=>{const s=t.objectKeys(o).filter(c=>typeof o[o[c]]!="number"),i={};for(const c of s)i[c]=o[c];return t.objectValues(i)},t.objectValues=o=>t.objectKeys(o).map(function(s){return o[s]}),t.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{const s=[];for(const i in o)Object.prototype.hasOwnProperty.call(o,i)&&s.push(i);return s},t.find=(o,s)=>{for(const i of o)if(s(i))return i},t.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&isFinite(o)&&Math.floor(o)===o;function n(o,s=" | "){return o.map(i=>typeof i=="string"?`'${i}'`:i).join(s)}t.joinValues=n,t.jsonStringifyReplacer=(o,s)=>typeof s=="bigint"?s.toString():s})(R||(R={}));var gr;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(gr||(gr={}));const v=R.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Re=t=>{switch(typeof t){case"undefined":return v.undefined;case"string":return v.string;case"number":return isNaN(t)?v.nan:v.number;case"boolean":return v.boolean;case"function":return v.function;case"bigint":return v.bigint;case"symbol":return v.symbol;case"object":return Array.isArray(t)?v.array:t===null?v.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?v.promise:typeof Map<"u"&&t instanceof Map?v.map:typeof Set<"u"&&t instanceof Set?v.set:typeof Date<"u"&&t instanceof Date?v.date:v.object;default:return v.unknown}},y=R.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"]),Bo=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class te extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const r=e||function(s){return s.message},n={_errors:[]},o=s=>{for(const i of s.issues)if(i.code==="invalid_union")i.unionErrors.map(o);else if(i.code==="invalid_return_type")o(i.returnTypeError);else if(i.code==="invalid_arguments")o(i.argumentsError);else if(i.path.length===0)n._errors.push(r(i));else{let c=n,l=0;for(;l<i.path.length;){const u=i.path[l];l===i.path.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(r(i))):c[u]=c[u]||{_errors:[]},c=c[u],l++}}};return o(this),n}static assert(e){if(!(e instanceof te))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,R.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){const r={},n=[];for(const o of this.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(e(o))):n.push(e(o));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}te.create=t=>new te(t);const Ke=(t,e)=>{let r;switch(t.code){case y.invalid_type:t.received===v.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case y.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,R.jsonStringifyReplacer)}`;break;case y.unrecognized_keys:r=`Unrecognized key(s) in object: ${R.joinValues(t.keys,", ")}`;break;case y.invalid_union:r="Invalid input";break;case y.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${R.joinValues(t.options)}`;break;case y.invalid_enum_value:r=`Invalid enum value. Expected ${R.joinValues(t.options)}, received '${t.received}'`;break;case y.invalid_arguments:r="Invalid function arguments";break;case y.invalid_return_type:r="Invalid function return type";break;case y.invalid_date:r="Invalid date";break;case y.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:R.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case y.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case y.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case y.custom:r="Invalid input";break;case y.invalid_intersection_types:r="Intersection results could not be merged";break;case y.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case y.not_finite:r="Number must be finite";break;default:r=e.defaultError,R.assertNever(t)}return{message:r}};let Wr=Ke;function qo(t){Wr=t}function Vt(){return Wr}const zt=t=>{const{data:e,path:r,errorMaps:n,issueData:o}=t,s=[...r,...o.path||[]],i={...o,path:s};if(o.message!==void 0)return{...o,path:s,message:o.message};let c="";const l=n.filter(u=>!!u).slice().reverse();for(const u of l)c=u(i,{data:e,defaultError:c}).message;return{...o,path:s,message:c}},Yo=[];function g(t,e){const r=Vt(),n=zt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Ke?void 0:Ke].filter(o=>!!o)});t.common.issues.push(n)}class H{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){const n=[];for(const o of r){if(o.status==="aborted")return S;o.status==="dirty"&&e.dirty(),n.push(o.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){const n=[];for(const o of r){const s=await o.key,i=await o.value;n.push({key:s,value:i})}return H.mergeObjectSync(e,n)}static mergeObjectSync(e,r){const n={};for(const o of r){const{key:s,value:i}=o;if(s.status==="aborted"||i.status==="aborted")return S;s.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof i.value<"u"||o.alwaysSet)&&(n[s.value]=i.value)}return{status:e.value,value:n}}}const S=Object.freeze({status:"aborted"}),Je=t=>({status:"dirty",value:t}),J=t=>({status:"valid",value:t}),vr=t=>t.status==="aborted",wr=t=>t.status==="dirty",dt=t=>t.status==="valid",pt=t=>typeof Promise<"u"&&t instanceof Promise;function Gt(t,e,r,n){if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(t)}function Hr(t,e,r,n,o){if(typeof e=="function"?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,r),r}typeof SuppressedError=="function"&&SuppressedError;var b;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(b||(b={}));var ft,mt;class fe{constructor(e,r,n,o){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=o}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 Kr=(t,e)=>{if(dt(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new te(t.common.issues);return this._error=r,this._error}}};function A(t){if(!t)return{};const{errorMap:e,invalid_type_error:r,required_error:n,description:o}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:o}:{errorMap:(i,c)=>{var l,u;const{message:d}=t;return i.code==="invalid_enum_value"?{message:d??c.defaultError}:typeof c.data>"u"?{message:(l=d??n)!==null&&l!==void 0?l:c.defaultError}:i.code!=="invalid_type"?{message:c.defaultError}:{message:(u=d??r)!==null&&u!==void 0?u:c.defaultError}},description:o}}class T{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)}get description(){return this._def.description}_getType(e){return Re(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Re(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new H,ctx:{common:e.parent.common,data:e.data,parsedType:Re(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if(pt(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){const r=this._parse(e);return Promise.resolve(r)}parse(e,r){const n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){var n;const o={common:{issues:[],async:(n=r==null?void 0:r.async)!==null&&n!==void 0?n:!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Re(e)},s=this._parseSync({data:e,path:o.path,parent:o});return Kr(o,s)}async parseAsync(e,r){const n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){const n={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Re(e)},o=this._parse({data:e,path:n.path,parent:n}),s=await(pt(o)?o:Promise.resolve(o));return Kr(n,s)}refine(e,r){const n=o=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(o):r;return this._refinement((o,s)=>{const i=e(o),c=()=>s.addIssue({code:y.custom,...n(o)});return typeof Promise<"u"&&i instanceof Promise?i.then(l=>l?!0:(c(),!1)):i?!0:(c(),!1)})}refinement(e,r){return this._refinement((n,o)=>e(n)?!0:(o.addIssue(typeof r=="function"?r(n,o):r),!1))}_refinement(e){return new ae({schema:this,typeName:C.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return he.create(this,this._def)}nullable(){return De.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return se.create(this,this._def)}promise(){return tt.create(this,this._def)}or(e){return gt.create([this,e],this._def)}and(e){return vt.create(this,e,this._def)}transform(e){return new ae({...A(this._def),schema:this,typeName:C.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new Ct({...A(this._def),innerType:this,defaultValue:r,typeName:C.ZodDefault})}brand(){return new kr({typeName:C.ZodBranded,type:this,...A(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new St({...A(this._def),innerType:this,catchValue:r,typeName:C.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Pt.create(this,e)}readonly(){return At.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Wo=/^c[^\s-]{8,}$/i,Ho=/^[0-9a-z]+$/,Ko=/^[0-9A-HJKMNP-TV-Z]{26}$/,Jo=/^[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,Qo=/^[a-z0-9_-]{21}$/i,Xo=/^[-+]?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)?)??$/,es=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ts="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let br;const rs=/^(?:(?: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])$/,ns=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,os=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Jr="((\\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])))",ss=new RegExp(`^${Jr}$`);function Qr(t){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`),e}function as(t){return new RegExp(`^${Qr(t)}$`)}function Xr(t){let e=`${Jr}T${Qr(t)}`;const r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function is(t,e){return!!((e==="v4"||!e)&&rs.test(t)||(e==="v6"||!e)&&ns.test(t))}class oe extends T{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==v.string){const s=this._getOrReturnCtx(e);return g(s,{code:y.invalid_type,expected:v.string,received:s.parsedType}),S}const n=new H;let o;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(o=this._getOrReturnCtx(e,o),g(o,{code:y.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(o=this._getOrReturnCtx(e,o),g(o,{code:y.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){const i=e.data.length>s.value,c=e.data.length<s.value;(i||c)&&(o=this._getOrReturnCtx(e,o),i?g(o,{code:y.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&g(o,{code:y.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")es.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"email",code:y.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")br||(br=new RegExp(ts,"u")),br.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"emoji",code:y.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")Jo.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"uuid",code:y.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")Qo.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"nanoid",code:y.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")Wo.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"cuid",code:y.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")Ho.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"cuid2",code:y.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")Ko.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"ulid",code:y.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{o=this._getOrReturnCtx(e,o),g(o,{validation:"url",code:y.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"regex",code:y.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(o=this._getOrReturnCtx(e,o),g(o,{code:y.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(o=this._getOrReturnCtx(e,o),g(o,{code:y.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(o=this._getOrReturnCtx(e,o),g(o,{code:y.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?Xr(s).test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{code:y.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?ss.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{code:y.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?as(s).test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{code:y.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?Xo.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"duration",code:y.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?is(e.data,s.version)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"ip",code:y.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?os.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"base64",code:y.invalid_string,message:s.message}),n.dirty()):R.assertNever(s);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(o=>e.test(o),{validation:r,code:y.invalid_string,...b.errToObj(n)})}_addCheck(e){return new oe({...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)})}ip(e){return this._addCheck({kind:"ip",...b.errToObj(e)})}datetime(e){var r,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(r=e==null?void 0:e.offset)!==null&&r!==void 0?r:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...b.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...b.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...b.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...b.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r==null?void 0:r.position,...b.errToObj(r==null?void 0:r.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...b.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...b.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...b.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...b.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...b.errToObj(r)})}nonempty(e){return this.min(1,b.errToObj(e))}trim(){return new oe({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new oe({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new oe({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}oe.create=t=>{var e;return new oe({checks:[],typeName:C.ZodString,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...A(t)})};function cs(t,e){const r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,o=r>n?r:n,s=parseInt(t.toFixed(o).replace(".","")),i=parseInt(e.toFixed(o).replace(".",""));return s%i/Math.pow(10,o)}class Ne extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==v.number){const s=this._getOrReturnCtx(e);return g(s,{code:y.invalid_type,expected:v.number,received:s.parsedType}),S}let n;const o=new H;for(const s of this._def.checks)s.kind==="int"?R.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{code:y.invalid_type,expected:"integer",received:"float",message:s.message}),o.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),g(n,{code:y.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),g(n,{code:y.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="multipleOf"?cs(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),g(n,{code:y.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{code:y.not_finite,message:s.message}),o.dirty()):R.assertNever(s);return{status:o.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,b.toString(r))}gt(e,r){return this.setLimit("min",e,!1,b.toString(r))}lte(e,r){return this.setLimit("max",e,!0,b.toString(r))}lt(e,r){return this.setLimit("max",e,!1,b.toString(r))}setLimit(e,r,n,o){return new Ne({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:b.toString(o)}]})}_addCheck(e){return new Ne({...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,r){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(r)})}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 r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&R.isInteger(e.value))}get isFinite(){let e=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}}Ne.create=t=>new Ne({checks:[],typeName:C.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...A(t)});class Oe extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==v.bigint){const s=this._getOrReturnCtx(e);return g(s,{code:y.invalid_type,expected:v.bigint,received:s.parsedType}),S}let n;const o=new H;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),g(n,{code:y.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),g(n,{code:y.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),g(n,{code:y.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):R.assertNever(s);return{status:o.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,b.toString(r))}gt(e,r){return this.setLimit("min",e,!1,b.toString(r))}lte(e,r){return this.setLimit("max",e,!0,b.toString(r))}lt(e,r){return this.setLimit("max",e,!1,b.toString(r))}setLimit(e,r,n,o){return new Oe({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:b.toString(o)}]})}_addCheck(e){return new Oe({...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,r){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(r)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}Oe.create=t=>{var e;return new Oe({checks:[],typeName:C.ZodBigInt,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...A(t)})};class ht extends T{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==v.boolean){const n=this._getOrReturnCtx(e);return g(n,{code:y.invalid_type,expected:v.boolean,received:n.parsedType}),S}return J(e.data)}}ht.create=t=>new ht({typeName:C.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...A(t)});class Ue extends T{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==v.date){const s=this._getOrReturnCtx(e);return g(s,{code:y.invalid_type,expected:v.date,received:s.parsedType}),S}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return g(s,{code:y.invalid_date}),S}const n=new H;let o;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(o=this._getOrReturnCtx(e,o),g(o,{code:y.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(o=this._getOrReturnCtx(e,o),g(o,{code:y.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):R.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ue({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:b.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:b.toString(r)})}get minDate(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}}Ue.create=t=>new Ue({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:C.ZodDate,...A(t)});class Bt extends T{_parse(e){if(this._getType(e)!==v.symbol){const n=this._getOrReturnCtx(e);return g(n,{code:y.invalid_type,expected:v.symbol,received:n.parsedType}),S}return J(e.data)}}Bt.create=t=>new Bt({typeName:C.ZodSymbol,...A(t)});class yt extends T{_parse(e){if(this._getType(e)!==v.undefined){const n=this._getOrReturnCtx(e);return g(n,{code:y.invalid_type,expected:v.undefined,received:n.parsedType}),S}return J(e.data)}}yt.create=t=>new yt({typeName:C.ZodUndefined,...A(t)});class _t extends T{_parse(e){if(this._getType(e)!==v.null){const n=this._getOrReturnCtx(e);return g(n,{code:y.invalid_type,expected:v.null,received:n.parsedType}),S}return J(e.data)}}_t.create=t=>new _t({typeName:C.ZodNull,...A(t)});class Qe extends T{constructor(){super(...arguments),this._any=!0}_parse(e){return J(e.data)}}Qe.create=t=>new Qe({typeName:C.ZodAny,...A(t)});class $e extends T{constructor(){super(...arguments),this._unknown=!0}_parse(e){return J(e.data)}}$e.create=t=>new $e({typeName:C.ZodUnknown,...A(t)});class Se extends T{_parse(e){const r=this._getOrReturnCtx(e);return g(r,{code:y.invalid_type,expected:v.never,received:r.parsedType}),S}}Se.create=t=>new Se({typeName:C.ZodNever,...A(t)});class qt extends T{_parse(e){if(this._getType(e)!==v.undefined){const n=this._getOrReturnCtx(e);return g(n,{code:y.invalid_type,expected:v.void,received:n.parsedType}),S}return J(e.data)}}qt.create=t=>new qt({typeName:C.ZodVoid,...A(t)});class se extends T{_parse(e){const{ctx:r,status:n}=this._processInputParams(e),o=this._def;if(r.parsedType!==v.array)return g(r,{code:y.invalid_type,expected:v.array,received:r.parsedType}),S;if(o.exactLength!==null){const i=r.data.length>o.exactLength.value,c=r.data.length<o.exactLength.value;(i||c)&&(g(r,{code:i?y.too_big:y.too_small,minimum:c?o.exactLength.value:void 0,maximum:i?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),n.dirty())}if(o.minLength!==null&&r.data.length<o.minLength.value&&(g(r,{code:y.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),n.dirty()),o.maxLength!==null&&r.data.length>o.maxLength.value&&(g(r,{code:y.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((i,c)=>o.type._parseAsync(new fe(r,i,r.path,c)))).then(i=>H.mergeArray(n,i));const s=[...r.data].map((i,c)=>o.type._parseSync(new fe(r,i,r.path,c)));return H.mergeArray(n,s)}get element(){return this._def.type}min(e,r){return new se({...this._def,minLength:{value:e,message:b.toString(r)}})}max(e,r){return new se({...this._def,maxLength:{value:e,message:b.toString(r)}})}length(e,r){return new se({...this._def,exactLength:{value:e,message:b.toString(r)}})}nonempty(e){return this.min(1,e)}}se.create=(t,e)=>new se({type:t,minLength:null,maxLength:null,exactLength:null,typeName:C.ZodArray,...A(e)});function Xe(t){if(t instanceof j){const e={};for(const r in t.shape){const n=t.shape[r];e[r]=he.create(Xe(n))}return new j({...t._def,shape:()=>e})}else return t instanceof se?new se({...t._def,type:Xe(t.element)}):t instanceof he?he.create(Xe(t.unwrap())):t instanceof De?De.create(Xe(t.unwrap())):t instanceof me?me.create(t.items.map(e=>Xe(e))):t}class j extends T{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),r=R.objectKeys(e);return this._cached={shape:e,keys:r}}_parse(e){if(this._getType(e)!==v.object){const u=this._getOrReturnCtx(e);return g(u,{code:y.invalid_type,expected:v.object,received:u.parsedType}),S}const{status:n,ctx:o}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),c=[];if(!(this._def.catchall instanceof Se&&this._def.unknownKeys==="strip"))for(const u in o.data)i.includes(u)||c.push(u);const l=[];for(const u of i){const d=s[u],p=o.data[u];l.push({key:{status:"valid",value:u},value:d._parse(new fe(o,p,o.path,u)),alwaysSet:u in o.data})}if(this._def.catchall instanceof Se){const u=this._def.unknownKeys;if(u==="passthrough")for(const d of c)l.push({key:{status:"valid",value:d},value:{status:"valid",value:o.data[d]}});else if(u==="strict")c.length>0&&(g(o,{code:y.unrecognized_keys,keys:c}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const d of c){const p=o.data[d];l.push({key:{status:"valid",value:d},value:u._parse(new fe(o,p,o.path,d)),alwaysSet:d in o.data})}}return o.common.async?Promise.resolve().then(async()=>{const u=[];for(const d of l){const p=await d.key,_=await d.value;u.push({key:p,value:_,alwaysSet:d.alwaysSet})}return u}).then(u=>H.mergeObjectSync(n,u)):H.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(e){return b.errToObj,new j({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{var o,s,i,c;const l=(i=(s=(o=this._def).errorMap)===null||s===void 0?void 0:s.call(o,r,n).message)!==null&&i!==void 0?i:n.defaultError;return r.code==="unrecognized_keys"?{message:(c=b.errToObj(e).message)!==null&&c!==void 0?c:l}:{message:l}}}:{}})}strip(){return new j({...this._def,unknownKeys:"strip"})}passthrough(){return new j({...this._def,unknownKeys:"passthrough"})}extend(e){return new j({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new j({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:C.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new j({...this._def,catchall:e})}pick(e){const r={};return R.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new j({...this._def,shape:()=>r})}omit(e){const r={};return R.objectKeys(this.shape).forEach(n=>{e[n]||(r[n]=this.shape[n])}),new j({...this._def,shape:()=>r})}deepPartial(){return Xe(this)}partial(e){const r={};return R.objectKeys(this.shape).forEach(n=>{const o=this.shape[n];e&&!e[n]?r[n]=o:r[n]=o.optional()}),new j({...this._def,shape:()=>r})}required(e){const r={};return R.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])r[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof he;)s=s._def.innerType;r[n]=s}}),new j({...this._def,shape:()=>r})}keyof(){return en(R.objectKeys(this.shape))}}j.create=(t,e)=>new j({shape:()=>t,unknownKeys:"strip",catchall:Se.create(),typeName:C.ZodObject,...A(e)}),j.strictCreate=(t,e)=>new j({shape:()=>t,unknownKeys:"strict",catchall:Se.create(),typeName:C.ZodObject,...A(e)}),j.lazycreate=(t,e)=>new j({shape:t,unknownKeys:"strip",catchall:Se.create(),typeName:C.ZodObject,...A(e)});class gt extends T{_parse(e){const{ctx:r}=this._processInputParams(e),n=this._def.options;function o(s){for(const c of s)if(c.result.status==="valid")return c.result;for(const c of s)if(c.result.status==="dirty")return r.common.issues.push(...c.ctx.common.issues),c.result;const i=s.map(c=>new te(c.ctx.common.issues));return g(r,{code:y.invalid_union,unionErrors:i}),S}if(r.common.async)return Promise.all(n.map(async s=>{const i={...r,common:{...r.common,issues:[]},parent:null};return{result:await s._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(o);{let s;const i=[];for(const l of n){const u={...r,common:{...r.common,issues:[]},parent:null},d=l._parseSync({data:r.data,path:r.path,parent:u});if(d.status==="valid")return d;d.status==="dirty"&&!s&&(s={result:d,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(s)return r.common.issues.push(...s.ctx.common.issues),s.result;const c=i.map(l=>new te(l));return g(r,{code:y.invalid_union,unionErrors:c}),S}}get options(){return this._def.options}}gt.create=(t,e)=>new gt({options:t,typeName:C.ZodUnion,...A(e)});const Pe=t=>t instanceof bt?Pe(t.schema):t instanceof ae?Pe(t.innerType()):t instanceof Et?[t.value]:t instanceof Me?t.options:t instanceof kt?R.objectValues(t.enum):t instanceof Ct?Pe(t._def.innerType):t instanceof yt?[void 0]:t instanceof _t?[null]:t instanceof he?[void 0,...Pe(t.unwrap())]:t instanceof De?[null,...Pe(t.unwrap())]:t instanceof kr||t instanceof At?Pe(t.unwrap()):t instanceof St?Pe(t._def.innerType):[];class Yt extends T{_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==v.object)return g(r,{code:y.invalid_type,expected:v.object,received:r.parsedType}),S;const n=this.discriminator,o=r.data[n],s=this.optionsMap.get(o);return s?r.common.async?s._parseAsync({data:r.data,path:r.path,parent:r}):s._parseSync({data:r.data,path:r.path,parent:r}):(g(r,{code:y.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),S)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){const o=new Map;for(const s of r){const i=Pe(s.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const c of i){if(o.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);o.set(c,s)}}return new Yt({typeName:C.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:o,...A(n)})}}function Er(t,e){const r=Re(t),n=Re(e);if(t===e)return{valid:!0,data:t};if(r===v.object&&n===v.object){const o=R.objectKeys(e),s=R.objectKeys(t).filter(c=>o.indexOf(c)!==-1),i={...t,...e};for(const c of s){const l=Er(t[c],e[c]);if(!l.valid)return{valid:!1};i[c]=l.data}return{valid:!0,data:i}}else if(r===v.array&&n===v.array){if(t.length!==e.length)return{valid:!1};const o=[];for(let s=0;s<t.length;s++){const i=t[s],c=e[s],l=Er(i,c);if(!l.valid)return{valid:!1};o.push(l.data)}return{valid:!0,data:o}}else return r===v.date&&n===v.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class vt extends T{_parse(e){const{status:r,ctx:n}=this._processInputParams(e),o=(s,i)=>{if(vr(s)||vr(i))return S;const c=Er(s.value,i.value);return c.valid?((wr(s)||wr(i))&&r.dirty(),{status:r.value,value:c.data}):(g(n,{code:y.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(([s,i])=>o(s,i)):o(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}vt.create=(t,e,r)=>new vt({left:t,right:e,typeName:C.ZodIntersection,...A(r)});class me extends T{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==v.array)return g(n,{code:y.invalid_type,expected:v.array,received:n.parsedType}),S;if(n.data.length<this._def.items.length)return g(n,{code:y.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),S;!this._def.rest&&n.data.length>this._def.items.length&&(g(n,{code:y.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const s=[...n.data].map((i,c)=>{const l=this._def.items[c]||this._def.rest;return l?l._parse(new fe(n,i,n.path,c)):null}).filter(i=>!!i);return n.common.async?Promise.all(s).then(i=>H.mergeArray(r,i)):H.mergeArray(r,s)}get items(){return this._def.items}rest(e){return new me({...this._def,rest:e})}}me.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new me({items:t,typeName:C.ZodTuple,rest:null,...A(e)})};class wt extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==v.object)return g(n,{code:y.invalid_type,expected:v.object,received:n.parsedType}),S;const o=[],s=this._def.keyType,i=this._def.valueType;for(const c in n.data)o.push({key:s._parse(new fe(n,c,n.path,c)),value:i._parse(new fe(n,n.data[c],n.path,c)),alwaysSet:c in n.data});return n.common.async?H.mergeObjectAsync(r,o):H.mergeObjectSync(r,o)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof T?new wt({keyType:e,valueType:r,typeName:C.ZodRecord,...A(n)}):new wt({keyType:oe.create(),valueType:e,typeName:C.ZodRecord,...A(r)})}}class Wt extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==v.map)return g(n,{code:y.invalid_type,expected:v.map,received:n.parsedType}),S;const o=this._def.keyType,s=this._def.valueType,i=[...n.data.entries()].map(([c,l],u)=>({key:o._parse(new fe(n,c,n.path,[u,"key"])),value:s._parse(new fe(n,l,n.path,[u,"value"]))}));if(n.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const l of i){const u=await l.key,d=await l.value;if(u.status==="aborted"||d.status==="aborted")return S;(u.status==="dirty"||d.status==="dirty")&&r.dirty(),c.set(u.value,d.value)}return{status:r.value,value:c}})}else{const c=new Map;for(const l of i){const u=l.key,d=l.value;if(u.status==="aborted"||d.status==="aborted")return S;(u.status==="dirty"||d.status==="dirty")&&r.dirty(),c.set(u.value,d.value)}return{status:r.value,value:c}}}}Wt.create=(t,e,r)=>new Wt({valueType:e,keyType:t,typeName:C.ZodMap,...A(r)});class Ze extends T{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==v.set)return g(n,{code:y.invalid_type,expected:v.set,received:n.parsedType}),S;const o=this._def;o.minSize!==null&&n.data.size<o.minSize.value&&(g(n,{code:y.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),r.dirty()),o.maxSize!==null&&n.data.size>o.maxSize.value&&(g(n,{code:y.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),r.dirty());const s=this._def.valueType;function i(l){const u=new Set;for(const d of l){if(d.status==="aborted")return S;d.status==="dirty"&&r.dirty(),u.add(d.value)}return{status:r.value,value:u}}const c=[...n.data.values()].map((l,u)=>s._parse(new fe(n,l,n.path,u)));return n.common.async?Promise.all(c).then(l=>i(l)):i(c)}min(e,r){return new Ze({...this._def,minSize:{value:e,message:b.toString(r)}})}max(e,r){return new Ze({...this._def,maxSize:{value:e,message:b.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}Ze.create=(t,e)=>new Ze({valueType:t,minSize:null,maxSize:null,typeName:C.ZodSet,...A(e)});class et extends T{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==v.function)return g(r,{code:y.invalid_type,expected:v.function,received:r.parsedType}),S;function n(c,l){return zt({data:c,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Vt(),Ke].filter(u=>!!u),issueData:{code:y.invalid_arguments,argumentsError:l}})}function o(c,l){return zt({data:c,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Vt(),Ke].filter(u=>!!u),issueData:{code:y.invalid_return_type,returnTypeError:l}})}const s={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof tt){const c=this;return J(async function(...l){const u=new te([]),d=await c._def.args.parseAsync(l,s).catch(f=>{throw u.addIssue(n(l,f)),u}),p=await Reflect.apply(i,this,d);return await c._def.returns._def.type.parseAsync(p,s).catch(f=>{throw u.addIssue(o(p,f)),u})})}else{const c=this;return J(function(...l){const u=c._def.args.safeParse(l,s);if(!u.success)throw new te([n(l,u.error)]);const d=Reflect.apply(i,this,u.data),p=c._def.returns.safeParse(d,s);if(!p.success)throw new te([o(d,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new et({...this._def,args:me.create(e).rest($e.create())})}returns(e){return new et({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new et({args:e||me.create([]).rest($e.create()),returns:r||$e.create(),typeName:C.ZodFunction,...A(n)})}}class bt extends T{get schema(){return this._def.getter()}_parse(e){const{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}bt.create=(t,e)=>new bt({getter:t,typeName:C.ZodLazy,...A(e)});class Et extends T{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return g(r,{received:r.data,code:y.invalid_literal,expected:this._def.value}),S}return{status:"valid",value:e.data}}get value(){return this._def.value}}Et.create=(t,e)=>new Et({value:t,typeName:C.ZodLiteral,...A(e)});function en(t,e){return new Me({values:t,typeName:C.ZodEnum,...A(e)})}class Me extends T{constructor(){super(...arguments),ft.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),n=this._def.values;return g(r,{expected:R.joinValues(n),received:r.parsedType,code:y.invalid_type}),S}if(Gt(this,ft)||Hr(this,ft,new Set(this._def.values)),!Gt(this,ft).has(e.data)){const r=this._getOrReturnCtx(e),n=this._def.values;return g(r,{received:r.data,code:y.invalid_enum_value,options:n}),S}return J(e.data)}get options(){return this._def.values}get enum(){const e={};for(const r of this._def.values)e[r]=r;return e}get Values(){const e={};for(const r of this._def.values)e[r]=r;return e}get Enum(){const e={};for(const r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return Me.create(e,{...this._def,...r})}exclude(e,r=this._def){return Me.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}}ft=new WeakMap,Me.create=en;class kt extends T{constructor(){super(...arguments),mt.set(this,void 0)}_parse(e){const r=R.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==v.string&&n.parsedType!==v.number){const o=R.objectValues(r);return g(n,{expected:R.joinValues(o),received:n.parsedType,code:y.invalid_type}),S}if(Gt(this,mt)||Hr(this,mt,new Set(R.getValidEnumValues(this._def.values))),!Gt(this,mt).has(e.data)){const o=R.objectValues(r);return g(n,{received:n.data,code:y.invalid_enum_value,options:o}),S}return J(e.data)}get enum(){return this._def.values}}mt=new WeakMap,kt.create=(t,e)=>new kt({values:t,typeName:C.ZodNativeEnum,...A(e)});class tt extends T{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==v.promise&&r.common.async===!1)return g(r,{code:y.invalid_type,expected:v.promise,received:r.parsedType}),S;const n=r.parsedType===v.promise?r.data:Promise.resolve(r.data);return J(n.then(o=>this._def.type.parseAsync(o,{path:r.path,errorMap:r.common.contextualErrorMap})))}}tt.create=(t,e)=>new tt({type:t,typeName:C.ZodPromise,...A(e)});class ae extends T{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===C.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:r,ctx:n}=this._processInputParams(e),o=this._def.effect||null,s={addIssue:i=>{g(n,i),i.fatal?r.abort():r.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),o.type==="preprocess"){const i=o.transform(n.data,s);if(n.common.async)return Promise.resolve(i).then(async c=>{if(r.value==="aborted")return S;const l=await this._def.schema._parseAsync({data:c,path:n.path,parent:n});return l.status==="aborted"?S:l.status==="dirty"||r.value==="dirty"?Je(l.value):l});{if(r.value==="aborted")return S;const c=this._def.schema._parseSync({data:i,path:n.path,parent:n});return c.status==="aborted"?S:c.status==="dirty"||r.value==="dirty"?Je(c.value):c}}if(o.type==="refinement"){cons