@synnaxlabs/freighter 0.45.1 → 0.47.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 (42) hide show
  1. package/.turbo/turbo-build.log +17 -0
  2. package/dist/eslint.config.d.ts +3 -0
  3. package/dist/eslint.config.d.ts.map +1 -0
  4. package/dist/freighter.cjs +4 -4
  5. package/dist/freighter.js +780 -691
  6. package/dist/src/alamos.d.ts.map +1 -0
  7. package/dist/src/errors.d.ts.map +1 -0
  8. package/dist/{errors.spec.d.ts.map → src/errors.spec.d.ts.map} +1 -1
  9. package/dist/src/http.d.ts.map +1 -0
  10. package/dist/{http.spec.d.ts.map → src/http.spec.d.ts.map} +1 -1
  11. package/dist/src/index.d.ts.map +1 -0
  12. package/dist/src/middleware.d.ts.map +1 -0
  13. package/dist/src/stream.d.ts.map +1 -0
  14. package/dist/src/transport.d.ts.map +1 -0
  15. package/dist/src/unary.d.ts.map +1 -0
  16. package/dist/src/websocket.d.ts.map +1 -0
  17. package/dist/{websocket.spec.d.ts.map → src/websocket.spec.d.ts.map} +1 -1
  18. package/package.json +11 -11
  19. package/src/http.ts +1 -1
  20. package/tsconfig.json +1 -1
  21. package/dist/alamos.d.ts.map +0 -1
  22. package/dist/errors.d.ts.map +0 -1
  23. package/dist/http.d.ts.map +0 -1
  24. package/dist/index.d.ts.map +0 -1
  25. package/dist/middleware.d.ts.map +0 -1
  26. package/dist/stream.d.ts.map +0 -1
  27. package/dist/transport.d.ts.map +0 -1
  28. package/dist/unary.d.ts.map +0 -1
  29. package/dist/websocket.d.ts.map +0 -1
  30. /package/dist/{alamos.d.ts → src/alamos.d.ts} +0 -0
  31. /package/dist/{errors.d.ts → src/errors.d.ts} +0 -0
  32. /package/dist/{errors.spec.d.ts → src/errors.spec.d.ts} +0 -0
  33. /package/dist/{http.d.ts → src/http.d.ts} +0 -0
  34. /package/dist/{http.spec.d.ts → src/http.spec.d.ts} +0 -0
  35. /package/dist/{index.d.ts → src/index.d.ts} +0 -0
  36. /package/dist/{middleware.d.ts → src/middleware.d.ts} +0 -0
  37. /package/dist/{stream.d.ts → src/stream.d.ts} +0 -0
  38. /package/dist/{transport.d.ts → src/transport.d.ts} +0 -0
  39. /package/dist/{unary.d.ts → src/unary.d.ts} +0 -0
  40. /package/dist/{websocket.d.ts → src/websocket.d.ts} +0 -0
  41. /package/dist/{websocket.spec.d.ts → src/websocket.spec.d.ts} +0 -0
  42. /package/{eslint.config.js → eslint.config.ts} +0 -0
