@synnaxlabs/x 0.41.0 → 0.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/.turbo/turbo-build.log +23 -23
  2. package/dist/binary.cjs +1 -1
  3. package/dist/binary.js +2 -2
  4. package/dist/{bounds-M-SZ3X1Z.cjs → bounds-BQo7rvs9.cjs} +1 -1
  5. package/dist/{bounds-DQrjn60Q.js → bounds-Bn5_l4Z3.js} +10 -9
  6. package/dist/bounds.cjs +1 -1
  7. package/dist/bounds.js +1 -1
  8. package/dist/compare.cjs +1 -1
  9. package/dist/compare.js +1 -1
  10. package/dist/deep.cjs +1 -1
  11. package/dist/deep.js +66 -69
  12. package/dist/{dimensions-PWy5QZoM.cjs → dimensions-D2QGoNXO.cjs} +1 -1
  13. package/dist/dimensions.cjs +1 -1
  14. package/dist/{external-CvWr1nhS.cjs → external-DWQITF5_.cjs} +1 -1
  15. package/dist/index-BywOGO8U.js +1074 -0
  16. package/dist/index-CYYjI7Uf.cjs +1 -0
  17. package/dist/index-C_6NXBlg.cjs +3 -0
  18. package/dist/{index-BVC_8Cg9.js → index-QGplUHuy.js} +1 -1
  19. package/dist/index.cjs +3 -3
  20. package/dist/index.js +702 -243
  21. package/dist/record.js +3 -1
  22. package/dist/{scale-DL9VFGhL.cjs → scale-BtZINJ-A.cjs} +1 -1
  23. package/dist/{scale-DQwBWnwc.js → scale-DfJe9755.js} +1 -1
  24. package/dist/scale.cjs +1 -1
  25. package/dist/scale.js +1 -1
  26. package/dist/{series-D0zxMWxP.js → series-B9JERcqi.js} +571 -492
  27. package/dist/series-DqJ6f97G.cjs +11 -0
  28. package/dist/spatial.cjs +1 -1
  29. package/dist/spatial.js +2 -2
  30. package/dist/src/binary/{encoder.d.ts → codec.d.ts} +14 -8
  31. package/dist/src/binary/codec.d.ts.map +1 -0
  32. package/dist/src/binary/codec.spec.d.ts +2 -0
  33. package/dist/src/binary/codec.spec.d.ts.map +1 -0
  34. package/dist/src/binary/index.d.ts +1 -1
  35. package/dist/src/binary/index.d.ts.map +1 -1
  36. package/dist/src/breaker/breaker.d.ts +14 -21
  37. package/dist/src/breaker/breaker.d.ts.map +1 -1
  38. package/dist/src/change/change.d.ts +5 -18
  39. package/dist/src/change/change.d.ts.map +1 -1
  40. package/dist/src/color/color.d.ts +126 -0
  41. package/dist/src/color/color.d.ts.map +1 -0
  42. package/dist/src/color/color.spec.d.ts +2 -0
  43. package/dist/src/color/color.spec.d.ts.map +1 -0
  44. package/dist/src/color/external.d.ts +5 -0
  45. package/dist/src/color/external.d.ts.map +1 -0
  46. package/dist/src/color/gradient.d.ts +18 -0
  47. package/dist/src/color/gradient.d.ts.map +1 -0
  48. package/dist/src/color/index.d.ts +2 -0
  49. package/dist/src/color/index.d.ts.map +1 -0
  50. package/dist/src/color/palette.d.ts +19 -0
  51. package/dist/src/color/palette.d.ts.map +1 -0
  52. package/dist/src/color/transformColorsToHex.d.ts +6 -0
  53. package/dist/src/color/transformColorsToHex.d.ts.map +1 -0
  54. package/dist/src/control/control.d.ts +69 -74
  55. package/dist/src/control/control.d.ts.map +1 -1
  56. package/dist/src/deep/merge.d.ts +1 -1
  57. package/dist/src/deep/merge.d.ts.map +1 -1
  58. package/dist/src/errors/errors.d.ts +127 -7
  59. package/dist/src/errors/errors.d.ts.map +1 -1
  60. package/dist/src/errors/errors.spec.d.ts +2 -0
  61. package/dist/src/errors/errors.spec.d.ts.map +1 -0
  62. package/dist/src/index.d.ts +4 -0
  63. package/dist/src/index.d.ts.map +1 -1
  64. package/dist/src/jsonrpc/jsonrpc.d.ts +10 -7
  65. package/dist/src/jsonrpc/jsonrpc.d.ts.map +1 -1
  66. package/dist/src/kv/types.d.ts +1 -7
  67. package/dist/src/kv/types.d.ts.map +1 -1
  68. package/dist/src/migrate/migrate.d.ts +1 -1
  69. package/dist/src/notation/notation.d.ts +5 -1
  70. package/dist/src/notation/notation.d.ts.map +1 -1
  71. package/dist/src/record.d.ts +2 -1
  72. package/dist/src/record.d.ts.map +1 -1
  73. package/dist/src/replace.d.ts +2 -0
  74. package/dist/src/replace.d.ts.map +1 -0
  75. package/dist/src/runtime/os.d.ts +9 -1
  76. package/dist/src/runtime/os.d.ts.map +1 -1
  77. package/dist/src/singleton/define.d.ts +9 -0
  78. package/dist/src/singleton/define.d.ts.map +1 -0
  79. package/dist/src/singleton/define.spec.d.ts +2 -0
  80. package/dist/src/singleton/define.spec.d.ts.map +1 -0
  81. package/dist/src/singleton/index.d.ts +2 -0
  82. package/dist/src/singleton/index.d.ts.map +1 -0
  83. package/dist/src/spatial/base.d.ts +74 -70
  84. package/dist/src/spatial/base.d.ts.map +1 -1
  85. package/dist/src/spatial/box/box.d.ts +18 -76
  86. package/dist/src/spatial/box/box.d.ts.map +1 -1
  87. package/dist/src/spatial/dimensions/dimensions.d.ts +5 -29
  88. package/dist/src/spatial/dimensions/dimensions.d.ts.map +1 -1
  89. package/dist/src/spatial/direction/direction.d.ts +9 -1
  90. package/dist/src/spatial/direction/direction.d.ts.map +1 -1
  91. package/dist/src/spatial/location/location.d.ts +43 -22
  92. package/dist/src/spatial/location/location.d.ts.map +1 -1
  93. package/dist/src/spatial/scale/scale.d.ts +12 -120
  94. package/dist/src/spatial/scale/scale.d.ts.map +1 -1
  95. package/dist/src/spatial/xy/xy.d.ts +5 -29
  96. package/dist/src/spatial/xy/xy.d.ts.map +1 -1
  97. package/dist/src/sync/index.d.ts +2 -0
  98. package/dist/src/sync/index.d.ts.map +1 -0
  99. package/dist/src/sync/mutex.d.ts +8 -0
  100. package/dist/src/sync/mutex.d.ts.map +1 -0
  101. package/dist/src/telem/gl.d.ts +4 -1
  102. package/dist/src/telem/gl.d.ts.map +1 -1
  103. package/dist/src/telem/series.d.ts +46 -125
  104. package/dist/src/telem/series.d.ts.map +1 -1
  105. package/dist/src/telem/telem.d.ts +101 -86
  106. package/dist/src/telem/telem.d.ts.map +1 -1
  107. package/dist/src/toArray.d.ts +1 -1
  108. package/dist/src/toArray.d.ts.map +1 -1
  109. package/dist/src/zod/util.d.ts.map +1 -1
  110. package/dist/telem.cjs +1 -1
  111. package/dist/telem.js +1 -1
  112. package/dist/toArray.cjs +1 -1
  113. package/dist/toArray.js +1 -1
  114. package/dist/zod.cjs +1 -1
  115. package/package.json +7 -4
  116. package/src/binary/codec.spec.ts +370 -0
  117. package/src/binary/{encoder.ts → codec.ts} +55 -11
  118. package/src/binary/index.ts +1 -1
  119. package/src/breaker/breaker.spec.ts +16 -25
  120. package/src/breaker/breaker.ts +36 -19
  121. package/src/color/color.spec.ts +673 -0
  122. package/src/color/color.ts +317 -0
  123. package/src/color/external.ts +13 -0
  124. package/src/color/gradient.ts +78 -0
  125. package/src/color/index.ts +10 -0
  126. package/src/color/palette.ts +28 -0
  127. package/src/color/transformColorsToHex.ts +30 -0
  128. package/src/control/control.ts +30 -22
  129. package/src/deep/merge.ts +2 -8
  130. package/src/errors/errors.spec.ts +152 -0
  131. package/src/errors/errors.ts +225 -10
  132. package/src/index.ts +4 -0
  133. package/src/jsonrpc/jsonrpc.ts +12 -8
  134. package/src/migrate/migrate.ts +2 -2
  135. package/src/primitive.ts +1 -1
  136. package/src/record.ts +5 -1
  137. package/src/replace.ts +1 -0
  138. package/src/singleton/define.spec.ts +93 -0
  139. package/src/singleton/define.ts +27 -0
  140. package/src/singleton/index.ts +10 -0
  141. package/src/sync/index.ts +1 -0
  142. package/src/sync/mutex.ts +16 -0
  143. package/src/telem/series.spec.ts +32 -0
  144. package/src/telem/series.ts +54 -19
  145. package/src/telem/telem.spec.ts +151 -10
  146. package/src/telem/telem.ts +126 -73
  147. package/src/toArray.ts +2 -2
  148. package/src/zod/util.spec.ts +17 -1
  149. package/src/zod/util.ts +4 -2
  150. package/tsconfig.tsbuildinfo +1 -1
  151. package/dist/index-BG3Scw3G.cjs +0 -1
  152. package/dist/index-C3QzbIwt.js +0 -101
  153. package/dist/index-CnclyYpG.cjs +0 -3
  154. package/dist/series-BMma2b5q.cjs +0 -11
  155. package/dist/src/binary/encoder.d.ts.map +0 -1
  156. package/dist/src/binary/encoder.spec.d.ts +0 -2
  157. package/dist/src/binary/encoder.spec.d.ts.map +0 -1
  158. package/src/binary/encoder.spec.ts +0 -174
@@ -1,80 +1,79 @@
1
1
  var rt = Object.defineProperty;
2
- var nt = (o, t, e) => t in o ? rt(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
- var s = (o, t, e) => nt(o, typeof t != "symbol" ? t + "" : t, e);
2
+ var it = (o, t, e) => t in o ? rt(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
+ var r = (o, t, e) => it(o, typeof t != "symbol" ? t + "" : t, e);
4
4
  import { z as l } from "zod";
5
- import { J as q } from "./index-C3QzbIwt.js";
6
- import { s as st } from "./index-DizUWH6z.js";
7
- import { n as it } from "./index-BVC_8Cg9.js";
8
- import { m as R, c as L, a as V, d as D, t as at, e as ut } from "./bounds-DQrjn60Q.js";
5
+ import { J as q } from "./index-BywOGO8U.js";
6
+ import { s as at } from "./index-DizUWH6z.js";
7
+ import { n as ut } from "./index-QGplUHuy.js";
8
+ import { m as C, c as L, a as J, d as D, e as ot, t as lt, f as ft } from "./bounds-Bn5_l4Z3.js";
9
9
  import "./box-Cc8IzcNo.js";
10
10
  import "./dimensions-CRgergMS.js";
11
11
  import "./base-DFq0vvGn.js";
12
12
  import "./location-C3aeu046.js";
13
- import "./scale-DQwBWnwc.js";
13
+ import "./scale-DfJe9755.js";
14
14
  import "./xy-D_LqxaGt.js";
15
- let ot = (o, t = 21) => (e = t) => {
16
- let r = "", a = e | 0;
17
- for (; a--; )
18
- r += o[Math.random() * o.length | 0];
19
- return r;
15
+ let ht = (o, t = 21) => (e = t) => {
16
+ let s = "", i = e | 0;
17
+ for (; i--; )
18
+ s += o[Math.random() * o.length | 0];
19
+ return s;
20
20
  };
21
- const lt = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", ft = ot(lt, 11), Q = () => ft(), Ct = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
21
+ const ct = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", dt = ht(ct, 11), tt = () => dt(), Lt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
22
22
  __proto__: null,
23
- create: Q
24
- }, Symbol.toStringTag, { value: "Module" })), ct = l.enum(["static", "dynamic"]), _ = (o, t) => {
23
+ create: tt
24
+ }, Symbol.toStringTag, { value: "Module" })), gt = l.enum(["static", "dynamic"]), et = (o, t) => {
25
25
  const e = new m(t);
26
26
  if (![
27
- w.DAY,
28
- w.HOUR,
29
- w.MINUTE,
30
- w.SECOND,
31
- w.MILLISECOND,
32
- w.MICROSECOND,
33
- w.NANOSECOND
34
- ].some((a) => a.equals(e)))
27
+ O.DAY,
28
+ O.HOUR,
29
+ O.MINUTE,
30
+ O.SECOND,
31
+ O.MILLISECOND,
32
+ O.MICROSECOND,
33
+ O.NANOSECOND
34
+ ].some((i) => i.equals(e)))
35
35
  throw new Error(
36
36
  "Invalid argument for remainder. Must be an even TimeSpan or Timestamp"
37
37
  );
