@synnaxlabs/x 0.44.2 → 0.44.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +15 -15
- package/dist/bounds-8OC_obRs.js +186 -0
- package/dist/bounds-CRK04jp7.cjs +1 -0
- package/dist/bounds.cjs +1 -1
- package/dist/bounds.js +1 -1
- package/dist/deep.cjs +1 -1
- package/dist/deep.js +1 -1
- package/dist/{external-Birv9jaY.js → external-BM_NS5yM.js} +6 -6
- package/dist/external-E3ErJeeM.cjs +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.js +235 -229
- package/dist/{path-DVFrKaNI.js → path-Blh4wJuA.js} +24 -21
- package/dist/path-CPSfCjde.cjs +1 -0
- package/dist/{scale-C6qKDbRb.cjs → scale-C3fEtXxW.cjs} +1 -1
- package/dist/{scale-EWNUk-bn.js → scale-Db1Gunj0.js} +1 -1
- package/dist/scale.cjs +1 -1
- package/dist/scale.js +1 -1
- package/dist/series-BcF7A8Je.cjs +6 -0
- package/dist/{series-EA1uaEDj.js → series-Cl3Vh_u-.js} +588 -471
- package/dist/spatial.cjs +1 -1
- package/dist/spatial.js +2 -2
- package/dist/src/breaker/breaker.d.ts +2 -1
- package/dist/src/breaker/breaker.d.ts.map +1 -1
- package/dist/src/deep/path.d.ts.map +1 -1
- package/dist/src/id/id.d.ts +3 -1
- package/dist/src/id/id.d.ts.map +1 -1
- package/dist/src/math/math.d.ts +2 -1
- package/dist/src/math/math.d.ts.map +1 -1
- package/dist/src/status/status.d.ts +1 -0
- package/dist/src/status/status.d.ts.map +1 -1
- package/dist/src/strings/strings.d.ts +1 -1
- package/dist/src/strings/strings.d.ts.map +1 -1
- package/dist/src/telem/series.d.ts +7 -0
- package/dist/src/telem/series.d.ts.map +1 -1
- package/dist/src/telem/telem.d.ts +78 -1
- package/dist/src/telem/telem.d.ts.map +1 -1
- package/dist/src/zod/util.d.ts.map +1 -1
- package/dist/telem.cjs +1 -1
- package/dist/telem.js +1 -1
- package/dist/zod.cjs +1 -1
- package/dist/zod.js +1 -1
- package/package.json +3 -3
- package/src/breaker/breaker.ts +4 -0
- package/src/deep/path.spec.ts +14 -0
- package/src/deep/path.ts +9 -2
- package/src/id/id.ts +8 -4
- package/src/math/math.spec.ts +20 -0
- package/src/math/math.ts +32 -29
- package/src/spatial/bounds/bounds.ts +1 -1
- package/src/status/status.ts +11 -0
- package/src/strings/strings.spec.ts +3 -0
- package/src/strings/strings.ts +2 -1
- package/src/telem/series.spec.ts +543 -2
- package/src/telem/series.ts +28 -9
- package/src/telem/telem.spec.ts +556 -0
- package/src/telem/telem.ts +118 -5
- package/src/zod/util.ts +5 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/bounds-D6e9xoHt.cjs +0 -1
- package/dist/bounds-Dj9nG39I.js +0 -174
- package/dist/external-DsmsSN1Y.cjs +0 -1
- package/dist/path-BeMr8xWN.cjs +0 -1
- package/dist/series-CcA_WjbJ.cjs +0 -6
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
const
|
|
1
|
+
const p = (s, r, t = ".") => {
|
|
2
2
|
const n = s.split(t);
|
|
3
3
|
return n.map((l, o) => {
|
|
4
4
|
const i = r(l, o, n);
|
|
5
5
|
return i == null ? null : typeof i == "string" ? i : i.join(t);
|
|
6
6
|
}).filter((l) => l != null).join(t);
|
|
7
|
-
},
|
|
7
|
+
}, u = (s, r) => {
|
|
8
8
|
if (!Array.isArray(s)) return s[r];
|
|
9
9
|
const t = s[r];
|
|
10
10
|
if (t != null || s.length == 0) return t;
|
|
11
11
|
const n = s[0];
|
|
12
12
|
if (typeof n == "object" && "key" in n)
|
|
13
13
|
return s.find((e) => e.key === r);
|
|
14
|
-
},
|
|
14
|
+
}, h = (s, r) => {
|
|
15
15
|
const t = s.split(".");
|
|
16
16
|
return t.forEach((n, e) => {
|
|
17
|
-
r =
|
|
17
|
+
r = u(r, n), r != null && typeof r == "object" && "key" in r && (t[e] = r.key);
|
|
18
18
|
}), t.join(".");
|
|
19
|
-
},
|
|
19
|
+
}, c = (s, r, t = { optional: !1, separator: "." }) => {
|
|
20
20
|
t.separator ??= ".";
|
|
21
|
-
const { optional: n, getter: e =
|
|
21
|
+
const { optional: n, getter: e = u } = t, l = r.split(t.separator);
|
|
22
22
|
if (l.length === 1 && l[0] === "") return s;
|
|
23
23
|
let o = s;
|
|
24
24
|
for (const i of l) {
|
|
@@ -30,11 +30,14 @@ const f = (s, r, t = ".") => {
|
|
|
30
30
|
o = a;
|
|
31
31
|
}
|
|
32
32
|
return o;
|
|
33
|
-
},
|
|
33
|
+
}, f = (s) => {
|
|
34
|
+
for (const r of s) if (isNaN(parseInt(r))) return null;
|
|
35
|
+
return parseInt(s);
|
|
36
|
+
}, g = (s, r, t) => {
|
|
34
37
|
const n = r.split(".");
|
|
35
38
|
let e = s;
|
|
36
39
|
for (let l = 0; l < n.length - 1; l++) {
|
|
37
|
-
const o = n[l], i =
|
|
40
|
+
const o = n[l], i = u(e, o);
|
|
38
41
|
if (i == null) throw new Error(`Path ${r} does not exist. ${o} is null`);
|
|
39
42
|
e = i;
|
|
40
43
|
}
|
|
@@ -44,8 +47,8 @@ const f = (s, r, t = ".") => {
|
|
|
44
47
|
return;
|
|
45
48
|
}
|
|
46
49
|
if (e.length === 0) return;
|
|
47
|
-
const l =
|
|
48
|
-
if (
|
|
50
|
+
const l = f(n[n.length - 1]);
|
|
51
|
+
if (l == null) {
|
|
49
52
|
const o = e[0];
|
|
50
53
|
if (typeof o == "object" && "key" in o) {
|
|
51
54
|
const i = e.findIndex((a) => a.key === n[n.length - 1]);
|
|
@@ -60,7 +63,7 @@ const f = (s, r, t = ".") => {
|
|
|
60
63
|
} catch (l) {
|
|
61
64
|
throw console.error("failed to set value", t, "at path", r, "on object", s), l;
|
|
62
65
|
}
|
|
63
|
-
},
|
|
66
|
+
}, y = (s, r) => {
|
|
64
67
|
const t = r.split(".");
|
|
65
68
|
let n = s;
|
|
66
69
|
for (let e = 0; e < t.length - 1; e++) {
|
|
@@ -75,12 +78,12 @@ const f = (s, r, t = ".") => {
|
|
|
75
78
|
return;
|
|
76
79
|
}
|
|
77
80
|
delete n[t[t.length - 1]];
|
|
78
|
-
},
|
|
81
|
+
}, d = (s, r) => {
|
|
79
82
|
const t = s.split(".");
|
|
80
83
|
return r < 0 ? t[t.length + r] : t[r];
|
|
81
|
-
},
|
|
84
|
+
}, x = (s, r) => {
|
|
82
85
|
try {
|
|
83
|
-
return
|
|
86
|
+
return c(s, r), !0;
|
|
84
87
|
} catch {
|
|
85
88
|
return !1;
|
|
86
89
|
}
|
|
@@ -96,12 +99,12 @@ const f = (s, r, t = ".") => {
|
|
|
96
99
|
return !0;
|
|
97
100
|
};
|
|
98
101
|
export {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
102
|
+
h as a,
|
|
103
|
+
d as e,
|
|
104
|
+
c as g,
|
|
105
|
+
x as h,
|
|
103
106
|
A as p,
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
+
y as r,
|
|
108
|
+
g as s,
|
|
109
|
+
p as t
|
|
107
110
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const a=(s,r,t=".")=>{const e=s.split(t);return e.map((l,o)=>{const i=r(l,o,e);return i==null?null:typeof i=="string"?i:i.join(t)}).filter(l=>l!=null).join(t)},u=(s,r)=>{if(!Array.isArray(s))return s[r];const t=s[r];if(t!=null||s.length==0)return t;const e=s[0];if(typeof e=="object"&&"key"in e)return s.find(n=>n.key===r)},h=(s,r)=>{const t=s.split(".");return t.forEach((e,n)=>{r=u(r,e),r!=null&&typeof r=="object"&&"key"in r&&(t[n]=r.key)}),t.join(".")},f=(s,r,t={optional:!1,separator:"."})=>{t.separator??=".";const{optional:e,getter:n=u}=t,l=r.split(t.separator);if(l.length===1&&l[0]==="")return s;let o=s;for(const i of l){const c=n(o,i);if(c==null){if(e)return null;throw new Error(`Path ${r} does not exist. ${i} is null`)}o=c}return o},p=s=>{for(const r of s)if(isNaN(parseInt(r)))return null;return parseInt(s)},g=(s,r,t)=>{const e=r.split(".");let n=s;for(let l=0;l<e.length-1;l++){const o=e[l],i=u(n,o);if(i==null)throw new Error(`Path ${r} does not exist. ${o} is null`);n=i}try{if(!Array.isArray(n)){n[e[e.length-1]]=t;return}if(n.length===0)return;const l=p(e[e.length-1]);if(l==null){const o=n[0];if(typeof o=="object"&&"key"in o){const i=n.findIndex(c=>c.key===e[e.length-1]);if(i!==-1){n[i]=t;return}}return}n[l]=t}catch(l){throw console.error("failed to set value",t,"at path",r,"on object",s),l}},y=(s,r)=>{const t=r.split(".");let e=s;for(let n=0;n<t.length-1;n++){const l=t[n];if(e[l]==null)return;e=e[l]}if(Array.isArray(e)){const n=parseInt(t[t.length-1]);if(isNaN(n))return;e.splice(n,1);return}delete e[t[t.length-1]]},d=(s,r)=>{const t=s.split(".");return r<0?t[t.length+r]:t[r]},m=(s,r)=>{try{return f(s,r),!0}catch{return!1}},A=(s,r)=>{if(r.length===0)return!0;const t=s.split("."),e=r.split(".");if(e.length>t.length)return!1;for(let n=0;n<e.length;n++){const l=t[n],o=e[n];if(o!=="*"&&l!==o)return!1}return!0};exports.element=d;exports.get=f;exports.has=m;exports.pathsMatch=A;exports.remove=y;exports.resolvePath=h;exports.set=g;exports.transformPath=a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const l=require("zod"),y=require("./bounds-
|
|
1
|
+
"use strict";const l=require("zod"),y=require("./bounds-CRK04jp7.cjs"),u=require("./box-Cxki783Y.cjs"),m=require("./location-DZi8ftXp.cjs"),h=require("./xy-CUE3QDNn.cjs"),f=(n,t,e)=>t!==void 0&&n<t?t:e!==void 0&&n>e?e:n,B=l.z.object({offset:h.crudeZ,scale:h.crudeZ}),g=l.z.object({offset:l.z.number(),scale:l.z.number()}),v=n=>(t,e,s,r)=>e==="dimension"?[t,s]:[t,r?s-n:s+n],R=n=>(t,e,s,r)=>[t,r?s/n:s*n],T=n=>(t,e,s)=>{if(t===null)return[n,s];const{lower:r,upper:o}=t,{lower:a,upper:p}=n,x=o-r,d=p-a;if(e==="dimension")return[n,s*(d/x)];const w=(s-r)*(d/x)+a;return[n,w]},q=n=>(t,e,s)=>[n,s],z=()=>(n,t,e)=>{if(n===null)throw new Error("cannot invert without bounds");if(t==="dimension")return[n,e];const{lower:s,upper:r}=n;return[n,r-(e-s)]},E=n=>(t,e,s)=>{const{lower:r,upper:o}=n;return s=f(s,r,o),[t,s]};class i{ops=[];currBounds=null;currType=null;reversed=!1;constructor(){this.ops=[]}static translate(t){return new i().translate(t)}static magnify(t){return new i().magnify(t)}static scale(t,e){return new i().scale(t,e)}translate(t){const e=this.new(),s=v(t);return s.type="translate",e.ops.push(s),e}magnify(t){const e=this.new(),s=R(t);return s.type="magnify",e.ops.push(s),e}scale(t,e){const s=y.construct(t,e),r=this.new(),o=T(s);return o.type="scale",r.ops.push(o),r}clamp(t,e){const s=y.construct(t,e),r=this.new(),o=E(s);return o.type="clamp",r.ops.push(o),r}reBound(t,e){const s=y.construct(t,e),r=this.new(),o=q(s);return o.type="re-bound",r.ops.push(o),r}invert(){const t=z();t.type="invert";const e=this.new();return e.ops.push(t),e}pos(t){return this.exec("position",t)}dim(t){return this.exec("dimension",t)}new(){const t=new i;return t.ops=this.ops.slice(),t.reversed=this.reversed,t}exec(t,e){return this.currBounds=null,this.ops.reduce(([s,r],o)=>o(s,t,r,this.reversed),[null,e])[1]}reverse(){const t=this.new();t.ops.reverse();const e=[];return t.ops.forEach((s,r)=>{if(s.type==="scale"||e.some(([a,p])=>r>=a&&r<=p))return;const o=t.ops.findIndex((a,p)=>a.type==="scale"&&p>r);o!==-1&&e.push([r,o])}),e.forEach(([s,r])=>{const o=t.ops.slice(s,r);o.unshift(t.ops[r]),t.ops.splice(s,r-s+1,...o)}),t.reversed=!t.reversed,t}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}static IDENTITY=new i}class c{x;y;currRoot;constructor(t=new i,e=new i,s=null){this.x=t,this.y=e,this.currRoot=s}static translate(t,e){return new c().translate(t,e)}static translateX(t){return new c().translateX(t)}static translateY(t){return new c().translateY(t)}static clamp(t){return new c().clamp(t)}static magnify(t){return new c().magnify(t)}static scale(t){return new c().scale(t)}static reBound(t){return new c().reBound(t)}translate(t,e){const s=h.construct(t,e),r=this.copy();return r.x=this.x.translate(s.x),r.y=this.y.translate(s.y),r}translateX(t){const e=this.copy();return e.x=this.x.translate(t),e}translateY(t){const e=this.copy();return e.y=this.y.translate(t),e}magnify(t){const e=this.copy();return e.x=this.x.magnify(t.x),e.y=this.y.magnify(t.y),e}scale(t){const e=this.copy();if(u.isBox(t)){const s=this.currRoot;return e.currRoot=t.root,s!=null&&!m.xyEquals(s,t.root)&&(s.x!==t.root.x&&(e.x=e.x.invert()),s.y!==t.root.y&&(e.y=e.y.invert())),e.x=e.x.scale(u.xBounds(t)),e.y=e.y.scale(u.yBounds(t)),e}return e.x=e.x.scale(t.width),e.y=e.y.scale(t.height),e}reBound(t){const e=this.copy();return e.x=this.x.reBound(u.xBounds(t)),e.y=this.y.reBound(u.yBounds(t)),e}clamp(t){const e=this.copy();return e.x=this.x.clamp(u.xBounds(t)),e.y=this.y.clamp(u.yBounds(t)),e}copy(){const t=new c;return t.currRoot=this.currRoot,t.x=this.x,t.y=this.y,t}reverse(){const t=this.copy();return t.x=this.x.reverse(),t.y=this.y.reverse(),t}pos(t){return{x:this.x.pos(t.x),y:this.y.pos(t.y)}}dim(t){return{x:this.x.dim(t.x),y:this.y.dim(t.y)}}box(t){return u.construct(this.pos(t.one),this.pos(t.two),0,0,this.currRoot??t.root)}get transform(){return{scale:this.dim({x:1,y:1}),offset:this.pos({x:0,y:0})}}static IDENTITY=new c}const I=Object.freeze(Object.defineProperty({__proto__:null,Scale:i,XY:c,crudeXYTransform:B,transform:g},Symbol.toStringTag,{value:"Module"}));exports.clamp=f;exports.scale=I;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z as p } from "zod";
|
|
2
|
-
import { c as l } from "./bounds-
|
|
2
|
+
import { c as l } from "./bounds-8OC_obRs.js";
|
|
3
3
|
import { e as w, f as y, y as h, c as g } from "./box-CO_2_DGG.js";
|
|
4
4
|
import { b as v } from "./location-Ar5y2DX2.js";
|
|
5
5
|
import { b as d, c as B } from "./xy-C_-hb3Q2.js";
|
package/dist/scale.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./scale-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./scale-C3fEtXxW.cjs");exports.scale=e.scale;
|
package/dist/scale.js
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";const o=require("zod"),S=require("./index-BQe8OIgm.cjs"),_=require("./index-DdhM_E4k.cjs"),C=require("./index-DOJlZHqJ.cjs"),h=require("./bounds-CRK04jp7.cjs");require("./box-Cxki783Y.cjs");require("./dimensions-D2QGoNXO.cjs");require("./base-BAM2mqCy.cjs");require("./location-DZi8ftXp.cjs");require("./scale-C3fEtXxW.cjs");require("./xy-CUE3QDNn.cjs");let Z=(a,t=21)=>(e=t)=>{let n="",u=e|0;for(;u--;)n+=a[Math.random()*a.length|0];return n};const k="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",tt=`0123456789${k}`,G=11,et=Z(k,1),nt=Z(tt,G-1),q=()=>`${et()}${nt()}`,st=Object.freeze(Object.defineProperty({__proto__:null,LENGTH:G,create:q},Symbol.toStringTag,{value:"Module"})),J=(a,t)=>e=>e instanceof t||typeof e=="object"&&e!==null&&"discriminator"in e&&e.discriminator===a,rt=Object.freeze(Object.defineProperty({__proto__:null,createMatcher:J},Symbol.toStringTag,{value:"Module"})),it=o.z.enum(["static","dynamic"]),at=o.z.union([o.z.tuple([o.z.int()]),o.z.tuple([o.z.int(),o.z.int().min(1).max(12)]),o.z.tuple([o.z.int(),o.z.int().min(1).max(12),o.z.int().min(1).max(31)])]),j=(a,t)=>{const e=new r(t);if(![i.DAY,i.HOUR,i.MINUTE,i.SECOND,i.MILLISECOND,i.MICROSECOND,i.NANOSECOND].some(u=>u.equals(e)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=a.valueOf()%e.valueOf();return a instanceof r?new r(n):new i(n)};class r extends C.ValueExtension{constructor(t,e="UTC"){if(t==null)super(r.now().valueOf());else if(t instanceof Date)super(BigInt(t.getTime())*r.MILLISECOND.valueOf());else if(typeof t=="string")super(r.parseDateTimeString(t,e).valueOf());else if(Array.isArray(t))super(r.parseDate(t));else{let n=0n;t instanceof Number&&(t=t.valueOf()),e==="local"&&(n=r.utcOffset.valueOf()),typeof t=="number"&&(isFinite(t)?t=Math.trunc(t):(isNaN(t)&&(t=0),t===1/0?t=r.MAX:t=r.MIN)),super(BigInt(t.valueOf())+n)}}static parseDate([t=1970,e=1,n=1]){const u=new Date(t,e-1,n,0,0,0,0);return new r(BigInt(u.getTime())*r.MILLISECOND.valueOf()).truncate(r.DAY).valueOf()}valueOf(){return this.value}static parseTimeString(t,e="UTC"){const[n,u,l]=t.split(":");let f="00",A="00";l!=null&&([f,A]=l.split("."));let m=r.hours(parseInt(n??"00")).add(r.minutes(parseInt(u??"00"))).add(r.seconds(parseInt(f??"00"))).add(r.milliseconds(parseInt(A??"00")));return e==="local"&&(m=m.add(r.utcOffset)),m.valueOf()}static parseDateTimeString(t,e="UTC"){if(!t.includes("/")&&!t.includes("-"))return r.parseTimeString(t,e);const n=new Date(t);return t.includes(":")||n.setUTCHours(0,0,0,0),new r(BigInt(n.getTime())*r.MILLISECOND.valueOf(),e).valueOf()}fString(t="ISO",e="UTC"){switch(t){case"ISODate":return this.toISOString(e).slice(0,10);case"ISOTime":return this.toISOString(e).slice(11,23);case"time":return this.timeString(!1,e);case"preciseTime":return this.timeString(!0,e);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,e)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,e)}`;default:return this.toISOString(e)}}toISOString(t="UTC"){return t==="UTC"?this.date().toISOString():this.sub(r.utcOffset).date().toISOString()}timeString(t=!1,e="UTC"){const n=this.toISOString(e);return t?n.slice(11,23):n.slice(11,19)}dateString(){const t=this.date(),e=t.toLocaleString("default",{month:"short"}),n=t.toLocaleString("default",{day:"numeric"});return`${e} ${n}`}static get utcOffset(){return new i(BigInt(new Date().getTimezoneOffset())*r.MINUTE.valueOf())}static since(t){return new r().span(t)}date(){return new Date(this.milliseconds)}equals(t){return this.valueOf()===new r(t).valueOf()}span(t){return this.range(t).span}range(t){return new w(this,t).makeValid()}spanRange(t){return this.range(this.add(t)).makeValid()}get isZero(){return this.valueOf()===0n}after(t){return this.valueOf()>new r(t).valueOf()}afterEq(t){return this.valueOf()>=new r(t).valueOf()}before(t){return this.valueOf()<new r(t).valueOf()}beforeEq(t){return this.valueOf()<=new r(t).valueOf()}add(t){return new r(h.add(this.valueOf(),new i(t).valueOf()))}sub(t){return new r(h.sub(this.valueOf(),new i(t).valueOf()))}get hours(){return Number(this.valueOf())/Number(i.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(i.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(i.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(i.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(r.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(r.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get year(){return this.date().getUTCFullYear()}setYear(t){const e=this.date();return e.setUTCFullYear(t),new r(e)}get month(){return this.date().getUTCMonth()}setMonth(t){const e=this.date();return e.setUTCMonth(t),new r(e)}get day(){return this.date().getUTCDate()}setDay(t){const e=this.date();return e.setUTCDate(t),new r(e)}get hour(){return this.date().getUTCHours()}setHour(t){const e=this.date();return e.setUTCHours(t),new r(e,"UTC")}get minute(){return this.date().getUTCMinutes()}setMinute(t){const e=this.date();return e.setUTCMinutes(t),new r(e)}get second(){return this.date().getUTCSeconds()}setSecond(t){const e=this.date();return e.setUTCSeconds(t),new r(e)}get millisecond(){return this.date().getUTCMilliseconds()}setMillisecond(t){const e=this.date();return e.setUTCMilliseconds(t),new r(e)}toString(){return this.date().toISOString()}remainder(t){return j(this,t)}get isToday(){return this.truncate(i.DAY).equals(r.now().truncate(i.DAY))}truncate(t){return this.sub(this.remainder(t))}static now(){return new r(new Date)}static max(...t){let e=r.MIN;for(const n of t){const u=new r(n);u.after(e)&&(e=u)}return e}static min(...t){let e=r.MAX;for(const n of t){const u=new r(n);u.before(e)&&(e=u)}return e}static nanoseconds(t,e="UTC"){return new r(t,e)}static NANOSECOND=r.nanoseconds(1);static microseconds(t,e="UTC"){return r.nanoseconds(t*1e3,e)}static MICROSECOND=r.microseconds(1);static milliseconds(t,e="UTC"){return r.microseconds(t*1e3,e)}static MILLISECOND=r.milliseconds(1);static seconds(t,e="UTC"){return r.milliseconds(t*1e3,e)}static SECOND=r.seconds(1);static minutes(t,e="UTC"){return r.seconds(t*60,e)}static MINUTE=r.minutes(1);static hours(t,e="UTC"){return r.minutes(t*60,e)}static HOUR=r.hours(1);static days(t,e="UTC"){return r.hours(t*24,e)}static DAY=r.days(1);static MAX=new r((1n<<63n)-1n);static MIN=new r(0);static ZERO=new r(0);static z=o.z.union([o.z.instanceof(r),o.z.object({value:o.z.bigint()}).transform(t=>new r(t.value)),o.z.string().transform(t=>new r(BigInt(t))),o.z.number().transform(t=>new r(t)),o.z.bigint().transform(t=>new r(t)),o.z.date().transform(t=>new r(t)),o.z.custom(t=>t instanceof i).transform(t=>new r(t)),at.transform(t=>new r(t))]);static sort(t,e){return Number(t.valueOf()-e.valueOf())}}class i extends C.ValueExtension{constructor(t){typeof t=="number"&&(t=Math.trunc(t.valueOf())),super(BigInt(t.valueOf()))}static fromSeconds(t){return t instanceof i?t:t instanceof y?t.period:t instanceof r?new i(t):["number","bigint"].includes(typeof t)?i.seconds(t):new i(t)}static fromMilliseconds(t){return t instanceof i?t:t instanceof y?t.period:t instanceof r?new i(t):["number","bigint"].includes(typeof t)?i.milliseconds(t):new i(t)}valueOf(){return this.value}lessThan(t){return this.valueOf()<new i(t).valueOf()}greaterThan(t){return this.valueOf()>new i(t).valueOf()}lessThanOrEqual(t){return this.valueOf()<=new i(t).valueOf()}greaterThanOrEqual(t){return this.valueOf()>=new i(t).valueOf()}remainder(t){return j(this,t)}truncate(t){return new i(BigInt(Math.trunc(Number(this.valueOf()/t.valueOf())))*t.valueOf())}toString(){const t=this.truncate(i.DAY),e=this.truncate(i.HOUR),n=this.truncate(i.MINUTE),u=this.truncate(i.SECOND),l=this.truncate(i.MILLISECOND),f=this.truncate(i.MICROSECOND),A=this.truncate(i.NANOSECOND),m=t,O=e.sub(t),N=n.sub(e),I=u.sub(n),c=l.sub(u),U=f.sub(l),E=A.sub(f);let M="";return m.isZero||(M+=`${m.days}d `),O.isZero||(M+=`${O.hours}h `),N.isZero||(M+=`${N.minutes}m `),I.isZero||(M+=`${I.seconds}s `),c.isZero||(M+=`${c.milliseconds}ms `),U.isZero||(M+=`${U.microseconds}µs `),E.isZero||(M+=`${E.nanoseconds}ns`),M.trim()}mult(t){return new i(h.mult(this.valueOf(),t))}div(t){return new i(h.div(this.valueOf(),t))}get days(){return Number(this.valueOf())/Number(i.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(i.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(i.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(i.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(i.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(i.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===0n}equals(t){return this.valueOf()===new i(t).valueOf()}add(t){return new i(this.valueOf()+new i(t).valueOf())}sub(t){return new i(this.valueOf()-new i(t).valueOf())}static nanoseconds(t=1){return new i(t)}static NANOSECOND=i.nanoseconds(1);static microseconds(t=1){return i.nanoseconds(h.mult(t,1e3))}static MICROSECOND=i.microseconds(1);static milliseconds(t=1){return i.microseconds(h.mult(t,1e3))}static MILLISECOND=i.milliseconds(1);static seconds(t=1){return i.milliseconds(h.mult(t,1e3))}static SECOND=i.seconds(1);static minutes(t=1){return i.seconds(h.mult(t,60))}static MINUTE=i.minutes(1);static hours(t){return i.minutes(h.mult(t,60))}static HOUR=i.hours(1);static days(t){return i.hours(h.mult(t,24))}static DAY=i.days(1);static MAX=new i((1n<<63n)-1n);static MIN=new i(0);static ZERO=new i(0);static z=o.z.union([o.z.object({value:o.z.bigint()}).transform(t=>new i(t.value)),o.z.string().transform(t=>new i(BigInt(t))),o.z.number().transform(t=>new i(t)),o.z.bigint().transform(t=>new i(t)),o.z.instanceof(i),o.z.instanceof(r).transform(t=>new i(t)),o.z.custom(t=>t instanceof y).transform(t=>new i(t))])}class y extends C.ValueExtension{constructor(t){super(t.valueOf())}toString(){return`${this.valueOf()} Hz`}equals(t){return this.valueOf()===new y(t).valueOf()}get period(){return i.seconds(1/this.valueOf())}sampleCount(t){return new i(t).seconds*this.valueOf()}byteCount(t,e){return this.sampleCount(t)*new g(e).valueOf()}span(t){return i.seconds(t/this.valueOf())}byteSpan(t,e){return this.span(t.valueOf()/e.valueOf())}add(t){return new y(h.add(this.valueOf(),t.valueOf()))}sub(t){return new y(h.sub(this.valueOf(),t.valueOf()))}mult(t){return new y(h.mult(this.valueOf(),t))}div(t){return new y(h.div(this.valueOf(),t))}static hz(t){return new y(t)}static khz(t){return y.hz(t*1e3)}static z=o.z.union([o.z.number().transform(t=>new y(t)),o.z.instanceof(y)])}class g extends C.ValueExtension{constructor(t){super(t.valueOf())}length(t){return t.valueOf()/this.valueOf()}size(t){return new d(t*this.valueOf())}add(t){return new g(h.add(this.valueOf(),t.valueOf()))}sub(t){return new g(h.sub(this.valueOf(),t.valueOf()))}mult(t){return new g(h.mult(this.valueOf(),t))}div(t){return new g(h.div(this.valueOf(),t))}static UNKNOWN=new g(0);static BIT128=new g(16);static BIT64=new g(8);static BIT32=new g(4);static BIT16=new g(2);static BIT8=new g(1);static z=o.z.union([o.z.number().transform(t=>new g(t)),o.z.instanceof(g)])}class w{start;end;constructor(t,e){typeof t=="object"&&"start"in t?(this.start=new r(t.start),this.end=new r(t.end)):(this.start=new r(t),this.end=new r(e))}get span(){return new i(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new w(this.end,this.start)}get numericBounds(){return{lower:Number(this.start.valueOf()),upper:Number(this.end.valueOf())}}equals(t,e=i.ZERO){if(e.isZero)return this.start.equals(t.start)&&this.end.equals(t.end);let n=this.start.sub(t.start).valueOf(),u=this.end.sub(t.end).valueOf();return n<0&&(n=-n),u<0&&(u=-u),n<=e.valueOf()&&u<=e.valueOf()}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(t,e=i.ZERO){t=t.makeValid();const n=this.makeValid();if(this.equals(t))return!0;if(t.end.equals(n.start)||n.end.equals(t.start))return!1;const u=r.max(n.start,t.start),l=r.min(n.end,t.end);return l.before(u)?!1:new i(l.sub(u)).greaterThanOrEqual(e)}contains(t){return t instanceof w?this.contains(t.start)&&this.contains(t.end):this.start.beforeEq(t)&&this.end.after(t)}boundBy(t){const e=new w(this.start,this.end);return t.start.after(this.start)&&(e.start=t.start),t.start.after(this.end)&&(e.end=t.start),t.end.before(this.end)&&(e.end=t.end),t.end.before(this.start)&&(e.start=t.end),e}static max(...t){return new w(r.min(...t.map(e=>e.start)),r.max(...t.map(e=>e.end)))}static MAX=new w(r.MIN,r.MAX);static MIN=new w(r.MAX,r.MIN);static ZERO=new w(r.ZERO,r.ZERO);static z=o.z.union([o.z.object({start:r.z,end:r.z}).transform(t=>new w(t.start,t.end)),o.z.instanceof(w)]);static sort(t,e){return r.sort(t.start,e.start)||r.sort(t.end,e.end)}}class s extends C.ValueExtension{constructor(t){if(t instanceof s||typeof t=="string"||typeof t.valueOf()=="string")super(t.valueOf());else{const e=s.ARRAY_CONSTRUCTOR_DATA_TYPES.get(t.constructor.name);if(e==null)throw new Error(`unable to find data type for ${t.toString()}`);super(e.valueOf())}}get Array(){const t=s.ARRAY_CONSTRUCTORS.get(this.toString());if(t==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return t}equals(t){return this.valueOf()===t.valueOf()}matches(...t){return t.some(e=>this.equals(e))}toString(){return this.valueOf()}get isVariable(){return this.equals(s.JSON)||this.equals(s.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(s.UUID)}get isInteger(){const t=this.toString();return t.startsWith("int")||t.startsWith("uint")}get isFloat(){return this.toString().startsWith("float")}get density(){const t=s.DENSITIES.get(this.toString());if(t==null)throw new Error(`unable to find density for ${this.valueOf()}`);return t}get isUnsignedInteger(){return this.equals(s.UINT8)||this.equals(s.UINT16)||this.equals(s.UINT32)||this.equals(s.UINT64)}get isSignedInteger(){return this.equals(s.INT8)||this.equals(s.INT16)||this.equals(s.INT32)||this.equals(s.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(s.INT32)&&t.equals(s.FLOAT64)||this.equals(s.INT8)&&t.equals(s.FLOAT32)?!0:this.isInteger&&t.isInteger?this.density.valueOf()<=t.density.valueOf()&&this.isUnsignedInteger===t.isUnsignedInteger:!1}canCastTo(t){return this.isNumeric&&t.isNumeric?!0:this.equals(t)}checkArray(t){return t.constructor===this.Array}get usesBigInt(){return s.BIG_INT_TYPES.some(t=>t.equals(this))}static UNKNOWN=new s("unknown");static FLOAT64=new s("float64");static FLOAT32=new s("float32");static INT64=new s("int64");static INT32=new s("int32");static INT16=new s("int16");static INT8=new s("int8");static UINT64=new s("uint64");static UINT32=new s("uint32");static UINT16=new s("uint16");static UINT8=new s("uint8");static BOOLEAN=this.UINT8;static TIMESTAMP=new s("timestamp");static UUID=new s("uuid");static STRING=new s("string");static JSON=new s("json");static ARRAY_CONSTRUCTORS=new Map([[s.UINT8.toString(),Uint8Array],[s.UINT16.toString(),Uint16Array],[s.UINT32.toString(),Uint32Array],[s.UINT64.toString(),BigUint64Array],[s.FLOAT32.toString(),Float32Array],[s.FLOAT64.toString(),Float64Array],[s.INT8.toString(),Int8Array],[s.INT16.toString(),Int16Array],[s.INT32.toString(),Int32Array],[s.INT64.toString(),BigInt64Array],[s.TIMESTAMP.toString(),BigInt64Array],[s.STRING.toString(),Uint8Array],[s.JSON.toString(),Uint8Array],[s.UUID.toString(),Uint8Array]]);static ARRAY_CONSTRUCTOR_DATA_TYPES=new Map([[Uint8Array.name,s.UINT8],[Uint16Array.name,s.UINT16],[Uint32Array.name,s.UINT32],[BigUint64Array.name,s.UINT64],[Float32Array.name,s.FLOAT32],[Float64Array.name,s.FLOAT64],[Int8Array.name,s.INT8],[Int16Array.name,s.INT16],[Int32Array.name,s.INT32],[BigInt64Array.name,s.INT64]]);static DENSITIES=new Map([[s.UINT8.toString(),g.BIT8],[s.UINT16.toString(),g.BIT16],[s.UINT32.toString(),g.BIT32],[s.UINT64.toString(),g.BIT64],[s.FLOAT32.toString(),g.BIT32],[s.FLOAT64.toString(),g.BIT64],[s.INT8.toString(),g.BIT8],[s.INT16.toString(),g.BIT16],[s.INT32.toString(),g.BIT32],[s.INT64.toString(),g.BIT64],[s.TIMESTAMP.toString(),g.BIT64],[s.STRING.toString(),g.UNKNOWN],[s.JSON.toString(),g.UNKNOWN],[s.UUID.toString(),g.BIT128]]);static ALL=[s.UNKNOWN,s.FLOAT64,s.FLOAT32,s.INT64,s.INT32,s.INT16,s.INT8,s.UINT64,s.UINT32,s.UINT16,s.UINT8,s.TIMESTAMP,s.UUID,s.STRING,s.JSON];static BIG_INT_TYPES=[s.INT64,s.UINT64,s.TIMESTAMP];static z=o.z.union([o.z.string().transform(t=>new s(t)),o.z.instanceof(s)])}class d extends C.ValueExtension{constructor(t){super(t.valueOf())}largerThan(t){return this.valueOf()>t.valueOf()}smallerThan(t){return this.valueOf()<t.valueOf()}add(t){return new d(h.add(this.valueOf(),t.valueOf()))}sub(t){return new d(h.sub(this.valueOf(),t.valueOf()))}mult(t){return new d(h.mult(this.valueOf(),t))}div(t){return new d(h.div(this.valueOf(),t))}truncate(t){return new d(Math.trunc(this.valueOf()/t.valueOf())*t.valueOf())}remainder(t){return d.bytes(this.valueOf()%t.valueOf())}get gigabytes(){return this.valueOf()/d.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/d.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/d.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/d.TERABYTE.valueOf()}toString(){const t=this.truncate(d.TERABYTE),e=this.truncate(d.GIGABYTE),n=this.truncate(d.MEGABYTE),u=this.truncate(d.KILOBYTE),l=this.truncate(d.BYTE),f=t,A=e.sub(t),m=n.sub(e),O=u.sub(n),N=l.sub(u);let I="";return f.isZero||(I+=`${f.terabytes}TB `),A.isZero||(I+=`${A.gigabytes}GB `),m.isZero||(I+=`${m.megabytes}MB `),O.isZero||(I+=`${O.kilobytes}KB `),(!N.isZero||I==="")&&(I+=`${N.valueOf()}B`),I.trim()}static bytes(t=1){return new d(t)}static BYTE=new d(1);static kilobytes(t=1){return d.bytes(t.valueOf()*1e3)}static KILOBYTE=d.kilobytes(1);static megabytes(t=1){return d.kilobytes(t.valueOf()*1e3)}static MEGABYTE=d.megabytes(1);static gigabytes(t=1){return d.megabytes(t.valueOf()*1e3)}static GIGABYTE=d.gigabytes(1);static terabytes(t){return d.gigabytes(t.valueOf()*1e3)}static TERABYTE=d.terabytes(1);static ZERO=new d(0);static z=o.z.union([o.z.number().transform(t=>new d(t)),o.z.instanceof(d)]);get isZero(){return this.valueOf()===0}}const ut=o.z.union([o.z.instanceof(Uint8Array),o.z.instanceof(Uint16Array),o.z.instanceof(Uint32Array),o.z.instanceof(BigUint64Array),o.z.instanceof(Float32Array),o.z.instanceof(Float64Array),o.z.instanceof(Int8Array),o.z.instanceof(Int16Array),o.z.instanceof(Int32Array),o.z.instanceof(BigInt64Array)]),z=a=>{const t=typeof a;return t==="string"||t==="number"||t==="boolean"||t==="bigint"||a instanceof r||a instanceof i||a instanceof Date},W=(a,t,e,n=0)=>a.usesBigInt&&!t.usesBigInt?Number(e)-Number(n):!a.usesBigInt&&t.usesBigInt?BigInt(e.valueOf())-BigInt(n.valueOf()):x(e,-n),x=(a,t)=>t==0?a:a==0?t:typeof a=="bigint"&&typeof t=="bigint"||typeof a=="number"&&typeof t=="number"?a+t:Number(a)+Number(t),ot="00000000-0000-0000-0000-000000000000",lt=/^(?:[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 ct(a){return typeof a=="string"&<.test(a)}const b=[];for(let a=0;a<256;++a)b.push((a+256).toString(16).slice(1));function H(a,t=0){return(b[a[t+0]]+b[a[t+1]]+b[a[t+2]]+b[a[t+3]]+"-"+b[a[t+4]]+b[a[t+5]]+"-"+b[a[t+6]]+b[a[t+7]]+"-"+b[a[t+8]]+b[a[t+9]]+"-"+b[a[t+10]]+b[a[t+11]]+b[a[t+12]]+b[a[t+13]]+b[a[t+14]]+b[a[t+15]]).toLowerCase()}function ft(a,t=0){const e=H(a,t);if(!ct(e))throw TypeError("Stringified UUID is invalid");return e}let R;const ht=new Uint8Array(16);function dt(){if(!R){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");R=crypto.getRandomValues.bind(crypto)}return R(ht)}const gt=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),F={randomUUID:gt};function Ot(a,t,e){if(F.randomUUID&&!a)return F.randomUUID();a=a||{};const n=a.random??a.rng?.()??dt();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,H(n)}const wt=()=>Ot(),P=(a,t)=>ft(a,t),bt=ot,It=Object.freeze(Object.defineProperty({__proto__:null,ZERO:bt,create:wt,parse:P},Symbol.toStringTag,{value:"Module"})),B=-1,L={[Symbol.iterator]:()=>L,next:()=>({done:!0,value:void 0})},yt=o.z.string().transform(a=>new Uint8Array(atob(a).split("").map(t=>t.charCodeAt(0))).buffer),mt=o.z.union([o.z.null(),o.z.undefined()]).transform(()=>new Uint8Array().buffer),p=10,K=(a,t)=>{if(a==="number"&&!t.isNumeric)throw new Error(`cannot convert series of type ${t.toString()} to number`);if(a==="bigint"&&!t.usesBigInt)throw new Error(`cannot convert series of type ${t.toString()} to bigint`)},D="sy_x_telem_series";class v{key;discriminator=D;dataType;sampleOffset;gl;_data;timeRange=w.ZERO;alignment=0n;alignmentMultiple=1n;cachedMin;cachedMax;writePos=B;_refCount=0;cachedLength;_cachedIndexes;static crudeZ=o.z.object({timeRange:w.z.optional(),dataType:s.z,alignment:o.z.coerce.bigint().optional(),data:o.z.union([yt,mt,o.z.instanceof(ArrayBuffer),o.z.instanceof(Uint8Array)]),glBufferUsage:it.optional().default("static").optional()});static z=v.crudeZ.transform(t=>new v(t));constructor(t){X(t)&&(t={data:t}),t.data??=[];const{dataType:e,timeRange:n,sampleOffset:u=0,glBufferUsage:l="static",alignment:f=0n,alignmentMultiple:A=1n,key:m=q(),data:O}=t;if(Q(O)){const c=O;this.key=c.key,this.dataType=c.dataType,this.sampleOffset=c.sampleOffset,this.gl=c.gl,this._data=c._data,this.timeRange=c.timeRange,this.alignment=c.alignment,this.alignmentMultiple=c.alignmentMultiple,this.cachedMin=c.cachedMin,this.cachedMax=c.cachedMax,this.writePos=c.writePos,this._refCount=c._refCount,this.cachedLength=c.cachedLength;return}const N=z(O),I=Array.isArray(O);if(e!=null)this.dataType=new s(e);else{if(O instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(I||N){let c=O;if(!N){if(O.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");c=O[0]}if(typeof c=="string")this.dataType=s.STRING;else if(typeof c=="number")this.dataType=s.FLOAT64;else if(typeof c=="bigint")this.dataType=s.INT64;else if(typeof c=="boolean")this.dataType=s.BOOLEAN;else if(c instanceof r||c instanceof Date||c instanceof r)this.dataType=s.TIMESTAMP;else if(typeof c=="object")this.dataType=s.JSON;else throw new Error(`cannot infer data type of ${typeof c} when constructing a Series from a JS array`)}else this.dataType=new s(O)}if(!I&&!N)this._data=O;else if(I&&O.length===0)this._data=new this.dataType.Array([]).buffer;else{let c=N?[O]:O;const U=c[0];(U instanceof r||U instanceof Date||U instanceof i)&&(c=c.map(E=>new r(E).valueOf())),this.dataType.equals(s.STRING)?(this.cachedLength=c.length,this._data=new TextEncoder().encode(`${c.join(`
|
|
2
|
+
`)}
|
|
3
|
+
`).buffer):this.dataType.equals(s.JSON)?(this.cachedLength=c.length,this._data=new TextEncoder().encode(`${c.map(E=>S.JSON_CODEC.encodeString(E)).join(`
|
|
4
|
+
`)}
|
|
5
|
+
`).buffer):this.dataType.usesBigInt&&typeof U=="number"?this._data=new this.dataType.Array(c.map(E=>BigInt(Math.round(E)))).buffer:!this.dataType.usesBigInt&&typeof U=="bigint"?this._data=new this.dataType.Array(c.map(Number)).buffer:this._data=new this.dataType.Array(c).buffer}this.key=m,this.alignment=f,this.alignmentMultiple=A,this.sampleOffset=u??0,this.timeRange=n??w.ZERO,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:l}}static alloc({capacity:t,dataType:e,...n}){if(t===0)throw new Error("[Series] - cannot allocate an array of length 0");const u=new new s(e).Array(t),l=new v({data:u.buffer,dataType:e,...n});return l.writePos=0,l}get refCount(){return this._refCount}acquire(t){this._refCount++,t!=null&&this.updateGLBuffer(t)}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(t){if(!t.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");return this.dataType.isVariable?this.writeVariable(t):this.writeFixed(t)}writeVariable(t){if(this.writePos===B)return 0;const e=this.byteCapacity.valueOf()-this.writePos,n=t.subBytes(0,e);return this.writeToUnderlyingData(n),this.writePos+=n.byteLength.valueOf(),this.cachedLength!=null&&(this.cachedLength+=n.length,this.calculateCachedLength()),n.length}writeFixed(t){if(this.writePos===B)return 0;const e=this.capacity-this.writePos,n=t.sub(0,e);return this.writeToUnderlyingData(n),this.cachedLength=void 0,this.maybeRecomputeMinMax(n),this.writePos+=n.length,n.length}writeToUnderlyingData(t){this.underlyingData.set(t.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===B?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){return this.dataType.isVariable?new TextDecoder().decode(this.underlyingData).split(`
|
|
6
|
+
`).slice(0,-1):Array.from(this).map(t=>t.toString())}parseJSON(t){if(!this.dataType.equals(s.JSON))throw new Error("cannot parse non-JSON series as JSON");return this.toStrings().map(e=>t.parse(S.JSON_CODEC.decodeString(e)))}get byteCapacity(){return new d(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===B?this.byteCapacity:this.dataType.isVariable?new d(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this.cachedLength!=null?this.cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===B?this.byteCapacity.valueOf()/this.dataType.density.valueOf():this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let t=0;const e=[0];return this.data.forEach((n,u)=>{n===p&&(t++,e.push(u+1))}),this._cachedIndexes=e,this.cachedLength=t,t}convert(t,e=0){if(this.dataType.equals(t))return this;const n=new t.Array(this.length);for(let u=0;u<this.length;u++)n[u]=W(this.dataType,t,this.data[u],e);return new v({data:n.buffer,dataType:t,timeRange:this.timeRange,sampleOffset:e,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(s.TIMESTAMP))this.cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const t=this.data;this.cachedMax=t.reduce((e,n)=>e>n?e:n)}else{const t=this.data;this.cachedMax=t.reduce((e,n)=>e>n?e:n)}return this.cachedMax}get max(){return this.calcMax()}calcMax(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this.cachedMax??=this.calcRawMax(),x(this.cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(s.TIMESTAMP))this.cachedMin=this.data[0];else if(this.dataType.usesBigInt){const t=this.data;this.cachedMin=t.reduce((e,n)=>e<n?e:n)}else{const t=this.data;this.cachedMin=t.reduce((e,n)=>e<n?e:n)}return this.cachedMin}get min(){return this.calcMin()}calcMin(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this.cachedMin??=this.calcRawMin(),x(this.cachedMin,this.sampleOffset))}get bounds(){return h.construct(Number(this.min),Number(this.max),{makeValid:!1})}maybeRecomputeMinMax(t){if(this.cachedMin!=null){const e=t.cachedMin??t.calcRawMin();e<this.cachedMin&&(this.cachedMin=e)}if(this.cachedMax!=null){const e=t.cachedMax??t.calcRawMax();e>this.cachedMax&&(this.cachedMax=e)}}atAlignment(t,e){const n=Number((t-this.alignment)/this.alignmentMultiple);if(n<0||n>=this.length){if(e===!0)throw new Error(`[series] - no value at index ${n}`);return}return this.at(n,e)}at(t,e=!1){if(this.dataType.isVariable)return this.atVariable(t,e??!1);if(this.dataType.equals(s.UUID))return this.atUUID(t,e);t<0&&(t=this.length+t);const n=this.data[t];if(n==null){if(e===!0)throw new Error(`[series] - no value at index ${t}`);return}return x(n,this.sampleOffset)}atUUID(t,e){t<0&&(t=this.length+t);const n=P(new Uint8Array(this.buffer,t*this.dataType.density.valueOf()));if(n==null){if(e)throw new Error(`[series] - no value at index ${t}`);return}return n}atVariable(t,e){let n=0,u=0;if(this._cachedIndexes!=null)n=this._cachedIndexes[t],u=this._cachedIndexes[t+1]-1;else{t<0&&(t=this.length+t);for(let f=0;f<this.data.length;f++)if(this.data[f]===p){if(t===0){u=f;break}n=f+1,t--}if(u===0&&(u=this.data.length),n>=u||t>0){if(e)throw new Error(`[series] - no value at index ${t}`);return}}const l=this.data.slice(n,u);return this.dataType.equals(s.STRING)?new TextDecoder().decode(l):_.snakeToCamel(JSON.parse(new TextDecoder().decode(l)))}binarySearch(t){let e=0,n=this.length-1;const u=C.newF(t);for(;e<=n;){const l=Math.floor((e+n)/2),f=u(this.at(l,!0),t);if(f===0)return l;f<0?e=l+1:n=l-1}return e}updateGLBuffer(t){if(this.gl.control=t,!this.dataType.equals(s.FLOAT32)&&!this.dataType.equals(s.UINT8))throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");const{buffer:e,bufferUsage:n,prevBuffer:u}=this.gl;if(e==null&&(this.gl.buffer=t.createBuffer()),this.writePos!==u)if(t.bindBuffer(t.ARRAY_BUFFER,this.gl.buffer),this.writePos!==B){u===0&&t.bufferData(t.ARRAY_BUFFER,this.byteCapacity.valueOf(),t.STATIC_DRAW);const l=this.dataType.density.size(u).valueOf(),f=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);t.bufferSubData(t.ARRAY_BUFFER,l,f.buffer),this.gl.prevBuffer=this.writePos}else t.bufferData(t.ARRAY_BUFFER,this.buffer,n==="static"?t.STATIC_DRAW:t.DYNAMIC_DRAW),this.gl.prevBuffer=B}as(t){return K(t,this.dataType),this}get digest(){return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:Y(this.alignmentBounds.lower),upper:Y(this.alignmentBounds.upper)},timeRange:this.timeRange.toString(),length:this.length,capacity:this.capacity}}get alignmentBounds(){return h.construct(this.alignment,this.alignment+BigInt(this.length)*this.alignmentMultiple)}maybeGarbageCollectGLBuffer(t){this.gl.buffer!=null&&(t.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const t=new vt(this);return this.dataType.equals(s.JSON)?new $(t):t}return this.dataType.equals(s.UUID)?new Nt(this):new At(this)}slice(t,e){return this.sliceSub(!1,t,e)}sub(t,e){return this.sliceSub(!0,t,e)}subIterator(t,e){return new V(this,t,e??this.length)}subAlignmentIterator(t,e){const n=Math.ceil(Number(t-this.alignment)/Number(this.alignmentMultiple)),u=Math.ceil(Number(e-this.alignment)/Number(this.alignmentMultiple));return new V(this,n,u)}subBytes(t,e){if(t>=0&&(e==null||e>=this.byteLength.valueOf()))return this;const n=this.data.subarray(t,e);return new v({data:n,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(t)})}sliceSub(t,e,n){if(e<=0&&(n==null||n>=this.length))return this;let u;return t?u=this.data.subarray(e,n):u=this.data.slice(e,n),new v({data:u,dataType:this.dataType,timeRange:this.timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}reAlign(t){return new v({data:this.buffer,dataType:this.dataType,timeRange:w.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:t})}toString(){let t=`Series(${this.dataType.toString()} ${this.length} [`;if(this.length<=10)t+=Array.from(this).map(e=>e.toString());else{for(let e=0;e<5;e++)t+=`${this.at(e)?.toString()}`,t+=",";t+="...,";for(let e=-5;e<0;e++)t+=this.at(e)?.toString(),e<-1&&(t+=",")}return t+="])",t}}const X=a=>a==null?!1:Array.isArray(a)||a instanceof ArrayBuffer||ArrayBuffer.isView(a)&&!(a instanceof DataView)||a instanceof v?!0:z(a),Q=J(D,v);class V{series;end;index;constructor(t,e,n){this.series=t;const u=h.construct(0,t.length+1);this.end=h.clamp(u,n),this.index=h.clamp(u,e)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}}class vt{series;index;decoder;constructor(t){if(!t.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=t,this.index=0,this.decoder=new TextDecoder}next(){const t=this.index,e=this.series.data;for(;this.index<e.length&&e[this.index]!==p;)this.index++;const n=this.index;return t===n?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(t,n))})}}class ${wrapped;static schema=o.z.record(o.z.string(),o.z.unknown());constructor(t){this.wrapped=t}next(){const t=this.wrapped.next();return t.done===!0?{done:!0,value:void 0}:{done:!1,value:S.JSON_CODEC.decodeString(t.value,$.schema)}}}class Nt{series;index;data;density;constructor(t){if(!t.dataType.equals(s.UUID))throw new Error("cannot create a UUID series iterator for a non-UUID series");this.series=t,this.index=0,this.data=new Uint8Array(t.buffer),this.density=s.UUID.density.valueOf()}next(){if(this.index>=this.series.length)return{done:!0,value:void 0};const t=P(this.data,this.index*this.density);return this.index++,{done:!1,value:t}}}class At{series;index;constructor(t){this.series=t,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}}class Ut{series;constructor(t=[]){if(t.length!==0){const e=t[0].dataType;for(let n=1;n<t.length;n++)if(!t[n].dataType.equals(e))throw new Error("[multi-series] - series must have the same data type")}this.series=t}as(t){return K(t,this.dataType),this}get dataType(){return this.series.length===0?s.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?w.ZERO:new w(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?h.construct(0n,0n):h.construct(this.series[0].alignmentBounds.lower,this.series[this.series.length-1].alignmentBounds.upper)}push(t){const e=()=>new Error(`cannot push a ${t.dataType.toString()} series to a ${this.dataType.toString()} multi-series`),n=t.dataType.equals(this.dataType);if(Q(t)){if(this.series.length!==0&&!n)throw e();this.series.push(t)}else{if(this.series.length!==0&&t.series.length!==0&&!n)throw e();this.series.push(...t.series)}}get length(){return this.series.reduce((t,e)=>t+e.length,0)}atAlignment(t,e){for(const n of this.series)if(h.contains(n.alignmentBounds,t))return n.atAlignment(t,e);if(e)throw new Error(`[series] - no value at alignment ${t}`)}at(t,e=!1){t<0&&(t=this.length+t);for(const n of this.series){if(t<n.length)return n.at(t,e);t-=n.length}if(e)throw new Error(`[series] - no value at index ${t}`)}subIterator(t,e){return new T(this,t,e??this.length)}subAlignmentIterator(t,e){if(t>=this.alignmentBounds.upper||e<=this.alignmentBounds.lower)return L;let n=0;for(let l=0;l<this.series.length;l++){const f=this.series[l];if(t<f.alignment)break;if(t>=f.alignmentBounds.upper)n+=f.length;else if(h.contains(f.alignmentBounds,t)){n+=Math.ceil(Number(t-f.alignment)/Number(f.alignmentMultiple));break}}let u=0;for(let l=0;l<this.series.length;l++){const f=this.series[l];if(e<f.alignment)break;if(e>=f.alignmentBounds.upper)u+=f.length;else if(h.contains(f.alignmentBounds,e)){u+=Math.ceil(Number(e-f.alignment)/Number(f.alignmentMultiple));break}}return new T(this,n,u)}subAlignmentSpanIterator(t,e){if(t>=this.alignmentBounds.upper)return L;e=Math.min(e,Number(this.distance(t,this.alignmentBounds.upper)));let n=0;for(let u=0;u<this.series.length;u++){const l=this.series[u];if(t<l.alignment)break;if(t>=l.alignmentBounds.upper)n+=l.length;else if(h.contains(l.alignmentBounds,t)){n+=Number(t-l.alignment);break}}return new T(this,n,n+e)}updateGLBuffer(t){this.series.forEach(e=>e.updateGLBuffer(t))}get bounds(){return h.max(this.series.map(t=>t.bounds))}get byteLength(){return new d(this.series.reduce((t,e)=>t+e.byteLength.valueOf(),0))}get data(){const t=new this.dataType.Array(this.length);let e=0;for(const n of this.series)t.set(n.data,e),e+=n.length;return new this.dataType.Array(t.buffer)}traverseAlignment(t,e){const n=this.series.map(u=>u.alignmentBounds);return h.traverse(n,t,e)}acquire(t){this.series.forEach(e=>e.acquire(t))}release(){this.series.forEach(t=>t.release())}distance(t,e){const n=this.series.map(u=>u.alignmentBounds);return h.distance(n,t,e)}parseJSON(t){if(!this.dataType.equals(s.JSON))throw new Error("cannot parse non-JSON series as JSON");return this.series.flatMap(e=>e.parseJSON(t))}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new Et(this.series)}toStrings(){return this.series.flatMap(t=>t.toStrings())}}class Et{series;seriesIndex;internal;constructor(t){this.series=t,this.seriesIndex=0,this.internal=t[0][Symbol.iterator]()}next(){const t=this.internal.next();return t.done===!1?t: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}}class T{series;index;end;constructor(t,e,n){this.series=t,this.end=n,this.index=e}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}}const Y=a=>{const t=a>>32n,e=a&0xffffffffn;return{domain:t,sample:e}};exports.DataType=s;exports.Density=g;exports.MultiSeries=Ut;exports.Rate=y;exports.Series=v;exports.Size=d;exports.TimeRange=w;exports.TimeSpan=i;exports.TimeStamp=r;exports.addSamples=x;exports.convertDataType=W;exports.create=q;exports.id=st;exports.isCrudeSeries=X;exports.isTelemValue=z;exports.matcher=rt;exports.typedArrayZ=ut;exports.uuid=It;
|