@synnaxlabs/freighter 0.32.0 → 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/freighter.js CHANGED
@@ -1,36 +1,40 @@
1
- var it = Object.defineProperty;
2
- var at = (r, e, t) => e in r ? it(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var p = (r, e, t) => at(r, typeof e != "symbol" ? e + "" : e, t);
1
+ var lt = Object.defineProperty;
2
+ var ht = (r, e, t) => e in r ? lt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var p = (r, e, t) => ht(r, typeof e != "symbol" ? e + "" : e, t);
4
4
  import { z as i } from "zod";
5
- const ot = (r) => {
5
+ const ft = (r) => {
6
6
  const e = r.replace(/_[a-z]/g, (t) => t[1].toUpperCase());
7
- return e.length > 1 && e[0] === e[0].toUpperCase() && e[1] === e[1].toUpperCase() ? e : e[0].toLowerCase() + e.slice(1);
8
- }, Le = (r) => {
7
+ return e.length > 1 && e[0] === e[0].toUpperCase() && e[1] === e[1].toUpperCase() || e.length === 0 ? e : e[0].toLowerCase() + e.slice(1);
8
+ }, qe = (r) => {
9
9
  const e = (t, n = de) => {
10
10
  if (typeof t == "string") return r(t);
11
11
  if (Array.isArray(t)) return t.map((c) => e(c, n));
12
- if (!ue(t)) return t;
13
- n = lt(n);
12
+ if (!ce(t)) return t;
13
+ n = pt(n);
14
14
  const s = {}, a = t;
15
15
  return Object.keys(a).forEach((c) => {
16
- let d = a[c];
17
- const f = r(c);
18
- n.recursive && (ue(d) ? Oe(d, n.keepTypesOnRecursion) || (d = e(d, n)) : n.recursiveInArray && Te(d) && (d = [...d].map((y) => {
16
+ let f = a[c];
17
+ const d = r(c);
18
+ n.recursive && (ce(f) ? Ie(f, n.keepTypesOnRecursion) || (f = e(f, n)) : n.recursiveInArray && Se(f) && (f = [...f].map((y) => {
19
19
  let T = y;
20
- return ue(y) ? Oe(T, n.keepTypesOnRecursion) || (T = e(y, n)) : Te(y) && (T = e({ key: y }, n).key), T;
21
- }))), s[f] = d;
20
+ return ce(y) ? Ie(T, n.keepTypesOnRecursion) || (T = e(y, n)) : Se(y) && (T = e({ key: y }, n).key), T;
21
+ }))), s[d] = f;
22
22
  }), s;
23
23
  };
24
24
  return e;
25
- }, Ye = Le(ot), ut = (r) => r.replace(/([a-z0-9])([A-Z])/g, (e, t, n) => `${t}_${n.toLowerCase()}`), ct = Le(ut), de = {
25
+ }, We = qe(ft), dt = (r) => (
26
+ // Don't convert the first character and don't convert a character that is after a
27
+ // non-alphanumeric character
28
+ r.replace(/([a-z0-9])([A-Z])/g, (e, t, n) => `${t}_${n.toLowerCase()}`)
29
+ ), gt = qe(dt), de = {
26
30
  recursive: !0,
27
31
  recursiveInArray: !0,
28
32
  keepTypesOnRecursion: [Number, String, Uint8Array]
29
- }, lt = (r = de) => (r.recursive == null ? r = de : r.recursiveInArray == null && (r.recursiveInArray = !1), r), Te = (r) => r != null && Array.isArray(r), ue = (r) => r != null && typeof r == "object" && !Array.isArray(r), Oe = (r, e) => (e || []).some((t) => r instanceof t), ke = (r) => r != null && typeof r == "object" && !Array.isArray(r);
30
- var ht = Object.defineProperty, dt = (r, e, t) => e in r ? ht(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, H = (r, e, t) => dt(r, typeof e != "symbol" ? e + "" : e, t);
31
- let ft = class {
33
+ }, pt = (r = de) => (r.recursive == null ? r = de : r.recursiveInArray ?? (r.recursiveInArray = !1), r), Se = (r) => r != null && Array.isArray(r), ce = (r) => r != null && typeof r == "object" && !Array.isArray(r), Ie = (r, e) => (e || []).some((t) => r instanceof t), Ve = (r) => r != null && typeof r == "object" && !Array.isArray(r);
34
+ var yt = Object.defineProperty, mt = (r, e, t) => e in r ? yt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, Q = (r, e, t) => mt(r, typeof e != "symbol" ? e + "" : e, t);
35
+ let wt = class {
32
36
  constructor() {
33
- H(this, "contentType", "application/json"), H(this, "decoder"), H(this, "encoder"), this.decoder = new TextDecoder(), this.encoder = new TextEncoder();
37
+ Q(this, "contentType", "application/json"), Q(this, "decoder"), Q(this, "encoder"), this.decoder = new TextDecoder(), this.encoder = new TextEncoder();
34
38
  }
35
39
  encode(e) {
36
40
  return this.encoder.encode(this.encodeString(e)).buffer;
@@ -39,18 +43,18 @@ let ft = class {
39
43
  return this.decodeString(this.decoder.decode(e), t);
40
44
  }
41
45
  decodeString(e, t) {
42
- const n = JSON.parse(e), s = Ye(n);
46
+ const n = JSON.parse(e), s = We(n);
43
47
  return t != null ? t.parse(s) : s;
44
48
  }
45
49
  encodeString(e) {
46
- const t = ct(e);
47
- return JSON.stringify(t, (n, s) => ArrayBuffer.isView(s) ? Array.from(s) : ke(s) && "encode_value" in s ? typeof s.value == "bigint" ? s.value.toString() : s.value : typeof s == "bigint" ? s.toString() : s);
50
+ const t = gt(e);
51
+ return JSON.stringify(t, (n, s) => ArrayBuffer.isView(s) ? Array.from(s) : Ve(s) && "encode_value" in s ? typeof s.value == "bigint" ? s.value.toString() : s.value : typeof s == "bigint" ? s.toString() : s);
48
52
  }
49
53
  static registerCustomType() {
50
54
  }
51
- }, gt = class {
55
+ }, bt = class {
52
56
  constructor() {
53
- H(this, "contentType", "text/csv");
57
+ Q(this, "contentType", "text/csv");
54
58
  }
55
59
  encode(e) {
56
60
  const t = this.encodeString(e);
@@ -61,7 +65,7 @@ let ft = class {
61
65
  return this.decodeString(n, t);
62
66
  }
63
67
  encodeString(e) {
64
- if (!Array.isArray(e) || e.length === 0 || !ke(e[0]))
68
+ if (!Array.isArray(e) || e.length === 0 || !Ve(e[0]))
65
69
  throw new Error("Payload must be an array of objects");
66
70
  const t = Object.keys(e[0]), n = [t.join(",")];
67
71
  return e.forEach((s) => {
@@ -72,16 +76,16 @@ let ft = class {
72
76
  }
73
77
  decodeString(e, t) {
74
78
  const [n, ...s] = e.trim().split(`
75
- `).map((d) => d.trim());
79
+ `).map((f) => f.trim());
76
80
  if (n.length === 0)
77
81
  return t != null ? t.parse({}) : {};
78
- const a = n.split(",").map((d) => d.trim()), c = {};
79
- return a.forEach((d) => {
80
- c[d] = [];
81
- }), s.forEach((d) => {
82
- const f = d.split(",").map((y) => y.trim());
82
+ const a = n.split(",").map((f) => f.trim()), c = {};
83
+ return a.forEach((f) => {
84
+ c[f] = [];
85
+ }), s.forEach((f) => {
86
+ const d = f.split(",").map((y) => y.trim());
83
87
  a.forEach((y, T) => {
84
- const l = this.parseValue(f[T]);
88
+ const l = this.parseValue(d[T]);
85
89
  l != null && c[y].push(l);
86
90
  });
87
91
  }), t != null ? t.parse(c) : c;
@@ -93,9 +97,9 @@ let ft = class {
93
97
  }
94
98
  static registerCustomType() {
95
99
  }
96
- }, pt = class {
100
+ }, Tt = class {
97
101
  constructor() {
98
- H(this, "contentType", "text/plain");
102
+ Q(this, "contentType", "text/plain");
99
103
  }
100
104
  encode(e) {
101
105
  return new TextEncoder().encode(e).buffer;
@@ -105,62 +109,65 @@ let ft = class {
105
109
  return t != null ? t.parse(n) : n;
106
110
  }
107
111
  };
108
- const _ = new ft();
109
- new gt();
110
- new pt();
111
- const ie = i.tuple([i.number(), i.number()]);
112
+ const ee = new wt();
113
+ new bt();
114
+ new Tt();
115
+ const ae = i.tuple([i.number(), i.number()]);
112
116
  i.tuple([i.bigint(), i.bigint()]);
113
- const je = i.object({ width: i.number(), height: i.number() }), yt = i.object({
117
+ const ze = i.object({ width: i.number(), height: i.number() }), Ot = i.object({
114
118
  signedWidth: i.number(),
115
119
  signedHeight: i.number()
116
- }), mt = ["width", "height"];
117
- i.enum(mt);
118
- const wt = ["start", "center", "end"], bt = ["signedWidth", "signedHeight"];
119
- i.enum(bt);
120
- const ne = i.object({ x: i.number(), y: i.number() }), Tt = i.object({ clientX: i.number(), clientY: i.number() }), Ot = ["x", "y"], Fe = i.enum(Ot), Ge = ["top", "right", "bottom", "left"];
121
- i.enum(Ge);
122
- const vt = ["left", "right"], qe = i.enum(vt), St = ["top", "bottom"], We = i.enum(St), ze = ["center"], ve = i.enum(ze), It = [...Ge, ...ze], Ze = i.enum(It);
123
- i.enum(wt);
124
- const Nt = ["first", "last"];
125
- i.enum(Nt);
126
- const Et = i.object({ lower: i.number(), upper: i.number() }), At = i.object({ lower: i.bigint(), upper: i.bigint() });
127
- i.union([Et, ie]);
128
- i.union([At, ie]);
129
- i.union([Fe, Ze]);
130
- i.union([Fe, Ze, i.instanceof(String)]);
131
- const K = (r, e) => {
120
+ }), vt = ["width", "height"];
121
+ i.enum(vt);
122
+ const St = ["start", "center", "end"], It = ["signedWidth", "signedHeight"];
123
+ i.enum(It);
124
+ const se = i.object({ x: i.number(), y: i.number() }), Nt = i.object({ clientX: i.number(), clientY: i.number() }), Et = ["x", "y"], Ze = i.enum(Et), Je = ["top", "right", "bottom", "left"];
125
+ i.enum(Je);
126
+ const At = ["left", "right"], He = i.enum(At), xt = ["top", "bottom"], Ke = i.enum(xt), Xe = ["center"], Ne = i.enum(Xe), Mt = [...Je, ...Xe], Qe = i.enum(Mt);
127
+ i.enum(St);
128
+ const $t = ["first", "last"];
129
+ i.enum($t);
130
+ const Bt = i.object({ lower: i.number(), upper: i.number() }), Rt = i.object({ lower: i.bigint(), upper: i.bigint() });
131
+ i.union([Bt, ae]);
132
+ i.union([Rt, ae]);
133
+ i.union([Ze, Qe]);
134
+ i.union([Ze, Qe, i.instanceof(String)]);
135
+ const Ut = (r) => typeof r == "bigint" || r instanceof BigInt, F = (r, e) => Ut(r) ? r.valueOf() * BigInt(e.valueOf()) : r.valueOf() * Number(e.valueOf()), k = (r, e) => {
132
136
  const t = {};
133
137
  if (typeof r == "number" || typeof r == "bigint")
134
138
  e != null ? (t.lower = r, t.upper = e) : (t.lower = typeof r == "bigint" ? 0n : 0, t.upper = r);
135
139
  else if (Array.isArray(r)) {
136
140
  if (r.length !== 2) throw new Error("bounds: expected array of length 2");
137
141
  [t.lower, t.upper] = r;
138
- } else return Se(r);
139
- return Se(t);
140
- }, Se = (r) => r.lower > r.upper ? { lower: r.upper, upper: r.lower } : r;
142
+ } else return Ee(r);
143
+ return Ee(t);
144
+ }, Ee = (r) => r.lower > r.upper ? { lower: r.upper, upper: r.lower } : r, Ae = (r, e) => {
145
+ const t = k(r);
146
+ return e < t.lower ? t.lower : e >= t.upper ? t.upper - (typeof t.upper == "number" ? 1 : 1n) : e;
147
+ };
141
148
  i.object({
142
- x: qe.or(ve),
143
- y: We.or(ve)
149
+ x: He.or(Ne),
150
+ y: Ke.or(Ne)
144
151
  });
145
- const xt = i.object({ x: qe, y: We }), Mt = Object.freeze({ x: "left", y: "top" }), $t = (r, e) => r.x === e.x && r.y === e.y, Ie = i.union([
152
+ const Ct = i.object({ x: He, y: Ke }), Dt = Object.freeze({ x: "left", y: "top" }), Pt = (r, e) => r.x === e.x && r.y === e.y, xe = i.union([
146
153
  i.number(),
147
- ne,
148
- ie,
149
- je,
150
- yt,
151
- Tt
152
- ]), Rt = (r, e) => {
154
+ se,
155
+ ae,
156
+ ze,
157
+ Ot,
158
+ Nt
159
+ ]), Lt = (r, e) => {
153
160
  if (typeof r == "string") {
154
161
  if (e === void 0) throw new Error("The y coordinate must be given.");
155
162
  return r === "x" ? { x: e, y: 0 } : { x: 0, y: e };
156
163
  }
157
164
  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 };
158
- }, Ne = Object.freeze({ x: 0, y: 0 }), X = i.union([i.number(), i.string()]);
165
+ }, Me = Object.freeze({ x: 0, y: 0 }), _ = i.union([i.number(), i.string()]);
159
166
  i.object({
160
- top: X,
161
- left: X,
162
- width: X,
163
- height: X
167
+ top: _,
168
+ left: _,
169
+ width: _,
170
+ height: _
164
171
  });
165
172
  i.object({
166
173
  left: i.number(),
@@ -169,15 +176,15 @@ i.object({
169
176
  bottom: i.number()
170
177
  });
171
178
  i.object({
172
- one: ne,
173
- two: ne,
174
- root: xt
179
+ one: se,
180
+ two: se,
181
+ root: Ct
175
182
  });
176
- const ye = (r, e, t = 0, n = 0, s) => {
183
+ const be = (r, e, t = 0, n = 0, s) => {
177
184
  const a = {
178
- one: { ...Ne },
179
- two: { ...Ne },
180
- root: s ?? Mt
185
+ one: { ...Me },
186
+ two: { ...Me },
187
+ root: s ?? Dt
181
188
  };
182
189
  if (typeof r == "number") {
183
190
  if (typeof e != "number")
@@ -191,71 +198,93 @@ const ye = (r, e, t = 0, n = 0, s) => {
191
198
  x: a.one.x + e.signedWidth,
192
199
  y: a.one.y + e.signedHeight
193
200
  } : a.two = e, a));
194
- }, ce = (r) => {
195
- const e = ye(r);
196
- return { lower: e.one.x, upper: e.two.x };
197
201
  }, le = (r) => {
198
- const e = ye(r);
202
+ const e = be(r);
203
+ return { lower: e.one.x, upper: e.two.x };
204
+ }, he = (r) => {
205
+ const e = be(r);
199
206
  return { lower: e.one.y, upper: e.two.y };
200
- }, Bt = (r) => typeof r != "object" || r == null ? !1 : "one" in r && "two" in r && "root" in r;
201
- var Ut = Object.defineProperty, Ct = (r, e, t) => e in r ? Ut(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, D = (r, e, t) => Ct(r, typeof e != "symbol" ? e + "" : e, t);
202
- const Dt = (r, e, t) => e !== void 0 && r < e ? e : t !== void 0 && r > t ? t : r;
203
- i.object({ offset: Ie, scale: Ie });
204
- const Pt = (r) => (e, t, n, s) => t === "dimension" ? [e, n] : [
207
+ }, Yt = (r) => typeof r != "object" || r == null ? !1 : "one" in r && "two" in r && "root" in r;
208
+ var kt = Object.defineProperty, jt = (r, e, t) => e in r ? kt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, D = (r, e, t) => jt(r, typeof e != "symbol" ? e + "" : e, t);
209
+ const Ft = (r, e, t) => e !== void 0 && r < e ? e : t !== void 0 && r > t ? t : r;
210
+ i.object({ offset: xe, scale: xe });
211
+ const Gt = (r) => (e, t, n, s) => t === "dimension" ? [e, n] : [
205
212
  e,
206
213
  s ? n - r : n + r
207
- ], Lt = (r) => (e, t, n, s) => [
214
+ ], qt = (r) => (e, t, n, s) => [
208
215
  e,
209
216
  s ? n / r : n * r
210
- ], Yt = (r) => (e, t, n) => {
217
+ ], Wt = (r) => (e, t, n) => {
211
218
  if (e === null) return [r, n];
212
- const { lower: s, upper: a } = e, { lower: c, upper: d } = r, f = a - s, y = d - c;
213
- if (t === "dimension") return [r, n * (y / f)];
214
- const T = (n - s) * (y / f) + c;
219
+ const { lower: s, upper: a } = e, { lower: c, upper: f } = r, d = a - s, y = f - c;
220
+ if (t === "dimension") return [r, n * (y / d)];
221
+ const T = (n - s) * (y / d) + c;
215
222
  return [r, T];
216
- }, kt = (r) => (e, t, n) => [r, n], jt = () => (r, e, t) => {
223
+ }, Vt = (r) => (e, t, n) => [r, n], zt = () => (r, e, t) => {
217
224
  if (r === null) throw new Error("cannot invert without bounds");
218
225
  if (e === "dimension") return [r, t];
219
226
  const { lower: n, upper: s } = r;
220
227
  return [r, s - (t - n)];
221
- }, Ft = (r) => (e, t, n) => {
228
+ }, Zt = (r) => (e, t, n) => {
222
229
  const { lower: s, upper: a } = r;
223
- return n = Dt(n, s, a), [e, n];
224
- }, fe = class W {
230
+ return n = Ft(n, s, a), [e, n];
231
+ }, ge = class z {
225
232
  constructor() {
226
233
  D(this, "ops", []), D(this, "currBounds", null), D(this, "currType", null), D(this, "reversed", !1), this.ops = [];
227
234
  }
235
+ /**
236
+ * @returns a new scale with a translation as its first operation. Any number provided
237
+ * to the {@link pos} operation on the scale will be translated by the specified value.
238
+ * @param value - The amount to translate by.
239
+ */
228
240
  static translate(e) {
229
- return new W().translate(e);
241
+ return new z().translate(e);
230
242
  }
243
+ /**
244
+ * @returns a new scale with a magnification as its first operation. Any number provided
245
+ * to the {@link pos} or {@link dim} operation will be multiplied by the specified value.
246
+ * @param value - The amount to translate by.
247
+ */
231
248
  static magnify(e) {
232
- return new W().magnify(e);
249
+ return new z().magnify(e);
233
250
  }
234
251
  static scale(e, t) {
235
- return new W().scale(e, t);
252
+ return new z().scale(e, t);
236
253
  }
254
+ /**
255
+ * @returns a copy of the scale with a translation as its next operation. Any
256
+ * number provided to the {@link pos} method on the scale will be translated by the
257
+ * specified value.
258
+ * @param value - The amount to translate by.
259
+ */
237
260
  translate(e) {
238
- const t = this.new(), n = Pt(e);
261
+ const t = this.new(), n = Gt(e);
239
262
  return n.type = "translate", t.ops.push(n), t;
240
263
  }
264
+ /**
265
+ * @returns a copy of the scale with a translation as its next operation. Any number
266
+ * provided to the {@link pos} or {@link dim} method on the scale will be multiplied
267
+ * by the specified value.
268
+ * @param value - The amount to magnify by.
269
+ */
241
270
  magnify(e) {
242
- const t = this.new(), n = Lt(e);
271
+ const t = this.new(), n = qt(e);
243
272
  return n.type = "magnify", t.ops.push(n), t;
244
273
  }
245
274
  scale(e, t) {
246
- const n = K(e, t), s = this.new(), a = Yt(n);
275
+ const n = k(e, t), s = this.new(), a = Wt(n);
247
276
  return a.type = "scale", s.ops.push(a), s;
248
277
  }
249
278
  clamp(e, t) {
250
- const n = K(e, t), s = this.new(), a = Ft(n);
279
+ const n = k(e, t), s = this.new(), a = Zt(n);
251
280
  return a.type = "clamp", s.ops.push(a), s;
252
281
  }
253
282
  reBound(e, t) {
254
- const n = K(e, t), s = this.new(), a = kt(n);
283
+ const n = k(e, t), s = this.new(), a = Vt(n);
255
284
  return a.type = "re-bound", s.ops.push(a), s;
256
285
  }
257
286
  invert() {
258
- const e = jt();
287
+ const e = zt();
259
288
  e.type = "invert";
260
289
  const t = this.new();
261
290
  return t.ops.push(e), t;
@@ -267,7 +296,7 @@ const Pt = (r) => (e, t, n, s) => t === "dimension" ? [e, n] : [
267
296
  return this.exec("dimension", e);
268
297
  }
269
298
  new() {
270
- const e = new W();
299
+ const e = new z();
271
300
  return e.ops = this.ops.slice(), e.reversed = this.reversed, e;
272
301
  }
273
302
  exec(e, t) {
@@ -281,9 +310,9 @@ const Pt = (r) => (e, t, n, s) => t === "dimension" ? [e, n] : [
281
310
  e.ops.reverse();
282
311
  const t = [];
283
312
  return e.ops.forEach((n, s) => {
284
- if (n.type === "scale" || t.some(([c, d]) => s >= c && s <= d))
313
+ if (n.type === "scale" || t.some(([c, f]) => s >= c && s <= f))
285
314
  return;
286
- const a = e.ops.findIndex((c, d) => c.type === "scale" && d > s);
315
+ const a = e.ops.findIndex((c, f) => c.type === "scale" && f > s);
287
316
  a !== -1 && t.push([s, a]);
288
317
  }), t.forEach(([n, s]) => {
289
318
  const a = e.ops.slice(n, s);
@@ -291,35 +320,35 @@ const Pt = (r) => (e, t, n, s) => t === "dimension" ? [e, n] : [
291
320
  }), e.reversed = !e.reversed, e;
292
321
  }
293
322
  };
294
- D(fe, "IDENTITY", new fe());
295
- let Ee = fe;
296
- const Ae = class U {
297
- constructor(e = new Ee(), t = new Ee(), n = null) {
323
+ D(ge, "IDENTITY", new ge());
324
+ let $e = ge;
325
+ const Be = class C {
326
+ constructor(e = new $e(), t = new $e(), n = null) {
298
327
  D(this, "x"), D(this, "y"), D(this, "currRoot"), this.x = e, this.y = t, this.currRoot = n;
299
328
  }
300
329
  static translate(e, t) {
301
- return new U().translate(e, t);
330
+ return new C().translate(e, t);
302
331
  }
303
332
  static translateX(e) {
304
- return new U().translateX(e);
333
+ return new C().translateX(e);
305
334
  }
306
335
  static translateY(e) {
307
- return new U().translateY(e);
336
+ return new C().translateY(e);
308
337
  }
309
338
  static clamp(e) {
310
- return new U().clamp(e);
339
+ return new C().clamp(e);
311
340
  }
312
341
  static magnify(e) {
313
- return new U().magnify(e);
342
+ return new C().magnify(e);
314
343
  }
315
344
  static scale(e) {
316
- return new U().scale(e);
345
+ return new C().scale(e);
317
346
  }
318
347
  static reBound(e) {
319
- return new U().reBound(e);
348
+ return new C().reBound(e);
320
349
  }
321
350
  translate(e, t) {
322
- const n = Rt(e, t), s = this.copy();
351
+ const n = Lt(e, t), s = this.copy();
323
352
  return s.x = this.x.translate(n.x), s.y = this.y.translate(n.y), s;
324
353
  }
325
354
  translateX(e) {
@@ -336,22 +365,22 @@ const Ae = class U {
336
365
  }
337
366
  scale(e) {
338
367
  const t = this.copy();
339
- if (Bt(e)) {
368
+ if (Yt(e)) {
340
369
  const n = this.currRoot;
341
- return t.currRoot = e.root, n != null && !$t(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(ce(e)), t.y = t.y.scale(le(e)), t;
370
+ return t.currRoot = e.root, n != null && !Pt(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(le(e)), t.y = t.y.scale(he(e)), t;
342
371
  }
343
372
  return t.x = t.x.scale(e.width), t.y = t.y.scale(e.height), t;
344
373
  }
345
374
  reBound(e) {
346
375
  const t = this.copy();
347
- return t.x = this.x.reBound(ce(e)), t.y = this.y.reBound(le(e)), t;
376
+ return t.x = this.x.reBound(le(e)), t.y = this.y.reBound(he(e)), t;
348
377
  }
349
378
  clamp(e) {
350
379
  const t = this.copy();
351
- return t.x = this.x.clamp(ce(e)), t.y = this.y.clamp(le(e)), t;
380
+ return t.x = this.x.clamp(le(e)), t.y = this.y.clamp(he(e)), t;
352
381
  }
353
382
  copy() {
354
- const e = new U();
383
+ const e = new C();
355
384
  return e.currRoot = this.currRoot, e.x = this.x, e.y = this.y, e;
356
385
  }
357
386
  reverse() {
@@ -362,7 +391,7 @@ const Ae = class U {
362
391
  return { x: this.x.pos(e.x), y: this.y.pos(e.y) };
363
392
  }
364
393
  box(e) {
365
- return ye(
394
+ return be(
366
395
  this.pos(e.one),
367
396
  this.pos(e.two),
368
397
  0,
@@ -371,9 +400,9 @@ const Ae = class U {
371
400
  );
372
401
  }
373
402
  };
374
- D(Ae, "IDENTITY", new Ae());
375
- const Gt = (r) => r != null && typeof r == "object" && "toString" in r, qt = (r, e = !1) => {
376
- const t = Gt(r) ? "stringer" : typeof r;
403
+ D(Be, "IDENTITY", new Be());
404
+ const Jt = (r) => r != null && typeof r == "object" && "toString" in r, Ht = (r, e = !1) => {
405
+ const t = Jt(r) ? "stringer" : typeof r;
377
406
  let n;
378
407
  switch (t) {
379
408
  case "string":
@@ -397,18 +426,18 @@ const Gt = (r) => r != null && typeof r == "object" && "toString" in r, qt = (r,
397
426
  default:
398
427
  return console.warn(`sortFunc: unknown type ${t}`), () => -1;
399
428
  }
400
- return e ? Wt(n) : n;
401
- }, Wt = (r) => (e, t) => r(t, e), zt = i.object({ signedWidth: i.number(), signedHeight: i.number() });
402
- i.union([je, zt, ne, ie]);
403
- const Zt = i.bigint().or(i.string().transform(BigInt));
404
- var Vt = Object.defineProperty, Jt = (r, e, t) => e in r ? Vt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, u = (r, e, t) => Jt(r, typeof e != "symbol" ? e + "" : e, t);
405
- let Ht = (r, e = 21) => (t = e) => {
429
+ return e ? Kt(n) : n;
430
+ }, Kt = (r) => (e, t) => r(t, e), Xt = i.object({ signedWidth: i.number(), signedHeight: i.number() });
431
+ i.union([ze, Xt, se, ae]);
432
+ const Qt = i.bigint().or(i.string().transform(BigInt));
433
+ var _t = Object.defineProperty, er = (r, e, t) => e in r ? _t(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, u = (r, e, t) => er(r, typeof e != "symbol" ? e + "" : e, t);
434
+ let tr = (r, e = 21) => (t = e) => {
406
435
  let n = "", s = t;
407
436
  for (; s--; )
408
437
  n += r[Math.random() * r.length | 0];
409
438
  return n;
410
439
  };
411
- const Kt = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", Xt = Ht(Kt, 11), Qt = i.enum(["static", "dynamic"]), Ve = (r, e) => {
440
+ const rr = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", nr = tr(rr, 11), sr = i.enum(["static", "dynamic"]), _e = (r, e) => {
412
441
  const t = new O(e);
413
442
  if (![
414
443
  S.DAY,
@@ -449,10 +478,10 @@ const Kt = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", Xt
449
478
  }
450
479
  static parseTimeString(e, t = "UTC") {
451
480
  const [n, s, a] = e.split(":");
452
- let c = "00", d = "00";
453
- a != null && ([c, d] = a.split("."));
454
- let f = h.hours(parseInt(n ?? "00", 10)).add(h.minutes(parseInt(s ?? "00", 10))).add(h.seconds(parseInt(c ?? "00", 10))).add(h.milliseconds(parseInt(d ?? "00", 10)));
455
- return t === "local" && (f = f.add(h.utcOffset)), f.valueOf();
481
+ let c = "00", f = "00";
482
+ a != null && ([c, f] = a.split("."));
483
+ let d = h.hours(parseInt(n ?? "00")).add(h.minutes(parseInt(s ?? "00"))).add(h.seconds(parseInt(c ?? "00"))).add(h.milliseconds(parseInt(f ?? "00")));
484
+ return t === "local" && (d = d.add(h.utcOffset)), d.valueOf();
456
485
  }
457
486
  static parseDateTimeString(e, t = "UTC") {
458
487
  if (!e.includes("/") && !e.includes("-"))
@@ -538,7 +567,7 @@ const Kt = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", Xt
538
567
  * valid, regardless of the TimeStamp order.
539
568
  */
540
569
  range(e) {
541
- return new me(this, e).makeValid();
570
+ return new Te(this, e).makeValid();
542
571
  }
543
572
  /**
544
573
  * Creates a TimeRange starting at the TimeStamp and spanning the given
@@ -640,7 +669,7 @@ const Kt = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", Xt
640
669
  * @example TimeStamp.now().remainder(TimeStamp.DAY) // => TimeStamp representing the current day
641
670
  */
642
671
  remainder(e) {
643
- return Ve(this, e);
672
+ return _e(this, e);
644
673
  }
645
674
  /** @returns true if the day portion TimeStamp is today, false otherwise. */
646
675
  get isToday() {
@@ -724,6 +753,12 @@ const w = class g {
724
753
  constructor(e) {
725
754
  u(this, "value"), u(this, "encodeValue", !0), typeof e == "number" && (e = Math.trunc(e.valueOf())), this.value = BigInt(e.valueOf());
726
755
  }
756
+ static fromSeconds(e) {
757
+ return e instanceof g ? e : e instanceof Re ? e.period : e instanceof O ? new g(e) : ["number", "bigint"].includes(typeof e) ? g.seconds(e) : new g(e);
758
+ }
759
+ static fromMilliseconds(e) {
760
+ return e instanceof g ? e : e instanceof Re ? e.period : e instanceof O ? new g(e) : ["number", "bigint"].includes(typeof e) ? g.milliseconds(e) : new g(e);
761
+ }
727
762
  encode() {
728
763
  return this.value.toString();
729
764
  }
@@ -743,7 +778,7 @@ const w = class g {
743
778
  return this.valueOf() >= new g(e).valueOf();
744
779
  }
745
780
  remainder(e) {
746
- return Ve(this, e);
781
+ return _e(this, e);
747
782
  }
748
783
  truncate(e) {
749
784
  return new g(
@@ -751,9 +786,9 @@ const w = class g {
751
786
  );
752
787
  }
753
788
  toString() {
754
- const e = this.truncate(g.DAY), t = this.truncate(g.HOUR), n = this.truncate(g.MINUTE), s = this.truncate(g.SECOND), a = this.truncate(g.MILLISECOND), c = this.truncate(g.MICROSECOND), d = this.truncate(g.NANOSECOND), f = e, y = t.sub(e), T = n.sub(t), l = s.sub(n), E = a.sub(s), R = c.sub(a), B = d.sub(c);
789
+ const e = this.truncate(g.DAY), t = this.truncate(g.HOUR), n = this.truncate(g.MINUTE), s = this.truncate(g.SECOND), a = this.truncate(g.MILLISECOND), c = this.truncate(g.MICROSECOND), f = this.truncate(g.NANOSECOND), d = e, y = t.sub(e), T = n.sub(t), l = s.sub(n), E = a.sub(s), R = c.sub(a), U = f.sub(c);
755
790
  let x = "";
756
- return f.isZero || (x += `${f.days}d `), y.isZero || (x += `${y.hours}h `), T.isZero || (x += `${T.minutes}m `), l.isZero || (x += `${l.seconds}s `), E.isZero || (x += `${E.milliseconds}ms `), R.isZero || (x += `${R.microseconds}µs `), B.isZero || (x += `${B.nanoseconds}ns`), x.trim();
791
+ return d.isZero || (x += `${d.days}d `), y.isZero || (x += `${y.hours}h `), T.isZero || (x += `${T.minutes}m `), l.isZero || (x += `${l.seconds}s `), E.isZero || (x += `${E.milliseconds}ms `), R.isZero || (x += `${R.microseconds}µs `), U.isZero || (x += `${U.nanoseconds}ns`), x.trim();
757
792
  }
758
793
  /** @returns the decimal number of days in the timespan */
759
794
  get days() {
@@ -829,7 +864,7 @@ const w = class g {
829
864
  * @returns A TimeSpan representing the given number of microseconds.
830
865
  */
831
866
  static microseconds(e = 1) {
832
- return g.nanoseconds(e * 1e3);
867
+ return g.nanoseconds(F(e, 1e3));
833
868
  }
834
869
  /**
835
870
  * Creates a TimeSpan representing the given number of milliseconds.
@@ -838,7 +873,7 @@ const w = class g {
838
873
  * @returns A TimeSpan representing the given number of milliseconds.
839
874
  */
840
875
  static milliseconds(e = 1) {
841
- return g.microseconds(e * 1e3);
876
+ return g.microseconds(F(e, 1e3));
842
877
  }
843
878
  /**
844
879
  * Creates a TimeSpan representing the given number of seconds.
@@ -847,7 +882,7 @@ const w = class g {
847
882
  * @returns A TimeSpan representing the given number of seconds.
848
883
  */
849
884
  static seconds(e = 1) {
850
- return g.milliseconds(e * 1e3);
885
+ return g.milliseconds(F(e, 1e3));
851
886
  }
852
887
  /**
853
888
  * Creates a TimeSpan representing the given number of minutes.
@@ -855,8 +890,8 @@ const w = class g {
855
890
  * @param value - The number of minutes.
856
891
  * @returns A TimeSpan representing the given number of minutes.
857
892
  */
858
- static minutes(e) {
859
- return g.seconds(e.valueOf() * 60);
893
+ static minutes(e = 1) {
894
+ return g.seconds(F(e, 60));
860
895
  }
861
896
  /**
862
897
  * Creates a TimeSpan representing the given number of hours.
@@ -865,7 +900,7 @@ const w = class g {
865
900
  * @returns A TimeSpan representing the given number of hours.
866
901
  */
867
902
  static hours(e) {
868
- return g.minutes(e * 60);
903
+ return g.minutes(F(e, 60));
869
904
  }
870
905
  /**
871
906
  * Creates a TimeSpan representing the given number of days.
@@ -874,7 +909,7 @@ const w = class g {
874
909
  * @returns A TimeSpan representing the given number of days.
875
910
  */
876
911
  static days(e) {
877
- return g.hours(e * 24);
912
+ return g.hours(F(e, 24));
878
913
  }
879
914
  };
880
915
  u(w, "NANOSECOND", w.nanoseconds(1)), /** A microsecond. */
@@ -895,7 +930,7 @@ u(w, "z", i.union([
895
930
  i.instanceof(w)
896
931
  ]));
897
932
  let S = w;
898
- const Q = class ee extends Number {
933
+ const Z = class te extends Number {
899
934
  constructor(e) {
900
935
  e instanceof Number ? super(e.valueOf()) : super(e);
901
936
  }
@@ -905,7 +940,7 @@ const Q = class ee extends Number {
905
940
  }
906
941
  /** @returns The number of seconds in the Rate. */
907
942
  equals(e) {
908
- return this.valueOf() === new ee(e).valueOf();
943
+ return this.valueOf() === new te(e).valueOf();
909
944
  }
910
945
  /**
911
946
  * Calculates the period of the Rate as a TimeSpan.
@@ -960,7 +995,7 @@ const Q = class ee extends Number {
960
995
  * @returns A Rate representing the given number of Hz.
961
996
  */
962
997
  static hz(e) {
963
- return new ee(e);
998
+ return new te(e);
964
999
  }
965
1000
  /**
966
1001
  * Creates a Rate representing the given number of kHz.
@@ -969,14 +1004,15 @@ const Q = class ee extends Number {
969
1004
  * @returns A Rate representing the given number of kHz.
970
1005
  */
971
1006
  static khz(e) {
972
- return ee.hz(e * 1e3);
1007
+ return te.hz(e * 1e3);
973
1008
  }
974
1009
  };
975
- u(Q, "z", i.union([
976
- i.number().transform((r) => new Q(r)),
977
- i.instanceof(Number).transform((r) => new Q(r)),
978
- i.instanceof(Q)
1010
+ u(Z, "z", i.union([
1011
+ i.number().transform((r) => new Z(r)),
1012
+ i.instanceof(Number).transform((r) => new Z(r)),
1013
+ i.instanceof(Z)
979
1014
  ]));
1015
+ let Re = Z;
980
1016
  const I = class extends Number {
981
1017
  /**
982
1018
  * Creates a Density representing the given number of bytes per value.
@@ -992,7 +1028,7 @@ const I = class extends Number {
992
1028
  return e.valueOf() / this.valueOf();
993
1029
  }
994
1030
  size(e) {
995
- return new Je(e * this.valueOf());
1031
+ return new pe(e * this.valueOf());
996
1032
  }
997
1033
  };
998
1034
  u(I, "UNKNOWN", new I(0)), /** 128 bits per value. */
@@ -1007,7 +1043,7 @@ u(I, "z", i.union([
1007
1043
  i.instanceof(I)
1008
1044
  ]));
1009
1045
  let A = I;
1010
- const M = class te {
1046
+ const M = class re {
1011
1047
  /**
1012
1048
  * Creates a TimeRange from the given start and end TimeStamps.
1013
1049
  *
@@ -1057,7 +1093,7 @@ const M = class te {
1057
1093
  * @returns A TimeRange with the start and end swapped.
1058
1094
  */
1059
1095
  swap() {
1060
- return new te(this.end, this.start);
1096
+ return new re(this.end, this.start);
1061
1097
  }
1062
1098
  /**
1063
1099
  * Checks if the TimeRange is equal to the given TimeRange.
@@ -1095,10 +1131,10 @@ const M = class te {
1095
1131
  return n < 0 && (n = -n), s < 0 && (s = -s), n <= t.valueOf() && s <= t.valueOf();
1096
1132
  }
1097
1133
  contains(e) {
1098
- return e instanceof te ? this.contains(e.start) && this.contains(e.end) : this.start.beforeEq(e) && this.end.after(e);
1134
+ return e instanceof re ? this.contains(e.start) && this.contains(e.end) : this.start.beforeEq(e) && this.end.after(e);
1099
1135
  }
1100
1136
  boundBy(e) {
1101
- const t = new te(this.start, this.end);
1137
+ const t = new re(this.start, this.end);
1102
1138
  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;
1103
1139
  }
1104
1140
  };
@@ -1109,18 +1145,17 @@ u(M, "z", i.union([
1109
1145
  i.object({ start: O.z, end: O.z }).transform((r) => new M(r.start, r.end)),
1110
1146
  i.instanceof(M)
1111
1147
  ]));
1112
- let me = M;
1148
+ let Te = M;
1113
1149
  const o = class $ extends String {
1114
1150
  constructor(e) {
1115
1151
  if (e instanceof $ || typeof e == "string" || typeof e.valueOf() == "string") {
1116
1152
  super(e.valueOf());
1117
1153
  return;
1118
- } else {
1119
- const t = $.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);
1120
- if (t != null) {
1121
- super(t.valueOf());
1122
- return;
1123
- }
1154
+ }
1155
+ const t = $.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);
1156
+ if (t != null) {
1157
+ super(t.valueOf());
1158
+ return;
1124
1159
  }
1125
1160
  throw super($.UNKNOWN.valueOf()), new Error(`unable to find data type for ${e.toString()}`);
1126
1161
  }
@@ -1308,9 +1343,9 @@ const N = class v extends Number {
1308
1343
  return this.valueOf() / v.TERABYTE.valueOf();
1309
1344
  }
1310
1345
  toString() {
1311
- const e = this.truncate(v.TERABYTE), t = this.truncate(v.GIGABYTE), n = this.truncate(v.MEGABYTE), s = this.truncate(v.KILOBYTE), a = this.truncate(v.BYTE), c = e, d = t.sub(e), f = n.sub(t), y = s.sub(n), T = a.sub(s);
1346
+ const e = this.truncate(v.TERABYTE), t = this.truncate(v.GIGABYTE), n = this.truncate(v.MEGABYTE), s = this.truncate(v.KILOBYTE), a = this.truncate(v.BYTE), c = e, f = t.sub(e), d = n.sub(t), y = s.sub(n), T = a.sub(s);
1312
1347
  let l = "";
1313
- return c.isZero || (l += `${c.terabytes}TB `), d.isZero || (l += `${d.gigabytes}GB `), f.isZero || (l += `${f.megabytes}MB `), y.isZero || (l += `${y.kilobytes}KB `), (!T.isZero || l === "") && (l += `${T.valueOf()}B`), l.trim();
1348
+ return c.isZero || (l += `${c.terabytes}TB `), f.isZero || (l += `${f.gigabytes}GB `), d.isZero || (l += `${d.megabytes}MB `), y.isZero || (l += `${y.kilobytes}KB `), (!T.isZero || l === "") && (l += `${T.valueOf()}B`), l.trim();
1314
1349
  }
1315
1350
  /**
1316
1351
  * Creates a Size from the given number of bytes.
@@ -1371,7 +1406,7 @@ u(N, "z", i.union([
1371
1406
  i.number().transform((r) => new N(r)),
1372
1407
  i.instanceof(N)
1373
1408
  ]));
1374
- let Je = N;
1409
+ let pe = N;
1375
1410
  i.union([
1376
1411
  i.instanceof(Uint8Array),
1377
1412
  i.instanceof(Uint16Array),
@@ -1384,44 +1419,44 @@ i.union([
1384
1419
  i.instanceof(Int32Array),
1385
1420
  i.instanceof(BigInt64Array)
1386
1421
  ]);
1387
- const He = (r) => {
1422
+ const et = (r) => {
1388
1423
  const e = typeof r;
1389
1424
  return e === "string" || e === "number" || e === "boolean" || e === "bigint" || r instanceof O || r instanceof S || r instanceof Date;
1390
- }, _t = (r, e, t, n = 0) => r.usesBigInt && !e.usesBigInt ? Number(t) - Number(n) : !r.usesBigInt && e.usesBigInt ? BigInt(t) - BigInt(n) : Z(t, -n), er = (r) => r == null ? !1 : Array.isArray(r) || r instanceof ArrayBuffer || ArrayBuffer.isView(r) && !(r instanceof DataView) || r instanceof nr ? !0 : He(r), Y = -1, tr = i.string().transform(
1425
+ }, ir = (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).valueOf(), ar = (r) => r == null ? !1 : Array.isArray(r) || r instanceof ArrayBuffer || ArrayBuffer.isView(r) && !(r instanceof DataView) || r instanceof cr ? !0 : et(r), P = -1, or = i.string().transform(
1391
1426
  (r) => new Uint8Array(
1392
1427
  atob(r).split("").map((e) => e.charCodeAt(0))
1393
1428
  ).buffer
1394
- ), rr = i.union([i.null(), i.undefined()]).transform(() => new Uint8Array().buffer), z = class C {
1429
+ ), ur = i.union([i.null(), i.undefined()]).transform(() => new Uint8Array().buffer), ye = 10, J = class B {
1395
1430
  constructor(e) {
1396
- u(this, "key", ""), u(this, "isSynnaxSeries", !0), u(this, "dataType"), u(this, "sampleOffset"), u(this, "gl"), u(this, "_data"), u(this, "_timeRange"), u(this, "alignment", 0n), u(this, "_cachedMin"), u(this, "_cachedMax"), u(this, "writePos", Y), u(this, "_refCount", 0), u(this, "_cachedLength"), er(e) && (e = { data: e });
1431
+ u(this, "key", ""), u(this, "isSynnaxSeries", !0), u(this, "dataType"), u(this, "sampleOffset"), u(this, "gl"), u(this, "_data"), u(this, "_timeRange"), u(this, "alignment", 0n), u(this, "_cachedMin"), u(this, "_cachedMax"), u(this, "writePos", P), u(this, "_refCount", 0), u(this, "_cachedLength"), u(this, "_cachedIndexes"), ar(e) && (e = { data: e });
1397
1432
  const {
1398
1433
  dataType: t,
1399
1434
  timeRange: n,
1400
1435
  sampleOffset: s = 0,
1401
1436
  glBufferUsage: a = "static",
1402
1437
  alignment: c = 0n,
1403
- key: d = Xt()
1404
- } = e, f = e.data ?? [];
1405
- if (f instanceof C || typeof f == "object" && "isSynnaxSeries" in f && f.isSynnaxSeries === !0) {
1406
- const l = f;
1438
+ key: f = nr()
1439
+ } = e, d = e.data ?? [];
1440
+ if (d instanceof B || typeof d == "object" && "isSynnaxSeries" in d && d.isSynnaxSeries === !0) {
1441
+ const l = d;
1407
1442
  this.key = l.key, this.dataType = l.dataType, this.sampleOffset = l.sampleOffset, this.gl = l.gl, this._data = l._data, this._timeRange = l._timeRange, this.alignment = l.alignment, this._cachedMin = l._cachedMin, this._cachedMax = l._cachedMax, this.writePos = l.writePos, this._refCount = l._refCount, this._cachedLength = l._cachedLength;
1408
1443
  return;
1409
1444
  }
1410
- const y = He(f), T = Array.isArray(f);
1445
+ const y = et(d), T = Array.isArray(d);
1411
1446
  if (t != null) this.dataType = new b(t);
1412
1447
  else {
1413
- if (f instanceof ArrayBuffer)
1448
+ if (d instanceof ArrayBuffer)
1414
1449
  throw new Error(
1415
1450
  "cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type."
1416
1451
  );
1417
1452
  if (T || y) {
1418
- let l = f;
1453
+ let l = d;
1419
1454
  if (!y) {
1420
- if (f.length === 0)
1455
+ if (d.length === 0)
1421
1456
  throw new Error(
1422
1457
  "cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type."
1423
1458
  );
1424
- l = f[0];
1459
+ l = d[0];
1425
1460
  }
1426
1461
  if (typeof l == "string") this.dataType = b.STRING;
1427
1462
  else if (typeof l == "number") this.dataType = b.FLOAT64;
@@ -1434,21 +1469,21 @@ const He = (r) => {
1434
1469
  throw new Error(
1435
1470
  `cannot infer data type of ${typeof l} when constructing a Series from a JS array`
1436
1471
  );
1437
- } else this.dataType = new b(f);
1472
+ } else this.dataType = new b(d);
1438
1473
  }
1439
- if (!T && !y) this._data = f;
1474
+ if (!T && !y) this._data = d;
1440
1475
  else {
1441
- let l = y ? [f] : f;
1476
+ let l = y ? [d] : d;
1442
1477
  const E = l[0];
1443
- (E instanceof O || E instanceof Date || E instanceof S) && (l = l.map((R) => new O(R).valueOf())), this.dataType.equals(b.STRING) ? (this._cachedLength = l.length, this._data = new TextEncoder().encode(l.join(`
1444
- `) + `
1478
+ (E instanceof O || E instanceof Date || E instanceof S) && (l = l.map((R) => new O(R).valueOf())), this.dataType.equals(b.STRING) ? (this._cachedLength = l.length, this._data = new TextEncoder().encode(`${l.join(`
1479
+ `)}
1445
1480
  `)) : this.dataType.equals(b.JSON) ? (this._cachedLength = l.length, this._data = new TextEncoder().encode(
1446
- l.map((R) => _.encodeString(R)).join(`
1447
- `) + `
1481
+ `${l.map((R) => ee.encodeString(R)).join(`
1482
+ `)}
1448
1483
  `
1449
1484
  )) : this._data = new this.dataType.Array(l).buffer;
1450
1485
  }
1451
- this.key = d, this.alignment = c, this.sampleOffset = s ?? 0, this._timeRange = n, this.gl = {
1486
+ this.key = f, this.alignment = c, this.sampleOffset = s ?? 0, this._timeRange = n, this.gl = {
1452
1487
  control: null,
1453
1488
  buffer: null,
1454
1489
  prevBuffer: 0,
@@ -1458,7 +1493,7 @@ const He = (r) => {
1458
1493
  static alloc({ capacity: e, dataType: t, ...n }) {
1459
1494
  if (e === 0)
1460
1495
  throw new Error("[Series] - cannot allocate an array of length 0");
1461
- const s = new new b(t).Array(e), a = new C({
1496
+ const s = new new b(t).Array(e), a = new B({
1462
1497
  data: s.buffer,
1463
1498
  dataType: t,
1464
1499
  ...n
@@ -1469,24 +1504,24 @@ const He = (r) => {
1469
1504
  const s = n.spanRange(t.span(e)), a = new BigInt64Array(e);
1470
1505
  for (let c = 0; c < e; c++)
1471
1506
  a[c] = BigInt(n.add(t.span(c)).valueOf());
1472
- return new C({ data: a, dataType: b.TIMESTAMP, timeRange: s });
1507
+ return new B({ data: a, dataType: b.TIMESTAMP, timeRange: s });
1473
1508
  }
1474
1509
  get refCount() {
1475
1510
  return this._refCount;
1476
1511
  }
1477
1512
  static fromStrings(e, t) {
1478
- const n = new TextEncoder().encode(e.join(`
1479
- `) + `
1513
+ const n = new TextEncoder().encode(`${e.join(`
1514
+ `)}
1480
1515
  `);
1481
- return new C({ data: n, dataType: b.STRING, timeRange: t });
1516
+ return new B({ data: n, dataType: b.STRING, timeRange: t });
1482
1517
  }
1483
1518
  static fromJSON(e, t) {
1484
1519
  const n = new TextEncoder().encode(
1485
- e.map((s) => _.encodeString(s)).join(`
1486
- `) + `
1520
+ `${e.map((s) => ee.encodeString(s)).join(`
1521
+ `)}
1487
1522
  `
1488
1523
  );
1489
- return new C({ data: n, dataType: b.JSON, timeRange: t });
1524
+ return new B({ data: n, dataType: b.JSON, timeRange: t });
1490
1525
  }
1491
1526
  acquire(e) {
1492
1527
  this._refCount++, e != null && this.updateGLBuffer(e);
@@ -1508,28 +1543,39 @@ const He = (r) => {
1508
1543
  write(e) {
1509
1544
  if (!e.dataType.equals(this.dataType))
1510
1545
  throw new Error("buffer must be of the same type as this array");
1511
- if (this.writePos === Y) return 0;
1512
- const t = this.capacity - this.writePos, n = t < e.length ? e.slice(0, t) : e;
1513
- return this.underlyingData.set(
1514
- n.data,
1546
+ return this.dataType.isVariable ? this.writeVariable(e) : this.writeFixed(e);
1547
+ }
1548
+ writeVariable(e) {
1549
+ if (this.writePos === P) return 0;
1550
+ const t = this.byteCapacity.valueOf() - this.writePos, n = e.subBytes(0, t);
1551
+ return this.writeToUnderlyingData(n), this.writePos += n.byteLength.valueOf(), this._cachedLength != null && (this._cachedLength += n.length, this.calculateCachedLength()), n.length;
1552
+ }
1553
+ writeFixed(e) {
1554
+ if (this.writePos === P) return 0;
1555
+ const t = this.capacity - this.writePos, n = e.sub(0, t);
1556
+ return this.writeToUnderlyingData(n), this._cachedLength = void 0, this.maybeRecomputeMinMax(n), this.writePos += n.length, n.length;
1557
+ }
1558
+ writeToUnderlyingData(e) {
1559
+ this.underlyingData.set(
1560
+ e.data,
1515
1561
  this.writePos
1516
- ), this.maybeRecomputeMinMax(n), this._cachedLength = void 0, this.writePos += n.length, n.length;
1562
+ );
1517
1563
  }
1518
1564
  /** @returns the underlying buffer backing this array. */
1519
1565
  get buffer() {
1520
- return this._data;
1566
+ return this._data instanceof ArrayBuffer || this._data instanceof SharedArrayBuffer ? this._data : this._data.buffer;
1521
1567
  }
1522
1568
  get underlyingData() {
1523
1569
  return new this.dataType.Array(this._data);
1524
1570
  }
1525
1571
  /** @returns a native typed array with the proper data type. */
1526
1572
  get data() {
1527
- return this.writePos === Y ? this.underlyingData : new this.dataType.Array(this._data, 0, this.writePos);
1573
+ return this.writePos === P ? this.underlyingData : new this.dataType.Array(this._data, 0, this.writePos);
1528
1574
  }
1529
1575
  toStrings() {
1530
1576
  if (!this.dataType.matches(b.STRING, b.UUID))
1531
1577
  throw new Error("cannot convert non-string series to strings");
1532
- return new TextDecoder().decode(this.buffer).split(`
1578
+ return new TextDecoder().decode(this.underlyingData).split(`
1533
1579
  `).slice(0, -1);
1534
1580
  }
1535
1581
  toUUIDs() {
@@ -1537,7 +1583,7 @@ const He = (r) => {
1537
1583
  throw new Error("cannot convert non-uuid series to uuids");
1538
1584
  const e = b.UUID.density.valueOf(), t = Array(this.length);
1539
1585
  for (let n = 0; n < this.length; n++) {
1540
- const s = this.buffer.slice(n * e, (n + 1) * e), a = Array.from(new Uint8Array(s), (c) => c.toString(16).padStart(2, "0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/, "$1-$2-$3-$4-$5");
1586
+ const s = this.underlyingData.slice(n * e, (n + 1) * e), a = Array.from(new Uint8Array(s), (c) => c.toString(16).padStart(2, "0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/, "$1-$2-$3-$4-$5");
1541
1587
  t[n] = a;
1542
1588
  }
1543
1589
  return t;
@@ -1545,8 +1591,8 @@ const He = (r) => {
1545
1591
  parseJSON(e) {
1546
1592
  if (!this.dataType.equals(b.JSON))
1547
1593
  throw new Error("cannot convert non-string series to strings");
1548
- return new TextDecoder().decode(this.buffer).split(`
1549
- `).slice(0, -1).map((t) => e.parse(_.decodeString(t)));
1594
+ return new TextDecoder().decode(this.underlyingData).split(`
1595
+ `).slice(0, -1).map((t) => e.parse(ee.decodeString(t)));
1550
1596
  }
1551
1597
  /** @returns the time range of this array. */
1552
1598
  get timeRange() {
@@ -1555,27 +1601,28 @@ const He = (r) => {
1555
1601
  }
1556
1602
  /** @returns the capacity of the series in bytes. */
1557
1603
  get byteCapacity() {
1558
- return new Je(this.buffer.byteLength);
1604
+ return new pe(this.underlyingData.byteLength);
1559
1605
  }
1560
1606
  /** @returns the capacity of the series in samples. */
1561
1607
  get capacity() {
1562
- return this.dataType.density.length(this.byteCapacity);
1608
+ return this.dataType.isVariable ? this.byteCapacity.valueOf() : this.dataType.density.length(this.byteCapacity);
1563
1609
  }
1564
1610
  /** @returns the length of the series in bytes. */
1565
1611
  get byteLength() {
1566
- return this.writePos === Y ? this.byteCapacity : this.dataType.density.size(this.writePos);
1612
+ return this.writePos === P ? this.byteCapacity : this.dataType.isVariable ? new pe(this.writePos) : this.dataType.density.size(this.writePos);
1567
1613
  }
1568
1614
  /** @returns the number of samples in this array. */
1569
1615
  get length() {
1570
- return this._cachedLength != null ? this._cachedLength : this.dataType.isVariable ? this.calculateCachedLength() : this.writePos === Y ? this.data.length : this.writePos;
1616
+ return this._cachedLength != null ? this._cachedLength : this.dataType.isVariable ? this.calculateCachedLength() : this.writePos === P ? this.data.length : this.writePos;
1571
1617
  }
1572
1618
  calculateCachedLength() {
1573
1619
  if (!this.dataType.isVariable)
1574
1620
  throw new Error("cannot calculate length of a non-variable length data type");
1575
1621
  let e = 0;
1576
- return this.data.forEach((t) => {
1577
- t === 10 && e++;
1578
- }), this._cachedLength = e, e;
1622
+ const t = [0];
1623
+ return this.data.forEach((n, s) => {
1624
+ n === ye && (e++, t.push(s + 1));
1625
+ }), this._cachedIndexes = t, this._cachedLength = e, e;
1579
1626
  }
1580
1627
  /**
1581
1628
  * Creates a new array with a different data type.
@@ -1590,8 +1637,8 @@ const He = (r) => {
1590
1637
  if (this.dataType.equals(e)) return this;
1591
1638
  const n = new e.Array(this.length);
1592
1639
  for (let s = 0; s < this.length; s++)
1593
- n[s] = _t(this.dataType, e, this.data[s], t);
1594
- return new C({
1640
+ n[s] = ir(this.dataType, e, this.data[s], t);
1641
+ return new B({
1595
1642
  data: n.buffer,
1596
1643
  dataType: e,
1597
1644
  timeRange: this._timeRange,
@@ -1617,12 +1664,11 @@ const He = (r) => {
1617
1664
  get max() {
1618
1665
  if (this.dataType.isVariable)
1619
1666
  throw new Error("cannot calculate maximum on a variable length data type");
1620
- return this.writePos === 0 ? -1 / 0 : (this._cachedMax == null && (this._cachedMax = this.calcRawMax()), Z(this._cachedMax, this.sampleOffset));
1667
+ return this.writePos === 0 ? -1 / 0 : (this._cachedMax ?? (this._cachedMax = this.calcRawMax()), H(this._cachedMax, this.sampleOffset));
1621
1668
  }
1622
1669
  calcRawMin() {
1623
1670
  if (this.length === 0) return 1 / 0;
1624
- if (this.dataType.equals(b.TIMESTAMP))
1625
- this._cachedMin = this.data[0];
1671
+ if (this.dataType.equals(b.TIMESTAMP)) this._cachedMin = this.data[0];
1626
1672
  else if (this.dataType.usesBigInt) {
1627
1673
  const e = this.data;
1628
1674
  this._cachedMin = e.reduce((t, n) => t < n ? t : n);
@@ -1636,11 +1682,11 @@ const He = (r) => {
1636
1682
  get min() {
1637
1683
  if (this.dataType.isVariable)
1638
1684
  throw new Error("cannot calculate minimum on a variable length data type");
1639
- return this.writePos === 0 ? 1 / 0 : (this._cachedMin == null && (this._cachedMin = this.calcRawMin()), Z(this._cachedMin, this.sampleOffset));
1685
+ return this.writePos === 0 ? 1 / 0 : (this._cachedMin ?? (this._cachedMin = this.calcRawMin()), H(this._cachedMin, this.sampleOffset));
1640
1686
  }
1641
1687
  /** @returns the bounds of this array. */
1642
1688
  get bounds() {
1643
- return K(Number(this.min), Number(this.max));
1689
+ return k(Number(this.min), Number(this.max));
1644
1690
  }
1645
1691
  maybeRecomputeMinMax(e) {
1646
1692
  if (this._cachedMin != null) {
@@ -1656,7 +1702,15 @@ const He = (r) => {
1656
1702
  this.max, this.min;
1657
1703
  }
1658
1704
  get range() {
1659
- return Z(this.max, -this.min);
1705
+ return H(this.max, -this.min);
1706
+ }
1707
+ atAlignment(e, t) {
1708
+ const n = Number(e - this.alignment);
1709
+ if (n < 0 || n >= this.length) {
1710
+ if (t === !0) throw new Error(`[series] - no value at index ${n}`);
1711
+ return;
1712
+ }
1713
+ return this.at(n, t);
1660
1714
  }
1661
1715
  at(e, t) {
1662
1716
  if (this.dataType.isVariable) return this.atVariable(e, t ?? !1);
@@ -1666,25 +1720,29 @@ const He = (r) => {
1666
1720
  if (t === !0) throw new Error(`[series] - no value at index ${e}`);
1667
1721
  return;
1668
1722
  }
1669
- return Z(n, this.sampleOffset);
1723
+ return H(n, this.sampleOffset);
1670
1724
  }
1671
1725
  atVariable(e, t) {
1672
- e < 0 && (e = this.length + e);
1673
1726
  let n = 0, s = 0;
1674
- for (let c = 0; c < this.data.length; c++)
1675
- if (this.data[c] === 10) {
1676
- if (e === 0) {
1677
- s = c;
1678
- break;
1727
+ if (this._cachedIndexes != null)
1728
+ n = this._cachedIndexes[e], s = this._cachedIndexes[e + 1] - 1;
1729
+ else {
1730
+ e < 0 && (e = this.length + e);
1731
+ for (let c = 0; c < this.data.length; c++)
1732
+ if (this.data[c] === ye) {
1733
+ if (e === 0) {
1734
+ s = c;
1735
+ break;
1736
+ }
1737
+ n = c + 1, e--;
1679
1738
  }
1680
- n = c + 1, e--;
1739
+ if (s === 0 && (s = this.data.length), n >= s || e > 0) {
1740
+ if (t) throw new Error(`[series] - no value at index ${e}`);
1741
+ return;
1681
1742
  }
1682
- if (s === 0 && (s = this.data.length), n >= s || e > 0) {
1683
- if (t) throw new Error(`[series] - no value at index ${e}`);
1684
- return;
1685
1743
  }
1686
1744
  const a = this.data.slice(n, s);
1687
- return this.dataType.equals(b.STRING) ? new TextDecoder().decode(a) : Ye(
1745
+ return this.dataType.equals(b.STRING) ? new TextDecoder().decode(a) : We(
1688
1746
  JSON.parse(new TextDecoder().decode(a))
1689
1747
  );
1690
1748
  }
@@ -1695,7 +1753,7 @@ const He = (r) => {
1695
1753
  */
1696
1754
  binarySearch(e) {
1697
1755
  let t = 0, n = this.length - 1;
1698
- const s = qt(e);
1756
+ const s = Ht(e);
1699
1757
  for (; t <= n; ) {
1700
1758
  const a = Math.floor((t + n) / 2), c = s(this.at(a, !0), e);
1701
1759
  if (c === 0) return a;
@@ -1708,16 +1766,16 @@ const He = (r) => {
1708
1766
  throw new Error("Only FLOAT32 arrays can be used in WebGL");
1709
1767
  const { buffer: t, bufferUsage: n, prevBuffer: s } = this.gl;
1710
1768
  if (t == null && (this.gl.buffer = e.createBuffer()), this.writePos !== s)
1711
- if (e.bindBuffer(e.ARRAY_BUFFER, this.gl.buffer), this.writePos !== Y) {
1769
+ if (e.bindBuffer(e.ARRAY_BUFFER, this.gl.buffer), this.writePos !== P) {
1712
1770
  s === 0 && e.bufferData(e.ARRAY_BUFFER, this.byteCapacity.valueOf(), e.STATIC_DRAW);
1713
1771
  const a = this.dataType.density.size(s).valueOf(), c = this.underlyingData.slice(this.gl.prevBuffer, this.writePos);
1714
1772
  e.bufferSubData(e.ARRAY_BUFFER, a, c.buffer), this.gl.prevBuffer = this.writePos;
1715
1773
  } else
1716
1774
  e.bufferData(
1717
1775
  e.ARRAY_BUFFER,
1718
- this.buffer,
1776
+ this.underlyingData,
1719
1777
  n === "static" ? e.STATIC_DRAW : e.DYNAMIC_DRAW
1720
- ), this.gl.prevBuffer = Y;
1778
+ ), this.gl.prevBuffer = P;
1721
1779
  }
1722
1780
  as(e) {
1723
1781
  if (e === "string") {
@@ -1764,7 +1822,7 @@ const He = (r) => {
1764
1822
  };
1765
1823
  }
1766
1824
  get alignmentBounds() {
1767
- return K(this.alignment, this.alignment + BigInt(this.length));
1825
+ return k(this.alignment, this.alignment + BigInt(this.length));
1768
1826
  }
1769
1827
  maybeGarbageCollectGLBuffer(e) {
1770
1828
  this.gl.buffer != null && (e.deleteBuffer(this.gl.buffer), this.gl.buffer = null, this.gl.prevBuffer = 0, this.gl.control = null);
@@ -1775,15 +1833,31 @@ const He = (r) => {
1775
1833
  }
1776
1834
  [Symbol.iterator]() {
1777
1835
  if (this.dataType.isVariable) {
1778
- const e = new sr(this);
1779
- return this.dataType.equals(b.JSON) ? new ir(e) : e;
1836
+ const e = new lr(this);
1837
+ return this.dataType.equals(b.JSON) ? new hr(e) : e;
1780
1838
  }
1781
- return new ar(this);
1839
+ return new fr(this);
1782
1840
  }
1783
1841
  slice(e, t) {
1784
- if (e <= 0 && (t == null || t >= this.length)) return this;
1785
- const n = this.data.slice(e, t);
1786
- return new C({
1842
+ return this.sliceSub(!1, e, t);
1843
+ }
1844
+ sub(e, t) {
1845
+ return this.sliceSub(!0, e, t);
1846
+ }
1847
+ subIterator(e, t) {
1848
+ return new Ue(this, e, t ?? this.length);
1849
+ }
1850
+ subAlignmentIterator(e, t) {
1851
+ return new Ue(
1852
+ this,
1853
+ Number(e - this.alignment),
1854
+ Number(t - this.alignment)
1855
+ );
1856
+ }
1857
+ subBytes(e, t) {
1858
+ if (e >= 0 && (t == null || t >= this.byteLength.valueOf())) return this;
1859
+ const n = this.data.subarray(e, t);
1860
+ return new B({
1787
1861
  data: n,
1788
1862
  dataType: this.dataType,
1789
1863
  timeRange: this._timeRange,
@@ -1792,26 +1866,51 @@ const He = (r) => {
1792
1866
  alignment: this.alignment + BigInt(e)
1793
1867
  });
1794
1868
  }
1869
+ sliceSub(e, t, n) {
1870
+ if (t <= 0 && (n == null || n >= this.length)) return this;
1871
+ let s;
1872
+ return e ? s = this.data.subarray(t, n) : s = this.data.slice(t, n), new B({
1873
+ data: s,
1874
+ dataType: this.dataType,
1875
+ timeRange: this._timeRange,
1876
+ sampleOffset: this.sampleOffset,
1877
+ glBufferUsage: this.gl.bufferUsage,
1878
+ alignment: this.alignment + BigInt(t)
1879
+ });
1880
+ }
1795
1881
  reAlign(e) {
1796
- return new C({
1882
+ return new B({
1797
1883
  data: this.buffer,
1798
1884
  dataType: this.dataType,
1799
- timeRange: me.ZERO,
1885
+ timeRange: Te.ZERO,
1800
1886
  sampleOffset: this.sampleOffset,
1801
1887
  glBufferUsage: "static",
1802
1888
  alignment: e
1803
1889
  });
1804
1890
  }
1805
1891
  };
1806
- u(z, "crudeZ", i.object({
1807
- timeRange: me.z.optional(),
1892
+ u(J, "crudeZ", i.object({
1893
+ timeRange: Te.z.optional(),
1808
1894
  dataType: b.z,
1809
- alignment: Zt.optional(),
1810
- data: i.union([tr, rr, i.instanceof(ArrayBuffer)]),
1811
- glBufferUsage: Qt.optional().default("static").optional()
1812
- })), u(z, "z", z.crudeZ.transform((r) => new z(r)));
1813
- let nr = z;
1814
- class sr {
1895
+ alignment: Qt.optional(),
1896
+ data: i.union([or, ur, i.instanceof(ArrayBuffer)]),
1897
+ glBufferUsage: sr.optional().default("static").optional()
1898
+ })), u(J, "z", J.crudeZ.transform((r) => new J(r)));
1899
+ let cr = J;
1900
+ class Ue {
1901
+ constructor(e, t, n) {
1902
+ u(this, "series"), u(this, "end"), u(this, "index"), this.series = e;
1903
+ const s = k(0, e.length);
1904
+ this.end = Ae(s, n), this.index = Ae(s, t);
1905
+ }
1906
+ next() {
1907
+ return this.index >= this.end ? { done: !0, value: void 0 } : { done: !1, value: this.series.at(this.index++, !0) };
1908
+ }
1909
+ [Symbol.iterator]() {
1910
+ return this;
1911
+ }
1912
+ }
1913
+ class lr {
1815
1914
  constructor(e) {
1816
1915
  if (u(this, "series"), u(this, "index"), u(this, "decoder"), !e.dataType.isVariable)
1817
1916
  throw new Error(
@@ -1821,7 +1920,7 @@ class sr {
1821
1920
  }
1822
1921
  next() {
1823
1922
  const e = this.index, t = this.series.data;
1824
- for (; this.index < t.length && t[this.index] !== 10; ) this.index++;
1923
+ for (; this.index < t.length && t[this.index] !== ye; ) this.index++;
1825
1924
  const n = this.index;
1826
1925
  return e === n ? { done: !0, value: void 0 } : (this.index++, { done: !1, value: this.decoder.decode(this.series.buffer.slice(e, n)) });
1827
1926
  }
@@ -1829,26 +1928,26 @@ class sr {
1829
1928
  return this;
1830
1929
  }
1831
1930
  }
1832
- var xe, Me;
1833
- class ir {
1931
+ var Ce, De;
1932
+ class hr {
1834
1933
  constructor(e) {
1835
- u(this, "wrapped"), u(this, xe, "JSONSeriesIterator"), this.wrapped = e;
1934
+ u(this, "wrapped"), u(this, Ce, "JSONSeriesIterator"), this.wrapped = e;
1836
1935
  }
1837
1936
  next() {
1838
1937
  const e = this.wrapped.next();
1839
1938
  return e.done === !0 ? { done: !0, value: void 0 } : {
1840
1939
  done: !1,
1841
- value: _.decodeString(e.value)
1940
+ value: ee.decodeString(e.value)
1842
1941
  };
1843
1942
  }
1844
- [(Me = Symbol.iterator, xe = Symbol.toStringTag, Me)]() {
1943
+ [(De = Symbol.iterator, Ce = Symbol.toStringTag, De)]() {
1845
1944
  return this;
1846
1945
  }
1847
1946
  }
1848
- var $e, Re;
1849
- class ar {
1947
+ var Pe, Le;
1948
+ class fr {
1850
1949
  constructor(e) {
1851
- u(this, "series"), u(this, "index"), u(this, $e, "SeriesIterator"), this.series = e, this.index = 0;
1950
+ u(this, "series"), u(this, "index"), u(this, Pe, "SeriesIterator"), this.series = e, this.index = 0;
1852
1951
  }
1853
1952
  next() {
1854
1953
  return this.index >= this.series.length ? { done: !0, value: void 0 } : {
@@ -1856,11 +1955,11 @@ class ar {
1856
1955
  value: this.series.at(this.index++, !0)
1857
1956
  };
1858
1957
  }
1859
- [(Re = Symbol.iterator, $e = Symbol.toStringTag, Re)]() {
1958
+ [(Le = Symbol.iterator, Pe = Symbol.toStringTag, Le)]() {
1860
1959
  return this;
1861
1960
  }
1862
1961
  }
1863
- const Z = (r, e) => typeof r == "bigint" && typeof e == "bigint" || typeof r == "number" && typeof e == "number" ? r + e : e === 0 ? r : r === 0 ? e : Number(r) + Number(e);
1962
+ const H = (r, e) => typeof r == "bigint" && typeof e == "bigint" || typeof r == "number" && typeof e == "number" ? r + e : e === 0 ? r : r === 0 ? e : Number(r) + Number(e);
1864
1963
  i.object({
1865
1964
  key: i.string(),
1866
1965
  value: i.string()
@@ -1869,27 +1968,27 @@ i.record(
1869
1968
  i.union([i.number(), i.string(), i.symbol()]),
1870
1969
  i.unknown()
1871
1970
  );
1872
- const Ke = () => typeof process < "u" && process.versions != null && process.versions.node != null ? "node" : typeof window > "u" || window.document === void 0 ? "webworker" : "browser", or = Ke(), Xe = ["MacOS", "Windows", "Linux", "Docker"], ur = i.enum(Xe);
1873
- let he;
1874
- const cr = () => {
1971
+ const tt = () => typeof process < "u" && process.versions != null && process.versions.node != null ? "node" : typeof window > "u" || window.document === void 0 ? "webworker" : "browser", dr = tt(), rt = ["MacOS", "Windows", "Linux", "Docker"], gr = i.enum(rt);
1972
+ let fe;
1973
+ const pr = () => {
1875
1974
  if (typeof window > "u") return;
1876
1975
  const r = window.navigator.userAgent.toLowerCase();
1877
1976
  if (r.includes("mac")) return "MacOS";
1878
1977
  if (r.includes("win")) return "Windows";
1879
1978
  if (r.includes("linux")) return "Linux";
1880
- }, lr = (r = {}) => {
1979
+ }, yr = (r = {}) => {
1881
1980
  const { force: e, default: t } = r;
1882
- return e ?? he ?? (he = cr(), he ?? t);
1883
- }, Qe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1981
+ return e ?? fe ?? (fe = pr(), fe ?? t);
1982
+ }, nt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1884
1983
  __proto__: null,
1885
- OPERATING_SYSTEMS: Xe,
1886
- RUNTIME: or,
1887
- detect: Ke,
1888
- getOS: lr,
1889
- osZ: ur
1984
+ OPERATING_SYSTEMS: rt,
1985
+ RUNTIME: dr,
1986
+ detect: tt,
1987
+ getOS: yr,
1988
+ osZ: gr
1890
1989
  }, Symbol.toStringTag, { value: "Module" }));
1891
- var hr = Object.defineProperty, dr = (r, e, t) => e in r ? hr(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, V = (r, e, t) => dr(r, typeof e != "symbol" ? e + "" : e, t);
1892
- const fr = (...r) => r.map(_e).join(""), _e = (r) => (r.endsWith("/") || (r += "/"), r.startsWith("/") && (r = r.slice(1)), r), gr = (r) => r.endsWith("/") ? r.slice(0, -1) : r, pr = (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("&"), ge = class pe {
1990
+ var mr = Object.defineProperty, wr = (r, e, t) => e in r ? mr(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, K = (r, e, t) => wr(r, typeof e != "symbol" ? e + "" : e, t);
1991
+ const br = (...r) => r.map(st).join(""), st = (r) => (r.endsWith("/") || (r += "/"), r.startsWith("/") && (r = r.slice(1)), r), Tr = (r) => r.endsWith("/") ? r.slice(0, -1) : r, Or = (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("&")}`, me = class we {
1893
1992
  /**
1894
1993
  * @param host - The hostname or IP address of the server.
1895
1994
  * @param port - The port number of the server.
@@ -1897,7 +1996,7 @@ const fr = (...r) => r.map(_e).join(""), _e = (r) => (r.endsWith("/") || (r += "
1897
1996
  * @param pathPrefix - A path prefix to use for all requests. Defaults to "".
1898
1997
  */
1899
1998
  constructor({ host: e, port: t, protocol: n = "", pathPrefix: s = "" }) {
1900
- V(this, "protocol"), V(this, "host"), V(this, "port"), V(this, "path"), this.protocol = n, this.host = e, this.port = t, this.path = _e(s);
1999
+ K(this, "protocol"), K(this, "host"), K(this, "port"), K(this, "path"), this.protocol = n, this.host = e, this.port = t, this.path = st(s);
1901
2000
  }
1902
2001
  /**
1903
2002
  * Replaces creates a new URL with the specified properties replaced.
@@ -1905,7 +2004,7 @@ const fr = (...r) => r.map(_e).join(""), _e = (r) => (r.endsWith("/") || (r += "
1905
2004
  * @returns a new URL.
1906
2005
  */
1907
2006
  replace(e) {
1908
- return new pe({
2007
+ return new we({
1909
2008
  host: e.host ?? this.host,
1910
2009
  port: e.port ?? this.port,
1911
2010
  protocol: e.protocol ?? this.protocol,
@@ -1918,54 +2017,54 @@ const fr = (...r) => r.map(_e).join(""), _e = (r) => (r.endsWith("/") || (r += "
1918
2017
  * @returns a new URL.
1919
2018
  */
1920
2019
  child(e) {
1921
- return new pe({
2020
+ return new we({
1922
2021
  ...this,
1923
- pathPrefix: fr(this.path, e)
2022
+ pathPrefix: br(this.path, e)
1924
2023
  });
1925
2024
  }
1926
2025
  /** @returns a string representation of the url */
1927
2026
  toString() {
1928
- return gr(
2027
+ return Tr(
1929
2028
  `${this.protocol}://${this.host}:${this.port}/${this.path}`
1930
2029
  );
1931
2030
  }
1932
2031
  };
1933
- V(ge, "UNKNOWN", new ge({ host: "unknown", port: 0 }));
1934
- let yr = ge;
1935
- var mr = Object.defineProperty, wr = (r, e, t) => e in r ? mr(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, re = (r, e, t) => wr(r, typeof e != "symbol" ? e + "" : e, t);
1936
- const j = class extends Number {
2032
+ K(me, "UNKNOWN", new me({ host: "unknown", port: 0 }));
2033
+ let vr = me;
2034
+ var Sr = Object.defineProperty, Ir = (r, e, t) => e in r ? Sr(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, ne = (r, e, t) => Ir(r, typeof e != "symbol" ? e + "" : e, t);
2035
+ const G = class extends Number {
1937
2036
  };
1938
- re(j, "Absolute", 255), re(j, "Default", 1), re(j, "z", i.union([
1939
- i.instanceof(j),
1940
- i.number().int().min(0).max(255).transform((r) => new j(r)),
1941
- i.instanceof(Number).transform((r) => new j(r))
2037
+ ne(G, "Absolute", 255), ne(G, "Default", 1), ne(G, "z", i.union([
2038
+ i.instanceof(G),
2039
+ i.number().int().min(0).max(255).transform((r) => new G(r)),
2040
+ i.instanceof(Number).transform((r) => new G(r))
1942
2041
  ]));
1943
2042
  i.object({
1944
2043
  name: i.string(),
1945
2044
  key: i.string()
1946
2045
  });
1947
- const et = class J extends Error {
2046
+ const it = class X extends Error {
1948
2047
  constructor() {
1949
- super(J.MESSAGE);
2048
+ super(X.MESSAGE);
1950
2049
  }
1951
2050
  /** Returns true if the error or message is a cancellation error" */
1952
2051
  matches(e) {
1953
- return typeof e == "string" ? e.includes(J.MESSAGE) : e instanceof J || e.message.includes(J.MESSAGE);
2052
+ return typeof e == "string" ? e.includes(X.MESSAGE) : e instanceof X || e.message.includes(X.MESSAGE);
1954
2053
  }
1955
2054
  };
1956
- re(et, "MESSAGE", "canceled");
1957
- let br = et;
1958
- new br();
2055
+ ne(it, "MESSAGE", "canceled");
2056
+ let Nr = it;
2057
+ new Nr();
1959
2058
  i.string().regex(/^\d+\.\d+\.\d+$/);
1960
- const we = (r) => (e) => e != null && typeof e == "object" && "type" in e && typeof e.type == "string" ? e.type.includes(r) : e instanceof Error ? e.message.includes(r) : typeof e != "string" ? !1 : e.includes(r);
1961
- class ae extends Error {
1962
- constructor(t) {
1963
- super(t);
2059
+ const Oe = (r) => (e) => e != null && typeof e == "object" && "type" in e && typeof e.type == "string" ? e.type.includes(r) : e instanceof Error ? e.message.includes(r) : typeof e != "string" ? !1 : e.includes(r);
2060
+ class oe extends Error {
2061
+ constructor() {
2062
+ super(...arguments);
1964
2063
  p(this, "discriminator", "FreighterError");
1965
2064
  p(this, "type", "");
1966
2065
  }
1967
2066
  }
1968
- const Tr = (r) => {
2067
+ const Er = (r) => {
1969
2068
  if (r == null || typeof r != "object") return !1;
1970
2069
  const e = r;
1971
2070
  if (e.discriminator !== "FreighterError") return !1;
@@ -1974,8 +2073,8 @@ const Tr = (r) => {
1974
2073
  `Freighter error is missing its type property: ${JSON.stringify(e)}`
1975
2074
  );
1976
2075
  return !0;
1977
- }, Be = "unknown", Ue = "nil", Or = "freighter", tt = i.object({ type: i.string(), data: i.string() });
1978
- class vr {
2076
+ }, Ye = "unknown", ke = "nil", Ar = "freighter", at = i.object({ type: i.string(), data: i.string() });
2077
+ class xr {
1979
2078
  constructor() {
1980
2079
  p(this, "providers", []);
1981
2080
  }
@@ -1983,87 +2082,87 @@ class vr {
1983
2082
  this.providers.push(e);
1984
2083
  }
1985
2084
  encode(e) {
1986
- if (e == null) return { type: Ue, data: "" };
1987
- if (Tr(e))
2085
+ if (e == null) return { type: ke, data: "" };
2086
+ if (Er(e))
1988
2087
  for (const t of this.providers) {
1989
2088
  const n = t.encode(e);
1990
2089
  if (n != null) return n;
1991
2090
  }
1992
- return { type: Be, data: JSON.stringify(e) };
2091
+ return { type: Ye, data: JSON.stringify(e) };
1993
2092
  }
1994
2093
  decode(e) {
1995
- if (e == null || e.type === Ue) return null;
1996
- if (e.type === Be) return new Ce(e.data);
2094
+ if (e == null || e.type === ke) return null;
2095
+ if (e.type === Ye) return new je(e.data);
1997
2096
  for (const t of this.providers) {
1998
2097
  const n = t.decode(e);
1999
2098
  if (n != null) return n;
2000
2099
  }
2001
- return new Ce(e.data);
2100
+ return new je(e.data);
2002
2101
  }
2003
2102
  }
2004
- const be = new vr(), Sr = ({
2103
+ const ve = new xr(), Mr = ({
2005
2104
  encode: r,
2006
2105
  decode: e
2007
- }) => be.register({ encode: r, decode: e }), Fr = (r) => be.encode(r), rt = (r) => be.decode(r);
2008
- class Ce extends ae {
2009
- constructor(t) {
2010
- super(t);
2106
+ }) => ve.register({ encode: r, decode: e }), Zr = (r) => ve.encode(r), ot = (r) => ve.decode(r);
2107
+ class je extends oe {
2108
+ constructor() {
2109
+ super(...arguments);
2011
2110
  p(this, "type", "unknown");
2012
2111
  }
2013
2112
  }
2014
- const oe = "freighter.", F = class F extends ae {
2113
+ const ue = "freighter.", q = class q extends oe {
2015
2114
  constructor() {
2016
2115
  super("EOF");
2017
- p(this, "type", F.TYPE);
2116
+ p(this, "type", q.TYPE);
2018
2117
  }
2019
2118
  };
2020
- p(F, "TYPE", oe + "eof"), p(F, "matches", we(F.TYPE));
2021
- let P = F;
2022
- const G = class G extends ae {
2119
+ p(q, "TYPE", `${ue}eof`), p(q, "matches", Oe(q.TYPE));
2120
+ let L = q;
2121
+ const W = class W extends oe {
2023
2122
  constructor() {
2024
2123
  super("StreamClosed");
2025
- p(this, "type", G.TYPE);
2124
+ p(this, "type", W.TYPE);
2026
2125
  }
2027
2126
  };
2028
- p(G, "TYPE", oe + "stream_closed"), p(G, "matches", we(G.TYPE));
2029
- let L = G;
2030
- const q = class q extends ae {
2127
+ p(W, "TYPE", `${ue}stream_closed`), p(W, "matches", Oe(W.TYPE));
2128
+ let Y = W;
2129
+ const V = class V extends oe {
2031
2130
  constructor(t = {}) {
2032
- const { message: n = "Unreachable", url: s = yr.UNKNOWN } = t;
2131
+ const { message: n = "Unreachable", url: s = vr.UNKNOWN } = t;
2033
2132
  super(n);
2034
- p(this, "type", q.TYPE);
2133
+ p(this, "type", V.TYPE);
2035
2134
  p(this, "url");
2036
2135
  this.url = s;
2037
2136
  }
2038
2137
  };
2039
- p(q, "TYPE", oe + "unreachable"), p(q, "matches", we(q.TYPE));
2040
- let k = q;
2041
- const Ir = (r) => {
2042
- if (!r.type.startsWith(Or)) return null;
2043
- if (P.matches(r)) return { type: P.TYPE, data: "EOF" };
2044
- if (L.matches(r))
2045
- return { type: L.TYPE, data: "StreamClosed" };
2046
- if (k.matches(r))
2047
- return { type: k.TYPE, data: "Unreachable" };
2138
+ p(V, "TYPE", `${ue}unreachable`), p(V, "matches", Oe(V.TYPE));
2139
+ let j = V;
2140
+ const $r = (r) => {
2141
+ if (!r.type.startsWith(Ar)) return null;
2142
+ if (L.matches(r)) return { type: L.TYPE, data: "EOF" };
2143
+ if (Y.matches(r))
2144
+ return { type: Y.TYPE, data: "StreamClosed" };
2145
+ if (j.matches(r))
2146
+ return { type: j.TYPE, data: "Unreachable" };
2048
2147
  throw new Error(`Unknown error type: ${r.type}: ${r.message}`);
2049
- }, Nr = (r) => {
2050
- if (!r.type.startsWith(oe)) return null;
2148
+ }, Br = (r) => {
2149
+ if (!r.type.startsWith(ue)) return null;
2051
2150
  switch (r.type) {
2052
- case P.TYPE:
2053
- return new P();
2054
2151
  case L.TYPE:
2055
2152
  return new L();
2056
- case k.TYPE:
2057
- return new k();
2153
+ case Y.TYPE:
2154
+ return new Y();
2155
+ case j.TYPE:
2156
+ return new j();
2058
2157
  default:
2059
2158
  throw new Error(`Unknown error type: ${r.data}`);
2060
2159
  }
2061
2160
  };
2062
- Sr({
2063
- encode: Ir,
2064
- decode: Nr
2161
+ Mr({
2162
+ encode: $r,
2163
+ decode: Br
2065
2164
  });
2066
- class nt {
2165
+ class ut {
2067
2166
  constructor() {
2068
2167
  p(this, "middleware", []);
2069
2168
  }
@@ -2090,65 +2189,65 @@ class nt {
2090
2189
  return await s(e);
2091
2190
  }
2092
2191
  }
2093
- const st = "Content-Type", De = (r) => {
2094
- if (Qe.RUNTIME !== "node") return fetch;
2192
+ const ct = "Content-Type", Fe = (r) => {
2193
+ if (nt.RUNTIME !== "node") return fetch;
2095
2194
  const e = require("node-fetch");
2096
2195
  if (r === "http") return e;
2097
2196
  const t = require("https"), n = new t.Agent({ rejectUnauthorized: !1 });
2098
2197
  return async (s, a) => await e(s, { ...a, agent: n });
2099
2198
  };
2100
- class Gr extends nt {
2199
+ class Jr extends ut {
2101
2200
  constructor(t, n, s = !1) {
2102
2201
  super();
2103
2202
  p(this, "endpoint");
2104
2203
  p(this, "encoder");
2105
2204
  p(this, "fetch");
2106
- return this.endpoint = t.replace({ protocol: s ? "https" : "http" }), this.encoder = n, this.fetch = De(this.endpoint.protocol), new Proxy(this, {
2107
- get: (a, c, d) => c === "endpoint" ? this.endpoint : Reflect.get(a, c, d)
2205
+ return this.endpoint = t.replace({ protocol: s ? "https" : "http" }), this.encoder = n, this.fetch = Fe(this.endpoint.protocol), new Proxy(this, {
2206
+ get: (a, c, f) => c === "endpoint" ? this.endpoint : Reflect.get(a, c, f)
2108
2207
  });
2109
2208
  }
2110
2209
  get headers() {
2111
2210
  return {
2112
- [st]: this.encoder.contentType
2211
+ [ct]: this.encoder.contentType
2113
2212
  };
2114
2213
  }
2115
2214
  async send(t, n, s, a) {
2116
2215
  n = s == null ? void 0 : s.parse(n);
2117
2216
  let c = null;
2118
- const d = this.endpoint.child(t), f = {};
2119
- f.method = "POST", f.body = this.encoder.encode(n ?? {});
2217
+ const f = this.endpoint.child(t), d = {};
2218
+ d.method = "POST", d.body = this.encoder.encode(n ?? {});
2120
2219
  const [, y] = await this.executeMiddleware(
2121
2220
  {
2122
- target: d.toString(),
2221
+ target: f.toString(),
2123
2222
  protocol: this.endpoint.protocol,
2124
2223
  params: {},
2125
2224
  role: "client"
2126
2225
  },
2127
2226
  async (T) => {
2128
2227
  const l = { ...T, params: {} };
2129
- f.headers = {
2228
+ d.headers = {
2130
2229
  ...this.headers,
2131
2230
  ...T.params
2132
2231
  };
2133
2232
  let E;
2134
2233
  try {
2135
- E = await De(T.protocol)(T.target, f);
2136
- } catch (B) {
2137
- let x = B;
2138
- return x.message === "Load failed" && (x = new k({ url: d })), [l, x];
2234
+ E = await Fe(T.protocol)(T.target, d);
2235
+ } catch (U) {
2236
+ let x = U;
2237
+ return x.message === "Load failed" && (x = new j({ url: f })), [l, x];
2139
2238
  }
2140
2239
  const R = await E.arrayBuffer();
2141
2240
  if (E != null && E.ok)
2142
2241
  return a != null && (c = this.encoder.decode(R, a)), [l, null];
2143
2242
  try {
2144
2243
  if (E.status !== 400) return [l, new Error(E.statusText)];
2145
- const B = this.encoder.decode(R, tt), x = rt(B);
2244
+ const U = this.encoder.decode(R, at), x = ot(U);
2146
2245
  return [l, x];
2147
- } catch (B) {
2246
+ } catch (U) {
2148
2247
  return [
2149
2248
  l,
2150
2249
  new Error(
2151
- `[freighter] - failed to decode error: ${E.statusText}: ${B.message}`
2250
+ `[freighter] - failed to decode error: ${E.statusText}: ${U.message}`
2152
2251
  )
2153
2252
  ];
2154
2253
  }
@@ -2157,16 +2256,16 @@ class Gr extends nt {
2157
2256
  return [c, y];
2158
2257
  }
2159
2258
  }
2160
- const qr = async (r, e, t, n, s) => {
2259
+ const Hr = async (r, e, t, n, s) => {
2161
2260
  const [a, c] = await r.send(e, t, n, s);
2162
2261
  if (c != null) throw c;
2163
2262
  return a;
2164
- }, Er = () => Qe.RUNTIME !== "node" ? (r) => new WebSocket(r) : (r) => new (require("ws")).WebSocket(r, { rejectUnauthorized: !1 }), Ar = i.object({
2263
+ }, Rr = () => nt.RUNTIME !== "node" ? (r) => new WebSocket(r) : (r) => new (require("ws")).WebSocket(r, { rejectUnauthorized: !1 }), Ur = i.object({
2165
2264
  type: i.union([i.literal("data"), i.literal("close")]),
2166
2265
  payload: i.unknown().optional(),
2167
- error: i.optional(tt)
2266
+ error: i.optional(at)
2168
2267
  });
2169
- class xr {
2268
+ class Cr {
2170
2269
  constructor(e, t, n, s) {
2171
2270
  p(this, "encoder");
2172
2271
  p(this, "reqSchema");
@@ -2180,8 +2279,8 @@ class xr {
2180
2279
  }
2181
2280
  /** Implements the Stream protocol */
2182
2281
  send(e) {
2183
- if (this.serverClosed != null) return new P();
2184
- if (this.sendClosed) throw new L();
2282
+ if (this.serverClosed != null) return new L();
2283
+ if (this.sendClosed) throw new Y();
2185
2284
  return this.ws.send(this.encoder.encode({ type: "data", payload: e })), null;
2186
2285
  }
2187
2286
  /** Implements the Stream protocol */
@@ -2190,7 +2289,7 @@ class xr {
2190
2289
  const e = await this.receiveMsg();
2191
2290
  if (e.type === "close") {
2192
2291
  if (e.error == null) throw new Error("Message error must be defined");
2193
- return this.serverClosed = rt(e.error), [null, this.serverClosed];
2292
+ return this.serverClosed = ot(e.error), [null, this.serverClosed];
2194
2293
  }
2195
2294
  return [this.resSchema.parse(e.payload), null];
2196
2295
  }
@@ -2219,13 +2318,13 @@ class xr {
2219
2318
  t != null ? t.resolve(e) : this.receiveDataQueue.push(e);
2220
2319
  }
2221
2320
  listenForMessages() {
2222
- this.ws.onmessage = (e) => this.addMessage(this.encoder.decode(e.data, Ar)), this.ws.onclose = (e) => this.addMessage({
2321
+ this.ws.onmessage = (e) => this.addMessage(this.encoder.decode(e.data, Ur)), this.ws.onclose = (e) => this.addMessage({
2223
2322
  type: "close",
2224
- error: { type: Ur(e) ? P.TYPE : L.TYPE, data: "" }
2323
+ error: { type: kr(e) ? L.TYPE : Y.TYPE, data: "" }
2225
2324
  });
2226
2325
  }
2227
2326
  }
2228
- const Mr = "freighterctx", $r = 1e3, Rr = 1001, Br = [$r, Rr], Ur = (r) => Br.includes(r.code), se = class se extends nt {
2327
+ const Dr = "freighterctx", Pr = 1e3, Lr = 1001, Yr = [Pr, Lr], kr = (r) => Yr.includes(r.code), ie = class ie extends ut {
2229
2328
  /**
2230
2329
  * @param encoder - The encoder to use for encoding messages and decoding
2231
2330
  * responses.
@@ -2239,54 +2338,54 @@ const Mr = "freighterctx", $r = 1e3, Rr = 1001, Br = [$r, Rr], Ur = (r) => Br.in
2239
2338
  }
2240
2339
  /** Implements the StreamClient interface. */
2241
2340
  async stream(t, n, s) {
2242
- const a = Er();
2341
+ const a = Rr();
2243
2342
  let c;
2244
- const [, d] = await this.executeMiddleware(
2343
+ const [, f] = await this.executeMiddleware(
2245
2344
  { target: t, protocol: "websocket", params: {}, role: "client" },
2246
- async (f) => {
2247
- const y = a(this.buildURL(t, f)), T = { ...f, params: {} };
2248
- y.binaryType = se.MESSAGE_TYPE;
2345
+ async (d) => {
2346
+ const y = a(this.buildURL(t, d)), T = { ...d, params: {} };
2347
+ y.binaryType = ie.MESSAGE_TYPE;
2249
2348
  const l = await this.wrapSocket(y, n, s);
2250
2349
  return l instanceof Error ? [T, l] : (c = l, [T, null]);
2251
2350
  }
2252
2351
  );
2253
- if (d != null) throw d;
2352
+ if (f != null) throw f;
2254
2353
  return c;
2255
2354
  }
2256
2355
  buildURL(t, n) {
2257
- const s = pr(
2356
+ const s = Or(
2258
2357
  {
2259
- [st]: this.encoder.contentType,
2358
+ [ct]: this.encoder.contentType,
2260
2359
  ...n.params
2261
2360
  },
2262
- Mr
2361
+ Dr
2263
2362
  );
2264
2363
  return this.baseUrl.child(t).toString() + s;
2265
2364
  }
2266
2365
  async wrapSocket(t, n, s) {
2267
2366
  return await new Promise((a) => {
2268
2367
  t.onopen = () => {
2269
- a(new xr(t, this.encoder, n, s));
2368
+ a(new Cr(t, this.encoder, n, s));
2270
2369
  }, t.onerror = (c) => {
2271
- const d = c;
2272
- a(new Error(d.message));
2370
+ const f = c;
2371
+ a(new Error(f.message));
2273
2372
  };
2274
2373
  });
2275
2374
  }
2276
2375
  };
2277
- p(se, "MESSAGE_TYPE", "arraybuffer");
2278
- let Pe = se;
2376
+ p(ie, "MESSAGE_TYPE", "arraybuffer");
2377
+ let Ge = ie;
2279
2378
  export {
2280
- ae as BaseTypedError,
2281
- P as EOF,
2282
- Gr as HTTPClient,
2283
- L as StreamClosed,
2284
- k as Unreachable,
2285
- Pe as WebSocketClient,
2286
- rt as decodeError,
2287
- Fr as encodeError,
2288
- we as errorMatcher,
2289
- tt as errorZ,
2290
- Sr as registerError,
2291
- qr as sendRequired
2379
+ oe as BaseTypedError,
2380
+ L as EOF,
2381
+ Jr as HTTPClient,
2382
+ Y as StreamClosed,
2383
+ j as Unreachable,
2384
+ Ge as WebSocketClient,
2385
+ ot as decodeError,
2386
+ Zr as encodeError,
2387
+ Oe as errorMatcher,
2388
+ at as errorZ,
2389
+ Mr as registerError,
2390
+ Hr as sendRequired
2292
2391
  };