@synnaxlabs/x 0.32.0 → 0.34.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 (124) hide show
  1. package/.turbo/turbo-build.log +32 -32
  2. package/dist/binary.cjs +1 -1
  3. package/dist/binary.js +1 -1
  4. package/dist/bounds-CFI9wDXn.js +171 -0
  5. package/dist/bounds-DzCDHgdE.cjs +1 -0
  6. package/dist/bounds.cjs +1 -1
  7. package/dist/bounds.js +1 -1
  8. package/dist/box-DVCNGsJG.js +201 -0
  9. package/dist/box-Mf8E1Ypp.cjs +1 -0
  10. package/dist/box.cjs +1 -1
  11. package/dist/box.js +1 -1
  12. package/dist/caseconv.cjs +1 -1
  13. package/dist/caseconv.js +1 -1
  14. package/dist/compare.js +1 -1
  15. package/dist/deep.cjs +1 -1
  16. package/dist/deep.js +46 -48
  17. package/dist/{direction-DZbN47uL.cjs → direction-D7qoo_GJ.cjs} +1 -1
  18. package/dist/direction.cjs +1 -1
  19. package/dist/external-B3XSLDq5.cjs +1 -0
  20. package/dist/{external-CO221aaF.js → external-sVtvYJS6.js} +3 -3
  21. package/dist/{index-B5THJ1eb.js → index-BBa2mWG1.js} +1 -1
  22. package/dist/{index-DgaYJC35.cjs → index-CYxQwEdX.cjs} +1 -1
  23. package/dist/{index-B3BUDIdi.js → index-HQonyH7n.js} +1 -2
  24. package/dist/index-YsO0EMN8.cjs +1 -0
  25. package/dist/{index-Duv1uH08.js → index-eue4dSQX.js} +14 -10
  26. package/dist/index.cjs +2 -2
  27. package/dist/index.js +162 -145
  28. package/dist/{location-DjcaXEps.js → location-CI9x53qR.js} +8 -8
  29. package/dist/{location-gPB1RtfA.cjs → location-DetomF8Z.cjs} +1 -1
  30. package/dist/location.cjs +1 -1
  31. package/dist/location.js +1 -1
  32. package/dist/path-BBCx3K6k.cjs +1 -0
  33. package/dist/{path-B-1-i3qC.js → path-CmnoH3RC.js} +26 -26
  34. package/dist/{position-DkON65EZ.js → position-CFc9RsSn.js} +2 -2
  35. package/dist/{position-C71OiHiw.cjs → position-DKhPhvPh.cjs} +1 -1
  36. package/dist/position.cjs +1 -1
  37. package/dist/position.js +1 -1
  38. package/dist/runtime.cjs +1 -1
  39. package/dist/runtime.js +1 -1
  40. package/dist/{scale-COPgp55a.cjs → scale-CT61XD_X.cjs} +1 -1
  41. package/dist/{scale-qw6vRO4s.js → scale-DNQE1LMm.js} +25 -3
  42. package/dist/scale.cjs +1 -1
  43. package/dist/scale.js +1 -1
  44. package/dist/series-DWLXo7J6.cjs +11 -0
  45. package/dist/{series-B5eA90Ci.js → series-sjWkW8qe.js} +627 -466
  46. package/dist/spatial.cjs +1 -1
  47. package/dist/spatial.js +5 -5
  48. package/dist/src/binary/encoder.d.ts.map +1 -1
  49. package/dist/src/caseconv/caseconv.d.ts.map +1 -1
  50. package/dist/src/clamp/clamp.d.ts.map +1 -1
  51. package/dist/src/compare/compare.d.ts.map +1 -1
  52. package/dist/src/debounce/debounce.d.ts.map +1 -1
  53. package/dist/src/deep/difference.d.ts.map +1 -1
  54. package/dist/src/deep/merge.d.ts.map +1 -1
  55. package/dist/src/deep/path.d.ts +2 -2
  56. package/dist/src/deep/path.d.ts.map +1 -1
  57. package/dist/src/math/math.d.ts +26 -6
  58. package/dist/src/math/math.d.ts.map +1 -1
  59. package/dist/src/math/math.spec.d.ts +2 -0
  60. package/dist/src/math/math.spec.d.ts.map +1 -0
  61. package/dist/src/migrate/migrate.d.ts.map +1 -1
  62. package/dist/src/record.d.ts +4 -0
  63. package/dist/src/record.d.ts.map +1 -1
  64. package/dist/src/spatial/bounds/bounds.d.ts +208 -4
  65. package/dist/src/spatial/bounds/bounds.d.ts.map +1 -1
  66. package/dist/src/spatial/box/box.d.ts +4 -4
  67. package/dist/src/spatial/box/box.d.ts.map +1 -1
  68. package/dist/src/spatial/scale/scale.d.ts +177 -5
  69. package/dist/src/spatial/scale/scale.d.ts.map +1 -1
  70. package/dist/src/strings/strings.d.ts +14 -0
  71. package/dist/src/strings/strings.d.ts.map +1 -1
  72. package/dist/src/telem/generate.d.ts.map +1 -1
  73. package/dist/src/telem/series.d.ts +35 -10
  74. package/dist/src/telem/series.d.ts.map +1 -1
  75. package/dist/src/telem/telem.d.ts +12 -10
  76. package/dist/src/telem/telem.d.ts.map +1 -1
  77. package/dist/src/url/url.d.ts.map +1 -1
  78. package/dist/telem.cjs +1 -1
  79. package/dist/telem.js +1 -1
  80. package/dist/url.cjs +1 -1
  81. package/dist/url.js +1 -1
  82. package/dist/{zodutil-BWvwKcpb.cjs → zodutil-C6RYzvXd.cjs} +1 -1
  83. package/dist/{zodutil-qNM8aVYC.js → zodutil-Tmuc4CNq.js} +1 -1
  84. package/dist/zodutil.cjs +1 -1
  85. package/dist/zodutil.js +1 -1
  86. package/package.json +10 -9
  87. package/src/binary/encoder.ts +1 -2
  88. package/src/caseconv/caseconv.ts +8 -15
  89. package/src/clamp/clamp.ts +1 -1
  90. package/src/compare/compare.ts +1 -3
  91. package/src/debounce/debounce.ts +1 -2
  92. package/src/deep/difference.ts +3 -9
  93. package/src/deep/merge.ts +8 -15
  94. package/src/deep/path.spec.ts +1 -1
  95. package/src/deep/path.ts +4 -4
  96. package/src/math/math.spec.ts +149 -0
  97. package/src/math/math.ts +61 -10
  98. package/src/migrate/migrate.ts +4 -5
  99. package/src/record.ts +5 -0
  100. package/src/runtime/os.ts +2 -2
  101. package/src/spatial/bounds/bounds.spec.ts +135 -270
  102. package/src/spatial/bounds/bounds.ts +296 -29
  103. package/src/spatial/box/box.ts +13 -12
  104. package/src/spatial/direction/direction.ts +1 -1
  105. package/src/spatial/location/location.ts +5 -5
  106. package/src/spatial/scale/scale.ts +196 -12
  107. package/src/strings/strings.spec.ts +33 -1
  108. package/src/strings/strings.ts +52 -0
  109. package/src/telem/generate.ts +1 -3
  110. package/src/telem/series.spec.ts +235 -0
  111. package/src/telem/series.ts +310 -100
  112. package/src/telem/telem.spec.ts +27 -11
  113. package/src/telem/telem.ts +56 -36
  114. package/src/url/url.ts +9 -12
  115. package/src/zodutil/zodutil.spec.ts +5 -7
  116. package/tsconfig.tsbuildinfo +1 -1
  117. package/dist/bounds-CpboA0q6.js +0 -127
  118. package/dist/bounds-ZZc1c-_Z.cjs +0 -1
  119. package/dist/box-BQID-0jO.cjs +0 -1
  120. package/dist/box-xRqO6NvI.js +0 -202
  121. package/dist/external-B-DoBvh7.cjs +0 -1
  122. package/dist/index-xk130iQA.cjs +0 -1
  123. package/dist/path-577Fmn5N.cjs +0 -1
  124. package/dist/series-CJ65b1Uz.cjs +0 -11
@@ -1,28 +1,28 @@
1
- var j = Object.defineProperty;
2
- var K = (f, t, e) => t in f ? j(f, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : f[t] = e;
3
- var s = (f, t, e) => K(f, typeof t != "symbol" ? t + "" : t, e);
1
+ var tt = Object.defineProperty;
2
+ var et = (l, t, e) => t in l ? tt(l, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : l[t] = e;
3
+ var s = (l, t, e) => et(l, typeof t != "symbol" ? t + "" : t, e);
4
4
  import { z as o } from "zod";
5
- import { J as L } from "./index-B5THJ1eb.js";
6
- import { s as z } from "./index-Duv1uH08.js";
7
- import { n as H } from "./index-B3BUDIdi.js";
8
- import { c as $ } from "./bounds-CpboA0q6.js";
9
- import "./box-xRqO6NvI.js";
5
+ import { J as $ } from "./index-BBa2mWG1.js";
6
+ import { s as nt } from "./index-eue4dSQX.js";
7
+ import { n as rt } from "./index-HQonyH7n.js";
8
+ import { m as R, c as L, a as k, d as D, t as st, e as it } from "./bounds-CFI9wDXn.js";
9
+ import "./box-DVCNGsJG.js";
10
10
  import "./dimensions-D-1PnJVI.js";
11
11
  import "./base-DnZzEvvz.js";
12
- import "./location-DjcaXEps.js";
13
- import "./scale-qw6vRO4s.js";
12
+ import "./location-CI9x53qR.js";
13
+ import "./scale-DNQE1LMm.js";
14
14
  import "./xy-CrgPnICw.js";
15
- import { b as X } from "./zodutil-qNM8aVYC.js";
16
- let Q = (f, t = 21) => (e = t) => {
17
- let r = "", u = e;
18
- for (; u--; )
19
- r += f[Math.random() * f.length | 0];
20
- return r;
15
+ import { b as at } from "./zodutil-Tmuc4CNq.js";
16
+ let ut = (l, t = 21) => (e = t) => {
17
+ let n = "", i = e;
18
+ for (; i--; )
19
+ n += l[Math.random() * l.length | 0];
20
+ return n;
21
21
  };
22
- const _ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", k = Q(_, 11), Nt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
22
+ const ot = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", X = ut(ot, 11), Rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
23
23
  __proto__: null,
24
- id: k
25
- }, Symbol.toStringTag, { value: "Module" })), tt = o.enum(["static", "dynamic"]), J = (f, t) => {
24
+ id: X
25
+ }, Symbol.toStringTag, { value: "Module" })), lt = o.enum(["static", "dynamic"]), Q = (l, t) => {
26
26
  const e = new m(t);
27
27
  if (![
28
28
  y.DAY,
@@ -32,30 +32,30 @@ const _ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", k =
32
32
  y.MILLISECOND,
33
33
  y.MICROSECOND,
34
34
  y.NANOSECOND
35
- ].some((u) => u.equals(e)))
35
+ ].some((i) => i.equals(e)))
36
36
  throw new Error(
37
37
  "Invalid argument for remainder. Must be an even TimeSpan or Timestamp"
38
38
  );
