@synnaxlabs/client 0.15.3 → 0.16.3

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.
@@ -0,0 +1,21 @@
1
+ "use strict";var Xh=Object.defineProperty;var Qh=(r,e,t)=>e in r?Xh(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var h=(r,e,t)=>(Qh(r,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("zod");var ef=Object.defineProperty,tf=(r,e,t)=>e in r?ef(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,A=(r,e,t)=>(tf(r,typeof e!="symbol"?e+"":e,t),t),wn;let rf="_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",nf=(r=21)=>{let e="",t=r;for(;t--;)e+=rf[Math.random()*64|0];return e};const sf=r=>r!=null&&typeof r=="object"&&"toString"in r,af=(r,e=!1)=>{const t=sf(r)?"stringer":typeof r;let n;switch(t){case"string":n=(s,a)=>s.localeCompare(a);break;case"stringer":n=(s,a)=>s.toString().localeCompare(a.toString());break;case"number":n=(s,a)=>s-a;break;case"bigint":n=(s,a)=>s-a>BigInt(0)?1:-1;break;case"boolean":n=(s,a)=>Number(s)-Number(a);break;default:return console.warn("sortFunc: unknown type"),()=>-1}return e?of(n):n},of=r=>(e,t)=>r(t,e);var Oe;(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})(Oe||(Oe={}));var yo;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(yo||(yo={}));const M=Oe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),jr=r=>{switch(typeof r){case"undefined":return M.undefined;case"string":return M.string;case"number":return isNaN(r)?M.nan:M.number;case"boolean":return M.boolean;case"function":return M.function;case"bigint":return M.bigint;case"symbol":return M.symbol;case"object":return Array.isArray(r)?M.array:r===null?M.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?M.promise:typeof Map<"u"&&r instanceof Map?M.map:typeof Set<"u"&&r instanceof Set?M.set:typeof Date<"u"&&r instanceof Date?M.date:M.object;default:return M.unknown}},C=Oe.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"]),cf=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Pt 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,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return s(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,Oe.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()}}Pt.create=r=>new Pt(r);const rs=(r,e)=>{let t;switch(r.code){case C.invalid_type:r.received===M.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case C.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Oe.jsonStringifyReplacer)}`;break;case C.unrecognized_keys:t=`Unrecognized key(s) in object: ${Oe.joinValues(r.keys,", ")}`;break;case C.invalid_union:t="Invalid input";break;case C.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Oe.joinValues(r.options)}`;break;case C.invalid_enum_value:t=`Invalid enum value. Expected ${Oe.joinValues(r.options)}, received '${r.received}'`;break;case C.invalid_arguments:t="Invalid function arguments";break;case C.invalid_return_type:t="Invalid function return type";break;case C.invalid_date:t="Invalid date";break;case C.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}"`:Oe.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case C.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 C.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 C.custom:t="Invalid input";break;case C.invalid_intersection_types:t="Intersection results could not be merged";break;case C.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case C.not_finite:t="Number must be finite";break;default:t=e.defaultError,Oe.assertNever(r)}return{message:t}};let Gu=rs;function uf(r){Gu=r}function Da(){return Gu}const Ma=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],i={...s,path:a};let o="";const c=n.filter(l=>!!l).slice().reverse();for(const l of c)o=l(i,{data:e,defaultError:o}).message;return{...s,path:a,message:s.message||o}},lf=[];function B(r,e){const t=Ma({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Da(),rs].filter(n=>!!n)});r.common.issues.push(t)}class ot{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 te;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 ot.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 te;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 te=Object.freeze({status:"aborted"}),Hu=r=>({status:"dirty",value:r}),mt=r=>({status:"valid",value:r}),go=r=>r.status==="aborted",vo=r=>r.status==="dirty",ns=r=>r.status==="valid",$a=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 Gt{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 Jc=(r,e)=>{if(ns(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 Pt(r.common.issues);return this._error=t,this._error}}};function ie(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 le{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 jr(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:jr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ot,ctx:{common:e.parent.common,data:e.data,parsedType:jr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if($a(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:jr(e)},a=this._parseSync({data:e,path:s.path,parent:s});return Jc(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:jr(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await($a(s)?s:Promise.resolve(s));return Jc(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:C.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!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 Lt({schema:this,typeName:J.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return br.create(this,this._def)}nullable(){return ln.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ut.create(this,this._def)}promise(){return Zn.create(this,this._def)}or(e){return os.create([this,e],this._def)}and(e){return cs.create(this,e,this._def)}transform(e){return new Lt({...ie(this._def),schema:this,typeName:J.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new fs({...ie(this._def),innerType:this,defaultValue:t,typeName:J.ZodDefault})}brand(){return new Qu({typeName:J.ZodBranded,type:this,...ie(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Ka({...ie(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 qs.create(this,e)}readonly(){return Wa.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const df=/^c[^\s-]{8,}$/i,hf=/^[a-z][a-z0-9]*$/,ff=/^[0-9A-HJKMNP-TV-Z]{26}$/,pf=/^[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,mf=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,yf="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ji;const gf=/^(((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}))$/,vf=/^(([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})))$/,wf=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 _f(r,e){return!!((e==="v4"||!e)&&gf.test(r)||(e==="v6"||!e)&&vf.test(r))}class jt extends le{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==M.string){const a=this._getOrReturnCtx(e);return B(a,{code:C.invalid_type,expected:M.string,received:a.parsedType}),te}const n=new ot;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),B(s,{code:C.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),B(s,{code:C.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?B(s,{code:C.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&B(s,{code:C.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")mf.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"email",code:C.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")Ji||(Ji=new RegExp(yf,"u")),Ji.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"emoji",code:C.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")pf.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"uuid",code:C.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")df.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"cuid",code:C.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")hf.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"cuid2",code:C.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")ff.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"ulid",code:C.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),B(s,{validation:"url",code:C.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),B(s,{validation:"regex",code:C.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),B(s,{code:C.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),B(s,{code:C.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),B(s,{code:C.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?wf(a).test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{code:C.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="ip"?_f(e.data,a.version)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"ip",code:C.invalid_string,message:a.message}),n.dirty()):Oe.assertNever(a);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:C.invalid_string,...W.errToObj(n)})}_addCheck(e){return new jt({...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 jt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new jt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new jt({...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}}jt.create=r=>{var e;return new jt({checks:[],typeName:J.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...ie(r)})};function bf(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 Mr extends le{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)!==M.number){const a=this._getOrReturnCtx(e);return B(a,{code:C.invalid_type,expected:M.number,received:a.parsedType}),te}let n;const s=new ot;for(const a of this._def.checks)a.kind==="int"?Oe.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{code:C.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),B(n,{code:C.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),B(n,{code:C.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?bf(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),B(n,{code:C.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{code:C.not_finite,message:a.message}),s.dirty()):Oe.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 Mr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:W.toString(s)}]})}_addCheck(e){return new Mr({...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"&&Oe.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)}}Mr.create=r=>new Mr({checks:[],typeName:J.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...ie(r)});class $r extends le{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)!==M.bigint){const a=this._getOrReturnCtx(e);return B(a,{code:C.invalid_type,expected:M.bigint,received:a.parsedType}),te}let n;const s=new ot;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),B(n,{code:C.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),B(n,{code:C.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),B(n,{code:C.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):Oe.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 $r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:W.toString(s)}]})}_addCheck(e){return new $r({...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}}$r.create=r=>{var e;return new $r({checks:[],typeName:J.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...ie(r)})};class ss extends le{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==M.boolean){const n=this._getOrReturnCtx(e);return B(n,{code:C.invalid_type,expected:M.boolean,received:n.parsedType}),te}return mt(e.data)}}ss.create=r=>new ss({typeName:J.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...ie(r)});class cn extends le{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==M.date){const a=this._getOrReturnCtx(e);return B(a,{code:C.invalid_type,expected:M.date,received:a.parsedType}),te}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return B(a,{code:C.invalid_date}),te}const n=new ot;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),B(s,{code:C.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),B(s,{code:C.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):Oe.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new cn({...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}}cn.create=r=>new cn({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:J.ZodDate,...ie(r)});class La extends le{_parse(e){if(this._getType(e)!==M.symbol){const n=this._getOrReturnCtx(e);return B(n,{code:C.invalid_type,expected:M.symbol,received:n.parsedType}),te}return mt(e.data)}}La.create=r=>new La({typeName:J.ZodSymbol,...ie(r)});class as extends le{_parse(e){if(this._getType(e)!==M.undefined){const n=this._getOrReturnCtx(e);return B(n,{code:C.invalid_type,expected:M.undefined,received:n.parsedType}),te}return mt(e.data)}}as.create=r=>new as({typeName:J.ZodUndefined,...ie(r)});class is extends le{_parse(e){if(this._getType(e)!==M.null){const n=this._getOrReturnCtx(e);return B(n,{code:C.invalid_type,expected:M.null,received:n.parsedType}),te}return mt(e.data)}}is.create=r=>new is({typeName:J.ZodNull,...ie(r)});class jn extends le{constructor(){super(...arguments),this._any=!0}_parse(e){return mt(e.data)}}jn.create=r=>new jn({typeName:J.ZodAny,...ie(r)});class nn extends le{constructor(){super(...arguments),this._unknown=!0}_parse(e){return mt(e.data)}}nn.create=r=>new nn({typeName:J.ZodUnknown,...ie(r)});class Sr extends le{_parse(e){const t=this._getOrReturnCtx(e);return B(t,{code:C.invalid_type,expected:M.never,received:t.parsedType}),te}}Sr.create=r=>new Sr({typeName:J.ZodNever,...ie(r)});class Ba extends le{_parse(e){if(this._getType(e)!==M.undefined){const n=this._getOrReturnCtx(e);return B(n,{code:C.invalid_type,expected:M.void,received:n.parsedType}),te}return mt(e.data)}}Ba.create=r=>new Ba({typeName:J.ZodVoid,...ie(r)});class Ut extends le{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==M.array)return B(t,{code:C.invalid_type,expected:M.array,received:t.parsedType}),te;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(B(t,{code:i?C.too_big:C.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&&(B(t,{code:C.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&&(B(t,{code:C.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 Gt(t,i,t.path,o)))).then(i=>ot.mergeArray(n,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new Gt(t,i,t.path,o)));return ot.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new Ut({...this._def,minLength:{value:e,message:W.toString(t)}})}max(e,t){return new Ut({...this._def,maxLength:{value:e,message:W.toString(t)}})}length(e,t){return new Ut({...this._def,exactLength:{value:e,message:W.toString(t)}})}nonempty(e){return this.min(1,e)}}Ut.create=(r,e)=>new Ut({type:r,minLength:null,maxLength:null,exactLength:null,typeName:J.ZodArray,...ie(e)});function On(r){if(r instanceof $e){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=br.create(On(n))}return new $e({...r._def,shape:()=>e})}else return r instanceof Ut?new Ut({...r._def,type:On(r.element)}):r instanceof br?br.create(On(r.unwrap())):r instanceof ln?ln.create(On(r.unwrap())):r instanceof Ht?Ht.create(r.items.map(e=>On(e))):r}class $e extends le{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=Oe.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==M.object){const l=this._getOrReturnCtx(e);return B(l,{code:C.invalid_type,expected:M.object,received:l.parsedType}),te}const{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof Sr&&this._def.unknownKeys==="strip"))for(const l in s.data)i.includes(l)||o.push(l);const c=[];for(const l of i){const w=a[l],T=s.data[l];c.push({key:{status:"valid",value:l},value:w._parse(new Gt(s,T,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof Sr){const l=this._def.unknownKeys;if(l==="passthrough")for(const w of o)c.push({key:{status:"valid",value:w},value:{status:"valid",value:s.data[w]}});else if(l==="strict")o.length>0&&(B(s,{code:C.unrecognized_keys,keys:o}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const w of o){const T=s.data[w];c.push({key:{status:"valid",value:w},value:l._parse(new Gt(s,T,s.path,w)),alwaysSet:w in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const l=[];for(const w of c){const T=await w.key;l.push({key:T,value:await w.value,alwaysSet:w.alwaysSet})}return l}).then(l=>ot.mergeObjectSync(n,l)):ot.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return W.errToObj,new $e({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,a,i,o;const c=(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:c}:{message:c}}}:{}})}strip(){return new $e({...this._def,unknownKeys:"strip"})}passthrough(){return new $e({...this._def,unknownKeys:"passthrough"})}extend(e){return new $e({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new $e({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 $e({...this._def,catchall:e})}pick(e){const t={};return Oe.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new $e({...this._def,shape:()=>t})}omit(e){const t={};return Oe.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new $e({...this._def,shape:()=>t})}deepPartial(){return On(this)}partial(e){const t={};return Oe.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new $e({...this._def,shape:()=>t})}required(e){const t={};return Oe.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof br;)a=a._def.innerType;t[n]=a}}),new $e({...this._def,shape:()=>t})}keyof(){return Xu(Oe.objectKeys(this.shape))}}$e.create=(r,e)=>new $e({shape:()=>r,unknownKeys:"strip",catchall:Sr.create(),typeName:J.ZodObject,...ie(e)});$e.strictCreate=(r,e)=>new $e({shape:()=>r,unknownKeys:"strict",catchall:Sr.create(),typeName:J.ZodObject,...ie(e)});$e.lazycreate=(r,e)=>new $e({shape:r,unknownKeys:"strip",catchall:Sr.create(),typeName:J.ZodObject,...ie(e)});class os extends le{_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 Pt(o.ctx.common.issues));return B(t,{code:C.invalid_union,unionErrors:i}),te}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 c of n){const l={...t,common:{...t.common,issues:[]},parent:null},w=c._parseSync({data:t.data,path:t.path,parent:l});if(w.status==="valid")return w;w.status==="dirty"&&!a&&(a={result:w,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new Pt(c));return B(t,{code:C.invalid_union,unionErrors:o}),te}}get options(){return this._def.options}}os.create=(r,e)=>new os({options:r,typeName:J.ZodUnion,...ie(e)});const pa=r=>r instanceof ls?pa(r.schema):r instanceof Lt?pa(r.innerType()):r instanceof ds?[r.value]:r instanceof Lr?r.options:r instanceof hs?Object.keys(r.enum):r instanceof fs?pa(r._def.innerType):r instanceof as?[void 0]:r instanceof is?[null]:null;class Ti extends le{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==M.object)return B(t,{code:C.invalid_type,expected:M.object,received:t.parsedType}),te;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}):(B(t,{code:C.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),te)}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=pa(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 Ti({typeName:J.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...ie(n)})}}function wo(r,e){const t=jr(r),n=jr(e);if(r===e)return{valid:!0,data:r};if(t===M.object&&n===M.object){const s=Oe.objectKeys(e),a=Oe.objectKeys(r).filter(o=>s.indexOf(o)!==-1),i={...r,...e};for(const o of a){const c=wo(r[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===M.array&&n===M.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],c=wo(i,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===M.date&&n===M.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class cs extends le{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(go(a)||go(i))return te;const o=wo(a.value,i.value);return o.valid?((vo(a)||vo(i))&&t.dirty(),{status:t.value,value:o.data}):(B(n,{code:C.invalid_intersection_types}),te)};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}))}}cs.create=(r,e,t)=>new cs({left:r,right:e,typeName:J.ZodIntersection,...ie(t)});class Ht extends le{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==M.array)return B(n,{code:C.invalid_type,expected:M.array,received:n.parsedType}),te;if(n.data.length<this._def.items.length)return B(n,{code:C.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),te;!this._def.rest&&n.data.length>this._def.items.length&&(B(n,{code:C.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...n.data].map((i,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new Gt(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>ot.mergeArray(t,i)):ot.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new Ht({...this._def,rest:e})}}Ht.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Ht({items:r,typeName:J.ZodTuple,rest:null,...ie(e)})};class us extends le{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!==M.object)return B(n,{code:C.invalid_type,expected:M.object,received:n.parsedType}),te;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)s.push({key:a._parse(new Gt(n,o,n.path,o)),value:i._parse(new Gt(n,n.data[o],n.path,o))});return n.common.async?ot.mergeObjectAsync(t,s):ot.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof le?new us({keyType:e,valueType:t,typeName:J.ZodRecord,...ie(n)}):new us({keyType:jt.create(),valueType:e,typeName:J.ZodRecord,...ie(t)})}}class Va extends le{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!==M.map)return B(n,{code:C.invalid_type,expected:M.map,received:n.parsedType}),te;const s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,c],l)=>({key:s._parse(new Gt(n,o,n.path,[l,"key"])),value:a._parse(new Gt(n,c,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const l=await c.key,w=await c.value;if(l.status==="aborted"||w.status==="aborted")return te;(l.status==="dirty"||w.status==="dirty")&&t.dirty(),o.set(l.value,w.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of i){const l=c.key,w=c.value;if(l.status==="aborted"||w.status==="aborted")return te;(l.status==="dirty"||w.status==="dirty")&&t.dirty(),o.set(l.value,w.value)}return{status:t.value,value:o}}}}Va.create=(r,e,t)=>new Va({valueType:e,keyType:r,typeName:J.ZodMap,...ie(t)});class un extends le{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==M.set)return B(n,{code:C.invalid_type,expected:M.set,received:n.parsedType}),te;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(B(n,{code:C.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&&(B(n,{code:C.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(c){const l=new Set;for(const w of c){if(w.status==="aborted")return te;w.status==="dirty"&&t.dirty(),l.add(w.value)}return{status:t.value,value:l}}const o=[...n.data.values()].map((c,l)=>a._parse(new Gt(n,c,n.path,l)));return n.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new un({...this._def,minSize:{value:e,message:W.toString(t)}})}max(e,t){return new un({...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)}}un.create=(r,e)=>new un({valueType:r,minSize:null,maxSize:null,typeName:J.ZodSet,...ie(e)});class Nn extends le{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==M.function)return B(t,{code:C.invalid_type,expected:M.function,received:t.parsedType}),te;function n(o,c){return Ma({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Da(),rs].filter(l=>!!l),issueData:{code:C.invalid_arguments,argumentsError:c}})}function s(o,c){return Ma({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Da(),rs].filter(l=>!!l),issueData:{code:C.invalid_return_type,returnTypeError:c}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Zn){const o=this;return mt(async function(...c){const l=new Pt([]),w=await o._def.args.parseAsync(c,a).catch(Q=>{throw l.addIssue(n(c,Q)),l}),T=await Reflect.apply(i,this,w);return await o._def.returns._def.type.parseAsync(T,a).catch(Q=>{throw l.addIssue(s(T,Q)),l})})}else{const o=this;return mt(function(...c){const l=o._def.args.safeParse(c,a);if(!l.success)throw new Pt([n(c,l.error)]);const w=Reflect.apply(i,this,l.data),T=o._def.returns.safeParse(w,a);if(!T.success)throw new Pt([s(w,T.error)]);return T.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Nn({...this._def,args:Ht.create(e).rest(nn.create())})}returns(e){return new Nn({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Nn({args:e||Ht.create([]).rest(nn.create()),returns:t||nn.create(),typeName:J.ZodFunction,...ie(n)})}}class ls extends le{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})}}ls.create=(r,e)=>new ls({getter:r,typeName:J.ZodLazy,...ie(e)});class ds extends le{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return B(t,{received:t.data,code:C.invalid_literal,expected:this._def.value}),te}return{status:"valid",value:e.data}}get value(){return this._def.value}}ds.create=(r,e)=>new ds({value:r,typeName:J.ZodLiteral,...ie(e)});function Xu(r,e){return new Lr({values:r,typeName:J.ZodEnum,...ie(e)})}class Lr extends le{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return B(t,{expected:Oe.joinValues(n),received:t.parsedType,code:C.invalid_type}),te}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),n=this._def.values;return B(t,{received:t.data,code:C.invalid_enum_value,options:n}),te}return mt(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 Lr.create(e)}exclude(e){return Lr.create(this.options.filter(t=>!e.includes(t)))}}Lr.create=Xu;class hs extends le{_parse(e){const t=Oe.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==M.string&&n.parsedType!==M.number){const s=Oe.objectValues(t);return B(n,{expected:Oe.joinValues(s),received:n.parsedType,code:C.invalid_type}),te}if(t.indexOf(e.data)===-1){const s=Oe.objectValues(t);return B(n,{received:n.data,code:C.invalid_enum_value,options:s}),te}return mt(e.data)}get enum(){return this._def.values}}hs.create=(r,e)=>new hs({values:r,typeName:J.ZodNativeEnum,...ie(e)});class Zn extends le{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==M.promise&&t.common.async===!1)return B(t,{code:C.invalid_type,expected:M.promise,received:t.parsedType}),te;const n=t.parsedType===M.promise?t.data:Promise.resolve(t.data);return mt(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Zn.create=(r,e)=>new Zn({type:r,typeName:J.ZodPromise,...ie(e)});class Lt extends le{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=>{B(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 c=s.refinement(o,a);if(n.common.async)return Promise.resolve(c);if(c 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"?te:(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"?te:(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(!ns(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=>ns(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);Oe.assertNever(s)}}Lt.create=(r,e,t)=>new Lt({schema:r,typeName:J.ZodEffects,effect:e,...ie(t)});Lt.createWithPreprocess=(r,e,t)=>new Lt({schema:e,effect:{type:"preprocess",transform:r},typeName:J.ZodEffects,...ie(t)});class br extends le{_parse(e){return this._getType(e)===M.undefined?mt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}br.create=(r,e)=>new br({innerType:r,typeName:J.ZodOptional,...ie(e)});class ln extends le{_parse(e){return this._getType(e)===M.null?mt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ln.create=(r,e)=>new ln({innerType:r,typeName:J.ZodNullable,...ie(e)});class fs extends le{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===M.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}fs.create=(r,e)=>new fs({innerType:r,typeName:J.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ie(e)});class Ka extends le{_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 $a(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Pt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Pt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Ka.create=(r,e)=>new Ka({innerType:r,typeName:J.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ie(e)});class Fa extends le{_parse(e){if(this._getType(e)!==M.nan){const n=this._getOrReturnCtx(e);return B(n,{code:C.invalid_type,expected:M.nan,received:n.parsedType}),te}return{status:"valid",value:e.data}}}Fa.create=r=>new Fa({typeName:J.ZodNaN,...ie(r)});const kf=Symbol("zod_brand");class Qu extends le{_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 qs extends le{_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"?te:a.status==="dirty"?(t.dirty(),Hu(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"?te: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 qs({in:e,out:t,typeName:J.ZodPipeline})}}class Wa extends le{_parse(e){const t=this._def.innerType._parse(e);return ns(t)&&(t.value=Object.freeze(t.value)),t}}Wa.create=(r,e)=>new Wa({innerType:r,typeName:J.ZodReadonly,...ie(e)});const el=(r,e={},t)=>r?jn.create().superRefine((n,s)=>{var a,i;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,l=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...l,fatal:c})}}):jn.create(),Of={object:$e.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 Tf=(r,e={message:`Input not instance of ${r.name}`})=>el(t=>t instanceof r,e),tl=jt.create,rl=Mr.create,xf=Fa.create,Sf=$r.create,nl=ss.create,Ef=cn.create,Nf=La.create,Af=as.create,If=is.create,Cf=jn.create,jf=nn.create,Zf=Sr.create,Rf=Ba.create,zf=Ut.create,Pf=$e.create,Uf=$e.strictCreate,Df=os.create,Mf=Ti.create,$f=cs.create,Lf=Ht.create,Bf=us.create,Vf=Va.create,Kf=un.create,Ff=Nn.create,Wf=ls.create,qf=ds.create,Yf=Lr.create,Jf=hs.create,Gf=Zn.create,Gc=Lt.create,Hf=br.create,Xf=ln.create,Qf=Lt.createWithPreprocess,ep=qs.create,tp=()=>tl().optional(),rp=()=>rl().optional(),np=()=>nl().optional(),sp={string:r=>jt.create({...r,coerce:!0}),number:r=>Mr.create({...r,coerce:!0}),boolean:r=>ss.create({...r,coerce:!0}),bigint:r=>$r.create({...r,coerce:!0}),date:r=>cn.create({...r,coerce:!0})},ap=te;var E=Object.freeze({__proto__:null,defaultErrorMap:rs,setErrorMap:uf,getErrorMap:Da,makeIssue:Ma,EMPTY_PATH:lf,addIssueToContext:B,ParseStatus:ot,INVALID:te,DIRTY:Hu,OK:mt,isAborted:go,isDirty:vo,isValid:ns,isAsync:$a,get util(){return Oe},get objectUtil(){return yo},ZodParsedType:M,getParsedType:jr,ZodType:le,ZodString:jt,ZodNumber:Mr,ZodBigInt:$r,ZodBoolean:ss,ZodDate:cn,ZodSymbol:La,ZodUndefined:as,ZodNull:is,ZodAny:jn,ZodUnknown:nn,ZodNever:Sr,ZodVoid:Ba,ZodArray:Ut,ZodObject:$e,ZodUnion:os,ZodDiscriminatedUnion:Ti,ZodIntersection:cs,ZodTuple:Ht,ZodRecord:us,ZodMap:Va,ZodSet:un,ZodFunction:Nn,ZodLazy:ls,ZodLiteral:ds,ZodEnum:Lr,ZodNativeEnum:hs,ZodPromise:Zn,ZodEffects:Lt,ZodTransformer:Lt,ZodOptional:br,ZodNullable:ln,ZodDefault:fs,ZodCatch:Ka,ZodNaN:Fa,BRAND:kf,ZodBranded:Qu,ZodPipeline:qs,ZodReadonly:Wa,custom:el,Schema:le,ZodSchema:le,late:Of,get ZodFirstPartyTypeKind(){return J},coerce:sp,any:Cf,array:zf,bigint:Sf,boolean:nl,date:Ef,discriminatedUnion:Mf,effect:Gc,enum:Yf,function:Ff,instanceof:Tf,intersection:$f,lazy:Wf,literal:qf,map:Vf,nan:xf,nativeEnum:Jf,never:Zf,null:If,nullable:Xf,number:rl,object:Pf,oboolean:np,onumber:rp,optional:Hf,ostring:tp,pipeline:ep,preprocess:Qf,promise:Gf,record:Bf,set:Kf,strictObject:Uf,string:tl,symbol:Nf,transformer:Gc,tuple:Lf,undefined:Af,union:Df,unknown:jf,void:Rf,NEVER:ap,ZodIssueCode:C,quotelessJson:cf,ZodError:Pt});const qo=E.tuple([E.number(),E.number()]),sl=E.object({width:E.number(),height:E.number()}),ip=E.object({signedWidth:E.number(),signedHeight:E.number()}),op=["width","height"];E.enum(op);const cp=["start","center","end"],up=["signedWidth","signedHeight"];E.enum(up);const qa=E.object({x:E.number(),y:E.number()}),lp=E.object({clientX:E.number(),clientY:E.number()}),dp=["x","y"],al=E.enum(dp),il=["top","right","bottom","left"];E.enum(il);const hp=["left","right"],ol=E.enum(hp),fp=["top","bottom"],cl=E.enum(fp),ul=["center"],Hc=E.enum(ul),pp=[...il,...ul],ll=E.enum(pp);E.enum(cp);const mp=["first","last"];E.enum(mp);const yp=E.object({lower:E.number(),upper:E.number()});E.union([yp,qo]);E.union([al,ll]);E.union([al,ll,E.instanceof(String)]);const es=(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),gp(t)},gp=r=>r.lower>r.upper?{lower:r.upper,upper:r.lower}:r;var Et=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},me={},xi={};Object.defineProperty(xi,"__esModule",{value:!0});function vp(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()}):""}xi.default=vp;var Si={};Object.defineProperty(Si,"__esModule",{value:!0});function wp(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():""}Si.default=wp;var Ei={};Object.defineProperty(Ei,"__esModule",{value:!0});function _p(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()}):""}Ei.default=_p;var Yo={};Object.defineProperty(Yo,"__esModule",{value:!0});function bp(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():""}Yo.default=bp;var Jo={};Object.defineProperty(Jo,"__esModule",{value:!0});function kp(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():""}Jo.default=kp;var Go={};Object.defineProperty(Go,"__esModule",{value:!0});function Op(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():""}Go.default=Op;var Ho={};Object.defineProperty(Ho,"__esModule",{value:!0});function Tp(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)}Ho.default=Tp;var Xo={};Object.defineProperty(Xo,"__esModule",{value:!0});function xp(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}):""}Xo.default=xp;var Ni={};Object.defineProperty(Ni,"__esModule",{value:!0});function Sp(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():""}Ni.default=Sp;var Qo={},gn={};(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})}})(gn);var Ep=Et&&Et.__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(Qo,"__esModule",{value:!0});var ar=gn;function ma(r,e){if(e===void 0&&(e=ar.DefaultOption),!ar.isValidObject(r))return null;e=ar.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=n.toLowerCase();e.recursive&&(ar.isValidObject(s)?ar.belongToTypes(s,e.keepTypesOnRecursion)||(s=ma(s,e)):e.recursiveInArray&&ar.isArrayObject(s)&&(s=Ep(s).map(function(i){var o=i;if(ar.isValidObject(i))ar.belongToTypes(o,e.keepTypesOnRecursion)||(o=ma(i,e));else if(ar.isArrayObject(i)){var c=ma({key:i},e);o=c.key}return o}))),t[a]=s}),t}Qo.default=ma;var ec={},Np=Et&&Et.__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(ec,"__esModule",{value:!0});var ir=gn;function ya(r,e){if(e===void 0&&(e=ir.DefaultOption),!ir.isValidObject(r))return null;e=ir.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=n.toUpperCase();e.recursive&&(ir.isValidObject(s)?ir.belongToTypes(s,e.keepTypesOnRecursion)||(s=ya(s,e)):e.recursiveInArray&&ir.isArrayObject(s)&&(s=Np(s).map(function(i){var o=i;if(ir.isValidObject(i))ir.belongToTypes(o,e.keepTypesOnRecursion)||(o=ya(i,e));else if(ir.isArrayObject(i)){var c=ya({key:i},e);o=c.key}return o}))),t[a]=s}),t}ec.default=ya;var tc={},Ap=Et&&Et.__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(tc,"__esModule",{value:!0});var or=gn,Ip=xi;function ga(r,e){if(e===void 0&&(e=or.DefaultOption),!or.isValidObject(r))return null;e=or.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=Ip.default(n);e.recursive&&(or.isValidObject(s)?or.belongToTypes(s,e.keepTypesOnRecursion)||(s=ga(s,e)):e.recursiveInArray&&or.isArrayObject(s)&&(s=Ap(s).map(function(i){var o=i;if(or.isValidObject(i))or.belongToTypes(o,e.keepTypesOnRecursion)||(o=ga(i,e));else if(or.isArrayObject(i)){var c=ga({key:i},e);o=c.key}return o}))),t[a]=s}),t}tc.default=ga;var rc={},Cp=Et&&Et.__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(rc,"__esModule",{value:!0});var cr=gn,jp=Si;function va(r,e){if(e===void 0&&(e=cr.DefaultOption),!cr.isValidObject(r))return null;e=cr.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=jp.default(n);e.recursive&&(cr.isValidObject(s)?cr.belongToTypes(s,e.keepTypesOnRecursion)||(s=va(s,e)):e.recursiveInArray&&cr.isArrayObject(s)&&(s=Cp(s).map(function(i){var o=i;if(cr.isValidObject(i))cr.belongToTypes(o,e.keepTypesOnRecursion)||(o=va(i,e));else if(cr.isArrayObject(i)){var c=va({key:i},e);o=c.key}return o}))),t[a]=s}),t}rc.default=va;var nc={},Zp=Et&&Et.__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(nc,"__esModule",{value:!0});var ur=gn,Rp=Ei;function wa(r,e){if(e===void 0&&(e=ur.DefaultOption),!ur.isValidObject(r))return null;e=ur.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=Rp.default(n);e.recursive&&(ur.isValidObject(s)?ur.belongToTypes(s,e.keepTypesOnRecursion)||(s=wa(s,e)):e.recursiveInArray&&ur.isArrayObject(s)&&(s=Zp(s).map(function(i){var o=i;if(ur.isValidObject(i))ur.belongToTypes(o,e.keepTypesOnRecursion)||(o=wa(i,e));else if(ur.isArrayObject(i)){var c=wa({key:i},e);o=c.key}return o}))),t[a]=s}),t}nc.default=wa;var sc={},zp=Et&&Et.__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(sc,"__esModule",{value:!0});var lr=gn,Pp=Ni;function _a(r,e){if(e===void 0&&(e=lr.DefaultOption),!lr.isValidObject(r))return null;e=lr.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=Pp.default(n);e.recursive&&(lr.isValidObject(s)?lr.belongToTypes(s,e.keepTypesOnRecursion)||(s=_a(s,e)):e.recursiveInArray&&lr.isArrayObject(s)&&(s=zp(s).map(function(i){var o=i;if(lr.isValidObject(i))lr.belongToTypes(o,e.keepTypesOnRecursion)||(o=_a(i,e));else if(lr.isArrayObject(i)){var c=_a({key:i},e);o=c.key}return o}))),t[a]=s}),t}sc.default=_a;Object.defineProperty(me,"__esModule",{value:!0});me.kebabKeys=me.pascalKeys=me.snakeKeys=me.camelKeys=me.upperKeys=me.lowerKeys=me.toLowerCase=me.toUpperCase=me.toKebabCase=me.toHeaderCase=me.toSentenceCase=me.toTextCase=me.toPathCase=me.toDotCase=me.toPascalCase=me.toSnakeCase=me.toCamelCase=void 0;var dl=xi;me.toCamelCase=dl.default;var hl=Si;me.toSnakeCase=hl.default;var fl=Ei;me.toPascalCase=fl.default;var pl=Yo;me.toDotCase=pl.default;var ml=Jo;me.toPathCase=ml.default;var yl=Go;me.toTextCase=yl.default;var gl=Ho;me.toSentenceCase=gl.default;var vl=Xo;me.toHeaderCase=vl.default;var wl=Ni;me.toKebabCase=wl.default;var _l=Qo;me.lowerKeys=_l.default;var bl=ec;me.upperKeys=bl.default;var kl=tc;me.camelKeys=kl.default;var Ol=rc;me.snakeKeys=Ol.default;var Tl=nc;me.pascalKeys=Tl.default;var xl=sc;me.kebabKeys=xl.default;var Sl=function(r){return String(r||"").toLowerCase()};me.toLowerCase=Sl;var El=function(r){return String(r||"").toUpperCase()};me.toUpperCase=El;var Up={toCamelCase:dl.default,toSnakeCase:hl.default,toPascalCase:fl.default,toDotCase:pl.default,toPathCase:ml.default,toTextCase:yl.default,toSentenceCase:gl.default,toHeaderCase:vl.default,toKebabCase:wl.default,toUpperCase:El,toLowerCase:Sl,lowerKeys:_l.default,upperKeys:bl.default,camelKeys:kl.default,snakeKeys:Ol.default,pascalKeys:Tl.default,kebabKeys:xl.default};me.default=Up;var Nl=me;const Al={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},Dp=r=>Nl.snakeKeys(r,Al),Mp=r=>Nl.camelKeys(r,Al);var Rn;(r=>{r.toSnake=Dp,r.toCamel=Mp,r.capitalize=e=>e[0].toUpperCase()+e.slice(1)})(Rn||(Rn={}));E.object({x:ol.or(Hc),y:cl.or(Hc)});const $p=E.object({x:ol,y:cl}),Lp=Object.freeze({x:"left",y:"top"}),Bp=(r,e)=>r.x===e.x&&r.y===e.y,Xc=E.union([E.number(),qa,qo,sl,ip,lp]),Vp=(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}},Qc={x:0,y:0},oa=E.union([E.number(),E.string()]);E.object({top:oa,left:oa,width:oa,height:oa});E.object({left:E.number(),top:E.number(),right:E.number(),bottom:E.number()});E.object({one:qa,two:qa,root:$p});const ac=(r,e,t=0,n=0,s)=>{const a={one:{...Qc},two:{...Qc},root:s??Lp};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))},Gi=r=>{const e=ac(r);return{lower:e.one.x,upper:e.two.x}},Hi=r=>{const e=ac(r);return{lower:e.one.y,upper:e.two.y}},Kp=r=>typeof r!="object"||r==null?!1:"one"in r&&"two"in r&&"root"in r,Fp=E.object({signedWidth:E.number(),signedHeight:E.number()});E.union([sl,Fp,qa,qo]);const Wp=(r,e,t)=>(e!=null&&(r=Math.max(r,e)),t!=null&&(r=Math.min(r,t)),r);E.object({offset:Xc,scale:Xc});const qp=r=>(e,t,n,s)=>t==="dimension"?[e,n]:[e,s?n-r:n+r],Yp=r=>(e,t,n,s)=>[e,s?n/r:n*r],Jp=r=>(e,t,n)=>{if(e===null)return[r,n];const{lower:s,upper:a}=e,{lower:i,upper:o}=r,c=a-s,l=o-i;if(t==="dimension")return[r,n*(l/c)];const w=(n-s)*(l/c)+i;return[r,w]},Gp=r=>(e,t,n)=>[r,n],Hp=()=>(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)]},Xp=r=>(e,t,n)=>{const{lower:s,upper:a}=r;return n=Wp(n,s,a),[e,n]},_o=class Jn{constructor(){A(this,"ops",[]),A(this,"currBounds",null),A(this,"currType",null),A(this,"reversed",!1),this.ops=[]}static translate(e){return new Jn().translate(e)}static magnify(e){return new Jn().magnify(e)}static scale(e,t){return new Jn().scale(e,t)}translate(e){const t=this.new(),n=qp(e);return n.type="translate",t.ops.push(n),t}magnify(e){const t=this.new(),n=Yp(e);return n.type="magnify",t.ops.push(n),t}scale(e,t){const n=es(e,t),s=this.new(),a=Jp(n);return a.type="scale",s.ops.push(a),s}clamp(e,t){const n=es(e,t),s=this.new(),a=Xp(n);return a.type="clamp",s.ops.push(a),s}reBound(e,t){const n=es(e,t),s=this.new(),a=Gp(n);return a.type="re-bound",s.ops.push(a),s}invert(){const e=Hp();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 Jn;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}};A(_o,"IDENTITY",new _o);let eu=_o;const tu=class gr{constructor(e=new eu,t=new eu,n=null){A(this,"x"),A(this,"y"),A(this,"currRoot"),this.x=e,this.y=t,this.currRoot=n}static translate(e,t){return new gr().translate(e,t)}static translateX(e){return new gr().translateX(e)}static translateY(e){return new gr().translateY(e)}static clamp(e){return new gr().clamp(e)}static magnify(e){return new gr().magnify(e)}static scale(e){return new gr().scale(e)}static reBound(e){return new gr().reBound(e)}translate(e,t){const n=Vp(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(Kp(e)){const n=this.currRoot;return t.currRoot=e.root,n!=null&&!Bp(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(Gi(e)),t.y=t.y.scale(Hi(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(Gi(e)),t.y=this.y.reBound(Hi(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(Gi(e)),t.y=this.y.clamp(Hi(e)),t}copy(){const e=new gr;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 ac(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};A(tu,"IDENTITY",new tu);const Il=(r,e)=>{const t=new Ue(e);if(![Pe.DAY,Pe.HOUR,Pe.MINUTE,Pe.SECOND,Pe.MILLISECOND,Pe.MICROSECOND,Pe.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 Ue?new Ue(n):new Pe(n)},Ce=class fe extends Number{constructor(e,t="UTC"){if(e==null)return fe.now();if(e instanceof Date)super(e.getTime()*fe.MILLISECOND.valueOf());else if(typeof e=="string")super(fe.parseDateTimeString(e,t).valueOf());else if(Array.isArray(e))super(fe.parseDate(e));else{let n=0;e instanceof Number&&(e=e.valueOf()),t==="local"&&(n=fe.utcOffset.valueOf()),super(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 fe(s.getTime()*fe.MILLISECOND.valueOf()).truncate(fe.DAY).valueOf()}static parseTimeString(e,t="UTC"){const[n,s,a]=e.split(":");let i="00",o="00";a!=null&&([i,o]=a.split("."));let c=fe.hours(parseInt(n??"00",10)).add(fe.minutes(parseInt(s??"00",10))).add(fe.seconds(parseInt(i??"00",10))).add(fe.milliseconds(parseInt(o??"00",10)));return t==="local"&&(c=c.add(fe.utcOffset)),c.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return fe.parseTimeString(e,t);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new fe(n.getTime()*fe.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(fe.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 Pe(new Date().getTimezoneOffset()*fe.MINUTE.valueOf())}static since(e){return new fe().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new fe(e).valueOf()}span(e){return this.range(e).span}range(e){return new Zt(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===0}after(e){return this.valueOf()>new fe(e).valueOf()}afterEq(e){return this.valueOf()>=new fe(e).valueOf()}before(e){return this.valueOf()<new fe(e).valueOf()}beforeEq(e){return this.valueOf()<=new fe(e).valueOf()}add(e){return new fe(this.valueOf()+e.valueOf())}sub(e){return new fe(this.valueOf()-e.valueOf())}milliseconds(){return this.valueOf()/fe.MILLISECOND.valueOf()}toString(){return this.date().toISOString()}remainder(e){return Il(this,e)}get isToday(){return this.truncate(Pe.DAY).equals(fe.now().truncate(Pe.DAY))}truncate(e){return this.sub(this.remainder(e))}get bigInt(){return BigInt(this.valueOf())}static now(){return new fe(new Date)}static nanoseconds(e){return new fe(e)}static microseconds(e){return fe.nanoseconds(e*1e3)}static milliseconds(e){return fe.microseconds(e*1e3)}static seconds(e){return fe.milliseconds(e*1e3)}static minutes(e){return fe.seconds(e*60)}static hours(e){return fe.minutes(e*60)}static days(e){return fe.hours(e*24)}};A(Ce,"NANOSECOND",Ce.nanoseconds(1));A(Ce,"MICROSECOND",Ce.microseconds(1));A(Ce,"MILLISECOND",Ce.milliseconds(1));A(Ce,"SECOND",Ce.seconds(1));A(Ce,"MINUTE",Ce.minutes(1));A(Ce,"HOUR",Ce.hours(1));A(Ce,"DAY",Ce.days(1));A(Ce,"MAX",new Ce(9122272036554776e3));A(Ce,"MIN",new Ce(0));A(Ce,"ZERO",new Ce(0));A(Ce,"z",E.union([E.instanceof(Number).transform(r=>new Ce(r)),E.number().transform(r=>new Ce(r)),E.instanceof(Ce)]));let Ue=Ce;const Ae=class be extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}lessThan(e){return this.valueOf()<new be(e).valueOf()}greaterThan(e){return this.valueOf()>new be(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new be(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new be(e).valueOf()}remainder(e){return Il(this,e)}truncate(e){return new be(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}multiply(e){return new be(this.valueOf()*e)}toString(){const e=this.truncate(be.DAY),t=this.truncate(be.HOUR),n=this.truncate(be.MINUTE),s=this.truncate(be.SECOND),a=this.truncate(be.MILLISECOND),i=this.truncate(be.MICROSECOND),o=this.truncate(be.NANOSECOND),c=e,l=t.sub(e),w=n.sub(t),T=s.sub(n),X=a.sub(s),Q=i.sub(a),Ze=o.sub(i);let ee="";return c.isZero||(ee+=`${c.days}d `),l.isZero||(ee+=`${l.hours}h `),w.isZero||(ee+=`${w.minutes}m `),T.isZero||(ee+=`${T.seconds}s `),X.isZero||(ee+=`${X.milliseconds}ms `),Q.isZero||(ee+=`${Q.microseconds}µs `),Ze.isZero||(ee+=`${Ze.nanoseconds}ns`),ee.trim()}get days(){return this.valueOf()/be.DAY.valueOf()}get hours(){return this.valueOf()/be.HOUR.valueOf()}get minutes(){return this.valueOf()/be.MINUTE.valueOf()}get seconds(){return this.valueOf()/be.SECOND.valueOf()}get milliseconds(){return this.valueOf()/be.MILLISECOND.valueOf()}get microseconds(){return this.valueOf()/be.MICROSECOND.valueOf()}get nanoseconds(){return this.valueOf()}get isZero(){return this.valueOf()===0}equals(e){return this.valueOf()===new be(e).valueOf()}add(e){return new be(this.valueOf()+new be(e).valueOf())}sub(e){return new be(this.valueOf()-new be(e).valueOf())}static nanoseconds(e=1){return new be(e)}static microseconds(e=1){return be.nanoseconds(e*1e3)}static milliseconds(e=1){return be.microseconds(e*1e3)}static seconds(e=1){return be.milliseconds(e*1e3)}static minutes(e){return be.seconds(e.valueOf()*60)}static hours(e){return be.minutes(e*60)}static days(e){return be.hours(e*24)}};A(Ae,"NANOSECOND",Ae.nanoseconds(1));A(Ae,"MICROSECOND",Ae.microseconds(1));A(Ae,"MILLISECOND",Ae.milliseconds(1));A(Ae,"SECOND",Ae.seconds(1));A(Ae,"MINUTE",Ae.minutes(1));A(Ae,"HOUR",Ae.hours(1));A(Ae,"DAY",Ae.days(1));A(Ae,"MAX",new Ae(Ae.MAX_SAFE_INTEGER));A(Ae,"MIN",new Ae(-Ae.MAX_SAFE_INTEGER));A(Ae,"ZERO",new Ae(0));A(Ae,"z",E.union([E.instanceof(Number).transform(r=>new Ae(r)),E.number().transform(r=>new Ae(r)),E.instanceof(Ae)]));let Pe=Ae;const Gn=class ba extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new ba(e).valueOf()}get period(){return Pe.seconds(1/this.valueOf())}sampleCount(e){return new Pe(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new st(t).valueOf()}span(e){return Pe.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new ba(e)}static khz(e){return ba.hz(e*1e3)}};A(Gn,"z",E.union([E.number().transform(r=>new Gn(r)),E.instanceof(Number).transform(r=>new Gn(r)),E.instanceof(Gn)]));let Ai=Gn;const tt=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new Ya(e*this.valueOf())}};A(tt,"UNKNOWN",new tt(0));A(tt,"BIT128",new tt(16));A(tt,"BIT64",new tt(8));A(tt,"BIT32",new tt(4));A(tt,"BIT16",new tt(2));A(tt,"BIT8",new tt(1));A(tt,"z",E.union([E.number().transform(r=>new tt(r)),E.instanceof(Number).transform(r=>new tt(r)),E.instanceof(tt)]));let st=tt;const Yt=class ka{constructor(e,t){A(this,"start"),A(this,"end"),this.start=new Ue(e),this.end=new Ue(t)}get span(){return new Pe(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 ka(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 ka?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new ka(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}};A(Yt,"MAX",new Yt(Ue.MIN,Ue.MAX));A(Yt,"MIN",new Yt(Ue.MAX,Ue.MIN));A(Yt,"ZERO",new Yt(Ue.ZERO,Ue.ZERO));A(Yt,"z",E.union([E.object({start:Ue.z,end:Ue.z}).transform(r=>new Yt(r.start,r.end)),E.instanceof(Yt)]));let Zt=Yt;const x=class tn extends String{constructor(e){if(e instanceof tn||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const t=tn.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}}throw super(tn.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=tn.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 density(){const e=tn.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 tn.BIG_INT_TYPES.some(e=>e.equals(this))}};A(x,"UNKNOWN",new x("unknown"));A(x,"FLOAT64",new x("float64"));A(x,"FLOAT32",new x("float32"));A(x,"INT64",new x("int64"));A(x,"INT32",new x("int32"));A(x,"INT16",new x("int16"));A(x,"INT8",new x("int8"));A(x,"UINT64",new x("uint64"));A(x,"UINT32",new x("uint32"));A(x,"UINT16",new x("uint16"));A(x,"UINT8",new x("uint8"));A(x,"TIMESTAMP",new x("timestamp"));A(x,"UUID",new x("uuid"));A(x,"STRING",new x("string"));A(x,"JSON",new x("json"));A(x,"ARRAY_CONSTRUCTORS",new Map([[x.UINT8.toString(),Uint8Array],[x.UINT16.toString(),Uint16Array],[x.UINT32.toString(),Uint32Array],[x.UINT64.toString(),BigUint64Array],[x.FLOAT32.toString(),Float32Array],[x.FLOAT64.toString(),Float64Array],[x.INT8.toString(),Int8Array],[x.INT16.toString(),Int16Array],[x.INT32.toString(),Int32Array],[x.INT64.toString(),BigInt64Array],[x.TIMESTAMP.toString(),BigInt64Array],[x.STRING.toString(),Uint8Array],[x.JSON.toString(),Uint8Array],[x.UUID.toString(),Uint8Array]]));A(x,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,x.UINT8],[Uint16Array.name,x.UINT16],[Uint32Array.name,x.UINT32],[BigUint64Array.name,x.UINT64],[Float32Array.name,x.FLOAT32],[Float64Array.name,x.FLOAT64],[Int8Array.name,x.INT8],[Int16Array.name,x.INT16],[Int32Array.name,x.INT32],[BigInt64Array.name,x.INT64]]));A(x,"DENSITIES",new Map([[x.UINT8.toString(),st.BIT8],[x.UINT16.toString(),st.BIT16],[x.UINT32.toString(),st.BIT32],[x.UINT64.toString(),st.BIT64],[x.FLOAT32.toString(),st.BIT32],[x.FLOAT64.toString(),st.BIT64],[x.INT8.toString(),st.BIT8],[x.INT16.toString(),st.BIT16],[x.INT32.toString(),st.BIT32],[x.INT64.toString(),st.BIT64],[x.TIMESTAMP.toString(),st.BIT64],[x.STRING.toString(),st.UNKNOWN],[x.JSON.toString(),st.UNKNOWN],[x.UUID.toString(),st.BIT128]]));A(x,"ALL",[x.UNKNOWN,x.FLOAT64,x.FLOAT32,x.INT64,x.INT32,x.INT16,x.INT8,x.UINT64,x.UINT32,x.UINT16,x.UINT8,x.TIMESTAMP,x.UUID,x.STRING,x.JSON]);A(x,"BIG_INT_TYPES",[x.INT64,x.UINT64,x.TIMESTAMP]);A(x,"z",E.union([E.string().transform(r=>new x(r)),E.instanceof(x)]));let et=x;const at=class Fe extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return Fe.bytes(this.valueOf()+e.valueOf())}sub(e){return Fe.bytes(this.valueOf()-e.valueOf())}truncate(e){return new Fe(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return Fe.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/Fe.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/Fe.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/Fe.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/Fe.TERABYTE.valueOf()}toString(){const e=this.truncate(Fe.TERABYTE),t=this.truncate(Fe.GIGABYTE),n=this.truncate(Fe.MEGABYTE),s=this.truncate(Fe.KILOBYTE),a=this.truncate(Fe.BYTE),i=e,o=t.sub(e),c=n.sub(t),l=s.sub(n),w=a.sub(s);let T="";return i.isZero||(T+=`${i.terabytes}TB `),o.isZero||(T+=`${o.gigabytes}GB `),c.isZero||(T+=`${c.megabytes}MB `),l.isZero||(T+=`${l.kilobytes}KB `),(!w.isZero||T==="")&&(T+=`${w.valueOf()}B`),T.trim()}static bytes(e=1){return new Fe(e)}static kilobytes(e=1){return Fe.bytes(e.valueOf()*1e3)}static megabytes(e=1){return Fe.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return Fe.megabytes(e.valueOf()*1e3)}static terabytes(e){return Fe.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};A(at,"BYTE",new at(1));A(at,"KILOBYTE",at.kilobytes(1));A(at,"MEGABYTE",at.megabytes(1));A(at,"GIGABYTE",at.gigabytes(1));A(at,"TERABYTE",at.terabytes(1));A(at,"ZERO",new at(0));A(at,"z",E.union([E.number().transform(r=>new at(r)),E.instanceof(at)]));let Ya=at;E.union([E.instanceof(Uint8Array),E.instanceof(Uint16Array),E.instanceof(Uint32Array),E.instanceof(BigUint64Array),E.instanceof(Float32Array),E.instanceof(Float64Array),E.instanceof(Int8Array),E.instanceof(Int16Array),E.instanceof(Int32Array),E.instanceof(BigInt64Array)]);const Qp=(r,e,t,n=0)=>r.usesBigInt&&!e.usesBigInt?Number(t)-Number(n):!r.usesBigInt&&e.usesBigInt?BigInt(t)-BigInt(n):Hn(t,-n),Xr=-1;class Ct{constructor({data:e,dataType:t,timeRange:n,sampleOffset:s=0,glBufferUsage:a="static",alignment:i=0,key:o=nf()}){if(A(this,"key",""),A(this,"dataType"),A(this,"sampleOffset"),A(this,"gl"),A(this,"_data"),A(this,"_timeRange"),A(this,"alignment",0),A(this,"_min"),A(this,"_max"),A(this,"writePos",Xr),A(this,"_refCount",0),t==null&&!(e instanceof ArrayBuffer))this.dataType=new et(e);else if(t!=null)this.dataType=new et(t);else throw new Error("must provide a data type when constructing a Series from a buffer");this.key=o,this.alignment=i,this.sampleOffset=s??0,this._data=e,this._timeRange=n,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:a}}static alloc({capacity:e,dataType:t,...n}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const s=new new et(t).Array(e),a=new Ct({data:s.buffer,dataType:t,...n});return a.writePos=0,a}static generateTimestamps(e,t,n){const s=n.spanRange(t.span(e)),a=new BigInt64Array(e);for(let i=0;i<e;i++)a[i]=BigInt(n.add(t.span(i)).valueOf());return new Ct({data:a,dataType:et.TIMESTAMP,timeRange:s})}get refCount(){return this._refCount}static fromStrings(e,t){const n=new TextEncoder().encode(e.join(`
2
+ `)+`
3
+ `);return new Ct({data:n,dataType:et.STRING,timeRange:t})}static fromJSON(e,t){const n=new TextEncoder().encode(e.map(s=>JSON.stringify(s)).join(`
4
+ `)+`
5
+ `);return new Ct({data:n,dataType:et.JSON,timeRange:t})}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){if(this._refCount--,this._refCount===0&&this.gl.control!=null)this.maybeGarbageCollectGLBuffer(this.gl.control);else if(this._refCount<0)throw new Error("cannot release an array with a negative reference count")}write(e){if(!e.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");if(this.writePos===Xr)return 0;const t=this.capacity-this.writePos,n=t<e.length?e.slice(0,t):e;return this.underlyingData.set(n.data,this.writePos),this.maybeRecomputeMinMax(n),this.writePos+=n.length,n.length}get buffer(){return this._data}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===Xr?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.equals(et.STRING))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
6
+ `).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(et.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=et.UUID.density.valueOf(),t=Array(this.length);for(let n=0;n<this.length;n++){const s=this.buffer.slice(n*e,(n+1)*e),a=Array.from(new Uint8Array(s),i=>i.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");t[n]=a}return t}parseJSON(e){if(!this.dataType.equals(et.JSON))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
7
+ `).slice(0,-1).map(t=>e.parse(JSON.parse(t)))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new Ya(this.buffer.byteLength)}get capacity(){return this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Xr?this.byteCapacity:this.dataType.density.size(this.writePos)}get length(){return this.writePos===Xr?this.data.length:this.writePos}convert(e,t=0){if(this.dataType.equals(e))return this;const n=new e.Array(this.length);for(let s=0;s<this.length;s++)n[s]=Qp(this.dataType,e,this.data[s],t);return new Ct({data:n.buffer,dataType:e,timeRange:this._timeRange,sampleOffset:t,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(et.TIMESTAMP))this._max=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._max=e.reduce((t,n)=>t>n?t:n)}else{const e=this.data;this._max=e.reduce((t,n)=>t>n?t:n)}return this._max}get max(){return this.writePos===0?-1/0:(this._max==null&&(this._max=this.calcRawMax()),Hn(this._max,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(et.TIMESTAMP))this._min=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._min=e.reduce((t,n)=>t<n?t:n)}else{const e=this.data;this._min=e.reduce((t,n)=>t<n?t:n)}return this._min}get min(){return this.writePos===0?1/0:(this._min==null&&(this._min=this.calcRawMin()),Hn(this._min,this.sampleOffset))}get bounds(){return es(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._min!=null){const t=e._min??e.calcRawMin();t<this._min&&(this._min=t)}if(this._max!=null){const t=e._max??e.calcRawMax();t>this._max&&(this._max=t)}}enrich(){this.max,this.min}get range(){return Hn(this.max,-this.min)}at(e,t){e<0&&(e=this.length+e);const n=this.data[e];if(n==null){if(t)throw new Error(`[series] - no value at index ${e}`);return}return Hn(n,this.sampleOffset)}binarySearch(e){let t=0,n=this.length-1;const s=af(e);for(;t<=n;){const a=Math.floor((t+n)/2),i=s(this.at(a,!0),e);if(i===0)return a;i<0?t=a+1:n=a-1}return t}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(et.FLOAT32))throw new Error("Only FLOAT32 arrays can be used in WebGL");const{buffer:t,bufferUsage:n,prevBuffer:s}=this.gl;if(t==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==s)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Xr){s===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const a=this.dataType.density.size(s).valueOf(),i=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,a,i.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,n==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=Xr}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:this.alignmentBounds,timeRange:(e=this._timeRange)==null?void 0:e.toString(),length:this.length,capacity:this.capacity}}get memInfo(){return{key:this.key,length:this.length,byteLength:this.byteLength,glBuffer:this.gl.buffer!=null}}get alignmentBounds(){return es(this.alignment,this.alignment+this.length)}maybeGarbageCollectGLBuffer(e){this.gl.buffer!=null&&(e.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}slice(e,t){if(e<=0&&(t==null||t>=this.length))return this;const n=this.data.slice(e,t);return new Ct({data:n,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+e})}reAlign(e){return new Ct({data:this.buffer,dataType:this.dataType,timeRange:Zt.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}}const Hn=(r,e)=>typeof r=="bigint"&&typeof e=="bigint"||typeof r=="number"&&typeof e=="number"?r+e:Number(r)+Number(e),ic=E.record(E.union([E.number(),E.string(),E.symbol()]),E.unknown()),em=r=>r!=null&&typeof r=="object"&&!Array.isArray(r),tm=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";tm();const rm=["MacOS","Windows","Linux","Docker"];E.enum(rm);const nm=(r,e)=>{let t=null;return e===0?r:(...s)=>{t!==null&&(clearTimeout(t),t=null),t=setTimeout(()=>r(...s),e)}},ru=r=>[...new Set(r)],sm=(...r)=>r.map(Cl).join(""),Cl=r=>(r.endsWith("/")||(r+="/"),r.startsWith("/")&&(r=r.slice(1)),r),am=r=>r.endsWith("/")?r.slice(0,-1):r;let im=(wn=class{constructor({host:r,port:e,protocol:t="",pathPrefix:n=""}){A(this,"protocol"),A(this,"host"),A(this,"port"),A(this,"path"),this.protocol=t,this.host=r,this.port=e,this.path=Cl(n)}replace(r){return new wn({host:r.host??this.host,port:r.port??this.port,protocol:r.protocol??this.protocol,pathPrefix:r.pathPrefix??this.path})}child(r){return new wn({...this,pathPrefix:sm(this.path,r)})}toString(){return am(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}},A(wn,"UNKNOWN",new wn({host:"unknown",port:0})),wn);const Se=r=>Array.isArray(r)?r:[r];var bo;try{bo=new TextDecoder}catch{}var P,xt,f=0,Re={},we,zr,Ot=0,Ft=0,Ge,kr,yt=[],ge,nu={useRecords:!1,mapsAsObjects:!0};class jl{}const Zl=new jl;Zl.name="MessagePack 0xC1";var Ur=!1,Rl=2,su;try{new Function("")}catch{Rl=1/0}class ps{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(P)return Ml(()=>(Oo(),this?this.unpack(e,t):ps.prototype.unpack.call(nu,e,t)));!e.buffer&&e.constructor===ArrayBuffer&&(e=typeof Buffer<"u"?Buffer.from(e):new Uint8Array(e)),typeof t=="object"?(xt=t.end||e.length,f=t.start||0):(f=0,xt=t>-1?t:e.length),Ft=0,zr=null,Ge=null,P=e;try{ge=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(n){throw P=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 ps){if(Re=this,this.structures)return we=this.structures,ca(t);(!we||we.length>0)&&(we=[])}else Re=nu,(!we||we.length>0)&&(we=[]);return ca(t)}unpackMultiple(e,t){let n,s=0;try{Ur=!0;let a=e.length,i=this?this.unpack(e,a):Ii.unpack(e,a);if(t){if(t(i,s,f)===!1)return;for(;f<a;)if(s=f,t(ca(),s,f)===!1)return}else{for(n=[i];f<a;)s=f,n.push(ca());return n}}catch(a){throw a.lastPosition=s,a.values=n,a}finally{Ur=!1,Oo()}}_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 ca(r){try{if(!Re.trusted&&!Ur){let t=we.sharedLength||0;t<we.length&&(we.length=t)}let e;if(Re.randomAccessStructure&&P[f]<64&&P[f]>=32&&su?(e=su(P,f,xt,Re),P=null,!(r&&r.lazy)&&e&&(e=e.toJSON()),f=xt):e=Be(),Ge&&(f=Ge.postBundlePosition,Ge=null),Ur&&(we.restoreStructures=null),f==xt)we&&we.restoreStructures&&au(),we=null,P=null,kr&&(kr=null);else{if(f>xt)throw new Error("Unexpected end of MessagePack data");if(!Ur){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 we&&we.restoreStructures&&au(),Oo(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||f>xt)&&(e.incomplete=!0),e}}function au(){for(let r in we.restoreStructures)we[r]=we.restoreStructures[r];we.restoreStructures=null}function Be(){let r=P[f++];if(r<160)if(r<128){if(r<64)return r;{let e=we[r&63]||Re.getStructures&&zl()[r&63];return e?(e.read||(e.read=oc(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=Ul();n==="__proto__"&&(n="__proto_"),e[n]=Be()}return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(Be(),Be());return e}else{r-=144;let e=new Array(r);for(let t=0;t<r;t++)e[t]=Be();return Re.freezeData?Object.freeze(e):e}else if(r<192){let e=r-160;if(Ft>=f)return zr.slice(f-Ot,(f+=e)-Ot);if(Ft==0&&xt<140){let t=e<16?cc(e):Pl(e);if(t!=null)return t}return ko(e)}else{let e;switch(r){case 192:return null;case 193:return Ge?(e=Be(),e>0?Ge[1].slice(Ge.position1,Ge.position1+=e):Ge[0].slice(Ge.position0,Ge.position0-=e)):Zl;case 194:return!1;case 195:return!0;case 196:if(e=P[f++],e===void 0)throw new Error("Unexpected end of buffer");return Xi(e);case 197:return e=ge.getUint16(f),f+=2,Xi(e);case 198:return e=ge.getUint32(f),f+=4,Xi(e);case 199:return Qr(P[f++]);case 200:return e=ge.getUint16(f),f+=2,Qr(e);case 201:return e=ge.getUint32(f),f+=4,Qr(e);case 202:if(e=ge.getFloat32(f),Re.useFloat32>2){let t=uc[(P[f]&127)<<1|P[f+1]>>7];return f+=4,(t*e+(e>0?.5:-.5)>>0)/t}return f+=4,e;case 203:return e=ge.getFloat64(f),f+=8,e;case 204:return P[f++];case 205:return e=ge.getUint16(f),f+=2,e;case 206:return e=ge.getUint32(f),f+=4,e;case 207:return Re.int64AsType==="number"?(e=ge.getUint32(f)*4294967296,e+=ge.getUint32(f+4)):Re.int64AsType==="string"?e=ge.getBigUint64(f).toString():Re.int64AsType==="auto"?(e=ge.getBigUint64(f),e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=ge.getBigUint64(f),f+=8,e;case 208:return ge.getInt8(f++);case 209:return e=ge.getInt16(f),f+=2,e;case 210:return e=ge.getInt32(f),f+=4,e;case 211:return Re.int64AsType==="number"?(e=ge.getInt32(f)*4294967296,e+=ge.getUint32(f+4)):Re.int64AsType==="string"?e=ge.getBigInt64(f).toString():Re.int64AsType==="auto"?(e=ge.getBigInt64(f),e>=BigInt(-2)<<BigInt(52)&&e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=ge.getBigInt64(f),f+=8,e;case 212:if(e=P[f++],e==114)return du(P[f++]&63);{let t=yt[e];if(t)return t.read?(f++,t.read(Be())):t.noBuffer?(f++,t()):t(P.subarray(f,++f));throw new Error("Unknown extension "+e)}case 213:return e=P[f],e==114?(f++,du(P[f++]&63,P[f++])):Qr(2);case 214:return Qr(4);case 215:return Qr(8);case 216:return Qr(16);case 217:return e=P[f++],Ft>=f?zr.slice(f-Ot,(f+=e)-Ot):cm(e);case 218:return e=ge.getUint16(f),f+=2,Ft>=f?zr.slice(f-Ot,(f+=e)-Ot):um(e);case 219:return e=ge.getUint32(f),f+=4,Ft>=f?zr.slice(f-Ot,(f+=e)-Ot):lm(e);case 220:return e=ge.getUint16(f),f+=2,ou(e);case 221:return e=ge.getUint32(f),f+=4,ou(e);case 222:return e=ge.getUint16(f),f+=2,cu(e);case 223:return e=ge.getUint32(f),f+=4,cu(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 om=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function oc(r,e){function t(){if(t.count++>Rl){let s=r.read=new Function("r","return function(){return "+(Re.freezeData?"Object.freeze":"")+"({"+r.map(a=>a==="__proto__"?"__proto_:r()":om.test(a)?a+":r()":"["+JSON.stringify(a)+"]:r()").join(",")+"})}")(Be);return r.highByte===0&&(r.read=iu(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]=Be()}return Re.freezeData?Object.freeze(n):n}return t.count=0,r.highByte===0?iu(e,t):t}const iu=(r,e)=>function(){let t=P[f++];if(t===0)return e();let n=r<32?-(r+(t<<5)):r+(t<<5),s=we[n]||zl()[n];if(!s)throw new Error("Record id is not defined for "+n);return s.read||(s.read=oc(s,r)),s.read()};function zl(){let r=Ml(()=>(P=null,Re.getStructures()));return we=Re._mergeStructures(r,we)}var ko=Ys,cm=Ys,um=Ys,lm=Ys;function Ys(r){let e;if(r<16&&(e=cc(r)))return e;if(r>64&&bo)return bo.decode(P.subarray(f,f+=r));const t=f+r,n=[];for(e="";f<t;){const s=P[f++];if(!(s&128))n.push(s);else if((s&224)===192){const a=P[f++]&63;n.push((s&31)<<6|a)}else if((s&240)===224){const a=P[f++]&63,i=P[f++]&63;n.push((s&31)<<12|a<<6|i)}else if((s&248)===240){const a=P[f++]&63,i=P[f++]&63,o=P[f++]&63;let c=(s&7)<<18|a<<12|i<<6|o;c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|c&1023),n.push(c)}else n.push(s);n.length>=4096&&(e+=Ye.apply(String,n),n.length=0)}return n.length>0&&(e+=Ye.apply(String,n)),e}function ou(r){let e=new Array(r);for(let t=0;t<r;t++)e[t]=Be();return Re.freezeData?Object.freeze(e):e}function cu(r){if(Re.mapsAsObjects){let e={};for(let t=0;t<r;t++){let n=Ul();n==="__proto__"&&(n="__proto_"),e[n]=Be()}return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(Be(),Be());return e}}var Ye=String.fromCharCode;function Pl(r){let e=f,t=new Array(r);for(let n=0;n<r;n++){const s=P[f++];if((s&128)>0){f=e;return}t[n]=s}return Ye.apply(String,t)}function cc(r){if(r<4)if(r<2){if(r===0)return"";{let e=P[f++];if((e&128)>1){f-=1;return}return Ye(e)}}else{let e=P[f++],t=P[f++];if((e&128)>0||(t&128)>0){f-=2;return}if(r<3)return Ye(e,t);let n=P[f++];if((n&128)>0){f-=3;return}return Ye(e,t,n)}else{let e=P[f++],t=P[f++],n=P[f++],s=P[f++];if((e&128)>0||(t&128)>0||(n&128)>0||(s&128)>0){f-=4;return}if(r<6){if(r===4)return Ye(e,t,n,s);{let a=P[f++];if((a&128)>0){f-=5;return}return Ye(e,t,n,s,a)}}else if(r<8){let a=P[f++],i=P[f++];if((a&128)>0||(i&128)>0){f-=6;return}if(r<7)return Ye(e,t,n,s,a,i);let o=P[f++];if((o&128)>0){f-=7;return}return Ye(e,t,n,s,a,i,o)}else{let a=P[f++],i=P[f++],o=P[f++],c=P[f++];if((a&128)>0||(i&128)>0||(o&128)>0||(c&128)>0){f-=8;return}if(r<10){if(r===8)return Ye(e,t,n,s,a,i,o,c);{let l=P[f++];if((l&128)>0){f-=9;return}return Ye(e,t,n,s,a,i,o,c,l)}}else if(r<12){let l=P[f++],w=P[f++];if((l&128)>0||(w&128)>0){f-=10;return}if(r<11)return Ye(e,t,n,s,a,i,o,c,l,w);let T=P[f++];if((T&128)>0){f-=11;return}return Ye(e,t,n,s,a,i,o,c,l,w,T)}else{let l=P[f++],w=P[f++],T=P[f++],X=P[f++];if((l&128)>0||(w&128)>0||(T&128)>0||(X&128)>0){f-=12;return}if(r<14){if(r===12)return Ye(e,t,n,s,a,i,o,c,l,w,T,X);{let Q=P[f++];if((Q&128)>0){f-=13;return}return Ye(e,t,n,s,a,i,o,c,l,w,T,X,Q)}}else{let Q=P[f++],Ze=P[f++];if((Q&128)>0||(Ze&128)>0){f-=14;return}if(r<15)return Ye(e,t,n,s,a,i,o,c,l,w,T,X,Q,Ze);let ee=P[f++];if((ee&128)>0){f-=15;return}return Ye(e,t,n,s,a,i,o,c,l,w,T,X,Q,Ze,ee)}}}}}function uu(){let r=P[f++],e;if(r<192)e=r-160;else switch(r){case 217:e=P[f++];break;case 218:e=ge.getUint16(f),f+=2;break;case 219:e=ge.getUint32(f),f+=4;break;default:throw new Error("Expected string")}return Ys(e)}function Xi(r){return Re.copyBuffers?Uint8Array.prototype.slice.call(P,f,f+=r):P.subarray(f,f+=r)}function Qr(r){let e=P[f++];if(yt[e]){let t;return yt[e](P.subarray(f,t=f+=r),n=>{f=n;try{return Be()}finally{f=t}})}else throw new Error("Unknown extension type "+e)}var lu=new Array(4096);function Ul(){let r=P[f++];if(r>=160&&r<192){if(r=r-160,Ft>=f)return zr.slice(f-Ot,(f+=r)-Ot);if(!(Ft==0&&xt<180))return ko(r)}else return f--,Be().toString();let e=(r<<5^(r>1?ge.getUint16(f):r>0?P[f]:0))&4095,t=lu[e],n=f,s=f+r-3,a,i=0;if(t&&t.bytes==r){for(;n<s;){if(a=ge.getUint32(n),a!=t[i++]){n=1879048192;break}n+=4}for(s+=3;n<s;)if(a=P[n++],a!=t[i++]){n=1879048192;break}if(n===s)return f=n,t.string;s-=3,n=f}for(t=[],lu[e]=t,t.bytes=r;n<s;)a=ge.getUint32(n),t.push(a),n+=4;for(s+=3;n<s;)a=P[n++],t.push(a);let o=r<16?cc(r):Pl(r);return o!=null?t.string=o:t.string=ko(r)}const du=(r,e)=>{let t=Be().map(a=>a.toString()),n=r;e!==void 0&&(r=r<32?-((e<<5)+r):(e<<5)+r,t.highByte=e);let s=we[r];return s&&(s.isShared||Ur)&&((we.restoreStructures||(we.restoreStructures=[]))[r]=s),we[r]=t,t.read=oc(t,n),t.read()};yt[0]=()=>{};yt[0].noBuffer=!0;let dm={Error,TypeError,ReferenceError};yt[101]=()=>{let r=Be();return(dm[r[0]]||Error)(r[1])};yt[105]=r=>{let e=ge.getUint32(f-4);kr||(kr=new Map);let t=P[f],n;t>=144&&t<160||t==220||t==221?n=[]:n={};let s={target:n};kr.set(e,s);let a=Be();return s.used?Object.assign(n,a):(s.target=a,a)};yt[112]=r=>{let e=ge.getUint32(f-4),t=kr.get(e);return t.used=!0,t.target};yt[115]=()=>new Set(Be());const Dl=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(r=>r+"Array");let hm=typeof globalThis=="object"?globalThis:window;yt[116]=r=>{let e=r[0],t=Dl[e];if(!t)throw new Error("Could not find typed array for code "+e);return new hm[t](Uint8Array.prototype.slice.call(r,1).buffer)};yt[120]=()=>{let r=Be();return new RegExp(r[0],r[1])};const fm=[];yt[98]=r=>{let e=(r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3],t=f;return f+=e-r.length,Ge=fm,Ge=[uu(),uu()],Ge.position0=0,Ge.position1=0,Ge.postBundlePosition=f,f=t,Be()};yt[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 Ml(r){let e=xt,t=f,n=Ot,s=Ft,a=zr,i=kr,o=Ge,c=new Uint8Array(P.slice(0,xt)),l=we,w=we.slice(0,we.length),T=Re,X=Ur,Q=r();return xt=e,f=t,Ot=n,Ft=s,zr=a,kr=i,Ge=o,P=c,Ur=X,we=l,we.splice(0,we.length,...w),Re=T,ge=new DataView(P.buffer,P.byteOffset,P.byteLength),Q}function Oo(){P=null,kr=null,we=null}function pm(r){r.unpack?yt[r.type]=r.unpack:yt[r.type]=r}const uc=new Array(147);for(let r=0;r<256;r++)uc[r]=+("1e"+Math.floor(45.15-r*.30103));var Ii=new ps({useRecords:!1});const mm=Ii.unpack;Ii.unpackMultiple;Ii.unpack;let ym=new Float32Array(1);new Uint8Array(ym.buffer,0,4);let Oa;try{Oa=new TextEncoder}catch{}let Ja,lc;const Ci=typeof Buffer<"u",ua=Ci?function(r){return Buffer.allocUnsafeSlow(r)}:Uint8Array,$l=Ci?Buffer:Uint8Array,hu=Ci?4294967296:2144337920;let _,qn,Ee,g=0,lt,De=null,gm;const vm=21760,wm=/[\u0080-\uFFFF]/,_n=Symbol("record-id");class _m extends ps{constructor(e){super(e),this.offset=0;let t,n,s,a,i=$l.prototype.utf8Write?function(d,O){return _.utf8Write(d,O,4294967295)}:Oa&&Oa.encodeInto?function(d,O){return Oa.encodeInto(d,_.subarray(O)).written}:!1,o=this;e||(e={});let c=e&&e.sequential,l=e.structures||e.saveStructures,w=e.maxSharedStructures;if(w==null&&(w=l?32:0),w>8160)throw new Error("Maximum maxSharedStructure is 8160");e.structuredClone&&e.moreTypes==null&&(this.moreTypes=!0);let T=e.maxOwnStructures;T==null&&(T=l?32:64),!this.structures&&e.useRecords!=!1&&(this.structures=[]);let X=w>32||T+w>64,Q=w+64,Ze=w+T+64;if(Ze>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let ee=[],rr=0,nr=0;this.pack=this.encode=function(d,O){if(_||(_=new ua(8192),Ee=_.dataView||(_.dataView=new DataView(_.buffer,0,8192)),g=0),lt=_.length-10,lt-g<2048?(_=new ua(_.length),Ee=_.dataView||(_.dataView=new DataView(_.buffer,0,_.length)),lt=_.length-10,g=0):g=g+7&2147483640,t=g,O&Nm&&(g+=O&255),a=o.structuredClone?new Map:null,o.bundleStrings&&typeof d!="string"?(De=[],De.size=1/0):De=null,s=o.structures,s){s.uninitialized&&(s=o._mergeStructures(o.getStructures()));let m=s.sharedLength||0;if(m>w)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 y=0;y<m;y++){let k=s[y];if(!k)continue;let z,D=s.transitions;for(let I=0,ne=k.length;I<ne;I++){let F=k[I];z=D[F],z||(z=D[F]=Object.create(null)),D=z}D[_n]=y+64}this.lastNamedStructuresLength=m}c||(s.nextId=m+64)}n&&(n=!1);try{o.randomAccessStructure&&d&&d.constructor&&d.constructor===Object?Yi(d):re(d);let m=De;if(De&&mu(t,re,0),a&&a.idsToInsert){let y=a.idsToInsert.sort((I,ne)=>I.offset>ne.offset?1:-1),k=y.length,z=-1;for(;m&&k>0;){let I=y[--k].offset+t;I<m.stringsPosition+t&&z===-1&&(z=0),I>m.position+t?z>=0&&(z+=6):(z>=0&&(Ee.setUint32(m.position+t,Ee.getUint32(m.position+t)+z),z=-1),m=m.previous,k++)}z>=0&&m&&Ee.setUint32(m.position+t,Ee.getUint32(m.position+t)+z),g+=y.length*6,g>lt&&Xe(g),o.offset=g;let D=km(_.subarray(t,g),y);return a=null,D}return o.offset=g,O&Sm?(_.start=t,_.end=g,_):_.subarray(t,g)}finally{if(s&&(Bn(),n&&o.saveStructures)){let m=s.sharedLength||0,y=_.subarray(t,g),k=Tm(s,o);return o.saveStructures(k,k.isCompatible)===!1?o.pack(d,O):(o.lastNamedStructuresLength=m,y)}O&Em&&(g=t)}};const Bn=()=>{nr<10&&nr++;let d=s.sharedLength||0;if(s.length>d&&!c&&(s.length=d),rr>1e4)s.transitions=null,nr=0,rr=0,ee.length>0&&(ee=[]);else if(ee.length>0&&!c){for(let O=0,m=ee.length;O<m;O++)ee[O][_n]=0;ee=[]}},Gr=d=>{var O=d.length;O<16?_[g++]=144|O:O<65536?(_[g++]=220,_[g++]=O>>8,_[g++]=O&255):(_[g++]=221,Ee.setUint32(g,O),g+=4);for(let m=0;m<O;m++)re(d[m])},re=d=>{g>lt&&(_=Xe(g));var O=typeof d,m;if(O==="string"){let y=d.length;if(De&&y>=4&&y<4096){if((De.size+=y)>vm){let I,ne=(De[0]?De[0].length*3+De[1].length:0)+10;g+ne>lt&&(_=Xe(g+ne));let F;De.position?(F=De,_[g]=200,g+=3,_[g++]=98,I=g-t,g+=4,mu(t,re,0),Ee.setUint16(I+t-3,g-t-I)):(_[g++]=214,_[g++]=98,I=g-t,g+=4),De=["",""],De.previous=F,De.size=0,De.position=I}let D=wm.test(d);De[D?0:1]+=d,_[g++]=193,re(D?-y:y);return}let k;y<32?k=1:y<256?k=2:y<65536?k=3:k=5;let z=y*3;if(g+z>lt&&(_=Xe(g+z)),y<64||!i){let D,I,ne,F=g+k;for(D=0;D<y;D++)I=d.charCodeAt(D),I<128?_[F++]=I:I<2048?(_[F++]=I>>6|192,_[F++]=I&63|128):(I&64512)===55296&&((ne=d.charCodeAt(D+1))&64512)===56320?(I=65536+((I&1023)<<10)+(ne&1023),D++,_[F++]=I>>18|240,_[F++]=I>>12&63|128,_[F++]=I>>6&63|128,_[F++]=I&63|128):(_[F++]=I>>12|224,_[F++]=I>>6&63|128,_[F++]=I&63|128);m=F-g-k}else m=i(d,g+k);m<32?_[g++]=160|m:m<256?(k<2&&_.copyWithin(g+2,g+1,g+1+m),_[g++]=217,_[g++]=m):m<65536?(k<3&&_.copyWithin(g+3,g+2,g+2+m),_[g++]=218,_[g++]=m>>8,_[g++]=m&255):(k<5&&_.copyWithin(g+5,g+3,g+3+m),_[g++]=219,Ee.setUint32(g,m),g+=4),g+=m}else if(O==="number")if(d>>>0===d)d<32||d<128&&this.useRecords===!1||d<64&&!this.randomAccessStructure?_[g++]=d:d<256?(_[g++]=204,_[g++]=d):d<65536?(_[g++]=205,_[g++]=d>>8,_[g++]=d&255):(_[g++]=206,Ee.setUint32(g,d),g+=4);else if(d>>0===d)d>=-32?_[g++]=256+d:d>=-128?(_[g++]=208,_[g++]=d+256):d>=-32768?(_[g++]=209,Ee.setInt16(g,d),g+=2):(_[g++]=210,Ee.setInt32(g,d),g+=4);else{let y;if((y=this.useFloat32)>0&&d<4294967296&&d>=-2147483648){_[g++]=202,Ee.setFloat32(g,d);let k;if(y<4||(k=d*uc[(_[g]&127)<<1|_[g+1]>>7])>>0===k){g+=4;return}else g--}_[g++]=203,Ee.setFloat64(g,d),g+=8}else if(O==="object"||O==="function")if(!d)_[g++]=192;else{if(a){let k=a.get(d);if(k){if(!k.id){let z=a.idsToInsert||(a.idsToInsert=[]);k.id=z.push(k)}_[g++]=214,_[g++]=112,Ee.setUint32(g,k.id),g+=4;return}else a.set(d,{offset:g-t})}let y=d.constructor;if(y===Object)sr(d,!0);else if(y===Array)Gr(d);else if(y===Map)if(this.mapAsEmptyObject)_[g++]=128;else{m=d.size,m<16?_[g++]=128|m:m<65536?(_[g++]=222,_[g++]=m>>8,_[g++]=m&255):(_[g++]=223,Ee.setUint32(g,m),g+=4);for(let[k,z]of d)re(k),re(z)}else{for(let k=0,z=Ja.length;k<z;k++){let D=lc[k];if(d instanceof D){let I=Ja[k];if(I.write){I.type&&(_[g++]=212,_[g++]=I.type,_[g++]=0);let Qe=I.write.call(this,d);Qe===d?Array.isArray(d)?Gr(d):sr(d):re(Qe);return}let ne=_,F=Ee,Ke=g;_=null;let ut;try{ut=I.pack.call(this,d,Qe=>(_=ne,ne=null,g+=Qe,g>lt&&Xe(g),{target:_,targetView:Ee,position:g-Qe}),re)}finally{ne&&(_=ne,Ee=F,g=Ke,lt=_.length-10)}ut&&(ut.length+g>lt&&Xe(ut.length+g),g=bm(ut,_,g,I.type));return}}if(Array.isArray(d))Gr(d);else{if(d.toJSON){const k=d.toJSON();if(k!==d)return re(k)}if(O==="function")return re(this.writeFunction&&this.writeFunction(d));sr(d,!d.hasOwnProperty)}}}else if(O==="boolean")_[g++]=d?195:194;else if(O==="bigint"){if(d<BigInt(1)<<BigInt(63)&&d>=-(BigInt(1)<<BigInt(63)))_[g++]=211,Ee.setBigInt64(g,d);else if(d<BigInt(1)<<BigInt(64)&&d>0)_[g++]=207,Ee.setBigUint64(g,d);else if(this.largeBigIntToFloat)_[g++]=203,Ee.setFloat64(g,Number(d));else throw new RangeError(d+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");g+=8}else if(O==="undefined")this.encodeUndefinedAsNil?_[g++]=192:(_[g++]=212,_[g++]=0,_[g++]=0);else throw new Error("Unknown type: "+O)},Vn=this.variableMapSize||this.coercibleKeyAsNumber?d=>{let O=Object.keys(d),m=O.length;m<16?_[g++]=128|m:m<65536?(_[g++]=222,_[g++]=m>>8,_[g++]=m&255):(_[g++]=223,Ee.setUint32(g,m),g+=4);let y;if(this.coercibleKeyAsNumber)for(let k=0;k<m;k++){y=O[k];let z=Number(y);re(isNaN(z)?y:z),re(d[y])}else for(let k=0;k<m;k++)re(y=O[k]),re(d[y])}:(d,O)=>{_[g++]=222;let m=g-t;g+=2;let y=0;for(let k in d)(O||d.hasOwnProperty(k))&&(re(k),re(d[k]),y++);_[m+++t]=y>>8,_[m+t]=y&255},Kn=this.useRecords===!1?Vn:e.progressiveRecords&&!X?(d,O)=>{let m,y=s.transitions||(s.transitions=Object.create(null)),k=g++-t,z;for(let D in d)if(O||d.hasOwnProperty(D)){if(m=y[D],m)y=m;else{let I=Object.keys(d),ne=y;y=s.transitions;let F=0;for(let Ke=0,ut=I.length;Ke<ut;Ke++){let Qe=I[Ke];m=y[Qe],m||(m=y[Qe]=Object.create(null),F++),y=m}k+t+1==g?(g--,Hr(y,I,F)):Wn(y,I,k,F),z=!0,y=ne[D]}re(d[D])}if(!z){let D=y[_n];D?_[k+t]=D:Wn(y,Object.keys(d),k,0)}}:(d,O)=>{let m,y=s.transitions||(s.transitions=Object.create(null)),k=0;for(let D in d)(O||d.hasOwnProperty(D))&&(m=y[D],m||(m=y[D]=Object.create(null),k++),y=m);let z=y[_n];z?z>=96&&X?(_[g++]=((z-=96)&31)+96,_[g++]=z>>5):_[g++]=z:Hr(y,y.__keys__||Object.keys(d),k);for(let D in d)(O||d.hasOwnProperty(D))&&re(d[D])},Fn=typeof this.useRecords=="function"&&this.useRecords,sr=Fn?(d,O)=>{Fn(d)?Kn(d,O):Vn(d,O)}:Kn,Xe=d=>{let O;if(d>16777216){if(d-t>hu)throw new Error("Packed buffer would be larger than maximum buffer size");O=Math.min(hu,Math.round(Math.max((d-t)*(d>67108864?1.25:2),4194304)/4096)*4096)}else O=(Math.max(d-t<<2,_.length-1)>>12)+1<<12;let m=new ua(O);return Ee=m.dataView||(m.dataView=new DataView(m.buffer,0,O)),d=Math.min(d,_.length),_.copy?_.copy(m,0,t,d):m.set(_.slice(t,d)),g-=t,t=0,lt=m.length-10,_=m},Hr=(d,O,m)=>{let y=s.nextId;y||(y=64),y<Q&&this.shouldShareStructure&&!this.shouldShareStructure(O)?(y=s.nextOwnId,y<Ze||(y=Q),s.nextOwnId=y+1):(y>=Ze&&(y=Q),s.nextId=y+1);let k=O.highByte=y>=96&&X?y-96>>5:-1;d[_n]=y,d.__keys__=O,s[y-64]=O,y<Q?(O.isShared=!0,s.sharedLength=y-63,n=!0,k>=0?(_[g++]=(y&31)+96,_[g++]=k):_[g++]=y):(k>=0?(_[g++]=213,_[g++]=114,_[g++]=(y&31)+96,_[g++]=k):(_[g++]=212,_[g++]=114,_[g++]=y),m&&(rr+=nr*m),ee.length>=T&&(ee.shift()[_n]=0),ee.push(d),re(O))},Wn=(d,O,m,y)=>{let k=_,z=g,D=lt,I=t;_=qn,g=0,t=0,_||(qn=_=new ua(8192)),lt=_.length-10,Hr(d,O,y),qn=_;let ne=g;if(_=k,g=z,lt=D,t=I,ne>1){let F=g+ne-1;F>lt&&Xe(F);let Ke=m+t;_.copyWithin(Ke+ne,Ke+1,g),_.set(qn.slice(0,ne),Ke),g=F}else _[m+t]=qn[0]},Yi=(d,O)=>{let m=gm(d,_,t,g,s,Xe,(y,k,z)=>{if(z)return n=!0;g=k;let D=_;return re(y),Bn(),D!==_?{position:g,targetView:Ee,target:_}:g},this);if(m===0)return sr(d,!0);g=m}}useBuffer(e){_=e,Ee=new DataView(_.buffer,_.byteOffset,_.byteLength),g=0}clearSharedData(){this.structures&&(this.structures=[]),this.typedStructs&&(this.typedStructs=[])}}lc=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,jl];Ja=[{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?fu(r,16,e):pu(Ci?Buffer.from(r):new Uint8Array(r),e)}},{pack(r,e){let t=r.constructor;t!==$l&&this.moreTypes?fu(r,Dl.indexOf(t.name),e):pu(r,e)}},{pack(r,e){let{target:t,position:n}=e(1);t[n]=193}}];function fu(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 pu(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 bm(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 km(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 mu(r,e,t){if(De.length>0){Ee.setUint32(De.position+r,g+t-De.position-r),De.stringsPosition=g-r;let n=De;De=null,e(n[0]),e(n[1])}}function Om(r){if(r.Class){if(!r.pack&&!r.write)throw new Error("Extension has no pack or write function");if(r.pack&&!r.type)throw new Error("Extension has no type (numeric code to identify the extension)");lc.unshift(r.Class),Ja.unshift(r)}pm(r)}function Tm(r,e){return r.isCompatible=t=>{let n=!t||(e.lastNamedStructuresLength||0)===t.length;return n||e._mergeStructures(t),n},r}let Ll=new _m({useRecords:!1});const xm=Ll.pack;Ll.pack;const Sm=512,Em=1024,Nm=2048;class dc{constructor(){A(this,"contentType","application/msgpack")}encode(e){return xm(Rn.toSnake(e))}decode(e,t){const n=Rn.toCamel(mm(new Uint8Array(e)));return t!=null?t.parse(n):n}static registerCustomType(e){Om({type:0,...e})}}class hc{constructor(){A(this,"contentType","application/json")}encode(e){const t=JSON.stringify(Rn.toSnake(e),(n,s)=>ArrayBuffer.isView(s)?Array.from(s):s);return new TextEncoder().encode(t)}decode(e,t){const n=Rn.toCamel(JSON.parse(new TextDecoder().decode(e)));return t!=null?t.parse(n):n}static registerCustomType(){}}const Am=[new dc,new hc],Bl=[dc,hc],Im=r=>Bl.forEach(e=>{e.registerCustomType(r)}),Vl=Object.freeze(Object.defineProperty({__proto__:null,ENCODERS:Am,ENCODER_CLASSES:Bl,JSONEncoderDecoder:hc,MsgpackEncoderDecoder:dc,registerCustomTypeEncoder:Im},Symbol.toStringTag,{value:"Module"}));class Cm{constructor(e){A(this,"handlers"),this.handlers=e??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){this.handlers.forEach((t,n)=>n(e))}}const Ga=Object.freeze(Object.defineProperty({__proto__:null,Observer:Cm},Symbol.toStringTag,{value:"Module"})),Js=u.z.number(),Gs=u.z.object({name:u.z.string(),key:u.z.number(),rate:Ai.z,dataType:et.z,leaseholder:u.z.number(),index:u.z.number(),isIndex:u.z.boolean(),alias:u.z.string().optional()}),Kl=Gs.extend({key:u.z.number().optional(),leaseholder:u.z.number().optional(),index:u.z.number().optional(),rate:Ai.z.optional(),isIndex:u.z.boolean().optional()}),Fl=r=>r.map(e=>({name:e.name,dataType:e.dataType,rate:e.rate??0,leaseholder:e.leaseholder,index:e.index,isIndex:e.isIndex}));u.z.object({channels:Kl.array()});const jm=u.z.object({channels:Gs.array()}),bi=class bi{constructor(e){h(this,"client");this.client=e}async create(e){const t={channels:Fl(e)},[n,s]=await this.client.send(bi.ENDPOINT,t,jm);if(s!=null)throw s;return n.channels}};h(bi,"ENDPOINT","/channel/create");let Ha=bi;const Zm=new Error("request for lock canceled");var Rm=function(r,e,t,n){function s(a){return a instanceof t?a:new t(function(i){i(a)})}return new(t||(t=Promise))(function(a,i){function o(w){try{l(n.next(w))}catch(T){i(T)}}function c(w){try{l(n.throw(w))}catch(T){i(T)}}function l(w){w.done?a(w.value):s(w.value).then(o,c)}l((n=n.apply(r,e||[])).next())})};class zm{constructor(e,t=Zm){this._value=e,this._cancelError=t,this._weightedQueues=[],this._weightedWaiters=[]}acquire(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((t,n)=>{this._weightedQueues[e-1]||(this._weightedQueues[e-1]=[]),this._weightedQueues[e-1].push({resolve:t,reject:n}),this._dispatch()})}runExclusive(e,t=1){return Rm(this,void 0,void 0,function*(){const[n,s]=yield this.acquire(t);try{return yield e(n)}finally{s()}})}waitForUnlock(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise(t=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),this._weightedWaiters[e-1].push(t),this._dispatch()})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatch()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatch()}cancel(){this._weightedQueues.forEach(e=>e.forEach(t=>t.reject(this._cancelError))),this._weightedQueues=[]}_dispatch(){var e;for(let t=this._value;t>0;t--){const n=(e=this._weightedQueues[t-1])===null||e===void 0?void 0:e.shift();if(!n)continue;const s=this._value,a=t;this._value-=t,t=this._value+1,n.resolve([s,this._newReleaser(a)])}this._drainUnlockWaiters()}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){for(let e=this._value;e>0;e--)this._weightedWaiters[e-1]&&(this._weightedWaiters[e-1].forEach(t=>t()),this._weightedWaiters[e-1]=[])}}var Pm=function(r,e,t,n){function s(a){return a instanceof t?a:new t(function(i){i(a)})}return new(t||(t=Promise))(function(a,i){function o(w){try{l(n.next(w))}catch(T){i(T)}}function c(w){try{l(n.throw(w))}catch(T){i(T)}}function l(w){w.done?a(w.value):s(w.value).then(o,c)}l((n=n.apply(r,e||[])).next())})};class Um{constructor(e){this._semaphore=new zm(1,e)}acquire(){return Pm(this,void 0,void 0,function*(){const[,e]=yield this._semaphore.acquire();return e})}runExclusive(e){return this._semaphore.runExclusive(()=>e())}isLocked(){return this._semaphore.isLocked()}waitForUnlock(){return this._semaphore.waitForUnlock()}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}u.z.object({leaseholder:u.z.number().optional(),keys:u.z.number().array().optional(),names:u.z.string().array().optional(),search:u.z.string().optional(),rangeKey:u.z.string().optional(),limit:u.z.number().optional(),offset:u.z.number().optional()});const Dm=u.z.object({channels:Gs.array()}),ki=class ki{constructor(e){h(this,"client");this.client=e}async search(e,t){return await this.execute({search:e,rangeKey:t})}async retrieve(e,t){const{variant:n,normalized:s}=qr(e);return await this.execute({[n]:s,rangeKey:t})}async page(e,t,n){return await this.execute({offset:e,limit:t,rangeKey:n})}async execute(e){const[t,n]=await this.client.send(ki.ENDPOINT,e,Dm);if(n!=null)throw n;return t.channels}};h(ki,"ENDPOINT","/channel/retrieve");let ms=ki;class fc{constructor(e){h(this,"cache");h(this,"namesToKeys");h(this,"wrapped");this.cache=new Map,this.namesToKeys=new Map,this.wrapped=e}async search(e,t){return await this.wrapped.search(e,t)}async page(e,t,n){return await this.wrapped.page(e,t,n)}async retrieve(e){const{normalized:t}=qr(e),n=[],s=[];if(t.forEach(i=>{const o=this.getFromCache(i);o!=null?n.push(o):s.push(i)}),s.length===0)return n;const a=await this.wrapped.retrieve(s);return this.updateCache(a),n.concat(a)}updateCache(e){e.forEach(t=>{this.cache.set(t.key,t),this.namesToKeys.set(t.name,t.key)})}getFromCache(e){const t=typeof e=="number"?e:this.namesToKeys.get(e);if(t!=null)return this.cache.get(t)}}const qr=r=>{const e=Se(r).filter(t=>t!=0);return{single:!Array.isArray(r),variant:typeof e[0]=="number"?"keys":"names",normalized:e,actual:r}};class Wl{constructor(e,t){h(this,"mu",new Um);h(this,"requests",new Map);h(this,"wrapped");h(this,"debouncedRun");this.wrapped=e,this.debouncedRun=nm(()=>{this.run()},t)}async search(e,t){return await this.wrapped.search(e,t)}async page(e,t,n){return await this.wrapped.page(e,t,n)}async retrieve(e){const{normalized:t,variant:n}=qr(e);return n==="names"?await this.wrapped.retrieve(t):await new Promise((a,i)=>{this.mu.runExclusive(()=>{this.requests.set(t,{resolve:a,reject:i}),this.debouncedRun()})})}async run(){await this.mu.runExclusive(async()=>{const e=new Set;this.requests.forEach((t,n)=>n.forEach(s=>e.add(s)));try{const t=await this.wrapped.retrieve(Array.from(e));this.requests.forEach((n,s)=>n.resolve(t.filter(a=>s.includes(a.key))))}catch(t){this.requests.forEach(n=>n.reject(t))}finally{this.requests.clear()}})}}var Mm=Object.defineProperty,$m=(r,e,t)=>e in r?Mm(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,qe=(r,e,t)=>($m(r,typeof e!="symbol"?e+"":e,t),t),Lm=Object.defineProperty,Bm=(r,e,t)=>e in r?Lm(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,R=(r,e,t)=>(Bm(r,typeof e!="symbol"?e+"":e,t),t),bn,Te;(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})(Te||(Te={}));var To;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(To||(To={}));const $=Te.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Zr=r=>{switch(typeof r){case"undefined":return $.undefined;case"string":return $.string;case"number":return isNaN(r)?$.nan:$.number;case"boolean":return $.boolean;case"function":return $.function;case"bigint":return $.bigint;case"symbol":return $.symbol;case"object":return Array.isArray(r)?$.array:r===null?$.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?$.promise:typeof Map<"u"&&r instanceof Map?$.map:typeof Set<"u"&&r instanceof Set?$.set:typeof Date<"u"&&r instanceof Date?$.date:$.object;default:return $.unknown}},j=Te.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"]),Vm=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");let Dt=class extends Error{constructor(r){super(),this.issues=[],this.addIssue=t=>{this.issues=[...this.issues,t]},this.addIssues=(t=[])=>{this.issues=[...this.issues,...t]};const e=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,e):this.__proto__=e,this.name="ZodError",this.issues=r}get errors(){return this.issues}format(r){const e=r||function(s){return s.message},t={_errors:[]},n=s=>{for(const a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(n);else if(a.code==="invalid_return_type")n(a.returnTypeError);else if(a.code==="invalid_arguments")n(a.argumentsError);else if(a.path.length===0)t._errors.push(e(a));else{let i=t,o=0;for(;o<a.path.length;){const c=a.path[o];o===a.path.length-1?(i[c]=i[c]||{_errors:[]},i[c]._errors.push(e(a))):i[c]=i[c]||{_errors:[]},i=i[c],o++}}};return n(this),t}toString(){return this.message}get message(){return JSON.stringify(this.issues,Te.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(r=e=>e.message){const e={},t=[];for(const n of this.issues)n.path.length>0?(e[n.path[0]]=e[n.path[0]]||[],e[n.path[0]].push(r(n))):t.push(r(n));return{formErrors:t,fieldErrors:e}}get formErrors(){return this.flatten()}};Dt.create=r=>new Dt(r);const ys=(r,e)=>{let t;switch(r.code){case j.invalid_type:r.received===$.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case j.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Te.jsonStringifyReplacer)}`;break;case j.unrecognized_keys:t=`Unrecognized key(s) in object: ${Te.joinValues(r.keys,", ")}`;break;case j.invalid_union:t="Invalid input";break;case j.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Te.joinValues(r.options)}`;break;case j.invalid_enum_value:t=`Invalid enum value. Expected ${Te.joinValues(r.options)}, received '${r.received}'`;break;case j.invalid_arguments:t="Invalid function arguments";break;case j.invalid_return_type:t="Invalid function return type";break;case j.invalid_date:t="Invalid date";break;case j.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}"`:Te.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case j.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 j.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 j.custom:t="Invalid input";break;case j.invalid_intersection_types:t="Intersection results could not be merged";break;case j.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case j.not_finite:t="Number must be finite";break;default:t=e.defaultError,Te.assertNever(r)}return{message:t}};let ql=ys;function Km(r){ql=r}function Xa(){return ql}const Qa=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],i={...s,path:a};let o="";const c=n.filter(l=>!!l).slice().reverse();for(const l of c)o=l(i,{data:e,defaultError:o}).message;return{...s,path:a,message:s.message||o}},Fm=[];function V(r,e){const t=Qa({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Xa(),ys].filter(n=>!!n)});r.common.issues.push(t)}let _t=class Yl{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 se;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 Yl.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 se;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 se=Object.freeze({status:"aborted"}),Jl=r=>({status:"dirty",value:r}),gt=r=>({status:"valid",value:r}),xo=r=>r.status==="aborted",So=r=>r.status==="dirty",gs=r=>r.status==="valid",ei=r=>typeof Promise<"u"&&r instanceof Promise;var q;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(q||(q={}));let Xt=class{constructor(r,e,t,n){this._cachedPath=[],this.parent=r,this.data=e,this._path=t,this._key=n}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 yu=(r,e)=>{if(gs(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 Dt(r.common.issues);return this._error=t,this._error}}};function oe(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}}let de=class{constructor(r){this.spa=this.safeParseAsync,this._def=r,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(r){return Zr(r.data)}_getOrReturnCtx(r,e){return e||{common:r.parent.common,data:r.data,parsedType:Zr(r.data),schemaErrorMap:this._def.errorMap,path:r.path,parent:r.parent}}_processInputParams(r){return{status:new _t,ctx:{common:r.parent.common,data:r.data,parsedType:Zr(r.data),schemaErrorMap:this._def.errorMap,path:r.path,parent:r.parent}}}_parseSync(r){const e=this._parse(r);if(ei(e))throw new Error("Synchronous parse encountered promise.");return e}_parseAsync(r){const e=this._parse(r);return Promise.resolve(e)}parse(r,e){const t=this.safeParse(r,e);if(t.success)return t.data;throw t.error}safeParse(r,e){var t;const n={common:{issues:[],async:(t=e==null?void 0:e.async)!==null&&t!==void 0?t:!1,contextualErrorMap:e==null?void 0:e.errorMap},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:r,parsedType:Zr(r)},s=this._parseSync({data:r,path:n.path,parent:n});return yu(n,s)}async parseAsync(r,e){const t=await this.safeParseAsync(r,e);if(t.success)return t.data;throw t.error}async safeParseAsync(r,e){const t={common:{issues:[],contextualErrorMap:e==null?void 0:e.errorMap,async:!0},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:r,parsedType:Zr(r)},n=this._parse({data:r,path:t.path,parent:t}),s=await(ei(n)?n:Promise.resolve(n));return yu(t,s)}refine(r,e){const t=n=>typeof e=="string"||typeof e>"u"?{message:e}:typeof e=="function"?e(n):e;return this._refinement((n,s)=>{const a=r(n),i=()=>s.addIssue({code:j.custom,...t(n)});return typeof Promise<"u"&&a instanceof Promise?a.then(o=>o?!0:(i(),!1)):a?!0:(i(),!1)})}refinement(r,e){return this._refinement((t,n)=>r(t)?!0:(n.addIssue(typeof e=="function"?e(t,n):e),!1))}_refinement(r){return new Bt({schema:this,typeName:G.ZodEffects,effect:{type:"refinement",refinement:r}})}superRefine(r){return this._refinement(r)}optional(){return Or.create(this,this._def)}nullable(){return hn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return dn.create(this,this._def)}promise(){return Un.create(this,this._def)}or(r){return Ts.create([this,r],this._def)}and(r){return xs.create(this,r,this._def)}transform(r){return new Bt({...oe(this._def),schema:this,typeName:G.ZodEffects,effect:{type:"transform",transform:r}})}default(r){const e=typeof r=="function"?r:()=>r;return new As({...oe(this._def),innerType:this,defaultValue:e,typeName:G.ZodDefault})}brand(){return new nd({typeName:G.ZodBranded,type:this,...oe(this._def)})}catch(r){const e=typeof r=="function"?r:()=>r;return new ai({...oe(this._def),innerType:this,catchValue:e,typeName:G.ZodCatch})}describe(r){const e=this.constructor;return new e({...this._def,description:r})}pipe(r){return pc.create(this,r)}readonly(){return oi.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const Wm=/^c[^\s-]{8,}$/i,qm=/^[a-z][a-z0-9]*$/,Ym=/^[0-9A-HJKMNP-TV-Z]{26}$/,Jm=/^[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,Gm=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Hm="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Qi;const Xm=/^(((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}))$/,Qm=/^(([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})))$/,ey=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 ty(r,e){return!!((e==="v4"||!e)&&Xm.test(r)||(e==="v6"||!e)&&Qm.test(r))}let zn=class Xn extends de{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==$.string){const s=this._getOrReturnCtx(e);return V(s,{code:j.invalid_type,expected:$.string,received:s.parsedType}),se}const t=new _t;let n;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(n=this._getOrReturnCtx(e,n),V(n,{code:j.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),V(n,{code:j.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?V(n,{code:j.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):i&&V(n,{code:j.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")Gm.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:"email",code:j.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")Qi||(Qi=new RegExp(Hm,"u")),Qi.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:"emoji",code:j.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")Jm.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:"uuid",code:j.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")Wm.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:"cuid",code:j.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")qm.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:"cuid2",code:j.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")Ym.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:"ulid",code:j.invalid_string,message:s.message}),t.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),V(n,{validation:"url",code:j.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),V(n,{validation:"regex",code:j.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),V(n,{code:j.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),V(n,{code:j.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(n=this._getOrReturnCtx(e,n),V(n,{code:j.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?ey(s).test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{code:j.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="ip"?ty(e.data,s.version)||(n=this._getOrReturnCtx(e,n),V(n,{validation:"ip",code:j.invalid_string,message:s.message}),t.dirty()):Te.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:j.invalid_string,...q.errToObj(n)})}_addCheck(e){return new Xn({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...q.errToObj(e)})}url(e){return this._addCheck({kind:"url",...q.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...q.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...q.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...q.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...q.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...q.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...q.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,...q.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...q.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...q.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...q.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...q.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...q.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...q.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...q.errToObj(t)})}nonempty(e){return this.min(1,q.errToObj(e))}trim(){return new Xn({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Xn({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Xn({...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}};zn.create=r=>{var e;return new zn({checks:[],typeName:G.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...oe(r)})};function ry(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)}let vs=class Eo extends de{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)!==$.number){const s=this._getOrReturnCtx(e);return V(s,{code:j.invalid_type,expected:$.number,received:s.parsedType}),se}let t;const n=new _t;for(const s of this._def.checks)s.kind==="int"?Te.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),V(t,{code:j.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),V(t,{code:j.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),V(t,{code:j.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="multipleOf"?ry(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),V(t,{code:j.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),V(t,{code:j.not_finite,message:s.message}),n.dirty()):Te.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,q.toString(t))}gt(e,t){return this.setLimit("min",e,!1,q.toString(t))}lte(e,t){return this.setLimit("max",e,!0,q.toString(t))}lt(e,t){return this.setLimit("max",e,!1,q.toString(t))}setLimit(e,t,n,s){return new Eo({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:q.toString(s)}]})}_addCheck(e){return new Eo({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:q.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:q.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:q.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:q.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:q.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:q.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:q.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:q.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:q.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"&&Te.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)}};vs.create=r=>new vs({checks:[],typeName:G.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...oe(r)});let ws=class No extends de{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)!==$.bigint){const s=this._getOrReturnCtx(e);return V(s,{code:j.invalid_type,expected:$.bigint,received:s.parsedType}),se}let t;const n=new _t;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),V(t,{code:j.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),V(t,{code:j.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),V(t,{code:j.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):Te.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,q.toString(t))}gt(e,t){return this.setLimit("min",e,!1,q.toString(t))}lte(e,t){return this.setLimit("max",e,!0,q.toString(t))}lt(e,t){return this.setLimit("max",e,!1,q.toString(t))}setLimit(e,t,n,s){return new No({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:q.toString(s)}]})}_addCheck(e){return new No({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:q.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:q.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:q.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:q.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:q.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}};ws.create=r=>{var e;return new ws({checks:[],typeName:G.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...oe(r)})};let _s=class extends de{_parse(r){if(this._def.coerce&&(r.data=!!r.data),this._getType(r)!==$.boolean){const e=this._getOrReturnCtx(r);return V(e,{code:j.invalid_type,expected:$.boolean,received:e.parsedType}),se}return gt(r.data)}};_s.create=r=>new _s({typeName:G.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...oe(r)});let bs=class Gl extends de{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==$.date){const s=this._getOrReturnCtx(e);return V(s,{code:j.invalid_type,expected:$.date,received:s.parsedType}),se}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return V(s,{code:j.invalid_date}),se}const t=new _t;let n;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(n=this._getOrReturnCtx(e,n),V(n,{code:j.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),V(n,{code:j.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):Te.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Gl({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:q.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:q.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}};bs.create=r=>new bs({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:G.ZodDate,...oe(r)});let ti=class extends de{_parse(r){if(this._getType(r)!==$.symbol){const e=this._getOrReturnCtx(r);return V(e,{code:j.invalid_type,expected:$.symbol,received:e.parsedType}),se}return gt(r.data)}};ti.create=r=>new ti({typeName:G.ZodSymbol,...oe(r)});let ks=class extends de{_parse(r){if(this._getType(r)!==$.undefined){const e=this._getOrReturnCtx(r);return V(e,{code:j.invalid_type,expected:$.undefined,received:e.parsedType}),se}return gt(r.data)}};ks.create=r=>new ks({typeName:G.ZodUndefined,...oe(r)});let Os=class extends de{_parse(r){if(this._getType(r)!==$.null){const e=this._getOrReturnCtx(r);return V(e,{code:j.invalid_type,expected:$.null,received:e.parsedType}),se}return gt(r.data)}};Os.create=r=>new Os({typeName:G.ZodNull,...oe(r)});let Pn=class extends de{constructor(){super(...arguments),this._any=!0}_parse(r){return gt(r.data)}};Pn.create=r=>new Pn({typeName:G.ZodAny,...oe(r)});let sn=class extends de{constructor(){super(...arguments),this._unknown=!0}_parse(r){return gt(r.data)}};sn.create=r=>new sn({typeName:G.ZodUnknown,...oe(r)});let Er=class extends de{_parse(r){const e=this._getOrReturnCtx(r);return V(e,{code:j.invalid_type,expected:$.never,received:e.parsedType}),se}};Er.create=r=>new Er({typeName:G.ZodNever,...oe(r)});let ri=class extends de{_parse(r){if(this._getType(r)!==$.undefined){const e=this._getOrReturnCtx(r);return V(e,{code:j.invalid_type,expected:$.void,received:e.parsedType}),se}return gt(r.data)}};ri.create=r=>new ri({typeName:G.ZodVoid,...oe(r)});let dn=class Ta extends de{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==$.array)return V(t,{code:j.invalid_type,expected:$.array,received:t.parsedType}),se;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(V(t,{code:i?j.too_big:j.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&&(V(t,{code:j.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&&(V(t,{code:j.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 Xt(t,i,t.path,o)))).then(i=>_t.mergeArray(n,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new Xt(t,i,t.path,o)));return _t.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new Ta({...this._def,minLength:{value:e,message:q.toString(t)}})}max(e,t){return new Ta({...this._def,maxLength:{value:e,message:q.toString(t)}})}length(e,t){return new Ta({...this._def,exactLength:{value:e,message:q.toString(t)}})}nonempty(e){return this.min(1,e)}};dn.create=(r,e)=>new dn({type:r,minLength:null,maxLength:null,exactLength:null,typeName:G.ZodArray,...oe(e)});function Tn(r){if(r instanceof Nt){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=Or.create(Tn(n))}return new Nt({...r._def,shape:()=>e})}else return r instanceof dn?new dn({...r._def,type:Tn(r.element)}):r instanceof Or?Or.create(Tn(r.unwrap())):r instanceof hn?hn.create(Tn(r.unwrap())):r instanceof Br?Br.create(r.items.map(e=>Tn(e))):r}let Nt=class It extends de{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=Te.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==$.object){const c=this._getOrReturnCtx(e);return V(c,{code:j.invalid_type,expected:$.object,received:c.parsedType}),se}const{status:t,ctx:n}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof Er&&this._def.unknownKeys==="strip"))for(const c in n.data)a.includes(c)||i.push(c);const o=[];for(const c of a){const l=s[c],w=n.data[c];o.push({key:{status:"valid",value:c},value:l._parse(new Xt(n,w,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Er){const c=this._def.unknownKeys;if(c==="passthrough")for(const l of i)o.push({key:{status:"valid",value:l},value:{status:"valid",value:n.data[l]}});else if(c==="strict")i.length>0&&(V(n,{code:j.unrecognized_keys,keys:i}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const l of i){const w=n.data[l];o.push({key:{status:"valid",value:l},value:c._parse(new Xt(n,w,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of o){const w=await l.key;c.push({key:w,value:await l.value,alwaysSet:l.alwaysSet})}return c}).then(c=>_t.mergeObjectSync(t,c)):_t.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return q.errToObj,new It({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,a,i,o;const c=(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=q.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new It({...this._def,unknownKeys:"strip"})}passthrough(){return new It({...this._def,unknownKeys:"passthrough"})}extend(e){return new It({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new It({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:G.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new It({...this._def,catchall:e})}pick(e){const t={};return Te.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new It({...this._def,shape:()=>t})}omit(e){const t={};return Te.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new It({...this._def,shape:()=>t})}deepPartial(){return Tn(this)}partial(e){const t={};return Te.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new It({...this._def,shape:()=>t})}required(e){const t={};return Te.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof Or;)s=s._def.innerType;t[n]=s}}),new It({...this._def,shape:()=>t})}keyof(){return rd(Te.objectKeys(this.shape))}};Nt.create=(r,e)=>new Nt({shape:()=>r,unknownKeys:"strip",catchall:Er.create(),typeName:G.ZodObject,...oe(e)});Nt.strictCreate=(r,e)=>new Nt({shape:()=>r,unknownKeys:"strict",catchall:Er.create(),typeName:G.ZodObject,...oe(e)});Nt.lazycreate=(r,e)=>new Nt({shape:r,unknownKeys:"strip",catchall:Er.create(),typeName:G.ZodObject,...oe(e)});let Ts=class extends de{_parse(r){const{ctx:e}=this._processInputParams(r),t=this._def.options;function n(s){for(const i of s)if(i.result.status==="valid")return i.result;for(const i of s)if(i.result.status==="dirty")return e.common.issues.push(...i.ctx.common.issues),i.result;const a=s.map(i=>new Dt(i.ctx.common.issues));return V(e,{code:j.invalid_union,unionErrors:a}),se}if(e.common.async)return Promise.all(t.map(async s=>{const a={...e,common:{...e.common,issues:[]},parent:null};return{result:await s._parseAsync({data:e.data,path:e.path,parent:a}),ctx:a}})).then(n);{let s;const a=[];for(const o of t){const c={...e,common:{...e.common,issues:[]},parent:null},l=o._parseSync({data:e.data,path:e.path,parent:c});if(l.status==="valid")return l;l.status==="dirty"&&!s&&(s={result:l,ctx:c}),c.common.issues.length&&a.push(c.common.issues)}if(s)return e.common.issues.push(...s.ctx.common.issues),s.result;const i=a.map(o=>new Dt(o));return V(e,{code:j.invalid_union,unionErrors:i}),se}}get options(){return this._def.options}};Ts.create=(r,e)=>new Ts({options:r,typeName:G.ZodUnion,...oe(e)});const xa=r=>r instanceof Ss?xa(r.schema):r instanceof Bt?xa(r.innerType()):r instanceof Es?[r.value]:r instanceof Hs?r.options:r instanceof Ns?Object.keys(r.enum):r instanceof As?xa(r._def.innerType):r instanceof ks?[void 0]:r instanceof Os?[null]:null;let Hl=class Xl extends de{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==$.object)return V(t,{code:j.invalid_type,expected:$.object,received:t.parsedType}),se;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}):(V(t,{code:j.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),se)}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=xa(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 Xl({typeName:G.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...oe(n)})}};function Ao(r,e){const t=Zr(r),n=Zr(e);if(r===e)return{valid:!0,data:r};if(t===$.object&&n===$.object){const s=Te.objectKeys(e),a=Te.objectKeys(r).filter(o=>s.indexOf(o)!==-1),i={...r,...e};for(const o of a){const c=Ao(r[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===$.array&&n===$.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],c=Ao(i,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===$.date&&n===$.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}let xs=class extends de{_parse(r){const{status:e,ctx:t}=this._processInputParams(r),n=(s,a)=>{if(xo(s)||xo(a))return se;const i=Ao(s.value,a.value);return i.valid?((So(s)||So(a))&&e.dirty(),{status:e.value,value:i.data}):(V(t,{code:j.invalid_intersection_types}),se)};return t.common.async?Promise.all([this._def.left._parseAsync({data:t.data,path:t.path,parent:t}),this._def.right._parseAsync({data:t.data,path:t.path,parent:t})]).then(([s,a])=>n(s,a)):n(this._def.left._parseSync({data:t.data,path:t.path,parent:t}),this._def.right._parseSync({data:t.data,path:t.path,parent:t}))}};xs.create=(r,e,t)=>new xs({left:r,right:e,typeName:G.ZodIntersection,...oe(t)});let Br=class Ql extends de{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==$.array)return V(n,{code:j.invalid_type,expected:$.array,received:n.parsedType}),se;if(n.data.length<this._def.items.length)return V(n,{code:j.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),se;!this._def.rest&&n.data.length>this._def.items.length&&(V(n,{code:j.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 Xt(n,a,n.path,i)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>_t.mergeArray(t,a)):_t.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new Ql({...this._def,rest:e})}};Br.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Br({items:r,typeName:G.ZodTuple,rest:null,...oe(e)})};let ed=class Io extends de{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!==$.object)return V(n,{code:j.invalid_type,expected:$.object,received:n.parsedType}),se;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)s.push({key:a._parse(new Xt(n,o,n.path,o)),value:i._parse(new Xt(n,n.data[o],n.path,o))});return n.common.async?_t.mergeObjectAsync(t,s):_t.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof de?new Io({keyType:e,valueType:t,typeName:G.ZodRecord,...oe(n)}):new Io({keyType:zn.create(),valueType:e,typeName:G.ZodRecord,...oe(t)})}},ni=class extends de{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(r){const{status:e,ctx:t}=this._processInputParams(r);if(t.parsedType!==$.map)return V(t,{code:j.invalid_type,expected:$.map,received:t.parsedType}),se;const n=this._def.keyType,s=this._def.valueType,a=[...t.data.entries()].map(([i,o],c)=>({key:n._parse(new Xt(t,i,t.path,[c,"key"])),value:s._parse(new Xt(t,o,t.path,[c,"value"]))}));if(t.common.async){const i=new Map;return Promise.resolve().then(async()=>{for(const o of a){const c=await o.key,l=await o.value;if(c.status==="aborted"||l.status==="aborted")return se;(c.status==="dirty"||l.status==="dirty")&&e.dirty(),i.set(c.value,l.value)}return{status:e.value,value:i}})}else{const i=new Map;for(const o of a){const c=o.key,l=o.value;if(c.status==="aborted"||l.status==="aborted")return se;(c.status==="dirty"||l.status==="dirty")&&e.dirty(),i.set(c.value,l.value)}return{status:e.value,value:i}}}};ni.create=(r,e,t)=>new ni({valueType:e,keyType:r,typeName:G.ZodMap,...oe(t)});let si=class Co extends de{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==$.set)return V(n,{code:j.invalid_type,expected:$.set,received:n.parsedType}),se;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(V(n,{code:j.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&&(V(n,{code:j.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(c){const l=new Set;for(const w of c){if(w.status==="aborted")return se;w.status==="dirty"&&t.dirty(),l.add(w.value)}return{status:t.value,value:l}}const o=[...n.data.values()].map((c,l)=>a._parse(new Xt(n,c,n.path,l)));return n.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new Co({...this._def,minSize:{value:e,message:q.toString(t)}})}max(e,t){return new Co({...this._def,maxSize:{value:e,message:q.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};si.create=(r,e)=>new si({valueType:r,minSize:null,maxSize:null,typeName:G.ZodSet,...oe(e)});let td=class Sa extends de{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==$.function)return V(t,{code:j.invalid_type,expected:$.function,received:t.parsedType}),se;function n(o,c){return Qa({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Xa(),ys].filter(l=>!!l),issueData:{code:j.invalid_arguments,argumentsError:c}})}function s(o,c){return Qa({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Xa(),ys].filter(l=>!!l),issueData:{code:j.invalid_return_type,returnTypeError:c}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Un){const o=this;return gt(async function(...c){const l=new Dt([]),w=await o._def.args.parseAsync(c,a).catch(X=>{throw l.addIssue(n(c,X)),l}),T=await Reflect.apply(i,this,w);return await o._def.returns._def.type.parseAsync(T,a).catch(X=>{throw l.addIssue(s(T,X)),l})})}else{const o=this;return gt(function(...c){const l=o._def.args.safeParse(c,a);if(!l.success)throw new Dt([n(c,l.error)]);const w=Reflect.apply(i,this,l.data),T=o._def.returns.safeParse(w,a);if(!T.success)throw new Dt([s(w,T.error)]);return T.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Sa({...this._def,args:Br.create(e).rest(sn.create())})}returns(e){return new Sa({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Sa({args:e||Br.create([]).rest(sn.create()),returns:t||sn.create(),typeName:G.ZodFunction,...oe(n)})}},Ss=class extends de{get schema(){return this._def.getter()}_parse(r){const{ctx:e}=this._processInputParams(r);return this._def.getter()._parse({data:e.data,path:e.path,parent:e})}};Ss.create=(r,e)=>new Ss({getter:r,typeName:G.ZodLazy,...oe(e)});let Es=class extends de{_parse(r){if(r.data!==this._def.value){const e=this._getOrReturnCtx(r);return V(e,{received:e.data,code:j.invalid_literal,expected:this._def.value}),se}return{status:"valid",value:r.data}}get value(){return this._def.value}};Es.create=(r,e)=>new Es({value:r,typeName:G.ZodLiteral,...oe(e)});function rd(r,e){return new Hs({values:r,typeName:G.ZodEnum,...oe(e)})}let Hs=class jo extends de{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return V(t,{expected:Te.joinValues(n),received:t.parsedType,code:j.invalid_type}),se}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),n=this._def.values;return V(t,{received:t.data,code:j.invalid_enum_value,options:n}),se}return gt(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 jo.create(e)}exclude(e){return jo.create(this.options.filter(t=>!e.includes(t)))}};Hs.create=rd;let Ns=class extends de{_parse(r){const e=Te.getValidEnumValues(this._def.values),t=this._getOrReturnCtx(r);if(t.parsedType!==$.string&&t.parsedType!==$.number){const n=Te.objectValues(e);return V(t,{expected:Te.joinValues(n),received:t.parsedType,code:j.invalid_type}),se}if(e.indexOf(r.data)===-1){const n=Te.objectValues(e);return V(t,{received:t.data,code:j.invalid_enum_value,options:n}),se}return gt(r.data)}get enum(){return this._def.values}};Ns.create=(r,e)=>new Ns({values:r,typeName:G.ZodNativeEnum,...oe(e)});let Un=class extends de{unwrap(){return this._def.type}_parse(r){const{ctx:e}=this._processInputParams(r);if(e.parsedType!==$.promise&&e.common.async===!1)return V(e,{code:j.invalid_type,expected:$.promise,received:e.parsedType}),se;const t=e.parsedType===$.promise?e.data:Promise.resolve(e.data);return gt(t.then(n=>this._def.type.parseAsync(n,{path:e.path,errorMap:e.common.contextualErrorMap})))}};Un.create=(r,e)=>new Un({type:r,typeName:G.ZodPromise,...oe(e)});let Bt=class extends de{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===G.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(r){const{status:e,ctx:t}=this._processInputParams(r),n=this._def.effect||null,s={addIssue:a=>{V(t,a),a.fatal?e.abort():e.dirty()},get path(){return t.path}};if(s.addIssue=s.addIssue.bind(s),n.type==="preprocess"){const a=n.transform(t.data,s);return t.common.issues.length?{status:"dirty",value:t.data}:t.common.async?Promise.resolve(a).then(i=>this._def.schema._parseAsync({data:i,path:t.path,parent:t})):this._def.schema._parseSync({data:a,path:t.path,parent:t})}if(n.type==="refinement"){const a=i=>{const o=n.refinement(i,s);if(t.common.async)return Promise.resolve(o);if(o instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(t.common.async===!1){const i=this._def.schema._parseSync({data:t.data,path:t.path,parent:t});return i.status==="aborted"?se:(i.status==="dirty"&&e.dirty(),a(i.value),{status:e.value,value:i.value})}else return this._def.schema._parseAsync({data:t.data,path:t.path,parent:t}).then(i=>i.status==="aborted"?se:(i.status==="dirty"&&e.dirty(),a(i.value).then(()=>({status:e.value,value:i.value}))))}if(n.type==="transform")if(t.common.async===!1){const a=this._def.schema._parseSync({data:t.data,path:t.path,parent:t});if(!gs(a))return a;const i=n.transform(a.value,s);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:e.value,value:i}}else return this._def.schema._parseAsync({data:t.data,path:t.path,parent:t}).then(a=>gs(a)?Promise.resolve(n.transform(a.value,s)).then(i=>({status:e.value,value:i})):a);Te.assertNever(n)}};Bt.create=(r,e,t)=>new Bt({schema:r,typeName:G.ZodEffects,effect:e,...oe(t)});Bt.createWithPreprocess=(r,e,t)=>new Bt({schema:e,effect:{type:"preprocess",transform:r},typeName:G.ZodEffects,...oe(t)});let Or=class extends de{_parse(r){return this._getType(r)===$.undefined?gt(void 0):this._def.innerType._parse(r)}unwrap(){return this._def.innerType}};Or.create=(r,e)=>new Or({innerType:r,typeName:G.ZodOptional,...oe(e)});let hn=class extends de{_parse(r){return this._getType(r)===$.null?gt(null):this._def.innerType._parse(r)}unwrap(){return this._def.innerType}};hn.create=(r,e)=>new hn({innerType:r,typeName:G.ZodNullable,...oe(e)});let As=class extends de{_parse(r){const{ctx:e}=this._processInputParams(r);let t=e.data;return e.parsedType===$.undefined&&(t=this._def.defaultValue()),this._def.innerType._parse({data:t,path:e.path,parent:e})}removeDefault(){return this._def.innerType}};As.create=(r,e)=>new As({innerType:r,typeName:G.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...oe(e)});let ai=class extends de{_parse(r){const{ctx:e}=this._processInputParams(r),t={...e,common:{...e.common,issues:[]}},n=this._def.innerType._parse({data:t.data,path:t.path,parent:{...t}});return ei(n)?n.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Dt(t.common.issues)},input:t.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new Dt(t.common.issues)},input:t.data})}}removeCatch(){return this._def.innerType}};ai.create=(r,e)=>new ai({innerType:r,typeName:G.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...oe(e)});let ii=class extends de{_parse(r){if(this._getType(r)!==$.nan){const e=this._getOrReturnCtx(r);return V(e,{code:j.invalid_type,expected:$.nan,received:e.parsedType}),se}return{status:"valid",value:r.data}}};ii.create=r=>new ii({typeName:G.ZodNaN,...oe(r)});const ny=Symbol("zod_brand");let nd=class extends de{_parse(r){const{ctx:e}=this._processInputParams(r),t=e.data;return this._def.type._parse({data:t,path:e.path,parent:e})}unwrap(){return this._def.type}},pc=class sd extends de{_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"?se:s.status==="dirty"?(t.dirty(),Jl(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"?se: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 sd({in:e,out:t,typeName:G.ZodPipeline})}},oi=class extends de{_parse(r){const e=this._def.innerType._parse(r);return gs(e)&&(e.value=Object.freeze(e.value)),e}};oi.create=(r,e)=>new oi({innerType:r,typeName:G.ZodReadonly,...oe(e)});const ad=(r,e={},t)=>r?Pn.create().superRefine((n,s)=>{var a,i;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,l=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...l,fatal:c})}}):Pn.create(),sy={object:Nt.lazycreate};var G;(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"})(G||(G={}));const ay=(r,e={message:`Input not instance of ${r.name}`})=>ad(t=>t instanceof r,e),id=zn.create,od=vs.create,iy=ii.create,oy=ws.create,cd=_s.create,cy=bs.create,uy=ti.create,ly=ks.create,dy=Os.create,hy=Pn.create,fy=sn.create,py=Er.create,my=ri.create,yy=dn.create,gy=Nt.create,vy=Nt.strictCreate,wy=Ts.create,_y=Hl.create,by=xs.create,ky=Br.create,Oy=ed.create,Ty=ni.create,xy=si.create,Sy=td.create,Ey=Ss.create,Ny=Es.create,Ay=Hs.create,Iy=Ns.create,Cy=Un.create,gu=Bt.create,jy=Or.create,Zy=hn.create,Ry=Bt.createWithPreprocess,zy=pc.create,Py=()=>id().optional(),Uy=()=>od().optional(),Dy=()=>cd().optional(),My={string:r=>zn.create({...r,coerce:!0}),number:r=>vs.create({...r,coerce:!0}),boolean:r=>_s.create({...r,coerce:!0}),bigint:r=>ws.create({...r,coerce:!0}),date:r=>bs.create({...r,coerce:!0})},$y=se;var N=Object.freeze({__proto__:null,defaultErrorMap:ys,setErrorMap:Km,getErrorMap:Xa,makeIssue:Qa,EMPTY_PATH:Fm,addIssueToContext:V,ParseStatus:_t,INVALID:se,DIRTY:Jl,OK:gt,isAborted:xo,isDirty:So,isValid:gs,isAsync:ei,get util(){return Te},get objectUtil(){return To},ZodParsedType:$,getParsedType:Zr,ZodType:de,ZodString:zn,ZodNumber:vs,ZodBigInt:ws,ZodBoolean:_s,ZodDate:bs,ZodSymbol:ti,ZodUndefined:ks,ZodNull:Os,ZodAny:Pn,ZodUnknown:sn,ZodNever:Er,ZodVoid:ri,ZodArray:dn,ZodObject:Nt,ZodUnion:Ts,ZodDiscriminatedUnion:Hl,ZodIntersection:xs,ZodTuple:Br,ZodRecord:ed,ZodMap:ni,ZodSet:si,ZodFunction:td,ZodLazy:Ss,ZodLiteral:Es,ZodEnum:Hs,ZodNativeEnum:Ns,ZodPromise:Un,ZodEffects:Bt,ZodTransformer:Bt,ZodOptional:Or,ZodNullable:hn,ZodDefault:As,ZodCatch:ai,ZodNaN:ii,BRAND:ny,ZodBranded:nd,ZodPipeline:pc,ZodReadonly:oi,custom:ad,Schema:de,ZodSchema:de,late:sy,get ZodFirstPartyTypeKind(){return G},coerce:My,any:hy,array:yy,bigint:oy,boolean:cd,date:cy,discriminatedUnion:_y,effect:gu,enum:Ay,function:Sy,instanceof:ay,intersection:by,lazy:Ey,literal:Ny,map:Ty,nan:iy,nativeEnum:Iy,never:py,null:dy,nullable:Zy,number:od,object:gy,oboolean:Dy,onumber:Uy,optional:jy,ostring:Py,pipeline:zy,preprocess:Ry,promise:Cy,record:Oy,set:xy,strictObject:vy,string:id,symbol:uy,transformer:gu,tuple:ky,undefined:ly,union:wy,unknown:fy,void:my,NEVER:$y,ZodIssueCode:j,quotelessJson:Vm,ZodError:Dt});const mc=N.tuple([N.number(),N.number()]),ud=N.object({width:N.number(),height:N.number()}),Ly=N.object({signedWidth:N.number(),signedHeight:N.number()}),By=["width","height"];N.enum(By);const Vy=["start","center","end"],Ky=["signedWidth","signedHeight"];N.enum(Ky);const ci=N.object({x:N.number(),y:N.number()}),Fy=N.object({clientX:N.number(),clientY:N.number()}),Wy=["x","y"],ld=N.enum(Wy),dd=["top","right","bottom","left"];N.enum(dd);const qy=["left","right"],hd=N.enum(qy),Yy=["top","bottom"],fd=N.enum(Yy),pd=["center"],vu=N.enum(pd),Jy=[...dd,...pd],md=N.enum(Jy);N.enum(Vy);const Gy=["first","last"];N.enum(Gy);const Hy=N.object({lower:N.number(),upper:N.number()});N.union([Hy,mc]);N.union([ld,md]);N.union([ld,md,N.instanceof(String)]);const eo=(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),Xy(t)},Xy=r=>r.lower>r.upper?{lower:r.upper,upper:r.lower}:r;var At=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},ye={},ji={};Object.defineProperty(ji,"__esModule",{value:!0});function Qy(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()}):""}ji.default=Qy;var Zi={};Object.defineProperty(Zi,"__esModule",{value:!0});function eg(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():""}Zi.default=eg;var Ri={};Object.defineProperty(Ri,"__esModule",{value:!0});function tg(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()}):""}Ri.default=tg;var yc={};Object.defineProperty(yc,"__esModule",{value:!0});function rg(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():""}yc.default=rg;var gc={};Object.defineProperty(gc,"__esModule",{value:!0});function ng(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():""}gc.default=ng;var vc={};Object.defineProperty(vc,"__esModule",{value:!0});function sg(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():""}vc.default=sg;var wc={};Object.defineProperty(wc,"__esModule",{value:!0});function ag(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)}wc.default=ag;var _c={};Object.defineProperty(_c,"__esModule",{value:!0});function ig(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}):""}_c.default=ig;var zi={};Object.defineProperty(zi,"__esModule",{value:!0});function og(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():""}zi.default=og;var bc={},vn={};(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})}})(vn);var cg=At&&At.__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(bc,"__esModule",{value:!0});var dr=vn;function Ea(r,e){if(e===void 0&&(e=dr.DefaultOption),!dr.isValidObject(r))return null;e=dr.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=n.toLowerCase();e.recursive&&(dr.isValidObject(s)?dr.belongToTypes(s,e.keepTypesOnRecursion)||(s=Ea(s,e)):e.recursiveInArray&&dr.isArrayObject(s)&&(s=cg(s).map(function(i){var o=i;if(dr.isValidObject(i))dr.belongToTypes(o,e.keepTypesOnRecursion)||(o=Ea(i,e));else if(dr.isArrayObject(i)){var c=Ea({key:i},e);o=c.key}return o}))),t[a]=s}),t}bc.default=Ea;var kc={},ug=At&&At.__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(kc,"__esModule",{value:!0});var hr=vn;function Na(r,e){if(e===void 0&&(e=hr.DefaultOption),!hr.isValidObject(r))return null;e=hr.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=n.toUpperCase();e.recursive&&(hr.isValidObject(s)?hr.belongToTypes(s,e.keepTypesOnRecursion)||(s=Na(s,e)):e.recursiveInArray&&hr.isArrayObject(s)&&(s=ug(s).map(function(i){var o=i;if(hr.isValidObject(i))hr.belongToTypes(o,e.keepTypesOnRecursion)||(o=Na(i,e));else if(hr.isArrayObject(i)){var c=Na({key:i},e);o=c.key}return o}))),t[a]=s}),t}kc.default=Na;var Oc={},lg=At&&At.__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(Oc,"__esModule",{value:!0});var fr=vn,dg=ji;function Aa(r,e){if(e===void 0&&(e=fr.DefaultOption),!fr.isValidObject(r))return null;e=fr.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=dg.default(n);e.recursive&&(fr.isValidObject(s)?fr.belongToTypes(s,e.keepTypesOnRecursion)||(s=Aa(s,e)):e.recursiveInArray&&fr.isArrayObject(s)&&(s=lg(s).map(function(i){var o=i;if(fr.isValidObject(i))fr.belongToTypes(o,e.keepTypesOnRecursion)||(o=Aa(i,e));else if(fr.isArrayObject(i)){var c=Aa({key:i},e);o=c.key}return o}))),t[a]=s}),t}Oc.default=Aa;var Tc={},hg=At&&At.__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(Tc,"__esModule",{value:!0});var pr=vn,fg=Zi;function Ia(r,e){if(e===void 0&&(e=pr.DefaultOption),!pr.isValidObject(r))return null;e=pr.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=fg.default(n);e.recursive&&(pr.isValidObject(s)?pr.belongToTypes(s,e.keepTypesOnRecursion)||(s=Ia(s,e)):e.recursiveInArray&&pr.isArrayObject(s)&&(s=hg(s).map(function(i){var o=i;if(pr.isValidObject(i))pr.belongToTypes(o,e.keepTypesOnRecursion)||(o=Ia(i,e));else if(pr.isArrayObject(i)){var c=Ia({key:i},e);o=c.key}return o}))),t[a]=s}),t}Tc.default=Ia;var xc={},pg=At&&At.__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(xc,"__esModule",{value:!0});var mr=vn,mg=Ri;function Ca(r,e){if(e===void 0&&(e=mr.DefaultOption),!mr.isValidObject(r))return null;e=mr.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=mg.default(n);e.recursive&&(mr.isValidObject(s)?mr.belongToTypes(s,e.keepTypesOnRecursion)||(s=Ca(s,e)):e.recursiveInArray&&mr.isArrayObject(s)&&(s=pg(s).map(function(i){var o=i;if(mr.isValidObject(i))mr.belongToTypes(o,e.keepTypesOnRecursion)||(o=Ca(i,e));else if(mr.isArrayObject(i)){var c=Ca({key:i},e);o=c.key}return o}))),t[a]=s}),t}xc.default=Ca;var Sc={},yg=At&&At.__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(Sc,"__esModule",{value:!0});var yr=vn,gg=zi;function ja(r,e){if(e===void 0&&(e=yr.DefaultOption),!yr.isValidObject(r))return null;e=yr.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=gg.default(n);e.recursive&&(yr.isValidObject(s)?yr.belongToTypes(s,e.keepTypesOnRecursion)||(s=ja(s,e)):e.recursiveInArray&&yr.isArrayObject(s)&&(s=yg(s).map(function(i){var o=i;if(yr.isValidObject(i))yr.belongToTypes(o,e.keepTypesOnRecursion)||(o=ja(i,e));else if(yr.isArrayObject(i)){var c=ja({key:i},e);o=c.key}return o}))),t[a]=s}),t}Sc.default=ja;Object.defineProperty(ye,"__esModule",{value:!0});ye.kebabKeys=ye.pascalKeys=ye.snakeKeys=ye.camelKeys=ye.upperKeys=ye.lowerKeys=ye.toLowerCase=ye.toUpperCase=ye.toKebabCase=ye.toHeaderCase=ye.toSentenceCase=ye.toTextCase=ye.toPathCase=ye.toDotCase=ye.toPascalCase=ye.toSnakeCase=ye.toCamelCase=void 0;var yd=ji;ye.toCamelCase=yd.default;var gd=Zi;ye.toSnakeCase=gd.default;var vd=Ri;ye.toPascalCase=vd.default;var wd=yc;ye.toDotCase=wd.default;var _d=gc;ye.toPathCase=_d.default;var bd=vc;ye.toTextCase=bd.default;var kd=wc;ye.toSentenceCase=kd.default;var Od=_c;ye.toHeaderCase=Od.default;var Td=zi;ye.toKebabCase=Td.default;var xd=bc;ye.lowerKeys=xd.default;var Sd=kc;ye.upperKeys=Sd.default;var Ed=Oc;ye.camelKeys=Ed.default;var Nd=Tc;ye.snakeKeys=Nd.default;var Ad=xc;ye.pascalKeys=Ad.default;var Id=Sc;ye.kebabKeys=Id.default;var Cd=function(r){return String(r||"").toLowerCase()};ye.toLowerCase=Cd;var jd=function(r){return String(r||"").toUpperCase()};ye.toUpperCase=jd;var vg={toCamelCase:yd.default,toSnakeCase:gd.default,toPascalCase:vd.default,toDotCase:wd.default,toPathCase:_d.default,toTextCase:bd.default,toSentenceCase:kd.default,toHeaderCase:Od.default,toKebabCase:Td.default,toUpperCase:jd,toLowerCase:Cd,lowerKeys:xd.default,upperKeys:Sd.default,camelKeys:Ed.default,snakeKeys:Nd.default,pascalKeys:Ad.default,kebabKeys:Id.default};ye.default=vg;var Zd=ye;const Rd={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},wg=r=>Zd.snakeKeys(r,Rd),_g=r=>Zd.camelKeys(r,Rd);var Dn;(r=>{r.toSnake=wg,r.toCamel=_g,r.capitalize=e=>e[0].toUpperCase()+e.slice(1)})(Dn||(Dn={}));N.object({x:hd.or(vu),y:fd.or(vu)});const bg=N.object({x:hd,y:fd}),kg=Object.freeze({x:"left",y:"top"}),Og=(r,e)=>r.x===e.x&&r.y===e.y,wu=N.union([N.number(),ci,mc,ud,Ly,Fy]),Tg=(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}},_u={x:0,y:0},la=N.union([N.number(),N.string()]);N.object({top:la,left:la,width:la,height:la});N.object({left:N.number(),top:N.number(),right:N.number(),bottom:N.number()});N.object({one:ci,two:ci,root:bg});const Ec=(r,e,t=0,n=0,s)=>{const a={one:{..._u},two:{..._u},root:s??kg};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))},to=r=>{const e=Ec(r);return{lower:e.one.x,upper:e.two.x}},ro=r=>{const e=Ec(r);return{lower:e.one.y,upper:e.two.y}},xg=r=>typeof r!="object"||r==null?!1:"one"in r&&"two"in r&&"root"in r,Sg=N.object({signedWidth:N.number(),signedHeight:N.number()});N.union([ud,Sg,ci,mc]);const Eg=(r,e,t)=>(e!=null&&(r=Math.max(r,e)),t!=null&&(r=Math.min(r,t)),r);N.object({offset:wu,scale:wu});const Ng=r=>(e,t,n,s)=>t==="dimension"?[e,n]:[e,s?n-r:n+r],Ag=r=>(e,t,n,s)=>[e,s?n/r:n*r],Ig=r=>(e,t,n)=>{if(e===null)return[r,n];const{lower:s,upper:a}=e,{lower:i,upper:o}=r,c=a-s,l=o-i;if(t==="dimension")return[r,n*(l/c)];const w=(n-s)*(l/c)+i;return[r,w]},Cg=r=>(e,t,n)=>[r,n],jg=()=>(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)]},Zg=r=>(e,t,n)=>{const{lower:s,upper:a}=r;return n=Eg(n,s,a),[e,n]},Zo=class Qn{constructor(){R(this,"ops",[]),R(this,"currBounds",null),R(this,"currType",null),R(this,"reversed",!1),this.ops=[]}static translate(e){return new Qn().translate(e)}static magnify(e){return new Qn().magnify(e)}static scale(e,t){return new Qn().scale(e,t)}translate(e){const t=this.new(),n=Ng(e);return n.type="translate",t.ops.push(n),t}magnify(e){const t=this.new(),n=Ag(e);return n.type="magnify",t.ops.push(n),t}scale(e,t){const n=eo(e,t),s=this.new(),a=Ig(n);return a.type="scale",s.ops.push(a),s}clamp(e,t){const n=eo(e,t),s=this.new(),a=Zg(n);return a.type="clamp",s.ops.push(a),s}reBound(e,t){const n=eo(e,t),s=this.new(),a=Cg(n);return a.type="re-bound",s.ops.push(a),s}invert(){const e=jg();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 Qn;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}};R(Zo,"IDENTITY",new Zo);let bu=Zo;const ku=class vr{constructor(e=new bu,t=new bu,n=null){R(this,"x"),R(this,"y"),R(this,"currRoot"),this.x=e,this.y=t,this.currRoot=n}static translate(e,t){return new vr().translate(e,t)}static translateX(e){return new vr().translateX(e)}static translateY(e){return new vr().translateY(e)}static clamp(e){return new vr().clamp(e)}static magnify(e){return new vr().magnify(e)}static scale(e){return new vr().scale(e)}static reBound(e){return new vr().reBound(e)}translate(e,t){const n=Tg(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(xg(e)){const n=this.currRoot;return t.currRoot=e.root,n!=null&&!Og(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(to(e)),t.y=t.y.scale(ro(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(to(e)),t.y=this.y.reBound(ro(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(to(e)),t.y=this.y.clamp(ro(e)),t}copy(){const e=new vr;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 Ec(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};R(ku,"IDENTITY",new ku);const zd=(r,e)=>{const t=new kt(e);if(![ft.DAY,ft.HOUR,ft.MINUTE,ft.SECOND,ft.MILLISECOND,ft.MICROSECOND,ft.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 kt?new kt(n):new ft(n)},je=class pe extends Number{constructor(e,t="UTC"){if(e==null)return pe.now();if(e instanceof Date)super(e.getTime()*pe.MILLISECOND.valueOf());else if(typeof e=="string")super(pe.parseDateTimeString(e,t).valueOf());else if(Array.isArray(e))super(pe.parseDate(e));else{let n=0;e instanceof Number&&(e=e.valueOf()),t==="local"&&(n=pe.utcOffset.valueOf()),super(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 pe(s.getTime()*pe.MILLISECOND.valueOf()).truncate(pe.DAY).valueOf()}static parseTimeString(e,t="UTC"){const[n,s,a]=e.split(":");let i="00",o="00";a!=null&&([i,o]=a.split("."));let c=pe.hours(parseInt(n??"00",10)).add(pe.minutes(parseInt(s??"00",10))).add(pe.seconds(parseInt(i??"00",10))).add(pe.milliseconds(parseInt(o??"00",10)));return t==="local"&&(c=c.add(pe.utcOffset)),c.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return pe.parseTimeString(e,t);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new pe(n.getTime()*pe.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(pe.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 ft(new Date().getTimezoneOffset()*pe.MINUTE.valueOf())}static since(e){return new pe().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new pe(e).valueOf()}span(e){return this.range(e).span}range(e){return new Rg(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===0}after(e){return this.valueOf()>new pe(e).valueOf()}afterEq(e){return this.valueOf()>=new pe(e).valueOf()}before(e){return this.valueOf()<new pe(e).valueOf()}beforeEq(e){return this.valueOf()<=new pe(e).valueOf()}add(e){return new pe(this.valueOf()+e.valueOf())}sub(e){return new pe(this.valueOf()-e.valueOf())}milliseconds(){return this.valueOf()/pe.MILLISECOND.valueOf()}toString(){return this.date().toISOString()}remainder(e){return zd(this,e)}get isToday(){return this.truncate(ft.DAY).equals(pe.now().truncate(ft.DAY))}truncate(e){return this.sub(this.remainder(e))}get bigInt(){return BigInt(this.valueOf())}static now(){return new pe(new Date)}static nanoseconds(e){return new pe(e)}static microseconds(e){return pe.nanoseconds(e*1e3)}static milliseconds(e){return pe.microseconds(e*1e3)}static seconds(e){return pe.milliseconds(e*1e3)}static minutes(e){return pe.seconds(e*60)}static hours(e){return pe.minutes(e*60)}static days(e){return pe.hours(e*24)}};R(je,"NANOSECOND",je.nanoseconds(1));R(je,"MICROSECOND",je.microseconds(1));R(je,"MILLISECOND",je.milliseconds(1));R(je,"SECOND",je.seconds(1));R(je,"MINUTE",je.minutes(1));R(je,"HOUR",je.hours(1));R(je,"DAY",je.days(1));R(je,"MAX",new je(9122272036554776e3));R(je,"MIN",new je(0));R(je,"ZERO",new je(0));R(je,"z",N.union([N.instanceof(Number).transform(r=>new je(r)),N.number().transform(r=>new je(r)),N.instanceof(je)]));let kt=je;const Ie=class ke extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}lessThan(e){return this.valueOf()<new ke(e).valueOf()}greaterThan(e){return this.valueOf()>new ke(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new ke(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new ke(e).valueOf()}remainder(e){return zd(this,e)}truncate(e){return new ke(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}multiply(e){return new ke(this.valueOf()*e)}toString(){const e=this.truncate(ke.DAY),t=this.truncate(ke.HOUR),n=this.truncate(ke.MINUTE),s=this.truncate(ke.SECOND),a=this.truncate(ke.MILLISECOND),i=this.truncate(ke.MICROSECOND),o=this.truncate(ke.NANOSECOND),c=e,l=t.sub(e),w=n.sub(t),T=s.sub(n),X=a.sub(s),Q=i.sub(a),Ze=o.sub(i);let ee="";return c.isZero||(ee+=`${c.days}d `),l.isZero||(ee+=`${l.hours}h `),w.isZero||(ee+=`${w.minutes}m `),T.isZero||(ee+=`${T.seconds}s `),X.isZero||(ee+=`${X.milliseconds}ms `),Q.isZero||(ee+=`${Q.microseconds}µs `),Ze.isZero||(ee+=`${Ze.nanoseconds}ns`),ee.trim()}get days(){return this.valueOf()/ke.DAY.valueOf()}get hours(){return this.valueOf()/ke.HOUR.valueOf()}get minutes(){return this.valueOf()/ke.MINUTE.valueOf()}get seconds(){return this.valueOf()/ke.SECOND.valueOf()}get milliseconds(){return this.valueOf()/ke.MILLISECOND.valueOf()}get microseconds(){return this.valueOf()/ke.MICROSECOND.valueOf()}get nanoseconds(){return this.valueOf()}get isZero(){return this.valueOf()===0}equals(e){return this.valueOf()===new ke(e).valueOf()}add(e){return new ke(this.valueOf()+new ke(e).valueOf())}sub(e){return new ke(this.valueOf()-new ke(e).valueOf())}static nanoseconds(e=1){return new ke(e)}static microseconds(e=1){return ke.nanoseconds(e*1e3)}static milliseconds(e=1){return ke.microseconds(e*1e3)}static seconds(e=1){return ke.milliseconds(e*1e3)}static minutes(e){return ke.seconds(e.valueOf()*60)}static hours(e){return ke.minutes(e*60)}static days(e){return ke.hours(e*24)}};R(Ie,"NANOSECOND",Ie.nanoseconds(1));R(Ie,"MICROSECOND",Ie.microseconds(1));R(Ie,"MILLISECOND",Ie.milliseconds(1));R(Ie,"SECOND",Ie.seconds(1));R(Ie,"MINUTE",Ie.minutes(1));R(Ie,"HOUR",Ie.hours(1));R(Ie,"DAY",Ie.days(1));R(Ie,"MAX",new Ie(Ie.MAX_SAFE_INTEGER));R(Ie,"MIN",new Ie(-Ie.MAX_SAFE_INTEGER));R(Ie,"ZERO",new Ie(0));R(Ie,"z",N.union([N.instanceof(Number).transform(r=>new Ie(r)),N.number().transform(r=>new Ie(r)),N.instanceof(Ie)]));let ft=Ie;const da=class Za extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new Za(e).valueOf()}get period(){return ft.seconds(1/this.valueOf())}sampleCount(e){return new ft(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new ht(t).valueOf()}span(e){return ft.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new Za(e)}static khz(e){return Za.hz(e*1e3)}};R(da,"z",N.union([N.number().transform(r=>new da(r)),N.instanceof(Number).transform(r=>new da(r)),N.instanceof(da)]));const rt=class extends Number{constructor(r){r instanceof Number?super(r.valueOf()):super(r)}length(r){return r.valueOf()/this.valueOf()}size(r){return new zg(r*this.valueOf())}};R(rt,"UNKNOWN",new rt(0));R(rt,"BIT128",new rt(16));R(rt,"BIT64",new rt(8));R(rt,"BIT32",new rt(4));R(rt,"BIT16",new rt(2));R(rt,"BIT8",new rt(1));R(rt,"z",N.union([N.number().transform(r=>new rt(r)),N.instanceof(Number).transform(r=>new rt(r)),N.instanceof(rt)]));let ht=rt;const Jt=class Ra{constructor(e,t){R(this,"start"),R(this,"end"),this.start=new kt(e),this.end=new kt(t)}get span(){return new ft(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 Ra(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 Ra?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new Ra(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}};R(Jt,"MAX",new Jt(kt.MIN,kt.MAX));R(Jt,"MIN",new Jt(kt.MAX,kt.MIN));R(Jt,"ZERO",new Jt(kt.ZERO,kt.ZERO));R(Jt,"z",N.union([N.object({start:kt.z,end:kt.z}).transform(r=>new Jt(r.start,r.end)),N.instanceof(Jt)]));let Rg=Jt;const S=class rn extends String{constructor(e){if(e instanceof rn||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const t=rn.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}}throw super(rn.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=rn.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 density(){const e=rn.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 rn.BIG_INT_TYPES.some(e=>e.equals(this))}};R(S,"UNKNOWN",new S("unknown"));R(S,"FLOAT64",new S("float64"));R(S,"FLOAT32",new S("float32"));R(S,"INT64",new S("int64"));R(S,"INT32",new S("int32"));R(S,"INT16",new S("int16"));R(S,"INT8",new S("int8"));R(S,"UINT64",new S("uint64"));R(S,"UINT32",new S("uint32"));R(S,"UINT16",new S("uint16"));R(S,"UINT8",new S("uint8"));R(S,"TIMESTAMP",new S("timestamp"));R(S,"UUID",new S("uuid"));R(S,"STRING",new S("string"));R(S,"JSON",new S("json"));R(S,"ARRAY_CONSTRUCTORS",new Map([[S.UINT8.toString(),Uint8Array],[S.UINT16.toString(),Uint16Array],[S.UINT32.toString(),Uint32Array],[S.UINT64.toString(),BigUint64Array],[S.FLOAT32.toString(),Float32Array],[S.FLOAT64.toString(),Float64Array],[S.INT8.toString(),Int8Array],[S.INT16.toString(),Int16Array],[S.INT32.toString(),Int32Array],[S.INT64.toString(),BigInt64Array],[S.TIMESTAMP.toString(),BigInt64Array],[S.STRING.toString(),Uint8Array],[S.JSON.toString(),Uint8Array],[S.UUID.toString(),Uint8Array]]));R(S,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,S.UINT8],[Uint16Array.name,S.UINT16],[Uint32Array.name,S.UINT32],[BigUint64Array.name,S.UINT64],[Float32Array.name,S.FLOAT32],[Float64Array.name,S.FLOAT64],[Int8Array.name,S.INT8],[Int16Array.name,S.INT16],[Int32Array.name,S.INT32],[BigInt64Array.name,S.INT64]]));R(S,"DENSITIES",new Map([[S.UINT8.toString(),ht.BIT8],[S.UINT16.toString(),ht.BIT16],[S.UINT32.toString(),ht.BIT32],[S.UINT64.toString(),ht.BIT64],[S.FLOAT32.toString(),ht.BIT32],[S.FLOAT64.toString(),ht.BIT64],[S.INT8.toString(),ht.BIT8],[S.INT16.toString(),ht.BIT16],[S.INT32.toString(),ht.BIT32],[S.INT64.toString(),ht.BIT64],[S.TIMESTAMP.toString(),ht.BIT64],[S.STRING.toString(),ht.UNKNOWN],[S.JSON.toString(),ht.UNKNOWN],[S.UUID.toString(),ht.BIT128]]));R(S,"ALL",[S.UNKNOWN,S.FLOAT64,S.FLOAT32,S.INT64,S.INT32,S.INT16,S.INT8,S.UINT64,S.UINT32,S.UINT16,S.UINT8,S.TIMESTAMP,S.UUID,S.STRING,S.JSON]);R(S,"BIG_INT_TYPES",[S.INT64,S.UINT64,S.TIMESTAMP]);R(S,"z",N.union([N.string().transform(r=>new S(r)),N.instanceof(S)]));const it=class We extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return We.bytes(this.valueOf()+e.valueOf())}sub(e){return We.bytes(this.valueOf()-e.valueOf())}truncate(e){return new We(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return We.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/We.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/We.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/We.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/We.TERABYTE.valueOf()}toString(){const e=this.truncate(We.TERABYTE),t=this.truncate(We.GIGABYTE),n=this.truncate(We.MEGABYTE),s=this.truncate(We.KILOBYTE),a=this.truncate(We.BYTE),i=e,o=t.sub(e),c=n.sub(t),l=s.sub(n),w=a.sub(s);let T="";return i.isZero||(T+=`${i.terabytes}TB `),o.isZero||(T+=`${o.gigabytes}GB `),c.isZero||(T+=`${c.megabytes}MB `),l.isZero||(T+=`${l.kilobytes}KB `),(!w.isZero||T==="")&&(T+=`${w.valueOf()}B`),T.trim()}static bytes(e=1){return new We(e)}static kilobytes(e=1){return We.bytes(e.valueOf()*1e3)}static megabytes(e=1){return We.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return We.megabytes(e.valueOf()*1e3)}static terabytes(e){return We.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};R(it,"BYTE",new it(1));R(it,"KILOBYTE",it.kilobytes(1));R(it,"MEGABYTE",it.megabytes(1));R(it,"GIGABYTE",it.gigabytes(1));R(it,"TERABYTE",it.terabytes(1));R(it,"ZERO",new it(0));R(it,"z",N.union([N.number().transform(r=>new it(r)),N.instanceof(it)]));let zg=it;N.union([N.instanceof(Uint8Array),N.instanceof(Uint16Array),N.instanceof(Uint32Array),N.instanceof(BigUint64Array),N.instanceof(Float32Array),N.instanceof(Float64Array),N.instanceof(Int8Array),N.instanceof(Int16Array),N.instanceof(Int32Array),N.instanceof(BigInt64Array)]);N.record(N.union([N.number(),N.string(),N.symbol()]),N.unknown());const Pd=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",Pg=Pd(),Ud=["MacOS","Windows","Linux","Docker"],Ug=N.enum(Ud);let no;const Dg=()=>{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"},Mg=(r={})=>{const{force:e,default:t}=r;return e??no??(no=Dg(),no??t)},Dd=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:Ud,RUNTIME:Pg,detect:Pd,getOS:Mg,osZ:Ug},Symbol.toStringTag,{value:"Module"})),$g=(...r)=>r.map(Md).join(""),Md=r=>(r.endsWith("/")||(r+="/"),r.startsWith("/")&&(r=r.slice(1)),r),Lg=r=>r.endsWith("/")?r.slice(0,-1):r,Bg=(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("&");let Vg=(bn=class{constructor({host:r,port:e,protocol:t="",pathPrefix:n=""}){R(this,"protocol"),R(this,"host"),R(this,"port"),R(this,"path"),this.protocol=t,this.host=r,this.port=e,this.path=Md(n)}replace(r){return new bn({host:r.host??this.host,port:r.port??this.port,protocol:r.protocol??this.protocol,pathPrefix:r.pathPrefix??this.path})}child(r){return new bn({...this,pathPrefix:$g(this.path,r)})}toString(){return Lg(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}},R(bn,"UNKNOWN",new bn({host:"unknown",port:0})),bn);var Ro;try{Ro=new TextDecoder}catch{}var U,St,p=0,ze={},_e,Pr,Tt=0,Wt=0,He,Tr,vt=[],ve,Ou={useRecords:!1,mapsAsObjects:!0};class $d{}const Ld=new $d;Ld.name="MessagePack 0xC1";var Dr=!1,Bd=2,Tu;try{new Function("")}catch{Bd=1/0}class Is{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(U)return qd(()=>(Po(),this?this.unpack(e,t):Is.prototype.unpack.call(Ou,e,t)));!e.buffer&&e.constructor===ArrayBuffer&&(e=typeof Buffer<"u"?Buffer.from(e):new Uint8Array(e)),typeof t=="object"?(St=t.end||e.length,p=t.start||0):(p=0,St=t>-1?t:e.length),Wt=0,Pr=null,He=null,U=e;try{ve=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(n){throw U=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 Is){if(ze=this,this.structures)return _e=this.structures,ha(t);(!_e||_e.length>0)&&(_e=[])}else ze=Ou,(!_e||_e.length>0)&&(_e=[]);return ha(t)}unpackMultiple(e,t){let n,s=0;try{Dr=!0;let a=e.length,i=this?this.unpack(e,a):Pi.unpack(e,a);if(t){if(t(i,s,p)===!1)return;for(;p<a;)if(s=p,t(ha(),s,p)===!1)return}else{for(n=[i];p<a;)s=p,n.push(ha());return n}}catch(a){throw a.lastPosition=s,a.values=n,a}finally{Dr=!1,Po()}}_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 ha(r){try{if(!ze.trusted&&!Dr){let t=_e.sharedLength||0;t<_e.length&&(_e.length=t)}let e;if(ze.randomAccessStructure&&U[p]<64&&U[p]>=32&&Tu?(e=Tu(U,p,St,ze),U=null,!(r&&r.lazy)&&e&&(e=e.toJSON()),p=St):e=Ve(),He&&(p=He.postBundlePosition,He=null),Dr&&(_e.restoreStructures=null),p==St)_e&&_e.restoreStructures&&xu(),_e=null,U=null,Tr&&(Tr=null);else{if(p>St)throw new Error("Unexpected end of MessagePack data");if(!Dr){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 _e&&_e.restoreStructures&&xu(),Po(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||p>St)&&(e.incomplete=!0),e}}function xu(){for(let r in _e.restoreStructures)_e[r]=_e.restoreStructures[r];_e.restoreStructures=null}function Ve(){let r=U[p++];if(r<160)if(r<128){if(r<64)return r;{let e=_e[r&63]||ze.getStructures&&Vd()[r&63];return e?(e.read||(e.read=Nc(e,r&63)),e.read()):r}}else if(r<144)if(r-=128,ze.mapsAsObjects){let e={};for(let t=0;t<r;t++){let n=Fd();n==="__proto__"&&(n="__proto_"),e[n]=Ve()}return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(Ve(),Ve());return e}else{r-=144;let e=new Array(r);for(let t=0;t<r;t++)e[t]=Ve();return ze.freezeData?Object.freeze(e):e}else if(r<192){let e=r-160;if(Wt>=p)return Pr.slice(p-Tt,(p+=e)-Tt);if(Wt==0&&St<140){let t=e<16?Ac(e):Kd(e);if(t!=null)return t}return zo(e)}else{let e;switch(r){case 192:return null;case 193:return He?(e=Ve(),e>0?He[1].slice(He.position1,He.position1+=e):He[0].slice(He.position0,He.position0-=e)):Ld;case 194:return!1;case 195:return!0;case 196:if(e=U[p++],e===void 0)throw new Error("Unexpected end of buffer");return so(e);case 197:return e=ve.getUint16(p),p+=2,so(e);case 198:return e=ve.getUint32(p),p+=4,so(e);case 199:return en(U[p++]);case 200:return e=ve.getUint16(p),p+=2,en(e);case 201:return e=ve.getUint32(p),p+=4,en(e);case 202:if(e=ve.getFloat32(p),ze.useFloat32>2){let t=Ic[(U[p]&127)<<1|U[p+1]>>7];return p+=4,(t*e+(e>0?.5:-.5)>>0)/t}return p+=4,e;case 203:return e=ve.getFloat64(p),p+=8,e;case 204:return U[p++];case 205:return e=ve.getUint16(p),p+=2,e;case 206:return e=ve.getUint32(p),p+=4,e;case 207:return ze.int64AsType==="number"?(e=ve.getUint32(p)*4294967296,e+=ve.getUint32(p+4)):ze.int64AsType==="string"?e=ve.getBigUint64(p).toString():ze.int64AsType==="auto"?(e=ve.getBigUint64(p),e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=ve.getBigUint64(p),p+=8,e;case 208:return ve.getInt8(p++);case 209:return e=ve.getInt16(p),p+=2,e;case 210:return e=ve.getInt32(p),p+=4,e;case 211:return ze.int64AsType==="number"?(e=ve.getInt32(p)*4294967296,e+=ve.getUint32(p+4)):ze.int64AsType==="string"?e=ve.getBigInt64(p).toString():ze.int64AsType==="auto"?(e=ve.getBigInt64(p),e>=BigInt(-2)<<BigInt(52)&&e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=ve.getBigInt64(p),p+=8,e;case 212:if(e=U[p++],e==114)return Cu(U[p++]&63);{let t=vt[e];if(t)return t.read?(p++,t.read(Ve())):t.noBuffer?(p++,t()):t(U.subarray(p,++p));throw new Error("Unknown extension "+e)}case 213:return e=U[p],e==114?(p++,Cu(U[p++]&63,U[p++])):en(2);case 214:return en(4);case 215:return en(8);case 216:return en(16);case 217:return e=U[p++],Wt>=p?Pr.slice(p-Tt,(p+=e)-Tt):Fg(e);case 218:return e=ve.getUint16(p),p+=2,Wt>=p?Pr.slice(p-Tt,(p+=e)-Tt):Wg(e);case 219:return e=ve.getUint32(p),p+=4,Wt>=p?Pr.slice(p-Tt,(p+=e)-Tt):qg(e);case 220:return e=ve.getUint16(p),p+=2,Eu(e);case 221:return e=ve.getUint32(p),p+=4,Eu(e);case 222:return e=ve.getUint16(p),p+=2,Nu(e);case 223:return e=ve.getUint32(p),p+=4,Nu(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 Kg=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Nc(r,e){function t(){if(t.count++>Bd){let s=r.read=new Function("r","return function(){return "+(ze.freezeData?"Object.freeze":"")+"({"+r.map(a=>a==="__proto__"?"__proto_:r()":Kg.test(a)?a+":r()":"["+JSON.stringify(a)+"]:r()").join(",")+"})}")(Ve);return r.highByte===0&&(r.read=Su(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]=Ve()}return ze.freezeData?Object.freeze(n):n}return t.count=0,r.highByte===0?Su(e,t):t}const Su=(r,e)=>function(){let t=U[p++];if(t===0)return e();let n=r<32?-(r+(t<<5)):r+(t<<5),s=_e[n]||Vd()[n];if(!s)throw new Error("Record id is not defined for "+n);return s.read||(s.read=Nc(s,r)),s.read()};function Vd(){let r=qd(()=>(U=null,ze.getStructures()));return _e=ze._mergeStructures(r,_e)}var zo=Xs,Fg=Xs,Wg=Xs,qg=Xs;function Xs(r){let e;if(r<16&&(e=Ac(r)))return e;if(r>64&&Ro)return Ro.decode(U.subarray(p,p+=r));const t=p+r,n=[];for(e="";p<t;){const s=U[p++];if(!(s&128))n.push(s);else if((s&224)===192){const a=U[p++]&63;n.push((s&31)<<6|a)}else if((s&240)===224){const a=U[p++]&63,i=U[p++]&63;n.push((s&31)<<12|a<<6|i)}else if((s&248)===240){const a=U[p++]&63,i=U[p++]&63,o=U[p++]&63;let c=(s&7)<<18|a<<12|i<<6|o;c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|c&1023),n.push(c)}else n.push(s);n.length>=4096&&(e+=Je.apply(String,n),n.length=0)}return n.length>0&&(e+=Je.apply(String,n)),e}function Eu(r){let e=new Array(r);for(let t=0;t<r;t++)e[t]=Ve();return ze.freezeData?Object.freeze(e):e}function Nu(r){if(ze.mapsAsObjects){let e={};for(let t=0;t<r;t++){let n=Fd();n==="__proto__"&&(n="__proto_"),e[n]=Ve()}return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(Ve(),Ve());return e}}var Je=String.fromCharCode;function Kd(r){let e=p,t=new Array(r);for(let n=0;n<r;n++){const s=U[p++];if((s&128)>0){p=e;return}t[n]=s}return Je.apply(String,t)}function Ac(r){if(r<4)if(r<2){if(r===0)return"";{let e=U[p++];if((e&128)>1){p-=1;return}return Je(e)}}else{let e=U[p++],t=U[p++];if((e&128)>0||(t&128)>0){p-=2;return}if(r<3)return Je(e,t);let n=U[p++];if((n&128)>0){p-=3;return}return Je(e,t,n)}else{let e=U[p++],t=U[p++],n=U[p++],s=U[p++];if((e&128)>0||(t&128)>0||(n&128)>0||(s&128)>0){p-=4;return}if(r<6){if(r===4)return Je(e,t,n,s);{let a=U[p++];if((a&128)>0){p-=5;return}return Je(e,t,n,s,a)}}else if(r<8){let a=U[p++],i=U[p++];if((a&128)>0||(i&128)>0){p-=6;return}if(r<7)return Je(e,t,n,s,a,i);let o=U[p++];if((o&128)>0){p-=7;return}return Je(e,t,n,s,a,i,o)}else{let a=U[p++],i=U[p++],o=U[p++],c=U[p++];if((a&128)>0||(i&128)>0||(o&128)>0||(c&128)>0){p-=8;return}if(r<10){if(r===8)return Je(e,t,n,s,a,i,o,c);{let l=U[p++];if((l&128)>0){p-=9;return}return Je(e,t,n,s,a,i,o,c,l)}}else if(r<12){let l=U[p++],w=U[p++];if((l&128)>0||(w&128)>0){p-=10;return}if(r<11)return Je(e,t,n,s,a,i,o,c,l,w);let T=U[p++];if((T&128)>0){p-=11;return}return Je(e,t,n,s,a,i,o,c,l,w,T)}else{let l=U[p++],w=U[p++],T=U[p++],X=U[p++];if((l&128)>0||(w&128)>0||(T&128)>0||(X&128)>0){p-=12;return}if(r<14){if(r===12)return Je(e,t,n,s,a,i,o,c,l,w,T,X);{let Q=U[p++];if((Q&128)>0){p-=13;return}return Je(e,t,n,s,a,i,o,c,l,w,T,X,Q)}}else{let Q=U[p++],Ze=U[p++];if((Q&128)>0||(Ze&128)>0){p-=14;return}if(r<15)return Je(e,t,n,s,a,i,o,c,l,w,T,X,Q,Ze);let ee=U[p++];if((ee&128)>0){p-=15;return}return Je(e,t,n,s,a,i,o,c,l,w,T,X,Q,Ze,ee)}}}}}function Au(){let r=U[p++],e;if(r<192)e=r-160;else switch(r){case 217:e=U[p++];break;case 218:e=ve.getUint16(p),p+=2;break;case 219:e=ve.getUint32(p),p+=4;break;default:throw new Error("Expected string")}return Xs(e)}function so(r){return ze.copyBuffers?Uint8Array.prototype.slice.call(U,p,p+=r):U.subarray(p,p+=r)}function en(r){let e=U[p++];if(vt[e]){let t;return vt[e](U.subarray(p,t=p+=r),n=>{p=n;try{return Ve()}finally{p=t}})}else throw new Error("Unknown extension type "+e)}var Iu=new Array(4096);function Fd(){let r=U[p++];if(r>=160&&r<192){if(r=r-160,Wt>=p)return Pr.slice(p-Tt,(p+=r)-Tt);if(!(Wt==0&&St<180))return zo(r)}else return p--,Ve().toString();let e=(r<<5^(r>1?ve.getUint16(p):r>0?U[p]:0))&4095,t=Iu[e],n=p,s=p+r-3,a,i=0;if(t&&t.bytes==r){for(;n<s;){if(a=ve.getUint32(n),a!=t[i++]){n=1879048192;break}n+=4}for(s+=3;n<s;)if(a=U[n++],a!=t[i++]){n=1879048192;break}if(n===s)return p=n,t.string;s-=3,n=p}for(t=[],Iu[e]=t,t.bytes=r;n<s;)a=ve.getUint32(n),t.push(a),n+=4;for(s+=3;n<s;)a=U[n++],t.push(a);let o=r<16?Ac(r):Kd(r);return o!=null?t.string=o:t.string=zo(r)}const Cu=(r,e)=>{let t=Ve().map(a=>a.toString()),n=r;e!==void 0&&(r=r<32?-((e<<5)+r):(e<<5)+r,t.highByte=e);let s=_e[r];return s&&(s.isShared||Dr)&&((_e.restoreStructures||(_e.restoreStructures=[]))[r]=s),_e[r]=t,t.read=Nc(t,n),t.read()};vt[0]=()=>{};vt[0].noBuffer=!0;let Yg={Error,TypeError,ReferenceError};vt[101]=()=>{let r=Ve();return(Yg[r[0]]||Error)(r[1])};vt[105]=r=>{let e=ve.getUint32(p-4);Tr||(Tr=new Map);let t=U[p],n;t>=144&&t<160||t==220||t==221?n=[]:n={};let s={target:n};Tr.set(e,s);let a=Ve();return s.used?Object.assign(n,a):(s.target=a,a)};vt[112]=r=>{let e=ve.getUint32(p-4),t=Tr.get(e);return t.used=!0,t.target};vt[115]=()=>new Set(Ve());const Wd=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(r=>r+"Array");let Jg=typeof globalThis=="object"?globalThis:window;vt[116]=r=>{let e=r[0],t=Wd[e];if(!t)throw new Error("Could not find typed array for code "+e);return new Jg[t](Uint8Array.prototype.slice.call(r,1).buffer)};vt[120]=()=>{let r=Ve();return new RegExp(r[0],r[1])};const Gg=[];vt[98]=r=>{let e=(r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3],t=p;return p+=e-r.length,He=Gg,He=[Au(),Au()],He.position0=0,He.position1=0,He.postBundlePosition=p,p=t,Ve()};vt[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 qd(r){let e=St,t=p,n=Tt,s=Wt,a=Pr,i=Tr,o=He,c=new Uint8Array(U.slice(0,St)),l=_e,w=_e.slice(0,_e.length),T=ze,X=Dr,Q=r();return St=e,p=t,Tt=n,Wt=s,Pr=a,Tr=i,He=o,U=c,Dr=X,_e=l,_e.splice(0,_e.length,...w),ze=T,ve=new DataView(U.buffer,U.byteOffset,U.byteLength),Q}function Po(){U=null,Tr=null,_e=null}function Hg(r){r.unpack?vt[r.type]=r.unpack:vt[r.type]=r}const Ic=new Array(147);for(let r=0;r<256;r++)Ic[r]=+("1e"+Math.floor(45.15-r*.30103));var Pi=new Is({useRecords:!1});const Xg=Pi.unpack;Pi.unpackMultiple;Pi.unpack;let Qg=new Float32Array(1);new Uint8Array(Qg.buffer,0,4);let za;try{za=new TextEncoder}catch{}let ui,Cc;const Ui=typeof Buffer<"u",fa=Ui?function(r){return Buffer.allocUnsafeSlow(r)}:Uint8Array,Yd=Ui?Buffer:Uint8Array,ju=Ui?4294967296:2144337920;let b,Yn,Ne,v=0,dt,Me=null,ev;const tv=21760,rv=/[\u0080-\uFFFF]/,kn=Symbol("record-id");class nv extends Is{constructor(e){super(e),this.offset=0;let t,n,s,a,i=Yd.prototype.utf8Write?function(d,O){return b.utf8Write(d,O,4294967295)}:za&&za.encodeInto?function(d,O){return za.encodeInto(d,b.subarray(O)).written}:!1,o=this;e||(e={});let c=e&&e.sequential,l=e.structures||e.saveStructures,w=e.maxSharedStructures;if(w==null&&(w=l?32:0),w>8160)throw new Error("Maximum maxSharedStructure is 8160");e.structuredClone&&e.moreTypes==null&&(this.moreTypes=!0);let T=e.maxOwnStructures;T==null&&(T=l?32:64),!this.structures&&e.useRecords!=!1&&(this.structures=[]);let X=w>32||T+w>64,Q=w+64,Ze=w+T+64;if(Ze>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let ee=[],rr=0,nr=0;this.pack=this.encode=function(d,O){if(b||(b=new fa(8192),Ne=b.dataView||(b.dataView=new DataView(b.buffer,0,8192)),v=0),dt=b.length-10,dt-v<2048?(b=new fa(b.length),Ne=b.dataView||(b.dataView=new DataView(b.buffer,0,b.length)),dt=b.length-10,v=0):v=v+7&2147483640,t=v,O&dv&&(v+=O&255),a=o.structuredClone?new Map:null,o.bundleStrings&&typeof d!="string"?(Me=[],Me.size=1/0):Me=null,s=o.structures,s){s.uninitialized&&(s=o._mergeStructures(o.getStructures()));let m=s.sharedLength||0;if(m>w)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 y=0;y<m;y++){let k=s[y];if(!k)continue;let z,D=s.transitions;for(let I=0,ne=k.length;I<ne;I++){let F=k[I];z=D[F],z||(z=D[F]=Object.create(null)),D=z}D[kn]=y+64}this.lastNamedStructuresLength=m}c||(s.nextId=m+64)}n&&(n=!1);try{o.randomAccessStructure&&d&&d.constructor&&d.constructor===Object?Yi(d):re(d);let m=Me;if(Me&&zu(t,re,0),a&&a.idsToInsert){let y=a.idsToInsert.sort((I,ne)=>I.offset>ne.offset?1:-1),k=y.length,z=-1;for(;m&&k>0;){let I=y[--k].offset+t;I<m.stringsPosition+t&&z===-1&&(z=0),I>m.position+t?z>=0&&(z+=6):(z>=0&&(Ne.setUint32(m.position+t,Ne.getUint32(m.position+t)+z),z=-1),m=m.previous,k++)}z>=0&&m&&Ne.setUint32(m.position+t,Ne.getUint32(m.position+t)+z),v+=y.length*6,v>dt&&Xe(v),o.offset=v;let D=av(b.subarray(t,v),y);return a=null,D}return o.offset=v,O&uv?(b.start=t,b.end=v,b):b.subarray(t,v)}finally{if(s&&(Bn(),n&&o.saveStructures)){let m=s.sharedLength||0,y=b.subarray(t,v),k=ov(s,o);return o.saveStructures(k,k.isCompatible)===!1?o.pack(d,O):(o.lastNamedStructuresLength=m,y)}O&lv&&(v=t)}};const Bn=()=>{nr<10&&nr++;let d=s.sharedLength||0;if(s.length>d&&!c&&(s.length=d),rr>1e4)s.transitions=null,nr=0,rr=0,ee.length>0&&(ee=[]);else if(ee.length>0&&!c){for(let O=0,m=ee.length;O<m;O++)ee[O][kn]=0;ee=[]}},Gr=d=>{var O=d.length;O<16?b[v++]=144|O:O<65536?(b[v++]=220,b[v++]=O>>8,b[v++]=O&255):(b[v++]=221,Ne.setUint32(v,O),v+=4);for(let m=0;m<O;m++)re(d[m])},re=d=>{v>dt&&(b=Xe(v));var O=typeof d,m;if(O==="string"){let y=d.length;if(Me&&y>=4&&y<4096){if((Me.size+=y)>tv){let I,ne=(Me[0]?Me[0].length*3+Me[1].length:0)+10;v+ne>dt&&(b=Xe(v+ne));let F;Me.position?(F=Me,b[v]=200,v+=3,b[v++]=98,I=v-t,v+=4,zu(t,re,0),Ne.setUint16(I+t-3,v-t-I)):(b[v++]=214,b[v++]=98,I=v-t,v+=4),Me=["",""],Me.previous=F,Me.size=0,Me.position=I}let D=rv.test(d);Me[D?0:1]+=d,b[v++]=193,re(D?-y:y);return}let k;y<32?k=1:y<256?k=2:y<65536?k=3:k=5;let z=y*3;if(v+z>dt&&(b=Xe(v+z)),y<64||!i){let D,I,ne,F=v+k;for(D=0;D<y;D++)I=d.charCodeAt(D),I<128?b[F++]=I:I<2048?(b[F++]=I>>6|192,b[F++]=I&63|128):(I&64512)===55296&&((ne=d.charCodeAt(D+1))&64512)===56320?(I=65536+((I&1023)<<10)+(ne&1023),D++,b[F++]=I>>18|240,b[F++]=I>>12&63|128,b[F++]=I>>6&63|128,b[F++]=I&63|128):(b[F++]=I>>12|224,b[F++]=I>>6&63|128,b[F++]=I&63|128);m=F-v-k}else m=i(d,v+k);m<32?b[v++]=160|m:m<256?(k<2&&b.copyWithin(v+2,v+1,v+1+m),b[v++]=217,b[v++]=m):m<65536?(k<3&&b.copyWithin(v+3,v+2,v+2+m),b[v++]=218,b[v++]=m>>8,b[v++]=m&255):(k<5&&b.copyWithin(v+5,v+3,v+3+m),b[v++]=219,Ne.setUint32(v,m),v+=4),v+=m}else if(O==="number")if(d>>>0===d)d<32||d<128&&this.useRecords===!1||d<64&&!this.randomAccessStructure?b[v++]=d:d<256?(b[v++]=204,b[v++]=d):d<65536?(b[v++]=205,b[v++]=d>>8,b[v++]=d&255):(b[v++]=206,Ne.setUint32(v,d),v+=4);else if(d>>0===d)d>=-32?b[v++]=256+d:d>=-128?(b[v++]=208,b[v++]=d+256):d>=-32768?(b[v++]=209,Ne.setInt16(v,d),v+=2):(b[v++]=210,Ne.setInt32(v,d),v+=4);else{let y;if((y=this.useFloat32)>0&&d<4294967296&&d>=-2147483648){b[v++]=202,Ne.setFloat32(v,d);let k;if(y<4||(k=d*Ic[(b[v]&127)<<1|b[v+1]>>7])>>0===k){v+=4;return}else v--}b[v++]=203,Ne.setFloat64(v,d),v+=8}else if(O==="object"||O==="function")if(!d)b[v++]=192;else{if(a){let k=a.get(d);if(k){if(!k.id){let z=a.idsToInsert||(a.idsToInsert=[]);k.id=z.push(k)}b[v++]=214,b[v++]=112,Ne.setUint32(v,k.id),v+=4;return}else a.set(d,{offset:v-t})}let y=d.constructor;if(y===Object)sr(d,!0);else if(y===Array)Gr(d);else if(y===Map)if(this.mapAsEmptyObject)b[v++]=128;else{m=d.size,m<16?b[v++]=128|m:m<65536?(b[v++]=222,b[v++]=m>>8,b[v++]=m&255):(b[v++]=223,Ne.setUint32(v,m),v+=4);for(let[k,z]of d)re(k),re(z)}else{for(let k=0,z=ui.length;k<z;k++){let D=Cc[k];if(d instanceof D){let I=ui[k];if(I.write){I.type&&(b[v++]=212,b[v++]=I.type,b[v++]=0);let Qe=I.write.call(this,d);Qe===d?Array.isArray(d)?Gr(d):sr(d):re(Qe);return}let ne=b,F=Ne,Ke=v;b=null;let ut;try{ut=I.pack.call(this,d,Qe=>(b=ne,ne=null,v+=Qe,v>dt&&Xe(v),{target:b,targetView:Ne,position:v-Qe}),re)}finally{ne&&(b=ne,Ne=F,v=Ke,dt=b.length-10)}ut&&(ut.length+v>dt&&Xe(ut.length+v),v=sv(ut,b,v,I.type));return}}if(Array.isArray(d))Gr(d);else{if(d.toJSON){const k=d.toJSON();if(k!==d)return re(k)}if(O==="function")return re(this.writeFunction&&this.writeFunction(d));sr(d,!d.hasOwnProperty)}}}else if(O==="boolean")b[v++]=d?195:194;else if(O==="bigint"){if(d<BigInt(1)<<BigInt(63)&&d>=-(BigInt(1)<<BigInt(63)))b[v++]=211,Ne.setBigInt64(v,d);else if(d<BigInt(1)<<BigInt(64)&&d>0)b[v++]=207,Ne.setBigUint64(v,d);else if(this.largeBigIntToFloat)b[v++]=203,Ne.setFloat64(v,Number(d));else throw new RangeError(d+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");v+=8}else if(O==="undefined")this.encodeUndefinedAsNil?b[v++]=192:(b[v++]=212,b[v++]=0,b[v++]=0);else throw new Error("Unknown type: "+O)},Vn=this.variableMapSize||this.coercibleKeyAsNumber?d=>{let O=Object.keys(d),m=O.length;m<16?b[v++]=128|m:m<65536?(b[v++]=222,b[v++]=m>>8,b[v++]=m&255):(b[v++]=223,Ne.setUint32(v,m),v+=4);let y;if(this.coercibleKeyAsNumber)for(let k=0;k<m;k++){y=O[k];let z=Number(y);re(isNaN(z)?y:z),re(d[y])}else for(let k=0;k<m;k++)re(y=O[k]),re(d[y])}:(d,O)=>{b[v++]=222;let m=v-t;v+=2;let y=0;for(let k in d)(O||d.hasOwnProperty(k))&&(re(k),re(d[k]),y++);b[m+++t]=y>>8,b[m+t]=y&255},Kn=this.useRecords===!1?Vn:e.progressiveRecords&&!X?(d,O)=>{let m,y=s.transitions||(s.transitions=Object.create(null)),k=v++-t,z;for(let D in d)if(O||d.hasOwnProperty(D)){if(m=y[D],m)y=m;else{let I=Object.keys(d),ne=y;y=s.transitions;let F=0;for(let Ke=0,ut=I.length;Ke<ut;Ke++){let Qe=I[Ke];m=y[Qe],m||(m=y[Qe]=Object.create(null),F++),y=m}k+t+1==v?(v--,Hr(y,I,F)):Wn(y,I,k,F),z=!0,y=ne[D]}re(d[D])}if(!z){let D=y[kn];D?b[k+t]=D:Wn(y,Object.keys(d),k,0)}}:(d,O)=>{let m,y=s.transitions||(s.transitions=Object.create(null)),k=0;for(let D in d)(O||d.hasOwnProperty(D))&&(m=y[D],m||(m=y[D]=Object.create(null),k++),y=m);let z=y[kn];z?z>=96&&X?(b[v++]=((z-=96)&31)+96,b[v++]=z>>5):b[v++]=z:Hr(y,y.__keys__||Object.keys(d),k);for(let D in d)(O||d.hasOwnProperty(D))&&re(d[D])},Fn=typeof this.useRecords=="function"&&this.useRecords,sr=Fn?(d,O)=>{Fn(d)?Kn(d,O):Vn(d,O)}:Kn,Xe=d=>{let O;if(d>16777216){if(d-t>ju)throw new Error("Packed buffer would be larger than maximum buffer size");O=Math.min(ju,Math.round(Math.max((d-t)*(d>67108864?1.25:2),4194304)/4096)*4096)}else O=(Math.max(d-t<<2,b.length-1)>>12)+1<<12;let m=new fa(O);return Ne=m.dataView||(m.dataView=new DataView(m.buffer,0,O)),d=Math.min(d,b.length),b.copy?b.copy(m,0,t,d):m.set(b.slice(t,d)),v-=t,t=0,dt=m.length-10,b=m},Hr=(d,O,m)=>{let y=s.nextId;y||(y=64),y<Q&&this.shouldShareStructure&&!this.shouldShareStructure(O)?(y=s.nextOwnId,y<Ze||(y=Q),s.nextOwnId=y+1):(y>=Ze&&(y=Q),s.nextId=y+1);let k=O.highByte=y>=96&&X?y-96>>5:-1;d[kn]=y,d.__keys__=O,s[y-64]=O,y<Q?(O.isShared=!0,s.sharedLength=y-63,n=!0,k>=0?(b[v++]=(y&31)+96,b[v++]=k):b[v++]=y):(k>=0?(b[v++]=213,b[v++]=114,b[v++]=(y&31)+96,b[v++]=k):(b[v++]=212,b[v++]=114,b[v++]=y),m&&(rr+=nr*m),ee.length>=T&&(ee.shift()[kn]=0),ee.push(d),re(O))},Wn=(d,O,m,y)=>{let k=b,z=v,D=dt,I=t;b=Yn,v=0,t=0,b||(Yn=b=new fa(8192)),dt=b.length-10,Hr(d,O,y),Yn=b;let ne=v;if(b=k,v=z,dt=D,t=I,ne>1){let F=v+ne-1;F>dt&&Xe(F);let Ke=m+t;b.copyWithin(Ke+ne,Ke+1,v),b.set(Yn.slice(0,ne),Ke),v=F}else b[m+t]=Yn[0]},Yi=(d,O)=>{let m=ev(d,b,t,v,s,Xe,(y,k,z)=>{if(z)return n=!0;v=k;let D=b;return re(y),Bn(),D!==b?{position:v,targetView:Ne,target:b}:v},this);if(m===0)return sr(d,!0);v=m}}useBuffer(e){b=e,Ne=new DataView(b.buffer,b.byteOffset,b.byteLength),v=0}clearSharedData(){this.structures&&(this.structures=[]),this.typedStructs&&(this.typedStructs=[])}}Cc=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,$d];ui=[{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?Zu(r,16,e):Ru(Ui?Buffer.from(r):new Uint8Array(r),e)}},{pack(r,e){let t=r.constructor;t!==Yd&&this.moreTypes?Zu(r,Wd.indexOf(t.name),e):Ru(r,e)}},{pack(r,e){let{target:t,position:n}=e(1);t[n]=193}}];function Zu(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 Ru(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 sv(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 av(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 zu(r,e,t){if(Me.length>0){Ne.setUint32(Me.position+r,v+t-Me.position-r),Me.stringsPosition=v-r;let n=Me;Me=null,e(n[0]),e(n[1])}}function iv(r){if(r.Class){if(!r.pack&&!r.write)throw new Error("Extension has no pack or write function");if(r.pack&&!r.type)throw new Error("Extension has no type (numeric code to identify the extension)");Cc.unshift(r.Class),ui.unshift(r)}Hg(r)}function ov(r,e){return r.isCompatible=t=>{let n=!t||(e.lastNamedStructuresLength||0)===t.length;return n||e._mergeStructures(t),n},r}let Jd=new nv({useRecords:!1});const cv=Jd.pack;Jd.pack;const uv=512,lv=1024,dv=2048;class hv{constructor(){R(this,"contentType","application/msgpack")}encode(e){return cv(Dn.toSnake(e))}decode(e,t){const n=Dn.toCamel(Xg(new Uint8Array(e)));return t!=null?t.parse(n):n}static registerCustomType(e){iv({type:0,...e})}}class fv{constructor(){R(this,"contentType","application/json")}encode(e){const t=JSON.stringify(Dn.toSnake(e),(n,s)=>ArrayBuffer.isView(s)?Array.from(s):s);return new TextEncoder().encode(t)}decode(e,t){const n=Dn.toCamel(JSON.parse(new TextDecoder().decode(e)));return t!=null?t.parse(n):n}static registerCustomType(){}}new hv,new fv;var xe;(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})(xe||(xe={}));var Uo;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Uo||(Uo={}));const L=xe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Rr=r=>{switch(typeof r){case"undefined":return L.undefined;case"string":return L.string;case"number":return isNaN(r)?L.nan:L.number;case"boolean":return L.boolean;case"function":return L.function;case"bigint":return L.bigint;case"symbol":return L.symbol;case"object":return Array.isArray(r)?L.array:r===null?L.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?L.promise:typeof Map<"u"&&r instanceof Map?L.map:typeof Set<"u"&&r instanceof Set?L.set:typeof Date<"u"&&r instanceof Date?L.date:L.object;default:return L.unknown}},Z=xe.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"]),pv=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Mt 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,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return s(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,xe.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()}}Mt.create=r=>new Mt(r);const Cs=(r,e)=>{let t;switch(r.code){case Z.invalid_type:r.received===L.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case Z.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,xe.jsonStringifyReplacer)}`;break;case Z.unrecognized_keys:t=`Unrecognized key(s) in object: ${xe.joinValues(r.keys,", ")}`;break;case Z.invalid_union:t="Invalid input";break;case Z.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${xe.joinValues(r.options)}`;break;case Z.invalid_enum_value:t=`Invalid enum value. Expected ${xe.joinValues(r.options)}, received '${r.received}'`;break;case Z.invalid_arguments:t="Invalid function arguments";break;case Z.invalid_return_type:t="Invalid function return type";break;case Z.invalid_date:t="Invalid date";break;case Z.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}"`:xe.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case Z.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 Z.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 Z.custom:t="Invalid input";break;case Z.invalid_intersection_types:t="Intersection results could not be merged";break;case Z.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case Z.not_finite:t="Number must be finite";break;default:t=e.defaultError,xe.assertNever(r)}return{message:t}};let Gd=Cs;function mv(r){Gd=r}function li(){return Gd}const di=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],i={...s,path:a};let o="";const c=n.filter(l=>!!l).slice().reverse();for(const l of c)o=l(i,{data:e,defaultError:o}).message;return{...s,path:a,message:s.message||o}},yv=[];function K(r,e){const t=di({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,li(),Cs].filter(n=>!!n)});r.common.issues.push(t)}class ct{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 ae;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 ct.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 ae;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 ae=Object.freeze({status:"aborted"}),Hd=r=>({status:"dirty",value:r}),wt=r=>({status:"valid",value:r}),Do=r=>r.status==="aborted",Mo=r=>r.status==="dirty",js=r=>r.status==="valid",hi=r=>typeof Promise<"u"&&r instanceof Promise;var Y;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Y||(Y={}));class Qt{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 Pu=(r,e)=>{if(js(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 Mt(r.common.issues);return this._error=t,this._error}}};function ce(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 he{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 Rr(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Rr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ct,ctx:{common:e.parent.common,data:e.data,parsedType:Rr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(hi(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:Rr(e)},a=this._parseSync({data:e,path:s.path,parent:s});return Pu(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:Rr(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(hi(s)?s:Promise.resolve(s));return Pu(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:Z.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!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 Vt({schema:this,typeName:H.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return xr.create(this,this._def)}nullable(){return mn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return $t.create(this,this._def)}promise(){return $n.create(this,this._def)}or(e){return Ps.create([this,e],this._def)}and(e){return Us.create(this,e,this._def)}transform(e){return new Vt({...ce(this._def),schema:this,typeName:H.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Bs({...ce(this._def),innerType:this,defaultValue:t,typeName:H.ZodDefault})}brand(){return new Qd({typeName:H.ZodBranded,type:this,...ce(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new yi({...ce(this._def),innerType:this,catchValue:t,typeName:H.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Qs.create(this,e)}readonly(){return vi.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const gv=/^c[^\s-]{8,}$/i,vv=/^[a-z][a-z0-9]*$/,wv=/^[0-9A-HJKMNP-TV-Z]{26}$/,_v=/^[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,bv=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,kv="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ao;const Ov=/^(((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}))$/,Tv=/^(([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})))$/,xv=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 Sv(r,e){return!!((e==="v4"||!e)&&Ov.test(r)||(e==="v6"||!e)&&Tv.test(r))}class Rt extends he{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==L.string){const s=this._getOrReturnCtx(e);return K(s,{code:Z.invalid_type,expected:L.string,received:s.parsedType}),ae}const t=new ct;let n;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(n=this._getOrReturnCtx(e,n),K(n,{code:Z.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),K(n,{code:Z.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?K(n,{code:Z.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):i&&K(n,{code:Z.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")bv.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"email",code:Z.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")ao||(ao=new RegExp(kv,"u")),ao.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"emoji",code:Z.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")_v.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"uuid",code:Z.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")gv.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"cuid",code:Z.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")vv.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"cuid2",code:Z.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")wv.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"ulid",code:Z.invalid_string,message:s.message}),t.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),K(n,{validation:"url",code:Z.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),K(n,{validation:"regex",code:Z.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),K(n,{code:Z.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),K(n,{code:Z.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(n=this._getOrReturnCtx(e,n),K(n,{code:Z.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?xv(s).test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{code:Z.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="ip"?Sv(e.data,s.version)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"ip",code:Z.invalid_string,message:s.message}),t.dirty()):xe.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:Z.invalid_string,...Y.errToObj(n)})}_addCheck(e){return new Rt({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Y.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Y.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Y.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Y.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Y.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Y.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Y.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Y.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,...Y.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Y.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Y.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Y.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Y.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Y.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Y.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Y.errToObj(t)})}nonempty(e){return this.min(1,Y.errToObj(e))}trim(){return new Rt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Rt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Rt({...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}}Rt.create=r=>{var e;return new Rt({checks:[],typeName:H.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...ce(r)})};function Ev(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 Vr extends he{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)!==L.number){const s=this._getOrReturnCtx(e);return K(s,{code:Z.invalid_type,expected:L.number,received:s.parsedType}),ae}let t;const n=new ct;for(const s of this._def.checks)s.kind==="int"?xe.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),K(t,{code:Z.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),K(t,{code:Z.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),K(t,{code:Z.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="multipleOf"?Ev(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),K(t,{code:Z.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),K(t,{code:Z.not_finite,message:s.message}),n.dirty()):xe.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Y.toString(t))}setLimit(e,t,n,s){return new Vr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Y.toString(s)}]})}_addCheck(e){return new Vr({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Y.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Y.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Y.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Y.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Y.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"&&xe.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)}}Vr.create=r=>new Vr({checks:[],typeName:H.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...ce(r)});class Kr extends he{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)!==L.bigint){const s=this._getOrReturnCtx(e);return K(s,{code:Z.invalid_type,expected:L.bigint,received:s.parsedType}),ae}let t;const n=new ct;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),K(t,{code:Z.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),K(t,{code:Z.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),K(t,{code:Z.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):xe.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Y.toString(t))}setLimit(e,t,n,s){return new Kr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Y.toString(s)}]})}_addCheck(e){return new Kr({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Y.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}}Kr.create=r=>{var e;return new Kr({checks:[],typeName:H.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...ce(r)})};class Zs extends he{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==L.boolean){const t=this._getOrReturnCtx(e);return K(t,{code:Z.invalid_type,expected:L.boolean,received:t.parsedType}),ae}return wt(e.data)}}Zs.create=r=>new Zs({typeName:H.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...ce(r)});class fn extends he{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==L.date){const s=this._getOrReturnCtx(e);return K(s,{code:Z.invalid_type,expected:L.date,received:s.parsedType}),ae}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return K(s,{code:Z.invalid_date}),ae}const t=new ct;let n;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(n=this._getOrReturnCtx(e,n),K(n,{code:Z.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),K(n,{code:Z.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):xe.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new fn({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Y.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Y.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}}fn.create=r=>new fn({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:H.ZodDate,...ce(r)});class fi extends he{_parse(e){if(this._getType(e)!==L.symbol){const t=this._getOrReturnCtx(e);return K(t,{code:Z.invalid_type,expected:L.symbol,received:t.parsedType}),ae}return wt(e.data)}}fi.create=r=>new fi({typeName:H.ZodSymbol,...ce(r)});class Rs extends he{_parse(e){if(this._getType(e)!==L.undefined){const t=this._getOrReturnCtx(e);return K(t,{code:Z.invalid_type,expected:L.undefined,received:t.parsedType}),ae}return wt(e.data)}}Rs.create=r=>new Rs({typeName:H.ZodUndefined,...ce(r)});class zs extends he{_parse(e){if(this._getType(e)!==L.null){const t=this._getOrReturnCtx(e);return K(t,{code:Z.invalid_type,expected:L.null,received:t.parsedType}),ae}return wt(e.data)}}zs.create=r=>new zs({typeName:H.ZodNull,...ce(r)});class Mn extends he{constructor(){super(...arguments),this._any=!0}_parse(e){return wt(e.data)}}Mn.create=r=>new Mn({typeName:H.ZodAny,...ce(r)});class an extends he{constructor(){super(...arguments),this._unknown=!0}_parse(e){return wt(e.data)}}an.create=r=>new an({typeName:H.ZodUnknown,...ce(r)});class Nr extends he{_parse(e){const t=this._getOrReturnCtx(e);return K(t,{code:Z.invalid_type,expected:L.never,received:t.parsedType}),ae}}Nr.create=r=>new Nr({typeName:H.ZodNever,...ce(r)});class pi extends he{_parse(e){if(this._getType(e)!==L.undefined){const t=this._getOrReturnCtx(e);return K(t,{code:Z.invalid_type,expected:L.void,received:t.parsedType}),ae}return wt(e.data)}}pi.create=r=>new pi({typeName:H.ZodVoid,...ce(r)});class $t extends he{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==L.array)return K(t,{code:Z.invalid_type,expected:L.array,received:t.parsedType}),ae;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(K(t,{code:i?Z.too_big:Z.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&&(K(t,{code:Z.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&&(K(t,{code:Z.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 Qt(t,i,t.path,o)))).then(i=>ct.mergeArray(n,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new Qt(t,i,t.path,o)));return ct.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new $t({...this._def,minLength:{value:e,message:Y.toString(t)}})}max(e,t){return new $t({...this._def,maxLength:{value:e,message:Y.toString(t)}})}length(e,t){return new $t({...this._def,exactLength:{value:e,message:Y.toString(t)}})}nonempty(e){return this.min(1,e)}}$t.create=(r,e)=>new $t({type:r,minLength:null,maxLength:null,exactLength:null,typeName:H.ZodArray,...ce(e)});function xn(r){if(r instanceof Le){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=xr.create(xn(n))}return new Le({...r._def,shape:()=>e})}else return r instanceof $t?new $t({...r._def,type:xn(r.element)}):r instanceof xr?xr.create(xn(r.unwrap())):r instanceof mn?mn.create(xn(r.unwrap())):r instanceof er?er.create(r.items.map(e=>xn(e))):r}class Le extends he{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=xe.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==L.object){const c=this._getOrReturnCtx(e);return K(c,{code:Z.invalid_type,expected:L.object,received:c.parsedType}),ae}const{status:t,ctx:n}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof Nr&&this._def.unknownKeys==="strip"))for(const c in n.data)a.includes(c)||i.push(c);const o=[];for(const c of a){const l=s[c],w=n.data[c];o.push({key:{status:"valid",value:c},value:l._parse(new Qt(n,w,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Nr){const c=this._def.unknownKeys;if(c==="passthrough")for(const l of i)o.push({key:{status:"valid",value:l},value:{status:"valid",value:n.data[l]}});else if(c==="strict")i.length>0&&(K(n,{code:Z.unrecognized_keys,keys:i}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const l of i){const w=n.data[l];o.push({key:{status:"valid",value:l},value:c._parse(new Qt(n,w,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of o){const w=await l.key;c.push({key:w,value:await l.value,alwaysSet:l.alwaysSet})}return c}).then(c=>ct.mergeObjectSync(t,c)):ct.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return Y.errToObj,new Le({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,a,i,o;const c=(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=Y.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Le({...this._def,unknownKeys:"strip"})}passthrough(){return new Le({...this._def,unknownKeys:"passthrough"})}extend(e){return new Le({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Le({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:H.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Le({...this._def,catchall:e})}pick(e){const t={};return xe.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Le({...this._def,shape:()=>t})}omit(e){const t={};return xe.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Le({...this._def,shape:()=>t})}deepPartial(){return xn(this)}partial(e){const t={};return xe.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new Le({...this._def,shape:()=>t})}required(e){const t={};return xe.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof xr;)s=s._def.innerType;t[n]=s}}),new Le({...this._def,shape:()=>t})}keyof(){return Xd(xe.objectKeys(this.shape))}}Le.create=(r,e)=>new Le({shape:()=>r,unknownKeys:"strip",catchall:Nr.create(),typeName:H.ZodObject,...ce(e)});Le.strictCreate=(r,e)=>new Le({shape:()=>r,unknownKeys:"strict",catchall:Nr.create(),typeName:H.ZodObject,...ce(e)});Le.lazycreate=(r,e)=>new Le({shape:r,unknownKeys:"strip",catchall:Nr.create(),typeName:H.ZodObject,...ce(e)});class Ps extends he{_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 Mt(o.ctx.common.issues));return K(t,{code:Z.invalid_union,unionErrors:i}),ae}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 c of n){const l={...t,common:{...t.common,issues:[]},parent:null},w=c._parseSync({data:t.data,path:t.path,parent:l});if(w.status==="valid")return w;w.status==="dirty"&&!a&&(a={result:w,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new Mt(c));return K(t,{code:Z.invalid_union,unionErrors:o}),ae}}get options(){return this._def.options}}Ps.create=(r,e)=>new Ps({options:r,typeName:H.ZodUnion,...ce(e)});const Pa=r=>r instanceof Ms?Pa(r.schema):r instanceof Vt?Pa(r.innerType()):r instanceof $s?[r.value]:r instanceof Fr?r.options:r instanceof Ls?Object.keys(r.enum):r instanceof Bs?Pa(r._def.innerType):r instanceof Rs?[void 0]:r instanceof zs?[null]:null;class Di extends he{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==L.object)return K(t,{code:Z.invalid_type,expected:L.object,received:t.parsedType}),ae;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}):(K(t,{code:Z.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ae)}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=Pa(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 Di({typeName:H.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...ce(n)})}}function $o(r,e){const t=Rr(r),n=Rr(e);if(r===e)return{valid:!0,data:r};if(t===L.object&&n===L.object){const s=xe.objectKeys(e),a=xe.objectKeys(r).filter(o=>s.indexOf(o)!==-1),i={...r,...e};for(const o of a){const c=$o(r[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===L.array&&n===L.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],c=$o(i,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===L.date&&n===L.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class Us extends he{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(Do(a)||Do(i))return ae;const o=$o(a.value,i.value);return o.valid?((Mo(a)||Mo(i))&&t.dirty(),{status:t.value,value:o.data}):(K(n,{code:Z.invalid_intersection_types}),ae)};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}))}}Us.create=(r,e,t)=>new Us({left:r,right:e,typeName:H.ZodIntersection,...ce(t)});class er extends he{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==L.array)return K(n,{code:Z.invalid_type,expected:L.array,received:n.parsedType}),ae;if(n.data.length<this._def.items.length)return K(n,{code:Z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ae;!this._def.rest&&n.data.length>this._def.items.length&&(K(n,{code:Z.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 Qt(n,a,n.path,i)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>ct.mergeArray(t,a)):ct.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new er({...this._def,rest:e})}}er.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new er({items:r,typeName:H.ZodTuple,rest:null,...ce(e)})};class Ds extends he{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!==L.object)return K(n,{code:Z.invalid_type,expected:L.object,received:n.parsedType}),ae;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)s.push({key:a._parse(new Qt(n,o,n.path,o)),value:i._parse(new Qt(n,n.data[o],n.path,o))});return n.common.async?ct.mergeObjectAsync(t,s):ct.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof he?new Ds({keyType:e,valueType:t,typeName:H.ZodRecord,...ce(n)}):new Ds({keyType:Rt.create(),valueType:e,typeName:H.ZodRecord,...ce(t)})}}class mi extends he{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!==L.map)return K(n,{code:Z.invalid_type,expected:L.map,received:n.parsedType}),ae;const s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,c],l)=>({key:s._parse(new Qt(n,o,n.path,[l,"key"])),value:a._parse(new Qt(n,c,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const l=await c.key,w=await c.value;if(l.status==="aborted"||w.status==="aborted")return ae;(l.status==="dirty"||w.status==="dirty")&&t.dirty(),o.set(l.value,w.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of i){const l=c.key,w=c.value;if(l.status==="aborted"||w.status==="aborted")return ae;(l.status==="dirty"||w.status==="dirty")&&t.dirty(),o.set(l.value,w.value)}return{status:t.value,value:o}}}}mi.create=(r,e,t)=>new mi({valueType:e,keyType:r,typeName:H.ZodMap,...ce(t)});class pn extends he{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==L.set)return K(n,{code:Z.invalid_type,expected:L.set,received:n.parsedType}),ae;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(K(n,{code:Z.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&&(K(n,{code:Z.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(c){const l=new Set;for(const w of c){if(w.status==="aborted")return ae;w.status==="dirty"&&t.dirty(),l.add(w.value)}return{status:t.value,value:l}}const o=[...n.data.values()].map((c,l)=>a._parse(new Qt(n,c,n.path,l)));return n.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new pn({...this._def,minSize:{value:e,message:Y.toString(t)}})}max(e,t){return new pn({...this._def,maxSize:{value:e,message:Y.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}pn.create=(r,e)=>new pn({valueType:r,minSize:null,maxSize:null,typeName:H.ZodSet,...ce(e)});class An extends he{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==L.function)return K(t,{code:Z.invalid_type,expected:L.function,received:t.parsedType}),ae;function n(o,c){return di({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,li(),Cs].filter(l=>!!l),issueData:{code:Z.invalid_arguments,argumentsError:c}})}function s(o,c){return di({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,li(),Cs].filter(l=>!!l),issueData:{code:Z.invalid_return_type,returnTypeError:c}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof $n){const o=this;return wt(async function(...c){const l=new Mt([]),w=await o._def.args.parseAsync(c,a).catch(X=>{throw l.addIssue(n(c,X)),l}),T=await Reflect.apply(i,this,w);return await o._def.returns._def.type.parseAsync(T,a).catch(X=>{throw l.addIssue(s(T,X)),l})})}else{const o=this;return wt(function(...c){const l=o._def.args.safeParse(c,a);if(!l.success)throw new Mt([n(c,l.error)]);const w=Reflect.apply(i,this,l.data),T=o._def.returns.safeParse(w,a);if(!T.success)throw new Mt([s(w,T.error)]);return T.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new An({...this._def,args:er.create(e).rest(an.create())})}returns(e){return new An({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new An({args:e||er.create([]).rest(an.create()),returns:t||an.create(),typeName:H.ZodFunction,...ce(n)})}}class Ms extends he{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})}}Ms.create=(r,e)=>new Ms({getter:r,typeName:H.ZodLazy,...ce(e)});class $s extends he{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return K(t,{received:t.data,code:Z.invalid_literal,expected:this._def.value}),ae}return{status:"valid",value:e.data}}get value(){return this._def.value}}$s.create=(r,e)=>new $s({value:r,typeName:H.ZodLiteral,...ce(e)});function Xd(r,e){return new Fr({values:r,typeName:H.ZodEnum,...ce(e)})}class Fr extends he{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return K(t,{expected:xe.joinValues(n),received:t.parsedType,code:Z.invalid_type}),ae}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),n=this._def.values;return K(t,{received:t.data,code:Z.invalid_enum_value,options:n}),ae}return wt(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 Fr.create(e)}exclude(e){return Fr.create(this.options.filter(t=>!e.includes(t)))}}Fr.create=Xd;class Ls extends he{_parse(e){const t=xe.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==L.string&&n.parsedType!==L.number){const s=xe.objectValues(t);return K(n,{expected:xe.joinValues(s),received:n.parsedType,code:Z.invalid_type}),ae}if(t.indexOf(e.data)===-1){const s=xe.objectValues(t);return K(n,{received:n.data,code:Z.invalid_enum_value,options:s}),ae}return wt(e.data)}get enum(){return this._def.values}}Ls.create=(r,e)=>new Ls({values:r,typeName:H.ZodNativeEnum,...ce(e)});class $n extends he{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==L.promise&&t.common.async===!1)return K(t,{code:Z.invalid_type,expected:L.promise,received:t.parsedType}),ae;const n=t.parsedType===L.promise?t.data:Promise.resolve(t.data);return wt(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}$n.create=(r,e)=>new $n({type:r,typeName:H.ZodPromise,...ce(e)});class Vt extends he{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===H.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=>{K(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 c=s.refinement(o,a);if(n.common.async)return Promise.resolve(c);if(c 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"?ae:(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"?ae:(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(!js(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=>js(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);xe.assertNever(s)}}Vt.create=(r,e,t)=>new Vt({schema:r,typeName:H.ZodEffects,effect:e,...ce(t)});Vt.createWithPreprocess=(r,e,t)=>new Vt({schema:e,effect:{type:"preprocess",transform:r},typeName:H.ZodEffects,...ce(t)});class xr extends he{_parse(e){return this._getType(e)===L.undefined?wt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}xr.create=(r,e)=>new xr({innerType:r,typeName:H.ZodOptional,...ce(e)});class mn extends he{_parse(e){return this._getType(e)===L.null?wt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}mn.create=(r,e)=>new mn({innerType:r,typeName:H.ZodNullable,...ce(e)});class Bs extends he{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===L.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Bs.create=(r,e)=>new Bs({innerType:r,typeName:H.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ce(e)});class yi extends he{_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 hi(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Mt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Mt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}yi.create=(r,e)=>new yi({innerType:r,typeName:H.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ce(e)});class gi extends he{_parse(e){if(this._getType(e)!==L.nan){const t=this._getOrReturnCtx(e);return K(t,{code:Z.invalid_type,expected:L.nan,received:t.parsedType}),ae}return{status:"valid",value:e.data}}}gi.create=r=>new gi({typeName:H.ZodNaN,...ce(r)});const Nv=Symbol("zod_brand");class Qd extends he{_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 Qs extends he{_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"?ae:s.status==="dirty"?(t.dirty(),Hd(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"?ae: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 Qs({in:e,out:t,typeName:H.ZodPipeline})}}class vi extends he{_parse(e){const t=this._def.innerType._parse(e);return js(t)&&(t.value=Object.freeze(t.value)),t}}vi.create=(r,e)=>new vi({innerType:r,typeName:H.ZodReadonly,...ce(e)});const eh=(r,e={},t)=>r?Mn.create().superRefine((n,s)=>{var a,i;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,l=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...l,fatal:c})}}):Mn.create(),Av={object:Le.lazycreate};var H;(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"})(H||(H={}));const Iv=(r,e={message:`Input not instance of ${r.name}`})=>eh(t=>t instanceof r,e),th=Rt.create,rh=Vr.create,Cv=gi.create,jv=Kr.create,nh=Zs.create,Zv=fn.create,Rv=fi.create,zv=Rs.create,Pv=zs.create,Uv=Mn.create,Dv=an.create,Mv=Nr.create,$v=pi.create,Lv=$t.create,Bv=Le.create,Vv=Le.strictCreate,Kv=Ps.create,Fv=Di.create,Wv=Us.create,qv=er.create,Yv=Ds.create,Jv=mi.create,Gv=pn.create,Hv=An.create,Xv=Ms.create,Qv=$s.create,ew=Fr.create,tw=Ls.create,rw=$n.create,Uu=Vt.create,nw=xr.create,sw=mn.create,aw=Vt.createWithPreprocess,iw=Qs.create,ow=()=>th().optional(),cw=()=>rh().optional(),uw=()=>nh().optional(),lw={string:r=>Rt.create({...r,coerce:!0}),number:r=>Vr.create({...r,coerce:!0}),boolean:r=>Zs.create({...r,coerce:!0}),bigint:r=>Kr.create({...r,coerce:!0}),date:r=>fn.create({...r,coerce:!0})},dw=ae;var _r=Object.freeze({__proto__:null,defaultErrorMap:Cs,setErrorMap:mv,getErrorMap:li,makeIssue:di,EMPTY_PATH:yv,addIssueToContext:K,ParseStatus:ct,INVALID:ae,DIRTY:Hd,OK:wt,isAborted:Do,isDirty:Mo,isValid:js,isAsync:hi,get util(){return xe},get objectUtil(){return Uo},ZodParsedType:L,getParsedType:Rr,ZodType:he,ZodString:Rt,ZodNumber:Vr,ZodBigInt:Kr,ZodBoolean:Zs,ZodDate:fn,ZodSymbol:fi,ZodUndefined:Rs,ZodNull:zs,ZodAny:Mn,ZodUnknown:an,ZodNever:Nr,ZodVoid:pi,ZodArray:$t,ZodObject:Le,ZodUnion:Ps,ZodDiscriminatedUnion:Di,ZodIntersection:Us,ZodTuple:er,ZodRecord:Ds,ZodMap:mi,ZodSet:pn,ZodFunction:An,ZodLazy:Ms,ZodLiteral:$s,ZodEnum:Fr,ZodNativeEnum:Ls,ZodPromise:$n,ZodEffects:Vt,ZodTransformer:Vt,ZodOptional:xr,ZodNullable:mn,ZodDefault:Bs,ZodCatch:yi,ZodNaN:gi,BRAND:Nv,ZodBranded:Qd,ZodPipeline:Qs,ZodReadonly:vi,custom:eh,Schema:he,ZodSchema:he,late:Av,get ZodFirstPartyTypeKind(){return H},coerce:lw,any:Uv,array:Lv,bigint:jv,boolean:nh,date:Zv,discriminatedUnion:Fv,effect:Uu,enum:ew,function:Hv,instanceof:Iv,intersection:Wv,lazy:Xv,literal:Qv,map:Jv,nan:Cv,nativeEnum:tw,never:Mv,null:Pv,nullable:sw,number:rh,object:Bv,oboolean:uw,onumber:cw,optional:nw,ostring:ow,pipeline:iw,preprocess:aw,promise:rw,record:Yv,set:Gv,strictObject:Vv,string:th,symbol:Rv,transformer:Uu,tuple:qv,undefined:zv,union:Kv,unknown:Dv,void:$v,NEVER:dw,ZodIssueCode:Z,quotelessJson:pv,ZodError:Mt});class ea extends Error{constructor(e,t){super(e),qe(this,"discriminator","FreighterError"),qe(this,"type"),this.type=t}}const hw=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},Lo="unknown",Du="nil",Mi="freighter",ta=_r.object({type:_r.string(),data:_r.string()});class fw{constructor(){qe(this,"providers",[])}register(e){this.providers.push(e)}encode(e){if(e==null)return{type:Du,data:""};if(hw(e))for(const t of this.providers){const n=t.encode(e);if(n!=null)return n}return{type:Lo,data:JSON.stringify(e)}}decode(e){if(e==null||e.type===Du)return null;if(e.type===Lo)return new Mu(e.data);for(const t of this.providers){const n=t.decode(e);if(n!=null)return n}return new Mu(e.data)}}const sh=new fw,ah=({encode:r,decode:e})=>sh.register({encode:r,decode:e}),jc=r=>sh.decode(r);class Mu extends ea{constructor(e){super(e,Lo)}}class Vs extends ea{constructor(){super("EOF",Mi)}}class wi extends ea{constructor(){super("StreamClosed",Mi)}}class Ks extends ea{constructor(e={}){const{message:t="Unreachable",url:n=Vg.UNKNOWN}=e;super(t,Mi),qe(this,"url"),this.url=n}}const Ua="freighter",pw=r=>{if(r.type!==Mi)return null;if(r instanceof Vs)return{type:Ua,data:"EOF"};if(r instanceof wi)return{type:Ua,data:"StreamClosed"};if(r instanceof Ks)return{type:Ua,data:"Unreachable"};throw new Error(`Unknown error type: ${r.type}: ${r.message}`)},mw=r=>{if(r.type!==Ua)return null;switch(r.data){case"EOF":return new Vs;case"StreamClosed":return new wi;case"Unreachable":return new Ks;default:throw new Error(`Unknown error type: ${r.data}`)}};ah({encode:pw,decode:mw});class ih{constructor(){qe(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 oh="Content-Type",$u=r=>{if(Dd.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 yw extends ih{constructor(e,t,n=!1){return super(),qe(this,"endpoint"),qe(this,"encoder"),qe(this,"fetch"),this.endpoint=e.replace({protocol:n?"https":"http"}),this.encoder=t,this.fetch=$u(this.endpoint.protocol),new Proxy(this,{get:(s,a,i)=>a==="endpoint"?this.endpoint:Reflect.get(s,a,i)})}get headers(){return{[oh]:this.encoder.contentType}}async send(e,t,n){let s=null;const a=this.endpoint.child(e),i={};i.method="POST",i.body=this.encoder.encode(t??{});const[,o]=await this.executeMiddleware({target:a.toString(),protocol:this.endpoint.protocol,params:{},role:"client"},async c=>{const l={...c,params:{}};i.headers={...this.headers,...c.params};let w;try{w=await $u(c.protocol)(c.target,i)}catch(X){let Q=X;return Q.message==="Load failed"&&(Q=new Ks({url:a})),[l,Q]}const T=await w.arrayBuffer();if(w!=null&&w.ok)return n!=null&&(s=this.encoder.decode(T,n)),[l,null];try{if(w.status!==400)return[l,new Error(w.statusText)];const X=this.encoder.decode(T,ta),Q=jc(X);return[l,Q]}catch(X){return[l,new Error(`[freighter] - failed to decode error: ${w.statusText}: ${X.message}`)]}});return[s,o]}}const ue=async(r,e,t,n)=>{const[s,a]=await r.send(e,t,n);if(a!=null)throw a;return s},gw=()=>Dd.RUNTIME!=="node"?r=>new WebSocket(r):r=>new(require("ws")).WebSocket(r,{rejectUnauthorized:!1}),vw=_r.object({type:_r.union([_r.literal("data"),_r.literal("close")]),payload:_r.unknown().optional(),error:_r.optional(ta)});class ww{constructor(e,t,n,s){qe(this,"encoder"),qe(this,"reqSchema"),qe(this,"resSchema"),qe(this,"ws"),qe(this,"serverClosed"),qe(this,"sendClosed"),qe(this,"receiveDataQueue",[]),qe(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 Vs;if(this.sendClosed)throw new wi;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=jc(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(){return this.receiveDataQueue.shift()??await new Promise((t,n)=>this.receiveCallbacksQueue.push({resolve:t,reject:n}))}listenForMessages(){this.ws.onmessage=e=>{const t=this.encoder.decode(e.data,vw),n=this.receiveCallbacksQueue.shift();n!=null?n.resolve(t):this.receiveDataQueue.push(t)},this.ws.onclose=e=>{this.serverClosed=Tw(e)?new Vs:new wi}}}const _w="freighterctx",bw=1e3,kw=1001,Ow=[bw,kw],Tw=r=>Ow.includes(r.code),ch=class uh extends ih{constructor(e,t,n=!1){super(),qe(this,"baseUrl"),qe(this,"encoder"),this.baseUrl=e.replace({protocol:n?"wss":"ws"}),this.encoder=t}async stream(e,t,n){const s=gw();let a;const[,i]=await this.executeMiddleware({target:e,protocol:"websocket",params:{},role:"client"},async o=>{const c=s(this.buildURL(e,o)),l={...o,params:{}};c.binaryType=uh.MESSAGE_TYPE;const w=await this.wrapSocket(c,t,n);return w instanceof Error?[l,w]:(a=w,[l,null])});if(i!=null)throw i;return a}buildURL(e,t){const n=Bg({[oh]:this.encoder.contentType,...t.params},_w);return this.baseUrl.child(e).toString()+n}async wrapSocket(e,t,n){return await new Promise(s=>{e.onopen=()=>{s(new ww(e,this.encoder,t,n))},e.onerror=a=>{const i=a;s(new Error(i.message))}})}};qe(ch,"MESSAGE_TYPE","arraybuffer");let xw=ch;const wr="sy.api.";var Ar=(r=>(r.General=wr+"general",r.Parse=wr+"parse",r.Auth=wr+"auth",r.Unexpected=wr+"unexpected",r.Validation=wr+"validation",r.Query=wr+"query",r.Route=wr+"route",r))(Ar||{});class Yr extends ea{constructor(e){super(e,wr)}}class zt extends Yr{constructor(t){var e=(...ok)=>(super(...ok),h(this,"fields"),this);typeof t=="string"?(e(t),this.fields=[]):Array.isArray(t)?(e(t.map(n=>`${n.field}: ${n.message}`).join(`
8
+ `)),this.fields=t):(e(`${t.field}: ${t.message}`),this.fields=[t])}}class lh extends Yr{}class dh extends Yr{}class Zc extends Yr{}class yn extends Yr{constructor(e){super(`
9
+ Unexpected error encountered:
10
+
11
+ ${e}
12
+
13
+ Please report this to the Synnax team.
14
+ `)}}class tr extends Yr{}class Sw extends tr{}class Ew extends tr{}class hh extends Yr{constructor(t,n){super(t);h(this,"path");this.path=n}}class Nw extends Yr{}const Aw=r=>{if(!r.type.startsWith(wr))return null;switch(r.type){case Ar.General:return new lh(r.data);case Ar.Parse:return new dh(r.data);case Ar.Auth:return new Zc(r.data);case Ar.Unexpected:return new yn(r.data);case Ar.Validation:return new zt(r.data);case Ar.Query:return new tr(r.data);case Ar.Route:return new hh(r.data,r.data);default:return new yn(r.data)}},Iw=()=>{throw new Error("Not implemented")};ah({encode:Iw,decode:Aw});const Cw=async(r,e)=>{const[t,n]=await e(r);return n==null?[t,n]:n instanceof Ks?[t,new Ks({message:`Cannot reach cluster at ${n.url.host}:${n.url.port}`,url:n.url})]:[t,n]};class Rc{constructor({dataType:e,rate:t,name:n,leaseholder:s=0,key:a=0,isIndex:i=!1,index:o=0,frameClient:c,alias:l}){h(this,"_frameClient");h(this,"key");h(this,"name");h(this,"rate");h(this,"dataType");h(this,"leaseholder");h(this,"index");h(this,"isIndex");h(this,"alias");this.key=a,this.name=n,this.rate=new Ai(t??0),this.dataType=new et(e),this.leaseholder=s,this.index=o,this.isIndex=i,this.alias=l,this._frameClient=c??null}get framer(){if(this._frameClient==null)throw new zt("cannot read from a channel that has not been created");return this._frameClient}get payload(){return Gs.parse({key:this.key,name:this.name,rate:this.rate.valueOf(),dataType:this.dataType.valueOf(),leaseholder:this.leaseholder,index:this.index,isIndex:this.isIndex})}async read(e){return await this.framer.read(e,this.key)}async write(e,t){return await this.framer.write(this.key,e,t)}}let fh=class{constructor(e,t,n,s){h(this,"frameClient");h(this,"retriever");h(this,"creator");h(this,"client");this.frameClient=e,this.retriever=t,this.client=n,this.creator=s}async create(e){console.log("ABC");const t=!Array.isArray(e),n=await this.creator.create(Se(e)),s=this.sugar(n);return t?s[0]:s}async retrieve(e,t){const{single:n,actual:s,normalized:a}=qr(e);if(a.length===0)return[];const i=this.sugar(await this.retriever.retrieve(e,t));if(!n)return i;if(i.length===0)throw new Sw(`channel matching ${s} not found`);if(i.length>1)throw new Ew(`multiple channels matching ${s} found`);return i[0]}async search(e,t){return this.sugar(await this.retriever.search(e,t))}newSearcherUnderRange(e){return new jw(this,e)}async page(e,t,n){return this.sugar(await this.retriever.page(e,t,n))}createDebouncedBatchRetriever(e=10){return new fc(new Wl(new ms(this.client),e))}sugar(e){const{frameClient:t}=this;return e.map(n=>new Rc({...n,frameClient:t}))}};class jw{constructor(e,t){h(this,"client");h(this,"rangeKey");this.client=e,this.rangeKey=t}async search(e){return await this.client.search(e,this.rangeKey)}async page(e,t){return await this.client.page(e,t,this.rangeKey)}async retrieve(e){return await this.client.retrieve(e,this.rangeKey)}}const Zw=Object.freeze(Object.defineProperty({__proto__:null,CacheRetriever:fc,Channel:Rc,Client:fh,ClusterRetriever:ms,Creator:Ha,DebouncedBatchRetriever:Wl,analyzeParams:qr,keyZ:Js,newPayload:Kl,parseChannels:Fl,payload:Gs},Symbol.toStringTag,{value:"Module"})),Rw=u.z.object({key:u.z.string(),username:u.z.string()}),zw=r=>async(e,t)=>{try{const n=await r();e.params.Authorization=`Bearer ${n}`}catch(n){return[e,n]}return await t(e)};u.z.object({username:u.z.string(),password:u.z.string()});const Pw=u.z.object({token:u.z.string(),user:Rw}),Uw="/auth/login";let Dw=class{constructor(e,t){h(this,"token");h(this,"client");h(this,"authenticating");h(this,"authenticated");h(this,"user");this.client=e,this.authenticated=!1,this.authenticate(t)}authenticate(e){this.authenticating=new Promise((t,n)=>{this.client.send(Uw,e,Pw).then(([s,a])=>{if(a!=null)return n(a);this.token=s==null?void 0:s.token,this.user=s==null?void 0:s.user,this.authenticated=!0,t()}).catch(n)})}middleware(){return zw(async()=>{if(this.authenticated||await this.authenticating,this.token==null)throw new Zc("[auth] - attempting to authenticate without a token");return this.token})}};const Mw=["disconnected","connecting","connected","failed"],ph=u.z.enum(Mw),mh=u.z.object({status:ph,error:u.z.instanceof(Error).optional(),message:u.z.string().optional(),clusterKey:u.z.string()}),$w=u.z.object({clusterKey:u.z.string()}),Lu={clusterKey:"",status:"disconnected",error:void 0,message:"Disconnected"},Sn=class Sn{constructor(e,t=Pe.seconds(30),n){h(this,"_state");h(this,"pollFrequency",Pe.seconds(30));h(this,"client");h(this,"name");h(this,"interval");h(this,"onChangeHandlers",[]);this._state={...Lu},this.client=e,this.pollFrequency=t,this.name=n,this.check(),this.startChecking()}stopChecking(){this.interval!=null&&clearInterval(this.interval)}async check(){var t;const e=this._state.status;try{const[n,s]=await this.client.send(Sn.ENDPOINT,null,$w);if(s!=null)throw s;this._state.status="connected",this._state.message=`Connected to ${this.name??"cluster"}`,this._state.clusterKey=n.clusterKey}catch(n){this._state.status="failed",this._state.error=n,this._state.message=(t=this.state.error)==null?void 0:t.message}return this.onChangeHandlers.length>0&&e!==this._state.status&&this.onChangeHandlers.forEach(n=>n(this.state)),this.state}get state(){return{...this._state}}onChange(e){this.onChangeHandlers.push(e)}startChecking(){this.interval=setInterval(()=>{this.check()},this.pollFrequency.milliseconds)}};h(Sn,"ENDPOINT","/connectivity/check"),h(Sn,"DEFAULT",Lu),h(Sn,"connectionStateZ",mh);let Fs=Sn;const Lw=Object.freeze(Object.defineProperty({__proto__:null,Checker:Fs,state:mh,status:ph},Symbol.toStringTag,{value:"Module"})),Ir=class Ir extends Number{};h(Ir,"Absolute",255),h(Ir,"Default",1),h(Ir,"z",u.z.union([u.z.instanceof(Ir),u.z.number().int().min(0).max(255).transform(e=>new Ir(e)),u.z.instanceof(Number).transform(e=>new Ir(e))]));let Wr=Ir;const Bu=r=>{const e=Se(r);return e.length===0?null:typeof e[0]=="number"?"key":"name"},Vu=(r,e)=>{const t=Se(r);if(t.length===e.length)return;const n=Bu(r);throw Bu===null?new zt("[Frame] - channel keys or names must be provided when constructing a frame."):new zt(`[Frame] - ${n}s and arrays must be the same length.
15
+ Got ${t.length} ${n}s and ${e.length} arrays.`)};class pt{constructor(e=[],t=[]){h(this,"columns",[]);h(this,"series",[]);if(e instanceof pt){this.columns=e.columns,this.series=e.series;return}if(e instanceof Map){e.forEach((s,a)=>this.push(a,...Se(s)));return}if(typeof e=="object"&&!Array.isArray(e)){if("keys"in e&&"series"in e){const s=e,a=s.series.map(i=>gh(i));Vu(s.keys,a),s.keys.forEach((i,o)=>this.push(i,a[o]))}else Object.entries(e).forEach(([s,a])=>this.push(s,...Se(a)));return}if(Array.isArray(e)||["string","number"].includes(typeof e)){const s=Se(t),a=Se(e);Vu(a,s),s.forEach((i,o)=>this.push(a[o],i));return}throw new zt(`[Frame] - invalid frame construction parameters. data parameter ust be a frame
16
+ payload, a list of lazy arrays, a lazy array, a map, or a record keyed by channel
17
+ name. keys parameter must be a set of channel keys or channel names.`)}get colType(){return this.columns.length===0?null:typeof this.columns[0]=="string"?"name":"key"}get keys(){if(this.colType==="name")throw new yn("colType is not key");return this.columns??[]}get uniqueKeys(){return ru(this.keys)}get names(){if(this.colType==="key")throw new yn("colType is not name");return this.columns??[]}get uniqueNames(){return ru(this.names)}get uniqueColumns(){return this.colType==="key"?this.uniqueKeys:this.uniqueNames}toPayload(){return{series:this.series.map(e=>vh(e)),keys:this.keys}}get isVertical(){return this.uniqueColumns.length===this.columns.length}get isHorizontal(){return this.uniqueColumns.length===1}get isSquare(){return this.isHorizontal&&this.isVertical}get isWeaklyAligned(){if(this.columns.length<=1)return!0;const e=this.timeRanges;return e.every(t=>t.equals(e[0]))}timeRange(e){if(e==null){if(this.columns.length===0)return Zt.ZERO;const n=Math.min(...this.series.map(a=>a.timeRange.start.valueOf())),s=Math.max(...this.series.map(a=>a.timeRange.end.valueOf()));return new Zt(n,s)}const t=this.get(e);return t==null?Zt.ZERO:new Zt(t[0].timeRange.start,t[t.length-1].timeRange.end)}get timeRanges(){return this.uniqueColumns.map(e=>this.timeRange(e))}get(e){return Array.isArray(e)?this.filter(t=>e.includes(t)):this.series.filter((t,n)=>this.columns[n]===e)}push(e,...t){if(e instanceof pt){if(this.colType!==null&&e.colType!==this.colType)throw new zt("keyVariant must match");this.series.push(...e.series),this.columns.push(...e.columns)}else{if(this.series.push(...t),typeof e=="string"&&this.colType==="key")throw new zt("keyVariant must match");if(typeof e!="string"&&this.colType==="name")throw new zt("keyVariant must match");this.columns.push(...Array.from({length:t.length},()=>e))}}concat(e){return new pt([...this.columns,...e.columns],[...this.series,...e.series])}has(e){return typeof e=="string"&&this.colType==="key"||typeof e=="number"&&this.colType==="name"?!1:this.columns.includes(e)}map(e){const t=new pt;return this.forEach((n,s,a)=>t.push(...e(n,s,a))),t}forEach(e){this.columns.forEach((t,n)=>{const s=this.series[n];e(t,s,n)})}filter(e){const t=new pt;return this.columns.forEach((n,s)=>{const a=this.series[s];e(n,a,s)&&t.push(n,a)}),t}get byteLength(){return new Ya(this.series.reduce((e,t)=>e.add(t.byteLength),Ya.ZERO))}get length(){return this.series.reduce((e,t)=>e+t.length,0)}}const yh=u.z.object({timeRange:Zt.z.optional(),alignment:u.z.number().optional(),dataType:et.z,data:u.z.string().transform(r=>new Uint8Array(atob(r).split("").map(e=>e.charCodeAt(0))).buffer)}),$i=u.z.object({keys:u.z.union([u.z.null().transform(()=>[]),u.z.number().array().optional().default([])]),series:u.z.union([u.z.null().transform(()=>[]),yh.array().optional().default([])])}),gh=r=>{const{dataType:e,data:t,timeRange:n,alignment:s}=r;return new Ct({data:t,dataType:e,timeRange:n,glBufferUsage:"static",alignment:s})},vh=r=>({timeRange:r._timeRange,dataType:r.dataType,data:new Uint8Array(r.data.buffer),alignment:r.alignment});class Li{constructor(e){h(this,"adapter");h(this,"retriever");h(this,"keys");this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,t){const n=new Li(e);return await n.update(t),n}async update(e){const{variant:t,normalized:n}=qr(e);if(t==="keys"){this.adapter=null,this.keys=n;return}const s=await this.retriever.retrieve(n),a=new Map;this.adapter=a,n.forEach(i=>{const o=s.find(c=>c.name===i);if(o==null)throw new Error(`Channel ${i} not found`);a.set(o.key,o.name)}),this.keys=Array.from(this.adapter.keys())}adapt(e){if(this.adapter==null)return e;const t=this.adapter;return e.map((n,s)=>{if(typeof n=="number"){const a=t.get(n);if(a==null)throw new Error(`Channel ${n} not found`);return[a,s]}return[n,s]})}}class zc{constructor(e){h(this,"adapter");h(this,"retriever");h(this,"keys");this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,t){const n=new zc(e);return await n.update(t),n}async update(e){const{variant:t,normalized:n}=qr(e);if(t==="keys"){this.adapter=null,this.keys=n;return}const s=await this.retriever.retrieve(n),a=new Map;this.adapter=a,n.forEach(i=>{const o=s.find(c=>c.name===i);if(o==null)throw new zt(`Channel ${i} was not provided in the list of channels when opening the writer`);a.set(o.name,o.key)}),this.keys=s.map(i=>i.key)}adapt(e){if(this.adapter==null)return e.columns.forEach(n=>{if(typeof n!="number")throw new zt(`Channel ${n} was not provided in the list of channels when opening the writer`)}),e;const t=this.adapter;return e.map((n,s)=>{if(typeof n=="string"){const a=t.get(n);if(a==null)throw new Error(`Channel ${n} not found`);return[a,s]}return[n,s]})}}class Pc{constructor(e,t){h(this,"name");h(this,"stream");this.stream=t,this.name=e}async receive(){const[e,t]=await this.stream.receive();if(t!=null)throw t;return e}received(){return this.stream.received()}async closeAndAck(){this.stream.closeSend();const[e,t]=await this.stream.receive();if(e!=null)throw new yn(`${this.name} received unexpected response on closure.
18
+ Please report this error to the Synnax team.`);if(t==null)throw new yn(`${this.name} received unexpected null error on closure.
19
+ Please report this error to Synnax team.
20
+ `);if(!(t instanceof Vs))throw t}closeSend(){this.stream.closeSend()}send(e){const t=this.stream.send(e);if(t!=null)throw t}}const Bo=new Pe(-1);var Uc=(r=>(r[r.Open=0]="Open",r[r.Next=1]="Next",r[r.Prev=2]="Prev",r[r.SeekFirst=3]="SeekFirst",r[r.SeekLast=4]="SeekLast",r[r.SeekLE=5]="SeekLE",r[r.SeekGE=6]="SeekGE",r[r.Valid=7]="Valid",r[r.Error=8]="Error",r))(Uc||{}),wh=(r=>(r[r.None=0]="None",r[r.Ack=1]="Ack",r[r.Data=2]="Data",r))(wh||{});const Bw=u.z.object({command:u.z.nativeEnum(Uc),span:Pe.z.optional(),bounds:Zt.z.optional(),stamp:Ue.z.optional(),keys:u.z.number().array().optional()}),Vw=u.z.object({variant:u.z.nativeEnum(wh),ack:u.z.boolean(),command:u.z.nativeEnum(Uc),error:ta.optional().nullable(),frame:$i.optional()}),ts=class ts{constructor(e,t){h(this,"stream");h(this,"adapter");h(this,"value");this.stream=new Pc("Iterator",e),this.value=new pt,this.adapter=t}static async _open(e,t,n,s){const a=await Li.open(n,t),i=await s.stream(ts.ENDPOINT,Bw,Vw),o=new ts(i,a);return await o.execute({command:0,keys:a.keys,bounds:e}),o}async next(e=Bo){return await this.execute({command:1,span:new Pe(e)})}async prev(e=Bo){return await this.execute({command:2,span:new Pe(e)})}async seekFirst(){return await this.execute({command:3})}async seekLast(){return await this.execute({command:4})}async seekLE(e){return await this.execute({command:5,stamp:new Ue(e)})}async seekGE(e){return await this.execute({command:6,stamp:new Ue(e)})}async valid(){return await this.execute({command:7})}async close(){await this.stream.closeAndAck()}[Symbol.asyncIterator](){return new Kw(this)}async execute(e){for(this.stream.send(e),this.value=new pt;;){const t=await this.stream.receive();if(t.variant===1)return t.ack;this.value.push(this.adapter.adapt(new pt(t.frame)))}}};h(ts,"ENDPOINT","/frame/iterate");let _i=ts;class Kw{constructor(e){h(this,"iter");h(this,"open",!1);this.iter=e}async next(){try{let e=!0;return this.open||(await this.iter.seekFirst()||(e=!1),this.open=!0),await this.iter.next()||(e=!1),e||await this.iter.close(),{done:!e,value:this.iter.value}}catch(e){throw await this.iter.close(),e}}}const Fw=u.z.object({start:Ue.z.optional(),keys:u.z.number().array()}),Ww=u.z.object({frame:$i,error:ta.optional().nullable()}),qw="/frame/stream";class Bi{constructor(e,t){h(this,"stream");h(this,"adapter");this.stream=new Pc("Streamer",e),this.adapter=t}get keys(){return this.adapter.keys}static async _open(e,t,n,s){const a=await Li.open(n,t),i=await s.stream(qw,Fw,Ww),o=new Bi(i,a);return i.send({start:new Ue(e),keys:a.keys}),o}async next(){try{return{done:!1,value:await this.read()}}catch{return{done:!0,value:void 0}}}async read(){return this.adapter.adapt(new pt((await this.stream.receive()).frame))}async update(e){await this.adapter.update(e),this.stream.send({keys:this.adapter.keys})}close(){this.stream.closeSend()}[Symbol.asyncIterator](){return this}}const Dc=u.z.object({name:u.z.string(),key:u.z.string()}),Yw=u.z.object({subject:Dc,resource:u.z.number(),authority:Wr.z}),Jw=(...r)=>e=>e.filter(t=>{let n=!1;return t.to!=null&&(n=r.includes(t.to.resource)),t.from!=null&&!n&&(n=r.includes(t.from.resource)),n}),Gw=r=>{var e,t;return r.to==null?`${(e=r.from)==null?void 0:e.resource} - ${(t=r.from)==null?void 0:t.subject.name} -> released`:r.from==null?`${r.to.resource} - released -> ${r.to.subject.name} (${r.to.authority.toString()})`:`${r.to.resource} - ${r.from.subject.name} -> ${r.to.subject.name} (${r.to.authority.toString()})`};class Mc{constructor(e){h(this,"states");h(this,"streamer");h(this,"ecd");h(this,"observer");h(this,"closePromise");this.states=new Map,this.ecd=new Vl.JSONEncoderDecoder,this.observer=new Ga.Observer,this.streamer=e,this.closePromise=this.stream()}subjects(){const e=new Map;return this.states.forEach(t=>e.set(t.subject.key,t.subject)),Array.from(e.values())}onChange(e){return this.observer.onChange(e)}async close(){this.streamer.close(),await this.closePromise}static async open(e){const t=await e.newStreamer("sy_node_1_control");return new Mc(t)}async stream(){for await(const e of this.streamer){const t=this.ecd.decode(e.series[0].buffer);this.merge(t),this.observer.notify(t.transfers)}}merge(e){e.transfers.forEach(t=>{t.from==null&&t.to==null&&console.warn("Invalid transfer: ",t),t.to==null?this.states.delete(t.from.resource):this.states.set(t.to.resource,t.to)})}}var $c=(r=>(r[r.Open=0]="Open",r[r.Write=1]="Write",r[r.Commit=2]="Commit",r[r.Error=3]="Error",r[r.SetAuthority=4]="SetAuthority",r[r.SetMode=5]="SetMode",r))($c||{}),Ws=(r=>(r[r.PersistStream=1]="PersistStream",r[r.PersistOnly=2]="PersistOnly",r[r.StreamOnly=3]="StreamOnly",r))(Ws||{});const Hw=u.z.object({start:Ue.z.optional(),controlSubject:Dc.optional(),keys:u.z.number().array().optional(),authorities:Wr.z.array().optional(),mode:u.z.nativeEnum(Ws).optional()}),Xw=u.z.object({command:u.z.nativeEnum($c),config:Hw.optional(),frame:$i.optional()}),Qw=u.z.object({ack:u.z.boolean(),command:u.z.nativeEnum($c),error:ta.optional().nullable()});var on;let _h=(on=class{constructor(e,t){h(this,"stream");h(this,"adapter");this.stream=new Pc("Writer",e),this.adapter=t}static async _open(e,t,{channels:n,authorities:s=Wr.Absolute,controlSubject:a,start:i,mode:o}){const c=await zc.open(e,n),l=await t.stream(on.ENDPOINT,Xw,Qw),w=new on(l,c);return await w.execute({command:0,config:{start:new Ue(i),keys:c.keys,controlSubject:a,authorities:Se(s),mode:o}}),w}async write(e,t){return["string","number"].includes(typeof e)&&(e=new pt(e,new Ct({data:t}))),e=this.adapter.adapt(new pt(e)),this.stream.send({command:1,frame:e.toPayload()}),!0}async setAuthority(e){return(await this.execute({command:4,config:{keys:Object.keys(e).map(n=>Number(n)),authorities:Object.values(e)}})).ack}async setMode(e){return(await this.execute({command:5,config:{mode:e}})).ack}async commit(){return this.errorAccumulated?!1:(await this.execute({command:2})).ack}async error(){this.stream.send({command:3});const e=await this.execute({command:3});return e.error!=null?jc(e.error):null}async close(){await this.stream.closeAndAck()}async execute(e){for(this.stream.send(e);;){const t=await this.stream.receive();if(t.command===e.command)return t;console.warn("writer received unexpected response",t)}}get errorAccumulated(){return this.stream.received()}},h(on,"ENDPOINT","/frame/write"),on),bh=class{constructor(e,t){h(this,"stream");h(this,"retriever");this.stream=e,this.retriever=t}async newIterator(e,t){return await _i._open(e,t,this.retriever,this.stream)}async newWriter({start:e,channels:t,controlSubject:n,authorities:s=Wr.Absolute,mode:a=Ws.PersistStream}){return await _h._open(this.retriever,this.stream,{start:e??Ue.now(),controlSubject:n,channels:t,authorities:s,mode:a})}async newStreamer(e,t=Ue.now()){return await Bi._open(t,e,this.retriever,this.stream)}async write(e,t,n){const s=await this.newWriter({start:t,channels:e,mode:Ws.PersistOnly});try{if(await s.write(e,n),!await s.commit())throw await s.error()}catch{await s.close()}}async read(e,t){const{single:n}=qr(t),s=await this.readFrame(e,t);return n?s.series[0]:s}async readFrame(e,t){const n=await this.newIterator(e,t),s=new pt;for await(const a of n)s.push(a);return s}};const e_=Object.freeze(Object.defineProperty({__proto__:null,AUTO_SPAN:Bo,Client:bh,Frame:pt,Iterator:_i,Streamer:Bi,Writer:_h,WriterMode:Ws,frameZ:$i,series:yh,seriesFromPayload:gh,seriesToPayload:vh},Symbol.toStringTag,{value:"Module"}));let kh=class{constructor(e,t,n){h(this,"tasks");h(this,"racks");h(this,"devices");this.tasks=e,this.racks=t,this.devices=n}};const t_=Object.freeze(Object.defineProperty({__proto__:null,Client:kh},Symbol.toStringTag,{value:"Module"})),ra=u.z.number(),Lc=u.z.object({key:ra,name:u.z.string()}),r_=Lc.partial({key:!0}),Bc=u.z.string(),Vi=u.z.object({key:Bc,rack:ra,name:u.z.string(),make:u.z.string(),model:u.z.string(),location:u.z.string(),properties:u.z.string()});class na{constructor(e,t,n,s){h(this,"streamer");h(this,"decoder");h(this,"base");h(this,"closePromise");h(this,"deleteChannel");h(this,"setChannel");this.streamer=e,this.decoder=t,this.base=new Ga.Observer,this.closePromise=this.stream(),this.deleteChannel=s,this.setChannel=n}onChange(e){return this.base.onChange(e)}async close(){return this.streamer.close(),await this.closePromise}async stream(){for await(const e of this.streamer){const t=[];if(this.deleteChannel!=null){const n=e.get(this.deleteChannel);t.push(...n.flatMap(s=>this.decoder("delete",s)))}if(this.setChannel!=null){const n=e.get(this.setChannel);t.push(...n.flatMap(s=>this.decoder("set",s)))}this.base.notify(t)}}static async open(e,t,n,s){const a=await e.newStreamer([t,n]);return new na(a,s,t,n)}}const n_="sy_device_set",s_="sy_device_delete";let Oh=class{constructor(e,t,n){h(this,"retriever");h(this,"writer");h(this,"frameClient");this.retriever=e,this.writer=t,this.frameClient=n}async create(e){return(await this.writer.create([e]))[0]}async retrieve(e){const t=await this.retriever.retrieve(Se(e));return Array.isArray(e)?t:t[0]}async search(e){return await this.retriever.search(e)}async page(e,t){return await this.retriever.page(e,t)}async delete(e){await this.writer.delete(e)}async openDeviceTracker(){return await na.open(this.frameClient,n_,s_,a_)}};const a_=(r,e)=>r==="delete"?e.toStrings().map(t=>({variant:r,key:t,value:void 0})):e.parseJSON(Vi).map(t=>({variant:r,key:t.key,value:t})),io="/hardware/device/retrieve";u.z.object({search:u.z.string().optional(),limit:u.z.number().optional(),offset:u.z.number().optional(),keys:Bc.array().optional()});const oo=u.z.object({devices:Vi.array()});let Th=class{constructor(e){h(this,"client");this.client=e}async search(e){return(await ue(this.client,io,{keys:[e]},oo)).devices}async page(e,t){return(await ue(this.client,io,{offset:e,limit:t},oo)).devices}async retrieve(e){return(await ue(this.client,io,{keys:e},oo)).devices}};const i_="/hardware/device/create",o_="/hardware/device/delete",c_=u.z.object({devices:Vi.array()}),u_=u.z.object({devices:Vi.array()});u.z.object({keys:Bc.array()});const l_=u.z.object({});let xh=class{constructor(e){h(this,"client");this.client=e}async create(e){return(await ue(this.client,i_,c_.parse({devices:e}),u_)).devices}async delete(e){await ue(this.client,o_,{keys:e},l_)}};const d_=Object.freeze(Object.defineProperty({__proto__:null,Client:Oh,Retriever:Th,Writer:xh},Symbol.toStringTag,{value:"Module"}));let Sh=class{constructor(e,t,n,s,a){h(this,"retriever");h(this,"writer");h(this,"frameClient");h(this,"taskWriter");h(this,"taskRetriever");this.retriever=e,this.writer=t,this.frameClient=n,this.taskWriter=s,this.taskRetriever=a}async create(e){const t=await this.writer.create([e]);return this.sugar(t)[0]}async search(e){const t=await this.retriever.search(e);return this.sugar(t)}async page(e,t){const n=await this.retriever.page(e,t);return this.sugar(n)}async retrieve(e){const t=await this.retriever.retrieve(Se(e));return Array.isArray(e)?this.sugar(t):this.sugar(t)[0]}sugar(e){return e.map(t=>new Eh(t.key,t.name,this.taskWriter,this.taskRetriever))}};class Eh{constructor(e,t,n,s){h(this,"key");h(this,"name");h(this,"writer");h(this,"retriever");this.key=e,this.name=t,this.writer=n,this.retriever=s}async listTasks(){return await this.retriever.retrieve({rack:this.key})}async retrieveTasks(){return[]}async createTask(e){return e.key=((BigInt(this.key)<<32n)+(BigInt(e.key??0)&0xffffffffn)).toString(),(await this.writer.create([e]))[0]}async deleteTask(e){await this.writer.delete([e])}}const h_="/hardware/rack/create",f_="/hardware/rack/delete";u.z.object({racks:r_.array()});const p_=u.z.object({racks:Lc.array()});u.z.object({keys:ra.array()});const m_=u.z.object({});let Nh=class{constructor(e){h(this,"client");this.client=e}async create(e){return(await ue(this.client,h_,{racks:e},p_)).racks}async delete(e){await ue(this.client,f_,{keys:e},m_)}};const co="/hardware/rack/retrieve";u.z.object({keys:ra.array().optional(),search:u.z.string().optional(),offset:u.z.number().optional(),limit:u.z.number().optional()});const uo=u.z.object({racks:Lc.array()});let Ah=class{constructor(e){h(this,"client");this.client=e}async page(e,t){return(await ue(this.client,co,{offset:e,limit:t},uo)).racks}async search(e){return(await ue(this.client,co,{search:e},uo)).racks}async retrieve(e){return(await ue(this.client,co,{keys:e},uo)).racks}};const y_=Object.freeze(Object.defineProperty({__proto__:null,Client:Sh,Rack:Eh,Retriever:Ah,Writer:Nh},Symbol.toStringTag,{value:"Module"}));let Ih=class{constructor(e,t){h(this,"retriever");h(this,"writer");this.retriever=e,this.writer=t}async search(e){return await this.retriever.search(e)}async page(e,t){return await this.retriever.page(e,t)}async create(e){return(await this.writer.create([e]))[0]}async retrieve(e){const t={};let n=!0;typeof e=="number"?t.rack=e:typeof e=="string"?(n=!1,t.keys=[e]):t.keys=Se(e);const s=await this.retriever.retrieve(t);return n?s:s[0]}};const Vc=u.z.bigint().or(u.z.number()).transform(r=>r.toString()),Kc=u.z.object({key:Vc,name:u.z.string(),type:u.z.string(),config:u.z.record(u.z.unknown()).or(u.z.string().transform(r=>JSON.parse(r)))}),g_=Kc.omit({key:!0}).extend({key:Vc.transform(r=>r.toString()).optional(),config:u.z.unknown().transform(r=>JSON.stringify(r))});u.z.object({rack:ra.optional(),keys:u.z.string().array().optional(),offset:u.z.number().optional(),limit:u.z.number().optional()});const lo=u.z.object({tasks:u.z.union([Kc.array(),u.z.null().transform(()=>[])])}),ho="/hardware/task/retrieve";let Ch=class{constructor(e){h(this,"client");this.client=e}async retrieve(e){return(await ue(this.client,ho,e,lo)).tasks}async search(e){return(await ue(this.client,ho,{keys:[e]},lo)).tasks}async page(e,t){return(await ue(this.client,ho,{offset:e,limit:t},lo)).tasks}};const v_="/hardware/task/create",w_="/hardware/task/delete";u.z.object({tasks:g_.array()});const __=u.z.object({tasks:Kc.array()});u.z.object({keys:Vc.array()});const b_=u.z.object({});let jh=class{constructor(e){h(this,"client");this.client=e}async create(e){return(await ue(this.client,v_,{tasks:e.map(n=>({...n,config:JSON.stringify(n.config)}))},__)).tasks}async delete(e){await ue(this.client,w_,{keys:e},b_)}};const k_=Object.freeze(Object.defineProperty({__proto__:null,Client:Ih,Retriever:Ch,Writer:jh},Symbol.toStringTag,{value:"Module"}));class O_{constructor(e,t){h(this,"key");h(this,"name");this.key=t,this.name=e}get ontologyID(){return new nt({type:"group",key:this.key})}}const T_=u.z.string().uuid(),x_=u.z.object({key:T_,name:u.z.string()}),S_=u.z.object({group:x_});var qt;let E_=(qt=class{constructor(e){h(this,"client");this.client=e}async create(e,t){const n={parent:e,name:t},[s,a]=await this.client.send(qt.ENDPOINT,n,S_);if(a!=null)throw a;return s.group}async rename(e,t){const n={key:e,name:t},[,s]=await this.client.send(qt.ENDPOINT_RENAME,n,u.z.object({}));if(s!=null)throw s}async delete(e){const t={keys:e},[,n]=await this.client.send(qt.ENDPOINT_DELETE,t,u.z.object({}));if(n!=null)throw n}},h(qt,"ENDPOINT","/ontology/create-group"),h(qt,"ENDPOINT_RENAME","/ontology/rename-group"),h(qt,"ENDPOINT_DELETE","/ontology/delete-group"),qt),N_=class{constructor(e){h(this,"creator");this.creator=new E_(e)}async create(e,t){return this.sugar(await this.creator.create(e,t))}async rename(e,t){return await this.creator.rename(e,t)}async delete(...e){return await this.creator.delete(e)}sugar(e){return new O_(e.name,e.key)}};const Zh=u.z.union([u.z.literal("label"),u.z.literal("builtin"),u.z.literal("cluster"),u.z.literal("channel"),u.z.literal("node"),u.z.literal("group"),u.z.literal("range"),u.z.literal("range-alias"),u.z.literal("user"),u.z.literal("workspace"),u.z.literal("pid"),u.z.literal("lineplot"),u.z.literal("rack")]),sa=u.z.object({type:Zh,key:u.z.string()}),Rh=u.z.string().transform(r=>{const[e,t]=r.split(":");return{type:e,key:t}}),zh=u.z.union([Rh,sa]),En=class En{constructor(e){h(this,"type");h(this,"key");if(e instanceof En)this.type=e.type,this.key=e.key;else if(typeof e=="string"){const[t,n]=e.split(":");this.type=t,this.key=n}else this.type=e.type,this.key=e.key}toString(){return`${this.type}:${this.key}`}get payload(){return{type:this.type,key:this.key}}};h(En,"z",u.z.union([zh,u.z.instanceof(En)]).transform(e=>new En(e)));let nt=En;const A_=new nt({type:"builtin",key:"root"}),Ph=u.z.object({type:u.z.number()}),Uh=u.z.object({type:Zh,fields:u.z.record(Ph)}),Dh=u.z.object({id:nt.z,name:u.z.string(),schema:Uh.optional(),data:u.z.record(u.z.unknown()).optional()}).transform(r=>({key:r.id.toString(),...r})),I_=u.z.object({from:nt.z,type:u.z.string(),to:nt.z}),Vo=r=>{const[e,t,n]=r.split("->");return{from:new nt(e),type:t,to:new nt(n)}};u.z.object({ids:sa.array().optional(),children:u.z.boolean().optional(),parents:u.z.boolean().optional(),includeSchema:u.z.boolean().optional(),includeFieldData:u.z.boolean().optional(),term:u.z.string().optional()});const C_=u.z.object({resources:Dh.array()});var In;let j_=(In=class{constructor(e){h(this,"client");this.client=e}async search(e){return await this.execute({term:e})}async retrieve(e,t=!0,n=!0){return await this.execute({ids:Se(e).map(s=>new nt(s).payload),includeFieldData:n,includeSchema:t})}async retrieveChildren(e,t=!0,n=!0){return await this.execute({ids:Se(e).map(s=>new nt(s).payload),children:!0,includeSchema:t,includeFieldData:n})}async retrieveParents(e,t=!0,n=!0){return await this.execute({ids:Se(e).map(s=>new nt(s).payload),parents:!0,includeSchema:t,includeFieldData:n})}async execute(e){const[t,n]=await this.client.send(In.ENDPOINT,e,C_);if(n!=null)throw n;return t.resources}},h(In,"ENDPOINT","/ontology/retrieve"),In);const fo={ADD_CHILDREN:"/ontology/add-children",REMOVE_CHILDREN:"/ontology/remove-children",MOVE_CHILDREN:"/ontology/move-children"};let Z_=class{constructor(e){h(this,"client");this.client=e}async addChildren(e,...t){const n={id:e,children:t},[,s]=await this.client.send(fo.ADD_CHILDREN,n,u.z.object({}));if(s!=null)throw s}async removeChildren(e,...t){const n={id:e,children:t},[,s]=await this.client.send(fo.REMOVE_CHILDREN,n,u.z.object({}));if(s!=null)throw s}async moveChildren(e,t,...n){const s={from:e,to:t,children:n},[,a]=await this.client.send(fo.MOVE_CHILDREN,s,u.z.object({}));if(a!=null)throw a}};const Ku="sy_ontology_resource_set",Fu="sy_ontology_resource_delete",Wu="sy_ontology_relationship_set",qu="sy_ontology_relationship_delete";class Ki{constructor(e,t){h(this,"resourceObs");h(this,"relationshipObs");h(this,"relationships");h(this,"resources");h(this,"streamer");h(this,"retriever");h(this,"closePromise");this.relationshipObs=new Ga.Observer,this.relationships=this.relationshipObs,this.resourceObs=new Ga.Observer,this.resources=this.resourceObs,this.retriever=t,this.streamer=e,this.closePromise=this.start()}async close(){this.streamer.close(),await this.closePromise}async start(){for await(const e of this.streamer)await this.update(e)}async update(e){const t=await this.parseResourceSets(e),n=this.parseResourceDeletes(e);t.concat(n).length>0&&this.resourceObs.notify(t.concat(n));const a=this.parseRelationshipSets(e),i=this.parseRelationshipDeletes(e);a.concat(i).length>0&&this.relationshipObs.notify(a.concat(i))}parseRelationshipSets(e){const t=e.get(Wu);return t.length===0?[]:t[0].toStrings().map(n=>({variant:"set",key:Vo(n),value:void 0}))}parseRelationshipDeletes(e){const t=e.get(qu);return t.length===0?[]:t[0].toStrings().map(n=>({variant:"delete",key:Vo(n)}))}async parseResourceSets(e){const t=e.get(Ku);if(t.length===0)return[];const n=t[0].toStrings().map(s=>new nt(s));try{return(await this.retriever.retrieve(n)).map(a=>({variant:"set",key:a.id,value:a}))}catch(s){if(s instanceof tr)return console.warn(s),[];throw s}}parseResourceDeletes(e){const t=e.get(Fu);return t.length===0?[]:t[0].toStrings().map(n=>({variant:"delete",key:new nt(n)}))}static async open(e,t){const n=await e.newStreamer([Ku,Fu,Wu,qu]);return new Ki(n,t)}}let Mh=class{constructor(e,t){h(this,"groups");h(this,"retriever");h(this,"writer");h(this,"framer");this.retriever=new j_(e),this.writer=new Z_(e),this.groups=new N_(e),this.framer=t}async search(e){return await this.retriever.search(e)}async retrieve(e,t,n){const s=await this.retriever.retrieve(e,t,n);if(Array.isArray(e))return s;if(s.length===0)throw new tr(`No resource found with ID ${e.toString()}`);return s[0]}async page(e,t){return[]}async retrieveChildren(e,t,n){return await this.retriever.retrieveChildren(e,t,n)}async retrieveParents(e,t,n){return await this.retriever.retrieveParents(e,t,n)}async addChildren(e,...t){return await this.writer.addChildren(e,...t)}async removeChildren(e,...t){return await this.writer.removeChildren(e,...t)}async moveChildren(e,t,...n){return await this.writer.moveChildren(e,t,...n)}async openChangeTracker(){return await Ki.open(this.framer,this.retriever)}};const R_=Object.freeze(Object.defineProperty({__proto__:null,ChangeTracker:Ki,Client:Mh,ID:nt,Root:A_,crudeIDZ:zh,idZ:sa,parseRelationship:Vo,relationshipSchemaZ:I_,resourceSchemaZ:Dh,schemaFieldZ:Ph,schemaZ:Uh,stringIDZ:Rh},Symbol.toStringTag,{value:"Module"})),Ln=u.z.string().uuid(),aa=u.z.object({key:Ln,name:u.z.string().min(1),color:u.z.string()}),z_=r=>new nt({type:"label",key:r});u.z.object({keys:Ln.array().optional(),for:sa.optional(),search:u.z.string().optional(),offset:u.z.number().optional(),limit:u.z.number().optional()});const P_=u.z.object({labels:aa.array().optional().default([])});var Cn;let $h=(Cn=class{constructor(e){h(this,"client");this.client=e}async retrieve(e){const t=Se(e);return await this.execute({keys:t})}async retrieveFor(e){return await this.execute({for:e})}async search(e){return await this.execute({search:e})}async page(e,t){return await this.execute({offset:e,limit:t})}async execute(e){const[t,n]=await this.client.send(Cn.ENDPOINT,e,P_);if(n!=null)throw n;return t.labels}},h(Cn,"ENDPOINT","/label/retrieve"),Cn);const Lh=aa.extend({key:Ln.optional()});u.z.object({labels:Lh.array()});const U_=u.z.object({labels:aa.array()});u.z.object({keys:Ln.array()});u.z.object({id:sa,labels:Ln.array()});const po=u.z.object({}),D_="/label/create",M_="/label/delete",$_="/label/set",L_="/label/remove";let Bh=class{constructor(e){h(this,"client");this.client=e}async create(e){return(await ue(this.client,D_,{labels:Se(e)},U_)).labels}async delete(e){await ue(this.client,M_,{keys:Se(e)},po)}async set(e,t){await ue(this.client,$_,{id:e,labels:t},po)}async remove(e,t){await ue(this.client,L_,{id:e,labels:t},po)}};const B_="sy_label_set",V_="sy_label_delete";let Vh=class{constructor(e,t){h(this,"retriever");h(this,"writer");h(this,"frameClient");this.writer=new Bh(e),this.retriever=new $h(e),this.frameClient=t}async search(e){return await this.retriever.search(e)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async retrieveFor(e){return await this.retriever.retrieveFor(e)}async label(e,t){await this.writer.set(e,t)}async removeLabels(e,t){await this.writer.remove(e,t)}async page(e,t){return await this.retriever.page(e,t)}async create(e){const t=Array.isArray(e),n=await this.writer.create(e);return t?n:n[0]}async delete(e){await this.writer.delete(e)}async openChangeTracker(){return await na.open(this.frameClient,B_,V_,K_)}};const K_=(r,e)=>r==="delete"?e.toUUIDs().map(t=>({variant:r,key:t})):e.parseJSON(aa).map(t=>({variant:r,key:t.key,value:t})),F_=Object.freeze(Object.defineProperty({__proto__:null,Client:Vh,Retriever:$h,Writer:Bh,keyZ:Ln,labelZ:aa,newLabelPayloadZ:Lh,ontologyID:z_},Symbol.toStringTag,{value:"Module"})),bt=u.z.string().uuid(),ia=u.z.object({key:bt,name:u.z.string().min(1),timeRange:Zt.z}),Kh=ia.extend({key:u.z.string().uuid().optional()}),Fc=r=>{const e=Se(r);if(e.length===0)throw new Error("Range params must not be empty");const t=bt.safeParse(e[0]).success;return{single:!Array.isArray(r),variant:t?"keys":"names",normalized:e,actual:r}},W_=u.z.object({}),q_=u.z.object({range:ia}),Y_=u.z.object({}),J_="/range/set-active",G_="/range/retrieve-active",H_="/range/clear-active";class X_{constructor(e){h(this,"client");this.client=e}async setActive(e){const[,t]=await this.client.send(J_,{range:e},W_);if(t!=null)throw t}async retrieveActive(){const[e,t]=await this.client.send(G_,{},q_);if(t instanceof tr)return null;if(t!=null)throw t;return e.range}async clearActive(e){const[,t]=await this.client.send(H_,{range:e},Y_);if(t!=null)throw t}}const Q_="sy_range_alias_set",eb="sy_range_alias_delete";u.z.object({range:bt,aliases:u.z.string().array()});const tb=u.z.object({aliases:u.z.record(u.z.string(),Js)});u.z.object({range:bt,aliases:u.z.record(Js,u.z.string())});u.z.unknown();u.z.object({range:bt,channels:Js.array()});const rb=u.z.unknown();u.z.object({range:bt});const nb=u.z.object({aliases:u.z.record(u.z.string(),u.z.string())}),Kt=class Kt{constructor(e,t,n){h(this,"frameClient");h(this,"cache",new Map);h(this,"client");h(this,"rangeKey");this.rangeKey=e,this.cache=new Map,this.client=n,this.frameClient=t}async resolve(e){const t=[],n=typeof e=="string",s={};if(n){const i=this.cache.get(e);if(i!=null)return i;t.push(e)}else e.forEach(i=>{const o=this.cache.get(i);o!=null?s[i]=o:t.push(i)});if(t.length===0)return s;const a=await ue(this.client,Kt.RESOLVE_ENDPOINT,{range:this.rangeKey,aliases:t},tb);return Object.entries(a.aliases).forEach(([i,o])=>this.cache.set(i,o)),n?a.aliases[t[0]]:{...s,...a.aliases}}async set(e){await ue(this.client,Kt.SET_ENDPOINT,{range:this.rangeKey,aliases:e},u.z.unknown())}async list(){return(await ue(this.client,Kt.LIST_ENDPOINT,{range:this.rangeKey},nb)).aliases}async delete(e){await ue(this.client,Kt.DELETE_ENDPOINT,{range:this.rangeKey,channels:e},rb)}async openChangeTracker(){return await na.open(this.frameClient,Q_,eb,ib(this.rangeKey))}};h(Kt,"SET_ENDPOINT","/range/alias/set"),h(Kt,"RESOLVE_ENDPOINT","/range/alias/resolve"),h(Kt,"LIST_ENDPOINT","/range/alias/list"),h(Kt,"DELETE_ENDPOINT","/range/alias/delete");let Ko=Kt;const sb=u.z.object({range:bt,channel:Js,alias:u.z.string()}),ab="---",ib=r=>(e,t)=>e==="delete"?t.toStrings().filter(n=>n.split(ab)[0]===r).map(n=>({variant:e,key:n,value:void 0})):t.parseJSON(sb).map(n=>({variant:e,key:n.alias,value:n}));u.z.object({range:bt,keys:u.z.string().array()});const ob=u.z.object({pairs:u.z.record(u.z.string(),u.z.string())});u.z.object({range:bt,pairs:u.z.record(u.z.string(),u.z.string())});u.z.object({range:bt,keys:u.z.string().array()});const Cr=class Cr{constructor(e,t){h(this,"rangeKey");h(this,"client");this.rangeKey=e,this.client=t}async get(e){const[t,n]=await this.client.send(Cr.GET_ENDPOINT,{range:this.rangeKey,keys:Se(e)},ob);if(n!=null)throw n;return Array.isArray(e)?t.pairs:t.pairs[e]}async set(e,t){await ue(this.client,Cr.SET_ENDPOINT,{range:this.rangeKey,pairs:em(e)?e:{[e]:t}},u.z.unknown())}async delete(e){await ue(this.client,Cr.DELETE_ENDPOINT,{range:this.rangeKey,keys:Se(e)},u.z.unknown())}};h(Cr,"GET_ENDPOINT","/range/kv/get"),h(Cr,"SET_ENDPOINT","/range/kv/set"),h(Cr,"DELETE_ENDPOINT","/range/kv/delete");let Fo=Cr;const mo=r=>new nt({type:"range",key:r});class Fh{constructor(e,t=Zt.ZERO,n,s,a,i,o,c){h(this,"key");h(this,"name");h(this,"kv");h(this,"timeRange");h(this,"channels");h(this,"aliaser");h(this,"frameClient");h(this,"labelClient");this.key=n,this.name=e,this.timeRange=t,this.frameClient=s,this.kv=a,this.aliaser=i,this.channels=o,this.labelClient=c}async setAlias(e,t){const n=await this.channels.retrieve(e);if(n.length===0)throw new tr(`Channel ${e} does not exist`);await this.aliaser.set({[n[0].key]:t})}async deleteAlias(...e){await this.aliaser.delete(e)}async listAliases(){return await this.aliaser.list()}async openAliasTracker(){return await this.aliaser.openChangeTracker()}async read(e){return await this.frameClient.read(this.timeRange,e)}async labels(){return await this.labelClient.retrieveFor(mo(this.key))}async addLabel(...e){await this.labelClient.label(mo(this.key),e)}async removeLabel(...e){await this.labelClient.removeLabels(mo(this.key),e)}}let Wh=class{constructor(e,t,n,s,a,i){h(this,"frameClient");h(this,"retriever");h(this,"writer");h(this,"unaryClient");h(this,"channels");h(this,"active");h(this,"labelClient");this.frameClient=e,this.retriever=t,this.writer=n,this.unaryClient=s,this.channels=a,this.active=new X_(s),this.labelClient=i}async create(e){const t=!Array.isArray(e),n=this.sugar(await this.writer.create(Se(e)));return t?n[0]:n}async rename(e,t){await this.writer.rename(e,t)}async delete(e){await this.writer.delete(Se(e))}async search(e){return this.sugar(await this.retriever.search(e))}async page(e,t){return[]}async retrieve(e){const{single:t,actual:n}=Fc(e),s=this.sugar(await this.retriever.retrieve(e));if(!t)return s;if(s.length===0)throw new tr(`range matching ${n} not found`);if(s.length>1)throw new tr(`multiple ranges matching ${n} found`);return s[0]}async setActive(e){await this.active.setActive(e)}async retrieveActive(){const e=await this.active.retrieveActive();return e==null?null:this.sugar([e])[0]}async clearActive(e){await this.active.clearActive(e)}sugar(e){return e.map(t=>new Fh(t.name,t.timeRange,t.key,this.frameClient,new Fo(t.key,this.unaryClient),new Ko(t.key,this.frameClient,this.unaryClient),this.channels,this.labelClient))}};const cb=u.z.object({ranges:ia.array()});u.z.object({ranges:Kh.array()});u.z.object({keys:bt.array()});const ub=u.z.object({});u.z.object({key:bt,name:u.z.string()});const lb=u.z.object({}),db="/range/create",hb="/range/delete",fb="/range/rename";let qh=class{constructor(e){h(this,"client");this.client=e}async rename(e,t){await ue(this.client,fb,{key:e,name:t},lb)}async create(e){return(await ue(this.client,db,{ranges:e},cb)).ranges}async delete(e){await ue(this.client,hb,{keys:e},ub)}};u.z.object({keys:bt.array().optional(),names:u.z.array(u.z.string()).optional(),term:u.z.string().optional()});const pb=u.z.object({ranges:u.z.array(ia)});let Yh=class{constructor(e){h(this,"ENDPOINT","/range/retrieve");h(this,"client");this.client=e}async retrieve(e){const{normalized:t,variant:n}=Fc(e);return await this.execute({[n]:t})}async search(e){return await this.execute({term:e})}async execute(e){const[t,n]=await this.client.send(this.ENDPOINT,e,pb);if(n!=null)throw n;return t.ranges}};const mb=Object.freeze(Object.defineProperty({__proto__:null,Client:Wh,Range:Fh,Retriever:Yh,Writer:qh,analyzeParams:Fc,keyZ:bt,newPayloadZ:Kh,payloadZ:ia},Symbol.toStringTag,{value:"Module"})),yb="/api/v1/";class gb{constructor(e,t=!1){h(this,"url");h(this,"unary");h(this,"stream");h(this,"secure");this.secure=t,this.url=e.child(yb);const n=new Vl.JSONEncoderDecoder;this.unary=new yw(this.url,n,this.secure),this.stream=new xw(this.url,n,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}}const Jr=u.z.string().uuid(),Wc=u.z.object({name:u.z.string(),key:Jr,layout:ic}),Fi=Wc.omit({layout:!0}).extend({layout:u.z.string().transform(r=>JSON.parse(r))}),qc=u.z.string().uuid(),vb=u.z.object({key:u.z.string(),name:u.z.string(),data:ic}),Yc=u.z.object({key:u.z.string(),name:u.z.string(),data:u.z.string().transform(r=>JSON.parse(r))});u.z.object({keys:u.z.string().array()});const wb=u.z.object({linePlots:Yc.array()});let _b=class{constructor(e){h(this,"ENDPOINT","/workspace/lineplot/retrieve");h(this,"client");this.client=e}async retrieve(e){const t=Se(e);return await this.execute({keys:t})}async execute(e){const[t,n]=await this.client.send(this.ENDPOINT,e,wb);if(n!=null)throw n;return t.linePlots}};vb.partial({key:!0});const bb=Yc.partial({key:!0});u.z.object({workspace:Jr,linePlots:bb.array()});const kb=u.z.object({linePlots:Yc.array()});u.z.object({keys:qc.array()});const Ob=u.z.object({});u.z.object({key:qc,name:u.z.string()});const Yu=u.z.object({});u.z.object({key:qc,data:u.z.string()});u.z.object({});const Tb="/workspace/lineplot/create",xb="/workspace/lineplot/delete",Sb="/workspace/lineplot/rename",Eb="/workspace/lineplot/set-data";let Nb=class{constructor(e){h(this,"client");this.client=e}async create(e,t){const n={...t,data:JSON.stringify(t.data)};return(await ue(this.client,Tb,{workspace:e,linePlots:[n]},kb)).linePlots[0]}async delete(e){const t=Se(e);await ue(this.client,xb,{keys:t},Ob)}async rename(e,t){await ue(this.client,Sb,{key:e,name:t},Yu)}async setData(e,t){await ue(this.client,Eb,{key:e,data:JSON.stringify(t)},Yu)}},Ab=class{constructor(e){h(this,"writer");h(this,"retriever");this.writer=new Nb(e),this.retriever=new _b(e)}async create(e,t){return await this.writer.create(e,t)}async rename(e,t){await this.writer.rename(e,t)}async setData(e,t){await this.writer.setData(e,t)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async delete(e){await this.writer.delete(e)}};const Wi=u.z.string().uuid(),Ib=u.z.object({key:u.z.string(),name:u.z.string(),data:ic,snapshot:u.z.boolean()}),qi=u.z.object({key:u.z.string(),name:u.z.string(),snapshot:u.z.boolean(),data:u.z.string().transform(r=>JSON.parse(r))});u.z.object({keys:u.z.string().array()});const Cb=u.z.object({pids:qi.array()});let jb=class{constructor(e){h(this,"ENDPOINT","/workspace/pid/retrieve");h(this,"client");this.client=e}async retrieve(e){const t=Se(e);return await this.execute({keys:t})}async execute(e){const[t,n]=await this.client.send(this.ENDPOINT,e,Cb);if(n!=null)throw n;return t.pids}};Ib.partial({key:!0});const Zb=qi.partial({key:!0,snapshot:!0});u.z.object({workspace:Jr,pids:Zb.array()});const Rb=u.z.object({pids:qi.array()});u.z.object({keys:Wi.array()});const zb=u.z.object({});u.z.object({key:Wi,name:u.z.string()});const Ju=u.z.object({});u.z.object({key:Wi,data:u.z.string()});u.z.object({});u.z.object({key:Wi,name:u.z.string(),snapshot:u.z.boolean()});const Pb=u.z.object({pid:qi}),Ub="/workspace/pid/create",Db="/workspace/pid/delete",Mb="/workspace/pid/rename",$b="/workspace/pid/set-data",Lb="/workspace/pid/copy";let Bb=class{constructor(e){h(this,"client");this.client=e}async create(e,t){const n={...t,data:JSON.stringify(t.data)};return(await ue(this.client,Ub,{workspace:e,pids:[n]},Rb)).pids[0]}async copy(e,t,n){return(await ue(this.client,Lb,{key:e,name:t,snapshot:n},Pb)).pid}async delete(e){const t=Se(e);await ue(this.client,Db,{keys:t},zb)}async rename(e,t){await ue(this.client,Mb,{key:e,name:t},Ju)}async setData(e,t){await ue(this.client,$b,{key:e,data:JSON.stringify(t)},Ju)}},Vb=class{constructor(e){h(this,"writer");h(this,"retriever");this.writer=new Bb(e),this.retriever=new jb(e)}async create(e,t){return await this.writer.create(e,t)}async rename(e,t){await this.writer.rename(e,t)}async setData(e,t){await this.writer.setData(e,t)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async delete(e){await this.writer.delete(e)}async copy(e,t,n){return await this.writer.copy(e,t,n)}};u.z.object({keys:Jr.array().optional(),search:u.z.string().optional(),author:u.z.string().uuid().optional(),offset:u.z.number().optional(),limit:u.z.number().optional()});const Kb=u.z.object({workspaces:Fi.array()}),Oi=class Oi{constructor(e){h(this,"client");this.client=e}async retrieve(e){const t=Se(e);return await this.execute({keys:t})}async retrieveByAuthor(e){return await this.execute({author:e})}async search(e){return await this.execute({search:e})}async page(e,t){return await this.execute({offset:e,limit:t})}async execute(e){const[t,n]=await this.client.send(Oi.ENDPOINT,e,Kb);if(n!=null)throw n;return t.workspaces}};h(Oi,"ENDPOINT","/workspace/retrieve");let Wo=Oi;Wc.partial({key:!0});const Fb=Fi.partial({key:!0});u.z.object({workspaces:Fb.partial({key:!0}).array()});const Wb=u.z.object({workspaces:Fi.array()});u.z.object({keys:Jr.array()});const qb=u.z.object({});u.z.object({key:Jr,name:u.z.string()});const Yb=u.z.object({});u.z.object({key:Jr,layout:u.z.string()});const Jb=u.z.object({}),Gb="/workspace/create",Hb="/workspace/delete",Xb="/workspace/rename",Qb="/workspace/set-layout";class e0{constructor(e){h(this,"client");this.client=e}async create(e){const t=Se(e).map(s=>({...s,layout:JSON.stringify(s.layout)}));return(await ue(this.client,Gb,{workspaces:t},Wb)).workspaces}async delete(e){await ue(this.client,Hb,{keys:Se(e)},qb)}async rename(e,t){await ue(this.client,Xb,{key:e,name:t},Yb)}async setLayout(e,t){await ue(this.client,Qb,{key:e,layout:JSON.stringify(t)},Jb)}}class Jh{constructor(e){h(this,"pid");h(this,"linePlot");h(this,"retriever");h(this,"writer");this.pid=new Vb(e),this.linePlot=new Ab(e),this.retriever=new Wo(e),this.writer=new e0(e)}async search(e){return await this.retriever.search(e)}async retrieveByAuthor(e){return await this.retriever.retrieveByAuthor(e)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async page(e,t){return await this.retriever.page(e,t)}async create(e){const t=Array.isArray(e),n=await this.writer.create(e);return t?n:n[0]}async rename(e,t){await this.writer.rename(e,t)}async setLayout(e,t){await this.writer.setLayout(e,t)}async delete(...e){await this.writer.delete(e)}}const t0=Object.freeze(Object.defineProperty({__proto__:null,Client:Jh,keyZ:Jr,workspaceRemoteZ:Fi,workspaceZ:Wc},Symbol.toStringTag,{value:"Module"})),Gh=u.z.object({host:u.z.string().min(1),port:u.z.number().or(u.z.string()),username:u.z.string().optional(),password:u.z.string().optional(),connectivityPollFrequency:Pe.z.default(Pe.seconds(30)),secure:u.z.boolean().optional().default(!1),name:u.z.string().optional()});class Hh{constructor(e){h(this,"transport");h(this,"createdAt");h(this,"telem");h(this,"ranges");h(this,"channels");h(this,"auth");h(this,"connectivity");h(this,"ontology");h(this,"props");h(this,"workspaces");h(this,"labels");h(this,"hardware");this.createdAt=Ue.now(),this.props=Gh.parse(e);const{host:t,port:n,username:s,password:a,connectivityPollFrequency:i,secure:o}=this.props;this.transport=new gb(new im({host:t,port:Number(n)}),o),this.transport.use(Cw),s!=null&&a!=null&&(this.auth=new Dw(this.transport.unary,{username:s,password:a}),this.transport.use(this.auth.middleware()));const c=new fc(new ms(this.transport.unary)),l=new Ha(this.transport.unary);this.telem=new bh(this.transport.stream,c),this.channels=new fh(this.telem,c,this.transport.unary,l),this.connectivity=new Fs(this.transport.unary,i,e.name),this.ontology=new Mh(this.transport.unary,this.telem);const w=new Yh(this.transport.unary),T=new qh(this.transport.unary);this.labels=new Vh(this.transport.unary,this.telem),this.ranges=new Wh(this.telem,w,T,this.transport.unary,c,this.labels),this.workspaces=new Jh(this.transport.unary);const X=new Oh(new Th(this.transport.unary),new xh(this.transport.unary),this.telem),Q=new Ch(this.transport.unary),Ze=new jh(this.transport.unary),ee=new Ih(Q,Ze),rr=new Sh(new Ah(this.transport.unary),new Nh(this.transport.unary),this.telem,Ze,Q);this.hardware=new kh(ee,rr,X)}close(){this.connectivity.stopChecking()}}h(Hh,"connectivity",Fs);const r0=Object.freeze(Object.defineProperty({__proto__:null,Authority:Wr,StateTracker:Mc,filterTransfersByChannelKey:Jw,stateZ:Yw,subjectZ:Dc,transferString:Gw},Symbol.toStringTag,{value:"Module"}));exports.AuthError=Zc;exports.Authority=Wr;exports.Channel=Rc;exports.ContiguityError=Nw;exports.DataType=et;exports.Density=st;exports.Frame=pt;exports.GeneralError=lh;exports.ParseError=dh;exports.QueryError=tr;exports.Rate=Ai;exports.RouteError=hh;exports.Series=Ct;exports.Synnax=Hh;exports.TimeRange=Zt;exports.TimeSpan=Pe;exports.TimeStamp=Ue;exports.UnexpectedError=yn;exports.ValidationError=zt;exports.channel=Zw;exports.connection=Lw;exports.control=r0;exports.device=d_;exports.framer=e_;exports.hardware=t_;exports.label=F_;exports.ontology=R_;exports.rack=y_;exports.ranger=mb;exports.synnaxPropsZ=Gh;exports.task=k_;exports.workspace=t0;
21
+ //# sourceMappingURL=client.cjs.map