@btc-vision/bitcoin 6.4.11 → 6.5.1

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.
@@ -0,0 +1,759 @@
1
+ import { B as A, g as fn, f as R } from "./crypto-C6FlKKmp.js";
2
+ import { o as _ } from "./script-COWGdiOo.js";
3
+ function Cn(n) {
4
+ if (n.length < 8 || n.length > 72 || n[0] !== 48 || n[1] !== n.length - 2 || n[2] !== 2) return !1;
5
+ const r = n[3];
6
+ if (r === 0 || 5 + r >= n.length || n[4 + r] !== 2) return !1;
7
+ const t = n[5 + r];
8
+ return !(t === 0 || 6 + r + t !== n.length || n[4] & 128 || r > 1 && n[4] === 0 && !(n[5] & 128) || n[r + 6] & 128 || t > 1 && n[r + 6] === 0 && !(n[r + 7] & 128));
9
+ }
10
+ function Fn(n) {
11
+ if (n.length < 8) throw new Error("DER sequence length is too short");
12
+ if (n.length > 72) throw new Error("DER sequence length is too long");
13
+ if (n[0] !== 48) throw new Error("Expected DER sequence");
14
+ if (n[1] !== n.length - 2) throw new Error("DER sequence length is invalid");
15
+ if (n[2] !== 2) throw new Error("Expected DER integer");
16
+ const r = n[3];
17
+ if (r === 0) throw new Error("R length is zero");
18
+ if (5 + r >= n.length) throw new Error("R length is too long");
19
+ if (n[4 + r] !== 2) throw new Error("Expected DER integer (2)");
20
+ const t = n[5 + r];
21
+ if (t === 0) throw new Error("S length is zero");
22
+ if (6 + r + t !== n.length) throw new Error("S length is invalid");
23
+ if (n[4] & 128) throw new Error("R value is negative");
24
+ if (r > 1 && n[4] === 0 && !(n[5] & 128))
25
+ throw new Error("R value excessively padded");
26
+ if (n[r + 6] & 128) throw new Error("S value is negative");
27
+ if (t > 1 && n[r + 6] === 0 && !(n[r + 7] & 128))
28
+ throw new Error("S value excessively padded");
29
+ return {
30
+ r: n.slice(4, 4 + r),
31
+ s: n.slice(6 + r)
32
+ };
33
+ }
34
+ function Mn(n, r) {
35
+ const t = n.length, e = r.length;
36
+ if (t === 0) throw new Error("R length is zero");
37
+ if (e === 0) throw new Error("S length is zero");
38
+ if (t > 33) throw new Error("R length is too long");
39
+ if (e > 33) throw new Error("S length is too long");
40
+ if (n[0] & 128) throw new Error("R value is negative");
41
+ if (r[0] & 128) throw new Error("S value is negative");
42
+ if (t > 1 && n[0] === 0 && !(n[1] & 128)) throw new Error("R value excessively padded");
43
+ if (e > 1 && r[0] === 0 && !(r[1] & 128)) throw new Error("S value excessively padded");
44
+ const a = A.allocUnsafe(6 + t + e);
45
+ return a[0] = 48, a[1] = a.length - 2, a[2] = 2, a[3] = n.length, n.copy(a, 4), a[4 + t] = 2, a[5 + t] = r.length, r.copy(a, 6 + t), a;
46
+ }
47
+ function cn(n) {
48
+ return n < _.OP_PUSHDATA1 ? 1 : n <= 255 ? 2 : n <= 65535 ? 3 : 5;
49
+ }
50
+ function zn(n, r, t) {
51
+ const e = cn(r);
52
+ return e === 1 ? n.writeUInt8(r, t) : e === 2 ? (n.writeUInt8(_.OP_PUSHDATA1, t), n.writeUInt8(r, t + 1)) : e === 3 ? (n.writeUInt8(_.OP_PUSHDATA2, t), n.writeUInt16LE(r, t + 1)) : (n.writeUInt8(_.OP_PUSHDATA4, t), n.writeUInt32LE(r, t + 1)), e;
53
+ }
54
+ function Xn(n, r) {
55
+ const t = n.readUInt8(r);
56
+ let e, a;
57
+ if (t < _.OP_PUSHDATA1)
58
+ e = t, a = 1;
59
+ else if (t === _.OP_PUSHDATA1) {
60
+ if (r + 2 > n.length) return null;
61
+ e = n.readUInt8(r + 1), a = 2;
62
+ } else if (t === _.OP_PUSHDATA2) {
63
+ if (r + 3 > n.length) return null;
64
+ e = n.readUInt16LE(r + 1), a = 3;
65
+ } else {
66
+ if (r + 5 > n.length) return null;
67
+ if (t !== _.OP_PUSHDATA4) throw new Error("Unexpected opcode");
68
+ e = n.readUInt32LE(r + 1), a = 5;
69
+ }
70
+ return {
71
+ opcode: t,
72
+ number: e,
73
+ size: a
74
+ };
75
+ }
76
+ var p, q;
77
+ function j() {
78
+ if (q) return p;
79
+ q = 1;
80
+ var n = {
81
+ Array: function(t) {
82
+ return t != null && t.constructor === Array;
83
+ },
84
+ Boolean: function(t) {
85
+ return typeof t == "boolean";
86
+ },
87
+ Function: function(t) {
88
+ return typeof t == "function";
89
+ },
90
+ Nil: function(t) {
91
+ return t == null;
92
+ },
93
+ Number: function(t) {
94
+ return typeof t == "number";
95
+ },
96
+ Object: function(t) {
97
+ return typeof t == "object";
98
+ },
99
+ String: function(t) {
100
+ return typeof t == "string";
101
+ },
102
+ "": function() {
103
+ return !0;
104
+ }
105
+ };
106
+ n.Null = n.Nil;
107
+ for (var r in n)
108
+ n[r].toJSON = function(t) {
109
+ return t;
110
+ }.bind(null, r);
111
+ return p = n, p;
112
+ }
113
+ var P, H;
114
+ function z() {
115
+ if (H) return P;
116
+ H = 1;
117
+ var n = j();
118
+ function r(i) {
119
+ return i.name || i.toString().match(/function (.*?)\s*\(/)[1];
120
+ }
121
+ function t(i) {
122
+ return n.Nil(i) ? "" : r(i.constructor);
123
+ }
124
+ function e(i) {
125
+ return n.Function(i) ? "" : n.String(i) ? JSON.stringify(i) : i && n.Object(i) ? "" : i;
126
+ }
127
+ function a(i, f) {
128
+ Error.captureStackTrace && Error.captureStackTrace(i, f);
129
+ }
130
+ function d(i) {
131
+ return n.Function(i) ? i.toJSON ? i.toJSON() : r(i) : n.Array(i) ? "Array" : i && n.Object(i) ? "Object" : i !== void 0 ? i : "";
132
+ }
133
+ function N(i, f, o) {
134
+ var u = e(f);
135
+ return "Expected " + d(i) + ", got" + (o !== "" ? " " + o : "") + (u !== "" ? " " + u : "");
136
+ }
137
+ function l(i, f, o) {
138
+ o = o || t(f), this.message = N(i, f, o), a(this, l), this.__type = i, this.__value = f, this.__valueTypeName = o;
139
+ }
140
+ l.prototype = Object.create(Error.prototype), l.prototype.constructor = l;
141
+ function E(i, f, o, u, s) {
142
+ var g = '" of type ';
143
+ return f === "key" && (g = '" with key type '), N('property "' + d(o) + g + d(i), u, s);
144
+ }
145
+ function h(i, f, o, u, s) {
146
+ i ? (s = s || t(u), this.message = E(i, o, f, u, s)) : this.message = 'Unexpected property "' + f + '"', a(this, l), this.__label = o, this.__property = f, this.__type = i, this.__value = u, this.__valueTypeName = s;
147
+ }
148
+ h.prototype = Object.create(Error.prototype), h.prototype.constructor = l;
149
+ function x(i, f) {
150
+ return new l(i, {}, f);
151
+ }
152
+ function y(i, f, o) {
153
+ return i instanceof h ? (f = f + "." + i.__property, i = new h(
154
+ i.__type,
155
+ f,
156
+ i.__label,
157
+ i.__value,
158
+ i.__valueTypeName
159
+ )) : i instanceof l && (i = new h(
160
+ i.__type,
161
+ f,
162
+ o,
163
+ i.__value,
164
+ i.__valueTypeName
165
+ )), a(i), i;
166
+ }
167
+ return P = {
168
+ TfTypeError: l,
169
+ TfPropertyTypeError: h,
170
+ tfCustomError: x,
171
+ tfSubError: y,
172
+ tfJSON: d,
173
+ getValueTypeName: t
174
+ }, P;
175
+ }
176
+ var V, D;
177
+ function un() {
178
+ if (D) return V;
179
+ D = 1;
180
+ var n = j(), r = z();
181
+ function t(c) {
182
+ return A.isBuffer(c);
183
+ }
184
+ function e(c) {
185
+ return typeof c == "string" && /^([0-9a-f]{2})+$/i.test(c);
186
+ }
187
+ function a(c, L) {
188
+ var U = c.toJSON();
189
+ function B(O) {
190
+ if (!c(O)) return !1;
191
+ if (O.length === L) return !0;
192
+ throw r.tfCustomError(U + "(Length: " + L + ")", U + "(Length: " + O.length + ")");
193
+ }
194
+ return B.toJSON = function() {
195
+ return U;
196
+ }, B;
197
+ }
198
+ var d = a.bind(null, n.Array), N = a.bind(null, t), l = a.bind(null, e), E = a.bind(null, n.String);
199
+ function h(c, L, U) {
200
+ U = U || n.Number;
201
+ function B(O, on) {
202
+ return U(O, on) && O > c && O < L;
203
+ }
204
+ return B.toJSON = function() {
205
+ return `${U.toJSON()} between [${c}, ${L}]`;
206
+ }, B;
207
+ }
208
+ var x = Math.pow(2, 53) - 1;
209
+ function y(c) {
210
+ return typeof c == "number" && isFinite(c);
211
+ }
212
+ function i(c) {
213
+ return c << 24 >> 24 === c;
214
+ }
215
+ function f(c) {
216
+ return c << 16 >> 16 === c;
217
+ }
218
+ function o(c) {
219
+ return (c | 0) === c;
220
+ }
221
+ function u(c) {
222
+ return typeof c == "number" && c >= -x && c <= x && Math.floor(c) === c;
223
+ }
224
+ function s(c) {
225
+ return (c & 255) === c;
226
+ }
227
+ function g(c) {
228
+ return (c & 65535) === c;
229
+ }
230
+ function m(c) {
231
+ return c >>> 0 === c;
232
+ }
233
+ function I(c) {
234
+ return typeof c == "number" && c >= 0 && c <= x && Math.floor(c) === c;
235
+ }
236
+ var S = {
237
+ ArrayN: d,
238
+ Buffer: t,
239
+ BufferN: N,
240
+ Finite: y,
241
+ Hex: e,
242
+ HexN: l,
243
+ Int8: i,
244
+ Int16: f,
245
+ Int32: o,
246
+ Int53: u,
247
+ Range: h,
248
+ StringN: E,
249
+ UInt8: s,
250
+ UInt16: g,
251
+ UInt32: m,
252
+ UInt53: I
253
+ };
254
+ for (var T in S)
255
+ S[T].toJSON = function(c) {
256
+ return c;
257
+ }.bind(null, T);
258
+ return V = S, V;
259
+ }
260
+ var $, C;
261
+ function sn() {
262
+ if (C) return $;
263
+ C = 1;
264
+ var n = z(), r = j(), t = n.tfJSON, e = n.TfTypeError, a = n.TfPropertyTypeError, d = n.tfSubError, N = n.getValueTypeName, l = {
265
+ arrayOf: function(f, o) {
266
+ f = E(f), o = o || {};
267
+ function u(s, g) {
268
+ return !r.Array(s) || r.Nil(s) || o.minLength !== void 0 && s.length < o.minLength || o.maxLength !== void 0 && s.length > o.maxLength || o.length !== void 0 && s.length !== o.length ? !1 : s.every(function(m, I) {
269
+ try {
270
+ return h(f, m, g);
271
+ } catch (S) {
272
+ throw d(S, I);
273
+ }
274
+ });
275
+ }
276
+ return u.toJSON = function() {
277
+ var s = "[" + t(f) + "]";
278
+ return o.length !== void 0 ? s += "{" + o.length + "}" : (o.minLength !== void 0 || o.maxLength !== void 0) && (s += "{" + (o.minLength === void 0 ? 0 : o.minLength) + "," + (o.maxLength === void 0 ? 1 / 0 : o.maxLength) + "}"), s;
279
+ }, u;
280
+ },
281
+ maybe: function i(f) {
282
+ f = E(f);
283
+ function o(u, s) {
284
+ return r.Nil(u) || f(u, s, i);
285
+ }
286
+ return o.toJSON = function() {
287
+ return "?" + t(f);
288
+ }, o;
289
+ },
290
+ map: function(f, o) {
291
+ f = E(f), o && (o = E(o));
292
+ function u(s, g) {
293
+ if (!r.Object(s) || r.Nil(s)) return !1;
294
+ for (var m in s) {
295
+ try {
296
+ o && h(o, m, g);
297
+ } catch (S) {
298
+ throw d(S, m, "key");
299
+ }
300
+ try {
301
+ var I = s[m];
302
+ h(f, I, g);
303
+ } catch (S) {
304
+ throw d(S, m);
305
+ }
306
+ }
307
+ return !0;
308
+ }
309
+ return o ? u.toJSON = function() {
310
+ return "{" + t(o) + ": " + t(f) + "}";
311
+ } : u.toJSON = function() {
312
+ return "{" + t(f) + "}";
313
+ }, u;
314
+ },
315
+ object: function(f) {
316
+ var o = {};
317
+ for (var u in f)
318
+ o[u] = E(f[u]);
319
+ function s(g, m) {
320
+ if (!r.Object(g) || r.Nil(g)) return !1;
321
+ var I;
322
+ try {
323
+ for (I in o) {
324
+ var S = o[I], T = g[I];
325
+ h(S, T, m);
326
+ }
327
+ } catch (c) {
328
+ throw d(c, I);
329
+ }
330
+ if (m) {
331
+ for (I in g)
332
+ if (!o[I])
333
+ throw new a(void 0, I);
334
+ }
335
+ return !0;
336
+ }
337
+ return s.toJSON = function() {
338
+ return t(o);
339
+ }, s;
340
+ },
341
+ anyOf: function() {
342
+ var f = [].slice.call(arguments).map(E);
343
+ function o(u, s) {
344
+ return f.some(function(g) {
345
+ try {
346
+ return h(g, u, s);
347
+ } catch {
348
+ return !1;
349
+ }
350
+ });
351
+ }
352
+ return o.toJSON = function() {
353
+ return f.map(t).join("|");
354
+ }, o;
355
+ },
356
+ allOf: function() {
357
+ var f = [].slice.call(arguments).map(E);
358
+ function o(u, s) {
359
+ return f.every(function(g) {
360
+ try {
361
+ return h(g, u, s);
362
+ } catch {
363
+ return !1;
364
+ }
365
+ });
366
+ }
367
+ return o.toJSON = function() {
368
+ return f.map(t).join(" & ");
369
+ }, o;
370
+ },
371
+ quacksLike: function(f) {
372
+ function o(u) {
373
+ return f === N(u);
374
+ }
375
+ return o.toJSON = function() {
376
+ return f;
377
+ }, o;
378
+ },
379
+ tuple: function() {
380
+ var f = [].slice.call(arguments).map(E);
381
+ function o(u, s) {
382
+ return r.Nil(u) || r.Nil(u.length) || s && u.length !== f.length ? !1 : f.every(function(g, m) {
383
+ try {
384
+ return h(g, u[m], s);
385
+ } catch (I) {
386
+ throw d(I, m);
387
+ }
388
+ });
389
+ }
390
+ return o.toJSON = function() {
391
+ return "(" + f.map(t).join(", ") + ")";
392
+ }, o;
393
+ },
394
+ value: function(f) {
395
+ function o(u) {
396
+ return u === f;
397
+ }
398
+ return o.toJSON = function() {
399
+ return f;
400
+ }, o;
401
+ }
402
+ };
403
+ l.oneOf = l.anyOf;
404
+ function E(i) {
405
+ if (r.String(i))
406
+ return i[0] === "?" ? l.maybe(i.slice(1)) : r[i] || l.quacksLike(i);
407
+ if (i && r.Object(i)) {
408
+ if (r.Array(i)) {
409
+ if (i.length !== 1) throw new TypeError("Expected compile() parameter of type Array of length 1");
410
+ return l.arrayOf(i[0]);
411
+ }
412
+ return l.object(i);
413
+ } else if (r.Function(i))
414
+ return i;
415
+ return l.value(i);
416
+ }
417
+ function h(i, f, o, u) {
418
+ if (r.Function(i)) {
419
+ if (i(f, o)) return !0;
420
+ throw new e(u || i, f);
421
+ }
422
+ return h(E(i), f, o);
423
+ }
424
+ for (var x in r)
425
+ h[x] = r[x];
426
+ for (x in l)
427
+ h[x] = l[x];
428
+ var y = un();
429
+ for (x in y)
430
+ h[x] = y[x];
431
+ return h.compile = E, h.TfTypeError = e, h.TfPropertyTypeError = a, $ = h, $;
432
+ }
433
+ var an = sn();
434
+ const hn = /* @__PURE__ */ fn(an), w = hn, F = R.alloc(32, 0), M = R.from(
435
+ "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",
436
+ "hex"
437
+ );
438
+ function ln(n, r) {
439
+ return n.length !== r.length ? !1 : n.every((t, e) => t.equals(r[e]));
440
+ }
441
+ function gn(n) {
442
+ if (!R.isBuffer(n) || n.length < 33) return !1;
443
+ const r = n[0], t = n.slice(1, 33);
444
+ if (t.compare(F) === 0 || t.compare(M) >= 0) return !1;
445
+ if ((r === 2 || r === 3) && n.length === 33)
446
+ return !0;
447
+ if (n.length !== 65) return !1;
448
+ const e = n.slice(33);
449
+ return e.compare(F) === 0 || e.compare(M) >= 0 ? !1 : r === 4 || r === 6 || r === 7;
450
+ }
451
+ const wn = 21 * 1e14;
452
+ function dn(n) {
453
+ return w.UInt53(n) && n <= wn;
454
+ }
455
+ const X = 254;
456
+ function G(n) {
457
+ return !n || !("output" in n) || !R.isBuffer(n.output) ? !1 : n.version !== void 0 ? (n.version & X) === n.version : !0;
458
+ }
459
+ function b(n) {
460
+ return Y(n) ? n.length !== 2 ? !1 : n.every((r) => b(r)) : G(n);
461
+ }
462
+ const En = w.BufferN(32), mn = w.BufferN(20), In = w.BufferN(32), xn = w.Number, Y = w.Array, Sn = w.Boolean, Nn = w.String, J = w.Buffer, Un = w.Hex, _n = w.maybe, v = w.tuple, On = w.UInt8, k = w.UInt32, yn = w.Function, An = w.BufferN, Ln = w.Null, Bn = w.oneOf, Tn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
463
+ __proto__: null,
464
+ Array: Y,
465
+ Boolean: Sn,
466
+ Buffer: J,
467
+ Buffer256bit: En,
468
+ BufferN: An,
469
+ Function: yn,
470
+ Hash160bit: mn,
471
+ Hash256bit: In,
472
+ Hex: Un,
473
+ Null: Ln,
474
+ Number: xn,
475
+ Satoshi: dn,
476
+ String: Nn,
477
+ TAPLEAF_VERSION_MASK: X,
478
+ UInt32: k,
479
+ UInt8: On,
480
+ isPoint: gn,
481
+ isTapleaf: G,
482
+ isTaptree: b,
483
+ maybe: _n,
484
+ oneOf: Bn,
485
+ stacksEqual: ln,
486
+ tuple: v,
487
+ typeforce: w
488
+ }, Symbol.toStringTag, { value: "Module" })), Z = "0123456789abcdefABCDEF";
489
+ Z.split("").map((n) => n.codePointAt(0));
490
+ Array(256).fill(!0).map((n, r) => {
491
+ const t = String.fromCodePoint(r), e = Z.indexOf(t);
492
+ return e < 0 ? void 0 : e < 16 ? e : e - 6;
493
+ });
494
+ new TextEncoder();
495
+ new TextDecoder();
496
+ function Rn(n, r, t, e) {
497
+ if (r + 2 > n.length)
498
+ throw new Error("Offset is outside the bounds of Uint8Array");
499
+ if (e = e.toUpperCase(), t > 65535)
500
+ throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 65535. Received ${t}`);
501
+ e === "LE" ? (n[r] = t & 255, n[r + 1] = t >> 8 & 255) : (n[r] = t >> 8 & 255, n[r + 1] = t & 255);
502
+ }
503
+ function pn(n, r, t, e) {
504
+ if (r + 4 > n.length)
505
+ throw new Error("Offset is outside the bounds of Uint8Array");
506
+ if (e = e.toUpperCase(), t > 4294967295)
507
+ throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${4294967295}. Received ${t}`);
508
+ e === "LE" ? (n[r] = t & 255, n[r + 1] = t >> 8 & 255, n[r + 2] = t >> 16 & 255, n[r + 3] = t >> 24 & 255) : (n[r] = t >> 24 & 255, n[r + 1] = t >> 16 & 255, n[r + 2] = t >> 8 & 255, n[r + 3] = t & 255);
509
+ }
510
+ function Pn(n, r, t, e) {
511
+ if (r + 8 > n.length)
512
+ throw new Error("Offset is outside the bounds of Uint8Array");
513
+ if (e = e.toUpperCase(), t > 0xffffffffffffffffn)
514
+ throw new Error(`The value of "value" is out of range. It must be >= 0 and <= ${0xffffffffffffffffn}. Received ${t}`);
515
+ e === "LE" ? (n[r] = Number(t & 0xffn), n[r + 1] = Number(t >> 8n & 0xffn), n[r + 2] = Number(t >> 16n & 0xffn), n[r + 3] = Number(t >> 24n & 0xffn), n[r + 4] = Number(t >> 32n & 0xffn), n[r + 5] = Number(t >> 40n & 0xffn), n[r + 6] = Number(t >> 48n & 0xffn), n[r + 7] = Number(t >> 56n & 0xffn)) : (n[r] = Number(t >> 56n & 0xffn), n[r + 1] = Number(t >> 48n & 0xffn), n[r + 2] = Number(t >> 40n & 0xffn), n[r + 3] = Number(t >> 32n & 0xffn), n[r + 4] = Number(t >> 24n & 0xffn), n[r + 5] = Number(t >> 16n & 0xffn), n[r + 6] = Number(t >> 8n & 0xffn), n[r + 7] = Number(t & 0xffn));
516
+ }
517
+ function Vn(n, r, t) {
518
+ if (r + 2 > n.length)
519
+ throw new Error("Offset is outside the bounds of Uint8Array");
520
+ if (t = t.toUpperCase(), t === "LE") {
521
+ let e = 0;
522
+ return e = (e << 8) + n[r + 1], e = (e << 8) + n[r], e;
523
+ } else {
524
+ let e = 0;
525
+ return e = (e << 8) + n[r], e = (e << 8) + n[r + 1], e;
526
+ }
527
+ }
528
+ function $n(n, r, t) {
529
+ if (r + 4 > n.length)
530
+ throw new Error("Offset is outside the bounds of Uint8Array");
531
+ if (t = t.toUpperCase(), t === "LE") {
532
+ let e = 0;
533
+ return e = (e << 8) + n[r + 3] >>> 0, e = (e << 8) + n[r + 2] >>> 0, e = (e << 8) + n[r + 1] >>> 0, e = (e << 8) + n[r] >>> 0, e;
534
+ } else {
535
+ let e = 0;
536
+ return e = (e << 8) + n[r] >>> 0, e = (e << 8) + n[r + 1] >>> 0, e = (e << 8) + n[r + 2] >>> 0, e = (e << 8) + n[r + 3] >>> 0, e;
537
+ }
538
+ }
539
+ function jn(n, r, t) {
540
+ if (r + 8 > n.length)
541
+ throw new Error("Offset is outside the bounds of Uint8Array");
542
+ if (t = t.toUpperCase(), t === "LE") {
543
+ let e = 0n;
544
+ return e = (e << 8n) + BigInt(n[r + 7]), e = (e << 8n) + BigInt(n[r + 6]), e = (e << 8n) + BigInt(n[r + 5]), e = (e << 8n) + BigInt(n[r + 4]), e = (e << 8n) + BigInt(n[r + 3]), e = (e << 8n) + BigInt(n[r + 2]), e = (e << 8n) + BigInt(n[r + 1]), e = (e << 8n) + BigInt(n[r]), e;
545
+ } else {
546
+ let e = 0n;
547
+ return e = (e << 8n) + BigInt(n[r]), e = (e << 8n) + BigInt(n[r + 1]), e = (e << 8n) + BigInt(n[r + 2]), e = (e << 8n) + BigInt(n[r + 3]), e = (e << 8n) + BigInt(n[r + 4]), e = (e << 8n) + BigInt(n[r + 5]), e = (e << 8n) + BigInt(n[r + 6]), e = (e << 8n) + BigInt(n[r + 7]), e;
548
+ }
549
+ }
550
+ const Jn = (n) => {
551
+ if (n < 0 || n > 0xffffffffffffffffn)
552
+ throw new RangeError("value out of range");
553
+ };
554
+ function vn(n) {
555
+ if (n < 0 || n > Number.MAX_SAFE_INTEGER || n % 1 !== 0)
556
+ throw new RangeError("value out of range");
557
+ }
558
+ function Q(n) {
559
+ typeof n == "number" ? vn(n) : Jn(n);
560
+ }
561
+ function W(n, r, t) {
562
+ Q(n), t === void 0 && (t = 0), r === void 0 && (r = new Uint8Array(nn(n)));
563
+ let e = 0;
564
+ return n < 253 ? (r.set([Number(n)], t), e = 1) : n <= 65535 ? (r.set([253], t), Rn(r, t + 1, Number(n), "LE"), e = 3) : n <= 4294967295 ? (r.set([254], t), pn(r, t + 1, Number(n), "LE"), e = 5) : (r.set([255], t), Pn(r, t + 1, BigInt(n), "LE"), e = 9), { buffer: r, bytes: e };
565
+ }
566
+ function K(n, r) {
567
+ r === void 0 && (r = 0);
568
+ const t = n.at(r);
569
+ if (t === void 0)
570
+ throw new Error("buffer too small");
571
+ if (t < 253)
572
+ return { numberValue: t, bigintValue: BigInt(t), bytes: 1 };
573
+ if (t === 253) {
574
+ const e = Vn(n, r + 1, "LE");
575
+ return {
576
+ numberValue: e,
577
+ bigintValue: BigInt(e),
578
+ bytes: 3
579
+ };
580
+ } else if (t === 254) {
581
+ const e = $n(n, r + 1, "LE");
582
+ return {
583
+ numberValue: e,
584
+ bigintValue: BigInt(e),
585
+ bytes: 5
586
+ };
587
+ } else {
588
+ const e = jn(n, r + 1, "LE");
589
+ return { numberValue: e <= Number.MAX_SAFE_INTEGER ? Number(e) : null, bigintValue: e, bytes: 9 };
590
+ }
591
+ }
592
+ function nn(n) {
593
+ return Q(n), n < 253 ? 1 : n <= 65535 ? 3 : n <= 4294967295 ? 5 : 9;
594
+ }
595
+ const Gn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
596
+ __proto__: null,
597
+ decode: K,
598
+ encode: W,
599
+ encodingLength: nn
600
+ }, Symbol.toStringTag, { value: "Module" })), { typeforce: rn } = Tn;
601
+ function tn(n, r) {
602
+ if (typeof n != "number") throw new Error("cannot write a non-number as a number");
603
+ if (n < 0) throw new Error("specified a negative value for writing an unsigned value");
604
+ if (n > r) throw new Error("RangeError: value out of range");
605
+ if (Math.floor(n) !== n) throw new Error("value has a fractional component");
606
+ }
607
+ function kn(n, r) {
608
+ const t = n.readUInt32LE(r);
609
+ let e = n.readUInt32LE(r + 4);
610
+ return e *= 4294967296, tn(e + t, 9007199254740991), e + t;
611
+ }
612
+ function qn(n, r, t) {
613
+ return tn(r, 9007199254740991), n.writeInt32LE(r & -1, t), n.writeUInt32LE(Math.floor(r / 4294967296), t + 4), t + 8;
614
+ }
615
+ function bn(n) {
616
+ if (n.length < 1) return n;
617
+ let r = n.length - 1, t = 0;
618
+ for (let e = 0; e < n.length / 2; e++)
619
+ t = n[e], n[e] = n[r], n[r] = t, r--;
620
+ return n;
621
+ }
622
+ function Yn(n) {
623
+ const r = A.allocUnsafe(n.length);
624
+ return n.copy(r), r;
625
+ }
626
+ class en {
627
+ constructor(r, t = 0) {
628
+ this.buffer = r, this.offset = t, rn(v(J, k), [r, t]);
629
+ }
630
+ static withCapacity(r) {
631
+ return new en(A.alloc(r));
632
+ }
633
+ writeUInt8(r) {
634
+ this.offset = this.buffer.writeUInt8(r, this.offset);
635
+ }
636
+ writeInt32(r) {
637
+ this.offset = this.buffer.writeInt32LE(r, this.offset);
638
+ }
639
+ writeUInt32(r) {
640
+ this.offset = this.buffer.writeUInt32LE(r, this.offset);
641
+ }
642
+ writeUInt64(r) {
643
+ this.offset = qn(this.buffer, r, this.offset);
644
+ }
645
+ writeVarInt(r) {
646
+ const t = W(r, this.buffer, this.offset);
647
+ this.offset += t.bytes;
648
+ }
649
+ writeSlice(r) {
650
+ if (this.buffer.length < this.offset + r.length)
651
+ throw new Error("Cannot write slice out of bounds");
652
+ this.offset += r.copy(this.buffer, this.offset);
653
+ }
654
+ writeVarSlice(r) {
655
+ this.writeVarInt(r.length), this.writeSlice(r);
656
+ }
657
+ writeVector(r) {
658
+ this.writeVarInt(r.length), r.forEach((t) => this.writeVarSlice(t));
659
+ }
660
+ end() {
661
+ if (this.buffer.length === this.offset)
662
+ return this.buffer;
663
+ throw new Error(`buffer size ${this.buffer.length}, offset ${this.offset}`);
664
+ }
665
+ }
666
+ class Zn {
667
+ constructor(r, t = 0) {
668
+ this.buffer = r, this.offset = t, rn(v(J, k), [r, t]);
669
+ }
670
+ readUInt8() {
671
+ const r = this.buffer.readUInt8(this.offset);
672
+ return this.offset++, r;
673
+ }
674
+ readInt32() {
675
+ const r = this.buffer.readInt32LE(this.offset);
676
+ return this.offset += 4, r;
677
+ }
678
+ readUInt32() {
679
+ const r = this.buffer.readUInt32LE(this.offset);
680
+ return this.offset += 4, r;
681
+ }
682
+ readUInt64() {
683
+ const r = kn(this.buffer, this.offset);
684
+ return this.offset += 8, r;
685
+ }
686
+ readVarInt() {
687
+ const r = K(this.buffer, this.offset);
688
+ return this.offset += r.bytes, r.numberValue || 0;
689
+ }
690
+ readSlice(r) {
691
+ if (this.buffer.length < this.offset + r)
692
+ throw new Error("Cannot read slice out of bounds");
693
+ const t = A.from(this.buffer.subarray(this.offset, this.offset + r));
694
+ return this.offset += r, t;
695
+ }
696
+ readVarSlice() {
697
+ return this.readSlice(this.readVarInt());
698
+ }
699
+ readVector() {
700
+ const r = this.readVarInt(), t = [];
701
+ for (let e = 0; e < r; e++) t.push(this.readVarSlice());
702
+ return t;
703
+ }
704
+ }
705
+ function Qn(n, r) {
706
+ if (!Array.isArray(n)) throw TypeError("Expected values Array");
707
+ if (typeof r != "function") throw TypeError("Expected digest Function");
708
+ let t = n.length;
709
+ const e = n.concat();
710
+ for (; t > 1; ) {
711
+ let a = 0;
712
+ for (let d = 0; d < t; d += 2, ++a) {
713
+ const N = e[d], l = d + 1 === t ? N : e[d + 1], E = A.concat([N, l]);
714
+ e[a] = r(E);
715
+ }
716
+ t = a;
717
+ }
718
+ return e[0];
719
+ }
720
+ export {
721
+ Y as A,
722
+ en as B,
723
+ Xn as C,
724
+ Nn as D,
725
+ Un as E,
726
+ yn as F,
727
+ Cn as G,
728
+ mn as H,
729
+ Ln as N,
730
+ dn as S,
731
+ X as T,
732
+ On as U,
733
+ v as a,
734
+ G as b,
735
+ Yn as c,
736
+ Gn as d,
737
+ kn as e,
738
+ Zn as f,
739
+ nn as g,
740
+ W as h,
741
+ b as i,
742
+ gn as j,
743
+ Tn as k,
744
+ In as l,
745
+ k as m,
746
+ _n as n,
747
+ J as o,
748
+ xn as p,
749
+ Qn as q,
750
+ bn as r,
751
+ ln as s,
752
+ w as t,
753
+ Fn as u,
754
+ An as v,
755
+ qn as w,
756
+ Mn as x,
757
+ cn as y,
758
+ zn as z
759
+ };