@synnaxlabs/freighter 0.9.2 → 0.9.4

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.
@@ -1,2 +1,2 @@
1
- "use strict";var La=Object.defineProperty;var $a=(r,e,t)=>e in r?La(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var le=(r,e,t)=>($a(r,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var za=Object.defineProperty,Va=(r,e,t)=>e in r?za(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,w=(r,e,t)=>(Va(r,typeof e!="symbol"?e+"":e,t),t),Y;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},r.getValidEnumValues=s=>{const a=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return r.objectValues(i)},r.objectValues=s=>r.objectKeys(s).map(function(a){return s[a]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},r.find=(s,a)=>{for(const i of s)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=n,r.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(Y||(Y={}));var xn;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(xn||(xn={}));const O=Y.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),it=r=>{switch(typeof r){case"undefined":return O.undefined;case"string":return O.string;case"number":return isNaN(r)?O.nan:O.number;case"boolean":return O.boolean;case"function":return O.function;case"bigint":return O.bigint;case"symbol":return O.symbol;case"object":return Array.isArray(r)?O.array:r===null?O.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?O.promise:typeof Map<"u"&&r instanceof Map?O.map:typeof Set<"u"&&r instanceof Set?O.set:typeof Date<"u"&&r instanceof Date?O.date:O.object;default:return O.unknown}},v=Y.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"]),Wa=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Ce extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},n={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let o=n,u=0;for(;u<i.path.length;){const d=i.path[u];u===i.path.length-1?(o[d]=o[d]||{_errors:[]},o[d]._errors.push(t(i))):o[d]=o[d]||{_errors:[]},o=o[d],u++}}};return s(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,Y.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Ce.create=r=>new Ce(r);const Lt=(r,e)=>{let t;switch(r.code){case v.invalid_type:r.received===O.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case v.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Y.jsonStringifyReplacer)}`;break;case v.unrecognized_keys:t=`Unrecognized key(s) in object: ${Y.joinValues(r.keys,", ")}`;break;case v.invalid_union:t="Invalid input";break;case v.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Y.joinValues(r.options)}`;break;case v.invalid_enum_value:t=`Invalid enum value. Expected ${Y.joinValues(r.options)}, received '${r.received}'`;break;case v.invalid_arguments:t="Invalid function arguments";break;case v.invalid_return_type:t="Invalid function return type";break;case v.invalid_date:t="Invalid date";break;case v.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:Y.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case v.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case v.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case v.custom:t="Invalid input";break;case v.invalid_intersection_types:t="Intersection results could not be merged";break;case v.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case v.not_finite:t="Number must be finite";break;default:t=e.defaultError,Y.assertNever(r)}return{message:t}};let Zs=Lt;function Fa(r){Zs=r}function Ur(){return Zs}const Mr=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],i={...s,path:a};let o="";const u=n.filter(d=>!!d).slice().reverse();for(const d of u)o=d(i,{data:e,defaultError:o}).message;return{...s,path:a,message:s.message||o}},Ka=[];function S(r,e){const t=Mr({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ur(),Lt].filter(n=>!!n)});r.common.issues.push(t)}class ge{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return P;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t)n.push({key:await s.key,value:await s.value});return ge.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return P;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}}const P=Object.freeze({status:"aborted"}),js=r=>({status:"dirty",value:r}),xe=r=>({status:"valid",value:r}),kn=r=>r.status==="aborted",On=r=>r.status==="dirty",$t=r=>r.status==="valid",Pr=r=>typeof Promise<"u"&&r instanceof Promise;var E;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(E||(E={}));class Be{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const os=(r,e)=>{if($t(e))return{success:!0,data:e.value};if(!r.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 Ce(r.common.issues);return this._error=t,this._error}}};function D(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,i)=>a.code!=="invalid_type"?{message:i.defaultError}:typeof i.data>"u"?{message:n??i.defaultError}:{message:t??i.defaultError},description:s}}class L{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)}get description(){return this._def.description}_getType(e){return it(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:it(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ge,ctx:{common:e.parent.common,data:e.data,parsedType:it(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Pr(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 s={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:it(e)},a=this._parseSync({data:e,path:s.path,parent:s});return os(s,a)}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:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:it(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(Pr(s)?s:Promise.resolve(s));return os(n,a)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue({code:v.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(u=>u?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new Ue({schema:this,typeName:Z.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Qe.create(this,this._def)}nullable(){return xt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ze.create(this,this._def)}promise(){return Rt.create(this,this._def)}or(e){return Ft.create([this,e],this._def)}and(e){return Kt.create(this,e,this._def)}transform(e){return new Ue({...D(this._def),schema:this,typeName:Z.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Ht({...D(this._def),innerType:this,defaultValue:t,typeName:Z.ZodDefault})}brand(){return new Us({typeName:Z.ZodBranded,type:this,...D(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new $r({...D(this._def),innerType:this,catchValue:t,typeName:Z.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return fr.create(this,e)}readonly(){return Vr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Ya=/^c[^\s-]{8,}$/i,qa=/^[a-z][a-z0-9]*$/,Ga=/^[0-9A-HJKMNP-TV-Z]{26}$/,Ja=/^[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,Ha=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Xa="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let mn;const Qa=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,ei=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ti=r=>r.precision?r.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}Z$`):r.precision===0?r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function ri(r,e){return!!((e==="v4"||!e)&&Qa.test(r)||(e==="v6"||!e)&&ei.test(r))}class Ae extends L{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==O.string){const s=this._getOrReturnCtx(e);return S(s,{code:v.invalid_type,expected:O.string,received:s.parsedType}),P}const t=new ge;let n;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(n=this._getOrReturnCtx(e,n),S(n,{code:v.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="max")e.data.length>s.value&&(n=this._getOrReturnCtx(e,n),S(n,{code:v.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="length"){const a=e.data.length>s.value,i=e.data.length<s.value;(a||i)&&(n=this._getOrReturnCtx(e,n),a?S(n,{code:v.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):i&&S(n,{code:v.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")Ha.test(e.data)||(n=this._getOrReturnCtx(e,n),S(n,{validation:"email",code:v.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")mn||(mn=new RegExp(Xa,"u")),mn.test(e.data)||(n=this._getOrReturnCtx(e,n),S(n,{validation:"emoji",code:v.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")Ja.test(e.data)||(n=this._getOrReturnCtx(e,n),S(n,{validation:"uuid",code:v.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")Ya.test(e.data)||(n=this._getOrReturnCtx(e,n),S(n,{validation:"cuid",code:v.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")qa.test(e.data)||(n=this._getOrReturnCtx(e,n),S(n,{validation:"cuid2",code:v.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")Ga.test(e.data)||(n=this._getOrReturnCtx(e,n),S(n,{validation:"ulid",code:v.invalid_string,message:s.message}),t.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),S(n,{validation:"url",code:v.invalid_string,message:s.message}),t.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),S(n,{validation:"regex",code:v.invalid_string,message:s.message}),t.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(n=this._getOrReturnCtx(e,n),S(n,{code:v.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),t.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(n=this._getOrReturnCtx(e,n),S(n,{code:v.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(n=this._getOrReturnCtx(e,n),S(n,{code:v.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?ti(s).test(e.data)||(n=this._getOrReturnCtx(e,n),S(n,{code:v.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="ip"?ri(e.data,s.version)||(n=this._getOrReturnCtx(e,n),S(n,{validation:"ip",code:v.invalid_string,message:s.message}),t.dirty()):Y.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:v.invalid_string,...E.errToObj(n)})}_addCheck(e){return new Ae({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...E.errToObj(e)})}url(e){return this._addCheck({kind:"url",...E.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...E.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...E.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...E.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...E.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...E.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...E.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,...E.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...E.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...E.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...E.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...E.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...E.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...E.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...E.errToObj(t)})}nonempty(e){return this.min(1,E.errToObj(e))}trim(){return new Ae({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ae({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ae({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Ae.create=r=>{var e;return new Ae({checks:[],typeName:Z.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...D(r)})};function ni(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,a=parseInt(r.toFixed(s).replace(".","")),i=parseInt(e.toFixed(s).replace(".",""));return a%i/Math.pow(10,s)}class lt extends L{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==O.number){const s=this._getOrReturnCtx(e);return S(s,{code:v.invalid_type,expected:O.number,received:s.parsedType}),P}let t;const n=new ge;for(const s of this._def.checks)s.kind==="int"?Y.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),S(t,{code:v.invalid_type,expected:"integer",received:"float",message:s.message}),n.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),S(t,{code:v.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),S(t,{code:v.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="multipleOf"?ni(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),S(t,{code:v.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),S(t,{code:v.not_finite,message:s.message}),n.dirty()):Y.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,E.toString(t))}gt(e,t){return this.setLimit("min",e,!1,E.toString(t))}lte(e,t){return this.setLimit("max",e,!0,E.toString(t))}lt(e,t){return this.setLimit("max",e,!1,E.toString(t))}setLimit(e,t,n,s){return new lt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:E.toString(s)}]})}_addCheck(e){return new lt({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:E.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:E.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:E.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:E.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:E.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:E.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:E.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:E.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:E.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Y.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}lt.create=r=>new lt({checks:[],typeName:Z.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...D(r)});class dt extends L{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==O.bigint){const s=this._getOrReturnCtx(e);return S(s,{code:v.invalid_type,expected:O.bigint,received:s.parsedType}),P}let t;const n=new ge;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),S(t,{code:v.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),S(t,{code:v.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),S(t,{code:v.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):Y.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,E.toString(t))}gt(e,t){return this.setLimit("min",e,!1,E.toString(t))}lte(e,t){return this.setLimit("max",e,!0,E.toString(t))}lt(e,t){return this.setLimit("max",e,!1,E.toString(t))}setLimit(e,t,n,s){return new dt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:E.toString(s)}]})}_addCheck(e){return new dt({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:E.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:E.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:E.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:E.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:E.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}dt.create=r=>{var e;return new dt({checks:[],typeName:Z.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...D(r)})};class zt extends L{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==O.boolean){const t=this._getOrReturnCtx(e);return S(t,{code:v.invalid_type,expected:O.boolean,received:t.parsedType}),P}return xe(e.data)}}zt.create=r=>new zt({typeName:Z.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...D(r)});class bt extends L{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==O.date){const s=this._getOrReturnCtx(e);return S(s,{code:v.invalid_type,expected:O.date,received:s.parsedType}),P}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return S(s,{code:v.invalid_date}),P}const t=new ge;let n;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(n=this._getOrReturnCtx(e,n),S(n,{code:v.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),t.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(n=this._getOrReturnCtx(e,n),S(n,{code:v.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):Y.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new bt({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:E.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:E.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}bt.create=r=>new bt({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:Z.ZodDate,...D(r)});class Dr extends L{_parse(e){if(this._getType(e)!==O.symbol){const t=this._getOrReturnCtx(e);return S(t,{code:v.invalid_type,expected:O.symbol,received:t.parsedType}),P}return xe(e.data)}}Dr.create=r=>new Dr({typeName:Z.ZodSymbol,...D(r)});class Vt extends L{_parse(e){if(this._getType(e)!==O.undefined){const t=this._getOrReturnCtx(e);return S(t,{code:v.invalid_type,expected:O.undefined,received:t.parsedType}),P}return xe(e.data)}}Vt.create=r=>new Vt({typeName:Z.ZodUndefined,...D(r)});class Wt extends L{_parse(e){if(this._getType(e)!==O.null){const t=this._getOrReturnCtx(e);return S(t,{code:v.invalid_type,expected:O.null,received:t.parsedType}),P}return xe(e.data)}}Wt.create=r=>new Wt({typeName:Z.ZodNull,...D(r)});class jt extends L{constructor(){super(...arguments),this._any=!0}_parse(e){return xe(e.data)}}jt.create=r=>new jt({typeName:Z.ZodAny,...D(r)});class vt extends L{constructor(){super(...arguments),this._unknown=!0}_parse(e){return xe(e.data)}}vt.create=r=>new vt({typeName:Z.ZodUnknown,...D(r)});class rt extends L{_parse(e){const t=this._getOrReturnCtx(e);return S(t,{code:v.invalid_type,expected:O.never,received:t.parsedType}),P}}rt.create=r=>new rt({typeName:Z.ZodNever,...D(r)});class Br extends L{_parse(e){if(this._getType(e)!==O.undefined){const t=this._getOrReturnCtx(e);return S(t,{code:v.invalid_type,expected:O.void,received:t.parsedType}),P}return xe(e.data)}}Br.create=r=>new Br({typeName:Z.ZodVoid,...D(r)});class Ze extends L{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==O.array)return S(t,{code:v.invalid_type,expected:O.array,received:t.parsedType}),P;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(S(t,{code:i?v.too_big:v.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(S(t,{code:v.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(S(t,{code:v.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new Be(t,i,t.path,o)))).then(i=>ge.mergeArray(n,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new Be(t,i,t.path,o)));return ge.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new Ze({...this._def,minLength:{value:e,message:E.toString(t)}})}max(e,t){return new Ze({...this._def,maxLength:{value:e,message:E.toString(t)}})}length(e,t){return new Ze({...this._def,exactLength:{value:e,message:E.toString(t)}})}nonempty(e){return this.min(1,e)}}Ze.create=(r,e)=>new Ze({type:r,minLength:null,maxLength:null,exactLength:null,typeName:Z.ZodArray,...D(e)});function At(r){if(r instanceof ae){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=Qe.create(At(n))}return new ae({...r._def,shape:()=>e})}else return r instanceof Ze?new Ze({...r._def,type:At(r.element)}):r instanceof Qe?Qe.create(At(r.unwrap())):r instanceof xt?xt.create(At(r.unwrap())):r instanceof Le?Le.create(r.items.map(e=>At(e))):r}class ae extends L{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=Y.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==O.object){const u=this._getOrReturnCtx(e);return S(u,{code:v.invalid_type,expected:O.object,received:u.parsedType}),P}const{status:t,ctx:n}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof rt&&this._def.unknownKeys==="strip"))for(const u in n.data)a.includes(u)||i.push(u);const o=[];for(const u of a){const d=s[u],p=n.data[u];o.push({key:{status:"valid",value:u},value:d._parse(new Be(n,p,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof rt){const u=this._def.unknownKeys;if(u==="passthrough")for(const d of i)o.push({key:{status:"valid",value:d},value:{status:"valid",value:n.data[d]}});else if(u==="strict")i.length>0&&(S(n,{code:v.unrecognized_keys,keys:i}),t.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const d of i){const p=n.data[d];o.push({key:{status:"valid",value:d},value:u._parse(new Be(n,p,n.path,d)),alwaysSet:d in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const u=[];for(const d of o){const p=await d.key;u.push({key:p,value:await d.value,alwaysSet:d.alwaysSet})}return u}).then(u=>ge.mergeObjectSync(t,u)):ge.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return E.errToObj,new ae({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,a,i,o;const u=(i=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,n).message)!==null&&i!==void 0?i:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=E.errToObj(e).message)!==null&&o!==void 0?o:u}:{message:u}}}:{}})}strip(){return new ae({...this._def,unknownKeys:"strip"})}passthrough(){return new ae({...this._def,unknownKeys:"passthrough"})}extend(e){return new ae({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ae({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Z.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ae({...this._def,catchall:e})}pick(e){const t={};return Y.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new ae({...this._def,shape:()=>t})}omit(e){const t={};return Y.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new ae({...this._def,shape:()=>t})}deepPartial(){return At(this)}partial(e){const t={};return Y.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new ae({...this._def,shape:()=>t})}required(e){const t={};return Y.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof Qe;)s=s._def.innerType;t[n]=s}}),new ae({...this._def,shape:()=>t})}keyof(){return Rs(Y.objectKeys(this.shape))}}ae.create=(r,e)=>new ae({shape:()=>r,unknownKeys:"strip",catchall:rt.create(),typeName:Z.ZodObject,...D(e)});ae.strictCreate=(r,e)=>new ae({shape:()=>r,unknownKeys:"strict",catchall:rt.create(),typeName:Z.ZodObject,...D(e)});ae.lazycreate=(r,e)=>new ae({shape:r,unknownKeys:"strip",catchall:rt.create(),typeName:Z.ZodObject,...D(e)});class Ft extends L{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new Ce(o.ctx.common.issues));return S(t,{code:v.invalid_union,unionErrors:i}),P}if(t.common.async)return Promise.all(n.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let a;const i=[];for(const u of n){const d={...t,common:{...t.common,issues:[]},parent:null},p=u._parseSync({data:t.data,path:t.path,parent:d});if(p.status==="valid")return p;p.status==="dirty"&&!a&&(a={result:p,ctx:d}),d.common.issues.length&&i.push(d.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(u=>new Ce(u));return S(t,{code:v.invalid_union,unionErrors:o}),P}}get options(){return this._def.options}}Ft.create=(r,e)=>new Ft({options:r,typeName:Z.ZodUnion,...D(e)});const kr=r=>r instanceof qt?kr(r.schema):r instanceof Ue?kr(r.innerType()):r instanceof Gt?[r.value]:r instanceof ht?r.options:r instanceof Jt?Object.keys(r.enum):r instanceof Ht?kr(r._def.innerType):r instanceof Vt?[void 0]:r instanceof Wt?[null]:null;class tn extends L{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==O.object)return S(t,{code:v.invalid_type,expected:O.object,received:t.parsedType}),P;const n=this.discriminator,s=t.data[n],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(S(t,{code:v.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),P)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const a of t){const i=kr(a.shape[e]);if(!i)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new tn({typeName:Z.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...D(n)})}}function Tn(r,e){const t=it(r),n=it(e);if(r===e)return{valid:!0,data:r};if(t===O.object&&n===O.object){const s=Y.objectKeys(e),a=Y.objectKeys(r).filter(o=>s.indexOf(o)!==-1),i={...r,...e};for(const o of a){const u=Tn(r[o],e[o]);if(!u.valid)return{valid:!1};i[o]=u.data}return{valid:!0,data:i}}else if(t===O.array&&n===O.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<r.length;a++){const i=r[a],o=e[a],u=Tn(i,o);if(!u.valid)return{valid:!1};s.push(u.data)}return{valid:!0,data:s}}else return t===O.date&&n===O.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class Kt extends L{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(kn(a)||kn(i))return P;const o=Tn(a.value,i.value);return o.valid?((On(a)||On(i))&&t.dirty(),{status:t.value,value:o.data}):(S(n,{code:v.invalid_intersection_types}),P)};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(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}Kt.create=(r,e,t)=>new Kt({left:r,right:e,typeName:Z.ZodIntersection,...D(t)});class Le extends L{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==O.array)return S(n,{code:v.invalid_type,expected:O.array,received:n.parsedType}),P;if(n.data.length<this._def.items.length)return S(n,{code:v.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),P;!this._def.rest&&n.data.length>this._def.items.length&&(S(n,{code:v.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((a,i)=>{const o=this._def.items[i]||this._def.rest;return o?o._parse(new Be(n,a,n.path,i)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>ge.mergeArray(t,a)):ge.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new Le({...this._def,rest:e})}}Le.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Le({items:r,typeName:Z.ZodTuple,rest:null,...D(e)})};class Yt extends L{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!==O.object)return S(n,{code:v.invalid_type,expected:O.object,received:n.parsedType}),P;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)s.push({key:a._parse(new Be(n,o,n.path,o)),value:i._parse(new Be(n,n.data[o],n.path,o))});return n.common.async?ge.mergeObjectAsync(t,s):ge.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof L?new Yt({keyType:e,valueType:t,typeName:Z.ZodRecord,...D(n)}):new Yt({keyType:Ae.create(),valueType:e,typeName:Z.ZodRecord,...D(t)})}}class Lr extends L{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!==O.map)return S(n,{code:v.invalid_type,expected:O.map,received:n.parsedType}),P;const s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,u],d)=>({key:s._parse(new Be(n,o,n.path,[d,"key"])),value:a._parse(new Be(n,u,n.path,[d,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const u of i){const d=await u.key,p=await u.value;if(d.status==="aborted"||p.status==="aborted")return P;(d.status==="dirty"||p.status==="dirty")&&t.dirty(),o.set(d.value,p.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const u of i){const d=u.key,p=u.value;if(d.status==="aborted"||p.status==="aborted")return P;(d.status==="dirty"||p.status==="dirty")&&t.dirty(),o.set(d.value,p.value)}return{status:t.value,value:o}}}}Lr.create=(r,e,t)=>new Lr({valueType:e,keyType:r,typeName:Z.ZodMap,...D(t)});class wt extends L{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==O.set)return S(n,{code:v.invalid_type,expected:O.set,received:n.parsedType}),P;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(S(n,{code:v.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(S(n,{code:v.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function i(u){const d=new Set;for(const p of u){if(p.status==="aborted")return P;p.status==="dirty"&&t.dirty(),d.add(p.value)}return{status:t.value,value:d}}const o=[...n.data.values()].map((u,d)=>a._parse(new Be(n,u,n.path,d)));return n.common.async?Promise.all(o).then(u=>i(u)):i(o)}min(e,t){return new wt({...this._def,minSize:{value:e,message:E.toString(t)}})}max(e,t){return new wt({...this._def,maxSize:{value:e,message:E.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}wt.create=(r,e)=>new wt({valueType:r,minSize:null,maxSize:null,typeName:Z.ZodSet,...D(e)});class Ct extends L{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==O.function)return S(t,{code:v.invalid_type,expected:O.function,received:t.parsedType}),P;function n(o,u){return Mr({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ur(),Lt].filter(d=>!!d),issueData:{code:v.invalid_arguments,argumentsError:u}})}function s(o,u){return Mr({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ur(),Lt].filter(d=>!!d),issueData:{code:v.invalid_return_type,returnTypeError:u}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Rt){const o=this;return xe(async function(...u){const d=new Ce([]),p=await o._def.args.parseAsync(u,a).catch(J=>{throw d.addIssue(n(u,J)),d}),A=await Reflect.apply(i,this,p);return await o._def.returns._def.type.parseAsync(A,a).catch(J=>{throw d.addIssue(s(A,J)),d})})}else{const o=this;return xe(function(...u){const d=o._def.args.safeParse(u,a);if(!d.success)throw new Ce([n(u,d.error)]);const p=Reflect.apply(i,this,d.data),A=o._def.returns.safeParse(p,a);if(!A.success)throw new Ce([s(p,A.error)]);return A.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ct({...this._def,args:Le.create(e).rest(vt.create())})}returns(e){return new Ct({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Ct({args:e||Le.create([]).rest(vt.create()),returns:t||vt.create(),typeName:Z.ZodFunction,...D(n)})}}class qt extends L{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})}}qt.create=(r,e)=>new qt({getter:r,typeName:Z.ZodLazy,...D(e)});class Gt extends L{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return S(t,{received:t.data,code:v.invalid_literal,expected:this._def.value}),P}return{status:"valid",value:e.data}}get value(){return this._def.value}}Gt.create=(r,e)=>new Gt({value:r,typeName:Z.ZodLiteral,...D(e)});function Rs(r,e){return new ht({values:r,typeName:Z.ZodEnum,...D(e)})}class ht extends L{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return S(t,{expected:Y.joinValues(n),received:t.parsedType,code:v.invalid_type}),P}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),n=this._def.values;return S(t,{received:t.data,code:v.invalid_enum_value,options:n}),P}return xe(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return ht.create(e)}exclude(e){return ht.create(this.options.filter(t=>!e.includes(t)))}}ht.create=Rs;class Jt extends L{_parse(e){const t=Y.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==O.string&&n.parsedType!==O.number){const s=Y.objectValues(t);return S(n,{expected:Y.joinValues(s),received:n.parsedType,code:v.invalid_type}),P}if(t.indexOf(e.data)===-1){const s=Y.objectValues(t);return S(n,{received:n.data,code:v.invalid_enum_value,options:s}),P}return xe(e.data)}get enum(){return this._def.values}}Jt.create=(r,e)=>new Jt({values:r,typeName:Z.ZodNativeEnum,...D(e)});class Rt extends L{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==O.promise&&t.common.async===!1)return S(t,{code:v.invalid_type,expected:O.promise,received:t.parsedType}),P;const n=t.parsedType===O.promise?t.data:Promise.resolve(t.data);return xe(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Rt.create=(r,e)=>new Rt({type:r,typeName:Z.ZodPromise,...D(e)});class Ue extends L{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Z.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{S(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(n.data,a);return n.common.issues.length?{status:"dirty",value:n.data}:n.common.async?Promise.resolve(i).then(o=>this._def.schema._parseAsync({data:o,path:n.path,parent:n})):this._def.schema._parseSync({data:i,path:n.path,parent:n})}if(s.type==="refinement"){const i=o=>{const u=s.refinement(o,a);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?P:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?P:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!$t(i))return i;const o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>$t(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);Y.assertNever(s)}}Ue.create=(r,e,t)=>new Ue({schema:r,typeName:Z.ZodEffects,effect:e,...D(t)});Ue.createWithPreprocess=(r,e,t)=>new Ue({schema:e,effect:{type:"preprocess",transform:r},typeName:Z.ZodEffects,...D(t)});class Qe extends L{_parse(e){return this._getType(e)===O.undefined?xe(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Qe.create=(r,e)=>new Qe({innerType:r,typeName:Z.ZodOptional,...D(e)});class xt extends L{_parse(e){return this._getType(e)===O.null?xe(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}xt.create=(r,e)=>new xt({innerType:r,typeName:Z.ZodNullable,...D(e)});class Ht extends L{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===O.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Ht.create=(r,e)=>new Ht({innerType:r,typeName:Z.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...D(e)});class $r extends L{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Pr(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Ce(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Ce(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}$r.create=(r,e)=>new $r({innerType:r,typeName:Z.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...D(e)});class zr extends L{_parse(e){if(this._getType(e)!==O.nan){const t=this._getOrReturnCtx(e);return S(t,{code:v.invalid_type,expected:O.nan,received:t.parsedType}),P}return{status:"valid",value:e.data}}}zr.create=r=>new zr({typeName:Z.ZodNaN,...D(r)});const si=Symbol("zod_brand");class Us extends L{_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}}class fr extends L{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?P:s.status==="dirty"?(t.dirty(),js(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?P:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new fr({in:e,out:t,typeName:Z.ZodPipeline})}}class Vr extends L{_parse(e){const t=this._def.innerType._parse(e);return $t(t)&&(t.value=Object.freeze(t.value)),t}}Vr.create=(r,e)=>new Vr({innerType:r,typeName:Z.ZodReadonly,...D(e)});const Ms=(r,e={},t)=>r?jt.create().superRefine((n,s)=>{var a,i;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,d=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...d,fatal:u})}}):jt.create(),ai={object:ae.lazycreate};var Z;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(Z||(Z={}));const ii=(r,e={message:`Input not instance of ${r.name}`})=>Ms(t=>t instanceof r,e),Ps=Ae.create,Ds=lt.create,oi=zr.create,ui=dt.create,Bs=zt.create,ci=bt.create,li=Dr.create,di=Vt.create,hi=Wt.create,fi=jt.create,pi=vt.create,mi=rt.create,yi=Br.create,gi=Ze.create,vi=ae.create,_i=ae.strictCreate,bi=Ft.create,wi=tn.create,xi=Kt.create,ki=Le.create,Oi=Yt.create,Ti=Lr.create,Si=wt.create,Ni=Ct.create,Ii=qt.create,Ai=Gt.create,Ei=ht.create,Ci=Jt.create,Zi=Rt.create,us=Ue.create,ji=Qe.create,Ri=xt.create,Ui=Ue.createWithPreprocess,Mi=fr.create,Pi=()=>Ps().optional(),Di=()=>Ds().optional(),Bi=()=>Bs().optional(),Li={string:r=>Ae.create({...r,coerce:!0}),number:r=>lt.create({...r,coerce:!0}),boolean:r=>zt.create({...r,coerce:!0}),bigint:r=>dt.create({...r,coerce:!0}),date:r=>bt.create({...r,coerce:!0})},$i=P;var m=Object.freeze({__proto__:null,defaultErrorMap:Lt,setErrorMap:Fa,getErrorMap:Ur,makeIssue:Mr,EMPTY_PATH:Ka,addIssueToContext:S,ParseStatus:ge,INVALID:P,DIRTY:js,OK:xe,isAborted:kn,isDirty:On,isValid:$t,isAsync:Pr,get util(){return Y},get objectUtil(){return xn},ZodParsedType:O,getParsedType:it,ZodType:L,ZodString:Ae,ZodNumber:lt,ZodBigInt:dt,ZodBoolean:zt,ZodDate:bt,ZodSymbol:Dr,ZodUndefined:Vt,ZodNull:Wt,ZodAny:jt,ZodUnknown:vt,ZodNever:rt,ZodVoid:Br,ZodArray:Ze,ZodObject:ae,ZodUnion:Ft,ZodDiscriminatedUnion:tn,ZodIntersection:Kt,ZodTuple:Le,ZodRecord:Yt,ZodMap:Lr,ZodSet:wt,ZodFunction:Ct,ZodLazy:qt,ZodLiteral:Gt,ZodEnum:ht,ZodNativeEnum:Jt,ZodPromise:Rt,ZodEffects:Ue,ZodTransformer:Ue,ZodOptional:Qe,ZodNullable:xt,ZodDefault:Ht,ZodCatch:$r,ZodNaN:zr,BRAND:si,ZodBranded:Us,ZodPipeline:fr,ZodReadonly:Vr,custom:Ms,Schema:L,ZodSchema:L,late:ai,get ZodFirstPartyTypeKind(){return Z},coerce:Li,any:fi,array:gi,bigint:ui,boolean:Bs,date:ci,discriminatedUnion:wi,effect:us,enum:Ei,function:Ni,instanceof:ii,intersection:xi,lazy:Ii,literal:Ai,map:Ti,nan:oi,nativeEnum:Ci,never:mi,null:hi,nullable:Ri,number:Ds,object:vi,oboolean:Bi,onumber:Di,optional:ji,ostring:Pi,pipeline:Mi,preprocess:Ui,promise:Zi,record:Oi,set:Si,strictObject:_i,string:Ps,symbol:li,transformer:us,tuple:ki,undefined:di,union:bi,unknown:pi,void:yi,NEVER:$i,ZodIssueCode:v,quotelessJson:Wa,ZodError:Ce});const Pn=m.tuple([m.number(),m.number()]),Ls=m.object({width:m.number(),height:m.number()}),zi=m.object({signedWidth:m.number(),signedHeight:m.number()}),Vi=["width","height"];m.enum(Vi);const Wi=["start","center","end"],Fi=["signedWidth","signedHeight"];m.enum(Fi);const Wr=m.object({x:m.number(),y:m.number()}),Ki=m.object({clientX:m.number(),clientY:m.number()}),Yi=["x","y"],$s=m.enum(Yi),zs=["top","right","bottom","left"];m.enum(zs);const qi=["left","right"],Vs=m.enum(qi),Gi=["top","bottom"],Ws=m.enum(Gi),Fs=["center"],cs=m.enum(Fs),Ji=[...zs,...Fs],Ks=m.enum(Ji);m.enum(Wi);const Hi=["first","last"];m.enum(Hi);const Xi=m.object({lower:m.number(),upper:m.number()});m.union([Xi,Pn]);m.union([$s,Ks]);m.union([$s,Ks,m.instanceof(String)]);const yn=(r,e)=>{const t={lower:0,upper:0};return typeof r=="number"?e!=null?(t.lower=r,t.upper=e):(t.lower=0,t.upper=r):Array.isArray(r)?[t.lower,t.upper]=r:(t.lower=r.lower,t.upper=r.upper),Qi(t)},Qi=r=>r.lower>r.upper?{lower:r.upper,upper:r.lower}:r;var Ie=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},W={},rn={};Object.defineProperty(rn,"__esModule",{value:!0});function eo(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"$"+n}).toLowerCase().replace(/(\$)(\w)/g,function(e,t,n){return n.toUpperCase()}):""}rn.default=eo;var nn={};Object.defineProperty(nn,"__esModule",{value:!0});function to(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"_").toLowerCase():""}nn.default=to;var sn={};Object.defineProperty(sn,"__esModule",{value:!0});function ro(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"$").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"$"+n}).toLowerCase().replace(/(\$)(\w?)/g,function(e,t,n){return n.toUpperCase()}):""}sn.default=ro;var Dn={};Object.defineProperty(Dn,"__esModule",{value:!0});function no(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,".").toLowerCase():""}Dn.default=no;var Bn={};Object.defineProperty(Bn,"__esModule",{value:!0});function so(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"/").toLowerCase():""}Bn.default=so;var Ln={};Object.defineProperty(Ln,"__esModule",{value:!0});function ao(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase():""}Ln.default=ao;var $n={};Object.defineProperty($n,"__esModule",{value:!0});function io(r){if(r===void 0&&(r=""),!r)return"";var e=String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(t,n,s){return n+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase();return e.charAt(0).toUpperCase()+e.slice(1)}$n.default=io;var zn={};Object.defineProperty(zn,"__esModule",{value:!0});function oo(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase().replace(/( ?)(\w+)( ?)/g,function(e,t,n,s){return t+n.charAt(0).toUpperCase()+n.slice(1)+s}):""}zn.default=oo;var an={};Object.defineProperty(an,"__esModule",{value:!0});function uo(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"-").toLowerCase():""}an.default=uo;var Vn={},St={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.belongToTypes=r.isValidObject=r.isArrayObject=r.validateOptions=r.DefaultOption=void 0,r.DefaultOption={recursive:!1,recursiveInArray:!1,keepTypesOnRecursion:[]},r.validateOptions=function(e){return e===void 0&&(e=r.DefaultOption),e.recursive==null?e=r.DefaultOption:e.recursiveInArray==null&&(e.recursiveInArray=!1),e},r.isArrayObject=function(e){return e!=null&&Array.isArray(e)},r.isValidObject=function(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)},r.belongToTypes=function(e,t){return(t||[]).some(function(n){return e instanceof n})}})(St);var co=Ie&&Ie.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(Vn,"__esModule",{value:!0});var We=St;function Or(r,e){if(e===void 0&&(e=We.DefaultOption),!We.isValidObject(r))return null;e=We.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=n.toLowerCase();e.recursive&&(We.isValidObject(s)?We.belongToTypes(s,e.keepTypesOnRecursion)||(s=Or(s,e)):e.recursiveInArray&&We.isArrayObject(s)&&(s=co(s).map(function(i){var o=i;if(We.isValidObject(i))We.belongToTypes(o,e.keepTypesOnRecursion)||(o=Or(i,e));else if(We.isArrayObject(i)){var u=Or({key:i},e);o=u.key}return o}))),t[a]=s}),t}Vn.default=Or;var Wn={},lo=Ie&&Ie.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(Wn,"__esModule",{value:!0});var Fe=St;function Tr(r,e){if(e===void 0&&(e=Fe.DefaultOption),!Fe.isValidObject(r))return null;e=Fe.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=n.toUpperCase();e.recursive&&(Fe.isValidObject(s)?Fe.belongToTypes(s,e.keepTypesOnRecursion)||(s=Tr(s,e)):e.recursiveInArray&&Fe.isArrayObject(s)&&(s=lo(s).map(function(i){var o=i;if(Fe.isValidObject(i))Fe.belongToTypes(o,e.keepTypesOnRecursion)||(o=Tr(i,e));else if(Fe.isArrayObject(i)){var u=Tr({key:i},e);o=u.key}return o}))),t[a]=s}),t}Wn.default=Tr;var Fn={},ho=Ie&&Ie.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(Fn,"__esModule",{value:!0});var Ke=St,fo=rn;function Sr(r,e){if(e===void 0&&(e=Ke.DefaultOption),!Ke.isValidObject(r))return null;e=Ke.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=fo.default(n);e.recursive&&(Ke.isValidObject(s)?Ke.belongToTypes(s,e.keepTypesOnRecursion)||(s=Sr(s,e)):e.recursiveInArray&&Ke.isArrayObject(s)&&(s=ho(s).map(function(i){var o=i;if(Ke.isValidObject(i))Ke.belongToTypes(o,e.keepTypesOnRecursion)||(o=Sr(i,e));else if(Ke.isArrayObject(i)){var u=Sr({key:i},e);o=u.key}return o}))),t[a]=s}),t}Fn.default=Sr;var Kn={},po=Ie&&Ie.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(Kn,"__esModule",{value:!0});var Ye=St,mo=nn;function Nr(r,e){if(e===void 0&&(e=Ye.DefaultOption),!Ye.isValidObject(r))return null;e=Ye.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=mo.default(n);e.recursive&&(Ye.isValidObject(s)?Ye.belongToTypes(s,e.keepTypesOnRecursion)||(s=Nr(s,e)):e.recursiveInArray&&Ye.isArrayObject(s)&&(s=po(s).map(function(i){var o=i;if(Ye.isValidObject(i))Ye.belongToTypes(o,e.keepTypesOnRecursion)||(o=Nr(i,e));else if(Ye.isArrayObject(i)){var u=Nr({key:i},e);o=u.key}return o}))),t[a]=s}),t}Kn.default=Nr;var Yn={},yo=Ie&&Ie.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(Yn,"__esModule",{value:!0});var qe=St,go=sn;function Ir(r,e){if(e===void 0&&(e=qe.DefaultOption),!qe.isValidObject(r))return null;e=qe.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=go.default(n);e.recursive&&(qe.isValidObject(s)?qe.belongToTypes(s,e.keepTypesOnRecursion)||(s=Ir(s,e)):e.recursiveInArray&&qe.isArrayObject(s)&&(s=yo(s).map(function(i){var o=i;if(qe.isValidObject(i))qe.belongToTypes(o,e.keepTypesOnRecursion)||(o=Ir(i,e));else if(qe.isArrayObject(i)){var u=Ir({key:i},e);o=u.key}return o}))),t[a]=s}),t}Yn.default=Ir;var qn={},vo=Ie&&Ie.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(qn,"__esModule",{value:!0});var Ge=St,_o=an;function Ar(r,e){if(e===void 0&&(e=Ge.DefaultOption),!Ge.isValidObject(r))return null;e=Ge.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=_o.default(n);e.recursive&&(Ge.isValidObject(s)?Ge.belongToTypes(s,e.keepTypesOnRecursion)||(s=Ar(s,e)):e.recursiveInArray&&Ge.isArrayObject(s)&&(s=vo(s).map(function(i){var o=i;if(Ge.isValidObject(i))Ge.belongToTypes(o,e.keepTypesOnRecursion)||(o=Ar(i,e));else if(Ge.isArrayObject(i)){var u=Ar({key:i},e);o=u.key}return o}))),t[a]=s}),t}qn.default=Ar;Object.defineProperty(W,"__esModule",{value:!0});W.kebabKeys=W.pascalKeys=W.snakeKeys=W.camelKeys=W.upperKeys=W.lowerKeys=W.toLowerCase=W.toUpperCase=W.toKebabCase=W.toHeaderCase=W.toSentenceCase=W.toTextCase=W.toPathCase=W.toDotCase=W.toPascalCase=W.toSnakeCase=W.toCamelCase=void 0;var Ys=rn;W.toCamelCase=Ys.default;var qs=nn;W.toSnakeCase=qs.default;var Gs=sn;W.toPascalCase=Gs.default;var Js=Dn;W.toDotCase=Js.default;var Hs=Bn;W.toPathCase=Hs.default;var Xs=Ln;W.toTextCase=Xs.default;var Qs=$n;W.toSentenceCase=Qs.default;var ea=zn;W.toHeaderCase=ea.default;var ta=an;W.toKebabCase=ta.default;var ra=Vn;W.lowerKeys=ra.default;var na=Wn;W.upperKeys=na.default;var sa=Fn;W.camelKeys=sa.default;var aa=Kn;W.snakeKeys=aa.default;var ia=Yn;W.pascalKeys=ia.default;var oa=qn;W.kebabKeys=oa.default;var ua=function(r){return String(r||"").toLowerCase()};W.toLowerCase=ua;var ca=function(r){return String(r||"").toUpperCase()};W.toUpperCase=ca;var bo={toCamelCase:Ys.default,toSnakeCase:qs.default,toPascalCase:Gs.default,toDotCase:Js.default,toPathCase:Hs.default,toTextCase:Xs.default,toSentenceCase:Qs.default,toHeaderCase:ea.default,toKebabCase:ta.default,toUpperCase:ca,toLowerCase:ua,lowerKeys:ra.default,upperKeys:na.default,camelKeys:sa.default,snakeKeys:aa.default,pascalKeys:ia.default,kebabKeys:oa.default};W.default=bo;var la=W;const da={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},wo=r=>la.snakeKeys(r,da),xo=r=>la.camelKeys(r,da);var Ut;(r=>{r.toSnake=wo,r.toCamel=xo,r.capitalize=e=>e[0].toUpperCase()+e.slice(1)})(Ut||(Ut={}));m.object({x:Vs.or(cs),y:Ws.or(cs)});const ko=m.object({x:Vs,y:Ws}),Oo=Object.freeze({x:"left",y:"top"}),To=(r,e)=>r.x===e.x&&r.y===e.y,ls=m.union([m.number(),Wr,Pn,Ls,zi,Ki]),So=(r,e)=>{if(typeof r=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return r==="x"?{x:e,y:0}:{x:0,y:e}}return typeof r=="number"?{x:r,y:e??r}:Array.isArray(r)?{x:r[0],y:r[1]}:"signedWidth"in r?{x:r.signedWidth,y:r.signedHeight}:"clientX"in r?{x:r.clientX,y:r.clientY}:"width"in r?{x:r.width,y:r.height}:{x:r.x,y:r.y}},ds={x:0,y:0},_r=m.union([m.number(),m.string()]);m.object({top:_r,left:_r,width:_r,height:_r});m.object({left:m.number(),top:m.number(),right:m.number(),bottom:m.number()});m.object({one:Wr,two:Wr,root:ko});const Gn=(r,e,t=0,n=0,s)=>{const a={one:{...ds},two:{...ds},root:s??Oo};if(typeof r=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:r,y:e},a.two={x:a.one.x+t,y:a.one.y+n},a}return"one"in r&&"two"in r&&"root"in r?{...r,root:s??r.root}:("getBoundingClientRect"in r&&(r=r.getBoundingClientRect()),"left"in r?(a.one={x:r.left,y:r.top},a.two={x:r.right,y:r.bottom},a):(a.one=r,e==null?a.two={x:a.one.x+t,y:a.one.y+n}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+t}:"width"in e?a.two={x:a.one.x+e.width,y:a.one.y+e.height}:"signedWidth"in e?a.two={x:a.one.x+e.signedWidth,y:a.one.y+e.signedHeight}:a.two=e,a))},gn=r=>{const e=Gn(r);return{lower:e.one.x,upper:e.two.x}},vn=r=>{const e=Gn(r);return{lower:e.one.y,upper:e.two.y}},No=r=>typeof r!="object"||r==null?!1:"one"in r&&"two"in r&&"root"in r,Io=m.object({signedWidth:m.number(),signedHeight:m.number()});m.union([Ls,Io,Wr,Pn]);const Ao=(r,e,t)=>(e!=null&&(r=Math.max(r,e)),t!=null&&(r=Math.min(r,t)),r);m.object({offset:ls,scale:ls});const Eo=r=>(e,t,n,s)=>t==="dimension"?[e,n]:[e,s?n-r:n+r],Co=r=>(e,t,n,s)=>[e,s?n/r:n*r],Zo=r=>(e,t,n)=>{if(e===null)return[r,n];const{lower:s,upper:a}=e,{lower:i,upper:o}=r,u=a-s,d=o-i;if(t==="dimension")return[r,n*(d/u)];const p=(n-s)*(d/u)+i;return[r,p]},jo=r=>(e,t,n)=>[r,n],Ro=()=>(r,e,t)=>{if(r===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[r,t];const{lower:n,upper:s}=r;return[r,s-(t-n)]},Uo=r=>(e,t,n)=>{const{lower:s,upper:a}=r;return n=Ao(n,s,a),[e,n]},Sn=class Bt{constructor(){w(this,"ops",[]),w(this,"currBounds",null),w(this,"currType",null),w(this,"reversed",!1),this.ops=[]}static translate(e){return new Bt().translate(e)}static magnify(e){return new Bt().magnify(e)}static scale(e,t){return new Bt().scale(e,t)}translate(e){const t=this.new(),n=Eo(e);return n.type="translate",t.ops.push(n),t}magnify(e){const t=this.new(),n=Co(e);return n.type="magnify",t.ops.push(n),t}scale(e,t){const n=yn(e,t),s=this.new(),a=Zo(n);return a.type="scale",s.ops.push(a),s}clamp(e,t){const n=yn(e,t),s=this.new(),a=Uo(n);return a.type="clamp",s.ops.push(a),s}reBound(e,t){const n=yn(e,t),s=this.new(),a=jo(n);return a.type="re-bound",s.ops.push(a),s}invert(){const e=Ro();e.type="invert";const t=this.new();return t.ops.push(e),t}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new Bt;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([n,s],a)=>a(n,e,s,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((n,s)=>{if(n.type==="scale"||t.some(([i,o])=>s>=i&&s<=o))return;const a=e.ops.findIndex((i,o)=>i.type==="scale"&&o>s);a!==-1&&t.push([s,a])}),t.forEach(([n,s])=>{const a=e.ops.slice(n,s);a.unshift(e.ops[s]),e.ops.splice(n,s-n+1,...a)}),e.reversed=!e.reversed,e}};w(Sn,"IDENTITY",new Sn);let hs=Sn;const fs=class Je{constructor(e=new hs,t=new hs,n=null){w(this,"x"),w(this,"y"),w(this,"currRoot"),this.x=e,this.y=t,this.currRoot=n}static translate(e,t){return new Je().translate(e,t)}static translateX(e){return new Je().translateX(e)}static translateY(e){return new Je().translateY(e)}static clamp(e){return new Je().clamp(e)}static magnify(e){return new Je().magnify(e)}static scale(e){return new Je().scale(e)}static reBound(e){return new Je().reBound(e)}translate(e,t){const n=So(e,t),s=this.copy();return s.x=this.x.translate(n.x),s.y=this.y.translate(n.y),s}translateX(e){const t=this.copy();return t.x=this.x.translate(e),t}translateY(e){const t=this.copy();return t.y=this.y.translate(e),t}magnify(e){const t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){const t=this.copy();if(No(e)){const n=this.currRoot;return t.currRoot=e.root,n!=null&&!To(n,e.root)&&(n.x!==e.root.x&&(t.x=t.x.invert()),n.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(gn(e)),t.y=t.y.scale(vn(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){const t=this.copy();return t.x=this.x.reBound(gn(e)),t.y=this.y.reBound(vn(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(gn(e)),t.y=this.y.clamp(vn(e)),t}copy(){const e=new Je;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}box(e){return Gn(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};w(fs,"IDENTITY",new fs);const ha=(r,e)=>{const t=new Oe(e);if(![we.DAY,we.HOUR,we.MINUTE,we.SECOND,we.MILLISECOND,we.MICROSECOND,we.NANOSECOND].some(s=>s.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=r.valueOf()%t.valueOf();return r instanceof Oe?new Oe(n):new we(n)},Q=class M{constructor(e,t="UTC"){if(w(this,"value"),w(this,"encodeValue",!0),e==null)this.value=M.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*M.MILLISECOND.valueOf();else if(typeof e=="string")this.value=M.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=M.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(n=M.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=M.MAX:e=M.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,t=1,n=1]){const s=new Date(e,t-1,n,0,0,0,0);return new M(BigInt(s.getTime())*M.MILLISECOND.valueOf()).truncate(M.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[n,s,a]=e.split(":");let i="00",o="00";a!=null&&([i,o]=a.split("."));let u=M.hours(parseInt(n??"00",10)).add(M.minutes(parseInt(s??"00",10))).add(M.seconds(parseInt(i??"00",10))).add(M.milliseconds(parseInt(o??"00",10)));return t==="local"&&(u=u.add(M.utcOffset)),u.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return M.parseTimeString(e,t);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new M(BigInt(n.getTime())*M.MILLISECOND.valueOf(),t).valueOf()}fString(e="ISO",t="UTC"){switch(e){case"ISODate":return this.toISOString(t).slice(0,10);case"ISOTime":return this.toISOString(t).slice(11,23);case"time":return this.timeString(!1,t);case"preciseTime":return this.timeString(!0,t);case"date":return this.dateString(t);case"preciseDate":return`${this.dateString(t)} ${this.timeString(!0,t)}`;case"dateTime":return`${this.dateString(t)} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(M.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const n=this.toISOString(t);return e?n.slice(11,23):n.slice(11,19)}dateString(e="UTC"){const t=this.date(),n=t.toLocaleString("default",{month:"short"}),s=t.toLocaleString("default",{day:"numeric"});return`${n} ${s}`}static get utcOffset(){return new we(BigInt(new Date().getTimezoneOffset())*M.MINUTE.valueOf())}static since(e){return new M().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new M(e).valueOf()}span(e){return this.range(e).span}range(e){return new Mo(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new M(e).valueOf()}afterEq(e){return this.valueOf()>=new M(e).valueOf()}before(e){return this.valueOf()<new M(e).valueOf()}beforeEq(e){return this.valueOf()<=new M(e).valueOf()}add(e){return new M(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new M(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf()/M.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return ha(this,e)}get isToday(){return this.truncate(we.DAY).equals(M.now().truncate(we.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new M(new Date)}static max(...e){let t=M.MIN;for(const n of e){const s=new M(n);s.after(t)&&(t=s)}return t}static min(...e){let t=M.MAX;for(const n of e){const s=new M(n);s.before(t)&&(t=s)}return t}static nanoseconds(e){return new M(e)}static microseconds(e){return M.nanoseconds(e*1e3)}static milliseconds(e){return M.microseconds(e*1e3)}static seconds(e){return M.milliseconds(e*1e3)}static minutes(e){return M.seconds(e*60)}static hours(e){return M.minutes(e*60)}static days(e){return M.hours(e*24)}};w(Q,"NANOSECOND",Q.nanoseconds(1)),w(Q,"MICROSECOND",Q.microseconds(1)),w(Q,"MILLISECOND",Q.milliseconds(1)),w(Q,"SECOND",Q.seconds(1)),w(Q,"MINUTE",Q.minutes(1)),w(Q,"HOUR",Q.hours(1)),w(Q,"DAY",Q.days(1)),w(Q,"MAX",new Q((1n<<63n)-1n)),w(Q,"MIN",new Q(0)),w(Q,"ZERO",new Q(0)),w(Q,"z",m.union([m.object({value:m.bigint()}).transform(r=>new Q(r.value)),m.string().transform(r=>new Q(BigInt(r))),m.instanceof(Number).transform(r=>new Q(r)),m.number().transform(r=>new Q(r)),m.instanceof(Q)]));let Oe=Q;const ee=class G{constructor(e){w(this,"value"),w(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new G(e).valueOf()}greaterThan(e){return this.valueOf()>new G(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new G(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new G(e).valueOf()}remainder(e){return ha(this,e)}truncate(e){return new G(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(G.DAY),t=this.truncate(G.HOUR),n=this.truncate(G.MINUTE),s=this.truncate(G.SECOND),a=this.truncate(G.MILLISECOND),i=this.truncate(G.MICROSECOND),o=this.truncate(G.NANOSECOND),u=e,d=t.sub(e),p=n.sub(t),A=s.sub(n),J=a.sub(s),ne=i.sub(a),pe=o.sub(i);let H="";return u.isZero||(H+=`${u.days}d `),d.isZero||(H+=`${d.hours}h `),p.isZero||(H+=`${p.minutes}m `),A.isZero||(H+=`${A.seconds}s `),J.isZero||(H+=`${J.milliseconds}ms `),ne.isZero||(H+=`${ne.microseconds}µs `),pe.isZero||(H+=`${pe.nanoseconds}ns`),H.trim()}get days(){return Number(this.valueOf()/G.DAY.valueOf())}get hours(){return Number(this.valueOf()/G.HOUR.valueOf())}get minutes(){return Number(this.valueOf()/G.MINUTE.valueOf())}get seconds(){return Number(this.valueOf()/G.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf()/G.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf()/G.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new G(e).valueOf()}add(e){return new G(this.valueOf()+new G(e).valueOf())}sub(e){return new G(this.valueOf()-new G(e).valueOf())}static nanoseconds(e=1){return new G(e)}static microseconds(e=1){return G.nanoseconds(e*1e3)}static milliseconds(e=1){return G.microseconds(e*1e3)}static seconds(e=1){return G.milliseconds(e*1e3)}static minutes(e){return G.seconds(e.valueOf()*60)}static hours(e){return G.minutes(e*60)}static days(e){return G.hours(e*24)}};w(ee,"NANOSECOND",ee.nanoseconds(1)),w(ee,"MICROSECOND",ee.microseconds(1)),w(ee,"MILLISECOND",ee.milliseconds(1)),w(ee,"SECOND",ee.seconds(1)),w(ee,"MINUTE",ee.minutes(1)),w(ee,"HOUR",ee.hours(1)),w(ee,"DAY",ee.days(1)),w(ee,"MAX",new ee((1n<<63n)-1n)),w(ee,"MIN",new ee(0)),w(ee,"ZERO",new ee(0)),w(ee,"z",m.union([m.object({value:m.bigint()}).transform(r=>new ee(r.value)),m.string().transform(r=>new ee(BigInt(r))),m.instanceof(Number).transform(r=>new ee(r)),m.number().transform(r=>new ee(r)),m.instanceof(ee)]));let we=ee;const br=class Er extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new Er(e).valueOf()}get period(){return we.seconds(1/this.valueOf())}sampleCount(e){return new we(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new be(t).valueOf()}span(e){return we.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new Er(e)}static khz(e){return Er.hz(e*1e3)}};w(br,"z",m.union([m.number().transform(r=>new br(r)),m.instanceof(Number).transform(r=>new br(r)),m.instanceof(br)]));const me=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new Po(e*this.valueOf())}};w(me,"UNKNOWN",new me(0)),w(me,"BIT128",new me(16)),w(me,"BIT64",new me(8)),w(me,"BIT32",new me(4)),w(me,"BIT16",new me(2)),w(me,"BIT8",new me(1)),w(me,"z",m.union([m.number().transform(r=>new me(r)),m.instanceof(Number).transform(r=>new me(r)),m.instanceof(me)]));let be=me;const Pe=class Cr{constructor(e,t){w(this,"start"),w(this,"end"),this.start=new Oe(e),this.end=new Oe(t)}get span(){return new we(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}swap(){return new Cr(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e){e=e.makeValid();const t=this.makeValid();return e.start.equals(t.start)?!0:e.end.equals(this.start)||e.start.equals(this.end)?!1:this.contains(e.end)||this.contains(e.start)||e.contains(this.start)||e.contains(this.end)}contains(e){return e instanceof Cr?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new Cr(this.start,this.end);return e.start.after(this.start)&&(t.start=e.start),e.start.after(this.end)&&(t.end=e.start),e.end.before(this.end)&&(t.end=e.end),e.end.before(this.start)&&(t.start=e.end),t}};w(Pe,"MAX",new Pe(Oe.MIN,Oe.MAX)),w(Pe,"MIN",new Pe(Oe.MAX,Oe.MIN)),w(Pe,"ZERO",new Pe(Oe.ZERO,Oe.ZERO)),w(Pe,"z",m.union([m.object({start:Oe.z,end:Oe.z}).transform(r=>new Pe(r.start,r.end)),m.instanceof(Pe)]));let Mo=Pe;const y=class He extends String{constructor(e){if(e instanceof He||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const t=He.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}}throw super(He.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=He.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}toString(){return this.valueOf()}get isVariable(){return this.equals(He.JSON)||this.equals(He.STRING)}get density(){const e=He.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return He.BIG_INT_TYPES.some(e=>e.equals(this))}};w(y,"UNKNOWN",new y("unknown")),w(y,"FLOAT64",new y("float64")),w(y,"FLOAT32",new y("float32")),w(y,"INT64",new y("int64")),w(y,"INT32",new y("int32")),w(y,"INT16",new y("int16")),w(y,"INT8",new y("int8")),w(y,"UINT64",new y("uint64")),w(y,"UINT32",new y("uint32")),w(y,"UINT16",new y("uint16")),w(y,"UINT8",new y("uint8")),w(y,"BOOLEAN",y.UINT8),w(y,"TIMESTAMP",new y("timestamp")),w(y,"UUID",new y("uuid")),w(y,"STRING",new y("string")),w(y,"JSON",new y("json")),w(y,"ARRAY_CONSTRUCTORS",new Map([[y.UINT8.toString(),Uint8Array],[y.UINT16.toString(),Uint16Array],[y.UINT32.toString(),Uint32Array],[y.UINT64.toString(),BigUint64Array],[y.FLOAT32.toString(),Float32Array],[y.FLOAT64.toString(),Float64Array],[y.INT8.toString(),Int8Array],[y.INT16.toString(),Int16Array],[y.INT32.toString(),Int32Array],[y.INT64.toString(),BigInt64Array],[y.TIMESTAMP.toString(),BigInt64Array],[y.STRING.toString(),Uint8Array],[y.JSON.toString(),Uint8Array],[y.UUID.toString(),Uint8Array]])),w(y,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,y.UINT8],[Uint16Array.name,y.UINT16],[Uint32Array.name,y.UINT32],[BigUint64Array.name,y.UINT64],[Float32Array.name,y.FLOAT32],[Float64Array.name,y.FLOAT64],[Int8Array.name,y.INT8],[Int16Array.name,y.INT16],[Int32Array.name,y.INT32],[BigInt64Array.name,y.INT64]])),w(y,"DENSITIES",new Map([[y.UINT8.toString(),be.BIT8],[y.UINT16.toString(),be.BIT16],[y.UINT32.toString(),be.BIT32],[y.UINT64.toString(),be.BIT64],[y.FLOAT32.toString(),be.BIT32],[y.FLOAT64.toString(),be.BIT64],[y.INT8.toString(),be.BIT8],[y.INT16.toString(),be.BIT16],[y.INT32.toString(),be.BIT32],[y.INT64.toString(),be.BIT64],[y.TIMESTAMP.toString(),be.BIT64],[y.STRING.toString(),be.UNKNOWN],[y.JSON.toString(),be.UNKNOWN],[y.UUID.toString(),be.BIT128]])),w(y,"ALL",[y.UNKNOWN,y.FLOAT64,y.FLOAT32,y.INT64,y.INT32,y.INT16,y.INT8,y.UINT64,y.UINT32,y.UINT16,y.UINT8,y.TIMESTAMP,y.UUID,y.STRING,y.JSON]),w(y,"BIG_INT_TYPES",[y.INT64,y.UINT64,y.TIMESTAMP]),w(y,"z",m.union([m.string().transform(r=>new y(r)),m.instanceof(y)]));const ye=class de extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return de.bytes(this.valueOf()+e.valueOf())}sub(e){return de.bytes(this.valueOf()-e.valueOf())}truncate(e){return new de(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return de.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/de.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/de.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/de.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/de.TERABYTE.valueOf()}toString(){const e=this.truncate(de.TERABYTE),t=this.truncate(de.GIGABYTE),n=this.truncate(de.MEGABYTE),s=this.truncate(de.KILOBYTE),a=this.truncate(de.BYTE),i=e,o=t.sub(e),u=n.sub(t),d=s.sub(n),p=a.sub(s);let A="";return i.isZero||(A+=`${i.terabytes}TB `),o.isZero||(A+=`${o.gigabytes}GB `),u.isZero||(A+=`${u.megabytes}MB `),d.isZero||(A+=`${d.kilobytes}KB `),(!p.isZero||A==="")&&(A+=`${p.valueOf()}B`),A.trim()}static bytes(e=1){return new de(e)}static kilobytes(e=1){return de.bytes(e.valueOf()*1e3)}static megabytes(e=1){return de.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return de.megabytes(e.valueOf()*1e3)}static terabytes(e){return de.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};w(ye,"BYTE",new ye(1)),w(ye,"KILOBYTE",ye.kilobytes(1)),w(ye,"MEGABYTE",ye.megabytes(1)),w(ye,"GIGABYTE",ye.gigabytes(1)),w(ye,"TERABYTE",ye.terabytes(1)),w(ye,"ZERO",new ye(0)),w(ye,"z",m.union([m.number().transform(r=>new ye(r)),m.instanceof(ye)]));let Po=ye;m.union([m.instanceof(Uint8Array),m.instanceof(Uint16Array),m.instanceof(Uint32Array),m.instanceof(BigUint64Array),m.instanceof(Float32Array),m.instanceof(Float64Array),m.instanceof(Int8Array),m.instanceof(Int16Array),m.instanceof(Int32Array),m.instanceof(BigInt64Array)]);m.record(m.union([m.number(),m.string(),m.symbol()]),m.unknown());const Do=r=>r!=null&&typeof r=="object"&&!Array.isArray(r),fa=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",Bo=fa(),pa=["MacOS","Windows","Linux","Docker"],Lo=m.enum(pa);let _n;const $o=()=>{if(typeof window>"u")return;const r=window.navigator.userAgent.toLowerCase();if(r.includes("mac"))return"MacOS";if(r.includes("win"))return"Windows";if(r.includes("linux"))return"Linux"},zo=(r={})=>{const{force:e,default:t}=r;return e??_n??(_n=$o(),_n??t)},ma=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:pa,RUNTIME:Bo,detect:fa,getOS:zo,osZ:Lo},Symbol.toStringTag,{value:"Module"})),Vo=(...r)=>r.map(ya).join(""),ya=r=>(r.endsWith("/")||(r+="/"),r.startsWith("/")&&(r=r.slice(1)),r),Wo=r=>r.endsWith("/")?r.slice(0,-1):r,Fo=(r,e="")=>r===null?"":"?"+Object.entries(r).filter(([,t])=>t==null?!1:Array.isArray(t)?t.length>0:!0).map(([t,n])=>`${e}${t}=${n}`).join("&");var Nt;let Ko=(Nt=class{constructor({host:r,port:e,protocol:t="",pathPrefix:n=""}){w(this,"protocol"),w(this,"host"),w(this,"port"),w(this,"path"),this.protocol=t,this.host=r,this.port=e,this.path=ya(n)}replace(r){return new Nt({host:r.host??this.host,port:r.port??this.port,protocol:r.protocol??this.protocol,pathPrefix:r.pathPrefix??this.path})}child(r){return new Nt({...this,pathPrefix:Vo(this.path,r)})}toString(){return Wo(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}},w(Nt,"UNKNOWN",new Nt({host:"unknown",port:0})),Nt);var Nn;try{Nn=new TextDecoder}catch{}var x,Ne,c=0,re={},K,ut,Se=0,De=0,fe,et,Te=[],F,ps={useRecords:!1,mapsAsObjects:!0};class ga{}const va=new ga;va.name="MessagePack 0xC1";var ct=!1,_a=2,ms;try{new Function("")}catch{_a=1/0}class Xt{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.sequential&&e.trusted!==!1&&(e.trusted=!0,!e.structures&&e.useRecords!=!1&&(e.structures=[],e.maxSharedStructures||(e.maxSharedStructures=0))),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0),e.int64AsNumber&&(e.int64AsType="number")),Object.assign(this,e)}unpack(e,t){if(x)return Oa(()=>(An(),this?this.unpack(e,t):Xt.prototype.unpack.call(ps,e,t)));!e.buffer&&e.constructor===ArrayBuffer&&(e=typeof Buffer<"u"?Buffer.from(e):new Uint8Array(e)),typeof t=="object"?(Ne=t.end||e.length,c=t.start||0):(c=0,Ne=t>-1?t:e.length),De=0,ut=null,fe=null,x=e;try{F=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(n){throw x=null,e instanceof Uint8Array?n:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof Xt){if(re=this,this.structures)return K=this.structures,wr(t);(!K||K.length>0)&&(K=[])}else re=ps,(!K||K.length>0)&&(K=[]);return wr(t)}unpackMultiple(e,t){let n,s=0;try{ct=!0;let a=e.length,i=this?this.unpack(e,a):on.unpack(e,a);if(t){if(t(i,s,c)===!1)return;for(;c<a;)if(s=c,t(wr(),s,c)===!1)return}else{for(n=[i];c<a;)s=c,n.push(wr());return n}}catch(a){throw a.lastPosition=s,a.values=n,a}finally{ct=!1,An()}}_mergeStructures(e,t){e=e||[],Object.isFrozen(e)&&(e=e.map(n=>n.slice(0)));for(let n=0,s=e.length;n<s;n++){let a=e[n];a&&(a.isShared=!0,n>=32&&(a.highByte=n-32>>5))}e.sharedLength=e.length;for(let n in t||[])if(n>=0){let s=e[n],a=t[n];a&&(s&&((e.restoreStructures||(e.restoreStructures=[]))[n]=s),e[n]=a)}return this.structures=e}decode(e,t){return this.unpack(e,t)}}function wr(r){try{if(!re.trusted&&!ct){let t=K.sharedLength||0;t<K.length&&(K.length=t)}let e;if(re.randomAccessStructure&&x[c]<64&&x[c]>=32&&ms?(e=ms(x,c,Ne,re),x=null,!(r&&r.lazy)&&e&&(e=e.toJSON()),c=Ne):e=ce(),fe&&(c=fe.postBundlePosition,fe=null),ct&&(K.restoreStructures=null),c==Ne)K&&K.restoreStructures&&ys(),K=null,x=null,et&&(et=null);else{if(c>Ne)throw new Error("Unexpected end of MessagePack data");if(!ct){let t;try{t=JSON.stringify(e,(n,s)=>typeof s=="bigint"?`${s}n`:s).slice(0,100)}catch(n){t="(JSON view not available "+n+")"}throw new Error("Data read, but end of buffer not reached "+t)}}return e}catch(e){throw K&&K.restoreStructures&&ys(),An(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||c>Ne)&&(e.incomplete=!0),e}}function ys(){for(let r in K.restoreStructures)K[r]=K.restoreStructures[r];K.restoreStructures=null}function ce(){let r=x[c++];if(r<160)if(r<128){if(r<64)return r;{let e=K[r&63]||re.getStructures&&ba()[r&63];return e?(e.read||(e.read=Jn(e,r&63)),e.read()):r}}else if(r<144)if(r-=128,re.mapsAsObjects){let e={};for(let t=0;t<r;t++){let n=xa();n==="__proto__"&&(n="__proto_"),e[n]=ce()}return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(ce(),ce());return e}else{r-=144;let e=new Array(r);for(let t=0;t<r;t++)e[t]=ce();return re.freezeData?Object.freeze(e):e}else if(r<192){let e=r-160;if(De>=c)return ut.slice(c-Se,(c+=e)-Se);if(De==0&&Ne<140){let t=e<16?Hn(e):wa(e);if(t!=null)return t}return In(e)}else{let e;switch(r){case 192:return null;case 193:return fe?(e=ce(),e>0?fe[1].slice(fe.position1,fe.position1+=e):fe[0].slice(fe.position0,fe.position0-=e)):va;case 194:return!1;case 195:return!0;case 196:if(e=x[c++],e===void 0)throw new Error("Unexpected end of buffer");return bn(e);case 197:return e=F.getUint16(c),c+=2,bn(e);case 198:return e=F.getUint32(c),c+=4,bn(e);case 199:return gt(x[c++]);case 200:return e=F.getUint16(c),c+=2,gt(e);case 201:return e=F.getUint32(c),c+=4,gt(e);case 202:if(e=F.getFloat32(c),re.useFloat32>2){let t=Xn[(x[c]&127)<<1|x[c+1]>>7];return c+=4,(t*e+(e>0?.5:-.5)>>0)/t}return c+=4,e;case 203:return e=F.getFloat64(c),c+=8,e;case 204:return x[c++];case 205:return e=F.getUint16(c),c+=2,e;case 206:return e=F.getUint32(c),c+=4,e;case 207:return re.int64AsType==="number"?(e=F.getUint32(c)*4294967296,e+=F.getUint32(c+4)):re.int64AsType==="string"?e=F.getBigUint64(c).toString():re.int64AsType==="auto"?(e=F.getBigUint64(c),e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=F.getBigUint64(c),c+=8,e;case 208:return F.getInt8(c++);case 209:return e=F.getInt16(c),c+=2,e;case 210:return e=F.getInt32(c),c+=4,e;case 211:return re.int64AsType==="number"?(e=F.getInt32(c)*4294967296,e+=F.getUint32(c+4)):re.int64AsType==="string"?e=F.getBigInt64(c).toString():re.int64AsType==="auto"?(e=F.getBigInt64(c),e>=BigInt(-2)<<BigInt(52)&&e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=F.getBigInt64(c),c+=8,e;case 212:if(e=x[c++],e==114)return xs(x[c++]&63);{let t=Te[e];if(t)return t.read?(c++,t.read(ce())):t.noBuffer?(c++,t()):t(x.subarray(c,++c));throw new Error("Unknown extension "+e)}case 213:return e=x[c],e==114?(c++,xs(x[c++]&63,x[c++])):gt(2);case 214:return gt(4);case 215:return gt(8);case 216:return gt(16);case 217:return e=x[c++],De>=c?ut.slice(c-Se,(c+=e)-Se):qo(e);case 218:return e=F.getUint16(c),c+=2,De>=c?ut.slice(c-Se,(c+=e)-Se):Go(e);case 219:return e=F.getUint32(c),c+=4,De>=c?ut.slice(c-Se,(c+=e)-Se):Jo(e);case 220:return e=F.getUint16(c),c+=2,vs(e);case 221:return e=F.getUint32(c),c+=4,vs(e);case 222:return e=F.getUint16(c),c+=2,_s(e);case 223:return e=F.getUint32(c),c+=4,_s(e);default:if(r>=224)return r-256;if(r===void 0){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}throw new Error("Unknown MessagePack token "+r)}}}const Yo=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Jn(r,e){function t(){if(t.count++>_a){let s=r.read=new Function("r","return function(){return "+(re.freezeData?"Object.freeze":"")+"({"+r.map(a=>a==="__proto__"?"__proto_:r()":Yo.test(a)?a+":r()":"["+JSON.stringify(a)+"]:r()").join(",")+"})}")(ce);return r.highByte===0&&(r.read=gs(e,r.read)),s()}let n={};for(let s=0,a=r.length;s<a;s++){let i=r[s];i==="__proto__"&&(i="__proto_"),n[i]=ce()}return re.freezeData?Object.freeze(n):n}return t.count=0,r.highByte===0?gs(e,t):t}const gs=(r,e)=>function(){let t=x[c++];if(t===0)return e();let n=r<32?-(r+(t<<5)):r+(t<<5),s=K[n]||ba()[n];if(!s)throw new Error("Record id is not defined for "+n);return s.read||(s.read=Jn(s,r)),s.read()};function ba(){let r=Oa(()=>(x=null,re.getStructures()));return K=re._mergeStructures(r,K)}var In=pr,qo=pr,Go=pr,Jo=pr;function pr(r){let e;if(r<16&&(e=Hn(r)))return e;if(r>64&&Nn)return Nn.decode(x.subarray(c,c+=r));const t=c+r,n=[];for(e="";c<t;){const s=x[c++];if(!(s&128))n.push(s);else if((s&224)===192){const a=x[c++]&63;n.push((s&31)<<6|a)}else if((s&240)===224){const a=x[c++]&63,i=x[c++]&63;n.push((s&31)<<12|a<<6|i)}else if((s&248)===240){const a=x[c++]&63,i=x[c++]&63,o=x[c++]&63;let u=(s&7)<<18|a<<12|i<<6|o;u>65535&&(u-=65536,n.push(u>>>10&1023|55296),u=56320|u&1023),n.push(u)}else n.push(s);n.length>=4096&&(e+=he.apply(String,n),n.length=0)}return n.length>0&&(e+=he.apply(String,n)),e}function vs(r){let e=new Array(r);for(let t=0;t<r;t++)e[t]=ce();return re.freezeData?Object.freeze(e):e}function _s(r){if(re.mapsAsObjects){let e={};for(let t=0;t<r;t++){let n=xa();n==="__proto__"&&(n="__proto_"),e[n]=ce()}return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(ce(),ce());return e}}var he=String.fromCharCode;function wa(r){let e=c,t=new Array(r);for(let n=0;n<r;n++){const s=x[c++];if((s&128)>0){c=e;return}t[n]=s}return he.apply(String,t)}function Hn(r){if(r<4)if(r<2){if(r===0)return"";{let e=x[c++];if((e&128)>1){c-=1;return}return he(e)}}else{let e=x[c++],t=x[c++];if((e&128)>0||(t&128)>0){c-=2;return}if(r<3)return he(e,t);let n=x[c++];if((n&128)>0){c-=3;return}return he(e,t,n)}else{let e=x[c++],t=x[c++],n=x[c++],s=x[c++];if((e&128)>0||(t&128)>0||(n&128)>0||(s&128)>0){c-=4;return}if(r<6){if(r===4)return he(e,t,n,s);{let a=x[c++];if((a&128)>0){c-=5;return}return he(e,t,n,s,a)}}else if(r<8){let a=x[c++],i=x[c++];if((a&128)>0||(i&128)>0){c-=6;return}if(r<7)return he(e,t,n,s,a,i);let o=x[c++];if((o&128)>0){c-=7;return}return he(e,t,n,s,a,i,o)}else{let a=x[c++],i=x[c++],o=x[c++],u=x[c++];if((a&128)>0||(i&128)>0||(o&128)>0||(u&128)>0){c-=8;return}if(r<10){if(r===8)return he(e,t,n,s,a,i,o,u);{let d=x[c++];if((d&128)>0){c-=9;return}return he(e,t,n,s,a,i,o,u,d)}}else if(r<12){let d=x[c++],p=x[c++];if((d&128)>0||(p&128)>0){c-=10;return}if(r<11)return he(e,t,n,s,a,i,o,u,d,p);let A=x[c++];if((A&128)>0){c-=11;return}return he(e,t,n,s,a,i,o,u,d,p,A)}else{let d=x[c++],p=x[c++],A=x[c++],J=x[c++];if((d&128)>0||(p&128)>0||(A&128)>0||(J&128)>0){c-=12;return}if(r<14){if(r===12)return he(e,t,n,s,a,i,o,u,d,p,A,J);{let ne=x[c++];if((ne&128)>0){c-=13;return}return he(e,t,n,s,a,i,o,u,d,p,A,J,ne)}}else{let ne=x[c++],pe=x[c++];if((ne&128)>0||(pe&128)>0){c-=14;return}if(r<15)return he(e,t,n,s,a,i,o,u,d,p,A,J,ne,pe);let H=x[c++];if((H&128)>0){c-=15;return}return he(e,t,n,s,a,i,o,u,d,p,A,J,ne,pe,H)}}}}}function bs(){let r=x[c++],e;if(r<192)e=r-160;else switch(r){case 217:e=x[c++];break;case 218:e=F.getUint16(c),c+=2;break;case 219:e=F.getUint32(c),c+=4;break;default:throw new Error("Expected string")}return pr(e)}function bn(r){return re.copyBuffers?Uint8Array.prototype.slice.call(x,c,c+=r):x.subarray(c,c+=r)}function gt(r){let e=x[c++];if(Te[e]){let t;return Te[e](x.subarray(c,t=c+=r),n=>{c=n;try{return ce()}finally{c=t}})}else throw new Error("Unknown extension type "+e)}var ws=new Array(4096);function xa(){let r=x[c++];if(r>=160&&r<192){if(r=r-160,De>=c)return ut.slice(c-Se,(c+=r)-Se);if(!(De==0&&Ne<180))return In(r)}else return c--,ce().toString();let e=(r<<5^(r>1?F.getUint16(c):r>0?x[c]:0))&4095,t=ws[e],n=c,s=c+r-3,a,i=0;if(t&&t.bytes==r){for(;n<s;){if(a=F.getUint32(n),a!=t[i++]){n=1879048192;break}n+=4}for(s+=3;n<s;)if(a=x[n++],a!=t[i++]){n=1879048192;break}if(n===s)return c=n,t.string;s-=3,n=c}for(t=[],ws[e]=t,t.bytes=r;n<s;)a=F.getUint32(n),t.push(a),n+=4;for(s+=3;n<s;)a=x[n++],t.push(a);let o=r<16?Hn(r):wa(r);return o!=null?t.string=o:t.string=In(r)}const xs=(r,e)=>{let t=ce().map(a=>a.toString()),n=r;e!==void 0&&(r=r<32?-((e<<5)+r):(e<<5)+r,t.highByte=e);let s=K[r];return s&&(s.isShared||ct)&&((K.restoreStructures||(K.restoreStructures=[]))[r]=s),K[r]=t,t.read=Jn(t,n),t.read()};Te[0]=()=>{};Te[0].noBuffer=!0;let Ho={Error,TypeError,ReferenceError};Te[101]=()=>{let r=ce();return(Ho[r[0]]||Error)(r[1])};Te[105]=r=>{let e=F.getUint32(c-4);et||(et=new Map);let t=x[c],n;t>=144&&t<160||t==220||t==221?n=[]:n={};let s={target:n};et.set(e,s);let a=ce();return s.used?Object.assign(n,a):(s.target=a,a)};Te[112]=r=>{let e=F.getUint32(c-4),t=et.get(e);return t.used=!0,t.target};Te[115]=()=>new Set(ce());const ka=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(r=>r+"Array");let Xo=typeof globalThis=="object"?globalThis:window;Te[116]=r=>{let e=r[0],t=ka[e];if(!t)throw new Error("Could not find typed array for code "+e);return new Xo[t](Uint8Array.prototype.slice.call(r,1).buffer)};Te[120]=()=>{let r=ce();return new RegExp(r[0],r[1])};const Qo=[];Te[98]=r=>{let e=(r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3],t=c;return c+=e-r.length,fe=Qo,fe=[bs(),bs()],fe.position0=0,fe.position1=0,fe.postBundlePosition=c,c=t,ce()};Te[255]=r=>r.length==4?new Date((r[0]*16777216+(r[1]<<16)+(r[2]<<8)+r[3])*1e3):r.length==8?new Date(((r[0]<<22)+(r[1]<<14)+(r[2]<<6)+(r[3]>>2))/1e6+((r[3]&3)*4294967296+r[4]*16777216+(r[5]<<16)+(r[6]<<8)+r[7])*1e3):r.length==12?new Date(((r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3])/1e6+((r[4]&128?-281474976710656:0)+r[6]*1099511627776+r[7]*4294967296+r[8]*16777216+(r[9]<<16)+(r[10]<<8)+r[11])*1e3):new Date("invalid");function Oa(r){let e=Ne,t=c,n=Se,s=De,a=ut,i=et,o=fe,u=new Uint8Array(x.slice(0,Ne)),d=K,p=K.slice(0,K.length),A=re,J=ct,ne=r();return Ne=e,c=t,Se=n,De=s,ut=a,et=i,fe=o,x=u,ct=J,K=d,K.splice(0,K.length,...p),re=A,F=new DataView(x.buffer,x.byteOffset,x.byteLength),ne}function An(){x=null,et=null,K=null}const Xn=new Array(147);for(let r=0;r<256;r++)Xn[r]=+("1e"+Math.floor(45.15-r*.30103));var on=new Xt({useRecords:!1});const eu=on.unpack;on.unpackMultiple;on.unpack;let tu=new Float32Array(1);new Uint8Array(tu.buffer,0,4);let Zr;try{Zr=new TextEncoder}catch{}let En,Ta;const un=typeof Buffer<"u",xr=un?function(r){return Buffer.allocUnsafeSlow(r)}:Uint8Array,Sa=un?Buffer:Uint8Array,ks=un?4294967296:2144337920;let h,Dt,te,l=0,_e,se=null,ru;const nu=21760,su=/[\u0080-\uFFFF]/,It=Symbol("record-id");class au extends Xt{constructor(e){super(e),this.offset=0;let t,n,s,a,i=Sa.prototype.utf8Write?function(f,I){return h.utf8Write(f,I,4294967295)}:Zr&&Zr.encodeInto?function(f,I){return Zr.encodeInto(f,h.subarray(I)).written}:!1,o=this;e||(e={});let u=e&&e.sequential,d=e.structures||e.saveStructures,p=e.maxSharedStructures;if(p==null&&(p=d?32:0),p>8160)throw new Error("Maximum maxSharedStructure is 8160");e.structuredClone&&e.moreTypes==null&&(this.moreTypes=!0);let A=e.maxOwnStructures;A==null&&(A=d?32:64),!this.structures&&e.useRecords!=!1&&(this.structures=[]);let J=p>32||A+p>64,ne=p+64,pe=p+A+64;if(pe>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let H=[],hn=0,gr=0;this.pack=this.encode=function(f,I){if(h||(h=new xr(8192),te=h.dataView||(h.dataView=new DataView(h.buffer,0,8192)),l=0),_e=h.length-10,_e-l<2048?(h=new xr(h.length),te=h.dataView||(h.dataView=new DataView(h.buffer,0,h.length)),_e=h.length-10,l=0):l=l+7&2147483640,t=l,I&hu&&(l+=I&255),a=o.structuredClone?new Map:null,o.bundleStrings&&typeof f!="string"?(se=[],se.size=1/0):se=null,s=o.structures,s){s.uninitialized&&(s=o._mergeStructures(o.getStructures()));let g=s.sharedLength||0;if(g>p)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+s.sharedLength);if(!s.transitions){s.transitions=Object.create(null);for(let b=0;b<g;b++){let k=s[b];if(!k)continue;let z,V=s.transitions;for(let R=0,ue=k.length;R<ue;R++){let X=k[R];z=V[X],z||(z=V[X]=Object.create(null)),V=z}V[It]=b+64}this.lastNamedStructuresLength=g}u||(s.nextId=g+64)}n&&(n=!1);try{o.randomAccessStructure&&f&&f.constructor&&f.constructor===Object?Ba(f):oe(f);let g=se;if(se&&Ss(t,oe,0),a&&a.idsToInsert){let b=a.idsToInsert.sort((R,ue)=>R.offset>ue.offset?1:-1),k=b.length,z=-1;for(;g&&k>0;){let R=b[--k].offset+t;R<g.stringsPosition+t&&z===-1&&(z=0),R>g.position+t?z>=0&&(z+=6):(z>=0&&(te.setUint32(g.position+t,te.getUint32(g.position+t)+z),z=-1),g=g.previous,k++)}z>=0&&g&&te.setUint32(g.position+t,te.getUint32(g.position+t)+z),l+=b.length*6,l>_e&&st(l),o.offset=l;let V=ou(h.subarray(t,l),b);return a=null,V}return o.offset=l,I&lu?(h.start=t,h.end=l,h):h.subarray(t,l)}finally{if(s&&(rs(),n&&o.saveStructures)){let g=s.sharedLength||0,b=h.subarray(t,l),k=uu(s,o);return o.saveStructures(k,k.isCompatible)===!1?o.pack(f,I):(o.lastNamedStructuresLength=g,b)}I&du&&(l=t)}};const rs=()=>{gr<10&&gr++;let f=s.sharedLength||0;if(s.length>f&&!u&&(s.length=f),hn>1e4)s.transitions=null,gr=0,hn=0,H.length>0&&(H=[]);else if(H.length>0&&!u){for(let I=0,g=H.length;I<g;I++)H[I][It]=0;H=[]}},fn=f=>{var I=f.length;I<16?h[l++]=144|I:I<65536?(h[l++]=220,h[l++]=I>>8,h[l++]=I&255):(h[l++]=221,te.setUint32(l,I),l+=4);for(let g=0;g<I;g++)oe(f[g])},oe=f=>{l>_e&&(h=st(l));var I=typeof f,g;if(I==="string"){let b=f.length;if(se&&b>=4&&b<4096){if((se.size+=b)>nu){let R,ue=(se[0]?se[0].length*3+se[1].length:0)+10;l+ue>_e&&(h=st(l+ue));let X;se.position?(X=se,h[l]=200,l+=3,h[l++]=98,R=l-t,l+=4,Ss(t,oe,0),te.setUint16(R+t-3,l-t-R)):(h[l++]=214,h[l++]=98,R=l-t,l+=4),se=["",""],se.previous=X,se.size=0,se.position=R}let V=su.test(f);se[V?0:1]+=f,h[l++]=193,oe(V?-b:b);return}let k;b<32?k=1:b<256?k=2:b<65536?k=3:k=5;let z=b*3;if(l+z>_e&&(h=st(l+z)),b<64||!i){let V,R,ue,X=l+k;for(V=0;V<b;V++)R=f.charCodeAt(V),R<128?h[X++]=R:R<2048?(h[X++]=R>>6|192,h[X++]=R&63|128):(R&64512)===55296&&((ue=f.charCodeAt(V+1))&64512)===56320?(R=65536+((R&1023)<<10)+(ue&1023),V++,h[X++]=R>>18|240,h[X++]=R>>12&63|128,h[X++]=R>>6&63|128,h[X++]=R&63|128):(h[X++]=R>>12|224,h[X++]=R>>6&63|128,h[X++]=R&63|128);g=X-l-k}else g=i(f,l+k);g<32?h[l++]=160|g:g<256?(k<2&&h.copyWithin(l+2,l+1,l+1+g),h[l++]=217,h[l++]=g):g<65536?(k<3&&h.copyWithin(l+3,l+2,l+2+g),h[l++]=218,h[l++]=g>>8,h[l++]=g&255):(k<5&&h.copyWithin(l+5,l+3,l+3+g),h[l++]=219,te.setUint32(l,g),l+=4),l+=g}else if(I==="number")if(f>>>0===f)f<32||f<128&&this.useRecords===!1||f<64&&!this.randomAccessStructure?h[l++]=f:f<256?(h[l++]=204,h[l++]=f):f<65536?(h[l++]=205,h[l++]=f>>8,h[l++]=f&255):(h[l++]=206,te.setUint32(l,f),l+=4);else if(f>>0===f)f>=-32?h[l++]=256+f:f>=-128?(h[l++]=208,h[l++]=f+256):f>=-32768?(h[l++]=209,te.setInt16(l,f),l+=2):(h[l++]=210,te.setInt32(l,f),l+=4);else{let b;if((b=this.useFloat32)>0&&f<4294967296&&f>=-2147483648){h[l++]=202,te.setFloat32(l,f);let k;if(b<4||(k=f*Xn[(h[l]&127)<<1|h[l+1]>>7])>>0===k){l+=4;return}else l--}h[l++]=203,te.setFloat64(l,f),l+=8}else if(I==="object"||I==="function")if(!f)h[l++]=192;else{if(a){let k=a.get(f);if(k){if(!k.id){let z=a.idsToInsert||(a.idsToInsert=[]);k.id=z.push(k)}h[l++]=214,h[l++]=112,te.setUint32(l,k.id),l+=4;return}else a.set(f,{offset:l-t})}let b=f.constructor;if(b===Object)vr(f,!0);else if(b===Array)fn(f);else if(b===Map)if(this.mapAsEmptyObject)h[l++]=128;else{g=f.size,g<16?h[l++]=128|g:g<65536?(h[l++]=222,h[l++]=g>>8,h[l++]=g&255):(h[l++]=223,te.setUint32(l,g),l+=4);for(let[k,z]of f)oe(k),oe(z)}else{for(let k=0,z=En.length;k<z;k++){let V=Ta[k];if(f instanceof V){let R=En[k];if(R.write){R.type&&(h[l++]=212,h[l++]=R.type,h[l++]=0);let at=R.write.call(this,f);at===f?Array.isArray(f)?fn(f):vr(f):oe(at);return}let ue=h,X=te,Ve=l;h=null;let yt;try{yt=R.pack.call(this,f,at=>(h=ue,ue=null,l+=at,l>_e&&st(l),{target:h,targetView:te,position:l-at}),oe)}finally{ue&&(h=ue,te=X,l=Ve,_e=h.length-10)}yt&&(yt.length+l>_e&&st(yt.length+l),l=iu(yt,h,l,R.type));return}}if(Array.isArray(f))fn(f);else{if(f.toJSON){const k=f.toJSON();if(k!==f)return oe(k)}if(I==="function")return oe(this.writeFunction&&this.writeFunction(f));vr(f,!f.hasOwnProperty)}}}else if(I==="boolean")h[l++]=f?195:194;else if(I==="bigint"){if(f<BigInt(1)<<BigInt(63)&&f>=-(BigInt(1)<<BigInt(63)))h[l++]=211,te.setBigInt64(l,f);else if(f<BigInt(1)<<BigInt(64)&&f>0)h[l++]=207,te.setBigUint64(l,f);else if(this.largeBigIntToFloat)h[l++]=203,te.setFloat64(l,Number(f));else throw new RangeError(f+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");l+=8}else if(I==="undefined")this.encodeUndefinedAsNil?h[l++]=192:(h[l++]=212,h[l++]=0,h[l++]=0);else throw new Error("Unknown type: "+I)},ns=this.variableMapSize||this.coercibleKeyAsNumber?f=>{let I=Object.keys(f),g=I.length;g<16?h[l++]=128|g:g<65536?(h[l++]=222,h[l++]=g>>8,h[l++]=g&255):(h[l++]=223,te.setUint32(l,g),l+=4);let b;if(this.coercibleKeyAsNumber)for(let k=0;k<g;k++){b=I[k];let z=Number(b);oe(isNaN(z)?b:z),oe(f[b])}else for(let k=0;k<g;k++)oe(b=I[k]),oe(f[b])}:(f,I)=>{h[l++]=222;let g=l-t;l+=2;let b=0;for(let k in f)(I||f.hasOwnProperty(k))&&(oe(k),oe(f[k]),b++);h[g+++t]=b>>8,h[g+t]=b&255},ss=this.useRecords===!1?ns:e.progressiveRecords&&!J?(f,I)=>{let g,b=s.transitions||(s.transitions=Object.create(null)),k=l++-t,z;for(let V in f)if(I||f.hasOwnProperty(V)){if(g=b[V],g)b=g;else{let R=Object.keys(f),ue=b;b=s.transitions;let X=0;for(let Ve=0,yt=R.length;Ve<yt;Ve++){let at=R[Ve];g=b[at],g||(g=b[at]=Object.create(null),X++),b=g}k+t+1==l?(l--,pn(b,R,X)):is(b,R,k,X),z=!0,b=ue[V]}oe(f[V])}if(!z){let V=b[It];V?h[k+t]=V:is(b,Object.keys(f),k,0)}}:(f,I)=>{let g,b=s.transitions||(s.transitions=Object.create(null)),k=0;for(let V in f)(I||f.hasOwnProperty(V))&&(g=b[V],g||(g=b[V]=Object.create(null),k++),b=g);let z=b[It];z?z>=96&&J?(h[l++]=((z-=96)&31)+96,h[l++]=z>>5):h[l++]=z:pn(b,b.__keys__||Object.keys(f),k);for(let V in f)(I||f.hasOwnProperty(V))&&oe(f[V])},as=typeof this.useRecords=="function"&&this.useRecords,vr=as?(f,I)=>{as(f)?ss(f,I):ns(f,I)}:ss,st=f=>{let I;if(f>16777216){if(f-t>ks)throw new Error("Packed buffer would be larger than maximum buffer size");I=Math.min(ks,Math.round(Math.max((f-t)*(f>67108864?1.25:2),4194304)/4096)*4096)}else I=(Math.max(f-t<<2,h.length-1)>>12)+1<<12;let g=new xr(I);return te=g.dataView||(g.dataView=new DataView(g.buffer,0,I)),f=Math.min(f,h.length),h.copy?h.copy(g,0,t,f):g.set(h.slice(t,f)),l-=t,t=0,_e=g.length-10,h=g},pn=(f,I,g)=>{let b=s.nextId;b||(b=64),b<ne&&this.shouldShareStructure&&!this.shouldShareStructure(I)?(b=s.nextOwnId,b<pe||(b=ne),s.nextOwnId=b+1):(b>=pe&&(b=ne),s.nextId=b+1);let k=I.highByte=b>=96&&J?b-96>>5:-1;f[It]=b,f.__keys__=I,s[b-64]=I,b<ne?(I.isShared=!0,s.sharedLength=b-63,n=!0,k>=0?(h[l++]=(b&31)+96,h[l++]=k):h[l++]=b):(k>=0?(h[l++]=213,h[l++]=114,h[l++]=(b&31)+96,h[l++]=k):(h[l++]=212,h[l++]=114,h[l++]=b),g&&(hn+=gr*g),H.length>=A&&(H.shift()[It]=0),H.push(f),oe(I))},is=(f,I,g,b)=>{let k=h,z=l,V=_e,R=t;h=Dt,l=0,t=0,h||(Dt=h=new xr(8192)),_e=h.length-10,pn(f,I,b),Dt=h;let ue=l;if(h=k,l=z,_e=V,t=R,ue>1){let X=l+ue-1;X>_e&&st(X);let Ve=g+t;h.copyWithin(Ve+ue,Ve+1,l),h.set(Dt.slice(0,ue),Ve),l=X}else h[g+t]=Dt[0]},Ba=(f,I)=>{let g=ru(f,h,t,l,s,st,(b,k,z)=>{if(z)return n=!0;l=k;let V=h;return oe(b),rs(),V!==h?{position:l,targetView:te,target:h}:l},this);if(g===0)return vr(f,!0);l=g}}useBuffer(e){h=e,te=new DataView(h.buffer,h.byteOffset,h.byteLength),l=0}clearSharedData(){this.structures&&(this.structures=[]),this.typedStructs&&(this.typedStructs=[])}}Ta=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,ga];En=[{pack(r,e,t){let n=r.getTime()/1e3;if((this.useTimestamp32||r.getMilliseconds()===0)&&n>=0&&n<4294967296){let{target:s,targetView:a,position:i}=e(6);s[i++]=214,s[i++]=255,a.setUint32(i,n)}else if(n>0&&n<4294967296){let{target:s,targetView:a,position:i}=e(10);s[i++]=215,s[i++]=255,a.setUint32(i,r.getMilliseconds()*4e6+(n/1e3/4294967296>>0)),a.setUint32(i+4,n)}else if(isNaN(n)){if(this.onInvalidDate)return e(0),t(this.onInvalidDate());let{target:s,targetView:a,position:i}=e(3);s[i++]=212,s[i++]=255,s[i++]=255}else{let{target:s,targetView:a,position:i}=e(15);s[i++]=199,s[i++]=12,s[i++]=255,a.setUint32(i,r.getMilliseconds()*1e6),a.setBigInt64(i+4,BigInt(Math.floor(n)))}}},{pack(r,e,t){if(this.setAsEmptyObject)return e(0),t({});let n=Array.from(r),{target:s,position:a}=e(this.moreTypes?3:0);this.moreTypes&&(s[a++]=212,s[a++]=115,s[a++]=0),t(n)}},{pack(r,e,t){let{target:n,position:s}=e(this.moreTypes?3:0);this.moreTypes&&(n[s++]=212,n[s++]=101,n[s++]=0),t([r.name,r.message])}},{pack(r,e,t){let{target:n,position:s}=e(this.moreTypes?3:0);this.moreTypes&&(n[s++]=212,n[s++]=120,n[s++]=0),t([r.source,r.flags])}},{pack(r,e){this.moreTypes?Os(r,16,e):Ts(un?Buffer.from(r):new Uint8Array(r),e)}},{pack(r,e){let t=r.constructor;t!==Sa&&this.moreTypes?Os(r,ka.indexOf(t.name),e):Ts(r,e)}},{pack(r,e){let{target:t,position:n}=e(1);t[n]=193}}];function Os(r,e,t,n){let s=r.byteLength;if(s+1<256){var{target:a,position:i}=t(4+s);a[i++]=199,a[i++]=s+1}else if(s+1<65536){var{target:a,position:i}=t(5+s);a[i++]=200,a[i++]=s+1>>8,a[i++]=s+1&255}else{var{target:a,position:i,targetView:o}=t(7+s);a[i++]=201,o.setUint32(i,s+1),i+=4}a[i++]=116,a[i++]=e,a.set(new Uint8Array(r.buffer,r.byteOffset,r.byteLength),i)}function Ts(r,e){let t=r.byteLength;var n,s;if(t<256){var{target:n,position:s}=e(t+2);n[s++]=196,n[s++]=t}else if(t<65536){var{target:n,position:s}=e(t+3);n[s++]=197,n[s++]=t>>8,n[s++]=t&255}else{var{target:n,position:s,targetView:a}=e(t+5);n[s++]=198,a.setUint32(s,t),s+=4}n.set(r,s)}function iu(r,e,t,n){let s=r.length;switch(s){case 1:e[t++]=212;break;case 2:e[t++]=213;break;case 4:e[t++]=214;break;case 8:e[t++]=215;break;case 16:e[t++]=216;break;default:s<256?(e[t++]=199,e[t++]=s):s<65536?(e[t++]=200,e[t++]=s>>8,e[t++]=s&255):(e[t++]=201,e[t++]=s>>24,e[t++]=s>>16&255,e[t++]=s>>8&255,e[t++]=s&255)}return e[t++]=n,e.set(r,t),t+=s,t}function ou(r,e){let t,n=e.length*6,s=r.length-n;for(;t=e.pop();){let a=t.offset,i=t.id;r.copyWithin(a+n,a,s),n-=6;let o=a+n;r[o++]=214,r[o++]=105,r[o++]=i>>24,r[o++]=i>>16&255,r[o++]=i>>8&255,r[o++]=i&255,s=a}return r}function Ss(r,e,t){if(se.length>0){te.setUint32(se.position+r,l+t-se.position-r),se.stringsPosition=l-r;let n=se;se=null,e(n[0]),e(n[1])}}function uu(r,e){return r.isCompatible=t=>{let n=!t||(e.lastNamedStructuresLength||0)===t.length;return n||e._mergeStructures(t),n},r}let Na=new au({useRecords:!1});const cu=Na.pack;Na.pack;const lu=512,du=1024,hu=2048;class fu{constructor(){w(this,"contentType","application/msgpack")}encode(e){return cu(Ut.toSnake(e))}decode(e,t){const n=Ut.toCamel(eu(new Uint8Array(e)));return t!=null?t.parse(n):n}}class pu{constructor(){w(this,"contentType","application/json"),w(this,"decoder"),this.decoder=new TextDecoder}encode(e){const t=JSON.stringify(Ut.toSnake(e),(n,s)=>ArrayBuffer.isView(s)?Array.from(s):Do(s)&&"encode_value"in s?typeof s.value=="bigint"?s.value.toString():s.value:typeof s=="bigint"?s.toString():s);return new TextEncoder().encode(t)}decode(e,t){const n=Ut.toCamel(JSON.parse(this.decoder.decode(e)));return t!=null?t.parse(n):n}static registerCustomType(){}}new fu,new pu;var q;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},r.getValidEnumValues=s=>{const a=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return r.objectValues(i)},r.objectValues=s=>r.objectKeys(s).map(function(a){return s[a]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},r.find=(s,a)=>{for(const i of s)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=n,r.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(q||(q={}));var Cn;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Cn||(Cn={}));const T=q.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ot=r=>{switch(typeof r){case"undefined":return T.undefined;case"string":return T.string;case"number":return isNaN(r)?T.nan:T.number;case"boolean":return T.boolean;case"function":return T.function;case"bigint":return T.bigint;case"symbol":return T.symbol;case"object":return Array.isArray(r)?T.array:r===null?T.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?T.promise:typeof Map<"u"&&r instanceof Map?T.map:typeof Set<"u"&&r instanceof Set?T.set:typeof Date<"u"&&r instanceof Date?T.date:T.object;default:return T.unknown}},_=q.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"]),mu=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class je extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},n={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let o=n,u=0;for(;u<i.path.length;){const d=i.path[u];u===i.path.length-1?(o[d]=o[d]||{_errors:[]},o[d]._errors.push(t(i))):o[d]=o[d]||{_errors:[]},o=o[d],u++}}};return s(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,q.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}je.create=r=>new je(r);const Qt=(r,e)=>{let t;switch(r.code){case _.invalid_type:r.received===T.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case _.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,q.jsonStringifyReplacer)}`;break;case _.unrecognized_keys:t=`Unrecognized key(s) in object: ${q.joinValues(r.keys,", ")}`;break;case _.invalid_union:t="Invalid input";break;case _.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${q.joinValues(r.options)}`;break;case _.invalid_enum_value:t=`Invalid enum value. Expected ${q.joinValues(r.options)}, received '${r.received}'`;break;case _.invalid_arguments:t="Invalid function arguments";break;case _.invalid_return_type:t="Invalid function return type";break;case _.invalid_date:t="Invalid date";break;case _.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:q.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case _.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case _.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case _.custom:t="Invalid input";break;case _.invalid_intersection_types:t="Intersection results could not be merged";break;case _.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case _.not_finite:t="Number must be finite";break;default:t=e.defaultError,q.assertNever(r)}return{message:t}};let Ia=Qt;function yu(r){Ia=r}function Fr(){return Ia}const Kr=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],i={...s,path:a};let o="";const u=n.filter(d=>!!d).slice().reverse();for(const d of u)o=d(i,{data:e,defaultError:o}).message;return{...s,path:a,message:s.message||o}},gu=[];function N(r,e){const t=Kr({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Fr(),Qt].filter(n=>!!n)});r.common.issues.push(t)}class ve{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return U;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t)n.push({key:await s.key,value:await s.value});return ve.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return U;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}}const U=Object.freeze({status:"aborted"}),Aa=r=>({status:"dirty",value:r}),ke=r=>({status:"valid",value:r}),Zn=r=>r.status==="aborted",jn=r=>r.status==="dirty",er=r=>r.status==="valid",Yr=r=>typeof Promise<"u"&&r instanceof Promise;var C;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(C||(C={}));class $e{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Ns=(r,e)=>{if(er(e))return{success:!0,data:e.value};if(!r.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 je(r.common.issues);return this._error=t,this._error}}};function B(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,o)=>i.code!=="invalid_type"?{message:o.defaultError}:typeof o.data>"u"?{message:n??o.defaultError}:{message:t??o.defaultError},description:s}}class ${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)}get description(){return this._def.description}_getType(e){return ot(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ot(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ve,ctx:{common:e.parent.common,data:e.data,parsedType:ot(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Yr(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 s={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ot(e)},a=this._parseSync({data:e,path:s.path,parent:s});return Ns(s,a)}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:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ot(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(Yr(s)?s:Promise.resolve(s));return Ns(n,a)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue({code:_.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(u=>u?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new Me({schema:this,typeName:j.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return tt.create(this,this._def)}nullable(){return Tt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Re.create(this,this._def)}promise(){return Pt.create(this,this._def)}or(e){return sr.create([this,e],this._def)}and(e){return ar.create(this,e,this._def)}transform(e){return new Me({...B(this._def),schema:this,typeName:j.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new lr({...B(this._def),innerType:this,defaultValue:t,typeName:j.ZodDefault})}brand(){return new Ca({typeName:j.ZodBranded,type:this,...B(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Hr({...B(this._def),innerType:this,catchValue:t,typeName:j.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return mr.create(this,e)}readonly(){return Qr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const vu=/^c[^\s-]{8,}$/i,_u=/^[a-z][a-z0-9]*$/,bu=/^[0-9A-HJKMNP-TV-Z]{26}$/,wu=/^[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,xu=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ku="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let wn;const Ou=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,Tu=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Su=r=>r.precision?r.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}Z$`):r.precision===0?r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function Nu(r,e){return!!((e==="v4"||!e)&&Ou.test(r)||(e==="v6"||!e)&&Tu.test(r))}class Ee extends ${_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==T.string){const a=this._getOrReturnCtx(e);return N(a,{code:_.invalid_type,expected:T.string,received:a.parsedType}),U}const n=new ve;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),N(s,{code:_.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),N(s,{code:_.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(s=this._getOrReturnCtx(e,s),i?N(s,{code:_.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&N(s,{code:_.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")xu.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"email",code:_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")wn||(wn=new RegExp(ku,"u")),wn.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"emoji",code:_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")wu.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"uuid",code:_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")vu.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"cuid",code:_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")_u.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"cuid2",code:_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")bu.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"ulid",code:_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),N(s,{validation:"url",code:_.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"regex",code:_.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),N(s,{code:_.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),N(s,{code:_.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),N(s,{code:_.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Su(a).test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{code:_.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="ip"?Nu(e.data,a.version)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"ip",code:_.invalid_string,message:a.message}),n.dirty()):q.assertNever(a);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:_.invalid_string,...C.errToObj(n)})}_addCheck(e){return new Ee({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...C.errToObj(e)})}url(e){return this._addCheck({kind:"url",...C.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...C.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...C.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...C.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...C.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...C.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...C.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,...C.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...C.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...C.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...C.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...C.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...C.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...C.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...C.errToObj(t)})}nonempty(e){return this.min(1,C.errToObj(e))}trim(){return new Ee({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ee({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ee({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Ee.create=r=>{var e;return new Ee({checks:[],typeName:j.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...B(r)})};function Iu(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,a=parseInt(r.toFixed(s).replace(".","")),i=parseInt(e.toFixed(s).replace(".",""));return a%i/Math.pow(10,s)}class ft extends ${constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==T.number){const a=this._getOrReturnCtx(e);return N(a,{code:_.invalid_type,expected:T.number,received:a.parsedType}),U}let n;const s=new ve;for(const a of this._def.checks)a.kind==="int"?q.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{code:_.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),N(n,{code:_.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),N(n,{code:_.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Iu(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),N(n,{code:_.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{code:_.not_finite,message:a.message}),s.dirty()):q.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,C.toString(t))}gt(e,t){return this.setLimit("min",e,!1,C.toString(t))}lte(e,t){return this.setLimit("max",e,!0,C.toString(t))}lt(e,t){return this.setLimit("max",e,!1,C.toString(t))}setLimit(e,t,n,s){return new ft({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:C.toString(s)}]})}_addCheck(e){return new ft({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:C.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:C.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:C.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:C.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:C.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:C.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:C.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:C.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:C.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&q.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}ft.create=r=>new ft({checks:[],typeName:j.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...B(r)});class pt extends ${constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==T.bigint){const a=this._getOrReturnCtx(e);return N(a,{code:_.invalid_type,expected:T.bigint,received:a.parsedType}),U}let n;const s=new ve;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),N(n,{code:_.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),N(n,{code:_.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),N(n,{code:_.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):q.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,C.toString(t))}gt(e,t){return this.setLimit("min",e,!1,C.toString(t))}lte(e,t){return this.setLimit("max",e,!0,C.toString(t))}lt(e,t){return this.setLimit("max",e,!1,C.toString(t))}setLimit(e,t,n,s){return new pt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:C.toString(s)}]})}_addCheck(e){return new pt({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:C.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:C.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:C.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:C.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:C.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}pt.create=r=>{var e;return new pt({checks:[],typeName:j.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...B(r)})};class tr extends ${_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==T.boolean){const n=this._getOrReturnCtx(e);return N(n,{code:_.invalid_type,expected:T.boolean,received:n.parsedType}),U}return ke(e.data)}}tr.create=r=>new tr({typeName:j.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...B(r)});class kt extends ${_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==T.date){const a=this._getOrReturnCtx(e);return N(a,{code:_.invalid_type,expected:T.date,received:a.parsedType}),U}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return N(a,{code:_.invalid_date}),U}const n=new ve;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),N(s,{code:_.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),N(s,{code:_.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):q.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new kt({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:C.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:C.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}kt.create=r=>new kt({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:j.ZodDate,...B(r)});class qr extends ${_parse(e){if(this._getType(e)!==T.symbol){const n=this._getOrReturnCtx(e);return N(n,{code:_.invalid_type,expected:T.symbol,received:n.parsedType}),U}return ke(e.data)}}qr.create=r=>new qr({typeName:j.ZodSymbol,...B(r)});class rr extends ${_parse(e){if(this._getType(e)!==T.undefined){const n=this._getOrReturnCtx(e);return N(n,{code:_.invalid_type,expected:T.undefined,received:n.parsedType}),U}return ke(e.data)}}rr.create=r=>new rr({typeName:j.ZodUndefined,...B(r)});class nr extends ${_parse(e){if(this._getType(e)!==T.null){const n=this._getOrReturnCtx(e);return N(n,{code:_.invalid_type,expected:T.null,received:n.parsedType}),U}return ke(e.data)}}nr.create=r=>new nr({typeName:j.ZodNull,...B(r)});class Mt extends ${constructor(){super(...arguments),this._any=!0}_parse(e){return ke(e.data)}}Mt.create=r=>new Mt({typeName:j.ZodAny,...B(r)});class _t extends ${constructor(){super(...arguments),this._unknown=!0}_parse(e){return ke(e.data)}}_t.create=r=>new _t({typeName:j.ZodUnknown,...B(r)});class nt extends ${_parse(e){const t=this._getOrReturnCtx(e);return N(t,{code:_.invalid_type,expected:T.never,received:t.parsedType}),U}}nt.create=r=>new nt({typeName:j.ZodNever,...B(r)});class Gr extends ${_parse(e){if(this._getType(e)!==T.undefined){const n=this._getOrReturnCtx(e);return N(n,{code:_.invalid_type,expected:T.void,received:n.parsedType}),U}return ke(e.data)}}Gr.create=r=>new Gr({typeName:j.ZodVoid,...B(r)});class Re extends ${_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==T.array)return N(t,{code:_.invalid_type,expected:T.array,received:t.parsedType}),U;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(N(t,{code:i?_.too_big:_.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(N(t,{code:_.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(N(t,{code:_.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new $e(t,i,t.path,o)))).then(i=>ve.mergeArray(n,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new $e(t,i,t.path,o)));return ve.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new Re({...this._def,minLength:{value:e,message:C.toString(t)}})}max(e,t){return new Re({...this._def,maxLength:{value:e,message:C.toString(t)}})}length(e,t){return new Re({...this._def,exactLength:{value:e,message:C.toString(t)}})}nonempty(e){return this.min(1,e)}}Re.create=(r,e)=>new Re({type:r,minLength:null,maxLength:null,exactLength:null,typeName:j.ZodArray,...B(e)});function Et(r){if(r instanceof ie){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=tt.create(Et(n))}return new ie({...r._def,shape:()=>e})}else return r instanceof Re?new Re({...r._def,type:Et(r.element)}):r instanceof tt?tt.create(Et(r.unwrap())):r instanceof Tt?Tt.create(Et(r.unwrap())):r instanceof ze?ze.create(r.items.map(e=>Et(e))):r}class ie extends ${constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=q.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==T.object){const d=this._getOrReturnCtx(e);return N(d,{code:_.invalid_type,expected:T.object,received:d.parsedType}),U}const{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof nt&&this._def.unknownKeys==="strip"))for(const d in s.data)i.includes(d)||o.push(d);const u=[];for(const d of i){const p=a[d],A=s.data[d];u.push({key:{status:"valid",value:d},value:p._parse(new $e(s,A,s.path,d)),alwaysSet:d in s.data})}if(this._def.catchall instanceof nt){const d=this._def.unknownKeys;if(d==="passthrough")for(const p of o)u.push({key:{status:"valid",value:p},value:{status:"valid",value:s.data[p]}});else if(d==="strict")o.length>0&&(N(s,{code:_.unrecognized_keys,keys:o}),n.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const p of o){const A=s.data[p];u.push({key:{status:"valid",value:p},value:d._parse(new $e(s,A,s.path,p)),alwaysSet:p in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const d=[];for(const p of u){const A=await p.key;d.push({key:A,value:await p.value,alwaysSet:p.alwaysSet})}return d}).then(d=>ve.mergeObjectSync(n,d)):ve.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return C.errToObj,new ie({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,a,i,o;const u=(i=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,n).message)!==null&&i!==void 0?i:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=C.errToObj(e).message)!==null&&o!==void 0?o:u}:{message:u}}}:{}})}strip(){return new ie({...this._def,unknownKeys:"strip"})}passthrough(){return new ie({...this._def,unknownKeys:"passthrough"})}extend(e){return new ie({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ie({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:j.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ie({...this._def,catchall:e})}pick(e){const t={};return q.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new ie({...this._def,shape:()=>t})}omit(e){const t={};return q.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new ie({...this._def,shape:()=>t})}deepPartial(){return Et(this)}partial(e){const t={};return q.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new ie({...this._def,shape:()=>t})}required(e){const t={};return q.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof tt;)a=a._def.innerType;t[n]=a}}),new ie({...this._def,shape:()=>t})}keyof(){return Ea(q.objectKeys(this.shape))}}ie.create=(r,e)=>new ie({shape:()=>r,unknownKeys:"strip",catchall:nt.create(),typeName:j.ZodObject,...B(e)});ie.strictCreate=(r,e)=>new ie({shape:()=>r,unknownKeys:"strict",catchall:nt.create(),typeName:j.ZodObject,...B(e)});ie.lazycreate=(r,e)=>new ie({shape:r,unknownKeys:"strip",catchall:nt.create(),typeName:j.ZodObject,...B(e)});class sr extends ${_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new je(o.ctx.common.issues));return N(t,{code:_.invalid_union,unionErrors:i}),U}if(t.common.async)return Promise.all(n.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let a;const i=[];for(const u of n){const d={...t,common:{...t.common,issues:[]},parent:null},p=u._parseSync({data:t.data,path:t.path,parent:d});if(p.status==="valid")return p;p.status==="dirty"&&!a&&(a={result:p,ctx:d}),d.common.issues.length&&i.push(d.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(u=>new je(u));return N(t,{code:_.invalid_union,unionErrors:o}),U}}get options(){return this._def.options}}sr.create=(r,e)=>new sr({options:r,typeName:j.ZodUnion,...B(e)});const jr=r=>r instanceof or?jr(r.schema):r instanceof Me?jr(r.innerType()):r instanceof ur?[r.value]:r instanceof mt?r.options:r instanceof cr?Object.keys(r.enum):r instanceof lr?jr(r._def.innerType):r instanceof rr?[void 0]:r instanceof nr?[null]:null;class cn extends ${_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==T.object)return N(t,{code:_.invalid_type,expected:T.object,received:t.parsedType}),U;const n=this.discriminator,s=t.data[n],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(N(t,{code:_.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),U)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const a of t){const i=jr(a.shape[e]);if(!i)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new cn({typeName:j.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...B(n)})}}function Rn(r,e){const t=ot(r),n=ot(e);if(r===e)return{valid:!0,data:r};if(t===T.object&&n===T.object){const s=q.objectKeys(e),a=q.objectKeys(r).filter(o=>s.indexOf(o)!==-1),i={...r,...e};for(const o of a){const u=Rn(r[o],e[o]);if(!u.valid)return{valid:!1};i[o]=u.data}return{valid:!0,data:i}}else if(t===T.array&&n===T.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<r.length;a++){const i=r[a],o=e[a],u=Rn(i,o);if(!u.valid)return{valid:!1};s.push(u.data)}return{valid:!0,data:s}}else return t===T.date&&n===T.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class ar extends ${_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(Zn(a)||Zn(i))return U;const o=Rn(a.value,i.value);return o.valid?((jn(a)||jn(i))&&t.dirty(),{status:t.value,value:o.data}):(N(n,{code:_.invalid_intersection_types}),U)};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(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}ar.create=(r,e,t)=>new ar({left:r,right:e,typeName:j.ZodIntersection,...B(t)});class ze extends ${_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==T.array)return N(n,{code:_.invalid_type,expected:T.array,received:n.parsedType}),U;if(n.data.length<this._def.items.length)return N(n,{code:_.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),U;!this._def.rest&&n.data.length>this._def.items.length&&(N(n,{code:_.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...n.data].map((i,o)=>{const u=this._def.items[o]||this._def.rest;return u?u._parse(new $e(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>ve.mergeArray(t,i)):ve.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new ze({...this._def,rest:e})}}ze.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ze({items:r,typeName:j.ZodTuple,rest:null,...B(e)})};class ir extends ${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!==T.object)return N(n,{code:_.invalid_type,expected:T.object,received:n.parsedType}),U;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)s.push({key:a._parse(new $e(n,o,n.path,o)),value:i._parse(new $e(n,n.data[o],n.path,o))});return n.common.async?ve.mergeObjectAsync(t,s):ve.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof $?new ir({keyType:e,valueType:t,typeName:j.ZodRecord,...B(n)}):new ir({keyType:Ee.create(),valueType:e,typeName:j.ZodRecord,...B(t)})}}class Jr extends ${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!==T.map)return N(n,{code:_.invalid_type,expected:T.map,received:n.parsedType}),U;const s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,u],d)=>({key:s._parse(new $e(n,o,n.path,[d,"key"])),value:a._parse(new $e(n,u,n.path,[d,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const u of i){const d=await u.key,p=await u.value;if(d.status==="aborted"||p.status==="aborted")return U;(d.status==="dirty"||p.status==="dirty")&&t.dirty(),o.set(d.value,p.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const u of i){const d=u.key,p=u.value;if(d.status==="aborted"||p.status==="aborted")return U;(d.status==="dirty"||p.status==="dirty")&&t.dirty(),o.set(d.value,p.value)}return{status:t.value,value:o}}}}Jr.create=(r,e,t)=>new Jr({valueType:e,keyType:r,typeName:j.ZodMap,...B(t)});class Ot extends ${_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==T.set)return N(n,{code:_.invalid_type,expected:T.set,received:n.parsedType}),U;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(N(n,{code:_.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(N(n,{code:_.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function i(u){const d=new Set;for(const p of u){if(p.status==="aborted")return U;p.status==="dirty"&&t.dirty(),d.add(p.value)}return{status:t.value,value:d}}const o=[...n.data.values()].map((u,d)=>a._parse(new $e(n,u,n.path,d)));return n.common.async?Promise.all(o).then(u=>i(u)):i(o)}min(e,t){return new Ot({...this._def,minSize:{value:e,message:C.toString(t)}})}max(e,t){return new Ot({...this._def,maxSize:{value:e,message:C.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Ot.create=(r,e)=>new Ot({valueType:r,minSize:null,maxSize:null,typeName:j.ZodSet,...B(e)});class Zt extends ${constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==T.function)return N(t,{code:_.invalid_type,expected:T.function,received:t.parsedType}),U;function n(o,u){return Kr({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Fr(),Qt].filter(d=>!!d),issueData:{code:_.invalid_arguments,argumentsError:u}})}function s(o,u){return Kr({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Fr(),Qt].filter(d=>!!d),issueData:{code:_.invalid_return_type,returnTypeError:u}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Pt){const o=this;return ke(async function(...u){const d=new je([]),p=await o._def.args.parseAsync(u,a).catch(ne=>{throw d.addIssue(n(u,ne)),d}),A=await Reflect.apply(i,this,p);return await o._def.returns._def.type.parseAsync(A,a).catch(ne=>{throw d.addIssue(s(A,ne)),d})})}else{const o=this;return ke(function(...u){const d=o._def.args.safeParse(u,a);if(!d.success)throw new je([n(u,d.error)]);const p=Reflect.apply(i,this,d.data),A=o._def.returns.safeParse(p,a);if(!A.success)throw new je([s(p,A.error)]);return A.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Zt({...this._def,args:ze.create(e).rest(_t.create())})}returns(e){return new Zt({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Zt({args:e||ze.create([]).rest(_t.create()),returns:t||_t.create(),typeName:j.ZodFunction,...B(n)})}}class or extends ${get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}or.create=(r,e)=>new or({getter:r,typeName:j.ZodLazy,...B(e)});class ur extends ${_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return N(t,{received:t.data,code:_.invalid_literal,expected:this._def.value}),U}return{status:"valid",value:e.data}}get value(){return this._def.value}}ur.create=(r,e)=>new ur({value:r,typeName:j.ZodLiteral,...B(e)});function Ea(r,e){return new mt({values:r,typeName:j.ZodEnum,...B(e)})}class mt extends ${_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return N(t,{expected:q.joinValues(n),received:t.parsedType,code:_.invalid_type}),U}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),n=this._def.values;return N(t,{received:t.data,code:_.invalid_enum_value,options:n}),U}return ke(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return mt.create(e)}exclude(e){return mt.create(this.options.filter(t=>!e.includes(t)))}}mt.create=Ea;class cr extends ${_parse(e){const t=q.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==T.string&&n.parsedType!==T.number){const s=q.objectValues(t);return N(n,{expected:q.joinValues(s),received:n.parsedType,code:_.invalid_type}),U}if(t.indexOf(e.data)===-1){const s=q.objectValues(t);return N(n,{received:n.data,code:_.invalid_enum_value,options:s}),U}return ke(e.data)}get enum(){return this._def.values}}cr.create=(r,e)=>new cr({values:r,typeName:j.ZodNativeEnum,...B(e)});class Pt extends ${unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==T.promise&&t.common.async===!1)return N(t,{code:_.invalid_type,expected:T.promise,received:t.parsedType}),U;const n=t.parsedType===T.promise?t.data:Promise.resolve(t.data);return ke(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Pt.create=(r,e)=>new Pt({type:r,typeName:j.ZodPromise,...B(e)});class Me extends ${innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===j.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{N(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(n.data,a);return n.common.issues.length?{status:"dirty",value:n.data}:n.common.async?Promise.resolve(i).then(o=>this._def.schema._parseAsync({data:o,path:n.path,parent:n})):this._def.schema._parseSync({data:i,path:n.path,parent:n})}if(s.type==="refinement"){const i=o=>{const u=s.refinement(o,a);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?U:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?U:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!er(i))return i;const o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>er(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);q.assertNever(s)}}Me.create=(r,e,t)=>new Me({schema:r,typeName:j.ZodEffects,effect:e,...B(t)});Me.createWithPreprocess=(r,e,t)=>new Me({schema:e,effect:{type:"preprocess",transform:r},typeName:j.ZodEffects,...B(t)});class tt extends ${_parse(e){return this._getType(e)===T.undefined?ke(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}tt.create=(r,e)=>new tt({innerType:r,typeName:j.ZodOptional,...B(e)});class Tt extends ${_parse(e){return this._getType(e)===T.null?ke(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Tt.create=(r,e)=>new Tt({innerType:r,typeName:j.ZodNullable,...B(e)});class lr extends ${_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===T.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}lr.create=(r,e)=>new lr({innerType:r,typeName:j.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...B(e)});class Hr extends ${_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Yr(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new je(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new je(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Hr.create=(r,e)=>new Hr({innerType:r,typeName:j.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...B(e)});class Xr extends ${_parse(e){if(this._getType(e)!==T.nan){const n=this._getOrReturnCtx(e);return N(n,{code:_.invalid_type,expected:T.nan,received:n.parsedType}),U}return{status:"valid",value:e.data}}}Xr.create=r=>new Xr({typeName:j.ZodNaN,...B(r)});const Au=Symbol("zod_brand");class Ca extends ${_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}}class mr extends ${_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?U:a.status==="dirty"?(t.dirty(),Aa(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?U:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new mr({in:e,out:t,typeName:j.ZodPipeline})}}class Qr extends ${_parse(e){const t=this._def.innerType._parse(e);return er(t)&&(t.value=Object.freeze(t.value)),t}}Qr.create=(r,e)=>new Qr({innerType:r,typeName:j.ZodReadonly,...B(e)});const Za=(r,e={},t)=>r?Mt.create().superRefine((n,s)=>{var a,i;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,d=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...d,fatal:u})}}):Mt.create(),Eu={object:ie.lazycreate};var j;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(j||(j={}));const Cu=(r,e={message:`Input not instance of ${r.name}`})=>Za(t=>t instanceof r,e),ja=Ee.create,Ra=ft.create,Zu=Xr.create,ju=pt.create,Ua=tr.create,Ru=kt.create,Uu=qr.create,Mu=rr.create,Pu=nr.create,Du=Mt.create,Bu=_t.create,Lu=nt.create,$u=Gr.create,zu=Re.create,Vu=ie.create,Wu=ie.strictCreate,Fu=sr.create,Ku=cn.create,Yu=ar.create,qu=ze.create,Gu=ir.create,Ju=Jr.create,Hu=Ot.create,Xu=Zt.create,Qu=or.create,ec=ur.create,tc=mt.create,rc=cr.create,nc=Pt.create,Is=Me.create,sc=tt.create,ac=Tt.create,ic=Me.createWithPreprocess,oc=mr.create,uc=()=>ja().optional(),cc=()=>Ra().optional(),lc=()=>Ua().optional(),dc={string:r=>Ee.create({...r,coerce:!0}),number:r=>ft.create({...r,coerce:!0}),boolean:r=>tr.create({...r,coerce:!0}),bigint:r=>pt.create({...r,coerce:!0}),date:r=>kt.create({...r,coerce:!0})},hc=U;var Xe=Object.freeze({__proto__:null,defaultErrorMap:Qt,setErrorMap:yu,getErrorMap:Fr,makeIssue:Kr,EMPTY_PATH:gu,addIssueToContext:N,ParseStatus:ve,INVALID:U,DIRTY:Aa,OK:ke,isAborted:Zn,isDirty:jn,isValid:er,isAsync:Yr,get util(){return q},get objectUtil(){return Cn},ZodParsedType:T,getParsedType:ot,ZodType:$,ZodString:Ee,ZodNumber:ft,ZodBigInt:pt,ZodBoolean:tr,ZodDate:kt,ZodSymbol:qr,ZodUndefined:rr,ZodNull:nr,ZodAny:Mt,ZodUnknown:_t,ZodNever:nt,ZodVoid:Gr,ZodArray:Re,ZodObject:ie,ZodUnion:sr,ZodDiscriminatedUnion:cn,ZodIntersection:ar,ZodTuple:ze,ZodRecord:ir,ZodMap:Jr,ZodSet:Ot,ZodFunction:Zt,ZodLazy:or,ZodLiteral:ur,ZodEnum:mt,ZodNativeEnum:cr,ZodPromise:Pt,ZodEffects:Me,ZodTransformer:Me,ZodOptional:tt,ZodNullable:Tt,ZodDefault:lr,ZodCatch:Hr,ZodNaN:Xr,BRAND:Au,ZodBranded:Ca,ZodPipeline:mr,ZodReadonly:Qr,custom:Za,Schema:$,ZodSchema:$,late:Eu,get ZodFirstPartyTypeKind(){return j},coerce:dc,any:Du,array:zu,bigint:ju,boolean:Ua,date:Ru,discriminatedUnion:Ku,effect:Is,enum:tc,function:Xu,instanceof:Cu,intersection:Yu,lazy:Qu,literal:ec,map:Ju,nan:Zu,nativeEnum:rc,never:Lu,null:Pu,nullable:ac,number:Ra,object:Vu,oboolean:lc,onumber:cc,optional:sc,ostring:uc,pipeline:oc,preprocess:ic,promise:nc,record:Gu,set:Hu,strictObject:Wu,string:ja,symbol:Uu,transformer:Is,tuple:qu,undefined:Mu,union:Fu,unknown:Bu,void:$u,NEVER:hc,ZodIssueCode:_,quotelessJson:mu,ZodError:je});class yr extends Error{constructor(t,n){super(t);le(this,"discriminator","FreighterError");le(this,"type");this.type=n}}const fc=r=>{if(r==null||typeof r!="object")return!1;const e=r;if(e.discriminator!=="FreighterError")return!1;if(!("type"in e))throw new Error(`Freighter error is missing its type property: ${JSON.stringify(e)}`);return!0},Un="unknown",As="nil",ln="freighter",Qn=Xe.object({type:Xe.string(),data:Xe.string()});class pc{constructor(){le(this,"providers",[])}register(e){this.providers.push(e)}encode(e){if(e==null)return{type:As,data:""};if(fc(e))for(const t of this.providers){const n=t.encode(e);if(n!=null)return n}return{type:Un,data:JSON.stringify(e)}}decode(e){if(e==null||e.type===As)return null;if(e.type===Un)return new Es(e.data);for(const t of this.providers){const n=t.decode(e);if(n!=null)return n}return new Es(e.data)}}const es=new pc,Ma=({encode:r,decode:e})=>es.register({encode:r,decode:e}),mc=r=>es.encode(r),ts=r=>es.decode(r);class Es extends yr{constructor(e){super(e,Un)}}class dr extends yr{constructor(){super("EOF",ln)}}class hr extends yr{constructor(){super("StreamClosed",ln)}}class dn extends yr{constructor(t={}){const{message:n="Unreachable",url:s=Ko.UNKNOWN}=t;super(n,ln);le(this,"url");this.url=s}}const Rr="freighter",yc=r=>{if(r.type!==ln)return null;if(r instanceof dr)return{type:Rr,data:"EOF"};if(r instanceof hr)return{type:Rr,data:"StreamClosed"};if(r instanceof dn)return{type:Rr,data:"Unreachable"};throw new Error(`Unknown error type: ${r.type}: ${r.message}`)},gc=r=>{if(r.type!==Rr)return null;switch(r.data){case"EOF":return new dr;case"StreamClosed":return new hr;case"Unreachable":return new dn;default:throw new Error(`Unknown error type: ${r.data}`)}};Ma({encode:yc,decode:gc});class Pa{constructor(){le(this,"middleware",[])}use(...e){this.middleware.push(...e)}async executeMiddleware(e,t){let n=0;const s=async a=>{if(n===this.middleware.length)return await t(a);const i=this.middleware[n];return n++,await i(a,s)};return await s(e)}}const Da="Content-Type",Cs=r=>{if(ma.RUNTIME!=="node")return fetch;const e=require("node-fetch");if(r==="http")return e;const t=require("https"),n=new t.Agent({rejectUnauthorized:!1});return async(s,a)=>await e(s,{...a,agent:n})};class vc extends Pa{constructor(t,n,s=!1){super();le(this,"endpoint");le(this,"encoder");le(this,"fetch");return this.endpoint=t.replace({protocol:s?"https":"http"}),this.encoder=n,this.fetch=Cs(this.endpoint.protocol),new Proxy(this,{get:(a,i,o)=>i==="endpoint"?this.endpoint:Reflect.get(a,i,o)})}get headers(){return{[Da]:this.encoder.contentType}}async send(t,n,s,a){n=s==null?void 0:s.parse(n);let i=null;const o=this.endpoint.child(t),u={};u.method="POST",u.body=this.encoder.encode(n??{});const[,d]=await this.executeMiddleware({target:o.toString(),protocol:this.endpoint.protocol,params:{},role:"client"},async p=>{const A={...p,params:{}};u.headers={...this.headers,...p.params};let J;try{J=await Cs(p.protocol)(p.target,u)}catch(pe){let H=pe;return H.message==="Load failed"&&(H=new dn({url:o})),[A,H]}const ne=await J.arrayBuffer();if(J!=null&&J.ok)return a!=null&&(i=this.encoder.decode(ne,a)),[A,null];try{if(J.status!==400)return[A,new Error(J.statusText)];const pe=this.encoder.decode(ne,Qn),H=ts(pe);return[A,H]}catch(pe){return[A,new Error(`[freighter] - failed to decode error: ${J.statusText}: ${pe.message}`)]}});return[i,d]}}const _c=async(r,e,t,n,s)=>{const[a,i]=await r.send(e,t,n,s);if(i!=null)throw i;return a},bc=()=>ma.RUNTIME!=="node"?r=>new WebSocket(r):r=>new(require("ws")).WebSocket(r,{rejectUnauthorized:!1}),wc=Xe.object({type:Xe.union([Xe.literal("data"),Xe.literal("close")]),payload:Xe.unknown().optional(),error:Xe.optional(Qn)});class xc{constructor(e,t,n,s){le(this,"encoder");le(this,"reqSchema");le(this,"resSchema");le(this,"ws");le(this,"serverClosed");le(this,"sendClosed");le(this,"receiveDataQueue",[]);le(this,"receiveCallbacksQueue",[]);this.encoder=t,this.reqSchema=n,this.resSchema=s,this.ws=e,this.sendClosed=!1,this.serverClosed=null,this.listenForMessages()}send(e){if(this.serverClosed!=null)return new dr;if(this.sendClosed)throw new hr;return this.ws.send(this.encoder.encode({type:"data",payload:e})),null}async receive(){if(this.serverClosed!=null)return[null,this.serverClosed];const e=await this.receiveMsg();if(e.type==="close"){if(e.error==null)throw new Error("Message error must be defined");return this.serverClosed=ts(e.error),[null,this.serverClosed]}return[this.resSchema.parse(e.payload),null]}received(){return this.receiveDataQueue.length!==0}closeSend(){if(this.sendClosed||this.serverClosed!=null)return;const e={type:"close"};try{this.ws.send(this.encoder.encode(e))}finally{this.sendClosed=!0}}async receiveMsg(){const e=this.receiveDataQueue.shift();return e??await new Promise((t,n)=>this.receiveCallbacksQueue.push({resolve:t,reject:n}))}listenForMessages(){this.ws.onmessage=e=>{const t=this.encoder.decode(e.data,wc),n=this.receiveCallbacksQueue.shift();n!=null?n.resolve(t):this.receiveDataQueue.push(t)},this.ws.onclose=e=>{this.serverClosed=Nc(e)?new dr:new hr}}}const kc="freighterctx",Oc=1e3,Tc=1001,Sc=[Oc,Tc],Nc=r=>Sc.includes(r.code),en=class en extends Pa{constructor(t,n,s=!1){super();le(this,"baseUrl");le(this,"encoder");this.baseUrl=t.replace({protocol:s?"wss":"ws"}),this.encoder=n}async stream(t,n,s){const a=bc();let i;const[,o]=await this.executeMiddleware({target:t,protocol:"websocket",params:{},role:"client"},async u=>{const d=a(this.buildURL(t,u)),p={...u,params:{}};d.binaryType=en.MESSAGE_TYPE;const A=await this.wrapSocket(d,n,s);return A instanceof Error?[p,A]:(i=A,[p,null])});if(o!=null)throw o;return i}buildURL(t,n){const s=Fo({[Da]:this.encoder.contentType,...n.params},kc);return this.baseUrl.child(t).toString()+s}async wrapSocket(t,n,s){return await new Promise(a=>{t.onopen=()=>{a(new xc(t,this.encoder,n,s))},t.onerror=i=>{const o=i;a(new Error(o.message))}})}};le(en,"MESSAGE_TYPE","arraybuffer");let Mn=en;exports.BaseTypedError=yr;exports.EOF=dr;exports.HTTPClient=vc;exports.StreamClosed=hr;exports.Unreachable=dn;exports.WebSocketClient=Mn;exports.decodeError=ts;exports.encodeError=mc;exports.errorZ=Qn;exports.registerError=Ma;exports.sendRequired=_c;
1
+ "use strict";var is=Object.defineProperty;var os=(r,e,t)=>e in r?is(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var L=(r,e,t)=>(os(r,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var us=Object.defineProperty,cs=(r,e,t)=>e in r?us(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,p=(r,e,t)=>(cs(r,typeof e!="symbol"?e+"":e,t),t),j;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},r.getValidEnumValues=s=>{const a=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return r.objectValues(i)},r.objectValues=s=>r.objectKeys(s).map(function(a){return s[a]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},r.find=(s,a)=>{for(const i of s)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=n,r.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(j||(j={}));var Tr;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Tr||(Tr={}));const y=j.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ze=r=>{switch(typeof r){case"undefined":return y.undefined;case"string":return y.string;case"number":return isNaN(r)?y.nan:y.number;case"boolean":return y.boolean;case"function":return y.function;case"bigint":return y.bigint;case"symbol":return y.symbol;case"object":return Array.isArray(r)?y.array:r===null?y.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?y.promise:typeof Map<"u"&&r instanceof Map?y.map:typeof Set<"u"&&r instanceof Set?y.set:typeof Date<"u"&&r instanceof Date?y.date:y.object;default:return y.unknown}},h=j.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"]),ds=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class re extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},n={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let o=n,u=0;for(;u<i.path.length;){const c=i.path[u];u===i.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(t(i))):o[c]=o[c]||{_errors:[]},o=o[c],u++}}};return s(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,j.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}re.create=r=>new re(r);const tt=(r,e)=>{let t;switch(r.code){case h.invalid_type:r.received===y.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case h.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,j.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:t=`Unrecognized key(s) in object: ${j.joinValues(r.keys,", ")}`;break;case h.invalid_union:t="Invalid input";break;case h.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${j.joinValues(r.options)}`;break;case h.invalid_enum_value:t=`Invalid enum value. Expected ${j.joinValues(r.options)}, received '${r.received}'`;break;case h.invalid_arguments:t="Invalid function arguments";break;case h.invalid_return_type:t="Invalid function return type";break;case h.invalid_date:t="Invalid date";break;case h.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:j.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case h.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case h.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case h.custom:t="Invalid input";break;case h.invalid_intersection_types:t="Intersection results could not be merged";break;case h.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case h.not_finite:t="Number must be finite";break;default:t=e.defaultError,j.assertNever(r)}return{message:t}};let dn=tt;function ls(r){dn=r}function Bt(){return dn}const Kt=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],i={...s,path:a};let o="";const u=n.filter(c=>!!c).slice().reverse();for(const c of u)o=c(i,{data:e,defaultError:o}).message;return{...s,path:a,message:s.message||o}},hs=[];function g(r,e){const t=Kt({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Bt(),tt].filter(n=>!!n)});r.common.issues.push(t)}class W{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return S;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t)n.push({key:await s.key,value:await s.value});return W.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return S;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}}const S=Object.freeze({status:"aborted"}),ln=r=>({status:"dirty",value:r}),H=r=>({status:"valid",value:r}),Or=r=>r.status==="aborted",Sr=r=>r.status==="dirty",rt=r=>r.status==="valid",Wt=r=>typeof Promise<"u"&&r instanceof Promise;var b;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(b||(b={}));class de{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Jr=(r,e)=>{if(rt(e))return{success:!0,data:e.value};if(!r.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 re(r.common.issues);return this._error=t,this._error}}};function N(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,i)=>a.code!=="invalid_type"?{message:i.defaultError}:typeof i.data>"u"?{message:n??i.defaultError}:{message:t??i.defaultError},description:s}}class C{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)}get description(){return this._def.description}_getType(e){return Ze(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Ze(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new W,ctx:{common:e.parent.common,data:e.data,parsedType:Ze(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Wt(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 s={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ze(e)},a=this._parseSync({data:e,path:s.path,parent:s});return Jr(s,a)}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:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ze(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(Wt(s)?s:Promise.resolve(s));return Jr(n,a)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue({code:h.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(u=>u?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new ie({schema:this,typeName:x.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Te.create(this,this._def)}nullable(){return Le.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ne.create(this,this._def)}promise(){return Je.create(this,this._def)}or(e){return it.create([this,e],this._def)}and(e){return ot.create(this,e,this._def)}transform(e){return new ie({...N(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ht({...N(this._def),innerType:this,defaultValue:t,typeName:x.ZodDefault})}brand(){return new fn({typeName:x.ZodBranded,type:this,...N(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Gt({...N(this._def),innerType:this,catchValue:t,typeName:x.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Nt.create(this,e)}readonly(){return Jt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const fs=/^c[^\s-]{8,}$/i,ps=/^[a-z][a-z0-9]*$/,ms=/^[0-9A-HJKMNP-TV-Z]{26}$/,ys=/^[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,vs=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,gs="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let gr;const _s=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,bs=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ws=r=>r.precision?r.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}Z$`):r.precision===0?r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function xs(r,e){return!!((e==="v4"||!e)&&_s.test(r)||(e==="v6"||!e)&&bs.test(r))}class ee extends C{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==y.string){const s=this._getOrReturnCtx(e);return g(s,{code:h.invalid_type,expected:y.string,received:s.parsedType}),S}const t=new W;let n;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(n=this._getOrReturnCtx(e,n),g(n,{code:h.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="max")e.data.length>s.value&&(n=this._getOrReturnCtx(e,n),g(n,{code:h.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="length"){const a=e.data.length>s.value,i=e.data.length<s.value;(a||i)&&(n=this._getOrReturnCtx(e,n),a?g(n,{code:h.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):i&&g(n,{code:h.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")vs.test(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{validation:"email",code:h.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")gr||(gr=new RegExp(gs,"u")),gr.test(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{validation:"emoji",code:h.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")ys.test(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{validation:"uuid",code:h.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")fs.test(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{validation:"cuid",code:h.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")ps.test(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{validation:"cuid2",code:h.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")ms.test(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{validation:"ulid",code:h.invalid_string,message:s.message}),t.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),g(n,{validation:"url",code:h.invalid_string,message:s.message}),t.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{validation:"regex",code:h.invalid_string,message:s.message}),t.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(n=this._getOrReturnCtx(e,n),g(n,{code:h.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),t.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(n=this._getOrReturnCtx(e,n),g(n,{code:h.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(n=this._getOrReturnCtx(e,n),g(n,{code:h.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?ws(s).test(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{code:h.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="ip"?xs(e.data,s.version)||(n=this._getOrReturnCtx(e,n),g(n,{validation:"ip",code:h.invalid_string,message:s.message}),t.dirty()):j.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:h.invalid_string,...b.errToObj(n)})}_addCheck(e){return new ee({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...b.errToObj(e)})}url(e){return this._addCheck({kind:"url",...b.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...b.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...b.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...b.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...b.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...b.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...b.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,...b.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...b.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...b.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...b.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...b.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...b.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...b.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...b.errToObj(t)})}nonempty(e){return this.min(1,b.errToObj(e))}trim(){return new ee({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ee({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ee({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ee.create=r=>{var e;return new ee({checks:[],typeName:x.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...N(r)})};function ks(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,a=parseInt(r.toFixed(s).replace(".","")),i=parseInt(e.toFixed(s).replace(".",""));return a%i/Math.pow(10,s)}class Ce extends C{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==y.number){const s=this._getOrReturnCtx(e);return g(s,{code:h.invalid_type,expected:y.number,received:s.parsedType}),S}let t;const n=new W;for(const s of this._def.checks)s.kind==="int"?j.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),g(t,{code:h.invalid_type,expected:"integer",received:"float",message:s.message}),n.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),g(t,{code:h.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),g(t,{code:h.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="multipleOf"?ks(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),g(t,{code:h.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),g(t,{code:h.not_finite,message:s.message}),n.dirty()):j.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,b.toString(t))}gt(e,t){return this.setLimit("min",e,!1,b.toString(t))}lte(e,t){return this.setLimit("max",e,!0,b.toString(t))}lt(e,t){return this.setLimit("max",e,!1,b.toString(t))}setLimit(e,t,n,s){return new Ce({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:b.toString(s)}]})}_addCheck(e){return new Ce({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:b.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:b.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:b.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:b.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:b.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&j.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Ce.create=r=>new Ce({checks:[],typeName:x.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...N(r)});class Ee extends C{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==y.bigint){const s=this._getOrReturnCtx(e);return g(s,{code:h.invalid_type,expected:y.bigint,received:s.parsedType}),S}let t;const n=new W;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),g(t,{code:h.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),g(t,{code:h.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),g(t,{code:h.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):j.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,b.toString(t))}gt(e,t){return this.setLimit("min",e,!1,b.toString(t))}lte(e,t){return this.setLimit("max",e,!0,b.toString(t))}lt(e,t){return this.setLimit("max",e,!1,b.toString(t))}setLimit(e,t,n,s){return new Ee({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:b.toString(s)}]})}_addCheck(e){return new Ee({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:b.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Ee.create=r=>{var e;return new Ee({checks:[],typeName:x.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...N(r)})};class nt extends C{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==y.boolean){const t=this._getOrReturnCtx(e);return g(t,{code:h.invalid_type,expected:y.boolean,received:t.parsedType}),S}return H(e.data)}}nt.create=r=>new nt({typeName:x.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...N(r)});class $e extends C{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==y.date){const s=this._getOrReturnCtx(e);return g(s,{code:h.invalid_type,expected:y.date,received:s.parsedType}),S}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return g(s,{code:h.invalid_date}),S}const t=new W;let n;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(n=this._getOrReturnCtx(e,n),g(n,{code:h.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),t.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(n=this._getOrReturnCtx(e,n),g(n,{code:h.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):j.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new $e({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:b.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:b.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}$e.create=r=>new $e({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:x.ZodDate,...N(r)});class Yt extends C{_parse(e){if(this._getType(e)!==y.symbol){const t=this._getOrReturnCtx(e);return g(t,{code:h.invalid_type,expected:y.symbol,received:t.parsedType}),S}return H(e.data)}}Yt.create=r=>new Yt({typeName:x.ZodSymbol,...N(r)});class st extends C{_parse(e){if(this._getType(e)!==y.undefined){const t=this._getOrReturnCtx(e);return g(t,{code:h.invalid_type,expected:y.undefined,received:t.parsedType}),S}return H(e.data)}}st.create=r=>new st({typeName:x.ZodUndefined,...N(r)});class at extends C{_parse(e){if(this._getType(e)!==y.null){const t=this._getOrReturnCtx(e);return g(t,{code:h.invalid_type,expected:y.null,received:t.parsedType}),S}return H(e.data)}}at.create=r=>new at({typeName:x.ZodNull,...N(r)});class He extends C{constructor(){super(...arguments),this._any=!0}_parse(e){return H(e.data)}}He.create=r=>new He({typeName:x.ZodAny,...N(r)});class Pe extends C{constructor(){super(...arguments),this._unknown=!0}_parse(e){return H(e.data)}}Pe.create=r=>new Pe({typeName:x.ZodUnknown,...N(r)});class Se extends C{_parse(e){const t=this._getOrReturnCtx(e);return g(t,{code:h.invalid_type,expected:y.never,received:t.parsedType}),S}}Se.create=r=>new Se({typeName:x.ZodNever,...N(r)});class qt extends C{_parse(e){if(this._getType(e)!==y.undefined){const t=this._getOrReturnCtx(e);return g(t,{code:h.invalid_type,expected:y.void,received:t.parsedType}),S}return H(e.data)}}qt.create=r=>new qt({typeName:x.ZodVoid,...N(r)});class ne extends C{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==y.array)return g(t,{code:h.invalid_type,expected:y.array,received:t.parsedType}),S;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(g(t,{code:i?h.too_big:h.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(g(t,{code:h.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(g(t,{code:h.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new de(t,i,t.path,o)))).then(i=>W.mergeArray(n,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new de(t,i,t.path,o)));return W.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new ne({...this._def,minLength:{value:e,message:b.toString(t)}})}max(e,t){return new ne({...this._def,maxLength:{value:e,message:b.toString(t)}})}length(e,t){return new ne({...this._def,exactLength:{value:e,message:b.toString(t)}})}nonempty(e){return this.min(1,e)}}ne.create=(r,e)=>new ne({type:r,minLength:null,maxLength:null,exactLength:null,typeName:x.ZodArray,...N(e)});function Ye(r){if(r instanceof $){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=Te.create(Ye(n))}return new $({...r._def,shape:()=>e})}else return r instanceof ne?new ne({...r._def,type:Ye(r.element)}):r instanceof Te?Te.create(Ye(r.unwrap())):r instanceof Le?Le.create(Ye(r.unwrap())):r instanceof le?le.create(r.items.map(e=>Ye(e))):r}class $ extends C{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=j.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==y.object){const u=this._getOrReturnCtx(e);return g(u,{code:h.invalid_type,expected:y.object,received:u.parsedType}),S}const{status:t,ctx:n}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof Se&&this._def.unknownKeys==="strip"))for(const u in n.data)a.includes(u)||i.push(u);const o=[];for(const u of a){const c=s[u],m=n.data[u];o.push({key:{status:"valid",value:u},value:c._parse(new de(n,m,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof Se){const u=this._def.unknownKeys;if(u==="passthrough")for(const c of i)o.push({key:{status:"valid",value:c},value:{status:"valid",value:n.data[c]}});else if(u==="strict")i.length>0&&(g(n,{code:h.unrecognized_keys,keys:i}),t.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const c of i){const m=n.data[c];o.push({key:{status:"valid",value:c},value:u._parse(new de(n,m,n.path,c)),alwaysSet:c in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const u=[];for(const c of o){const m=await c.key;u.push({key:m,value:await c.value,alwaysSet:c.alwaysSet})}return u}).then(u=>W.mergeObjectSync(t,u)):W.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return b.errToObj,new $({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,a,i,o;const u=(i=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,n).message)!==null&&i!==void 0?i:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=b.errToObj(e).message)!==null&&o!==void 0?o:u}:{message:u}}}:{}})}strip(){return new $({...this._def,unknownKeys:"strip"})}passthrough(){return new $({...this._def,unknownKeys:"passthrough"})}extend(e){return new $({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new $({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:x.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new $({...this._def,catchall:e})}pick(e){const t={};return j.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new $({...this._def,shape:()=>t})}omit(e){const t={};return j.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new $({...this._def,shape:()=>t})}deepPartial(){return Ye(this)}partial(e){const t={};return j.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new $({...this._def,shape:()=>t})}required(e){const t={};return j.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof Te;)s=s._def.innerType;t[n]=s}}),new $({...this._def,shape:()=>t})}keyof(){return hn(j.objectKeys(this.shape))}}$.create=(r,e)=>new $({shape:()=>r,unknownKeys:"strip",catchall:Se.create(),typeName:x.ZodObject,...N(e)});$.strictCreate=(r,e)=>new $({shape:()=>r,unknownKeys:"strict",catchall:Se.create(),typeName:x.ZodObject,...N(e)});$.lazycreate=(r,e)=>new $({shape:r,unknownKeys:"strip",catchall:Se.create(),typeName:x.ZodObject,...N(e)});class it extends C{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new re(o.ctx.common.issues));return g(t,{code:h.invalid_union,unionErrors:i}),S}if(t.common.async)return Promise.all(n.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let a;const i=[];for(const u of n){const c={...t,common:{...t.common,issues:[]},parent:null},m=u._parseSync({data:t.data,path:t.path,parent:c});if(m.status==="valid")return m;m.status==="dirty"&&!a&&(a={result:m,ctx:c}),c.common.issues.length&&i.push(c.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(u=>new re(u));return g(t,{code:h.invalid_union,unionErrors:o}),S}}get options(){return this._def.options}}it.create=(r,e)=>new it({options:r,typeName:x.ZodUnion,...N(e)});const At=r=>r instanceof ct?At(r.schema):r instanceof ie?At(r.innerType()):r instanceof dt?[r.value]:r instanceof Ae?r.options:r instanceof lt?Object.keys(r.enum):r instanceof ht?At(r._def.innerType):r instanceof st?[void 0]:r instanceof at?[null]:null;class dr extends C{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==y.object)return g(t,{code:h.invalid_type,expected:y.object,received:t.parsedType}),S;const n=this.discriminator,s=t.data[n],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(g(t,{code:h.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(e,t,n){const s=new Map;for(const a of t){const i=At(a.shape[e]);if(!i)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new dr({typeName:x.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...N(n)})}}function Nr(r,e){const t=Ze(r),n=Ze(e);if(r===e)return{valid:!0,data:r};if(t===y.object&&n===y.object){const s=j.objectKeys(e),a=j.objectKeys(r).filter(o=>s.indexOf(o)!==-1),i={...r,...e};for(const o of a){const u=Nr(r[o],e[o]);if(!u.valid)return{valid:!1};i[o]=u.data}return{valid:!0,data:i}}else if(t===y.array&&n===y.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<r.length;a++){const i=r[a],o=e[a],u=Nr(i,o);if(!u.valid)return{valid:!1};s.push(u.data)}return{valid:!0,data:s}}else return t===y.date&&n===y.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class ot extends C{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(Or(a)||Or(i))return S;const o=Nr(a.value,i.value);return o.valid?((Sr(a)||Sr(i))&&t.dirty(),{status:t.value,value:o.data}):(g(n,{code:h.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(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}ot.create=(r,e,t)=>new ot({left:r,right:e,typeName:x.ZodIntersection,...N(t)});class le extends C{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==y.array)return g(n,{code:h.invalid_type,expected:y.array,received:n.parsedType}),S;if(n.data.length<this._def.items.length)return g(n,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),S;!this._def.rest&&n.data.length>this._def.items.length&&(g(n,{code:h.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((a,i)=>{const o=this._def.items[i]||this._def.rest;return o?o._parse(new de(n,a,n.path,i)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>W.mergeArray(t,a)):W.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new le({...this._def,rest:e})}}le.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new le({items:r,typeName:x.ZodTuple,rest:null,...N(e)})};class ut extends C{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!==y.object)return g(n,{code:h.invalid_type,expected:y.object,received:n.parsedType}),S;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)s.push({key:a._parse(new de(n,o,n.path,o)),value:i._parse(new de(n,n.data[o],n.path,o))});return n.common.async?W.mergeObjectAsync(t,s):W.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof C?new ut({keyType:e,valueType:t,typeName:x.ZodRecord,...N(n)}):new ut({keyType:ee.create(),valueType:e,typeName:x.ZodRecord,...N(t)})}}class Ft extends C{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!==y.map)return g(n,{code:h.invalid_type,expected:y.map,received:n.parsedType}),S;const s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,u],c)=>({key:s._parse(new de(n,o,n.path,[c,"key"])),value:a._parse(new de(n,u,n.path,[c,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const u of i){const c=await u.key,m=await u.value;if(c.status==="aborted"||m.status==="aborted")return S;(c.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(c.value,m.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const u of i){const c=u.key,m=u.value;if(c.status==="aborted"||m.status==="aborted")return S;(c.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(c.value,m.value)}return{status:t.value,value:o}}}}Ft.create=(r,e,t)=>new Ft({valueType:e,keyType:r,typeName:x.ZodMap,...N(t)});class De extends C{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==y.set)return g(n,{code:h.invalid_type,expected:y.set,received:n.parsedType}),S;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(g(n,{code:h.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(g(n,{code:h.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function i(u){const c=new Set;for(const m of u){if(m.status==="aborted")return S;m.status==="dirty"&&t.dirty(),c.add(m.value)}return{status:t.value,value:c}}const o=[...n.data.values()].map((u,c)=>a._parse(new de(n,u,n.path,c)));return n.common.async?Promise.all(o).then(u=>i(u)):i(o)}min(e,t){return new De({...this._def,minSize:{value:e,message:b.toString(t)}})}max(e,t){return new De({...this._def,maxSize:{value:e,message:b.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}De.create=(r,e)=>new De({valueType:r,minSize:null,maxSize:null,typeName:x.ZodSet,...N(e)});class Fe extends C{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==y.function)return g(t,{code:h.invalid_type,expected:y.function,received:t.parsedType}),S;function n(o,u){return Kt({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Bt(),tt].filter(c=>!!c),issueData:{code:h.invalid_arguments,argumentsError:u}})}function s(o,u){return Kt({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Bt(),tt].filter(c=>!!c),issueData:{code:h.invalid_return_type,returnTypeError:u}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Je){const o=this;return H(async function(...u){const c=new re([]),m=await o._def.args.parseAsync(u,a).catch(B=>{throw c.addIssue(n(u,B)),c}),I=await Reflect.apply(i,this,m);return await o._def.returns._def.type.parseAsync(I,a).catch(B=>{throw c.addIssue(s(I,B)),c})})}else{const o=this;return H(function(...u){const c=o._def.args.safeParse(u,a);if(!c.success)throw new re([n(u,c.error)]);const m=Reflect.apply(i,this,c.data),I=o._def.returns.safeParse(m,a);if(!I.success)throw new re([s(m,I.error)]);return I.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Fe({...this._def,args:le.create(e).rest(Pe.create())})}returns(e){return new Fe({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Fe({args:e||le.create([]).rest(Pe.create()),returns:t||Pe.create(),typeName:x.ZodFunction,...N(n)})}}class ct 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})}}ct.create=(r,e)=>new ct({getter:r,typeName:x.ZodLazy,...N(e)});class dt extends C{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return g(t,{received:t.data,code:h.invalid_literal,expected:this._def.value}),S}return{status:"valid",value:e.data}}get value(){return this._def.value}}dt.create=(r,e)=>new dt({value:r,typeName:x.ZodLiteral,...N(e)});function hn(r,e){return new Ae({values:r,typeName:x.ZodEnum,...N(e)})}class Ae extends C{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return g(t,{expected:j.joinValues(n),received:t.parsedType,code:h.invalid_type}),S}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),n=this._def.values;return g(t,{received:t.data,code:h.invalid_enum_value,options:n}),S}return H(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return Ae.create(e)}exclude(e){return Ae.create(this.options.filter(t=>!e.includes(t)))}}Ae.create=hn;class lt extends C{_parse(e){const t=j.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==y.string&&n.parsedType!==y.number){const s=j.objectValues(t);return g(n,{expected:j.joinValues(s),received:n.parsedType,code:h.invalid_type}),S}if(t.indexOf(e.data)===-1){const s=j.objectValues(t);return g(n,{received:n.data,code:h.invalid_enum_value,options:s}),S}return H(e.data)}get enum(){return this._def.values}}lt.create=(r,e)=>new lt({values:r,typeName:x.ZodNativeEnum,...N(e)});class Je extends C{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==y.promise&&t.common.async===!1)return g(t,{code:h.invalid_type,expected:y.promise,received:t.parsedType}),S;const n=t.parsedType===y.promise?t.data:Promise.resolve(t.data);return H(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Je.create=(r,e)=>new Je({type:r,typeName:x.ZodPromise,...N(e)});class ie extends C{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===x.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{g(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(n.data,a);return n.common.issues.length?{status:"dirty",value:n.data}:n.common.async?Promise.resolve(i).then(o=>this._def.schema._parseAsync({data:o,path:n.path,parent:n})):this._def.schema._parseSync({data:i,path:n.path,parent:n})}if(s.type==="refinement"){const i=o=>{const u=s.refinement(o,a);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?S:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?S:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!rt(i))return i;const o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>rt(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);j.assertNever(s)}}ie.create=(r,e,t)=>new ie({schema:r,typeName:x.ZodEffects,effect:e,...N(t)});ie.createWithPreprocess=(r,e,t)=>new ie({schema:e,effect:{type:"preprocess",transform:r},typeName:x.ZodEffects,...N(t)});class Te extends C{_parse(e){return this._getType(e)===y.undefined?H(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Te.create=(r,e)=>new Te({innerType:r,typeName:x.ZodOptional,...N(e)});class Le extends C{_parse(e){return this._getType(e)===y.null?H(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Le.create=(r,e)=>new Le({innerType:r,typeName:x.ZodNullable,...N(e)});class ht extends C{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===y.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ht.create=(r,e)=>new ht({innerType:r,typeName:x.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...N(e)});class Gt extends C{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Wt(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new re(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new re(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Gt.create=(r,e)=>new Gt({innerType:r,typeName:x.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...N(e)});class Ht extends C{_parse(e){if(this._getType(e)!==y.nan){const t=this._getOrReturnCtx(e);return g(t,{code:h.invalid_type,expected:y.nan,received:t.parsedType}),S}return{status:"valid",value:e.data}}}Ht.create=r=>new Ht({typeName:x.ZodNaN,...N(r)});const Ts=Symbol("zod_brand");class fn extends C{_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}}class Nt extends C{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?S:s.status==="dirty"?(t.dirty(),ln(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?S:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new Nt({in:e,out:t,typeName:x.ZodPipeline})}}class Jt extends C{_parse(e){const t=this._def.innerType._parse(e);return rt(t)&&(t.value=Object.freeze(t.value)),t}}Jt.create=(r,e)=>new Jt({innerType:r,typeName:x.ZodReadonly,...N(e)});const pn=(r,e={},t)=>r?He.create().superRefine((n,s)=>{var a,i;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,c=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...c,fatal:u})}}):He.create(),Os={object:$.lazycreate};var x;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(x||(x={}));const Ss=(r,e={message:`Input not instance of ${r.name}`})=>pn(t=>t instanceof r,e),mn=ee.create,yn=Ce.create,Ns=Ht.create,Zs=Ee.create,vn=nt.create,Is=$e.create,Cs=Yt.create,Es=st.create,As=at.create,js=He.create,Rs=Pe.create,Ms=Se.create,Ps=qt.create,Us=ne.create,$s=$.create,Ds=$.strictCreate,Ls=it.create,zs=dr.create,Vs=ot.create,Bs=le.create,Ks=ut.create,Ws=Ft.create,Ys=De.create,qs=Fe.create,Fs=ct.create,Gs=dt.create,Hs=Ae.create,Js=lt.create,Xs=Je.create,Xr=ie.create,Qs=Te.create,ea=Le.create,ta=ie.createWithPreprocess,ra=Nt.create,na=()=>mn().optional(),sa=()=>yn().optional(),aa=()=>vn().optional(),ia={string:r=>ee.create({...r,coerce:!0}),number:r=>Ce.create({...r,coerce:!0}),boolean:r=>nt.create({...r,coerce:!0}),bigint:r=>Ee.create({...r,coerce:!0}),date:r=>$e.create({...r,coerce:!0})},oa=S;var d=Object.freeze({__proto__:null,defaultErrorMap:tt,setErrorMap:ls,getErrorMap:Bt,makeIssue:Kt,EMPTY_PATH:hs,addIssueToContext:g,ParseStatus:W,INVALID:S,DIRTY:ln,OK:H,isAborted:Or,isDirty:Sr,isValid:rt,isAsync:Wt,get util(){return j},get objectUtil(){return Tr},ZodParsedType:y,getParsedType:Ze,ZodType:C,ZodString:ee,ZodNumber:Ce,ZodBigInt:Ee,ZodBoolean:nt,ZodDate:$e,ZodSymbol:Yt,ZodUndefined:st,ZodNull:at,ZodAny:He,ZodUnknown:Pe,ZodNever:Se,ZodVoid:qt,ZodArray:ne,ZodObject:$,ZodUnion:it,ZodDiscriminatedUnion:dr,ZodIntersection:ot,ZodTuple:le,ZodRecord:ut,ZodMap:Ft,ZodSet:De,ZodFunction:Fe,ZodLazy:ct,ZodLiteral:dt,ZodEnum:Ae,ZodNativeEnum:lt,ZodPromise:Je,ZodEffects:ie,ZodTransformer:ie,ZodOptional:Te,ZodNullable:Le,ZodDefault:ht,ZodCatch:Gt,ZodNaN:Ht,BRAND:Ts,ZodBranded:fn,ZodPipeline:Nt,ZodReadonly:Jt,custom:pn,Schema:C,ZodSchema:C,late:Os,get ZodFirstPartyTypeKind(){return x},coerce:ia,any:js,array:Us,bigint:Zs,boolean:vn,date:Is,discriminatedUnion:zs,effect:Xr,enum:Hs,function:qs,instanceof:Ss,intersection:Vs,lazy:Fs,literal:Gs,map:Ws,nan:Ns,nativeEnum:Js,never:Ms,null:As,nullable:ea,number:yn,object:$s,oboolean:aa,onumber:sa,optional:Qs,ostring:na,pipeline:ra,preprocess:ta,promise:Xs,record:Ks,set:Ys,strictObject:Ds,string:mn,symbol:Cs,transformer:Xr,tuple:Bs,undefined:Es,union:Ls,unknown:Rs,void:Ps,NEVER:oa,ZodIssueCode:h,quotelessJson:ds,ZodError:re});const Mr=d.tuple([d.number(),d.number()]),gn=d.object({width:d.number(),height:d.number()}),ua=d.object({signedWidth:d.number(),signedHeight:d.number()}),ca=["width","height"];d.enum(ca);const da=["start","center","end"],la=["signedWidth","signedHeight"];d.enum(la);const Xt=d.object({x:d.number(),y:d.number()}),ha=d.object({clientX:d.number(),clientY:d.number()}),fa=["x","y"],_n=d.enum(fa),bn=["top","right","bottom","left"];d.enum(bn);const pa=["left","right"],wn=d.enum(pa),ma=["top","bottom"],xn=d.enum(ma),kn=["center"],Qr=d.enum(kn),ya=[...bn,...kn],Tn=d.enum(ya);d.enum(da);const va=["first","last"];d.enum(va);const ga=d.object({lower:d.number(),upper:d.number()});d.union([ga,Mr]);d.union([_n,Tn]);d.union([_n,Tn,d.instanceof(String)]);const _r=(r,e)=>{const t={lower:0,upper:0};return typeof r=="number"?e!=null?(t.lower=r,t.upper=e):(t.lower=0,t.upper=r):Array.isArray(r)?[t.lower,t.upper]=r:(t.lower=r.lower,t.upper=r.upper),_a(t)},_a=r=>r.lower>r.upper?{lower:r.upper,upper:r.lower}:r;var Q=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},A={},lr={};Object.defineProperty(lr,"__esModule",{value:!0});function ba(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"$"+n}).toLowerCase().replace(/(\$)(\w)/g,function(e,t,n){return n.toUpperCase()}):""}lr.default=ba;var hr={};Object.defineProperty(hr,"__esModule",{value:!0});function wa(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"_").toLowerCase():""}hr.default=wa;var fr={};Object.defineProperty(fr,"__esModule",{value:!0});function xa(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"$").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"$"+n}).toLowerCase().replace(/(\$)(\w?)/g,function(e,t,n){return n.toUpperCase()}):""}fr.default=xa;var Pr={};Object.defineProperty(Pr,"__esModule",{value:!0});function ka(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,".").toLowerCase():""}Pr.default=ka;var Ur={};Object.defineProperty(Ur,"__esModule",{value:!0});function Ta(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"/").toLowerCase():""}Ur.default=Ta;var $r={};Object.defineProperty($r,"__esModule",{value:!0});function Oa(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase():""}$r.default=Oa;var Dr={};Object.defineProperty(Dr,"__esModule",{value:!0});function Sa(r){if(r===void 0&&(r=""),!r)return"";var e=String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(t,n,s){return n+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase();return e.charAt(0).toUpperCase()+e.slice(1)}Dr.default=Sa;var Lr={};Object.defineProperty(Lr,"__esModule",{value:!0});function Na(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase().replace(/( ?)(\w+)( ?)/g,function(e,t,n,s){return t+n.charAt(0).toUpperCase()+n.slice(1)+s}):""}Lr.default=Na;var pr={};Object.defineProperty(pr,"__esModule",{value:!0});function Za(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"-").toLowerCase():""}pr.default=Za;var zr={},Ke={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.belongToTypes=r.isValidObject=r.isArrayObject=r.validateOptions=r.DefaultOption=void 0,r.DefaultOption={recursive:!1,recursiveInArray:!1,keepTypesOnRecursion:[]},r.validateOptions=function(e){return e===void 0&&(e=r.DefaultOption),e.recursive==null?e=r.DefaultOption:e.recursiveInArray==null&&(e.recursiveInArray=!1),e},r.isArrayObject=function(e){return e!=null&&Array.isArray(e)},r.isValidObject=function(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)},r.belongToTypes=function(e,t){return(t||[]).some(function(n){return e instanceof n})}})(Ke);var Ia=Q&&Q.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(zr,"__esModule",{value:!0});var ye=Ke;function jt(r,e){if(e===void 0&&(e=ye.DefaultOption),!ye.isValidObject(r))return null;e=ye.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=n.toLowerCase();e.recursive&&(ye.isValidObject(s)?ye.belongToTypes(s,e.keepTypesOnRecursion)||(s=jt(s,e)):e.recursiveInArray&&ye.isArrayObject(s)&&(s=Ia(s).map(function(i){var o=i;if(ye.isValidObject(i))ye.belongToTypes(o,e.keepTypesOnRecursion)||(o=jt(i,e));else if(ye.isArrayObject(i)){var u=jt({key:i},e);o=u.key}return o}))),t[a]=s}),t}zr.default=jt;var Vr={},Ca=Q&&Q.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(Vr,"__esModule",{value:!0});var ve=Ke;function Rt(r,e){if(e===void 0&&(e=ve.DefaultOption),!ve.isValidObject(r))return null;e=ve.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=n.toUpperCase();e.recursive&&(ve.isValidObject(s)?ve.belongToTypes(s,e.keepTypesOnRecursion)||(s=Rt(s,e)):e.recursiveInArray&&ve.isArrayObject(s)&&(s=Ca(s).map(function(i){var o=i;if(ve.isValidObject(i))ve.belongToTypes(o,e.keepTypesOnRecursion)||(o=Rt(i,e));else if(ve.isArrayObject(i)){var u=Rt({key:i},e);o=u.key}return o}))),t[a]=s}),t}Vr.default=Rt;var Br={},Ea=Q&&Q.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(Br,"__esModule",{value:!0});var ge=Ke,Aa=lr;function Mt(r,e){if(e===void 0&&(e=ge.DefaultOption),!ge.isValidObject(r))return null;e=ge.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=Aa.default(n);e.recursive&&(ge.isValidObject(s)?ge.belongToTypes(s,e.keepTypesOnRecursion)||(s=Mt(s,e)):e.recursiveInArray&&ge.isArrayObject(s)&&(s=Ea(s).map(function(i){var o=i;if(ge.isValidObject(i))ge.belongToTypes(o,e.keepTypesOnRecursion)||(o=Mt(i,e));else if(ge.isArrayObject(i)){var u=Mt({key:i},e);o=u.key}return o}))),t[a]=s}),t}Br.default=Mt;var Kr={},ja=Q&&Q.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(Kr,"__esModule",{value:!0});var _e=Ke,Ra=hr;function Pt(r,e){if(e===void 0&&(e=_e.DefaultOption),!_e.isValidObject(r))return null;e=_e.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=Ra.default(n);e.recursive&&(_e.isValidObject(s)?_e.belongToTypes(s,e.keepTypesOnRecursion)||(s=Pt(s,e)):e.recursiveInArray&&_e.isArrayObject(s)&&(s=ja(s).map(function(i){var o=i;if(_e.isValidObject(i))_e.belongToTypes(o,e.keepTypesOnRecursion)||(o=Pt(i,e));else if(_e.isArrayObject(i)){var u=Pt({key:i},e);o=u.key}return o}))),t[a]=s}),t}Kr.default=Pt;var Wr={},Ma=Q&&Q.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(Wr,"__esModule",{value:!0});var be=Ke,Pa=fr;function Ut(r,e){if(e===void 0&&(e=be.DefaultOption),!be.isValidObject(r))return null;e=be.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=Pa.default(n);e.recursive&&(be.isValidObject(s)?be.belongToTypes(s,e.keepTypesOnRecursion)||(s=Ut(s,e)):e.recursiveInArray&&be.isArrayObject(s)&&(s=Ma(s).map(function(i){var o=i;if(be.isValidObject(i))be.belongToTypes(o,e.keepTypesOnRecursion)||(o=Ut(i,e));else if(be.isArrayObject(i)){var u=Ut({key:i},e);o=u.key}return o}))),t[a]=s}),t}Wr.default=Ut;var Yr={},Ua=Q&&Q.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(Yr,"__esModule",{value:!0});var we=Ke,$a=pr;function $t(r,e){if(e===void 0&&(e=we.DefaultOption),!we.isValidObject(r))return null;e=we.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=$a.default(n);e.recursive&&(we.isValidObject(s)?we.belongToTypes(s,e.keepTypesOnRecursion)||(s=$t(s,e)):e.recursiveInArray&&we.isArrayObject(s)&&(s=Ua(s).map(function(i){var o=i;if(we.isValidObject(i))we.belongToTypes(o,e.keepTypesOnRecursion)||(o=$t(i,e));else if(we.isArrayObject(i)){var u=$t({key:i},e);o=u.key}return o}))),t[a]=s}),t}Yr.default=$t;Object.defineProperty(A,"__esModule",{value:!0});A.kebabKeys=A.pascalKeys=A.snakeKeys=A.camelKeys=A.upperKeys=A.lowerKeys=A.toLowerCase=A.toUpperCase=A.toKebabCase=A.toHeaderCase=A.toSentenceCase=A.toTextCase=A.toPathCase=A.toDotCase=A.toPascalCase=A.toSnakeCase=A.toCamelCase=void 0;var On=lr;A.toCamelCase=On.default;var Sn=hr;A.toSnakeCase=Sn.default;var Nn=fr;A.toPascalCase=Nn.default;var Zn=Pr;A.toDotCase=Zn.default;var In=Ur;A.toPathCase=In.default;var Cn=$r;A.toTextCase=Cn.default;var En=Dr;A.toSentenceCase=En.default;var An=Lr;A.toHeaderCase=An.default;var jn=pr;A.toKebabCase=jn.default;var Rn=zr;A.lowerKeys=Rn.default;var Mn=Vr;A.upperKeys=Mn.default;var Pn=Br;A.camelKeys=Pn.default;var Un=Kr;A.snakeKeys=Un.default;var $n=Wr;A.pascalKeys=$n.default;var Dn=Yr;A.kebabKeys=Dn.default;var Ln=function(r){return String(r||"").toLowerCase()};A.toLowerCase=Ln;var zn=function(r){return String(r||"").toUpperCase()};A.toUpperCase=zn;var Da={toCamelCase:On.default,toSnakeCase:Sn.default,toPascalCase:Nn.default,toDotCase:Zn.default,toPathCase:In.default,toTextCase:Cn.default,toSentenceCase:En.default,toHeaderCase:An.default,toKebabCase:jn.default,toUpperCase:zn,toLowerCase:Ln,lowerKeys:Rn.default,upperKeys:Mn.default,camelKeys:Pn.default,snakeKeys:Un.default,pascalKeys:$n.default,kebabKeys:Dn.default};A.default=Da;var Vn=A;const Bn={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},La=r=>Vn.snakeKeys(r,Bn),za=r=>Vn.camelKeys(r,Bn);var Qt;(r=>{r.toSnake=La,r.toCamel=za,r.capitalize=e=>e[0].toUpperCase()+e.slice(1)})(Qt||(Qt={}));d.object({x:wn.or(Qr),y:xn.or(Qr)});const Va=d.object({x:wn,y:xn}),Ba=Object.freeze({x:"left",y:"top"}),Ka=(r,e)=>r.x===e.x&&r.y===e.y,en=d.union([d.number(),Xt,Mr,gn,ua,ha]),Wa=(r,e)=>{if(typeof r=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return r==="x"?{x:e,y:0}:{x:0,y:e}}return typeof r=="number"?{x:r,y:e??r}:Array.isArray(r)?{x:r[0],y:r[1]}:"signedWidth"in r?{x:r.signedWidth,y:r.signedHeight}:"clientX"in r?{x:r.clientX,y:r.clientY}:"width"in r?{x:r.width,y:r.height}:{x:r.x,y:r.y}},tn={x:0,y:0},Ct=d.union([d.number(),d.string()]);d.object({top:Ct,left:Ct,width:Ct,height:Ct});d.object({left:d.number(),top:d.number(),right:d.number(),bottom:d.number()});d.object({one:Xt,two:Xt,root:Va});const qr=(r,e,t=0,n=0,s)=>{const a={one:{...tn},two:{...tn},root:s??Ba};if(typeof r=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:r,y:e},a.two={x:a.one.x+t,y:a.one.y+n},a}return"one"in r&&"two"in r&&"root"in r?{...r,root:s??r.root}:("getBoundingClientRect"in r&&(r=r.getBoundingClientRect()),"left"in r?(a.one={x:r.left,y:r.top},a.two={x:r.right,y:r.bottom},a):(a.one=r,e==null?a.two={x:a.one.x+t,y:a.one.y+n}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+t}:"width"in e?a.two={x:a.one.x+e.width,y:a.one.y+e.height}:"signedWidth"in e?a.two={x:a.one.x+e.signedWidth,y:a.one.y+e.signedHeight}:a.two=e,a))},br=r=>{const e=qr(r);return{lower:e.one.x,upper:e.two.x}},wr=r=>{const e=qr(r);return{lower:e.one.y,upper:e.two.y}},Ya=r=>typeof r!="object"||r==null?!1:"one"in r&&"two"in r&&"root"in r,qa=d.object({signedWidth:d.number(),signedHeight:d.number()});d.union([gn,qa,Xt,Mr]);const Fa=(r,e,t)=>(e!=null&&(r=Math.max(r,e)),t!=null&&(r=Math.min(r,t)),r);d.object({offset:en,scale:en});const Ga=r=>(e,t,n,s)=>t==="dimension"?[e,n]:[e,s?n-r:n+r],Ha=r=>(e,t,n,s)=>[e,s?n/r:n*r],Ja=r=>(e,t,n)=>{if(e===null)return[r,n];const{lower:s,upper:a}=e,{lower:i,upper:o}=r,u=a-s,c=o-i;if(t==="dimension")return[r,n*(c/u)];const m=(n-s)*(c/u)+i;return[r,m]},Xa=r=>(e,t,n)=>[r,n],Qa=()=>(r,e,t)=>{if(r===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[r,t];const{lower:n,upper:s}=r;return[r,s-(t-n)]},ei=r=>(e,t,n)=>{const{lower:s,upper:a}=r;return n=Fa(n,s,a),[e,n]},Zr=class et{constructor(){p(this,"ops",[]),p(this,"currBounds",null),p(this,"currType",null),p(this,"reversed",!1),this.ops=[]}static translate(e){return new et().translate(e)}static magnify(e){return new et().magnify(e)}static scale(e,t){return new et().scale(e,t)}translate(e){const t=this.new(),n=Ga(e);return n.type="translate",t.ops.push(n),t}magnify(e){const t=this.new(),n=Ha(e);return n.type="magnify",t.ops.push(n),t}scale(e,t){const n=_r(e,t),s=this.new(),a=Ja(n);return a.type="scale",s.ops.push(a),s}clamp(e,t){const n=_r(e,t),s=this.new(),a=ei(n);return a.type="clamp",s.ops.push(a),s}reBound(e,t){const n=_r(e,t),s=this.new(),a=Xa(n);return a.type="re-bound",s.ops.push(a),s}invert(){const e=Qa();e.type="invert";const t=this.new();return t.ops.push(e),t}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new et;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([n,s],a)=>a(n,e,s,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((n,s)=>{if(n.type==="scale"||t.some(([i,o])=>s>=i&&s<=o))return;const a=e.ops.findIndex((i,o)=>i.type==="scale"&&o>s);a!==-1&&t.push([s,a])}),t.forEach(([n,s])=>{const a=e.ops.slice(n,s);a.unshift(e.ops[s]),e.ops.splice(n,s-n+1,...a)}),e.reversed=!e.reversed,e}};p(Zr,"IDENTITY",new Zr);let rn=Zr;const nn=class xe{constructor(e=new rn,t=new rn,n=null){p(this,"x"),p(this,"y"),p(this,"currRoot"),this.x=e,this.y=t,this.currRoot=n}static translate(e,t){return new xe().translate(e,t)}static translateX(e){return new xe().translateX(e)}static translateY(e){return new xe().translateY(e)}static clamp(e){return new xe().clamp(e)}static magnify(e){return new xe().magnify(e)}static scale(e){return new xe().scale(e)}static reBound(e){return new xe().reBound(e)}translate(e,t){const n=Wa(e,t),s=this.copy();return s.x=this.x.translate(n.x),s.y=this.y.translate(n.y),s}translateX(e){const t=this.copy();return t.x=this.x.translate(e),t}translateY(e){const t=this.copy();return t.y=this.y.translate(e),t}magnify(e){const t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){const t=this.copy();if(Ya(e)){const n=this.currRoot;return t.currRoot=e.root,n!=null&&!Ka(n,e.root)&&(n.x!==e.root.x&&(t.x=t.x.invert()),n.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(br(e)),t.y=t.y.scale(wr(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){const t=this.copy();return t.x=this.x.reBound(br(e)),t.y=this.y.reBound(wr(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(br(e)),t.y=this.y.clamp(wr(e)),t}copy(){const e=new xe;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}box(e){return qr(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};p(nn,"IDENTITY",new nn);const Kn=(r,e)=>{const t=new F(e);if(![G.DAY,G.HOUR,G.MINUTE,G.SECOND,G.MILLISECOND,G.MICROSECOND,G.NANOSECOND].some(s=>s.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=r.valueOf()%t.valueOf();return r instanceof F?new F(n):new G(n)},P=class O{constructor(e,t="UTC"){if(p(this,"value"),p(this,"encodeValue",!0),e==null)this.value=O.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*O.MILLISECOND.valueOf();else if(typeof e=="string")this.value=O.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=O.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(n=O.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=O.MAX:e=O.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,t=1,n=1]){const s=new Date(e,t-1,n,0,0,0,0);return new O(BigInt(s.getTime())*O.MILLISECOND.valueOf()).truncate(O.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[n,s,a]=e.split(":");let i="00",o="00";a!=null&&([i,o]=a.split("."));let u=O.hours(parseInt(n??"00",10)).add(O.minutes(parseInt(s??"00",10))).add(O.seconds(parseInt(i??"00",10))).add(O.milliseconds(parseInt(o??"00",10)));return t==="local"&&(u=u.add(O.utcOffset)),u.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return O.parseTimeString(e,t);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new O(BigInt(n.getTime())*O.MILLISECOND.valueOf(),t).valueOf()}fString(e="ISO",t="UTC"){switch(e){case"ISODate":return this.toISOString(t).slice(0,10);case"ISOTime":return this.toISOString(t).slice(11,23);case"time":return this.timeString(!1,t);case"preciseTime":return this.timeString(!0,t);case"date":return this.dateString(t);case"preciseDate":return`${this.dateString(t)} ${this.timeString(!0,t)}`;case"dateTime":return`${this.dateString(t)} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(O.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const n=this.toISOString(t);return e?n.slice(11,23):n.slice(11,19)}dateString(e="UTC"){const t=this.date(),n=t.toLocaleString("default",{month:"short"}),s=t.toLocaleString("default",{day:"numeric"});return`${n} ${s}`}static get utcOffset(){return new G(BigInt(new Date().getTimezoneOffset())*O.MINUTE.valueOf())}static since(e){return new O().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new O(e).valueOf()}span(e){return this.range(e).span}range(e){return new ti(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new O(e).valueOf()}afterEq(e){return this.valueOf()>=new O(e).valueOf()}before(e){return this.valueOf()<new O(e).valueOf()}beforeEq(e){return this.valueOf()<=new O(e).valueOf()}add(e){return new O(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new O(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf()/O.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return Kn(this,e)}get isToday(){return this.truncate(G.DAY).equals(O.now().truncate(G.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new O(new Date)}static max(...e){let t=O.MIN;for(const n of e){const s=new O(n);s.after(t)&&(t=s)}return t}static min(...e){let t=O.MAX;for(const n of e){const s=new O(n);s.before(t)&&(t=s)}return t}static nanoseconds(e){return new O(e)}static microseconds(e){return O.nanoseconds(e*1e3)}static milliseconds(e){return O.microseconds(e*1e3)}static seconds(e){return O.milliseconds(e*1e3)}static minutes(e){return O.seconds(e*60)}static hours(e){return O.minutes(e*60)}static days(e){return O.hours(e*24)}};p(P,"NANOSECOND",P.nanoseconds(1)),p(P,"MICROSECOND",P.microseconds(1)),p(P,"MILLISECOND",P.milliseconds(1)),p(P,"SECOND",P.seconds(1)),p(P,"MINUTE",P.minutes(1)),p(P,"HOUR",P.hours(1)),p(P,"DAY",P.days(1)),p(P,"MAX",new P((1n<<63n)-1n)),p(P,"MIN",new P(0)),p(P,"ZERO",new P(0)),p(P,"z",d.union([d.object({value:d.bigint()}).transform(r=>new P(r.value)),d.string().transform(r=>new P(BigInt(r))),d.instanceof(Number).transform(r=>new P(r)),d.number().transform(r=>new P(r)),d.instanceof(P)]));let F=P;const U=class M{constructor(e){p(this,"value"),p(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new M(e).valueOf()}greaterThan(e){return this.valueOf()>new M(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new M(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new M(e).valueOf()}remainder(e){return Kn(this,e)}truncate(e){return new M(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(M.DAY),t=this.truncate(M.HOUR),n=this.truncate(M.MINUTE),s=this.truncate(M.SECOND),a=this.truncate(M.MILLISECOND),i=this.truncate(M.MICROSECOND),o=this.truncate(M.NANOSECOND),u=e,c=t.sub(e),m=n.sub(t),I=s.sub(n),B=a.sub(s),pe=i.sub(a),me=o.sub(i);let X="";return u.isZero||(X+=`${u.days}d `),c.isZero||(X+=`${c.hours}h `),m.isZero||(X+=`${m.minutes}m `),I.isZero||(X+=`${I.seconds}s `),B.isZero||(X+=`${B.milliseconds}ms `),pe.isZero||(X+=`${pe.microseconds}µs `),me.isZero||(X+=`${me.nanoseconds}ns`),X.trim()}get days(){return Number(this.valueOf()/M.DAY.valueOf())}get hours(){return Number(this.valueOf()/M.HOUR.valueOf())}get minutes(){return Number(this.valueOf()/M.MINUTE.valueOf())}get seconds(){return Number(this.valueOf()/M.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf()/M.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf()/M.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new M(e).valueOf()}add(e){return new M(this.valueOf()+new M(e).valueOf())}sub(e){return new M(this.valueOf()-new M(e).valueOf())}static nanoseconds(e=1){return new M(e)}static microseconds(e=1){return M.nanoseconds(e*1e3)}static milliseconds(e=1){return M.microseconds(e*1e3)}static seconds(e=1){return M.milliseconds(e*1e3)}static minutes(e){return M.seconds(e.valueOf()*60)}static hours(e){return M.minutes(e*60)}static days(e){return M.hours(e*24)}};p(U,"NANOSECOND",U.nanoseconds(1)),p(U,"MICROSECOND",U.microseconds(1)),p(U,"MILLISECOND",U.milliseconds(1)),p(U,"SECOND",U.seconds(1)),p(U,"MINUTE",U.minutes(1)),p(U,"HOUR",U.hours(1)),p(U,"DAY",U.days(1)),p(U,"MAX",new U((1n<<63n)-1n)),p(U,"MIN",new U(0)),p(U,"ZERO",new U(0)),p(U,"z",d.union([d.object({value:d.bigint()}).transform(r=>new U(r.value)),d.string().transform(r=>new U(BigInt(r))),d.instanceof(Number).transform(r=>new U(r)),d.number().transform(r=>new U(r)),d.instanceof(U)]));let G=U;const Et=class Dt extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new Dt(e).valueOf()}get period(){return G.seconds(1/this.valueOf())}sampleCount(e){return new G(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new q(t).valueOf()}span(e){return G.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new Dt(e)}static khz(e){return Dt.hz(e*1e3)}};p(Et,"z",d.union([d.number().transform(r=>new Et(r)),d.instanceof(Number).transform(r=>new Et(r)),d.instanceof(Et)]));const V=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new ri(e*this.valueOf())}};p(V,"UNKNOWN",new V(0)),p(V,"BIT128",new V(16)),p(V,"BIT64",new V(8)),p(V,"BIT32",new V(4)),p(V,"BIT16",new V(2)),p(V,"BIT8",new V(1)),p(V,"z",d.union([d.number().transform(r=>new V(r)),d.instanceof(Number).transform(r=>new V(r)),d.instanceof(V)]));let q=V;const ue=class Lt{constructor(e,t){p(this,"start"),p(this,"end"),typeof e=="object"&&"start"in e?(this.start=new F(e.start),this.end=new F(e.end)):(this.start=new F(e),this.end=new F(t))}get span(){return new G(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}swap(){return new Lt(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e){e=e.makeValid();const t=this.makeValid();return e.start.equals(t.start)?!0:e.end.equals(this.start)||e.start.equals(this.end)?!1:this.contains(e.end)||this.contains(e.start)||e.contains(this.start)||e.contains(this.end)}contains(e){return e instanceof Lt?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new Lt(this.start,this.end);return e.start.after(this.start)&&(t.start=e.start),e.start.after(this.end)&&(t.end=e.start),e.end.before(this.end)&&(t.end=e.end),e.end.before(this.start)&&(t.start=e.end),t}};p(ue,"MAX",new ue(F.MIN,F.MAX)),p(ue,"MIN",new ue(F.MAX,F.MIN)),p(ue,"ZERO",new ue(F.ZERO,F.ZERO)),p(ue,"z",d.union([d.object({start:F.z,end:F.z}).transform(r=>new ue(r.start,r.end)),d.instanceof(ue)]));let ti=ue;const l=class ce extends String{constructor(e){if(e instanceof ce||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const t=ce.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}}throw super(ce.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=ce.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}toString(){return this.valueOf()}get isVariable(){return this.equals(ce.JSON)||this.equals(ce.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(ce.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=ce.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return ce.BIG_INT_TYPES.some(e=>e.equals(this))}};p(l,"UNKNOWN",new l("unknown")),p(l,"FLOAT64",new l("float64")),p(l,"FLOAT32",new l("float32")),p(l,"INT64",new l("int64")),p(l,"INT32",new l("int32")),p(l,"INT16",new l("int16")),p(l,"INT8",new l("int8")),p(l,"UINT64",new l("uint64")),p(l,"UINT32",new l("uint32")),p(l,"UINT16",new l("uint16")),p(l,"UINT8",new l("uint8")),p(l,"BOOLEAN",l.UINT8),p(l,"TIMESTAMP",new l("timestamp")),p(l,"UUID",new l("uuid")),p(l,"STRING",new l("string")),p(l,"JSON",new l("json")),p(l,"ARRAY_CONSTRUCTORS",new Map([[l.UINT8.toString(),Uint8Array],[l.UINT16.toString(),Uint16Array],[l.UINT32.toString(),Uint32Array],[l.UINT64.toString(),BigUint64Array],[l.FLOAT32.toString(),Float32Array],[l.FLOAT64.toString(),Float64Array],[l.INT8.toString(),Int8Array],[l.INT16.toString(),Int16Array],[l.INT32.toString(),Int32Array],[l.INT64.toString(),BigInt64Array],[l.TIMESTAMP.toString(),BigInt64Array],[l.STRING.toString(),Uint8Array],[l.JSON.toString(),Uint8Array],[l.UUID.toString(),Uint8Array]])),p(l,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,l.UINT8],[Uint16Array.name,l.UINT16],[Uint32Array.name,l.UINT32],[BigUint64Array.name,l.UINT64],[Float32Array.name,l.FLOAT32],[Float64Array.name,l.FLOAT64],[Int8Array.name,l.INT8],[Int16Array.name,l.INT16],[Int32Array.name,l.INT32],[BigInt64Array.name,l.INT64]])),p(l,"DENSITIES",new Map([[l.UINT8.toString(),q.BIT8],[l.UINT16.toString(),q.BIT16],[l.UINT32.toString(),q.BIT32],[l.UINT64.toString(),q.BIT64],[l.FLOAT32.toString(),q.BIT32],[l.FLOAT64.toString(),q.BIT64],[l.INT8.toString(),q.BIT8],[l.INT16.toString(),q.BIT16],[l.INT32.toString(),q.BIT32],[l.INT64.toString(),q.BIT64],[l.TIMESTAMP.toString(),q.BIT64],[l.STRING.toString(),q.UNKNOWN],[l.JSON.toString(),q.UNKNOWN],[l.UUID.toString(),q.BIT128]])),p(l,"ALL",[l.UNKNOWN,l.FLOAT64,l.FLOAT32,l.INT64,l.INT32,l.INT16,l.INT8,l.UINT64,l.UINT32,l.UINT16,l.UINT8,l.TIMESTAMP,l.UUID,l.STRING,l.JSON]),p(l,"BIG_INT_TYPES",[l.INT64,l.UINT64,l.TIMESTAMP]),p(l,"z",d.union([d.string().transform(r=>new l(r)),d.instanceof(l)]));const K=class z extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return z.bytes(this.valueOf()+e.valueOf())}sub(e){return z.bytes(this.valueOf()-e.valueOf())}truncate(e){return new z(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return z.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/z.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/z.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/z.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/z.TERABYTE.valueOf()}toString(){const e=this.truncate(z.TERABYTE),t=this.truncate(z.GIGABYTE),n=this.truncate(z.MEGABYTE),s=this.truncate(z.KILOBYTE),a=this.truncate(z.BYTE),i=e,o=t.sub(e),u=n.sub(t),c=s.sub(n),m=a.sub(s);let I="";return i.isZero||(I+=`${i.terabytes}TB `),o.isZero||(I+=`${o.gigabytes}GB `),u.isZero||(I+=`${u.megabytes}MB `),c.isZero||(I+=`${c.kilobytes}KB `),(!m.isZero||I==="")&&(I+=`${m.valueOf()}B`),I.trim()}static bytes(e=1){return new z(e)}static kilobytes(e=1){return z.bytes(e.valueOf()*1e3)}static megabytes(e=1){return z.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return z.megabytes(e.valueOf()*1e3)}static terabytes(e){return z.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};p(K,"BYTE",new K(1)),p(K,"KILOBYTE",K.kilobytes(1)),p(K,"MEGABYTE",K.megabytes(1)),p(K,"GIGABYTE",K.gigabytes(1)),p(K,"TERABYTE",K.terabytes(1)),p(K,"ZERO",new K(0)),p(K,"z",d.union([d.number().transform(r=>new K(r)),d.instanceof(K)]));let ri=K;d.union([d.instanceof(Uint8Array),d.instanceof(Uint16Array),d.instanceof(Uint32Array),d.instanceof(BigUint64Array),d.instanceof(Float32Array),d.instanceof(Float64Array),d.instanceof(Int8Array),d.instanceof(Int16Array),d.instanceof(Int32Array),d.instanceof(BigInt64Array)]);d.record(d.union([d.number(),d.string(),d.symbol()]),d.unknown());const ni=r=>r!=null&&typeof r=="object"&&!Array.isArray(r),Wn=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",si=Wn(),Yn=["MacOS","Windows","Linux","Docker"],ai=d.enum(Yn);let xr;const ii=()=>{if(typeof window>"u")return;const r=window.navigator.userAgent.toLowerCase();if(r.includes("mac"))return"MacOS";if(r.includes("win"))return"Windows";if(r.includes("linux"))return"Linux"},oi=(r={})=>{const{force:e,default:t}=r;return e??xr??(xr=ii(),xr??t)},qn=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:Yn,RUNTIME:si,detect:Wn,getOS:oi,osZ:ai},Symbol.toStringTag,{value:"Module"})),ui=(...r)=>r.map(Fn).join(""),Fn=r=>(r.endsWith("/")||(r+="/"),r.startsWith("/")&&(r=r.slice(1)),r),ci=r=>r.endsWith("/")?r.slice(0,-1):r,di=(r,e="")=>r===null?"":"?"+Object.entries(r).filter(([,t])=>t==null?!1:Array.isArray(t)?t.length>0:!0).map(([t,n])=>`${e}${t}=${n}`).join("&");var We;let li=(We=class{constructor({host:r,port:e,protocol:t="",pathPrefix:n=""}){p(this,"protocol"),p(this,"host"),p(this,"port"),p(this,"path"),this.protocol=t,this.host=r,this.port=e,this.path=Fn(n)}replace(r){return new We({host:r.host??this.host,port:r.port??this.port,protocol:r.protocol??this.protocol,pathPrefix:r.pathPrefix??this.path})}child(r){return new We({...this,pathPrefix:ui(this.path,r)})}toString(){return ci(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}},p(We,"UNKNOWN",new We({host:"unknown",port:0})),We);class hi{constructor(){p(this,"contentType","application/json"),p(this,"decoder"),this.decoder=new TextDecoder}encode(e){const t=JSON.stringify(Qt.toSnake(e),(n,s)=>ArrayBuffer.isView(s)?Array.from(s):ni(s)&&"encode_value"in s?typeof s.value=="bigint"?s.value.toString():s.value:typeof s=="bigint"?s.toString():s);return new TextEncoder().encode(t)}decode(e,t){const n=Qt.toCamel(JSON.parse(this.decoder.decode(e)));return t!=null?t.parse(n):n}static registerCustomType(){}}new hi;var R;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},r.getValidEnumValues=s=>{const a=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return r.objectValues(i)},r.objectValues=s=>r.objectKeys(s).map(function(a){return s[a]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},r.find=(s,a)=>{for(const i of s)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=n,r.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(R||(R={}));var Ir;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Ir||(Ir={}));const v=R.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ie=r=>{switch(typeof r){case"undefined":return v.undefined;case"string":return v.string;case"number":return isNaN(r)?v.nan:v.number;case"boolean":return v.boolean;case"function":return v.function;case"bigint":return v.bigint;case"symbol":return v.symbol;case"object":return Array.isArray(r)?v.array:r===null?v.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?v.promise:typeof Map<"u"&&r instanceof Map?v.map:typeof Set<"u"&&r instanceof Set?v.set:typeof Date<"u"&&r instanceof Date?v.date:v.object;default:return v.unknown}},f=R.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"]),fi=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class se extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},n={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let o=n,u=0;for(;u<i.path.length;){const c=i.path[u];u===i.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(t(i))):o[c]=o[c]||{_errors:[]},o=o[c],u++}}};return s(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,R.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}se.create=r=>new se(r);const ft=(r,e)=>{let t;switch(r.code){case f.invalid_type:r.received===v.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case f.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,R.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:t=`Unrecognized key(s) in object: ${R.joinValues(r.keys,", ")}`;break;case f.invalid_union:t="Invalid input";break;case f.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${R.joinValues(r.options)}`;break;case f.invalid_enum_value:t=`Invalid enum value. Expected ${R.joinValues(r.options)}, received '${r.received}'`;break;case f.invalid_arguments:t="Invalid function arguments";break;case f.invalid_return_type:t="Invalid function return type";break;case f.invalid_date:t="Invalid date";break;case f.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:R.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case f.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case f.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case f.custom:t="Invalid input";break;case f.invalid_intersection_types:t="Intersection results could not be merged";break;case f.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case f.not_finite:t="Number must be finite";break;default:t=e.defaultError,R.assertNever(r)}return{message:t}};let Gn=ft;function pi(r){Gn=r}function er(){return Gn}const tr=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],i={...s,path:a};let o="";const u=n.filter(c=>!!c).slice().reverse();for(const c of u)o=c(i,{data:e,defaultError:o}).message;return{...s,path:a,message:s.message||o}},mi=[];function _(r,e){const t=tr({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,er(),ft].filter(n=>!!n)});r.common.issues.push(t)}class Y{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return T;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t)n.push({key:await s.key,value:await s.value});return Y.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return T;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}}const T=Object.freeze({status:"aborted"}),Hn=r=>({status:"dirty",value:r}),J=r=>({status:"valid",value:r}),Cr=r=>r.status==="aborted",Er=r=>r.status==="dirty",pt=r=>r.status==="valid",rr=r=>typeof Promise<"u"&&r instanceof Promise;var w;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(w||(w={}));class he{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const sn=(r,e)=>{if(pt(e))return{success:!0,data:e.value};if(!r.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 se(r.common.issues);return this._error=t,this._error}}};function Z(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,o)=>i.code!=="invalid_type"?{message:o.defaultError}:typeof o.data>"u"?{message:n??o.defaultError}:{message:t??o.defaultError},description:s}}class 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)}get description(){return this._def.description}_getType(e){return Ie(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Ie(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Y,ctx:{common:e.parent.common,data:e.data,parsedType:Ie(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(rr(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 s={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ie(e)},a=this._parseSync({data:e,path:s.path,parent:s});return sn(s,a)}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:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ie(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(rr(s)?s:Promise.resolve(s));return sn(n,a)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue({code:f.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(u=>u?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new oe({schema:this,typeName:k.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Oe.create(this,this._def)}nullable(){return Be.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ae.create(this,this._def)}promise(){return Qe.create(this,this._def)}or(e){return gt.create([this,e],this._def)}and(e){return _t.create(this,e,this._def)}transform(e){return new oe({...Z(this._def),schema:this,typeName:k.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Tt({...Z(this._def),innerType:this,defaultValue:t,typeName:k.ZodDefault})}brand(){return new Xn({typeName:k.ZodBranded,type:this,...Z(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ir({...Z(this._def),innerType:this,catchValue:t,typeName:k.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Zt.create(this,e)}readonly(){return ur.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const yi=/^c[^\s-]{8,}$/i,vi=/^[a-z][a-z0-9]*$/,gi=/^[0-9A-HJKMNP-TV-Z]{26}$/,_i=/^[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,bi=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,wi="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let kr;const xi=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,ki=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Ti=r=>r.precision?r.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}Z$`):r.precision===0?r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function Oi(r,e){return!!((e==="v4"||!e)&&xi.test(r)||(e==="v6"||!e)&&ki.test(r))}class te extends E{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==v.string){const a=this._getOrReturnCtx(e);return _(a,{code:f.invalid_type,expected:v.string,received:a.parsedType}),T}const n=new Y;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),_(s,{code:f.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),_(s,{code:f.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(s=this._getOrReturnCtx(e,s),i?_(s,{code:f.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&_(s,{code:f.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")bi.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"email",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")kr||(kr=new RegExp(wi,"u")),kr.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"emoji",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")_i.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"uuid",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")yi.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"cuid",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")vi.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"cuid2",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")gi.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"ulid",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),_(s,{validation:"url",code:f.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"regex",code:f.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),_(s,{code:f.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),_(s,{code:f.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),_(s,{code:f.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Ti(a).test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{code:f.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="ip"?Oi(e.data,a.version)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"ip",code:f.invalid_string,message:a.message}),n.dirty()):R.assertNever(a);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:f.invalid_string,...w.errToObj(n)})}_addCheck(e){return new te({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...w.errToObj(e)})}url(e){return this._addCheck({kind:"url",...w.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...w.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...w.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...w.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...w.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...w.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...w.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,...w.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...w.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...w.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...w.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...w.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...w.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...w.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...w.errToObj(t)})}nonempty(e){return this.min(1,w.errToObj(e))}trim(){return new te({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new te({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new te({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}te.create=r=>{var e;return new te({checks:[],typeName:k.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Z(r)})};function Si(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,a=parseInt(r.toFixed(s).replace(".","")),i=parseInt(e.toFixed(s).replace(".",""));return a%i/Math.pow(10,s)}class je extends E{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==v.number){const a=this._getOrReturnCtx(e);return _(a,{code:f.invalid_type,expected:v.number,received:a.parsedType}),T}let n;const s=new Y;for(const a of this._def.checks)a.kind==="int"?R.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),_(n,{code:f.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),_(n,{code:f.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),_(n,{code:f.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Si(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),_(n,{code:f.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),_(n,{code:f.not_finite,message:a.message}),s.dirty()):R.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,w.toString(t))}gt(e,t){return this.setLimit("min",e,!1,w.toString(t))}lte(e,t){return this.setLimit("max",e,!0,w.toString(t))}lt(e,t){return this.setLimit("max",e,!1,w.toString(t))}setLimit(e,t,n,s){return new je({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:w.toString(s)}]})}_addCheck(e){return new je({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:w.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:w.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:w.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:w.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:w.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&R.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}je.create=r=>new je({checks:[],typeName:k.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...Z(r)});class Re extends E{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==v.bigint){const a=this._getOrReturnCtx(e);return _(a,{code:f.invalid_type,expected:v.bigint,received:a.parsedType}),T}let n;const s=new Y;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),_(n,{code:f.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),_(n,{code:f.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),_(n,{code:f.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):R.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,w.toString(t))}gt(e,t){return this.setLimit("min",e,!1,w.toString(t))}lte(e,t){return this.setLimit("max",e,!0,w.toString(t))}lt(e,t){return this.setLimit("max",e,!1,w.toString(t))}setLimit(e,t,n,s){return new Re({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:w.toString(s)}]})}_addCheck(e){return new Re({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:w.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Re.create=r=>{var e;return new Re({checks:[],typeName:k.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Z(r)})};class mt extends E{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==v.boolean){const n=this._getOrReturnCtx(e);return _(n,{code:f.invalid_type,expected:v.boolean,received:n.parsedType}),T}return J(e.data)}}mt.create=r=>new mt({typeName:k.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...Z(r)});class ze extends E{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==v.date){const a=this._getOrReturnCtx(e);return _(a,{code:f.invalid_type,expected:v.date,received:a.parsedType}),T}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return _(a,{code:f.invalid_date}),T}const n=new Y;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),_(s,{code:f.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),_(s,{code:f.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):R.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ze({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:w.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:w.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}ze.create=r=>new ze({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:k.ZodDate,...Z(r)});class nr extends E{_parse(e){if(this._getType(e)!==v.symbol){const n=this._getOrReturnCtx(e);return _(n,{code:f.invalid_type,expected:v.symbol,received:n.parsedType}),T}return J(e.data)}}nr.create=r=>new nr({typeName:k.ZodSymbol,...Z(r)});class yt extends E{_parse(e){if(this._getType(e)!==v.undefined){const n=this._getOrReturnCtx(e);return _(n,{code:f.invalid_type,expected:v.undefined,received:n.parsedType}),T}return J(e.data)}}yt.create=r=>new yt({typeName:k.ZodUndefined,...Z(r)});class vt extends E{_parse(e){if(this._getType(e)!==v.null){const n=this._getOrReturnCtx(e);return _(n,{code:f.invalid_type,expected:v.null,received:n.parsedType}),T}return J(e.data)}}vt.create=r=>new vt({typeName:k.ZodNull,...Z(r)});class Xe extends E{constructor(){super(...arguments),this._any=!0}_parse(e){return J(e.data)}}Xe.create=r=>new Xe({typeName:k.ZodAny,...Z(r)});class Ue extends E{constructor(){super(...arguments),this._unknown=!0}_parse(e){return J(e.data)}}Ue.create=r=>new Ue({typeName:k.ZodUnknown,...Z(r)});class Ne extends E{_parse(e){const t=this._getOrReturnCtx(e);return _(t,{code:f.invalid_type,expected:v.never,received:t.parsedType}),T}}Ne.create=r=>new Ne({typeName:k.ZodNever,...Z(r)});class sr extends E{_parse(e){if(this._getType(e)!==v.undefined){const n=this._getOrReturnCtx(e);return _(n,{code:f.invalid_type,expected:v.void,received:n.parsedType}),T}return J(e.data)}}sr.create=r=>new sr({typeName:k.ZodVoid,...Z(r)});class ae extends E{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==v.array)return _(t,{code:f.invalid_type,expected:v.array,received:t.parsedType}),T;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(_(t,{code:i?f.too_big:f.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(_(t,{code:f.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(_(t,{code:f.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new he(t,i,t.path,o)))).then(i=>Y.mergeArray(n,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new he(t,i,t.path,o)));return Y.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new ae({...this._def,minLength:{value:e,message:w.toString(t)}})}max(e,t){return new ae({...this._def,maxLength:{value:e,message:w.toString(t)}})}length(e,t){return new ae({...this._def,exactLength:{value:e,message:w.toString(t)}})}nonempty(e){return this.min(1,e)}}ae.create=(r,e)=>new ae({type:r,minLength:null,maxLength:null,exactLength:null,typeName:k.ZodArray,...Z(e)});function qe(r){if(r instanceof D){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=Oe.create(qe(n))}return new D({...r._def,shape:()=>e})}else return r instanceof ae?new ae({...r._def,type:qe(r.element)}):r instanceof Oe?Oe.create(qe(r.unwrap())):r instanceof Be?Be.create(qe(r.unwrap())):r instanceof fe?fe.create(r.items.map(e=>qe(e))):r}class D extends E{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=R.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==v.object){const c=this._getOrReturnCtx(e);return _(c,{code:f.invalid_type,expected:v.object,received:c.parsedType}),T}const{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof Ne&&this._def.unknownKeys==="strip"))for(const c in s.data)i.includes(c)||o.push(c);const u=[];for(const c of i){const m=a[c],I=s.data[c];u.push({key:{status:"valid",value:c},value:m._parse(new he(s,I,s.path,c)),alwaysSet:c in s.data})}if(this._def.catchall instanceof Ne){const c=this._def.unknownKeys;if(c==="passthrough")for(const m of o)u.push({key:{status:"valid",value:m},value:{status:"valid",value:s.data[m]}});else if(c==="strict")o.length>0&&(_(s,{code:f.unrecognized_keys,keys:o}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const m of o){const I=s.data[m];u.push({key:{status:"valid",value:m},value:c._parse(new he(s,I,s.path,m)),alwaysSet:m in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const c=[];for(const m of u){const I=await m.key;c.push({key:I,value:await m.value,alwaysSet:m.alwaysSet})}return c}).then(c=>Y.mergeObjectSync(n,c)):Y.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return w.errToObj,new D({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,a,i,o;const u=(i=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,n).message)!==null&&i!==void 0?i:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=w.errToObj(e).message)!==null&&o!==void 0?o:u}:{message:u}}}:{}})}strip(){return new D({...this._def,unknownKeys:"strip"})}passthrough(){return new D({...this._def,unknownKeys:"passthrough"})}extend(e){return new D({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new D({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:k.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new D({...this._def,catchall:e})}pick(e){const t={};return R.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new D({...this._def,shape:()=>t})}omit(e){const t={};return R.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new D({...this._def,shape:()=>t})}deepPartial(){return qe(this)}partial(e){const t={};return R.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new D({...this._def,shape:()=>t})}required(e){const t={};return R.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof Oe;)a=a._def.innerType;t[n]=a}}),new D({...this._def,shape:()=>t})}keyof(){return Jn(R.objectKeys(this.shape))}}D.create=(r,e)=>new D({shape:()=>r,unknownKeys:"strip",catchall:Ne.create(),typeName:k.ZodObject,...Z(e)});D.strictCreate=(r,e)=>new D({shape:()=>r,unknownKeys:"strict",catchall:Ne.create(),typeName:k.ZodObject,...Z(e)});D.lazycreate=(r,e)=>new D({shape:r,unknownKeys:"strip",catchall:Ne.create(),typeName:k.ZodObject,...Z(e)});class gt extends E{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new se(o.ctx.common.issues));return _(t,{code:f.invalid_union,unionErrors:i}),T}if(t.common.async)return Promise.all(n.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let a;const i=[];for(const u of n){const c={...t,common:{...t.common,issues:[]},parent:null},m=u._parseSync({data:t.data,path:t.path,parent:c});if(m.status==="valid")return m;m.status==="dirty"&&!a&&(a={result:m,ctx:c}),c.common.issues.length&&i.push(c.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(u=>new se(u));return _(t,{code:f.invalid_union,unionErrors:o}),T}}get options(){return this._def.options}}gt.create=(r,e)=>new gt({options:r,typeName:k.ZodUnion,...Z(e)});const zt=r=>r instanceof wt?zt(r.schema):r instanceof oe?zt(r.innerType()):r instanceof xt?[r.value]:r instanceof Me?r.options:r instanceof kt?Object.keys(r.enum):r instanceof Tt?zt(r._def.innerType):r instanceof yt?[void 0]:r instanceof vt?[null]:null;class mr extends E{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==v.object)return _(t,{code:f.invalid_type,expected:v.object,received:t.parsedType}),T;const n=this.discriminator,s=t.data[n],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(_(t,{code:f.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),T)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const a of t){const i=zt(a.shape[e]);if(!i)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new mr({typeName:k.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...Z(n)})}}function Ar(r,e){const t=Ie(r),n=Ie(e);if(r===e)return{valid:!0,data:r};if(t===v.object&&n===v.object){const s=R.objectKeys(e),a=R.objectKeys(r).filter(o=>s.indexOf(o)!==-1),i={...r,...e};for(const o of a){const u=Ar(r[o],e[o]);if(!u.valid)return{valid:!1};i[o]=u.data}return{valid:!0,data:i}}else if(t===v.array&&n===v.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<r.length;a++){const i=r[a],o=e[a],u=Ar(i,o);if(!u.valid)return{valid:!1};s.push(u.data)}return{valid:!0,data:s}}else return t===v.date&&n===v.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class _t extends E{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(Cr(a)||Cr(i))return T;const o=Ar(a.value,i.value);return o.valid?((Er(a)||Er(i))&&t.dirty(),{status:t.value,value:o.data}):(_(n,{code:f.invalid_intersection_types}),T)};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(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}_t.create=(r,e,t)=>new _t({left:r,right:e,typeName:k.ZodIntersection,...Z(t)});class fe extends E{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==v.array)return _(n,{code:f.invalid_type,expected:v.array,received:n.parsedType}),T;if(n.data.length<this._def.items.length)return _(n,{code:f.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),T;!this._def.rest&&n.data.length>this._def.items.length&&(_(n,{code:f.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...n.data].map((i,o)=>{const u=this._def.items[o]||this._def.rest;return u?u._parse(new he(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>Y.mergeArray(t,i)):Y.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new fe({...this._def,rest:e})}}fe.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new fe({items:r,typeName:k.ZodTuple,rest:null,...Z(e)})};class bt 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!==v.object)return _(n,{code:f.invalid_type,expected:v.object,received:n.parsedType}),T;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)s.push({key:a._parse(new he(n,o,n.path,o)),value:i._parse(new he(n,n.data[o],n.path,o))});return n.common.async?Y.mergeObjectAsync(t,s):Y.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof E?new bt({keyType:e,valueType:t,typeName:k.ZodRecord,...Z(n)}):new bt({keyType:te.create(),valueType:e,typeName:k.ZodRecord,...Z(t)})}}class ar 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!==v.map)return _(n,{code:f.invalid_type,expected:v.map,received:n.parsedType}),T;const s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,u],c)=>({key:s._parse(new he(n,o,n.path,[c,"key"])),value:a._parse(new he(n,u,n.path,[c,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const u of i){const c=await u.key,m=await u.value;if(c.status==="aborted"||m.status==="aborted")return T;(c.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(c.value,m.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const u of i){const c=u.key,m=u.value;if(c.status==="aborted"||m.status==="aborted")return T;(c.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(c.value,m.value)}return{status:t.value,value:o}}}}ar.create=(r,e,t)=>new ar({valueType:e,keyType:r,typeName:k.ZodMap,...Z(t)});class Ve extends E{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==v.set)return _(n,{code:f.invalid_type,expected:v.set,received:n.parsedType}),T;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(_(n,{code:f.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(_(n,{code:f.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function i(u){const c=new Set;for(const m of u){if(m.status==="aborted")return T;m.status==="dirty"&&t.dirty(),c.add(m.value)}return{status:t.value,value:c}}const o=[...n.data.values()].map((u,c)=>a._parse(new he(n,u,n.path,c)));return n.common.async?Promise.all(o).then(u=>i(u)):i(o)}min(e,t){return new Ve({...this._def,minSize:{value:e,message:w.toString(t)}})}max(e,t){return new Ve({...this._def,maxSize:{value:e,message:w.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Ve.create=(r,e)=>new Ve({valueType:r,minSize:null,maxSize:null,typeName:k.ZodSet,...Z(e)});class Ge extends E{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==v.function)return _(t,{code:f.invalid_type,expected:v.function,received:t.parsedType}),T;function n(o,u){return tr({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,er(),ft].filter(c=>!!c),issueData:{code:f.invalid_arguments,argumentsError:u}})}function s(o,u){return tr({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,er(),ft].filter(c=>!!c),issueData:{code:f.invalid_return_type,returnTypeError:u}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Qe){const o=this;return J(async function(...u){const c=new se([]),m=await o._def.args.parseAsync(u,a).catch(pe=>{throw c.addIssue(n(u,pe)),c}),I=await Reflect.apply(i,this,m);return await o._def.returns._def.type.parseAsync(I,a).catch(pe=>{throw c.addIssue(s(I,pe)),c})})}else{const o=this;return J(function(...u){const c=o._def.args.safeParse(u,a);if(!c.success)throw new se([n(u,c.error)]);const m=Reflect.apply(i,this,c.data),I=o._def.returns.safeParse(m,a);if(!I.success)throw new se([s(m,I.error)]);return I.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ge({...this._def,args:fe.create(e).rest(Ue.create())})}returns(e){return new Ge({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Ge({args:e||fe.create([]).rest(Ue.create()),returns:t||Ue.create(),typeName:k.ZodFunction,...Z(n)})}}class wt 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})}}wt.create=(r,e)=>new wt({getter:r,typeName:k.ZodLazy,...Z(e)});class xt extends E{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return _(t,{received:t.data,code:f.invalid_literal,expected:this._def.value}),T}return{status:"valid",value:e.data}}get value(){return this._def.value}}xt.create=(r,e)=>new xt({value:r,typeName:k.ZodLiteral,...Z(e)});function Jn(r,e){return new Me({values:r,typeName:k.ZodEnum,...Z(e)})}class Me extends E{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return _(t,{expected:R.joinValues(n),received:t.parsedType,code:f.invalid_type}),T}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),n=this._def.values;return _(t,{received:t.data,code:f.invalid_enum_value,options:n}),T}return J(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return Me.create(e)}exclude(e){return Me.create(this.options.filter(t=>!e.includes(t)))}}Me.create=Jn;class kt extends E{_parse(e){const t=R.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==v.string&&n.parsedType!==v.number){const s=R.objectValues(t);return _(n,{expected:R.joinValues(s),received:n.parsedType,code:f.invalid_type}),T}if(t.indexOf(e.data)===-1){const s=R.objectValues(t);return _(n,{received:n.data,code:f.invalid_enum_value,options:s}),T}return J(e.data)}get enum(){return this._def.values}}kt.create=(r,e)=>new kt({values:r,typeName:k.ZodNativeEnum,...Z(e)});class Qe extends E{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==v.promise&&t.common.async===!1)return _(t,{code:f.invalid_type,expected:v.promise,received:t.parsedType}),T;const n=t.parsedType===v.promise?t.data:Promise.resolve(t.data);return J(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Qe.create=(r,e)=>new Qe({type:r,typeName:k.ZodPromise,...Z(e)});class oe extends E{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===k.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{_(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(n.data,a);return n.common.issues.length?{status:"dirty",value:n.data}:n.common.async?Promise.resolve(i).then(o=>this._def.schema._parseAsync({data:o,path:n.path,parent:n})):this._def.schema._parseSync({data:i,path:n.path,parent:n})}if(s.type==="refinement"){const i=o=>{const u=s.refinement(o,a);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?T:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?T:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!pt(i))return i;const o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>pt(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);R.assertNever(s)}}oe.create=(r,e,t)=>new oe({schema:r,typeName:k.ZodEffects,effect:e,...Z(t)});oe.createWithPreprocess=(r,e,t)=>new oe({schema:e,effect:{type:"preprocess",transform:r},typeName:k.ZodEffects,...Z(t)});class Oe extends E{_parse(e){return this._getType(e)===v.undefined?J(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Oe.create=(r,e)=>new Oe({innerType:r,typeName:k.ZodOptional,...Z(e)});class Be extends E{_parse(e){return this._getType(e)===v.null?J(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Be.create=(r,e)=>new Be({innerType:r,typeName:k.ZodNullable,...Z(e)});class Tt extends E{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===v.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Tt.create=(r,e)=>new Tt({innerType:r,typeName:k.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Z(e)});class ir extends E{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return rr(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new se(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new se(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}ir.create=(r,e)=>new ir({innerType:r,typeName:k.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Z(e)});class or extends E{_parse(e){if(this._getType(e)!==v.nan){const n=this._getOrReturnCtx(e);return _(n,{code:f.invalid_type,expected:v.nan,received:n.parsedType}),T}return{status:"valid",value:e.data}}}or.create=r=>new or({typeName:k.ZodNaN,...Z(r)});const Ni=Symbol("zod_brand");class Xn 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}}class Zt extends E{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?T:a.status==="dirty"?(t.dirty(),Hn(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?T:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new Zt({in:e,out:t,typeName:k.ZodPipeline})}}class ur extends E{_parse(e){const t=this._def.innerType._parse(e);return pt(t)&&(t.value=Object.freeze(t.value)),t}}ur.create=(r,e)=>new ur({innerType:r,typeName:k.ZodReadonly,...Z(e)});const Qn=(r,e={},t)=>r?Xe.create().superRefine((n,s)=>{var a,i;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,c=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...c,fatal:u})}}):Xe.create(),Zi={object:D.lazycreate};var k;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(k||(k={}));const Ii=(r,e={message:`Input not instance of ${r.name}`})=>Qn(t=>t instanceof r,e),es=te.create,ts=je.create,Ci=or.create,Ei=Re.create,rs=mt.create,Ai=ze.create,ji=nr.create,Ri=yt.create,Mi=vt.create,Pi=Xe.create,Ui=Ue.create,$i=Ne.create,Di=sr.create,Li=ae.create,zi=D.create,Vi=D.strictCreate,Bi=gt.create,Ki=mr.create,Wi=_t.create,Yi=fe.create,qi=bt.create,Fi=ar.create,Gi=Ve.create,Hi=Ge.create,Ji=wt.create,Xi=xt.create,Qi=Me.create,eo=kt.create,to=Qe.create,an=oe.create,ro=Oe.create,no=Be.create,so=oe.createWithPreprocess,ao=Zt.create,io=()=>es().optional(),oo=()=>ts().optional(),uo=()=>rs().optional(),co={string:r=>te.create({...r,coerce:!0}),number:r=>je.create({...r,coerce:!0}),boolean:r=>mt.create({...r,coerce:!0}),bigint:r=>Re.create({...r,coerce:!0}),date:r=>ze.create({...r,coerce:!0})},lo=T;var ke=Object.freeze({__proto__:null,defaultErrorMap:ft,setErrorMap:pi,getErrorMap:er,makeIssue:tr,EMPTY_PATH:mi,addIssueToContext:_,ParseStatus:Y,INVALID:T,DIRTY:Hn,OK:J,isAborted:Cr,isDirty:Er,isValid:pt,isAsync:rr,get util(){return R},get objectUtil(){return Ir},ZodParsedType:v,getParsedType:Ie,ZodType:E,ZodString:te,ZodNumber:je,ZodBigInt:Re,ZodBoolean:mt,ZodDate:ze,ZodSymbol:nr,ZodUndefined:yt,ZodNull:vt,ZodAny:Xe,ZodUnknown:Ue,ZodNever:Ne,ZodVoid:sr,ZodArray:ae,ZodObject:D,ZodUnion:gt,ZodDiscriminatedUnion:mr,ZodIntersection:_t,ZodTuple:fe,ZodRecord:bt,ZodMap:ar,ZodSet:Ve,ZodFunction:Ge,ZodLazy:wt,ZodLiteral:xt,ZodEnum:Me,ZodNativeEnum:kt,ZodPromise:Qe,ZodEffects:oe,ZodTransformer:oe,ZodOptional:Oe,ZodNullable:Be,ZodDefault:Tt,ZodCatch:ir,ZodNaN:or,BRAND:Ni,ZodBranded:Xn,ZodPipeline:Zt,ZodReadonly:ur,custom:Qn,Schema:E,ZodSchema:E,late:Zi,get ZodFirstPartyTypeKind(){return k},coerce:co,any:Pi,array:Li,bigint:Ei,boolean:rs,date:Ai,discriminatedUnion:Ki,effect:an,enum:Qi,function:Hi,instanceof:Ii,intersection:Wi,lazy:Ji,literal:Xi,map:Fi,nan:Ci,nativeEnum:eo,never:$i,null:Mi,nullable:no,number:ts,object:zi,oboolean:uo,onumber:oo,optional:ro,ostring:io,pipeline:ao,preprocess:so,promise:to,record:qi,set:Gi,strictObject:Vi,string:es,symbol:ji,transformer:an,tuple:Yi,undefined:Ri,union:Bi,unknown:Ui,void:Di,NEVER:lo,ZodIssueCode:f,quotelessJson:fi,ZodError:se});class It extends Error{constructor(t,n){super(t);L(this,"discriminator","FreighterError");L(this,"type");this.type=n}}const ho=r=>{if(r==null||typeof r!="object")return!1;const e=r;if(e.discriminator!=="FreighterError")return!1;if(!("type"in e))throw new Error(`Freighter error is missing its type property: ${JSON.stringify(e)}`);return!0},jr="unknown",on="nil",yr="freighter",Fr=ke.object({type:ke.string(),data:ke.string()});class fo{constructor(){L(this,"providers",[])}register(e){this.providers.push(e)}encode(e){if(e==null)return{type:on,data:""};if(ho(e))for(const t of this.providers){const n=t.encode(e);if(n!=null)return n}return{type:jr,data:JSON.stringify(e)}}decode(e){if(e==null||e.type===on)return null;if(e.type===jr)return new un(e.data);for(const t of this.providers){const n=t.decode(e);if(n!=null)return n}return new un(e.data)}}const Gr=new fo,ns=({encode:r,decode:e})=>Gr.register({encode:r,decode:e}),po=r=>Gr.encode(r),Hr=r=>Gr.decode(r);class un extends It{constructor(e){super(e,jr)}}class Ot extends It{constructor(){super("EOF",yr)}}class St extends It{constructor(){super("StreamClosed",yr)}}class vr extends It{constructor(t={}){const{message:n="Unreachable",url:s=li.UNKNOWN}=t;super(n,yr);L(this,"url");this.url=s}}const Vt="freighter",mo=r=>{if(r.type!==yr)return null;if(r instanceof Ot)return{type:Vt,data:"EOF"};if(r instanceof St)return{type:Vt,data:"StreamClosed"};if(r instanceof vr)return{type:Vt,data:"Unreachable"};throw new Error(`Unknown error type: ${r.type}: ${r.message}`)},yo=r=>{if(r.type!==Vt)return null;switch(r.data){case"EOF":return new Ot;case"StreamClosed":return new St;case"Unreachable":return new vr;default:throw new Error(`Unknown error type: ${r.data}`)}};ns({encode:mo,decode:yo});class ss{constructor(){L(this,"middleware",[])}use(...e){this.middleware.push(...e)}async executeMiddleware(e,t){let n=0;const s=async a=>{if(n===this.middleware.length)return await t(a);const i=this.middleware[n];return n++,await i(a,s)};return await s(e)}}const as="Content-Type",cn=r=>{if(qn.RUNTIME!=="node")return fetch;const e=require("node-fetch");if(r==="http")return e;const t=require("https"),n=new t.Agent({rejectUnauthorized:!1});return async(s,a)=>await e(s,{...a,agent:n})};class vo extends ss{constructor(t,n,s=!1){super();L(this,"endpoint");L(this,"encoder");L(this,"fetch");return this.endpoint=t.replace({protocol:s?"https":"http"}),this.encoder=n,this.fetch=cn(this.endpoint.protocol),new Proxy(this,{get:(a,i,o)=>i==="endpoint"?this.endpoint:Reflect.get(a,i,o)})}get headers(){return{[as]:this.encoder.contentType}}async send(t,n,s,a){n=s==null?void 0:s.parse(n);let i=null;const o=this.endpoint.child(t),u={};u.method="POST",u.body=this.encoder.encode(n??{});const[,c]=await this.executeMiddleware({target:o.toString(),protocol:this.endpoint.protocol,params:{},role:"client"},async m=>{const I={...m,params:{}};u.headers={...this.headers,...m.params};let B;try{B=await cn(m.protocol)(m.target,u)}catch(me){let X=me;return X.message==="Load failed"&&(X=new vr({url:o})),[I,X]}const pe=await B.arrayBuffer();if(B!=null&&B.ok)return a!=null&&(i=this.encoder.decode(pe,a)),[I,null];try{if(B.status!==400)return[I,new Error(B.statusText)];const me=this.encoder.decode(pe,Fr),X=Hr(me);return[I,X]}catch(me){return[I,new Error(`[freighter] - failed to decode error: ${B.statusText}: ${me.message}`)]}});return[i,c]}}const go=async(r,e,t,n,s)=>{const[a,i]=await r.send(e,t,n,s);if(i!=null)throw i;return a},_o=()=>qn.RUNTIME!=="node"?r=>new WebSocket(r):r=>new(require("ws")).WebSocket(r,{rejectUnauthorized:!1}),bo=ke.object({type:ke.union([ke.literal("data"),ke.literal("close")]),payload:ke.unknown().optional(),error:ke.optional(Fr)});class wo{constructor(e,t,n,s){L(this,"encoder");L(this,"reqSchema");L(this,"resSchema");L(this,"ws");L(this,"serverClosed");L(this,"sendClosed");L(this,"receiveDataQueue",[]);L(this,"receiveCallbacksQueue",[]);this.encoder=t,this.reqSchema=n,this.resSchema=s,this.ws=e,this.sendClosed=!1,this.serverClosed=null,this.listenForMessages()}send(e){if(this.serverClosed!=null)return new Ot;if(this.sendClosed)throw new St;return this.ws.send(this.encoder.encode({type:"data",payload:e})),null}async receive(){if(this.serverClosed!=null)return[null,this.serverClosed];const e=await this.receiveMsg();if(e.type==="close"){if(e.error==null)throw new Error("Message error must be defined");return this.serverClosed=Hr(e.error),[null,this.serverClosed]}return[this.resSchema.parse(e.payload),null]}received(){return this.receiveDataQueue.length!==0}closeSend(){if(this.sendClosed||this.serverClosed!=null)return;const e={type:"close"};try{this.ws.send(this.encoder.encode(e))}finally{this.sendClosed=!0}}async receiveMsg(){const e=this.receiveDataQueue.shift();return e??await new Promise((t,n)=>this.receiveCallbacksQueue.push({resolve:t,reject:n}))}listenForMessages(){this.ws.onmessage=e=>{const t=this.encoder.decode(e.data,bo),n=this.receiveCallbacksQueue.shift();n!=null?n.resolve(t):this.receiveDataQueue.push(t)},this.ws.onclose=e=>{this.serverClosed=So(e)?new Ot:new St}}}const xo="freighterctx",ko=1e3,To=1001,Oo=[ko,To],So=r=>Oo.includes(r.code),cr=class cr extends ss{constructor(t,n,s=!1){super();L(this,"baseUrl");L(this,"encoder");this.baseUrl=t.replace({protocol:s?"wss":"ws"}),this.encoder=n}async stream(t,n,s){const a=_o();let i;const[,o]=await this.executeMiddleware({target:t,protocol:"websocket",params:{},role:"client"},async u=>{const c=a(this.buildURL(t,u)),m={...u,params:{}};c.binaryType=cr.MESSAGE_TYPE;const I=await this.wrapSocket(c,n,s);return I instanceof Error?[m,I]:(i=I,[m,null])});if(o!=null)throw o;return i}buildURL(t,n){const s=di({[as]:this.encoder.contentType,...n.params},xo);return this.baseUrl.child(t).toString()+s}async wrapSocket(t,n,s){return await new Promise(a=>{t.onopen=()=>{a(new wo(t,this.encoder,n,s))},t.onerror=i=>{const o=i;a(new Error(o.message))}})}};L(cr,"MESSAGE_TYPE","arraybuffer");let Rr=cr;exports.BaseTypedError=It;exports.EOF=Ot;exports.HTTPClient=vo;exports.StreamClosed=St;exports.Unreachable=vr;exports.WebSocketClient=Rr;exports.decodeError=Hr;exports.encodeError=po;exports.errorZ=Fr;exports.registerError=ns;exports.sendRequired=go;
2
2
  //# sourceMappingURL=freighter.cjs.map