@synnaxlabs/freighter 0.44.1 → 0.44.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/freighter.js CHANGED
@@ -1,36 +1,36 @@
1
1
  import O, { z as s } from "zod";
2
- const He = (n) => {
3
- const e = n.replace(/_[a-z]/g, (t) => t[1].toUpperCase());
2
+ const Xe = (r) => {
3
+ const e = r.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
- }, Se = (n) => {
6
- const e = (t, r = se) => {
7
- if (typeof t == "string") return n(t);
8
- if (Array.isArray(t)) return t.map((c) => e(c, r));
9
- if (!te(t)) return t;
10
- r = _e(r);
5
+ }, Se = (r) => {
6
+ const e = (t, n = ie) => {
7
+ if (typeof t == "string") return r(t);
8
+ if (Array.isArray(t)) return t.map((c) => e(c, n));
9
+ if (!re(t)) return t;
10
+ n = et(n);
11
11
  const i = {}, a = t;
12
- return "toJSON" in a && typeof a.toJSON == "function" ? e(a.toJSON(), r) : (Object.keys(a).forEach((c) => {
12
+ return "toJSON" in a && typeof a.toJSON == "function" ? e(a.toJSON(), n) : (Object.keys(a).forEach((c) => {
13
13
  let d = a[c];
14
- const y = n(c);
15
- r.recursive && (te(d) ? me(d) || (d = e(d, r)) : r.recursiveInArray && pe(d) && (d = [...d].map((f) => {
14
+ const y = r(c);
15
+ n.recursive && (re(d) ? ye(d) || (d = e(d, n)) : n.recursiveInArray && me(d) && (d = [...d].map((f) => {
16
16
  let p = f;
17
- return te(f) ? me(p) || (p = e(f, r)) : pe(f) && (p = e({ key: f }, r).key), p;
17
+ return re(f) ? ye(p) || (p = e(f, n)) : me(f) && (p = e({ key: f }, n).key), p;
18
18
  }))), i[y] = d;
19
19
  }), i);
20
20
  };
21
21
  return e;
22
- }, Ne = Se(He), Xe = (n) => (
22
+ }, Ee = Se(Xe), Ke = (r) => (
23
23
  // Don't convert the first character and don't convert a character that is after a
24
24
  // non-alphanumeric character
25
- n.replace(
25
+ r.replace(
26
26
  /([a-z0-9])([A-Z])/g,
27
- (e, t, r) => `${t}_${r.toLowerCase()}`
27
+ (e, t, n) => `${t}_${n.toLowerCase()}`
28
28
  )
29
- ), Ke = Se(Xe), Qe = [Number, String, Uint8Array], se = {
29
+ ), Qe = Se(Ke), _e = [Number, String, Uint8Array], ie = {
30
30
  recursive: !0,
31
31
  recursiveInArray: !0
32
- }, _e = (n = se) => (n.recursive == null ? n = se : n.recursiveInArray ??= !1, n), pe = (n) => n != null && Array.isArray(n), te = (n) => n != null && typeof n == "object" && !Array.isArray(n), me = (n) => Qe.some((e) => n instanceof e);
33
- let et = class {
32
+ }, et = (r = ie) => (r.recursive == null ? r = ie : r.recursiveInArray ??= !1, r), me = (r) => r != null && Array.isArray(r), re = (r) => r != null && typeof r == "object" && !Array.isArray(r), ye = (r) => _e.some((e) => r instanceof e);
33
+ let tt = class {
34
34
  contentType = "application/json";
35
35
  decoder;
36
36
  encoder;
@@ -44,16 +44,16 @@ let et = 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 = Ne(r);
47
+ const n = JSON.parse(e), i = Ee(n);
48
48
  return t != null ? t.parse(i) : i;
49
49
  }
50
50
  encodeString(e) {
51
- const t = Ke(e);
52
- return JSON.stringify(t, (r, i) => ArrayBuffer.isView(i) ? Array.from(i) : typeof i == "bigint" ? i.toString() : i);
51
+ const t = Qe(e);
52
+ return JSON.stringify(t, (n, i) => ArrayBuffer.isView(i) ? Array.from(i) : typeof i == "bigint" ? i.toString() : i);
53
53
  }
54
54
  };
55
- const ie = new et();
56
- class q {
55
+ const ae = new tt();
56
+ let q = class {
57
57
  /** The underlying primitive value */
58
58
  value;
59
59
  constructor(e) {
@@ -72,98 +72,100 @@ class q {
72
72
  toString() {
73
73
  return this.value.toString();
74
74
  }
75
- }
76
- const tt = (n) => n != null && typeof n == "object" && "toString" in n, nt = (n, e = !1) => {
77
- const t = tt(n) ? "stringer" : typeof n;
78
- let r;
75
+ };
76
+ const rt = (r) => r != null && typeof r == "object" && "toString" in r, nt = (r, e = !1) => {
77
+ const t = rt(r) ? "stringer" : typeof r;
78
+ let n;
79
79
  switch (t) {
80
80
  case "string":
81
- r = (i, a) => i.localeCompare(a);
81
+ n = (i, a) => i.localeCompare(a);
82
82
  break;
83
83
  case "stringer":
84
- r = (i, a) => i.toString().localeCompare(a.toString());
84
+ n = (i, a) => i.toString().localeCompare(a.toString());
85
85
  break;
86
86
  case "number":
87
- r = (i, a) => Number(i) - Number(a);
87
+ n = (i, a) => Number(i) - Number(a);
88
88
  break;
89
89
  case "bigint":
90
- r = (i, a) => BigInt(i) - BigInt(a) > 0n ? 1 : -1;
90
+ n = (i, a) => BigInt(i) - BigInt(a) > 0n ? 1 : -1;
91
91
  break;
92
92
  case "boolean":
93
- r = (i, a) => Number(i) - Number(a);
93
+ n = (i, a) => Number(i) - Number(a);
94
94
  break;
95
95
  case "undefined":
96
- r = () => 0;
96
+ n = () => 0;
97
97
  break;
98
98
  default:
99
99
  return console.warn(`sortFunc: unknown type ${t}`), () => -1;
100
100
  }
101
- return e ? rt(r) : r;
102
- }, rt = (n) => (e, t) => n(t, e), X = s.tuple([s.number(), s.number()]);
101
+ return e ? st(n) : n;
102
+ }, st = (r) => (e, t) => r(t, e), K = s.tuple([s.number(), s.number()]);
103
103
  s.tuple([s.bigint(), s.bigint()]);
104
- const Ee = s.object({ width: s.number(), height: s.number() }), st = s.object({
104
+ const xe = s.object({ width: s.number(), height: s.number() }), it = s.object({
105
105
  signedWidth: s.number(),
106
106
  signedHeight: s.number()
107
- }), it = ["width", "height"];
108
- s.enum(it);
109
- const at = ["start", "center", "end"], ot = ["signedWidth", "signedHeight"];
110
- s.enum(ot);
111
- const H = s.object({ x: s.number(), y: s.number() }), ut = s.object({ clientX: s.number(), clientY: s.number() }), lt = ["x", "y"], xe = s.enum(lt), Ae = ["top", "right", "bottom", "left"];
112
- s.enum(Ae);
113
- const ct = ["left", "right"], Ue = s.enum(ct), ht = ["top", "bottom"], Me = s.enum(ht), Ce = ["center"], ye = s.enum(Ce), ft = [...Ae, ...Ce], $e = s.enum(ft);
107
+ }), at = ["width", "height"];
114
108
  s.enum(at);
115
- const dt = ["first", "last"];
116
- s.enum(dt);
117
- const gt = s.object({ lower: s.number(), upper: s.number() }), pt = s.object({ lower: s.bigint(), upper: s.bigint() });
118
- s.union([gt, X]);
119
- s.union([pt, X]);
120
- s.enum([...xe.options, ...$e.options]);
121
- s.union([xe, $e, s.instanceof(String)]);
122
- const K = (n) => (e, t) => {
109
+ const ot = ["start", "center", "end"], ut = ["signedWidth", "signedHeight"];
110
+ s.enum(ut);
111
+ const X = s.object({ x: s.number(), y: s.number() }), lt = s.object({ clientX: s.number(), clientY: s.number() }), ct = ["x", "y"], Ae = s.enum(ct), Ue = ["top", "right", "bottom", "left"];
112
+ s.enum(Ue);
113
+ const ht = ["left", "right"], Me = s.enum(ht), ft = ["top", "bottom"], Ce = s.enum(ft), $e = ["center"], we = s.enum($e), dt = [...Ue, ...$e], Be = s.enum(dt);
114
+ s.enum(ot);
115
+ const gt = ["first", "last"];
116
+ s.enum(gt);
117
+ const pt = s.object({ lower: s.number(), upper: s.number() }), mt = s.object({ lower: s.bigint(), upper: s.bigint() });
118
+ s.union([pt, K]);
119
+ s.union([mt, K]);
120
+ s.enum([...Ae.options, ...Be.options]);
121
+ s.enum(["x", "left", "right"]);
122
+ s.enum(["y", "top", "bottom"]);
123
+ s.union([Ae, Be, s.instanceof(String)]);
124
+ const Q = (r) => (e, t) => {
123
125
  if (typeof e == "bigint") {
124
- if (mt(t))
125
- return n(e, BigInt(t));
126
- const r = n(Number(e), Number(t));
127
- return typeof r == "number" ? BigInt(Math.round(r)) : r;
128
- }
129
- return n(Number(e), Number(t));
130
- }, Q = K((n, e) => n - e), _ = K((n, e) => n + e), mt = (n) => typeof n == "bigint" ? !0 : Number.isInteger(n), U = K((n, e) => n * e), ee = K((n, e) => n / e), R = (n, e, t) => {
131
- const r = {};
132
- if (typeof e == "object" && (t = e, e = void 0), t = { makeValid: !0, ...t }, typeof n == "number" || typeof n == "bigint")
133
- e != null ? (r.lower = n, r.upper = e) : (r.lower = typeof n == "bigint" ? 0n : 0, r.upper = n);
134
- else if (Array.isArray(n)) {
135
- if (n.length !== 2) throw new Error("bounds: expected array of length 2");
136
- [r.lower, r.upper] = n;
126
+ if (yt(t))
127
+ return r(e, BigInt(t));
128
+ const n = r(Number(e), Number(t));
129
+ return typeof n == "number" ? BigInt(Math.round(n)) : n;
130
+ }
131
+ return r(Number(e), Number(t));
132
+ }, _ = Q((r, e) => r - e), ee = Q((r, e) => r + e), yt = (r) => typeof r == "bigint" ? !0 : Number.isInteger(r), U = Q((r, e) => r * e), te = Q((r, e) => r / e), R = (r, e, t) => {
133
+ const n = {};
134
+ if (typeof e == "object" && (t = e, e = void 0), t = { makeValid: !0, ...t }, typeof r == "number" || typeof r == "bigint")
135
+ e != null ? (n.lower = r, n.upper = e) : (n.lower = typeof r == "bigint" ? 0n : 0, n.upper = r);
136
+ else if (Array.isArray(r)) {
137
+ if (r.length !== 2) throw new Error("bounds: expected array of length 2");
138
+ [n.lower, n.upper] = r;
137
139
  } else
138
- r.lower = n.lower, r.upper = n.upper;
139
- return t?.makeValid ? yt(r) : r;
140
- }, yt = (n) => n.lower > n.upper ? { lower: n.upper, upper: n.lower } : n, we = (n, e) => {
141
- const t = R(n);
140
+ n.lower = r.lower, n.upper = r.upper;
141
+ return t?.makeValid ? wt(n) : n;
142
+ }, wt = (r) => r.lower > r.upper ? { lower: r.upper, upper: r.lower } : r, be = (r, e) => {
143
+ const t = R(r);
142
144
  return e < t.lower ? t.lower : e >= t.upper ? t.upper - (typeof t.upper == "number" ? 1 : 1n) : e;
143
145
  };
144
146
  s.object({
145
- x: Ue.or(ye),
146
- y: Me.or(ye)
147
+ x: Me.or(we),
148
+ y: Ce.or(we)
147
149
  });
148
- const wt = s.object({ x: Ue, y: Me }), bt = Object.freeze({ x: "left", y: "top" }), Ot = (n, e) => n.x === e.x && n.y === e.y, be = s.union([
150
+ const bt = s.object({ x: Me, y: Ce }), Ot = Object.freeze({ x: "left", y: "top" }), Tt = (r, e) => r.x === e.x && r.y === e.y, Oe = s.union([
149
151
  s.number(),
150
- H,
151
152
  X,
152
- Ee,
153
- st,
154
- ut
155
- ]), Tt = (n, e) => {
156
- if (typeof n == "string") {
153
+ K,
154
+ xe,
155
+ it,
156
+ lt
157
+ ]), vt = (r, e) => {
158
+ if (typeof r == "string") {
157
159
  if (e === void 0) throw new Error("The y coordinate must be given.");
158
- return n === "x" ? { x: e, y: 0 } : { x: 0, y: e };
160
+ return r === "x" ? { x: e, y: 0 } : { x: 0, y: e };
159
161
  }
160
- 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 };
161
- }, Oe = Object.freeze({ x: 0, y: 0 }), z = s.union([s.number(), s.string()]);
162
+ return typeof r == "number" ? { x: r, y: e ?? r } : Array.isArray(r) ? { x: r[0], y: r[1] } : "signedWidth" in r ? { x: r.signedWidth, y: r.signedHeight } : "clientX" in r ? { x: r.clientX, y: r.clientY } : "width" in r ? { x: r.width, y: r.height } : { x: r.x, y: r.y };
163
+ }, Te = Object.freeze({ x: 0, y: 0 }), G = s.union([s.number(), s.string()]);
162
164
  s.object({
163
- top: z,
164
- left: z,
165
- width: z,
166
- height: z
165
+ top: G,
166
+ left: G,
167
+ width: G,
168
+ height: G
167
169
  });
168
170
  s.object({
169
171
  left: s.number(),
@@ -172,61 +174,61 @@ s.object({
172
174
  bottom: s.number()
173
175
  });
174
176
  s.object({
175
- one: H,
176
- two: H,
177
- root: wt
177
+ one: X,
178
+ two: X,
179
+ root: bt
178
180
  });
179
- const he = (n, e, t = 0, r = 0, i) => {
181
+ const fe = (r, e, t = 0, n = 0, i) => {
180
182
  const a = {
181
- one: { ...Oe },
182
- two: { ...Oe },
183
- root: i ?? bt
183
+ one: { ...Te },
184
+ two: { ...Te },
185
+ root: i ?? Ot
184
186
  };
185
- if (typeof n == "number") {
187
+ if (typeof r == "number") {
186
188
  if (typeof e != "number")
187
189
  throw new Error("Box constructor called with invalid arguments");
188
- return a.one = { x: n, y: e }, a.two = { x: a.one.x + t, y: a.one.y + r }, a;
190
+ return a.one = { x: r, y: e }, a.two = { x: a.one.x + t, y: a.one.y + n }, a;
189
191
  }
190
- return "one" in n && "two" in n && "root" in n ? { ...n, root: i ?? n.root } : ("getBoundingClientRect" in n && (n = n.getBoundingClientRect()), "left" in n ? (a.one = { x: n.left, y: n.top }, a.two = { x: n.right, y: n.bottom }, a) : (a.one = n, e == null ? a.two = { x: a.one.x + t, y: a.one.y + r } : typeof e == "number" ? a.two = { x: a.one.x + e, y: a.one.y + t } : "width" in e ? a.two = {
192
+ return "one" in r && "two" in r && "root" in r ? { ...r, root: i ?? r.root } : ("getBoundingClientRect" in r && (r = r.getBoundingClientRect()), "left" in r ? (a.one = { x: r.left, y: r.top }, a.two = { x: r.right, y: r.bottom }, a) : (a.one = r, e == null ? a.two = { x: a.one.x + t, y: a.one.y + n } : typeof e == "number" ? a.two = { x: a.one.x + e, y: a.one.y + t } : "width" in e ? a.two = {
191
193
  x: a.one.x + e.width,
192
194
  y: a.one.y + e.height
193
195
  } : "signedWidth" in e ? a.two = {
194
196
  x: a.one.x + e.signedWidth,
195
197
  y: a.one.y + e.signedHeight
196
198
  } : a.two = e, a));
197
- }, ne = (n) => {
198
- const e = he(n);
199
+ }, ne = (r) => {
200
+ const e = fe(r);
199
201
  return { lower: e.one.x, upper: e.two.x };
200
- }, re = (n) => {
201
- const e = he(n);
202
+ }, se = (r) => {
203
+ const e = fe(r);
202
204
  return { lower: e.one.y, upper: e.two.y };
203
- }, vt = (n) => typeof n != "object" || n == null ? !1 : "one" in n && "two" in n && "root" in n, It = s.object({ signedWidth: s.number(), signedHeight: s.number() });
204
- s.union([Ee, It, H, X]);
205
- const St = (n, e, t) => e !== void 0 && n < e ? e : t !== void 0 && n > t ? t : n;
206
- s.object({ offset: be, scale: be });
205
+ }, It = (r) => typeof r != "object" || r == null ? !1 : "one" in r && "two" in r && "root" in r, Nt = s.object({ signedWidth: s.number(), signedHeight: s.number() });
206
+ s.union([xe, Nt, X, K]);
207
+ const St = (r, e, t) => e !== void 0 && r < e ? e : t !== void 0 && r > t ? t : r;
208
+ s.object({ offset: Oe, scale: Oe });
207
209
  s.object({ offset: s.number(), scale: s.number() });
208
- const Nt = (n) => (e, t, r, i) => t === "dimension" ? [e, r] : [
210
+ const Et = (r) => (e, t, n, i) => t === "dimension" ? [e, n] : [
209
211
  e,
210
- i ? r - n : r + n
211
- ], Et = (n) => (e, t, r, i) => [
212
+ i ? n - r : n + r
213
+ ], xt = (r) => (e, t, n, i) => [
212
214
  e,
213
- i ? r / n : r * n
214
- ], xt = (n) => (e, t, r) => {
215
- if (e === null) return [n, r];
216
- const { lower: i, upper: a } = e, { lower: c, upper: d } = n, y = a - i, f = d - c;
217
- if (t === "dimension") return [n, r * (f / y)];
218
- const p = (r - i) * (f / y) + c;
219
- return [n, p];
220
- }, At = (n) => (e, t, r) => [n, r], Ut = () => (n, e, t) => {
221
- if (n === null) throw new Error("cannot invert without bounds");
222
- if (e === "dimension") return [n, t];
223
- const { lower: r, upper: i } = n;
224
- return [n, i - (t - r)];
225
- }, Mt = (n) => (e, t, r) => {
226
- const { lower: i, upper: a } = n;
227
- return r = St(r, i, a), [e, r];
215
+ i ? n / r : n * r
216
+ ], At = (r) => (e, t, n) => {
217
+ if (e === null) return [r, n];
218
+ const { lower: i, upper: a } = e, { lower: c, upper: d } = r, y = a - i, f = d - c;
219
+ if (t === "dimension") return [r, n * (f / y)];
220
+ const p = (n - i) * (f / y) + c;
221
+ return [r, p];
222
+ }, Ut = (r) => (e, t, n) => [r, n], Mt = () => (r, e, t) => {
223
+ if (r === null) throw new Error("cannot invert without bounds");
224
+ if (e === "dimension") return [r, t];
225
+ const { lower: n, upper: i } = r;
226
+ return [r, i - (t - n)];
227
+ }, Ct = (r) => (e, t, n) => {
228
+ const { lower: i, upper: a } = r;
229
+ return n = St(n, i, a), [e, n];
228
230
  };
229
- let Te = class D {
231
+ let ve = class D {
230
232
  ops = [];
231
233
  currBounds = null;
232
234
  currType = null;
@@ -260,8 +262,8 @@ let Te = class D {
260
262
  * @param value - The amount to translate by.
261
263
  */
262
264
  translate(e) {
263
- const t = this.new(), r = Nt(e);
264
- return r.type = "translate", t.ops.push(r), t;
265
+ const t = this.new(), n = Et(e);
266
+ return n.type = "translate", t.ops.push(n), t;
265
267
  }
266
268
  /**
267
269
  * @returns a copy of the scale with a translation as its next operation. Any number
@@ -270,23 +272,23 @@ let Te = class D {
270
272
  * @param value - The amount to magnify by.
271
273
  */
272
274
  magnify(e) {
273
- const t = this.new(), r = Et(e);
274
- return r.type = "magnify", t.ops.push(r), t;
275
+ const t = this.new(), n = xt(e);
276
+ return n.type = "magnify", t.ops.push(n), t;
275
277
  }
276
278
  scale(e, t) {
277
- const r = R(e, t), i = this.new(), a = xt(r);
279
+ const n = R(e, t), i = this.new(), a = At(n);
278
280
  return a.type = "scale", i.ops.push(a), i;
279
281
  }
280
282
  clamp(e, t) {
281
- const r = R(e, t), i = this.new(), a = Mt(r);
283
+ const n = R(e, t), i = this.new(), a = Ct(n);
282
284
  return a.type = "clamp", i.ops.push(a), i;
283
285
  }
284
286
  reBound(e, t) {
285
- const r = R(e, t), i = this.new(), a = At(r);
287
+ const n = R(e, t), i = this.new(), a = Ut(n);
286
288
  return a.type = "re-bound", i.ops.push(a), i;
287
289
  }
288
290
  invert() {
289
- const e = Ut();
291
+ const e = Mt();
290
292
  e.type = "invert";
291
293
  const t = this.new();
292
294
  return t.ops.push(e), t;
@@ -303,7 +305,7 @@ let Te = class D {
303
305
  }
304
306
  exec(e, t) {
305
307
  return this.currBounds = null, this.ops.reduce(
306
- ([r, i], a) => a(r, e, i, this.reversed),
308
+ ([n, i], a) => a(n, e, i, this.reversed),
307
309
  [null, t]
308
310
  )[1];
309
311
  }
@@ -311,26 +313,26 @@ let Te = class D {
311
313
  const e = this.new();
312
314
  e.ops.reverse();
313
315
  const t = [];
314
- return e.ops.forEach((r, i) => {
315
- if (r.type === "scale" || t.some(([c, d]) => i >= c && i <= d))
316
+ return e.ops.forEach((n, i) => {
317
+ if (n.type === "scale" || t.some(([c, d]) => i >= c && i <= d))
316
318
  return;
317
319
  const a = e.ops.findIndex((c, d) => c.type === "scale" && d > i);
318
320
  a !== -1 && t.push([i, a]);
319
- }), t.forEach(([r, i]) => {
320
- const a = e.ops.slice(r, i);
321
- a.unshift(e.ops[i]), e.ops.splice(r, i - r + 1, ...a);
321
+ }), t.forEach(([n, i]) => {
322
+ const a = e.ops.slice(n, i);
323
+ a.unshift(e.ops[i]), e.ops.splice(n, i - n + 1, ...a);
322
324
  }), e.reversed = !e.reversed, e;
323
325
  }
324
326
  get transform() {
325
327
  return { scale: this.dim(1), offset: this.pos(0) };
326
328
  }
327
329
  static IDENTITY = new D();
328
- }, Hn = class A {
330
+ }, Xr = class A {
329
331
  x;
330
332
  y;
331
333
  currRoot;
332
- constructor(e = new Te(), t = new Te(), r = null) {
333
- this.x = e, this.y = t, this.currRoot = r;
334
+ constructor(e = new ve(), t = new ve(), n = null) {
335
+ this.x = e, this.y = t, this.currRoot = n;
334
336
  }
335
337
  static translate(e, t) {
336
338
  return new A().translate(e, t);
@@ -354,8 +356,8 @@ let Te = class D {
354
356
  return new A().reBound(e);
355
357
  }
356
358
  translate(e, t) {
357
- const r = Tt(e, t), i = this.copy();
358
- return i.x = this.x.translate(r.x), i.y = this.y.translate(r.y), i;
359
+ const n = vt(e, t), i = this.copy();
360
+ return i.x = this.x.translate(n.x), i.y = this.y.translate(n.y), i;
359
361
  }
360
362
  translateX(e) {
361
363
  const t = this.copy();
@@ -371,19 +373,19 @@ let Te = class D {
371
373
  }
372
374
  scale(e) {
373
375
  const t = this.copy();
374
- if (vt(e)) {
375
- const r = this.currRoot;
376
- return t.currRoot = e.root, r != null && !Ot(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(ne(e)), t.y = t.y.scale(re(e)), t;
376
+ if (It(e)) {
377
+ const n = this.currRoot;
378
+ return t.currRoot = e.root, n != null && !Tt(n, e.root) && (n.x !== e.root.x && (t.x = t.x.invert()), n.y !== e.root.y && (t.y = t.y.invert())), t.x = t.x.scale(ne(e)), t.y = t.y.scale(se(e)), t;
377
379
  }
378
380
  return t.x = t.x.scale(e.width), t.y = t.y.scale(e.height), t;
379
381
  }
380
382
  reBound(e) {
381
383
  const t = this.copy();
382
- return t.x = this.x.reBound(ne(e)), t.y = this.y.reBound(re(e)), t;
384
+ return t.x = this.x.reBound(ne(e)), t.y = this.y.reBound(se(e)), t;
383
385
  }
384
386
  clamp(e) {
385
387
  const t = this.copy();
386
- return t.x = this.x.clamp(ne(e)), t.y = this.y.clamp(re(e)), t;
388
+ return t.x = this.x.clamp(ne(e)), t.y = this.y.clamp(se(e)), t;
387
389
  }
388
390
  copy() {
389
391
  const e = new A();
@@ -400,7 +402,7 @@ let Te = class D {
400
402
  return { x: this.x.dim(e.x), y: this.y.dim(e.y) };
401
403
  }
402
404
  box(e) {
403
- return he(
405
+ return fe(
404
406
  this.pos(e.one),
405
407
  this.pos(e.two),
406
408
  0,
@@ -415,17 +417,17 @@ let Te = class D {
415
417
  };
416
418
  }
417
419
  static IDENTITY = new A();
418
- }, Be = (n, e = 21) => (t = e) => {
419
- let r = "", i = t | 0;
420
+ }, Re = (r, e = 21) => (t = e) => {
421
+ let n = "", i = t | 0;
420
422
  for (; i--; )
421
- r += n[Math.random() * n.length | 0];
422
- return r;
423
+ n += r[Math.random() * r.length | 0];
424
+ return n;
423
425
  };
424
- const Re = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", Ct = `0123456789${Re}`, $t = 11, Bt = Be(Re, 1), Rt = Be(Ct, $t - 1), Dt = () => `${Bt()}${Rt()}`, Lt = (n, e) => (t) => t instanceof e || typeof t == "object" && t !== null && "discriminator" in t && t.discriminator === n, Pt = s.enum(["static", "dynamic"]), kt = s.union([
426
+ const De = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", $t = `0123456789${De}`, Bt = 11, Rt = Re(De, 1), Dt = Re($t, Bt - 1), Lt = () => `${Rt()}${Dt()}`, Pt = (r, e) => (t) => t instanceof e || typeof t == "object" && t !== null && "discriminator" in t && t.discriminator === r, kt = s.enum(["static", "dynamic"]), Yt = s.union([
425
427
  s.tuple([s.int()]),
426
428
  s.tuple([s.int(), s.int().min(1).max(12)]),
427
429
  s.tuple([s.int(), s.int().min(1).max(12), s.int().min(1).max(31)])
428
- ]), De = (n, e) => {
430
+ ]), Le = (r, e) => {
429
431
  const t = new o(e);
430
432
  if (![
431
433
  g.DAY,
@@ -439,8 +441,8 @@ const Re = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", Ct = `0123456
439
441
  throw new Error(
440
442
  "Invalid argument for remainder. Must be an even TimeSpan or Timestamp"
441
443
  );
442
- const r = n.valueOf() % t.valueOf();
443
- return n instanceof o ? new o(r) : new g(r);
444
+ const n = r.valueOf() % t.valueOf();
445
+ return r instanceof o ? new o(n) : new g(n);
444
446
  };
445
447
  class o extends q {
446
448
  constructor(e, t = "UTC") {
@@ -451,12 +453,12 @@ class o extends q {
451
453
  super(o.parseDateTimeString(e, t).valueOf());
452
454
  else if (Array.isArray(e)) super(o.parseDate(e));
453
455
  else {
454
- let r = 0n;
455
- 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)), super(BigInt(e.valueOf()) + r);
456
+ let n = 0n;
457
+ e instanceof Number && (e = e.valueOf()), t === "local" && (n = 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)), super(BigInt(e.valueOf()) + n);
456
458
  }
457
459
  }
458
- static parseDate([e = 1970, t = 1, r = 1]) {
459
- const i = new Date(e, t - 1, r, 0, 0, 0, 0);
460
+ static parseDate([e = 1970, t = 1, n = 1]) {
461
+ const i = new Date(e, t - 1, n, 0, 0, 0, 0);
460
462
  return new o(BigInt(i.getTime()) * o.MILLISECOND.valueOf()).truncate(o.DAY).valueOf();
461
463
  }
462
464
  /**
@@ -467,18 +469,18 @@ class o extends q {
467
469
  return this.value;
468
470
  }
469
471
  static parseTimeString(e, t = "UTC") {
470
- const [r, i, a] = e.split(":");
472
+ const [n, i, a] = e.split(":");
471
473
  let c = "00", d = "00";
472
474
  a != null && ([c, d] = a.split("."));
473
- let y = o.hours(parseInt(r ?? "00")).add(o.minutes(parseInt(i ?? "00"))).add(o.seconds(parseInt(c ?? "00"))).add(o.milliseconds(parseInt(d ?? "00")));
475
+ let y = o.hours(parseInt(n ?? "00")).add(o.minutes(parseInt(i ?? "00"))).add(o.seconds(parseInt(c ?? "00"))).add(o.milliseconds(parseInt(d ?? "00")));
474
476
  return t === "local" && (y = y.add(o.utcOffset)), y.valueOf();
475
477
  }
476
478
  static parseDateTimeString(e, t = "UTC") {
477
479
  if (!e.includes("/") && !e.includes("-"))
478
480
  return o.parseTimeString(e, t);
479
- const r = new Date(e);
480
- return e.includes(":") || r.setUTCHours(0, 0, 0, 0), new o(
481
- BigInt(r.getTime()) * o.MILLISECOND.valueOf(),
481
+ const n = new Date(e);
482
+ return e.includes(":") || n.setUTCHours(0, 0, 0, 0), new o(
483
+ BigInt(n.getTime()) * o.MILLISECOND.valueOf(),
482
484
  t
483
485
  ).valueOf();
484
486
  }
@@ -513,12 +515,12 @@ class o extends q {
513
515
  return e === "UTC" ? this.date().toISOString() : this.sub(o.utcOffset).date().toISOString();
514
516
  }
515
517
  timeString(e = !1, t = "UTC") {
516
- const r = this.toISOString(t);
517
- return e ? r.slice(11, 23) : r.slice(11, 19);
518
+ const n = this.toISOString(t);
519
+ return e ? n.slice(11, 23) : n.slice(11, 19);
518
520
  }
519
521
  dateString() {
520
- const e = this.date(), t = e.toLocaleString("default", { month: "short" }), r = e.toLocaleString("default", { day: "numeric" });
521
- return `${t} ${r}`;
522
+ const e = this.date(), t = e.toLocaleString("default", { month: "short" }), n = e.toLocaleString("default", { day: "numeric" });
523
+ return `${t} ${n}`;
522
524
  }
523
525
  /** @returns The UTC offset for the time zone of the machine. */
524
526
  static get utcOffset() {
@@ -565,7 +567,7 @@ class o extends q {
565
567
  * valid, regardless of the TimeStamp order.
566
568
  */
567
569
  range(e) {
568
- return new S(this, e).makeValid();
570
+ return new F(this, e).makeValid();
569
571
  }
570
572
  /**
571
573
  * Creates a TimeRange starting at the TimeStamp and spanning the given
@@ -634,7 +636,7 @@ class o extends q {
634
636
  * TimeSpan.
635
637
  */
636
638
  add(e) {
637
- return new o(_(this.valueOf(), new g(e).valueOf()));
639
+ return new o(ee(this.valueOf(), new g(e).valueOf()));
638
640
  }
639
641
  /**
640
642
  * Subtracts a TimeSpan from the TimeStamp.
@@ -644,7 +646,7 @@ class o extends q {
644
646
  * TimeSpan.
645
647
  */
646
648
  sub(e) {
647
- return new o(Q(this.valueOf(), new g(e).valueOf()));
649
+ return new o(_(this.valueOf(), new g(e).valueOf()));
648
650
  }
649
651
  /**
650
652
  * @returns the floating point number of hours since the unix epoch to the timestamp
@@ -798,7 +800,7 @@ class o extends q {
798
800
  * @example TimeStamp.now().remainder(TimeStamp.DAY) // => TimeStamp representing the current day
799
801
  */
800
802
  remainder(e) {
801
- return De(this, e);
803
+ return Le(this, e);
802
804
  }
803
805
  /** @returns true if the day portion TimeStamp is today, false otherwise. */
804
806
  get isToday() {
@@ -829,8 +831,8 @@ class o extends q {
829
831
  */
830
832
  static max(...e) {
831
833
  let t = o.MIN;
832
- for (const r of e) {
833
- const i = new o(r);
834
+ for (const n of e) {
835
+ const i = new o(n);
834
836
  i.after(t) && (t = i);
835
837
  }
836
838
  return t;
@@ -843,8 +845,8 @@ class o extends q {
843
845
  */
844
846
  static min(...e) {
845
847
  let t = o.MAX;
846
- for (const r of e) {
847
- const i = new o(r);
848
+ for (const n of e) {
849
+ const i = new o(n);
848
850
  i.before(t) && (t = i);
849
851
  }
850
852
  return t;
@@ -911,7 +913,7 @@ class o extends q {
911
913
  s.bigint().transform((e) => new o(e)),
912
914
  s.date().transform((e) => new o(e)),
913
915
  s.custom((e) => e instanceof g).transform((e) => new o(e)),
914
- kt.transform((e) => new o(e))
916
+ Yt.transform((e) => new o(e))
915
917
  ]);
916
918
  /**
917
919
  * Sorts two timestamps.
@@ -936,7 +938,7 @@ let g = class l extends q {
936
938
  * @returns A TimeSpan representing the given number of seconds.
937
939
  */
938
940
  static fromSeconds(e) {
939
- return e instanceof l ? e : e instanceof E ? e.period : e instanceof o ? new l(e) : ["number", "bigint"].includes(typeof e) ? l.seconds(e) : new l(e);
941
+ return e instanceof l ? e : e instanceof S ? e.period : e instanceof o ? new l(e) : ["number", "bigint"].includes(typeof e) ? l.seconds(e) : new l(e);
940
942
  }
941
943
  /**
942
944
  * Creates a TimeSpan representing the given number of milliseconds.
@@ -945,7 +947,7 @@ let g = class l extends q {
945
947
  * @returns A TimeSpan representing the given number of milliseconds.
946
948
  */
947
949
  static fromMilliseconds(e) {
948
- return e instanceof l ? e : e instanceof E ? e.period : e instanceof o ? new l(e) : ["number", "bigint"].includes(typeof e) ? l.milliseconds(e) : new l(e);
950
+ return e instanceof l ? e : e instanceof S ? e.period : e instanceof o ? new l(e) : ["number", "bigint"].includes(typeof e) ? l.milliseconds(e) : new l(e);
949
951
  }
950
952
  /**
951
953
  * @returns the primitive value of the TimeSpan. Overrides standard JS valueOf()
@@ -997,7 +999,7 @@ let g = class l extends q {
997
999
  * @returns A new TimeSpan representing the remainder.
998
1000
  */
999
1001
  remainder(e) {
1000
- return De(this, e);
1002
+ return Le(this, e);
1001
1003
  }
1002
1004
  /**
1003
1005
  * Truncates the TimeSpan to the nearest multiple of the given span.
@@ -1016,7 +1018,7 @@ let g = class l extends q {
1016
1018
  * @returns A string representation of the TimeSpan.
1017
1019
  */
1018
1020
  toString() {
1019
- 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), d = this.truncate(l.NANOSECOND), y = e, f = t.sub(e), p = r.sub(t), b = i.sub(r), h = a.sub(i), T = c.sub(a), x = d.sub(c);
1021
+ const e = this.truncate(l.DAY), t = this.truncate(l.HOUR), n = this.truncate(l.MINUTE), i = this.truncate(l.SECOND), a = this.truncate(l.MILLISECOND), c = this.truncate(l.MICROSECOND), d = this.truncate(l.NANOSECOND), y = e, f = t.sub(e), p = n.sub(t), b = i.sub(n), h = a.sub(i), T = c.sub(a), x = d.sub(c);
1020
1022
  let C = "";
1021
1023
  return y.isZero || (C += `${y.days}d `), f.isZero || (C += `${f.hours}h `), p.isZero || (C += `${p.minutes}m `), b.isZero || (C += `${b.seconds}s `), h.isZero || (C += `${h.milliseconds}ms `), T.isZero || (C += `${T.microseconds}µs `), x.isZero || (C += `${x.nanoseconds}ns`), C.trim();
1022
1024
  }
@@ -1036,7 +1038,7 @@ let g = class l extends q {
1036
1038
  * @returns A new TimeSpan that is this TimeSpan divided by the provided value.
1037
1039
  */
1038
1040
  div(e) {
1039
- return new l(ee(this.valueOf(), e));
1041
+ return new l(te(this.valueOf(), e));
1040
1042
  }
1041
1043
  /** @returns the decimal number of days in the TimeSpan. */
1042
1044
  get days() {
@@ -1189,10 +1191,10 @@ let g = class l extends q {
1189
1191
  s.bigint().transform((e) => new l(e)),
1190
1192
  s.instanceof(l),
1191
1193
  s.instanceof(o).transform((e) => new l(e)),
1192
- s.custom((e) => e instanceof E).transform((e) => new l(e))
1194
+ s.custom((e) => e instanceof S).transform((e) => new l(e))
1193
1195
  ]);
1194
1196
  };
1195
- class E extends q {
1197
+ class S extends q {
1196
1198
  constructor(e) {
1197
1199
  super(e.valueOf());
1198
1200
  }
@@ -1202,7 +1204,7 @@ class E extends q {
1202
1204
  }
1203
1205
  /** @returns The number of seconds in the Rate. */
1204
1206
  equals(e) {
1205
- return this.valueOf() === new E(e).valueOf();
1207
+ return this.valueOf() === new S(e).valueOf();
1206
1208
  }
1207
1209
  /**
1208
1210
  * Calculates the period of the Rate as a TimeSpan.
@@ -1257,7 +1259,7 @@ class E extends q {
1257
1259
  * @returns A new Rate representing the sum of the two rates.
1258
1260
  */
1259
1261
  add(e) {
1260
- return new E(_(this.valueOf(), e.valueOf()));
1262
+ return new S(ee(this.valueOf(), e.valueOf()));
1261
1263
  }
1262
1264
  /**
1263
1265
  * Subtracts another Rate from this Rate.
@@ -1266,7 +1268,7 @@ class E extends q {
1266
1268
  * @returns A new Rate representing the difference of the two rates.
1267
1269
  */
1268
1270
  sub(e) {
1269
- return new E(Q(this.valueOf(), e.valueOf()));
1271
+ return new S(_(this.valueOf(), e.valueOf()));
1270
1272
  }
1271
1273
  /**
1272
1274
  * Multiplies this Rate by a scalar value.
@@ -1275,7 +1277,7 @@ class E extends q {
1275
1277
  * @returns A new Rate representing this Rate multiplied by the value.
1276
1278
  */
1277
1279
  mult(e) {
1278
- return new E(U(this.valueOf(), e));
1280
+ return new S(U(this.valueOf(), e));
1279
1281
  }
1280
1282
  /**
1281
1283
  * Divides this Rate by a scalar value.
@@ -1284,7 +1286,7 @@ class E extends q {
1284
1286
  * @returns A new Rate representing this Rate divided by the value.
1285
1287
  */
1286
1288
  div(e) {
1287
- return new E(ee(this.valueOf(), e));
1289
+ return new S(te(this.valueOf(), e));
1288
1290
  }
1289
1291
  /**
1290
1292
  * Creates a Rate representing the given number of Hz.
@@ -1293,7 +1295,7 @@ class E extends q {
1293
1295
  * @returns A Rate representing the given number of Hz.
1294
1296
  */
1295
1297
  static hz(e) {
1296
- return new E(e);
1298
+ return new S(e);
1297
1299
  }
1298
1300
  /**
1299
1301
  * Creates a Rate representing the given number of kHz.
@@ -1302,12 +1304,12 @@ class E extends q {
1302
1304
  * @returns A Rate representing the given number of kHz.
1303
1305
  */
1304
1306
  static khz(e) {
1305
- return E.hz(e * 1e3);
1307
+ return S.hz(e * 1e3);
1306
1308
  }
1307
1309
  /** A zod schema for validating and transforming rates */
1308
1310
  static z = s.union([
1309
- s.number().transform((e) => new E(e)),
1310
- s.instanceof(E)
1311
+ s.number().transform((e) => new S(e)),
1312
+ s.instanceof(S)
1311
1313
  ]);
1312
1314
  }
1313
1315
  let I = class N extends q {
@@ -1337,7 +1339,7 @@ let I = class N extends q {
1337
1339
  * @returns A Size representing the given number of values.
1338
1340
  */
1339
1341
  size(e) {
1340
- return new ae(e * this.valueOf());
1342
+ return new oe(e * this.valueOf());
1341
1343
  }
1342
1344
  /**
1343
1345
  * Adds another Density to this Density.
@@ -1346,7 +1348,7 @@ let I = class N extends q {
1346
1348
  * @returns A new Density representing the sum of the two densities.
1347
1349
  */
1348
1350
  add(e) {
1349
- return new N(_(this.valueOf(), e.valueOf()));
1351
+ return new N(ee(this.valueOf(), e.valueOf()));
1350
1352
  }
1351
1353
  /**
1352
1354
  * Subtracts another Density from this Density.
@@ -1355,7 +1357,7 @@ let I = class N extends q {
1355
1357
  * @returns A new Density representing the difference of the two densities.
1356
1358
  */
1357
1359
  sub(e) {
1358
- return new N(Q(this.valueOf(), e.valueOf()));
1360
+ return new N(_(this.valueOf(), e.valueOf()));
1359
1361
  }
1360
1362
  /**
1361
1363
  * Multiplies this Density by a scalar value.
@@ -1373,7 +1375,7 @@ let I = class N extends q {
1373
1375
  * @returns A new Density representing this Density divided by the value.
1374
1376
  */
1375
1377
  div(e) {
1376
- return new N(ee(this.valueOf(), e));
1378
+ return new N(te(this.valueOf(), e));
1377
1379
  }
1378
1380
  /** Unknown/Invalid Density. */
1379
1381
  static UNKNOWN = new N(0);
@@ -1392,8 +1394,7 @@ let I = class N extends q {
1392
1394
  s.number().transform((e) => new N(e)),
1393
1395
  s.instanceof(N)
1394
1396
  ]);
1395
- };
1396
- class S {
1397
+ }, F = class E {
1397
1398
  /**
1398
1399
  * The starting TimeStamp of the TimeRange.
1399
1400
  *
@@ -1461,7 +1462,7 @@ class S {
1461
1462
  * @returns A TimeRange with the start and end swapped.
1462
1463
  */
1463
1464
  swap() {
1464
- return new S(this.end, this.start);
1465
+ return new E(this.end, this.start);
1465
1466
  }
1466
1467
  get numericBounds() {
1467
1468
  return {
@@ -1478,8 +1479,8 @@ class S {
1478
1479
  equals(e, t = g.ZERO) {
1479
1480
  if (t.isZero)
1480
1481
  return this.start.equals(e.start) && this.end.equals(e.end);
1481
- let r = this.start.sub(e.start).valueOf(), i = this.end.sub(e.end).valueOf();
1482
- return r < 0 && (r = -r), i < 0 && (i = -i), r <= t.valueOf() && i <= t.valueOf();
1482
+ let n = this.start.sub(e.start).valueOf(), i = this.end.sub(e.end).valueOf();
1483
+ return n < 0 && (n = -n), i < 0 && (i = -i), n <= t.valueOf() && i <= t.valueOf();
1483
1484
  }
1484
1485
  /**
1485
1486
  * Returns a string representation of the TimeRange.
@@ -1510,14 +1511,14 @@ class S {
1510
1511
  */
1511
1512
  overlapsWith(e, t = g.ZERO) {
1512
1513
  e = e.makeValid();
1513
- const r = this.makeValid();
1514
+ const n = this.makeValid();
1514
1515
  if (this.equals(e)) return !0;
1515
- if (e.end.equals(r.start) || r.end.equals(e.start)) return !1;
1516
- const i = o.max(r.start, e.start), a = o.min(r.end, e.end);
1516
+ if (e.end.equals(n.start) || n.end.equals(e.start)) return !1;
1517
+ const i = o.max(n.start, e.start), a = o.min(n.end, e.end);
1517
1518
  return a.before(i) ? !1 : new g(a.sub(i)).greaterThanOrEqual(t);
1518
1519
  }
1519
1520
  contains(e) {
1520
- return e instanceof S ? this.contains(e.start) && this.contains(e.end) : this.start.beforeEq(e) && this.end.after(e);
1521
+ return e instanceof E ? this.contains(e.start) && this.contains(e.end) : this.start.beforeEq(e) && this.end.after(e);
1521
1522
  }
1522
1523
  /**
1523
1524
  * Returns a new TimeRange that is bound by the given TimeRange.
@@ -1531,25 +1532,25 @@ class S {
1531
1532
  * console.log(bounded); // TimeRange(1500, 2000)
1532
1533
  */
1533
1534
  boundBy(e) {
1534
- const t = new S(this.start, this.end);
1535
+ const t = new E(this.start, this.end);
1535
1536
  return e.start.after(this.start) && (t.start = e.start), e.start.after(this.end) && (t.end = e.start), e.end.before(this.end) && (t.end = e.end), e.end.before(this.start) && (t.start = e.end), t;
1536
1537
  }
1537
1538
  static max(...e) {
1538
- return new S(
1539
+ return new E(
1539
1540
  o.min(...e.map((t) => t.start)),
1540
1541
  o.max(...e.map((t) => t.end))
1541
1542
  );
1542
1543
  }
1543
1544
  /** The maximum possible time range. */
1544
- static MAX = new S(o.MIN, o.MAX);
1545
+ static MAX = new E(o.MIN, o.MAX);
1545
1546
  /** The minimum possible time range. */
1546
- static MIN = new S(o.MAX, o.MIN);
1547
+ static MIN = new E(o.MAX, o.MIN);
1547
1548
  /** A time range whose start and end are both zero. */
1548
- static ZERO = new S(o.ZERO, o.ZERO);
1549
+ static ZERO = new E(o.ZERO, o.ZERO);
1549
1550
  /** A zod schema for validating and transforming time ranges */
1550
1551
  static z = s.union([
1551
- s.object({ start: o.z, end: o.z }).transform((e) => new S(e.start, e.end)),
1552
- s.instanceof(S)
1552
+ s.object({ start: o.z, end: o.z }).transform((e) => new E(e.start, e.end)),
1553
+ s.instanceof(E)
1553
1554
  ]);
1554
1555
  /**
1555
1556
  * Sorts two time ranges. The range with the earlier start time is considered less than
@@ -1565,8 +1566,23 @@ class S {
1565
1566
  static sort(e, t) {
1566
1567
  return o.sort(e.start, t.start) || o.sort(e.end, t.end);
1567
1568
  }
1568
- }
1569
- let w = class u extends q {
1569
+ /**
1570
+ * Simplify takes the list of `TimeRange`s, makes all of them valid, sorts them, and
1571
+ * merges any overlapping ranges.
1572
+ *
1573
+ * @param ranges - The list of `TimeRange`s to simplify.
1574
+ * @returns A list of simplified `TimeRange`s.
1575
+ */
1576
+ static simplify(e) {
1577
+ return e.map((t) => t.makeValid()).sort((t, n) => E.sort(t, n)).reduce((t, n) => {
1578
+ if (n.isZero) return t;
1579
+ if (t.length === 0)
1580
+ return t.push(n), t;
1581
+ const i = t[t.length - 1];
1582
+ return i.overlapsWith(n) || i.end.equals(n.start) ? i.end = o.max(i.end, n.end) : t.push(n), t;
1583
+ }, []);
1584
+ }
1585
+ }, w = class u extends q {
1570
1586
  constructor(e) {
1571
1587
  if (e instanceof u || typeof e == "string" || typeof e.valueOf() == "string")
1572
1588
  super(e.valueOf());
@@ -1784,7 +1800,7 @@ let w = class u extends q {
1784
1800
  s.string().transform((e) => new u(e)),
1785
1801
  s.instanceof(u)
1786
1802
  ]);
1787
- }, ae = class m extends q {
1803
+ }, oe = class m extends q {
1788
1804
  constructor(e) {
1789
1805
  super(e.valueOf());
1790
1806
  }
@@ -1798,11 +1814,11 @@ let w = class u extends q {
1798
1814
  }
1799
1815
  /** @returns a new Size representing the sum of the two Sizes. */
1800
1816
  add(e) {
1801
- return new m(_(this.valueOf(), e.valueOf()));
1817
+ return new m(ee(this.valueOf(), e.valueOf()));
1802
1818
  }
1803
1819
  /** @returns a new Size representing the difference of the two Sizes. */
1804
1820
  sub(e) {
1805
- return new m(Q(this.valueOf(), e.valueOf()));
1821
+ return new m(_(this.valueOf(), e.valueOf()));
1806
1822
  }
1807
1823
  /**
1808
1824
  * Multiplies this Size by a scalar value.
@@ -1820,7 +1836,7 @@ let w = class u extends q {
1820
1836
  * @returns A new Size representing this Size divided by the value.
1821
1837
  */
1822
1838
  div(e) {
1823
- return new m(ee(this.valueOf(), e));
1839
+ return new m(te(this.valueOf(), e));
1824
1840
  }
1825
1841
  /** @returns a new Size representing the truncated value of the Size. */
1826
1842
  truncate(e) {
@@ -1848,7 +1864,7 @@ let w = class u extends q {
1848
1864
  }
1849
1865
  /** @returns a nicely formatted string representation of the Size. */
1850
1866
  toString() {
1851
- const e = this.truncate(m.TERABYTE), t = this.truncate(m.GIGABYTE), r = this.truncate(m.MEGABYTE), i = this.truncate(m.KILOBYTE), a = this.truncate(m.BYTE), c = e, d = t.sub(e), y = r.sub(t), f = i.sub(r), p = a.sub(i);
1867
+ const e = this.truncate(m.TERABYTE), t = this.truncate(m.GIGABYTE), n = this.truncate(m.MEGABYTE), i = this.truncate(m.KILOBYTE), a = this.truncate(m.BYTE), c = e, d = t.sub(e), y = n.sub(t), f = i.sub(n), p = a.sub(i);
1852
1868
  let b = "";
1853
1869
  return c.isZero || (b += `${c.terabytes}TB `), d.isZero || (b += `${d.gigabytes}GB `), y.isZero || (b += `${y.megabytes}MB `), f.isZero || (b += `${f.kilobytes}KB `), (!p.isZero || b === "") && (b += `${p.valueOf()}B`), b.trim();
1854
1870
  }
@@ -1931,36 +1947,36 @@ s.union([
1931
1947
  s.instanceof(Int32Array),
1932
1948
  s.instanceof(BigInt64Array)
1933
1949
  ]);
1934
- const Le = (n) => {
1935
- const e = typeof n;
1936
- return e === "string" || e === "number" || e === "boolean" || e === "bigint" || n instanceof o || n instanceof g || n instanceof Date;
1937
- }, Yt = (n, e, t, r = 0) => n.usesBigInt && !e.usesBigInt ? Number(t) - Number(r) : !n.usesBigInt && e.usesBigInt ? BigInt(t.valueOf()) - BigInt(r.valueOf()) : J(t, -r), J = (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), jt = /^(?:[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;
1938
- function qt(n) {
1939
- return typeof n == "string" && jt.test(n);
1950
+ const Pe = (r) => {
1951
+ const e = typeof r;
1952
+ return e === "string" || e === "number" || e === "boolean" || e === "bigint" || r instanceof o || r instanceof g || r instanceof Date;
1953
+ }, jt = (r, e, t, n = 0) => r.usesBigInt && !e.usesBigInt ? Number(t) - Number(n) : !r.usesBigInt && e.usesBigInt ? BigInt(t.valueOf()) - BigInt(n.valueOf()) : H(t, -n), H = (r, e) => e == 0 ? r : r == 0 ? e : typeof r == "bigint" && typeof e == "bigint" || typeof r == "number" && typeof e == "number" ? r + e : Number(r) + Number(e), qt = /^(?:[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;
1954
+ function Ft(r) {
1955
+ return typeof r == "string" && qt.test(r);
1940
1956
  }
1941
1957
  const v = [];
1942
- for (let n = 0; n < 256; ++n)
1943
- v.push((n + 256).toString(16).slice(1));
1944
- function Ft(n, e = 0) {
1945
- 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();
1958
+ for (let r = 0; r < 256; ++r)
1959
+ v.push((r + 256).toString(16).slice(1));
1960
+ function Wt(r, e = 0) {
1961
+ return (v[r[e + 0]] + v[r[e + 1]] + v[r[e + 2]] + v[r[e + 3]] + "-" + v[r[e + 4]] + v[r[e + 5]] + "-" + v[r[e + 6]] + v[r[e + 7]] + "-" + v[r[e + 8]] + v[r[e + 9]] + "-" + v[r[e + 10]] + v[r[e + 11]] + v[r[e + 12]] + v[r[e + 13]] + v[r[e + 14]] + v[r[e + 15]]).toLowerCase();
1946
1962
  }
1947
- function Wt(n, e = 0) {
1948
- const t = Ft(n, e);
1949
- if (!qt(t))
1963
+ function Zt(r, e = 0) {
1964
+ const t = Wt(r, e);
1965
+ if (!Ft(t))
1950
1966
  throw TypeError("Stringified UUID is invalid");
1951
1967
  return t;
1952
1968
  }
1953
1969
  typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
1954
- const Pe = (n, e) => Wt(n, e), $ = -1, Zt = s.string().transform(
1955
- (n) => new Uint8Array(
1956
- atob(n).split("").map((e) => e.charCodeAt(0))
1970
+ const ke = (r, e) => Zt(r, e), $ = -1, Vt = s.string().transform(
1971
+ (r) => new Uint8Array(
1972
+ atob(r).split("").map((e) => e.charCodeAt(0))
1957
1973
  ).buffer
1958
- ), Vt = s.union([s.null(), s.undefined()]).transform(() => new Uint8Array().buffer), oe = 10, zt = (n, e) => {
1959
- if (n === "number" && !e.isNumeric)
1974
+ ), zt = s.union([s.null(), s.undefined()]).transform(() => new Uint8Array().buffer), ue = 10, Gt = (r, e) => {
1975
+ if (r === "number" && !e.isNumeric)
1960
1976
  throw new Error(`cannot convert series of type ${e.toString()} to number`);
1961
- if (n === "bigint" && !e.usesBigInt)
1977
+ if (r === "bigint" && !e.usesBigInt)
1962
1978
  throw new Error(`cannot convert series of type ${e.toString()} to bigint`);
1963
- }, ke = "sy_x_telem_series";
1979
+ }, Ye = "sy_x_telem_series";
1964
1980
  class M {
1965
1981
  /**
1966
1982
  * A unique identifier for the series. If specified by the user, it is their
@@ -1972,7 +1988,7 @@ class M {
1972
1988
  * A discriminator used for identifying instances of the series class even
1973
1989
  * when bundlers mangle the class name.
1974
1990
  */
1975
- discriminator = ke;
1991
+ discriminator = Ye;
1976
1992
  /** The data type of the series. */
1977
1993
  dataType;
1978
1994
  /**
@@ -1988,7 +2004,7 @@ class M {
1988
2004
  /** The underlying data. */
1989
2005
  _data;
1990
2006
  /** The time range occupied by the series' data. */
1991
- timeRange = S.ZERO;
2007
+ timeRange = F.ZERO;
1992
2008
  /**
1993
2009
  * Alignment defines the location of the series relative to other series in a logical
1994
2010
  * group. Useful for defining the position of the series within a channel's data.
@@ -2017,16 +2033,16 @@ class M {
2017
2033
  * can be constructed into a series.
2018
2034
  */
2019
2035
  static crudeZ = s.object({
2020
- timeRange: S.z.optional(),
2036
+ timeRange: F.z.optional(),
2021
2037
  dataType: w.z,
2022
2038
  alignment: s.coerce.bigint().optional(),
2023
2039
  data: s.union([
2024
- Zt,
2025
2040
  Vt,
2041
+ zt,
2026
2042
  s.instanceof(ArrayBuffer),
2027
2043
  s.instanceof(Uint8Array)
2028
2044
  ]),
2029
- glBufferUsage: Pt.optional().default("static").optional()
2045
+ glBufferUsage: kt.optional().default("static").optional()
2030
2046
  });
2031
2047
  /**
2032
2048
  * A zod schema that validates and constructs a series from it's crude
@@ -2107,23 +2123,23 @@ class M {
2107
2123
  * @throws Error if data type cannot be inferred from input
2108
2124
  */
2109
2125
  constructor(e) {
2110
- Gt(e) && (e = { data: e }), e.data ??= [];
2126
+ Jt(e) && (e = { data: e }), e.data ??= [];
2111
2127
  const {
2112
2128
  dataType: t,
2113
- timeRange: r,
2129
+ timeRange: n,
2114
2130
  sampleOffset: i = 0,
2115
2131
  glBufferUsage: a = "static",
2116
2132
  alignment: c = 0n,
2117
2133
  alignmentMultiple: d = 1n,
2118
- key: y = Dt(),
2134
+ key: y = Lt(),
2119
2135
  data: f
2120
2136
  } = e;
2121
- if (Jt(f)) {
2137
+ if (Ht(f)) {
2122
2138
  const h = f;
2123
2139
  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;
2124
2140
  return;
2125
2141
  }
2126
- const p = Le(f), b = Array.isArray(f);
2142
+ const p = Pe(f), b = Array.isArray(f);
2127
2143
  if (t != null) this.dataType = new w(t);
2128
2144
  else {
2129
2145
  if (f instanceof ArrayBuffer)
@@ -2161,7 +2177,7 @@ class M {
2161
2177
  (T instanceof o || T instanceof Date || T instanceof g) && (h = h.map((x) => new o(x).valueOf())), this.dataType.equals(w.STRING) ? (this.cachedLength = h.length, this._data = new TextEncoder().encode(`${h.join(`
2162
2178
  `)}
2163
2179
  `).buffer) : this.dataType.equals(w.JSON) ? (this.cachedLength = h.length, this._data = new TextEncoder().encode(
2164
- `${h.map((x) => ie.encodeString(x)).join(`
2180
+ `${h.map((x) => ae.encodeString(x)).join(`
2165
2181
  `)}
2166
2182
  `
2167
2183
  ).buffer) : this.dataType.usesBigInt && typeof T == "number" ? this._data = new this.dataType.Array(
@@ -2170,7 +2186,7 @@ class M {
2170
2186
  h.map(Number)
2171
2187
  ).buffer : this._data = new this.dataType.Array(h).buffer;
2172
2188
  }
2173
- this.key = y, this.alignment = c, this.alignmentMultiple = d, this.sampleOffset = i ?? 0, this.timeRange = r ?? S.ZERO, this.gl = {
2189
+ this.key = y, this.alignment = c, this.alignmentMultiple = d, this.sampleOffset = i ?? 0, this.timeRange = n ?? F.ZERO, this.gl = {
2174
2190
  control: null,
2175
2191
  buffer: null,
2176
2192
  prevBuffer: 0,
@@ -2184,10 +2200,10 @@ class M {
2184
2200
  * @param args.dataType the data type of the series.
2185
2201
  * @param args.rest the rest of the arguments to pass to the series constructor.
2186
2202
  */
2187
- static alloc({ capacity: e, dataType: t, ...r }) {
2203
+ static alloc({ capacity: e, dataType: t, ...n }) {
2188
2204
  if (e === 0)
2189
2205
  throw new Error("[Series] - cannot allocate an array of length 0");
2190
- const i = new new w(t).Array(e), a = new M({ data: i.buffer, dataType: t, ...r });
2206
+ const i = new new w(t).Array(e), a = new M({ data: i.buffer, dataType: t, ...n });
2191
2207
  return a.writePos = 0, a;
2192
2208
  }
2193
2209
  /**
@@ -2231,13 +2247,13 @@ class M {
2231
2247
  }
2232
2248
  writeVariable(e) {
2233
2249
  if (this.writePos === $) return 0;
2234
- const t = this.byteCapacity.valueOf() - this.writePos, r = e.subBytes(0, t);
2235
- return this.writeToUnderlyingData(r), this.writePos += r.byteLength.valueOf(), this.cachedLength != null && (this.cachedLength += r.length, this.calculateCachedLength()), r.length;
2250
+ const t = this.byteCapacity.valueOf() - this.writePos, n = e.subBytes(0, t);
2251
+ return this.writeToUnderlyingData(n), this.writePos += n.byteLength.valueOf(), this.cachedLength != null && (this.cachedLength += n.length, this.calculateCachedLength()), n.length;
2236
2252
  }
2237
2253
  writeFixed(e) {
2238
2254
  if (this.writePos === $) return 0;
2239
- const t = this.capacity - this.writePos, r = e.sub(0, t);
2240
- return this.writeToUnderlyingData(r), this.cachedLength = void 0, this.maybeRecomputeMinMax(r), this.writePos += r.length, r.length;
2255
+ const t = this.capacity - this.writePos, n = e.sub(0, t);
2256
+ return this.writeToUnderlyingData(n), this.cachedLength = void 0, this.maybeRecomputeMinMax(n), this.writePos += n.length, n.length;
2241
2257
  }
2242
2258
  writeToUnderlyingData(e) {
2243
2259
  this.underlyingData.set(
@@ -2279,14 +2295,14 @@ class M {
2279
2295
  parseJSON(e) {
2280
2296
  if (!this.dataType.equals(w.JSON))
2281
2297
  throw new Error("cannot parse non-JSON series as JSON");
2282
- return this.toStrings().map((t) => e.parse(ie.decodeString(t)));
2298
+ return this.toStrings().map((t) => e.parse(ae.decodeString(t)));
2283
2299
  }
2284
2300
  /**
2285
2301
  * Returns the capacity of the series in bytes.
2286
2302
  * @returns The size of the underlying buffer in bytes.
2287
2303
  */
2288
2304
  get byteCapacity() {
2289
- return new ae(this.underlyingData.byteLength);
2305
+ return new oe(this.underlyingData.byteLength);
2290
2306
  }
2291
2307
  /**
2292
2308
  * Returns the capacity of the series in samples.
@@ -2302,7 +2318,7 @@ class M {
2302
2318
  * @returns The size of the data in bytes.
2303
2319
  */
2304
2320
  get byteLength() {
2305
- return this.writePos === $ ? this.byteCapacity : this.dataType.isVariable ? new ae(this.writePos) : this.dataType.density.size(this.writePos);
2321
+ return this.writePos === $ ? this.byteCapacity : this.dataType.isVariable ? new oe(this.writePos) : this.dataType.density.size(this.writePos);
2306
2322
  }
2307
2323
  /**
2308
2324
  * Returns the number of samples in this array.
@@ -2317,8 +2333,8 @@ class M {
2317
2333
  throw new Error("cannot calculate length of a non-variable length data type");
2318
2334
  let e = 0;
2319
2335
  const t = [0];
2320
- return this.data.forEach((r, i) => {
2321
- r === oe && (e++, t.push(i + 1));
2336
+ return this.data.forEach((n, i) => {
2337
+ n === ue && (e++, t.push(i + 1));
2322
2338
  }), this._cachedIndexes = t, this.cachedLength = e, e;
2323
2339
  }
2324
2340
  /**
@@ -2332,11 +2348,11 @@ class M {
2332
2348
  */
2333
2349
  convert(e, t = 0) {
2334
2350
  if (this.dataType.equals(e)) return this;
2335
- const r = new e.Array(this.length);
2351
+ const n = new e.Array(this.length);
2336
2352
  for (let i = 0; i < this.length; i++)
2337
- r[i] = Yt(this.dataType, e, this.data[i], t);
2353
+ n[i] = jt(this.dataType, e, this.data[i], t);
2338
2354
  return new M({
2339
- data: r.buffer,
2355
+ data: n.buffer,
2340
2356
  dataType: e,
2341
2357
  timeRange: this.timeRange,
2342
2358
  sampleOffset: t,
@@ -2350,10 +2366,10 @@ class M {
2350
2366
  this.cachedMax = this.data[this.data.length - 1];
2351
2367
  else if (this.dataType.usesBigInt) {
2352
2368
  const e = this.data;
2353
- this.cachedMax = e.reduce((t, r) => t > r ? t : r);
2369
+ this.cachedMax = e.reduce((t, n) => t > n ? t : n);
2354
2370
  } else {
2355
2371
  const e = this.data;
2356
- this.cachedMax = e.reduce((t, r) => t > r ? t : r);
2372
+ this.cachedMax = e.reduce((t, n) => t > n ? t : n);
2357
2373
  }
2358
2374
  return this.cachedMax;
2359
2375
  }
@@ -2364,17 +2380,17 @@ class M {
2364
2380
  calcMax() {
2365
2381
  if (this.dataType.isVariable)
2366
2382
  throw new Error("cannot calculate maximum on a variable length data type");
2367
- return this.writePos === 0 ? -1 / 0 : (this.cachedMax ??= this.calcRawMax(), J(this.cachedMax, this.sampleOffset));
2383
+ return this.writePos === 0 ? -1 / 0 : (this.cachedMax ??= this.calcRawMax(), H(this.cachedMax, this.sampleOffset));
2368
2384
  }
2369
2385
  calcRawMin() {
2370
2386
  if (this.length === 0) return 1 / 0;
2371
2387
  if (this.dataType.equals(w.TIMESTAMP)) this.cachedMin = this.data[0];
2372
2388
  else if (this.dataType.usesBigInt) {
2373
2389
  const e = this.data;
2374
- this.cachedMin = e.reduce((t, r) => t < r ? t : r);
2390
+ this.cachedMin = e.reduce((t, n) => t < n ? t : n);
2375
2391
  } else {
2376
2392
  const e = this.data;
2377
- this.cachedMin = e.reduce((t, r) => t < r ? t : r);
2393
+ this.cachedMin = e.reduce((t, n) => t < n ? t : n);
2378
2394
  }
2379
2395
  return this.cachedMin;
2380
2396
  }
@@ -2385,7 +2401,7 @@ class M {
2385
2401
  calcMin() {
2386
2402
  if (this.dataType.isVariable)
2387
2403
  throw new Error("cannot calculate minimum on a variable length data type");
2388
- return this.writePos === 0 ? 1 / 0 : (this.cachedMin ??= this.calcRawMin(), J(this.cachedMin, this.sampleOffset));
2404
+ return this.writePos === 0 ? 1 / 0 : (this.cachedMin ??= this.calcRawMin(), H(this.cachedMin, this.sampleOffset));
2389
2405
  }
2390
2406
  /** @returns the bounds of the series. */
2391
2407
  get bounds() {
@@ -2402,56 +2418,56 @@ class M {
2402
2418
  }
2403
2419
  }
2404
2420
  atAlignment(e, t) {
2405
- const r = Number((e - this.alignment) / this.alignmentMultiple);
2406
- if (r < 0 || r >= this.length) {
2407
- if (t === !0) throw new Error(`[series] - no value at index ${r}`);
2421
+ const n = Number((e - this.alignment) / this.alignmentMultiple);
2422
+ if (n < 0 || n >= this.length) {
2423
+ if (t === !0) throw new Error(`[series] - no value at index ${n}`);
2408
2424
  return;
2409
2425
  }
2410
- return this.at(r, t);
2426
+ return this.at(n, t);
2411
2427
  }
2412
2428
  at(e, t = !1) {
2413
2429
  if (this.dataType.isVariable) return this.atVariable(e, t ?? !1);
2414
2430
  if (this.dataType.equals(w.UUID)) return this.atUUID(e, t);
2415
2431
  e < 0 && (e = this.length + e);
2416
- const r = this.data[e];
2417
- if (r == null) {
2432
+ const n = this.data[e];
2433
+ if (n == null) {
2418
2434
  if (t === !0) throw new Error(`[series] - no value at index ${e}`);
2419
2435
  return;
2420
2436
  }
2421
- return J(r, this.sampleOffset);
2437
+ return H(n, this.sampleOffset);
2422
2438
  }
2423
2439
  atUUID(e, t) {
2424
2440
  e < 0 && (e = this.length + e);
2425
- const r = Pe(
2441
+ const n = ke(
2426
2442
  new Uint8Array(this.buffer, e * this.dataType.density.valueOf())
2427
2443
  );
2428
- if (r == null) {
2444
+ if (n == null) {
2429
2445
  if (t) throw new Error(`[series] - no value at index ${e}`);
2430
2446
  return;
2431
2447
  }
2432
- return r;
2448
+ return n;
2433
2449
  }
2434
2450
  atVariable(e, t) {
2435
- let r = 0, i = 0;
2451
+ let n = 0, i = 0;
2436
2452
  if (this._cachedIndexes != null)
2437
- r = this._cachedIndexes[e], i = this._cachedIndexes[e + 1] - 1;
2453
+ n = this._cachedIndexes[e], i = this._cachedIndexes[e + 1] - 1;
2438
2454
  else {
2439
2455
  e < 0 && (e = this.length + e);
2440
2456
  for (let c = 0; c < this.data.length; c++)
2441
- if (this.data[c] === oe) {
2457
+ if (this.data[c] === ue) {
2442
2458
  if (e === 0) {
2443
2459
  i = c;
2444
2460
  break;
2445
2461
  }
2446
- r = c + 1, e--;
2462
+ n = c + 1, e--;
2447
2463
  }
2448
- if (i === 0 && (i = this.data.length), r >= i || e > 0) {
2464
+ if (i === 0 && (i = this.data.length), n >= i || e > 0) {
2449
2465
  if (t) throw new Error(`[series] - no value at index ${e}`);
2450
2466
  return;
2451
2467
  }
2452
2468
  }
2453
- const a = this.data.slice(r, i);
2454
- return this.dataType.equals(w.STRING) ? new TextDecoder().decode(a) : Ne(JSON.parse(new TextDecoder().decode(a)));
2469
+ const a = this.data.slice(n, i);
2470
+ return this.dataType.equals(w.STRING) ? new TextDecoder().decode(a) : Ee(JSON.parse(new TextDecoder().decode(a)));
2455
2471
  }
2456
2472
  /**
2457
2473
  * @returns the index of the first sample that is greater than or equal to the given value.
@@ -2459,12 +2475,12 @@ class M {
2459
2475
  * @param value the value to search for.
2460
2476
  */
2461
2477
  binarySearch(e) {
2462
- let t = 0, r = this.length - 1;
2478
+ let t = 0, n = this.length - 1;
2463
2479
  const i = nt(e);
2464
- for (; t <= r; ) {
2465
- const a = Math.floor((t + r) / 2), c = i(this.at(a, !0), e);
2480
+ for (; t <= n; ) {
2481
+ const a = Math.floor((t + n) / 2), c = i(this.at(a, !0), e);
2466
2482
  if (c === 0) return a;
2467
- c < 0 ? t = a + 1 : r = a - 1;
2483
+ c < 0 ? t = a + 1 : n = a - 1;
2468
2484
  }
2469
2485
  return t;
2470
2486
  }
@@ -2478,7 +2494,7 @@ class M {
2478
2494
  updateGLBuffer(e) {
2479
2495
  if (this.gl.control = e, !this.dataType.equals(w.FLOAT32) && !this.dataType.equals(w.UINT8))
2480
2496
  throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");
2481
- const { buffer: t, bufferUsage: r, prevBuffer: i } = this.gl;
2497
+ const { buffer: t, bufferUsage: n, prevBuffer: i } = this.gl;
2482
2498
  if (t == null && (this.gl.buffer = e.createBuffer()), this.writePos !== i)
2483
2499
  if (e.bindBuffer(e.ARRAY_BUFFER, this.gl.buffer), this.writePos !== $) {
2484
2500
  i === 0 && e.bufferData(e.ARRAY_BUFFER, this.byteCapacity.valueOf(), e.STATIC_DRAW);
@@ -2488,11 +2504,11 @@ class M {
2488
2504
  e.bufferData(
2489
2505
  e.ARRAY_BUFFER,
2490
2506
  this.buffer,
2491
- r === "static" ? e.STATIC_DRAW : e.DYNAMIC_DRAW
2507
+ n === "static" ? e.STATIC_DRAW : e.DYNAMIC_DRAW
2492
2508
  ), this.gl.prevBuffer = $;
2493
2509
  }
2494
2510
  as(e) {
2495
- return zt(e, this.dataType), this;
2511
+ return Gt(e, this.dataType), this;
2496
2512
  }
2497
2513
  /** @returns a digest containing information about the series. */
2498
2514
  get digest() {
@@ -2501,8 +2517,8 @@ class M {
2501
2517
  dataType: this.dataType.toString(),
2502
2518
  sampleOffset: this.sampleOffset,
2503
2519
  alignment: {
2504
- lower: Ie(this.alignmentBounds.lower),
2505
- upper: Ie(this.alignmentBounds.upper)
2520
+ lower: Ne(this.alignmentBounds.lower),
2521
+ upper: Ne(this.alignmentBounds.upper)
2506
2522
  },
2507
2523
  timeRange: this.timeRange.toString(),
2508
2524
  length: this.length,
@@ -2539,10 +2555,10 @@ class M {
2539
2555
  }
2540
2556
  [Symbol.iterator]() {
2541
2557
  if (this.dataType.isVariable) {
2542
- const e = new Ht(this);
2543
- return this.dataType.equals(w.JSON) ? new Xt(e) : e;
2558
+ const e = new Xt(this);
2559
+ return this.dataType.equals(w.JSON) ? new Kt(e) : e;
2544
2560
  }
2545
- return this.dataType.equals(w.UUID) ? new Kt(this) : new Qt(this);
2561
+ return this.dataType.equals(w.UUID) ? new Qt(this) : new _t(this);
2546
2562
  }
2547
2563
  /**
2548
2564
  * Returns a slice of the series from start to end.
@@ -2569,7 +2585,7 @@ class M {
2569
2585
  * @returns An iterator over the specified range.
2570
2586
  */
2571
2587
  subIterator(e, t) {
2572
- return new ve(this, e, t ?? this.length);
2588
+ return new Ie(this, e, t ?? this.length);
2573
2589
  }
2574
2590
  /**
2575
2591
  * Returns an iterator over a portion of the series based on alignment.
@@ -2578,18 +2594,18 @@ class M {
2578
2594
  * @returns An iterator over the specified alignment range.
2579
2595
  */
2580
2596
  subAlignmentIterator(e, t) {
2581
- const r = Math.ceil(
2597
+ const n = Math.ceil(
2582
2598
  Number(e - this.alignment) / Number(this.alignmentMultiple)
2583
2599
  ), i = Math.ceil(
2584
2600
  Number(t - this.alignment) / Number(this.alignmentMultiple)
2585
2601
  );
2586
- return new ve(this, r, i);
2602
+ return new Ie(this, n, i);
2587
2603
  }
2588
2604
  subBytes(e, t) {
2589
2605
  if (e >= 0 && (t == null || t >= this.byteLength.valueOf())) return this;
2590
- const r = this.data.subarray(e, t);
2606
+ const n = this.data.subarray(e, t);
2591
2607
  return new M({
2592
- data: r,
2608
+ data: n,
2593
2609
  dataType: this.dataType,
2594
2610
  timeRange: this.timeRange,
2595
2611
  sampleOffset: this.sampleOffset,
@@ -2597,10 +2613,10 @@ class M {
2597
2613
  alignment: this.alignment + BigInt(e)
2598
2614
  });
2599
2615
  }
2600
- sliceSub(e, t, r) {
2601
- if (t <= 0 && (r == null || r >= this.length)) return this;
2616
+ sliceSub(e, t, n) {
2617
+ if (t <= 0 && (n == null || n >= this.length)) return this;
2602
2618
  let i;
2603
- return e ? i = this.data.subarray(t, r) : i = this.data.slice(t, r), new M({
2619
+ return e ? i = this.data.subarray(t, n) : i = this.data.slice(t, n), new M({
2604
2620
  data: i,
2605
2621
  dataType: this.dataType,
2606
2622
  timeRange: this.timeRange,
@@ -2618,7 +2634,7 @@ class M {
2618
2634
  return new M({
2619
2635
  data: this.buffer,
2620
2636
  dataType: this.dataType,
2621
- timeRange: S.ZERO,
2637
+ timeRange: F.ZERO,
2622
2638
  sampleOffset: this.sampleOffset,
2623
2639
  glBufferUsage: "static",
2624
2640
  alignment: e
@@ -2642,21 +2658,21 @@ class M {
2642
2658
  return e += "])", e;
2643
2659
  }
2644
2660
  }
2645
- const Gt = (n) => n == null ? !1 : Array.isArray(n) || n instanceof ArrayBuffer || ArrayBuffer.isView(n) && !(n instanceof DataView) || n instanceof M ? !0 : Le(n), Jt = Lt(ke, M);
2646
- class ve {
2661
+ const Jt = (r) => r == null ? !1 : Array.isArray(r) || r instanceof ArrayBuffer || ArrayBuffer.isView(r) && !(r instanceof DataView) || r instanceof M ? !0 : Pe(r), Ht = Pt(Ye, M);
2662
+ class Ie {
2647
2663
  series;
2648
2664
  end;
2649
2665
  index;
2650
- constructor(e, t, r) {
2666
+ constructor(e, t, n) {
2651
2667
  this.series = e;
2652
2668
  const i = R(0, e.length + 1);
2653
- this.end = we(i, r), this.index = we(i, t);
2669
+ this.end = be(i, n), this.index = be(i, t);
2654
2670
  }
2655
2671
  next() {
2656
2672
  return this.index >= this.end ? { done: !0, value: void 0 } : { done: !1, value: this.series.at(this.index++, !0) };
2657
2673
  }
2658
2674
  }
2659
- class Ht {
2675
+ class Xt {
2660
2676
  series;
2661
2677
  index;
2662
2678
  decoder;
@@ -2669,12 +2685,12 @@ class Ht {
2669
2685
  }
2670
2686
  next() {
2671
2687
  const e = this.index, t = this.series.data;
2672
- for (; this.index < t.length && t[this.index] !== oe; ) this.index++;
2673
- const r = this.index;
2674
- return e === r ? { done: !0, value: void 0 } : (this.index++, { done: !1, value: this.decoder.decode(this.series.buffer.slice(e, r)) });
2688
+ for (; this.index < t.length && t[this.index] !== ue; ) this.index++;
2689
+ const n = this.index;
2690
+ return e === n ? { done: !0, value: void 0 } : (this.index++, { done: !1, value: this.decoder.decode(this.series.buffer.slice(e, n)) });
2675
2691
  }
2676
2692
  }
2677
- let Xt = class Ye {
2693
+ let Kt = class je {
2678
2694
  wrapped;
2679
2695
  static schema = s.record(s.string(), s.unknown());
2680
2696
  constructor(e) {
@@ -2684,11 +2700,11 @@ let Xt = class Ye {
2684
2700
  const e = this.wrapped.next();
2685
2701
  return e.done === !0 ? { done: !0, value: void 0 } : {
2686
2702
  done: !1,
2687
- value: ie.decodeString(e.value, Ye.schema)
2703
+ value: ae.decodeString(e.value, je.schema)
2688
2704
  };
2689
2705
  }
2690
2706
  };
2691
- class Kt {
2707
+ class Qt {
2692
2708
  series;
2693
2709
  index;
2694
2710
  data;
@@ -2700,11 +2716,11 @@ class Kt {
2700
2716
  }
2701
2717
  next() {
2702
2718
  if (this.index >= this.series.length) return { done: !0, value: void 0 };
2703
- const e = Pe(this.data, this.index * this.density);
2719
+ const e = ke(this.data, this.index * this.density);
2704
2720
  return this.index++, { done: !1, value: e };
2705
2721
  }
2706
2722
  }
2707
- let Qt = class {
2723
+ let _t = class {
2708
2724
  series;
2709
2725
  index;
2710
2726
  constructor(e) {
@@ -2717,8 +2733,8 @@ let Qt = class {
2717
2733
  };
2718
2734
  }
2719
2735
  };
2720
- const Ie = (n) => {
2721
- const e = n >> 32n, t = n & 0xffffffffn;
2736
+ const Ne = (r) => {
2737
+ const e = r >> 32n, t = r & 0xffffffffn;
2722
2738
  return { domain: e, sample: t };
2723
2739
  };
2724
2740
  s.object({ key: s.string(), value: s.string() });
@@ -2726,18 +2742,18 @@ s.record(
2726
2742
  s.union([s.number(), s.string(), s.symbol()]),
2727
2743
  s.unknown()
2728
2744
  );
2729
- const _t = () => typeof process < "u" && process.versions != null && process.versions.node != null ? "node" : typeof window > "u" || window.document === void 0 ? "webworker" : "browser";
2730
- _t();
2731
- const en = ["macOS", "Windows", "Linux"], tn = ["macos", "windows", "linux"], nn = {
2745
+ const er = () => typeof process < "u" && process.versions != null && process.versions.node != null ? "node" : typeof window > "u" || window.document === void 0 ? "webworker" : "browser";
2746
+ er();
2747
+ const tr = ["macOS", "Windows", "Linux"], rr = ["macos", "windows", "linux"], nr = {
2732
2748
  macos: "macOS",
2733
2749
  windows: "Windows",
2734
2750
  linux: "Linux"
2735
2751
  };
2736
- s.enum(en).or(
2737
- s.enum(tn).transform((n) => nn[n])
2752
+ s.enum(tr).or(
2753
+ s.enum(rr).transform((r) => nr[r])
2738
2754
  );
2739
- const rn = (...n) => n.map(je).join(""), je = (n) => (n.endsWith("/") || (n += "/"), n.startsWith("/") && (n = n.slice(1)), n), sn = (n) => n.endsWith("/") ? n.slice(0, -1) : n, an = (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("&")}`;
2740
- class W {
2755
+ const sr = (...r) => r.map(qe).join(""), qe = (r) => (r.endsWith("/") || (r += "/"), r.startsWith("/") && (r = r.slice(1)), r), ir = (r) => r.endsWith("/") ? r.slice(0, -1) : r, ar = (r, e = "") => r === null ? "" : `?${Object.entries(r).filter(([, t]) => t == null ? !1 : Array.isArray(t) ? t.length > 0 : !0).map(([t, n]) => `${e}${t}=${n}`).join("&")}`;
2756
+ class Z {
2741
2757
  protocol;
2742
2758
  host;
2743
2759
  port;
@@ -2748,8 +2764,8 @@ class W {
2748
2764
  * @param protocol - The protocol to use for all requests. Defaults to "".
2749
2765
  * @param pathPrefix - A path prefix to use for all requests. Defaults to "".
2750
2766
  */
2751
- constructor({ host: e, port: t, protocol: r = "", pathPrefix: i = "" }) {
2752
- this.protocol = r, this.host = e, this.port = t, this.path = je(i);
2767
+ constructor({ host: e, port: t, protocol: n = "", pathPrefix: i = "" }) {
2768
+ this.protocol = n, this.host = e, this.port = t, this.path = qe(i);
2753
2769
  }
2754
2770
  /**
2755
2771
  * Replaces creates a new URL with the specified properties replaced.
@@ -2757,7 +2773,7 @@ class W {
2757
2773
  * @returns a new URL.
2758
2774
  */
2759
2775
  replace(e) {
2760
- return new W({
2776
+ return new Z({
2761
2777
  host: e.host ?? this.host,
2762
2778
  port: e.port ?? this.port,
2763
2779
  protocol: e.protocol ?? this.protocol,
@@ -2770,23 +2786,23 @@ class W {
2770
2786
  * @returns a new URL.
2771
2787
  */
2772
2788
  child(e) {
2773
- return new W({
2789
+ return new Z({
2774
2790
  ...this,
2775
- pathPrefix: rn(this.path, e)
2791
+ pathPrefix: sr(this.path, e)
2776
2792
  });
2777
2793
  }
2778
2794
  /** @returns a string representation of the url */
2779
2795
  toString() {
2780
- return sn(
2796
+ return ir(
2781
2797
  `${this.protocol}://${this.host}:${this.port}/${this.path}`
2782
2798
  );
2783
2799
  }
2784
- static UNKNOWN = new W({ host: "unknown", port: 0 });
2800
+ static UNKNOWN = new Z({ host: "unknown", port: 0 });
2785
2801
  }
2786
- const on = async (n) => await new Promise(
2787
- (e) => setTimeout(e, g.fromMilliseconds(n).milliseconds)
2802
+ const or = async (r) => await new Promise(
2803
+ (e) => setTimeout(e, g.fromMilliseconds(r).milliseconds)
2788
2804
  );
2789
- class un {
2805
+ class ur {
2790
2806
  config;
2791
2807
  retries;
2792
2808
  interval;
@@ -2795,12 +2811,12 @@ class un {
2795
2811
  baseInterval: new g(e?.baseInterval ?? g.seconds(1)),
2796
2812
  maxRetries: e?.maxRetries ?? 5,
2797
2813
  scale: e?.scale ?? 1,
2798
- sleepFn: e?.sleepFn ?? on
2814
+ sleepFn: e?.sleepFn ?? or
2799
2815
  }, this.retries = 0, this.interval = new g(this.config.baseInterval);
2800
2816
  }
2801
2817
  async wait() {
2802
- const { maxRetries: e, scale: t, sleepFn: r } = this.config;
2803
- return this.retries >= e ? !1 : (await r(this.interval), this.interval = this.interval.mult(t), this.retries++, !0);
2818
+ const { maxRetries: e, scale: t, sleepFn: n } = this.config;
2819
+ return this.retries >= e ? !1 : (await n(this.interval), this.interval = this.interval.mult(t), this.retries++, !0);
2804
2820
  }
2805
2821
  get retryMessage() {
2806
2822
  return `breaker triggered ${this.retries + 1}/${this.config.maxRetries} times, retrying in ${this.interval.toString()}`;
@@ -2809,93 +2825,93 @@ class un {
2809
2825
  this.retries = 0, this.interval = this.config.baseInterval;
2810
2826
  }
2811
2827
  }
2812
- const ln = s.object({
2828
+ const lr = s.object({
2813
2829
  baseInterval: g.z.optional(),
2814
2830
  maxRetries: s.number().optional(),
2815
2831
  scale: s.number().optional()
2816
- }), cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2832
+ }), cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2817
2833
  __proto__: null,
2818
- Breaker: un,
2819
- breakerConfigZ: ln
2820
- }, Symbol.toStringTag, { value: "Module" })), hn = /^#?([0-9a-f]{6}|[0-9a-f]{8})$/i, qe = s.string().regex(hn), P = s.number().min(0).max(255), Fe = s.number().min(0).max(1), We = s.tuple([P, P, P, Fe]), fn = s.tuple([P, P, P]), dn = s.object({ rgba255: We }), gn = s.number().min(0).max(360), pn = s.number().min(0).max(100), mn = s.number().min(0).max(100), yn = s.tuple([gn, pn, mn, Fe]), fe = s.union([qe, fn, We, yn, dn]), wn = fe.transform((n) => de(n)), de = (n, e = 1) => {
2821
- if (n = fe.parse(n), typeof n == "string") return bn(n, e);
2822
- if (Array.isArray(n)) {
2823
- if (n.length < 3 || n.length > 4)
2824
- throw new Error(`Invalid color: [${n.join(", ")}]`);
2825
- return n.length === 3 ? [...n, e] : n;
2826
- }
2827
- return n.rgba255;
2828
- }, bn = (n, e = 1) => (n = qe.parse(n), n = On(n), [
2829
- G(n, 0),
2830
- G(n, 2),
2831
- G(n, 4),
2832
- n.length === 8 ? G(n, 6) / 255 : e
2833
- ]), G = (n, e) => parseInt(n.slice(e, e + 2), 16), On = (n) => n.startsWith("#") ? n.slice(1) : n;
2834
- de("#000000");
2835
- de("#ffffff");
2836
- const Tn = s.object({
2834
+ Breaker: ur,
2835
+ breakerConfigZ: lr
2836
+ }, Symbol.toStringTag, { value: "Module" })), hr = /^#?([0-9a-f]{6}|[0-9a-f]{8})$/i, Fe = s.string().regex(hr), P = s.number().min(0).max(255), We = s.number().min(0).max(1), Ze = s.tuple([P, P, P, We]), fr = s.tuple([P, P, P]), dr = s.object({ rgba255: Ze }), gr = s.number().min(0).max(360), pr = s.number().min(0).max(100), mr = s.number().min(0).max(100), yr = s.tuple([gr, pr, mr, We]), de = s.union([Fe, fr, Ze, yr, dr]), wr = de.transform((r) => ge(r)), ge = (r, e = 1) => {
2837
+ if (r = de.parse(r), typeof r == "string") return br(r, e);
2838
+ if (Array.isArray(r)) {
2839
+ if (r.length < 3 || r.length > 4)
2840
+ throw new Error(`Invalid color: [${r.join(", ")}]`);
2841
+ return r.length === 3 ? [...r, e] : r;
2842
+ }
2843
+ return r.rgba255;
2844
+ }, br = (r, e = 1) => (r = Fe.parse(r), r = Or(r), [
2845
+ J(r, 0),
2846
+ J(r, 2),
2847
+ J(r, 4),
2848
+ r.length === 8 ? J(r, 6) / 255 : e
2849
+ ]), J = (r, e) => parseInt(r.slice(e, e + 2), 16), Or = (r) => r.startsWith("#") ? r.slice(1) : r;
2850
+ ge("#000000");
2851
+ ge("#ffffff");
2852
+ const Tr = s.object({
2837
2853
  key: s.string(),
2838
- color: fe,
2854
+ color: de,
2839
2855
  position: s.number(),
2840
2856
  switched: s.boolean().optional()
2841
2857
  });
2842
- s.array(Tn);
2843
- const vn = s.object({
2858
+ s.array(Tr);
2859
+ const vr = s.object({
2844
2860
  key: s.string(),
2845
2861
  name: s.string(),
2846
- color: wn
2862
+ color: wr
2847
2863
  });
2848
2864
  s.object({
2849
2865
  key: s.string(),
2850
2866
  name: s.string(),
2851
- swatches: s.array(vn)
2867
+ swatches: s.array(vr)
2852
2868
  });
2853
2869
  s.int().min(0).max(255);
2854
2870
  s.object({
2855
2871
  name: s.string(),
2856
2872
  key: s.string()
2857
2873
  });
2858
- const In = (n) => Object.getOwnPropertySymbols(globalThis).includes(n), Sn = (n, e) => {
2859
- const t = Symbol.for(n);
2860
- if (!In(t)) {
2861
- const r = e();
2862
- Object.defineProperty(globalThis, t, { value: r });
2874
+ const Ir = (r) => Object.getOwnPropertySymbols(globalThis).includes(r), Nr = (r, e) => {
2875
+ const t = Symbol.for(r);
2876
+ if (!Ir(t)) {
2877
+ const n = e();
2878
+ Object.defineProperty(globalThis, t, { value: n });
2863
2879
  }
2864
2880
  return () => globalThis[t];
2865
- }, Ze = "sy_x_error", Nn = (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 F extends Error {
2866
- static discriminator = Ze;
2867
- discriminator = F.discriminator;
2868
- static TYPE = n;
2869
- type = F.TYPE;
2870
- static matches = Nn(n);
2871
- matches = F.matches;
2872
- constructor(t, r) {
2873
- super(t, r), this.name = F.TYPE;
2881
+ }, Ve = "sy_x_error", Sr = (r) => (e) => e != null && typeof e == "object" && "type" in e && typeof e.type == "string" ? e.type.startsWith(r) : e instanceof Error ? e.message.startsWith(r) : typeof e != "string" ? !1 : e.startsWith(r), V = (r) => class W extends Error {
2882
+ static discriminator = Ve;
2883
+ discriminator = W.discriminator;
2884
+ static TYPE = r;
2885
+ type = W.TYPE;
2886
+ static matches = Sr(r);
2887
+ matches = W.matches;
2888
+ constructor(t, n) {
2889
+ super(t, n), this.name = W.TYPE;
2874
2890
  }
2875
2891
  static sub(t) {
2876
- return Z(`${n}.${t}`);
2892
+ return V(`${r}.${t}`);
2877
2893
  }
2878
- }, Ve = (n) => {
2879
- if (n == null || typeof n != "object") return !1;
2880
- const e = n;
2881
- if (e.discriminator !== Ze) return !1;
2894
+ }, ze = (r) => {
2895
+ if (r == null || typeof r != "object") return !1;
2896
+ const e = r;
2897
+ if (e.discriminator !== Ve) return !1;
2882
2898
  if (!("type" in e))
2883
2899
  throw new Error(
2884
2900
  `X Error is missing its type property: ${JSON.stringify(e)}`
2885
2901
  );
2886
2902
  return !0;
2887
- }, L = "unknown", ue = "nil";
2888
- class En {
2903
+ }, L = "unknown", le = "nil";
2904
+ class Er {
2889
2905
  providers = [];
2890
2906
  register(e) {
2891
2907
  this.providers.push(e);
2892
2908
  }
2893
2909
  encode(e) {
2894
- if (e == null) return { type: ue, data: "" };
2895
- if (Ve(e))
2910
+ if (e == null) return { type: le, data: "" };
2911
+ if (ze(e))
2896
2912
  for (const t of this.providers) {
2897
- const r = t.encode(e);
2898
- if (r != null) return r;
2913
+ const n = t.encode(e);
2914
+ if (n != null) return n;
2899
2915
  }
2900
2916
  if (e instanceof Error) return { type: L, data: e.message };
2901
2917
  if (typeof e == "string") return { type: L, data: e };
@@ -2906,37 +2922,37 @@ class En {
2906
2922
  }
2907
2923
  }
2908
2924
  decode(e) {
2909
- if (e == null || e.type === ue) return null;
2910
- if (e.type === L) return new le(e.data);
2925
+ if (e == null || e.type === le) return null;
2926
+ if (e.type === L) return new ce(e.data);
2911
2927
  for (const t of this.providers) {
2912
- const r = t.decode(e);
2913
- if (r != null) return r;
2928
+ const n = t.decode(e);
2929
+ if (n != null) return n;
2914
2930
  }
2915
- return new le(e.data);
2931
+ return new ce(e.data);
2916
2932
  }
2917
2933
  }
2918
- const ge = Sn("synnax-error-registry", () => new En()), xn = ({ encode: n, decode: e }) => ge().register({ encode: n, decode: e }), An = (n) => ge().encode(n), Un = (n) => n == null ? null : ge().decode(n);
2919
- class le extends Z("unknown") {
2934
+ const pe = Nr("synnax-error-registry", () => new Er()), xr = ({ encode: r, decode: e }) => pe().register({ encode: r, decode: e }), Ar = (r) => pe().encode(r), Ur = (r) => r == null ? null : pe().decode(r);
2935
+ class ce extends V("unknown") {
2920
2936
  }
2921
- const Mn = s.object({ type: s.string(), data: s.string() });
2922
- class Cn extends Z("canceled") {
2937
+ const Mr = s.object({ type: s.string(), data: s.string() });
2938
+ class Cr extends V("canceled") {
2923
2939
  }
2924
- class $n extends Z("not_implemented") {
2940
+ class $r extends V("not_implemented") {
2925
2941
  }
2926
2942
  const B = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2927
2943
  __proto__: null,
2928
- Canceled: Cn,
2929
- NONE: ue,
2930
- NotImplemented: $n,
2944
+ Canceled: Cr,
2945
+ NONE: le,
2946
+ NotImplemented: $r,
2931
2947
  UNKNOWN: L,
2932
- Unknown: le,
2933
- createTyped: Z,
2934
- decode: Un,
2935
- encode: An,
2936
- isTyped: Ve,
2937
- payloadZ: Mn,
2938
- register: xn
2939
- }, Symbol.toStringTag, { value: "Module" })), Bn = O.object({
2948
+ Unknown: ce,
2949
+ createTyped: V,
2950
+ decode: Ur,
2951
+ encode: Ar,
2952
+ isTyped: ze,
2953
+ payloadZ: Mr,
2954
+ register: xr
2955
+ }, Symbol.toStringTag, { value: "Module" })), Br = O.object({
2940
2956
  jsonrpc: O.literal("2.0"),
2941
2957
  method: O.string(),
2942
2958
  // params should be z.union([z.record(z.string(), z.json()),
@@ -2944,12 +2960,12 @@ const B = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2944
2960
  // definition of params then in the JSON-RPC spec.
2945
2961
  params: O.any().optional(),
2946
2962
  id: O.union([O.string(), O.number(), O.null()]).optional()
2947
- }), ze = O.object({
2963
+ }), Ge = O.object({
2948
2964
  jsonrpc: O.literal("2.0"),
2949
2965
  id: O.union([O.string(), O.number(), O.null()])
2950
- }), Rn = ze.extend({
2966
+ }), Rr = Ge.extend({
2951
2967
  result: O.json()
2952
- }), Dn = ze.extend({
2968
+ }), Dr = Ge.extend({
2953
2969
  error: O.object({
2954
2970
  code: O.number().int(),
2955
2971
  // This should be z.string(), but the VSCode JSON RPC implementation uses a looser
@@ -2957,11 +2973,11 @@ const B = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2957
2973
  message: O.string().optional(),
2958
2974
  data: O.json().optional()
2959
2975
  })
2960
- }), Ln = O.union([Rn, Dn]);
2961
- O.union([Bn, Ln]);
2976
+ }), Lr = O.union([Rr, Dr]);
2977
+ O.union([Br, Lr]);
2962
2978
  s.string().regex(/^\d+\.\d+\.\d+$/);
2963
- const Pn = ["standard", "scientific", "engineering"];
2964
- s.enum(Pn);
2979
+ const Pr = ["standard", "scientific", "engineering"];
2980
+ s.enum(Pr);
2965
2981
  s.enum([
2966
2982
  "success",
2967
2983
  "info",
@@ -2970,36 +2986,36 @@ s.enum([
2970
2986
  "loading",
2971
2987
  "disabled"
2972
2988
  ]);
2973
- class V extends B.createTyped("freighter") {
2989
+ class z extends B.createTyped("freighter") {
2974
2990
  }
2975
- class k extends V.sub("eof") {
2991
+ class k extends z.sub("eof") {
2976
2992
  constructor() {
2977
2993
  super("EOF");
2978
2994
  }
2979
2995
  }
2980
- class Y extends V.sub("stream_closed") {
2996
+ class Y extends z.sub("stream_closed") {
2981
2997
  constructor() {
2982
2998
  super("StreamClosed");
2983
2999
  }
2984
3000
  }
2985
- class j extends V.sub("unreachable") {
3001
+ class j extends z.sub("unreachable") {
2986
3002
  url;
2987
3003
  constructor(e = {}) {
2988
- const { message: t = "Unreachable", url: r = W.UNKNOWN } = e;
2989
- super(t), this.url = r;
3004
+ const { message: t = "Unreachable", url: n = Z.UNKNOWN } = e;
3005
+ super(t), this.url = n;
2990
3006
  }
2991
3007
  }
2992
- const kn = (n) => {
2993
- if (!n.type.startsWith(V.TYPE)) return null;
2994
- if (k.matches(n)) return { type: k.TYPE, data: "EOF" };
2995
- if (Y.matches(n))
3008
+ const kr = (r) => {
3009
+ if (!r.type.startsWith(z.TYPE)) return null;
3010
+ if (k.matches(r)) return { type: k.TYPE, data: "EOF" };
3011
+ if (Y.matches(r))
2996
3012
  return { type: Y.TYPE, data: "StreamClosed" };
2997
- if (j.matches(n))
3013
+ if (j.matches(r))
2998
3014
  return { type: j.TYPE, data: "Unreachable" };
2999
- throw new Error(`Unknown error type: ${n.type}: ${n.message}`);
3000
- }, Yn = (n) => {
3001
- if (!n.type.startsWith(V.TYPE)) return null;
3002
- switch (n.type) {
3015
+ throw new Error(`Unknown error type: ${r.type}: ${r.message}`);
3016
+ }, Yr = (r) => {
3017
+ if (!r.type.startsWith(z.TYPE)) return null;
3018
+ switch (r.type) {
3003
3019
  case k.TYPE:
3004
3020
  return new k();
3005
3021
  case Y.TYPE:
@@ -3007,14 +3023,14 @@ const kn = (n) => {
3007
3023
  case j.TYPE:
3008
3024
  return new j();
3009
3025
  default:
3010
- throw new B.Unknown(`Unknown error type: ${n.data}`);
3026
+ throw new B.Unknown(`Unknown error type: ${r.data}`);
3011
3027
  }
3012
3028
  };
3013
3029
  B.register({
3014
- encode: kn,
3015
- decode: Yn
3030
+ encode: kr,
3031
+ decode: Yr
3016
3032
  });
3017
- class Ge {
3033
+ class Je {
3018
3034
  middleware = [];
3019
3035
  /** Implements the Transport interface */
3020
3036
  use(...e) {
@@ -3030,47 +3046,47 @@ class Ge {
3030
3046
  * @returns An error if one was encountered, otherwise undefined.
3031
3047
  */
3032
3048
  async executeMiddleware(e, t) {
3033
- let r = 0;
3049
+ let n = 0;
3034
3050
  const i = async (a) => {
3035
- if (r === this.middleware.length) return await t(a);
3036
- const c = this.middleware[r];
3037
- return r++, await c(a, i);
3051
+ if (n === this.middleware.length) return await t(a);
3052
+ const c = this.middleware[n];
3053
+ return n++, await c(a, i);
3038
3054
  };
3039
3055
  return await i(e);
3040
3056
  }
3041
3057
  }
3042
- const Je = "Content-Type", jn = /* @__PURE__ */ new Set([
3058
+ const He = "Content-Type", jr = /* @__PURE__ */ new Set([
3043
3059
  "ECONNREFUSED",
3044
3060
  "ECONNRESET",
3045
3061
  "ETIMEDOUT",
3046
3062
  "EPIPE",
3047
3063
  "UND_ERR_CONNECT_TIMEOUT",
3048
3064
  "UND_ERR_SOCKET"
3049
- ]), qn = (n) => {
3050
- const e = n?.cause?.code ?? n?.code ?? n?.errno;
3051
- if (typeof e == "string" && jn.has(e)) return !0;
3052
- if (n.name === "TypeError") {
3053
- const t = String(n.message || "").toLowerCase();
3065
+ ]), qr = (r) => {
3066
+ const e = r?.cause?.code ?? r?.code ?? r?.errno;
3067
+ if (typeof e == "string" && jr.has(e)) return !0;
3068
+ if (r.name === "TypeError") {
3069
+ const t = String(r.message || "").toLowerCase();
3054
3070
  if (/load failed|failed to fetch|networkerror|network error/.test(t))
3055
3071
  return typeof navigator < "u" && navigator.onLine === !1, !0;
3056
3072
  }
3057
- return n?.name === "AbortError" || n?.code === "ABORT_ERR", !1;
3058
- }, Fn = 400;
3059
- class Kn extends Ge {
3073
+ return r?.name === "AbortError" || r?.code === "ABORT_ERR", !1;
3074
+ }, Fr = 400;
3075
+ class Qr extends Je {
3060
3076
  endpoint;
3061
3077
  encoder;
3062
- constructor(e, t, r = !1) {
3063
- return super(), this.endpoint = e.replace({ protocol: r ? "https" : "http" }), this.encoder = t, new Proxy(this, {
3078
+ constructor(e, t, n = !1) {
3079
+ return super(), this.endpoint = e.replace({ protocol: n ? "https" : "http" }), this.encoder = t, new Proxy(this, {
3064
3080
  get: (i, a, c) => a === "endpoint" ? this.endpoint : Reflect.get(i, a, c)
3065
3081
  });
3066
3082
  }
3067
3083
  get headers() {
3068
3084
  return {
3069
- [Je]: this.encoder.contentType
3085
+ [He]: this.encoder.contentType
3070
3086
  };
3071
3087
  }
3072
- async send(e, t, r, i) {
3073
- t = r?.parse(t);
3088
+ async send(e, t, n, i) {
3089
+ t = n?.parse(t);
3074
3090
  let a = null;
3075
3091
  const c = this.endpoint.child(e), d = {};
3076
3092
  d.method = "POST", d.body = this.encoder.encode(t ?? {});
@@ -3092,13 +3108,13 @@ class Kn extends Ge {
3092
3108
  b = await fetch(f.target, d);
3093
3109
  } catch (T) {
3094
3110
  if (!(T instanceof Error)) throw T;
3095
- return [p, qn(T) ? new j({ url: c }) : T];
3111
+ return [p, qr(T) ? new j({ url: c }) : T];
3096
3112
  }
3097
3113
  const h = await b.arrayBuffer();
3098
3114
  if (b?.ok)
3099
3115
  return i != null && (a = this.encoder.decode(h, i)), [p, null];
3100
3116
  try {
3101
- if (b.status !== Fn)
3117
+ if (b.status !== Fr)
3102
3118
  return [p, new Error(b.statusText)];
3103
3119
  const T = this.encoder.decode(h, B.payloadZ), x = B.decode(T);
3104
3120
  return [p, x];
@@ -3117,7 +3133,7 @@ class Kn extends Ge {
3117
3133
  return [a, null];
3118
3134
  }
3119
3135
  }
3120
- const Qn = (n, e) => {
3136
+ const _r = (r, e) => {
3121
3137
  class t {
3122
3138
  wrapped;
3123
3139
  constructor(i) {
@@ -3127,7 +3143,7 @@ const Qn = (n, e) => {
3127
3143
  this.wrapped.use(...i);
3128
3144
  }
3129
3145
  async send(i, a, c, d) {
3130
- const y = new cn.Breaker(e);
3146
+ const y = new cr.Breaker(e);
3131
3147
  do {
3132
3148
  const [f, p] = await this.wrapped.send(i, a, c, d);
3133
3149
  if (p == null) return [f, null];
@@ -3136,17 +3152,17 @@ const Qn = (n, e) => {
3136
3152
  } while (!0);
3137
3153
  }
3138
3154
  }
3139
- return new t(n);
3140
- }, _n = async (n, e, t, r, i) => {
3141
- const [a, c] = await n.send(e, t, r, i);
3155
+ return new t(r);
3156
+ }, en = async (r, e, t, n, i) => {
3157
+ const [a, c] = await r.send(e, t, n, i);
3142
3158
  if (c != null) throw c;
3143
3159
  return a;
3144
- }, Wn = s.object({
3160
+ }, Wr = s.object({
3145
3161
  type: s.enum(["data", "close", "open"]),
3146
3162
  payload: s.unknown(),
3147
3163
  error: s.optional(B.payloadZ)
3148
3164
  });
3149
- class Zn {
3165
+ class Zr {
3150
3166
  codec;
3151
3167
  reqSchema;
3152
3168
  resSchema;
@@ -3155,8 +3171,8 @@ class Zn {
3155
3171
  sendClosed;
3156
3172
  receiveDataQueue = [];
3157
3173
  receiveCallbacksQueue = [];
3158
- constructor(e, t, r, i) {
3159
- this.codec = t, this.reqSchema = r, this.resSchema = i, this.ws = e, this.sendClosed = !1, this.serverClosed = null, this.listenForMessages();
3174
+ constructor(e, t, n, i) {
3175
+ this.codec = t, this.reqSchema = n, this.resSchema = i, this.ws = e, this.sendClosed = !1, this.serverClosed = null, this.listenForMessages();
3160
3176
  }
3161
3177
  async receiveOpenAck() {
3162
3178
  const e = await this.receiveMsg();
@@ -3200,7 +3216,7 @@ class Zn {
3200
3216
  async receiveMsg() {
3201
3217
  const e = this.receiveDataQueue.shift();
3202
3218
  return e ?? await new Promise(
3203
- (t, r) => this.receiveCallbacksQueue.push({ resolve: t, reject: r })
3219
+ (t, n) => this.receiveCallbacksQueue.push({ resolve: t, reject: n })
3204
3220
  );
3205
3221
  }
3206
3222
  addMessage(e) {
@@ -3211,20 +3227,20 @@ class Zn {
3211
3227
  this.ws.onmessage = this.onMessage.bind(this), this.ws.onclose = this.onClose.bind(this);
3212
3228
  }
3213
3229
  onMessage(e) {
3214
- this.addMessage(this.codec.decode(e.data, Wn));
3230
+ this.addMessage(this.codec.decode(e.data, Wr));
3215
3231
  }
3216
3232
  onClose(e) {
3217
3233
  this.addMessage({
3218
3234
  type: "close",
3219
3235
  error: {
3220
- type: e.code === zn ? k.TYPE : Y.TYPE,
3236
+ type: e.code === zr ? k.TYPE : Y.TYPE,
3221
3237
  data: ""
3222
3238
  }
3223
3239
  });
3224
3240
  }
3225
3241
  }
3226
- const Vn = "freighterctx", zn = 1e3;
3227
- class ce extends Ge {
3242
+ const Vr = "freighterctx", zr = 1e3;
3243
+ class he extends Je {
3228
3244
  baseUrl;
3229
3245
  encoder;
3230
3246
  secure;
@@ -3234,22 +3250,22 @@ class ce extends Ge {
3234
3250
  * responses.
3235
3251
  * @param baseEndpoint - A base url to use as a prefix for all requests.
3236
3252
  */
3237
- constructor(e, t, r = !1) {
3238
- super(), this.secure = r, this.baseUrl = e.replace({ protocol: r ? "wss" : "ws" }), this.encoder = t;
3253
+ constructor(e, t, n = !1) {
3254
+ super(), this.secure = n, this.baseUrl = e.replace({ protocol: n ? "wss" : "ws" }), this.encoder = t;
3239
3255
  }
3240
3256
  withCodec(e) {
3241
- const t = new ce(this.baseUrl, e, this.secure);
3257
+ const t = new he(this.baseUrl, e, this.secure);
3242
3258
  return t.use(...this.middleware), t;
3243
3259
  }
3244
3260
  /** Implements the StreamClient interface. */
3245
- async stream(e, t, r) {
3261
+ async stream(e, t, n) {
3246
3262
  let i;
3247
3263
  const [, a] = await this.executeMiddleware(
3248
3264
  { target: e, protocol: "websocket", params: {}, role: "client" },
3249
3265
  async (c) => {
3250
3266
  const d = new WebSocket(this.buildURL(e, c)), y = { ...c, params: {} };
3251
- d.binaryType = ce.MESSAGE_TYPE;
3252
- const f = await this.wrapSocket(d, t, r);
3267
+ d.binaryType = he.MESSAGE_TYPE;
3268
+ const f = await this.wrapSocket(d, t, n);
3253
3269
  return f instanceof Error ? [y, f] : (i = f, [y, null]);
3254
3270
  }
3255
3271
  );
@@ -3257,19 +3273,19 @@ class ce extends Ge {
3257
3273
  return i;
3258
3274
  }
3259
3275
  buildURL(e, t) {
3260
- const r = an(
3276
+ const n = ar(
3261
3277
  {
3262
- [Je]: this.encoder.contentType,
3278
+ [He]: this.encoder.contentType,
3263
3279
  ...t.params
3264
3280
  },
3265
- Vn
3281
+ Vr
3266
3282
  );
3267
- return this.baseUrl.child(e).toString() + r;
3283
+ return this.baseUrl.child(e).toString() + n;
3268
3284
  }
3269
- async wrapSocket(e, t, r) {
3285
+ async wrapSocket(e, t, n) {
3270
3286
  return await new Promise((i) => {
3271
3287
  e.onopen = () => {
3272
- const a = new Zn(e, this.encoder, t, r);
3288
+ const a = new Zr(e, this.encoder, t, n);
3273
3289
  a.receiveOpenAck().then((c) => {
3274
3290
  c != null ? i(c) : i(a);
3275
3291
  }).catch((c) => i(c));
@@ -3282,10 +3298,10 @@ class ce extends Ge {
3282
3298
  }
3283
3299
  export {
3284
3300
  k as EOF,
3285
- Kn as HTTPClient,
3301
+ Qr as HTTPClient,
3286
3302
  Y as StreamClosed,
3287
3303
  j as Unreachable,
3288
- ce as WebSocketClient,
3289
- _n as sendRequired,
3290
- Qn as unaryWithBreaker
3304
+ he as WebSocketClient,
3305
+ en as sendRequired,
3306
+ _r as unaryWithBreaker
3291
3307
  };