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