@walkeros/server-destination-gcp 0.2.1 → 0.3.0

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/index.mjs CHANGED
@@ -1 +1 @@
1
- var e,t,a,r=Object.defineProperty,n=(e,t)=>{for(var a in t)r(e,a,{get:t[a],enumerable:!0})},s={};n(s,{BRAND:()=>Le,DIRTY:()=>x,EMPTY_PATH:()=>g,INVALID:()=>k,NEVER:()=>It,OK:()=>Z,ParseStatus:()=>b,Schema:()=>C,ZodAny:()=>ue,ZodArray:()=>me,ZodBigInt:()=>ne,ZodBoolean:()=>se,ZodBranded:()=>ze,ZodCatch:()=>Re,ZodDate:()=>ie,ZodDefault:()=>Me,ZodDiscriminatedUnion:()=>_e,ZodEffects:()=>Ie,ZodEnum:()=>je,ZodError:()=>u,ZodFirstPartyTypeKind:()=>Ke,ZodFunction:()=>Te,ZodIntersection:()=>ke,ZodIssueCode:()=>d,ZodLazy:()=>Oe,ZodLiteral:()=>Se,ZodMap:()=>we,ZodNaN:()=>Fe,ZodNativeEnum:()=>Ne,ZodNever:()=>pe,ZodNull:()=>ce,ZodNullable:()=>Ee,ZodNumber:()=>re,ZodObject:()=>ge,ZodOptional:()=>$e,ZodParsedType:()=>i,ZodPipeline:()=>De,ZodPromise:()=>Ce,ZodReadonly:()=>Ve,ZodRecord:()=>Ze,ZodSchema:()=>C,ZodSet:()=>Ae,ZodString:()=>te,ZodSymbol:()=>oe,ZodTransformer:()=>Ie,ZodTuple:()=>xe,ZodType:()=>C,ZodUndefined:()=>de,ZodUnion:()=>ye,ZodUnknown:()=>le,ZodVoid:()=>he,addIssueToContext:()=>y,any:()=>nt,array:()=>dt,bigint:()=>Ge,boolean:()=>Xe,coerce:()=>Ct,custom:()=>Be,date:()=>et,datetimeRegex:()=>Q,defaultErrorMap:()=>l,discriminatedUnion:()=>pt,effect:()=>wt,enum:()=>kt,function:()=>vt,getErrorMap:()=>m,getParsedType:()=>o,instanceof:()=>Je,intersection:()=>ht,isAborted:()=>w,isAsync:()=>O,isDirty:()=>A,isValid:()=>T,late:()=>We,lazy:()=>_t,literal:()=>bt,makeIssue:()=>f,map:()=>gt,nan:()=>Qe,nativeEnum:()=>xt,never:()=>it,null:()=>rt,nullable:()=>Tt,number:()=>Ye,object:()=>ct,objectUtil:()=>a,oboolean:()=>Nt,onumber:()=>jt,optional:()=>At,ostring:()=>Pt,pipeline:()=>St,preprocess:()=>Ot,promise:()=>Zt,quotelessJson:()=>c,record:()=>ft,set:()=>yt,setErrorMap:()=>h,strictObject:()=>ut,string:()=>He,symbol:()=>tt,transformer:()=>wt,tuple:()=>mt,undefined:()=>at,union:()=>lt,unknown:()=>st,util:()=>e,void:()=>ot}),(t=e||(e={})).assertEqual=e=>{},t.assertIs=function(e){},t.assertNever=function(e){throw new Error},t.arrayToEnum=e=>{const t={};for(const a of e)t[a]=a;return t},t.getValidEnumValues=e=>{const a=t.objectKeys(e).filter(t=>"number"!=typeof e[e[t]]),r={};for(const t of a)r[t]=e[t];return t.objectValues(r)},t.objectValues=e=>t.objectKeys(e).map(function(t){return e[t]}),t.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.push(a);return t},t.find=(e,t)=>{for(const a of e)if(t(a))return a},t.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,t.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},t.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t,(a||(a={})).mergeShapes=(e,t)=>({...e,...t});var i=e.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),o=e=>{switch(typeof e){case"undefined":return i.undefined;case"string":return i.string;case"number":return Number.isNaN(e)?i.nan:i.number;case"boolean":return i.boolean;case"function":return i.function;case"bigint":return i.bigint;case"symbol":return i.symbol;case"object":return Array.isArray(e)?i.array:null===e?i.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?i.promise:"undefined"!=typeof Map&&e instanceof Map?i.map:"undefined"!=typeof Set&&e instanceof Set?i.set:"undefined"!=typeof Date&&e instanceof Date?i.date:i.object;default:return i.unknown}},d=e.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"]),c=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),u=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};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(e){return e.message},a={_errors:[]},r=e=>{for(const n of e.issues)if("invalid_union"===n.code)n.unionErrors.map(r);else if("invalid_return_type"===n.code)r(n.returnTypeError);else if("invalid_arguments"===n.code)r(n.argumentsError);else if(0===n.path.length)a._errors.push(t(n));else{let e=a,r=0;for(;r<n.path.length;){const a=n.path[r];r===n.path.length-1?(e[a]=e[a]||{_errors:[]},e[a]._errors.push(t(n))):e[a]=e[a]||{_errors:[]},e=e[a],r++}}};return r(this),a}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,e.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t={},a=[];for(const r of this.issues)if(r.path.length>0){const a=r.path[0];t[a]=t[a]||[],t[a].push(e(r))}else a.push(e(r));return{formErrors:a,fieldErrors:t}}get formErrors(){return this.flatten()}};u.create=e=>new u(e);var l=(t,a)=>{let r;switch(t.code){case d.invalid_type:r=t.received===i.undefined?"Required":`Expected ${t.expected}, received ${t.received}`;break;case d.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,e.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:r=`Unrecognized key(s) in object: ${e.joinValues(t.keys,", ")}`;break;case d.invalid_union:r="Invalid input";break;case d.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${e.joinValues(t.options)}`;break;case d.invalid_enum_value:r=`Invalid enum value. Expected ${e.joinValues(t.options)}, received '${t.received}'`;break;case d.invalid_arguments:r="Invalid function arguments";break;case d.invalid_return_type:r="Invalid function return type";break;case d.invalid_date:r="Invalid date";break;case d.invalid_string:"object"==typeof t.validation?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,"number"==typeof t.validation.position&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:e.assertNever(t.validation):r="regex"!==t.validation?`Invalid ${t.validation}`:"Invalid";break;case d.too_small:r="array"===t.type?`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:"string"===t.type?`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:"number"===t.type||"bigint"===t.type?`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:"date"===t.type?`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:"Invalid input";break;case d.too_big:r="array"===t.type?`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:"string"===t.type?`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:"number"===t.type?`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:"bigint"===t.type?`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:"date"===t.type?`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:"Invalid input";break;case d.custom:r="Invalid input";break;case d.invalid_intersection_types:r="Intersection results could not be merged";break;case d.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case d.not_finite:r="Number must be finite";break;default:r=a.defaultError,e.assertNever(t)}return{message:r}},p=l;function h(e){p=e}function m(){return p}var f=e=>{const{data:t,path:a,errorMaps:r,issueData:n}=e,s=[...a,...n.path||[]],i={...n,path:s};if(void 0!==n.message)return{...n,path:s,message:n.message};let o="";const d=r.filter(e=>!!e).slice().reverse();for(const e of d)o=e(i,{data:t,defaultError:o}).message;return{...n,path:s,message:o}},g=[];function y(e,t){const a=m(),r=f({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,a,a===l?void 0:l].filter(e=>!!e)});e.common.issues.push(r)}var v,_,b=class e{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const a=[];for(const r of t){if("aborted"===r.status)return k;"dirty"===r.status&&e.dirty(),a.push(r.value)}return{status:e.value,value:a}}static async mergeObjectAsync(t,a){const r=[];for(const e of a){const t=await e.key,a=await e.value;r.push({key:t,value:a})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){const a={};for(const r of t){const{key:t,value:n}=r;if("aborted"===t.status)return k;if("aborted"===n.status)return k;"dirty"===t.status&&e.dirty(),"dirty"===n.status&&e.dirty(),"__proto__"===t.value||void 0===n.value&&!r.alwaysSet||(a[t.value]=n.value)}return{status:e.value,value:a}}},k=Object.freeze({status:"aborted"}),x=e=>({status:"dirty",value:e}),Z=e=>({status:"valid",value:e}),w=e=>"aborted"===e.status,A=e=>"dirty"===e.status,T=e=>"valid"===e.status,O=e=>"undefined"!=typeof Promise&&e instanceof Promise;(_=v||(v={})).errToObj=e=>"string"==typeof e?{message:e}:e||{},_.toString=e=>"string"==typeof e?e:null==e?void 0:e.message;var S=class{constructor(e,t,a,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=a,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},P=(e,t)=>{if(T(t))return{success:!0,data:t.value};if(!e.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 u(e.common.issues);return this._error=t,this._error}}};function j(e){if(!e)return{};const{errorMap:t,invalid_type_error:a,required_error:r,description:n}=e;if(t&&(a||r))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:n};return{errorMap:(t,n)=>{var s,i;const{message:o}=e;return"invalid_enum_value"===t.code?{message:null!=o?o:n.defaultError}:void 0===n.data?{message:null!=(s=null!=o?o:r)?s:n.defaultError}:"invalid_type"!==t.code?{message:n.defaultError}:{message:null!=(i=null!=o?o:a)?i:n.defaultError}},description:n}}var N,C=class{get description(){return this._def.description}_getType(e){return o(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:o(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new b,ctx:{common:e.parent.common,data:e.data,parsedType:o(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(O(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 a=this.safeParse(e,t);if(a.success)return a.data;throw a.error}safeParse(e,t){var a;const r={common:{issues:[],async:null!=(a=null==t?void 0:t.async)&&a,contextualErrorMap:null==t?void 0:t.errorMap},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:o(e)},n=this._parseSync({data:e,path:r.path,parent:r});return P(r,n)}"~validate"(e){var t,a;const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:o(e)};if(!this["~standard"].async)try{const t=this._parseSync({data:e,path:[],parent:r});return T(t)?{value:t.value}:{issues:r.common.issues}}catch(e){(null==(a=null==(t=null==e?void 0:e.message)?void 0:t.toLowerCase())?void 0:a.includes("encountered"))&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(e=>T(e)?{value:e.value}:{issues:r.common.issues})}async parseAsync(e,t){const a=await this.safeParseAsync(e,t);if(a.success)return a.data;throw a.error}async safeParseAsync(e,t){const a={common:{issues:[],contextualErrorMap:null==t?void 0:t.errorMap,async:!0},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:o(e)},r=this._parse({data:e,path:a.path,parent:a}),n=await(O(r)?r:Promise.resolve(r));return P(a,n)}refine(e,t){const a=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement((t,r)=>{const n=e(t),s=()=>r.addIssue({code:d.custom,...a(t)});return"undefined"!=typeof Promise&&n instanceof Promise?n.then(e=>!!e||(s(),!1)):!!n||(s(),!1)})}refinement(e,t){return this._refinement((a,r)=>!!e(a)||(r.addIssue("function"==typeof t?t(a,r):t),!1))}_refinement(e){return new Ie({schema:this,typeName:Ke.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:e=>this["~validate"](e)}}optional(){return $e.create(this,this._def)}nullable(){return Ee.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return me.create(this)}promise(){return Ce.create(this,this._def)}or(e){return ye.create([this,e],this._def)}and(e){return ke.create(this,e,this._def)}transform(e){return new Ie({...j(this._def),schema:this,typeName:Ke.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new Me({...j(this._def),innerType:this,defaultValue:t,typeName:Ke.ZodDefault})}brand(){return new ze({typeName:Ke.ZodBranded,type:this,...j(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new Re({...j(this._def),innerType:this,catchValue:t,typeName:Ke.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return De.create(this,e)}readonly(){return Ve.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},I=/^c[^\s-]{8,}$/i,$=/^[0-9a-z]+$/,E=/^[0-9A-HJKMNP-TV-Z]{26}$/i,M=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,R=/^[a-z0-9_-]{21}$/i,F=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,L=/^[-+]?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)?)??$/,z=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,D=/^(?:(?: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])$/,V=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,U=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,B=/^(([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])$/,K=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,q=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,W="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",J=new RegExp(`^${W}$`);function H(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e.precision?"+":"?"}`}function Y(e){return new RegExp(`^${H(e)}$`)}function Q(e){let t=`${W}T${H(e)}`;const a=[];return a.push(e.local?"Z?":"Z"),e.offset&&a.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${a.join("|")})`,new RegExp(`^${t}$`)}function G(e,t){return!("v4"!==t&&t||!D.test(e))||!("v6"!==t&&t||!U.test(e))}function X(e,t){if(!F.test(e))return!1;try{const[a]=e.split(".");if(!a)return!1;const r=a.replace(/-/g,"+").replace(/_/g,"/").padEnd(a.length+(4-a.length%4)%4,"="),n=JSON.parse(atob(r));return"object"==typeof n&&null!==n&&((!("typ"in n)||"JWT"===(null==n?void 0:n.typ))&&(!!n.alg&&(!t||n.alg===t)))}catch(e){return!1}}function ee(e,t){return!("v4"!==t&&t||!V.test(e))||!("v6"!==t&&t||!B.test(e))}var te=class t extends C{_parse(t){this._def.coerce&&(t.data=String(t.data));if(this._getType(t)!==i.string){const e=this._getOrReturnCtx(t);return y(e,{code:d.invalid_type,expected:i.string,received:e.parsedType}),k}const a=new b;let r;for(const n of this._def.checks)if("min"===n.kind)t.data.length<n.value&&(r=this._getOrReturnCtx(t,r),y(r,{code:d.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),a.dirty());else if("max"===n.kind)t.data.length>n.value&&(r=this._getOrReturnCtx(t,r),y(r,{code:d.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),a.dirty());else if("length"===n.kind){const e=t.data.length>n.value,s=t.data.length<n.value;(e||s)&&(r=this._getOrReturnCtx(t,r),e?y(r,{code:d.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):s&&y(r,{code:d.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),a.dirty())}else if("email"===n.kind)z.test(t.data)||(r=this._getOrReturnCtx(t,r),y(r,{validation:"email",code:d.invalid_string,message:n.message}),a.dirty());else if("emoji"===n.kind)N||(N=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),N.test(t.data)||(r=this._getOrReturnCtx(t,r),y(r,{validation:"emoji",code:d.invalid_string,message:n.message}),a.dirty());else if("uuid"===n.kind)M.test(t.data)||(r=this._getOrReturnCtx(t,r),y(r,{validation:"uuid",code:d.invalid_string,message:n.message}),a.dirty());else if("nanoid"===n.kind)R.test(t.data)||(r=this._getOrReturnCtx(t,r),y(r,{validation:"nanoid",code:d.invalid_string,message:n.message}),a.dirty());else if("cuid"===n.kind)I.test(t.data)||(r=this._getOrReturnCtx(t,r),y(r,{validation:"cuid",code:d.invalid_string,message:n.message}),a.dirty());else if("cuid2"===n.kind)$.test(t.data)||(r=this._getOrReturnCtx(t,r),y(r,{validation:"cuid2",code:d.invalid_string,message:n.message}),a.dirty());else if("ulid"===n.kind)E.test(t.data)||(r=this._getOrReturnCtx(t,r),y(r,{validation:"ulid",code:d.invalid_string,message:n.message}),a.dirty());else if("url"===n.kind)try{new URL(t.data)}catch(e){r=this._getOrReturnCtx(t,r),y(r,{validation:"url",code:d.invalid_string,message:n.message}),a.dirty()}else if("regex"===n.kind){n.regex.lastIndex=0;n.regex.test(t.data)||(r=this._getOrReturnCtx(t,r),y(r,{validation:"regex",code:d.invalid_string,message:n.message}),a.dirty())}else if("trim"===n.kind)t.data=t.data.trim();else if("includes"===n.kind)t.data.includes(n.value,n.position)||(r=this._getOrReturnCtx(t,r),y(r,{code:d.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),a.dirty());else if("toLowerCase"===n.kind)t.data=t.data.toLowerCase();else if("toUpperCase"===n.kind)t.data=t.data.toUpperCase();else if("startsWith"===n.kind)t.data.startsWith(n.value)||(r=this._getOrReturnCtx(t,r),y(r,{code:d.invalid_string,validation:{startsWith:n.value},message:n.message}),a.dirty());else if("endsWith"===n.kind)t.data.endsWith(n.value)||(r=this._getOrReturnCtx(t,r),y(r,{code:d.invalid_string,validation:{endsWith:n.value},message:n.message}),a.dirty());else if("datetime"===n.kind){Q(n).test(t.data)||(r=this._getOrReturnCtx(t,r),y(r,{code:d.invalid_string,validation:"datetime",message:n.message}),a.dirty())}else if("date"===n.kind){J.test(t.data)||(r=this._getOrReturnCtx(t,r),y(r,{code:d.invalid_string,validation:"date",message:n.message}),a.dirty())}else if("time"===n.kind){Y(n).test(t.data)||(r=this._getOrReturnCtx(t,r),y(r,{code:d.invalid_string,validation:"time",message:n.message}),a.dirty())}else"duration"===n.kind?L.test(t.data)||(r=this._getOrReturnCtx(t,r),y(r,{validation:"duration",code:d.invalid_string,message:n.message}),a.dirty()):"ip"===n.kind?G(t.data,n.version)||(r=this._getOrReturnCtx(t,r),y(r,{validation:"ip",code:d.invalid_string,message:n.message}),a.dirty()):"jwt"===n.kind?X(t.data,n.alg)||(r=this._getOrReturnCtx(t,r),y(r,{validation:"jwt",code:d.invalid_string,message:n.message}),a.dirty()):"cidr"===n.kind?ee(t.data,n.version)||(r=this._getOrReturnCtx(t,r),y(r,{validation:"cidr",code:d.invalid_string,message:n.message}),a.dirty()):"base64"===n.kind?K.test(t.data)||(r=this._getOrReturnCtx(t,r),y(r,{validation:"base64",code:d.invalid_string,message:n.message}),a.dirty()):"base64url"===n.kind?q.test(t.data)||(r=this._getOrReturnCtx(t,r),y(r,{validation:"base64url",code:d.invalid_string,message:n.message}),a.dirty()):e.assertNever(n);return{status:a.value,value:t.data}}_regex(e,t,a){return this.refinement(t=>e.test(t),{validation:t,code:d.invalid_string,...v.errToObj(a)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...v.errToObj(e)})}url(e){return this._addCheck({kind:"url",...v.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...v.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...v.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...v.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...v.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...v.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...v.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...v.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...v.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...v.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...v.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...v.errToObj(e)})}datetime(e){var t,a;return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,offset:null!=(t=null==e?void 0:e.offset)&&t,local:null!=(a=null==e?void 0:e.local)&&a,...v.errToObj(null==e?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,...v.errToObj(null==e?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...v.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...v.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:null==t?void 0:t.position,...v.errToObj(null==t?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...v.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...v.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...v.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...v.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...v.errToObj(t)})}nonempty(e){return this.min(1,v.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>"datetime"===e.kind)}get isDate(){return!!this._def.checks.find(e=>"date"===e.kind)}get isTime(){return!!this._def.checks.find(e=>"time"===e.kind)}get isDuration(){return!!this._def.checks.find(e=>"duration"===e.kind)}get isEmail(){return!!this._def.checks.find(e=>"email"===e.kind)}get isURL(){return!!this._def.checks.find(e=>"url"===e.kind)}get isEmoji(){return!!this._def.checks.find(e=>"emoji"===e.kind)}get isUUID(){return!!this._def.checks.find(e=>"uuid"===e.kind)}get isNANOID(){return!!this._def.checks.find(e=>"nanoid"===e.kind)}get isCUID(){return!!this._def.checks.find(e=>"cuid"===e.kind)}get isCUID2(){return!!this._def.checks.find(e=>"cuid2"===e.kind)}get isULID(){return!!this._def.checks.find(e=>"ulid"===e.kind)}get isIP(){return!!this._def.checks.find(e=>"ip"===e.kind)}get isCIDR(){return!!this._def.checks.find(e=>"cidr"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get isBase64url(){return!!this._def.checks.find(e=>"base64url"===e.kind)}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}};function ae(e,t){const a=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,n=a>r?a:r;return Number.parseInt(e.toFixed(n).replace(".",""))%Number.parseInt(t.toFixed(n).replace(".",""))/10**n}te.create=e=>{var t;return new te({checks:[],typeName:Ke.ZodString,coerce:null!=(t=null==e?void 0:e.coerce)&&t,...j(e)})};var re=class t extends C{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){this._def.coerce&&(t.data=Number(t.data));if(this._getType(t)!==i.number){const e=this._getOrReturnCtx(t);return y(e,{code:d.invalid_type,expected:i.number,received:e.parsedType}),k}let a;const r=new b;for(const n of this._def.checks)if("int"===n.kind)e.isInteger(t.data)||(a=this._getOrReturnCtx(t,a),y(a,{code:d.invalid_type,expected:"integer",received:"float",message:n.message}),r.dirty());else if("min"===n.kind){(n.inclusive?t.data<n.value:t.data<=n.value)&&(a=this._getOrReturnCtx(t,a),y(a,{code:d.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty())}else if("max"===n.kind){(n.inclusive?t.data>n.value:t.data>=n.value)&&(a=this._getOrReturnCtx(t,a),y(a,{code:d.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty())}else"multipleOf"===n.kind?0!==ae(t.data,n.value)&&(a=this._getOrReturnCtx(t,a),y(a,{code:d.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):"finite"===n.kind?Number.isFinite(t.data)||(a=this._getOrReturnCtx(t,a),y(a,{code:d.not_finite,message:n.message}),r.dirty()):e.assertNever(n);return{status:r.value,value:t.data}}gte(e,t){return this.setLimit("min",e,!0,v.toString(t))}gt(e,t){return this.setLimit("min",e,!1,v.toString(t))}lte(e,t){return this.setLimit("max",e,!0,v.toString(t))}lt(e,t){return this.setLimit("max",e,!1,v.toString(t))}setLimit(e,a,r,n){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:a,inclusive:r,message:v.toString(n)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:v.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:v.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:v.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:v.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:v.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(t=>"int"===t.kind||"multipleOf"===t.kind&&e.isInteger(t.value))}get isFinite(){let e=null,t=null;for(const a of this._def.checks){if("finite"===a.kind||"int"===a.kind||"multipleOf"===a.kind)return!0;"min"===a.kind?(null===t||a.value>t)&&(t=a.value):"max"===a.kind&&(null===e||a.value<e)&&(e=a.value)}return Number.isFinite(t)&&Number.isFinite(e)}};re.create=e=>new re({checks:[],typeName:Ke.ZodNumber,coerce:(null==e?void 0:e.coerce)||!1,...j(e)});var ne=class t extends C{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch(e){return this._getInvalidInput(t)}if(this._getType(t)!==i.bigint)return this._getInvalidInput(t);let a;const r=new b;for(const n of this._def.checks)if("min"===n.kind){(n.inclusive?t.data<n.value:t.data<=n.value)&&(a=this._getOrReturnCtx(t,a),y(a,{code:d.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),r.dirty())}else if("max"===n.kind){(n.inclusive?t.data>n.value:t.data>=n.value)&&(a=this._getOrReturnCtx(t,a),y(a,{code:d.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),r.dirty())}else"multipleOf"===n.kind?t.data%n.value!==BigInt(0)&&(a=this._getOrReturnCtx(t,a),y(a,{code:d.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):e.assertNever(n);return{status:r.value,value:t.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return y(t,{code:d.invalid_type,expected:i.bigint,received:t.parsedType}),k}gte(e,t){return this.setLimit("min",e,!0,v.toString(t))}gt(e,t){return this.setLimit("min",e,!1,v.toString(t))}lte(e,t){return this.setLimit("max",e,!0,v.toString(t))}lt(e,t){return this.setLimit("max",e,!1,v.toString(t))}setLimit(e,a,r,n){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:a,inclusive:r,message:v.toString(n)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:v.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}};ne.create=e=>{var t;return new ne({checks:[],typeName:Ke.ZodBigInt,coerce:null!=(t=null==e?void 0:e.coerce)&&t,...j(e)})};var se=class extends C{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==i.boolean){const t=this._getOrReturnCtx(e);return y(t,{code:d.invalid_type,expected:i.boolean,received:t.parsedType}),k}return Z(e.data)}};se.create=e=>new se({typeName:Ke.ZodBoolean,coerce:(null==e?void 0:e.coerce)||!1,...j(e)});var ie=class t extends C{_parse(t){this._def.coerce&&(t.data=new Date(t.data));if(this._getType(t)!==i.date){const e=this._getOrReturnCtx(t);return y(e,{code:d.invalid_type,expected:i.date,received:e.parsedType}),k}if(Number.isNaN(t.data.getTime())){return y(this._getOrReturnCtx(t),{code:d.invalid_date}),k}const a=new b;let r;for(const n of this._def.checks)"min"===n.kind?t.data.getTime()<n.value&&(r=this._getOrReturnCtx(t,r),y(r,{code:d.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),a.dirty()):"max"===n.kind?t.data.getTime()>n.value&&(r=this._getOrReturnCtx(t,r),y(r,{code:d.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),a.dirty()):e.assertNever(n);return{status:a.value,value:new Date(t.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:v.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:v.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}};ie.create=e=>new ie({checks:[],coerce:(null==e?void 0:e.coerce)||!1,typeName:Ke.ZodDate,...j(e)});var oe=class extends C{_parse(e){if(this._getType(e)!==i.symbol){const t=this._getOrReturnCtx(e);return y(t,{code:d.invalid_type,expected:i.symbol,received:t.parsedType}),k}return Z(e.data)}};oe.create=e=>new oe({typeName:Ke.ZodSymbol,...j(e)});var de=class extends C{_parse(e){if(this._getType(e)!==i.undefined){const t=this._getOrReturnCtx(e);return y(t,{code:d.invalid_type,expected:i.undefined,received:t.parsedType}),k}return Z(e.data)}};de.create=e=>new de({typeName:Ke.ZodUndefined,...j(e)});var ce=class extends C{_parse(e){if(this._getType(e)!==i.null){const t=this._getOrReturnCtx(e);return y(t,{code:d.invalid_type,expected:i.null,received:t.parsedType}),k}return Z(e.data)}};ce.create=e=>new ce({typeName:Ke.ZodNull,...j(e)});var ue=class extends C{constructor(){super(...arguments),this._any=!0}_parse(e){return Z(e.data)}};ue.create=e=>new ue({typeName:Ke.ZodAny,...j(e)});var le=class extends C{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Z(e.data)}};le.create=e=>new le({typeName:Ke.ZodUnknown,...j(e)});var pe=class extends C{_parse(e){const t=this._getOrReturnCtx(e);return y(t,{code:d.invalid_type,expected:i.never,received:t.parsedType}),k}};pe.create=e=>new pe({typeName:Ke.ZodNever,...j(e)});var he=class extends C{_parse(e){if(this._getType(e)!==i.undefined){const t=this._getOrReturnCtx(e);return y(t,{code:d.invalid_type,expected:i.void,received:t.parsedType}),k}return Z(e.data)}};he.create=e=>new he({typeName:Ke.ZodVoid,...j(e)});var me=class e extends C{_parse(e){const{ctx:t,status:a}=this._processInputParams(e),r=this._def;if(t.parsedType!==i.array)return y(t,{code:d.invalid_type,expected:i.array,received:t.parsedType}),k;if(null!==r.exactLength){const e=t.data.length>r.exactLength.value,n=t.data.length<r.exactLength.value;(e||n)&&(y(t,{code:e?d.too_big:d.too_small,minimum:n?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),a.dirty())}if(null!==r.minLength&&t.data.length<r.minLength.value&&(y(t,{code:d.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),a.dirty()),null!==r.maxLength&&t.data.length>r.maxLength.value&&(y(t,{code:d.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),a.dirty()),t.common.async)return Promise.all([...t.data].map((e,a)=>r.type._parseAsync(new S(t,e,t.path,a)))).then(e=>b.mergeArray(a,e));const n=[...t.data].map((e,a)=>r.type._parseSync(new S(t,e,t.path,a)));return b.mergeArray(a,n)}get element(){return this._def.type}min(t,a){return new e({...this._def,minLength:{value:t,message:v.toString(a)}})}max(t,a){return new e({...this._def,maxLength:{value:t,message:v.toString(a)}})}length(t,a){return new e({...this._def,exactLength:{value:t,message:v.toString(a)}})}nonempty(e){return this.min(1,e)}};function fe(e){if(e instanceof ge){const t={};for(const a in e.shape){const r=e.shape[a];t[a]=$e.create(fe(r))}return new ge({...e._def,shape:()=>t})}return e instanceof me?new me({...e._def,type:fe(e.element)}):e instanceof $e?$e.create(fe(e.unwrap())):e instanceof Ee?Ee.create(fe(e.unwrap())):e instanceof xe?xe.create(e.items.map(e=>fe(e))):e}me.create=(e,t)=>new me({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Ke.ZodArray,...j(t)});var ge=class t extends C{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const t=this._def.shape(),a=e.objectKeys(t);return this._cached={shape:t,keys:a},this._cached}_parse(e){if(this._getType(e)!==i.object){const t=this._getOrReturnCtx(e);return y(t,{code:d.invalid_type,expected:i.object,received:t.parsedType}),k}const{status:t,ctx:a}=this._processInputParams(e),{shape:r,keys:n}=this._getCached(),s=[];if(!(this._def.catchall instanceof pe&&"strip"===this._def.unknownKeys))for(const e in a.data)n.includes(e)||s.push(e);const o=[];for(const e of n){const t=r[e],n=a.data[e];o.push({key:{status:"valid",value:e},value:t._parse(new S(a,n,a.path,e)),alwaysSet:e in a.data})}if(this._def.catchall instanceof pe){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of s)o.push({key:{status:"valid",value:e},value:{status:"valid",value:a.data[e]}});else if("strict"===e)s.length>0&&(y(a,{code:d.unrecognized_keys,keys:s}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of s){const r=a.data[t];o.push({key:{status:"valid",value:t},value:e._parse(new S(a,r,a.path,t)),alwaysSet:t in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const e=[];for(const t of o){const a=await t.key,r=await t.value;e.push({key:a,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>b.mergeObjectSync(t,e)):b.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return v.errToObj,new t({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,a)=>{var r,n,s,i;const o=null!=(s=null==(n=(r=this._def).errorMap)?void 0:n.call(r,t,a).message)?s:a.defaultError;return"unrecognized_keys"===t.code?{message:null!=(i=v.errToObj(e).message)?i:o}:{message:o}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ke.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new t({...this._def,catchall:e})}pick(a){const r={};for(const t of e.objectKeys(a))a[t]&&this.shape[t]&&(r[t]=this.shape[t]);return new t({...this._def,shape:()=>r})}omit(a){const r={};for(const t of e.objectKeys(this.shape))a[t]||(r[t]=this.shape[t]);return new t({...this._def,shape:()=>r})}deepPartial(){return fe(this)}partial(a){const r={};for(const t of e.objectKeys(this.shape)){const e=this.shape[t];a&&!a[t]?r[t]=e:r[t]=e.optional()}return new t({...this._def,shape:()=>r})}required(a){const r={};for(const t of e.objectKeys(this.shape))if(a&&!a[t])r[t]=this.shape[t];else{let e=this.shape[t];for(;e instanceof $e;)e=e._def.innerType;r[t]=e}return new t({...this._def,shape:()=>r})}keyof(){return Pe(e.objectKeys(this.shape))}};ge.create=(e,t)=>new ge({shape:()=>e,unknownKeys:"strip",catchall:pe.create(),typeName:Ke.ZodObject,...j(t)}),ge.strictCreate=(e,t)=>new ge({shape:()=>e,unknownKeys:"strict",catchall:pe.create(),typeName:Ke.ZodObject,...j(t)}),ge.lazycreate=(e,t)=>new ge({shape:e,unknownKeys:"strip",catchall:pe.create(),typeName:Ke.ZodObject,...j(t)});var ye=class extends C{_parse(e){const{ctx:t}=this._processInputParams(e),a=this._def.options;if(t.common.async)return Promise.all(a.map(async e=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const a of e)if("dirty"===a.result.status)return t.common.issues.push(...a.ctx.common.issues),a.result;const a=e.map(e=>new u(e.ctx.common.issues));return y(t,{code:d.invalid_union,unionErrors:a}),k});{let e;const r=[];for(const n of a){const a={...t,common:{...t.common,issues:[]},parent:null},s=n._parseSync({data:t.data,path:t.path,parent:a});if("valid"===s.status)return s;"dirty"!==s.status||e||(e={result:s,ctx:a}),a.common.issues.length&&r.push(a.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const n=r.map(e=>new u(e));return y(t,{code:d.invalid_union,unionErrors:n}),k}}get options(){return this._def.options}};ye.create=(e,t)=>new ye({options:e,typeName:Ke.ZodUnion,...j(t)});var ve=t=>t instanceof Oe?ve(t.schema):t instanceof Ie?ve(t.innerType()):t instanceof Se?[t.value]:t instanceof je?t.options:t instanceof Ne?e.objectValues(t.enum):t instanceof Me?ve(t._def.innerType):t instanceof de?[void 0]:t instanceof ce?[null]:t instanceof $e?[void 0,...ve(t.unwrap())]:t instanceof Ee?[null,...ve(t.unwrap())]:t instanceof ze||t instanceof Ve?ve(t.unwrap()):t instanceof Re?ve(t._def.innerType):[],_e=class e extends C{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==i.object)return y(t,{code:d.invalid_type,expected:i.object,received:t.parsedType}),k;const a=this.discriminator,r=t.data[a],n=this.optionsMap.get(r);return n?t.common.async?n._parseAsync({data:t.data,path:t.path,parent:t}):n._parseSync({data:t.data,path:t.path,parent:t}):(y(t,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),k)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,a,r){const n=new Map;for(const e of a){const a=ve(e.shape[t]);if(!a.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const r of a){if(n.has(r))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);n.set(r,e)}}return new e({typeName:Ke.ZodDiscriminatedUnion,discriminator:t,options:a,optionsMap:n,...j(r)})}};function be(t,a){const r=o(t),n=o(a);if(t===a)return{valid:!0,data:t};if(r===i.object&&n===i.object){const r=e.objectKeys(a),n=e.objectKeys(t).filter(e=>-1!==r.indexOf(e)),s={...t,...a};for(const e of n){const r=be(t[e],a[e]);if(!r.valid)return{valid:!1};s[e]=r.data}return{valid:!0,data:s}}if(r===i.array&&n===i.array){if(t.length!==a.length)return{valid:!1};const e=[];for(let r=0;r<t.length;r++){const n=be(t[r],a[r]);if(!n.valid)return{valid:!1};e.push(n.data)}return{valid:!0,data:e}}return r===i.date&&n===i.date&&+t===+a?{valid:!0,data:t}:{valid:!1}}var ke=class extends C{_parse(e){const{status:t,ctx:a}=this._processInputParams(e),r=(e,r)=>{if(w(e)||w(r))return k;const n=be(e.value,r.value);return n.valid?((A(e)||A(r))&&t.dirty(),{status:t.value,value:n.data}):(y(a,{code:d.invalid_intersection_types}),k)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}};ke.create=(e,t,a)=>new ke({left:e,right:t,typeName:Ke.ZodIntersection,...j(a)});var xe=class e extends C{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==i.array)return y(a,{code:d.invalid_type,expected:i.array,received:a.parsedType}),k;if(a.data.length<this._def.items.length)return y(a,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),k;!this._def.rest&&a.data.length>this._def.items.length&&(y(a,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...a.data].map((e,t)=>{const r=this._def.items[t]||this._def.rest;return r?r._parse(new S(a,e,a.path,t)):null}).filter(e=>!!e);return a.common.async?Promise.all(r).then(e=>b.mergeArray(t,e)):b.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};xe.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new xe({items:e,typeName:Ke.ZodTuple,rest:null,...j(t)})};var Ze=class e extends C{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==i.object)return y(a,{code:d.invalid_type,expected:i.object,received:a.parsedType}),k;const r=[],n=this._def.keyType,s=this._def.valueType;for(const e in a.data)r.push({key:n._parse(new S(a,e,a.path,e)),value:s._parse(new S(a,a.data[e],a.path,e)),alwaysSet:e in a.data});return a.common.async?b.mergeObjectAsync(t,r):b.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,a,r){return new e(a instanceof C?{keyType:t,valueType:a,typeName:Ke.ZodRecord,...j(r)}:{keyType:te.create(),valueType:t,typeName:Ke.ZodRecord,...j(a)})}},we=class extends C{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==i.map)return y(a,{code:d.invalid_type,expected:i.map,received:a.parsedType}),k;const r=this._def.keyType,n=this._def.valueType,s=[...a.data.entries()].map(([e,t],s)=>({key:r._parse(new S(a,e,a.path,[s,"key"])),value:n._parse(new S(a,t,a.path,[s,"value"]))}));if(a.common.async){const e=new Map;return Promise.resolve().then(async()=>{for(const a of s){const r=await a.key,n=await a.value;if("aborted"===r.status||"aborted"===n.status)return k;"dirty"!==r.status&&"dirty"!==n.status||t.dirty(),e.set(r.value,n.value)}return{status:t.value,value:e}})}{const e=new Map;for(const a of s){const r=a.key,n=a.value;if("aborted"===r.status||"aborted"===n.status)return k;"dirty"!==r.status&&"dirty"!==n.status||t.dirty(),e.set(r.value,n.value)}return{status:t.value,value:e}}}};we.create=(e,t,a)=>new we({valueType:t,keyType:e,typeName:Ke.ZodMap,...j(a)});var Ae=class e extends C{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==i.set)return y(a,{code:d.invalid_type,expected:i.set,received:a.parsedType}),k;const r=this._def;null!==r.minSize&&a.data.size<r.minSize.value&&(y(a,{code:d.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),null!==r.maxSize&&a.data.size>r.maxSize.value&&(y(a,{code:d.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const n=this._def.valueType;function s(e){const a=new Set;for(const r of e){if("aborted"===r.status)return k;"dirty"===r.status&&t.dirty(),a.add(r.value)}return{status:t.value,value:a}}const o=[...a.data.values()].map((e,t)=>n._parse(new S(a,e,a.path,t)));return a.common.async?Promise.all(o).then(e=>s(e)):s(o)}min(t,a){return new e({...this._def,minSize:{value:t,message:v.toString(a)}})}max(t,a){return new e({...this._def,maxSize:{value:t,message:v.toString(a)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Ae.create=(e,t)=>new Ae({valueType:e,minSize:null,maxSize:null,typeName:Ke.ZodSet,...j(t)});var Te=class e extends C{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==i.function)return y(t,{code:d.invalid_type,expected:i.function,received:t.parsedType}),k;function a(e,a){return f({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,m(),l].filter(e=>!!e),issueData:{code:d.invalid_arguments,argumentsError:a}})}function r(e,a){return f({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,m(),l].filter(e=>!!e),issueData:{code:d.invalid_return_type,returnTypeError:a}})}const n={errorMap:t.common.contextualErrorMap},s=t.data;if(this._def.returns instanceof Ce){const e=this;return Z(async function(...t){const i=new u([]),o=await e._def.args.parseAsync(t,n).catch(e=>{throw i.addIssue(a(t,e)),i}),d=await Reflect.apply(s,this,o);return await e._def.returns._def.type.parseAsync(d,n).catch(e=>{throw i.addIssue(r(d,e)),i})})}{const e=this;return Z(function(...t){const i=e._def.args.safeParse(t,n);if(!i.success)throw new u([a(t,i.error)]);const o=Reflect.apply(s,this,i.data),d=e._def.returns.safeParse(o,n);if(!d.success)throw new u([r(o,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:xe.create(t).rest(le.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,a,r){return new e({args:t||xe.create([]).rest(le.create()),returns:a||le.create(),typeName:Ke.ZodFunction,...j(r)})}},Oe=class extends C{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})}};Oe.create=(e,t)=>new Oe({getter:e,typeName:Ke.ZodLazy,...j(t)});var Se=class extends C{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return y(t,{received:t.data,code:d.invalid_literal,expected:this._def.value}),k}return{status:"valid",value:e.data}}get value(){return this._def.value}};function Pe(e,t){return new je({values:e,typeName:Ke.ZodEnum,...j(t)})}Se.create=(e,t)=>new Se({value:e,typeName:Ke.ZodLiteral,...j(t)});var je=class t extends C{_parse(t){if("string"!=typeof t.data){const a=this._getOrReturnCtx(t),r=this._def.values;return y(a,{expected:e.joinValues(r),received:a.parsedType,code:d.invalid_type}),k}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const e=this._getOrReturnCtx(t),a=this._def.values;return y(e,{received:e.data,code:d.invalid_enum_value,options:a}),k}return Z(t.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,a=this._def){return t.create(e,{...this._def,...a})}exclude(e,a=this._def){return t.create(this.options.filter(t=>!e.includes(t)),{...this._def,...a})}};je.create=Pe;var Ne=class extends C{_parse(t){const a=e.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==i.string&&r.parsedType!==i.number){const t=e.objectValues(a);return y(r,{expected:e.joinValues(t),received:r.parsedType,code:d.invalid_type}),k}if(this._cache||(this._cache=new Set(e.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const t=e.objectValues(a);return y(r,{received:r.data,code:d.invalid_enum_value,options:t}),k}return Z(t.data)}get enum(){return this._def.values}};Ne.create=(e,t)=>new Ne({values:e,typeName:Ke.ZodNativeEnum,...j(t)});var Ce=class extends C{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==i.promise&&!1===t.common.async)return y(t,{code:d.invalid_type,expected:i.promise,received:t.parsedType}),k;const a=t.parsedType===i.promise?t.data:Promise.resolve(t.data);return Z(a.then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Ce.create=(e,t)=>new Ce({type:e,typeName:Ke.ZodPromise,...j(t)});var Ie=class extends C{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ke.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:a,ctx:r}=this._processInputParams(t),n=this._def.effect||null,s={addIssue:e=>{y(r,e),e.fatal?a.abort():a.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),"preprocess"===n.type){const e=n.transform(r.data,s);if(r.common.async)return Promise.resolve(e).then(async e=>{if("aborted"===a.value)return k;const t=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return"aborted"===t.status?k:"dirty"===t.status||"dirty"===a.value?x(t.value):t});{if("aborted"===a.value)return k;const t=this._def.schema._parseSync({data:e,path:r.path,parent:r});return"aborted"===t.status?k:"dirty"===t.status||"dirty"===a.value?x(t.value):t}}if("refinement"===n.type){const e=e=>{const t=n.refinement(e,s);if(r.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===r.common.async){const t=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===t.status?k:("dirty"===t.status&&a.dirty(),e(t.value),{status:a.value,value:t.value})}return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(t=>"aborted"===t.status?k:("dirty"===t.status&&a.dirty(),e(t.value).then(()=>({status:a.value,value:t.value}))))}if("transform"===n.type){if(!1===r.common.async){const e=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!T(e))return k;const t=n.transform(e.value,s);if(t instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:a.value,value:t}}return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(e=>T(e)?Promise.resolve(n.transform(e.value,s)).then(e=>({status:a.value,value:e})):k)}e.assertNever(n)}};Ie.create=(e,t,a)=>new Ie({schema:e,typeName:Ke.ZodEffects,effect:t,...j(a)}),Ie.createWithPreprocess=(e,t,a)=>new Ie({schema:t,effect:{type:"preprocess",transform:e},typeName:Ke.ZodEffects,...j(a)});var $e=class extends C{_parse(e){return this._getType(e)===i.undefined?Z(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};$e.create=(e,t)=>new $e({innerType:e,typeName:Ke.ZodOptional,...j(t)});var Ee=class extends C{_parse(e){return this._getType(e)===i.null?Z(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ee.create=(e,t)=>new Ee({innerType:e,typeName:Ke.ZodNullable,...j(t)});var Me=class extends C{_parse(e){const{ctx:t}=this._processInputParams(e);let a=t.data;return t.parsedType===i.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Me.create=(e,t)=>new Me({innerType:e,typeName:Ke.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...j(t)});var Re=class extends C{_parse(e){const{ctx:t}=this._processInputParams(e),a={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return O(r)?r.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new u(a.common.issues)},input:a.data})})):{status:"valid",value:"valid"===r.status?r.value:this._def.catchValue({get error(){return new u(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}};Re.create=(e,t)=>new Re({innerType:e,typeName:Ke.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...j(t)});var Fe=class extends C{_parse(e){if(this._getType(e)!==i.nan){const t=this._getOrReturnCtx(e);return y(t,{code:d.invalid_type,expected:i.nan,received:t.parsedType}),k}return{status:"valid",value:e.data}}};Fe.create=e=>new Fe({typeName:Ke.ZodNaN,...j(e)});var Le=Symbol("zod_brand"),ze=class extends C{_parse(e){const{ctx:t}=this._processInputParams(e),a=t.data;return this._def.type._parse({data:a,path:t.path,parent:t})}unwrap(){return this._def.type}},De=class e extends C{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.common.async){return(async()=>{const e=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return"aborted"===e.status?k:"dirty"===e.status?(t.dirty(),x(e.value)):this._def.out._parseAsync({data:e.value,path:a.path,parent:a})})()}{const e=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return"aborted"===e.status?k:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:a.path,parent:a})}}static create(t,a){return new e({in:t,out:a,typeName:Ke.ZodPipeline})}},Ve=class extends C{_parse(e){const t=this._def.innerType._parse(e),a=e=>(T(e)&&(e.value=Object.freeze(e.value)),e);return O(t)?t.then(e=>a(e)):a(t)}unwrap(){return this._def.innerType}};function Ue(e,t){const a="function"==typeof e?e(t):"string"==typeof e?{message:e}:e;return"string"==typeof a?{message:a}:a}function Be(e,t={},a){return e?ue.create().superRefine((r,n)=>{var s,i;const o=e(r);if(o instanceof Promise)return o.then(e=>{var s,i;if(!e){const e=Ue(t,r),o=null==(i=null!=(s=e.fatal)?s:a)||i;n.addIssue({code:"custom",...e,fatal:o})}});if(!o){const e=Ue(t,r),o=null==(i=null!=(s=e.fatal)?s:a)||i;n.addIssue({code:"custom",...e,fatal:o})}}):ue.create()}Ve.create=(e,t)=>new Ve({innerType:e,typeName:Ke.ZodReadonly,...j(t)});var Ke,qe,We={object:ge.lazycreate};(qe=Ke||(Ke={})).ZodString="ZodString",qe.ZodNumber="ZodNumber",qe.ZodNaN="ZodNaN",qe.ZodBigInt="ZodBigInt",qe.ZodBoolean="ZodBoolean",qe.ZodDate="ZodDate",qe.ZodSymbol="ZodSymbol",qe.ZodUndefined="ZodUndefined",qe.ZodNull="ZodNull",qe.ZodAny="ZodAny",qe.ZodUnknown="ZodUnknown",qe.ZodNever="ZodNever",qe.ZodVoid="ZodVoid",qe.ZodArray="ZodArray",qe.ZodObject="ZodObject",qe.ZodUnion="ZodUnion",qe.ZodDiscriminatedUnion="ZodDiscriminatedUnion",qe.ZodIntersection="ZodIntersection",qe.ZodTuple="ZodTuple",qe.ZodRecord="ZodRecord",qe.ZodMap="ZodMap",qe.ZodSet="ZodSet",qe.ZodFunction="ZodFunction",qe.ZodLazy="ZodLazy",qe.ZodLiteral="ZodLiteral",qe.ZodEnum="ZodEnum",qe.ZodEffects="ZodEffects",qe.ZodNativeEnum="ZodNativeEnum",qe.ZodOptional="ZodOptional",qe.ZodNullable="ZodNullable",qe.ZodDefault="ZodDefault",qe.ZodCatch="ZodCatch",qe.ZodPromise="ZodPromise",qe.ZodBranded="ZodBranded",qe.ZodPipeline="ZodPipeline",qe.ZodReadonly="ZodReadonly";var Je=(e,t={message:`Input not instance of ${e.name}`})=>Be(t=>t instanceof e,t),He=te.create,Ye=re.create,Qe=Fe.create,Ge=ne.create,Xe=se.create,et=ie.create,tt=oe.create,at=de.create,rt=ce.create,nt=ue.create,st=le.create,it=pe.create,ot=he.create,dt=me.create,ct=ge.create,ut=ge.strictCreate,lt=ye.create,pt=_e.create,ht=ke.create,mt=xe.create,ft=Ze.create,gt=we.create,yt=Ae.create,vt=Te.create,_t=Oe.create,bt=Se.create,kt=je.create,xt=Ne.create,Zt=Ce.create,wt=Ie.create,At=$e.create,Tt=Ee.create,Ot=Ie.createWithPreprocess,St=De.create,Pt=()=>He().optional(),jt=()=>Ye().optional(),Nt=()=>Xe().optional(),Ct={string:e=>te.create({...e,coerce:!0}),number:e=>re.create({...e,coerce:!0}),boolean:e=>se.create({...e,coerce:!0}),bigint:e=>ne.create({...e,coerce:!0}),date:e=>ie.create({...e,coerce:!0})},It=k,$t=Symbol("Let zodToJsonSchema decide on which parser to use"),Et={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},Mt=e=>{const t=(e=>"string"==typeof e?{...Et,name:e}:{...Et,...e})(e),a=void 0!==t.name?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:a,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,a])=>[a._def,{def:a._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}};function Rt(e,t,a,r){(null==r?void 0:r.errorMessages)&&a&&(e.errorMessage={...e.errorMessage,[t]:a})}function Ft(e,t,a,r,n){e[t]=a,Rt(e,t,r,n)}var Lt=(e,t)=>{let a=0;for(;a<e.length&&a<t.length&&e[a]===t[a];a++);return[(e.length-a).toString(),...t.slice(a)].join("/")};function zt(e){if("openAi"!==e.target)return{};const t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:"relative"===e.$refStrategy?Lt(t,e.currentPath):t.join("/")}}function Dt(e,t){return ma(e.type._def,t)}function Vt(e,t,a){const r=null!=a?a:t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((a,r)=>Vt(e,t,a))};switch(r){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Ut(e,t)}}var Ut=(e,t)=>{const a={type:"integer",format:"unix-time"};if("openApi3"===t.target)return a;for(const r of e.checks)switch(r.kind){case"min":Ft(a,"minimum",r.value,r.message,t);break;case"max":Ft(a,"maximum",r.value,r.message,t)}return a};var Bt=void 0,Kt=/^[cC][^\s-]{8,}$/,qt=/^[0-9a-z]+$/,Wt=/^[0-9A-HJKMNP-TV-Z]{26}$/,Jt=/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,Ht=()=>(void 0===Bt&&(Bt=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Bt),Yt=/^(?:(?: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])$/,Qt=/^(([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])$/,Gt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Xt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ea=/^[a-zA-Z0-9_-]{21}$/,ta=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;function aa(e,t){const a={type:"string"};if(e.checks)for(const r of e.checks)switch(r.kind){case"min":Ft(a,"minLength","number"==typeof a.minLength?Math.max(a.minLength,r.value):r.value,r.message,t);break;case"max":Ft(a,"maxLength","number"==typeof a.maxLength?Math.min(a.maxLength,r.value):r.value,r.message,t);break;case"email":switch(t.emailStrategy){case"format:email":sa(a,"email",r.message,t);break;case"format:idn-email":sa(a,"idn-email",r.message,t);break;case"pattern:zod":ia(a,Jt,r.message,t)}break;case"url":sa(a,"uri",r.message,t);break;case"uuid":sa(a,"uuid",r.message,t);break;case"regex":ia(a,r.regex,r.message,t);break;case"cuid":ia(a,Kt,r.message,t);break;case"cuid2":ia(a,qt,r.message,t);break;case"startsWith":ia(a,RegExp(`^${ra(r.value,t)}`),r.message,t);break;case"endsWith":ia(a,RegExp(`${ra(r.value,t)}$`),r.message,t);break;case"datetime":sa(a,"date-time",r.message,t);break;case"date":sa(a,"date",r.message,t);break;case"time":sa(a,"time",r.message,t);break;case"duration":sa(a,"duration",r.message,t);break;case"length":Ft(a,"minLength","number"==typeof a.minLength?Math.max(a.minLength,r.value):r.value,r.message,t),Ft(a,"maxLength","number"==typeof a.maxLength?Math.min(a.maxLength,r.value):r.value,r.message,t);break;case"includes":ia(a,RegExp(ra(r.value,t)),r.message,t);break;case"ip":"v6"!==r.version&&sa(a,"ipv4",r.message,t),"v4"!==r.version&&sa(a,"ipv6",r.message,t);break;case"base64url":ia(a,Xt,r.message,t);break;case"jwt":ia(a,ta,r.message,t);break;case"cidr":"v6"!==r.version&&ia(a,Yt,r.message,t),"v4"!==r.version&&ia(a,Qt,r.message,t);break;case"emoji":ia(a,Ht(),r.message,t);break;case"ulid":ia(a,Wt,r.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":sa(a,"binary",r.message,t);break;case"contentEncoding:base64":Ft(a,"contentEncoding","base64",r.message,t);break;case"pattern:zod":ia(a,Gt,r.message,t)}break;case"nanoid":ia(a,ea,r.message,t)}return a}function ra(e,t){return"escape"===t.patternStrategy?function(e){let t="";for(let a=0;a<e.length;a++)na.has(e[a])||(t+="\\"),t+=e[a];return t}(e):e}var na=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function sa(e,t,a,r){var n;e.format||(null==(n=e.anyOf)?void 0:n.some(e=>e.format))?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&r.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.anyOf.push({format:t,...a&&r.errorMessages&&{errorMessage:{format:a}}})):Ft(e,"format",t,a,r)}function ia(e,t,a,r){var n;e.pattern||(null==(n=e.allOf)?void 0:n.some(e=>e.pattern))?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&r.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.allOf.push({pattern:oa(t,r),...a&&r.errorMessages&&{errorMessage:{pattern:a}}})):Ft(e,"pattern",oa(t,r),a,r)}function oa(e,t){var a;if(!t.applyRegexFlags||!e.flags)return e.source;const r=e.flags.includes("i"),n=e.flags.includes("m"),s=e.flags.includes("s"),i=r?e.source.toLowerCase():e.source;let o="",d=!1,c=!1,u=!1;for(let e=0;e<i.length;e++)if(d)o+=i[e],d=!1;else{if(r)if(c){if(i[e].match(/[a-z]/)){u?(o+=i[e],o+=`${i[e-2]}-${i[e]}`.toUpperCase(),u=!1):"-"===i[e+1]&&(null==(a=i[e+2])?void 0:a.match(/[a-z]/))?(o+=i[e],u=!0):o+=`${i[e]}${i[e].toUpperCase()}`;continue}}else if(i[e].match(/[a-z]/)){o+=`[${i[e]}${i[e].toUpperCase()}]`;continue}if(n){if("^"===i[e]){o+="(^|(?<=[\r\n]))";continue}if("$"===i[e]){o+="($|(?=[\r\n]))";continue}}s&&"."===i[e]?o+=c?`${i[e]}\r\n`:`[${i[e]}\r\n]`:(o+=i[e],"\\"===i[e]?d=!0:c&&"]"===i[e]?c=!1:c||"["!==i[e]||(c=!0))}try{new RegExp(o)}catch(a){return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return o}function da(e,t){var a,r,n,s,i,o,d;if("openAi"===t.target&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),"openApi3"===t.target&&(null==(a=e.keyType)?void 0:a._def.typeName)===Ke.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((a,r)=>{var n;return{...a,[r]:null!=(n=ma(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",r]}))?n:zt(t)}},{}),additionalProperties:t.rejectedAdditionalProperties};const c={type:"object",additionalProperties:null!=(r=ma(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))?r:t.allowedAdditionalProperties};if("openApi3"===t.target)return c;if((null==(n=e.keyType)?void 0:n._def.typeName)===Ke.ZodString&&(null==(s=e.keyType._def.checks)?void 0:s.length)){const{type:a,...r}=aa(e.keyType._def,t);return{...c,propertyNames:r}}if((null==(i=e.keyType)?void 0:i._def.typeName)===Ke.ZodEnum)return{...c,propertyNames:{enum:e.keyType._def.values}};if((null==(o=e.keyType)?void 0:o._def.typeName)===Ke.ZodBranded&&e.keyType._def.type._def.typeName===Ke.ZodString&&(null==(d=e.keyType._def.type._def.checks)?void 0:d.length)){const{type:a,...r}=Dt(e.keyType._def,t);return{...c,propertyNames:r}}return c}var ca={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};var ua=(e,t)=>{const a=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,a)=>ma(e._def,{...t,currentPath:[...t.currentPath,"anyOf",`${a}`]})).filter(e=>!!e&&(!t.strictUnions||"object"==typeof e&&Object.keys(e).length>0));return a.length?{anyOf:a}:void 0};function la(e,t){const a="openAi"===t.target,r={type:"object",properties:{}},n=[],s=e.shape();for(const e in s){let i=s[e];if(void 0===i||void 0===i._def)continue;let o=pa(i);o&&a&&("ZodOptional"===i._def.typeName&&(i=i._def.innerType),i.isNullable()||(i=i.nullable()),o=!1);const d=ma(i._def,{...t,currentPath:[...t.currentPath,"properties",e],propertyPath:[...t.currentPath,"properties",e]});void 0!==d&&(r.properties[e]=d,o||n.push(e))}n.length&&(r.required=n);const i=function(e,t){if("ZodNever"!==e.catchall._def.typeName)return ma(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return"strict"===t.removeAdditionalStrategy?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}(e,t);return void 0!==i&&(r.additionalProperties=i),r}function pa(e){try{return e.isOptional()}catch(e){return!0}}var ha=(e,t,a)=>{switch(t){case Ke.ZodString:return aa(e,a);case Ke.ZodNumber:return function(e,t){const a={type:"number"};if(!e.checks)return a;for(const r of e.checks)switch(r.kind){case"int":a.type="integer",Rt(a,"type",r.message,t);break;case"min":"jsonSchema7"===t.target?r.inclusive?Ft(a,"minimum",r.value,r.message,t):Ft(a,"exclusiveMinimum",r.value,r.message,t):(r.inclusive||(a.exclusiveMinimum=!0),Ft(a,"minimum",r.value,r.message,t));break;case"max":"jsonSchema7"===t.target?r.inclusive?Ft(a,"maximum",r.value,r.message,t):Ft(a,"exclusiveMaximum",r.value,r.message,t):(r.inclusive||(a.exclusiveMaximum=!0),Ft(a,"maximum",r.value,r.message,t));break;case"multipleOf":Ft(a,"multipleOf",r.value,r.message,t)}return a}(e,a);case Ke.ZodObject:return la(e,a);case Ke.ZodBigInt:return function(e,t){const a={type:"integer",format:"int64"};if(!e.checks)return a;for(const r of e.checks)switch(r.kind){case"min":"jsonSchema7"===t.target?r.inclusive?Ft(a,"minimum",r.value,r.message,t):Ft(a,"exclusiveMinimum",r.value,r.message,t):(r.inclusive||(a.exclusiveMinimum=!0),Ft(a,"minimum",r.value,r.message,t));break;case"max":"jsonSchema7"===t.target?r.inclusive?Ft(a,"maximum",r.value,r.message,t):Ft(a,"exclusiveMaximum",r.value,r.message,t):(r.inclusive||(a.exclusiveMaximum=!0),Ft(a,"maximum",r.value,r.message,t));break;case"multipleOf":Ft(a,"multipleOf",r.value,r.message,t)}return a}(e,a);case Ke.ZodBoolean:return{type:"boolean"};case Ke.ZodDate:return Vt(e,a);case Ke.ZodUndefined:return function(e){return{not:zt(e)}}(a);case Ke.ZodNull:return function(e){return"openApi3"===e.target?{enum:["null"],nullable:!0}:{type:"null"}}(a);case Ke.ZodArray:return function(e,t){var a,r,n;const s={type:"array"};return(null==(a=e.type)?void 0:a._def)&&(null==(n=null==(r=e.type)?void 0:r._def)?void 0:n.typeName)!==Ke.ZodAny&&(s.items=ma(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&Ft(s,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&Ft(s,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(Ft(s,"minItems",e.exactLength.value,e.exactLength.message,t),Ft(s,"maxItems",e.exactLength.value,e.exactLength.message,t)),s}(e,a);case Ke.ZodUnion:case Ke.ZodDiscriminatedUnion:return function(e,t){if("openApi3"===t.target)return ua(e,t);const a=e.options instanceof Map?Array.from(e.options.values()):e.options;if(a.every(e=>e._def.typeName in ca&&(!e._def.checks||!e._def.checks.length))){const e=a.reduce((e,t)=>{const a=ca[t._def.typeName];return a&&!e.includes(a)?[...e,a]:e},[]);return{type:e.length>1?e:e[0]}}if(a.every(e=>"ZodLiteral"===e._def.typeName&&!e.description)){const e=a.reduce((e,t)=>{const a=typeof t._def.value;switch(a){case"string":case"number":case"boolean":return[...e,a];case"bigint":return[...e,"integer"];case"object":if(null===t._def.value)return[...e,"null"];default:return e}},[]);if(e.length===a.length){const t=e.filter((e,t,a)=>a.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:a.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(a.every(e=>"ZodEnum"===e._def.typeName))return{type:"string",enum:a.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return ua(e,t)}(e,a);case Ke.ZodIntersection:return function(e,t){const a=[ma(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),ma(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(e=>!!e);let r="jsonSchema2019-09"===t.target?{unevaluatedProperties:!1}:void 0;const n=[];return a.forEach(e=>{if("type"in(t=e)&&"string"===t.type||!("allOf"in t)){let t=e;if("additionalProperties"in e&&!1===e.additionalProperties){const{additionalProperties:a,...r}=e;t=r}else r=void 0;n.push(t)}else n.push(...e.allOf),void 0===e.unevaluatedProperties&&(r=void 0);var t}),n.length?{allOf:n,...r}:void 0}(e,a);case Ke.ZodTuple:return function(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((e,a)=>ma(e._def,{...t,currentPath:[...t.currentPath,"items",`${a}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[]),additionalItems:ma(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,a)=>ma(e._def,{...t,currentPath:[...t.currentPath,"items",`${a}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[])}}(e,a);case Ke.ZodRecord:return da(e,a);case Ke.ZodLiteral:return function(e,t){const a=typeof e.value;return"bigint"!==a&&"number"!==a&&"boolean"!==a&&"string"!==a?{type:Array.isArray(e.value)?"array":"object"}:"openApi3"===t.target?{type:"bigint"===a?"integer":a,enum:[e.value]}:{type:"bigint"===a?"integer":a,const:e.value}}(e,a);case Ke.ZodEnum:return function(e){return{type:"string",enum:Array.from(e.values)}}(e);case Ke.ZodNativeEnum:return function(e){const t=e.values,a=Object.keys(e.values).filter(e=>"number"!=typeof t[t[e]]).map(e=>t[e]),r=Array.from(new Set(a.map(e=>typeof e)));return{type:1===r.length?"string"===r[0]?"string":"number":["string","number"],enum:a}}(e);case Ke.ZodNullable:return function(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return"openApi3"===t.target?{type:ca[e.innerType._def.typeName],nullable:!0}:{type:[ca[e.innerType._def.typeName],"null"]};if("openApi3"===t.target){const a=ma(e.innerType._def,{...t,currentPath:[...t.currentPath]});return a&&"$ref"in a?{allOf:[a],nullable:!0}:a&&{...a,nullable:!0}}const a=ma(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return a&&{anyOf:[a,{type:"null"}]}}(e,a);case Ke.ZodOptional:return((e,t)=>{var a;if(t.currentPath.toString()===(null==(a=t.propertyPath)?void 0:a.toString()))return ma(e.innerType._def,t);const r=ma(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:zt(t)},r]}:zt(t)})(e,a);case Ke.ZodMap:return function(e,t){return"record"===t.mapStrategy?da(e,t):{type:"array",maxItems:125,items:{type:"array",items:[ma(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||zt(t),ma(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||zt(t)],minItems:2,maxItems:2}}}(e,a);case Ke.ZodSet:return function(e,t){const a={type:"array",uniqueItems:!0,items:ma(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&Ft(a,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&Ft(a,"maxItems",e.maxSize.value,e.maxSize.message,t),a}(e,a);case Ke.ZodLazy:return()=>e.getter()._def;case Ke.ZodPromise:return function(e,t){return ma(e.type._def,t)}(e,a);case Ke.ZodNaN:case Ke.ZodNever:return function(e){return"openAi"===e.target?void 0:{not:zt({...e,currentPath:[...e.currentPath,"not"]})}}(a);case Ke.ZodEffects:return function(e,t){return"input"===t.effectStrategy?ma(e.schema._def,t):zt(t)}(e,a);case Ke.ZodAny:return zt(a);case Ke.ZodUnknown:return function(e){return zt(e)}(a);case Ke.ZodDefault:return function(e,t){return{...ma(e.innerType._def,t),default:e.defaultValue()}}(e,a);case Ke.ZodBranded:return Dt(e,a);case Ke.ZodReadonly:case Ke.ZodCatch:return((e,t)=>ma(e.innerType._def,t))(e,a);case Ke.ZodPipeline:return((e,t)=>{if("input"===t.pipeStrategy)return ma(e.in._def,t);if("output"===t.pipeStrategy)return ma(e.out._def,t);const a=ma(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]});return{allOf:[a,ma(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",a?"1":"0"]})].filter(e=>void 0!==e)}})(e,a);case Ke.ZodFunction:case Ke.ZodVoid:case Ke.ZodSymbol:default:return}};function ma(e,t,a=!1){var r;const n=t.seen.get(e);if(t.override){const s=null==(r=t.override)?void 0:r.call(t,e,t,n,a);if(s!==$t)return s}if(n&&!a){const e=fa(n,t);if(void 0!==e)return e}const s={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,s);const i=ha(e,e.typeName,t),o="function"==typeof i?ma(i(),t):i;if(o&&ga(e,t,o),t.postProcess){const a=t.postProcess(o,e,t);return s.jsonSchema=o,a}return s.jsonSchema=o,o}var fa=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:Lt(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((e,a)=>t.currentPath[a]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),zt(t)):"seen"===t.$refStrategy?zt(t):void 0}},ga=(e,t,a)=>(e.description&&(a.description=e.description,t.markdownDescription&&(a.markdownDescription=e.description)),a),ya=(e,t)=>{var a;const r=Mt(t);let n="object"==typeof t&&t.definitions?Object.entries(t.definitions).reduce((e,[t,a])=>{var n;return{...e,[t]:null!=(n=ma(a._def,{...r,currentPath:[...r.basePath,r.definitionPath,t]},!0))?n:zt(r)}},{}):void 0;const s="string"==typeof t?t:"title"===(null==t?void 0:t.nameStrategy)||null==t?void 0:t.name,i=null!=(a=ma(e._def,void 0===s?r:{...r,currentPath:[...r.basePath,r.definitionPath,s]},!1))?a:zt(r),o="object"==typeof t&&void 0!==t.name&&"title"===t.nameStrategy?t.name:void 0;void 0!==o&&(i.title=o),r.flags.hasReferencedOpenAiAnyType&&(n||(n={}),n[r.openAiAnyTypeName]||(n[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:"relative"===r.$refStrategy?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));const d=void 0===s?n?{...i,[r.definitionPath]:n}:i:{$ref:[..."relative"===r.$refStrategy?[]:r.basePath,r.definitionPath,s].join("/"),[r.definitionPath]:{...n,[s]:i}};return"jsonSchema7"===r.target?d.$schema="http://json-schema.org/draft-07/schema#":"jsonSchema2019-09"!==r.target&&"openAi"!==r.target||(d.$schema="https://json-schema.org/draft/2019-09/schema#"),"openAi"===r.target&&("anyOf"in d||"oneOf"in d||"allOf"in d||"type"in d&&Array.isArray(d.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),d},va=s.record(s.string(),s.boolean()).describe("Consent requirement mapping"),_a=s.lazy(()=>s.union([s.string(),s.number(),s.boolean(),Za,s.array(_a)])),ba=s.tuple([_a,_a]).describe("Loop: [source, transform] tuple for array transformations"),ka=s.array(_a).describe("Set: Array of values"),xa=s.record(s.string(),_a).describe("Map: Object mapping keys to values"),Za=s.object({key:s.string().optional().describe('Property path (e.g., "data.id")'),value:s.union([s.string(),s.number(),s.boolean()]).optional().describe("Static primitive value"),fn:s.string().optional().describe("Function string for custom transformation"),map:xa.optional().describe("Object with key-value mappings"),loop:ba.optional().describe("Tuple [source, transform]"),set:ka.optional().describe("Array of values"),consent:va.optional().describe("Required consent states"),condition:s.string().optional().describe("Condition function string"),validate:s.string().optional().describe("Validation function string")}).refine(e=>Object.keys(e).length>0,{message:"ValueConfig must have at least one property"}).describe("Value configuration for transformations"),wa=ba,Aa=ka,Ta=xa;ya(Za,{target:"jsonSchema7",$refStrategy:"relative",name:"ValueConfig"}),ya(wa,{target:"jsonSchema7",$refStrategy:"relative",name:"Loop"}),ya(Aa,{target:"jsonSchema7",$refStrategy:"relative",name:"Set"}),ya(Ta,{target:"jsonSchema7",$refStrategy:"relative",name:"Map"});function Oa(e){return Array.isArray(e)}function Sa(e){return"object"==typeof e&&null!==e&&!Oa(e)&&"[object Object]"===Object.prototype.toString.call(e)}import{BigQuery as Pa}from"@google-cloud/bigquery";function ja(e={},t){const a=e.settings||{},{projectId:r,bigquery:n}=a;let{client:s,location:i,datasetId:o,tableId:d}=a;r||function(e){throw new Error(String(e))}("Config settings projectId missing"),i=i||"EU",o=o||"walkeros",d=d||"events";const c=n||{};c.projectId=r;const u=(null==t?void 0:t.BigQuery)||Pa;s=s||new u(c);const l={...a,client:s,projectId:r,location:i,datasetId:o,tableId:d};return{...e,settings:l}}var Na=e=>Object.entries(e).reduce((e,[t,a])=>(e[t]=Sa(a)||Oa(a)?JSON.stringify(a):a,e),{}),Ca={};n({},{env:()=>Ia});var Ia={};n(Ia,{push:()=>Ea});var $a=()=>{};var Ea={get BigQuery(){return class{constructor(e){this.options=e,this.calls=[]}dataset(e){return this.calls.push({method:"dataset",args:[e]}),this}table(e){return this.calls.push({method:"table",args:[e]}),this}async insert(e){return this.calls.push({method:"insert",args:[e]}),Promise.resolve()}get mockFn(){return $a}}}},Ma={type:"gcp-bigquery",config:{},init:async({config:e,env:t})=>ja(e,t),push:async(e,{config:t,mapping:a,data:r,collector:n,env:s})=>await async function(e,{config:t,mapping:a,data:r,collector:n,env:s}){const{client:i,datasetId:o,tableId:d}=t.settings;let c;if(Sa(r))c=r;else{const t=new Date;c={...e,timestamp:e.timestamp?new Date(e.timestamp):t,createdAt:t}}const u=[Na(c)];await i.dataset(o).table(d).insert(u)}(e,{config:t,mapping:a,data:r,collector:n,env:s})};export{Ca as DestinationBigQuery,Ma as destinationBigQuery};//# sourceMappingURL=index.mjs.map
1
+ var e,t,n,a=Object.defineProperty,r=(e,t)=>{for(var n in t)a(e,n,{get:t[n],enumerable:!0})},i={};r(i,{BRAND:()=>ze,DIRTY:()=>k,EMPTY_PATH:()=>g,INVALID:()=>S,NEVER:()=>It,OK:()=>x,ParseStatus:()=>_,Schema:()=>E,ZodAny:()=>ue,ZodArray:()=>he,ZodBigInt:()=>re,ZodBoolean:()=>ie,ZodBranded:()=>Le,ZodCatch:()=>Re,ZodDate:()=>se,ZodDefault:()=>Me,ZodDiscriminatedUnion:()=>be,ZodEffects:()=>Ie,ZodEnum:()=>Ce,ZodError:()=>u,ZodFirstPartyTypeKind:()=>Je,ZodFunction:()=>Ze,ZodIntersection:()=>Se,ZodIssueCode:()=>c,ZodLazy:()=>Pe,ZodLiteral:()=>Ae,ZodMap:()=>we,ZodNaN:()=>De,ZodNativeEnum:()=>Oe,ZodNever:()=>pe,ZodNull:()=>de,ZodNullable:()=>$e,ZodNumber:()=>ae,ZodObject:()=>ge,ZodOptional:()=>Ne,ZodParsedType:()=>s,ZodPipeline:()=>Fe,ZodPromise:()=>Ee,ZodReadonly:()=>Ue,ZodRecord:()=>xe,ZodSchema:()=>E,ZodSet:()=>je,ZodString:()=>te,ZodSymbol:()=>oe,ZodTransformer:()=>Ie,ZodTuple:()=>ke,ZodType:()=>E,ZodUndefined:()=>ce,ZodUnion:()=>ye,ZodUnknown:()=>le,ZodVoid:()=>me,addIssueToContext:()=>y,any:()=>rt,array:()=>ct,bigint:()=>Ye,boolean:()=>Xe,coerce:()=>Et,custom:()=>Ve,date:()=>et,datetimeRegex:()=>G,defaultErrorMap:()=>l,discriminatedUnion:()=>pt,effect:()=>wt,enum:()=>St,function:()=>vt,getErrorMap:()=>h,getParsedType:()=>o,instanceof:()=>Ke,intersection:()=>mt,isAborted:()=>w,isAsync:()=>P,isDirty:()=>j,isValid:()=>Z,late:()=>We,lazy:()=>bt,literal:()=>_t,makeIssue:()=>f,map:()=>gt,nan:()=>Ge,nativeEnum:()=>kt,never:()=>st,null:()=>at,nullable:()=>Zt,number:()=>Qe,object:()=>dt,objectUtil:()=>n,oboolean:()=>Ot,onumber:()=>Ct,optional:()=>jt,ostring:()=>Tt,pipeline:()=>At,preprocess:()=>Pt,promise:()=>xt,quotelessJson:()=>d,record:()=>ft,set:()=>yt,setErrorMap:()=>m,strictObject:()=>ut,string:()=>He,symbol:()=>tt,transformer:()=>wt,tuple:()=>ht,undefined:()=>nt,union:()=>lt,unknown:()=>it,util:()=>e,void:()=>ot}),(t=e||(e={})).assertEqual=e=>{},t.assertIs=function(e){},t.assertNever=function(e){throw new Error},t.arrayToEnum=e=>{const t={};for(const n of e)t[n]=n;return t},t.getValidEnumValues=e=>{const n=t.objectKeys(e).filter(t=>"number"!=typeof e[e[t]]),a={};for(const t of n)a[t]=e[t];return t.objectValues(a)},t.objectValues=e=>t.objectKeys(e).map(function(t){return e[t]}),t.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},t.find=(e,t)=>{for(const n of e)if(t(n))return n},t.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,t.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},t.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t,(n||(n={})).mergeShapes=(e,t)=>({...e,...t});var s=e.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),o=e=>{switch(typeof e){case"undefined":return s.undefined;case"string":return s.string;case"number":return Number.isNaN(e)?s.nan:s.number;case"boolean":return s.boolean;case"function":return s.function;case"bigint":return s.bigint;case"symbol":return s.symbol;case"object":return Array.isArray(e)?s.array:null===e?s.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?s.promise:"undefined"!=typeof Map&&e instanceof Map?s.map:"undefined"!=typeof Set&&e instanceof Set?s.set:"undefined"!=typeof Date&&e instanceof Date?s.date:s.object;default:return s.unknown}},c=e.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"]),d=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),u=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};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(e){return e.message},n={_errors:[]},a=e=>{for(const r of e.issues)if("invalid_union"===r.code)r.unionErrors.map(a);else if("invalid_return_type"===r.code)a(r.returnTypeError);else if("invalid_arguments"===r.code)a(r.argumentsError);else if(0===r.path.length)n._errors.push(t(r));else{let e=n,a=0;for(;a<r.path.length;){const n=r.path[a];a===r.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(r))):e[n]=e[n]||{_errors:[]},e=e[n],a++}}};return a(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,e.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t={},n=[];for(const a of this.issues)if(a.path.length>0){const n=a.path[0];t[n]=t[n]||[],t[n].push(e(a))}else n.push(e(a));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};u.create=e=>new u(e);var l=(t,n)=>{let a;switch(t.code){case c.invalid_type:a=t.received===s.undefined?"Required":`Expected ${t.expected}, received ${t.received}`;break;case c.invalid_literal:a=`Invalid literal value, expected ${JSON.stringify(t.expected,e.jsonStringifyReplacer)}`;break;case c.unrecognized_keys:a=`Unrecognized key(s) in object: ${e.joinValues(t.keys,", ")}`;break;case c.invalid_union:a="Invalid input";break;case c.invalid_union_discriminator:a=`Invalid discriminator value. Expected ${e.joinValues(t.options)}`;break;case c.invalid_enum_value:a=`Invalid enum value. Expected ${e.joinValues(t.options)}, received '${t.received}'`;break;case c.invalid_arguments:a="Invalid function arguments";break;case c.invalid_return_type:a="Invalid function return type";break;case c.invalid_date:a="Invalid date";break;case c.invalid_string:"object"==typeof t.validation?"includes"in t.validation?(a=`Invalid input: must include "${t.validation.includes}"`,"number"==typeof t.validation.position&&(a=`${a} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?a=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?a=`Invalid input: must end with "${t.validation.endsWith}"`:e.assertNever(t.validation):a="regex"!==t.validation?`Invalid ${t.validation}`:"Invalid";break;case c.too_small:a="array"===t.type?`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:"string"===t.type?`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:"number"===t.type||"bigint"===t.type?`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:"date"===t.type?`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:"Invalid input";break;case c.too_big:a="array"===t.type?`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:"string"===t.type?`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:"number"===t.type?`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:"bigint"===t.type?`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:"date"===t.type?`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:"Invalid input";break;case c.custom:a="Invalid input";break;case c.invalid_intersection_types:a="Intersection results could not be merged";break;case c.not_multiple_of:a=`Number must be a multiple of ${t.multipleOf}`;break;case c.not_finite:a="Number must be finite";break;default:a=n.defaultError,e.assertNever(t)}return{message:a}},p=l;function m(e){p=e}function h(){return p}var f=e=>{const{data:t,path:n,errorMaps:a,issueData:r}=e,i=[...n,...r.path||[]],s={...r,path:i};if(void 0!==r.message)return{...r,path:i,message:r.message};let o="";const c=a.filter(e=>!!e).slice().reverse();for(const e of c)o=e(s,{data:t,defaultError:o}).message;return{...r,path:i,message:o}},g=[];function y(e,t){const n=h(),a=f({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===l?void 0:l].filter(e=>!!e)});e.common.issues.push(a)}var v,b,_=class e{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const a of t){if("aborted"===a.status)return S;"dirty"===a.status&&e.dirty(),n.push(a.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){const a=[];for(const e of n){const t=await e.key,n=await e.value;a.push({key:t,value:n})}return e.mergeObjectSync(t,a)}static mergeObjectSync(e,t){const n={};for(const a of t){const{key:t,value:r}=a;if("aborted"===t.status)return S;if("aborted"===r.status)return S;"dirty"===t.status&&e.dirty(),"dirty"===r.status&&e.dirty(),"__proto__"===t.value||void 0===r.value&&!a.alwaysSet||(n[t.value]=r.value)}return{status:e.value,value:n}}},S=Object.freeze({status:"aborted"}),k=e=>({status:"dirty",value:e}),x=e=>({status:"valid",value:e}),w=e=>"aborted"===e.status,j=e=>"dirty"===e.status,Z=e=>"valid"===e.status,P=e=>"undefined"!=typeof Promise&&e instanceof Promise;(b=v||(v={})).errToObj=e=>"string"==typeof e?{message:e}:e||{},b.toString=e=>"string"==typeof e?e:null==e?void 0:e.message;var A=class{constructor(e,t,n,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},T=(e,t)=>{if(Z(t))return{success:!0,data:t.value};if(!e.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 u(e.common.issues);return this._error=t,this._error}}};function C(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:a,description:r}=e;if(t&&(n||a))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:r};return{errorMap:(t,r)=>{var i,s;const{message:o}=e;return"invalid_enum_value"===t.code?{message:null!=o?o:r.defaultError}:void 0===r.data?{message:null!=(i=null!=o?o:a)?i:r.defaultError}:"invalid_type"!==t.code?{message:r.defaultError}:{message:null!=(s=null!=o?o:n)?s:r.defaultError}},description:r}}var O,E=class{get description(){return this._def.description}_getType(e){return o(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:o(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new _,ctx:{common:e.parent.common,data:e.data,parsedType:o(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(P(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const a={common:{issues:[],async:null!=(n=null==t?void 0:t.async)&&n,contextualErrorMap:null==t?void 0:t.errorMap},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:o(e)},r=this._parseSync({data:e,path:a.path,parent:a});return T(a,r)}"~validate"(e){var t,n;const a={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:o(e)};if(!this["~standard"].async)try{const t=this._parseSync({data:e,path:[],parent:a});return Z(t)?{value:t.value}:{issues:a.common.issues}}catch(e){(null==(n=null==(t=null==e?void 0:e.message)?void 0:t.toLowerCase())?void 0:n.includes("encountered"))&&(this["~standard"].async=!0),a.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:a}).then(e=>Z(e)?{value:e.value}:{issues:a.common.issues})}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:null==t?void 0:t.errorMap,async:!0},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:o(e)},a=this._parse({data:e,path:n.path,parent:n}),r=await(P(a)?a:Promise.resolve(a));return T(n,r)}refine(e,t){const n=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement((t,a)=>{const r=e(t),i=()=>a.addIssue({code:c.custom,...n(t)});return"undefined"!=typeof Promise&&r instanceof Promise?r.then(e=>!!e||(i(),!1)):!!r||(i(),!1)})}refinement(e,t){return this._refinement((n,a)=>!!e(n)||(a.addIssue("function"==typeof t?t(n,a):t),!1))}_refinement(e){return new Ie({schema:this,typeName:Je.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:e=>this["~validate"](e)}}optional(){return Ne.create(this,this._def)}nullable(){return $e.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return he.create(this)}promise(){return Ee.create(this,this._def)}or(e){return ye.create([this,e],this._def)}and(e){return Se.create(this,e,this._def)}transform(e){return new Ie({...C(this._def),schema:this,typeName:Je.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new Me({...C(this._def),innerType:this,defaultValue:t,typeName:Je.ZodDefault})}brand(){return new Le({typeName:Je.ZodBranded,type:this,...C(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new Re({...C(this._def),innerType:this,catchValue:t,typeName:Je.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return Fe.create(this,e)}readonly(){return Ue.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},I=/^c[^\s-]{8,}$/i,N=/^[0-9a-z]+$/,$=/^[0-9A-HJKMNP-TV-Z]{26}$/i,M=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,R=/^[a-z0-9_-]{21}$/i,D=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,z=/^[-+]?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)?)??$/,L=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,F=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,U=/^(?:(?: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])$/,B=/^(([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]))$/,V=/^(([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])$/,J=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,q=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,W="((\\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])))",K=new RegExp(`^${W}$`);function H(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e.precision?"+":"?"}`}function Q(e){return new RegExp(`^${H(e)}$`)}function G(e){let t=`${W}T${H(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function Y(e,t){return!("v4"!==t&&t||!F.test(e))||!("v6"!==t&&t||!B.test(e))}function X(e,t){if(!D.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const a=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),r=JSON.parse(atob(a));return"object"==typeof r&&null!==r&&((!("typ"in r)||"JWT"===(null==r?void 0:r.typ))&&(!!r.alg&&(!t||r.alg===t)))}catch(e){return!1}}function ee(e,t){return!("v4"!==t&&t||!U.test(e))||!("v6"!==t&&t||!V.test(e))}var te=class t extends E{_parse(t){this._def.coerce&&(t.data=String(t.data));if(this._getType(t)!==s.string){const e=this._getOrReturnCtx(t);return y(e,{code:c.invalid_type,expected:s.string,received:e.parsedType}),S}const n=new _;let a;for(const r of this._def.checks)if("min"===r.kind)t.data.length<r.value&&(a=this._getOrReturnCtx(t,a),y(a,{code:c.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),n.dirty());else if("max"===r.kind)t.data.length>r.value&&(a=this._getOrReturnCtx(t,a),y(a,{code:c.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),n.dirty());else if("length"===r.kind){const e=t.data.length>r.value,i=t.data.length<r.value;(e||i)&&(a=this._getOrReturnCtx(t,a),e?y(a,{code:c.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):i&&y(a,{code:c.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),n.dirty())}else if("email"===r.kind)L.test(t.data)||(a=this._getOrReturnCtx(t,a),y(a,{validation:"email",code:c.invalid_string,message:r.message}),n.dirty());else if("emoji"===r.kind)O||(O=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),O.test(t.data)||(a=this._getOrReturnCtx(t,a),y(a,{validation:"emoji",code:c.invalid_string,message:r.message}),n.dirty());else if("uuid"===r.kind)M.test(t.data)||(a=this._getOrReturnCtx(t,a),y(a,{validation:"uuid",code:c.invalid_string,message:r.message}),n.dirty());else if("nanoid"===r.kind)R.test(t.data)||(a=this._getOrReturnCtx(t,a),y(a,{validation:"nanoid",code:c.invalid_string,message:r.message}),n.dirty());else if("cuid"===r.kind)I.test(t.data)||(a=this._getOrReturnCtx(t,a),y(a,{validation:"cuid",code:c.invalid_string,message:r.message}),n.dirty());else if("cuid2"===r.kind)N.test(t.data)||(a=this._getOrReturnCtx(t,a),y(a,{validation:"cuid2",code:c.invalid_string,message:r.message}),n.dirty());else if("ulid"===r.kind)$.test(t.data)||(a=this._getOrReturnCtx(t,a),y(a,{validation:"ulid",code:c.invalid_string,message:r.message}),n.dirty());else if("url"===r.kind)try{new URL(t.data)}catch(e){a=this._getOrReturnCtx(t,a),y(a,{validation:"url",code:c.invalid_string,message:r.message}),n.dirty()}else if("regex"===r.kind){r.regex.lastIndex=0;r.regex.test(t.data)||(a=this._getOrReturnCtx(t,a),y(a,{validation:"regex",code:c.invalid_string,message:r.message}),n.dirty())}else if("trim"===r.kind)t.data=t.data.trim();else if("includes"===r.kind)t.data.includes(r.value,r.position)||(a=this._getOrReturnCtx(t,a),y(a,{code:c.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),n.dirty());else if("toLowerCase"===r.kind)t.data=t.data.toLowerCase();else if("toUpperCase"===r.kind)t.data=t.data.toUpperCase();else if("startsWith"===r.kind)t.data.startsWith(r.value)||(a=this._getOrReturnCtx(t,a),y(a,{code:c.invalid_string,validation:{startsWith:r.value},message:r.message}),n.dirty());else if("endsWith"===r.kind)t.data.endsWith(r.value)||(a=this._getOrReturnCtx(t,a),y(a,{code:c.invalid_string,validation:{endsWith:r.value},message:r.message}),n.dirty());else if("datetime"===r.kind){G(r).test(t.data)||(a=this._getOrReturnCtx(t,a),y(a,{code:c.invalid_string,validation:"datetime",message:r.message}),n.dirty())}else if("date"===r.kind){K.test(t.data)||(a=this._getOrReturnCtx(t,a),y(a,{code:c.invalid_string,validation:"date",message:r.message}),n.dirty())}else if("time"===r.kind){Q(r).test(t.data)||(a=this._getOrReturnCtx(t,a),y(a,{code:c.invalid_string,validation:"time",message:r.message}),n.dirty())}else"duration"===r.kind?z.test(t.data)||(a=this._getOrReturnCtx(t,a),y(a,{validation:"duration",code:c.invalid_string,message:r.message}),n.dirty()):"ip"===r.kind?Y(t.data,r.version)||(a=this._getOrReturnCtx(t,a),y(a,{validation:"ip",code:c.invalid_string,message:r.message}),n.dirty()):"jwt"===r.kind?X(t.data,r.alg)||(a=this._getOrReturnCtx(t,a),y(a,{validation:"jwt",code:c.invalid_string,message:r.message}),n.dirty()):"cidr"===r.kind?ee(t.data,r.version)||(a=this._getOrReturnCtx(t,a),y(a,{validation:"cidr",code:c.invalid_string,message:r.message}),n.dirty()):"base64"===r.kind?J.test(t.data)||(a=this._getOrReturnCtx(t,a),y(a,{validation:"base64",code:c.invalid_string,message:r.message}),n.dirty()):"base64url"===r.kind?q.test(t.data)||(a=this._getOrReturnCtx(t,a),y(a,{validation:"base64url",code:c.invalid_string,message:r.message}),n.dirty()):e.assertNever(r);return{status:n.value,value:t.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:c.invalid_string,...v.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...v.errToObj(e)})}url(e){return this._addCheck({kind:"url",...v.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...v.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...v.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...v.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...v.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...v.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...v.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...v.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...v.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...v.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...v.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...v.errToObj(e)})}datetime(e){var t,n;return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,offset:null!=(t=null==e?void 0:e.offset)&&t,local:null!=(n=null==e?void 0:e.local)&&n,...v.errToObj(null==e?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,...v.errToObj(null==e?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...v.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...v.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:null==t?void 0:t.position,...v.errToObj(null==t?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...v.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...v.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...v.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...v.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...v.errToObj(t)})}nonempty(e){return this.min(1,v.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>"datetime"===e.kind)}get isDate(){return!!this._def.checks.find(e=>"date"===e.kind)}get isTime(){return!!this._def.checks.find(e=>"time"===e.kind)}get isDuration(){return!!this._def.checks.find(e=>"duration"===e.kind)}get isEmail(){return!!this._def.checks.find(e=>"email"===e.kind)}get isURL(){return!!this._def.checks.find(e=>"url"===e.kind)}get isEmoji(){return!!this._def.checks.find(e=>"emoji"===e.kind)}get isUUID(){return!!this._def.checks.find(e=>"uuid"===e.kind)}get isNANOID(){return!!this._def.checks.find(e=>"nanoid"===e.kind)}get isCUID(){return!!this._def.checks.find(e=>"cuid"===e.kind)}get isCUID2(){return!!this._def.checks.find(e=>"cuid2"===e.kind)}get isULID(){return!!this._def.checks.find(e=>"ulid"===e.kind)}get isIP(){return!!this._def.checks.find(e=>"ip"===e.kind)}get isCIDR(){return!!this._def.checks.find(e=>"cidr"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get isBase64url(){return!!this._def.checks.find(e=>"base64url"===e.kind)}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}};function ne(e,t){const n=(e.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,r=n>a?n:a;return Number.parseInt(e.toFixed(r).replace(".",""))%Number.parseInt(t.toFixed(r).replace(".",""))/10**r}te.create=e=>{var t;return new te({checks:[],typeName:Je.ZodString,coerce:null!=(t=null==e?void 0:e.coerce)&&t,...C(e)})};var ae=class t extends E{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){this._def.coerce&&(t.data=Number(t.data));if(this._getType(t)!==s.number){const e=this._getOrReturnCtx(t);return y(e,{code:c.invalid_type,expected:s.number,received:e.parsedType}),S}let n;const a=new _;for(const r of this._def.checks)if("int"===r.kind)e.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),y(n,{code:c.invalid_type,expected:"integer",received:"float",message:r.message}),a.dirty());else if("min"===r.kind){(r.inclusive?t.data<r.value:t.data<=r.value)&&(n=this._getOrReturnCtx(t,n),y(n,{code:c.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty())}else if("max"===r.kind){(r.inclusive?t.data>r.value:t.data>=r.value)&&(n=this._getOrReturnCtx(t,n),y(n,{code:c.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty())}else"multipleOf"===r.kind?0!==ne(t.data,r.value)&&(n=this._getOrReturnCtx(t,n),y(n,{code:c.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):"finite"===r.kind?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),y(n,{code:c.not_finite,message:r.message}),a.dirty()):e.assertNever(r);return{status:a.value,value:t.data}}gte(e,t){return this.setLimit("min",e,!0,v.toString(t))}gt(e,t){return this.setLimit("min",e,!1,v.toString(t))}lte(e,t){return this.setLimit("max",e,!0,v.toString(t))}lt(e,t){return this.setLimit("max",e,!1,v.toString(t))}setLimit(e,n,a,r){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:a,message:v.toString(r)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:v.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:v.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:v.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:v.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:v.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(t=>"int"===t.kind||"multipleOf"===t.kind&&e.isInteger(t.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if("finite"===n.kind||"int"===n.kind||"multipleOf"===n.kind)return!0;"min"===n.kind?(null===t||n.value>t)&&(t=n.value):"max"===n.kind&&(null===e||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}};ae.create=e=>new ae({checks:[],typeName:Je.ZodNumber,coerce:(null==e?void 0:e.coerce)||!1,...C(e)});var re=class t extends E{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch(e){return this._getInvalidInput(t)}if(this._getType(t)!==s.bigint)return this._getInvalidInput(t);let n;const a=new _;for(const r of this._def.checks)if("min"===r.kind){(r.inclusive?t.data<r.value:t.data<=r.value)&&(n=this._getOrReturnCtx(t,n),y(n,{code:c.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty())}else if("max"===r.kind){(r.inclusive?t.data>r.value:t.data>=r.value)&&(n=this._getOrReturnCtx(t,n),y(n,{code:c.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty())}else"multipleOf"===r.kind?t.data%r.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),y(n,{code:c.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):e.assertNever(r);return{status:a.value,value:t.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return y(t,{code:c.invalid_type,expected:s.bigint,received:t.parsedType}),S}gte(e,t){return this.setLimit("min",e,!0,v.toString(t))}gt(e,t){return this.setLimit("min",e,!1,v.toString(t))}lte(e,t){return this.setLimit("max",e,!0,v.toString(t))}lt(e,t){return this.setLimit("max",e,!1,v.toString(t))}setLimit(e,n,a,r){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:a,message:v.toString(r)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:v.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}};re.create=e=>{var t;return new re({checks:[],typeName:Je.ZodBigInt,coerce:null!=(t=null==e?void 0:e.coerce)&&t,...C(e)})};var ie=class extends E{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==s.boolean){const t=this._getOrReturnCtx(e);return y(t,{code:c.invalid_type,expected:s.boolean,received:t.parsedType}),S}return x(e.data)}};ie.create=e=>new ie({typeName:Je.ZodBoolean,coerce:(null==e?void 0:e.coerce)||!1,...C(e)});var se=class t extends E{_parse(t){this._def.coerce&&(t.data=new Date(t.data));if(this._getType(t)!==s.date){const e=this._getOrReturnCtx(t);return y(e,{code:c.invalid_type,expected:s.date,received:e.parsedType}),S}if(Number.isNaN(t.data.getTime())){return y(this._getOrReturnCtx(t),{code:c.invalid_date}),S}const n=new _;let a;for(const r of this._def.checks)"min"===r.kind?t.data.getTime()<r.value&&(a=this._getOrReturnCtx(t,a),y(a,{code:c.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),n.dirty()):"max"===r.kind?t.data.getTime()>r.value&&(a=this._getOrReturnCtx(t,a),y(a,{code:c.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),n.dirty()):e.assertNever(r);return{status:n.value,value:new Date(t.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:v.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:v.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}};se.create=e=>new se({checks:[],coerce:(null==e?void 0:e.coerce)||!1,typeName:Je.ZodDate,...C(e)});var oe=class extends E{_parse(e){if(this._getType(e)!==s.symbol){const t=this._getOrReturnCtx(e);return y(t,{code:c.invalid_type,expected:s.symbol,received:t.parsedType}),S}return x(e.data)}};oe.create=e=>new oe({typeName:Je.ZodSymbol,...C(e)});var ce=class extends E{_parse(e){if(this._getType(e)!==s.undefined){const t=this._getOrReturnCtx(e);return y(t,{code:c.invalid_type,expected:s.undefined,received:t.parsedType}),S}return x(e.data)}};ce.create=e=>new ce({typeName:Je.ZodUndefined,...C(e)});var de=class extends E{_parse(e){if(this._getType(e)!==s.null){const t=this._getOrReturnCtx(e);return y(t,{code:c.invalid_type,expected:s.null,received:t.parsedType}),S}return x(e.data)}};de.create=e=>new de({typeName:Je.ZodNull,...C(e)});var ue=class extends E{constructor(){super(...arguments),this._any=!0}_parse(e){return x(e.data)}};ue.create=e=>new ue({typeName:Je.ZodAny,...C(e)});var le=class extends E{constructor(){super(...arguments),this._unknown=!0}_parse(e){return x(e.data)}};le.create=e=>new le({typeName:Je.ZodUnknown,...C(e)});var pe=class extends E{_parse(e){const t=this._getOrReturnCtx(e);return y(t,{code:c.invalid_type,expected:s.never,received:t.parsedType}),S}};pe.create=e=>new pe({typeName:Je.ZodNever,...C(e)});var me=class extends E{_parse(e){if(this._getType(e)!==s.undefined){const t=this._getOrReturnCtx(e);return y(t,{code:c.invalid_type,expected:s.void,received:t.parsedType}),S}return x(e.data)}};me.create=e=>new me({typeName:Je.ZodVoid,...C(e)});var he=class e extends E{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),a=this._def;if(t.parsedType!==s.array)return y(t,{code:c.invalid_type,expected:s.array,received:t.parsedType}),S;if(null!==a.exactLength){const e=t.data.length>a.exactLength.value,r=t.data.length<a.exactLength.value;(e||r)&&(y(t,{code:e?c.too_big:c.too_small,minimum:r?a.exactLength.value:void 0,maximum:e?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),n.dirty())}if(null!==a.minLength&&t.data.length<a.minLength.value&&(y(t,{code:c.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),n.dirty()),null!==a.maxLength&&t.data.length>a.maxLength.value&&(y(t,{code:c.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>a.type._parseAsync(new A(t,e,t.path,n)))).then(e=>_.mergeArray(n,e));const r=[...t.data].map((e,n)=>a.type._parseSync(new A(t,e,t.path,n)));return _.mergeArray(n,r)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:v.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:v.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:v.toString(n)}})}nonempty(e){return this.min(1,e)}};function fe(e){if(e instanceof ge){const t={};for(const n in e.shape){const a=e.shape[n];t[n]=Ne.create(fe(a))}return new ge({...e._def,shape:()=>t})}return e instanceof he?new he({...e._def,type:fe(e.element)}):e instanceof Ne?Ne.create(fe(e.unwrap())):e instanceof $e?$e.create(fe(e.unwrap())):e instanceof ke?ke.create(e.items.map(e=>fe(e))):e}he.create=(e,t)=>new he({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Je.ZodArray,...C(t)});var ge=class t extends E{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const t=this._def.shape(),n=e.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(e){if(this._getType(e)!==s.object){const t=this._getOrReturnCtx(e);return y(t,{code:c.invalid_type,expected:s.object,received:t.parsedType}),S}const{status:t,ctx:n}=this._processInputParams(e),{shape:a,keys:r}=this._getCached(),i=[];if(!(this._def.catchall instanceof pe&&"strip"===this._def.unknownKeys))for(const e in n.data)r.includes(e)||i.push(e);const o=[];for(const e of r){const t=a[e],r=n.data[e];o.push({key:{status:"valid",value:e},value:t._parse(new A(n,r,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof pe){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of i)o.push({key:{status:"valid",value:e},value:{status:"valid",value:n.data[e]}});else if("strict"===e)i.length>0&&(y(n,{code:c.unrecognized_keys,keys:i}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of i){const a=n.data[t];o.push({key:{status:"valid",value:t},value:e._parse(new A(n,a,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const e=[];for(const t of o){const n=await t.key,a=await t.value;e.push({key:n,value:a,alwaysSet:t.alwaysSet})}return e}).then(e=>_.mergeObjectSync(t,e)):_.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return v.errToObj,new t({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,n)=>{var a,r,i,s;const o=null!=(i=null==(r=(a=this._def).errorMap)?void 0:r.call(a,t,n).message)?i:n.defaultError;return"unrecognized_keys"===t.code?{message:null!=(s=v.errToObj(e).message)?s:o}:{message:o}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Je.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new t({...this._def,catchall:e})}pick(n){const a={};for(const t of e.objectKeys(n))n[t]&&this.shape[t]&&(a[t]=this.shape[t]);return new t({...this._def,shape:()=>a})}omit(n){const a={};for(const t of e.objectKeys(this.shape))n[t]||(a[t]=this.shape[t]);return new t({...this._def,shape:()=>a})}deepPartial(){return fe(this)}partial(n){const a={};for(const t of e.objectKeys(this.shape)){const e=this.shape[t];n&&!n[t]?a[t]=e:a[t]=e.optional()}return new t({...this._def,shape:()=>a})}required(n){const a={};for(const t of e.objectKeys(this.shape))if(n&&!n[t])a[t]=this.shape[t];else{let e=this.shape[t];for(;e instanceof Ne;)e=e._def.innerType;a[t]=e}return new t({...this._def,shape:()=>a})}keyof(){return Te(e.objectKeys(this.shape))}};ge.create=(e,t)=>new ge({shape:()=>e,unknownKeys:"strip",catchall:pe.create(),typeName:Je.ZodObject,...C(t)}),ge.strictCreate=(e,t)=>new ge({shape:()=>e,unknownKeys:"strict",catchall:pe.create(),typeName:Je.ZodObject,...C(t)}),ge.lazycreate=(e,t)=>new ge({shape:e,unknownKeys:"strip",catchall:pe.create(),typeName:Je.ZodObject,...C(t)});var ye=class extends E{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;if(t.common.async)return Promise.all(n.map(async e=>{const n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const n of e)if("dirty"===n.result.status)return t.common.issues.push(...n.ctx.common.issues),n.result;const n=e.map(e=>new u(e.ctx.common.issues));return y(t,{code:c.invalid_union,unionErrors:n}),S});{let e;const a=[];for(const r of n){const n={...t,common:{...t.common,issues:[]},parent:null},i=r._parseSync({data:t.data,path:t.path,parent:n});if("valid"===i.status)return i;"dirty"!==i.status||e||(e={result:i,ctx:n}),n.common.issues.length&&a.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const r=a.map(e=>new u(e));return y(t,{code:c.invalid_union,unionErrors:r}),S}}get options(){return this._def.options}};ye.create=(e,t)=>new ye({options:e,typeName:Je.ZodUnion,...C(t)});var ve=t=>t instanceof Pe?ve(t.schema):t instanceof Ie?ve(t.innerType()):t instanceof Ae?[t.value]:t instanceof Ce?t.options:t instanceof Oe?e.objectValues(t.enum):t instanceof Me?ve(t._def.innerType):t instanceof ce?[void 0]:t instanceof de?[null]:t instanceof Ne?[void 0,...ve(t.unwrap())]:t instanceof $e?[null,...ve(t.unwrap())]:t instanceof Le||t instanceof Ue?ve(t.unwrap()):t instanceof Re?ve(t._def.innerType):[],be=class e extends E{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==s.object)return y(t,{code:c.invalid_type,expected:s.object,received:t.parsedType}),S;const n=this.discriminator,a=t.data[n],r=this.optionsMap.get(a);return r?t.common.async?r._parseAsync({data:t.data,path:t.path,parent:t}):r._parseSync({data:t.data,path:t.path,parent:t}):(y(t,{code:c.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),S)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,a){const r=new Map;for(const e of n){const n=ve(e.shape[t]);if(!n.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const a of n){if(r.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);r.set(a,e)}}return new e({typeName:Je.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:r,...C(a)})}};function _e(t,n){const a=o(t),r=o(n);if(t===n)return{valid:!0,data:t};if(a===s.object&&r===s.object){const a=e.objectKeys(n),r=e.objectKeys(t).filter(e=>-1!==a.indexOf(e)),i={...t,...n};for(const e of r){const a=_e(t[e],n[e]);if(!a.valid)return{valid:!1};i[e]=a.data}return{valid:!0,data:i}}if(a===s.array&&r===s.array){if(t.length!==n.length)return{valid:!1};const e=[];for(let a=0;a<t.length;a++){const r=_e(t[a],n[a]);if(!r.valid)return{valid:!1};e.push(r.data)}return{valid:!0,data:e}}return a===s.date&&r===s.date&&+t===+n?{valid:!0,data:t}:{valid:!1}}var Se=class extends E{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),a=(e,a)=>{if(w(e)||w(a))return S;const r=_e(e.value,a.value);return r.valid?((j(e)||j(a))&&t.dirty(),{status:t.value,value:r.data}):(y(n,{code:c.invalid_intersection_types}),S)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>a(e,t)):a(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Se.create=(e,t,n)=>new Se({left:e,right:t,typeName:Je.ZodIntersection,...C(n)});var ke=class e extends E{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==s.array)return y(n,{code:c.invalid_type,expected:s.array,received:n.parsedType}),S;if(n.data.length<this._def.items.length)return y(n,{code:c.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),S;!this._def.rest&&n.data.length>this._def.items.length&&(y(n,{code:c.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...n.data].map((e,t)=>{const a=this._def.items[t]||this._def.rest;return a?a._parse(new A(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(a).then(e=>_.mergeArray(t,e)):_.mergeArray(t,a)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};ke.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ke({items:e,typeName:Je.ZodTuple,rest:null,...C(t)})};var xe=class e extends E{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==s.object)return y(n,{code:c.invalid_type,expected:s.object,received:n.parsedType}),S;const a=[],r=this._def.keyType,i=this._def.valueType;for(const e in n.data)a.push({key:r._parse(new A(n,e,n.path,e)),value:i._parse(new A(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?_.mergeObjectAsync(t,a):_.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(t,n,a){return new e(n instanceof E?{keyType:t,valueType:n,typeName:Je.ZodRecord,...C(a)}:{keyType:te.create(),valueType:t,typeName:Je.ZodRecord,...C(n)})}},we=class extends E{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==s.map)return y(n,{code:c.invalid_type,expected:s.map,received:n.parsedType}),S;const a=this._def.keyType,r=this._def.valueType,i=[...n.data.entries()].map(([e,t],i)=>({key:a._parse(new A(n,e,n.path,[i,"key"])),value:r._parse(new A(n,t,n.path,[i,"value"]))}));if(n.common.async){const e=new Map;return Promise.resolve().then(async()=>{for(const n of i){const a=await n.key,r=await n.value;if("aborted"===a.status||"aborted"===r.status)return S;"dirty"!==a.status&&"dirty"!==r.status||t.dirty(),e.set(a.value,r.value)}return{status:t.value,value:e}})}{const e=new Map;for(const n of i){const a=n.key,r=n.value;if("aborted"===a.status||"aborted"===r.status)return S;"dirty"!==a.status&&"dirty"!==r.status||t.dirty(),e.set(a.value,r.value)}return{status:t.value,value:e}}}};we.create=(e,t,n)=>new we({valueType:t,keyType:e,typeName:Je.ZodMap,...C(n)});var je=class e extends E{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==s.set)return y(n,{code:c.invalid_type,expected:s.set,received:n.parsedType}),S;const a=this._def;null!==a.minSize&&n.data.size<a.minSize.value&&(y(n,{code:c.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),t.dirty()),null!==a.maxSize&&n.data.size>a.maxSize.value&&(y(n,{code:c.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());const r=this._def.valueType;function i(e){const n=new Set;for(const a of e){if("aborted"===a.status)return S;"dirty"===a.status&&t.dirty(),n.add(a.value)}return{status:t.value,value:n}}const o=[...n.data.values()].map((e,t)=>r._parse(new A(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>i(e)):i(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:v.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:v.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};je.create=(e,t)=>new je({valueType:e,minSize:null,maxSize:null,typeName:Je.ZodSet,...C(t)});var Ze=class e extends E{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==s.function)return y(t,{code:c.invalid_type,expected:s.function,received:t.parsedType}),S;function n(e,n){return f({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,h(),l].filter(e=>!!e),issueData:{code:c.invalid_arguments,argumentsError:n}})}function a(e,n){return f({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,h(),l].filter(e=>!!e),issueData:{code:c.invalid_return_type,returnTypeError:n}})}const r={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Ee){const e=this;return x(async function(...t){const s=new u([]),o=await e._def.args.parseAsync(t,r).catch(e=>{throw s.addIssue(n(t,e)),s}),c=await Reflect.apply(i,this,o);return await e._def.returns._def.type.parseAsync(c,r).catch(e=>{throw s.addIssue(a(c,e)),s})})}{const e=this;return x(function(...t){const s=e._def.args.safeParse(t,r);if(!s.success)throw new u([n(t,s.error)]);const o=Reflect.apply(i,this,s.data),c=e._def.returns.safeParse(o,r);if(!c.success)throw new u([a(o,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:ke.create(t).rest(le.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,a){return new e({args:t||ke.create([]).rest(le.create()),returns:n||le.create(),typeName:Je.ZodFunction,...C(a)})}},Pe=class extends E{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})}};Pe.create=(e,t)=>new Pe({getter:e,typeName:Je.ZodLazy,...C(t)});var Ae=class extends E{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return y(t,{received:t.data,code:c.invalid_literal,expected:this._def.value}),S}return{status:"valid",value:e.data}}get value(){return this._def.value}};function Te(e,t){return new Ce({values:e,typeName:Je.ZodEnum,...C(t)})}Ae.create=(e,t)=>new Ae({value:e,typeName:Je.ZodLiteral,...C(t)});var Ce=class t extends E{_parse(t){if("string"!=typeof t.data){const n=this._getOrReturnCtx(t),a=this._def.values;return y(n,{expected:e.joinValues(a),received:n.parsedType,code:c.invalid_type}),S}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const e=this._getOrReturnCtx(t),n=this._def.values;return y(e,{received:e.data,code:c.invalid_enum_value,options:n}),S}return x(t.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,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(t=>!e.includes(t)),{...this._def,...n})}};Ce.create=Te;var Oe=class extends E{_parse(t){const n=e.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(t);if(a.parsedType!==s.string&&a.parsedType!==s.number){const t=e.objectValues(n);return y(a,{expected:e.joinValues(t),received:a.parsedType,code:c.invalid_type}),S}if(this._cache||(this._cache=new Set(e.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const t=e.objectValues(n);return y(a,{received:a.data,code:c.invalid_enum_value,options:t}),S}return x(t.data)}get enum(){return this._def.values}};Oe.create=(e,t)=>new Oe({values:e,typeName:Je.ZodNativeEnum,...C(t)});var Ee=class extends E{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==s.promise&&!1===t.common.async)return y(t,{code:c.invalid_type,expected:s.promise,received:t.parsedType}),S;const n=t.parsedType===s.promise?t.data:Promise.resolve(t.data);return x(n.then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Ee.create=(e,t)=>new Ee({type:e,typeName:Je.ZodPromise,...C(t)});var Ie=class extends E{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Je.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:a}=this._processInputParams(t),r=this._def.effect||null,i={addIssue:e=>{y(a,e),e.fatal?n.abort():n.dirty()},get path(){return a.path}};if(i.addIssue=i.addIssue.bind(i),"preprocess"===r.type){const e=r.transform(a.data,i);if(a.common.async)return Promise.resolve(e).then(async e=>{if("aborted"===n.value)return S;const t=await this._def.schema._parseAsync({data:e,path:a.path,parent:a});return"aborted"===t.status?S:"dirty"===t.status||"dirty"===n.value?k(t.value):t});{if("aborted"===n.value)return S;const t=this._def.schema._parseSync({data:e,path:a.path,parent:a});return"aborted"===t.status?S:"dirty"===t.status||"dirty"===n.value?k(t.value):t}}if("refinement"===r.type){const e=e=>{const t=r.refinement(e,i);if(a.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===a.common.async){const t=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return"aborted"===t.status?S:("dirty"===t.status&&n.dirty(),e(t.value),{status:n.value,value:t.value})}return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(t=>"aborted"===t.status?S:("dirty"===t.status&&n.dirty(),e(t.value).then(()=>({status:n.value,value:t.value}))))}if("transform"===r.type){if(!1===a.common.async){const e=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!Z(e))return S;const t=r.transform(e.value,i);if(t instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:t}}return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(e=>Z(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:n.value,value:e})):S)}e.assertNever(r)}};Ie.create=(e,t,n)=>new Ie({schema:e,typeName:Je.ZodEffects,effect:t,...C(n)}),Ie.createWithPreprocess=(e,t,n)=>new Ie({schema:t,effect:{type:"preprocess",transform:e},typeName:Je.ZodEffects,...C(n)});var Ne=class extends E{_parse(e){return this._getType(e)===s.undefined?x(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ne.create=(e,t)=>new Ne({innerType:e,typeName:Je.ZodOptional,...C(t)});var $e=class extends E{_parse(e){return this._getType(e)===s.null?x(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};$e.create=(e,t)=>new $e({innerType:e,typeName:Je.ZodNullable,...C(t)});var Me=class extends E{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===s.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Me.create=(e,t)=>new Me({innerType:e,typeName:Je.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...C(t)});var Re=class extends E{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return P(a)?a.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new u(n.common.issues)},input:n.data})})):{status:"valid",value:"valid"===a.status?a.value:this._def.catchValue({get error(){return new u(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Re.create=(e,t)=>new Re({innerType:e,typeName:Je.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...C(t)});var De=class extends E{_parse(e){if(this._getType(e)!==s.nan){const t=this._getOrReturnCtx(e);return y(t,{code:c.invalid_type,expected:s.nan,received:t.parsedType}),S}return{status:"valid",value:e.data}}};De.create=e=>new De({typeName:Je.ZodNaN,...C(e)});var ze=Symbol("zod_brand"),Le=class extends E{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},Fe=class e extends E{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async){return(async()=>{const e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return"aborted"===e.status?S:"dirty"===e.status?(t.dirty(),k(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})()}{const e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return"aborted"===e.status?S:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:Je.ZodPipeline})}},Ue=class extends E{_parse(e){const t=this._def.innerType._parse(e),n=e=>(Z(e)&&(e.value=Object.freeze(e.value)),e);return P(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};function Be(e,t){const n="function"==typeof e?e(t):"string"==typeof e?{message:e}:e;return"string"==typeof n?{message:n}:n}function Ve(e,t={},n){return e?ue.create().superRefine((a,r)=>{var i,s;const o=e(a);if(o instanceof Promise)return o.then(e=>{var i,s;if(!e){const e=Be(t,a),o=null==(s=null!=(i=e.fatal)?i:n)||s;r.addIssue({code:"custom",...e,fatal:o})}});if(!o){const e=Be(t,a),o=null==(s=null!=(i=e.fatal)?i:n)||s;r.addIssue({code:"custom",...e,fatal:o})}}):ue.create()}Ue.create=(e,t)=>new Ue({innerType:e,typeName:Je.ZodReadonly,...C(t)});var Je,qe,We={object:ge.lazycreate};(qe=Je||(Je={})).ZodString="ZodString",qe.ZodNumber="ZodNumber",qe.ZodNaN="ZodNaN",qe.ZodBigInt="ZodBigInt",qe.ZodBoolean="ZodBoolean",qe.ZodDate="ZodDate",qe.ZodSymbol="ZodSymbol",qe.ZodUndefined="ZodUndefined",qe.ZodNull="ZodNull",qe.ZodAny="ZodAny",qe.ZodUnknown="ZodUnknown",qe.ZodNever="ZodNever",qe.ZodVoid="ZodVoid",qe.ZodArray="ZodArray",qe.ZodObject="ZodObject",qe.ZodUnion="ZodUnion",qe.ZodDiscriminatedUnion="ZodDiscriminatedUnion",qe.ZodIntersection="ZodIntersection",qe.ZodTuple="ZodTuple",qe.ZodRecord="ZodRecord",qe.ZodMap="ZodMap",qe.ZodSet="ZodSet",qe.ZodFunction="ZodFunction",qe.ZodLazy="ZodLazy",qe.ZodLiteral="ZodLiteral",qe.ZodEnum="ZodEnum",qe.ZodEffects="ZodEffects",qe.ZodNativeEnum="ZodNativeEnum",qe.ZodOptional="ZodOptional",qe.ZodNullable="ZodNullable",qe.ZodDefault="ZodDefault",qe.ZodCatch="ZodCatch",qe.ZodPromise="ZodPromise",qe.ZodBranded="ZodBranded",qe.ZodPipeline="ZodPipeline",qe.ZodReadonly="ZodReadonly";var Ke=(e,t={message:`Input not instance of ${e.name}`})=>Ve(t=>t instanceof e,t),He=te.create,Qe=ae.create,Ge=De.create,Ye=re.create,Xe=ie.create,et=se.create,tt=oe.create,nt=ce.create,at=de.create,rt=ue.create,it=le.create,st=pe.create,ot=me.create,ct=he.create,dt=ge.create,ut=ge.strictCreate,lt=ye.create,pt=be.create,mt=Se.create,ht=ke.create,ft=xe.create,gt=we.create,yt=je.create,vt=Ze.create,bt=Pe.create,_t=Ae.create,St=Ce.create,kt=Oe.create,xt=Ee.create,wt=Ie.create,jt=Ne.create,Zt=$e.create,Pt=Ie.createWithPreprocess,At=Fe.create,Tt=()=>He().optional(),Ct=()=>Qe().optional(),Ot=()=>Xe().optional(),Et={string:e=>te.create({...e,coerce:!0}),number:e=>ae.create({...e,coerce:!0}),boolean:e=>ie.create({...e,coerce:!0}),bigint:e=>re.create({...e,coerce:!0}),date:e=>se.create({...e,coerce:!0})},It=S,Nt=Symbol("Let zodToJsonSchema decide on which parser to use"),$t={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},Mt=e=>{const t=(e=>"string"==typeof e?{...$t,name:e}:{...$t,...e})(e),n=void 0!==t.name?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}};function Rt(e,t,n,a){(null==a?void 0:a.errorMessages)&&n&&(e.errorMessage={...e.errorMessage,[t]:n})}function Dt(e,t,n,a,r){e[t]=n,Rt(e,t,a,r)}var zt=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join("/")};function Lt(e){if("openAi"!==e.target)return{};const t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:"relative"===e.$refStrategy?zt(t,e.currentPath):t.join("/")}}function Ft(e,t){return fn(e.type._def,t)}function Ut(e,t,n){const a=null!=n?n:t.dateStrategy;if(Array.isArray(a))return{anyOf:a.map((n,a)=>Ut(e,t,n))};switch(a){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Bt(e,t)}}var Bt=(e,t)=>{const n={type:"integer",format:"unix-time"};if("openApi3"===t.target)return n;for(const a of e.checks)switch(a.kind){case"min":Dt(n,"minimum",a.value,a.message,t);break;case"max":Dt(n,"maximum",a.value,a.message,t)}return n};var Vt=void 0,Jt=/^[cC][^\s-]{8,}$/,qt=/^[0-9a-z]+$/,Wt=/^[0-9A-HJKMNP-TV-Z]{26}$/,Kt=/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,Ht=()=>(void 0===Vt&&(Vt=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Vt),Qt=/^(?:(?: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])$/,Gt=/^(([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])$/,Yt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Xt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,en=/^[a-zA-Z0-9_-]{21}$/,tn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;function nn(e,t){const n={type:"string"};if(e.checks)for(const a of e.checks)switch(a.kind){case"min":Dt(n,"minLength","number"==typeof n.minLength?Math.max(n.minLength,a.value):a.value,a.message,t);break;case"max":Dt(n,"maxLength","number"==typeof n.maxLength?Math.min(n.maxLength,a.value):a.value,a.message,t);break;case"email":switch(t.emailStrategy){case"format:email":sn(n,"email",a.message,t);break;case"format:idn-email":sn(n,"idn-email",a.message,t);break;case"pattern:zod":on(n,Kt,a.message,t)}break;case"url":sn(n,"uri",a.message,t);break;case"uuid":sn(n,"uuid",a.message,t);break;case"regex":on(n,a.regex,a.message,t);break;case"cuid":on(n,Jt,a.message,t);break;case"cuid2":on(n,qt,a.message,t);break;case"startsWith":on(n,RegExp(`^${an(a.value,t)}`),a.message,t);break;case"endsWith":on(n,RegExp(`${an(a.value,t)}$`),a.message,t);break;case"datetime":sn(n,"date-time",a.message,t);break;case"date":sn(n,"date",a.message,t);break;case"time":sn(n,"time",a.message,t);break;case"duration":sn(n,"duration",a.message,t);break;case"length":Dt(n,"minLength","number"==typeof n.minLength?Math.max(n.minLength,a.value):a.value,a.message,t),Dt(n,"maxLength","number"==typeof n.maxLength?Math.min(n.maxLength,a.value):a.value,a.message,t);break;case"includes":on(n,RegExp(an(a.value,t)),a.message,t);break;case"ip":"v6"!==a.version&&sn(n,"ipv4",a.message,t),"v4"!==a.version&&sn(n,"ipv6",a.message,t);break;case"base64url":on(n,Xt,a.message,t);break;case"jwt":on(n,tn,a.message,t);break;case"cidr":"v6"!==a.version&&on(n,Qt,a.message,t),"v4"!==a.version&&on(n,Gt,a.message,t);break;case"emoji":on(n,Ht(),a.message,t);break;case"ulid":on(n,Wt,a.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":sn(n,"binary",a.message,t);break;case"contentEncoding:base64":Dt(n,"contentEncoding","base64",a.message,t);break;case"pattern:zod":on(n,Yt,a.message,t)}break;case"nanoid":on(n,en,a.message,t)}return n}function an(e,t){return"escape"===t.patternStrategy?function(e){let t="";for(let n=0;n<e.length;n++)rn.has(e[n])||(t+="\\"),t+=e[n];return t}(e):e}var rn=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function sn(e,t,n,a){var r;e.format||(null==(r=e.anyOf)?void 0:r.some(e=>e.format))?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&a.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.anyOf.push({format:t,...n&&a.errorMessages&&{errorMessage:{format:n}}})):Dt(e,"format",t,n,a)}function on(e,t,n,a){var r;e.pattern||(null==(r=e.allOf)?void 0:r.some(e=>e.pattern))?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&a.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.allOf.push({pattern:cn(t,a),...n&&a.errorMessages&&{errorMessage:{pattern:n}}})):Dt(e,"pattern",cn(t,a),n,a)}function cn(e,t){var n;if(!t.applyRegexFlags||!e.flags)return e.source;const a=e.flags.includes("i"),r=e.flags.includes("m"),i=e.flags.includes("s"),s=a?e.source.toLowerCase():e.source;let o="",c=!1,d=!1,u=!1;for(let e=0;e<s.length;e++)if(c)o+=s[e],c=!1;else{if(a)if(d){if(s[e].match(/[a-z]/)){u?(o+=s[e],o+=`${s[e-2]}-${s[e]}`.toUpperCase(),u=!1):"-"===s[e+1]&&(null==(n=s[e+2])?void 0:n.match(/[a-z]/))?(o+=s[e],u=!0):o+=`${s[e]}${s[e].toUpperCase()}`;continue}}else if(s[e].match(/[a-z]/)){o+=`[${s[e]}${s[e].toUpperCase()}]`;continue}if(r){if("^"===s[e]){o+="(^|(?<=[\r\n]))";continue}if("$"===s[e]){o+="($|(?=[\r\n]))";continue}}i&&"."===s[e]?o+=d?`${s[e]}\r\n`:`[${s[e]}\r\n]`:(o+=s[e],"\\"===s[e]?c=!0:d&&"]"===s[e]?d=!1:d||"["!==s[e]||(d=!0))}try{new RegExp(o)}catch(n){return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return o}function dn(e,t){var n,a,r,i,s,o,c;if("openAi"===t.target&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),"openApi3"===t.target&&(null==(n=e.keyType)?void 0:n._def.typeName)===Je.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((n,a)=>{var r;return{...n,[a]:null!=(r=fn(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",a]}))?r:Lt(t)}},{}),additionalProperties:t.rejectedAdditionalProperties};const d={type:"object",additionalProperties:null!=(a=fn(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))?a:t.allowedAdditionalProperties};if("openApi3"===t.target)return d;if((null==(r=e.keyType)?void 0:r._def.typeName)===Je.ZodString&&(null==(i=e.keyType._def.checks)?void 0:i.length)){const{type:n,...a}=nn(e.keyType._def,t);return{...d,propertyNames:a}}if((null==(s=e.keyType)?void 0:s._def.typeName)===Je.ZodEnum)return{...d,propertyNames:{enum:e.keyType._def.values}};if((null==(o=e.keyType)?void 0:o._def.typeName)===Je.ZodBranded&&e.keyType._def.type._def.typeName===Je.ZodString&&(null==(c=e.keyType._def.type._def.checks)?void 0:c.length)){const{type:n,...a}=Ft(e.keyType._def,t);return{...d,propertyNames:a}}return d}var un={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};var ln=(e,t)=>{const n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,n)=>fn(e._def,{...t,currentPath:[...t.currentPath,"anyOf",`${n}`]})).filter(e=>!!e&&(!t.strictUnions||"object"==typeof e&&Object.keys(e).length>0));return n.length?{anyOf:n}:void 0};function pn(e,t){const n="openAi"===t.target,a={type:"object",properties:{}},r=[],i=e.shape();for(const e in i){let s=i[e];if(void 0===s||void 0===s._def)continue;let o=mn(s);o&&n&&("ZodOptional"===s._def.typeName&&(s=s._def.innerType),s.isNullable()||(s=s.nullable()),o=!1);const c=fn(s._def,{...t,currentPath:[...t.currentPath,"properties",e],propertyPath:[...t.currentPath,"properties",e]});void 0!==c&&(a.properties[e]=c,o||r.push(e))}r.length&&(a.required=r);const s=function(e,t){if("ZodNever"!==e.catchall._def.typeName)return fn(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return"strict"===t.removeAdditionalStrategy?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}(e,t);return void 0!==s&&(a.additionalProperties=s),a}function mn(e){try{return e.isOptional()}catch(e){return!0}}var hn=(e,t,n)=>{switch(t){case Je.ZodString:return nn(e,n);case Je.ZodNumber:return function(e,t){const n={type:"number"};if(!e.checks)return n;for(const a of e.checks)switch(a.kind){case"int":n.type="integer",Rt(n,"type",a.message,t);break;case"min":"jsonSchema7"===t.target?a.inclusive?Dt(n,"minimum",a.value,a.message,t):Dt(n,"exclusiveMinimum",a.value,a.message,t):(a.inclusive||(n.exclusiveMinimum=!0),Dt(n,"minimum",a.value,a.message,t));break;case"max":"jsonSchema7"===t.target?a.inclusive?Dt(n,"maximum",a.value,a.message,t):Dt(n,"exclusiveMaximum",a.value,a.message,t):(a.inclusive||(n.exclusiveMaximum=!0),Dt(n,"maximum",a.value,a.message,t));break;case"multipleOf":Dt(n,"multipleOf",a.value,a.message,t)}return n}(e,n);case Je.ZodObject:return pn(e,n);case Je.ZodBigInt:return function(e,t){const n={type:"integer",format:"int64"};if(!e.checks)return n;for(const a of e.checks)switch(a.kind){case"min":"jsonSchema7"===t.target?a.inclusive?Dt(n,"minimum",a.value,a.message,t):Dt(n,"exclusiveMinimum",a.value,a.message,t):(a.inclusive||(n.exclusiveMinimum=!0),Dt(n,"minimum",a.value,a.message,t));break;case"max":"jsonSchema7"===t.target?a.inclusive?Dt(n,"maximum",a.value,a.message,t):Dt(n,"exclusiveMaximum",a.value,a.message,t):(a.inclusive||(n.exclusiveMaximum=!0),Dt(n,"maximum",a.value,a.message,t));break;case"multipleOf":Dt(n,"multipleOf",a.value,a.message,t)}return n}(e,n);case Je.ZodBoolean:return{type:"boolean"};case Je.ZodDate:return Ut(e,n);case Je.ZodUndefined:return function(e){return{not:Lt(e)}}(n);case Je.ZodNull:return function(e){return"openApi3"===e.target?{enum:["null"],nullable:!0}:{type:"null"}}(n);case Je.ZodArray:return function(e,t){var n,a,r;const i={type:"array"};return(null==(n=e.type)?void 0:n._def)&&(null==(r=null==(a=e.type)?void 0:a._def)?void 0:r.typeName)!==Je.ZodAny&&(i.items=fn(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&Dt(i,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&Dt(i,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(Dt(i,"minItems",e.exactLength.value,e.exactLength.message,t),Dt(i,"maxItems",e.exactLength.value,e.exactLength.message,t)),i}(e,n);case Je.ZodUnion:case Je.ZodDiscriminatedUnion:return function(e,t){if("openApi3"===t.target)return ln(e,t);const n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(e=>e._def.typeName in un&&(!e._def.checks||!e._def.checks.length))){const e=n.reduce((e,t)=>{const n=un[t._def.typeName];return n&&!e.includes(n)?[...e,n]:e},[]);return{type:e.length>1?e:e[0]}}if(n.every(e=>"ZodLiteral"===e._def.typeName&&!e.description)){const e=n.reduce((e,t)=>{const n=typeof t._def.value;switch(n){case"string":case"number":case"boolean":return[...e,n];case"bigint":return[...e,"integer"];case"object":if(null===t._def.value)return[...e,"null"];default:return e}},[]);if(e.length===n.length){const t=e.filter((e,t,n)=>n.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:n.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(n.every(e=>"ZodEnum"===e._def.typeName))return{type:"string",enum:n.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return ln(e,t)}(e,n);case Je.ZodIntersection:return function(e,t){const n=[fn(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),fn(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(e=>!!e);let a="jsonSchema2019-09"===t.target?{unevaluatedProperties:!1}:void 0;const r=[];return n.forEach(e=>{if("type"in(t=e)&&"string"===t.type||!("allOf"in t)){let t=e;if("additionalProperties"in e&&!1===e.additionalProperties){const{additionalProperties:n,...a}=e;t=a}else a=void 0;r.push(t)}else r.push(...e.allOf),void 0===e.unevaluatedProperties&&(a=void 0);var t}),r.length?{allOf:r,...a}:void 0}(e,n);case Je.ZodTuple:return function(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((e,n)=>fn(e._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[]),additionalItems:fn(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,n)=>fn(e._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[])}}(e,n);case Je.ZodRecord:return dn(e,n);case Je.ZodLiteral:return function(e,t){const n=typeof e.value;return"bigint"!==n&&"number"!==n&&"boolean"!==n&&"string"!==n?{type:Array.isArray(e.value)?"array":"object"}:"openApi3"===t.target?{type:"bigint"===n?"integer":n,enum:[e.value]}:{type:"bigint"===n?"integer":n,const:e.value}}(e,n);case Je.ZodEnum:return function(e){return{type:"string",enum:Array.from(e.values)}}(e);case Je.ZodNativeEnum:return function(e){const t=e.values,n=Object.keys(e.values).filter(e=>"number"!=typeof t[t[e]]).map(e=>t[e]),a=Array.from(new Set(n.map(e=>typeof e)));return{type:1===a.length?"string"===a[0]?"string":"number":["string","number"],enum:n}}(e);case Je.ZodNullable:return function(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return"openApi3"===t.target?{type:un[e.innerType._def.typeName],nullable:!0}:{type:[un[e.innerType._def.typeName],"null"]};if("openApi3"===t.target){const n=fn(e.innerType._def,{...t,currentPath:[...t.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}const n=fn(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}(e,n);case Je.ZodOptional:return((e,t)=>{var n;if(t.currentPath.toString()===(null==(n=t.propertyPath)?void 0:n.toString()))return fn(e.innerType._def,t);const a=fn(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return a?{anyOf:[{not:Lt(t)},a]}:Lt(t)})(e,n);case Je.ZodMap:return function(e,t){return"record"===t.mapStrategy?dn(e,t):{type:"array",maxItems:125,items:{type:"array",items:[fn(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||Lt(t),fn(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||Lt(t)],minItems:2,maxItems:2}}}(e,n);case Je.ZodSet:return function(e,t){const n={type:"array",uniqueItems:!0,items:fn(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&Dt(n,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&Dt(n,"maxItems",e.maxSize.value,e.maxSize.message,t),n}(e,n);case Je.ZodLazy:return()=>e.getter()._def;case Je.ZodPromise:return function(e,t){return fn(e.type._def,t)}(e,n);case Je.ZodNaN:case Je.ZodNever:return function(e){return"openAi"===e.target?void 0:{not:Lt({...e,currentPath:[...e.currentPath,"not"]})}}(n);case Je.ZodEffects:return function(e,t){return"input"===t.effectStrategy?fn(e.schema._def,t):Lt(t)}(e,n);case Je.ZodAny:return Lt(n);case Je.ZodUnknown:return function(e){return Lt(e)}(n);case Je.ZodDefault:return function(e,t){return{...fn(e.innerType._def,t),default:e.defaultValue()}}(e,n);case Je.ZodBranded:return Ft(e,n);case Je.ZodReadonly:case Je.ZodCatch:return((e,t)=>fn(e.innerType._def,t))(e,n);case Je.ZodPipeline:return((e,t)=>{if("input"===t.pipeStrategy)return fn(e.in._def,t);if("output"===t.pipeStrategy)return fn(e.out._def,t);const n=fn(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]});return{allOf:[n,fn(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",n?"1":"0"]})].filter(e=>void 0!==e)}})(e,n);case Je.ZodFunction:case Je.ZodVoid:case Je.ZodSymbol:default:return}};function fn(e,t,n=!1){var a;const r=t.seen.get(e);if(t.override){const i=null==(a=t.override)?void 0:a.call(t,e,t,r,n);if(i!==Nt)return i}if(r&&!n){const e=gn(r,t);if(void 0!==e)return e}const i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);const s=hn(e,e.typeName,t),o="function"==typeof s?fn(s(),t):s;if(o&&yn(e,t,o),t.postProcess){const n=t.postProcess(o,e,t);return i.jsonSchema=o,n}return i.jsonSchema=o,o}var gn=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:zt(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((e,n)=>t.currentPath[n]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),Lt(t)):"seen"===t.$refStrategy?Lt(t):void 0}},yn=(e,t,n)=>(e.description&&(n.description=e.description,t.markdownDescription&&(n.markdownDescription=e.description)),n),vn=(e,t)=>{var n;const a=Mt(t);let r="object"==typeof t&&t.definitions?Object.entries(t.definitions).reduce((e,[t,n])=>{var r;return{...e,[t]:null!=(r=fn(n._def,{...a,currentPath:[...a.basePath,a.definitionPath,t]},!0))?r:Lt(a)}},{}):void 0;const i="string"==typeof t?t:"title"===(null==t?void 0:t.nameStrategy)||null==t?void 0:t.name,s=null!=(n=fn(e._def,void 0===i?a:{...a,currentPath:[...a.basePath,a.definitionPath,i]},!1))?n:Lt(a),o="object"==typeof t&&void 0!==t.name&&"title"===t.nameStrategy?t.name:void 0;void 0!==o&&(s.title=o),a.flags.hasReferencedOpenAiAnyType&&(r||(r={}),r[a.openAiAnyTypeName]||(r[a.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:"relative"===a.$refStrategy?"1":[...a.basePath,a.definitionPath,a.openAiAnyTypeName].join("/")}}));const c=void 0===i?r?{...s,[a.definitionPath]:r}:s:{$ref:[..."relative"===a.$refStrategy?[]:a.basePath,a.definitionPath,i].join("/"),[a.definitionPath]:{...r,[i]:s}};return"jsonSchema7"===a.target?c.$schema="http://json-schema.org/draft-07/schema#":"jsonSchema2019-09"!==a.target&&"openAi"!==a.target||(c.$schema="https://json-schema.org/draft/2019-09/schema#"),"openAi"===a.target&&("anyOf"in c||"oneOf"in c||"allOf"in c||"type"in c&&Array.isArray(c.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),c},bn=Object.defineProperty,_n=(e,t)=>{for(var n in t)bn(e,n,{get:t[n],enumerable:!0})},Sn=i.string(),kn=i.number(),xn=(i.boolean(),i.string().min(1)),wn=i.number().int().positive(),jn=i.number().int().nonnegative(),Zn=i.number().describe("Tagging version number");i.union([i.string(),i.number(),i.boolean()]).optional();_n({},{ErrorHandlerSchema:()=>Tn,HandlerSchema:()=>On,LogHandlerSchema:()=>Cn,StorageSchema:()=>An,StorageTypeSchema:()=>Pn,errorHandlerJsonSchema:()=>Nn,handlerJsonSchema:()=>Mn,logHandlerJsonSchema:()=>$n,storageJsonSchema:()=>In,storageTypeJsonSchema:()=>En});var Pn=i.enum(["local","session","cookie"]).describe("Storage mechanism: local, session, or cookie"),An=i.object({Local:i.literal("local"),Session:i.literal("session"),Cookie:i.literal("cookie")}).describe("Storage type constants for type-safe references"),Tn=i.any().describe("Error handler function: (error, state?) => void"),Cn=i.any().describe("Log handler function: (message, verbose?) => void"),On=i.object({Error:Tn.describe("Error handler function"),Log:Cn.describe("Log handler function")}).describe("Handler interface with error and log functions"),En=vn(Pn,{target:"jsonSchema7",$refStrategy:"relative",name:"StorageType"}),In=vn(An,{target:"jsonSchema7",$refStrategy:"relative",name:"Storage"}),Nn=vn(Tn,{target:"jsonSchema7",$refStrategy:"relative",name:"ErrorHandler"}),$n=vn(Cn,{target:"jsonSchema7",$refStrategy:"relative",name:"LogHandler"}),Mn=vn(On,{target:"jsonSchema7",$refStrategy:"relative",name:"Handler"});i.object({onError:Tn.optional().describe("Error handler function: (error, state?) => void"),onLog:Cn.optional().describe("Log handler function: (message, verbose?) => void")}).partial(),i.object({verbose:i.boolean().describe("Enable verbose logging for debugging").optional()}).partial(),i.object({queue:i.boolean().describe("Whether to queue events when consent is not granted").optional()}).partial(),i.object({}).partial(),i.object({init:i.boolean().describe("Whether to initialize immediately").optional(),loadScript:i.boolean().describe("Whether to load external script (for web destinations)").optional()}).partial(),i.object({disabled:i.boolean().describe("Set to true to disable").optional()}).partial(),i.object({primary:i.boolean().describe("Mark as primary (only one can be primary)").optional()}).partial(),i.object({settings:i.any().optional().describe("Implementation-specific configuration")}).partial(),i.object({env:i.any().optional().describe("Environment dependencies (platform-specific)")}).partial(),i.object({type:i.string().optional().describe("Instance type identifier"),config:i.any().describe("Instance configuration")}).partial(),i.object({collector:i.any().describe("Collector instance (runtime object)"),config:i.any().describe("Configuration"),env:i.any().describe("Environment dependencies")}).partial(),i.object({batch:i.number().optional().describe("Batch size: bundle N events for batch processing"),batched:i.any().optional().describe("Batch of events to be processed")}).partial(),i.object({ignore:i.boolean().describe("Set to true to skip processing").optional(),condition:i.string().optional().describe("Condition function: return true to process")}).partial(),i.object({sources:i.record(i.string(),i.any()).describe("Map of source instances")}).partial(),i.object({destinations:i.record(i.string(),i.any()).describe("Map of destination instances")}).partial();_n({},{ConsentSchema:()=>Un,DeepPartialEventSchema:()=>Qn,EntitiesSchema:()=>Wn,EntitySchema:()=>qn,EventSchema:()=>Kn,OrderedPropertiesSchema:()=>Ln,PartialEventSchema:()=>Hn,PropertiesSchema:()=>zn,PropertySchema:()=>Dn,PropertyTypeSchema:()=>Rn,SourceSchema:()=>Jn,SourceTypeSchema:()=>Fn,UserSchema:()=>Bn,VersionSchema:()=>Vn,consentJsonSchema:()=>ra,entityJsonSchema:()=>na,eventJsonSchema:()=>Gn,orderedPropertiesJsonSchema:()=>ta,partialEventJsonSchema:()=>Yn,propertiesJsonSchema:()=>ea,sourceTypeJsonSchema:()=>aa,userJsonSchema:()=>Xn});var Rn=i.lazy(()=>i.union([i.boolean(),i.string(),i.number(),i.record(i.string(),Dn)])),Dn=i.lazy(()=>i.union([Rn,i.array(Rn)])),zn=i.record(i.string(),Dn.optional()).describe("Flexible property collection with optional values"),Ln=i.record(i.string(),i.tuple([Dn,i.number()]).optional()).describe("Ordered properties with [value, order] tuples for priority control"),Fn=i.union([i.enum(["web","server","app","other"]),i.string()]).describe("Source type: web, server, app, other, or custom"),Un=i.record(i.string(),i.boolean()).describe("Consent requirement mapping (group name → state)"),Bn=zn.and(i.object({id:i.string().optional().describe("User identifier"),device:i.string().optional().describe("Device identifier"),session:i.string().optional().describe("Session identifier"),hash:i.string().optional().describe("Hashed identifier"),address:i.string().optional().describe("User address"),email:i.string().email().optional().describe("User email address"),phone:i.string().optional().describe("User phone number"),userAgent:i.string().optional().describe("Browser user agent string"),browser:i.string().optional().describe("Browser name"),browserVersion:i.string().optional().describe("Browser version"),deviceType:i.string().optional().describe("Device type (mobile, desktop, tablet)"),os:i.string().optional().describe("Operating system"),osVersion:i.string().optional().describe("Operating system version"),screenSize:i.string().optional().describe("Screen dimensions"),language:i.string().optional().describe("User language"),country:i.string().optional().describe("User country"),region:i.string().optional().describe("User region/state"),city:i.string().optional().describe("User city"),zip:i.string().optional().describe("User postal code"),timezone:i.string().optional().describe("User timezone"),ip:i.string().optional().describe("User IP address"),internal:i.boolean().optional().describe("Internal user flag (employee, test user)")})).describe("User identification and properties"),Vn=zn.and(i.object({source:Sn.describe('Walker implementation version (e.g., "2.0.0")'),tagging:Zn})).describe("Walker version information"),Jn=zn.and(i.object({type:Fn.describe("Source type identifier"),id:Sn.describe("Source identifier (typically URL on web)"),previous_id:Sn.describe("Previous source identifier (typically referrer on web)")})).describe("Event source information"),qn=i.lazy(()=>i.object({entity:i.string().describe("Entity name"),data:zn.describe("Entity-specific properties"),nested:i.array(qn).describe("Nested child entities"),context:Ln.describe("Entity context data")})).describe("Nested entity structure with recursive nesting support"),Wn=i.array(qn).describe("Array of nested entities"),Kn=i.object({name:i.string().describe('Event name in "entity action" format (e.g., "page view", "product add")'),data:zn.describe("Event-specific properties"),context:Ln.describe("Ordered context properties with priorities"),globals:zn.describe("Global properties shared across events"),custom:zn.describe("Custom implementation-specific properties"),user:Bn.describe("User identification and attributes"),nested:Wn.describe("Related nested entities"),consent:Un.describe("Consent states at event time"),id:xn.describe("Unique event identifier (timestamp-based)"),trigger:Sn.describe("Event trigger identifier"),entity:Sn.describe("Parsed entity from event name"),action:Sn.describe("Parsed action from event name"),timestamp:wn.describe("Unix timestamp in milliseconds since epoch"),timing:kn.describe("Event processing timing information"),group:Sn.describe("Event grouping identifier"),count:jn.describe("Event count in session"),version:Vn.describe("Walker version information"),source:Jn.describe("Event source information")}).describe("Complete walkerOS event structure"),Hn=Kn.partial().describe("Partial event structure with all fields optional"),Qn=i.lazy(()=>Kn.deepPartial()).describe("Deep partial event structure with all nested fields optional"),Gn=vn(Kn,{target:"jsonSchema7",$refStrategy:"relative",name:"Event"}),Yn=vn(Hn,{target:"jsonSchema7",$refStrategy:"relative",name:"PartialEvent"}),Xn=vn(Bn,{target:"jsonSchema7",$refStrategy:"relative",name:"User"}),ea=vn(zn,{target:"jsonSchema7",$refStrategy:"relative",name:"Properties"}),ta=vn(Ln,{target:"jsonSchema7",$refStrategy:"relative",name:"OrderedProperties"}),na=vn(qn,{target:"jsonSchema7",$refStrategy:"relative",name:"Entity"}),aa=vn(Fn,{target:"jsonSchema7",$refStrategy:"relative",name:"SourceType"}),ra=vn(Un,{target:"jsonSchema7",$refStrategy:"relative",name:"Consent"});_n({},{ConfigSchema:()=>ha,LoopSchema:()=>oa,MapSchema:()=>da,PolicySchema:()=>la,ResultSchema:()=>fa,RuleSchema:()=>pa,RulesSchema:()=>ma,SetSchema:()=>ca,ValueConfigSchema:()=>ua,ValueSchema:()=>ia,ValuesSchema:()=>sa,configJsonSchema:()=>wa,loopJsonSchema:()=>va,mapJsonSchema:()=>_a,policyJsonSchema:()=>Sa,ruleJsonSchema:()=>ka,rulesJsonSchema:()=>xa,setJsonSchema:()=>ba,valueConfigJsonSchema:()=>ya,valueJsonSchema:()=>ga});var ia=i.lazy(()=>i.union([i.string().describe('String value or property path (e.g., "data.id")'),i.number().describe("Numeric value"),i.boolean().describe("Boolean value"),ua,i.array(ia).describe("Array of values")])),sa=i.array(ia).describe("Array of transformation values"),oa=i.tuple([ia,ia]).describe("Loop transformation: [source, transform] tuple for array processing"),ca=i.array(ia).describe("Set: Array of values for selection or combination"),da=i.record(i.string(),ia).describe("Map: Object mapping keys to transformation values"),ua=i.object({key:i.string().optional().describe('Property path to extract from event (e.g., "data.id", "user.email")'),value:i.union([i.string(),i.number(),i.boolean()]).optional().describe("Static primitive value"),fn:i.string().optional().describe("Custom transformation function as string (serialized)"),map:da.optional().describe("Object mapping: transform event data to structured output"),loop:oa.optional().describe("Loop transformation: [source, transform] for array processing"),set:ca.optional().describe("Set of values: combine or select from multiple values"),consent:Un.optional().describe("Required consent states to include this value"),condition:i.string().optional().describe("Condition function as string: return true to include value"),validate:i.string().optional().describe("Validation function as string: return true if value is valid")}).refine(e=>Object.keys(e).length>0,{message:"ValueConfig must have at least one property"}).describe("Value transformation configuration with multiple strategies"),la=i.record(i.string(),ia).describe("Policy rules for event pre-processing (key → value mapping)"),pa=i.object({batch:i.number().optional().describe("Batch size: bundle N events for batch processing"),condition:i.string().optional().describe("Condition function as string: return true to process event"),consent:Un.optional().describe("Required consent states to process this event"),settings:i.any().optional().describe("Destination-specific settings for this event mapping"),data:i.union([ia,sa]).optional().describe("Data transformation rules for event"),ignore:i.boolean().optional().describe("Set to true to skip processing this event"),name:i.string().optional().describe('Custom event name override (e.g., "view_item" for "product view")'),policy:la.optional().describe("Event-level policy overrides (applied after config-level policy)")}).describe("Mapping rule for specific entity-action combination"),ma=i.record(i.string(),i.record(i.string(),i.union([pa,i.array(pa)])).optional()).describe("Nested mapping rules: { entity: { action: Rule | Rule[] } } with wildcard support"),ha=i.object({consent:Un.optional().describe("Required consent states to process any events"),data:i.union([ia,sa]).optional().describe("Global data transformation applied to all events"),mapping:ma.optional().describe("Entity-action specific mapping rules"),policy:la.optional().describe("Pre-processing policy rules applied before mapping")}).describe("Shared mapping configuration for sources and destinations"),fa=i.object({eventMapping:pa.optional().describe("Resolved mapping rule for event"),mappingKey:i.string().optional().describe('Mapping key used (e.g., "product.view")')}).describe("Mapping resolution result"),ga=vn(ia,{target:"jsonSchema7",$refStrategy:"relative",name:"Value"}),ya=vn(ua,{target:"jsonSchema7",$refStrategy:"relative",name:"ValueConfig"}),va=vn(oa,{target:"jsonSchema7",$refStrategy:"relative",name:"Loop"}),ba=vn(ca,{target:"jsonSchema7",$refStrategy:"relative",name:"Set"}),_a=vn(da,{target:"jsonSchema7",$refStrategy:"relative",name:"Map"}),Sa=vn(la,{target:"jsonSchema7",$refStrategy:"relative",name:"Policy"}),ka=vn(pa,{target:"jsonSchema7",$refStrategy:"relative",name:"Rule"}),xa=vn(ma,{target:"jsonSchema7",$refStrategy:"relative",name:"Rules"}),wa=vn(ha,{target:"jsonSchema7",$refStrategy:"relative",name:"MappingConfig"});_n({},{BatchSchema:()=>Ia,ConfigSchema:()=>ja,ContextSchema:()=>Aa,DLQSchema:()=>Ua,DataSchema:()=>Na,DestinationPolicySchema:()=>Pa,DestinationsSchema:()=>Da,InitDestinationsSchema:()=>Ra,InitSchema:()=>Ma,InstanceSchema:()=>$a,PartialConfigSchema:()=>Za,PushBatchContextSchema:()=>Ca,PushContextSchema:()=>Ta,PushEventSchema:()=>Oa,PushEventsSchema:()=>Ea,PushResultSchema:()=>La,RefSchema:()=>za,ResultSchema:()=>Fa,batchJsonSchema:()=>Wa,configJsonSchema:()=>Ba,contextJsonSchema:()=>Ja,instanceJsonSchema:()=>Ka,partialConfigJsonSchema:()=>Va,pushContextJsonSchema:()=>qa,resultJsonSchema:()=>Ha});var ja=i.object({consent:Un.optional().describe("Required consent states to send events to this destination"),settings:i.any().describe("Implementation-specific configuration").optional(),data:i.union([ia,sa]).optional().describe("Global data transformation applied to all events for this destination"),env:i.any().describe("Environment dependencies (platform-specific)").optional(),id:xn.describe("Destination instance identifier (defaults to destination key)").optional(),init:i.boolean().describe("Whether to initialize immediately").optional(),loadScript:i.boolean().describe("Whether to load external script (for web destinations)").optional(),mapping:ma.optional().describe("Entity-action specific mapping rules for this destination"),policy:la.optional().describe("Pre-processing policy rules applied before event mapping"),queue:i.boolean().describe("Whether to queue events when consent is not granted").optional(),verbose:i.boolean().describe("Enable verbose logging for debugging").optional(),onError:Tn.optional(),onLog:Cn.optional()}).describe("Destination configuration"),Za=ja.deepPartial().describe("Partial destination configuration with all fields deeply optional"),Pa=la.describe("Destination policy rules for event pre-processing"),Aa=i.object({collector:i.any().describe("Collector instance (runtime object)"),config:ja.describe("Destination configuration"),data:i.union([i.any(),i.undefined(),i.array(i.union([i.any(),i.undefined()]))]).optional().describe("Transformed event data"),env:i.any().describe("Environment dependencies")}).describe("Destination context for init and push functions"),Ta=Aa.extend({mapping:pa.optional().describe("Resolved mapping rule for this specific event")}).describe("Push context with event-specific mapping"),Ca=Ta.describe("Batch push context with event-specific mapping"),Oa=i.object({event:Kn.describe("The event to process"),mapping:pa.optional().describe("Mapping rule for this event")}).describe("Event with optional mapping for batch processing"),Ea=i.array(Oa).describe("Array of events with mappings"),Ia=i.object({key:i.string().describe('Batch key (usually mapping key like "product.view")'),events:i.array(Kn).describe("Array of events in batch"),data:i.array(i.union([i.any(),i.undefined(),i.array(i.union([i.any(),i.undefined()]))])).describe("Transformed data for each event"),mapping:pa.optional().describe("Shared mapping rule for batch")}).describe("Batch of events grouped by mapping key"),Na=i.union([i.any(),i.undefined(),i.array(i.union([i.any(),i.undefined()]))]).describe("Transformed event data (Property, undefined, or array)"),$a=i.object({config:ja.describe("Destination configuration"),queue:i.array(Kn).optional().describe("Queued events awaiting consent"),dlq:i.array(i.tuple([Kn,i.any()])).optional().describe("Dead letter queue (failed events with errors)"),type:i.string().optional().describe("Destination type identifier"),env:i.any().optional().describe("Environment dependencies"),init:i.any().optional().describe("Initialization function"),push:i.any().describe("Push function for single events"),pushBatch:i.any().optional().describe("Batch push function"),on:i.any().optional().describe("Event lifecycle hook function")}).describe("Destination instance (runtime object with functions)"),Ma=i.object({code:$a.describe("Destination instance with implementation"),config:Za.optional().describe("Partial configuration overrides"),env:i.any().optional().describe("Partial environment overrides")}).describe("Destination initialization configuration"),Ra=i.record(i.string(),Ma).describe("Map of destination IDs to initialization configurations"),Da=i.record(i.string(),$a).describe("Map of destination IDs to runtime instances"),za=i.object({id:i.string().describe("Destination ID"),destination:$a.describe("Destination instance")}).describe("Destination reference (ID + instance)"),La=i.object({queue:i.array(Kn).optional().describe("Events queued (awaiting consent)"),error:i.any().optional().describe("Error if push failed")}).describe("Push operation result"),Fa=i.object({successful:i.array(za).describe("Destinations that processed successfully"),queued:i.array(za).describe("Destinations that queued events"),failed:i.array(za).describe("Destinations that failed to process")}).describe("Overall destination processing result"),Ua=i.array(i.tuple([Kn,i.any()])).describe("Dead letter queue: [(event, error), ...]"),Ba=vn(ja,{target:"jsonSchema7",$refStrategy:"relative",name:"DestinationConfig"}),Va=vn(Za,{target:"jsonSchema7",$refStrategy:"relative",name:"PartialDestinationConfig"}),Ja=vn(Aa,{target:"jsonSchema7",$refStrategy:"relative",name:"DestinationContext"}),qa=vn(Ta,{target:"jsonSchema7",$refStrategy:"relative",name:"PushContext"}),Wa=vn(Ia,{target:"jsonSchema7",$refStrategy:"relative",name:"Batch"}),Ka=vn($a,{target:"jsonSchema7",$refStrategy:"relative",name:"DestinationInstance"}),Ha=vn(Fa,{target:"jsonSchema7",$refStrategy:"relative",name:"DestinationResult"});_n({},{CommandTypeSchema:()=>Qa,ConfigSchema:()=>Ga,DestinationsSchema:()=>nr,InitConfigSchema:()=>Xa,InstanceSchema:()=>ar,PushContextSchema:()=>er,SessionDataSchema:()=>Ya,SourcesSchema:()=>tr,commandTypeJsonSchema:()=>rr,configJsonSchema:()=>ir,initConfigJsonSchema:()=>or,instanceJsonSchema:()=>dr,pushContextJsonSchema:()=>cr,sessionDataJsonSchema:()=>sr});var Qa=i.union([i.enum(["action","config","consent","context","destination","elb","globals","hook","init","link","run","user","walker"]),i.string()]).describe("Collector command type: standard commands or custom string for extensions"),Ga=i.object({run:i.boolean().describe("Whether to run collector automatically on initialization").optional(),tagging:Zn,globalsStatic:zn.describe("Static global properties that persist across collector runs"),sessionStatic:i.record(i.any()).describe("Static session data that persists across collector runs"),verbose:i.boolean().describe("Enable verbose logging for debugging"),onError:Tn.optional(),onLog:Cn.optional()}).describe("Core collector configuration"),Ya=zn.and(i.object({isStart:i.boolean().describe("Whether this is a new session start"),storage:i.boolean().describe("Whether storage is available"),id:xn.describe("Session identifier").optional(),start:wn.describe("Session start timestamp").optional(),marketing:i.literal(!0).optional().describe("Marketing attribution flag"),updated:wn.describe("Last update timestamp").optional(),isNew:i.boolean().describe("Whether this is a new session").optional(),device:xn.describe("Device identifier").optional(),count:jn.describe("Event count in session").optional(),runs:jn.describe("Number of runs").optional()})).describe("Session state and tracking data"),Xa=Ga.partial().extend({consent:Un.optional().describe("Initial consent state"),user:Bn.optional().describe("Initial user data"),globals:zn.optional().describe("Initial global properties"),sources:i.any().optional().describe("Source configurations"),destinations:i.any().optional().describe("Destination configurations"),custom:zn.optional().describe("Initial custom implementation-specific properties")}).describe("Collector initialization configuration with initial state"),er=i.object({mapping:ha.optional().describe("Source-level mapping configuration")}).describe("Push context with optional source mapping"),tr=i.record(i.string(),i.any()).describe("Map of source IDs to source instances"),nr=i.record(i.string(),i.any()).describe("Map of destination IDs to destination instances"),ar=i.object({push:i.any().describe("Push function for processing events"),command:i.any().describe("Command function for walker commands"),allowed:i.boolean().describe("Whether event processing is allowed"),config:Ga.describe("Current collector configuration"),consent:Un.describe("Current consent state"),count:i.number().describe("Event count (increments with each event)"),custom:zn.describe("Custom implementation-specific properties"),sources:tr.describe("Registered source instances"),destinations:nr.describe("Registered destination instances"),globals:zn.describe("Current global properties"),group:i.string().describe("Event grouping identifier"),hooks:i.any().describe("Lifecycle hook functions"),on:i.any().describe("Event lifecycle configuration"),queue:i.array(Kn).describe("Queued events awaiting processing"),round:i.number().describe("Collector run count (increments with each run)"),session:i.union([i.undefined(),Ya]).describe("Current session state"),timing:i.number().describe("Event processing timing information"),user:Bn.describe("Current user data"),version:i.string().describe("Walker implementation version")}).describe("Collector instance with state and methods"),rr=vn(Qa,{target:"jsonSchema7",$refStrategy:"relative",name:"CommandType"}),ir=vn(Ga,{target:"jsonSchema7",$refStrategy:"relative",name:"CollectorConfig"}),sr=vn(Ya,{target:"jsonSchema7",$refStrategy:"relative",name:"SessionData"}),or=vn(Xa,{target:"jsonSchema7",$refStrategy:"relative",name:"InitConfig"}),cr=vn(er,{target:"jsonSchema7",$refStrategy:"relative",name:"CollectorPushContext"}),dr=vn(ar,{target:"jsonSchema7",$refStrategy:"relative",name:"CollectorInstance"});_n({},{BaseEnvSchema:()=>ur,ConfigSchema:()=>lr,InitSchema:()=>hr,InitSourceSchema:()=>fr,InitSourcesSchema:()=>gr,InstanceSchema:()=>mr,PartialConfigSchema:()=>pr,baseEnvJsonSchema:()=>yr,configJsonSchema:()=>vr,initSourceJsonSchema:()=>Sr,initSourcesJsonSchema:()=>kr,instanceJsonSchema:()=>_r,partialConfigJsonSchema:()=>br});var ur=i.object({push:i.any().describe("Collector push function"),command:i.any().describe("Collector command function"),sources:i.any().optional().describe("Map of registered source instances"),elb:i.any().describe("Public API function (alias for collector.push)")}).catchall(i.unknown()).describe("Base environment for dependency injection - platform-specific sources extend this"),lr=ha.extend({settings:i.any().describe("Implementation-specific configuration").optional(),env:ur.optional().describe("Environment dependencies (platform-specific)"),id:xn.describe("Source identifier (defaults to source key)").optional(),onError:Tn.optional(),disabled:i.boolean().describe("Set to true to disable").optional(),primary:i.boolean().describe("Mark as primary (only one can be primary)").optional()}).describe("Source configuration with mapping and environment"),pr=lr.deepPartial().describe("Partial source configuration with all fields deeply optional"),mr=i.object({type:i.string().describe('Source type identifier (e.g., "browser", "dataLayer")'),config:lr.describe("Current source configuration"),push:i.any().describe("Push function - THE HANDLER (flexible signature for platform compatibility)"),destroy:i.any().optional().describe("Cleanup function called when source is removed"),on:i.any().optional().describe("Lifecycle hook function for event types")}).describe("Source instance with push handler and lifecycle methods"),hr=i.any().describe("Source initialization function: (config, env) => Instance | Promise<Instance>"),fr=i.object({code:hr.describe("Source initialization function"),config:pr.optional().describe("Partial configuration overrides"),env:ur.partial().optional().describe("Partial environment overrides"),primary:i.boolean().optional().describe("Mark as primary source (only one can be primary)")}).describe("Source initialization configuration"),gr=i.record(i.string(),fr).describe("Map of source IDs to initialization configurations"),yr=vn(ur,{target:"jsonSchema7",$refStrategy:"relative",name:"SourceBaseEnv"}),vr=vn(lr,{target:"jsonSchema7",$refStrategy:"relative",name:"SourceConfig"}),br=vn(pr,{target:"jsonSchema7",$refStrategy:"relative",name:"PartialSourceConfig"}),_r=vn(mr,{target:"jsonSchema7",$refStrategy:"relative",name:"SourceInstance"}),Sr=vn(fr,{target:"jsonSchema7",$refStrategy:"relative",name:"InitSource"}),kr=vn(gr,{target:"jsonSchema7",$refStrategy:"relative",name:"InitSources"});function xr(e){return vn(e,{target:"jsonSchema7",$refStrategy:"none"})}function wr(e){return Array.isArray(e)}function jr(e){return"object"==typeof e&&null!==e&&!wr(e)&&"[object Object]"===Object.prototype.toString.call(e)}import{BigQuery as Zr}from"@google-cloud/bigquery";function Pr(e={},t){const n=e.settings||{},{projectId:a,bigquery:r}=n;let{client:i,location:s,datasetId:o,tableId:c}=n;a||function(e){throw new Error(String(e))}("Config settings projectId missing"),s=s||"EU",o=o||"walkeros",c=c||"events";const d=r||{};d.projectId=a;const u=(null==t?void 0:t.BigQuery)||Zr;i=i||new u(d);const l={...n,client:i,projectId:a,location:s,datasetId:o,tableId:c};return{...e,settings:l}}var Ar=e=>Object.entries(e).reduce((e,[t,n])=>(e[t]=jr(n)||wr(n)?JSON.stringify(n):n,e),{}),Tr={};r({},{env:()=>Cr});var Cr={};r(Cr,{push:()=>Er});var Or=()=>{};var Er={get BigQuery(){return class{constructor(e){this.options=e,this.calls=[]}dataset(e){return this.calls.push({method:"dataset",args:[e]}),this}table(e){return this.calls.push({method:"table",args:[e]}),this}async insert(e){return this.calls.push({method:"insert",args:[e]}),Promise.resolve()}get mockFn(){return Or}}}},Ir={};r(Ir,{MappingSchema:()=>$r,SettingsSchema:()=>Nr,mapping:()=>Rr,settings:()=>Mr});var Nr=i.object({client:i.any().describe("Google Cloud BigQuery client instance (like new BigQuery({ projectId, keyFilename }))").optional(),projectId:i.string().min(1).describe("Google Cloud Project ID (like my-gcp-project)"),datasetId:i.string().min(1).default("walkeros").describe("BigQuery dataset ID where events will be stored (like walker_events)"),tableId:i.string().min(1).default("events").describe("BigQuery table ID for event storage (like events)"),location:i.string().default("EU").describe("Geographic location for the BigQuery dataset (like US)"),bigquery:i.any().describe('Additional BigQuery client configuration options (like { keyFilename: "path/to/key.json" })').optional()}),$r=i.object({}),Mr=xr(Nr),Rr=xr($r),Dr={type:"gcp-bigquery",config:{},init:async({config:e,env:t})=>Pr(e,t),push:async(e,{config:t,mapping:n,data:a,collector:r,env:i})=>await async function(e,{config:t,mapping:n,data:a,collector:r,env:i}){const{client:s,datasetId:o,tableId:c}=t.settings;let d;if(jr(a))d=a;else{const t=new Date;d={...e,timestamp:e.timestamp?new Date(e.timestamp):t,createdAt:t}}const u=[Ar(d)];await s.dataset(o).table(c).insert(u)}(e,{config:t,mapping:n,data:a,collector:r,env:i})};export{Tr as DestinationBigQuery,Dr as destinationBigQuery,Ir as schemas};//# sourceMappingURL=index.mjs.map