@snapfail/browser 0.0.9 → 0.0.10
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/auto-init.d.ts +6 -0
- package/dist/snapfail.iife.js +2 -0
- package/package.json +2 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(()=>{var X$=Object.defineProperty;var G$=(_)=>_;function J$(_,$){this[_]=G$.bind(null,$)}var M$=(_,$)=>{for(var S in $)X$(_,S,{get:$[S],enumerable:!0,configurable:!0,set:J$.bind($,S)})};class Q_{windowMs;events=[];constructor(_){this.windowMs=_}push(_){let $=Date.now()-this.windowMs;this.events=this.events.filter((S)=>S.timestamp>=$),this.events.push(_)}snapshot(){let _=Date.now()-this.windowMs;return this.events.filter(($)=>$.timestamp>=_).slice()}flush(){let _=this.snapshot();return this.events=[],_}clear(){this.events=[]}}var W={};M$(W,{void:()=>d$,util:()=>v,unknown:()=>u$,union:()=>e$,undefined:()=>r$,tuple:()=>SS,transformer:()=>QS,symbol:()=>Z$,string:()=>r_,strictObject:()=>s$,setErrorMap:()=>Y$,set:()=>qS,record:()=>HS,quotelessJson:()=>Q$,promise:()=>MS,preprocess:()=>BS,pipeline:()=>ES,ostring:()=>RS,optional:()=>zS,onumber:()=>jS,oboolean:()=>bS,objectUtil:()=>C_,object:()=>t$,number:()=>o_,nullable:()=>YS,null:()=>o$,never:()=>p$,nativeEnum:()=>JS,nan:()=>y$,map:()=>fS,makeIssue:()=>z_,literal:()=>XS,lazy:()=>WS,late:()=>T$,isValid:()=>n,isDirty:()=>A_,isAsync:()=>s,isAborted:()=>O_,intersection:()=>$S,instanceof:()=>n$,getParsedType:()=>h,getErrorMap:()=>t,function:()=>wS,enum:()=>GS,effect:()=>QS,discriminatedUnion:()=>_S,defaultErrorMap:()=>l,datetimeRegex:()=>x_,date:()=>c$,custom:()=>Z_,coerce:()=>vS,boolean:()=>i_,bigint:()=>x$,array:()=>a$,any:()=>i$,addIssueToContext:()=>Q,ZodVoid:()=>B_,ZodUnknown:()=>y,ZodUnion:()=>f_,ZodUndefined:()=>S_,ZodType:()=>b,ZodTuple:()=>P,ZodTransformer:()=>C,ZodSymbol:()=>Y_,ZodString:()=>F,ZodSet:()=>p,ZodSchema:()=>b,ZodRecord:()=>E_,ZodReadonly:()=>M_,ZodPromise:()=>d,ZodPipeline:()=>b_,ZodParsedType:()=>M,ZodOptional:()=>k,ZodObject:()=>O,ZodNumber:()=>x,ZodNullable:()=>T,ZodNull:()=>H_,ZodNever:()=>I,ZodNativeEnum:()=>X_,ZodNaN:()=>j_,ZodMap:()=>R_,ZodLiteral:()=>W_,ZodLazy:()=>w_,ZodIssueCode:()=>J,ZodIntersection:()=>q_,ZodFunction:()=>__,ZodFirstPartyTypeKind:()=>R,ZodError:()=>D,ZodEnum:()=>Z,ZodEffects:()=>C,ZodDiscriminatedUnion:()=>L_,ZodDefault:()=>G_,ZodDate:()=>i,ZodCatch:()=>J_,ZodBranded:()=>U_,ZodBoolean:()=>$_,ZodBigInt:()=>c,ZodArray:()=>K,ZodAny:()=>u,Schema:()=>b,ParseStatus:()=>U,OK:()=>N,NEVER:()=>OS,INVALID:()=>Y,EMPTY_PATH:()=>B$,DIRTY:()=>o,BRAND:()=>m$});var v;(function(_){_.assertEqual=(H)=>{};function $(H){}_.assertIs=$;function S(H){throw Error()}_.assertNever=S,_.arrayToEnum=(H)=>{let w={};for(let q of H)w[q]=q;return w},_.getValidEnumValues=(H)=>{let w=_.objectKeys(H).filter((X)=>typeof H[H[X]]!=="number"),q={};for(let X of w)q[X]=H[X];return _.objectValues(q)},_.objectValues=(H)=>{return _.objectKeys(H).map(function(w){return H[w]})},_.objectKeys=typeof Object.keys==="function"?(H)=>Object.keys(H):(H)=>{let w=[];for(let q in H)if(Object.prototype.hasOwnProperty.call(H,q))w.push(q);return w},_.find=(H,w)=>{for(let q of H)if(w(q))return q;return},_.isInteger=typeof Number.isInteger==="function"?(H)=>Number.isInteger(H):(H)=>typeof H==="number"&&Number.isFinite(H)&&Math.floor(H)===H;function f(H,w=" | "){return H.map((q)=>typeof q==="string"?`'${q}'`:q).join(w)}_.joinValues=f,_.jsonStringifyReplacer=(H,w)=>{if(typeof w==="bigint")return w.toString();return w}})(v||(v={}));var C_;(function(_){_.mergeShapes=($,S)=>{return{...$,...S}}})(C_||(C_={}));var M=v.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),h=(_)=>{switch(typeof _){case"undefined":return M.undefined;case"string":return M.string;case"number":return Number.isNaN(_)?M.nan:M.number;case"boolean":return M.boolean;case"function":return M.function;case"bigint":return M.bigint;case"symbol":return M.symbol;case"object":if(Array.isArray(_))return M.array;if(_===null)return M.null;if(_.then&&typeof _.then==="function"&&_.catch&&typeof _.catch==="function")return M.promise;if(typeof Map<"u"&&_ instanceof Map)return M.map;if(typeof Set<"u"&&_ instanceof Set)return M.set;if(typeof Date<"u"&&_ instanceof Date)return M.date;return M.object;default:return M.unknown}};var J=v.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"]),Q$=(_)=>{return JSON.stringify(_,null,2).replace(/"([^"]+)":/g,"$1:")};class D extends Error{get errors(){return this.issues}constructor(_){super();this.issues=[],this.addIssue=(S)=>{this.issues=[...this.issues,S]},this.addIssues=(S=[])=>{this.issues=[...this.issues,...S]};let $=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,$);else this.__proto__=$;this.name="ZodError",this.issues=_}format(_){let $=_||function(H){return H.message},S={_errors:[]},f=(H)=>{for(let w of H.issues)if(w.code==="invalid_union")w.unionErrors.map(f);else if(w.code==="invalid_return_type")f(w.returnTypeError);else if(w.code==="invalid_arguments")f(w.argumentsError);else if(w.path.length===0)S._errors.push($(w));else{let q=S,X=0;while(X<w.path.length){let G=w.path[X];if(X!==w.path.length-1)q[G]=q[G]||{_errors:[]};else q[G]=q[G]||{_errors:[]},q[G]._errors.push($(w));q=q[G],X++}}};return f(this),S}static assert(_){if(!(_ instanceof D))throw Error(`Not a ZodError: ${_}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,v.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(_=($)=>$.message){let $={},S=[];for(let f of this.issues)if(f.path.length>0){let H=f.path[0];$[H]=$[H]||[],$[H].push(_(f))}else S.push(_(f));return{formErrors:S,fieldErrors:$}}get formErrors(){return this.flatten()}}D.create=(_)=>{return new D(_)};var z$=(_,$)=>{let S;switch(_.code){case J.invalid_type:if(_.received===M.undefined)S="Required";else S=`Expected ${_.expected}, received ${_.received}`;break;case J.invalid_literal:S=`Invalid literal value, expected ${JSON.stringify(_.expected,v.jsonStringifyReplacer)}`;break;case J.unrecognized_keys:S=`Unrecognized key(s) in object: ${v.joinValues(_.keys,", ")}`;break;case J.invalid_union:S="Invalid input";break;case J.invalid_union_discriminator:S=`Invalid discriminator value. Expected ${v.joinValues(_.options)}`;break;case J.invalid_enum_value:S=`Invalid enum value. Expected ${v.joinValues(_.options)}, received '${_.received}'`;break;case J.invalid_arguments:S="Invalid function arguments";break;case J.invalid_return_type:S="Invalid function return type";break;case J.invalid_date:S="Invalid date";break;case J.invalid_string:if(typeof _.validation==="object")if("includes"in _.validation){if(S=`Invalid input: must include "${_.validation.includes}"`,typeof _.validation.position==="number")S=`${S} at one or more positions greater than or equal to ${_.validation.position}`}else if("startsWith"in _.validation)S=`Invalid input: must start with "${_.validation.startsWith}"`;else if("endsWith"in _.validation)S=`Invalid input: must end with "${_.validation.endsWith}"`;else v.assertNever(_.validation);else if(_.validation!=="regex")S=`Invalid ${_.validation}`;else S="Invalid";break;case J.too_small:if(_.type==="array")S=`Array must contain ${_.exact?"exactly":_.inclusive?"at least":"more than"} ${_.minimum} element(s)`;else if(_.type==="string")S=`String must contain ${_.exact?"exactly":_.inclusive?"at least":"over"} ${_.minimum} character(s)`;else if(_.type==="number")S=`Number must be ${_.exact?"exactly equal to ":_.inclusive?"greater than or equal to ":"greater than "}${_.minimum}`;else if(_.type==="bigint")S=`Number must be ${_.exact?"exactly equal to ":_.inclusive?"greater than or equal to ":"greater than "}${_.minimum}`;else if(_.type==="date")S=`Date must be ${_.exact?"exactly equal to ":_.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(_.minimum))}`;else S="Invalid input";break;case J.too_big:if(_.type==="array")S=`Array must contain ${_.exact?"exactly":_.inclusive?"at most":"less than"} ${_.maximum} element(s)`;else if(_.type==="string")S=`String must contain ${_.exact?"exactly":_.inclusive?"at most":"under"} ${_.maximum} character(s)`;else if(_.type==="number")S=`Number must be ${_.exact?"exactly":_.inclusive?"less than or equal to":"less than"} ${_.maximum}`;else if(_.type==="bigint")S=`BigInt must be ${_.exact?"exactly":_.inclusive?"less than or equal to":"less than"} ${_.maximum}`;else if(_.type==="date")S=`Date must be ${_.exact?"exactly":_.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(_.maximum))}`;else S="Invalid input";break;case J.custom:S="Invalid input";break;case J.invalid_intersection_types:S="Intersection results could not be merged";break;case J.not_multiple_of:S=`Number must be a multiple of ${_.multipleOf}`;break;case J.not_finite:S="Number must be finite";break;default:S=$.defaultError,v.assertNever(_)}return{message:S}},l=z$;var l_=l;function Y$(_){l_=_}function t(){return l_}var z_=(_)=>{let{data:$,path:S,errorMaps:f,issueData:H}=_,w=[...S,...H.path||[]],q={...H,path:w};if(H.message!==void 0)return{...H,path:w,message:H.message};let X="",G=f.filter((B)=>!!B).slice().reverse();for(let B of G)X=B(q,{data:$,defaultError:X}).message;return{...H,path:w,message:X}},B$=[];function Q(_,$){let S=t(),f=z_({issueData:$,data:_.data,path:_.path,errorMaps:[_.common.contextualErrorMap,_.schemaErrorMap,S,S===l?void 0:l].filter((H)=>!!H)});_.common.issues.push(f)}class U{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray(_,$){let S=[];for(let f of $){if(f.status==="aborted")return Y;if(f.status==="dirty")_.dirty();S.push(f.value)}return{status:_.value,value:S}}static async mergeObjectAsync(_,$){let S=[];for(let f of $){let H=await f.key,w=await f.value;S.push({key:H,value:w})}return U.mergeObjectSync(_,S)}static mergeObjectSync(_,$){let S={};for(let f of $){let{key:H,value:w}=f;if(H.status==="aborted")return Y;if(w.status==="aborted")return Y;if(H.status==="dirty")_.dirty();if(w.status==="dirty")_.dirty();if(H.value!=="__proto__"&&(typeof w.value<"u"||f.alwaysSet))S[H.value]=w.value}return{status:_.value,value:S}}}var Y=Object.freeze({status:"aborted"}),o=(_)=>({status:"dirty",value:_}),N=(_)=>({status:"valid",value:_}),O_=(_)=>_.status==="aborted",A_=(_)=>_.status==="dirty",n=(_)=>_.status==="valid",s=(_)=>typeof Promise<"u"&&_ instanceof Promise;var z;(function(_){_.errToObj=($)=>typeof $==="string"?{message:$}:$||{},_.toString=($)=>typeof $==="string"?$:$?.message})(z||(z={}));class g{constructor(_,$,S,f){this._cachedPath=[],this.parent=_,this.data=$,this._path=S,this._key=f}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var m_=(_,$)=>{if(n($))return{success:!0,data:$.value};else{if(!_.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let S=new D(_.common.issues);return this._error=S,this._error}}}};function j(_){if(!_)return{};let{errorMap:$,invalid_type_error:S,required_error:f,description:H}=_;if($&&(S||f))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if($)return{errorMap:$,description:H};return{errorMap:(q,X)=>{let{message:G}=_;if(q.code==="invalid_enum_value")return{message:G??X.defaultError};if(typeof X.data>"u")return{message:G??f??X.defaultError};if(q.code!=="invalid_type")return{message:X.defaultError};return{message:G??S??X.defaultError}},description:H}}class b{get description(){return this._def.description}_getType(_){return h(_.data)}_getOrReturnCtx(_,$){return $||{common:_.parent.common,data:_.data,parsedType:h(_.data),schemaErrorMap:this._def.errorMap,path:_.path,parent:_.parent}}_processInputParams(_){return{status:new U,ctx:{common:_.parent.common,data:_.data,parsedType:h(_.data),schemaErrorMap:this._def.errorMap,path:_.path,parent:_.parent}}}_parseSync(_){let $=this._parse(_);if(s($))throw Error("Synchronous parse encountered promise.");return $}_parseAsync(_){let $=this._parse(_);return Promise.resolve($)}parse(_,$){let S=this.safeParse(_,$);if(S.success)return S.data;throw S.error}safeParse(_,$){let S={common:{issues:[],async:$?.async??!1,contextualErrorMap:$?.errorMap},path:$?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:_,parsedType:h(_)},f=this._parseSync({data:_,path:S.path,parent:S});return m_(S,f)}"~validate"(_){let $={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:_,parsedType:h(_)};if(!this["~standard"].async)try{let S=this._parseSync({data:_,path:[],parent:$});return n(S)?{value:S.value}:{issues:$.common.issues}}catch(S){if(S?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;$.common={issues:[],async:!0}}return this._parseAsync({data:_,path:[],parent:$}).then((S)=>n(S)?{value:S.value}:{issues:$.common.issues})}async parseAsync(_,$){let S=await this.safeParseAsync(_,$);if(S.success)return S.data;throw S.error}async safeParseAsync(_,$){let S={common:{issues:[],contextualErrorMap:$?.errorMap,async:!0},path:$?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:_,parsedType:h(_)},f=this._parse({data:_,path:S.path,parent:S}),H=await(s(f)?f:Promise.resolve(f));return m_(S,H)}refine(_,$){let S=(f)=>{if(typeof $==="string"||typeof $>"u")return{message:$};else if(typeof $==="function")return $(f);else return $};return this._refinement((f,H)=>{let w=_(f),q=()=>H.addIssue({code:J.custom,...S(f)});if(typeof Promise<"u"&&w instanceof Promise)return w.then((X)=>{if(!X)return q(),!1;else return!0});if(!w)return q(),!1;else return!0})}refinement(_,$){return this._refinement((S,f)=>{if(!_(S))return f.addIssue(typeof $==="function"?$(S,f):$),!1;else return!0})}_refinement(_){return new C({schema:this,typeName:R.ZodEffects,effect:{type:"refinement",refinement:_}})}superRefine(_){return this._refinement(_)}constructor(_){this.spa=this.safeParseAsync,this._def=_,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:($)=>this["~validate"]($)}}optional(){return k.create(this,this._def)}nullable(){return T.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return K.create(this)}promise(){return d.create(this,this._def)}or(_){return f_.create([this,_],this._def)}and(_){return q_.create(this,_,this._def)}transform(_){return new C({...j(this._def),schema:this,typeName:R.ZodEffects,effect:{type:"transform",transform:_}})}default(_){let $=typeof _==="function"?_:()=>_;return new G_({...j(this._def),innerType:this,defaultValue:$,typeName:R.ZodDefault})}brand(){return new U_({typeName:R.ZodBranded,type:this,...j(this._def)})}catch(_){let $=typeof _==="function"?_:()=>_;return new J_({...j(this._def),innerType:this,catchValue:$,typeName:R.ZodCatch})}describe(_){return new this.constructor({...this._def,description:_})}pipe(_){return b_.create(this,_)}readonly(){return M_.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var E$=/^c[^\s-]{8,}$/i,R$=/^[0-9a-z]+$/,j$=/^[0-9A-HJKMNP-TV-Z]{26}$/i,b$=/^[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,v$=/^[a-z0-9_-]{21}$/i,O$=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,A$=/^[-+]?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,U$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",h_,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])$/,N$=/^(?:(?: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])$/,D$=/^(([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]))$/,F$=/^(([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}=))?$/,k$=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,n_="((\\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])))",g$=new RegExp(`^${n_}$`);function y_(_){let $="[0-5]\\d";if(_.precision)$=`${$}\\.\\d{${_.precision}}`;else if(_.precision==null)$=`${$}(\\.\\d+)?`;let S=_.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${$})${S}`}function C$(_){return new RegExp(`^${y_(_)}$`)}function x_(_){let $=`${n_}T${y_(_)}`,S=[];if(S.push(_.local?"Z?":"Z"),_.offset)S.push("([+-]\\d{2}:?\\d{2})");return $=`${$}(${S.join("|")})`,new RegExp(`^${$}$`)}function h$(_,$){if(($==="v4"||!$)&&V$.test(_))return!0;if(($==="v6"||!$)&&D$.test(_))return!0;return!1}function I$(_,$){if(!O$.test(_))return!1;try{let[S]=_.split(".");if(!S)return!1;let f=S.replace(/-/g,"+").replace(/_/g,"/").padEnd(S.length+(4-S.length%4)%4,"="),H=JSON.parse(atob(f));if(typeof H!=="object"||H===null)return!1;if("typ"in H&&H?.typ!=="JWT")return!1;if(!H.alg)return!1;if($&&H.alg!==$)return!1;return!0}catch{return!1}}function P$(_,$){if(($==="v4"||!$)&&N$.test(_))return!0;if(($==="v6"||!$)&&F$.test(_))return!0;return!1}class F extends b{_parse(_){if(this._def.coerce)_.data=String(_.data);if(this._getType(_)!==M.string){let H=this._getOrReturnCtx(_);return Q(H,{code:J.invalid_type,expected:M.string,received:H.parsedType}),Y}let S=new U,f=void 0;for(let H of this._def.checks)if(H.kind==="min"){if(_.data.length<H.value)f=this._getOrReturnCtx(_,f),Q(f,{code:J.too_small,minimum:H.value,type:"string",inclusive:!0,exact:!1,message:H.message}),S.dirty()}else if(H.kind==="max"){if(_.data.length>H.value)f=this._getOrReturnCtx(_,f),Q(f,{code:J.too_big,maximum:H.value,type:"string",inclusive:!0,exact:!1,message:H.message}),S.dirty()}else if(H.kind==="length"){let w=_.data.length>H.value,q=_.data.length<H.value;if(w||q){if(f=this._getOrReturnCtx(_,f),w)Q(f,{code:J.too_big,maximum:H.value,type:"string",inclusive:!0,exact:!0,message:H.message});else if(q)Q(f,{code:J.too_small,minimum:H.value,type:"string",inclusive:!0,exact:!0,message:H.message});S.dirty()}}else if(H.kind==="email"){if(!L$.test(_.data))f=this._getOrReturnCtx(_,f),Q(f,{validation:"email",code:J.invalid_string,message:H.message}),S.dirty()}else if(H.kind==="emoji"){if(!h_)h_=new RegExp(U$,"u");if(!h_.test(_.data))f=this._getOrReturnCtx(_,f),Q(f,{validation:"emoji",code:J.invalid_string,message:H.message}),S.dirty()}else if(H.kind==="uuid"){if(!b$.test(_.data))f=this._getOrReturnCtx(_,f),Q(f,{validation:"uuid",code:J.invalid_string,message:H.message}),S.dirty()}else if(H.kind==="nanoid"){if(!v$.test(_.data))f=this._getOrReturnCtx(_,f),Q(f,{validation:"nanoid",code:J.invalid_string,message:H.message}),S.dirty()}else if(H.kind==="cuid"){if(!E$.test(_.data))f=this._getOrReturnCtx(_,f),Q(f,{validation:"cuid",code:J.invalid_string,message:H.message}),S.dirty()}else if(H.kind==="cuid2"){if(!R$.test(_.data))f=this._getOrReturnCtx(_,f),Q(f,{validation:"cuid2",code:J.invalid_string,message:H.message}),S.dirty()}else if(H.kind==="ulid"){if(!j$.test(_.data))f=this._getOrReturnCtx(_,f),Q(f,{validation:"ulid",code:J.invalid_string,message:H.message}),S.dirty()}else if(H.kind==="url")try{new URL(_.data)}catch{f=this._getOrReturnCtx(_,f),Q(f,{validation:"url",code:J.invalid_string,message:H.message}),S.dirty()}else if(H.kind==="regex"){if(H.regex.lastIndex=0,!H.regex.test(_.data))f=this._getOrReturnCtx(_,f),Q(f,{validation:"regex",code:J.invalid_string,message:H.message}),S.dirty()}else if(H.kind==="trim")_.data=_.data.trim();else if(H.kind==="includes"){if(!_.data.includes(H.value,H.position))f=this._getOrReturnCtx(_,f),Q(f,{code:J.invalid_string,validation:{includes:H.value,position:H.position},message:H.message}),S.dirty()}else if(H.kind==="toLowerCase")_.data=_.data.toLowerCase();else if(H.kind==="toUpperCase")_.data=_.data.toUpperCase();else if(H.kind==="startsWith"){if(!_.data.startsWith(H.value))f=this._getOrReturnCtx(_,f),Q(f,{code:J.invalid_string,validation:{startsWith:H.value},message:H.message}),S.dirty()}else if(H.kind==="endsWith"){if(!_.data.endsWith(H.value))f=this._getOrReturnCtx(_,f),Q(f,{code:J.invalid_string,validation:{endsWith:H.value},message:H.message}),S.dirty()}else if(H.kind==="datetime"){if(!x_(H).test(_.data))f=this._getOrReturnCtx(_,f),Q(f,{code:J.invalid_string,validation:"datetime",message:H.message}),S.dirty()}else if(H.kind==="date"){if(!g$.test(_.data))f=this._getOrReturnCtx(_,f),Q(f,{code:J.invalid_string,validation:"date",message:H.message}),S.dirty()}else if(H.kind==="time"){if(!C$(H).test(_.data))f=this._getOrReturnCtx(_,f),Q(f,{code:J.invalid_string,validation:"time",message:H.message}),S.dirty()}else if(H.kind==="duration"){if(!A$.test(_.data))f=this._getOrReturnCtx(_,f),Q(f,{validation:"duration",code:J.invalid_string,message:H.message}),S.dirty()}else if(H.kind==="ip"){if(!h$(_.data,H.version))f=this._getOrReturnCtx(_,f),Q(f,{validation:"ip",code:J.invalid_string,message:H.message}),S.dirty()}else if(H.kind==="jwt"){if(!I$(_.data,H.alg))f=this._getOrReturnCtx(_,f),Q(f,{validation:"jwt",code:J.invalid_string,message:H.message}),S.dirty()}else if(H.kind==="cidr"){if(!P$(_.data,H.version))f=this._getOrReturnCtx(_,f),Q(f,{validation:"cidr",code:J.invalid_string,message:H.message}),S.dirty()}else if(H.kind==="base64"){if(!K$.test(_.data))f=this._getOrReturnCtx(_,f),Q(f,{validation:"base64",code:J.invalid_string,message:H.message}),S.dirty()}else if(H.kind==="base64url"){if(!k$.test(_.data))f=this._getOrReturnCtx(_,f),Q(f,{validation:"base64url",code:J.invalid_string,message:H.message}),S.dirty()}else v.assertNever(H);return{status:S.value,value:_.data}}_regex(_,$,S){return this.refinement((f)=>_.test(f),{validation:$,code:J.invalid_string,...z.errToObj(S)})}_addCheck(_){return new F({...this._def,checks:[...this._def.checks,_]})}email(_){return this._addCheck({kind:"email",...z.errToObj(_)})}url(_){return this._addCheck({kind:"url",...z.errToObj(_)})}emoji(_){return this._addCheck({kind:"emoji",...z.errToObj(_)})}uuid(_){return this._addCheck({kind:"uuid",...z.errToObj(_)})}nanoid(_){return this._addCheck({kind:"nanoid",...z.errToObj(_)})}cuid(_){return this._addCheck({kind:"cuid",...z.errToObj(_)})}cuid2(_){return this._addCheck({kind:"cuid2",...z.errToObj(_)})}ulid(_){return this._addCheck({kind:"ulid",...z.errToObj(_)})}base64(_){return this._addCheck({kind:"base64",...z.errToObj(_)})}base64url(_){return this._addCheck({kind:"base64url",...z.errToObj(_)})}jwt(_){return this._addCheck({kind:"jwt",...z.errToObj(_)})}ip(_){return this._addCheck({kind:"ip",...z.errToObj(_)})}cidr(_){return this._addCheck({kind:"cidr",...z.errToObj(_)})}datetime(_){if(typeof _==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:_});return this._addCheck({kind:"datetime",precision:typeof _?.precision>"u"?null:_?.precision,offset:_?.offset??!1,local:_?.local??!1,...z.errToObj(_?.message)})}date(_){return this._addCheck({kind:"date",message:_})}time(_){if(typeof _==="string")return this._addCheck({kind:"time",precision:null,message:_});return this._addCheck({kind:"time",precision:typeof _?.precision>"u"?null:_?.precision,...z.errToObj(_?.message)})}duration(_){return this._addCheck({kind:"duration",...z.errToObj(_)})}regex(_,$){return this._addCheck({kind:"regex",regex:_,...z.errToObj($)})}includes(_,$){return this._addCheck({kind:"includes",value:_,position:$?.position,...z.errToObj($?.message)})}startsWith(_,$){return this._addCheck({kind:"startsWith",value:_,...z.errToObj($)})}endsWith(_,$){return this._addCheck({kind:"endsWith",value:_,...z.errToObj($)})}min(_,$){return this._addCheck({kind:"min",value:_,...z.errToObj($)})}max(_,$){return this._addCheck({kind:"max",value:_,...z.errToObj($)})}length(_,$){return this._addCheck({kind:"length",value:_,...z.errToObj($)})}nonempty(_){return this.min(1,z.errToObj(_))}trim(){return new F({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new F({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new F({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((_)=>_.kind==="datetime")}get isDate(){return!!this._def.checks.find((_)=>_.kind==="date")}get isTime(){return!!this._def.checks.find((_)=>_.kind==="time")}get isDuration(){return!!this._def.checks.find((_)=>_.kind==="duration")}get isEmail(){return!!this._def.checks.find((_)=>_.kind==="email")}get isURL(){return!!this._def.checks.find((_)=>_.kind==="url")}get isEmoji(){return!!this._def.checks.find((_)=>_.kind==="emoji")}get isUUID(){return!!this._def.checks.find((_)=>_.kind==="uuid")}get isNANOID(){return!!this._def.checks.find((_)=>_.kind==="nanoid")}get isCUID(){return!!this._def.checks.find((_)=>_.kind==="cuid")}get isCUID2(){return!!this._def.checks.find((_)=>_.kind==="cuid2")}get isULID(){return!!this._def.checks.find((_)=>_.kind==="ulid")}get isIP(){return!!this._def.checks.find((_)=>_.kind==="ip")}get isCIDR(){return!!this._def.checks.find((_)=>_.kind==="cidr")}get isBase64(){return!!this._def.checks.find((_)=>_.kind==="base64")}get isBase64url(){return!!this._def.checks.find((_)=>_.kind==="base64url")}get minLength(){let _=null;for(let $ of this._def.checks)if($.kind==="min"){if(_===null||$.value>_)_=$.value}return _}get maxLength(){let _=null;for(let $ of this._def.checks)if($.kind==="max"){if(_===null||$.value<_)_=$.value}return _}}F.create=(_)=>{return new F({checks:[],typeName:R.ZodString,coerce:_?.coerce??!1,...j(_)})};function l$(_,$){let S=(_.toString().split(".")[1]||"").length,f=($.toString().split(".")[1]||"").length,H=S>f?S:f,w=Number.parseInt(_.toFixed(H).replace(".","")),q=Number.parseInt($.toFixed(H).replace(".",""));return w%q/10**H}class x extends b{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(_){if(this._def.coerce)_.data=Number(_.data);if(this._getType(_)!==M.number){let H=this._getOrReturnCtx(_);return Q(H,{code:J.invalid_type,expected:M.number,received:H.parsedType}),Y}let S=void 0,f=new U;for(let H of this._def.checks)if(H.kind==="int"){if(!v.isInteger(_.data))S=this._getOrReturnCtx(_,S),Q(S,{code:J.invalid_type,expected:"integer",received:"float",message:H.message}),f.dirty()}else if(H.kind==="min"){if(H.inclusive?_.data<H.value:_.data<=H.value)S=this._getOrReturnCtx(_,S),Q(S,{code:J.too_small,minimum:H.value,type:"number",inclusive:H.inclusive,exact:!1,message:H.message}),f.dirty()}else if(H.kind==="max"){if(H.inclusive?_.data>H.value:_.data>=H.value)S=this._getOrReturnCtx(_,S),Q(S,{code:J.too_big,maximum:H.value,type:"number",inclusive:H.inclusive,exact:!1,message:H.message}),f.dirty()}else if(H.kind==="multipleOf"){if(l$(_.data,H.value)!==0)S=this._getOrReturnCtx(_,S),Q(S,{code:J.not_multiple_of,multipleOf:H.value,message:H.message}),f.dirty()}else if(H.kind==="finite"){if(!Number.isFinite(_.data))S=this._getOrReturnCtx(_,S),Q(S,{code:J.not_finite,message:H.message}),f.dirty()}else v.assertNever(H);return{status:f.value,value:_.data}}gte(_,$){return this.setLimit("min",_,!0,z.toString($))}gt(_,$){return this.setLimit("min",_,!1,z.toString($))}lte(_,$){return this.setLimit("max",_,!0,z.toString($))}lt(_,$){return this.setLimit("max",_,!1,z.toString($))}setLimit(_,$,S,f){return new x({...this._def,checks:[...this._def.checks,{kind:_,value:$,inclusive:S,message:z.toString(f)}]})}_addCheck(_){return new x({...this._def,checks:[...this._def.checks,_]})}int(_){return this._addCheck({kind:"int",message:z.toString(_)})}positive(_){return this._addCheck({kind:"min",value:0,inclusive:!1,message:z.toString(_)})}negative(_){return this._addCheck({kind:"max",value:0,inclusive:!1,message:z.toString(_)})}nonpositive(_){return this._addCheck({kind:"max",value:0,inclusive:!0,message:z.toString(_)})}nonnegative(_){return this._addCheck({kind:"min",value:0,inclusive:!0,message:z.toString(_)})}multipleOf(_,$){return this._addCheck({kind:"multipleOf",value:_,message:z.toString($)})}finite(_){return this._addCheck({kind:"finite",message:z.toString(_)})}safe(_){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:z.toString(_)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:z.toString(_)})}get minValue(){let _=null;for(let $ of this._def.checks)if($.kind==="min"){if(_===null||$.value>_)_=$.value}return _}get maxValue(){let _=null;for(let $ of this._def.checks)if($.kind==="max"){if(_===null||$.value<_)_=$.value}return _}get isInt(){return!!this._def.checks.find((_)=>_.kind==="int"||_.kind==="multipleOf"&&v.isInteger(_.value))}get isFinite(){let _=null,$=null;for(let S of this._def.checks)if(S.kind==="finite"||S.kind==="int"||S.kind==="multipleOf")return!0;else if(S.kind==="min"){if($===null||S.value>$)$=S.value}else if(S.kind==="max"){if(_===null||S.value<_)_=S.value}return Number.isFinite($)&&Number.isFinite(_)}}x.create=(_)=>{return new x({checks:[],typeName:R.ZodNumber,coerce:_?.coerce||!1,...j(_)})};class c extends b{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse(_){if(this._def.coerce)try{_.data=BigInt(_.data)}catch{return this._getInvalidInput(_)}if(this._getType(_)!==M.bigint)return this._getInvalidInput(_);let S=void 0,f=new U;for(let H of this._def.checks)if(H.kind==="min"){if(H.inclusive?_.data<H.value:_.data<=H.value)S=this._getOrReturnCtx(_,S),Q(S,{code:J.too_small,type:"bigint",minimum:H.value,inclusive:H.inclusive,message:H.message}),f.dirty()}else if(H.kind==="max"){if(H.inclusive?_.data>H.value:_.data>=H.value)S=this._getOrReturnCtx(_,S),Q(S,{code:J.too_big,type:"bigint",maximum:H.value,inclusive:H.inclusive,message:H.message}),f.dirty()}else if(H.kind==="multipleOf"){if(_.data%H.value!==BigInt(0))S=this._getOrReturnCtx(_,S),Q(S,{code:J.not_multiple_of,multipleOf:H.value,message:H.message}),f.dirty()}else v.assertNever(H);return{status:f.value,value:_.data}}_getInvalidInput(_){let $=this._getOrReturnCtx(_);return Q($,{code:J.invalid_type,expected:M.bigint,received:$.parsedType}),Y}gte(_,$){return this.setLimit("min",_,!0,z.toString($))}gt(_,$){return this.setLimit("min",_,!1,z.toString($))}lte(_,$){return this.setLimit("max",_,!0,z.toString($))}lt(_,$){return this.setLimit("max",_,!1,z.toString($))}setLimit(_,$,S,f){return new c({...this._def,checks:[...this._def.checks,{kind:_,value:$,inclusive:S,message:z.toString(f)}]})}_addCheck(_){return new c({...this._def,checks:[...this._def.checks,_]})}positive(_){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:z.toString(_)})}negative(_){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:z.toString(_)})}nonpositive(_){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:z.toString(_)})}nonnegative(_){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:z.toString(_)})}multipleOf(_,$){return this._addCheck({kind:"multipleOf",value:_,message:z.toString($)})}get minValue(){let _=null;for(let $ of this._def.checks)if($.kind==="min"){if(_===null||$.value>_)_=$.value}return _}get maxValue(){let _=null;for(let $ of this._def.checks)if($.kind==="max"){if(_===null||$.value<_)_=$.value}return _}}c.create=(_)=>{return new c({checks:[],typeName:R.ZodBigInt,coerce:_?.coerce??!1,...j(_)})};class $_ extends b{_parse(_){if(this._def.coerce)_.data=Boolean(_.data);if(this._getType(_)!==M.boolean){let S=this._getOrReturnCtx(_);return Q(S,{code:J.invalid_type,expected:M.boolean,received:S.parsedType}),Y}return N(_.data)}}$_.create=(_)=>{return new $_({typeName:R.ZodBoolean,coerce:_?.coerce||!1,...j(_)})};class i extends b{_parse(_){if(this._def.coerce)_.data=new Date(_.data);if(this._getType(_)!==M.date){let H=this._getOrReturnCtx(_);return Q(H,{code:J.invalid_type,expected:M.date,received:H.parsedType}),Y}if(Number.isNaN(_.data.getTime())){let H=this._getOrReturnCtx(_);return Q(H,{code:J.invalid_date}),Y}let S=new U,f=void 0;for(let H of this._def.checks)if(H.kind==="min"){if(_.data.getTime()<H.value)f=this._getOrReturnCtx(_,f),Q(f,{code:J.too_small,message:H.message,inclusive:!0,exact:!1,minimum:H.value,type:"date"}),S.dirty()}else if(H.kind==="max"){if(_.data.getTime()>H.value)f=this._getOrReturnCtx(_,f),Q(f,{code:J.too_big,message:H.message,inclusive:!0,exact:!1,maximum:H.value,type:"date"}),S.dirty()}else v.assertNever(H);return{status:S.value,value:new Date(_.data.getTime())}}_addCheck(_){return new i({...this._def,checks:[...this._def.checks,_]})}min(_,$){return this._addCheck({kind:"min",value:_.getTime(),message:z.toString($)})}max(_,$){return this._addCheck({kind:"max",value:_.getTime(),message:z.toString($)})}get minDate(){let _=null;for(let $ of this._def.checks)if($.kind==="min"){if(_===null||$.value>_)_=$.value}return _!=null?new Date(_):null}get maxDate(){let _=null;for(let $ of this._def.checks)if($.kind==="max"){if(_===null||$.value<_)_=$.value}return _!=null?new Date(_):null}}i.create=(_)=>{return new i({checks:[],coerce:_?.coerce||!1,typeName:R.ZodDate,...j(_)})};class Y_ extends b{_parse(_){if(this._getType(_)!==M.symbol){let S=this._getOrReturnCtx(_);return Q(S,{code:J.invalid_type,expected:M.symbol,received:S.parsedType}),Y}return N(_.data)}}Y_.create=(_)=>{return new Y_({typeName:R.ZodSymbol,...j(_)})};class S_ extends b{_parse(_){if(this._getType(_)!==M.undefined){let S=this._getOrReturnCtx(_);return Q(S,{code:J.invalid_type,expected:M.undefined,received:S.parsedType}),Y}return N(_.data)}}S_.create=(_)=>{return new S_({typeName:R.ZodUndefined,...j(_)})};class H_ extends b{_parse(_){if(this._getType(_)!==M.null){let S=this._getOrReturnCtx(_);return Q(S,{code:J.invalid_type,expected:M.null,received:S.parsedType}),Y}return N(_.data)}}H_.create=(_)=>{return new H_({typeName:R.ZodNull,...j(_)})};class u extends b{constructor(){super(...arguments);this._any=!0}_parse(_){return N(_.data)}}u.create=(_)=>{return new u({typeName:R.ZodAny,...j(_)})};class y extends b{constructor(){super(...arguments);this._unknown=!0}_parse(_){return N(_.data)}}y.create=(_)=>{return new y({typeName:R.ZodUnknown,...j(_)})};class I extends b{_parse(_){let $=this._getOrReturnCtx(_);return Q($,{code:J.invalid_type,expected:M.never,received:$.parsedType}),Y}}I.create=(_)=>{return new I({typeName:R.ZodNever,...j(_)})};class B_ extends b{_parse(_){if(this._getType(_)!==M.undefined){let S=this._getOrReturnCtx(_);return Q(S,{code:J.invalid_type,expected:M.void,received:S.parsedType}),Y}return N(_.data)}}B_.create=(_)=>{return new B_({typeName:R.ZodVoid,...j(_)})};class K extends b{_parse(_){let{ctx:$,status:S}=this._processInputParams(_),f=this._def;if($.parsedType!==M.array)return Q($,{code:J.invalid_type,expected:M.array,received:$.parsedType}),Y;if(f.exactLength!==null){let w=$.data.length>f.exactLength.value,q=$.data.length<f.exactLength.value;if(w||q)Q($,{code:w?J.too_big:J.too_small,minimum:q?f.exactLength.value:void 0,maximum:w?f.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:f.exactLength.message}),S.dirty()}if(f.minLength!==null){if($.data.length<f.minLength.value)Q($,{code:J.too_small,minimum:f.minLength.value,type:"array",inclusive:!0,exact:!1,message:f.minLength.message}),S.dirty()}if(f.maxLength!==null){if($.data.length>f.maxLength.value)Q($,{code:J.too_big,maximum:f.maxLength.value,type:"array",inclusive:!0,exact:!1,message:f.maxLength.message}),S.dirty()}if($.common.async)return Promise.all([...$.data].map((w,q)=>{return f.type._parseAsync(new g($,w,$.path,q))})).then((w)=>{return U.mergeArray(S,w)});let H=[...$.data].map((w,q)=>{return f.type._parseSync(new g($,w,$.path,q))});return U.mergeArray(S,H)}get element(){return this._def.type}min(_,$){return new K({...this._def,minLength:{value:_,message:z.toString($)}})}max(_,$){return new K({...this._def,maxLength:{value:_,message:z.toString($)}})}length(_,$){return new K({...this._def,exactLength:{value:_,message:z.toString($)}})}nonempty(_){return this.min(1,_)}}K.create=(_,$)=>{return new K({type:_,minLength:null,maxLength:null,exactLength:null,typeName:R.ZodArray,...j($)})};function e(_){if(_ instanceof O){let $={};for(let S in _.shape){let f=_.shape[S];$[S]=k.create(e(f))}return new O({..._._def,shape:()=>$})}else if(_ instanceof K)return new K({..._._def,type:e(_.element)});else if(_ instanceof k)return k.create(e(_.unwrap()));else if(_ instanceof T)return T.create(e(_.unwrap()));else if(_ instanceof P)return P.create(_.items.map(($)=>e($)));else return _}class O extends b{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let _=this._def.shape(),$=v.objectKeys(_);return this._cached={shape:_,keys:$},this._cached}_parse(_){if(this._getType(_)!==M.object){let G=this._getOrReturnCtx(_);return Q(G,{code:J.invalid_type,expected:M.object,received:G.parsedType}),Y}let{status:S,ctx:f}=this._processInputParams(_),{shape:H,keys:w}=this._getCached(),q=[];if(!(this._def.catchall instanceof I&&this._def.unknownKeys==="strip")){for(let G in f.data)if(!w.includes(G))q.push(G)}let X=[];for(let G of w){let B=H[G],E=f.data[G];X.push({key:{status:"valid",value:G},value:B._parse(new g(f,E,f.path,G)),alwaysSet:G in f.data})}if(this._def.catchall instanceof I){let G=this._def.unknownKeys;if(G==="passthrough")for(let B of q)X.push({key:{status:"valid",value:B},value:{status:"valid",value:f.data[B]}});else if(G==="strict"){if(q.length>0)Q(f,{code:J.unrecognized_keys,keys:q}),S.dirty()}else if(G==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let G=this._def.catchall;for(let B of q){let E=f.data[B];X.push({key:{status:"valid",value:B},value:G._parse(new g(f,E,f.path,B)),alwaysSet:B in f.data})}}if(f.common.async)return Promise.resolve().then(async()=>{let G=[];for(let B of X){let E=await B.key,A=await B.value;G.push({key:E,value:A,alwaysSet:B.alwaysSet})}return G}).then((G)=>{return U.mergeObjectSync(S,G)});else return U.mergeObjectSync(S,X)}get shape(){return this._def.shape()}strict(_){return z.errToObj,new O({...this._def,unknownKeys:"strict",..._!==void 0?{errorMap:($,S)=>{let f=this._def.errorMap?.($,S).message??S.defaultError;if($.code==="unrecognized_keys")return{message:z.errToObj(_).message??f};return{message:f}}}:{}})}strip(){return new O({...this._def,unknownKeys:"strip"})}passthrough(){return new O({...this._def,unknownKeys:"passthrough"})}extend(_){return new O({...this._def,shape:()=>({...this._def.shape(),..._})})}merge(_){return new O({unknownKeys:_._def.unknownKeys,catchall:_._def.catchall,shape:()=>({...this._def.shape(),..._._def.shape()}),typeName:R.ZodObject})}setKey(_,$){return this.augment({[_]:$})}catchall(_){return new O({...this._def,catchall:_})}pick(_){let $={};for(let S of v.objectKeys(_))if(_[S]&&this.shape[S])$[S]=this.shape[S];return new O({...this._def,shape:()=>$})}omit(_){let $={};for(let S of v.objectKeys(this.shape))if(!_[S])$[S]=this.shape[S];return new O({...this._def,shape:()=>$})}deepPartial(){return e(this)}partial(_){let $={};for(let S of v.objectKeys(this.shape)){let f=this.shape[S];if(_&&!_[S])$[S]=f;else $[S]=f.optional()}return new O({...this._def,shape:()=>$})}required(_){let $={};for(let S of v.objectKeys(this.shape))if(_&&!_[S])$[S]=this.shape[S];else{let H=this.shape[S];while(H instanceof k)H=H._def.innerType;$[S]=H}return new O({...this._def,shape:()=>$})}keyof(){return c_(v.objectKeys(this.shape))}}O.create=(_,$)=>{return new O({shape:()=>_,unknownKeys:"strip",catchall:I.create(),typeName:R.ZodObject,...j($)})};O.strictCreate=(_,$)=>{return new O({shape:()=>_,unknownKeys:"strict",catchall:I.create(),typeName:R.ZodObject,...j($)})};O.lazycreate=(_,$)=>{return new O({shape:_,unknownKeys:"strip",catchall:I.create(),typeName:R.ZodObject,...j($)})};class f_ extends b{_parse(_){let{ctx:$}=this._processInputParams(_),S=this._def.options;function f(H){for(let q of H)if(q.result.status==="valid")return q.result;for(let q of H)if(q.result.status==="dirty")return $.common.issues.push(...q.ctx.common.issues),q.result;let w=H.map((q)=>new D(q.ctx.common.issues));return Q($,{code:J.invalid_union,unionErrors:w}),Y}if($.common.async)return Promise.all(S.map(async(H)=>{let w={...$,common:{...$.common,issues:[]},parent:null};return{result:await H._parseAsync({data:$.data,path:$.path,parent:w}),ctx:w}})).then(f);else{let H=void 0,w=[];for(let X of S){let G={...$,common:{...$.common,issues:[]},parent:null},B=X._parseSync({data:$.data,path:$.path,parent:G});if(B.status==="valid")return B;else if(B.status==="dirty"&&!H)H={result:B,ctx:G};if(G.common.issues.length)w.push(G.common.issues)}if(H)return $.common.issues.push(...H.ctx.common.issues),H.result;let q=w.map((X)=>new D(X));return Q($,{code:J.invalid_union,unionErrors:q}),Y}}get options(){return this._def.options}}f_.create=(_,$)=>{return new f_({options:_,typeName:R.ZodUnion,...j($)})};var m=(_)=>{if(_ instanceof w_)return m(_.schema);else if(_ instanceof C)return m(_.innerType());else if(_ instanceof W_)return[_.value];else if(_ instanceof Z)return _.options;else if(_ instanceof X_)return v.objectValues(_.enum);else if(_ instanceof G_)return m(_._def.innerType);else if(_ instanceof S_)return[void 0];else if(_ instanceof H_)return[null];else if(_ instanceof k)return[void 0,...m(_.unwrap())];else if(_ instanceof T)return[null,...m(_.unwrap())];else if(_ instanceof U_)return m(_.unwrap());else if(_ instanceof M_)return m(_.unwrap());else if(_ instanceof J_)return m(_._def.innerType);else return[]};class L_ extends b{_parse(_){let{ctx:$}=this._processInputParams(_);if($.parsedType!==M.object)return Q($,{code:J.invalid_type,expected:M.object,received:$.parsedType}),Y;let S=this.discriminator,f=$.data[S],H=this.optionsMap.get(f);if(!H)return Q($,{code:J.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[S]}),Y;if($.common.async)return H._parseAsync({data:$.data,path:$.path,parent:$});else return H._parseSync({data:$.data,path:$.path,parent:$})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(_,$,S){let f=new Map;for(let H of $){let w=m(H.shape[_]);if(!w.length)throw Error(`A discriminator value for key \`${_}\` could not be extracted from all schema options`);for(let q of w){if(f.has(q))throw Error(`Discriminator property ${String(_)} has duplicate value ${String(q)}`);f.set(q,H)}}return new L_({typeName:R.ZodDiscriminatedUnion,discriminator:_,options:$,optionsMap:f,...j(S)})}}function I_(_,$){let S=h(_),f=h($);if(_===$)return{valid:!0,data:_};else if(S===M.object&&f===M.object){let H=v.objectKeys($),w=v.objectKeys(_).filter((X)=>H.indexOf(X)!==-1),q={..._,...$};for(let X of w){let G=I_(_[X],$[X]);if(!G.valid)return{valid:!1};q[X]=G.data}return{valid:!0,data:q}}else if(S===M.array&&f===M.array){if(_.length!==$.length)return{valid:!1};let H=[];for(let w=0;w<_.length;w++){let q=_[w],X=$[w],G=I_(q,X);if(!G.valid)return{valid:!1};H.push(G.data)}return{valid:!0,data:H}}else if(S===M.date&&f===M.date&&+_===+$)return{valid:!0,data:_};else return{valid:!1}}class q_ extends b{_parse(_){let{status:$,ctx:S}=this._processInputParams(_),f=(H,w)=>{if(O_(H)||O_(w))return Y;let q=I_(H.value,w.value);if(!q.valid)return Q(S,{code:J.invalid_intersection_types}),Y;if(A_(H)||A_(w))$.dirty();return{status:$.value,value:q.data}};if(S.common.async)return Promise.all([this._def.left._parseAsync({data:S.data,path:S.path,parent:S}),this._def.right._parseAsync({data:S.data,path:S.path,parent:S})]).then(([H,w])=>f(H,w));else return f(this._def.left._parseSync({data:S.data,path:S.path,parent:S}),this._def.right._parseSync({data:S.data,path:S.path,parent:S}))}}q_.create=(_,$,S)=>{return new q_({left:_,right:$,typeName:R.ZodIntersection,...j(S)})};class P extends b{_parse(_){let{status:$,ctx:S}=this._processInputParams(_);if(S.parsedType!==M.array)return Q(S,{code:J.invalid_type,expected:M.array,received:S.parsedType}),Y;if(S.data.length<this._def.items.length)return Q(S,{code:J.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Y;if(!this._def.rest&&S.data.length>this._def.items.length)Q(S,{code:J.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),$.dirty();let H=[...S.data].map((w,q)=>{let X=this._def.items[q]||this._def.rest;if(!X)return null;return X._parse(new g(S,w,S.path,q))}).filter((w)=>!!w);if(S.common.async)return Promise.all(H).then((w)=>{return U.mergeArray($,w)});else return U.mergeArray($,H)}get items(){return this._def.items}rest(_){return new P({...this._def,rest:_})}}P.create=(_,$)=>{if(!Array.isArray(_))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new P({items:_,typeName:R.ZodTuple,rest:null,...j($)})};class E_ extends b{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(_){let{status:$,ctx:S}=this._processInputParams(_);if(S.parsedType!==M.object)return Q(S,{code:J.invalid_type,expected:M.object,received:S.parsedType}),Y;let f=[],H=this._def.keyType,w=this._def.valueType;for(let q in S.data)f.push({key:H._parse(new g(S,q,S.path,q)),value:w._parse(new g(S,S.data[q],S.path,q)),alwaysSet:q in S.data});if(S.common.async)return U.mergeObjectAsync($,f);else return U.mergeObjectSync($,f)}get element(){return this._def.valueType}static create(_,$,S){if($ instanceof b)return new E_({keyType:_,valueType:$,typeName:R.ZodRecord,...j(S)});return new E_({keyType:F.create(),valueType:_,typeName:R.ZodRecord,...j($)})}}class R_ extends b{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(_){let{status:$,ctx:S}=this._processInputParams(_);if(S.parsedType!==M.map)return Q(S,{code:J.invalid_type,expected:M.map,received:S.parsedType}),Y;let f=this._def.keyType,H=this._def.valueType,w=[...S.data.entries()].map(([q,X],G)=>{return{key:f._parse(new g(S,q,S.path,[G,"key"])),value:H._parse(new g(S,X,S.path,[G,"value"]))}});if(S.common.async){let q=new Map;return Promise.resolve().then(async()=>{for(let X of w){let G=await X.key,B=await X.value;if(G.status==="aborted"||B.status==="aborted")return Y;if(G.status==="dirty"||B.status==="dirty")$.dirty();q.set(G.value,B.value)}return{status:$.value,value:q}})}else{let q=new Map;for(let X of w){let{key:G,value:B}=X;if(G.status==="aborted"||B.status==="aborted")return Y;if(G.status==="dirty"||B.status==="dirty")$.dirty();q.set(G.value,B.value)}return{status:$.value,value:q}}}}R_.create=(_,$,S)=>{return new R_({valueType:$,keyType:_,typeName:R.ZodMap,...j(S)})};class p extends b{_parse(_){let{status:$,ctx:S}=this._processInputParams(_);if(S.parsedType!==M.set)return Q(S,{code:J.invalid_type,expected:M.set,received:S.parsedType}),Y;let f=this._def;if(f.minSize!==null){if(S.data.size<f.minSize.value)Q(S,{code:J.too_small,minimum:f.minSize.value,type:"set",inclusive:!0,exact:!1,message:f.minSize.message}),$.dirty()}if(f.maxSize!==null){if(S.data.size>f.maxSize.value)Q(S,{code:J.too_big,maximum:f.maxSize.value,type:"set",inclusive:!0,exact:!1,message:f.maxSize.message}),$.dirty()}let H=this._def.valueType;function w(X){let G=new Set;for(let B of X){if(B.status==="aborted")return Y;if(B.status==="dirty")$.dirty();G.add(B.value)}return{status:$.value,value:G}}let q=[...S.data.values()].map((X,G)=>H._parse(new g(S,X,S.path,G)));if(S.common.async)return Promise.all(q).then((X)=>w(X));else return w(q)}min(_,$){return new p({...this._def,minSize:{value:_,message:z.toString($)}})}max(_,$){return new p({...this._def,maxSize:{value:_,message:z.toString($)}})}size(_,$){return this.min(_,$).max(_,$)}nonempty(_){return this.min(1,_)}}p.create=(_,$)=>{return new p({valueType:_,minSize:null,maxSize:null,typeName:R.ZodSet,...j($)})};class __ extends b{constructor(){super(...arguments);this.validate=this.implement}_parse(_){let{ctx:$}=this._processInputParams(_);if($.parsedType!==M.function)return Q($,{code:J.invalid_type,expected:M.function,received:$.parsedType}),Y;function S(q,X){return z_({data:q,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,t(),l].filter((G)=>!!G),issueData:{code:J.invalid_arguments,argumentsError:X}})}function f(q,X){return z_({data:q,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,t(),l].filter((G)=>!!G),issueData:{code:J.invalid_return_type,returnTypeError:X}})}let H={errorMap:$.common.contextualErrorMap},w=$.data;if(this._def.returns instanceof d){let q=this;return N(async function(...X){let G=new D([]),B=await q._def.args.parseAsync(X,H).catch((V)=>{throw G.addIssue(S(X,V)),G}),E=await Reflect.apply(w,this,B);return await q._def.returns._def.type.parseAsync(E,H).catch((V)=>{throw G.addIssue(f(E,V)),G})})}else{let q=this;return N(function(...X){let G=q._def.args.safeParse(X,H);if(!G.success)throw new D([S(X,G.error)]);let B=Reflect.apply(w,this,G.data),E=q._def.returns.safeParse(B,H);if(!E.success)throw new D([f(B,E.error)]);return E.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(..._){return new __({...this._def,args:P.create(_).rest(y.create())})}returns(_){return new __({...this._def,returns:_})}implement(_){return this.parse(_)}strictImplement(_){return this.parse(_)}static create(_,$,S){return new __({args:_?_:P.create([]).rest(y.create()),returns:$||y.create(),typeName:R.ZodFunction,...j(S)})}}class w_ extends b{get schema(){return this._def.getter()}_parse(_){let{ctx:$}=this._processInputParams(_);return this._def.getter()._parse({data:$.data,path:$.path,parent:$})}}w_.create=(_,$)=>{return new w_({getter:_,typeName:R.ZodLazy,...j($)})};class W_ extends b{_parse(_){if(_.data!==this._def.value){let $=this._getOrReturnCtx(_);return Q($,{received:$.data,code:J.invalid_literal,expected:this._def.value}),Y}return{status:"valid",value:_.data}}get value(){return this._def.value}}W_.create=(_,$)=>{return new W_({value:_,typeName:R.ZodLiteral,...j($)})};function c_(_,$){return new Z({values:_,typeName:R.ZodEnum,...j($)})}class Z extends b{_parse(_){if(typeof _.data!=="string"){let $=this._getOrReturnCtx(_),S=this._def.values;return Q($,{expected:v.joinValues(S),received:$.parsedType,code:J.invalid_type}),Y}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has(_.data)){let $=this._getOrReturnCtx(_),S=this._def.values;return Q($,{received:$.data,code:J.invalid_enum_value,options:S}),Y}return N(_.data)}get options(){return this._def.values}get enum(){let _={};for(let $ of this._def.values)_[$]=$;return _}get Values(){let _={};for(let $ of this._def.values)_[$]=$;return _}get Enum(){let _={};for(let $ of this._def.values)_[$]=$;return _}extract(_,$=this._def){return Z.create(_,{...this._def,...$})}exclude(_,$=this._def){return Z.create(this.options.filter((S)=>!_.includes(S)),{...this._def,...$})}}Z.create=c_;class X_ extends b{_parse(_){let $=v.getValidEnumValues(this._def.values),S=this._getOrReturnCtx(_);if(S.parsedType!==M.string&&S.parsedType!==M.number){let f=v.objectValues($);return Q(S,{expected:v.joinValues(f),received:S.parsedType,code:J.invalid_type}),Y}if(!this._cache)this._cache=new Set(v.getValidEnumValues(this._def.values));if(!this._cache.has(_.data)){let f=v.objectValues($);return Q(S,{received:S.data,code:J.invalid_enum_value,options:f}),Y}return N(_.data)}get enum(){return this._def.values}}X_.create=(_,$)=>{return new X_({values:_,typeName:R.ZodNativeEnum,...j($)})};class d extends b{unwrap(){return this._def.type}_parse(_){let{ctx:$}=this._processInputParams(_);if($.parsedType!==M.promise&&$.common.async===!1)return Q($,{code:J.invalid_type,expected:M.promise,received:$.parsedType}),Y;let S=$.parsedType===M.promise?$.data:Promise.resolve($.data);return N(S.then((f)=>{return this._def.type.parseAsync(f,{path:$.path,errorMap:$.common.contextualErrorMap})}))}}d.create=(_,$)=>{return new d({type:_,typeName:R.ZodPromise,...j($)})};class C extends b{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===R.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(_){let{status:$,ctx:S}=this._processInputParams(_),f=this._def.effect||null,H={addIssue:(w)=>{if(Q(S,w),w.fatal)$.abort();else $.dirty()},get path(){return S.path}};if(H.addIssue=H.addIssue.bind(H),f.type==="preprocess"){let w=f.transform(S.data,H);if(S.common.async)return Promise.resolve(w).then(async(q)=>{if($.value==="aborted")return Y;let X=await this._def.schema._parseAsync({data:q,path:S.path,parent:S});if(X.status==="aborted")return Y;if(X.status==="dirty")return o(X.value);if($.value==="dirty")return o(X.value);return X});else{if($.value==="aborted")return Y;let q=this._def.schema._parseSync({data:w,path:S.path,parent:S});if(q.status==="aborted")return Y;if(q.status==="dirty")return o(q.value);if($.value==="dirty")return o(q.value);return q}}if(f.type==="refinement"){let w=(q)=>{let X=f.refinement(q,H);if(S.common.async)return Promise.resolve(X);if(X instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return q};if(S.common.async===!1){let q=this._def.schema._parseSync({data:S.data,path:S.path,parent:S});if(q.status==="aborted")return Y;if(q.status==="dirty")$.dirty();return w(q.value),{status:$.value,value:q.value}}else return this._def.schema._parseAsync({data:S.data,path:S.path,parent:S}).then((q)=>{if(q.status==="aborted")return Y;if(q.status==="dirty")$.dirty();return w(q.value).then(()=>{return{status:$.value,value:q.value}})})}if(f.type==="transform")if(S.common.async===!1){let w=this._def.schema._parseSync({data:S.data,path:S.path,parent:S});if(!n(w))return Y;let q=f.transform(w.value,H);if(q instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:$.value,value:q}}else return this._def.schema._parseAsync({data:S.data,path:S.path,parent:S}).then((w)=>{if(!n(w))return Y;return Promise.resolve(f.transform(w.value,H)).then((q)=>({status:$.value,value:q}))});v.assertNever(f)}}C.create=(_,$,S)=>{return new C({schema:_,typeName:R.ZodEffects,effect:$,...j(S)})};C.createWithPreprocess=(_,$,S)=>{return new C({schema:$,effect:{type:"preprocess",transform:_},typeName:R.ZodEffects,...j(S)})};class k extends b{_parse(_){if(this._getType(_)===M.undefined)return N(void 0);return this._def.innerType._parse(_)}unwrap(){return this._def.innerType}}k.create=(_,$)=>{return new k({innerType:_,typeName:R.ZodOptional,...j($)})};class T extends b{_parse(_){if(this._getType(_)===M.null)return N(null);return this._def.innerType._parse(_)}unwrap(){return this._def.innerType}}T.create=(_,$)=>{return new T({innerType:_,typeName:R.ZodNullable,...j($)})};class G_ extends b{_parse(_){let{ctx:$}=this._processInputParams(_),S=$.data;if($.parsedType===M.undefined)S=this._def.defaultValue();return this._def.innerType._parse({data:S,path:$.path,parent:$})}removeDefault(){return this._def.innerType}}G_.create=(_,$)=>{return new G_({innerType:_,typeName:R.ZodDefault,defaultValue:typeof $.default==="function"?$.default:()=>$.default,...j($)})};class J_ extends b{_parse(_){let{ctx:$}=this._processInputParams(_),S={...$,common:{...$.common,issues:[]}},f=this._def.innerType._parse({data:S.data,path:S.path,parent:{...S}});if(s(f))return f.then((H)=>{return{status:"valid",value:H.status==="valid"?H.value:this._def.catchValue({get error(){return new D(S.common.issues)},input:S.data})}});else return{status:"valid",value:f.status==="valid"?f.value:this._def.catchValue({get error(){return new D(S.common.issues)},input:S.data})}}removeCatch(){return this._def.innerType}}J_.create=(_,$)=>{return new J_({innerType:_,typeName:R.ZodCatch,catchValue:typeof $.catch==="function"?$.catch:()=>$.catch,...j($)})};class j_ extends b{_parse(_){if(this._getType(_)!==M.nan){let S=this._getOrReturnCtx(_);return Q(S,{code:J.invalid_type,expected:M.nan,received:S.parsedType}),Y}return{status:"valid",value:_.data}}}j_.create=(_)=>{return new j_({typeName:R.ZodNaN,...j(_)})};var m$=Symbol("zod_brand");class U_ extends b{_parse(_){let{ctx:$}=this._processInputParams(_),S=$.data;return this._def.type._parse({data:S,path:$.path,parent:$})}unwrap(){return this._def.type}}class b_ extends b{_parse(_){let{status:$,ctx:S}=this._processInputParams(_);if(S.common.async)return(async()=>{let H=await this._def.in._parseAsync({data:S.data,path:S.path,parent:S});if(H.status==="aborted")return Y;if(H.status==="dirty")return $.dirty(),o(H.value);else return this._def.out._parseAsync({data:H.value,path:S.path,parent:S})})();else{let f=this._def.in._parseSync({data:S.data,path:S.path,parent:S});if(f.status==="aborted")return Y;if(f.status==="dirty")return $.dirty(),{status:"dirty",value:f.value};else return this._def.out._parseSync({data:f.value,path:S.path,parent:S})}}static create(_,$){return new b_({in:_,out:$,typeName:R.ZodPipeline})}}class M_ extends b{_parse(_){let $=this._def.innerType._parse(_),S=(f)=>{if(n(f))f.value=Object.freeze(f.value);return f};return s($)?$.then((f)=>S(f)):S($)}unwrap(){return this._def.innerType}}M_.create=(_,$)=>{return new M_({innerType:_,typeName:R.ZodReadonly,...j($)})};function T_(_,$){let S=typeof _==="function"?_($):typeof _==="string"?{message:_}:_;return typeof S==="string"?{message:S}:S}function Z_(_,$={},S){if(_)return u.create().superRefine((f,H)=>{let w=_(f);if(w instanceof Promise)return w.then((q)=>{if(!q){let X=T_($,f),G=X.fatal??S??!0;H.addIssue({code:"custom",...X,fatal:G})}});if(!w){let q=T_($,f),X=q.fatal??S??!0;H.addIssue({code:"custom",...q,fatal:X})}return});return u.create()}var T$={object:O.lazycreate},R;(function(_){_.ZodString="ZodString",_.ZodNumber="ZodNumber",_.ZodNaN="ZodNaN",_.ZodBigInt="ZodBigInt",_.ZodBoolean="ZodBoolean",_.ZodDate="ZodDate",_.ZodSymbol="ZodSymbol",_.ZodUndefined="ZodUndefined",_.ZodNull="ZodNull",_.ZodAny="ZodAny",_.ZodUnknown="ZodUnknown",_.ZodNever="ZodNever",_.ZodVoid="ZodVoid",_.ZodArray="ZodArray",_.ZodObject="ZodObject",_.ZodUnion="ZodUnion",_.ZodDiscriminatedUnion="ZodDiscriminatedUnion",_.ZodIntersection="ZodIntersection",_.ZodTuple="ZodTuple",_.ZodRecord="ZodRecord",_.ZodMap="ZodMap",_.ZodSet="ZodSet",_.ZodFunction="ZodFunction",_.ZodLazy="ZodLazy",_.ZodLiteral="ZodLiteral",_.ZodEnum="ZodEnum",_.ZodEffects="ZodEffects",_.ZodNativeEnum="ZodNativeEnum",_.ZodOptional="ZodOptional",_.ZodNullable="ZodNullable",_.ZodDefault="ZodDefault",_.ZodCatch="ZodCatch",_.ZodPromise="ZodPromise",_.ZodBranded="ZodBranded",_.ZodPipeline="ZodPipeline",_.ZodReadonly="ZodReadonly"})(R||(R={}));var n$=(_,$={message:`Input not instance of ${_.name}`})=>Z_((S)=>S instanceof _,$),r_=F.create,o_=x.create,y$=j_.create,x$=c.create,i_=$_.create,c$=i.create,Z$=Y_.create,r$=S_.create,o$=H_.create,i$=u.create,u$=y.create,p$=I.create,d$=B_.create,a$=K.create,t$=O.create,s$=O.strictCreate,e$=f_.create,_S=L_.create,$S=q_.create,SS=P.create,HS=E_.create,fS=R_.create,qS=p.create,wS=__.create,WS=w_.create,XS=W_.create,GS=Z.create,JS=X_.create,MS=d.create,QS=C.create,zS=k.create,YS=T.create,BS=C.createWithPreprocess,ES=b_.create,RS=()=>r_().optional(),jS=()=>o_().optional(),bS=()=>i_().optional(),vS={string:(_)=>F.create({..._,coerce:!0}),number:(_)=>x.create({..._,coerce:!0}),boolean:(_)=>$_.create({..._,coerce:!0}),bigint:(_)=>c.create({..._,coerce:!0}),date:(_)=>i.create({..._,coerce:!0})};var OS=Y;var u_=W.object({mode:W.enum(["dev","prod"]),url:W.string(),route:W.string().optional(),buildId:W.string().optional(),releaseHash:W.string().optional(),framework:W.string().optional()}),V_=W.object({userAgent:W.string(),viewport:W.object({width:W.number(),height:W.number()}).optional(),language:W.string().optional()}),N_=W.object({file:W.string(),line:W.number().optional(),col:W.number().optional(),fn:W.string().optional(),codeSnippet:W.string().optional()}),D_=W.object({method:W.string(),url:W.string(),status:W.number().optional(),durationMs:W.number().optional(),requestBodySize:W.number().optional(),responseBodySize:W.number().optional(),requestHeaders:W.record(W.string()).optional(),responseHeaders:W.record(W.string()).optional(),error:W.string().optional()}),F_=W.object({level:W.enum(["log","warn","error"]),args:W.array(W.unknown()),timestamp:W.number()}),K_=W.object({localStorage:W.array(W.object({key:W.string(),type:W.string()})).optional(),sessionStorage:W.array(W.object({key:W.string(),type:W.string()})).optional(),cookies:W.array(W.string()).optional()}),k_=W.object({t:W.number(),kind:W.enum(["click","input","scroll","nav","mutation","error"]),target:W.string().optional(),summary:W.string()});var AS=W.enum(["critical","error","warning"]),LS=W.enum(["unresolved","resolved","ignored"]),US=W.enum(["high","medium","low"]),zH=W.object({id:W.string(),fingerprint:W.string(),title:W.string(),errorType:W.string(),severity:AS,status:LS,count:W.number().int().positive(),firstSeen:W.number(),lastSeen:W.number(),environments:W.array(W.enum(["dev","prod"])),sampleIds:W.array(W.string()),diagnosisId:W.string().optional(),projectKey:W.string()}),YH=W.object({id:W.string(),groupId:W.string(),projectKey:W.string(),environmentMode:W.enum(["dev","prod"]),createdAt:W.number(),errorType:W.string(),errorMessage:W.string(),normalizedMessage:W.string(),stackFrames:W.array(N_),consoleEntries:W.array(F_),networkEntries:W.array(D_),storageSnapshot:K_.optional(),timeline:W.array(k_),replayRef:W.string().optional(),device:V_,url:W.string(),route:W.string().optional()}),BH=W.object({id:W.string(),groupId:W.string(),createdAt:W.number(),model:W.string(),rootCause:W.string(),plainSummary:W.string(),fixPrompt:W.string(),confidence:US,analyzedSampleIds:W.array(W.string())});var bH=W.object({projectKey:W.string(),error:W.object({type:W.string(),message:W.string(),stack:W.array(N_)}),environment:u_,device:V_,consoleEntries:W.array(F_).default([]),networkEntries:W.array(D_).default([]),storageSnapshot:K_.optional(),timeline:W.array(k_).default([])});var VS=new Set(["authorization","cookie","set-cookie","x-api-key","x-auth-token","x-secret"]),NS=new Set(["token","key","secret","password","api_key","access_token","refresh_token","client_secret","apikey"]),DS=/eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*/g,FS=/\b(sk-|pk_live_|pk_test_|Bearer\s)\S+/g;function g_(_){try{let $=new URL(_);for(let S of $.searchParams.keys())if(NS.has(S.toLowerCase()))$.searchParams.set(S,"[redacted]");return $.toString()}catch{return _}}function p_(_){let $={};for(let[S,f]of Object.entries(_))if(!VS.has(S.toLowerCase()))$[S]=f;return $}function d_(_){return _.map(($)=>({...$,url:g_($.url),requestHeaders:$.requestHeaders?p_($.requestHeaders):void 0,responseHeaders:$.responseHeaders?p_($.responseHeaders):void 0}))}function KS(_){return _.replace(DS,"[token]").replace(FS,"$1[api-key]")}function a_(_){return _.map(($)=>({...$,args:$.args.map((S)=>typeof S==="string"?KS(S):S)}))}function kS(){try{if("__ASTRO__"in window)return"astro";if("__NEXT_DATA__"in window)return"next";if(document.querySelector("meta[name='generator'][content*='Astro']"))return"astro";let _=import.meta.env;if(_&&Object.keys(_).some(($)=>$.startsWith("VITE_")))return"vite"}catch{}return}function gS(){return{userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}function t_(_,$,S){return{projectKey:_.projectKey,error:{type:$.type,message:$.message,stack:$.stack},environment:{mode:_.environment,url:window.location.href,route:window.location.pathname,framework:kS(),buildId:_.buildId},device:gS(),consoleEntries:a_(S.console),networkEntries:d_(S.network),timeline:S.replay}}function P_(_){if(!_)return[];return _.split(`
|
|
2
|
+
`).slice(1).map(($)=>$.trim()).filter(($)=>$.startsWith("at ")).map(($)=>{let S=$.match(/^at (.+?) \((.+):(\d+):(\d+)\)$/);if(S)return{fn:S[1],file:S[2],line:parseInt(S[3],10),col:parseInt(S[4],10)};let f=$.match(/^at (.+):(\d+):(\d+)$/);if(f)return{file:f[1],line:parseInt(f[2],10),col:parseInt(f[3],10)};return{file:$.replace(/^at /,"")}})}function s_(_){if(_ instanceof Error)return{type:_.name||"Error",message:_.message,stack:P_(_.stack)};return{type:"UnknownError",message:String(_),stack:[]}}function e_(_){let $=(f)=>{f.preventDefault(),_(s_(f.error??Error(f.message)))},S=(f)=>{f.preventDefault(),_(s_(f.reason))};return window.addEventListener("error",$),window.addEventListener("unhandledrejection",S),()=>{window.removeEventListener("error",$),window.removeEventListener("unhandledrejection",S)}}var _$=["log","warn","error"];function CS(_){if(typeof _==="string"||typeof _==="number"||typeof _==="boolean")return _;try{return String(_)}catch{return"[unserializable]"}}function $$(_){let $={};for(let S of _$)$[S]=console[S].bind(console),console[S]=(...f)=>{$[S](...f),_.push({level:S,args:f.map(CS),timestamp:Date.now()})};return()=>{for(let S of _$)console[S]=$[S]}}function S$(_,$){let S=window.fetch.bind(window),f=XMLHttpRequest.prototype.open,H=XMLHttpRequest.prototype.send;function w(X){return!!$&&X.startsWith($)}window.fetch=async(X,G)=>{let B=G?.method??"GET",E=g_(typeof X==="string"?X:X instanceof URL?X.href:X.url),A=Date.now();if(w(E))return S(X,G);let V;if(G?.body&&typeof G.body==="string")V=new TextEncoder().encode(G.body).length;try{let L=await S(X,G),r=L.clone(),a;try{a=(await r.arrayBuffer()).byteLength}catch{}return _.push({method:B,url:E,status:L.status,durationMs:Date.now()-A,requestBodySize:V,responseBodySize:a,timestamp:Date.now()}),L}catch(L){throw _.push({method:B,url:E,durationMs:Date.now()-A,error:String(L),timestamp:Date.now()}),L}};let q=new WeakMap;return XMLHttpRequest.prototype.open=function(X,G,...B){let E=g_(String(G));return q.set(this,{method:X,url:E,start:0,skip:w(E)}),f.call(this,X,G,...B)},XMLHttpRequest.prototype.send=function(X){let G=q.get(this);if(G)G.start=Date.now();return this.addEventListener("loadend",()=>{if(!G||G.skip)return;_.push({method:G.method,url:G.url,status:this.status||void 0,durationMs:Date.now()-G.start,timestamp:Date.now()})}),H.call(this,X)},()=>{window.fetch=S,XMLHttpRequest.prototype.open=f,XMLHttpRequest.prototype.send=H}}function H$(_){if(_.id)return`#${_.id}`.slice(0,60);let $=Array.from(_.classList).slice(0,2).join(".");return($?`${_.tagName.toLowerCase()}.${$}`:_.tagName.toLowerCase()).slice(0,60)}function f$(_){let $=[],S=0,f=(E)=>{let A=Date.now(),V=E.target instanceof Element?H$(E.target):"unknown",L=E.target instanceof Element?(E.target.textContent??"").trim().slice(0,40):"";_.push({t:A,kind:"click",target:V,summary:L?`click on "${L}"`:`click on ${V}`,timestamp:A})};document.addEventListener("click",f,{capture:!0,passive:!0}),$.push(()=>document.removeEventListener("click",f,{capture:!0}));let H=(E)=>{if(!(E.target instanceof HTMLInputElement))return;let A=Date.now(),V=H$(E.target),L=E.target.type||"text";_.push({t:A,kind:"input",target:V,summary:`input[type=${L}] changed`,timestamp:A})};document.addEventListener("input",H,{capture:!0,passive:!0}),$.push(()=>document.removeEventListener("input",H,{capture:!0}));let w=0,q=()=>{let E=Date.now();if(E-w<500)return;w=E,_.push({t:E,kind:"scroll",summary:`scroll to (${Math.round(window.scrollX)}, ${Math.round(window.scrollY)})`,timestamp:E})};document.addEventListener("scroll",q,{capture:!0,passive:!0}),$.push(()=>document.removeEventListener("scroll",q,{capture:!0}));let X=()=>{let E=Date.now();_.push({t:E,kind:"nav",summary:`nav to ${location.pathname}${location.search}`,timestamp:E})};window.addEventListener("popstate",X),$.push(()=>window.removeEventListener("popstate",X));let G=(E)=>{let A=history[E].bind(history);return history[E]=function(...V){A(...V);let L=Date.now();_.push({t:L,kind:"nav",summary:`nav to ${location.pathname}${location.search}`,timestamp:L})},()=>{history[E]=A}};$.push(G("pushState")),$.push(G("replaceState"));let B=new MutationObserver((E)=>{let A=Date.now();if(A-S<500)return;S=A;let V=E.reduce((a,v_)=>a+v_.addedNodes.length,0),L=E.reduce((a,v_)=>a+v_.removedNodes.length,0),r=[];if(V>0)r.push(`+${V} nodes`);if(L>0)r.push(`-${L} nodes`);if(r.length===0)r.push("attr changed");_.push({t:A,kind:"mutation",summary:`DOM: ${r.join(", ")}`,timestamp:A})});return B.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0}),$.push(()=>B.disconnect()),()=>$.forEach((E)=>E())}async function q$(_,$){try{await fetch(`${_}/api/collect`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify($),keepalive:!0})}catch{}}function w$(_){if(!_.projectKey)return{capture(){},destroy(){}};let $=(_.bufferSeconds??15)*1000,S=new Q_($),f=new Q_($),H=new Q_($),w=[$$(S),S$(f,_.endpoint),f$(H)];function q(X){let G=t_(_,X,{console:S.flush(),network:f.flush().map(({timestamp:B,...E})=>E),replay:H.flush().map(({timestamp:B,...E})=>E)});q$(_.endpoint,G)}return w.push(e_(q)),{capture(X){q(hS(X))},destroy(){w.forEach((X)=>X()),S.clear(),f.clear(),H.clear()}}}function hS(_){if(_ instanceof Error)return{type:_.name||"Error",message:_.message,stack:P_(_.stack)};return{type:"UnknownError",message:String(_),stack:[]}}var IS=document.currentScript;function W$(){let _=IS??document.querySelector("script[data-project-key]"),$=_?.dataset.projectKey??"",S=_?.dataset.endpoint??"https://app.snapfail.com",f=_?.dataset.env,H=f==="dev"||f==="prod"?f:location.hostname==="localhost"||location.hostname==="127.0.0.1"?"dev":"prod";if(!$){console.warn("[snapfail] missing data-project-key attribute on <script> tag");return}window.Snapfail=w$({projectKey:$,endpoint:S,environment:H})}if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",W$);else W$();})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@snapfail/browser",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Browser SDK for snapfail — error capture, replay and transport",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"files": ["dist"],
|
|
15
15
|
"scripts": {
|
|
16
16
|
"build": "bun build src/index.ts --outdir dist --target browser --format esm --sourcemap=none && bun tsc -p tsconfig.build.json --outDir dist",
|
|
17
|
+
"build:iife": "bun build src/auto-init.ts --outfile dist/snapfail.iife.js --target browser --format iife --minify",
|
|
17
18
|
"prepublishOnly": "bun run build"
|
|
18
19
|
},
|
|
19
20
|
"dependencies": {
|