@synnaxlabs/drift 0.40.0 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +0,0 @@
1
- "use strict";const Er=require("@reduxjs/toolkit"),je=(n=!1,...e)=>{n&&console.log(...e)},Cn=(n=!1,...e)=>{n&&console.group(...e)},Ut=n=>{n&&console.groupEnd()},$r=n=>{const e=n.replace(/_[a-z]/g,t=>t[1].toUpperCase());return e.length>1&&e[0]===e[0].toUpperCase()&&e[1]===e[1].toUpperCase()||e.length===0?e:e[0].toLowerCase()+e.slice(1)},jn=n=>{const e=(t,r=Dt)=>{if(typeof t=="string")return n(t);if(Array.isArray(t))return t.map(a=>e(a,r));if(!jt(t))return t;r=Cr(r);const s={},i=t;return Object.keys(i).forEach(a=>{let o=i[a];const c=n(a);r.recursive&&(jt(o)?yn(o,r.keepTypesOnRecursion)||(o=e(o,r)):r.recursiveInArray&&mn(o)&&(o=[...o].map(l=>{let p=l;return jt(l)?yn(p,r.keepTypesOnRecursion)||(p=e(l,r)):mn(l)&&(p=e({key:l},r).key),p}))),s[c]=o}),s};return e},Zn=jn($r),Mr=n=>n.replace(/([a-z0-9])([A-Z])/g,(e,t,r)=>`${t}_${r.toLowerCase()}`),Rr=jn(Mr),Dt={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},Cr=(n=Dt)=>(n.recursive==null?n=Dt:n.recursiveInArray??(n.recursiveInArray=!1),n),mn=n=>n!=null&&Array.isArray(n),jt=n=>n!=null&&typeof n=="object"&&!Array.isArray(n),yn=(n,e)=>(e||[]).some(t=>n instanceof t),Ge=n=>n!=null&&typeof n=="object"&&!Array.isArray(n);var jr=Object.defineProperty,Zr=(n,e,t)=>e in n?jr(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Je=(n,e,t)=>Zr(n,typeof e!="symbol"?e+"":e,t);let Br=class{constructor(){Je(this,"contentType","application/json"),Je(this,"decoder"),Je(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(e){return this.encoder.encode(this.encodeString(e)).buffer}decode(e,t){return this.decodeString(this.decoder.decode(e),t)}decodeString(e,t){const r=JSON.parse(e),s=Zn(r);return t!=null?t.parse(s):s}encodeString(e){const t=Rr(e);return JSON.stringify(t,(r,s)=>ArrayBuffer.isView(s)?Array.from(s):Ge(s)&&"encode_value"in s?typeof s.value=="bigint"?s.value.toString():s.value:typeof s=="bigint"?s.toString():s)}static registerCustomType(){}},Ur=class{constructor(){Je(this,"contentType","text/csv")}encode(e){const t=this.encodeString(e);return new TextEncoder().encode(t).buffer}decode(e,t){const r=new TextDecoder().decode(e);return this.decodeString(r,t)}encodeString(e){if(!Array.isArray(e)||e.length===0||!Ge(e[0]))throw new Error("Payload must be an array of objects");const t=Object.keys(e[0]),r=[t.join(",")];return e.forEach(s=>{const i=t.map(a=>JSON.stringify(s[a]??""));r.push(i.join(","))}),r.join(`
2
- `)}decodeString(e,t){const[r,...s]=e.trim().split(`
3
- `).map(o=>o.trim());if(r.length===0)return t!=null?t.parse({}):{};const i=r.split(",").map(o=>o.trim()),a={};return i.forEach(o=>{a[o]=[]}),s.forEach(o=>{const c=o.split(",").map(l=>l.trim());i.forEach((l,p)=>{const y=this.parseValue(c[p]);y!=null&&a[l].push(y)})}),t!=null?t.parse(a):a}parseValue(e){if(e==null||e.length===0)return null;const t=Number(e);return isNaN(t)?e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e:t}static registerCustomType(){}},Dr=class{constructor(){Je(this,"contentType","text/plain")}encode(e){return new TextEncoder().encode(e).buffer}decode(e,t){const r=new TextDecoder().decode(e);return t!=null?t.parse(r):r}};const pt=new Br;new Ur;new Dr;var S;(function(n){n.assertEqual=s=>s;function e(s){}n.assertIs=e;function t(s){throw new Error}n.assertNever=t,n.arrayToEnum=s=>{const i={};for(const a of s)i[a]=a;return i},n.getValidEnumValues=s=>{const i=n.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(const o of i)a[o]=s[o];return n.objectValues(a)},n.objectValues=s=>n.objectKeys(s).map(function(i){return s[i]}),n.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},n.find=(s,i)=>{for(const a of s)if(i(a))return a},n.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}n.joinValues=r,n.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(S||(S={}));var Pt;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(Pt||(Pt={}));const g=S.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),se=n=>{switch(typeof n){case"undefined":return g.undefined;case"string":return g.string;case"number":return isNaN(n)?g.nan:g.number;case"boolean":return g.boolean;case"function":return g.function;case"bigint":return g.bigint;case"symbol":return g.symbol;case"object":return Array.isArray(n)?g.array:n===null?g.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?g.promise:typeof Map<"u"&&n instanceof Map?g.map:typeof Set<"u"&&n instanceof Set?g.set:typeof Date<"u"&&n instanceof Date?g.date:g.object;default:return g.unknown}},f=S.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"]),Pr=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class z extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(i){return i.message},r={_errors:[]},s=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)r._errors.push(t(a));else{let o=r,c=0;for(;c<a.path.length;){const l=a.path[c];c===a.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(a))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return s(this),r}static assert(e){if(!(e instanceof z))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,S.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];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))):r.push(e(s));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}z.create=n=>new z(n);const $e=(n,e)=>{let t;switch(n.code){case f.invalid_type:n.received===g.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case f.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,S.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:t=`Unrecognized key(s) in object: ${S.joinValues(n.keys,", ")}`;break;case f.invalid_union:t="Invalid input";break;case f.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${S.joinValues(n.options)}`;break;case f.invalid_enum_value:t=`Invalid enum value. Expected ${S.joinValues(n.options)}, received '${n.received}'`;break;case f.invalid_arguments:t="Invalid function arguments";break;case f.invalid_return_type:t="Invalid function return type";break;case f.invalid_date:t="Invalid date";break;case f.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:S.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case f.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case f.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case f.custom:t="Invalid input";break;case f.invalid_intersection_types:t="Intersection results could not be merged";break;case f.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case f.not_finite:t="Number must be finite";break;default:t=e.defaultError,S.assertNever(n)}return{message:t}};let Bn=$e;function Lr(n){Bn=n}function bt(){return Bn}const xt=n=>{const{data:e,path:t,errorMaps:r,issueData:s}=n,i=[...t,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let o="";const c=r.filter(l=>!!l).slice().reverse();for(const l of c)o=l(a,{data:e,defaultError:o}).message;return{...s,path:i,message:o}},Wr=[];function m(n,e){const t=bt(),r=xt({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===$e?void 0:$e].filter(s=>!!s)});n.common.issues.push(r)}class P{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const s of t){if(s.status==="aborted")return x;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const s of t){const i=await s.key,a=await s.value;r.push({key:i,value:a})}return P.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const s of t){const{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return x;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(r[i.value]=a.value)}return{status:e.value,value:r}}}const x=Object.freeze({status:"aborted"}),Ae=n=>({status:"dirty",value:n}),W=n=>({status:"valid",value:n}),Lt=n=>n.status==="aborted",Wt=n=>n.status==="dirty",Te=n=>n.status==="valid",He=n=>typeof Promise<"u"&&n instanceof Promise;function _t(n,e,t,r){if(typeof e=="function"?n!==e||!0:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(n)}function Un(n,e,t,r,s){if(typeof e=="function"?n!==e||!0:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(n,t),t}var v;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(v||(v={}));var Ze,Be;class K{constructor(e,t,r,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,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 gn=(n,e)=>{if(Te(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new z(n.common.issues);return this._error=t,this._error}}};function _(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:s}=n;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,o)=>{var c,l;const{message:p}=n;return a.code==="invalid_enum_value"?{message:p??o.defaultError}:typeof o.data>"u"?{message:(c=p??r)!==null&&c!==void 0?c:o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:(l=p??t)!==null&&l!==void 0?l:o.defaultError}},description:s}}class O{get description(){return this._def.description}_getType(e){return se(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:se(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new P,ctx:{common:e.parent.common,data:e.data,parsedType:se(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(He(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const s={common:{issues:[],async:(r=t==null?void 0:t.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:se(e)},i=this._parseSync({data:e,path:s.path,parent:s});return gn(s,i)}"~validate"(e){var t,r;const s={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:se(e)};if(!this["~standard"].async)try{const i=this._parseSync({data:e,path:[],parent:s});return Te(i)?{value:i.value}:{issues:s.common.issues}}catch(i){!((r=(t=i==null?void 0:i.message)===null||t===void 0?void 0:t.toLowerCase())===null||r===void 0)&&r.includes("encountered")&&(this["~standard"].async=!0),s.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:s}).then(i=>Te(i)?{value:i.value}:{issues:s.common.issues})}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:se(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(He(s)?s:Promise.resolve(s));return gn(r,i)}refine(e,t){const r=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{const a=e(s),o=()=>i.addIssue({code:f.custom,...r(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof t=="function"?t(r,s):t),!1))}_refinement(e){return new Y({schema:this,typeName:b.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return X.create(this,this._def)}nullable(){return pe.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return F.create(this)}promise(){return Re.create(this,this._def)}or(e){return et.create([this,e],this._def)}and(e){return tt.create(this,e,this._def)}transform(e){return new Y({..._(this._def),schema:this,typeName:b.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new at({..._(this._def),innerType:this,defaultValue:t,typeName:b.ZodDefault})}brand(){return new en({typeName:b.ZodBranded,type:this,..._(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ot({..._(this._def),innerType:this,catchValue:t,typeName:b.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return dt.create(this,e)}readonly(){return ut.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const zr=/^c[^\s-]{8,}$/i,Vr=/^[0-9a-z]+$/,qr=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Fr=/^[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,Yr=/^[a-z0-9_-]{21}$/i,Gr=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Jr=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Hr=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Xr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Zt;const Kr=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Qr=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,es=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,ts=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ns=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,rs=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Dn="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",ss=new RegExp(`^${Dn}$`);function Pn(n){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`),e}function is(n){return new RegExp(`^${Pn(n)}$`)}function Ln(n){let e=`${Dn}T${Pn(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function as(n,e){return!!((e==="v4"||!e)&&Kr.test(n)||(e==="v6"||!e)&&es.test(n))}function os(n,e){if(!Gr.test(n))return!1;try{const[t]=n.split("."),r=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||!s.typ||!s.alg||e&&s.alg!==e)}catch{return!1}}function us(n,e){return!!((e==="v4"||!e)&&Qr.test(n)||(e==="v6"||!e)&&ts.test(n))}class q extends O{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==g.string){const i=this._getOrReturnCtx(e);return m(i,{code:f.invalid_type,expected:g.string,received:i.parsedType}),x}const r=new P;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:f.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:f.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const a=e.data.length>i.value,o=e.data.length<i.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?m(s,{code:f.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&m(s,{code:f.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")Hr.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"email",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Zt||(Zt=new RegExp(Xr,"u")),Zt.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"emoji",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")Fr.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"uuid",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")Yr.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"nanoid",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")zr.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"cuid",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")Vr.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"cuid2",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")qr.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"ulid",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),m(s,{validation:"url",code:f.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"regex",code:f.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),m(s,{code:f.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),m(s,{code:f.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),m(s,{code:f.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?Ln(i).test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:f.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?ss.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:f.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?is(i).test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:f.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?Jr.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"duration",code:f.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?as(e.data,i.version)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"ip",code:f.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?os(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"jwt",code:f.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?us(e.data,i.version)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"cidr",code:f.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?ns.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"base64",code:f.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?rs.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"base64url",code:f.invalid_string,message:i.message}),r.dirty()):S.assertNever(i);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(s=>e.test(s),{validation:t,code:f.invalid_string,...v.errToObj(r)})}_addCheck(e){return new q({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...v.errToObj(e)})}url(e){return this._addCheck({kind:"url",...v.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...v.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...v.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...v.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...v.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...v.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...v.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...v.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...v.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...v.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...v.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...v.errToObj(e)})}datetime(e){var t,r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(r=e==null?void 0:e.local)!==null&&r!==void 0?r:!1,...v.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...v.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...v.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...v.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...v.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...v.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...v.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...v.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...v.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...v.errToObj(t)})}nonempty(e){return this.min(1,v.errToObj(e))}trim(){return new q({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new q({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new q({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}q.create=n=>{var e;return new q({checks:[],typeName:b.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,..._(n)})};function cs(n,e){const t=(n.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=t>r?t:r,i=parseInt(n.toFixed(s).replace(".","")),a=parseInt(e.toFixed(s).replace(".",""));return i%a/Math.pow(10,s)}class de extends O{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)!==g.number){const i=this._getOrReturnCtx(e);return m(i,{code:f.invalid_type,expected:g.number,received:i.parsedType}),x}let r;const s=new P;for(const i of this._def.checks)i.kind==="int"?S.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{code:f.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:f.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:f.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?cs(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),m(r,{code:f.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{code:f.not_finite,message:i.message}),s.dirty()):S.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,v.toString(t))}gt(e,t){return this.setLimit("min",e,!1,v.toString(t))}lte(e,t){return this.setLimit("max",e,!0,v.toString(t))}lt(e,t){return this.setLimit("max",e,!1,v.toString(t))}setLimit(e,t,r,s){return new de({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:v.toString(s)}]})}_addCheck(e){return new de({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:v.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:v.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:v.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:v.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:v.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)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"&&S.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}de.create=n=>new de({checks:[],typeName:b.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,..._(n)});class he extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==g.bigint)return this._getInvalidInput(e);let r;const s=new P;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:f.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:f.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),m(r,{code:f.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):S.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return m(t,{code:f.invalid_type,expected:g.bigint,received:t.parsedType}),x}gte(e,t){return this.setLimit("min",e,!0,v.toString(t))}gt(e,t){return this.setLimit("min",e,!1,v.toString(t))}lte(e,t){return this.setLimit("max",e,!0,v.toString(t))}lt(e,t){return this.setLimit("max",e,!1,v.toString(t))}setLimit(e,t,r,s){return new he({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:v.toString(s)}]})}_addCheck(e){return new he({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:v.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)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}}he.create=n=>{var e;return new he({checks:[],typeName:b.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,..._(n)})};class Xe extends O{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==g.boolean){const r=this._getOrReturnCtx(e);return m(r,{code:f.invalid_type,expected:g.boolean,received:r.parsedType}),x}return W(e.data)}}Xe.create=n=>new Xe({typeName:b.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,..._(n)});class Oe extends O{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==g.date){const i=this._getOrReturnCtx(e);return m(i,{code:f.invalid_type,expected:g.date,received:i.parsedType}),x}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return m(i,{code:f.invalid_date}),x}const r=new P;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:f.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:f.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):S.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Oe({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:v.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:v.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)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}}Oe.create=n=>new Oe({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:b.ZodDate,..._(n)});class Tt extends O{_parse(e){if(this._getType(e)!==g.symbol){const r=this._getOrReturnCtx(e);return m(r,{code:f.invalid_type,expected:g.symbol,received:r.parsedType}),x}return W(e.data)}}Tt.create=n=>new Tt({typeName:b.ZodSymbol,..._(n)});class Ke extends O{_parse(e){if(this._getType(e)!==g.undefined){const r=this._getOrReturnCtx(e);return m(r,{code:f.invalid_type,expected:g.undefined,received:r.parsedType}),x}return W(e.data)}}Ke.create=n=>new Ke({typeName:b.ZodUndefined,..._(n)});class Qe extends O{_parse(e){if(this._getType(e)!==g.null){const r=this._getOrReturnCtx(e);return m(r,{code:f.invalid_type,expected:g.null,received:r.parsedType}),x}return W(e.data)}}Qe.create=n=>new Qe({typeName:b.ZodNull,..._(n)});class Me extends O{constructor(){super(...arguments),this._any=!0}_parse(e){return W(e.data)}}Me.create=n=>new Me({typeName:b.ZodAny,..._(n)});class we extends O{constructor(){super(...arguments),this._unknown=!0}_parse(e){return W(e.data)}}we.create=n=>new we({typeName:b.ZodUnknown,..._(n)});class ae extends O{_parse(e){const t=this._getOrReturnCtx(e);return m(t,{code:f.invalid_type,expected:g.never,received:t.parsedType}),x}}ae.create=n=>new ae({typeName:b.ZodNever,..._(n)});class Ot extends O{_parse(e){if(this._getType(e)!==g.undefined){const r=this._getOrReturnCtx(e);return m(r,{code:f.invalid_type,expected:g.void,received:r.parsedType}),x}return W(e.data)}}Ot.create=n=>new Ot({typeName:b.ZodVoid,..._(n)});class F extends O{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),s=this._def;if(t.parsedType!==g.array)return m(t,{code:f.invalid_type,expected:g.array,received:t.parsedType}),x;if(s.exactLength!==null){const a=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(a||o)&&(m(t,{code:a?f.too_big:f.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(m(t,{code:f.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(m(t,{code:f.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>s.type._parseAsync(new K(t,a,t.path,o)))).then(a=>P.mergeArray(r,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new K(t,a,t.path,o)));return P.mergeArray(r,i)}get element(){return this._def.type}min(e,t){return new F({...this._def,minLength:{value:e,message:v.toString(t)}})}max(e,t){return new F({...this._def,maxLength:{value:e,message:v.toString(t)}})}length(e,t){return new F({...this._def,exactLength:{value:e,message:v.toString(t)}})}nonempty(e){return this.min(1,e)}}F.create=(n,e)=>new F({type:n,minLength:null,maxLength:null,exactLength:null,typeName:b.ZodArray,..._(e)});function ke(n){if(n instanceof R){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=X.create(ke(r))}return new R({...n._def,shape:()=>e})}else return n instanceof F?new F({...n._def,type:ke(n.element)}):n instanceof X?X.create(ke(n.unwrap())):n instanceof pe?pe.create(ke(n.unwrap())):n instanceof Q?Q.create(n.items.map(e=>ke(e))):n}class R extends O{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=S.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==g.object){const l=this._getOrReturnCtx(e);return m(l,{code:f.invalid_type,expected:g.object,received:l.parsedType}),x}const{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof ae&&this._def.unknownKeys==="strip"))for(const l in s.data)a.includes(l)||o.push(l);const c=[];for(const l of a){const p=i[l],y=s.data[l];c.push({key:{status:"valid",value:l},value:p._parse(new K(s,y,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof ae){const l=this._def.unknownKeys;if(l==="passthrough")for(const p of o)c.push({key:{status:"valid",value:p},value:{status:"valid",value:s.data[p]}});else if(l==="strict")o.length>0&&(m(s,{code:f.unrecognized_keys,keys:o}),r.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const p of o){const y=s.data[p];c.push({key:{status:"valid",value:p},value:l._parse(new K(s,y,s.path,p)),alwaysSet:p in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const l=[];for(const p of c){const y=await p.key,j=await p.value;l.push({key:y,value:j,alwaysSet:p.alwaysSet})}return l}).then(l=>P.mergeObjectSync(r,l)):P.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return v.errToObj,new R({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var s,i,a,o;const c=(a=(i=(s=this._def).errorMap)===null||i===void 0?void 0:i.call(s,t,r).message)!==null&&a!==void 0?a:r.defaultError;return t.code==="unrecognized_keys"?{message:(o=v.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new R({...this._def,unknownKeys:"strip"})}passthrough(){return new R({...this._def,unknownKeys:"passthrough"})}extend(e){return new R({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new R({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:b.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new R({...this._def,catchall:e})}pick(e){const t={};return S.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new R({...this._def,shape:()=>t})}omit(e){const t={};return S.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new R({...this._def,shape:()=>t})}deepPartial(){return ke(this)}partial(e){const t={};return S.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];e&&!e[r]?t[r]=s:t[r]=s.optional()}),new R({...this._def,shape:()=>t})}required(e){const t={};return S.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof X;)i=i._def.innerType;t[r]=i}}),new R({...this._def,shape:()=>t})}keyof(){return Wn(S.objectKeys(this.shape))}}R.create=(n,e)=>new R({shape:()=>n,unknownKeys:"strip",catchall:ae.create(),typeName:b.ZodObject,..._(e)});R.strictCreate=(n,e)=>new R({shape:()=>n,unknownKeys:"strict",catchall:ae.create(),typeName:b.ZodObject,..._(e)});R.lazycreate=(n,e)=>new R({shape:n,unknownKeys:"strip",catchall:ae.create(),typeName:b.ZodObject,..._(e)});class et extends O{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function s(i){for(const o of i)if(o.result.status==="valid")return o.result;for(const o of i)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=i.map(o=>new z(o.ctx.common.issues));return m(t,{code:f.invalid_union,unionErrors:a}),x}if(t.common.async)return Promise.all(r.map(async i=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(s);{let i;const a=[];for(const c of r){const l={...t,common:{...t.common,issues:[]},parent:null},p=c._parseSync({data:t.data,path:t.path,parent:l});if(p.status==="valid")return p;p.status==="dirty"&&!i&&(i={result:p,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(c=>new z(c));return m(t,{code:f.invalid_union,unionErrors:o}),x}}get options(){return this._def.options}}et.create=(n,e)=>new et({options:n,typeName:b.ZodUnion,..._(e)});const ne=n=>n instanceof rt?ne(n.schema):n instanceof Y?ne(n.innerType()):n instanceof st?[n.value]:n instanceof fe?n.options:n instanceof it?S.objectValues(n.enum):n instanceof at?ne(n._def.innerType):n instanceof Ke?[void 0]:n instanceof Qe?[null]:n instanceof X?[void 0,...ne(n.unwrap())]:n instanceof pe?[null,...ne(n.unwrap())]:n instanceof en||n instanceof ut?ne(n.unwrap()):n instanceof ot?ne(n._def.innerType):[];class At extends O{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==g.object)return m(t,{code:f.invalid_type,expected:g.object,received:t.parsedType}),x;const r=this.discriminator,s=t.data[r],i=this.optionsMap.get(s);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(m(t,{code:f.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),x)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const s=new Map;for(const i of t){const a=ne(i.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,i)}}return new At({typeName:b.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,..._(r)})}}function zt(n,e){const t=se(n),r=se(e);if(n===e)return{valid:!0,data:n};if(t===g.object&&r===g.object){const s=S.objectKeys(e),i=S.objectKeys(n).filter(o=>s.indexOf(o)!==-1),a={...n,...e};for(const o of i){const c=zt(n[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===g.array&&r===g.array){if(n.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<n.length;i++){const a=n[i],o=e[i],c=zt(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===g.date&&r===g.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class tt extends O{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=(i,a)=>{if(Lt(i)||Lt(a))return x;const o=zt(i.value,a.value);return o.valid?((Wt(i)||Wt(a))&&t.dirty(),{status:t.value,value:o.data}):(m(r,{code:f.invalid_intersection_types}),x)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}tt.create=(n,e,t)=>new tt({left:n,right:e,typeName:b.ZodIntersection,..._(t)});class Q extends O{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.array)return m(r,{code:f.invalid_type,expected:g.array,received:r.parsedType}),x;if(r.data.length<this._def.items.length)return m(r,{code:f.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),x;!this._def.rest&&r.data.length>this._def.items.length&&(m(r,{code:f.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...r.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new K(r,a,r.path,o)):null}).filter(a=>!!a);return r.common.async?Promise.all(i).then(a=>P.mergeArray(t,a)):P.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new Q({...this._def,rest:e})}}Q.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Q({items:n,typeName:b.ZodTuple,rest:null,..._(e)})};class nt extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.object)return m(r,{code:f.invalid_type,expected:g.object,received:r.parsedType}),x;const s=[],i=this._def.keyType,a=this._def.valueType;for(const o in r.data)s.push({key:i._parse(new K(r,o,r.path,o)),value:a._parse(new K(r,r.data[o],r.path,o)),alwaysSet:o in r.data});return r.common.async?P.mergeObjectAsync(t,s):P.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof O?new nt({keyType:e,valueType:t,typeName:b.ZodRecord,..._(r)}):new nt({keyType:q.create(),valueType:e,typeName:b.ZodRecord,..._(t)})}}class St extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.map)return m(r,{code:f.invalid_type,expected:g.map,received:r.parsedType}),x;const s=this._def.keyType,i=this._def.valueType,a=[...r.data.entries()].map(([o,c],l)=>({key:s._parse(new K(r,o,r.path,[l,"key"])),value:i._parse(new K(r,c,r.path,[l,"value"]))}));if(r.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const l=await c.key,p=await c.value;if(l.status==="aborted"||p.status==="aborted")return x;(l.status==="dirty"||p.status==="dirty")&&t.dirty(),o.set(l.value,p.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const l=c.key,p=c.value;if(l.status==="aborted"||p.status==="aborted")return x;(l.status==="dirty"||p.status==="dirty")&&t.dirty(),o.set(l.value,p.value)}return{status:t.value,value:o}}}}St.create=(n,e,t)=>new St({valueType:e,keyType:n,typeName:b.ZodMap,..._(t)});class Se extends O{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.set)return m(r,{code:f.invalid_type,expected:g.set,received:r.parsedType}),x;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(m(r,{code:f.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(m(r,{code:f.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const i=this._def.valueType;function a(c){const l=new Set;for(const p of c){if(p.status==="aborted")return x;p.status==="dirty"&&t.dirty(),l.add(p.value)}return{status:t.value,value:l}}const o=[...r.data.values()].map((c,l)=>i._parse(new K(r,c,r.path,l)));return r.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new Se({...this._def,minSize:{value:e,message:v.toString(t)}})}max(e,t){return new Se({...this._def,maxSize:{value:e,message:v.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Se.create=(n,e)=>new Se({valueType:n,minSize:null,maxSize:null,typeName:b.ZodSet,..._(e)});class Ee extends O{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==g.function)return m(t,{code:f.invalid_type,expected:g.function,received:t.parsedType}),x;function r(o,c){return xt({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,bt(),$e].filter(l=>!!l),issueData:{code:f.invalid_arguments,argumentsError:c}})}function s(o,c){return xt({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,bt(),$e].filter(l=>!!l),issueData:{code:f.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof Re){const o=this;return W(async function(...c){const l=new z([]),p=await o._def.args.parseAsync(c,i).catch(U=>{throw l.addIssue(r(c,U)),l}),y=await Reflect.apply(a,this,p);return await o._def.returns._def.type.parseAsync(y,i).catch(U=>{throw l.addIssue(s(y,U)),l})})}else{const o=this;return W(function(...c){const l=o._def.args.safeParse(c,i);if(!l.success)throw new z([r(c,l.error)]);const p=Reflect.apply(a,this,l.data),y=o._def.returns.safeParse(p,i);if(!y.success)throw new z([s(p,y.error)]);return y.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ee({...this._def,args:Q.create(e).rest(we.create())})}returns(e){return new Ee({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new Ee({args:e||Q.create([]).rest(we.create()),returns:t||we.create(),typeName:b.ZodFunction,..._(r)})}}class rt extends O{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})}}rt.create=(n,e)=>new rt({getter:n,typeName:b.ZodLazy,..._(e)});class st extends O{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return m(t,{received:t.data,code:f.invalid_literal,expected:this._def.value}),x}return{status:"valid",value:e.data}}get value(){return this._def.value}}st.create=(n,e)=>new st({value:n,typeName:b.ZodLiteral,..._(e)});function Wn(n,e){return new fe({values:n,typeName:b.ZodEnum,..._(e)})}class fe extends O{constructor(){super(...arguments),Ze.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return m(t,{expected:S.joinValues(r),received:t.parsedType,code:f.invalid_type}),x}if(_t(this,Ze)||Un(this,Ze,new Set(this._def.values)),!_t(this,Ze).has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return m(t,{received:t.data,code:f.invalid_enum_value,options:r}),x}return W(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return fe.create(e,{...this._def,...t})}exclude(e,t=this._def){return fe.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}Ze=new WeakMap;fe.create=Wn;class it extends O{constructor(){super(...arguments),Be.set(this,void 0)}_parse(e){const t=S.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==g.string&&r.parsedType!==g.number){const s=S.objectValues(t);return m(r,{expected:S.joinValues(s),received:r.parsedType,code:f.invalid_type}),x}if(_t(this,Be)||Un(this,Be,new Set(S.getValidEnumValues(this._def.values))),!_t(this,Be).has(e.data)){const s=S.objectValues(t);return m(r,{received:r.data,code:f.invalid_enum_value,options:s}),x}return W(e.data)}get enum(){return this._def.values}}Be=new WeakMap;it.create=(n,e)=>new it({values:n,typeName:b.ZodNativeEnum,..._(e)});class Re extends O{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==g.promise&&t.common.async===!1)return m(t,{code:f.invalid_type,expected:g.promise,received:t.parsedType}),x;const r=t.parsedType===g.promise?t.data:Promise.resolve(t.data);return W(r.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Re.create=(n,e)=>new Re({type:n,typeName:b.ZodPromise,..._(e)});class Y extends O{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===b.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a=>{m(r,a),a.fatal?t.abort():t.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const a=s.transform(r.data,i);if(r.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return x;const c=await this._def.schema._parseAsync({data:o,path:r.path,parent:r});return c.status==="aborted"?x:c.status==="dirty"||t.value==="dirty"?Ae(c.value):c});{if(t.value==="aborted")return x;const o=this._def.schema._parseSync({data:a,path:r.path,parent:r});return o.status==="aborted"?x:o.status==="dirty"||t.value==="dirty"?Ae(o.value):o}}if(s.type==="refinement"){const a=o=>{const c=s.refinement(o,i);if(r.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(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?x:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?x:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Te(a))return a;const o=s.transform(a.value,i);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:r.data,path:r.path,parent:r}).then(a=>Te(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);S.assertNever(s)}}Y.create=(n,e,t)=>new Y({schema:n,typeName:b.ZodEffects,effect:e,..._(t)});Y.createWithPreprocess=(n,e,t)=>new Y({schema:e,effect:{type:"preprocess",transform:n},typeName:b.ZodEffects,..._(t)});class X extends O{_parse(e){return this._getType(e)===g.undefined?W(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}X.create=(n,e)=>new X({innerType:n,typeName:b.ZodOptional,..._(e)});class pe extends O{_parse(e){return this._getType(e)===g.null?W(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}pe.create=(n,e)=>new pe({innerType:n,typeName:b.ZodNullable,..._(e)});class at extends O{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===g.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}at.create=(n,e)=>new at({innerType:n,typeName:b.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._(e)});class ot extends O{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return He(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new z(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new z(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}ot.create=(n,e)=>new ot({innerType:n,typeName:b.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._(e)});class Nt extends O{_parse(e){if(this._getType(e)!==g.nan){const r=this._getOrReturnCtx(e);return m(r,{code:f.invalid_type,expected:g.nan,received:r.parsedType}),x}return{status:"valid",value:e.data}}}Nt.create=n=>new Nt({typeName:b.ZodNaN,..._(n)});const ls=Symbol("zod_brand");class en extends O{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class dt extends O{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?x:i.status==="dirty"?(t.dirty(),Ae(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?x:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,t){return new dt({in:e,out:t,typeName:b.ZodPipeline})}}class ut extends O{_parse(e){const t=this._def.innerType._parse(e),r=s=>(Te(s)&&(s.value=Object.freeze(s.value)),s);return He(t)?t.then(s=>r(s)):r(t)}unwrap(){return this._def.innerType}}ut.create=(n,e)=>new ut({innerType:n,typeName:b.ZodReadonly,..._(e)});function vn(n,e){const t=typeof n=="function"?n(e):typeof n=="string"?{message:n}:n;return typeof t=="string"?{message:t}:t}function zn(n,e={},t){return n?Me.create().superRefine((r,s)=>{var i,a;const o=n(r);if(o instanceof Promise)return o.then(c=>{var l,p;if(!c){const y=vn(e,r),j=(p=(l=y.fatal)!==null&&l!==void 0?l:t)!==null&&p!==void 0?p:!0;s.addIssue({code:"custom",...y,fatal:j})}});if(!o){const c=vn(e,r),l=(a=(i=c.fatal)!==null&&i!==void 0?i:t)!==null&&a!==void 0?a:!0;s.addIssue({code:"custom",...c,fatal:l})}}):Me.create()}const ds={object:R.lazycreate};var b;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(b||(b={}));const hs=(n,e={message:`Input not instance of ${n.name}`})=>zn(t=>t instanceof n,e),Vn=q.create,qn=de.create,fs=Nt.create,ps=he.create,Fn=Xe.create,ms=Oe.create,ys=Tt.create,gs=Ke.create,vs=Qe.create,ws=Me.create,bs=we.create,xs=ae.create,_s=Ot.create,Ts=F.create,Os=R.create,Ss=R.strictCreate,Ns=et.create,Is=At.create,ks=tt.create,As=Q.create,Es=nt.create,$s=St.create,Ms=Se.create,Rs=Ee.create,Cs=rt.create,js=st.create,Zs=fe.create,Bs=it.create,Us=Re.create,wn=Y.create,Ds=X.create,Ps=pe.create,Ls=Y.createWithPreprocess,Ws=dt.create,zs=()=>Vn().optional(),Vs=()=>qn().optional(),qs=()=>Fn().optional(),Fs={string:n=>q.create({...n,coerce:!0}),number:n=>de.create({...n,coerce:!0}),boolean:n=>Xe.create({...n,coerce:!0}),bigint:n=>he.create({...n,coerce:!0}),date:n=>Oe.create({...n,coerce:!0})},Ys=x;var u=Object.freeze({__proto__:null,defaultErrorMap:$e,setErrorMap:Lr,getErrorMap:bt,makeIssue:xt,EMPTY_PATH:Wr,addIssueToContext:m,ParseStatus:P,INVALID:x,DIRTY:Ae,OK:W,isAborted:Lt,isDirty:Wt,isValid:Te,isAsync:He,get util(){return S},get objectUtil(){return Pt},ZodParsedType:g,getParsedType:se,ZodType:O,datetimeRegex:Ln,ZodString:q,ZodNumber:de,ZodBigInt:he,ZodBoolean:Xe,ZodDate:Oe,ZodSymbol:Tt,ZodUndefined:Ke,ZodNull:Qe,ZodAny:Me,ZodUnknown:we,ZodNever:ae,ZodVoid:Ot,ZodArray:F,ZodObject:R,ZodUnion:et,ZodDiscriminatedUnion:At,ZodIntersection:tt,ZodTuple:Q,ZodRecord:nt,ZodMap:St,ZodSet:Se,ZodFunction:Ee,ZodLazy:rt,ZodLiteral:st,ZodEnum:fe,ZodNativeEnum:it,ZodPromise:Re,ZodEffects:Y,ZodTransformer:Y,ZodOptional:X,ZodNullable:pe,ZodDefault:at,ZodCatch:ot,ZodNaN:Nt,BRAND:ls,ZodBranded:en,ZodPipeline:dt,ZodReadonly:ut,custom:zn,Schema:O,ZodSchema:O,late:ds,get ZodFirstPartyTypeKind(){return b},coerce:Fs,any:ws,array:Ts,bigint:ps,boolean:Fn,date:ms,discriminatedUnion:Is,effect:wn,enum:Zs,function:Rs,instanceof:hs,intersection:ks,lazy:Cs,literal:js,map:$s,nan:fs,nativeEnum:Bs,never:xs,null:vs,nullable:Ps,number:qn,object:Os,oboolean:qs,onumber:Vs,optional:Ds,ostring:zs,pipeline:Ws,preprocess:Ls,promise:Us,record:Es,set:Ms,strictObject:Ss,string:Vn,symbol:ys,transformer:wn,tuple:As,undefined:gs,union:Ns,unknown:bs,void:_s,NEVER:Ys,ZodIssueCode:f,quotelessJson:Pr,ZodError:z});const Gs=n=>n!=null&&typeof n=="object"&&"toString"in n,Js=(n,e=!1)=>{const t=Gs(n)?"stringer":typeof n;let r;switch(t){case"string":r=(s,i)=>s.localeCompare(i);break;case"stringer":r=(s,i)=>s.toString().localeCompare(i.toString());break;case"number":r=(s,i)=>Number(s)-Number(i);break;case"bigint":r=(s,i)=>BigInt(s)-BigInt(i)>0n?1:-1;break;case"boolean":r=(s,i)=>Number(s)-Number(i);break;case"undefined":r=()=>0;break;default:return console.warn(`sortFunc: unknown type ${t}`),()=>-1}return e?Hs(r):r},Hs=n=>(e,t)=>n(t,e),Et=u.tuple([u.number(),u.number()]);u.tuple([u.bigint(),u.bigint()]);const tn=u.object({width:u.number(),height:u.number()}),Xs=u.object({signedWidth:u.number(),signedHeight:u.number()}),Ks=["width","height"];u.enum(Ks);const Qs=["start","center","end"],ei=["signedWidth","signedHeight"];u.enum(ei);const ct=u.object({x:u.number(),y:u.number()}),Yn=u.object({clientX:u.number(),clientY:u.number()}),Gn=["x","y"],Jn=u.enum(Gn),Hn=["top","right","bottom","left"];u.enum(Hn);const nn=["left","right"],Xn=u.enum(nn),rn=["top","bottom"],Kn=u.enum(rn),Qn=["center"],bn=u.enum(Qn),ti=[...Hn,...Qn],er=u.enum(ti);u.enum(Qs);const ni=["first","last"];u.enum(ni);const ri=u.object({lower:u.number(),upper:u.number()}),si=u.object({lower:u.bigint(),upper:u.bigint()});u.union([ri,Et]);u.union([si,Et]);u.enum([...Jn.options,...er.options]);u.union([Jn,er,u.instanceof(String)]);const ii=n=>typeof n=="bigint"||n instanceof BigInt,Ie=(n,e)=>ii(n)?n.valueOf()*BigInt(e.valueOf()):n.valueOf()*Number(e.valueOf()),be=(n,e)=>{const t={};if(typeof n=="number"||typeof n=="bigint")e!=null?(t.lower=n,t.upper=e):(t.lower=typeof n=="bigint"?0n:0,t.upper=n);else if(Array.isArray(n)){if(n.length!==2)throw new Error("bounds: expected array of length 2");[t.lower,t.upper]=n}else return xn(n);return xn(t)},xn=n=>n.lower>n.upper?{lower:n.upper,upper:n.lower}:n,_n=(n,e)=>{const t=be(n);return e<t.lower?t.lower:e>=t.upper?t.upper-(typeof t.upper=="number"?1:1n):e},sn=n=>Gn.includes(n)?n:rn.includes(n)?"y":"x";u.object({x:Xn.or(bn),y:Kn.or(bn)});const ai=u.object({x:Xn,y:Kn}),an=Object.freeze({x:"left",y:"top"}),oi=Object.freeze({x:"right",y:"top"}),tr=Object.freeze({x:"left",y:"bottom"}),ui=Object.freeze({x:"right",y:"bottom"}),nr=(n,e)=>n.x===e.x&&n.y===e.y,ci=n=>[n.x,n.y],Vt=u.union([u.number(),ct,Et,tn,Xs,Yn]),M=(n,e)=>{if(typeof n=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return n==="x"?{x:e,y:0}:{x:0,y:e}}return typeof n=="number"?{x:n,y:e??n}:Array.isArray(n)?{x:n[0],y:n[1]}:"signedWidth"in n?{x:n.signedWidth,y:n.signedHeight}:"clientX"in n?{x:n.clientX,y:n.clientY}:"width"in n?{x:n.width,y:n.height}:{x:n.x,y:n.y}},ee=Object.freeze({x:0,y:0}),rr=Object.freeze({x:1,y:1}),li=Object.freeze({x:1/0,y:1/0}),di=Object.freeze({x:NaN,y:NaN}),It=(n,e,t=0)=>{const r=M(n),s=M(e);return t===0?r.x===s.x&&r.y===s.y:Math.abs(r.x-s.x)<=t&&Math.abs(r.y-s.y)<=t},hi=n=>It(n,ee),on=(n,e,t)=>{const r=M(n),s=M(e,t);return{x:r.x*s.x,y:r.y*s.y}},sr=(n,e)=>{const t=M(n);return{x:t.x+e,y:t.y}},ir=(n,e)=>{const t=M(n);return{x:t.x,y:t.y+e}},lt=(n,e,t,...r)=>typeof e=="string"&&typeof t=="number"?e==="x"?sr(n,t):ir(n,t):[n,e,t??ee,...r].reduce((s,i)=>{const a=M(i);return{x:s.x+a.x,y:s.y+a.y}},ee),fi=(n,e,t)=>{const r=M(n);return e==="x"?{x:t,y:r.y}:{x:r.x,y:t}},pi=(n,e)=>{const t=M(n),r=M(e);return Math.sqrt((t.x-r.x)**2+(t.y-r.y)**2)},mi=(n,e)=>{const t=M(n),r=M(e);return{x:r.x-t.x,y:r.y-t.y}},yi=n=>{const e=M(n);return Number.isNaN(e.x)||Number.isNaN(e.y)},gi=n=>{const e=M(n);return Number.isFinite(e.x)&&Number.isFinite(e.y)},vi=n=>{const e=M(n);return[e.x,e.y]},wi=n=>{const e=M(n);return{left:e.x,top:e.y}},qt=(n,e=0)=>{const t=M(n);return{x:Number(t.x.toFixed(e)),y:Number(t.y.toFixed(e))}},Ue=(n,e)=>{const t=M(n),r=M(e);return{x:t.x-r.x,y:t.y-r.y}},De=n=>{const e=M(n),t=Math.hypot(e.x,e.y);return t===0?{x:0,y:0}:{x:-e.y/t,y:e.x/t}},ar=n=>{const e=M(n),t=Math.hypot(e.x,e.y);return t===0?{x:0,y:0}:{x:e.x/t,y:e.y/t}},or=(...n)=>{const e=n.reduce((t,r)=>lt(t,r),ee);return on(e,1/n.length)},bi=(n,e)=>{const t=[];for(let r=0;r<n.length;r++){const s=n[r];let i,a,o,c;if(r===0){const l=n[r+1],p=Ue(l,s);a=De(p),o=a,c=e}else if(r===n.length-1){const l=n[r-1],p=Ue(s,l);i=De(p),o=i,c=e}else{const l=n[r-1],p=n[r+1],y=Ue(s,l),j=Ue(p,s);i=De(y),a=De(j);const U=Math.acos((y.x*j.x+y.y*j.y)/(Math.hypot(y.x,y.y)*Math.hypot(j.x,j.y))),Ce=Math.sin(U/2);Ce===0?c=e:c=e/Ce,o=ar(or(i,a))}t.push(on(o,c))}return t},kt=Object.freeze(Object.defineProperty({__proto__:null,INFINITY:li,NAN:di,ONE:rr,ZERO:ee,average:or,calculateMiters:bi,clientXY:Yn,construct:M,couple:vi,crudeZ:Vt,css:wi,distance:pi,equals:It,isFinite:gi,isNan:yi,isZero:hi,normal:De,normalize:ar,scale:on,set:fi,sub:Ue,translate:lt,translateX:sr,translateY:ir,translation:mi,truncate:qt,xy:ct},Symbol.toStringTag,{value:"Module"})),ft=u.union([u.number(),u.string()]),xi=u.object({top:ft,left:ft,width:ft,height:ft}),_i=u.object({left:u.number(),top:u.number(),right:u.number(),bottom:u.number()}),Ti=u.object({one:ct,two:ct,root:ai}),ur={one:ee,two:ee,root:an},Oi={one:ee,two:rr,root:tr},cr=(n,e)=>({one:n.one,two:n.two,root:e??n.root}),$=(n,e,t=0,r=0,s)=>{const i={one:{...ee},two:{...ee},root:s??an};if(typeof n=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return i.one={x:n,y:e},i.two={x:i.one.x+t,y:i.one.y+r},i}return"one"in n&&"two"in n&&"root"in n?{...n,root:s??n.root}:("getBoundingClientRect"in n&&(n=n.getBoundingClientRect()),"left"in n?(i.one={x:n.left,y:n.top},i.two={x:n.right,y:n.bottom},i):(i.one=n,e==null?i.two={x:i.one.x+t,y:i.one.y+r}:typeof e=="number"?i.two={x:i.one.x+e,y:i.one.y+t}:"width"in e?i.two={x:i.one.x+e.width,y:i.one.y+e.height}:"signedWidth"in e?i.two={x:i.one.x+e.signedWidth,y:i.one.y+e.signedHeight}:i.two=e,i))},Si=(n,e,t)=>{const r=$(n);if(typeof e=="string"){if(t==null)throw new Error("Invalid arguments for resize");const s=sn(e);return $(r.one,void 0,s==="x"?t:me(r),s==="y"?t:ye(r),r.root)}return $(r.one,e,void 0,void 0,r.root)},Ni=(n,e,t=!0)=>{const r=$(n);let s=(i,a)=>i<a;return t&&(s=(i,a)=>i<=a),"one"in e?s(ce(r),ce(e))&&s(xe(e),xe(r))&&s(le(r),le(e))&&s(_e(e),_e(r)):s(ce(r),e.x)&&s(e.x,xe(r))&&s(le(r),e.y)&&s(e.y,_e(r))},Ii=(n,e)=>It(n.one,e.one)&&It(n.two,e.two)&&nr(n.root,e.root),lr=n=>({width:me(n),height:ye(n)}),ki=n=>({signedWidth:$t(n),signedHeight:Mt(n)}),Ai=n=>({top:le(n),left:ce(n),width:me(n),height:ye(n)}),un=(n,e,t=!1)=>{const r=sn(e)==="y"?Mt(n):$t(n);return t?r:Math.abs(r)},ht=(n,e)=>{const t=$(n);return{x:e.x==="center"?Ft(t).x:Ne(t,e.x),y:e.y==="center"?Ft(t).y:Ne(t,e.y)}},Ne=(n,e)=>{const t=$(n),r=ci(t.root).includes(e)?Math.min:Math.max;return nn.includes(e)?r(t.one.x,t.two.x):r(t.one.y,t.two.y)},Ei=n=>n.one.x===n.two.x&&n.one.y===n.two.y,me=n=>un(n,"x"),ye=n=>un(n,"y"),$t=n=>{const e=$(n);return e.two.x-e.one.x},Mt=n=>{const e=$(n);return e.two.y-e.one.y},dr=n=>ht(n,an),$i=n=>ht(n,oi),Mi=n=>ht(n,tr),Ri=n=>ht(n,ui),xe=n=>Ne(n,"right"),_e=n=>Ne(n,"bottom"),ce=n=>Ne(n,"left"),le=n=>Ne(n,"top"),Ft=n=>lt(dr(n),{x:$t(n)/2,y:Mt(n)/2}),cn=n=>{const e=$(n);return e.root.x==="left"?ce(e):xe(e)},ln=n=>{const e=$(n);return e.root.y==="top"?le(e):_e(e)},Ci=n=>({x:cn(n),y:ln(n)}),mt=n=>{const e=$(n);return{lower:e.one.x,upper:e.two.x}},yt=n=>{const e=$(n);return{lower:e.one.y,upper:e.two.y}},ji=(n,e)=>cr(n,e),Zi=(n,e)=>{const t=$(n),r=nn.includes(e)?"x":rn.includes(e)?"y":null;if(r===null)throw new Error(`Invalid location: ${e}`);const s=e==="top"||e==="left"?Math.min:Math.max,i={...t.one},a={...t.two};return i[r]=s(t.one[r],t.two[r]),a[r]=s(t.one[r],t.two[r]),[i,a]},Bi=(n,e)=>{const t=$(n),r=$(e),s=cn(r)+(me(r)-me(t))/2,i=ln(r)+(ye(r)-ye(t))/2;return $({x:s,y:i},lr(t))},hr=n=>typeof n!="object"||n==null?!1:"one"in n&&"two"in n&&"root"in n,Ui=n=>me(n)/ye(n),Di=(n,e,t)=>{if(typeof e=="string"){if(t==null)throw new Error("Undefined amount passed into box.translate");const s=sn(e);e=M(s,t)}const r=$(n);return $(lt(r.one,e),lt(r.two,e),void 0,void 0,r.root)},Pi=(n,e)=>{const t=Math.max(ce(n),ce(e)),r=Math.max(le(n),le(e)),s=Math.min(xe(n),xe(e)),i=Math.min(_e(n),_e(e));return t>s||r>i?ur:$({x:t,y:r},{x:s,y:i},void 0,void 0,n.root)},Li=n=>me(n)*ye(n),Wi=(n,e)=>{const t=$(n);return $(qt(t.one,e),qt(t.two,e),void 0,void 0,t.root)},zi=(n,e,t,r,s,i)=>{const a={x:n,y:e},o={x:n+t,y:e+r};return s.x!==i.x&&(s.x==="center"?(a.x-=t/2,o.x-=t/2):(a.x-=t,o.x-=t)),s.y!==i.y&&(s.y==="center"?(a.y-=r/2,o.y-=r/2):(a.y-=r,o.y-=r)),$(a,o,void 0,void 0,i)},Pe=Object.freeze(Object.defineProperty({__proto__:null,DECIMAL:Oi,ZERO:ur,area:Li,areaIsZero:Ei,aspect:Ui,bottom:_e,bottomLeft:Mi,bottomRight:Ri,box:Ti,center:Ft,construct:$,constructWithAlternateRoot:zi,contains:Ni,copy:cr,css:Ai,cssBox:xi,dim:un,dims:lr,domRect:_i,edgePoints:Zi,equals:Ii,height:ye,intersection:Pi,isBox:hr,left:ce,loc:Ne,positionInCenter:Bi,reRoot:ji,resize:Si,right:xe,root:Ci,signedDims:ki,signedHeight:Mt,signedWidth:$t,top:le,topLeft:dr,topRight:$i,translate:Di,truncate:Wi,width:me,x:cn,xBounds:mt,xyLoc:ht,y:ln,yBounds:yt},Symbol.toStringTag,{value:"Module"})),fr=u.object({signedWidth:u.number(),signedHeight:u.number()}),Vi=u.union([tn,fr,ct,Et]),qi={width:0,height:0},Fi={width:1,height:1},G=(n,e)=>typeof n=="number"?{width:n,height:e??n}:Array.isArray(n)?{width:n[0],height:n[1]}:"x"in n?{width:n.x,height:n.y}:"signedWidth"in n?{width:n.signedWidth,height:n.signedHeight}:{...n},Yi=(n,e)=>{if(e==null)return!1;const t=G(n),r=G(e);return t.width===r.width&&t.height===r.height},Gi=n=>{const e=G(n);return{width:e.height,height:e.width}},Ji=n=>{const e=G(n);return`0 0 ${e.width} ${e.height}`},Hi=n=>{const e=G(n);return[e.width,e.height]},Xi=n=>({width:Math.max(...n.map(e=>G(e).width)),height:Math.max(...n.map(e=>G(e).height))}),Ki=n=>({width:Math.min(...n.map(e=>G(e).width)),height:Math.min(...n.map(e=>G(e).height))}),Qi=(n,e)=>{const t=G(n);return{width:t.width*e,height:t.height*e}},gt=Object.freeze(Object.defineProperty({__proto__:null,DECIMAL:Fi,ZERO:qi,construct:G,couple:Hi,crude:Vi,dimensions:tn,equals:Yi,max:Xi,min:Ki,scale:Qi,signed:fr,svgViewBox:Ji,swap:Gi},Symbol.toStringTag,{value:"Module"}));var ea=Object.defineProperty,ta=(n,e,t)=>e in n?ea(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,ie=(n,e,t)=>ta(n,typeof e!="symbol"?e+"":e,t);const na=(n,e,t)=>e!==void 0&&n<e?e:t!==void 0&&n>t?t:n;u.object({offset:Vt,scale:Vt});u.object({offset:u.number(),scale:u.number()});const ra=n=>(e,t,r,s)=>t==="dimension"?[e,r]:[e,s?r-n:r+n],sa=n=>(e,t,r,s)=>[e,s?r/n:r*n],ia=n=>(e,t,r)=>{if(e===null)return[n,r];const{lower:s,upper:i}=e,{lower:a,upper:o}=n,c=i-s,l=o-a;if(t==="dimension")return[n,r*(l/c)];const p=(r-s)*(l/c)+a;return[n,p]},aa=n=>(e,t,r)=>[n,r],oa=()=>(n,e,t)=>{if(n===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[n,t];const{lower:r,upper:s}=n;return[n,s-(t-r)]},ua=n=>(e,t,r)=>{const{lower:s,upper:i}=n;return r=na(r,s,i),[e,r]},Yt=class Le{constructor(){ie(this,"ops",[]),ie(this,"currBounds",null),ie(this,"currType",null),ie(this,"reversed",!1),this.ops=[]}static translate(e){return new Le().translate(e)}static magnify(e){return new Le().magnify(e)}static scale(e,t){return new Le().scale(e,t)}translate(e){const t=this.new(),r=ra(e);return r.type="translate",t.ops.push(r),t}magnify(e){const t=this.new(),r=sa(e);return r.type="magnify",t.ops.push(r),t}scale(e,t){const r=be(e,t),s=this.new(),i=ia(r);return i.type="scale",s.ops.push(i),s}clamp(e,t){const r=be(e,t),s=this.new(),i=ua(r);return i.type="clamp",s.ops.push(i),s}reBound(e,t){const r=be(e,t),s=this.new(),i=aa(r);return i.type="re-bound",s.ops.push(i),s}invert(){const e=oa();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 Le;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([r,s],i)=>i(r,e,s,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((r,s)=>{if(r.type==="scale"||t.some(([a,o])=>s>=a&&s<=o))return;const i=e.ops.findIndex((a,o)=>a.type==="scale"&&o>s);i!==-1&&t.push([s,i])}),t.forEach(([r,s])=>{const i=e.ops.slice(r,s);i.unshift(e.ops[s]),e.ops.splice(r,s-r+1,...i)}),e.reversed=!e.reversed,e}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}};ie(Yt,"IDENTITY",new Yt);let Tn=Yt;const On=class re{constructor(e=new Tn,t=new Tn,r=null){ie(this,"x"),ie(this,"y"),ie(this,"currRoot"),this.x=e,this.y=t,this.currRoot=r}static translate(e,t){return new re().translate(e,t)}static translateX(e){return new re().translateX(e)}static translateY(e){return new re().translateY(e)}static clamp(e){return new re().clamp(e)}static magnify(e){return new re().magnify(e)}static scale(e){return new re().scale(e)}static reBound(e){return new re().reBound(e)}translate(e,t){const r=M(e,t),s=this.copy();return s.x=this.x.translate(r.x),s.y=this.y.translate(r.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(hr(e)){const r=this.currRoot;return t.currRoot=e.root,r!=null&&!nr(r,e.root)&&(r.x!==e.root.x&&(t.x=t.x.invert()),r.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(mt(e)),t.y=t.y.scale(yt(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(mt(e)),t.y=this.y.reBound(yt(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(mt(e)),t.y=this.y.clamp(yt(e)),t}copy(){const e=new re;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)}}dim(e){return{x:this.x.dim(e.x),y:this.y.dim(e.y)}}box(e){return $(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}get transform(){return{scale:this.dim({x:1,y:1}),offset:this.pos({x:0,y:0})}}};ie(On,"IDENTITY",new On);var ca=Object.defineProperty,la=(n,e,t)=>e in n?ca(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,h=(n,e,t)=>la(n,typeof e!="symbol"?e+"":e,t);let da=(n,e=21)=>(t=e)=>{let r="",s=t|0;for(;s--;)r+=n[Math.random()*n.length|0];return r};const ha="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",fa=da(ha,11),pr=()=>fa(),Gt=Object.freeze(Object.defineProperty({__proto__:null,create:pr},Symbol.toStringTag,{value:"Module"})),pa=u.enum(["static","dynamic"]),mr=(n,e)=>{const t=new E(e);if(![A.DAY,A.HOUR,A.MINUTE,A.SECOND,A.MILLISECOND,A.MICROSECOND,A.NANOSECOND].some(s=>s.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const r=n.valueOf()%t.valueOf();return n instanceof E?new E(r):new A(r)},I=class w{constructor(e,t="UTC"){if(h(this,"value"),h(this,"encodeValue",!0),e==null)this.value=w.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*w.MILLISECOND.valueOf();else if(typeof e=="string")this.value=w.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=w.parseDate(e);else{let r=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(r=w.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=w.MAX:e=w.MIN)),this.value=BigInt(e.valueOf())+r}}static parseDate([e=1970,t=1,r=1]){const s=new Date(e,t-1,r,0,0,0,0);return new w(BigInt(s.getTime())*w.MILLISECOND.valueOf()).truncate(w.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[r,s,i]=e.split(":");let a="00",o="00";i!=null&&([a,o]=i.split("."));let c=w.hours(parseInt(r??"00")).add(w.minutes(parseInt(s??"00"))).add(w.seconds(parseInt(a??"00"))).add(w.milliseconds(parseInt(o??"00")));return t==="local"&&(c=c.add(w.utcOffset)),c.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return w.parseTimeString(e,t);const r=new Date(e);return e.includes(":")||r.setUTCHours(0,0,0,0),new w(BigInt(r.getTime())*w.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();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,t)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(w.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const r=this.toISOString(t);return e?r.slice(11,23):r.slice(11,19)}dateString(){const e=this.date(),t=e.toLocaleString("default",{month:"short"}),r=e.toLocaleString("default",{day:"numeric"});return`${t} ${r}`}static get utcOffset(){return new A(BigInt(new Date().getTimezoneOffset())*w.MINUTE.valueOf())}static since(e){return new w().span(e)}date(){return new Date(this.milliseconds)}equals(e){return this.valueOf()===new w(e).valueOf()}span(e){return this.range(e).span}range(e){return new dn(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new w(e).valueOf()}afterEq(e){return this.valueOf()>=new w(e).valueOf()}before(e){return this.valueOf()<new w(e).valueOf()}beforeEq(e){return this.valueOf()<=new w(e).valueOf()}add(e){return new w(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new w(this.valueOf()-BigInt(e.valueOf()))}get hours(){return Number(this.valueOf())/Number(A.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(A.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(A.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(A.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(w.MILLISECOND.valueOf())}get year(){return this.date().getFullYear()}setYear(e){const t=this.date();return t.setFullYear(e),new w(t)}get month(){return this.date().getMonth()}setMonth(e){const t=this.date();return t.setMonth(e),new w(t)}get day(){return this.date().getDate()}setDay(e){const t=this.date();return t.setDate(e),new w(t)}get hour(){return this.date().getHours()}setHour(e){const t=this.date();return t.setHours(e),new w(t)}get minute(){return this.date().getMinutes()}setMinute(e){const t=this.date();return t.setMinutes(e),new w(t)}get second(){return this.date().getSeconds()}setSecond(e){const t=this.date();return t.setSeconds(e),new w(t)}get millisecond(){return this.date().getMilliseconds()}setMillisecond(e){const t=this.date();return t.setMilliseconds(e),new w(t)}toString(){return this.date().toISOString()}remainder(e){return mr(this,e)}get isToday(){return this.truncate(A.DAY).equals(w.now().truncate(A.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new w(new Date)}static max(...e){let t=w.MIN;for(const r of e){const s=new w(r);s.after(t)&&(t=s)}return t}static min(...e){let t=w.MAX;for(const r of e){const s=new w(r);s.before(t)&&(t=s)}return t}static nanoseconds(e){return new w(e)}static microseconds(e){return w.nanoseconds(e*1e3)}static milliseconds(e){return w.microseconds(e*1e3)}static seconds(e){return w.milliseconds(e*1e3)}static minutes(e){return w.seconds(e*60)}static hours(e){return w.minutes(e*60)}static days(e){return w.hours(e*24)}};h(I,"NANOSECOND",I.nanoseconds(1)),h(I,"MICROSECOND",I.microseconds(1)),h(I,"MILLISECOND",I.milliseconds(1)),h(I,"SECOND",I.seconds(1)),h(I,"MINUTE",I.minutes(1)),h(I,"HOUR",I.hours(1)),h(I,"DAY",I.days(1)),h(I,"MAX",new I((1n<<63n)-1n)),h(I,"MIN",new I(0)),h(I,"ZERO",new I(0)),h(I,"z",u.union([u.object({value:u.bigint()}).transform(n=>new I(n.value)),u.string().transform(n=>new I(BigInt(n))),u.instanceof(Number).transform(n=>new I(n)),u.number().transform(n=>new I(n)),u.instanceof(I)]));let E=I;const k=class T{constructor(e){h(this,"value"),h(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}static fromSeconds(e){return e instanceof T?e:e instanceof Sn?e.period:e instanceof E?new T(e):["number","bigint"].includes(typeof e)?T.seconds(e):new T(e)}static fromMilliseconds(e){return e instanceof T?e:e instanceof Sn?e.period:e instanceof E?new T(e):["number","bigint"].includes(typeof e)?T.milliseconds(e):new T(e)}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new T(e).valueOf()}greaterThan(e){return this.valueOf()>new T(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new T(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new T(e).valueOf()}remainder(e){return mr(this,e)}truncate(e){return new T(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(T.DAY),t=this.truncate(T.HOUR),r=this.truncate(T.MINUTE),s=this.truncate(T.SECOND),i=this.truncate(T.MILLISECOND),a=this.truncate(T.MICROSECOND),o=this.truncate(T.NANOSECOND),c=e,l=t.sub(e),p=r.sub(t),y=s.sub(r),j=i.sub(s),U=a.sub(i),Ce=o.sub(a);let oe="";return c.isZero||(oe+=`${c.days}d `),l.isZero||(oe+=`${l.hours}h `),p.isZero||(oe+=`${p.minutes}m `),y.isZero||(oe+=`${y.seconds}s `),j.isZero||(oe+=`${j.milliseconds}ms `),U.isZero||(oe+=`${U.microseconds}µs `),Ce.isZero||(oe+=`${Ce.nanoseconds}ns`),oe.trim()}mult(e){return new T(this.valueOf()*BigInt(e))}get days(){return Number(this.valueOf())/Number(T.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(T.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(T.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(T.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(T.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(T.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new T(e).valueOf()}add(e){return new T(this.valueOf()+new T(e).valueOf())}sub(e){return new T(this.valueOf()-new T(e).valueOf())}static nanoseconds(e=1){return new T(e)}static microseconds(e=1){return T.nanoseconds(Ie(e,1e3))}static milliseconds(e=1){return T.microseconds(Ie(e,1e3))}static seconds(e=1){return T.milliseconds(Ie(e,1e3))}static minutes(e=1){return T.seconds(Ie(e,60))}static hours(e){return T.minutes(Ie(e,60))}static days(e){return T.hours(Ie(e,24))}};h(k,"NANOSECOND",k.nanoseconds(1)),h(k,"MICROSECOND",k.microseconds(1)),h(k,"MILLISECOND",k.milliseconds(1)),h(k,"SECOND",k.seconds(1)),h(k,"MINUTE",k.minutes(1)),h(k,"HOUR",k.hours(1)),h(k,"DAY",k.days(1)),h(k,"MAX",new k((1n<<63n)-1n)),h(k,"MIN",new k(0)),h(k,"ZERO",new k(0)),h(k,"z",u.union([u.object({value:u.bigint()}).transform(n=>new k(n.value)),u.string().transform(n=>new k(BigInt(n))),u.instanceof(Number).transform(n=>new k(n)),u.number().transform(n=>new k(n)),u.instanceof(k)]));let A=k;const We=class vt extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new vt(e).valueOf()}get period(){return A.seconds(1/this.valueOf())}sampleCount(e){return new A(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new L(t).valueOf()}span(e){return A.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new vt(e)}static khz(e){return vt.hz(e*1e3)}};h(We,"z",u.union([u.number().transform(n=>new We(n)),u.instanceof(Number).transform(n=>new We(n)),u.instanceof(We)]));let Sn=We;const B=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new Jt(e*this.valueOf())}};h(B,"UNKNOWN",new B(0)),h(B,"BIT128",new B(16)),h(B,"BIT64",new B(8)),h(B,"BIT32",new B(4)),h(B,"BIT16",new B(2)),h(B,"BIT8",new B(1)),h(B,"z",u.union([u.number().transform(n=>new B(n)),u.instanceof(Number).transform(n=>new B(n)),u.instanceof(B)]));let L=B;const J=class wt{constructor(e,t){h(this,"start"),h(this,"end"),typeof e=="object"&&"start"in e?(this.start=new E(e.start),this.end=new E(e.end)):(this.start=new E(e),this.end=new E(t))}get span(){return new A(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}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new wt(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,t=A.ZERO){e=e.makeValid();const r=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(r.start)||r.end.equals(e.start))return!1;const s=E.max(r.start,e.start),i=E.min(r.end,e.end);return i.before(s)?!1:new A(i.sub(s)).greaterThanOrEqual(t)}roughlyEquals(e,t){let r=this.start.sub(e.start).valueOf(),s=this.end.sub(e.end).valueOf();return r<0&&(r=-r),s<0&&(s=-s),r<=t.valueOf()&&s<=t.valueOf()}contains(e){return e instanceof wt?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new wt(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}};h(J,"MAX",new J(E.MIN,E.MAX)),h(J,"MIN",new J(E.MAX,E.MIN)),h(J,"ZERO",new J(E.ZERO,E.ZERO)),h(J,"z",u.union([u.object({start:E.z,end:E.z}).transform(n=>new J(n.start,n.end)),u.instanceof(J)]));let dn=J;const d=class C extends String{constructor(e){if(e instanceof C||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}const t=C.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}throw super(C.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=C.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()}matches(...e){return e.some(t=>this.equals(t))}toString(){return this.valueOf()}get isVariable(){return this.equals(C.JSON)||this.equals(C.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(C.UUID)}get isInteger(){const e=this.toString();return e.startsWith("int")||e.startsWith("uint")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=C.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}get isUnsigned(){return this.equals(C.UINT8)||this.equals(C.UINT16)||this.equals(C.UINT32)||this.equals(C.UINT64)}get isSigned(){return this.equals(C.INT8)||this.equals(C.INT16)||this.equals(C.INT32)||this.equals(C.INT64)}canSafelyCastTo(e){return this.equals(e)?!0:!this.isNumeric||!e.isNumeric||this.isVariable||e.isVariable||this.isUnsigned&&e.isSigned?!1:this.isFloat?e.isFloat&&this.density.valueOf()<=e.density.valueOf():this.equals(C.INT32)&&e.equals(C.FLOAT64)||this.equals(C.INT8)&&e.equals(C.FLOAT32)?!0:this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf()&&this.isUnsigned===e.isUnsigned:!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return C.BIG_INT_TYPES.some(e=>e.equals(this))}};h(d,"UNKNOWN",new d("unknown")),h(d,"FLOAT64",new d("float64")),h(d,"FLOAT32",new d("float32")),h(d,"INT64",new d("int64")),h(d,"INT32",new d("int32")),h(d,"INT16",new d("int16")),h(d,"INT8",new d("int8")),h(d,"UINT64",new d("uint64")),h(d,"UINT32",new d("uint32")),h(d,"UINT16",new d("uint16")),h(d,"UINT8",new d("uint8")),h(d,"BOOLEAN",d.UINT8),h(d,"TIMESTAMP",new d("timestamp")),h(d,"UUID",new d("uuid")),h(d,"STRING",new d("string")),h(d,"JSON",new d("json")),h(d,"ARRAY_CONSTRUCTORS",new Map([[d.UINT8.toString(),Uint8Array],[d.UINT16.toString(),Uint16Array],[d.UINT32.toString(),Uint32Array],[d.UINT64.toString(),BigUint64Array],[d.FLOAT32.toString(),Float32Array],[d.FLOAT64.toString(),Float64Array],[d.INT8.toString(),Int8Array],[d.INT16.toString(),Int16Array],[d.INT32.toString(),Int32Array],[d.INT64.toString(),BigInt64Array],[d.TIMESTAMP.toString(),BigInt64Array],[d.STRING.toString(),Uint8Array],[d.JSON.toString(),Uint8Array],[d.UUID.toString(),Uint8Array]])),h(d,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,d.UINT8],[Uint16Array.name,d.UINT16],[Uint32Array.name,d.UINT32],[BigUint64Array.name,d.UINT64],[Float32Array.name,d.FLOAT32],[Float64Array.name,d.FLOAT64],[Int8Array.name,d.INT8],[Int16Array.name,d.INT16],[Int32Array.name,d.INT32],[BigInt64Array.name,d.INT64]])),h(d,"DENSITIES",new Map([[d.UINT8.toString(),L.BIT8],[d.UINT16.toString(),L.BIT16],[d.UINT32.toString(),L.BIT32],[d.UINT64.toString(),L.BIT64],[d.FLOAT32.toString(),L.BIT32],[d.FLOAT64.toString(),L.BIT64],[d.INT8.toString(),L.BIT8],[d.INT16.toString(),L.BIT16],[d.INT32.toString(),L.BIT32],[d.INT64.toString(),L.BIT64],[d.TIMESTAMP.toString(),L.BIT64],[d.STRING.toString(),L.UNKNOWN],[d.JSON.toString(),L.UNKNOWN],[d.UUID.toString(),L.BIT128]])),h(d,"ALL",[d.UNKNOWN,d.FLOAT64,d.FLOAT32,d.INT64,d.INT32,d.INT16,d.INT8,d.UINT64,d.UINT32,d.UINT16,d.UINT8,d.TIMESTAMP,d.UUID,d.STRING,d.JSON]),h(d,"BIG_INT_TYPES",[d.INT64,d.UINT64,d.TIMESTAMP]),h(d,"z",u.union([u.string().transform(n=>new d(n)),u.instanceof(d)]));let N=d;const D=class Z extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return Z.bytes(this.valueOf()+e.valueOf())}sub(e){return Z.bytes(this.valueOf()-e.valueOf())}truncate(e){return new Z(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return Z.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/Z.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/Z.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/Z.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/Z.TERABYTE.valueOf()}toString(){const e=this.truncate(Z.TERABYTE),t=this.truncate(Z.GIGABYTE),r=this.truncate(Z.MEGABYTE),s=this.truncate(Z.KILOBYTE),i=this.truncate(Z.BYTE),a=e,o=t.sub(e),c=r.sub(t),l=s.sub(r),p=i.sub(s);let y="";return a.isZero||(y+=`${a.terabytes}TB `),o.isZero||(y+=`${o.gigabytes}GB `),c.isZero||(y+=`${c.megabytes}MB `),l.isZero||(y+=`${l.kilobytes}KB `),(!p.isZero||y==="")&&(y+=`${p.valueOf()}B`),y.trim()}static bytes(e=1){return new Z(e)}static kilobytes(e=1){return Z.bytes(e.valueOf()*1e3)}static megabytes(e=1){return Z.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return Z.megabytes(e.valueOf()*1e3)}static terabytes(e){return Z.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};h(D,"BYTE",new D(1)),h(D,"KILOBYTE",D.kilobytes(1)),h(D,"MEGABYTE",D.megabytes(1)),h(D,"GIGABYTE",D.gigabytes(1)),h(D,"TERABYTE",D.terabytes(1)),h(D,"ZERO",new D(0)),h(D,"z",u.union([u.number().transform(n=>new D(n)),u.instanceof(D)]));let Jt=D;u.union([u.instanceof(Uint8Array),u.instanceof(Uint16Array),u.instanceof(Uint32Array),u.instanceof(BigUint64Array),u.instanceof(Float32Array),u.instanceof(Float64Array),u.instanceof(Int8Array),u.instanceof(Int16Array),u.instanceof(Int32Array),u.instanceof(BigInt64Array)]);const yr=n=>{const e=typeof n;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||n instanceof E||n instanceof A||n instanceof Date},ma=(n,e,t,r=0)=>n.usesBigInt&&!e.usesBigInt?Number(t)-Number(r):!n.usesBigInt&&e.usesBigInt?BigInt(t.valueOf())-BigInt(r.valueOf()):ze(t,-r).valueOf(),ze=(n,e)=>typeof n=="bigint"&&typeof e=="bigint"||typeof n=="number"&&typeof e=="number"?n+e:e===0?n:n===0?e:Number(n)+Number(e),ya=n=>n==null?!1:Array.isArray(n)||n instanceof ArrayBuffer||ArrayBuffer.isView(n)&&!(n instanceof DataView)||n instanceof wa?!0:yr(n),ue=-1,ga=u.string().transform(n=>new Uint8Array(atob(n).split("").map(e=>e.charCodeAt(0))).buffer),va=u.union([u.null(),u.undefined()]).transform(()=>new Uint8Array().buffer),Ht=10,Ve=class H{constructor(e){h(this,"key",""),h(this,"isSynnaxSeries",!0),h(this,"dataType"),h(this,"sampleOffset"),h(this,"gl"),h(this,"_data"),h(this,"_timeRange"),h(this,"alignment",0n),h(this,"_cachedMin"),h(this,"_cachedMax"),h(this,"writePos",ue),h(this,"_refCount",0),h(this,"_cachedLength"),h(this,"_cachedIndexes"),ya(e)&&(e={data:e});const{dataType:t,timeRange:r,sampleOffset:s=0,glBufferUsage:i="static",alignment:a=0n,key:o=pr()}=e,c=e.data??[];if(c instanceof H||typeof c=="object"&&"isSynnaxSeries"in c&&c.isSynnaxSeries===!0){const y=c;this.key=y.key,this.dataType=y.dataType,this.sampleOffset=y.sampleOffset,this.gl=y.gl,this._data=y._data,this._timeRange=y._timeRange,this.alignment=y.alignment,this._cachedMin=y._cachedMin,this._cachedMax=y._cachedMax,this.writePos=y.writePos,this._refCount=y._refCount,this._cachedLength=y._cachedLength;return}const l=yr(c),p=Array.isArray(c);if(t!=null)this.dataType=new N(t);else{if(c instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(p||l){let y=c;if(!l){if(c.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");y=c[0]}if(typeof y=="string")this.dataType=N.STRING;else if(typeof y=="number")this.dataType=N.FLOAT64;else if(typeof y=="bigint")this.dataType=N.INT64;else if(typeof y=="boolean")this.dataType=N.BOOLEAN;else if(y instanceof E||y instanceof Date||y instanceof E)this.dataType=N.TIMESTAMP;else if(typeof y=="object")this.dataType=N.JSON;else throw new Error(`cannot infer data type of ${typeof y} when constructing a Series from a JS array`)}else this.dataType=new N(c)}if(!p&&!l)this._data=c;else{let y=l?[c]:c;const j=y[0];(j instanceof E||j instanceof Date||j instanceof A)&&(y=y.map(U=>new E(U).valueOf())),this.dataType.equals(N.STRING)?(this._cachedLength=y.length,this._data=new TextEncoder().encode(`${y.join(`
4
- `)}
5
- `).buffer):this.dataType.equals(N.JSON)?(this._cachedLength=y.length,this._data=new TextEncoder().encode(`${y.map(U=>pt.encodeString(U)).join(`
6
- `)}
7
- `).buffer):this.dataType.usesBigInt&&typeof j=="number"?this._data=new this.dataType.Array(y.map(U=>BigInt(Math.round(U)))).buffer:!this.dataType.usesBigInt&&typeof j=="bigint"?this._data=new this.dataType.Array(y.map(U=>Number(U))).buffer:this._data=new this.dataType.Array(y).buffer}this.key=o,this.alignment=a,this.sampleOffset=s??0,this._timeRange=r,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:i}}static alloc({capacity:e,dataType:t,...r}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const s=new new N(t).Array(e),i=new H({data:s.buffer,dataType:t,...r});return i.writePos=0,i}static createTimestamps(e,t,r){const s=r.spanRange(t.span(e)),i=new BigInt64Array(e);for(let a=0;a<e;a++)i[a]=BigInt(r.add(t.span(a)).valueOf());return new H({data:i,dataType:N.TIMESTAMP,timeRange:s})}get refCount(){return this._refCount}static fromStrings(e,t){const r=new TextEncoder().encode(`${e.join(`
8
- `)}
9
- `);return new H({data:r,dataType:N.STRING,timeRange:t})}static fromJSON(e,t){const r=new TextEncoder().encode(`${e.map(s=>pt.encodeString(s)).join(`
10
- `)}
11
- `);return new H({data:r,dataType:N.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");return this.dataType.isVariable?this.writeVariable(e):this.writeFixed(e)}writeVariable(e){if(this.writePos===ue)return 0;const t=this.byteCapacity.valueOf()-this.writePos,r=e.subBytes(0,t);return this.writeToUnderlyingData(r),this.writePos+=r.byteLength.valueOf(),this._cachedLength!=null&&(this._cachedLength+=r.length,this.calculateCachedLength()),r.length}writeFixed(e){if(this.writePos===ue)return 0;const t=this.capacity-this.writePos,r=e.sub(0,t);return this.writeToUnderlyingData(r),this._cachedLength=void 0,this.maybeRecomputeMinMax(r),this.writePos+=r.length,r.length}writeToUnderlyingData(e){this.underlyingData.set(e.data,this.writePos)}get buffer(){return typeof this._data=="object"&&"buffer"in this._data?this._data.buffer:this._data}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===ue?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.matches(N.STRING,N.UUID))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.underlyingData).split(`
12
- `).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(N.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=N.UUID.density.valueOf(),t=Array(this.length);for(let r=0;r<this.length;r++){const s=this.underlyingData.slice(r*e,(r+1)*e),i=Array.from(new Uint8Array(s.buffer),a=>a.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");t[r]=i}return t}parseJSON(e){if(!this.dataType.equals(N.JSON))throw new Error("cannot parse non-JSON series as JSON");return new TextDecoder().decode(this.underlyingData).split(`
13
- `).slice(0,-1).map(t=>e.parse(pt.decodeString(t)))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new Jt(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===ue?this.byteCapacity:this.dataType.isVariable?new Jt(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===ue?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;const t=[0];return this.data.forEach((r,s)=>{r===Ht&&(e++,t.push(s+1))}),this._cachedIndexes=t,this._cachedLength=e,e}convert(e,t=0){if(this.dataType.equals(e))return this;const r=new e.Array(this.length);for(let s=0;s<this.length;s++)r[s]=ma(this.dataType,e,this.data[s],t);return new H({data:r.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(N.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((t,r)=>t>r?t:r)}else{const e=this.data;this._cachedMax=e.reduce((t,r)=>t>r?t:r)}return this._cachedMax}get max(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this._cachedMax??(this._cachedMax=this.calcRawMax()),ze(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(N.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((t,r)=>t<r?t:r)}else{const e=this.data;this._cachedMin=e.reduce((t,r)=>t<r?t:r)}return this._cachedMin}get min(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this._cachedMin??(this._cachedMin=this.calcRawMin()),ze(this._cachedMin,this.sampleOffset))}get bounds(){return be(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const t=e._cachedMin??e.calcRawMin();t<this._cachedMin&&(this._cachedMin=t)}if(this._cachedMax!=null){const t=e._cachedMax??e.calcRawMax();t>this._cachedMax&&(this._cachedMax=t)}}enrich(){this.max,this.min}get range(){return ze(this.max,-this.min)}atAlignment(e,t){const r=Number(e-this.alignment);if(r<0||r>=this.length){if(t===!0)throw new Error(`[series] - no value at index ${r}`);return}return this.at(r,t)}at(e,t){if(this.dataType.isVariable)return this.atVariable(e,t??!1);e<0&&(e=this.length+e);const r=this.data[e];if(r==null){if(t===!0)throw new Error(`[series] - no value at index ${e}`);return}return ze(r,this.sampleOffset)}atVariable(e,t){let r=0,s=0;if(this._cachedIndexes!=null)r=this._cachedIndexes[e],s=this._cachedIndexes[e+1]-1;else{e<0&&(e=this.length+e);for(let a=0;a<this.data.length;a++)if(this.data[a]===Ht){if(e===0){s=a;break}r=a+1,e--}if(s===0&&(s=this.data.length),r>=s||e>0){if(t)throw new Error(`[series] - no value at index ${e}`);return}}const i=this.data.slice(r,s);return this.dataType.equals(N.STRING)?new TextDecoder().decode(i):Zn(JSON.parse(new TextDecoder().decode(i)))}binarySearch(e){let t=0,r=this.length-1;const s=Js(e);for(;t<=r;){const i=Math.floor((t+r)/2),a=s(this.at(i,!0),e);if(a===0)return i;a<0?t=i+1:r=i-1}return t}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(N.FLOAT32)&&!this.dataType.equals(N.UINT8))throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");const{buffer:t,bufferUsage:r,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!==ue){s===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const i=this.dataType.density.size(s).valueOf(),a=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,i,a.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,r==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=ue}as(e){if(e==="string"){if(!this.dataType.equals(N.STRING))throw new Error(`cannot convert series of type ${this.dataType.toString()} to string`);return this}if(e==="number"){if(!this.dataType.isNumeric)throw new Error(`cannot convert series of type ${this.dataType.toString()} to number`);return this}if(e==="bigint"){if(!this.dataType.equals(N.INT64))throw new Error(`cannot convert series of type ${this.dataType.toString()} to bigint`);return this}throw new Error(`cannot convert series to ${e}`)}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:$n(this.alignmentBounds.lower),upper:$n(this.alignmentBounds.upper)},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 be(this.alignment,this.alignment+BigInt(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}[Symbol.iterator](){if(this.dataType.isVariable){const e=new ba(this);return this.dataType.equals(N.JSON)?new xa(e):e}return new _a(this)}slice(e,t){return this.sliceSub(!1,e,t)}sub(e,t){return this.sliceSub(!0,e,t)}subIterator(e,t){return new Nn(this,e,t??this.length)}subAlignmentIterator(e,t){return new Nn(this,Number(e-this.alignment),Number(t-this.alignment))}subBytes(e,t){if(e>=0&&(t==null||t>=this.byteLength.valueOf()))return this;const r=this.data.subarray(e,t);return new H({data:r,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}sliceSub(e,t,r){if(t<=0&&(r==null||r>=this.length))return this;let s;return e?s=this.data.subarray(t,r):s=this.data.slice(t,r),new H({data:s,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(t)})}reAlign(e){return new H({data:this.buffer,dataType:this.dataType,timeRange:dn.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}};h(Ve,"crudeZ",u.object({timeRange:dn.z.optional(),dataType:N.z,alignment:u.coerce.bigint().optional(),data:u.union([ga,va,u.instanceof(ArrayBuffer),u.instanceof(Uint8Array)]),glBufferUsage:pa.optional().default("static").optional()})),h(Ve,"z",Ve.crudeZ.transform(n=>new Ve(n)));let wa=Ve;class Nn{constructor(e,t,r){h(this,"series"),h(this,"end"),h(this,"index"),this.series=e;const s=be(0,e.length);this.end=_n(s,r),this.index=_n(s,t)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}}class ba{constructor(e){if(h(this,"series"),h(this,"index"),h(this,"decoder"),!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,t=this.series.data;for(;this.index<t.length&&t[this.index]!==Ht;)this.index++;const r=this.index;return e===r?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,r))})}[Symbol.iterator](){return this}}var In,kn;class xa{constructor(e){h(this,"wrapped"),h(this,In,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:pt.decodeString(e.value)}}[(kn=Symbol.iterator,In=Symbol.toStringTag,kn)](){return this}}var An,En;class _a{constructor(e){h(this,"series"),h(this,"index"),h(this,An,"SeriesIterator"),this.series=e,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[(En=Symbol.iterator,An=Symbol.toStringTag,En)](){return this}}const $n=n=>{const e=n>>32n,t=n&0xffffffffn;return{domain:e,sample:t}},Ta=(n,e,t=".")=>{const r=n.split(t);return r.map((s,i)=>{const a=e(s,i,r);return a==null?null:typeof a=="string"?a:a.join(t)}).filter(s=>s!=null).join(t)},gr=(n,e,t={optional:!1,separator:"."})=>{t.separator??(t.separator=".");const{optional:r,getter:s=(o,c)=>o[c]}=t,i=e.split(t.separator);if(i.length===1&&i[0]==="")return n;let a=n;for(const o of i){const c=s(a,o);if(c==null){if(r)return null;throw new Error(`Path ${e} does not exist. ${o} is null`)}a=c}return a},Oa=(n,e,t)=>{const r=e.split(".");let s=n;for(let i=0;i<r.length-1;i++){const a=r[i];s[a]??(s[a]={}),s=s[a]}try{s[r[r.length-1]]=t}catch(i){throw console.error("failed to set value",t,"at path",e,"on object",n),i}},Sa=(n,e)=>{const t=e.split(".");let r=n;for(let s=0;s<t.length-1;s++){const i=t[s];if(r[i]==null)return;r=r[i]}if(Array.isArray(r)){const s=parseInt(t[t.length-1]);if(isNaN(s))return;r.splice(s,1);return}delete r[t[t.length-1]]},Na=(n,e)=>{const t=n.split(".");return e<0?t[t.length+e]:t[e]},Ia=(n,e)=>{try{return gr(n,e),!0}catch{return!1}},ka=(n,e)=>{if(e.length===0)return!0;const t=n.split("."),r=e.split(".");if(r.length>t.length)return!1;for(let s=0;s<r.length;s++){const i=t[s],a=r[s];if(a!=="*"&&i!==a)return!1}return!0},Aa=n=>JSON.parse(JSON.stringify(n)),Ea=(n,...e)=>(e.forEach(t=>{let r=n;const s=t.split(".");s.forEach((i,a)=>{a===s.length-1?delete r[i]:i in r&&(r=r[i])})}),n),$a=(n,e,t="")=>{const r={},s=(i,a,o)=>{if(typeof i!=typeof a||i===null||a===null){r[o]=[i,a];return}if(typeof i=="object"&&typeof a=="object")if(Array.isArray(i)&&Array.isArray(a)){if(i.length!==a.length){r[o]=[i,a];return}for(let c=0;c<i.length;c++)s(i[c],a[c],`${o}[${c}]`)}else new Set([...Object.keys(i),...Object.keys(a)]).forEach(c=>{s(i[c],a[c],o!==""?`${o}.${c}`:c)});else i!==a&&(r[o]=[i,a])};return s(n,e,t),r},Xt=(n,e)=>{const t=Array.isArray(n),r=Array.isArray(e);if(t!==r)return!1;if(t&&r){const a=n,o=e;if(a.length!==o.length)return!1;for(let c=0;c<a.length;c++)if(!Xt(a[c],o[c]))return!1;return!0}if(n==null||e==null||typeof n!="object"||typeof e!="object")return n===e;if("equals"in n)return n.equals(e);const s=Object.keys(n),i=Object.keys(e);if(s.length!==i.length)return!1;for(const a of s){const o=n[a],c=e[a];if(typeof o=="object"&&typeof c=="object"){if(!Xt(o,c))return!1}else if(o!==c)return!1}return!0},vr=(n,e)=>{if(typeof n!="object"||n==null)return n===e;const t=Object.keys(n),r=Object.keys(e);if(r.length>t.length)return!1;for(const s of r){const i=n[s],a=e[s];if(typeof i=="object"&&typeof a=="object"){if(!vr(i,a))return!1}else if(i!==a)return!1}return!0},Kt=(n,...e)=>{if(e.length===0)return n;const t=e.shift();if(Ge(n)&&Ge(t))for(const r in t)try{Ge(t[r])?(r in n||Object.assign(n,{[r]:{}}),Kt(n[r],t[r])):Object.assign(n,{[r]:t[r]})}catch(s){throw s instanceof TypeError?new TypeError(`.${r}: ${s.message}`):s}return Kt(n,...e)},Ma=(n,e,t)=>{const r=(s,i,a)=>{for(const o in i){const c=i[o],l=wr(a);if(l!=null&&l[o]){const p=l[o].safeParse(c);p.success&&(s[o]=p.data)}else typeof c=="object"&&!Array.isArray(c)&&c!==null&&a&&a.shape&&a.shape[o]&&(s[o]||(s[o]={}),r(s[o],c,a.shape[o]))}return s};return r({...n},e,t)},wr=n=>{var e;return((e=n._def)==null?void 0:e.typeName)==="ZodEffects"?wr(n._def.schema):n==null?void 0:n.shape},hn=Object.freeze(Object.defineProperty({__proto__:null,copy:Aa,deleteD:Ea,difference:$a,element:Na,equal:Xt,get:gr,has:Ia,override:Kt,overrideValidItems:Ma,partialEqual:vr,pathsMatch:ka,remove:Sa,set:Oa,transformPath:Ta},Symbol.toStringTag,{value:"Module"}));u.object({key:u.string(),value:u.string()});u.record(u.union([u.number(),u.string(),u.symbol()]),u.unknown());const br=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",Ra=br(),xr=["macOS","Windows","Linux"],Ca=["macos","windows","linux"],ja={macos:"macOS",windows:"Windows",linux:"Linux"},Za=u.enum(xr).or(u.enum(Ca).transform(n=>ja[n])),Ba=()=>{if(typeof window>"u")return;const n=window.navigator.userAgent.toLowerCase();if(n.includes("mac"))return"macOS";if(n.includes("win"))return"Windows";if(n.includes("linux"))return"Linux"};let Bt;const Ua=(n={})=>{const{force:e,default:t}=n;return e??Bt??(Bt=Ba(),Bt??t)},Da=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:xr,RUNTIME:Ra,detect:br,getOS:Ua,osZ:Za},Symbol.toStringTag,{value:"Module"}));var Pa=Object.defineProperty,La=(n,e,t)=>e in n?Pa(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,qe=(n,e,t)=>La(n,typeof e!="symbol"?e+"":e,t);const Wa=(...n)=>n.map(_r).join(""),_r=n=>(n.endsWith("/")||(n+="/"),n.startsWith("/")&&(n=n.slice(1)),n),za=n=>n.endsWith("/")?n.slice(0,-1):n,Mn=class Qt{constructor({host:e,port:t,protocol:r="",pathPrefix:s=""}){qe(this,"protocol"),qe(this,"host"),qe(this,"port"),qe(this,"path"),this.protocol=r,this.host=e,this.port=t,this.path=_r(s)}replace(e){return new Qt({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new Qt({...this,pathPrefix:Wa(this.path,e)})}toString(){return za(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};qe(Mn,"UNKNOWN",new Mn({host:"unknown",port:0}));const Va=-128,qa=127;u.number().int().min(Va).max(qa);const Fa=-32768,Ya=32767;u.number().int().min(Fa).max(Ya);const Ga=-2147483648,Ja=2147483647;u.number().int().min(Ga).max(Ja);const Ha=-9223372036854775808n,Xa=9223372036854775807n;u.bigint().min(Ha).max(Xa);const Ka=255;u.number().int().min(0).max(Ka);const Qa=65535;u.number().int().min(0).max(Qa);const eo=4294967295;u.number().int().min(0).max(eo);const to=18446744073709551615n;u.bigint().min(0n).max(to);var no=Object.defineProperty,ro=(n,e,t)=>e in n?no(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Fe=(n,e,t)=>ro(n,typeof e!="symbol"?e+"":e,t);u.object({interval:A.z.optional(),maxRetries:u.number().optional(),scale:u.number().optional()});const te=class extends Number{};Fe(te,"ABSOLUTE",255),Fe(te,"MINIMUM",0),Fe(te,"BOUNDS",{lower:te.MINIMUM,upper:te.ABSOLUTE+1}),Fe(te,"z",u.union([u.instanceof(te),u.number().int().min(0).max(255).transform(n=>new te(n)),u.instanceof(Number).transform(n=>new te(n))]));u.object({name:u.string(),key:u.string()});const Tr=class Ye extends Error{constructor(){super(Ye.MESSAGE)}matches(e){return typeof e=="string"?e.includes(Ye.MESSAGE):e instanceof Ye||e.message.includes(Ye.MESSAGE)}};Fe(Tr,"MESSAGE","canceled");let so=Tr;new so;u.string().regex(/^\d+\.\d+\.\d+$/);const ve="main",fn="prerender",Rt={stage:"creating",processCount:0,reserved:!1,focusCount:0,centerCount:0},Or={...Rt,key:fn,visible:!1},io=u.object({key:u.string(),url:u.string().optional(),title:u.string().optional(),center:u.boolean().optional(),position:kt.xy.optional(),size:gt.dimensions.optional(),minSize:gt.dimensions.optional(),maxSize:gt.dimensions.optional(),resizable:u.boolean().optional(),fullscreen:u.boolean().optional(),focus:u.boolean().optional(),maximized:u.boolean().optional(),visible:u.boolean().optional(),minimized:u.boolean().optional(),decorations:u.boolean().optional(),skipTaskbar:u.boolean().optional(),fileDropEnabled:u.boolean().optional(),transparent:u.boolean().optional(),alwaysOnTop:u.boolean().optional()}),ao=A.milliseconds(50),Sr=()=>setTimeout(()=>window.location.reload(),ao.milliseconds),Nr={label:ve,config:{enablePrerender:!0,debug:!1,defaultWindowProps:{}},windows:{main:{...Rt,key:ve,reserved:!0}},labelKeys:{main:ve},keyLabels:{main:ve}},oo=(n,e)=>{if(n.type===kr.type)return e.label!==ve||(n.payload.label=Gt.create(),n.payload.prerenderLabel=Gt.create()),n;if("label"in n.payload)return n;let t=e.label;const r=n.payload;return r.key!=null&&(r.key in e.windows?t=r.key:t=e.keyLabels[r.key]),n.payload={...n.payload,label:t},n},V=n=>(e,t)=>{if(!("label"in t.payload))throw new Error("Missing label");n(e,t)},ge=(n,e=!1)=>V((t,r)=>{let s=e;const i=t.windows[r.payload.label];if(i!=null){if(r.payload.value!=null)s=r.payload.value;else{const a=i[n];a!=null&&(s=!a)}t.windows[r.payload.label]={...i,[n]:s}}}),Ct=(n,e=!1)=>(t,r)=>{const s=t.windows[r.payload.label];s!=null&&(t.windows[r.payload.label]={...s,[n]:s[n]+(e?-1:1)})},uo=n=>Object.values(n.windows).some(e=>e.key===fn&&!e.reserved),pn="drift",co=(n,e,t)=>n.position!=null&&n.size!=null&&e==null?Pe.topLeft(Pe.positionInCenter(Pe.construct(kt.ZERO,t??kt.ZERO),Pe.construct(n.position,n.size))):e,lo=(n,{payload:e})=>{if(e.key===fn)return;const{key:t,label:r,prerenderLabel:s}=e;if(r==null||s==null)throw new Error("[drift] - bug - missing label and prerender label");console.log(n.config.debug),Cn(n.config.debug,"reducer create window");const i=n.windows.main;if(e.position=co(i,e.position,e.size),t in n.keyLabels){je(n.config.debug,"window already exists, un-minimize and focus it");const c=n.keyLabels[e.key];n.windows[c].visible=!0,n.windows[c].focusCount+=1,n.windows[c].minimized=!1,n.windows[c].position=e.position,Ut(n.config.debug);return}const[a,o]=Object.entries(n.windows).find(([,c])=>!c.reserved)??[null,null];a!=null?(je(n.config.debug,"using available pre-rendered window"),n.windows[a]={...o,visible:!0,reserved:!0,focusCount:1,focus:!0,...e},n.labelKeys[a]=e.key,n.keyLabels[e.key]=a):(je(n.config.debug,"creating new window"),n.windows[r]={...n.config.defaultWindowProps,...Rt,...e,reserved:!0},n.labelKeys[r]=t,n.keyLabels[t]=r),n.config.enablePrerender&&!uo(n)&&(je(n.config.debug,"creating pre-render window"),n.windows[s]=hn.copy({...n.config.defaultWindowProps,...Or})),Ut(n.config.debug)},ho=V((n,e)=>{const t=n.windows[e.payload.label];t!=null&&(t.stage=e.payload.stage)}),fo=V((n,{payload:{label:e}})=>{const t=n.windows[e];t==null||t.processCount>0||(t.stage="closing",delete n.windows[e],delete n.labelKeys[e],delete n.keyLabels[t.key])}),po=V((n,e)=>{const t=n.windows[e.payload.label];t==null||t.processCount>0||(t.stage="reloading",Sr())}),mo=V(Ct("processCount")),yo=V((n,e)=>{Ct("processCount",!0)(n,e);const t=n.windows[e.payload.label];t!=null&&t.processCount===0&&(t.stage==="reloading"?Sr():(n.windows[e.payload.label].visible=!1,delete n.windows[e.payload.label],delete n.labelKeys[e.payload.label],delete n.keyLabels[t.key]))}),go=(n,e)=>{const t=n.windows[e.payload.key];t!=null&&(t.error=e.payload.message)},vo=V((n,e)=>{const t=n.windows[e.payload.label];t!=null&&(t.visible!==!0&&(t.visible=!0),Ct("focusCount")(n,e))}),wo=ge("minimized"),bo=ge("maximized"),xo=ge("visible",!0),_o=ge("fullscreen",!0),To=V(Ct("centerCount")),Oo=V((n,e)=>{n.windows[e.payload.label].position=e.payload.position}),So=V((n,e)=>{n.windows[e.payload.label].size=e.payload.size}),No=V((n,e)=>{n.windows[e.payload.label].minSize=e.payload.size}),Io=V((n,e)=>{n.windows[e.payload.label].maxSize=e.payload.size}),ko=ge("resizable"),Ao=ge("skipTaskbar"),Eo=ge("alwaysOnTop"),$o=V((n,e)=>{n.windows[e.payload.label].title=e.payload.title}),Mo=ge("decorations"),Rn=(n,e)=>{const t=n.windows[e.payload.label];hn.partialEqual(t,e.payload)||(n.windows[e.payload.label]={...t,...e.payload})},Ro=(n,e)=>{if(n.config={...n.config,...e.payload},n.label=e.payload.label,n.label===ve&&n.config.enablePrerender){const t=Gt.create();n.windows[t]={...n.config.defaultWindowProps,...Or}}},Ir=Er.createSlice({name:pn,initialState:Nr,reducers:{internalSetInitial:Ro,createWindow:lo,setWindowStage:ho,closeWindow:fo,registerProcess:mo,completeProcess:yo,setWindowError:go,focusWindow:vo,reloadWindow:po,setWindowMinimized:wo,setWindowMaximized:bo,setWindowVisible:xo,setWindowFullscreen:_o,centerWindow:To,setWindowPosition:Oo,setWindowSize:So,setWindowMinSize:No,setWindowMaxSize:Io,setWindowResizable:ko,setWindowSkipTaskbar:Ao,setWindowAlwaysOnTop:Eo,setWindowTitle:$o,setWindowDecorations:Mo,runtimeSetWindowProps:Rn,setWindowProps:Rn}}),{actions:{runtimeSetWindowProps:Co,setWindowProps:jo,createWindow:kr,internalSetInitial:Ar,setWindowStage:Zo,closeWindow:Bo,registerProcess:Uo,completeProcess:Do,setWindowError:Po,focusWindow:Lo,reloadWindow:Wo,setWindowMinimized:zo,setWindowMaximized:Vo,setWindowVisible:qo,setWindowFullscreen:Fo,centerWindow:du,setWindowPosition:Yo,setWindowSize:Go,setWindowMinSize:Jo,setWindowMaxSize:Ho,setWindowResizable:Xo,setWindowSkipTaskbar:Ko,setWindowAlwaysOnTop:Qo,setWindowTitle:eu,setWindowDecorations:tu}}=Ir,nu=Ir.reducer,ru=n=>n.startsWith(pn),su=[Ar.type],iu=(n,e)=>!n&&!su.includes(e);exports.G=kt;exports.I=hn;exports.INITIAL_WINDOW_STATE=Rt;exports.MAIN_WINDOW=ve;exports.Mo=Pe;exports.S=Da;exports.SLICE_NAME=pn;exports.ZERO_SLICE_STATE=Nr;exports._=gt;exports.assignLabel=oo;exports.closeWindow=Bo;exports.completeProcess=Do;exports.createWindow=kr;exports.focusWindow=Lo;exports.group=Cn;exports.groupEnd=Ut;exports.internalSetInitial=Ar;exports.isDriftAction=ru;exports.log=je;exports.reducer=nu;exports.registerProcess=Uo;exports.reloadWindow=Wo;exports.runtimeSetWindowProps=Co;exports.setWindowAlwaysOnTop=Qo;exports.setWindowDecorations=tu;exports.setWindowError=Po;exports.setWindowFullscreen=Fo;exports.setWindowMaxSize=Ho;exports.setWindowMaximized=Vo;exports.setWindowMinSize=Jo;exports.setWindowMinimized=zo;exports.setWindowPosition=Yo;exports.setWindowProps=jo;exports.setWindowResizable=Xo;exports.setWindowSize=Go;exports.setWindowSkipTaskbar=Ko;exports.setWindowStage=Zo;exports.setWindowTitle=eu;exports.setWindowVisible=qo;exports.shouldEmit=iu;exports.windowPropsZ=io;exports.y=A;