@jsdev_ninja/core 0.12.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs.js +1 -1
- package/dist/core.cjs.js.map +1 -1
- package/dist/core.es.js +321 -326
- package/dist/core.es.js.map +1 -1
- package/dist/core.umd.js +1 -1
- package/dist/core.umd.js.map +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +8 -15
- package/lib/utils/index.ts +10 -26
- package/package.json +1 -1
package/dist/core.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var b;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const a={};for(const c of s)a[c]=c;return a},r.getValidEnumValues=s=>{const a=r.objectKeys(s).filter(i=>typeof s[s[i]]!="number"),c={};for(const i of a)c[i]=s[i];return r.objectValues(c)},r.objectValues=s=>r.objectKeys(s).map(function(a){return s[a]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const c in s)Object.prototype.hasOwnProperty.call(s,c)&&a.push(c);return a},r.find=(s,a)=>{for(const c of s)if(a(c))return c},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(c=>typeof c=="string"?`'${c}'`:c).join(a)}r.joinValues=n,r.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(b||(b={}));var Oe;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Oe||(Oe={}));const h=b.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),D=r=>{switch(typeof r){case"undefined":return h.undefined;case"string":return h.string;case"number":return isNaN(r)?h.nan:h.number;case"boolean":return h.boolean;case"function":return h.function;case"bigint":return h.bigint;case"symbol":return h.symbol;case"object":return Array.isArray(r)?h.array:r===null?h.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?h.promise:typeof Map<"u"&&r instanceof Map?h.map:typeof Set<"u"&&r instanceof Set?h.set:typeof Date<"u"&&r instanceof Date?h.date:h.object;default:return h.unknown}},d=b.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"]),it=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class I extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(a){return a.message},n={_errors:[]},s=a=>{for(const c of a.issues)if(c.code==="invalid_union")c.unionErrors.map(s);else if(c.code==="invalid_return_type")s(c.returnTypeError);else if(c.code==="invalid_arguments")s(c.argumentsError);else if(c.path.length===0)n._errors.push(t(c));else{let i=n,l=0;for(;l<c.path.length;){const u=c.path[l];l===c.path.length-1?(i[u]=i[u]||{_errors:[]},i[u]._errors.push(t(c))):i[u]=i[u]||{_errors:[]},i=i[u],l++}}};return s(this),n}static assert(e){if(!(e instanceof I))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,b.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}I.create=r=>new I(r);const G=(r,e)=>{let t;switch(r.code){case d.invalid_type:r.received===h.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case d.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,b.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:t=`Unrecognized key(s) in object: ${b.joinValues(r.keys,", ")}`;break;case d.invalid_union:t="Invalid input";break;case d.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${b.joinValues(r.options)}`;break;case d.invalid_enum_value:t=`Invalid enum value. Expected ${b.joinValues(r.options)}, received '${r.received}'`;break;case d.invalid_arguments:t="Invalid function arguments";break;case d.invalid_return_type:t="Invalid function return type";break;case d.invalid_date:t="Invalid date";break;case d.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:b.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case d.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case d.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case d.custom:t="Invalid input";break;case d.invalid_intersection_types:t="Intersection results could not be merged";break;case d.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case d.not_finite:t="Number must be finite";break;default:t=e.defaultError,b.assertNever(r)}return{message:t}};let Je=G;function ot(r){Je=r}function ve(){return Je}const _e=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],c={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let i="";const l=n.filter(u=>!!u).slice().reverse();for(const u of l)i=u(c,{data:e,defaultError:i}).message;return{...s,path:a,message:i}},ct=[];function f(r,e){const t=ve(),n=_e({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===G?void 0:G].filter(s=>!!s)});r.common.issues.push(n)}class S{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return g;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t){const a=await s.key,c=await s.value;n.push({key:a,value:c})}return S.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:a,value:c}=s;if(a.status==="aborted"||c.status==="aborted")return g;a.status==="dirty"&&e.dirty(),c.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof c.value<"u"||s.alwaysSet)&&(n[a.value]=c.value)}return{status:e.value,value:n}}}const g=Object.freeze({status:"aborted"}),Y=r=>({status:"dirty",value:r}),C=r=>({status:"valid",value:r}),Ee=r=>r.status==="aborted",je=r=>r.status==="dirty",q=r=>r.status==="valid",ne=r=>typeof Promise<"u"&&r instanceof Promise;function be(r,e,t,n){if(typeof e=="function"?r!==e||!0:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function Qe(r,e,t,n,s){if(typeof e=="function"?r!==e||!0:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}var p;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(p||(p={}));var te,re;class P{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}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 Be=(r,e)=>{if(q(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new I(r.common.issues);return this._error=t,this._error}}};function v(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(c,i)=>{var l,u;const{message:m}=r;return c.code==="invalid_enum_value"?{message:m??i.defaultError}:typeof i.data>"u"?{message:(l=m??n)!==null&&l!==void 0?l:i.defaultError}:c.code!=="invalid_type"?{message:i.defaultError}:{message:(u=m??t)!==null&&u!==void 0?u:i.defaultError}},description:s}}class _{get description(){return this._def.description}_getType(e){return D(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:D(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new S,ctx:{common:e.parent.common,data:e.data,parsedType:D(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(ne(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const s={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:D(e)},a=this._parseSync({data:e,path:s.path,parent:s});return Be(s,a)}"~validate"(e){var t,n;const s={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:D(e)};if(!this["~standard"].async)try{const a=this._parseSync({data:e,path:[],parent:s});return q(a)?{value:a.value}:{issues:s.common.issues}}catch(a){!((n=(t=a==null?void 0:a.message)===null||t===void 0?void 0:t.toLowerCase())===null||n===void 0)&&n.includes("encountered")&&(this["~standard"].async=!0),s.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:s}).then(a=>q(a)?{value:a.value}:{issues:s.common.issues})}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:D(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(ne(s)?s:Promise.resolve(s));return Be(n,a)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const c=e(s),i=()=>a.addIssue({code:d.custom,...n(s)});return typeof Promise<"u"&&c instanceof Promise?c.then(l=>l?!0:(i(),!1)):c?!0:(i(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new E({schema:this,typeName:y.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return j.create(this,this._def)}nullable(){return F.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return O.create(this)}promise(){return K.create(this,this._def)}or(e){return oe.create([this,e],this._def)}and(e){return ce.create(this,e,this._def)}transform(e){return new E({...v(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new he({...v(this._def),innerType:this,defaultValue:t,typeName:y.ZodDefault})}brand(){return new Re({typeName:y.ZodBranded,type:this,...v(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new me({...v(this._def),innerType:this,catchValue:t,typeName:y.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ye.create(this,e)}readonly(){return pe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const dt=/^c[^\s-]{8,}$/i,ut=/^[0-9a-z]+$/,lt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ft=/^[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,ht=/^[a-z0-9_-]{21}$/i,mt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,pt=/^[-+]?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)?)??$/,yt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,gt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ze;const vt=/^(?:(?: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])$/,_t=/^(?:(?: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])$/,bt=/^(([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]))$/,xt=/^(([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])$/,kt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,wt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ye="((\\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])))",Tt=new RegExp(`^${Ye}$`);function He(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function St(r){return new RegExp(`^${He(r)}$`)}function Ge(r){let e=`${Ye}T${He(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Ct(r,e){return!!((e==="v4"||!e)&&vt.test(r)||(e==="v6"||!e)&&bt.test(r))}function It(r,e){if(!mt.test(r))return!1;try{const[t]=r.split("."),n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||!s.typ||!s.alg||e&&s.alg!==e)}catch{return!1}}function Zt(r,e){return!!((e==="v4"||!e)&&_t.test(r)||(e==="v6"||!e)&&xt.test(r))}class N extends _{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==h.string){const a=this._getOrReturnCtx(e);return f(a,{code:d.invalid_type,expected:h.string,received:a.parsedType}),g}const n=new S;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const c=e.data.length>a.value,i=e.data.length<a.value;(c||i)&&(s=this._getOrReturnCtx(e,s),c?f(s,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):i&&f(s,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")yt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"email",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")Ze||(Ze=new RegExp(gt,"u")),Ze.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"emoji",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")ft.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"uuid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")ht.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"nanoid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")dt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cuid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")ut.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cuid2",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")lt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"ulid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),f(s,{validation:"url",code:d.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"regex",code:d.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),f(s,{code:d.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),f(s,{code:d.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),f(s,{code:d.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Ge(a).test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:d.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?Tt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:d.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?St(a).test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:d.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?pt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"duration",code:d.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?Ct(e.data,a.version)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"ip",code:d.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?It(e.data,a.alg)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"jwt",code:d.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?Zt(e.data,a.version)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cidr",code:d.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?kt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"base64",code:d.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?wt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"base64url",code:d.invalid_string,message:a.message}),n.dirty()):b.assertNever(a);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:d.invalid_string,...p.errToObj(n)})}_addCheck(e){return new N({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...p.errToObj(e)})}url(e){return this._addCheck({kind:"url",...p.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...p.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...p.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...p.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...p.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...p.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...p.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...p.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...p.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...p.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...p.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...p.errToObj(e)})}datetime(e){var t,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:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...p.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,...p.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...p.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...p.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...p.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...p.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...p.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...p.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...p.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...p.errToObj(t)})}nonempty(e){return this.min(1,p.errToObj(e))}trim(){return new N({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new N({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new N({...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 isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}N.create=r=>{var e;return new N({checks:[],typeName:y.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...v(r)})};function At(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,a=parseInt(r.toFixed(s).replace(".","")),c=parseInt(e.toFixed(s).replace(".",""));return a%c/Math.pow(10,s)}class V extends _{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==h.number){const a=this._getOrReturnCtx(e);return f(a,{code:d.invalid_type,expected:h.number,received:a.parsedType}),g}let n;const s=new S;for(const a of this._def.checks)a.kind==="int"?b.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:d.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:d.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:d.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?At(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),f(n,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:d.not_finite,message:a.message}),s.dirty()):b.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,p.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.toString(t))}setLimit(e,t,n,s){return new V({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:p.toString(s)}]})}_addCheck(e){return new V({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:p.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:p.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:p.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:p.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:p.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&b.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}V.create=r=>new V({checks:[],typeName:y.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...v(r)});class L extends _{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==h.bigint)return this._getInvalidInput(e);let n;const s=new S;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:d.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:d.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),f(n,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):b.assertNever(a);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return f(t,{code:d.invalid_type,expected:h.bigint,received:t.parsedType}),g}gte(e,t){return this.setLimit("min",e,!0,p.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.toString(t))}setLimit(e,t,n,s){return new L({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:p.toString(s)}]})}_addCheck(e){return new L({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:p.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}L.create=r=>{var e;return new L({checks:[],typeName:y.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...v(r)})};class se extends _{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==h.boolean){const n=this._getOrReturnCtx(e);return f(n,{code:d.invalid_type,expected:h.boolean,received:n.parsedType}),g}return C(e.data)}}se.create=r=>new se({typeName:y.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...v(r)});class W extends _{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==h.date){const a=this._getOrReturnCtx(e);return f(a,{code:d.invalid_type,expected:h.date,received:a.parsedType}),g}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return f(a,{code:d.invalid_date}),g}const n=new S;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:d.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:d.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):b.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new W({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:p.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:p.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}W.create=r=>new W({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:y.ZodDate,...v(r)});class xe extends _{_parse(e){if(this._getType(e)!==h.symbol){const n=this._getOrReturnCtx(e);return f(n,{code:d.invalid_type,expected:h.symbol,received:n.parsedType}),g}return C(e.data)}}xe.create=r=>new xe({typeName:y.ZodSymbol,...v(r)});class ae extends _{_parse(e){if(this._getType(e)!==h.undefined){const n=this._getOrReturnCtx(e);return f(n,{code:d.invalid_type,expected:h.undefined,received:n.parsedType}),g}return C(e.data)}}ae.create=r=>new ae({typeName:y.ZodUndefined,...v(r)});class ie extends _{_parse(e){if(this._getType(e)!==h.null){const n=this._getOrReturnCtx(e);return f(n,{code:d.invalid_type,expected:h.null,received:n.parsedType}),g}return C(e.data)}}ie.create=r=>new ie({typeName:y.ZodNull,...v(r)});class X extends _{constructor(){super(...arguments),this._any=!0}_parse(e){return C(e.data)}}X.create=r=>new X({typeName:y.ZodAny,...v(r)});class U extends _{constructor(){super(...arguments),this._unknown=!0}_parse(e){return C(e.data)}}U.create=r=>new U({typeName:y.ZodUnknown,...v(r)});class M extends _{_parse(e){const t=this._getOrReturnCtx(e);return f(t,{code:d.invalid_type,expected:h.never,received:t.parsedType}),g}}M.create=r=>new M({typeName:y.ZodNever,...v(r)});class ke extends _{_parse(e){if(this._getType(e)!==h.undefined){const n=this._getOrReturnCtx(e);return f(n,{code:d.invalid_type,expected:h.void,received:n.parsedType}),g}return C(e.data)}}ke.create=r=>new ke({typeName:y.ZodVoid,...v(r)});class O extends _{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==h.array)return f(t,{code:d.invalid_type,expected:h.array,received:t.parsedType}),g;if(s.exactLength!==null){const c=t.data.length>s.exactLength.value,i=t.data.length<s.exactLength.value;(c||i)&&(f(t,{code:c?d.too_big:d.too_small,minimum:i?s.exactLength.value:void 0,maximum:c?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(f(t,{code:d.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(f(t,{code:d.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((c,i)=>s.type._parseAsync(new P(t,c,t.path,i)))).then(c=>S.mergeArray(n,c));const a=[...t.data].map((c,i)=>s.type._parseSync(new P(t,c,t.path,i)));return S.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new O({...this._def,minLength:{value:e,message:p.toString(t)}})}max(e,t){return new O({...this._def,maxLength:{value:e,message:p.toString(t)}})}length(e,t){return new O({...this._def,exactLength:{value:e,message:p.toString(t)}})}nonempty(e){return this.min(1,e)}}O.create=(r,e)=>new O({type:r,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,...v(e)});function Q(r){if(r instanceof k){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=j.create(Q(n))}return new k({...r._def,shape:()=>e})}else return r instanceof O?new O({...r._def,type:Q(r.element)}):r instanceof j?j.create(Q(r.unwrap())):r instanceof F?F.create(Q(r.unwrap())):r instanceof R?R.create(r.items.map(e=>Q(e))):r}class k extends _{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(),t=b.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==h.object){const u=this._getOrReturnCtx(e);return f(u,{code:d.invalid_type,expected:h.object,received:u.parsedType}),g}const{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:c}=this._getCached(),i=[];if(!(this._def.catchall instanceof M&&this._def.unknownKeys==="strip"))for(const u in s.data)c.includes(u)||i.push(u);const l=[];for(const u of c){const m=a[u],x=s.data[u];l.push({key:{status:"valid",value:u},value:m._parse(new P(s,x,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof M){const u=this._def.unknownKeys;if(u==="passthrough")for(const m of i)l.push({key:{status:"valid",value:m},value:{status:"valid",value:s.data[m]}});else if(u==="strict")i.length>0&&(f(s,{code:d.unrecognized_keys,keys:i}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const m of i){const x=s.data[m];l.push({key:{status:"valid",value:m},value:u._parse(new P(s,x,s.path,m)),alwaysSet:m in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const m of l){const x=await m.key,Z=await m.value;u.push({key:x,value:Z,alwaysSet:m.alwaysSet})}return u}).then(u=>S.mergeObjectSync(n,u)):S.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(e){return p.errToObj,new k({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,a,c,i;const l=(c=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,n).message)!==null&&c!==void 0?c:n.defaultError;return t.code==="unrecognized_keys"?{message:(i=p.errToObj(e).message)!==null&&i!==void 0?i:l}:{message:l}}}:{}})}strip(){return new k({...this._def,unknownKeys:"strip"})}passthrough(){return new k({...this._def,unknownKeys:"passthrough"})}extend(e){return new k({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new k({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:y.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new k({...this._def,catchall:e})}pick(e){const t={};return b.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new k({...this._def,shape:()=>t})}omit(e){const t={};return b.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new k({...this._def,shape:()=>t})}deepPartial(){return Q(this)}partial(e){const t={};return b.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new k({...this._def,shape:()=>t})}required(e){const t={};return b.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof j;)a=a._def.innerType;t[n]=a}}),new k({...this._def,shape:()=>t})}keyof(){return Xe(b.objectKeys(this.shape))}}k.create=(r,e)=>new k({shape:()=>r,unknownKeys:"strip",catchall:M.create(),typeName:y.ZodObject,...v(e)});k.strictCreate=(r,e)=>new k({shape:()=>r,unknownKeys:"strict",catchall:M.create(),typeName:y.ZodObject,...v(e)});k.lazycreate=(r,e)=>new k({shape:r,unknownKeys:"strip",catchall:M.create(),typeName:y.ZodObject,...v(e)});class oe extends _{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(a){for(const i of a)if(i.result.status==="valid")return i.result;for(const i of a)if(i.result.status==="dirty")return t.common.issues.push(...i.ctx.common.issues),i.result;const c=a.map(i=>new I(i.ctx.common.issues));return f(t,{code:d.invalid_union,unionErrors:c}),g}if(t.common.async)return Promise.all(n.map(async a=>{const c={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:c}),ctx:c}})).then(s);{let a;const c=[];for(const l of n){const u={...t,common:{...t.common,issues:[]},parent:null},m=l._parseSync({data:t.data,path:t.path,parent:u});if(m.status==="valid")return m;m.status==="dirty"&&!a&&(a={result:m,ctx:u}),u.common.issues.length&&c.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const i=c.map(l=>new I(l));return f(t,{code:d.invalid_union,unionErrors:i}),g}}get options(){return this._def.options}}oe.create=(r,e)=>new oe({options:r,typeName:y.ZodUnion,...v(e)});const $=r=>r instanceof ue?$(r.schema):r instanceof E?$(r.innerType()):r instanceof le?[r.value]:r instanceof z?r.options:r instanceof fe?b.objectValues(r.enum):r instanceof he?$(r._def.innerType):r instanceof ae?[void 0]:r instanceof ie?[null]:r instanceof j?[void 0,...$(r.unwrap())]:r instanceof F?[null,...$(r.unwrap())]:r instanceof Re||r instanceof pe?$(r.unwrap()):r instanceof me?$(r._def.innerType):[];class Se extends _{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.object)return f(t,{code:d.invalid_type,expected:h.object,received:t.parsedType}),g;const n=this.discriminator,s=t.data[n],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(f(t,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),g)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const a of t){const c=$(a.shape[e]);if(!c.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const i of c){if(s.has(i))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);s.set(i,a)}}return new Se({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...v(n)})}}function Pe(r,e){const t=D(r),n=D(e);if(r===e)return{valid:!0,data:r};if(t===h.object&&n===h.object){const s=b.objectKeys(e),a=b.objectKeys(r).filter(i=>s.indexOf(i)!==-1),c={...r,...e};for(const i of a){const l=Pe(r[i],e[i]);if(!l.valid)return{valid:!1};c[i]=l.data}return{valid:!0,data:c}}else if(t===h.array&&n===h.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<r.length;a++){const c=r[a],i=e[a],l=Pe(c,i);if(!l.valid)return{valid:!1};s.push(l.data)}return{valid:!0,data:s}}else return t===h.date&&n===h.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class ce extends _{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(a,c)=>{if(Ee(a)||Ee(c))return g;const i=Pe(a.value,c.value);return i.valid?((je(a)||je(c))&&t.dirty(),{status:t.value,value:i.data}):(f(n,{code:d.invalid_intersection_types}),g)};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(([a,c])=>s(a,c)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}ce.create=(r,e,t)=>new ce({left:r,right:e,typeName:y.ZodIntersection,...v(t)});class R extends _{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.array)return f(n,{code:d.invalid_type,expected:h.array,received:n.parsedType}),g;if(n.data.length<this._def.items.length)return f(n,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),g;!this._def.rest&&n.data.length>this._def.items.length&&(f(n,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...n.data].map((c,i)=>{const l=this._def.items[i]||this._def.rest;return l?l._parse(new P(n,c,n.path,i)):null}).filter(c=>!!c);return n.common.async?Promise.all(a).then(c=>S.mergeArray(t,c)):S.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new R({...this._def,rest:e})}}R.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new R({items:r,typeName:y.ZodTuple,rest:null,...v(e)})};class de extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.object)return f(n,{code:d.invalid_type,expected:h.object,received:n.parsedType}),g;const s=[],a=this._def.keyType,c=this._def.valueType;for(const i in n.data)s.push({key:a._parse(new P(n,i,n.path,i)),value:c._parse(new P(n,n.data[i],n.path,i)),alwaysSet:i in n.data});return n.common.async?S.mergeObjectAsync(t,s):S.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof _?new de({keyType:e,valueType:t,typeName:y.ZodRecord,...v(n)}):new de({keyType:N.create(),valueType:e,typeName:y.ZodRecord,...v(t)})}}class we extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.map)return f(n,{code:d.invalid_type,expected:h.map,received:n.parsedType}),g;const s=this._def.keyType,a=this._def.valueType,c=[...n.data.entries()].map(([i,l],u)=>({key:s._parse(new P(n,i,n.path,[u,"key"])),value:a._parse(new P(n,l,n.path,[u,"value"]))}));if(n.common.async){const i=new Map;return Promise.resolve().then(async()=>{for(const l of c){const u=await l.key,m=await l.value;if(u.status==="aborted"||m.status==="aborted")return g;(u.status==="dirty"||m.status==="dirty")&&t.dirty(),i.set(u.value,m.value)}return{status:t.value,value:i}})}else{const i=new Map;for(const l of c){const u=l.key,m=l.value;if(u.status==="aborted"||m.status==="aborted")return g;(u.status==="dirty"||m.status==="dirty")&&t.dirty(),i.set(u.value,m.value)}return{status:t.value,value:i}}}}we.create=(r,e,t)=>new we({valueType:e,keyType:r,typeName:y.ZodMap,...v(t)});class J extends _{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.set)return f(n,{code:d.invalid_type,expected:h.set,received:n.parsedType}),g;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(f(n,{code:d.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(f(n,{code:d.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function c(l){const u=new Set;for(const m of l){if(m.status==="aborted")return g;m.status==="dirty"&&t.dirty(),u.add(m.value)}return{status:t.value,value:u}}const i=[...n.data.values()].map((l,u)=>a._parse(new P(n,l,n.path,u)));return n.common.async?Promise.all(i).then(l=>c(l)):c(i)}min(e,t){return new J({...this._def,minSize:{value:e,message:p.toString(t)}})}max(e,t){return new J({...this._def,maxSize:{value:e,message:p.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}J.create=(r,e)=>new J({valueType:r,minSize:null,maxSize:null,typeName:y.ZodSet,...v(e)});class H extends _{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.function)return f(t,{code:d.invalid_type,expected:h.function,received:t.parsedType}),g;function n(i,l){return _e({data:i,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ve(),G].filter(u=>!!u),issueData:{code:d.invalid_arguments,argumentsError:l}})}function s(i,l){return _e({data:i,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ve(),G].filter(u=>!!u),issueData:{code:d.invalid_return_type,returnTypeError:l}})}const a={errorMap:t.common.contextualErrorMap},c=t.data;if(this._def.returns instanceof K){const i=this;return C(async function(...l){const u=new I([]),m=await i._def.args.parseAsync(l,a).catch(w=>{throw u.addIssue(n(l,w)),u}),x=await Reflect.apply(c,this,m);return await i._def.returns._def.type.parseAsync(x,a).catch(w=>{throw u.addIssue(s(x,w)),u})})}else{const i=this;return C(function(...l){const u=i._def.args.safeParse(l,a);if(!u.success)throw new I([n(l,u.error)]);const m=Reflect.apply(c,this,u.data),x=i._def.returns.safeParse(m,a);if(!x.success)throw new I([s(m,x.error)]);return x.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new H({...this._def,args:R.create(e).rest(U.create())})}returns(e){return new H({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new H({args:e||R.create([]).rest(U.create()),returns:t||U.create(),typeName:y.ZodFunction,...v(n)})}}class ue extends _{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ue.create=(r,e)=>new ue({getter:r,typeName:y.ZodLazy,...v(e)});class le extends _{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return f(t,{received:t.data,code:d.invalid_literal,expected:this._def.value}),g}return{status:"valid",value:e.data}}get value(){return this._def.value}}le.create=(r,e)=>new le({value:r,typeName:y.ZodLiteral,...v(e)});function Xe(r,e){return new z({values:r,typeName:y.ZodEnum,...v(e)})}class z extends _{constructor(){super(...arguments),te.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return f(t,{expected:b.joinValues(n),received:t.parsedType,code:d.invalid_type}),g}if(be(this,te)||Qe(this,te,new Set(this._def.values)),!be(this,te).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return f(t,{received:t.data,code:d.invalid_enum_value,options:n}),g}return C(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return z.create(e,{...this._def,...t})}exclude(e,t=this._def){return z.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}te=new WeakMap;z.create=Xe;class fe extends _{constructor(){super(...arguments),re.set(this,void 0)}_parse(e){const t=b.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==h.string&&n.parsedType!==h.number){const s=b.objectValues(t);return f(n,{expected:b.joinValues(s),received:n.parsedType,code:d.invalid_type}),g}if(be(this,re)||Qe(this,re,new Set(b.getValidEnumValues(this._def.values))),!be(this,re).has(e.data)){const s=b.objectValues(t);return f(n,{received:n.data,code:d.invalid_enum_value,options:s}),g}return C(e.data)}get enum(){return this._def.values}}re=new WeakMap;fe.create=(r,e)=>new fe({values:r,typeName:y.ZodNativeEnum,...v(e)});class K extends _{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.promise&&t.common.async===!1)return f(t,{code:d.invalid_type,expected:h.promise,received:t.parsedType}),g;const n=t.parsedType===h.promise?t.data:Promise.resolve(t.data);return C(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}K.create=(r,e)=>new K({type:r,typeName:y.ZodPromise,...v(e)});class E extends _{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:c=>{f(n,c),c.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const c=s.transform(n.data,a);if(n.common.async)return Promise.resolve(c).then(async i=>{if(t.value==="aborted")return g;const l=await this._def.schema._parseAsync({data:i,path:n.path,parent:n});return l.status==="aborted"?g:l.status==="dirty"||t.value==="dirty"?Y(l.value):l});{if(t.value==="aborted")return g;const i=this._def.schema._parseSync({data:c,path:n.path,parent:n});return i.status==="aborted"?g:i.status==="dirty"||t.value==="dirty"?Y(i.value):i}}if(s.type==="refinement"){const c=i=>{const l=s.refinement(i,a);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?g:(i.status==="dirty"&&t.dirty(),c(i.value),{status:t.value,value:i.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>i.status==="aborted"?g:(i.status==="dirty"&&t.dirty(),c(i.value).then(()=>({status:t.value,value:i.value}))))}if(s.type==="transform")if(n.common.async===!1){const c=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!q(c))return c;const i=s.transform(c.value,a);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:i}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(c=>q(c)?Promise.resolve(s.transform(c.value,a)).then(i=>({status:t.value,value:i})):c);b.assertNever(s)}}E.create=(r,e,t)=>new E({schema:r,typeName:y.ZodEffects,effect:e,...v(t)});E.createWithPreprocess=(r,e,t)=>new E({schema:e,effect:{type:"preprocess",transform:r},typeName:y.ZodEffects,...v(t)});class j extends _{_parse(e){return this._getType(e)===h.undefined?C(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}j.create=(r,e)=>new j({innerType:r,typeName:y.ZodOptional,...v(e)});class F extends _{_parse(e){return this._getType(e)===h.null?C(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}F.create=(r,e)=>new F({innerType:r,typeName:y.ZodNullable,...v(e)});class he extends _{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===h.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}he.create=(r,e)=>new he({innerType:r,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...v(e)});class me extends _{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return ne(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new I(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new I(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}me.create=(r,e)=>new me({innerType:r,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...v(e)});class Te extends _{_parse(e){if(this._getType(e)!==h.nan){const n=this._getOrReturnCtx(e);return f(n,{code:d.invalid_type,expected:h.nan,received:n.parsedType}),g}return{status:"valid",value:e.data}}}Te.create=r=>new Te({typeName:y.ZodNaN,...v(r)});const Nt=Symbol("zod_brand");class Re extends _{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class ye extends _{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?g:a.status==="dirty"?(t.dirty(),Y(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?g:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new ye({in:e,out:t,typeName:y.ZodPipeline})}}class pe extends _{_parse(e){const t=this._def.innerType._parse(e),n=s=>(q(s)&&(s.value=Object.freeze(s.value)),s);return ne(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}}pe.create=(r,e)=>new pe({innerType:r,typeName:y.ZodReadonly,...v(e)});function qe(r,e){const t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function Ke(r,e={},t){return r?X.create().superRefine((n,s)=>{var a,c;const i=r(n);if(i instanceof Promise)return i.then(l=>{var u,m;if(!l){const x=qe(e,n),Z=(m=(u=x.fatal)!==null&&u!==void 0?u:t)!==null&&m!==void 0?m:!0;s.addIssue({code:"custom",...x,fatal:Z})}});if(!i){const l=qe(e,n),u=(c=(a=l.fatal)!==null&&a!==void 0?a:t)!==null&&c!==void 0?c:!0;s.addIssue({code:"custom",...l,fatal:u})}}):X.create()}const Ot={object:k.lazycreate};var y;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(y||(y={}));const Et=(r,e={message:`Input not instance of ${r.name}`})=>Ke(t=>t instanceof r,e),et=N.create,tt=V.create,jt=Te.create,Pt=L.create,rt=se.create,Rt=W.create,$t=xe.create,Dt=ae.create,Mt=ie.create,Vt=X.create,Lt=U.create,zt=M.create,Ft=ke.create,Ut=O.create,Bt=k.create,qt=k.strictCreate,Wt=oe.create,Jt=Se.create,Qt=ce.create,Yt=R.create,Ht=de.create,Gt=we.create,Xt=J.create,Kt=H.create,er=ue.create,tr=le.create,rr=z.create,nr=fe.create,sr=K.create,We=E.create,ar=j.create,ir=F.create,or=E.createWithPreprocess,cr=ye.create,dr=()=>et().optional(),ur=()=>tt().optional(),lr=()=>rt().optional(),fr={string:r=>N.create({...r,coerce:!0}),number:r=>V.create({...r,coerce:!0}),boolean:r=>se.create({...r,coerce:!0}),bigint:r=>L.create({...r,coerce:!0}),date:r=>W.create({...r,coerce:!0})},hr=g;var o=Object.freeze({__proto__:null,defaultErrorMap:G,setErrorMap:ot,getErrorMap:ve,makeIssue:_e,EMPTY_PATH:ct,addIssueToContext:f,ParseStatus:S,INVALID:g,DIRTY:Y,OK:C,isAborted:Ee,isDirty:je,isValid:q,isAsync:ne,get util(){return b},get objectUtil(){return Oe},ZodParsedType:h,getParsedType:D,ZodType:_,datetimeRegex:Ge,ZodString:N,ZodNumber:V,ZodBigInt:L,ZodBoolean:se,ZodDate:W,ZodSymbol:xe,ZodUndefined:ae,ZodNull:ie,ZodAny:X,ZodUnknown:U,ZodNever:M,ZodVoid:ke,ZodArray:O,ZodObject:k,ZodUnion:oe,ZodDiscriminatedUnion:Se,ZodIntersection:ce,ZodTuple:R,ZodRecord:de,ZodMap:we,ZodSet:J,ZodFunction:H,ZodLazy:ue,ZodLiteral:le,ZodEnum:z,ZodNativeEnum:fe,ZodPromise:K,ZodEffects:E,ZodTransformer:E,ZodOptional:j,ZodNullable:F,ZodDefault:he,ZodCatch:me,ZodNaN:Te,BRAND:Nt,ZodBranded:Re,ZodPipeline:ye,ZodReadonly:pe,custom:Ke,Schema:_,ZodSchema:_,late:Ot,get ZodFirstPartyTypeKind(){return y},coerce:fr,any:Vt,array:Ut,bigint:Pt,boolean:rt,date:Rt,discriminatedUnion:Jt,effect:We,enum:rr,function:Kt,instanceof:Et,intersection:Qt,lazy:er,literal:tr,map:Gt,nan:jt,nativeEnum:nr,never:zt,null:Mt,nullable:ir,number:tt,object:Bt,oboolean:lr,onumber:ur,optional:ar,ostring:dr,pipeline:cr,preprocess:or,promise:sr,record:Ht,set:Xt,strictObject:qt,string:et,symbol:$t,transformer:We,tuple:Yt,undefined:Dt,union:Wt,unknown:Lt,void:Ft,NEVER:hr,ZodIssueCode:d,quotelessJson:it,ZodError:I});const T=o.string().min(1,{message:"שדה חובה"}),mr=o.string().regex(/^\d+$/,"Must be a numeric string"),nt=o.object({country:T,city:T,street:T,streetNumber:T,floor:T,apartmentEnterNumber:T,apartmentNumber:T}),B=o.object({lang:o.enum(["he"]),value:o.string()}),pr=o.array(B),$e=o.object({id:o.string().min(1),companyId:o.string().min(1),storeId:o.string().min(1),parentId:o.string().nullish(),tag:o.string().optional(),locales:o.array(B),depth:o.number()}),Ce=$e.extend({children:o.lazy(()=>Ce.array())}),yr=$e.extend({index:o.number(),depth:o.number(),collapsed:o.boolean().optional(),children:o.array(Ce)}),ee=o.string().min(1),De=o.object({type:o.literal("Product"),storeId:ee,companyId:ee,id:ee,objectID:ee,sku:ee,name:o.array(B),description:o.array(B),isPublished:o.boolean(),vat:o.boolean(),priceType:o.object({type:o.enum(["unit","kg","gram","liter","ml"]),value:o.number()}),price:o.number().positive(),purchasePrice:o.number().optional(),profitPercentage:o.number().optional(),currency:o.literal("ILS"),discount:o.object({type:o.enum(["number","percent","none"]),value:o.number()}),isDiscountable:o.boolean({description:"included in store discounts"}).optional(),weight:o.object({value:o.number(),unit:o.enum(["kg","gram","none"])}),volume:o.object({value:o.number(),unit:o.enum(["liter","ml","none"])}),images:o.array(o.object({url:o.string().url(),id:o.string()})),manufacturer:o.string(),brand:o.string(),importer:o.string(),supplier:o.string(),ingredients:o.array(B),created_at:o.number(),updated_at:o.number(),categoryIds:o.array(o.string().nonempty()),categoryList:o.array(Ce),categories:o.object({lvl0:o.array(o.string()),lvl1:o.array(o.string()),lvl2:o.array(o.string()),lvl3:o.array(o.string()),lvl4:o.array(o.string())}),categoryNames:o.array(o.string())}),gr=De.extend({image:o.instanceof(File).optional()}),Me=o.object({product:De,originalPrice:o.number().optional(),finalPrice:o.number().optional(),finalDiscount:o.number().optional(),amount:o.number().int().positive({message:"Quantity must be a positive integer."})}),vr=o.object({type:o.literal("Cart"),id:o.string().uuid(),companyId:o.string().uuid(),storeId:o.string().uuid(),userId:o.string().uuid(),status:o.enum(["active","draft","completed"]),items:o.array(Me)}),_r=o.object({id:o.string(),name:o.string(),websiteDomains:o.array(o.string())}),br=o.object({type:o.literal("FavoriteProduct"),id:o.string().uuid(),companyId:o.string().uuid(),storeId:o.string().uuid(),userId:o.string().uuid(),productId:o.string().uuid()}),Ve=o.enum(["default","delayed"]),st=o.object({type:o.literal("Profile"),id:T,companyId:T,storeId:T,tenantId:T,clientType:o.enum(["user","company"]),companyName:o.string().optional(),displayName:T,email:o.string().email(),phoneNumber:T.optional(),address:nt.optional(),isAnonymous:o.boolean(),createdDate:o.number(),lastActivityDate:o.number(),paymentType:Ve});function xr(){return{type:"Profile",id:"",companyId:"",storeId:"",tenantId:"",clientType:"user",displayName:"",email:"",phoneNumber:"",address:{country:"",city:"",street:"",streetNumber:"",floor:"",apartmentEnterNumber:"",apartmentNumber:""},createdDate:0,lastActivityDate:0,isAnonymous:!0,paymentType:Ve.Values.default}}const kr=o.object({type:o.literal("Order"),id:T,companyId:T,storeId:T,userId:T,status:o.enum(["draft","pending","processing","in_delivery","delivered","cancelled","completed","refunded"]),paymentStatus:o.enum(["pending","pending_j5","external","completed","failed","refunded"]),cart:o.object({id:o.string(),items:o.array(Me),cartDiscount:o.number(),cartTotal:o.number(),cartVat:o.number()}),originalAmount:o.number().positive().optional(),actualAmount:o.number().positive().optional(),date:o.number(),deliveryDate:o.coerce.number().optional(),createdAt:o.number().optional(),client:st.required({}),nameOnInvoice:o.string().optional(),clientComment:o.string().optional()}),wr=o.enum(["individual","company"]);o.object({id:o.string(),companyId:o.string(),name:o.string(),urls:o.array(o.string()),logoUrl:o.string(),tenantId:o.string(),paymentType:o.enum(["external","j5"]),allowAnonymousClients:o.boolean(),isVatIncludedInPrice:o.boolean(),clientTypes:o.array(wr),minimumOrder:o.number().optional(),freeDeliveryPrice:o.number().optional(),deliveryPrice:o.number().optional()});const Ae=o.string().min(1),Tr=o.object({type:o.literal("Discount"),storeId:Ae,companyId:Ae,id:Ae,name:o.array(B),active:o.boolean(),variant:o.discriminatedUnion("variantType",[o.object({variantType:o.literal("bundle"),productsId:o.array(o.string()).min(1),requiredQuantity:o.number().positive(),discountPrice:o.number().positive()})]),images:o.array(o.string().nonempty()).optional()}),Ne={VAT:18};function Sr(r){var e,t;return((e=r.discount)==null?void 0:e.type)==="percent"?r.price*(r.discount.value??100)/100:((t=r.discount)==null?void 0:t.type)==="number"?r.price-(r.discount.value??0):0}function Cr(r){var e,t;if(((e=r.discount)==null?void 0:e.type)==="percent"){const n=r.price*r.discount.value/100;return r.price-n}return((t=r.discount)==null?void 0:t.type)==="number"?r.price-r.discount.value:r.price}function Ir({cart:r,discounts:e,store:t}){const{isVatIncludedInPrice:n}=t;let s=r.map(i=>({amount:i.amount,product:{...i.product},originalPrice:i.product.price,finalPrice:i.product.price,finalDiscount:0}));const a=e.filter(i=>i.variant.variantType==="bundle"&&((r==null?void 0:r.reduce((u,m)=>(i.variant.productsId.includes(m.product.id)&&(u+=m.amount),u),0))??0)>=i.variant.requiredQuantity);console.log("activeDiscounts",a),a.forEach(i=>{var l,u;if(i.variant.variantType==="bundle"){const m=r.filter(A=>i.variant.productsId.includes(A.product.id)),x=(m==null?void 0:m.reduce((A,Ue)=>(i.variant.productsId.includes(Ue.product.id)&&(A+=Ue.amount),A),0))??0,Z=Math.floor(x/i.variant.requiredQuantity),w=Cr((l=m[0])==null?void 0:l.product),Ie=Sr((u=m[0])==null?void 0:u.product);console.log("price",w,Ie);const at=Number((i.variant.discountPrice/i.variant.requiredQuantity).toFixed(2))*1;console.log("discountPrice",at);const Le=(w*i.variant.requiredQuantity-i.variant.discountPrice)*Z,ze=x*w,Fe=ze-Le;console.log("totalDiscount",Le),console.log("discountPriceFinal",Fe,ze);const ge=Number((Fe/x).toFixed(2));console.log("averagePrice",ge),s=s.map(A=>i.variant.productsId.includes(A.product.id)?{...A,finalPrice:ge,originalPrice:A.product.price,discountPrice:w,finalDiscount:A.product.price-ge}:A),console.log("averagePrice",ge),console.log("yes",Z,i.variant.requiredQuantity,i.variant.discountPrice),console.log("dis",x,m)}}),console.log("result",s);const c=s.reduce((i,l)=>{const{product:u,amount:m,finalPrice:x,finalDiscount:Z}=l;console.log("isVatIncludedInPrice",n);let w=0;if(u.vat)if(n){const Ie=x*(Ne.VAT/(100+Ne.VAT));w=Number(Ie.toFixed(2)),w=w*m,i.vat+=Number(w.toFixed(2))}else w=x*Ne.VAT/100,w=w*m,i.vat+=Number(w.toFixed(2));return console.log("finalDiscount",Z),i.cost+=m*x,i.discount+=Z&&m*Z,i.finalCost+=m*x+(n?0:w),i.productsCost+=m*x+(n?0:w),i},{discount:0,cost:0,finalCost:0,vat:0,productsCost:0,deliveryPrice:(t==null?void 0:t.deliveryPrice)??0});return c.deliveryPrice&&c.productsCost>=(t.freeDeliveryPrice??0)?c.deliveryPrice=0:c.finalCost+=c.deliveryPrice,console.log("cartDetails",c),{items:s,...c}}const Zr={stores:"STORES",companies:"COMPANIES"},Ar={products:"products",profiles:"profiles",cart:"cart",clients:"clients",orders:"orders",categories:"categories",favorites:"favorites",payments:"payments",settings:"settings",discounts:"discounts"},Nr={systemCollections:Zr,storeCollections:Ar,getPath:({companyId:r,storeId:e,collectionName:t,id:n})=>`${r}/${e}/${t}${n?`/${n}`:""}`,getDocPath:r=>`{companyId}/{storeId}/${r}/{id}`},Or={firestore:Nr};exports.AddressSchema=nt;exports.BaseCategorySchema=$e;exports.CartItemProductSchema=Me;exports.CartSchema=vr;exports.CategorySchema=Ce;exports.CompanySchema=_r;exports.DiscountSchema=Tr;exports.FavoriteProductSchema=br;exports.FirebaseAPI=Or;exports.LocaleSchema=B;exports.LocaleValueSchema=pr;exports.NewProductSchema=gr;exports.OrderSchema=kr;exports.ProductSchema=De;exports.ProfilePaymentTypeSchema=Ve;exports.ProfileSchema=st;exports.TFlattenCategorySchema=yr;exports.createEmptyProfile=xr;exports.getCartCost=Ir;exports.notEmptyTextSchema=T;exports.numericTextSchema=mr;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var b;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const a={};for(const c of s)a[c]=c;return a},r.getValidEnumValues=s=>{const a=r.objectKeys(s).filter(i=>typeof s[s[i]]!="number"),c={};for(const i of a)c[i]=s[i];return r.objectValues(c)},r.objectValues=s=>r.objectKeys(s).map(function(a){return s[a]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const c in s)Object.prototype.hasOwnProperty.call(s,c)&&a.push(c);return a},r.find=(s,a)=>{for(const c of s)if(a(c))return c},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(c=>typeof c=="string"?`'${c}'`:c).join(a)}r.joinValues=n,r.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(b||(b={}));var Oe;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Oe||(Oe={}));const h=b.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),D=r=>{switch(typeof r){case"undefined":return h.undefined;case"string":return h.string;case"number":return isNaN(r)?h.nan:h.number;case"boolean":return h.boolean;case"function":return h.function;case"bigint":return h.bigint;case"symbol":return h.symbol;case"object":return Array.isArray(r)?h.array:r===null?h.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?h.promise:typeof Map<"u"&&r instanceof Map?h.map:typeof Set<"u"&&r instanceof Set?h.set:typeof Date<"u"&&r instanceof Date?h.date:h.object;default:return h.unknown}},d=b.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"]),ot=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Z extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(a){return a.message},n={_errors:[]},s=a=>{for(const c of a.issues)if(c.code==="invalid_union")c.unionErrors.map(s);else if(c.code==="invalid_return_type")s(c.returnTypeError);else if(c.code==="invalid_arguments")s(c.argumentsError);else if(c.path.length===0)n._errors.push(t(c));else{let i=n,l=0;for(;l<c.path.length;){const u=c.path[l];l===c.path.length-1?(i[u]=i[u]||{_errors:[]},i[u]._errors.push(t(c))):i[u]=i[u]||{_errors:[]},i=i[u],l++}}};return s(this),n}static assert(e){if(!(e instanceof Z))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,b.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Z.create=r=>new Z(r);const G=(r,e)=>{let t;switch(r.code){case d.invalid_type:r.received===h.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case d.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,b.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:t=`Unrecognized key(s) in object: ${b.joinValues(r.keys,", ")}`;break;case d.invalid_union:t="Invalid input";break;case d.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${b.joinValues(r.options)}`;break;case d.invalid_enum_value:t=`Invalid enum value. Expected ${b.joinValues(r.options)}, received '${r.received}'`;break;case d.invalid_arguments:t="Invalid function arguments";break;case d.invalid_return_type:t="Invalid function return type";break;case d.invalid_date:t="Invalid date";break;case d.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:b.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case d.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case d.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case d.custom:t="Invalid input";break;case d.invalid_intersection_types:t="Intersection results could not be merged";break;case d.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case d.not_finite:t="Number must be finite";break;default:t=e.defaultError,b.assertNever(r)}return{message:t}};let Je=G;function ct(r){Je=r}function ge(){return Je}const _e=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],c={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let i="";const l=n.filter(u=>!!u).slice().reverse();for(const u of l)i=u(c,{data:e,defaultError:i}).message;return{...s,path:a,message:i}},dt=[];function f(r,e){const t=ge(),n=_e({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===G?void 0:G].filter(s=>!!s)});r.common.issues.push(n)}class S{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return v;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t){const a=await s.key,c=await s.value;n.push({key:a,value:c})}return S.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:a,value:c}=s;if(a.status==="aborted"||c.status==="aborted")return v;a.status==="dirty"&&e.dirty(),c.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof c.value<"u"||s.alwaysSet)&&(n[a.value]=c.value)}return{status:e.value,value:n}}}const v=Object.freeze({status:"aborted"}),Q=r=>({status:"dirty",value:r}),C=r=>({status:"valid",value:r}),Ee=r=>r.status==="aborted",je=r=>r.status==="dirty",q=r=>r.status==="valid",se=r=>typeof Promise<"u"&&r instanceof Promise;function be(r,e,t,n){if(typeof e=="function"?r!==e||!0:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function Ye(r,e,t,n,s){if(typeof e=="function"?r!==e||!0:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}var p;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(p||(p={}));var re,ne;class P{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}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 Fe=(r,e)=>{if(q(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Z(r.common.issues);return this._error=t,this._error}}};function g(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(c,i)=>{var l,u;const{message:m}=r;return c.code==="invalid_enum_value"?{message:m??i.defaultError}:typeof i.data>"u"?{message:(l=m??n)!==null&&l!==void 0?l:i.defaultError}:c.code!=="invalid_type"?{message:i.defaultError}:{message:(u=m??t)!==null&&u!==void 0?u:i.defaultError}},description:s}}class _{get description(){return this._def.description}_getType(e){return D(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:D(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new S,ctx:{common:e.parent.common,data:e.data,parsedType:D(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(se(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const s={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:D(e)},a=this._parseSync({data:e,path:s.path,parent:s});return Fe(s,a)}"~validate"(e){var t,n;const s={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:D(e)};if(!this["~standard"].async)try{const a=this._parseSync({data:e,path:[],parent:s});return q(a)?{value:a.value}:{issues:s.common.issues}}catch(a){!((n=(t=a==null?void 0:a.message)===null||t===void 0?void 0:t.toLowerCase())===null||n===void 0)&&n.includes("encountered")&&(this["~standard"].async=!0),s.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:s}).then(a=>q(a)?{value:a.value}:{issues:s.common.issues})}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:D(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(se(s)?s:Promise.resolve(s));return Fe(n,a)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const c=e(s),i=()=>a.addIssue({code:d.custom,...n(s)});return typeof Promise<"u"&&c instanceof Promise?c.then(l=>l?!0:(i(),!1)):c?!0:(i(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new O({schema:this,typeName:y.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return j.create(this,this._def)}nullable(){return F.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return N.create(this)}promise(){return K.create(this,this._def)}or(e){return ce.create([this,e],this._def)}and(e){return de.create(this,e,this._def)}transform(e){return new O({...g(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new me({...g(this._def),innerType:this,defaultValue:t,typeName:y.ZodDefault})}brand(){return new Re({typeName:y.ZodBranded,type:this,...g(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new pe({...g(this._def),innerType:this,catchValue:t,typeName:y.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ve.create(this,e)}readonly(){return ye.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ut=/^c[^\s-]{8,}$/i,lt=/^[0-9a-z]+$/,ft=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ht=/^[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,mt=/^[a-z0-9_-]{21}$/i,pt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,yt=/^[-+]?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)?)??$/,vt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,gt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ie;const _t=/^(?:(?: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])$/,bt=/^(?:(?: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])$/,xt=/^(([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]))$/,kt=/^(([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])$/,wt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Tt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Qe="((\\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])))",St=new RegExp(`^${Qe}$`);function He(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Ct(r){return new RegExp(`^${He(r)}$`)}function Ge(r){let e=`${Qe}T${He(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Zt(r,e){return!!((e==="v4"||!e)&&_t.test(r)||(e==="v6"||!e)&&xt.test(r))}function It(r,e){if(!pt.test(r))return!1;try{const[t]=r.split("."),n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||!s.typ||!s.alg||e&&s.alg!==e)}catch{return!1}}function At(r,e){return!!((e==="v4"||!e)&&bt.test(r)||(e==="v6"||!e)&&kt.test(r))}class A extends _{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==h.string){const a=this._getOrReturnCtx(e);return f(a,{code:d.invalid_type,expected:h.string,received:a.parsedType}),v}const n=new S;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const c=e.data.length>a.value,i=e.data.length<a.value;(c||i)&&(s=this._getOrReturnCtx(e,s),c?f(s,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):i&&f(s,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")vt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"email",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")Ie||(Ie=new RegExp(gt,"u")),Ie.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"emoji",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")ht.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"uuid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")mt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"nanoid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")ut.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cuid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")lt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cuid2",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")ft.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"ulid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),f(s,{validation:"url",code:d.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"regex",code:d.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),f(s,{code:d.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),f(s,{code:d.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),f(s,{code:d.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Ge(a).test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:d.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?St.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:d.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?Ct(a).test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:d.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?yt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"duration",code:d.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?Zt(e.data,a.version)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"ip",code:d.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?It(e.data,a.alg)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"jwt",code:d.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?At(e.data,a.version)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cidr",code:d.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?wt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"base64",code:d.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?Tt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"base64url",code:d.invalid_string,message:a.message}),n.dirty()):b.assertNever(a);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:d.invalid_string,...p.errToObj(n)})}_addCheck(e){return new A({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...p.errToObj(e)})}url(e){return this._addCheck({kind:"url",...p.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...p.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...p.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...p.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...p.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...p.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...p.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...p.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...p.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...p.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...p.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...p.errToObj(e)})}datetime(e){var t,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:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...p.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,...p.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...p.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...p.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...p.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...p.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...p.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...p.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...p.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...p.errToObj(t)})}nonempty(e){return this.min(1,p.errToObj(e))}trim(){return new A({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new A({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new A({...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 isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}A.create=r=>{var e;return new A({checks:[],typeName:y.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...g(r)})};function Nt(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,a=parseInt(r.toFixed(s).replace(".","")),c=parseInt(e.toFixed(s).replace(".",""));return a%c/Math.pow(10,s)}class V extends _{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==h.number){const a=this._getOrReturnCtx(e);return f(a,{code:d.invalid_type,expected:h.number,received:a.parsedType}),v}let n;const s=new S;for(const a of this._def.checks)a.kind==="int"?b.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:d.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:d.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:d.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Nt(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),f(n,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:d.not_finite,message:a.message}),s.dirty()):b.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,p.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.toString(t))}setLimit(e,t,n,s){return new V({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:p.toString(s)}]})}_addCheck(e){return new V({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:p.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:p.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:p.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:p.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:p.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&b.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}V.create=r=>new V({checks:[],typeName:y.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...g(r)});class L extends _{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==h.bigint)return this._getInvalidInput(e);let n;const s=new S;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:d.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:d.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),f(n,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):b.assertNever(a);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return f(t,{code:d.invalid_type,expected:h.bigint,received:t.parsedType}),v}gte(e,t){return this.setLimit("min",e,!0,p.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.toString(t))}setLimit(e,t,n,s){return new L({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:p.toString(s)}]})}_addCheck(e){return new L({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:p.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}L.create=r=>{var e;return new L({checks:[],typeName:y.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...g(r)})};class ae extends _{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==h.boolean){const n=this._getOrReturnCtx(e);return f(n,{code:d.invalid_type,expected:h.boolean,received:n.parsedType}),v}return C(e.data)}}ae.create=r=>new ae({typeName:y.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...g(r)});class W extends _{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==h.date){const a=this._getOrReturnCtx(e);return f(a,{code:d.invalid_type,expected:h.date,received:a.parsedType}),v}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return f(a,{code:d.invalid_date}),v}const n=new S;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:d.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:d.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):b.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new W({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:p.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:p.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}W.create=r=>new W({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:y.ZodDate,...g(r)});class xe extends _{_parse(e){if(this._getType(e)!==h.symbol){const n=this._getOrReturnCtx(e);return f(n,{code:d.invalid_type,expected:h.symbol,received:n.parsedType}),v}return C(e.data)}}xe.create=r=>new xe({typeName:y.ZodSymbol,...g(r)});class ie extends _{_parse(e){if(this._getType(e)!==h.undefined){const n=this._getOrReturnCtx(e);return f(n,{code:d.invalid_type,expected:h.undefined,received:n.parsedType}),v}return C(e.data)}}ie.create=r=>new ie({typeName:y.ZodUndefined,...g(r)});class oe extends _{_parse(e){if(this._getType(e)!==h.null){const n=this._getOrReturnCtx(e);return f(n,{code:d.invalid_type,expected:h.null,received:n.parsedType}),v}return C(e.data)}}oe.create=r=>new oe({typeName:y.ZodNull,...g(r)});class X extends _{constructor(){super(...arguments),this._any=!0}_parse(e){return C(e.data)}}X.create=r=>new X({typeName:y.ZodAny,...g(r)});class U extends _{constructor(){super(...arguments),this._unknown=!0}_parse(e){return C(e.data)}}U.create=r=>new U({typeName:y.ZodUnknown,...g(r)});class M extends _{_parse(e){const t=this._getOrReturnCtx(e);return f(t,{code:d.invalid_type,expected:h.never,received:t.parsedType}),v}}M.create=r=>new M({typeName:y.ZodNever,...g(r)});class ke extends _{_parse(e){if(this._getType(e)!==h.undefined){const n=this._getOrReturnCtx(e);return f(n,{code:d.invalid_type,expected:h.void,received:n.parsedType}),v}return C(e.data)}}ke.create=r=>new ke({typeName:y.ZodVoid,...g(r)});class N extends _{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==h.array)return f(t,{code:d.invalid_type,expected:h.array,received:t.parsedType}),v;if(s.exactLength!==null){const c=t.data.length>s.exactLength.value,i=t.data.length<s.exactLength.value;(c||i)&&(f(t,{code:c?d.too_big:d.too_small,minimum:i?s.exactLength.value:void 0,maximum:c?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(f(t,{code:d.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(f(t,{code:d.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((c,i)=>s.type._parseAsync(new P(t,c,t.path,i)))).then(c=>S.mergeArray(n,c));const a=[...t.data].map((c,i)=>s.type._parseSync(new P(t,c,t.path,i)));return S.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new N({...this._def,minLength:{value:e,message:p.toString(t)}})}max(e,t){return new N({...this._def,maxLength:{value:e,message:p.toString(t)}})}length(e,t){return new N({...this._def,exactLength:{value:e,message:p.toString(t)}})}nonempty(e){return this.min(1,e)}}N.create=(r,e)=>new N({type:r,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,...g(e)});function Y(r){if(r instanceof k){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=j.create(Y(n))}return new k({...r._def,shape:()=>e})}else return r instanceof N?new N({...r._def,type:Y(r.element)}):r instanceof j?j.create(Y(r.unwrap())):r instanceof F?F.create(Y(r.unwrap())):r instanceof R?R.create(r.items.map(e=>Y(e))):r}class k extends _{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(),t=b.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==h.object){const u=this._getOrReturnCtx(e);return f(u,{code:d.invalid_type,expected:h.object,received:u.parsedType}),v}const{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:c}=this._getCached(),i=[];if(!(this._def.catchall instanceof M&&this._def.unknownKeys==="strip"))for(const u in s.data)c.includes(u)||i.push(u);const l=[];for(const u of c){const m=a[u],x=s.data[u];l.push({key:{status:"valid",value:u},value:m._parse(new P(s,x,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof M){const u=this._def.unknownKeys;if(u==="passthrough")for(const m of i)l.push({key:{status:"valid",value:m},value:{status:"valid",value:s.data[m]}});else if(u==="strict")i.length>0&&(f(s,{code:d.unrecognized_keys,keys:i}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const m of i){const x=s.data[m];l.push({key:{status:"valid",value:m},value:u._parse(new P(s,x,s.path,m)),alwaysSet:m in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const m of l){const x=await m.key,E=await m.value;u.push({key:x,value:E,alwaysSet:m.alwaysSet})}return u}).then(u=>S.mergeObjectSync(n,u)):S.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(e){return p.errToObj,new k({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,a,c,i;const l=(c=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,n).message)!==null&&c!==void 0?c:n.defaultError;return t.code==="unrecognized_keys"?{message:(i=p.errToObj(e).message)!==null&&i!==void 0?i:l}:{message:l}}}:{}})}strip(){return new k({...this._def,unknownKeys:"strip"})}passthrough(){return new k({...this._def,unknownKeys:"passthrough"})}extend(e){return new k({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new k({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:y.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new k({...this._def,catchall:e})}pick(e){const t={};return b.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new k({...this._def,shape:()=>t})}omit(e){const t={};return b.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new k({...this._def,shape:()=>t})}deepPartial(){return Y(this)}partial(e){const t={};return b.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new k({...this._def,shape:()=>t})}required(e){const t={};return b.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof j;)a=a._def.innerType;t[n]=a}}),new k({...this._def,shape:()=>t})}keyof(){return Xe(b.objectKeys(this.shape))}}k.create=(r,e)=>new k({shape:()=>r,unknownKeys:"strip",catchall:M.create(),typeName:y.ZodObject,...g(e)});k.strictCreate=(r,e)=>new k({shape:()=>r,unknownKeys:"strict",catchall:M.create(),typeName:y.ZodObject,...g(e)});k.lazycreate=(r,e)=>new k({shape:r,unknownKeys:"strip",catchall:M.create(),typeName:y.ZodObject,...g(e)});class ce extends _{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(a){for(const i of a)if(i.result.status==="valid")return i.result;for(const i of a)if(i.result.status==="dirty")return t.common.issues.push(...i.ctx.common.issues),i.result;const c=a.map(i=>new Z(i.ctx.common.issues));return f(t,{code:d.invalid_union,unionErrors:c}),v}if(t.common.async)return Promise.all(n.map(async a=>{const c={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:c}),ctx:c}})).then(s);{let a;const c=[];for(const l of n){const u={...t,common:{...t.common,issues:[]},parent:null},m=l._parseSync({data:t.data,path:t.path,parent:u});if(m.status==="valid")return m;m.status==="dirty"&&!a&&(a={result:m,ctx:u}),u.common.issues.length&&c.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const i=c.map(l=>new Z(l));return f(t,{code:d.invalid_union,unionErrors:i}),v}}get options(){return this._def.options}}ce.create=(r,e)=>new ce({options:r,typeName:y.ZodUnion,...g(e)});const $=r=>r instanceof le?$(r.schema):r instanceof O?$(r.innerType()):r instanceof fe?[r.value]:r instanceof z?r.options:r instanceof he?b.objectValues(r.enum):r instanceof me?$(r._def.innerType):r instanceof ie?[void 0]:r instanceof oe?[null]:r instanceof j?[void 0,...$(r.unwrap())]:r instanceof F?[null,...$(r.unwrap())]:r instanceof Re||r instanceof ye?$(r.unwrap()):r instanceof pe?$(r._def.innerType):[];class Se extends _{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.object)return f(t,{code:d.invalid_type,expected:h.object,received:t.parsedType}),v;const n=this.discriminator,s=t.data[n],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(f(t,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),v)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const a of t){const c=$(a.shape[e]);if(!c.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const i of c){if(s.has(i))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);s.set(i,a)}}return new Se({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...g(n)})}}function Pe(r,e){const t=D(r),n=D(e);if(r===e)return{valid:!0,data:r};if(t===h.object&&n===h.object){const s=b.objectKeys(e),a=b.objectKeys(r).filter(i=>s.indexOf(i)!==-1),c={...r,...e};for(const i of a){const l=Pe(r[i],e[i]);if(!l.valid)return{valid:!1};c[i]=l.data}return{valid:!0,data:c}}else if(t===h.array&&n===h.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<r.length;a++){const c=r[a],i=e[a],l=Pe(c,i);if(!l.valid)return{valid:!1};s.push(l.data)}return{valid:!0,data:s}}else return t===h.date&&n===h.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class de extends _{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(a,c)=>{if(Ee(a)||Ee(c))return v;const i=Pe(a.value,c.value);return i.valid?((je(a)||je(c))&&t.dirty(),{status:t.value,value:i.data}):(f(n,{code:d.invalid_intersection_types}),v)};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(([a,c])=>s(a,c)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}de.create=(r,e,t)=>new de({left:r,right:e,typeName:y.ZodIntersection,...g(t)});class R extends _{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.array)return f(n,{code:d.invalid_type,expected:h.array,received:n.parsedType}),v;if(n.data.length<this._def.items.length)return f(n,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&n.data.length>this._def.items.length&&(f(n,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...n.data].map((c,i)=>{const l=this._def.items[i]||this._def.rest;return l?l._parse(new P(n,c,n.path,i)):null}).filter(c=>!!c);return n.common.async?Promise.all(a).then(c=>S.mergeArray(t,c)):S.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new R({...this._def,rest:e})}}R.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new R({items:r,typeName:y.ZodTuple,rest:null,...g(e)})};class ue extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.object)return f(n,{code:d.invalid_type,expected:h.object,received:n.parsedType}),v;const s=[],a=this._def.keyType,c=this._def.valueType;for(const i in n.data)s.push({key:a._parse(new P(n,i,n.path,i)),value:c._parse(new P(n,n.data[i],n.path,i)),alwaysSet:i in n.data});return n.common.async?S.mergeObjectAsync(t,s):S.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof _?new ue({keyType:e,valueType:t,typeName:y.ZodRecord,...g(n)}):new ue({keyType:A.create(),valueType:e,typeName:y.ZodRecord,...g(t)})}}class we extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.map)return f(n,{code:d.invalid_type,expected:h.map,received:n.parsedType}),v;const s=this._def.keyType,a=this._def.valueType,c=[...n.data.entries()].map(([i,l],u)=>({key:s._parse(new P(n,i,n.path,[u,"key"])),value:a._parse(new P(n,l,n.path,[u,"value"]))}));if(n.common.async){const i=new Map;return Promise.resolve().then(async()=>{for(const l of c){const u=await l.key,m=await l.value;if(u.status==="aborted"||m.status==="aborted")return v;(u.status==="dirty"||m.status==="dirty")&&t.dirty(),i.set(u.value,m.value)}return{status:t.value,value:i}})}else{const i=new Map;for(const l of c){const u=l.key,m=l.value;if(u.status==="aborted"||m.status==="aborted")return v;(u.status==="dirty"||m.status==="dirty")&&t.dirty(),i.set(u.value,m.value)}return{status:t.value,value:i}}}}we.create=(r,e,t)=>new we({valueType:e,keyType:r,typeName:y.ZodMap,...g(t)});class J extends _{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.set)return f(n,{code:d.invalid_type,expected:h.set,received:n.parsedType}),v;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(f(n,{code:d.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(f(n,{code:d.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function c(l){const u=new Set;for(const m of l){if(m.status==="aborted")return v;m.status==="dirty"&&t.dirty(),u.add(m.value)}return{status:t.value,value:u}}const i=[...n.data.values()].map((l,u)=>a._parse(new P(n,l,n.path,u)));return n.common.async?Promise.all(i).then(l=>c(l)):c(i)}min(e,t){return new J({...this._def,minSize:{value:e,message:p.toString(t)}})}max(e,t){return new J({...this._def,maxSize:{value:e,message:p.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}J.create=(r,e)=>new J({valueType:r,minSize:null,maxSize:null,typeName:y.ZodSet,...g(e)});class H extends _{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.function)return f(t,{code:d.invalid_type,expected:h.function,received:t.parsedType}),v;function n(i,l){return _e({data:i,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ge(),G].filter(u=>!!u),issueData:{code:d.invalid_arguments,argumentsError:l}})}function s(i,l){return _e({data:i,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ge(),G].filter(u=>!!u),issueData:{code:d.invalid_return_type,returnTypeError:l}})}const a={errorMap:t.common.contextualErrorMap},c=t.data;if(this._def.returns instanceof K){const i=this;return C(async function(...l){const u=new Z([]),m=await i._def.args.parseAsync(l,a).catch(w=>{throw u.addIssue(n(l,w)),u}),x=await Reflect.apply(c,this,m);return await i._def.returns._def.type.parseAsync(x,a).catch(w=>{throw u.addIssue(s(x,w)),u})})}else{const i=this;return C(function(...l){const u=i._def.args.safeParse(l,a);if(!u.success)throw new Z([n(l,u.error)]);const m=Reflect.apply(c,this,u.data),x=i._def.returns.safeParse(m,a);if(!x.success)throw new Z([s(m,x.error)]);return x.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new H({...this._def,args:R.create(e).rest(U.create())})}returns(e){return new H({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new H({args:e||R.create([]).rest(U.create()),returns:t||U.create(),typeName:y.ZodFunction,...g(n)})}}class le extends _{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}le.create=(r,e)=>new le({getter:r,typeName:y.ZodLazy,...g(e)});class fe extends _{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return f(t,{received:t.data,code:d.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}}fe.create=(r,e)=>new fe({value:r,typeName:y.ZodLiteral,...g(e)});function Xe(r,e){return new z({values:r,typeName:y.ZodEnum,...g(e)})}class z extends _{constructor(){super(...arguments),re.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return f(t,{expected:b.joinValues(n),received:t.parsedType,code:d.invalid_type}),v}if(be(this,re)||Ye(this,re,new Set(this._def.values)),!be(this,re).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return f(t,{received:t.data,code:d.invalid_enum_value,options:n}),v}return C(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return z.create(e,{...this._def,...t})}exclude(e,t=this._def){return z.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}re=new WeakMap;z.create=Xe;class he extends _{constructor(){super(...arguments),ne.set(this,void 0)}_parse(e){const t=b.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==h.string&&n.parsedType!==h.number){const s=b.objectValues(t);return f(n,{expected:b.joinValues(s),received:n.parsedType,code:d.invalid_type}),v}if(be(this,ne)||Ye(this,ne,new Set(b.getValidEnumValues(this._def.values))),!be(this,ne).has(e.data)){const s=b.objectValues(t);return f(n,{received:n.data,code:d.invalid_enum_value,options:s}),v}return C(e.data)}get enum(){return this._def.values}}ne=new WeakMap;he.create=(r,e)=>new he({values:r,typeName:y.ZodNativeEnum,...g(e)});class K extends _{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.promise&&t.common.async===!1)return f(t,{code:d.invalid_type,expected:h.promise,received:t.parsedType}),v;const n=t.parsedType===h.promise?t.data:Promise.resolve(t.data);return C(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}K.create=(r,e)=>new K({type:r,typeName:y.ZodPromise,...g(e)});class O extends _{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:c=>{f(n,c),c.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const c=s.transform(n.data,a);if(n.common.async)return Promise.resolve(c).then(async i=>{if(t.value==="aborted")return v;const l=await this._def.schema._parseAsync({data:i,path:n.path,parent:n});return l.status==="aborted"?v:l.status==="dirty"||t.value==="dirty"?Q(l.value):l});{if(t.value==="aborted")return v;const i=this._def.schema._parseSync({data:c,path:n.path,parent:n});return i.status==="aborted"?v:i.status==="dirty"||t.value==="dirty"?Q(i.value):i}}if(s.type==="refinement"){const c=i=>{const l=s.refinement(i,a);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?v:(i.status==="dirty"&&t.dirty(),c(i.value),{status:t.value,value:i.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>i.status==="aborted"?v:(i.status==="dirty"&&t.dirty(),c(i.value).then(()=>({status:t.value,value:i.value}))))}if(s.type==="transform")if(n.common.async===!1){const c=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!q(c))return c;const i=s.transform(c.value,a);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:i}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(c=>q(c)?Promise.resolve(s.transform(c.value,a)).then(i=>({status:t.value,value:i})):c);b.assertNever(s)}}O.create=(r,e,t)=>new O({schema:r,typeName:y.ZodEffects,effect:e,...g(t)});O.createWithPreprocess=(r,e,t)=>new O({schema:e,effect:{type:"preprocess",transform:r},typeName:y.ZodEffects,...g(t)});class j extends _{_parse(e){return this._getType(e)===h.undefined?C(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}j.create=(r,e)=>new j({innerType:r,typeName:y.ZodOptional,...g(e)});class F extends _{_parse(e){return this._getType(e)===h.null?C(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}F.create=(r,e)=>new F({innerType:r,typeName:y.ZodNullable,...g(e)});class me extends _{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===h.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}me.create=(r,e)=>new me({innerType:r,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...g(e)});class pe extends _{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return se(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Z(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Z(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}pe.create=(r,e)=>new pe({innerType:r,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...g(e)});class Te extends _{_parse(e){if(this._getType(e)!==h.nan){const n=this._getOrReturnCtx(e);return f(n,{code:d.invalid_type,expected:h.nan,received:n.parsedType}),v}return{status:"valid",value:e.data}}}Te.create=r=>new Te({typeName:y.ZodNaN,...g(r)});const Ot=Symbol("zod_brand");class Re extends _{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class ve extends _{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?v:a.status==="dirty"?(t.dirty(),Q(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?v:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new ve({in:e,out:t,typeName:y.ZodPipeline})}}class ye extends _{_parse(e){const t=this._def.innerType._parse(e),n=s=>(q(s)&&(s.value=Object.freeze(s.value)),s);return se(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}}ye.create=(r,e)=>new ye({innerType:r,typeName:y.ZodReadonly,...g(e)});function Ue(r,e){const t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function Ke(r,e={},t){return r?X.create().superRefine((n,s)=>{var a,c;const i=r(n);if(i instanceof Promise)return i.then(l=>{var u,m;if(!l){const x=Ue(e,n),E=(m=(u=x.fatal)!==null&&u!==void 0?u:t)!==null&&m!==void 0?m:!0;s.addIssue({code:"custom",...x,fatal:E})}});if(!i){const l=Ue(e,n),u=(c=(a=l.fatal)!==null&&a!==void 0?a:t)!==null&&c!==void 0?c:!0;s.addIssue({code:"custom",...l,fatal:u})}}):X.create()}const Et={object:k.lazycreate};var y;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(y||(y={}));const jt=(r,e={message:`Input not instance of ${r.name}`})=>Ke(t=>t instanceof r,e),et=A.create,tt=V.create,Pt=Te.create,Rt=L.create,rt=ae.create,$t=W.create,Dt=xe.create,Mt=ie.create,Vt=oe.create,Lt=X.create,zt=U.create,Ft=M.create,Ut=ke.create,Bt=N.create,qt=k.create,Wt=k.strictCreate,Jt=ce.create,Yt=Se.create,Qt=de.create,Ht=R.create,Gt=ue.create,Xt=we.create,Kt=J.create,er=H.create,tr=le.create,rr=fe.create,nr=z.create,sr=he.create,ar=K.create,Be=O.create,ir=j.create,or=F.create,cr=O.createWithPreprocess,dr=ve.create,ur=()=>et().optional(),lr=()=>tt().optional(),fr=()=>rt().optional(),hr={string:r=>A.create({...r,coerce:!0}),number:r=>V.create({...r,coerce:!0}),boolean:r=>ae.create({...r,coerce:!0}),bigint:r=>L.create({...r,coerce:!0}),date:r=>W.create({...r,coerce:!0})},mr=v;var o=Object.freeze({__proto__:null,defaultErrorMap:G,setErrorMap:ct,getErrorMap:ge,makeIssue:_e,EMPTY_PATH:dt,addIssueToContext:f,ParseStatus:S,INVALID:v,DIRTY:Q,OK:C,isAborted:Ee,isDirty:je,isValid:q,isAsync:se,get util(){return b},get objectUtil(){return Oe},ZodParsedType:h,getParsedType:D,ZodType:_,datetimeRegex:Ge,ZodString:A,ZodNumber:V,ZodBigInt:L,ZodBoolean:ae,ZodDate:W,ZodSymbol:xe,ZodUndefined:ie,ZodNull:oe,ZodAny:X,ZodUnknown:U,ZodNever:M,ZodVoid:ke,ZodArray:N,ZodObject:k,ZodUnion:ce,ZodDiscriminatedUnion:Se,ZodIntersection:de,ZodTuple:R,ZodRecord:ue,ZodMap:we,ZodSet:J,ZodFunction:H,ZodLazy:le,ZodLiteral:fe,ZodEnum:z,ZodNativeEnum:he,ZodPromise:K,ZodEffects:O,ZodTransformer:O,ZodOptional:j,ZodNullable:F,ZodDefault:me,ZodCatch:pe,ZodNaN:Te,BRAND:Ot,ZodBranded:Re,ZodPipeline:ve,ZodReadonly:ye,custom:Ke,Schema:_,ZodSchema:_,late:Et,get ZodFirstPartyTypeKind(){return y},coerce:hr,any:Lt,array:Bt,bigint:Rt,boolean:rt,date:$t,discriminatedUnion:Yt,effect:Be,enum:nr,function:er,instanceof:jt,intersection:Qt,lazy:tr,literal:rr,map:Xt,nan:Pt,nativeEnum:sr,never:Ft,null:Vt,nullable:or,number:tt,object:qt,oboolean:fr,onumber:lr,optional:ir,ostring:ur,pipeline:dr,preprocess:cr,promise:ar,record:Gt,set:Kt,strictObject:Wt,string:et,symbol:Dt,transformer:Be,tuple:Ht,undefined:Mt,union:Jt,unknown:zt,void:Ut,NEVER:mr,ZodIssueCode:d,quotelessJson:ot,ZodError:Z});const T=o.string().min(1,{message:"שדה חובה"}),pr=o.string().regex(/^\d+$/,"Must be a numeric string"),nt=o.object({country:T,city:T,street:T,streetNumber:T,floor:T,apartmentEnterNumber:T,apartmentNumber:T}),B=o.object({lang:o.enum(["he"]),value:o.string()}),yr=o.array(B),$e=o.object({id:o.string().min(1),companyId:o.string().min(1),storeId:o.string().min(1),parentId:o.string().nullish(),tag:o.string().optional(),locales:o.array(B),depth:o.number()}),Ce=$e.extend({children:o.lazy(()=>Ce.array())}),vr=$e.extend({index:o.number(),depth:o.number(),collapsed:o.boolean().optional(),children:o.array(Ce)}),te=o.string().min(1),De=o.object({type:o.literal("Product"),storeId:te,companyId:te,id:te,objectID:te,sku:te,name:o.array(B),description:o.array(B),isPublished:o.boolean(),vat:o.boolean(),priceType:o.object({type:o.enum(["unit","kg","gram","liter","ml"]),value:o.number()}),price:o.number().positive(),purchasePrice:o.number().optional(),profitPercentage:o.number().optional(),currency:o.literal("ILS"),discount:o.object({type:o.enum(["number","percent","none"]),value:o.number()}),isDiscountable:o.boolean({description:"included in store discounts"}).optional(),weight:o.object({value:o.number(),unit:o.enum(["kg","gram","none"])}),volume:o.object({value:o.number(),unit:o.enum(["liter","ml","none"])}),images:o.array(o.object({url:o.string().url(),id:o.string()})),manufacturer:o.string(),brand:o.string(),importer:o.string(),supplier:o.string(),ingredients:o.array(B),created_at:o.number(),updated_at:o.number(),categoryIds:o.array(o.string().nonempty()),categoryList:o.array(Ce),categories:o.object({lvl0:o.array(o.string()),lvl1:o.array(o.string()),lvl2:o.array(o.string()),lvl3:o.array(o.string()),lvl4:o.array(o.string())}),categoryNames:o.array(o.string())}),gr=De.extend({image:o.instanceof(File).optional()}),Me=o.object({product:De,originalPrice:o.number().optional(),finalPrice:o.number().optional(),finalDiscount:o.number().optional(),amount:o.number().int().positive({message:"Quantity must be a positive integer."})}),_r=o.object({type:o.literal("Cart"),id:o.string().uuid(),companyId:o.string().uuid(),storeId:o.string().uuid(),userId:o.string().uuid(),status:o.enum(["active","draft","completed"]),items:o.array(Me)}),br=o.object({id:o.string(),name:o.string(),websiteDomains:o.array(o.string())}),xr=o.object({type:o.literal("FavoriteProduct"),id:o.string().uuid(),companyId:o.string().uuid(),storeId:o.string().uuid(),userId:o.string().uuid(),productId:o.string().uuid()}),Ve=o.enum(["default","delayed"]),st=o.object({type:o.literal("Profile"),id:T,companyId:T,storeId:T,tenantId:T,clientType:o.enum(["user","company"]),companyName:o.string().optional(),displayName:T,email:o.string().email(),phoneNumber:T.optional(),address:nt.optional(),isAnonymous:o.boolean(),createdDate:o.number(),lastActivityDate:o.number(),paymentType:Ve});function kr(){return{type:"Profile",id:"",companyId:"",storeId:"",tenantId:"",clientType:"user",displayName:"",email:"",phoneNumber:"",address:{country:"",city:"",street:"",streetNumber:"",floor:"",apartmentEnterNumber:"",apartmentNumber:""},createdDate:0,lastActivityDate:0,isAnonymous:!0,paymentType:Ve.Values.default}}const wr=o.object({type:o.literal("Order"),id:T,companyId:T,storeId:T,userId:T,status:o.enum(["draft","pending","processing","in_delivery","delivered","cancelled","completed","refunded"]),paymentStatus:o.enum(["pending","pending_j5","external","completed","failed","refunded"]),cart:o.object({id:o.string(),items:o.array(Me),cartDiscount:o.number(),cartTotal:o.number(),cartVat:o.number()}),originalAmount:o.number().positive().optional(),actualAmount:o.number().positive().optional(),date:o.number(),deliveryDate:o.coerce.number().optional(),createdAt:o.number().optional(),client:st.required({}),nameOnInvoice:o.string().optional(),clientComment:o.string().optional()}),Tr=o.enum(["individual","company"]);o.object({id:o.string(),companyId:o.string(),name:o.string(),urls:o.array(o.string()),logoUrl:o.string(),tenantId:o.string(),paymentType:o.enum(["external","j5"]),allowAnonymousClients:o.boolean(),isVatIncludedInPrice:o.boolean(),clientTypes:o.array(Tr),minimumOrder:o.number().optional(),freeDeliveryPrice:o.number().optional(),deliveryPrice:o.number().optional()});const Ae=o.string().min(1),Sr=o.object({type:o.literal("Discount"),storeId:Ae,companyId:Ae,id:Ae,name:o.array(B),active:o.boolean(),variant:o.discriminatedUnion("variantType",[o.object({variantType:o.literal("bundle"),productsId:o.array(o.string()).min(1),requiredQuantity:o.number().positive(),discountPrice:o.number().positive()})]),images:o.array(o.string().nonempty()).optional()}),Ne={VAT:18};function qe(r){var e,t;return((e=r.discount)==null?void 0:e.type)==="percent"?r.price*(r.discount.value??100)/100:((t=r.discount)==null?void 0:t.type)==="number"?r.discount.value??0:0}function We(r){var e,t;if(((e=r.discount)==null?void 0:e.type)==="percent"){const n=r.price*r.discount.value/100;return r.price-n}return((t=r.discount)==null?void 0:t.type)==="number"?r.price-r.discount.value:r.price}function Cr({cart:r,discounts:e,store:t}){const{isVatIncludedInPrice:n}=t;let s=r.map(i=>({amount:i.amount,product:{...i.product},originalPrice:i.product.price,finalPrice:We(i.product),finalDiscount:qe(i.product)}));const a=e.filter(i=>i.variant.variantType==="bundle"&&((r==null?void 0:r.reduce((u,m)=>(i.variant.productsId.includes(m.product.id)&&(u+=m.amount),u),0))??0)>=i.variant.requiredQuantity);console.log("activeDiscounts",a),a.forEach(i=>{var l,u;if(i.variant.variantType==="bundle"){const m=r.filter(I=>i.variant.productsId.includes(I.product.id)),x=(m==null?void 0:m.reduce((I,ze)=>(i.variant.productsId.includes(ze.product.id)&&(I+=ze.amount),I),0))??0,E=Math.floor(x/i.variant.requiredQuantity),w=We((l=m[0])==null?void 0:l.product),ee=qe((u=m[0])==null?void 0:u.product);console.log("price",w,ee);const Ze=Number((i.variant.discountPrice/i.variant.requiredQuantity).toFixed(2))*1;console.log("discountPrice",Ze);const at=(w*i.variant.requiredQuantity-i.variant.discountPrice)*E,it=x*w-at,Le=Number((it/x).toFixed(2));s=s.map(I=>i.variant.productsId.includes(I.product.id)?{...I,finalPrice:Le,originalPrice:I.product.price,discountPrice:w,finalDiscount:I.finalDiscount+(I.product.price-Le)}:I)}});const c=s.reduce((i,l)=>{const{product:u,amount:m,finalPrice:x,finalDiscount:E}=l;let w=0;if(u.vat){let ee=0;if(n){const Ze=x*(Ne.VAT/(100+Ne.VAT));w=Number(Ze.toFixed(2)),w=w*m,ee=Number(w.toFixed(2))}else w=x*Ne.VAT/100,w=w*m,ee=Number(w.toFixed(2));i.vat=Number((i.vat+ee).toFixed(2))}return i.cost+=m*x,i.discount+=E&&m*E,i.finalCost+=m*x+(n?0:w),i.productsCost+=m*x+(n?0:w),i},{discount:0,cost:0,finalCost:0,vat:0,productsCost:0,deliveryPrice:(t==null?void 0:t.deliveryPrice)??0});return c.deliveryPrice&&c.productsCost>=(t.freeDeliveryPrice??0)?c.deliveryPrice=0:c.finalCost+=c.deliveryPrice,console.log("cartDetails",c),{items:s,...c}}const Zr={stores:"STORES",companies:"COMPANIES"},Ir={products:"products",profiles:"profiles",cart:"cart",clients:"clients",orders:"orders",categories:"categories",favorites:"favorites",payments:"payments",settings:"settings",discounts:"discounts"},Ar={systemCollections:Zr,storeCollections:Ir,getPath:({companyId:r,storeId:e,collectionName:t,id:n})=>`${r}/${e}/${t}${n?`/${n}`:""}`,getDocPath:r=>`{companyId}/{storeId}/${r}/{id}`},Nr={firestore:Ar};exports.AddressSchema=nt;exports.BaseCategorySchema=$e;exports.CartItemProductSchema=Me;exports.CartSchema=_r;exports.CategorySchema=Ce;exports.CompanySchema=br;exports.DiscountSchema=Sr;exports.FavoriteProductSchema=xr;exports.FirebaseAPI=Nr;exports.LocaleSchema=B;exports.LocaleValueSchema=yr;exports.NewProductSchema=gr;exports.OrderSchema=wr;exports.ProductSchema=De;exports.ProfilePaymentTypeSchema=Ve;exports.ProfileSchema=st;exports.TFlattenCategorySchema=vr;exports.createEmptyProfile=kr;exports.getCartCost=Cr;exports.notEmptyTextSchema=T;exports.numericTextSchema=pr;
|
|
2
2
|
//# sourceMappingURL=core.cjs.js.map
|