@icp-sdk/vetkeys 0.5.0-beta.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,16 +2,16 @@ var Rn = (t) => {
2
2
  throw TypeError(t);
3
3
  };
4
4
  var Bn = (t, e, r) => e.has(t) || Rn("Cannot " + r);
5
- var K = (t, e, r) => (Bn(t, e, "read from private field"), r ? r.call(t) : e.get(t)), oe = (t, e, r) => e.has(t) ? Rn("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), te = (t, e, r, n) => (Bn(t, e, "write to private field"), n ? n.call(t, r) : e.set(t, r), r);
5
+ var z = (t, e, r) => (Bn(t, e, "read from private field"), r ? r.call(t) : e.get(t)), ie = (t, e, r) => e.has(t) ? Rn("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), te = (t, e, r, n) => (Bn(t, e, "write to private field"), n ? n.call(t, r) : e.set(t, r), r);
6
6
  var Un = (t, e, r, n) => ({
7
7
  set _(s) {
8
8
  te(t, e, s, r);
9
9
  },
10
10
  get _() {
11
- return K(t, e, n);
11
+ return z(t, e, n);
12
12
  }
13
13
  });
14
- import { s as di, h as Gr, b as V, c as ge, d as pe, e as hi, u as U, F as as, _ as li, f as cs, w as yi, r as pi, g as $r, i as Nn, j as Ht, k as Rr, l as Pn, m as Ne, n as Ft, p as mi, o as wi, q as Mn, t as gi, v as Be, x as xe, y as bi } from "./index-BUXhtQhx.mjs";
14
+ import { s as hi, h as Gr, b as V, c as me, d as le, e as li, u as U, F as cs, _ as yi, f as us, w as pi, r as mi, g as $r, i as Nn, j as Ht, k as Rr, l as Pn, m as Ne, n as Ft, p as wi, o as gi, q as Mn, t as bi, v as Be, x as ge, y as xi } from "./index-BUXhtQhx.mjs";
15
15
  var kn;
16
16
  (function(t) {
17
17
  t[t.SysFatal = 1] = "SysFatal", t[t.SysTransient = 2] = "SysTransient", t[t.DestinationInvalid = 3] = "DestinationInvalid", t[t.CanisterReject = 4] = "CanisterReject", t[t.CanisterError = 5] = "CanisterError";
@@ -20,10 +20,10 @@ var at;
20
20
  (function(t) {
21
21
  t.Replied = "replied", t.Rejected = "rejected";
22
22
  })(at || (at = {}));
23
- function xi(t) {
23
+ function _i(t) {
24
24
  return t != null && "reject_code" in t;
25
25
  }
26
- function _i(t) {
26
+ function Ti(t) {
27
27
  return t != null && "certificate" in t;
28
28
  }
29
29
  const Qt = "abcdefghijklmnopqrstuvwxyz234567", ct = /* @__PURE__ */ Object.create(null);
@@ -31,7 +31,7 @@ for (let t = 0; t < Qt.length; t++)
31
31
  ct[Qt[t]] = t;
32
32
  ct[0] = ct.o;
33
33
  ct[1] = ct.i;
34
- function Ti(t) {
34
+ function Ei(t) {
35
35
  let e = 0, r = 0, n = "";
36
36
  function s(i) {
37
37
  return e < 0 ? r |= i >> -e : r = i << e & 248, e > 3 ? (e -= 8, 1) : (e < 4 && (n += Qt[r >> 3], e += 5), 0);
@@ -40,7 +40,7 @@ function Ti(t) {
40
40
  i += s(t[i]);
41
41
  return n + (e < 0 ? Qt[r >> 3] : "");
42
42
  }
43
- function Ei(t) {
43
+ function Ci(t) {
44
44
  let e = 0, r = 0;
45
45
  const n = new Uint8Array(t.length * 4 / 3 | 0);
46
46
  let s = 0;
@@ -54,7 +54,7 @@ function Ei(t) {
54
54
  i(o);
55
55
  return n.slice(0, s);
56
56
  }
57
- const Ci = new Uint32Array([
57
+ const Ii = new Uint32Array([
58
58
  0,
59
59
  1996959894,
60
60
  3993919788,
@@ -312,15 +312,15 @@ const Ci = new Uint32Array([
312
312
  1510334235,
313
313
  755167117
314
314
  ]);
315
- function Ii(t) {
315
+ function vi(t) {
316
316
  let e = -1;
317
317
  for (let r = 0; r < t.length; r++) {
318
318
  const s = (t[r] ^ e) & 255;
319
- e = Ci[s] ^ e >>> 8;
319
+ e = Ii[s] ^ e >>> 8;
320
320
  }
321
321
  return (e ^ -1) >>> 0;
322
322
  }
323
- const qt = "__principal__", vi = 2, Vn = 4, Si = "aaaaa-aa";
323
+ const qt = "__principal__", Si = 2, Vn = 4, Ai = "aaaaa-aa";
324
324
  let A = class nt {
325
325
  static anonymous() {
326
326
  return new this(new Uint8Array([Vn]));
@@ -330,11 +330,11 @@ let A = class nt {
330
330
  * @returns {Principal} principal of the management canister
331
331
  */
332
332
  static managementCanister() {
333
- return this.fromText(Si);
333
+ return this.fromText(Ai);
334
334
  }
335
335
  static selfAuthenticating(e) {
336
- const r = di(e);
337
- return new this(new Uint8Array([...r, vi]));
336
+ const r = hi(e);
337
+ return new this(new Uint8Array([...r, Si]));
338
338
  }
339
339
  static from(e) {
340
340
  if (typeof e == "string")
@@ -355,7 +355,7 @@ let A = class nt {
355
355
  qt in o && (r = o[qt]);
356
356
  }
357
357
  const n = r.toLowerCase().replace(/-/g, "");
358
- let s = Ei(n);
358
+ let s = Ci(n);
359
359
  s = s.slice(4, s.length);
360
360
  const i = new this(s);
361
361
  if (i.toText() !== r)
@@ -382,8 +382,8 @@ let A = class nt {
382
382
  }
383
383
  toText() {
384
384
  const e = new ArrayBuffer(4);
385
- new DataView(e).setUint32(0, Ii(this._arr));
386
- const n = new Uint8Array(e), s = new Uint8Array([...n, ...this._arr]), o = Ti(s).match(/.{1,5}/g);
385
+ new DataView(e).setUint32(0, vi(this._arr));
386
+ const n = new Uint8Array(e), s = new Uint8Array([...n, ...this._arr]), o = Ei(s).match(/.{1,5}/g);
387
387
  if (!o)
388
388
  throw new Error();
389
389
  return o.join("-");
@@ -439,9 +439,9 @@ var Jt;
439
439
  (function(t) {
440
440
  t.Normal = "normal", t.Verbose = "verbose";
441
441
  })(Jt || (Jt = {}));
442
- const Ai = /* @__PURE__ */ new Set(["arg", "certificate", "nonce"]);
442
+ const Oi = /* @__PURE__ */ new Set(["arg", "certificate", "nonce"]);
443
443
  function Xr(t) {
444
- return (e, r) => r instanceof Uint8Array ? t === Jt.Normal && Ai.has(e) ? `<${r.length} bytes, set ErrorCode.verbosity = ErrorVerbosity.Verbose to display>` : `hex(${r.length}):${V(r)}` : r;
444
+ return (e, r) => r instanceof Uint8Array ? t === Jt.Normal && Oi.has(e) ? `<${r.length} bytes, set ErrorCode.verbosity = ErrorVerbosity.Verbose to display>` : `hex(${r.length}):${V(r)}` : r;
445
445
  }
446
446
  const ur = class ur {
447
447
  constructor(e = !1) {
@@ -463,7 +463,7 @@ Call context:
463
463
  };
464
464
  ur.verbosity = Jt.Normal;
465
465
  let T = ur;
466
- class _e extends Error {
466
+ class xe extends Error {
467
467
  get code() {
468
468
  return this.cause.code;
469
469
  }
@@ -484,7 +484,7 @@ class _e extends Error {
484
484
  return this.code.isCertified;
485
485
  }
486
486
  constructor(e, r) {
487
- super(e.toString()), this.name = "AgentError", this.cause = { code: e, kind: r }, Object.setPrototypeOf(this, _e.prototype);
487
+ super(e.toString()), this.name = "AgentError", this.cause = { code: e, kind: r }, Object.setPrototypeOf(this, xe.prototype);
488
488
  }
489
489
  hasCode(e) {
490
490
  return this.code instanceof e;
@@ -493,14 +493,14 @@ class _e extends Error {
493
493
  return `${this.name} (${this.kind}): ${this.message}`;
494
494
  }
495
495
  }
496
- class et extends _e {
496
+ class et extends xe {
497
497
  static fromCode(e) {
498
498
  return new this(e);
499
499
  }
500
500
  }
501
- class ae extends et {
501
+ class oe extends et {
502
502
  constructor(e) {
503
- super(e, Ae.Trust), this.name = "TrustError", Object.setPrototypeOf(this, ae.prototype);
503
+ super(e, Ae.Trust), this.name = "TrustError", Object.setPrototypeOf(this, oe.prototype);
504
504
  }
505
505
  }
506
506
  class M extends et {
@@ -518,9 +518,9 @@ class er extends et {
518
518
  super(e, Ae.Transport), this.name = "TransportError", Object.setPrototypeOf(this, er.prototype);
519
519
  }
520
520
  }
521
- class ce extends et {
521
+ class ae extends et {
522
522
  constructor(e) {
523
- super(e, Ae.External), this.name = "ExternalError", Object.setPrototypeOf(this, ce.prototype);
523
+ super(e, Ae.External), this.name = "ExternalError", Object.setPrototypeOf(this, ae.prototype);
524
524
  }
525
525
  }
526
526
  class N extends et {
@@ -750,9 +750,9 @@ class Le extends T {
750
750
  return "This identity has expired due this application's security policy. Please refresh your authentication.";
751
751
  }
752
752
  }
753
- class ve extends T {
753
+ class Ie extends T {
754
754
  constructor(e, r) {
755
- super(), this.message = e, this.providedIngressExpiryInMinutes = r, this.name = "IngressExpiryInvalidErrorCode", Object.setPrototypeOf(this, ve.prototype);
755
+ super(), this.message = e, this.providedIngressExpiryInMinutes = r, this.name = "IngressExpiryInvalidErrorCode", Object.setPrototypeOf(this, Ie.prototype);
756
756
  }
757
757
  toErrorMessage() {
758
758
  return `${this.message}. Provided ingress expiry time is ${this.providedIngressExpiryInMinutes} minutes.`;
@@ -927,7 +927,7 @@ class lt {
927
927
  constructor(e, r = e?.byteLength || 0) {
928
928
  if (e && !(e instanceof Uint8Array))
929
929
  try {
930
- e = us(e);
930
+ e = fs(e);
931
931
  } catch {
932
932
  throw new Error("Buffer must be a Uint8Array");
933
933
  }
@@ -984,10 +984,10 @@ class lt {
984
984
  n.set(this._view), this._buffer = r, this._view = n;
985
985
  }
986
986
  }
987
- function us(t) {
987
+ function fs(t) {
988
988
  if (!t)
989
989
  throw new Error("Input cannot be null or undefined");
990
- return t instanceof Uint8Array ? t : t instanceof ArrayBuffer ? new Uint8Array(t) : Array.isArray(t) ? new Uint8Array(t) : "buffer" in t ? us(t.buffer) : new Uint8Array(t);
990
+ return t instanceof Uint8Array ? t : t instanceof ArrayBuffer ? new Uint8Array(t) : Array.isArray(t) ? new Uint8Array(t) : "buffer" in t ? fs(t.buffer) : new Uint8Array(t);
991
991
  }
992
992
  function bn(t, e) {
993
993
  if (t.byteLength !== e.byteLength)
@@ -997,12 +997,12 @@ function bn(t, e) {
997
997
  return t[r] - e[r];
998
998
  return 0;
999
999
  }
1000
- function Oi(t) {
1000
+ function $i(t) {
1001
1001
  if (!(t instanceof Uint8Array))
1002
1002
  throw new Error("Input must be a Uint8Array");
1003
1003
  return new DataView(t.buffer, t.byteOffset, t.byteLength);
1004
1004
  }
1005
- function $i(t) {
1005
+ function Ri(t) {
1006
1006
  const r = new TextEncoder().encode(t);
1007
1007
  let n = 0;
1008
1008
  for (const s of r)
@@ -1015,9 +1015,9 @@ function Q(t) {
1015
1015
  if (Number.isSafeInteger(e) && e >= 0 && e < 2 ** 32)
1016
1016
  return e;
1017
1017
  }
1018
- return $i(t);
1018
+ return Ri(t);
1019
1019
  }
1020
- function fs(t) {
1020
+ function ds(t) {
1021
1021
  const e = BigInt(t);
1022
1022
  if (t <= 0)
1023
1023
  throw new RangeError("Input must be positive");
@@ -1029,20 +1029,20 @@ function Br(t) {
1029
1029
  throw new RangeError("Input must be non-negative");
1030
1030
  return BigInt(1) << e;
1031
1031
  }
1032
- function ds() {
1032
+ function hs() {
1033
1033
  throw new Error("unexpected end of buffer");
1034
1034
  }
1035
1035
  function Ze(t, e) {
1036
- return t.byteLength < e && ds(), t.read(e);
1036
+ return t.byteLength < e && hs(), t.read(e);
1037
1037
  }
1038
1038
  function We(t) {
1039
1039
  const e = t.readUint8();
1040
- return e === void 0 && ds(), e;
1040
+ return e === void 0 && hs(), e;
1041
1041
  }
1042
1042
  function D(t) {
1043
1043
  if (typeof t == "number" && (t = BigInt(t)), t < BigInt(0))
1044
1044
  throw new Error("Cannot leb encode negative values.");
1045
- const e = (t === BigInt(0) ? 0 : fs(t)) + 1, r = new lt(new Uint8Array(e), 0);
1045
+ const e = (t === BigInt(0) ? 0 : ds(t)) + 1, r = new lt(new Uint8Array(e), 0);
1046
1046
  for (; ; ) {
1047
1047
  const n = Number(t & BigInt(127));
1048
1048
  if (t /= BigInt(128), t === BigInt(0)) {
@@ -1064,7 +1064,7 @@ function Y(t) {
1064
1064
  typeof t == "number" && (t = BigInt(t));
1065
1065
  const e = t < BigInt(0);
1066
1066
  e && (t = -t - BigInt(1));
1067
- const r = (t === BigInt(0) ? 0 : fs(t)) + 1, n = new lt(new Uint8Array(r), 0);
1067
+ const r = (t === BigInt(0) ? 0 : ds(t)) + 1, n = new lt(new Uint8Array(r), 0);
1068
1068
  for (; ; ) {
1069
1069
  const i = s(t);
1070
1070
  if (t /= BigInt(128), e && t === BigInt(0) && (i & 64) !== 0 || !e && t === BigInt(0) && (i & 64) === 0) {
@@ -1094,12 +1094,12 @@ function Pe(t) {
1094
1094
  s = s * BigInt(128) + BigInt(128 - (n[i] & 127) - 1);
1095
1095
  return -s - BigInt(1);
1096
1096
  }
1097
- function Ri(t, e) {
1097
+ function Bi(t, e) {
1098
1098
  if (BigInt(t) < BigInt(0))
1099
1099
  throw new Error("Cannot write negative values.");
1100
- return hs(t, e);
1100
+ return ls(t, e);
1101
1101
  }
1102
- function hs(t, e) {
1102
+ function ls(t, e) {
1103
1103
  t = BigInt(t);
1104
1104
  const r = new lt(new Uint8Array(Math.min(1, e)), 0);
1105
1105
  let n = 0, s = BigInt(256), i = BigInt(0), o = Number(t % s);
@@ -1107,7 +1107,7 @@ function hs(t, e) {
1107
1107
  t < 0 && i === BigInt(0) && o !== 0 && (i = BigInt(1)), o = Number((t / s - i) % BigInt(256)), r.write(new Uint8Array([o])), s *= BigInt(256);
1108
1108
  return r.buffer;
1109
1109
  }
1110
- function ls(t, e) {
1110
+ function ys(t, e) {
1111
1111
  if (e <= 0 || !Number.isInteger(e))
1112
1112
  throw new Error("Byte length must be a positive integer");
1113
1113
  let r = BigInt(We(t)), n = BigInt(1), s = 0;
@@ -1118,10 +1118,10 @@ function ls(t, e) {
1118
1118
  }
1119
1119
  return r;
1120
1120
  }
1121
- function Bi(t, e) {
1121
+ function Ui(t, e) {
1122
1122
  if (e <= 0 || !Number.isInteger(e))
1123
1123
  throw new Error("Byte length must be a positive integer");
1124
- let r = ls(t, e);
1124
+ let r = ys(t, e);
1125
1125
  const n = BigInt(2) ** (BigInt(8) * BigInt(e - 1) + BigInt(7));
1126
1126
  return r >= n && (r -= n * BigInt(2)), r;
1127
1127
  }
@@ -1134,11 +1134,11 @@ var O;
1134
1134
  (function(t) {
1135
1135
  t[t.Null = -1] = "Null", t[t.Bool = -2] = "Bool", t[t.Nat = -3] = "Nat", t[t.Int = -4] = "Int", t[t.Float32 = -13] = "Float32", t[t.Float64 = -14] = "Float64", t[t.Text = -15] = "Text", t[t.Reserved = -16] = "Reserved", t[t.Empty = -17] = "Empty", t[t.Opt = -18] = "Opt", t[t.Vector = -19] = "Vector", t[t.Record = -20] = "Record", t[t.Variant = -21] = "Variant", t[t.Func = -22] = "Func", t[t.Service = -23] = "Service", t[t.Principal = -24] = "Principal";
1136
1136
  })(O || (O = {}));
1137
- const Yt = "DIDL", Ui = new TextEncoder().encode(Yt), jn = 400;
1137
+ const Yt = "DIDL", Ni = new TextEncoder().encode(Yt), jn = 400;
1138
1138
  function Et(t, e, r) {
1139
1139
  return t.map((n, s) => r(n, e[s]));
1140
1140
  }
1141
- class Ni {
1141
+ class Pi {
1142
1142
  constructor() {
1143
1143
  this._typs = [], this._idx = /* @__PURE__ */ new Map(), this._idxRefCount = /* @__PURE__ */ new Map();
1144
1144
  }
@@ -1180,7 +1180,7 @@ class Ni {
1180
1180
  return Y(this._idx.get(e) || 0);
1181
1181
  }
1182
1182
  }
1183
- class Pi {
1183
+ class Mi {
1184
1184
  visitType(e, r) {
1185
1185
  throw new Error("Not implemented");
1186
1186
  }
@@ -1262,14 +1262,14 @@ class yr {
1262
1262
  return this.name;
1263
1263
  }
1264
1264
  valueToString(e) {
1265
- return q(e);
1265
+ return L(e);
1266
1266
  }
1267
1267
  /* Implement `T` in the IDL spec, only needed for non-primitive types */
1268
1268
  buildTypeTable(e) {
1269
1269
  e.has(this) || this._buildTypeTableImpl(e);
1270
1270
  }
1271
1271
  }
1272
- class fe extends yr {
1272
+ class ue extends yr {
1273
1273
  checkType(e) {
1274
1274
  if (this.name !== e.name)
1275
1275
  throw new Error(`type mismatch: type on the wire ${e.name}, expect type ${this.name}`);
@@ -1280,7 +1280,7 @@ class fe extends yr {
1280
1280
  }
1281
1281
  class Fe extends yr {
1282
1282
  checkType(e) {
1283
- if (e instanceof ue) {
1283
+ if (e instanceof ce) {
1284
1284
  const r = e.getType();
1285
1285
  if (typeof r > "u")
1286
1286
  throw new J("Type mismatch: cannot decode from uninitialized recursive type");
@@ -1292,7 +1292,7 @@ class Fe extends yr {
1292
1292
  return e.indexOf(this.name);
1293
1293
  }
1294
1294
  }
1295
- class xn extends fe {
1295
+ class xn extends ue {
1296
1296
  get typeName() {
1297
1297
  return E.EmptyClass;
1298
1298
  }
@@ -1303,7 +1303,7 @@ class xn extends fe {
1303
1303
  return e.visitEmpty(this, r);
1304
1304
  }
1305
1305
  covariant(e) {
1306
- throw new Error(`Invalid ${this.display()} argument: ${q(e)}`);
1306
+ throw new Error(`Invalid ${this.display()} argument: ${L(e)}`);
1307
1307
  }
1308
1308
  encodeValue() {
1309
1309
  throw new Error("Empty cannot appear as a function argument");
@@ -1321,7 +1321,7 @@ class xn extends fe {
1321
1321
  return "empty";
1322
1322
  }
1323
1323
  }
1324
- class ys extends yr {
1324
+ class ps extends yr {
1325
1325
  get typeName() {
1326
1326
  return E.UnknownClass;
1327
1327
  }
@@ -1335,7 +1335,7 @@ class ys extends yr {
1335
1335
  throw e.visitType(this, r);
1336
1336
  }
1337
1337
  covariant(e) {
1338
- throw new Error(`Invalid ${this.display()} argument: ${q(e)}`);
1338
+ throw new Error(`Invalid ${this.display()} argument: ${L(e)}`);
1339
1339
  }
1340
1340
  encodeValue() {
1341
1341
  throw new Error("Unknown cannot appear as a function argument");
@@ -1350,7 +1350,7 @@ class ys extends yr {
1350
1350
  let n = r.decodeValue(e, r);
1351
1351
  Object(n) !== n && (n = Object(n));
1352
1352
  let s;
1353
- return r instanceof ue ? s = () => r.getType() : s = () => r, Object.defineProperty(n, "type", {
1353
+ return r instanceof ce ? s = () => r.getType() : s = () => r, Object.defineProperty(n, "type", {
1354
1354
  value: s,
1355
1355
  writable: !0,
1356
1356
  enumerable: !1,
@@ -1364,7 +1364,7 @@ class ys extends yr {
1364
1364
  return "Unknown";
1365
1365
  }
1366
1366
  }
1367
- class ps extends fe {
1367
+ class ms extends ue {
1368
1368
  get typeName() {
1369
1369
  return E.BoolClass;
1370
1370
  }
@@ -1377,7 +1377,7 @@ class ps extends fe {
1377
1377
  covariant(e) {
1378
1378
  if (typeof e == "boolean")
1379
1379
  return !0;
1380
- throw new Error(`Invalid ${this.display()} argument: ${q(e)}`);
1380
+ throw new Error(`Invalid ${this.display()} argument: ${L(e)}`);
1381
1381
  }
1382
1382
  encodeValue(e) {
1383
1383
  return new Uint8Array([e ? 1 : 0]);
@@ -1399,7 +1399,7 @@ class ps extends fe {
1399
1399
  return "bool";
1400
1400
  }
1401
1401
  }
1402
- class Ct extends fe {
1402
+ class Ct extends ue {
1403
1403
  get typeName() {
1404
1404
  return E.NullClass;
1405
1405
  }
@@ -1412,7 +1412,7 @@ class Ct extends fe {
1412
1412
  covariant(e) {
1413
1413
  if (e === null)
1414
1414
  return !0;
1415
- throw new Error(`Invalid ${this.display()} argument: ${q(e)}`);
1415
+ throw new Error(`Invalid ${this.display()} argument: ${L(e)}`);
1416
1416
  }
1417
1417
  encodeValue() {
1418
1418
  return new Uint8Array(0);
@@ -1427,7 +1427,7 @@ class Ct extends fe {
1427
1427
  return "null";
1428
1428
  }
1429
1429
  }
1430
- class De extends fe {
1430
+ class De extends ue {
1431
1431
  get typeName() {
1432
1432
  return E.ReservedClass;
1433
1433
  }
@@ -1453,7 +1453,7 @@ class De extends fe {
1453
1453
  return "reserved";
1454
1454
  }
1455
1455
  }
1456
- class ms extends fe {
1456
+ class ws extends ue {
1457
1457
  get typeName() {
1458
1458
  return E.TextClass;
1459
1459
  }
@@ -1466,7 +1466,7 @@ class ms extends fe {
1466
1466
  covariant(e) {
1467
1467
  if (typeof e == "string")
1468
1468
  return !0;
1469
- throw new Error(`Invalid ${this.display()} argument: ${q(e)}`);
1469
+ throw new Error(`Invalid ${this.display()} argument: ${L(e)}`);
1470
1470
  }
1471
1471
  encodeValue(e) {
1472
1472
  const r = new TextEncoder().encode(e), n = D(r.byteLength);
@@ -1487,7 +1487,7 @@ class ms extends fe {
1487
1487
  return `"${e}"`;
1488
1488
  }
1489
1489
  }
1490
- class _n extends fe {
1490
+ class _n extends ue {
1491
1491
  get typeName() {
1492
1492
  return E.IntClass;
1493
1493
  }
@@ -1500,7 +1500,7 @@ class _n extends fe {
1500
1500
  covariant(e) {
1501
1501
  if (typeof e == "bigint" || Number.isInteger(e))
1502
1502
  return !0;
1503
- throw new Error(`Invalid ${this.display()} argument: ${q(e)}`);
1503
+ throw new Error(`Invalid ${this.display()} argument: ${L(e)}`);
1504
1504
  }
1505
1505
  encodeValue(e) {
1506
1506
  return Y(e);
@@ -1518,7 +1518,7 @@ class _n extends fe {
1518
1518
  return e.toString();
1519
1519
  }
1520
1520
  }
1521
- class Tn extends fe {
1521
+ class Tn extends ue {
1522
1522
  get typeName() {
1523
1523
  return E.NatClass;
1524
1524
  }
@@ -1531,7 +1531,7 @@ class Tn extends fe {
1531
1531
  covariant(e) {
1532
1532
  if (typeof e == "bigint" && e >= BigInt(0) || Number.isInteger(e) && e >= 0)
1533
1533
  return !0;
1534
- throw new Error(`Invalid ${this.display()} argument: ${q(e)}`);
1534
+ throw new Error(`Invalid ${this.display()} argument: ${L(e)}`);
1535
1535
  }
1536
1536
  encodeValue(e) {
1537
1537
  return D(e);
@@ -1549,7 +1549,7 @@ class Tn extends fe {
1549
1549
  return e.toString();
1550
1550
  }
1551
1551
  }
1552
- class En extends fe {
1552
+ class En extends ue {
1553
1553
  get typeName() {
1554
1554
  return E.FloatClass;
1555
1555
  }
@@ -1566,7 +1566,7 @@ class En extends fe {
1566
1566
  covariant(e) {
1567
1567
  if (typeof e == "number" || e instanceof Number)
1568
1568
  return !0;
1569
- throw new Error(`Invalid ${this.display()} argument: ${q(e)}`);
1569
+ throw new Error(`Invalid ${this.display()} argument: ${L(e)}`);
1570
1570
  }
1571
1571
  encodeValue(e) {
1572
1572
  const r = new ArrayBuffer(this._bits / 8), n = new DataView(r);
@@ -1578,7 +1578,7 @@ class En extends fe {
1578
1578
  }
1579
1579
  decodeValue(e, r) {
1580
1580
  this.checkType(r);
1581
- const n = Ze(e, this._bits / 8), s = Oi(n);
1581
+ const n = Ze(e, this._bits / 8), s = $i(n);
1582
1582
  return this._bits === 32 ? s.getFloat32(0, !0) : s.getFloat64(0, !0);
1583
1583
  }
1584
1584
  get name() {
@@ -1588,7 +1588,7 @@ class En extends fe {
1588
1588
  return e.toString();
1589
1589
  }
1590
1590
  }
1591
- class Qe extends fe {
1591
+ class Qe extends ue {
1592
1592
  get typeName() {
1593
1593
  return E.FixedIntClass;
1594
1594
  }
@@ -1611,10 +1611,10 @@ class Qe extends fe {
1611
1611
  if (s >= r && s <= n)
1612
1612
  return !0;
1613
1613
  }
1614
- throw new Error(`Invalid ${this.display()} argument: ${q(e)}`);
1614
+ throw new Error(`Invalid ${this.display()} argument: ${L(e)}`);
1615
1615
  }
1616
1616
  encodeValue(e) {
1617
- return hs(e, this._bits / 8);
1617
+ return ls(e, this._bits / 8);
1618
1618
  }
1619
1619
  encodeType() {
1620
1620
  const e = Math.log2(this._bits) - 3;
@@ -1622,7 +1622,7 @@ class Qe extends fe {
1622
1622
  }
1623
1623
  decodeValue(e, r) {
1624
1624
  this.checkType(r);
1625
- const n = Bi(e, this._bits / 8);
1625
+ const n = Ui(e, this._bits / 8);
1626
1626
  return this._bits <= 32 ? Number(n) : n;
1627
1627
  }
1628
1628
  get name() {
@@ -1632,7 +1632,7 @@ class Qe extends fe {
1632
1632
  return e.toString();
1633
1633
  }
1634
1634
  }
1635
- class je extends fe {
1635
+ class je extends ue {
1636
1636
  get typeName() {
1637
1637
  return E.FixedNatClass;
1638
1638
  }
@@ -1652,10 +1652,10 @@ class je extends fe {
1652
1652
  return !0;
1653
1653
  } else if (Number.isInteger(e) && e >= 0 && BigInt(e) < r)
1654
1654
  return !0;
1655
- throw new Error(`Invalid ${this.display()} argument: ${q(e)}`);
1655
+ throw new Error(`Invalid ${this.display()} argument: ${L(e)}`);
1656
1656
  }
1657
1657
  encodeValue(e) {
1658
- return Ri(e, this._bits / 8);
1658
+ return Bi(e, this._bits / 8);
1659
1659
  }
1660
1660
  encodeType() {
1661
1661
  const e = Math.log2(this._bits) - 3;
@@ -1663,7 +1663,7 @@ class je extends fe {
1663
1663
  }
1664
1664
  decodeValue(e, r) {
1665
1665
  this.checkType(r);
1666
- const n = ls(e, this._bits / 8);
1666
+ const n = ys(e, this._bits / 8);
1667
1667
  return this._bits <= 32 ? Number(n) : n;
1668
1668
  }
1669
1669
  get name() {
@@ -1698,7 +1698,7 @@ index ${s} -> ${i.message}`, { cause: i });
1698
1698
  }
1699
1699
  }))
1700
1700
  return !0;
1701
- throw new Error(`Invalid ${this.display()} argument: ${q(e)}`);
1701
+ throw new Error(`Invalid ${this.display()} argument: ${L(e)}`);
1702
1702
  }
1703
1703
  encodeValue(e) {
1704
1704
  const r = D(e.length);
@@ -1812,11 +1812,11 @@ class $e extends Fe {
1812
1812
  if (Array.isArray(e) && (e.length === 0 || e.length === 1 && this._type.covariant(e[0])))
1813
1813
  return !0;
1814
1814
  } catch (r) {
1815
- throw new Error(`Invalid ${this.display()} argument: ${q(e)}
1815
+ throw new Error(`Invalid ${this.display()} argument: ${L(e)}
1816
1816
 
1817
1817
  -> ${r.message}`, { cause: r });
1818
1818
  }
1819
- throw new Error(`Invalid ${this.display()} argument: ${q(e)}`);
1819
+ throw new Error(`Invalid ${this.display()} argument: ${L(e)}`);
1820
1820
  }
1821
1821
  encodeValue(e) {
1822
1822
  return e.length === 0 ? new Uint8Array([0]) : $(new Uint8Array([1]), this._type.encodeValue(e[0]));
@@ -1832,7 +1832,7 @@ class $e extends Fe {
1832
1832
  if (r instanceof De)
1833
1833
  return [];
1834
1834
  let n = r;
1835
- if (r instanceof ue) {
1835
+ if (r instanceof ce) {
1836
1836
  const s = r.getType();
1837
1837
  if (typeof s > "u")
1838
1838
  throw new J("Type mismatch: cannot decode from uninitialized recursive type");
@@ -1917,7 +1917,7 @@ field ${r} -> ${s.message}`, {
1917
1917
  }
1918
1918
  }))
1919
1919
  return !0;
1920
- throw new Error(`Invalid ${this.display()} argument: ${q(e)}`);
1920
+ throw new Error(`Invalid ${this.display()} argument: ${L(e)}`);
1921
1921
  }
1922
1922
  encodeValue(e) {
1923
1923
  const r = this._fields.map(([s]) => e[s]), n = Et(this._fields, r, ([, s], i) => s.encodeValue(i));
@@ -1940,15 +1940,15 @@ field ${r} -> ${s.message}`, {
1940
1940
  a.decodeValue(e, a), o++;
1941
1941
  continue;
1942
1942
  }
1943
- const [f, l] = this._fields[i], p = Q(this._fields[i][0]), d = Q(c);
1943
+ const [f, h] = this._fields[i], p = Q(this._fields[i][0]), d = Q(c);
1944
1944
  if (p === d)
1945
- s[f] = l.decodeValue(e, a), i++, o++;
1945
+ s[f] = h.decodeValue(e, a), i++, o++;
1946
1946
  else if (d > p)
1947
- if (l instanceof $e || l instanceof De)
1947
+ if (h instanceof $e || h instanceof De)
1948
1948
  s[f] = [], i++;
1949
1949
  else {
1950
- const y = this._fields.map(([w]) => w).join(", "), h = n._fields.map(([w]) => w).join(", ");
1951
- throw new J(`Cannot find required field '${f}' in record, expected fields: [${y}], received fields: [${h}]`);
1950
+ const y = this._fields.map(([m]) => m).join(", "), l = n._fields.map(([m]) => m).join(", ");
1951
+ throw new J(`Cannot find required field '${f}' in record, expected fields: [${y}], received fields: [${l}]`);
1952
1952
  }
1953
1953
  else
1954
1954
  a.decodeValue(e, a), o++;
@@ -1957,8 +1957,8 @@ field ${r} -> ${s.message}`, {
1957
1957
  if (a instanceof $e || a instanceof De)
1958
1958
  s[c] = [];
1959
1959
  else {
1960
- const f = this._fields.map(([p]) => p).join(", "), l = n._fields.map(([p]) => p).join(", ");
1961
- throw new J(`Cannot find required field '${c}' in record, expected fields: [${f}], received fields: [${l}]`);
1960
+ const f = this._fields.map(([p]) => p).join(", "), h = n._fields.map(([p]) => p).join(", ");
1961
+ throw new J(`Cannot find required field '${c}' in record, expected fields: [${f}], received fields: [${h}]`);
1962
1962
  }
1963
1963
  return s;
1964
1964
  }
@@ -2006,7 +2006,7 @@ index ${n} -> ${s.message}`, {
2006
2006
  }
2007
2007
  }))
2008
2008
  return !0;
2009
- throw new Error(`Invalid ${this.display()} argument: ${q(e)}`);
2009
+ throw new Error(`Invalid ${this.display()} argument: ${L(e)}`);
2010
2010
  }
2011
2011
  encodeValue(e) {
2012
2012
  const r = Et(this._components, e, (n, s) => n.encodeValue(s));
@@ -2056,7 +2056,7 @@ variant ${r} -> ${s.message}`, {
2056
2056
  }
2057
2057
  }))
2058
2058
  return !0;
2059
- throw new Error(`Invalid ${this.display()} argument: ${q(e)}`);
2059
+ throw new Error(`Invalid ${this.display()} argument: ${L(e)}`);
2060
2060
  }
2061
2061
  encodeValue(e) {
2062
2062
  for (let r = 0; r < this._fields.length; r++) {
@@ -2085,8 +2085,8 @@ variant ${r} -> ${s.message}`, {
2085
2085
  const [i, o] = n._fields[s];
2086
2086
  for (const [a, f] of this._fields)
2087
2087
  if (Q(i) === Q(a)) {
2088
- const l = f.decodeValue(e, o);
2089
- return { [a]: l };
2088
+ const h = f.decodeValue(e, o);
2089
+ return { [a]: h };
2090
2090
  }
2091
2091
  const c = this._fields.map(([a]) => a).join(", ");
2092
2092
  throw new J(`Cannot find field hash ${i} in variant, expected fields: [${c}]`);
@@ -2136,7 +2136,7 @@ const fr = class fr extends Fe {
2136
2136
  covariant(e) {
2137
2137
  if (this._type && this._type.covariant(e))
2138
2138
  return !0;
2139
- throw new Error(`Invalid ${this.display()} argument: ${q(e)}`);
2139
+ throw new Error(`Invalid ${this.display()} argument: ${L(e)}`);
2140
2140
  }
2141
2141
  encodeValue(e) {
2142
2142
  if (!this._type)
@@ -2168,14 +2168,14 @@ const fr = class fr extends Fe {
2168
2168
  }
2169
2169
  };
2170
2170
  fr._counter = 0;
2171
- let ue = fr;
2171
+ let ce = fr;
2172
2172
  function Cn(t) {
2173
2173
  if (We(t) !== 1)
2174
2174
  throw new Error("Cannot decode principal");
2175
2175
  const r = Number(X(t));
2176
2176
  return A.fromUint8Array(new Uint8Array(Ze(t, r)));
2177
2177
  }
2178
- class ws extends fe {
2178
+ class gs extends ue {
2179
2179
  get typeName() {
2180
2180
  return E.PrincipalClass;
2181
2181
  }
@@ -2188,7 +2188,7 @@ class ws extends fe {
2188
2188
  covariant(e) {
2189
2189
  if (e && e._isPrincipal)
2190
2190
  return !0;
2191
- throw new Error(`Invalid ${this.display()} argument: ${q(e)}`);
2191
+ throw new Error(`Invalid ${this.display()} argument: ${L(e)}`);
2192
2192
  }
2193
2193
  encodeValue(e) {
2194
2194
  const r = e.toUint8Array(), n = D(r.byteLength);
@@ -2228,7 +2228,7 @@ class It extends Fe {
2228
2228
  covariant(e) {
2229
2229
  if (Array.isArray(e) && e.length === 2 && e[0] && e[0]._isPrincipal && typeof e[1] == "string")
2230
2230
  return !0;
2231
- throw new Error(`Invalid ${this.display()} argument: ${q(e)}`);
2231
+ throw new Error(`Invalid ${this.display()} argument: ${L(e)}`);
2232
2232
  }
2233
2233
  encodeValue([e, r]) {
2234
2234
  const n = e.toUint8Array(), s = D(n.byteLength), i = $(new Uint8Array([1]), s, n), o = new TextEncoder().encode(r), c = D(o.byteLength);
@@ -2240,7 +2240,7 @@ class It extends Fe {
2240
2240
  e.add(this, $(r, n, s, i, o, c, a));
2241
2241
  }
2242
2242
  decodeValue(e, r) {
2243
- const n = r instanceof ue ? r.getType() ?? r : r;
2243
+ const n = r instanceof ce ? r.getType() ?? r : r;
2244
2244
  if (!In(n, this))
2245
2245
  throw new Error(`Cannot decode function reference at type ${this.display()} from wire type ${n.display()}`);
2246
2246
  if (We(e) !== 1)
@@ -2285,7 +2285,7 @@ class or extends Fe {
2285
2285
  covariant(e) {
2286
2286
  if (e && e._isPrincipal)
2287
2287
  return !0;
2288
- throw new Error(`Invalid ${this.display()} argument: ${q(e)}`);
2288
+ throw new Error(`Invalid ${this.display()} argument: ${L(e)}`);
2289
2289
  }
2290
2290
  encodeValue(e) {
2291
2291
  const r = e.toUint8Array(), n = D(r.length);
@@ -2300,7 +2300,7 @@ class or extends Fe {
2300
2300
  e.add(this, $(r, n, ...s));
2301
2301
  }
2302
2302
  decodeValue(e, r) {
2303
- const n = r instanceof ue ? r.getType() ?? r : r;
2303
+ const n = r instanceof ce ? r.getType() ?? r : r;
2304
2304
  if (!In(n, this))
2305
2305
  throw new Error(`Cannot decode service reference at type ${this.display()} from wire type ${n.display()}`);
2306
2306
  return Cn(e);
@@ -2318,14 +2318,14 @@ class or extends Fe {
2318
2318
  return e;
2319
2319
  }
2320
2320
  }
2321
- function q(t) {
2321
+ function L(t) {
2322
2322
  const e = JSON.stringify(t, (r, n) => typeof n == "bigint" ? `BigInt(${n})` : n);
2323
2323
  return e && e.length > jn ? `${e.substring(0, jn - 3)}...` : e;
2324
2324
  }
2325
2325
  function Ur(t, e) {
2326
2326
  if (e.length < t.length)
2327
2327
  throw Error("Wrong number of message arguments");
2328
- const r = new Ni();
2328
+ const r = new Pi();
2329
2329
  t.forEach((c) => c.buildTypeTable(r));
2330
2330
  const n = r.encode(), s = D(e.length), i = $(...t.map((c) => c.encodeType(r))), o = $(...Et(t, e, (c, a) => {
2331
2331
  try {
@@ -2337,9 +2337,9 @@ function Ur(t, e) {
2337
2337
  }
2338
2338
  return c.encodeValue(a);
2339
2339
  }));
2340
- return $(Ui, n, s, i, o);
2340
+ return $(Ni, n, s, i, o);
2341
2341
  }
2342
- function gs(t, e) {
2342
+ function bs(t, e) {
2343
2343
  const r = new lt(e);
2344
2344
  if (e.byteLength < Yt.length)
2345
2345
  throw new Error("Message length smaller than magic number");
@@ -2347,14 +2347,14 @@ function gs(t, e) {
2347
2347
  if (s !== Yt)
2348
2348
  throw new Error(`Wrong magic number: ${JSON.stringify(s)}`);
2349
2349
  function i(d) {
2350
- const y = [], h = Number(X(d));
2351
- for (let u = 0; u < h; u++) {
2352
- const m = Number(Pe(d));
2353
- switch (m) {
2350
+ const y = [], l = Number(X(d));
2351
+ for (let u = 0; u < l; u++) {
2352
+ const w = Number(Pe(d));
2353
+ switch (w) {
2354
2354
  case O.Opt:
2355
2355
  case O.Vector: {
2356
2356
  const g = Number(Pe(d));
2357
- y.push([m, g]);
2357
+ y.push([w, g]);
2358
2358
  break;
2359
2359
  }
2360
2360
  case O.Record:
@@ -2371,7 +2371,7 @@ function gs(t, e) {
2371
2371
  const v = Number(Pe(d));
2372
2372
  g.push([R, v]);
2373
2373
  }
2374
- y.push([m, g]);
2374
+ y.push([w, g]);
2375
2375
  break;
2376
2376
  }
2377
2377
  case O.Func: {
@@ -2402,7 +2402,7 @@ function gs(t, e) {
2402
2402
  default:
2403
2403
  throw new Error("unknown annotation");
2404
2404
  }
2405
- y.push([m, [g, I, v]]);
2405
+ y.push([w, [g, I, v]]);
2406
2406
  break;
2407
2407
  }
2408
2408
  case O.Service: {
@@ -2412,63 +2412,63 @@ function gs(t, e) {
2412
2412
  const I = Number(X(d)), R = new TextDecoder().decode(Ze(d, I)), v = Pe(d);
2413
2413
  C.push([R, v]);
2414
2414
  }
2415
- y.push([m, C]);
2415
+ y.push([w, C]);
2416
2416
  break;
2417
2417
  }
2418
2418
  default:
2419
- throw new Error(`Illegal op_code: ${m}`);
2419
+ throw new Error(`Illegal op_code: ${w}`);
2420
2420
  }
2421
2421
  }
2422
- const w = [], b = Number(X(d));
2422
+ const m = [], b = Number(X(d));
2423
2423
  for (let u = 0; u < b; u++)
2424
- w.push(Number(Pe(d)));
2425
- return [y, w];
2424
+ m.push(Number(Pe(d)));
2425
+ return [y, m];
2426
2426
  }
2427
2427
  const [o, c] = i(r);
2428
2428
  if (c.length < t.length)
2429
2429
  throw new Error("Wrong number of return values");
2430
- const a = o.map((d) => qs());
2430
+ const a = o.map((d) => Ls());
2431
2431
  function f(d) {
2432
2432
  if (d < -24)
2433
2433
  throw new Error("future value not supported");
2434
2434
  if (d < 0)
2435
2435
  switch (d) {
2436
2436
  case -1:
2437
- return Ts;
2437
+ return Es;
2438
2438
  case -2:
2439
- return _s;
2439
+ return Ts;
2440
2440
  case -3:
2441
- return Is;
2441
+ return vs;
2442
2442
  case -4:
2443
- return Cs;
2443
+ return Is;
2444
2444
  case -5:
2445
- return Bs;
2446
- case -6:
2447
2445
  return Us;
2448
- case -7:
2446
+ case -6:
2449
2447
  return Ns;
2450
- case -8:
2448
+ case -7:
2451
2449
  return Ps;
2450
+ case -8:
2451
+ return Ms;
2452
2452
  case -9:
2453
- return As;
2454
- case -10:
2455
2453
  return Os;
2456
- case -11:
2454
+ case -10:
2457
2455
  return $s;
2458
- case -12:
2456
+ case -11:
2459
2457
  return Rs;
2458
+ case -12:
2459
+ return Bs;
2460
2460
  case -13:
2461
- return vs;
2462
- case -14:
2463
2461
  return Ss;
2462
+ case -14:
2463
+ return As;
2464
2464
  case -15:
2465
- return Es;
2465
+ return Cs;
2466
2466
  case -16:
2467
- return xs;
2467
+ return _s;
2468
2468
  case -17:
2469
- return bs;
2469
+ return xs;
2470
2470
  case -24:
2471
- return Ms;
2471
+ return ks;
2472
2472
  default:
2473
2473
  throw new Error(`Illegal op_code: ${d}`);
2474
2474
  }
@@ -2476,46 +2476,46 @@ function gs(t, e) {
2476
2476
  throw new Error("type index out of range");
2477
2477
  return a[d];
2478
2478
  }
2479
- function l(d) {
2479
+ function h(d) {
2480
2480
  switch (d[0]) {
2481
2481
  case O.Vector: {
2482
2482
  const y = f(d[1]);
2483
- return Vs(y);
2483
+ return js(y);
2484
2484
  }
2485
2485
  case O.Opt: {
2486
2486
  const y = f(d[1]);
2487
- return js(y);
2487
+ return Ds(y);
2488
2488
  }
2489
2489
  case O.Record: {
2490
2490
  const y = {};
2491
2491
  for (const [b, u] of d[1]) {
2492
- const m = `_${b}_`;
2493
- y[m] = f(u);
2492
+ const w = `_${b}_`;
2493
+ y[w] = f(u);
2494
2494
  }
2495
- const h = Ds(y), w = h.tryAsTuple();
2496
- return Array.isArray(w) ? ks(...w) : h;
2495
+ const l = Fs(y), m = l.tryAsTuple();
2496
+ return Array.isArray(m) ? Vs(...m) : l;
2497
2497
  }
2498
2498
  case O.Variant: {
2499
2499
  const y = {};
2500
- for (const [h, w] of d[1]) {
2501
- const b = `_${h}_`;
2502
- y[b] = f(w);
2500
+ for (const [l, m] of d[1]) {
2501
+ const b = `_${l}_`;
2502
+ y[b] = f(m);
2503
2503
  }
2504
- return Fs(y);
2504
+ return qs(y);
2505
2505
  }
2506
2506
  case O.Func: {
2507
- const [y, h, w] = d[1];
2508
- return Ls(y.map((b) => f(b)), h.map((b) => f(b)), w);
2507
+ const [y, l, m] = d[1];
2508
+ return Ks(y.map((b) => f(b)), l.map((b) => f(b)), m);
2509
2509
  }
2510
2510
  case O.Service: {
2511
- const y = {}, h = d[1];
2512
- for (const [w, b] of h) {
2511
+ const y = {}, l = d[1];
2512
+ for (const [m, b] of l) {
2513
2513
  let u = f(b);
2514
- if (u instanceof ue && (u = u.getType()), !(u instanceof It))
2514
+ if (u instanceof ce && (u = u.getType()), !(u instanceof It))
2515
2515
  throw new Error("Illegal service definition: services can only contain functions");
2516
- y[w] = u;
2516
+ y[m] = u;
2517
2517
  }
2518
- return Ks(y);
2518
+ return zs(y);
2519
2519
  }
2520
2520
  default:
2521
2521
  throw new Error(`Illegal op_code: ${d[0]}`);
@@ -2523,18 +2523,18 @@ function gs(t, e) {
2523
2523
  }
2524
2524
  o.forEach((d, y) => {
2525
2525
  if (d[0] === O.Func) {
2526
- const h = l(d);
2527
- a[y].fill(h);
2526
+ const l = h(d);
2527
+ a[y].fill(l);
2528
2528
  }
2529
2529
  }), o.forEach((d, y) => {
2530
2530
  if (d[0] !== O.Func) {
2531
- const h = l(d);
2532
- a[y].fill(h);
2531
+ const l = h(d);
2532
+ a[y].fill(l);
2533
2533
  }
2534
2534
  }), Nr();
2535
2535
  const p = c.map((d) => f(d));
2536
2536
  try {
2537
- const d = t.map((y, h) => y.decodeValue(r, p[h]));
2537
+ const d = t.map((y, l) => y.decodeValue(r, p[l]));
2538
2538
  for (let y = t.length; y < p.length; y++)
2539
2539
  p[y].decodeValue(r, p[y]);
2540
2540
  if (r.byteLength > 0)
@@ -2544,29 +2544,29 @@ function gs(t, e) {
2544
2544
  Nr();
2545
2545
  }
2546
2546
  }
2547
- const bs = new xn(), xs = new De(), Mi = new ys(), _s = new ps(), Ts = new Ct(), Es = new ms(), Cs = new _n(), Is = new Tn(), vs = new En(32), Ss = new En(64), As = new Qe(8), Os = new Qe(16), $s = new Qe(32), Rs = new Qe(64), Bs = new je(8), Us = new je(16), Ns = new je(32), Ps = new je(64), Ms = new ws();
2548
- function ks(...t) {
2547
+ const xs = new xn(), _s = new De(), ki = new ps(), Ts = new ms(), Es = new Ct(), Cs = new ws(), Is = new _n(), vs = new Tn(), Ss = new En(32), As = new En(64), Os = new Qe(8), $s = new Qe(16), Rs = new Qe(32), Bs = new Qe(64), Us = new je(8), Ns = new je(16), Ps = new je(32), Ms = new je(64), ks = new gs();
2548
+ function Vs(...t) {
2549
2549
  return new pr(t);
2550
2550
  }
2551
- function Vs(t) {
2551
+ function js(t) {
2552
2552
  return new ft(t);
2553
2553
  }
2554
- function js(t) {
2554
+ function Ds(t) {
2555
2555
  return new $e(t);
2556
2556
  }
2557
- function Ds(t) {
2557
+ function Fs(t) {
2558
2558
  return new Je(t);
2559
2559
  }
2560
- function Fs(t) {
2560
+ function qs(t) {
2561
2561
  return new dt(t);
2562
2562
  }
2563
- function qs() {
2564
- return new ue();
2563
+ function Ls() {
2564
+ return new ce();
2565
2565
  }
2566
- function Ls(t, e, r = []) {
2566
+ function Ks(t, e, r = []) {
2567
2567
  return new It(t, e, r);
2568
2568
  }
2569
- function Ks(t) {
2569
+ function zs(t) {
2570
2570
  return new or(t);
2571
2571
  }
2572
2572
  class mr {
@@ -2613,7 +2613,7 @@ let Gt = new mr();
2613
2613
  function Nr() {
2614
2614
  Gt = new mr();
2615
2615
  }
2616
- function ki(t, e) {
2616
+ function Vi(t, e) {
2617
2617
  const r = new Set(t.annotations), n = new Set(e.annotations);
2618
2618
  if (r.size !== n.size)
2619
2619
  return !1;
@@ -2626,10 +2626,10 @@ function _r(t) {
2626
2626
  return t instanceof $e || t instanceof Ct || t instanceof De;
2627
2627
  }
2628
2628
  function In(t, e) {
2629
- const r = Gt.copy(), n = Ie(r, t, e);
2629
+ const r = Gt.copy(), n = Ce(r, t, e);
2630
2630
  return n ? Gt.add(t, e) : Gt.addNegative(t, e), n;
2631
2631
  }
2632
- function Ie(t, e, r) {
2632
+ function Ce(t, e, r) {
2633
2633
  if (e.name === r.name)
2634
2634
  return !0;
2635
2635
  const n = t.known(e, r);
@@ -2638,7 +2638,7 @@ function Ie(t, e, r) {
2638
2638
  if (t.add(e, r), r instanceof De || e instanceof xn || e instanceof Tn && r instanceof _n)
2639
2639
  return !0;
2640
2640
  if (e instanceof ft && r instanceof ft)
2641
- return Ie(t, e._type, r._type);
2641
+ return Ce(t, e._type, r._type);
2642
2642
  if (r instanceof $e)
2643
2643
  return !0;
2644
2644
  if (e instanceof Je && r instanceof Je) {
@@ -2646,7 +2646,7 @@ function Ie(t, e, r) {
2646
2646
  for (const [i, o] of r._fields) {
2647
2647
  const c = s[Q(i)];
2648
2648
  if (c) {
2649
- if (!Ie(t, c, o))
2649
+ if (!Ce(t, c, o))
2650
2650
  return !1;
2651
2651
  } else if (!_r(o))
2652
2652
  return !1;
@@ -2654,12 +2654,12 @@ function Ie(t, e, r) {
2654
2654
  return !0;
2655
2655
  }
2656
2656
  if (e instanceof It && r instanceof It) {
2657
- if (!ki(e, r))
2657
+ if (!Vi(e, r))
2658
2658
  return !1;
2659
2659
  for (let s = 0; s < e.argTypes.length; s++) {
2660
2660
  const i = e.argTypes[s];
2661
2661
  if (s < r.argTypes.length) {
2662
- if (!Ie(t, r.argTypes[s], i))
2662
+ if (!Ce(t, r.argTypes[s], i))
2663
2663
  return !1;
2664
2664
  } else if (!_r(i))
2665
2665
  return !1;
@@ -2667,7 +2667,7 @@ function Ie(t, e, r) {
2667
2667
  for (let s = 0; s < r.retTypes.length; s++) {
2668
2668
  const i = r.retTypes[s];
2669
2669
  if (s < e.retTypes.length) {
2670
- if (!Ie(t, e.retTypes[s], i))
2670
+ if (!Ce(t, e.retTypes[s], i))
2671
2671
  return !1;
2672
2672
  } else if (!_r(i))
2673
2673
  return !1;
@@ -2678,7 +2678,7 @@ function Ie(t, e, r) {
2678
2678
  const s = r.alternativesAsObject;
2679
2679
  for (const [i, o] of e._fields) {
2680
2680
  const c = s[Q(i)];
2681
- if (!c || !Ie(t, o, c))
2681
+ if (!c || !Ce(t, o, c))
2682
2682
  return !1;
2683
2683
  }
2684
2684
  return !0;
@@ -2687,68 +2687,68 @@ function Ie(t, e, r) {
2687
2687
  const s = e.fieldsAsObject();
2688
2688
  for (const [i, o] of r._fields) {
2689
2689
  const c = s[i];
2690
- if (!c || !Ie(t, c, o))
2690
+ if (!c || !Ce(t, c, o))
2691
2691
  return !1;
2692
2692
  }
2693
2693
  return !0;
2694
2694
  }
2695
- return e instanceof ue ? Ie(t, e.getType(), r) : r instanceof ue ? Ie(t, e, r.getType()) : !1;
2695
+ return e instanceof ce ? Ce(t, e.getType(), r) : r instanceof ce ? Ce(t, e, r.getType()) : !1;
2696
2696
  }
2697
- const Vi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2697
+ const ji = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2698
2698
  __proto__: null,
2699
- Bool: _s,
2700
- BoolClass: ps,
2699
+ Bool: Ts,
2700
+ BoolClass: ms,
2701
2701
  CandidDecodeError: J,
2702
2702
  ConstructType: Fe,
2703
- Empty: bs,
2703
+ Empty: xs,
2704
2704
  EmptyClass: xn,
2705
2705
  FixedIntClass: Qe,
2706
2706
  FixedNatClass: je,
2707
- Float32: vs,
2708
- Float64: Ss,
2707
+ Float32: Ss,
2708
+ Float64: As,
2709
2709
  FloatClass: En,
2710
- Func: Ls,
2710
+ Func: Ks,
2711
2711
  FuncClass: It,
2712
- Int: Cs,
2713
- Int16: Os,
2714
- Int32: $s,
2715
- Int64: Rs,
2716
- Int8: As,
2712
+ Int: Is,
2713
+ Int16: $s,
2714
+ Int32: Rs,
2715
+ Int64: Bs,
2716
+ Int8: Os,
2717
2717
  IntClass: _n,
2718
- Nat: Is,
2719
- Nat16: Us,
2720
- Nat32: Ns,
2721
- Nat64: Ps,
2722
- Nat8: Bs,
2718
+ Nat: vs,
2719
+ Nat16: Ns,
2720
+ Nat32: Ps,
2721
+ Nat64: Ms,
2722
+ Nat8: Us,
2723
2723
  NatClass: Tn,
2724
- Null: Ts,
2724
+ Null: Es,
2725
2725
  NullClass: Ct,
2726
- Opt: js,
2726
+ Opt: Ds,
2727
2727
  OptClass: $e,
2728
- PrimitiveType: fe,
2729
- Principal: Ms,
2730
- PrincipalClass: ws,
2731
- Rec: qs,
2732
- RecClass: ue,
2733
- Record: Ds,
2728
+ PrimitiveType: ue,
2729
+ Principal: ks,
2730
+ PrincipalClass: gs,
2731
+ Rec: Ls,
2732
+ RecClass: ce,
2733
+ Record: Fs,
2734
2734
  RecordClass: Je,
2735
- Reserved: xs,
2735
+ Reserved: _s,
2736
2736
  ReservedClass: De,
2737
- Service: Ks,
2737
+ Service: zs,
2738
2738
  ServiceClass: or,
2739
- Text: Es,
2740
- TextClass: ms,
2741
- Tuple: ks,
2739
+ Text: Cs,
2740
+ TextClass: ws,
2741
+ Tuple: Vs,
2742
2742
  TupleClass: pr,
2743
2743
  Type: yr,
2744
- Unknown: Mi,
2745
- UnknownClass: ys,
2746
- Variant: Fs,
2744
+ Unknown: ki,
2745
+ UnknownClass: ps,
2746
+ Variant: qs,
2747
2747
  VariantClass: dt,
2748
- Vec: Vs,
2748
+ Vec: js,
2749
2749
  VecClass: ft,
2750
- Visitor: Pi,
2751
- decode: gs,
2750
+ Visitor: Mi,
2751
+ decode: bs,
2752
2752
  encode: Ur,
2753
2753
  resetSubtypeCache: Nr,
2754
2754
  subtype: In
@@ -2768,43 +2768,43 @@ function wr(t, e) {
2768
2768
  }
2769
2769
  function Pr(t) {
2770
2770
  if (typeof t == "string")
2771
- return zs(t);
2771
+ return Hs(t);
2772
2772
  if (typeof t == "number")
2773
- return pe(D(t));
2773
+ return le(D(t));
2774
2774
  if (t instanceof Uint8Array || ArrayBuffer.isView(t))
2775
- return pe(ar(t));
2775
+ return le(ar(t));
2776
2776
  if (Array.isArray(t)) {
2777
2777
  const e = t.map(Pr);
2778
- return pe(ge(...e));
2778
+ return le(me(...e));
2779
2779
  }
2780
2780
  if (t && typeof t == "object" && t._isPrincipal)
2781
- return pe(t.toUint8Array());
2781
+ return le(t.toUint8Array());
2782
2782
  if (typeof t == "object" && t !== null && typeof t.toHash == "function")
2783
2783
  return Pr(t.toHash());
2784
2784
  if (typeof t == "object")
2785
2785
  return cr(t);
2786
2786
  if (typeof t == "bigint")
2787
- return pe(D(t));
2787
+ return le(D(t));
2788
2788
  throw N.fromCode(new fn(t));
2789
2789
  }
2790
- const zs = (t) => {
2790
+ const Hs = (t) => {
2791
2791
  const e = new TextEncoder().encode(t);
2792
- return pe(e);
2792
+ return le(e);
2793
2793
  };
2794
2794
  function Tr(t) {
2795
2795
  return cr(t);
2796
2796
  }
2797
2797
  function cr(t) {
2798
2798
  const n = Object.entries(t).filter(([, o]) => o !== void 0).map(([o, c]) => {
2799
- const a = zs(o), f = Pr(c);
2799
+ const a = Hs(o), f = Pr(c);
2800
2800
  return [a, f];
2801
- }).sort(([o], [c]) => bn(o, c)), s = ge(...n.map((o) => ge(...o)));
2802
- return pe(s);
2801
+ }).sort(([o], [c]) => bn(o, c)), s = me(...n.map((o) => me(...o)));
2802
+ return le(s);
2803
2803
  }
2804
- const ji = new TextEncoder().encode("\ric-state-root");
2804
+ const Di = new TextEncoder().encode("\ric-state-root");
2805
2805
  new TextEncoder().encode(`
2806
2806
  ic-request`);
2807
- const Di = new TextEncoder().encode("\vic-response");
2807
+ const Fi = new TextEncoder().encode("\vic-response");
2808
2808
  new TextEncoder().encode("ic-request-auth-delegation");
2809
2809
  class Er {
2810
2810
  getPrincipal() {
@@ -2822,28 +2822,28 @@ class tt extends Error {
2822
2822
  super(e), this.name = "DecodingError";
2823
2823
  }
2824
2824
  }
2825
- const Hs = 55799, Ys = /* @__PURE__ */ Symbol("CBOR_STOP_CODE");
2826
- var me = /* @__PURE__ */ ((t) => (t[t.False = 20] = "False", t[t.True = 21] = "True", t[t.Null = 22] = "Null", t[t.Undefined = 23] = "Undefined", t[t.Break = 31] = "Break", t))(me || {}), H = /* @__PURE__ */ ((t) => (t[t.UnsignedInteger = 0] = "UnsignedInteger", t[t.NegativeInteger = 1] = "NegativeInteger", t[t.ByteString = 2] = "ByteString", t[t.TextString = 3] = "TextString", t[t.Array = 4] = "Array", t[t.Map = 5] = "Map", t[t.Tag = 6] = "Tag", t[t.Simple = 7] = "Simple", t))(H || {});
2827
- const Fi = 23, qi = 255, Li = 65535, Ki = 4294967295, zi = BigInt("0xffffffffffffffff");
2828
- var ye = /* @__PURE__ */ ((t) => (t[t.Value = 23] = "Value", t[t.OneByte = 24] = "OneByte", t[t.TwoBytes = 25] = "TwoBytes", t[t.FourBytes = 26] = "FourBytes", t[t.EightBytes = 27] = "EightBytes", t[t.Indefinite = 31] = "Indefinite", t))(ye || {});
2825
+ const Ys = 55799, Gs = /* @__PURE__ */ Symbol("CBOR_STOP_CODE");
2826
+ var ye = /* @__PURE__ */ ((t) => (t[t.False = 20] = "False", t[t.True = 21] = "True", t[t.Null = 22] = "Null", t[t.Undefined = 23] = "Undefined", t[t.Break = 31] = "Break", t))(ye || {}), H = /* @__PURE__ */ ((t) => (t[t.UnsignedInteger = 0] = "UnsignedInteger", t[t.NegativeInteger = 1] = "NegativeInteger", t[t.ByteString = 2] = "ByteString", t[t.TextString = 3] = "TextString", t[t.Array = 4] = "Array", t[t.Map = 5] = "Map", t[t.Tag = 6] = "Tag", t[t.Simple = 7] = "Simple", t))(H || {});
2827
+ const qi = 23, Li = 255, Ki = 65535, zi = 4294967295, Hi = BigInt("0xffffffffffffffff");
2828
+ var he = /* @__PURE__ */ ((t) => (t[t.Value = 23] = "Value", t[t.OneByte = 24] = "OneByte", t[t.TwoBytes = 25] = "TwoBytes", t[t.FourBytes = 26] = "FourBytes", t[t.EightBytes = 27] = "EightBytes", t[t.Indefinite = 31] = "Indefinite", t))(he || {});
2829
2829
  const st = !1;
2830
- function Hi(t) {
2830
+ function Yi(t) {
2831
2831
  return t == null;
2832
2832
  }
2833
- function Gs(t, e) {
2833
+ function Gi(t, e) {
2834
2834
  const r = new Uint8Array(e);
2835
2835
  return r.set(t), r;
2836
2836
  }
2837
- const Yi = new TextDecoder();
2838
- function Gi(t) {
2837
+ const Xi = new TextDecoder();
2838
+ function Zi(t) {
2839
2839
  return (t & 224) >> 5;
2840
2840
  }
2841
- function Xi(t) {
2841
+ function Wi(t) {
2842
2842
  return t & 31;
2843
2843
  }
2844
- let vt = new Uint8Array(), gt, we = 0;
2845
- function Zi(t, e) {
2846
- vt = t, we = 0;
2844
+ let vt = new Uint8Array(), gt, pe = 0;
2845
+ function Qi(t, e) {
2846
+ vt = t, pe = 0;
2847
2847
  const r = He();
2848
2848
  return e?.(r) ?? r;
2849
2849
  }
@@ -2853,35 +2853,35 @@ function He(t) {
2853
2853
  case H.UnsignedInteger:
2854
2854
  return yt(r);
2855
2855
  case H.NegativeInteger:
2856
- return eo(r);
2856
+ return ro(r);
2857
2857
  case H.ByteString:
2858
2858
  return Xs(r);
2859
2859
  case H.TextString:
2860
2860
  return Mr(r);
2861
2861
  case H.Array:
2862
- return Wi(r);
2863
- case H.Map:
2864
2862
  return Ji(r);
2865
- case H.Tag:
2863
+ case H.Map:
2866
2864
  return to(r);
2865
+ case H.Tag:
2866
+ return no(r);
2867
2867
  case H.Simple:
2868
- return Qi(r);
2868
+ return eo(r);
2869
2869
  }
2870
2870
  throw new tt(`Unsupported major type: ${e}`);
2871
2871
  }
2872
2872
  function Xt() {
2873
- const t = vt.at(we);
2874
- if (Hi(t))
2873
+ const t = vt.at(pe);
2874
+ if (Yi(t))
2875
2875
  throw new tt("Provided CBOR data is empty");
2876
- const e = Gi(t), r = Xi(t);
2877
- return we++, [e, r];
2876
+ const e = Zi(t), r = Wi(t);
2877
+ return pe++, [e, r];
2878
2878
  }
2879
- function Wi(t, e) {
2879
+ function Ji(t, e) {
2880
2880
  const r = yt(t);
2881
2881
  if (r === 1 / 0) {
2882
2882
  const s = [];
2883
2883
  let i = He();
2884
- for (; i !== Ys; )
2884
+ for (; i !== Gs; )
2885
2885
  s.push(i), i = He();
2886
2886
  return s;
2887
2887
  }
@@ -2892,26 +2892,26 @@ function Wi(t, e) {
2892
2892
  }
2893
2893
  return n;
2894
2894
  }
2895
- function Qi(t) {
2895
+ function eo(t) {
2896
2896
  switch (t) {
2897
- case me.False:
2897
+ case ye.False:
2898
2898
  return !1;
2899
- case me.True:
2899
+ case ye.True:
2900
2900
  return !0;
2901
- case me.Null:
2901
+ case ye.Null:
2902
2902
  return null;
2903
- case me.Undefined:
2903
+ case ye.Undefined:
2904
2904
  return;
2905
- case me.Break:
2906
- return Ys;
2905
+ case ye.Break:
2906
+ return Gs;
2907
2907
  }
2908
2908
  throw new tt(`Unrecognized simple type: ${t.toString(2)}`);
2909
2909
  }
2910
- function Ji(t, e) {
2910
+ function to(t, e) {
2911
2911
  const r = yt(t), n = {};
2912
2912
  if (r === 1 / 0) {
2913
2913
  let [s, i] = Xt();
2914
- for (; s !== H.Simple && i !== me.Break; ) {
2914
+ for (; s !== H.Simple && i !== ye.Break; ) {
2915
2915
  const o = Mr(i), c = He();
2916
2916
  n[o] = c, [s, i] = Xt();
2917
2917
  }
@@ -2927,24 +2927,24 @@ function Ji(t, e) {
2927
2927
  return n;
2928
2928
  }
2929
2929
  function yt(t) {
2930
- if (t <= ye.Value)
2930
+ if (t <= he.Value)
2931
2931
  return t;
2932
- switch (gt = new DataView(vt.buffer, vt.byteOffset + we), t) {
2933
- case ye.OneByte:
2934
- return we++, gt.getUint8(0);
2935
- case ye.TwoBytes:
2936
- return we += 2, gt.getUint16(0, st);
2937
- case ye.FourBytes:
2938
- return we += 4, gt.getUint32(0, st);
2939
- case ye.EightBytes:
2940
- return we += 8, gt.getBigUint64(0, st);
2941
- case ye.Indefinite:
2932
+ switch (gt = new DataView(vt.buffer, vt.byteOffset + pe), t) {
2933
+ case he.OneByte:
2934
+ return pe++, gt.getUint8(0);
2935
+ case he.TwoBytes:
2936
+ return pe += 2, gt.getUint16(0, st);
2937
+ case he.FourBytes:
2938
+ return pe += 4, gt.getUint32(0, st);
2939
+ case he.EightBytes:
2940
+ return pe += 8, gt.getBigUint64(0, st);
2941
+ case he.Indefinite:
2942
2942
  return 1 / 0;
2943
2943
  default:
2944
2944
  throw new tt(`Unsupported integer info: ${t.toString(2)}`);
2945
2945
  }
2946
2946
  }
2947
- function eo(t) {
2947
+ function ro(t) {
2948
2948
  const e = yt(t);
2949
2949
  return typeof e == "number" ? -1 - e : -1n - e;
2950
2950
  }
@@ -2953,15 +2953,15 @@ function Xs(t) {
2953
2953
  if (e > Number.MAX_SAFE_INTEGER)
2954
2954
  throw new tt("Byte length is too large");
2955
2955
  const r = Number(e);
2956
- return we += r, vt.slice(we - r, we);
2956
+ return pe += r, vt.slice(pe - r, pe);
2957
2957
  }
2958
2958
  function Mr(t) {
2959
2959
  const e = Xs(t);
2960
- return Yi.decode(e);
2960
+ return Xi.decode(e);
2961
2961
  }
2962
- function to(t, e) {
2962
+ function no(t, e) {
2963
2963
  const r = yt(t);
2964
- if (r === Hs)
2964
+ if (r === Ys)
2965
2965
  return He();
2966
2966
  throw new tt(`Unsupported tag: ${r}.`);
2967
2967
  }
@@ -2970,141 +2970,147 @@ class vn extends Error {
2970
2970
  super(e), this.name = "SerializationError";
2971
2971
  }
2972
2972
  }
2973
- const ro = 2 * 1024, no = 100, so = new TextEncoder();
2973
+ const so = 2 * 1024, Dn = 100, io = new TextEncoder();
2974
2974
  function bt(t) {
2975
2975
  return t << 5;
2976
2976
  }
2977
- let se = new Uint8Array(ro), de = new DataView(se.buffer), z = 0, Cr = [];
2978
- function io(t, e) {
2979
- z = 0;
2977
+ let ve = new Uint8Array(so), be = new DataView(ve.buffer), q = 0, Cr = [];
2978
+ function oo(t, e) {
2979
+ q = 0;
2980
2980
  const r = e?.(t) ?? t;
2981
- return yo(Hs, r, e), se.slice(0, z);
2981
+ return po(Ys, r, e), ve.slice(0, q);
2982
+ }
2983
+ function Zs(t) {
2984
+ let e = ve.length * 2;
2985
+ for (; e < t; )
2986
+ e *= 2;
2987
+ ve = Gi(ve, e), be = new DataView(ve.buffer);
2982
2988
  }
2983
2989
  function Sn(t, e) {
2984
- if (z > se.length - no && (se = Gs(se, se.length * 2), de = new DataView(se.buffer)), t === !1 || t === !0 || t === null || t === void 0) {
2985
- co(t);
2990
+ if (t === !1 || t === !0 || t === null || t === void 0) {
2991
+ uo(t);
2986
2992
  return;
2987
2993
  }
2988
2994
  if (typeof t == "number" || typeof t == "bigint") {
2989
- lo(t);
2995
+ yo(t);
2990
2996
  return;
2991
2997
  }
2992
2998
  if (typeof t == "string") {
2993
- Qs(t);
2999
+ Js(t);
2994
3000
  return;
2995
3001
  }
2996
3002
  if (t instanceof Uint8Array) {
2997
- Dn(t);
3003
+ Fn(t);
2998
3004
  return;
2999
3005
  }
3000
3006
  if (t instanceof ArrayBuffer) {
3001
- Dn(new Uint8Array(t));
3007
+ Fn(new Uint8Array(t));
3002
3008
  return;
3003
3009
  }
3004
3010
  if (Array.isArray(t)) {
3005
- oo(t, e);
3011
+ ao(t, e);
3006
3012
  return;
3007
3013
  }
3008
3014
  if (typeof t == "object") {
3009
- ao(t, e);
3015
+ co(t, e);
3010
3016
  return;
3011
3017
  }
3012
3018
  throw new vn(`Unsupported type: ${typeof t}`);
3013
3019
  }
3014
- function oo(t, e) {
3020
+ function ao(t, e) {
3015
3021
  pt(H.Array, t.length), t.forEach((r, n) => {
3016
3022
  Sn(e?.(r, n.toString()) ?? r, e);
3017
3023
  });
3018
3024
  }
3019
- function ao(t, e) {
3025
+ function co(t, e) {
3020
3026
  Cr = Object.entries(t), pt(H.Map, Cr.length), Cr.forEach(([r, n]) => {
3021
- Qs(r), Sn(e?.(n, r) ?? n, e);
3027
+ Js(r), Sn(e?.(n, r) ?? n, e);
3022
3028
  });
3023
3029
  }
3024
3030
  function pt(t, e) {
3025
- if (e <= Fi) {
3026
- de.setUint8(
3027
- z++,
3031
+ if (q > ve.length - Dn && Zs(q + Dn), e <= qi) {
3032
+ be.setUint8(
3033
+ q++,
3028
3034
  bt(t) | Number(e)
3029
3035
  );
3030
3036
  return;
3031
3037
  }
3032
- if (e <= qi) {
3033
- de.setUint8(
3034
- z++,
3035
- bt(t) | ye.OneByte
3036
- ), de.setUint8(z, Number(e)), z += 1;
3037
- return;
3038
- }
3039
3038
  if (e <= Li) {
3040
- de.setUint8(
3041
- z++,
3042
- bt(t) | ye.TwoBytes
3043
- ), de.setUint16(z, Number(e), st), z += 2;
3039
+ be.setUint8(
3040
+ q++,
3041
+ bt(t) | he.OneByte
3042
+ ), be.setUint8(q, Number(e)), q += 1;
3044
3043
  return;
3045
3044
  }
3046
3045
  if (e <= Ki) {
3047
- de.setUint8(
3048
- z++,
3049
- bt(t) | ye.FourBytes
3050
- ), de.setUint32(z, Number(e), st), z += 4;
3046
+ be.setUint8(
3047
+ q++,
3048
+ bt(t) | he.TwoBytes
3049
+ ), be.setUint16(q, Number(e), st), q += 2;
3051
3050
  return;
3052
3051
  }
3053
3052
  if (e <= zi) {
3054
- de.setUint8(
3055
- z++,
3056
- bt(t) | ye.EightBytes
3057
- ), de.setBigUint64(z, BigInt(e), st), z += 8;
3053
+ be.setUint8(
3054
+ q++,
3055
+ bt(t) | he.FourBytes
3056
+ ), be.setUint32(q, Number(e), st), q += 4;
3057
+ return;
3058
+ }
3059
+ if (e <= Hi) {
3060
+ be.setUint8(
3061
+ q++,
3062
+ bt(t) | he.EightBytes
3063
+ ), be.setBigUint64(q, BigInt(e), st), q += 8;
3058
3064
  return;
3059
3065
  }
3060
3066
  throw new vn(`Value too large to encode: ${e}`);
3061
3067
  }
3062
- function co(t) {
3063
- pt(H.Simple, uo(t));
3064
- }
3065
3068
  function uo(t) {
3069
+ pt(H.Simple, fo(t));
3070
+ }
3071
+ function fo(t) {
3066
3072
  if (t === !1)
3067
- return me.False;
3073
+ return ye.False;
3068
3074
  if (t === !0)
3069
- return me.True;
3075
+ return ye.True;
3070
3076
  if (t === null)
3071
- return me.Null;
3077
+ return ye.Null;
3072
3078
  if (t === void 0)
3073
- return me.Undefined;
3079
+ return ye.Undefined;
3074
3080
  throw new vn(`Unrecognized simple value: ${t.toString()}`);
3075
3081
  }
3076
- function Zs(t, e) {
3077
- pt(t, e.length), z > se.length - e.length && (se = Gs(se, se.length + e.length), de = new DataView(se.buffer)), se.set(e, z), z += e.length;
3078
- }
3079
3082
  function Ws(t, e) {
3080
- pt(t, e);
3083
+ pt(t, e.length), q > ve.length - e.length && Zs(q + e.length), ve.set(e, q), q += e.length;
3081
3084
  }
3082
- function fo(t) {
3083
- Ws(H.UnsignedInteger, t);
3085
+ function Qs(t, e) {
3086
+ pt(t, e);
3084
3087
  }
3085
3088
  function ho(t) {
3086
- Ws(
3089
+ Qs(H.UnsignedInteger, t);
3090
+ }
3091
+ function lo(t) {
3092
+ Qs(
3087
3093
  H.NegativeInteger,
3088
3094
  typeof t == "bigint" ? -1n - t : -1 - t
3089
3095
  );
3090
3096
  }
3091
- function lo(t) {
3092
- t >= 0 ? fo(t) : ho(t);
3097
+ function yo(t) {
3098
+ t >= 0 ? ho(t) : lo(t);
3093
3099
  }
3094
- function Qs(t) {
3095
- Zs(H.TextString, so.encode(t));
3100
+ function Js(t) {
3101
+ Ws(H.TextString, io.encode(t));
3096
3102
  }
3097
- function Dn(t) {
3098
- Zs(H.ByteString, t);
3103
+ function Fn(t) {
3104
+ Ws(H.ByteString, t);
3099
3105
  }
3100
- function yo(t, e, r) {
3106
+ function po(t, e, r) {
3101
3107
  pt(H.Tag, t), Sn(e, r);
3102
3108
  }
3103
- const Lt = "__expiry__", kr = BigInt(1e3), po = BigInt(1e6), mo = BigInt(60), Vr = mo * kr, wo = BigInt(1) * Vr;
3104
- function go(t) {
3109
+ const Lt = "__expiry__", kr = BigInt(1e3), mo = BigInt(1e6), wo = BigInt(60), Vr = wo * kr, go = BigInt(1) * Vr;
3110
+ function bo(t) {
3105
3111
  return t / kr * kr;
3106
3112
  }
3107
- function bo(t) {
3113
+ function xo(t) {
3108
3114
  return t / Vr * Vr;
3109
3115
  }
3110
3116
  class it {
@@ -3122,9 +3128,9 @@ class it {
3122
3128
  * @returns {Expiry} The constructed Expiry object.
3123
3129
  */
3124
3130
  static fromDeltaInMilliseconds(e, r = 0) {
3125
- const n = BigInt(Date.now()) + BigInt(r), s = n + BigInt(e), i = bo(s);
3131
+ const n = BigInt(Date.now()) + BigInt(r), s = n + BigInt(e), i = xo(s);
3126
3132
  let o;
3127
- return i >= n + wo ? o = i : o = go(s), new it(o * po);
3133
+ return i >= n + go ? o = i : o = bo(s), new it(o * mo);
3128
3134
  }
3129
3135
  toBigInt() {
3130
3136
  return this.__expiry__;
@@ -3162,19 +3168,19 @@ class it {
3162
3168
  return e instanceof it || typeof e == "object" && e !== null && "_isExpiry" in e && e._isExpiry === !0 && "__expiry__" in e && typeof e.__expiry__ == "bigint";
3163
3169
  }
3164
3170
  }
3165
- function xo(t) {
3171
+ function _o(t) {
3166
3172
  return typeof t == "object" && t !== null && "toCborValue" in t;
3167
3173
  }
3168
3174
  function Ir(t) {
3169
3175
  try {
3170
- return io(t, (e) => A.isPrincipal(e) ? e.toUint8Array() : it.isExpiry(e) ? e.toBigInt() : xo(e) ? e.toCborValue() : e);
3176
+ return oo(t, (e) => A.isPrincipal(e) ? e.toUint8Array() : it.isExpiry(e) ? e.toBigInt() : _o(e) ? e.toCborValue() : e);
3171
3177
  } catch (e) {
3172
3178
  throw N.fromCode(new nn(e, t));
3173
3179
  }
3174
3180
  }
3175
- function Te(t) {
3181
+ function _e(t) {
3176
3182
  try {
3177
- return Zi(t);
3183
+ return Qi(t);
3178
3184
  } catch (e) {
3179
3185
  throw N.fromCode(new rn(e, t));
3180
3186
  }
@@ -3202,45 +3208,45 @@ var St;
3202
3208
  (function(t) {
3203
3209
  t.Query = "query", t.ReadState = "read_state";
3204
3210
  })(St || (St = {}));
3205
- var le;
3211
+ var de;
3206
3212
  (function(t) {
3207
3213
  t.Received = "received", t.Processing = "processing", t.Replied = "replied", t.Rejected = "rejected", t.Unknown = "unknown", t.Done = "done";
3208
- })(le || (le = {}));
3214
+ })(de || (de = {}));
3209
3215
  function Dr() {
3210
3216
  const t = new ArrayBuffer(16), e = new DataView(t), r = Kt(), n = Kt(), s = Kt(), i = Kt();
3211
3217
  return e.setUint32(0, r), e.setUint32(4, n), e.setUint32(8, s), e.setUint32(12, i), Object.assign(new Uint8Array(t), { __nonce__: void 0 });
3212
3218
  }
3213
- function Fn(t = Dr) {
3219
+ function qn(t = Dr) {
3214
3220
  return async (e) => {
3215
3221
  const r = e.request.headers;
3216
3222
  e.request.headers = r, e.endpoint === ze.Call && (e.body.nonce = t());
3217
3223
  };
3218
3224
  }
3219
- function qn(t) {
3225
+ function Ln(t) {
3220
3226
  const e = [];
3221
3227
  return t.forEach((r, n) => {
3222
3228
  e.push([n, r]);
3223
3229
  }), e;
3224
3230
  }
3225
- function _o(t, e, r) {
3231
+ function To(t, e, r) {
3226
3232
  const n = typeof t == "string" ? t : V(t), s = typeof e == "string" ? e : V(e), i = typeof r == "string" ? r : V(r);
3227
- return hi.verifyShortSignature(s, i, n);
3233
+ return li.verifyShortSignature(s, i, n);
3228
3234
  }
3229
- const To = BigInt(1e6), Js = (t) => X(new lt(t)), gr = (t) => {
3230
- const r = Js(t) / To;
3235
+ const Eo = BigInt(1e6), ei = (t) => X(new lt(t)), gr = (t) => {
3236
+ const r = ei(t) / Eo;
3231
3237
  return new Date(Number(r));
3232
- }, Ln = 60 * 1e3, Eo = 60, Co = 24, Io = Co * Eo, vo = 5, So = 5, Ao = 30 * Io;
3238
+ }, Kn = 60 * 1e3, Co = 60, Io = 24, vo = Io * Co, So = 5, Ao = 5, Oo = 30 * vo;
3233
3239
  var F;
3234
3240
  (function(t) {
3235
3241
  t[t.Empty = 0] = "Empty", t[t.Fork = 1] = "Fork", t[t.Labeled = 2] = "Labeled", t[t.Leaf = 3] = "Leaf", t[t.Pruned = 4] = "Pruned";
3236
3242
  })(F || (F = {}));
3237
- function Oo(t, e) {
3243
+ function $o(t, e) {
3238
3244
  for (let r = 0; r < t.length; r++)
3239
3245
  if (t[r] > e[r])
3240
3246
  return !0;
3241
3247
  return !1;
3242
3248
  }
3243
- class Ee {
3249
+ class Te {
3244
3250
  #t = !1;
3245
3251
  #e = void 0;
3246
3252
  /**
@@ -3249,14 +3255,14 @@ class Ee {
3249
3255
  * @throws {Error} if the verification of the certificate fails
3250
3256
  */
3251
3257
  static async create(e) {
3252
- const r = Ee.createUnverified(e);
3258
+ const r = Te.createUnverified(e);
3253
3259
  return await r.verify(), r;
3254
3260
  }
3255
3261
  static createUnverified(e) {
3256
- return new Ee(e.certificate, e.rootKey, e.principal, e.blsVerify ?? _o, e.maxAgeInMinutes, e.disableTimeVerification, e.agent);
3262
+ return new Te(e.certificate, e.rootKey, e.principal, e.blsVerify ?? To, e.maxAgeInMinutes, e.disableTimeVerification, e.agent);
3257
3263
  }
3258
- constructor(e, r, n, s, i = vo, o = !1, c) {
3259
- this._rootKey = r, this._principal = n, this._blsVerify = s, this._maxAgeInMinutes = i, this.#t = o, this.cert = Te(e), c && "getTimeDiffMsecs" in c && "hasSyncedTime" in c && "syncTime" in c && "syncTimeWithSubnet" in c && (this.#e = c);
3264
+ constructor(e, r, n, s, i = So, o = !1, c) {
3265
+ this._rootKey = r, this._principal = n, this._blsVerify = s, this._maxAgeInMinutes = i, this.#t = o, this.cert = _e(e), c && "getTimeDiffMsecs" in c && "hasSyncedTime" in c && "syncTime" in c && "syncTimeWithSubnet" in c && (this.#e = c);
3260
3266
  }
3261
3267
  /**
3262
3268
  * Lookup a path in the certificate tree, using {@link lookup_path}.
@@ -3275,71 +3281,71 @@ class Ee {
3275
3281
  return br(e, this.cert.tree);
3276
3282
  }
3277
3283
  async verify() {
3278
- const e = await Zt(this.cert.tree), r = await this._checkDelegationAndGetKey(this.cert.delegation), n = this.cert.signature, s = Ro(r), i = ge(ji, e), o = be(this.lookup_path(["time"]));
3284
+ const e = await Zt(this.cert.tree), r = await this._checkDelegationAndGetKey(this.cert.delegation), n = this.cert.signature, s = Bo(r), i = me(Di, e), o = we(this.lookup_path(["time"]));
3279
3285
  if (!o)
3280
3286
  throw M.fromCode(new Ve("Certificate does not contain a time"));
3281
3287
  if (!this.#t) {
3282
- const c = this.#e?.getTimeDiffMsecs() ?? 0, a = this._maxAgeInMinutes * Ln, f = /* @__PURE__ */ new Date(), l = f.getTime() + c, p = l - a, d = l + So * Ln, y = gr(o), h = y.getTime() < p, w = y.getTime() > d;
3283
- if ((h || w) && this.#e && !this.#e.hasSyncedTime())
3288
+ const c = this.#e?.getTimeDiffMsecs() ?? 0, a = this._maxAgeInMinutes * Kn, f = /* @__PURE__ */ new Date(), h = f.getTime() + c, p = h - a, d = h + Ao * Kn, y = gr(o), l = y.getTime() < p, m = y.getTime() > d;
3289
+ if ((l || m) && this.#e && !this.#e.hasSyncedTime())
3284
3290
  return await this._syncTime(), await this.verify();
3285
- if (h)
3286
- throw ae.fromCode(new ut(this._maxAgeInMinutes, y, f, c, "past"));
3287
- if (w)
3288
- throw this.#e?.hasSyncedTime() ? Z.fromCode(new ne("System time has been synced with the IC network, but certificate is still too far in the future.")) : ae.fromCode(new ut(5, y, f, c, "future"));
3291
+ if (l)
3292
+ throw oe.fromCode(new ut(this._maxAgeInMinutes, y, f, c, "past"));
3293
+ if (m)
3294
+ throw this.#e?.hasSyncedTime() ? Z.fromCode(new ne("System time has been synced with the IC network, but certificate is still too far in the future.")) : oe.fromCode(new ut(5, y, f, c, "future"));
3289
3295
  }
3290
3296
  try {
3291
3297
  if (!await this._blsVerify(s, n, i))
3292
- throw ae.fromCode(new Ve("Invalid signature"));
3298
+ throw oe.fromCode(new Ve("Invalid signature"));
3293
3299
  } catch (c) {
3294
- throw ae.fromCode(new Ve("Signature verification failed", c));
3300
+ throw oe.fromCode(new Ve("Signature verification failed", c));
3295
3301
  }
3296
3302
  }
3297
3303
  async _checkDelegationAndGetKey(e) {
3298
3304
  if (!e)
3299
3305
  return this._rootKey;
3300
- const r = Ee.createUnverified({
3306
+ const r = Te.createUnverified({
3301
3307
  certificate: e.certificate,
3302
3308
  rootKey: this._rootKey,
3303
3309
  principal: this._principal,
3304
3310
  blsVerify: this._blsVerify,
3305
3311
  disableTimeVerification: this.#t,
3306
- maxAgeInMinutes: Ao,
3312
+ maxAgeInMinutes: Oo,
3307
3313
  agent: this.#e
3308
3314
  });
3309
3315
  if (r.cert.delegation)
3310
3316
  throw M.fromCode(new Zr());
3311
3317
  await r.verify();
3312
3318
  let n;
3313
- if (zn(this._principal)) {
3319
+ if (Hn(this._principal)) {
3314
3320
  const i = this._principal.canisterId;
3315
- if (n = A.fromUint8Array(e.subnet_id), !ti({
3321
+ if (n = A.fromUint8Array(e.subnet_id), !ri({
3316
3322
  canisterId: i,
3317
3323
  subnetId: n,
3318
3324
  tree: r.cert.tree
3319
3325
  }))
3320
- throw ae.fromCode(new kt(i, n));
3321
- } else if (Kn(this._principal))
3326
+ throw oe.fromCode(new kt(i, n));
3327
+ } else if (zn(this._principal))
3322
3328
  n = this._principal.subnetId;
3323
3329
  else
3324
3330
  throw Se;
3325
- const s = be(r.lookup_path(["subnet", n.toUint8Array(), "public_key"]));
3331
+ const s = we(r.lookup_path(["subnet", n.toUint8Array(), "public_key"]));
3326
3332
  if (!s)
3327
- throw Kn(this._principal) ? ae.fromCode(new Wr(n)) : ae.fromCode(new Jr(`Could not find subnet key for subnet ID ${n.toText()}`));
3333
+ throw zn(this._principal) ? oe.fromCode(new Wr(n)) : oe.fromCode(new Jr(`Could not find subnet key for subnet ID ${n.toText()}`));
3328
3334
  return s;
3329
3335
  }
3330
3336
  async _syncTime() {
3331
- this.#e && (zn(this._principal) ? await this.#e.syncTime(this._principal.canisterId) : await this.#e.syncTimeWithSubnet(this._principal.subnetId));
3337
+ this.#e && (Hn(this._principal) ? await this.#e.syncTime(this._principal.canisterId) : await this.#e.syncTimeWithSubnet(this._principal.subnetId));
3332
3338
  }
3333
3339
  }
3334
- function Kn(t) {
3340
+ function zn(t) {
3335
3341
  return "subnetId" in t;
3336
3342
  }
3337
- function zn(t) {
3343
+ function Hn(t) {
3338
3344
  return "canisterId" in t;
3339
3345
  }
3340
- const xt = Gr("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"), $o = 96;
3341
- function Ro(t) {
3342
- const e = xt.byteLength + $o;
3346
+ const xt = Gr("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"), Ro = 96;
3347
+ function Bo(t) {
3348
+ const e = xt.byteLength + Ro;
3343
3349
  if (t.byteLength !== e)
3344
3350
  throw M.fromCode(new hr(e, t.byteLength));
3345
3351
  const r = t.slice(0, xt.byteLength);
@@ -3347,37 +3353,37 @@ function Ro(t) {
3347
3353
  throw M.fromCode(new en(xt, r));
3348
3354
  return t.slice(xt.byteLength);
3349
3355
  }
3350
- function be(t) {
3351
- if (t.status === ie.Found && t.value instanceof Uint8Array)
3356
+ function we(t) {
3357
+ if (t.status === se.Found && t.value instanceof Uint8Array)
3352
3358
  return t.value;
3353
3359
  }
3354
3360
  async function Zt(t) {
3355
3361
  switch (t[0]) {
3356
3362
  case F.Empty:
3357
- return pe(zt("ic-hashtree-empty"));
3363
+ return le(zt("ic-hashtree-empty"));
3358
3364
  case F.Pruned:
3359
3365
  return t[1];
3360
3366
  case F.Leaf:
3361
- return pe(ge(zt("ic-hashtree-leaf"), t[1]));
3367
+ return le(me(zt("ic-hashtree-leaf"), t[1]));
3362
3368
  case F.Labeled:
3363
- return pe(ge(zt("ic-hashtree-labeled"), t[1], await Zt(t[2])));
3369
+ return le(me(zt("ic-hashtree-labeled"), t[1], await Zt(t[2])));
3364
3370
  case F.Fork:
3365
- return pe(ge(zt("ic-hashtree-fork"), await Zt(t[1]), await Zt(t[2])));
3371
+ return le(me(zt("ic-hashtree-fork"), await Zt(t[1]), await Zt(t[2])));
3366
3372
  default:
3367
3373
  throw Se;
3368
3374
  }
3369
3375
  }
3370
3376
  function zt(t) {
3371
3377
  const e = new Uint8Array([t.length]), r = new TextEncoder().encode(t);
3372
- return ge(e, r);
3378
+ return me(e, r);
3373
3379
  }
3374
- function ei(t) {
3380
+ function ti(t) {
3375
3381
  return typeof t[0] == "string" ? U(t[0]) : t[0];
3376
3382
  }
3377
- var ie;
3383
+ var se;
3378
3384
  (function(t) {
3379
3385
  t.Unknown = "Unknown", t.Absent = "Absent", t.Found = "Found", t.Error = "Error";
3380
- })(ie || (ie = {}));
3386
+ })(se || (se = {}));
3381
3387
  var Ye;
3382
3388
  (function(t) {
3383
3389
  t.Absent = "Absent", t.Unknown = "Unknown", t.Found = "Found";
@@ -3391,31 +3397,31 @@ function mt(t, e) {
3391
3397
  switch (e[0]) {
3392
3398
  case F.Empty:
3393
3399
  return {
3394
- status: ie.Absent
3400
+ status: se.Absent
3395
3401
  };
3396
3402
  case F.Leaf: {
3397
3403
  if (!e[1])
3398
3404
  throw Z.fromCode(new Vt("Invalid tree structure for leaf"));
3399
3405
  if (e[1] instanceof Uint8Array)
3400
3406
  return {
3401
- status: ie.Found,
3407
+ status: se.Found,
3402
3408
  value: e[1].slice(e[1].byteOffset, e[1].byteLength + e[1].byteOffset)
3403
3409
  };
3404
3410
  throw Se;
3405
3411
  }
3406
3412
  case F.Pruned:
3407
3413
  return {
3408
- status: ie.Unknown
3414
+ status: se.Unknown
3409
3415
  };
3410
3416
  case F.Labeled:
3411
3417
  case F.Fork:
3412
3418
  return {
3413
- status: ie.Error
3419
+ status: se.Error
3414
3420
  };
3415
3421
  default:
3416
3422
  throw Se;
3417
3423
  }
3418
- const r = ei(t), n = _t(r, e);
3424
+ const r = ti(t), n = _t(r, e);
3419
3425
  switch (n.status) {
3420
3426
  case k.Found:
3421
3427
  return mt(t.slice(1), n.value);
@@ -3423,11 +3429,11 @@ function mt(t, e) {
3423
3429
  case k.Greater:
3424
3430
  case k.Less:
3425
3431
  return {
3426
- status: ie.Absent
3432
+ status: se.Absent
3427
3433
  };
3428
3434
  case k.Unknown:
3429
3435
  return {
3430
- status: ie.Unknown
3436
+ status: se.Unknown
3431
3437
  };
3432
3438
  default:
3433
3439
  throw Se;
@@ -3439,7 +3445,7 @@ function br(t, e) {
3439
3445
  status: Ye.Found,
3440
3446
  value: e
3441
3447
  };
3442
- const r = ei(t), n = _t(r, e);
3448
+ const r = ti(t), n = _t(r, e);
3443
3449
  switch (n.status) {
3444
3450
  case k.Found:
3445
3451
  return br(t.slice(1), n.value);
@@ -3472,7 +3478,7 @@ function _t(t, e) {
3472
3478
  // if we have a labelled node, compare the node's label to the one we are
3473
3479
  // looking for
3474
3480
  case F.Labeled:
3475
- return Oo(t, e[1]) ? {
3481
+ return $o(t, e[1]) ? {
3476
3482
  status: k.Greater
3477
3483
  } : wr(t, e[1]) ? {
3478
3484
  status: k.Found,
@@ -3538,34 +3544,34 @@ function Wt(t, e) {
3538
3544
  throw Se;
3539
3545
  }
3540
3546
  }
3541
- function ti(t) {
3542
- const e = Bo(t), r = ri(e), { canisterId: n } = t;
3547
+ function ri(t) {
3548
+ const e = Uo(t), r = ni(e), { canisterId: n } = t;
3543
3549
  return r.some((i) => i[0].ltEq(n) && i[1].gtEq(n));
3544
3550
  }
3545
- function Bo(t) {
3551
+ function Uo(t) {
3546
3552
  const { subnetId: e, tree: r, canisterId: n } = t, s = br(["canister_ranges", e.toUint8Array()], r);
3547
3553
  if (s.status !== Ye.Found)
3548
- return Uo(e, r);
3549
- const i = s.value, o = No(i);
3554
+ return No(e, r);
3555
+ const i = s.value, o = Po(i);
3550
3556
  if (o.length === 0)
3551
3557
  throw M.fromCode(new kt(n, e));
3552
3558
  o.sort(bn);
3553
- const c = Po(o, n), a = o[c];
3554
- return Mo(a, i);
3559
+ const c = Mo(o, n), a = o[c];
3560
+ return ko(a, i);
3555
3561
  }
3556
- function Uo(t, e) {
3562
+ function No(t, e) {
3557
3563
  const r = mt(["subnet", t.toUint8Array(), "canister_ranges"], e);
3558
- if (r.status !== ie.Found)
3564
+ if (r.status !== se.Found)
3559
3565
  throw M.fromCode(new Ge(`Could not find canister ranges for subnet ${t.toText()}`, r.status));
3560
3566
  return r.value;
3561
3567
  }
3562
- function ri(t) {
3563
- return Te(t).map((n) => [
3568
+ function ni(t) {
3569
+ return _e(t).map((n) => [
3564
3570
  A.fromUint8Array(n[0]),
3565
3571
  A.fromUint8Array(n[1])
3566
3572
  ]);
3567
3573
  }
3568
- function No(t) {
3574
+ function Po(t) {
3569
3575
  const e = [];
3570
3576
  for (const r of Wt([], t)) {
3571
3577
  const n = r[0];
@@ -3575,7 +3581,7 @@ function No(t) {
3575
3581
  }
3576
3582
  return e;
3577
3583
  }
3578
- function Po(t, e) {
3584
+ function Mo(t, e) {
3579
3585
  const r = e.toUint8Array();
3580
3586
  let n = 0, s = t.length - 1;
3581
3587
  for (; n < s; ) {
@@ -3584,34 +3590,34 @@ function Po(t, e) {
3584
3590
  }
3585
3591
  return n;
3586
3592
  }
3587
- function Mo(t, e) {
3593
+ function ko(t, e) {
3588
3594
  const r = mt([t], e);
3589
- if (r.status !== ie.Found)
3595
+ if (r.status !== se.Found)
3590
3596
  throw M.fromCode(new Ge(`Could not find canister range for shard ${t.toString()}`, r.status));
3591
3597
  return r.value;
3592
3598
  }
3593
- function Hn(t, e) {
3599
+ function Yn(t, e) {
3594
3600
  return t.delegation ? A.fromUint8Array(t.delegation.subnet_id) : A.selfAuthenticating(e);
3595
3601
  }
3596
- const ko = A.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe");
3597
- function ni(t, e) {
3602
+ const Vo = A.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe");
3603
+ function si(t, e) {
3598
3604
  switch (e) {
3599
3605
  case "raw":
3600
3606
  return t;
3601
3607
  case "leb128":
3602
- return Js(t);
3608
+ return ei(t);
3603
3609
  case "cbor":
3604
- return Te(t);
3610
+ return _e(t);
3605
3611
  case "hex":
3606
3612
  return V(t);
3607
3613
  case "utf-8":
3608
3614
  return new TextDecoder().decode(t);
3609
3615
  }
3610
3616
  }
3611
- function Vo(t) {
3612
- return Te(t).map((r) => A.fromUint8Array(r));
3617
+ function jo(t) {
3618
+ return _e(t).map((r) => A.fromUint8Array(r));
3613
3619
  }
3614
- function jo(t, e) {
3620
+ function Do(t, e) {
3615
3621
  const r = typeof t == "string" ? U(t) : t;
3616
3622
  return [U("canister"), e, U("metadata"), r];
3617
3623
  }
@@ -3627,7 +3633,7 @@ function An(t, e) {
3627
3633
  const n = Fr(r.value), s = /* @__PURE__ */ new Map();
3628
3634
  return n.forEach((i) => {
3629
3635
  const o = A.from(i[1]).toText(), c = mt(["public_key"], i[2]);
3630
- if (c.status !== ie.Found)
3636
+ if (c.status !== se.Found)
3631
3637
  throw M.fromCode(new Ge("Public key not found", c.status));
3632
3638
  const a = c.value;
3633
3639
  if (a.byteLength !== 44)
@@ -3635,81 +3641,81 @@ function An(t, e) {
3635
3641
  s.set(o, a);
3636
3642
  }), s;
3637
3643
  }
3638
- const Do = async (t) => {
3644
+ const Fo = async (t) => {
3639
3645
  const { agent: e, paths: r, disableCertificateTimeVerification: n = !1 } = t, s = A.from(t.canisterId), i = [...new Set(r)], o = /* @__PURE__ */ new Map(), c = i.map((a, f) => {
3640
- const l = qo(a, s);
3646
+ const h = Lo(a, s);
3641
3647
  return (async () => {
3642
3648
  try {
3643
3649
  if (e.rootKey === null)
3644
- throw ce.fromCode(new Xe());
3650
+ throw ae.fromCode(new Xe());
3645
3651
  const p = e.rootKey, d = await e.readState(s, {
3646
- paths: [l]
3647
- }), y = await Ee.create({
3652
+ paths: [h]
3653
+ }), y = await Te.create({
3648
3654
  certificate: d.certificate,
3649
3655
  rootKey: p,
3650
3656
  principal: { canisterId: s },
3651
3657
  disableTimeVerification: n,
3652
3658
  agent: e
3653
- }), h = (u, m) => {
3654
- if (m === "subnet") {
3655
- const g = Fo(d.certificate, s, p);
3659
+ }), l = (u, w) => {
3660
+ if (w === "subnet") {
3661
+ const g = qo(d.certificate, s, p);
3656
3662
  return {
3657
- path: m,
3663
+ path: w,
3658
3664
  data: g
3659
3665
  };
3660
3666
  }
3661
3667
  return {
3662
- path: m,
3663
- data: be(u.lookup_path(l))
3668
+ path: w,
3669
+ data: we(u.lookup_path(h))
3664
3670
  };
3665
- }, { path: w, data: b } = h(y, i[f]);
3671
+ }, { path: m, data: b } = l(y, i[f]);
3666
3672
  if (!b)
3667
- typeof w == "string" ? o.set(w, null) : o.set(w.key, null);
3673
+ typeof m == "string" ? o.set(m, null) : o.set(m.key, null);
3668
3674
  else
3669
- switch (w) {
3675
+ switch (m) {
3670
3676
  case "time": {
3671
- o.set(w, gr(b));
3677
+ o.set(m, gr(b));
3672
3678
  break;
3673
3679
  }
3674
3680
  case "controllers": {
3675
- o.set(w, Vo(b));
3681
+ o.set(m, jo(b));
3676
3682
  break;
3677
3683
  }
3678
3684
  case "module_hash": {
3679
- o.set(w, V(b));
3685
+ o.set(m, V(b));
3680
3686
  break;
3681
3687
  }
3682
3688
  case "subnet": {
3683
- o.set(w, b);
3689
+ o.set(m, b);
3684
3690
  break;
3685
3691
  }
3686
3692
  case "candid": {
3687
- o.set(w, new TextDecoder().decode(b));
3693
+ o.set(m, new TextDecoder().decode(b));
3688
3694
  break;
3689
3695
  }
3690
3696
  default:
3691
- ht(w) && o.set(w.key, ni(b, w.decodeStrategy));
3697
+ ht(m) && o.set(m.key, si(b, m.decodeStrategy));
3692
3698
  }
3693
3699
  } catch (p) {
3694
- if (p instanceof _e && (p.hasCode(Ve) || p.hasCode(ut)))
3700
+ if (p instanceof xe && (p.hasCode(Ve) || p.hasCode(ut)))
3695
3701
  throw p;
3696
3702
  ht(a) ? o.set(a.key, null) : o.set(a, null);
3697
3703
  }
3698
3704
  })();
3699
3705
  });
3700
3706
  return await Promise.all(c), o;
3701
- }, Fo = (t, e, r) => {
3707
+ }, qo = (t, e, r) => {
3702
3708
  if (!e._isPrincipal)
3703
3709
  throw N.fromCode(new ne("Invalid canisterId"));
3704
- const n = Te(t), { delegation: s } = n;
3710
+ const n = _e(t), { delegation: s } = n;
3705
3711
  let i;
3706
- s && s.subnet_id ? i = A.fromUint8Array(new Uint8Array(s.subnet_id)) : !s && typeof r < "u" ? i = A.selfAuthenticating(new Uint8Array(r)) : i = ko;
3712
+ s && s.subnet_id ? i = A.fromUint8Array(new Uint8Array(s.subnet_id)) : !s && typeof r < "u" ? i = A.selfAuthenticating(new Uint8Array(r)) : i = Vo;
3707
3713
  const o = An(n, i);
3708
3714
  return {
3709
3715
  subnetId: i.toText(),
3710
3716
  nodeKeys: o
3711
3717
  };
3712
- }, qo = (t, e) => {
3718
+ }, Lo = (t, e) => {
3713
3719
  const r = e.toUint8Array();
3714
3720
  switch (t) {
3715
3721
  case "time":
@@ -3729,63 +3735,63 @@ const Do = async (t) => {
3729
3735
  ];
3730
3736
  default:
3731
3737
  if (ht(t))
3732
- return typeof t.path == "string" || t.path instanceof Uint8Array ? jo(t.path, r) : t.path;
3738
+ return typeof t.path == "string" || t.path instanceof Uint8Array ? Do(t.path, r) : t.path;
3733
3739
  }
3734
3740
  throw Z.fromCode(new ne(`Error while encoding your path for canister status. Please ensure that your path ${t} was formatted correctly.`));
3735
3741
  };
3736
- async function Lo(t) {
3742
+ async function Ko(t) {
3737
3743
  const { agent: e, paths: r, disableCertificateTimeVerification: n = !1 } = t, s = A.from(t.subnetId), i = [...new Set(r)], o = /* @__PURE__ */ new Map(), c = i.map((a, f) => {
3738
- const l = Ko(a, s);
3744
+ const h = zo(a, s);
3739
3745
  return (async () => {
3740
3746
  try {
3741
3747
  if (e.rootKey === null)
3742
- throw ce.fromCode(new Xe());
3748
+ throw ae.fromCode(new Xe());
3743
3749
  const p = e.rootKey, d = await e.readSubnetState(s, {
3744
- paths: [l]
3745
- }), y = await Ee.create({
3750
+ paths: [h]
3751
+ }), y = await Te.create({
3746
3752
  certificate: d.certificate,
3747
3753
  rootKey: p,
3748
3754
  principal: { subnetId: s },
3749
3755
  disableTimeVerification: n,
3750
3756
  agent: e
3751
- }), h = (u, m) => {
3752
- if (m === "nodeKeys") {
3757
+ }), l = (u, w) => {
3758
+ if (w === "nodeKeys") {
3753
3759
  const g = An(u.cert, s);
3754
3760
  return {
3755
- path: m,
3761
+ path: w,
3756
3762
  data: g
3757
3763
  };
3758
3764
  }
3759
3765
  return {
3760
- path: m,
3761
- data: be(u.lookup_path(l))
3766
+ path: w,
3767
+ data: we(u.lookup_path(h))
3762
3768
  };
3763
- }, { path: w, data: b } = h(y, i[f]);
3769
+ }, { path: m, data: b } = l(y, i[f]);
3764
3770
  if (!b)
3765
- typeof w == "string" ? o.set(w, null) : o.set(w.key, null);
3771
+ typeof m == "string" ? o.set(m, null) : o.set(m.key, null);
3766
3772
  else
3767
- switch (w) {
3773
+ switch (m) {
3768
3774
  case "time": {
3769
- o.set(w, gr(b));
3775
+ o.set(m, gr(b));
3770
3776
  break;
3771
3777
  }
3772
3778
  case "canisterRanges": {
3773
- o.set(w, ri(b));
3779
+ o.set(m, ni(b));
3774
3780
  break;
3775
3781
  }
3776
3782
  case "publicKey": {
3777
- o.set(w, b);
3783
+ o.set(m, b);
3778
3784
  break;
3779
3785
  }
3780
3786
  case "nodeKeys": {
3781
- o.set(w, b);
3787
+ o.set(m, b);
3782
3788
  break;
3783
3789
  }
3784
3790
  default:
3785
- ht(w) && o.set(w.key, ni(b, w.decodeStrategy));
3791
+ ht(m) && o.set(m.key, si(b, m.decodeStrategy));
3786
3792
  }
3787
3793
  } catch (p) {
3788
- if (p instanceof _e && (p.hasCode(Ve) || p.hasCode(ut)))
3794
+ if (p instanceof xe && (p.hasCode(Ve) || p.hasCode(ut)))
3789
3795
  throw p;
3790
3796
  ht(a) ? o.set(a.key, null) : o.set(a, null);
3791
3797
  }
@@ -3793,7 +3799,7 @@ async function Lo(t) {
3793
3799
  });
3794
3800
  return await Promise.all(c), o;
3795
3801
  }
3796
- function Ko(t, e) {
3802
+ function zo(t, e) {
3797
3803
  const r = e.toUint8Array();
3798
3804
  switch (t) {
3799
3805
  case "time":
@@ -3815,20 +3821,20 @@ function Ko(t, e) {
3815
3821
  }
3816
3822
  throw Z.fromCode(new ne(`Error while encoding your path for subnet status. Please ensure that your path ${t} was formatted correctly.`));
3817
3823
  }
3818
- function si(t, e, r) {
3819
- const n = new Uint8Array(be(t.lookup_path([...e, "reject_code"])))[0], s = new TextDecoder().decode(be(t.lookup_path([...e, "reject_message"]))), i = be(t.lookup_path([...e, "error_code"])), o = i ? new TextDecoder().decode(i) : void 0;
3824
+ function ii(t, e, r) {
3825
+ const n = new Uint8Array(we(t.lookup_path([...e, "reject_code"])))[0], s = new TextDecoder().decode(we(t.lookup_path([...e, "reject_message"]))), i = we(t.lookup_path([...e, "error_code"])), o = i ? new TextDecoder().decode(i) : void 0;
3820
3826
  return new on(r, n, s, o);
3821
3827
  }
3822
- const Ue = BigInt(0), G = BigInt(1), vr = BigInt(2), zo = BigInt(8);
3823
- function Ho(t, e, r, n) {
3828
+ const Ue = BigInt(0), G = BigInt(1), vr = BigInt(2), Ho = BigInt(8);
3829
+ function Yo(t, e, r, n) {
3824
3830
  const s = t.sqr(r), i = t.sqr(n), o = t.add(t.mul(e.a, s), i), c = t.add(t.ONE, t.mul(e.d, t.mul(s, i)));
3825
3831
  return t.eql(o, c);
3826
3832
  }
3827
- function Yo(t, e = {}) {
3828
- const r = li("edwards", t, e, e.FpFnLE), { Fp: n, Fn: s } = r;
3833
+ function Go(t, e = {}) {
3834
+ const r = yi("edwards", t, e, e.FpFnLE), { Fp: n, Fn: s } = r;
3829
3835
  let i = r.CURVE;
3830
3836
  const { h: o } = i;
3831
- cs(e, {}, { uvRatio: "function" });
3837
+ us(e, {}, { uvRatio: "function" });
3832
3838
  const c = vr << BigInt(s.BYTES * 8) - G, a = (b) => n.create(b), f = e.uvRatio || ((b, u) => {
3833
3839
  try {
3834
3840
  return { isValid: !0, value: n.sqrt(n.div(b, u)) };
@@ -3836,69 +3842,69 @@ function Yo(t, e = {}) {
3836
3842
  return { isValid: !1, value: Ue };
3837
3843
  }
3838
3844
  });
3839
- if (!Ho(n, i, i.Gx, i.Gy))
3845
+ if (!Yo(n, i, i.Gx, i.Gy))
3840
3846
  throw new Error("bad curve params: generator point");
3841
- function l(b, u, m = !1) {
3842
- const g = m ? G : Ue;
3847
+ function h(b, u, w = !1) {
3848
+ const g = w ? G : Ue;
3843
3849
  return Pn("coordinate " + b, u, g, c), u;
3844
3850
  }
3845
3851
  function p(b) {
3846
- if (!(b instanceof h))
3852
+ if (!(b instanceof l))
3847
3853
  throw new Error("ExtendedPoint expected");
3848
3854
  }
3849
3855
  const d = Mn((b, u) => {
3850
- const { X: m, Y: g, Z: C } = b, I = b.is0();
3851
- u == null && (u = I ? zo : n.inv(C));
3852
- const R = a(m * u), v = a(g * u), B = n.mul(C, u);
3856
+ const { X: w, Y: g, Z: C } = b, I = b.is0();
3857
+ u == null && (u = I ? Ho : n.inv(C));
3858
+ const R = a(w * u), v = a(g * u), B = n.mul(C, u);
3853
3859
  if (I)
3854
3860
  return { x: Ue, y: G };
3855
3861
  if (B !== G)
3856
3862
  throw new Error("invZ was invalid");
3857
3863
  return { x: R, y: v };
3858
3864
  }), y = Mn((b) => {
3859
- const { a: u, d: m } = i;
3865
+ const { a: u, d: w } = i;
3860
3866
  if (b.is0())
3861
3867
  throw new Error("bad point: ZERO");
3862
- const { X: g, Y: C, Z: I, T: R } = b, v = a(g * g), B = a(C * C), x = a(I * I), _ = a(x * x), S = a(v * u), j = a(x * a(S + B)), L = a(_ + a(m * a(v * B)));
3863
- if (j !== L)
3868
+ const { X: g, Y: C, Z: I, T: R } = b, v = a(g * g), B = a(C * C), x = a(I * I), _ = a(x * x), S = a(v * u), j = a(x * a(S + B)), K = a(_ + a(w * a(v * B)));
3869
+ if (j !== K)
3864
3870
  throw new Error("bad point: equation left != right (1)");
3865
3871
  const P = a(g * C), W = a(I * R);
3866
3872
  if (P !== W)
3867
3873
  throw new Error("bad point: equation left != right (2)");
3868
3874
  return !0;
3869
3875
  });
3870
- class h {
3871
- constructor(u, m, g, C) {
3872
- this.X = l("x", u), this.Y = l("y", m), this.Z = l("z", g, !0), this.T = l("t", C), Object.freeze(this);
3876
+ class l {
3877
+ constructor(u, w, g, C) {
3878
+ this.X = h("x", u), this.Y = h("y", w), this.Z = h("z", g, !0), this.T = h("t", C), Object.freeze(this);
3873
3879
  }
3874
3880
  static CURVE() {
3875
3881
  return i;
3876
3882
  }
3877
3883
  static fromAffine(u) {
3878
- if (u instanceof h)
3884
+ if (u instanceof l)
3879
3885
  throw new Error("extended point not allowed");
3880
- const { x: m, y: g } = u || {};
3881
- return l("x", m), l("y", g), new h(m, g, G, a(m * g));
3886
+ const { x: w, y: g } = u || {};
3887
+ return h("x", w), h("y", g), new l(w, g, G, a(w * g));
3882
3888
  }
3883
3889
  // Uses algo from RFC8032 5.1.3.
3884
- static fromBytes(u, m = !1) {
3890
+ static fromBytes(u, w = !1) {
3885
3891
  const g = n.BYTES, { a: C, d: I } = i;
3886
- u = Nn(Ht(u, g, "point")), $r(m, "zip215");
3892
+ u = Nn(Ht(u, g, "point")), $r(w, "zip215");
3887
3893
  const R = Nn(u), v = u[g - 1];
3888
3894
  R[g - 1] = v & -129;
3889
- const B = Rr(R), x = m ? c : n.ORDER;
3895
+ const B = Rr(R), x = w ? c : n.ORDER;
3890
3896
  Pn("point.y", B, Ue, x);
3891
3897
  const _ = a(B * B), S = a(_ - G), j = a(I * _ - C);
3892
- let { isValid: L, value: P } = f(S, j);
3893
- if (!L)
3898
+ let { isValid: K, value: P } = f(S, j);
3899
+ if (!K)
3894
3900
  throw new Error("bad point: invalid y coordinate");
3895
3901
  const W = (P & G) === G, ee = (v & 128) !== 0;
3896
- if (!m && P === Ue && ee)
3902
+ if (!w && P === Ue && ee)
3897
3903
  throw new Error("bad point: x=0 and x_0=1");
3898
- return ee !== W && (P = a(-P)), h.fromAffine({ x: P, y: B });
3904
+ return ee !== W && (P = a(-P)), l.fromAffine({ x: P, y: B });
3899
3905
  }
3900
- static fromHex(u, m = !1) {
3901
- return h.fromBytes(Ne("point", u), m);
3906
+ static fromHex(u, w = !1) {
3907
+ return l.fromBytes(Ne("point", u), w);
3902
3908
  }
3903
3909
  get x() {
3904
3910
  return this.toAffine().x;
@@ -3906,8 +3912,8 @@ function Yo(t, e = {}) {
3906
3912
  get y() {
3907
3913
  return this.toAffine().y;
3908
3914
  }
3909
- precompute(u = 8, m = !0) {
3910
- return w.createCache(this, u), m || this.multiply(vr), this;
3915
+ precompute(u = 8, w = !0) {
3916
+ return m.createCache(this, u), w || this.multiply(vr), this;
3911
3917
  }
3912
3918
  // Useful in fromAffine() - not for fromBytes(), which always created valid points.
3913
3919
  assertValidity() {
@@ -3916,29 +3922,29 @@ function Yo(t, e = {}) {
3916
3922
  // Compare one point to another.
3917
3923
  equals(u) {
3918
3924
  p(u);
3919
- const { X: m, Y: g, Z: C } = this, { X: I, Y: R, Z: v } = u, B = a(m * v), x = a(I * C), _ = a(g * v), S = a(R * C);
3925
+ const { X: w, Y: g, Z: C } = this, { X: I, Y: R, Z: v } = u, B = a(w * v), x = a(I * C), _ = a(g * v), S = a(R * C);
3920
3926
  return B === x && _ === S;
3921
3927
  }
3922
3928
  is0() {
3923
- return this.equals(h.ZERO);
3929
+ return this.equals(l.ZERO);
3924
3930
  }
3925
3931
  negate() {
3926
- return new h(a(-this.X), this.Y, this.Z, a(-this.T));
3932
+ return new l(a(-this.X), this.Y, this.Z, a(-this.T));
3927
3933
  }
3928
3934
  // Fast algo for doubling Extended Point.
3929
3935
  // https://hyperelliptic.org/EFD/g1p/auto-twisted-extended.html#doubling-dbl-2008-hwcd
3930
3936
  // Cost: 4M + 4S + 1*a + 6add + 1*2.
3931
3937
  double() {
3932
- const { a: u } = i, { X: m, Y: g, Z: C } = this, I = a(m * m), R = a(g * g), v = a(vr * a(C * C)), B = a(u * I), x = m + g, _ = a(a(x * x) - I - R), S = B + R, j = S - v, L = B - R, P = a(_ * j), W = a(S * L), ee = a(_ * L), Re = a(j * S);
3933
- return new h(P, W, Re, ee);
3938
+ const { a: u } = i, { X: w, Y: g, Z: C } = this, I = a(w * w), R = a(g * g), v = a(vr * a(C * C)), B = a(u * I), x = w + g, _ = a(a(x * x) - I - R), S = B + R, j = S - v, K = B - R, P = a(_ * j), W = a(S * K), ee = a(_ * K), Re = a(j * S);
3939
+ return new l(P, W, Re, ee);
3934
3940
  }
3935
3941
  // Fast algo for adding 2 Extended Points.
3936
3942
  // https://hyperelliptic.org/EFD/g1p/auto-twisted-extended.html#addition-add-2008-hwcd
3937
3943
  // Cost: 9M + 1*a + 1*d + 7add.
3938
3944
  add(u) {
3939
3945
  p(u);
3940
- const { a: m, d: g } = i, { X: C, Y: I, Z: R, T: v } = this, { X: B, Y: x, Z: _, T: S } = u, j = a(C * B), L = a(I * x), P = a(v * g * S), W = a(R * _), ee = a((C + I) * (B + x) - j - L), Re = W - P, qe = W + P, Ce = a(L - m * j), wt = a(ee * Re), Dt = a(qe * Ce), xr = a(ee * Ce), $n = a(Re * qe);
3941
- return new h(wt, Dt, $n, xr);
3946
+ const { a: w, d: g } = i, { X: C, Y: I, Z: R, T: v } = this, { X: B, Y: x, Z: _, T: S } = u, j = a(C * B), K = a(I * x), P = a(v * g * S), W = a(R * _), ee = a((C + I) * (B + x) - j - K), Re = W - P, qe = W + P, Ee = a(K - w * j), wt = a(ee * Re), Dt = a(qe * Ee), xr = a(ee * Ee), $n = a(Re * qe);
3947
+ return new l(wt, Dt, $n, xr);
3942
3948
  }
3943
3949
  subtract(u) {
3944
3950
  return this.add(u.negate());
@@ -3947,18 +3953,18 @@ function Yo(t, e = {}) {
3947
3953
  multiply(u) {
3948
3954
  if (!s.isValidNot0(u))
3949
3955
  throw new Error("invalid scalar: expected 1 <= sc < curve.n");
3950
- const { p: m, f: g } = w.cached(this, u, (C) => Ft(h, C));
3951
- return Ft(h, [m, g])[0];
3956
+ const { p: w, f: g } = m.cached(this, u, (C) => Ft(l, C));
3957
+ return Ft(l, [w, g])[0];
3952
3958
  }
3953
3959
  // Non-constant-time multiplication. Uses double-and-add algorithm.
3954
3960
  // It's faster, but should only be used when you don't care about
3955
3961
  // an exposed private key e.g. sig verification.
3956
3962
  // Does NOT allow scalars higher than CURVE.n.
3957
3963
  // Accepts optional accumulator to merge with multiply (important for sparse scalars)
3958
- multiplyUnsafe(u, m = h.ZERO) {
3964
+ multiplyUnsafe(u, w = l.ZERO) {
3959
3965
  if (!s.isValid(u))
3960
3966
  throw new Error("invalid scalar: expected 0 <= sc < curve.n");
3961
- return u === Ue ? h.ZERO : this.is0() || u === G ? this : w.unsafe(this, u, (g) => Ft(h, g), m);
3967
+ return u === Ue ? l.ZERO : this.is0() || u === G ? this : m.unsafe(this, u, (g) => Ft(l, g), w);
3962
3968
  }
3963
3969
  // Checks if point is of small order.
3964
3970
  // If you add something to small order point, you will have "dirty"
@@ -3970,7 +3976,7 @@ function Yo(t, e = {}) {
3970
3976
  // Multiplies point by curve order and checks if the result is 0.
3971
3977
  // Returns `false` is the point is dirty.
3972
3978
  isTorsionFree() {
3973
- return w.unsafe(this, i.n).is0();
3979
+ return m.unsafe(this, i.n).is0();
3974
3980
  }
3975
3981
  // Converts Extended point to default (x, y) coordinates.
3976
3982
  // Can accept precomputed Z^-1 - for example, from invertBatch.
@@ -3981,7 +3987,7 @@ function Yo(t, e = {}) {
3981
3987
  return o === G ? this : this.multiplyUnsafe(o);
3982
3988
  }
3983
3989
  toBytes() {
3984
- const { x: u, y: m } = this.toAffine(), g = n.toBytes(m);
3990
+ const { x: u, y: w } = this.toAffine(), g = n.toBytes(w);
3985
3991
  return g[g.length - 1] |= u & G ? 128 : 0, g;
3986
3992
  }
3987
3993
  toHex() {
@@ -4004,10 +4010,10 @@ function Yo(t, e = {}) {
4004
4010
  return this.T;
4005
4011
  }
4006
4012
  static normalizeZ(u) {
4007
- return Ft(h, u);
4013
+ return Ft(l, u);
4008
4014
  }
4009
- static msm(u, m) {
4010
- return mi(h, s, u, m);
4015
+ static msm(u, w) {
4016
+ return wi(l, s, u, w);
4011
4017
  }
4012
4018
  _setWindowSize(u) {
4013
4019
  this.precompute(u);
@@ -4016,74 +4022,74 @@ function Yo(t, e = {}) {
4016
4022
  return this.toBytes();
4017
4023
  }
4018
4024
  }
4019
- h.BASE = new h(i.Gx, i.Gy, G, a(i.Gx * i.Gy)), h.ZERO = new h(Ue, G, G, Ue), h.Fp = n, h.Fn = s;
4020
- const w = new yi(h, s.BITS);
4021
- return h.BASE.precompute(8), h;
4025
+ l.BASE = new l(i.Gx, i.Gy, G, a(i.Gx * i.Gy)), l.ZERO = new l(Ue, G, G, Ue), l.Fp = n, l.Fn = s;
4026
+ const m = new pi(l, s.BITS);
4027
+ return l.BASE.precompute(8), l;
4022
4028
  }
4023
- function Go(t, e, r = {}) {
4029
+ function Xo(t, e, r = {}) {
4024
4030
  if (typeof e != "function")
4025
4031
  throw new Error('"hash" function param is required');
4026
- cs(r, {}, {
4032
+ us(r, {}, {
4027
4033
  adjustScalarBytes: "function",
4028
4034
  randomBytes: "function",
4029
4035
  domain: "function",
4030
4036
  prehash: "function",
4031
4037
  mapToCurve: "function"
4032
4038
  });
4033
- const { prehash: n } = r, { BASE: s, Fp: i, Fn: o } = t, c = r.randomBytes || pi, a = r.adjustScalarBytes || ((x) => x), f = r.domain || ((x, _, S) => {
4039
+ const { prehash: n } = r, { BASE: s, Fp: i, Fn: o } = t, c = r.randomBytes || mi, a = r.adjustScalarBytes || ((x) => x), f = r.domain || ((x, _, S) => {
4034
4040
  if ($r(S, "phflag"), _.length || S)
4035
4041
  throw new Error("Contexts/pre-hash are not supported");
4036
4042
  return x;
4037
4043
  });
4038
- function l(x) {
4044
+ function h(x) {
4039
4045
  return o.create(Rr(x));
4040
4046
  }
4041
4047
  function p(x) {
4042
4048
  const _ = g.secretKey;
4043
4049
  x = Ne("private key", x, _);
4044
- const S = Ne("hashed private key", e(x), 2 * _), j = a(S.slice(0, _)), L = S.slice(_, 2 * _), P = l(j);
4045
- return { head: j, prefix: L, scalar: P };
4050
+ const S = Ne("hashed private key", e(x), 2 * _), j = a(S.slice(0, _)), K = S.slice(_, 2 * _), P = h(j);
4051
+ return { head: j, prefix: K, scalar: P };
4046
4052
  }
4047
4053
  function d(x) {
4048
- const { head: _, prefix: S, scalar: j } = p(x), L = s.multiply(j), P = L.toBytes();
4049
- return { head: _, prefix: S, scalar: j, point: L, pointBytes: P };
4054
+ const { head: _, prefix: S, scalar: j } = p(x), K = s.multiply(j), P = K.toBytes();
4055
+ return { head: _, prefix: S, scalar: j, point: K, pointBytes: P };
4050
4056
  }
4051
4057
  function y(x) {
4052
4058
  return d(x).pointBytes;
4053
4059
  }
4054
- function h(x = Uint8Array.of(), ..._) {
4055
- const S = ge(..._);
4056
- return l(e(f(S, Ne("context", x), !!n)));
4060
+ function l(x = Uint8Array.of(), ..._) {
4061
+ const S = me(..._);
4062
+ return h(e(f(S, Ne("context", x), !!n)));
4057
4063
  }
4058
- function w(x, _, S = {}) {
4064
+ function m(x, _, S = {}) {
4059
4065
  x = Ne("message", x), n && (x = n(x));
4060
- const { prefix: j, scalar: L, pointBytes: P } = d(_), W = h(S.context, j, x), ee = s.multiply(W).toBytes(), Re = h(S.context, ee, P, x), qe = o.create(W + Re * L);
4066
+ const { prefix: j, scalar: K, pointBytes: P } = d(_), W = l(S.context, j, x), ee = s.multiply(W).toBytes(), Re = l(S.context, ee, P, x), qe = o.create(W + Re * K);
4061
4067
  if (!o.isValid(qe))
4062
4068
  throw new Error("sign failed: invalid s");
4063
- const Ce = ge(ee, o.toBytes(qe));
4064
- return Ht(Ce, g.signature, "result");
4069
+ const Ee = me(ee, o.toBytes(qe));
4070
+ return Ht(Ee, g.signature, "result");
4065
4071
  }
4066
4072
  const b = { zip215: !0 };
4067
4073
  function u(x, _, S, j = b) {
4068
- const { context: L, zip215: P } = j, W = g.signature;
4074
+ const { context: K, zip215: P } = j, W = g.signature;
4069
4075
  x = Ne("signature", x, W), _ = Ne("message", _), S = Ne("publicKey", S, g.publicKey), P !== void 0 && $r(P, "zip215"), n && (_ = n(_));
4070
4076
  const ee = W / 2, Re = x.subarray(0, ee), qe = Rr(x.subarray(ee, W));
4071
- let Ce, wt, Dt;
4077
+ let Ee, wt, Dt;
4072
4078
  try {
4073
- Ce = t.fromBytes(S, P), wt = t.fromBytes(Re, P), Dt = s.multiplyUnsafe(qe);
4079
+ Ee = t.fromBytes(S, P), wt = t.fromBytes(Re, P), Dt = s.multiplyUnsafe(qe);
4074
4080
  } catch {
4075
4081
  return !1;
4076
4082
  }
4077
- if (!P && Ce.isSmallOrder())
4083
+ if (!P && Ee.isSmallOrder())
4078
4084
  return !1;
4079
- const xr = h(L, wt.toBytes(), Ce.toBytes(), _);
4080
- return wt.add(Ce.multiplyUnsafe(xr)).subtract(Dt).clearCofactor().is0();
4081
- }
4082
- const m = i.BYTES, g = {
4083
- secretKey: m,
4084
- publicKey: m,
4085
- signature: 2 * m,
4086
- seed: m
4085
+ const xr = l(K, wt.toBytes(), Ee.toBytes(), _);
4086
+ return wt.add(Ee.multiplyUnsafe(xr)).subtract(Dt).clearCofactor().is0();
4087
+ }
4088
+ const w = i.BYTES, g = {
4089
+ secretKey: w,
4090
+ publicKey: w,
4091
+ signature: 2 * w,
4092
+ seed: w
4087
4093
  };
4088
4094
  function C(x = c(g.seed)) {
4089
4095
  return Ht(x, g.seed, "seed");
@@ -4093,7 +4099,7 @@ function Go(t, e, r = {}) {
4093
4099
  return { secretKey: _, publicKey: y(_) };
4094
4100
  }
4095
4101
  function R(x) {
4096
- return wi(x) && x.length === o.BYTES;
4102
+ return gi(x) && x.length === o.BYTES;
4097
4103
  }
4098
4104
  function v(x, _) {
4099
4105
  try {
@@ -4120,8 +4126,8 @@ function Go(t, e, r = {}) {
4120
4126
  const { y: _ } = t.fromBytes(x), S = g.publicKey, j = S === 32;
4121
4127
  if (!j && S !== 57)
4122
4128
  throw new Error("only defined for 25519 and 448");
4123
- const L = j ? i.div(G + _, G - _) : i.div(_ - G, _ + G);
4124
- return i.toBytes(L);
4129
+ const K = j ? i.div(G + _, G - _) : i.div(_ - G, _ + G);
4130
+ return i.toBytes(K);
4125
4131
  },
4126
4132
  toMontgomerySecret(x) {
4127
4133
  const _ = g.secretKey;
@@ -4139,14 +4145,14 @@ function Go(t, e, r = {}) {
4139
4145
  return Object.freeze({
4140
4146
  keygen: I,
4141
4147
  getPublicKey: y,
4142
- sign: w,
4148
+ sign: m,
4143
4149
  verify: u,
4144
4150
  utils: B,
4145
4151
  Point: t,
4146
4152
  lengths: g
4147
4153
  });
4148
4154
  }
4149
- function Xo(t) {
4155
+ function Zo(t) {
4150
4156
  const e = {
4151
4157
  a: t.a,
4152
4158
  d: t.d,
@@ -4155,7 +4161,7 @@ function Xo(t) {
4155
4161
  h: t.h,
4156
4162
  Gx: t.Gx,
4157
4163
  Gy: t.Gy
4158
- }, r = t.Fp, n = as(e.n, t.nBitLength, !0), s = { Fp: r, Fn: n, uvRatio: t.uvRatio }, i = {
4164
+ }, r = t.Fp, n = cs(e.n, t.nBitLength, !0), s = { Fp: r, Fn: n, uvRatio: t.uvRatio }, i = {
4159
4165
  randomBytes: t.randomBytes,
4160
4166
  adjustScalarBytes: t.adjustScalarBytes,
4161
4167
  domain: t.domain,
@@ -4164,7 +4170,7 @@ function Xo(t) {
4164
4170
  };
4165
4171
  return { CURVE: e, curveOpts: s, hash: t.hash, eddsaOpts: i };
4166
4172
  }
4167
- function Zo(t, e) {
4173
+ function Wo(t, e) {
4168
4174
  const r = e.Point;
4169
4175
  return Object.assign({}, e, {
4170
4176
  ExtendedPoint: r,
@@ -4173,57 +4179,57 @@ function Zo(t, e) {
4173
4179
  nByteLength: r.Fn.BYTES
4174
4180
  });
4175
4181
  }
4176
- function Wo(t) {
4177
- const { CURVE: e, curveOpts: r, hash: n, eddsaOpts: s } = Xo(t), i = Yo(e, r), o = Go(i, n, s);
4178
- return Zo(t, o);
4182
+ function Qo(t) {
4183
+ const { CURVE: e, curveOpts: r, hash: n, eddsaOpts: s } = Zo(t), i = Go(e, r), o = Xo(i, n, s);
4184
+ return Wo(t, o);
4179
4185
  }
4180
- const Qo = BigInt(1), Yn = BigInt(2);
4186
+ const Jo = BigInt(1), Gn = BigInt(2);
4181
4187
  BigInt(3);
4182
- const Jo = BigInt(5), ea = BigInt(8), On = BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"), ii = {
4188
+ const ea = BigInt(5), ta = BigInt(8), On = BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"), oi = {
4183
4189
  p: On,
4184
4190
  n: BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),
4185
- h: ea,
4191
+ h: ta,
4186
4192
  a: BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),
4187
4193
  d: BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),
4188
4194
  Gx: BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),
4189
4195
  Gy: BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")
4190
4196
  };
4191
- function ta(t) {
4192
- const e = BigInt(10), r = BigInt(20), n = BigInt(40), s = BigInt(80), i = On, c = t * t % i * t % i, a = xe(c, Yn, i) * c % i, f = xe(a, Qo, i) * t % i, l = xe(f, Jo, i) * f % i, p = xe(l, e, i) * l % i, d = xe(p, r, i) * p % i, y = xe(d, n, i) * d % i, h = xe(y, s, i) * y % i, w = xe(h, s, i) * y % i, b = xe(w, e, i) * l % i;
4193
- return { pow_p_5_8: xe(b, Yn, i) * t % i, b2: c };
4194
- }
4195
4197
  function ra(t) {
4198
+ const e = BigInt(10), r = BigInt(20), n = BigInt(40), s = BigInt(80), i = On, c = t * t % i * t % i, a = ge(c, Gn, i) * c % i, f = ge(a, Jo, i) * t % i, h = ge(f, ea, i) * f % i, p = ge(h, e, i) * h % i, d = ge(p, r, i) * p % i, y = ge(d, n, i) * d % i, l = ge(y, s, i) * y % i, m = ge(l, s, i) * y % i, b = ge(m, e, i) * h % i;
4199
+ return { pow_p_5_8: ge(b, Gn, i) * t % i, b2: c };
4200
+ }
4201
+ function na(t) {
4196
4202
  return t[0] &= 248, t[31] &= 127, t[31] |= 64, t;
4197
4203
  }
4198
- const Gn = /* @__PURE__ */ BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");
4199
- function na(t, e) {
4200
- const r = On, n = Be(e * e * e, r), s = Be(n * n * e, r), i = ta(t * s).pow_p_5_8;
4204
+ const Xn = /* @__PURE__ */ BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");
4205
+ function sa(t, e) {
4206
+ const r = On, n = Be(e * e * e, r), s = Be(n * n * e, r), i = ra(t * s).pow_p_5_8;
4201
4207
  let o = Be(t * n * i, r);
4202
- const c = Be(e * o * o, r), a = o, f = Be(o * Gn, r), l = c === t, p = c === Be(-t, r), d = c === Be(-t * Gn, r);
4203
- return l && (o = a), (p || d) && (o = f), bi(o, r) && (o = Be(-o, r)), { isValid: l || p, value: o };
4204
- }
4205
- const sa = as(ii.p, { isLE: !0 }), ia = {
4206
- ...ii,
4207
- Fp: sa,
4208
- hash: gi,
4209
- adjustScalarBytes: ra,
4208
+ const c = Be(e * o * o, r), a = o, f = Be(o * Xn, r), h = c === t, p = c === Be(-t, r), d = c === Be(-t * Xn, r);
4209
+ return h && (o = a), (p || d) && (o = f), xi(o, r) && (o = Be(-o, r)), { isValid: h || p, value: o };
4210
+ }
4211
+ const ia = cs(oi.p, { isLE: !0 }), oa = {
4212
+ ...oi,
4213
+ Fp: ia,
4214
+ hash: bi,
4215
+ adjustScalarBytes: na,
4210
4216
  // dom2
4211
4217
  // Ratio of u to v. Allows us to combine inversion and square root. Uses algo from RFC8032 5.1.3.
4212
4218
  // Constant-time, u/√v
4213
- uvRatio: na
4214
- }, oa = Wo(ia);
4215
- function oi(t) {
4219
+ uvRatio: sa
4220
+ }, aa = Qo(oa);
4221
+ function ai(t) {
4216
4222
  if (!Number.isFinite(t) || t <= 0)
4217
4223
  throw new Error(`expirationTime must be a positive finite number, got ${t}`);
4218
4224
  }
4219
- class aa {
4225
+ class ca {
4220
4226
  #t;
4221
4227
  #e;
4222
4228
  #r = null;
4223
4229
  constructor(e) {
4224
4230
  if (typeof globalThis.indexedDB > "u")
4225
4231
  throw new Error("IndexedDBExpirableStore requires IndexedDB, which is not available in this environment");
4226
- oi(e.expirationTime), this.#t = e.dbName, this.#e = e.storeName, this.expirationTime = e.expirationTime;
4232
+ ai(e.expirationTime), this.#t = e.dbName, this.#e = e.storeName, this.expirationTime = e.expirationTime;
4227
4233
  }
4228
4234
  #s() {
4229
4235
  return this.#r || (this.#r = this.#c().catch((e) => {
@@ -4303,10 +4309,10 @@ class aa {
4303
4309
  });
4304
4310
  }
4305
4311
  }
4306
- class ca {
4312
+ class ua {
4307
4313
  #t;
4308
4314
  constructor(e) {
4309
- oi(e.expirationTime), this.expirationTime = e.expirationTime, this.#t = /* @__PURE__ */ new Map();
4315
+ ai(e.expirationTime), this.expirationTime = e.expirationTime, this.#t = /* @__PURE__ */ new Map();
4310
4316
  }
4311
4317
  get(e) {
4312
4318
  const r = this.#t.get(e);
@@ -4324,10 +4330,10 @@ class ca {
4324
4330
  e - n.timestamp > this.expirationTime && this.#t.delete(r);
4325
4331
  }
4326
4332
  }
4327
- function ua(t) {
4328
- return typeof globalThis.indexedDB < "u" ? new aa(t) : new ca({ expirationTime: t.expirationTime });
4333
+ function fa(t) {
4334
+ return typeof globalThis.indexedDB < "u" ? new ca(t) : new ua({ expirationTime: t.expirationTime });
4329
4335
  }
4330
- const Xn = (t) => {
4336
+ const Zn = (t) => {
4331
4337
  if (t <= 127)
4332
4338
  return 1;
4333
4339
  if (t <= 255)
@@ -4337,7 +4343,7 @@ const Xn = (t) => {
4337
4343
  if (t <= 16777215)
4338
4344
  return 4;
4339
4345
  throw N.fromCode(new lr("Length too long (> 4 bytes)"));
4340
- }, Zn = (t, e, r) => {
4346
+ }, Wn = (t, e, r) => {
4341
4347
  if (r <= 127)
4342
4348
  return t[e] = r, 1;
4343
4349
  if (r <= 255)
@@ -4359,7 +4365,7 @@ const Xn = (t) => {
4359
4365
  if (t[e] === 131)
4360
4366
  return 4;
4361
4367
  throw N.fromCode(new Oe("Length too long (> 4 bytes)"));
4362
- }, fa = (t, e) => {
4368
+ }, da = (t, e) => {
4363
4369
  const r = qr(t, e);
4364
4370
  if (r === 1)
4365
4371
  return t[e];
@@ -4388,7 +4394,7 @@ Uint8Array.from([
4388
4394
  1
4389
4395
  // DER encoded COSE
4390
4396
  ]);
4391
- const Wn = Uint8Array.from([
4397
+ const Qn = Uint8Array.from([
4392
4398
  48,
4393
4399
  5,
4394
4400
  6,
@@ -4452,13 +4458,13 @@ Uint8Array.from([
4452
4458
  2,
4453
4459
  1
4454
4460
  ]);
4455
- function da(t, e) {
4456
- const r = 2 + Xn(t.byteLength + 1), n = e.byteLength + r + t.byteLength;
4461
+ function ha(t, e) {
4462
+ const r = 2 + Zn(t.byteLength + 1), n = e.byteLength + r + t.byteLength;
4457
4463
  let s = 0;
4458
- const i = new Uint8Array(1 + Xn(n) + n);
4459
- return i[s++] = 48, s += Zn(i, s, n), i.set(e, s), s += e.byteLength, i[s++] = 3, s += Zn(i, s, t.byteLength + 1), i[s++] = 0, i.set(new Uint8Array(t), s), i;
4464
+ const i = new Uint8Array(1 + Zn(n) + n);
4465
+ return i[s++] = 48, s += Wn(i, s, n), i.set(e, s), s += e.byteLength, i[s++] = 3, s += Wn(i, s, t.byteLength + 1), i[s++] = 0, i.set(new Uint8Array(t), s), i;
4460
4466
  }
4461
- const ha = (t, e) => {
4467
+ const la = (t, e) => {
4462
4468
  let r = 0;
4463
4469
  const n = (c, a) => {
4464
4470
  if (s[r++] !== c)
@@ -4467,7 +4473,7 @@ const ha = (t, e) => {
4467
4473
  if (n(48, "sequence"), r += qr(s, r), !wr(s.slice(r, r + e.byteLength), e))
4468
4474
  throw N.fromCode(new Oe("Not the expected OID."));
4469
4475
  r += e.byteLength, n(3, "bit string");
4470
- const i = fa(s, r) - 1;
4476
+ const i = da(s, r) - 1;
4471
4477
  r += qr(s, r), n(0, "0 padding");
4472
4478
  const o = s.slice(r);
4473
4479
  if (i !== o.length)
@@ -4478,8 +4484,8 @@ var At, Ot;
4478
4484
  const Ke = class Ke {
4479
4485
  // `fromRaw` and `fromDer` should be used for instantiation, not this constructor.
4480
4486
  constructor(e) {
4481
- oe(this, At);
4482
- oe(this, Ot);
4487
+ ie(this, At);
4488
+ ie(this, Ot);
4483
4489
  if (e.byteLength !== Ke.RAW_KEY_LENGTH)
4484
4490
  throw N.fromCode(new Oe("An Ed25519 public key must be exactly 32 bytes long"));
4485
4491
  te(this, At, e), te(this, Ot, Ke.derEncode(e));
@@ -4494,19 +4500,19 @@ const Ke = class Ke {
4494
4500
  return new Ke(this.derDecode(e));
4495
4501
  }
4496
4502
  static derEncode(e) {
4497
- return da(e, Wn);
4503
+ return ha(e, Qn);
4498
4504
  }
4499
4505
  static derDecode(e) {
4500
- const r = ha(e, Wn);
4506
+ const r = la(e, Qn);
4501
4507
  if (r.length !== this.RAW_KEY_LENGTH)
4502
4508
  throw N.fromCode(new Oe("An Ed25519 public key must be exactly 32 bytes long"));
4503
4509
  return r;
4504
4510
  }
4505
4511
  get rawKey() {
4506
- return K(this, At);
4512
+ return z(this, At);
4507
4513
  }
4508
4514
  get derKey() {
4509
- return K(this, Ot);
4515
+ return z(this, Ot);
4510
4516
  }
4511
4517
  toDer() {
4512
4518
  return this.derKey;
@@ -4517,7 +4523,7 @@ const Ke = class Ke {
4517
4523
  };
4518
4524
  At = new WeakMap(), Ot = new WeakMap(), Ke.RAW_KEY_LENGTH = 32;
4519
4525
  let Lr = Ke;
4520
- class la {
4526
+ class ya {
4521
4527
  constructor() {
4522
4528
  this.observers = [];
4523
4529
  }
@@ -4531,7 +4537,7 @@ class la {
4531
4537
  this.observers.forEach((n) => n(e, ...r));
4532
4538
  }
4533
4539
  }
4534
- class ya extends la {
4540
+ class pa extends ya {
4535
4541
  constructor() {
4536
4542
  super();
4537
4543
  }
@@ -4545,156 +4551,156 @@ class ya extends la {
4545
4551
  this.notify({ message: e, level: "error", error: r }, ...n);
4546
4552
  }
4547
4553
  }
4548
- const Qn = 0.5, Jn = 1.5, es = 500, ts = 6e4, rs = 9e5, ns = 10;
4549
- var he, $t, Rt, Bt, Ut, Nt, Pt, Mt, ot;
4554
+ const Jn = 0.5, es = 1.5, ts = 500, rs = 6e4, ns = 9e5, ss = 10;
4555
+ var fe, $t, Rt, Bt, Ut, Nt, Pt, Mt, ot;
4550
4556
  const dr = class dr {
4551
4557
  constructor(e = dr.default) {
4552
- oe(this, he);
4553
- oe(this, $t);
4554
- oe(this, Rt);
4555
- oe(this, Bt);
4556
- oe(this, Ut);
4557
- oe(this, Nt);
4558
- oe(this, Pt);
4559
- oe(this, Mt);
4560
- oe(this, ot, 0);
4561
- const { initialInterval: r = es, randomizationFactor: n = Qn, multiplier: s = Jn, maxInterval: i = ts, maxElapsedTime: o = rs, maxIterations: c = ns, date: a = Date } = e;
4562
- te(this, he, r), te(this, $t, n), te(this, Rt, s), te(this, Bt, i), te(this, Mt, a), te(this, Ut, a.now()), te(this, Nt, o), te(this, Pt, c);
4558
+ ie(this, fe);
4559
+ ie(this, $t);
4560
+ ie(this, Rt);
4561
+ ie(this, Bt);
4562
+ ie(this, Ut);
4563
+ ie(this, Nt);
4564
+ ie(this, Pt);
4565
+ ie(this, Mt);
4566
+ ie(this, ot, 0);
4567
+ const { initialInterval: r = ts, randomizationFactor: n = Jn, multiplier: s = es, maxInterval: i = rs, maxElapsedTime: o = ns, maxIterations: c = ss, date: a = Date } = e;
4568
+ te(this, fe, r), te(this, $t, n), te(this, Rt, s), te(this, Bt, i), te(this, Mt, a), te(this, Ut, a.now()), te(this, Nt, o), te(this, Pt, c);
4563
4569
  }
4564
4570
  get ellapsedTimeInMsec() {
4565
- return K(this, Mt).now() - K(this, Ut);
4571
+ return z(this, Mt).now() - z(this, Ut);
4566
4572
  }
4567
4573
  get currentInterval() {
4568
- return K(this, he);
4574
+ return z(this, fe);
4569
4575
  }
4570
4576
  get count() {
4571
- return K(this, ot);
4577
+ return z(this, ot);
4572
4578
  }
4573
4579
  get randomValueFromInterval() {
4574
- const e = K(this, $t) * K(this, he), r = K(this, he) - e, n = K(this, he) + e;
4580
+ const e = z(this, $t) * z(this, fe), r = z(this, fe) - e, n = z(this, fe) + e;
4575
4581
  return Math.random() * (n - r) + r;
4576
4582
  }
4577
4583
  incrementCurrentInterval() {
4578
- return te(this, he, Math.min(K(this, he) * K(this, Rt), K(this, Bt))), Un(this, ot)._++, K(this, he);
4584
+ return te(this, fe, Math.min(z(this, fe) * z(this, Rt), z(this, Bt))), Un(this, ot)._++, z(this, fe);
4579
4585
  }
4580
4586
  next() {
4581
- return this.ellapsedTimeInMsec >= K(this, Nt) || K(this, ot) >= K(this, Pt) ? null : (this.incrementCurrentInterval(), this.randomValueFromInterval);
4587
+ return this.ellapsedTimeInMsec >= z(this, Nt) || z(this, ot) >= z(this, Pt) ? null : (this.incrementCurrentInterval(), this.randomValueFromInterval);
4582
4588
  }
4583
4589
  };
4584
- he = new WeakMap(), $t = new WeakMap(), Rt = new WeakMap(), Bt = new WeakMap(), Ut = new WeakMap(), Nt = new WeakMap(), Pt = new WeakMap(), Mt = new WeakMap(), ot = new WeakMap(), dr.default = {
4585
- initialInterval: es,
4586
- randomizationFactor: Qn,
4587
- multiplier: Jn,
4588
- maxInterval: ts,
4590
+ fe = new WeakMap(), $t = new WeakMap(), Rt = new WeakMap(), Bt = new WeakMap(), Ut = new WeakMap(), Nt = new WeakMap(), Pt = new WeakMap(), Mt = new WeakMap(), ot = new WeakMap(), dr.default = {
4591
+ initialInterval: ts,
4592
+ randomizationFactor: Jn,
4593
+ multiplier: es,
4594
+ maxInterval: rs,
4589
4595
  // 1 minute
4590
- maxElapsedTime: rs,
4591
- maxIterations: ns,
4596
+ maxElapsedTime: ns,
4597
+ maxIterations: ss,
4592
4598
  date: Date
4593
4599
  };
4594
4600
  let Kr = dr;
4595
- const pa = 300 * 1e3;
4596
- function ma() {
4597
- return _a(ga(wa(), 1e3), xa(1e3, 1.2), ba(pa));
4598
- }
4601
+ const ma = 300 * 1e3;
4599
4602
  function wa() {
4603
+ return Ta(ba(ga(), 1e3), _a(1e3, 1.2), xa(ma));
4604
+ }
4605
+ function ga() {
4600
4606
  let t = !0;
4601
4607
  return async () => t ? (t = !1, !0) : !1;
4602
4608
  }
4603
- function ga(t, e) {
4609
+ function ba(t, e) {
4604
4610
  return async (r, n, s) => {
4605
4611
  if (await t(r, n, s))
4606
4612
  return new Promise((i) => setTimeout(i, e));
4607
4613
  };
4608
4614
  }
4609
- function ba(t) {
4615
+ function xa(t) {
4610
4616
  const e = Date.now() + t;
4611
4617
  return async (r, n, s) => {
4612
4618
  if (Date.now() > e)
4613
4619
  throw M.fromCode(new Tt(`Request timed out after ${t} msec`, n, s));
4614
4620
  };
4615
4621
  }
4616
- function xa(t, e) {
4622
+ function _a(t, e) {
4617
4623
  let r = t;
4618
4624
  return () => new Promise((n) => setTimeout(() => {
4619
4625
  r *= e, n();
4620
4626
  }, r));
4621
4627
  }
4622
- function _a(...t) {
4628
+ function Ta(...t) {
4623
4629
  return async (e, r, n) => {
4624
4630
  for (const s of t)
4625
4631
  await s(e, r, n);
4626
4632
  };
4627
4633
  }
4628
- const Ta = {
4634
+ const Ea = {
4629
4635
  preSignReadStateRequest: !1
4630
4636
  };
4631
- function ai(t, e) {
4637
+ function ci(t, e) {
4632
4638
  return Object.prototype.hasOwnProperty.call(t, e);
4633
4639
  }
4634
4640
  function Sr(t, e) {
4635
- return t !== null && typeof t == "object" && ai(t, e);
4641
+ return t !== null && typeof t == "object" && ci(t, e);
4636
4642
  }
4637
- function Ea(t, e) {
4638
- return ai(t, e) && typeof t[e] == "function";
4643
+ function Ca(t, e) {
4644
+ return ci(t, e) && typeof t[e] == "function";
4639
4645
  }
4640
- function ss(t) {
4641
- return Sr(t, "body") && Sr(t.body, "content") && t.body.content.request_type === St.ReadState && Sr(t.body.content, "ingress_expiry") && typeof t.body.content.ingress_expiry == "object" && t.body.content.ingress_expiry !== null && Ea(t.body.content.ingress_expiry, "toHash");
4646
+ function is(t) {
4647
+ return Sr(t, "body") && Sr(t.body, "content") && t.body.content.request_type === St.ReadState && Sr(t.body.content, "ingress_expiry") && typeof t.body.content.ingress_expiry == "object" && t.body.content.ingress_expiry !== null && Ca(t.body.content.ingress_expiry, "toHash");
4642
4648
  }
4643
4649
  async function zr(t, e, r, n = {}) {
4644
4650
  const s = [U("request_status"), r];
4645
4651
  let i, o;
4646
- if (n.preSignReadStateRequest ?? !1 ? (o = await Ca({
4652
+ if (n.preSignReadStateRequest ?? !1 ? (o = await Ia({
4647
4653
  paths: [s],
4648
4654
  agent: t,
4649
4655
  pollingOptions: n
4650
4656
  }), i = await t.readState(e, { paths: [s] }, void 0, o)) : i = await t.readState(e, { paths: [s] }), t.rootKey == null)
4651
- throw ce.fromCode(new Xe());
4652
- const a = await Ee.create({
4657
+ throw ae.fromCode(new Xe());
4658
+ const a = await Te.create({
4653
4659
  certificate: i.certificate,
4654
4660
  rootKey: t.rootKey,
4655
4661
  principal: { canisterId: e },
4656
4662
  blsVerify: n.blsVerify,
4657
4663
  agent: t
4658
- }), f = be(a.lookup_path([...s, U("status")]));
4659
- let l;
4660
- switch (typeof f > "u" ? l = le.Unknown : l = new TextDecoder().decode(f), l) {
4661
- case le.Replied:
4664
+ }), f = we(a.lookup_path([...s, U("status")]));
4665
+ let h;
4666
+ switch (typeof f > "u" ? h = de.Unknown : h = new TextDecoder().decode(f), h) {
4667
+ case de.Replied:
4662
4668
  return {
4663
- reply: be(a.lookup_path([...s, "reply"])),
4669
+ reply: we(a.lookup_path([...s, "reply"])),
4664
4670
  certificate: a,
4665
4671
  rawCertificate: i.certificate
4666
4672
  };
4667
- case le.Received:
4668
- case le.Unknown:
4669
- case le.Processing: {
4670
- const p = n.strategy ?? ma();
4671
- return await p(e, r, l), zr(t, e, r, {
4673
+ case de.Received:
4674
+ case de.Unknown:
4675
+ case de.Processing: {
4676
+ const p = n.strategy ?? wa();
4677
+ return await p(e, r, h), zr(t, e, r, {
4672
4678
  ...n,
4673
4679
  // Pass over either the strategy already provided or the new one created above
4674
4680
  strategy: p,
4675
4681
  request: o
4676
4682
  });
4677
4683
  }
4678
- case le.Rejected:
4679
- throw ke.fromCode(si(a, s, r));
4680
- case le.Done:
4684
+ case de.Rejected:
4685
+ throw ke.fromCode(ii(a, s, r));
4686
+ case de.Done:
4681
4687
  throw Z.fromCode(new un(r));
4682
4688
  }
4683
4689
  throw Se;
4684
4690
  }
4685
- async function Ca(t) {
4691
+ async function Ia(t) {
4686
4692
  const { paths: e, agent: r, pollingOptions: n } = t;
4687
- if (n.request && ss(n.request))
4693
+ if (n.request && is(n.request))
4688
4694
  return n.request;
4689
4695
  const s = await r.createReadStateRequest?.({
4690
4696
  paths: e
4691
4697
  }, void 0);
4692
- if (!ss(s))
4698
+ if (!is(s))
4693
4699
  throw N.fromCode(new gn(s));
4694
4700
  return s;
4695
4701
  }
4696
- const Hr = 60 * 1e3, Ia = 1e6, va = 0, Sa = "308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae", Aa = "ic0.app", Oa = ".ic0.app", $a = "icp0.io", Ra = ".icp0.io", Ba = "icp-api.io", Ua = ".icp-api.io", Ar = 200, is = 202, Na = 404;
4697
- function Pa(t) {
4702
+ const Hr = 60 * 1e3, va = 1e6, Sa = 0, Aa = "308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae", Oa = "ic0.app", $a = ".ic0.app", Ra = "icp0.io", Ba = ".icp0.io", Ua = "icp-api.io", Na = ".icp-api.io", Ar = 200, os = 202, Pa = 404;
4703
+ function Ma(t) {
4698
4704
  let e;
4699
4705
  if (t !== void 0)
4700
4706
  !t.match(/^[a-z]+:/) && typeof window < "u" ? e = new URL(`${window.location.protocol}//${t}`) : e = new URL(t);
@@ -4736,18 +4742,18 @@ class Me {
4736
4742
  * @deprecated Use `HttpAgent.create` or `HttpAgent.createSync` instead
4737
4743
  */
4738
4744
  constructor(e = {}) {
4739
- if (this.#t = null, this.#e = !1, this.#r = va, this.#s = !1, this.#c = null, this.#f = !1, this._isAgent = !0, this.config = {}, this.log = new ya(), this.#l = [], this.#y = [], this.#x = /* @__PURE__ */ new Map(), this.#p = !0, this.#E = (s, i) => {
4745
+ if (this.#t = null, this.#e = !1, this.#r = Sa, this.#s = !1, this.#c = null, this.#f = !1, this._isAgent = !0, this.config = {}, this.log = new pa(), this.#l = [], this.#y = [], this.#x = /* @__PURE__ */ new Map(), this.#p = !0, this.#E = (s, i) => {
4740
4746
  if (this.#p === !1)
4741
4747
  return s;
4742
4748
  const { status: o, signatures: c = [], requestId: a } = s, f = i.size;
4743
4749
  if (c.length > f)
4744
4750
  throw M.fromCode(new ln(c.length, f));
4745
- for (const l of c) {
4746
- const { timestamp: p, identity: d } = l, y = A.fromUint8Array(d).toText();
4747
- let h;
4751
+ for (const h of c) {
4752
+ const { timestamp: p, identity: d } = h, y = A.fromUint8Array(d).toText();
4753
+ let l;
4748
4754
  if (o === at.Replied) {
4749
4755
  const { reply: g } = s;
4750
- h = cr({
4756
+ l = cr({
4751
4757
  status: o,
4752
4758
  reply: g,
4753
4759
  timestamp: BigInt(p),
@@ -4755,7 +4761,7 @@ class Me {
4755
4761
  });
4756
4762
  } else if (o === at.Rejected) {
4757
4763
  const { reject_code: g, reject_message: C, error_code: I } = s;
4758
- h = cr({
4764
+ l = cr({
4759
4765
  status: o,
4760
4766
  reject_code: g,
4761
4767
  reject_message: C,
@@ -4765,12 +4771,12 @@ class Me {
4765
4771
  });
4766
4772
  } else
4767
4773
  throw Z.fromCode(new ne(`Unknown status: ${o}`));
4768
- const w = ge(Di, h), b = i.get(y);
4774
+ const m = me(Fi, l), b = i.get(y);
4769
4775
  if (!b)
4770
4776
  throw M.fromCode(new pn());
4771
4777
  const u = Lr.fromDer(b).rawKey;
4772
- if (!oa.verify(l.signature, w, u))
4773
- throw ae.fromCode(new mn(y));
4778
+ if (!aa.verify(h.signature, m, u))
4779
+ throw oe.fromCode(new mn(y));
4774
4780
  }
4775
4781
  return s;
4776
4782
  }, this.config = e, e.fetch)
@@ -4781,9 +4787,9 @@ class Me {
4781
4787
  throw N.fromCode(new dn());
4782
4788
  this.#i = s.bind(globalThis);
4783
4789
  }
4784
- this.#g = e.fetchOptions, this.#T = e.callOptions, this.#e = e.shouldFetchRootKey ?? !1, this.#f = e.shouldSyncTime ?? !1, e.rootKey ? this.rootKey = e.rootKey : this.#e ? this.rootKey = null : this.rootKey = Gr(Sa);
4785
- const r = Pa(e.host);
4786
- this.host = new URL(r), this.host.hostname.endsWith(Oa) ? this.host.hostname = Aa : this.host.hostname.endsWith(Ra) ? this.host.hostname = $a : this.host.hostname.endsWith(Ua) && (this.host.hostname = Ba), e.verifyQuerySignatures !== void 0 && (this.#p = e.verifyQuerySignatures), this.#b = e.subnetNodeKeyExpirableStore ?? ua({
4790
+ this.#g = e.fetchOptions, this.#T = e.callOptions, this.#e = e.shouldFetchRootKey ?? !1, this.#f = e.shouldSyncTime ?? !1, e.rootKey ? this.rootKey = e.rootKey : this.#e ? this.rootKey = null : this.rootKey = Gr(Aa);
4791
+ const r = Ma(e.host);
4792
+ this.host = new URL(r), this.host.hostname.endsWith($a) ? this.host.hostname = Oa : this.host.hostname.endsWith(Ba) ? this.host.hostname = Ra : this.host.hostname.endsWith(Na) && (this.host.hostname = Ua), e.verifyQuerySignatures !== void 0 && (this.#p = e.verifyQuerySignatures), this.#b = e.subnetNodeKeyExpirableStore ?? fa({
4787
4793
  dbName: `icp-sdk-${this.host.host}`,
4788
4794
  storeName: "subnetNodeKeys",
4789
4795
  expirationTime: 5 * Hr
@@ -4796,10 +4802,10 @@ class Me {
4796
4802
  this.#o = `${s}${i ? `:${i}` : ""}`;
4797
4803
  }
4798
4804
  if (this.#n = Promise.resolve(e.identity || new Er()), e.ingressExpiryInMinutes && e.ingressExpiryInMinutes > 5)
4799
- throw N.fromCode(new ve("The maximum ingress expiry time is 5 minutes.", e.ingressExpiryInMinutes));
4805
+ throw N.fromCode(new Ie("The maximum ingress expiry time is 5 minutes.", e.ingressExpiryInMinutes));
4800
4806
  if (e.ingressExpiryInMinutes && e.ingressExpiryInMinutes <= 0)
4801
- throw N.fromCode(new ve("Ingress expiry time must be greater than 0.", e.ingressExpiryInMinutes));
4802
- this.#a = e.ingressExpiryInMinutes || 5, this.addTransform("update", Fn(Dr)), e.useQueryNonces && this.addTransform("query", Fn(Dr)), e.logToConsole && this.log.subscribe((s) => {
4807
+ throw N.fromCode(new Ie("Ingress expiry time must be greater than 0.", e.ingressExpiryInMinutes));
4808
+ this.#a = e.ingressExpiryInMinutes || 5, this.addTransform("update", qn(Dr)), e.useQueryNonces && this.addTransform("query", qn(Dr)), e.logToConsole && this.log.subscribe((s) => {
4803
4809
  s.level === "error" ? console.error(s.message) : s.level === "warn" ? console.warn(s.message) : console.log(s.message);
4804
4810
  });
4805
4811
  }
@@ -4838,28 +4844,23 @@ class Me {
4838
4844
  }
4839
4845
  async getPrincipal() {
4840
4846
  if (!this.#n)
4841
- throw ce.fromCode(new Le());
4847
+ throw ae.fromCode(new Le());
4842
4848
  return (await this.#n).getPrincipal();
4843
4849
  }
4844
4850
  /**
4845
4851
  * Makes a call to a canister method.
4846
4852
  * @param canisterId - The ID of the canister to call. Can be a Principal or a string.
4847
4853
  * @param options - Options for the call.
4848
- * @param options.methodName - The name of the method to call.
4849
- * @param options.arg - The argument to pass to the method, as a Uint8Array.
4850
- * @param options.effectiveCanisterId - (Optional) The effective canister ID, if different from the target canister ID.
4851
- * @param options.callSync - (Optional) Whether to use synchronous call mode. Defaults to true.
4852
- * @param options.nonce - (Optional) A unique nonce for the request. If provided, it will override any nonce set by transforms.
4853
4854
  * @param identity - (Optional) The identity to use for the call. If not provided, the agent's current identity will be used.
4854
4855
  * @returns A promise that resolves to the response of the call, including the request ID and response details.
4855
4856
  */
4856
4857
  async call(e, r, n) {
4857
4858
  const s = r.callSync ?? !0, i = await (n ?? this.#n);
4858
4859
  if (!i)
4859
- throw ce.fromCode(new Le());
4860
+ throw ae.fromCode(new Le());
4860
4861
  const o = A.from(e), c = r.effectiveCanisterId ? A.from(r.effectiveCanisterId) : o;
4861
4862
  await this.#d(c);
4862
- const a = i.getPrincipal(), f = Or(this.#a, this.#r), l = {
4863
+ const a = i.getPrincipal(), f = Or(this.#a, this.#r), h = {
4863
4864
  request_type: jr.Call,
4864
4865
  canister_id: o,
4865
4866
  method_name: r.methodName,
@@ -4877,62 +4878,62 @@ class Me {
4877
4878
  }
4878
4879
  },
4879
4880
  endpoint: ze.Call,
4880
- body: l
4881
+ body: h
4881
4882
  }), d;
4882
- r?.nonce ? d = y(r.nonce) : p.body.nonce ? d = y(p.body.nonce) : d = void 0, l.nonce = d;
4883
+ r?.nonce ? d = y(r.nonce) : p.body.nonce ? d = y(p.body.nonce) : d = void 0, h.nonce = d;
4883
4884
  function y(u) {
4884
4885
  return Object.assign(u, { __nonce__: void 0 });
4885
4886
  }
4886
4887
  p = await i.transformRequest(p);
4887
- const h = Ir(p.body), w = this.#h(), b = Tr(l);
4888
+ const l = Tr(p.body.content ?? h), m = Ir(p.body), b = this.#h();
4888
4889
  try {
4889
4890
  const g = s ? () => {
4890
4891
  const v = new URL(`/api/v4/canister/${c.toText()}/call`, this.host);
4891
4892
  return this.log.print(`fetching "${v.pathname}" with request:`, p), this.#i(v, {
4892
4893
  ...this.#T,
4893
4894
  ...p.request,
4894
- body: h
4895
+ body: m
4895
4896
  });
4896
4897
  } : () => {
4897
4898
  const v = new URL(`/api/v2/canister/${c.toText()}/call`, this.host);
4898
4899
  return this.log.print(`fetching "${v.pathname}" with request:`, p), this.#i(v, {
4899
4900
  ...this.#T,
4900
4901
  ...p.request,
4901
- body: h
4902
+ body: m
4902
4903
  });
4903
4904
  }, { responseBodyBytes: C, ...I } = await this.#m({
4904
4905
  requestFn: g,
4905
- backoff: w,
4906
+ backoff: b,
4906
4907
  tries: 0
4907
- }), R = C.byteLength > 0 ? Te(C) : null;
4908
+ }), R = C.byteLength > 0 ? _e(C) : null;
4908
4909
  return {
4909
- requestId: b,
4910
+ requestId: l,
4910
4911
  response: {
4911
4912
  ...I,
4912
4913
  body: R
4913
4914
  },
4914
- requestDetails: l
4915
+ requestDetails: h
4915
4916
  };
4916
4917
  } catch (u) {
4917
- let m;
4918
- if (u instanceof _e) {
4918
+ let w;
4919
+ if (u instanceof xe) {
4919
4920
  if (u.hasCode(rr))
4920
4921
  return this.log.warn("v4 api not supported. Fall back to v2"), this.call(e, {
4921
4922
  ...r,
4922
4923
  // disable v4 api
4923
4924
  callSync: !1
4924
4925
  }, n);
4925
- if (u.hasCode(ve) && !this.#s)
4926
+ if (u.hasCode(Ie) && !this.#s)
4926
4927
  return await this.syncTime(o), this.call(o, r, n);
4927
4928
  u.code.requestContext = {
4928
- requestId: b,
4929
+ requestId: l,
4929
4930
  senderPubKey: p.body.sender_pubkey,
4930
4931
  senderSignature: p.body.sender_sig,
4931
4932
  ingressExpiry: p.body.content.ingress_expiry
4932
- }, m = u;
4933
+ }, w = u;
4933
4934
  } else
4934
- m = Z.fromCode(new ne(u));
4935
- throw this.log.error(`Error while making call: ${m.message}`, m), m;
4935
+ w = Z.fromCode(new ne(u));
4936
+ throw this.log.error(`Error while making call: ${w.message}`, w), w;
4936
4937
  }
4937
4938
  }
4938
4939
  /**
@@ -4944,53 +4945,53 @@ class Me {
4944
4945
  */
4945
4946
  async update(e, r, n = {}) {
4946
4947
  const s = A.from(r.effectiveCanisterId), { requestId: i, response: o, requestDetails: c } = await this.call(e, r), { body: a, ...f } = o;
4947
- if (_i(a))
4948
- return this.#S(a, o, i, s, r.methodName, f, c, n);
4949
- if (xi(a) && this.#A(a, i, s, r.methodName, f), o.status === is)
4950
- return { ...await zr(this, s, i, n), requestDetails: c, callResponse: o };
4951
- const l = new ne(`Unexpected response from call: status ${o.status} with unrecognized body`);
4952
- throw l.callContext = {
4948
+ if (Ti(a))
4949
+ return this.#S(a, o, i, s, r.methodName, f, c, n, r.onPollingStarted);
4950
+ if (_i(a) && this.#A(a, i, s, r.methodName, f), o.status === os)
4951
+ return r.onPollingStarted?.(), { ...await zr(this, s, i, n), requestDetails: c, callResponse: o };
4952
+ const h = new ne(`Unexpected response from call: status ${o.status} with unrecognized body`);
4953
+ throw h.callContext = {
4953
4954
  canisterId: s,
4954
4955
  methodName: r.methodName,
4955
4956
  httpDetails: f
4956
- }, Z.fromCode(l);
4957
+ }, Z.fromCode(h);
4957
4958
  }
4958
- async #S(e, r, n, s, i, o, c, a) {
4959
+ async #S(e, r, n, s, i, o, c, a, f) {
4959
4960
  if (this.rootKey == null)
4960
- throw ce.fromCode(new Xe());
4961
- const f = e.certificate, l = await Ee.create({
4962
- certificate: f,
4961
+ throw ae.fromCode(new Xe());
4962
+ const h = e.certificate, p = await Te.create({
4963
+ certificate: h,
4963
4964
  rootKey: this.rootKey,
4964
4965
  principal: { canisterId: s },
4965
4966
  blsVerify: a.blsVerify,
4966
4967
  agent: this
4967
- }), p = [U("request_status"), n], d = be(l.lookup_path([...p, U("status")])), y = d ? new TextDecoder().decode(d) : void 0;
4968
- switch (y) {
4969
- case le.Replied:
4968
+ }), d = [U("request_status"), n], y = we(p.lookup_path([...d, U("status")])), l = y ? new TextDecoder().decode(y) : void 0;
4969
+ switch (l) {
4970
+ case de.Replied:
4970
4971
  return {
4971
- reply: be(l.lookup_path([...p, "reply"])),
4972
- certificate: l,
4973
- rawCertificate: f,
4972
+ reply: we(p.lookup_path([...d, "reply"])),
4973
+ certificate: p,
4974
+ rawCertificate: h,
4974
4975
  requestDetails: c,
4975
4976
  callResponse: r
4976
4977
  };
4977
- case le.Rejected: {
4978
- const h = si(l, p, n);
4979
- throw h.callContext = {
4978
+ case de.Rejected: {
4979
+ const m = ii(p, d, n);
4980
+ throw m.callContext = {
4980
4981
  canisterId: s,
4981
4982
  methodName: i,
4982
4983
  httpDetails: o
4983
- }, ke.fromCode(h);
4984
+ }, ke.fromCode(m);
4984
4985
  }
4985
4986
  case void 0:
4986
- return this.log.warn(`v4 sync response certificate does not contain request ID ${V(n)} status. Falling back to polling.`), { ...await zr(this, s, n, a), requestDetails: c, callResponse: r };
4987
+ return this.log.warn(`v4 sync response certificate does not contain request ID ${V(n)} status. Falling back to polling.`), f?.(), { ...await zr(this, s, n, a), requestDetails: c, callResponse: r };
4987
4988
  default: {
4988
- const h = new wn(y, n, r, f);
4989
- throw h.callContext = {
4989
+ const m = new wn(l, n, r, h);
4990
+ throw m.callContext = {
4990
4991
  canisterId: s,
4991
4992
  methodName: i,
4992
4993
  httpDetails: o
4993
- }, Z.fromCode(h);
4994
+ }, Z.fromCode(m);
4994
4995
  }
4995
4996
  }
4996
4997
  }
@@ -5011,9 +5012,9 @@ class Me {
5011
5012
  }), a === null)
5012
5013
  throw Z.fromCode(new Tt(`Backoff strategy exhausted after ${c} attempts.`, i));
5013
5014
  a > 0 && await new Promise((u) => setTimeout(u, a));
5014
- let l;
5015
+ let h;
5015
5016
  try {
5016
- this.log.print(`fetching "${f.pathname}" with request:`, n), l = await this.#i(f, {
5017
+ this.log.print(`fetching "${f.pathname}" with request:`, n), h = await this.#i(f, {
5017
5018
  ...this.#g,
5018
5019
  ...n.request,
5019
5020
  body: s
@@ -5025,38 +5026,38 @@ class Me {
5025
5026
  Retrying query.`), await this.#_({ ...e, tries: c + 1 });
5026
5027
  throw er.fromCode(new nr(u));
5027
5028
  }
5028
- const p = qn(l.headers);
5029
- if (l.status !== Ar) {
5030
- const u = await l.text();
5031
- if (os(u))
5032
- throw N.fromCode(new ve(u, this.#a));
5029
+ const p = Ln(h.headers);
5030
+ if (h.status !== Ar) {
5031
+ const u = await h.text();
5032
+ if (as(u))
5033
+ throw N.fromCode(new Ie(u, this.#a));
5033
5034
  if (c < this.#u)
5034
5035
  return await this.#_({ ...e, tries: c + 1 });
5035
- throw M.fromCode(new tr(l.status, l.statusText, p, u));
5036
+ throw M.fromCode(new tr(h.status, h.statusText, p, u));
5036
5037
  }
5037
5038
  const y = {
5038
- ...Te(ar(await l.arrayBuffer())),
5039
+ ..._e(ar(await h.arrayBuffer())),
5039
5040
  httpDetails: {
5040
- ok: l.ok,
5041
- status: l.status,
5042
- statusText: l.statusText,
5041
+ ok: h.ok,
5042
+ status: h.status,
5043
+ statusText: h.statusText,
5043
5044
  headers: p
5044
5045
  },
5045
5046
  requestId: i
5046
5047
  };
5047
5048
  if (!this.#p)
5048
5049
  return y;
5049
- const h = y.signatures?.[0]?.timestamp;
5050
- if (!h)
5050
+ const l = y.signatures?.[0]?.timestamp;
5051
+ if (!l)
5051
5052
  throw M.fromCode(new yn("Timestamp not found in query response. This suggests a malformed or malicious response."));
5052
- const w = Number(BigInt(h) / BigInt(Ia));
5053
- if (Date.now() + this.#r - w > this.#v) {
5053
+ const m = Number(BigInt(l) / BigInt(va));
5054
+ if (Date.now() + this.#r - m > this.#v) {
5054
5055
  if (c < this.#u)
5055
5056
  return this.log.warn("Timestamp is older than the max ingress expiry. Retrying query.", {
5056
5057
  requestId: i,
5057
- signatureTimestampMs: w
5058
+ signatureTimestampMs: m
5058
5059
  }), await this.syncTime(r), await this.#_({ ...e, tries: c + 1 });
5059
- throw ae.fromCode(new sn(this.#a, i, c));
5060
+ throw oe.fromCode(new sn(this.#a, i, c));
5060
5061
  }
5061
5062
  return y;
5062
5063
  }
@@ -5075,19 +5076,19 @@ class Me {
5075
5076
  const { requestFn: r, backoff: n, tries: s } = e, i = s === 0 ? 0 : n.next();
5076
5077
  if (i === null)
5077
5078
  throw M.fromCode(new Tt(`Retry strategy exhausted after ${s} attempts.`));
5078
- i > 0 && await new Promise((l) => setTimeout(l, i));
5079
+ i > 0 && await new Promise((h) => setTimeout(h, i));
5079
5080
  let o, c = new Uint8Array();
5080
5081
  try {
5081
5082
  o = await r(), o.status === Ar && (c = ar(await o.clone().arrayBuffer()));
5082
- } catch (l) {
5083
+ } catch (h) {
5083
5084
  if (s < this.#u)
5084
5085
  return this.log.warn(`Caught exception while attempting to make request:
5085
- ${l}
5086
+ ${h}
5086
5087
  Retrying request.`), await this.#m({ requestFn: r, backoff: n, tries: s + 1 });
5087
- throw er.fromCode(new nr(l));
5088
+ throw er.fromCode(new nr(h));
5088
5089
  }
5089
- const a = qn(o.headers);
5090
- if (o.status === Ar || o.status === is)
5090
+ const a = Ln(o.headers);
5091
+ if (o.status === Ar || o.status === os)
5091
5092
  return {
5092
5093
  ok: o.ok,
5093
5094
  // should always be true
@@ -5097,10 +5098,10 @@ class Me {
5097
5098
  headers: a
5098
5099
  };
5099
5100
  const f = await o.text();
5100
- if (o.status === Na && o.url.includes("api/v4"))
5101
+ if (o.status === Pa && o.url.includes("api/v4"))
5101
5102
  throw M.fromCode(new rr());
5102
- if (os(f))
5103
- throw N.fromCode(new ve(f, this.#a));
5103
+ if (as(f))
5104
+ throw N.fromCode(new Ie(f, this.#a));
5104
5105
  if (s < this.#u)
5105
5106
  return await this.#m({ requestFn: r, backoff: n, tries: s + 1 });
5106
5107
  throw M.fromCode(new tr(o.status, o.statusText, a, f));
@@ -5111,15 +5112,15 @@ class Me {
5111
5112
  let o;
5112
5113
  const c = await (n ?? this.#n);
5113
5114
  if (!c)
5114
- throw ce.fromCode(new Le());
5115
- const a = A.from(e), f = c.getPrincipal(), l = Or(this.#a, this.#r), p = {
5115
+ throw ae.fromCode(new Le());
5116
+ const a = A.from(e), f = c.getPrincipal(), h = Or(this.#a, this.#r), p = {
5116
5117
  request_type: St.Query,
5117
5118
  canister_id: a,
5118
5119
  method_name: r.methodName,
5119
5120
  arg: r.arg,
5120
5121
  sender: f,
5121
- ingress_expiry: l
5122
- }, d = Tr(p);
5122
+ ingress_expiry: h
5123
+ };
5123
5124
  o = await this._transform({
5124
5125
  request: {
5125
5126
  method: "POST",
@@ -5131,7 +5132,7 @@ class Me {
5131
5132
  endpoint: ze.Query,
5132
5133
  body: p
5133
5134
  }), o = await c.transformRequest(o);
5134
- const y = Ir(o.body), h = {
5135
+ const d = Tr(o.body.content ?? p), y = Ir(o.body), l = {
5135
5136
  canister: a.toText(),
5136
5137
  ecid: i,
5137
5138
  transformedRequest: o,
@@ -5139,8 +5140,8 @@ class Me {
5139
5140
  requestId: d,
5140
5141
  backoff: s,
5141
5142
  tries: 0
5142
- }, w = async () => {
5143
- const b = await this.#_(h);
5143
+ }, m = async () => {
5144
+ const b = await this.#_(l);
5144
5145
  return {
5145
5146
  requestDetails: p,
5146
5147
  ...b
@@ -5148,22 +5149,22 @@ class Me {
5148
5149
  };
5149
5150
  try {
5150
5151
  if (!this.#p)
5151
- return await w();
5152
+ return await m();
5152
5153
  const [b, u] = await Promise.all([
5153
- w(),
5154
+ m(),
5154
5155
  this.fetchSubnetKeys(i)
5155
5156
  ]);
5156
5157
  try {
5157
5158
  return this.#E(b, u);
5158
5159
  } catch {
5159
5160
  this.log.warn("Query response verification failed. Retrying with fresh subnet keys."), await this.#b.delete(i.toString());
5160
- const m = await this.fetchSubnetKeys(i);
5161
- return this.#E(b, m);
5161
+ const w = await this.fetchSubnetKeys(i);
5162
+ return this.#E(b, w);
5162
5163
  }
5163
5164
  } catch (b) {
5164
5165
  let u;
5165
- if (b instanceof _e) {
5166
- if (b.hasCode(ve) && !this.#s)
5166
+ if (b instanceof xe) {
5167
+ if (b.hasCode(Ie) && !this.#s)
5167
5168
  return await this.syncTime(i), this.query(e, r, n);
5168
5169
  b.code.requestContext = {
5169
5170
  requestId: d,
@@ -5187,7 +5188,7 @@ class Me {
5187
5188
  await this.#d();
5188
5189
  const n = await (r ?? this.#n);
5189
5190
  if (!n)
5190
- throw ce.fromCode(new Le());
5191
+ throw ae.fromCode(new Le());
5191
5192
  const s = n.getPrincipal(), i = await this._transform({
5192
5193
  request: {
5193
5194
  method: "POST",
@@ -5209,10 +5210,10 @@ class Me {
5209
5210
  async readState(e, r, n, s) {
5210
5211
  await this.#w();
5211
5212
  const i = A.from(e);
5212
- function o(l) {
5213
- for (const p of l.paths) {
5214
- const [d, y] = p, h = new TextEncoder().encode("request_status");
5215
- if (wr(d, h))
5213
+ function o(h) {
5214
+ for (const p of h.paths) {
5215
+ const [d, y] = p, l = new TextEncoder().encode("request_status");
5216
+ if (wr(d, l))
5216
5217
  return y;
5217
5218
  }
5218
5219
  }
@@ -5221,10 +5222,10 @@ class Me {
5221
5222
  c = s;
5222
5223
  else {
5223
5224
  a = o(r);
5224
- const l = await this.#n;
5225
- if (!l)
5226
- throw ce.fromCode(new Le());
5227
- c = await this.createReadStateRequest(r, l);
5225
+ const h = await this.#n;
5226
+ if (!h)
5227
+ throw ae.fromCode(new Le());
5228
+ c = await this.createReadStateRequest(r, h);
5228
5229
  }
5229
5230
  const f = new URL(`/api/v3/canister/${i.toString()}/read_state`, this.host);
5230
5231
  return await this.#C(f, { canisterId: i }, c, a);
@@ -5252,11 +5253,11 @@ class Me {
5252
5253
  backoff: i,
5253
5254
  tries: 0
5254
5255
  });
5255
- return Te(o);
5256
+ return _e(o);
5256
5257
  } catch (o) {
5257
5258
  let c;
5258
- if (o instanceof _e) {
5259
- if (o.hasCode(ve) && !this.#s) {
5259
+ if (o instanceof xe) {
5260
+ if (o.hasCode(Ie) && !this.#s) {
5260
5261
  if ("canisterId" in r)
5261
5262
  await this.syncTime(r.canisterId);
5262
5263
  else if ("subnetId" in r)
@@ -5279,13 +5280,13 @@ class Me {
5279
5280
  parseTimeFromResponse(e) {
5280
5281
  let r;
5281
5282
  if (e.certificate) {
5282
- const n = Te(e.certificate);
5283
+ const n = _e(e.certificate);
5283
5284
  if (n && "tree" in n)
5284
5285
  r = n.tree;
5285
5286
  else
5286
5287
  throw M.fromCode(new Vt("Could not decode time from response"));
5287
5288
  const s = mt(["time"], r);
5288
- if (s.status !== ie.Found)
5289
+ if (s.status !== se.Found)
5289
5290
  throw M.fromCode(new Ge("Time was not found in the response or was not in its expected format.", s.status));
5290
5291
  if (!(s.value instanceof Uint8Array) && !ArrayBuffer.isView(s))
5291
5292
  throw M.fromCode(new Qr("Time was not in its expected format."));
@@ -5312,7 +5313,7 @@ class Me {
5312
5313
  rootKey: this.rootKey ?? void 0,
5313
5314
  shouldSyncTime: !1
5314
5315
  }), i = await Promise.all(Array(3).fill(null).map(async () => {
5315
- const c = (await Do({
5316
+ const c = (await Fo({
5316
5317
  canisterId: n,
5317
5318
  agent: s,
5318
5319
  paths: ["time"],
@@ -5324,7 +5325,7 @@ class Me {
5324
5325
  }, []));
5325
5326
  this.#I(r, i);
5326
5327
  } catch (n) {
5327
- const s = n instanceof _e ? n : Z.fromCode(new ne(n));
5328
+ const s = n instanceof xe ? n : Z.fromCode(new ne(n));
5328
5329
  throw this.log.error("Caught exception while attempting to sync time", s), s;
5329
5330
  }
5330
5331
  })(), await this.#c.finally(() => {
@@ -5347,7 +5348,7 @@ class Me {
5347
5348
  rootKey: this.rootKey ?? void 0,
5348
5349
  shouldSyncTime: !1
5349
5350
  }), s = await Promise.all(Array(3).fill(null).map(async () => {
5350
- const o = (await Lo({
5351
+ const o = (await Ko({
5351
5352
  subnetId: e,
5352
5353
  agent: n,
5353
5354
  paths: ["time"],
@@ -5359,7 +5360,7 @@ class Me {
5359
5360
  }, []));
5360
5361
  this.#I(r, s);
5361
5362
  } catch (n) {
5362
- const s = n instanceof _e ? n : Z.fromCode(new ne(n));
5363
+ const s = n instanceof xe ? n : Z.fromCode(new ne(n));
5363
5364
  throw this.log.error("Caught exception while attempting to sync time with subnet", s), s;
5364
5365
  }
5365
5366
  }
@@ -5380,7 +5381,7 @@ class Me {
5380
5381
  requestFn: () => this.#i(r, { headers: e, ...this.#g }),
5381
5382
  tries: 0
5382
5383
  });
5383
- return Te(s);
5384
+ return _e(s);
5384
5385
  }
5385
5386
  async fetchRootKey() {
5386
5387
  return this.#t = this.#t ?? (async () => {
@@ -5398,7 +5399,7 @@ class Me {
5398
5399
  if (this.rootKey === null && this.host.toString() !== "https://icp-api.io" && this.#e)
5399
5400
  await this.fetchRootKey();
5400
5401
  else
5401
- throw ce.fromCode(new Xe(this.#e));
5402
+ throw ae.fromCode(new Xe(this.#e));
5402
5403
  }
5403
5404
  async #O(e) {
5404
5405
  this.#f && !this.hasSyncedTime() && await this.syncTime(e);
@@ -5425,7 +5426,7 @@ class Me {
5425
5426
  await this.#d(e);
5426
5427
  const r = this.rootKey, n = await this.readState(e, {
5427
5428
  paths: [[U("subnet")]]
5428
- }), s = await Ee.create({
5429
+ }), s = await Te.create({
5429
5430
  certificate: n.certificate,
5430
5431
  rootKey: r,
5431
5432
  principal: { canisterId: e },
@@ -5433,14 +5434,14 @@ class Me {
5433
5434
  });
5434
5435
  if (!s.cert.delegation) {
5435
5436
  const c = A.selfAuthenticating(r);
5436
- if (!ti({
5437
+ if (!ri({
5437
5438
  canisterId: e,
5438
5439
  subnetId: c,
5439
5440
  tree: s.cert.tree
5440
5441
  }))
5441
- throw ae.fromCode(new kt(e, c));
5442
+ throw oe.fromCode(new kt(e, c));
5442
5443
  }
5443
- const i = Hn(s.cert, r), o = An(s.cert, i);
5444
+ const i = Yn(s.cert, r), o = An(s.cert, i);
5444
5445
  return await this.#b.set(e.toText(), o), o;
5445
5446
  }
5446
5447
  /**
@@ -5454,13 +5455,13 @@ class Me {
5454
5455
  await this.#d(r);
5455
5456
  const n = await this.readState(r, {
5456
5457
  paths: [[U("time")]]
5457
- }), s = await Ee.create({
5458
+ }), s = await Te.create({
5458
5459
  certificate: n.certificate,
5459
5460
  rootKey: this.rootKey,
5460
5461
  principal: { canisterId: r },
5461
5462
  agent: this
5462
5463
  });
5463
- return Hn(s.cert, this.rootKey);
5464
+ return Yn(s.cert, this.rootKey);
5464
5465
  }
5465
5466
  _transform(e) {
5466
5467
  let r = Promise.resolve(e);
@@ -5492,11 +5493,11 @@ function Or(t, e) {
5492
5493
  const r = t * Hr;
5493
5494
  return it.fromDeltaInMilliseconds(r, e);
5494
5495
  }
5495
- function os(t) {
5496
+ function as(t) {
5496
5497
  return t.includes("Invalid request expiry: ");
5497
5498
  }
5498
5499
  const re = /* @__PURE__ */ Symbol.for("ic-agent-metadata");
5499
- class ci {
5500
+ class ui {
5500
5501
  /**
5501
5502
  * Get the Agent class this Actor would call, or undefined if the Actor would use
5502
5503
  * the default agent (global.ic.agent).
@@ -5516,22 +5517,22 @@ class ci {
5516
5517
  return A.from(e[re].config.canisterId);
5517
5518
  }
5518
5519
  static createActorClass(e, r) {
5519
- const n = e({ IDL: Vi });
5520
- class s extends ci {
5520
+ const n = e({ IDL: ji });
5521
+ class s extends ui {
5521
5522
  constructor(o) {
5522
5523
  if (!o.canisterId)
5523
5524
  throw N.fromCode(new sr(o.canisterId));
5524
5525
  const c = typeof o.canisterId == "string" ? A.fromText(o.canisterId) : o.canisterId;
5525
5526
  super({
5526
5527
  config: {
5527
- ...ui,
5528
+ ...fi,
5528
5529
  ...o,
5529
5530
  canisterId: c
5530
5531
  },
5531
5532
  service: n
5532
5533
  });
5533
5534
  for (const [a, f] of n._fields)
5534
- r?.httpDetails && f.annotations.push(Yr), r?.certificate && f.annotations.push(fi), this[a] = Ma(this, a, f, o.blsVerify);
5535
+ r?.httpDetails && f.annotations.push(Yr), r?.certificate && f.annotations.push(di), this[a] = ka(this, a, f, o.blsVerify);
5535
5536
  }
5536
5537
  }
5537
5538
  return s;
@@ -5621,7 +5622,7 @@ class ci {
5621
5622
  }
5622
5623
  }
5623
5624
  function rt(t, e) {
5624
- const r = gs(t, e);
5625
+ const r = bs(t, e);
5625
5626
  switch (r.length) {
5626
5627
  case 0:
5627
5628
  return;
@@ -5631,11 +5632,11 @@ function rt(t, e) {
5631
5632
  return r;
5632
5633
  }
5633
5634
  }
5634
- const ui = {
5635
- pollingOptions: Ta,
5635
+ const fi = {
5636
+ pollingOptions: Ea,
5636
5637
  queryStrategy: "query"
5637
- }, Yr = "http-details", fi = "certificate";
5638
- function Ma(t, e, r, n) {
5638
+ }, Yr = "http-details", di = "certificate";
5639
+ function ka(t, e, r, n) {
5639
5640
  let s;
5640
5641
  const i = r.annotations.includes("query") || r.annotations.includes("composite_query"), o = t[re].config.queryStrategy;
5641
5642
  i && o === "query" ? s = async (a, ...f) => {
@@ -5646,26 +5647,26 @@ function Ma(t, e, r, n) {
5646
5647
  ...a
5647
5648
  })
5648
5649
  };
5649
- const l = a.agent || t[re].config.agent || new Me(), p = A.from(a.canisterId || t[re].config.canisterId), d = Ur(r.argTypes, f), y = await l.query(p, {
5650
+ const h = a.agent || t[re].config.agent || new Me(), p = A.from(a.canisterId || t[re].config.canisterId), d = Ur(r.argTypes, f), y = await h.query(p, {
5650
5651
  methodName: e,
5651
5652
  arg: d,
5652
5653
  effectiveCanisterId: a.effectiveCanisterId
5653
- }), h = {
5654
+ }), l = {
5654
5655
  ...y.httpDetails,
5655
5656
  requestDetails: y.requestDetails
5656
5657
  };
5657
5658
  switch (y.status) {
5658
5659
  case at.Rejected: {
5659
- const w = new an(y.requestId, y.reject_code, y.reject_message, y.error_code, y.signatures);
5660
- throw w.callContext = {
5660
+ const m = new an(y.requestId, y.reject_code, y.reject_message, y.error_code, y.signatures);
5661
+ throw m.callContext = {
5661
5662
  canisterId: p,
5662
5663
  methodName: e,
5663
- httpDetails: h
5664
- }, ke.fromCode(w);
5664
+ httpDetails: l
5665
+ }, ke.fromCode(m);
5665
5666
  }
5666
5667
  case at.Replied:
5667
5668
  return r.annotations.includes(Yr) ? {
5668
- httpDetails: h,
5669
+ httpDetails: l,
5669
5670
  result: rt(r.retTypes, y.reply.arg)
5670
5671
  } : rt(r.retTypes, y.reply.arg);
5671
5672
  }
@@ -5677,33 +5678,33 @@ function Ma(t, e, r, n) {
5677
5678
  ...a
5678
5679
  })
5679
5680
  };
5680
- const l = a.agent || t[re].config.agent || Me.createSync(), { canisterId: p, effectiveCanisterId: d, pollingOptions: y } = {
5681
- ...ui,
5681
+ const h = a.agent || t[re].config.agent || Me.createSync(), { canisterId: p, effectiveCanisterId: d, pollingOptions: y } = {
5682
+ ...fi,
5682
5683
  ...t[re].config,
5683
5684
  ...a
5684
- }, h = A.from(p), w = d !== void 0 ? A.from(d) : h, b = Ur(r.argTypes, f);
5685
- let u, m, g, C;
5685
+ }, l = A.from(p), m = d !== void 0 ? A.from(d) : l, b = Ur(r.argTypes, f);
5686
+ let u, w, g, C;
5686
5687
  try {
5687
- ({ reply: u, certificate: m, callResponse: g, requestDetails: C } = await l.update(h, {
5688
+ ({ reply: u, certificate: w, callResponse: g, requestDetails: C } = await h.update(l, {
5688
5689
  methodName: e,
5689
5690
  arg: b,
5690
- effectiveCanisterId: w,
5691
+ effectiveCanisterId: m,
5691
5692
  nonce: a.nonce
5692
5693
  }, { ...y, blsVerify: n }));
5693
5694
  } catch (B) {
5694
5695
  if (B instanceof ke) {
5695
5696
  const x = Object.create(Object.getPrototypeOf(B.code), Object.getOwnPropertyDescriptors(B.code));
5696
- throw x.callContext = { ...B.code.callContext, canisterId: h, methodName: e }, ke.fromCode(x);
5697
+ throw x.callContext = { ...B.code.callContext, canisterId: l, methodName: e }, ke.fromCode(x);
5697
5698
  }
5698
5699
  throw B;
5699
5700
  }
5700
- const I = r.annotations.includes(Yr), R = r.annotations.includes(fi), v = { ...g, requestDetails: C };
5701
+ const I = r.annotations.includes(Yr), R = r.annotations.includes(di), v = { ...g, requestDetails: C };
5701
5702
  return I && R ? {
5702
5703
  httpDetails: v,
5703
- certificate: m,
5704
+ certificate: w,
5704
5705
  result: rt(r.retTypes, u)
5705
5706
  } : R ? {
5706
- certificate: m,
5707
+ certificate: w,
5707
5708
  result: rt(r.retTypes, u)
5708
5709
  } : I ? {
5709
5710
  httpDetails: v,
@@ -5714,5 +5715,5 @@ function Ma(t, e, r, n) {
5714
5715
  return c.withOptions = (a) => (...f) => s(a, ...f), c;
5715
5716
  }
5716
5717
  export {
5717
- ci as A
5718
+ ui as A
5718
5719
  };