39
- const r = f.valueOf() % e.valueOf();
40
- return f instanceof m ? new m(r) : new y(r);
41
- }, i = class i {
39
+ const n = l.valueOf() % e.valueOf();
40
+ return l instanceof m ? new m(n) : new y(n);
41
+ }, a = class a {
42
42
  constructor(t, e = "UTC") {
43
43
  s(this, "value");
44
44
  s(this, "encodeValue", !0);
45
- if (t == null) this.value = i.now().valueOf();
45
+ if (t == null) this.value = a.now().valueOf();
46
46
  else if (t instanceof Date)
47
- this.value = BigInt(t.getTime()) * i.MILLISECOND.valueOf();
47
+ this.value = BigInt(t.getTime()) * a.MILLISECOND.valueOf();
48
48
  else if (typeof t == "string")
49
- this.value = i.parseDateTimeString(t, e).valueOf();
50
- else if (Array.isArray(t)) this.value = i.parseDate(t);
49
+ this.value = a.parseDateTimeString(t, e).valueOf();
50
+ else if (Array.isArray(t)) this.value = a.parseDate(t);
51
51
  else {
52
- let r = BigInt(0);
53
- 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;
52
+ let n = BigInt(0);
53
+ t instanceof Number && (t = t.valueOf()), e === "local" && (n = 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()) + n;
54
54
  }
55
55
  }
56
- static parseDate([t = 1970, e = 1, r = 1]) {
57
- const u = new Date(t, e - 1, r, 0, 0, 0, 0);
58
- return new i(BigInt(u.getTime()) * i.MILLISECOND.valueOf()).truncate(i.DAY).valueOf();
56
+ static parseDate([t = 1970, e = 1, n = 1]) {
57
+ const i = new Date(t, e - 1, n, 0, 0, 0, 0);
58
+ return new a(BigInt(i.getTime()) * a.MILLISECOND.valueOf()).truncate(a.DAY).valueOf();
59
59
  }
60
60
  encode() {
61
61
  return this.value.toString();
@@ -64,18 +64,18 @@ const _ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", k =
64
64
  return this.value;
65
65
  }
66
66
  static parseTimeString(t, e = "UTC") {
67
- const [r, u, d] = t.split(":");
68
- let g = "00", S = "00";
69
- d != null && ([g, S] = d.split("."));
70
- let O = i.hours(parseInt(r ?? "00", 10)).add(i.minutes(parseInt(u ?? "00", 10))).add(i.seconds(parseInt(g ?? "00", 10))).add(i.milliseconds(parseInt(S ?? "00", 10)));
71
- return e === "local" && (O = O.add(i.utcOffset)), O.valueOf();
67
+ const [n, i, c] = t.split(":");
68
+ let h = "00", S = "00";
69
+ c != null && ([h, S] = c.split("."));
70
+ let O = a.hours(parseInt(n ?? "00")).add(a.minutes(parseInt(i ?? "00"))).add(a.seconds(parseInt(h ?? "00"))).add(a.milliseconds(parseInt(S ?? "00")));
71
+ return e === "local" && (O = O.add(a.utcOffset)), O.valueOf();
72
72
  }
73
73
  static parseDateTimeString(t, e = "UTC") {
74
74
  if (!t.includes("/") && !t.includes("-"))
75
- return i.parseTimeString(t, e);
76
- const r = new Date(t);
77
- return t.includes(":") || r.setUTCHours(0, 0, 0, 0), new i(
78
- BigInt(r.getTime()) * i.MILLISECOND.valueOf(),
75
+ return a.parseTimeString(t, e);
76
+ const n = new Date(t);
77
+ return t.includes(":") || n.setUTCHours(0, 0, 0, 0), new a(
78
+ BigInt(n.getTime()) * a.MILLISECOND.valueOf(),
79
79
  e
80
80
  ).valueOf();
81
81
  }
@@ -100,19 +100,19 @@ const _ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", k =
100
100
  }
101
101
  }
102
102
  toISOString(t = "UTC") {
103
- return t === "UTC" ? this.date().toISOString() : this.sub(i.utcOffset).date().toISOString();
103
+ return t === "UTC" ? this.date().toISOString() : this.sub(a.utcOffset).date().toISOString();
104
104
  }
105
105
  timeString(t = !1, e = "UTC") {
106
- const r = this.toISOString(e);
107
- return t ? r.slice(11, 23) : r.slice(11, 19);
106
+ const n = this.toISOString(e);
107
+ return t ? n.slice(11, 23) : n.slice(11, 19);
108
108
  }
109
109
  dateString() {
110
- const t = this.date(), e = t.toLocaleString("default", { month: "short" }), r = t.toLocaleString("default", { day: "numeric" });
111
- return `${e} ${r}`;
110
+ const t = this.date(), e = t.toLocaleString("default", { month: "short" }), n = t.toLocaleString("default", { day: "numeric" });
111
+ return `${e} ${n}`;
112
112
  }
113
113
  static get utcOffset() {
114
114
  return new y(
115
- BigInt((/* @__PURE__ */ new Date()).getTimezoneOffset()) * i.MINUTE.valueOf()
115
+ BigInt((/* @__PURE__ */ new Date()).getTimezoneOffset()) * a.MINUTE.valueOf()
116
116
  );
117
117
  }
118
118
  /**
@@ -121,7 +121,7 @@ const _ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", k =
121
121
  * @param other - The other timestamp.
122
122
  */
123
123
  static since(t) {
124
- return new i().span(t);
124
+ return new a().span(t);
125
125
  }
126
126
  /** @returns A JavaScript Date object representing the TimeStamp. */
127
127
  date() {
@@ -134,7 +134,7 @@ const _ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", k =
134
134
  * @returns True if the TimeStamps are equal, false otherwise.
135
135
  */
136
136
  equals(t) {
137
- return this.valueOf() === new i(t).valueOf();
137
+ return this.valueOf() === new a(t).valueOf();
138
138
  }
139
139
  /**
140
140
  * Creates a TimeSpan representing the duration between the two timestamps.
@@ -154,7 +154,7 @@ const _ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", k =
154
154
  * valid, regardless of the TimeStamp order.
155
155
  */
156
156
  range(t) {
157
- return new B(this, t).makeValid();
157
+ return new E(this, t).makeValid();
158
158
  }
159
159
  /**
160
160
  * Creates a TimeRange starting at the TimeStamp and spanning the given
@@ -183,7 +183,7 @@ const _ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", k =
183
183
  * otherwise.
184
184
  */
185
185
  after(t) {
186
- return this.valueOf() > new i(t).valueOf();
186
+ return this.valueOf() > new a(t).valueOf();
187
187
  }
188
188
  /**
189
189
  * Checks if the TimeStamp is after or equal to the given TimeStamp.
@@ -193,7 +193,7 @@ const _ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", k =
193
193
  * false otherwise.
194
194
  */
195
195
  afterEq(t) {
196
- return this.valueOf() >= new i(t).valueOf();
196
+ return this.valueOf() >= new a(t).valueOf();
197
197
  }
198
198
  /**
199
199
  * Checks if the TimeStamp is before the given TimeStamp.
@@ -203,7 +203,7 @@ const _ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", k =
203
203
  * otherwise.
204
204
  */
205
205
  before(t) {
206
- return this.valueOf() < new i(t).valueOf();
206
+ return this.valueOf() < new a(t).valueOf();
207
207
  }
208
208
  /**
209
209
  * Checks if TimeStamp is before or equal to the current timestamp.
@@ -213,7 +213,7 @@ const _ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", k =
213
213
  * false otherwise.
214
214
  */
215
215
  beforeEq(t) {
216
- return this.valueOf() <= new i(t).valueOf();
216
+ return this.valueOf() <= new a(t).valueOf();
217
217
  }
218
218
  /**
219
219
  * Adds a TimeSpan to the TimeStamp.
@@ -223,7 +223,7 @@ const _ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", k =
223
223
  * TimeSpan.
224
224
  */
225
225
  add(t) {
226
- return new i(this.valueOf() + BigInt(t.valueOf()));
226
+ return new a(this.valueOf() + BigInt(t.valueOf()));
227
227
  }
228
228
  /**
229
229
  * Subtracts a TimeSpan from the TimeStamp.
@@ -233,13 +233,13 @@ const _ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", k =
233
233
  * TimeSpan.
234
234
  */
235
235
  sub(t) {
236
- return new i(this.valueOf() - BigInt(t.valueOf()));
236
+ return new a(this.valueOf() - BigInt(t.valueOf()));
237
237
  }
238
238
  /**
239
239
  * @returns The number of milliseconds since the unix epoch.
240
240
  */
241
241
  milliseconds() {
242
- return Number(this.valueOf()) / Number(i.MILLISECOND.valueOf());
242
+ return Number(this.valueOf()) / Number(a.MILLISECOND.valueOf());
243
243
  }
244
244
  toString() {
245
245
  return this.date().toISOString();
@@ -256,11 +256,11 @@ const _ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", k =
256
256
  * @example TimeStamp.now().remainder(TimeStamp.DAY) // => TimeStamp representing the current day
257
257
  */
258
258
  remainder(t) {
259
- return J(this, t);
259
+ return Q(this, t);
260
260
  }
261
261
  /** @returns true if the day portion TimeStamp is today, false otherwise. */
262
262
  get isToday() {
263
- return this.truncate(y.DAY).equals(i.now().truncate(y.DAY));
263
+ return this.truncate(y.DAY).equals(a.now().truncate(y.DAY));
264
264
  }
265
265
  truncate(t) {
266
266
  return this.sub(this.remainder(t));
@@ -271,78 +271,84 @@ const _ = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", k =
271
271
  * JavaScript can do).
272
272
  */
273
273
  static now() {
274
- return new i(/* @__PURE__ */ new Date());
274
+ return new a(/* @__PURE__ */ new Date());
275
275
  }
276
276
  static max(...t) {
277
- let e = i.MIN;
278
- for (const r of t) {
279
- const u = new i(r);
280
- u.after(e) && (e = u);
277
+ let e = a.MIN;
278
+ for (const n of t) {
279
+ const i = new a(n);
280
+ i.after(e) && (e = i);
281
281
  }
282
282
  return e;
283
283
  }
284
284
  static min(...t) {
285
- let e = i.MAX;
286
- for (const r of t) {
287
- const u = new i(r);
288
- u.before(e) && (e = u);
285
+ let e = a.MAX;
286
+ for (const n of t) {
287
+ const i = new a(n);
288
+ i.before(e) && (e = i);
289
289
  }
290
290
  return e;
291
291
  }
292
292
  /** @returns a new TimeStamp n nanoseconds after the unix epoch */
293
293
  static nanoseconds(t) {
294
- return new i(t);
294
+ return new a(t);
295
295
  }
296
296
  /** @returns a new TimeStamp n microseconds after the unix epoch */
297
297
  static microseconds(t) {
298
- return i.nanoseconds(t * 1e3);
298
+ return a.nanoseconds(t * 1e3);
299
299
  }
300
300
  /** @returns a new TimeStamp n milliseconds after the unix epoch */
301
301
  static milliseconds(t) {
302
- return i.microseconds(t * 1e3);
302
+ return a.microseconds(t * 1e3);
303
303
  }
304
304
  /** @returns a new TimeStamp n seconds after the unix epoch */
305
305
  static seconds(t) {
306
- return i.milliseconds(t * 1e3);
306
+ return a.milliseconds(t * 1e3);
307
307
  }
308
308
  /** @returns a new TimeStamp n minutes after the unix epoch */
309
309
  static minutes(t) {
310
- return i.seconds(t * 60);
310
+ return a.seconds(t * 60);
311
311
  }
312
312
  /** @returns a new TimeStamp n hours after the unix epoch */
313
313
  static hours(t) {
314
- return i.minutes(t * 60);
314
+ return a.minutes(t * 60);
315
315
  }
316
316
  /** @returns a new TimeStamp n days after the unix epoch */
317
317
  static days(t) {
318
- return i.hours(t * 24);
318
+ return a.hours(t * 24);
319
319
  }
320
320
  };
321
321
  /* One nanosecond after the unix epoch */
322
- s(i, "NANOSECOND", i.nanoseconds(1)), /** One microsecond after the unix epoch */
323
- s(i, "MICROSECOND", i.microseconds(1)), /** One millisecond after the unix epoch */
324
- s(i, "MILLISECOND", i.milliseconds(1)), /** One second after the unix epoch */
325
- s(i, "SECOND", i.seconds(1)), /** One minute after the unix epoch */
326
- s(i, "MINUTE", i.minutes(1)), /** One hour after the unix epoch */
327
- s(i, "HOUR", i.hours(1)), /** One day after the unix epoch */
328
- s(i, "DAY", i.days(1)), /** The maximum possible value for a timestamp */
329
- s(i, "MAX", new i((1n << 63n) - 1n)), /** The minimum possible value for a timestamp */
330
- s(i, "MIN", new i(0)), /** The unix epoch */
331
- s(i, "ZERO", new i(0)), /** A zod schema for validating timestamps */
332
- s(i, "z", o.union([
333
- o.object({ value: o.bigint() }).transform((t) => new i(t.value)),
334
- o.string().transform((t) => new i(BigInt(t))),
335
- o.instanceof(Number).transform((t) => new i(t)),
336
- o.number().transform((t) => new i(t)),
337
- o.instanceof(i)
322
+ s(a, "NANOSECOND", a.nanoseconds(1)), /** One microsecond after the unix epoch */
323
+ s(a, "MICROSECOND", a.microseconds(1)), /** One millisecond after the unix epoch */
324
+ s(a, "MILLISECOND", a.milliseconds(1)), /** One second after the unix epoch */
325
+ s(a, "SECOND", a.seconds(1)), /** One minute after the unix epoch */
326
+ s(a, "MINUTE", a.minutes(1)), /** One hour after the unix epoch */
327
+ s(a, "HOUR", a.hours(1)), /** One day after the unix epoch */
328
+ s(a, "DAY", a.days(1)), /** The maximum possible value for a timestamp */
329
+ s(a, "MAX", new a((1n << 63n) - 1n)), /** The minimum possible value for a timestamp */
330
+ s(a, "MIN", new a(0)), /** The unix epoch */
331
+ s(a, "ZERO", new a(0)), /** A zod schema for validating timestamps */
332
+ s(a, "z", o.union([
333
+ o.object({ value: o.bigint() }).transform((t) => new a(t.value)),
334
+ o.string().transform((t) => new a(BigInt(t))),
335
+ o.instanceof(Number).transform((t) => new a(t)),
336
+ o.number().transform((t) => new a(t)),
337
+ o.instanceof(a)
338
338
  ]));
339
- let m = i;
340
- const a = class a {
339
+ let m = a;
340
+ const u = class u {
341
341
  constructor(t) {
342
342
  s(this, "value");
343
343
  s(this, "encodeValue", !0);
344
344
  typeof t == "number" && (t = Math.trunc(t.valueOf())), this.value = BigInt(t.valueOf());
345
345
  }
346
+ static fromSeconds(t) {
347
+ return t instanceof u ? t : t instanceof P ? t.period : t instanceof m ? new u(t) : ["number", "bigint"].includes(typeof t) ? u.seconds(t) : new u(t);
348
+ }
349
+ static fromMilliseconds(t) {
350
+ return t instanceof u ? t : t instanceof P ? t.period : t instanceof m ? new u(t) : ["number", "bigint"].includes(typeof t) ? u.milliseconds(t) : new u(t);
351
+ }
346
352
  encode() {
347
353
  return this.value.toString();
348
354
  }
@@ -350,52 +356,52 @@ const a = class a {
350
356
  return this.value;
351
357
  }
352
358
  lessThan(t) {
353
- return this.valueOf() < new a(t).valueOf();
359
+ return this.valueOf() < new u(t).valueOf();
354
360
  }
355
361
  greaterThan(t) {
356
- return this.valueOf() > new a(t).valueOf();
362
+ return this.valueOf() > new u(t).valueOf();
357
363
  }
358
364
  lessThanOrEqual(t) {
359
- return this.valueOf() <= new a(t).valueOf();
365
+ return this.valueOf() <= new u(t).valueOf();
360
366
  }
361
367
  greaterThanOrEqual(t) {
362
- return this.valueOf() >= new a(t).valueOf();
368
+ return this.valueOf() >= new u(t).valueOf();
363
369
  }
364
370
  remainder(t) {
365
- return J(this, t);
371
+ return Q(this, t);
366
372
  }
367
373
  truncate(t) {
368
- return new a(
374
+ return new u(
369
375
  BigInt(Math.trunc(Number(this.valueOf() / t.valueOf()))) * t.valueOf()
370
376
  );
371
377
  }
372
378
  toString() {
373
- const t = this.truncate(a.DAY), e = this.truncate(a.HOUR), r = this.truncate(a.MINUTE), u = this.truncate(a.SECOND), d = this.truncate(a.MILLISECOND), g = this.truncate(a.MICROSECOND), S = this.truncate(a.NANOSECOND), O = t, N = e.sub(t), p = r.sub(e), c = u.sub(r), M = d.sub(u), U = g.sub(d), D = S.sub(g);
379
+ const t = this.truncate(u.DAY), e = this.truncate(u.HOUR), n = this.truncate(u.MINUTE), i = this.truncate(u.SECOND), c = this.truncate(u.MILLISECOND), h = this.truncate(u.MICROSECOND), S = this.truncate(u.NANOSECOND), O = t, N = e.sub(t), p = n.sub(e), f = i.sub(n), M = c.sub(i), U = h.sub(c), Z = S.sub(h);
374
380
  let A = "";
375
- return O.isZero || (A += `${O.days}d `), N.isZero || (A += `${N.hours}h `), p.isZero || (A += `${p.minutes}m `), c.isZero || (A += `${c.seconds}s `), M.isZero || (A += `${M.milliseconds}ms `), U.isZero || (A += `${U.microseconds}µs `), D.isZero || (A += `${D.nanoseconds}ns`), A.trim();
381
+ return O.isZero || (A += `${O.days}d `), N.isZero || (A += `${N.hours}h `), p.isZero || (A += `${p.minutes}m `), f.isZero || (A += `${f.seconds}s `), M.isZero || (A += `${M.milliseconds}ms `), U.isZero || (A += `${U.microseconds}µs `), Z.isZero || (A += `${Z.nanoseconds}ns`), A.trim();
376
382
  }
377
383
  /** @returns the decimal number of days in the timespan */
378
384
  get days() {
379
- return Number(this.valueOf()) / Number(a.DAY.valueOf());
385
+ return Number(this.valueOf()) / Number(u.DAY.valueOf());
380
386
  }
381
387
  /** @returns the decimal number of hours in the timespan */
382
388
  get hours() {
383
- return Number(this.valueOf()) / Number(a.HOUR.valueOf());
389
+ return Number(this.valueOf()) / Number(u.HOUR.valueOf());
384
390
  }
385
391
  /** @returns the decimal number of minutes in the timespan */
386
392
  get minutes() {
387
- return Number(this.valueOf()) / Number(a.MINUTE.valueOf());
393
+ return Number(this.valueOf()) / Number(u.MINUTE.valueOf());
388
394
  }
389
395
  /** @returns The number of seconds in the TimeSpan. */
390
396
  get seconds() {
391
- return Number(this.valueOf()) / Number(a.SECOND.valueOf());
397
+ return Number(this.valueOf()) / Number(u.SECOND.valueOf());
392
398
  }
393
399
  /** @returns The number of milliseconds in the TimeSpan. */
394
400
  get milliseconds() {
395
- return Number(this.valueOf()) / Number(a.MILLISECOND.valueOf());
401
+ return Number(this.valueOf()) / Number(u.MILLISECOND.valueOf());
396
402
  }
397
403
  get microseconds() {
398
- return Number(this.valueOf()) / Number(a.MICROSECOND.valueOf());
404
+ return Number(this.valueOf()) / Number(u.MICROSECOND.valueOf());
399
405
  }
400
406
  get nanoseconds() {
401
407
  return Number(this.valueOf());
@@ -414,7 +420,7 @@ const a = class a {
414
420
  * @returns True if the TimeSpans are equal, false otherwise.
415
421
  */
416
422
  equals(t) {
417
- return this.valueOf() === new a(t).valueOf();
423
+ return this.valueOf() === new u(t).valueOf();
418
424
  }
419
425
  /**
420
426
  * Adds a TimeSpan to the TimeSpan.
@@ -422,7 +428,7 @@ const a = class a {
422
428
  * @returns A new TimeSpan representing the sum of the two TimeSpans.
423
429
  */
424
430
  add(t) {
425
- return new a(this.valueOf() + new a(t).valueOf());
431
+ return new u(this.valueOf() + new u(t).valueOf());
426
432
  }
427
433
  /**
428
434
  * Creates a TimeSpan representing the duration between the two timestamps.
@@ -430,7 +436,7 @@ const a = class a {
430
436
  * @param other
431
437
  */
432
438
  sub(t) {
433
- return new a(this.valueOf() - new a(t).valueOf());
439
+ return new u(this.valueOf() - new u(t).valueOf());
434
440
  }
435
441
  /**
436
442
  * Creates a TimeSpan representing the given number of nanoseconds.
@@ -439,7 +445,7 @@ const a = class a {
439
445
  * @returns A TimeSpan representing the given number of nanoseconds.
440
446
  */
441
447
  static nanoseconds(t = 1) {
442
- return new a(t);
448
+ return new u(t);
443
449
  }
444
450
  /**
445
451
  * Creates a TimeSpan representing the given number of microseconds.
@@ -448,7 +454,7 @@ const a = class a {
448
454
  * @returns A TimeSpan representing the given number of microseconds.
449
455
  */
450
456
  static microseconds(t = 1) {
451
- return a.nanoseconds(t * 1e3);
457
+ return u.nanoseconds(R(t, 1e3));
452
458
  }
453
459
  /**
454
460
  * Creates a TimeSpan representing the given number of milliseconds.
@@ -457,7 +463,7 @@ const a = class a {
457
463
  * @returns A TimeSpan representing the given number of milliseconds.
458
464
  */
459
465
  static milliseconds(t = 1) {
460
- return a.microseconds(t * 1e3);
466
+ return u.microseconds(R(t, 1e3));
461
467
  }
462
468
  /**
463
469
  * Creates a TimeSpan representing the given number of seconds.
@@ -466,7 +472,7 @@ const a = class a {
466
472
  * @returns A TimeSpan representing the given number of seconds.
467
473
  */
468
474
  static seconds(t = 1) {
469
- return a.milliseconds(t * 1e3);
475
+ return u.milliseconds(R(t, 1e3));
470
476
  }
471
477
  /**
472
478
  * Creates a TimeSpan representing the given number of minutes.
@@ -474,8 +480,8 @@ const a = class a {
474
480
  * @param value - The number of minutes.
475
481
  * @returns A TimeSpan representing the given number of minutes.
476
482
  */
477
- static minutes(t) {
478
- return a.seconds(t.valueOf() * 60);
483
+ static minutes(t = 1) {
484
+ return u.seconds(R(t, 60));
479
485
  }
480
486
  /**
481
487
  * Creates a TimeSpan representing the given number of hours.
@@ -484,7 +490,7 @@ const a = class a {
484
490
  * @returns A TimeSpan representing the given number of hours.
485
491
  */
486
492
  static hours(t) {
487
- return a.minutes(t * 60);
493
+ return u.minutes(R(t, 60));
488
494
  }
489
495
  /**
490
496
  * Creates a TimeSpan representing the given number of days.
@@ -493,28 +499,28 @@ const a = class a {
493
499
  * @returns A TimeSpan representing the given number of days.
494
500
  */
495
501
  static days(t) {
496
- return a.hours(t * 24);
502
+ return u.hours(R(t, 24));
497
503
  }
498
504
  };
499
505
  /** A nanosecond. */
500
- s(a, "NANOSECOND", a.nanoseconds(1)), /** A microsecond. */
501
- s(a, "MICROSECOND", a.microseconds(1)), /** A millisecond. */
502
- s(a, "MILLISECOND", a.milliseconds(1)), /** A second. */
503
- s(a, "SECOND", a.seconds(1)), /** A minute. */
504
- s(a, "MINUTE", a.minutes(1)), /** Represents an hour. */
505
- s(a, "HOUR", a.hours(1)), /** Represents a day. */
506
- s(a, "DAY", a.days(1)), /** The maximum possible value for a TimeSpan. */
507
- s(a, "MAX", new a((1n << 63n) - 1n)), /** The minimum possible value for a TimeSpan. */
508
- s(a, "MIN", new a(0)), /** The zero value for a TimeSpan. */
509
- s(a, "ZERO", new a(0)), /** A zod schema for validating and transforming timespans */
510
- s(a, "z", o.union([
511
- o.object({ value: o.bigint() }).transform((t) => new a(t.value)),
512
- o.string().transform((t) => new a(BigInt(t))),
513
- o.instanceof(Number).transform((t) => new a(t)),
514
- o.number().transform((t) => new a(t)),
515
- o.instanceof(a)
506
+ s(u, "NANOSECOND", u.nanoseconds(1)), /** A microsecond. */
507
+ s(u, "MICROSECOND", u.microseconds(1)), /** A millisecond. */
508
+ s(u, "MILLISECOND", u.milliseconds(1)), /** A second. */
509
+ s(u, "SECOND", u.seconds(1)), /** A minute. */
510
+ s(u, "MINUTE", u.minutes(1)), /** Represents an hour. */
511
+ s(u, "HOUR", u.hours(1)), /** Represents a day. */
512
+ s(u, "DAY", u.days(1)), /** The maximum possible value for a TimeSpan. */
513
+ s(u, "MAX", new u((1n << 63n) - 1n)), /** The minimum possible value for a TimeSpan. */
514
+ s(u, "MIN", new u(0)), /** The zero value for a TimeSpan. */
515
+ s(u, "ZERO", new u(0)), /** A zod schema for validating and transforming timespans */
516
+ s(u, "z", o.union([
517
+ o.object({ value: o.bigint() }).transform((t) => new u(t.value)),
518
+ o.string().transform((t) => new u(BigInt(t))),
519
+ o.instanceof(Number).transform((t) => new u(t)),
520
+ o.number().transform((t) => new u(t)),
521
+ o.instanceof(u)
516
522
  ]));
517
- let y = a;
523
+ let y = u;
518
524
  const v = class v extends Number {
519
525
  constructor(t) {
520
526
  t instanceof Number ? super(t.valueOf()) : super(t);
@@ -598,7 +604,7 @@ s(v, "z", o.union([
598
604
  o.instanceof(Number).transform((t) => new v(t)),
599
605
  o.instanceof(v)
600
606
  ]));
601
- let q = v;
607
+ let P = v;
602
608
  const w = class w extends Number {
603
609
  /**
604
610
  * Creates a Density representing the given number of bytes per value.
@@ -614,7 +620,7 @@ const w = class w extends Number {
614
620
  return t.valueOf() / this.valueOf();
615
621
  }
616
622
  size(t) {
617
- return new C(t * this.valueOf());
623
+ return new x(t * this.valueOf());
618
624
  }
619
625
  };
620
626
  /** Unknown/Invalid Density. */
@@ -630,7 +636,7 @@ s(w, "z", o.union([
630
636
  o.instanceof(w)
631
637
  ]));
632
638
  let b = w;
633
- const I = class I {
639
+ const T = class T {
634
640
  /**
635
641
  * Creates a TimeRange from the given start and end TimeStamps.
636
642
  *
@@ -698,7 +704,7 @@ const I = class I {
698
704
  * @returns A TimeRange with the start and end swapped.
699
705
  */
700
706
  swap() {
701
- return new I(this.end, this.start);
707
+ return new T(this.end, this.start);
702
708
  }
703
709
  /**
704
710
  * Checks if the TimeRange is equal to the given TimeRange.
@@ -725,52 +731,51 @@ const I = class I {
725
731
  */
726
732
  overlapsWith(t, e = y.ZERO) {
727
733
  t = t.makeValid();
728
- const r = this.makeValid();
734
+ const n = this.makeValid();
729
735
  if (this.equals(t)) return !0;
730
- if (t.end.equals(r.start) || r.end.equals(t.start)) return !1;
731
- const u = m.max(r.start, t.start), d = m.min(r.end, t.end);
732
- return d.before(u) ? !1 : new y(d.sub(u)).greaterThanOrEqual(e);
736
+ if (t.end.equals(n.start) || n.end.equals(t.start)) return !1;
737
+ const i = m.max(n.start, t.start), c = m.min(n.end, t.end);
738
+ return c.before(i) ? !1 : new y(c.sub(i)).greaterThanOrEqual(e);
733
739
  }
734
740
  roughlyEquals(t, e) {
735
- let r = this.start.sub(t.start).valueOf(), u = this.end.sub(t.end).valueOf();
736
- return r < 0 && (r = -r), u < 0 && (u = -u), r <= e.valueOf() && u <= e.valueOf();
741
+ let n = this.start.sub(t.start).valueOf(), i = this.end.sub(t.end).valueOf();
742
+ return n < 0 && (n = -n), i < 0 && (i = -i), n <= e.valueOf() && i <= e.valueOf();
737
743
  }
738
744
  contains(t) {
739
- return t instanceof I ? this.contains(t.start) && this.contains(t.end) : this.start.beforeEq(t) && this.end.after(t);
745
+ return t instanceof T ? this.contains(t.start) && this.contains(t.end) : this.start.beforeEq(t) && this.end.after(t);
740
746
  }
741
747
  boundBy(t) {
742
- const e = new I(this.start, this.end);
748
+ const e = new T(this.start, this.end);
743
749
  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;
744
750
  }
745
751
  };
746
752
  /** The maximum possible time range. */
747
- s(I, "MAX", new I(m.MIN, m.MAX)), /** The minimum possible time range. */
748
- s(I, "MIN", new I(m.MAX, m.MIN)), /** A zero time range. */
749
- s(I, "ZERO", new I(m.ZERO, m.ZERO)), /** A zod schema for validating and transforming time ranges */
750
- s(I, "z", o.union([
751
- o.object({ start: m.z, end: m.z }).transform((t) => new I(t.start, t.end)),
752
- o.instanceof(I)
753
+ s(T, "MAX", new T(m.MIN, m.MAX)), /** The minimum possible time range. */
754
+ s(T, "MIN", new T(m.MAX, m.MIN)), /** A zero time range. */
755
+ s(T, "ZERO", new T(m.ZERO, m.ZERO)), /** A zod schema for validating and transforming time ranges */
756
+ s(T, "z", o.union([
757
+ o.object({ start: m.z, end: m.z }).transform((t) => new T(t.start, t.end)),
758
+ o.instanceof(T)
753
759
  ]));
754
- let B = I;
755
- const n = class n extends String {
760
+ let E = T;
761
+ const r = class r extends String {
756
762
  constructor(t) {
757
- if (t instanceof n || typeof t == "string" || typeof t.valueOf() == "string") {
763
+ if (t instanceof r || typeof t == "string" || typeof t.valueOf() == "string") {
758
764
  super(t.valueOf());
759
765
  return;
760
- } else {
761
- const e = n.ARRAY_CONSTRUCTOR_DATA_TYPES.get(t.constructor.name);
762
- if (e != null) {
763
- super(e.valueOf());
764
- return;
765
- }
766
766
  }
767
- throw super(n.UNKNOWN.valueOf()), new Error(`unable to find data type for ${t.toString()}`);
767
+ const e = r.ARRAY_CONSTRUCTOR_DATA_TYPES.get(t.constructor.name);
768
+ if (e != null) {
769
+ super(e.valueOf());
770
+ return;
771
+ }
772
+ throw super(r.UNKNOWN.valueOf()), new Error(`unable to find data type for ${t.toString()}`);
768
773
  }
769
774
  /**
770
775
  * @returns the TypedArray constructor for the DataType.
771
776
  */
772
777
  get Array() {
773
- const t = n.ARRAY_CONSTRUCTORS.get(this.toString());
778
+ const t = r.ARRAY_CONSTRUCTORS.get(this.toString());
774
779
  if (t == null)
775
780
  throw new Error(`unable to find array constructor for ${this.valueOf()}`);
776
781
  return t;
@@ -792,10 +797,10 @@ const n = class n extends String {
792
797
  return this.valueOf();
793
798
  }
794
799
  get isVariable() {
795
- return this.equals(n.JSON) || this.equals(n.STRING);
800
+ return this.equals(r.JSON) || this.equals(r.STRING);
796
801
  }
797
802
  get isNumeric() {
798
- return !this.isVariable && !this.equals(n.UUID);
803
+ return !this.isVariable && !this.equals(r.UUID);
799
804
  }
800
805
  get isInteger() {
801
806
  return this.toString().startsWith("int");
@@ -804,7 +809,7 @@ const n = class n extends String {
804
809
  return this.toString().startsWith("float");
805
810
  }
806
811
  get density() {
807
- const t = n.DENSITIES.get(this.toString());
812
+ const t = r.DENSITIES.get(this.toString());
808
813
  if (t == null) throw new Error(`unable to find density for ${this.valueOf()}`);
809
814
  return t;
810
815
  }
@@ -829,92 +834,92 @@ const n = class n extends String {
829
834
  return this.toString();
830
835
  }
831
836
  get usesBigInt() {
832
- return n.BIG_INT_TYPES.some((t) => t.equals(this));
837
+ return r.BIG_INT_TYPES.some((t) => t.equals(this));
833
838
  }
834
839
  };
835
840
  /** Represents an Unknown/Invalid DataType. */
836
- s(n, "UNKNOWN", new n("unknown")), /** Represents a 64-bit floating point value. */
837
- s(n, "FLOAT64", new n("float64")), /** Represents a 32-bit floating point value. */
838
- s(n, "FLOAT32", new n("float32")), /** Represents a 64-bit signed integer value. */
839
- s(n, "INT64", new n("int64")), /** Represents a 32-bit signed integer value. */
840
- s(n, "INT32", new n("int32")), /** Represents a 16-bit signed integer value. */
841
- s(n, "INT16", new n("int16")), /** Represents a 8-bit signed integer value. */
842
- s(n, "INT8", new n("int8")), /** Represents a 64-bit unsigned integer value. */
843
- s(n, "UINT64", new n("uint64")), /** Represents a 32-bit unsigned integer value. */
844
- s(n, "UINT32", new n("uint32")), /** Represents a 16-bit unsigned integer value. */
845
- s(n, "UINT16", new n("uint16")), /** Represents a 8-bit unsigned integer value. */
846
- s(n, "UINT8", new n("uint8")), /** Represents a boolean value. Alias for UINT8. */
847
- s(n, "BOOLEAN", n.UINT8), /** Represents a 64-bit unix epoch. */
848
- s(n, "TIMESTAMP", new n("timestamp")), /** Represents a UUID data type */
849
- s(n, "UUID", new n("uuid")), /** Represents a string data type. Strings have an unknown density, and are separate
841
+ s(r, "UNKNOWN", new r("unknown")), /** Represents a 64-bit floating point value. */
842
+ s(r, "FLOAT64", new r("float64")), /** Represents a 32-bit floating point value. */
843
+ s(r, "FLOAT32", new r("float32")), /** Represents a 64-bit signed integer value. */
844
+ s(r, "INT64", new r("int64")), /** Represents a 32-bit signed integer value. */
845
+ s(r, "INT32", new r("int32")), /** Represents a 16-bit signed integer value. */
846
+ s(r, "INT16", new r("int16")), /** Represents a 8-bit signed integer value. */
847
+ s(r, "INT8", new r("int8")), /** Represents a 64-bit unsigned integer value. */
848
+ s(r, "UINT64", new r("uint64")), /** Represents a 32-bit unsigned integer value. */
849
+ s(r, "UINT32", new r("uint32")), /** Represents a 16-bit unsigned integer value. */
850
+ s(r, "UINT16", new r("uint16")), /** Represents a 8-bit unsigned integer value. */
851
+ s(r, "UINT8", new r("uint8")), /** Represents a boolean value. Alias for UINT8. */
852
+ s(r, "BOOLEAN", r.UINT8), /** Represents a 64-bit unix epoch. */
853
+ s(r, "TIMESTAMP", new r("timestamp")), /** Represents a UUID data type */
854
+ s(r, "UUID", new r("uuid")), /** Represents a string data type. Strings have an unknown density, and are separate
850
855
  * by a newline character. */
851
- s(n, "STRING", new n("string")), /** Represents a JSON data type. JSON has an unknown density, and is separated by a
856
+ s(r, "STRING", new r("string")), /** Represents a JSON data type. JSON has an unknown density, and is separated by a
852
857
  * newline character. */
853
- s(n, "JSON", new n("json")), s(n, "ARRAY_CONSTRUCTORS", /* @__PURE__ */ new Map([
854
- [n.UINT8.toString(), Uint8Array],
855
- [n.UINT16.toString(), Uint16Array],
856
- [n.UINT32.toString(), Uint32Array],
857
- [n.UINT64.toString(), BigUint64Array],
858
- [n.FLOAT32.toString(), Float32Array],
859
- [n.FLOAT64.toString(), Float64Array],
860
- [n.INT8.toString(), Int8Array],
861
- [n.INT16.toString(), Int16Array],
862
- [n.INT32.toString(), Int32Array],
863
- [n.INT64.toString(), BigInt64Array],
864
- [n.TIMESTAMP.toString(), BigInt64Array],
865
- [n.STRING.toString(), Uint8Array],
866
- [n.JSON.toString(), Uint8Array],
867
- [n.UUID.toString(), Uint8Array]
868
- ])), s(n, "ARRAY_CONSTRUCTOR_DATA_TYPES", /* @__PURE__ */ new Map([
869
- [Uint8Array.name, n.UINT8],
870
- [Uint16Array.name, n.UINT16],
871
- [Uint32Array.name, n.UINT32],
872
- [BigUint64Array.name, n.UINT64],
873
- [Float32Array.name, n.FLOAT32],
874
- [Float64Array.name, n.FLOAT64],
875
- [Int8Array.name, n.INT8],
876
- [Int16Array.name, n.INT16],
877
- [Int32Array.name, n.INT32],
878
- [BigInt64Array.name, n.INT64]
879
- ])), s(n, "DENSITIES", /* @__PURE__ */ new Map([
880
- [n.UINT8.toString(), b.BIT8],
881
- [n.UINT16.toString(), b.BIT16],
882
- [n.UINT32.toString(), b.BIT32],
883
- [n.UINT64.toString(), b.BIT64],
884
- [n.FLOAT32.toString(), b.BIT32],
885
- [n.FLOAT64.toString(), b.BIT64],
886
- [n.INT8.toString(), b.BIT8],
887
- [n.INT16.toString(), b.BIT16],
888
- [n.INT32.toString(), b.BIT32],
889
- [n.INT64.toString(), b.BIT64],
890
- [n.TIMESTAMP.toString(), b.BIT64],
891
- [n.STRING.toString(), b.UNKNOWN],
892
- [n.JSON.toString(), b.UNKNOWN],
893
- [n.UUID.toString(), b.BIT128]
858
+ s(r, "JSON", new r("json")), s(r, "ARRAY_CONSTRUCTORS", /* @__PURE__ */ new Map([
859
+ [r.UINT8.toString(), Uint8Array],
860
+ [r.UINT16.toString(), Uint16Array],
861
+ [r.UINT32.toString(), Uint32Array],
862
+ [r.UINT64.toString(), BigUint64Array],
863
+ [r.FLOAT32.toString(), Float32Array],
864
+ [r.FLOAT64.toString(), Float64Array],
865
+ [r.INT8.toString(), Int8Array],
866
+ [r.INT16.toString(), Int16Array],
867
+ [r.INT32.toString(), Int32Array],
868
+ [r.INT64.toString(), BigInt64Array],
869
+ [r.TIMESTAMP.toString(), BigInt64Array],
870
+ [r.STRING.toString(), Uint8Array],
871
+ [r.JSON.toString(), Uint8Array],
872
+ [r.UUID.toString(), Uint8Array]
873
+ ])), s(r, "ARRAY_CONSTRUCTOR_DATA_TYPES", /* @__PURE__ */ new Map([
874
+ [Uint8Array.name, r.UINT8],
875
+ [Uint16Array.name, r.UINT16],
876
+ [Uint32Array.name, r.UINT32],
877
+ [BigUint64Array.name, r.UINT64],
878
+ [Float32Array.name, r.FLOAT32],
879
+ [Float64Array.name, r.FLOAT64],
880
+ [Int8Array.name, r.INT8],
881
+ [Int16Array.name, r.INT16],
882
+ [Int32Array.name, r.INT32],
883
+ [BigInt64Array.name, r.INT64]
884
+ ])), s(r, "DENSITIES", /* @__PURE__ */ new Map([
885
+ [r.UINT8.toString(), b.BIT8],
886
+ [r.UINT16.toString(), b.BIT16],
887
+ [r.UINT32.toString(), b.BIT32],
888
+ [r.UINT64.toString(), b.BIT64],
889
+ [r.FLOAT32.toString(), b.BIT32],
890
+ [r.FLOAT64.toString(), b.BIT64],
891
+ [r.INT8.toString(), b.BIT8],
892
+ [r.INT16.toString(), b.BIT16],
893
+ [r.INT32.toString(), b.BIT32],
894
+ [r.INT64.toString(), b.BIT64],
895
+ [r.TIMESTAMP.toString(), b.BIT64],
896
+ [r.STRING.toString(), b.UNKNOWN],
897
+ [r.JSON.toString(), b.UNKNOWN],
898
+ [r.UUID.toString(), b.BIT128]
894
899
  ])), /** All the data types. */
895
- s(n, "ALL", [
896
- n.UNKNOWN,
897
- n.FLOAT64,
898
- n.FLOAT32,
899
- n.INT64,
900
- n.INT32,
901
- n.INT16,
902
- n.INT8,
903
- n.UINT64,
904
- n.UINT32,
905
- n.UINT16,
906
- n.UINT8,
907
- n.TIMESTAMP,
908
- n.UUID,
909
- n.STRING,
910
- n.JSON
911
- ]), s(n, "BIG_INT_TYPES", [n.INT64, n.UINT64, n.TIMESTAMP]), /** A zod schema for a DataType. */
912
- s(n, "z", o.union([
913
- o.string().transform((t) => new n(t)),
914
- o.instanceof(n)
900
+ s(r, "ALL", [
901
+ r.UNKNOWN,
902
+ r.FLOAT64,
903
+ r.FLOAT32,
904
+ r.INT64,
905
+ r.INT32,
906
+ r.INT16,
907
+ r.INT8,
908
+ r.UINT64,
909
+ r.UINT32,
910
+ r.UINT16,
911
+ r.UINT8,
912
+ r.TIMESTAMP,
913
+ r.UUID,
914
+ r.STRING,
915
+ r.JSON
916
+ ]), s(r, "BIG_INT_TYPES", [r.INT64, r.UINT64, r.TIMESTAMP]), /** A zod schema for a DataType. */
917
+ s(r, "z", o.union([
918
+ o.string().transform((t) => new r(t)),
919
+ o.instanceof(r)
915
920
  ]));
916
- let h = n;
917
- const l = class l extends Number {
921
+ let g = r;
922
+ const d = class d extends Number {
918
923
  constructor(t) {
919
924
  super(t.valueOf());
920
925
  }
@@ -927,33 +932,33 @@ const l = class l extends Number {
927
932
  return this.valueOf() < t.valueOf();
928
933
  }
929
934
  add(t) {
930
- return l.bytes(this.valueOf() + t.valueOf());
935
+ return d.bytes(this.valueOf() + t.valueOf());
931
936
  }
932
937
  sub(t) {
933
- return l.bytes(this.valueOf() - t.valueOf());
938
+ return d.bytes(this.valueOf() - t.valueOf());
934
939
  }
935
940
  truncate(t) {
936
- return new l(Math.trunc(this.valueOf() / t.valueOf()) * t.valueOf());
941
+ return new d(Math.trunc(this.valueOf() / t.valueOf()) * t.valueOf());
937
942
  }
938
943
  remainder(t) {
939
- return l.bytes(this.valueOf() % t.valueOf());
944
+ return d.bytes(this.valueOf() % t.valueOf());
940
945
  }
941
946
  get gigabytes() {
942
- return this.valueOf() / l.GIGABYTE.valueOf();
947
+ return this.valueOf() / d.GIGABYTE.valueOf();
943
948
  }
944
949
  get megabytes() {
945
- return this.valueOf() / l.MEGABYTE.valueOf();
950
+ return this.valueOf() / d.MEGABYTE.valueOf();
946
951
  }
947
952
  get kilobytes() {
948
- return this.valueOf() / l.KILOBYTE.valueOf();
953
+ return this.valueOf() / d.KILOBYTE.valueOf();
949
954
  }
950
955
  get terabytes() {
951
- return this.valueOf() / l.TERABYTE.valueOf();
956
+ return this.valueOf() / d.TERABYTE.valueOf();
952
957
  }
953
958
  toString() {
954
- const t = this.truncate(l.TERABYTE), e = this.truncate(l.GIGABYTE), r = this.truncate(l.MEGABYTE), u = this.truncate(l.KILOBYTE), d = this.truncate(l.BYTE), g = t, S = e.sub(t), O = r.sub(e), N = u.sub(r), p = d.sub(u);
955
- let c = "";
956
- return g.isZero || (c += `${g.terabytes}TB `), S.isZero || (c += `${S.gigabytes}GB `), O.isZero || (c += `${O.megabytes}MB `), N.isZero || (c += `${N.kilobytes}KB `), (!p.isZero || c === "") && (c += `${p.valueOf()}B`), c.trim();
959
+ const t = this.truncate(d.TERABYTE), e = this.truncate(d.GIGABYTE), n = this.truncate(d.MEGABYTE), i = this.truncate(d.KILOBYTE), c = this.truncate(d.BYTE), h = t, S = e.sub(t), O = n.sub(e), N = i.sub(n), p = c.sub(i);
960
+ let f = "";
961
+ return h.isZero || (f += `${h.terabytes}TB `), S.isZero || (f += `${S.gigabytes}GB `), O.isZero || (f += `${O.megabytes}MB `), N.isZero || (f += `${N.kilobytes}KB `), (!p.isZero || f === "") && (f += `${p.valueOf()}B`), f.trim();
957
962
  }
958
963
  /**
959
964
  * Creates a Size from the given number of bytes.
@@ -962,7 +967,7 @@ const l = class l extends Number {
962
967
  * @returns A Size representing the given number of bytes.
963
968
  */
964
969
  static bytes(t = 1) {
965
- return new l(t);
970
+ return new d(t);
966
971
  }
967
972
  /**
968
973
  * Creates a Size from the given number if kilobytes.
@@ -971,7 +976,7 @@ const l = class l extends Number {
971
976
  * @returns A Size representing the given number of kilobytes.
972
977
  */
973
978
  static kilobytes(t = 1) {
974
- return l.bytes(t.valueOf() * 1e3);
979
+ return d.bytes(t.valueOf() * 1e3);
975
980
  }
976
981
  /**
977
982
  * Creates a Size from the given number of megabytes.
@@ -980,7 +985,7 @@ const l = class l extends Number {
980
985
  * @returns A Size representing the given number of megabytes.
981
986
  */
982
987
  static megabytes(t = 1) {
983
- return l.kilobytes(t.valueOf() * 1e3);
988
+ return d.kilobytes(t.valueOf() * 1e3);
984
989
  }
985
990
  /**
986
991
  * Creates a Size from the given number of gigabytes.
@@ -989,7 +994,7 @@ const l = class l extends Number {
989
994
  * @returns A Size representing the given number of gigabytes.
990
995
  */
991
996
  static gigabytes(t = 1) {
992
- return l.megabytes(t.valueOf() * 1e3);
997
+ return d.megabytes(t.valueOf() * 1e3);
993
998
  }
994
999
  /**
995
1000
  * Creates a Size from the given number of terabytes.
@@ -998,25 +1003,25 @@ const l = class l extends Number {
998
1003
  * @returns A Size representing the given number of terabytes.
999
1004
  */
1000
1005
  static terabytes(t) {
1001
- return l.gigabytes(t.valueOf() * 1e3);
1006
+ return d.gigabytes(t.valueOf() * 1e3);
1002
1007
  }
1003
1008
  get isZero() {
1004
1009
  return this.valueOf() === 0;
1005
1010
  }
1006
1011
  };
1007
1012
  /** A single byte */
1008
- s(l, "BYTE", new l(1)), /** A kilobyte */
1009
- s(l, "KILOBYTE", l.kilobytes(1)), /** A megabyte */
1010
- s(l, "MEGABYTE", l.megabytes(1)), /** A gigabyte */
1011
- s(l, "GIGABYTE", l.gigabytes(1)), /** A terabyte. */
1012
- s(l, "TERABYTE", l.terabytes(1)), /** The zero value for Size */
1013
- s(l, "ZERO", new l(0)), /** A zod schema for a Size. */
1014
- s(l, "z", o.union([
1015
- o.number().transform((t) => new l(t)),
1016
- o.instanceof(l)
1013
+ s(d, "BYTE", new d(1)), /** A kilobyte */
1014
+ s(d, "KILOBYTE", d.kilobytes(1)), /** A megabyte */
1015
+ s(d, "MEGABYTE", d.megabytes(1)), /** A gigabyte */
1016
+ s(d, "GIGABYTE", d.gigabytes(1)), /** A terabyte. */
1017
+ s(d, "TERABYTE", d.terabytes(1)), /** The zero value for Size */
1018
+ s(d, "ZERO", new d(0)), /** A zod schema for a Size. */
1019
+ s(d, "z", o.union([
1020
+ o.number().transform((t) => new d(t)),
1021
+ o.instanceof(d)
1017
1022
  ]));
1018
- let C = l;
1019
- const St = o.union([
1023
+ let x = d;
1024
+ const xt = o.union([
1020
1025
  o.instanceof(Uint8Array),
1021
1026
  o.instanceof(Uint16Array),
1022
1027
  o.instanceof(Uint32Array),
@@ -1027,14 +1032,17 @@ const St = o.union([
1027
1032
  o.instanceof(Int16Array),
1028
1033
  o.instanceof(Int32Array),
1029
1034
  o.instanceof(BigInt64Array)
1030
- ]), W = (f) => {
1031
- const t = typeof f;
1032
- return t === "string" || t === "number" || t === "boolean" || t === "bigint" || f instanceof m || f instanceof y || f instanceof Date;
1033
- }, et = (f, t, e, r = 0) => f.usesBigInt && !t.usesBigInt ? Number(e) - Number(r) : !f.usesBigInt && t.usesBigInt ? BigInt(e) - BigInt(r) : R(e, -r), rt = (f) => f == null ? !1 : Array.isArray(f) || f instanceof ArrayBuffer || ArrayBuffer.isView(f) && !(f instanceof DataView) || f instanceof x ? !0 : W(f), E = -1, nt = o.string().transform(
1034
- (f) => new Uint8Array(
1035
- atob(f).split("").map((t) => t.charCodeAt(0))
1035
+ ]), _ = (l) => {
1036
+ const t = typeof l;
1037
+ return t === "string" || t === "number" || t === "boolean" || t === "bigint" || l instanceof m || l instanceof y || l instanceof Date;
1038
+ }, ct = (l, t, e, n = 0) => l.usesBigInt && !t.usesBigInt ? Number(e) - Number(n) : !l.usesBigInt && t.usesBigInt ? BigInt(e.valueOf()) - BigInt(n.valueOf()) : C(e, -n).valueOf(), ft = (l) => l == null ? !1 : Array.isArray(l) || l instanceof ArrayBuffer || ArrayBuffer.isView(l) && !(l instanceof DataView) || l instanceof V ? !0 : _(l), B = -1, q = {
1039
+ [Symbol.iterator]: () => q,
1040
+ next: () => ({ done: !0, value: void 0 })
1041
+ }, ht = o.string().transform(
1042
+ (l) => new Uint8Array(
1043
+ atob(l).split("").map((t) => t.charCodeAt(0))
1036
1044
  ).buffer
1037
- ), st = o.union([o.null(), o.undefined()]).transform(() => new Uint8Array().buffer), T = class T {
1045
+ ), dt = o.union([o.null(), o.undefined()]).transform(() => new Uint8Array().buffer), Y = 10, I = class I {
1038
1046
  constructor(t) {
1039
1047
  s(this, "key", "");
1040
1048
  s(this, "isSynnaxSeries", !0);
@@ -1059,104 +1067,107 @@ const St = o.union([
1059
1067
  /** A cached maximum value. */
1060
1068
  s(this, "_cachedMax");
1061
1069
  /** The write position of the buffer. */
1062
- s(this, "writePos", E);
1070
+ s(this, "writePos", B);
1063
1071
  /** Tracks the number of entities currently using this array. */
1064
1072
  s(this, "_refCount", 0);
1073
+ /** Caches the length of the array for variable length data types. */
1065
1074
  s(this, "_cachedLength");
1066
- rt(t) && (t = { data: t });
1075
+ /** Caches the indexes of the array for variable length data types. */
1076
+ s(this, "_cachedIndexes");
1077
+ ft(t) && (t = { data: t });
1067
1078
  const {
1068
1079
  dataType: e,
1069
- timeRange: r,
1070
- sampleOffset: u = 0,
1071
- glBufferUsage: d = "static",
1072
- alignment: g = 0n,
1073
- key: S = k()
1080
+ timeRange: n,
1081
+ sampleOffset: i = 0,
1082
+ glBufferUsage: c = "static",
1083
+ alignment: h = 0n,
1084
+ key: S = X()
1074
1085
  } = t, O = t.data ?? [];
1075
- if (O instanceof T || typeof O == "object" && "isSynnaxSeries" in O && O.isSynnaxSeries === !0) {
1076
- const c = O;
1077
- this.key = c.key, this.dataType = c.dataType, this.sampleOffset = c.sampleOffset, this.gl = c.gl, this._data = c._data, this._timeRange = c._timeRange, this.alignment = c.alignment, this._cachedMin = c._cachedMin, this._cachedMax = c._cachedMax, this.writePos = c.writePos, this._refCount = c._refCount, this._cachedLength = c._cachedLength;
1086
+ if (O instanceof I || typeof O == "object" && "isSynnaxSeries" in O && O.isSynnaxSeries === !0) {
1087
+ const f = O;
1088
+ 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;
1078
1089
  return;
1079
1090
  }
1080
- const N = W(O), p = Array.isArray(O);
1081
- if (e != null) this.dataType = new h(e);
1091
+ const N = _(O), p = Array.isArray(O);
1092
+ if (e != null) this.dataType = new g(e);
1082
1093
  else {
1083
1094
  if (O instanceof ArrayBuffer)
1084
1095
  throw new Error(
1085
1096
  "cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type."
1086
1097
  );
1087
1098
  if (p || N) {
1088
- let c = O;
1099
+ let f = O;
1089
1100
  if (!N) {
1090
1101
  if (O.length === 0)
1091
1102
  throw new Error(
1092
1103
  "cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type."
1093
1104
  );
1094
- c = O[0];
1105
+ f = O[0];
1095
1106
  }
1096
- if (typeof c == "string") this.dataType = h.STRING;
1097
- else if (typeof c == "number") this.dataType = h.FLOAT64;
1098
- else if (typeof c == "bigint") this.dataType = h.INT64;
1099
- else if (typeof c == "boolean") this.dataType = h.BOOLEAN;
1100
- else if (c instanceof m || c instanceof Date || c instanceof m)
1101
- this.dataType = h.TIMESTAMP;
1102
- else if (typeof c == "object") this.dataType = h.JSON;
1107
+ if (typeof f == "string") this.dataType = g.STRING;
1108
+ else if (typeof f == "number") this.dataType = g.FLOAT64;
1109
+ else if (typeof f == "bigint") this.dataType = g.INT64;
1110
+ else if (typeof f == "boolean") this.dataType = g.BOOLEAN;
1111
+ else if (f instanceof m || f instanceof Date || f instanceof m)
1112
+ this.dataType = g.TIMESTAMP;
1113
+ else if (typeof f == "object") this.dataType = g.JSON;
1103
1114
  else
1104
1115
  throw new Error(
1105
- `cannot infer data type of ${typeof c} when constructing a Series from a JS array`
1116
+ `cannot infer data type of ${typeof f} when constructing a Series from a JS array`
1106
1117
  );
1107
- } else this.dataType = new h(O);
1118
+ } else this.dataType = new g(O);
1108
1119
  }
1109
1120
  if (!p && !N) this._data = O;
1110
1121
  else {
1111
- let c = N ? [O] : O;
1112
- const M = c[0];
1113
- (M instanceof m || M instanceof Date || M instanceof y) && (c = c.map((U) => new m(U).valueOf())), this.dataType.equals(h.STRING) ? (this._cachedLength = c.length, this._data = new TextEncoder().encode(c.join(`
1114
- `) + `
1115
- `)) : this.dataType.equals(h.JSON) ? (this._cachedLength = c.length, this._data = new TextEncoder().encode(
1116
- c.map((U) => L.encodeString(U)).join(`
1117
- `) + `
1122
+ let f = N ? [O] : O;
1123
+ const M = f[0];
1124
+ (M instanceof m || M instanceof Date || M instanceof y) && (f = f.map((U) => new m(U).valueOf())), this.dataType.equals(g.STRING) ? (this._cachedLength = f.length, this._data = new TextEncoder().encode(`${f.join(`
1125
+ `)}
1126
+ `)) : this.dataType.equals(g.JSON) ? (this._cachedLength = f.length, this._data = new TextEncoder().encode(
1127
+ `${f.map((U) => $.encodeString(U)).join(`
1128
+ `)}
1118
1129
  `
1119
- )) : this._data = new this.dataType.Array(c).buffer;
1130
+ )) : this._data = new this.dataType.Array(f).buffer;
1120
1131
  }
1121
- this.key = S, this.alignment = g, this.sampleOffset = u ?? 0, this._timeRange = r, this.gl = {
1132
+ this.key = S, this.alignment = h, this.sampleOffset = i ?? 0, this._timeRange = n, this.gl = {
1122
1133
  control: null,
1123
1134
  buffer: null,
1124
1135
  prevBuffer: 0,
1125
- bufferUsage: d
1136
+ bufferUsage: c
1126
1137
  };
1127
1138
  }
1128
- static alloc({ capacity: t, dataType: e, ...r }) {
1139
+ static alloc({ capacity: t, dataType: e, ...n }) {
1129
1140
  if (t === 0)
1130
1141
  throw new Error("[Series] - cannot allocate an array of length 0");
1131
- const u = new new h(e).Array(t), d = new T({
1132
- data: u.buffer,
1142
+ const i = new new g(e).Array(t), c = new I({
1143
+ data: i.buffer,
1133
1144
  dataType: e,
1134
- ...r
1145
+ ...n
1135
1146
  });
1136
- return d.writePos = 0, d;
1147
+ return c.writePos = 0, c;
1137
1148
  }
1138
- static generateTimestamps(t, e, r) {
1139
- const u = r.spanRange(e.span(t)), d = new BigInt64Array(t);
1140
- for (let g = 0; g < t; g++)
1141
- d[g] = BigInt(r.add(e.span(g)).valueOf());
1142
- return new T({ data: d, dataType: h.TIMESTAMP, timeRange: u });
1149
+ static generateTimestamps(t, e, n) {
1150
+ const i = n.spanRange(e.span(t)), c = new BigInt64Array(t);
1151
+ for (let h = 0; h < t; h++)
1152
+ c[h] = BigInt(n.add(e.span(h)).valueOf());
1153
+ return new I({ data: c, dataType: g.TIMESTAMP, timeRange: i });
1143
1154
  }
1144
1155
  get refCount() {
1145
1156
  return this._refCount;
1146
1157
  }
1147
1158
  static fromStrings(t, e) {
1148
- const r = new TextEncoder().encode(t.join(`
1149
- `) + `
1159
+ const n = new TextEncoder().encode(`${t.join(`
1160
+ `)}
1150
1161
  `);
1151
- return new T({ data: r, dataType: h.STRING, timeRange: e });
1162
+ return new I({ data: n, dataType: g.STRING, timeRange: e });
1152
1163
  }
1153
1164
  static fromJSON(t, e) {
1154
- const r = new TextEncoder().encode(
1155
- t.map((u) => L.encodeString(u)).join(`
1156
- `) + `
1165
+ const n = new TextEncoder().encode(
1166
+ `${t.map((i) => $.encodeString(i)).join(`
1167
+ `)}
1157
1168
  `
1158
1169
  );
1159
- return new T({ data: r, dataType: h.JSON, timeRange: e });
1170
+ return new I({ data: n, dataType: g.JSON, timeRange: e });
1160
1171
  }
1161
1172
  acquire(t) {
1162
1173
  this._refCount++, t != null && this.updateGLBuffer(t);
@@ -1178,45 +1189,56 @@ const St = o.union([
1178
1189
  write(t) {
1179
1190
  if (!t.dataType.equals(this.dataType))
1180
1191
  throw new Error("buffer must be of the same type as this array");
1181
- if (this.writePos === E) return 0;
1182
- const e = this.capacity - this.writePos, r = e < t.length ? t.slice(0, e) : t;
1183
- return this.underlyingData.set(
1184
- r.data,
1192
+ return this.dataType.isVariable ? this.writeVariable(t) : this.writeFixed(t);
1193
+ }
1194
+ writeVariable(t) {
1195
+ if (this.writePos === B) return 0;
1196
+ const e = this.byteCapacity.valueOf() - this.writePos, n = t.subBytes(0, e);
1197
+ return this.writeToUnderlyingData(n), this.writePos += n.byteLength.valueOf(), this._cachedLength != null && (this._cachedLength += n.length, this.calculateCachedLength()), n.length;
1198
+ }
1199
+ writeFixed(t) {
1200
+ if (this.writePos === B) return 0;
1201
+ const e = this.capacity - this.writePos, n = t.sub(0, e);
1202
+ return this.writeToUnderlyingData(n), this._cachedLength = void 0, this.maybeRecomputeMinMax(n), this.writePos += n.length, n.length;
1203
+ }
1204
+ writeToUnderlyingData(t) {
1205
+ this.underlyingData.set(
1206
+ t.data,
1185
1207
  this.writePos
1186
- ), this.maybeRecomputeMinMax(r), this._cachedLength = void 0, this.writePos += r.length, r.length;
1208
+ );
1187
1209
  }
1188
1210
  /** @returns the underlying buffer backing this array. */
1189
1211
  get buffer() {
1190
- return this._data;
1212
+ return this._data instanceof ArrayBuffer || this._data instanceof SharedArrayBuffer ? this._data : this._data.buffer;
1191
1213
  }
1192
1214
  get underlyingData() {
1193
1215
  return new this.dataType.Array(this._data);
1194
1216
  }
1195
1217
  /** @returns a native typed array with the proper data type. */
1196
1218
  get data() {
1197
- return this.writePos === E ? this.underlyingData : new this.dataType.Array(this._data, 0, this.writePos);
1219
+ return this.writePos === B ? this.underlyingData : new this.dataType.Array(this._data, 0, this.writePos);
1198
1220
  }
1199
1221
  toStrings() {
1200
- if (!this.dataType.matches(h.STRING, h.UUID))
1222
+ if (!this.dataType.matches(g.STRING, g.UUID))
1201
1223
  throw new Error("cannot convert non-string series to strings");
1202
- return new TextDecoder().decode(this.buffer).split(`
1224
+ return new TextDecoder().decode(this.underlyingData).split(`
1203
1225
  `).slice(0, -1);
1204
1226
  }
1205
1227
  toUUIDs() {
1206
- if (!this.dataType.equals(h.UUID))
1228
+ if (!this.dataType.equals(g.UUID))
1207
1229
  throw new Error("cannot convert non-uuid series to uuids");
1208
- const t = h.UUID.density.valueOf(), e = Array(this.length);
1209
- for (let r = 0; r < this.length; r++) {
1210
- const u = this.buffer.slice(r * t, (r + 1) * t), d = Array.from(new Uint8Array(u), (g) => g.toString(16).padStart(2, "0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/, "$1-$2-$3-$4-$5");
1211
- e[r] = d;
1230
+ const t = g.UUID.density.valueOf(), e = Array(this.length);
1231
+ for (let n = 0; n < this.length; n++) {
1232
+ const i = this.underlyingData.slice(n * t, (n + 1) * t), c = Array.from(new Uint8Array(i), (h) => h.toString(16).padStart(2, "0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/, "$1-$2-$3-$4-$5");
1233
+ e[n] = c;
1212
1234
  }
1213
1235
  return e;
1214
1236
  }
1215
1237
  parseJSON(t) {
1216
- if (!this.dataType.equals(h.JSON))
1238
+ if (!this.dataType.equals(g.JSON))
1217
1239
  throw new Error("cannot convert non-string series to strings");
1218
- return new TextDecoder().decode(this.buffer).split(`
1219
- `).slice(0, -1).map((e) => t.parse(L.decodeString(e)));
1240
+ return new TextDecoder().decode(this.underlyingData).split(`
1241
+ `).slice(0, -1).map((e) => t.parse($.decodeString(e)));
1220
1242
  }
1221
1243
  /** @returns the time range of this array. */
1222
1244
  get timeRange() {
@@ -1225,27 +1247,28 @@ const St = o.union([
1225
1247
  }
1226
1248
  /** @returns the capacity of the series in bytes. */
1227
1249
  get byteCapacity() {
1228
- return new C(this.buffer.byteLength);
1250
+ return new x(this.underlyingData.byteLength);
1229
1251
  }
1230
1252
  /** @returns the capacity of the series in samples. */
1231
1253
  get capacity() {
1232
- return this.dataType.density.length(this.byteCapacity);
1254
+ return this.dataType.isVariable ? this.byteCapacity.valueOf() : this.dataType.density.length(this.byteCapacity);
1233
1255
  }
1234
1256
  /** @returns the length of the series in bytes. */
1235
1257
  get byteLength() {
1236
- return this.writePos === E ? this.byteCapacity : this.dataType.density.size(this.writePos);
1258
+ return this.writePos === B ? this.byteCapacity : this.dataType.isVariable ? new x(this.writePos) : this.dataType.density.size(this.writePos);
1237
1259
  }
1238
1260
  /** @returns the number of samples in this array. */
1239
1261
  get length() {
1240
- return this._cachedLength != null ? this._cachedLength : this.dataType.isVariable ? this.calculateCachedLength() : this.writePos === E ? this.data.length : this.writePos;
1262
+ return this._cachedLength != null ? this._cachedLength : this.dataType.isVariable ? this.calculateCachedLength() : this.writePos === B ? this.data.length : this.writePos;
1241
1263
  }
1242
1264
  calculateCachedLength() {
1243
1265
  if (!this.dataType.isVariable)
1244
1266
  throw new Error("cannot calculate length of a non-variable length data type");
1245
1267
  let t = 0;
1246
- return this.data.forEach((e) => {
1247
- e === 10 && t++;
1248
- }), this._cachedLength = t, t;
1268
+ const e = [0];
1269
+ return this.data.forEach((n, i) => {
1270
+ n === Y && (t++, e.push(i + 1));
1271
+ }), this._cachedIndexes = e, this._cachedLength = t, t;
1249
1272
  }
1250
1273
  /**
1251
1274
  * Creates a new array with a different data type.
@@ -1258,11 +1281,11 @@ const St = o.union([
1258
1281
  */
1259
1282
  convert(t, e = 0) {
1260
1283
  if (this.dataType.equals(t)) return this;
1261
- const r = new t.Array(this.length);
1262
- for (let u = 0; u < this.length; u++)
1263
- r[u] = et(this.dataType, t, this.data[u], e);
1264
- return new T({
1265
- data: r.buffer,
1284
+ const n = new t.Array(this.length);
1285
+ for (let i = 0; i < this.length; i++)
1286
+ n[i] = ct(this.dataType, t, this.data[i], e);
1287
+ return new I({
1288
+ data: n.buffer,
1266
1289
  dataType: t,
1267
1290
  timeRange: this._timeRange,
1268
1291
  sampleOffset: e,
@@ -1272,14 +1295,14 @@ const St = o.union([
1272
1295
  }
1273
1296
  calcRawMax() {
1274
1297
  if (this.length === 0) return -1 / 0;
1275
- if (this.dataType.equals(h.TIMESTAMP))
1298
+ if (this.dataType.equals(g.TIMESTAMP))
1276
1299
  this._cachedMax = this.data[this.data.length - 1];
1277
1300
  else if (this.dataType.usesBigInt) {
1278
1301
  const t = this.data;
1279
- this._cachedMax = t.reduce((e, r) => e > r ? e : r);
1302
+ this._cachedMax = t.reduce((e, n) => e > n ? e : n);
1280
1303
  } else {
1281
1304
  const t = this.data;
1282
- this._cachedMax = t.reduce((e, r) => e > r ? e : r);
1305
+ this._cachedMax = t.reduce((e, n) => e > n ? e : n);
1283
1306
  }
1284
1307
  return this._cachedMax;
1285
1308
  }
@@ -1287,18 +1310,17 @@ const St = o.union([
1287
1310
  get max() {
1288
1311
  if (this.dataType.isVariable)
1289
1312
  throw new Error("cannot calculate maximum on a variable length data type");
1290
- return this.writePos === 0 ? -1 / 0 : (this._cachedMax == null && (this._cachedMax = this.calcRawMax()), R(this._cachedMax, this.sampleOffset));
1313
+ return this.writePos === 0 ? -1 / 0 : (this._cachedMax ?? (this._cachedMax = this.calcRawMax()), C(this._cachedMax, this.sampleOffset));
1291
1314
  }
1292
1315
  calcRawMin() {
1293
1316
  if (this.length === 0) return 1 / 0;
1294
- if (this.dataType.equals(h.TIMESTAMP))
1295
- this._cachedMin = this.data[0];
1317
+ if (this.dataType.equals(g.TIMESTAMP)) this._cachedMin = this.data[0];
1296
1318
  else if (this.dataType.usesBigInt) {
1297
1319
  const t = this.data;
1298
- this._cachedMin = t.reduce((e, r) => e < r ? e : r);
1320
+ this._cachedMin = t.reduce((e, n) => e < n ? e : n);
1299
1321
  } else {
1300
1322
  const t = this.data;
1301
- this._cachedMin = t.reduce((e, r) => e < r ? e : r);
1323
+ this._cachedMin = t.reduce((e, n) => e < n ? e : n);
1302
1324
  }
1303
1325
  return this._cachedMin;
1304
1326
  }
@@ -1306,11 +1328,11 @@ const St = o.union([
1306
1328
  get min() {
1307
1329
  if (this.dataType.isVariable)
1308
1330
  throw new Error("cannot calculate minimum on a variable length data type");
1309
- return this.writePos === 0 ? 1 / 0 : (this._cachedMin == null && (this._cachedMin = this.calcRawMin()), R(this._cachedMin, this.sampleOffset));
1331
+ return this.writePos === 0 ? 1 / 0 : (this._cachedMin ?? (this._cachedMin = this.calcRawMin()), C(this._cachedMin, this.sampleOffset));
1310
1332
  }
1311
1333
  /** @returns the bounds of this array. */
1312
1334
  get bounds() {
1313
- return $(Number(this.min), Number(this.max));
1335
+ return L(Number(this.min), Number(this.max));
1314
1336
  }
1315
1337
  maybeRecomputeMinMax(t) {
1316
1338
  if (this._cachedMin != null) {
@@ -1326,36 +1348,48 @@ const St = o.union([
1326
1348
  this.max, this.min;
1327
1349
  }
1328
1350
  get range() {
1329
- return R(this.max, -this.min);
1351
+ return C(this.max, -this.min);
1352
+ }
1353
+ atAlignment(t, e) {
1354
+ const n = Number(t - this.alignment);
1355
+ if (n < 0 || n >= this.length) {
1356
+ if (e === !0) throw new Error(`[series] - no value at index ${n}`);
1357
+ return;
1358
+ }
1359
+ return this.at(n, e);
1330
1360
  }
1331
1361
  at(t, e) {
1332
1362
  if (this.dataType.isVariable) return this.atVariable(t, e ?? !1);
1333
1363
  t < 0 && (t = this.length + t);
1334
- const r = this.data[t];
1335
- if (r == null) {
1364
+ const n = this.data[t];
1365
+ if (n == null) {
1336
1366
  if (e === !0) throw new Error(`[series] - no value at index ${t}`);
1337
1367
  return;
1338
1368
  }
1339
- return R(r, this.sampleOffset);
1369
+ return C(n, this.sampleOffset);
1340
1370
  }
1341
1371
  atVariable(t, e) {
1342
- t < 0 && (t = this.length + t);
1343
- let r = 0, u = 0;
1344
- for (let g = 0; g < this.data.length; g++)
1345
- if (this.data[g] === 10) {
1346
- if (t === 0) {
1347
- u = g;
1348
- break;
1372
+ let n = 0, i = 0;
1373
+ if (this._cachedIndexes != null)
1374
+ n = this._cachedIndexes[t], i = this._cachedIndexes[t + 1] - 1;
1375
+ else {
1376
+ t < 0 && (t = this.length + t);
1377
+ for (let h = 0; h < this.data.length; h++)
1378
+ if (this.data[h] === Y) {
1379
+ if (t === 0) {
1380
+ i = h;
1381
+ break;
1382
+ }
1383
+ n = h + 1, t--;
1349
1384
  }
1350
- r = g + 1, t--;
1385
+ if (i === 0 && (i = this.data.length), n >= i || t > 0) {
1386
+ if (e) throw new Error(`[series] - no value at index ${t}`);
1387
+ return;
1351
1388
  }
1352
- if (u === 0 && (u = this.data.length), r >= u || t > 0) {
1353
- if (e) throw new Error(`[series] - no value at index ${t}`);
1354
- return;
1355
1389
  }
1356
- const d = this.data.slice(r, u);
1357
- return this.dataType.equals(h.STRING) ? new TextDecoder().decode(d) : z(
1358
- JSON.parse(new TextDecoder().decode(d))
1390
+ const c = this.data.slice(n, i);
1391
+ return this.dataType.equals(g.STRING) ? new TextDecoder().decode(c) : nt(
1392
+ JSON.parse(new TextDecoder().decode(c))
1359
1393
  );
1360
1394
  }
1361
1395
  /**
@@ -1364,34 +1398,34 @@ const St = o.union([
1364
1398
  * @param value the value to search for.
1365
1399
  */
1366
1400
  binarySearch(t) {
1367
- let e = 0, r = this.length - 1;
1368
- const u = H(t);
1369
- for (; e <= r; ) {
1370
- const d = Math.floor((e + r) / 2), g = u(this.at(d, !0), t);
1371
- if (g === 0) return d;
1372
- g < 0 ? e = d + 1 : r = d - 1;
1401
+ let e = 0, n = this.length - 1;
1402
+ const i = rt(t);
1403
+ for (; e <= n; ) {
1404
+ const c = Math.floor((e + n) / 2), h = i(this.at(c, !0), t);
1405
+ if (h === 0) return c;
1406
+ h < 0 ? e = c + 1 : n = c - 1;
1373
1407
  }
1374
1408
  return e;
1375
1409
  }
1376
1410
  updateGLBuffer(t) {
1377
- if (this.gl.control = t, !this.dataType.equals(h.FLOAT32))
1411
+ if (this.gl.control = t, !this.dataType.equals(g.FLOAT32))
1378
1412
  throw new Error("Only FLOAT32 arrays can be used in WebGL");
1379
- const { buffer: e, bufferUsage: r, prevBuffer: u } = this.gl;
1380
- if (e == null && (this.gl.buffer = t.createBuffer()), this.writePos !== u)
1381
- if (t.bindBuffer(t.ARRAY_BUFFER, this.gl.buffer), this.writePos !== E) {
1382
- u === 0 && t.bufferData(t.ARRAY_BUFFER, this.byteCapacity.valueOf(), t.STATIC_DRAW);
1383
- const d = this.dataType.density.size(u).valueOf(), g = this.underlyingData.slice(this.gl.prevBuffer, this.writePos);
1384
- t.bufferSubData(t.ARRAY_BUFFER, d, g.buffer), this.gl.prevBuffer = this.writePos;
1413
+ const { buffer: e, bufferUsage: n, prevBuffer: i } = this.gl;
1414
+ if (e == null && (this.gl.buffer = t.createBuffer()), this.writePos !== i)
1415
+ if (t.bindBuffer(t.ARRAY_BUFFER, this.gl.buffer), this.writePos !== B) {
1416
+ i === 0 && t.bufferData(t.ARRAY_BUFFER, this.byteCapacity.valueOf(), t.STATIC_DRAW);
1417
+ const c = this.dataType.density.size(i).valueOf(), h = this.underlyingData.slice(this.gl.prevBuffer, this.writePos);
1418
+ t.bufferSubData(t.ARRAY_BUFFER, c, h.buffer), this.gl.prevBuffer = this.writePos;
1385
1419
  } else
1386
1420
  t.bufferData(
1387
1421
  t.ARRAY_BUFFER,
1388
- this.buffer,
1389
- r === "static" ? t.STATIC_DRAW : t.DYNAMIC_DRAW
1390
- ), this.gl.prevBuffer = E;
1422
+ this.underlyingData,
1423
+ n === "static" ? t.STATIC_DRAW : t.DYNAMIC_DRAW
1424
+ ), this.gl.prevBuffer = B;
1391
1425
  }
1392
1426
  as(t) {
1393
1427
  if (t === "string") {
1394
- if (!this.dataType.equals(h.STRING))
1428
+ if (!this.dataType.equals(g.STRING))
1395
1429
  throw new Error(
1396
1430
  `cannot convert series of type ${this.dataType.toString()} to string`
1397
1431
  );
@@ -1405,7 +1439,7 @@ const St = o.union([
1405
1439
  return this;
1406
1440
  }
1407
1441
  if (t === "bigint") {
1408
- if (!this.dataType.equals(h.INT64))
1442
+ if (!this.dataType.equals(g.INT64))
1409
1443
  throw new Error(
1410
1444
  `cannot convert series of type ${this.dataType.toString()} to bigint`
1411
1445
  );
@@ -1434,7 +1468,7 @@ const St = o.union([
1434
1468
  };
1435
1469
  }
1436
1470
  get alignmentBounds() {
1437
- return $(this.alignment, this.alignment + BigInt(this.length));
1471
+ return L(this.alignment, this.alignment + BigInt(this.length));
1438
1472
  }
1439
1473
  maybeGarbageCollectGLBuffer(t) {
1440
1474
  this.gl.buffer != null && (t.deleteBuffer(this.gl.buffer), this.gl.buffer = null, this.gl.prevBuffer = 0, this.gl.control = null);
@@ -1445,16 +1479,32 @@ const St = o.union([
1445
1479
  }
1446
1480
  [Symbol.iterator]() {
1447
1481
  if (this.dataType.isVariable) {
1448
- const t = new it(this);
1449
- return this.dataType.equals(h.JSON) ? new at(t) : t;
1482
+ const t = new gt(this);
1483
+ return this.dataType.equals(g.JSON) ? new mt(t) : t;
1450
1484
  }
1451
- return new ut(this);
1485
+ return new Ot(this);
1452
1486
  }
1453
1487
  slice(t, e) {
1454
- if (t <= 0 && (e == null || e >= this.length)) return this;
1455
- const r = this.data.slice(t, e);
1456
- return new T({
1457
- data: r,
1488
+ return this.sliceSub(!1, t, e);
1489
+ }
1490
+ sub(t, e) {
1491
+ return this.sliceSub(!0, t, e);
1492
+ }
1493
+ subIterator(t, e) {
1494
+ return new G(this, t, e ?? this.length);
1495
+ }
1496
+ subAlignmentIterator(t, e) {
1497
+ return new G(
1498
+ this,
1499
+ Number(t - this.alignment),
1500
+ Number(e - this.alignment)
1501
+ );
1502
+ }
1503
+ subBytes(t, e) {
1504
+ if (t >= 0 && (e == null || e >= this.byteLength.valueOf())) return this;
1505
+ const n = this.data.subarray(t, e);
1506
+ return new I({
1507
+ data: n,
1458
1508
  dataType: this.dataType,
1459
1509
  timeRange: this._timeRange,
1460
1510
  sampleOffset: this.sampleOffset,
@@ -1462,26 +1512,54 @@ const St = o.union([
1462
1512
  alignment: this.alignment + BigInt(t)
1463
1513
  });
1464
1514
  }
1515
+ sliceSub(t, e, n) {
1516
+ if (e <= 0 && (n == null || n >= this.length)) return this;
1517
+ let i;
1518
+ return t ? i = this.data.subarray(e, n) : i = this.data.slice(e, n), new I({
1519
+ data: i,
1520
+ dataType: this.dataType,
1521
+ timeRange: this._timeRange,
1522
+ sampleOffset: this.sampleOffset,
1523
+ glBufferUsage: this.gl.bufferUsage,
1524
+ alignment: this.alignment + BigInt(e)
1525
+ });
1526
+ }
1465
1527
  reAlign(t) {
1466
- return new T({
1528
+ return new I({
1467
1529
  data: this.buffer,
1468
1530
  dataType: this.dataType,
1469
- timeRange: B.ZERO,
1531
+ timeRange: E.ZERO,
1470
1532
  sampleOffset: this.sampleOffset,
1471
1533
  glBufferUsage: "static",
1472
1534
  alignment: t
1473
1535
  });
1474
1536
  }
1475
1537
  };
1476
- s(T, "crudeZ", o.object({
1477
- timeRange: B.z.optional(),
1478
- dataType: h.z,
1479
- alignment: X.optional(),
1480
- data: o.union([nt, st, o.instanceof(ArrayBuffer)]),
1481
- glBufferUsage: tt.optional().default("static").optional()
1482
- })), s(T, "z", T.crudeZ.transform((t) => new T(t)));
1483
- let x = T;
1484
- class it {
1538
+ s(I, "crudeZ", o.object({
1539
+ timeRange: E.z.optional(),
1540
+ dataType: g.z,
1541
+ alignment: at.optional(),
1542
+ data: o.union([ht, dt, o.instanceof(ArrayBuffer)]),
1543
+ glBufferUsage: lt.optional().default("static").optional()
1544
+ })), s(I, "z", I.crudeZ.transform((t) => new I(t)));
1545
+ let V = I;
1546
+ class G {
1547
+ constructor(t, e, n) {
1548
+ s(this, "series");
1549
+ s(this, "end");
1550
+ s(this, "index");
1551
+ this.series = t;
1552
+ const i = L(0, t.length);
1553
+ this.end = k(i, n), this.index = k(i, e);
1554
+ }
1555
+ next() {
1556
+ return this.index >= this.end ? { done: !0, value: void 0 } : { done: !1, value: this.series.at(this.index++, !0) };
1557
+ }
1558
+ [Symbol.iterator]() {
1559
+ return this;
1560
+ }
1561
+ }
1562
+ class gt {
1485
1563
  constructor(t) {
1486
1564
  s(this, "series");
1487
1565
  s(this, "index");
@@ -1494,38 +1572,38 @@ class it {
1494
1572
  }
1495
1573
  next() {
1496
1574
  const t = this.index, e = this.series.data;
1497
- for (; this.index < e.length && e[this.index] !== 10; ) this.index++;
1498
- const r = this.index;
1499
- return t === r ? { done: !0, value: void 0 } : (this.index++, { done: !1, value: this.decoder.decode(this.series.buffer.slice(t, r)) });
1575
+ for (; this.index < e.length && e[this.index] !== Y; ) this.index++;
1576
+ const n = this.index;
1577
+ return t === n ? { done: !0, value: void 0 } : (this.index++, { done: !1, value: this.decoder.decode(this.series.buffer.slice(t, n)) });
1500
1578
  }
1501
1579
  [Symbol.iterator]() {
1502
1580
  return this;
1503
1581
  }
1504
1582
  }
1505
- var F, P;
1506
- class at {
1583
+ var J, W;
1584
+ class mt {
1507
1585
  constructor(t) {
1508
1586
  s(this, "wrapped");
1509
- s(this, F, "JSONSeriesIterator");
1587
+ s(this, J, "JSONSeriesIterator");
1510
1588
  this.wrapped = t;
1511
1589
  }
1512
1590
  next() {
1513
1591
  const t = this.wrapped.next();
1514
1592
  return t.done === !0 ? { done: !0, value: void 0 } : {
1515
1593
  done: !1,
1516
- value: L.decodeString(t.value)
1594
+ value: $.decodeString(t.value)
1517
1595
  };
1518
1596
  }
1519
- [(P = Symbol.iterator, F = Symbol.toStringTag, P)]() {
1597
+ [(W = Symbol.iterator, J = Symbol.toStringTag, W)]() {
1520
1598
  return this;
1521
1599
  }
1522
1600
  }
1523
- var Y, Z;
1524
- class ut {
1601
+ var j, K;
1602
+ class Ot {
1525
1603
  constructor(t) {
1526
1604
  s(this, "series");
1527
1605
  s(this, "index");
1528
- s(this, Y, "SeriesIterator");
1606
+ s(this, j, "SeriesIterator");
1529
1607
  this.series = t, this.index = 0;
1530
1608
  }
1531
1609
  next() {
@@ -1534,101 +1612,184 @@ class ut {
1534
1612
  value: this.series.at(this.index++, !0)
1535
1613
  };
1536
1614
  }
1537
- [(Z = Symbol.iterator, Y = Symbol.toStringTag, Z)]() {
1615
+ [(K = Symbol.iterator, j = Symbol.toStringTag, K)]() {
1538
1616
  return this;
1539
1617
  }
1540
1618
  }
1541
- const R = (f, t) => typeof f == "bigint" && typeof t == "bigint" || typeof f == "number" && typeof t == "number" ? f + t : t === 0 ? f : f === 0 ? t : Number(f) + Number(t);
1542
- class vt {
1619
+ const C = (l, t) => typeof l == "bigint" && typeof t == "bigint" || typeof l == "number" && typeof t == "number" ? l + t : t === 0 ? l : l === 0 ? t : Number(l) + Number(t);
1620
+ class Ct {
1543
1621
  constructor(t) {
1544
1622
  s(this, "series");
1545
1623
  if (t.length !== 0) {
1546
1624
  const e = t[0].dataType;
1547
- for (let r = 1; r < t.length; r++)
1548
- if (!t[r].dataType.equals(e))
1625
+ for (let n = 1; n < t.length; n++)
1626
+ if (!t[n].dataType.equals(e))
1549
1627
  throw new Error("[multi-series] - series must have the same data type");
1550
1628
  }
1551
1629
  this.series = t;
1552
1630
  }
1553
1631
  as(t) {
1554
- if (!new h(t).equals(this.dataType))
1632
+ if (!new g(t).equals(this.dataType))
1555
1633
  throw new Error(
1556
1634
  `cannot convert series of type ${this.dataType.toString()} to ${t.toString()}`
1557
1635
  );
1558
1636
  return this;
1559
1637
  }
1560
1638
  get dataType() {
1561
- return this.series.length === 0 ? h.UNKNOWN : this.series[0].dataType;
1639
+ return this.series.length === 0 ? g.UNKNOWN : this.series[0].dataType;
1562
1640
  }
1563
1641
  get timeRange() {
1564
- return this.series.length === 0 ? B.ZERO : new B(
1642
+ return this.series.length === 0 ? E.ZERO : new E(
1565
1643
  this.series[0].timeRange.start,
1566
1644
  this.series[this.series.length - 1].timeRange.end
1567
1645
  );
1568
1646
  }
1647
+ get alignment() {
1648
+ return this.series.length === 0 ? 0n : this.series[0].alignment;
1649
+ }
1650
+ get alignmentBounds() {
1651
+ return this.series.length === 0 ? L(0n, 0n) : L(
1652
+ this.series[0].alignmentBounds.lower,
1653
+ this.series[this.series.length - 1].alignmentBounds.upper
1654
+ );
1655
+ }
1569
1656
  push(t) {
1570
1657
  this.series.push(t);
1571
1658
  }
1572
1659
  get length() {
1573
1660
  return this.series.reduce((t, e) => t + e.length, 0);
1574
1661
  }
1662
+ atAlignment(t, e) {
1663
+ if (this.series.length === 0) {
1664
+ if (e) throw new Error(`[series] - no value at alignment ${t}`);
1665
+ return;
1666
+ }
1667
+ for (const n of this.series)
1668
+ if (D(n.alignmentBounds, t))
1669
+ return n.atAlignment(t, e);
1670
+ if (e) throw new Error(`[series] - no value at alignment ${t}`);
1671
+ }
1575
1672
  at(t, e = !1) {
1576
1673
  t < 0 && (t = this.length + t);
1577
- for (const r of this.series) {
1578
- if (t < r.length) return r.at(t, e);
1579
- t -= r.length;
1674
+ for (const n of this.series) {
1675
+ if (t < n.length) return n.at(t, e);
1676
+ t -= n.length;
1580
1677
  }
1581
1678
  if (e) throw new Error(`[series] - no value at index ${t}`);
1582
1679
  }
1680
+ subIterator(t, e) {
1681
+ return new F(this, t, e ?? this.length);
1682
+ }
1683
+ subAlignmentIterator(t, e) {
1684
+ if (t >= this.alignmentBounds.upper || e <= this.alignmentBounds.lower)
1685
+ return q;
1686
+ let n = 0;
1687
+ for (let c = 0; c < this.series.length; c++) {
1688
+ const h = this.series[c];
1689
+ if (t < h.alignment) break;
1690
+ if (t >= h.alignmentBounds.upper) n += h.length;
1691
+ else if (D(h.alignmentBounds, t)) {
1692
+ n += Number(t - h.alignment);
1693
+ break;
1694
+ }
1695
+ }
1696
+ let i = 0;
1697
+ for (let c = 0; c < this.series.length; c++) {
1698
+ const h = this.series[c];
1699
+ if (e < h.alignment) break;
1700
+ if (e >= h.alignmentBounds.upper) i += h.length;
1701
+ else if (D(h.alignmentBounds, e)) {
1702
+ i += Number(e - h.alignment);
1703
+ break;
1704
+ }
1705
+ }
1706
+ return new F(this, n, i);
1707
+ }
1708
+ subAlignmentSpanIterator(t, e) {
1709
+ if (t >= this.alignmentBounds.upper) return q;
1710
+ let n = 0;
1711
+ for (let i = 0; i < this.series.length; i++) {
1712
+ const c = this.series[i];
1713
+ if (t < c.alignment) break;
1714
+ if (t >= c.alignmentBounds.upper) n += c.length;
1715
+ else if (D(c.alignmentBounds, t)) {
1716
+ n += Number(t - c.alignment);
1717
+ break;
1718
+ }
1719
+ }
1720
+ return new F(this, n, n + e);
1721
+ }
1583
1722
  get byteLength() {
1584
- return new C(this.series.reduce((t, e) => t + e.byteLength.valueOf(), 0));
1723
+ return new x(this.series.reduce((t, e) => t + e.byteLength.valueOf(), 0));
1585
1724
  }
1586
1725
  get data() {
1587
1726
  const t = new this.dataType.Array(this.length);
1588
1727
  let e = 0;
1589
- for (const r of this.series)
1590
- t.set(r.data, e), e += r.length;
1728
+ for (const n of this.series)
1729
+ t.set(n.data, e), e += n.length;
1591
1730
  return new this.dataType.Array(t);
1592
1731
  }
1732
+ traverseAlignment(t, e) {
1733
+ const n = this.series.map((i) => i.alignmentBounds);
1734
+ return st(n, t, e);
1735
+ }
1736
+ distance(t, e) {
1737
+ const n = this.series.map((i) => i.alignmentBounds);
1738
+ return it(n, t, e);
1739
+ }
1593
1740
  [Symbol.iterator]() {
1594
1741
  return this.series.length === 0 ? {
1595
1742
  next() {
1596
1743
  return { done: !0, value: void 0 };
1597
1744
  }
1598
- } : new ot(this.series);
1745
+ } : new yt(this.series);
1599
1746
  }
1600
1747
  }
1601
- var G, V;
1602
- class ot {
1748
+ var z, H;
1749
+ class yt {
1603
1750
  constructor(t) {
1604
1751
  s(this, "series");
1605
1752
  s(this, "seriesIndex");
1606
1753
  s(this, "internal");
1607
- s(this, G, "MultiSeriesIterator");
1754
+ s(this, z, "MultiSeriesIterator");
1608
1755
  this.series = t, this.seriesIndex = 0, this.internal = t[0][Symbol.iterator]();
1609
1756
  }
1610
1757
  next() {
1611
1758
  const t = this.internal.next();
1612
1759
  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());
1613
1760
  }
1614
- [(V = Symbol.iterator, G = Symbol.toStringTag, V)]() {
1761
+ [(H = Symbol.iterator, z = Symbol.toStringTag, H)]() {
1762
+ return this;
1763
+ }
1764
+ }
1765
+ class F {
1766
+ constructor(t, e, n) {
1767
+ s(this, "series");
1768
+ s(this, "index");
1769
+ s(this, "end");
1770
+ this.series = t, this.end = n, this.index = e;
1771
+ }
1772
+ next() {
1773
+ return this.index >= this.end ? { done: !0, value: void 0 } : { done: !1, value: this.series.at(this.index++, !0) };
1774
+ }
1775
+ [Symbol.iterator]() {
1615
1776
  return this;
1616
1777
  }
1617
1778
  }
1618
1779
  export {
1619
1780
  b as D,
1620
- vt as M,
1621
- q as R,
1622
- x as S,
1781
+ Ct as M,
1782
+ P as R,
1783
+ V as S,
1623
1784
  m as T,
1624
- R as a,
1785
+ C as a,
1625
1786
  y as b,
1626
- B as c,
1627
- h as d,
1628
- C as e,
1629
- W as f,
1630
- et as g,
1631
- Nt as h,
1632
- rt as i,
1633
- St as t
1787
+ E as c,
1788
+ g as d,
1789
+ x as e,
1790
+ _ as f,
1791
+ ct as g,
1792
+ Rt as h,
1793
+ ft as i,
1794
+ xt as t
1634
1795
  };