@synnaxlabs/freighter 0.23.0 → 0.25.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,526 +1,264 @@
1
- var $t = Object.defineProperty;
2
- var Ut = (t, e, r) => e in t ? $t(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
- var v = (t, e, r) => (Ut(t, typeof e != "symbol" ? e + "" : e, r), r);
4
- import { z as i } from "zod";
5
- var C = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, d = {}, oe = {};
6
- Object.defineProperty(oe, "__esModule", { value: !0 });
7
- function xt(t) {
8
- return t === void 0 && (t = ""), t ? String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, "").replace(/[^A-Za-z0-9]+/g, "$").replace(/([a-z])([A-Z])/g, function(e, r, n) {
9
- return r + "$" + n;
10
- }).toLowerCase().replace(/(\$)(\w)/g, function(e, r, n) {
11
- return n.toUpperCase();
12
- }) : "";
13
- }
14
- oe.default = xt;
15
- var ue = {};
16
- Object.defineProperty(ue, "__esModule", { value: !0 });
17
- function Mt(t) {
18
- return t === void 0 && (t = ""), t ? String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, "").replace(/([a-z])([A-Z])/g, function(e, r, n) {
19
- return r + "_" + n.toLowerCase();
20
- }).replace(/[^A-Za-z0-9]+|_+/g, "_").toLowerCase() : "";
21
- }
22
- ue.default = Mt;
23
- var le = {};
24
- Object.defineProperty(le, "__esModule", { value: !0 });
25
- function jt(t) {
26
- return t === void 0 && (t = ""), t ? String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, "$").replace(/[^A-Za-z0-9]+/g, "$").replace(/([a-z])([A-Z])/g, function(e, r, n) {
27
- return r + "$" + n;
28
- }).toLowerCase().replace(/(\$)(\w?)/g, function(e, r, n) {
29
- return n.toUpperCase();
30
- }) : "";
31
- }
32
- le.default = jt;
33
- var Ie = {};
34
- Object.defineProperty(Ie, "__esModule", { value: !0 });
35
- function Rt(t) {
36
- return t === void 0 && (t = ""), t ? String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, "").replace(/([a-z])([A-Z])/g, function(e, r, n) {
37
- return r + "_" + n.toLowerCase();
38
- }).replace(/[^A-Za-z0-9]+|_+/g, ".").toLowerCase() : "";
39
- }
40
- Ie.default = Rt;
41
- var Ne = {};
42
- Object.defineProperty(Ne, "__esModule", { value: !0 });
43
- function Dt(t) {
44
- return t === void 0 && (t = ""), t ? String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, "").replace(/([a-z])([A-Z])/g, function(e, r, n) {
45
- return r + "_" + n.toLowerCase();
46
- }).replace(/[^A-Za-z0-9]+|_+/g, "/").toLowerCase() : "";
47
- }
48
- Ne.default = Dt;
49
- var Ee = {};
50
- Object.defineProperty(Ee, "__esModule", { value: !0 });
51
- function Bt(t) {
52
- return t === void 0 && (t = ""), t ? String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, "").replace(/([a-z])([A-Z])/g, function(e, r, n) {
53
- return r + "_" + n.toLowerCase();
54
- }).replace(/[^A-Za-z0-9]+|_+/g, " ").toLowerCase() : "";
55
- }
56
- Ee.default = Bt;
57
- var Ce = {};
58
- Object.defineProperty(Ce, "__esModule", { value: !0 });
59
- function kt(t) {
60
- if (t === void 0 && (t = ""), !t)
61
- return "";
62
- var e = String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, "").replace(/([a-z])([A-Z])/g, function(r, n, s) {
63
- return n + "_" + s.toLowerCase();
64
- }).replace(/[^A-Za-z0-9]+|_+/g, " ").toLowerCase();
65
- return e.charAt(0).toUpperCase() + e.slice(1);
66
- }
67
- Ce.default = kt;
68
- var $e = {};
69
- Object.defineProperty($e, "__esModule", { value: !0 });
70
- function Lt(t) {
71
- return t === void 0 && (t = ""), t ? String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, "").replace(/([a-z])([A-Z])/g, function(e, r, n) {
72
- return r + "_" + n.toLowerCase();
73
- }).replace(/[^A-Za-z0-9]+|_+/g, " ").toLowerCase().replace(/( ?)(\w+)( ?)/g, function(e, r, n, s) {
74
- return r + n.charAt(0).toUpperCase() + n.slice(1) + s;
75
- }) : "";
76
- }
77
- $e.default = Lt;
78
- var ce = {};
79
- Object.defineProperty(ce, "__esModule", { value: !0 });
80
- function Pt(t) {
81
- return t === void 0 && (t = ""), t ? String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g, "").replace(/([a-z])([A-Z])/g, function(e, r, n) {
82
- return r + "_" + n.toLowerCase();
83
- }).replace(/[^A-Za-z0-9]+|_+/g, "-").toLowerCase() : "";
84
- }
85
- ce.default = Pt;
86
- var Ue = {}, K = {};
87
- (function(t) {
88
- Object.defineProperty(t, "__esModule", { value: !0 }), t.belongToTypes = t.isValidObject = t.isArrayObject = t.validateOptions = t.DefaultOption = void 0, t.DefaultOption = {
89
- recursive: !1,
90
- recursiveInArray: !1,
91
- keepTypesOnRecursion: []
92
- }, t.validateOptions = function(e) {
93
- return e === void 0 && (e = t.DefaultOption), e.recursive == null ? e = t.DefaultOption : e.recursiveInArray == null && (e.recursiveInArray = !1), e;
94
- }, t.isArrayObject = function(e) {
95
- return e != null && Array.isArray(e);
96
- }, t.isValidObject = function(e) {
97
- return e != null && typeof e == "object" && !Array.isArray(e);
98
- }, t.belongToTypes = function(e, r) {
99
- return (r || []).some(function(n) {
100
- return e instanceof n;
101
- });
1
+ var Ze = Object.defineProperty;
2
+ var ze = (r, e, t) => e in r ? Ze(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var f = (r, e, t) => ze(r, typeof e != "symbol" ? e + "" : e, t);
4
+ import { z as s } from "zod";
5
+ const Ve = (r) => {
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
+ }, Ee = (r) => {
9
+ const e = (t, n = oe) => {
10
+ if (typeof t == "string") return r(t);
11
+ if (Array.isArray(t)) return t.map((a) => e(a, n));
12
+ if (!te(t)) return null;
13
+ n = Je(n);
14
+ const i = {};
15
+ return Object.keys(t).forEach((a) => {
16
+ let c = t[a];
17
+ const h = r(a);
18
+ n.recursive && (te(c) ? pe(c, n.keepTypesOnRecursion) || (c = e(c, n)) : n.recursiveInArray && fe(c) && (c = [...c].map((p) => {
19
+ let m = p;
20
+ return te(p) ? pe(m, n.keepTypesOnRecursion) || (m = e(p, n)) : fe(p) && (m = e({ key: p }, n).key), m;
21
+ }))), i[h] = c;
22
+ }), i;
102
23
  };
103
- })(K);
104
- var Zt = C && C.__spreadArrays || function() {
105
- for (var t = 0, e = 0, r = arguments.length; e < r; e++)
106
- t += arguments[e].length;
107
- for (var n = Array(t), s = 0, e = 0; e < r; e++)
108
- for (var a = arguments[e], u = 0, c = a.length; u < c; u++, s++)
109
- n[s] = a[u];
110
- return n;
111
- };
112
- Object.defineProperty(Ue, "__esModule", { value: !0 });
113
- var j = K;
114
- function J(t, e) {
115
- if (e === void 0 && (e = j.DefaultOption), !j.isValidObject(t))
116
- return null;
117
- e = j.validateOptions(e);
118
- var r = {};
119
- return Object.keys(t).forEach(function(n) {
120
- var s = t[n], a = n.toLowerCase();
121
- e.recursive && (j.isValidObject(s) ? j.belongToTypes(s, e.keepTypesOnRecursion) || (s = J(s, e)) : e.recursiveInArray && j.isArrayObject(s) && (s = Zt(s).map(function(u) {
122
- var c = u;
123
- if (j.isValidObject(u))
124
- j.belongToTypes(c, e.keepTypesOnRecursion) || (c = J(u, e));
125
- else if (j.isArrayObject(u)) {
126
- var h = J({ key: u }, e);
127
- c = h.key;
128
- }
129
- return c;
130
- }))), r[a] = s;
131
- }), r;
132
- }
133
- Ue.default = J;
134
- var xe = {}, zt = C && C.__spreadArrays || function() {
135
- for (var t = 0, e = 0, r = arguments.length; e < r; e++)
136
- t += arguments[e].length;
137
- for (var n = Array(t), s = 0, e = 0; e < r; e++)
138
- for (var a = arguments[e], u = 0, c = a.length; u < c; u++, s++)
139
- n[s] = a[u];
140
- return n;
141
- };
142
- Object.defineProperty(xe, "__esModule", { value: !0 });
143
- var R = K;
144
- function Q(t, e) {
145
- if (e === void 0 && (e = R.DefaultOption), !R.isValidObject(t))
146
- return null;
147
- e = R.validateOptions(e);
148
- var r = {};
149
- return Object.keys(t).forEach(function(n) {
150
- var s = t[n], a = n.toUpperCase();
151
- e.recursive && (R.isValidObject(s) ? R.belongToTypes(s, e.keepTypesOnRecursion) || (s = Q(s, e)) : e.recursiveInArray && R.isArrayObject(s) && (s = zt(s).map(function(u) {
152
- var c = u;
153
- if (R.isValidObject(u))
154
- R.belongToTypes(c, e.keepTypesOnRecursion) || (c = Q(u, e));
155
- else if (R.isArrayObject(u)) {
156
- var h = Q({ key: u }, e);
157
- c = h.key;
158
- }
159
- return c;
160
- }))), r[a] = s;
161
- }), r;
162
- }
163
- xe.default = Q;
164
- var Me = {}, Yt = C && C.__spreadArrays || function() {
165
- for (var t = 0, e = 0, r = arguments.length; e < r; e++)
166
- t += arguments[e].length;
167
- for (var n = Array(t), s = 0, e = 0; e < r; e++)
168
- for (var a = arguments[e], u = 0, c = a.length; u < c; u++, s++)
169
- n[s] = a[u];
170
- return n;
171
- };
172
- Object.defineProperty(Me, "__esModule", { value: !0 });
173
- var D = K, Kt = oe;
174
- function _(t, e) {
175
- if (e === void 0 && (e = D.DefaultOption), !D.isValidObject(t))
176
- return null;
177
- e = D.validateOptions(e);
178
- var r = {};
179
- return Object.keys(t).forEach(function(n) {
180
- var s = t[n], a = Kt.default(n);
181
- e.recursive && (D.isValidObject(s) ? D.belongToTypes(s, e.keepTypesOnRecursion) || (s = _(s, e)) : e.recursiveInArray && D.isArrayObject(s) && (s = Yt(s).map(function(u) {
182
- var c = u;
183
- if (D.isValidObject(u))
184
- D.belongToTypes(c, e.keepTypesOnRecursion) || (c = _(u, e));
185
- else if (D.isArrayObject(u)) {
186
- var h = _({ key: u }, e);
187
- c = h.key;
188
- }
189
- return c;
190
- }))), r[a] = s;
191
- }), r;
192
- }
193
- Me.default = _;
194
- var je = {}, Vt = C && C.__spreadArrays || function() {
195
- for (var t = 0, e = 0, r = arguments.length; e < r; e++)
196
- t += arguments[e].length;
197
- for (var n = Array(t), s = 0, e = 0; e < r; e++)
198
- for (var a = arguments[e], u = 0, c = a.length; u < c; u++, s++)
199
- n[s] = a[u];
200
- return n;
201
- };
202
- Object.defineProperty(je, "__esModule", { value: !0 });
203
- var B = K, Ft = ue;
204
- function ee(t, e) {
205
- if (e === void 0 && (e = B.DefaultOption), !B.isValidObject(t))
206
- return null;
207
- e = B.validateOptions(e);
208
- var r = {};
209
- return Object.keys(t).forEach(function(n) {
210
- var s = t[n], a = Ft.default(n);
211
- e.recursive && (B.isValidObject(s) ? B.belongToTypes(s, e.keepTypesOnRecursion) || (s = ee(s, e)) : e.recursiveInArray && B.isArrayObject(s) && (s = Vt(s).map(function(u) {
212
- var c = u;
213
- if (B.isValidObject(u))
214
- B.belongToTypes(c, e.keepTypesOnRecursion) || (c = ee(u, e));
215
- else if (B.isArrayObject(u)) {
216
- var h = ee({ key: u }, e);
217
- c = h.key;
218
- }
219
- return c;
220
- }))), r[a] = s;
221
- }), r;
222
- }
223
- je.default = ee;
224
- var Re = {}, Wt = C && C.__spreadArrays || function() {
225
- for (var t = 0, e = 0, r = arguments.length; e < r; e++)
226
- t += arguments[e].length;
227
- for (var n = Array(t), s = 0, e = 0; e < r; e++)
228
- for (var a = arguments[e], u = 0, c = a.length; u < c; u++, s++)
229
- n[s] = a[u];
230
- return n;
231
- };
232
- Object.defineProperty(Re, "__esModule", { value: !0 });
233
- var k = K, qt = le;
234
- function te(t, e) {
235
- if (e === void 0 && (e = k.DefaultOption), !k.isValidObject(t))
236
- return null;
237
- e = k.validateOptions(e);
238
- var r = {};
239
- return Object.keys(t).forEach(function(n) {
240
- var s = t[n], a = qt.default(n);
241
- e.recursive && (k.isValidObject(s) ? k.belongToTypes(s, e.keepTypesOnRecursion) || (s = te(s, e)) : e.recursiveInArray && k.isArrayObject(s) && (s = Wt(s).map(function(u) {
242
- var c = u;
243
- if (k.isValidObject(u))
244
- k.belongToTypes(c, e.keepTypesOnRecursion) || (c = te(u, e));
245
- else if (k.isArrayObject(u)) {
246
- var h = te({ key: u }, e);
247
- c = h.key;
248
- }
249
- return c;
250
- }))), r[a] = s;
251
- }), r;
252
- }
253
- Re.default = te;
254
- var De = {}, Gt = C && C.__spreadArrays || function() {
255
- for (var t = 0, e = 0, r = arguments.length; e < r; e++)
256
- t += arguments[e].length;
257
- for (var n = Array(t), s = 0, e = 0; e < r; e++)
258
- for (var a = arguments[e], u = 0, c = a.length; u < c; u++, s++)
259
- n[s] = a[u];
260
- return n;
261
- };
262
- Object.defineProperty(De, "__esModule", { value: !0 });
263
- var L = K, Ht = ce;
264
- function re(t, e) {
265
- if (e === void 0 && (e = L.DefaultOption), !L.isValidObject(t))
266
- return null;
267
- e = L.validateOptions(e);
268
- var r = {};
269
- return Object.keys(t).forEach(function(n) {
270
- var s = t[n], a = Ht.default(n);
271
- e.recursive && (L.isValidObject(s) ? L.belongToTypes(s, e.keepTypesOnRecursion) || (s = re(s, e)) : e.recursiveInArray && L.isArrayObject(s) && (s = Gt(s).map(function(u) {
272
- var c = u;
273
- if (L.isValidObject(u))
274
- L.belongToTypes(c, e.keepTypesOnRecursion) || (c = re(u, e));
275
- else if (L.isArrayObject(u)) {
276
- var h = re({ key: u }, e);
277
- c = h.key;
278
- }
279
- return c;
280
- }))), r[a] = s;
281
- }), r;
282
- }
283
- De.default = re;
284
- Object.defineProperty(d, "__esModule", { value: !0 });
285
- d.kebabKeys = d.pascalKeys = d.snakeKeys = d.camelKeys = d.upperKeys = d.lowerKeys = d.toLowerCase = d.toUpperCase = d.toKebabCase = d.toHeaderCase = d.toSentenceCase = d.toTextCase = d.toPathCase = d.toDotCase = d.toPascalCase = d.toSnakeCase = d.toCamelCase = void 0;
286
- var Ge = oe;
287
- d.toCamelCase = Ge.default;
288
- var He = ue;
289
- d.toSnakeCase = He.default;
290
- var Xe = le;
291
- d.toPascalCase = Xe.default;
292
- var Je = Ie;
293
- d.toDotCase = Je.default;
294
- var Qe = Ne;
295
- d.toPathCase = Qe.default;
296
- var _e = Ee;
297
- d.toTextCase = _e.default;
298
- var et = Ce;
299
- d.toSentenceCase = et.default;
300
- var tt = $e;
301
- d.toHeaderCase = tt.default;
302
- var rt = ce;
303
- d.toKebabCase = rt.default;
304
- var nt = Ue;
305
- d.lowerKeys = nt.default;
306
- var st = xe;
307
- d.upperKeys = st.default;
308
- var it = Me;
309
- d.camelKeys = it.default;
310
- var at = je;
311
- d.snakeKeys = at.default;
312
- var ot = Re;
313
- d.pascalKeys = ot.default;
314
- var ut = De;
315
- d.kebabKeys = ut.default;
316
- var lt = function(t) {
317
- return String(t || "").toLowerCase();
318
- };
319
- d.toLowerCase = lt;
320
- var ct = function(t) {
321
- return String(t || "").toUpperCase();
322
- };
323
- d.toUpperCase = ct;
324
- var Xt = {
325
- toCamelCase: Ge.default,
326
- toSnakeCase: He.default,
327
- toPascalCase: Xe.default,
328
- toDotCase: Je.default,
329
- toPathCase: Qe.default,
330
- toTextCase: _e.default,
331
- toSentenceCase: et.default,
332
- toHeaderCase: tt.default,
333
- toKebabCase: rt.default,
334
- toUpperCase: ct,
335
- toLowerCase: lt,
336
- lowerKeys: nt.default,
337
- upperKeys: st.default,
338
- camelKeys: it.default,
339
- snakeKeys: at.default,
340
- pascalKeys: ot.default,
341
- kebabKeys: ut.default
342
- };
343
- d.default = Xt;
344
- var ft = d;
345
- const dt = {
24
+ return e;
25
+ }, He = Ee(Ve), Ke = (r) => r.replace(/([a-z0-9])([A-Z])/g, (e, t, n) => `${t}_${n.toLowerCase()}`), Xe = Ee(Ke), oe = {
346
26
  recursive: !0,
347
27
  recursiveInArray: !0,
348
28
  keepTypesOnRecursion: [Number, String, Uint8Array]
349
- }, Jt = (t) => ft.snakeKeys(t, dt), Qt = (t) => ft.camelKeys(t, dt), _t = (t) => t != null && typeof t == "object" && !Array.isArray(t);
350
- var er = Object.defineProperty, tr = (t, e, r) => e in t ? er(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, ye = (t, e, r) => (tr(t, typeof e != "symbol" ? e + "" : e, r), r);
351
- let rr = class {
29
+ }, Je = (r = oe) => (r.recursive == null ? r = oe : r.recursiveInArray == null && (r.recursiveInArray = !1), r), fe = (r) => r != null && Array.isArray(r), te = (r) => r != null && typeof r == "object" && !Array.isArray(r), pe = (r, e) => (e || []).some((t) => r instanceof t), Ae = (r) => r != null && typeof r == "object" && !Array.isArray(r);
30
+ var Qe = Object.defineProperty, _e = (r, e, t) => e in r ? Qe(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, q = (r, e, t) => _e(r, typeof e != "symbol" ? e + "" : e, t);
31
+ let et = class {
352
32
  constructor() {
353
- ye(this, "contentType", "application/json"), ye(this, "decoder"), ye(this, "encoder"), this.decoder = new TextDecoder(), this.encoder = new TextEncoder();
33
+ q(this, "contentType", "application/json"), q(this, "decoder"), q(this, "encoder"), this.decoder = new TextDecoder(), this.encoder = new TextEncoder();
354
34
  }
355
35
  encode(e) {
356
36
  return this.encoder.encode(this.encodeString(e)).buffer;
357
37
  }
358
- decode(e, r) {
359
- return this.decodeString(this.decoder.decode(e), r);
38
+ decode(e, t) {
39
+ return this.decodeString(this.decoder.decode(e), t);
360
40
  }
361
- decodeString(e, r) {
362
- const n = Qt(JSON.parse(e));
363
- return r != null ? r.parse(n) : n;
41
+ decodeString(e, t) {
42
+ const n = JSON.parse(e), i = He(n);
43
+ return t != null ? t.parse(i) : i;
364
44
  }
365
45
  encodeString(e) {
366
- return JSON.stringify(Jt(e), (r, n) => ArrayBuffer.isView(n) ? Array.from(n) : _t(n) && "encode_value" in n ? typeof n.value == "bigint" ? n.value.toString() : n.value : typeof n == "bigint" ? n.toString() : n);
46
+ const t = Xe(e);
47
+ return JSON.stringify(t, (n, i) => ArrayBuffer.isView(i) ? Array.from(i) : Ae(i) && "encode_value" in i ? typeof i.value == "bigint" ? i.value.toString() : i.value : typeof i == "bigint" ? i.toString() : i);
367
48
  }
368
49
  static registerCustomType() {
369
50
  }
51
+ }, tt = class {
52
+ constructor() {
53
+ q(this, "contentType", "text/csv");
54
+ }
55
+ encode(e) {
56
+ const t = this.encodeString(e);
57
+ return new TextEncoder().encode(t).buffer;
58
+ }
59
+ decode(e, t) {
60
+ const n = new TextDecoder().decode(e);
61
+ return this.decodeString(n, t);
62
+ }
63
+ encodeString(e) {
64
+ if (!Array.isArray(e) || e.length === 0 || !Ae(e[0]))
65
+ throw new Error("Payload must be an array of objects");
66
+ const t = Object.keys(e[0]), n = [t.join(",")];
67
+ return e.forEach((i) => {
68
+ const a = t.map((c) => JSON.stringify(i[c] ?? ""));
69
+ n.push(a.join(","));
70
+ }), n.join(`
71
+ `);
72
+ }
73
+ decodeString(e, t) {
74
+ const [n, ...i] = e.trim().split(`
75
+ `).map((h) => h.trim());
76
+ if (n.length === 0)
77
+ return t != null ? t.parse({}) : {};
78
+ const a = n.split(",").map((h) => h.trim()), c = {};
79
+ return a.forEach((h) => {
80
+ c[h] = [];
81
+ }), i.forEach((h) => {
82
+ const p = h.split(",").map((m) => m.trim());
83
+ a.forEach((m, v) => {
84
+ const w = this.parseValue(p[v]);
85
+ w != null && c[m].push(w);
86
+ });
87
+ }), t != null ? t.parse(c) : c;
88
+ }
89
+ parseValue(e) {
90
+ if (e == null || e.length === 0) return null;
91
+ const t = Number(e);
92
+ return isNaN(t) ? e.startsWith('"') && e.endsWith('"') ? e.slice(1, -1) : e : t;
93
+ }
94
+ static registerCustomType() {
95
+ }
96
+ }, rt = class {
97
+ constructor() {
98
+ q(this, "contentType", "text/plain");
99
+ }
100
+ encode(e) {
101
+ return new TextEncoder().encode(e).buffer;
102
+ }
103
+ decode(e, t) {
104
+ const n = new TextDecoder().decode(e);
105
+ return t != null ? t.parse(n) : n;
106
+ }
370
107
  };
371
- new rr();
372
- const fe = i.tuple([i.number(), i.number()]);
373
- i.tuple([i.bigint(), i.bigint()]);
374
- const ht = i.object({ width: i.number(), height: i.number() }), nr = i.object({
375
- signedWidth: i.number(),
376
- signedHeight: i.number()
377
- }), sr = ["width", "height"];
378
- i.enum(sr);
379
- const ir = ["start", "center", "end"], ar = ["signedWidth", "signedHeight"];
380
- i.enum(ar);
381
- const ie = i.object({ x: i.number(), y: i.number() }), or = i.object({ clientX: i.number(), clientY: i.number() }), ur = ["x", "y"], pt = i.enum(ur), yt = ["top", "right", "bottom", "left"];
382
- i.enum(yt);
383
- const lr = ["left", "right"], gt = i.enum(lr), cr = ["top", "bottom"], vt = i.enum(cr), Ot = ["center"], Le = i.enum(Ot), fr = [...yt, ...Ot], wt = i.enum(fr);
384
- i.enum(ir);
385
- const dr = ["first", "last"];
386
- i.enum(dr);
387
- const hr = i.object({ lower: i.number(), upper: i.number() }), pr = i.object({ lower: i.bigint(), upper: i.bigint() });
388
- i.union([hr, fe]);
389
- i.union([pr, fe]);
390
- i.union([pt, wt]);
391
- i.union([pt, wt, i.instanceof(String)]);
392
- const ge = (t, e) => {
393
- const r = {};
394
- if (typeof t == "number" || typeof t == "bigint")
395
- e != null ? (r.lower = t, r.upper = e) : (r.lower = typeof t == "bigint" ? 0n : 0, r.upper = t);
396
- else if (Array.isArray(t)) {
397
- if (t.length !== 2)
398
- throw new Error("bounds: expected array of length 2");
399
- [r.lower, r.upper] = t;
400
- } else
401
- return Pe(t);
402
- return Pe(r);
403
- }, Pe = (t) => t.lower > t.upper ? { lower: t.upper, upper: t.lower } : t;
404
- i.object({
405
- x: gt.or(Le),
406
- y: vt.or(Le)
108
+ new et();
109
+ new tt();
110
+ new rt();
111
+ const Q = s.tuple([s.number(), s.number()]);
112
+ s.tuple([s.bigint(), s.bigint()]);
113
+ const xe = s.object({ width: s.number(), height: s.number() }), nt = s.object({
114
+ signedWidth: s.number(),
115
+ signedHeight: s.number()
116
+ }), st = ["width", "height"];
117
+ s.enum(st);
118
+ const it = ["start", "center", "end"], ot = ["signedWidth", "signedHeight"];
119
+ s.enum(ot);
120
+ const X = s.object({ x: s.number(), y: s.number() }), at = s.object({ clientX: s.number(), clientY: s.number() }), ut = ["x", "y"], $e = s.enum(ut), Ue = ["top", "right", "bottom", "left"];
121
+ s.enum(Ue);
122
+ const ct = ["left", "right"], Me = s.enum(ct), lt = ["top", "bottom"], Ce = s.enum(lt), Be = ["center"], ye = s.enum(Be), ht = [...Ue, ...Be], Re = s.enum(ht);
123
+ s.enum(it);
124
+ const dt = ["first", "last"];
125
+ s.enum(dt);
126
+ const ft = s.object({ lower: s.number(), upper: s.number() }), pt = s.object({ lower: s.bigint(), upper: s.bigint() });
127
+ s.union([ft, Q]);
128
+ s.union([pt, Q]);
129
+ s.union([$e, Re]);
130
+ s.union([$e, Re, s.instanceof(String)]);
131
+ const re = (r, e) => {
132
+ const t = {};
133
+ if (typeof r == "number" || typeof r == "bigint")
134
+ e != null ? (t.lower = r, t.upper = e) : (t.lower = typeof r == "bigint" ? 0n : 0, t.upper = r);
135
+ else if (Array.isArray(r)) {
136
+ if (r.length !== 2) throw new Error("bounds: expected array of length 2");
137
+ [t.lower, t.upper] = r;
138
+ } else return ge(r);
139
+ return ge(t);
140
+ }, ge = (r) => r.lower > r.upper ? { lower: r.upper, upper: r.lower } : r;
141
+ s.object({
142
+ x: Me.or(ye),
143
+ y: Ce.or(ye)
407
144
  });
408
- const yr = i.object({ x: gt, y: vt }), gr = Object.freeze({ x: "left", y: "top" }), vr = (t, e) => t.x === e.x && t.y === e.y, Ze = i.union([
409
- i.number(),
410
- ie,
411
- fe,
412
- ht,
413
- nr,
414
- or
415
- ]), Or = (t, e) => {
416
- if (typeof t == "string") {
417
- if (e === void 0)
418
- throw new Error("The y coordinate must be given.");
419
- return t === "x" ? { x: e, y: 0 } : { x: 0, y: e };
420
- }
421
- return typeof t == "number" ? { x: t, y: e ?? t } : Array.isArray(t) ? { x: t[0], y: t[1] } : "signedWidth" in t ? { x: t.signedWidth, y: t.signedHeight } : "clientX" in t ? { x: t.clientX, y: t.clientY } : "width" in t ? { x: t.width, y: t.height } : { x: t.x, y: t.y };
422
- }, ze = Object.freeze({ x: 0, y: 0 }), H = i.union([i.number(), i.string()]);
423
- i.object({
424
- top: H,
425
- left: H,
426
- width: H,
427
- height: H
145
+ const yt = s.object({ x: Me, y: Ce }), gt = Object.freeze({ x: "left", y: "top" }), wt = (r, e) => r.x === e.x && r.y === e.y, we = s.union([
146
+ s.number(),
147
+ X,
148
+ Q,
149
+ xe,
150
+ nt,
151
+ at
152
+ ]), mt = (r, e) => {
153
+ if (typeof r == "string") {
154
+ if (e === void 0) throw new Error("The y coordinate must be given.");
155
+ return r === "x" ? { x: e, y: 0 } : { x: 0, y: e };
156
+ }
157
+ 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
+ }, me = Object.freeze({ x: 0, y: 0 }), Z = s.union([s.number(), s.string()]);
159
+ s.object({
160
+ top: Z,
161
+ left: Z,
162
+ width: Z,
163
+ height: Z
428
164
  });
429
- i.object({
430
- left: i.number(),
431
- top: i.number(),
432
- right: i.number(),
433
- bottom: i.number()
165
+ s.object({
166
+ left: s.number(),
167
+ top: s.number(),
168
+ right: s.number(),
169
+ bottom: s.number()
434
170
  });
435
- i.object({
436
- one: ie,
437
- two: ie,
438
- root: yr
171
+ s.object({
172
+ one: X,
173
+ two: X,
174
+ root: yt
439
175
  });
440
- const Be = (t, e, r = 0, n = 0, s) => {
176
+ const le = (r, e, t = 0, n = 0, i) => {
441
177
  const a = {
442
- one: { ...ze },
443
- two: { ...ze },
444
- root: s ?? gr
178
+ one: { ...me },
179
+ two: { ...me },
180
+ root: i ?? gt
445
181
  };
446
- if (typeof t == "number") {
182
+ if (typeof r == "number") {
447
183
  if (typeof e != "number")
448
184
  throw new Error("Box constructor called with invalid arguments");
449
- return a.one = { x: t, y: e }, a.two = { x: a.one.x + r, y: a.one.y + n }, a;
185
+ return a.one = { x: r, y: e }, a.two = { x: a.one.x + t, y: a.one.y + n }, a;
450
186
  }
451
- return "one" in t && "two" in t && "root" in t ? { ...t, root: s ?? t.root } : ("getBoundingClientRect" in t && (t = t.getBoundingClientRect()), "left" in t ? (a.one = { x: t.left, y: t.top }, a.two = { x: t.right, y: t.bottom }, a) : (a.one = t, e == null ? a.two = { x: a.one.x + r, y: a.one.y + n } : typeof e == "number" ? a.two = { x: a.one.x + e, y: a.one.y + r } : "width" in e ? a.two = {
187
+ return "one" in r && "two" in r && "root" in r ? { ...r, root: i ?? r.root } : ("getBoundingClientRect" in r && (r = r.getBoundingClientRect()), "left" in r ? (a.one = { x: r.left, y: r.top }, a.two = { x: r.right, y: r.bottom }, a) : (a.one = r, e == null ? a.two = { x: a.one.x + t, y: a.one.y + n } : typeof e == "number" ? a.two = { x: a.one.x + e, y: a.one.y + t } : "width" in e ? a.two = {
452
188
  x: a.one.x + e.width,
453
189
  y: a.one.y + e.height
454
190
  } : "signedWidth" in e ? a.two = {
455
191
  x: a.one.x + e.signedWidth,
456
192
  y: a.one.y + e.signedHeight
457
193
  } : a.two = e, a));
458
- }, ve = (t) => {
459
- const e = Be(t);
194
+ }, ne = (r) => {
195
+ const e = le(r);
460
196
  return { lower: e.one.x, upper: e.two.x };
461
- }, Oe = (t) => {
462
- const e = Be(t);
197
+ }, se = (r) => {
198
+ const e = le(r);
463
199
  return { lower: e.one.y, upper: e.two.y };
464
- }, wr = (t) => typeof t != "object" || t == null ? !1 : "one" in t && "two" in t && "root" in t;
465
- var br = Object.defineProperty, mr = (t, e, r) => e in t ? br(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, Z = (t, e, r) => (mr(t, typeof e != "symbol" ? e + "" : e, r), r);
466
- const Tr = (t, e, r) => (e != null && (t = Math.max(t, e)), r != null && (t = Math.min(t, r)), t);
467
- i.object({ offset: Ze, scale: Ze });
468
- const Sr = (t) => (e, r, n, s) => r === "dimension" ? [e, n] : [e, s ? n - t : n + t], Ar = (t) => (e, r, n, s) => [e, s ? n / t : n * t], Ir = (t) => (e, r, n) => {
469
- if (e === null)
470
- return [t, n];
471
- const { lower: s, upper: a } = e, { lower: u, upper: c } = t, h = a - s, E = c - u;
472
- if (r === "dimension")
473
- return [t, n * (E / h)];
474
- const A = (n - s) * (E / h) + u;
475
- return [t, A];
476
- }, Nr = (t) => (e, r, n) => [t, n], Er = () => (t, e, r) => {
477
- if (t === null)
478
- throw new Error("cannot invert without bounds");
479
- if (e === "dimension")
480
- return [t, r];
481
- const { lower: n, upper: s } = t;
482
- return [t, s - (r - n)];
483
- }, Cr = (t) => (e, r, n) => {
484
- const { lower: s, upper: a } = t;
485
- return n = Tr(n, s, a), [e, n];
486
- }, me = class q {
200
+ }, Ot = (r) => typeof r != "object" || r == null ? !1 : "one" in r && "two" in r && "root" in r;
201
+ var vt = Object.defineProperty, bt = (r, e, t) => e in r ? vt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, C = (r, e, t) => bt(r, typeof e != "symbol" ? e + "" : e, t);
202
+ const Tt = (r, e, t) => e !== void 0 && r < e ? e : t !== void 0 && r > t ? t : r;
203
+ s.object({ offset: we, scale: we });
204
+ const It = (r) => (e, t, n, i) => t === "dimension" ? [e, n] : [
205
+ e,
206
+ i ? n - r : n + r
207
+ ], St = (r) => (e, t, n, i) => [
208
+ e,
209
+ i ? n / r : n * r
210
+ ], Nt = (r) => (e, t, n) => {
211
+ if (e === null) return [r, n];
212
+ const { lower: i, upper: a } = e, { lower: c, upper: h } = r, p = a - i, m = h - c;
213
+ if (t === "dimension") return [r, n * (m / p)];
214
+ const v = (n - i) * (m / p) + c;
215
+ return [r, v];
216
+ }, Et = (r) => (e, t, n) => [r, n], At = () => (r, e, t) => {
217
+ if (r === null) throw new Error("cannot invert without bounds");
218
+ if (e === "dimension") return [r, t];
219
+ const { lower: n, upper: i } = r;
220
+ return [r, i - (t - n)];
221
+ }, xt = (r) => (e, t, n) => {
222
+ const { lower: i, upper: a } = r;
223
+ return n = Tt(n, i, a), [e, n];
224
+ }, ae = class W {
487
225
  constructor() {
488
- Z(this, "ops", []), Z(this, "currBounds", null), Z(this, "currType", null), Z(this, "reversed", !1), this.ops = [];
226
+ C(this, "ops", []), C(this, "currBounds", null), C(this, "currType", null), C(this, "reversed", !1), this.ops = [];
489
227
  }
490
228
  static translate(e) {
491
- return new q().translate(e);
229
+ return new W().translate(e);
492
230
  }
493
231
  static magnify(e) {
494
- return new q().magnify(e);
232
+ return new W().magnify(e);
495
233
  }
496
- static scale(e, r) {
497
- return new q().scale(e, r);
234
+ static scale(e, t) {
235
+ return new W().scale(e, t);
498
236
  }
499
237
  translate(e) {
500
- const r = this.new(), n = Sr(e);
501
- return n.type = "translate", r.ops.push(n), r;
238
+ const t = this.new(), n = It(e);
239
+ return n.type = "translate", t.ops.push(n), t;
502
240
  }
503
241
  magnify(e) {
504
- const r = this.new(), n = Ar(e);
505
- return n.type = "magnify", r.ops.push(n), r;
242
+ const t = this.new(), n = St(e);
243
+ return n.type = "magnify", t.ops.push(n), t;
506
244
  }
507
- scale(e, r) {
508
- const n = ge(e, r), s = this.new(), a = Ir(n);
509
- return a.type = "scale", s.ops.push(a), s;
245
+ scale(e, t) {
246
+ const n = re(e, t), i = this.new(), a = Nt(n);
247
+ return a.type = "scale", i.ops.push(a), i;
510
248
  }
511
- clamp(e, r) {
512
- const n = ge(e, r), s = this.new(), a = Cr(n);
513
- return a.type = "clamp", s.ops.push(a), s;
249
+ clamp(e, t) {
250
+ const n = re(e, t), i = this.new(), a = xt(n);
251
+ return a.type = "clamp", i.ops.push(a), i;
514
252
  }
515
- reBound(e, r) {
516
- const n = ge(e, r), s = this.new(), a = Nr(n);
517
- return a.type = "re-bound", s.ops.push(a), s;
253
+ reBound(e, t) {
254
+ const n = re(e, t), i = this.new(), a = Et(n);
255
+ return a.type = "re-bound", i.ops.push(a), i;
518
256
  }
519
257
  invert() {
520
- const e = Er();
258
+ const e = At();
521
259
  e.type = "invert";
522
- const r = this.new();
523
- return r.ops.push(e), r;
260
+ const t = this.new();
261
+ return t.ops.push(e), t;
524
262
  }
525
263
  pos(e) {
526
264
  return this.exec("position", e);
@@ -529,91 +267,91 @@ const Sr = (t) => (e, r, n, s) => r === "dimension" ? [e, n] : [e, s ? n - t : n
529
267
  return this.exec("dimension", e);
530
268
  }
531
269
  new() {
532
- const e = new q();
270
+ const e = new W();
533
271
  return e.ops = this.ops.slice(), e.reversed = this.reversed, e;
534
272
  }
535
- exec(e, r) {
273
+ exec(e, t) {
536
274
  return this.currBounds = null, this.ops.reduce(
537
- ([n, s], a) => a(n, e, s, this.reversed),
538
- [null, r]
275
+ ([n, i], a) => a(n, e, i, this.reversed),
276
+ [null, t]
539
277
  )[1];
540
278
  }
541
279
  reverse() {
542
280
  const e = this.new();
543
281
  e.ops.reverse();
544
- const r = [];
545
- return e.ops.forEach((n, s) => {
546
- if (n.type === "scale" || r.some(([u, c]) => s >= u && s <= c))
282
+ const t = [];
283
+ return e.ops.forEach((n, i) => {
284
+ if (n.type === "scale" || t.some(([c, h]) => i >= c && i <= h))
547
285
  return;
548
- const a = e.ops.findIndex((u, c) => u.type === "scale" && c > s);
549
- a !== -1 && r.push([s, a]);
550
- }), r.forEach(([n, s]) => {
551
- const a = e.ops.slice(n, s);
552
- a.unshift(e.ops[s]), e.ops.splice(n, s - n + 1, ...a);
286
+ const a = e.ops.findIndex((c, h) => c.type === "scale" && h > i);
287
+ a !== -1 && t.push([i, a]);
288
+ }), t.forEach(([n, i]) => {
289
+ const a = e.ops.slice(n, i);
290
+ a.unshift(e.ops[i]), e.ops.splice(n, i - n + 1, ...a);
553
291
  }), e.reversed = !e.reversed, e;
554
292
  }
555
293
  };
556
- Z(me, "IDENTITY", new me());
557
- let Ye = me;
558
- const Ke = class P {
559
- constructor(e = new Ye(), r = new Ye(), n = null) {
560
- Z(this, "x"), Z(this, "y"), Z(this, "currRoot"), this.x = e, this.y = r, this.currRoot = n;
294
+ C(ae, "IDENTITY", new ae());
295
+ let Oe = ae;
296
+ const ve = class M {
297
+ constructor(e = new Oe(), t = new Oe(), n = null) {
298
+ C(this, "x"), C(this, "y"), C(this, "currRoot"), this.x = e, this.y = t, this.currRoot = n;
561
299
  }
562
- static translate(e, r) {
563
- return new P().translate(e, r);
300
+ static translate(e, t) {
301
+ return new M().translate(e, t);
564
302
  }
565
303
  static translateX(e) {
566
- return new P().translateX(e);
304
+ return new M().translateX(e);
567
305
  }
568
306
  static translateY(e) {
569
- return new P().translateY(e);
307
+ return new M().translateY(e);
570
308
  }
571
309
  static clamp(e) {
572
- return new P().clamp(e);
310
+ return new M().clamp(e);
573
311
  }
574
312
  static magnify(e) {
575
- return new P().magnify(e);
313
+ return new M().magnify(e);
576
314
  }
577
315
  static scale(e) {
578
- return new P().scale(e);
316
+ return new M().scale(e);
579
317
  }
580
318
  static reBound(e) {
581
- return new P().reBound(e);
319
+ return new M().reBound(e);
582
320
  }
583
- translate(e, r) {
584
- const n = Or(e, r), s = this.copy();
585
- return s.x = this.x.translate(n.x), s.y = this.y.translate(n.y), s;
321
+ translate(e, t) {
322
+ const n = mt(e, t), i = this.copy();
323
+ return i.x = this.x.translate(n.x), i.y = this.y.translate(n.y), i;
586
324
  }
587
325
  translateX(e) {
588
- const r = this.copy();
589
- return r.x = this.x.translate(e), r;
326
+ const t = this.copy();
327
+ return t.x = this.x.translate(e), t;
590
328
  }
591
329
  translateY(e) {
592
- const r = this.copy();
593
- return r.y = this.y.translate(e), r;
330
+ const t = this.copy();
331
+ return t.y = this.y.translate(e), t;
594
332
  }
595
333
  magnify(e) {
596
- const r = this.copy();
597
- return r.x = this.x.magnify(e.x), r.y = this.y.magnify(e.y), r;
334
+ const t = this.copy();
335
+ return t.x = this.x.magnify(e.x), t.y = this.y.magnify(e.y), t;
598
336
  }
599
337
  scale(e) {
600
- const r = this.copy();
601
- if (wr(e)) {
338
+ const t = this.copy();
339
+ if (Ot(e)) {
602
340
  const n = this.currRoot;
603
- return r.currRoot = e.root, n != null && !vr(n, e.root) && (n.x !== e.root.x && (r.x = r.x.invert()), n.y !== e.root.y && (r.y = r.y.invert())), r.x = r.x.scale(ve(e)), r.y = r.y.scale(Oe(e)), r;
341
+ return t.currRoot = e.root, n != null && !wt(n, e.root) && (n.x !== e.root.x && (t.x = t.x.invert()), n.y !== e.root.y && (t.y = t.y.invert())), t.x = t.x.scale(ne(e)), t.y = t.y.scale(se(e)), t;
604
342
  }
605
- return r.x = r.x.scale(e.width), r.y = r.y.scale(e.height), r;
343
+ return t.x = t.x.scale(e.width), t.y = t.y.scale(e.height), t;
606
344
  }
607
345
  reBound(e) {
608
- const r = this.copy();
609
- return r.x = this.x.reBound(ve(e)), r.y = this.y.reBound(Oe(e)), r;
346
+ const t = this.copy();
347
+ return t.x = this.x.reBound(ne(e)), t.y = this.y.reBound(se(e)), t;
610
348
  }
611
349
  clamp(e) {
612
- const r = this.copy();
613
- return r.x = this.x.clamp(ve(e)), r.y = this.y.clamp(Oe(e)), r;
350
+ const t = this.copy();
351
+ return t.x = this.x.clamp(ne(e)), t.y = this.y.clamp(se(e)), t;
614
352
  }
615
353
  copy() {
616
- const e = new P();
354
+ const e = new M();
617
355
  return e.currRoot = this.currRoot, e.x = this.x, e.y = this.y, e;
618
356
  }
619
357
  reverse() {
@@ -624,7 +362,7 @@ const Ke = class P {
624
362
  return { x: this.x.pos(e.x), y: this.y.pos(e.y) };
625
363
  }
626
364
  box(e) {
627
- return Be(
365
+ return le(
628
366
  this.pos(e.one),
629
367
  this.pos(e.two),
630
368
  0,
@@ -633,70 +371,42 @@ const Ke = class P {
633
371
  );
634
372
  }
635
373
  };
636
- Z(Ke, "IDENTITY", new Ke());
637
- i.record(
638
- i.union([i.number(), i.string(), i.symbol()]),
639
- i.unknown()
640
- );
641
- const bt = () => typeof process < "u" && process.versions != null && process.versions.node != null ? "node" : typeof window > "u" || window.document === void 0 ? "webworker" : "browser", $r = bt(), mt = ["MacOS", "Windows", "Linux", "Docker"], Ur = i.enum(mt);
642
- let we;
643
- const xr = () => {
644
- if (typeof window > "u")
645
- return;
646
- const t = window.navigator.userAgent.toLowerCase();
647
- if (t.includes("mac"))
648
- return "MacOS";
649
- if (t.includes("win"))
650
- return "Windows";
651
- if (t.includes("linux"))
652
- return "Linux";
653
- }, Mr = (t = {}) => {
654
- const { force: e, default: r } = t;
655
- return e ?? we ?? (we = xr(), we ?? r);
656
- }, Tt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
657
- __proto__: null,
658
- OPERATING_SYSTEMS: mt,
659
- RUNTIME: $r,
660
- detect: bt,
661
- getOS: Mr,
662
- osZ: Ur
663
- }, Symbol.toStringTag, { value: "Module" })), jr = i.object({ signedWidth: i.number(), signedHeight: i.number() });
664
- i.union([ht, jr, ie, fe]);
665
- var Rr = Object.defineProperty, Dr = (t, e, r) => e in t ? Rr(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, l = (t, e, r) => (Dr(t, typeof e != "symbol" ? e + "" : e, r), r);
666
- const St = (t, e) => {
667
- const r = new m(e);
374
+ C(ve, "IDENTITY", new ve());
375
+ const $t = s.object({ signedWidth: s.number(), signedHeight: s.number() });
376
+ s.union([xe, $t, X, Q]);
377
+ var Ut = Object.defineProperty, Mt = (r, e, t) => e in r ? Ut(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, u = (r, e, t) => Mt(r, typeof e != "symbol" ? e + "" : e, t);
378
+ const De = (r, e) => {
379
+ const t = new T(e);
668
380
  if (![
669
- T.DAY,
670
- T.HOUR,
671
- T.MINUTE,
672
- T.SECOND,
673
- T.MILLISECOND,
674
- T.MICROSECOND,
675
- T.NANOSECOND
676
- ].some((s) => s.equals(r)))
381
+ I.DAY,
382
+ I.HOUR,
383
+ I.MINUTE,
384
+ I.SECOND,
385
+ I.MILLISECOND,
386
+ I.MICROSECOND,
387
+ I.NANOSECOND
388
+ ].some((i) => i.equals(t)))
677
389
  throw new Error(
678
390
  "Invalid argument for remainder. Must be an even TimeSpan or Timestamp"
679
391
  );
680
- const n = t.valueOf() % r.valueOf();
681
- return t instanceof m ? new m(n) : new T(n);
682
- }, y = class f {
683
- constructor(e, r = "UTC") {
684
- if (l(this, "value"), l(this, "encodeValue", !0), e == null)
685
- this.value = f.now().valueOf();
392
+ const n = r.valueOf() % t.valueOf();
393
+ return r instanceof T ? new T(n) : new I(n);
394
+ }, y = class l {
395
+ constructor(e, t = "UTC") {
396
+ if (u(this, "value"), u(this, "encodeValue", !0), e == null) this.value = l.now().valueOf();
686
397
  else if (e instanceof Date)
687
- this.value = BigInt(e.getTime()) * f.MILLISECOND.valueOf();
398
+ this.value = BigInt(e.getTime()) * l.MILLISECOND.valueOf();
688
399
  else if (typeof e == "string")
689
- this.value = f.parseDateTimeString(e, r).valueOf();
690
- else if (Array.isArray(e))
691
- this.value = f.parseDate(e);
400
+ this.value = l.parseDateTimeString(e, t).valueOf();
401
+ else if (Array.isArray(e)) this.value = l.parseDate(e);
692
402
  else {
693
403
  let n = BigInt(0);
694
- e instanceof Number && (e = e.valueOf()), r === "local" && (n = f.utcOffset.valueOf()), typeof e == "number" && (isFinite(e) ? e = Math.trunc(e) : (isNaN(e) && (e = 0), e === 1 / 0 ? e = f.MAX : e = f.MIN)), this.value = BigInt(e.valueOf()) + n;
404
+ e instanceof Number && (e = e.valueOf()), t === "local" && (n = l.utcOffset.valueOf()), typeof e == "number" && (isFinite(e) ? e = Math.trunc(e) : (isNaN(e) && (e = 0), e === 1 / 0 ? e = l.MAX : e = l.MIN)), this.value = BigInt(e.valueOf()) + n;
695
405
  }
696
406
  }
697
- static parseDate([e = 1970, r = 1, n = 1]) {
698
- const s = new Date(e, r - 1, n, 0, 0, 0, 0);
699
- return new f(BigInt(s.getTime()) * f.MILLISECOND.valueOf()).truncate(f.DAY).valueOf();
407
+ static parseDate([e = 1970, t = 1, n = 1]) {
408
+ const i = new Date(e, t - 1, n, 0, 0, 0, 0);
409
+ return new l(BigInt(i.getTime()) * l.MILLISECOND.valueOf()).truncate(l.DAY).valueOf();
700
410
  }
701
411
  encode() {
702
412
  return this.value.toString();
@@ -704,56 +414,56 @@ const St = (t, e) => {
704
414
  valueOf() {
705
415
  return this.value;
706
416
  }
707
- static parseTimeString(e, r = "UTC") {
708
- const [n, s, a] = e.split(":");
709
- let u = "00", c = "00";
710
- a != null && ([u, c] = a.split("."));
711
- let h = f.hours(parseInt(n ?? "00", 10)).add(f.minutes(parseInt(s ?? "00", 10))).add(f.seconds(parseInt(u ?? "00", 10))).add(f.milliseconds(parseInt(c ?? "00", 10)));
712
- return r === "local" && (h = h.add(f.utcOffset)), h.valueOf();
417
+ static parseTimeString(e, t = "UTC") {
418
+ const [n, i, a] = e.split(":");
419
+ let c = "00", h = "00";
420
+ a != null && ([c, h] = a.split("."));
421
+ let p = l.hours(parseInt(n ?? "00", 10)).add(l.minutes(parseInt(i ?? "00", 10))).add(l.seconds(parseInt(c ?? "00", 10))).add(l.milliseconds(parseInt(h ?? "00", 10)));
422
+ return t === "local" && (p = p.add(l.utcOffset)), p.valueOf();
713
423
  }
714
- static parseDateTimeString(e, r = "UTC") {
424
+ static parseDateTimeString(e, t = "UTC") {
715
425
  if (!e.includes("/") && !e.includes("-"))
716
- return f.parseTimeString(e, r);
426
+ return l.parseTimeString(e, t);
717
427
  const n = new Date(e);
718
- return e.includes(":") || n.setUTCHours(0, 0, 0, 0), new f(
719
- BigInt(n.getTime()) * f.MILLISECOND.valueOf(),
720
- r
428
+ return e.includes(":") || n.setUTCHours(0, 0, 0, 0), new l(
429
+ BigInt(n.getTime()) * l.MILLISECOND.valueOf(),
430
+ t
721
431
  ).valueOf();
722
432
  }
723
- fString(e = "ISO", r = "UTC") {
433
+ fString(e = "ISO", t = "UTC") {
724
434
  switch (e) {
725
435
  case "ISODate":
726
- return this.toISOString(r).slice(0, 10);
436
+ return this.toISOString(t).slice(0, 10);
727
437
  case "ISOTime":
728
- return this.toISOString(r).slice(11, 23);
438
+ return this.toISOString(t).slice(11, 23);
729
439
  case "time":
730
- return this.timeString(!1, r);
440
+ return this.timeString(!1, t);
731
441
  case "preciseTime":
732
- return this.timeString(!0, r);
442
+ return this.timeString(!0, t);
733
443
  case "date":
734
444
  return this.dateString();
735
445
  case "preciseDate":
736
- return `${this.dateString()} ${this.timeString(!0, r)}`;
446
+ return `${this.dateString()} ${this.timeString(!0, t)}`;
737
447
  case "dateTime":
738
- return `${this.dateString()} ${this.timeString(!1, r)}`;
448
+ return `${this.dateString()} ${this.timeString(!1, t)}`;
739
449
  default:
740
- return this.toISOString(r);
450
+ return this.toISOString(t);
741
451
  }
742
452
  }
743
453
  toISOString(e = "UTC") {
744
- return e === "UTC" ? this.date().toISOString() : this.sub(f.utcOffset).date().toISOString();
454
+ return e === "UTC" ? this.date().toISOString() : this.sub(l.utcOffset).date().toISOString();
745
455
  }
746
- timeString(e = !1, r = "UTC") {
747
- const n = this.toISOString(r);
456
+ timeString(e = !1, t = "UTC") {
457
+ const n = this.toISOString(t);
748
458
  return e ? n.slice(11, 23) : n.slice(11, 19);
749
459
  }
750
460
  dateString() {
751
- const e = this.date(), r = e.toLocaleString("default", { month: "short" }), n = e.toLocaleString("default", { day: "numeric" });
752
- return `${r} ${n}`;
461
+ const e = this.date(), t = e.toLocaleString("default", { month: "short" }), n = e.toLocaleString("default", { day: "numeric" });
462
+ return `${t} ${n}`;
753
463
  }
754
464
  static get utcOffset() {
755
- return new T(
756
- BigInt((/* @__PURE__ */ new Date()).getTimezoneOffset()) * f.MINUTE.valueOf()
465
+ return new I(
466
+ BigInt((/* @__PURE__ */ new Date()).getTimezoneOffset()) * l.MINUTE.valueOf()
757
467
  );
758
468
  }
759
469
  /**
@@ -762,7 +472,7 @@ const St = (t, e) => {
762
472
  * @param other - The other timestamp.
763
473
  */
764
474
  static since(e) {
765
- return new f().span(e);
475
+ return new l().span(e);
766
476
  }
767
477
  /** @returns A JavaScript Date object representing the TimeStamp. */
768
478
  date() {
@@ -775,7 +485,7 @@ const St = (t, e) => {
775
485
  * @returns True if the TimeStamps are equal, false otherwise.
776
486
  */
777
487
  equals(e) {
778
- return this.valueOf() === new f(e).valueOf();
488
+ return this.valueOf() === new l(e).valueOf();
779
489
  }
780
490
  /**
781
491
  * Creates a TimeSpan representing the duration between the two timestamps.
@@ -795,7 +505,7 @@ const St = (t, e) => {
795
505
  * valid, regardless of the TimeStamp order.
796
506
  */
797
507
  range(e) {
798
- return new Br(this, e).makeValid();
508
+ return new Ct(this, e).makeValid();
799
509
  }
800
510
  /**
801
511
  * Creates a TimeRange starting at the TimeStamp and spanning the given
@@ -824,7 +534,7 @@ const St = (t, e) => {
824
534
  * otherwise.
825
535
  */
826
536
  after(e) {
827
- return this.valueOf() > new f(e).valueOf();
537
+ return this.valueOf() > new l(e).valueOf();
828
538
  }
829
539
  /**
830
540
  * Checks if the TimeStamp is after or equal to the given TimeStamp.
@@ -834,7 +544,7 @@ const St = (t, e) => {
834
544
  * false otherwise.
835
545
  */
836
546
  afterEq(e) {
837
- return this.valueOf() >= new f(e).valueOf();
547
+ return this.valueOf() >= new l(e).valueOf();
838
548
  }
839
549
  /**
840
550
  * Checks if the TimeStamp is before the given TimeStamp.
@@ -844,7 +554,7 @@ const St = (t, e) => {
844
554
  * otherwise.
845
555
  */
846
556
  before(e) {
847
- return this.valueOf() < new f(e).valueOf();
557
+ return this.valueOf() < new l(e).valueOf();
848
558
  }
849
559
  /**
850
560
  * Checks if TimeStamp is before or equal to the current timestamp.
@@ -854,7 +564,7 @@ const St = (t, e) => {
854
564
  * false otherwise.
855
565
  */
856
566
  beforeEq(e) {
857
- return this.valueOf() <= new f(e).valueOf();
567
+ return this.valueOf() <= new l(e).valueOf();
858
568
  }
859
569
  /**
860
570
  * Adds a TimeSpan to the TimeStamp.
@@ -864,7 +574,7 @@ const St = (t, e) => {
864
574
  * TimeSpan.
865
575
  */
866
576
  add(e) {
867
- return new f(this.valueOf() + BigInt(e.valueOf()));
577
+ return new l(this.valueOf() + BigInt(e.valueOf()));
868
578
  }
869
579
  /**
870
580
  * Subtracts a TimeSpan from the TimeStamp.
@@ -874,13 +584,13 @@ const St = (t, e) => {
874
584
  * TimeSpan.
875
585
  */
876
586
  sub(e) {
877
- return new f(this.valueOf() - BigInt(e.valueOf()));
587
+ return new l(this.valueOf() - BigInt(e.valueOf()));
878
588
  }
879
589
  /**
880
590
  * @returns The number of milliseconds since the unix epoch.
881
591
  */
882
592
  milliseconds() {
883
- return Number(this.valueOf()) / Number(f.MILLISECOND.valueOf());
593
+ return Number(this.valueOf()) / Number(l.MILLISECOND.valueOf());
884
594
  }
885
595
  toString() {
886
596
  return this.date().toISOString();
@@ -897,11 +607,11 @@ const St = (t, e) => {
897
607
  * @example TimeStamp.now().remainder(TimeStamp.DAY) // => TimeStamp representing the current day
898
608
  */
899
609
  remainder(e) {
900
- return St(this, e);
610
+ return De(this, e);
901
611
  }
902
612
  /** @returns true if the day portion TimeStamp is today, false otherwise. */
903
613
  get isToday() {
904
- return this.truncate(T.DAY).equals(f.now().truncate(T.DAY));
614
+ return this.truncate(I.DAY).equals(l.now().truncate(I.DAY));
905
615
  }
906
616
  truncate(e) {
907
617
  return this.sub(this.remainder(e));
@@ -912,74 +622,74 @@ const St = (t, e) => {
912
622
  * JavaScript can do).
913
623
  */
914
624
  static now() {
915
- return new f(/* @__PURE__ */ new Date());
625
+ return new l(/* @__PURE__ */ new Date());
916
626
  }
917
627
  static max(...e) {
918
- let r = f.MIN;
628
+ let t = l.MIN;
919
629
  for (const n of e) {
920
- const s = new f(n);
921
- s.after(r) && (r = s);
630
+ const i = new l(n);
631
+ i.after(t) && (t = i);
922
632
  }
923
- return r;
633
+ return t;
924
634
  }
925
635
  static min(...e) {
926
- let r = f.MAX;
636
+ let t = l.MAX;
927
637
  for (const n of e) {
928
- const s = new f(n);
929
- s.before(r) && (r = s);
638
+ const i = new l(n);
639
+ i.before(t) && (t = i);
930
640
  }
931
- return r;
641
+ return t;
932
642
  }
933
643
  /** @returns a new TimeStamp n nanoseconds after the unix epoch */
934
644
  static nanoseconds(e) {
935
- return new f(e);
645
+ return new l(e);
936
646
  }
937
647
  /** @returns a new TimeStamp n microseconds after the unix epoch */
938
648
  static microseconds(e) {
939
- return f.nanoseconds(e * 1e3);
649
+ return l.nanoseconds(e * 1e3);
940
650
  }
941
651
  /** @returns a new TimeStamp n milliseconds after the unix epoch */
942
652
  static milliseconds(e) {
943
- return f.microseconds(e * 1e3);
653
+ return l.microseconds(e * 1e3);
944
654
  }
945
655
  /** @returns a new TimeStamp n seconds after the unix epoch */
946
656
  static seconds(e) {
947
- return f.milliseconds(e * 1e3);
657
+ return l.milliseconds(e * 1e3);
948
658
  }
949
659
  /** @returns a new TimeStamp n minutes after the unix epoch */
950
660
  static minutes(e) {
951
- return f.seconds(e * 60);
661
+ return l.seconds(e * 60);
952
662
  }
953
663
  /** @returns a new TimeStamp n hours after the unix epoch */
954
664
  static hours(e) {
955
- return f.minutes(e * 60);
665
+ return l.minutes(e * 60);
956
666
  }
957
667
  /** @returns a new TimeStamp n days after the unix epoch */
958
668
  static days(e) {
959
- return f.hours(e * 24);
669
+ return l.hours(e * 24);
960
670
  }
961
671
  };
962
- l(y, "NANOSECOND", y.nanoseconds(1)), /** One microsecond after the unix epoch */
963
- l(y, "MICROSECOND", y.microseconds(1)), /** One millisecond after the unix epoch */
964
- l(y, "MILLISECOND", y.milliseconds(1)), /** One second after the unix epoch */
965
- l(y, "SECOND", y.seconds(1)), /** One minute after the unix epoch */
966
- l(y, "MINUTE", y.minutes(1)), /** One hour after the unix epoch */
967
- l(y, "HOUR", y.hours(1)), /** One day after the unix epoch */
968
- l(y, "DAY", y.days(1)), /** The maximum possible value for a timestamp */
969
- l(y, "MAX", new y((1n << 63n) - 1n)), /** The minimum possible value for a timestamp */
970
- l(y, "MIN", new y(0)), /** The unix epoch */
971
- l(y, "ZERO", new y(0)), /** A zod schema for validating timestamps */
972
- l(y, "z", i.union([
973
- i.object({ value: i.bigint() }).transform((t) => new y(t.value)),
974
- i.string().transform((t) => new y(BigInt(t))),
975
- i.instanceof(Number).transform((t) => new y(t)),
976
- i.number().transform((t) => new y(t)),
977
- i.instanceof(y)
672
+ u(y, "NANOSECOND", y.nanoseconds(1)), /** One microsecond after the unix epoch */
673
+ u(y, "MICROSECOND", y.microseconds(1)), /** One millisecond after the unix epoch */
674
+ u(y, "MILLISECOND", y.milliseconds(1)), /** One second after the unix epoch */
675
+ u(y, "SECOND", y.seconds(1)), /** One minute after the unix epoch */
676
+ u(y, "MINUTE", y.minutes(1)), /** One hour after the unix epoch */
677
+ u(y, "HOUR", y.hours(1)), /** One day after the unix epoch */
678
+ u(y, "DAY", y.days(1)), /** The maximum possible value for a timestamp */
679
+ u(y, "MAX", new y((1n << 63n) - 1n)), /** The minimum possible value for a timestamp */
680
+ u(y, "MIN", new y(0)), /** The unix epoch */
681
+ u(y, "ZERO", new y(0)), /** A zod schema for validating timestamps */
682
+ u(y, "z", s.union([
683
+ s.object({ value: s.bigint() }).transform((r) => new y(r.value)),
684
+ s.string().transform((r) => new y(BigInt(r))),
685
+ s.instanceof(Number).transform((r) => new y(r)),
686
+ s.number().transform((r) => new y(r)),
687
+ s.instanceof(y)
978
688
  ]));
979
- let m = y;
980
- const g = class p {
689
+ let T = y;
690
+ const g = class d {
981
691
  constructor(e) {
982
- l(this, "value"), l(this, "encodeValue", !0), typeof e == "number" && (e = Math.trunc(e.valueOf())), this.value = BigInt(e.valueOf());
692
+ u(this, "value"), u(this, "encodeValue", !0), typeof e == "number" && (e = Math.trunc(e.valueOf())), this.value = BigInt(e.valueOf());
983
693
  }
984
694
  encode() {
985
695
  return this.value.toString();
@@ -988,52 +698,52 @@ const g = class p {
988
698
  return this.value;
989
699
  }
990
700
  lessThan(e) {
991
- return this.valueOf() < new p(e).valueOf();
701
+ return this.valueOf() < new d(e).valueOf();
992
702
  }
993
703
  greaterThan(e) {
994
- return this.valueOf() > new p(e).valueOf();
704
+ return this.valueOf() > new d(e).valueOf();
995
705
  }
996
706
  lessThanOrEqual(e) {
997
- return this.valueOf() <= new p(e).valueOf();
707
+ return this.valueOf() <= new d(e).valueOf();
998
708
  }
999
709
  greaterThanOrEqual(e) {
1000
- return this.valueOf() >= new p(e).valueOf();
710
+ return this.valueOf() >= new d(e).valueOf();
1001
711
  }
1002
712
  remainder(e) {
1003
- return St(this, e);
713
+ return De(this, e);
1004
714
  }
1005
715
  truncate(e) {
1006
- return new p(
716
+ return new d(
1007
717
  BigInt(Math.trunc(Number(this.valueOf() / e.valueOf()))) * e.valueOf()
1008
718
  );
1009
719
  }
1010
720
  toString() {
1011
- const e = this.truncate(p.DAY), r = this.truncate(p.HOUR), n = this.truncate(p.MINUTE), s = this.truncate(p.SECOND), a = this.truncate(p.MILLISECOND), u = this.truncate(p.MICROSECOND), c = this.truncate(p.NANOSECOND), h = e, E = r.sub(e), A = n.sub(r), O = s.sub(n), $ = a.sub(s), W = u.sub(a), M = c.sub(u);
1012
- let N = "";
1013
- return h.isZero || (N += `${h.days}d `), E.isZero || (N += `${E.hours}h `), A.isZero || (N += `${A.minutes}m `), O.isZero || (N += `${O.seconds}s `), $.isZero || (N += `${$.milliseconds}ms `), W.isZero || (N += `${W.microseconds}µs `), M.isZero || (N += `${M.nanoseconds}ns`), N.trim();
721
+ const e = this.truncate(d.DAY), t = this.truncate(d.HOUR), n = this.truncate(d.MINUTE), i = this.truncate(d.SECOND), a = this.truncate(d.MILLISECOND), c = this.truncate(d.MICROSECOND), h = this.truncate(d.NANOSECOND), p = e, m = t.sub(e), v = n.sub(t), w = i.sub(n), A = a.sub(i), k = c.sub(a), U = h.sub(c);
722
+ let E = "";
723
+ return p.isZero || (E += `${p.days}d `), m.isZero || (E += `${m.hours}h `), v.isZero || (E += `${v.minutes}m `), w.isZero || (E += `${w.seconds}s `), A.isZero || (E += `${A.milliseconds}ms `), k.isZero || (E += `${k.microseconds}µs `), U.isZero || (E += `${U.nanoseconds}ns`), E.trim();
1014
724
  }
1015
725
  /** @returns the decimal number of days in the timespan */
1016
726
  get days() {
1017
- return Number(this.valueOf()) / Number(p.DAY.valueOf());
727
+ return Number(this.valueOf()) / Number(d.DAY.valueOf());
1018
728
  }
1019
729
  /** @returns the decimal number of hours in the timespan */
1020
730
  get hours() {
1021
- return Number(this.valueOf()) / Number(p.HOUR.valueOf());
731
+ return Number(this.valueOf()) / Number(d.HOUR.valueOf());
1022
732
  }
1023
733
  /** @returns the decimal number of minutes in the timespan */
1024
734
  get minutes() {
1025
- return Number(this.valueOf()) / Number(p.MINUTE.valueOf());
735
+ return Number(this.valueOf()) / Number(d.MINUTE.valueOf());
1026
736
  }
1027
737
  /** @returns The number of seconds in the TimeSpan. */
1028
738
  get seconds() {
1029
- return Number(this.valueOf()) / Number(p.SECOND.valueOf());
739
+ return Number(this.valueOf()) / Number(d.SECOND.valueOf());
1030
740
  }
1031
741
  /** @returns The number of milliseconds in the TimeSpan. */
1032
742
  get milliseconds() {
1033
- return Number(this.valueOf()) / Number(p.MILLISECOND.valueOf());
743
+ return Number(this.valueOf()) / Number(d.MILLISECOND.valueOf());
1034
744
  }
1035
745
  get microseconds() {
1036
- return Number(this.valueOf()) / Number(p.MICROSECOND.valueOf());
746
+ return Number(this.valueOf()) / Number(d.MICROSECOND.valueOf());
1037
747
  }
1038
748
  get nanoseconds() {
1039
749
  return Number(this.valueOf());
@@ -1052,7 +762,7 @@ const g = class p {
1052
762
  * @returns True if the TimeSpans are equal, false otherwise.
1053
763
  */
1054
764
  equals(e) {
1055
- return this.valueOf() === new p(e).valueOf();
765
+ return this.valueOf() === new d(e).valueOf();
1056
766
  }
1057
767
  /**
1058
768
  * Adds a TimeSpan to the TimeSpan.
@@ -1060,7 +770,7 @@ const g = class p {
1060
770
  * @returns A new TimeSpan representing the sum of the two TimeSpans.
1061
771
  */
1062
772
  add(e) {
1063
- return new p(this.valueOf() + new p(e).valueOf());
773
+ return new d(this.valueOf() + new d(e).valueOf());
1064
774
  }
1065
775
  /**
1066
776
  * Creates a TimeSpan representing the duration between the two timestamps.
@@ -1068,7 +778,7 @@ const g = class p {
1068
778
  * @param other
1069
779
  */
1070
780
  sub(e) {
1071
- return new p(this.valueOf() - new p(e).valueOf());
781
+ return new d(this.valueOf() - new d(e).valueOf());
1072
782
  }
1073
783
  /**
1074
784
  * Creates a TimeSpan representing the given number of nanoseconds.
@@ -1077,7 +787,7 @@ const g = class p {
1077
787
  * @returns A TimeSpan representing the given number of nanoseconds.
1078
788
  */
1079
789
  static nanoseconds(e = 1) {
1080
- return new p(e);
790
+ return new d(e);
1081
791
  }
1082
792
  /**
1083
793
  * Creates a TimeSpan representing the given number of microseconds.
@@ -1086,7 +796,7 @@ const g = class p {
1086
796
  * @returns A TimeSpan representing the given number of microseconds.
1087
797
  */
1088
798
  static microseconds(e = 1) {
1089
- return p.nanoseconds(e * 1e3);
799
+ return d.nanoseconds(e * 1e3);
1090
800
  }
1091
801
  /**
1092
802
  * Creates a TimeSpan representing the given number of milliseconds.
@@ -1095,7 +805,7 @@ const g = class p {
1095
805
  * @returns A TimeSpan representing the given number of milliseconds.
1096
806
  */
1097
807
  static milliseconds(e = 1) {
1098
- return p.microseconds(e * 1e3);
808
+ return d.microseconds(e * 1e3);
1099
809
  }
1100
810
  /**
1101
811
  * Creates a TimeSpan representing the given number of seconds.
@@ -1104,7 +814,7 @@ const g = class p {
1104
814
  * @returns A TimeSpan representing the given number of seconds.
1105
815
  */
1106
816
  static seconds(e = 1) {
1107
- return p.milliseconds(e * 1e3);
817
+ return d.milliseconds(e * 1e3);
1108
818
  }
1109
819
  /**
1110
820
  * Creates a TimeSpan representing the given number of minutes.
@@ -1113,7 +823,7 @@ const g = class p {
1113
823
  * @returns A TimeSpan representing the given number of minutes.
1114
824
  */
1115
825
  static minutes(e) {
1116
- return p.seconds(e.valueOf() * 60);
826
+ return d.seconds(e.valueOf() * 60);
1117
827
  }
1118
828
  /**
1119
829
  * Creates a TimeSpan representing the given number of hours.
@@ -1122,7 +832,7 @@ const g = class p {
1122
832
  * @returns A TimeSpan representing the given number of hours.
1123
833
  */
1124
834
  static hours(e) {
1125
- return p.minutes(e * 60);
835
+ return d.minutes(e * 60);
1126
836
  }
1127
837
  /**
1128
838
  * Creates a TimeSpan representing the given number of days.
@@ -1131,28 +841,28 @@ const g = class p {
1131
841
  * @returns A TimeSpan representing the given number of days.
1132
842
  */
1133
843
  static days(e) {
1134
- return p.hours(e * 24);
844
+ return d.hours(e * 24);
1135
845
  }
1136
846
  };
1137
- l(g, "NANOSECOND", g.nanoseconds(1)), /** A microsecond. */
1138
- l(g, "MICROSECOND", g.microseconds(1)), /** A millisecond. */
1139
- l(g, "MILLISECOND", g.milliseconds(1)), /** A second. */
1140
- l(g, "SECOND", g.seconds(1)), /** A minute. */
1141
- l(g, "MINUTE", g.minutes(1)), /** Represents an hour. */
1142
- l(g, "HOUR", g.hours(1)), /** Represents a day. */
1143
- l(g, "DAY", g.days(1)), /** The maximum possible value for a TimeSpan. */
1144
- l(g, "MAX", new g((1n << 63n) - 1n)), /** The minimum possible value for a TimeSpan. */
1145
- l(g, "MIN", new g(0)), /** The zero value for a TimeSpan. */
1146
- l(g, "ZERO", new g(0)), /** A zod schema for validating and transforming timespans */
1147
- l(g, "z", i.union([
1148
- i.object({ value: i.bigint() }).transform((t) => new g(t.value)),
1149
- i.string().transform((t) => new g(BigInt(t))),
1150
- i.instanceof(Number).transform((t) => new g(t)),
1151
- i.number().transform((t) => new g(t)),
1152
- i.instanceof(g)
847
+ u(g, "NANOSECOND", g.nanoseconds(1)), /** A microsecond. */
848
+ u(g, "MICROSECOND", g.microseconds(1)), /** A millisecond. */
849
+ u(g, "MILLISECOND", g.milliseconds(1)), /** A second. */
850
+ u(g, "SECOND", g.seconds(1)), /** A minute. */
851
+ u(g, "MINUTE", g.minutes(1)), /** Represents an hour. */
852
+ u(g, "HOUR", g.hours(1)), /** Represents a day. */
853
+ u(g, "DAY", g.days(1)), /** The maximum possible value for a TimeSpan. */
854
+ u(g, "MAX", new g((1n << 63n) - 1n)), /** The minimum possible value for a TimeSpan. */
855
+ u(g, "MIN", new g(0)), /** The zero value for a TimeSpan. */
856
+ u(g, "ZERO", new g(0)), /** A zod schema for validating and transforming timespans */
857
+ u(g, "z", s.union([
858
+ s.object({ value: s.bigint() }).transform((r) => new g(r.value)),
859
+ s.string().transform((r) => new g(BigInt(r))),
860
+ s.instanceof(Number).transform((r) => new g(r)),
861
+ s.number().transform((r) => new g(r)),
862
+ s.instanceof(g)
1153
863
  ]));
1154
- let T = g;
1155
- const X = class ne extends Number {
864
+ let I = g;
865
+ const z = class V extends Number {
1156
866
  constructor(e) {
1157
867
  e instanceof Number ? super(e.valueOf()) : super(e);
1158
868
  }
@@ -1162,7 +872,7 @@ const X = class ne extends Number {
1162
872
  }
1163
873
  /** @returns The number of seconds in the Rate. */
1164
874
  equals(e) {
1165
- return this.valueOf() === new ne(e).valueOf();
875
+ return this.valueOf() === new V(e).valueOf();
1166
876
  }
1167
877
  /**
1168
878
  * Calculates the period of the Rate as a TimeSpan.
@@ -1170,7 +880,7 @@ const X = class ne extends Number {
1170
880
  * @returns A TimeSpan representing the period of the Rate.
1171
881
  */
1172
882
  get period() {
1173
- return T.seconds(1 / this.valueOf());
883
+ return I.seconds(1 / this.valueOf());
1174
884
  }
1175
885
  /**
1176
886
  * Calculates the number of samples in the given TimeSpan at this rate.
@@ -1179,7 +889,7 @@ const X = class ne extends Number {
1179
889
  * @returns The number of samples in the given TimeSpan at this rate.
1180
890
  */
1181
891
  sampleCount(e) {
1182
- return new T(e).seconds * this.valueOf();
892
+ return new I(e).seconds * this.valueOf();
1183
893
  }
1184
894
  /**
1185
895
  * Calculates the number of bytes in the given TimeSpan at this rate.
@@ -1188,8 +898,8 @@ const X = class ne extends Number {
1188
898
  * @param density - The density of the data in bytes per sample.
1189
899
  * @returns The number of bytes in the given TimeSpan at this rate.
1190
900
  */
1191
- byteCount(e, r) {
1192
- return this.sampleCount(e) * new I(r).valueOf();
901
+ byteCount(e, t) {
902
+ return this.sampleCount(e) * new N(t).valueOf();
1193
903
  }
1194
904
  /**
1195
905
  * Calculates a TimeSpan given the number of samples at this rate.
@@ -1198,7 +908,7 @@ const X = class ne extends Number {
1198
908
  * @returns A TimeSpan that corresponds to the given number of samples.
1199
909
  */
1200
910
  span(e) {
1201
- return T.seconds(e / this.valueOf());
911
+ return I.seconds(e / this.valueOf());
1202
912
  }
1203
913
  /**
1204
914
  * Calculates a TimeSpan given the number of bytes at this rate.
@@ -1207,8 +917,8 @@ const X = class ne extends Number {
1207
917
  * @param density - The density of the data in bytes per sample.
1208
918
  * @returns A TimeSpan that corresponds to the given number of bytes.
1209
919
  */
1210
- byteSpan(e, r) {
1211
- return this.span(e.valueOf() / r.valueOf());
920
+ byteSpan(e, t) {
921
+ return this.span(e.valueOf() / t.valueOf());
1212
922
  }
1213
923
  /**
1214
924
  * Creates a Rate representing the given number of Hz.
@@ -1217,7 +927,7 @@ const X = class ne extends Number {
1217
927
  * @returns A Rate representing the given number of Hz.
1218
928
  */
1219
929
  static hz(e) {
1220
- return new ne(e);
930
+ return new V(e);
1221
931
  }
1222
932
  /**
1223
933
  * Creates a Rate representing the given number of kHz.
@@ -1226,13 +936,13 @@ const X = class ne extends Number {
1226
936
  * @returns A Rate representing the given number of kHz.
1227
937
  */
1228
938
  static khz(e) {
1229
- return ne.hz(e * 1e3);
939
+ return V.hz(e * 1e3);
1230
940
  }
1231
941
  };
1232
- l(X, "z", i.union([
1233
- i.number().transform((t) => new X(t)),
1234
- i.instanceof(Number).transform((t) => new X(t)),
1235
- i.instanceof(X)
942
+ u(z, "z", s.union([
943
+ s.number().transform((r) => new z(r)),
944
+ s.instanceof(Number).transform((r) => new z(r)),
945
+ s.instanceof(z)
1236
946
  ]));
1237
947
  const b = class extends Number {
1238
948
  /**
@@ -1249,34 +959,34 @@ const b = class extends Number {
1249
959
  return e.valueOf() / this.valueOf();
1250
960
  }
1251
961
  size(e) {
1252
- return new kr(e * this.valueOf());
962
+ return new Bt(e * this.valueOf());
1253
963
  }
1254
964
  };
1255
- l(b, "UNKNOWN", new b(0)), /** 128 bits per value. */
1256
- l(b, "BIT128", new b(16)), /** 64 bits per value. */
1257
- l(b, "BIT64", new b(8)), /** 32 bits per value. */
1258
- l(b, "BIT32", new b(4)), /** 16 bits per value. */
1259
- l(b, "BIT16", new b(2)), /** 8 bits per value. */
1260
- l(b, "BIT8", new b(1)), /** A zod schema for validating and transforming densities */
1261
- l(b, "z", i.union([
1262
- i.number().transform((t) => new b(t)),
1263
- i.instanceof(Number).transform((t) => new b(t)),
1264
- i.instanceof(b)
965
+ u(b, "UNKNOWN", new b(0)), /** 128 bits per value. */
966
+ u(b, "BIT128", new b(16)), /** 64 bits per value. */
967
+ u(b, "BIT64", new b(8)), /** 32 bits per value. */
968
+ u(b, "BIT32", new b(4)), /** 16 bits per value. */
969
+ u(b, "BIT16", new b(2)), /** 8 bits per value. */
970
+ u(b, "BIT8", new b(1)), /** A zod schema for validating and transforming densities */
971
+ u(b, "z", s.union([
972
+ s.number().transform((r) => new b(r)),
973
+ s.instanceof(Number).transform((r) => new b(r)),
974
+ s.instanceof(b)
1265
975
  ]));
1266
- let I = b;
1267
- const U = class se {
976
+ let N = b;
977
+ const x = class H {
1268
978
  /**
1269
979
  * Creates a TimeRange from the given start and end TimeStamps.
1270
980
  *
1271
981
  * @param start - A TimeStamp representing the start of the range.
1272
982
  * @param end - A TimeStamp representing the end of the range.
1273
983
  */
1274
- constructor(e, r) {
1275
- l(this, "start"), l(this, "end"), typeof e == "object" && "start" in e ? (this.start = new m(e.start), this.end = new m(e.end)) : (this.start = new m(e), this.end = new m(r));
984
+ constructor(e, t) {
985
+ u(this, "start"), u(this, "end"), typeof e == "object" && "start" in e ? (this.start = new T(e.start), this.end = new T(e.end)) : (this.start = new T(e), this.end = new T(t));
1276
986
  }
1277
987
  /** @returns The TimeSpan occupied by the TimeRange. */
1278
988
  get span() {
1279
- return new T(this.end.valueOf() - this.start.valueOf());
989
+ return new I(this.end.valueOf() - this.start.valueOf());
1280
990
  }
1281
991
  /**
1282
992
  * Checks if the timestamp is valid i.e. the start is before the end.
@@ -1308,7 +1018,7 @@ const U = class se {
1308
1018
  * @returns A TimeRange with the start and end swapped.
1309
1019
  */
1310
1020
  swap() {
1311
- return new se(this.end, this.start);
1021
+ return new H(this.end, this.start);
1312
1022
  }
1313
1023
  /**
1314
1024
  * Checks if the TimeRange is equal to the given TimeRange.
@@ -1333,55 +1043,53 @@ const U = class se {
1333
1043
  * @param other - The other TimeRange to compare to.
1334
1044
  * @returns True if the two TimeRanges overlap, false otherwise.
1335
1045
  */
1336
- overlapsWith(e, r = T.ZERO) {
1046
+ overlapsWith(e, t = I.ZERO) {
1337
1047
  e = e.makeValid();
1338
1048
  const n = this.makeValid();
1339
- if (this.equals(e))
1340
- return !0;
1341
- if (e.end.equals(n.start) || n.end.equals(e.start))
1342
- return !1;
1343
- const s = m.max(n.start, e.start), a = m.min(n.end, e.end);
1344
- return a.before(s) ? !1 : new T(a.sub(s)).greaterThanOrEqual(r);
1049
+ if (this.equals(e)) return !0;
1050
+ if (e.end.equals(n.start) || n.end.equals(e.start)) return !1;
1051
+ const i = T.max(n.start, e.start), a = T.min(n.end, e.end);
1052
+ return a.before(i) ? !1 : new I(a.sub(i)).greaterThanOrEqual(t);
1345
1053
  }
1346
- roughlyEquals(e, r) {
1347
- let n = this.start.sub(e.start).valueOf(), s = this.end.sub(e.end).valueOf();
1348
- return n < 0 && (n = -n), s < 0 && (s = -s), n <= r.valueOf() && s <= r.valueOf();
1054
+ roughlyEquals(e, t) {
1055
+ let n = this.start.sub(e.start).valueOf(), i = this.end.sub(e.end).valueOf();
1056
+ return n < 0 && (n = -n), i < 0 && (i = -i), n <= t.valueOf() && i <= t.valueOf();
1349
1057
  }
1350
1058
  contains(e) {
1351
- return e instanceof se ? this.contains(e.start) && this.contains(e.end) : this.start.beforeEq(e) && this.end.after(e);
1059
+ return e instanceof H ? this.contains(e.start) && this.contains(e.end) : this.start.beforeEq(e) && this.end.after(e);
1352
1060
  }
1353
1061
  boundBy(e) {
1354
- const r = new se(this.start, this.end);
1355
- return e.start.after(this.start) && (r.start = e.start), e.start.after(this.end) && (r.end = e.start), e.end.before(this.end) && (r.end = e.end), e.end.before(this.start) && (r.start = e.end), r;
1062
+ const t = new H(this.start, this.end);
1063
+ 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;
1356
1064
  }
1357
1065
  };
1358
- l(U, "MAX", new U(m.MIN, m.MAX)), /** The minimum possible time range. */
1359
- l(U, "MIN", new U(m.MAX, m.MIN)), /** A zero time range. */
1360
- l(U, "ZERO", new U(m.ZERO, m.ZERO)), /** A zod schema for validating and transforming time ranges */
1361
- l(U, "z", i.union([
1362
- i.object({ start: m.z, end: m.z }).transform((t) => new U(t.start, t.end)),
1363
- i.instanceof(U)
1066
+ u(x, "MAX", new x(T.MIN, T.MAX)), /** The minimum possible time range. */
1067
+ u(x, "MIN", new x(T.MAX, T.MIN)), /** A zero time range. */
1068
+ u(x, "ZERO", new x(T.ZERO, T.ZERO)), /** A zod schema for validating and transforming time ranges */
1069
+ u(x, "z", s.union([
1070
+ s.object({ start: T.z, end: T.z }).transform((r) => new x(r.start, r.end)),
1071
+ s.instanceof(x)
1364
1072
  ]));
1365
- let Br = U;
1366
- const o = class x extends String {
1073
+ let Ct = x;
1074
+ const o = class $ extends String {
1367
1075
  constructor(e) {
1368
- if (e instanceof x || typeof e == "string" || typeof e.valueOf() == "string") {
1076
+ if (e instanceof $ || typeof e == "string" || typeof e.valueOf() == "string") {
1369
1077
  super(e.valueOf());
1370
1078
  return;
1371
1079
  } else {
1372
- const r = x.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);
1373
- if (r != null) {
1374
- super(r.valueOf());
1080
+ const t = $.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);
1081
+ if (t != null) {
1082
+ super(t.valueOf());
1375
1083
  return;
1376
1084
  }
1377
1085
  }
1378
- throw super(x.UNKNOWN.valueOf()), new Error(`unable to find data type for ${e.toString()}`);
1086
+ throw super($.UNKNOWN.valueOf()), new Error(`unable to find data type for ${e.toString()}`);
1379
1087
  }
1380
1088
  /**
1381
1089
  * @returns the TypedArray constructor for the DataType.
1382
1090
  */
1383
1091
  get Array() {
1384
- const e = x.ARRAY_CONSTRUCTORS.get(this.toString());
1092
+ const e = $.ARRAY_CONSTRUCTORS.get(this.toString());
1385
1093
  if (e == null)
1386
1094
  throw new Error(`unable to find array constructor for ${this.valueOf()}`);
1387
1095
  return e;
@@ -1394,10 +1102,10 @@ const o = class x extends String {
1394
1102
  return this.valueOf();
1395
1103
  }
1396
1104
  get isVariable() {
1397
- return this.equals(x.JSON) || this.equals(x.STRING);
1105
+ return this.equals($.JSON) || this.equals($.STRING);
1398
1106
  }
1399
1107
  get isNumeric() {
1400
- return !this.isVariable && !this.equals(x.UUID);
1108
+ return !this.isVariable && !this.equals($.UUID);
1401
1109
  }
1402
1110
  get isInteger() {
1403
1111
  return this.toString().startsWith("int");
@@ -1406,9 +1114,8 @@ const o = class x extends String {
1406
1114
  return this.toString().startsWith("float");
1407
1115
  }
1408
1116
  get density() {
1409
- const e = x.DENSITIES.get(this.toString());
1410
- if (e == null)
1411
- throw new Error(`unable to find density for ${this.valueOf()}`);
1117
+ const e = $.DENSITIES.get(this.toString());
1118
+ if (e == null) throw new Error(`unable to find density for ${this.valueOf()}`);
1412
1119
  return e;
1413
1120
  }
1414
1121
  /** @returns true if the data type can be cast to the other data type without loss of precision. */
@@ -1432,27 +1139,27 @@ const o = class x extends String {
1432
1139
  return this.toString();
1433
1140
  }
1434
1141
  get usesBigInt() {
1435
- return x.BIG_INT_TYPES.some((e) => e.equals(this));
1142
+ return $.BIG_INT_TYPES.some((e) => e.equals(this));
1436
1143
  }
1437
1144
  };
1438
- l(o, "UNKNOWN", new o("unknown")), /** Represents a 64-bit floating point value. */
1439
- l(o, "FLOAT64", new o("float64")), /** Represents a 32-bit floating point value. */
1440
- l(o, "FLOAT32", new o("float32")), /** Represents a 64-bit signed integer value. */
1441
- l(o, "INT64", new o("int64")), /** Represents a 32-bit signed integer value. */
1442
- l(o, "INT32", new o("int32")), /** Represents a 16-bit signed integer value. */
1443
- l(o, "INT16", new o("int16")), /** Represents a 8-bit signed integer value. */
1444
- l(o, "INT8", new o("int8")), /** Represents a 64-bit unsigned integer value. */
1445
- l(o, "UINT64", new o("uint64")), /** Represents a 32-bit unsigned integer value. */
1446
- l(o, "UINT32", new o("uint32")), /** Represents a 16-bit unsigned integer value. */
1447
- l(o, "UINT16", new o("uint16")), /** Represents a 8-bit unsigned integer value. */
1448
- l(o, "UINT8", new o("uint8")), /** Represents a boolean value. Alias for UINT8. */
1449
- l(o, "BOOLEAN", o.UINT8), /** Represents a 64-bit unix epoch. */
1450
- l(o, "TIMESTAMP", new o("timestamp")), /** Represents a UUID data type */
1451
- l(o, "UUID", new o("uuid")), /** Represents a string data type. Strings have an unknown density, and are separate
1145
+ u(o, "UNKNOWN", new o("unknown")), /** Represents a 64-bit floating point value. */
1146
+ u(o, "FLOAT64", new o("float64")), /** Represents a 32-bit floating point value. */
1147
+ u(o, "FLOAT32", new o("float32")), /** Represents a 64-bit signed integer value. */
1148
+ u(o, "INT64", new o("int64")), /** Represents a 32-bit signed integer value. */
1149
+ u(o, "INT32", new o("int32")), /** Represents a 16-bit signed integer value. */
1150
+ u(o, "INT16", new o("int16")), /** Represents a 8-bit signed integer value. */
1151
+ u(o, "INT8", new o("int8")), /** Represents a 64-bit unsigned integer value. */
1152
+ u(o, "UINT64", new o("uint64")), /** Represents a 32-bit unsigned integer value. */
1153
+ u(o, "UINT32", new o("uint32")), /** Represents a 16-bit unsigned integer value. */
1154
+ u(o, "UINT16", new o("uint16")), /** Represents a 8-bit unsigned integer value. */
1155
+ u(o, "UINT8", new o("uint8")), /** Represents a boolean value. Alias for UINT8. */
1156
+ u(o, "BOOLEAN", o.UINT8), /** Represents a 64-bit unix epoch. */
1157
+ u(o, "TIMESTAMP", new o("timestamp")), /** Represents a UUID data type */
1158
+ u(o, "UUID", new o("uuid")), /** Represents a string data type. Strings have an unknown density, and are separate
1452
1159
  * by a newline character. */
1453
- l(o, "STRING", new o("string")), /** Represents a JSON data type. JSON has an unknown density, and is separated by a
1160
+ u(o, "STRING", new o("string")), /** Represents a JSON data type. JSON has an unknown density, and is separated by a
1454
1161
  * newline character. */
1455
- l(o, "JSON", new o("json")), l(o, "ARRAY_CONSTRUCTORS", /* @__PURE__ */ new Map([
1162
+ u(o, "JSON", new o("json")), u(o, "ARRAY_CONSTRUCTORS", /* @__PURE__ */ new Map([
1456
1163
  [o.UINT8.toString(), Uint8Array],
1457
1164
  [o.UINT16.toString(), Uint16Array],
1458
1165
  [o.UINT32.toString(), Uint32Array],
@@ -1467,7 +1174,7 @@ l(o, "JSON", new o("json")), l(o, "ARRAY_CONSTRUCTORS", /* @__PURE__ */ new Map(
1467
1174
  [o.STRING.toString(), Uint8Array],
1468
1175
  [o.JSON.toString(), Uint8Array],
1469
1176
  [o.UUID.toString(), Uint8Array]
1470
- ])), l(o, "ARRAY_CONSTRUCTOR_DATA_TYPES", /* @__PURE__ */ new Map([
1177
+ ])), u(o, "ARRAY_CONSTRUCTOR_DATA_TYPES", /* @__PURE__ */ new Map([
1471
1178
  [Uint8Array.name, o.UINT8],
1472
1179
  [Uint16Array.name, o.UINT16],
1473
1180
  [Uint32Array.name, o.UINT32],
@@ -1478,23 +1185,23 @@ l(o, "JSON", new o("json")), l(o, "ARRAY_CONSTRUCTORS", /* @__PURE__ */ new Map(
1478
1185
  [Int16Array.name, o.INT16],
1479
1186
  [Int32Array.name, o.INT32],
1480
1187
  [BigInt64Array.name, o.INT64]
1481
- ])), l(o, "DENSITIES", /* @__PURE__ */ new Map([
1482
- [o.UINT8.toString(), I.BIT8],
1483
- [o.UINT16.toString(), I.BIT16],
1484
- [o.UINT32.toString(), I.BIT32],
1485
- [o.UINT64.toString(), I.BIT64],
1486
- [o.FLOAT32.toString(), I.BIT32],
1487
- [o.FLOAT64.toString(), I.BIT64],
1488
- [o.INT8.toString(), I.BIT8],
1489
- [o.INT16.toString(), I.BIT16],
1490
- [o.INT32.toString(), I.BIT32],
1491
- [o.INT64.toString(), I.BIT64],
1492
- [o.TIMESTAMP.toString(), I.BIT64],
1493
- [o.STRING.toString(), I.UNKNOWN],
1494
- [o.JSON.toString(), I.UNKNOWN],
1495
- [o.UUID.toString(), I.BIT128]
1188
+ ])), u(o, "DENSITIES", /* @__PURE__ */ new Map([
1189
+ [o.UINT8.toString(), N.BIT8],
1190
+ [o.UINT16.toString(), N.BIT16],
1191
+ [o.UINT32.toString(), N.BIT32],
1192
+ [o.UINT64.toString(), N.BIT64],
1193
+ [o.FLOAT32.toString(), N.BIT32],
1194
+ [o.FLOAT64.toString(), N.BIT64],
1195
+ [o.INT8.toString(), N.BIT8],
1196
+ [o.INT16.toString(), N.BIT16],
1197
+ [o.INT32.toString(), N.BIT32],
1198
+ [o.INT64.toString(), N.BIT64],
1199
+ [o.TIMESTAMP.toString(), N.BIT64],
1200
+ [o.STRING.toString(), N.UNKNOWN],
1201
+ [o.JSON.toString(), N.UNKNOWN],
1202
+ [o.UUID.toString(), N.BIT128]
1496
1203
  ])), /** All the data types. */
1497
- l(o, "ALL", [
1204
+ u(o, "ALL", [
1498
1205
  o.UNKNOWN,
1499
1206
  o.FLOAT64,
1500
1207
  o.FLOAT32,
@@ -1510,12 +1217,12 @@ l(o, "ALL", [
1510
1217
  o.UUID,
1511
1218
  o.STRING,
1512
1219
  o.JSON
1513
- ]), l(o, "BIG_INT_TYPES", [o.INT64, o.UINT64, o.TIMESTAMP]), /** A zod schema for a DataType. */
1514
- l(o, "z", i.union([
1515
- i.string().transform((t) => new o(t)),
1516
- i.instanceof(o)
1220
+ ]), u(o, "BIG_INT_TYPES", [o.INT64, o.UINT64, o.TIMESTAMP]), /** A zod schema for a DataType. */
1221
+ u(o, "z", s.union([
1222
+ s.string().transform((r) => new o(r)),
1223
+ s.instanceof(o)
1517
1224
  ]));
1518
- const S = class w extends Number {
1225
+ const S = class O extends Number {
1519
1226
  constructor(e) {
1520
1227
  super(e.valueOf());
1521
1228
  }
@@ -1528,33 +1235,33 @@ const S = class w extends Number {
1528
1235
  return this.valueOf() < e.valueOf();
1529
1236
  }
1530
1237
  add(e) {
1531
- return w.bytes(this.valueOf() + e.valueOf());
1238
+ return O.bytes(this.valueOf() + e.valueOf());
1532
1239
  }
1533
1240
  sub(e) {
1534
- return w.bytes(this.valueOf() - e.valueOf());
1241
+ return O.bytes(this.valueOf() - e.valueOf());
1535
1242
  }
1536
1243
  truncate(e) {
1537
- return new w(Math.trunc(this.valueOf() / e.valueOf()) * e.valueOf());
1244
+ return new O(Math.trunc(this.valueOf() / e.valueOf()) * e.valueOf());
1538
1245
  }
1539
1246
  remainder(e) {
1540
- return w.bytes(this.valueOf() % e.valueOf());
1247
+ return O.bytes(this.valueOf() % e.valueOf());
1541
1248
  }
1542
1249
  get gigabytes() {
1543
- return this.valueOf() / w.GIGABYTE.valueOf();
1250
+ return this.valueOf() / O.GIGABYTE.valueOf();
1544
1251
  }
1545
1252
  get megabytes() {
1546
- return this.valueOf() / w.MEGABYTE.valueOf();
1253
+ return this.valueOf() / O.MEGABYTE.valueOf();
1547
1254
  }
1548
1255
  get kilobytes() {
1549
- return this.valueOf() / w.KILOBYTE.valueOf();
1256
+ return this.valueOf() / O.KILOBYTE.valueOf();
1550
1257
  }
1551
1258
  get terabytes() {
1552
- return this.valueOf() / w.TERABYTE.valueOf();
1259
+ return this.valueOf() / O.TERABYTE.valueOf();
1553
1260
  }
1554
1261
  toString() {
1555
- const e = this.truncate(w.TERABYTE), r = this.truncate(w.GIGABYTE), n = this.truncate(w.MEGABYTE), s = this.truncate(w.KILOBYTE), a = this.truncate(w.BYTE), u = e, c = r.sub(e), h = n.sub(r), E = s.sub(n), A = a.sub(s);
1556
- let O = "";
1557
- return u.isZero || (O += `${u.terabytes}TB `), c.isZero || (O += `${c.gigabytes}GB `), h.isZero || (O += `${h.megabytes}MB `), E.isZero || (O += `${E.kilobytes}KB `), (!A.isZero || O === "") && (O += `${A.valueOf()}B`), O.trim();
1262
+ const e = this.truncate(O.TERABYTE), t = this.truncate(O.GIGABYTE), n = this.truncate(O.MEGABYTE), i = this.truncate(O.KILOBYTE), a = this.truncate(O.BYTE), c = e, h = t.sub(e), p = n.sub(t), m = i.sub(n), v = a.sub(i);
1263
+ let w = "";
1264
+ return c.isZero || (w += `${c.terabytes}TB `), h.isZero || (w += `${h.gigabytes}GB `), p.isZero || (w += `${p.megabytes}MB `), m.isZero || (w += `${m.kilobytes}KB `), (!v.isZero || w === "") && (w += `${v.valueOf()}B`), w.trim();
1558
1265
  }
1559
1266
  /**
1560
1267
  * Creates a Size from the given number of bytes.
@@ -1563,7 +1270,7 @@ const S = class w extends Number {
1563
1270
  * @returns A Size representing the given number of bytes.
1564
1271
  */
1565
1272
  static bytes(e = 1) {
1566
- return new w(e);
1273
+ return new O(e);
1567
1274
  }
1568
1275
  /**
1569
1276
  * Creates a Size from the given number if kilobytes.
@@ -1572,7 +1279,7 @@ const S = class w extends Number {
1572
1279
  * @returns A Size representing the given number of kilobytes.
1573
1280
  */
1574
1281
  static kilobytes(e = 1) {
1575
- return w.bytes(e.valueOf() * 1e3);
1282
+ return O.bytes(e.valueOf() * 1e3);
1576
1283
  }
1577
1284
  /**
1578
1285
  * Creates a Size from the given number of megabytes.
@@ -1581,7 +1288,7 @@ const S = class w extends Number {
1581
1288
  * @returns A Size representing the given number of megabytes.
1582
1289
  */
1583
1290
  static megabytes(e = 1) {
1584
- return w.kilobytes(e.valueOf() * 1e3);
1291
+ return O.kilobytes(e.valueOf() * 1e3);
1585
1292
  }
1586
1293
  /**
1587
1294
  * Creates a Size from the given number of gigabytes.
@@ -1590,7 +1297,7 @@ const S = class w extends Number {
1590
1297
  * @returns A Size representing the given number of gigabytes.
1591
1298
  */
1592
1299
  static gigabytes(e = 1) {
1593
- return w.megabytes(e.valueOf() * 1e3);
1300
+ return O.megabytes(e.valueOf() * 1e3);
1594
1301
  }
1595
1302
  /**
1596
1303
  * Creates a Size from the given number of terabytes.
@@ -1599,45 +1306,68 @@ const S = class w extends Number {
1599
1306
  * @returns A Size representing the given number of terabytes.
1600
1307
  */
1601
1308
  static terabytes(e) {
1602
- return w.gigabytes(e.valueOf() * 1e3);
1309
+ return O.gigabytes(e.valueOf() * 1e3);
1603
1310
  }
1604
1311
  get isZero() {
1605
1312
  return this.valueOf() === 0;
1606
1313
  }
1607
1314
  };
1608
- l(S, "BYTE", new S(1)), /** A kilobyte */
1609
- l(S, "KILOBYTE", S.kilobytes(1)), /** A megabyte */
1610
- l(S, "MEGABYTE", S.megabytes(1)), /** A gigabyte */
1611
- l(S, "GIGABYTE", S.gigabytes(1)), /** A terabyte. */
1612
- l(S, "TERABYTE", S.terabytes(1)), /** The zero value for Size */
1613
- l(S, "ZERO", new S(0)), /** A zod schema for a Size. */
1614
- l(S, "z", i.union([
1615
- i.number().transform((t) => new S(t)),
1616
- i.instanceof(S)
1315
+ u(S, "BYTE", new S(1)), /** A kilobyte */
1316
+ u(S, "KILOBYTE", S.kilobytes(1)), /** A megabyte */
1317
+ u(S, "MEGABYTE", S.megabytes(1)), /** A gigabyte */
1318
+ u(S, "GIGABYTE", S.gigabytes(1)), /** A terabyte. */
1319
+ u(S, "TERABYTE", S.terabytes(1)), /** The zero value for Size */
1320
+ u(S, "ZERO", new S(0)), /** A zod schema for a Size. */
1321
+ u(S, "z", s.union([
1322
+ s.number().transform((r) => new S(r)),
1323
+ s.instanceof(S)
1617
1324
  ]));
1618
- let kr = S;
1619
- i.union([
1620
- i.instanceof(Uint8Array),
1621
- i.instanceof(Uint16Array),
1622
- i.instanceof(Uint32Array),
1623
- i.instanceof(BigUint64Array),
1624
- i.instanceof(Float32Array),
1625
- i.instanceof(Float64Array),
1626
- i.instanceof(Int8Array),
1627
- i.instanceof(Int16Array),
1628
- i.instanceof(Int32Array),
1629
- i.instanceof(BigInt64Array)
1325
+ let Bt = S;
1326
+ s.union([
1327
+ s.instanceof(Uint8Array),
1328
+ s.instanceof(Uint16Array),
1329
+ s.instanceof(Uint32Array),
1330
+ s.instanceof(BigUint64Array),
1331
+ s.instanceof(Float32Array),
1332
+ s.instanceof(Float64Array),
1333
+ s.instanceof(Int8Array),
1334
+ s.instanceof(Int16Array),
1335
+ s.instanceof(Int32Array),
1336
+ s.instanceof(BigInt64Array)
1630
1337
  ]);
1631
- var Lr = Object.defineProperty, Pr = (t, e, r) => e in t ? Lr(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, G = (t, e, r) => (Pr(t, typeof e != "symbol" ? e + "" : e, r), r);
1632
- const Zr = (...t) => t.map(At).join(""), At = (t) => (t.endsWith("/") || (t += "/"), t.startsWith("/") && (t = t.slice(1)), t), zr = (t) => t.endsWith("/") ? t.slice(0, -1) : t, Yr = (t, e = "") => t === null ? "" : "?" + Object.entries(t).filter(([, r]) => r == null ? !1 : Array.isArray(r) ? r.length > 0 : !0).map(([r, n]) => `${e}${r}=${n}`).join("&"), Te = class Se {
1338
+ s.record(
1339
+ s.union([s.number(), s.string(), s.symbol()]),
1340
+ s.unknown()
1341
+ );
1342
+ const Ye = () => typeof process < "u" && process.versions != null && process.versions.node != null ? "node" : typeof window > "u" || window.document === void 0 ? "webworker" : "browser", Rt = Ye(), Le = ["MacOS", "Windows", "Linux", "Docker"], Dt = s.enum(Le);
1343
+ let ie;
1344
+ const Yt = () => {
1345
+ if (typeof window > "u") return;
1346
+ const r = window.navigator.userAgent.toLowerCase();
1347
+ if (r.includes("mac")) return "MacOS";
1348
+ if (r.includes("win")) return "Windows";
1349
+ if (r.includes("linux")) return "Linux";
1350
+ }, Lt = (r = {}) => {
1351
+ const { force: e, default: t } = r;
1352
+ return e ?? ie ?? (ie = Yt(), ie ?? t);
1353
+ }, Pe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1354
+ __proto__: null,
1355
+ OPERATING_SYSTEMS: Le,
1356
+ RUNTIME: Rt,
1357
+ detect: Ye,
1358
+ getOS: Lt,
1359
+ osZ: Dt
1360
+ }, Symbol.toStringTag, { value: "Module" }));
1361
+ var Pt = Object.defineProperty, jt = (r, e, t) => e in r ? Pt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, F = (r, e, t) => jt(r, typeof e != "symbol" ? e + "" : e, t);
1362
+ const kt = (...r) => r.map(je).join(""), je = (r) => (r.endsWith("/") || (r += "/"), r.startsWith("/") && (r = r.slice(1)), r), Wt = (r) => r.endsWith("/") ? r.slice(0, -1) : r, Ft = (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("&"), ue = class ce {
1633
1363
  /**
1634
1364
  * @param host - The hostname or IP address of the server.
1635
1365
  * @param port - The port number of the server.
1636
1366
  * @param protocol - The protocol to use for all requests. Defaults to "".
1637
1367
  * @param pathPrefix - A path prefix to use for all requests. Defaults to "".
1638
1368
  */
1639
- constructor({ host: e, port: r, protocol: n = "", pathPrefix: s = "" }) {
1640
- G(this, "protocol"), G(this, "host"), G(this, "port"), G(this, "path"), this.protocol = n, this.host = e, this.port = r, this.path = At(s);
1369
+ constructor({ host: e, port: t, protocol: n = "", pathPrefix: i = "" }) {
1370
+ F(this, "protocol"), F(this, "host"), F(this, "port"), F(this, "path"), this.protocol = n, this.host = e, this.port = t, this.path = je(i);
1641
1371
  }
1642
1372
  /**
1643
1373
  * Replaces creates a new URL with the specified properties replaced.
@@ -1645,7 +1375,7 @@ const Zr = (...t) => t.map(At).join(""), At = (t) => (t.endsWith("/") || (t += "
1645
1375
  * @returns a new URL.
1646
1376
  */
1647
1377
  replace(e) {
1648
- return new Se({
1378
+ return new ce({
1649
1379
  host: e.host ?? this.host,
1650
1380
  port: e.port ?? this.port,
1651
1381
  protocol: e.protocol ?? this.protocol,
@@ -1658,149 +1388,154 @@ const Zr = (...t) => t.map(At).join(""), At = (t) => (t.endsWith("/") || (t += "
1658
1388
  * @returns a new URL.
1659
1389
  */
1660
1390
  child(e) {
1661
- return new Se({
1391
+ return new ce({
1662
1392
  ...this,
1663
- pathPrefix: Zr(this.path, e)
1393
+ pathPrefix: kt(this.path, e)
1664
1394
  });
1665
1395
  }
1666
1396
  /** @returns a string representation of the url */
1667
1397
  toString() {
1668
- return zr(
1398
+ return Wt(
1669
1399
  `${this.protocol}://${this.host}:${this.port}/${this.path}`
1670
1400
  );
1671
1401
  }
1672
1402
  };
1673
- G(Te, "UNKNOWN", new Te({ host: "unknown", port: 0 }));
1674
- let Kr = Te;
1675
- var Vr = Object.defineProperty, Fr = (t, e, r) => e in t ? Vr(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, be = (t, e, r) => (Fr(t, typeof e != "symbol" ? e + "" : e, r), r);
1676
- const V = class extends Number {
1403
+ F(ue, "UNKNOWN", new ue({ host: "unknown", port: 0 }));
1404
+ let Gt = ue;
1405
+ var qt = Object.defineProperty, Zt = (r, e, t) => e in r ? qt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, K = (r, e, t) => Zt(r, typeof e != "symbol" ? e + "" : e, t);
1406
+ const Y = class extends Number {
1677
1407
  };
1678
- be(V, "Absolute", 255), be(V, "Default", 1), be(V, "z", i.union([
1679
- i.instanceof(V),
1680
- i.number().int().min(0).max(255).transform((t) => new V(t)),
1681
- i.instanceof(Number).transform((t) => new V(t))
1408
+ K(Y, "Absolute", 255), K(Y, "Default", 1), K(Y, "z", s.union([
1409
+ s.instanceof(Y),
1410
+ s.number().int().min(0).max(255).transform((r) => new Y(r)),
1411
+ s.instanceof(Number).transform((r) => new Y(r))
1682
1412
  ]));
1683
- i.object({
1684
- name: i.string(),
1685
- key: i.string()
1686
- });
1687
- const Wr = i.string().regex(/^\d+\.\d+\.\d+$/);
1688
- i.object({
1689
- version: Wr
1413
+ s.object({
1414
+ name: s.string(),
1415
+ key: s.string()
1690
1416
  });
1691
- class de extends Error {
1692
- constructor(r, n) {
1693
- super(r);
1694
- v(this, "discriminator", "FreighterError");
1695
- v(this, "type");
1696
- this.type = n;
1417
+ const ke = class G extends Error {
1418
+ constructor() {
1419
+ super(G.MESSAGE);
1420
+ }
1421
+ /** Returns true if the error or message is a cancellation error" */
1422
+ matches(e) {
1423
+ return typeof e == "string" ? e.includes(G.MESSAGE) : e instanceof G || e.message.includes(G.MESSAGE);
1424
+ }
1425
+ };
1426
+ K(ke, "MESSAGE", "canceled");
1427
+ let zt = ke;
1428
+ new zt();
1429
+ s.string().regex(/^\d+\.\d+\.\d+$/);
1430
+ const he = (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);
1431
+ class _ extends Error {
1432
+ constructor(t) {
1433
+ super(t);
1434
+ f(this, "discriminator", "FreighterError");
1435
+ f(this, "type", "");
1697
1436
  }
1698
1437
  }
1699
- const qr = (t) => {
1700
- if (t == null || typeof t != "object")
1701
- return !1;
1702
- const e = t;
1703
- if (e.discriminator !== "FreighterError")
1704
- return !1;
1438
+ const Vt = (r) => {
1439
+ if (r == null || typeof r != "object") return !1;
1440
+ const e = r;
1441
+ if (e.discriminator !== "FreighterError") return !1;
1705
1442
  if (!("type" in e))
1706
1443
  throw new Error(
1707
1444
  `Freighter error is missing its type property: ${JSON.stringify(e)}`
1708
1445
  );
1709
1446
  return !0;
1710
- }, Ae = "unknown", Ve = "nil", he = "freighter", It = i.object({ type: i.string(), data: i.string() });
1711
- class Gr {
1447
+ }, be = "unknown", Te = "nil", Ht = "freighter", We = s.object({ type: s.string(), data: s.string() });
1448
+ class Kt {
1712
1449
  constructor() {
1713
- v(this, "providers", []);
1450
+ f(this, "providers", []);
1714
1451
  }
1715
1452
  register(e) {
1716
1453
  this.providers.push(e);
1717
1454
  }
1718
1455
  encode(e) {
1719
- if (e == null)
1720
- return { type: Ve, data: "" };
1721
- if (qr(e))
1722
- for (const r of this.providers) {
1723
- const n = r.encode(e);
1724
- if (n != null)
1725
- return n;
1456
+ if (e == null) return { type: Te, data: "" };
1457
+ if (Vt(e))
1458
+ for (const t of this.providers) {
1459
+ const n = t.encode(e);
1460
+ if (n != null) return n;
1726
1461
  }
1727
- return { type: Ae, data: JSON.stringify(e) };
1462
+ return { type: be, data: JSON.stringify(e) };
1728
1463
  }
1729
1464
  decode(e) {
1730
- if (e == null || e.type === Ve)
1731
- return null;
1732
- if (e.type === Ae)
1733
- return new Fe(e.data);
1734
- for (const r of this.providers) {
1735
- const n = r.decode(e);
1736
- if (n != null)
1737
- return n;
1465
+ if (e == null || e.type === Te) return null;
1466
+ if (e.type === be) return new Ie(e.data);
1467
+ for (const t of this.providers) {
1468
+ const n = t.decode(e);
1469
+ if (n != null) return n;
1738
1470
  }
1739
- return new Fe(e.data);
1471
+ return new Ie(e.data);
1740
1472
  }
1741
1473
  }
1742
- const ke = new Gr(), Hr = ({
1743
- encode: t,
1474
+ const de = new Kt(), Xt = ({
1475
+ encode: r,
1744
1476
  decode: e
1745
- }) => ke.register({ encode: t, decode: e }), dn = (t) => ke.encode(t), Nt = (t) => ke.decode(t);
1746
- class Fe extends de {
1747
- constructor(e) {
1748
- super(e, Ae);
1477
+ }) => de.register({ encode: r, decode: e }), pr = (r) => de.encode(r), Fe = (r) => de.decode(r);
1478
+ class Ie extends _ {
1479
+ constructor(t) {
1480
+ super(t);
1481
+ f(this, "type", "unknown");
1749
1482
  }
1750
1483
  }
1751
- const pe = "freighter.";
1752
- class z extends de {
1484
+ const ee = "freighter.", L = class L extends _ {
1753
1485
  constructor() {
1754
- super("EOF", he);
1486
+ super("EOF");
1487
+ f(this, "type", L.TYPE);
1755
1488
  }
1756
- }
1757
- v(z, "TYPE", pe + "eof");
1758
- class Y extends de {
1489
+ };
1490
+ f(L, "TYPE", ee + "eof"), f(L, "matches", he(L.TYPE));
1491
+ let B = L;
1492
+ const P = class P extends _ {
1759
1493
  constructor() {
1760
- super("StreamClosed", he);
1494
+ super("StreamClosed");
1495
+ f(this, "type", P.TYPE);
1761
1496
  }
1762
- }
1763
- v(Y, "TYPE", pe + "stream_closed");
1764
- class F extends de {
1765
- constructor(r = {}) {
1766
- const { message: n = "Unreachable", url: s = Kr.UNKNOWN } = r;
1767
- super(n, he);
1768
- v(this, "url");
1769
- this.url = s;
1497
+ };
1498
+ f(P, "TYPE", ee + "stream_closed"), f(P, "matches", he(P.TYPE));
1499
+ let R = P;
1500
+ const j = class j extends _ {
1501
+ constructor(t = {}) {
1502
+ const { message: n = "Unreachable", url: i = Gt.UNKNOWN } = t;
1503
+ super(n);
1504
+ f(this, "type", j.TYPE);
1505
+ f(this, "url");
1506
+ this.url = i;
1770
1507
  }
1771
- }
1772
- v(F, "TYPE", pe + "unreachable");
1773
- const Xr = (t) => {
1774
- if (t.type !== he)
1775
- return null;
1776
- if (t instanceof z)
1777
- return { type: z.TYPE, data: "EOF" };
1778
- if (t instanceof Y)
1779
- return { type: Y.TYPE, data: "StreamClosed" };
1780
- if (t instanceof F)
1781
- return { type: F.TYPE, data: "Unreachable" };
1782
- throw new Error(`Unknown error type: ${t.type}: ${t.message}`);
1783
- }, Jr = (t) => {
1784
- if (!t.type.startsWith(pe))
1785
- return null;
1786
- switch (t.type) {
1787
- case z.TYPE:
1788
- return new z();
1789
- case Y.TYPE:
1790
- return new Y();
1791
- case F.TYPE:
1792
- return new F();
1508
+ };
1509
+ f(j, "TYPE", ee + "unreachable"), f(j, "matches", he(j.TYPE));
1510
+ let D = j;
1511
+ const Jt = (r) => {
1512
+ if (!r.type.startsWith(Ht)) return null;
1513
+ if (B.matches(r)) return { type: B.TYPE, data: "EOF" };
1514
+ if (R.matches(r))
1515
+ return { type: R.TYPE, data: "StreamClosed" };
1516
+ if (D.matches(r))
1517
+ return { type: D.TYPE, data: "Unreachable" };
1518
+ throw new Error(`Unknown error type: ${r.type}: ${r.message}`);
1519
+ }, Qt = (r) => {
1520
+ if (!r.type.startsWith(ee)) return null;
1521
+ switch (r.type) {
1522
+ case B.TYPE:
1523
+ return new B();
1524
+ case R.TYPE:
1525
+ return new R();
1526
+ case D.TYPE:
1527
+ return new D();
1793
1528
  default:
1794
- throw new Error(`Unknown error type: ${t.data}`);
1529
+ throw new Error(`Unknown error type: ${r.data}`);
1795
1530
  }
1796
1531
  };
1797
- Hr({
1798
- encode: Xr,
1799
- decode: Jr
1532
+ Xt({
1533
+ encode: Jt,
1534
+ decode: Qt
1800
1535
  });
1801
- class Et {
1536
+ class Ge {
1802
1537
  constructor() {
1803
- v(this, "middleware", []);
1538
+ f(this, "middleware", []);
1804
1539
  }
1805
1540
  /** Implements the Transport interface */
1806
1541
  use(...e) {
@@ -1815,126 +1550,117 @@ class Et {
1815
1550
  * @param finalizer - The finalizer to call with the metadata.
1816
1551
  * @returns An error if one was encountered, otherwise undefined.
1817
1552
  */
1818
- async executeMiddleware(e, r) {
1553
+ async executeMiddleware(e, t) {
1819
1554
  let n = 0;
1820
- const s = async (a) => {
1821
- if (n === this.middleware.length)
1822
- return await r(a);
1823
- const u = this.middleware[n];
1824
- return n++, await u(a, s);
1555
+ const i = async (a) => {
1556
+ if (n === this.middleware.length) return await t(a);
1557
+ const c = this.middleware[n];
1558
+ return n++, await c(a, i);
1825
1559
  };
1826
- return await s(e);
1560
+ return await i(e);
1827
1561
  }
1828
1562
  }
1829
- const Ct = "Content-Type", We = (t) => {
1830
- if (Tt.RUNTIME !== "node")
1831
- return fetch;
1563
+ const qe = "Content-Type", Se = (r) => {
1564
+ if (Pe.RUNTIME !== "node") return fetch;
1832
1565
  const e = require("node-fetch");
1833
- if (t === "http")
1834
- return e;
1835
- const r = require("https"), n = new r.Agent({ rejectUnauthorized: !1 });
1836
- return async (s, a) => await e(s, { ...a, agent: n });
1566
+ if (r === "http") return e;
1567
+ const t = require("https"), n = new t.Agent({ rejectUnauthorized: !1 });
1568
+ return async (i, a) => await e(i, { ...a, agent: n });
1837
1569
  };
1838
- class hn extends Et {
1839
- constructor(r, n, s = !1) {
1570
+ class yr extends Ge {
1571
+ constructor(t, n, i = !1) {
1840
1572
  super();
1841
- v(this, "endpoint");
1842
- v(this, "encoder");
1843
- v(this, "fetch");
1844
- return this.endpoint = r.replace({ protocol: s ? "https" : "http" }), this.encoder = n, this.fetch = We(this.endpoint.protocol), new Proxy(this, {
1845
- get: (a, u, c) => u === "endpoint" ? this.endpoint : Reflect.get(a, u, c)
1573
+ f(this, "endpoint");
1574
+ f(this, "encoder");
1575
+ f(this, "fetch");
1576
+ return this.endpoint = t.replace({ protocol: i ? "https" : "http" }), this.encoder = n, this.fetch = Se(this.endpoint.protocol), new Proxy(this, {
1577
+ get: (a, c, h) => c === "endpoint" ? this.endpoint : Reflect.get(a, c, h)
1846
1578
  });
1847
1579
  }
1848
1580
  get headers() {
1849
1581
  return {
1850
- [Ct]: this.encoder.contentType
1582
+ [qe]: this.encoder.contentType
1851
1583
  };
1852
1584
  }
1853
- async send(r, n, s, a) {
1854
- n = s == null ? void 0 : s.parse(n);
1855
- let u = null;
1856
- const c = this.endpoint.child(r), h = {};
1857
- h.method = "POST", h.body = this.encoder.encode(n ?? {});
1858
- const [, E] = await this.executeMiddleware(
1585
+ async send(t, n, i, a) {
1586
+ n = i == null ? void 0 : i.parse(n);
1587
+ let c = null;
1588
+ const h = this.endpoint.child(t), p = {};
1589
+ p.method = "POST", p.body = this.encoder.encode(n ?? {});
1590
+ const [, m] = await this.executeMiddleware(
1859
1591
  {
1860
- target: c.toString(),
1592
+ target: h.toString(),
1861
1593
  protocol: this.endpoint.protocol,
1862
1594
  params: {},
1863
1595
  role: "client"
1864
1596
  },
1865
- async (A) => {
1866
- const O = { ...A, params: {} };
1867
- h.headers = {
1597
+ async (v) => {
1598
+ const w = { ...v, params: {} };
1599
+ p.headers = {
1868
1600
  ...this.headers,
1869
- ...A.params
1601
+ ...v.params
1870
1602
  };
1871
- let $;
1603
+ let A;
1872
1604
  try {
1873
- $ = await We(A.protocol)(A.target, h);
1874
- } catch (M) {
1875
- let N = M;
1876
- return N.message === "Load failed" && (N = new F({ url: c })), [O, N];
1605
+ A = await Se(v.protocol)(v.target, p);
1606
+ } catch (U) {
1607
+ let E = U;
1608
+ return E.message === "Load failed" && (E = new D({ url: h })), [w, E];
1877
1609
  }
1878
- const W = await $.arrayBuffer();
1879
- if ($ != null && $.ok)
1880
- return a != null && (u = this.encoder.decode(W, a)), [O, null];
1610
+ const k = await A.arrayBuffer();
1611
+ if (A != null && A.ok)
1612
+ return a != null && (c = this.encoder.decode(k, a)), [w, null];
1881
1613
  try {
1882
- if ($.status !== 400)
1883
- return [O, new Error($.statusText)];
1884
- const M = this.encoder.decode(W, It), N = Nt(M);
1885
- return [O, N];
1886
- } catch (M) {
1614
+ if (A.status !== 400) return [w, new Error(A.statusText)];
1615
+ const U = this.encoder.decode(k, We), E = Fe(U);
1616
+ return [w, E];
1617
+ } catch (U) {
1887
1618
  return [
1888
- O,
1619
+ w,
1889
1620
  new Error(
1890
- `[freighter] - failed to decode error: ${$.statusText}: ${M.message}`
1621
+ `[freighter] - failed to decode error: ${A.statusText}: ${U.message}`
1891
1622
  )
1892
1623
  ];
1893
1624
  }
1894
1625
  }
1895
1626
  );
1896
- return [u, E];
1627
+ return [c, m];
1897
1628
  }
1898
1629
  }
1899
- const pn = async (t, e, r, n, s) => {
1900
- const [a, u] = await t.send(e, r, n, s);
1901
- if (u != null)
1902
- throw u;
1630
+ const gr = async (r, e, t, n, i) => {
1631
+ const [a, c] = await r.send(e, t, n, i);
1632
+ if (c != null) throw c;
1903
1633
  return a;
1904
- }, Qr = () => Tt.RUNTIME !== "node" ? (t) => new WebSocket(t) : (t) => new (require("ws")).WebSocket(t, { rejectUnauthorized: !1 }), _r = i.object({
1905
- type: i.union([i.literal("data"), i.literal("close")]),
1906
- payload: i.unknown().optional(),
1907
- error: i.optional(It)
1634
+ }, _t = () => Pe.RUNTIME !== "node" ? (r) => new WebSocket(r) : (r) => new (require("ws")).WebSocket(r, { rejectUnauthorized: !1 }), er = s.object({
1635
+ type: s.union([s.literal("data"), s.literal("close")]),
1636
+ payload: s.unknown().optional(),
1637
+ error: s.optional(We)
1908
1638
  });
1909
- class en {
1910
- constructor(e, r, n, s) {
1911
- v(this, "encoder");
1912
- v(this, "reqSchema");
1913
- v(this, "resSchema");
1914
- v(this, "ws");
1915
- v(this, "serverClosed");
1916
- v(this, "sendClosed");
1917
- v(this, "receiveDataQueue", []);
1918
- v(this, "receiveCallbacksQueue", []);
1919
- this.encoder = r, this.reqSchema = n, this.resSchema = s, this.ws = e, this.sendClosed = !1, this.serverClosed = null, this.listenForMessages();
1639
+ class tr {
1640
+ constructor(e, t, n, i) {
1641
+ f(this, "encoder");
1642
+ f(this, "reqSchema");
1643
+ f(this, "resSchema");
1644
+ f(this, "ws");
1645
+ f(this, "serverClosed");
1646
+ f(this, "sendClosed");
1647
+ f(this, "receiveDataQueue", []);
1648
+ f(this, "receiveCallbacksQueue", []);
1649
+ this.encoder = t, this.reqSchema = n, this.resSchema = i, this.ws = e, this.sendClosed = !1, this.serverClosed = null, this.listenForMessages();
1920
1650
  }
1921
1651
  /** Implements the Stream protocol */
1922
1652
  send(e) {
1923
- if (this.serverClosed != null)
1924
- return new z();
1925
- if (this.sendClosed)
1926
- throw new Y();
1653
+ if (this.serverClosed != null) return new B();
1654
+ if (this.sendClosed) throw new R();
1927
1655
  return this.ws.send(this.encoder.encode({ type: "data", payload: e })), null;
1928
1656
  }
1929
1657
  /** Implements the Stream protocol */
1930
1658
  async receive() {
1931
- if (this.serverClosed != null)
1932
- return [null, this.serverClosed];
1659
+ if (this.serverClosed != null) return [null, this.serverClosed];
1933
1660
  const e = await this.receiveMsg();
1934
1661
  if (e.type === "close") {
1935
- if (e.error == null)
1936
- throw new Error("Message error must be defined");
1937
- return this.serverClosed = Nt(e.error), [null, this.serverClosed];
1662
+ if (e.error == null) throw new Error("Message error must be defined");
1663
+ return this.serverClosed = Fe(e.error), [null, this.serverClosed];
1938
1664
  }
1939
1665
  return [this.resSchema.parse(e.payload), null];
1940
1666
  }
@@ -1944,8 +1670,7 @@ class en {
1944
1670
  }
1945
1671
  /** Implements the Stream protocol */
1946
1672
  closeSend() {
1947
- if (this.sendClosed || this.serverClosed != null)
1948
- return;
1673
+ if (this.sendClosed || this.serverClosed != null) return;
1949
1674
  const e = { type: "close" };
1950
1675
  try {
1951
1676
  this.ws.send(this.encoder.encode(e));
@@ -1956,82 +1681,82 @@ class en {
1956
1681
  async receiveMsg() {
1957
1682
  const e = this.receiveDataQueue.shift();
1958
1683
  return e ?? await new Promise(
1959
- (r, n) => this.receiveCallbacksQueue.push({ resolve: r, reject: n })
1684
+ (t, n) => this.receiveCallbacksQueue.push({ resolve: t, reject: n })
1960
1685
  );
1961
1686
  }
1962
1687
  addMessage(e) {
1963
- const r = this.receiveCallbacksQueue.shift();
1964
- r != null ? r.resolve(e) : this.receiveDataQueue.push(e);
1688
+ const t = this.receiveCallbacksQueue.shift();
1689
+ t != null ? t.resolve(e) : this.receiveDataQueue.push(e);
1965
1690
  }
1966
1691
  listenForMessages() {
1967
- this.ws.onmessage = (e) => this.addMessage(this.encoder.decode(e.data, _r)), this.ws.onclose = (e) => this.addMessage({
1692
+ this.ws.onmessage = (e) => this.addMessage(this.encoder.decode(e.data, er)), this.ws.onclose = (e) => this.addMessage({
1968
1693
  type: "close",
1969
- error: { type: an(e) ? z.TYPE : Y.TYPE, data: "" }
1694
+ error: { type: or(e) ? B.TYPE : R.TYPE, data: "" }
1970
1695
  });
1971
1696
  }
1972
1697
  }
1973
- const tn = "freighterctx", rn = 1e3, nn = 1001, sn = [rn, nn], an = (t) => sn.includes(t.code), ae = class ae extends Et {
1698
+ const rr = "freighterctx", nr = 1e3, sr = 1001, ir = [nr, sr], or = (r) => ir.includes(r.code), J = class J extends Ge {
1974
1699
  /**
1975
1700
  * @param encoder - The encoder to use for encoding messages and decoding
1976
1701
  * responses.
1977
1702
  * @param baseEndpoint - A base url to use as a prefix for all requests.
1978
1703
  */
1979
- constructor(r, n, s = !1) {
1704
+ constructor(t, n, i = !1) {
1980
1705
  super();
1981
- v(this, "baseUrl");
1982
- v(this, "encoder");
1983
- this.baseUrl = r.replace({ protocol: s ? "wss" : "ws" }), this.encoder = n;
1706
+ f(this, "baseUrl");
1707
+ f(this, "encoder");
1708
+ this.baseUrl = t.replace({ protocol: i ? "wss" : "ws" }), this.encoder = n;
1984
1709
  }
1985
1710
  /** Implements the StreamClient interface. */
1986
- async stream(r, n, s) {
1987
- const a = Qr();
1988
- let u;
1989
- const [, c] = await this.executeMiddleware(
1990
- { target: r, protocol: "websocket", params: {}, role: "client" },
1991
- async (h) => {
1992
- const E = a(this.buildURL(r, h)), A = { ...h, params: {} };
1993
- E.binaryType = ae.MESSAGE_TYPE;
1994
- const O = await this.wrapSocket(E, n, s);
1995
- return O instanceof Error ? [A, O] : (u = O, [A, null]);
1711
+ async stream(t, n, i) {
1712
+ const a = _t();
1713
+ let c;
1714
+ const [, h] = await this.executeMiddleware(
1715
+ { target: t, protocol: "websocket", params: {}, role: "client" },
1716
+ async (p) => {
1717
+ const m = a(this.buildURL(t, p)), v = { ...p, params: {} };
1718
+ m.binaryType = J.MESSAGE_TYPE;
1719
+ const w = await this.wrapSocket(m, n, i);
1720
+ return w instanceof Error ? [v, w] : (c = w, [v, null]);
1996
1721
  }
1997
1722
  );
1998
- if (c != null)
1999
- throw c;
2000
- return u;
1723
+ if (h != null) throw h;
1724
+ return c;
2001
1725
  }
2002
- buildURL(r, n) {
2003
- const s = Yr(
1726
+ buildURL(t, n) {
1727
+ const i = Ft(
2004
1728
  {
2005
- [Ct]: this.encoder.contentType,
1729
+ [qe]: this.encoder.contentType,
2006
1730
  ...n.params
2007
1731
  },
2008
- tn
1732
+ rr
2009
1733
  );
2010
- return this.baseUrl.child(r).toString() + s;
1734
+ return this.baseUrl.child(t).toString() + i;
2011
1735
  }
2012
- async wrapSocket(r, n, s) {
1736
+ async wrapSocket(t, n, i) {
2013
1737
  return await new Promise((a) => {
2014
- r.onopen = () => {
2015
- a(new en(r, this.encoder, n, s));
2016
- }, r.onerror = (u) => {
2017
- const c = u;
2018
- a(new Error(c.message));
1738
+ t.onopen = () => {
1739
+ a(new tr(t, this.encoder, n, i));
1740
+ }, t.onerror = (c) => {
1741
+ const h = c;
1742
+ a(new Error(h.message));
2019
1743
  };
2020
1744
  });
2021
1745
  }
2022
1746
  };
2023
- v(ae, "MESSAGE_TYPE", "arraybuffer");
2024
- let qe = ae;
1747
+ f(J, "MESSAGE_TYPE", "arraybuffer");
1748
+ let Ne = J;
2025
1749
  export {
2026
- de as BaseTypedError,
2027
- z as EOF,
2028
- hn as HTTPClient,
2029
- Y as StreamClosed,
2030
- F as Unreachable,
2031
- qe as WebSocketClient,
2032
- Nt as decodeError,
2033
- dn as encodeError,
2034
- It as errorZ,
2035
- Hr as registerError,
2036
- pn as sendRequired
1750
+ _ as BaseTypedError,
1751
+ B as EOF,
1752
+ yr as HTTPClient,
1753
+ R as StreamClosed,
1754
+ D as Unreachable,
1755
+ Ne as WebSocketClient,
1756
+ Fe as decodeError,
1757
+ pr as encodeError,
1758
+ he as errorMatcher,
1759
+ We as errorZ,
1760
+ Xt as registerError,
1761
+ gr as sendRequired
2037
1762
  };