nostr-double-ratchet 0.0.28 → 0.0.30

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.
@@ -1,11 +1,11 @@
1
- var Ki = Object.defineProperty;
2
- var Ni = (e, t, n) => t in e ? Ki(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var J = (e, t, n) => Ni(e, typeof t != "symbol" ? t + "" : t, n);
1
+ var Ni = Object.defineProperty;
2
+ var Ki = (e, t, n) => t in e ? Ni(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var J = (e, t, n) => Ki(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  function Bn(e) {
5
5
  if (!Number.isSafeInteger(e) || e < 0)
6
6
  throw new Error(`Wrong positive integer: ${e}`);
7
7
  }
8
- function Gn(e, ...t) {
8
+ function Fn(e, ...t) {
9
9
  if (!(e instanceof Uint8Array))
10
10
  throw new Error("Expected Uint8Array");
11
11
  if (t.length > 0 && !t.includes(e.length))
@@ -23,14 +23,14 @@ function et(e, t = !0) {
23
23
  throw new Error("Hash#digest() has already been called");
24
24
  }
25
25
  function Ai(e, t) {
26
- Gn(e);
26
+ Fn(e);
27
27
  const n = t.outputLen;
28
28
  if (e.length < n)
29
29
  throw new Error(`digestInto() expects output buffer of length at least ${n}`);
30
30
  }
31
- const Kt = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
31
+ const xt = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
32
32
  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
33
- const Fn = (e) => e instanceof Uint8Array, Nt = (e) => new DataView(e.buffer, e.byteOffset, e.byteLength), re = (e, t) => e << 32 - t | e >>> t, Ci = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
33
+ const Gn = (e) => e instanceof Uint8Array, Nt = (e) => new DataView(e.buffer, e.byteOffset, e.byteLength), re = (e, t) => e << 32 - t | e >>> t, Ci = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
34
34
  if (!Ci)
35
35
  throw new Error("Non little-endian hardware is not supported");
36
36
  function Bi(e) {
@@ -38,8 +38,8 @@ function Bi(e) {
38
38
  throw new Error(`utf8ToBytes expected string, got ${typeof e}`);
39
39
  return new Uint8Array(new TextEncoder().encode(e));
40
40
  }
41
- function Vt(e) {
42
- if (typeof e == "string" && (e = Bi(e)), !Fn(e))
41
+ function Wt(e) {
42
+ if (typeof e == "string" && (e = Bi(e)), !Gn(e))
43
43
  throw new Error(`expected Uint8Array, got ${typeof e}`);
44
44
  return e;
45
45
  }
@@ -47,7 +47,7 @@ function ki(...e) {
47
47
  const t = new Uint8Array(e.reduce((r, i) => r + i.length, 0));
48
48
  let n = 0;
49
49
  return e.forEach((r) => {
50
- if (!Fn(r))
50
+ if (!Gn(r))
51
51
  throw new Error("Uint8Array expected");
52
52
  t.set(r, n), n += r.length;
53
53
  }), t;
@@ -58,16 +58,16 @@ let Jn = class {
58
58
  return this._cloneInto();
59
59
  }
60
60
  };
61
- function _i(e) {
62
- const t = (r) => e().update(Vt(r)).digest(), n = e();
61
+ function Ii(e) {
62
+ const t = (r) => e().update(Wt(r)).digest(), n = e();
63
63
  return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = () => e(), t;
64
64
  }
65
65
  function Yn(e = 32) {
66
- if (Kt && typeof Kt.getRandomValues == "function")
67
- return Kt.getRandomValues(new Uint8Array(e));
66
+ if (xt && typeof xt.getRandomValues == "function")
67
+ return xt.getRandomValues(new Uint8Array(e));
68
68
  throw new Error("crypto.getRandomValues must be defined");
69
69
  }
70
- function Ii(e, t, n, r) {
70
+ function _i(e, t, n, r) {
71
71
  if (typeof e.setBigUint64 == "function")
72
72
  return e.setBigUint64(t, n, r);
73
73
  const i = BigInt(32), s = BigInt(4294967295), o = Number(n >> i & s), c = Number(n & s), a = r ? 4 : 0, l = r ? 0 : 4;
@@ -80,7 +80,7 @@ let Ui = class extends Jn {
80
80
  update(t) {
81
81
  et(this);
82
82
  const { view: n, buffer: r, blockLen: i } = this;
83
- t = Vt(t);
83
+ t = Wt(t);
84
84
  const s = t.length;
85
85
  for (let o = 0; o < s; ) {
86
86
  const c = Math.min(i - this.pos, s - o);
@@ -101,7 +101,7 @@ let Ui = class extends Jn {
101
101
  n[o++] = 128, this.buffer.subarray(o).fill(0), this.padOffset > i - o && (this.process(r, 0), o = 0);
102
102
  for (let u = o; u < i; u++)
103
103
  n[u] = 0;
104
- Ii(r, i - 8, BigInt(this.length * 8), s), this.process(r, 0);
104
+ _i(r, i - 8, BigInt(this.length * 8), s), this.process(r, 0);
105
105
  const c = Nt(t), a = this.outputLen;
106
106
  if (a % 4)
107
107
  throw new Error("_sha2: outputLen should be aligned to 32bit");
@@ -214,12 +214,12 @@ let Ti = class extends Ui {
214
214
  for (let u = 0; u < 16; u++, n += 4)
215
215
  ve[u] = t.getUint32(n, !1);
216
216
  for (let u = 16; u < 64; u++) {
217
- const g = ve[u - 15], w = ve[u - 2], y = re(g, 7) ^ re(g, 18) ^ g >>> 3, h = re(w, 17) ^ re(w, 19) ^ w >>> 10;
218
- ve[u] = h + ve[u - 7] + y + ve[u - 16] | 0;
217
+ const p = ve[u - 15], w = ve[u - 2], g = re(p, 7) ^ re(p, 18) ^ p >>> 3, h = re(w, 17) ^ re(w, 19) ^ w >>> 10;
218
+ ve[u] = h + ve[u - 7] + g + ve[u - 16] | 0;
219
219
  }
220
220
  let { A: r, B: i, C: s, D: o, E: c, F: a, G: l, H: f } = this;
221
221
  for (let u = 0; u < 64; u++) {
222
- const g = re(c, 6) ^ re(c, 11) ^ re(c, 25), w = f + g + Li(c, a, l) + Ri[u] + ve[u] | 0, h = (re(r, 2) ^ re(r, 13) ^ re(r, 22)) + $i(r, i, s) | 0;
222
+ const p = re(c, 6) ^ re(c, 11) ^ re(c, 25), w = f + p + Li(c, a, l) + Ri[u] + ve[u] | 0, h = (re(r, 2) ^ re(r, 13) ^ re(r, 22)) + $i(r, i, s) | 0;
223
223
  f = l, l = a, a = c, c = o + w | 0, o = s, s = i, i = r, r = w + h | 0;
224
224
  }
225
225
  r = r + this.A | 0, i = i + this.B | 0, s = s + this.C | 0, o = o + this.D | 0, c = c + this.E | 0, a = a + this.F | 0, l = l + this.G | 0, f = f + this.H | 0, this.set(r, i, s, o, c, a, l, f);
@@ -231,7 +231,7 @@ let Ti = class extends Ui {
231
231
  this.set(0, 0, 0, 0, 0, 0, 0, 0), this.buffer.fill(0);
232
232
  }
233
233
  };
234
- const $t = /* @__PURE__ */ _i(() => new Ti());
234
+ const Lt = /* @__PURE__ */ Ii(() => new Ti());
235
235
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
236
236
  const Xn = BigInt(0), at = BigInt(1), Oi = BigInt(2), ct = (e) => e instanceof Uint8Array, Mi = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
237
237
  function De(e) {
@@ -246,7 +246,7 @@ function Qn(e) {
246
246
  const t = e.toString(16);
247
247
  return t.length & 1 ? `0${t}` : t;
248
248
  }
249
- function Zt(e) {
249
+ function Vt(e) {
250
250
  if (typeof e != "string")
251
251
  throw new Error("hex string expected, got " + typeof e);
252
252
  return BigInt(e === "" ? "0" : `0x${e}`);
@@ -266,19 +266,19 @@ function je(e) {
266
266
  }
267
267
  return n;
268
268
  }
269
- function F(e) {
270
- return Zt(De(e));
269
+ function G(e) {
270
+ return Vt(De(e));
271
271
  }
272
- function Gt(e) {
272
+ function Zt(e) {
273
273
  if (!ct(e))
274
274
  throw new Error("Uint8Array expected");
275
- return Zt(De(Uint8Array.from(e).reverse()));
275
+ return Vt(De(Uint8Array.from(e).reverse()));
276
276
  }
277
- function Ne(e, t) {
277
+ function Ke(e, t) {
278
278
  return je(e.toString(16).padStart(t * 2, "0"));
279
279
  }
280
280
  function Ft(e, t) {
281
- return Ne(e, t).reverse();
281
+ return Ke(e, t).reverse();
282
282
  }
283
283
  function Pi(e) {
284
284
  return je(Qn(e));
@@ -300,7 +300,7 @@ function Z(e, t, n) {
300
300
  throw new Error(`${e} expected ${n} bytes, got ${i}`);
301
301
  return r;
302
302
  }
303
- function _e(...e) {
303
+ function Ie(...e) {
304
304
  const t = new Uint8Array(e.reduce((r, i) => r + i.length, 0));
305
305
  let n = 0;
306
306
  return e.forEach((r) => {
@@ -331,7 +331,7 @@ function Di(e) {
331
331
  function ji(e, t) {
332
332
  return e >> BigInt(t) & at;
333
333
  }
334
- const zi = (e, t, n) => e | (n ? at : Xn) << BigInt(t), Jt = (e) => (Oi << BigInt(e - 1)) - at, St = (e) => new Uint8Array(e), kn = (e) => Uint8Array.from(e);
334
+ const zi = (e, t, n) => e | (n ? at : Xn) << BigInt(t), Gt = (e) => (Oi << BigInt(e - 1)) - at, Kt = (e) => new Uint8Array(e), kn = (e) => Uint8Array.from(e);
335
335
  function er(e, t, n) {
336
336
  if (typeof e != "number" || e < 2)
337
337
  throw new Error("hashLen must be a number");
@@ -339,27 +339,27 @@ function er(e, t, n) {
339
339
  throw new Error("qByteLen must be a number");
340
340
  if (typeof n != "function")
341
341
  throw new Error("hmacFn must be a function");
342
- let r = St(e), i = St(e), s = 0;
342
+ let r = Kt(e), i = Kt(e), s = 0;
343
343
  const o = () => {
344
344
  r.fill(1), i.fill(0), s = 0;
345
- }, c = (...u) => n(i, r, ...u), a = (u = St()) => {
345
+ }, c = (...u) => n(i, r, ...u), a = (u = Kt()) => {
346
346
  i = c(kn([0]), u), r = c(), u.length !== 0 && (i = c(kn([1]), u), r = c());
347
347
  }, l = () => {
348
348
  if (s++ >= 1e3)
349
349
  throw new Error("drbg: tried 1000 values");
350
350
  let u = 0;
351
- const g = [];
351
+ const p = [];
352
352
  for (; u < t; ) {
353
353
  r = c();
354
354
  const w = r.slice();
355
- g.push(w), u += r.length;
355
+ p.push(w), u += r.length;
356
356
  }
357
- return _e(...g);
357
+ return Ie(...p);
358
358
  };
359
- return (u, g) => {
359
+ return (u, p) => {
360
360
  o(), a(u);
361
361
  let w;
362
- for (; !(w = g(l())); )
362
+ for (; !(w = p(l())); )
363
363
  a();
364
364
  return o(), w;
365
365
  };
@@ -394,18 +394,18 @@ const Vi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
394
394
  __proto__: null,
395
395
  bitGet: ji,
396
396
  bitLen: Di,
397
- bitMask: Jt,
397
+ bitMask: Gt,
398
398
  bitSet: zi,
399
399
  bytesToHex: De,
400
- bytesToNumberBE: F,
401
- bytesToNumberLE: Gt,
402
- concatBytes: _e,
400
+ bytesToNumberBE: G,
401
+ bytesToNumberLE: Zt,
402
+ concatBytes: Ie,
403
403
  createHmacDrbg: er,
404
404
  ensureBytes: Z,
405
405
  equalBytes: Hi,
406
406
  hexToBytes: je,
407
- hexToNumber: Zt,
408
- numberToBytesBE: Ne,
407
+ hexToNumber: Vt,
408
+ numberToBytesBE: Ke,
409
409
  numberToBytesLE: Ft,
410
410
  numberToHexUnpadded: Qn,
411
411
  numberToVarBytesBE: Pi,
@@ -413,21 +413,21 @@ const Vi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
413
413
  validateObject: Ye
414
414
  }, Symbol.toStringTag, { value: "Module" }));
415
415
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
416
- const W = BigInt(0), j = BigInt(1), Ce = BigInt(2), Zi = BigInt(3), Rt = BigInt(4), _n = BigInt(5), In = BigInt(8);
416
+ const W = BigInt(0), z = BigInt(1), Ce = BigInt(2), Zi = BigInt(3), $t = BigInt(4), In = BigInt(5), _n = BigInt(8);
417
417
  BigInt(9);
418
418
  BigInt(16);
419
419
  function V(e, t) {
420
420
  const n = e % t;
421
421
  return n >= W ? n : t + n;
422
422
  }
423
- function Gi(e, t, n) {
423
+ function Fi(e, t, n) {
424
424
  if (n <= W || t < W)
425
425
  throw new Error("Expected power/modulo > 0");
426
- if (n === j)
426
+ if (n === z)
427
427
  return W;
428
- let r = j;
428
+ let r = z;
429
429
  for (; t > W; )
430
- t & j && (r = r * e % n), e = e * e % n, t >>= j;
430
+ t & z && (r = r * e % n), e = e * e % n, t >>= z;
431
431
  return r;
432
432
  }
433
433
  function Y(e, t, n) {
@@ -436,27 +436,27 @@ function Y(e, t, n) {
436
436
  r *= r, r %= n;
437
437
  return r;
438
438
  }
439
- function Tt(e, t) {
439
+ function Rt(e, t) {
440
440
  if (e === W || t <= W)
441
441
  throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);
442
- let n = V(e, t), r = t, i = W, s = j;
442
+ let n = V(e, t), r = t, i = W, s = z;
443
443
  for (; n !== W; ) {
444
444
  const c = r / n, a = r % n, l = i - s * c;
445
445
  r = n, n = a, i = s, s = l;
446
446
  }
447
- if (r !== j)
447
+ if (r !== z)
448
448
  throw new Error("invert: does not exist");
449
449
  return V(i, t);
450
450
  }
451
- function Fi(e) {
452
- const t = (e - j) / Ce;
451
+ function Gi(e) {
452
+ const t = (e - z) / Ce;
453
453
  let n, r, i;
454
- for (n = e - j, r = 0; n % Ce === W; n /= Ce, r++)
454
+ for (n = e - z, r = 0; n % Ce === W; n /= Ce, r++)
455
455
  ;
456
- for (i = Ce; i < e && Gi(i, t, e) !== e - j; i++)
456
+ for (i = Ce; i < e && Fi(i, t, e) !== e - z; i++)
457
457
  ;
458
458
  if (r === 1) {
459
- const o = (e + j) / Rt;
459
+ const o = (e + z) / $t;
460
460
  return function(a, l) {
461
461
  const f = a.pow(l, o);
462
462
  if (!a.eql(a.sqr(f), l))
@@ -464,26 +464,26 @@ function Fi(e) {
464
464
  return f;
465
465
  };
466
466
  }
467
- const s = (n + j) / Ce;
467
+ const s = (n + z) / Ce;
468
468
  return function(c, a) {
469
469
  if (c.pow(a, t) === c.neg(c.ONE))
470
470
  throw new Error("Cannot find square root");
471
- let l = r, f = c.pow(c.mul(c.ONE, i), n), u = c.pow(a, s), g = c.pow(a, n);
472
- for (; !c.eql(g, c.ONE); ) {
473
- if (c.eql(g, c.ZERO))
471
+ let l = r, f = c.pow(c.mul(c.ONE, i), n), u = c.pow(a, s), p = c.pow(a, n);
472
+ for (; !c.eql(p, c.ONE); ) {
473
+ if (c.eql(p, c.ZERO))
474
474
  return c.ZERO;
475
475
  let w = 1;
476
- for (let h = c.sqr(g); w < l && !c.eql(h, c.ONE); w++)
476
+ for (let h = c.sqr(p); w < l && !c.eql(h, c.ONE); w++)
477
477
  h = c.sqr(h);
478
- const y = c.pow(f, j << BigInt(l - w - 1));
479
- f = c.sqr(y), u = c.mul(u, y), g = c.mul(g, f), l = w;
478
+ const g = c.pow(f, z << BigInt(l - w - 1));
479
+ f = c.sqr(g), u = c.mul(u, g), p = c.mul(p, f), l = w;
480
480
  }
481
481
  return u;
482
482
  };
483
483
  }
484
484
  function Ji(e) {
485
- if (e % Rt === Zi) {
486
- const t = (e + j) / Rt;
485
+ if (e % $t === Zi) {
486
+ const t = (e + z) / $t;
487
487
  return function(r, i) {
488
488
  const s = r.pow(i, t);
489
489
  if (!r.eql(r.sqr(s), i))
@@ -491,8 +491,8 @@ function Ji(e) {
491
491
  return s;
492
492
  };
493
493
  }
494
- if (e % In === _n) {
495
- const t = (e - _n) / In;
494
+ if (e % _n === In) {
495
+ const t = (e - In) / _n;
496
496
  return function(r, i) {
497
497
  const s = r.mul(i, Ce), o = r.pow(s, t), c = r.mul(i, o), a = r.mul(r.mul(c, Ce), o), l = r.mul(c, r.sub(a, r.ONE));
498
498
  if (!r.eql(r.sqr(l), i))
@@ -500,7 +500,7 @@ function Ji(e) {
500
500
  return l;
501
501
  };
502
502
  }
503
- return Fi(e);
503
+ return Gi(e);
504
504
  }
505
505
  const Yi = [
506
506
  "create",
@@ -535,11 +535,11 @@ function Qi(e, t, n) {
535
535
  throw new Error("Expected power > 0");
536
536
  if (n === W)
537
537
  return e.ONE;
538
- if (n === j)
538
+ if (n === z)
539
539
  return t;
540
540
  let r = e.ONE, i = t;
541
541
  for (; n > W; )
542
- n & j && (r = e.mul(r, i)), i = e.sqr(i), n >>= j;
542
+ n & z && (r = e.mul(r, i)), i = e.sqr(i), n >>= z;
543
543
  return r;
544
544
  }
545
545
  function es(e, t) {
@@ -560,9 +560,9 @@ function ts(e, t, n = !1, r = {}) {
560
560
  ORDER: e,
561
561
  BITS: i,
562
562
  BYTES: s,
563
- MASK: Jt(i),
563
+ MASK: Gt(i),
564
564
  ZERO: W,
565
- ONE: j,
565
+ ONE: z,
566
566
  create: (a) => V(a, e),
567
567
  isValid: (a) => {
568
568
  if (typeof a != "bigint")
@@ -570,7 +570,7 @@ function ts(e, t, n = !1, r = {}) {
570
570
  return W <= a && a < e;
571
571
  },
572
572
  is0: (a) => a === W,
573
- isOdd: (a) => (a & j) === j,
573
+ isOdd: (a) => (a & z) === z,
574
574
  neg: (a) => V(-a, e),
575
575
  eql: (a, l) => a === l,
576
576
  sqr: (a) => V(a * a, e),
@@ -578,23 +578,23 @@ function ts(e, t, n = !1, r = {}) {
578
578
  sub: (a, l) => V(a - l, e),
579
579
  mul: (a, l) => V(a * l, e),
580
580
  pow: (a, l) => Qi(c, a, l),
581
- div: (a, l) => V(a * Tt(l, e), e),
581
+ div: (a, l) => V(a * Rt(l, e), e),
582
582
  // Same as above, but doesn't normalize
583
583
  sqrN: (a) => a * a,
584
584
  addN: (a, l) => a + l,
585
585
  subN: (a, l) => a - l,
586
586
  mulN: (a, l) => a * l,
587
- inv: (a) => Tt(a, e),
587
+ inv: (a) => Rt(a, e),
588
588
  sqrt: r.sqrt || ((a) => o(c, a)),
589
589
  invertBatch: (a) => es(c, a),
590
590
  // TODO: do we really need constant cmov?
591
591
  // We don't have const-time bigints anyway, so probably will be not very useful
592
592
  cmov: (a, l, f) => f ? l : a,
593
- toBytes: (a) => n ? Ft(a, s) : Ne(a, s),
593
+ toBytes: (a) => n ? Ft(a, s) : Ke(a, s),
594
594
  fromBytes: (a) => {
595
595
  if (a.length !== s)
596
596
  throw new Error(`Fp.fromBytes: expected ${s}, got ${a.length}`);
597
- return n ? Gt(a) : F(a);
597
+ return n ? Zt(a) : G(a);
598
598
  }
599
599
  });
600
600
  return Object.freeze(c);
@@ -613,11 +613,11 @@ function ns(e, t, n = !1) {
613
613
  const r = e.length, i = nr(t), s = rr(t);
614
614
  if (r < 16 || r < s || r > 1024)
615
615
  throw new Error(`expected ${s}-1024 bytes of input, got ${r}`);
616
- const o = n ? F(e) : Gt(e), c = V(o, t - j) + j;
617
- return n ? Ft(c, i) : Ne(c, i);
616
+ const o = n ? G(e) : Zt(e), c = V(o, t - z) + z;
617
+ return n ? Ft(c, i) : Ke(c, i);
618
618
  }
619
619
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
620
- const rs = BigInt(0), At = BigInt(1);
620
+ const rs = BigInt(0), St = BigInt(1);
621
621
  function is(e, t) {
622
622
  const n = (i, s) => {
623
623
  const o = s.negate();
@@ -632,7 +632,7 @@ function is(e, t) {
632
632
  unsafeLadder(i, s) {
633
633
  let o = e.ZERO, c = i;
634
634
  for (; s > rs; )
635
- s & At && (o = o.add(c)), c = c.double(), s >>= At;
635
+ s & St && (o = o.add(c)), c = c.double(), s >>= St;
636
636
  return o;
637
637
  },
638
638
  /**
@@ -650,7 +650,7 @@ function is(e, t) {
650
650
  let l = i, f = l;
651
651
  for (let u = 0; u < o; u++) {
652
652
  f = l, a.push(f);
653
- for (let g = 1; g < c; g++)
653
+ for (let p = 1; p < c; p++)
654
654
  f = f.add(l), a.push(f);
655
655
  l = f.double();
656
656
  }
@@ -666,13 +666,13 @@ function is(e, t) {
666
666
  wNAF(i, s, o) {
667
667
  const { windows: c, windowSize: a } = r(i);
668
668
  let l = e.ZERO, f = e.BASE;
669
- const u = BigInt(2 ** i - 1), g = 2 ** i, w = BigInt(i);
670
- for (let y = 0; y < c; y++) {
671
- const h = y * a;
669
+ const u = BigInt(2 ** i - 1), p = 2 ** i, w = BigInt(i);
670
+ for (let g = 0; g < c; g++) {
671
+ const h = g * a;
672
672
  let d = Number(o & u);
673
- o >>= w, d > a && (d -= g, o += At);
674
- const p = h, E = h + Math.abs(d) - 1, S = y % 2 !== 0, I = d < 0;
675
- d === 0 ? f = f.add(n(S, s[p])) : l = l.add(n(I, s[E]));
673
+ o >>= w, d > a && (d -= p, o += St);
674
+ const y = h, E = h + Math.abs(d) - 1, S = g % 2 !== 0, _ = d < 0;
675
+ d === 0 ? f = f.add(n(S, s[y])) : l = l.add(n(_, s[E]));
676
676
  }
677
677
  return { p: l, f };
678
678
  },
@@ -768,65 +768,65 @@ BigInt(2);
768
768
  const Un = BigInt(3);
769
769
  BigInt(4);
770
770
  function cs(e) {
771
- const t = ss(e), { Fp: n } = t, r = t.toBytes || ((y, h, d) => {
772
- const p = h.toAffine();
773
- return _e(Uint8Array.from([4]), n.toBytes(p.x), n.toBytes(p.y));
774
- }), i = t.fromBytes || ((y) => {
775
- const h = y.subarray(1), d = n.fromBytes(h.subarray(0, n.BYTES)), p = n.fromBytes(h.subarray(n.BYTES, 2 * n.BYTES));
776
- return { x: d, y: p };
771
+ const t = ss(e), { Fp: n } = t, r = t.toBytes || ((g, h, d) => {
772
+ const y = h.toAffine();
773
+ return Ie(Uint8Array.from([4]), n.toBytes(y.x), n.toBytes(y.y));
774
+ }), i = t.fromBytes || ((g) => {
775
+ const h = g.subarray(1), d = n.fromBytes(h.subarray(0, n.BYTES)), y = n.fromBytes(h.subarray(n.BYTES, 2 * n.BYTES));
776
+ return { x: d, y };
777
777
  });
778
- function s(y) {
779
- const { a: h, b: d } = t, p = n.sqr(y), E = n.mul(p, y);
780
- return n.add(n.add(E, n.mul(y, h)), d);
778
+ function s(g) {
779
+ const { a: h, b: d } = t, y = n.sqr(g), E = n.mul(y, g);
780
+ return n.add(n.add(E, n.mul(g, h)), d);
781
781
  }
782
782
  if (!n.eql(n.sqr(t.Gy), s(t.Gx)))
783
783
  throw new Error("bad generator point: equation left != right");
784
- function o(y) {
785
- return typeof y == "bigint" && ce < y && y < t.n;
784
+ function o(g) {
785
+ return typeof g == "bigint" && ce < g && g < t.n;
786
786
  }
787
- function c(y) {
788
- if (!o(y))
787
+ function c(g) {
788
+ if (!o(g))
789
789
  throw new Error("Expected valid bigint: 0 < bigint < curve.n");
790
790
  }
791
- function a(y) {
792
- const { allowedPrivateKeyLengths: h, nByteLength: d, wrapPrivateKey: p, n: E } = t;
793
- if (h && typeof y != "bigint") {
794
- if (y instanceof Uint8Array && (y = De(y)), typeof y != "string" || !h.includes(y.length))
791
+ function a(g) {
792
+ const { allowedPrivateKeyLengths: h, nByteLength: d, wrapPrivateKey: y, n: E } = t;
793
+ if (h && typeof g != "bigint") {
794
+ if (g instanceof Uint8Array && (g = De(g)), typeof g != "string" || !h.includes(g.length))
795
795
  throw new Error("Invalid key");
796
- y = y.padStart(d * 2, "0");
796
+ g = g.padStart(d * 2, "0");
797
797
  }
798
798
  let S;
799
799
  try {
800
- S = typeof y == "bigint" ? y : F(Z("private key", y, d));
800
+ S = typeof g == "bigint" ? g : G(Z("private key", g, d));
801
801
  } catch {
802
- throw new Error(`private key must be ${d} bytes, hex or bigint, not ${typeof y}`);
802
+ throw new Error(`private key must be ${d} bytes, hex or bigint, not ${typeof g}`);
803
803
  }
804
- return p && (S = V(S, E)), c(S), S;
804
+ return y && (S = V(S, E)), c(S), S;
805
805
  }
806
806
  const l = /* @__PURE__ */ new Map();
807
- function f(y) {
808
- if (!(y instanceof u))
807
+ function f(g) {
808
+ if (!(g instanceof u))
809
809
  throw new Error("ProjectivePoint expected");
810
810
  }
811
811
  class u {
812
- constructor(h, d, p) {
813
- if (this.px = h, this.py = d, this.pz = p, h == null || !n.isValid(h))
812
+ constructor(h, d, y) {
813
+ if (this.px = h, this.py = d, this.pz = y, h == null || !n.isValid(h))
814
814
  throw new Error("x required");
815
815
  if (d == null || !n.isValid(d))
816
816
  throw new Error("y required");
817
- if (p == null || !n.isValid(p))
817
+ if (y == null || !n.isValid(y))
818
818
  throw new Error("z required");
819
819
  }
820
820
  // Does not validate if the point is on-curve.
821
821
  // Use fromHex instead, or call assertValidity() later.
822
822
  static fromAffine(h) {
823
- const { x: d, y: p } = h || {};
824
- if (!h || !n.isValid(d) || !n.isValid(p))
823
+ const { x: d, y } = h || {};
824
+ if (!h || !n.isValid(d) || !n.isValid(y))
825
825
  throw new Error("invalid affine point");
826
826
  if (h instanceof u)
827
827
  throw new Error("projective point not allowed");
828
828
  const E = (S) => n.eql(S, n.ZERO);
829
- return E(d) && E(p) ? u.ZERO : new u(d, p, n.ONE);
829
+ return E(d) && E(y) ? u.ZERO : new u(d, y, n.ONE);
830
830
  }
831
831
  get x() {
832
832
  return this.toAffine().x;
@@ -841,8 +841,8 @@ function cs(e) {
841
841
  * Optimization: converts a list of projective points to a list of identical points with Z=1.
842
842
  */
843
843
  static normalizeZ(h) {
844
- const d = n.invertBatch(h.map((p) => p.pz));
845
- return h.map((p, E) => p.toAffine(d[E])).map(u.fromAffine);
844
+ const d = n.invertBatch(h.map((y) => y.pz));
845
+ return h.map((y, E) => y.toAffine(d[E])).map(u.fromAffine);
846
846
  }
847
847
  /**
848
848
  * Converts hash string or Uint8Array to Point.
@@ -870,8 +870,8 @@ function cs(e) {
870
870
  const { x: h, y: d } = this.toAffine();
871
871
  if (!n.isValid(h) || !n.isValid(d))
872
872
  throw new Error("bad point: x or y not FE");
873
- const p = n.sqr(d), E = s(h);
874
- if (!n.eql(p, E))
873
+ const y = n.sqr(d), E = s(h);
874
+ if (!n.eql(y, E))
875
875
  throw new Error("bad point: equation left != right");
876
876
  if (!this.isTorsionFree())
877
877
  throw new Error("bad point: not in prime-order subgroup");
@@ -887,7 +887,7 @@ function cs(e) {
887
887
  */
888
888
  equals(h) {
889
889
  f(h);
890
- const { px: d, py: p, pz: E } = this, { px: S, py: I, pz: B } = h, m = n.eql(n.mul(d, B), n.mul(S, E)), x = n.eql(n.mul(p, B), n.mul(I, E));
890
+ const { px: d, py: y, pz: E } = this, { px: S, py: _, pz: B } = h, m = n.eql(n.mul(d, B), n.mul(S, E)), x = n.eql(n.mul(y, B), n.mul(_, E));
891
891
  return m && x;
892
892
  }
893
893
  /**
@@ -901,9 +901,9 @@ function cs(e) {
901
901
  // https://eprint.iacr.org/2015/1060, algorithm 3
902
902
  // Cost: 8M + 3S + 3*a + 2*b3 + 15add.
903
903
  double() {
904
- const { a: h, b: d } = t, p = n.mul(d, Un), { px: E, py: S, pz: I } = this;
905
- let B = n.ZERO, m = n.ZERO, x = n.ZERO, K = n.mul(E, E), M = n.mul(S, S), _ = n.mul(I, I), A = n.mul(E, S);
906
- return A = n.add(A, A), x = n.mul(E, I), x = n.add(x, x), B = n.mul(h, x), m = n.mul(p, _), m = n.add(B, m), B = n.sub(M, m), m = n.add(M, m), m = n.mul(B, m), B = n.mul(A, B), x = n.mul(p, x), _ = n.mul(h, _), A = n.sub(K, _), A = n.mul(h, A), A = n.add(A, x), x = n.add(K, K), K = n.add(x, K), K = n.add(K, _), K = n.mul(K, A), m = n.add(m, K), _ = n.mul(S, I), _ = n.add(_, _), K = n.mul(_, A), B = n.sub(B, K), x = n.mul(_, M), x = n.add(x, x), x = n.add(x, x), new u(B, m, x);
904
+ const { a: h, b: d } = t, y = n.mul(d, Un), { px: E, py: S, pz: _ } = this;
905
+ let B = n.ZERO, m = n.ZERO, x = n.ZERO, N = n.mul(E, E), M = n.mul(S, S), I = n.mul(_, _), A = n.mul(E, S);
906
+ return A = n.add(A, A), x = n.mul(E, _), x = n.add(x, x), B = n.mul(h, x), m = n.mul(y, I), m = n.add(B, m), B = n.sub(M, m), m = n.add(M, m), m = n.mul(B, m), B = n.mul(A, B), x = n.mul(y, x), I = n.mul(h, I), A = n.sub(N, I), A = n.mul(h, A), A = n.add(A, x), x = n.add(N, N), N = n.add(x, N), N = n.add(N, I), N = n.mul(N, A), m = n.add(m, N), I = n.mul(S, _), I = n.add(I, I), N = n.mul(I, A), B = n.sub(B, N), x = n.mul(I, M), x = n.add(x, x), x = n.add(x, x), new u(B, m, x);
907
907
  }
908
908
  // Renes-Costello-Batina exception-free addition formula.
909
909
  // There is 30% faster Jacobian formula, but it is not complete.
@@ -911,13 +911,13 @@ function cs(e) {
911
911
  // Cost: 12M + 0S + 3*a + 3*b3 + 23add.
912
912
  add(h) {
913
913
  f(h);
914
- const { px: d, py: p, pz: E } = this, { px: S, py: I, pz: B } = h;
915
- let m = n.ZERO, x = n.ZERO, K = n.ZERO;
916
- const M = t.a, _ = n.mul(t.b, Un);
917
- let A = n.mul(d, S), R = n.mul(p, I), T = n.mul(E, B), q = n.add(d, p), b = n.add(S, I);
914
+ const { px: d, py: y, pz: E } = this, { px: S, py: _, pz: B } = h;
915
+ let m = n.ZERO, x = n.ZERO, N = n.ZERO;
916
+ const M = t.a, I = n.mul(t.b, Un);
917
+ let A = n.mul(d, S), R = n.mul(y, _), T = n.mul(E, B), q = n.add(d, y), b = n.add(S, _);
918
918
  q = n.mul(q, b), b = n.add(A, R), q = n.sub(q, b), b = n.add(d, E);
919
919
  let v = n.add(S, B);
920
- return b = n.mul(b, v), v = n.add(A, T), b = n.sub(b, v), v = n.add(p, E), m = n.add(I, B), v = n.mul(v, m), m = n.add(R, T), v = n.sub(v, m), K = n.mul(M, b), m = n.mul(_, T), K = n.add(m, K), m = n.sub(R, K), K = n.add(R, K), x = n.mul(m, K), R = n.add(A, A), R = n.add(R, A), T = n.mul(M, T), b = n.mul(_, b), R = n.add(R, T), T = n.sub(A, T), T = n.mul(M, T), b = n.add(b, T), A = n.mul(R, b), x = n.add(x, A), A = n.mul(v, b), m = n.mul(q, m), m = n.sub(m, A), A = n.mul(q, R), K = n.mul(v, K), K = n.add(K, A), new u(m, x, K);
920
+ return b = n.mul(b, v), v = n.add(A, T), b = n.sub(b, v), v = n.add(y, E), m = n.add(_, B), v = n.mul(v, m), m = n.add(R, T), v = n.sub(v, m), N = n.mul(M, b), m = n.mul(I, T), N = n.add(m, N), m = n.sub(R, N), N = n.add(R, N), x = n.mul(m, N), R = n.add(A, A), R = n.add(R, A), T = n.mul(M, T), b = n.mul(I, b), R = n.add(R, T), T = n.sub(A, T), T = n.mul(M, T), b = n.add(b, T), A = n.mul(R, b), x = n.add(x, A), A = n.mul(v, b), m = n.mul(q, m), m = n.sub(m, A), A = n.mul(q, R), N = n.mul(v, N), N = n.add(N, A), new u(m, x, N);
921
921
  }
922
922
  subtract(h) {
923
923
  return this.add(h.negate());
@@ -927,8 +927,8 @@ function cs(e) {
927
927
  }
928
928
  wNAF(h) {
929
929
  return w.wNAFCached(this, l, h, (d) => {
930
- const p = n.invertBatch(d.map((E) => E.pz));
931
- return d.map((E, S) => E.toAffine(p[S])).map(u.fromAffine);
930
+ const y = n.invertBatch(d.map((E) => E.pz));
931
+ return d.map((E, S) => E.toAffine(y[S])).map(u.fromAffine);
932
932
  });
933
933
  }
934
934
  /**
@@ -942,13 +942,13 @@ function cs(e) {
942
942
  return d;
943
943
  if (c(h), h === X)
944
944
  return this;
945
- const { endo: p } = t;
946
- if (!p)
945
+ const { endo: y } = t;
946
+ if (!y)
947
947
  return w.unsafeLadder(this, h);
948
- let { k1neg: E, k1: S, k2neg: I, k2: B } = p.splitScalar(h), m = d, x = d, K = this;
948
+ let { k1neg: E, k1: S, k2neg: _, k2: B } = y.splitScalar(h), m = d, x = d, N = this;
949
949
  for (; S > ce || B > ce; )
950
- S & X && (m = m.add(K)), B & X && (x = x.add(K)), K = K.double(), S >>= X, B >>= X;
951
- return E && (m = m.negate()), I && (x = x.negate()), x = new u(n.mul(x.px, p.beta), x.py, x.pz), m.add(x);
950
+ S & X && (m = m.add(N)), B & X && (x = x.add(N)), N = N.double(), S >>= X, B >>= X;
951
+ return E && (m = m.negate()), _ && (x = x.negate()), x = new u(n.mul(x.px, y.beta), x.py, x.pz), m.add(x);
952
952
  }
953
953
  /**
954
954
  * Constant time multiplication.
@@ -961,17 +961,17 @@ function cs(e) {
961
961
  */
962
962
  multiply(h) {
963
963
  c(h);
964
- let d = h, p, E;
964
+ let d = h, y, E;
965
965
  const { endo: S } = t;
966
966
  if (S) {
967
- const { k1neg: I, k1: B, k2neg: m, k2: x } = S.splitScalar(d);
968
- let { p: K, f: M } = this.wNAF(B), { p: _, f: A } = this.wNAF(x);
969
- K = w.constTimeNegate(I, K), _ = w.constTimeNegate(m, _), _ = new u(n.mul(_.px, S.beta), _.py, _.pz), p = K.add(_), E = M.add(A);
967
+ const { k1neg: _, k1: B, k2neg: m, k2: x } = S.splitScalar(d);
968
+ let { p: N, f: M } = this.wNAF(B), { p: I, f: A } = this.wNAF(x);
969
+ N = w.constTimeNegate(_, N), I = w.constTimeNegate(m, I), I = new u(n.mul(I.px, S.beta), I.py, I.pz), y = N.add(I), E = M.add(A);
970
970
  } else {
971
- const { p: I, f: B } = this.wNAF(d);
972
- p = I, E = B;
971
+ const { p: _, f: B } = this.wNAF(d);
972
+ y = _, E = B;
973
973
  }
974
- return u.normalizeZ([p, E])[0];
974
+ return u.normalizeZ([y, E])[0];
975
975
  }
976
976
  /**
977
977
  * Efficiently calculate `aP + bQ`. Unsafe, can expose private key, if used incorrectly.
@@ -979,22 +979,22 @@ function cs(e) {
979
979
  * The trick could be useful if both P and Q are not G (not in our case).
980
980
  * @returns non-zero affine point
981
981
  */
982
- multiplyAndAddUnsafe(h, d, p) {
983
- const E = u.BASE, S = (B, m) => m === ce || m === X || !B.equals(E) ? B.multiplyUnsafe(m) : B.multiply(m), I = S(this, d).add(S(h, p));
984
- return I.is0() ? void 0 : I;
982
+ multiplyAndAddUnsafe(h, d, y) {
983
+ const E = u.BASE, S = (B, m) => m === ce || m === X || !B.equals(E) ? B.multiplyUnsafe(m) : B.multiply(m), _ = S(this, d).add(S(h, y));
984
+ return _.is0() ? void 0 : _;
985
985
  }
986
986
  // Converts Projective point to affine (x, y) coordinates.
987
987
  // Can accept precomputed Z^-1 - for example, from invertBatch.
988
988
  // (x, y, z) ∋ (x=x/z, y=y/z)
989
989
  toAffine(h) {
990
- const { px: d, py: p, pz: E } = this, S = this.is0();
990
+ const { px: d, py: y, pz: E } = this, S = this.is0();
991
991
  h == null && (h = S ? n.ONE : n.inv(E));
992
- const I = n.mul(d, h), B = n.mul(p, h), m = n.mul(E, h);
992
+ const _ = n.mul(d, h), B = n.mul(y, h), m = n.mul(E, h);
993
993
  if (S)
994
994
  return { x: n.ZERO, y: n.ZERO };
995
995
  if (!n.eql(m, n.ONE))
996
996
  throw new Error("invZ was invalid");
997
- return { x: I, y: B };
997
+ return { x: _, y: B };
998
998
  }
999
999
  isTorsionFree() {
1000
1000
  const { h, isTorsionFree: d } = t;
@@ -1016,7 +1016,7 @@ function cs(e) {
1016
1016
  }
1017
1017
  }
1018
1018
  u.BASE = new u(t.Gx, t.Gy, n.ONE), u.ZERO = new u(n.ZERO, n.ONE, n.ZERO);
1019
- const g = t.nBitLength, w = is(u, t.endo ? Math.ceil(g / 2) : g);
1019
+ const p = t.nBitLength, w = is(u, t.endo ? Math.ceil(p / 2) : p);
1020
1020
  return {
1021
1021
  CURVE: t,
1022
1022
  ProjectivePoint: u,
@@ -1046,68 +1046,68 @@ function ls(e) {
1046
1046
  return V(b, r);
1047
1047
  }
1048
1048
  function a(b) {
1049
- return Tt(b, r);
1049
+ return Rt(b, r);
1050
1050
  }
1051
- const { ProjectivePoint: l, normPrivateKeyToScalar: f, weierstrassEquation: u, isWithinCurveOrder: g } = cs({
1051
+ const { ProjectivePoint: l, normPrivateKeyToScalar: f, weierstrassEquation: u, isWithinCurveOrder: p } = cs({
1052
1052
  ...t,
1053
- toBytes(b, v, N) {
1054
- const k = v.toAffine(), C = n.toBytes(k.x), U = _e;
1055
- return N ? U(Uint8Array.from([v.hasEvenY() ? 2 : 3]), C) : U(Uint8Array.from([4]), C, n.toBytes(k.y));
1053
+ toBytes(b, v, K) {
1054
+ const k = v.toAffine(), C = n.toBytes(k.x), U = Ie;
1055
+ return K ? U(Uint8Array.from([v.hasEvenY() ? 2 : 3]), C) : U(Uint8Array.from([4]), C, n.toBytes(k.y));
1056
1056
  },
1057
1057
  fromBytes(b) {
1058
- const v = b.length, N = b[0], k = b.subarray(1);
1059
- if (v === i && (N === 2 || N === 3)) {
1060
- const C = F(k);
1058
+ const v = b.length, K = b[0], k = b.subarray(1);
1059
+ if (v === i && (K === 2 || K === 3)) {
1060
+ const C = G(k);
1061
1061
  if (!o(C))
1062
1062
  throw new Error("Point is not on curve");
1063
1063
  const U = u(C);
1064
1064
  let O = n.sqrt(U);
1065
1065
  const $ = (O & X) === X;
1066
- return (N & 1) === 1 !== $ && (O = n.neg(O)), { x: C, y: O };
1067
- } else if (v === s && N === 4) {
1066
+ return (K & 1) === 1 !== $ && (O = n.neg(O)), { x: C, y: O };
1067
+ } else if (v === s && K === 4) {
1068
1068
  const C = n.fromBytes(k.subarray(0, n.BYTES)), U = n.fromBytes(k.subarray(n.BYTES, 2 * n.BYTES));
1069
1069
  return { x: C, y: U };
1070
1070
  } else
1071
1071
  throw new Error(`Point of length ${v} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`);
1072
1072
  }
1073
- }), w = (b) => De(Ne(b, t.nByteLength));
1074
- function y(b) {
1073
+ }), w = (b) => De(Ke(b, t.nByteLength));
1074
+ function g(b) {
1075
1075
  const v = r >> X;
1076
1076
  return b > v;
1077
1077
  }
1078
1078
  function h(b) {
1079
- return y(b) ? c(-b) : b;
1079
+ return g(b) ? c(-b) : b;
1080
1080
  }
1081
- const d = (b, v, N) => F(b.slice(v, N));
1082
- class p {
1083
- constructor(v, N, k) {
1084
- this.r = v, this.s = N, this.recovery = k, this.assertValidity();
1081
+ const d = (b, v, K) => G(b.slice(v, K));
1082
+ class y {
1083
+ constructor(v, K, k) {
1084
+ this.r = v, this.s = K, this.recovery = k, this.assertValidity();
1085
1085
  }
1086
1086
  // pair (bytes of r, bytes of s)
1087
1087
  static fromCompact(v) {
1088
- const N = t.nByteLength;
1089
- return v = Z("compactSignature", v, N * 2), new p(d(v, 0, N), d(v, N, 2 * N));
1088
+ const K = t.nByteLength;
1089
+ return v = Z("compactSignature", v, K * 2), new y(d(v, 0, K), d(v, K, 2 * K));
1090
1090
  }
1091
1091
  // DER encoded ECDSA signature
1092
1092
  // https://bitcoin.stackexchange.com/questions/57644/what-are-the-parts-of-a-bitcoin-transaction-input-script
1093
1093
  static fromDER(v) {
1094
- const { r: N, s: k } = Be.toSig(Z("DER", v));
1095
- return new p(N, k);
1094
+ const { r: K, s: k } = Be.toSig(Z("DER", v));
1095
+ return new y(K, k);
1096
1096
  }
1097
1097
  assertValidity() {
1098
- if (!g(this.r))
1098
+ if (!p(this.r))
1099
1099
  throw new Error("r must be 0 < r < CURVE.n");
1100
- if (!g(this.s))
1100
+ if (!p(this.s))
1101
1101
  throw new Error("s must be 0 < s < CURVE.n");
1102
1102
  }
1103
1103
  addRecoveryBit(v) {
1104
- return new p(this.r, this.s, v);
1104
+ return new y(this.r, this.s, v);
1105
1105
  }
1106
1106
  recoverPublicKey(v) {
1107
- const { r: N, s: k, recovery: C } = this, U = x(Z("msgHash", v));
1107
+ const { r: K, s: k, recovery: C } = this, U = x(Z("msgHash", v));
1108
1108
  if (C == null || ![0, 1, 2, 3].includes(C))
1109
1109
  throw new Error("recovery id invalid");
1110
- const O = C === 2 || C === 3 ? N + t.n : N;
1110
+ const O = C === 2 || C === 3 ? K + t.n : K;
1111
1111
  if (O >= n.ORDER)
1112
1112
  throw new Error("recovery id 2 or 3 invalid");
1113
1113
  const $ = (C & 1) === 0 ? "02" : "03", ee = l.fromHex($ + w(O)), ge = a(O), Ue = c(-U * ge), Ve = c(k * ge), we = l.BASE.multiplyAndAddUnsafe(ee, Ue, Ve);
@@ -1117,10 +1117,10 @@ function ls(e) {
1117
1117
  }
1118
1118
  // Signatures should be low-s, to prevent malleability.
1119
1119
  hasHighS() {
1120
- return y(this.s);
1120
+ return g(this.s);
1121
1121
  }
1122
1122
  normalizeS() {
1123
- return this.hasHighS() ? new p(this.r, c(-this.s), this.recovery) : this;
1123
+ return this.hasHighS() ? new y(this.r, c(-this.s), this.recovery) : this;
1124
1124
  }
1125
1125
  // DER-encoded
1126
1126
  toDERRawBytes() {
@@ -1169,45 +1169,45 @@ function ls(e) {
1169
1169
  function S(b, v = !0) {
1170
1170
  return l.fromPrivateKey(b).toRawBytes(v);
1171
1171
  }
1172
- function I(b) {
1173
- const v = b instanceof Uint8Array, N = typeof b == "string", k = (v || N) && b.length;
1174
- return v ? k === i || k === s : N ? k === 2 * i || k === 2 * s : b instanceof l;
1172
+ function _(b) {
1173
+ const v = b instanceof Uint8Array, K = typeof b == "string", k = (v || K) && b.length;
1174
+ return v ? k === i || k === s : K ? k === 2 * i || k === 2 * s : b instanceof l;
1175
1175
  }
1176
- function B(b, v, N = !0) {
1177
- if (I(b))
1176
+ function B(b, v, K = !0) {
1177
+ if (_(b))
1178
1178
  throw new Error("first arg must be private key");
1179
- if (!I(v))
1179
+ if (!_(v))
1180
1180
  throw new Error("second arg must be public key");
1181
- return l.fromHex(v).multiply(f(b)).toRawBytes(N);
1181
+ return l.fromHex(v).multiply(f(b)).toRawBytes(K);
1182
1182
  }
1183
1183
  const m = t.bits2int || function(b) {
1184
- const v = F(b), N = b.length * 8 - t.nBitLength;
1185
- return N > 0 ? v >> BigInt(N) : v;
1184
+ const v = G(b), K = b.length * 8 - t.nBitLength;
1185
+ return K > 0 ? v >> BigInt(K) : v;
1186
1186
  }, x = t.bits2int_modN || function(b) {
1187
1187
  return c(m(b));
1188
- }, K = Jt(t.nBitLength);
1188
+ }, N = Gt(t.nBitLength);
1189
1189
  function M(b) {
1190
1190
  if (typeof b != "bigint")
1191
1191
  throw new Error("bigint expected");
1192
- if (!(ce <= b && b < K))
1192
+ if (!(ce <= b && b < N))
1193
1193
  throw new Error(`bigint expected < 2^${t.nBitLength}`);
1194
- return Ne(b, t.nByteLength);
1194
+ return Ke(b, t.nByteLength);
1195
1195
  }
1196
- function _(b, v, N = A) {
1197
- if (["recovered", "canonical"].some((Ae) => Ae in N))
1196
+ function I(b, v, K = A) {
1197
+ if (["recovered", "canonical"].some((Ae) => Ae in K))
1198
1198
  throw new Error("sign() legacy options not supported");
1199
1199
  const { hash: k, randomBytes: C } = t;
1200
- let { lowS: U, prehash: O, extraEntropy: $ } = N;
1200
+ let { lowS: U, prehash: O, extraEntropy: $ } = K;
1201
1201
  U == null && (U = !0), b = Z("msgHash", b), O && (b = Z("prehashed msgHash", k(b)));
1202
1202
  const ee = x(b), ge = f(v), Ue = [M(ge), M(ee)];
1203
1203
  if ($ != null) {
1204
1204
  const Ae = $ === !0 ? C(n.BYTES) : $;
1205
1205
  Ue.push(Z("extraEntropy", Ae));
1206
1206
  }
1207
- const Ve = _e(...Ue), we = ee;
1208
- function xt(Ae) {
1207
+ const Ve = Ie(...Ue), we = ee;
1208
+ function Et(Ae) {
1209
1209
  const Le = m(Ae);
1210
- if (!g(Le))
1210
+ if (!p(Le))
1211
1211
  return;
1212
1212
  const Sn = a(Le), $e = l.BASE.multiply(Le).toAffine(), te = c($e.x);
1213
1213
  if (te === ce)
@@ -1216,38 +1216,38 @@ function ls(e) {
1216
1216
  if (Re === ce)
1217
1217
  return;
1218
1218
  let An = ($e.x === te ? 0 : 2) | Number($e.y & X), Cn = Re;
1219
- return U && y(Re) && (Cn = h(Re), An ^= 1), new p(te, Cn, An);
1219
+ return U && g(Re) && (Cn = h(Re), An ^= 1), new y(te, Cn, An);
1220
1220
  }
1221
- return { seed: Ve, k2sig: xt };
1221
+ return { seed: Ve, k2sig: Et };
1222
1222
  }
1223
1223
  const A = { lowS: t.lowS, prehash: !1 }, R = { lowS: t.lowS, prehash: !1 };
1224
- function T(b, v, N = A) {
1225
- const { seed: k, k2sig: C } = _(b, v, N), U = t;
1224
+ function T(b, v, K = A) {
1225
+ const { seed: k, k2sig: C } = I(b, v, K), U = t;
1226
1226
  return er(U.hash.outputLen, U.nByteLength, U.hmac)(k, C);
1227
1227
  }
1228
1228
  l.BASE._setWindowSize(8);
1229
- function q(b, v, N, k = R) {
1229
+ function q(b, v, K, k = R) {
1230
1230
  var $e;
1231
1231
  const C = b;
1232
- if (v = Z("msgHash", v), N = Z("publicKey", N), "strict" in k)
1232
+ if (v = Z("msgHash", v), K = Z("publicKey", K), "strict" in k)
1233
1233
  throw new Error("options.strict was renamed to lowS");
1234
1234
  const { lowS: U, prehash: O } = k;
1235
1235
  let $, ee;
1236
1236
  try {
1237
1237
  if (typeof C == "string" || C instanceof Uint8Array)
1238
1238
  try {
1239
- $ = p.fromDER(C);
1239
+ $ = y.fromDER(C);
1240
1240
  } catch (te) {
1241
1241
  if (!(te instanceof Be.Err))
1242
1242
  throw te;
1243
- $ = p.fromCompact(C);
1243
+ $ = y.fromCompact(C);
1244
1244
  }
1245
1245
  else if (typeof C == "object" && typeof C.r == "bigint" && typeof C.s == "bigint") {
1246
1246
  const { r: te, s: Re } = C;
1247
- $ = new p(te, Re);
1247
+ $ = new y(te, Re);
1248
1248
  } else
1249
1249
  throw new Error("PARSE");
1250
- ee = l.fromHex(N);
1250
+ ee = l.fromHex(K);
1251
1251
  } catch (te) {
1252
1252
  if (te.message === "PARSE")
1253
1253
  throw new Error("signature must be Signature instance, Uint8Array or hex string");
@@ -1256,7 +1256,7 @@ function ls(e) {
1256
1256
  if (U && $.hasHighS())
1257
1257
  return !1;
1258
1258
  O && (v = t.hash(v));
1259
- const { r: ge, s: Ue } = $, Ve = x(v), we = a(Ue), xt = c(Ve * we), Ae = c(ge * we), Le = ($e = l.BASE.multiplyAndAddUnsafe(ee, xt, Ae)) == null ? void 0 : $e.toAffine();
1259
+ const { r: ge, s: Ue } = $, Ve = x(v), we = a(Ue), Et = c(Ve * we), Ae = c(ge * we), Le = ($e = l.BASE.multiplyAndAddUnsafe(ee, Et, Ae)) == null ? void 0 : $e.toAffine();
1260
1260
  return Le ? c(Le.x) === ge : !1;
1261
1261
  }
1262
1262
  return {
@@ -1266,14 +1266,14 @@ function ls(e) {
1266
1266
  sign: T,
1267
1267
  verify: q,
1268
1268
  ProjectivePoint: l,
1269
- Signature: p,
1269
+ Signature: y,
1270
1270
  utils: E
1271
1271
  };
1272
1272
  }
1273
1273
  let sr = class extends Jn {
1274
1274
  constructor(t, n) {
1275
1275
  super(), this.finished = !1, this.destroyed = !1, Si(t);
1276
- const r = Vt(n);
1276
+ const r = Wt(n);
1277
1277
  if (this.iHash = t.create(), typeof this.iHash.update != "function")
1278
1278
  throw new Error("Expected instance of class which extends utils.Hash");
1279
1279
  this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
@@ -1290,7 +1290,7 @@ let sr = class extends Jn {
1290
1290
  return et(this), this.iHash.update(t), this;
1291
1291
  }
1292
1292
  digestInto(t) {
1293
- et(this), Gn(t, this.outputLen), this.finished = !0, this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy();
1293
+ et(this), Fn(t, this.outputLen), this.finished = !0, this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy();
1294
1294
  }
1295
1295
  digest() {
1296
1296
  const t = new Uint8Array(this.oHash.outputLen);
@@ -1322,15 +1322,15 @@ function hs(e, t) {
1322
1322
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
1323
1323
  const ut = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"), tt = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"), ar = BigInt(1), nt = BigInt(2), Ln = (e, t) => (e + t / nt) / t;
1324
1324
  function cr(e) {
1325
- const t = ut, n = BigInt(3), r = BigInt(6), i = BigInt(11), s = BigInt(22), o = BigInt(23), c = BigInt(44), a = BigInt(88), l = e * e * e % t, f = l * l * e % t, u = Y(f, n, t) * f % t, g = Y(u, n, t) * f % t, w = Y(g, nt, t) * l % t, y = Y(w, i, t) * w % t, h = Y(y, s, t) * y % t, d = Y(h, c, t) * h % t, p = Y(d, a, t) * d % t, E = Y(p, c, t) * h % t, S = Y(E, n, t) * f % t, I = Y(S, o, t) * y % t, B = Y(I, r, t) * l % t, m = Y(B, nt, t);
1326
- if (!Ot.eql(Ot.sqr(m), e))
1325
+ const t = ut, n = BigInt(3), r = BigInt(6), i = BigInt(11), s = BigInt(22), o = BigInt(23), c = BigInt(44), a = BigInt(88), l = e * e * e % t, f = l * l * e % t, u = Y(f, n, t) * f % t, p = Y(u, n, t) * f % t, w = Y(p, nt, t) * l % t, g = Y(w, i, t) * w % t, h = Y(g, s, t) * g % t, d = Y(h, c, t) * h % t, y = Y(d, a, t) * d % t, E = Y(y, c, t) * h % t, S = Y(E, n, t) * f % t, _ = Y(S, o, t) * g % t, B = Y(_, r, t) * l % t, m = Y(B, nt, t);
1326
+ if (!Tt.eql(Tt.sqr(m), e))
1327
1327
  throw new Error("Cannot find square root");
1328
1328
  return m;
1329
1329
  }
1330
- const Ot = ts(ut, void 0, void 0, { sqrt: cr }), Ie = hs({
1330
+ const Tt = ts(ut, void 0, void 0, { sqrt: cr }), _e = hs({
1331
1331
  a: BigInt(0),
1332
1332
  b: BigInt(7),
1333
- Fp: Ot,
1333
+ Fp: Tt,
1334
1334
  n: tt,
1335
1335
  // Base point (x, y) aka generator point
1336
1336
  Gx: BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),
@@ -1348,60 +1348,60 @@ const Ot = ts(ut, void 0, void 0, { sqrt: cr }), Ie = hs({
1348
1348
  splitScalar: (e) => {
1349
1349
  const t = tt, n = BigInt("0x3086d221a7d46bcde86c90e49284eb15"), r = -ar * BigInt("0xe4437ed6010e88286f547fa90abfe4c3"), i = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), s = n, o = BigInt("0x100000000000000000000000000000000"), c = Ln(s * e, t), a = Ln(-r * e, t);
1350
1350
  let l = V(e - c * n - a * i, t), f = V(-c * r - a * s, t);
1351
- const u = l > o, g = f > o;
1352
- if (u && (l = t - l), g && (f = t - f), l > o || f > o)
1351
+ const u = l > o, p = f > o;
1352
+ if (u && (l = t - l), p && (f = t - f), l > o || f > o)
1353
1353
  throw new Error("splitScalar: Endomorphism failed, k=" + e);
1354
- return { k1neg: u, k1: l, k2neg: g, k2: f };
1354
+ return { k1neg: u, k1: l, k2neg: p, k2: f };
1355
1355
  }
1356
1356
  }
1357
- }, $t), lt = BigInt(0), ur = (e) => typeof e == "bigint" && lt < e && e < ut, ds = (e) => typeof e == "bigint" && lt < e && e < tt, $n = {};
1357
+ }, Lt), lt = BigInt(0), ur = (e) => typeof e == "bigint" && lt < e && e < ut, ds = (e) => typeof e == "bigint" && lt < e && e < tt, $n = {};
1358
1358
  function rt(e, ...t) {
1359
1359
  let n = $n[e];
1360
1360
  if (n === void 0) {
1361
- const r = $t(Uint8Array.from(e, (i) => i.charCodeAt(0)));
1362
- n = _e(r, r), $n[e] = n;
1361
+ const r = Lt(Uint8Array.from(e, (i) => i.charCodeAt(0)));
1362
+ n = Ie(r, r), $n[e] = n;
1363
1363
  }
1364
- return $t(_e(n, ...t));
1364
+ return Lt(Ie(n, ...t));
1365
1365
  }
1366
- const Yt = (e) => e.toRawBytes(!0).slice(1), Mt = (e) => Ne(e, 32), Ct = (e) => V(e, ut), Fe = (e) => V(e, tt), Xt = Ie.ProjectivePoint, ps = (e, t, n) => Xt.BASE.multiplyAndAddUnsafe(e, t, n);
1367
- function Pt(e) {
1368
- let t = Ie.utils.normPrivateKeyToScalar(e), n = Xt.fromPrivateKey(t);
1369
- return { scalar: n.hasEvenY() ? t : Fe(-t), bytes: Yt(n) };
1366
+ const Jt = (e) => e.toRawBytes(!0).slice(1), Ot = (e) => Ke(e, 32), At = (e) => V(e, ut), Ge = (e) => V(e, tt), Yt = _e.ProjectivePoint, ps = (e, t, n) => Yt.BASE.multiplyAndAddUnsafe(e, t, n);
1367
+ function Mt(e) {
1368
+ let t = _e.utils.normPrivateKeyToScalar(e), n = Yt.fromPrivateKey(t);
1369
+ return { scalar: n.hasEvenY() ? t : Ge(-t), bytes: Jt(n) };
1370
1370
  }
1371
1371
  function lr(e) {
1372
1372
  if (!ur(e))
1373
1373
  throw new Error("bad x: need 0 < x < p");
1374
- const t = Ct(e * e), n = Ct(t * e + BigInt(7));
1374
+ const t = At(e * e), n = At(t * e + BigInt(7));
1375
1375
  let r = cr(n);
1376
- r % nt !== lt && (r = Ct(-r));
1377
- const i = new Xt(e, r, ar);
1376
+ r % nt !== lt && (r = At(-r));
1377
+ const i = new Yt(e, r, ar);
1378
1378
  return i.assertValidity(), i;
1379
1379
  }
1380
1380
  function fr(...e) {
1381
- return Fe(F(rt("BIP0340/challenge", ...e)));
1381
+ return Ge(G(rt("BIP0340/challenge", ...e)));
1382
1382
  }
1383
1383
  function ys(e) {
1384
- return Pt(e).bytes;
1384
+ return Mt(e).bytes;
1385
1385
  }
1386
1386
  function gs(e, t, n = Yn(32)) {
1387
- const r = Z("message", e), { bytes: i, scalar: s } = Pt(t), o = Z("auxRand", n, 32), c = Mt(s ^ F(rt("BIP0340/aux", o))), a = rt("BIP0340/nonce", c, i, r), l = Fe(F(a));
1387
+ const r = Z("message", e), { bytes: i, scalar: s } = Mt(t), o = Z("auxRand", n, 32), c = Ot(s ^ G(rt("BIP0340/aux", o))), a = rt("BIP0340/nonce", c, i, r), l = Ge(G(a));
1388
1388
  if (l === lt)
1389
1389
  throw new Error("sign failed: k is zero");
1390
- const { bytes: f, scalar: u } = Pt(l), g = fr(f, i, r), w = new Uint8Array(64);
1391
- if (w.set(f, 0), w.set(Mt(Fe(u + g * s)), 32), !hr(w, r, i))
1390
+ const { bytes: f, scalar: u } = Mt(l), p = fr(f, i, r), w = new Uint8Array(64);
1391
+ if (w.set(f, 0), w.set(Ot(Ge(u + p * s)), 32), !hr(w, r, i))
1392
1392
  throw new Error("sign: Invalid signature produced");
1393
1393
  return w;
1394
1394
  }
1395
1395
  function hr(e, t, n) {
1396
1396
  const r = Z("signature", e, 64), i = Z("message", t), s = Z("publicKey", n, 32);
1397
1397
  try {
1398
- const o = lr(F(s)), c = F(r.subarray(0, 32));
1398
+ const o = lr(G(s)), c = G(r.subarray(0, 32));
1399
1399
  if (!ur(c))
1400
1400
  return !1;
1401
- const a = F(r.subarray(32, 64));
1401
+ const a = G(r.subarray(32, 64));
1402
1402
  if (!ds(a))
1403
1403
  return !1;
1404
- const l = fr(Mt(c), Yt(o), i), f = ps(o, a, Fe(-l));
1404
+ const l = fr(Ot(c), Jt(o), i), f = ps(o, a, Ge(-l));
1405
1405
  return !(!f || !f.hasEvenY() || f.toAffine().x !== c);
1406
1406
  } catch {
1407
1407
  return !1;
@@ -1412,29 +1412,29 @@ const Ze = {
1412
1412
  sign: gs,
1413
1413
  verify: hr,
1414
1414
  utils: {
1415
- randomPrivateKey: Ie.utils.randomPrivateKey,
1415
+ randomPrivateKey: _e.utils.randomPrivateKey,
1416
1416
  lift_x: lr,
1417
- pointToBytes: Yt,
1418
- numberToBytesBE: Ne,
1419
- bytesToNumberBE: F,
1417
+ pointToBytes: Jt,
1418
+ numberToBytesBE: Ke,
1419
+ bytesToNumberBE: G,
1420
1420
  taggedHash: rt,
1421
1421
  mod: V
1422
1422
  }
1423
- }, Bt = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
1423
+ }, Ct = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
1424
1424
  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
1425
- const Qt = (e) => e instanceof Uint8Array, kt = (e) => new DataView(e.buffer, e.byteOffset, e.byteLength), ie = (e, t) => e << 32 - t | e >>> t, ws = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
1425
+ const Xt = (e) => e instanceof Uint8Array, Bt = (e) => new DataView(e.buffer, e.byteOffset, e.byteLength), ie = (e, t) => e << 32 - t | e >>> t, ws = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
1426
1426
  if (!ws)
1427
1427
  throw new Error("Non little-endian hardware is not supported");
1428
1428
  const bs = Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
1429
- function H(e) {
1430
- if (!Qt(e))
1429
+ function P(e) {
1430
+ if (!Xt(e))
1431
1431
  throw new Error("Uint8Array expected");
1432
1432
  let t = "";
1433
1433
  for (let n = 0; n < e.length; n++)
1434
1434
  t += bs[e[n]];
1435
1435
  return t;
1436
1436
  }
1437
- function z(e) {
1437
+ function j(e) {
1438
1438
  if (typeof e != "string")
1439
1439
  throw new Error("hex string expected, got " + typeof e);
1440
1440
  const t = e.length;
@@ -1455,7 +1455,7 @@ function vs(e) {
1455
1455
  return new Uint8Array(new TextEncoder().encode(e));
1456
1456
  }
1457
1457
  function Je(e) {
1458
- if (typeof e == "string" && (e = vs(e)), !Qt(e))
1458
+ if (typeof e == "string" && (e = vs(e)), !Xt(e))
1459
1459
  throw new Error(`expected Uint8Array, got ${typeof e}`);
1460
1460
  return e;
1461
1461
  }
@@ -1463,7 +1463,7 @@ function ft(...e) {
1463
1463
  const t = new Uint8Array(e.reduce((r, i) => r + i.length, 0));
1464
1464
  let n = 0;
1465
1465
  return e.forEach((r) => {
1466
- if (!Qt(r))
1466
+ if (!Xt(r))
1467
1467
  throw new Error("Uint8Array expected");
1468
1468
  t.set(r, n), n += r.length;
1469
1469
  }), t;
@@ -1479,11 +1479,11 @@ function pr(e) {
1479
1479
  return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = () => e(), t;
1480
1480
  }
1481
1481
  function yr(e = 32) {
1482
- if (Bt && typeof Bt.getRandomValues == "function")
1483
- return Bt.getRandomValues(new Uint8Array(e));
1482
+ if (Ct && typeof Ct.getRandomValues == "function")
1483
+ return Ct.getRandomValues(new Uint8Array(e));
1484
1484
  throw new Error("crypto.getRandomValues must be defined");
1485
1485
  }
1486
- function Ht(e) {
1486
+ function Pt(e) {
1487
1487
  if (!Number.isSafeInteger(e) || e < 0)
1488
1488
  throw new Error(`Wrong positive integer: ${e}`);
1489
1489
  }
@@ -1500,7 +1500,7 @@ function gr(e, ...t) {
1500
1500
  function Es(e) {
1501
1501
  if (typeof e != "function" || typeof e.create != "function")
1502
1502
  throw new Error("Hash should be wrapped by utils.wrapConstructor");
1503
- Ht(e.outputLen), Ht(e.blockLen);
1503
+ Pt(e.outputLen), Pt(e.blockLen);
1504
1504
  }
1505
1505
  function xs(e, t = !0) {
1506
1506
  if (e.destroyed)
@@ -1508,21 +1508,21 @@ function xs(e, t = !0) {
1508
1508
  if (t && e.finished)
1509
1509
  throw new Error("Hash#digest() has already been called");
1510
1510
  }
1511
- function Ks(e, t) {
1511
+ function Ns(e, t) {
1512
1512
  gr(e);
1513
1513
  const n = t.outputLen;
1514
1514
  if (e.length < n)
1515
1515
  throw new Error(`digestInto() expects output buffer of length at least ${n}`);
1516
1516
  }
1517
1517
  const se = {
1518
- number: Ht,
1518
+ number: Pt,
1519
1519
  bool: ms,
1520
1520
  bytes: gr,
1521
1521
  hash: Es,
1522
1522
  exists: xs,
1523
- output: Ks
1523
+ output: Ns
1524
1524
  };
1525
- function Ns(e, t, n, r) {
1525
+ function Ks(e, t, n, r) {
1526
1526
  if (typeof e.setBigUint64 == "function")
1527
1527
  return e.setBigUint64(t, n, r);
1528
1528
  const i = BigInt(32), s = BigInt(4294967295), o = Number(n >> i & s), c = Number(n & s), a = r ? 4 : 0, l = r ? 0 : 4;
@@ -1530,7 +1530,7 @@ function Ns(e, t, n, r) {
1530
1530
  }
1531
1531
  class Ss extends dr {
1532
1532
  constructor(t, n, r, i) {
1533
- super(), this.blockLen = t, this.outputLen = n, this.padOffset = r, this.isLE = i, this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.buffer = new Uint8Array(t), this.view = kt(this.buffer);
1533
+ super(), this.blockLen = t, this.outputLen = n, this.padOffset = r, this.isLE = i, this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.buffer = new Uint8Array(t), this.view = Bt(this.buffer);
1534
1534
  }
1535
1535
  update(t) {
1536
1536
  se.exists(this);
@@ -1540,7 +1540,7 @@ class Ss extends dr {
1540
1540
  for (let o = 0; o < s; ) {
1541
1541
  const c = Math.min(i - this.pos, s - o);
1542
1542
  if (c === i) {
1543
- const a = kt(t);
1543
+ const a = Bt(t);
1544
1544
  for (; i <= s - o; o += i)
1545
1545
  this.process(a, o);
1546
1546
  continue;
@@ -1556,8 +1556,8 @@ class Ss extends dr {
1556
1556
  n[o++] = 128, this.buffer.subarray(o).fill(0), this.padOffset > i - o && (this.process(r, 0), o = 0);
1557
1557
  for (let u = o; u < i; u++)
1558
1558
  n[u] = 0;
1559
- Ns(r, i - 8, BigInt(this.length * 8), s), this.process(r, 0);
1560
- const c = kt(t), a = this.outputLen;
1559
+ Ks(r, i - 8, BigInt(this.length * 8), s), this.process(r, 0);
1560
+ const c = Bt(t), a = this.outputLen;
1561
1561
  if (a % 4)
1562
1562
  throw new Error("_sha2: outputLen should be aligned to 32bit");
1563
1563
  const l = a / 4, f = this.get();
@@ -1669,12 +1669,12 @@ class wr extends Ss {
1669
1669
  for (let u = 0; u < 16; u++, n += 4)
1670
1670
  Ee[u] = t.getUint32(n, !1);
1671
1671
  for (let u = 16; u < 64; u++) {
1672
- const g = Ee[u - 15], w = Ee[u - 2], y = ie(g, 7) ^ ie(g, 18) ^ g >>> 3, h = ie(w, 17) ^ ie(w, 19) ^ w >>> 10;
1673
- Ee[u] = h + Ee[u - 7] + y + Ee[u - 16] | 0;
1672
+ const p = Ee[u - 15], w = Ee[u - 2], g = ie(p, 7) ^ ie(p, 18) ^ p >>> 3, h = ie(w, 17) ^ ie(w, 19) ^ w >>> 10;
1673
+ Ee[u] = h + Ee[u - 7] + g + Ee[u - 16] | 0;
1674
1674
  }
1675
1675
  let { A: r, B: i, C: s, D: o, E: c, F: a, G: l, H: f } = this;
1676
1676
  for (let u = 0; u < 64; u++) {
1677
- const g = ie(c, 6) ^ ie(c, 11) ^ ie(c, 25), w = f + g + As(c, a, l) + Bs[u] + Ee[u] | 0, h = (ie(r, 2) ^ ie(r, 13) ^ ie(r, 22)) + Cs(r, i, s) | 0;
1677
+ const p = ie(c, 6) ^ ie(c, 11) ^ ie(c, 25), w = f + p + As(c, a, l) + Bs[u] + Ee[u] | 0, h = (ie(r, 2) ^ ie(r, 13) ^ ie(r, 22)) + Cs(r, i, s) | 0;
1678
1678
  f = l, l = a, a = c, c = o + w | 0, o = s, s = i, i = r, r = w + h | 0;
1679
1679
  }
1680
1680
  r = r + this.A | 0, i = i + this.B | 0, s = s + this.C | 0, o = o + this.D | 0, c = c + this.E | 0, a = a + this.F | 0, l = l + this.G | 0, f = f + this.H | 0, this.set(r, i, s, o, c, a, l, f);
@@ -1815,7 +1815,7 @@ function Rn(e, t, n) {
1815
1815
  return i.reverse();
1816
1816
  }
1817
1817
  const vr = (e, t) => t ? vr(t, e % t) : e, it = (e, t) => e + (t - vr(e, t));
1818
- function qt(e, t, n, r) {
1818
+ function Ht(e, t, n, r) {
1819
1819
  if (!Array.isArray(e))
1820
1820
  throw new Error("convertRadix2: data should be array");
1821
1821
  if (t <= 0 || t > 32)
@@ -1841,7 +1841,7 @@ function qt(e, t, n, r) {
1841
1841
  throw new Error(`Non-zero padding: ${i}`);
1842
1842
  return r && s > 0 && c.push(i >>> 0), c;
1843
1843
  }
1844
- function _s(e) {
1844
+ function Is(e) {
1845
1845
  return We(e), {
1846
1846
  encode: (t) => {
1847
1847
  if (!(t instanceof Uint8Array))
@@ -1864,12 +1864,12 @@ function Se(e, t = !1) {
1864
1864
  encode: (n) => {
1865
1865
  if (!(n instanceof Uint8Array))
1866
1866
  throw new Error("radix2.encode input should be Uint8Array");
1867
- return qt(Array.from(n), 8, e, !t);
1867
+ return Ht(Array.from(n), 8, e, !t);
1868
1868
  },
1869
1869
  decode: (n) => {
1870
1870
  if (!Array.isArray(n) || n.length && typeof n[0] != "number")
1871
1871
  throw new Error("radix2.decode input should be array of strings");
1872
- return Uint8Array.from(qt(n, e, 8, t));
1872
+ return Uint8Array.from(Ht(n, e, 8, t));
1873
1873
  }
1874
1874
  };
1875
1875
  }
@@ -1883,25 +1883,25 @@ function Tn(e) {
1883
1883
  }
1884
1884
  };
1885
1885
  }
1886
- const Is = de(Se(4), pe("0123456789ABCDEF"), ye("")), Us = de(Se(5), pe("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"), ht(5), ye(""));
1886
+ const _s = de(Se(4), pe("0123456789ABCDEF"), ye("")), Us = de(Se(5), pe("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"), ht(5), ye(""));
1887
1887
  de(Se(5), pe("0123456789ABCDEFGHIJKLMNOPQRSTUV"), ht(5), ye(""));
1888
1888
  de(Se(5), pe("0123456789ABCDEFGHJKMNPQRSTVWXYZ"), ye(""), br((e) => e.toUpperCase().replace(/O/g, "0").replace(/[IL]/g, "1")));
1889
- const he = de(Se(6), pe("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), ht(6), ye("")), Ls = de(Se(6), pe("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"), ht(6), ye("")), en = (e) => de(_s(58), pe(e), ye("")), Dt = en("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
1890
- en("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ");
1891
- en("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");
1889
+ const he = de(Se(6), pe("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), ht(6), ye("")), Ls = de(Se(6), pe("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"), ht(6), ye("")), Qt = (e) => de(Is(58), pe(e), ye("")), qt = Qt("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
1890
+ Qt("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ");
1891
+ Qt("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");
1892
1892
  const On = [0, 2, 3, 5, 6, 7, 9, 10, 11], $s = {
1893
1893
  encode(e) {
1894
1894
  let t = "";
1895
1895
  for (let n = 0; n < e.length; n += 8) {
1896
1896
  const r = e.subarray(n, n + 8);
1897
- t += Dt.encode(r).padStart(On[r.length], "1");
1897
+ t += qt.encode(r).padStart(On[r.length], "1");
1898
1898
  }
1899
1899
  return t;
1900
1900
  },
1901
1901
  decode(e) {
1902
1902
  let t = [];
1903
1903
  for (let n = 0; n < e.length; n += 11) {
1904
- const r = e.slice(n, n + 11), i = On.indexOf(r.length), s = Dt.decode(r);
1904
+ const r = e.slice(n, n + 11), i = On.indexOf(r.length), s = qt.decode(r);
1905
1905
  for (let o = 0; o < s.length - i; o++)
1906
1906
  if (s[o] !== 0)
1907
1907
  throw new Error("base58xmr: wrong padding");
@@ -1909,8 +1909,8 @@ const On = [0, 2, 3, 5, 6, 7, 9, 10, 11], $s = {
1909
1909
  }
1910
1910
  return Uint8Array.from(t);
1911
1911
  }
1912
- }, jt = de(pe("qpzry9x8gf2tvdw0s3jn54khce6mua7l"), ye("")), Mn = [996825010, 642813549, 513874426, 1027748829, 705979059];
1913
- function Ge(e) {
1912
+ }, Dt = de(pe("qpzry9x8gf2tvdw0s3jn54khce6mua7l"), ye("")), Mn = [996825010, 642813549, 513874426, 1027748829, 705979059];
1913
+ function Fe(e) {
1914
1914
  const t = e >> 25;
1915
1915
  let n = (e & 33554431) << 5;
1916
1916
  for (let r = 0; r < Mn.length; r++)
@@ -1924,53 +1924,53 @@ function Pn(e, t, n = 1) {
1924
1924
  const o = e.charCodeAt(s);
1925
1925
  if (o < 33 || o > 126)
1926
1926
  throw new Error(`Invalid prefix (${e})`);
1927
- i = Ge(i) ^ o >> 5;
1927
+ i = Fe(i) ^ o >> 5;
1928
1928
  }
1929
- i = Ge(i);
1929
+ i = Fe(i);
1930
1930
  for (let s = 0; s < r; s++)
1931
- i = Ge(i) ^ e.charCodeAt(s) & 31;
1931
+ i = Fe(i) ^ e.charCodeAt(s) & 31;
1932
1932
  for (let s of t)
1933
- i = Ge(i) ^ s;
1933
+ i = Fe(i) ^ s;
1934
1934
  for (let s = 0; s < 6; s++)
1935
- i = Ge(i);
1936
- return i ^= n, jt.encode(qt([i % 2 ** 30], 30, 5, !1));
1935
+ i = Fe(i);
1936
+ return i ^= n, Dt.encode(Ht([i % 2 ** 30], 30, 5, !1));
1937
1937
  }
1938
1938
  function mr(e) {
1939
1939
  const t = e === "bech32" ? 1 : 734539939, n = Se(5), r = n.decode, i = n.encode, s = Tn(r);
1940
- function o(f, u, g = 90) {
1940
+ function o(f, u, p = 90) {
1941
1941
  if (typeof f != "string")
1942
1942
  throw new Error(`bech32.encode prefix should be string, not ${typeof f}`);
1943
1943
  if (!Array.isArray(u) || u.length && typeof u[0] != "number")
1944
1944
  throw new Error(`bech32.encode words should be array of numbers, not ${typeof u}`);
1945
1945
  const w = f.length + 7 + u.length;
1946
- if (g !== !1 && w > g)
1947
- throw new TypeError(`Length ${w} exceeds limit ${g}`);
1948
- return f = f.toLowerCase(), `${f}1${jt.encode(u)}${Pn(f, u, t)}`;
1946
+ if (p !== !1 && w > p)
1947
+ throw new TypeError(`Length ${w} exceeds limit ${p}`);
1948
+ return f = f.toLowerCase(), `${f}1${Dt.encode(u)}${Pn(f, u, t)}`;
1949
1949
  }
1950
1950
  function c(f, u = 90) {
1951
1951
  if (typeof f != "string")
1952
1952
  throw new Error(`bech32.decode input should be string, not ${typeof f}`);
1953
1953
  if (f.length < 8 || u !== !1 && f.length > u)
1954
1954
  throw new TypeError(`Wrong string length: ${f.length} (${f}). Expected (8..${u})`);
1955
- const g = f.toLowerCase();
1956
- if (f !== g && f !== f.toUpperCase())
1955
+ const p = f.toLowerCase();
1956
+ if (f !== p && f !== f.toUpperCase())
1957
1957
  throw new Error("String must be lowercase or uppercase");
1958
- f = g;
1958
+ f = p;
1959
1959
  const w = f.lastIndexOf("1");
1960
1960
  if (w === 0 || w === -1)
1961
1961
  throw new Error('Letter "1" must be present between prefix and data only');
1962
- const y = f.slice(0, w), h = f.slice(w + 1);
1962
+ const g = f.slice(0, w), h = f.slice(w + 1);
1963
1963
  if (h.length < 6)
1964
1964
  throw new Error("Data must be at least 6 characters long");
1965
- const d = jt.decode(h).slice(0, -6), p = Pn(y, d, t);
1966
- if (!h.endsWith(p))
1967
- throw new Error(`Invalid checksum in ${f}: expected "${p}"`);
1968
- return { prefix: y, words: d };
1965
+ const d = Dt.decode(h).slice(0, -6), y = Pn(g, d, t);
1966
+ if (!h.endsWith(y))
1967
+ throw new Error(`Invalid checksum in ${f}: expected "${y}"`);
1968
+ return { prefix: g, words: d };
1969
1969
  }
1970
1970
  const a = Tn(c);
1971
1971
  function l(f) {
1972
- const { prefix: u, words: g } = c(f, !1);
1973
- return { prefix: u, words: g, bytes: r(g) };
1972
+ const { prefix: u, words: p } = c(f, !1);
1973
+ return { prefix: u, words: p, bytes: r(p) };
1974
1974
  }
1975
1975
  return { encode: o, decode: c, decodeToBytes: l, decodeUnsafe: a, fromWords: r, fromWordsUnsafe: s, toWords: i };
1976
1976
  }
@@ -1986,15 +1986,15 @@ const Rs = {
1986
1986
  })), Os = {
1987
1987
  utf8: Rs,
1988
1988
  hex: Ts,
1989
- base16: Is,
1989
+ base16: _s,
1990
1990
  base32: Us,
1991
1991
  base64: he,
1992
1992
  base64url: Ls,
1993
- base58: Dt,
1993
+ base58: qt,
1994
1994
  base58xmr: $s
1995
1995
  };
1996
1996
  `${Object.keys(Os).join(", ")}`;
1997
- function _t(e) {
1997
+ function kt(e) {
1998
1998
  if (!Number.isSafeInteger(e) || e < 0)
1999
1999
  throw new Error(`positive integer expected, not ${e}`);
2000
2000
  }
@@ -2012,7 +2012,7 @@ function ue(e, ...t) {
2012
2012
  throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`);
2013
2013
  }
2014
2014
  /*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */
2015
- const G = (e) => new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4)), Ps = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
2015
+ const F = (e) => new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4)), Ps = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
2016
2016
  if (!Ps)
2017
2017
  throw new Error("Non little-endian hardware is not supported");
2018
2018
  function Hs(e, t) {
@@ -2028,19 +2028,19 @@ function qs(e, t) {
2028
2028
  n |= e[r] ^ t[r];
2029
2029
  return n === 0;
2030
2030
  }
2031
- const Ds = /* @__NO_SIDE_EFFECTS__ */ (e, t) => (Object.assign(t, e), t), Ke = 16, js = 283;
2032
- function tn(e) {
2031
+ const Ds = /* @__NO_SIDE_EFFECTS__ */ (e, t) => (Object.assign(t, e), t), Ne = 16, js = 283;
2032
+ function en(e) {
2033
2033
  return e << 1 ^ js & -(e >> 7);
2034
2034
  }
2035
2035
  function He(e, t) {
2036
2036
  let n = 0;
2037
2037
  for (; t > 0; t >>= 1)
2038
- n ^= e & -(t & 1), e = tn(e);
2038
+ n ^= e & -(t & 1), e = en(e);
2039
2039
  return n;
2040
2040
  }
2041
- const zt = /* @__PURE__ */ (() => {
2041
+ const jt = /* @__PURE__ */ (() => {
2042
2042
  let e = new Uint8Array(256);
2043
- for (let n = 0, r = 1; n < 256; n++, r ^= tn(r))
2043
+ for (let n = 0, r = 1; n < 256; n++, r ^= en(r))
2044
2044
  e[n] = r;
2045
2045
  const t = new Uint8Array(256);
2046
2046
  t[0] = 99;
@@ -2049,7 +2049,7 @@ const zt = /* @__PURE__ */ (() => {
2049
2049
  r |= r << 8, t[e[n]] = (r ^ r >> 4 ^ r >> 5 ^ r >> 6 ^ r >> 7 ^ 99) & 255;
2050
2050
  }
2051
2051
  return t;
2052
- })(), zs = /* @__PURE__ */ zt.map((e, t) => zt.indexOf(t)), Ws = (e) => e << 24 | e >>> 8, It = (e) => e << 8 | e >>> 24;
2052
+ })(), zs = /* @__PURE__ */ jt.map((e, t) => jt.indexOf(t)), Ws = (e) => e << 24 | e >>> 8, It = (e) => e << 8 | e >>> 24;
2053
2053
  function Er(e, t) {
2054
2054
  if (e.length !== 256)
2055
2055
  throw new Error("Wrong sbox length");
@@ -2061,18 +2061,18 @@ function Er(e, t) {
2061
2061
  }
2062
2062
  return { sbox: e, sbox2: a, T0: n, T1: r, T2: i, T3: s, T01: o, T23: c };
2063
2063
  }
2064
- const nn = /* @__PURE__ */ Er(zt, (e) => He(e, 3) << 24 | e << 16 | e << 8 | He(e, 2)), xr = /* @__PURE__ */ Er(zs, (e) => He(e, 11) << 24 | He(e, 13) << 16 | He(e, 9) << 8 | He(e, 14)), Vs = /* @__PURE__ */ (() => {
2064
+ const tn = /* @__PURE__ */ Er(jt, (e) => He(e, 3) << 24 | e << 16 | e << 8 | He(e, 2)), xr = /* @__PURE__ */ Er(zs, (e) => He(e, 11) << 24 | He(e, 13) << 16 | He(e, 9) << 8 | He(e, 14)), Vs = /* @__PURE__ */ (() => {
2065
2065
  const e = new Uint8Array(16);
2066
- for (let t = 0, n = 1; t < 16; t++, n = tn(n))
2066
+ for (let t = 0, n = 1; t < 16; t++, n = en(n))
2067
2067
  e[t] = n;
2068
2068
  return e;
2069
2069
  })();
2070
- function Kr(e) {
2070
+ function Nr(e) {
2071
2071
  ue(e);
2072
2072
  const t = e.length;
2073
2073
  if (![16, 24, 32].includes(t))
2074
2074
  throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${t}`);
2075
- const { sbox2: n } = nn, r = G(e), i = r.length, s = (c) => oe(n, c, c, c, c), o = new Uint32Array(t + 28);
2075
+ const { sbox2: n } = tn, r = F(e), i = r.length, s = (c) => oe(n, c, c, c, c), o = new Uint32Array(t + 28);
2076
2076
  o.set(r);
2077
2077
  for (let c = i; c < o.length; c++) {
2078
2078
  let a = o[c - 1];
@@ -2081,7 +2081,7 @@ function Kr(e) {
2081
2081
  return o;
2082
2082
  }
2083
2083
  function Zs(e) {
2084
- const t = Kr(e), n = t.slice(), r = t.length, { sbox2: i } = nn, { T0: s, T1: o, T2: c, T3: a } = xr;
2084
+ const t = Nr(e), n = t.slice(), r = t.length, { sbox2: i } = tn, { T0: s, T1: o, T2: c, T3: a } = xr;
2085
2085
  for (let l = 0; l < r; l += 4)
2086
2086
  for (let f = 0; f < 4; f++)
2087
2087
  n[l + f] = t[r - l - 4 + f];
@@ -2099,51 +2099,51 @@ function oe(e, t, n, r, i) {
2099
2099
  return e[t & 255 | n & 65280] | e[r >>> 16 & 255 | i >>> 16 & 65280] << 16;
2100
2100
  }
2101
2101
  function qn(e, t, n, r, i) {
2102
- const { sbox2: s, T01: o, T23: c } = nn;
2102
+ const { sbox2: s, T01: o, T23: c } = tn;
2103
2103
  let a = 0;
2104
2104
  t ^= e[a++], n ^= e[a++], r ^= e[a++], i ^= e[a++];
2105
2105
  const l = e.length / 4 - 2;
2106
- for (let y = 0; y < l; y++) {
2107
- const h = e[a++] ^ xe(o, c, t, n, r, i), d = e[a++] ^ xe(o, c, n, r, i, t), p = e[a++] ^ xe(o, c, r, i, t, n), E = e[a++] ^ xe(o, c, i, t, n, r);
2108
- t = h, n = d, r = p, i = E;
2106
+ for (let g = 0; g < l; g++) {
2107
+ const h = e[a++] ^ xe(o, c, t, n, r, i), d = e[a++] ^ xe(o, c, n, r, i, t), y = e[a++] ^ xe(o, c, r, i, t, n), E = e[a++] ^ xe(o, c, i, t, n, r);
2108
+ t = h, n = d, r = y, i = E;
2109
2109
  }
2110
- const f = e[a++] ^ oe(s, t, n, r, i), u = e[a++] ^ oe(s, n, r, i, t), g = e[a++] ^ oe(s, r, i, t, n), w = e[a++] ^ oe(s, i, t, n, r);
2111
- return { s0: f, s1: u, s2: g, s3: w };
2110
+ const f = e[a++] ^ oe(s, t, n, r, i), u = e[a++] ^ oe(s, n, r, i, t), p = e[a++] ^ oe(s, r, i, t, n), w = e[a++] ^ oe(s, i, t, n, r);
2111
+ return { s0: f, s1: u, s2: p, s3: w };
2112
2112
  }
2113
- function Gs(e, t, n, r, i) {
2113
+ function Fs(e, t, n, r, i) {
2114
2114
  const { sbox2: s, T01: o, T23: c } = xr;
2115
2115
  let a = 0;
2116
2116
  t ^= e[a++], n ^= e[a++], r ^= e[a++], i ^= e[a++];
2117
2117
  const l = e.length / 4 - 2;
2118
- for (let y = 0; y < l; y++) {
2119
- const h = e[a++] ^ xe(o, c, t, i, r, n), d = e[a++] ^ xe(o, c, n, t, i, r), p = e[a++] ^ xe(o, c, r, n, t, i), E = e[a++] ^ xe(o, c, i, r, n, t);
2120
- t = h, n = d, r = p, i = E;
2118
+ for (let g = 0; g < l; g++) {
2119
+ const h = e[a++] ^ xe(o, c, t, i, r, n), d = e[a++] ^ xe(o, c, n, t, i, r), y = e[a++] ^ xe(o, c, r, n, t, i), E = e[a++] ^ xe(o, c, i, r, n, t);
2120
+ t = h, n = d, r = y, i = E;
2121
2121
  }
2122
- const f = e[a++] ^ oe(s, t, i, r, n), u = e[a++] ^ oe(s, n, t, i, r), g = e[a++] ^ oe(s, r, n, t, i), w = e[a++] ^ oe(s, i, r, n, t);
2123
- return { s0: f, s1: u, s2: g, s3: w };
2122
+ const f = e[a++] ^ oe(s, t, i, r, n), u = e[a++] ^ oe(s, n, t, i, r), p = e[a++] ^ oe(s, r, n, t, i), w = e[a++] ^ oe(s, i, r, n, t);
2123
+ return { s0: f, s1: u, s2: p, s3: w };
2124
2124
  }
2125
- function Nr(e, t) {
2125
+ function Kr(e, t) {
2126
2126
  if (!t)
2127
2127
  return new Uint8Array(e);
2128
2128
  if (ue(t), t.length < e)
2129
2129
  throw new Error(`aes: wrong destination length, expected at least ${e}, got: ${t.length}`);
2130
2130
  return t;
2131
2131
  }
2132
- function Fs(e) {
2133
- if (ue(e), e.length % Ke !== 0)
2134
- throw new Error(`aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size ${Ke}`);
2132
+ function Gs(e) {
2133
+ if (ue(e), e.length % Ne !== 0)
2134
+ throw new Error(`aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size ${Ne}`);
2135
2135
  }
2136
2136
  function Js(e, t, n) {
2137
2137
  let r = e.length;
2138
- const i = r % Ke;
2138
+ const i = r % Ne;
2139
2139
  if (!t && i !== 0)
2140
2140
  throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");
2141
- const s = G(e);
2141
+ const s = F(e);
2142
2142
  if (t) {
2143
- let a = Ke - i;
2144
- a || (a = Ke), r = r + a;
2143
+ let a = Ne - i;
2144
+ a || (a = Ne), r = r + a;
2145
2145
  }
2146
- const o = Nr(r, n), c = G(o);
2146
+ const o = Kr(r, n), c = F(o);
2147
2147
  return { b: s, o: c, out: o };
2148
2148
  }
2149
2149
  function Ys(e, t) {
@@ -2162,10 +2162,10 @@ function Ys(e, t) {
2162
2162
  return i;
2163
2163
  }
2164
2164
  function Xs(e) {
2165
- const t = new Uint8Array(16), n = G(t);
2165
+ const t = new Uint8Array(16), n = F(t);
2166
2166
  t.set(e);
2167
- const r = Ke - e.length;
2168
- for (let i = Ke - r; i < Ke; i++)
2167
+ const r = Ne - e.length;
2168
+ for (let i = Ne - r; i < Ne; i++)
2169
2169
  t[i] = r;
2170
2170
  return n;
2171
2171
  }
@@ -2174,110 +2174,110 @@ const Sr = /* @__PURE__ */ Ds({ blockSize: 16, nonceLength: 16 }, function(t, n,
2174
2174
  const i = !r.disablePadding;
2175
2175
  return {
2176
2176
  encrypt: (s, o) => {
2177
- const c = Kr(t), { b: a, o: l, out: f } = Js(s, i, o), u = G(n);
2178
- let g = u[0], w = u[1], y = u[2], h = u[3], d = 0;
2177
+ const c = Nr(t), { b: a, o: l, out: f } = Js(s, i, o), u = F(n);
2178
+ let p = u[0], w = u[1], g = u[2], h = u[3], d = 0;
2179
2179
  for (; d + 4 <= a.length; )
2180
- g ^= a[d + 0], w ^= a[d + 1], y ^= a[d + 2], h ^= a[d + 3], { s0: g, s1: w, s2: y, s3: h } = qn(c, g, w, y, h), l[d++] = g, l[d++] = w, l[d++] = y, l[d++] = h;
2180
+ p ^= a[d + 0], w ^= a[d + 1], g ^= a[d + 2], h ^= a[d + 3], { s0: p, s1: w, s2: g, s3: h } = qn(c, p, w, g, h), l[d++] = p, l[d++] = w, l[d++] = g, l[d++] = h;
2181
2181
  if (i) {
2182
- const p = Xs(s.subarray(d * 4));
2183
- g ^= p[0], w ^= p[1], y ^= p[2], h ^= p[3], { s0: g, s1: w, s2: y, s3: h } = qn(c, g, w, y, h), l[d++] = g, l[d++] = w, l[d++] = y, l[d++] = h;
2182
+ const y = Xs(s.subarray(d * 4));
2183
+ p ^= y[0], w ^= y[1], g ^= y[2], h ^= y[3], { s0: p, s1: w, s2: g, s3: h } = qn(c, p, w, g, h), l[d++] = p, l[d++] = w, l[d++] = g, l[d++] = h;
2184
2184
  }
2185
2185
  return c.fill(0), f;
2186
2186
  },
2187
2187
  decrypt: (s, o) => {
2188
- Fs(s);
2189
- const c = Zs(t), a = G(n), l = Nr(s.length, o), f = G(s), u = G(l);
2190
- let g = a[0], w = a[1], y = a[2], h = a[3];
2188
+ Gs(s);
2189
+ const c = Zs(t), a = F(n), l = Kr(s.length, o), f = F(s), u = F(l);
2190
+ let p = a[0], w = a[1], g = a[2], h = a[3];
2191
2191
  for (let d = 0; d + 4 <= f.length; ) {
2192
- const p = g, E = w, S = y, I = h;
2193
- g = f[d + 0], w = f[d + 1], y = f[d + 2], h = f[d + 3];
2194
- const { s0: B, s1: m, s2: x, s3: K } = Gs(c, g, w, y, h);
2195
- u[d++] = B ^ p, u[d++] = m ^ E, u[d++] = x ^ S, u[d++] = K ^ I;
2192
+ const y = p, E = w, S = g, _ = h;
2193
+ p = f[d + 0], w = f[d + 1], g = f[d + 2], h = f[d + 3];
2194
+ const { s0: B, s1: m, s2: x, s3: N } = Fs(c, p, w, g, h);
2195
+ u[d++] = B ^ y, u[d++] = m ^ E, u[d++] = x ^ S, u[d++] = N ^ _;
2196
2196
  }
2197
2197
  return c.fill(0), Ys(l, i);
2198
2198
  }
2199
2199
  };
2200
- }), Ar = (e) => Uint8Array.from(e.split("").map((t) => t.charCodeAt(0))), Qs = Ar("expand 16-byte k"), eo = Ar("expand 32-byte k"), to = G(Qs), Cr = G(eo);
2200
+ }), Ar = (e) => Uint8Array.from(e.split("").map((t) => t.charCodeAt(0))), Qs = Ar("expand 16-byte k"), eo = Ar("expand 32-byte k"), to = F(Qs), Cr = F(eo);
2201
2201
  Cr.slice();
2202
2202
  function L(e, t) {
2203
2203
  return e << t | e >>> 32 - t;
2204
2204
  }
2205
- function Wt(e) {
2205
+ function zt(e) {
2206
2206
  return e.byteOffset % 4 === 0;
2207
2207
  }
2208
2208
  const Xe = 64, no = 16, Br = 2 ** 32 - 1, Dn = new Uint32Array();
2209
2209
  function ro(e, t, n, r, i, s, o, c) {
2210
- const a = i.length, l = new Uint8Array(Xe), f = G(l), u = Wt(i) && Wt(s), g = u ? G(i) : Dn, w = u ? G(s) : Dn;
2211
- for (let y = 0; y < a; o++) {
2210
+ const a = i.length, l = new Uint8Array(Xe), f = F(l), u = zt(i) && zt(s), p = u ? F(i) : Dn, w = u ? F(s) : Dn;
2211
+ for (let g = 0; g < a; o++) {
2212
2212
  if (e(t, n, r, f, o, c), o >= Br)
2213
2213
  throw new Error("arx: counter overflow");
2214
- const h = Math.min(Xe, a - y);
2214
+ const h = Math.min(Xe, a - g);
2215
2215
  if (u && h === Xe) {
2216
- const d = y / 4;
2217
- if (y % 4 !== 0)
2216
+ const d = g / 4;
2217
+ if (g % 4 !== 0)
2218
2218
  throw new Error("arx: invalid block position");
2219
- for (let p = 0, E; p < no; p++)
2220
- E = d + p, w[E] = g[E] ^ f[p];
2221
- y += Xe;
2219
+ for (let y = 0, E; y < no; y++)
2220
+ E = d + y, w[E] = p[E] ^ f[y];
2221
+ g += Xe;
2222
2222
  continue;
2223
2223
  }
2224
- for (let d = 0, p; d < h; d++)
2225
- p = y + d, s[p] = i[p] ^ l[d];
2226
- y += h;
2224
+ for (let d = 0, y; d < h; d++)
2225
+ y = g + d, s[y] = i[y] ^ l[d];
2226
+ g += h;
2227
2227
  }
2228
2228
  }
2229
2229
  function io(e, t) {
2230
2230
  const { allowShortKeys: n, extendNonceFn: r, counterLength: i, counterRight: s, rounds: o } = Hs({ allowShortKeys: !1, counterLength: 8, counterRight: !1, rounds: 20 }, t);
2231
2231
  if (typeof e != "function")
2232
2232
  throw new Error("core must be a function");
2233
- return _t(i), _t(o), Hn(s), Hn(n), (c, a, l, f, u = 0) => {
2233
+ return kt(i), kt(o), Hn(s), Hn(n), (c, a, l, f, u = 0) => {
2234
2234
  ue(c), ue(a), ue(l);
2235
- const g = l.length;
2236
- if (f || (f = new Uint8Array(g)), ue(f), _t(u), u < 0 || u >= Br)
2235
+ const p = l.length;
2236
+ if (f || (f = new Uint8Array(p)), ue(f), kt(u), u < 0 || u >= Br)
2237
2237
  throw new Error("arx: counter overflow");
2238
- if (f.length < g)
2239
- throw new Error(`arx: output (${f.length}) is shorter than data (${g})`);
2238
+ if (f.length < p)
2239
+ throw new Error(`arx: output (${f.length}) is shorter than data (${p})`);
2240
2240
  const w = [];
2241
- let y = c.length, h, d;
2242
- if (y === 32)
2241
+ let g = c.length, h, d;
2242
+ if (g === 32)
2243
2243
  h = c.slice(), w.push(h), d = Cr;
2244
- else if (y === 16 && n)
2244
+ else if (g === 16 && n)
2245
2245
  h = new Uint8Array(32), h.set(c), h.set(c, 16), d = to, w.push(h);
2246
2246
  else
2247
- throw new Error(`arx: invalid 32-byte key, got length=${y}`);
2248
- Wt(a) || (a = a.slice(), w.push(a));
2249
- const p = G(h);
2247
+ throw new Error(`arx: invalid 32-byte key, got length=${g}`);
2248
+ zt(a) || (a = a.slice(), w.push(a));
2249
+ const y = F(h);
2250
2250
  if (r) {
2251
2251
  if (a.length !== 24)
2252
2252
  throw new Error("arx: extended nonce must be 24 bytes");
2253
- r(d, p, G(a.subarray(0, 16)), p), a = a.subarray(16);
2253
+ r(d, y, F(a.subarray(0, 16)), y), a = a.subarray(16);
2254
2254
  }
2255
2255
  const E = 16 - i;
2256
2256
  if (E !== a.length)
2257
2257
  throw new Error(`arx: nonce must be ${E} or 16 bytes`);
2258
2258
  if (E !== 12) {
2259
- const I = new Uint8Array(12);
2260
- I.set(a, s ? 0 : 12 - a.length), a = I, w.push(a);
2259
+ const _ = new Uint8Array(12);
2260
+ _.set(a, s ? 0 : 12 - a.length), a = _, w.push(a);
2261
2261
  }
2262
- const S = G(a);
2263
- for (ro(e, d, p, S, l, f, u, o); w.length > 0; )
2262
+ const S = F(a);
2263
+ for (ro(e, d, y, S, l, f, u, o); w.length > 0; )
2264
2264
  w.pop().fill(0);
2265
2265
  return f;
2266
2266
  };
2267
2267
  }
2268
2268
  function so(e, t, n, r, i, s = 20) {
2269
- let o = e[0], c = e[1], a = e[2], l = e[3], f = t[0], u = t[1], g = t[2], w = t[3], y = t[4], h = t[5], d = t[6], p = t[7], E = i, S = n[0], I = n[1], B = n[2], m = o, x = c, K = a, M = l, _ = f, A = u, R = g, T = w, q = y, b = h, v = d, N = p, k = E, C = S, U = I, O = B;
2269
+ let o = e[0], c = e[1], a = e[2], l = e[3], f = t[0], u = t[1], p = t[2], w = t[3], g = t[4], h = t[5], d = t[6], y = t[7], E = i, S = n[0], _ = n[1], B = n[2], m = o, x = c, N = a, M = l, I = f, A = u, R = p, T = w, q = g, b = h, v = d, K = y, k = E, C = S, U = _, O = B;
2270
2270
  for (let ee = 0; ee < s; ee += 2)
2271
- m = m + _ | 0, k = L(k ^ m, 16), q = q + k | 0, _ = L(_ ^ q, 12), m = m + _ | 0, k = L(k ^ m, 8), q = q + k | 0, _ = L(_ ^ q, 7), x = x + A | 0, C = L(C ^ x, 16), b = b + C | 0, A = L(A ^ b, 12), x = x + A | 0, C = L(C ^ x, 8), b = b + C | 0, A = L(A ^ b, 7), K = K + R | 0, U = L(U ^ K, 16), v = v + U | 0, R = L(R ^ v, 12), K = K + R | 0, U = L(U ^ K, 8), v = v + U | 0, R = L(R ^ v, 7), M = M + T | 0, O = L(O ^ M, 16), N = N + O | 0, T = L(T ^ N, 12), M = M + T | 0, O = L(O ^ M, 8), N = N + O | 0, T = L(T ^ N, 7), m = m + A | 0, O = L(O ^ m, 16), v = v + O | 0, A = L(A ^ v, 12), m = m + A | 0, O = L(O ^ m, 8), v = v + O | 0, A = L(A ^ v, 7), x = x + R | 0, k = L(k ^ x, 16), N = N + k | 0, R = L(R ^ N, 12), x = x + R | 0, k = L(k ^ x, 8), N = N + k | 0, R = L(R ^ N, 7), K = K + T | 0, C = L(C ^ K, 16), q = q + C | 0, T = L(T ^ q, 12), K = K + T | 0, C = L(C ^ K, 8), q = q + C | 0, T = L(T ^ q, 7), M = M + _ | 0, U = L(U ^ M, 16), b = b + U | 0, _ = L(_ ^ b, 12), M = M + _ | 0, U = L(U ^ M, 8), b = b + U | 0, _ = L(_ ^ b, 7);
2271
+ m = m + I | 0, k = L(k ^ m, 16), q = q + k | 0, I = L(I ^ q, 12), m = m + I | 0, k = L(k ^ m, 8), q = q + k | 0, I = L(I ^ q, 7), x = x + A | 0, C = L(C ^ x, 16), b = b + C | 0, A = L(A ^ b, 12), x = x + A | 0, C = L(C ^ x, 8), b = b + C | 0, A = L(A ^ b, 7), N = N + R | 0, U = L(U ^ N, 16), v = v + U | 0, R = L(R ^ v, 12), N = N + R | 0, U = L(U ^ N, 8), v = v + U | 0, R = L(R ^ v, 7), M = M + T | 0, O = L(O ^ M, 16), K = K + O | 0, T = L(T ^ K, 12), M = M + T | 0, O = L(O ^ M, 8), K = K + O | 0, T = L(T ^ K, 7), m = m + A | 0, O = L(O ^ m, 16), v = v + O | 0, A = L(A ^ v, 12), m = m + A | 0, O = L(O ^ m, 8), v = v + O | 0, A = L(A ^ v, 7), x = x + R | 0, k = L(k ^ x, 16), K = K + k | 0, R = L(R ^ K, 12), x = x + R | 0, k = L(k ^ x, 8), K = K + k | 0, R = L(R ^ K, 7), N = N + T | 0, C = L(C ^ N, 16), q = q + C | 0, T = L(T ^ q, 12), N = N + T | 0, C = L(C ^ N, 8), q = q + C | 0, T = L(T ^ q, 7), M = M + I | 0, U = L(U ^ M, 16), b = b + U | 0, I = L(I ^ b, 12), M = M + I | 0, U = L(U ^ M, 8), b = b + U | 0, I = L(I ^ b, 7);
2272
2272
  let $ = 0;
2273
- r[$++] = o + m | 0, r[$++] = c + x | 0, r[$++] = a + K | 0, r[$++] = l + M | 0, r[$++] = f + _ | 0, r[$++] = u + A | 0, r[$++] = g + R | 0, r[$++] = w + T | 0, r[$++] = y + q | 0, r[$++] = h + b | 0, r[$++] = d + v | 0, r[$++] = p + N | 0, r[$++] = E + k | 0, r[$++] = S + C | 0, r[$++] = I + U | 0, r[$++] = B + O | 0;
2273
+ r[$++] = o + m | 0, r[$++] = c + x | 0, r[$++] = a + N | 0, r[$++] = l + M | 0, r[$++] = f + I | 0, r[$++] = u + A | 0, r[$++] = p + R | 0, r[$++] = w + T | 0, r[$++] = g + q | 0, r[$++] = h + b | 0, r[$++] = d + v | 0, r[$++] = y + K | 0, r[$++] = E + k | 0, r[$++] = S + C | 0, r[$++] = _ + U | 0, r[$++] = B + O | 0;
2274
2274
  }
2275
2275
  const kr = /* @__PURE__ */ io(so, {
2276
2276
  counterRight: !1,
2277
2277
  counterLength: 4,
2278
2278
  allowShortKeys: !1
2279
2279
  });
2280
- class _r extends dr {
2280
+ class Ir extends dr {
2281
2281
  constructor(t, n) {
2282
2282
  super(), this.finished = !1, this.destroyed = !1, se.hash(t);
2283
2283
  const r = Je(n);
@@ -2312,23 +2312,23 @@ class _r extends dr {
2312
2312
  this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
2313
2313
  }
2314
2314
  }
2315
- const dt = (e, t, n) => new _r(e, t).update(n).digest();
2316
- dt.create = (e, t) => new _r(e, t);
2317
- function rn(e, t, n) {
2315
+ const dt = (e, t, n) => new Ir(e, t).update(n).digest();
2316
+ dt.create = (e, t) => new Ir(e, t);
2317
+ function nn(e, t, n) {
2318
2318
  return se.hash(e), n === void 0 && (n = new Uint8Array(e.outputLen)), dt(e, Je(n), Je(t));
2319
2319
  }
2320
- const Ut = new Uint8Array([0]), jn = new Uint8Array();
2321
- function Ir(e, t, n, r = 32) {
2320
+ const _t = new Uint8Array([0]), jn = new Uint8Array();
2321
+ function _r(e, t, n, r = 32) {
2322
2322
  if (se.hash(e), se.number(r), r > 255 * e.outputLen)
2323
2323
  throw new Error("Length should be <= 255*HashLen");
2324
2324
  const i = Math.ceil(r / e.outputLen);
2325
2325
  n === void 0 && (n = jn);
2326
2326
  const s = new Uint8Array(i * e.outputLen), o = dt.create(e, t), c = o._cloneInto(), a = new Uint8Array(o.outputLen);
2327
2327
  for (let l = 0; l < i; l++)
2328
- Ut[0] = l + 1, c.update(l === 0 ? jn : a).update(n).update(Ut).digestInto(a), s.set(a, e.outputLen * l), o._cloneInto(c);
2329
- return o.destroy(), c.destroy(), a.fill(0), Ut.fill(0), s.slice(0, r);
2328
+ _t[0] = l + 1, c.update(l === 0 ? jn : a).update(n).update(_t).digestInto(a), s.set(a, e.outputLen * l), o._cloneInto(c);
2329
+ return o.destroy(), c.destroy(), a.fill(0), _t.fill(0), s.slice(0, r);
2330
2330
  }
2331
- var oo = Object.defineProperty, P = (e, t) => {
2331
+ var oo = Object.defineProperty, H = (e, t) => {
2332
2332
  for (var n in t)
2333
2333
  oo(e, n, { get: t[n], enumerable: !0 });
2334
2334
  }, Te = Symbol("verified"), ao = (e) => e instanceof Object;
@@ -2346,10 +2346,12 @@ function pt(e) {
2346
2346
  return !0;
2347
2347
  }
2348
2348
  var co = {};
2349
- P(co, {
2349
+ H(co, {
2350
2350
  Queue: () => ho,
2351
2351
  QueueNode: () => Ur,
2352
- binarySearch: () => sn,
2352
+ binarySearch: () => rn,
2353
+ bytesToHex: () => P,
2354
+ hexToBytes: () => j,
2353
2355
  insertEventIntoAscendingList: () => fo,
2354
2356
  insertEventIntoDescendingList: () => lo,
2355
2357
  normalizeURL: () => uo,
@@ -2367,14 +2369,14 @@ function uo(e) {
2367
2369
  }
2368
2370
  }
2369
2371
  function lo(e, t) {
2370
- const [n, r] = sn(e, (i) => t.id === i.id ? 0 : t.created_at === i.created_at ? -1 : i.created_at - t.created_at);
2372
+ const [n, r] = rn(e, (i) => t.id === i.id ? 0 : t.created_at === i.created_at ? -1 : i.created_at - t.created_at);
2371
2373
  return r || e.splice(n, 0, t), e;
2372
2374
  }
2373
2375
  function fo(e, t) {
2374
- const [n, r] = sn(e, (i) => t.id === i.id ? 0 : t.created_at === i.created_at ? -1 : t.created_at - i.created_at);
2376
+ const [n, r] = rn(e, (i) => t.id === i.id ? 0 : t.created_at === i.created_at ? -1 : t.created_at - i.created_at);
2375
2377
  return r || e.splice(n, 0, t), e;
2376
2378
  }
2377
- function sn(e, t) {
2379
+ function rn(e, t) {
2378
2380
  let n = 0, r = e.length - 1;
2379
2381
  for (; n <= r; ) {
2380
2382
  const i = Math.floor((n + r) / 2), s = t(e[i]);
@@ -2416,11 +2418,11 @@ var Ur = class {
2416
2418
  return Ze.utils.randomPrivateKey();
2417
2419
  }
2418
2420
  getPublicKey(e) {
2419
- return H(Ze.getPublicKey(e));
2421
+ return P(Ze.getPublicKey(e));
2420
2422
  }
2421
2423
  finalizeEvent(e, t) {
2422
2424
  const n = e;
2423
- return n.pubkey = H(Ze.getPublicKey(t)), n.id = qe(n), n.sig = H(Ze.sign(qe(n), t)), n[Te] = !0, n;
2425
+ return n.pubkey = P(Ze.getPublicKey(t)), n.id = qe(n), n.sig = P(Ze.sign(qe(n), t)), n[Te] = !0, n;
2424
2426
  }
2425
2427
  verifyEvent(e) {
2426
2428
  if (typeof e[Te] == "boolean")
@@ -2443,122 +2445,120 @@ function yo(e) {
2443
2445
  }
2444
2446
  function qe(e) {
2445
2447
  let t = fe(ne.encode(yo(e)));
2446
- return H(t);
2448
+ return P(t);
2447
2449
  }
2448
2450
  var yt = new po(), ke = yt.generateSecretKey, ae = yt.getPublicKey, Q = yt.finalizeEvent, gt = yt.verifyEvent, go = {};
2449
- P(go, {
2450
- Application: () => ga,
2451
- BadgeAward: () => So,
2452
- BadgeDefinition: () => ua,
2453
- BlockedRelaysList: () => Zo,
2454
- BookmarkList: () => zo,
2455
- Bookmarksets: () => oa,
2456
- Calendar: () => Ka,
2451
+ H(go, {
2452
+ Application: () => ya,
2453
+ BadgeAward: () => Ko,
2454
+ BadgeDefinition: () => ca,
2455
+ BlockedRelaysList: () => Vo,
2456
+ BookmarkList: () => jo,
2457
+ Bookmarksets: () => sa,
2458
+ Calendar: () => xa,
2457
2459
  CalendarEventRSVP: () => Na,
2458
2460
  ChannelCreation: () => Mr,
2459
2461
  ChannelHideMessage: () => qr,
2460
2462
  ChannelMessage: () => Hr,
2461
2463
  ChannelMetadata: () => Pr,
2462
2464
  ChannelMuteUser: () => Dr,
2463
- ClassifiedListing: () => va,
2465
+ ClassifiedListing: () => ba,
2464
2466
  ClientAuth: () => zr,
2465
- CommunitiesList: () => Wo,
2466
- CommunityDefinition: () => Ca,
2467
- CommunityPostApproval: () => Lo,
2468
- Contacts: () => xo,
2469
- CreateOrUpdateProduct: () => ha,
2470
- CreateOrUpdateStall: () => fa,
2471
- Curationsets: () => aa,
2472
- Date: () => Ea,
2473
- DirectMessageRelaysList: () => Yo,
2474
- DraftClassifiedListing: () => ma,
2475
- DraftLong: () => pa,
2476
- Emojisets: () => ya,
2477
- EncryptedDirectMessage: () => Ko,
2467
+ CommunitiesList: () => zo,
2468
+ CommunityDefinition: () => Aa,
2469
+ CommunityPostApproval: () => Uo,
2470
+ Contacts: () => Eo,
2471
+ CreateOrUpdateProduct: () => fa,
2472
+ CreateOrUpdateStall: () => la,
2473
+ Curationsets: () => oa,
2474
+ Date: () => ma,
2475
+ DirectMessageRelaysList: () => Jo,
2476
+ DraftClassifiedListing: () => va,
2477
+ DraftLong: () => da,
2478
+ Emojisets: () => pa,
2479
+ EncryptedDirectMessage: () => xo,
2478
2480
  EventDeletion: () => No,
2479
- FileMetadata: () => Co,
2480
- FileServerPreference: () => Xo,
2481
- Followsets: () => ra,
2481
+ FileMetadata: () => Ao,
2482
+ FileServerPreference: () => Yo,
2483
+ Followsets: () => na,
2482
2484
  GenericRepost: () => un,
2483
- Genericlists: () => ia,
2485
+ Genericlists: () => ra,
2484
2486
  GiftWrap: () => jr,
2485
2487
  HTTPAuth: () => ln,
2486
- Handlerinformation: () => Aa,
2487
- Handlerrecommendation: () => Sa,
2488
- Highlights: () => Ho,
2488
+ Handlerinformation: () => Sa,
2489
+ Handlerrecommendation: () => Ka,
2490
+ Highlights: () => Po,
2489
2491
  InterestsList: () => Fo,
2490
- Interestsets: () => la,
2491
- JobFeedback: () => To,
2492
- JobRequest: () => $o,
2493
- JobResult: () => Ro,
2494
- Label: () => Uo,
2495
- LightningPubRPC: () => ea,
2496
- LiveChatMessage: () => Bo,
2497
- LiveEvent: () => wa,
2498
- LongFormArticle: () => da,
2499
- Metadata: () => mo,
2500
- Mutelist: () => qo,
2501
- NWCWalletInfo: () => Qo,
2492
+ Interestsets: () => ua,
2493
+ JobFeedback: () => Ro,
2494
+ JobRequest: () => Lo,
2495
+ JobResult: () => $o,
2496
+ Label: () => _o,
2497
+ LightningPubRPC: () => Qo,
2498
+ LiveChatMessage: () => Co,
2499
+ LiveEvent: () => ga,
2500
+ LongFormArticle: () => ha,
2501
+ Metadata: () => vo,
2502
+ Mutelist: () => Ho,
2503
+ NWCWalletInfo: () => Xo,
2502
2504
  NWCWalletRequest: () => Wr,
2503
- NWCWalletResponse: () => ta,
2504
- NostrConnect: () => na,
2505
- OpenTimestamps: () => Ao,
2506
- Pinlist: () => Do,
2505
+ NWCWalletResponse: () => ea,
2506
+ NostrConnect: () => ta,
2507
+ OpenTimestamps: () => So,
2508
+ Pinlist: () => qo,
2507
2509
  PrivateDirectMessage: () => Or,
2508
- ProblemTracker: () => ko,
2509
- ProfileBadges: () => ca,
2510
- PublicChatsList: () => Vo,
2510
+ ProblemTracker: () => Bo,
2511
+ ProfileBadges: () => aa,
2512
+ PublicChatsList: () => Wo,
2511
2513
  Reaction: () => cn,
2512
- RecommendRelay: () => Eo,
2513
- RelayList: () => jo,
2514
- Relaysets: () => sa,
2515
- Report: () => _o,
2514
+ RecommendRelay: () => mo,
2515
+ RelayList: () => Do,
2516
+ Relaysets: () => ia,
2517
+ Report: () => ko,
2516
2518
  Reporting: () => Io,
2517
2519
  Repost: () => an,
2518
2520
  Seal: () => Tr,
2519
- SearchRelaysList: () => Go,
2521
+ SearchRelaysList: () => Zo,
2520
2522
  ShortTextNote: () => Rr,
2521
- Time: () => xa,
2522
- UserEmojiList: () => Jo,
2523
- UserStatuses: () => ba,
2524
- Zap: () => Po,
2525
- ZapGoal: () => Oo,
2526
- ZapRequest: () => Mo,
2527
- classifyKind: () => bo,
2528
- isAddressableKind: () => wt,
2523
+ Time: () => Ea,
2524
+ UserEmojiList: () => Go,
2525
+ UserStatuses: () => wa,
2526
+ Zap: () => Mo,
2527
+ ZapGoal: () => To,
2528
+ ZapRequest: () => Oo,
2529
+ classifyKind: () => wo,
2530
+ isAddressableKind: () => on,
2529
2531
  isEphemeralKind: () => $r,
2530
- isKind: () => vo,
2531
- isParameterizedReplaceableKind: () => wo,
2532
+ isKind: () => bo,
2532
2533
  isRegularKind: () => Lr,
2533
- isReplaceableKind: () => on
2534
+ isReplaceableKind: () => sn
2534
2535
  });
2535
2536
  function Lr(e) {
2536
2537
  return 1e3 <= e && e < 1e4 || [1, 2, 4, 5, 6, 7, 8, 16, 40, 41, 42, 43, 44].includes(e);
2537
2538
  }
2538
- function on(e) {
2539
+ function sn(e) {
2539
2540
  return [0, 3].includes(e) || 1e4 <= e && e < 2e4;
2540
2541
  }
2541
2542
  function $r(e) {
2542
2543
  return 2e4 <= e && e < 3e4;
2543
2544
  }
2544
- function wt(e) {
2545
+ function on(e) {
2545
2546
  return 3e4 <= e && e < 4e4;
2546
2547
  }
2547
- var wo = wt;
2548
- function bo(e) {
2549
- return Lr(e) ? "regular" : on(e) ? "replaceable" : $r(e) ? "ephemeral" : wt(e) ? "parameterized" : "unknown";
2548
+ function wo(e) {
2549
+ return Lr(e) ? "regular" : sn(e) ? "replaceable" : $r(e) ? "ephemeral" : on(e) ? "parameterized" : "unknown";
2550
2550
  }
2551
- function vo(e, t) {
2551
+ function bo(e, t) {
2552
2552
  const n = t instanceof Array ? t : [t];
2553
2553
  return pt(e) && n.includes(e.kind) || !1;
2554
2554
  }
2555
- var mo = 0, Rr = 1, Eo = 2, xo = 3, Ko = 4, No = 5, an = 6, cn = 7, So = 8, Tr = 13, Or = 14, un = 16, Mr = 40, Pr = 41, Hr = 42, qr = 43, Dr = 44, Ao = 1040, jr = 1059, Co = 1063, Bo = 1311, ko = 1971, _o = 1984, Io = 1984, Uo = 1985, Lo = 4550, $o = 5999, Ro = 6999, To = 7e3, Oo = 9041, Mo = 9734, Po = 9735, Ho = 9802, qo = 1e4, Do = 10001, jo = 10002, zo = 10003, Wo = 10004, Vo = 10005, Zo = 10006, Go = 10007, Fo = 10015, Jo = 10030, Yo = 10050, Xo = 10096, Qo = 13194, ea = 21e3, zr = 22242, Wr = 23194, ta = 23195, na = 24133, ln = 27235, ra = 3e4, ia = 30001, sa = 30002, oa = 30003, aa = 30004, ca = 30008, ua = 30009, la = 30015, fa = 30017, ha = 30018, da = 30023, pa = 30024, ya = 30030, ga = 30078, wa = 30311, ba = 30315, va = 30402, ma = 30403, Ea = 31922, xa = 31923, Ka = 31924, Na = 31925, Sa = 31989, Aa = 31990, Ca = 34550, Ba = {};
2556
- P(Ba, {
2555
+ var vo = 0, Rr = 1, mo = 2, Eo = 3, xo = 4, No = 5, an = 6, cn = 7, Ko = 8, Tr = 13, Or = 14, un = 16, Mr = 40, Pr = 41, Hr = 42, qr = 43, Dr = 44, So = 1040, jr = 1059, Ao = 1063, Co = 1311, Bo = 1971, ko = 1984, Io = 1984, _o = 1985, Uo = 4550, Lo = 5999, $o = 6999, Ro = 7e3, To = 9041, Oo = 9734, Mo = 9735, Po = 9802, Ho = 1e4, qo = 10001, Do = 10002, jo = 10003, zo = 10004, Wo = 10005, Vo = 10006, Zo = 10007, Fo = 10015, Go = 10030, Jo = 10050, Yo = 10096, Xo = 13194, Qo = 21e3, zr = 22242, Wr = 23194, ea = 23195, ta = 24133, ln = 27235, na = 3e4, ra = 30001, ia = 30002, sa = 30003, oa = 30004, aa = 30008, ca = 30009, ua = 30015, la = 30017, fa = 30018, ha = 30023, da = 30024, pa = 30030, ya = 30078, ga = 30311, wa = 30315, ba = 30402, va = 30403, ma = 31922, Ea = 31923, xa = 31924, Na = 31925, Ka = 31989, Sa = 31990, Aa = 34550, Ca = {};
2556
+ H(Ca, {
2557
2557
  getHex64: () => fn,
2558
2558
  getInt: () => Vr,
2559
- getSubscriptionId: () => ka,
2560
- matchEventId: () => _a,
2561
- matchEventKind: () => Ua,
2559
+ getSubscriptionId: () => Ba,
2560
+ matchEventId: () => ka,
2561
+ matchEventKind: () => _a,
2562
2562
  matchEventPubkey: () => Ia
2563
2563
  });
2564
2564
  function fn(e, t) {
@@ -2569,7 +2569,7 @@ function Vr(e, t) {
2569
2569
  let n = t.length, r = e.indexOf(`"${t}":`) + n + 3, i = e.slice(r), s = Math.min(i.indexOf(","), i.indexOf("}"));
2570
2570
  return parseInt(i.slice(0, s), 10);
2571
2571
  }
2572
- function ka(e) {
2572
+ function Ba(e) {
2573
2573
  let t = e.slice(0, 22).indexOf('"EVENT"');
2574
2574
  if (t === -1)
2575
2575
  return null;
@@ -2582,20 +2582,20 @@ function ka(e) {
2582
2582
  let s = r + 1 + i;
2583
2583
  return e.slice(r + 1, s);
2584
2584
  }
2585
- function _a(e, t) {
2585
+ function ka(e, t) {
2586
2586
  return t === fn(e, "id");
2587
2587
  }
2588
2588
  function Ia(e, t) {
2589
2589
  return t === fn(e, "pubkey");
2590
2590
  }
2591
- function Ua(e, t) {
2591
+ function _a(e, t) {
2592
2592
  return t === Vr(e, "kind");
2593
2593
  }
2594
- var La = {};
2595
- P(La, {
2596
- makeAuthEvent: () => $a
2594
+ var Ua = {};
2595
+ H(Ua, {
2596
+ makeAuthEvent: () => La
2597
2597
  });
2598
- function $a(e, t) {
2598
+ function La(e, t) {
2599
2599
  return {
2600
2600
  kind: zr,
2601
2601
  created_at: Math.floor(Date.now() / 1e3),
@@ -2606,32 +2606,32 @@ function $a(e, t) {
2606
2606
  content: ""
2607
2607
  };
2608
2608
  }
2609
- var Ra;
2609
+ var $a;
2610
2610
  try {
2611
- Ra = WebSocket;
2611
+ $a = WebSocket;
2612
2612
  } catch {
2613
2613
  }
2614
- var Ta;
2614
+ var Ra;
2615
2615
  try {
2616
- Ta = WebSocket;
2616
+ Ra = WebSocket;
2617
2617
  } catch {
2618
2618
  }
2619
- var Oa = {};
2620
- P(Oa, {
2619
+ var Ta = {};
2620
+ H(Ta, {
2621
2621
  BECH32_REGEX: () => Zr,
2622
2622
  Bech32MaxSize: () => hn,
2623
- NostrTypeGuard: () => Ma,
2624
- decode: () => bt,
2625
- decodeNostrURI: () => Ha,
2626
- encodeBytes: () => mt,
2627
- naddrEncode: () => Va,
2628
- neventEncode: () => Wa,
2629
- noteEncode: () => ja,
2630
- nprofileEncode: () => za,
2631
- npubEncode: () => Da,
2632
- nsecEncode: () => qa
2623
+ NostrTypeGuard: () => Oa,
2624
+ decode: () => wt,
2625
+ decodeNostrURI: () => Pa,
2626
+ encodeBytes: () => vt,
2627
+ naddrEncode: () => Wa,
2628
+ neventEncode: () => za,
2629
+ noteEncode: () => Da,
2630
+ nprofileEncode: () => ja,
2631
+ npubEncode: () => qa,
2632
+ nsecEncode: () => Ha
2633
2633
  });
2634
- var Ma = {
2634
+ var Oa = {
2635
2635
  isNProfile: (e) => /^nprofile1[a-z\d]+$/.test(e || ""),
2636
2636
  isNEvent: (e) => /^nevent1[a-z\d]+$/.test(e || ""),
2637
2637
  isNAddr: (e) => /^naddr1[a-z\d]+$/.test(e || ""),
@@ -2640,23 +2640,23 @@ var Ma = {
2640
2640
  isNote: (e) => /^note1[a-z\d]+$/.test(e || ""),
2641
2641
  isNcryptsec: (e) => /^ncryptsec1[a-z\d]+$/.test(e || "")
2642
2642
  }, hn = 5e3, Zr = /[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;
2643
- function Pa(e) {
2643
+ function Ma(e) {
2644
2644
  const t = new Uint8Array(4);
2645
2645
  return t[0] = e >> 24 & 255, t[1] = e >> 16 & 255, t[2] = e >> 8 & 255, t[3] = e & 255, t;
2646
2646
  }
2647
- function Ha(e) {
2647
+ function Pa(e) {
2648
2648
  try {
2649
- return e.startsWith("nostr:") && (e = e.substring(6)), bt(e);
2649
+ return e.startsWith("nostr:") && (e = e.substring(6)), wt(e);
2650
2650
  } catch {
2651
2651
  return { type: "invalid", data: null };
2652
2652
  }
2653
2653
  }
2654
- function bt(e) {
2654
+ function wt(e) {
2655
2655
  var i, s, o, c, a, l, f;
2656
2656
  let { prefix: t, words: n } = ze.decode(e, hn), r = new Uint8Array(ze.fromWords(n));
2657
2657
  switch (t) {
2658
2658
  case "nprofile": {
2659
- let u = Lt(r);
2659
+ let u = Ut(r);
2660
2660
  if (!((i = u[0]) != null && i[0]))
2661
2661
  throw new Error("missing TLV 0 for nprofile");
2662
2662
  if (u[0][0].length !== 32)
@@ -2664,13 +2664,13 @@ function bt(e) {
2664
2664
  return {
2665
2665
  type: "nprofile",
2666
2666
  data: {
2667
- pubkey: H(u[0][0]),
2668
- relays: u[1] ? u[1].map((g) => le.decode(g)) : []
2667
+ pubkey: P(u[0][0]),
2668
+ relays: u[1] ? u[1].map((p) => le.decode(p)) : []
2669
2669
  }
2670
2670
  };
2671
2671
  }
2672
2672
  case "nevent": {
2673
- let u = Lt(r);
2673
+ let u = Ut(r);
2674
2674
  if (!((s = u[0]) != null && s[0]))
2675
2675
  throw new Error("missing TLV 0 for nevent");
2676
2676
  if (u[0][0].length !== 32)
@@ -2682,15 +2682,15 @@ function bt(e) {
2682
2682
  return {
2683
2683
  type: "nevent",
2684
2684
  data: {
2685
- id: H(u[0][0]),
2686
- relays: u[1] ? u[1].map((g) => le.decode(g)) : [],
2687
- author: (o = u[2]) != null && o[0] ? H(u[2][0]) : void 0,
2688
- kind: (c = u[3]) != null && c[0] ? parseInt(H(u[3][0]), 16) : void 0
2685
+ id: P(u[0][0]),
2686
+ relays: u[1] ? u[1].map((p) => le.decode(p)) : [],
2687
+ author: (o = u[2]) != null && o[0] ? P(u[2][0]) : void 0,
2688
+ kind: (c = u[3]) != null && c[0] ? parseInt(P(u[3][0]), 16) : void 0
2689
2689
  }
2690
2690
  };
2691
2691
  }
2692
2692
  case "naddr": {
2693
- let u = Lt(r);
2693
+ let u = Ut(r);
2694
2694
  if (!((a = u[0]) != null && a[0]))
2695
2695
  throw new Error("missing TLV 0 for naddr");
2696
2696
  if (!((l = u[2]) != null && l[0]))
@@ -2705,9 +2705,9 @@ function bt(e) {
2705
2705
  type: "naddr",
2706
2706
  data: {
2707
2707
  identifier: le.decode(u[0][0]),
2708
- pubkey: H(u[2][0]),
2709
- kind: parseInt(H(u[3][0]), 16),
2710
- relays: u[1] ? u[1].map((g) => le.decode(g)) : []
2708
+ pubkey: P(u[2][0]),
2709
+ kind: parseInt(P(u[3][0]), 16),
2710
+ relays: u[1] ? u[1].map((p) => le.decode(p)) : []
2711
2711
  }
2712
2712
  };
2713
2713
  }
@@ -2715,12 +2715,12 @@ function bt(e) {
2715
2715
  return { type: t, data: r };
2716
2716
  case "npub":
2717
2717
  case "note":
2718
- return { type: t, data: H(r) };
2718
+ return { type: t, data: P(r) };
2719
2719
  default:
2720
2720
  throw new Error(`unknown prefix ${t}`);
2721
2721
  }
2722
2722
  }
2723
- function Lt(e) {
2723
+ function Ut(e) {
2724
2724
  let t = {}, n = e;
2725
2725
  for (; n.length > 0; ) {
2726
2726
  let r = n[0], i = n[1], s = n.slice(2, 2 + i);
@@ -2730,50 +2730,50 @@ function Lt(e) {
2730
2730
  }
2731
2731
  return t;
2732
2732
  }
2733
+ function Ha(e) {
2734
+ return vt("nsec", e);
2735
+ }
2733
2736
  function qa(e) {
2734
- return mt("nsec", e);
2737
+ return vt("npub", j(e));
2735
2738
  }
2736
2739
  function Da(e) {
2737
- return mt("npub", z(e));
2738
- }
2739
- function ja(e) {
2740
- return mt("note", z(e));
2740
+ return vt("note", j(e));
2741
2741
  }
2742
- function vt(e, t) {
2742
+ function bt(e, t) {
2743
2743
  let n = ze.toWords(t);
2744
2744
  return ze.encode(e, n, hn);
2745
2745
  }
2746
- function mt(e, t) {
2747
- return vt(e, t);
2746
+ function vt(e, t) {
2747
+ return bt(e, t);
2748
2748
  }
2749
- function za(e) {
2749
+ function ja(e) {
2750
2750
  let t = dn({
2751
- 0: [z(e.pubkey)],
2751
+ 0: [j(e.pubkey)],
2752
2752
  1: (e.relays || []).map((n) => ne.encode(n))
2753
2753
  });
2754
- return vt("nprofile", t);
2754
+ return bt("nprofile", t);
2755
2755
  }
2756
- function Wa(e) {
2756
+ function za(e) {
2757
2757
  let t;
2758
- e.kind !== void 0 && (t = Pa(e.kind));
2758
+ e.kind !== void 0 && (t = Ma(e.kind));
2759
2759
  let n = dn({
2760
- 0: [z(e.id)],
2760
+ 0: [j(e.id)],
2761
2761
  1: (e.relays || []).map((r) => ne.encode(r)),
2762
- 2: e.author ? [z(e.author)] : [],
2762
+ 2: e.author ? [j(e.author)] : [],
2763
2763
  3: t ? [new Uint8Array(t)] : []
2764
2764
  });
2765
- return vt("nevent", n);
2765
+ return bt("nevent", n);
2766
2766
  }
2767
- function Va(e) {
2767
+ function Wa(e) {
2768
2768
  let t = new ArrayBuffer(4);
2769
2769
  new DataView(t).setUint32(0, e.kind, !1);
2770
2770
  let n = dn({
2771
2771
  0: [ne.encode(e.identifier)],
2772
2772
  1: (e.relays || []).map((r) => ne.encode(r)),
2773
- 2: [z(e.pubkey)],
2773
+ 2: [j(e.pubkey)],
2774
2774
  3: [new Uint8Array(t)]
2775
2775
  });
2776
- return vt("naddr", n);
2776
+ return bt("naddr", n);
2777
2777
  }
2778
2778
  function dn(e) {
2779
2779
  let t = [];
@@ -2784,44 +2784,44 @@ function dn(e) {
2784
2784
  });
2785
2785
  }), ft(...t);
2786
2786
  }
2787
- var Za = {};
2788
- P(Za, {
2789
- decrypt: () => Ga,
2790
- encrypt: () => Gr
2787
+ var Va = {};
2788
+ H(Va, {
2789
+ decrypt: () => Za,
2790
+ encrypt: () => Fr
2791
2791
  });
2792
- function Gr(e, t, n) {
2793
- const r = e instanceof Uint8Array ? H(e) : e, i = Ie.getSharedSecret(r, "02" + t), s = Fr(i);
2792
+ function Fr(e, t, n) {
2793
+ const r = e instanceof Uint8Array ? P(e) : e, i = _e.getSharedSecret(r, "02" + t), s = Gr(i);
2794
2794
  let o = Uint8Array.from(yr(16)), c = ne.encode(n), a = Sr(s, o).encrypt(c), l = he.encode(new Uint8Array(a)), f = he.encode(new Uint8Array(o.buffer));
2795
2795
  return `${l}?iv=${f}`;
2796
2796
  }
2797
- function Ga(e, t, n) {
2798
- const r = e instanceof Uint8Array ? H(e) : e;
2799
- let [i, s] = n.split("?iv="), o = Ie.getSharedSecret(r, "02" + t), c = Fr(o), a = he.decode(s), l = he.decode(i), f = Sr(c, a).decrypt(l);
2797
+ function Za(e, t, n) {
2798
+ const r = e instanceof Uint8Array ? P(e) : e;
2799
+ let [i, s] = n.split("?iv="), o = _e.getSharedSecret(r, "02" + t), c = Gr(o), a = he.decode(s), l = he.decode(i), f = Sr(c, a).decrypt(l);
2800
2800
  return le.decode(f);
2801
2801
  }
2802
- function Fr(e) {
2802
+ function Gr(e) {
2803
2803
  return e.slice(1, 33);
2804
2804
  }
2805
2805
  var Fa = {};
2806
- P(Fa, {
2806
+ H(Fa, {
2807
2807
  NIP05_REGEX: () => pn,
2808
- isNip05: () => Ja,
2809
- isValid: () => Qa,
2808
+ isNip05: () => Ga,
2809
+ isValid: () => Xa,
2810
2810
  queryProfile: () => Jr,
2811
- searchDomain: () => Xa,
2812
- useFetchImplementation: () => Ya
2811
+ searchDomain: () => Ya,
2812
+ useFetchImplementation: () => Ja
2813
2813
  });
2814
- var pn = /^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/, Ja = (e) => pn.test(e || ""), Et;
2814
+ var pn = /^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/, Ga = (e) => pn.test(e || ""), mt;
2815
2815
  try {
2816
- Et = fetch;
2816
+ mt = fetch;
2817
2817
  } catch {
2818
2818
  }
2819
- function Ya(e) {
2820
- Et = e;
2819
+ function Ja(e) {
2820
+ mt = e;
2821
2821
  }
2822
- async function Xa(e, t = "") {
2822
+ async function Ya(e, t = "") {
2823
2823
  try {
2824
- const n = `https://${e}/.well-known/nostr.json?name=${t}`, r = await Et(n, { redirect: "manual" });
2824
+ const n = `https://${e}/.well-known/nostr.json?name=${t}`, r = await mt(n, { redirect: "manual" });
2825
2825
  if (r.status !== 200)
2826
2826
  throw Error("Wrong response code");
2827
2827
  return (await r.json()).names;
@@ -2836,7 +2836,7 @@ async function Jr(e) {
2836
2836
  return null;
2837
2837
  const [, n = "_", r] = t;
2838
2838
  try {
2839
- const s = `https://${r}/.well-known/nostr.json?name=${n}`, o = await Et(s, { redirect: "manual" });
2839
+ const s = `https://${r}/.well-known/nostr.json?name=${n}`, o = await mt(s, { redirect: "manual" });
2840
2840
  if (o.status !== 200)
2841
2841
  throw Error("Wrong response code");
2842
2842
  const c = await o.json(), a = c.names[n];
@@ -2845,15 +2845,15 @@ async function Jr(e) {
2845
2845
  return null;
2846
2846
  }
2847
2847
  }
2848
- async function Qa(e, t) {
2848
+ async function Xa(e, t) {
2849
2849
  const n = await Jr(t);
2850
2850
  return n ? n.pubkey === e : !1;
2851
2851
  }
2852
- var ec = {};
2853
- P(ec, {
2854
- parse: () => tc
2852
+ var Qa = {};
2853
+ H(Qa, {
2854
+ parse: () => ec
2855
2855
  });
2856
- function tc(e) {
2856
+ function ec(e) {
2857
2857
  const t = {
2858
2858
  reply: void 0,
2859
2859
  root: void 0,
@@ -2920,29 +2920,29 @@ function tc(e) {
2920
2920
  }
2921
2921
  }), t;
2922
2922
  }
2923
- var nc = {};
2924
- P(nc, {
2925
- fetchRelayInformation: () => ic,
2926
- useFetchImplementation: () => rc
2923
+ var tc = {};
2924
+ H(tc, {
2925
+ fetchRelayInformation: () => rc,
2926
+ useFetchImplementation: () => nc
2927
2927
  });
2928
2928
  var Yr;
2929
2929
  try {
2930
2930
  Yr = fetch;
2931
2931
  } catch {
2932
2932
  }
2933
- function rc(e) {
2933
+ function nc(e) {
2934
2934
  Yr = e;
2935
2935
  }
2936
- async function ic(e) {
2936
+ async function rc(e) {
2937
2937
  return await (await fetch(e.replace("ws://", "http://").replace("wss://", "https://"), {
2938
2938
  headers: { Accept: "application/nostr+json" }
2939
2939
  })).json();
2940
2940
  }
2941
- var sc = {};
2942
- P(sc, {
2941
+ var ic = {};
2942
+ H(ic, {
2943
2943
  fastEventHash: () => Qr,
2944
2944
  getPow: () => Xr,
2945
- minePow: () => oc
2945
+ minePow: () => sc
2946
2946
  });
2947
2947
  function Xr(e) {
2948
2948
  let t = 0;
@@ -2957,7 +2957,7 @@ function Xr(e) {
2957
2957
  }
2958
2958
  return t;
2959
2959
  }
2960
- function oc(e, t) {
2960
+ function sc(e, t) {
2961
2961
  let n = 0;
2962
2962
  const r = e, i = ["nonce", n.toString(), t.toString()];
2963
2963
  for (r.tags.push(i); ; ) {
@@ -2968,41 +2968,41 @@ function oc(e, t) {
2968
2968
  return r;
2969
2969
  }
2970
2970
  function Qr(e) {
2971
- return H(
2971
+ return P(
2972
2972
  fe(ne.encode(JSON.stringify([0, e.pubkey, e.created_at, e.kind, e.tags, e.content])))
2973
2973
  );
2974
2974
  }
2975
- var ac = {};
2976
- P(ac, {
2977
- unwrapEvent: () => bc,
2978
- unwrapManyEvents: () => vc,
2975
+ var oc = {};
2976
+ H(oc, {
2977
+ unwrapEvent: () => wc,
2978
+ unwrapManyEvents: () => bc,
2979
2979
  wrapEvent: () => hi,
2980
- wrapManyEvents: () => wc
2980
+ wrapManyEvents: () => gc
2981
2981
  });
2982
- var cc = {};
2983
- P(cc, {
2982
+ var ac = {};
2983
+ H(ac, {
2984
2984
  createRumor: () => ci,
2985
2985
  createSeal: () => ui,
2986
2986
  createWrap: () => li,
2987
2987
  unwrapEvent: () => vn,
2988
2988
  unwrapManyEvents: () => fi,
2989
2989
  wrapEvent: () => st,
2990
- wrapManyEvents: () => yc
2990
+ wrapManyEvents: () => pc
2991
2991
  });
2992
2992
  var D = {};
2993
- P(D, {
2993
+ H(D, {
2994
2994
  decrypt: () => bn,
2995
2995
  encrypt: () => wn,
2996
2996
  getConversationKey: () => yn,
2997
- v2: () => dc
2997
+ v2: () => hc
2998
2998
  });
2999
2999
  var ei = 1, ti = 65535;
3000
3000
  function yn(e, t) {
3001
- const n = Ie.getSharedSecret(e, "02" + t).subarray(1, 33);
3002
- return rn(fe, n, "nip44-v2");
3001
+ const n = _e.getSharedSecret(e, "02" + t).subarray(1, 33);
3002
+ return nn(fe, n, "nip44-v2");
3003
3003
  }
3004
3004
  function ni(e, t) {
3005
- const n = Ir(fe, e, t, 76);
3005
+ const n = _r(fe, e, t, 76);
3006
3006
  return {
3007
3007
  chacha_key: n.subarray(0, 32),
3008
3008
  chacha_nonce: n.subarray(32, 44),
@@ -3017,17 +3017,17 @@ function gn(e) {
3017
3017
  const t = 1 << Math.floor(Math.log2(e - 1)) + 1, n = t <= 256 ? 32 : t / 8;
3018
3018
  return n * (Math.floor((e - 1) / n) + 1);
3019
3019
  }
3020
- function uc(e) {
3020
+ function cc(e) {
3021
3021
  if (!Number.isSafeInteger(e) || e < ei || e > ti)
3022
3022
  throw new Error("invalid plaintext size: must be between 1 and 65535 bytes");
3023
3023
  const t = new Uint8Array(2);
3024
3024
  return new DataView(t.buffer).setUint16(0, e, !1), t;
3025
3025
  }
3026
- function lc(e) {
3027
- const t = ne.encode(e), n = t.length, r = uc(n), i = new Uint8Array(gn(n) - n);
3026
+ function uc(e) {
3027
+ const t = ne.encode(e), n = t.length, r = cc(n), i = new Uint8Array(gn(n) - n);
3028
3028
  return ft(r, t, i);
3029
3029
  }
3030
- function fc(e) {
3030
+ function lc(e) {
3031
3031
  const t = new DataView(e.buffer).getUint16(0), n = e.subarray(2, 2 + t);
3032
3032
  if (t < ei || t > ti || n.length !== t || e.length !== 2 + gn(t))
3033
3033
  throw new Error("invalid padding");
@@ -3039,7 +3039,7 @@ function ri(e, t, n) {
3039
3039
  const r = ft(n, t);
3040
3040
  return dt(fe, e, r);
3041
3041
  }
3042
- function hc(e) {
3042
+ function fc(e) {
3043
3043
  if (typeof e != "string")
3044
3044
  throw new Error("payload must be a valid string");
3045
3045
  const t = e.length;
@@ -3066,24 +3066,24 @@ function hc(e) {
3066
3066
  };
3067
3067
  }
3068
3068
  function wn(e, t, n = yr(32)) {
3069
- const { chacha_key: r, chacha_nonce: i, hmac_key: s } = ni(t, n), o = lc(e), c = kr(r, i, o), a = ri(s, c, n);
3069
+ const { chacha_key: r, chacha_nonce: i, hmac_key: s } = ni(t, n), o = uc(e), c = kr(r, i, o), a = ri(s, c, n);
3070
3070
  return he.encode(ft(new Uint8Array([2]), n, c, a));
3071
3071
  }
3072
3072
  function bn(e, t) {
3073
- const { nonce: n, ciphertext: r, mac: i } = hc(e), { chacha_key: s, chacha_nonce: o, hmac_key: c } = ni(t, n), a = ri(c, r, n);
3073
+ const { nonce: n, ciphertext: r, mac: i } = fc(e), { chacha_key: s, chacha_nonce: o, hmac_key: c } = ni(t, n), a = ri(c, r, n);
3074
3074
  if (!qs(a, i))
3075
3075
  throw new Error("invalid MAC");
3076
3076
  const l = kr(s, o, r);
3077
- return fc(l);
3077
+ return lc(l);
3078
3078
  }
3079
- var dc = {
3079
+ var hc = {
3080
3080
  utils: {
3081
3081
  getConversationKey: yn,
3082
3082
  calcPaddedLen: gn
3083
3083
  },
3084
3084
  encrypt: wn,
3085
3085
  decrypt: bn
3086
- }, pc = 2 * 24 * 60 * 60, ii = () => Math.round(Date.now() / 1e3), si = () => Math.round(ii() - Math.random() * pc), oi = (e, t) => yn(e, t), ai = (e, t, n) => wn(JSON.stringify(e), oi(t, n)), zn = (e, t) => JSON.parse(bn(e.content, oi(t, e.pubkey)));
3086
+ }, dc = 2 * 24 * 60 * 60, ii = () => Math.round(Date.now() / 1e3), si = () => Math.round(ii() - Math.random() * dc), oi = (e, t) => yn(e, t), ai = (e, t, n) => wn(JSON.stringify(e), oi(t, n)), zn = (e, t) => JSON.parse(bn(e.content, oi(t, e.pubkey)));
3087
3087
  function ci(e, t) {
3088
3088
  const n = {
3089
3089
  created_at: ii(),
@@ -3121,7 +3121,7 @@ function st(e, t, n) {
3121
3121
  const r = ci(e, t), i = ui(r, t, n);
3122
3122
  return li(i, n);
3123
3123
  }
3124
- function yc(e, t, n) {
3124
+ function pc(e, t, n) {
3125
3125
  if (!n || n.length === 0)
3126
3126
  throw new Error("At least one recipient is required.");
3127
3127
  const r = ae(t), i = [st(e, t, r)];
@@ -3139,7 +3139,7 @@ function fi(e, t) {
3139
3139
  n.push(vn(r, t));
3140
3140
  }), n.sort((r, i) => r.created_at - i.created_at), n;
3141
3141
  }
3142
- function gc(e, t, n, r) {
3142
+ function yc(e, t, n, r) {
3143
3143
  const i = {
3144
3144
  created_at: Math.ceil(Date.now() / 1e3),
3145
3145
  kind: Or,
@@ -3151,23 +3151,23 @@ function gc(e, t, n, r) {
3151
3151
  }), r && i.tags.push(["e", r.eventId, r.relayUrl || "", "reply"]), n && i.tags.push(["subject", n]), i;
3152
3152
  }
3153
3153
  function hi(e, t, n, r, i) {
3154
- const s = gc(t, n, r, i);
3154
+ const s = yc(t, n, r, i);
3155
3155
  return st(s, e, t.publicKey);
3156
3156
  }
3157
- function wc(e, t, n, r, i) {
3157
+ function gc(e, t, n, r, i) {
3158
3158
  if (!t || t.length === 0)
3159
3159
  throw new Error("At least one recipient is required.");
3160
3160
  return [{ publicKey: ae(e) }, ...t].map(
3161
3161
  (o) => hi(e, o, n, r, i)
3162
3162
  );
3163
3163
  }
3164
- var bc = vn, vc = fi, mc = {};
3165
- P(mc, {
3166
- finishRepostEvent: () => Ec,
3167
- getRepostedEvent: () => xc,
3164
+ var wc = vn, bc = fi, vc = {};
3165
+ H(vc, {
3166
+ finishRepostEvent: () => mc,
3167
+ getRepostedEvent: () => Ec,
3168
3168
  getRepostedEventPointer: () => di
3169
3169
  });
3170
- function Ec(e, t, n, r) {
3170
+ function mc(e, t, n, r) {
3171
3171
  var o;
3172
3172
  let i;
3173
3173
  const s = [...e.tags ?? [], ["e", t.id, n], ["p", t.pubkey]];
@@ -3196,7 +3196,7 @@ function di(e) {
3196
3196
  author: n == null ? void 0 : n[1]
3197
3197
  };
3198
3198
  }
3199
- function xc(e, { skipVerification: t } = {}) {
3199
+ function Ec(e, { skipVerification: t } = {}) {
3200
3200
  const n = di(e);
3201
3201
  if (n === void 0 || e.content === "")
3202
3202
  return;
@@ -3209,32 +3209,32 @@ function xc(e, { skipVerification: t } = {}) {
3209
3209
  if (r.id === n.id && !(!t && !gt(r)))
3210
3210
  return r;
3211
3211
  }
3212
- var Kc = {};
3213
- P(Kc, {
3212
+ var xc = {};
3213
+ H(xc, {
3214
3214
  NOSTR_URI_REGEX: () => mn,
3215
- parse: () => Sc,
3215
+ parse: () => Kc,
3216
3216
  test: () => Nc
3217
3217
  });
3218
3218
  var mn = new RegExp(`nostr:(${Zr.source})`);
3219
3219
  function Nc(e) {
3220
3220
  return typeof e == "string" && new RegExp(`^${mn.source}$`).test(e);
3221
3221
  }
3222
- function Sc(e) {
3222
+ function Kc(e) {
3223
3223
  const t = e.match(new RegExp(`^${mn.source}$`));
3224
3224
  if (!t)
3225
3225
  throw new Error(`Invalid Nostr URI: ${e}`);
3226
3226
  return {
3227
3227
  uri: t[0],
3228
3228
  value: t[1],
3229
- decoded: bt(t[1])
3229
+ decoded: wt(t[1])
3230
3230
  };
3231
3231
  }
3232
- var Ac = {};
3233
- P(Ac, {
3234
- finishReactionEvent: () => Cc,
3235
- getReactedEventPointer: () => Bc
3232
+ var Sc = {};
3233
+ H(Sc, {
3234
+ finishReactionEvent: () => Ac,
3235
+ getReactedEventPointer: () => Cc
3236
3236
  });
3237
- function Cc(e, t, n) {
3237
+ function Ac(e, t, n) {
3238
3238
  const r = t.tags.filter((i) => i.length >= 2 && (i[0] === "e" || i[0] === "p"));
3239
3239
  return Q(
3240
3240
  {
@@ -3246,7 +3246,7 @@ function Cc(e, t, n) {
3246
3246
  n
3247
3247
  );
3248
3248
  }
3249
- function Bc(e) {
3249
+ function Cc(e) {
3250
3250
  if (e.kind !== cn)
3251
3251
  return;
3252
3252
  let t, n;
@@ -3261,11 +3261,11 @@ function Bc(e) {
3261
3261
  author: n[1]
3262
3262
  };
3263
3263
  }
3264
- var kc = {};
3265
- P(kc, {
3264
+ var Bc = {};
3265
+ H(Bc, {
3266
3266
  parse: () => Ic
3267
3267
  });
3268
- var _c = /\W/m, Wn = /\W |\W$|$|,| /m;
3268
+ var kc = /\W/m, Wn = /\W |\W$|$|,| /m;
3269
3269
  function* Ic(e) {
3270
3270
  const t = e.length;
3271
3271
  let n = 0, r = 0;
@@ -3274,9 +3274,9 @@ function* Ic(e) {
3274
3274
  if (i === -1)
3275
3275
  break;
3276
3276
  if (e.substring(i - 5, i) === "nostr") {
3277
- const s = e.substring(i + 60).match(_c), o = s ? i + 60 + s.index : t;
3277
+ const s = e.substring(i + 60).match(kc), o = s ? i + 60 + s.index : t;
3278
3278
  try {
3279
- let c, { data: a, type: l } = bt(e.substring(i + 1, o));
3279
+ let c, { data: a, type: l } = wt(e.substring(i + 1, o));
3280
3280
  switch (l) {
3281
3281
  case "npub":
3282
3282
  c = { pubkey: a };
@@ -3337,15 +3337,15 @@ function* Ic(e) {
3337
3337
  }
3338
3338
  n !== t && (yield { type: "text", text: e.substring(n) });
3339
3339
  }
3340
- var Uc = {};
3341
- P(Uc, {
3342
- channelCreateEvent: () => Lc,
3343
- channelHideMessageEvent: () => Tc,
3344
- channelMessageEvent: () => Rc,
3345
- channelMetadataEvent: () => $c,
3346
- channelMuteUserEvent: () => Oc
3340
+ var _c = {};
3341
+ H(_c, {
3342
+ channelCreateEvent: () => Uc,
3343
+ channelHideMessageEvent: () => Rc,
3344
+ channelMessageEvent: () => $c,
3345
+ channelMetadataEvent: () => Lc,
3346
+ channelMuteUserEvent: () => Tc
3347
3347
  });
3348
- var Lc = (e, t) => {
3348
+ var Uc = (e, t) => {
3349
3349
  let n;
3350
3350
  if (typeof e.content == "object")
3351
3351
  n = JSON.stringify(e.content);
@@ -3362,7 +3362,7 @@ var Lc = (e, t) => {
3362
3362
  },
3363
3363
  t
3364
3364
  );
3365
- }, $c = (e, t) => {
3365
+ }, Lc = (e, t) => {
3366
3366
  let n;
3367
3367
  if (typeof e.content == "object")
3368
3368
  n = JSON.stringify(e.content);
@@ -3379,7 +3379,7 @@ var Lc = (e, t) => {
3379
3379
  },
3380
3380
  t
3381
3381
  );
3382
- }, Rc = (e, t) => {
3382
+ }, $c = (e, t) => {
3383
3383
  const n = [["e", e.channel_create_event_id, e.relay_url, "root"]];
3384
3384
  return e.reply_to_channel_message_event_id && n.push(["e", e.reply_to_channel_message_event_id, e.relay_url, "reply"]), Q(
3385
3385
  {
@@ -3390,7 +3390,7 @@ var Lc = (e, t) => {
3390
3390
  },
3391
3391
  t
3392
3392
  );
3393
- }, Tc = (e, t) => {
3393
+ }, Rc = (e, t) => {
3394
3394
  let n;
3395
3395
  if (typeof e.content == "object")
3396
3396
  n = JSON.stringify(e.content);
@@ -3407,7 +3407,7 @@ var Lc = (e, t) => {
3407
3407
  },
3408
3408
  t
3409
3409
  );
3410
- }, Oc = (e, t) => {
3410
+ }, Tc = (e, t) => {
3411
3411
  let n;
3412
3412
  if (typeof e.content == "object")
3413
3413
  n = JSON.stringify(e.content);
@@ -3424,15 +3424,15 @@ var Lc = (e, t) => {
3424
3424
  },
3425
3425
  t
3426
3426
  );
3427
- }, Mc = {};
3428
- P(Mc, {
3427
+ }, Oc = {};
3428
+ H(Oc, {
3429
3429
  EMOJI_SHORTCODE_REGEX: () => pi,
3430
- matchAll: () => Pc,
3430
+ matchAll: () => Mc,
3431
3431
  regex: () => En,
3432
- replaceAll: () => Hc
3432
+ replaceAll: () => Pc
3433
3433
  });
3434
3434
  var pi = /:(\w+):/, En = () => new RegExp(`\\B${pi.source}\\B`, "g");
3435
- function* Pc(e) {
3435
+ function* Mc(e) {
3436
3436
  const t = e.matchAll(En());
3437
3437
  for (const n of t)
3438
3438
  try {
@@ -3446,45 +3446,45 @@ function* Pc(e) {
3446
3446
  } catch {
3447
3447
  }
3448
3448
  }
3449
- function Hc(e, t) {
3449
+ function Pc(e, t) {
3450
3450
  return e.replaceAll(En(), (n, r) => t({
3451
3451
  shortcode: n,
3452
3452
  name: r
3453
3453
  }));
3454
3454
  }
3455
- var qc = {};
3456
- P(qc, {
3457
- useFetchImplementation: () => Dc,
3458
- validateGithub: () => jc
3455
+ var Hc = {};
3456
+ H(Hc, {
3457
+ useFetchImplementation: () => qc,
3458
+ validateGithub: () => Dc
3459
3459
  });
3460
3460
  var xn;
3461
3461
  try {
3462
3462
  xn = fetch;
3463
3463
  } catch {
3464
3464
  }
3465
- function Dc(e) {
3465
+ function qc(e) {
3466
3466
  xn = e;
3467
3467
  }
3468
- async function jc(e, t, n) {
3468
+ async function Dc(e, t, n) {
3469
3469
  try {
3470
3470
  return await (await xn(`https://gist.github.com/${t}/${n}/raw`)).text() === `Verifying that I control the following Nostr public key: ${e}`;
3471
3471
  } catch {
3472
3472
  return !1;
3473
3473
  }
3474
3474
  }
3475
- var zc = {};
3476
- P(zc, {
3477
- makeNwcRequestEvent: () => Vc,
3478
- parseConnectionString: () => Wc
3475
+ var jc = {};
3476
+ H(jc, {
3477
+ makeNwcRequestEvent: () => Wc,
3478
+ parseConnectionString: () => zc
3479
3479
  });
3480
- function Wc(e) {
3480
+ function zc(e) {
3481
3481
  const { pathname: t, searchParams: n } = new URL(e), r = t, i = n.get("relay"), s = n.get("secret");
3482
3482
  if (!r || !i || !s)
3483
3483
  throw new Error("invalid connection string");
3484
3484
  return { pubkey: r, relay: i, secret: s };
3485
3485
  }
3486
- async function Vc(e, t, n) {
3487
- const i = await Gr(t, e, JSON.stringify({
3486
+ async function Wc(e, t, n) {
3487
+ const i = Fr(t, e, JSON.stringify({
3488
3488
  method: "pay_invoice",
3489
3489
  params: {
3490
3490
  invoice: n
@@ -3497,30 +3497,31 @@ async function Vc(e, t, n) {
3497
3497
  };
3498
3498
  return Q(s, t);
3499
3499
  }
3500
- var Zc = {};
3501
- P(Zc, {
3502
- normalizeIdentifier: () => Gc
3500
+ var Vc = {};
3501
+ H(Vc, {
3502
+ normalizeIdentifier: () => Zc
3503
3503
  });
3504
- function Gc(e) {
3504
+ function Zc(e) {
3505
3505
  return e = e.trim().toLowerCase(), e = e.normalize("NFKC"), Array.from(e).map((t) => new RegExp("\\p{Letter}", "u").test(t) || new RegExp("\\p{Number}", "u").test(t) ? t : "-").join("");
3506
3506
  }
3507
3507
  var Fc = {};
3508
- P(Fc, {
3509
- getZapEndpoint: () => Yc,
3510
- makeZapReceipt: () => eu,
3511
- makeZapRequest: () => Xc,
3512
- useFetchImplementation: () => Jc,
3513
- validateZapRequest: () => Qc
3508
+ H(Fc, {
3509
+ getSatoshisAmountFromBolt11: () => eu,
3510
+ getZapEndpoint: () => Jc,
3511
+ makeZapReceipt: () => Qc,
3512
+ makeZapRequest: () => Yc,
3513
+ useFetchImplementation: () => Gc,
3514
+ validateZapRequest: () => Xc
3514
3515
  });
3515
- var Kn;
3516
+ var Nn;
3516
3517
  try {
3517
- Kn = fetch;
3518
+ Nn = fetch;
3518
3519
  } catch {
3519
3520
  }
3520
- function Jc(e) {
3521
- Kn = e;
3521
+ function Gc(e) {
3522
+ Nn = e;
3522
3523
  }
3523
- async function Yc(e) {
3524
+ async function Jc(e) {
3524
3525
  try {
3525
3526
  let t = "", { lud06: n, lud16: r } = JSON.parse(e.content);
3526
3527
  if (n) {
@@ -3531,14 +3532,14 @@ async function Yc(e) {
3531
3532
  t = new URL(`/.well-known/lnurlp/${o}`, `https://${c}`).toString();
3532
3533
  } else
3533
3534
  return null;
3534
- let s = await (await Kn(t)).json();
3535
+ let s = await (await Nn(t)).json();
3535
3536
  if (s.allowsNostr && s.nostrPubkey)
3536
3537
  return s.callback;
3537
3538
  } catch {
3538
3539
  }
3539
3540
  return null;
3540
3541
  }
3541
- function Xc({
3542
+ function Yc({
3542
3543
  profile: e,
3543
3544
  event: t,
3544
3545
  amount: n,
@@ -3560,10 +3561,10 @@ function Xc({
3560
3561
  ]
3561
3562
  };
3562
3563
  if (t && typeof t == "string" && s.tags.push(["e", t]), t && typeof t == "object") {
3563
- if (on(t.kind)) {
3564
+ if (sn(t.kind)) {
3564
3565
  const o = ["a", `${t.kind}:${t.pubkey}:`];
3565
3566
  s.tags.push(o);
3566
- } else if (wt(t.kind)) {
3567
+ } else if (on(t.kind)) {
3567
3568
  let o = t.tags.find(([a, l]) => a === "d" && l);
3568
3569
  if (!o)
3569
3570
  throw new Error("d tag not found or is empty");
@@ -3573,7 +3574,7 @@ function Xc({
3573
3574
  }
3574
3575
  return s;
3575
3576
  }
3576
- function Qc(e) {
3577
+ function Xc(e) {
3577
3578
  let t;
3578
3579
  try {
3579
3580
  t = JSON.parse(e);
@@ -3592,7 +3593,7 @@ function Qc(e) {
3592
3593
  let r = t.tags.find(([s, o]) => s === "e" && o);
3593
3594
  return r && !r[1].match(/^[a-f0-9]{64}$/) ? "Zap request 'e' tag is not valid hex." : t.tags.find(([s, o]) => s === "relays" && o) ? null : "Zap request doesn't have a 'relays' tag.";
3594
3595
  }
3595
- function eu({
3596
+ function Qc({
3596
3597
  zapRequest: e,
3597
3598
  preimage: t,
3598
3599
  bolt11: n,
@@ -3606,10 +3607,41 @@ function eu({
3606
3607
  };
3607
3608
  return t && o.tags.push(["preimage", t]), o;
3608
3609
  }
3610
+ function eu(e) {
3611
+ if (e.length < 50)
3612
+ return 0;
3613
+ e = e.substring(0, 50);
3614
+ const t = e.lastIndexOf("1");
3615
+ if (t === -1)
3616
+ return 0;
3617
+ const n = e.substring(0, t);
3618
+ if (!n.startsWith("lnbc"))
3619
+ return 0;
3620
+ const r = n.substring(4);
3621
+ if (r.length < 1)
3622
+ return 0;
3623
+ const i = r[r.length - 1], s = i.charCodeAt(0) - 48, o = s >= 0 && s <= 9;
3624
+ let c = r.length - 1;
3625
+ if (o && c++, c < 1)
3626
+ return 0;
3627
+ const a = parseInt(r.substring(0, c));
3628
+ switch (i) {
3629
+ case "m":
3630
+ return a * 1e5;
3631
+ case "u":
3632
+ return a * 100;
3633
+ case "n":
3634
+ return a / 10;
3635
+ case "p":
3636
+ return a / 1e4;
3637
+ default:
3638
+ return a * 1e8;
3639
+ }
3640
+ }
3609
3641
  var tu = {};
3610
- P(tu, {
3642
+ H(tu, {
3611
3643
  getToken: () => nu,
3612
- hashPayload: () => Nn,
3644
+ hashPayload: () => Kn,
3613
3645
  unpackEventFromToken: () => gi,
3614
3646
  validateEvent: () => xi,
3615
3647
  validateEventKind: () => bi,
@@ -3630,7 +3662,7 @@ async function nu(e, t, n, r = !1, i) {
3630
3662
  created_at: Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3),
3631
3663
  content: ""
3632
3664
  };
3633
- i && s.tags.push(["payload", Nn(i)]);
3665
+ i && s.tags.push(["payload", Kn(i)]);
3634
3666
  const o = await n(s);
3635
3667
  return (r ? yi : "") + he.encode(ne.encode(JSON.stringify(o)));
3636
3668
  }
@@ -3665,15 +3697,15 @@ function mi(e, t) {
3665
3697
  const n = e.tags.find((r) => r[0] === "method");
3666
3698
  return n ? n.length > 0 && n[1].toLowerCase() === t.toLowerCase() : !1;
3667
3699
  }
3668
- function Nn(e) {
3700
+ function Kn(e) {
3669
3701
  const t = fe(ne.encode(JSON.stringify(e)));
3670
- return H(t);
3702
+ return P(t);
3671
3703
  }
3672
3704
  function Ei(e, t) {
3673
3705
  const n = e.tags.find((i) => i[0] === "payload");
3674
3706
  if (!n)
3675
3707
  return !1;
3676
- const r = Nn(t);
3708
+ const r = Kn(t);
3677
3709
  return n.length > 0 && n[1] === r;
3678
3710
  }
3679
3711
  async function xi(e, t, n, r) {
@@ -3695,19 +3727,19 @@ const Oe = 1060, Vn = 30078, Zn = 1059, iu = 14, wu = 100, su = 1;
3695
3727
  function bu(e) {
3696
3728
  return JSON.stringify({
3697
3729
  version: su,
3698
- rootKey: H(e.rootKey),
3730
+ rootKey: P(e.rootKey),
3699
3731
  theirCurrentNostrPublicKey: e.theirCurrentNostrPublicKey,
3700
3732
  theirNextNostrPublicKey: e.theirNextNostrPublicKey,
3701
3733
  ourCurrentNostrKey: e.ourCurrentNostrKey ? {
3702
3734
  publicKey: e.ourCurrentNostrKey.publicKey,
3703
- privateKey: H(e.ourCurrentNostrKey.privateKey)
3735
+ privateKey: P(e.ourCurrentNostrKey.privateKey)
3704
3736
  } : void 0,
3705
3737
  ourNextNostrKey: {
3706
3738
  publicKey: e.ourNextNostrKey.publicKey,
3707
- privateKey: H(e.ourNextNostrKey.privateKey)
3739
+ privateKey: P(e.ourNextNostrKey.privateKey)
3708
3740
  },
3709
- receivingChainKey: e.receivingChainKey ? H(e.receivingChainKey) : void 0,
3710
- sendingChainKey: e.sendingChainKey ? H(e.sendingChainKey) : void 0,
3741
+ receivingChainKey: e.receivingChainKey ? P(e.receivingChainKey) : void 0,
3742
+ sendingChainKey: e.sendingChainKey ? P(e.sendingChainKey) : void 0,
3711
3743
  sendingChainMessageNumber: e.sendingChainMessageNumber,
3712
3744
  receivingChainMessageNumber: e.receivingChainMessageNumber,
3713
3745
  previousSendingChainMessageCount: e.previousSendingChainMessageCount,
@@ -3715,11 +3747,11 @@ function bu(e) {
3715
3747
  Object.entries(e.skippedKeys).map(([t, n]) => [
3716
3748
  t,
3717
3749
  {
3718
- headerKeys: n.headerKeys.map((r) => H(r)),
3750
+ headerKeys: n.headerKeys.map((r) => P(r)),
3719
3751
  messageKeys: Object.fromEntries(
3720
3752
  Object.entries(n.messageKeys).map(([r, i]) => [
3721
3753
  r,
3722
- H(i)
3754
+ P(i)
3723
3755
  ])
3724
3756
  )
3725
3757
  }
@@ -3738,19 +3770,19 @@ function vu(e) {
3738
3770
  messageKeys: i
3739
3771
  };
3740
3772
  }), {
3741
- rootKey: z(t.rootKey),
3773
+ rootKey: j(t.rootKey),
3742
3774
  theirCurrentNostrPublicKey: t.theirCurrentNostrPublicKey,
3743
3775
  theirNextNostrPublicKey: t.theirNextNostrPublicKey,
3744
3776
  ourCurrentNostrKey: t.ourCurrentNostrKey ? {
3745
3777
  publicKey: t.ourCurrentNostrKey.publicKey,
3746
- privateKey: z(t.ourCurrentNostrKey.privateKey)
3778
+ privateKey: j(t.ourCurrentNostrKey.privateKey)
3747
3779
  } : void 0,
3748
3780
  ourNextNostrKey: {
3749
3781
  publicKey: t.ourNextNostrKey.publicKey,
3750
- privateKey: z(t.ourNextNostrKey.privateKey)
3782
+ privateKey: j(t.ourNextNostrKey.privateKey)
3751
3783
  },
3752
- receivingChainKey: t.receivingChainKey ? z(t.receivingChainKey) : void 0,
3753
- sendingChainKey: t.sendingChainKey ? z(t.sendingChainKey) : void 0,
3784
+ receivingChainKey: t.receivingChainKey ? j(t.receivingChainKey) : void 0,
3785
+ sendingChainKey: t.sendingChainKey ? j(t.sendingChainKey) : void 0,
3754
3786
  sendingChainMessageNumber: t.sendingChainMessageNumber,
3755
3787
  receivingChainMessageNumber: t.receivingChainMessageNumber,
3756
3788
  previousSendingChainMessageCount: t.previousSendingChainMessageCount,
@@ -3758,19 +3790,19 @@ function vu(e) {
3758
3790
  };
3759
3791
  }
3760
3792
  return {
3761
- rootKey: z(t.rootKey),
3793
+ rootKey: j(t.rootKey),
3762
3794
  theirCurrentNostrPublicKey: t.theirCurrentNostrPublicKey,
3763
3795
  theirNextNostrPublicKey: t.theirNextNostrPublicKey,
3764
3796
  ourCurrentNostrKey: t.ourCurrentNostrKey ? {
3765
3797
  publicKey: t.ourCurrentNostrKey.publicKey,
3766
- privateKey: z(t.ourCurrentNostrKey.privateKey)
3798
+ privateKey: j(t.ourCurrentNostrKey.privateKey)
3767
3799
  } : void 0,
3768
3800
  ourNextNostrKey: {
3769
3801
  publicKey: t.ourNextNostrKey.publicKey,
3770
- privateKey: z(t.ourNextNostrKey.privateKey)
3802
+ privateKey: j(t.ourNextNostrKey.privateKey)
3771
3803
  },
3772
- receivingChainKey: t.receivingChainKey ? z(t.receivingChainKey) : void 0,
3773
- sendingChainKey: t.sendingChainKey ? z(t.sendingChainKey) : void 0,
3804
+ receivingChainKey: t.receivingChainKey ? j(t.receivingChainKey) : void 0,
3805
+ sendingChainKey: t.sendingChainKey ? j(t.sendingChainKey) : void 0,
3774
3806
  sendingChainMessageNumber: t.sendingChainMessageNumber,
3775
3807
  receivingChainMessageNumber: t.receivingChainMessageNumber,
3776
3808
  previousSendingChainMessageCount: t.previousSendingChainMessageCount,
@@ -3778,11 +3810,11 @@ function vu(e) {
3778
3810
  Object.entries(t.skippedKeys || {}).map(([n, r]) => [
3779
3811
  n,
3780
3812
  {
3781
- headerKeys: r.headerKeys.map((i) => z(i)),
3813
+ headerKeys: r.headerKeys.map((i) => j(i)),
3782
3814
  messageKeys: Object.fromEntries(
3783
3815
  Object.entries(r.messageKeys).map(([i, s]) => [
3784
3816
  i,
3785
- z(s)
3817
+ j(s)
3786
3818
  ])
3787
3819
  )
3788
3820
  }
@@ -3806,9 +3838,9 @@ async function* mu(e) {
3806
3838
  }
3807
3839
  }
3808
3840
  function Me(e, t = new Uint8Array(32), n = 1) {
3809
- const r = rn(fe, e, t), i = [];
3841
+ const r = nn(fe, e, t), i = [];
3810
3842
  for (let s = 1; s <= n; s++)
3811
- i.push(Ir(fe, r, new Uint8Array([s]), 32));
3843
+ i.push(_r(fe, r, new Uint8Array([s]), 32));
3812
3844
  return i;
3813
3845
  }
3814
3846
  function Eu(e, t) {
@@ -3833,9 +3865,9 @@ class ot {
3833
3865
  }
3834
3866
  /**
3835
3867
  * Initializes a new secure communication session
3836
- * @param nostrSubscribe Function to subscribe to Nostr events. Make sure it deduplicates events (doesnt return the same event twice), otherwise you'll see decryption errors!
3837
- * @param theirNextNostrPublicKey The public key of the other party
3838
- * @param ourCurrentPrivateKey Our current private key for Nostr
3868
+ * @param nostrSubscribe Function to subscribe to Nostr events. Make sure it deduplicates events (doesn't return the same event twice), otherwise you'll see decryption errors!
3869
+ * @param theirEphemeralNostrPublicKey The ephemeral public key of the other party for the initial handshake
3870
+ * @param ourEphemeralNostrPrivateKey Our ephemeral private key for the initial handshake
3839
3871
  * @param isInitiator Whether we are initiating the conversation (true) or responding (false)
3840
3872
  * @param sharedSecret Initial shared secret for securing the first message chain
3841
3873
  * @param name Optional name for the session (for debugging)
@@ -3854,7 +3886,7 @@ class ot {
3854
3886
  publicKey: ae(r),
3855
3887
  privateKey: r
3856
3888
  });
3857
- const g = {
3889
+ const p = {
3858
3890
  rootKey: a,
3859
3891
  theirNextNostrPublicKey: n,
3860
3892
  ourCurrentNostrKey: f,
@@ -3865,7 +3897,7 @@ class ot {
3865
3897
  receivingChainMessageNumber: 0,
3866
3898
  previousSendingChainMessageCount: 0,
3867
3899
  skippedKeys: {}
3868
- }, w = new ot(t, g);
3900
+ }, w = new ot(t, p);
3869
3901
  return o && (w.name = o), w;
3870
3902
  }
3871
3903
  /**
@@ -4007,17 +4039,25 @@ class ot {
4007
4039
  throw new Error("Failed to decrypt header with current and skipped header keys");
4008
4040
  }
4009
4041
  handleNostrEvent(t) {
4010
- var c, a;
4011
- const [n, r, i] = this.decryptHeader(t);
4012
- if (!i)
4013
- this.state.theirNextNostrPublicKey !== n.nextPublicKey && (this.state.theirCurrentNostrPublicKey = this.state.theirNextNostrPublicKey, this.state.theirNextNostrPublicKey = n.nextPublicKey, (c = this.nostrUnsubscribe) == null || c.call(this), this.nostrUnsubscribe = this.nostrNextUnsubscribe, this.nostrNextUnsubscribe = this.nostrSubscribe(
4014
- { authors: [this.state.theirNextNostrPublicKey], kinds: [Oe] },
4015
- (l) => this.handleNostrEvent(l)
4016
- )), r && (this.skipMessageKeys(n.previousChainLength, t.pubkey), this.ratchetStep());
4017
- else if (!((a = this.state.skippedKeys[t.pubkey]) != null && a.messageKeys[n.number]))
4018
- return;
4019
- const s = this.ratchetDecrypt(n, t.content, t.pubkey), o = JSON.parse(s);
4020
- pt(o) && o.id === qe(o) && this.internalSubscriptions.forEach((l) => l(o, t));
4042
+ var n, r;
4043
+ try {
4044
+ const [i, s, o] = this.decryptHeader(t);
4045
+ if (!o)
4046
+ this.state.theirNextNostrPublicKey !== i.nextPublicKey && (this.state.theirCurrentNostrPublicKey = this.state.theirNextNostrPublicKey, this.state.theirNextNostrPublicKey = i.nextPublicKey, (n = this.nostrUnsubscribe) == null || n.call(this), this.nostrUnsubscribe = this.nostrNextUnsubscribe, this.nostrNextUnsubscribe = this.nostrSubscribe(
4047
+ { authors: [this.state.theirNextNostrPublicKey], kinds: [Oe] },
4048
+ (l) => this.handleNostrEvent(l)
4049
+ )), s && (this.skipMessageKeys(i.previousChainLength, t.pubkey), this.ratchetStep());
4050
+ else if (!((r = this.state.skippedKeys[t.pubkey]) != null && r.messageKeys[i.number]))
4051
+ return;
4052
+ const c = this.ratchetDecrypt(i, t.content, t.pubkey), a = JSON.parse(c);
4053
+ if (!pt(a) || a.id !== qe(a))
4054
+ return;
4055
+ this.internalSubscriptions.forEach((l) => l(a, t));
4056
+ } catch (i) {
4057
+ if (i instanceof Error && i.message.includes("Failed to decrypt header"))
4058
+ return;
4059
+ throw i;
4060
+ }
4021
4061
  }
4022
4062
  subscribeToNostrEvents() {
4023
4063
  if (this.nostrNextUnsubscribe) return;
@@ -4038,18 +4078,18 @@ class ot {
4038
4078
  new TextDecoder("utf-8");
4039
4079
  new TextEncoder();
4040
4080
  function Qe(e, t) {
4041
- const n = Ie.getSharedSecret(e, "02" + t).subarray(1, 33);
4042
- return rn(fe, n, "nip44-v2");
4081
+ const n = _e.getSharedSecret(e, "02" + t).subarray(1, 33);
4082
+ return nn(fe, n, "nip44-v2");
4043
4083
  }
4044
4084
  const cu = 2 * 24 * 60 * 60, uu = () => Math.round(Date.now() / 1e3), lu = () => Math.round(uu() - Math.random() * cu);
4045
4085
  class Pe {
4046
4086
  constructor(t, n, r, i, s, o, c = []) {
4047
- this.inviterEphemeralPublicKey = t, this.sharedSecret = n, this.inviter = r, this.inviterEphemeralPrivateKey = i, this.label = s, this.maxUses = o, this.usedBy = c;
4087
+ this.inviterEphemeralPublicKey = t, this.sharedSecret = n, this.inviter = r, this.inviterEphemeralPrivateKey = i, this.deviceId = s, this.maxUses = o, this.usedBy = c;
4048
4088
  }
4049
4089
  static createNew(t, n, r) {
4050
4090
  if (!t)
4051
4091
  throw new Error("Inviter public key is required");
4052
- const i = ke(), s = ae(i), o = H(ke());
4092
+ const i = ke(), s = ae(i), o = P(ke());
4053
4093
  return new Pe(
4054
4094
  s,
4055
4095
  o,
@@ -4086,13 +4126,13 @@ class Pe {
4086
4126
  n.sharedSecret,
4087
4127
  n.inviter,
4088
4128
  n.inviterEphemeralPrivateKey ? new Uint8Array(n.inviterEphemeralPrivateKey) : void 0,
4089
- n.label,
4129
+ n.deviceId,
4090
4130
  n.maxUses,
4091
4131
  n.usedBy
4092
4132
  );
4093
4133
  }
4094
4134
  static fromEvent(t) {
4095
- var o, c;
4135
+ var a, l, f, u;
4096
4136
  if (!t.sig)
4097
4137
  throw new Error("Event is not signed");
4098
4138
  if (!gt(t))
@@ -4100,13 +4140,16 @@ class Pe {
4100
4140
  const { tags: n } = t;
4101
4141
  if (!n)
4102
4142
  throw new Error("Invalid invite event: missing tags");
4103
- const r = (o = n.find(([a]) => a === "ephemeralKey")) == null ? void 0 : o[1], i = (c = n.find(([a]) => a === "sharedSecret")) == null ? void 0 : c[1], s = t.pubkey;
4143
+ const r = (a = n.find(([p]) => p === "ephemeralKey")) == null ? void 0 : a[1], i = (l = n.find(([p]) => p === "sharedSecret")) == null ? void 0 : l[1], s = t.pubkey, o = (f = n.find(([p]) => p === "d")) == null ? void 0 : f[1], c = (u = o == null ? void 0 : o.split("/")) == null ? void 0 : u[2];
4104
4144
  if (!r || !i)
4105
4145
  throw new Error("Invalid invite event: missing session key or sharedSecret");
4106
4146
  return new Pe(
4107
4147
  r,
4108
4148
  i,
4109
- s
4149
+ s,
4150
+ void 0,
4151
+ // inviterEphemeralPrivateKey not available when parsing from event
4152
+ c
4110
4153
  );
4111
4154
  }
4112
4155
  static fromUser(t, n, r) {
@@ -4114,11 +4157,10 @@ class Pe {
4114
4157
  kinds: [Vn],
4115
4158
  authors: [t],
4116
4159
  "#l": ["double-ratchet/invites"]
4117
- };
4118
- let s = 0;
4160
+ }, s = /* @__PURE__ */ new Set();
4119
4161
  return n(i, (c) => {
4120
- if (!(!c.created_at || c.created_at <= s)) {
4121
- s = c.created_at;
4162
+ if (!s.has(c.id)) {
4163
+ s.add(c.id);
4122
4164
  try {
4123
4165
  const a = Pe.fromEvent(c);
4124
4166
  r(a);
@@ -4136,7 +4178,7 @@ class Pe {
4136
4178
  sharedSecret: this.sharedSecret,
4137
4179
  inviter: this.inviter,
4138
4180
  inviterEphemeralPrivateKey: this.inviterEphemeralPrivateKey ? Array.from(this.inviterEphemeralPrivateKey) : void 0,
4139
- label: this.label,
4181
+ deviceId: this.deviceId,
4140
4182
  maxUses: this.maxUses,
4141
4183
  usedBy: this.usedBy
4142
4184
  });
@@ -4152,9 +4194,9 @@ class Pe {
4152
4194
  }, r = new URL(t);
4153
4195
  return r.hash = encodeURIComponent(JSON.stringify(n)), r.toString();
4154
4196
  }
4155
- getEvent(t) {
4156
- if (!t)
4157
- throw new Error("Device name is required");
4197
+ getEvent() {
4198
+ if (!this.deviceId)
4199
+ throw new Error("Device ID is required");
4158
4200
  return {
4159
4201
  kind: Vn,
4160
4202
  pubkey: this.inviter,
@@ -4163,18 +4205,19 @@ class Pe {
4163
4205
  tags: [
4164
4206
  ["ephemeralKey", this.inviterEphemeralPublicKey],
4165
4207
  ["sharedSecret", this.sharedSecret],
4166
- ["d", "double-ratchet/invites/" + t],
4208
+ ["d", "double-ratchet/invites/" + this.deviceId],
4167
4209
  ["l", "double-ratchet/invites"]
4168
4210
  ]
4169
4211
  };
4170
4212
  }
4171
4213
  /**
4172
4214
  * Called by the invitee. Accepts the invite and creates a new session with the inviter.
4173
- *
4174
- * @param inviteeSecretKey - The invitee's secret key or a signing function
4215
+ *
4175
4216
  * @param nostrSubscribe - A function to subscribe to Nostr events
4217
+ * @param inviteePublicKey - The invitee's public key
4218
+ * @param encryptor - The invitee's secret key or a signing/encrypt function
4176
4219
  * @returns An object containing the new session and an event to be published
4177
- *
4220
+ *
4178
4221
  * 1. Inner event: No signature, content encrypted with DH(inviter, invitee).
4179
4222
  * Purpose: Authenticate invitee. Contains invitee session key.
4180
4223
  * 2. Envelope: No signature, content encrypted with DH(inviter, random key).
@@ -4184,14 +4227,14 @@ class Pe {
4184
4227
  * so the inviter can create the session on their side.
4185
4228
  */
4186
4229
  async accept(t, n, r) {
4187
- const i = ke(), s = ae(i), o = this.inviter || this.inviterEphemeralPublicKey, c = z(this.sharedSecret), a = ot.init(t, this.inviterEphemeralPublicKey, i, !0, c, void 0), f = await (typeof r == "function" ? r : (d, p) => Promise.resolve(D.encrypt(d, Qe(r, p))))(s, o), u = {
4230
+ const i = ke(), s = ae(i), o = this.inviter || this.inviterEphemeralPublicKey, c = j(this.sharedSecret), a = ot.init(t, this.inviterEphemeralPublicKey, i, !0, c, void 0), f = await (typeof r == "function" ? r : (d, y) => Promise.resolve(D.encrypt(d, Qe(r, y))))(s, o), u = {
4188
4231
  pubkey: n,
4189
4232
  content: await D.encrypt(f, c),
4190
4233
  created_at: Math.floor(Date.now() / 1e3)
4191
- }, g = JSON.stringify(u), w = ke(), y = ae(w), h = {
4234
+ }, p = JSON.stringify(u), w = ke(), g = ae(w), h = {
4192
4235
  kind: Zn,
4193
- pubkey: y,
4194
- content: D.encrypt(g, Qe(w, this.inviterEphemeralPublicKey)),
4236
+ pubkey: g,
4237
+ content: D.encrypt(p, Qe(w, this.inviterEphemeralPublicKey)),
4195
4238
  created_at: lu(),
4196
4239
  tags: [["p", this.inviterEphemeralPublicKey]]
4197
4240
  };
@@ -4208,10 +4251,10 @@ class Pe {
4208
4251
  try {
4209
4252
  if (this.maxUses && this.usedBy.length >= this.maxUses)
4210
4253
  return;
4211
- const o = await D.decrypt(s.content, Qe(this.inviterEphemeralPrivateKey, s.pubkey)), c = JSON.parse(o), a = z(this.sharedSecret), l = c.pubkey;
4254
+ const o = await D.decrypt(s.content, Qe(this.inviterEphemeralPrivateKey, s.pubkey)), c = JSON.parse(o), a = j(this.sharedSecret), l = c.pubkey;
4212
4255
  this.usedBy.push(l);
4213
- const f = await D.decrypt(c.content, a), g = await (typeof t == "function" ? t : (h, d) => Promise.resolve(D.decrypt(h, Qe(t, d))))(f, l), w = s.id, y = ot.init(n, g, this.inviterEphemeralPrivateKey, !1, a, w);
4214
- r(y, l);
4256
+ const f = await D.decrypt(c.content, a), p = await (typeof t == "function" ? t : (h, d) => Promise.resolve(D.decrypt(h, Qe(t, d))))(f, l), w = s.id, g = ot.init(n, p, this.inviterEphemeralPrivateKey, !1, a, w);
4257
+ r(g, l);
4215
4258
  } catch {
4216
4259
  }
4217
4260
  });