@synnaxlabs/x 0.54.0 → 0.54.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +7 -7
- package/dist/src/binary/codec.d.ts.map +1 -1
- package/dist/src/color/color.d.ts +1 -1
- package/dist/src/color/palette.d.ts +2 -2
- package/dist/src/deep/atKeys.d.ts +27 -0
- package/dist/src/deep/atKeys.d.ts.map +1 -0
- package/dist/src/deep/atKeys.spec.d.ts +2 -0
- package/dist/src/deep/atKeys.spec.d.ts.map +1 -0
- package/dist/src/deep/external.d.ts +1 -0
- package/dist/src/deep/external.d.ts.map +1 -1
- package/dist/src/fmt/external.d.ts +3 -0
- package/dist/src/fmt/external.d.ts.map +1 -0
- package/dist/src/fmt/index.d.ts +2 -0
- package/dist/src/fmt/index.d.ts.map +1 -0
- package/dist/src/fmt/path.d.ts +13 -0
- package/dist/src/fmt/path.d.ts.map +1 -0
- package/dist/src/fmt/path.spec.d.ts +2 -0
- package/dist/src/fmt/path.spec.d.ts.map +1 -0
- package/dist/src/fmt/value.d.ts +23 -0
- package/dist/src/fmt/value.d.ts.map +1 -0
- package/dist/src/fmt/value.spec.d.ts +2 -0
- package/dist/src/fmt/value.spec.d.ts.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/label/types.gen.d.ts +2 -2
- package/dist/src/narrow/narrow.d.ts +9 -0
- package/dist/src/narrow/narrow.d.ts.map +1 -1
- package/dist/src/primitive/primitive.d.ts +10 -0
- package/dist/src/primitive/primitive.d.ts.map +1 -1
- package/dist/src/status/status.d.ts +14 -2
- package/dist/src/status/status.d.ts.map +1 -1
- package/dist/src/status/types.gen.d.ts +1 -1
- package/dist/src/telem/series.d.ts +4 -4
- package/dist/src/telem/telem.d.ts +10 -10
- package/dist/src/zod/external.d.ts +1 -0
- package/dist/src/zod/external.d.ts.map +1 -1
- package/dist/src/zod/parse.d.ts +47 -0
- package/dist/src/zod/parse.d.ts.map +1 -0
- package/dist/src/zod/parse.spec.d.ts +2 -0
- package/dist/src/zod/parse.spec.d.ts.map +1 -0
- package/dist/x.cjs +16 -7
- package/dist/x.js +2190 -1869
- package/package.json +3 -3
- package/src/binary/codec.ts +3 -2
- package/src/deep/atKeys.spec.ts +107 -0
- package/src/deep/atKeys.ts +49 -0
- package/src/deep/external.ts +1 -0
- package/src/fmt/external.ts +11 -0
- package/src/fmt/index.ts +10 -0
- package/src/fmt/path.spec.ts +46 -0
- package/src/fmt/path.ts +30 -0
- package/src/fmt/value.spec.ts +206 -0
- package/src/fmt/value.ts +83 -0
- package/src/index.ts +1 -0
- package/src/narrow/narrow.spec.ts +43 -0
- package/src/narrow/narrow.ts +15 -0
- package/src/primitive/primitive.spec.ts +51 -0
- package/src/primitive/primitive.ts +12 -0
- package/src/status/status.spec.ts +152 -0
- package/src/status/status.ts +67 -19
- package/src/zod/external.ts +1 -0
- package/src/zod/parse.spec.ts +702 -0
- package/src/zod/parse.ts +519 -0
- package/tsconfig.tsbuildinfo +1 -1
package/dist/x.cjs
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let l=require(`zod`);l=c(l);var u=e=>l.default.union([l.default.union([l.default.null(),l.default.undefined()]).transform(()=>[]),e.array()]),d=e=>Array.isArray(e)?e:e==null?[]:[e],f=(e,t)=>{if(Array.isArray(t))return t.reduce((e,t)=>f(e,t),e??[]);if(e==null)return[t];let n=e.findIndex(e=>e==t),r=[...e];return n===-1?r.push(t):r[n]=t,r},p=((e,t)=>{if(e!=null)return Array.isArray(t)?e.filter(e=>!t.includes(e)):e.filter(e=>e!=t)}),m=(e,t)=>{if(Array.isArray(t))return t.reduce((e,t)=>m(e,t),e??[]);if(e==null)return[t];let n=e.findIndex(e=>e.key===t.key),r=[...e];return n===-1?r.push(t):r[n]=t,r},ee=((e,t)=>{if(e!=null)return Array.isArray(t)?e.filter(e=>!t.includes(e.key)):e.filter(e=>e.key!==t)}),h=o({nullishToEmpty:()=>u,remove:()=>p,removeKeyed:()=>ee,toArray:()=>d,upsert:()=>f,upsertKeyed:()=>m}),te=o({camelToSnake:()=>ue,capitalize:()=>de,preserveCase:()=>re,snakeToCamel:()=>le,toKebab:()=>he,toProperNoun:()=>ge}),ne=`synnax.caseconv.preserveCase`,re=e=>(e[ne]=!0,e),ie=e=>{if(typeof e!=`object`||!e)return!1;if(ne in e)return!0;let t=e._zod?.def;return t==null?!1:t.innerType&&ie(t.innerType)?!0:t.type===`union`&&Array.isArray(t.options)?t.options.some(ie):t.type===`pipe`?ie(t.in)||ie(t.out):!1},ae=e=>{if(e==null)return;let t=e._zod?.def;if(t?.type===`array`&&t.element!=null)return t.element;if(t?.type===`union`&&Array.isArray(t.options))for(let e of t.options){let t=ae(e);if(t!=null)return t}},oe=e=>{if(e==null)return null;let t=e;if(t.shape!=null)return t.shape;if(typeof t.sourceType==`function`){let e=t.sourceType();if(e?.shape!=null)return e.shape}let n=t._zod?.def;if(n==null)return null;if(n.innerType!=null)return oe(n.innerType);if(n.type===`union`&&Array.isArray(n.options))for(let e of n.options){let t=oe(e);if(t!=null)return t}return n.type===`pipe`?oe(n.in)??oe(n.out):null},se=e=>{if(e.length===0)return e;let t=e.indexOf(`_`)===-1?e:e.replace(/_[a-z]/g,e=>e[1].toUpperCase()),n=t.charCodeAt(0);return n<65||n>90||t.length>1&&t.charCodeAt(1)>=65&&t.charCodeAt(1)<=90?t:String.fromCharCode(n+32)+t.slice(1)},ce=e=>{let t=(n,r=fe)=>{if(typeof n==`string`)return e(n);if(Array.isArray(n)){let e=ae(r.schema),i={recursive:r.recursive,recursiveInArray:r.recursiveInArray,schema:e};return n.map(e=>t(e,i))}if(!pe(n)||r.schema!=null&&ie(r.schema))return n;let i=r.recursive??!0,a=r.recursiveInArray??i,o=r.schema,s={},c=n;if(`toJSON`in c&&typeof c.toJSON==`function`)return t(c.toJSON(),r);let l=oe(o),u={recursive:i,recursiveInArray:a,schema:void 0},d=Object.keys(c);for(let n=0;n<d.length;n++){let r=d[n],o=c[r],f=e(r),p=l==null?void 0:l[r]??l[f]??void 0;i&&(pe(o)?me(o)||(u.schema=p,o=t(o,u)):a&&Array.isArray(o)&&(u.schema=ae(p),o=o.map(e=>{if(pe(e)){if(!me(e))return t(e,u)}else if(Array.isArray(e))return t({key:e},u).key;return e}))),s[f]=o}return s};return t},le=ce(se),ue=ce(e=>e.replace(/([a-z0-9])([A-Z])/g,(e,t,n)=>`${t}_${n.toLowerCase()}`)),de=e=>e.length===0?e:e[0].toUpperCase()+e.slice(1),fe={recursive:!0,recursiveInArray:!0,schema:void 0},pe=e=>typeof e==`object`&&!!e&&!Array.isArray(e),me=e=>e instanceof Uint8Array||e instanceof Number||e instanceof String,he=ce(e=>e.replace(/[\s_]+/g,`-`).replace(/([a-z0-9])([A-Z])/g,(e,t,n)=>`${t}-${n.toLowerCase()}`).toLowerCase()),ge=ce(e=>{if(e.length===0)return e;let t=e.replace(/[_-]/g,` `);return t=t.replace(/([a-z0-9])([A-Z])/g,(e,t,n)=>`${t} ${n}`),t=t.replace(/([A-Z]+)([A-Z][a-z])/g,(e,t,n)=>`${t} ${n}`),t=t.replace(/\s+/g,` `).trim(),t=t.replace(/\b\w/g,e=>e.toUpperCase()),t}),_e=o({isObject:()=>g}),g=e=>typeof e==`object`&&!!e&&!Array.isArray(e),ve=o({CSVCodec:()=>be,CSV_CODEC:()=>Ce,ENCODERS:()=>Te,JSONCodec:()=>ye,JSON_CODEC:()=>Se,TEXT_CODEC:()=>we,TextCodec:()=>xe}),ye=class{contentType=`application/json`;decoder;encoder;constructor(){this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(e,t){return this.encoder.encode(this.encodeString(e,t))}decode(e,t){return this.decodeString(this.decoder.decode(e),t)}decodeString(e,t){let n=le(JSON.parse(e),{schema:t});return t==null?n:t.parse(n)}encodeString(e,t){let n=ue((t==null?e:t.parse(e))??{},{schema:t});return JSON.stringify(n,(e,t)=>ArrayBuffer.isView(t)?Array.from(t):typeof t==`bigint`?t.toString():t)}},be=class{contentType=`text/csv`;encode(e){let t=this.encodeString(e);return new TextEncoder().encode(t)}decode(e,t){let n=new TextDecoder().decode(e);return this.decodeString(n,t)}encodeString(e){if(!Array.isArray(e)||e.length===0||!g(e[0]))throw Error(`Payload must be an array of objects`);let t=Object.keys(e[0]),n=[t.join(`,`)];return e.forEach(e=>{let r=t.map(t=>JSON.stringify(e[t]??``));n.push(r.join(`,`))}),n.join(`
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let l=require(`zod`);l=c(l);var u=e=>l.default.union([l.default.union([l.default.null(),l.default.undefined()]).transform(()=>[]),e.array()]),d=e=>Array.isArray(e)?e:e==null?[]:[e],f=(e,t)=>{if(Array.isArray(t))return t.reduce((e,t)=>f(e,t),e??[]);if(e==null)return[t];let n=e.findIndex(e=>e==t),r=[...e];return n===-1?r.push(t):r[n]=t,r},p=((e,t)=>{if(e!=null)return Array.isArray(t)?e.filter(e=>!t.includes(e)):e.filter(e=>e!=t)}),m=(e,t)=>{if(Array.isArray(t))return t.reduce((e,t)=>m(e,t),e??[]);if(e==null)return[t];let n=e.findIndex(e=>e.key===t.key),r=[...e];return n===-1?r.push(t):r[n]=t,r},ee=((e,t)=>{if(e!=null)return Array.isArray(t)?e.filter(e=>!t.includes(e.key)):e.filter(e=>e.key!==t)}),h=o({nullishToEmpty:()=>u,remove:()=>p,removeKeyed:()=>ee,toArray:()=>d,upsert:()=>f,upsertKeyed:()=>m}),te=o({camelToSnake:()=>ue,capitalize:()=>de,preserveCase:()=>re,snakeToCamel:()=>le,toKebab:()=>he,toProperNoun:()=>ge}),ne=`synnax.caseconv.preserveCase`,re=e=>(e[ne]=!0,e),ie=e=>{if(typeof e!=`object`||!e)return!1;if(ne in e)return!0;let t=e._zod?.def;return t==null?!1:t.innerType&&ie(t.innerType)?!0:t.type===`union`&&Array.isArray(t.options)?t.options.some(ie):t.type===`pipe`?ie(t.in)||ie(t.out):!1},ae=e=>{if(e==null)return;let t=e._zod?.def;if(t?.type===`array`&&t.element!=null)return t.element;if(t?.type===`union`&&Array.isArray(t.options))for(let e of t.options){let t=ae(e);if(t!=null)return t}},oe=e=>{if(e==null)return null;let t=e;if(t.shape!=null)return t.shape;if(typeof t.sourceType==`function`){let e=t.sourceType();if(e?.shape!=null)return e.shape}let n=t._zod?.def;if(n==null)return null;if(n.innerType!=null)return oe(n.innerType);if(n.type===`union`&&Array.isArray(n.options))for(let e of n.options){let t=oe(e);if(t!=null)return t}return n.type===`pipe`?oe(n.in)??oe(n.out):null},se=e=>{if(e.length===0)return e;let t=e.indexOf(`_`)===-1?e:e.replace(/_[a-z]/g,e=>e[1].toUpperCase()),n=t.charCodeAt(0);return n<65||n>90||t.length>1&&t.charCodeAt(1)>=65&&t.charCodeAt(1)<=90?t:String.fromCharCode(n+32)+t.slice(1)},ce=e=>{let t=(n,r=fe)=>{if(typeof n==`string`)return e(n);if(Array.isArray(n)){let e=ae(r.schema),i={recursive:r.recursive,recursiveInArray:r.recursiveInArray,schema:e};return n.map(e=>t(e,i))}if(!pe(n)||r.schema!=null&&ie(r.schema))return n;let i=r.recursive??!0,a=r.recursiveInArray??i,o=r.schema,s={},c=n;if(`toJSON`in c&&typeof c.toJSON==`function`)return t(c.toJSON(),r);let l=oe(o),u={recursive:i,recursiveInArray:a,schema:void 0},d=Object.keys(c);for(let n=0;n<d.length;n++){let r=d[n],o=c[r],f=e(r),p=l==null?void 0:l[r]??l[f]??void 0;i&&(pe(o)?me(o)||(u.schema=p,o=t(o,u)):a&&Array.isArray(o)&&(u.schema=ae(p),o=o.map(e=>{if(pe(e)){if(!me(e))return t(e,u)}else if(Array.isArray(e))return t({key:e},u).key;return e}))),s[f]=o}return s};return t},le=ce(se),ue=ce(e=>e.replace(/([a-z0-9])([A-Z])/g,(e,t,n)=>`${t}_${n.toLowerCase()}`)),de=e=>e.length===0?e:e[0].toUpperCase()+e.slice(1),fe={recursive:!0,recursiveInArray:!0,schema:void 0},pe=e=>typeof e==`object`&&!!e&&!Array.isArray(e),me=e=>e instanceof Uint8Array||e instanceof Number||e instanceof String,he=ce(e=>e.replace(/[\s_]+/g,`-`).replace(/([a-z0-9])([A-Z])/g,(e,t,n)=>`${t}-${n.toLowerCase()}`).toLowerCase()),ge=ce(e=>{if(e.length===0)return e;let t=e.replace(/[_-]/g,` `);return t=t.replace(/([a-z0-9])([A-Z])/g,(e,t,n)=>`${t} ${n}`),t=t.replace(/([A-Z]+)([A-Z][a-z])/g,(e,t,n)=>`${t} ${n}`),t=t.replace(/\s+/g,` `).trim(),t=t.replace(/\b\w/g,e=>e.toUpperCase()),t}),_e=o({isObject:()=>g,isPlainObject:()=>ve}),g=e=>typeof e==`object`&&!!e&&!Array.isArray(e),ve=e=>{if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},ye=e=>e.nullable().transform(e=>e===null?void 0:e).optional(),be=(e,t)=>{let n=e;for(let e of t){if(typeof n!=`object`||!n)return{present:!1,value:void 0};let t=n;if(!(e in t))return{present:!1,value:void 0};n=t[e]}return{present:!0,value:n}},xe=e=>{try{return structuredClone(e)}catch{return console.warn(`Failed to deep copy object, falling back to JSON.parse(JSON.stringify)`,e),console.trace(),JSON.parse(JSON.stringify(e))}},Se=(e,t,n=``)=>{let r={},i=(e,t,n)=>{if(typeof e!=typeof t||e===null||t===null){r[n]=[e,t];return}if(typeof e==`object`&&typeof t==`object`)if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length){r[n]=[e,t];return}for(let r=0;r<e.length;r++)i(e[r],t[r],`${n}[${r}]`)}else new Set([...Object.keys(e),...Object.keys(t)]).forEach(r=>{i(e[r],t[r],n===``?r:`${n}.${r}`)});else e!==t&&(r[n]=[e,t])};return i(e,t,n),r},Ce=(e,t)=>{let n=Array.isArray(e),r=Array.isArray(t);if(n!==r)return!1;if(n&&r){let n=e,r=t;if(n.length!==r.length)return!1;for(let e=0;e<n.length;e++)if(!Ce(n[e],r[e]))return!1;return!0}if(e==null||t==null||typeof e!=`object`||typeof t!=`object`)return e===t;if(`equals`in e)return e.equals(t);let i=Object.keys(e),a=Object.keys(t);if(i.length!==a.length)return!1;for(let n of i){let r=e[n],i=t[n];if(typeof r==`object`&&typeof i==`object`){if(!Ce(r,i))return!1}else if(r!==i)return!1}return!0},we=(e,t)=>{if(typeof e!=`object`||!e)return e===t;let n=Object.keys(e),r=Object.keys(t);if(r.length>n.length)return!1;for(let n of r){let r=e[n],i=t[n];if(typeof r==`object`&&typeof i==`object`){if(!we(r,i))return!1}else if(r!==i)return!1}return!0},Te=(e,t,n=`.`)=>{let r=e.split(n);return r.map((e,i)=>{let a=t(e,i,r);return a==null?null:typeof a==`string`?a:a.join(n)}).filter(e=>e!=null).join(n)},_=(e,t)=>{if(!Array.isArray(e))return e[t];let n=e[t];if(n!=null||e.length==0)return n;let r=e[0];if(typeof r==`object`&&`key`in r)return e.find(e=>e.key===t)},Ee=(e,t)=>{let n=e.split(`.`);return n.forEach((e,r)=>{t=_(t,e),typeof t==`object`&&t&&`key`in t&&(n[r]=t.key)}),n.join(`.`)},De=(e,t)=>{let n=e.split(`.`);return t<0?n[n.length+t]:n[t]},Oe=(e,t)=>{if(t.length===0)return!0;let n=e.split(`.`),r=t.split(`.`);if(r.length>n.length)return!1;for(let e=0;e<r.length;e++){let t=n[e],i=r[e];if(i!==`*`&&t!==i)return!1}return!0},v=e=>{let t=parseInt(e,10);return isNaN(t)||t<0||t.toString()!==e?null:t},ke=(e,t)=>{for(let n=1;n<=t.length;n++){let r=t.slice(0,n).join(`.`);if(_(e,r)!=null)return[r,n]}return null},Ae=((e,t,n={optional:!1})=>{let{optional:r,getter:i=_}=n;if(t===``)return e;let a=t.split(`.`);if(a.length===1){let n=i(e,a[0]);if(n===void 0){if(r)return null;throw Error(`Path ${t} does not exist. ${a[0]} is undefined`)}return n}let o=(e,n)=>{if(n>=a.length)return e;for(let s=a.length-n;s>=1;s--){let c=a.slice(n,n+s).join(`.`),l=i(e,c);if(l!==void 0){if(n+s===a.length)return l;if(l===null){if(r)return null;throw Error(`Path ${t} does not exist. ${c} is null`)}return o(l,n+s)}}if(r)return null;throw Error(`Path ${t} does not exist. ${a[n]} is undefined`)};return o(e,0)}),je=(e,t)=>Ae(e,t,{optional:!0})!==null,Me=(e,...t)=>{if(t.length===0)return e;let n=t.shift();if(g(e)&&g(n))for(let t in n)try{g(n[t])?(t in e||Object.assign(e,{[t]:{}}),Me(e[t],n[t])):Object.assign(e,{[t]:n[t]})}catch(e){throw e instanceof TypeError?TypeError(`.${t}: ${e.message}`,{cause:e}):e}return Me(e,...t)},Ne=(e,t,n)=>{let r=(e,t,n)=>{if(n.def?.type===`union`)return n.def.options.reduce((e,n)=>r(e,t,n),e);if(n.def?.type===`intersection`)return r(r(e,t,n.def.left),t,n.def.right);for(let i in t){let a=t[i],o=n?.shape;if(o!=null)for(;o!=null;){if(o[i]!=null){let t=o[i].safeParse(a);if(t.success){e[i]=t.data;break}}o=o.def?.shape}typeof a==`object`&&!Array.isArray(a)&&a!==null&&n&&n.shape&&n.shape[i]&&(e[i]||={},r(e[i],a,n.shape[i]))}return e};return r({...e},t,n)},Pe=(e,t)=>{let n=t.split(`.`),r=e,i=0;for(;i<n.length;){if(i===n.length-1){let e=n[i];if(Array.isArray(r)){let t=parseInt(e,10);if(!isNaN(t)&&t<r.length){r.splice(t,1);return}let n=r[0];if(typeof n==`object`&&`key`in n){let t=r.findIndex(t=>t.key===e);if(t!==-1){r.splice(t,1);return}}return}delete r[e];return}let e=!1;if(Array.isArray(r)&&r.length>0){let t=r[0];if(typeof t==`object`&&`key`in t)for(let t=n.length-i;t>=1;t--){let a=n.slice(i,i+t).join(`.`),o=r.find(e=>e.key===a);if(o!=null){if(i+t===n.length){let e=r.findIndex(e=>e.key===a);e!==-1&&r.splice(e,1);return}r=o,i+=t,e=!0;break}}}if(!e)for(let t=n.length-i;t>=1;t--){let a=n.slice(i,i+t).join(`.`);if(!Array.isArray(r)&&typeof r==`object`&&r&&a in r){if(i+t===n.length){delete r[a];return}r=r[a],i+=t,e=!0;break}}if(!e){let e=_(r,n[i]);if(e==null)return;r=e,i++}}},Fe=(e,t,n)=>{let r=t.split(`.`),i=e,a=0;for(;a<r.length-1;){let e=ke(i,r.slice(a,r.length-1)),t;e==null?(t=r[a],a++):[t,a]=[e[0],a+e[1]];let n=_(i,t);if(n==null){let e=r[a],o=v(e);o==null&&e.startsWith(`-`)&&v(e.substring(1))!=null&&(o=0),n=o==null?{}:[],i[t]=n}i=n}try{let e=r[r.length-1];if(Array.isArray(i)){let t=v(e);if(t==null){if(e.startsWith(`-`)){let n=v(e.substring(1));n!=null&&(t=i.length-n)}if(t==null){if(i.length===0){let t=v(e);if(t!=null){i[t]=n;return}}let t=i[0];if(typeof t==`object`&&`key`in t){let t=i.findIndex(t=>t.key===e);if(t!==-1){i[t]=n;return}}return}}i[t]=n;return}let t=ke(i,[e]);if(t!=null){i[t[0]]=n;return}i[e]=n}catch(r){throw console.error(`failed to set value`,n,`at path`,t,`on object`,e),r}},Ie=o({SEPARATOR:()=>`.`,atKeys:()=>be,copy:()=>xe,defaultGetter:()=>_,difference:()=>Se,element:()=>De,equal:()=>Ce,findBestKey:()=>ke,get:()=>Ae,getIndex:()=>v,has:()=>je,override:()=>Me,overrideValidItems:()=>Ne,partialEqual:()=>we,pathsMatch:()=>Oe,remove:()=>Pe,resolvePath:()=>Ee,set:()=>Fe,transformPath:()=>Te}),Le=e=>Object.getOwnPropertySymbols(globalThis).includes(e),Re=(e,t)=>{let n=Symbol.for(e);if(!Le(n)){let e=t();Object.defineProperty(globalThis,n,{value:e})}return()=>globalThis[n]},ze=o({Canceled:()=>Ze,NONE:()=>`nil`,NotImplemented:()=>Qe,UNKNOWN:()=>Ue,Unknown:()=>Ye,createTyped:()=>y,decode:()=>Je,encode:()=>qe,isTyped:()=>He,payloadZ:()=>Xe,register:()=>Ke}),Be=`sy_x_error`,Ve=e=>t=>typeof t==`object`&&t&&`type`in t&&typeof t.type==`string`?t.type.startsWith(e):t instanceof Error?t.message.startsWith(e):typeof t==`string`?t.startsWith(e):!1,y=e=>class t extends Error{static discriminator=Be;discriminator=t.discriminator;static TYPE=e;type=t.TYPE;static matches=Ve(e);matches=t.matches;constructor(e,n){super(e,n),this.name=t.TYPE}static sub(t){return y(`${e}.${t}`)}},He=e=>{if(typeof e!=`object`||!e)return!1;let t=e;if(t.discriminator!==Be)return!1;if(!(`type`in t))throw Error(`X Error is missing its type property: ${JSON.stringify(t)}`);return!0},Ue=`unknown`,We=class{providers=[];register(e){this.providers.push(e)}encode(e){if(e==null)return{type:`nil`,data:``};if(He(e))for(let t of this.providers){let n=t.encode(e);if(n!=null)return n}if(e instanceof Error)return{type:Ue,data:e.message};if(typeof e==`string`)return{type:Ue,data:e};try{return{type:Ue,data:JSON.stringify(e)}}catch{return{type:Ue,data:`unable to encode error information`}}}decode(e){if(e==null||e.type===`nil`)return null;if(e.type===`unknown`)return new Ye(e.data);for(let t of this.providers){let n=t.decode(e);if(n!=null)return n}return new Ye(e.data)}},Ge=Re(`synnax-error-registry`,()=>new We),Ke=({encode:e,decode:t})=>Ge().register({encode:e,decode:t}),qe=e=>Ge().encode(e),Je=e=>e==null?null:Ge().decode(e),Ye=class extends y(`unknown`){},Xe=l.z.object({type:l.z.string(),data:l.z.string()}),Ze=class extends y(`canceled`){},Qe=class extends y(`not_implemented`){},$e=e=>{if(e.length===0)return`<root>`;let t=``;return e.forEach((e,n)=>{typeof e==`number`?t+=`[${e}]`:n===0?t+=String(e):t+=`.${String(e)}`}),t},et=200,tt=10,nt=8,b=(e,t={})=>{let n=t.maxStringLength??et,r=t.maxArrayLength??tt,i=t.maxDepth??nt,a=(e,t)=>{if(e===null)return null;if(e===void 0)return`[undefined]`;let o=typeof e;if(o===`string`){let t=e;return t.length>n?`${t.slice(0,n)}…(+${t.length-n} chars)`:t}if(o===`number`||o===`boolean`)return e;if(o===`bigint`)return`${e.toString()}n`;if(o===`symbol`||o===`function`)return`[${o}]`;if(Array.isArray(e)){if(t>=i)return`[Array(${e.length})]`;let n=e.slice(0,r).map(e=>a(e,t+1));return e.length>r&&n.push(`…(+${e.length-r} more)`),n}if(ve(e)){if(t>=i)return`[Object]`;let n={};for(let[r,i]of Object.entries(e))n[r]=a(i,t+1);return n}if(e instanceof Date)return e.toISOString();if(e instanceof Error)return`[Error: ${e.message}]`;try{return`[${Object.prototype.toString.call(e)}]`}catch{return`[unknown]`}};return a(e,0)},rt=(e,t={})=>JSON.stringify(b(e,t),null,2),it=o({path:()=>$e,stringify:()=>rt,value:()=>b}),at=o({ValueExtension:()=>S,is:()=>lt,isCrudeValueExtension:()=>x,isNonZero:()=>ct,isStringer:()=>ot,isZero:()=>st}),x=e=>typeof e==`object`&&!!e&&`value`in e,S=class{value;constructor(e){this.value=e}valueOf(){return this.value}toJSON(){return this.value}toString(){return this.value.toString()}},ot=e=>typeof e==`object`&&!!e&&`toString`in e,st=e=>{if(ot(e))return e?.toString().length===0;switch(typeof e){case`string`:return e.length===0;case`number`:return e===0;case`bigint`:return e===0n;case`boolean`:return!e;case`undefined`:return!0;case`object`:return e==null;default:return!1}},ct=e=>!st(e),lt=e=>e==null||typeof e!=`object`&&typeof e!=`function`,ut=`value`,dt=`zod.parse`,ft=`✗`,pt=60,mt={maxStringLength:60,maxArrayLength:3,maxDepth:3},ht=e=>e.slice(0,-1),gt=e=>{switch(e.code){case`invalid_type`:return`expected ${e.expected}`;case`invalid_value`:return`expected one of ${JSON.stringify(e.values)}`;case`unrecognized_keys`:return`unexpected key`;case`too_small`:{let t=e.inclusive===!1?`>`:`>=`;return`${e.origin} too small: expected ${t}${e.minimum}`}case`too_big`:{let t=e.inclusive===!1?`<`:`<=`;return`${e.origin} too large: expected ${t}${e.maximum}`}case`invalid_format`:return`expected ${e.format} format`;case`not_multiple_of`:return`expected multiple of ${e.divisor}`;case`custom`:return e.message||`custom validation failed`;default:return e.message}},_t=(e,t,n)=>{let r=JSON.stringify(b(t,n));return`${gt(e)}, received ${r}`},vt=e=>{let t=0;for(let n of e){if(n.path.length>t&&(t=n.path.length),n.code===`invalid_union`&&`errors`in n)for(let e of n.errors){let n=vt(e);n>t&&(t=n)}if((n.code===`invalid_key`||n.code===`invalid_element`)&&`issues`in n){let e=vt(n.issues);e>t&&(t=e)}}return t},yt=(e,t=[])=>{let n=[];for(let r of e){let e=[...t,...r.path];if(r.code===`invalid_union`&&`errors`in r&&r.errors.length>0){let t=r.errors[0],i=vt(t);for(let e=1;e<r.errors.length;e++){let n=vt(r.errors[e]);n>i&&(t=r.errors[e],i=n)}n.push(...yt(t,e));continue}if(r.code===`invalid_element`&&`issues`in r&&`key`in r&&(typeof r.key==`string`||typeof r.key==`number`)){n.push(...yt(r.issues,[...e,r.key]));continue}if(r.code===`invalid_key`&&`issues`in r){n.push(...yt(r.issues,e));continue}n.push({...r,path:e})}return n},bt=e=>{let t=[];for(let n of e){if(n.code===`unrecognized_keys`&&`keys`in n&&Array.isArray(n.keys)){for(let e of n.keys)t.push({...n,path:[...n.path,e]});continue}t.push(n)}return t},xt=(e,t,n,r)=>{let i=`${n} `,a=`${n+ft} `,o={...mt,...r};if(Array.isArray(e)){let e=-1;for(let n of t.keys()){let t=Number(n);Number.isInteger(t)&&t>e&&(e=t)}let n=o.maxArrayLength??3;e>=n&&(o={...o,maxArrayLength:e+2})}let s=b(e,o);if(typeof s!=`object`||!s){let e=JSON.stringify(s),n=t.values().next().value;return[`${a}${e}${n?` × ${n.reason}`:``}`]}let c=[],l=Array.isArray(s);c.push(`${n}${l?`[`:`{`}`);let u=[];if(l){let e=s;for(let n=0;n<e.length;n++){let r=t.get(String(n));u.push({content:JSON.stringify(e[n]),mark:r&&!r.missing?r:void 0})}}else{let e=s;for(let n of Object.keys(e)){let r=t.get(n);u.push({content:`"${n}": ${JSON.stringify(e[n])}`,mark:r&&!r.missing?r:void 0})}for(let[e,n]of t.entries())n.missing&&u.push({content:`"${e}": <missing>`,mark:n})}let d=0;return u.forEach((e,t)=>{if(e.mark==null)return;let n=t<u.length-1?1:0,r=e.content.length+n;r>d&&r<=pt&&(d=r)}),u.forEach((e,t)=>{let n=t<u.length-1?`,`:``,r=e.content+n;if(e.mark!=null){let t=` `.repeat(Math.max(2,d-r.length+2));c.push(`${a}${r}${t}× ${e.mark.reason}`)}else c.push(`${i}${r}`)}),c.push(n+(l?`]`:`}`)),c},St=`__root__`,Ct=(e,t,n)=>{let r=new Map;for(let t of e){let e=t.path.length===0?St:`::${$e(ht(t.path))}`,n=r.get(e);n==null?r.set(e,[t]):n.push(t)}let i=[];for(let[e,a]of r){if(e===St){i.push(a.map(e=>` × ${_t(e,t,n)}`).join(`
|
|
2
|
+
`));continue}let r=ht(a[0].path),{present:o,value:s}=be(t,r);if(!o){i.push(a.map(e=>` at ${$e(e.path)}\n × ${_t(e,t,n)}`).join(`
|
|
3
|
+
`));continue}let c=new Map;for(let e of a){let n=String(e.path[e.path.length-1]),r=be(t,e.path);c.set(n,{reason:gt(e),missing:!r.present})}let l=r.length===0,u=xt(s,c,l?` `:` `,n);l?i.push(u.join(`
|
|
4
|
+
`)):i.push([` at ${$e(r)}`,...u].join(`
|
|
5
|
+
`))}return i.join(`
|
|
6
|
+
|
|
7
|
+
`)},wt=(e,t)=>{let n=Object.entries(e);return n.every(([,e])=>lt(e))?n.map(([e,t])=>`${e}=${typeof t==`string`?t:String(t)}`).join(`, `):rt(e,t)},Tt=({issues:e,input:t,label:n,context:r,formatOptions:i})=>{let a=i??{},o=bt(yt(e)),s=[`Failed to parse ${n} (${o.length===1?`1 issue`:`${o.length} issues`})`];return s.push(Ct(o,t,a)),r!=null&&Object.keys(r).length>0&&s.push(` context: ${wt(r,a)}`),s.join(`
|
|
8
|
+
|
|
9
|
+
`)},Et=class extends y(dt){issues;input;label;context;constructor({issues:e,input:t,label:n,context:r,cause:i,formatOptions:a}){super(Tt({issues:e,input:t,label:n,context:r,formatOptions:a}),{cause:i}),this.issues=e,this.input=t,this.label=n,this.context=r}toStatus(){let e={input:b(this.input),issues:this.issues};return this.context!=null&&(e.context=this.context),{message:`Failed to parse ${this.label}`,description:this.message,details:e}}};Ke({encode:e=>{if(!Et.matches(e))return null;let t=e,n={label:t.label,context:t.context,issues:t.issues,input:b(t.input)};return{type:dt,data:JSON.stringify(n)}},decode:e=>{if(e.type!==dt)return null;let t=JSON.parse(e.data);return new Et({issues:t.issues,input:t.input,label:t.label,context:t.context})}});var Dt=(e,t,n={})=>{let r=e.safeParse(t);if(r.success)return r.data;throw new Et({issues:r.error.issues,input:t,label:n.label??ut,context:n.context,cause:r.error})},Ot=2**12-1,kt=2**16-1,At=2**20-1,jt=2**32-1,Mt=2n**64n-1n,Nt=2**64-1,Pt=-128,Ft=-(2**15),It=2**15-1,Lt=-(2**31),Rt=2**31-1,zt=-(2n**63n),Bt=2n**63n-1n,Vt=-(2**63),Ht=2**63-1,Ut=e=>(t,n)=>{if(typeof t==`bigint`){if(Jt(n))return e(t,BigInt(n));let r=e(Number(t),Number(n));return typeof r==`number`?BigInt(Math.round(r)):r}return e(Number(t),Number(n))},C=Ut((e,t)=>e-t),w=Ut((e,t)=>e+t),Wt=(e,t,n=1e-4)=>Math.abs(e-t)<n,Gt=(e,t)=>{let n=typeof e==`bigint`,r=typeof t==`bigint`;return n&&r?e===t:n&&Jt(t)?e===BigInt(t):r&&Jt(e)?t===BigInt(e):e===t},Kt=e=>{let t=10**Math.floor(Math.log10(e));return Math.round(e/t)*t},qt=Ut((e,t)=>e<=t?e:t),Jt=e=>typeof e==`bigint`?!0:Number.isInteger(e),Yt=Ut((e,t)=>e>=t?e:t),Xt=e=>typeof e==`bigint`?e<0n?-e:e:e<0?-e:e,T=Ut((e,t)=>e*t),Zt=Ut((e,t)=>e/t),Qt=l.z.tuple([l.z.number(),l.z.number()]),$t=[`x`,`y`],en=l.z.enum($t),tn=[`top`,`right`,`bottom`,`left`],nn=l.z.enum(tn),rn=[`left`,`right`],an=l.z.enum(rn),on=[`top`,`bottom`],sn=l.z.enum(on),cn=[`center`],ln=l.z.enum(cn),un=[`top`,`right`,`bottom`,`left`,`center`],dn=l.z.enum(un),fn=[`start`,`center`,`end`],pn=l.z.enum(fn),mn=[`first`,`last`],hn=l.z.enum(mn),gn=l.z.object({clientX:l.z.number(),clientY:l.z.number()}),_n=l.z.object({width:l.z.number(),height:l.z.number()}),vn=l.z.object({signedWidth:l.z.number(),signedHeight:l.z.number()}),yn=l.z.object({lower:l.z.number(),upper:l.z.number()}),bn=l.z.enum([`x`,`y`,...tn,...cn]),xn=l.z.union([en,l.z.enum([...tn,...cn]),l.z.instanceof(String)]),Sn=o({CLIP:()=>En,DECIMAL:()=>Tn,INFINITE:()=>wn,ZERO:()=>Cn,boundsZ:()=>yn,buildInsertionPlan:()=>Vn,clamp:()=>kn,construct:()=>E,contains:()=>D,distance:()=>Un,equals:()=>Dn,findInsertPosition:()=>zn,isFinite:()=>Pn,isZero:()=>Mn,linspace:()=>Rn,makeValid:()=>On,max:()=>In,mean:()=>Fn,min:()=>Ln,overlapsWith:()=>An,span:()=>jn,spanIsZero:()=>Nn,traverse:()=>Hn}),E=(e,t,n)=>{let r={};if(typeof t==`object`&&(n=t,t=void 0),n={makeValid:!0,...n},typeof e==`number`||typeof e==`bigint`)t==null?(r.lower=typeof e==`bigint`?0n:0,r.upper=e):(r.lower=e,r.upper=t);else if(Array.isArray(e)){if(e.length!==2)throw Error(`bounds: expected array of length 2`);[r.lower,r.upper]=e}else r.lower=e.lower,r.upper=e.upper;return n?.makeValid?On(r):r},Cn=Object.freeze({lower:0,upper:0}),wn=Object.freeze({lower:-1/0,upper:1/0}),Tn=Object.freeze({lower:0,upper:1}),En=Object.freeze({lower:-1,upper:1}),Dn=(e,t)=>{if(e==null&&t==null)return!0;if(e==null||t==null)return!1;let n=E(e),r=E(t);return n?.lower===r?.lower&&n?.upper===r?.upper},On=e=>e.lower>e.upper?{lower:e.upper,upper:e.lower}:e,kn=(e,t)=>{let n=E(e);return t<n.lower?n.lower:t>=n.upper?n.upper-(typeof n.upper==`number`?1:1n):t},D=(e,t)=>{let n=E(e);if(typeof t==`number`||typeof t==`bigint`)return t>=n.lower&&t<n.upper;let r=E(t);return r.lower>=n.lower&&r.upper<=n.upper},An=(e,t)=>{let n=E(e),r=E(t);return n.lower===r.lower?!0:r.upper===n.lower||r.lower===n.upper?!1:D(n,r.upper)||D(n,r.lower)||D(r,n.upper)||D(r,n.lower)},jn=e=>{let t=E(e);return t.upper-t.lower},Mn=e=>{let t=E(e);return typeof t.lower==`bigint`?t.lower===0n&&t.upper===0n:t.lower===0&&t.upper===0},Nn=e=>{let t=jn(e);return typeof t==`number`?t===0:t===0n},Pn=e=>{let t=E(e);return typeof t.lower==`bigint`?!0:Number.isFinite(t.lower)&&Number.isFinite(t.upper)},Fn=e=>{let t=E(e);return(t.upper+t.lower)/2},In=e=>({lower:Math.min(...e.map(e=>E(e).lower)),upper:Math.max(...e.map(e=>E(e).upper))}),Ln=e=>({lower:Math.max(...e.map(e=>E(e).lower)),upper:Math.min(...e.map(e=>E(e).upper))}),Rn=e=>{let t=E(e),n=typeof t.lower==`bigint`;return Array.from({length:Number(jn(e))},(e,r)=>n?t.lower+BigInt(r):t.lower+r)},zn=(e,t)=>{let n=e.map(e=>E(e)),r=n.findIndex(e=>D(e,t)||t<e.lower);if(r===-1)return{index:e.length,position:0};let i=n[r];return D(i,t)?{index:r,position:Number(t-i.lower)}:{index:r,position:0}},Bn={removeBefore:0,removeAfter:0,insertInto:0,deleteInBetween:0},Vn=(e,t)=>{let n=e.map(e=>E(e)),r=E(t);if(n.length===0)return Bn;let i=zn(n,r.lower),a=zn(n,r.upper);if(i.index===e.length)return{...Bn,insertInto:e.length};if(a.index===0)return{...Bn,removeAfter:a.position};if(i.index===a.index)return i.position!==0&&a.position!==0?null:{removeAfter:a.position,removeBefore:i.position,insertInto:i.index,deleteInBetween:0};let o=a.index-i.index,s=i.index,c=C(Number(jn(n[i.index])),i.position);return i.position===0?c=0:(--o,s+=1),{removeBefore:c,removeAfter:a.position,insertInto:s,deleteInBetween:o}},Hn=(e,t,n)=>{let r=e.map(e=>E(e)),i=n>0?1:n<0?-1:0;if(i===0)return t;let a=n,o=t;for(;Gt(a,0)===!1;){let e=r.findIndex(e=>i>0?o>=e.lower&&o<e.upper:o>e.lower&&o<=e.upper);if(e!==-1){let t=r[e],n;if(n=i>0?C(t.upper,o):C(o,t.lower),n>0){let e=qt(Xt(a),n);if(o=w(o,i>0?e:-e),a=C(a,i>0?e:-e),Gt(a,0))return o;continue}}if(i>0){let e=r.filter(e=>e.lower>o);if(e.length>0)o=e[0].lower;else return o}else{let e=r.filter(e=>e.upper<o);if(e.length>0)o=e[e.length-1].upper;else return o}}return o},Un=(e,t,n)=>{let r=e.map(e=>E(e));if(t===n)return typeof t==`bigint`?0n:0;let i=E(t<n?[t,n]:[n,t]),a=typeof t==`bigint`?0n:0;for(let e of r){let t=e.lower>i.lower?e.lower:i.lower,n=e.upper<i.upper?e.upper:i.upper;if(t<n){let e=n-t;a+=e}}return a},Wn=2,Gn=3,Kn=2,qn=5,Jn=1e-10,Yn=(e,t)=>{if(Number.isNaN(e)||!Number.isFinite(e))return e;let n=Math.abs(e);if(n===0)return 0;let r=!1,i=0;if(t!=null){i=jn(t);let e=i/n;r=i>0&&e>Jn}if(r){let t;t=i>=1e3?Wn:i>=1?Gn:Math.ceil(-Math.log10(i))+Kn;let n=10**t;return Math.round(e*n)/n}if(n>=1e3){let t=10**Wn;return Math.round(e*t)/t}if(n>=1){let t=10**Gn;return Math.round(e*t)/t}let a=10**(qn-Math.floor(Math.log10(n))-1);return Math.round(e*a)/a},Xn=o({MAX_INT16:()=>It,MAX_INT32:()=>Rt,MAX_INT64:()=>Bt,MAX_INT64_NUMBER:()=>Ht,MAX_INT8:()=>127,MAX_UINT12:()=>Ot,MAX_UINT16:()=>kt,MAX_UINT20:()=>At,MAX_UINT32:()=>jt,MAX_UINT64:()=>Mt,MAX_UINT64_NUMBER:()=>Nt,MAX_UINT8:()=>255,MIN_INT16:()=>Ft,MIN_INT32:()=>Lt,MIN_INT64:()=>zt,MIN_INT64_NUMBER:()=>Vt,MIN_INT8:()=>Pt,abs:()=>Xt,add:()=>w,closeTo:()=>Wt,div:()=>Zt,equal:()=>Gt,isInteger:()=>Jt,max:()=>Yt,min:()=>qt,mult:()=>T,roundToNearestMagnitude:()=>Kt,smartRound:()=>Yn,sub:()=>C}),Zn=l.z.int().min(Pt).max(127),Qn=l.z.int().min(Ft).max(It),$n=l.z.int().min(Vt).max(Ht),er=l.z.int().min(0).max(255),tr=l.z.int().min(0).max(Ot),nr=l.z.int().min(0).max(kt),rr=l.z.int().min(0).max(At),ir=e=>l.default.array(e).or(e.transform(e=>[e])),ar=e=>e._zod.def.output,or=e=>Te(e,(e,t,n)=>{let r=t===n.length-1,i=!isNaN(parseInt(e,10)),a=!isNaN(parseInt(n[t+1],10));return i&&(e=`element`),r||a?e:[e,`shape`]}),sr=(e,t)=>{if(e==null)return null;let n=e[t];return n==null&&typeof e==`object`&&`sourceType`in e?e.sourceType()[t]:n},cr=((e,t,n)=>t===``?e:Ae(sr(e,`shape`),or(t),{...n,getter:sr})),lr=o({ParseError:()=>Et,functionOutput:()=>ar,getFieldSchema:()=>cr,getFieldSchemaPath:()=>or,int16:()=>Qn,int64:()=>$n,int8:()=>Zn,nullToUndefined:()=>ye,parse:()=>Dt,toArray:()=>ir,uint12:()=>tr,uint16:()=>nr,uint20:()=>rr,uint8:()=>er}),ur=o({CSVCodec:()=>fr,CSV_CODEC:()=>hr,ENCODERS:()=>_r,JSONCodec:()=>dr,JSON_CODEC:()=>mr,TEXT_CODEC:()=>gr,TextCodec:()=>pr}),dr=class{contentType=`application/json`;decoder;encoder;constructor(){this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(e,t){return this.encoder.encode(this.encodeString(e,t))}decode(e,t){return this.decodeString(this.decoder.decode(e),t)}decodeString(e,t){let n=le(JSON.parse(e),{schema:t});return t==null?n:Dt(t,n)}encodeString(e,t){let n=ue((t==null?e:Dt(t,e))??{},{schema:t});return JSON.stringify(n,(e,t)=>ArrayBuffer.isView(t)?Array.from(t):typeof t==`bigint`?t.toString():t)}},fr=class{contentType=`text/csv`;encode(e){let t=this.encodeString(e);return new TextEncoder().encode(t)}decode(e,t){let n=new TextDecoder().decode(e);return this.decodeString(n,t)}encodeString(e){if(!Array.isArray(e)||e.length===0||!g(e[0]))throw Error(`Payload must be an array of objects`);let t=Object.keys(e[0]),n=[t.join(`,`)];return e.forEach(e=>{let r=t.map(t=>JSON.stringify(e[t]??``));n.push(r.join(`,`))}),n.join(`
|
|
2
10
|
`)}decodeString(e,t){let[n,...r]=e.trim().split(`
|
|
3
|
-
`).map(e=>e.trim());if(n.length===0)return t==null?{}:t.parse({});let i=n.split(`,`).map(e=>e.trim()),a={};return i.forEach(e=>{a[e]=[]}),r.forEach(e=>{let t=e.split(`,`).map(e=>e.trim());i.forEach((e,n)=>{let r=this.parseValue(t[n]);r!=null&&a[e].push(r)})}),t==null?a:t.parse(a)}parseValue(e){if(e==null||e.length===0)return null;let t=Number(e);return isNaN(t)?e.startsWith(`"`)&&e.endsWith(`"`)?e.slice(1,-1):e:t}},xe=class{contentType=`text/plain`;encode(e){if(typeof e!=`string`)throw Error(`TextCodec.encode payload must be a string`);return new TextEncoder().encode(e)}decode(e,t){let n=new TextDecoder().decode(e);return t==null?n:t.parse(n)}},Se=new ye,Ce=new be,we=new xe,Te=[Se],Ee=o({ValueExtension:()=>v,isCrudeValueExtension:()=>_,isNonZero:()=>ke,isStringer:()=>De,isZero:()=>Oe}),_=e=>typeof e==`object`&&!!e&&`value`in e,v=class{value;constructor(e){this.value=e}valueOf(){return this.value}toJSON(){return this.value}toString(){return this.value.toString()}},De=e=>typeof e==`object`&&!!e&&`toString`in e,Oe=e=>{if(De(e))return e?.toString().length===0;switch(typeof e){case`string`:return e.length===0;case`number`:return e===0;case`bigint`:return e===0n;case`boolean`:return!e;case`undefined`:return!0;case`object`:return e==null;default:return!1}},ke=e=>!Oe(e),Ae=o({by:()=>Me,unique:()=>je}),je=e=>[...new Set(e)],Me=(e,t,n=!0)=>{let r=new Map;return e.forEach(e=>{let i=t(e);if(r.has(i)){if(n)return;r.delete(i)}r.set(i,e)}),Array.from(r.values())},Ne=(e,t=!1)=>{let n=De(e)?`stringer`:typeof e,r;switch(n){case`string`:r=(e,t)=>e.localeCompare(t);break;case`stringer`:r=(e,t)=>e.toString().localeCompare(t.toString());break;case`number`:r=(e,t)=>Number(e)-Number(t);break;case`bigint`:r=(e,t)=>BigInt(e)-BigInt(t)>0n?1:-1;break;case`boolean`:r=(e,t)=>Number(e)-Number(t);break;case`undefined`:r=()=>0;break;default:return console.warn(`sortFunc: unknown type ${n}`),()=>-1}return t?ze(r):r},Pe=(e,t,n)=>{let r=Ne(t[e],n);return(t,n)=>r(t[e],n[e])},Fe=(e,t)=>e.length===t.length?e.every((e,n)=>e===t[n])?0:-1:e.length-t.length,Ie=(e,t)=>{if(e.length!==t.length)return e.length-t.length;if(e.length===0)return 0;let n=Ne(e[0]),r=[...e].sort(n),i=[...t].sort(n);return r.every((e,t)=>e===i[t])?0:-1},Le=(e,t)=>Ie(je(e),je(t)),Re=(e,t)=>e===t?0:e===`first`&&t===`last`?1:-1,ze=e=>(t,n)=>e(n,t),Be=e=>e<0,Ve=e=>e>0,He=e=>e>=0,Ue=e=>e===0,We=(e,t)=>{let n=/([a-zA-Z]+)|(\d+)/g,r=e.replace(/[\s_.-]+/g,``).match(n),i=t.replace(/[\s_.-]+/g,``).match(n);if(!r||!i)return 0;for(let e=0;e<Math.min(r.length,i.length);e++){let t=r[e],n=i[e];if(isNaN(Number(t))&&isNaN(Number(n))){let e=t.localeCompare(n);if(e!==0)return e}else if(!isNaN(Number(t))&&!isNaN(Number(n))){let e=Number(t)-Number(n);if(e!==0)return e}else return isNaN(Number(t))?-1:1}return r.length-i.length},Ge=(e,t,n)=>{let r=0,i=e.length,a=n??Ne(t);for(;r<i;){let n=Math.floor((r+i)/2),o=a(e[n],t);if(o===0)return n;o<0?r=n+1:i=n}return r},Ke=(e,t,n)=>{let r=Ge(e,t,n);e.splice(r,0,t)},qe=o({EQUAL:()=>0,GREATER_THAN:()=>1,LESS_THAN:()=>-1,insert:()=>Ke,isEqualTo:()=>Ue,isGreaterThan:()=>Ve,isGreaterThanEqual:()=>He,isLessThan:()=>Be,newF:()=>Ne,newFieldF:()=>Pe,order:()=>Re,primitiveArrays:()=>Fe,reverseF:()=>ze,search:()=>Ge,stringsWithNumbers:()=>We,uniqueUnorderedPrimitiveArrays:()=>Le,unorderedPrimitiveArrays:()=>Ie}),Je=(e,t=21)=>(n=t)=>{let r=``,i=n|0;for(;i--;)r+=e[Math.random()*e.length|0];return r},Ye=o({LENGTH:()=>11,create:()=>et}),Xe=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,Ze=`0123456789${Xe}`,Qe=Je(Xe,1),$e=Je(Ze,10),et=()=>`${Qe()}${$e()}`,tt=o({createMatcher:()=>nt}),nt=(e,t)=>n=>n instanceof t||typeof n==`object`&&!!n&&`discriminator`in n&&n.discriminator===e,rt=2**12-1,it=2**16-1,at=2**20-1,ot=2**32-1,st=2n**64n-1n,ct=2**64-1,lt=-128,ut=-(2**15),dt=2**15-1,ft=-(2**31),pt=2**31-1,mt=-(2n**63n),ht=2n**63n-1n,gt=-(2**63),_t=2**63-1,y=e=>(t,n)=>{if(typeof t==`bigint`){if(St(n))return e(t,BigInt(n));let r=e(Number(t),Number(n));return typeof r==`number`?BigInt(Math.round(r)):r}return e(Number(t),Number(n))},b=y((e,t)=>e-t),x=y((e,t)=>e+t),vt=(e,t,n=1e-4)=>Math.abs(e-t)<n,yt=(e,t)=>{let n=typeof e==`bigint`,r=typeof t==`bigint`;return n&&r?e===t:n&&St(t)?e===BigInt(t):r&&St(e)?t===BigInt(e):e===t},bt=e=>{let t=10**Math.floor(Math.log10(e));return Math.round(e/t)*t},xt=y((e,t)=>e<=t?e:t),St=e=>typeof e==`bigint`?!0:Number.isInteger(e),Ct=y((e,t)=>e>=t?e:t),wt=e=>typeof e==`bigint`?e<0n?-e:e:e<0?-e:e,S=y((e,t)=>e*t),Tt=y((e,t)=>e/t),Et=l.z.tuple([l.z.number(),l.z.number()]),Dt=[`x`,`y`],Ot=l.z.enum(Dt),kt=[`top`,`right`,`bottom`,`left`],At=l.z.enum(kt),jt=[`left`,`right`],Mt=l.z.enum(jt),Nt=[`top`,`bottom`],Pt=l.z.enum(Nt),Ft=[`center`],It=l.z.enum(Ft),Lt=[`top`,`right`,`bottom`,`left`,`center`],Rt=l.z.enum(Lt),zt=[`start`,`center`,`end`],Bt=l.z.enum(zt),Vt=[`first`,`last`],Ht=l.z.enum(Vt),Ut=l.z.object({clientX:l.z.number(),clientY:l.z.number()}),Wt=l.z.object({width:l.z.number(),height:l.z.number()}),Gt=l.z.object({signedWidth:l.z.number(),signedHeight:l.z.number()}),Kt=l.z.object({lower:l.z.number(),upper:l.z.number()}),qt=l.z.enum([`x`,`y`,...kt,...Ft]),Jt=l.z.union([Ot,l.z.enum([...kt,...Ft]),l.z.instanceof(String)]),Yt=o({CLIP:()=>$t,DECIMAL:()=>Qt,INFINITE:()=>Zt,ZERO:()=>Xt,boundsZ:()=>Kt,buildInsertionPlan:()=>hn,clamp:()=>nn,construct:()=>C,contains:()=>w,distance:()=>_n,equals:()=>en,findInsertPosition:()=>pn,isFinite:()=>cn,isZero:()=>on,linspace:()=>fn,makeValid:()=>tn,max:()=>un,mean:()=>ln,min:()=>dn,overlapsWith:()=>rn,span:()=>an,spanIsZero:()=>sn,traverse:()=>gn}),C=(e,t,n)=>{let r={};if(typeof t==`object`&&(n=t,t=void 0),n={makeValid:!0,...n},typeof e==`number`||typeof e==`bigint`)t==null?(r.lower=typeof e==`bigint`?0n:0,r.upper=e):(r.lower=e,r.upper=t);else if(Array.isArray(e)){if(e.length!==2)throw Error(`bounds: expected array of length 2`);[r.lower,r.upper]=e}else r.lower=e.lower,r.upper=e.upper;return n?.makeValid?tn(r):r},Xt=Object.freeze({lower:0,upper:0}),Zt=Object.freeze({lower:-1/0,upper:1/0}),Qt=Object.freeze({lower:0,upper:1}),$t=Object.freeze({lower:-1,upper:1}),en=(e,t)=>{if(e==null&&t==null)return!0;if(e==null||t==null)return!1;let n=C(e),r=C(t);return n?.lower===r?.lower&&n?.upper===r?.upper},tn=e=>e.lower>e.upper?{lower:e.upper,upper:e.lower}:e,nn=(e,t)=>{let n=C(e);return t<n.lower?n.lower:t>=n.upper?n.upper-(typeof n.upper==`number`?1:1n):t},w=(e,t)=>{let n=C(e);if(typeof t==`number`||typeof t==`bigint`)return t>=n.lower&&t<n.upper;let r=C(t);return r.lower>=n.lower&&r.upper<=n.upper},rn=(e,t)=>{let n=C(e),r=C(t);return n.lower===r.lower?!0:r.upper===n.lower||r.lower===n.upper?!1:w(n,r.upper)||w(n,r.lower)||w(r,n.upper)||w(r,n.lower)},an=e=>{let t=C(e);return t.upper-t.lower},on=e=>{let t=C(e);return typeof t.lower==`bigint`?t.lower===0n&&t.upper===0n:t.lower===0&&t.upper===0},sn=e=>{let t=an(e);return typeof t==`number`?t===0:t===0n},cn=e=>{let t=C(e);return typeof t.lower==`bigint`?!0:Number.isFinite(t.lower)&&Number.isFinite(t.upper)},ln=e=>{let t=C(e);return(t.upper+t.lower)/2},un=e=>({lower:Math.min(...e.map(e=>C(e).lower)),upper:Math.max(...e.map(e=>C(e).upper))}),dn=e=>({lower:Math.max(...e.map(e=>C(e).lower)),upper:Math.min(...e.map(e=>C(e).upper))}),fn=e=>{let t=C(e),n=typeof t.lower==`bigint`;return Array.from({length:Number(an(e))},(e,r)=>n?t.lower+BigInt(r):t.lower+r)},pn=(e,t)=>{let n=e.map(e=>C(e)),r=n.findIndex(e=>w(e,t)||t<e.lower);if(r===-1)return{index:e.length,position:0};let i=n[r];return w(i,t)?{index:r,position:Number(t-i.lower)}:{index:r,position:0}},mn={removeBefore:0,removeAfter:0,insertInto:0,deleteInBetween:0},hn=(e,t)=>{let n=e.map(e=>C(e)),r=C(t);if(n.length===0)return mn;let i=pn(n,r.lower),a=pn(n,r.upper);if(i.index===e.length)return{...mn,insertInto:e.length};if(a.index===0)return{...mn,removeAfter:a.position};if(i.index===a.index)return i.position!==0&&a.position!==0?null:{removeAfter:a.position,removeBefore:i.position,insertInto:i.index,deleteInBetween:0};let o=a.index-i.index,s=i.index,c=b(Number(an(n[i.index])),i.position);return i.position===0?c=0:(--o,s+=1),{removeBefore:c,removeAfter:a.position,insertInto:s,deleteInBetween:o}},gn=(e,t,n)=>{let r=e.map(e=>C(e)),i=n>0?1:n<0?-1:0;if(i===0)return t;let a=n,o=t;for(;yt(a,0)===!1;){let e=r.findIndex(e=>i>0?o>=e.lower&&o<e.upper:o>e.lower&&o<=e.upper);if(e!==-1){let t=r[e],n;if(n=i>0?b(t.upper,o):b(o,t.lower),n>0){let e=xt(wt(a),n);if(o=x(o,i>0?e:-e),a=b(a,i>0?e:-e),yt(a,0))return o;continue}}if(i>0){let e=r.filter(e=>e.lower>o);if(e.length>0)o=e[0].lower;else return o}else{let e=r.filter(e=>e.upper<o);if(e.length>0)o=e[e.length-1].upper;else return o}}return o},_n=(e,t,n)=>{let r=e.map(e=>C(e));if(t===n)return typeof t==`bigint`?0n:0;let i=C(t<n?[t,n]:[n,t]),a=typeof t==`bigint`?0n:0;for(let e of r){let t=e.lower>i.lower?e.lower:i.lower,n=e.upper<i.upper?e.upper:i.upper;if(t<n){let e=n-t;a+=e}}return a},vn=2,yn=3,bn=2,xn=5,Sn=1e-10,Cn=(e,t)=>{if(Number.isNaN(e)||!Number.isFinite(e))return e;let n=Math.abs(e);if(n===0)return 0;let r=!1,i=0;if(t!=null){i=an(t);let e=i/n;r=i>0&&e>Sn}if(r){let t;t=i>=1e3?vn:i>=1?yn:Math.ceil(-Math.log10(i))+bn;let n=10**t;return Math.round(e*n)/n}if(n>=1e3){let t=10**vn;return Math.round(e*t)/t}if(n>=1){let t=10**yn;return Math.round(e*t)/t}let a=10**(xn-Math.floor(Math.log10(n))-1);return Math.round(e*a)/a},wn=o({MAX_INT16:()=>dt,MAX_INT32:()=>pt,MAX_INT64:()=>ht,MAX_INT64_NUMBER:()=>_t,MAX_INT8:()=>127,MAX_UINT12:()=>rt,MAX_UINT16:()=>it,MAX_UINT20:()=>at,MAX_UINT32:()=>ot,MAX_UINT64:()=>st,MAX_UINT64_NUMBER:()=>ct,MAX_UINT8:()=>255,MIN_INT16:()=>ut,MIN_INT32:()=>ft,MIN_INT64:()=>mt,MIN_INT64_NUMBER:()=>gt,MIN_INT8:()=>lt,abs:()=>wt,add:()=>x,closeTo:()=>vt,div:()=>Tt,equal:()=>yt,isInteger:()=>St,max:()=>Ct,min:()=>xt,mult:()=>S,roundToNearestMagnitude:()=>bt,smartRound:()=>Cn,sub:()=>b}),Tn=o({DIRECTIONS:()=>Dt,construct:()=>T,crude:()=>En,dimension:()=>On,directionZ:()=>Ot,isDirection:()=>An,isX:()=>Mn,isY:()=>Nn,location:()=>kn,signedDimension:()=>jn,swap:()=>Dn}),En=qt,T=e=>Dt.includes(e)?e:Nt.includes(e)?`y`:`x`,Dn=e=>T(e)===`x`?`y`:`x`,On=e=>T(e)===`x`?`width`:`height`,kn=e=>T(e)===`x`?`left`:`top`,An=e=>En.safeParse(e).success,jn=e=>T(e)===`x`?`signedWidth`:`signedHeight`,Mn=e=>e===`center`?!1:T(e)===`x`,Nn=e=>T(e)===`y`,Pn=o({BOTTOM_CENTER:()=>Qn,BOTTOM_LEFT:()=>Jn,BOTTOM_RIGHT:()=>Yn,CENTER:()=>Xn,CENTER_LEFT:()=>er,CENTER_LOCATIONS:()=>Ft,CENTER_RIGHT:()=>$n,LOCATIONS:()=>Lt,OUTER_LOCATIONS:()=>kt,TOP_CENTER:()=>Zn,TOP_LEFT:()=>D,TOP_RIGHT:()=>qn,XY_LOCATIONS:()=>tr,X_LOCATIONS:()=>jt,Y_LOCATIONS:()=>Nt,center:()=>Ln,construct:()=>E,constructXY:()=>cr,corner:()=>Kn,crude:()=>Vn,direction:()=>Wn,isX:()=>ar,isY:()=>or,locationZ:()=>Rt,outerZ:()=>Rn,rotate:()=>Un,swap:()=>Hn,x:()=>Fn,xy:()=>Gn,xyCouple:()=>ir,xyEquals:()=>nr,xyMatches:()=>rr,xyToString:()=>sr,y:()=>In}),Fn=Mt,In=Pt,Ln=It,Rn=At,zn={top:`bottom`,right:`left`,bottom:`top`,left:`right`,center:`center`},Bn={top:{clockwise:`left`,counterclockwise:`right`},right:{clockwise:`top`,counterclockwise:`bottom`},bottom:{clockwise:`right`,counterclockwise:`left`},left:{clockwise:`bottom`,counterclockwise:`top`}},Vn=Jt,E=e=>e instanceof String||!Dt.includes(e)?e:e===`x`?`left`:`top`,Hn=e=>zn[E(e)],Un=(e,t)=>Bn[e][t],Wn=e=>{let t=E(e);return t===`top`||t===`bottom`?`y`:`x`},Gn=l.z.object({x:Mt.or(It),y:Pt.or(It)}),Kn=l.z.object({x:Mt,y:Pt}),D=Object.freeze({x:`left`,y:`top`}),qn=Object.freeze({x:`right`,y:`top`}),Jn=Object.freeze({x:`left`,y:`bottom`}),Yn=Object.freeze({x:`right`,y:`bottom`}),Xn=Object.freeze({x:`center`,y:`center`}),Zn=Object.freeze({x:`center`,y:`top`}),Qn=Object.freeze({x:`center`,y:`bottom`}),$n=Object.freeze({x:`right`,y:`center`}),er=Object.freeze({x:`left`,y:`center`}),tr=Object.freeze([er,$n,Zn,Qn,D,qn,Jn,Yn,Xn]),nr=(e,t)=>e.x===t.x&&e.y===t.y,rr=(e,t)=>{if(typeof t==`object`){let n=!0;return`x`in t&&e.x!==t.x&&(n=!1),`y`in t&&e.y!==t.y&&(n=!1),n}return e.x===t||e.y===t},ir=e=>[e.x,e.y],ar=e=>Wn(E(e))===`x`,or=e=>Wn(E(e))===`y`,sr=e=>`${e.x}${de(e.y)}`,cr=(e,t)=>{let n,r;if(typeof e==`object`&&`x`in e?(n=e.x,r=e.y):(n=E(e),r=E(t??e)),Wn(n)===Wn(r)&&n!==`center`&&r!==`center`)throw Error(`[XYLocation] - encountered two locations with the same direction: ${n.toString()} - ${r.toString()}`);let i={...Xn};return n===`center`?ar(r)?[i.x,i.y]=[r,n]:[i.x,i.y]=[n,r]:ar(n)?[i.x,i.y]=[n,r]:[i.x,i.y]=[r,n],i},lr=[`top`,`right`,`bottom`,`left`],ur=l.z.enum(lr),O=l.z.object({x:l.z.number(),y:l.z.number()}),dr=o({INFINITY:()=>mr,NAN:()=>hr,ONE:()=>pr,ZERO:()=>A,average:()=>Nr,calculateMiters:()=>Pr,clientXyZ:()=>Ut,construct:()=>k,couple:()=>Dr,crudeZ:()=>fr,css:()=>Or,distance:()=>Cr,equals:()=>gr,isFinite:()=>Er,isNan:()=>Tr,isZero:()=>_r,normal:()=>jr,normalize:()=>Mr,reciprocal:()=>Lr,rotate:()=>Rr,round:()=>Ir,scale:()=>vr,set:()=>Sr,sub:()=>Ar,swap:()=>Fr,translate:()=>xr,translateX:()=>yr,translateY:()=>br,translation:()=>wr,truncate:()=>kr,xyZ:()=>O}),fr=l.z.union([l.z.number(),O,Et,Wt,Gt,Ut]),k=(e,t)=>{if(typeof e==`string`){if(t===void 0)throw Error(`The y coordinate must be given.`);return e===`x`?{x:t,y:0}:{x:0,y:t}}return typeof e==`number`?{x:e,y:t??e}:Array.isArray(e)?{x:e[0],y:e[1]}:`signedWidth`in e?{x:e.signedWidth,y:e.signedHeight}:`clientX`in e?{x:e.clientX,y:e.clientY}:`width`in e?{x:e.width,y:e.height}:{x:e.x,y:e.y}},A=Object.freeze({x:0,y:0}),pr=Object.freeze({x:1,y:1}),mr=Object.freeze({x:1/0,y:1/0}),hr=Object.freeze({x:NaN,y:NaN}),gr=(e,t,n=0)=>{let r=k(e),i=k(t);return n===0?r.x===i.x&&r.y===i.y:Math.abs(r.x-i.x)<=n&&Math.abs(r.y-i.y)<=n},_r=e=>gr(e,A),vr=(e,t,n)=>{let r=k(e),i=k(t,n);return{x:r.x*i.x,y:r.y*i.y}},yr=(e,t)=>{let n=k(e);return{x:n.x+t,y:n.y}},br=(e,t)=>{let n=k(e);return{x:n.x,y:n.y+t}},xr=(e,t,n,...r)=>{if(typeof t==`string`){if(typeof n!=`number`)throw Error(`The value must be a number.`);return t===`x`?yr(e,n):br(e,n)}if(typeof t==`object`&&`x`in t&&typeof t.x==`string`){let r=k(n),i=k(e);return t.x===`left`?r.x=-r.x:t.x===`center`&&(r.x=0),t.y===`top`?r.y=-r.y:t.y===`center`&&(r.y=0),{x:i.x+r.x,y:i.y+r.y}}return[e,t,n??A,...r].reduce((e,t)=>{let n=k(t);return{x:e.x+n.x,y:e.y+n.y}},A)},Sr=(e,t,n)=>{let r=k(e);return T(t)===`x`?{x:n,y:r.y}:{x:r.x,y:n}},Cr=(e,t)=>{let n=k(e),r=k(t);return Math.sqrt((n.x-r.x)**2+(n.y-r.y)**2)},wr=(e,t)=>{let n=k(e),r=k(t);return{x:r.x-n.x,y:r.y-n.y}},Tr=e=>{let t=k(e);return Number.isNaN(t.x)||Number.isNaN(t.y)},Er=e=>{let t=k(e);return Number.isFinite(t.x)&&Number.isFinite(t.y)},Dr=e=>{let t=k(e);return[t.x,t.y]},Or=e=>{let t=k(e);return{left:t.x,top:t.y}},kr=(e,t=0)=>{let n=k(e);return{x:Number(n.x.toFixed(t)),y:Number(n.y.toFixed(t))}},Ar=(e,t)=>{let n=k(e),r=k(t);return{x:n.x-r.x,y:n.y-r.y}},jr=e=>{let t=k(e),n=Math.hypot(t.x,t.y);return n===0?{x:0,y:0}:{x:-t.y/n,y:t.x/n}},Mr=e=>{let t=k(e),n=Math.hypot(t.x,t.y);return n===0?{x:0,y:0}:{x:t.x/n,y:t.y/n}},Nr=(...e)=>vr(e.reduce((e,t)=>xr(e,t),A),1/e.length),Pr=(e,t)=>{let n=[];for(let r=0;r<e.length;r++){let i=e[r],a,o,s,c;if(r===0){let n=e[r+1];o=jr(Ar(n,i)),s=o,c=t}else if(r===e.length-1){let n=e[r-1];a=jr(Ar(i,n)),s=a,c=t}else{let n=e[r-1],l=e[r+1],u=Ar(i,n),d=Ar(l,i);a=jr(u),o=jr(d);let f=Math.acos((u.x*d.x+u.y*d.y)/(Math.hypot(u.x,u.y)*Math.hypot(d.x,d.y))),p=Math.sin(f/2);c=p===0?t:t/p,s=Mr(Nr(a,o))}n.push(vr(s,c))}return n},Fr=e=>{let t=k(e);return{x:t.y,y:t.x}},Ir=e=>{let t=k(e);return{x:Math.round(t.x),y:Math.round(t.y)}},Lr=e=>{let t=k(e);return{x:1/t.x,y:1/t.y}},Rr=(e,t,n)=>{let r=k(e),i=k(t),a=n===`clockwise`?Math.PI/2:-Math.PI/2,o=r.x-i.x,s=r.y-i.y,c=o*Math.cos(a)-s*Math.sin(a),l=o*Math.sin(a)+s*Math.cos(a);return{x:c+i.x,y:l+i.y}},zr=o({DECIMAL:()=>Gr,ZERO:()=>Wr,area:()=>wi,areaIsZero:()=>ei,aspect:()=>xi,bottom:()=>L,bottomCenter:()=>si,bottomLeft:()=>oi,bottomRight:()=>ci,box:()=>Ur,center:()=>di,centerLeft:()=>li,centerRight:()=>ui,construct:()=>j,constructWithAlternateRoot:()=>Ei,contains:()=>Jr,copy:()=>Kr,css:()=>Qr,cssBox:()=>Vr,dim:()=>$r,dims:()=>Xr,domRect:()=>Hr,edgePoints:()=>vi,equals:()=>Yr,height:()=>F,intersection:()=>Ci,isBox:()=>bi,left:()=>R,loc:()=>N,positionInCenter:()=>yi,reRoot:()=>_i,resize:()=>qr,right:()=>I,root:()=>mi,round:()=>Di,signedDims:()=>Zr,signedHeight:()=>ni,signedWidth:()=>ti,top:()=>z,topCenter:()=>ii,topLeft:()=>ri,topRight:()=>ai,translate:()=>Si,truncate:()=>Ti,width:()=>P,x:()=>fi,xBounds:()=>hi,xyLoc:()=>M,y:()=>pi,yBounds:()=>gi}),Br=l.z.union([l.z.number(),l.z.string()]),Vr=l.z.object({top:Br,left:Br,width:Br,height:Br}),Hr=l.z.object({left:l.z.number(),top:l.z.number(),right:l.z.number(),bottom:l.z.number()}),Ur=l.z.object({one:O,two:O,root:Kn}),Wr={one:A,two:A,root:D},Gr={one:A,two:pr,root:Jn},Kr=(e,t)=>({one:e.one,two:e.two,root:t??e.root}),j=(e,t,n=0,r=0,i)=>{let a={one:{...A},two:{...A},root:i??D};if(typeof e==`number`){if(typeof t!=`number`)throw Error(`Box constructor called with invalid arguments`);return a.one={x:e,y:t},a.two={x:a.one.x+n,y:a.one.y+r},a}return`one`in e&&`two`in e&&`root`in e?{...e,root:i??e.root}:(`getBoundingClientRect`in e&&(e=e.getBoundingClientRect()),`left`in e?(a.one={x:e.left,y:e.top},a.two={x:e.right,y:e.bottom},a):(a.one=e,t==null?a.two={x:a.one.x+n,y:a.one.y+r}:typeof t==`number`?a.two={x:a.one.x+t,y:a.one.y+n}:`width`in t?a.two={x:a.one.x+t.width,y:a.one.y+t.height}:`signedWidth`in t?a.two={x:a.one.x+t.signedWidth,y:a.one.y+t.signedHeight}:a.two=t,a))},qr=(e,t,n)=>{let r=j(e);if(typeof t==`string`){if(n==null)throw Error(`Invalid arguments for resize`);let e=T(t);return j(r.one,void 0,e===`x`?n:P(r),e===`y`?n:F(r),r.root)}return j(r.one,t,void 0,void 0,r.root)},Jr=(e,t,n=!0)=>{let r=j(e),i=(e,t)=>e<t;return n&&(i=(e,t)=>e<=t),`one`in t?i(R(r),R(t))&&i(I(t),I(r))&&i(z(r),z(t))&&i(L(t),L(r)):i(R(r),t.x)&&i(t.x,I(r))&&i(z(r),t.y)&&i(t.y,L(r))},Yr=(e,t)=>gr(e.one,t.one)&&gr(e.two,t.two)&&nr(e.root,t.root),Xr=e=>({width:P(e),height:F(e)}),Zr=e=>({signedWidth:ti(e),signedHeight:ni(e)}),Qr=e=>({top:z(e),left:R(e),width:P(e),height:F(e)}),$r=(e,t,n=!1)=>{let r=T(t)===`y`?ni(e):ti(e);return n?r:Math.abs(r)},M=(e,t)=>{let n=j(e);return{x:t.x===`center`?di(n).x:N(n,t.x),y:t.y===`center`?di(n).y:N(n,t.y)}},N=(e,t)=>{let n=j(e),r=ir(n.root).includes(t)?Math.min:Math.max;return jt.includes(t)?r(n.one.x,n.two.x):r(n.one.y,n.two.y)},ei=e=>wi(e)===0,P=e=>$r(e,`x`),F=e=>$r(e,`y`),ti=e=>{let t=j(e);return t.two.x-t.one.x},ni=e=>{let t=j(e);return t.two.y-t.one.y},ri=e=>M(e,D),ii=e=>M(e,Zn),ai=e=>M(e,qn),oi=e=>M(e,Jn),si=e=>M(e,Qn),ci=e=>M(e,Yn),li=e=>M(e,er),ui=e=>M(e,$n),I=e=>N(e,`right`),L=e=>N(e,`bottom`),R=e=>N(e,`left`),z=e=>N(e,`top`),di=e=>xr(ri(e),{x:ti(e)/2,y:ni(e)/2}),fi=e=>{let t=j(e);return t.root.x===`left`?R(t):I(t)},pi=e=>{let t=j(e);return t.root.y===`top`?z(t):L(t)},mi=e=>({x:fi(e),y:pi(e)}),hi=e=>{let t=j(e);return{lower:t.one.x,upper:t.two.x}},gi=e=>{let t=j(e);return{lower:t.one.y,upper:t.two.y}},_i=(e,t)=>Kr(e,t),vi=(e,t)=>{let n=j(e),r=jt.includes(t)?`x`:Nt.includes(t)?`y`:null;if(r===null)throw Error(`Invalid location: ${t}`);let i=t===`top`||t===`left`?Math.min:Math.max,a={...n.one},o={...n.two};return a[r]=i(n.one[r],n.two[r]),o[r]=i(n.one[r],n.two[r]),[a,o]},yi=(e,t)=>{let n=j(e),r=j(t);return j({x:fi(r)+(P(r)-P(n))/2,y:pi(r)+(F(r)-F(n))/2},Xr(n))},bi=e=>typeof e!=`object`||!e?!1:`one`in e&&`two`in e&&`root`in e,xi=e=>P(e)/F(e),Si=(e,t,n)=>{if(typeof t==`string`){if(n==null)throw Error(`Undefined amount passed into box.translate`);t=k(T(t),n)}let r=j(e);return j(xr(r.one,t),xr(r.two,t),void 0,void 0,r.root)},Ci=(e,t)=>{let n=Math.max(R(e),R(t)),r=Math.max(z(e),z(t)),i=Math.min(I(e),I(t)),a=Math.min(L(e),L(t));return n>i||r>a?Wr:j({x:n,y:r},{x:i,y:a},void 0,void 0,e.root)},wi=e=>P(e)*F(e),Ti=(e,t)=>{let n=j(e);return j(kr(n.one,t),kr(n.two,t),void 0,void 0,n.root)},Ei=(e,t,n,r,i,a)=>{let o={x:e,y:t},s={x:e+n,y:t+r};return i.x!==a.x&&(i.x===`center`?(o.x-=n/2,s.x-=n/2):(o.x-=n,s.x-=n)),i.y!==a.y&&(i.y===`center`?(o.y-=r/2,s.y-=r/2):(o.y-=r,s.y-=r)),j(o,s,void 0,void 0,a)},Di=e=>{let t=j(e);return j(Ir(t.one),Ir(t.two),void 0,void 0,t.root)},Oi=o({DECIMAL:()=>ji,ZERO:()=>Ai,construct:()=>B,couple:()=>Fi,crude:()=>ki,dimensionsZ:()=>Wt,equals:()=>Mi,max:()=>Ii,min:()=>Li,scale:()=>Ri,signedDimensionsZ:()=>Gt,svgViewBox:()=>Pi,swap:()=>Ni}),ki=l.z.union([Wt,Gt,O,Et]),Ai={width:0,height:0},ji={width:1,height:1},B=(e,t)=>typeof e==`number`?{width:e,height:t??e}:Array.isArray(e)?{width:e[0],height:e[1]}:`x`in e?{width:e.x,height:e.y}:`signedWidth`in e?{width:e.signedWidth,height:e.signedHeight}:{...e},Mi=(e,t)=>{if(t==null)return!1;let n=B(e),r=B(t);return n.width===r.width&&n.height===r.height},Ni=e=>{let t=B(e);return{width:t.height,height:t.width}},Pi=e=>{let t=B(e);return`0 0 ${t.width} ${t.height}`},Fi=e=>{let t=B(e);return[t.width,t.height]},Ii=e=>({width:Math.max(...e.map(e=>B(e).width)),height:Math.max(...e.map(e=>B(e).height))}),Li=e=>({width:Math.min(...e.map(e=>B(e).width)),height:Math.min(...e.map(e=>B(e).height))}),Ri=(e,t)=>{let n=B(e);return{width:n.width*t,height:n.height*t}},zi=(e,t,n)=>t!==void 0&&e<t?t:n!==void 0&&e>n?n:e,Bi=o({Scale:()=>Yi,XY:()=>Xi,crudeXYTransform:()=>Vi,transform:()=>Hi}),Vi=l.z.object({offset:fr,scale:fr}),Hi=l.z.object({offset:l.z.number(),scale:l.z.number()}),Ui=e=>(t,n,r,i)=>n===`dimension`?[t,r]:[t,i?r-e:r+e],Wi=e=>(t,n,r,i)=>[t,i?r/e:r*e],Gi=e=>(t,n,r)=>{if(t===null)return[e,r];let{lower:i,upper:a}=t,{lower:o,upper:s}=e,c=a-i,l=s-o;return n===`dimension`?[e,l/c*r]:[e,(r-i)*(l/c)+o]},Ki=e=>(t,n,r)=>[e,r],qi=()=>(e,t,n)=>{if(e===null)throw Error(`cannot invert without bounds`);if(t===`dimension`)return[e,n];let{lower:r,upper:i}=e;return[e,i-(n-r)]},Ji=e=>(t,n,r)=>{let{lower:i,upper:a}=e;return r=zi(r,i,a),[t,r]},Yi=class e{ops=[];currBounds=null;currType=null;reversed=!1;constructor(){this.ops=[]}static translate(t){return new e().translate(t)}static magnify(t){return new e().magnify(t)}static scale(t,n){return new e().scale(t,n)}translate(e){let t=this.new(),n=Ui(e);return n.type=`translate`,t.ops.push(n),t}magnify(e){let t=this.new(),n=Wi(e);return n.type=`magnify`,t.ops.push(n),t}scale(e,t){let n=C(e,t),r=this.new(),i=Gi(n);return i.type=`scale`,r.ops.push(i),r}clamp(e,t){let n=C(e,t),r=this.new(),i=Ji(n);return i.type=`clamp`,r.ops.push(i),r}reBound(e,t){let n=C(e,t),r=this.new(),i=Ki(n);return i.type=`re-bound`,r.ops.push(i),r}invert(){let e=qi();e.type=`invert`;let t=this.new();return t.ops.push(e),t}pos(e){return this.exec(`position`,e)}dim(e){return this.exec(`dimension`,e)}new(){let t=new e;return t.ops=this.ops.slice(),t.reversed=this.reversed,t}exec(e,t){return this.currBounds=null,this.ops.reduce(([t,n],r)=>r(t,e,n,this.reversed),[null,t])[1]}reverse(){let e=this.new();e.ops.reverse();let t=[];return e.ops.forEach((n,r)=>{if(n.type===`scale`||t.some(([e,t])=>r>=e&&r<=t))return;let i=e.ops.findIndex((e,t)=>e.type===`scale`&&t>r);i!==-1&&t.push([r,i])}),t.forEach(([t,n])=>{let r=e.ops.slice(t,n);r.unshift(e.ops[n]),e.ops.splice(t,n-t+1,...r)}),e.reversed=!e.reversed,e}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}static IDENTITY=new e},Xi=class e{x;y;currRoot;constructor(e=new Yi,t=new Yi,n=null){this.x=e,this.y=t,this.currRoot=n}static translate(t,n){return new e().translate(t,n)}static translateX(t){return new e().translateX(t)}static translateY(t){return new e().translateY(t)}static clamp(t){return new e().clamp(t)}static magnify(t){return new e().magnify(t)}static scale(t){return new e().scale(t)}static reBound(t){return new e().reBound(t)}translate(e,t){let n=k(e,t),r=this.copy();return r.x=this.x.translate(n.x),r.y=this.y.translate(n.y),r}translateX(e){let t=this.copy();return t.x=this.x.translate(e),t}translateY(e){let t=this.copy();return t.y=this.y.translate(e),t}magnify(e){let t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){let t=this.copy();if(bi(e)){let n=this.currRoot;return t.currRoot=e.root,n!=null&&!nr(n,e.root)&&(n.x!==e.root.x&&(t.x=t.x.invert()),n.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(hi(e)),t.y=t.y.scale(gi(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){let t=this.copy();return t.x=this.x.reBound(hi(e)),t.y=this.y.reBound(gi(e)),t}clamp(e){let t=this.copy();return t.x=this.x.clamp(hi(e)),t.y=this.y.clamp(gi(e)),t}copy(){let t=new e;return t.currRoot=this.currRoot,t.x=this.x,t.y=this.y,t}reverse(){let 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 j(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})}}static IDENTITY=new e},Zi=o({ALIGNMENTS:()=>zt,CENTER_LOCATIONS:()=>Ft,DIRECTIONS:()=>Dt,LOCATIONS:()=>Lt,ORDERS:()=>Vt,OUTER_LOCATIONS:()=>kt,X_LOCATIONS:()=>jt,Y_LOCATIONS:()=>Nt,alignmentZ:()=>Bt,boundsZ:()=>Kt,centerLocationZ:()=>It,clientXyZ:()=>Ut,dimensionsZ:()=>Wt,directionZ:()=>Ot,locationZ:()=>Rt,orderZ:()=>Ht,outerLocationZ:()=>At,signedDimensionsZ:()=>Gt,xLocationZ:()=>Mt,xyZ:()=>O,yLocationZ:()=>Pt}),Qi=o({calculate:()=>ra,completeXY:()=>$i,toCSS:()=>ta,toDecimal:()=>na,xy:()=>ea}),$i=O.extend({root:Kn,units:l.default.object({x:l.default.enum([`px`,`decimal`]),y:l.default.enum([`px`,`decimal`])})}),ea=$i.partial({root:!0,units:!0}),ta=e=>{let t={};return t[e.root?.x??`left`]=e?.units?.x===`px`?`${e.x}px`:`${e.x*100}%`,t[e.root?.y??`top`]=e?.units?.y===`px`?`${e.y}px`:`${e.y*100}%`,t},na=({position:e,element:t,container:n})=>{let r={x:e.x,y:e.y};return e.units?.x===`decimal`?e.root?.x===`right`&&(r.x=1-e.x):e.root?.x===`right`?r.x=1-(e.x+P(t))/P(n):r.x/=P(n),e.units?.y===`decimal`?e.root?.y===`bottom`&&(r.y=1-e.y):e.root?.y===`bottom`?r.y=1-(e.y+F(t))/F(n):r.y/=F(n),r},ra=({position:e,element:t,container:n,lowerThreshold:r=.2,upperThreshold:i=.8})=>{let a={x:e.x,y:e.y,root:{...D},units:{x:`px`,y:`px`}};return e.x>i?(a.x=(1-e.x)*P(n)-P(t),a.root.x=`right`):e.x<r?a.x=e.x*P(n):a.units.x=`decimal`,e.y>i?(a.y=(1-e.y)*F(n)-F(t),a.root.y=`bottom`):e.y<r?a.y=e.y*F(n):a.units.y=`decimal`,a.x=Math.round(a.x*100)/100,{...a,...kr(a,3)}},ia=l.z.enum([`static`,`dynamic`]),aa=365,oa=30,sa=l.z.union([l.z.tuple([l.z.int()]),l.z.tuple([l.z.int(),l.z.int().min(1).max(12)]),l.z.tuple([l.z.int(),l.z.int().min(1).max(12),l.z.int().min(1).max(31)])]),ca=(e,t)=>{let n=new V(t);if(![H.DAY,H.HOUR,H.MINUTE,H.SECOND,H.MILLISECOND,H.MICROSECOND,H.NANOSECOND].some(e=>e.equals(n)))throw Error(`Invalid argument for remainder. Must be an even TimeSpan or Timestamp`);let r=e.valueOf()%n.valueOf();return e instanceof V?new V(r):new H(r)},V=class e extends v{constructor(t,n=`UTC`){if(t==null)super(e.now().valueOf());else if(t instanceof Date)super(BigInt(t.getTime())*e.MILLISECOND.valueOf());else if(typeof t==`string`)super(e.parseDateTimeString(t,n).valueOf());else if(Array.isArray(t))super(e.parseDate(t));else{let r=0n;t instanceof Number&&(t=t.valueOf()),n===`local`&&(r=e.utcOffset.valueOf()),typeof t==`number`&&(isFinite(t)?t=t===_t?ht:Math.trunc(t):(isNaN(t)&&(t=0),t=t===1/0?e.MAX:e.MIN)),_(t)&&(t=t.value),super(BigInt(t.valueOf())+r)}}static parseDate([t=1970,n=1,r=1]){let i=new Date(t,n-1,r,0,0,0,0);return new e(BigInt(i.getTime())*e.MILLISECOND.valueOf()).truncate(e.DAY).valueOf()}valueOf(){return this.value}static parseTimeString(t,n=`UTC`){let[r,i,a]=t.split(`:`),o=`00`,s=`00`;a!=null&&([o,s]=a.split(`.`));let c=e.hours(parseInt(r??`00`,10)).add(e.minutes(parseInt(i??`00`,10))).add(e.seconds(parseInt(o??`00`,10))).add(e.milliseconds(parseInt(s??`00`,10)));return n===`local`&&(c=c.add(e.utcOffset)),c.valueOf()}static parseDateTimeString(t,n=`UTC`){if(!t.includes(`/`)&&!t.includes(`-`))return e.parseTimeString(t,n);if(t.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?$/)!=null){let r=t,i=0;if(t.includes(`.`)){let e=t.split(`.`);r=e[0];let n=e[1]||`0`;i=parseInt(n.padEnd(3,`0`).slice(0,3),10)}let a=n===`local`?new Date(r.replace(`T`,` `)):new Date(`${r}Z`);return BigInt(a.getTime())*e.MILLISECOND.valueOf()+BigInt(i)*e.MILLISECOND.valueOf()}let r=new Date(t);return t.includes(`:`)||r.setUTCHours(0,0,0,0),new e(BigInt(r.getTime())*e.MILLISECOND.valueOf(),n).valueOf()}toISOString(t=`UTC`){if(t===`UTC`)return this.date().toISOString();let n=this.date(),r=new H(BigInt(n.getTimezoneOffset())*e.MINUTE.valueOf());return this.sub(r).date().toISOString()}timeString(e=!1,t=`UTC`){let n=this.toISOString(t);return e?n.slice(11,23):n.slice(11,19)}dateString(){let e=this.date();return`${e.toLocaleString(`default`,{month:`short`})} ${e.toLocaleString(`default`,{day:`numeric`})}`}static get utcOffset(){return new H(BigInt(new Date().getTimezoneOffset())*e.MINUTE.valueOf())}static since(t){return new e().span(t)}date(){return new Date(this.milliseconds)}equals(t){return this.valueOf()===new e(t).valueOf()}span(e){return this.range(e).span}range(e){return new G(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===0n}after(t){return this.valueOf()>new e(t).valueOf()}afterEq(t){return this.valueOf()>=new e(t).valueOf()}before(t){return this.valueOf()<new e(t).valueOf()}beforeEq(t){return this.valueOf()<=new e(t).valueOf()}add(t){return new e(x(this.valueOf(),new H(t).valueOf()))}sub(t){return new e(b(this.valueOf(),new H(t).valueOf()))}get hours(){return Number(this.valueOf())/Number(H.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(H.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(H.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(H.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(e.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(e.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get year(){return this.date().getUTCFullYear()}get localYear(){return this.date().getFullYear()}setYear(t){let n=this.date();return n.setUTCFullYear(t),new e(n)}setLocalYear(t){let n=this.date();return n.setFullYear(t),new e(n)}get month(){return this.date().getUTCMonth()}get localMonth(){return this.date().getMonth()}setMonth(t){let n=this.date();return n.setUTCMonth(t),new e(n)}setLocalMonth(t){let n=this.date();return n.setMonth(t),new e(n)}get day(){return this.date().getUTCDate()}get localDay(){return this.date().getDate()}setDay(t){let n=this.date();return n.setUTCDate(t),new e(n)}setLocalDay(t){let n=this.date();return n.setDate(t),new e(n)}get hour(){return this.date().getUTCHours()}get localHour(){return this.date().getHours()}setLocalHour(t){let n=this.date();return n.setHours(t),new e(n)}setHour(t){let n=this.date();return n.setUTCHours(t),new e(n)}get minute(){return this.date().getUTCMinutes()}get localMinute(){return this.date().getMinutes()}setMinute(t){let n=this.date();return n.setUTCMinutes(t),new e(n)}setLocalMinute(t){let n=this.date();return n.setMinutes(t),new e(n)}get second(){return this.date().getUTCSeconds()}get localSecond(){return this.date().getSeconds()}setSecond(t){let n=this.date();return n.setUTCSeconds(t),new e(n)}setLocalSecond(t){let n=this.date();return n.setSeconds(t),new e(n)}get millisecond(){return this.date().getUTCMilliseconds()}get localMillisecond(){return this.date().getMilliseconds()}setMillisecond(t){let n=this.date();return n.setUTCMilliseconds(t),new e(n)}setLocalMillisecond(t){let n=this.date();return n.setMilliseconds(t),new e(n)}toString(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)}}remainder(e){return ca(this,e)}get isToday(){return this.truncate(H.DAY).equals(e.now().truncate(H.DAY))}truncate(e){return this.sub(this.remainder(e))}formatBySpan(e){return e.greaterThanOrEqual(H.days(30))?`shortDate`:e.greaterThanOrEqual(H.DAY)?`dateTime`:e.greaterThanOrEqual(H.HOUR)?`time`:e.greaterThanOrEqual(H.SECOND)?`preciseTime`:`ISOTime`}static now(){return new e(new Date)}static max(...t){let n=e.MIN;for(let r of t){let t=new e(r);t.after(n)&&(n=t)}return n}static min(...t){let n=e.MAX;for(let r of t){let t=new e(r);t.before(n)&&(n=t)}return n}static nanoseconds(t,n=`UTC`){return new e(t,n)}static NANOSECOND=e.nanoseconds(1);static microseconds(t,n=`UTC`){return e.nanoseconds(t*1e3,n)}static MICROSECOND=e.microseconds(1);static milliseconds(t,n=`UTC`){return e.microseconds(t*1e3,n)}static MILLISECOND=e.milliseconds(1);static seconds(t,n=`UTC`){return e.milliseconds(t*1e3,n)}static SECOND=e.seconds(1);static minutes(t,n=`UTC`){return e.seconds(t*60,n)}static MINUTE=e.minutes(1);static hours(t,n=`UTC`){return e.minutes(t*60,n)}static HOUR=e.hours(1);static days(t,n=`UTC`){return e.hours(t*24,n)}static DAY=e.days(1);static MAX=new e(ht);static MIN=new e(0);static ZERO=new e(0);static z=l.z.union([l.z.instanceof(e),l.z.object({value:l.z.bigint()}).transform(t=>new e(t.value)),l.z.string().transform(t=>new e(BigInt(t))),l.z.number().transform(t=>new e(t)),l.z.bigint().transform(t=>new e(t)),l.z.date().transform(t=>new e(t)),l.z.custom(e=>e instanceof H).transform(t=>new e(t)),sa.transform(t=>new e(t))]);static sort(e,t){return Number(e.valueOf()-t.valueOf())}},H=class e extends v{constructor(e){typeof e==`number`&&(e=Math.trunc(e.valueOf())),_(e)&&(e=e.value),super(BigInt(e.valueOf()))}static fromSeconds(t){return t instanceof e?t:t instanceof U?t.period:t instanceof V?new e(t):(_(t)&&(t=t.value),[`number`,`bigint`].includes(typeof t)?e.seconds(t):new e(t))}static fromMilliseconds(t){return t instanceof e?t:t instanceof U?t.period:t instanceof V?new e(t):(_(t)&&(t=t.value),[`number`,`bigint`].includes(typeof t)?e.milliseconds(t):new e(t))}valueOf(){return this.value}lessThan(t){return this.valueOf()<new e(t).valueOf()}greaterThan(t){return this.valueOf()>new e(t).valueOf()}lessThanOrEqual(t){return this.valueOf()<=new e(t).valueOf()}greaterThanOrEqual(t){return this.valueOf()>=new e(t).valueOf()}remainder(e){return ca(this,e)}truncate(t){return new e(BigInt(Math.trunc(Number(this.valueOf()/t.valueOf())))*t.valueOf())}toString(t=`full`){if(t===`semantic`)return this.toSemanticString();let n=this.truncate(e.DAY),r=this.truncate(e.HOUR),i=this.truncate(e.MINUTE),a=this.truncate(e.SECOND),o=this.truncate(e.MILLISECOND),s=this.truncate(e.MICROSECOND),c=this.truncate(e.NANOSECOND),l=n,u=r.sub(n),d=i.sub(r),f=a.sub(i),p=o.sub(a),m=s.sub(o),ee=c.sub(s),h=``;return l.isZero||(h+=`${l.days}d `),u.isZero||(h+=`${u.hours}h `),d.isZero||(h+=`${d.minutes}m `),f.isZero||(h+=`${f.seconds}s `),p.isZero||(h+=`${p.milliseconds}ms `),m.isZero||(h+=`${m.microseconds}µs `),ee.isZero||(h+=`${ee.nanoseconds}ns`),h.trim()}toSemanticString(){let t=new e(this.valueOf()<0n?-this.valueOf():this.valueOf()),n=this.valueOf()<0n;if(t.valueOf()===0n)return`0s`;if(t.lessThan(e.SECOND))return`< 1s`;let r=t.days,i=t.hours,a=t.minutes,o=t.seconds,s=Math.floor(r/aa),c=Math.floor(r/oa),l=Math.floor(r/7),u=Math.floor(r),d=Math.floor(i),f=Math.floor(a),p=Math.floor(o),m=n?`-`:``;if(s>=1){let e=`${s}y`;if(s<2){let t=Math.floor(r%aa/oa);t>0&&(e+=` ${t}mo`)}return m+e}if(l>=1&&r<oa&&r%7==0){let e=`${l}w`,t=Math.floor(r%7),n=Math.floor(i-l*7*24);return l<2&&(t>0?e+=` ${t}d`:n>0&&n<24&&(e+=` ${n}h`)),m+e}if(c>=1){let e=`${c}mo`;if(c<3){let t=Math.floor(r%oa);t>0&&(e+=` ${t}d`)}return m+e}if(l>=1){let e=`${l}w`,t=Math.floor(r%7),n=Math.floor(i-l*7*24);return l<2&&(t>0?e+=` ${t}d`:n>0&&n<24&&(e+=` ${n}h`)),m+e}if(u>=1){let e=`${u}d`,t=Math.floor(i-u*24);return u<2&&t>0&&(e+=` ${t}h`),m+e}if(d>=1){let e=`${d}h`;if(d<3){let t=Math.floor(a-d*60);t>0&&(e+=` ${t}m`)}return m+e}if(f>=1){let e=`${f}m`;if(f<5){let t=Math.floor(o-f*60);t>0&&(e+=` ${t}s`)}return m+e}return`${m}${p}s`}mult(t){return new e(S(this.valueOf(),t))}div(t){return new e(Tt(this.valueOf(),t))}get days(){return Number(this.valueOf())/Number(e.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(e.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(e.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(e.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(e.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(e.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===0n}equals(t){return this.valueOf()===new e(t).valueOf()}add(t){return new e(this.valueOf()+new e(t).valueOf())}sub(t){return new e(this.valueOf()-new e(t).valueOf())}static nanoseconds(t=1){return new e(t)}static NANOSECOND=e.nanoseconds(1);static microseconds(t=1){return e.nanoseconds(S(t,1e3))}static MICROSECOND=e.microseconds(1);static milliseconds(t=1){return e.microseconds(S(t,1e3))}static MILLISECOND=e.milliseconds(1);static seconds(t=1){return e.milliseconds(S(t,1e3))}static SECOND=e.seconds(1);static minutes(t=1){return e.seconds(S(t,60))}static MINUTE=e.minutes(1);static hours(t){return e.minutes(S(t,60))}static HOUR=e.hours(1);static days(t){return e.hours(S(t,24))}static DAY=e.days(1);static MAX=new e(ht);static MIN=new e(0);static ZERO=new e(0);static z=l.z.union([l.z.object({value:l.z.bigint()}).transform(t=>new e(t.value)),l.z.string().transform(t=>new e(BigInt(t))),l.z.number().transform(t=>new e(t)),l.z.bigint().transform(t=>new e(t)),l.z.instanceof(e),l.z.instanceof(V).transform(t=>new e(t)),l.z.custom(e=>e instanceof U).transform(t=>new e(t))])},U=class e extends v{constructor(e){_(e)&&(e=e.value),super(e.valueOf())}toString(){return`${this.valueOf()} Hz`}equals(t){return this.valueOf()===new e(t).valueOf()}get period(){return H.seconds(1/this.valueOf())}sampleCount(e){return new H(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new W(t).valueOf()}span(e){return H.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/new W(t).valueOf())}add(t){return new e(x(this.valueOf(),new e(t).valueOf()))}sub(t){return new e(b(this.valueOf(),new e(t).valueOf()))}mult(t){return new e(S(this.valueOf(),t))}div(t){return new e(Tt(this.valueOf(),t))}static hz(t){return new e(t)}static khz(t){return e.hz(t*1e3)}static z=l.z.union([l.z.number().transform(t=>new e(t)),l.z.instanceof(e)])},W=class e extends v{constructor(e){_(e)&&(e=e.value),super(e.valueOf())}length(e){return e.valueOf()/this.valueOf()}size(e){return new q(e*this.valueOf())}add(t){return new e(x(this.valueOf(),new e(t).valueOf()))}sub(t){return new e(b(this.valueOf(),new e(t).valueOf()))}mult(t){return new e(S(this.valueOf(),t))}div(t){return new e(Tt(this.valueOf(),t))}static UNKNOWN=new e(0);static BIT128=new e(16);static BIT64=new e(8);static BIT32=new e(4);static BIT16=new e(2);static BIT8=new e(1);static z=l.z.union([l.z.number().transform(t=>new e(t)),l.z.instanceof(e)])},G=class e{start;end;constructor(e,t){typeof e==`object`&&`start`in e?(this.start=new V(e.start),this.end=new V(e.end)):(this.start=new V(e),this.end=new V(t))}get span(){return new H(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.start.isZero&&this.end.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new e(this.end,this.start)}get numericBounds(){return{lower:Number(this.start.valueOf()),upper:Number(this.end.valueOf())}}equals(e,t=H.ZERO){if(t.isZero)return this.start.equals(e.start)&&this.end.equals(e.end);let n=this.start.sub(e.start).valueOf(),r=this.end.sub(e.end).valueOf();return n<0&&(n=-n),r<0&&(r=-r),n<=t.valueOf()&&r<=t.valueOf()}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.toString(`preciseDate`)} - ${this.span.toString()}`}overlapsWith(e,t=H.ZERO){e=e.makeValid();let n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;let r=V.max(n.start,e.start),i=V.min(n.end,e.end);return i.before(r)?!1:new H(i.sub(r)).greaterThanOrEqual(t)}contains(t){return t instanceof e?this.contains(t.start)&&this.contains(t.end):this.start.beforeEq(t)&&this.end.after(t)}boundBy(t){let n=new e(this.start,this.end);return t.start.after(this.start)&&(n.start=t.start),t.start.after(this.end)&&(n.end=t.start),t.end.before(this.end)&&(n.end=t.end),t.end.before(this.start)&&(n.start=t.end),n}static max(...t){return new e(V.min(...t.map(e=>e.start)),V.max(...t.map(e=>e.end)))}static MAX=new e(V.MIN,V.MAX);static ZERO=new e(V.ZERO,V.ZERO);static z=l.z.union([l.z.object({start:V.z,end:V.z}).transform(t=>new e(t.start,t.end)),l.z.instanceof(e)]);static boundedZ=e.z.refine(({isValid:e})=>e,{message:`Time range start time must be before or equal to time range end time`}).refine(({end:e})=>e.valueOf()<=ht,{message:`Time range end time must be less than or equal to the maximum value of an int64`}).refine(({start:e})=>e.valueOf()>=mt,{message:`Time range start time must be greater than or equal to the minimum value of an int64`});static sort(e,t){return V.sort(e.start,t.start)||V.sort(e.end,t.end)}static merge(...t){return e.max(...t.map(t=>new e(t).makeValid()))}},K=class e extends v{constructor(t){if(_(t)&&(t=t.value),t instanceof e||typeof t==`string`||typeof t.valueOf()==`string`)super(t.valueOf());else{let n=e.ARRAY_CONSTRUCTOR_DATA_TYPES.get(t.constructor.name);if(n==null)throw Error(`unable to find data type for ${t.toString()}`);super(n.valueOf())}}get Array(){let t=e.ARRAY_CONSTRUCTORS.get(this.toString());if(t==null)throw Error(`unable to find array constructor for ${this.valueOf()}`);return t}equals(e){return this.valueOf()===e.valueOf()}matches(...e){return e.some(e=>this.equals(e))}toString(t=!1){return t?e.SHORT_STRINGS.get(this.valueOf())??this.valueOf():this.valueOf()}get isVariable(){return this.equals(e.JSON)||this.equals(e.STRING)||this.equals(e.BYTES)}get isNumeric(){return!this.isVariable&&!this.equals(e.UUID)}get isInteger(){let e=this.toString();return e.startsWith(`int`)||e.startsWith(`uint`)}get isFloat(){return this.toString().startsWith(`float`)}get density(){let t=e.DENSITIES.get(this.toString());if(t==null)throw Error(`unable to find density for ${this.valueOf()}`);return t}get isUnsignedInteger(){return this.equals(e.UINT8)||this.equals(e.UINT16)||this.equals(e.UINT32)||this.equals(e.UINT64)}get isSignedInteger(){return this.equals(e.INT8)||this.equals(e.INT16)||this.equals(e.INT32)||this.equals(e.INT64)}canSafelyCastTo(t){return this.equals(t)?!0:!this.isNumeric||!t.isNumeric||this.isVariable||t.isVariable||this.isUnsignedInteger&&t.isSignedInteger?!1:this.isFloat?t.isFloat&&this.density.valueOf()<=t.density.valueOf():this.equals(e.INT32)&&t.equals(e.FLOAT64)||this.equals(e.INT8)&&t.equals(e.FLOAT32)?!0:this.isInteger&&t.isInteger?this.density.valueOf()<=t.density.valueOf()&&this.isUnsignedInteger===t.isUnsignedInteger:!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}get usesBigInt(){return e.BIG_INT_TYPES.some(e=>e.equals(this))}static UNKNOWN=new e(`unknown`);static FLOAT64=new e(`float64`);static FLOAT32=new e(`float32`);static INT64=new e(`int64`);static INT32=new e(`int32`);static INT16=new e(`int16`);static INT8=new e(`int8`);static UINT64=new e(`uint64`);static UINT32=new e(`uint32`);static UINT16=new e(`uint16`);static UINT8=new e(`uint8`);static TIMESTAMP=new e(`timestamp`);static UUID=new e(`uuid`);static STRING=new e(`string`);static JSON=new e(`json`);static BYTES=new e(`bytes`);static ARRAY_CONSTRUCTORS=new Map([[e.UINT8.toString(),Uint8Array],[e.UINT16.toString(),Uint16Array],[e.UINT32.toString(),Uint32Array],[e.UINT64.toString(),BigUint64Array],[e.FLOAT32.toString(),Float32Array],[e.FLOAT64.toString(),Float64Array],[e.INT8.toString(),Int8Array],[e.INT16.toString(),Int16Array],[e.INT32.toString(),Int32Array],[e.INT64.toString(),BigInt64Array],[e.TIMESTAMP.toString(),BigInt64Array],[e.STRING.toString(),Uint8Array],[e.JSON.toString(),Uint8Array],[e.UUID.toString(),Uint8Array],[e.BYTES.toString(),Uint8Array]]);static ARRAY_CONSTRUCTOR_DATA_TYPES=new Map([[Uint8Array.name,e.UINT8],[Uint16Array.name,e.UINT16],[Uint32Array.name,e.UINT32],[BigUint64Array.name,e.UINT64],[Float32Array.name,e.FLOAT32],[Float64Array.name,e.FLOAT64],[Int8Array.name,e.INT8],[Int16Array.name,e.INT16],[Int32Array.name,e.INT32],[BigInt64Array.name,e.INT64]]);static DENSITIES=new Map([[e.UINT8.toString(),W.BIT8],[e.UINT16.toString(),W.BIT16],[e.UINT32.toString(),W.BIT32],[e.UINT64.toString(),W.BIT64],[e.FLOAT32.toString(),W.BIT32],[e.FLOAT64.toString(),W.BIT64],[e.INT8.toString(),W.BIT8],[e.INT16.toString(),W.BIT16],[e.INT32.toString(),W.BIT32],[e.INT64.toString(),W.BIT64],[e.TIMESTAMP.toString(),W.BIT64],[e.STRING.toString(),W.UNKNOWN],[e.JSON.toString(),W.UNKNOWN],[e.UUID.toString(),W.BIT128],[e.BYTES.toString(),W.UNKNOWN]]);static ALL=[e.UNKNOWN,e.UINT8,e.UINT16,e.UINT32,e.UINT64,e.INT8,e.INT16,e.INT32,e.INT64,e.FLOAT32,e.FLOAT64,e.TIMESTAMP,e.UUID,e.STRING,e.JSON,e.BYTES];static SHORT_STRINGS=new Map([[e.UINT8.toString(),`u8`],[e.UINT16.toString(),`u16`],[e.UINT32.toString(),`u32`],[e.UINT64.toString(),`u64`],[e.INT8.toString(),`i8`],[e.INT16.toString(),`i16`],[e.INT32.toString(),`i32`],[e.INT64.toString(),`i64`],[e.FLOAT32.toString(),`f32`],[e.FLOAT64.toString(),`f64`],[e.TIMESTAMP.toString(),`ts`],[e.UUID.toString(),`uuid`],[e.STRING.toString(),`str`],[e.JSON.toString(),`json`],[e.BYTES.toString(),`bytes`]]);static BIG_INT_TYPES=[e.INT64,e.UINT64,e.TIMESTAMP];static z=l.z.union([l.z.string().transform(t=>new e(t)),l.z.instanceof(e)])},q=class e extends v{constructor(e){_(e)&&(e=e.value),super(e.valueOf())}largerThan(e){return _(e)&&(e=e.value),this.valueOf()>e.valueOf()}smallerThan(e){return _(e)&&(e=e.value),this.valueOf()<e.valueOf()}add(t){return _(t)&&(t=t.value),new e(x(this.valueOf(),t.valueOf()))}sub(t){return _(t)&&(t=t.value),new e(b(this.valueOf(),t.valueOf()))}mult(t){return new e(S(this.valueOf(),t))}div(t){return new e(Tt(this.valueOf(),t))}truncate(t){return new e(Math.trunc(this.valueOf()/new e(t).valueOf())*new e(t).valueOf())}remainder(t){return e.bytes(this.valueOf()%new e(t).valueOf())}get gigabytes(){return this.valueOf()/e.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/e.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/e.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/e.TERABYTE.valueOf()}toString(){let t=this.truncate(e.TERABYTE),n=this.truncate(e.GIGABYTE),r=this.truncate(e.MEGABYTE),i=this.truncate(e.KILOBYTE),a=this.truncate(e.BYTE),o=t,s=n.sub(t),c=r.sub(n),l=i.sub(r),u=a.sub(i),d=``;return o.isZero||(d+=`${o.terabytes}TB `),s.isZero||(d+=`${s.gigabytes}GB `),c.isZero||(d+=`${c.megabytes}MB `),l.isZero||(d+=`${l.kilobytes}KB `),(!u.isZero||d===``)&&(d+=`${u.valueOf()}B`),d.trim()}static bytes(t=1){return new e(t)}static BYTE=new e(1);static kilobytes(t=1){return e.bytes(new e(t).valueOf()*1e3)}static KILOBYTE=e.kilobytes(1);static megabytes(t=1){return e.kilobytes(new e(t).valueOf()*1e3)}static MEGABYTE=e.megabytes(1);static gigabytes(t=1){return e.megabytes(new e(t).valueOf()*1e3)}static GIGABYTE=e.gigabytes(1);static terabytes(t){return e.gigabytes(new e(t).valueOf()*1e3)}static TERABYTE=e.terabytes(1);static ZERO=new e(0);static z=l.z.union([l.z.number().transform(t=>new e(t)),l.z.instanceof(e)]);get isZero(){return this.valueOf()===0}},la=l.z.object({start:l.z.number(),end:l.z.number()}),ua=l.z.union([l.z.instanceof(Uint8Array),l.z.instanceof(Uint16Array),l.z.instanceof(Uint32Array),l.z.instanceof(BigUint64Array),l.z.instanceof(Float32Array),l.z.instanceof(Float64Array),l.z.instanceof(Int8Array),l.z.instanceof(Int16Array),l.z.instanceof(Int32Array),l.z.instanceof(BigInt64Array)]),da=e=>{let t=typeof e;return t===`string`||t===`number`||t===`boolean`||t===`bigint`||e instanceof V||e instanceof H||e instanceof Date},fa=(e,t,n,r=0)=>e.usesBigInt&&!t.usesBigInt?Number(n)-Number(r):!e.usesBigInt&&t.usesBigInt?BigInt(n.valueOf())-BigInt(r.valueOf()):b(n,r),pa=G.z,ma=V.z,ha=H.z,ga=U.z,_a=q.z,va=K.z,ya=G.boundedZ,ba=`00000000-0000-0000-0000-000000000000`,xa=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function Sa(e){return typeof e==`string`&&xa.test(e)}var J=[];for(let e=0;e<256;++e)J.push((e+256).toString(16).slice(1));function Ca(e,t=0){return(J[e[t+0]]+J[e[t+1]]+J[e[t+2]]+J[e[t+3]]+`-`+J[e[t+4]]+J[e[t+5]]+`-`+J[e[t+6]]+J[e[t+7]]+`-`+J[e[t+8]]+J[e[t+9]]+`-`+J[e[t+10]]+J[e[t+11]]+J[e[t+12]]+J[e[t+13]]+J[e[t+14]]+J[e[t+15]]).toLowerCase()}function wa(e,t=0){let n=Ca(e,t);if(!Sa(n))throw TypeError(`Stringified UUID is invalid`);return n}var Ta,Ea=new Uint8Array(16);function Da(){if(!Ta){if(typeof crypto>`u`||!crypto.getRandomValues)throw Error(`crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported`);Ta=crypto.getRandomValues.bind(crypto)}return Ta(Ea)}var Oa={randomUUID:typeof crypto<`u`&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ka(e,t,n){e||={};let r=e.random??e.rng?.()??Da();if(r.length<16)throw Error(`Random bytes length must be >= 16`);if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(n||=0,n<0||n+16>t.length)throw RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=r[e];return t}return Ca(r)}function Aa(e,t,n){return Oa.randomUUID&&!t&&!e?Oa.randomUUID():ka(e,t,n)}var ja=o({ZERO:()=>Pa,create:()=>Ma,parse:()=>Na}),Ma=()=>Aa(),Na=(e,t)=>wa(e,t),Pa=ba,Y=-1,Fa={[Symbol.iterator]:()=>Fa,next:()=>({done:!0,value:void 0})},Ia=l.z.string().transform(e=>new Uint8Array(atob(e).split(``).map(e=>e.charCodeAt(0))).buffer),La=l.z.union([l.z.null(),l.z.undefined()]).transform(()=>new Uint8Array().buffer),Ra=10,za=(e,t)=>{if(e===`number`&&!t.isNumeric)throw Error(`cannot convert series of type ${t.toString()} to number`);if(e===`bigint`&&!t.usesBigInt)throw Error(`cannot convert series of type ${t.toString()} to bigint`)},Ba=`sy_x_telem_series`,Va=class e{key;discriminator=Ba;dataType;sampleOffset;gl;_data;timeRange=G.ZERO;alignment=0n;alignmentMultiple=1n;cachedMin;cachedMax;writePos=Y;_refCount=0;cachedLength;_cachedIndexes;static crudeZ=l.z.object({timeRange:G.z.optional(),dataType:K.z,alignment:l.z.coerce.bigint().optional(),data:l.z.union([Ia,La,l.z.instanceof(ArrayBuffer),l.z.instanceof(Uint8Array)]),glBufferUsage:ia.default(`static`).optional()});static z=e.crudeZ.transform(t=>new e(t));constructor(e){Ha(e)&&(e={data:e}),e.data??=[];let{dataType:t,timeRange:n,sampleOffset:r=0,glBufferUsage:i=`static`,alignment:a=0n,alignmentMultiple:o=1n,key:s=et(),data:c}=e;if(Ua(c)){let e=c;this.key=e.key,this.dataType=e.dataType,this.sampleOffset=e.sampleOffset,this.gl=e.gl,this._data=e._data,this.timeRange=e.timeRange,this.alignment=e.alignment,this.alignmentMultiple=e.alignmentMultiple,this.cachedMin=e.cachedMin,this.cachedMax=e.cachedMax,this.writePos=e.writePos,this._refCount=e._refCount,this.cachedLength=e.cachedLength;return}let l=da(c),u=Array.isArray(c);if(t!=null)this.dataType=new K(t);else if(c instanceof ArrayBuffer)throw Error(`cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.`);else if(u||l){let e=c;if(!l){if(c.length===0)throw Error(`cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.`);e=c[0]}if(typeof e==`string`)this.dataType=K.STRING;else if(typeof e==`number`)this.dataType=K.FLOAT64;else if(typeof e==`bigint`)this.dataType=K.INT64;else if(typeof e==`boolean`)this.dataType=K.UINT8;else if(e instanceof V||e instanceof Date||e instanceof V)this.dataType=K.TIMESTAMP;else if(typeof e==`object`)this.dataType=K.JSON;else throw Error(`cannot infer data type of ${typeof e} when constructing a Series from a JS array`)}else this.dataType=new K(c);if(!u&&!l)this._data=c;else if(u&&c.length===0)this._data=new this.dataType.Array([]).buffer;else{let e=l?[c]:c,t=e[0];(t instanceof V||t instanceof Date||t instanceof H)&&(e=e.map(e=>new V(e).valueOf())),this.dataType.equals(K.STRING)?(this.cachedLength=e.length,this._data=new TextEncoder().encode(`${e.join(`
|
|
4
|
-
`)}\n`).buffer):this.dataType.equals(
|
|
5
|
-
`)}\n`).buffer):this.dataType.usesBigInt&&typeof t==`number`?this._data=new this.dataType.Array(e.map(e=>BigInt(Math.round(e)))).buffer:!this.dataType.usesBigInt&&typeof t==`bigint`?this._data=new this.dataType.Array(e.map(Number)).buffer:this._data=new this.dataType.Array(e).buffer}this.key=s,this.alignment=a,this.alignmentMultiple=o,this.sampleOffset=r??0,this.timeRange=n??
|
|
6
|
-
`).slice(0,-1):Array.from(this).map(e=>e.toString())}parseJSON(e){if(!this.dataType.equals(K.JSON))throw Error(`cannot parse non-JSON series as JSON`);return this.toStrings().map(t=>e.parse(Se.decodeString(t)))}get byteCapacity(){return new q(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Y?this.byteCapacity:this.dataType.isVariable?new q(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this.cachedLength==null?this.dataType.isVariable?this.calculateCachedLength():this.writePos===Y?this.byteCapacity.valueOf()/this.dataType.density.valueOf():this.writePos:this.cachedLength}calculateCachedLength(){if(!this.dataType.isVariable)throw Error(`cannot calculate length of a non-variable length data type`);let e=0,t=[0];return this.data.forEach((n,r)=>{n===Ra&&(e++,t.push(r+1))}),this._cachedIndexes=t,this.cachedLength=e,e}convert(t,n=0){if(this.dataType.equals(t))return this;let r=new t.Array(this.length);for(let e=0;e<this.length;e++)r[e]=fa(this.dataType,t,this.data[e],n);return new e({data:r.buffer,dataType:t,timeRange:this.timeRange,sampleOffset:n,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){return this.length===0?-1/0:(this.dataType.equals(K.TIMESTAMP)?this.cachedMax=this.data[this.data.length-1]:(this.dataType.usesBigInt,this.cachedMax=this.data.reduce((e,t)=>e>t?e:t)),this.cachedMax)}get max(){return this.calcMax()}calcMax(){if(this.dataType.isVariable)throw Error(`cannot calculate maximum on a variable length data type`);return this.writePos===0?-1/0:(this.cachedMax??=this.calcRawMax(),x(this.cachedMax,this.sampleOffset))}calcRawMin(){return this.length===0?1/0:(this.dataType.equals(K.TIMESTAMP)?this.cachedMin=this.data[0]:(this.dataType.usesBigInt,this.cachedMin=this.data.reduce((e,t)=>e<t?e:t)),this.cachedMin)}get min(){return this.calcMin()}calcMin(){if(this.dataType.isVariable)throw Error(`cannot calculate minimum on a variable length data type`);return this.writePos===0?1/0:(this.cachedMin??=this.calcRawMin(),x(this.cachedMin,this.sampleOffset))}get bounds(){return C(Number(this.min),Number(this.max),{makeValid:!1})}maybeRecomputeMinMax(e){if(this.cachedMin!=null){let t=e.cachedMin??e.calcRawMin();t<this.cachedMin&&(this.cachedMin=t)}if(this.cachedMax!=null){let t=e.cachedMax??e.calcRawMax();t>this.cachedMax&&(this.cachedMax=t)}}atAlignment(e,t){let n=Number((e-this.alignment)/this.alignmentMultiple);if(n<0||n>=this.length){if(t===!0)throw Error(`[series] - no value at index ${n}`);return}return this.at(n,t)}at(e,t=!1){if(this.dataType.isVariable)return this.atVariable(e,t??!1);if(this.dataType.equals(K.UUID))return this.atUUID(e,t);e<0&&(e=this.length+e);let n=this.data[e];if(n==null){if(t===!0)throw Error(`[series] - no value at index ${e}`);return}return x(n,this.sampleOffset)}atUUID(e,t){e<0&&(e=this.length+e);let n=Na(new Uint8Array(this.buffer,e*this.dataType.density.valueOf()));if(n==null){if(t)throw Error(`[series] - no value at index ${e}`);return}return n}atVariable(e,t){let n=0,r=0;if(this._cachedIndexes!=null)n=this._cachedIndexes[e],r=this._cachedIndexes[e+1]-1;else{e<0&&(e=this.length+e);for(let t=0;t<this.data.length;t++)if(this.data[t]===Ra){if(e===0){r=t;break}n=t+1,e--}if(r===0&&(r=this.data.length),n>=r||e>0){if(t)throw Error(`[series] - no value at index ${e}`);return}}let i=this.data.slice(n,r);return this.dataType.equals(K.STRING)?new TextDecoder().decode(i):le(JSON.parse(new TextDecoder().decode(i)))}binarySearch(e){let t=0,n=this.length-1,r=Ne(e);for(;t<=n;){let i=Math.floor((t+n)/2),a=r(this.at(i,!0),e);if(a===0)return i;a<0?t=i+1:n=i-1}return t}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(K.FLOAT32)&&!this.dataType.equals(K.UINT8))throw Error(`Only FLOAT32 and UINT8 arrays can be used in WebGL`);let{buffer:t,bufferUsage:n,prevBuffer:r}=this.gl;if(t??(this.gl.buffer=e.createBuffer()),this.writePos!==r)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Y){r===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);let t=this.dataType.density.size(r).valueOf(),n=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,t,n.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,n===`static`?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=Y}as(e){return za(e,this.dataType),this}get digest(){return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:Qa(this.alignmentBounds.lower),upper:Qa(this.alignmentBounds.upper),multiple:this.alignmentMultiple},timeRange:this.timeRange.toString(),length:this.length,capacity:this.capacity}}get alignmentBounds(){return C(this.alignment,this.alignment+BigInt(this.length)*this.alignmentMultiple)}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 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){let e=new Ga(this);return this.dataType.equals(K.JSON)?new Ka(e):e}return this.dataType.equals(K.UUID)?new qa(this):new Ja(this)}slice(e,t){return this.sliceSub(!1,e,t)}sub(e,t){return this.sliceSub(!0,e,t)}subIterator(e,t){return new Wa(this,e,t??this.length)}subAlignmentIterator(e,t){let n=Math.ceil(Number(e-this.alignment)/Number(this.alignmentMultiple)),r=Math.ceil(Number(t-this.alignment)/Number(this.alignmentMultiple));return new Wa(this,n,r)}subBytes(t,n){return t>=0&&(n==null||n>=this.byteLength.valueOf())?this:new e({data:this.data.subarray(t,n),dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(t)})}sliceSub(t,n,r){if(n<=0&&(r==null||r>=this.length))return this;let i;return i=t?this.data.subarray(n,r):this.data.slice(n,r),new e({data:i,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(n)})}reAlign(t){return new e({data:this.buffer,dataType:this.dataType,timeRange:G.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:`static`,alignment:t})}toString(){let e=`Series(${this.dataType.toString()} ${this.length} [`;if(this.length<=10)e+=Array.from(this).map(e=>e.toString());else{for(let t=0;t<5;t++)e+=`${this.at(t)?.toString()}`,e+=`,`;e+=`...,`;for(let t=-5;t<0;t++)e+=this.at(t)?.toString(),t<-1&&(e+=`,`)}return e+=`])`,e}},Ha=e=>e==null?!1:Array.isArray(e)||e instanceof ArrayBuffer||ArrayBuffer.isView(e)&&!(e instanceof DataView)||e instanceof Va?!0:da(e),Ua=nt(Ba,Va),Wa=class{series;end;index;constructor(e,t,n){this.series=e;let r=C(0,e.length+1);this.end=nn(r,n),this.index=nn(r,t)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}},Ga=class{series;index;decoder;constructor(e){if(!e.dataType.isVariable)throw Error(`cannot create a variable series iterator for a non-variable series`);this.series=e,this.index=0,this.decoder=new TextDecoder}next(){let e=this.index,t=this.series.data;for(;this.index<t.length&&t[this.index]!==Ra;)this.index++;let n=this.index;return e===n?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,n))})}},Ka=class e{wrapped;static schema=l.z.record(l.z.string(),l.z.unknown());constructor(e){this.wrapped=e}next(){let t=this.wrapped.next();return t.done===!0?{done:!0,value:void 0}:{done:!1,value:Se.decodeString(t.value,e.schema)}}},qa=class{series;index;data;density;constructor(e){if(!e.dataType.equals(K.UUID))throw Error(`cannot create a UUID series iterator for a non-UUID series`);this.series=e,this.index=0,this.data=new Uint8Array(e.buffer),this.density=K.UUID.density.valueOf()}next(){if(this.index>=this.series.length)return{done:!0,value:void 0};let e=Na(this.data,this.index*this.density);return this.index++,{done:!1,value:e}}},Ja=class{series;index;constructor(e){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)}}},Ya=class{series;constructor(e=[]){if(e.length!==0){let t=e[0].dataType;for(let n=1;n<e.length;n++)if(!e[n].dataType.equals(t))throw Error(`[multi-series] - series must have the same data type`)}this.series=e}as(e){return za(e,this.dataType),this}get dataType(){return this.series.length===0?K.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?G.ZERO:new G(this.series[0].timeRange.start,this.series[this.series.length-1].timeRange.end)}get alignment(){return this.series.length===0?0n:this.series[0].alignment}get alignmentBounds(){return this.series.length===0?C(0n,0n):C(this.series[0].alignmentBounds.lower,this.series[this.series.length-1].alignmentBounds.upper)}push(e){let t=()=>Error(`cannot push a ${e.dataType.toString()} series to a ${this.dataType.toString()} multi-series`),n=e.dataType.equals(this.dataType);if(Ua(e)){if(this.series.length!==0&&!n)throw t();this.series.push(e)}else{if(this.series.length!==0&&e.series.length!==0&&!n)throw t();this.series.push(...e.series)}}get length(){return this.series.reduce((e,t)=>e+t.length,0)}atAlignment(e,t){for(let n of this.series)if(w(n.alignmentBounds,e))return n.atAlignment(e,t);if(t)throw Error(`[series] - no value at alignment ${e}`)}at(e,t=!1){e<0&&(e=this.length+e);for(let n of this.series){if(e<n.length)return n.at(e,t);e-=n.length}if(t)throw Error(`[series] - no value at index ${e}`)}subIterator(e,t){return new Za(this,e,t??this.length)}subAlignmentIterator(e,t){if(e>=this.alignmentBounds.upper||t<=this.alignmentBounds.lower)return Fa;let n=0;for(let t=0;t<this.series.length;t++){let r=this.series[t];if(e<r.alignment)break;if(e>=r.alignmentBounds.upper)n+=r.length;else if(w(r.alignmentBounds,e)){n+=Math.ceil(Number(e-r.alignment)/Number(r.alignmentMultiple));break}}let r=0;for(let e=0;e<this.series.length;e++){let n=this.series[e];if(t<n.alignment)break;if(t>=n.alignmentBounds.upper)r+=n.length;else if(w(n.alignmentBounds,t)){r+=Math.ceil(Number(t-n.alignment)/Number(n.alignmentMultiple));break}}return new Za(this,n,r)}subAlignmentSpanIterator(e,t){if(e>=this.alignmentBounds.upper)return Fa;t=Math.min(t,Number(this.distance(e,this.alignmentBounds.upper)));let n=0;for(let t=0;t<this.series.length;t++){let r=this.series[t];if(e<r.alignment)break;if(e>=r.alignmentBounds.upper)n+=r.length;else if(w(r.alignmentBounds,e)){n+=Number(e-r.alignment);break}}return new Za(this,n,n+t)}updateGLBuffer(e){this.series.forEach(t=>t.updateGLBuffer(e))}get bounds(){return un(this.series.map(e=>e.bounds))}get byteLength(){return new q(this.series.reduce((e,t)=>e+t.byteLength.valueOf(),0))}get data(){let e=new this.dataType.Array(this.length),t=0;for(let n of this.series)e.set(n.data,t),t+=n.length;return new this.dataType.Array(e.buffer)}traverseAlignment(e,t){return gn(this.series.map(e=>e.alignmentBounds),e,t)}acquire(e){this.series.forEach(t=>t.acquire(e))}release(){this.series.forEach(e=>e.release())}distance(e,t){return _n(this.series.map(e=>e.alignmentBounds),e,t)}parseJSON(e){if(!this.dataType.equals(K.JSON))throw Error(`cannot parse non-JSON series as JSON`);return this.series.flatMap(t=>t.parseJSON(e))}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new Xa(this.series)}toStrings(){return this.series.flatMap(e=>e.toStrings())}},Xa=class{series;seriesIndex;internal;constructor(e){this.series=e,this.seriesIndex=0,this.internal=e[0][Symbol.iterator]()}next(){let e=this.internal.next();return e.done===!1?e:this.seriesIndex===this.series.length-1?{done:!0,value:void 0}:(this.internal=this.series[++this.seriesIndex][Symbol.iterator](),this.next())}[Symbol.iterator](){return this}},Za=class{series;index;end;constructor(e,t,n){this.series=e,this.end=n,this.index=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}},Qa=e=>({domain:e>>32n,sample:e&4294967295n}),$a=o({DataType:()=>K,Density:()=>W,MultiSeries:()=>Ya,Rate:()=>U,Series:()=>Va,Size:()=>q,TimeRange:()=>G,TimeSpan:()=>H,TimeStamp:()=>V,convertDataType:()=>fa,dataTypeZ:()=>va,isCrudeSeries:()=>Ha,isTelemValue:()=>da,numericTimeRangeZ:()=>la,rateZ:()=>ga,sizeZ:()=>_a,timeRangeBoundedZ:()=>ya,timeRangeZ:()=>pa,timeSpanZ:()=>ha,timeStampZ:()=>ma,typedArrayZ:()=>ua}),eo=o({sleep:()=>to}),to=async e=>await new Promise(t=>setTimeout(t,H.fromMilliseconds(e).milliseconds)),no=o({Breaker:()=>ro,breakerConfigZ:()=>io}),ro=class{config;retries;interval;constructor(e){this.config={baseInterval:new H(e?.baseInterval??H.seconds(1)),maxRetries:e?.maxRetries??5,scale:e?.scale??1,sleepFn:e?.sleepFn??to},this.retries=0,this.interval=new H(this.config.baseInterval)}async wait(){let{maxRetries:e,scale:t,sleepFn:n}=this.config;return this.retries>=e?!1:(await n(this.interval),this.interval=this.interval.mult(t),this.retries++,!0)}get retryMessage(){return`breaker triggered ${this.retries+1}/${this.config.maxRetries} times, retrying in ${this.interval.toString()}`}reset(){this.retries=0,this.interval=this.config.baseInterval}},io=l.z.object({baseInterval:H.z.optional(),maxRetries:l.z.number().optional(),scale:l.z.number().optional()}),ao=o({Z:()=>oo}),oo=e=>l.z.object({variant:l.z.enum([`set`,`delete`]),key:l.z.string(),value:e}),so=e=>e.nullable().transform(e=>e===null?void 0:e).optional(),co=l.z.int().min(lt).max(127),lo=l.z.int().min(ut).max(dt),uo=l.z.int().min(gt).max(_t),fo=l.z.int().min(0).max(255),po=l.z.int().min(0).max(rt),mo=l.z.int().min(0).max(it),ho=l.z.int().min(0).max(at),go=e=>l.default.array(e).or(e.transform(e=>[e])),_o=e=>{try{return structuredClone(e)}catch{return console.warn(`Failed to deep copy object, falling back to JSON.parse(JSON.stringify)`,e),console.trace(),JSON.parse(JSON.stringify(e))}},vo=(e,t,n=``)=>{let r={},i=(e,t,n)=>{if(typeof e!=typeof t||e===null||t===null){r[n]=[e,t];return}if(typeof e==`object`&&typeof t==`object`)if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length){r[n]=[e,t];return}for(let r=0;r<e.length;r++)i(e[r],t[r],`${n}[${r}]`)}else new Set([...Object.keys(e),...Object.keys(t)]).forEach(r=>{i(e[r],t[r],n===``?r:`${n}.${r}`)});else e!==t&&(r[n]=[e,t])};return i(e,t,n),r},yo=(e,t)=>{let n=Array.isArray(e),r=Array.isArray(t);if(n!==r)return!1;if(n&&r){let n=e,r=t;if(n.length!==r.length)return!1;for(let e=0;e<n.length;e++)if(!yo(n[e],r[e]))return!1;return!0}if(e==null||t==null||typeof e!=`object`||typeof t!=`object`)return e===t;if(`equals`in e)return e.equals(t);let i=Object.keys(e),a=Object.keys(t);if(i.length!==a.length)return!1;for(let n of i){let r=e[n],i=t[n];if(typeof r==`object`&&typeof i==`object`){if(!yo(r,i))return!1}else if(r!==i)return!1}return!0},bo=(e,t)=>{if(typeof e!=`object`||!e)return e===t;let n=Object.keys(e),r=Object.keys(t);if(r.length>n.length)return!1;for(let n of r){let r=e[n],i=t[n];if(typeof r==`object`&&typeof i==`object`){if(!bo(r,i))return!1}else if(r!==i)return!1}return!0},xo=(e,t,n=`.`)=>{let r=e.split(n);return r.map((e,i)=>{let a=t(e,i,r);return a==null?null:typeof a==`string`?a:a.join(n)}).filter(e=>e!=null).join(n)},X=(e,t)=>{if(!Array.isArray(e))return e[t];let n=e[t];if(n!=null||e.length==0)return n;let r=e[0];if(typeof r==`object`&&`key`in r)return e.find(e=>e.key===t)},So=(e,t)=>{let n=e.split(`.`);return n.forEach((e,r)=>{t=X(t,e),typeof t==`object`&&t&&`key`in t&&(n[r]=t.key)}),n.join(`.`)},Co=(e,t)=>{let n=e.split(`.`);return t<0?n[n.length+t]:n[t]},wo=(e,t)=>{if(t.length===0)return!0;let n=e.split(`.`),r=t.split(`.`);if(r.length>n.length)return!1;for(let e=0;e<r.length;e++){let t=n[e],i=r[e];if(i!==`*`&&t!==i)return!1}return!0},Z=e=>{let t=parseInt(e,10);return isNaN(t)||t<0||t.toString()!==e?null:t},To=(e,t)=>{for(let n=1;n<=t.length;n++){let r=t.slice(0,n).join(`.`);if(X(e,r)!=null)return[r,n]}return null},Eo=((e,t,n={optional:!1})=>{let{optional:r,getter:i=X}=n;if(t===``)return e;let a=t.split(`.`);if(a.length===1){let n=i(e,a[0]);if(n===void 0){if(r)return null;throw Error(`Path ${t} does not exist. ${a[0]} is undefined`)}return n}let o=(e,n)=>{if(n>=a.length)return e;for(let s=a.length-n;s>=1;s--){let c=a.slice(n,n+s).join(`.`),l=i(e,c);if(l!==void 0){if(n+s===a.length)return l;if(l===null){if(r)return null;throw Error(`Path ${t} does not exist. ${c} is null`)}return o(l,n+s)}}if(r)return null;throw Error(`Path ${t} does not exist. ${a[n]} is undefined`)};return o(e,0)}),Do=(e,t)=>Eo(e,t,{optional:!0})!==null,Oo=(e,...t)=>{if(t.length===0)return e;let n=t.shift();if(g(e)&&g(n))for(let t in n)try{g(n[t])?(t in e||Object.assign(e,{[t]:{}}),Oo(e[t],n[t])):Object.assign(e,{[t]:n[t]})}catch(e){throw e instanceof TypeError?TypeError(`.${t}: ${e.message}`,{cause:e}):e}return Oo(e,...t)},ko=(e,t,n)=>{let r=(e,t,n)=>{if(n.def?.type===`union`)return n.def.options.reduce((e,n)=>r(e,t,n),e);if(n.def?.type===`intersection`)return r(r(e,t,n.def.left),t,n.def.right);for(let i in t){let a=t[i],o=n?.shape;if(o!=null)for(;o!=null;){if(o[i]!=null){let t=o[i].safeParse(a);if(t.success){e[i]=t.data;break}}o=o.def?.shape}typeof a==`object`&&!Array.isArray(a)&&a!==null&&n&&n.shape&&n.shape[i]&&(e[i]||={},r(e[i],a,n.shape[i]))}return e};return r({...e},t,n)},Ao=(e,t)=>{let n=t.split(`.`),r=e,i=0;for(;i<n.length;){if(i===n.length-1){let e=n[i];if(Array.isArray(r)){let t=parseInt(e,10);if(!isNaN(t)&&t<r.length){r.splice(t,1);return}let n=r[0];if(typeof n==`object`&&`key`in n){let t=r.findIndex(t=>t.key===e);if(t!==-1){r.splice(t,1);return}}return}delete r[e];return}let e=!1;if(Array.isArray(r)&&r.length>0){let t=r[0];if(typeof t==`object`&&`key`in t)for(let t=n.length-i;t>=1;t--){let a=n.slice(i,i+t).join(`.`),o=r.find(e=>e.key===a);if(o!=null){if(i+t===n.length){let e=r.findIndex(e=>e.key===a);e!==-1&&r.splice(e,1);return}r=o,i+=t,e=!0;break}}}if(!e)for(let t=n.length-i;t>=1;t--){let a=n.slice(i,i+t).join(`.`);if(!Array.isArray(r)&&typeof r==`object`&&r&&a in r){if(i+t===n.length){delete r[a];return}r=r[a],i+=t,e=!0;break}}if(!e){let e=X(r,n[i]);if(e==null)return;r=e,i++}}},jo=(e,t,n)=>{let r=t.split(`.`),i=e,a=0;for(;a<r.length-1;){let e=To(i,r.slice(a,r.length-1)),t;e==null?(t=r[a],a++):[t,a]=[e[0],a+e[1]];let n=X(i,t);if(n==null){let e=r[a],o=Z(e);o==null&&e.startsWith(`-`)&&Z(e.substring(1))!=null&&(o=0),n=o==null?{}:[],i[t]=n}i=n}try{let e=r[r.length-1];if(Array.isArray(i)){let t=Z(e);if(t==null){if(e.startsWith(`-`)){let n=Z(e.substring(1));n!=null&&(t=i.length-n)}if(t==null){if(i.length===0){let t=Z(e);if(t!=null){i[t]=n;return}}let t=i[0];if(typeof t==`object`&&`key`in t){let t=i.findIndex(t=>t.key===e);if(t!==-1){i[t]=n;return}}return}}i[t]=n;return}let t=To(i,[e]);if(t!=null){i[t[0]]=n;return}i[e]=n}catch(r){throw console.error(`failed to set value`,n,`at path`,t,`on object`,e),r}},Mo=o({SEPARATOR:()=>`.`,copy:()=>_o,defaultGetter:()=>X,difference:()=>vo,element:()=>Co,equal:()=>yo,findBestKey:()=>To,get:()=>Eo,getIndex:()=>Z,has:()=>Do,override:()=>Oo,overrideValidItems:()=>ko,partialEqual:()=>bo,pathsMatch:()=>wo,remove:()=>Ao,resolvePath:()=>So,set:()=>jo,transformPath:()=>xo}),No=e=>e._zod.def.output,Po=e=>xo(e,(e,t,n)=>{let r=t===n.length-1,i=!isNaN(parseInt(e,10)),a=!isNaN(parseInt(n[t+1],10));return i&&(e=`element`),r||a?e:[e,`shape`]}),Fo=(e,t)=>{if(e==null)return null;let n=e[t];return n==null&&typeof e==`object`&&`sourceType`in e?e.sourceType()[t]:n},Io=((e,t,n)=>t===``?e:Eo(Fo(e,`shape`),Po(t),{...n,getter:Fo})),Lo=o({functionOutput:()=>No,getFieldSchema:()=>Io,getFieldSchemaPath:()=>Po,int16:()=>lo,int64:()=>uo,int8:()=>co,nullToUndefined:()=>so,toArray:()=>go,uint12:()=>po,uint16:()=>mo,uint20:()=>ho,uint8:()=>fo}),Ro=l.z.string().regex(/^#?([0-9a-f]{6}|[0-9a-f]{8})$/i),Q=fo,zo=l.z.number().min(0).max(1),Bo=l.z.tuple([Q,Q,Q,zo]),Vo=l.z.tuple([Q,Q,Q]),Ho=l.z.object({rgba255:Bo}),Uo=l.z.object({r:Q,g:Q,b:Q,a:zo}),Wo=l.z.number().min(0).max(360),Go=l.z.number().min(0).max(100),Ko=l.z.number().min(0).max(100),qo=l.z.tuple([Wo,Go,Ko,zo]),Jo=l.z.union([Ro,Vo,Bo,qo,Ho,Uo]),Yo=Jo.transform(e=>$(e)),Xo=e=>Yo.safeParse(e).success,Zo=e=>Bo.safeParse(e).success,Qo=(e=>{if(e==null)return;let t=Yo.safeParse(e);if(t.success)return ts(t.data);if(typeof e==`string`)return e;throw t.error}),$=(e,t=1)=>{if(e=Jo.parse(e),typeof e==`string`)return ys(e,t);if(Array.isArray(e)){if(e.length<3||e.length>4)throw Error(`Invalid color: [${e.join(`, `)}]`);return e.length===3?[...e,t]:e}return`a`in e&&`r`in e?[e.r,e.g,e.b,e.a]:e.rgba255},$o=(e,t)=>{if(e==null||t==null)return e==t;let n=$(e),r=$(t);return n.every((e,t)=>e===r[t])},es=(e=>{if(e==null)return;let[t,n,r,i]=$(e),a=Math.round(i*255);return`#${xs(t)}${xs(n)}${xs(r)}${a===255?``:xs(a)}`}),ts=e=>{let[t,n,r,i]=$(e);return`rgba(${t}, ${n}, ${r}, ${i})`},ns=e=>`rgb(${rs(e)})`,rs=e=>{let[t,n,r]=$(e);return`${t}, ${n}, ${r}`},is=e=>[...as(e),ls(e)],as=e=>[os(e)/255,ss(e)/255,cs(e)/255],os=e=>$(e)[0],ss=e=>$(e)[1],cs=e=>$(e)[2],ls=e=>$(e)[3],us=e=>$o(bs,e),ds=e=>Os($(e)),fs=(e,t)=>{let[n,r,i]=$(e);if(t>100)throw Error(`Color opacity must be between 0 and 100, got ${t}`);return t>1&&(t/=100),[n,r,i,t]},ps=e=>{let[t,n,r]=as(e).map(e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4);return Number((.2126*t+.7152*n+.0722*r).toFixed(3))},ms=e=>{let[t,n,r]=as(e);return 1-(Math.max(t,n,r)-Math.min(t,n,r))},hs=(e,t)=>{let n=$(e),r=$(t),i=ps(n),a=ps(r);return(Math.max(i,a)+.5)/(Math.min(i,a)+.5)},gs=(e,...t)=>{if(t.length===0)throw Error(`[Color.pickByContrast] - must provide at least one color`);let n=$(e),[r]=t.sort((e,t)=>hs(n,t)-hs(n,e));return $(r)},_s=e=>ps(e)<.5,vs=e=>ps(e)>.5,ys=(e,t=1)=>(e=Ro.parse(e),e=Cs(e),[Ss(e,0),Ss(e,2),Ss(e,4),e.length===8?Ss(e,6)/255:t]),bs=[0,0,0,0],xs=e=>Math.floor(e).toString(16).padStart(2,`0`),Ss=(e,t)=>parseInt(e.slice(t,t+2),16),Cs=e=>e.startsWith(`#`)?e.slice(1):e,ws={black:`#000000`,white:`#ffffff`,red:`#ff0000`,green:`#008000`,blue:`#0000ff`,yellow:`#ffff00`,cyan:`#00ffff`,magenta:`#ff00ff`,silver:`#c0c0c0`,gray:`#808080`,grey:`#808080`,maroon:`#800000`,olive:`#808000`,lime:`#00ff00`,aqua:`#00ffff`,teal:`#008080`,navy:`#000080`,fuchsia:`#ff00ff`,purple:`#800080`,orange:`#ffa500`,brown:`#a52a2a`,tan:`#d2b48c`,gold:`#ffd700`,indigo:`#4b0082`,violet:`#ee82ee`,pink:`#ffc0cb`,coral:`#ff7f50`,salmon:`#fa8072`,khaki:`#f0e68c`,crimson:`#dc143c`,transparent:`transparent`},Ts=e=>{if(!e)return;let t=e.trim().toLowerCase();if(!(t===`transparent`||t===`none`)){if(t.startsWith(`#`)){if(t.length===4){let e=t[1],n=t[2],r=t[3],i=`#${e}${e}${n}${n}${r}${r}`;if(Ro.safeParse(i).success)return ys(i)}return(t.length===7||t.length===9)&&Ro.safeParse(t).success?ys(t):void 0}if(t.startsWith(`rgb`)){let e=t.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/);if(e){let[,t,n,r,i]=e;return[parseInt(t,10),parseInt(n,10),parseInt(r,10),i?parseFloat(i):1]}}if(ws[t])return ys(ws[t])}},Es=e=>{e=qo.parse(e);let[t,n,r]=e,i=e[3];t/=360,n/=100,r/=100;let a,o,s;if(n===0)a=o=s=r;else{let e=r<.5?r*(1+n):r+n-r*n,i=2*r-e;a=Ds(i,e,t+1/3),o=Ds(i,e,t),s=Ds(i,e,t-1/3)}return[Math.round(a*255),Math.round(o*255),Math.round(s*255),i]},Ds=(e,t,n)=>(n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e),Os=e=>{e=Bo.parse(e);let[t,n,r]=e,i=e[3];t/=255,n/=255,r/=255;let a=Math.max(t,n,r),o=Math.min(t,n,r),s,c,l=(a+o)/2;if(a===o)s=c=0;else{let e=a-o;c=l>.5?e/(2-a-o):e/(a+o),s=a===t?(n-r)/e+(n<r?6:0):a===n?(r-t)/e+2:(t-n)/e+4,s/=6}return s*=360,c*=100,l*=100,[Math.round(s),Math.round(c),Math.round(l),i]},ks=$(`#000000`),As=$(`#ffffff`),js=l.z.object({key:l.z.string(),color:Jo,position:l.z.number(),switched:l.z.boolean().optional()}),Ms=l.z.array(js),Ns=(e,t)=>{if(e.length===0)return bs;if(e=e.slice().sort((e,t)=>e.position-t.position),t<=e[0].position)return $(e[0].color);if(t>=e[e.length-1].position)return $(e[e.length-1].color);for(let n=0;n<e.length-1;n++){let r=e[n],i=e[n+1];if(t<r.position||t>i.position)continue;if(t===r.position)return $(r.color);if(t===i.position)return $(i.color);let a=(t-r.position)/(i.position-r.position),o=$(r.color),s=$(i.color);return $([Math.round(os(o)+a*(os(s)-os(o))),Math.round(ss(o)+a*(ss(s)-ss(o))),Math.round(cs(o)+a*(cs(s)-cs(o))),ls(o)+a*(ls(s)-ls(o))])}return $(e[e.length-1].color)},Ps=l.z.object({key:l.z.string(),name:l.z.string(),color:Yo}),Fs=l.z.object({key:l.z.string(),name:l.z.string(),swatches:l.z.array(Ps)}),Is=o({BLACK:()=>ks,WHITE:()=>As,ZERO:()=>bs,aValue:()=>ls,bValue:()=>cs,colorZ:()=>Yo,construct:()=>$,contrast:()=>hs,crudeZ:()=>Jo,cssString:()=>Qo,equals:()=>$o,fromCSS:()=>Ts,fromGradient:()=>Ns,fromHSLA:()=>Es,gValue:()=>ss,gradientZ:()=>Ms,grayness:()=>ms,hex:()=>es,hsla:()=>ds,isColor:()=>Zo,isCrude:()=>Xo,isDark:()=>_s,isLight:()=>vs,isZero:()=>us,luminance:()=>ps,paletteZ:()=>Fs,pickByContrast:()=>gs,rValue:()=>os,rgbCSS:()=>ns,rgbString:()=>rs,rgba1:()=>is,rgbaCSS:()=>ts,setAlpha:()=>fs,stopZ:()=>js}),Ls=fo,Rs=function(e){return e[e.exclusive=0]=`exclusive`,e[e.shared=1]=`shared`,e}({}),zs=l.z.enum(Rs),Bs=l.z.object({key:l.z.string(),name:l.z.string(),group:l.z.uint32().optional()}),Vs=e=>l.z.object({subject:Bs,resource:e,authority:Ls}),Hs={lower:0,upper:256},Us=(...e)=>t=>t.filter(t=>{let n=!1;return t.to!=null&&(n=e.includes(t.to.resource)),t.from!=null&&!n&&(n=e.includes(t.from.resource)),n}),Ws=e=>l.z.object({from:Vs(e),to:l.z.null().optional()}),Gs=e=>l.z.object({from:l.z.null().optional(),to:Vs(e)}),Ks=e=>l.z.union([Ws(e),Gs(e),l.z.object({from:Vs(e),to:Vs(e)})]),qs=o({ABSOLUTE_AUTHORITY:()=>255,AUTHORITY_BOUNDS:()=>Hs,Concurrency:()=>Rs,ZERO_AUTHORITY:()=>0,acquireZ:()=>Gs,authorityZ:()=>Ls,concurrencyZ:()=>zs,filterTransfersByChannelKey:()=>Us,releaseZ:()=>Ws,stateZ:()=>Vs,subjectZ:()=>Bs,transferZ:()=>Ks}),Js=o({formatValue:()=>Ys}),Ys=e=>{switch(typeof e){case`bigint`:case`number`:return e.toString();case`boolean`:return e?`1`:`0`;case`undefined`:return``;case`string`:case`symbol`:case`function`:return Zs(e.toString());case`object`:return e==null?``:Zs(JSON.stringify(e))}},Xs=/[",\n]/,Zs=e=>Xs.test(e)?`"${e.replace(/"/g,`""`)}"`:e,Qs=(e,t)=>{let n=null;return t===0?e:(...r)=>{n!==null&&(clearTimeout(n),n=null),n=setTimeout(()=>e(...r),t)}},$s=(e,t)=>{let n=null;return t===0?e:(...r)=>{n===null&&(n=setTimeout(()=>{e(...r),n=null},t))}},ec=o({}),tc=e=>Object.getOwnPropertySymbols(globalThis).includes(e),nc=(e,t)=>{let n=Symbol.for(e);if(!tc(n)){let e=t();Object.defineProperty(globalThis,n,{value:e})}return()=>globalThis[n]},rc=o({Canceled:()=>gc,NONE:()=>`nil`,NotImplemented:()=>_c,UNKNOWN:()=>cc,Unknown:()=>mc,createTyped:()=>oc,decode:()=>pc,encode:()=>fc,isTyped:()=>sc,payloadZ:()=>hc,register:()=>dc}),ic=`sy_x_error`,ac=e=>t=>typeof t==`object`&&t&&`type`in t&&typeof t.type==`string`?t.type.startsWith(e):t instanceof Error?t.message.startsWith(e):typeof t==`string`?t.startsWith(e):!1,oc=e=>class t extends Error{static discriminator=ic;discriminator=t.discriminator;static TYPE=e;type=t.TYPE;static matches=ac(e);matches=t.matches;constructor(e,n){super(e,n),this.name=t.TYPE}static sub(t){return oc(`${e}.${t}`)}},sc=e=>{if(typeof e!=`object`||!e)return!1;let t=e;if(t.discriminator!==ic)return!1;if(!(`type`in t))throw Error(`X Error is missing its type property: ${JSON.stringify(t)}`);return!0},cc=`unknown`,lc=class{providers=[];register(e){this.providers.push(e)}encode(e){if(e==null)return{type:`nil`,data:``};if(sc(e))for(let t of this.providers){let n=t.encode(e);if(n!=null)return n}if(e instanceof Error)return{type:cc,data:e.message};if(typeof e==`string`)return{type:cc,data:e};try{return{type:cc,data:JSON.stringify(e)}}catch{return{type:cc,data:`unable to encode error information`}}}decode(e){if(e==null||e.type===`nil`)return null;if(e.type===`unknown`)return new mc(e.data);for(let t of this.providers){let n=t.decode(e);if(n!=null)return n}return new mc(e.data)}},uc=nc(`synnax-error-registry`,()=>new lc),dc=({encode:e,decode:t})=>uc().register({encode:e,decode:t}),fc=e=>uc().encode(e),pc=e=>e==null?null:uc().decode(e),mc=class extends oc(`unknown`){},hc=l.z.object({type:l.z.string(),data:l.z.string()}),gc=class extends oc(`canceled`){},_c=class extends oc(`not_implemented`){},vc=o({ZERO_PRIMITIVES:()=>Sc,pointerZ:()=>yc,primitiveTypeZ:()=>xc,primitiveZ:()=>bc}),yc=l.z.string().regex(/^(?:$|(?:\/(?:[^~/]|~0|~1)*)+)$/,`must be a valid JSON pointer (RFC 6901)`),bc=l.z.union([l.z.string(),l.z.number(),l.z.boolean(),l.z.null()]),xc=l.z.enum([`string`,`number`,`boolean`,`null`]),Sc={string:``,number:0,boolean:!1,null:null},Cc=class{store=new Map;async get(e){return this.store.get(e)??null}async set(e,t){this.store.set(e,t)}async delete(e){this.store.delete(e)}async length(){return this.store.size}async clear(){this.store.clear()}},wc=class{store=new Map;get(e){return this.store.get(e)??null}set(e,t){this.store.set(e,t)}delete(e){this.store.delete(e)}},Tc=l.z.object({key:l.z.string(),value:l.z.string()}),Ec=o({MockAsync:()=>Cc,MockSync:()=>wc,stringPairZ:()=>Tc}),Dc=o({keyZ:()=>Oc,labelZ:()=>kc,newZ:()=>Ac}),Oc=l.z.uuid(),kc=l.z.object({key:Oc,name:l.z.string().min(1),color:Yo}),Ac=kc.partial({key:!0}),jc=o({is:()=>Nc}),Mc=RegExp(`^(https?:\\/\\/)?((([a-zA-Z0-9][a-zA-Z0-9-]*\\.)+[a-zA-Z]{2,})|localhost|(\\d{1,3}\\.){3}\\d{1,3})(\\:\\d+)?(\\/[-a-zA-Z0-9@:%._\\+~#=]*)*(\\?[;&a-zA-Z0-9%_.,~+=-]*)?(#[-a-zA-Z0-9_]*)?$`),Nc=e=>Mc.test(e),Pc=o({getOrSetDefault:()=>Fc}),Fc=(e,t,n)=>{let r=e.get(t);return r===void 0?(e.set(t,n),n):r},Ic=o({compareSemVer:()=>zc,createMigration:()=>Uc,migrator:()=>Wc,semVerNewer:()=>Vc,semVerOlder:()=>Hc,semVerZ:()=>Lc,versionsEqual:()=>Bc}),Lc=l.z.string().regex(/^\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/),Rc=(e,t)=>{let n=e.split(`.`),r=t.split(`.`),i=Math.max(n.length,r.length);for(let e=0;e<i;e++){let t=n[e],i=r[e];if(t===void 0)return-1;if(i===void 0)return 1;let a=/^\d+$/.test(t),o=/^\d+$/.test(i);if(a&&!o)return-1;if(!a&&o)return 1;if(a&&o){let e=parseInt(t,10),n=parseInt(i,10);if(e<n)return-1;if(e>n)return 1}else{if(t<i)return-1;if(t>i)return 1}}return 0},zc=((e,t,n={})=>{n.checkMajor??=!0,n.checkMinor??=!0,n.checkPatch??=!0;let r=Lc.parse(e),i=Lc.parse(t),[a,o]=r.split(`-`),[s,c]=i.split(`-`),[l,u,d]=a.split(`.`).map(Number),[f,p,m]=s.split(`.`).map(Number);if(n.checkMajor){if(l<f)return-1;if(l>f)return 1}if(n.checkMinor){if(u<p)return-1;if(u>p)return 1}if(n.checkPatch){if(d<m)return-1;if(d>m)return 1}return o===void 0&&c===void 0?0:o===void 0?1:c===void 0?-1:Rc(o,c)}),Bc=(e,t,n={})=>Ue(zc(e,t,n)),Vc=(e,t,n={})=>Ve(zc(e,t,n)),Hc=(e,t,n={})=>Be(zc(e,t,n)),Uc=({name:e,migrate:t})=>n=>{try{let r=t(n);return console.log(`${e} migrated: ${n.version} -> ${r.version}`),r}catch(t){throw console.log(`${e} failed to migrate from ${n.version}`),console.error(t),t}},Wc=({name:e,migrations:t,targetSchema:n,defaultVersion:r,def:i})=>{let a=Object.keys(t).sort(zc).pop();if(a==null)return t=>{if(t.version??=r,t.version!==i.version)return console.log(`${e} version ${t.version} is newer than latest version of ${i.version}.
|
|
11
|
+
`).map(e=>e.trim());if(n.length===0)return t==null?{}:t.parse({});let i=n.split(`,`).map(e=>e.trim()),a={};return i.forEach(e=>{a[e]=[]}),r.forEach(e=>{let t=e.split(`,`).map(e=>e.trim());i.forEach((e,n)=>{let r=this.parseValue(t[n]);r!=null&&a[e].push(r)})}),t==null?a:t.parse(a)}parseValue(e){if(e==null||e.length===0)return null;let t=Number(e);return isNaN(t)?e.startsWith(`"`)&&e.endsWith(`"`)?e.slice(1,-1):e:t}},pr=class{contentType=`text/plain`;encode(e){if(typeof e!=`string`)throw Error(`TextCodec.encode payload must be a string`);return new TextEncoder().encode(e)}decode(e,t){let n=new TextDecoder().decode(e);return t==null?n:t.parse(n)}},mr=new dr,hr=new fr,gr=new pr,_r=[mr],vr=o({by:()=>br,unique:()=>yr}),yr=e=>[...new Set(e)],br=(e,t,n=!0)=>{let r=new Map;return e.forEach(e=>{let i=t(e);if(r.has(i)){if(n)return;r.delete(i)}r.set(i,e)}),Array.from(r.values())},xr=(e,t=!1)=>{let n=ot(e)?`stringer`:typeof e,r;switch(n){case`string`:r=(e,t)=>e.localeCompare(t);break;case`stringer`:r=(e,t)=>e.toString().localeCompare(t.toString());break;case`number`:r=(e,t)=>Number(e)-Number(t);break;case`bigint`:r=(e,t)=>BigInt(e)-BigInt(t)>0n?1:-1;break;case`boolean`:r=(e,t)=>Number(e)-Number(t);break;case`undefined`:r=()=>0;break;default:return console.warn(`sortFunc: unknown type ${n}`),()=>-1}return t?Dr(r):r},Sr=(e,t,n)=>{let r=xr(t[e],n);return(t,n)=>r(t[e],n[e])},Cr=(e,t)=>e.length===t.length?e.every((e,n)=>e===t[n])?0:-1:e.length-t.length,wr=(e,t)=>{if(e.length!==t.length)return e.length-t.length;if(e.length===0)return 0;let n=xr(e[0]),r=[...e].sort(n),i=[...t].sort(n);return r.every((e,t)=>e===i[t])?0:-1},Tr=(e,t)=>wr(yr(e),yr(t)),Er=(e,t)=>e===t?0:e===`first`&&t===`last`?1:-1,Dr=e=>(t,n)=>e(n,t),Or=e=>e<0,kr=e=>e>0,Ar=e=>e>=0,jr=e=>e===0,Mr=(e,t)=>{let n=/([a-zA-Z]+)|(\d+)/g,r=e.replace(/[\s_.-]+/g,``).match(n),i=t.replace(/[\s_.-]+/g,``).match(n);if(!r||!i)return 0;for(let e=0;e<Math.min(r.length,i.length);e++){let t=r[e],n=i[e];if(isNaN(Number(t))&&isNaN(Number(n))){let e=t.localeCompare(n);if(e!==0)return e}else if(!isNaN(Number(t))&&!isNaN(Number(n))){let e=Number(t)-Number(n);if(e!==0)return e}else return isNaN(Number(t))?-1:1}return r.length-i.length},Nr=(e,t,n)=>{let r=0,i=e.length,a=n??xr(t);for(;r<i;){let n=Math.floor((r+i)/2),o=a(e[n],t);if(o===0)return n;o<0?r=n+1:i=n}return r},Pr=(e,t,n)=>{let r=Nr(e,t,n);e.splice(r,0,t)},Fr=o({EQUAL:()=>0,GREATER_THAN:()=>1,LESS_THAN:()=>-1,insert:()=>Pr,isEqualTo:()=>jr,isGreaterThan:()=>kr,isGreaterThanEqual:()=>Ar,isLessThan:()=>Or,newF:()=>xr,newFieldF:()=>Sr,order:()=>Er,primitiveArrays:()=>Cr,reverseF:()=>Dr,search:()=>Nr,stringsWithNumbers:()=>Mr,uniqueUnorderedPrimitiveArrays:()=>Tr,unorderedPrimitiveArrays:()=>wr}),Ir=(e,t=21)=>(n=t)=>{let r=``,i=n|0;for(;i--;)r+=e[Math.random()*e.length|0];return r},Lr=o({LENGTH:()=>11,create:()=>Hr}),Rr=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,zr=`0123456789${Rr}`,Br=Ir(Rr,1),Vr=Ir(zr,10),Hr=()=>`${Br()}${Vr()}`,Ur=o({createMatcher:()=>Wr}),Wr=(e,t)=>n=>n instanceof t||typeof n==`object`&&!!n&&`discriminator`in n&&n.discriminator===e,Gr=o({DIRECTIONS:()=>$t,construct:()=>O,crude:()=>Kr,dimension:()=>Jr,directionZ:()=>en,isDirection:()=>Xr,isX:()=>Qr,isY:()=>$r,location:()=>Yr,signedDimension:()=>Zr,swap:()=>qr}),Kr=bn,O=e=>$t.includes(e)?e:on.includes(e)?`y`:`x`,qr=e=>O(e)===`x`?`y`:`x`,Jr=e=>O(e)===`x`?`width`:`height`,Yr=e=>O(e)===`x`?`left`:`top`,Xr=e=>Kr.safeParse(e).success,Zr=e=>O(e)===`x`?`signedWidth`:`signedHeight`,Qr=e=>e===`center`?!1:O(e)===`x`,$r=e=>O(e)===`y`,ei=o({BOTTOM_CENTER:()=>vi,BOTTOM_LEFT:()=>mi,BOTTOM_RIGHT:()=>hi,CENTER:()=>gi,CENTER_LEFT:()=>bi,CENTER_LOCATIONS:()=>cn,CENTER_RIGHT:()=>yi,LOCATIONS:()=>un,OUTER_LOCATIONS:()=>tn,TOP_CENTER:()=>_i,TOP_LEFT:()=>A,TOP_RIGHT:()=>pi,XY_LOCATIONS:()=>xi,X_LOCATIONS:()=>rn,Y_LOCATIONS:()=>on,center:()=>ri,construct:()=>k,constructXY:()=>Oi,corner:()=>fi,crude:()=>si,direction:()=>ui,isX:()=>Ti,isY:()=>Ei,locationZ:()=>dn,outerZ:()=>ii,rotate:()=>li,swap:()=>ci,x:()=>ti,xy:()=>di,xyCouple:()=>wi,xyEquals:()=>Si,xyMatches:()=>Ci,xyToString:()=>Di,y:()=>ni}),ti=an,ni=sn,ri=ln,ii=nn,ai={top:`bottom`,right:`left`,bottom:`top`,left:`right`,center:`center`},oi={top:{clockwise:`left`,counterclockwise:`right`},right:{clockwise:`top`,counterclockwise:`bottom`},bottom:{clockwise:`right`,counterclockwise:`left`},left:{clockwise:`bottom`,counterclockwise:`top`}},si=xn,k=e=>e instanceof String||!$t.includes(e)?e:e===`x`?`left`:`top`,ci=e=>ai[k(e)],li=(e,t)=>oi[e][t],ui=e=>{let t=k(e);return t===`top`||t===`bottom`?`y`:`x`},di=l.z.object({x:an.or(ln),y:sn.or(ln)}),fi=l.z.object({x:an,y:sn}),A=Object.freeze({x:`left`,y:`top`}),pi=Object.freeze({x:`right`,y:`top`}),mi=Object.freeze({x:`left`,y:`bottom`}),hi=Object.freeze({x:`right`,y:`bottom`}),gi=Object.freeze({x:`center`,y:`center`}),_i=Object.freeze({x:`center`,y:`top`}),vi=Object.freeze({x:`center`,y:`bottom`}),yi=Object.freeze({x:`right`,y:`center`}),bi=Object.freeze({x:`left`,y:`center`}),xi=Object.freeze([bi,yi,_i,vi,A,pi,mi,hi,gi]),Si=(e,t)=>e.x===t.x&&e.y===t.y,Ci=(e,t)=>{if(typeof t==`object`){let n=!0;return`x`in t&&e.x!==t.x&&(n=!1),`y`in t&&e.y!==t.y&&(n=!1),n}return e.x===t||e.y===t},wi=e=>[e.x,e.y],Ti=e=>ui(k(e))===`x`,Ei=e=>ui(k(e))===`y`,Di=e=>`${e.x}${de(e.y)}`,Oi=(e,t)=>{let n,r;if(typeof e==`object`&&`x`in e?(n=e.x,r=e.y):(n=k(e),r=k(t??e)),ui(n)===ui(r)&&n!==`center`&&r!==`center`)throw Error(`[XYLocation] - encountered two locations with the same direction: ${n.toString()} - ${r.toString()}`);let i={...gi};return n===`center`?Ti(r)?[i.x,i.y]=[r,n]:[i.x,i.y]=[n,r]:Ti(n)?[i.x,i.y]=[n,r]:[i.x,i.y]=[r,n],i},ki=[`top`,`right`,`bottom`,`left`],Ai=l.z.enum(ki),j=l.z.object({x:l.z.number(),y:l.z.number()}),ji=o({INFINITY:()=>Pi,NAN:()=>Fi,ONE:()=>Ni,ZERO:()=>N,average:()=>$i,calculateMiters:()=>ea,clientXyZ:()=>gn,construct:()=>M,couple:()=>qi,crudeZ:()=>Mi,css:()=>Ji,distance:()=>Ui,equals:()=>Ii,isFinite:()=>Ki,isNan:()=>Gi,isZero:()=>Li,normal:()=>Zi,normalize:()=>Qi,reciprocal:()=>ra,rotate:()=>ia,round:()=>na,scale:()=>Ri,set:()=>Hi,sub:()=>Xi,swap:()=>ta,translate:()=>Vi,translateX:()=>zi,translateY:()=>Bi,translation:()=>Wi,truncate:()=>Yi,xyZ:()=>j}),Mi=l.z.union([l.z.number(),j,Qt,_n,vn,gn]),M=(e,t)=>{if(typeof e==`string`){if(t===void 0)throw Error(`The y coordinate must be given.`);return e===`x`?{x:t,y:0}:{x:0,y:t}}return typeof e==`number`?{x:e,y:t??e}:Array.isArray(e)?{x:e[0],y:e[1]}:`signedWidth`in e?{x:e.signedWidth,y:e.signedHeight}:`clientX`in e?{x:e.clientX,y:e.clientY}:`width`in e?{x:e.width,y:e.height}:{x:e.x,y:e.y}},N=Object.freeze({x:0,y:0}),Ni=Object.freeze({x:1,y:1}),Pi=Object.freeze({x:1/0,y:1/0}),Fi=Object.freeze({x:NaN,y:NaN}),Ii=(e,t,n=0)=>{let r=M(e),i=M(t);return n===0?r.x===i.x&&r.y===i.y:Math.abs(r.x-i.x)<=n&&Math.abs(r.y-i.y)<=n},Li=e=>Ii(e,N),Ri=(e,t,n)=>{let r=M(e),i=M(t,n);return{x:r.x*i.x,y:r.y*i.y}},zi=(e,t)=>{let n=M(e);return{x:n.x+t,y:n.y}},Bi=(e,t)=>{let n=M(e);return{x:n.x,y:n.y+t}},Vi=(e,t,n,...r)=>{if(typeof t==`string`){if(typeof n!=`number`)throw Error(`The value must be a number.`);return t===`x`?zi(e,n):Bi(e,n)}if(typeof t==`object`&&`x`in t&&typeof t.x==`string`){let r=M(n),i=M(e);return t.x===`left`?r.x=-r.x:t.x===`center`&&(r.x=0),t.y===`top`?r.y=-r.y:t.y===`center`&&(r.y=0),{x:i.x+r.x,y:i.y+r.y}}return[e,t,n??N,...r].reduce((e,t)=>{let n=M(t);return{x:e.x+n.x,y:e.y+n.y}},N)},Hi=(e,t,n)=>{let r=M(e);return O(t)===`x`?{x:n,y:r.y}:{x:r.x,y:n}},Ui=(e,t)=>{let n=M(e),r=M(t);return Math.sqrt((n.x-r.x)**2+(n.y-r.y)**2)},Wi=(e,t)=>{let n=M(e),r=M(t);return{x:r.x-n.x,y:r.y-n.y}},Gi=e=>{let t=M(e);return Number.isNaN(t.x)||Number.isNaN(t.y)},Ki=e=>{let t=M(e);return Number.isFinite(t.x)&&Number.isFinite(t.y)},qi=e=>{let t=M(e);return[t.x,t.y]},Ji=e=>{let t=M(e);return{left:t.x,top:t.y}},Yi=(e,t=0)=>{let n=M(e);return{x:Number(n.x.toFixed(t)),y:Number(n.y.toFixed(t))}},Xi=(e,t)=>{let n=M(e),r=M(t);return{x:n.x-r.x,y:n.y-r.y}},Zi=e=>{let t=M(e),n=Math.hypot(t.x,t.y);return n===0?{x:0,y:0}:{x:-t.y/n,y:t.x/n}},Qi=e=>{let t=M(e),n=Math.hypot(t.x,t.y);return n===0?{x:0,y:0}:{x:t.x/n,y:t.y/n}},$i=(...e)=>Ri(e.reduce((e,t)=>Vi(e,t),N),1/e.length),ea=(e,t)=>{let n=[];for(let r=0;r<e.length;r++){let i=e[r],a,o,s,c;if(r===0){let n=e[r+1];o=Zi(Xi(n,i)),s=o,c=t}else if(r===e.length-1){let n=e[r-1];a=Zi(Xi(i,n)),s=a,c=t}else{let n=e[r-1],l=e[r+1],u=Xi(i,n),d=Xi(l,i);a=Zi(u),o=Zi(d);let f=Math.acos((u.x*d.x+u.y*d.y)/(Math.hypot(u.x,u.y)*Math.hypot(d.x,d.y))),p=Math.sin(f/2);c=p===0?t:t/p,s=Qi($i(a,o))}n.push(Ri(s,c))}return n},ta=e=>{let t=M(e);return{x:t.y,y:t.x}},na=e=>{let t=M(e);return{x:Math.round(t.x),y:Math.round(t.y)}},ra=e=>{let t=M(e);return{x:1/t.x,y:1/t.y}},ia=(e,t,n)=>{let r=M(e),i=M(t),a=n===`clockwise`?Math.PI/2:-Math.PI/2,o=r.x-i.x,s=r.y-i.y,c=o*Math.cos(a)-s*Math.sin(a),l=o*Math.sin(a)+s*Math.cos(a);return{x:c+i.x,y:l+i.y}},aa=o({DECIMAL:()=>da,ZERO:()=>ua,area:()=>Wa,areaIsZero:()=>ba,aspect:()=>Va,bottom:()=>B,bottomCenter:()=>Da,bottomLeft:()=>Ea,bottomRight:()=>Oa,box:()=>la,center:()=>ja,centerLeft:()=>ka,centerRight:()=>Aa,construct:()=>P,constructWithAlternateRoot:()=>Ka,contains:()=>ma,copy:()=>fa,css:()=>va,cssBox:()=>sa,dim:()=>ya,dims:()=>ga,domRect:()=>ca,edgePoints:()=>Ra,equals:()=>ha,height:()=>R,intersection:()=>Ua,isBox:()=>Ba,left:()=>V,loc:()=>I,positionInCenter:()=>za,reRoot:()=>La,resize:()=>pa,right:()=>z,root:()=>Pa,round:()=>qa,signedDims:()=>_a,signedHeight:()=>Sa,signedWidth:()=>xa,top:()=>H,topCenter:()=>wa,topLeft:()=>Ca,topRight:()=>Ta,translate:()=>Ha,truncate:()=>Ga,width:()=>L,x:()=>Ma,xBounds:()=>Fa,xyLoc:()=>F,y:()=>Na,yBounds:()=>Ia}),oa=l.z.union([l.z.number(),l.z.string()]),sa=l.z.object({top:oa,left:oa,width:oa,height:oa}),ca=l.z.object({left:l.z.number(),top:l.z.number(),right:l.z.number(),bottom:l.z.number()}),la=l.z.object({one:j,two:j,root:fi}),ua={one:N,two:N,root:A},da={one:N,two:Ni,root:mi},fa=(e,t)=>({one:e.one,two:e.two,root:t??e.root}),P=(e,t,n=0,r=0,i)=>{let a={one:{...N},two:{...N},root:i??A};if(typeof e==`number`){if(typeof t!=`number`)throw Error(`Box constructor called with invalid arguments`);return a.one={x:e,y:t},a.two={x:a.one.x+n,y:a.one.y+r},a}return`one`in e&&`two`in e&&`root`in e?{...e,root:i??e.root}:(`getBoundingClientRect`in e&&(e=e.getBoundingClientRect()),`left`in e?(a.one={x:e.left,y:e.top},a.two={x:e.right,y:e.bottom},a):(a.one=e,t==null?a.two={x:a.one.x+n,y:a.one.y+r}:typeof t==`number`?a.two={x:a.one.x+t,y:a.one.y+n}:`width`in t?a.two={x:a.one.x+t.width,y:a.one.y+t.height}:`signedWidth`in t?a.two={x:a.one.x+t.signedWidth,y:a.one.y+t.signedHeight}:a.two=t,a))},pa=(e,t,n)=>{let r=P(e);if(typeof t==`string`){if(n==null)throw Error(`Invalid arguments for resize`);let e=O(t);return P(r.one,void 0,e===`x`?n:L(r),e===`y`?n:R(r),r.root)}return P(r.one,t,void 0,void 0,r.root)},ma=(e,t,n=!0)=>{let r=P(e),i=(e,t)=>e<t;return n&&(i=(e,t)=>e<=t),`one`in t?i(V(r),V(t))&&i(z(t),z(r))&&i(H(r),H(t))&&i(B(t),B(r)):i(V(r),t.x)&&i(t.x,z(r))&&i(H(r),t.y)&&i(t.y,B(r))},ha=(e,t)=>Ii(e.one,t.one)&&Ii(e.two,t.two)&&Si(e.root,t.root),ga=e=>({width:L(e),height:R(e)}),_a=e=>({signedWidth:xa(e),signedHeight:Sa(e)}),va=e=>({top:H(e),left:V(e),width:L(e),height:R(e)}),ya=(e,t,n=!1)=>{let r=O(t)===`y`?Sa(e):xa(e);return n?r:Math.abs(r)},F=(e,t)=>{let n=P(e);return{x:t.x===`center`?ja(n).x:I(n,t.x),y:t.y===`center`?ja(n).y:I(n,t.y)}},I=(e,t)=>{let n=P(e),r=wi(n.root).includes(t)?Math.min:Math.max;return rn.includes(t)?r(n.one.x,n.two.x):r(n.one.y,n.two.y)},ba=e=>Wa(e)===0,L=e=>ya(e,`x`),R=e=>ya(e,`y`),xa=e=>{let t=P(e);return t.two.x-t.one.x},Sa=e=>{let t=P(e);return t.two.y-t.one.y},Ca=e=>F(e,A),wa=e=>F(e,_i),Ta=e=>F(e,pi),Ea=e=>F(e,mi),Da=e=>F(e,vi),Oa=e=>F(e,hi),ka=e=>F(e,bi),Aa=e=>F(e,yi),z=e=>I(e,`right`),B=e=>I(e,`bottom`),V=e=>I(e,`left`),H=e=>I(e,`top`),ja=e=>Vi(Ca(e),{x:xa(e)/2,y:Sa(e)/2}),Ma=e=>{let t=P(e);return t.root.x===`left`?V(t):z(t)},Na=e=>{let t=P(e);return t.root.y===`top`?H(t):B(t)},Pa=e=>({x:Ma(e),y:Na(e)}),Fa=e=>{let t=P(e);return{lower:t.one.x,upper:t.two.x}},Ia=e=>{let t=P(e);return{lower:t.one.y,upper:t.two.y}},La=(e,t)=>fa(e,t),Ra=(e,t)=>{let n=P(e),r=rn.includes(t)?`x`:on.includes(t)?`y`:null;if(r===null)throw Error(`Invalid location: ${t}`);let i=t===`top`||t===`left`?Math.min:Math.max,a={...n.one},o={...n.two};return a[r]=i(n.one[r],n.two[r]),o[r]=i(n.one[r],n.two[r]),[a,o]},za=(e,t)=>{let n=P(e),r=P(t);return P({x:Ma(r)+(L(r)-L(n))/2,y:Na(r)+(R(r)-R(n))/2},ga(n))},Ba=e=>typeof e!=`object`||!e?!1:`one`in e&&`two`in e&&`root`in e,Va=e=>L(e)/R(e),Ha=(e,t,n)=>{if(typeof t==`string`){if(n==null)throw Error(`Undefined amount passed into box.translate`);t=M(O(t),n)}let r=P(e);return P(Vi(r.one,t),Vi(r.two,t),void 0,void 0,r.root)},Ua=(e,t)=>{let n=Math.max(V(e),V(t)),r=Math.max(H(e),H(t)),i=Math.min(z(e),z(t)),a=Math.min(B(e),B(t));return n>i||r>a?ua:P({x:n,y:r},{x:i,y:a},void 0,void 0,e.root)},Wa=e=>L(e)*R(e),Ga=(e,t)=>{let n=P(e);return P(Yi(n.one,t),Yi(n.two,t),void 0,void 0,n.root)},Ka=(e,t,n,r,i,a)=>{let o={x:e,y:t},s={x:e+n,y:t+r};return i.x!==a.x&&(i.x===`center`?(o.x-=n/2,s.x-=n/2):(o.x-=n,s.x-=n)),i.y!==a.y&&(i.y===`center`?(o.y-=r/2,s.y-=r/2):(o.y-=r,s.y-=r)),P(o,s,void 0,void 0,a)},qa=e=>{let t=P(e);return P(na(t.one),na(t.two),void 0,void 0,t.root)},Ja=o({DECIMAL:()=>Za,ZERO:()=>Xa,construct:()=>U,couple:()=>to,crude:()=>Ya,dimensionsZ:()=>_n,equals:()=>Qa,max:()=>no,min:()=>ro,scale:()=>io,signedDimensionsZ:()=>vn,svgViewBox:()=>eo,swap:()=>$a}),Ya=l.z.union([_n,vn,j,Qt]),Xa={width:0,height:0},Za={width:1,height:1},U=(e,t)=>typeof e==`number`?{width:e,height:t??e}:Array.isArray(e)?{width:e[0],height:e[1]}:`x`in e?{width:e.x,height:e.y}:`signedWidth`in e?{width:e.signedWidth,height:e.signedHeight}:{...e},Qa=(e,t)=>{if(t==null)return!1;let n=U(e),r=U(t);return n.width===r.width&&n.height===r.height},$a=e=>{let t=U(e);return{width:t.height,height:t.width}},eo=e=>{let t=U(e);return`0 0 ${t.width} ${t.height}`},to=e=>{let t=U(e);return[t.width,t.height]},no=e=>({width:Math.max(...e.map(e=>U(e).width)),height:Math.max(...e.map(e=>U(e).height))}),ro=e=>({width:Math.min(...e.map(e=>U(e).width)),height:Math.min(...e.map(e=>U(e).height))}),io=(e,t)=>{let n=U(e);return{width:n.width*t,height:n.height*t}},ao=(e,t,n)=>t!==void 0&&e<t?t:n!==void 0&&e>n?n:e,oo=o({Scale:()=>go,XY:()=>_o,crudeXYTransform:()=>so,transform:()=>co}),so=l.z.object({offset:Mi,scale:Mi}),co=l.z.object({offset:l.z.number(),scale:l.z.number()}),lo=e=>(t,n,r,i)=>n===`dimension`?[t,r]:[t,i?r-e:r+e],uo=e=>(t,n,r,i)=>[t,i?r/e:r*e],fo=e=>(t,n,r)=>{if(t===null)return[e,r];let{lower:i,upper:a}=t,{lower:o,upper:s}=e,c=a-i,l=s-o;return n===`dimension`?[e,l/c*r]:[e,(r-i)*(l/c)+o]},po=e=>(t,n,r)=>[e,r],mo=()=>(e,t,n)=>{if(e===null)throw Error(`cannot invert without bounds`);if(t===`dimension`)return[e,n];let{lower:r,upper:i}=e;return[e,i-(n-r)]},ho=e=>(t,n,r)=>{let{lower:i,upper:a}=e;return r=ao(r,i,a),[t,r]},go=class e{ops=[];currBounds=null;currType=null;reversed=!1;constructor(){this.ops=[]}static translate(t){return new e().translate(t)}static magnify(t){return new e().magnify(t)}static scale(t,n){return new e().scale(t,n)}translate(e){let t=this.new(),n=lo(e);return n.type=`translate`,t.ops.push(n),t}magnify(e){let t=this.new(),n=uo(e);return n.type=`magnify`,t.ops.push(n),t}scale(e,t){let n=E(e,t),r=this.new(),i=fo(n);return i.type=`scale`,r.ops.push(i),r}clamp(e,t){let n=E(e,t),r=this.new(),i=ho(n);return i.type=`clamp`,r.ops.push(i),r}reBound(e,t){let n=E(e,t),r=this.new(),i=po(n);return i.type=`re-bound`,r.ops.push(i),r}invert(){let e=mo();e.type=`invert`;let t=this.new();return t.ops.push(e),t}pos(e){return this.exec(`position`,e)}dim(e){return this.exec(`dimension`,e)}new(){let t=new e;return t.ops=this.ops.slice(),t.reversed=this.reversed,t}exec(e,t){return this.currBounds=null,this.ops.reduce(([t,n],r)=>r(t,e,n,this.reversed),[null,t])[1]}reverse(){let e=this.new();e.ops.reverse();let t=[];return e.ops.forEach((n,r)=>{if(n.type===`scale`||t.some(([e,t])=>r>=e&&r<=t))return;let i=e.ops.findIndex((e,t)=>e.type===`scale`&&t>r);i!==-1&&t.push([r,i])}),t.forEach(([t,n])=>{let r=e.ops.slice(t,n);r.unshift(e.ops[n]),e.ops.splice(t,n-t+1,...r)}),e.reversed=!e.reversed,e}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}static IDENTITY=new e},_o=class e{x;y;currRoot;constructor(e=new go,t=new go,n=null){this.x=e,this.y=t,this.currRoot=n}static translate(t,n){return new e().translate(t,n)}static translateX(t){return new e().translateX(t)}static translateY(t){return new e().translateY(t)}static clamp(t){return new e().clamp(t)}static magnify(t){return new e().magnify(t)}static scale(t){return new e().scale(t)}static reBound(t){return new e().reBound(t)}translate(e,t){let n=M(e,t),r=this.copy();return r.x=this.x.translate(n.x),r.y=this.y.translate(n.y),r}translateX(e){let t=this.copy();return t.x=this.x.translate(e),t}translateY(e){let t=this.copy();return t.y=this.y.translate(e),t}magnify(e){let t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){let t=this.copy();if(Ba(e)){let n=this.currRoot;return t.currRoot=e.root,n!=null&&!Si(n,e.root)&&(n.x!==e.root.x&&(t.x=t.x.invert()),n.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(Fa(e)),t.y=t.y.scale(Ia(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){let t=this.copy();return t.x=this.x.reBound(Fa(e)),t.y=this.y.reBound(Ia(e)),t}clamp(e){let t=this.copy();return t.x=this.x.clamp(Fa(e)),t.y=this.y.clamp(Ia(e)),t}copy(){let t=new e;return t.currRoot=this.currRoot,t.x=this.x,t.y=this.y,t}reverse(){let 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 P(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})}}static IDENTITY=new e},vo=o({ALIGNMENTS:()=>fn,CENTER_LOCATIONS:()=>cn,DIRECTIONS:()=>$t,LOCATIONS:()=>un,ORDERS:()=>mn,OUTER_LOCATIONS:()=>tn,X_LOCATIONS:()=>rn,Y_LOCATIONS:()=>on,alignmentZ:()=>pn,boundsZ:()=>yn,centerLocationZ:()=>ln,clientXyZ:()=>gn,dimensionsZ:()=>_n,directionZ:()=>en,locationZ:()=>dn,orderZ:()=>hn,outerLocationZ:()=>nn,signedDimensionsZ:()=>vn,xLocationZ:()=>an,xyZ:()=>j,yLocationZ:()=>sn}),yo=o({calculate:()=>wo,completeXY:()=>bo,toCSS:()=>So,toDecimal:()=>Co,xy:()=>xo}),bo=j.extend({root:fi,units:l.default.object({x:l.default.enum([`px`,`decimal`]),y:l.default.enum([`px`,`decimal`])})}),xo=bo.partial({root:!0,units:!0}),So=e=>{let t={};return t[e.root?.x??`left`]=e?.units?.x===`px`?`${e.x}px`:`${e.x*100}%`,t[e.root?.y??`top`]=e?.units?.y===`px`?`${e.y}px`:`${e.y*100}%`,t},Co=({position:e,element:t,container:n})=>{let r={x:e.x,y:e.y};return e.units?.x===`decimal`?e.root?.x===`right`&&(r.x=1-e.x):e.root?.x===`right`?r.x=1-(e.x+L(t))/L(n):r.x/=L(n),e.units?.y===`decimal`?e.root?.y===`bottom`&&(r.y=1-e.y):e.root?.y===`bottom`?r.y=1-(e.y+R(t))/R(n):r.y/=R(n),r},wo=({position:e,element:t,container:n,lowerThreshold:r=.2,upperThreshold:i=.8})=>{let a={x:e.x,y:e.y,root:{...A},units:{x:`px`,y:`px`}};return e.x>i?(a.x=(1-e.x)*L(n)-L(t),a.root.x=`right`):e.x<r?a.x=e.x*L(n):a.units.x=`decimal`,e.y>i?(a.y=(1-e.y)*R(n)-R(t),a.root.y=`bottom`):e.y<r?a.y=e.y*R(n):a.units.y=`decimal`,a.x=Math.round(a.x*100)/100,{...a,...Yi(a,3)}},To=l.z.enum([`static`,`dynamic`]),Eo=365,Do=30,Oo=l.z.union([l.z.tuple([l.z.int()]),l.z.tuple([l.z.int(),l.z.int().min(1).max(12)]),l.z.tuple([l.z.int(),l.z.int().min(1).max(12),l.z.int().min(1).max(31)])]),ko=(e,t)=>{let n=new W(t);if(![G.DAY,G.HOUR,G.MINUTE,G.SECOND,G.MILLISECOND,G.MICROSECOND,G.NANOSECOND].some(e=>e.equals(n)))throw Error(`Invalid argument for remainder. Must be an even TimeSpan or Timestamp`);let r=e.valueOf()%n.valueOf();return e instanceof W?new W(r):new G(r)},W=class e extends S{constructor(t,n=`UTC`){if(t==null)super(e.now().valueOf());else if(t instanceof Date)super(BigInt(t.getTime())*e.MILLISECOND.valueOf());else if(typeof t==`string`)super(e.parseDateTimeString(t,n).valueOf());else if(Array.isArray(t))super(e.parseDate(t));else{let r=0n;t instanceof Number&&(t=t.valueOf()),n===`local`&&(r=e.utcOffset.valueOf()),typeof t==`number`&&(isFinite(t)?t=t===Ht?Bt:Math.trunc(t):(isNaN(t)&&(t=0),t=t===1/0?e.MAX:e.MIN)),x(t)&&(t=t.value),super(BigInt(t.valueOf())+r)}}static parseDate([t=1970,n=1,r=1]){let i=new Date(t,n-1,r,0,0,0,0);return new e(BigInt(i.getTime())*e.MILLISECOND.valueOf()).truncate(e.DAY).valueOf()}valueOf(){return this.value}static parseTimeString(t,n=`UTC`){let[r,i,a]=t.split(`:`),o=`00`,s=`00`;a!=null&&([o,s]=a.split(`.`));let c=e.hours(parseInt(r??`00`,10)).add(e.minutes(parseInt(i??`00`,10))).add(e.seconds(parseInt(o??`00`,10))).add(e.milliseconds(parseInt(s??`00`,10)));return n===`local`&&(c=c.add(e.utcOffset)),c.valueOf()}static parseDateTimeString(t,n=`UTC`){if(!t.includes(`/`)&&!t.includes(`-`))return e.parseTimeString(t,n);if(t.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?$/)!=null){let r=t,i=0;if(t.includes(`.`)){let e=t.split(`.`);r=e[0];let n=e[1]||`0`;i=parseInt(n.padEnd(3,`0`).slice(0,3),10)}let a=n===`local`?new Date(r.replace(`T`,` `)):new Date(`${r}Z`);return BigInt(a.getTime())*e.MILLISECOND.valueOf()+BigInt(i)*e.MILLISECOND.valueOf()}let r=new Date(t);return t.includes(`:`)||r.setUTCHours(0,0,0,0),new e(BigInt(r.getTime())*e.MILLISECOND.valueOf(),n).valueOf()}toISOString(t=`UTC`){if(t===`UTC`)return this.date().toISOString();let n=this.date(),r=new G(BigInt(n.getTimezoneOffset())*e.MINUTE.valueOf());return this.sub(r).date().toISOString()}timeString(e=!1,t=`UTC`){let n=this.toISOString(t);return e?n.slice(11,23):n.slice(11,19)}dateString(){let e=this.date();return`${e.toLocaleString(`default`,{month:`short`})} ${e.toLocaleString(`default`,{day:`numeric`})}`}static get utcOffset(){return new G(BigInt(new Date().getTimezoneOffset())*e.MINUTE.valueOf())}static since(t){return new e().span(t)}date(){return new Date(this.milliseconds)}equals(t){return this.valueOf()===new e(t).valueOf()}span(e){return this.range(e).span}range(e){return new q(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===0n}after(t){return this.valueOf()>new e(t).valueOf()}afterEq(t){return this.valueOf()>=new e(t).valueOf()}before(t){return this.valueOf()<new e(t).valueOf()}beforeEq(t){return this.valueOf()<=new e(t).valueOf()}add(t){return new e(w(this.valueOf(),new G(t).valueOf()))}sub(t){return new e(C(this.valueOf(),new G(t).valueOf()))}get hours(){return Number(this.valueOf())/Number(G.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(G.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(G.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(G.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(e.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(e.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get year(){return this.date().getUTCFullYear()}get localYear(){return this.date().getFullYear()}setYear(t){let n=this.date();return n.setUTCFullYear(t),new e(n)}setLocalYear(t){let n=this.date();return n.setFullYear(t),new e(n)}get month(){return this.date().getUTCMonth()}get localMonth(){return this.date().getMonth()}setMonth(t){let n=this.date();return n.setUTCMonth(t),new e(n)}setLocalMonth(t){let n=this.date();return n.setMonth(t),new e(n)}get day(){return this.date().getUTCDate()}get localDay(){return this.date().getDate()}setDay(t){let n=this.date();return n.setUTCDate(t),new e(n)}setLocalDay(t){let n=this.date();return n.setDate(t),new e(n)}get hour(){return this.date().getUTCHours()}get localHour(){return this.date().getHours()}setLocalHour(t){let n=this.date();return n.setHours(t),new e(n)}setHour(t){let n=this.date();return n.setUTCHours(t),new e(n)}get minute(){return this.date().getUTCMinutes()}get localMinute(){return this.date().getMinutes()}setMinute(t){let n=this.date();return n.setUTCMinutes(t),new e(n)}setLocalMinute(t){let n=this.date();return n.setMinutes(t),new e(n)}get second(){return this.date().getUTCSeconds()}get localSecond(){return this.date().getSeconds()}setSecond(t){let n=this.date();return n.setUTCSeconds(t),new e(n)}setLocalSecond(t){let n=this.date();return n.setSeconds(t),new e(n)}get millisecond(){return this.date().getUTCMilliseconds()}get localMillisecond(){return this.date().getMilliseconds()}setMillisecond(t){let n=this.date();return n.setUTCMilliseconds(t),new e(n)}setLocalMillisecond(t){let n=this.date();return n.setMilliseconds(t),new e(n)}toString(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)}}remainder(e){return ko(this,e)}get isToday(){return this.truncate(G.DAY).equals(e.now().truncate(G.DAY))}truncate(e){return this.sub(this.remainder(e))}formatBySpan(e){return e.greaterThanOrEqual(G.days(30))?`shortDate`:e.greaterThanOrEqual(G.DAY)?`dateTime`:e.greaterThanOrEqual(G.HOUR)?`time`:e.greaterThanOrEqual(G.SECOND)?`preciseTime`:`ISOTime`}static now(){return new e(new Date)}static max(...t){let n=e.MIN;for(let r of t){let t=new e(r);t.after(n)&&(n=t)}return n}static min(...t){let n=e.MAX;for(let r of t){let t=new e(r);t.before(n)&&(n=t)}return n}static nanoseconds(t,n=`UTC`){return new e(t,n)}static NANOSECOND=e.nanoseconds(1);static microseconds(t,n=`UTC`){return e.nanoseconds(t*1e3,n)}static MICROSECOND=e.microseconds(1);static milliseconds(t,n=`UTC`){return e.microseconds(t*1e3,n)}static MILLISECOND=e.milliseconds(1);static seconds(t,n=`UTC`){return e.milliseconds(t*1e3,n)}static SECOND=e.seconds(1);static minutes(t,n=`UTC`){return e.seconds(t*60,n)}static MINUTE=e.minutes(1);static hours(t,n=`UTC`){return e.minutes(t*60,n)}static HOUR=e.hours(1);static days(t,n=`UTC`){return e.hours(t*24,n)}static DAY=e.days(1);static MAX=new e(Bt);static MIN=new e(0);static ZERO=new e(0);static z=l.z.union([l.z.instanceof(e),l.z.object({value:l.z.bigint()}).transform(t=>new e(t.value)),l.z.string().transform(t=>new e(BigInt(t))),l.z.number().transform(t=>new e(t)),l.z.bigint().transform(t=>new e(t)),l.z.date().transform(t=>new e(t)),l.z.custom(e=>e instanceof G).transform(t=>new e(t)),Oo.transform(t=>new e(t))]);static sort(e,t){return Number(e.valueOf()-t.valueOf())}},G=class e extends S{constructor(e){typeof e==`number`&&(e=Math.trunc(e.valueOf())),x(e)&&(e=e.value),super(BigInt(e.valueOf()))}static fromSeconds(t){return t instanceof e?t:t instanceof Ao?t.period:t instanceof W?new e(t):(x(t)&&(t=t.value),[`number`,`bigint`].includes(typeof t)?e.seconds(t):new e(t))}static fromMilliseconds(t){return t instanceof e?t:t instanceof Ao?t.period:t instanceof W?new e(t):(x(t)&&(t=t.value),[`number`,`bigint`].includes(typeof t)?e.milliseconds(t):new e(t))}valueOf(){return this.value}lessThan(t){return this.valueOf()<new e(t).valueOf()}greaterThan(t){return this.valueOf()>new e(t).valueOf()}lessThanOrEqual(t){return this.valueOf()<=new e(t).valueOf()}greaterThanOrEqual(t){return this.valueOf()>=new e(t).valueOf()}remainder(e){return ko(this,e)}truncate(t){return new e(BigInt(Math.trunc(Number(this.valueOf()/t.valueOf())))*t.valueOf())}toString(t=`full`){if(t===`semantic`)return this.toSemanticString();let n=this.truncate(e.DAY),r=this.truncate(e.HOUR),i=this.truncate(e.MINUTE),a=this.truncate(e.SECOND),o=this.truncate(e.MILLISECOND),s=this.truncate(e.MICROSECOND),c=this.truncate(e.NANOSECOND),l=n,u=r.sub(n),d=i.sub(r),f=a.sub(i),p=o.sub(a),m=s.sub(o),ee=c.sub(s),h=``;return l.isZero||(h+=`${l.days}d `),u.isZero||(h+=`${u.hours}h `),d.isZero||(h+=`${d.minutes}m `),f.isZero||(h+=`${f.seconds}s `),p.isZero||(h+=`${p.milliseconds}ms `),m.isZero||(h+=`${m.microseconds}µs `),ee.isZero||(h+=`${ee.nanoseconds}ns`),h.trim()}toSemanticString(){let t=new e(this.valueOf()<0n?-this.valueOf():this.valueOf()),n=this.valueOf()<0n;if(t.valueOf()===0n)return`0s`;if(t.lessThan(e.SECOND))return`< 1s`;let r=t.days,i=t.hours,a=t.minutes,o=t.seconds,s=Math.floor(r/Eo),c=Math.floor(r/Do),l=Math.floor(r/7),u=Math.floor(r),d=Math.floor(i),f=Math.floor(a),p=Math.floor(o),m=n?`-`:``;if(s>=1){let e=`${s}y`;if(s<2){let t=Math.floor(r%Eo/Do);t>0&&(e+=` ${t}mo`)}return m+e}if(l>=1&&r<Do&&r%7==0){let e=`${l}w`,t=Math.floor(r%7),n=Math.floor(i-l*7*24);return l<2&&(t>0?e+=` ${t}d`:n>0&&n<24&&(e+=` ${n}h`)),m+e}if(c>=1){let e=`${c}mo`;if(c<3){let t=Math.floor(r%Do);t>0&&(e+=` ${t}d`)}return m+e}if(l>=1){let e=`${l}w`,t=Math.floor(r%7),n=Math.floor(i-l*7*24);return l<2&&(t>0?e+=` ${t}d`:n>0&&n<24&&(e+=` ${n}h`)),m+e}if(u>=1){let e=`${u}d`,t=Math.floor(i-u*24);return u<2&&t>0&&(e+=` ${t}h`),m+e}if(d>=1){let e=`${d}h`;if(d<3){let t=Math.floor(a-d*60);t>0&&(e+=` ${t}m`)}return m+e}if(f>=1){let e=`${f}m`;if(f<5){let t=Math.floor(o-f*60);t>0&&(e+=` ${t}s`)}return m+e}return`${m}${p}s`}mult(t){return new e(T(this.valueOf(),t))}div(t){return new e(Zt(this.valueOf(),t))}get days(){return Number(this.valueOf())/Number(e.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(e.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(e.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(e.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(e.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(e.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===0n}equals(t){return this.valueOf()===new e(t).valueOf()}add(t){return new e(this.valueOf()+new e(t).valueOf())}sub(t){return new e(this.valueOf()-new e(t).valueOf())}static nanoseconds(t=1){return new e(t)}static NANOSECOND=e.nanoseconds(1);static microseconds(t=1){return e.nanoseconds(T(t,1e3))}static MICROSECOND=e.microseconds(1);static milliseconds(t=1){return e.microseconds(T(t,1e3))}static MILLISECOND=e.milliseconds(1);static seconds(t=1){return e.milliseconds(T(t,1e3))}static SECOND=e.seconds(1);static minutes(t=1){return e.seconds(T(t,60))}static MINUTE=e.minutes(1);static hours(t){return e.minutes(T(t,60))}static HOUR=e.hours(1);static days(t){return e.hours(T(t,24))}static DAY=e.days(1);static MAX=new e(Bt);static MIN=new e(0);static ZERO=new e(0);static z=l.z.union([l.z.object({value:l.z.bigint()}).transform(t=>new e(t.value)),l.z.string().transform(t=>new e(BigInt(t))),l.z.number().transform(t=>new e(t)),l.z.bigint().transform(t=>new e(t)),l.z.instanceof(e),l.z.instanceof(W).transform(t=>new e(t)),l.z.custom(e=>e instanceof Ao).transform(t=>new e(t))])},Ao=class e extends S{constructor(e){x(e)&&(e=e.value),super(e.valueOf())}toString(){return`${this.valueOf()} Hz`}equals(t){return this.valueOf()===new e(t).valueOf()}get period(){return G.seconds(1/this.valueOf())}sampleCount(e){return new G(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new K(t).valueOf()}span(e){return G.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/new K(t).valueOf())}add(t){return new e(w(this.valueOf(),new e(t).valueOf()))}sub(t){return new e(C(this.valueOf(),new e(t).valueOf()))}mult(t){return new e(T(this.valueOf(),t))}div(t){return new e(Zt(this.valueOf(),t))}static hz(t){return new e(t)}static khz(t){return e.hz(t*1e3)}static z=l.z.union([l.z.number().transform(t=>new e(t)),l.z.instanceof(e)])},K=class e extends S{constructor(e){x(e)&&(e=e.value),super(e.valueOf())}length(e){return e.valueOf()/this.valueOf()}size(e){return new Y(e*this.valueOf())}add(t){return new e(w(this.valueOf(),new e(t).valueOf()))}sub(t){return new e(C(this.valueOf(),new e(t).valueOf()))}mult(t){return new e(T(this.valueOf(),t))}div(t){return new e(Zt(this.valueOf(),t))}static UNKNOWN=new e(0);static BIT128=new e(16);static BIT64=new e(8);static BIT32=new e(4);static BIT16=new e(2);static BIT8=new e(1);static z=l.z.union([l.z.number().transform(t=>new e(t)),l.z.instanceof(e)])},q=class e{start;end;constructor(e,t){typeof e==`object`&&`start`in e?(this.start=new W(e.start),this.end=new W(e.end)):(this.start=new W(e),this.end=new W(t))}get span(){return new G(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.start.isZero&&this.end.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new e(this.end,this.start)}get numericBounds(){return{lower:Number(this.start.valueOf()),upper:Number(this.end.valueOf())}}equals(e,t=G.ZERO){if(t.isZero)return this.start.equals(e.start)&&this.end.equals(e.end);let n=this.start.sub(e.start).valueOf(),r=this.end.sub(e.end).valueOf();return n<0&&(n=-n),r<0&&(r=-r),n<=t.valueOf()&&r<=t.valueOf()}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.toString(`preciseDate`)} - ${this.span.toString()}`}overlapsWith(e,t=G.ZERO){e=e.makeValid();let n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;let r=W.max(n.start,e.start),i=W.min(n.end,e.end);return i.before(r)?!1:new G(i.sub(r)).greaterThanOrEqual(t)}contains(t){return t instanceof e?this.contains(t.start)&&this.contains(t.end):this.start.beforeEq(t)&&this.end.after(t)}boundBy(t){let n=new e(this.start,this.end);return t.start.after(this.start)&&(n.start=t.start),t.start.after(this.end)&&(n.end=t.start),t.end.before(this.end)&&(n.end=t.end),t.end.before(this.start)&&(n.start=t.end),n}static max(...t){return new e(W.min(...t.map(e=>e.start)),W.max(...t.map(e=>e.end)))}static MAX=new e(W.MIN,W.MAX);static ZERO=new e(W.ZERO,W.ZERO);static z=l.z.union([l.z.object({start:W.z,end:W.z}).transform(t=>new e(t.start,t.end)),l.z.instanceof(e)]);static boundedZ=e.z.refine(({isValid:e})=>e,{message:`Time range start time must be before or equal to time range end time`}).refine(({end:e})=>e.valueOf()<=Bt,{message:`Time range end time must be less than or equal to the maximum value of an int64`}).refine(({start:e})=>e.valueOf()>=zt,{message:`Time range start time must be greater than or equal to the minimum value of an int64`});static sort(e,t){return W.sort(e.start,t.start)||W.sort(e.end,t.end)}static merge(...t){return e.max(...t.map(t=>new e(t).makeValid()))}},J=class e extends S{constructor(t){if(x(t)&&(t=t.value),t instanceof e||typeof t==`string`||typeof t.valueOf()==`string`)super(t.valueOf());else{let n=e.ARRAY_CONSTRUCTOR_DATA_TYPES.get(t.constructor.name);if(n==null)throw Error(`unable to find data type for ${t.toString()}`);super(n.valueOf())}}get Array(){let t=e.ARRAY_CONSTRUCTORS.get(this.toString());if(t==null)throw Error(`unable to find array constructor for ${this.valueOf()}`);return t}equals(e){return this.valueOf()===e.valueOf()}matches(...e){return e.some(e=>this.equals(e))}toString(t=!1){return t?e.SHORT_STRINGS.get(this.valueOf())??this.valueOf():this.valueOf()}get isVariable(){return this.equals(e.JSON)||this.equals(e.STRING)||this.equals(e.BYTES)}get isNumeric(){return!this.isVariable&&!this.equals(e.UUID)}get isInteger(){let e=this.toString();return e.startsWith(`int`)||e.startsWith(`uint`)}get isFloat(){return this.toString().startsWith(`float`)}get density(){let t=e.DENSITIES.get(this.toString());if(t==null)throw Error(`unable to find density for ${this.valueOf()}`);return t}get isUnsignedInteger(){return this.equals(e.UINT8)||this.equals(e.UINT16)||this.equals(e.UINT32)||this.equals(e.UINT64)}get isSignedInteger(){return this.equals(e.INT8)||this.equals(e.INT16)||this.equals(e.INT32)||this.equals(e.INT64)}canSafelyCastTo(t){return this.equals(t)?!0:!this.isNumeric||!t.isNumeric||this.isVariable||t.isVariable||this.isUnsignedInteger&&t.isSignedInteger?!1:this.isFloat?t.isFloat&&this.density.valueOf()<=t.density.valueOf():this.equals(e.INT32)&&t.equals(e.FLOAT64)||this.equals(e.INT8)&&t.equals(e.FLOAT32)?!0:this.isInteger&&t.isInteger?this.density.valueOf()<=t.density.valueOf()&&this.isUnsignedInteger===t.isUnsignedInteger:!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}get usesBigInt(){return e.BIG_INT_TYPES.some(e=>e.equals(this))}static UNKNOWN=new e(`unknown`);static FLOAT64=new e(`float64`);static FLOAT32=new e(`float32`);static INT64=new e(`int64`);static INT32=new e(`int32`);static INT16=new e(`int16`);static INT8=new e(`int8`);static UINT64=new e(`uint64`);static UINT32=new e(`uint32`);static UINT16=new e(`uint16`);static UINT8=new e(`uint8`);static TIMESTAMP=new e(`timestamp`);static UUID=new e(`uuid`);static STRING=new e(`string`);static JSON=new e(`json`);static BYTES=new e(`bytes`);static ARRAY_CONSTRUCTORS=new Map([[e.UINT8.toString(),Uint8Array],[e.UINT16.toString(),Uint16Array],[e.UINT32.toString(),Uint32Array],[e.UINT64.toString(),BigUint64Array],[e.FLOAT32.toString(),Float32Array],[e.FLOAT64.toString(),Float64Array],[e.INT8.toString(),Int8Array],[e.INT16.toString(),Int16Array],[e.INT32.toString(),Int32Array],[e.INT64.toString(),BigInt64Array],[e.TIMESTAMP.toString(),BigInt64Array],[e.STRING.toString(),Uint8Array],[e.JSON.toString(),Uint8Array],[e.UUID.toString(),Uint8Array],[e.BYTES.toString(),Uint8Array]]);static ARRAY_CONSTRUCTOR_DATA_TYPES=new Map([[Uint8Array.name,e.UINT8],[Uint16Array.name,e.UINT16],[Uint32Array.name,e.UINT32],[BigUint64Array.name,e.UINT64],[Float32Array.name,e.FLOAT32],[Float64Array.name,e.FLOAT64],[Int8Array.name,e.INT8],[Int16Array.name,e.INT16],[Int32Array.name,e.INT32],[BigInt64Array.name,e.INT64]]);static DENSITIES=new Map([[e.UINT8.toString(),K.BIT8],[e.UINT16.toString(),K.BIT16],[e.UINT32.toString(),K.BIT32],[e.UINT64.toString(),K.BIT64],[e.FLOAT32.toString(),K.BIT32],[e.FLOAT64.toString(),K.BIT64],[e.INT8.toString(),K.BIT8],[e.INT16.toString(),K.BIT16],[e.INT32.toString(),K.BIT32],[e.INT64.toString(),K.BIT64],[e.TIMESTAMP.toString(),K.BIT64],[e.STRING.toString(),K.UNKNOWN],[e.JSON.toString(),K.UNKNOWN],[e.UUID.toString(),K.BIT128],[e.BYTES.toString(),K.UNKNOWN]]);static ALL=[e.UNKNOWN,e.UINT8,e.UINT16,e.UINT32,e.UINT64,e.INT8,e.INT16,e.INT32,e.INT64,e.FLOAT32,e.FLOAT64,e.TIMESTAMP,e.UUID,e.STRING,e.JSON,e.BYTES];static SHORT_STRINGS=new Map([[e.UINT8.toString(),`u8`],[e.UINT16.toString(),`u16`],[e.UINT32.toString(),`u32`],[e.UINT64.toString(),`u64`],[e.INT8.toString(),`i8`],[e.INT16.toString(),`i16`],[e.INT32.toString(),`i32`],[e.INT64.toString(),`i64`],[e.FLOAT32.toString(),`f32`],[e.FLOAT64.toString(),`f64`],[e.TIMESTAMP.toString(),`ts`],[e.UUID.toString(),`uuid`],[e.STRING.toString(),`str`],[e.JSON.toString(),`json`],[e.BYTES.toString(),`bytes`]]);static BIG_INT_TYPES=[e.INT64,e.UINT64,e.TIMESTAMP];static z=l.z.union([l.z.string().transform(t=>new e(t)),l.z.instanceof(e)])},Y=class e extends S{constructor(e){x(e)&&(e=e.value),super(e.valueOf())}largerThan(e){return x(e)&&(e=e.value),this.valueOf()>e.valueOf()}smallerThan(e){return x(e)&&(e=e.value),this.valueOf()<e.valueOf()}add(t){return x(t)&&(t=t.value),new e(w(this.valueOf(),t.valueOf()))}sub(t){return x(t)&&(t=t.value),new e(C(this.valueOf(),t.valueOf()))}mult(t){return new e(T(this.valueOf(),t))}div(t){return new e(Zt(this.valueOf(),t))}truncate(t){return new e(Math.trunc(this.valueOf()/new e(t).valueOf())*new e(t).valueOf())}remainder(t){return e.bytes(this.valueOf()%new e(t).valueOf())}get gigabytes(){return this.valueOf()/e.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/e.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/e.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/e.TERABYTE.valueOf()}toString(){let t=this.truncate(e.TERABYTE),n=this.truncate(e.GIGABYTE),r=this.truncate(e.MEGABYTE),i=this.truncate(e.KILOBYTE),a=this.truncate(e.BYTE),o=t,s=n.sub(t),c=r.sub(n),l=i.sub(r),u=a.sub(i),d=``;return o.isZero||(d+=`${o.terabytes}TB `),s.isZero||(d+=`${s.gigabytes}GB `),c.isZero||(d+=`${c.megabytes}MB `),l.isZero||(d+=`${l.kilobytes}KB `),(!u.isZero||d===``)&&(d+=`${u.valueOf()}B`),d.trim()}static bytes(t=1){return new e(t)}static BYTE=new e(1);static kilobytes(t=1){return e.bytes(new e(t).valueOf()*1e3)}static KILOBYTE=e.kilobytes(1);static megabytes(t=1){return e.kilobytes(new e(t).valueOf()*1e3)}static MEGABYTE=e.megabytes(1);static gigabytes(t=1){return e.megabytes(new e(t).valueOf()*1e3)}static GIGABYTE=e.gigabytes(1);static terabytes(t){return e.gigabytes(new e(t).valueOf()*1e3)}static TERABYTE=e.terabytes(1);static ZERO=new e(0);static z=l.z.union([l.z.number().transform(t=>new e(t)),l.z.instanceof(e)]);get isZero(){return this.valueOf()===0}},jo=l.z.object({start:l.z.number(),end:l.z.number()}),Mo=l.z.union([l.z.instanceof(Uint8Array),l.z.instanceof(Uint16Array),l.z.instanceof(Uint32Array),l.z.instanceof(BigUint64Array),l.z.instanceof(Float32Array),l.z.instanceof(Float64Array),l.z.instanceof(Int8Array),l.z.instanceof(Int16Array),l.z.instanceof(Int32Array),l.z.instanceof(BigInt64Array)]),No=e=>{let t=typeof e;return t===`string`||t===`number`||t===`boolean`||t===`bigint`||e instanceof W||e instanceof G||e instanceof Date},Po=(e,t,n,r=0)=>e.usesBigInt&&!t.usesBigInt?Number(n)-Number(r):!e.usesBigInt&&t.usesBigInt?BigInt(n.valueOf())-BigInt(r.valueOf()):C(n,r),Fo=q.z,Io=W.z,Lo=G.z,Ro=Ao.z,zo=Y.z,Bo=J.z,Vo=q.boundedZ,Ho=`00000000-0000-0000-0000-000000000000`,Uo=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function Wo(e){return typeof e==`string`&&Uo.test(e)}var X=[];for(let e=0;e<256;++e)X.push((e+256).toString(16).slice(1));function Go(e,t=0){return(X[e[t+0]]+X[e[t+1]]+X[e[t+2]]+X[e[t+3]]+`-`+X[e[t+4]]+X[e[t+5]]+`-`+X[e[t+6]]+X[e[t+7]]+`-`+X[e[t+8]]+X[e[t+9]]+`-`+X[e[t+10]]+X[e[t+11]]+X[e[t+12]]+X[e[t+13]]+X[e[t+14]]+X[e[t+15]]).toLowerCase()}function Ko(e,t=0){let n=Go(e,t);if(!Wo(n))throw TypeError(`Stringified UUID is invalid`);return n}var qo,Jo=new Uint8Array(16);function Yo(){if(!qo){if(typeof crypto>`u`||!crypto.getRandomValues)throw Error(`crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported`);qo=crypto.getRandomValues.bind(crypto)}return qo(Jo)}var Xo={randomUUID:typeof crypto<`u`&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Zo(e,t,n){e||={};let r=e.random??e.rng?.()??Yo();if(r.length<16)throw Error(`Random bytes length must be >= 16`);if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(n||=0,n<0||n+16>t.length)throw RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=r[e];return t}return Go(r)}function Qo(e,t,n){return Xo.randomUUID&&!t&&!e?Xo.randomUUID():Zo(e,t,n)}var $o=o({ZERO:()=>ns,create:()=>es,parse:()=>ts}),es=()=>Qo(),ts=(e,t)=>Ko(e,t),ns=Ho,Z=-1,rs={[Symbol.iterator]:()=>rs,next:()=>({done:!0,value:void 0})},is=l.z.string().transform(e=>new Uint8Array(atob(e).split(``).map(e=>e.charCodeAt(0))).buffer),as=l.z.union([l.z.null(),l.z.undefined()]).transform(()=>new Uint8Array().buffer),os=10,ss=(e,t)=>{if(e===`number`&&!t.isNumeric)throw Error(`cannot convert series of type ${t.toString()} to number`);if(e===`bigint`&&!t.usesBigInt)throw Error(`cannot convert series of type ${t.toString()} to bigint`)},cs=`sy_x_telem_series`,ls=class e{key;discriminator=cs;dataType;sampleOffset;gl;_data;timeRange=q.ZERO;alignment=0n;alignmentMultiple=1n;cachedMin;cachedMax;writePos=Z;_refCount=0;cachedLength;_cachedIndexes;static crudeZ=l.z.object({timeRange:q.z.optional(),dataType:J.z,alignment:l.z.coerce.bigint().optional(),data:l.z.union([is,as,l.z.instanceof(ArrayBuffer),l.z.instanceof(Uint8Array)]),glBufferUsage:To.default(`static`).optional()});static z=e.crudeZ.transform(t=>new e(t));constructor(e){us(e)&&(e={data:e}),e.data??=[];let{dataType:t,timeRange:n,sampleOffset:r=0,glBufferUsage:i=`static`,alignment:a=0n,alignmentMultiple:o=1n,key:s=Hr(),data:c}=e;if(ds(c)){let e=c;this.key=e.key,this.dataType=e.dataType,this.sampleOffset=e.sampleOffset,this.gl=e.gl,this._data=e._data,this.timeRange=e.timeRange,this.alignment=e.alignment,this.alignmentMultiple=e.alignmentMultiple,this.cachedMin=e.cachedMin,this.cachedMax=e.cachedMax,this.writePos=e.writePos,this._refCount=e._refCount,this.cachedLength=e.cachedLength;return}let l=No(c),u=Array.isArray(c);if(t!=null)this.dataType=new J(t);else if(c instanceof ArrayBuffer)throw Error(`cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.`);else if(u||l){let e=c;if(!l){if(c.length===0)throw Error(`cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.`);e=c[0]}if(typeof e==`string`)this.dataType=J.STRING;else if(typeof e==`number`)this.dataType=J.FLOAT64;else if(typeof e==`bigint`)this.dataType=J.INT64;else if(typeof e==`boolean`)this.dataType=J.UINT8;else if(e instanceof W||e instanceof Date||e instanceof W)this.dataType=J.TIMESTAMP;else if(typeof e==`object`)this.dataType=J.JSON;else throw Error(`cannot infer data type of ${typeof e} when constructing a Series from a JS array`)}else this.dataType=new J(c);if(!u&&!l)this._data=c;else if(u&&c.length===0)this._data=new this.dataType.Array([]).buffer;else{let e=l?[c]:c,t=e[0];(t instanceof W||t instanceof Date||t instanceof G)&&(e=e.map(e=>new W(e).valueOf())),this.dataType.equals(J.STRING)?(this.cachedLength=e.length,this._data=new TextEncoder().encode(`${e.join(`
|
|
12
|
+
`)}\n`).buffer):this.dataType.equals(J.JSON)?(this.cachedLength=e.length,this._data=new TextEncoder().encode(`${e.map(e=>mr.encodeString(e)).join(`
|
|
13
|
+
`)}\n`).buffer):this.dataType.usesBigInt&&typeof t==`number`?this._data=new this.dataType.Array(e.map(e=>BigInt(Math.round(e)))).buffer:!this.dataType.usesBigInt&&typeof t==`bigint`?this._data=new this.dataType.Array(e.map(Number)).buffer:this._data=new this.dataType.Array(e).buffer}this.key=s,this.alignment=a,this.alignmentMultiple=o,this.sampleOffset=r??0,this.timeRange=n??q.ZERO,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:i}}static alloc({capacity:t,dataType:n,...r}){if(t===0)throw Error(`[Series] - cannot allocate an array of length 0`);let i=new e({data:new new J(n).Array(t).buffer,dataType:n,...r});return i.writePos=0,i}get refCount(){return this._refCount}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){this._refCount--,this.refCount===0&&this.gl.control!=null?this.maybeGarbageCollectGLBuffer(this.gl.control):this.refCount<0&&console.warn(`cannot release a series with a negative reference count`)}write(e){if(!e.dataType.equals(this.dataType))throw 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===Z)return 0;let t=this.byteCapacity.valueOf()-this.writePos,n=e.subBytes(0,t);return this.writeToUnderlyingData(n),this.writePos+=n.byteLength.valueOf(),this.cachedLength!=null&&(this.cachedLength+=n.length,this.calculateCachedLength()),n.length}writeFixed(e){if(this.writePos===Z)return 0;let t=this.capacity-this.writePos,n=e.sub(0,t);return this.writeToUnderlyingData(n),this.cachedLength=void 0,this.maybeRecomputeMinMax(n),this.writePos+=n.length,n.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===Z?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){return this.dataType.isVariable?new TextDecoder().decode(this.underlyingData).split(`
|
|
14
|
+
`).slice(0,-1):Array.from(this).map(e=>e.toString())}parseJSON(e){if(!this.dataType.equals(J.JSON))throw Error(`cannot parse non-JSON series as JSON`);return this.toStrings().map(t=>e.parse(mr.decodeString(t)))}get byteCapacity(){return new Y(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Z?this.byteCapacity:this.dataType.isVariable?new Y(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this.cachedLength==null?this.dataType.isVariable?this.calculateCachedLength():this.writePos===Z?this.byteCapacity.valueOf()/this.dataType.density.valueOf():this.writePos:this.cachedLength}calculateCachedLength(){if(!this.dataType.isVariable)throw Error(`cannot calculate length of a non-variable length data type`);let e=0,t=[0];return this.data.forEach((n,r)=>{n===os&&(e++,t.push(r+1))}),this._cachedIndexes=t,this.cachedLength=e,e}convert(t,n=0){if(this.dataType.equals(t))return this;let r=new t.Array(this.length);for(let e=0;e<this.length;e++)r[e]=Po(this.dataType,t,this.data[e],n);return new e({data:r.buffer,dataType:t,timeRange:this.timeRange,sampleOffset:n,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){return this.length===0?-1/0:(this.dataType.equals(J.TIMESTAMP)?this.cachedMax=this.data[this.data.length-1]:(this.dataType.usesBigInt,this.cachedMax=this.data.reduce((e,t)=>e>t?e:t)),this.cachedMax)}get max(){return this.calcMax()}calcMax(){if(this.dataType.isVariable)throw Error(`cannot calculate maximum on a variable length data type`);return this.writePos===0?-1/0:(this.cachedMax??=this.calcRawMax(),w(this.cachedMax,this.sampleOffset))}calcRawMin(){return this.length===0?1/0:(this.dataType.equals(J.TIMESTAMP)?this.cachedMin=this.data[0]:(this.dataType.usesBigInt,this.cachedMin=this.data.reduce((e,t)=>e<t?e:t)),this.cachedMin)}get min(){return this.calcMin()}calcMin(){if(this.dataType.isVariable)throw Error(`cannot calculate minimum on a variable length data type`);return this.writePos===0?1/0:(this.cachedMin??=this.calcRawMin(),w(this.cachedMin,this.sampleOffset))}get bounds(){return E(Number(this.min),Number(this.max),{makeValid:!1})}maybeRecomputeMinMax(e){if(this.cachedMin!=null){let t=e.cachedMin??e.calcRawMin();t<this.cachedMin&&(this.cachedMin=t)}if(this.cachedMax!=null){let t=e.cachedMax??e.calcRawMax();t>this.cachedMax&&(this.cachedMax=t)}}atAlignment(e,t){let n=Number((e-this.alignment)/this.alignmentMultiple);if(n<0||n>=this.length){if(t===!0)throw Error(`[series] - no value at index ${n}`);return}return this.at(n,t)}at(e,t=!1){if(this.dataType.isVariable)return this.atVariable(e,t??!1);if(this.dataType.equals(J.UUID))return this.atUUID(e,t);e<0&&(e=this.length+e);let n=this.data[e];if(n==null){if(t===!0)throw Error(`[series] - no value at index ${e}`);return}return w(n,this.sampleOffset)}atUUID(e,t){e<0&&(e=this.length+e);let n=ts(new Uint8Array(this.buffer,e*this.dataType.density.valueOf()));if(n==null){if(t)throw Error(`[series] - no value at index ${e}`);return}return n}atVariable(e,t){let n=0,r=0;if(this._cachedIndexes!=null)n=this._cachedIndexes[e],r=this._cachedIndexes[e+1]-1;else{e<0&&(e=this.length+e);for(let t=0;t<this.data.length;t++)if(this.data[t]===os){if(e===0){r=t;break}n=t+1,e--}if(r===0&&(r=this.data.length),n>=r||e>0){if(t)throw Error(`[series] - no value at index ${e}`);return}}let i=this.data.slice(n,r);return this.dataType.equals(J.STRING)?new TextDecoder().decode(i):le(JSON.parse(new TextDecoder().decode(i)))}binarySearch(e){let t=0,n=this.length-1,r=xr(e);for(;t<=n;){let i=Math.floor((t+n)/2),a=r(this.at(i,!0),e);if(a===0)return i;a<0?t=i+1:n=i-1}return t}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(J.FLOAT32)&&!this.dataType.equals(J.UINT8))throw Error(`Only FLOAT32 and UINT8 arrays can be used in WebGL`);let{buffer:t,bufferUsage:n,prevBuffer:r}=this.gl;if(t??(this.gl.buffer=e.createBuffer()),this.writePos!==r)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Z){r===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);let t=this.dataType.density.size(r).valueOf(),n=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,t,n.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,n===`static`?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=Z}as(e){return ss(e,this.dataType),this}get digest(){return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:bs(this.alignmentBounds.lower),upper:bs(this.alignmentBounds.upper),multiple:this.alignmentMultiple},timeRange:this.timeRange.toString(),length:this.length,capacity:this.capacity}}get alignmentBounds(){return E(this.alignment,this.alignment+BigInt(this.length)*this.alignmentMultiple)}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 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){let e=new ps(this);return this.dataType.equals(J.JSON)?new ms(e):e}return this.dataType.equals(J.UUID)?new hs(this):new gs(this)}slice(e,t){return this.sliceSub(!1,e,t)}sub(e,t){return this.sliceSub(!0,e,t)}subIterator(e,t){return new fs(this,e,t??this.length)}subAlignmentIterator(e,t){let n=Math.ceil(Number(e-this.alignment)/Number(this.alignmentMultiple)),r=Math.ceil(Number(t-this.alignment)/Number(this.alignmentMultiple));return new fs(this,n,r)}subBytes(t,n){return t>=0&&(n==null||n>=this.byteLength.valueOf())?this:new e({data:this.data.subarray(t,n),dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(t)})}sliceSub(t,n,r){if(n<=0&&(r==null||r>=this.length))return this;let i;return i=t?this.data.subarray(n,r):this.data.slice(n,r),new e({data:i,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(n)})}reAlign(t){return new e({data:this.buffer,dataType:this.dataType,timeRange:q.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:`static`,alignment:t})}toString(){let e=`Series(${this.dataType.toString()} ${this.length} [`;if(this.length<=10)e+=Array.from(this).map(e=>e.toString());else{for(let t=0;t<5;t++)e+=`${this.at(t)?.toString()}`,e+=`,`;e+=`...,`;for(let t=-5;t<0;t++)e+=this.at(t)?.toString(),t<-1&&(e+=`,`)}return e+=`])`,e}},us=e=>e==null?!1:Array.isArray(e)||e instanceof ArrayBuffer||ArrayBuffer.isView(e)&&!(e instanceof DataView)||e instanceof ls?!0:No(e),ds=Wr(cs,ls),fs=class{series;end;index;constructor(e,t,n){this.series=e;let r=E(0,e.length+1);this.end=kn(r,n),this.index=kn(r,t)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}},ps=class{series;index;decoder;constructor(e){if(!e.dataType.isVariable)throw Error(`cannot create a variable series iterator for a non-variable series`);this.series=e,this.index=0,this.decoder=new TextDecoder}next(){let e=this.index,t=this.series.data;for(;this.index<t.length&&t[this.index]!==os;)this.index++;let n=this.index;return e===n?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,n))})}},ms=class e{wrapped;static schema=l.z.record(l.z.string(),l.z.unknown());constructor(e){this.wrapped=e}next(){let t=this.wrapped.next();return t.done===!0?{done:!0,value:void 0}:{done:!1,value:mr.decodeString(t.value,e.schema)}}},hs=class{series;index;data;density;constructor(e){if(!e.dataType.equals(J.UUID))throw Error(`cannot create a UUID series iterator for a non-UUID series`);this.series=e,this.index=0,this.data=new Uint8Array(e.buffer),this.density=J.UUID.density.valueOf()}next(){if(this.index>=this.series.length)return{done:!0,value:void 0};let e=ts(this.data,this.index*this.density);return this.index++,{done:!1,value:e}}},gs=class{series;index;constructor(e){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)}}},_s=class{series;constructor(e=[]){if(e.length!==0){let t=e[0].dataType;for(let n=1;n<e.length;n++)if(!e[n].dataType.equals(t))throw Error(`[multi-series] - series must have the same data type`)}this.series=e}as(e){return ss(e,this.dataType),this}get dataType(){return this.series.length===0?J.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?q.ZERO:new q(this.series[0].timeRange.start,this.series[this.series.length-1].timeRange.end)}get alignment(){return this.series.length===0?0n:this.series[0].alignment}get alignmentBounds(){return this.series.length===0?E(0n,0n):E(this.series[0].alignmentBounds.lower,this.series[this.series.length-1].alignmentBounds.upper)}push(e){let t=()=>Error(`cannot push a ${e.dataType.toString()} series to a ${this.dataType.toString()} multi-series`),n=e.dataType.equals(this.dataType);if(ds(e)){if(this.series.length!==0&&!n)throw t();this.series.push(e)}else{if(this.series.length!==0&&e.series.length!==0&&!n)throw t();this.series.push(...e.series)}}get length(){return this.series.reduce((e,t)=>e+t.length,0)}atAlignment(e,t){for(let n of this.series)if(D(n.alignmentBounds,e))return n.atAlignment(e,t);if(t)throw Error(`[series] - no value at alignment ${e}`)}at(e,t=!1){e<0&&(e=this.length+e);for(let n of this.series){if(e<n.length)return n.at(e,t);e-=n.length}if(t)throw Error(`[series] - no value at index ${e}`)}subIterator(e,t){return new ys(this,e,t??this.length)}subAlignmentIterator(e,t){if(e>=this.alignmentBounds.upper||t<=this.alignmentBounds.lower)return rs;let n=0;for(let t=0;t<this.series.length;t++){let r=this.series[t];if(e<r.alignment)break;if(e>=r.alignmentBounds.upper)n+=r.length;else if(D(r.alignmentBounds,e)){n+=Math.ceil(Number(e-r.alignment)/Number(r.alignmentMultiple));break}}let r=0;for(let e=0;e<this.series.length;e++){let n=this.series[e];if(t<n.alignment)break;if(t>=n.alignmentBounds.upper)r+=n.length;else if(D(n.alignmentBounds,t)){r+=Math.ceil(Number(t-n.alignment)/Number(n.alignmentMultiple));break}}return new ys(this,n,r)}subAlignmentSpanIterator(e,t){if(e>=this.alignmentBounds.upper)return rs;t=Math.min(t,Number(this.distance(e,this.alignmentBounds.upper)));let n=0;for(let t=0;t<this.series.length;t++){let r=this.series[t];if(e<r.alignment)break;if(e>=r.alignmentBounds.upper)n+=r.length;else if(D(r.alignmentBounds,e)){n+=Number(e-r.alignment);break}}return new ys(this,n,n+t)}updateGLBuffer(e){this.series.forEach(t=>t.updateGLBuffer(e))}get bounds(){return In(this.series.map(e=>e.bounds))}get byteLength(){return new Y(this.series.reduce((e,t)=>e+t.byteLength.valueOf(),0))}get data(){let e=new this.dataType.Array(this.length),t=0;for(let n of this.series)e.set(n.data,t),t+=n.length;return new this.dataType.Array(e.buffer)}traverseAlignment(e,t){return Hn(this.series.map(e=>e.alignmentBounds),e,t)}acquire(e){this.series.forEach(t=>t.acquire(e))}release(){this.series.forEach(e=>e.release())}distance(e,t){return Un(this.series.map(e=>e.alignmentBounds),e,t)}parseJSON(e){if(!this.dataType.equals(J.JSON))throw Error(`cannot parse non-JSON series as JSON`);return this.series.flatMap(t=>t.parseJSON(e))}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new vs(this.series)}toStrings(){return this.series.flatMap(e=>e.toStrings())}},vs=class{series;seriesIndex;internal;constructor(e){this.series=e,this.seriesIndex=0,this.internal=e[0][Symbol.iterator]()}next(){let e=this.internal.next();return e.done===!1?e:this.seriesIndex===this.series.length-1?{done:!0,value:void 0}:(this.internal=this.series[++this.seriesIndex][Symbol.iterator](),this.next())}[Symbol.iterator](){return this}},ys=class{series;index;end;constructor(e,t,n){this.series=e,this.end=n,this.index=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}},bs=e=>({domain:e>>32n,sample:e&4294967295n}),xs=o({DataType:()=>J,Density:()=>K,MultiSeries:()=>_s,Rate:()=>Ao,Series:()=>ls,Size:()=>Y,TimeRange:()=>q,TimeSpan:()=>G,TimeStamp:()=>W,convertDataType:()=>Po,dataTypeZ:()=>Bo,isCrudeSeries:()=>us,isTelemValue:()=>No,numericTimeRangeZ:()=>jo,rateZ:()=>Ro,sizeZ:()=>zo,timeRangeBoundedZ:()=>Vo,timeRangeZ:()=>Fo,timeSpanZ:()=>Lo,timeStampZ:()=>Io,typedArrayZ:()=>Mo}),Ss=o({sleep:()=>Cs}),Cs=async e=>await new Promise(t=>setTimeout(t,G.fromMilliseconds(e).milliseconds)),ws=o({Breaker:()=>Ts,breakerConfigZ:()=>Es}),Ts=class{config;retries;interval;constructor(e){this.config={baseInterval:new G(e?.baseInterval??G.seconds(1)),maxRetries:e?.maxRetries??5,scale:e?.scale??1,sleepFn:e?.sleepFn??Cs},this.retries=0,this.interval=new G(this.config.baseInterval)}async wait(){let{maxRetries:e,scale:t,sleepFn:n}=this.config;return this.retries>=e?!1:(await n(this.interval),this.interval=this.interval.mult(t),this.retries++,!0)}get retryMessage(){return`breaker triggered ${this.retries+1}/${this.config.maxRetries} times, retrying in ${this.interval.toString()}`}reset(){this.retries=0,this.interval=this.config.baseInterval}},Es=l.z.object({baseInterval:G.z.optional(),maxRetries:l.z.number().optional(),scale:l.z.number().optional()}),Ds=o({Z:()=>Os}),Os=e=>l.z.object({variant:l.z.enum([`set`,`delete`]),key:l.z.string(),value:e}),ks=l.z.string().regex(/^#?([0-9a-f]{6}|[0-9a-f]{8})$/i),Q=er,As=l.z.number().min(0).max(1),js=l.z.tuple([Q,Q,Q,As]),Ms=l.z.tuple([Q,Q,Q]),Ns=l.z.object({rgba255:js}),Ps=l.z.object({r:Q,g:Q,b:Q,a:As}),Fs=l.z.number().min(0).max(360),Is=l.z.number().min(0).max(100),Ls=l.z.number().min(0).max(100),Rs=l.z.tuple([Fs,Is,Ls,As]),zs=l.z.union([ks,Ms,js,Rs,Ns,Ps]),Bs=zs.transform(e=>$(e)),Vs=e=>Bs.safeParse(e).success,Hs=e=>js.safeParse(e).success,Us=(e=>{if(e==null)return;let t=Bs.safeParse(e);if(t.success)return Ks(t.data);if(typeof e==`string`)return e;throw t.error}),$=(e,t=1)=>{if(e=zs.parse(e),typeof e==`string`)return uc(e,t);if(Array.isArray(e)){if(e.length<3||e.length>4)throw Error(`Invalid color: [${e.join(`, `)}]`);return e.length===3?[...e,t]:e}return`a`in e&&`r`in e?[e.r,e.g,e.b,e.a]:e.rgba255},Ws=(e,t)=>{if(e==null||t==null)return e==t;let n=$(e),r=$(t);return n.every((e,t)=>e===r[t])},Gs=(e=>{if(e==null)return;let[t,n,r,i]=$(e),a=Math.round(i*255);return`#${fc(t)}${fc(n)}${fc(r)}${a===255?``:fc(a)}`}),Ks=e=>{let[t,n,r,i]=$(e);return`rgba(${t}, ${n}, ${r}, ${i})`},qs=e=>`rgb(${Js(e)})`,Js=e=>{let[t,n,r]=$(e);return`${t}, ${n}, ${r}`},Ys=e=>[...Xs(e),ec(e)],Xs=e=>[Zs(e)/255,Qs(e)/255,$s(e)/255],Zs=e=>$(e)[0],Qs=e=>$(e)[1],$s=e=>$(e)[2],ec=e=>$(e)[3],tc=e=>Ws(dc,e),nc=e=>yc($(e)),rc=(e,t)=>{let[n,r,i]=$(e);if(t>100)throw Error(`Color opacity must be between 0 and 100, got ${t}`);return t>1&&(t/=100),[n,r,i,t]},ic=e=>{let[t,n,r]=Xs(e).map(e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4);return Number((.2126*t+.7152*n+.0722*r).toFixed(3))},ac=e=>{let[t,n,r]=Xs(e);return 1-(Math.max(t,n,r)-Math.min(t,n,r))},oc=(e,t)=>{let n=$(e),r=$(t),i=ic(n),a=ic(r);return(Math.max(i,a)+.5)/(Math.min(i,a)+.5)},sc=(e,...t)=>{if(t.length===0)throw Error(`[Color.pickByContrast] - must provide at least one color`);let n=$(e),[r]=t.sort((e,t)=>oc(n,t)-oc(n,e));return $(r)},cc=e=>ic(e)<.5,lc=e=>ic(e)>.5,uc=(e,t=1)=>(e=ks.parse(e),e=mc(e),[pc(e,0),pc(e,2),pc(e,4),e.length===8?pc(e,6)/255:t]),dc=[0,0,0,0],fc=e=>Math.floor(e).toString(16).padStart(2,`0`),pc=(e,t)=>parseInt(e.slice(t,t+2),16),mc=e=>e.startsWith(`#`)?e.slice(1):e,hc={black:`#000000`,white:`#ffffff`,red:`#ff0000`,green:`#008000`,blue:`#0000ff`,yellow:`#ffff00`,cyan:`#00ffff`,magenta:`#ff00ff`,silver:`#c0c0c0`,gray:`#808080`,grey:`#808080`,maroon:`#800000`,olive:`#808000`,lime:`#00ff00`,aqua:`#00ffff`,teal:`#008080`,navy:`#000080`,fuchsia:`#ff00ff`,purple:`#800080`,orange:`#ffa500`,brown:`#a52a2a`,tan:`#d2b48c`,gold:`#ffd700`,indigo:`#4b0082`,violet:`#ee82ee`,pink:`#ffc0cb`,coral:`#ff7f50`,salmon:`#fa8072`,khaki:`#f0e68c`,crimson:`#dc143c`,transparent:`transparent`},gc=e=>{if(!e)return;let t=e.trim().toLowerCase();if(!(t===`transparent`||t===`none`)){if(t.startsWith(`#`)){if(t.length===4){let e=t[1],n=t[2],r=t[3],i=`#${e}${e}${n}${n}${r}${r}`;if(ks.safeParse(i).success)return uc(i)}return(t.length===7||t.length===9)&&ks.safeParse(t).success?uc(t):void 0}if(t.startsWith(`rgb`)){let e=t.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/);if(e){let[,t,n,r,i]=e;return[parseInt(t,10),parseInt(n,10),parseInt(r,10),i?parseFloat(i):1]}}if(hc[t])return uc(hc[t])}},_c=e=>{e=Rs.parse(e);let[t,n,r]=e,i=e[3];t/=360,n/=100,r/=100;let a,o,s;if(n===0)a=o=s=r;else{let e=r<.5?r*(1+n):r+n-r*n,i=2*r-e;a=vc(i,e,t+1/3),o=vc(i,e,t),s=vc(i,e,t-1/3)}return[Math.round(a*255),Math.round(o*255),Math.round(s*255),i]},vc=(e,t,n)=>(n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e),yc=e=>{e=js.parse(e);let[t,n,r]=e,i=e[3];t/=255,n/=255,r/=255;let a=Math.max(t,n,r),o=Math.min(t,n,r),s,c,l=(a+o)/2;if(a===o)s=c=0;else{let e=a-o;c=l>.5?e/(2-a-o):e/(a+o),s=a===t?(n-r)/e+(n<r?6:0):a===n?(r-t)/e+2:(t-n)/e+4,s/=6}return s*=360,c*=100,l*=100,[Math.round(s),Math.round(c),Math.round(l),i]},bc=$(`#000000`),xc=$(`#ffffff`),Sc=l.z.object({key:l.z.string(),color:zs,position:l.z.number(),switched:l.z.boolean().optional()}),Cc=l.z.array(Sc),wc=(e,t)=>{if(e.length===0)return dc;if(e=e.slice().sort((e,t)=>e.position-t.position),t<=e[0].position)return $(e[0].color);if(t>=e[e.length-1].position)return $(e[e.length-1].color);for(let n=0;n<e.length-1;n++){let r=e[n],i=e[n+1];if(t<r.position||t>i.position)continue;if(t===r.position)return $(r.color);if(t===i.position)return $(i.color);let a=(t-r.position)/(i.position-r.position),o=$(r.color),s=$(i.color);return $([Math.round(Zs(o)+a*(Zs(s)-Zs(o))),Math.round(Qs(o)+a*(Qs(s)-Qs(o))),Math.round($s(o)+a*($s(s)-$s(o))),ec(o)+a*(ec(s)-ec(o))])}return $(e[e.length-1].color)},Tc=l.z.object({key:l.z.string(),name:l.z.string(),color:Bs}),Ec=l.z.object({key:l.z.string(),name:l.z.string(),swatches:l.z.array(Tc)}),Dc=o({BLACK:()=>bc,WHITE:()=>xc,ZERO:()=>dc,aValue:()=>ec,bValue:()=>$s,colorZ:()=>Bs,construct:()=>$,contrast:()=>oc,crudeZ:()=>zs,cssString:()=>Us,equals:()=>Ws,fromCSS:()=>gc,fromGradient:()=>wc,fromHSLA:()=>_c,gValue:()=>Qs,gradientZ:()=>Cc,grayness:()=>ac,hex:()=>Gs,hsla:()=>nc,isColor:()=>Hs,isCrude:()=>Vs,isDark:()=>cc,isLight:()=>lc,isZero:()=>tc,luminance:()=>ic,paletteZ:()=>Ec,pickByContrast:()=>sc,rValue:()=>Zs,rgbCSS:()=>qs,rgbString:()=>Js,rgba1:()=>Ys,rgbaCSS:()=>Ks,setAlpha:()=>rc,stopZ:()=>Sc}),Oc=er,kc=function(e){return e[e.exclusive=0]=`exclusive`,e[e.shared=1]=`shared`,e}({}),Ac=l.z.enum(kc),jc=l.z.object({key:l.z.string(),name:l.z.string(),group:l.z.uint32().optional()}),Mc=e=>l.z.object({subject:jc,resource:e,authority:Oc}),Nc={lower:0,upper:256},Pc=(...e)=>t=>t.filter(t=>{let n=!1;return t.to!=null&&(n=e.includes(t.to.resource)),t.from!=null&&!n&&(n=e.includes(t.from.resource)),n}),Fc=e=>l.z.object({from:Mc(e),to:l.z.null().optional()}),Ic=e=>l.z.object({from:l.z.null().optional(),to:Mc(e)}),Lc=e=>l.z.union([Fc(e),Ic(e),l.z.object({from:Mc(e),to:Mc(e)})]),Rc=o({ABSOLUTE_AUTHORITY:()=>255,AUTHORITY_BOUNDS:()=>Nc,Concurrency:()=>kc,ZERO_AUTHORITY:()=>0,acquireZ:()=>Ic,authorityZ:()=>Oc,concurrencyZ:()=>Ac,filterTransfersByChannelKey:()=>Pc,releaseZ:()=>Fc,stateZ:()=>Mc,subjectZ:()=>jc,transferZ:()=>Lc}),zc=o({formatValue:()=>Bc}),Bc=e=>{switch(typeof e){case`bigint`:case`number`:return e.toString();case`boolean`:return e?`1`:`0`;case`undefined`:return``;case`string`:case`symbol`:case`function`:return Hc(e.toString());case`object`:return e==null?``:Hc(JSON.stringify(e))}},Vc=/[",\n]/,Hc=e=>Vc.test(e)?`"${e.replace(/"/g,`""`)}"`:e,Uc=(e,t)=>{let n=null;return t===0?e:(...r)=>{n!==null&&(clearTimeout(n),n=null),n=setTimeout(()=>e(...r),t)}},Wc=(e,t)=>{let n=null;return t===0?e:(...r)=>{n===null&&(n=setTimeout(()=>{e(...r),n=null},t))}},Gc=o({}),Kc=o({ZERO_PRIMITIVES:()=>Xc,pointerZ:()=>qc,primitiveTypeZ:()=>Yc,primitiveZ:()=>Jc}),qc=l.z.string().regex(/^(?:$|(?:\/(?:[^~/]|~0|~1)*)+)$/,`must be a valid JSON pointer (RFC 6901)`),Jc=l.z.union([l.z.string(),l.z.number(),l.z.boolean(),l.z.null()]),Yc=l.z.enum([`string`,`number`,`boolean`,`null`]),Xc={string:``,number:0,boolean:!1,null:null},Zc=class{store=new Map;async get(e){return this.store.get(e)??null}async set(e,t){this.store.set(e,t)}async delete(e){this.store.delete(e)}async length(){return this.store.size}async clear(){this.store.clear()}},Qc=class{store=new Map;get(e){return this.store.get(e)??null}set(e,t){this.store.set(e,t)}delete(e){this.store.delete(e)}},$c=l.z.object({key:l.z.string(),value:l.z.string()}),el=o({MockAsync:()=>Zc,MockSync:()=>Qc,stringPairZ:()=>$c}),tl=o({keyZ:()=>nl,labelZ:()=>rl,newZ:()=>il}),nl=l.z.uuid(),rl=l.z.object({key:nl,name:l.z.string().min(1),color:Bs}),il=rl.partial({key:!0}),al=o({is:()=>sl}),ol=RegExp(`^(https?:\\/\\/)?((([a-zA-Z0-9][a-zA-Z0-9-]*\\.)+[a-zA-Z]{2,})|localhost|(\\d{1,3}\\.){3}\\d{1,3})(\\:\\d+)?(\\/[-a-zA-Z0-9@:%._\\+~#=]*)*(\\?[;&a-zA-Z0-9%_.,~+=-]*)?(#[-a-zA-Z0-9_]*)?$`),sl=e=>ol.test(e),cl=o({getOrSetDefault:()=>ll}),ll=(e,t,n)=>{let r=e.get(t);return r===void 0?(e.set(t,n),n):r},ul=o({compareSemVer:()=>pl,createMigration:()=>_l,migrator:()=>vl,semVerNewer:()=>hl,semVerOlder:()=>gl,semVerZ:()=>dl,versionsEqual:()=>ml}),dl=l.z.string().regex(/^\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/),fl=(e,t)=>{let n=e.split(`.`),r=t.split(`.`),i=Math.max(n.length,r.length);for(let e=0;e<i;e++){let t=n[e],i=r[e];if(t===void 0)return-1;if(i===void 0)return 1;let a=/^\d+$/.test(t),o=/^\d+$/.test(i);if(a&&!o)return-1;if(!a&&o)return 1;if(a&&o){let e=parseInt(t,10),n=parseInt(i,10);if(e<n)return-1;if(e>n)return 1}else{if(t<i)return-1;if(t>i)return 1}}return 0},pl=((e,t,n={})=>{n.checkMajor??=!0,n.checkMinor??=!0,n.checkPatch??=!0;let r=dl.parse(e),i=dl.parse(t),[a,o]=r.split(`-`),[s,c]=i.split(`-`),[l,u,d]=a.split(`.`).map(Number),[f,p,m]=s.split(`.`).map(Number);if(n.checkMajor){if(l<f)return-1;if(l>f)return 1}if(n.checkMinor){if(u<p)return-1;if(u>p)return 1}if(n.checkPatch){if(d<m)return-1;if(d>m)return 1}return o===void 0&&c===void 0?0:o===void 0?1:c===void 0?-1:fl(o,c)}),ml=(e,t,n={})=>jr(pl(e,t,n)),hl=(e,t,n={})=>kr(pl(e,t,n)),gl=(e,t,n={})=>Or(pl(e,t,n)),_l=({name:e,migrate:t})=>n=>{try{let r=t(n);return console.log(`${e} migrated: ${n.version} -> ${r.version}`),r}catch(t){throw console.log(`${e} failed to migrate from ${n.version}`),console.error(t),t}},vl=({name:e,migrations:t,targetSchema:n,defaultVersion:r,def:i})=>{let a=Object.keys(t).sort(pl).pop();if(a==null)return t=>{if(t.version??=r,t.version!==i.version)return console.log(`${e} version ${t.version} is newer than latest version of ${i.version}.
|
|
7
15
|
Returning default instead.
|
|
8
|
-
`),i;try{return n==null?t:n.parse(t)}catch(t){return console.log(`${e} failed to parse default. Exiting with default`),console.error(t),i}};let o=Object.keys(t).length,s=!1,c=n=>{try{if(o===0||
|
|
16
|
+
`),i;try{return n==null?t:n.parse(t)}catch(t){return console.log(`${e} failed to parse default. Exiting with default`),console.error(t),i}};let o=Object.keys(t).length,s=!1,c=n=>{try{if(o===0||hl(n.version,a))return console.log(s?`${e} ${n.version} now up to date`:`${e} version ${n.version} is up to date with target version ${i.version}`),n;let r=t[n.version],l=r(n);return s=!0,c(l)}catch(t){return console.log(`${e} failed to migrate from ${n.version} to ${a}`),console.error(t),i}};return t=>{try{if(t.version==null)if(r!=null)console.log(`${e} version is null. Setting version to default of ${r}`),t.version=r;else return console.log(`${e} version is null and no default version set. Exiting with default`),i;return c(t)}catch(t){return console.log(`${e} failed to parse final result. Exiting with default`),console.error(t),i}}},yl=o({NOTATIONS:()=>bl,notationZ:()=>xl,stringifyNumber:()=>Sl}),bl=[`standard`,`scientific`,`engineering`],xl=l.z.enum(bl),Sl=(e,t,n)=>{if(Number.isNaN(e))return`NaN`;if(e===1/0)return`∞`;if(e===-1/0)return`-∞`;if(n===`standard`)return e.toFixed(t);if(e===0)return t===0?`0ᴇ0`:`0.${`0`.repeat(t)}ᴇ0`;let r;return r=n===`scientific`?Math.floor(Math.log10(Math.abs(e))):Math.floor(Math.log10(Math.abs(e))/3)*3,`${(e/10**r).toFixed(t)}ᴇ${r}`},Cl=o({BaseObserver:()=>Tl,Observer:()=>wl}),wl=class{handlers;transform;closer;constructor(e,t){this.transform=e,this.handlers=t??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){let t=e;if(this.transform!=null){let[n,r]=this.transform(e);if(!r)return;t=n}this.handlers.forEach((e,n)=>n(t))}setCloser(e){this.closer=e}async close(){return await this.closer?.()}},Tl=class{handlers;constructor(e){this.handlers=e??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){this.handlers.forEach((t,n)=>n(e))}},El=o({}),Dl=o({entries:()=>Al,keyZ:()=>Ol,map:()=>jl,nullishToEmpty:()=>Pl,omit:()=>Nl,purgeUndefined:()=>Ml,unknownZ:()=>kl}),Ol=l.z.union([l.z.string(),l.z.number()]),kl=()=>l.z.record(Ol,l.z.unknown()),Al=e=>Object.entries(e),jl=(e,t)=>Object.fromEntries(Al(e).map(([e,n])=>[e,t(n,e)])),Ml=e=>Object.fromEntries(Al(e).filter(([e,t])=>t!==void 0)),Nl=(e,...t)=>{let n={...e};for(let e of t)delete n[e];return n},Pl=()=>l.z.union([l.z.union([l.z.null(),l.z.undefined()]).transform(()=>({})),kl()]),Fl=()=>typeof process<`u`&&process.versions!=null&&process.versions.node!=null?`node`:typeof window>`u`||window.document===void 0?`webworker`:`browser`,Il=Fl(),Ll=[`macOS`,`Windows`,`Linux`],Rl=[`macos`,`windows`,`linux`],zl={macos:`macOS`,windows:`Windows`,linux:`Linux`},Bl=l.z.enum(Ll).or(l.z.enum(Rl).transform(e=>zl[e])),Vl=()=>{if(typeof window>`u`)return;let e=window.navigator.userAgent.toLowerCase();if(e.includes(`mac`))return`macOS`;if(e.includes(`win`))return`Windows`;if(e.includes(`linux`))return`Linux`},Hl,Ul=((e={})=>{let{force:t,default:n}=e;return t??Hl??(Hl=Vl(),Hl??n)}),Wl=o({OPERATING_SYSTEMS:()=>Ll,RUNTIME:()=>Il,detect:()=>Fl,getOS:()=>Ul,osZ:()=>Bl}),Gl=o({flushMicrotasks:()=>Kl,flushTaskQueue:()=>ql}),Kl=()=>Promise.resolve(),ql=()=>new Promise(e=>setTimeout(e,0)),Jl=o({copy:()=>Yl}),Yl=e=>Array.isArray(e)?[...e]:typeof e==`object`&&e?{...e}:e,Xl=l.z.object({message:l.z.string().optional(),description:l.z.string().optional(),details:kl().optional()}),Zl=e=>`toStatus`in e&&typeof e.toStatus==`function`,Ql=e=>{if(!Zl(e))return;let t;try{t=e.toStatus()}catch{return}let n=Xl.safeParse(t);return n.success?n.data:void 0},$l=l.z.object({stack:l.z.string(),error:l.z.instanceof(Error)}).and(kl()),eu=(e,t)=>{if(!(e instanceof Error))throw e;let n={variant:`error`,message:t??e.message,description:t==null?void 0:e.message,details:{stack:e.stack??``,error:e}},r=Ql(e);return r!=null&&(t!=null&&r.message!=null?n.message=`${t}: ${r.message}`:r.message!=null&&(n.message=r.message),r.description!=null&&(n.description=r.description),r.details!=null&&n.details!=null&&(n.details={...n.details,...r.details})),tu(n)},tu=e=>({key:Hr(),time:W.now(),name:``,...e}),nu=(e,t=[])=>{if(e!=null)return Array.isArray(t)?t.includes(e)?e:void 0:t===e?e:void 0},ru=(e,t=[])=>{if(e!=null)return Array.isArray(t)?t.includes(e)?void 0:e:t===e?void 0:e},iu={includeTimestamp:!1,includeName:!0},au=e=>{if(e.includes(`
|
|
17
|
+
`))return`Description:\n${e}`;try{let t=JSON.parse(e);return`Description:\n${JSON.stringify(t,null,2)}`}catch{return`Description: ${e}`}},ou=(e,t={})=>{let n={...iu,...t},r=[],i=e.variant.toUpperCase();if(n.includeName&&ct(e.name)&&(i+=` [${e.name}]`),i+=`: ${e.message}`,n.includeTimestamp&&(i+=` (${e.time.toString(`dateTime`,`local`)})`),r.push(i),e.description!=null&&r.push(au(e.description)),`details`in e&&g(e.details)){let t=e.details;`stack`in t&&typeof t.stack==`string`&&t.stack!==``&&r.push(`Stack Trace:\n${t.stack}`);let n=Object.fromEntries(Object.entries(t).filter(([e])=>e!==`stack`&&e!==`error`));Object.keys(n).length>0&&r.push(`Details:\n${JSON.stringify(n,null,2)}`)}return r.join(`
|
|
9
18
|
|
|
10
|
-
`)},kl=[`success`,`info`,`warning`,`error`,`loading`,`disabled`],Al=l.z.enum(kl),jl=l.z.literal(`success`),Ml=l.z.literal(`info`),Nl=l.z.literal(`warning`),Pl=l.z.literal(`error`),Fl=l.z.literal(`loading`),Il=l.z.literal(`disabled`),Ll=({details:e,v:t}={})=>l.z.object({key:l.z.string().default(()=>et()),name:l.z.string().default(``),variant:t??Al,message:l.z.string(),description:l.z.string().optional(),time:ma.default(()=>V.now()),details:e??l.z.unknown().optional(),labels:so(kc.array())}),Rl=({details:e,v:t}={})=>Ll({details:e,v:t}).partial({key:!0,name:!0,time:!0}),zl=o({VARIANTS:()=>kl,create:()=>wl,disabledVariantZ:()=>Il,errorVariantZ:()=>Pl,exceptionDetailsSchema:()=>Sl,fromException:()=>Cl,infoVariantZ:()=>Ml,keepVariants:()=>Tl,loadingVariantZ:()=>Fl,newZ:()=>Rl,removeVariants:()=>El,statusZ:()=>Ll,successVariantZ:()=>jl,toString:()=>Ol,variantZ:()=>Al,warningVariantZ:()=>Nl}),Bl=(e,t)=>{if(!t.has(e))return e;let n,r,i=e;for(;t.has(i);){let e=i.match(Vl);e?(n=i.slice(0,e.index).trim(),r=parseInt(e[1],10)+1):(n=i,r=1),i=`${n} (${r})`}return i},Vl=/\((\d+)\)$/,Hl=(e,t=``)=>{if(typeof e==`string`)return e;let n=e.length;return n===0?t:n===1?e[0]:n===2?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(`, `)}, and ${e[n-1]}`},Ul=e=>{let t=e.split(` `),n=new Set,r=t.map(e=>e.charAt(0).toLowerCase()).join(``);n.add(r.replace(/-/g,`_`)),n.add(r.replace(/(.)(.)/g,`$1_$2`).replace(/-/g,`_`));let i=/\d+/g;e.match(i)&&t.forEach((e,r)=>{if(i.test(e)){let e=t.map((e,t)=>t===r?e:e.charAt(0).toLowerCase()).join(``);n.add(e.replace(/-/g,`_`)),n.add(e.replace(/(.)(.)/g,`$1_$2`).replace(/-/g,`_`))}});let a=t.map(e=>(e.length>3?e.substring(0,3):e).toLowerCase());return n.add(a.join(``).replace(/-/g,`_`)),n.add(a.join(`_`).replace(/-/g,`_`)),Array.from(n).filter(e=>e.length>=2&&e.length<=12&&!/^\d/.test(e))},Wl=(e,t)=>e.startsWith(t)?e.slice(t.length):e,Gl=o({createShortIdentifiers:()=>Ul,deduplicateFileName:()=>Bl,naturalLanguageJoin:()=>Hl,trimPrefix:()=>Wl}),Kl=Error(`request for lock canceled`),ql=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},Jl=class{constructor(e,t=Kl){this._value=e,this._cancelError=t,this._queue=[],this._weightedWaiters=[]}acquire(e=1,t=0){if(e<=0)throw Error(`invalid weight ${e}: must be positive`);return new Promise((n,r)=>{let i={resolve:n,reject:r,weight:e,priority:t},a=Xl(this._queue,e=>t<=e.priority);a===-1&&e<=this._value?this._dispatchItem(i):this._queue.splice(a+1,0,i)})}runExclusive(e){return ql(this,arguments,void 0,function*(e,t=1,n=0){let[r,i]=yield this.acquire(t,n);try{return yield e(r)}finally{i()}})}waitForUnlock(e=1,t=0){if(e<=0)throw Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,t)?Promise.resolve():new Promise(n=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),Yl(this._weightedWaiters[e-1],{resolve:n,priority:t})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){let t=this._value;this._value-=e.weight,e.resolve([t,this._newReleaser(e.weight)])}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){let t=this._weightedWaiters[e-1];t&&(t.forEach(e=>e.resolve()),this._weightedWaiters[e-1]=[])}else{let e=this._queue[0].priority;for(let t=this._value;t>0;t--){let n=this._weightedWaiters[t-1];if(!n)continue;let r=n.findIndex(t=>t.priority<=e);(r===-1?n:n.splice(0,r)).forEach((e=>e.resolve()))}}}_couldLockImmediately(e,t){return(this._queue.length===0||this._queue[0].priority<t)&&e<=this._value}};function Yl(e,t){let n=Xl(e,e=>t.priority<=e.priority);e.splice(n+1,0,t)}function Xl(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}var Zl=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},Ql=class{constructor(e){this._semaphore=new Jl(1,e)}acquire(){return Zl(this,arguments,void 0,function*(e=0){let[,t]=yield this._semaphore.acquire(1,e);return t})}runExclusive(e,t=0){return this._semaphore.runExclusive(()=>e(),1,t)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}},$l=o({mutex:()=>eu,newMutex:()=>tu}),eu=class extends Ql{constructor(e){super(),Object.assign(this,e)}},tu=e=>new eu(e),nu=o({expectAlways:()=>iu,toString:()=>ru}),ru=e=>JSON.stringify(e,(e,t)=>typeof t==`bigint`?t.toString():t),iu=async(e,t=200,n=20)=>{let r=Date.now();for(;Date.now()-r<t;)await e(),await new Promise(e=>setTimeout(e,n))},au=(...e)=>e.map(ou).join(``),ou=e=>(e.endsWith(`/`)||(e+=`/`),e.startsWith(`/`)&&(e=e.slice(1)),e),su=e=>e.endsWith(`/`)?e.slice(0,-1):e,cu=(e,t=``)=>e===null?``:`?${Object.entries(e).filter(([,e])=>e==null?!1:Array.isArray(e)?e.length>0:!0).map(([e,n])=>`${t}${e}=${n}`).join(`&`)}`,lu=class e{protocol;host;port;path;constructor({host:e,port:t,protocol:n=``,pathPrefix:r=``}){this.protocol=n,this.host=e,this.port=t,this.path=ou(r)}replace(t){return new e({host:t.host??this.host,port:t.port??this.port,protocol:t.protocol??this.protocol,pathPrefix:t.pathPrefix??this.path})}child(t){return new e({...this,pathPrefix:au(this.path,t)})}toString(){return su(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}static UNKNOWN=new e({host:`unknown`,port:0})},uu=class{sender;handlers;constructor(e){this.sender=e,this.handlers=new Map}handle({data:e}){let t=this.handlers.get(e.type)?.handler;t==null?console.warn(`No handler for ${e.type}`):t(e.payload)}route(e){let t=new fu(du(e,this.sender));return this.handlers.set(e,t),t}},du=(e,t)=>(n,r)=>t({type:e,payload:n},r),fu=class{_send;handler;constructor(e){this._send=e,this.handler=null}send(e,t=[]){this._send(e,t)}handle(e){this.handler=e}},pu=()=>{let e,t;return e=new uu(e=>{t.handle({data:e})}),t=new uu(t=>{e.handle({data:t})}),[e,t]};exports.DataType=K,exports.Density=W,exports.MultiSeries=Ya,exports.OUTER_LOCATIONS=lr,exports.Rate=U,exports.RoutedWorker=uu,exports.Series=Va,exports.Size=q,exports.TimeRange=G,exports.TimeSpan=H,exports.TimeStamp=V,exports.TypedWorker=fu,exports.URL=lu,Object.defineProperty(exports,`array`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`binary`,{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,`bounds`,{enumerable:!0,get:function(){return Yt}}),Object.defineProperty(exports,`box`,{enumerable:!0,get:function(){return zr}}),Object.defineProperty(exports,`breaker`,{enumerable:!0,get:function(){return no}}),exports.buildQueryString=cu,Object.defineProperty(exports,`caseconv`,{enumerable:!0,get:function(){return te}}),Object.defineProperty(exports,`change`,{enumerable:!0,get:function(){return ao}}),exports.clamp=zi,Object.defineProperty(exports,`color`,{enumerable:!0,get:function(){return Is}}),Object.defineProperty(exports,`compare`,{enumerable:!0,get:function(){return qe}}),Object.defineProperty(exports,`control`,{enumerable:!0,get:function(){return qs}}),exports.convertDataType=fa,exports.createMockWorkers=pu,Object.defineProperty(exports,`csv`,{enumerable:!0,get:function(){return Js}}),exports.dataTypeZ=va,exports.debounce=Qs,Object.defineProperty(exports,`deep`,{enumerable:!0,get:function(){return Mo}}),Object.defineProperty(exports,`destructor`,{enumerable:!0,get:function(){return ec}}),Object.defineProperty(exports,`dimensions`,{enumerable:!0,get:function(){return Oi}}),Object.defineProperty(exports,`direction`,{enumerable:!0,get:function(){return Tn}}),Object.defineProperty(exports,`errors`,{enumerable:!0,get:function(){return rc}}),Object.defineProperty(exports,`id`,{enumerable:!0,get:function(){return Ye}}),Object.defineProperty(exports,`instance`,{enumerable:!0,get:function(){return tt}}),exports.isCrudeSeries=Ha,exports.isTelemValue=da,Object.defineProperty(exports,`json`,{enumerable:!0,get:function(){return vc}}),Object.defineProperty(exports,`kv`,{enumerable:!0,get:function(){return Ec}}),Object.defineProperty(exports,`label`,{enumerable:!0,get:function(){return Dc}}),Object.defineProperty(exports,`link`,{enumerable:!0,get:function(){return jc}}),Object.defineProperty(exports,`location`,{enumerable:!0,get:function(){return Pn}}),Object.defineProperty(exports,`map`,{enumerable:!0,get:function(){return Pc}}),Object.defineProperty(exports,`math`,{enumerable:!0,get:function(){return wn}}),Object.defineProperty(exports,`migrate`,{enumerable:!0,get:function(){return Ic}}),Object.defineProperty(exports,`narrow`,{enumerable:!0,get:function(){return _e}}),Object.defineProperty(exports,`notation`,{enumerable:!0,get:function(){return Gc}}),exports.numericTimeRangeZ=la,Object.defineProperty(exports,`observe`,{enumerable:!0,get:function(){return Yc}}),Object.defineProperty(exports,`optional`,{enumerable:!0,get:function(){return Qc}}),exports.outerLocationZ=ur,Object.defineProperty(exports,`primitive`,{enumerable:!0,get:function(){return Ee}}),exports.rateZ=ga,Object.defineProperty(exports,`record`,{enumerable:!0,get:function(){return $c}}),Object.defineProperty(exports,`runtime`,{enumerable:!0,get:function(){return gl}}),Object.defineProperty(exports,`scale`,{enumerable:!0,get:function(){return Bi}}),Object.defineProperty(exports,`scheduler`,{enumerable:!0,get:function(){return _l}}),Object.defineProperty(exports,`shallow`,{enumerable:!0,get:function(){return bl}}),exports.sizeZ=_a,Object.defineProperty(exports,`sleep`,{enumerable:!0,get:function(){return eo}}),Object.defineProperty(exports,`spatial`,{enumerable:!0,get:function(){return Zi}}),Object.defineProperty(exports,`status`,{enumerable:!0,get:function(){return zl}}),Object.defineProperty(exports,`sticky`,{enumerable:!0,get:function(){return Qi}}),Object.defineProperty(exports,`strings`,{enumerable:!0,get:function(){return Gl}}),Object.defineProperty(exports,`sync`,{enumerable:!0,get:function(){return $l}}),Object.defineProperty(exports,`telem`,{enumerable:!0,get:function(){return $a}}),Object.defineProperty(exports,`testutil`,{enumerable:!0,get:function(){return nu}}),exports.throttle=$s,exports.timeRangeBoundedZ=ya,exports.timeRangeZ=pa,exports.timeSpanZ=ha,exports.timeStampZ=ma,exports.typedArrayZ=ua,Object.defineProperty(exports,`unique`,{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(exports,`uuid`,{enumerable:!0,get:function(){return ja}}),Object.defineProperty(exports,`xy`,{enumerable:!0,get:function(){return dr}}),exports.xyZ=O,Object.defineProperty(exports,`zod`,{enumerable:!0,get:function(){return Lo}});
|
|
19
|
+
`)},su=[`success`,`info`,`warning`,`error`,`loading`,`disabled`],cu=l.z.enum(su),lu=l.z.literal(`success`),uu=l.z.literal(`info`),du=l.z.literal(`warning`),fu=l.z.literal(`error`),pu=l.z.literal(`loading`),mu=l.z.literal(`disabled`),hu=({details:e,v:t}={})=>l.z.object({key:l.z.string().default(()=>Hr()),name:l.z.string().default(``),variant:t??cu,message:l.z.string(),description:l.z.string().optional(),time:Io.default(()=>W.now()),details:e??l.z.unknown().optional(),labels:ye(rl.array())}),gu=({details:e,v:t}={})=>hu({details:e,v:t}).partial({key:!0,name:!0,time:!0}),_u=o({VARIANTS:()=>su,create:()=>tu,disabledVariantZ:()=>mu,errorVariantZ:()=>fu,exceptionDetailsSchema:()=>$l,fromException:()=>eu,infoVariantZ:()=>uu,keepVariants:()=>nu,loadingVariantZ:()=>pu,newZ:()=>gu,removeVariants:()=>ru,statusZ:()=>hu,successVariantZ:()=>lu,toString:()=>ou,variantZ:()=>cu,warningVariantZ:()=>du}),vu=(e,t)=>{if(!t.has(e))return e;let n,r,i=e;for(;t.has(i);){let e=i.match(yu);e?(n=i.slice(0,e.index).trim(),r=parseInt(e[1],10)+1):(n=i,r=1),i=`${n} (${r})`}return i},yu=/\((\d+)\)$/,bu=(e,t=``)=>{if(typeof e==`string`)return e;let n=e.length;return n===0?t:n===1?e[0]:n===2?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(`, `)}, and ${e[n-1]}`},xu=e=>{let t=e.split(` `),n=new Set,r=t.map(e=>e.charAt(0).toLowerCase()).join(``);n.add(r.replace(/-/g,`_`)),n.add(r.replace(/(.)(.)/g,`$1_$2`).replace(/-/g,`_`));let i=/\d+/g;e.match(i)&&t.forEach((e,r)=>{if(i.test(e)){let e=t.map((e,t)=>t===r?e:e.charAt(0).toLowerCase()).join(``);n.add(e.replace(/-/g,`_`)),n.add(e.replace(/(.)(.)/g,`$1_$2`).replace(/-/g,`_`))}});let a=t.map(e=>(e.length>3?e.substring(0,3):e).toLowerCase());return n.add(a.join(``).replace(/-/g,`_`)),n.add(a.join(`_`).replace(/-/g,`_`)),Array.from(n).filter(e=>e.length>=2&&e.length<=12&&!/^\d/.test(e))},Su=(e,t)=>e.startsWith(t)?e.slice(t.length):e,Cu=o({createShortIdentifiers:()=>xu,deduplicateFileName:()=>vu,naturalLanguageJoin:()=>bu,trimPrefix:()=>Su}),wu=Error(`request for lock canceled`),Tu=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},Eu=class{constructor(e,t=wu){this._value=e,this._cancelError=t,this._queue=[],this._weightedWaiters=[]}acquire(e=1,t=0){if(e<=0)throw Error(`invalid weight ${e}: must be positive`);return new Promise((n,r)=>{let i={resolve:n,reject:r,weight:e,priority:t},a=Ou(this._queue,e=>t<=e.priority);a===-1&&e<=this._value?this._dispatchItem(i):this._queue.splice(a+1,0,i)})}runExclusive(e){return Tu(this,arguments,void 0,function*(e,t=1,n=0){let[r,i]=yield this.acquire(t,n);try{return yield e(r)}finally{i()}})}waitForUnlock(e=1,t=0){if(e<=0)throw Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,t)?Promise.resolve():new Promise(n=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),Du(this._weightedWaiters[e-1],{resolve:n,priority:t})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){let t=this._value;this._value-=e.weight,e.resolve([t,this._newReleaser(e.weight)])}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){let t=this._weightedWaiters[e-1];t&&(t.forEach(e=>e.resolve()),this._weightedWaiters[e-1]=[])}else{let e=this._queue[0].priority;for(let t=this._value;t>0;t--){let n=this._weightedWaiters[t-1];if(!n)continue;let r=n.findIndex(t=>t.priority<=e);(r===-1?n:n.splice(0,r)).forEach((e=>e.resolve()))}}}_couldLockImmediately(e,t){return(this._queue.length===0||this._queue[0].priority<t)&&e<=this._value}};function Du(e,t){let n=Ou(e,e=>t.priority<=e.priority);e.splice(n+1,0,t)}function Ou(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}var ku=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},Au=class{constructor(e){this._semaphore=new Eu(1,e)}acquire(){return ku(this,arguments,void 0,function*(e=0){let[,t]=yield this._semaphore.acquire(1,e);return t})}runExclusive(e,t=0){return this._semaphore.runExclusive(()=>e(),1,t)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}},ju=o({mutex:()=>Mu,newMutex:()=>Nu}),Mu=class extends Au{constructor(e){super(),Object.assign(this,e)}},Nu=e=>new Mu(e),Pu=o({expectAlways:()=>Iu,toString:()=>Fu}),Fu=e=>JSON.stringify(e,(e,t)=>typeof t==`bigint`?t.toString():t),Iu=async(e,t=200,n=20)=>{let r=Date.now();for(;Date.now()-r<t;)await e(),await new Promise(e=>setTimeout(e,n))},Lu=(...e)=>e.map(Ru).join(``),Ru=e=>(e.endsWith(`/`)||(e+=`/`),e.startsWith(`/`)&&(e=e.slice(1)),e),zu=e=>e.endsWith(`/`)?e.slice(0,-1):e,Bu=(e,t=``)=>e===null?``:`?${Object.entries(e).filter(([,e])=>e==null?!1:Array.isArray(e)?e.length>0:!0).map(([e,n])=>`${t}${e}=${n}`).join(`&`)}`,Vu=class e{protocol;host;port;path;constructor({host:e,port:t,protocol:n=``,pathPrefix:r=``}){this.protocol=n,this.host=e,this.port=t,this.path=Ru(r)}replace(t){return new e({host:t.host??this.host,port:t.port??this.port,protocol:t.protocol??this.protocol,pathPrefix:t.pathPrefix??this.path})}child(t){return new e({...this,pathPrefix:Lu(this.path,t)})}toString(){return zu(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}static UNKNOWN=new e({host:`unknown`,port:0})},Hu=class{sender;handlers;constructor(e){this.sender=e,this.handlers=new Map}handle({data:e}){let t=this.handlers.get(e.type)?.handler;t==null?console.warn(`No handler for ${e.type}`):t(e.payload)}route(e){let t=new Wu(Uu(e,this.sender));return this.handlers.set(e,t),t}},Uu=(e,t)=>(n,r)=>t({type:e,payload:n},r),Wu=class{_send;handler;constructor(e){this._send=e,this.handler=null}send(e,t=[]){this._send(e,t)}handle(e){this.handler=e}},Gu=()=>{let e,t;return e=new Hu(e=>{t.handle({data:e})}),t=new Hu(t=>{e.handle({data:t})}),[e,t]};exports.DataType=J,exports.Density=K,exports.MultiSeries=_s,exports.OUTER_LOCATIONS=ki,exports.Rate=Ao,exports.RoutedWorker=Hu,exports.Series=ls,exports.Size=Y,exports.TimeRange=q,exports.TimeSpan=G,exports.TimeStamp=W,exports.TypedWorker=Wu,exports.URL=Vu,Object.defineProperty(exports,`array`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`binary`,{enumerable:!0,get:function(){return ur}}),Object.defineProperty(exports,`bounds`,{enumerable:!0,get:function(){return Sn}}),Object.defineProperty(exports,`box`,{enumerable:!0,get:function(){return aa}}),Object.defineProperty(exports,`breaker`,{enumerable:!0,get:function(){return ws}}),exports.buildQueryString=Bu,Object.defineProperty(exports,`caseconv`,{enumerable:!0,get:function(){return te}}),Object.defineProperty(exports,`change`,{enumerable:!0,get:function(){return Ds}}),exports.clamp=ao,Object.defineProperty(exports,`color`,{enumerable:!0,get:function(){return Dc}}),Object.defineProperty(exports,`compare`,{enumerable:!0,get:function(){return Fr}}),Object.defineProperty(exports,`control`,{enumerable:!0,get:function(){return Rc}}),exports.convertDataType=Po,exports.createMockWorkers=Gu,Object.defineProperty(exports,`csv`,{enumerable:!0,get:function(){return zc}}),exports.dataTypeZ=Bo,exports.debounce=Uc,Object.defineProperty(exports,`deep`,{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(exports,`destructor`,{enumerable:!0,get:function(){return Gc}}),Object.defineProperty(exports,`dimensions`,{enumerable:!0,get:function(){return Ja}}),Object.defineProperty(exports,`direction`,{enumerable:!0,get:function(){return Gr}}),Object.defineProperty(exports,`errors`,{enumerable:!0,get:function(){return ze}}),Object.defineProperty(exports,`fmt`,{enumerable:!0,get:function(){return it}}),Object.defineProperty(exports,`id`,{enumerable:!0,get:function(){return Lr}}),Object.defineProperty(exports,`instance`,{enumerable:!0,get:function(){return Ur}}),exports.isCrudeSeries=us,exports.isTelemValue=No,Object.defineProperty(exports,`json`,{enumerable:!0,get:function(){return Kc}}),Object.defineProperty(exports,`kv`,{enumerable:!0,get:function(){return el}}),Object.defineProperty(exports,`label`,{enumerable:!0,get:function(){return tl}}),Object.defineProperty(exports,`link`,{enumerable:!0,get:function(){return al}}),Object.defineProperty(exports,`location`,{enumerable:!0,get:function(){return ei}}),Object.defineProperty(exports,`map`,{enumerable:!0,get:function(){return cl}}),Object.defineProperty(exports,`math`,{enumerable:!0,get:function(){return Xn}}),Object.defineProperty(exports,`migrate`,{enumerable:!0,get:function(){return ul}}),Object.defineProperty(exports,`narrow`,{enumerable:!0,get:function(){return _e}}),Object.defineProperty(exports,`notation`,{enumerable:!0,get:function(){return yl}}),exports.numericTimeRangeZ=jo,Object.defineProperty(exports,`observe`,{enumerable:!0,get:function(){return Cl}}),Object.defineProperty(exports,`optional`,{enumerable:!0,get:function(){return El}}),exports.outerLocationZ=Ai,Object.defineProperty(exports,`primitive`,{enumerable:!0,get:function(){return at}}),exports.rateZ=Ro,Object.defineProperty(exports,`record`,{enumerable:!0,get:function(){return Dl}}),Object.defineProperty(exports,`runtime`,{enumerable:!0,get:function(){return Wl}}),Object.defineProperty(exports,`scale`,{enumerable:!0,get:function(){return oo}}),Object.defineProperty(exports,`scheduler`,{enumerable:!0,get:function(){return Gl}}),Object.defineProperty(exports,`shallow`,{enumerable:!0,get:function(){return Jl}}),exports.sizeZ=zo,Object.defineProperty(exports,`sleep`,{enumerable:!0,get:function(){return Ss}}),Object.defineProperty(exports,`spatial`,{enumerable:!0,get:function(){return vo}}),Object.defineProperty(exports,`status`,{enumerable:!0,get:function(){return _u}}),Object.defineProperty(exports,`sticky`,{enumerable:!0,get:function(){return yo}}),Object.defineProperty(exports,`strings`,{enumerable:!0,get:function(){return Cu}}),Object.defineProperty(exports,`sync`,{enumerable:!0,get:function(){return ju}}),Object.defineProperty(exports,`telem`,{enumerable:!0,get:function(){return xs}}),Object.defineProperty(exports,`testutil`,{enumerable:!0,get:function(){return Pu}}),exports.throttle=Wc,exports.timeRangeBoundedZ=Vo,exports.timeRangeZ=Fo,exports.timeSpanZ=Lo,exports.timeStampZ=Io,exports.typedArrayZ=Mo,Object.defineProperty(exports,`unique`,{enumerable:!0,get:function(){return vr}}),Object.defineProperty(exports,`uuid`,{enumerable:!0,get:function(){return $o}}),Object.defineProperty(exports,`xy`,{enumerable:!0,get:function(){return ji}}),exports.xyZ=j,Object.defineProperty(exports,`zod`,{enumerable:!0,get:function(){return lr}});
|