@synnaxlabs/freighter 0.55.0 → 0.56.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/freighter.js CHANGED
@@ -26,6 +26,7 @@ var n = Object.defineProperty, r = (e, t) => {
26
26
  if (e == null) return;
27
27
  let t = e._zod?.def;
28
28
  if (t?.type === "array" && t.element != null) return t.element;
29
+ if (t?.innerType != null) return c(t.innerType);
29
30
  if (t?.type === "union" && Array.isArray(t.options)) for (let e of t.options) {
30
31
  let t = c(e);
31
32
  if (t != null) return t;
@@ -41,9 +42,14 @@ var n = Object.defineProperty, r = (e, t) => {
41
42
  let n = t._zod?.def;
42
43
  if (n == null) return null;
43
44
  if (n.innerType != null) return l(n.innerType);
44
- if (n.type === "union" && Array.isArray(n.options)) for (let e of n.options) {
45
- let t = l(e);
46
- if (t != null) return t;
45
+ if (n.type === "union" && Array.isArray(n.options)) {
46
+ let e = null;
47
+ for (let t of n.options) {
48
+ let n = l(t);
49
+ if (n != null) if (e == null) e = { ...n };
50
+ else for (let t in n) t in e || (e[t] = n[t]);
51
+ }
52
+ return e;
47
53
  }
48
54
  return n.type === "pipe" ? l(n.in) ?? l(n.out) : null;
49
55
  }, u = (e) => {
@@ -155,17 +161,17 @@ var n = Object.defineProperty, r = (e, t) => {
155
161
  }
156
162
  return () => globalThis[n];
157
163
  }, v = /* @__PURE__ */ r({
158
- Canceled: () => _e,
164
+ Canceled: () => ye,
159
165
  NONE: () => "nil",
160
- NotImplemented: () => ve,
166
+ NotImplemented: () => be,
161
167
  UNKNOWN: () => b,
162
- Unknown: () => he,
168
+ Unknown: () => _e,
163
169
  createTyped: () => y,
164
- decode: () => me,
165
- encode: () => pe,
170
+ decode: () => ge,
171
+ encode: () => he,
166
172
  isTyped: () => le,
167
- payloadZ: () => ge,
168
- register: () => fe
173
+ payloadZ: () => ve,
174
+ register: () => me
169
175
  }), se = "sy_x_error", ce = (e) => (t) => typeof t == "object" && t && "type" in t && typeof t.type == "string" ? t.type.startsWith(e) : t instanceof Error ? t.message.startsWith(e) : typeof t == "string" ? t.startsWith(e) : !1, y = (e) => class t extends Error {
170
176
  static discriminator = se;
171
177
  discriminator = t.discriminator;
@@ -185,7 +191,11 @@ var n = Object.defineProperty, r = (e, t) => {
185
191
  if (t.discriminator !== se) return !1;
186
192
  if (!("type" in t)) throw Error(`X Error is missing its type property: ${JSON.stringify(t)}`);
187
193
  return !0;
188
- }, b = "unknown", ue = class {
194
+ }, b = "unknown", ue = (e, t) => ({
195
+ ...e,
196
+ name: t.name,
197
+ stack: t.stack
198
+ }), de = (e, t) => (t.name != null && (e.name = t.name), t.stack != null && (e.stack = t.stack), e), fe = class {
189
199
  providers = [];
190
200
  register(e) {
191
201
  this.providers.push(e);
@@ -197,12 +207,12 @@ var n = Object.defineProperty, r = (e, t) => {
197
207
  };
198
208
  if (le(e)) for (let t of this.providers) {
199
209
  let n = t.encode(e);
200
- if (n != null) return n;
210
+ if (n != null) return ue(n, e);
201
211
  }
202
- if (e instanceof Error) return {
212
+ if (e instanceof Error) return ue({
203
213
  type: b,
204
214
  data: e.message
205
- };
215
+ }, e);
206
216
  if (typeof e == "string") return {
207
217
  type: b,
208
218
  data: e
@@ -221,27 +231,29 @@ var n = Object.defineProperty, r = (e, t) => {
221
231
  }
222
232
  decode(e) {
223
233
  if (e == null || e.type === "nil") return null;
224
- if (e.type === "unknown") return new he(e.data);
234
+ if (e.type === "unknown") return de(new _e(e.data), e);
225
235
  for (let t of this.providers) {
226
236
  let n = t.decode(e);
227
- if (n != null) return n;
237
+ if (n != null) return de(n, e);
228
238
  }
229
- return new he(e.data);
239
+ return de(new _e(e.data), e);
230
240
  }
231
- }, de = oe("synnax-error-registry", () => new ue()), fe = ({ encode: e, decode: t }) => de().register({
241
+ }, pe = oe("synnax-error-registry", () => new fe()), me = ({ encode: e, decode: t }) => pe().register({
232
242
  encode: e,
233
243
  decode: t
234
- }), pe = (e) => de().encode(e), me = (e) => e == null ? null : de().decode(e), he = class extends y("unknown") {}, ge = t.object({
244
+ }), he = (e) => pe().encode(e), ge = (e) => e == null ? null : pe().decode(e), _e = class extends y("unknown") {}, ve = t.object({
235
245
  type: t.string(),
236
- data: t.string()
237
- }), _e = class extends y("canceled") {}, ve = class extends y("not_implemented") {}, ye = (e) => {
246
+ data: t.string(),
247
+ name: t.string().optional(),
248
+ stack: t.string().optional()
249
+ }), ye = class extends y("canceled") {}, be = class extends y("not_implemented") {}, xe = (e) => {
238
250
  if (e.length === 0) return "<root>";
239
251
  let t = "";
240
252
  return e.forEach((e, n) => {
241
253
  typeof e == "number" ? t += `[${e}]` : n === 0 ? t += String(e) : t += `.${String(e)}`;
242
254
  }), t;
243
- }, be = 200, xe = 10, Se = 8, x = (e, t = {}) => {
244
- let n = t.maxStringLength ?? be, r = t.maxArrayLength ?? xe, i = t.maxDepth ?? Se, a = (e, t) => {
255
+ }, Se = 200, Ce = 10, we = 8, x = (e, t = {}) => {
256
+ let n = t.maxStringLength ?? Se, r = t.maxArrayLength ?? Ce, i = t.maxDepth ?? we, a = (e, t) => {
245
257
  if (e === null) return null;
246
258
  if (e === void 0) return "[undefined]";
247
259
  let o = typeof e;
@@ -272,7 +284,7 @@ var n = Object.defineProperty, r = (e, t) => {
272
284
  }
273
285
  };
274
286
  return a(e, 0);
275
- }, Ce = (e, t = {}) => JSON.stringify(x(e, t), null, 2), S = (e) => typeof e == "object" && !!e && "value" in e, C = class {
287
+ }, Te = (e, t = {}) => JSON.stringify(x(e, t), null, 2), S = (e) => typeof e == "object" && !!e && "value" in e, C = class {
276
288
  value;
277
289
  constructor(e) {
278
290
  this.value = e;
@@ -286,11 +298,11 @@ var n = Object.defineProperty, r = (e, t) => {
286
298
  toString() {
287
299
  return this.value.toString();
288
300
  }
289
- }, we = (e) => typeof e == "object" && !!e && "toString" in e, Te = (e) => e == null || typeof e != "object" && typeof e != "function", Ee = "value", De = "zod.parse", Oe = "✗", ke = 60, Ae = {
301
+ }, Ee = (e) => typeof e == "object" && !!e && "toString" in e, De = (e) => e == null || typeof e != "object" && typeof e != "function", Oe = "value", ke = "zod.parse", Ae = "✗", je = 60, Me = {
290
302
  maxStringLength: 60,
291
303
  maxArrayLength: 3,
292
304
  maxDepth: 3
293
- }, je = (e) => e.slice(0, -1), Me = (e) => {
305
+ }, Ne = (e) => e.slice(0, -1), Pe = (e) => {
294
306
  switch (e.code) {
295
307
  case "invalid_type": return `expected ${e.expected}`;
296
308
  case "invalid_value": return `expected one of ${JSON.stringify(e.values)}`;
@@ -308,9 +320,9 @@ var n = Object.defineProperty, r = (e, t) => {
308
320
  case "custom": return e.message || "custom validation failed";
309
321
  default: return e.message;
310
322
  }
311
- }, Ne = (e, t, n) => {
323
+ }, Fe = (e, t, n) => {
312
324
  let r = JSON.stringify(x(t, n));
313
- return `${Me(e)}, received ${r}`;
325
+ return `${Pe(e)}, received ${r}`;
314
326
  }, w = (e) => {
315
327
  let t = 0;
316
328
  for (let n of e) {
@@ -351,7 +363,7 @@ var n = Object.defineProperty, r = (e, t) => {
351
363
  });
352
364
  }
353
365
  return n;
354
- }, Pe = (e) => {
366
+ }, Ie = (e) => {
355
367
  let t = [];
356
368
  for (let n of e) {
357
369
  if (n.code === "unrecognized_keys" && "keys" in n && Array.isArray(n.keys)) {
@@ -364,9 +376,9 @@ var n = Object.defineProperty, r = (e, t) => {
364
376
  t.push(n);
365
377
  }
366
378
  return t;
367
- }, Fe = (e, t, n, r) => {
368
- let i = `${n} `, a = `${n + Oe} `, o = {
369
- ...Ae,
379
+ }, Le = (e, t, n, r) => {
380
+ let i = `${n} `, a = `${n + Ae} `, o = {
381
+ ...Me,
370
382
  ...r
371
383
  };
372
384
  if (Array.isArray(e)) {
@@ -416,7 +428,7 @@ var n = Object.defineProperty, r = (e, t) => {
416
428
  return u.forEach((e, t) => {
417
429
  if (e.mark == null) return;
418
430
  let n = +(t < u.length - 1), r = e.content.length + n;
419
- r > d && r <= ke && (d = r);
431
+ r > d && r <= je && (d = r);
420
432
  }), u.forEach((e, t) => {
421
433
  let n = t < u.length - 1 ? "," : "", r = e.content + n;
422
434
  if (e.mark != null) {
@@ -424,48 +436,48 @@ var n = Object.defineProperty, r = (e, t) => {
424
436
  c.push(`${a}${r}${t}× ${e.mark.reason}`);
425
437
  } else c.push(`${i}${r}`);
426
438
  }), c.push(n + (l ? "]" : "}")), c;
427
- }, Ie = "__root__", Le = (e, t, n) => {
439
+ }, Re = "__root__", ze = (e, t, n) => {
428
440
  let r = /* @__PURE__ */ new Map();
429
441
  for (let t of e) {
430
- let e = t.path.length === 0 ? Ie : `::${ye(je(t.path))}`, n = r.get(e);
442
+ let e = t.path.length === 0 ? Re : `::${xe(Ne(t.path))}`, n = r.get(e);
431
443
  n == null ? r.set(e, [t]) : n.push(t);
432
444
  }
433
445
  let i = [];
434
446
  for (let [e, a] of r) {
435
- if (e === Ie) {
436
- i.push(a.map((e) => ` × ${Ne(e, t, n)}`).join("\n"));
447
+ if (e === Re) {
448
+ i.push(a.map((e) => ` × ${Fe(e, t, n)}`).join("\n"));
437
449
  continue;
438
450
  }
439
- let r = je(a[0].path), { present: o, value: s } = te(t, r);
451
+ let r = Ne(a[0].path), { present: o, value: s } = te(t, r);
440
452
  if (!o) {
441
- i.push(a.map((e) => ` at ${ye(e.path)}\n × ${Ne(e, t, n)}`).join("\n"));
453
+ i.push(a.map((e) => ` at ${xe(e.path)}\n × ${Fe(e, t, n)}`).join("\n"));
442
454
  continue;
443
455
  }
444
456
  let c = /* @__PURE__ */ new Map();
445
457
  for (let e of a) {
446
458
  let n = String(e.path[e.path.length - 1]), r = te(t, e.path);
447
459
  c.set(n, {
448
- reason: Me(e),
460
+ reason: Pe(e),
449
461
  missing: !r.present
450
462
  });
451
463
  }
452
- let l = r.length === 0, u = Fe(s, c, l ? " " : " ", n);
453
- l ? i.push(u.join("\n")) : i.push([` at ${ye(r)}`, ...u].join("\n"));
464
+ let l = r.length === 0, u = Le(s, c, l ? " " : " ", n);
465
+ l ? i.push(u.join("\n")) : i.push([` at ${xe(r)}`, ...u].join("\n"));
454
466
  }
455
467
  return i.join("\n\n");
456
- }, Re = (e, t) => {
468
+ }, Be = (e, t) => {
457
469
  let n = Object.entries(e);
458
- return n.every(([, e]) => Te(e)) ? n.map(([e, t]) => `${e}=${typeof t == "string" ? t : String(t)}`).join(", ") : Ce(e, t);
459
- }, ze = ({ issues: e, input: t, label: n, context: r, formatOptions: i }) => {
460
- let a = i ?? {}, o = Pe(T(e)), s = [`Failed to parse ${n} (${o.length === 1 ? "1 issue" : `${o.length} issues`})`];
461
- return s.push(Le(o, t, a)), r != null && Object.keys(r).length > 0 && s.push(` context: ${Re(r, a)}`), s.join("\n\n");
462
- }, Be = class extends y(De) {
470
+ return n.every(([, e]) => De(e)) ? n.map(([e, t]) => `${e}=${typeof t == "string" ? t : String(t)}`).join(", ") : Te(e, t);
471
+ }, Ve = ({ issues: e, input: t, label: n, context: r, formatOptions: i }) => {
472
+ let a = i ?? {}, o = Ie(T(e)), s = [`Failed to parse ${n} (${o.length === 1 ? "1 issue" : `${o.length} issues`})`];
473
+ return s.push(ze(o, t, a)), r != null && Object.keys(r).length > 0 && s.push(` context: ${Be(r, a)}`), s.join("\n\n");
474
+ }, He = class extends y(ke) {
463
475
  issues;
464
476
  input;
465
477
  label;
466
478
  context;
467
479
  constructor({ issues: e, input: t, label: n, context: r, cause: i, formatOptions: a }) {
468
- super(ze({
480
+ super(Ve({
469
481
  issues: e,
470
482
  input: t,
471
483
  label: n,
@@ -485,9 +497,9 @@ var n = Object.defineProperty, r = (e, t) => {
485
497
  };
486
498
  }
487
499
  };
488
- fe({
500
+ me({
489
501
  encode: (e) => {
490
- if (!Be.matches(e)) return null;
502
+ if (!He.matches(e)) return null;
491
503
  let t = e, n = {
492
504
  label: t.label,
493
505
  context: t.context,
@@ -495,14 +507,14 @@ fe({
495
507
  input: x(t.input)
496
508
  };
497
509
  return {
498
- type: De,
510
+ type: ke,
499
511
  data: JSON.stringify(n)
500
512
  };
501
513
  },
502
514
  decode: (e) => {
503
- if (e.type !== De) return null;
515
+ if (e.type !== ke) return null;
504
516
  let t = JSON.parse(e.data);
505
- return new Be({
517
+ return new He({
506
518
  issues: t.issues,
507
519
  input: t.input,
508
520
  label: t.label,
@@ -510,31 +522,33 @@ fe({
510
522
  });
511
523
  }
512
524
  });
513
- var Ve = (e, t, n = {}) => {
525
+ var Ue = (e, t, n = {}) => {
514
526
  let r = e.safeParse(t);
515
527
  if (r.success) return r.data;
516
- throw new Be({
528
+ throw new He({
517
529
  issues: r.error.issues,
518
530
  input: t,
519
- label: n.label ?? Ee,
531
+ label: n.label ?? Oe,
520
532
  context: n.context,
521
533
  cause: r.error
522
534
  });
523
- }, He = 2 ** 12 - 1, Ue = 2 ** 16 - 1, We = 2 ** 20 - 1, Ge = -128, Ke = -(2 ** 15), qe = 2 ** 15 - 1, Je = -(2n ** 63n), E = 2n ** 63n - 1n, Ye = -(2 ** 63), Xe = 2 ** 63 - 1, D = (e) => (t, n) => {
535
+ }, We = 2 ** 12 - 1, Ge = 2 ** 16 - 1, Ke = 2 ** 20 - 1, qe = -128, Je = -(2 ** 15), Ye = 2 ** 15 - 1, Xe = -(2n ** 63n), Ze = 2n ** 63n - 1n, Qe = -(2 ** 63), $e = 2 ** 63 - 1, E = (e) => (t, n) => {
524
536
  if (typeof t == "bigint") {
525
- if (Ze(n)) return e(t, BigInt(n));
537
+ if (et(n)) return e(t, BigInt(n));
526
538
  let r = e(Number(t), Number(n));
527
539
  return typeof r == "number" ? BigInt(Math.round(r)) : r;
528
540
  }
529
541
  return e(Number(t), Number(n));
530
- }, O = D((e, t) => e - t), k = D((e, t) => e + t), Ze = (e) => typeof e == "bigint" ? !0 : Number.isInteger(e), A = D((e, t) => e * t), j = D((e, t) => e / t), Qe = t.tuple([t.number(), t.number()]), $e = t.enum(["x", "y"]), et = [
542
+ }, D = E((e, t) => e - t), O = E((e, t) => e + t), et = (e) => typeof e == "bigint" ? !0 : Number.isInteger(e), k = E((e, t) => e * t), A = E((e, t) => e / t), tt = ["left", "right"], nt = t.enum(tt), rt = t.enum(["top", "bottom"]), it = t.enum(["px", "decimal"]), at = [
531
543
  "top",
532
544
  "right",
533
545
  "bottom",
534
546
  "left"
535
547
  ];
536
- t.enum(et);
537
- var tt = ["left", "right"], nt = t.enum(tt), rt = t.enum(["top", "bottom"]), it = ["center"], at = t.enum(it);
548
+ t.enum(at);
549
+ var ot = t.enum(["x", "y"]);
550
+ t.enum(["clockwise", "counterclockwise"]);
551
+ var st = ["center"], ct = t.enum(st);
538
552
  t.enum([
539
553
  "top",
540
554
  "right",
@@ -545,31 +559,36 @@ t.enum([
545
559
  "start",
546
560
  "center",
547
561
  "end"
548
- ]), t.enum(["first", "last"]);
549
- var ot = t.object({
550
- clientX: t.number(),
551
- clientY: t.number()
552
- }), st = t.object({
562
+ ]), t.enum(["first", "last"]), t.enum(["width", "height"]), t.enum(["signedWidth", "signedHeight"]);
563
+ var j = t.object({
564
+ x: t.number(),
565
+ y: t.number()
566
+ }), lt = t.object({
567
+ x: nt,
568
+ y: rt
569
+ }), ut = t.object({
570
+ x: it,
571
+ y: it
572
+ }), dt = t.object({
553
573
  width: t.number(),
554
574
  height: t.number()
555
- }), ct = t.object({
575
+ }), ft = t.object({
556
576
  signedWidth: t.number(),
557
577
  signedHeight: t.number()
578
+ }), pt = t.object({
579
+ clientX: t.number(),
580
+ clientY: t.number()
558
581
  });
559
582
  t.object({
560
- lower: t.number(),
561
- upper: t.number()
562
- }), t.enum([
563
- "x",
564
- "y",
565
- ...et,
566
- ...it
567
- ]), t.union([
568
- $e,
569
- t.enum([...et, ...it]),
570
- t.instanceof(String)
571
- ]);
572
- var M = (e, t, n) => {
583
+ zoom: t.number().default(1),
584
+ position: j
585
+ });
586
+ var mt = t.object({
587
+ x: t.number(),
588
+ y: t.number(),
589
+ root: lt.optional(),
590
+ units: ut.optional()
591
+ }), ht = t.tuple([t.number(), t.number()]), M = (e, t, n) => {
573
592
  let r = {};
574
593
  if (typeof t == "object" && (n = t, t = void 0), n = {
575
594
  makeValid: !0,
@@ -579,7 +598,7 @@ var M = (e, t, n) => {
579
598
  if (e.length !== 2) throw Error("bounds: expected array of length 2");
580
599
  [r.lower, r.upper] = e;
581
600
  } else r.lower = e.lower, r.upper = e.upper;
582
- return n?.makeValid ? lt(r) : r;
601
+ return n?.makeValid ? gt(r) : r;
583
602
  };
584
603
  Object.freeze({
585
604
  lower: 0,
@@ -594,17 +613,17 @@ Object.freeze({
594
613
  lower: -1,
595
614
  upper: 1
596
615
  });
597
- var lt = (e) => e.lower > e.upper ? {
616
+ var gt = (e) => e.lower > e.upper ? {
598
617
  lower: e.upper,
599
618
  upper: e.lower
600
- } : e, ut = (e, t) => {
619
+ } : e, _t = (e, t) => {
601
620
  let n = M(e);
602
621
  return t < n.lower ? n.lower : t >= n.upper ? n.upper - (typeof n.upper == "number" ? 1 : 1n) : t;
603
622
  };
604
- t.int().min(Ge).max(127), t.int().min(Ke).max(qe), t.int().min(Ye).max(Xe);
605
- var dt = t.int().min(0).max(255);
606
- t.int().min(0).max(He), t.int().min(0).max(Ue), t.int().min(0).max(We);
607
- var ft = class {
623
+ t.int().min(qe).max(127), t.int().min(Je).max(Ye), t.int().min(Qe).max($e);
624
+ var vt = t.int().min(0).max(255);
625
+ t.int().min(0).max(We), t.int().min(0).max(Ge), t.int().min(0).max(Ke);
626
+ var yt = class {
608
627
  contentType = "application/json";
609
628
  decoder;
610
629
  encoder;
@@ -619,13 +638,13 @@ var ft = class {
619
638
  }
620
639
  decodeString(e, t) {
621
640
  let n = f(JSON.parse(e), { schema: t });
622
- return t == null ? n : Ve(t, n);
641
+ return t == null ? n : Ue(t, n);
623
642
  }
624
643
  encodeString(e, t) {
625
- let n = p((t == null ? e : Ve(t, e)) ?? {}, { schema: t });
644
+ let n = p((t == null ? e : Ue(t, e)) ?? {}, { schema: t });
626
645
  return JSON.stringify(n, (e, t) => ArrayBuffer.isView(t) ? Array.from(t) : typeof t == "bigint" ? t.toString() : t);
627
646
  }
628
- }, pt = class {
647
+ }, bt = class {
629
648
  contentType = "text/csv";
630
649
  encode(e) {
631
650
  let t = this.encodeString(e);
@@ -662,7 +681,7 @@ var ft = class {
662
681
  let t = Number(e);
663
682
  return isNaN(t) ? e.startsWith("\"") && e.endsWith("\"") ? e.slice(1, -1) : e : t;
664
683
  }
665
- }, mt = class {
684
+ }, xt = class {
666
685
  contentType = "text/plain";
667
686
  encode(e) {
668
687
  if (typeof e != "string") throw Error("TextCodec.encode payload must be a string");
@@ -672,9 +691,9 @@ var ft = class {
672
691
  let n = new TextDecoder().decode(e);
673
692
  return t == null ? n : t.parse(n);
674
693
  }
675
- }, ht = new ft();
676
- new pt(), new mt();
677
- var gt = 365, N = 30, _t = t.union([
694
+ }, St = new yt();
695
+ new bt(), new xt();
696
+ var Ct = 365, N = 30, wt = t.union([
678
697
  t.tuple([t.int()]),
679
698
  t.tuple([t.int(), t.int().min(1).max(12)]),
680
699
  t.tuple([
@@ -682,7 +701,7 @@ var gt = 365, N = 30, _t = t.union([
682
701
  t.int().min(1).max(12),
683
702
  t.int().min(1).max(31)
684
703
  ])
685
- ]), vt = (e, t) => {
704
+ ]), Tt = (e, t) => {
686
705
  let n = new P(t);
687
706
  if (![
688
707
  F.DAY,
@@ -696,6 +715,9 @@ var gt = 365, N = 30, _t = t.union([
696
715
  let r = e.valueOf() % n.valueOf();
697
716
  return e instanceof P ? new P(r) : new F(r);
698
717
  }, P = class e extends C {
718
+ hash() {
719
+ return this.value.toString();
720
+ }
699
721
  constructor(t, n = "UTC") {
700
722
  if (t == null) super(e.now().valueOf());
701
723
  else if (t instanceof Date) super(BigInt(t.getTime()) * e.MILLISECOND.valueOf());
@@ -703,7 +725,7 @@ var gt = 365, N = 30, _t = t.union([
703
725
  else if (Array.isArray(t)) super(e.parseDate(t));
704
726
  else {
705
727
  let r = 0n;
706
- t instanceof Number && (t = t.valueOf()), n === "local" && (r = e.utcOffset.valueOf()), typeof t == "number" && (isFinite(t) ? t = t === Xe ? E : Math.trunc(t) : (isNaN(t) && (t = 0), t = t === Infinity ? e.MAX : e.MIN)), S(t) && (t = t.value), super(BigInt(t.valueOf()) + r);
728
+ t instanceof Number && (t = t.valueOf()), n === "local" && (r = e.utcOffset.valueOf()), typeof t == "number" && (isFinite(t) ? t = t === $e ? Ze : Math.trunc(t) : (isNaN(t) && (t = 0), t = t === Infinity ? e.MAX : e.MIN)), S(t) && (t = t.value), super(BigInt(t.valueOf()) + r);
707
729
  }
708
730
  }
709
731
  static parseDate([t = 1970, n = 1, r = 1]) {
@@ -764,7 +786,7 @@ var gt = 365, N = 30, _t = t.union([
764
786
  return this.range(e).span;
765
787
  }
766
788
  range(e) {
767
- return new L(this, e).makeValid();
789
+ return new R(this, e).makeValid();
768
790
  }
769
791
  spanRange(e) {
770
792
  return this.range(this.add(e)).makeValid();
@@ -785,10 +807,10 @@ var gt = 365, N = 30, _t = t.union([
785
807
  return this.valueOf() <= new e(t).valueOf();
786
808
  }
787
809
  add(t) {
788
- return new e(k(this.valueOf(), new F(t).valueOf()));
810
+ return new e(O(this.valueOf(), new F(t).valueOf()));
789
811
  }
790
812
  sub(t) {
791
- return new e(O(this.valueOf(), new F(t).valueOf()));
813
+ return new e(D(this.valueOf(), new F(t).valueOf()));
792
814
  }
793
815
  get hours() {
794
816
  return Number(this.valueOf()) / Number(F.HOUR.valueOf());
@@ -912,7 +934,6 @@ var gt = 365, N = 30, _t = t.union([
912
934
  toString(e = "ISO", t = "UTC") {
913
935
  switch (e) {
914
936
  case "ISODate": return this.toISOString(t).slice(0, 10);
915
- case "ISOTime": return this.toISOString(t).slice(11, 23);
916
937
  case "time": return this.timeString(!1, t);
917
938
  case "preciseTime": return this.timeString(!0, t);
918
939
  case "date": return this.dateString();
@@ -922,7 +943,7 @@ var gt = 365, N = 30, _t = t.union([
922
943
  }
923
944
  }
924
945
  remainder(e) {
925
- return vt(this, e);
946
+ return Tt(this, e);
926
947
  }
927
948
  get isToday() {
928
949
  return this.truncate(F.DAY).equals(e.now().truncate(F.DAY));
@@ -931,7 +952,7 @@ var gt = 365, N = 30, _t = t.union([
931
952
  return this.sub(this.remainder(e));
932
953
  }
933
954
  formatBySpan(e) {
934
- return e.greaterThanOrEqual(F.days(30)) ? "shortDate" : e.greaterThanOrEqual(F.DAY) ? "dateTime" : e.greaterThanOrEqual(F.HOUR) ? "time" : e.greaterThanOrEqual(F.SECOND) ? "preciseTime" : "ISOTime";
955
+ return e.greaterThanOrEqual(F.days(30)) ? "date" : e.greaterThanOrEqual(F.DAY) ? "dateTime" : e.greaterThanOrEqual(F.HOUR) ? "time" : "preciseTime";
935
956
  }
936
957
  static now() {
937
958
  return new e(/* @__PURE__ */ new Date());
@@ -980,7 +1001,7 @@ var gt = 365, N = 30, _t = t.union([
980
1001
  return e.hours(t * 24, n);
981
1002
  }
982
1003
  static DAY = e.days(1);
983
- static MAX = new e(E);
1004
+ static MAX = new e(Ze);
984
1005
  static MIN = new e(0);
985
1006
  static ZERO = new e(0);
986
1007
  static z = t.union([
@@ -991,7 +1012,7 @@ var gt = 365, N = 30, _t = t.union([
991
1012
  t.bigint().transform((t) => new e(t)),
992
1013
  t.date().transform((t) => new e(t)),
993
1014
  t.custom((e) => e instanceof F).transform((t) => new e(t)),
994
- _t.transform((t) => new e(t))
1015
+ wt.transform((t) => new e(t))
995
1016
  ]);
996
1017
  static sort(e, t) {
997
1018
  return Number(e.valueOf() - t.valueOf());
@@ -1001,14 +1022,17 @@ var gt = 365, N = 30, _t = t.union([
1001
1022
  typeof e == "number" && (e = Math.trunc(e.valueOf())), S(e) && (e = e.value), super(BigInt(e.valueOf()));
1002
1023
  }
1003
1024
  static fromSeconds(t) {
1004
- return t instanceof e ? t : t instanceof yt ? t.period : t instanceof P ? new e(t) : (S(t) && (t = t.value), ["number", "bigint"].includes(typeof t) ? e.seconds(t) : new e(t));
1025
+ return t instanceof e ? t : t instanceof I ? t.period : t instanceof P ? new e(t) : (S(t) && (t = t.value), ["number", "bigint"].includes(typeof t) ? e.seconds(t) : new e(t));
1005
1026
  }
1006
1027
  static fromMilliseconds(t) {
1007
- return t instanceof e ? t : t instanceof yt ? t.period : t instanceof P ? new e(t) : (S(t) && (t = t.value), ["number", "bigint"].includes(typeof t) ? e.milliseconds(t) : new e(t));
1028
+ return t instanceof e ? t : t instanceof I ? t.period : t instanceof P ? new e(t) : (S(t) && (t = t.value), ["number", "bigint"].includes(typeof t) ? e.milliseconds(t) : new e(t));
1008
1029
  }
1009
1030
  valueOf() {
1010
1031
  return this.value;
1011
1032
  }
1033
+ hash() {
1034
+ return this.value.toString();
1035
+ }
1012
1036
  lessThan(t) {
1013
1037
  return this.valueOf() < new e(t).valueOf();
1014
1038
  }
@@ -1022,7 +1046,7 @@ var gt = 365, N = 30, _t = t.union([
1022
1046
  return this.valueOf() >= new e(t).valueOf();
1023
1047
  }
1024
1048
  remainder(e) {
1025
- return vt(this, e);
1049
+ return Tt(this, e);
1026
1050
  }
1027
1051
  truncate(t) {
1028
1052
  return new e(BigInt(Math.trunc(Number(this.valueOf() / t.valueOf()))) * t.valueOf());
@@ -1036,11 +1060,11 @@ var gt = 365, N = 30, _t = t.union([
1036
1060
  let t = new e(this.valueOf() < 0n ? -this.valueOf() : this.valueOf()), n = this.valueOf() < 0n;
1037
1061
  if (t.valueOf() === 0n) return "0s";
1038
1062
  if (t.lessThan(e.SECOND)) return "< 1s";
1039
- let r = t.days, i = t.hours, a = t.minutes, o = t.seconds, s = Math.floor(r / gt), c = Math.floor(r / N), l = Math.floor(r / 7), u = Math.floor(r), d = Math.floor(i), f = Math.floor(a), p = Math.floor(o), m = n ? "-" : "";
1063
+ let r = t.days, i = t.hours, a = t.minutes, o = t.seconds, s = Math.floor(r / Ct), c = Math.floor(r / N), l = Math.floor(r / 7), u = Math.floor(r), d = Math.floor(i), f = Math.floor(a), p = Math.floor(o), m = n ? "-" : "";
1040
1064
  if (s >= 1) {
1041
1065
  let e = `${s}y`;
1042
1066
  if (s < 2) {
1043
- let t = Math.floor(r % gt / N);
1067
+ let t = Math.floor(r % Ct / N);
1044
1068
  t > 0 && (e += ` ${t}mo`);
1045
1069
  }
1046
1070
  return m + e;
@@ -1084,10 +1108,10 @@ var gt = 365, N = 30, _t = t.union([
1084
1108
  return `${m}${p}s`;
1085
1109
  }
1086
1110
  mult(t) {
1087
- return new e(A(this.valueOf(), t));
1111
+ return new e(k(this.valueOf(), t));
1088
1112
  }
1089
1113
  div(t) {
1090
- return new e(j(this.valueOf(), t));
1114
+ return new e(A(this.valueOf(), t));
1091
1115
  }
1092
1116
  get days() {
1093
1117
  return Number(this.valueOf()) / Number(e.DAY.valueOf());
@@ -1131,30 +1155,30 @@ var gt = 365, N = 30, _t = t.union([
1131
1155
  }
1132
1156
  static NANOSECOND = e.nanoseconds(1);
1133
1157
  static microseconds(t = 1) {
1134
- return e.nanoseconds(A(t, 1e3));
1158
+ return e.nanoseconds(k(t, 1e3));
1135
1159
  }
1136
1160
  static MICROSECOND = e.microseconds(1);
1137
1161
  static milliseconds(t = 1) {
1138
- return e.microseconds(A(t, 1e3));
1162
+ return e.microseconds(k(t, 1e3));
1139
1163
  }
1140
1164
  static MILLISECOND = e.milliseconds(1);
1141
1165
  static seconds(t = 1) {
1142
- return e.milliseconds(A(t, 1e3));
1166
+ return e.milliseconds(k(t, 1e3));
1143
1167
  }
1144
1168
  static SECOND = e.seconds(1);
1145
1169
  static minutes(t = 1) {
1146
- return e.seconds(A(t, 60));
1170
+ return e.seconds(k(t, 60));
1147
1171
  }
1148
1172
  static MINUTE = e.minutes(1);
1149
1173
  static hours(t) {
1150
- return e.minutes(A(t, 60));
1174
+ return e.minutes(k(t, 60));
1151
1175
  }
1152
1176
  static HOUR = e.hours(1);
1153
1177
  static days(t) {
1154
- return e.hours(A(t, 24));
1178
+ return e.hours(k(t, 24));
1155
1179
  }
1156
1180
  static DAY = e.days(1);
1157
- static MAX = new e(E);
1181
+ static MAX = new e(Ze);
1158
1182
  static MIN = new e(0);
1159
1183
  static ZERO = new e(0);
1160
1184
  static z = t.union([
@@ -1164,12 +1188,15 @@ var gt = 365, N = 30, _t = t.union([
1164
1188
  t.bigint().transform((t) => new e(t)),
1165
1189
  t.instanceof(e),
1166
1190
  t.instanceof(P).transform((t) => new e(t)),
1167
- t.custom((e) => e instanceof yt).transform((t) => new e(t))
1191
+ t.custom((e) => e instanceof I).transform((t) => new e(t))
1168
1192
  ]);
1169
- }, yt = class e extends C {
1193
+ }, I = class e extends C {
1170
1194
  constructor(e) {
1171
1195
  S(e) && (e = e.value), super(e.valueOf());
1172
1196
  }
1197
+ hash() {
1198
+ return this.value.toString();
1199
+ }
1173
1200
  toString() {
1174
1201
  return `${this.valueOf()} Hz`;
1175
1202
  }
@@ -1183,25 +1210,25 @@ var gt = 365, N = 30, _t = t.union([
1183
1210
  return new F(e).seconds * this.valueOf();
1184
1211
  }
1185
1212
  byteCount(e, t) {
1186
- return this.sampleCount(e) * new I(t).valueOf();
1213
+ return this.sampleCount(e) * new L(t).valueOf();
1187
1214
  }
1188
1215
  span(e) {
1189
1216
  return F.seconds(e / this.valueOf());
1190
1217
  }
1191
1218
  byteSpan(e, t) {
1192
- return this.span(e.valueOf() / new I(t).valueOf());
1219
+ return this.span(e.valueOf() / new L(t).valueOf());
1193
1220
  }
1194
1221
  add(t) {
1195
- return new e(k(this.valueOf(), new e(t).valueOf()));
1222
+ return new e(O(this.valueOf(), new e(t).valueOf()));
1196
1223
  }
1197
1224
  sub(t) {
1198
- return new e(O(this.valueOf(), new e(t).valueOf()));
1225
+ return new e(D(this.valueOf(), new e(t).valueOf()));
1199
1226
  }
1200
1227
  mult(t) {
1201
- return new e(A(this.valueOf(), t));
1228
+ return new e(k(this.valueOf(), t));
1202
1229
  }
1203
1230
  div(t) {
1204
- return new e(j(this.valueOf(), t));
1231
+ return new e(A(this.valueOf(), t));
1205
1232
  }
1206
1233
  static hz(t) {
1207
1234
  return new e(t);
@@ -1210,7 +1237,7 @@ var gt = 365, N = 30, _t = t.union([
1210
1237
  return e.hz(t * 1e3);
1211
1238
  }
1212
1239
  static z = t.union([t.number().transform((t) => new e(t)), t.instanceof(e)]);
1213
- }, I = class e extends C {
1240
+ }, L = class e extends C {
1214
1241
  constructor(e) {
1215
1242
  S(e) && (e = e.value), super(e.valueOf());
1216
1243
  }
@@ -1218,19 +1245,19 @@ var gt = 365, N = 30, _t = t.union([
1218
1245
  return e.valueOf() / this.valueOf();
1219
1246
  }
1220
1247
  size(e) {
1221
- return new z(e * this.valueOf());
1248
+ return new B(e * this.valueOf());
1222
1249
  }
1223
1250
  add(t) {
1224
- return new e(k(this.valueOf(), new e(t).valueOf()));
1251
+ return new e(O(this.valueOf(), new e(t).valueOf()));
1225
1252
  }
1226
1253
  sub(t) {
1227
- return new e(O(this.valueOf(), new e(t).valueOf()));
1254
+ return new e(D(this.valueOf(), new e(t).valueOf()));
1228
1255
  }
1229
1256
  mult(t) {
1230
- return new e(A(this.valueOf(), t));
1257
+ return new e(k(this.valueOf(), t));
1231
1258
  }
1232
1259
  div(t) {
1233
- return new e(j(this.valueOf(), t));
1260
+ return new e(A(this.valueOf(), t));
1234
1261
  }
1235
1262
  static UNKNOWN = new e(0);
1236
1263
  static BIT128 = new e(16);
@@ -1239,7 +1266,10 @@ var gt = 365, N = 30, _t = t.union([
1239
1266
  static BIT16 = new e(2);
1240
1267
  static BIT8 = new e(1);
1241
1268
  static z = t.union([t.number().transform((t) => new e(t)), t.instanceof(e)]);
1242
- }, L = class e {
1269
+ }, R = class e {
1270
+ hash() {
1271
+ return `${this.start.hash()}-${this.end.hash()}`;
1272
+ }
1243
1273
  start;
1244
1274
  end;
1245
1275
  constructor(e, t) {
@@ -1307,14 +1337,17 @@ var gt = 365, N = 30, _t = t.union([
1307
1337
  start: P.z,
1308
1338
  end: P.z
1309
1339
  }).transform((t) => new e(t.start, t.end)), t.instanceof(e)]);
1310
- static boundedZ = e.z.refine(({ isValid: e }) => e, { message: "Time range start time must be before or equal to time range end time" }).refine(({ end: e }) => e.valueOf() <= E, { message: "Time range end time must be less than or equal to the maximum value of an int64" }).refine(({ start: e }) => e.valueOf() >= Je, { message: "Time range start time must be greater than or equal to the minimum value of an int64" });
1340
+ static boundedZ = e.z.refine(({ isValid: e }) => e, { message: "Time range start time must be before or equal to time range end time" }).refine(({ end: e }) => e.valueOf() <= Ze, { message: "Time range end time must be less than or equal to the maximum value of an int64" }).refine(({ start: e }) => e.valueOf() >= Xe, { message: "Time range start time must be greater than or equal to the minimum value of an int64" });
1311
1341
  static sort(e, t) {
1312
1342
  return P.sort(e.start, t.start) || P.sort(e.end, t.end);
1313
1343
  }
1314
1344
  static merge(...t) {
1315
1345
  return e.max(...t.map((t) => new e(t).makeValid()));
1316
1346
  }
1317
- }, R = class e extends C {
1347
+ }, z = class e extends C {
1348
+ hash() {
1349
+ return this.value;
1350
+ }
1318
1351
  constructor(t) {
1319
1352
  if (S(t) && (t = t.value), t instanceof e || typeof t == "string" || typeof t.valueOf() == "string") super(t.valueOf());
1320
1353
  else {
@@ -1419,21 +1452,21 @@ var gt = 365, N = 30, _t = t.union([
1419
1452
  [BigInt64Array.name, e.INT64]
1420
1453
  ]);
1421
1454
  static DENSITIES = new Map([
1422
- [e.UINT8.toString(), I.BIT8],
1423
- [e.UINT16.toString(), I.BIT16],
1424
- [e.UINT32.toString(), I.BIT32],
1425
- [e.UINT64.toString(), I.BIT64],
1426
- [e.FLOAT32.toString(), I.BIT32],
1427
- [e.FLOAT64.toString(), I.BIT64],
1428
- [e.INT8.toString(), I.BIT8],
1429
- [e.INT16.toString(), I.BIT16],
1430
- [e.INT32.toString(), I.BIT32],
1431
- [e.INT64.toString(), I.BIT64],
1432
- [e.TIMESTAMP.toString(), I.BIT64],
1433
- [e.STRING.toString(), I.UNKNOWN],
1434
- [e.JSON.toString(), I.UNKNOWN],
1435
- [e.UUID.toString(), I.BIT128],
1436
- [e.BYTES.toString(), I.UNKNOWN]
1455
+ [e.UINT8.toString(), L.BIT8],
1456
+ [e.UINT16.toString(), L.BIT16],
1457
+ [e.UINT32.toString(), L.BIT32],
1458
+ [e.UINT64.toString(), L.BIT64],
1459
+ [e.FLOAT32.toString(), L.BIT32],
1460
+ [e.FLOAT64.toString(), L.BIT64],
1461
+ [e.INT8.toString(), L.BIT8],
1462
+ [e.INT16.toString(), L.BIT16],
1463
+ [e.INT32.toString(), L.BIT32],
1464
+ [e.INT64.toString(), L.BIT64],
1465
+ [e.TIMESTAMP.toString(), L.BIT64],
1466
+ [e.STRING.toString(), L.UNKNOWN],
1467
+ [e.JSON.toString(), L.UNKNOWN],
1468
+ [e.UUID.toString(), L.BIT128],
1469
+ [e.BYTES.toString(), L.UNKNOWN]
1437
1470
  ]);
1438
1471
  static ALL = [
1439
1472
  e.UNKNOWN,
@@ -1476,7 +1509,7 @@ var gt = 365, N = 30, _t = t.union([
1476
1509
  e.TIMESTAMP
1477
1510
  ];
1478
1511
  static z = t.union([t.string().transform((t) => new e(t)), t.instanceof(e)]);
1479
- }, z = class e extends C {
1512
+ }, B = class e extends C {
1480
1513
  constructor(e) {
1481
1514
  S(e) && (e = e.value), super(e.valueOf());
1482
1515
  }
@@ -1487,16 +1520,16 @@ var gt = 365, N = 30, _t = t.union([
1487
1520
  return S(e) && (e = e.value), this.valueOf() < e.valueOf();
1488
1521
  }
1489
1522
  add(t) {
1490
- return S(t) && (t = t.value), new e(k(this.valueOf(), t.valueOf()));
1523
+ return S(t) && (t = t.value), new e(O(this.valueOf(), t.valueOf()));
1491
1524
  }
1492
1525
  sub(t) {
1493
- return S(t) && (t = t.value), new e(O(this.valueOf(), t.valueOf()));
1526
+ return S(t) && (t = t.value), new e(D(this.valueOf(), t.valueOf()));
1494
1527
  }
1495
1528
  mult(t) {
1496
- return new e(A(this.valueOf(), t));
1529
+ return new e(k(this.valueOf(), t));
1497
1530
  }
1498
1531
  div(t) {
1499
- return new e(j(this.valueOf(), t));
1532
+ return new e(A(this.valueOf(), t));
1500
1533
  }
1501
1534
  truncate(t) {
1502
1535
  return new e(Math.trunc(this.valueOf() / new e(t).valueOf()) * new e(t).valueOf());
@@ -1561,13 +1594,13 @@ t.object({
1561
1594
  t.instanceof(Int32Array),
1562
1595
  t.instanceof(BigInt64Array)
1563
1596
  ]);
1564
- var bt = (e) => {
1597
+ var Et = (e) => {
1565
1598
  let t = typeof e;
1566
1599
  return t === "string" || t === "number" || t === "boolean" || t === "bigint" || e instanceof P || e instanceof F || e instanceof Date;
1567
- }, xt = (e, t, n, r = 0) => e.usesBigInt && !t.usesBigInt ? Number(n) - Number(r) : !e.usesBigInt && t.usesBigInt ? BigInt(n.valueOf()) - BigInt(r.valueOf()) : O(n, r);
1568
- L.z, P.z, F.z, yt.z, z.z, R.z, L.boundedZ;
1569
- var St = (e, t = !1) => {
1570
- let n = we(e) ? "stringer" : typeof e, r;
1600
+ }, Dt = (e, t, n, r = 0) => e.usesBigInt && !t.usesBigInt ? Number(BigInt(n.valueOf()) - BigInt(r.valueOf())) : !e.usesBigInt && t.usesBigInt ? BigInt(n.valueOf()) - BigInt(r.valueOf()) : D(n, r);
1601
+ R.z, P.z, F.z, I.z, B.z, z.z, R.boundedZ;
1602
+ var Ot = (e, t = !1) => {
1603
+ let n = Ee(e) ? "stringer" : typeof e, r;
1571
1604
  switch (n) {
1572
1605
  case "string":
1573
1606
  r = (e, t) => e.localeCompare(t);
@@ -1589,75 +1622,73 @@ var St = (e, t = !1) => {
1589
1622
  break;
1590
1623
  default: return console.warn(`sortFunc: unknown type ${n}`), () => -1;
1591
1624
  }
1592
- return t ? Ct(r) : r;
1593
- }, Ct = (e) => (t, n) => e(n, t), wt = (e, t = 21) => (n = t) => {
1625
+ return t ? kt(r) : r;
1626
+ }, kt = (e) => (t, n) => e(n, t), At = (e, t = 21) => (n = t) => {
1594
1627
  let r = "", i = n | 0;
1595
1628
  for (; i--;) r += e[Math.random() * e.length | 0];
1596
1629
  return r;
1597
- }, Tt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", Et = `0123456789${Tt}`, Dt = wt(Tt, 1), Ot = wt(Et, 10), kt = () => `${Dt()}${Ot()}`, At = (e, t) => (n) => n instanceof t || typeof n == "object" && !!n && "discriminator" in n && n.discriminator === e;
1598
- t.object({
1599
- x: nt.or(at),
1600
- y: rt.or(at)
1630
+ }, jt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", Mt = `0123456789${jt}`, Nt = At(jt, 1), Pt = At(Mt, 10), Ft = () => `${Nt()}${Pt()}`, It = (e, t) => (n) => n instanceof t || typeof n == "object" && !!n && "discriminator" in n && n.discriminator === e;
1631
+ e.enum([
1632
+ "x",
1633
+ "y",
1634
+ ...at,
1635
+ ...st
1636
+ ]);
1637
+ var Lt = lt;
1638
+ t.union([
1639
+ ot,
1640
+ t.enum([...at, ...st]),
1641
+ t.instanceof(String)
1642
+ ]), t.object({
1643
+ x: nt.or(ct),
1644
+ y: rt.or(ct)
1601
1645
  });
1602
- var jt = t.object({
1603
- x: nt,
1604
- y: rt
1605
- }), Mt = Object.freeze({
1646
+ var Rt = Object.freeze({
1606
1647
  x: "left",
1607
1648
  y: "top"
1608
- }), Nt = Object.freeze({
1649
+ }), zt = Object.freeze({
1609
1650
  x: "right",
1610
1651
  y: "top"
1611
- }), Pt = Object.freeze({
1652
+ }), Bt = Object.freeze({
1612
1653
  x: "left",
1613
1654
  y: "bottom"
1614
- }), Ft = Object.freeze({
1655
+ }), Vt = Object.freeze({
1615
1656
  x: "right",
1616
1657
  y: "bottom"
1617
- }), It = Object.freeze({
1658
+ }), Ht = Object.freeze({
1618
1659
  x: "center",
1619
1660
  y: "center"
1620
- }), Lt = Object.freeze({
1661
+ }), Ut = Object.freeze({
1621
1662
  x: "center",
1622
1663
  y: "top"
1623
- }), Rt = Object.freeze({
1664
+ }), Wt = Object.freeze({
1624
1665
  x: "center",
1625
1666
  y: "bottom"
1626
- }), zt = Object.freeze({
1667
+ }), Gt = Object.freeze({
1627
1668
  x: "right",
1628
1669
  y: "center"
1629
- }), Bt = Object.freeze({
1670
+ }), Kt = Object.freeze({
1630
1671
  x: "left",
1631
1672
  y: "center"
1632
1673
  });
1633
1674
  Object.freeze([
1634
- Bt,
1635
- zt,
1636
- Lt,
1675
+ Kt,
1676
+ Gt,
1677
+ Ut,
1678
+ Wt,
1637
1679
  Rt,
1638
- Mt,
1639
- Nt,
1640
- Pt,
1641
- Ft,
1642
- It
1643
- ]);
1644
- var Vt = (e, t) => e.x === t.x && e.y === t.y, Ht = (e) => [e.x, e.y];
1645
- t.enum([
1646
- "top",
1647
- "right",
1648
- "bottom",
1649
- "left"
1680
+ zt,
1681
+ Bt,
1682
+ Vt,
1683
+ Ht
1650
1684
  ]);
1651
- var B = t.object({
1652
- x: t.number(),
1653
- y: t.number()
1654
- }), Ut = t.union([
1685
+ var qt = (e, t) => e.x === t.x && e.y === t.y, Jt = (e) => [e.x, e.y], Yt = t.union([
1655
1686
  t.number(),
1656
- B,
1657
- Qe,
1658
- st,
1659
- ct,
1660
- ot
1687
+ j,
1688
+ ht,
1689
+ dt,
1690
+ ft,
1691
+ pt
1661
1692
  ]), V = (e, t) => {
1662
1693
  if (typeof e == "string") {
1663
1694
  if (t === void 0) throw Error("The y coordinate must be given.");
@@ -1702,22 +1733,22 @@ Object.freeze({
1702
1733
  x: NaN,
1703
1734
  y: NaN
1704
1735
  });
1705
- var Wt = (e, t) => {
1736
+ var Xt = (e, t) => {
1706
1737
  let n = V(e);
1707
1738
  return {
1708
1739
  x: n.x + t,
1709
1740
  y: n.y
1710
1741
  };
1711
- }, Gt = (e, t) => {
1742
+ }, Zt = (e, t) => {
1712
1743
  let n = V(e);
1713
1744
  return {
1714
1745
  x: n.x,
1715
1746
  y: n.y + t
1716
1747
  };
1717
- }, Kt = (e, t, n, ...r) => {
1748
+ }, Qt = (e, t, n, ...r) => {
1718
1749
  if (typeof t == "string") {
1719
1750
  if (typeof n != "number") throw Error("The value must be a number.");
1720
- return t === "x" ? Wt(e, n) : Gt(e, n);
1751
+ return t === "x" ? Xt(e, n) : Zt(e, n);
1721
1752
  }
1722
1753
  if (typeof t == "object" && "x" in t && typeof t.x == "string") {
1723
1754
  let r = V(n), i = V(e);
@@ -1750,15 +1781,15 @@ t.object({
1750
1781
  right: t.number(),
1751
1782
  bottom: t.number()
1752
1783
  }), t.object({
1753
- one: B,
1754
- two: B,
1755
- root: jt
1784
+ one: j,
1785
+ two: j,
1786
+ root: Lt
1756
1787
  });
1757
1788
  var W = (e, t, n = 0, r = 0, i) => {
1758
1789
  let a = {
1759
1790
  one: { ...H },
1760
1791
  two: { ...H },
1761
- root: i ?? Mt
1792
+ root: i ?? Rt
1762
1793
  };
1763
1794
  if (typeof e == "number") {
1764
1795
  if (typeof t != "number") throw Error("Box constructor called with invalid arguments");
@@ -1792,64 +1823,64 @@ var W = (e, t, n = 0, r = 0, i) => {
1792
1823
  x: a.one.x + t.signedWidth,
1793
1824
  y: a.one.y + t.signedHeight
1794
1825
  } : a.two = t, a));
1795
- }, qt = (e, t) => {
1826
+ }, $t = (e, t) => {
1796
1827
  let n = W(e);
1797
1828
  return {
1798
- x: t.x === "center" ? Qt(n).x : Jt(n, t.x),
1799
- y: t.y === "center" ? Qt(n).y : Jt(n, t.y)
1829
+ x: t.x === "center" ? an(n).x : en(n, t.x),
1830
+ y: t.y === "center" ? an(n).y : en(n, t.y)
1800
1831
  };
1801
- }, Jt = (e, t) => {
1802
- let n = W(e), r = Ht(n.root).includes(t) ? Math.min : Math.max;
1832
+ }, en = (e, t) => {
1833
+ let n = W(e), r = Jt(n.root).includes(t) ? Math.min : Math.max;
1803
1834
  return tt.includes(t) ? r(n.one.x, n.two.x) : r(n.one.y, n.two.y);
1804
- }, Yt = (e) => {
1835
+ }, tn = (e) => {
1805
1836
  let t = W(e);
1806
1837
  return t.two.x - t.one.x;
1807
- }, Xt = (e) => {
1838
+ }, nn = (e) => {
1808
1839
  let t = W(e);
1809
1840
  return t.two.y - t.one.y;
1810
- }, Zt = (e) => qt(e, Mt), Qt = (e) => Kt(Zt(e), {
1811
- x: Yt(e) / 2,
1812
- y: Xt(e) / 2
1813
- }), $t = (e) => {
1841
+ }, rn = (e) => $t(e, Rt), an = (e) => Qt(rn(e), {
1842
+ x: tn(e) / 2,
1843
+ y: nn(e) / 2
1844
+ }), on = (e) => {
1814
1845
  let t = W(e);
1815
1846
  return {
1816
1847
  lower: t.one.x,
1817
1848
  upper: t.two.x
1818
1849
  };
1819
- }, en = (e) => {
1850
+ }, sn = (e) => {
1820
1851
  let t = W(e);
1821
1852
  return {
1822
1853
  lower: t.one.y,
1823
1854
  upper: t.two.y
1824
1855
  };
1825
- }, tn = (e) => typeof e != "object" || !e ? !1 : "one" in e && "two" in e && "root" in e;
1856
+ }, cn = (e) => typeof e != "object" || !e ? !1 : "one" in e && "two" in e && "root" in e;
1826
1857
  t.union([
1827
- st,
1828
- ct,
1829
- B,
1830
- Qe
1858
+ dt,
1859
+ ft,
1860
+ j,
1861
+ ht
1831
1862
  ]);
1832
- var nn = (e, t, n) => t !== void 0 && e < t ? t : n !== void 0 && e > n ? n : e;
1863
+ var ln = (e, t, n) => t !== void 0 && e < t ? t : n !== void 0 && e > n ? n : e;
1833
1864
  t.object({
1834
- offset: Ut,
1835
- scale: Ut
1865
+ offset: Yt,
1866
+ scale: Yt
1836
1867
  }), t.object({
1837
1868
  offset: t.number(),
1838
1869
  scale: t.number()
1839
1870
  });
1840
- var rn = (e) => (t, n, r, i) => n === "dimension" ? [t, r] : [t, i ? r - e : r + e], an = (e) => (t, n, r, i) => [t, i ? r / e : r * e], on = (e) => (t, n, r) => {
1871
+ var un = (e) => (t, n, r, i) => n === "dimension" ? [t, r] : [t, i ? r - e : r + e], dn = (e) => (t, n, r, i) => [t, i ? r / e : r * e], fn = (e) => (t, n, r) => {
1841
1872
  if (t === null) return [e, r];
1842
1873
  let { lower: i, upper: a } = t, { lower: o, upper: s } = e, c = a - i, l = s - o;
1843
1874
  return n === "dimension" ? [e, l / c * r] : [e, (r - i) * (l / c) + o];
1844
- }, sn = (e) => (t, n, r) => [e, r], cn = () => (e, t, n) => {
1875
+ }, pn = (e) => (t, n, r) => [e, r], mn = () => (e, t, n) => {
1845
1876
  if (e === null) throw Error("cannot invert without bounds");
1846
1877
  if (t === "dimension") return [e, n];
1847
1878
  let { lower: r, upper: i } = e;
1848
1879
  return [e, i - (n - r)];
1849
- }, ln = (e) => (t, n, r) => {
1880
+ }, hn = (e) => (t, n, r) => {
1850
1881
  let { lower: i, upper: a } = e;
1851
- return r = nn(r, i, a), [t, r];
1852
- }, un = class e {
1882
+ return r = ln(r, i, a), [t, r];
1883
+ }, gn = class e {
1853
1884
  ops = [];
1854
1885
  currBounds = null;
1855
1886
  currType = null;
@@ -1867,27 +1898,27 @@ var rn = (e) => (t, n, r, i) => n === "dimension" ? [t, r] : [t, i ? r - e : r +
1867
1898
  return new e().scale(t, n);
1868
1899
  }
1869
1900
  translate(e) {
1870
- let t = this.new(), n = rn(e);
1901
+ let t = this.new(), n = un(e);
1871
1902
  return n.type = "translate", t.ops.push(n), t;
1872
1903
  }
1873
1904
  magnify(e) {
1874
- let t = this.new(), n = an(e);
1905
+ let t = this.new(), n = dn(e);
1875
1906
  return n.type = "magnify", t.ops.push(n), t;
1876
1907
  }
1877
1908
  scale(e, t) {
1878
- let n = M(e, t), r = this.new(), i = on(n);
1909
+ let n = M(e, t), r = this.new(), i = fn(n);
1879
1910
  return i.type = "scale", r.ops.push(i), r;
1880
1911
  }
1881
1912
  clamp(e, t) {
1882
- let n = M(e, t), r = this.new(), i = ln(n);
1913
+ let n = M(e, t), r = this.new(), i = hn(n);
1883
1914
  return i.type = "clamp", r.ops.push(i), r;
1884
1915
  }
1885
1916
  reBound(e, t) {
1886
- let n = M(e, t), r = this.new(), i = sn(n);
1917
+ let n = M(e, t), r = this.new(), i = pn(n);
1887
1918
  return i.type = "re-bound", r.ops.push(i), r;
1888
1919
  }
1889
1920
  invert() {
1890
- let e = cn();
1921
+ let e = mn();
1891
1922
  e.type = "invert";
1892
1923
  let t = this.new();
1893
1924
  return t.ops.push(e), t;
@@ -1930,7 +1961,7 @@ var rn = (e) => (t, n, r, i) => n === "dimension" ? [t, r] : [t, i ? r - e : r +
1930
1961
  x;
1931
1962
  y;
1932
1963
  currRoot;
1933
- constructor(e = new un(), t = new un(), n = null) {
1964
+ constructor(e = new gn(), t = new gn(), n = null) {
1934
1965
  this.x = e, this.y = t, this.currRoot = n;
1935
1966
  }
1936
1967
  static translate(t, n) {
@@ -1972,19 +2003,19 @@ var rn = (e) => (t, n, r, i) => n === "dimension" ? [t, r] : [t, i ? r - e : r +
1972
2003
  }
1973
2004
  scale(e) {
1974
2005
  let t = this.copy();
1975
- if (tn(e)) {
2006
+ if (cn(e)) {
1976
2007
  let n = this.currRoot;
1977
- return t.currRoot = e.root, n != null && !Vt(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($t(e)), t.y = t.y.scale(en(e)), t;
2008
+ return t.currRoot = e.root, n != null && !qt(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(on(e)), t.y = t.y.scale(sn(e)), t;
1978
2009
  }
1979
2010
  return t.x = t.x.scale(e.width), t.y = t.y.scale(e.height), t;
1980
2011
  }
1981
2012
  reBound(e) {
1982
2013
  let t = this.copy();
1983
- return t.x = this.x.reBound($t(e)), t.y = this.y.reBound(en(e)), t;
2014
+ return t.x = this.x.reBound(on(e)), t.y = this.y.reBound(sn(e)), t;
1984
2015
  }
1985
2016
  clamp(e) {
1986
2017
  let t = this.copy();
1987
- return t.x = this.x.clamp($t(e)), t.y = this.y.clamp(en(e)), t;
2018
+ return t.x = this.x.clamp(on(e)), t.y = this.y.clamp(sn(e)), t;
1988
2019
  }
1989
2020
  copy() {
1990
2021
  let t = new e();
@@ -2022,48 +2053,49 @@ var rn = (e) => (t, n, r, i) => n === "dimension" ? [t, r] : [t, i ? r - e : r +
2022
2053
  };
2023
2054
  }
2024
2055
  static IDENTITY = new e();
2025
- }), B.extend({
2026
- root: jt,
2027
- units: e.object({
2028
- x: e.enum(["px", "decimal"]),
2029
- y: e.enum(["px", "decimal"])
2030
- })
2031
- }).partial({
2056
+ }), mt.required({
2032
2057
  root: !0,
2033
2058
  units: !0
2034
2059
  });
2035
- var dn = t.enum(["static", "dynamic"]), fn = /^(?:[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;
2036
- function pn(e) {
2037
- return typeof e == "string" && fn.test(e);
2060
+ var _n = t.enum(["static", "dynamic"]), vn = /^(?:[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;
2061
+ function yn(e) {
2062
+ return typeof e == "string" && vn.test(e);
2038
2063
  }
2039
2064
  var G = [];
2040
2065
  for (let e = 0; e < 256; ++e) G.push((e + 256).toString(16).slice(1));
2041
- function mn(e, t = 0) {
2066
+ function bn(e, t = 0) {
2042
2067
  return (G[e[t + 0]] + G[e[t + 1]] + G[e[t + 2]] + G[e[t + 3]] + "-" + G[e[t + 4]] + G[e[t + 5]] + "-" + G[e[t + 6]] + G[e[t + 7]] + "-" + G[e[t + 8]] + G[e[t + 9]] + "-" + G[e[t + 10]] + G[e[t + 11]] + G[e[t + 12]] + G[e[t + 13]] + G[e[t + 14]] + G[e[t + 15]]).toLowerCase();
2043
2068
  }
2044
- function hn(e, t = 0) {
2045
- let n = mn(e, t);
2046
- if (!pn(n)) throw TypeError("Stringified UUID is invalid");
2069
+ function xn(e, t = 0) {
2070
+ let n = bn(e, t);
2071
+ if (!yn(n)) throw TypeError("Stringified UUID is invalid");
2047
2072
  return n;
2048
2073
  }
2049
- typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
2050
- var gn = (e, t) => hn(e, t), K = -1, _n = {
2051
- [Symbol.iterator]: () => _n,
2074
+ var Sn = (e, t) => xn(e, t), Cn = (e) => {
2075
+ let t = Math.fround(e);
2076
+ if (!Number.isFinite(t)) return t.toString();
2077
+ for (let e = 1; e <= 9; e++) {
2078
+ let n = parseFloat(t.toPrecision(e));
2079
+ if (Math.fround(n) === t) return n.toString();
2080
+ }
2081
+ return t.toString();
2082
+ }, K = -1, wn = {
2083
+ [Symbol.iterator]: () => wn,
2052
2084
  next: () => ({
2053
2085
  done: !0,
2054
2086
  value: void 0
2055
2087
  })
2056
- }, vn = t.string().transform((e) => new Uint8Array(atob(e).split("").map((e) => e.charCodeAt(0))).buffer), yn = t.union([t.null(), t.undefined()]).transform(() => new Uint8Array().buffer), q = 4, bn = (e, t) => {
2088
+ }, Tn = t.string().transform((e) => new Uint8Array(atob(e).split("").map((e) => e.charCodeAt(0))).buffer), En = t.union([t.null(), t.undefined()]).transform(() => new Uint8Array().buffer), q = 4, Dn = (e, t) => {
2057
2089
  if (e === "number" && !t.isNumeric) throw Error(`cannot convert series of type ${t.toString()} to number`);
2058
2090
  if (e === "bigint" && !t.usesBigInt) throw Error(`cannot convert series of type ${t.toString()} to bigint`);
2059
- }, xn = "sy_x_telem_series", Sn = class e {
2091
+ }, On = "sy_x_telem_series", kn = class e {
2060
2092
  key;
2061
- discriminator = xn;
2093
+ discriminator = On;
2062
2094
  dataType;
2063
2095
  sampleOffset;
2064
2096
  gl;
2065
2097
  _data;
2066
- timeRange = L.ZERO;
2098
+ timeRange = R.ZERO;
2067
2099
  alignment = 0n;
2068
2100
  alignmentMultiple = 1n;
2069
2101
  cachedMin;
@@ -2073,28 +2105,28 @@ var gn = (e, t) => hn(e, t), K = -1, _n = {
2073
2105
  cachedLength;
2074
2106
  _cachedIndexes;
2075
2107
  static crudeZ = t.object({
2076
- timeRange: L.z.optional(),
2077
- dataType: R.z,
2108
+ timeRange: R.z.optional(),
2109
+ dataType: z.z,
2078
2110
  alignment: t.coerce.bigint().optional(),
2079
2111
  data: t.union([
2080
- vn,
2081
- yn,
2112
+ Tn,
2113
+ En,
2082
2114
  t.instanceof(ArrayBuffer),
2083
2115
  t.instanceof(Uint8Array)
2084
- ]),
2085
- glBufferUsage: dn.default("static").optional()
2116
+ ]).default(() => new Uint8Array().buffer),
2117
+ glBufferUsage: _n.default("static").optional()
2086
2118
  });
2087
2119
  static z = e.crudeZ.transform((t) => new e(t));
2088
2120
  constructor(e) {
2089
- Cn(e) && (e = { data: e }), e.data ??= [];
2090
- let { dataType: t, timeRange: n, sampleOffset: r = 0, glBufferUsage: i = "static", alignment: a = 0n, alignmentMultiple: o = 1n, key: s = kt(), data: c } = e;
2091
- if (wn(c)) {
2121
+ An(e) && (e = { data: e }), e.data ??= [];
2122
+ let { dataType: t, timeRange: n, sampleOffset: r = 0, glBufferUsage: i = "static", alignment: a = 0n, alignmentMultiple: o = 1n, key: s = Ft(), data: c } = e;
2123
+ if (jn(c)) {
2092
2124
  let e = c;
2093
2125
  this.key = e.key, this.dataType = e.dataType, this.sampleOffset = e.sampleOffset, this.gl = e.gl, this._data = e._data, this.timeRange = e.timeRange, this.alignment = e.alignment, this.alignmentMultiple = e.alignmentMultiple, this.cachedMin = e.cachedMin, this.cachedMax = e.cachedMax, this.writePos = e.writePos, this._refCount = e._refCount, this.cachedLength = e.cachedLength;
2094
2126
  return;
2095
2127
  }
2096
- let l = bt(c), u = Array.isArray(c);
2097
- if (t != null) this.dataType = new R(t);
2128
+ let l = Et(c), u = Array.isArray(c);
2129
+ if (t != null) this.dataType = new z(t);
2098
2130
  else if (c instanceof ArrayBuffer) throw Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");
2099
2131
  else if (u || l) {
2100
2132
  let e = c;
@@ -2102,31 +2134,31 @@ var gn = (e, t) => hn(e, t), K = -1, _n = {
2102
2134
  if (c.length === 0) throw Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");
2103
2135
  e = c[0];
2104
2136
  }
2105
- if (typeof e == "string") this.dataType = R.STRING;
2106
- else if (typeof e == "number") this.dataType = R.FLOAT64;
2107
- else if (typeof e == "bigint") this.dataType = R.INT64;
2108
- else if (typeof e == "boolean") this.dataType = R.UINT8;
2109
- else if (e instanceof P || e instanceof Date || e instanceof P) this.dataType = R.TIMESTAMP;
2110
- else if (typeof e == "object") this.dataType = R.JSON;
2137
+ if (typeof e == "string") this.dataType = z.STRING;
2138
+ else if (typeof e == "number") this.dataType = z.FLOAT64;
2139
+ else if (typeof e == "bigint") this.dataType = z.INT64;
2140
+ else if (typeof e == "boolean") this.dataType = z.UINT8;
2141
+ else if (e instanceof P || e instanceof Date || e instanceof P) this.dataType = z.TIMESTAMP;
2142
+ else if (typeof e == "object") this.dataType = z.JSON;
2111
2143
  else throw Error(`cannot infer data type of ${typeof e} when constructing a Series from a JS array`);
2112
- } else this.dataType = new R(c);
2144
+ } else this.dataType = new z(c);
2113
2145
  if (!u && !l) this._data = c;
2114
2146
  else if (u && c.length === 0) this._data = new this.dataType.Array([]).buffer;
2115
2147
  else {
2116
2148
  let e = l ? [c] : c, t = e[0];
2117
- if ((t instanceof P || t instanceof Date || t instanceof F) && (e = e.map((e) => new P(e).valueOf())), this.dataType.equals(R.STRING)) {
2149
+ if ((t instanceof P || t instanceof Date || t instanceof F) && (e = e.map((e) => new P(e).valueOf())), this.dataType.equals(z.STRING)) {
2118
2150
  this.cachedLength = e.length;
2119
2151
  let t = e.map((e) => new TextEncoder().encode(e)), n = t.reduce((e, t) => e + q + t.byteLength, 0), r = new ArrayBuffer(n), i = new DataView(r), a = new Uint8Array(r), o = 0;
2120
2152
  for (let e of t) i.setUint32(o, e.byteLength, !0), o += q, a.set(e, o), o += e.byteLength;
2121
2153
  this._data = r;
2122
- } else if (this.dataType.equals(R.JSON)) {
2154
+ } else if (this.dataType.equals(z.JSON)) {
2123
2155
  this.cachedLength = e.length;
2124
- let t = e.map((e) => new TextEncoder().encode(ht.encodeString(e))), n = t.reduce((e, t) => e + q + t.byteLength, 0), r = new ArrayBuffer(n), i = new DataView(r), a = new Uint8Array(r), o = 0;
2156
+ let t = e.map((e) => new TextEncoder().encode(St.encodeString(e))), n = t.reduce((e, t) => e + q + t.byteLength, 0), r = new ArrayBuffer(n), i = new DataView(r), a = new Uint8Array(r), o = 0;
2125
2157
  for (let e of t) i.setUint32(o, e.byteLength, !0), o += q, a.set(e, o), o += e.byteLength;
2126
2158
  this._data = r;
2127
2159
  } else this.dataType.usesBigInt && typeof t == "number" ? this._data = new this.dataType.Array(e.map((e) => BigInt(Math.round(e)))).buffer : !this.dataType.usesBigInt && typeof t == "bigint" ? this._data = new this.dataType.Array(e.map(Number)).buffer : this._data = new this.dataType.Array(e).buffer;
2128
2160
  }
2129
- this.key = s, this.alignment = a, this.alignmentMultiple = o, this.sampleOffset = r ?? 0, this.timeRange = n ?? L.ZERO, this.gl = {
2161
+ this.key = s, this.alignment = a, this.alignmentMultiple = o, this.sampleOffset = r ?? 0, this.timeRange = n ?? R.ZERO, this.gl = {
2130
2162
  control: null,
2131
2163
  buffer: null,
2132
2164
  prevBuffer: 0,
@@ -2136,7 +2168,7 @@ var gn = (e, t) => hn(e, t), K = -1, _n = {
2136
2168
  static alloc({ capacity: t, dataType: n, ...r }) {
2137
2169
  if (t === 0) throw Error("[Series] - cannot allocate an array of length 0");
2138
2170
  let i = new e({
2139
- data: new new R(n).Array(t).buffer,
2171
+ data: new new z(n).Array(t).buffer,
2140
2172
  dataType: n,
2141
2173
  ...r
2142
2174
  });
@@ -2196,17 +2228,17 @@ var gn = (e, t) => hn(e, t), K = -1, _n = {
2196
2228
  return Array.from(this).map((e) => e.toString());
2197
2229
  }
2198
2230
  parseJSON(e) {
2199
- if (!this.dataType.equals(R.JSON)) throw Error("cannot parse non-JSON series as JSON");
2200
- return this.toStrings().map((t) => e.parse(ht.decodeString(t)));
2231
+ if (!this.dataType.equals(z.JSON)) throw Error("cannot parse non-JSON series as JSON");
2232
+ return this.toStrings().map((t) => e.parse(St.decodeString(t)));
2201
2233
  }
2202
2234
  get byteCapacity() {
2203
- return new z(this.underlyingData.byteLength);
2235
+ return new B(this.underlyingData.byteLength);
2204
2236
  }
2205
2237
  get capacity() {
2206
2238
  return this.dataType.isVariable ? this.byteCapacity.valueOf() : this.dataType.density.length(this.byteCapacity);
2207
2239
  }
2208
2240
  get byteLength() {
2209
- return this.writePos === K ? this.byteCapacity : this.dataType.isVariable ? new z(this.writePos) : this.dataType.density.size(this.writePos);
2241
+ return this.writePos === K ? this.byteCapacity : this.dataType.isVariable ? new B(this.writePos) : this.dataType.density.size(this.writePos);
2210
2242
  }
2211
2243
  get length() {
2212
2244
  return this.cachedLength == null ? this.dataType.isVariable ? this.calculateCachedLength() : this.writePos === K ? this.byteCapacity.valueOf() / this.dataType.density.valueOf() : this.writePos : this.cachedLength;
@@ -2223,7 +2255,7 @@ var gn = (e, t) => hn(e, t), K = -1, _n = {
2223
2255
  convert(t, n = 0) {
2224
2256
  if (this.dataType.equals(t)) return this;
2225
2257
  let r = new t.Array(this.length);
2226
- for (let e = 0; e < this.length; e++) r[e] = xt(this.dataType, t, this.data[e], n);
2258
+ for (let e = 0; e < this.length; e++) r[e] = Dt(this.dataType, t, this.data[e], n);
2227
2259
  return new e({
2228
2260
  data: r.buffer,
2229
2261
  dataType: t,
@@ -2234,24 +2266,42 @@ var gn = (e, t) => hn(e, t), K = -1, _n = {
2234
2266
  });
2235
2267
  }
2236
2268
  calcRawMax() {
2237
- return this.length === 0 ? -Infinity : (this.dataType.equals(R.TIMESTAMP) ? this.cachedMax = this.data[this.data.length - 1] : (this.dataType.usesBigInt, this.cachedMax = this.data.reduce((e, t) => e > t ? e : t)), this.cachedMax);
2269
+ if (this.length === 0) return -Infinity;
2270
+ if (this.dataType.equals(z.TIMESTAMP)) this.cachedMax = this.data[this.data.length - 1];
2271
+ else if (this.dataType.usesBigInt) {
2272
+ let e = this.data;
2273
+ this.cachedMax = e.reduce((e, t) => e > t ? e : t);
2274
+ } else {
2275
+ let e = this.data;
2276
+ this.cachedMax = e.reduce((e, t) => e > t ? e : t);
2277
+ }
2278
+ return this.cachedMax;
2238
2279
  }
2239
2280
  get max() {
2240
2281
  return this.calcMax();
2241
2282
  }
2242
2283
  calcMax() {
2243
2284
  if (this.dataType.isVariable) throw Error("cannot calculate maximum on a variable length data type");
2244
- return this.writePos === 0 ? -Infinity : (this.cachedMax ??= this.calcRawMax(), k(this.cachedMax, this.sampleOffset));
2285
+ return this.writePos === 0 ? -Infinity : (this.cachedMax ??= this.calcRawMax(), this.applyOffset(this.cachedMax));
2245
2286
  }
2246
2287
  calcRawMin() {
2247
- return this.length === 0 ? Infinity : (this.dataType.equals(R.TIMESTAMP) ? this.cachedMin = this.data[0] : (this.dataType.usesBigInt, this.cachedMin = this.data.reduce((e, t) => e < t ? e : t)), this.cachedMin);
2288
+ if (this.length === 0) return Infinity;
2289
+ if (this.dataType.equals(z.TIMESTAMP)) this.cachedMin = this.data[0];
2290
+ else if (this.dataType.usesBigInt) {
2291
+ let e = this.data;
2292
+ this.cachedMin = e.reduce((e, t) => e < t ? e : t);
2293
+ } else {
2294
+ let e = this.data;
2295
+ this.cachedMin = e.reduce((e, t) => e < t ? e : t);
2296
+ }
2297
+ return this.cachedMin;
2248
2298
  }
2249
2299
  get min() {
2250
2300
  return this.calcMin();
2251
2301
  }
2252
2302
  calcMin() {
2253
2303
  if (this.dataType.isVariable) throw Error("cannot calculate minimum on a variable length data type");
2254
- return this.writePos === 0 ? Infinity : (this.cachedMin ??= this.calcRawMin(), k(this.cachedMin, this.sampleOffset));
2304
+ return this.writePos === 0 ? Infinity : (this.cachedMin ??= this.calcRawMin(), this.applyOffset(this.cachedMin));
2255
2305
  }
2256
2306
  get bounds() {
2257
2307
  return M(Number(this.min), Number(this.max), { makeValid: !1 });
@@ -2275,25 +2325,37 @@ var gn = (e, t) => hn(e, t), K = -1, _n = {
2275
2325
  return this.at(n, t);
2276
2326
  }
2277
2327
  at(e, t = !1) {
2278
- if (this.dataType.isVariable) return this.atVariable(e, t ?? !1);
2279
- if (this.dataType.equals(R.UUID)) return this.atUUID(e, t);
2328
+ if (this.dataType.isVariable) {
2329
+ let n = this.atVariable(e, t);
2330
+ return n == null ? void 0 : this.dataType.equals(z.STRING) ? n : f(JSON.parse(n));
2331
+ }
2332
+ if (this.dataType.equals(z.UUID)) return this.atUUID(e, t);
2280
2333
  e < 0 && (e = this.length + e);
2281
2334
  let n = this.data[e];
2282
2335
  if (n == null) {
2283
2336
  if (t === !0) throw Error(`[series] - no value at index ${e}`);
2284
2337
  return;
2285
2338
  }
2286
- return k(n, this.sampleOffset);
2339
+ return this.applyOffset(n);
2340
+ }
2341
+ applyOffset(e) {
2342
+ return typeof this.sampleOffset == "bigint" && typeof e == "number" ? BigInt(Math.round(e)) + this.sampleOffset : O(e, this.sampleOffset);
2287
2343
  }
2288
2344
  atUUID(e, t) {
2289
2345
  e < 0 && (e = this.length + e);
2290
- let n = gn(new Uint8Array(this.buffer, e * this.dataType.density.valueOf()));
2346
+ let n = Sn(new Uint8Array(this.buffer, e * this.dataType.density.valueOf()));
2291
2347
  if (n == null) {
2292
2348
  if (t) throw Error(`[series] - no value at index ${e}`);
2293
2349
  return;
2294
2350
  }
2295
2351
  return n;
2296
2352
  }
2353
+ asString(e, t = !1) {
2354
+ if (this.dataType.isVariable) return this.atVariable(e, t);
2355
+ if (this.dataType.equals(z.UUID)) return this.atUUID(e, t);
2356
+ let n = this.at(e, t);
2357
+ if (n != null) return this.dataType.equals(z.FLOAT32) ? Cn(n) : String(n);
2358
+ }
2297
2359
  atVariable(e, t) {
2298
2360
  let n = 0, r = 0, i = this.buffer, a = new DataView(i);
2299
2361
  if (this._cachedIndexes != null) {
@@ -2319,10 +2381,10 @@ var gn = (e, t) => hn(e, t), K = -1, _n = {
2319
2381
  }
2320
2382
  }
2321
2383
  let o = new Uint8Array(i, n, r);
2322
- return this.dataType.equals(R.STRING) ? new TextDecoder().decode(o) : f(JSON.parse(new TextDecoder().decode(o)));
2384
+ return new TextDecoder().decode(o);
2323
2385
  }
2324
2386
  binarySearch(e) {
2325
- let t = 0, n = this.length - 1, r = St(e);
2387
+ let t = 0, n = this.length - 1, r = Ot(e);
2326
2388
  for (; t <= n;) {
2327
2389
  let i = Math.floor((t + n) / 2), a = r(this.at(i, !0), e);
2328
2390
  if (a === 0) return i;
@@ -2331,7 +2393,7 @@ var gn = (e, t) => hn(e, t), K = -1, _n = {
2331
2393
  return t;
2332
2394
  }
2333
2395
  updateGLBuffer(e) {
2334
- if (this.gl.control = e, !this.dataType.equals(R.FLOAT32) && !this.dataType.equals(R.UINT8)) throw Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");
2396
+ if (this.gl.control = e, !this.dataType.equals(z.FLOAT32) && !this.dataType.equals(z.UINT8)) throw Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");
2335
2397
  let { buffer: t, bufferUsage: n, prevBuffer: r } = this.gl;
2336
2398
  if (t ?? (this.gl.buffer = e.createBuffer()), this.writePos !== r) if (e.bindBuffer(e.ARRAY_BUFFER, this.gl.buffer), this.writePos !== K) {
2337
2399
  r === 0 && e.bufferData(e.ARRAY_BUFFER, this.byteCapacity.valueOf(), e.STATIC_DRAW);
@@ -2340,7 +2402,7 @@ var gn = (e, t) => hn(e, t), K = -1, _n = {
2340
2402
  } else e.bufferData(e.ARRAY_BUFFER, this.buffer, n === "static" ? e.STATIC_DRAW : e.DYNAMIC_DRAW), this.gl.prevBuffer = K;
2341
2403
  }
2342
2404
  as(e) {
2343
- return bn(e, this.dataType), this;
2405
+ return Dn(e, this.dataType), this;
2344
2406
  }
2345
2407
  get digest() {
2346
2408
  return {
@@ -2348,8 +2410,8 @@ var gn = (e, t) => hn(e, t), K = -1, _n = {
2348
2410
  dataType: this.dataType.toString(),
2349
2411
  sampleOffset: this.sampleOffset,
2350
2412
  alignment: {
2351
- lower: An(this.alignmentBounds.lower),
2352
- upper: An(this.alignmentBounds.upper),
2413
+ lower: Ln(this.alignmentBounds.lower),
2414
+ upper: Ln(this.alignmentBounds.upper),
2353
2415
  multiple: this.alignmentMultiple
2354
2416
  },
2355
2417
  timeRange: this.timeRange.toString(),
@@ -2369,10 +2431,10 @@ var gn = (e, t) => hn(e, t), K = -1, _n = {
2369
2431
  }
2370
2432
  [Symbol.iterator]() {
2371
2433
  if (this.dataType.isVariable) {
2372
- let e = new En(this);
2373
- return this.dataType.equals(R.JSON) ? new Dn(e) : e;
2434
+ let e = new Nn(this);
2435
+ return this.dataType.equals(z.JSON) ? new Pn(e) : e;
2374
2436
  }
2375
- return this.dataType.equals(R.UUID) ? new On(this) : new kn(this);
2437
+ return this.dataType.equals(z.UUID) ? new Fn(this) : new In(this);
2376
2438
  }
2377
2439
  slice(e, t) {
2378
2440
  return this.sliceSub(!1, e, t);
@@ -2381,11 +2443,11 @@ var gn = (e, t) => hn(e, t), K = -1, _n = {
2381
2443
  return this.sliceSub(!0, e, t);
2382
2444
  }
2383
2445
  subIterator(e, t) {
2384
- return new Tn(this, e, t ?? this.length);
2446
+ return new Mn(this, e, t ?? this.length);
2385
2447
  }
2386
2448
  subAlignmentIterator(e, t) {
2387
2449
  let n = Math.ceil(Number(e - this.alignment) / Number(this.alignmentMultiple)), r = Math.ceil(Number(t - this.alignment) / Number(this.alignmentMultiple));
2388
- return new Tn(this, n, r);
2450
+ return new Mn(this, n, r);
2389
2451
  }
2390
2452
  subBytes(t, n) {
2391
2453
  return t >= 0 && (n == null || n >= this.byteLength.valueOf()) ? this : new e({
@@ -2413,7 +2475,7 @@ var gn = (e, t) => hn(e, t), K = -1, _n = {
2413
2475
  return new e({
2414
2476
  data: this.buffer,
2415
2477
  dataType: this.dataType,
2416
- timeRange: L.ZERO,
2478
+ timeRange: R.ZERO,
2417
2479
  sampleOffset: this.sampleOffset,
2418
2480
  glBufferUsage: "static",
2419
2481
  alignment: t
@@ -2429,14 +2491,14 @@ var gn = (e, t) => hn(e, t), K = -1, _n = {
2429
2491
  }
2430
2492
  return e += "])", e;
2431
2493
  }
2432
- }, Cn = (e) => e == null ? !1 : Array.isArray(e) || e instanceof ArrayBuffer || ArrayBuffer.isView(e) && !(e instanceof DataView) || e instanceof Sn ? !0 : bt(e), wn = At(xn, Sn), Tn = class {
2494
+ }, An = (e) => e == null ? !1 : Array.isArray(e) || e instanceof ArrayBuffer || ArrayBuffer.isView(e) && !(e instanceof DataView) || e instanceof kn ? !0 : Et(e), jn = It(On, kn), Mn = class {
2433
2495
  series;
2434
2496
  end;
2435
2497
  index;
2436
2498
  constructor(e, t, n) {
2437
2499
  this.series = e;
2438
2500
  let r = M(0, e.length + 1);
2439
- this.end = ut(r, n), this.index = ut(r, t);
2501
+ this.end = _t(r, n), this.index = _t(r, t);
2440
2502
  }
2441
2503
  next() {
2442
2504
  return this.index >= this.end ? {
@@ -2447,7 +2509,7 @@ var gn = (e, t) => hn(e, t), K = -1, _n = {
2447
2509
  value: this.series.at(this.index++, !0)
2448
2510
  };
2449
2511
  }
2450
- }, En = class {
2512
+ }, Nn = class {
2451
2513
  series;
2452
2514
  byteOffset;
2453
2515
  decoder;
@@ -2470,7 +2532,7 @@ var gn = (e, t) => hn(e, t), K = -1, _n = {
2470
2532
  value: n
2471
2533
  };
2472
2534
  }
2473
- }, Dn = class e {
2535
+ }, Pn = class e {
2474
2536
  wrapped;
2475
2537
  static schema = t.record(t.string(), t.unknown());
2476
2538
  constructor(e) {
@@ -2483,30 +2545,30 @@ var gn = (e, t) => hn(e, t), K = -1, _n = {
2483
2545
  value: void 0
2484
2546
  } : {
2485
2547
  done: !1,
2486
- value: ht.decodeString(t.value, e.schema)
2548
+ value: St.decodeString(t.value, e.schema)
2487
2549
  };
2488
2550
  }
2489
- }, On = class {
2551
+ }, Fn = class {
2490
2552
  series;
2491
2553
  index;
2492
2554
  data;
2493
2555
  density;
2494
2556
  constructor(e) {
2495
- if (!e.dataType.equals(R.UUID)) throw Error("cannot create a UUID series iterator for a non-UUID series");
2496
- this.series = e, this.index = 0, this.data = new Uint8Array(e.buffer), this.density = R.UUID.density.valueOf();
2557
+ if (!e.dataType.equals(z.UUID)) throw Error("cannot create a UUID series iterator for a non-UUID series");
2558
+ this.series = e, this.index = 0, this.data = new Uint8Array(e.buffer), this.density = z.UUID.density.valueOf();
2497
2559
  }
2498
2560
  next() {
2499
2561
  if (this.index >= this.series.length) return {
2500
2562
  done: !0,
2501
2563
  value: void 0
2502
2564
  };
2503
- let e = gn(this.data, this.index * this.density);
2565
+ let e = Sn(this.data, this.index * this.density);
2504
2566
  return this.index++, {
2505
2567
  done: !1,
2506
2568
  value: e
2507
2569
  };
2508
2570
  }
2509
- }, kn = class {
2571
+ }, In = class {
2510
2572
  series;
2511
2573
  index;
2512
2574
  constructor(e) {
@@ -2521,13 +2583,23 @@ var gn = (e, t) => hn(e, t), K = -1, _n = {
2521
2583
  value: this.series.at(this.index++, !0)
2522
2584
  };
2523
2585
  }
2524
- }, An = (e) => ({
2586
+ }, Ln = (e) => ({
2525
2587
  domain: e >> 32n,
2526
2588
  sample: e & 4294967295n
2527
- }), jn = async (e) => await new Promise((t) => setTimeout(t, F.fromMilliseconds(e).milliseconds)), Mn = /* @__PURE__ */ r({
2528
- Breaker: () => Nn,
2529
- breakerConfigZ: () => Pn
2530
- }), Nn = class {
2589
+ });
2590
+ t.enum([
2591
+ "ISO",
2592
+ "ISODate",
2593
+ "time",
2594
+ "preciseTime",
2595
+ "date",
2596
+ "preciseDate",
2597
+ "dateTime"
2598
+ ]), t.enum(["local", "UTC"]);
2599
+ var Rn = async (e) => await new Promise((t) => setTimeout(t, F.fromMilliseconds(e).milliseconds)), zn = /* @__PURE__ */ r({
2600
+ Breaker: () => Bn,
2601
+ breakerConfigZ: () => Vn
2602
+ }), Bn = class {
2531
2603
  config;
2532
2604
  retries;
2533
2605
  interval;
@@ -2536,7 +2608,7 @@ var gn = (e, t) => hn(e, t), K = -1, _n = {
2536
2608
  baseInterval: new F(e?.baseInterval ?? F.seconds(1)),
2537
2609
  maxRetries: e?.maxRetries ?? 5,
2538
2610
  scale: e?.scale ?? 1,
2539
- sleepFn: e?.sleepFn ?? jn
2611
+ sleepFn: e?.sleepFn ?? Rn
2540
2612
  }, this.retries = 0, this.interval = new F(this.config.baseInterval);
2541
2613
  }
2542
2614
  async wait() {
@@ -2549,38 +2621,38 @@ var gn = (e, t) => hn(e, t), K = -1, _n = {
2549
2621
  reset() {
2550
2622
  this.retries = 0, this.interval = this.config.baseInterval;
2551
2623
  }
2552
- }, Pn = t.object({
2624
+ }, Vn = t.object({
2553
2625
  baseInterval: F.z.optional(),
2554
2626
  maxRetries: t.number().optional(),
2555
2627
  scale: t.number().optional()
2556
- }), Fn = t.string().regex(/^#?([0-9a-f]{6}|[0-9a-f]{8})$/i), J = dt, In = t.number().min(0).max(1), Ln = t.tuple([
2628
+ }), Hn = t.string().regex(/^#?([0-9a-f]{6}|[0-9a-f]{8})$/i), J = vt, Un = t.number().min(0).max(1), Wn = t.tuple([
2557
2629
  J,
2558
2630
  J,
2559
2631
  J,
2560
- In
2561
- ]), Rn = t.tuple([
2632
+ Un
2633
+ ]), Gn = t.tuple([
2562
2634
  J,
2563
2635
  J,
2564
2636
  J
2565
- ]), zn = t.object({ rgba255: Ln }), Bn = t.object({
2637
+ ]), Kn = t.object({ rgba255: Wn }), qn = t.object({
2566
2638
  r: J,
2567
2639
  g: J,
2568
2640
  b: J,
2569
- a: In
2570
- }), Vn = t.number().min(0).max(360), Hn = t.number().min(0).max(100), Un = t.number().min(0).max(100), Wn = t.tuple([
2571
- Vn,
2641
+ a: Un
2642
+ }), Jn = t.number().min(0).max(360), Yn = t.number().min(0).max(100), Xn = t.number().min(0).max(100), Zn = t.tuple([
2643
+ Jn,
2644
+ Yn,
2645
+ Xn,
2646
+ Un
2647
+ ]), Qn = t.union([
2572
2648
  Hn,
2573
- Un,
2574
- In
2575
- ]), Gn = t.union([
2576
- Fn,
2577
- Rn,
2578
- Ln,
2649
+ Gn,
2579
2650
  Wn,
2580
- zn,
2581
- Bn
2582
- ]), Kn = Gn.transform((e) => qn(e)), qn = (e, t = 1) => {
2583
- if (e = Gn.parse(e), typeof e == "string") return Jn(e, t);
2651
+ Zn,
2652
+ Kn,
2653
+ qn
2654
+ ]), $n = Qn.transform((e) => er(e)), er = (e, t = 1) => {
2655
+ if (e = Qn.parse(e), typeof e == "string") return tr(e, t);
2584
2656
  if (Array.isArray(e)) {
2585
2657
  if (e.length < 3 || e.length > 4) throw Error(`Invalid color: [${e.join(", ")}]`);
2586
2658
  return e.length === 3 ? [...e, t] : e;
@@ -2591,34 +2663,34 @@ var gn = (e, t) => hn(e, t), K = -1, _n = {
2591
2663
  e.b,
2592
2664
  e.a
2593
2665
  ] : e.rgba255;
2594
- }, Jn = (e, t = 1) => (e = Fn.parse(e), e = Yn(e), [
2666
+ }, tr = (e, t = 1) => (e = Hn.parse(e), e = nr(e), [
2595
2667
  Y(e, 0),
2596
2668
  Y(e, 2),
2597
2669
  Y(e, 4),
2598
2670
  e.length === 8 ? Y(e, 6) / 255 : t
2599
- ]), Y = (e, t) => parseInt(e.slice(t, t + 2), 16), Yn = (e) => e.startsWith("#") ? e.slice(1) : e;
2600
- qn("#000000"), qn("#ffffff");
2601
- var Xn = t.object({
2671
+ ]), Y = (e, t) => parseInt(e.slice(t, t + 2), 16), nr = (e) => e.startsWith("#") ? e.slice(1) : e;
2672
+ er("#000000"), er("#ffffff");
2673
+ var rr = t.object({
2602
2674
  key: t.string(),
2603
- color: Gn,
2675
+ color: Qn,
2604
2676
  position: t.number(),
2605
2677
  switched: t.boolean().optional()
2606
2678
  });
2607
- t.array(Xn);
2608
- var Zn = t.object({
2679
+ t.array(rr);
2680
+ var ir = t.object({
2609
2681
  key: t.string(),
2610
2682
  name: t.string(),
2611
- color: Kn
2683
+ color: $n
2612
2684
  });
2613
2685
  t.object({
2614
2686
  key: t.string(),
2615
2687
  name: t.string(),
2616
- swatches: t.array(Zn)
2688
+ swatches: t.array(ir)
2617
2689
  });
2618
- var Qn = /* @__PURE__ */ function(e) {
2690
+ var ar = /* @__PURE__ */ function(e) {
2619
2691
  return e[e.exclusive = 0] = "exclusive", e[e.shared = 1] = "shared", e;
2620
2692
  }({});
2621
- t.enum(Qn), t.object({
2693
+ t.enum(ar), t.object({
2622
2694
  key: t.string(),
2623
2695
  name: t.string(),
2624
2696
  group: t.uint32().optional()
@@ -2636,53 +2708,71 @@ t.enum(Qn), t.object({
2636
2708
  key: t.string(),
2637
2709
  value: t.string()
2638
2710
  });
2639
- var $n = t.uuid();
2711
+ var or = t.uuid();
2640
2712
  t.object({
2641
- key: $n,
2713
+ key: or,
2642
2714
  name: t.string().min(1),
2643
- color: Kn
2715
+ color: $n
2644
2716
  }).partial({ key: !0 }), t.string().regex(/^\d+\.\d+\.\d+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/), t.enum([
2645
2717
  "standard",
2646
2718
  "scientific",
2647
2719
  "engineering"
2648
2720
  ]);
2649
- var er = t.union([t.string(), t.number()]), tr = () => t.record(er, t.unknown());
2721
+ var sr = t.union([t.string(), t.number()]), cr = () => t.record(sr, t.unknown());
2650
2722
  typeof process < "u" && process.versions != null && process.versions.node != null || typeof window > "u" || window.document;
2651
- var nr = [
2723
+ var lr = [
2652
2724
  "macOS",
2653
2725
  "Windows",
2654
2726
  "Linux"
2655
- ], rr = [
2727
+ ], ur = [
2656
2728
  "macos",
2657
2729
  "windows",
2658
2730
  "linux"
2659
- ], ir = {
2731
+ ], dr = {
2660
2732
  macos: "macOS",
2661
2733
  windows: "Windows",
2662
2734
  linux: "Linux"
2663
2735
  };
2664
- t.enum(nr).or(t.enum(rr).transform((e) => ir[e])), t.object({
2736
+ t.enum(lr).or(t.enum(ur).transform((e) => dr[e])), t.object({
2665
2737
  message: t.string().optional(),
2666
2738
  description: t.string().optional(),
2667
- details: tr().optional()
2739
+ details: cr().optional()
2668
2740
  }), t.object({
2669
2741
  stack: t.string(),
2670
2742
  error: t.instanceof(Error)
2671
- }).and(tr()), t.enum([
2743
+ }).and(cr()), t.enum([
2672
2744
  "success",
2673
2745
  "info",
2674
2746
  "warning",
2675
2747
  "error",
2676
2748
  "loading",
2677
2749
  "disabled"
2678
- ]), t.literal("success"), t.literal("info"), t.literal("warning"), t.literal("error"), t.literal("loading"), t.literal("disabled");
2679
- var ar = (...e) => e.map(or).join(""), or = (e) => (e.endsWith("/") || (e += "/"), e.startsWith("/") && (e = e.slice(1)), e), sr = (e) => e.endsWith("/") ? e.slice(0, -1) : e, cr = (e, t = "") => e === null ? "" : `?${Object.entries(e).filter(([, e]) => e == null ? !1 : Array.isArray(e) ? e.length > 0 : !0).map(([e, n]) => `${t}${e}=${n}`).join("&")}`, lr = class e {
2750
+ ]), t.literal("success"), t.literal("info"), t.literal("warning"), t.literal("error"), t.literal("loading"), t.literal("disabled"), t.enum([
2751
+ "h1",
2752
+ "h2",
2753
+ "h3",
2754
+ "h4",
2755
+ "h5",
2756
+ "p",
2757
+ "small"
2758
+ ]), t.union([t.number(), t.enum([
2759
+ "normal",
2760
+ "bold",
2761
+ "bolder",
2762
+ "lighter"
2763
+ ])]), t.object({
2764
+ size: t.number(),
2765
+ weight: t.union([t.number(), t.string()]),
2766
+ lineHeight: t.number(),
2767
+ textTransform: t.string().optional()
2768
+ });
2769
+ var fr = (...e) => e.map(pr).join(""), pr = (e) => (e.endsWith("/") || (e += "/"), e.startsWith("/") && (e = e.slice(1)), e), mr = (e) => e.endsWith("/") ? e.slice(0, -1) : e, hr = (e, t = "") => e === null ? "" : `?${Object.entries(e).filter(([, e]) => e == null ? !1 : Array.isArray(e) ? e.length > 0 : !0).map(([e, n]) => `${t}${e}=${n}`).join("&")}`, gr = class e {
2680
2770
  protocol;
2681
2771
  host;
2682
2772
  port;
2683
2773
  path;
2684
2774
  constructor({ host: e, port: t, protocol: n = "", pathPrefix: r = "" }) {
2685
- this.protocol = n, this.host = e, this.port = t, this.path = or(r);
2775
+ this.protocol = n, this.host = e, this.port = t, this.path = pr(r);
2686
2776
  }
2687
2777
  replace(t) {
2688
2778
  return new e({
@@ -2695,11 +2785,11 @@ var ar = (...e) => e.map(or).join(""), or = (e) => (e.endsWith("/") || (e += "/"
2695
2785
  child(t) {
2696
2786
  return new e({
2697
2787
  ...this,
2698
- pathPrefix: ar(this.path, t)
2788
+ pathPrefix: fr(this.path, t)
2699
2789
  });
2700
2790
  }
2701
2791
  toString() {
2702
- return sr(`${this.protocol}://${this.host}:${this.port}/${this.path}`);
2792
+ return mr(`${this.protocol}://${this.host}:${this.port}/${this.path}`);
2703
2793
  }
2704
2794
  static UNKNOWN = new e({
2705
2795
  host: "unknown",
@@ -2716,7 +2806,7 @@ var ar = (...e) => e.map(or).join(""), or = (e) => (e.endsWith("/") || (e += "/"
2716
2806
  }, $ = class extends X.sub("unreachable") {
2717
2807
  url;
2718
2808
  constructor(e = {}) {
2719
- let { message: t = "Unreachable", url: n = lr.UNKNOWN } = e;
2809
+ let { message: t = "Unreachable", url: n = gr.UNKNOWN } = e;
2720
2810
  super(t), this.url = n;
2721
2811
  }
2722
2812
  };
@@ -2749,7 +2839,7 @@ v.register({
2749
2839
  });
2750
2840
  //#endregion
2751
2841
  //#region src/middleware.ts
2752
- var ur = class {
2842
+ var _r = class {
2753
2843
  middleware = [];
2754
2844
  use(...e) {
2755
2845
  this.middleware.push(...e);
@@ -2762,34 +2852,33 @@ var ur = class {
2762
2852
  };
2763
2853
  return await r(e);
2764
2854
  }
2765
- }, dr = "Content-Type", fr = new Set([
2855
+ }, vr = "Content-Type", yr = new Set([
2766
2856
  "ECONNREFUSED",
2767
2857
  "ECONNRESET",
2768
2858
  "ETIMEDOUT",
2769
2859
  "EPIPE",
2770
2860
  "UND_ERR_CONNECT_TIMEOUT",
2771
2861
  "UND_ERR_SOCKET"
2772
- ]), pr = (e) => {
2862
+ ]), br = (e) => {
2773
2863
  let t = e?.cause?.code ?? e?.code ?? e?.errno;
2774
- if (typeof t == "string" && fr.has(t)) return !0;
2864
+ if (typeof t == "string" && yr.has(t)) return !0;
2775
2865
  if (e.name === "TypeError") {
2776
2866
  let t = String(e.message || "").toLowerCase();
2777
2867
  if (/load failed|failed to fetch|networkerror|network error/.test(t)) return typeof navigator < "u" && navigator.onLine, !0;
2778
2868
  }
2779
2869
  return e?.name === "AbortError" || e?.code, !1;
2780
- }, mr = 400, hr = class extends ur {
2870
+ }, xr = 400, Sr = class extends _r {
2781
2871
  endpoint;
2782
2872
  encoder;
2783
2873
  constructor(e, t, n = !1) {
2784
2874
  return super(), this.endpoint = e.replace({ protocol: n ? "https" : "http" }), this.encoder = t, new Proxy(this, { get: (e, t, n) => t === "endpoint" ? this.endpoint : Reflect.get(e, t, n) });
2785
2875
  }
2786
2876
  get headers() {
2787
- return { [dr]: this.encoder.contentType };
2877
+ return { [vr]: this.encoder.contentType };
2788
2878
  }
2789
2879
  async send(e, t, n, r) {
2790
2880
  let i = null, a = this.endpoint.child(e), o = {};
2791
- o.method = "POST", o.body = this.encoder.encode(t, n);
2792
- let [, s] = await this.executeMiddleware({
2881
+ if (o.method = "POST", o.body = this.encoder.encode(t, n), await this.executeMiddleware({
2793
2882
  target: a.toString(),
2794
2883
  protocol: this.endpoint.protocol,
2795
2884
  params: {},
@@ -2807,24 +2896,22 @@ var ur = class {
2807
2896
  try {
2808
2897
  n = await fetch(e.target, o);
2809
2898
  } catch (e) {
2810
- if (!(e instanceof Error)) throw e;
2811
- return [t, pr(e) ? new $({ url: a }) : e];
2899
+ throw e instanceof Error && br(e) ? new $({ url: a }) : e;
2812
2900
  }
2813
2901
  let s = await n.arrayBuffer();
2814
- if (n?.ok) return r != null && (i = this.encoder.decode(s, r)), [t, null];
2902
+ if (n?.ok) return r != null && (i = this.encoder.decode(s, r)), t;
2903
+ if (n.status !== xr) throw Error(n.statusText);
2904
+ let c;
2815
2905
  try {
2816
- if (n.status !== mr) return [t, Error(n.statusText)];
2817
- let e = this.encoder.decode(s, v.payloadZ);
2818
- return [t, v.decode(e)];
2906
+ c = v.decode(this.encoder.decode(s, v.payloadZ));
2819
2907
  } catch (e) {
2820
- return [t, /* @__PURE__ */ Error(`[freighter] - failed to decode error: ${n.statusText}: ${e.message}`)];
2908
+ throw e instanceof Error ? Error(`[freighter] - failed to decode error: ${n.statusText}: ${e.message}`, { cause: e }) : e;
2821
2909
  }
2822
- });
2823
- if (s != null) return [null, s];
2824
- if (i == null) throw Error("Response must be defined");
2825
- return [i, null];
2910
+ throw c ?? Error(n.statusText);
2911
+ }), i == null) throw Error("Response must be defined");
2912
+ return i;
2826
2913
  }
2827
- }, gr = (e, t) => {
2914
+ }, Cr = (e, t) => {
2828
2915
  class n {
2829
2916
  wrapped;
2830
2917
  constructor(e) {
@@ -2834,21 +2921,18 @@ var ur = class {
2834
2921
  this.wrapped.use(...e);
2835
2922
  }
2836
2923
  async send(e, n, r, i) {
2837
- let a = new Mn.Breaker(t);
2838
- do {
2839
- let [t, o] = await this.wrapped.send(e, n, r, i);
2840
- if (o == null) return [t, null];
2841
- if (!$.matches(o)) return [null, o];
2842
- if (console.warn(`[freighter] ${a.retryMessage}`, o), !await a.wait()) return [t, o];
2843
- } while (!0);
2924
+ let a = new zn.Breaker(t);
2925
+ do
2926
+ try {
2927
+ return await this.wrapped.send(e, n, r, i);
2928
+ } catch (e) {
2929
+ if (!$.matches(e) || (console.warn(`[freighter] ${a.retryMessage}`, e), !await a.wait())) throw e;
2930
+ }
2931
+ while (!0);
2844
2932
  }
2845
2933
  }
2846
2934
  return new n(e);
2847
- }, _r = async (e, t, n, r, i) => {
2848
- let [a, o] = await e.send(t, n, r, i);
2849
- if (o != null) throw o;
2850
- return a;
2851
- }, vr = t.object({
2935
+ }, wr = t.object({
2852
2936
  type: t.enum([
2853
2937
  "data",
2854
2938
  "close",
@@ -2856,7 +2940,7 @@ var ur = class {
2856
2940
  ]),
2857
2941
  payload: t.unknown(),
2858
2942
  error: t.optional(v.payloadZ)
2859
- }), yr = class {
2943
+ }), Tr = class {
2860
2944
  codec;
2861
2945
  reqSchema;
2862
2946
  resSchema;
@@ -2870,28 +2954,21 @@ var ur = class {
2870
2954
  }
2871
2955
  async receiveOpenAck() {
2872
2956
  let e = await this.receiveMsg();
2873
- if (e.type !== "open") {
2874
- if (e.error == null) throw Error("Message error must be defined");
2875
- return v.decode(e.error);
2876
- }
2877
- return null;
2957
+ if (e.type !== "open") throw e.error == null ? Error("Message error must be defined") : v.decode(e.error) ?? /* @__PURE__ */ Error(`Unexpected open-ack message type: ${e.type}`);
2878
2958
  }
2879
2959
  send(e) {
2880
- if (this.serverClosed != null) return new Z();
2960
+ if (this.serverClosed != null) throw new Z();
2881
2961
  if (this.sendClosed) throw new Q();
2882
- return this.ws.send(this.codec.encode({
2962
+ this.ws.send(this.codec.encode({
2883
2963
  type: "data",
2884
2964
  payload: e
2885
- })), null;
2965
+ }));
2886
2966
  }
2887
2967
  async receive() {
2888
- if (this.serverClosed != null) return [null, this.serverClosed];
2968
+ if (this.serverClosed != null) throw this.serverClosed;
2889
2969
  let e = await this.receiveMsg();
2890
- if (e.type === "close") {
2891
- if (e.error == null || (this.serverClosed = v.decode(e.error), this.serverClosed == null)) throw Error("Message error must be defined");
2892
- return [null, this.serverClosed];
2893
- }
2894
- return [this.resSchema.parse(e.payload), null];
2970
+ if (e.type === "close") throw e.error == null || (this.serverClosed = v.decode(e.error), this.serverClosed == null) ? Error("Message error must be defined") : this.serverClosed;
2971
+ return this.resSchema.parse(e.payload);
2895
2972
  }
2896
2973
  received() {
2897
2974
  return this.receiveDataQueue.length !== 0;
@@ -2919,18 +2996,18 @@ var ur = class {
2919
2996
  this.ws.onmessage = this.onMessage.bind(this), this.ws.onclose = this.onClose.bind(this);
2920
2997
  }
2921
2998
  onMessage(e) {
2922
- this.addMessage(this.codec.decode(e.data, vr));
2999
+ this.addMessage(this.codec.decode(e.data, wr));
2923
3000
  }
2924
3001
  onClose(e) {
2925
3002
  this.addMessage({
2926
3003
  type: "close",
2927
3004
  error: {
2928
- type: e.code === xr ? Z.TYPE : Q.TYPE,
3005
+ type: e.code === Dr ? Z.TYPE : Q.TYPE,
2929
3006
  data: ""
2930
3007
  }
2931
3008
  });
2932
3009
  }
2933
- }, br = "freighterctx", xr = 1e3, Sr = class e extends ur {
3010
+ }, Er = "freighterctx", Dr = 1e3, Or = class e extends _r {
2934
3011
  baseUrl;
2935
3012
  encoder;
2936
3013
  secure;
@@ -2943,7 +3020,8 @@ var ur = class {
2943
3020
  return n.use(...this.middleware), n;
2944
3021
  }
2945
3022
  async stream(t, n, r) {
2946
- let i, [, a] = await this.executeMiddleware({
3023
+ let i;
3024
+ return await this.executeMiddleware({
2947
3025
  target: t,
2948
3026
  protocol: "websocket",
2949
3027
  params: {},
@@ -2953,32 +3031,26 @@ var ur = class {
2953
3031
  ...a,
2954
3032
  params: {}
2955
3033
  };
2956
- o.binaryType = e.MESSAGE_TYPE;
2957
- let c = await this.wrapSocket(o, n, r);
2958
- return c instanceof Error ? [s, c] : (i = c, [s, null]);
2959
- });
2960
- if (a != null) throw a;
2961
- return i;
3034
+ return o.binaryType = e.MESSAGE_TYPE, i = await this.wrapSocket(o, n, r), s;
3035
+ }), i;
2962
3036
  }
2963
3037
  buildURL(e, t) {
2964
- let n = cr({
2965
- [dr]: this.encoder.contentType,
3038
+ let n = hr({
3039
+ [vr]: this.encoder.contentType,
2966
3040
  ...t.params
2967
- }, br);
3041
+ }, Er);
2968
3042
  return this.baseUrl.child(e).toString() + n;
2969
3043
  }
2970
3044
  async wrapSocket(e, t, n) {
2971
- return await new Promise((r) => {
3045
+ return await new Promise((r, i) => {
2972
3046
  e.onopen = () => {
2973
- let i = new yr(e, this.encoder, t, n);
2974
- i.receiveOpenAck().then((e) => {
2975
- r(e ?? i);
2976
- }).catch((e) => r(e));
3047
+ let a = new Tr(e, this.encoder, t, n);
3048
+ a.receiveOpenAck().then(() => r(a)).catch((e) => i(e));
2977
3049
  }, e.onerror = (e) => {
2978
- r(Error(e.message));
3050
+ i(Error(e.message));
2979
3051
  };
2980
3052
  });
2981
3053
  }
2982
3054
  };
2983
3055
  //#endregion
2984
- export { Z as EOF, hr as HTTPClient, Q as StreamClosed, $ as Unreachable, Sr as WebSocketClient, _r as sendRequired, gr as unaryWithBreaker };
3056
+ export { Z as EOF, Sr as HTTPClient, Q as StreamClosed, $ as Unreachable, Or as WebSocketClient, Cr as unaryWithBreaker };