UNPKG

@devcomfort/text-transcoder

Version:
1 lines 614 kB
!function(l,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((l="undefined"!=typeof globalThis?globalThis:l||self).textTranscoder={})}(this,(function(l){const n=["unicode-1-1-utf-8","utf-8","utf8","UTF-8","IBM866","866","cp866","csibm866","ibm866","ISO-8859-2","csisolatin2","iso-8859-2","iso-ir-101","iso8859-2","iso88592","iso_8859-2","iso_8859-2:1987","l2","latin2","ISO-8859-3","csisolatin3","iso-8859-3","iso-ir-109","iso8859-3","iso88593","iso_8859-3","iso_8859-3:1988","l3","latin3","ISO-8859-4","csisolatin4","iso-8859-4","iso-ir-110","iso8859-4","iso88594","iso_8859-4","iso_8859-4:1988","l4","latin4","ISO-8859-5","csisolatincyrillic","cyrillic","iso-8859-5","iso-ir-144","iso8859-5","iso88595","iso_8859-5","iso_8859-5:1988","ISO-8859-6","arabic","asmo-708","csiso88596e","csiso88596i","csisolatinarabic","ecma-114","iso-8859-6","iso-8859-6-e","iso-8859-6-i","iso-ir-127","iso8859-6","iso88596","iso_8859-6","iso_8859-6:1987","ISO-8859-7","csisolatingreek","ecma-118","elot_928","greek","greek8","iso-8859-7","iso-ir-126","iso8859-7","iso88597","iso_8859-7","iso_8859-7:1987","sun_eu_greek","ISO-8859-8","csiso88598e","csisolatinhebrew","hebrew","iso-8859-8","iso-8859-8-e","iso-ir-138","iso8859-8","iso88598","iso_8859-8","iso_8859-8:1988","visual","ISO-8859-8-I","csiso88598i","iso-8859-8-i","logical","ISO-8859-10","csisolatin6","iso-8859-10","iso-ir-157","iso8859-10","iso885910","l6","latin6","ISO-8859-13","iso-8859-13","iso8859-13","iso885913","ISO-8859-14","iso-8859-14","iso8859-14","iso885914","ISO-8859-15","csisolatin9","iso-8859-15","iso8859-15","iso885915","iso_8859-15","l9","ISO-8859-16","iso-8859-16","cskoi8r","koi","koi8","koi8-r","koi8_r","KOI8-U","koi8-ru","koi8-u","macintosh","csmacintosh","mac","macintosh","x-mac-roman","windows-874","dos-874","iso-8859-11","iso8859-11","iso885911","tis-620","windows-1250","cp1250","x-cp1250","windows-1251","cp1251","x-cp1251","windows-1252","ansi_x3.4-1968","ascii","cp1252","cp819","csisolatin1","ibm819","iso-8859-1","iso-ir-100","iso8859-1","iso88591","iso_8859-1","iso_8859-1:1987","l1","latin1","us-ascii","x-cp1252","cp1253","windows-1253","x-cp1253","cp1254","csisolatin5","iso-8859-9","iso-ir-148","iso8859-9","iso88599","iso_8859-9","iso_8859-9:1989","l5","latin5","windows-1254","x-cp1254","cp1255","windows-1255","x-cp1255","cp1256","windows-1256","x-cp1256","cp1257","windows-1257","x-cp1257","cp1258","windows-1258","x-cp1258","x-mac-cyrillic","x-mac-ukrainian","chinese","csgb2312","csiso58gb231280","gb2312","gb_2312","gb_2312-80","gbk","iso-ir-58","x-gbk","gb18030","big5","big5-hkscs","cn-big5","csbig5","x-x-big5","cseucpkdfmtjapanese","euc-jp","x-euc-jp","csiso2022jp","iso-2022-jp","csshiftjis","ms932","ms_kanji","shift-jis","shift_jis","sjis","windows-31j","x-sjis","cseuckr","csksc56011987","euc-kr","iso-ir-149","korean","ks_c_5601-1987","ks_c_5601-1989","ksc5601","ksc_5601","windows-949","csiso2022kr","hz-gb-2312","iso-2022-cn","iso-2022-cn-ext","iso-2022-kr","utf-16be","utf-16","utf-16le","x-user-defined"];var u,e;!function(l){l.assertEqual=l=>l,l.assertIs=function(l){},l.assertNever=function(l){throw new Error},l.arrayToEnum=l=>{const n={};for(const u of l)n[u]=u;return n},l.getValidEnumValues=n=>{const u=l.objectKeys(n).filter((l=>"number"!=typeof n[n[l]])),e={};for(const l of u)e[l]=n[l];return l.objectValues(e)},l.objectValues=n=>l.objectKeys(n).map((function(l){return n[l]})),l.objectKeys="function"==typeof Object.keys?l=>Object.keys(l):l=>{const n=[];for(const u in l)Object.prototype.hasOwnProperty.call(l,u)&&n.push(u);return n},l.find=(l,n)=>{for(const u of l)if(n(u))return u},l.isInteger="function"==typeof Number.isInteger?l=>Number.isInteger(l):l=>"number"==typeof l&&isFinite(l)&&Math.floor(l)===l,l.joinValues=function(l,n=" | "){return l.map((l=>"string"==typeof l?`'${l}'`:l)).join(n)},l.jsonStringifyReplacer=(l,n)=>"bigint"==typeof n?n.toString():n}(u||(u={})),function(l){l.mergeShapes=(l,n)=>({...l,...n})}(e||(e={}));const t=u.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),s=l=>{switch(typeof l){case"undefined":return t.undefined;case"string":return t.string;case"number":return isNaN(l)?t.nan:t.number;case"boolean":return t.boolean;case"function":return t.function;case"bigint":return t.bigint;case"symbol":return t.symbol;case"object":return Array.isArray(l)?t.array:null===l?t.null:l.then&&"function"==typeof l.then&&l.catch&&"function"==typeof l.catch?t.promise:"undefined"!=typeof Map&&l instanceof Map?t.map:"undefined"!=typeof Set&&l instanceof Set?t.set:"undefined"!=typeof Date&&l instanceof Date?t.date:t.object;default:return t.unknown}},i=u.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 a extends Error{get errors(){return this.issues}constructor(l){super(),this.issues=[],this.addIssue=l=>{this.issues=[...this.issues,l]},this.addIssues=(l=[])=>{this.issues=[...this.issues,...l]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=l}format(l){const n=l||function(l){return l.message},u={_errors:[]},e=l=>{for(const t of l.issues)if("invalid_union"===t.code)t.unionErrors.map(e);else if("invalid_return_type"===t.code)e(t.returnTypeError);else if("invalid_arguments"===t.code)e(t.argumentsError);else if(0===t.path.length)u._errors.push(n(t));else{let l=u,e=0;for(;e<t.path.length;){const u=t.path[e];e===t.path.length-1?(l[u]=l[u]||{_errors:[]},l[u]._errors.push(n(t))):l[u]=l[u]||{_errors:[]},l=l[u],e++}}};return e(this),u}static assert(l){if(!(l instanceof a))throw new Error(`Not a ZodError: ${l}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,u.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(l=l=>l.message){const n={},u=[];for(const e of this.issues)e.path.length>0?(n[e.path[0]]=n[e.path[0]]||[],n[e.path[0]].push(l(e))):u.push(l(e));return{formErrors:u,fieldErrors:n}}get formErrors(){return this.flatten()}}a.create=l=>new a(l);const r=(l,n)=>{let e;switch(l.code){case i.invalid_type:e=l.received===t.undefined?"Required":`Expected ${l.expected}, received ${l.received}`;break;case i.invalid_literal:e=`Invalid literal value, expected ${JSON.stringify(l.expected,u.jsonStringifyReplacer)}`;break;case i.unrecognized_keys:e=`Unrecognized key(s) in object: ${u.joinValues(l.keys,", ")}`;break;case i.invalid_union:e="Invalid input";break;case i.invalid_union_discriminator:e=`Invalid discriminator value. Expected ${u.joinValues(l.options)}`;break;case i.invalid_enum_value:e=`Invalid enum value. Expected ${u.joinValues(l.options)}, received '${l.received}'`;break;case i.invalid_arguments:e="Invalid function arguments";break;case i.invalid_return_type:e="Invalid function return type";break;case i.invalid_date:e="Invalid date";break;case i.invalid_string:"object"==typeof l.validation?"includes"in l.validation?(e=`Invalid input: must include "${l.validation.includes}"`,"number"==typeof l.validation.position&&(e=`${e} at one or more positions greater than or equal to ${l.validation.position}`)):"startsWith"in l.validation?e=`Invalid input: must start with "${l.validation.startsWith}"`:"endsWith"in l.validation?e=`Invalid input: must end with "${l.validation.endsWith}"`:u.assertNever(l.validation):e="regex"!==l.validation?`Invalid ${l.validation}`:"Invalid";break;case i.too_small:e="array"===l.type?`Array must contain ${l.exact?"exactly":l.inclusive?"at least":"more than"} ${l.minimum} element(s)`:"string"===l.type?`String must contain ${l.exact?"exactly":l.inclusive?"at least":"over"} ${l.minimum} character(s)`:"number"===l.type?`Number must be ${l.exact?"exactly equal to ":l.inclusive?"greater than or equal to ":"greater than "}${l.minimum}`:"date"===l.type?`Date must be ${l.exact?"exactly equal to ":l.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(l.minimum))}`:"Invalid input";break;case i.too_big:e="array"===l.type?`Array must contain ${l.exact?"exactly":l.inclusive?"at most":"less than"} ${l.maximum} element(s)`:"string"===l.type?`String must contain ${l.exact?"exactly":l.inclusive?"at most":"under"} ${l.maximum} character(s)`:"number"===l.type?`Number must be ${l.exact?"exactly":l.inclusive?"less than or equal to":"less than"} ${l.maximum}`:"bigint"===l.type?`BigInt must be ${l.exact?"exactly":l.inclusive?"less than or equal to":"less than"} ${l.maximum}`:"date"===l.type?`Date must be ${l.exact?"exactly":l.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(l.maximum))}`:"Invalid input";break;case i.custom:e="Invalid input";break;case i.invalid_intersection_types:e="Intersection results could not be merged";break;case i.not_multiple_of:e=`Number must be a multiple of ${l.multipleOf}`;break;case i.not_finite:e="Number must be finite";break;default:e=n.defaultError,u.assertNever(l)}return{message:e}};let o=r;function d(){return o}const c=l=>{const{data:n,path:u,errorMaps:e,issueData:t}=l,s=[...u,...t.path||[]],i={...t,path:s};if(void 0!==t.message)return{...t,path:s,message:t.message};let a="";const r=e.filter((l=>!!l)).slice().reverse();for(const l of r)a=l(i,{data:n,defaultError:a}).message;return{...t,path:s,message:a}};function h(l,n){const u=d(),e=c({issueData:n,data:l.data,path:l.path,errorMaps:[l.common.contextualErrorMap,l.schemaErrorMap,u,u===r?void 0:r].filter((l=>!!l))});l.common.issues.push(e)}class p{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(l,n){const u=[];for(const e of n){if("aborted"===e.status)return f;"dirty"===e.status&&l.dirty(),u.push(e.value)}return{status:l.value,value:u}}static async mergeObjectAsync(l,n){const u=[];for(const l of n){const n=await l.key,e=await l.value;u.push({key:n,value:e})}return p.mergeObjectSync(l,u)}static mergeObjectSync(l,n){const u={};for(const e of n){const{key:n,value:t}=e;if("aborted"===n.status)return f;if("aborted"===t.status)return f;"dirty"===n.status&&l.dirty(),"dirty"===t.status&&l.dirty(),"__proto__"===n.value||void 0===t.value&&!e.alwaysSet||(u[n.value]=t.value)}return{status:l.value,value:u}}}const f=Object.freeze({status:"aborted"}),_=l=>({status:"dirty",value:l}),m=l=>({status:"valid",value:l}),g=l=>"aborted"===l.status,y=l=>"dirty"===l.status,v=l=>"valid"===l.status,b=l=>"undefined"!=typeof Promise&&l instanceof Promise;function k(l,n,u,e){if("function"==typeof n||!n.has(l))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n.get(l)}function w(l,n,u,e,t){if("function"==typeof n||!n.has(l))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n.set(l,u),u}var x,j,S;!function(l){l.errToObj=l=>"string"==typeof l?{message:l}:l||{},l.toString=l=>"string"==typeof l?l:null==l?void 0:l.message}(x||(x={}));class O{constructor(l,n,u,e){this._cachedPath=[],this.parent=l,this.data=n,this._path=u,this._key=e}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 Z=(l,n)=>{if(v(n))return{success:!0,data:n.value};if(!l.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new a(l.common.issues);return this._error=n,this._error}}};function T(l){if(!l)return{};const{errorMap:n,invalid_type_error:u,required_error:e,description:t}=l;if(n&&(u||e))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(n)return{errorMap:n,description:t};return{errorMap:(n,t)=>{var s,i;const{message:a}=l;return"invalid_enum_value"===n.code?{message:null!=a?a:t.defaultError}:void 0===t.data?{message:null!==(s=null!=a?a:e)&&void 0!==s?s:t.defaultError}:"invalid_type"!==n.code?{message:t.defaultError}:{message:null!==(i=null!=a?a:u)&&void 0!==i?i:t.defaultError}},description:t}}class I{get description(){return this._def.description}_getType(l){return s(l.data)}_getOrReturnCtx(l,n){return n||{common:l.parent.common,data:l.data,parsedType:s(l.data),schemaErrorMap:this._def.errorMap,path:l.path,parent:l.parent}}_processInputParams(l){return{status:new p,ctx:{common:l.parent.common,data:l.data,parsedType:s(l.data),schemaErrorMap:this._def.errorMap,path:l.path,parent:l.parent}}}_parseSync(l){const n=this._parse(l);if(b(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(l){const n=this._parse(l);return Promise.resolve(n)}parse(l,n){const u=this.safeParse(l,n);if(u.success)return u.data;throw u.error}safeParse(l,n){var u;const e={common:{issues:[],async:null!==(u=null==n?void 0:n.async)&&void 0!==u&&u,contextualErrorMap:null==n?void 0:n.errorMap},path:(null==n?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:l,parsedType:s(l)},t=this._parseSync({data:l,path:e.path,parent:e});return Z(e,t)}"~validate"(l){var n,u;const e={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:l,parsedType:s(l)};if(!this["~standard"].async)try{const n=this._parseSync({data:l,path:[],parent:e});return v(n)?{value:n.value}:{issues:e.common.issues}}catch(l){(null===(u=null===(n=null==l?void 0:l.message)||void 0===n?void 0:n.toLowerCase())||void 0===u?void 0:u.includes("encountered"))&&(this["~standard"].async=!0),e.common={issues:[],async:!0}}return this._parseAsync({data:l,path:[],parent:e}).then((l=>v(l)?{value:l.value}:{issues:e.common.issues}))}async parseAsync(l,n){const u=await this.safeParseAsync(l,n);if(u.success)return u.data;throw u.error}async safeParseAsync(l,n){const u={common:{issues:[],contextualErrorMap:null==n?void 0:n.errorMap,async:!0},path:(null==n?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:l,parsedType:s(l)},e=this._parse({data:l,path:u.path,parent:u}),t=await(b(e)?e:Promise.resolve(e));return Z(u,t)}refine(l,n){const u=l=>"string"==typeof n||void 0===n?{message:n}:"function"==typeof n?n(l):n;return this._refinement(((n,e)=>{const t=l(n),s=()=>e.addIssue({code:i.custom,...u(n)});return"undefined"!=typeof Promise&&t instanceof Promise?t.then((l=>!!l||(s(),!1))):!!t||(s(),!1)}))}refinement(l,n){return this._refinement(((u,e)=>!!l(u)||(e.addIssue("function"==typeof n?n(u,e):n),!1)))}_refinement(l){return new Il({schema:this,typeName:Ul.ZodEffects,effect:{type:"refinement",refinement:l}})}superRefine(l){return this._refinement(l)}constructor(l){this.spa=this.safeParseAsync,this._def=l,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:l=>this["~validate"](l)}}optional(){return Cl.create(this,this._def)}nullable(){return Al.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return dl.create(this)}promise(){return Tl.create(this,this._def)}or(l){return pl.create([this,l],this._def)}and(l){return gl.create(this,l,this._def)}transform(l){return new Il({...T(this._def),schema:this,typeName:Ul.ZodEffects,effect:{type:"transform",transform:l}})}default(l){const n="function"==typeof l?l:()=>l;return new El({...T(this._def),innerType:this,defaultValue:n,typeName:Ul.ZodDefault})}brand(){return new Ml({typeName:Ul.ZodBranded,type:this,...T(this._def)})}catch(l){const n="function"==typeof l?l:()=>l;return new Nl({...T(this._def),innerType:this,catchValue:n,typeName:Ul.ZodCatch})}describe(l){return new(0,this.constructor)({...this._def,description:l})}pipe(l){return $l.create(this,l)}readonly(){return Ll.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const C=/^c[^\s-]{8,}$/i,A=/^[0-9a-z]+$/,E=/^[0-9A-HJKMNP-TV-Z]{26}$/i,N=/^[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,R=/^[a-z0-9_-]{21}$/i,P=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,M=/^[-+]?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)?)??$/,$=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let L;const F=/^(?:(?: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])$/,B=/^(?:(?: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])$/,U=/^(([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]))$/,D=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,z=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,K=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,V="((\\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])))",J=new RegExp(`^${V}$`);function W(l){let n="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return l.precision?n=`${n}\\.\\d{${l.precision}}`:null==l.precision&&(n=`${n}(\\.\\d+)?`),n}function q(l){let n=`${V}T${W(l)}`;const u=[];return u.push(l.local?"Z?":"Z"),l.offset&&u.push("([+-]\\d{2}:?\\d{2})"),n=`${n}(${u.join("|")})`,new RegExp(`^${n}$`)}function G(l,n){if(!P.test(l))return!1;try{const[u]=l.split("."),e=u.replace(/-/g,"+").replace(/_/g,"/").padEnd(u.length+(4-u.length%4)%4,"="),t=JSON.parse(atob(e));return"object"==typeof t&&null!==t&&(!(!t.typ||!t.alg)&&(!n||t.alg===n))}catch(l){return!1}}function Y(l,n){return!("v4"!==n&&n||!B.test(l))||!("v6"!==n&&n||!D.test(l))}class H extends I{_parse(l){this._def.coerce&&(l.data=String(l.data));if(this._getType(l)!==t.string){const n=this._getOrReturnCtx(l);return h(n,{code:i.invalid_type,expected:t.string,received:n.parsedType}),f}const n=new p;let e;for(const t of this._def.checks)if("min"===t.kind)l.data.length<t.value&&(e=this._getOrReturnCtx(l,e),h(e,{code:i.too_small,minimum:t.value,type:"string",inclusive:!0,exact:!1,message:t.message}),n.dirty());else if("max"===t.kind)l.data.length>t.value&&(e=this._getOrReturnCtx(l,e),h(e,{code:i.too_big,maximum:t.value,type:"string",inclusive:!0,exact:!1,message:t.message}),n.dirty());else if("length"===t.kind){const u=l.data.length>t.value,s=l.data.length<t.value;(u||s)&&(e=this._getOrReturnCtx(l,e),u?h(e,{code:i.too_big,maximum:t.value,type:"string",inclusive:!0,exact:!0,message:t.message}):s&&h(e,{code:i.too_small,minimum:t.value,type:"string",inclusive:!0,exact:!0,message:t.message}),n.dirty())}else if("email"===t.kind)$.test(l.data)||(e=this._getOrReturnCtx(l,e),h(e,{validation:"email",code:i.invalid_string,message:t.message}),n.dirty());else if("emoji"===t.kind)L||(L=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),L.test(l.data)||(e=this._getOrReturnCtx(l,e),h(e,{validation:"emoji",code:i.invalid_string,message:t.message}),n.dirty());else if("uuid"===t.kind)N.test(l.data)||(e=this._getOrReturnCtx(l,e),h(e,{validation:"uuid",code:i.invalid_string,message:t.message}),n.dirty());else if("nanoid"===t.kind)R.test(l.data)||(e=this._getOrReturnCtx(l,e),h(e,{validation:"nanoid",code:i.invalid_string,message:t.message}),n.dirty());else if("cuid"===t.kind)C.test(l.data)||(e=this._getOrReturnCtx(l,e),h(e,{validation:"cuid",code:i.invalid_string,message:t.message}),n.dirty());else if("cuid2"===t.kind)A.test(l.data)||(e=this._getOrReturnCtx(l,e),h(e,{validation:"cuid2",code:i.invalid_string,message:t.message}),n.dirty());else if("ulid"===t.kind)E.test(l.data)||(e=this._getOrReturnCtx(l,e),h(e,{validation:"ulid",code:i.invalid_string,message:t.message}),n.dirty());else if("url"===t.kind)try{new URL(l.data)}catch(u){e=this._getOrReturnCtx(l,e),h(e,{validation:"url",code:i.invalid_string,message:t.message}),n.dirty()}else if("regex"===t.kind){t.regex.lastIndex=0;t.regex.test(l.data)||(e=this._getOrReturnCtx(l,e),h(e,{validation:"regex",code:i.invalid_string,message:t.message}),n.dirty())}else if("trim"===t.kind)l.data=l.data.trim();else if("includes"===t.kind)l.data.includes(t.value,t.position)||(e=this._getOrReturnCtx(l,e),h(e,{code:i.invalid_string,validation:{includes:t.value,position:t.position},message:t.message}),n.dirty());else if("toLowerCase"===t.kind)l.data=l.data.toLowerCase();else if("toUpperCase"===t.kind)l.data=l.data.toUpperCase();else if("startsWith"===t.kind)l.data.startsWith(t.value)||(e=this._getOrReturnCtx(l,e),h(e,{code:i.invalid_string,validation:{startsWith:t.value},message:t.message}),n.dirty());else if("endsWith"===t.kind)l.data.endsWith(t.value)||(e=this._getOrReturnCtx(l,e),h(e,{code:i.invalid_string,validation:{endsWith:t.value},message:t.message}),n.dirty());else if("datetime"===t.kind){q(t).test(l.data)||(e=this._getOrReturnCtx(l,e),h(e,{code:i.invalid_string,validation:"datetime",message:t.message}),n.dirty())}else if("date"===t.kind){J.test(l.data)||(e=this._getOrReturnCtx(l,e),h(e,{code:i.invalid_string,validation:"date",message:t.message}),n.dirty())}else if("time"===t.kind){new RegExp(`^${W(t)}$`).test(l.data)||(e=this._getOrReturnCtx(l,e),h(e,{code:i.invalid_string,validation:"time",message:t.message}),n.dirty())}else"duration"===t.kind?M.test(l.data)||(e=this._getOrReturnCtx(l,e),h(e,{validation:"duration",code:i.invalid_string,message:t.message}),n.dirty()):"ip"===t.kind?(s=l.data,("v4"!==(a=t.version)&&a||!F.test(s))&&("v6"!==a&&a||!U.test(s))&&(e=this._getOrReturnCtx(l,e),h(e,{validation:"ip",code:i.invalid_string,message:t.message}),n.dirty())):"jwt"===t.kind?G(l.data,t.alg)||(e=this._getOrReturnCtx(l,e),h(e,{validation:"jwt",code:i.invalid_string,message:t.message}),n.dirty()):"cidr"===t.kind?Y(l.data,t.version)||(e=this._getOrReturnCtx(l,e),h(e,{validation:"cidr",code:i.invalid_string,message:t.message}),n.dirty()):"base64"===t.kind?z.test(l.data)||(e=this._getOrReturnCtx(l,e),h(e,{validation:"base64",code:i.invalid_string,message:t.message}),n.dirty()):"base64url"===t.kind?K.test(l.data)||(e=this._getOrReturnCtx(l,e),h(e,{validation:"base64url",code:i.invalid_string,message:t.message}),n.dirty()):u.assertNever(t);var s,a;return{status:n.value,value:l.data}}_regex(l,n,u){return this.refinement((n=>l.test(n)),{validation:n,code:i.invalid_string,...x.errToObj(u)})}_addCheck(l){return new H({...this._def,checks:[...this._def.checks,l]})}email(l){return this._addCheck({kind:"email",...x.errToObj(l)})}url(l){return this._addCheck({kind:"url",...x.errToObj(l)})}emoji(l){return this._addCheck({kind:"emoji",...x.errToObj(l)})}uuid(l){return this._addCheck({kind:"uuid",...x.errToObj(l)})}nanoid(l){return this._addCheck({kind:"nanoid",...x.errToObj(l)})}cuid(l){return this._addCheck({kind:"cuid",...x.errToObj(l)})}cuid2(l){return this._addCheck({kind:"cuid2",...x.errToObj(l)})}ulid(l){return this._addCheck({kind:"ulid",...x.errToObj(l)})}base64(l){return this._addCheck({kind:"base64",...x.errToObj(l)})}base64url(l){return this._addCheck({kind:"base64url",...x.errToObj(l)})}jwt(l){return this._addCheck({kind:"jwt",...x.errToObj(l)})}ip(l){return this._addCheck({kind:"ip",...x.errToObj(l)})}cidr(l){return this._addCheck({kind:"cidr",...x.errToObj(l)})}datetime(l){var n,u;return"string"==typeof l?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:l}):this._addCheck({kind:"datetime",precision:void 0===(null==l?void 0:l.precision)?null:null==l?void 0:l.precision,offset:null!==(n=null==l?void 0:l.offset)&&void 0!==n&&n,local:null!==(u=null==l?void 0:l.local)&&void 0!==u&&u,...x.errToObj(null==l?void 0:l.message)})}date(l){return this._addCheck({kind:"date",message:l})}time(l){return"string"==typeof l?this._addCheck({kind:"time",precision:null,message:l}):this._addCheck({kind:"time",precision:void 0===(null==l?void 0:l.precision)?null:null==l?void 0:l.precision,...x.errToObj(null==l?void 0:l.message)})}duration(l){return this._addCheck({kind:"duration",...x.errToObj(l)})}regex(l,n){return this._addCheck({kind:"regex",regex:l,...x.errToObj(n)})}includes(l,n){return this._addCheck({kind:"includes",value:l,position:null==n?void 0:n.position,...x.errToObj(null==n?void 0:n.message)})}startsWith(l,n){return this._addCheck({kind:"startsWith",value:l,...x.errToObj(n)})}endsWith(l,n){return this._addCheck({kind:"endsWith",value:l,...x.errToObj(n)})}min(l,n){return this._addCheck({kind:"min",value:l,...x.errToObj(n)})}max(l,n){return this._addCheck({kind:"max",value:l,...x.errToObj(n)})}length(l,n){return this._addCheck({kind:"length",value:l,...x.errToObj(n)})}nonempty(l){return this.min(1,x.errToObj(l))}trim(){return new H({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new H({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new H({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((l=>"datetime"===l.kind))}get isDate(){return!!this._def.checks.find((l=>"date"===l.kind))}get isTime(){return!!this._def.checks.find((l=>"time"===l.kind))}get isDuration(){return!!this._def.checks.find((l=>"duration"===l.kind))}get isEmail(){return!!this._def.checks.find((l=>"email"===l.kind))}get isURL(){return!!this._def.checks.find((l=>"url"===l.kind))}get isEmoji(){return!!this._def.checks.find((l=>"emoji"===l.kind))}get isUUID(){return!!this._def.checks.find((l=>"uuid"===l.kind))}get isNANOID(){return!!this._def.checks.find((l=>"nanoid"===l.kind))}get isCUID(){return!!this._def.checks.find((l=>"cuid"===l.kind))}get isCUID2(){return!!this._def.checks.find((l=>"cuid2"===l.kind))}get isULID(){return!!this._def.checks.find((l=>"ulid"===l.kind))}get isIP(){return!!this._def.checks.find((l=>"ip"===l.kind))}get isCIDR(){return!!this._def.checks.find((l=>"cidr"===l.kind))}get isBase64(){return!!this._def.checks.find((l=>"base64"===l.kind))}get isBase64url(){return!!this._def.checks.find((l=>"base64url"===l.kind))}get minLength(){let l=null;for(const n of this._def.checks)"min"===n.kind&&(null===l||n.value>l)&&(l=n.value);return l}get maxLength(){let l=null;for(const n of this._def.checks)"max"===n.kind&&(null===l||n.value<l)&&(l=n.value);return l}}function X(l,n){const u=(l.toString().split(".")[1]||"").length,e=(n.toString().split(".")[1]||"").length,t=u>e?u:e;return parseInt(l.toFixed(t).replace(".",""))%parseInt(n.toFixed(t).replace(".",""))/Math.pow(10,t)}H.create=l=>{var n;return new H({checks:[],typeName:Ul.ZodString,coerce:null!==(n=null==l?void 0:l.coerce)&&void 0!==n&&n,...T(l)})};class Q extends I{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(l){this._def.coerce&&(l.data=Number(l.data));if(this._getType(l)!==t.number){const n=this._getOrReturnCtx(l);return h(n,{code:i.invalid_type,expected:t.number,received:n.parsedType}),f}let n;const e=new p;for(const t of this._def.checks)if("int"===t.kind)u.isInteger(l.data)||(n=this._getOrReturnCtx(l,n),h(n,{code:i.invalid_type,expected:"integer",received:"float",message:t.message}),e.dirty());else if("min"===t.kind){(t.inclusive?l.data<t.value:l.data<=t.value)&&(n=this._getOrReturnCtx(l,n),h(n,{code:i.too_small,minimum:t.value,type:"number",inclusive:t.inclusive,exact:!1,message:t.message}),e.dirty())}else if("max"===t.kind){(t.inclusive?l.data>t.value:l.data>=t.value)&&(n=this._getOrReturnCtx(l,n),h(n,{code:i.too_big,maximum:t.value,type:"number",inclusive:t.inclusive,exact:!1,message:t.message}),e.dirty())}else"multipleOf"===t.kind?0!==X(l.data,t.value)&&(n=this._getOrReturnCtx(l,n),h(n,{code:i.not_multiple_of,multipleOf:t.value,message:t.message}),e.dirty()):"finite"===t.kind?Number.isFinite(l.data)||(n=this._getOrReturnCtx(l,n),h(n,{code:i.not_finite,message:t.message}),e.dirty()):u.assertNever(t);return{status:e.value,value:l.data}}gte(l,n){return this.setLimit("min",l,!0,x.toString(n))}gt(l,n){return this.setLimit("min",l,!1,x.toString(n))}lte(l,n){return this.setLimit("max",l,!0,x.toString(n))}lt(l,n){return this.setLimit("max",l,!1,x.toString(n))}setLimit(l,n,u,e){return new Q({...this._def,checks:[...this._def.checks,{kind:l,value:n,inclusive:u,message:x.toString(e)}]})}_addCheck(l){return new Q({...this._def,checks:[...this._def.checks,l]})}int(l){return this._addCheck({kind:"int",message:x.toString(l)})}positive(l){return this._addCheck({kind:"min",value:0,inclusive:!1,message:x.toString(l)})}negative(l){return this._addCheck({kind:"max",value:0,inclusive:!1,message:x.toString(l)})}nonpositive(l){return this._addCheck({kind:"max",value:0,inclusive:!0,message:x.toString(l)})}nonnegative(l){return this._addCheck({kind:"min",value:0,inclusive:!0,message:x.toString(l)})}multipleOf(l,n){return this._addCheck({kind:"multipleOf",value:l,message:x.toString(n)})}finite(l){return this._addCheck({kind:"finite",message:x.toString(l)})}safe(l){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:x.toString(l)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:x.toString(l)})}get minValue(){let l=null;for(const n of this._def.checks)"min"===n.kind&&(null===l||n.value>l)&&(l=n.value);return l}get maxValue(){let l=null;for(const n of this._def.checks)"max"===n.kind&&(null===l||n.value<l)&&(l=n.value);return l}get isInt(){return!!this._def.checks.find((l=>"int"===l.kind||"multipleOf"===l.kind&&u.isInteger(l.value)))}get isFinite(){let l=null,n=null;for(const u of this._def.checks){if("finite"===u.kind||"int"===u.kind||"multipleOf"===u.kind)return!0;"min"===u.kind?(null===n||u.value>n)&&(n=u.value):"max"===u.kind&&(null===l||u.value<l)&&(l=u.value)}return Number.isFinite(n)&&Number.isFinite(l)}}Q.create=l=>new Q({checks:[],typeName:Ul.ZodNumber,coerce:(null==l?void 0:l.coerce)||!1,...T(l)});class ll extends I{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(l){if(this._def.coerce)try{l.data=BigInt(l.data)}catch(n){return this._getInvalidInput(l)}if(this._getType(l)!==t.bigint)return this._getInvalidInput(l);let n;const e=new p;for(const t of this._def.checks)if("min"===t.kind){(t.inclusive?l.data<t.value:l.data<=t.value)&&(n=this._getOrReturnCtx(l,n),h(n,{code:i.too_small,type:"bigint",minimum:t.value,inclusive:t.inclusive,message:t.message}),e.dirty())}else if("max"===t.kind){(t.inclusive?l.data>t.value:l.data>=t.value)&&(n=this._getOrReturnCtx(l,n),h(n,{code:i.too_big,type:"bigint",maximum:t.value,inclusive:t.inclusive,message:t.message}),e.dirty())}else"multipleOf"===t.kind?l.data%t.value!==BigInt(0)&&(n=this._getOrReturnCtx(l,n),h(n,{code:i.not_multiple_of,multipleOf:t.value,message:t.message}),e.dirty()):u.assertNever(t);return{status:e.value,value:l.data}}_getInvalidInput(l){const n=this._getOrReturnCtx(l);return h(n,{code:i.invalid_type,expected:t.bigint,received:n.parsedType}),f}gte(l,n){return this.setLimit("min",l,!0,x.toString(n))}gt(l,n){return this.setLimit("min",l,!1,x.toString(n))}lte(l,n){return this.setLimit("max",l,!0,x.toString(n))}lt(l,n){return this.setLimit("max",l,!1,x.toString(n))}setLimit(l,n,u,e){return new ll({...this._def,checks:[...this._def.checks,{kind:l,value:n,inclusive:u,message:x.toString(e)}]})}_addCheck(l){return new ll({...this._def,checks:[...this._def.checks,l]})}positive(l){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:x.toString(l)})}negative(l){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:x.toString(l)})}nonpositive(l){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:x.toString(l)})}nonnegative(l){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:x.toString(l)})}multipleOf(l,n){return this._addCheck({kind:"multipleOf",value:l,message:x.toString(n)})}get minValue(){let l=null;for(const n of this._def.checks)"min"===n.kind&&(null===l||n.value>l)&&(l=n.value);return l}get maxValue(){let l=null;for(const n of this._def.checks)"max"===n.kind&&(null===l||n.value<l)&&(l=n.value);return l}}ll.create=l=>{var n;return new ll({checks:[],typeName:Ul.ZodBigInt,coerce:null!==(n=null==l?void 0:l.coerce)&&void 0!==n&&n,...T(l)})};class nl extends I{_parse(l){this._def.coerce&&(l.data=Boolean(l.data));if(this._getType(l)!==t.boolean){const n=this._getOrReturnCtx(l);return h(n,{code:i.invalid_type,expected:t.boolean,received:n.parsedType}),f}return m(l.data)}}nl.create=l=>new nl({typeName:Ul.ZodBoolean,coerce:(null==l?void 0:l.coerce)||!1,...T(l)});class ul extends I{_parse(l){this._def.coerce&&(l.data=new Date(l.data));if(this._getType(l)!==t.date){const n=this._getOrReturnCtx(l);return h(n,{code:i.invalid_type,expected:t.date,received:n.parsedType}),f}if(isNaN(l.data.getTime())){return h(this._getOrReturnCtx(l),{code:i.invalid_date}),f}const n=new p;let e;for(const t of this._def.checks)"min"===t.kind?l.data.getTime()<t.value&&(e=this._getOrReturnCtx(l,e),h(e,{code:i.too_small,message:t.message,inclusive:!0,exact:!1,minimum:t.value,type:"date"}),n.dirty()):"max"===t.kind?l.data.getTime()>t.value&&(e=this._getOrReturnCtx(l,e),h(e,{code:i.too_big,message:t.message,inclusive:!0,exact:!1,maximum:t.value,type:"date"}),n.dirty()):u.assertNever(t);return{status:n.value,value:new Date(l.data.getTime())}}_addCheck(l){return new ul({...this._def,checks:[...this._def.checks,l]})}min(l,n){return this._addCheck({kind:"min",value:l.getTime(),message:x.toString(n)})}max(l,n){return this._addCheck({kind:"max",value:l.getTime(),message:x.toString(n)})}get minDate(){let l=null;for(const n of this._def.checks)"min"===n.kind&&(null===l||n.value>l)&&(l=n.value);return null!=l?new Date(l):null}get maxDate(){let l=null;for(const n of this._def.checks)"max"===n.kind&&(null===l||n.value<l)&&(l=n.value);return null!=l?new Date(l):null}}ul.create=l=>new ul({checks:[],coerce:(null==l?void 0:l.coerce)||!1,typeName:Ul.ZodDate,...T(l)});class el extends I{_parse(l){if(this._getType(l)!==t.symbol){const n=this._getOrReturnCtx(l);return h(n,{code:i.invalid_type,expected:t.symbol,received:n.parsedType}),f}return m(l.data)}}el.create=l=>new el({typeName:Ul.ZodSymbol,...T(l)});class tl extends I{_parse(l){if(this._getType(l)!==t.undefined){const n=this._getOrReturnCtx(l);return h(n,{code:i.invalid_type,expected:t.undefined,received:n.parsedType}),f}return m(l.data)}}tl.create=l=>new tl({typeName:Ul.ZodUndefined,...T(l)});class sl extends I{_parse(l){if(this._getType(l)!==t.null){const n=this._getOrReturnCtx(l);return h(n,{code:i.invalid_type,expected:t.null,received:n.parsedType}),f}return m(l.data)}}sl.create=l=>new sl({typeName:Ul.ZodNull,...T(l)});class il extends I{constructor(){super(...arguments),this._any=!0}_parse(l){return m(l.data)}}il.create=l=>new il({typeName:Ul.ZodAny,...T(l)});class al extends I{constructor(){super(...arguments),this._unknown=!0}_parse(l){return m(l.data)}}al.create=l=>new al({typeName:Ul.ZodUnknown,...T(l)});class rl extends I{_parse(l){const n=this._getOrReturnCtx(l);return h(n,{code:i.invalid_type,expected:t.never,received:n.parsedType}),f}}rl.create=l=>new rl({typeName:Ul.ZodNever,...T(l)});class ol extends I{_parse(l){if(this._getType(l)!==t.undefined){const n=this._getOrReturnCtx(l);return h(n,{code:i.invalid_type,expected:t.void,received:n.parsedType}),f}return m(l.data)}}ol.create=l=>new ol({typeName:Ul.ZodVoid,...T(l)});class dl extends I{_parse(l){const{ctx:n,status:u}=this._processInputParams(l),e=this._def;if(n.parsedType!==t.array)return h(n,{code:i.invalid_type,expected:t.array,received:n.parsedType}),f;if(null!==e.exactLength){const l=n.data.length>e.exactLength.value,t=n.data.length<e.exactLength.value;(l||t)&&(h(n,{code:l?i.too_big:i.too_small,minimum:t?e.exactLength.value:void 0,maximum:l?e.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:e.exactLength.message}),u.dirty())}if(null!==e.minLength&&n.data.length<e.minLength.value&&(h(n,{code:i.too_small,minimum:e.minLength.value,type:"array",inclusive:!0,exact:!1,message:e.minLength.message}),u.dirty()),null!==e.maxLength&&n.data.length>e.maxLength.value&&(h(n,{code:i.too_big,maximum:e.maxLength.value,type:"array",inclusive:!0,exact:!1,message:e.maxLength.message}),u.dirty()),n.common.async)return Promise.all([...n.data].map(((l,u)=>e.type._parseAsync(new O(n,l,n.path,u))))).then((l=>p.mergeArray(u,l)));const s=[...n.data].map(((l,u)=>e.type._parseSync(new O(n,l,n.path,u))));return p.mergeArray(u,s)}get element(){return this._def.type}min(l,n){return new dl({...this._def,minLength:{value:l,message:x.toString(n)}})}max(l,n){return new dl({...this._def,maxLength:{value:l,message:x.toString(n)}})}length(l,n){return new dl({...this._def,exactLength:{value:l,message:x.toString(n)}})}nonempty(l){return this.min(1,l)}}function cl(l){if(l instanceof hl){const n={};for(const u in l.shape){const e=l.shape[u];n[u]=Cl.create(cl(e))}return new hl({...l._def,shape:()=>n})}return l instanceof dl?new dl({...l._def,type:cl(l.element)}):l instanceof Cl?Cl.create(cl(l.unwrap())):l instanceof Al?Al.create(cl(l.unwrap())):l instanceof yl?yl.create(l.items.map((l=>cl(l)))):l}dl.create=(l,n)=>new dl({type:l,minLength:null,maxLength:null,exactLength:null,typeName:Ul.ZodArray,...T(n)});class hl extends I{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const l=this._def.shape(),n=u.objectKeys(l);return this._cached={shape:l,keys:n}}_parse(l){if(this._getType(l)!==t.object){const n=this._getOrReturnCtx(l);return h(n,{code:i.invalid_type,expected:t.object,received:n.parsedType}),f}const{status:n,ctx:u}=this._processInputParams(l),{shape:e,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof rl&&"strip"===this._def.unknownKeys))for(const l in u.data)s.includes(l)||a.push(l);const r=[];for(const l of s){const n=e[l],t=u.data[l];r.push({key:{status:"valid",value:l},value:n._parse(new O(u,t,u.path,l)),alwaysSet:l in u.data})}if(this._def.catchall instanceof rl){const l=this._def.unknownKeys;if("passthrough"===l)for(const l of a)r.push({key:{status:"valid",value:l},value:{status:"valid",value:u.data[l]}});else if("strict"===l)a.length>0&&(h(u,{code:i.unrecognized_keys,keys:a}),n.dirty());else if("strip"!==l)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const n of a){const e=u.data[n];r.push({key:{status:"valid",value:n},value:l._parse(new O(u,e,u.path,n)),alwaysSet:n in u.data})}}return u.common.async?Promise.resolve().then((async()=>{const l=[];for(const n of r){const u=await n.key,e=await n.value;l.push({key:u,value:e,alwaysSet:n.alwaysSet})}return l})).then((l=>p.mergeObjectSync(n,l))):p.mergeObjectSync(n,r)}get shape(){return this._def.shape()}strict(l){return x.errToObj,new hl({...this._def,unknownKeys:"strict",...void 0!==l?{errorMap:(n,u)=>{var e,t,s,i;const a=null!==(s=null===(t=(e=this._def).errorMap)||void 0===t?void 0:t.call(e,n,u).message)&&void 0!==s?s:u.defaultError;return"unrecognized_keys"===n.code?{message:null!==(i=x.errToObj(l).message)&&void 0!==i?i:a}:{message:a}}}:{}})}strip(){return new hl({...this._def,unknownKeys:"strip"})}passthrough(){return new hl({...this._def,unknownKeys:"passthrough"})}extend(l){return new hl({...this._def,shape:()=>({...this._def.shape(),...l})})}merge(l){return new hl({unknownKeys:l._def.unknownKeys,catchall:l._def.catchall,shape:()=>({...this._def.shape(),...l._def.shape()}),typeName:Ul.ZodObject})}setKey(l,n){return this.augment({[l]:n})}catchall(l){return new hl({...this._def,catchall:l})}pick(l){const n={};return u.objectKeys(l).forEach((u=>{l[u]&&this.shape[u]&&(n[u]=this.shape[u])})),new hl({...this._def,shape:()=>n})}omit(l){const n={};return u.objectKeys(this.shape).forEach((u=>{l[u]||(n[u]=this.shape[u])})),new hl({...this._def,shape:()=>n})}deepPartial(){return cl(this)}partial(l){const n={};return u.objectKeys(this.shape).forEach((u=>{const e=this.shape[u];l&&!l[u]?n[u]=e:n[u]=e.optional()})),new hl({...this._def,shape:()=>n})}required(l){const n={};return u.objectKeys(this.shape).forEach((u=>{if(l&&!l[u])n[u]=this.shape[u];else{let l=this.shape[u];for(;l instanceof Cl;)l=l._def.innerType;n[u]=l}})),new hl({...this._def,shape:()=>n})}keyof(){return Sl(u.objectKeys(this.shape))}}hl.create=(l,n)=>new hl({shape:()=>l,unknownKeys:"strip",catchall:rl.create(),typeName:Ul.ZodObject,...T(n)}),hl.strictCreate=(l,n)=>new hl({shape:()=>l,unknownKeys:"strict",catchall:rl.create(),typeName:Ul.ZodObject,...T(n)}),hl.lazycreate=(l,n)=>new hl({shape:l,unknownKeys:"strip",catchall:rl.create(),typeName:Ul.ZodObject,...T(n)});class pl extends I{_parse(l){const{ctx:n}=this._processInputParams(l),u=this._def.options;if(n.common.async)return Promise.all(u.map((async l=>{const u={...n,common:{...n.common,issues:[]},parent:null};return{result:await l._parseAsync({data:n.data,path:n.path,parent:u}),ctx:u}}))).then((function(l){for(const n of l)if("valid"===n.result.status)return n.result;for(const u of l)if("dirty"===u.result.status)return n.common.issues.push(...u.ctx.common.issues),u.result;const u=l.map((l=>new a(l.ctx.common.issues)));return h(n,{code:i.invalid_union,unionErrors:u}),f}));{let l;const e=[];for(const t of u){const u={...n,common:{...n.common,issues:[]},parent:null},s=t._parseSync({data:n.data,path:n.path,parent:u});if("valid"===s.status)return s;"dirty"!==s.status||l||(l={result:s,ctx:u}),u.common.issues.length&&e.push(u.common.issues)}if(l)return n.common.issues.push(...l.ctx.common.issues),l.result;const t=e.map((l=>new a(l)));return h(n,{code:i.invalid_union,unionErrors:t}),f}}get options(){return this._def.options}}pl.create=(l,n)=>new pl({options:l,typeName:Ul.ZodUnion,...T(n)});const fl=l=>l instanceof xl?fl(l.schema):l instanceof Il?fl(l.innerType()):l instanceof jl?[l.value]:l instanceof Ol?l.options:l instanceof Zl?u.objectValues(l.enum):l instanceof El?fl(l._def.innerType):l instanceof tl?[void 0]:l instanceof sl?[null]:l instanceof Cl?[void 0,...fl(l.unwrap())]:l instanceof Al?[null,...fl(l.unwrap())]:l instanceof Ml||l instanceof Ll?fl(l.unwrap()):l instanceof Nl?fl(l._def.innerType):[];class _l extends I{_parse(l){const{ctx:n}=this._processInputParams(l);if(n.parsedType!==t.object)return h(n,{code:i.invalid_type,expected:t.object,received:n.parsedType}),f;const u=this.discriminator,e=n.data[u],s=this.optionsMap.get(e);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(h(n,{code:i.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[u]}),f)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(l,n,u){const e=new Map;for(const u of n){const n=fl(u.shape[l]);if(!n.length)throw new Error(`A discriminator value for key \`${l}\` could not be extracted from all schema options`);for(const t of n){if(e.has(t))throw new Error(`Discriminator property ${String(l)} has duplicate value ${String(t)}`);e.set(t,u)}}return new _l({typeName:Ul.ZodDiscriminatedUnion,discriminator:l,options:n,optionsMap:e,...T(u)})}}function ml(l,n){const e=s(l),i=s(n);if(l===n)return{valid:!0,data:l};if(e===t.object&&i===t.object){const e=u.objectKeys(n),t=u.objectKeys(l).filter((l=>-1!==e.indexOf(l))),s={...l,...n};for(const u of t){const e=ml(l[u],n[u]);if(!e.valid)return{valid:!1};s[u]=e.data}return{valid:!0,data:s}}if(e===t.array&&i===t.array){if(l.length!==n.length)return{valid:!1};const u=[];for(let e=0;e<l.length;e++){const t=ml(l[e],n[e]);if(!t.valid)return{valid:!1};u.push(t.data)}return{valid:!0,data:u}}return e===t.date&&i===t.date&&+l==+n?{valid:!0,data:l}:{valid:!1}}class gl extends I{_parse(l){const{status:n,ctx:u}=this._processInputParams(l),e=(l,e)=>{if(g(l)||g(e))return f;const t=ml(l.value,e.value);return t.valid?((y(l)||y(e))&&n.dirty(),{status:n.value,value:t.data}):(h(u,{code:i.invalid_intersection_types}),f)};return u.common.async?Promise.all([this._def.left._parseAsync({data:u.data,path:u.path,parent:u}),this._def.right._parseAsync({data:u.data,path:u.path,parent:u})]).then((([l,n])=>e(l,n))):e(this._def.left._parseSync({data:u.data,path:u.path,parent:u}),this._def.right._parseSync({data:u.data,path:u.path,parent:u}))}}gl.create=(l,n,u)=>new gl({left:l,right:n,typeName:Ul.ZodIntersection,...T(u)});class yl extends I{_parse(l){const{status:n,ctx:u}=this._processInputParams(l);if(u.parsedType!==t.array)return h(u,{code:i.invalid_type,expected:t.array,received:u.parsedType}),f;if(u.data.length<this._def.items.length)return h(u,{code:i.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),f;!this._def.rest&&u.data.length>this._def.items.length&&(h(u,{code:i.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const e=[...u.data].map(((l,n)=>{const e=this._def.items[n]||this._def.rest;return e?e._parse(new O(u,l,u.path,n)):null})).filter((l=>!!l));return u.common.async?Promise.all(e).then((l=>p.mergeArray(n,l))):p.mergeArray(n,e)}get items(){return this._def.items}rest(l){return new yl({...this._def,rest:l})}}yl.create=(l,n)=>{if(!Array.isArray(l))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new yl({items:l,typeName:Ul.ZodTuple,rest:null,...T(n)})};class vl extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(l){const{status:n,ctx:u}=this._processInputParams(l);if(u.parsedType!==t.object)return h(u,{code:i.invalid_type,expected:t.object,received:u.parsedType}),f;const e=[],s=this._def.keyType,a=this._def.valueType;for(const l in u.data)e.push({key:s._parse(new O(u,l,u.path,l)),value:a._parse(new O(u,u.data[l],u.path,l)),alwaysSet:l in u.data});return u.common.async?p.mergeObjectAsync(n,e):p.mergeObjectSync(n,e)}get element(){return this._def.valueType}static create(l,n,u){return new vl(n instanceof I?{keyType:l,valueType:n,typeName:Ul.ZodRecord,...T(u)}:{keyType:H.create(),valueType:l,typeName:Ul.ZodRecord,...T(n)})}}class bl extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(l){const{status:n,ctx:u}=this._processInputParams(l);if(u.parsedType!==t.map)return h(u,{code:i.invalid_type,expected:t.map,received:u.parsedType}),f;const e=this._def.keyType,s=this._def.valueType,a=[...u.data.entries()].map((([l,n],t)=>({key:e._parse(new O(u,l,u.path,[t,"key"])),value:s._parse(new O(u,n,u.path,[t,"value"]))})));if(u.common.async){const l=new Map;return Promise.resolve().then((async()=>{for(const u of a){const e=await u.key,t=await u.value;if("aborted"===e.status||"aborted"===t.status)return f;"dirty"!==e.status&&"dirty"!==t.status||n.dirty(),l.set(e.value,t.value)}return{status:n.value,value:l}}))}{const l=new Map;for(const u of a){const e=u.key,t=u.value;if("aborted"===e.status||"aborted"===t.status)return f;"dirty"!==e.status&&"dirty"!==t.status||n.dirty(),l.set(e.value,t.value)}return{status:n.value,value:l}}}}bl.create=(l,n,u)=>new bl({valueType:n,keyType:l,typeName:Ul.ZodMap,...T(u)});class kl extends I{_parse(l){const{status:n,ctx:u}=this._processInputParams(l);if(u.parsedType!==t.set)return h(u,{code:i.invalid_type,expected:t.set,received:u.parsedType}),f;const e=this._def;null!==e.minSize&&u.data.size<e.minSize.value&&(h(u,{code:i.too_small,minimum:e.minSize.value,type:"set",inclusive:!0,exact:!1,message:e.minSize.message}),n.dirty()),null!==e.maxSize&&u.data.size>e.maxSize.value&&(h(u,{code:i.too_big,maximum:e.maxSize.value,type:"se