package/dist/freighter.js CHANGED
@@ -1,36 +1,36 @@
1
- import O, { z as s } from "zod";
2
- const Qe = (n) => {
1
+ import b, { z as s } from "zod";
2
+ const tt = (n) => {
3
3
  const e = n.replace(/_[a-z]/g, (t) => t[1].toUpperCase());
4
4
  return e.length > 1 && e[0] === e[0].toUpperCase() && e[1] === e[1].toUpperCase() || e.length === 0 ? e : e[0].toLowerCase() + e.slice(1);
5
- }, Ee = (n) => {
6
- const e = (t, r = ae) => {
5
+ }, Me = (n) => {
6
+ const e = (t, r = ue) => {
7
7
  if (typeof t == "string") return n(t);
8
8
  if (Array.isArray(t)) return t.map((c) => e(c, r));
9
- if (!re(t)) return t;
10
- r = nt(r);
9
+ if (!ie(t)) return t;
10
+ r = it(r);
11
11
  const i = {}, a = t;
12
12
  return "toJSON" in a && typeof a.toJSON == "function" ? e(a.toJSON(), r) : (Object.keys(a).forEach((c) => {
13
- let g = a[c];
13
+ let d = a[c];
14
14
  const y = n(c);
15
- r.recursive && (re(g) ? we(g) || (g = e(g, r)) : r.recursiveInArray && ye(g) && (g = [...g].map((f) => {
16
- let m = f;
17
- return re(f) ? we(m) || (m = e(f, r)) : ye(f) && (m = e({ key: f }, r).key), m;
18
- }))), i[y] = g;
15
+ r.recursive && (ie(d) ? Te(d) || (d = e(d, r)) : r.recursiveInArray && Oe(d) && (d = [...d].map((f) => {
16
+ let g = f;
17
+ return ie(f) ? Te(g) || (g = e(f, r)) : Oe(f) && (g = e({ key: f }, r).key), g;
18
+ }))), i[y] = d;
19
19
  }), i);
20
20
  };
21
21
  return e;
22
- }, xe = Ee(Qe), _e = (n) => (
22
+ }, $e = Me(tt), nt = (n) => (
23
23
  // Don't convert the first character and don't convert a character that is after a
24
24
  // non-alphanumeric character
25
25
  n.replace(
26
26
  /([a-z0-9])([A-Z])/g,
27
27
  (e, t, r) => `${t}_${r.toLowerCase()}`
28
28
  )
29
- ), et = Ee(_e), tt = [Number, String, Uint8Array], ae = {
29
+ ), rt = Me(nt), st = [Number, String, Uint8Array], ue = {
30
30
  recursive: !0,
31
31
  recursiveInArray: !0
32
- }, nt = (n = ae) => (n.recursive == null ? n = ae : n.recursiveInArray ??= !1, n), ye = (n) => n != null && Array.isArray(n), re = (n) => n != null && typeof n == "object" && !Array.isArray(n), we = (n) => tt.some((e) => n instanceof e);
33
- let rt = class {
32
+ }, it = (n = ue) => (n.recursive == null ? n = ue : n.recursiveInArray ??= !1, n), Oe = (n) => n != null && Array.isArray(n), ie = (n) => n != null && typeof n == "object" && !Array.isArray(n), Te = (n) => st.some((e) => n instanceof e);
33
+ let at = class {
34
34
  contentType = "application/json";
35
35
  decoder;
36
36
  encoder;
@@ -44,16 +44,16 @@ let rt = class {
44
44
  return this.decodeString(this.decoder.decode(e), t);
45
45
  }
46
46
  decodeString(e, t) {
47
- const r = JSON.parse(e), i = xe(r);
47
+ const r = JSON.parse(e), i = $e(r);
48
48
  return t != null ? t.parse(i) : i;
49
49
  }
50
50
  encodeString(e) {
51
- const t = et(e);
51
+ const t = rt(e);
52
52
  return JSON.stringify(t, (r, i) => ArrayBuffer.isView(i) ? Array.from(i) : typeof i == "bigint" ? i.toString() : i);
53
53
  }
54
54
  };
55
- const oe = new rt(), E = (n) => n != null && typeof n == "object" && "value" in n;
56
- let F = class {
55
+ const le = new at(), U = (n) => n != null && typeof n == "object" && "value" in n;
56
+ let Z = class {
57
57
  /** The underlying primitive value */
58
58
  value;
59
59
  constructor(e) {
@@ -73,8 +73,8 @@ let F = class {
73
73
  return this.value.toString();
74
74
  }
75
75
  };
76
- const st = (n) => n != null && typeof n == "object" && "toString" in n, it = (n, e = !1) => {
77
- const t = st(n) ? "stringer" : typeof n;
76
+ const ot = (n) => n != null && typeof n == "object" && "toString" in n, ut = (n, e = !1) => {
77
+ const t = ot(n) ? "stringer" : typeof n;
78
78
  let r;
79
79
  switch (t) {
80
80
  case "string":
@@ -98,38 +98,38 @@ const st = (n) => n != null && typeof n == "object" && "toString" in n, it = (n,
98
98
  default:
99
99
  return console.warn(`sortFunc: unknown type ${t}`), () => -1;
100
100
  }
101
- return e ? at(r) : r;
102
- }, at = (n) => (e, t) => n(t, e), Q = s.tuple([s.number(), s.number()]);
101
+ return e ? lt(r) : r;
102
+ }, lt = (n) => (e, t) => n(t, e), ee = s.tuple([s.number(), s.number()]);
103
103
  s.tuple([s.bigint(), s.bigint()]);
104
- const Ae = s.object({ width: s.number(), height: s.number() }), ot = s.object({
104
+ const Ce = s.object({ width: s.number(), height: s.number() }), ct = s.object({
105
105
  signedWidth: s.number(),
106
106
  signedHeight: s.number()
107
- }), ut = ["width", "height"];
108
- s.enum(ut);
109
- const lt = ["start", "center", "end"], ct = ["signedWidth", "signedHeight"];
110
- s.enum(ct);
111
- const K = s.object({ x: s.number(), y: s.number() }), ht = s.object({ clientX: s.number(), clientY: s.number() }), ft = ["x", "y"], Ue = s.enum(ft), Me = ["top", "right", "bottom", "left"];
112
- s.enum(Me);
113
- const dt = ["left", "right"], Ce = s.enum(dt), gt = ["top", "bottom"], $e = s.enum(gt), Be = ["center"], be = s.enum(Be), pt = [...Me, ...Be], Re = s.enum(pt);
114
- s.enum(lt);
115
- const mt = ["first", "last"];
116
- s.enum(mt);
117
- const yt = s.object({ lower: s.number(), upper: s.number() }), wt = s.object({ lower: s.bigint(), upper: s.bigint() });
118
- s.union([yt, Q]);
119
- s.union([wt, Q]);
120
- s.enum([...Ue.options, ...Re.options]);
107
+ }), ht = ["width", "height"];
108
+ s.enum(ht);
109
+ const ft = ["start", "center", "end"], dt = ["signedWidth", "signedHeight"];
110
+ s.enum(dt);
111
+ const _ = s.object({ x: s.number(), y: s.number() }), gt = s.object({ clientX: s.number(), clientY: s.number() }), pt = ["x", "y"], Be = s.enum(pt), Re = ["top", "right", "bottom", "left"];
112
+ s.enum(Re);
113
+ const mt = ["left", "right"], De = s.enum(mt), yt = ["top", "bottom"], Le = s.enum(yt), Pe = ["center"], ve = s.enum(Pe), wt = [...Re, ...Pe], ke = s.enum(wt);
114
+ s.enum(ft);
115
+ const bt = ["first", "last"];
116
+ s.enum(bt);
117
+ const Ot = s.object({ lower: s.number(), upper: s.number() }), Tt = s.object({ lower: s.bigint(), upper: s.bigint() });
118
+ s.union([Ot, ee]);
119
+ s.union([Tt, ee]);
120
+ s.enum([...Be.options, ...ke.options]);
121
121
  s.enum(["x", "left", "right"]);
122
122
  s.enum(["y", "top", "bottom"]);
123
- s.union([Ue, Re, s.instanceof(String)]);
124
- const _ = (n) => (e, t) => {
123
+ s.union([Be, ke, s.instanceof(String)]);
124
+ const te = (n) => (e, t) => {
125
125
  if (typeof e == "bigint") {
126
- if (bt(t))
126
+ if (vt(t))
127
127
  return n(e, BigInt(t));
128
128
  const r = n(Number(e), Number(t));
129
129
  return typeof r == "number" ? BigInt(Math.round(r)) : r;
130
130
  }
131
131
  return n(Number(e), Number(t));
132
- }, ee = _((n, e) => n - e), te = _((n, e) => n + e), bt = (n) => typeof n == "bigint" ? !0 : Number.isInteger(n), M = _((n, e) => n * e), ne = _((n, e) => n / e), D = (n, e, t) => {
132
+ }, ne = te((n, e) => n - e), re = te((n, e) => n + e), vt = (n) => typeof n == "bigint" ? !0 : Number.isInteger(n), C = te((n, e) => n * e), se = te((n, e) => n / e), P = (n, e, t) => {
133
133
  const r = {};
134
134
  if (typeof e == "object" && (t = e, e = void 0), t = { makeValid: !0, ...t }, typeof n == "number" || typeof n == "bigint")
135
135
  e != null ? (r.lower = n, r.upper = e) : (r.lower = typeof n == "bigint" ? 0n : 0, r.upper = n);
@@ -138,34 +138,34 @@ const _ = (n) => (e, t) => {
138
138
  [r.lower, r.upper] = n;
139
139
  } else
140
140
  r.lower = n.lower, r.upper = n.upper;
141
- return t?.makeValid ? Ot(r) : r;
142
- }, Ot = (n) => n.lower > n.upper ? { lower: n.upper, upper: n.lower } : n, Oe = (n, e) => {
143
- const t = D(n);
141
+ return t?.makeValid ? St(r) : r;
142
+ }, St = (n) => n.lower > n.upper ? { lower: n.upper, upper: n.lower } : n, Se = (n, e) => {
143
+ const t = P(n);
144
144
  return e < t.lower ? t.lower : e >= t.upper ? t.upper - (typeof t.upper == "number" ? 1 : 1n) : e;
145
145
  };
146
146
  s.object({
147
- x: Ce.or(be),
148
- y: $e.or(be)
147
+ x: De.or(ve),
148
+ y: Le.or(ve)
149
149
  });
150
- const Tt = s.object({ x: Ce, y: $e }), vt = Object.freeze({ x: "left", y: "top" }), It = (n, e) => n.x === e.x && n.y === e.y, Te = s.union([
150
+ const It = s.object({ x: De, y: Le }), Nt = Object.freeze({ x: "left", y: "top" }), Et = (n, e) => n.x === e.x && n.y === e.y, Ie = s.union([
151
151
  s.number(),
152
- K,
153
- Q,
154
- Ae,
155
- ot,
156
- ht
157
- ]), Nt = (n, e) => {
152
+ _,
153
+ ee,
154
+ Ce,
155
+ ct,
156
+ gt
157
+ ]), xt = (n, e) => {
158
158
  if (typeof n == "string") {
159
159
  if (e === void 0) throw new Error("The y coordinate must be given.");
160
160
  return n === "x" ? { x: e, y: 0 } : { x: 0, y: e };
161
161
  }
162
162
  return typeof n == "number" ? { x: n, y: e ?? n } : Array.isArray(n) ? { x: n[0], y: n[1] } : "signedWidth" in n ? { x: n.signedWidth, y: n.signedHeight } : "clientX" in n ? { x: n.clientX, y: n.clientY } : "width" in n ? { x: n.width, y: n.height } : { x: n.x, y: n.y };
163
- }, ve = Object.freeze({ x: 0, y: 0 }), H = s.union([s.number(), s.string()]);
163
+ }, Ne = Object.freeze({ x: 0, y: 0 }), J = s.union([s.number(), s.string()]);
164
164
  s.object({
165
- top: H,
166
- left: H,
167
- width: H,
168
- height: H
165
+ top: J,
166
+ left: J,
167
+ width: J,
168
+ height: J
169
169
  });
170
170
  s.object({
171
171
  left: s.number(),
@@ -174,15 +174,15 @@ s.object({
174
174
  bottom: s.number()
175
175
  });
176
176
  s.object({
177
- one: K,
178
- two: K,
179
- root: Tt
177
+ one: _,
178
+ two: _,
179
+ root: It
180
180
  });
181
- const de = (n, e, t = 0, r = 0, i) => {
181
+ const me = (n, e, t = 0, r = 0, i) => {
182
182
  const a = {
183
- one: { ...ve },
184
- two: { ...ve },
185
- root: i ?? vt
183
+ one: { ...Ne },
184
+ two: { ...Ne },
185
+ root: i ?? Nt
186
186
  };
187
187
  if (typeof n == "number") {
188
188
  if (typeof e != "number")
@@ -196,39 +196,39 @@ const de = (n, e, t = 0, r = 0, i) => {
196
196
  x: a.one.x + e.signedWidth,
197
197
  y: a.one.y + e.signedHeight
198
198
  } : a.two = e, a));
199
- }, se = (n) => {
200
- const e = de(n);
199
+ }, ae = (n) => {
200
+ const e = me(n);
201
201
  return { lower: e.one.x, upper: e.two.x };
202
- }, ie = (n) => {
203
- const e = de(n);
202
+ }, oe = (n) => {
203
+ const e = me(n);
204
204
  return { lower: e.one.y, upper: e.two.y };
205
- }, St = (n) => typeof n != "object" || n == null ? !1 : "one" in n && "two" in n && "root" in n, Et = s.object({ signedWidth: s.number(), signedHeight: s.number() });
206
- s.union([Ae, Et, K, Q]);
207
- const xt = (n, e, t) => e !== void 0 && n < e ? e : t !== void 0 && n > t ? t : n;
208
- s.object({ offset: Te, scale: Te });
205
+ }, At = (n) => typeof n != "object" || n == null ? !1 : "one" in n && "two" in n && "root" in n, Ut = s.object({ signedWidth: s.number(), signedHeight: s.number() });
206
+ s.union([Ce, Ut, _, ee]);
207
+ const Mt = (n, e, t) => e !== void 0 && n < e ? e : t !== void 0 && n > t ? t : n;
208
+ s.object({ offset: Ie, scale: Ie });
209
209
  s.object({ offset: s.number(), scale: s.number() });
210
- const At = (n) => (e, t, r, i) => t === "dimension" ? [e, r] : [
210
+ const $t = (n) => (e, t, r, i) => t === "dimension" ? [e, r] : [
211
211
  e,
212
212
  i ? r - n : r + n
213
- ], Ut = (n) => (e, t, r, i) => [
213
+ ], Ct = (n) => (e, t, r, i) => [
214
214
  e,
215
215
  i ? r / n : r * n
216
- ], Mt = (n) => (e, t, r) => {
216
+ ], Bt = (n) => (e, t, r) => {
217
217
  if (e === null) return [n, r];
218
- const { lower: i, upper: a } = e, { lower: c, upper: g } = n, y = a - i, f = g - c;
218
+ const { lower: i, upper: a } = e, { lower: c, upper: d } = n, y = a - i, f = d - c;
219
219
  if (t === "dimension") return [n, r * (f / y)];
220
- const m = (r - i) * (f / y) + c;
221
- return [n, m];
222
- }, Ct = (n) => (e, t, r) => [n, r], $t = () => (n, e, t) => {
220
+ const g = (r - i) * (f / y) + c;
221
+ return [n, g];
222
+ }, Rt = (n) => (e, t, r) => [n, r], Dt = () => (n, e, t) => {
223
223
  if (n === null) throw new Error("cannot invert without bounds");
224
224
  if (e === "dimension") return [n, t];
225
225
  const { lower: r, upper: i } = n;
226
226
  return [n, i - (t - r)];
227
- }, Bt = (n) => (e, t, r) => {
227
+ }, Lt = (n) => (e, t, r) => {
228
228
  const { lower: i, upper: a } = n;
229
- return r = xt(r, i, a), [e, r];
229
+ return r = Mt(r, i, a), [e, r];
230
230
  };
231
- let Ie = class L {
231
+ let Ee = class k {
232
232
  ops = [];
233
233
  currBounds = null;
234
234
  currType = null;
@@ -242,7 +242,7 @@ let Ie = class L {
242
242
  * @param value - The amount to translate by.
243
243
  */
244
244
  static translate(e) {
245
- return new L().translate(e);
245
+ return new k().translate(e);
246
246
  }
247
247
  /**
248
248
  * @returns a new scale with a magnification as its first operation. Any number provided
@@ -250,10 +250,10 @@ let Ie = class L {
250
250
  * @param value - The amount to translate by.
251
251
  */
252
252
  static magnify(e) {
253
- return new L().magnify(e);
253
+ return new k().magnify(e);
254
254
  }
255
255
  static scale(e, t) {
256
- return new L().scale(e, t);
256
+ return new k().scale(e, t);
257
257
  }
258
258
  /**
259
259
  * @returns a copy of the scale with a translation as its next operation. Any
@@ -262,7 +262,7 @@ let Ie = class L {
262
262
  * @param value - The amount to translate by.
263
263
  */
264
264
  translate(e) {
265
- const t = this.new(), r = At(e);
265
+ const t = this.new(), r = $t(e);
266
266
  return r.type = "translate", t.ops.push(r), t;
267
267
  }
268
268
  /**
@@ -272,23 +272,23 @@ let Ie = class L {
272
272
  * @param value - The amount to magnify by.
273
273
  */
274
274
  magnify(e) {
275
- const t = this.new(), r = Ut(e);
275
+ const t = this.new(), r = Ct(e);
276
276
  return r.type = "magnify", t.ops.push(r), t;
277
277
  }
278
278
  scale(e, t) {
279
- const r = D(e, t), i = this.new(), a = Mt(r);
279
+ const r = P(e, t), i = this.new(), a = Bt(r);
280
280
  return a.type = "scale", i.ops.push(a), i;
281
281
  }
282
282
  clamp(e, t) {
283
- const r = D(e, t), i = this.new(), a = Bt(r);
283
+ const r = P(e, t), i = this.new(), a = Lt(r);
284
284
  return a.type = "clamp", i.ops.push(a), i;
285
285
  }
286
286
  reBound(e, t) {
287
- const r = D(e, t), i = this.new(), a = Ct(r);
287
+ const r = P(e, t), i = this.new(), a = Rt(r);
288
288
  return a.type = "re-bound", i.ops.push(a), i;
289
289
  }
290
290
  invert() {
291
- const e = $t();
291
+ const e = Dt();
292
292
  e.type = "invert";
293
293
  const t = this.new();
294
294
  return t.ops.push(e), t;
@@ -300,7 +300,7 @@ let Ie = class L {
300
300
  return this.exec("dimension", e);
301
301
  }
302
302
  new() {
303
- const e = new L();
303
+ const e = new k();
304
304
  return e.ops = this.ops.slice(), e.reversed = this.reversed, e;
305
305
  }
306
306
  exec(e, t) {
@@ -314,9 +314,9 @@ let Ie = class L {
314
314
  e.ops.reverse();
315
315
  const t = [];
316
316
  return e.ops.forEach((r, i) => {
317
- if (r.type === "scale" || t.some(([c, g]) => i >= c && i <= g))
317
+ if (r.type === "scale" || t.some(([c, d]) => i >= c && i <= d))
318
318
  return;
319
- const a = e.ops.findIndex((c, g) => c.type === "scale" && g > i);
319
+ const a = e.ops.findIndex((c, d) => c.type === "scale" && d > i);
320
320
  a !== -1 && t.push([i, a]);
321
321
  }), t.forEach(([r, i]) => {
322
322
  const a = e.ops.slice(r, i);
@@ -326,37 +326,37 @@ let Ie = class L {
326
326
  get transform() {
327
327
  return { scale: this.dim(1), offset: this.pos(0) };
328
328
  }
329
- static IDENTITY = new L();
330
- }, _n = class U {
329
+ static IDENTITY = new k();
330
+ }, sr = class $ {
331
331
  x;
332
332
  y;
333
333
  currRoot;
334
- constructor(e = new Ie(), t = new Ie(), r = null) {
334
+ constructor(e = new Ee(), t = new Ee(), r = null) {
335
335
  this.x = e, this.y = t, this.currRoot = r;
336
336
  }
337
337
  static translate(e, t) {
338
- return new U().translate(e, t);
338
+ return new $().translate(e, t);
339
339
  }
340
340
  static translateX(e) {
341
- return new U().translateX(e);
341
+ return new $().translateX(e);
342
342
  }
343
343
  static translateY(e) {
344
- return new U().translateY(e);
344
+ return new $().translateY(e);
345
345
  }
346
346
  static clamp(e) {
347
- return new U().clamp(e);
347
+ return new $().clamp(e);
348
348
  }
349
349
  static magnify(e) {
350
- return new U().magnify(e);
350
+ return new $().magnify(e);
351
351
  }
352
352
  static scale(e) {
353
- return new U().scale(e);
353
+ return new $().scale(e);
354
354
  }
355
355
  static reBound(e) {
356
- return new U().reBound(e);
356
+ return new $().reBound(e);
357
357
  }
358
358
  translate(e, t) {
359
- const r = Nt(e, t), i = this.copy();
359
+ const r = xt(e, t), i = this.copy();
360
360
  return i.x = this.x.translate(r.x), i.y = this.y.translate(r.y), i;
361
361
  }
362
362
  translateX(e) {
@@ -373,22 +373,22 @@ let Ie = class L {
373
373
  }
374
374
  scale(e) {
375
375
  const t = this.copy();
376
- if (St(e)) {
376
+ if (At(e)) {
377
377
  const r = this.currRoot;
378
- return t.currRoot = e.root, r != null && !It(r, e.root) && (r.x !== e.root.x && (t.x = t.x.invert()), r.y !== e.root.y && (t.y = t.y.invert())), t.x = t.x.scale(se(e)), t.y = t.y.scale(ie(e)), t;
378
+ return t.currRoot = e.root, r != null && !Et(r, e.root) && (r.x !== e.root.x && (t.x = t.x.invert()), r.y !== e.root.y && (t.y = t.y.invert())), t.x = t.x.scale(ae(e)), t.y = t.y.scale(oe(e)), t;
379
379
  }
380
380
  return t.x = t.x.scale(e.width), t.y = t.y.scale(e.height), t;
381
381
  }
382
382
  reBound(e) {
383
383
  const t = this.copy();
384
- return t.x = this.x.reBound(se(e)), t.y = this.y.reBound(ie(e)), t;
384
+ return t.x = this.x.reBound(ae(e)), t.y = this.y.reBound(oe(e)), t;
385
385
  }
386
386
  clamp(e) {
387
387
  const t = this.copy();
388
- return t.x = this.x.clamp(se(e)), t.y = this.y.clamp(ie(e)), t;
388
+ return t.x = this.x.clamp(ae(e)), t.y = this.y.clamp(oe(e)), t;
389
389
  }
390
390
  copy() {
391
- const e = new U();
391
+ const e = new $();
392
392
  return e.currRoot = this.currRoot, e.x = this.x, e.y = this.y, e;
393
393
  }
394
394
  reverse() {
@@ -402,7 +402,7 @@ let Ie = class L {
402
402
  return { x: this.x.dim(e.x), y: this.y.dim(e.y) };
403
403
  }
404
404
  box(e) {
405
- return de(
405
+ return me(
406
406
  this.pos(e.one),
407
407
  this.pos(e.two),
408
408
  0,
@@ -416,50 +416,50 @@ let Ie = class L {
416
416
  offset: this.pos({ x: 0, y: 0 })
417
417
  };
418
418
  }
419
- static IDENTITY = new U();
420
- }, De = (n, e = 21) => (t = e) => {
419
+ static IDENTITY = new $();
420
+ }, je = (n, e = 21) => (t = e) => {
421
421
  let r = "", i = t | 0;
422
422
  for (; i--; )
423
423
  r += n[Math.random() * n.length | 0];
424
424
  return r;
425
425
  };
426
- const Le = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", Rt = `0123456789${Le}`, Dt = 11, Lt = De(Le, 1), kt = De(Rt, Dt - 1), Pt = () => `${Lt()}${kt()}`, jt = (n, e) => (t) => t instanceof e || typeof t == "object" && t !== null && "discriminator" in t && t.discriminator === n, Yt = s.enum(["static", "dynamic"]), qt = s.union([
426
+ const Ye = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", Pt = `0123456789${Ye}`, kt = 11, jt = je(Ye, 1), Yt = je(Pt, kt - 1), qt = () => `${jt()}${Yt()}`, Ft = (n, e) => (t) => t instanceof e || typeof t == "object" && t !== null && "discriminator" in t && t.discriminator === n, Wt = s.enum(["static", "dynamic"]), ce = 2n ** 63n - 1n, Zt = 2 ** 63 - 1, xe = 365, K = 30, Gt = s.union([
427
427
  s.tuple([s.int()]),
428
428
  s.tuple([s.int(), s.int().min(1).max(12)]),
429
429
  s.tuple([s.int(), s.int().min(1).max(12), s.int().min(1).max(31)])
430
- ]), ke = (n, e) => {
431
- const t = new o(e);
430
+ ]), qe = (n, e) => {
431
+ const t = new u(e);
432
432
  if (![
433
- p.DAY,
434
- p.HOUR,
435
- p.MINUTE,
436
- p.SECOND,
437
- p.MILLISECOND,
438
- p.MICROSECOND,
439
- p.NANOSECOND
433
+ l.DAY,
434
+ l.HOUR,
435
+ l.MINUTE,
436
+ l.SECOND,
437
+ l.MILLISECOND,
438
+ l.MICROSECOND,
439
+ l.NANOSECOND
440
440
  ].some((i) => i.equals(t)))
441
441
  throw new Error(
442
442
  "Invalid argument for remainder. Must be an even TimeSpan or Timestamp"
443
443
  );
444
444
  const r = n.valueOf() % t.valueOf();
445
- return n instanceof o ? new o(r) : new p(r);
445
+ return n instanceof u ? new u(r) : new l(r);
446
446
  };
447
- class o extends F {
447
+ class u extends Z {
448
448
  constructor(e, t = "UTC") {
449
- if (e == null) super(o.now().valueOf());
449
+ if (e == null) super(u.now().valueOf());
450
450
  else if (e instanceof Date)
451
- super(BigInt(e.getTime()) * o.MILLISECOND.valueOf());
451
+ super(BigInt(e.getTime()) * u.MILLISECOND.valueOf());
452
452
  else if (typeof e == "string")
453
- super(o.parseDateTimeString(e, t).valueOf());
454
- else if (Array.isArray(e)) super(o.parseDate(e));
453
+ super(u.parseDateTimeString(e, t).valueOf());
454
+ else if (Array.isArray(e)) super(u.parseDate(e));
455
455
  else {
456
456
  let r = 0n;
457
- e instanceof Number && (e = e.valueOf()), t === "local" && (r = o.utcOffset.valueOf()), typeof e == "number" && (isFinite(e) ? e = Math.trunc(e) : (isNaN(e) && (e = 0), e === 1 / 0 ? e = o.MAX : e = o.MIN)), E(e) && (e = e.value), super(BigInt(e.valueOf()) + r);
457
+ e instanceof Number && (e = e.valueOf()), t === "local" && (r = u.utcOffset.valueOf()), typeof e == "number" && (isFinite(e) ? e === Zt ? e = ce : e = Math.trunc(e) : (isNaN(e) && (e = 0), e === 1 / 0 ? e = u.MAX : e = u.MIN)), U(e) && (e = e.value), super(BigInt(e.valueOf()) + r);
458
458
  }
459
459
  }
460
460
  static parseDate([e = 1970, t = 1, r = 1]) {
461
461
  const i = new Date(e, t - 1, r, 0, 0, 0, 0);
462
- return new o(BigInt(i.getTime()) * o.MILLISECOND.valueOf()).truncate(o.DAY).valueOf();
462
+ return new u(BigInt(i.getTime()) * u.MILLISECOND.valueOf()).truncate(u.DAY).valueOf();
463
463
  }
464
464
  /**
465
465
  * @returns the primitive value of the TimeStamp. Overrides standard JS valueOf()
@@ -470,49 +470,22 @@ class o extends F {
470
470
  }
471
471
  static parseTimeString(e, t = "UTC") {
472
472
  const [r, i, a] = e.split(":");
473
- let c = "00", g = "00";
474
- a != null && ([c, g] = a.split("."));
475
- let y = o.hours(parseInt(r ?? "00")).add(o.minutes(parseInt(i ?? "00"))).add(o.seconds(parseInt(c ?? "00"))).add(o.milliseconds(parseInt(g ?? "00")));
476
- return t === "local" && (y = y.add(o.utcOffset)), y.valueOf();
473
+ let c = "00", d = "00";
474
+ a != null && ([c, d] = a.split("."));
475
+ let y = u.hours(parseInt(r ?? "00")).add(u.minutes(parseInt(i ?? "00"))).add(u.seconds(parseInt(c ?? "00"))).add(u.milliseconds(parseInt(d ?? "00")));
476
+ return t === "local" && (y = y.add(u.utcOffset)), y.valueOf();
477
477
  }
478
478
  static parseDateTimeString(e, t = "UTC") {
479
479
  if (!e.includes("/") && !e.includes("-"))
480
- return o.parseTimeString(e, t);
480
+ return u.parseTimeString(e, t);
481
481
  const r = new Date(e);
482
- return e.includes(":") || r.setUTCHours(0, 0, 0, 0), new o(
483
- BigInt(r.getTime()) * o.MILLISECOND.valueOf(),
482
+ return e.includes(":") || r.setUTCHours(0, 0, 0, 0), new u(
483
+ BigInt(r.getTime()) * u.MILLISECOND.valueOf(),
484
484
  t
485
485
  ).valueOf();
486
486
  }
487
- /**
488
- * Formats the TimeStamp as a string in the specified format.
489
- *
490
- * @param format - The format to use for the string representation.
491
- * @param tzInfo - The timezone to use when creating the string representation.
492
- * @returns A string representation of the TimeStamp in the specified format.
493
- */
494
- fString(e = "ISO", t = "UTC") {
495
- switch (e) {
496
- case "ISODate":
497
- return this.toISOString(t).slice(0, 10);
498
- case "ISOTime":
499
- return this.toISOString(t).slice(11, 23);
500
- case "time":
501
- return this.timeString(!1, t);
502
- case "preciseTime":
503
- return this.timeString(!0, t);
504
- case "date":
505
- return this.dateString();
506
- case "preciseDate":
507
- return `${this.dateString()} ${this.timeString(!0, t)}`;
508
- case "dateTime":
509
- return `${this.dateString()} ${this.timeString(!1, t)}`;
510
- default:
511
- return this.toISOString(t);
512
- }
513
- }
514
487
  toISOString(e = "UTC") {
515
- return e === "UTC" ? this.date().toISOString() : this.sub(o.utcOffset).date().toISOString();
488
+ return e === "UTC" ? this.date().toISOString() : this.sub(u.utcOffset).date().toISOString();
516
489
  }
517
490
  timeString(e = !1, t = "UTC") {
518
491
  const r = this.toISOString(t);
@@ -524,8 +497,8 @@ class o extends F {
524
497
  }
525
498
  /** @returns The UTC offset for the time zone of the machine. */
526
499
  static get utcOffset() {
527
- return new p(
528
- BigInt((/* @__PURE__ */ new Date()).getTimezoneOffset()) * o.MINUTE.valueOf()
500
+ return new l(
501
+ BigInt((/* @__PURE__ */ new Date()).getTimezoneOffset()) * u.MINUTE.valueOf()
529
502
  );
530
503
  }
531
504
  /**
@@ -534,7 +507,7 @@ class o extends F {
534
507
  * @param other - The other timestamp.
535
508
  */
536
509
  static since(e) {
537
- return new o().span(e);
510
+ return new u().span(e);
538
511
  }
539
512
  /** @returns A JavaScript Date object representing the TimeStamp. */
540
513
  date() {
@@ -547,7 +520,7 @@ class o extends F {
547
520
  * @returns True if the TimeStamps are equal, false otherwise.
548
521
  */
549
522
  equals(e) {
550
- return this.valueOf() === new o(e).valueOf();
523
+ return this.valueOf() === new u(e).valueOf();
551
524
  }
552
525
  /**
553
526
  * Creates a TimeSpan representing the duration between the two timestamps.
@@ -567,7 +540,7 @@ class o extends F {
567
540
  * valid, regardless of the TimeStamp order.
568
541
  */
569
542
  range(e) {
570
- return new W(this, e).makeValid();
543
+ return new x(this, e).makeValid();
571
544
  }
572
545
  /**
573
546
  * Creates a TimeRange starting at the TimeStamp and spanning the given
@@ -596,7 +569,7 @@ class o extends F {
596
569
  * otherwise.
597
570
  */
598
571
  after(e) {
599
- return this.valueOf() > new o(e).valueOf();
572
+ return this.valueOf() > new u(e).valueOf();
600
573
  }
601
574
  /**
602
575
  * Checks if the TimeStamp is after or equal to the given TimeStamp.
@@ -606,7 +579,7 @@ class o extends F {
606
579
  * false otherwise.
607
580
  */
608
581
  afterEq(e) {
609
- return this.valueOf() >= new o(e).valueOf();
582
+ return this.valueOf() >= new u(e).valueOf();
610
583
  }
611
584
  /**
612
585
  * Checks if the TimeStamp is before the given TimeStamp.
@@ -616,7 +589,7 @@ class o extends F {
616
589
  * otherwise.
617
590
  */
618
591
  before(e) {
619
- return this.valueOf() < new o(e).valueOf();
592
+ return this.valueOf() < new u(e).valueOf();
620
593
  }
621
594
  /**
622
595
  * Checks if TimeStamp is before or equal to the current timestamp.
@@ -626,7 +599,7 @@ class o extends F {
626
599
  * false otherwise.
627
600
  */
628
601
  beforeEq(e) {
629
- return this.valueOf() <= new o(e).valueOf();
602
+ return this.valueOf() <= new u(e).valueOf();
630
603
  }
631
604
  /**
632
605
  * Adds a TimeSpan to the TimeStamp.
@@ -636,7 +609,7 @@ class o extends F {
636
609
  * TimeSpan.
637
610
  */
638
611
  add(e) {
639
- return new o(te(this.valueOf(), new p(e).valueOf()));
612
+ return new u(re(this.valueOf(), new l(e).valueOf()));
640
613
  }
641
614
  /**
642
615
  * Subtracts a TimeSpan from the TimeStamp.
@@ -646,43 +619,43 @@ class o extends F {
646
619
  * TimeSpan.
647
620
  */
648
621
  sub(e) {
649
- return new o(ee(this.valueOf(), new p(e).valueOf()));
622
+ return new u(ne(this.valueOf(), new l(e).valueOf()));
650
623
  }
651
624
  /**
652
625
  * @returns the floating point number of hours since the unix epoch to the timestamp
653
626
  * value.
654
627
  */
655
628
  get hours() {
656
- return Number(this.valueOf()) / Number(p.HOUR.valueOf());
629
+ return Number(this.valueOf()) / Number(l.HOUR.valueOf());
657
630
  }
658
631
  /**
659
632
  * @returns the floating point number of minutes since the unix epoch to the timestamp
660
633
  * value.
661
634
  */
662
635
  get minutes() {
663
- return Number(this.valueOf()) / Number(p.MINUTE.valueOf());
636
+ return Number(this.valueOf()) / Number(l.MINUTE.valueOf());
664
637
  }
665
638
  /**
666
639
  * @returns the floating point number of days since the unix epoch to the timestamp
667
640
  * value.
668
641
  */
669
642
  get days() {
670
- return Number(this.valueOf()) / Number(p.DAY.valueOf());
643
+ return Number(this.valueOf()) / Number(l.DAY.valueOf());
671
644
  }
672
645
  /**
673
646
  * @returns the floating point number of seconds since the unix epoch to the timestamp
674
647
  * value.
675
648
  */
676
649
  get seconds() {
677
- return Number(this.valueOf()) / Number(p.SECOND.valueOf());
650
+ return Number(this.valueOf()) / Number(l.SECOND.valueOf());
678
651
  }
679
652
  /** @returns the floating point number of milliseconds since the unix epoch. */
680
653
  get milliseconds() {
681
- return Number(this.valueOf()) / Number(o.MILLISECOND.valueOf());
654
+ return Number(this.valueOf()) / Number(u.MILLISECOND.valueOf());
682
655
  }
683
656
  /** @returns the floating point number of microseconds since the unix epoch. */
684
657
  get microseconds() {
685
- return Number(this.valueOf()) / Number(o.MICROSECOND.valueOf());
658
+ return Number(this.valueOf()) / Number(u.MICROSECOND.valueOf());
686
659
  }
687
660
  /**
688
661
  * @returns the floating point number of nanoseconds since the unix epoch.
@@ -702,7 +675,7 @@ class o extends F {
702
675
  */
703
676
  setYear(e) {
704
677
  const t = this.date();
705
- return t.setUTCFullYear(e), new o(t);
678
+ return t.setUTCFullYear(e), new u(t);
706
679
  }
707
680
  /** @returns the integer month that the timestamp corresponds to with its year. */
708
681
  get month() {
@@ -714,7 +687,7 @@ class o extends F {
714
687
  */
715
688
  setMonth(e) {
716
689
  const t = this.date();
717
- return t.setUTCMonth(e), new o(t);
690
+ return t.setUTCMonth(e), new u(t);
718
691
  }
719
692
  /** @returns the integer day that the timestamp corresponds to within its month. */
720
693
  get day() {
@@ -726,7 +699,7 @@ class o extends F {
726
699
  */
727
700
  setDay(e) {
728
701
  const t = this.date();
729
- return t.setUTCDate(e), new o(t);
702
+ return t.setUTCDate(e), new u(t);
730
703
  }
731
704
  /**
732
705
  * @returns the integer hour that the timestamp corresponds to within its day.
@@ -746,7 +719,7 @@ class o extends F {
746
719
  */
747
720
  setLocalHour(e) {
748
721
  const t = this.date();
749
- return t.setHours(e), new o(t);
722
+ return t.setHours(e), new u(t);
750
723
  }
751
724
  /**
752
725
  * @returns a copy of the timestamp with the hour changed.
@@ -754,7 +727,7 @@ class o extends F {
754
727
  */
755
728
  setHour(e) {
756
729
  const t = this.date();
757
- return t.setUTCHours(e), new o(t);
730
+ return t.setUTCHours(e), new u(t);
758
731
  }
759
732
  /** @returns the integer minute that the timestamp corresponds to within its hour. */
760
733
  get minute() {
@@ -766,7 +739,7 @@ class o extends F {
766
739
  */
767
740
  setMinute(e) {
768
741
  const t = this.date();
769
- return t.setUTCMinutes(e), new o(t);
742
+ return t.setUTCMinutes(e), new u(t);
770
743
  }
771
744
  /**
772
745
  * @returns the integer second that the timestamp corresponds to within its
@@ -781,11 +754,11 @@ class o extends F {
781
754
  */
782
755
  setSecond(e) {
783
756
  const t = this.date();
784
- return t.setUTCSeconds(e), new o(t);
757
+ return t.setUTCSeconds(e), new u(t);
785
758
  }
786
759
  /**
787
- * @reutrns the integer millisecond that the timestamp corresponds to within
788
- * its second.
760
+ * @returns the integer millisecond that the timestamp corresponds to within its
761
+ * second.
789
762
  */
790
763
  get millisecond() {
791
764
  return this.date().getUTCMilliseconds();
@@ -796,11 +769,34 @@ class o extends F {
796
769
  */
797
770
  setMillisecond(e) {
798
771
  const t = this.date();
799
- return t.setUTCMilliseconds(e), new o(t);
772
+ return t.setUTCMilliseconds(e), new u(t);
800
773
  }
801
- /** @returns the time stamp formatted as an ISO string. */
802
- toString() {
803
- return this.date().toISOString();
774
+ /**
775
+ * Returns a string representation of the TimeStamp.
776
+ *
777
+ * @param format - Optional format for the string representation. Defaults to "ISO".
778
+ * @param tzInfo - Optional timezone info. Defaults to "UTC".
779
+ * @returns A string representation of the TimeStamp.
780
+ */
781
+ toString(e = "ISO", t = "UTC") {
782
+ switch (e) {
783
+ case "ISODate":
784
+ return this.toISOString(t).slice(0, 10);
785
+ case "ISOTime":
786
+ return this.toISOString(t).slice(11, 23);
787
+ case "time":
788
+ return this.timeString(!1, t);
789
+ case "preciseTime":
790
+ return this.timeString(!0, t);
791
+ case "date":
792
+ return this.dateString();
793
+ case "preciseDate":
794
+ return `${this.dateString()} ${this.timeString(!0, t)}`;
795
+ case "dateTime":
796
+ return `${this.dateString()} ${this.timeString(!1, t)}`;
797
+ default:
798
+ return this.toISOString(t);
799
+ }
804
800
  }
805
801
  /**
806
802
  * @returns A new TimeStamp that is the remainder of the TimeStamp divided by the
@@ -814,11 +810,11 @@ class o extends F {
814
810
  * @example TimeStamp.now().remainder(TimeStamp.DAY) // => TimeStamp representing the current day
815
811
  */
816
812
  remainder(e) {
817
- return ke(this, e);
813
+ return qe(this, e);
818
814
  }
819
815
  /** @returns true if the day portion TimeStamp is today, false otherwise. */
820
816
  get isToday() {
821
- return this.truncate(p.DAY).equals(o.now().truncate(p.DAY));
817
+ return this.truncate(l.DAY).equals(u.now().truncate(l.DAY));
822
818
  }
823
819
  /**
824
820
  * Truncates the TimeStamp to the nearest multiple of the given span.
@@ -835,7 +831,7 @@ class o extends F {
835
831
  * JavaScript can do).
836
832
  */
837
833
  static now() {
838
- return new o(/* @__PURE__ */ new Date());
834
+ return new u(/* @__PURE__ */ new Date());
839
835
  }
840
836
  /**
841
837
  * Finds the maximum timestamp among the provided timestamps.
@@ -844,9 +840,9 @@ class o extends F {
844
840
  * @returns The maximum (latest) timestamp from the input.
845
841
  */
846
842
  static max(...e) {
847
- let t = o.MIN;
843
+ let t = u.MIN;
848
844
  for (const r of e) {
849
- const i = new o(r);
845
+ const i = new u(r);
850
846
  i.after(t) && (t = i);
851
847
  }
852
848
  return t;
@@ -858,9 +854,9 @@ class o extends F {
858
854
  * @returns The minimum (earliest) timestamp from the input.
859
855
  */
860
856
  static min(...e) {
861
- let t = o.MAX;
857
+ let t = u.MAX;
862
858
  for (const r of e) {
863
- const i = new o(r);
859
+ const i = new u(r);
864
860
  i.before(t) && (t = i);
865
861
  }
866
862
  return t;
@@ -872,62 +868,62 @@ class o extends F {
872
868
  * @returns A TimeStamp representing the given number of nanoseconds.
873
869
  */
874
870
  static nanoseconds(e, t = "UTC") {
875
- return new o(e, t);
871
+ return new u(e, t);
876
872
  }
877
873
  /** One nanosecond after the unix epoch */
878
- static NANOSECOND = o.nanoseconds(1);
874
+ static NANOSECOND = u.nanoseconds(1);
879
875
  /** @returns a new TimeStamp n microseconds after the unix epoch */
880
876
  static microseconds(e, t = "UTC") {
881
- return o.nanoseconds(e * 1e3, t);
877
+ return u.nanoseconds(e * 1e3, t);
882
878
  }
883
879
  /** One microsecond after the unix epoch */
884
- static MICROSECOND = o.microseconds(1);
880
+ static MICROSECOND = u.microseconds(1);
885
881
  /** @returns a new TimeStamp n milliseconds after the unix epoch */
886
882
  static milliseconds(e, t = "UTC") {
887
- return o.microseconds(e * 1e3, t);
883
+ return u.microseconds(e * 1e3, t);
888
884
  }
889
885
  /** One millisecond after the unix epoch */
890
- static MILLISECOND = o.milliseconds(1);
886
+ static MILLISECOND = u.milliseconds(1);
891
887
  /** @returns a new TimeStamp n seconds after the unix epoch */
892
888
  static seconds(e, t = "UTC") {
893
- return o.milliseconds(e * 1e3, t);
889
+ return u.milliseconds(e * 1e3, t);
894
890
  }
895
891
  /** One second after the unix epoch */
896
- static SECOND = o.seconds(1);
892
+ static SECOND = u.seconds(1);
897
893
  /** @returns a new TimeStamp n minutes after the unix epoch */
898
894
  static minutes(e, t = "UTC") {
899
- return o.seconds(e * 60, t);
895
+ return u.seconds(e * 60, t);
900
896
  }
901
897
  /** One minute after the unix epoch */
902
- static MINUTE = o.minutes(1);
898
+ static MINUTE = u.minutes(1);
903
899
  /** @returns a new TimeStamp n hours after the unix epoch */
904
900
  static hours(e, t = "UTC") {
905
- return o.minutes(e * 60, t);
901
+ return u.minutes(e * 60, t);
906
902
  }
907
903
  /** One hour after the unix epoch */
908
- static HOUR = o.hours(1);
904
+ static HOUR = u.hours(1);
909
905
  /** @returns a new TimeStamp n days after the unix epoch */
910
906
  static days(e, t = "UTC") {
911
- return o.hours(e * 24, t);
907
+ return u.hours(e * 24, t);
912
908
  }
913
909
  /** One day after the unix epoch */
914
- static DAY = o.days(1);
910
+ static DAY = u.days(1);
915
911
  /** The maximum possible value for a timestamp */
916
- static MAX = new o((1n << 63n) - 1n);
912
+ static MAX = new u(ce);
917
913
  /** The minimum possible value for a timestamp */
918
- static MIN = new o(0);
914
+ static MIN = new u(0);
919
915
  /** The unix epoch */
920
- static ZERO = new o(0);
916
+ static ZERO = new u(0);
921
917
  /** A zod schema for validating timestamps */
922
918
  static z = s.union([
923
- s.instanceof(o),
924
- s.object({ value: s.bigint() }).transform((e) => new o(e.value)),
925
- s.string().transform((e) => new o(BigInt(e))),
926
- s.number().transform((e) => new o(e)),
927
- s.bigint().transform((e) => new o(e)),
928
- s.date().transform((e) => new o(e)),
929
- s.custom((e) => e instanceof p).transform((e) => new o(e)),
930
- qt.transform((e) => new o(e))
919
+ s.instanceof(u),
920
+ s.object({ value: s.bigint() }).transform((e) => new u(e.value)),
921
+ s.string().transform((e) => new u(BigInt(e))),
922
+ s.number().transform((e) => new u(e)),
923
+ s.bigint().transform((e) => new u(e)),
924
+ s.date().transform((e) => new u(e)),
925
+ s.custom((e) => e instanceof l).transform((e) => new u(e)),
926
+ Gt.transform((e) => new u(e))
931
927
  ]);
932
928
  /**
933
929
  * Sorts two timestamps.
@@ -941,9 +937,9 @@ class o extends F {
941
937
  return Number(e.valueOf() - t.valueOf());
942
938
  }
943
939
  }
944
- let p = class l extends F {
940
+ class l extends Z {
945
941
  constructor(e) {
946
- typeof e == "number" && (e = Math.trunc(e.valueOf())), E(e) && (e = e.value), super(BigInt(e.valueOf()));
942
+ typeof e == "number" && (e = Math.trunc(e.valueOf())), U(e) && (e = e.value), super(BigInt(e.valueOf()));
947
943
  }
948
944
  /**
949
945
  * Creates a TimeSpan representing the given number of seconds.
@@ -952,7 +948,7 @@ let p = class l extends F {
952
948
  * @returns A TimeSpan representing the given number of seconds.
953
949
  */
954
950
  static fromSeconds(e) {
955
- return e instanceof l ? e : e instanceof S ? e.period : e instanceof o ? new l(e) : (E(e) && (e = e.value), ["number", "bigint"].includes(typeof e) ? l.seconds(e) : new l(e));
951
+ return e instanceof l ? e : e instanceof E ? e.period : e instanceof u ? new l(e) : (U(e) && (e = e.value), ["number", "bigint"].includes(typeof e) ? l.seconds(e) : new l(e));
956
952
  }
957
953
  /**
958
954
  * Creates a TimeSpan representing the given number of milliseconds.
@@ -961,7 +957,7 @@ let p = class l extends F {
961
957
  * @returns A TimeSpan representing the given number of milliseconds.
962
958
  */
963
959
  static fromMilliseconds(e) {
964
- return e instanceof l ? e : e instanceof S ? e.period : e instanceof o ? new l(e) : (E(e) && (e = e.value), ["number", "bigint"].includes(typeof e) ? l.milliseconds(e) : new l(e));
960
+ return e instanceof l ? e : e instanceof E ? e.period : e instanceof u ? new l(e) : (U(e) && (e = e.value), ["number", "bigint"].includes(typeof e) ? l.milliseconds(e) : new l(e));
965
961
  }
966
962
  /**
967
963
  * @returns the primitive value of the TimeSpan. Overrides standard JS valueOf()
@@ -1013,7 +1009,7 @@ let p = class l extends F {
1013
1009
  * @returns A new TimeSpan representing the remainder.
1014
1010
  */
1015
1011
  remainder(e) {
1016
- return ke(this, e);
1012
+ return qe(this, e);
1017
1013
  }
1018
1014
  /**
1019
1015
  * Truncates the TimeSpan to the nearest multiple of the given span.
@@ -1029,12 +1025,72 @@ let p = class l extends F {
1029
1025
  /**
1030
1026
  * Returns a string representation of the TimeSpan.
1031
1027
  *
1028
+ * @param format - Optional format for the string representation. Defaults to "full".
1029
+ * - "full": Shows all non-zero units with full precision (e.g., "2d 3h 45m 12s 500ms")
1030
+ * - "semantic": Shows 1-2 most significant units (e.g., "2d 3h")
1032
1031
  * @returns A string representation of the TimeSpan.
1033
1032
  */
1034
- toString() {
1035
- const e = this.truncate(l.DAY), t = this.truncate(l.HOUR), r = this.truncate(l.MINUTE), i = this.truncate(l.SECOND), a = this.truncate(l.MILLISECOND), c = this.truncate(l.MICROSECOND), g = this.truncate(l.NANOSECOND), y = e, f = t.sub(e), m = r.sub(t), b = i.sub(r), h = a.sub(i), T = c.sub(a), A = g.sub(c);
1036
- let C = "";
1037
- return y.isZero || (C += `${y.days}d `), f.isZero || (C += `${f.hours}h `), m.isZero || (C += `${m.minutes}m `), b.isZero || (C += `${b.seconds}s `), h.isZero || (C += `${h.milliseconds}ms `), T.isZero || (C += `${T.microseconds}µs `), A.isZero || (C += `${A.nanoseconds}ns`), C.trim();
1033
+ toString(e = "full") {
1034
+ if (e === "semantic") return this.toSemanticString();
1035
+ const t = this.truncate(l.DAY), r = this.truncate(l.HOUR), i = this.truncate(l.MINUTE), a = this.truncate(l.SECOND), c = this.truncate(l.MILLISECOND), d = this.truncate(l.MICROSECOND), y = this.truncate(l.NANOSECOND), f = t, g = r.sub(t), w = i.sub(r), h = a.sub(i), T = c.sub(a), A = d.sub(c), M = y.sub(d);
1036
+ let m = "";
1037
+ return f.isZero || (m += `${f.days}d `), g.isZero || (m += `${g.hours}h `), w.isZero || (m += `${w.minutes}m `), h.isZero || (m += `${h.seconds}s `), T.isZero || (m += `${T.milliseconds}ms `), A.isZero || (m += `${A.microseconds}µs `), M.isZero || (m += `${M.nanoseconds}ns`), m.trim();
1038
+ }
1039
+ toSemanticString() {
1040
+ const e = this.valueOf() < 0n ? -this.valueOf() : this.valueOf(), t = new l(e), r = this.valueOf() < 0n;
1041
+ if (t.valueOf() === 0n) return "0s";
1042
+ if (t.lessThan(l.SECOND)) return "< 1s";
1043
+ const i = t.days, a = t.hours, c = t.minutes, d = t.seconds, y = Math.floor(i / xe), f = Math.floor(i / K), g = Math.floor(i / 7), w = Math.floor(i), h = Math.floor(a), T = Math.floor(c), A = Math.floor(d), M = r ? "-" : "";
1044
+ if (y >= 1) {
1045
+ let m = `${y}y`;
1046
+ if (y < 2) {
1047
+ const v = Math.floor(
1048
+ i % xe / K
1049
+ );
1050
+ v > 0 && (m += ` ${v}mo`);
1051
+ }
1052
+ return M + m;
1053
+ }
1054
+ if (g >= 1 && i < K && i % 7 === 0) {
1055
+ let m = `${g}w`;
1056
+ const v = Math.floor(i % 7), L = Math.floor(a - g * 7 * 24);
1057
+ return g < 2 && (v > 0 ? m += ` ${v}d` : L > 0 && L < 24 && (m += ` ${L}h`)), M + m;
1058
+ }
1059
+ if (f >= 1) {
1060
+ let m = `${f}mo`;
1061
+ if (f < 3) {
1062
+ const v = Math.floor(i % K);
1063
+ v > 0 && (m += ` ${v}d`);
1064
+ }
1065
+ return M + m;
1066
+ }
1067
+ if (g >= 1) {
1068
+ let m = `${g}w`;
1069
+ const v = Math.floor(i % 7), L = Math.floor(a - g * 7 * 24);
1070
+ return g < 2 && (v > 0 ? m += ` ${v}d` : L > 0 && L < 24 && (m += ` ${L}h`)), M + m;
1071
+ }
1072
+ if (w >= 1) {
1073
+ let m = `${w}d`;
1074
+ const v = Math.floor(a - w * 24);
1075
+ return w < 2 && v > 0 && (m += ` ${v}h`), M + m;
1076
+ }
1077
+ if (h >= 1) {
1078
+ let m = `${h}h`;
1079
+ if (h < 3) {
1080
+ const v = Math.floor(c - h * 60);
1081
+ v > 0 && (m += ` ${v}m`);
1082
+ }
1083
+ return M + m;
1084
+ }
1085
+ if (T >= 1) {
1086
+ let m = `${T}m`;
1087
+ if (T < 5) {
1088
+ const v = Math.floor(d - T * 60);
1089
+ v > 0 && (m += ` ${v}s`);
1090
+ }
1091
+ return M + m;
1092
+ }
1093
+ return `${M}${A}s`;
1038
1094
  }
1039
1095
  /**
1040
1096
  * Multiplies the TimeSpan by a scalar value.
@@ -1043,7 +1099,7 @@ let p = class l extends F {
1043
1099
  * @returns A new TimeSpan that is this TimeSpan multiplied by the provided value.
1044
1100
  */
1045
1101
  mult(e) {
1046
- return new l(M(this.valueOf(), e));
1102
+ return new l(C(this.valueOf(), e));
1047
1103
  }
1048
1104
  /**
1049
1105
  * Divides the TimeSpan by a scalar value.
@@ -1052,7 +1108,7 @@ let p = class l extends F {
1052
1108
  * @returns A new TimeSpan that is this TimeSpan divided by the provided value.
1053
1109
  */
1054
1110
  div(e) {
1055
- return new l(ne(this.valueOf(), e));
1111
+ return new l(se(this.valueOf(), e));
1056
1112
  }
1057
1113
  /** @returns the decimal number of days in the TimeSpan. */
1058
1114
  get days() {
@@ -1132,7 +1188,7 @@ let p = class l extends F {
1132
1188
  * @returns A TimeSpan representing the given number of microseconds.
1133
1189
  */
1134
1190
  static microseconds(e = 1) {
1135
- return l.nanoseconds(M(e, 1e3));
1191
+ return l.nanoseconds(C(e, 1e3));
1136
1192
  }
1137
1193
  /** A microsecond. */
1138
1194
  static MICROSECOND = l.microseconds(1);
@@ -1143,7 +1199,7 @@ let p = class l extends F {
1143
1199
  * @returns A TimeSpan representing the given number of milliseconds.
1144
1200
  */
1145
1201
  static milliseconds(e = 1) {
1146
- return l.microseconds(M(e, 1e3));
1202
+ return l.microseconds(C(e, 1e3));
1147
1203
  }
1148
1204
  /** A millisecond. */
1149
1205
  static MILLISECOND = l.milliseconds(1);
@@ -1154,7 +1210,7 @@ let p = class l extends F {
1154
1210
  * @returns A TimeSpan representing the given number of seconds.
1155
1211
  */
1156
1212
  static seconds(e = 1) {
1157
- return l.milliseconds(M(e, 1e3));
1213
+ return l.milliseconds(C(e, 1e3));
1158
1214
  }
1159
1215
  /** A second. */
1160
1216
  static SECOND = l.seconds(1);
@@ -1165,7 +1221,7 @@ let p = class l extends F {
1165
1221
  * @returns A TimeSpan representing the given number of minutes.
1166
1222
  */
1167
1223
  static minutes(e = 1) {
1168
- return l.seconds(M(e, 60));
1224
+ return l.seconds(C(e, 60));
1169
1225
  }
1170
1226
  /** A minute. */
1171
1227
  static MINUTE = l.minutes(1);
@@ -1176,7 +1232,7 @@ let p = class l extends F {
1176
1232
  * @returns A TimeSpan representing the given number of hours.
1177
1233
  */
1178
1234
  static hours(e) {
1179
- return l.minutes(M(e, 60));
1235
+ return l.minutes(C(e, 60));
1180
1236
  }
1181
1237
  /** Represents an hour. */
1182
1238
  static HOUR = l.hours(1);
@@ -1187,30 +1243,30 @@ let p = class l extends F {
1187
1243
  * @returns A TimeSpan representing the given number of days.
1188
1244
  */
1189
1245
  static days(e) {
1190
- return l.hours(M(e, 24));
1246
+ return l.hours(C(e, 24));
1191
1247
  }
1192
1248
  /** Represents a day. */
1193
1249
  static DAY = l.days(1);
1194
1250
  /** The maximum possible value for a TimeSpan. */
1195
- static MAX = new l((1n << 63n) - 1n);
1251
+ static MAX = new l(ce);
1196
1252
  /** The minimum possible value for a TimeSpan. */
1197
1253
  static MIN = new l(0);
1198
1254
  /** The zero value for a TimeSpan. */
1199
1255
  static ZERO = new l(0);
1200
- /** A zod schema for validating and transforming timespans */
1256
+ /** A zod schema for validating and transforming time spans */
1201
1257
  static z = s.union([
1202
1258
  s.object({ value: s.bigint() }).transform((e) => new l(e.value)),
1203
1259
  s.string().transform((e) => new l(BigInt(e))),
1204
1260
  s.number().transform((e) => new l(e)),
1205
1261
  s.bigint().transform((e) => new l(e)),
1206
1262
  s.instanceof(l),
1207
- s.instanceof(o).transform((e) => new l(e)),
1208
- s.custom((e) => e instanceof S).transform((e) => new l(e))
1263
+ s.instanceof(u).transform((e) => new l(e)),
1264
+ s.custom((e) => e instanceof E).transform((e) => new l(e))
1209
1265
  ]);
1210
- };
1211
- class S extends F {
1266
+ }
1267
+ class E extends Z {
1212
1268
  constructor(e) {
1213
- E(e) && (e = e.value), super(e.valueOf());
1269
+ U(e) && (e = e.value), super(e.valueOf());
1214
1270
  }
1215
1271
  /** @returns a pretty string representation of the rate in the format "X Hz". */
1216
1272
  toString() {
@@ -1218,7 +1274,7 @@ class S extends F {
1218
1274
  }
1219
1275
  /** @returns The number of seconds in the Rate. */
1220
1276
  equals(e) {
1221
- return this.valueOf() === new S(e).valueOf();
1277
+ return this.valueOf() === new E(e).valueOf();
1222
1278
  }
1223
1279
  /**
1224
1280
  * Calculates the period of the Rate as a TimeSpan.
@@ -1226,7 +1282,7 @@ class S extends F {
1226
1282
  * @returns A TimeSpan representing the period of the Rate.
1227
1283
  */
1228
1284
  get period() {
1229
- return p.seconds(1 / this.valueOf());
1285
+ return l.seconds(1 / this.valueOf());
1230
1286
  }
1231
1287
  /**
1232
1288
  * Calculates the number of samples in the given TimeSpan at this rate.
@@ -1235,7 +1291,7 @@ class S extends F {
1235
1291
  * @returns The number of samples in the given TimeSpan at this rate.
1236
1292
  */
1237
1293
  sampleCount(e) {
1238
- return new p(e).seconds * this.valueOf();
1294
+ return new l(e).seconds * this.valueOf();
1239
1295
  }
1240
1296
  /**
1241
1297
  * Calculates the number of bytes in the given TimeSpan at this rate.
@@ -1254,7 +1310,7 @@ class S extends F {
1254
1310
  * @returns A TimeSpan that corresponds to the given number of samples.
1255
1311
  */
1256
1312
  span(e) {
1257
- return p.seconds(e / this.valueOf());
1313
+ return l.seconds(e / this.valueOf());
1258
1314
  }
1259
1315
  /**
1260
1316
  * Calculates a TimeSpan given the number of bytes at this rate.
@@ -1273,7 +1329,7 @@ class S extends F {
1273
1329
  * @returns A new Rate representing the sum of the two rates.
1274
1330
  */
1275
1331
  add(e) {
1276
- return new S(te(this.valueOf(), new S(e).valueOf()));
1332
+ return new E(re(this.valueOf(), new E(e).valueOf()));
1277
1333
  }
1278
1334
  /**
1279
1335
  * Subtracts another Rate from this Rate.
@@ -1282,7 +1338,7 @@ class S extends F {
1282
1338
  * @returns A new Rate representing the difference of the two rates.
1283
1339
  */
1284
1340
  sub(e) {
1285
- return new S(ee(this.valueOf(), new S(e).valueOf()));
1341
+ return new E(ne(this.valueOf(), new E(e).valueOf()));
1286
1342
  }
1287
1343
  /**
1288
1344
  * Multiplies this Rate by a scalar value.
@@ -1291,7 +1347,7 @@ class S extends F {
1291
1347
  * @returns A new Rate representing this Rate multiplied by the value.
1292
1348
  */
1293
1349
  mult(e) {
1294
- return new S(M(this.valueOf(), e));
1350
+ return new E(C(this.valueOf(), e));
1295
1351
  }
1296
1352
  /**
1297
1353
  * Divides this Rate by a scalar value.
@@ -1300,7 +1356,7 @@ class S extends F {
1300
1356
  * @returns A new Rate representing this Rate divided by the value.
1301
1357
  */
1302
1358
  div(e) {
1303
- return new S(ne(this.valueOf(), e));
1359
+ return new E(se(this.valueOf(), e));
1304
1360
  }
1305
1361
  /**
1306
1362
  * Creates a Rate representing the given number of Hz.
@@ -1309,7 +1365,7 @@ class S extends F {
1309
1365
  * @returns A Rate representing the given number of Hz.
1310
1366
  */
1311
1367
  static hz(e) {
1312
- return new S(e);
1368
+ return new E(e);
1313
1369
  }
1314
1370
  /**
1315
1371
  * Creates a Rate representing the given number of kHz.
@@ -1318,15 +1374,15 @@ class S extends F {
1318
1374
  * @returns A Rate representing the given number of kHz.
1319
1375
  */
1320
1376
  static khz(e) {
1321
- return S.hz(e * 1e3);
1377
+ return E.hz(e * 1e3);
1322
1378
  }
1323
1379
  /** A zod schema for validating and transforming rates */
1324
1380
  static z = s.union([
1325
- s.number().transform((e) => new S(e)),
1326
- s.instanceof(S)
1381
+ s.number().transform((e) => new E(e)),
1382
+ s.instanceof(E)
1327
1383
  ]);
1328
1384
  }
1329
- let I = class N extends F {
1385
+ let I = class N extends Z {
1330
1386
  /**
1331
1387
  * Creates a Density representing the given number of bytes per value.
1332
1388
  *
@@ -1335,7 +1391,7 @@ let I = class N extends F {
1335
1391
  * @returns A Density representing the given number of bytes per value.
1336
1392
  */
1337
1393
  constructor(e) {
1338
- E(e) && (e = e.value), super(e.valueOf());
1394
+ U(e) && (e = e.value), super(e.valueOf());
1339
1395
  }
1340
1396
  /**
1341
1397
  * Calculates the number of values in the given Size.
@@ -1353,7 +1409,7 @@ let I = class N extends F {
1353
1409
  * @returns A Size representing the given number of values.
1354
1410
  */
1355
1411
  size(e) {
1356
- return new ue(e * this.valueOf());
1412
+ return new he(e * this.valueOf());
1357
1413
  }
1358
1414
  /**
1359
1415
  * Adds another Density to this Density.
@@ -1362,7 +1418,7 @@ let I = class N extends F {
1362
1418
  * @returns A new Density representing the sum of the two densities.
1363
1419
  */
1364
1420
  add(e) {
1365
- return new N(te(this.valueOf(), new N(e).valueOf()));
1421
+ return new N(re(this.valueOf(), new N(e).valueOf()));
1366
1422
  }
1367
1423
  /**
1368
1424
  * Subtracts another Density from this Density.
@@ -1371,7 +1427,7 @@ let I = class N extends F {
1371
1427
  * @returns A new Density representing the difference of the two densities.
1372
1428
  */
1373
1429
  sub(e) {
1374
- return new N(ee(this.valueOf(), new N(e).valueOf()));
1430
+ return new N(ne(this.valueOf(), new N(e).valueOf()));
1375
1431
  }
1376
1432
  /**
1377
1433
  * Multiplies this Density by a scalar value.
@@ -1380,7 +1436,7 @@ let I = class N extends F {
1380
1436
  * @returns A new Density representing this Density multiplied by the value.
1381
1437
  */
1382
1438
  mult(e) {
1383
- return new N(M(this.valueOf(), e));
1439
+ return new N(C(this.valueOf(), e));
1384
1440
  }
1385
1441
  /**
1386
1442
  * Divides this Density by a scalar value.
@@ -1389,7 +1445,7 @@ let I = class N extends F {
1389
1445
  * @returns A new Density representing this Density divided by the value.
1390
1446
  */
1391
1447
  div(e) {
1392
- return new N(ne(this.valueOf(), e));
1448
+ return new N(se(this.valueOf(), e));
1393
1449
  }
1394
1450
  /** Unknown/Invalid Density. */
1395
1451
  static UNKNOWN = new N(0);
@@ -1408,7 +1464,8 @@ let I = class N extends F {
1408
1464
  s.number().transform((e) => new N(e)),
1409
1465
  s.instanceof(N)
1410
1466
  ]);
1411
- }, W = class x {
1467
+ };
1468
+ class x {
1412
1469
  /**
1413
1470
  * The starting TimeStamp of the TimeRange.
1414
1471
  *
@@ -1434,11 +1491,11 @@ let I = class N extends F {
1434
1491
  * @param end - A TimeStamp representing the end of the range.
1435
1492
  */
1436
1493
  constructor(e, t) {
1437
- typeof e == "object" && "start" in e ? (this.start = new o(e.start), this.end = new o(e.end)) : (this.start = new o(e), this.end = new o(t));
1494
+ typeof e == "object" && "start" in e ? (this.start = new u(e.start), this.end = new u(e.end)) : (this.start = new u(e), this.end = new u(t));
1438
1495
  }
1439
1496
  /** @returns The TimeSpan occupied by the TimeRange. */
1440
1497
  get span() {
1441
- return new p(this.end.valueOf() - this.start.valueOf());
1498
+ return new l(this.end.valueOf() - this.start.valueOf());
1442
1499
  }
1443
1500
  /**
1444
1501
  * Checks if the timestamp is valid i.e. the start is before the end.
@@ -1457,12 +1514,12 @@ let I = class N extends F {
1457
1514
  return this.isValid ? this : this.swap();
1458
1515
  }
1459
1516
  /**
1460
- * Checks if the TimeRange has a zero span.
1517
+ * Checks if the TimeRange is zero (both start and end are TimeStamp.ZERO).
1461
1518
  *
1462
- * @returns True if the TimeRange has a zero span.
1519
+ * @returns True if both start and end are TimeStamp.ZERO, false otherwise.
1463
1520
  */
1464
1521
  get isZero() {
1465
- return this.span.isZero;
1522
+ return this.start.isZero && this.end.isZero;
1466
1523
  }
1467
1524
  /**
1468
1525
  * @returns the TimeRange as a numeric object with start and end properties.
@@ -1490,7 +1547,7 @@ let I = class N extends F {
1490
1547
  * @param other - The TimeRange to compare to.
1491
1548
  * @returns True if the TimeRange is equal to the given TimeRange.
1492
1549
  */
1493
- equals(e, t = p.ZERO) {
1550
+ equals(e, t = l.ZERO) {
1494
1551
  if (t.isZero)
1495
1552
  return this.start.equals(e.start) && this.end.equals(e.end);
1496
1553
  let r = this.start.sub(e.start).valueOf(), i = this.end.sub(e.end).valueOf();
@@ -1510,7 +1567,7 @@ let I = class N extends F {
1510
1567
  * @returns A pretty string representation of the TimeRange.
1511
1568
  */
1512
1569
  toPrettyString() {
1513
- return `${this.start.fString("preciseDate")} - ${this.span.toString()}`;
1570
+ return `${this.start.toString("preciseDate")} - ${this.span.toString()}`;
1514
1571
  }
1515
1572
  /**
1516
1573
  * Checks if the two time ranges overlap. If the two time ranges are equal, returns
@@ -1523,13 +1580,13 @@ let I = class N extends F {
1523
1580
  * checking for overlap.
1524
1581
  * @returns True if the two TimeRanges overlap, false otherwise.
1525
1582
  */
1526
- overlapsWith(e, t = p.ZERO) {
1583
+ overlapsWith(e, t = l.ZERO) {
1527
1584
  e = e.makeValid();
1528
1585
  const r = this.makeValid();
1529
1586
  if (this.equals(e)) return !0;
1530
1587
  if (e.end.equals(r.start) || r.end.equals(e.start)) return !1;
1531
- const i = o.max(r.start, e.start), a = o.min(r.end, e.end);
1532
- return a.before(i) ? !1 : new p(a.sub(i)).greaterThanOrEqual(t);
1588
+ const i = u.max(r.start, e.start), a = u.min(r.end, e.end);
1589
+ return a.before(i) ? !1 : new l(a.sub(i)).greaterThanOrEqual(t);
1533
1590
  }
1534
1591
  contains(e) {
1535
1592
  return e instanceof x ? this.contains(e.start) && this.contains(e.end) : this.start.beforeEq(e) && this.end.after(e);
@@ -1551,19 +1608,17 @@ let I = class N extends F {
1551
1608
  }
1552
1609
  static max(...e) {
1553
1610
  return new x(
1554
- o.min(...e.map((t) => t.start)),
1555
- o.max(...e.map((t) => t.end))
1611
+ u.min(...e.map((t) => t.start)),
1612
+ u.max(...e.map((t) => t.end))
1556
1613
  );
1557
1614
  }
1558
1615
  /** The maximum possible time range. */
1559
- static MAX = new x(o.MIN, o.MAX);
1560
- /** The minimum possible time range. */
1561
- static MIN = new x(o.MAX, o.MIN);
1616
+ static MAX = new x(u.MIN, u.MAX);
1562
1617
  /** A time range whose start and end are both zero. */
1563
- static ZERO = new x(o.ZERO, o.ZERO);
1618
+ static ZERO = new x(u.ZERO, u.ZERO);
1564
1619
  /** A zod schema for validating and transforming time ranges */
1565
1620
  static z = s.union([
1566
- s.object({ start: o.z, end: o.z }).transform((e) => new x(e.start, e.end)),
1621
+ s.object({ start: u.z, end: u.z }).transform((e) => new x(e.start, e.end)),
1567
1622
  s.instanceof(x)
1568
1623
  ]);
1569
1624
  /**
@@ -1578,7 +1633,7 @@ let I = class N extends F {
1578
1633
  * equal.
1579
1634
  */
1580
1635
  static sort(e, t) {
1581
- return o.sort(e.start, t.start) || o.sort(e.end, t.end);
1636
+ return u.sort(e.start, t.start) || u.sort(e.end, t.end);
1582
1637
  }
1583
1638
  /**
1584
1639
  * Simplify takes the list of `TimeRange`s, makes all of them valid, sorts them, and
@@ -1589,19 +1644,20 @@ let I = class N extends F {
1589
1644
  */
1590
1645
  static simplify(e) {
1591
1646
  return e.map((t) => t.makeValid()).sort((t, r) => x.sort(t, r)).reduce((t, r) => {
1592
- if (r.isZero) return t;
1647
+ if (r.span.isZero) return t;
1593
1648
  if (t.length === 0)
1594
1649
  return t.push(r), t;
1595
1650
  const i = t[t.length - 1];
1596
- return i.overlapsWith(r) || i.end.equals(r.start) ? i.end = o.max(i.end, r.end) : t.push(r), t;
1651
+ return i.overlapsWith(r) || i.end.equals(r.start) ? i.end = u.max(i.end, r.end) : t.push(r), t;
1597
1652
  }, []);
1598
1653
  }
1599
- }, w = class u extends F {
1654
+ }
1655
+ let O = class o extends Z {
1600
1656
  constructor(e) {
1601
- if (E(e) && (e = e.value), e instanceof u || typeof e == "string" || typeof e.valueOf() == "string")
1657
+ if (U(e) && (e = e.value), e instanceof o || typeof e == "string" || typeof e.valueOf() == "string")
1602
1658
  super(e.valueOf());
1603
1659
  else {
1604
- const t = u.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);
1660
+ const t = o.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);
1605
1661
  if (t == null)
1606
1662
  throw new Error(`unable to find data type for ${e.toString()}`);
1607
1663
  super(t.valueOf());
@@ -1611,7 +1667,7 @@ let I = class N extends F {
1611
1667
  * @returns the TypedArray constructor for the DataType.
1612
1668
  */
1613
1669
  get Array() {
1614
- const e = u.ARRAY_CONSTRUCTORS.get(this.toString());
1670
+ const e = o.ARRAY_CONSTRUCTORS.get(this.toString());
1615
1671
  if (e == null)
1616
1672
  throw new Error(`unable to find array constructor for ${this.valueOf()}`);
1617
1673
  return e;
@@ -1628,9 +1684,10 @@ let I = class N extends F {
1628
1684
  matches(...e) {
1629
1685
  return e.some((t) => this.equals(t));
1630
1686
  }
1631
- /** @returns a string representation of the DataType. */
1632
- toString() {
1633
- return this.valueOf();
1687
+ /** @returns a string representation of the DataType. If short is true, a 1-4
1688
+ * character representation (i64, str, etc.) is returned instead. */
1689
+ toString(e = !1) {
1690
+ return e ? o.SHORT_STRINGS.get(this.valueOf()) ?? this.valueOf() : this.valueOf();
1634
1691
  }
1635
1692
  /**
1636
1693
  * @returns true if the DataType has a variable density.
@@ -1638,7 +1695,7 @@ let I = class N extends F {
1638
1695
  * @example DataType.INT32.isVariable // false
1639
1696
  */
1640
1697
  get isVariable() {
1641
- return this.equals(u.JSON) || this.equals(u.STRING);
1698
+ return this.equals(o.JSON) || this.equals(o.STRING);
1642
1699
  }
1643
1700
  /**
1644
1701
  * @returns true if the DataType is numeric.
@@ -1646,7 +1703,7 @@ let I = class N extends F {
1646
1703
  * @example DataType.STRING.isNumeric // false
1647
1704
  */
1648
1705
  get isNumeric() {
1649
- return !this.isVariable && !this.equals(u.UUID);
1706
+ return !this.isVariable && !this.equals(o.UUID);
1650
1707
  }
1651
1708
  /**
1652
1709
  * @returns true if the DataType is an integer.
@@ -1671,7 +1728,7 @@ let I = class N extends F {
1671
1728
  * @example DataType.FLOAT32.density // Density.BIT32
1672
1729
  */
1673
1730
  get density() {
1674
- const e = u.DENSITIES.get(this.toString());
1731
+ const e = o.DENSITIES.get(this.toString());
1675
1732
  if (e == null) throw new Error(`unable to find density for ${this.valueOf()}`);
1676
1733
  return e;
1677
1734
  }
@@ -1681,7 +1738,7 @@ let I = class N extends F {
1681
1738
  * @example DataType.INT32.isUnsigned // false
1682
1739
  */
1683
1740
  get isUnsignedInteger() {
1684
- return this.equals(u.UINT8) || this.equals(u.UINT16) || this.equals(u.UINT32) || this.equals(u.UINT64);
1741
+ return this.equals(o.UINT8) || this.equals(o.UINT16) || this.equals(o.UINT32) || this.equals(o.UINT64);
1685
1742
  }
1686
1743
  /**
1687
1744
  * @returns true if the DataType is a signed integer.
@@ -1689,11 +1746,11 @@ let I = class N extends F {
1689
1746
  * @example DataType.UINT32.isSigned // false
1690
1747
  */
1691
1748
  get isSignedInteger() {
1692
- return this.equals(u.INT8) || this.equals(u.INT16) || this.equals(u.INT32) || this.equals(u.INT64);
1749
+ return this.equals(o.INT8) || this.equals(o.INT16) || this.equals(o.INT32) || this.equals(o.INT64);
1693
1750
  }
1694
1751
  /** @returns true if the data type can be cast to the other data type without loss of precision. */
1695
1752
  canSafelyCastTo(e) {
1696
- return this.equals(e) ? !0 : !this.isNumeric || !e.isNumeric || this.isVariable || e.isVariable || this.isUnsignedInteger && e.isSignedInteger ? !1 : this.isFloat ? e.isFloat && this.density.valueOf() <= e.density.valueOf() : this.equals(u.INT32) && e.equals(u.FLOAT64) || this.equals(u.INT8) && e.equals(u.FLOAT32) ? !0 : this.isInteger && e.isInteger ? this.density.valueOf() <= e.density.valueOf() && this.isUnsignedInteger === e.isUnsignedInteger : !1;
1753
+ return this.equals(e) ? !0 : !this.isNumeric || !e.isNumeric || this.isVariable || e.isVariable || this.isUnsignedInteger && e.isSignedInteger ? !1 : this.isFloat ? e.isFloat && this.density.valueOf() <= e.density.valueOf() : this.equals(o.INT32) && e.equals(o.FLOAT64) || this.equals(o.INT8) && e.equals(o.FLOAT32) ? !0 : this.isInteger && e.isInteger ? this.density.valueOf() <= e.density.valueOf() && this.isUnsignedInteger === e.isUnsignedInteger : !1;
1697
1754
  }
1698
1755
  /** @returns true if the data type can be cast to the other data type, even if there is a loss of precision. */
1699
1756
  canCastTo(e) {
@@ -1710,129 +1767,146 @@ let I = class N extends F {
1710
1767
  }
1711
1768
  /** @returns true if the data type uses bigints to store values. */
1712
1769
  get usesBigInt() {
1713
- return u.BIG_INT_TYPES.some((e) => e.equals(this));
1770
+ return o.BIG_INT_TYPES.some((e) => e.equals(this));
1714
1771
  }
1715
1772
  /** Represents an Unknown/Invalid DataType. */
1716
- static UNKNOWN = new u("unknown");
1773
+ static UNKNOWN = new o("unknown");
1717
1774
  /** Represents a 64-bit floating point value. */
1718
- static FLOAT64 = new u("float64");
1775
+ static FLOAT64 = new o("float64");
1719
1776
  /** Represents a 32-bit floating point value. */
1720
- static FLOAT32 = new u("float32");
1777
+ static FLOAT32 = new o("float32");
1721
1778
  /** Represents a 64-bit signed integer value. */
1722
- static INT64 = new u("int64");
1779
+ static INT64 = new o("int64");
1723
1780
  /** Represents a 32-bit signed integer value. */
1724
- static INT32 = new u("int32");
1781
+ static INT32 = new o("int32");
1725
1782
  /** Represents a 16-bit signed integer value. */
1726
- static INT16 = new u("int16");
1783
+ static INT16 = new o("int16");
1727
1784
  /** Represents a 8-bit signed integer value. */
1728
- static INT8 = new u("int8");
1785
+ static INT8 = new o("int8");
1729
1786
  /** Represents a 64-bit unsigned integer value. */
1730
- static UINT64 = new u("uint64");
1787
+ static UINT64 = new o("uint64");
1731
1788
  /** Represents a 32-bit unsigned integer value. */
1732
- static UINT32 = new u("uint32");
1789
+ static UINT32 = new o("uint32");
1733
1790
  /** Represents a 16-bit unsigned integer value. */
1734
- static UINT16 = new u("uint16");
1791
+ static UINT16 = new o("uint16");
1735
1792
  /** Represents a 8-bit unsigned integer value. */
1736
- static UINT8 = new u("uint8");
1737
- /** Represents a boolean value. Alias for UINT8. */
1738
- static BOOLEAN = this.UINT8;
1793
+ static UINT8 = new o("uint8");
1794
+ /** Represents a boolean value. Stored as a 8-bit unsigned integer. */
1795
+ static BOOLEAN = new o("boolean");
1739
1796
  /** Represents a 64-bit unix epoch. */
1740
- static TIMESTAMP = new u("timestamp");
1741
- /** Represents a UUID data type */
1742
- static UUID = new u("uuid");
1797
+ static TIMESTAMP = new o("timestamp");
1798
+ /** Represents a UUID data type. */
1799
+ static UUID = new o("uuid");
1743
1800
  /** Represents a string data type. Strings have an unknown density, and are separate
1744
1801
  * by a newline character. */
1745
- static STRING = new u("string");
1802
+ static STRING = new o("string");
1746
1803
  /** Represents a JSON data type. JSON has an unknown density, and is separated by a
1747
1804
  * newline character. */
1748
- static JSON = new u("json");
1805
+ static JSON = new o("json");
1749
1806
  static ARRAY_CONSTRUCTORS = /* @__PURE__ */ new Map([
1750
- [u.UINT8.toString(), Uint8Array],
1751
- [u.UINT16.toString(), Uint16Array],
1752
- [u.UINT32.toString(), Uint32Array],
1753
- [u.UINT64.toString(), BigUint64Array],
1754
- [u.FLOAT32.toString(), Float32Array],
1755
- [u.FLOAT64.toString(), Float64Array],
1756
- [u.INT8.toString(), Int8Array],
1757
- [u.INT16.toString(), Int16Array],
1758
- [u.INT32.toString(), Int32Array],
1759
- [u.INT64.toString(), BigInt64Array],
1760
- [u.TIMESTAMP.toString(), BigInt64Array],
1761
- [u.STRING.toString(), Uint8Array],
1762
- [u.JSON.toString(), Uint8Array],
1763
- [u.UUID.toString(), Uint8Array]
1807
+ [o.UINT8.toString(), Uint8Array],
1808
+ [o.UINT16.toString(), Uint16Array],
1809
+ [o.UINT32.toString(), Uint32Array],
1810
+ [o.UINT64.toString(), BigUint64Array],
1811
+ [o.FLOAT32.toString(), Float32Array],
1812
+ [o.FLOAT64.toString(), Float64Array],
1813
+ [o.INT8.toString(), Int8Array],
1814
+ [o.INT16.toString(), Int16Array],
1815
+ [o.INT32.toString(), Int32Array],
1816
+ [o.INT64.toString(), BigInt64Array],
1817
+ [o.TIMESTAMP.toString(), BigInt64Array],
1818
+ [o.STRING.toString(), Uint8Array],
1819
+ [o.JSON.toString(), Uint8Array],
1820
+ [o.UUID.toString(), Uint8Array]
1764
1821
  ]);
1765
1822
  static ARRAY_CONSTRUCTOR_DATA_TYPES = /* @__PURE__ */ new Map([
1766
- [Uint8Array.name, u.UINT8],
1767
- [Uint16Array.name, u.UINT16],
1768
- [Uint32Array.name, u.UINT32],
1769
- [BigUint64Array.name, u.UINT64],
1770
- [Float32Array.name, u.FLOAT32],
1771
- [Float64Array.name, u.FLOAT64],
1772
- [Int8Array.name, u.INT8],
1773
- [Int16Array.name, u.INT16],
1774
- [Int32Array.name, u.INT32],
1775
- [BigInt64Array.name, u.INT64]
1823
+ [Uint8Array.name, o.UINT8],
1824
+ [Uint16Array.name, o.UINT16],
1825
+ [Uint32Array.name, o.UINT32],
1826
+ [BigUint64Array.name, o.UINT64],
1827
+ [Float32Array.name, o.FLOAT32],
1828
+ [Float64Array.name, o.FLOAT64],
1829
+ [Int8Array.name, o.INT8],
1830
+ [Int16Array.name, o.INT16],
1831
+ [Int32Array.name, o.INT32],
1832
+ [BigInt64Array.name, o.INT64]
1776
1833
  ]);
1777
1834
  static DENSITIES = /* @__PURE__ */ new Map([
1778
- [u.UINT8.toString(), I.BIT8],
1779
- [u.UINT16.toString(), I.BIT16],
1780
- [u.UINT32.toString(), I.BIT32],
1781
- [u.UINT64.toString(), I.BIT64],
1782
- [u.FLOAT32.toString(), I.BIT32],
1783
- [u.FLOAT64.toString(), I.BIT64],
1784
- [u.INT8.toString(), I.BIT8],
1785
- [u.INT16.toString(), I.BIT16],
1786
- [u.INT32.toString(), I.BIT32],
1787
- [u.INT64.toString(), I.BIT64],
1788
- [u.TIMESTAMP.toString(), I.BIT64],
1789
- [u.STRING.toString(), I.UNKNOWN],
1790
- [u.JSON.toString(), I.UNKNOWN],
1791
- [u.UUID.toString(), I.BIT128]
1835
+ [o.UINT8.toString(), I.BIT8],
1836
+ [o.UINT16.toString(), I.BIT16],
1837
+ [o.UINT32.toString(), I.BIT32],
1838
+ [o.UINT64.toString(), I.BIT64],
1839
+ [o.FLOAT32.toString(), I.BIT32],
1840
+ [o.FLOAT64.toString(), I.BIT64],
1841
+ [o.INT8.toString(), I.BIT8],
1842
+ [o.INT16.toString(), I.BIT16],
1843
+ [o.INT32.toString(), I.BIT32],
1844
+ [o.INT64.toString(), I.BIT64],
1845
+ [o.TIMESTAMP.toString(), I.BIT64],
1846
+ [o.STRING.toString(), I.UNKNOWN],
1847
+ [o.JSON.toString(), I.UNKNOWN],
1848
+ [o.UUID.toString(), I.BIT128]
1792
1849
  ]);
1793
1850
  /** All the data types. */
1794
1851
  static ALL = [
1795
- u.UNKNOWN,
1796
- u.FLOAT64,
1797
- u.FLOAT32,
1798
- u.INT64,
1799
- u.INT32,
1800
- u.INT16,
1801
- u.INT8,
1802
- u.UINT64,
1803
- u.UINT32,
1804
- u.UINT16,
1805
- u.UINT8,
1806
- u.TIMESTAMP,
1807
- u.UUID,
1808
- u.STRING,
1809
- u.JSON
1852
+ o.UNKNOWN,
1853
+ o.FLOAT64,
1854
+ o.FLOAT32,
1855
+ o.INT64,
1856
+ o.INT32,
1857
+ o.INT16,
1858
+ o.INT8,
1859
+ o.UINT64,
1860
+ o.UINT32,
1861
+ o.UINT16,
1862
+ o.UINT8,
1863
+ o.TIMESTAMP,
1864
+ o.UUID,
1865
+ o.STRING,
1866
+ o.JSON
1810
1867
  ];
1811
- static BIG_INT_TYPES = [u.INT64, u.UINT64, u.TIMESTAMP];
1868
+ static SHORT_STRINGS = /* @__PURE__ */ new Map([
1869
+ [o.UINT8.toString(), "u8"],
1870
+ [o.UINT16.toString(), "u16"],
1871
+ [o.UINT32.toString(), "u32"],
1872
+ [o.UINT64.toString(), "u64"],
1873
+ [o.INT8.toString(), "i8"],
1874
+ [o.INT16.toString(), "i16"],
1875
+ [o.INT32.toString(), "i32"],
1876
+ [o.INT64.toString(), "i64"],
1877
+ [o.FLOAT32.toString(), "f32"],
1878
+ [o.FLOAT64.toString(), "f64"],
1879
+ [o.BOOLEAN.toString(), "bool"],
1880
+ [o.TIMESTAMP.toString(), "ts"],
1881
+ [o.UUID.toString(), "uuid"],
1882
+ [o.STRING.toString(), "str"],
1883
+ [o.JSON.toString(), "json"]
1884
+ ]);
1885
+ static BIG_INT_TYPES = [o.INT64, o.UINT64, o.TIMESTAMP];
1812
1886
  /** A zod schema for a DataType. */
1813
1887
  static z = s.union([
1814
- s.string().transform((e) => new u(e)),
1815
- s.instanceof(u)
1888
+ s.string().transform((e) => new o(e)),
1889
+ s.instanceof(o)
1816
1890
  ]);
1817
- }, ue = class d extends F {
1891
+ }, he = class p extends Z {
1818
1892
  constructor(e) {
1819
- E(e) && (e = e.value), super(e.valueOf());
1893
+ U(e) && (e = e.value), super(e.valueOf());
1820
1894
  }
1821
1895
  /** @returns true if the Size is larger than the other size. */
1822
1896
  largerThan(e) {
1823
- return E(e) && (e = e.value), this.valueOf() > e.valueOf();
1897
+ return U(e) && (e = e.value), this.valueOf() > e.valueOf();
1824
1898
  }
1825
1899
  /** @returns true if the Size is smaller than the other size. */
1826
1900
  smallerThan(e) {
1827
- return E(e) && (e = e.value), this.valueOf() < e.valueOf();
1901
+ return U(e) && (e = e.value), this.valueOf() < e.valueOf();
1828
1902
  }
1829
1903
  /** @returns a new Size representing the sum of the two Sizes. */
1830
1904
  add(e) {
1831
- return E(e) && (e = e.value), new d(te(this.valueOf(), e.valueOf()));
1905
+ return U(e) && (e = e.value), new p(re(this.valueOf(), e.valueOf()));
1832
1906
  }
1833
1907
  /** @returns a new Size representing the difference of the two Sizes. */
1834
1908
  sub(e) {
1835
- return E(e) && (e = e.value), new d(ee(this.valueOf(), e.valueOf()));
1909
+ return U(e) && (e = e.value), new p(ne(this.valueOf(), e.valueOf()));
1836
1910
  }
1837
1911
  /**
1838
1912
  * Multiplies this Size by a scalar value.
@@ -1841,7 +1915,7 @@ let I = class N extends F {
1841
1915
  * @returns A new Size representing this Size multiplied by the value.
1842
1916
  */
1843
1917
  mult(e) {
1844
- return new d(M(this.valueOf(), e));
1918
+ return new p(C(this.valueOf(), e));
1845
1919
  }
1846
1920
  /**
1847
1921
  * Divides this Size by a scalar value.
@@ -1850,39 +1924,39 @@ let I = class N extends F {
1850
1924
  * @returns A new Size representing this Size divided by the value.
1851
1925
  */
1852
1926
  div(e) {
1853
- return new d(ne(this.valueOf(), e));
1927
+ return new p(se(this.valueOf(), e));
1854
1928
  }
1855
1929
  /** @returns a new Size representing the truncated value of the Size. */
1856
1930
  truncate(e) {
1857
- return new d(
1858
- Math.trunc(this.valueOf() / new d(e).valueOf()) * new d(e).valueOf()
1931
+ return new p(
1932
+ Math.trunc(this.valueOf() / new p(e).valueOf()) * new p(e).valueOf()
1859
1933
  );
1860
1934
  }
1861
1935
  /** @returns a new Size representing the remainder of the Size. */
1862
1936
  remainder(e) {
1863
- return d.bytes(this.valueOf() % new d(e).valueOf());
1937
+ return p.bytes(this.valueOf() % new p(e).valueOf());
1864
1938
  }
1865
1939
  /** @returns the number of gigabytes in the Size. */
1866
1940
  get gigabytes() {
1867
- return this.valueOf() / d.GIGABYTE.valueOf();
1941
+ return this.valueOf() / p.GIGABYTE.valueOf();
1868
1942
  }
1869
1943
  /** @returns the number of megabytes in the Size. */
1870
1944
  get megabytes() {
1871
- return this.valueOf() / d.MEGABYTE.valueOf();
1945
+ return this.valueOf() / p.MEGABYTE.valueOf();
1872
1946
  }
1873
1947
  /** @returns the number of kilobytes in the Size. */
1874
1948
  get kilobytes() {
1875
- return this.valueOf() / d.KILOBYTE.valueOf();
1949
+ return this.valueOf() / p.KILOBYTE.valueOf();
1876
1950
  }
1877
1951
  /** @returns the number of terabytes in the Size. */
1878
1952
  get terabytes() {
1879
- return this.valueOf() / d.TERABYTE.valueOf();
1953
+ return this.valueOf() / p.TERABYTE.valueOf();
1880
1954
  }
1881
1955
  /** @returns a nicely formatted string representation of the Size. */
1882
1956
  toString() {
1883
- const e = this.truncate(d.TERABYTE), t = this.truncate(d.GIGABYTE), r = this.truncate(d.MEGABYTE), i = this.truncate(d.KILOBYTE), a = this.truncate(d.BYTE), c = e, g = t.sub(e), y = r.sub(t), f = i.sub(r), m = a.sub(i);
1884
- let b = "";
1885
- return c.isZero || (b += `${c.terabytes}TB `), g.isZero || (b += `${g.gigabytes}GB `), y.isZero || (b += `${y.megabytes}MB `), f.isZero || (b += `${f.kilobytes}KB `), (!m.isZero || b === "") && (b += `${m.valueOf()}B`), b.trim();
1957
+ const e = this.truncate(p.TERABYTE), t = this.truncate(p.GIGABYTE), r = this.truncate(p.MEGABYTE), i = this.truncate(p.KILOBYTE), a = this.truncate(p.BYTE), c = e, d = t.sub(e), y = r.sub(t), f = i.sub(r), g = a.sub(i);
1958
+ let w = "";
1959
+ return c.isZero || (w += `${c.terabytes}TB `), d.isZero || (w += `${d.gigabytes}GB `), y.isZero || (w += `${y.megabytes}MB `), f.isZero || (w += `${f.kilobytes}KB `), (!g.isZero || w === "") && (w += `${g.valueOf()}B`), w.trim();
1886
1960
  }
1887
1961
  /**
1888
1962
  * Creates a Size from the given number of bytes.
@@ -1891,10 +1965,10 @@ let I = class N extends F {
1891
1965
  * @returns A Size representing the given number of bytes.
1892
1966
  */
1893
1967
  static bytes(e = 1) {
1894
- return new d(e);
1968
+ return new p(e);
1895
1969
  }
1896
1970
  /** A single byte */
1897
- static BYTE = new d(1);
1971
+ static BYTE = new p(1);
1898
1972
  /**
1899
1973
  * Creates a Size from the given number if kilobytes.
1900
1974
  *
@@ -1902,10 +1976,10 @@ let I = class N extends F {
1902
1976
  * @returns A Size representing the given number of kilobytes.
1903
1977
  */
1904
1978
  static kilobytes(e = 1) {
1905
- return d.bytes(new d(e).valueOf() * 1e3);
1979
+ return p.bytes(new p(e).valueOf() * 1e3);
1906
1980
  }
1907
1981
  /** A kilobyte */
1908
- static KILOBYTE = d.kilobytes(1);
1982
+ static KILOBYTE = p.kilobytes(1);
1909
1983
  /**
1910
1984
  * Creates a Size from the given number of megabytes.
1911
1985
  *
@@ -1913,10 +1987,10 @@ let I = class N extends F {
1913
1987
  * @returns A Size representing the given number of megabytes.
1914
1988
  */
1915
1989
  static megabytes(e = 1) {
1916
- return d.kilobytes(new d(e).valueOf() * 1e3);
1990
+ return p.kilobytes(new p(e).valueOf() * 1e3);
1917
1991
  }
1918
1992
  /** A megabyte */
1919
- static MEGABYTE = d.megabytes(1);
1993
+ static MEGABYTE = p.megabytes(1);
1920
1994
  /**
1921
1995
  * Creates a Size from the given number of gigabytes.
1922
1996
  *
@@ -1924,10 +1998,10 @@ let I = class N extends F {
1924
1998
  * @returns A Size representing the given number of gigabytes.
1925
1999
  */
1926
2000
  static gigabytes(e = 1) {
1927
- return d.megabytes(new d(e).valueOf() * 1e3);
2001
+ return p.megabytes(new p(e).valueOf() * 1e3);
1928
2002
  }
1929
2003
  /** A gigabyte */
1930
- static GIGABYTE = d.gigabytes(1);
2004
+ static GIGABYTE = p.gigabytes(1);
1931
2005
  /**
1932
2006
  * Creates a Size from the given number of terabytes.
1933
2007
  *
@@ -1935,22 +2009,26 @@ let I = class N extends F {
1935
2009
  * @returns A Size representing the given number of terabytes.
1936
2010
  */
1937
2011
  static terabytes(e) {
1938
- return d.gigabytes(new d(e).valueOf() * 1e3);
2012
+ return p.gigabytes(new p(e).valueOf() * 1e3);
1939
2013
  }
1940
2014
  /** A terabyte. */
1941
- static TERABYTE = d.terabytes(1);
2015
+ static TERABYTE = p.terabytes(1);
1942
2016
  /** The zero value for Size */
1943
- static ZERO = new d(0);
2017
+ static ZERO = new p(0);
1944
2018
  /** A zod schema for a Size. */
1945
2019
  static z = s.union([
1946
- s.number().transform((e) => new d(e)),
1947
- s.instanceof(d)
2020
+ s.number().transform((e) => new p(e)),
2021
+ s.instanceof(p)
1948
2022
  ]);
1949
2023
  /** @returns true if the Size is zero. */
1950
2024
  get isZero() {
1951
2025
  return this.valueOf() === 0;
1952
2026
  }
1953
2027
  };
2028
+ s.object({
2029
+ start: s.number(),
2030
+ end: s.number()
2031
+ });
1954
2032
  s.union([
1955
2033
  s.instanceof(Uint8Array),
1956
2034
  s.instanceof(Uint16Array),
@@ -1963,37 +2041,37 @@ s.union([
1963
2041
  s.instanceof(Int32Array),
1964
2042
  s.instanceof(BigInt64Array)
1965
2043
  ]);
1966
- const Pe = (n) => {
2044
+ const Fe = (n) => {
1967
2045
  const e = typeof n;
1968
- return e === "string" || e === "number" || e === "boolean" || e === "bigint" || n instanceof o || n instanceof p || n instanceof Date;
1969
- }, Ft = (n, e, t, r = 0) => n.usesBigInt && !e.usesBigInt ? Number(t) - Number(r) : !n.usesBigInt && e.usesBigInt ? BigInt(t.valueOf()) - BigInt(r.valueOf()) : X(t, -r), X = (n, e) => e == 0 ? n : n == 0 ? e : typeof n == "bigint" && typeof e == "bigint" || typeof n == "number" && typeof e == "number" ? n + e : Number(n) + Number(e), Wt = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
1970
- function Zt(n) {
1971
- return typeof n == "string" && Wt.test(n);
2046
+ return e === "string" || e === "number" || e === "boolean" || e === "bigint" || n instanceof u || n instanceof l || n instanceof Date;
2047
+ }, zt = (n, e, t, r = 0) => n.usesBigInt && !e.usesBigInt ? Number(t) - Number(r) : !n.usesBigInt && e.usesBigInt ? BigInt(t.valueOf()) - BigInt(r.valueOf()) : Q(t, -r), Q = (n, e) => e == 0 ? n : n == 0 ? e : typeof n == "bigint" && typeof e == "bigint" || typeof n == "number" && typeof e == "number" ? n + e : Number(n) + Number(e), Vt = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
2048
+ function Ht(n) {
2049
+ return typeof n == "string" && Vt.test(n);
1972
2050
  }
1973
- const v = [];
2051
+ const S = [];
1974
2052
  for (let n = 0; n < 256; ++n)
1975
- v.push((n + 256).toString(16).slice(1));
1976
- function Vt(n, e = 0) {
1977
- return (v[n[e + 0]] + v[n[e + 1]] + v[n[e + 2]] + v[n[e + 3]] + "-" + v[n[e + 4]] + v[n[e + 5]] + "-" + v[n[e + 6]] + v[n[e + 7]] + "-" + v[n[e + 8]] + v[n[e + 9]] + "-" + v[n[e + 10]] + v[n[e + 11]] + v[n[e + 12]] + v[n[e + 13]] + v[n[e + 14]] + v[n[e + 15]]).toLowerCase();
2053
+ S.push((n + 256).toString(16).slice(1));
2054
+ function Jt(n, e = 0) {
2055
+ return (S[n[e + 0]] + S[n[e + 1]] + S[n[e + 2]] + S[n[e + 3]] + "-" + S[n[e + 4]] + S[n[e + 5]] + "-" + S[n[e + 6]] + S[n[e + 7]] + "-" + S[n[e + 8]] + S[n[e + 9]] + "-" + S[n[e + 10]] + S[n[e + 11]] + S[n[e + 12]] + S[n[e + 13]] + S[n[e + 14]] + S[n[e + 15]]).toLowerCase();
1978
2056
  }
1979
- function zt(n, e = 0) {
1980
- const t = Vt(n, e);
1981
- if (!Zt(t))
2057
+ function Kt(n, e = 0) {
2058
+ const t = Jt(n, e);
2059
+ if (!Ht(t))
1982
2060
  throw TypeError("Stringified UUID is invalid");
1983
2061
  return t;
1984
2062
  }
1985
2063
  typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
1986
- const je = (n, e) => zt(n, e), $ = -1, Gt = s.string().transform(
2064
+ const We = (n, e) => Kt(n, e), R = -1, Xt = s.string().transform(
1987
2065
  (n) => new Uint8Array(
1988
2066
  atob(n).split("").map((e) => e.charCodeAt(0))
1989
2067
  ).buffer
1990
- ), Ht = s.union([s.null(), s.undefined()]).transform(() => new Uint8Array().buffer), le = 10, Jt = (n, e) => {
2068
+ ), Qt = s.union([s.null(), s.undefined()]).transform(() => new Uint8Array().buffer), fe = 10, _t = (n, e) => {
1991
2069
  if (n === "number" && !e.isNumeric)
1992
2070
  throw new Error(`cannot convert series of type ${e.toString()} to number`);
1993
2071
  if (n === "bigint" && !e.usesBigInt)
1994
2072
  throw new Error(`cannot convert series of type ${e.toString()} to bigint`);
1995
- }, Ye = "sy_x_telem_series";
1996
- let qe = class B {
2073
+ }, Ze = "sy_x_telem_series";
2074
+ class B {
1997
2075
  /**
1998
2076
  * A unique identifier for the series. If specified by the user, it is their
1999
2077
  * responsibility to ensure that it is unique. If not specified, a new ID will be
@@ -2004,7 +2082,7 @@ let qe = class B {
2004
2082
  * A discriminator used for identifying instances of the series class even
2005
2083
  * when bundlers mangle the class name.
2006
2084
  */
2007
- discriminator = Ye;
2085
+ discriminator = Ze;
2008
2086
  /** The data type of the series. */
2009
2087
  dataType;
2010
2088
  /**
@@ -2020,7 +2098,7 @@ let qe = class B {
2020
2098
  /** The underlying data. */
2021
2099
  _data;
2022
2100
  /** The time range occupied by the series' data. */
2023
- timeRange = W.ZERO;
2101
+ timeRange = x.ZERO;
2024
2102
  /**
2025
2103
  * Alignment defines the location of the series relative to other series in a logical
2026
2104
  * group. Useful for defining the position of the series within a channel's data.
@@ -2037,7 +2115,7 @@ let qe = class B {
2037
2115
  /** A cached maximum value. */
2038
2116
  cachedMax;
2039
2117
  /** The write position of the buffer. */
2040
- writePos = $;
2118
+ writePos = R;
2041
2119
  /** Tracks the number of entities currently using this array. */
2042
2120
  _refCount = 0;
2043
2121
  /** Caches the length of the array for variable length data types. */
@@ -2049,16 +2127,16 @@ let qe = class B {
2049
2127
  * can be constructed into a series.
2050
2128
  */
2051
2129
  static crudeZ = s.object({
2052
- timeRange: W.z.optional(),
2053
- dataType: w.z,
2130
+ timeRange: x.z.optional(),
2131
+ dataType: O.z,
2054
2132
  alignment: s.coerce.bigint().optional(),
2055
2133
  data: s.union([
2056
- Gt,
2057
- Ht,
2134
+ Xt,
2135
+ Qt,
2058
2136
  s.instanceof(ArrayBuffer),
2059
2137
  s.instanceof(Uint8Array)
2060
2138
  ]),
2061
- glBufferUsage: Yt.optional().default("static").optional()
2139
+ glBufferUsage: Wt.optional().default("static").optional()
2062
2140
  });
2063
2141
  /**
2064
2142
  * A zod schema that validates and constructs a series from it's crude
@@ -2139,61 +2217,61 @@ let qe = class B {
2139
2217
  * @throws Error if data type cannot be inferred from input
2140
2218
  */
2141
2219
  constructor(e) {
2142
- Xt(e) && (e = { data: e }), e.data ??= [];
2220
+ en(e) && (e = { data: e }), e.data ??= [];
2143
2221
  const {
2144
2222
  dataType: t,
2145
2223
  timeRange: r,
2146
2224
  sampleOffset: i = 0,
2147
2225
  glBufferUsage: a = "static",
2148
2226
  alignment: c = 0n,
2149
- alignmentMultiple: g = 1n,
2150
- key: y = Pt(),
2227
+ alignmentMultiple: d = 1n,
2228
+ key: y = qt(),
2151
2229
  data: f
2152
2230
  } = e;
2153
- if (Kt(f)) {
2231
+ if (tn(f)) {
2154
2232
  const h = f;
2155
2233
  this.key = h.key, this.dataType = h.dataType, this.sampleOffset = h.sampleOffset, this.gl = h.gl, this._data = h._data, this.timeRange = h.timeRange, this.alignment = h.alignment, this.alignmentMultiple = h.alignmentMultiple, this.cachedMin = h.cachedMin, this.cachedMax = h.cachedMax, this.writePos = h.writePos, this._refCount = h._refCount, this.cachedLength = h.cachedLength;
2156
2234
  return;
2157
2235
  }
2158
- const m = Pe(f), b = Array.isArray(f);
2159
- if (t != null) this.dataType = new w(t);
2236
+ const g = Fe(f), w = Array.isArray(f);
2237
+ if (t != null) this.dataType = new O(t);
2160
2238
  else {
2161
2239
  if (f instanceof ArrayBuffer)
2162
2240
  throw new Error(
2163
2241
  "cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type."
2164
2242
  );
2165
- if (b || m) {
2243
+ if (w || g) {
2166
2244
  let h = f;
2167
- if (!m) {
2245
+ if (!g) {
2168
2246
  if (f.length === 0)
2169
2247
  throw new Error(
2170
2248
  "cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type."
2171
2249
  );
2172
2250
  h = f[0];
2173
2251
  }
2174
- if (typeof h == "string") this.dataType = w.STRING;
2175
- else if (typeof h == "number") this.dataType = w.FLOAT64;
2176
- else if (typeof h == "bigint") this.dataType = w.INT64;
2177
- else if (typeof h == "boolean") this.dataType = w.BOOLEAN;
2178
- else if (h instanceof o || h instanceof Date || h instanceof o)
2179
- this.dataType = w.TIMESTAMP;
2180
- else if (typeof h == "object") this.dataType = w.JSON;
2252
+ if (typeof h == "string") this.dataType = O.STRING;
2253
+ else if (typeof h == "number") this.dataType = O.FLOAT64;
2254
+ else if (typeof h == "bigint") this.dataType = O.INT64;
2255
+ else if (typeof h == "boolean") this.dataType = O.BOOLEAN;
2256
+ else if (h instanceof u || h instanceof Date || h instanceof u)
2257
+ this.dataType = O.TIMESTAMP;
2258
+ else if (typeof h == "object") this.dataType = O.JSON;
2181
2259
  else
2182
2260
  throw new Error(
2183
2261
  `cannot infer data type of ${typeof h} when constructing a Series from a JS array`
2184
2262
  );
2185
- } else this.dataType = new w(f);
2263
+ } else this.dataType = new O(f);
2186
2264
  }
2187
- if (!b && !m) this._data = f;
2188
- else if (b && f.length === 0)
2265
+ if (!w && !g) this._data = f;
2266
+ else if (w && f.length === 0)
2189
2267
  this._data = new this.dataType.Array([]).buffer;
2190
2268
  else {
2191
- let h = m ? [f] : f;
2269
+ let h = g ? [f] : f;
2192
2270
  const T = h[0];
2193
- (T instanceof o || T instanceof Date || T instanceof p) && (h = h.map((A) => new o(A).valueOf())), this.dataType.equals(w.STRING) ? (this.cachedLength = h.length, this._data = new TextEncoder().encode(`${h.join(`
2271
+ (T instanceof u || T instanceof Date || T instanceof l) && (h = h.map((A) => new u(A).valueOf())), this.dataType.equals(O.STRING) ? (this.cachedLength = h.length, this._data = new TextEncoder().encode(`${h.join(`
2194
2272
  `)}
2195
- `).buffer) : this.dataType.equals(w.JSON) ? (this.cachedLength = h.length, this._data = new TextEncoder().encode(
2196
- `${h.map((A) => oe.encodeString(A)).join(`
2273
+ `).buffer) : this.dataType.equals(O.JSON) ? (this.cachedLength = h.length, this._data = new TextEncoder().encode(
2274
+ `${h.map((A) => le.encodeString(A)).join(`
2197
2275
  `)}
2198
2276
  `
2199
2277
  ).buffer) : this.dataType.usesBigInt && typeof T == "number" ? this._data = new this.dataType.Array(
@@ -2202,7 +2280,7 @@ let qe = class B {
2202
2280
  h.map(Number)
2203
2281
  ).buffer : this._data = new this.dataType.Array(h).buffer;
2204
2282
  }
2205
- this.key = y, this.alignment = c, this.alignmentMultiple = g, this.sampleOffset = i ?? 0, this.timeRange = r ?? W.ZERO, this.gl = {
2283
+ this.key = y, this.alignment = c, this.alignmentMultiple = d, this.sampleOffset = i ?? 0, this.timeRange = r ?? x.ZERO, this.gl = {
2206
2284
  control: null,
2207
2285
  buffer: null,
2208
2286
  prevBuffer: 0,
@@ -2219,7 +2297,7 @@ let qe = class B {
2219
2297
  static alloc({ capacity: e, dataType: t, ...r }) {
2220
2298
  if (e === 0)
2221
2299
  throw new Error("[Series] - cannot allocate an array of length 0");
2222
- const i = new new w(t).Array(e), a = new B({ data: i.buffer, dataType: t, ...r });
2300
+ const i = new new O(t).Array(e), a = new B({ data: i.buffer, dataType: t, ...r });
2223
2301
  return a.writePos = 0, a;
2224
2302
  }
2225
2303
  /**
@@ -2262,12 +2340,12 @@ let qe = class B {
2262
2340
  return this.dataType.isVariable ? this.writeVariable(e) : this.writeFixed(e);
2263
2341
  }
2264
2342
  writeVariable(e) {
2265
- if (this.writePos === $) return 0;
2343
+ if (this.writePos === R) return 0;
2266
2344
  const t = this.byteCapacity.valueOf() - this.writePos, r = e.subBytes(0, t);
2267
2345
  return this.writeToUnderlyingData(r), this.writePos += r.byteLength.valueOf(), this.cachedLength != null && (this.cachedLength += r.length, this.calculateCachedLength()), r.length;
2268
2346
  }
2269
2347
  writeFixed(e) {
2270
- if (this.writePos === $) return 0;
2348
+ if (this.writePos === R) return 0;
2271
2349
  const t = this.capacity - this.writePos, r = e.sub(0, t);
2272
2350
  return this.writeToUnderlyingData(r), this.cachedLength = void 0, this.maybeRecomputeMinMax(r), this.writePos += r.length, r.length;
2273
2351
  }
@@ -2290,7 +2368,7 @@ let qe = class B {
2290
2368
  * @returns A typed array containing the series data.
2291
2369
  */
2292
2370
  get data() {
2293
- return this.writePos === $ ? this.underlyingData : new this.dataType.Array(this._data, 0, this.writePos);
2371
+ return this.writePos === R ? this.underlyingData : new this.dataType.Array(this._data, 0, this.writePos);
2294
2372
  }
2295
2373
  /**
2296
2374
  * Returns an array of the values in the series as strings.
@@ -2309,16 +2387,16 @@ let qe = class B {
2309
2387
  * @returns An array of values parsed from the JSON series.
2310
2388
  */
2311
2389
  parseJSON(e) {
2312
- if (!this.dataType.equals(w.JSON))
2390
+ if (!this.dataType.equals(O.JSON))
2313
2391
  throw new Error("cannot parse non-JSON series as JSON");
2314
- return this.toStrings().map((t) => e.parse(oe.decodeString(t)));
2392
+ return this.toStrings().map((t) => e.parse(le.decodeString(t)));
2315
2393
  }
2316
2394
  /**
2317
2395
  * Returns the capacity of the series in bytes.
2318
2396
  * @returns The size of the underlying buffer in bytes.
2319
2397
  */
2320
2398
  get byteCapacity() {
2321
- return new ue(this.underlyingData.byteLength);
2399
+ return new he(this.underlyingData.byteLength);
2322
2400
  }
2323
2401
  /**
2324
2402
  * Returns the capacity of the series in samples.
@@ -2334,7 +2412,7 @@ let qe = class B {
2334
2412
  * @returns The size of the data in bytes.
2335
2413
  */
2336
2414
  get byteLength() {
2337
- return this.writePos === $ ? this.byteCapacity : this.dataType.isVariable ? new ue(this.writePos) : this.dataType.density.size(this.writePos);
2415
+ return this.writePos === R ? this.byteCapacity : this.dataType.isVariable ? new he(this.writePos) : this.dataType.density.size(this.writePos);
2338
2416
  }
2339
2417
  /**
2340
2418
  * Returns the number of samples in this array.
@@ -2342,7 +2420,7 @@ let qe = class B {
2342
2420
  * @returns The number of samples in the series.
2343
2421
  */
2344
2422
  get length() {
2345
- return this.cachedLength != null ? this.cachedLength : this.dataType.isVariable ? this.calculateCachedLength() : this.writePos === $ ? this.byteCapacity.valueOf() / this.dataType.density.valueOf() : this.writePos;
2423
+ return this.cachedLength != null ? this.cachedLength : this.dataType.isVariable ? this.calculateCachedLength() : this.writePos === R ? this.byteCapacity.valueOf() / this.dataType.density.valueOf() : this.writePos;
2346
2424
  }
2347
2425
  calculateCachedLength() {
2348
2426
  if (!this.dataType.isVariable)
@@ -2350,7 +2428,7 @@ let qe = class B {
2350
2428
  let e = 0;
2351
2429
  const t = [0];
2352
2430
  return this.data.forEach((r, i) => {
2353
- r === le && (e++, t.push(i + 1));
2431
+ r === fe && (e++, t.push(i + 1));
2354
2432
  }), this._cachedIndexes = t, this.cachedLength = e, e;
2355
2433
  }
2356
2434
  /**
@@ -2366,7 +2444,7 @@ let qe = class B {
2366
2444
  if (this.dataType.equals(e)) return this;
2367
2445
  const r = new e.Array(this.length);
2368
2446
  for (let i = 0; i < this.length; i++)
2369
- r[i] = Ft(this.dataType, e, this.data[i], t);
2447
+ r[i] = zt(this.dataType, e, this.data[i], t);
2370
2448
  return new B({
2371
2449
  data: r.buffer,
2372
2450
  dataType: e,
@@ -2378,7 +2456,7 @@ let qe = class B {
2378
2456
  }
2379
2457
  calcRawMax() {
2380
2458
  if (this.length === 0) return -1 / 0;
2381
- if (this.dataType.equals(w.TIMESTAMP))
2459
+ if (this.dataType.equals(O.TIMESTAMP))
2382
2460
  this.cachedMax = this.data[this.data.length - 1];
2383
2461
  else if (this.dataType.usesBigInt) {
2384
2462
  const e = this.data;
@@ -2396,11 +2474,11 @@ let qe = class B {
2396
2474
  calcMax() {
2397
2475
  if (this.dataType.isVariable)
2398
2476
  throw new Error("cannot calculate maximum on a variable length data type");
2399
- return this.writePos === 0 ? -1 / 0 : (this.cachedMax ??= this.calcRawMax(), X(this.cachedMax, this.sampleOffset));
2477
+ return this.writePos === 0 ? -1 / 0 : (this.cachedMax ??= this.calcRawMax(), Q(this.cachedMax, this.sampleOffset));
2400
2478
  }
2401
2479
  calcRawMin() {
2402
2480
  if (this.length === 0) return 1 / 0;
2403
- if (this.dataType.equals(w.TIMESTAMP)) this.cachedMin = this.data[0];
2481
+ if (this.dataType.equals(O.TIMESTAMP)) this.cachedMin = this.data[0];
2404
2482
  else if (this.dataType.usesBigInt) {
2405
2483
  const e = this.data;
2406
2484
  this.cachedMin = e.reduce((t, r) => t < r ? t : r);
@@ -2417,11 +2495,11 @@ let qe = class B {
2417
2495
  calcMin() {
2418
2496
  if (this.dataType.isVariable)
2419
2497
  throw new Error("cannot calculate minimum on a variable length data type");
2420
- return this.writePos === 0 ? 1 / 0 : (this.cachedMin ??= this.calcRawMin(), X(this.cachedMin, this.sampleOffset));
2498
+ return this.writePos === 0 ? 1 / 0 : (this.cachedMin ??= this.calcRawMin(), Q(this.cachedMin, this.sampleOffset));
2421
2499
  }
2422
2500
  /** @returns the bounds of the series. */
2423
2501
  get bounds() {
2424
- return D(Number(this.min), Number(this.max), { makeValid: !1 });
2502
+ return P(Number(this.min), Number(this.max), { makeValid: !1 });
2425
2503
  }
2426
2504
  maybeRecomputeMinMax(e) {
2427
2505
  if (this.cachedMin != null) {
@@ -2443,18 +2521,18 @@ let qe = class B {
2443
2521
  }
2444
2522
  at(e, t = !1) {
2445
2523
  if (this.dataType.isVariable) return this.atVariable(e, t ?? !1);
2446
- if (this.dataType.equals(w.UUID)) return this.atUUID(e, t);
2524
+ if (this.dataType.equals(O.UUID)) return this.atUUID(e, t);
2447
2525
  e < 0 && (e = this.length + e);
2448
2526
  const r = this.data[e];
2449
2527
  if (r == null) {
2450
2528
  if (t === !0) throw new Error(`[series] - no value at index ${e}`);
2451
2529
  return;
2452
2530
  }
2453
- return X(r, this.sampleOffset);
2531
+ return Q(r, this.sampleOffset);
2454
2532
  }
2455
2533
  atUUID(e, t) {
2456
2534
  e < 0 && (e = this.length + e);
2457
- const r = je(
2535
+ const r = We(
2458
2536
  new Uint8Array(this.buffer, e * this.dataType.density.valueOf())
2459
2537
  );
2460
2538
  if (r == null) {
@@ -2470,7 +2548,7 @@ let qe = class B {
2470
2548
  else {
2471
2549
  e < 0 && (e = this.length + e);
2472
2550
  for (let c = 0; c < this.data.length; c++)
2473
- if (this.data[c] === le) {
2551
+ if (this.data[c] === fe) {
2474
2552
  if (e === 0) {
2475
2553
  i = c;
2476
2554
  break;
@@ -2483,7 +2561,7 @@ let qe = class B {
2483
2561
  }
2484
2562
  }
2485
2563
  const a = this.data.slice(r, i);
2486
- return this.dataType.equals(w.STRING) ? new TextDecoder().decode(a) : xe(JSON.parse(new TextDecoder().decode(a)));
2564
+ return this.dataType.equals(O.STRING) ? new TextDecoder().decode(a) : $e(JSON.parse(new TextDecoder().decode(a)));
2487
2565
  }
2488
2566
  /**
2489
2567
  * @returns the index of the first sample that is greater than or equal to the given value.
@@ -2492,7 +2570,7 @@ let qe = class B {
2492
2570
  */
2493
2571
  binarySearch(e) {
2494
2572
  let t = 0, r = this.length - 1;
2495
- const i = it(e);
2573
+ const i = ut(e);
2496
2574
  for (; t <= r; ) {
2497
2575
  const a = Math.floor((t + r) / 2), c = i(this.at(a, !0), e);
2498
2576
  if (c === 0) return a;
@@ -2508,11 +2586,11 @@ let qe = class B {
2508
2586
  * be the same buffer previously passed to {@method acquire} or {@method updateGLBuffer}.
2509
2587
  */
2510
2588
  updateGLBuffer(e) {
2511
- if (this.gl.control = e, !this.dataType.equals(w.FLOAT32) && !this.dataType.equals(w.UINT8))
2589
+ if (this.gl.control = e, !this.dataType.equals(O.FLOAT32) && !this.dataType.equals(O.UINT8))
2512
2590
  throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");
2513
2591
  const { buffer: t, bufferUsage: r, prevBuffer: i } = this.gl;
2514
2592
  if (t == null && (this.gl.buffer = e.createBuffer()), this.writePos !== i)
2515
- if (e.bindBuffer(e.ARRAY_BUFFER, this.gl.buffer), this.writePos !== $) {
2593
+ if (e.bindBuffer(e.ARRAY_BUFFER, this.gl.buffer), this.writePos !== R) {
2516
2594
  i === 0 && e.bufferData(e.ARRAY_BUFFER, this.byteCapacity.valueOf(), e.STATIC_DRAW);
2517
2595
  const a = this.dataType.density.size(i).valueOf(), c = this.underlyingData.slice(this.gl.prevBuffer, this.writePos);
2518
2596
  e.bufferSubData(e.ARRAY_BUFFER, a, c.buffer), this.gl.prevBuffer = this.writePos;
@@ -2521,10 +2599,10 @@ let qe = class B {
2521
2599
  e.ARRAY_BUFFER,
2522
2600
  this.buffer,
2523
2601
  r === "static" ? e.STATIC_DRAW : e.DYNAMIC_DRAW
2524
- ), this.gl.prevBuffer = $;
2602
+ ), this.gl.prevBuffer = R;
2525
2603
  }
2526
2604
  as(e) {
2527
- return Jt(e, this.dataType), this;
2605
+ return _t(e, this.dataType), this;
2528
2606
  }
2529
2607
  /** @returns a digest containing information about the series. */
2530
2608
  get digest() {
@@ -2533,8 +2611,8 @@ let qe = class B {
2533
2611
  dataType: this.dataType.toString(),
2534
2612
  sampleOffset: this.sampleOffset,
2535
2613
  alignment: {
2536
- lower: Se(this.alignmentBounds.lower),
2537
- upper: Se(this.alignmentBounds.upper),
2614
+ lower: Ue(this.alignmentBounds.lower),
2615
+ upper: Ue(this.alignmentBounds.upper),
2538
2616
  multiple: this.alignmentMultiple
2539
2617
  },
2540
2618
  timeRange: this.timeRange.toString(),
@@ -2552,7 +2630,7 @@ let qe = class B {
2552
2630
  * is exclusive.
2553
2631
  */
2554
2632
  get alignmentBounds() {
2555
- return D(
2633
+ return P(
2556
2634
  this.alignment,
2557
2635
  this.alignment + BigInt(this.length) * this.alignmentMultiple
2558
2636
  );
@@ -2572,10 +2650,10 @@ let qe = class B {
2572
2650
  }
2573
2651
  [Symbol.iterator]() {
2574
2652
  if (this.dataType.isVariable) {
2575
- const e = new Qt(this);
2576
- return this.dataType.equals(w.JSON) ? new _t(e) : e;
2653
+ const e = new nn(this);
2654
+ return this.dataType.equals(O.JSON) ? new rn(e) : e;
2577
2655
  }
2578
- return this.dataType.equals(w.UUID) ? new en(this) : new tn(this);
2656
+ return this.dataType.equals(O.UUID) ? new sn(this) : new an(this);
2579
2657
  }
2580
2658
  /**
2581
2659
  * Returns a slice of the series from start to end.
@@ -2602,7 +2680,7 @@ let qe = class B {
2602
2680
  * @returns An iterator over the specified range.
2603
2681
  */
2604
2682
  subIterator(e, t) {
2605
- return new Ne(this, e, t ?? this.length);
2683
+ return new Ae(this, e, t ?? this.length);
2606
2684
  }
2607
2685
  /**
2608
2686
  * Returns an iterator over a portion of the series based on alignment.
@@ -2616,7 +2694,7 @@ let qe = class B {
2616
2694
  ), i = Math.ceil(
2617
2695
  Number(t - this.alignment) / Number(this.alignmentMultiple)
2618
2696
  );
2619
- return new Ne(this, r, i);
2697
+ return new Ae(this, r, i);
2620
2698
  }
2621
2699
  subBytes(e, t) {
2622
2700
  if (e >= 0 && (t == null || t >= this.byteLength.valueOf())) return this;
@@ -2651,7 +2729,7 @@ let qe = class B {
2651
2729
  return new B({
2652
2730
  data: this.buffer,
2653
2731
  dataType: this.dataType,
2654
- timeRange: W.ZERO,
2732
+ timeRange: x.ZERO,
2655
2733
  sampleOffset: this.sampleOffset,
2656
2734
  glBufferUsage: "static",
2657
2735
  alignment: e
@@ -2674,22 +2752,22 @@ let qe = class B {
2674
2752
  }
2675
2753
  return e += "])", e;
2676
2754
  }
2677
- };
2678
- const Xt = (n) => n == null ? !1 : Array.isArray(n) || n instanceof ArrayBuffer || ArrayBuffer.isView(n) && !(n instanceof DataView) || n instanceof qe ? !0 : Pe(n), Kt = jt(Ye, qe);
2679
- let Ne = class {
2755
+ }
2756
+ const en = (n) => n == null ? !1 : Array.isArray(n) || n instanceof ArrayBuffer || ArrayBuffer.isView(n) && !(n instanceof DataView) || n instanceof B ? !0 : Fe(n), tn = Ft(Ze, B);
2757
+ class Ae {
2680
2758
  series;
2681
2759
  end;
2682
2760
  index;
2683
2761
  constructor(e, t, r) {
2684
2762
  this.series = e;
2685
- const i = D(0, e.length + 1);
2686
- this.end = Oe(i, r), this.index = Oe(i, t);
2763
+ const i = P(0, e.length + 1);
2764
+ this.end = Se(i, r), this.index = Se(i, t);
2687
2765
  }
2688
2766
  next() {
2689
2767
  return this.index >= this.end ? { done: !0, value: void 0 } : { done: !1, value: this.series.at(this.index++, !0) };
2690
2768
  }
2691
- };
2692
- class Qt {
2769
+ }
2770
+ class nn {
2693
2771
  series;
2694
2772
  index;
2695
2773
  decoder;
@@ -2702,12 +2780,12 @@ class Qt {
2702
2780
  }
2703
2781
  next() {
2704
2782
  const e = this.index, t = this.series.data;
2705
- for (; this.index < t.length && t[this.index] !== le; ) this.index++;
2783
+ for (; this.index < t.length && t[this.index] !== fe; ) this.index++;
2706
2784
  const r = this.index;
2707
2785
  return e === r ? { done: !0, value: void 0 } : (this.index++, { done: !1, value: this.decoder.decode(this.series.buffer.slice(e, r)) });
2708
2786
  }
2709
2787
  }
2710
- let _t = class Fe {
2788
+ let rn = class Ge {
2711
2789
  wrapped;
2712
2790
  static schema = s.record(s.string(), s.unknown());
2713
2791
  constructor(e) {
@@ -2717,26 +2795,27 @@ let _t = class Fe {
2717
2795
  const e = this.wrapped.next();
2718
2796
  return e.done === !0 ? { done: !0, value: void 0 } : {
2719
2797
  done: !1,
2720
- value: oe.decodeString(e.value, Fe.schema)
2798
+ value: le.decodeString(e.value, Ge.schema)
2721
2799
  };
2722
2800
  }
2723
- }, en = class {
2801
+ };
2802
+ class sn {
2724
2803
  series;
2725
2804
  index;
2726
2805
  data;
2727
2806
  density;
2728
2807
  constructor(e) {
2729
- if (!e.dataType.equals(w.UUID))
2808
+ if (!e.dataType.equals(O.UUID))
2730
2809
  throw new Error("cannot create a UUID series iterator for a non-UUID series");
2731
- this.series = e, this.index = 0, this.data = new Uint8Array(e.buffer), this.density = w.UUID.density.valueOf();
2810
+ this.series = e, this.index = 0, this.data = new Uint8Array(e.buffer), this.density = O.UUID.density.valueOf();
2732
2811
  }
2733
2812
  next() {
2734
2813
  if (this.index >= this.series.length) return { done: !0, value: void 0 };
2735
- const e = je(this.data, this.index * this.density);
2814
+ const e = We(this.data, this.index * this.density);
2736
2815
  return this.index++, { done: !1, value: e };
2737
2816
  }
2738
- };
2739
- class tn {
2817
+ }
2818
+ let an = class {
2740
2819
  series;
2741
2820
  index;
2742
2821
  constructor(e) {
@@ -2748,8 +2827,8 @@ class tn {
2748
2827
  value: this.series.at(this.index++, !0)
2749
2828
  };
2750
2829
  }
2751
- }
2752
- const Se = (n) => {
2830
+ };
2831
+ const Ue = (n) => {
2753
2832
  const e = n >> 32n, t = n & 0xffffffffn;
2754
2833
  return { domain: e, sample: t };
2755
2834
  };
@@ -2758,18 +2837,18 @@ s.record(
2758
2837
  s.union([s.number(), s.string(), s.symbol()]),
2759
2838
  s.unknown()
2760
2839
  );
2761
- const nn = () => typeof process < "u" && process.versions != null && process.versions.node != null ? "node" : typeof window > "u" || window.document === void 0 ? "webworker" : "browser";
2762
- nn();
2763
- const rn = ["macOS", "Windows", "Linux"], sn = ["macos", "windows", "linux"], an = {
2840
+ const on = () => typeof process < "u" && process.versions != null && process.versions.node != null ? "node" : typeof window > "u" || window.document === void 0 ? "webworker" : "browser";
2841
+ on();
2842
+ const un = ["macOS", "Windows", "Linux"], ln = ["macos", "windows", "linux"], cn = {
2764
2843
  macos: "macOS",
2765
2844
  windows: "Windows",
2766
2845
  linux: "Linux"
2767
2846
  };
2768
- s.enum(rn).or(
2769
- s.enum(sn).transform((n) => an[n])
2847
+ s.enum(un).or(
2848
+ s.enum(ln).transform((n) => cn[n])
2770
2849
  );
2771
- const on = (...n) => n.map(We).join(""), We = (n) => (n.endsWith("/") || (n += "/"), n.startsWith("/") && (n = n.slice(1)), n), un = (n) => n.endsWith("/") ? n.slice(0, -1) : n, ln = (n, e = "") => n === null ? "" : `?${Object.entries(n).filter(([, t]) => t == null ? !1 : Array.isArray(t) ? t.length > 0 : !0).map(([t, r]) => `${e}${t}=${r}`).join("&")}`;
2772
- class V {
2850
+ const hn = (...n) => n.map(ze).join(""), ze = (n) => (n.endsWith("/") || (n += "/"), n.startsWith("/") && (n = n.slice(1)), n), fn = (n) => n.endsWith("/") ? n.slice(0, -1) : n, dn = (n, e = "") => n === null ? "" : `?${Object.entries(n).filter(([, t]) => t == null ? !1 : Array.isArray(t) ? t.length > 0 : !0).map(([t, r]) => `${e}${t}=${r}`).join("&")}`;
2851
+ class z {
2773
2852
  protocol;
2774
2853
  host;
2775
2854
  port;
@@ -2781,7 +2860,7 @@ class V {
2781
2860
  * @param pathPrefix - A path prefix to use for all requests. Defaults to "".
2782
2861
  */
2783
2862
  constructor({ host: e, port: t, protocol: r = "", pathPrefix: i = "" }) {
2784
- this.protocol = r, this.host = e, this.port = t, this.path = We(i);
2863
+ this.protocol = r, this.host = e, this.port = t, this.path = ze(i);
2785
2864
  }
2786
2865
  /**
2787
2866
  * Replaces creates a new URL with the specified properties replaced.
@@ -2789,7 +2868,7 @@ class V {
2789
2868
  * @returns a new URL.
2790
2869
  */
2791
2870
  replace(e) {
2792
- return new V({
2871
+ return new z({
2793
2872
  host: e.host ?? this.host,
2794
2873
  port: e.port ?? this.port,
2795
2874
  protocol: e.protocol ?? this.protocol,
@@ -2802,33 +2881,33 @@ class V {
2802
2881
  * @returns a new URL.
2803
2882
  */
2804
2883
  child(e) {
2805
- return new V({
2884
+ return new z({
2806
2885
  ...this,
2807
- pathPrefix: on(this.path, e)
2886
+ pathPrefix: hn(this.path, e)
2808
2887
  });
2809
2888
  }
2810
2889
  /** @returns a string representation of the url */
2811
2890
  toString() {
2812
- return un(
2891
+ return fn(
2813
2892
  `${this.protocol}://${this.host}:${this.port}/${this.path}`
2814
2893
  );
2815
2894
  }
2816
- static UNKNOWN = new V({ host: "unknown", port: 0 });
2895
+ static UNKNOWN = new z({ host: "unknown", port: 0 });
2817
2896
  }
2818
- const cn = async (n) => await new Promise(
2819
- (e) => setTimeout(e, p.fromMilliseconds(n).milliseconds)
2897
+ const gn = async (n) => await new Promise(
2898
+ (e) => setTimeout(e, l.fromMilliseconds(n).milliseconds)
2820
2899
  );
2821
- class hn {
2900
+ class pn {
2822
2901
  config;
2823
2902
  retries;
2824
2903
  interval;
2825
2904
  constructor(e) {
2826
2905
  this.config = {
2827
- baseInterval: new p(e?.baseInterval ?? p.seconds(1)),
2906
+ baseInterval: new l(e?.baseInterval ?? l.seconds(1)),
2828
2907
  maxRetries: e?.maxRetries ?? 5,
2829
2908
  scale: e?.scale ?? 1,
2830
- sleepFn: e?.sleepFn ?? cn
2831
- }, this.retries = 0, this.interval = new p(this.config.baseInterval);
2909
+ sleepFn: e?.sleepFn ?? gn
2910
+ }, this.retries = 0, this.interval = new l(this.config.baseInterval);
2832
2911
  }
2833
2912
  async wait() {
2834
2913
  const { maxRetries: e, scale: t, sleepFn: r } = this.config;
@@ -2841,159 +2920,165 @@ class hn {
2841
2920
  this.retries = 0, this.interval = this.config.baseInterval;
2842
2921
  }
2843
2922
  }
2844
- const fn = s.object({
2845
- baseInterval: p.z.optional(),
2923
+ const mn = s.object({
2924
+ baseInterval: l.z.optional(),
2846
2925
  maxRetries: s.number().optional(),
2847
2926
  scale: s.number().optional()
2848
- }), dn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2927
+ }), yn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2849
2928
  __proto__: null,
2850
- Breaker: hn,
2851
- breakerConfigZ: fn
2852
- }, Symbol.toStringTag, { value: "Module" })), gn = /^#?([0-9a-f]{6}|[0-9a-f]{8})$/i, Ze = s.string().regex(gn), P = s.number().min(0).max(255), Ve = s.number().min(0).max(1), ze = s.tuple([P, P, P, Ve]), pn = s.tuple([P, P, P]), mn = s.object({ rgba255: ze }), yn = s.number().min(0).max(360), wn = s.number().min(0).max(100), bn = s.number().min(0).max(100), On = s.tuple([yn, wn, bn, Ve]), ge = s.union([Ze, pn, ze, On, mn]), Tn = ge.transform((n) => pe(n)), pe = (n, e = 1) => {
2853
- if (n = ge.parse(n), typeof n == "string") return vn(n, e);
2929
+ Breaker: pn,
2930
+ breakerConfigZ: mn
2931
+ }, Symbol.toStringTag, { value: "Module" })), wn = /^#?([0-9a-f]{6}|[0-9a-f]{8})$/i, Ve = s.string().regex(wn), Y = s.number().min(0).max(255), He = s.number().min(0).max(1), Je = s.tuple([Y, Y, Y, He]), bn = s.tuple([Y, Y, Y]), On = s.object({ rgba255: Je }), Tn = s.number().min(0).max(360), vn = s.number().min(0).max(100), Sn = s.number().min(0).max(100), In = s.tuple([Tn, vn, Sn, He]), ye = s.union([Ve, bn, Je, In, On]), Nn = ye.transform((n) => we(n)), we = (n, e = 1) => {
2932
+ if (n = ye.parse(n), typeof n == "string") return En(n, e);
2854
2933
  if (Array.isArray(n)) {
2855
2934
  if (n.length < 3 || n.length > 4)
2856
2935
  throw new Error(`Invalid color: [${n.join(", ")}]`);
2857
2936
  return n.length === 3 ? [...n, e] : n;
2858
2937
  }
2859
2938
  return n.rgba255;
2860
- }, vn = (n, e = 1) => (n = Ze.parse(n), n = In(n), [
2861
- J(n, 0),
2862
- J(n, 2),
2863
- J(n, 4),
2864
- n.length === 8 ? J(n, 6) / 255 : e
2865
- ]), J = (n, e) => parseInt(n.slice(e, e + 2), 16), In = (n) => n.startsWith("#") ? n.slice(1) : n;
2866
- pe("#000000");
2867
- pe("#ffffff");
2868
- const Nn = s.object({
2939
+ }, En = (n, e = 1) => (n = Ve.parse(n), n = xn(n), [
2940
+ X(n, 0),
2941
+ X(n, 2),
2942
+ X(n, 4),
2943
+ n.length === 8 ? X(n, 6) / 255 : e
2944
+ ]), X = (n, e) => parseInt(n.slice(e, e + 2), 16), xn = (n) => n.startsWith("#") ? n.slice(1) : n;
2945
+ we("#000000");
2946
+ we("#ffffff");
2947
+ const An = s.object({
2869
2948
  key: s.string(),
2870
- color: ge,
2949
+ color: ye,
2871
2950
  position: s.number(),
2872
2951
  switched: s.boolean().optional()
2873
2952
  });
2874
- s.array(Nn);
2875
- const Sn = s.object({
2953
+ s.array(An);
2954
+ const Un = s.object({
2876
2955
  key: s.string(),
2877
2956
  name: s.string(),
2878
- color: Tn
2957
+ color: Nn
2879
2958
  });
2880
2959
  s.object({
2881
2960
  key: s.string(),
2882
2961
  name: s.string(),
2883
- swatches: s.array(Sn)
2962
+ swatches: s.array(Un)
2884
2963
  });
2885
2964
  s.int().min(0).max(255);
2886
2965
  s.object({
2887
2966
  name: s.string(),
2888
2967
  key: s.string()
2889
2968
  });
2890
- const En = (n) => Object.getOwnPropertySymbols(globalThis).includes(n), xn = (n, e) => {
2969
+ const Mn = (n) => Object.getOwnPropertySymbols(globalThis).includes(n), $n = (n, e) => {
2891
2970
  const t = Symbol.for(n);
2892
- if (!En(t)) {
2971
+ if (!Mn(t)) {
2893
2972
  const r = e();
2894
2973
  Object.defineProperty(globalThis, t, { value: r });
2895
2974
  }
2896
2975
  return () => globalThis[t];
2897
- }, Ge = "sy_x_error", An = (n) => (e) => e != null && typeof e == "object" && "type" in e && typeof e.type == "string" ? e.type.startsWith(n) : e instanceof Error ? e.message.startsWith(n) : typeof e != "string" ? !1 : e.startsWith(n), z = (n) => class Z extends Error {
2898
- static discriminator = Ge;
2899
- discriminator = Z.discriminator;
2976
+ }, Ke = "sy_x_error", Cn = (n) => (e) => e != null && typeof e == "object" && "type" in e && typeof e.type == "string" ? e.type.startsWith(n) : e instanceof Error ? e.message.startsWith(n) : typeof e != "string" ? !1 : e.startsWith(n), V = (n) => class G extends Error {
2977
+ static discriminator = Ke;
2978
+ discriminator = G.discriminator;
2900
2979
  static TYPE = n;
2901
- type = Z.TYPE;
2902
- static matches = An(n);
2903
- matches = Z.matches;
2980
+ type = G.TYPE;
2981
+ static matches = Cn(n);
2982
+ matches = G.matches;
2904
2983
  constructor(t, r) {
2905
- super(t, r), this.name = Z.TYPE;
2984
+ super(t, r), this.name = G.TYPE;
2906
2985
  }
2907
2986
  static sub(t) {
2908
- return z(`${n}.${t}`);
2987
+ return V(`${n}.${t}`);
2909
2988
  }
2910
- }, He = (n) => {
2989
+ }, Xe = (n) => {
2911
2990
  if (n == null || typeof n != "object") return !1;
2912
2991
  const e = n;
2913
- if (e.discriminator !== Ge) return !1;
2992
+ if (e.discriminator !== Ke) return !1;
2914
2993
  if (!("type" in e))
2915
2994
  throw new Error(
2916
2995
  `X Error is missing its type property: ${JSON.stringify(e)}`
2917
2996
  );
2918
2997
  return !0;
2919
- }, k = "unknown", ce = "nil";
2920
- class Un {
2998
+ }, j = "unknown", de = "nil";
2999
+ class Bn {
2921
3000
  providers = [];
2922
3001
  register(e) {
2923
3002
  this.providers.push(e);
2924
3003
  }
2925
3004
  encode(e) {
2926
- if (e == null) return { type: ce, data: "" };
2927
- if (He(e))
3005
+ if (e == null) return { type: de, data: "" };
3006
+ if (Xe(e))
2928
3007
  for (const t of this.providers) {
2929
3008
  const r = t.encode(e);
2930
3009
  if (r != null) return r;
2931
3010
  }
2932
- if (e instanceof Error) return { type: k, data: e.message };
2933
- if (typeof e == "string") return { type: k, data: e };
3011
+ if (e instanceof Error) return { type: j, data: e.message };
3012
+ if (typeof e == "string") return { type: j, data: e };
2934
3013
  try {
2935
- return { type: k, data: JSON.stringify(e) };
3014
+ return { type: j, data: JSON.stringify(e) };
2936
3015
  } catch {
2937
- return { type: k, data: "unable to encode error information" };
3016
+ return { type: j, data: "unable to encode error information" };
2938
3017
  }
2939
3018
  }
2940
3019
  decode(e) {
2941
- if (e == null || e.type === ce) return null;
2942
- if (e.type === k) return new he(e.data);
3020
+ if (e == null || e.type === de) return null;
3021
+ if (e.type === j) return new ge(e.data);
2943
3022
  for (const t of this.providers) {
2944
3023
  const r = t.decode(e);
2945
3024
  if (r != null) return r;
2946
3025
  }
2947
- return new he(e.data);
3026
+ return new ge(e.data);
2948
3027
  }
2949
3028
  }
2950
- const me = xn("synnax-error-registry", () => new Un()), Mn = ({ encode: n, decode: e }) => me().register({ encode: n, decode: e }), Cn = (n) => me().encode(n), $n = (n) => n == null ? null : me().decode(n);
2951
- class he extends z("unknown") {
3029
+ const be = $n("synnax-error-registry", () => new Bn()), Rn = ({ encode: n, decode: e }) => be().register({ encode: n, decode: e }), Dn = (n) => be().encode(n), Ln = (n) => n == null ? null : be().decode(n);
3030
+ class ge extends V("unknown") {
2952
3031
  }
2953
- const Bn = s.object({ type: s.string(), data: s.string() });
2954
- class Rn extends z("canceled") {
3032
+ const Pn = s.object({ type: s.string(), data: s.string() });
3033
+ class kn extends V("canceled") {
2955
3034
  }
2956
- class Dn extends z("not_implemented") {
3035
+ class jn extends V("not_implemented") {
2957
3036
  }
2958
- const R = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3037
+ const D = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2959
3038
  __proto__: null,
2960
- Canceled: Rn,
2961
- NONE: ce,
2962
- NotImplemented: Dn,
2963
- UNKNOWN: k,
2964
- Unknown: he,
2965
- createTyped: z,
2966
- decode: $n,
2967
- encode: Cn,
2968
- isTyped: He,
2969
- payloadZ: Bn,
2970
- register: Mn
2971
- }, Symbol.toStringTag, { value: "Module" })), Ln = O.object({
2972
- jsonrpc: O.literal("2.0"),
2973
- method: O.string(),
3039
+ Canceled: kn,
3040
+ NONE: de,
3041
+ NotImplemented: jn,
3042
+ UNKNOWN: j,
3043
+ Unknown: ge,
3044
+ createTyped: V,
3045
+ decode: Ln,
3046
+ encode: Dn,
3047
+ isTyped: Xe,
3048
+ payloadZ: Pn,
3049
+ register: Rn
3050
+ }, Symbol.toStringTag, { value: "Module" })), Yn = b.object({
3051
+ jsonrpc: b.literal("2.0"),
3052
+ method: b.string(),
2974
3053
  // params should be z.union([z.record(z.string(), z.json()),
2975
3054
  // z.array(z.json())]).optional() but the VSCode JSON RPC implementation uses a looser
2976
3055
  // definition of params then in the JSON-RPC spec.
2977
- params: O.any().optional(),
2978
- id: O.union([O.string(), O.number(), O.null()]).optional()
2979
- }), Je = O.object({
2980
- jsonrpc: O.literal("2.0"),
2981
- id: O.union([O.string(), O.number(), O.null()])
2982
- }), kn = Je.extend({
2983
- result: O.json()
2984
- }), Pn = Je.extend({
2985
- error: O.object({
2986
- code: O.number().int(),
3056
+ params: b.any().optional(),
3057
+ id: b.union([b.string(), b.number(), b.null()]).optional()
3058
+ }), Qe = b.object({
3059
+ jsonrpc: b.literal("2.0"),
3060
+ id: b.union([b.string(), b.number(), b.null()])
3061
+ }), qn = Qe.extend({
3062
+ result: b.json()
3063
+ }), Fn = Qe.extend({
3064
+ error: b.object({
3065
+ code: b.number().int(),
2987
3066
  // This should be z.string(), but the VSCode JSON RPC implementation uses a looser
2988
3067
  // definition of error than the JSON-RPC spec.
2989
- message: O.string().optional(),
2990
- data: O.json().optional()
3068
+ message: b.string().optional(),
3069
+ data: b.json().optional()
2991
3070
  })
2992
- }), jn = O.union([kn, Pn]);
2993
- O.union([Ln, jn]);
3071
+ }), Wn = b.union([qn, Fn]);
3072
+ b.union([Yn, Wn]);
3073
+ const Zn = b.uuid();
3074
+ b.object({
3075
+ key: Zn,
3076
+ name: b.string().min(1),
3077
+ color: b.string()
3078
+ });
2994
3079
  s.string().regex(/^\d+\.\d+\.\d+$/);
2995
- const Yn = ["standard", "scientific", "engineering"];
2996
- s.enum(Yn);
3080
+ const Gn = ["standard", "scientific", "engineering"];
3081
+ s.enum(Gn);
2997
3082
  s.enum([
2998
3083
  "success",
2999
3084
  "info",
@@ -3002,51 +3087,55 @@ s.enum([
3002
3087
  "loading",
3003
3088
  "disabled"
3004
3089
  ]);
3005
- class G extends R.createTyped("freighter") {
3090
+ s.object({
3091
+ stack: s.string(),
3092
+ error: s.instanceof(Error)
3093
+ });
3094
+ class H extends D.createTyped("freighter") {
3006
3095
  }
3007
- class j extends G.sub("eof") {
3096
+ class q extends H.sub("eof") {
3008
3097
  constructor() {
3009
3098
  super("EOF");
3010
3099
  }
3011
3100
  }
3012
- class Y extends G.sub("stream_closed") {
3101
+ class F extends H.sub("stream_closed") {
3013
3102
  constructor() {
3014
3103
  super("StreamClosed");
3015
3104
  }
3016
3105
  }
3017
- class q extends G.sub("unreachable") {
3106
+ class W extends H.sub("unreachable") {
3018
3107
  url;
3019
3108
  constructor(e = {}) {
3020
- const { message: t = "Unreachable", url: r = V.UNKNOWN } = e;
3109
+ const { message: t = "Unreachable", url: r = z.UNKNOWN } = e;
3021
3110
  super(t), this.url = r;
3022
3111
  }
3023
3112
  }
3024
- const qn = (n) => {
3025
- if (!n.type.startsWith(G.TYPE)) return null;
3026
- if (j.matches(n)) return { type: j.TYPE, data: "EOF" };
3027
- if (Y.matches(n))
3028
- return { type: Y.TYPE, data: "StreamClosed" };
3029
- if (q.matches(n))
3030
- return { type: q.TYPE, data: "Unreachable" };
3113
+ const zn = (n) => {
3114
+ if (!n.type.startsWith(H.TYPE)) return null;
3115
+ if (q.matches(n)) return { type: q.TYPE, data: "EOF" };
3116
+ if (F.matches(n))
3117
+ return { type: F.TYPE, data: "StreamClosed" };
3118
+ if (W.matches(n))
3119
+ return { type: W.TYPE, data: "Unreachable" };
3031
3120
  throw new Error(`Unknown error type: ${n.type}: ${n.message}`);
3032
- }, Fn = (n) => {
3033
- if (!n.type.startsWith(G.TYPE)) return null;
3121
+ }, Vn = (n) => {
3122
+ if (!n.type.startsWith(H.TYPE)) return null;
3034
3123
  switch (n.type) {
3035
- case j.TYPE:
3036
- return new j();
3037
- case Y.TYPE:
3038
- return new Y();
3039
3124
  case q.TYPE:
3040
3125
  return new q();
3126
+ case F.TYPE:
3127
+ return new F();
3128
+ case W.TYPE:
3129
+ return new W();
3041
3130
  default:
3042
- throw new R.Unknown(`Unknown error type: ${n.data}`);
3131
+ throw new D.Unknown(`Unknown error type: ${n.data}`);
3043
3132
  }
3044
3133
  };
3045
- R.register({
3046
- encode: qn,
3047
- decode: Fn
3134
+ D.register({
3135
+ encode: zn,
3136
+ decode: Vn
3048
3137
  });
3049
- class Xe {
3138
+ class _e {
3050
3139
  middleware = [];
3051
3140
  /** Implements the Transport interface */
3052
3141
  use(...e) {
@@ -3071,24 +3160,24 @@ class Xe {
3071
3160
  return await i(e);
3072
3161
  }
3073
3162
  }
3074
- const Ke = "Content-Type", Wn = /* @__PURE__ */ new Set([
3163
+ const et = "Content-Type", Hn = /* @__PURE__ */ new Set([
3075
3164
  "ECONNREFUSED",
3076
3165
  "ECONNRESET",
3077
3166
  "ETIMEDOUT",
3078
3167
  "EPIPE",
3079
3168
  "UND_ERR_CONNECT_TIMEOUT",
3080
3169
  "UND_ERR_SOCKET"
3081
- ]), Zn = (n) => {
3170
+ ]), Jn = (n) => {
3082
3171
  const e = n?.cause?.code ?? n?.code ?? n?.errno;
3083
- if (typeof e == "string" && Wn.has(e)) return !0;
3172
+ if (typeof e == "string" && Hn.has(e)) return !0;
3084
3173
  if (n.name === "TypeError") {
3085
3174
  const t = String(n.message || "").toLowerCase();
3086
3175
  if (/load failed|failed to fetch|networkerror|network error/.test(t))
3087
3176
  return typeof navigator < "u" && navigator.onLine === !1, !0;
3088
3177
  }
3089
3178
  return n?.name === "AbortError" || n?.code === "ABORT_ERR", !1;
3090
- }, Vn = 400;
3091
- class nr extends Xe {
3179
+ }, Kn = 400;
3180
+ class ar extends _e {
3092
3181
  endpoint;
3093
3182
  encoder;
3094
3183
  constructor(e, t, r = !1) {
@@ -3098,14 +3187,14 @@ class nr extends Xe {
3098
3187
  }
3099
3188
  get headers() {
3100
3189
  return {
3101
- [Ke]: this.encoder.contentType
3190
+ [et]: this.encoder.contentType
3102
3191
  };
3103
3192
  }
3104
3193
  async send(e, t, r, i) {
3105
3194
  t = r?.parse(t);
3106
3195
  let a = null;
3107
- const c = this.endpoint.child(e), g = {};
3108
- g.method = "POST", g.body = this.encoder.encode(t ?? {});
3196
+ const c = this.endpoint.child(e), d = {};
3197
+ d.method = "POST", d.body = this.encoder.encode(t ?? {});
3109
3198
  const [, y] = await this.executeMiddleware(
3110
3199
  {
3111
3200
  target: c.toString(),
@@ -3114,31 +3203,31 @@ class nr extends Xe {
3114
3203
  role: "client"
3115
3204
  },
3116
3205
  async (f) => {
3117
- const m = { ...f, params: {} };
3118
- g.headers = {
3206
+ const g = { ...f, params: {} };
3207
+ d.headers = {
3119
3208
  ...this.headers,
3120
3209
  ...f.params
3121
3210
  };
3122
- let b;
3211
+ let w;
3123
3212
  try {
3124
- b = await fetch(f.target, g);
3213
+ w = await fetch(f.target, d);
3125
3214
  } catch (T) {
3126
3215
  if (!(T instanceof Error)) throw T;
3127
- return [m, Zn(T) ? new q({ url: c }) : T];
3216
+ return [g, Jn(T) ? new W({ url: c }) : T];
3128
3217
  }
3129
- const h = await b.arrayBuffer();
3130
- if (b?.ok)
3131
- return i != null && (a = this.encoder.decode(h, i)), [m, null];
3218
+ const h = await w.arrayBuffer();
3219
+ if (w?.ok)
3220
+ return i != null && (a = this.encoder.decode(h, i)), [g, null];
3132
3221
  try {
3133
- if (b.status !== Vn)
3134
- return [m, new Error(b.statusText)];
3135
- const T = this.encoder.decode(h, R.payloadZ), A = R.decode(T);
3136
- return [m, A];
3222
+ if (w.status !== Kn)
3223
+ return [g, new Error(w.statusText)];
3224
+ const T = this.encoder.decode(h, D.payloadZ), A = D.decode(T);
3225
+ return [g, A];
3137
3226
  } catch (T) {
3138
3227
  return [
3139
- m,
3228
+ g,
3140
3229
  new Error(
3141
- `[freighter] - failed to decode error: ${b.statusText}: ${T.message}`
3230
+ `[freighter] - failed to decode error: ${w.statusText}: ${T.message}`
3142
3231
  )
3143
3232
  ];
3144
3233
  }
@@ -3149,7 +3238,7 @@ class nr extends Xe {
3149
3238
  return [a, null];
3150
3239
  }
3151
3240
  }
3152
- const rr = (n, e) => {
3241
+ const or = (n, e) => {
3153
3242
  class t {
3154
3243
  wrapped;
3155
3244
  constructor(i) {
@@ -3158,27 +3247,27 @@ const rr = (n, e) => {
3158
3247
  use(...i) {
3159
3248
  this.wrapped.use(...i);
3160
3249
  }
3161
- async send(i, a, c, g) {
3162
- const y = new dn.Breaker(e);
3250
+ async send(i, a, c, d) {
3251
+ const y = new yn.Breaker(e);
3163
3252
  do {
3164
- const [f, m] = await this.wrapped.send(i, a, c, g);
3165
- if (m == null) return [f, null];
3166
- if (!q.matches(m)) return [null, m];
3167
- if (console.warn(`[freighter] ${y.retryMessage}`, m), !await y.wait()) return [f, m];
3253
+ const [f, g] = await this.wrapped.send(i, a, c, d);
3254
+ if (g == null) return [f, null];
3255
+ if (!W.matches(g)) return [null, g];
3256
+ if (console.warn(`[freighter] ${y.retryMessage}`, g), !await y.wait()) return [f, g];
3168
3257
  } while (!0);
3169
3258
  }
3170
3259
  }
3171
3260
  return new t(n);
3172
- }, sr = async (n, e, t, r, i) => {
3261
+ }, ur = async (n, e, t, r, i) => {
3173
3262
  const [a, c] = await n.send(e, t, r, i);
3174
3263
  if (c != null) throw c;
3175
3264
  return a;
3176
- }, zn = s.object({
3265
+ }, Xn = s.object({
3177
3266
  type: s.enum(["data", "close", "open"]),
3178
3267
  payload: s.unknown(),
3179
- error: s.optional(R.payloadZ)
3268
+ error: s.optional(D.payloadZ)
3180
3269
  });
3181
- class Gn {
3270
+ class Qn {
3182
3271
  codec;
3183
3272
  reqSchema;
3184
3273
  resSchema;
@@ -3194,14 +3283,14 @@ class Gn {
3194
3283
  const e = await this.receiveMsg();
3195
3284
  if (e.type !== "open") {
3196
3285
  if (e.error == null) throw new Error("Message error must be defined");
3197
- return R.decode(e.error);
3286
+ return D.decode(e.error);
3198
3287
  }
3199
3288
  return null;
3200
3289
  }
3201
3290
  /** Implements the Stream protocol */
3202
3291
  send(e) {
3203
- if (this.serverClosed != null) return new j();
3204
- if (this.sendClosed) throw new Y();
3292
+ if (this.serverClosed != null) return new q();
3293
+ if (this.sendClosed) throw new F();
3205
3294
  return this.ws.send(this.codec.encode({ type: "data", payload: e })), null;
3206
3295
  }
3207
3296
  /** Implements the Stream protocol */
@@ -3210,7 +3299,7 @@ class Gn {
3210
3299
  const e = await this.receiveMsg();
3211
3300
  if (e.type === "close") {
3212
3301
  if (e.error == null) throw new Error("Message error must be defined");
3213
- if (this.serverClosed = R.decode(e.error), this.serverClosed == null) throw new Error("Message error must be defined");
3302
+ if (this.serverClosed = D.decode(e.error), this.serverClosed == null) throw new Error("Message error must be defined");
3214
3303
  return [null, this.serverClosed];
3215
3304
  }
3216
3305
  return [this.resSchema.parse(e.payload), null];
@@ -3243,20 +3332,20 @@ class Gn {
3243
3332
  this.ws.onmessage = this.onMessage.bind(this), this.ws.onclose = this.onClose.bind(this);
3244
3333
  }
3245
3334
  onMessage(e) {
3246
- this.addMessage(this.codec.decode(e.data, zn));
3335
+ this.addMessage(this.codec.decode(e.data, Xn));
3247
3336
  }
3248
3337
  onClose(e) {
3249
3338
  this.addMessage({
3250
3339
  type: "close",
3251
3340
  error: {
3252
- type: e.code === Jn ? j.TYPE : Y.TYPE,
3341
+ type: e.code === er ? q.TYPE : F.TYPE,
3253
3342
  data: ""
3254
3343
  }
3255
3344
  });
3256
3345
  }
3257
3346
  }
3258
- const Hn = "freighterctx", Jn = 1e3;
3259
- class fe extends Xe {
3347
+ const _n = "freighterctx", er = 1e3;
3348
+ class pe extends _e {
3260
3349
  baseUrl;
3261
3350
  encoder;
3262
3351
  secure;
@@ -3270,7 +3359,7 @@ class fe extends Xe {
3270
3359
  super(), this.secure = r, this.baseUrl = e.replace({ protocol: r ? "wss" : "ws" }), this.encoder = t;
3271
3360
  }
3272
3361
  withCodec(e) {
3273
- const t = new fe(this.baseUrl, e, this.secure);
3362
+ const t = new pe(this.baseUrl, e, this.secure);
3274
3363
  return t.use(...this.middleware), t;
3275
3364
  }
3276
3365
  /** Implements the StreamClient interface. */
@@ -3279,9 +3368,9 @@ class fe extends Xe {
3279
3368
  const [, a] = await this.executeMiddleware(
3280
3369
  { target: e, protocol: "websocket", params: {}, role: "client" },
3281
3370
  async (c) => {
3282
- const g = new WebSocket(this.buildURL(e, c)), y = { ...c, params: {} };
3283
- g.binaryType = fe.MESSAGE_TYPE;
3284
- const f = await this.wrapSocket(g, t, r);
3371
+ const d = new WebSocket(this.buildURL(e, c)), y = { ...c, params: {} };
3372
+ d.binaryType = pe.MESSAGE_TYPE;
3373
+ const f = await this.wrapSocket(d, t, r);
3285
3374
  return f instanceof Error ? [y, f] : (i = f, [y, null]);
3286
3375
  }
3287
3376
  );
@@ -3289,19 +3378,19 @@ class fe extends Xe {
3289
3378
  return i;
3290
3379
  }
3291
3380
  buildURL(e, t) {
3292
- const r = ln(
3381
+ const r = dn(
3293
3382
  {
3294
- [Ke]: this.encoder.contentType,
3383
+ [et]: this.encoder.contentType,
3295
3384
  ...t.params
3296
3385
  },
3297
- Hn
3386
+ _n
3298
3387
  );
3299
3388
  return this.baseUrl.child(e).toString() + r;
3300
3389
  }
3301
3390
  async wrapSocket(e, t, r) {
3302
3391
  return await new Promise((i) => {
3303
3392
  e.onopen = () => {
3304
- const a = new Gn(e, this.encoder, t, r);
3393
+ const a = new Qn(e, this.encoder, t, r);
3305
3394
  a.receiveOpenAck().then((c) => {
3306
3395
  c != null ? i(c) : i(a);
3307
3396
  }).catch((c) => i(c));
@@ -3313,11 +3402,11 @@ class fe extends Xe {
3313
3402
  }
3314
3403
  }
3315
3404
  export {
3316
- j as EOF,
3317
- nr as HTTPClient,
3318
- Y as StreamClosed,
3319
- q as Unreachable,
3320
- fe as WebSocketClient,
3321
- sr as sendRequired,
3322
- rr as unaryWithBreaker
3405
+ q as EOF,
3406
+ ar as HTTPClient,
3407
+ F as StreamClosed,
3408
+ W as Unreachable,
3409
+ pe as WebSocketClient,
3410
+ ur as sendRequired,
3411
+ or as unaryWithBreaker
3323
3412
  };