@jsdev_ninja/core 0.13.13 → 0.13.14
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 +253 -220
- 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/entities/DeliveryNote.d.ts +134 -0
- package/dist/entities/DeliveryNote.d.ts.map +1 -0
- package/dist/entities/DeliveryNote.js +34 -0
- package/dist/entities/index.d.ts +1 -0
- package/dist/entities/index.d.ts.map +1 -1
- package/dist/entities/index.js +1 -0
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/lib/entities/DeliveryNote.ts +42 -0
- package/lib/entities/index.ts +1 -0
- package/package.json +1 -1
package/dist/core.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(v,_){typeof exports=="object"&&typeof module<"u"?_(exports):typeof define=="function"&&define.amd?define(["exports"],_):(v=typeof globalThis<"u"?globalThis:v||self,_(v.core={}))})(this,function(v){"use strict";var Dn=Object.defineProperty;var Mn=(v,_,F)=>_ in v?Dn(v,_,{enumerable:!0,configurable:!0,writable:!0,value:F}):v[_]=F;var dt=(v,_,F)=>Mn(v,typeof _!="symbol"?_+"":_,F);var _;(function(n){n.assertEqual=s=>s;function e(s){}n.assertIs=e;function t(s){throw new Error}n.assertNever=t,n.arrayToEnum=s=>{const a={};for(const o of s)a[o]=o;return a},n.getValidEnumValues=s=>{const a=n.objectKeys(s).filter(c=>typeof s[s[c]]!="number"),o={};for(const c of a)o[c]=s[c];return n.objectValues(o)},n.objectValues=s=>n.objectKeys(s).map(function(a){return s[a]}),n.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&a.push(o);return a},n.find=(s,a)=>{for(const o of s)if(a(o))return o},n.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,a=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}n.joinValues=r,n.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(_||(_={}));var F;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(F||(F={}));const h=_.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),M=n=>{switch(typeof n){case"undefined":return h.undefined;case"string":return h.string;case"number":return isNaN(n)?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(n)?h.array:n===null?h.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?h.promise:typeof Map<"u"&&n instanceof Map?h.map:typeof Set<"u"&&n instanceof Set?h.set:typeof Date<"u"&&n instanceof Date?h.date:h.object;default:return h.unknown}},u=_.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),ut=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class I extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};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},r={_errors:[]},s=a=>{for(const o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(t(o));else{let c=r,d=0;for(;d<o.path.length;){const l=o.path[d];d===o.path.length-1?(c[l]=c[l]||{_errors:[]},c[l]._errors.push(t(o))):c[l]=c[l]||{_errors:[]},c=c[l],d++}}};return s(this),r}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,_.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];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))):r.push(e(s));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}I.create=n=>new I(n);const Y=(n,e)=>{let t;switch(n.code){case u.invalid_type:n.received===h.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case u.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,_.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:t=`Unrecognized key(s) in object: ${_.joinValues(n.keys,", ")}`;break;case u.invalid_union:t="Invalid input";break;case u.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${_.joinValues(n.options)}`;break;case u.invalid_enum_value:t=`Invalid enum value. Expected ${_.joinValues(n.options)}, received '${n.received}'`;break;case u.invalid_arguments:t="Invalid function arguments";break;case u.invalid_return_type:t="Invalid function return type";break;case u.invalid_date:t="Invalid date";break;case u.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:_.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case u.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case u.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case u.custom:t="Invalid input";break;case u.invalid_intersection_types:t="Intersection results could not be merged";break;case u.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case u.not_finite:t="Number must be finite";break;default:t=e.defaultError,_.assertNever(n)}return{message:t}};let Le=Y;function lt(n){Le=n}function _e(){return Le}const be=n=>{const{data:e,path:t,errorMaps:r,issueData:s}=n,a=[...t,...s.path||[]],o={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let c="";const d=r.filter(l=>!!l).slice().reverse();for(const l of d)c=l(o,{data:e,defaultError:c}).message;return{...s,path:a,message:c}},ft=[];function f(n,e){const t=_e(),r=be({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===Y?void 0:Y].filter(s=>!!s)});n.common.issues.push(r)}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 r=[];for(const s of t){if(s.status==="aborted")return g;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const s of t){const a=await s.key,o=await s.value;r.push({key:a,value:o})}return S.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const s of t){const{key:a,value:o}=s;if(a.status==="aborted"||o.status==="aborted")return g;a.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[a.value]=o.value)}return{status:e.value,value:r}}}const g=Object.freeze({status:"aborted"}),H=n=>({status:"dirty",value:n}),C=n=>({status:"valid",value:n}),Ae=n=>n.status==="aborted",Ne=n=>n.status==="dirty",W=n=>n.status==="valid",ne=n=>typeof Promise<"u"&&n instanceof Promise;function xe(n,e,t,r){if(typeof e=="function"?n!==e||!0:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(n)}function Ue(n,e,t,r,s){if(typeof e=="function"?n!==e||!0:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(n,t),t}typeof SuppressedError=="function"&&SuppressedError;var p;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(p||(p={}));var re,se;class E{constructor(e,t,r,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,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=(n,e)=>{if(W(e))return{success:!0,data:e.value};if(!n.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(n.common.issues);return this._error=t,this._error}}};function b(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:s}=n;if(e&&(t||r))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:(o,c)=>{var d,l;const{message:m}=n;return o.code==="invalid_enum_value"?{message:m??c.defaultError}:typeof c.data>"u"?{message:(d=m??r)!==null&&d!==void 0?d:c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:(l=m??t)!==null&&l!==void 0?l:c.defaultError}},description:s}}class x{get description(){return this._def.description}_getType(e){return M(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:M(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:M(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 r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const s={common:{issues:[],async:(r=t==null?void 0:t.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:M(e)},a=this._parseSync({data:e,path:s.path,parent:s});return Be(s,a)}"~validate"(e){var t,r;const s={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:M(e)};if(!this["~standard"].async)try{const a=this._parseSync({data:e,path:[],parent:s});return W(a)?{value:a.value}:{issues:s.common.issues}}catch(a){!((r=(t=a==null?void 0:a.message)===null||t===void 0?void 0:t.toLowerCase())===null||r===void 0)&&r.includes("encountered")&&(this["~standard"].async=!0),s.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:s}).then(a=>W(a)?{value:a.value}:{issues:s.common.issues})}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:M(e)},s=this._parse({data:e,path:r.path,parent:r}),a=await(ne(s)?s:Promise.resolve(s));return Be(r,a)}refine(e,t){const r=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const o=e(s),c=()=>a.addIssue({code:u.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(d=>d?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(e,t){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof t=="function"?t(r,s):t),!1))}_refinement(e){return new j({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 R.create(this,this._def)}nullable(){return B.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return O.create(this)}promise(){return ee.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 j({...b(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new me({...b(this._def),innerType:this,defaultValue:t,typeName:y.ZodDefault})}brand(){return new je({typeName:y.ZodBranded,type:this,...b(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new pe({...b(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 ge.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ht=/^c[^\s-]{8,}$/i,mt=/^[0-9a-z]+$/,pt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,yt=/^[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,gt=/^[a-z0-9_-]{21}$/i,vt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,_t=/^[-+]?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)?)??$/,bt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,xt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ze;const kt=/^(?:(?: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])$/,wt=/^(?:(?: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])$/,Tt=/^(([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]))$/,St=/^(([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])$/,Ct=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,It=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,We="((\\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])))",At=new RegExp(`^${We}$`);function qe(n){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Nt(n){return new RegExp(`^${qe(n)}$`)}function Qe(n){let e=`${We}T${qe(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Zt(n,e){return!!((e==="v4"||!e)&&kt.test(n)||(e==="v6"||!e)&&Tt.test(n))}function Ot(n,e){if(!vt.test(n))return!1;try{const[t]=n.split("."),r=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||!s.typ||!s.alg||e&&s.alg!==e)}catch{return!1}}function jt(n,e){return!!((e==="v4"||!e)&&wt.test(n)||(e==="v6"||!e)&&St.test(n))}class Z extends x{_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:u.invalid_type,expected:h.string,received:a.parsedType}),g}const r=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:u.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:u.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){const o=e.data.length>a.value,c=e.data.length<a.value;(o||c)&&(s=this._getOrReturnCtx(e,s),o?f(s,{code:u.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):c&&f(s,{code:u.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")bt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"email",code:u.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")Ze||(Ze=new RegExp(xt,"u")),Ze.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"emoji",code:u.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")yt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"uuid",code:u.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")gt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"nanoid",code:u.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")ht.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cuid",code:u.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")mt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cuid2",code:u.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")pt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"ulid",code:u.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),f(s,{validation:"url",code:u.invalid_string,message:a.message}),r.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"regex",code:u.invalid_string,message:a.message}),r.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:u.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),r.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:u.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),f(s,{code:u.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?Qe(a).test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:u.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?At.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:u.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?Nt(a).test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:u.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?_t.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"duration",code:u.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?Zt(e.data,a.version)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"ip",code:u.invalid_string,message:a.message}),r.dirty()):a.kind==="jwt"?Ot(e.data,a.alg)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"jwt",code:u.invalid_string,message:a.message}),r.dirty()):a.kind==="cidr"?jt(e.data,a.version)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cidr",code:u.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?Ct.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"base64",code:u.invalid_string,message:a.message}),r.dirty()):a.kind==="base64url"?It.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"base64url",code:u.invalid_string,message:a.message}),r.dirty()):_.assertNever(a);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(s=>e.test(s),{validation:t,code:u.invalid_string,...p.errToObj(r)})}_addCheck(e){return new Z({...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,r;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:(r=e==null?void 0:e.local)!==null&&r!==void 0?r:!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 Z({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Z({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Z({...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}}Z.create=n=>{var e;return new Z({checks:[],typeName:y.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...b(n)})};function Et(n,e){const t=(n.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=t>r?t:r,a=parseInt(n.toFixed(s).replace(".","")),o=parseInt(e.toFixed(s).replace(".",""));return a%o/Math.pow(10,s)}class z extends x{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:u.invalid_type,expected:h.number,received:a.parsedType}),g}let r;const s=new S;for(const a of this._def.checks)a.kind==="int"?_.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:u.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:u.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)&&(r=this._getOrReturnCtx(e,r),f(r,{code:u.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Et(e.data,a.value)!==0&&(r=this._getOrReturnCtx(e,r),f(r,{code:u.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:u.not_finite,message:a.message}),s.dirty()):_.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,r,s){return new z({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:p.toString(s)}]})}_addCheck(e){return new z({...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"&&_.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}z.create=n=>new z({checks:[],typeName:y.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...b(n)});class L extends x{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 r;const s=new S;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:u.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)&&(r=this._getOrReturnCtx(e,r),f(r,{code:u.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),f(r,{code:u.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):_.assertNever(a);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return f(t,{code:u.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,r,s){return new L({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,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=n=>{var e;return new L({checks:[],typeName:y.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...b(n)})};class ae extends x{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==h.boolean){const r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:h.boolean,received:r.parsedType}),g}return C(e.data)}}ae.create=n=>new ae({typeName:y.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...b(n)});class q extends x{_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:u.invalid_type,expected:h.date,received:a.parsedType}),g}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return f(a,{code:u.invalid_date}),g}const r=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:u.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:u.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):_.assertNever(a);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new q({...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}}q.create=n=>new q({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:y.ZodDate,...b(n)});class ke extends x{_parse(e){if(this._getType(e)!==h.symbol){const r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:h.symbol,received:r.parsedType}),g}return C(e.data)}}ke.create=n=>new ke({typeName:y.ZodSymbol,...b(n)});class ie extends x{_parse(e){if(this._getType(e)!==h.undefined){const r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:h.undefined,received:r.parsedType}),g}return C(e.data)}}ie.create=n=>new ie({typeName:y.ZodUndefined,...b(n)});class oe extends x{_parse(e){if(this._getType(e)!==h.null){const r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:h.null,received:r.parsedType}),g}return C(e.data)}}oe.create=n=>new oe({typeName:y.ZodNull,...b(n)});class G extends x{constructor(){super(...arguments),this._any=!0}_parse(e){return C(e.data)}}G.create=n=>new G({typeName:y.ZodAny,...b(n)});class Q extends x{constructor(){super(...arguments),this._unknown=!0}_parse(e){return C(e.data)}}Q.create=n=>new Q({typeName:y.ZodUnknown,...b(n)});class $ extends x{_parse(e){const t=this._getOrReturnCtx(e);return f(t,{code:u.invalid_type,expected:h.never,received:t.parsedType}),g}}$.create=n=>new $({typeName:y.ZodNever,...b(n)});class we extends x{_parse(e){if(this._getType(e)!==h.undefined){const r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:h.void,received:r.parsedType}),g}return C(e.data)}}we.create=n=>new we({typeName:y.ZodVoid,...b(n)});class O extends x{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),s=this._def;if(t.parsedType!==h.array)return f(t,{code:u.invalid_type,expected:h.array,received:t.parsedType}),g;if(s.exactLength!==null){const o=t.data.length>s.exactLength.value,c=t.data.length<s.exactLength.value;(o||c)&&(f(t,{code:o?u.too_big:u.too_small,minimum:c?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(f(t,{code:u.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(f(t,{code:u.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((o,c)=>s.type._parseAsync(new E(t,o,t.path,c)))).then(o=>S.mergeArray(r,o));const a=[...t.data].map((o,c)=>s.type._parseSync(new E(t,o,t.path,c)));return S.mergeArray(r,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=(n,e)=>new O({type:n,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,...b(e)});function X(n){if(n instanceof w){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=R.create(X(r))}return new w({...n._def,shape:()=>e})}else return n instanceof O?new O({...n._def,type:X(n.element)}):n instanceof R?R.create(X(n.unwrap())):n instanceof B?B.create(X(n.unwrap())):n instanceof P?P.create(n.items.map(e=>X(e))):n}class w extends x{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=_.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==h.object){const l=this._getOrReturnCtx(e);return f(l,{code:u.invalid_type,expected:h.object,received:l.parsedType}),g}const{status:r,ctx:s}=this._processInputParams(e),{shape:a,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof $&&this._def.unknownKeys==="strip"))for(const l in s.data)o.includes(l)||c.push(l);const d=[];for(const l of o){const m=a[l],k=s.data[l];d.push({key:{status:"valid",value:l},value:m._parse(new E(s,k,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof $){const l=this._def.unknownKeys;if(l==="passthrough")for(const m of c)d.push({key:{status:"valid",value:m},value:{status:"valid",value:s.data[m]}});else if(l==="strict")c.length>0&&(f(s,{code:u.unrecognized_keys,keys:c}),r.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const m of c){const k=s.data[m];d.push({key:{status:"valid",value:m},value:l._parse(new E(s,k,s.path,m)),alwaysSet:m in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const l=[];for(const m of d){const k=await m.key,T=await m.value;l.push({key:k,value:T,alwaysSet:m.alwaysSet})}return l}).then(l=>S.mergeObjectSync(r,l)):S.mergeObjectSync(r,d)}get shape(){return this._def.shape()}strict(e){return p.errToObj,new w({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var s,a,o,c;const d=(o=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,r).message)!==null&&o!==void 0?o:r.defaultError;return t.code==="unrecognized_keys"?{message:(c=p.errToObj(e).message)!==null&&c!==void 0?c:d}:{message:d}}}:{}})}strip(){return new w({...this._def,unknownKeys:"strip"})}passthrough(){return new w({...this._def,unknownKeys:"passthrough"})}extend(e){return new w({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new w({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 w({...this._def,catchall:e})}pick(e){const t={};return _.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new w({...this._def,shape:()=>t})}omit(e){const t={};return _.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new w({...this._def,shape:()=>t})}deepPartial(){return X(this)}partial(e){const t={};return _.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];e&&!e[r]?t[r]=s:t[r]=s.optional()}),new w({...this._def,shape:()=>t})}required(e){const t={};return _.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof R;)a=a._def.innerType;t[r]=a}}),new w({...this._def,shape:()=>t})}keyof(){return Je(_.objectKeys(this.shape))}}w.create=(n,e)=>new w({shape:()=>n,unknownKeys:"strip",catchall:$.create(),typeName:y.ZodObject,...b(e)}),w.strictCreate=(n,e)=>new w({shape:()=>n,unknownKeys:"strict",catchall:$.create(),typeName:y.ZodObject,...b(e)}),w.lazycreate=(n,e)=>new w({shape:n,unknownKeys:"strip",catchall:$.create(),typeName:y.ZodObject,...b(e)});class ce extends x{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function s(a){for(const c of a)if(c.result.status==="valid")return c.result;for(const c of a)if(c.result.status==="dirty")return t.common.issues.push(...c.ctx.common.issues),c.result;const o=a.map(c=>new I(c.ctx.common.issues));return f(t,{code:u.invalid_union,unionErrors:o}),g}if(t.common.async)return Promise.all(r.map(async a=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(s);{let a;const o=[];for(const d of r){const l={...t,common:{...t.common,issues:[]},parent:null},m=d._parseSync({data:t.data,path:t.path,parent:l});if(m.status==="valid")return m;m.status==="dirty"&&!a&&(a={result:m,ctx:l}),l.common.issues.length&&o.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const c=o.map(d=>new I(d));return f(t,{code:u.invalid_union,unionErrors:c}),g}}get options(){return this._def.options}}ce.create=(n,e)=>new ce({options:n,typeName:y.ZodUnion,...b(e)});const V=n=>n instanceof le?V(n.schema):n instanceof j?V(n.innerType()):n instanceof fe?[n.value]:n instanceof U?n.options:n instanceof he?_.objectValues(n.enum):n instanceof me?V(n._def.innerType):n instanceof ie?[void 0]:n instanceof oe?[null]:n instanceof R?[void 0,...V(n.unwrap())]:n instanceof B?[null,...V(n.unwrap())]:n instanceof je||n instanceof ge?V(n.unwrap()):n instanceof pe?V(n._def.innerType):[];class Te extends x{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.object)return f(t,{code:u.invalid_type,expected:h.object,received:t.parsedType}),g;const r=this.discriminator,s=t.data[r],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:u.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),g)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const s=new Map;for(const a of t){const o=V(a.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const c of o){if(s.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);s.set(c,a)}}return new Te({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...b(r)})}}function Oe(n,e){const t=M(n),r=M(e);if(n===e)return{valid:!0,data:n};if(t===h.object&&r===h.object){const s=_.objectKeys(e),a=_.objectKeys(n).filter(c=>s.indexOf(c)!==-1),o={...n,...e};for(const c of a){const d=Oe(n[c],e[c]);if(!d.valid)return{valid:!1};o[c]=d.data}return{valid:!0,data:o}}else if(t===h.array&&r===h.array){if(n.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<n.length;a++){const o=n[a],c=e[a],d=Oe(o,c);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return t===h.date&&r===h.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class de extends x{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=(a,o)=>{if(Ae(a)||Ae(o))return g;const c=Oe(a.value,o.value);return c.valid?((Ne(a)||Ne(o))&&t.dirty(),{status:t.value,value:c.data}):(f(r,{code:u.invalid_intersection_types}),g)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,o])=>s(a,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}de.create=(n,e,t)=>new de({left:n,right:e,typeName:y.ZodIntersection,...b(t)});class P extends x{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==h.array)return f(r,{code:u.invalid_type,expected:h.array,received:r.parsedType}),g;if(r.data.length<this._def.items.length)return f(r,{code:u.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),g;!this._def.rest&&r.data.length>this._def.items.length&&(f(r,{code:u.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...r.data].map((o,c)=>{const d=this._def.items[c]||this._def.rest;return d?d._parse(new E(r,o,r.path,c)):null}).filter(o=>!!o);return r.common.async?Promise.all(a).then(o=>S.mergeArray(t,o)):S.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new P({...this._def,rest:e})}}P.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new P({items:n,typeName:y.ZodTuple,rest:null,...b(e)})};class ue extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==h.object)return f(r,{code:u.invalid_type,expected:h.object,received:r.parsedType}),g;const s=[],a=this._def.keyType,o=this._def.valueType;for(const c in r.data)s.push({key:a._parse(new E(r,c,r.path,c)),value:o._parse(new E(r,r.data[c],r.path,c)),alwaysSet:c in r.data});return r.common.async?S.mergeObjectAsync(t,s):S.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof x?new ue({keyType:e,valueType:t,typeName:y.ZodRecord,...b(r)}):new ue({keyType:Z.create(),valueType:e,typeName:y.ZodRecord,...b(t)})}}class Se extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==h.map)return f(r,{code:u.invalid_type,expected:h.map,received:r.parsedType}),g;const s=this._def.keyType,a=this._def.valueType,o=[...r.data.entries()].map(([c,d],l)=>({key:s._parse(new E(r,c,r.path,[l,"key"])),value:a._parse(new E(r,d,r.path,[l,"value"]))}));if(r.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const d of o){const l=await d.key,m=await d.value;if(l.status==="aborted"||m.status==="aborted")return g;(l.status==="dirty"||m.status==="dirty")&&t.dirty(),c.set(l.value,m.value)}return{status:t.value,value:c}})}else{const c=new Map;for(const d of o){const l=d.key,m=d.value;if(l.status==="aborted"||m.status==="aborted")return g;(l.status==="dirty"||m.status==="dirty")&&t.dirty(),c.set(l.value,m.value)}return{status:t.value,value:c}}}}Se.create=(n,e,t)=>new Se({valueType:e,keyType:n,typeName:y.ZodMap,...b(t)});class J extends x{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==h.set)return f(r,{code:u.invalid_type,expected:h.set,received:r.parsedType}),g;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(f(r,{code:u.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(f(r,{code:u.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function o(d){const l=new Set;for(const m of d){if(m.status==="aborted")return g;m.status==="dirty"&&t.dirty(),l.add(m.value)}return{status:t.value,value:l}}const c=[...r.data.values()].map((d,l)=>a._parse(new E(r,d,r.path,l)));return r.common.async?Promise.all(c).then(d=>o(d)):o(c)}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=(n,e)=>new J({valueType:n,minSize:null,maxSize:null,typeName:y.ZodSet,...b(e)});class K extends x{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.function)return f(t,{code:u.invalid_type,expected:h.function,received:t.parsedType}),g;function r(c,d){return be({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,_e(),Y].filter(l=>!!l),issueData:{code:u.invalid_arguments,argumentsError:d}})}function s(c,d){return be({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,_e(),Y].filter(l=>!!l),issueData:{code:u.invalid_return_type,returnTypeError:d}})}const a={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof ee){const c=this;return C(async function(...d){const l=new I([]),m=await c._def.args.parseAsync(d,a).catch(A=>{throw l.addIssue(r(d,A)),l}),k=await Reflect.apply(o,this,m);return await c._def.returns._def.type.parseAsync(k,a).catch(A=>{throw l.addIssue(s(k,A)),l})})}else{const c=this;return C(function(...d){const l=c._def.args.safeParse(d,a);if(!l.success)throw new I([r(d,l.error)]);const m=Reflect.apply(o,this,l.data),k=c._def.returns.safeParse(m,a);if(!k.success)throw new I([s(m,k.error)]);return k.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new K({...this._def,args:P.create(e).rest(Q.create())})}returns(e){return new K({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new K({args:e||P.create([]).rest(Q.create()),returns:t||Q.create(),typeName:y.ZodFunction,...b(r)})}}class le extends x{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=(n,e)=>new le({getter:n,typeName:y.ZodLazy,...b(e)});class fe extends x{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return f(t,{received:t.data,code:u.invalid_literal,expected:this._def.value}),g}return{status:"valid",value:e.data}}get value(){return this._def.value}}fe.create=(n,e)=>new fe({value:n,typeName:y.ZodLiteral,...b(e)});function Je(n,e){return new U({values:n,typeName:y.ZodEnum,...b(e)})}class U extends x{constructor(){super(...arguments),re.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return f(t,{expected:_.joinValues(r),received:t.parsedType,code:u.invalid_type}),g}if(xe(this,re)||Ue(this,re,new Set(this._def.values)),!xe(this,re).has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return f(t,{received:t.data,code:u.invalid_enum_value,options:r}),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 U.create(e,{...this._def,...t})}exclude(e,t=this._def){return U.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}re=new WeakMap,U.create=Je;class he extends x{constructor(){super(...arguments),se.set(this,void 0)}_parse(e){const t=_.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==h.string&&r.parsedType!==h.number){const s=_.objectValues(t);return f(r,{expected:_.joinValues(s),received:r.parsedType,code:u.invalid_type}),g}if(xe(this,se)||Ue(this,se,new Set(_.getValidEnumValues(this._def.values))),!xe(this,se).has(e.data)){const s=_.objectValues(t);return f(r,{received:r.data,code:u.invalid_enum_value,options:s}),g}return C(e.data)}get enum(){return this._def.values}}se=new WeakMap,he.create=(n,e)=>new he({values:n,typeName:y.ZodNativeEnum,...b(e)});class ee extends x{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:u.invalid_type,expected:h.promise,received:t.parsedType}),g;const r=t.parsedType===h.promise?t.data:Promise.resolve(t.data);return C(r.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ee.create=(n,e)=>new ee({type:n,typeName:y.ZodPromise,...b(e)});class j extends x{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:r}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:o=>{f(r,o),o.fatal?t.abort():t.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const o=s.transform(r.data,a);if(r.common.async)return Promise.resolve(o).then(async c=>{if(t.value==="aborted")return g;const d=await this._def.schema._parseAsync({data:c,path:r.path,parent:r});return d.status==="aborted"?g:d.status==="dirty"||t.value==="dirty"?H(d.value):d});{if(t.value==="aborted")return g;const c=this._def.schema._parseSync({data:o,path:r.path,parent:r});return c.status==="aborted"?g:c.status==="dirty"||t.value==="dirty"?H(c.value):c}}if(s.type==="refinement"){const o=c=>{const d=s.refinement(c,a);if(r.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(r.common.async===!1){const c=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return c.status==="aborted"?g:(c.status==="dirty"&&t.dirty(),o(c.value),{status:t.value,value:c.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(c=>c.status==="aborted"?g:(c.status==="dirty"&&t.dirty(),o(c.value).then(()=>({status:t.value,value:c.value}))))}if(s.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!W(o))return o;const c=s.transform(o.value,a);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:c}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>W(o)?Promise.resolve(s.transform(o.value,a)).then(c=>({status:t.value,value:c})):o);_.assertNever(s)}}j.create=(n,e,t)=>new j({schema:n,typeName:y.ZodEffects,effect:e,...b(t)}),j.createWithPreprocess=(n,e,t)=>new j({schema:e,effect:{type:"preprocess",transform:n},typeName:y.ZodEffects,...b(t)});class R extends x{_parse(e){return this._getType(e)===h.undefined?C(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}R.create=(n,e)=>new R({innerType:n,typeName:y.ZodOptional,...b(e)});class B extends x{_parse(e){return this._getType(e)===h.null?C(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}B.create=(n,e)=>new B({innerType:n,typeName:y.ZodNullable,...b(e)});class me extends x{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===h.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}me.create=(n,e)=>new me({innerType:n,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...b(e)});class pe extends x{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return ne(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new I(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new I(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}pe.create=(n,e)=>new pe({innerType:n,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...b(e)});class Ce extends x{_parse(e){if(this._getType(e)!==h.nan){const r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:h.nan,received:r.parsedType}),g}return{status:"valid",value:e.data}}}Ce.create=n=>new Ce({typeName:y.ZodNaN,...b(n)});const Pt=Symbol("zod_brand");class je extends x{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class ye extends x{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?g:a.status==="dirty"?(t.dirty(),H(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?g:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,t){return new ye({in:e,out:t,typeName:y.ZodPipeline})}}class ge extends x{_parse(e){const t=this._def.innerType._parse(e),r=s=>(W(s)&&(s.value=Object.freeze(s.value)),s);return ne(t)?t.then(s=>r(s)):r(t)}unwrap(){return this._def.innerType}}ge.create=(n,e)=>new ge({innerType:n,typeName:y.ZodReadonly,...b(e)});function Ye(n,e){const t=typeof n=="function"?n(e):typeof n=="string"?{message:n}:n;return typeof t=="string"?{message:t}:t}function He(n,e={},t){return n?G.create().superRefine((r,s)=>{var a,o;const c=n(r);if(c instanceof Promise)return c.then(d=>{var l,m;if(!d){const k=Ye(e,r),T=(m=(l=k.fatal)!==null&&l!==void 0?l:t)!==null&&m!==void 0?m:!0;s.addIssue({code:"custom",...k,fatal:T})}});if(!c){const d=Ye(e,r),l=(o=(a=d.fatal)!==null&&a!==void 0?a:t)!==null&&o!==void 0?o:!0;s.addIssue({code:"custom",...d,fatal:l})}}):G.create()}const Rt={object:w.lazycreate};var y;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(y||(y={}));const Dt=(n,e={message:`Input not instance of ${n.name}`})=>He(t=>t instanceof n,e),Ge=Z.create,Xe=z.create,Mt=Ce.create,$t=L.create,Ke=ae.create,Vt=q.create,Ft=ke.create,zt=ie.create,Lt=oe.create,Ut=G.create,Bt=Q.create,Wt=$.create,qt=we.create,Qt=O.create,Jt=w.create,Yt=w.strictCreate,Ht=ce.create,Gt=Te.create,Xt=de.create,Kt=P.create,en=ue.create,tn=Se.create,nn=J.create,rn=K.create,sn=le.create,an=fe.create,on=U.create,cn=he.create,dn=ee.create,et=j.create,un=R.create,ln=B.create,fn=j.createWithPreprocess,hn=ye.create;var i=Object.freeze({__proto__:null,defaultErrorMap:Y,setErrorMap:lt,getErrorMap:_e,makeIssue:be,EMPTY_PATH:ft,addIssueToContext:f,ParseStatus:S,INVALID:g,DIRTY:H,OK:C,isAborted:Ae,isDirty:Ne,isValid:W,isAsync:ne,get util(){return _},get objectUtil(){return F},ZodParsedType:h,getParsedType:M,ZodType:x,datetimeRegex:Qe,ZodString:Z,ZodNumber:z,ZodBigInt:L,ZodBoolean:ae,ZodDate:q,ZodSymbol:ke,ZodUndefined:ie,ZodNull:oe,ZodAny:G,ZodUnknown:Q,ZodNever:$,ZodVoid:we,ZodArray:O,ZodObject:w,ZodUnion:ce,ZodDiscriminatedUnion:Te,ZodIntersection:de,ZodTuple:P,ZodRecord:ue,ZodMap:Se,ZodSet:J,ZodFunction:K,ZodLazy:le,ZodLiteral:fe,ZodEnum:U,ZodNativeEnum:he,ZodPromise:ee,ZodEffects:j,ZodTransformer:j,ZodOptional:R,ZodNullable:B,ZodDefault:me,ZodCatch:pe,ZodNaN:Ce,BRAND:Pt,ZodBranded:je,ZodPipeline:ye,ZodReadonly:ge,custom:He,Schema:x,ZodSchema:x,late:Rt,get ZodFirstPartyTypeKind(){return y},coerce:{string:n=>Z.create({...n,coerce:!0}),number:n=>z.create({...n,coerce:!0}),boolean:n=>ae.create({...n,coerce:!0}),bigint:n=>L.create({...n,coerce:!0}),date:n=>q.create({...n,coerce:!0})},any:Ut,array:Qt,bigint:$t,boolean:Ke,date:Vt,discriminatedUnion:Gt,effect:et,enum:on,function:rn,instanceof:Dt,intersection:Xt,lazy:sn,literal:an,map:tn,nan:Mt,nativeEnum:cn,never:Wt,null:Lt,nullable:ln,number:Xe,object:Jt,oboolean:()=>Ke().optional(),onumber:()=>Xe().optional(),optional:un,ostring:()=>Ge().optional(),pipeline:hn,preprocess:fn,promise:dn,record:en,set:nn,strictObject:Yt,string:Ge,symbol:Ft,transformer:et,tuple:Kt,undefined:zt,union:Ht,unknown:Bt,void:qt,NEVER:g,ZodIssueCode:u,quotelessJson:ut,ZodError:I});const tt=i.object({country:i.string(),city:i.string(),street:i.string(),streetNumber:i.string(),floor:i.string(),apartmentEnterNumber:i.string(),apartmentNumber:i.string()}),D=i.string().min(1,{message:"שדה חובה"}),mn=i.string().regex(/^\d+$/,"Must be a numeric string"),pn=i.object({url:i.string().url(),id:i.string()});function yn(n){return!!(n!=null&&n.url)}const te=i.object({lang:i.enum(["he"]),value:i.string()}),gn=i.array(te),Ee=i.object({id:i.string().min(1),companyId:i.string().min(1),storeId:i.string().min(1),parentId:i.string().nullish(),tag:i.string().optional(),locales:i.array(te),depth:i.number()}),Ie=Ee.extend({children:i.lazy(()=>Ie.array())}),vn=Ee.extend({index:i.number(),depth:i.number(),collapsed:i.boolean().optional(),children:i.array(Ie)}),ve=i.string().min(1),Pe=i.object({type:i.literal("Product"),storeId:ve,companyId:ve,id:ve,objectID:ve,sku:ve,name:i.array(te),description:i.array(te),isPublished:i.boolean(),vat:i.boolean(),priceType:i.object({type:i.enum(["unit","kg","gram","liter","ml"]),value:i.number()}),price:i.number().positive(),purchasePrice:i.number().optional(),profitPercentage:i.number().optional(),currency:i.literal("ILS"),discount:i.object({type:i.enum(["number","percent","none"]),value:i.number()}),isDiscountable:i.boolean({description:"included in store discounts"}).optional(),weight:i.object({value:i.number(),unit:i.enum(["kg","gram","none"])}),volume:i.object({value:i.number(),unit:i.enum(["liter","ml","none"])}),images:i.array(i.object({url:i.string().url(),id:i.string()})),manufacturer:i.string(),brand:i.string(),importer:i.string(),supplier:i.string(),ingredients:i.array(te),created_at:i.number(),updated_at:i.number(),categoryIds:i.array(i.string().nonempty()),categoryList:i.array(Ie).optional(),categories:i.object({lvl0:i.array(i.string()),lvl1:i.array(i.string()),lvl2:i.array(i.string()),lvl3:i.array(i.string()),lvl4:i.array(i.string())}).optional(),categoryNames:i.array(i.string()).optional()}),_n=Pe.extend({image:i.instanceof(File).optional()}),Re=i.object({product:Pe,originalPrice:i.number().optional(),finalPrice:i.number().optional(),finalDiscount:i.number().optional(),amount:i.number().positive({message:"Quantity must be a positive number."})}),bn=i.object({type:i.literal("Cart"),id:i.string().uuid(),companyId:i.string().uuid(),storeId:i.string().uuid(),userId:i.string().uuid(),status:i.enum(["active","draft","completed"]),items:i.array(Re)}),xn=i.object({id:i.string(),name:i.string(),websiteDomains:i.array(i.string())}),kn=i.object({type:i.literal("FavoriteProduct"),id:i.string().uuid(),companyId:i.string().uuid(),storeId:i.string().uuid(),userId:i.string().uuid(),productId:i.string().uuid()}),De=i.enum(["default","delayed"],{description:"delayed is J5 transaction"}),nt=i.object({type:i.literal("Profile"),id:D,companyId:D,storeId:D,tenantId:D,clientType:i.enum(["user","company"]),companyName:i.string().optional(),displayName:D,email:i.string().email(),phoneNumber:i.string().optional(),address:tt.optional(),isAnonymous:i.boolean(),createdDate:i.number(),lastActivityDate:i.number(),paymentType:De,organizationId:i.string().optional()});function wn(){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:De.Values.default}}const Tn=i.object({type:i.literal("Order"),id:D,companyId:D,storeId:D,userId:D,status:i.enum(["draft","pending","processing","in_delivery","delivered","cancelled","completed","refunded"]),paymentStatus:i.enum(["pending","pending_j5","external","completed","failed","refunded"]),cart:i.object({id:i.string(),items:i.array(Re),cartDiscount:i.number(),cartTotal:i.number(),cartVat:i.number(),deliveryPrice:i.number().optional()}),originalAmount:i.number().positive().optional(),actualAmount:i.number().positive().optional(),date:i.number(),deliveryDate:i.coerce.number(),client:nt.required({}),nameOnInvoice:i.string().optional(),clientComment:i.string().optional()}),rt=i.enum(["individual","company"]),Sn=i.object({id:i.string(),companyId:i.string(),name:i.string(),urls:i.array(i.string()),logoUrl:i.string(),tenantId:i.string(),paymentType:i.enum(["external","j5"]),allowAnonymousClients:i.boolean(),isVatIncludedInPrice:i.boolean(),clientTypes:i.array(rt),minimumOrder:i.number().optional(),freeDeliveryPrice:i.number().optional(),deliveryPrice:i.number().optional()}),st=i.object({minSpend:i.number().positive().optional(),stackable:i.boolean().default(!1)}).optional(),at=i.discriminatedUnion("variantType",[i.object({variantType:i.literal("bundle"),productsId:i.array(i.string().nonempty()).min(1),requiredQuantity:i.number().positive(),bundlePrice:i.number().positive()})]),Cn=i.object({type:i.literal("Discount"),storeId:i.string().min(1),companyId:i.string().min(1),id:i.string().min(1),name:i.array(i.object({lang:i.enum(["he"]),value:i.string().nonempty()})),active:i.boolean(),startDate:i.number(),endDate:i.number(),variant:at,conditions:st});class it{canApply(e,t){if(e.variant.variantType!=="bundle"||!this.isDiscountActive(e))return!1;const{productsId:r,requiredQuantity:s}=e.variant;return this.getTotalQuantity(t.cart,r)>=s}calculate(e,t){if(e.variant.variantType!=="bundle")return{applicable:!1,discountAmount:0,affectedItems:[]};const{productsId:r,requiredQuantity:s,bundlePrice:a}=e.variant,o=t.cart.filter(N=>r.includes(N.product.id)),c=this.getTotalQuantity(t.cart,r),d=Math.floor(c/s);if(d===0)return{applicable:!1,discountAmount:0,affectedItems:[]};const l=this.calculateOriginalPrice(o),m=this.getTotalQuantity(t.cart,r),k=this.calculateDiscountedPrice(l,a,d,s,m),T=l-k,A=this.distributeDiscount(o,T,l);return{applicable:!0,discountAmount:Number(T.toFixed(2)),affectedItems:A}}isDiscountActive(e){const t=Date.now();return e.active&&e.startDate<=t&&e.endDate>=t}getTotalQuantity(e,t){return e.filter(r=>t.includes(r.product.id)).reduce((r,s)=>r+s.amount,0)}calculateOriginalPrice(e){return e.reduce((t,r)=>t+r.product.price*r.amount,0)}calculateDiscountedPrice(e,t,r,s,a){const o=t*r,c=r*s,l=Math.max(0,a-c)/a*e;return o+l}distributeDiscount(e,t,r){const s=t/r;return e.map(a=>{const o=a.product.price*a.amount*s;return{productId:a.product.id,quantity:a.amount,originalPrice:Number(a.product.price.toFixed(2)),discountedPrice:Number((a.product.price-o/a.amount).toFixed(2)),discountAmount:Number(o.toFixed(2))}})}}class Me{static getStrategy(e){return this.strategies.get(e.variant.variantType)||null}static registerStrategy(e,t){this.strategies.set(e,t)}static getRegisteredTypes(){return Array.from(this.strategies.keys())}static clearStrategies(){this.strategies.clear()}}dt(Me,"strategies",new Map([["bundle",new it]]));class ot{static calculateDiscounts(e,t,r){var l,m;const s={cart:e,user:r,appliedDiscounts:[]},a=this.filterActiveDiscounts(t),o=[];for(const k of a){const T=Me.getStrategy(k);if(!T||!T.canApply(k,s)||!((l=k.conditions)!=null&&l.stackable)&&o.length>0)continue;const A=T.calculate(k,s);A.applicable&&(o.push({discountId:k.id,discountName:((m=k.name[0])==null?void 0:m.value)||"Discount",discountAmount:Number(A.discountAmount.toFixed(2)),affectedItems:A.affectedItems}),s.appliedDiscounts=o)}const c=this.calculateFinalPrices(e,o),d=o.reduce((k,T)=>k+T.discountAmount,0);return{items:c,totalDiscount:Number(d.toFixed(2)),appliedDiscounts:o}}static filterActiveDiscounts(e){const t=Date.now();return e.filter(r=>r.active&&r.startDate<=t&&r.endDate>=t)}static calculateFinalPrices(e,t){return e.map(r=>{const s=t.filter(d=>d.affectedItems.some(l=>l.productId===r.product.id)),a=s.reduce((d,l)=>{const m=l.affectedItems.find(k=>k.productId===r.product.id);return d+((m==null?void 0:m.discountAmount)||0)},0),o=a/r.amount,c=r.product.price-o;return{amount:r.amount,product:r.product,originalPrice:Number(r.product.price.toFixed(2)),finalPrice:Number(Math.max(0,c).toFixed(2)),finalDiscount:Number(a.toFixed(2)),appliedDiscounts:s.map(d=>d.discountId)}})}static isDiscountActive(e){const t=Date.now();return e.active&&e.startDate<=t&&e.endDate>=t}static getActiveDiscounts(e){return this.filterActiveDiscounts(e)}}function $e(n){return Number(n.toFixed(2))}function In(n){return n.toFixed(2)}function An(n){return Math.max(0,$e(n))}function Nn(n,e){if(n<=0)return 0;const t=n-e;return $e(t/n*100)}const ct=i.object({id:i.string(),name:i.string(),discountPercentage:i.number().positive().min(0).max(100).optional(),nameOnInvoice:i.string().optional()}),Zn=ct.omit({id:!0}),Ve={VAT:18};function On(n){var e,t;return((e=n.discount)==null?void 0:e.type)==="percent"?n.price*(n.discount.value??100)/100:((t=n.discount)==null?void 0:t.type)==="number"?n.discount.value??0:0}function jn(n){var e,t;if(((e=n.discount)==null?void 0:e.type)==="percent"){const r=n.price*n.discount.value/100;return n.price-r}return((t=n.discount)==null?void 0:t.type)==="number"?n.price-n.discount.value:n.price}function En({cart:n,discounts:e,store:t}){const{isVatIncludedInPrice:r}=t,s=n.map(d=>({amount:d.amount,product:{id:d.product.id,price:d.product.price}})),a=ot.calculateDiscounts(s,e),o=n.map((d,l)=>{const m=a.items[l];return{amount:d.amount,product:{...d.product},originalPrice:d.product.price,finalPrice:m?m.finalPrice:jn(d.product),finalDiscount:m?m.finalDiscount:On(d.product)}}),c=o.reduce((d,l)=>{const{product:m,amount:k,finalPrice:T,finalDiscount:A}=l;let N=0;if(m.vat){let ze=0;if(r){const Rn=T*(Ve.VAT/(100+Ve.VAT));N=Number(Rn.toFixed(2)),N=N*k,ze=Number(N.toFixed(2))}else N=T*Ve.VAT/100,N=N*k,ze=Number(N.toFixed(2));d.vat=Number((d.vat+ze).toFixed(2))}const Fe=Number(T.toFixed(2));return d.cost+=k*Fe,d.discount+=A&&k*A,d.finalCost+=k*Fe+(r?0:N),d.productsCost+=k*Fe+(r?0:N),d.cost=Number(d.cost.toFixed(2)),d.discount=Number(d.discount.toFixed(2)),d.finalCost=Number(d.finalCost.toFixed(2)),d.productsCost=Number(d.productsCost.toFixed(2)),d},{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:o,...c}}const Pn={firestore:{systemCollections:{stores:"STORES",companies:"COMPANIES"},storeCollections:{products:"products",profiles:"profiles",cart:"cart",clients:"clients",orders:"orders",categories:"categories",favorites:"favorites",payments:"payments",settings:"settings",discounts:"discounts",organizations:"organizations"},getPath:({companyId:n,storeId:e,collectionName:t,id:r})=>`${n}/${e}/${t}${r?`/${r}`:""}`,getDocPath:n=>`{companyId}/{storeId}/${n}/{id}`}};v.AddressSchema=tt,v.BaseCategorySchema=Ee,v.BundleDiscountStrategy=it,v.CartItemProductSchema=Re,v.CartSchema=bn,v.CategorySchema=Ie,v.CompanySchema=xn,v.DiscountConditionsSchema=st,v.DiscountEngine=ot,v.DiscountSchema=Cn,v.DiscountStrategyFactory=Me,v.DiscountVariantSchema=at,v.FavoriteProductSchema=kn,v.FileSchema=pn,v.FirebaseAPI=Pn,v.LocaleSchema=te,v.LocaleValueSchema=gn,v.NewOrganizationSchema=Zn,v.NewProductSchema=_n,v.OrderSchema=Tn,v.OrganizationSchema=ct,v.ProductSchema=Pe,v.ProfilePaymentTypeSchema=De,v.ProfileSchema=nt,v.StoreSchema=Sn,v.TFlattenCategorySchema=vn,v.calculatePercentageDiscount=Nn,v.clientTypesSchema=rt,v.createEmptyProfile=wn,v.ensureNonNegative=An,v.formatCurrency=$e,v.formatCurrencyString=In,v.getCartCost=En,v.isFile=yn,v.notEmptyTextSchema=D,v.numericTextSchema=mn,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(y,_){typeof exports=="object"&&typeof module<"u"?_(exports):typeof define=="function"&&define.amd?define(["exports"],_):(y=typeof globalThis<"u"?globalThis:y||self,_(y.core={}))})(this,function(y){"use strict";var Fn=Object.defineProperty;var zn=(y,_,F)=>_ in y?Fn(y,_,{enumerable:!0,configurable:!0,writable:!0,value:F}):y[_]=F;var lt=(y,_,F)=>zn(y,typeof _!="symbol"?_+"":_,F);var _;(function(n){n.assertEqual=a=>a;function e(a){}n.assertIs=e;function t(a){throw new Error}n.assertNever=t,n.arrayToEnum=a=>{const s={};for(const o of a)s[o]=o;return s},n.getValidEnumValues=a=>{const s=n.objectKeys(a).filter(c=>typeof a[a[c]]!="number"),o={};for(const c of s)o[c]=a[c];return n.objectValues(o)},n.objectValues=a=>n.objectKeys(a).map(function(s){return a[s]}),n.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const s=[];for(const o in a)Object.prototype.hasOwnProperty.call(a,o)&&s.push(o);return s},n.find=(a,s)=>{for(const o of a)if(s(o))return o},n.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&isFinite(a)&&Math.floor(a)===a;function r(a,s=" | "){return a.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}n.joinValues=r,n.jsonStringifyReplacer=(a,s)=>typeof s=="bigint"?s.toString():s})(_||(_={}));var F;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(F||(F={}));const m=_.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),M=n=>{switch(typeof n){case"undefined":return m.undefined;case"string":return m.string;case"number":return isNaN(n)?m.nan:m.number;case"boolean":return m.boolean;case"function":return m.function;case"bigint":return m.bigint;case"symbol":return m.symbol;case"object":return Array.isArray(n)?m.array:n===null?m.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?m.promise:typeof Map<"u"&&n instanceof Map?m.map:typeof Set<"u"&&n instanceof Set?m.set:typeof Date<"u"&&n instanceof Date?m.date:m.object;default:return m.unknown}},u=_.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),ft=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class I extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};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(s){return s.message},r={_errors:[]},a=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(a);else if(o.code==="invalid_return_type")a(o.returnTypeError);else if(o.code==="invalid_arguments")a(o.argumentsError);else if(o.path.length===0)r._errors.push(t(o));else{let c=r,d=0;for(;d<o.path.length;){const l=o.path[d];d===o.path.length-1?(c[l]=c[l]||{_errors:[]},c[l]._errors.push(t(o))):c[l]=c[l]||{_errors:[]},c=c[l],d++}}};return a(this),r}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,_.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const a of this.issues)a.path.length>0?(t[a.path[0]]=t[a.path[0]]||[],t[a.path[0]].push(e(a))):r.push(e(a));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}I.create=n=>new I(n);const J=(n,e)=>{let t;switch(n.code){case u.invalid_type:n.received===m.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case u.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,_.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:t=`Unrecognized key(s) in object: ${_.joinValues(n.keys,", ")}`;break;case u.invalid_union:t="Invalid input";break;case u.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${_.joinValues(n.options)}`;break;case u.invalid_enum_value:t=`Invalid enum value. Expected ${_.joinValues(n.options)}, received '${n.received}'`;break;case u.invalid_arguments:t="Invalid function arguments";break;case u.invalid_return_type:t="Invalid function return type";break;case u.invalid_date:t="Invalid date";break;case u.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:_.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case u.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case u.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case u.custom:t="Invalid input";break;case u.invalid_intersection_types:t="Intersection results could not be merged";break;case u.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case u.not_finite:t="Number must be finite";break;default:t=e.defaultError,_.assertNever(n)}return{message:t}};let Ue=J;function mt(n){Ue=n}function _e(){return Ue}const be=n=>{const{data:e,path:t,errorMaps:r,issueData:a}=n,s=[...t,...a.path||[]],o={...a,path:s};if(a.message!==void 0)return{...a,path:s,message:a.message};let c="";const d=r.filter(l=>!!l).slice().reverse();for(const l of d)c=l(o,{data:e,defaultError:c}).message;return{...a,path:s,message:c}},ht=[];function f(n,e){const t=_e(),r=be({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===J?void 0:J].filter(a=>!!a)});n.common.issues.push(r)}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 r=[];for(const a of t){if(a.status==="aborted")return v;a.status==="dirty"&&e.dirty(),r.push(a.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const a of t){const s=await a.key,o=await a.value;r.push({key:s,value:o})}return S.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const a of t){const{key:s,value:o}=a;if(s.status==="aborted"||o.status==="aborted")return v;s.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||a.alwaysSet)&&(r[s.value]=o.value)}return{status:e.value,value:r}}}const v=Object.freeze({status:"aborted"}),X=n=>({status:"dirty",value:n}),C=n=>({status:"valid",value:n}),Ne=n=>n.status==="aborted",Ae=n=>n.status==="dirty",q=n=>n.status==="valid",ne=n=>typeof Promise<"u"&&n instanceof Promise;function xe(n,e,t,r){if(typeof e=="function"?n!==e||!0:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(n)}function Be(n,e,t,r,a){if(typeof e=="function"?n!==e||!0:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(n,t),t}typeof SuppressedError=="function"&&SuppressedError;var p;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(p||(p={}));var re,ae;class j{constructor(e,t,r,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=a}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 qe=(n,e)=>{if(q(e))return{success:!0,data:e.value};if(!n.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(n.common.issues);return this._error=t,this._error}}};function b(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:a}=n;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:a}:{errorMap:(o,c)=>{var d,l;const{message:h}=n;return o.code==="invalid_enum_value"?{message:h??c.defaultError}:typeof c.data>"u"?{message:(d=h??r)!==null&&d!==void 0?d:c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:(l=h??t)!==null&&l!==void 0?l:c.defaultError}},description:a}}class x{get description(){return this._def.description}_getType(e){return M(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:M(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:M(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 r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const a={common:{issues:[],async:(r=t==null?void 0:t.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:M(e)},s=this._parseSync({data:e,path:a.path,parent:a});return qe(a,s)}"~validate"(e){var t,r;const a={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:M(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:a});return q(s)?{value:s.value}:{issues:a.common.issues}}catch(s){!((r=(t=s==null?void 0:s.message)===null||t===void 0?void 0:t.toLowerCase())===null||r===void 0)&&r.includes("encountered")&&(this["~standard"].async=!0),a.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:a}).then(s=>q(s)?{value:s.value}:{issues:a.common.issues})}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:M(e)},a=this._parse({data:e,path:r.path,parent:r}),s=await(ne(a)?a:Promise.resolve(a));return qe(r,s)}refine(e,t){const r=a=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(a):t;return this._refinement((a,s)=>{const o=e(a),c=()=>s.addIssue({code:u.custom,...r(a)});return typeof Promise<"u"&&o instanceof Promise?o.then(d=>d?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(e,t){return this._refinement((r,a)=>e(r)?!0:(a.addIssue(typeof t=="function"?t(r,a):t),!1))}_refinement(e){return new D({schema:this,typeName:g.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 P.create(this,this._def)}nullable(){return B.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return O.create(this)}promise(){return ee.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 D({...b(this._def),schema:this,typeName:g.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new he({...b(this._def),innerType:this,defaultValue:t,typeName:g.ZodDefault})}brand(){return new De({typeName:g.ZodBranded,type:this,...b(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new pe({...b(this._def),innerType:this,catchValue:t,typeName:g.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ye.create(this,e)}readonly(){return ge.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const pt=/^c[^\s-]{8,}$/i,yt=/^[0-9a-z]+$/,gt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,vt=/^[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,_t=/^[a-z0-9_-]{21}$/i,bt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,xt=/^[-+]?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)?)??$/,kt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,wt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ze;const Tt=/^(?:(?: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])$/,St=/^(?:(?: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])$/,Ct=/^(([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]))$/,It=/^(([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])$/,Nt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,At=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,We="((\\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])))",Zt=new RegExp(`^${We}$`);function Qe(n){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Ot(n){return new RegExp(`^${Qe(n)}$`)}function Ye(n){let e=`${We}T${Qe(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Dt(n,e){return!!((e==="v4"||!e)&&Tt.test(n)||(e==="v6"||!e)&&Ct.test(n))}function jt(n,e){if(!bt.test(n))return!1;try{const[t]=n.split("."),r=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),a=JSON.parse(atob(r));return!(typeof a!="object"||a===null||!a.typ||!a.alg||e&&a.alg!==e)}catch{return!1}}function Et(n,e){return!!((e==="v4"||!e)&&St.test(n)||(e==="v6"||!e)&&It.test(n))}class Z extends x{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==m.string){const s=this._getOrReturnCtx(e);return f(s,{code:u.invalid_type,expected:m.string,received:s.parsedType}),v}const r=new S;let a;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:u.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")e.data.length>s.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:u.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){const o=e.data.length>s.value,c=e.data.length<s.value;(o||c)&&(a=this._getOrReturnCtx(e,a),o?f(a,{code:u.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&f(a,{code:u.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")kt.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"email",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")Ze||(Ze=new RegExp(wt,"u")),Ze.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"emoji",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")vt.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"uuid",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")_t.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"nanoid",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")pt.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"cuid",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")yt.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"cuid2",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")gt.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"ulid",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),f(a,{validation:"url",code:u.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"regex",code:u.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(a=this._getOrReturnCtx(e,a),f(a,{code:u.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(a=this._getOrReturnCtx(e,a),f(a,{code:u.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(a=this._getOrReturnCtx(e,a),f(a,{code:u.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?Ye(s).test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:u.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?Zt.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:u.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?Ot(s).test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:u.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?xt.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"duration",code:u.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?Dt(e.data,s.version)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"ip",code:u.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?jt(e.data,s.alg)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"jwt",code:u.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?Et(e.data,s.version)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"cidr",code:u.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?Nt.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"base64",code:u.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?At.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"base64url",code:u.invalid_string,message:s.message}),r.dirty()):_.assertNever(s);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(a=>e.test(a),{validation:t,code:u.invalid_string,...p.errToObj(r)})}_addCheck(e){return new Z({...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,r;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:(r=e==null?void 0:e.local)!==null&&r!==void 0?r:!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 Z({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Z({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Z({...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}}Z.create=n=>{var e;return new Z({checks:[],typeName:g.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...b(n)})};function Pt(n,e){const t=(n.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,a=t>r?t:r,s=parseInt(n.toFixed(a).replace(".","")),o=parseInt(e.toFixed(a).replace(".",""));return s%o/Math.pow(10,a)}class z extends x{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)!==m.number){const s=this._getOrReturnCtx(e);return f(s,{code:u.invalid_type,expected:m.number,received:s.parsedType}),v}let r;const a=new S;for(const s of this._def.checks)s.kind==="int"?_.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:u.invalid_type,expected:"integer",received:"float",message:s.message}),a.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:u.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),a.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:u.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),a.dirty()):s.kind==="multipleOf"?Pt(e.data,s.value)!==0&&(r=this._getOrReturnCtx(e,r),f(r,{code:u.not_multiple_of,multipleOf:s.value,message:s.message}),a.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:u.not_finite,message:s.message}),a.dirty()):_.assertNever(s);return{status:a.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,r,a){return new z({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:p.toString(a)}]})}_addCheck(e){return new z({...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"&&_.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}z.create=n=>new z({checks:[],typeName:g.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...b(n)});class L extends x{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)!==m.bigint)return this._getInvalidInput(e);let r;const a=new S;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:u.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),a.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:u.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),a.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),f(r,{code:u.not_multiple_of,multipleOf:s.value,message:s.message}),a.dirty()):_.assertNever(s);return{status:a.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return f(t,{code:u.invalid_type,expected:m.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,r,a){return new L({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:p.toString(a)}]})}_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=n=>{var e;return new L({checks:[],typeName:g.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...b(n)})};class se extends x{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==m.boolean){const r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:m.boolean,received:r.parsedType}),v}return C(e.data)}}se.create=n=>new se({typeName:g.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...b(n)});class W extends x{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==m.date){const s=this._getOrReturnCtx(e);return f(s,{code:u.invalid_type,expected:m.date,received:s.parsedType}),v}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return f(s,{code:u.invalid_date}),v}const r=new S;let a;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:u.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:u.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):_.assertNever(s);return{status:r.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=n=>new W({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:g.ZodDate,...b(n)});class ke extends x{_parse(e){if(this._getType(e)!==m.symbol){const r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:m.symbol,received:r.parsedType}),v}return C(e.data)}}ke.create=n=>new ke({typeName:g.ZodSymbol,...b(n)});class ie extends x{_parse(e){if(this._getType(e)!==m.undefined){const r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:m.undefined,received:r.parsedType}),v}return C(e.data)}}ie.create=n=>new ie({typeName:g.ZodUndefined,...b(n)});class oe extends x{_parse(e){if(this._getType(e)!==m.null){const r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:m.null,received:r.parsedType}),v}return C(e.data)}}oe.create=n=>new oe({typeName:g.ZodNull,...b(n)});class H extends x{constructor(){super(...arguments),this._any=!0}_parse(e){return C(e.data)}}H.create=n=>new H({typeName:g.ZodAny,...b(n)});class Q extends x{constructor(){super(...arguments),this._unknown=!0}_parse(e){return C(e.data)}}Q.create=n=>new Q({typeName:g.ZodUnknown,...b(n)});class $ extends x{_parse(e){const t=this._getOrReturnCtx(e);return f(t,{code:u.invalid_type,expected:m.never,received:t.parsedType}),v}}$.create=n=>new $({typeName:g.ZodNever,...b(n)});class we extends x{_parse(e){if(this._getType(e)!==m.undefined){const r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:m.void,received:r.parsedType}),v}return C(e.data)}}we.create=n=>new we({typeName:g.ZodVoid,...b(n)});class O extends x{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),a=this._def;if(t.parsedType!==m.array)return f(t,{code:u.invalid_type,expected:m.array,received:t.parsedType}),v;if(a.exactLength!==null){const o=t.data.length>a.exactLength.value,c=t.data.length<a.exactLength.value;(o||c)&&(f(t,{code:o?u.too_big:u.too_small,minimum:c?a.exactLength.value:void 0,maximum:o?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),r.dirty())}if(a.minLength!==null&&t.data.length<a.minLength.value&&(f(t,{code:u.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),r.dirty()),a.maxLength!==null&&t.data.length>a.maxLength.value&&(f(t,{code:u.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((o,c)=>a.type._parseAsync(new j(t,o,t.path,c)))).then(o=>S.mergeArray(r,o));const s=[...t.data].map((o,c)=>a.type._parseSync(new j(t,o,t.path,c)));return S.mergeArray(r,s)}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=(n,e)=>new O({type:n,minLength:null,maxLength:null,exactLength:null,typeName:g.ZodArray,...b(e)});function G(n){if(n instanceof w){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=P.create(G(r))}return new w({...n._def,shape:()=>e})}else return n instanceof O?new O({...n._def,type:G(n.element)}):n instanceof P?P.create(G(n.unwrap())):n instanceof B?B.create(G(n.unwrap())):n instanceof E?E.create(n.items.map(e=>G(e))):n}class w extends x{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=_.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==m.object){const l=this._getOrReturnCtx(e);return f(l,{code:u.invalid_type,expected:m.object,received:l.parsedType}),v}const{status:r,ctx:a}=this._processInputParams(e),{shape:s,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof $&&this._def.unknownKeys==="strip"))for(const l in a.data)o.includes(l)||c.push(l);const d=[];for(const l of o){const h=s[l],k=a.data[l];d.push({key:{status:"valid",value:l},value:h._parse(new j(a,k,a.path,l)),alwaysSet:l in a.data})}if(this._def.catchall instanceof $){const l=this._def.unknownKeys;if(l==="passthrough")for(const h of c)d.push({key:{status:"valid",value:h},value:{status:"valid",value:a.data[h]}});else if(l==="strict")c.length>0&&(f(a,{code:u.unrecognized_keys,keys:c}),r.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const h of c){const k=a.data[h];d.push({key:{status:"valid",value:h},value:l._parse(new j(a,k,a.path,h)),alwaysSet:h in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const l=[];for(const h of d){const k=await h.key,T=await h.value;l.push({key:k,value:T,alwaysSet:h.alwaysSet})}return l}).then(l=>S.mergeObjectSync(r,l)):S.mergeObjectSync(r,d)}get shape(){return this._def.shape()}strict(e){return p.errToObj,new w({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var a,s,o,c;const d=(o=(s=(a=this._def).errorMap)===null||s===void 0?void 0:s.call(a,t,r).message)!==null&&o!==void 0?o:r.defaultError;return t.code==="unrecognized_keys"?{message:(c=p.errToObj(e).message)!==null&&c!==void 0?c:d}:{message:d}}}:{}})}strip(){return new w({...this._def,unknownKeys:"strip"})}passthrough(){return new w({...this._def,unknownKeys:"passthrough"})}extend(e){return new w({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new w({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:g.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new w({...this._def,catchall:e})}pick(e){const t={};return _.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new w({...this._def,shape:()=>t})}omit(e){const t={};return _.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new w({...this._def,shape:()=>t})}deepPartial(){return G(this)}partial(e){const t={};return _.objectKeys(this.shape).forEach(r=>{const a=this.shape[r];e&&!e[r]?t[r]=a:t[r]=a.optional()}),new w({...this._def,shape:()=>t})}required(e){const t={};return _.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof P;)s=s._def.innerType;t[r]=s}}),new w({...this._def,shape:()=>t})}keyof(){return Je(_.objectKeys(this.shape))}}w.create=(n,e)=>new w({shape:()=>n,unknownKeys:"strip",catchall:$.create(),typeName:g.ZodObject,...b(e)}),w.strictCreate=(n,e)=>new w({shape:()=>n,unknownKeys:"strict",catchall:$.create(),typeName:g.ZodObject,...b(e)}),w.lazycreate=(n,e)=>new w({shape:n,unknownKeys:"strip",catchall:$.create(),typeName:g.ZodObject,...b(e)});class ce extends x{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function a(s){for(const c of s)if(c.result.status==="valid")return c.result;for(const c of s)if(c.result.status==="dirty")return t.common.issues.push(...c.ctx.common.issues),c.result;const o=s.map(c=>new I(c.ctx.common.issues));return f(t,{code:u.invalid_union,unionErrors:o}),v}if(t.common.async)return Promise.all(r.map(async s=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(a);{let s;const o=[];for(const d of r){const l={...t,common:{...t.common,issues:[]},parent:null},h=d._parseSync({data:t.data,path:t.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!s&&(s={result:h,ctx:l}),l.common.issues.length&&o.push(l.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const c=o.map(d=>new I(d));return f(t,{code:u.invalid_union,unionErrors:c}),v}}get options(){return this._def.options}}ce.create=(n,e)=>new ce({options:n,typeName:g.ZodUnion,...b(e)});const V=n=>n instanceof le?V(n.schema):n instanceof D?V(n.innerType()):n instanceof fe?[n.value]:n instanceof U?n.options:n instanceof me?_.objectValues(n.enum):n instanceof he?V(n._def.innerType):n instanceof ie?[void 0]:n instanceof oe?[null]:n instanceof P?[void 0,...V(n.unwrap())]:n instanceof B?[null,...V(n.unwrap())]:n instanceof De||n instanceof ge?V(n.unwrap()):n instanceof pe?V(n._def.innerType):[];class Te extends x{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==m.object)return f(t,{code:u.invalid_type,expected:m.object,received:t.parsedType}),v;const r=this.discriminator,a=t.data[r],s=this.optionsMap.get(a);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(f(t,{code:u.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),v)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const a=new Map;for(const s of t){const o=V(s.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const c of o){if(a.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);a.set(c,s)}}return new Te({typeName:g.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...b(r)})}}function Oe(n,e){const t=M(n),r=M(e);if(n===e)return{valid:!0,data:n};if(t===m.object&&r===m.object){const a=_.objectKeys(e),s=_.objectKeys(n).filter(c=>a.indexOf(c)!==-1),o={...n,...e};for(const c of s){const d=Oe(n[c],e[c]);if(!d.valid)return{valid:!1};o[c]=d.data}return{valid:!0,data:o}}else if(t===m.array&&r===m.array){if(n.length!==e.length)return{valid:!1};const a=[];for(let s=0;s<n.length;s++){const o=n[s],c=e[s],d=Oe(o,c);if(!d.valid)return{valid:!1};a.push(d.data)}return{valid:!0,data:a}}else return t===m.date&&r===m.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class de extends x{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),a=(s,o)=>{if(Ne(s)||Ne(o))return v;const c=Oe(s.value,o.value);return c.valid?((Ae(s)||Ae(o))&&t.dirty(),{status:t.value,value:c.data}):(f(r,{code:u.invalid_intersection_types}),v)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,o])=>a(s,o)):a(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}de.create=(n,e,t)=>new de({left:n,right:e,typeName:g.ZodIntersection,...b(t)});class E extends x{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==m.array)return f(r,{code:u.invalid_type,expected:m.array,received:r.parsedType}),v;if(r.data.length<this._def.items.length)return f(r,{code:u.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&r.data.length>this._def.items.length&&(f(r,{code:u.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...r.data].map((o,c)=>{const d=this._def.items[c]||this._def.rest;return d?d._parse(new j(r,o,r.path,c)):null}).filter(o=>!!o);return r.common.async?Promise.all(s).then(o=>S.mergeArray(t,o)):S.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new E({...this._def,rest:e})}}E.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new E({items:n,typeName:g.ZodTuple,rest:null,...b(e)})};class ue extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==m.object)return f(r,{code:u.invalid_type,expected:m.object,received:r.parsedType}),v;const a=[],s=this._def.keyType,o=this._def.valueType;for(const c in r.data)a.push({key:s._parse(new j(r,c,r.path,c)),value:o._parse(new j(r,r.data[c],r.path,c)),alwaysSet:c in r.data});return r.common.async?S.mergeObjectAsync(t,a):S.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof x?new ue({keyType:e,valueType:t,typeName:g.ZodRecord,...b(r)}):new ue({keyType:Z.create(),valueType:e,typeName:g.ZodRecord,...b(t)})}}class Se extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==m.map)return f(r,{code:u.invalid_type,expected:m.map,received:r.parsedType}),v;const a=this._def.keyType,s=this._def.valueType,o=[...r.data.entries()].map(([c,d],l)=>({key:a._parse(new j(r,c,r.path,[l,"key"])),value:s._parse(new j(r,d,r.path,[l,"value"]))}));if(r.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const d of o){const l=await d.key,h=await d.value;if(l.status==="aborted"||h.status==="aborted")return v;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),c.set(l.value,h.value)}return{status:t.value,value:c}})}else{const c=new Map;for(const d of o){const l=d.key,h=d.value;if(l.status==="aborted"||h.status==="aborted")return v;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),c.set(l.value,h.value)}return{status:t.value,value:c}}}}Se.create=(n,e,t)=>new Se({valueType:e,keyType:n,typeName:g.ZodMap,...b(t)});class Y extends x{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==m.set)return f(r,{code:u.invalid_type,expected:m.set,received:r.parsedType}),v;const a=this._def;a.minSize!==null&&r.data.size<a.minSize.value&&(f(r,{code:u.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),t.dirty()),a.maxSize!==null&&r.data.size>a.maxSize.value&&(f(r,{code:u.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());const s=this._def.valueType;function o(d){const l=new Set;for(const h of d){if(h.status==="aborted")return v;h.status==="dirty"&&t.dirty(),l.add(h.value)}return{status:t.value,value:l}}const c=[...r.data.values()].map((d,l)=>s._parse(new j(r,d,r.path,l)));return r.common.async?Promise.all(c).then(d=>o(d)):o(c)}min(e,t){return new Y({...this._def,minSize:{value:e,message:p.toString(t)}})}max(e,t){return new Y({...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)}}Y.create=(n,e)=>new Y({valueType:n,minSize:null,maxSize:null,typeName:g.ZodSet,...b(e)});class K extends x{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==m.function)return f(t,{code:u.invalid_type,expected:m.function,received:t.parsedType}),v;function r(c,d){return be({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,_e(),J].filter(l=>!!l),issueData:{code:u.invalid_arguments,argumentsError:d}})}function a(c,d){return be({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,_e(),J].filter(l=>!!l),issueData:{code:u.invalid_return_type,returnTypeError:d}})}const s={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof ee){const c=this;return C(async function(...d){const l=new I([]),h=await c._def.args.parseAsync(d,s).catch(N=>{throw l.addIssue(r(d,N)),l}),k=await Reflect.apply(o,this,h);return await c._def.returns._def.type.parseAsync(k,s).catch(N=>{throw l.addIssue(a(k,N)),l})})}else{const c=this;return C(function(...d){const l=c._def.args.safeParse(d,s);if(!l.success)throw new I([r(d,l.error)]);const h=Reflect.apply(o,this,l.data),k=c._def.returns.safeParse(h,s);if(!k.success)throw new I([a(h,k.error)]);return k.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new K({...this._def,args:E.create(e).rest(Q.create())})}returns(e){return new K({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new K({args:e||E.create([]).rest(Q.create()),returns:t||Q.create(),typeName:g.ZodFunction,...b(r)})}}class le extends x{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=(n,e)=>new le({getter:n,typeName:g.ZodLazy,...b(e)});class fe extends x{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return f(t,{received:t.data,code:u.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}}fe.create=(n,e)=>new fe({value:n,typeName:g.ZodLiteral,...b(e)});function Je(n,e){return new U({values:n,typeName:g.ZodEnum,...b(e)})}class U extends x{constructor(){super(...arguments),re.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return f(t,{expected:_.joinValues(r),received:t.parsedType,code:u.invalid_type}),v}if(xe(this,re)||Be(this,re,new Set(this._def.values)),!xe(this,re).has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return f(t,{received:t.data,code:u.invalid_enum_value,options:r}),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 U.create(e,{...this._def,...t})}exclude(e,t=this._def){return U.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}re=new WeakMap,U.create=Je;class me extends x{constructor(){super(...arguments),ae.set(this,void 0)}_parse(e){const t=_.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==m.string&&r.parsedType!==m.number){const a=_.objectValues(t);return f(r,{expected:_.joinValues(a),received:r.parsedType,code:u.invalid_type}),v}if(xe(this,ae)||Be(this,ae,new Set(_.getValidEnumValues(this._def.values))),!xe(this,ae).has(e.data)){const a=_.objectValues(t);return f(r,{received:r.data,code:u.invalid_enum_value,options:a}),v}return C(e.data)}get enum(){return this._def.values}}ae=new WeakMap,me.create=(n,e)=>new me({values:n,typeName:g.ZodNativeEnum,...b(e)});class ee extends x{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==m.promise&&t.common.async===!1)return f(t,{code:u.invalid_type,expected:m.promise,received:t.parsedType}),v;const r=t.parsedType===m.promise?t.data:Promise.resolve(t.data);return C(r.then(a=>this._def.type.parseAsync(a,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ee.create=(n,e)=>new ee({type:n,typeName:g.ZodPromise,...b(e)});class D extends x{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===g.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),a=this._def.effect||null,s={addIssue:o=>{f(r,o),o.fatal?t.abort():t.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),a.type==="preprocess"){const o=a.transform(r.data,s);if(r.common.async)return Promise.resolve(o).then(async c=>{if(t.value==="aborted")return v;const d=await this._def.schema._parseAsync({data:c,path:r.path,parent:r});return d.status==="aborted"?v:d.status==="dirty"||t.value==="dirty"?X(d.value):d});{if(t.value==="aborted")return v;const c=this._def.schema._parseSync({data:o,path:r.path,parent:r});return c.status==="aborted"?v:c.status==="dirty"||t.value==="dirty"?X(c.value):c}}if(a.type==="refinement"){const o=c=>{const d=a.refinement(c,s);if(r.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(r.common.async===!1){const c=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return c.status==="aborted"?v:(c.status==="dirty"&&t.dirty(),o(c.value),{status:t.value,value:c.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(c=>c.status==="aborted"?v:(c.status==="dirty"&&t.dirty(),o(c.value).then(()=>({status:t.value,value:c.value}))))}if(a.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!q(o))return o;const c=a.transform(o.value,s);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:c}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>q(o)?Promise.resolve(a.transform(o.value,s)).then(c=>({status:t.value,value:c})):o);_.assertNever(a)}}D.create=(n,e,t)=>new D({schema:n,typeName:g.ZodEffects,effect:e,...b(t)}),D.createWithPreprocess=(n,e,t)=>new D({schema:e,effect:{type:"preprocess",transform:n},typeName:g.ZodEffects,...b(t)});class P extends x{_parse(e){return this._getType(e)===m.undefined?C(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}P.create=(n,e)=>new P({innerType:n,typeName:g.ZodOptional,...b(e)});class B extends x{_parse(e){return this._getType(e)===m.null?C(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}B.create=(n,e)=>new B({innerType:n,typeName:g.ZodNullable,...b(e)});class he extends x{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===m.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}he.create=(n,e)=>new he({innerType:n,typeName:g.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...b(e)});class pe extends x{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return ne(a)?a.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new I(r.common.issues)},input:r.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new I(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}pe.create=(n,e)=>new pe({innerType:n,typeName:g.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...b(e)});class Ce extends x{_parse(e){if(this._getType(e)!==m.nan){const r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:m.nan,received:r.parsedType}),v}return{status:"valid",value:e.data}}}Ce.create=n=>new Ce({typeName:g.ZodNaN,...b(n)});const Rt=Symbol("zod_brand");class De extends x{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class ye extends x{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?v:s.status==="dirty"?(t.dirty(),X(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{const a=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?v:a.status==="dirty"?(t.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:r.path,parent:r})}}static create(e,t){return new ye({in:e,out:t,typeName:g.ZodPipeline})}}class ge extends x{_parse(e){const t=this._def.innerType._parse(e),r=a=>(q(a)&&(a.value=Object.freeze(a.value)),a);return ne(t)?t.then(a=>r(a)):r(t)}unwrap(){return this._def.innerType}}ge.create=(n,e)=>new ge({innerType:n,typeName:g.ZodReadonly,...b(e)});function Xe(n,e){const t=typeof n=="function"?n(e):typeof n=="string"?{message:n}:n;return typeof t=="string"?{message:t}:t}function He(n,e={},t){return n?H.create().superRefine((r,a)=>{var s,o;const c=n(r);if(c instanceof Promise)return c.then(d=>{var l,h;if(!d){const k=Xe(e,r),T=(h=(l=k.fatal)!==null&&l!==void 0?l:t)!==null&&h!==void 0?h:!0;a.addIssue({code:"custom",...k,fatal:T})}});if(!c){const d=Xe(e,r),l=(o=(s=d.fatal)!==null&&s!==void 0?s:t)!==null&&o!==void 0?o:!0;a.addIssue({code:"custom",...d,fatal:l})}}):H.create()}const Mt={object:w.lazycreate};var g;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(g||(g={}));const $t=(n,e={message:`Input not instance of ${n.name}`})=>He(t=>t instanceof n,e),Ge=Z.create,Ke=z.create,Vt=Ce.create,Ft=L.create,et=se.create,zt=W.create,Lt=ke.create,Ut=ie.create,Bt=oe.create,qt=H.create,Wt=Q.create,Qt=$.create,Yt=we.create,Jt=O.create,Xt=w.create,Ht=w.strictCreate,Gt=ce.create,Kt=Te.create,en=de.create,tn=E.create,nn=ue.create,rn=Se.create,an=Y.create,sn=K.create,on=le.create,cn=fe.create,dn=U.create,un=me.create,ln=ee.create,tt=D.create,fn=P.create,mn=B.create,hn=D.createWithPreprocess,pn=ye.create;var i=Object.freeze({__proto__:null,defaultErrorMap:J,setErrorMap:mt,getErrorMap:_e,makeIssue:be,EMPTY_PATH:ht,addIssueToContext:f,ParseStatus:S,INVALID:v,DIRTY:X,OK:C,isAborted:Ne,isDirty:Ae,isValid:q,isAsync:ne,get util(){return _},get objectUtil(){return F},ZodParsedType:m,getParsedType:M,ZodType:x,datetimeRegex:Ye,ZodString:Z,ZodNumber:z,ZodBigInt:L,ZodBoolean:se,ZodDate:W,ZodSymbol:ke,ZodUndefined:ie,ZodNull:oe,ZodAny:H,ZodUnknown:Q,ZodNever:$,ZodVoid:we,ZodArray:O,ZodObject:w,ZodUnion:ce,ZodDiscriminatedUnion:Te,ZodIntersection:de,ZodTuple:E,ZodRecord:ue,ZodMap:Se,ZodSet:Y,ZodFunction:K,ZodLazy:le,ZodLiteral:fe,ZodEnum:U,ZodNativeEnum:me,ZodPromise:ee,ZodEffects:D,ZodTransformer:D,ZodOptional:P,ZodNullable:B,ZodDefault:he,ZodCatch:pe,ZodNaN:Ce,BRAND:Rt,ZodBranded:De,ZodPipeline:ye,ZodReadonly:ge,custom:He,Schema:x,ZodSchema:x,late:Mt,get ZodFirstPartyTypeKind(){return g},coerce:{string:n=>Z.create({...n,coerce:!0}),number:n=>z.create({...n,coerce:!0}),boolean:n=>se.create({...n,coerce:!0}),bigint:n=>L.create({...n,coerce:!0}),date:n=>W.create({...n,coerce:!0})},any:qt,array:Jt,bigint:Ft,boolean:et,date:zt,discriminatedUnion:Kt,effect:tt,enum:dn,function:sn,instanceof:$t,intersection:en,lazy:on,literal:cn,map:rn,nan:Vt,nativeEnum:un,never:Qt,null:Bt,nullable:mn,number:Ke,object:Xt,oboolean:()=>et().optional(),onumber:()=>Ke().optional(),optional:fn,ostring:()=>Ge().optional(),pipeline:pn,preprocess:hn,promise:ln,record:nn,set:an,strictObject:Ht,string:Ge,symbol:Lt,transformer:tt,tuple:tn,undefined:Ut,union:Gt,unknown:Wt,void:Yt,NEVER:v,ZodIssueCode:u,quotelessJson:ft,ZodError:I});const nt=i.object({country:i.string(),city:i.string(),street:i.string(),streetNumber:i.string(),floor:i.string(),apartmentEnterNumber:i.string(),apartmentNumber:i.string()}),R=i.string().min(1,{message:"שדה חובה"}),yn=i.string().regex(/^\d+$/,"Must be a numeric string"),gn=i.object({url:i.string().url(),id:i.string()});function vn(n){return!!(n!=null&&n.url)}const te=i.object({lang:i.enum(["he"]),value:i.string()}),_n=i.array(te),je=i.object({id:i.string().min(1),companyId:i.string().min(1),storeId:i.string().min(1),parentId:i.string().nullish(),tag:i.string().optional(),locales:i.array(te),depth:i.number()}),Ie=je.extend({children:i.lazy(()=>Ie.array())}),bn=je.extend({index:i.number(),depth:i.number(),collapsed:i.boolean().optional(),children:i.array(Ie)}),ve=i.string().min(1),Ee=i.object({type:i.literal("Product"),storeId:ve,companyId:ve,id:ve,objectID:ve,sku:ve,name:i.array(te),description:i.array(te),isPublished:i.boolean(),vat:i.boolean(),priceType:i.object({type:i.enum(["unit","kg","gram","liter","ml"]),value:i.number()}),price:i.number().positive(),purchasePrice:i.number().optional(),profitPercentage:i.number().optional(),currency:i.literal("ILS"),discount:i.object({type:i.enum(["number","percent","none"]),value:i.number()}),isDiscountable:i.boolean({description:"included in store discounts"}).optional(),weight:i.object({value:i.number(),unit:i.enum(["kg","gram","none"])}),volume:i.object({value:i.number(),unit:i.enum(["liter","ml","none"])}),images:i.array(i.object({url:i.string().url(),id:i.string()})),manufacturer:i.string(),brand:i.string(),importer:i.string(),supplier:i.string(),ingredients:i.array(te),created_at:i.number(),updated_at:i.number(),categoryIds:i.array(i.string().nonempty()),categoryList:i.array(Ie).optional(),categories:i.object({lvl0:i.array(i.string()),lvl1:i.array(i.string()),lvl2:i.array(i.string()),lvl3:i.array(i.string()),lvl4:i.array(i.string())}).optional(),categoryNames:i.array(i.string()).optional()}),xn=Ee.extend({image:i.instanceof(File).optional()}),Pe=i.object({product:Ee,originalPrice:i.number().optional(),finalPrice:i.number().optional(),finalDiscount:i.number().optional(),amount:i.number().positive({message:"Quantity must be a positive number."})}),kn=i.object({type:i.literal("Cart"),id:i.string().uuid(),companyId:i.string().uuid(),storeId:i.string().uuid(),userId:i.string().uuid(),status:i.enum(["active","draft","completed"]),items:i.array(Pe)}),wn=i.object({id:i.string(),name:i.string(),websiteDomains:i.array(i.string())}),Tn=i.object({type:i.literal("FavoriteProduct"),id:i.string().uuid(),companyId:i.string().uuid(),storeId:i.string().uuid(),userId:i.string().uuid(),productId:i.string().uuid()}),Re=i.enum(["default","delayed"],{description:"delayed is J5 transaction"}),rt=i.object({type:i.literal("Profile"),id:R,companyId:R,storeId:R,tenantId:R,clientType:i.enum(["user","company"]),companyName:i.string().optional(),displayName:R,email:i.string().email(),phoneNumber:i.string().optional(),address:nt.optional(),isAnonymous:i.boolean(),createdDate:i.number(),lastActivityDate:i.number(),paymentType:Re,organizationId:i.string().optional()});function Sn(){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:Re.Values.default}}const Cn=i.object({type:i.literal("Order"),id:R,companyId:R,storeId:R,userId:R,status:i.enum(["draft","pending","processing","in_delivery","delivered","cancelled","completed","refunded"]),paymentStatus:i.enum(["pending","pending_j5","external","completed","failed","refunded"]),cart:i.object({id:i.string(),items:i.array(Pe),cartDiscount:i.number(),cartTotal:i.number(),cartVat:i.number(),deliveryPrice:i.number().optional()}),originalAmount:i.number().positive().optional(),actualAmount:i.number().positive().optional(),date:i.number(),deliveryDate:i.coerce.number(),client:rt.required({}),nameOnInvoice:i.string().optional(),clientComment:i.string().optional()}),at=i.enum(["individual","company"]),In=i.object({id:i.string(),companyId:i.string(),name:i.string(),urls:i.array(i.string()),logoUrl:i.string(),tenantId:i.string(),paymentType:i.enum(["external","j5"]),allowAnonymousClients:i.boolean(),isVatIncludedInPrice:i.boolean(),clientTypes:i.array(at),minimumOrder:i.number().optional(),freeDeliveryPrice:i.number().optional(),deliveryPrice:i.number().optional()}),st=i.object({minSpend:i.number().positive().optional(),stackable:i.boolean().default(!1)}).optional(),it=i.discriminatedUnion("variantType",[i.object({variantType:i.literal("bundle"),productsId:i.array(i.string().nonempty()).min(1),requiredQuantity:i.number().positive(),bundlePrice:i.number().positive()})]),Nn=i.object({type:i.literal("Discount"),storeId:i.string().min(1),companyId:i.string().min(1),id:i.string().min(1),name:i.array(i.object({lang:i.enum(["he"]),value:i.string().nonempty()})),active:i.boolean(),startDate:i.number(),endDate:i.number(),variant:it,conditions:st});class ot{canApply(e,t){if(e.variant.variantType!=="bundle"||!this.isDiscountActive(e))return!1;const{productsId:r,requiredQuantity:a}=e.variant;return this.getTotalQuantity(t.cart,r)>=a}calculate(e,t){if(e.variant.variantType!=="bundle")return{applicable:!1,discountAmount:0,affectedItems:[]};const{productsId:r,requiredQuantity:a,bundlePrice:s}=e.variant,o=t.cart.filter(A=>r.includes(A.product.id)),c=this.getTotalQuantity(t.cart,r),d=Math.floor(c/a);if(d===0)return{applicable:!1,discountAmount:0,affectedItems:[]};const l=this.calculateOriginalPrice(o),h=this.getTotalQuantity(t.cart,r),k=this.calculateDiscountedPrice(l,s,d,a,h),T=l-k,N=this.distributeDiscount(o,T,l);return{applicable:!0,discountAmount:Number(T.toFixed(2)),affectedItems:N}}isDiscountActive(e){const t=Date.now();return e.active&&e.startDate<=t&&e.endDate>=t}getTotalQuantity(e,t){return e.filter(r=>t.includes(r.product.id)).reduce((r,a)=>r+a.amount,0)}calculateOriginalPrice(e){return e.reduce((t,r)=>t+r.product.price*r.amount,0)}calculateDiscountedPrice(e,t,r,a,s){const o=t*r,c=r*a,l=Math.max(0,s-c)/s*e;return o+l}distributeDiscount(e,t,r){const a=t/r;return e.map(s=>{const o=s.product.price*s.amount*a;return{productId:s.product.id,quantity:s.amount,originalPrice:Number(s.product.price.toFixed(2)),discountedPrice:Number((s.product.price-o/s.amount).toFixed(2)),discountAmount:Number(o.toFixed(2))}})}}class Me{static getStrategy(e){return this.strategies.get(e.variant.variantType)||null}static registerStrategy(e,t){this.strategies.set(e,t)}static getRegisteredTypes(){return Array.from(this.strategies.keys())}static clearStrategies(){this.strategies.clear()}}lt(Me,"strategies",new Map([["bundle",new ot]]));class ct{static calculateDiscounts(e,t,r){var l,h;const a={cart:e,user:r,appliedDiscounts:[]},s=this.filterActiveDiscounts(t),o=[];for(const k of s){const T=Me.getStrategy(k);if(!T||!T.canApply(k,a)||!((l=k.conditions)!=null&&l.stackable)&&o.length>0)continue;const N=T.calculate(k,a);N.applicable&&(o.push({discountId:k.id,discountName:((h=k.name[0])==null?void 0:h.value)||"Discount",discountAmount:Number(N.discountAmount.toFixed(2)),affectedItems:N.affectedItems}),a.appliedDiscounts=o)}const c=this.calculateFinalPrices(e,o),d=o.reduce((k,T)=>k+T.discountAmount,0);return{items:c,totalDiscount:Number(d.toFixed(2)),appliedDiscounts:o}}static filterActiveDiscounts(e){const t=Date.now();return e.filter(r=>r.active&&r.startDate<=t&&r.endDate>=t)}static calculateFinalPrices(e,t){return e.map(r=>{const a=t.filter(d=>d.affectedItems.some(l=>l.productId===r.product.id)),s=a.reduce((d,l)=>{const h=l.affectedItems.find(k=>k.productId===r.product.id);return d+((h==null?void 0:h.discountAmount)||0)},0),o=s/r.amount,c=r.product.price-o;return{amount:r.amount,product:r.product,originalPrice:Number(r.product.price.toFixed(2)),finalPrice:Number(Math.max(0,c).toFixed(2)),finalDiscount:Number(s.toFixed(2)),appliedDiscounts:a.map(d=>d.discountId)}})}static isDiscountActive(e){const t=Date.now();return e.active&&e.startDate<=t&&e.endDate>=t}static getActiveDiscounts(e){return this.filterActiveDiscounts(e)}}function $e(n){return Number(n.toFixed(2))}function An(n){return n.toFixed(2)}function Zn(n){return Math.max(0,$e(n))}function On(n,e){if(n<=0)return 0;const t=n-e;return $e(t/n*100)}const dt=i.object({id:i.string(),name:i.string(),discountPercentage:i.number().positive().min(0).max(100).optional(),nameOnInvoice:i.string().optional()}),Dn=dt.omit({id:!0}),Ve=i.object({_COMMENT:i.string().optional(),transaction_id:i.string(),date:i.string().regex(/^\d{4}-\d{2}-\d{2}$/,"Date must be in YYYY-MM-DD format"),currency:i.string().length(3,"Currency must be 3 characters"),rate:i.number().positive(),vat:i.string().regex(/^\d+\.\d{2}$/,"VAT must be in format XX.XX"),vat_price:i.number().positive(),price_discount:i.number(),price_discount_in_currency:i.number(),price_total:i.string().regex(/^\d+\.\d{2}$/,"Price total must be in format XX.XX"),price_total_in_currency:i.number().positive()}),ut=i.object({doc_uuid:i.string().uuid("Document UUID must be a valid UUID"),pdf_link:i.string().url("PDF link must be a valid URL"),pdf_link_copy:i.string().url("PDF copy link must be a valid URL"),doc_number:i.string().min(1,"Document number is required"),sent_mails:i.array(i.string().email("Each email must be valid")),success:i.boolean(),ua_uuid:i.string().uuid("UA UUID must be a valid UUID"),calculatedData:Ve,warning:i.string().optional()});function jn(n){return ut.safeParse(n).success}function En(n){return Ve.safeParse(n).success}const Fe={VAT:18};function Pn(n){var e,t;return((e=n.discount)==null?void 0:e.type)==="percent"?n.price*(n.discount.value??100)/100:((t=n.discount)==null?void 0:t.type)==="number"?n.discount.value??0:0}function Rn(n){var e,t;if(((e=n.discount)==null?void 0:e.type)==="percent"){const r=n.price*n.discount.value/100;return n.price-r}return((t=n.discount)==null?void 0:t.type)==="number"?n.price-n.discount.value:n.price}function Mn({cart:n,discounts:e,store:t}){const{isVatIncludedInPrice:r}=t,a=n.map(d=>({amount:d.amount,product:{id:d.product.id,price:d.product.price}})),s=ct.calculateDiscounts(a,e),o=n.map((d,l)=>{const h=s.items[l];return{amount:d.amount,product:{...d.product},originalPrice:d.product.price,finalPrice:h?h.finalPrice:Rn(d.product),finalDiscount:h?h.finalDiscount:Pn(d.product)}}),c=o.reduce((d,l)=>{const{product:h,amount:k,finalPrice:T,finalDiscount:N}=l;let A=0;if(h.vat){let Le=0;if(r){const Vn=T*(Fe.VAT/(100+Fe.VAT));A=Number(Vn.toFixed(2)),A=A*k,Le=Number(A.toFixed(2))}else A=T*Fe.VAT/100,A=A*k,Le=Number(A.toFixed(2));d.vat=Number((d.vat+Le).toFixed(2))}const ze=Number(T.toFixed(2));return d.cost+=k*ze,d.discount+=N&&k*N,d.finalCost+=k*ze+(r?0:A),d.productsCost+=k*ze+(r?0:A),d.cost=Number(d.cost.toFixed(2)),d.discount=Number(d.discount.toFixed(2)),d.finalCost=Number(d.finalCost.toFixed(2)),d.productsCost=Number(d.productsCost.toFixed(2)),d},{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:o,...c}}const $n={firestore:{systemCollections:{stores:"STORES",companies:"COMPANIES"},storeCollections:{products:"products",profiles:"profiles",cart:"cart",clients:"clients",orders:"orders",categories:"categories",favorites:"favorites",payments:"payments",settings:"settings",discounts:"discounts",organizations:"organizations"},getPath:({companyId:n,storeId:e,collectionName:t,id:r})=>`${n}/${e}/${t}${r?`/${r}`:""}`,getDocPath:n=>`{companyId}/{storeId}/${n}/{id}`}};y.AddressSchema=nt,y.BaseCategorySchema=je,y.BundleDiscountStrategy=ot,y.CalculatedDataSchema=Ve,y.CartItemProductSchema=Pe,y.CartSchema=kn,y.CategorySchema=Ie,y.CompanySchema=wn,y.DeliveryNoteSchema=ut,y.DiscountConditionsSchema=st,y.DiscountEngine=ct,y.DiscountSchema=Nn,y.DiscountStrategyFactory=Me,y.DiscountVariantSchema=it,y.FavoriteProductSchema=Tn,y.FileSchema=gn,y.FirebaseAPI=$n,y.LocaleSchema=te,y.LocaleValueSchema=_n,y.NewOrganizationSchema=Dn,y.NewProductSchema=xn,y.OrderSchema=Cn,y.OrganizationSchema=dt,y.ProductSchema=Ee,y.ProfilePaymentTypeSchema=Re,y.ProfileSchema=rt,y.StoreSchema=In,y.TFlattenCategorySchema=bn,y.calculatePercentageDiscount=On,y.clientTypesSchema=at,y.createEmptyProfile=Sn,y.ensureNonNegative=Zn,y.formatCurrency=$e,y.formatCurrencyString=An,y.getCartCost=Mn,y.isCalculatedData=En,y.isDeliveryNote=jn,y.isFile=vn,y.notEmptyTextSchema=R,y.numericTextSchema=yn,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})});
|
|
2
2
|
//# sourceMappingURL=core.umd.js.map
|