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