38
- const r = o.valueOf() % e.valueOf();
39
- return o instanceof m ? new m(r) : new w(r);
40
- }, i = class i {
38
+ const s = o.valueOf() % e.valueOf();
39
+ return o instanceof m ? new m(s) : new O(s);
40
+ }, a = class a {
41
41
  constructor(t, e = "UTC") {
42
- s(this, "value");
43
- s(this, "encodeValue", !0);
44
- if (t == null) this.value = i.now().valueOf();
42
+ /** The underlying value for the time stamp */
43
+ r(this, "value");
44
+ /** Makes sure JSON encodes the value and not the class. */
45
+ r(this, "encodeValue", !0);
46
+ if (t == null) this.value = a.now().valueOf();
45
47
  else if (t instanceof Date)
46
- this.value = BigInt(t.getTime()) * i.MILLISECOND.valueOf();
48
+ this.value = BigInt(t.getTime()) * a.MILLISECOND.valueOf();
47
49
  else if (typeof t == "string")
48
- this.value = i.parseDateTimeString(t, e).valueOf();
49
- else if (Array.isArray(t)) this.value = i.parseDate(t);
50
+ this.value = a.parseDateTimeString(t, e).valueOf();
51
+ else if (Array.isArray(t)) this.value = a.parseDate(t);
50
52
  else {
51
- let r = BigInt(0);
52
- t instanceof Number && (t = t.valueOf()), e === "local" && (r = i.utcOffset.valueOf()), typeof t == "number" && (isFinite(t) ? t = Math.trunc(t) : (isNaN(t) && (t = 0), t === 1 / 0 ? t = i.MAX : t = i.MIN)), this.value = BigInt(t.valueOf()) + r;
53
+ let s = BigInt(0);
54
+ t instanceof Number && (t = t.valueOf()), e === "local" && (s = a.utcOffset.valueOf()), typeof t == "number" && (isFinite(t) ? t = Math.trunc(t) : (isNaN(t) && (t = 0), t === 1 / 0 ? t = a.MAX : t = a.MIN)), this.value = BigInt(t.valueOf()) + s;
53
55
  }
54
56
  }
55
- static parseDate([t = 1970, e = 1, r = 1]) {
56
- const a = new Date(t, e - 1, r, 0, 0, 0, 0);
57
- return new i(BigInt(a.getTime()) * i.MILLISECOND.valueOf()).truncate(i.DAY).valueOf();
58
- }
59
- encode() {
60
- return this.value.toString();
57
+ static parseDate([t = 1970, e = 1, s = 1]) {
58
+ const i = new Date(t, e - 1, s, 0, 0, 0, 0);
59
+ return new a(BigInt(i.getTime()) * a.MILLISECOND.valueOf()).truncate(a.DAY).valueOf();
61
60
  }
62
61
  valueOf() {
63
62
  return this.value;
64
63
  }
65
64
  static parseTimeString(t, e = "UTC") {
66
- const [r, a, c] = t.split(":");
67
- let h = "00", v = "00";
68
- c != null && ([h, v] = c.split("."));
69
- let O = i.hours(parseInt(r ?? "00")).add(i.minutes(parseInt(a ?? "00"))).add(i.seconds(parseInt(h ?? "00"))).add(i.milliseconds(parseInt(v ?? "00")));
70
- return e === "local" && (O = O.add(i.utcOffset)), O.valueOf();
65
+ const [s, i, h] = t.split(":");
66
+ let c = "00", v = "00";
67
+ h != null && ([c, v] = h.split("."));
68
+ let b = a.hours(parseInt(s ?? "00")).add(a.minutes(parseInt(i ?? "00"))).add(a.seconds(parseInt(c ?? "00"))).add(a.milliseconds(parseInt(v ?? "00")));
69
+ return e === "local" && (b = b.add(a.utcOffset)), b.valueOf();
71
70
  }
72
71
  static parseDateTimeString(t, e = "UTC") {
73
72
  if (!t.includes("/") && !t.includes("-"))
74
- return i.parseTimeString(t, e);
75
- const r = new Date(t);
76
- return t.includes(":") || r.setUTCHours(0, 0, 0, 0), new i(
77
- BigInt(r.getTime()) * i.MILLISECOND.valueOf(),
73
+ return a.parseTimeString(t, e);
74
+ const s = new Date(t);
75
+ return t.includes(":") || s.setUTCHours(0, 0, 0, 0), new a(
76
+ BigInt(s.getTime()) * a.MILLISECOND.valueOf(),
78
77
  e
79
78
  ).valueOf();
80
79
  }
@@ -99,19 +98,19 @@ const lt = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", ft
99
98
  }
100
99
  }
101
100
  toISOString(t = "UTC") {
102
- return t === "UTC" ? this.date().toISOString() : this.sub(i.utcOffset).date().toISOString();
101
+ return t === "UTC" ? this.date().toISOString() : this.sub(a.utcOffset).date().toISOString();
103
102
  }
104
103
  timeString(t = !1, e = "UTC") {
105
- const r = this.toISOString(e);
106
- return t ? r.slice(11, 23) : r.slice(11, 19);
104
+ const s = this.toISOString(e);
105
+ return t ? s.slice(11, 23) : s.slice(11, 19);
107
106
  }
108
107
  dateString() {
109
- const t = this.date(), e = t.toLocaleString("default", { month: "short" }), r = t.toLocaleString("default", { day: "numeric" });
110
- return `${e} ${r}`;
108
+ const t = this.date(), e = t.toLocaleString("default", { month: "short" }), s = t.toLocaleString("default", { day: "numeric" });
109
+ return `${e} ${s}`;
111
110
  }
112
111
  static get utcOffset() {
113
- return new w(
114
- BigInt((/* @__PURE__ */ new Date()).getTimezoneOffset()) * i.MINUTE.valueOf()
112
+ return new O(
113
+ BigInt((/* @__PURE__ */ new Date()).getTimezoneOffset()) * a.MINUTE.valueOf()
115
114
  );
116
115
  }
117
116
  /**
@@ -120,7 +119,7 @@ const lt = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", ft
120
119
  * @param other - The other timestamp.
121
120
  */
122
121
  static since(t) {
123
- return new i().span(t);
122
+ return new a().span(t);
124
123
  }
125
124
  /** @returns A JavaScript Date object representing the TimeStamp. */
126
125
  date() {
@@ -133,7 +132,7 @@ const lt = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", ft
133
132
  * @returns True if the TimeStamps are equal, false otherwise.
134
133
  */
135
134
  equals(t) {
136
- return this.valueOf() === new i(t).valueOf();
135
+ return this.valueOf() === new a(t).valueOf();
137
136
  }
138
137
  /**
139
138
  * Creates a TimeSpan representing the duration between the two timestamps.
@@ -153,7 +152,7 @@ const lt = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", ft
153
152
  * valid, regardless of the TimeStamp order.
154
153
  */
155
154
  range(t) {
156
- return new U(this, t).makeValid();
155
+ return new A(this, t).makeValid();
157
156
  }
158
157
  /**
159
158
  * Creates a TimeRange starting at the TimeStamp and spanning the given
@@ -182,7 +181,7 @@ const lt = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", ft
182
181
  * otherwise.
183
182
  */
184
183
  after(t) {
185
- return this.valueOf() > new i(t).valueOf();
184
+ return this.valueOf() > new a(t).valueOf();
186
185
  }
187
186
  /**
188
187
  * Checks if the TimeStamp is after or equal to the given TimeStamp.
@@ -192,7 +191,7 @@ const lt = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", ft
192
191
  * false otherwise.
193
192
  */
194
193
  afterEq(t) {
195
- return this.valueOf() >= new i(t).valueOf();
194
+ return this.valueOf() >= new a(t).valueOf();
196
195
  }
197
196
  /**
198
197
  * Checks if the TimeStamp is before the given TimeStamp.
@@ -202,7 +201,7 @@ const lt = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", ft
202
201
  * otherwise.
203
202
  */
204
203
  before(t) {
205
- return this.valueOf() < new i(t).valueOf();
204
+ return this.valueOf() < new a(t).valueOf();
206
205
  }
207
206
  /**
208
207
  * Checks if TimeStamp is before or equal to the current timestamp.
@@ -212,7 +211,7 @@ const lt = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", ft
212
211
  * false otherwise.
213
212
  */
214
213
  beforeEq(t) {
215
- return this.valueOf() <= new i(t).valueOf();
214
+ return this.valueOf() <= new a(t).valueOf();
216
215
  }
217
216
  /**
218
217
  * Adds a TimeSpan to the TimeStamp.
@@ -222,7 +221,7 @@ const lt = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", ft
222
221
  * TimeSpan.
223
222
  */
224
223
  add(t) {
225
- return new i(this.valueOf() + BigInt(t.valueOf()));
224
+ return new a(this.valueOf() + BigInt(t.valueOf()));
226
225
  }
227
226
  /**
228
227
  * Subtracts a TimeSpan from the TimeStamp.
@@ -232,45 +231,49 @@ const lt = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", ft
232
231
  * TimeSpan.
233
232
  */
234
233
  sub(t) {
235
- return new i(this.valueOf() - BigInt(t.valueOf()));
234
+ return new a(this.valueOf() - BigInt(t.valueOf()));
236
235
  }
237
236
  /**
238
237
  * @returns the floating point number of hours since the unix epoch to the timestamp
239
238
  * value.
240
239
  */
241
240
  get hours() {
242
- return Number(this.valueOf()) / Number(w.HOUR.valueOf());
241
+ return Number(this.valueOf()) / Number(O.HOUR.valueOf());
243
242
  }
244
243
  /**
245
244
  * @returns the floating point number of minutes since the unix epoch to the timestamp
246
245
  * value.
247
246
  */
248
247
  get minutes() {
249
- return Number(this.valueOf()) / Number(w.MINUTE.valueOf());
248
+ return Number(this.valueOf()) / Number(O.MINUTE.valueOf());
250
249
  }
251
250
  /**
252
251
  * @returns the floating point number of days since the unix epoch to the timestamp
253
252
  * value.
254
253
  */
255
254
  get days() {
256
- return Number(this.valueOf()) / Number(w.DAY.valueOf());
255
+ return Number(this.valueOf()) / Number(O.DAY.valueOf());
257
256
  }
258
257
  /**
259
258
  * @returns the floating point number of seconds since the unix epoch to the timestamp
260
259
  * value.
261
260
  */
262
261
  get seconds() {
263
- return Number(this.valueOf()) / Number(w.SECOND.valueOf());
262
+ return Number(this.valueOf()) / Number(O.SECOND.valueOf());
264
263
  }
265
- /**
266
- * @returns The number of milliseconds since the unix epoch.
267
- */
264
+ /** @returns the floating point number of milliseconds since the unix epoch. */
268
265
  get milliseconds() {
269
- return Number(this.valueOf()) / Number(i.MILLISECOND.valueOf());
266
+ return Number(this.valueOf()) / Number(a.MILLISECOND.valueOf());
270
267
  }
268
+ /** @returns the floating point number of microseconds since the unix epoch */
271
269
  get microseconds() {
272
- return Number(this.valueOf()) / Number(i.MICROSECOND.valueOf());
270
+ return Number(this.valueOf()) / Number(a.MICROSECOND.valueOf());
273
271
  }
272
+ /**
273
+ * @returns the floating point number of nanoseconds since the unix epoch.
274
+ * Note that since we're converting to float64, this reduces the resolution
275
+ * to a quarter of a microsecond.
276
+ */
274
277
  get nanoseconds() {
275
278
  return Number(this.valueOf());
276
279
  }
@@ -278,63 +281,102 @@ const lt = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", ft
278
281
  get year() {
279
282
  return this.date().getFullYear();
280
283
  }
284
+ /**
285
+ * @returns a copy of the timestamp with the year changed.
286
+ * @param year the value to set the year to.
287
+ */
281
288
  setYear(t) {
282
289
  const e = this.date();
283
- return e.setFullYear(t), new i(e);
290
+ return e.setFullYear(t), new a(e);
284
291
  }
285
292
  /** @returns the integer month that the timestamp corresponds to with its year. */
286
293
  get month() {
287
- return this.date().getMonth();
294
+ return this.date().getUTCMonth();
288
295
  }
296
+ /**
297
+ * @returns a copy of the timestamp with the month changed.
298
+ * @param month the value to set the month to.
299
+ */
289
300
  setMonth(t) {
290
301
  const e = this.date();
291
- return e.setMonth(t), new i(e);
302
+ return e.setUTCMonth(t), new a(e);
292
303
  }
293
304
  /** @returns the integer day that the timestamp corresponds to within its month. */
294
305
  get day() {
295
- return this.date().getDate();
306
+ return this.date().getUTCDate();
296
307
  }
308
+ /**
309
+ * @returns a copy of the timestamp with the day changed.
310
+ * @param day the value the set the day to.
311
+ */
297
312
  setDay(t) {
298
313
  const e = this.date();
299
- return e.setDate(t), new i(e);
314
+ return e.setUTCDate(t), new a(e);
300
315
  }
301
- /** @returns the integer hour that the timestamp corresponds to within its day. */
316
+ /**
317
+ * @returns the integer hour that the timestamp corresponds to within its day.
318
+ */
302
319
  get hour() {
303
- return this.date().getHours();
320
+ return this.date().getUTCHours();
304
321
  }
322
+ /**
323
+ * @returns a copy of the timestamp with the hour changed.
324
+ * @param hour the value to set the hour to.
325
+ */
305
326
  setHour(t) {
306
327
  const e = this.date();
307
- return e.setHours(t), new i(e);
328
+ return e.setUTCHours(t), new a(e, "UTC");
308
329
  }
309
330
  /** @returns the integer minute that the timestamp corresponds to within its hour. */
310
331
  get minute() {
311
332
  return this.date().getMinutes();
312
333
  }
334
+ /**
335
+ * @returns a copy of the timestamp with the minute changed.
336
+ * @param minute the value to set the minute to.
337
+ */
313
338
  setMinute(t) {
314
339
  const e = this.date();
315
- return e.setMinutes(t), new i(e);
340
+ return e.setUTCMinutes(t), new a(e);
316
341
  }
342
+ /**
343
+ * @returns the integer second that the timestamp corresponds to within its
344
+ * minute.
345
+ */
317
346
  get second() {
318
347
  return this.date().getSeconds();
319
348
  }
349
+ /**
350
+ * @returns a copy of the timestamp with the second changed.
351
+ * @param second the value to set the second to.
352
+ */
320
353
  setSecond(t) {
321
354
  const e = this.date();
322
- return e.setSeconds(t), new i(e);
355
+ return e.setUTCSeconds(t), new a(e);
323
356
  }
357
+ /**
358
+ * @reutrns the integer millisecond that the timestamp corresponds to within
359
+ * its second.
360
+ */
324
361
  get millisecond() {
325
362
  return this.date().getMilliseconds();
326
363
  }
364
+ /**
365
+ * @returns a copy of the timestamp with the milliseconds changed.
366
+ * @param millisecond the value to set the millisecond to.
367
+ */
327
368
  setMillisecond(t) {
328
369
  const e = this.date();
329
- return e.setMilliseconds(t), new i(e);
370
+ return e.setMilliseconds(t), new a(e);
330
371
  }
372
+ /** @returns the time stamp formatted as an ISO string. */
331
373
  toString() {
332
374
  return this.date().toISOString();
333
375
  }
334
376
  /**
335
377
  * @returns A new TimeStamp that is the remainder of the TimeStamp divided by the
336
378
  * given span. This is useful in cases where you want only part of a TimeStamp's value
337
- * i.e. the hours, minutes, seconds, milliseconds, microseconds, and nanoseconds but
379
+ * i.e., the hours, minutes, seconds, milliseconds, microseconds, and nanoseconds but
338
380
  * not the days, years, etc.
339
381
  *
340
382
  * @param divisor - The TimeSpan to divide by. Must be an even TimeSpan or TimeStamp. Even
@@ -343,11 +385,11 @@ const lt = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", ft
343
385
  * @example TimeStamp.now().remainder(TimeStamp.DAY) // => TimeStamp representing the current day
344
386
  */
345
387
  remainder(t) {
346
- return _(this, t);
388
+ return et(this, t);
347
389
  }
348
390
  /** @returns true if the day portion TimeStamp is today, false otherwise. */
349
391
  get isToday() {
350
- return this.truncate(w.DAY).equals(i.now().truncate(w.DAY));
392
+ return this.truncate(O.DAY).equals(a.now().truncate(O.DAY));
351
393
  }
352
394
  truncate(t) {
353
395
  return this.sub(this.remainder(t));
@@ -358,76 +400,78 @@ const lt = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", ft
358
400
  * JavaScript can do).
359
401
  */
360
402
  static now() {
361
- return new i(/* @__PURE__ */ new Date());
403
+ return new a(/* @__PURE__ */ new Date());
362
404
  }
405
+ /** @returns the maximum value of all the timestamps. */
363
406
  static max(...t) {
364
- let e = i.MIN;
365
- for (const r of t) {
366
- const a = new i(r);
367
- a.after(e) && (e = a);
407
+ let e = a.MIN;
408
+ for (const s of t) {
409
+ const i = new a(s);
410
+ i.after(e) && (e = i);
368
411
  }
369
412
  return e;
370
413
  }
414
+ /** @returns the minimum value of all the timestamps. */
371
415
  static min(...t) {
372
- let e = i.MAX;
373
- for (const r of t) {
374
- const a = new i(r);
375
- a.before(e) && (e = a);
416
+ let e = a.MAX;
417
+ for (const s of t) {
418
+ const i = new a(s);
419
+ i.before(e) && (e = i);
376
420
  }
377
421
  return e;
378
422
  }
379
423
  /** @returns a new TimeStamp n nanoseconds after the unix epoch */
380
- static nanoseconds(t) {
381
- return new i(t);
424
+ static nanoseconds(t, e = "UTC") {
425
+ return new a(t, e);
382
426
  }
383
427
  /** @returns a new TimeStamp n microseconds after the unix epoch */
384
- static microseconds(t) {
385
- return i.nanoseconds(t * 1e3);
428
+ static microseconds(t, e = "UTC") {
429
+ return a.nanoseconds(t * 1e3, e);
386
430
  }
387
431
  /** @returns a new TimeStamp n milliseconds after the unix epoch */
388
- static milliseconds(t) {
389
- return i.microseconds(t * 1e3);
432
+ static milliseconds(t, e = "UTC") {
433
+ return a.microseconds(t * 1e3, e);
390
434
  }
391
435
  /** @returns a new TimeStamp n seconds after the unix epoch */
392
- static seconds(t) {
393
- return i.milliseconds(t * 1e3);
436
+ static seconds(t, e = "UTC") {
437
+ return a.milliseconds(t * 1e3, e);
394
438
  }
395
439
  /** @returns a new TimeStamp n minutes after the unix epoch */
396
- static minutes(t) {
397
- return i.seconds(t * 60);
440
+ static minutes(t, e = "UTC") {
441
+ return a.seconds(t * 60, e);
398
442
  }
399
443
  /** @returns a new TimeStamp n hours after the unix epoch */
400
- static hours(t) {
401
- return i.minutes(t * 60);
444
+ static hours(t, e = "UTC") {
445
+ return a.minutes(t * 60, e);
402
446
  }
403
447
  /** @returns a new TimeStamp n days after the unix epoch */
404
- static days(t) {
405
- return i.hours(t * 24);
448
+ static days(t, e = "UTC") {
449
+ return a.hours(t * 24, e);
406
450
  }
407
451
  };
408
- /* One nanosecond after the unix epoch */
409
- s(i, "NANOSECOND", i.nanoseconds(1)), /** One microsecond after the unix epoch */
410
- s(i, "MICROSECOND", i.microseconds(1)), /** One millisecond after the unix epoch */
411
- s(i, "MILLISECOND", i.milliseconds(1)), /** One second after the unix epoch */
412
- s(i, "SECOND", i.seconds(1)), /** One minute after the unix epoch */
413
- s(i, "MINUTE", i.minutes(1)), /** One hour after the unix epoch */
414
- s(i, "HOUR", i.hours(1)), /** One day after the unix epoch */
415
- s(i, "DAY", i.days(1)), /** The maximum possible value for a timestamp */
416
- s(i, "MAX", new i((1n << 63n) - 1n)), /** The minimum possible value for a timestamp */
417
- s(i, "MIN", new i(0)), /** The unix epoch */
418
- s(i, "ZERO", new i(0)), /** A zod schema for validating timestamps */
419
- s(i, "z", l.union([
420
- l.object({ value: l.bigint() }).transform((t) => new i(t.value)),
421
- l.string().transform((t) => new i(BigInt(t))),
422
- l.instanceof(Number).transform((t) => new i(t)),
423
- l.number().transform((t) => new i(t)),
424
- l.instanceof(i)
452
+ /** One nanosecond after the unix epoch */
453
+ r(a, "NANOSECOND", a.nanoseconds(1)), /** One microsecond after the unix epoch */
454
+ r(a, "MICROSECOND", a.microseconds(1)), /** One millisecond after the unix epoch */
455
+ r(a, "MILLISECOND", a.milliseconds(1)), /** One second after the unix epoch */
456
+ r(a, "SECOND", a.seconds(1)), /** One minute after the unix epoch */
457
+ r(a, "MINUTE", a.minutes(1)), /** One hour after the unix epoch */
458
+ r(a, "HOUR", a.hours(1)), /** One day after the unix epoch */
459
+ r(a, "DAY", a.days(1)), /** The maximum possible value for a timestamp */
460
+ r(a, "MAX", new a((1n << 63n) - 1n)), /** The minimum possible value for a timestamp */
461
+ r(a, "MIN", new a(0)), /** The unix epoch */
462
+ r(a, "ZERO", new a(0)), /** A zod schema for validating timestamps */
463
+ r(a, "z", l.union([
464
+ l.object({ value: l.bigint() }).transform((t) => new a(t.value)),
465
+ l.string().transform((t) => new a(BigInt(t))),
466
+ l.instanceof(Number).transform((t) => new a(t)),
467
+ l.number().transform((t) => new a(t)),
468
+ l.instanceof(a)
425
469
  ]));
426
- let m = i;
470
+ let m = a;
427
471
  const u = class u {
428
472
  constructor(t) {
429
- s(this, "value");
430
- s(this, "encodeValue", !0);
473
+ r(this, "value");
474
+ r(this, "encodeValue", !0);
431
475
  typeof t == "number" && (t = Math.trunc(t.valueOf())), this.value = BigInt(t.valueOf());
432
476
  }
433
477
  static fromSeconds(t) {
@@ -455,7 +499,7 @@ const u = class u {
455
499
  return this.valueOf() >= new u(t).valueOf();
456
500
  }
457
501
  remainder(t) {
458
- return _(this, t);
502
+ return et(this, t);
459
503
  }
460
504
  truncate(t) {
461
505
  return new u(
@@ -463,9 +507,9 @@ const u = class u {
463
507
  );
464
508
  }
465
509
  toString() {
466
- const t = this.truncate(u.DAY), e = this.truncate(u.HOUR), r = this.truncate(u.MINUTE), a = this.truncate(u.SECOND), c = this.truncate(u.MILLISECOND), h = this.truncate(u.MICROSECOND), v = this.truncate(u.NANOSECOND), O = t, T = e.sub(t), A = r.sub(e), f = a.sub(r), B = c.sub(a), S = h.sub(c), Z = v.sub(h);
510
+ const t = this.truncate(u.DAY), e = this.truncate(u.HOUR), s = this.truncate(u.MINUTE), i = this.truncate(u.SECOND), h = this.truncate(u.MILLISECOND), c = this.truncate(u.MICROSECOND), v = this.truncate(u.NANOSECOND), b = t, N = e.sub(t), B = s.sub(e), f = i.sub(s), U = h.sub(i), S = c.sub(h), V = v.sub(c);
467
511
  let E = "";
468
- return O.isZero || (E += `${O.days}d `), T.isZero || (E += `${T.hours}h `), A.isZero || (E += `${A.minutes}m `), f.isZero || (E += `${f.seconds}s `), B.isZero || (E += `${B.milliseconds}ms `), S.isZero || (E += `${S.microseconds}µs `), Z.isZero || (E += `${Z.nanoseconds}ns`), E.trim();
512
+ return b.isZero || (E += `${b.days}d `), N.isZero || (E += `${N.hours}h `), B.isZero || (E += `${B.minutes}m `), f.isZero || (E += `${f.seconds}s `), U.isZero || (E += `${U.milliseconds}ms `), S.isZero || (E += `${S.microseconds}µs `), V.isZero || (E += `${V.nanoseconds}ns`), E.trim();
469
513
  }
470
514
  mult(t) {
471
515
  return new u(this.valueOf() * BigInt(t));
@@ -544,7 +588,7 @@ const u = class u {
544
588
  * @returns A TimeSpan representing the given number of microseconds.
545
589
  */
546
590
  static microseconds(t = 1) {
547
- return u.nanoseconds(R(t, 1e3));
591
+ return u.nanoseconds(C(t, 1e3));
548
592
  }
549
593
  /**
550
594
  * Creates a TimeSpan representing the given number of milliseconds.
@@ -553,7 +597,7 @@ const u = class u {
553
597
  * @returns A TimeSpan representing the given number of milliseconds.
554
598
  */
555
599
  static milliseconds(t = 1) {
556
- return u.microseconds(R(t, 1e3));
600
+ return u.microseconds(C(t, 1e3));
557
601
  }
558
602
  /**
559
603
  * Creates a TimeSpan representing the given number of seconds.
@@ -562,7 +606,7 @@ const u = class u {
562
606
  * @returns A TimeSpan representing the given number of seconds.
563
607
  */
564
608
  static seconds(t = 1) {
565
- return u.milliseconds(R(t, 1e3));
609
+ return u.milliseconds(C(t, 1e3));
566
610
  }
567
611
  /**
568
612
  * Creates a TimeSpan representing the given number of minutes.
@@ -571,7 +615,7 @@ const u = class u {
571
615
  * @returns A TimeSpan representing the given number of minutes.
572
616
  */
573
617
  static minutes(t = 1) {
574
- return u.seconds(R(t, 60));
618
+ return u.seconds(C(t, 60));
575
619
  }
576
620
  /**
577
621
  * Creates a TimeSpan representing the given number of hours.
@@ -580,7 +624,7 @@ const u = class u {
580
624
  * @returns A TimeSpan representing the given number of hours.
581
625
  */
582
626
  static hours(t) {
583
- return u.minutes(R(t, 60));
627
+ return u.minutes(C(t, 60));
584
628
  }
585
629
  /**
586
630
  * Creates a TimeSpan representing the given number of days.
@@ -589,28 +633,28 @@ const u = class u {
589
633
  * @returns A TimeSpan representing the given number of days.
590
634
  */
591
635
  static days(t) {
592
- return u.hours(R(t, 24));
636
+ return u.hours(C(t, 24));
593
637
  }
594
638
  };
595
639
  /** A nanosecond. */
596
- s(u, "NANOSECOND", u.nanoseconds(1)), /** A microsecond. */
597
- s(u, "MICROSECOND", u.microseconds(1)), /** A millisecond. */
598
- s(u, "MILLISECOND", u.milliseconds(1)), /** A second. */
599
- s(u, "SECOND", u.seconds(1)), /** A minute. */
600
- s(u, "MINUTE", u.minutes(1)), /** Represents an hour. */
601
- s(u, "HOUR", u.hours(1)), /** Represents a day. */
602
- s(u, "DAY", u.days(1)), /** The maximum possible value for a TimeSpan. */
603
- s(u, "MAX", new u((1n << 63n) - 1n)), /** The minimum possible value for a TimeSpan. */
604
- s(u, "MIN", new u(0)), /** The zero value for a TimeSpan. */
605
- s(u, "ZERO", new u(0)), /** A zod schema for validating and transforming timespans */
606
- s(u, "z", l.union([
640
+ r(u, "NANOSECOND", u.nanoseconds(1)), /** A microsecond. */
641
+ r(u, "MICROSECOND", u.microseconds(1)), /** A millisecond. */
642
+ r(u, "MILLISECOND", u.milliseconds(1)), /** A second. */
643
+ r(u, "SECOND", u.seconds(1)), /** A minute. */
644
+ r(u, "MINUTE", u.minutes(1)), /** Represents an hour. */
645
+ r(u, "HOUR", u.hours(1)), /** Represents a day. */
646
+ r(u, "DAY", u.days(1)), /** The maximum possible value for a TimeSpan. */
647
+ r(u, "MAX", new u((1n << 63n) - 1n)), /** The minimum possible value for a TimeSpan. */
648
+ r(u, "MIN", new u(0)), /** The zero value for a TimeSpan. */
649
+ r(u, "ZERO", new u(0)), /** A zod schema for validating and transforming timespans */
650
+ r(u, "z", l.union([
607
651
  l.object({ value: l.bigint() }).transform((t) => new u(t.value)),
608
652
  l.string().transform((t) => new u(BigInt(t))),
609
653
  l.instanceof(Number).transform((t) => new u(t)),
610
654
  l.number().transform((t) => new u(t)),
611
655
  l.instanceof(u)
612
656
  ]));
613
- let w = u;
657
+ let O = u;
614
658
  const p = class p extends Number {
615
659
  constructor(t) {
616
660
  t instanceof Number ? super(t.valueOf()) : super(t);
@@ -629,7 +673,7 @@ const p = class p extends Number {
629
673
  * @returns A TimeSpan representing the period of the Rate.
630
674
  */
631
675
  get period() {
632
- return w.seconds(1 / this.valueOf());
676
+ return O.seconds(1 / this.valueOf());
633
677
  }
634
678
  /**
635
679
  * Calculates the number of samples in the given TimeSpan at this rate.
@@ -638,7 +682,7 @@ const p = class p extends Number {
638
682
  * @returns The number of samples in the given TimeSpan at this rate.
639
683
  */
640
684
  sampleCount(t) {
641
- return new w(t).seconds * this.valueOf();
685
+ return new O(t).seconds * this.valueOf();
642
686
  }
643
687
  /**
644
688
  * Calculates the number of bytes in the given TimeSpan at this rate.
@@ -657,7 +701,7 @@ const p = class p extends Number {
657
701
  * @returns A TimeSpan that corresponds to the given number of samples.
658
702
  */
659
703
  span(t) {
660
- return w.seconds(t / this.valueOf());
704
+ return O.seconds(t / this.valueOf());
661
705
  }
662
706
  /**
663
707
  * Calculates a TimeSpan given the number of bytes at this rate.
@@ -689,13 +733,13 @@ const p = class p extends Number {
689
733
  }
690
734
  };
691
735
  /** A zod schema for validating and transforming rates */
692
- s(p, "z", l.union([
736
+ r(p, "z", l.union([
693
737
  l.number().transform((t) => new p(t)),
694
738
  l.instanceof(Number).transform((t) => new p(t)),
695
739
  l.instanceof(p)
696
740
  ]));
697
741
  let $ = p;
698
- const b = class b extends Number {
742
+ const w = class w extends Number {
699
743
  /**
700
744
  * Creates a Density representing the given number of bytes per value.
701
745
  *
@@ -710,23 +754,23 @@ const b = class b extends Number {
710
754
  return t.valueOf() / this.valueOf();
711
755
  }
712
756
  size(t) {
713
- return new C(t * this.valueOf());
757
+ return new R(t * this.valueOf());
714
758
  }
715
759
  };
716
760
  /** Unknown/Invalid Density. */
717
- s(b, "UNKNOWN", new b(0)), /** 128 bits per value. */
718
- s(b, "BIT128", new b(16)), /** 64 bits per value. */
719
- s(b, "BIT64", new b(8)), /** 32 bits per value. */
720
- s(b, "BIT32", new b(4)), /** 16 bits per value. */
721
- s(b, "BIT16", new b(2)), /** 8 bits per value. */
722
- s(b, "BIT8", new b(1)), /** A zod schema for validating and transforming densities */
723
- s(b, "z", l.union([
724
- l.number().transform((t) => new b(t)),
725
- l.instanceof(Number).transform((t) => new b(t)),
726
- l.instanceof(b)
761
+ r(w, "UNKNOWN", new w(0)), /** 128 bits per value. */
762
+ r(w, "BIT128", new w(16)), /** 64 bits per value. */
763
+ r(w, "BIT64", new w(8)), /** 32 bits per value. */
764
+ r(w, "BIT32", new w(4)), /** 16 bits per value. */
765
+ r(w, "BIT16", new w(2)), /** 8 bits per value. */
766
+ r(w, "BIT8", new w(1)), /** A zod schema for validating and transforming densities */
767
+ r(w, "z", l.union([
768
+ l.number().transform((t) => new w(t)),
769
+ l.instanceof(Number).transform((t) => new w(t)),
770
+ l.instanceof(w)
727
771
  ]));
728
- let y = b;
729
- const N = class N {
772
+ let y = w;
773
+ const I = class I {
730
774
  /**
731
775
  * Creates a TimeRange from the given start and end TimeStamps.
732
776
  *
@@ -742,7 +786,7 @@ const N = class N {
742
786
  *
743
787
  * In most cases, operations should treat start as inclusive.
744
788
  */
745
- s(this, "start");
789
+ r(this, "start");
746
790
  /**
747
791
  * The starting TimeStamp of the TimeRange.
748
792
  *
@@ -751,12 +795,12 @@ const N = class N {
751
795
  *
752
796
  * In most cases, operations should treat end as exclusive.
753
797
  */
754
- s(this, "end");
798
+ r(this, "end");
755
799
  typeof t == "object" && "start" in t ? (this.start = new m(t.start), this.end = new m(t.end)) : (this.start = new m(t), this.end = new m(e));
756
800
  }
757
801
  /** @returns The TimeSpan occupied by the TimeRange. */
758
802
  get span() {
759
- return new w(this.end.valueOf() - this.start.valueOf());
803
+ return new O(this.end.valueOf() - this.start.valueOf());
760
804
  }
761
805
  /**
762
806
  * Checks if the timestamp is valid i.e. the start is before the end.
@@ -794,7 +838,13 @@ const N = class N {
794
838
  * @returns A TimeRange with the start and end swapped.
795
839
  */
796
840
  swap() {
797
- return new N(this.end, this.start);
841
+ return new I(this.end, this.start);
842
+ }
843
+ get numericBounds() {
844
+ return {
845
+ lower: Number(this.start.valueOf()),
846
+ upper: Number(this.end.valueOf())
847
+ };
798
848
  }
799
849
  /**
800
850
  * Checks if the TimeRange is equal to the given TimeRange.
@@ -802,8 +852,11 @@ const N = class N {
802
852
  * @param other - The TimeRange to compare to.
803
853
  * @returns True if the TimeRange is equal to the given TimeRange.
804
854
  */
805
- equals(t) {
806
- return this.start.equals(t.start) && this.end.equals(t.end);
855
+ equals(t, e = O.ZERO) {
856
+ if (e.isZero)
857
+ return this.start.equals(t.start) && this.end.equals(t.end);
858
+ let s = this.start.sub(t.start).valueOf(), i = this.end.sub(t.end).valueOf();
859
+ return s < 0 && (s = -s), i < 0 && (i = -i), s <= e.valueOf() && i <= e.valueOf();
807
860
  }
808
861
  toString() {
809
862
  return `${this.start.toString()} - ${this.end.toString()}`;
@@ -812,54 +865,64 @@ const N = class N {
812
865
  return `${this.start.fString("preciseDate")} - ${this.span.toString()}`;
813
866
  }
814
867
  /**
815
- * Checks if if the two time ranges overlap. If the two time ranges are equal, returns
816
- * true. If the start of one range is equal to the end of the other, returns false.
817
- * Just follow the rule [start, end) i.e. start is inclusive and end is exclusive.
868
+ * Checks if the two time ranges overlap. If the two time ranges are equal, returns
869
+ * true. If the start of one range is equal to the end of the other, it returns false.
870
+ * Just follow the rule [start, end), i.e., start is inclusive, and the end is exclusive.
818
871
  *
819
872
  * @param other - The other TimeRange to compare to.
873
+ * @param delta - A TimeSpan representing the minimum amount of overlap for
874
+ * overlap to return true. This allows for a slight amount of leeway when
875
+ * checking for overlap.
820
876
  * @returns True if the two TimeRanges overlap, false otherwise.
821
877
  */
822
- overlapsWith(t, e = w.ZERO) {
878
+ overlapsWith(t, e = O.ZERO) {
823
879
  t = t.makeValid();
824
- const r = this.makeValid();
880
+ const s = this.makeValid();
825
881
  if (this.equals(t)) return !0;
826
- if (t.end.equals(r.start) || r.end.equals(t.start)) return !1;
827
- const a = m.max(r.start, t.start), c = m.min(r.end, t.end);
828
- return c.before(a) ? !1 : new w(c.sub(a)).greaterThanOrEqual(e);
829
- }
830
- roughlyEquals(t, e) {
831
- let r = this.start.sub(t.start).valueOf(), a = this.end.sub(t.end).valueOf();
832
- return r < 0 && (r = -r), a < 0 && (a = -a), r <= e.valueOf() && a <= e.valueOf();
882
+ if (t.end.equals(s.start) || s.end.equals(t.start)) return !1;
883
+ const i = m.max(s.start, t.start), h = m.min(s.end, t.end);
884
+ return h.before(i) ? !1 : new O(h.sub(i)).greaterThanOrEqual(e);
833
885
  }
834
886
  contains(t) {
835
- return t instanceof N ? this.contains(t.start) && this.contains(t.end) : this.start.beforeEq(t) && this.end.after(t);
887
+ return t instanceof I ? this.contains(t.start) && this.contains(t.end) : this.start.beforeEq(t) && this.end.after(t);
836
888
  }
837
889
  boundBy(t) {
838
- const e = new N(this.start, this.end);
890
+ const e = new I(this.start, this.end);
839
891
  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;
840
892
  }
893
+ static max(...t) {
894
+ return new I(
895
+ m.min(...t.map((e) => e.start)),
896
+ m.max(...t.map((e) => e.end))
897
+ );
898
+ }
841
899
  };
842
900
  /** The maximum possible time range. */
843
- s(N, "MAX", new N(m.MIN, m.MAX)), /** The minimum possible time range. */
844
- s(N, "MIN", new N(m.MAX, m.MIN)), /** A zero time range. */
845
- s(N, "ZERO", new N(m.ZERO, m.ZERO)), /** A zod schema for validating and transforming time ranges */
846
- s(N, "z", l.union([
847
- l.object({ start: m.z, end: m.z }).transform((t) => new N(t.start, t.end)),
848
- l.instanceof(N)
901
+ r(I, "MAX", new I(m.MIN, m.MAX)), /** The minimum possible time range. */
902
+ r(I, "MIN", new I(m.MAX, m.MIN)), /** A time range whose start and end are both zero. */
903
+ r(I, "ZERO", new I(m.ZERO, m.ZERO)), /** A zod schema for validating and transforming time ranges */
904
+ r(I, "z", l.union([
905
+ l.object({ start: m.z, end: m.z }).transform((t) => new I(t.start, t.end)),
906
+ l.instanceof(I)
849
907
  ]));
850
- let U = N;
851
- const xt = (o, t) => o.start.before(t.start) ? -1 : o.start.after(t.start) ? 1 : o.end.before(t.end) ? -1 : o.end.after(t.end) ? 1 : 0, n = class n extends String {
908
+ let A = I;
909
+ const Dt = (o, t) => o.start.before(t.start) ? -1 : o.start.after(t.start) ? 1 : o.end.before(t.end) ? -1 : o.end.after(t.end) ? 1 : 0, n = class n {
852
910
  constructor(t) {
911
+ r(this, "value");
912
+ r(this, "encodeValue", !0);
853
913
  if (t instanceof n || typeof t == "string" || typeof t.valueOf() == "string") {
854
- super(t.valueOf());
914
+ this.value = t.valueOf();
855
915
  return;
856
916
  }
857
917
  const e = n.ARRAY_CONSTRUCTOR_DATA_TYPES.get(t.constructor.name);
858
918
  if (e != null) {
859
- super(e.valueOf());
919
+ this.value = e.valueOf();
860
920
  return;
861
921
  }
862
- throw super(n.UNKNOWN.valueOf()), new Error(`unable to find data type for ${t.toString()}`);
922
+ throw this.value = n.UNKNOWN.valueOf(), new Error(`unable to find data type for ${t.toString()}`);
923
+ }
924
+ valueOf() {
925
+ return this.value;
863
926
  }
864
927
  /**
865
928
  * @returns the TypedArray constructor for the DataType.
@@ -904,9 +967,11 @@ const xt = (o, t) => o.start.before(t.start) ? -1 : o.start.after(t.start) ? 1 :
904
967
  if (t == null) throw new Error(`unable to find density for ${this.valueOf()}`);
905
968
  return t;
906
969
  }
970
+ /** @returns ture if the data type is an unsigned numeric integer type */
907
971
  get isUnsigned() {
908
972
  return this.equals(n.UINT8) || this.equals(n.UINT16) || this.equals(n.UINT32) || this.equals(n.UINT64);
909
973
  }
974
+ /** @returns true if the data type is a signed numeric integer type */
910
975
  get isSigned() {
911
976
  return this.equals(n.INT8) || this.equals(n.INT16) || this.equals(n.INT32) || this.equals(n.INT64);
912
977
  }
@@ -918,15 +983,6 @@ const xt = (o, t) => o.start.before(t.start) ? -1 : o.start.after(t.start) ? 1 :
918
983
  canCastTo(t) {
919
984
  return this.isNumeric && t.isNumeric ? !0 : this.equals(t);
920
985
  }
921
- /**
922
- * Checks whether the given TypedArray is of the same type as the DataType.
923
- *
924
- * @param array - The TypedArray to check.
925
- * @returns True if the TypedArray is of the same type as the DataType.
926
- */
927
- checkArray(t) {
928
- return t.constructor === this.Array;
929
- }
930
986
  toJSON() {
931
987
  return this.toString();
932
988
  }
@@ -935,24 +991,24 @@ const xt = (o, t) => o.start.before(t.start) ? -1 : o.start.after(t.start) ? 1 :
935
991
  }
936
992
  };
937
993
  /** Represents an Unknown/Invalid DataType. */
938
- s(n, "UNKNOWN", new n("unknown")), /** Represents a 64-bit floating point value. */
939
- s(n, "FLOAT64", new n("float64")), /** Represents a 32-bit floating point value. */
940
- s(n, "FLOAT32", new n("float32")), /** Represents a 64-bit signed integer value. */
941
- s(n, "INT64", new n("int64")), /** Represents a 32-bit signed integer value. */
942
- s(n, "INT32", new n("int32")), /** Represents a 16-bit signed integer value. */
943
- s(n, "INT16", new n("int16")), /** Represents a 8-bit signed integer value. */
944
- s(n, "INT8", new n("int8")), /** Represents a 64-bit unsigned integer value. */
945
- s(n, "UINT64", new n("uint64")), /** Represents a 32-bit unsigned integer value. */
946
- s(n, "UINT32", new n("uint32")), /** Represents a 16-bit unsigned integer value. */
947
- s(n, "UINT16", new n("uint16")), /** Represents a 8-bit unsigned integer value. */
948
- s(n, "UINT8", new n("uint8")), /** Represents a boolean value. Alias for UINT8. */
949
- s(n, "BOOLEAN", n.UINT8), /** Represents a 64-bit unix epoch. */
950
- s(n, "TIMESTAMP", new n("timestamp")), /** Represents a UUID data type */
951
- s(n, "UUID", new n("uuid")), /** Represents a string data type. Strings have an unknown density, and are separate
994
+ r(n, "UNKNOWN", new n("unknown")), /** Represents a 64-bit floating point value. */
995
+ r(n, "FLOAT64", new n("float64")), /** Represents a 32-bit floating point value. */
996
+ r(n, "FLOAT32", new n("float32")), /** Represents a 64-bit signed integer value. */
997
+ r(n, "INT64", new n("int64")), /** Represents a 32-bit signed integer value. */
998
+ r(n, "INT32", new n("int32")), /** Represents a 16-bit signed integer value. */
999
+ r(n, "INT16", new n("int16")), /** Represents a 8-bit signed integer value. */
1000
+ r(n, "INT8", new n("int8")), /** Represents a 64-bit unsigned integer value. */
1001
+ r(n, "UINT64", new n("uint64")), /** Represents a 32-bit unsigned integer value. */
1002
+ r(n, "UINT32", new n("uint32")), /** Represents a 16-bit unsigned integer value. */
1003
+ r(n, "UINT16", new n("uint16")), /** Represents a 8-bit unsigned integer value. */
1004
+ r(n, "UINT8", new n("uint8")), /** Represents a boolean value. Alias for UINT8. */
1005
+ r(n, "BOOLEAN", n.UINT8), /** Represents a 64-bit unix epoch. */
1006
+ r(n, "TIMESTAMP", new n("timestamp")), /** Represents a UUID data type */
1007
+ r(n, "UUID", new n("uuid")), /** Represents a string data type. Strings have an unknown density, and are separate
952
1008
  * by a newline character. */
953
- s(n, "STRING", new n("string")), /** Represents a JSON data type. JSON has an unknown density, and is separated by a
1009
+ r(n, "STRING", new n("string")), /** Represents a JSON data type. JSON has an unknown density, and is separated by a
954
1010
  * newline character. */
955
- s(n, "JSON", new n("json")), s(n, "ARRAY_CONSTRUCTORS", /* @__PURE__ */ new Map([
1011
+ r(n, "JSON", new n("json")), r(n, "ARRAY_CONSTRUCTORS", /* @__PURE__ */ new Map([
956
1012
  [n.UINT8.toString(), Uint8Array],
957
1013
  [n.UINT16.toString(), Uint16Array],
958
1014
  [n.UINT32.toString(), Uint32Array],
@@ -967,7 +1023,7 @@ s(n, "JSON", new n("json")), s(n, "ARRAY_CONSTRUCTORS", /* @__PURE__ */ new Map(
967
1023
  [n.STRING.toString(), Uint8Array],
968
1024
  [n.JSON.toString(), Uint8Array],
969
1025
  [n.UUID.toString(), Uint8Array]
970
- ])), s(n, "ARRAY_CONSTRUCTOR_DATA_TYPES", /* @__PURE__ */ new Map([
1026
+ ])), r(n, "ARRAY_CONSTRUCTOR_DATA_TYPES", /* @__PURE__ */ new Map([
971
1027
  [Uint8Array.name, n.UINT8],
972
1028
  [Uint16Array.name, n.UINT16],
973
1029
  [Uint32Array.name, n.UINT32],
@@ -978,7 +1034,7 @@ s(n, "JSON", new n("json")), s(n, "ARRAY_CONSTRUCTORS", /* @__PURE__ */ new Map(
978
1034
  [Int16Array.name, n.INT16],
979
1035
  [Int32Array.name, n.INT32],
980
1036
  [BigInt64Array.name, n.INT64]
981
- ])), s(n, "DENSITIES", /* @__PURE__ */ new Map([
1037
+ ])), r(n, "DENSITIES", /* @__PURE__ */ new Map([
982
1038
  [n.UINT8.toString(), y.BIT8],
983
1039
  [n.UINT16.toString(), y.BIT16],
984
1040
  [n.UINT32.toString(), y.BIT32],
@@ -994,7 +1050,7 @@ s(n, "JSON", new n("json")), s(n, "ARRAY_CONSTRUCTORS", /* @__PURE__ */ new Map(
994
1050
  [n.JSON.toString(), y.UNKNOWN],
995
1051
  [n.UUID.toString(), y.BIT128]
996
1052
  ])), /** All the data types. */
997
- s(n, "ALL", [
1053
+ r(n, "ALL", [
998
1054
  n.UNKNOWN,
999
1055
  n.FLOAT64,
1000
1056
  n.FLOAT32,
@@ -1010,8 +1066,8 @@ s(n, "ALL", [
1010
1066
  n.UUID,
1011
1067
  n.STRING,
1012
1068
  n.JSON
1013
- ]), s(n, "BIG_INT_TYPES", [n.INT64, n.UINT64, n.TIMESTAMP]), /** A zod schema for a DataType. */
1014
- s(n, "z", l.union([
1069
+ ]), r(n, "BIG_INT_TYPES", [n.INT64, n.UINT64, n.TIMESTAMP]), /** A zod schema for a DataType. */
1070
+ r(n, "z", l.union([
1015
1071
  l.string().transform((t) => new n(t)),
1016
1072
  l.instanceof(n)
1017
1073
  ]));
@@ -1024,7 +1080,7 @@ const d = class d extends Number {
1024
1080
  largerThan(t) {
1025
1081
  return this.valueOf() > t.valueOf();
1026
1082
  }
1027
- /** @returns true if the Size is smaller than the other sisze. */
1083
+ /** @returns true if the Size is smaller than the other size. */
1028
1084
  smallerThan(t) {
1029
1085
  return this.valueOf() < t.valueOf();
1030
1086
  }
@@ -1053,9 +1109,9 @@ const d = class d extends Number {
1053
1109
  return this.valueOf() / d.TERABYTE.valueOf();
1054
1110
  }
1055
1111
  toString() {
1056
- const t = this.truncate(d.TERABYTE), e = this.truncate(d.GIGABYTE), r = this.truncate(d.MEGABYTE), a = this.truncate(d.KILOBYTE), c = this.truncate(d.BYTE), h = t, v = e.sub(t), O = r.sub(e), T = a.sub(r), A = c.sub(a);
1112
+ const t = this.truncate(d.TERABYTE), e = this.truncate(d.GIGABYTE), s = this.truncate(d.MEGABYTE), i = this.truncate(d.KILOBYTE), h = this.truncate(d.BYTE), c = t, v = e.sub(t), b = s.sub(e), N = i.sub(s), B = h.sub(i);
1057
1113
  let f = "";
1058
- return h.isZero || (f += `${h.terabytes}TB `), v.isZero || (f += `${v.gigabytes}GB `), O.isZero || (f += `${O.megabytes}MB `), T.isZero || (f += `${T.kilobytes}KB `), (!A.isZero || f === "") && (f += `${A.valueOf()}B`), f.trim();
1114
+ return c.isZero || (f += `${c.terabytes}TB `), v.isZero || (f += `${v.gigabytes}GB `), b.isZero || (f += `${b.megabytes}MB `), N.isZero || (f += `${N.kilobytes}KB `), (!B.isZero || f === "") && (f += `${B.valueOf()}B`), f.trim();
1059
1115
  }
1060
1116
  /**
1061
1117
  * Creates a Size from the given number of bytes.
@@ -1107,18 +1163,18 @@ const d = class d extends Number {
1107
1163
  }
1108
1164
  };
1109
1165
  /** A single byte */
1110
- s(d, "BYTE", new d(1)), /** A kilobyte */
1111
- s(d, "KILOBYTE", d.kilobytes(1)), /** A megabyte */
1112
- s(d, "MEGABYTE", d.megabytes(1)), /** A gigabyte */
1113
- s(d, "GIGABYTE", d.gigabytes(1)), /** A terabyte. */
1114
- s(d, "TERABYTE", d.terabytes(1)), /** The zero value for Size */
1115
- s(d, "ZERO", new d(0)), /** A zod schema for a Size. */
1116
- s(d, "z", l.union([
1166
+ r(d, "BYTE", new d(1)), /** A kilobyte */
1167
+ r(d, "KILOBYTE", d.kilobytes(1)), /** A megabyte */
1168
+ r(d, "MEGABYTE", d.megabytes(1)), /** A gigabyte */
1169
+ r(d, "GIGABYTE", d.gigabytes(1)), /** A terabyte. */
1170
+ r(d, "TERABYTE", d.terabytes(1)), /** The zero value for Size */
1171
+ r(d, "ZERO", new d(0)), /** A zod schema for a Size. */
1172
+ r(d, "z", l.union([
1117
1173
  l.number().transform((t) => new d(t)),
1118
1174
  l.instanceof(d)
1119
1175
  ]));
1120
- let C = d;
1121
- const Lt = l.union([
1176
+ let R = d;
1177
+ const qt = l.union([
1122
1178
  l.instanceof(Uint8Array),
1123
1179
  l.instanceof(Uint16Array),
1124
1180
  l.instanceof(Uint32Array),
@@ -1129,84 +1185,84 @@ const Lt = l.union([
1129
1185
  l.instanceof(Int16Array),
1130
1186
  l.instanceof(Int32Array),
1131
1187
  l.instanceof(BigInt64Array)
1132
- ]), tt = (o) => {
1188
+ ]), st = (o) => {
1133
1189
  const t = typeof o;
1134
- return t === "string" || t === "number" || t === "boolean" || t === "bigint" || o instanceof m || o instanceof w || o instanceof Date;
1135
- }, ht = (o, t, e, r = 0) => o.usesBigInt && !t.usesBigInt ? Number(e) - Number(r) : !o.usesBigInt && t.usesBigInt ? BigInt(e.valueOf()) - BigInt(r.valueOf()) : x(e, -r).valueOf(), x = (o, t) => typeof o == "bigint" && typeof t == "bigint" || typeof o == "number" && typeof t == "number" ? o + t : t === 0 ? o : o === 0 ? t : Number(o) + Number(t), dt = (o) => o == null ? !1 : Array.isArray(o) || o instanceof ArrayBuffer || ArrayBuffer.isView(o) && !(o instanceof DataView) || o instanceof k ? !0 : tt(o), M = -1, F = {
1136
- [Symbol.iterator]: () => F,
1190
+ return t === "string" || t === "number" || t === "boolean" || t === "bigint" || o instanceof m || o instanceof O || o instanceof Date;
1191
+ }, mt = (o, t, e, s = 0) => o.usesBigInt && !t.usesBigInt ? Number(e) - Number(s) : !o.usesBigInt && t.usesBigInt ? BigInt(e.valueOf()) - BigInt(s.valueOf()) : x(e, -s).valueOf(), x = (o, t) => t == 0 ? o : o == 0 ? t : typeof o == "bigint" && typeof t == "bigint" || typeof o == "number" && typeof t == "number" ? o + t : Number(o) + Number(t), Ot = (o) => o == null ? !1 : Array.isArray(o) || o instanceof ArrayBuffer || ArrayBuffer.isView(o) && !(o instanceof DataView) || o instanceof k ? !0 : st(o), M = -1, Y = {
1192
+ [Symbol.iterator]: () => Y,
1137
1193
  next: () => ({ done: !0, value: void 0 })
1138
- }, gt = l.string().transform(
1194
+ }, bt = l.string().transform(
1139
1195
  (o) => new Uint8Array(
1140
1196
  atob(o).split("").map((t) => t.charCodeAt(0))
1141
1197
  ).buffer
1142
- ), mt = l.union([l.null(), l.undefined()]).transform(() => new Uint8Array().buffer), Y = 10, et = (o, t) => {
1198
+ ), wt = l.union([l.null(), l.undefined()]).transform(() => new Uint8Array().buffer), Z = 10, nt = (o, t) => {
1143
1199
  if (o === "string" && !t.isVariable)
1144
1200
  throw new Error(`cannot convert series of type ${t.toString()} to string`);
1145
1201
  if (o === "number" && !t.isNumeric)
1146
1202
  throw new Error(`cannot convert series of type ${t.toString()} to number`);
1147
1203
  if (o === "bigint" && !t.usesBigInt)
1148
1204
  throw new Error(`cannot convert series of type ${t.toString()} to bigint`);
1149
- }, I = class I {
1205
+ }, T = class T {
1150
1206
  constructor(t) {
1151
- s(this, "key", "");
1152
- s(this, "isSynnaxSeries", !0);
1207
+ r(this, "key", "");
1208
+ r(this, "isSynnaxSeries", !0);
1153
1209
  /** The data type of the array */
1154
- s(this, "dataType");
1210
+ r(this, "dataType");
1155
1211
  /**
1156
1212
  * A sample offset that can be used to shift the values of all samples upwards or
1157
1213
  * downwards. Typically used to convert arrays to lower precision while preserving
1158
1214
  * the relative range of actual values.
1159
1215
  */
1160
- s(this, "sampleOffset");
1216
+ r(this, "sampleOffset");
1161
1217
  /**
1162
1218
  * Stores information about the buffer state of this array into a WebGL buffer.
1163
1219
  */
1164
- s(this, "gl");
1220
+ r(this, "gl");
1165
1221
  /** The underlying data. */
1166
- s(this, "_data");
1167
- s(this, "_timeRange");
1168
- s(this, "alignment", 0n);
1222
+ r(this, "_data");
1223
+ r(this, "timeRange", A.ZERO);
1224
+ r(this, "alignment", 0n);
1169
1225
  /** A cached minimum value. */
1170
- s(this, "_cachedMin");
1226
+ r(this, "_cachedMin");
1171
1227
  /** A cached maximum value. */
1172
- s(this, "_cachedMax");
1228
+ r(this, "_cachedMax");
1173
1229
  /** The write position of the buffer. */
1174
- s(this, "writePos", M);
1230
+ r(this, "writePos", M);
1175
1231
  /** Tracks the number of entities currently using this array. */
1176
- s(this, "_refCount", 0);
1232
+ r(this, "_refCount", 0);
1177
1233
  /** Caches the length of the array for variable length data types. */
1178
- s(this, "_cachedLength");
1234
+ r(this, "_cachedLength");
1179
1235
  /** Caches the indexes of the array for variable length data types. */
1180
- s(this, "_cachedIndexes");
1181
- dt(t) && (t = { data: t });
1236
+ r(this, "_cachedIndexes");
1237
+ Ot(t) && (t = { data: t });
1182
1238
  const {
1183
1239
  dataType: e,
1184
- timeRange: r,
1185
- sampleOffset: a = 0,
1186
- glBufferUsage: c = "static",
1187
- alignment: h = 0n,
1188
- key: v = Q()
1189
- } = t, O = t.data ?? [];
1190
- if (O instanceof I || typeof O == "object" && "isSynnaxSeries" in O && O.isSynnaxSeries === !0) {
1191
- const f = O;
1192
- this.key = f.key, this.dataType = f.dataType, this.sampleOffset = f.sampleOffset, this.gl = f.gl, this._data = f._data, this._timeRange = f._timeRange, this.alignment = f.alignment, this._cachedMin = f._cachedMin, this._cachedMax = f._cachedMax, this.writePos = f.writePos, this._refCount = f._refCount, this._cachedLength = f._cachedLength;
1240
+ timeRange: s,
1241
+ sampleOffset: i = 0,
1242
+ glBufferUsage: h = "static",
1243
+ alignment: c = 0n,
1244
+ key: v = tt()
1245
+ } = t, b = t.data ?? [];
1246
+ if (b instanceof T || typeof b == "object" && "isSynnaxSeries" in b && b.isSynnaxSeries === !0) {
1247
+ const f = b;
1248
+ this.key = f.key, this.dataType = f.dataType, this.sampleOffset = f.sampleOffset, this.gl = f.gl, this._data = f._data, this.timeRange = f.timeRange, this.alignment = f.alignment, this._cachedMin = f._cachedMin, this._cachedMax = f._cachedMax, this.writePos = f.writePos, this._refCount = f._refCount, this._cachedLength = f._cachedLength;
1193
1249
  return;
1194
1250
  }
1195
- const T = tt(O), A = Array.isArray(O);
1251
+ const N = st(b), B = Array.isArray(b);
1196
1252
  if (e != null) this.dataType = new g(e);
1197
1253
  else {
1198
- if (O instanceof ArrayBuffer)
1254
+ if (b instanceof ArrayBuffer)
1199
1255
  throw new Error(
1200
1256
  "cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type."
1201
1257
  );
1202
- if (A || T) {
1203
- let f = O;
1204
- if (!T) {
1205
- if (O.length === 0)
1258
+ if (B || N) {
1259
+ let f = b;
1260
+ if (!N) {
1261
+ if (b.length === 0)
1206
1262
  throw new Error(
1207
1263
  "cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type."
1208
1264
  );
1209
- f = O[0];
1265
+ f = b[0];
1210
1266
  }
1211
1267
  if (typeof f == "string") this.dataType = g.STRING;
1212
1268
  else if (typeof f == "number") this.dataType = g.FLOAT64;
@@ -1219,74 +1275,75 @@ const Lt = l.union([
1219
1275
  throw new Error(
1220
1276
  `cannot infer data type of ${typeof f} when constructing a Series from a JS array`
1221
1277
  );
1222
- } else this.dataType = new g(O);
1278
+ } else this.dataType = new g(b);
1223
1279
  }
1224
- if (!A && !T) this._data = O;
1280
+ if (!B && !N) this._data = b;
1225
1281
  else {
1226
- let f = T ? [O] : O;
1227
- const B = f[0];
1228
- (B instanceof m || B instanceof Date || B instanceof w) && (f = f.map((S) => new m(S).valueOf())), this.dataType.equals(g.STRING) ? (this._cachedLength = f.length, this._data = new TextEncoder().encode(`${f.join(`
1282
+ let f = N ? [b] : b;
1283
+ const U = f[0];
1284
+ (U instanceof m || U instanceof Date || U instanceof O) && (f = f.map((S) => new m(S).valueOf())), this.dataType.equals(g.STRING) ? (this._cachedLength = f.length, this._data = new TextEncoder().encode(`${f.join(`
1229
1285
  `)}
1230
1286
  `).buffer) : this.dataType.equals(g.JSON) ? (this._cachedLength = f.length, this._data = new TextEncoder().encode(
1231
1287
  `${f.map((S) => q.encodeString(S)).join(`
1232
1288
  `)}
1233
1289
  `
1234
- ).buffer) : this.dataType.usesBigInt && typeof B == "number" ? this._data = new this.dataType.Array(
1290
+ ).buffer) : this.dataType.usesBigInt && typeof U == "number" ? this._data = new this.dataType.Array(
1235
1291
  f.map((S) => BigInt(Math.round(S)))
1236
- ).buffer : !this.dataType.usesBigInt && typeof B == "bigint" ? this._data = new this.dataType.Array(
1292
+ ).buffer : !this.dataType.usesBigInt && typeof U == "bigint" ? this._data = new this.dataType.Array(
1237
1293
  f.map((S) => Number(S))
1238
1294
  ).buffer : this._data = new this.dataType.Array(f).buffer;
1239
1295
  }
1240
- this.key = v, this.alignment = h, this.sampleOffset = a ?? 0, this._timeRange = r, this.gl = {
1296
+ this.key = v, this.alignment = c, this.sampleOffset = i ?? 0, this.timeRange = s ?? A.ZERO, this.gl = {
1241
1297
  control: null,
1242
1298
  buffer: null,
1243
1299
  prevBuffer: 0,
1244
- bufferUsage: c
1300
+ bufferUsage: h
1245
1301
  };
1246
1302
  }
1247
- static alloc({ capacity: t, dataType: e, ...r }) {
1303
+ static alloc({ capacity: t, dataType: e, ...s }) {
1248
1304
  if (t === 0)
1249
1305
  throw new Error("[Series] - cannot allocate an array of length 0");
1250
- const a = new new g(e).Array(t), c = new I({
1251
- data: a.buffer,
1306
+ const i = new new g(e).Array(t), h = new T({
1307
+ data: i.buffer,
1252
1308
  dataType: e,
1253
- ...r
1309
+ ...s
1254
1310
  });
1255
- return c.writePos = 0, c;
1311
+ return h.writePos = 0, h;
1256
1312
  }
1257
- static createTimestamps(t, e, r) {
1258
- const a = r.spanRange(e.span(t)), c = new BigInt64Array(t);
1259
- for (let h = 0; h < t; h++)
1260
- c[h] = BigInt(r.add(e.span(h)).valueOf());
1261
- return new I({ data: c, dataType: g.TIMESTAMP, timeRange: a });
1313
+ static createTimestamps(t, e, s) {
1314
+ const i = s.spanRange(e.span(t)), h = new BigInt64Array(t);
1315
+ for (let c = 0; c < t; c++)
1316
+ h[c] = BigInt(s.add(e.span(c)).valueOf());
1317
+ return new T({ data: h, dataType: g.TIMESTAMP, timeRange: i });
1262
1318
  }
1263
1319
  get refCount() {
1264
1320
  return this._refCount;
1265
1321
  }
1266
1322
  static fromStrings(t, e) {
1267
- const r = new TextEncoder().encode(
1323
+ const s = new TextEncoder().encode(
1268
1324
  `${t.join(`
1269
1325
  `)}
1270
1326
  `
1271
1327
  );
1272
- return new I({ data: r, dataType: g.STRING, timeRange: e });
1328
+ return new T({ data: s, dataType: g.STRING, timeRange: e });
1273
1329
  }
1274
1330
  static fromJSON(t, e) {
1275
- const r = new TextEncoder().encode(
1276
- `${t.map((a) => q.encodeString(a)).join(`
1331
+ const s = new TextEncoder().encode(
1332
+ `${t.map((i) => q.encodeString(i)).join(`
1277
1333
  `)}
1278
1334
  `
1279
1335
  );
1280
- return new I({ data: r, dataType: g.JSON, timeRange: e });
1336
+ return new T({ data: s, dataType: g.JSON, timeRange: e });
1281
1337
  }
1282
1338
  acquire(t) {
1283
1339
  this._refCount++, t != null && this.updateGLBuffer(t);
1284
1340
  }
1285
1341
  release() {
1286
- if (this._refCount--, this._refCount === 0 && this.gl.control != null)
1287
- this.maybeGarbageCollectGLBuffer(this.gl.control);
1288
- else if (this._refCount < 0)
1289
- throw new Error("cannot release an array with a negative reference count");
1342
+ if (this._refCount <= 0) {
1343
+ console.warn("attempted to release a series with a negative reference count");
1344
+ return;
1345
+ }
1346
+ this._refCount--, this._refCount === 0 && this.gl.control != null && this.maybeGarbageCollectGLBuffer(this.gl.control);
1290
1347
  }
1291
1348
  /**
1292
1349
  * Writes the given series to this series. If the series being written exceeds the
@@ -1303,13 +1360,13 @@ const Lt = l.union([
1303
1360
  }
1304
1361
  writeVariable(t) {
1305
1362
  if (this.writePos === M) return 0;
1306
- const e = this.byteCapacity.valueOf() - this.writePos, r = t.subBytes(0, e);
1307
- return this.writeToUnderlyingData(r), this.writePos += r.byteLength.valueOf(), this._cachedLength != null && (this._cachedLength += r.length, this.calculateCachedLength()), r.length;
1363
+ const e = this.byteCapacity.valueOf() - this.writePos, s = t.subBytes(0, e);
1364
+ return this.writeToUnderlyingData(s), this.writePos += s.byteLength.valueOf(), this._cachedLength != null && (this._cachedLength += s.length, this.calculateCachedLength()), s.length;
1308
1365
  }
1309
1366
  writeFixed(t) {
1310
1367
  if (this.writePos === M) return 0;
1311
- const e = this.capacity - this.writePos, r = t.sub(0, e);
1312
- return this.writeToUnderlyingData(r), this._cachedLength = void 0, this.maybeRecomputeMinMax(r), this.writePos += r.length, r.length;
1368
+ const e = this.capacity - this.writePos, s = t.sub(0, e);
1369
+ return this.writeToUnderlyingData(s), this._cachedLength = void 0, this.maybeRecomputeMinMax(s), this.writePos += s.length, s.length;
1313
1370
  }
1314
1371
  writeToUnderlyingData(t) {
1315
1372
  this.underlyingData.set(
@@ -1338,12 +1395,12 @@ const Lt = l.union([
1338
1395
  if (!this.dataType.equals(g.UUID))
1339
1396
  throw new Error("cannot convert non-uuid series to uuids");
1340
1397
  const t = g.UUID.density.valueOf(), e = Array(this.length);
1341
- for (let r = 0; r < this.length; r++) {
1342
- const a = this.underlyingData.slice(r * t, (r + 1) * t), c = Array.from(
1343
- new Uint8Array(a.buffer),
1344
- (h) => h.toString(16).padStart(2, "0")
1398
+ for (let s = 0; s < this.length; s++) {
1399
+ const i = this.underlyingData.slice(s * t, (s + 1) * t), h = Array.from(
1400
+ new Uint8Array(i.buffer),
1401
+ (c) => c.toString(16).padStart(2, "0")
1345
1402
  ).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/, "$1-$2-$3-$4-$5");
1346
- e[r] = c;
1403
+ e[s] = h;
1347
1404
  }
1348
1405
  return e;
1349
1406
  }
@@ -1353,14 +1410,9 @@ const Lt = l.union([
1353
1410
  return new TextDecoder().decode(this.underlyingData).split(`
1354
1411
  `).slice(0, -1).map((e) => t.parse(q.decodeString(e)));
1355
1412
  }
1356
- /** @returns the time range of this array. */
1357
- get timeRange() {
1358
- if (this._timeRange == null) throw new Error("time range not set on series");
1359
- return this._timeRange;
1360
- }
1361
1413
  /** @returns the capacity of the series in bytes. */
1362
1414
  get byteCapacity() {
1363
- return new C(this.underlyingData.byteLength);
1415
+ return new R(this.underlyingData.byteLength);
1364
1416
  }
1365
1417
  /** @returns the capacity of the series in samples. */
1366
1418
  get capacity() {
@@ -1368,7 +1420,7 @@ const Lt = l.union([
1368
1420
  }
1369
1421
  /** @returns the length of the series in bytes. */
1370
1422
  get byteLength() {
1371
- return this.writePos === M ? this.byteCapacity : this.dataType.isVariable ? new C(this.writePos) : this.dataType.density.size(this.writePos);
1423
+ return this.writePos === M ? this.byteCapacity : this.dataType.isVariable ? new R(this.writePos) : this.dataType.density.size(this.writePos);
1372
1424
  }
1373
1425
  /** @returns the number of samples in this array. */
1374
1426
  get length() {
@@ -1379,8 +1431,8 @@ const Lt = l.union([
1379
1431
  throw new Error("cannot calculate length of a non-variable length data type");
1380
1432
  let t = 0;
1381
1433
  const e = [0];
1382
- return this.data.forEach((r, a) => {
1383
- r === Y && (t++, e.push(a + 1));
1434
+ return this.data.forEach((s, i) => {
1435
+ s === Z && (t++, e.push(i + 1));
1384
1436
  }), this._cachedIndexes = e, this._cachedLength = t, t;
1385
1437
  }
1386
1438
  /**
@@ -1394,13 +1446,13 @@ const Lt = l.union([
1394
1446
  */
1395
1447
  convert(t, e = 0) {
1396
1448
  if (this.dataType.equals(t)) return this;
1397
- const r = new t.Array(this.length);
1398
- for (let a = 0; a < this.length; a++)
1399
- r[a] = ht(this.dataType, t, this.data[a], e);
1400
- return new I({
1401
- data: r.buffer,
1449
+ const s = new t.Array(this.length);
1450
+ for (let i = 0; i < this.length; i++)
1451
+ s[i] = mt(this.dataType, t, this.data[i], e);
1452
+ return new T({
1453
+ data: s.buffer,
1402
1454
  dataType: t,
1403
- timeRange: this._timeRange,
1455
+ timeRange: this.timeRange,
1404
1456
  sampleOffset: e,
1405
1457
  glBufferUsage: this.gl.bufferUsage,
1406
1458
  alignment: this.alignment
@@ -1412,10 +1464,10 @@ const Lt = l.union([
1412
1464
  this._cachedMax = this.data[this.data.length - 1];
1413
1465
  else if (this.dataType.usesBigInt) {
1414
1466
  const t = this.data;
1415
- this._cachedMax = t.reduce((e, r) => e > r ? e : r);
1467
+ this._cachedMax = t.reduce((e, s) => e > s ? e : s);
1416
1468
  } else {
1417
1469
  const t = this.data;
1418
- this._cachedMax = t.reduce((e, r) => e > r ? e : r);
1470
+ this._cachedMax = t.reduce((e, s) => e > s ? e : s);
1419
1471
  }
1420
1472
  return this._cachedMax;
1421
1473
  }
@@ -1430,10 +1482,10 @@ const Lt = l.union([
1430
1482
  if (this.dataType.equals(g.TIMESTAMP)) this._cachedMin = this.data[0];
1431
1483
  else if (this.dataType.usesBigInt) {
1432
1484
  const t = this.data;
1433
- this._cachedMin = t.reduce((e, r) => e < r ? e : r);
1485
+ this._cachedMin = t.reduce((e, s) => e < s ? e : s);
1434
1486
  } else {
1435
1487
  const t = this.data;
1436
- this._cachedMin = t.reduce((e, r) => e < r ? e : r);
1488
+ this._cachedMin = t.reduce((e, s) => e < s ? e : s);
1437
1489
  }
1438
1490
  return this._cachedMin;
1439
1491
  }
@@ -1464,44 +1516,44 @@ const Lt = l.union([
1464
1516
  return x(this.max, -this.min);
1465
1517
  }
1466
1518
  atAlignment(t, e) {
1467
- const r = Number(t - this.alignment);
1468
- if (r < 0 || r >= this.length) {
1469
- if (e === !0) throw new Error(`[series] - no value at index ${r}`);
1519
+ const s = Number(t - this.alignment);
1520
+ if (s < 0 || s >= this.length) {
1521
+ if (e === !0) throw new Error(`[series] - no value at index ${s}`);
1470
1522
  return;
1471
1523
  }
1472
- return this.at(r, e);
1524
+ return this.at(s, e);
1473
1525
  }
1474
1526
  at(t, e) {
1475
1527
  if (this.dataType.isVariable) return this.atVariable(t, e ?? !1);
1476
1528
  t < 0 && (t = this.length + t);
1477
- const r = this.data[t];
1478
- if (r == null) {
1529
+ const s = this.data[t];
1530
+ if (s == null) {
1479
1531
  if (e === !0) throw new Error(`[series] - no value at index ${t}`);
1480
1532
  return;
1481
1533
  }
1482
- return x(r, this.sampleOffset);
1534
+ return x(s, this.sampleOffset);
1483
1535
  }
1484
1536
  atVariable(t, e) {
1485
- let r = 0, a = 0;
1537
+ let s = 0, i = 0;
1486
1538
  if (this._cachedIndexes != null)
1487
- r = this._cachedIndexes[t], a = this._cachedIndexes[t + 1] - 1;
1539
+ s = this._cachedIndexes[t], i = this._cachedIndexes[t + 1] - 1;
1488
1540
  else {
1489
1541
  t < 0 && (t = this.length + t);
1490
- for (let h = 0; h < this.data.length; h++)
1491
- if (this.data[h] === Y) {
1542
+ for (let c = 0; c < this.data.length; c++)
1543
+ if (this.data[c] === Z) {
1492
1544
  if (t === 0) {
1493
- a = h;
1545
+ i = c;
1494
1546
  break;
1495
1547
  }
1496
- r = h + 1, t--;
1548
+ s = c + 1, t--;
1497
1549
  }
1498
- if (a === 0 && (a = this.data.length), r >= a || t > 0) {
1550
+ if (i === 0 && (i = this.data.length), s >= i || t > 0) {
1499
1551
  if (e) throw new Error(`[series] - no value at index ${t}`);
1500
1552
  return;
1501
1553
  }
1502
1554
  }
1503
- const c = this.data.slice(r, a);
1504
- return this.dataType.equals(g.STRING) ? new TextDecoder().decode(c) : st(JSON.parse(new TextDecoder().decode(c)));
1555
+ const h = this.data.slice(s, i);
1556
+ return this.dataType.equals(g.STRING) ? new TextDecoder().decode(h) : at(JSON.parse(new TextDecoder().decode(h)));
1505
1557
  }
1506
1558
  /**
1507
1559
  * @returns the index of the first sample that is greater than or equal to the given value.
@@ -1509,33 +1561,33 @@ const Lt = l.union([
1509
1561
  * @param value the value to search for.
1510
1562
  */
1511
1563
  binarySearch(t) {
1512
- let e = 0, r = this.length - 1;
1513
- const a = it(t);
1514
- for (; e <= r; ) {
1515
- const c = Math.floor((e + r) / 2), h = a(this.at(c, !0), t);
1516
- if (h === 0) return c;
1517
- h < 0 ? e = c + 1 : r = c - 1;
1564
+ let e = 0, s = this.length - 1;
1565
+ const i = ut(t);
1566
+ for (; e <= s; ) {
1567
+ const h = Math.floor((e + s) / 2), c = i(this.at(h, !0), t);
1568
+ if (c === 0) return h;
1569
+ c < 0 ? e = h + 1 : s = h - 1;
1518
1570
  }
1519
1571
  return e;
1520
1572
  }
1521
1573
  updateGLBuffer(t) {
1522
1574
  if (this.gl.control = t, !this.dataType.equals(g.FLOAT32) && !this.dataType.equals(g.UINT8))
1523
1575
  throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");
1524
- const { buffer: e, bufferUsage: r, prevBuffer: a } = this.gl;
1525
- if (e == null && (this.gl.buffer = t.createBuffer()), this.writePos !== a)
1576
+ const { buffer: e, bufferUsage: s, prevBuffer: i } = this.gl;
1577
+ if (e == null && (this.gl.buffer = t.createBuffer()), this.writePos !== i)
1526
1578
  if (t.bindBuffer(t.ARRAY_BUFFER, this.gl.buffer), this.writePos !== M) {
1527
- a === 0 && t.bufferData(t.ARRAY_BUFFER, this.byteCapacity.valueOf(), t.STATIC_DRAW);
1528
- const c = this.dataType.density.size(a).valueOf(), h = this.underlyingData.slice(this.gl.prevBuffer, this.writePos);
1529
- t.bufferSubData(t.ARRAY_BUFFER, c, h.buffer), this.gl.prevBuffer = this.writePos;
1579
+ i === 0 && t.bufferData(t.ARRAY_BUFFER, this.byteCapacity.valueOf(), t.STATIC_DRAW);
1580
+ const h = this.dataType.density.size(i).valueOf(), c = this.underlyingData.slice(this.gl.prevBuffer, this.writePos);
1581
+ t.bufferSubData(t.ARRAY_BUFFER, h, c.buffer), this.gl.prevBuffer = this.writePos;
1530
1582
  } else
1531
1583
  t.bufferData(
1532
1584
  t.ARRAY_BUFFER,
1533
1585
  this.buffer,
1534
- r === "static" ? t.STATIC_DRAW : t.DYNAMIC_DRAW
1586
+ s === "static" ? t.STATIC_DRAW : t.DYNAMIC_DRAW
1535
1587
  ), this.gl.prevBuffer = M;
1536
1588
  }
1537
1589
  as(t) {
1538
- return et(t, this.dataType), this;
1590
+ return nt(t, this.dataType), this;
1539
1591
  }
1540
1592
  get digest() {
1541
1593
  var t;
@@ -1544,10 +1596,10 @@ const Lt = l.union([
1544
1596
  dataType: this.dataType.toString(),
1545
1597
  sampleOffset: this.sampleOffset,
1546
1598
  alignment: {
1547
- lower: J(this.alignmentBounds.lower),
1548
- upper: J(this.alignmentBounds.upper)
1599
+ lower: H(this.alignmentBounds.lower),
1600
+ upper: H(this.alignmentBounds.upper)
1549
1601
  },
1550
- timeRange: (t = this._timeRange) == null ? void 0 : t.toString(),
1602
+ timeRange: (t = this.timeRange) == null ? void 0 : t.toString(),
1551
1603
  length: this.length,
1552
1604
  capacity: this.capacity
1553
1605
  };
@@ -1572,10 +1624,10 @@ const Lt = l.union([
1572
1624
  }
1573
1625
  [Symbol.iterator]() {
1574
1626
  if (this.dataType.isVariable) {
1575
- const t = new Ot(this);
1576
- return this.dataType.equals(g.JSON) ? new wt(t) : t;
1627
+ const t = new yt(this);
1628
+ return this.dataType.equals(g.JSON) ? new G(t) : t;
1577
1629
  }
1578
- return new bt(this);
1630
+ return new It(this);
1579
1631
  }
1580
1632
  slice(t, e) {
1581
1633
  return this.sliceSub(!1, t, e);
@@ -1584,10 +1636,10 @@ const Lt = l.union([
1584
1636
  return this.sliceSub(!0, t, e);
1585
1637
  }
1586
1638
  subIterator(t, e) {
1587
- return new G(this, t, e ?? this.length);
1639
+ return new W(this, t, e ?? this.length);
1588
1640
  }
1589
1641
  subAlignmentIterator(t, e) {
1590
- return new G(
1642
+ return new W(
1591
1643
  this,
1592
1644
  Number(t - this.alignment),
1593
1645
  Number(e - this.alignment)
@@ -1595,60 +1647,73 @@ const Lt = l.union([
1595
1647
  }
1596
1648
  subBytes(t, e) {
1597
1649
  if (t >= 0 && (e == null || e >= this.byteLength.valueOf())) return this;
1598
- const r = this.data.subarray(t, e);
1599
- return new I({
1600
- data: r,
1650
+ const s = this.data.subarray(t, e);
1651
+ return new T({
1652
+ data: s,
1601
1653
  dataType: this.dataType,
1602
- timeRange: this._timeRange,
1654
+ timeRange: this.timeRange,
1603
1655
  sampleOffset: this.sampleOffset,
1604
1656
  glBufferUsage: this.gl.bufferUsage,
1605
1657
  alignment: this.alignment + BigInt(t)
1606
1658
  });
1607
1659
  }
1608
- sliceSub(t, e, r) {
1609
- if (e <= 0 && (r == null || r >= this.length)) return this;
1610
- let a;
1611
- return t ? a = this.data.subarray(e, r) : a = this.data.slice(e, r), new I({
1612
- data: a,
1660
+ sliceSub(t, e, s) {
1661
+ if (e <= 0 && (s == null || s >= this.length)) return this;
1662
+ let i;
1663
+ return t ? i = this.data.subarray(e, s) : i = this.data.slice(e, s), new T({
1664
+ data: i,
1613
1665
  dataType: this.dataType,
1614
- timeRange: this._timeRange,
1666
+ timeRange: this.timeRange,
1615
1667
  sampleOffset: this.sampleOffset,
1616
1668
  glBufferUsage: this.gl.bufferUsage,
1617
1669
  alignment: this.alignment + BigInt(e)
1618
1670
  });
1619
1671
  }
1620
1672
  reAlign(t) {
1621
- return new I({
1673
+ return new T({
1622
1674
  data: this.buffer,
1623
1675
  dataType: this.dataType,
1624
- timeRange: U.ZERO,
1676
+ timeRange: A.ZERO,
1625
1677
  sampleOffset: this.sampleOffset,
1626
1678
  glBufferUsage: "static",
1627
1679
  alignment: t
1628
1680
  });
1629
1681
  }
1682
+ toString() {
1683
+ var e, s;
1684
+ let t = `${this.dataType.toString()} ${this.length} [`;
1685
+ if (this.length <= 10) t += Array.from(this).map((i) => i.toString());
1686
+ else {
1687
+ for (let i = 0; i < 5; i++)
1688
+ t += `${(e = this.at(i)) == null ? void 0 : e.toString()}`, i < 4 && (t += ",");
1689
+ t += "...";
1690
+ for (let i = -5; i < 0; i++)
1691
+ t += (s = this.at(i)) == null ? void 0 : s.toString(), i < -1 && (t += ",");
1692
+ }
1693
+ return t += "]", t;
1694
+ }
1630
1695
  };
1631
- s(I, "crudeZ", l.object({
1632
- timeRange: U.z.optional(),
1696
+ r(T, "crudeZ", l.object({
1697
+ timeRange: A.z.optional(),
1633
1698
  dataType: g.z,
1634
1699
  alignment: l.coerce.bigint().optional(),
1635
1700
  data: l.union([
1636
- gt,
1637
- mt,
1701
+ bt,
1702
+ wt,
1638
1703
  l.instanceof(ArrayBuffer),
1639
1704
  l.instanceof(Uint8Array)
1640
1705
  ]),
1641
- glBufferUsage: ct.optional().default("static").optional()
1642
- })), s(I, "z", I.crudeZ.transform((t) => new I(t)));
1643
- let k = I;
1644
- class G {
1645
- constructor(t, e, r) {
1646
- s(this, "series");
1647
- s(this, "end");
1648
- s(this, "index");
1706
+ glBufferUsage: gt.optional().default("static").optional()
1707
+ })), r(T, "z", T.crudeZ.transform((t) => new T(t)));
1708
+ let k = T;
1709
+ class W {
1710
+ constructor(t, e, s) {
1711
+ r(this, "series");
1712
+ r(this, "end");
1713
+ r(this, "index");
1649
1714
  this.series = t;
1650
- const a = L(0, t.length);
1651
- this.end = V(a, r), this.index = V(a, e);
1715
+ const i = L(0, t.length);
1716
+ this.end = J(i, s), this.index = J(i, e);
1652
1717
  }
1653
1718
  next() {
1654
1719
  return this.index >= this.end ? { done: !0, value: void 0 } : { done: !1, value: this.series.at(this.index++, !0) };
@@ -1657,11 +1722,11 @@ class G {
1657
1722
  return this;
1658
1723
  }
1659
1724
  }
1660
- class Ot {
1725
+ class yt {
1661
1726
  constructor(t) {
1662
- s(this, "series");
1663
- s(this, "index");
1664
- s(this, "decoder");
1727
+ r(this, "series");
1728
+ r(this, "index");
1729
+ r(this, "decoder");
1665
1730
  if (!t.dataType.isVariable)
1666
1731
  throw new Error(
1667
1732
  "cannot create a variable series iterator for a non-variable series"
@@ -1670,38 +1735,40 @@ class Ot {
1670
1735
  }
1671
1736
  next() {
1672
1737
  const t = this.index, e = this.series.data;
1673
- for (; this.index < e.length && e[this.index] !== Y; ) this.index++;
1674
- const r = this.index;
1675
- return t === r ? { done: !0, value: void 0 } : (this.index++, { done: !1, value: this.decoder.decode(this.series.buffer.slice(t, r)) });
1738
+ for (; this.index < e.length && e[this.index] !== Z; ) this.index++;
1739
+ const s = this.index;
1740
+ return t === s ? { done: !0, value: void 0 } : (this.index++, { done: !1, value: this.decoder.decode(this.series.buffer.slice(t, s)) });
1676
1741
  }
1677
1742
  [Symbol.iterator]() {
1678
1743
  return this;
1679
1744
  }
1680
1745
  }
1681
- var W, j;
1682
- class wt {
1746
+ var j, K;
1747
+ const P = class P {
1683
1748
  constructor(t) {
1684
- s(this, "wrapped");
1685
- s(this, W, "JSONSeriesIterator");
1749
+ r(this, "wrapped");
1750
+ r(this, j, "JSONSeriesIterator");
1686
1751
  this.wrapped = t;
1687
1752
  }
1688
1753
  next() {
1689
1754
  const t = this.wrapped.next();
1690
1755
  return t.done === !0 ? { done: !0, value: void 0 } : {
1691
1756
  done: !1,
1692
- value: q.decodeString(t.value)
1757
+ value: q.decodeString(t.value, P.SCHEMA)
1693
1758
  };
1694
1759
  }
1695
- [(j = Symbol.iterator, W = Symbol.toStringTag, j)]() {
1760
+ [(K = Symbol.iterator, j = Symbol.toStringTag, K)]() {
1696
1761
  return this;
1697
1762
  }
1698
- }
1699
- var H, K;
1700
- class bt {
1763
+ };
1764
+ r(P, "SCHEMA", l.record(l.string(), l.unknown()));
1765
+ let G = P;
1766
+ var z, X;
1767
+ class It {
1701
1768
  constructor(t) {
1702
- s(this, "series");
1703
- s(this, "index");
1704
- s(this, H, "SeriesIterator");
1769
+ r(this, "series");
1770
+ r(this, "index");
1771
+ r(this, z, "SeriesIterator");
1705
1772
  this.series = t, this.index = 0;
1706
1773
  }
1707
1774
  next() {
@@ -1710,29 +1777,29 @@ class bt {
1710
1777
  value: this.series.at(this.index++, !0)
1711
1778
  };
1712
1779
  }
1713
- [(K = Symbol.iterator, H = Symbol.toStringTag, K)]() {
1780
+ [(X = Symbol.iterator, z = Symbol.toStringTag, X)]() {
1714
1781
  return this;
1715
1782
  }
1716
1783
  }
1717
- class Dt {
1718
- constructor(t) {
1719
- s(this, "series");
1784
+ class $t {
1785
+ constructor(t = []) {
1786
+ r(this, "series");
1720
1787
  if (t.length !== 0) {
1721
1788
  const e = t[0].dataType;
1722
- for (let r = 1; r < t.length; r++)
1723
- if (!t[r].dataType.equals(e))
1789
+ for (let s = 1; s < t.length; s++)
1790
+ if (!t[s].dataType.equals(e))
1724
1791
  throw new Error("[multi-series] - series must have the same data type");
1725
1792
  }
1726
1793
  this.series = t;
1727
1794
  }
1728
1795
  as(t) {
1729
- return et(t, this.dataType), this;
1796
+ return nt(t, this.dataType), this;
1730
1797
  }
1731
1798
  get dataType() {
1732
1799
  return this.series.length === 0 ? g.UNKNOWN : this.series[0].dataType;
1733
1800
  }
1734
1801
  get timeRange() {
1735
- return this.series.length === 0 ? U.ZERO : new U(
1802
+ return this.series.length === 0 ? A.ZERO : new A(
1736
1803
  this.series[0].timeRange.start,
1737
1804
  this.series[this.series.length - 1].timeRange.end
1738
1805
  );
@@ -1747,7 +1814,7 @@ class Dt {
1747
1814
  );
1748
1815
  }
1749
1816
  push(t) {
1750
- this.series.push(t);
1817
+ "isSynnaxSeries" in t && t.isSynnaxSeries ? this.series.push(t) : this.series.push(...t.series);
1751
1818
  }
1752
1819
  get length() {
1753
1820
  return this.series.reduce((t, e) => t + e.length, 0);
@@ -1757,78 +1824,90 @@ class Dt {
1757
1824
  if (e) throw new Error(`[series] - no value at alignment ${t}`);
1758
1825
  return;
1759
1826
  }
1760
- for (const r of this.series)
1761
- if (D(r.alignmentBounds, t))
1762
- return r.atAlignment(t, e);
1827
+ for (const s of this.series)
1828
+ if (D(s.alignmentBounds, t))
1829
+ return s.atAlignment(t, e);
1763
1830
  if (e) throw new Error(`[series] - no value at alignment ${t}`);
1764
1831
  }
1765
1832
  at(t, e = !1) {
1766
1833
  t < 0 && (t = this.length + t);
1767
- for (const r of this.series) {
1768
- if (t < r.length) return r.at(t, e);
1769
- t -= r.length;
1834
+ for (const s of this.series) {
1835
+ if (t < s.length) return s.at(t, e);
1836
+ t -= s.length;
1770
1837
  }
1771
1838
  if (e) throw new Error(`[series] - no value at index ${t}`);
1772
1839
  }
1773
1840
  subIterator(t, e) {
1774
- return new P(this, t, e ?? this.length);
1841
+ return new F(this, t, e ?? this.length);
1775
1842
  }
1776
1843
  subAlignmentIterator(t, e) {
1777
1844
  if (t >= this.alignmentBounds.upper || e <= this.alignmentBounds.lower)
1778
- return F;
1779
- let r = 0;
1780
- for (let c = 0; c < this.series.length; c++) {
1781
- const h = this.series[c];
1782
- if (t < h.alignment) break;
1783
- if (t >= h.alignmentBounds.upper) r += h.length;
1784
- else if (D(h.alignmentBounds, t)) {
1785
- r += Number(t - h.alignment);
1845
+ return Y;
1846
+ let s = 0;
1847
+ for (let h = 0; h < this.series.length; h++) {
1848
+ const c = this.series[h];
1849
+ if (t < c.alignment) break;
1850
+ if (t >= c.alignmentBounds.upper) s += c.length;
1851
+ else if (D(c.alignmentBounds, t)) {
1852
+ s += Number(t - c.alignment);
1786
1853
  break;
1787
1854
  }
1788
1855
  }
1789
- let a = 0;
1790
- for (let c = 0; c < this.series.length; c++) {
1791
- const h = this.series[c];
1792
- if (e < h.alignment) break;
1793
- if (e >= h.alignmentBounds.upper) a += h.length;
1794
- else if (D(h.alignmentBounds, e)) {
1795
- a += Number(e - h.alignment);
1856
+ let i = 0;
1857
+ for (let h = 0; h < this.series.length; h++) {
1858
+ const c = this.series[h];
1859
+ if (e < c.alignment) break;
1860
+ if (e >= c.alignmentBounds.upper) i += c.length;
1861
+ else if (D(c.alignmentBounds, e)) {
1862
+ i += Number(e - c.alignment);
1796
1863
  break;
1797
1864
  }
1798
1865
  }
1799
- return new P(this, r, a);
1866
+ return new F(this, s, i);
1800
1867
  }
1801
1868
  subAlignmentSpanIterator(t, e) {
1802
- if (t >= this.alignmentBounds.upper) return F;
1803
- let r = 0;
1804
- for (let a = 0; a < this.series.length; a++) {
1805
- const c = this.series[a];
1806
- if (t < c.alignment) break;
1807
- if (t >= c.alignmentBounds.upper) r += c.length;
1808
- else if (D(c.alignmentBounds, t)) {
1809
- r += Number(t - c.alignment);
1869
+ if (t >= this.alignmentBounds.upper) return Y;
1870
+ let s = 0;
1871
+ for (let i = 0; i < this.series.length; i++) {
1872
+ const h = this.series[i];
1873
+ if (t < h.alignment) break;
1874
+ if (t >= h.alignmentBounds.upper) s += h.length;
1875
+ else if (D(h.alignmentBounds, t)) {
1876
+ s += Number(t - h.alignment);
1810
1877
  break;
1811
1878
  }
1812
1879
  }
1813
- return new P(this, r, r + e);
1880
+ return new F(this, s, s + e);
1881
+ }
1882
+ updateGLBuffer(t) {
1883
+ this.series.forEach((e) => e.updateGLBuffer(t));
1884
+ }
1885
+ get bounds() {
1886
+ return ot(this.series.map((t) => t.bounds));
1814
1887
  }
1815
1888
  get byteLength() {
1816
- return new C(this.series.reduce((t, e) => t + e.byteLength.valueOf(), 0));
1889
+ return new R(this.series.reduce((t, e) => t + e.byteLength.valueOf(), 0));
1817
1890
  }
1818
1891
  get data() {
1819
1892
  const t = new this.dataType.Array(this.length);
1820
1893
  let e = 0;
1821
- for (const r of this.series)
1822
- t.set(r.data, e), e += r.length;
1894
+ for (const s of this.series)
1895
+ t.set(s.data, e), e += s.length;
1823
1896
  return new this.dataType.Array(t.buffer);
1824
1897
  }
1825
1898
  traverseAlignment(t, e) {
1826
- const r = this.series.map((a) => a.alignmentBounds);
1827
- return at(r, t, e);
1899
+ const s = this.series.map((i) => i.alignmentBounds);
1900
+ return lt(s, t, e);
1901
+ }
1902
+ acquire() {
1903
+ this.series.forEach((t) => t.acquire());
1904
+ }
1905
+ release() {
1906
+ this.series.forEach((t) => t.release());
1828
1907
  }
1829
1908
  distance(t, e) {
1830
- const r = this.series.map((a) => a.alignmentBounds);
1831
- return ut(r, t, e);
1909
+ const s = this.series.map((i) => i.alignmentBounds);
1910
+ return ft(s, t, e);
1832
1911
  }
1833
1912
  parseJSON(t) {
1834
1913
  if (!this.dataType.equals(g.JSON))
@@ -1840,32 +1919,32 @@ class Dt {
1840
1919
  next() {
1841
1920
  return { done: !0, value: void 0 };
1842
1921
  }
1843
- } : new yt(this.series);
1922
+ } : new Tt(this.series);
1844
1923
  }
1845
1924
  }
1846
- var z, X;
1847
- class yt {
1925
+ var Q, _;
1926
+ class Tt {
1848
1927
  constructor(t) {
1849
- s(this, "series");
1850
- s(this, "seriesIndex");
1851
- s(this, "internal");
1852
- s(this, z, "MultiSeriesIterator");
1928
+ r(this, "series");
1929
+ r(this, "seriesIndex");
1930
+ r(this, "internal");
1931
+ r(this, Q, "MultiSeriesIterator");
1853
1932
  this.series = t, this.seriesIndex = 0, this.internal = t[0][Symbol.iterator]();
1854
1933
  }
1855
1934
  next() {
1856
1935
  const t = this.internal.next();
1857
1936
  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());
1858
1937
  }
1859
- [(X = Symbol.iterator, z = Symbol.toStringTag, X)]() {
1938
+ [(_ = Symbol.iterator, Q = Symbol.toStringTag, _)]() {
1860
1939
  return this;
1861
1940
  }
1862
1941
  }
1863
- class P {
1864
- constructor(t, e, r) {
1865
- s(this, "series");
1866
- s(this, "index");
1867
- s(this, "end");
1868
- this.series = t, this.end = r, this.index = e;
1942
+ class F {
1943
+ constructor(t, e, s) {
1944
+ r(this, "series");
1945
+ r(this, "index");
1946
+ r(this, "end");
1947
+ this.series = t, this.end = s, this.index = e;
1869
1948
  }
1870
1949
  next() {
1871
1950
  return this.index >= this.end ? { done: !0, value: void 0 } : { done: !1, value: this.series.at(this.index++, !0) };
@@ -1874,25 +1953,25 @@ class P {
1874
1953
  return this;
1875
1954
  }
1876
1955
  }
1877
- const J = (o) => {
1956
+ const H = (o) => {
1878
1957
  const t = o >> 32n, e = o & 0xffffffffn;
1879
1958
  return { domain: t, sample: e };
1880
1959
  };
1881
1960
  export {
1882
1961
  y as D,
1883
- Dt as M,
1962
+ $t as M,
1884
1963
  $ as R,
1885
1964
  k as S,
1886
1965
  m as T,
1887
- w as a,
1888
- U as b,
1966
+ O as a,
1967
+ A as b,
1889
1968
  g as c,
1890
- C as d,
1891
- tt as e,
1892
- ht as f,
1969
+ R as d,
1970
+ st as e,
1971
+ mt as f,
1893
1972
  x as g,
1894
- Ct as h,
1895
- dt as i,
1896
- xt as s,
1897
- Lt as t
1973
+ Lt as h,
1974
+ Ot as i,
1975
+ Dt as s,
1976
+ qt as t
1898
1977
  };