@cartridge/controller 0.12.0 → 0.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
1
  import { WalletAccount as Qt, constants as Z, num as ct, shortString as Qe } from "starknet";
2
- import { R as Q, t as Ht, i as jt, K as lt, B as Wt, N as _, p as Yt, v as Vt, A as qt, s as dt } from "./provider-BYY0uIsZ.js";
3
- import { a as Ps, d as Ts, E as Rs, f as Us, e as Ms, F as zs, I as Os, h as Ds, n as Fs, b as Qs, c as Hs } from "./provider-BYY0uIsZ.js";
2
+ import { R as T, t as Ht, i as jt, K as lt, B as Wt, N as A, p as Yt, v as Vt, A as qt, s as dt } from "./provider-B8OiOgBt.js";
3
+ import { a as Ro, d as Uo, E as Mo, f as zo, e as Oo, F as Do, I as Fo, h as Qo, n as Ho, b as jo, c as Wo } from "./provider-B8OiOgBt.js";
4
4
  class He extends Qt {
5
5
  keychain;
6
6
  modal;
7
7
  options;
8
- constructor(e, r, n, s, o, a) {
8
+ constructor(e, r, n, o, s, a) {
9
9
  super({
10
10
  provider: { nodeUrl: r },
11
11
  walletProvider: e,
12
12
  address: n
13
- }), this.keychain = s, this.options = o, this.modal = a;
13
+ }), this.keychain = o, this.options = s, this.modal = a;
14
14
  }
15
15
  /**
16
16
  * Invoke execute function in account contract
@@ -26,34 +26,59 @@ class He extends Qt {
26
26
  */
27
27
  async execute(e) {
28
28
  return e = Ht(e), new Promise(async (r, n) => {
29
- const s = await this.keychain.execute(
29
+ const o = await this.keychain.execute(
30
30
  e,
31
31
  void 0,
32
32
  void 0,
33
33
  !1,
34
34
  this.options?.feeSource
35
35
  );
36
- if (s.code === Q.SUCCESS) {
37
- r(s);
36
+ if (o.code === T.SUCCESS) {
37
+ r(o);
38
+ return;
39
+ }
40
+ if (this.options?.propagateSessionErrors && o.code !== T.USER_INTERACTION_REQUIRED) {
41
+ n(o.error);
38
42
  return;
39
43
  }
40
- if (this.options?.propagateSessionErrors && s.code !== Q.USER_INTERACTION_REQUIRED) {
41
- n(s.error);
44
+ const s = this.options?.errorDisplayMode || "modal", a = o.error, i = o.code === T.USER_INTERACTION_REQUIRED;
45
+ if (s === "silent" && !i) {
46
+ console.warn(
47
+ "[Cartridge Controller] Transaction failed silently:",
48
+ a
49
+ ), n(a);
50
+ return;
51
+ }
52
+ if (s === "notification" && !i) {
53
+ const { toast: c } = await Promise.resolve().then(() => xo);
54
+ let d = !1, h;
55
+ h = c({
56
+ variant: "error",
57
+ message: a?.message || "Transaction failed",
58
+ duration: 1e4,
59
+ onClick: () => {
60
+ d = !0, h && h(), this.modal.open(), this.keychain.execute(e, void 0, void 0, !0, a).then((f) => {
61
+ f.code === T.SUCCESS ? (r(f), this.modal.close()) : n(f.error);
62
+ });
63
+ }
64
+ }), setTimeout(() => {
65
+ d || n(a);
66
+ }, 10100);
42
67
  return;
43
68
  }
44
69
  this.modal.open();
45
- const o = await this.keychain.execute(
70
+ const l = await this.keychain.execute(
46
71
  e,
47
72
  void 0,
48
73
  void 0,
49
74
  !0,
50
- s.error
75
+ a
51
76
  );
52
- if (o.code === Q.SUCCESS) {
53
- r(o), this.modal.close();
77
+ if (l.code === T.SUCCESS) {
78
+ r(l), this.modal.close();
54
79
  return;
55
80
  }
56
- n(o.error);
81
+ n(l.error);
57
82
  });
58
83
  }
59
84
  /**
@@ -66,14 +91,14 @@ class He extends Qt {
66
91
  */
67
92
  async signMessage(e) {
68
93
  return new Promise(async (r, n) => {
69
- const s = await this.keychain.signMessage(e, "", !0);
70
- if (!("code" in s)) {
71
- r(s);
94
+ const o = await this.keychain.signMessage(e, "", !0);
95
+ if (!("code" in o)) {
96
+ r(o);
72
97
  return;
73
98
  }
74
99
  this.modal.open();
75
- const o = await this.keychain.signMessage(e, "", !1);
76
- "code" in o ? n(o.error) : r(o), this.modal.close();
100
+ const s = await this.keychain.signMessage(e, "", !1);
101
+ "code" in s ? n(s.error) : r(s), this.modal.close();
77
102
  });
78
103
  }
79
104
  }
@@ -81,10 +106,10 @@ var B;
81
106
  (function(t) {
82
107
  t.Call = "call", t.Reply = "reply", t.Syn = "syn", t.SynAck = "synAck", t.Ack = "ack";
83
108
  })(B || (B = {}));
84
- var M;
109
+ var z;
85
110
  (function(t) {
86
111
  t.Fulfilled = "fulfilled", t.Rejected = "rejected";
87
- })(M || (M = {}));
112
+ })(z || (z = {}));
88
113
  var G;
89
114
  (function(t) {
90
115
  t.ConnectionDestroyed = "ConnectionDestroyed", t.ConnectionTimeout = "ConnectionTimeout", t.NoIframeSrc = "NoIframeSrc";
@@ -93,21 +118,21 @@ var ve;
93
118
  (function(t) {
94
119
  t.DataCloneError = "DataCloneError";
95
120
  })(ve || (ve = {}));
96
- var R;
121
+ var U;
97
122
  (function(t) {
98
123
  t.Message = "message";
99
- })(R || (R = {}));
124
+ })(U || (U = {}));
100
125
  const Zt = (t, e) => {
101
126
  const r = [];
102
127
  let n = !1;
103
128
  return {
104
- destroy(s) {
105
- n || (n = !0, e(`${t}: Destroying connection`), r.forEach((o) => {
106
- o(s);
129
+ destroy(o) {
130
+ n || (n = !0, e(`${t}: Destroying connection`), r.forEach((s) => {
131
+ s(o);
107
132
  }));
108
133
  },
109
- onDestroy(s) {
110
- n ? s() : r.push(s);
134
+ onDestroy(o) {
135
+ n ? o() : r.push(o);
111
136
  }
112
137
  };
113
138
  }, Kt = (t) => (...e) => {
@@ -119,10 +144,10 @@ const Zt = (t, e) => {
119
144
  if (t && Jt.find((i) => t.startsWith(i)))
120
145
  return "null";
121
146
  const e = document.location, r = Xt.exec(t);
122
- let n, s, o;
123
- r ? (n = r[1] ? r[1] : e.protocol, s = r[2], o = r[4]) : (n = e.protocol, s = e.hostname, o = e.port);
124
- const a = o && o !== Gt[n] ? `:${o}` : "";
125
- return `${n}//${s}${a}`;
147
+ let n, o, s;
148
+ r ? (n = r[1] ? r[1] : e.protocol, o = r[2], s = r[4]) : (n = e.protocol, o = e.hostname, s = e.port);
149
+ const a = s && s !== Gt[n] ? `:${s}` : "";
150
+ return `${n}//${o}${a}`;
126
151
  }, je = ({ name: t, message: e, stack: r }) => ({
127
152
  name: t,
128
153
  message: e,
@@ -131,121 +156,121 @@ const Zt = (t, e) => {
131
156
  const e = new Error();
132
157
  return Object.keys(t).forEach((r) => e[r] = t[r]), e;
133
158
  }, rr = (t, e, r) => {
134
- const { localName: n, local: s, remote: o, originForSending: a, originForReceiving: i } = t;
159
+ const { localName: n, local: o, remote: s, originForSending: a, originForReceiving: i } = t;
135
160
  let l = !1;
136
161
  const c = (d) => {
137
- if (d.source !== o || d.data.penpal !== B.Call)
162
+ if (d.source !== s || d.data.penpal !== B.Call)
138
163
  return;
139
164
  if (i !== "*" && d.origin !== i) {
140
165
  r(`${n} received message from origin ${d.origin} which did not match expected origin ${i}`);
141
166
  return;
142
167
  }
143
- const h = d.data, { methodName: f, args: u, id: p } = h;
168
+ const h = d.data, { methodName: f, args: u, id: g } = h;
144
169
  r(`${n}: Received ${f}() call`);
145
- const b = (y) => (I) => {
170
+ const y = (w) => (_) => {
146
171
  if (r(`${n}: Sending ${f}() reply`), l) {
147
172
  r(`${n}: Unable to send ${f}() reply due to destroyed connection`);
148
173
  return;
149
174
  }
150
- const m = {
175
+ const C = {
151
176
  penpal: B.Reply,
152
- id: p,
153
- resolution: y,
154
- returnValue: I
177
+ id: g,
178
+ resolution: w,
179
+ returnValue: _
155
180
  };
156
- y === M.Rejected && I instanceof Error && (m.returnValue = je(I), m.returnValueIsError = !0);
181
+ w === z.Rejected && _ instanceof Error && (C.returnValue = je(_), C.returnValueIsError = !0);
157
182
  try {
158
- o.postMessage(m, a);
159
- } catch (w) {
160
- if (w.name === ve.DataCloneError) {
161
- const E = {
183
+ s.postMessage(C, a);
184
+ } catch (p) {
185
+ if (p.name === ve.DataCloneError) {
186
+ const k = {
162
187
  penpal: B.Reply,
163
- id: p,
164
- resolution: M.Rejected,
165
- returnValue: je(w),
188
+ id: g,
189
+ resolution: z.Rejected,
190
+ returnValue: je(p),
166
191
  returnValueIsError: !0
167
192
  };
168
- o.postMessage(E, a);
193
+ s.postMessage(k, a);
169
194
  }
170
- throw w;
195
+ throw p;
171
196
  }
172
197
  };
173
- new Promise((y) => y(e[f].call(e, d.origin).apply(e, u))).then(b(M.Fulfilled), b(M.Rejected));
198
+ new Promise((w) => w(e[f].call(e, d.origin).apply(e, u))).then(y(z.Fulfilled), y(z.Rejected));
174
199
  };
175
- return s.addEventListener(R.Message, c), () => {
176
- l = !0, s.removeEventListener(R.Message, c);
200
+ return o.addEventListener(U.Message, c), () => {
201
+ l = !0, o.removeEventListener(U.Message, c);
177
202
  };
178
203
  };
179
204
  let nr = 0;
180
- const sr = () => ++nr, ht = ".", ft = (t) => t ? t.split(ht) : [], or = (t) => t.join(ht), ar = (t, e) => {
205
+ const or = () => ++nr, ht = ".", ft = (t) => t ? t.split(ht) : [], sr = (t) => t.join(ht), ar = (t, e) => {
181
206
  const r = ft(e || "");
182
- return r.push(t), or(r);
207
+ return r.push(t), sr(r);
183
208
  }, ir = (t, e, r) => {
184
209
  const n = ft(e);
185
- return n.reduce((s, o, a) => (typeof s[o] > "u" && (s[o] = {}), a === n.length - 1 && (s[o] = r), s[o]), t), t;
210
+ return n.reduce((o, s, a) => (typeof o[s] > "u" && (o[s] = {}), a === n.length - 1 && (o[s] = r), o[s]), t), t;
186
211
  }, ut = (t, e) => {
187
212
  const r = {};
188
213
  return Object.keys(t).forEach((n) => {
189
- const s = t[n], o = ar(n, e);
190
- typeof s == "object" && Object.assign(r, ut(s, o)), typeof s == "function" && (r[o] = s);
214
+ const o = t[n], s = ar(n, e);
215
+ typeof o == "object" && Object.assign(r, ut(o, s)), typeof o == "function" && (r[s] = o);
191
216
  }), r;
192
217
  }, cr = (t) => {
193
218
  const e = {};
194
219
  for (const r in t)
195
220
  ir(e, r, t[r]);
196
221
  return e;
197
- }, lr = (t, e, r, n, s) => {
198
- const { localName: o, local: a, remote: i, originForSending: l, originForReceiving: c } = e;
222
+ }, lr = (t, e, r, n, o) => {
223
+ const { localName: s, local: a, remote: i, originForSending: l, originForReceiving: c } = e;
199
224
  let d = !1;
200
- s(`${o}: Connecting call sender`);
201
- const h = (u) => (...p) => {
202
- s(`${o}: Sending ${u}() call`);
203
- let b;
225
+ o(`${s}: Connecting call sender`);
226
+ const h = (u) => (...g) => {
227
+ o(`${s}: Sending ${u}() call`);
228
+ let y;
204
229
  try {
205
- i.closed && (b = !0);
230
+ i.closed && (y = !0);
206
231
  } catch {
207
- b = !0;
232
+ y = !0;
208
233
  }
209
- if (b && n(), d) {
210
- const y = new Error(`Unable to send ${u}() call due to destroyed connection`);
211
- throw y.code = G.ConnectionDestroyed, y;
234
+ if (y && n(), d) {
235
+ const w = new Error(`Unable to send ${u}() call due to destroyed connection`);
236
+ throw w.code = G.ConnectionDestroyed, w;
212
237
  }
213
- return new Promise((y, I) => {
214
- const m = sr(), w = (L) => {
215
- if (L.source !== i || L.data.penpal !== B.Reply || L.data.id !== m)
238
+ return new Promise((w, _) => {
239
+ const C = or(), p = (L) => {
240
+ if (L.source !== i || L.data.penpal !== B.Reply || L.data.id !== C)
216
241
  return;
217
242
  if (c !== "*" && L.origin !== c) {
218
- s(`${o} received message from origin ${L.origin} which did not match expected origin ${c}`);
243
+ o(`${s} received message from origin ${L.origin} which did not match expected origin ${c}`);
219
244
  return;
220
245
  }
221
246
  const ue = L.data;
222
- s(`${o}: Received ${u}() reply`), a.removeEventListener(R.Message, w);
247
+ o(`${s}: Received ${u}() reply`), a.removeEventListener(U.Message, p);
223
248
  let pe = ue.returnValue;
224
- ue.returnValueIsError && (pe = tr(pe)), (ue.resolution === M.Fulfilled ? y : I)(pe);
249
+ ue.returnValueIsError && (pe = tr(pe)), (ue.resolution === z.Fulfilled ? w : _)(pe);
225
250
  };
226
- a.addEventListener(R.Message, w);
227
- const E = {
251
+ a.addEventListener(U.Message, p);
252
+ const k = {
228
253
  penpal: B.Call,
229
- id: m,
254
+ id: C,
230
255
  methodName: u,
231
- args: p
256
+ args: g
232
257
  };
233
- i.postMessage(E, l);
258
+ i.postMessage(k, l);
234
259
  });
235
- }, f = r.reduce((u, p) => (u[p] = h(p), u), {});
260
+ }, f = r.reduce((u, g) => (u[g] = h(g), u), {});
236
261
  return Object.assign(t, cr(f)), () => {
237
262
  d = !0;
238
263
  };
239
- }, dr = (t, e, r, n, s) => {
240
- const { destroy: o, onDestroy: a } = n;
264
+ }, dr = (t, e, r, n, o) => {
265
+ const { destroy: s, onDestroy: a } = n;
241
266
  let i, l;
242
267
  const c = {};
243
268
  return (d) => {
244
269
  if (e !== "*" && d.origin !== e) {
245
- s(`Parent: Handshake - Received ACK message from origin ${d.origin} which did not match expected origin ${e}`);
270
+ o(`Parent: Handshake - Received ACK message from origin ${d.origin} which did not match expected origin ${e}`);
246
271
  return;
247
272
  }
248
- s("Parent: Handshake - Received ACK");
273
+ o("Parent: Handshake - Received ACK");
249
274
  const h = {
250
275
  localName: "Parent",
251
276
  local: window,
@@ -253,31 +278,31 @@ const sr = () => ++nr, ht = ".", ft = (t) => t ? t.split(ht) : [], or = (t) => t
253
278
  originForSending: r,
254
279
  originForReceiving: e
255
280
  };
256
- i && i(), i = rr(h, t, s), a(i), l && l.forEach((u) => {
281
+ i && i(), i = rr(h, t, o), a(i), l && l.forEach((u) => {
257
282
  delete c[u];
258
283
  }), l = d.data.methodNames;
259
- const f = lr(c, h, l, o, s);
284
+ const f = lr(c, h, l, s, o);
260
285
  return a(f), c;
261
286
  };
262
- }, hr = (t, e, r, n) => (s) => {
263
- if (!s.source)
287
+ }, hr = (t, e, r, n) => (o) => {
288
+ if (!o.source)
264
289
  return;
265
- if (r !== "*" && s.origin !== r) {
266
- t(`Parent: Handshake - Received SYN message from origin ${s.origin} which did not match expected origin ${r}`);
290
+ if (r !== "*" && o.origin !== r) {
291
+ t(`Parent: Handshake - Received SYN message from origin ${o.origin} which did not match expected origin ${r}`);
267
292
  return;
268
293
  }
269
294
  t("Parent: Handshake - Received SYN, responding with SYN-ACK");
270
- const o = {
295
+ const s = {
271
296
  penpal: B.SynAck,
272
297
  methodNames: Object.keys(e)
273
298
  };
274
- s.source.postMessage(o, n);
299
+ o.source.postMessage(s, n);
275
300
  }, fr = 6e4, ur = (t, e) => {
276
- const { destroy: r, onDestroy: n } = e, s = setInterval(() => {
277
- t.isConnected || (clearInterval(s), r());
301
+ const { destroy: r, onDestroy: n } = e, o = setInterval(() => {
302
+ t.isConnected || (clearInterval(o), r());
278
303
  }, fr);
279
304
  n(() => {
280
- clearInterval(s);
305
+ clearInterval(o);
281
306
  });
282
307
  }, pr = (t, e) => {
283
308
  let r;
@@ -293,27 +318,27 @@ const sr = () => ++nr, ht = ".", ft = (t) => t ? t.split(ht) : [], or = (t) => t
293
318
  throw e.code = G.NoIframeSrc, e;
294
319
  }
295
320
  }, mr = (t) => {
296
- let { iframe: e, methods: r = {}, childOrigin: n, timeout: s, debug: o = !1 } = t;
297
- const a = Kt(o), i = Zt("Parent", a), { onDestroy: l, destroy: c } = i;
321
+ let { iframe: e, methods: r = {}, childOrigin: n, timeout: o, debug: s = !1 } = t;
322
+ const a = Kt(s), i = Zt("Parent", a), { onDestroy: l, destroy: c } = i;
298
323
  n || (gr(e), n = er(e.src));
299
324
  const d = n === "null" ? "*" : n, h = ut(r), f = hr(a, h, n, d), u = dr(h, n, d, i, a);
300
325
  return {
301
- promise: new Promise((b, y) => {
302
- const I = pr(s, c), m = (w) => {
303
- if (!(w.source !== e.contentWindow || !w.data)) {
304
- if (w.data.penpal === B.Syn) {
305
- f(w);
326
+ promise: new Promise((y, w) => {
327
+ const _ = pr(o, c), C = (p) => {
328
+ if (!(p.source !== e.contentWindow || !p.data)) {
329
+ if (p.data.penpal === B.Syn) {
330
+ f(p);
306
331
  return;
307
332
  }
308
- if (w.data.penpal === B.Ack) {
309
- const E = u(w);
310
- E && (I(), b(E));
333
+ if (p.data.penpal === B.Ack) {
334
+ const k = u(p);
335
+ k && (_(), y(k));
311
336
  return;
312
337
  }
313
338
  }
314
339
  };
315
- window.addEventListener(R.Message, m), a("Parent: Awaiting handshake"), ur(e, i), l((w) => {
316
- window.removeEventListener(R.Message, m), w && y(w);
340
+ window.addEventListener(U.Message, C), a("Parent: Awaiting handshake"), ur(e, i), l((p) => {
341
+ window.removeEventListener(U.Message, C), p && w(p);
317
342
  });
318
343
  }),
319
344
  destroy() {
@@ -331,8 +356,8 @@ class wr {
331
356
  id: e,
332
357
  url: r,
333
358
  onClose: n,
334
- onConnect: s,
335
- methods: o = {}
359
+ onConnect: o,
360
+ methods: s = {}
336
361
  }) {
337
362
  if (typeof document > "u" || typeof window > "u")
338
363
  return;
@@ -365,9 +390,9 @@ class wr {
365
390
  methods: {
366
391
  close: (f) => () => this.close(),
367
392
  reload: (f) => () => window.location.reload(),
368
- ...o
393
+ ...s
369
394
  }
370
- }).promise.then(s), this.resize(), window.addEventListener("resize", () => this.resize());
395
+ }).promise.then(o), this.resize(), window.addEventListener("resize", () => this.resize());
371
396
  const d = new MutationObserver(() => {
372
397
  if (typeof document > "u") return;
373
398
  const f = document.getElementById("controller");
@@ -412,15 +437,15 @@ class wr {
412
437
  const yr = "6.13.7";
413
438
  function We(t, e, r) {
414
439
  for (let n in e) {
415
- let s = e[n];
416
- Object.defineProperty(t, n, { enumerable: !0, value: s, writable: !1 });
440
+ let o = e[n];
441
+ Object.defineProperty(t, n, { enumerable: !0, value: o, writable: !1 });
417
442
  }
418
443
  }
419
- function F(t) {
444
+ function Q(t) {
420
445
  if (t == null)
421
446
  return "null";
422
447
  if (Array.isArray(t))
423
- return "[ " + t.map(F).join(", ") + " ]";
448
+ return "[ " + t.map(Q).join(", ") + " ]";
424
449
  if (t instanceof Uint8Array) {
425
450
  const e = "0123456789abcdef";
426
451
  let r = "0x";
@@ -429,7 +454,7 @@ function F(t) {
429
454
  return r;
430
455
  }
431
456
  if (typeof t == "object" && typeof t.toJSON == "function")
432
- return F(t.toJSON());
457
+ return Q(t.toJSON());
433
458
  switch (typeof t) {
434
459
  case "boolean":
435
460
  case "symbol":
@@ -442,7 +467,7 @@ function F(t) {
442
467
  return JSON.stringify(t);
443
468
  case "object": {
444
469
  const e = Object.keys(t);
445
- return e.sort(), "{ " + e.map((r) => `${F(r)}: ${F(t[r])}`).join(", ") + " }";
470
+ return e.sort(), "{ " + e.map((r) => `${Q(r)}: ${Q(t[r])}`).join(", ") + " }";
446
471
  }
447
472
  }
448
473
  return "[ COULD NOT SERIALIZE ]";
@@ -450,32 +475,32 @@ function F(t) {
450
475
  function br(t, e, r) {
451
476
  let n = t;
452
477
  {
453
- const o = [];
478
+ const s = [];
454
479
  if (r) {
455
480
  if ("message" in r || "code" in r || "name" in r)
456
- throw new Error(`value will overwrite populated values: ${F(r)}`);
481
+ throw new Error(`value will overwrite populated values: ${Q(r)}`);
457
482
  for (const a in r) {
458
483
  if (a === "shortMessage")
459
484
  continue;
460
485
  const i = r[a];
461
- o.push(a + "=" + F(i));
486
+ s.push(a + "=" + Q(i));
462
487
  }
463
488
  }
464
- o.push(`code=${e}`), o.push(`version=${yr}`), o.length && (t += " (" + o.join(", ") + ")");
489
+ s.push(`code=${e}`), s.push(`version=${yr}`), s.length && (t += " (" + s.join(", ") + ")");
465
490
  }
466
- let s;
491
+ let o;
467
492
  switch (e) {
468
493
  case "INVALID_ARGUMENT":
469
- s = new TypeError(t);
494
+ o = new TypeError(t);
470
495
  break;
471
496
  case "NUMERIC_FAULT":
472
497
  case "BUFFER_OVERRUN":
473
- s = new RangeError(t);
498
+ o = new RangeError(t);
474
499
  break;
475
500
  default:
476
- s = new Error(t);
501
+ o = new Error(t);
477
502
  }
478
- return We(s, { code: e }), r && Object.assign(s, r), s.shortMessage == null && We(s, { shortMessage: n }), s;
503
+ return We(o, { code: e }), r && Object.assign(o, r), o.shortMessage == null && We(o, { shortMessage: n }), o;
479
504
  }
480
505
  function Cr(t, e, r, n) {
481
506
  if (!t)
@@ -500,23 +525,23 @@ function xr(t, e, r) {
500
525
  return t;
501
526
  if (typeof t == "string" && t.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)) {
502
527
  const n = new Uint8Array((t.length - 2) / 2);
503
- let s = 2;
504
- for (let o = 0; o < n.length; o++)
505
- n[o] = parseInt(t.substring(s, s + 2), 16), s += 2;
528
+ let o = 2;
529
+ for (let s = 0; s < n.length; s++)
530
+ n[s] = parseInt(t.substring(o, o + 2), 16), o += 2;
506
531
  return n;
507
532
  }
508
533
  Y(!1, "invalid BytesLike value", e || "value", t);
509
534
  }
510
- function Se(t, e) {
535
+ function $e(t, e) {
511
536
  return xr(t, e);
512
537
  }
513
538
  const Ye = "0123456789abcdef";
514
539
  function vr(t) {
515
- const e = Se(t);
540
+ const e = $e(t);
516
541
  let r = "0x";
517
542
  for (let n = 0; n < e.length; n++) {
518
- const s = e[n];
519
- r += Ye[(s & 240) >> 4] + Ye[s & 15];
543
+ const o = e[n];
544
+ r += Ye[(o & 240) >> 4] + Ye[o & 15];
520
545
  }
521
546
  return r;
522
547
  }
@@ -528,7 +553,7 @@ function Ve(t) {
528
553
  if (!Number.isSafeInteger(t) || t < 0)
529
554
  throw new Error("positive integer expected, got " + t);
530
555
  }
531
- function se(t, ...e) {
556
+ function oe(t, ...e) {
532
557
  if (!kr(t))
533
558
  throw new Error("Uint8Array expected");
534
559
  if (e.length > 0 && !e.includes(t.length))
@@ -541,7 +566,7 @@ function qe(t, e = !0) {
541
566
  throw new Error("Hash#digest() has already been called");
542
567
  }
543
568
  function Er(t, e) {
544
- se(t);
569
+ oe(t);
545
570
  const r = e.outputLen;
546
571
  if (t.length < r)
547
572
  throw new Error("digestInto() expects output buffer of length at least " + r);
@@ -557,19 +582,19 @@ const Ar = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
557
582
  function Ir(t) {
558
583
  return t << 24 & 4278190080 | t << 8 & 16711680 | t >>> 8 & 65280 | t >>> 24 & 255;
559
584
  }
560
- function $r(t) {
585
+ function Sr(t) {
561
586
  for (let e = 0; e < t.length; e++)
562
587
  t[e] = Ir(t[e]);
563
588
  return t;
564
589
  }
565
- const Ze = Ar ? (t) => t : $r;
566
- function Sr(t) {
590
+ const Ze = Ar ? (t) => t : Sr;
591
+ function $r(t) {
567
592
  if (typeof t != "string")
568
593
  throw new Error("string expected");
569
594
  return new Uint8Array(new TextEncoder().encode(t));
570
595
  }
571
596
  function gt(t) {
572
- return typeof t == "string" && (t = Sr(t)), se(t), t;
597
+ return typeof t == "string" && (t = $r(t)), oe(t), t;
573
598
  }
574
599
  class Lr {
575
600
  }
@@ -583,20 +608,20 @@ function Br(t, e = !1) {
583
608
  }
584
609
  function Pr(t, e = !1) {
585
610
  const r = t.length;
586
- let n = new Uint32Array(r), s = new Uint32Array(r);
587
- for (let o = 0; o < r; o++) {
588
- const { h: a, l: i } = Br(t[o], e);
589
- [n[o], s[o]] = [a, i];
611
+ let n = new Uint32Array(r), o = new Uint32Array(r);
612
+ for (let s = 0; s < r; s++) {
613
+ const { h: a, l: i } = Br(t[s], e);
614
+ [n[s], o[s]] = [a, i];
590
615
  }
591
- return [n, s];
616
+ return [n, o];
592
617
  }
593
618
  const Tr = (t, e, r) => t << r | e >>> 32 - r, Rr = (t, e, r) => e << r | t >>> 32 - r, Ur = (t, e, r) => e << r - 32 | t >>> 64 - r, Mr = (t, e, r) => t << r - 32 | e >>> 64 - r, zr = BigInt(0), W = BigInt(1), Or = BigInt(2), Dr = BigInt(7), Fr = BigInt(256), Qr = BigInt(113), mt = [], wt = [], yt = [];
594
619
  for (let t = 0, e = W, r = 1, n = 0; t < 24; t++) {
595
620
  [r, n] = [n, (2 * r + 3 * n) % 5], mt.push(2 * (5 * n + r)), wt.push((t + 1) * (t + 2) / 2 % 64);
596
- let s = zr;
597
- for (let o = 0; o < 7; o++)
598
- e = (e << W ^ (e >> Dr) * Qr) % Fr, e & Or && (s ^= W << (W << /* @__PURE__ */ BigInt(o)) - W);
599
- yt.push(s);
621
+ let o = zr;
622
+ for (let s = 0; s < 7; s++)
623
+ e = (e << W ^ (e >> Dr) * Qr) % Fr, e & Or && (o ^= W << (W << /* @__PURE__ */ BigInt(s)) - W);
624
+ yt.push(o);
600
625
  }
601
626
  const bt = Pr(yt, !0), Hr = bt[0], jr = bt[1], Ge = (t, e, r) => r > 32 ? Ur(t, e, r) : Tr(t, e, r), Xe = (t, e, r) => r > 32 ? Mr(t, e, r) : Rr(t, e, r);
602
627
  function Wr(t, e = 24) {
@@ -609,10 +634,10 @@ function Wr(t, e = 24) {
609
634
  for (let u = 0; u < 50; u += 10)
610
635
  t[a + u] ^= h, t[a + u + 1] ^= f;
611
636
  }
612
- let s = t[2], o = t[3];
637
+ let o = t[2], s = t[3];
613
638
  for (let a = 0; a < 24; a++) {
614
- const i = wt[a], l = Ge(s, o, i), c = Xe(s, o, i), d = mt[a];
615
- s = t[d], o = t[d + 1], t[d] = l, t[d + 1] = c;
639
+ const i = wt[a], l = Ge(o, s, i), c = Xe(o, s, i), d = mt[a];
640
+ o = t[d], s = t[d + 1], t[d] = l, t[d + 1] = c;
616
641
  }
617
642
  for (let a = 0; a < 50; a += 10) {
618
643
  for (let i = 0; i < 10; i++)
@@ -626,8 +651,8 @@ function Wr(t, e = 24) {
626
651
  }
627
652
  class Le extends Lr {
628
653
  // NOTE: we accept arguments in bytes instead of bits here.
629
- constructor(e, r, n, s = !1, o = 24) {
630
- if (super(), this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, this.enableXOF = !1, this.blockLen = e, this.suffix = r, this.outputLen = n, this.enableXOF = s, this.rounds = o, Ve(n), !(0 < e && e < 200))
654
+ constructor(e, r, n, o = !1, s = 24) {
655
+ if (super(), this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, this.enableXOF = !1, this.blockLen = e, this.suffix = r, this.outputLen = n, this.enableXOF = o, this.rounds = s, Ve(n), !(0 < e && e < 200))
631
656
  throw new Error("only keccak-f1600 function is supported");
632
657
  this.state = new Uint8Array(200), this.state32 = _r(this.state);
633
658
  }
@@ -638,12 +663,12 @@ class Le extends Lr {
638
663
  Ze(this.state32), Wr(this.state32, this.rounds), Ze(this.state32), this.posOut = 0, this.pos = 0;
639
664
  }
640
665
  update(e) {
641
- qe(this), e = gt(e), se(e);
642
- const { blockLen: r, state: n } = this, s = e.length;
643
- for (let o = 0; o < s; ) {
644
- const a = Math.min(r - this.pos, s - o);
666
+ qe(this), e = gt(e), oe(e);
667
+ const { blockLen: r, state: n } = this, o = e.length;
668
+ for (let s = 0; s < o; ) {
669
+ const a = Math.min(r - this.pos, o - s);
645
670
  for (let i = 0; i < a; i++)
646
- n[this.pos++] ^= e[o++];
671
+ n[this.pos++] ^= e[s++];
647
672
  this.pos === r && this.keccak();
648
673
  }
649
674
  return this;
@@ -652,16 +677,16 @@ class Le extends Lr {
652
677
  if (this.finished)
653
678
  return;
654
679
  this.finished = !0;
655
- const { state: e, suffix: r, pos: n, blockLen: s } = this;
656
- e[n] ^= r, (r & 128) !== 0 && n === s - 1 && this.keccak(), e[s - 1] ^= 128, this.keccak();
680
+ const { state: e, suffix: r, pos: n, blockLen: o } = this;
681
+ e[n] ^= r, (r & 128) !== 0 && n === o - 1 && this.keccak(), e[o - 1] ^= 128, this.keccak();
657
682
  }
658
683
  writeInto(e) {
659
- qe(this, !1), se(e), this.finish();
684
+ qe(this, !1), oe(e), this.finish();
660
685
  const r = this.state, { blockLen: n } = this;
661
- for (let s = 0, o = e.length; s < o; ) {
686
+ for (let o = 0, s = e.length; o < s; ) {
662
687
  this.posOut >= n && this.keccak();
663
- const a = Math.min(n - this.posOut, o - s);
664
- e.set(r.subarray(this.posOut, this.posOut + a), s), this.posOut += a, s += a;
688
+ const a = Math.min(n - this.posOut, s - o);
689
+ e.set(r.subarray(this.posOut, this.posOut + a), o), this.posOut += a, o += a;
665
690
  }
666
691
  return e;
667
692
  }
@@ -685,8 +710,8 @@ class Le extends Lr {
685
710
  this.destroyed = !0, pt(this.state);
686
711
  }
687
712
  _cloneInto(e) {
688
- const { blockLen: r, suffix: n, outputLen: s, rounds: o, enableXOF: a } = this;
689
- return e || (e = new Le(r, n, s, a, o)), e.state32.set(this.state32), e.pos = this.pos, e.posOut = this.posOut, e.finished = this.finished, e.rounds = o, e.suffix = n, e.outputLen = s, e.enableXOF = a, e.destroyed = this.destroyed, e;
713
+ const { blockLen: r, suffix: n, outputLen: o, rounds: s, enableXOF: a } = this;
714
+ return e || (e = new Le(r, n, o, a, s)), e.state32.set(this.state32), e.pos = this.pos, e.posOut = this.posOut, e.finished = this.finished, e.rounds = s, e.suffix = n, e.outputLen = o, e.enableXOF = a, e.destroyed = this.destroyed, e;
690
715
  }
691
716
  }
692
717
  const Yr = (t, e, r) => Nr(() => new Le(e, t, r)), Vr = Yr(1, 136, 256 / 8);
@@ -696,7 +721,7 @@ const xt = function(t) {
696
721
  };
697
722
  let vt = xt;
698
723
  function X(t) {
699
- const e = Se(t, "data");
724
+ const e = $e(t, "data");
700
725
  return vr(vt(e));
701
726
  }
702
727
  X._ = xt;
@@ -713,11 +738,11 @@ const qr = BigInt(0), Zr = BigInt(36);
713
738
  function Je(t) {
714
739
  t = t.toLowerCase();
715
740
  const e = t.substring(2).split(""), r = new Uint8Array(40);
716
- for (let s = 0; s < 40; s++)
717
- r[s] = e[s].charCodeAt(0);
718
- const n = Se(X(r));
719
- for (let s = 0; s < 40; s += 2)
720
- n[s >> 1] >> 4 >= 8 && (e[s] = e[s].toUpperCase()), (n[s >> 1] & 15) >= 8 && (e[s + 1] = e[s + 1].toUpperCase());
741
+ for (let o = 0; o < 40; o++)
742
+ r[o] = e[o].charCodeAt(0);
743
+ const n = $e(X(r));
744
+ for (let o = 0; o < 40; o += 2)
745
+ n[o >> 1] >> 4 >= 8 && (e[o] = e[o].toUpperCase()), (n[o >> 1] & 15) >= 8 && (e[o + 1] = e[o + 1].toUpperCase());
721
746
  return "0x" + e.join("");
722
747
  }
723
748
  const Ne = {};
@@ -911,8 +936,8 @@ function en(t) {
911
936
  function tn() {
912
937
  const t = /* @__PURE__ */ new Set();
913
938
  let e = [];
914
- const r = () => en((s) => {
915
- e.some(({ info: o }) => o.uuid === s.info.uuid) || (e = [...e, s], t.forEach((o) => o(e, { added: [s] })));
939
+ const r = () => en((o) => {
940
+ e.some(({ info: s }) => s.uuid === o.info.uuid) || (e = [...e, o], t.forEach((s) => s(e, { added: [o] })));
916
941
  });
917
942
  let n = r();
918
943
  return {
@@ -920,13 +945,13 @@ function tn() {
920
945
  return t;
921
946
  },
922
947
  clear() {
923
- t.forEach((s) => s([], { removed: [...e] })), e = [];
948
+ t.forEach((o) => o([], { removed: [...e] })), e = [];
924
949
  },
925
950
  destroy() {
926
951
  this.clear(), t.clear(), n?.();
927
952
  },
928
- findProvider({ rdns: s }) {
929
- return e.find((o) => o.info.rdns === s);
953
+ findProvider({ rdns: o }) {
954
+ return e.find((s) => s.info.rdns === o);
930
955
  },
931
956
  getProviders() {
932
957
  return e;
@@ -934,8 +959,8 @@ function tn() {
934
959
  reset() {
935
960
  this.clear(), n?.(), n = r();
936
961
  },
937
- subscribe(s, { emitImmediately: o } = {}) {
938
- return t.add(s), o && s(e, { added: e }), () => t.delete(s);
962
+ subscribe(o, { emitImmediately: s } = {}) {
963
+ return t.add(o), s && o(e, { added: e }), () => t.delete(o);
939
964
  }
940
965
  };
941
966
  }
@@ -1029,11 +1054,11 @@ class de {
1029
1054
  const n = this.getProvider();
1030
1055
  if (n ? r = n.provider : this.rdns === "io.metamask" && window.ethereum?.isMetaMask && (r = window.ethereum), !r)
1031
1056
  throw new Error(`${this.displayName} provider not found`);
1032
- const s = await r.request({
1057
+ const o = await r.request({
1033
1058
  method: "eth_requestAccounts"
1034
1059
  });
1035
- if (s && s.length > 0)
1036
- return this.account = P(s[0]), this.connectedAccounts = s.map(P), !n && this.rdns === "io.metamask" && (this.provider = {
1060
+ if (o && o.length > 0)
1061
+ return this.account = P(o[0]), this.connectedAccounts = o.map(P), !n && this.rdns === "io.metamask" && (this.provider = {
1037
1062
  info: {
1038
1063
  uuid: "metamask-fallback",
1039
1064
  name: "MetaMask",
@@ -1081,11 +1106,11 @@ class de {
1081
1106
  const n = this.getEthereumProvider();
1082
1107
  if (!n)
1083
1108
  throw new Error(`${this.displayName} provider not found`);
1084
- const s = await n.request({
1109
+ const o = await n.request({
1085
1110
  method: "personal_sign",
1086
1111
  params: [e, r || this.account]
1087
1112
  });
1088
- return { success: !0, wallet: this.type, result: s };
1113
+ return { success: !0, wallet: this.type, result: o };
1089
1114
  } catch (n) {
1090
1115
  return console.error(`Error signing message with ${this.displayName}:`, n), {
1091
1116
  success: !1,
@@ -1194,8 +1219,8 @@ class de {
1194
1219
  const n = this.getEthereumProvider();
1195
1220
  if (!n)
1196
1221
  throw new Error(`${this.displayName} is not connected`);
1197
- const s = Date.now(), o = 1e3;
1198
- for (; Date.now() - s < r; ) {
1222
+ const o = Date.now(), s = 1e3;
1223
+ for (; Date.now() - o < r; ) {
1199
1224
  const a = await n.request({
1200
1225
  method: "eth_getTransactionReceipt",
1201
1226
  params: [e]
@@ -1206,7 +1231,7 @@ class de {
1206
1231
  wallet: this.type,
1207
1232
  result: a
1208
1233
  };
1209
- await new Promise((i) => setTimeout(i, o));
1234
+ await new Promise((i) => setTimeout(i, s));
1210
1235
  }
1211
1236
  throw new Error("Transaction confirmation timed out");
1212
1237
  } catch (n) {
@@ -1226,7 +1251,7 @@ class nn extends de {
1226
1251
  rdns = "com.coinbase.wallet";
1227
1252
  displayName = "Base Wallet";
1228
1253
  }
1229
- class sn extends de {
1254
+ class on extends de {
1230
1255
  type = "metamask";
1231
1256
  rdns = "io.metamask";
1232
1257
  displayName = "MetaMask";
@@ -1244,7 +1269,7 @@ function kt(t, ...e) {
1244
1269
  function Et(t, e) {
1245
1270
  return Array.isArray(e) ? e.length === 0 ? !0 : t ? e.every((r) => typeof r == "string") : e.every((r) => Number.isSafeInteger(r)) : !1;
1246
1271
  }
1247
- function on(t) {
1272
+ function sn(t) {
1248
1273
  if (typeof t != "function")
1249
1274
  throw new Error("function expected");
1250
1275
  return !0;
@@ -1258,7 +1283,7 @@ function J(t) {
1258
1283
  if (!Number.isSafeInteger(t))
1259
1284
  throw new Error(`invalid integer: ${t}`);
1260
1285
  }
1261
- function oe(t) {
1286
+ function se(t) {
1262
1287
  if (!Array.isArray(t))
1263
1288
  throw new Error("array expected");
1264
1289
  }
@@ -1272,25 +1297,25 @@ function _t(t, e) {
1272
1297
  }
1273
1298
  // @__NO_SIDE_EFFECTS__
1274
1299
  function Pe(...t) {
1275
- const e = (o) => o, r = (o, a) => (i) => o(a(i)), n = t.map((o) => o.encode).reduceRight(r, e), s = t.map((o) => o.decode).reduce(r, e);
1276
- return { encode: n, decode: s };
1300
+ const e = (s) => s, r = (s, a) => (i) => s(a(i)), n = t.map((s) => s.encode).reduceRight(r, e), o = t.map((s) => s.decode).reduce(r, e);
1301
+ return { encode: n, decode: o };
1277
1302
  }
1278
1303
  // @__NO_SIDE_EFFECTS__
1279
1304
  function Te(t) {
1280
1305
  const e = typeof t == "string" ? t.split("") : t, r = e.length;
1281
1306
  ae("alphabet", e);
1282
- const n = new Map(e.map((s, o) => [s, o]));
1307
+ const n = new Map(e.map((o, s) => [o, s]));
1283
1308
  return {
1284
- encode: (s) => (oe(s), s.map((o) => {
1285
- if (!Number.isSafeInteger(o) || o < 0 || o >= r)
1286
- throw new Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${t}`);
1287
- return e[o];
1309
+ encode: (o) => (se(o), o.map((s) => {
1310
+ if (!Number.isSafeInteger(s) || s < 0 || s >= r)
1311
+ throw new Error(`alphabet.encode: digit index outside alphabet "${s}". Allowed: ${t}`);
1312
+ return e[s];
1288
1313
  })),
1289
- decode: (s) => (oe(s), s.map((o) => {
1290
- j("alphabet.decode", o);
1291
- const a = n.get(o);
1314
+ decode: (o) => (se(o), o.map((s) => {
1315
+ j("alphabet.decode", s);
1316
+ const a = n.get(s);
1292
1317
  if (a === void 0)
1293
- throw new Error(`Unknown letter: "${o}". Allowed: ${t}`);
1318
+ throw new Error(`Unknown letter: "${s}". Allowed: ${t}`);
1294
1319
  return a;
1295
1320
  }))
1296
1321
  };
@@ -1324,42 +1349,42 @@ function an(t, e = "=") {
1324
1349
  }
1325
1350
  // @__NO_SIDE_EFFECTS__
1326
1351
  function cn(t) {
1327
- return on(t), { encode: (e) => e, decode: (e) => t(e) };
1352
+ return sn(t), { encode: (e) => e, decode: (e) => t(e) };
1328
1353
  }
1329
1354
  function tt(t, e, r) {
1330
1355
  if (e < 2)
1331
1356
  throw new Error(`convertRadix: invalid from=${e}, base cannot be less than 2`);
1332
1357
  if (r < 2)
1333
1358
  throw new Error(`convertRadix: invalid to=${r}, base cannot be less than 2`);
1334
- if (oe(t), !t.length)
1359
+ if (se(t), !t.length)
1335
1360
  return [];
1336
1361
  let n = 0;
1337
- const s = [], o = Array.from(t, (i) => {
1362
+ const o = [], s = Array.from(t, (i) => {
1338
1363
  if (J(i), i < 0 || i >= e)
1339
1364
  throw new Error(`invalid integer: ${i}`);
1340
1365
  return i;
1341
- }), a = o.length;
1366
+ }), a = s.length;
1342
1367
  for (; ; ) {
1343
1368
  let i = 0, l = !0;
1344
1369
  for (let c = n; c < a; c++) {
1345
- const d = o[c], h = e * i, f = h + d;
1370
+ const d = s[c], h = e * i, f = h + d;
1346
1371
  if (!Number.isSafeInteger(f) || h / e !== i || f - d !== h)
1347
1372
  throw new Error("convertRadix: carry overflow");
1348
1373
  const u = f / r;
1349
1374
  i = f % r;
1350
- const p = Math.floor(u);
1351
- if (o[c] = p, !Number.isSafeInteger(p) || p * r + i !== f)
1375
+ const g = Math.floor(u);
1376
+ if (s[c] = g, !Number.isSafeInteger(g) || g * r + i !== f)
1352
1377
  throw new Error("convertRadix: carry overflow");
1353
1378
  if (l)
1354
- p ? l = !1 : n = c;
1379
+ g ? l = !1 : n = c;
1355
1380
  else continue;
1356
1381
  }
1357
- if (s.push(i), l)
1382
+ if (o.push(i), l)
1358
1383
  break;
1359
1384
  }
1360
1385
  for (let i = 0; i < t.length - 1 && t[i] === 0; i++)
1361
- s.push(0);
1362
- return s.reverse();
1386
+ o.push(0);
1387
+ return o.reverse();
1363
1388
  }
1364
1389
  const At = (t, e) => e === 0 ? t : At(e, t % e), ie = /* @__NO_SIDE_EFFECTS__ */ (t, e) => t + (e - At(t, e)), me = /* @__PURE__ */ (() => {
1365
1390
  let t = [];
@@ -1368,31 +1393,31 @@ const At = (t, e) => e === 0 ? t : At(e, t % e), ie = /* @__NO_SIDE_EFFECTS__ */
1368
1393
  return t;
1369
1394
  })();
1370
1395
  function rt(t, e, r, n) {
1371
- if (oe(t), e <= 0 || e > 32)
1396
+ if (se(t), e <= 0 || e > 32)
1372
1397
  throw new Error(`convertRadix2: wrong from=${e}`);
1373
1398
  if (r <= 0 || r > 32)
1374
1399
  throw new Error(`convertRadix2: wrong to=${r}`);
1375
1400
  if (/* @__PURE__ */ ie(e, r) > 32)
1376
1401
  throw new Error(`convertRadix2: carry overflow from=${e} to=${r} carryBits=${/* @__PURE__ */ ie(e, r)}`);
1377
- let s = 0, o = 0;
1402
+ let o = 0, s = 0;
1378
1403
  const a = me[e], i = me[r] - 1, l = [];
1379
1404
  for (const c of t) {
1380
1405
  if (J(c), c >= a)
1381
1406
  throw new Error(`convertRadix2: invalid data word=${c} from=${e}`);
1382
- if (s = s << e | c, o + e > 32)
1383
- throw new Error(`convertRadix2: carry overflow pos=${o} from=${e}`);
1384
- for (o += e; o >= r; o -= r)
1385
- l.push((s >> o - r & i) >>> 0);
1386
- const d = me[o];
1407
+ if (o = o << e | c, s + e > 32)
1408
+ throw new Error(`convertRadix2: carry overflow pos=${s} from=${e}`);
1409
+ for (s += e; s >= r; s -= r)
1410
+ l.push((o >> s - r & i) >>> 0);
1411
+ const d = me[s];
1387
1412
  if (d === void 0)
1388
1413
  throw new Error("invalid carry");
1389
- s &= d - 1;
1414
+ o &= d - 1;
1390
1415
  }
1391
- if (s = s << r - o & i, !n && o >= e)
1416
+ if (o = o << r - s & i, !n && s >= e)
1392
1417
  throw new Error("Excess padding");
1393
- if (!n && s > 0)
1394
- throw new Error(`Non-zero padding: ${s}`);
1395
- return n && o > 0 && l.push(s >>> 0), l;
1418
+ if (!n && o > 0)
1419
+ throw new Error(`Non-zero padding: ${o}`);
1420
+ return n && s > 0 && l.push(o >>> 0), l;
1396
1421
  }
1397
1422
  // @__NO_SIDE_EFFECTS__
1398
1423
  function ln(t) {
@@ -1452,47 +1477,47 @@ function Ee(t, e) {
1452
1477
  return !1;
1453
1478
  return !0;
1454
1479
  }
1455
- function T(t) {
1480
+ function R(t) {
1456
1481
  return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
1457
1482
  }
1458
- const $t = (t) => new DataView(t.buffer, t.byteOffset, t.byteLength);
1459
- function D(t) {
1483
+ const St = (t) => new DataView(t.buffer, t.byteOffset, t.byteLength);
1484
+ function F(t) {
1460
1485
  return Object.prototype.toString.call(t) === "[object Object]";
1461
1486
  }
1462
1487
  function N(t) {
1463
1488
  return Number.isSafeInteger(t);
1464
1489
  }
1465
- const St = (t) => {
1466
- if (t !== null && typeof t != "string" && !S(t) && !T(t) && !N(t))
1490
+ const $t = (t) => {
1491
+ if (t !== null && typeof t != "string" && !$(t) && !R(t) && !N(t))
1467
1492
  throw new Error(`lengthCoder: expected null | number | Uint8Array | CoderType, got ${t} (${typeof t})`);
1468
1493
  return {
1469
1494
  encodeStream(e, r) {
1470
1495
  if (t === null)
1471
1496
  return;
1472
- if (S(t))
1497
+ if ($(t))
1473
1498
  return t.encodeStream(e, r);
1474
1499
  let n;
1475
- if (typeof t == "number" ? n = t : typeof t == "string" && (n = O.resolve(e.stack, t)), typeof n == "bigint" && (n = Number(n)), n === void 0 || n !== r)
1500
+ if (typeof t == "number" ? n = t : typeof t == "string" && (n = D.resolve(e.stack, t)), typeof n == "bigint" && (n = Number(n)), n === void 0 || n !== r)
1476
1501
  throw e.err(`Wrong length: ${n} len=${t} exp=${r} (${typeof r})`);
1477
1502
  },
1478
1503
  decodeStream(e) {
1479
1504
  let r;
1480
- if (S(t) ? r = Number(t.decodeStream(e)) : typeof t == "number" ? r = t : typeof t == "string" && (r = O.resolve(e.stack, t)), typeof r == "bigint" && (r = Number(r)), typeof r != "number")
1505
+ if ($(t) ? r = Number(t.decodeStream(e)) : typeof t == "number" ? r = t : typeof t == "string" && (r = D.resolve(e.stack, t)), typeof r == "bigint" && (r = Number(r)), typeof r != "number")
1481
1506
  throw e.err(`Wrong length: ${r}`);
1482
1507
  return r;
1483
1508
  }
1484
1509
  };
1485
- }, k = {
1510
+ }, E = {
1486
1511
  BITS: 32,
1487
1512
  FULL_MASK: -1 >>> 0,
1488
1513
  // 1<<32 will overflow
1489
1514
  len: (t) => Math.ceil(t / 32),
1490
- create: (t) => new Uint32Array(k.len(t)),
1515
+ create: (t) => new Uint32Array(E.len(t)),
1491
1516
  clean: (t) => t.fill(0),
1492
1517
  debug: (t) => Array.from(t).map((e) => (e >>> 0).toString(2).padStart(32, "0")),
1493
1518
  checkLen: (t, e) => {
1494
- if (k.len(e) !== t.length)
1495
- throw new Error(`wrong length=${t.length}. Expected: ${k.len(e)}`);
1519
+ if (E.len(e) !== t.length)
1520
+ throw new Error(`wrong length=${t.length}. Expected: ${E.len(e)}`);
1496
1521
  },
1497
1522
  chunkLen: (t, e, r) => {
1498
1523
  if (e < 0)
@@ -1506,14 +1531,14 @@ const St = (t) => {
1506
1531
  mask: 1 << 32 - (t + e) % 32 - 1
1507
1532
  }),
1508
1533
  indices: (t, e, r = !1) => {
1509
- k.checkLen(t, e);
1510
- const { FULL_MASK: n, BITS: s } = k, o = s - e % s, a = o ? n >>> o << o : n, i = [];
1534
+ E.checkLen(t, e);
1535
+ const { FULL_MASK: n, BITS: o } = E, s = o - e % o, a = s ? n >>> s << s : n, i = [];
1511
1536
  for (let l = 0; l < t.length; l++) {
1512
1537
  let c = t[l];
1513
1538
  if (r && (c = ~c), l === t.length - 1 && (c &= a), c !== 0)
1514
- for (let d = 0; d < s; d++) {
1515
- const h = 1 << s - d - 1;
1516
- c & h && i.push(l * s + d);
1539
+ for (let d = 0; d < o; d++) {
1540
+ const h = 1 << o - d - 1;
1541
+ c & h && i.push(l * o + d);
1517
1542
  }
1518
1543
  }
1519
1544
  return i;
@@ -1525,21 +1550,21 @@ const St = (t) => {
1525
1550
  r === void 0 || n !== r.pos + r.length ? e.push(r = { pos: n, length: 1 }) : r.length += 1;
1526
1551
  return e;
1527
1552
  },
1528
- rangeDebug: (t, e, r = !1) => `[${k.range(k.indices(t, e, r)).map((n) => `(${n.pos}/${n.length})`).join(", ")}]`,
1529
- setRange: (t, e, r, n, s = !0) => {
1530
- k.chunkLen(e, r, n);
1531
- const { FULL_MASK: o, BITS: a } = k, i = r % a ? Math.floor(r / a) : void 0, l = r + n, c = l % a ? Math.floor(l / a) : void 0;
1553
+ rangeDebug: (t, e, r = !1) => `[${E.range(E.indices(t, e, r)).map((n) => `(${n.pos}/${n.length})`).join(", ")}]`,
1554
+ setRange: (t, e, r, n, o = !0) => {
1555
+ E.chunkLen(e, r, n);
1556
+ const { FULL_MASK: s, BITS: a } = E, i = r % a ? Math.floor(r / a) : void 0, l = r + n, c = l % a ? Math.floor(l / a) : void 0;
1532
1557
  if (i !== void 0 && i === c)
1533
- return k.set(t, i, o >>> a - n << a - n - r, s);
1534
- if (i !== void 0 && !k.set(t, i, o >>> r % a, s))
1558
+ return E.set(t, i, s >>> a - n << a - n - r, o);
1559
+ if (i !== void 0 && !E.set(t, i, s >>> r % a, o))
1535
1560
  return !1;
1536
1561
  const d = i !== void 0 ? i + 1 : r / a, h = c !== void 0 ? c : l / a;
1537
1562
  for (let f = d; f < h; f++)
1538
- if (!k.set(t, f, o, s))
1563
+ if (!E.set(t, f, s, o))
1539
1564
  return !1;
1540
- return !(c !== void 0 && i !== c && !k.set(t, c, o << a - l % a, s));
1565
+ return !(c !== void 0 && i !== c && !E.set(t, c, s << a - l % a, o));
1541
1566
  }
1542
- }, O = {
1567
+ }, D = {
1543
1568
  /**
1544
1569
  * Internal method for handling stack of paths (debug, errors, dynamic fields via path)
1545
1570
  * This is looks ugly (callback), but allows us to force stack cleaning by construction (.pop always after function).
@@ -1550,8 +1575,8 @@ const St = (t) => {
1550
1575
  */
1551
1576
  pushObj: (t, e, r) => {
1552
1577
  const n = { obj: e };
1553
- t.push(n), r((s, o) => {
1554
- n.field = s, o(), n.field = void 0;
1578
+ t.push(n), r((o, s) => {
1579
+ n.field = o, s(), n.field = void 0;
1555
1580
  }), t.pop();
1556
1581
  },
1557
1582
  path: (t) => {
@@ -1561,35 +1586,35 @@ const St = (t) => {
1561
1586
  return e.join("/");
1562
1587
  },
1563
1588
  err: (t, e, r) => {
1564
- const n = new Error(`${t}(${O.path(e)}): ${typeof r == "string" ? r : r.message}`);
1589
+ const n = new Error(`${t}(${D.path(e)}): ${typeof r == "string" ? r : r.message}`);
1565
1590
  return r instanceof Error && r.stack && (n.stack = r.stack), n;
1566
1591
  },
1567
1592
  resolve: (t, e) => {
1568
1593
  const r = e.split("/"), n = t.map((a) => a.obj);
1569
- let s = 0;
1570
- for (; s < r.length && r[s] === ".."; s++)
1594
+ let o = 0;
1595
+ for (; o < r.length && r[o] === ".."; o++)
1571
1596
  n.pop();
1572
- let o = n.pop();
1573
- for (; s < r.length; s++) {
1574
- if (!o || o[r[s]] === void 0)
1597
+ let s = n.pop();
1598
+ for (; o < r.length; o++) {
1599
+ if (!s || s[r[o]] === void 0)
1575
1600
  return;
1576
- o = o[r[s]];
1601
+ s = s[r[o]];
1577
1602
  }
1578
- return o;
1603
+ return s;
1579
1604
  }
1580
1605
  };
1581
1606
  class Ue {
1582
- constructor(e, r = {}, n = [], s = void 0, o = 0) {
1583
- this.pos = 0, this.bitBuf = 0, this.bitPos = 0, this.data = e, this.opts = r, this.stack = n, this.parent = s, this.parentOffset = o, this.view = $t(e);
1607
+ constructor(e, r = {}, n = [], o = void 0, s = 0) {
1608
+ this.pos = 0, this.bitBuf = 0, this.bitPos = 0, this.data = e, this.opts = r, this.stack = n, this.parent = o, this.parentOffset = s, this.view = St(e);
1584
1609
  }
1585
1610
  /** Internal method for pointers. */
1586
1611
  _enablePointers() {
1587
1612
  if (this.parent)
1588
1613
  return this.parent._enablePointers();
1589
- this.bs || (this.bs = k.create(this.data.length), k.setRange(this.bs, this.data.length, 0, this.pos, this.opts.allowMultipleReads));
1614
+ this.bs || (this.bs = E.create(this.data.length), E.setRange(this.bs, this.data.length, 0, this.pos, this.opts.allowMultipleReads));
1590
1615
  }
1591
1616
  markBytesBS(e, r) {
1592
- return this.parent ? this.parent.markBytesBS(this.parentOffset + e, r) : !r || !this.bs ? !0 : k.setRange(this.bs, this.data.length, e, r, !1);
1617
+ return this.parent ? this.parent.markBytesBS(this.parentOffset + e, r) : !r || !this.bs ? !0 : E.setRange(this.bs, this.data.length, e, r, !1);
1593
1618
  }
1594
1619
  markBytes(e) {
1595
1620
  const r = this.pos;
@@ -1600,7 +1625,7 @@ class Ue {
1600
1625
  return n;
1601
1626
  }
1602
1627
  pushObj(e, r) {
1603
- return O.pushObj(this.stack, e, r);
1628
+ return D.pushObj(this.stack, e, r);
1604
1629
  }
1605
1630
  readView(e, r) {
1606
1631
  if (!Number.isFinite(e))
@@ -1621,9 +1646,9 @@ class Ue {
1621
1646
  if (this.bitPos)
1622
1647
  throw this.err(`${this.bitPos} bits left after unpack: ${we.encode(this.data.slice(this.pos))}`);
1623
1648
  if (this.bs && !this.parent) {
1624
- const e = k.indices(this.bs, this.data.length, !0);
1649
+ const e = E.indices(this.bs, this.data.length, !0);
1625
1650
  if (e.length) {
1626
- const r = k.range(e).map(({ pos: n, length: s }) => `(${n}/${s})[${we.encode(this.data.subarray(n, n + s))}]`).join(", ");
1651
+ const r = E.range(e).map(({ pos: n, length: o }) => `(${n}/${o})[${we.encode(this.data.subarray(n, n + o))}]`).join(", ");
1627
1652
  throw this.err(`unread byte ranges: ${r} (total=${this.data.length})`);
1628
1653
  } else
1629
1654
  return;
@@ -1634,7 +1659,7 @@ class Ue {
1634
1659
  }
1635
1660
  // User methods
1636
1661
  err(e) {
1637
- return O.err("Reader", this.stack, e);
1662
+ return D.err("Reader", this.stack, e);
1638
1663
  }
1639
1664
  offsetReader(e) {
1640
1665
  if (e > this.data.length)
@@ -1681,7 +1706,7 @@ class Ue {
1681
1706
  return r >>> 0;
1682
1707
  }
1683
1708
  find(e, r = this.pos) {
1684
- if (!T(e))
1709
+ if (!R(e))
1685
1710
  throw this.err(`find: needle is not bytes! ${e}`);
1686
1711
  if (this.bitPos)
1687
1712
  throw this.err("findByte: bitPos not empty");
@@ -1697,10 +1722,10 @@ class Ue {
1697
1722
  }
1698
1723
  class mn {
1699
1724
  constructor(e = []) {
1700
- this.pos = 0, this.buffers = [], this.ptrs = [], this.bitBuf = 0, this.bitPos = 0, this.viewBuf = new Uint8Array(8), this.finished = !1, this.stack = e, this.view = $t(this.viewBuf);
1725
+ this.pos = 0, this.buffers = [], this.ptrs = [], this.bitBuf = 0, this.bitPos = 0, this.viewBuf = new Uint8Array(8), this.finished = !1, this.stack = e, this.view = St(this.viewBuf);
1701
1726
  }
1702
1727
  pushObj(e, r) {
1703
- return O.pushObj(this.stack, e, r);
1728
+ return D.pushObj(this.stack, e, r);
1704
1729
  }
1705
1730
  writeView(e, r) {
1706
1731
  if (this.finished)
@@ -1713,7 +1738,7 @@ class mn {
1713
1738
  err(e) {
1714
1739
  if (this.finished)
1715
1740
  throw this.err("buffer: finished");
1716
- return O.err("Reader", this.stack, e);
1741
+ return D.err("Reader", this.stack, e);
1717
1742
  }
1718
1743
  bytes(e) {
1719
1744
  if (this.finished)
@@ -1734,22 +1759,22 @@ class mn {
1734
1759
  throw this.err("buffer: finished");
1735
1760
  if (this.bitPos)
1736
1761
  throw this.err("buffer: ends with non-empty bit buffer");
1737
- const r = this.buffers.concat(this.ptrs.map((o) => o.buffer)), n = r.map((o) => o.length).reduce((o, a) => o + a, 0), s = new Uint8Array(n);
1738
- for (let o = 0, a = 0; o < r.length; o++) {
1739
- const i = r[o];
1740
- s.set(i, a), a += i.length;
1762
+ const r = this.buffers.concat(this.ptrs.map((s) => s.buffer)), n = r.map((s) => s.length).reduce((s, a) => s + a, 0), o = new Uint8Array(n);
1763
+ for (let s = 0, a = 0; s < r.length; s++) {
1764
+ const i = r[s];
1765
+ o.set(i, a), a += i.length;
1741
1766
  }
1742
- for (let o = this.pos, a = 0; a < this.ptrs.length; a++) {
1767
+ for (let s = this.pos, a = 0; a < this.ptrs.length; a++) {
1743
1768
  const i = this.ptrs[a];
1744
- s.set(i.ptr.encode(o), i.pos), o += i.buffer.length;
1769
+ o.set(i.ptr.encode(s), i.pos), s += i.buffer.length;
1745
1770
  }
1746
1771
  if (e) {
1747
1772
  this.buffers = [];
1748
- for (const o of this.ptrs)
1749
- o.buffer.fill(0);
1773
+ for (const s of this.ptrs)
1774
+ s.buffer.fill(0);
1750
1775
  this.ptrs = [], this.finished = !0, this.bitBuf = 0;
1751
1776
  }
1752
- return s;
1777
+ return o;
1753
1778
  }
1754
1779
  bits(e, r) {
1755
1780
  if (r > 32)
@@ -1782,43 +1807,43 @@ function Lt(t) {
1782
1807
  return t.encodeStream(r, e), r.finish();
1783
1808
  },
1784
1809
  decode: (e, r = {}) => {
1785
- const n = new Ue(e, r), s = t.decodeStream(n);
1786
- return n.finish(), s;
1810
+ const n = new Ue(e, r), o = t.decodeStream(n);
1811
+ return n.finish(), o;
1787
1812
  }
1788
1813
  };
1789
1814
  }
1790
1815
  function Nt(t, e) {
1791
- if (!S(t))
1816
+ if (!$(t))
1792
1817
  throw new Error(`validate: invalid inner value ${t}`);
1793
1818
  if (typeof e != "function")
1794
1819
  throw new Error("validate: fn should be function");
1795
1820
  return Lt({
1796
1821
  size: t.size,
1797
1822
  encodeStream: (r, n) => {
1798
- let s;
1823
+ let o;
1799
1824
  try {
1800
- s = e(n);
1801
- } catch (o) {
1802
- throw r.err(o);
1825
+ o = e(n);
1826
+ } catch (s) {
1827
+ throw r.err(s);
1803
1828
  }
1804
- t.encodeStream(r, s);
1829
+ t.encodeStream(r, o);
1805
1830
  },
1806
1831
  decodeStream: (r) => {
1807
1832
  const n = t.decodeStream(r);
1808
1833
  try {
1809
1834
  return e(n);
1810
- } catch (s) {
1811
- throw r.err(s);
1835
+ } catch (o) {
1836
+ throw r.err(o);
1812
1837
  }
1813
1838
  }
1814
1839
  });
1815
1840
  }
1816
- const A = (t) => {
1841
+ const I = (t) => {
1817
1842
  const e = Lt(t);
1818
1843
  return t.validate ? Nt(e, t.validate) : e;
1819
- }, he = (t) => D(t) && typeof t.decode == "function" && typeof t.encode == "function";
1820
- function S(t) {
1821
- return D(t) && he(t) && typeof t.encodeStream == "function" && typeof t.decodeStream == "function" && (t.size === void 0 || N(t.size));
1844
+ }, he = (t) => F(t) && typeof t.decode == "function" && typeof t.encode == "function";
1845
+ function $(t) {
1846
+ return F(t) && he(t) && typeof t.encodeStream == "function" && typeof t.decodeStream == "function" && (t.size === void 0 || N(t.size));
1822
1847
  }
1823
1848
  function yn() {
1824
1849
  return {
@@ -1829,15 +1854,15 @@ function yn() {
1829
1854
  for (const r of t) {
1830
1855
  if (!Array.isArray(r) || r.length !== 2)
1831
1856
  throw new Error("array of two elements expected");
1832
- const n = r[0], s = r[1];
1857
+ const n = r[0], o = r[1];
1833
1858
  if (e[n] !== void 0)
1834
1859
  throw new Error(`key(${n}) appears twice in struct`);
1835
- e[n] = s;
1860
+ e[n] = o;
1836
1861
  }
1837
1862
  return e;
1838
1863
  },
1839
1864
  decode: (t) => {
1840
- if (!D(t))
1865
+ if (!F(t))
1841
1866
  throw new Error(`expected plain object, got ${t}`);
1842
1867
  return Object.entries(t);
1843
1868
  }
@@ -1858,7 +1883,7 @@ const bn = {
1858
1883
  }
1859
1884
  };
1860
1885
  function Cn(t) {
1861
- if (!D(t))
1886
+ if (!F(t))
1862
1887
  throw new Error("plain object expected");
1863
1888
  return {
1864
1889
  encode: (e) => {
@@ -1883,12 +1908,12 @@ function xn(t, e = !1) {
1883
1908
  encode: (n) => {
1884
1909
  if (typeof n != "bigint")
1885
1910
  throw new Error(`expected bigint, got ${typeof n}`);
1886
- let s = (n < 0n ? -n : n).toString(10), o = s.length - t;
1887
- o < 0 && (s = s.padStart(s.length - o, "0"), o = 0);
1888
- let a = s.length - 1;
1889
- for (; a >= o && s[a] === "0"; a--)
1911
+ let o = (n < 0n ? -n : n).toString(10), s = o.length - t;
1912
+ s < 0 && (o = o.padStart(o.length - s, "0"), s = 0);
1913
+ let a = o.length - 1;
1914
+ for (; a >= s && o[a] === "0"; a--)
1890
1915
  ;
1891
- let i = s.slice(0, o), l = s.slice(o, a + 1);
1916
+ let i = o.slice(0, s), l = o.slice(s, a + 1);
1892
1917
  return i || (i = "0"), n < 0n && (i = "-" + i), l ? `${i}.${l}` : i;
1893
1918
  },
1894
1919
  decode: (n) => {
@@ -1896,16 +1921,16 @@ function xn(t, e = !1) {
1896
1921
  throw new Error(`expected string, got ${typeof n}`);
1897
1922
  if (n === "-0")
1898
1923
  throw new Error("negative zero is not allowed");
1899
- let s = !1;
1900
- if (n.startsWith("-") && (s = !0, n = n.slice(1)), !/^(0|[1-9]\d*)(\.\d+)?$/.test(n))
1924
+ let o = !1;
1925
+ if (n.startsWith("-") && (o = !0, n = n.slice(1)), !/^(0|[1-9]\d*)(\.\d+)?$/.test(n))
1901
1926
  throw new Error(`wrong string value=${n}`);
1902
- let o = n.indexOf(".");
1903
- o = o === -1 ? n.length : o;
1904
- const a = n.slice(0, o), i = n.slice(o + 1).replace(/0+$/, ""), l = BigInt(a) * r;
1927
+ let s = n.indexOf(".");
1928
+ s = s === -1 ? n.length : s;
1929
+ const a = n.slice(0, s), i = n.slice(s + 1).replace(/0+$/, ""), l = BigInt(a) * r;
1905
1930
  if (!e && i.length > t)
1906
1931
  throw new Error(`fractional part cannot be represented with this precision (num=${n}, prec=${t})`);
1907
1932
  const c = Math.min(i.length, t), d = BigInt(i.slice(0, c)) * 10n ** BigInt(t - c), h = l + d;
1908
- return s ? -h : h;
1933
+ return o ? -h : h;
1909
1934
  }
1910
1935
  };
1911
1936
  }
@@ -1947,11 +1972,11 @@ const kn = (t) => {
1947
1972
  throw new Error(`bigint/signed: expected boolean, got ${typeof r}`);
1948
1973
  if (typeof n != "boolean")
1949
1974
  throw new Error(`bigint/sized: expected boolean, got ${typeof n}`);
1950
- const s = BigInt(t), o = 2n ** (8n * s - 1n);
1951
- return A({
1975
+ const o = BigInt(t), s = 2n ** (8n * o - 1n);
1976
+ return I({
1952
1977
  size: n ? t : void 0,
1953
1978
  encodeStream: (a, i) => {
1954
- r && i < 0 && (i = i | o);
1979
+ r && i < 0 && (i = i | s);
1955
1980
  const l = [];
1956
1981
  for (let d = 0; d < t; d++)
1957
1982
  l.push(Number(i & 255n)), i >>= 8n;
@@ -1969,17 +1994,17 @@ const kn = (t) => {
1969
1994
  let c = 0n;
1970
1995
  for (let d = 0; d < l.length; d++)
1971
1996
  c |= BigInt(l[d]) << 8n * BigInt(d);
1972
- return r && c & o && (c = (c ^ o) - o), c;
1997
+ return r && c & s && (c = (c ^ s) - s), c;
1973
1998
  },
1974
1999
  validate: (a) => {
1975
2000
  if (typeof a != "bigint")
1976
2001
  throw new Error(`bigint: invalid value: ${a}`);
1977
- return wn(a, 8n * s, !!r), a;
2002
+ return wn(a, 8n * o, !!r), a;
1978
2003
  }
1979
2004
  });
1980
- }, v = /* @__PURE__ */ En(8, !0), _n = (t, e) => A({
2005
+ }, v = /* @__PURE__ */ En(8, !0), _n = (t, e) => I({
1981
2006
  size: t,
1982
- encodeStream: (r, n) => r.writeView(t, (s) => e.write(s, n)),
2007
+ encodeStream: (r, n) => r.writeView(t, (o) => e.write(o, n)),
1983
2008
  decodeStream: (r) => r.readView(t, e.read),
1984
2009
  validate: (r) => {
1985
2010
  if (typeof r != "number")
@@ -1987,11 +2012,11 @@ const kn = (t) => {
1987
2012
  return e.validate && e.validate(r), r;
1988
2013
  }
1989
2014
  }), Bt = (t, e, r) => {
1990
- const n = t * 8, s = 2 ** (n - 1), o = (l) => {
2015
+ const n = t * 8, o = 2 ** (n - 1), s = (l) => {
1991
2016
  if (!N(l))
1992
2017
  throw new Error(`sintView: value is not safe integer: ${l}`);
1993
- if (l < -s || l >= s)
1994
- throw new Error(`sintView: value out of bounds. Expected ${-s} <= ${l} < ${s}`);
2018
+ if (l < -o || l >= o)
2019
+ throw new Error(`sintView: value out of bounds. Expected ${-o} <= ${l} < ${o}`);
1995
2020
  }, a = 2 ** n, i = (l) => {
1996
2021
  if (!N(l))
1997
2022
  throw new Error(`uintView: value is not safe integer: ${l}`);
@@ -2001,15 +2026,15 @@ const kn = (t) => {
2001
2026
  return _n(t, {
2002
2027
  write: r.write,
2003
2028
  read: r.read,
2004
- validate: e ? o : i
2029
+ validate: e ? s : i
2005
2030
  });
2006
2031
  }, ce = /* @__PURE__ */ Bt(4, !1, {
2007
2032
  read: (t, e) => t.getUint32(e, !0),
2008
2033
  write: (t, e) => t.setUint32(0, e, !0)
2009
- }), $ = /* @__PURE__ */ Bt(1, !1, {
2034
+ }), S = /* @__PURE__ */ Bt(1, !1, {
2010
2035
  read: (t, e) => t.getUint8(e),
2011
2036
  write: (t, e) => t.setUint8(0, e)
2012
- }), Ae = /* @__PURE__ */ A({
2037
+ }), Ae = /* @__PURE__ */ I({
2013
2038
  size: 1,
2014
2039
  encodeStream: (t, e) => t.byte(e ? 1 : 0),
2015
2040
  decodeStream: (t) => {
@@ -2026,27 +2051,27 @@ const kn = (t) => {
2026
2051
  }), fe = (t, e = !1) => {
2027
2052
  if (typeof e != "boolean")
2028
2053
  throw new Error(`bytes/le: expected boolean, got ${typeof e}`);
2029
- const r = St(t), n = T(t);
2030
- return A({
2054
+ const r = $t(t), n = R(t);
2055
+ return I({
2031
2056
  size: typeof t == "number" ? t : void 0,
2032
- encodeStream: (s, o) => {
2033
- n || r.encodeStream(s, o.length), s.bytes(e ? _e(o) : o), n && s.bytes(t);
2057
+ encodeStream: (o, s) => {
2058
+ n || r.encodeStream(o, s.length), o.bytes(e ? _e(s) : s), n && o.bytes(t);
2034
2059
  },
2035
- decodeStream: (s) => {
2036
- let o;
2060
+ decodeStream: (o) => {
2061
+ let s;
2037
2062
  if (n) {
2038
- const a = s.find(t);
2063
+ const a = o.find(t);
2039
2064
  if (!a)
2040
- throw s.err("bytes: cannot find terminator");
2041
- o = s.bytes(a - s.pos), s.bytes(t.length);
2065
+ throw o.err("bytes: cannot find terminator");
2066
+ s = o.bytes(a - o.pos), o.bytes(t.length);
2042
2067
  } else
2043
- o = s.bytes(t === null ? s.leftBytes : r.decodeStream(s));
2044
- return e ? _e(o) : o;
2068
+ s = o.bytes(t === null ? o.leftBytes : r.decodeStream(o));
2069
+ return e ? _e(s) : s;
2045
2070
  },
2046
- validate: (s) => {
2047
- if (!T(s))
2048
- throw new Error(`bytes: invalid value ${s}`);
2049
- return s;
2071
+ validate: (o) => {
2072
+ if (!R(o))
2073
+ throw new Error(`bytes: invalid value ${o}`);
2074
+ return o;
2050
2075
  }
2051
2076
  });
2052
2077
  }, An = (t, e = !1) => Nt(In(fe(t, e), un), (r) => {
@@ -2055,38 +2080,38 @@ const kn = (t) => {
2055
2080
  return r;
2056
2081
  });
2057
2082
  function In(t, e) {
2058
- if (!S(t))
2083
+ if (!$(t))
2059
2084
  throw new Error(`apply: invalid inner value ${t}`);
2060
2085
  if (!he(e))
2061
2086
  throw new Error(`apply: invalid base value ${t}`);
2062
- return A({
2087
+ return I({
2063
2088
  size: t.size,
2064
2089
  encodeStream: (r, n) => {
2065
- let s;
2090
+ let o;
2066
2091
  try {
2067
- s = e.decode(n);
2068
- } catch (o) {
2069
- throw r.err("" + o);
2092
+ o = e.decode(n);
2093
+ } catch (s) {
2094
+ throw r.err("" + s);
2070
2095
  }
2071
- return t.encodeStream(r, s);
2096
+ return t.encodeStream(r, o);
2072
2097
  },
2073
2098
  decodeStream: (r) => {
2074
2099
  const n = t.decodeStream(r);
2075
2100
  try {
2076
2101
  return e.encode(n);
2077
- } catch (s) {
2078
- throw r.err("" + s);
2102
+ } catch (o) {
2103
+ throw r.err("" + o);
2079
2104
  }
2080
2105
  }
2081
2106
  });
2082
2107
  }
2083
2108
  function K(t, e, r) {
2084
- if (!S(t) || !S(e))
2109
+ if (!$(t) || !$(e))
2085
2110
  throw new Error(`optional: invalid flag or inner value flag=${t} inner=${e}`);
2086
- return A({
2111
+ return I({
2087
2112
  size: r !== void 0 && t.size && e.size ? t.size + e.size : void 0,
2088
- encodeStream: (n, s) => {
2089
- t.encodeStream(n, !!s), s ? e.encodeStream(n, s) : r !== void 0 && e.encodeStream(n, r);
2113
+ encodeStream: (n, o) => {
2114
+ t.encodeStream(n, !!o), o ? e.encodeStream(n, o) : r !== void 0 && e.encodeStream(n, r);
2090
2115
  },
2091
2116
  decodeStream: (n) => {
2092
2117
  if (t.decodeStream(n))
@@ -2095,8 +2120,8 @@ function K(t, e, r) {
2095
2120
  }
2096
2121
  });
2097
2122
  }
2098
- function $n(t) {
2099
- return A({
2123
+ function Sn(t) {
2124
+ return I({
2100
2125
  encodeStream: (e, r) => {
2101
2126
  if (r !== t)
2102
2127
  throw new Error(`constant: invalid value ${r} (exp: ${t})`);
@@ -2104,7 +2129,7 @@ function $n(t) {
2104
2129
  decodeStream: (e) => t
2105
2130
  });
2106
2131
  }
2107
- function Sn(t) {
2132
+ function $n(t) {
2108
2133
  let e = 0;
2109
2134
  for (const r of t) {
2110
2135
  if (r.size === void 0)
@@ -2115,25 +2140,25 @@ function Sn(t) {
2115
2140
  }
2116
2141
  return e;
2117
2142
  }
2118
- function g(t) {
2119
- if (!D(t))
2143
+ function m(t) {
2144
+ if (!F(t))
2120
2145
  throw new Error(`struct: expected plain object, got ${t}`);
2121
2146
  for (const e in t)
2122
- if (!S(t[e]))
2147
+ if (!$(t[e]))
2123
2148
  throw new Error(`struct: field ${e} is not CoderType`);
2124
- return A({
2125
- size: Sn(Object.values(t)),
2149
+ return I({
2150
+ size: $n(Object.values(t)),
2126
2151
  encodeStream: (e, r) => {
2127
2152
  e.pushObj(r, (n) => {
2128
- for (const s in t)
2129
- n(s, () => t[s].encodeStream(e, r[s]));
2153
+ for (const o in t)
2154
+ n(o, () => t[o].encodeStream(e, r[o]));
2130
2155
  });
2131
2156
  },
2132
2157
  decodeStream: (e) => {
2133
2158
  const r = {};
2134
2159
  return e.pushObj(r, (n) => {
2135
- for (const s in t)
2136
- n(s, () => r[s] = t[s].decodeStream(e));
2160
+ for (const o in t)
2161
+ n(o, () => r[o] = t[o].decodeStream(e));
2137
2162
  }), r;
2138
2163
  },
2139
2164
  validate: (e) => {
@@ -2144,49 +2169,49 @@ function g(t) {
2144
2169
  });
2145
2170
  }
2146
2171
  function ne(t, e) {
2147
- if (!S(e))
2172
+ if (!$(e))
2148
2173
  throw new Error(`array: invalid inner value ${e}`);
2149
- const r = St(typeof t == "string" ? `../${t}` : t);
2150
- return A({
2174
+ const r = $t(typeof t == "string" ? `../${t}` : t);
2175
+ return I({
2151
2176
  size: typeof t == "number" && e.size ? t * e.size : void 0,
2152
- encodeStream: (n, s) => {
2153
- const o = n;
2154
- o.pushObj(s, (a) => {
2155
- T(t) || r.encodeStream(n, s.length);
2156
- for (let i = 0; i < s.length; i++)
2177
+ encodeStream: (n, o) => {
2178
+ const s = n;
2179
+ s.pushObj(o, (a) => {
2180
+ R(t) || r.encodeStream(n, o.length);
2181
+ for (let i = 0; i < o.length; i++)
2157
2182
  a(`${i}`, () => {
2158
- const l = s[i], c = n.pos;
2159
- if (e.encodeStream(n, l), T(t)) {
2160
- if (t.length > o.pos - c)
2183
+ const l = o[i], c = n.pos;
2184
+ if (e.encodeStream(n, l), R(t)) {
2185
+ if (t.length > s.pos - c)
2161
2186
  return;
2162
- const d = o.finish(!1).subarray(c, o.pos);
2187
+ const d = s.finish(!1).subarray(c, s.pos);
2163
2188
  if (Ee(d.subarray(0, t.length), t))
2164
- throw o.err(`array: inner element encoding same as separator. elm=${l} data=${d}`);
2189
+ throw s.err(`array: inner element encoding same as separator. elm=${l} data=${d}`);
2165
2190
  }
2166
2191
  });
2167
- }), T(t) && n.bytes(t);
2192
+ }), R(t) && n.bytes(t);
2168
2193
  },
2169
2194
  decodeStream: (n) => {
2170
- const s = [];
2171
- return n.pushObj(s, (o) => {
2195
+ const o = [];
2196
+ return n.pushObj(o, (s) => {
2172
2197
  if (t === null)
2173
- for (let a = 0; !n.isEnd() && (o(`${a}`, () => s.push(e.decodeStream(n))), !(e.size && n.leftBytes < e.size)); a++)
2198
+ for (let a = 0; !n.isEnd() && (s(`${a}`, () => o.push(e.decodeStream(n))), !(e.size && n.leftBytes < e.size)); a++)
2174
2199
  ;
2175
- else if (T(t))
2200
+ else if (R(t))
2176
2201
  for (let a = 0; ; a++) {
2177
2202
  if (Ee(n.bytes(t.length, !0), t)) {
2178
2203
  n.bytes(t.length);
2179
2204
  break;
2180
2205
  }
2181
- o(`${a}`, () => s.push(e.decodeStream(n)));
2206
+ s(`${a}`, () => o.push(e.decodeStream(n)));
2182
2207
  }
2183
2208
  else {
2184
2209
  let a;
2185
- o("arrayLen", () => a = r.decodeStream(n));
2210
+ s("arrayLen", () => a = r.decodeStream(n));
2186
2211
  for (let i = 0; i < a; i++)
2187
- o(`${i}`, () => s.push(e.decodeStream(n)));
2212
+ s(`${i}`, () => o.push(e.decodeStream(n)));
2188
2213
  }
2189
- }), s;
2214
+ }), o;
2190
2215
  },
2191
2216
  validate: (n) => {
2192
2217
  if (!Array.isArray(n))
@@ -2196,21 +2221,21 @@ function ne(t, e) {
2196
2221
  });
2197
2222
  }
2198
2223
  function Me(t, e) {
2199
- if (!S(t))
2224
+ if (!$(t))
2200
2225
  throw new Error(`map: invalid inner value ${t}`);
2201
- if (!D(e))
2226
+ if (!F(e))
2202
2227
  throw new Error("map: variants should be plain object");
2203
2228
  const r = /* @__PURE__ */ new Map();
2204
2229
  for (const n in e)
2205
2230
  r.set(e[n], n);
2206
- return A({
2231
+ return I({
2207
2232
  size: t.size,
2208
- encodeStream: (n, s) => t.encodeStream(n, e[s]),
2233
+ encodeStream: (n, o) => t.encodeStream(n, e[o]),
2209
2234
  decodeStream: (n) => {
2210
- const s = t.decodeStream(n), o = r.get(s);
2211
- if (o === void 0)
2212
- throw n.err(`Enum: unknown value: ${s} ${Array.from(r.keys())}`);
2213
- return o;
2235
+ const o = t.decodeStream(n), s = r.get(o);
2236
+ if (s === void 0)
2237
+ throw n.err(`Enum: unknown value: ${o} ${Array.from(r.keys())}`);
2238
+ return s;
2214
2239
  },
2215
2240
  validate: (n) => {
2216
2241
  if (typeof n != "string")
@@ -2222,24 +2247,24 @@ function Me(t, e) {
2222
2247
  });
2223
2248
  }
2224
2249
  function Ln(t, e) {
2225
- if (!S(t))
2250
+ if (!$(t))
2226
2251
  throw new Error(`tag: invalid tag value ${t}`);
2227
- if (!D(e))
2252
+ if (!F(e))
2228
2253
  throw new Error("tag: variants should be plain object");
2229
2254
  for (const r in e)
2230
- if (!S(e[r]))
2255
+ if (!$(e[r]))
2231
2256
  throw new Error(`tag: variant ${r} is not CoderType`);
2232
- return A({
2257
+ return I({
2233
2258
  size: t.size,
2234
2259
  encodeStream: (r, n) => {
2235
- const { TAG: s, data: o } = n, a = e[s];
2236
- t.encodeStream(r, s), a.encodeStream(r, o);
2260
+ const { TAG: o, data: s } = n, a = e[o];
2261
+ t.encodeStream(r, o), a.encodeStream(r, s);
2237
2262
  },
2238
2263
  decodeStream: (r) => {
2239
- const n = t.decodeStream(r), s = e[n];
2240
- if (!s)
2264
+ const n = t.decodeStream(r), o = e[n];
2265
+ if (!o)
2241
2266
  throw r.err(`Tag: invalid tag ${n}`);
2242
- return { TAG: n, data: s.decodeStream(r) };
2267
+ return { TAG: n, data: o.decodeStream(r) };
2243
2268
  },
2244
2269
  validate: (r) => {
2245
2270
  const { TAG: n } = r;
@@ -2254,29 +2279,29 @@ function ye(t, e) {
2254
2279
  return e % t === 0 ? 0 : t - e % t;
2255
2280
  }
2256
2281
  function Pt(t, e, r) {
2257
- if (!S(e))
2282
+ if (!$(e))
2258
2283
  throw new Error(`padRight: invalid inner value ${e}`);
2259
2284
  if (!N(t) || t <= 0)
2260
2285
  throw new Error(`padLeft: wrong blockSize=${t}`);
2261
2286
  if (r !== void 0 && typeof r != "function")
2262
2287
  throw new Error(`padRight: wrong padFn=${typeof r}`);
2263
2288
  const n = r || Nn;
2264
- return A({
2289
+ return I({
2265
2290
  size: e.size ? e.size + ye(t, e.size) : void 0,
2266
- encodeStream: (s, o) => {
2267
- const a = s, i = a.pos;
2268
- e.encodeStream(s, o);
2291
+ encodeStream: (o, s) => {
2292
+ const a = o, i = a.pos;
2293
+ e.encodeStream(o, s);
2269
2294
  const l = ye(t, a.pos - i);
2270
2295
  for (let c = 0; c < l; c++)
2271
- s.byte(n(c));
2296
+ o.byte(n(c));
2272
2297
  },
2273
- decodeStream: (s) => {
2274
- const o = s.pos, a = e.decodeStream(s);
2275
- return s.bytes(ye(t, s.pos - o)), a;
2298
+ decodeStream: (o) => {
2299
+ const s = o.pos, a = e.decodeStream(o);
2300
+ return o.bytes(ye(t, o.pos - s)), a;
2276
2301
  }
2277
2302
  });
2278
2303
  }
2279
- const Bn = 9, be = V.decimal(Bn), q = A({
2304
+ const Bn = 9, be = V.decimal(Bn), q = I({
2280
2305
  encodeStream: (t, e) => {
2281
2306
  if (!e)
2282
2307
  return t.byte(0);
@@ -2294,53 +2319,53 @@ const Bn = 9, be = V.decimal(Bn), q = A({
2294
2319
  }
2295
2320
  }), re = An(Pt(8, ce, void 0)), Pn = () => {
2296
2321
  const t = fe(32);
2297
- return A({
2322
+ return I({
2298
2323
  size: t.size,
2299
2324
  encodeStream: (e, r) => t.encodeStream(e, ke.decode(r)),
2300
2325
  decodeStream: (e) => ke.encode(t.decodeStream(e))
2301
2326
  });
2302
- }, C = Pn(), Tn = g({
2303
- requiredSignatures: $,
2304
- readSigned: $,
2305
- readUnsigned: $,
2306
- keys: ne(q, C),
2307
- blockhash: C,
2308
- instructions: ne(q, g({ programIdx: $, keys: ne(q, $), data: fe(q) }))
2327
+ }, b = Pn(), Tn = m({
2328
+ requiredSignatures: S,
2329
+ readSigned: S,
2330
+ readUnsigned: S,
2331
+ keys: ne(q, b),
2332
+ blockhash: b,
2333
+ instructions: ne(q, m({ programIdx: S, keys: ne(q, S), data: fe(q) }))
2309
2334
  });
2310
2335
  function Rn(t) {
2311
2336
  if (ke.decode(t).length !== 32)
2312
2337
  throw new Error("Invalid Solana address");
2313
2338
  }
2314
- const Un = (t, e, r, n, s) => ({
2339
+ const Un = (t, e, r, n, o) => ({
2315
2340
  sign: t < e,
2316
- write: t < e - r || t >= e && t < s - n
2317
- }), nt = g({
2341
+ write: t < e - r || t >= e && t < o - n
2342
+ }), nt = m({
2318
2343
  signatures: ne(q, fe(64)),
2319
2344
  msg: Tn
2320
- }), Ie = A({
2345
+ }), Ie = I({
2321
2346
  encodeStream: (t, e) => {
2322
- const { msg: r, signatures: n } = e, s = {}, o = (h, f, u) => {
2323
- let p = s[h] || (s[h] = { sign: !1, write: !1 });
2324
- p.write || (p.write = u), p.sign || (p.sign = f);
2347
+ const { msg: r, signatures: n } = e, o = {}, s = (h, f, u) => {
2348
+ let g = o[h] || (o[h] = { sign: !1, write: !1 });
2349
+ g.write || (g.write = u), g.sign || (g.sign = f);
2325
2350
  };
2326
- o(r.feePayer, !0, !0);
2351
+ s(r.feePayer, !0, !0);
2327
2352
  for (let h of r.instructions)
2328
2353
  for (let f of h.keys)
2329
- o(f.address, f.sign, f.write);
2354
+ s(f.address, f.sign, f.write);
2330
2355
  for (let h of r.instructions)
2331
- o(h.program, !1, !1);
2332
- const a = Object.keys(s), i = [
2356
+ s(h.program, !1, !1);
2357
+ const a = Object.keys(o), i = [
2333
2358
  r.feePayer,
2334
- ...a.filter((h) => s[h].sign && s[h].write && h !== r.feePayer),
2335
- ...a.filter((h) => s[h].sign && !s[h].write),
2336
- ...a.filter((h) => !s[h].sign && s[h].write),
2337
- ...a.filter((h) => !s[h].sign && !s[h].write)
2359
+ ...a.filter((h) => o[h].sign && o[h].write && h !== r.feePayer),
2360
+ ...a.filter((h) => o[h].sign && !o[h].write),
2361
+ ...a.filter((h) => !o[h].sign && o[h].write),
2362
+ ...a.filter((h) => !o[h].sign && !o[h].write)
2338
2363
  ];
2339
2364
  let l = 0, c = 0, d = 0;
2340
2365
  for (let h of i)
2341
- s[h].sign && l++, !s[h].write && (s[h].sign ? c++ : d++);
2366
+ o[h].sign && l++, !o[h].write && (o[h].sign ? c++ : d++);
2342
2367
  nt.encodeStream(t, {
2343
- signatures: i.filter((h) => s[h].sign).map((h) => n[h] || new Uint8Array(64)),
2368
+ signatures: i.filter((h) => o[h].sign).map((h) => n[h] || new Uint8Array(64)),
2344
2369
  msg: {
2345
2370
  requiredSignatures: l,
2346
2371
  readSigned: c,
@@ -2363,45 +2388,45 @@ const Un = (t, e, r, n, s) => ({
2363
2388
  if (r.keys.length < e.length)
2364
2389
  throw new Error("SOL.tx: invalid keys length");
2365
2390
  const n = {};
2366
- for (let o = 0; o < e.length; o++)
2367
- n[r.keys[o]] = e[o];
2368
- let s = [];
2369
- for (let o = 0; o < r.keys.length; o++)
2370
- s.push({
2371
- address: r.keys[o],
2372
- ...Un(o, r.requiredSignatures, r.readSigned, r.readUnsigned, r.keys.length)
2391
+ for (let s = 0; s < e.length; s++)
2392
+ n[r.keys[s]] = e[s];
2393
+ let o = [];
2394
+ for (let s = 0; s < r.keys.length; s++)
2395
+ o.push({
2396
+ address: r.keys[s],
2397
+ ...Un(s, r.requiredSignatures, r.readSigned, r.readUnsigned, r.keys.length)
2373
2398
  });
2374
- if (!s.length)
2399
+ if (!o.length)
2375
2400
  throw new Error("SOL.tx: empty accounts array");
2376
2401
  return {
2377
2402
  msg: {
2378
- feePayer: s[0].address,
2403
+ feePayer: o[0].address,
2379
2404
  blockhash: r.blockhash,
2380
- instructions: r.instructions.map((o) => ({
2381
- program: s[o.programIdx].address,
2382
- keys: o.keys.map((a) => s[a]),
2383
- data: o.data
2405
+ instructions: r.instructions.map((s) => ({
2406
+ program: o[s.programIdx].address,
2407
+ keys: s.keys.map((a) => o[a]),
2408
+ data: s.data
2384
2409
  }))
2385
2410
  },
2386
2411
  signatures: n
2387
2412
  };
2388
2413
  }
2389
- }), st = {};
2414
+ }), ot = {};
2390
2415
  function ze(t, e, r) {
2391
- if (st[t])
2416
+ if (ot[t])
2392
2417
  throw new Error("SOL: program for this address already defined");
2393
- const n = Me(e, Object.keys(r).reduce((i, l, c) => ({ ...i, [l]: c }), {})), s = Object.keys(r).reduce((i, l) => ({ ...i, [l]: r[l].coder }), {}), o = Ln(n, s);
2394
- st[t] = (i, l) => {
2418
+ const n = Me(e, Object.keys(r).reduce((i, l, c) => ({ ...i, [l]: c }), {})), o = Object.keys(r).reduce((i, l) => ({ ...i, [l]: r[l].coder }), {}), s = Ln(n, o);
2419
+ ot[t] = (i, l) => {
2395
2420
  if (i.program !== t)
2396
2421
  throw new Error("SOL.parseInstruction: Wrong instruction program address");
2397
- const { TAG: c, data: d } = o.decode(i.data), h = { type: c, info: d }, f = Object.keys(r[c].keys);
2422
+ const { TAG: c, data: d } = s.decode(i.data), h = { type: c, info: d }, f = Object.keys(r[c].keys);
2398
2423
  if (f.length !== i.keys.length)
2399
2424
  throw new Error("SOL.parseInstruction: Keys length mismatch");
2400
2425
  for (let u = 0; u < f.length; u++) {
2401
- const p = f[u];
2402
- if (r[c].keys[p].address) {
2403
- if (r[c].keys[p].address !== i.keys[u].address)
2404
- throw new Error(`SOL.parseInstruction(${t}/${c}): Invalid constant address for key exp=${r[c].keys[p].address} got=${i.keys[u].address}`);
2426
+ const g = f[u];
2427
+ if (r[c].keys[g].address) {
2428
+ if (r[c].keys[g].address !== i.keys[u].address)
2429
+ throw new Error(`SOL.parseInstruction(${t}/${c}): Invalid constant address for key exp=${r[c].keys[g].address} got=${i.keys[u].address}`);
2405
2430
  continue;
2406
2431
  }
2407
2432
  h.info[f[u]] = i.keys[u].address;
@@ -2412,7 +2437,7 @@ function ze(t, e, r) {
2412
2437
  for (const i in r)
2413
2438
  a[i] = (l) => ({
2414
2439
  program: t,
2415
- data: o.encode({ TAG: i, data: l }),
2440
+ data: s.encode({ TAG: i, data: l }),
2416
2441
  keys: Object.keys(r[i].keys).map((c) => {
2417
2442
  let { sign: d, write: h, address: f } = r[i].keys[c];
2418
2443
  return f || (f = l[c]), Rn(f), { address: f, sign: d, write: h };
@@ -2420,9 +2445,9 @@ function ze(t, e, r) {
2420
2445
  });
2421
2446
  return a;
2422
2447
  }
2423
- const Ce = "SysvarRecentB1ockHashes11111111111111111111", z = "SysvarRent111111111111111111111111111111111", Tt = "11111111111111111111111111111111", Rt = ze(Tt, ce, {
2448
+ const Ce = "SysvarRecentB1ockHashes11111111111111111111", O = "SysvarRent111111111111111111111111111111111", Tt = "11111111111111111111111111111111", Rt = ze(Tt, ce, {
2424
2449
  createAccount: {
2425
- coder: g({ lamports: v, space: v, owner: C }),
2450
+ coder: m({ lamports: v, space: v, owner: b }),
2426
2451
  keys: {
2427
2452
  source: { sign: !0, write: !0 },
2428
2453
  newAccount: { sign: !0, write: !0 }
@@ -2430,22 +2455,22 @@ const Ce = "SysvarRecentB1ockHashes11111111111111111111", z = "SysvarRent1111111
2430
2455
  hint: (t) => `Create new account=${t.newAccount} with balance of ${be.encode(t.lamports)} and owner program ${t.owner}, using funding account ${t.source}`
2431
2456
  },
2432
2457
  assign: {
2433
- coder: g({ owner: C }),
2458
+ coder: m({ owner: b }),
2434
2459
  keys: { account: { sign: !0, write: !0 } },
2435
2460
  hint: (t) => `Assign account=${t.account} to owner program=${t.owner}`
2436
2461
  },
2437
2462
  transfer: {
2438
- coder: g({ lamports: v }),
2463
+ coder: m({ lamports: v }),
2439
2464
  keys: { source: { sign: !0, write: !0 }, destination: { sign: !1, write: !0 } },
2440
2465
  hint: (t) => `Transfer ${be.encode(t.lamports)} SOL from ${t.source} to ${t.destination}`
2441
2466
  },
2442
2467
  createAccountWithSeed: {
2443
- coder: g({
2444
- base: C,
2468
+ coder: m({
2469
+ base: b,
2445
2470
  seed: re,
2446
2471
  lamports: v,
2447
2472
  space: v,
2448
- owner: C
2473
+ owner: b
2449
2474
  }),
2450
2475
  keys: {
2451
2476
  source: { sign: !0, write: !0 },
@@ -2454,7 +2479,7 @@ const Ce = "SysvarRecentB1ockHashes11111111111111111111", z = "SysvarRent1111111
2454
2479
  }
2455
2480
  },
2456
2481
  advanceNonce: {
2457
- coder: g({}),
2482
+ coder: m({}),
2458
2483
  keys: {
2459
2484
  nonceAccount: { sign: !1, write: !0 },
2460
2485
  _recent_bh: { address: Ce, sign: !1, write: !1 },
@@ -2463,26 +2488,26 @@ const Ce = "SysvarRecentB1ockHashes11111111111111111111", z = "SysvarRent1111111
2463
2488
  hint: (t) => `Consume nonce in nonce account=${t.nonceAccount} (owner: ${t.nonceAuthority})`
2464
2489
  },
2465
2490
  withdrawFromNonce: {
2466
- coder: g({ lamports: v }),
2491
+ coder: m({ lamports: v }),
2467
2492
  keys: {
2468
2493
  nonceAccount: { sign: !1, write: !0 },
2469
2494
  destination: { sign: !1, write: !0 },
2470
2495
  _recent_bh: { address: Ce, sign: !1, write: !1 },
2471
- _rent: { address: z, sign: !1, write: !1 },
2496
+ _rent: { address: O, sign: !1, write: !1 },
2472
2497
  nonceAuthority: { sign: !0, write: !1 }
2473
2498
  },
2474
2499
  hint: (t) => `Withdraw ${be.encode(t.lamports)} SOL from nonce account=${t.nonceAccount} (owner: ${t.nonceAuthority}) to ${t.destination}`
2475
2500
  },
2476
2501
  initializeNonce: {
2477
- coder: g({ nonceAuthority: C }),
2502
+ coder: m({ nonceAuthority: b }),
2478
2503
  keys: {
2479
2504
  nonceAccount: { sign: !1, write: !0 },
2480
2505
  _recent_bh: { address: Ce, sign: !1, write: !1 },
2481
- _rent: { address: z, sign: !1, write: !1 }
2506
+ _rent: { address: O, sign: !1, write: !1 }
2482
2507
  }
2483
2508
  },
2484
2509
  authorizeNonce: {
2485
- coder: g({ newAuthorized: C }),
2510
+ coder: m({ newAuthorized: b }),
2486
2511
  keys: {
2487
2512
  nonceAccount: { sign: !1, write: !0 },
2488
2513
  nonceAuthority: { sign: !0, write: !1 }
@@ -2490,17 +2515,17 @@ const Ce = "SysvarRecentB1ockHashes11111111111111111111", z = "SysvarRent1111111
2490
2515
  hint: (t) => `Change owner of nonce account=${t.nonceAccount} from ${t.nonceAuthority} to ${t.newAuthorized}`
2491
2516
  },
2492
2517
  allocate: {
2493
- coder: g({ space: v }),
2518
+ coder: m({ space: v }),
2494
2519
  keys: {
2495
2520
  account: { sign: !0, write: !0 }
2496
2521
  }
2497
2522
  },
2498
2523
  allocateWithSeed: {
2499
- coder: g({
2500
- base: C,
2524
+ coder: m({
2525
+ base: b,
2501
2526
  seed: re,
2502
2527
  space: v,
2503
- owner: C
2528
+ owner: b
2504
2529
  }),
2505
2530
  keys: {
2506
2531
  account: { sign: !1, write: !0 },
@@ -2508,10 +2533,10 @@ const Ce = "SysvarRecentB1ockHashes11111111111111111111", z = "SysvarRent1111111
2508
2533
  }
2509
2534
  },
2510
2535
  assignWithSeed: {
2511
- coder: g({
2512
- base: C,
2536
+ coder: m({
2537
+ base: b,
2513
2538
  seed: re,
2514
- owner: C
2539
+ owner: b
2515
2540
  }),
2516
2541
  keys: {
2517
2542
  account: { sign: !1, write: !0 },
@@ -2519,10 +2544,10 @@ const Ce = "SysvarRecentB1ockHashes11111111111111111111", z = "SysvarRent1111111
2519
2544
  }
2520
2545
  },
2521
2546
  transferWithSeed: {
2522
- coder: g({
2547
+ coder: m({
2523
2548
  lamports: v,
2524
2549
  sourceSeed: re,
2525
- sourceOwner: C
2550
+ sourceOwner: b
2526
2551
  }),
2527
2552
  keys: {
2528
2553
  source: { sign: !1, write: !0 },
@@ -2534,45 +2559,45 @@ const Ce = "SysvarRecentB1ockHashes11111111111111111111", z = "SysvarRent1111111
2534
2559
  };
2535
2560
  Ut(Rt.transfer);
2536
2561
  Ut(Rt.advanceNonce);
2537
- const Mn = Me($, {
2562
+ const Mn = Me(S, {
2538
2563
  MintTokens: 0,
2539
2564
  FreezeAccount: 1,
2540
2565
  AccountOwner: 2,
2541
2566
  CloseAccount: 3
2542
- }), U = (t, e) => e[t]?.symbol || t, Mt = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
2543
- ze(Mt, $, {
2567
+ }), M = (t, e) => e[t]?.symbol || t, Mt = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
2568
+ ze(Mt, S, {
2544
2569
  initializeMint: {
2545
- coder: g({
2546
- decimals: $,
2547
- mintAuthority: C,
2548
- freezeAuthority: K(Ae, C, "11111111111111111111111111111111")
2570
+ coder: m({
2571
+ decimals: S,
2572
+ mintAuthority: b,
2573
+ freezeAuthority: K(Ae, b, "11111111111111111111111111111111")
2549
2574
  }),
2550
2575
  keys: {
2551
2576
  mint: { sign: !1, write: !0 },
2552
- _rent: { address: z, sign: !1, write: !1 }
2577
+ _rent: { address: O, sign: !1, write: !1 }
2553
2578
  }
2554
2579
  },
2555
2580
  initializeAccount: {
2556
- coder: g({}),
2581
+ coder: m({}),
2557
2582
  keys: {
2558
2583
  account: { sign: !1, write: !0 },
2559
2584
  mint: { sign: !1, write: !1 },
2560
2585
  owner: { sign: !1, write: !1 },
2561
- _rent: { address: z, sign: !1, write: !1 }
2586
+ _rent: { address: O, sign: !1, write: !1 }
2562
2587
  },
2563
- hint: (t, e) => `Initialize token account=${t.account} with owner=${t.owner} token=${U(t.mint, e)}`
2588
+ hint: (t, e) => `Initialize token account=${t.account} with owner=${t.owner} token=${M(t.mint, e)}`
2564
2589
  },
2565
2590
  // TODO: multisig support?
2566
2591
  initializeMultisig: {
2567
- coder: g({ m: $ }),
2592
+ coder: m({ m: S }),
2568
2593
  keys: {
2569
2594
  account: { sign: !1, write: !0 },
2570
- _rent: { address: z, sign: !1, write: !1 }
2595
+ _rent: { address: O, sign: !1, write: !1 }
2571
2596
  },
2572
2597
  hint: (t, e) => `Initialize multi-sig token account=${t.account} with signatures=${t.m}`
2573
2598
  },
2574
2599
  transfer: {
2575
- coder: g({ amount: v }),
2600
+ coder: m({ amount: v }),
2576
2601
  keys: {
2577
2602
  source: { sign: !1, write: !0 },
2578
2603
  destination: { sign: !1, write: !0 },
@@ -2581,7 +2606,7 @@ ze(Mt, $, {
2581
2606
  hint: (t, e) => `Transfer ${t.amount} from token account=${t.source} of owner=${t.owner} to ${t.destination}`
2582
2607
  },
2583
2608
  approve: {
2584
- coder: g({ amount: v }),
2609
+ coder: m({ amount: v }),
2585
2610
  keys: {
2586
2611
  account: { sign: !1, write: !0 },
2587
2612
  delegate: { sign: !1, write: !1 },
@@ -2590,7 +2615,7 @@ ze(Mt, $, {
2590
2615
  hint: (t, e) => `Approve authority of delegate=${t.delegate} over tokens on account=${t.account} on behalf of owner=${t.owner}`
2591
2616
  },
2592
2617
  revoke: {
2593
- coder: g({}),
2618
+ coder: m({}),
2594
2619
  keys: {
2595
2620
  account: { sign: !1, write: !0 },
2596
2621
  owner: { sign: !0, write: !1 }
@@ -2598,9 +2623,9 @@ ze(Mt, $, {
2598
2623
  hint: (t, e) => `Revoke delegate's authority over tokens on account=${t.account} on behalf of owner=${t.owner}`
2599
2624
  },
2600
2625
  setAuthority: {
2601
- coder: g({
2626
+ coder: m({
2602
2627
  authorityType: Mn,
2603
- newAuthority: K(Ae, C, "11111111111111111111111111111111")
2628
+ newAuthority: K(Ae, b, "11111111111111111111111111111111")
2604
2629
  }),
2605
2630
  keys: {
2606
2631
  account: { sign: !1, write: !0 },
@@ -2609,7 +2634,7 @@ ze(Mt, $, {
2609
2634
  hint: (t, e) => `Sets a new authority=${t.newAuthority} of a mint or account=${t.account}. Current authority=${t.currentAuthority}. Authority Type: ${t.authorityType}`
2610
2635
  },
2611
2636
  mintTo: {
2612
- coder: g({ amount: v }),
2637
+ coder: m({ amount: v }),
2613
2638
  keys: {
2614
2639
  mint: { sign: !1, write: !0 },
2615
2640
  dest: { sign: !1, write: !0 },
@@ -2617,7 +2642,7 @@ ze(Mt, $, {
2617
2642
  }
2618
2643
  },
2619
2644
  burn: {
2620
- coder: g({ amount: v }),
2645
+ coder: m({ amount: v }),
2621
2646
  keys: {
2622
2647
  account: { sign: !1, write: !0 },
2623
2648
  mint: { sign: !1, write: !0 },
@@ -2626,7 +2651,7 @@ ze(Mt, $, {
2626
2651
  hint: (t, e) => `Burn ${t.amount} tokens from account=${t.account} of owner=${t.owner} mint=${t.mint}`
2627
2652
  },
2628
2653
  closeAccount: {
2629
- coder: g({}),
2654
+ coder: m({}),
2630
2655
  keys: {
2631
2656
  account: { sign: !1, write: !0 },
2632
2657
  dest: { sign: !1, write: !0 },
@@ -2635,7 +2660,7 @@ ze(Mt, $, {
2635
2660
  hint: (t, e) => `Close token account=${t.account} of owner=${t.owner}, transferring all its SOL to destionation account=${t.dest}`
2636
2661
  },
2637
2662
  freezeAccount: {
2638
- coder: g({}),
2663
+ coder: m({}),
2639
2664
  keys: {
2640
2665
  account: { sign: !1, write: !0 },
2641
2666
  mint: { sign: !1, write: !0 },
@@ -2644,7 +2669,7 @@ ze(Mt, $, {
2644
2669
  hint: (t, e) => `Freeze token account=${t.account} of mint=${t.mint} using freeze_authority=${t.authority}`
2645
2670
  },
2646
2671
  thawAccount: {
2647
- coder: g({}),
2672
+ coder: m({}),
2648
2673
  keys: {
2649
2674
  account: { sign: !1, write: !0 },
2650
2675
  mint: { sign: !1, write: !1 },
@@ -2653,69 +2678,69 @@ ze(Mt, $, {
2653
2678
  hint: (t, e) => `Thaw a frozne token account=${t.account} of mint=${t.mint} using freeze_authority=${t.authority}`
2654
2679
  },
2655
2680
  transferChecked: {
2656
- coder: g({ amount: v, decimals: $ }),
2681
+ coder: m({ amount: v, decimals: S }),
2657
2682
  keys: {
2658
2683
  source: { sign: !1, write: !0 },
2659
2684
  mint: { sign: !1, write: !1 },
2660
2685
  destination: { sign: !1, write: !0 },
2661
2686
  owner: { sign: !0, write: !1 }
2662
2687
  },
2663
- hint: (t, e) => `Transfer ${V.decimal(t.decimals).encode(t.amount)} ${U(t.mint, e)} from token account=${t.source} of owner=${t.owner} to ${t.destination}`
2688
+ hint: (t, e) => `Transfer ${V.decimal(t.decimals).encode(t.amount)} ${M(t.mint, e)} from token account=${t.source} of owner=${t.owner} to ${t.destination}`
2664
2689
  },
2665
2690
  approveChecked: {
2666
- coder: g({ amount: v, decimals: $ }),
2691
+ coder: m({ amount: v, decimals: S }),
2667
2692
  keys: {
2668
2693
  source: { sign: !1, write: !0 },
2669
2694
  mint: { sign: !1, write: !1 },
2670
2695
  delegate: { sign: !1, write: !1 },
2671
2696
  owner: { sign: !0, write: !1 }
2672
2697
  },
2673
- hint: (t, e) => `Approve delgate=${t.delegate} authority on behalf account=${t.source} owner=${t.owner} over ${V.decimal(t.decimals).encode(t.amount)} ${U(t.mint, e)}`
2698
+ hint: (t, e) => `Approve delgate=${t.delegate} authority on behalf account=${t.source} owner=${t.owner} over ${V.decimal(t.decimals).encode(t.amount)} ${M(t.mint, e)}`
2674
2699
  },
2675
2700
  mintToChecked: {
2676
- coder: g({ amount: v, decimals: $ }),
2701
+ coder: m({ amount: v, decimals: S }),
2677
2702
  keys: {
2678
2703
  mint: { sign: !1, write: !0 },
2679
2704
  dest: { sign: !1, write: !0 },
2680
2705
  authority: { sign: !0, write: !1 }
2681
2706
  },
2682
- hint: (t, e) => `Mint new tokens (${V.decimal(t.decimals).encode(t.amount)} ${U(t.mint, e)}) to account=${t.dest} using authority=${t.authority}`
2707
+ hint: (t, e) => `Mint new tokens (${V.decimal(t.decimals).encode(t.amount)} ${M(t.mint, e)}) to account=${t.dest} using authority=${t.authority}`
2683
2708
  },
2684
2709
  burnChecked: {
2685
- coder: g({ amount: v, decimals: $ }),
2710
+ coder: m({ amount: v, decimals: S }),
2686
2711
  keys: {
2687
2712
  mint: { sign: !1, write: !0 },
2688
2713
  account: { sign: !1, write: !0 },
2689
2714
  owner: { sign: !0, write: !1 }
2690
2715
  },
2691
- hint: (t, e) => `Burn tokens (${V.decimal(t.decimals).encode(t.amount)} ${U(t.mint, e)}) on account=${t.account} of owner=${t.owner}`
2716
+ hint: (t, e) => `Burn tokens (${V.decimal(t.decimals).encode(t.amount)} ${M(t.mint, e)}) on account=${t.account} of owner=${t.owner}`
2692
2717
  },
2693
2718
  initializeAccount2: {
2694
- coder: g({ owner: C }),
2719
+ coder: m({ owner: b }),
2695
2720
  keys: {
2696
2721
  account: { sign: !1, write: !0 },
2697
2722
  mint: { sign: !1, write: !1 },
2698
- _rent: { address: z, sign: !1, write: !1 }
2723
+ _rent: { address: O, sign: !1, write: !1 }
2699
2724
  },
2700
- hint: (t, e) => `Initialize token account=${t.account} with owner=${t.owner} token=${U(t.mint, e)}`
2725
+ hint: (t, e) => `Initialize token account=${t.account} with owner=${t.owner} token=${M(t.mint, e)}`
2701
2726
  },
2702
2727
  syncNative: {
2703
- coder: g({}),
2728
+ coder: m({}),
2704
2729
  keys: { nativeAccount: { sign: !1, write: !0 } },
2705
2730
  hint: (t) => `Sync SOL balance for wrapped account ${t.nativeAccount}`
2706
2731
  }
2707
2732
  });
2708
- g({
2733
+ m({
2709
2734
  version: ce,
2710
2735
  state: ce,
2711
- authority: C,
2712
- nonce: C,
2736
+ authority: b,
2737
+ nonce: b,
2713
2738
  lamportPerSignature: v
2714
2739
  });
2715
2740
  const zn = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
2716
- ze(zn, $n(0), {
2741
+ ze(zn, Sn(0), {
2717
2742
  create: {
2718
- coder: g({}),
2743
+ coder: m({}),
2719
2744
  keys: {
2720
2745
  source: { sign: !0, write: !0 },
2721
2746
  account: { sign: !1, write: !0 },
@@ -2723,27 +2748,27 @@ ze(zn, $n(0), {
2723
2748
  mint: { sign: !1, write: !1 },
2724
2749
  _sys: { address: Tt, sign: !1, write: !1 },
2725
2750
  _token: { address: Mt, sign: !1, write: !1 },
2726
- _rent: { address: z, sign: !1, write: !1 }
2751
+ _rent: { address: O, sign: !1, write: !1 }
2727
2752
  },
2728
- hint: (t, e) => `Initialize associated token account=${t.account} with owner=${t.wallet} for token=${U(t.mint, e)}, payed by ${t.source}`
2753
+ hint: (t, e) => `Initialize associated token account=${t.account} with owner=${t.wallet} for token=${M(t.mint, e)}, payed by ${t.source}`
2729
2754
  }
2730
2755
  });
2731
2756
  const xe = Pt(4, Ae, () => 0);
2732
- g({
2733
- mint: C,
2734
- owner: C,
2757
+ m({
2758
+ mint: b,
2759
+ owner: b,
2735
2760
  amount: v,
2736
- delegate: K(xe, C, "11111111111111111111111111111111"),
2737
- state: Me($, {
2761
+ delegate: K(xe, b, "11111111111111111111111111111111"),
2762
+ state: Me(S, {
2738
2763
  uninitialized: 0,
2739
2764
  initialized: 1,
2740
2765
  frozen: 2
2741
2766
  }),
2742
2767
  isNative: K(xe, v, 0n),
2743
2768
  delegateAmount: v,
2744
- closeAuthority: K(xe, C, "11111111111111111111111111111111")
2769
+ closeAuthority: K(xe, b, "11111111111111111111111111111111")
2745
2770
  });
2746
- function ot(t, e, r) {
2771
+ function st(t, e, r) {
2747
2772
  if (!e.length)
2748
2773
  throw new Error("SOLPublic: empty instructions array");
2749
2774
  return hn.encode(Ie.encode({
@@ -2763,7 +2788,7 @@ function On(t) {
2763
2788
  throw new TypeError(d + " is ambiguous");
2764
2789
  e[h] = c;
2765
2790
  }
2766
- const r = t.length, n = t.charAt(0), s = Math.log(r) / Math.log(256), o = Math.log(256) / Math.log(r);
2791
+ const r = t.length, n = t.charAt(0), o = Math.log(r) / Math.log(256), s = Math.log(256) / Math.log(r);
2767
2792
  function a(c) {
2768
2793
  if (c instanceof Uint8Array || (ArrayBuffer.isView(c) ? c = new Uint8Array(c.buffer, c.byteOffset, c.byteLength) : Array.isArray(c) && (c = Uint8Array.from(c))), !(c instanceof Uint8Array))
2769
2794
  throw new TypeError("Expected Uint8Array");
@@ -2773,22 +2798,22 @@ function On(t) {
2773
2798
  const u = c.length;
2774
2799
  for (; f !== u && c[f] === 0; )
2775
2800
  f++, d++;
2776
- const p = (u - f) * o + 1 >>> 0, b = new Uint8Array(p);
2801
+ const g = (u - f) * s + 1 >>> 0, y = new Uint8Array(g);
2777
2802
  for (; f !== u; ) {
2778
- let m = c[f], w = 0;
2779
- for (let E = p - 1; (m !== 0 || w < h) && E !== -1; E--, w++)
2780
- m += 256 * b[E] >>> 0, b[E] = m % r >>> 0, m = m / r >>> 0;
2781
- if (m !== 0)
2803
+ let C = c[f], p = 0;
2804
+ for (let k = g - 1; (C !== 0 || p < h) && k !== -1; k--, p++)
2805
+ C += 256 * y[k] >>> 0, y[k] = C % r >>> 0, C = C / r >>> 0;
2806
+ if (C !== 0)
2782
2807
  throw new Error("Non-zero carry");
2783
- h = w, f++;
2808
+ h = p, f++;
2784
2809
  }
2785
- let y = p - h;
2786
- for (; y !== p && b[y] === 0; )
2787
- y++;
2788
- let I = n.repeat(d);
2789
- for (; y < p; ++y)
2790
- I += t.charAt(b[y]);
2791
- return I;
2810
+ let w = g - h;
2811
+ for (; w !== g && y[w] === 0; )
2812
+ w++;
2813
+ let _ = n.repeat(d);
2814
+ for (; w < g; ++w)
2815
+ _ += t.charAt(y[w]);
2816
+ return _;
2792
2817
  }
2793
2818
  function i(c) {
2794
2819
  if (typeof c != "string")
@@ -2798,29 +2823,29 @@ function On(t) {
2798
2823
  let d = 0, h = 0, f = 0;
2799
2824
  for (; c[d] === n; )
2800
2825
  h++, d++;
2801
- const u = (c.length - d) * s + 1 >>> 0, p = new Uint8Array(u);
2826
+ const u = (c.length - d) * o + 1 >>> 0, g = new Uint8Array(u);
2802
2827
  for (; d < c.length; ) {
2803
- const m = c.charCodeAt(d);
2804
- if (m > 255)
2828
+ const C = c.charCodeAt(d);
2829
+ if (C > 255)
2805
2830
  return;
2806
- let w = e[m];
2807
- if (w === 255)
2831
+ let p = e[C];
2832
+ if (p === 255)
2808
2833
  return;
2809
- let E = 0;
2810
- for (let L = u - 1; (w !== 0 || E < f) && L !== -1; L--, E++)
2811
- w += r * p[L] >>> 0, p[L] = w % 256 >>> 0, w = w / 256 >>> 0;
2812
- if (w !== 0)
2834
+ let k = 0;
2835
+ for (let L = u - 1; (p !== 0 || k < f) && L !== -1; L--, k++)
2836
+ p += r * g[L] >>> 0, g[L] = p % 256 >>> 0, p = p / 256 >>> 0;
2837
+ if (p !== 0)
2813
2838
  throw new Error("Non-zero carry");
2814
- f = E, d++;
2839
+ f = k, d++;
2815
2840
  }
2816
- let b = u - f;
2817
- for (; b !== u && p[b] === 0; )
2818
- b++;
2819
- const y = new Uint8Array(h + (u - b));
2820
- let I = h;
2821
- for (; b !== u; )
2822
- y[I++] = p[b++];
2823
- return y;
2841
+ let y = u - f;
2842
+ for (; y !== u && g[y] === 0; )
2843
+ y++;
2844
+ const w = new Uint8Array(h + (u - y));
2845
+ let _ = h;
2846
+ for (; y !== u; )
2847
+ w[_++] = g[y++];
2848
+ return w;
2824
2849
  }
2825
2850
  function l(c) {
2826
2851
  const d = i(c);
@@ -2849,15 +2874,15 @@ class Oe {
2849
2874
  return this._instructions.push(...e), this;
2850
2875
  }
2851
2876
  static from(e) {
2852
- const r = e instanceof Uint8Array ? e : new Uint8Array(e), n = Ie.decode(r), s = new Oe();
2853
- return s._transaction = n, s;
2877
+ const r = e instanceof Uint8Array ? e : new Uint8Array(e), n = Ie.decode(r), o = new Oe();
2878
+ return o._transaction = n, o;
2854
2879
  }
2855
2880
  serialize(e) {
2856
2881
  if (this._transaction)
2857
2882
  return Buffer.from(Ie.encode(this._transaction));
2858
2883
  if (!this.feePayer || !this.recentBlockhash)
2859
2884
  throw new Error("Transaction requires feePayer and recentBlockhash");
2860
- const r = ot(
2885
+ const r = st(
2861
2886
  this.feePayer.toString(),
2862
2887
  this._instructions,
2863
2888
  this.recentBlockhash
@@ -2867,7 +2892,7 @@ class Oe {
2867
2892
  serializeMessage() {
2868
2893
  if (!this.feePayer || !this.recentBlockhash)
2869
2894
  throw new Error("Transaction requires feePayer and recentBlockhash");
2870
- const e = ot(
2895
+ const e = st(
2871
2896
  this.feePayer.toString(),
2872
2897
  this._instructions,
2873
2898
  this.recentBlockhash
@@ -2943,11 +2968,11 @@ class Fn {
2943
2968
  if (!this.isAvailable() || !this.account)
2944
2969
  throw new Error("Phantom is not connected");
2945
2970
  try {
2946
- const r = Oe.from(e), s = await this.getProvider().signAndSendTransaction(r);
2971
+ const r = Oe.from(e), o = await this.getProvider().signAndSendTransaction(r);
2947
2972
  return {
2948
2973
  success: !0,
2949
2974
  wallet: this.type,
2950
- result: s
2975
+ result: o
2951
2976
  };
2952
2977
  } catch (r) {
2953
2978
  return console.error("Error sending transaction with Phantom:", r), {
@@ -3134,16 +3159,16 @@ class Wn {
3134
3159
  constructor() {
3135
3160
  if (this.walletAdapters = /* @__PURE__ */ new Map(), typeof window > "u")
3136
3161
  return;
3137
- const e = new sn();
3162
+ const e = new on();
3138
3163
  this.walletAdapters.set("metamask", e);
3139
3164
  const r = new Fn();
3140
3165
  this.walletAdapters.set("phantom", r);
3141
3166
  const n = new Qn();
3142
3167
  this.walletAdapters.set("phantom-evm", n);
3143
- const s = new Jr();
3144
- this.walletAdapters.set("argent", s);
3145
- const o = new jn();
3146
- this.walletAdapters.set("braavos", o);
3168
+ const o = new Jr();
3169
+ this.walletAdapters.set("argent", o);
3170
+ const s = new jn();
3171
+ this.walletAdapters.set("braavos", s);
3147
3172
  const a = new Hn();
3148
3173
  this.walletAdapters.set("rabby", a);
3149
3174
  const i = new nn();
@@ -3158,7 +3183,7 @@ class Wn {
3158
3183
  externalSendTransaction: (e) => (r, n) => this.sendTransaction(r, n),
3159
3184
  externalGetBalance: (e) => (r, n) => this.getBalance(r, n),
3160
3185
  externalSwitchChain: (e) => (r, n) => this.switchChain(r, n),
3161
- externalWaitForTransaction: (e) => (r, n, s) => this.waitForTransaction(r, n, s)
3186
+ externalWaitForTransaction: (e) => (r, n, o) => this.waitForTransaction(r, n, o)
3162
3187
  };
3163
3188
  }
3164
3189
  async detectWallets() {
@@ -3172,18 +3197,18 @@ class Wn {
3172
3197
  throw new Error(`Unsupported wallet type: ${e}`);
3173
3198
  return r;
3174
3199
  }
3175
- handleError(e, r, n, s) {
3176
- const o = r instanceof Error ? r.message : "Unknown error";
3200
+ handleError(e, r, n, o) {
3201
+ const s = r instanceof Error ? r.message : "Unknown error";
3177
3202
  let a = "unknown";
3178
3203
  if (typeof e == "string") {
3179
3204
  const i = this.getConnectedWalletAdapter(e);
3180
- a = s ?? i?.type ?? e;
3205
+ a = o ?? i?.type ?? e;
3181
3206
  } else
3182
3207
  a = e;
3183
3208
  return console.error(`Error ${n} with ${e} wallet:`, r), {
3184
3209
  success: !1,
3185
3210
  wallet: a,
3186
- error: o
3211
+ error: s
3187
3212
  };
3188
3213
  }
3189
3214
  async connectWallet(e) {
@@ -3215,7 +3240,7 @@ class Wn {
3215
3240
  throw new Error(`Wallet ${e} is not connected or supported`);
3216
3241
  return r;
3217
3242
  }
3218
- if (r = this.walletAdapters.values().find((s) => s.getConnectedAccounts().includes(n)), !r)
3243
+ if (r = this.walletAdapters.values().find((o) => o.getConnectedAccounts().includes(n)), !r)
3219
3244
  throw new Error(`No wallet found with connected address ${e}`);
3220
3245
  return r;
3221
3246
  }
@@ -3227,10 +3252,10 @@ class Wn {
3227
3252
  `Wallet type ${n.type} (identifier: ${e}) does not support signing messages`
3228
3253
  );
3229
3254
  return await n.signMessage(r, e);
3230
- } catch (s) {
3255
+ } catch (o) {
3231
3256
  return this.handleError(
3232
3257
  e,
3233
- s,
3258
+ o,
3234
3259
  "signing message with",
3235
3260
  n?.type
3236
3261
  );
@@ -3244,10 +3269,10 @@ class Wn {
3244
3269
  `Wallet type ${n.type} (identifier: ${e}) does not support signing typed data`
3245
3270
  );
3246
3271
  return await n.signTypedData(r);
3247
- } catch (s) {
3272
+ } catch (o) {
3248
3273
  return this.handleError(
3249
3274
  e,
3250
- s,
3275
+ o,
3251
3276
  "signing typed data with",
3252
3277
  n?.type
3253
3278
  );
@@ -3257,10 +3282,10 @@ class Wn {
3257
3282
  let n;
3258
3283
  try {
3259
3284
  return n = this.getConnectedWalletAdapter(e), await n.sendTransaction(r);
3260
- } catch (s) {
3285
+ } catch (o) {
3261
3286
  return this.handleError(
3262
3287
  e,
3263
- s,
3288
+ o,
3264
3289
  "sending transaction with",
3265
3290
  n?.type
3266
3291
  );
@@ -3270,10 +3295,10 @@ class Wn {
3270
3295
  let n;
3271
3296
  try {
3272
3297
  return n = this.getConnectedWalletAdapter(e), await n.getBalance(r);
3273
- } catch (s) {
3298
+ } catch (o) {
3274
3299
  return this.handleError(
3275
3300
  e,
3276
- s,
3301
+ o,
3277
3302
  "getting balance from",
3278
3303
  n?.type
3279
3304
  );
@@ -3287,15 +3312,15 @@ class Wn {
3287
3312
  }
3288
3313
  }
3289
3314
  async waitForTransaction(e, r, n) {
3290
- let s;
3315
+ let o;
3291
3316
  try {
3292
- return s = this.getConnectedWalletAdapter(e), await s.waitForTransaction(r, n);
3293
- } catch (o) {
3317
+ return o = this.getConnectedWalletAdapter(e), await o.waitForTransaction(r, n);
3318
+ } catch (s) {
3294
3319
  return this.handleError(
3295
3320
  e,
3296
- o,
3321
+ s,
3297
3322
  "waiting for transaction with",
3298
- s?.type
3323
+ o?.type
3299
3324
  );
3300
3325
  }
3301
3326
  }
@@ -3306,8 +3331,8 @@ class Yn extends wr {
3306
3331
  url: e,
3307
3332
  policies: r,
3308
3333
  version: n,
3309
- slot: s,
3310
- namespace: o,
3334
+ slot: o,
3335
+ namespace: s,
3311
3336
  tokens: a,
3312
3337
  preset: i,
3313
3338
  shouldOverridePresetPolicies: l,
@@ -3316,30 +3341,31 @@ class Yn extends wr {
3316
3341
  refGroup: h,
3317
3342
  needsSessionCreation: f,
3318
3343
  username: u,
3319
- onSessionCreated: p,
3320
- encryptedBlob: b,
3321
- propagateSessionErrors: y,
3322
- ...I
3344
+ onSessionCreated: g,
3345
+ encryptedBlob: y,
3346
+ propagateSessionErrors: w,
3347
+ errorDisplayMode: _,
3348
+ ...C
3323
3349
  }) {
3324
- const m = new URL(e ?? lt), w = new Wn();
3325
- y && m.searchParams.set("propagate_error", "true"), n && m.searchParams.set("v", encodeURIComponent(n)), s && m.searchParams.set("ps", encodeURIComponent(s)), o && m.searchParams.set("ns", encodeURIComponent(o)), a?.erc20 && m.searchParams.set(
3350
+ const p = new URL(e ?? lt), k = new Wn();
3351
+ w && p.searchParams.set("propagate_error", "true"), _ && p.searchParams.set("error_display_mode", _), n && p.searchParams.set("v", encodeURIComponent(n)), o && p.searchParams.set("ps", encodeURIComponent(o)), s && p.searchParams.set("ns", encodeURIComponent(s)), a?.erc20 && p.searchParams.set(
3326
3352
  "erc20",
3327
3353
  encodeURIComponent(a.erc20.toString())
3328
- ), c && m.searchParams.set("rpc_url", encodeURIComponent(c)), d && m.searchParams.set("ref", encodeURIComponent(d)), h && m.searchParams.set("ref_group", encodeURIComponent(h)), f && m.searchParams.set("needs_session_creation", "true"), u && m.searchParams.set("username", encodeURIComponent(u)), (!i || l) && r ? m.searchParams.set(
3354
+ ), c && p.searchParams.set("rpc_url", encodeURIComponent(c)), d && p.searchParams.set("ref", encodeURIComponent(d)), h && p.searchParams.set("ref_group", encodeURIComponent(h)), f && p.searchParams.set("needs_session_creation", "true"), u && p.searchParams.set("username", encodeURIComponent(u)), (!i || l) && r ? p.searchParams.set(
3329
3355
  "policies",
3330
3356
  encodeURIComponent(JSON.stringify(r))
3331
- ) : i && m.searchParams.set("preset", i), b && (m.hash = `kc=${encodeURIComponent(b)}`), super({
3332
- ...I,
3357
+ ) : i && p.searchParams.set("preset", i), y && (p.hash = `kc=${encodeURIComponent(y)}`), super({
3358
+ ...C,
3333
3359
  id: "controller-keychain",
3334
- url: m,
3360
+ url: p,
3335
3361
  methods: {
3336
- ...w.getIFrameMethods(),
3362
+ ...k.getIFrameMethods(),
3337
3363
  // Expose callback for keychain to notify parent that session was created and storage access granted
3338
- onSessionCreated: (E) => () => {
3339
- p && p();
3364
+ onSessionCreated: (L) => () => {
3365
+ g && g();
3340
3366
  }
3341
3367
  }
3342
- }), this.walletBridge = w, typeof window < "u" && (window.external_wallets = this.walletBridge);
3368
+ }), this.walletBridge = k, typeof window < "u" && (window.external_wallets = this.walletBridge);
3343
3369
  }
3344
3370
  getWalletBridge() {
3345
3371
  return this.walletBridge;
@@ -3368,8 +3394,8 @@ function Vn(t) {
3368
3394
  error: "URL must have a valid hostname"
3369
3395
  };
3370
3396
  if (typeof window < "u") {
3371
- const n = window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1", s = e.hostname === "localhost" || e.hostname === "127.0.0.1";
3372
- if (!n && s)
3397
+ const n = window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1", o = e.hostname === "localhost" || e.hostname === "127.0.0.1";
3398
+ if (!n && o)
3373
3399
  return {
3374
3400
  isValid: !1,
3375
3401
  error: "Cannot redirect to localhost from production"
@@ -3377,7 +3403,7 @@ function Vn(t) {
3377
3403
  }
3378
3404
  return { isValid: !0 };
3379
3405
  }
3380
- class vs extends Wt {
3406
+ class _o extends Wt {
3381
3407
  keychain;
3382
3408
  options;
3383
3409
  iframes;
@@ -3393,30 +3419,30 @@ class vs extends Wt {
3393
3419
  const n = [...[
3394
3420
  { rpcUrl: "https://api.cartridge.gg/x/starknet/sepolia/rpc/v0_9" },
3395
3421
  { rpcUrl: "https://api.cartridge.gg/x/starknet/mainnet/rpc/v0_9" }
3396
- ], ...e.chains || []], s = e.defaultChainId || Z.StarknetChainId.SN_MAIN;
3397
- this.selectedChain = s, this.chains = /* @__PURE__ */ new Map();
3398
- const o = typeof window < "u" ? new URLSearchParams(window.location.search) : null;
3422
+ ], ...e.chains || []], o = e.defaultChainId || Z.StarknetChainId.SN_MAIN;
3423
+ this.selectedChain = o, this.chains = /* @__PURE__ */ new Map();
3424
+ const s = typeof window < "u" ? new URLSearchParams(window.location.search) : null;
3399
3425
  if (this.referral = {
3400
- ref: o?.get("ref") ?? void 0,
3401
- refGroup: o?.get("ref_group") ?? void 0
3402
- }, this.options = { ...e, chains: n, defaultChainId: s }, typeof window < "u" && typeof localStorage < "u") {
3403
- const a = o?.get("controller_standalone");
3426
+ ref: s?.get("ref") ?? void 0,
3427
+ refGroup: s?.get("ref_group") ?? void 0
3428
+ }, this.options = { ...e, chains: n, defaultChainId: o }, typeof window < "u" && typeof localStorage < "u") {
3429
+ const a = s?.get("controller_standalone");
3404
3430
  a === "1" && sessionStorage.setItem("controller_standalone", "1");
3405
- const i = o?.get("lastUsedConnector");
3431
+ const i = s?.get("lastUsedConnector");
3406
3432
  if (i && localStorage.setItem("lastUsedConnector", i), window.location.hash) {
3407
3433
  const c = new URLSearchParams(window.location.hash.slice(1)).get("kc");
3408
3434
  c && (this.encryptedBlob = c);
3409
3435
  }
3410
- if (o && window.history?.replaceState) {
3436
+ if (s && window.history?.replaceState) {
3411
3437
  let l = !1;
3412
- a && (o.delete("controller_standalone"), l = !0), i && (o.delete("lastUsedConnector"), l = !0);
3438
+ a && (s.delete("controller_standalone"), l = !0), i && (s.delete("lastUsedConnector"), l = !0);
3413
3439
  let c = window.location.hash;
3414
3440
  if (c) {
3415
3441
  const d = new URLSearchParams(c.slice(1));
3416
3442
  d.has("kc") && (d.delete("kc"), c = d.toString() ? `#${d.toString()}` : "", l = !0);
3417
3443
  }
3418
3444
  if (l) {
3419
- const d = window.location.pathname + (o.toString() ? "?" + o.toString() : "") + c;
3445
+ const d = window.location.pathname + (s.toString() ? "?" + s.toString() : "") + c;
3420
3446
  window.history.replaceState({}, "", d);
3421
3447
  }
3422
3448
  }
@@ -3427,7 +3453,7 @@ class vs extends Wt {
3427
3453
  }
3428
3454
  async logout() {
3429
3455
  if (!this.keychain) {
3430
- console.error(new _().message);
3456
+ console.error(new A().message);
3431
3457
  return;
3432
3458
  }
3433
3459
  try {
@@ -3445,7 +3471,7 @@ class vs extends Wt {
3445
3471
  if (this.iframes) {
3446
3472
  try {
3447
3473
  if (this.iframes.keychain || (this.iframes.keychain = this.createKeychainIframe()), await this.waitForKeychain(), !this.keychain) {
3448
- console.error(new _().message);
3474
+ console.error(new A().message);
3449
3475
  return;
3450
3476
  }
3451
3477
  const e = await this.keychain.probe(this.rpcUrl());
@@ -3470,14 +3496,14 @@ class vs extends Wt {
3470
3496
  if (this.account)
3471
3497
  return this.account;
3472
3498
  if (this.iframes.keychain || (this.iframes.keychain = this.createKeychainIframe(), await this.waitForKeychain()), !this.keychain || !this.iframes.keychain) {
3473
- console.error(new _().message);
3499
+ console.error(new A().message);
3474
3500
  return;
3475
3501
  }
3476
3502
  this.iframes.keychain.open();
3477
3503
  try {
3478
3504
  const r = e ?? this.options.signupOptions;
3479
3505
  let n = await this.keychain.connect(r);
3480
- if (n.code !== Q.SUCCESS)
3506
+ if (n.code !== T.SUCCESS)
3481
3507
  throw new Error(n.message);
3482
3508
  return n = n, this.account = new He(
3483
3509
  this,
@@ -3498,7 +3524,7 @@ class vs extends Wt {
3498
3524
  if (!this.iframes)
3499
3525
  return !1;
3500
3526
  if (!this.keychain || !this.iframes.keychain)
3501
- return console.error(new _().message), !1;
3527
+ return console.error(new A().message), !1;
3502
3528
  const r = this.selectedChain;
3503
3529
  try {
3504
3530
  this.selectedChain = e, await this.keychain.switchChain(this.rpcUrl());
@@ -3512,7 +3538,7 @@ class vs extends Wt {
3512
3538
  }
3513
3539
  async disconnect() {
3514
3540
  if (!this.keychain) {
3515
- console.error(new _().message);
3541
+ console.error(new A().message);
3516
3542
  return;
3517
3543
  }
3518
3544
  return this.account = void 0, this.keychain.disconnect();
@@ -3521,7 +3547,7 @@ class vs extends Wt {
3521
3547
  if (!this.iframes)
3522
3548
  return;
3523
3549
  if (!this.keychain || !this.iframes.keychain) {
3524
- console.error(new _().message);
3550
+ console.error(new A().message);
3525
3551
  return;
3526
3552
  }
3527
3553
  if (!this.account) {
@@ -3537,7 +3563,7 @@ class vs extends Wt {
3537
3563
  if (!this.iframes)
3538
3564
  return;
3539
3565
  if (!this.keychain || !this.iframes.keychain) {
3540
- console.error(new _().message);
3566
+ console.error(new A().message);
3541
3567
  return;
3542
3568
  }
3543
3569
  if (!this.account) {
@@ -3552,7 +3578,7 @@ class vs extends Wt {
3552
3578
  async openProfileAt(e) {
3553
3579
  if (this.iframes) {
3554
3580
  if (!this.keychain || !this.iframes.keychain) {
3555
- console.error(new _().message);
3581
+ console.error(new A().message);
3556
3582
  return;
3557
3583
  }
3558
3584
  if (!this.account) {
@@ -3565,14 +3591,14 @@ class vs extends Wt {
3565
3591
  openSettings() {
3566
3592
  if (this.iframes) {
3567
3593
  if (!this.keychain || !this.iframes.keychain) {
3568
- console.error(new _().message);
3594
+ console.error(new A().message);
3569
3595
  return;
3570
3596
  }
3571
3597
  this.iframes.keychain.open(), this.keychain.openSettings();
3572
3598
  }
3573
3599
  }
3574
3600
  revoke(e, r) {
3575
- return this.keychain ? this.keychain.revoke(e) : (console.error(new _().message), null);
3601
+ return this.keychain ? this.keychain.revoke(e) : (console.error(new A().message), null);
3576
3602
  }
3577
3603
  rpcUrl() {
3578
3604
  const e = this.chains.get(this.selectedChain);
@@ -3588,7 +3614,7 @@ class vs extends Wt {
3588
3614
  }
3589
3615
  username() {
3590
3616
  if (!this.keychain) {
3591
- console.error(new _().message);
3617
+ console.error(new A().message);
3592
3618
  return;
3593
3619
  }
3594
3620
  return this.keychain.username();
@@ -3596,7 +3622,7 @@ class vs extends Wt {
3596
3622
  openPurchaseCredits() {
3597
3623
  if (this.iframes) {
3598
3624
  if (!this.keychain || !this.iframes.keychain) {
3599
- console.error(new _().message);
3625
+ console.error(new A().message);
3600
3626
  return;
3601
3627
  }
3602
3628
  this.keychain.navigate("/purchase/credits").then(() => {
@@ -3607,7 +3633,7 @@ class vs extends Wt {
3607
3633
  async openStarterPack(e, r) {
3608
3634
  if (this.iframes) {
3609
3635
  if (!this.keychain || !this.iframes.keychain) {
3610
- console.error(new _().message);
3636
+ console.error(new A().message);
3611
3637
  return;
3612
3638
  }
3613
3639
  await this.keychain.openStarterPack(e, r), this.iframes.keychain?.open();
@@ -3617,19 +3643,19 @@ class vs extends Wt {
3617
3643
  if (!this.iframes)
3618
3644
  return;
3619
3645
  if (!this.keychain || !this.iframes.keychain) {
3620
- console.error(new _().message);
3646
+ console.error(new A().message);
3621
3647
  return;
3622
3648
  }
3623
3649
  let n = this.selectedChain;
3624
3650
  r && this.switchStarknetChain(r), this.iframes.keychain.open();
3625
- const s = await this.keychain.execute(e, void 0, void 0, !0);
3651
+ const o = await this.keychain.execute(e, void 0, void 0, !0);
3626
3652
  return this.iframes.keychain.close(), r && this.switchStarknetChain(n), {
3627
- status: !(s && (s.code === Q.NOT_CONNECTED || s.code === Q.CANCELED)),
3628
- transactionHash: s?.transaction_hash
3653
+ status: !(o && (o.code === T.NOT_CONNECTED || o.code === T.CANCELED)),
3654
+ transactionHash: o?.transaction_hash
3629
3655
  };
3630
3656
  }
3631
3657
  async delegateAccount() {
3632
- return this.keychain ? await this.keychain.delegateAccount() : (console.error(new _().message), null);
3658
+ return this.keychain ? await this.keychain.delegateAccount() : (console.error(new A().message), null);
3633
3659
  }
3634
3660
  /**
3635
3661
  * Opens the keychain in standalone mode (first-party context) for authentication.
@@ -3641,10 +3667,10 @@ class vs extends Wt {
3641
3667
  console.error("open can only be called in browser context");
3642
3668
  return;
3643
3669
  }
3644
- const r = new URL(this.options.url || lt), n = e.redirectUrl || window.location.href, s = Vn(n);
3645
- if (!s.isValid) {
3670
+ const r = new URL(this.options.url || lt), n = e.redirectUrl || window.location.href, o = Vn(n);
3671
+ if (!o.isValid) {
3646
3672
  console.error(
3647
- `Invalid redirect URL: ${s.error}`,
3673
+ `Invalid redirect URL: ${o.error}`,
3648
3674
  `URL: ${n}`
3649
3675
  );
3650
3676
  return;
@@ -3657,12 +3683,12 @@ class vs extends Wt {
3657
3683
  initializeChains(e) {
3658
3684
  for (const r of e)
3659
3685
  try {
3660
- const n = new URL(r.rpcUrl), s = Yt(n), o = s === Z.StarknetChainId.SN_MAIN, a = s === Z.StarknetChainId.SN_SEPOLIA, i = n.hostname === "api.cartridge.gg", l = n.hostname === "localhost" || n.hostname === "127.0.0.1";
3661
- if ((o || a) && !(i || l))
3686
+ const n = new URL(r.rpcUrl), o = Yt(n), s = o === Z.StarknetChainId.SN_MAIN, a = o === Z.StarknetChainId.SN_SEPOLIA, i = n.hostname === "api.cartridge.gg", l = n.hostname === "localhost" || n.hostname === "127.0.0.1";
3687
+ if ((s || a) && !(i || l))
3662
3688
  throw new Error(
3663
- `Only Cartridge RPC providers are allowed for ${o ? "mainnet" : "sepolia"}. Please use: https://api.cartridge.gg/x/starknet/${o ? "mainnet" : "sepolia"}/rpc/v0_9`
3689
+ `Only Cartridge RPC providers are allowed for ${s ? "mainnet" : "sepolia"}. Please use: https://api.cartridge.gg/x/starknet/${s ? "mainnet" : "sepolia"}/rpc/v0_9`
3664
3690
  );
3665
- this.chains.set(s, r);
3691
+ this.chains.set(o, r);
3666
3692
  } catch (n) {
3667
3693
  throw console.error(`Failed to parse chainId for ${r.rpcUrl}:`, n), n;
3668
3694
  }
@@ -3671,9 +3697,9 @@ class vs extends Wt {
3671
3697
  );
3672
3698
  }
3673
3699
  createKeychainIframe() {
3674
- const e = typeof window < "u" && typeof sessionStorage < "u" && sessionStorage.getItem("controller_standalone") === "1", n = (typeof window < "u" ? new URLSearchParams(window.location.search) : void 0)?.get("username") ?? void 0, s = this.encryptedBlob;
3675
- e && sessionStorage.removeItem("controller_standalone"), s && (this.encryptedBlob = void 0);
3676
- const o = new Yn({
3700
+ const e = typeof window < "u" && typeof sessionStorage < "u" && sessionStorage.getItem("controller_standalone") === "1", n = (typeof window < "u" ? new URLSearchParams(window.location.search) : void 0)?.get("username") ?? void 0, o = this.encryptedBlob;
3701
+ e && sessionStorage.removeItem("controller_standalone"), o && (this.encryptedBlob = void 0);
3702
+ const s = new Yn({
3677
3703
  ...this.options,
3678
3704
  rpcUrl: this.rpcUrl(),
3679
3705
  onClose: this.keychain?.reset,
@@ -3684,24 +3710,24 @@ class vs extends Wt {
3684
3710
  ref: this.referral.ref,
3685
3711
  refGroup: this.referral.refGroup,
3686
3712
  needsSessionCreation: e,
3687
- encryptedBlob: s ?? void 0,
3713
+ encryptedBlob: o ?? void 0,
3688
3714
  username: n,
3689
3715
  onSessionCreated: async () => {
3690
3716
  await this.probe();
3691
3717
  }
3692
3718
  });
3693
3719
  return e && setTimeout(() => {
3694
- o.open();
3695
- }, 100), o;
3720
+ s.open();
3721
+ }, 100), s;
3696
3722
  }
3697
3723
  waitForKeychain({
3698
3724
  timeout: e = 5e4,
3699
3725
  interval: r = 100
3700
3726
  } = {}) {
3701
- return new Promise((n, s) => {
3702
- const o = Date.now(), a = setInterval(() => {
3703
- if (Date.now() - o > e) {
3704
- clearInterval(a), s(new Error("Timeout waiting for keychain"));
3727
+ return new Promise((n, o) => {
3728
+ const s = Date.now(), a = setInterval(() => {
3729
+ if (Date.now() - s > e) {
3730
+ clearInterval(a), o(new Error("Timeout waiting for keychain"));
3705
3731
  return;
3706
3732
  }
3707
3733
  this.keychain && (clearInterval(a), n());
@@ -3724,7 +3750,7 @@ async function zt(t) {
3724
3750
  throw new Error(`HTTP error! status: ${e.status}`);
3725
3751
  return e.json();
3726
3752
  }
3727
- async function ks(t) {
3753
+ async function Ao(t) {
3728
3754
  const e = t.filter((r) => !H.has(r));
3729
3755
  return e.length > 0 && (await zt({ usernames: e })).results.forEach((n) => {
3730
3756
  H.set(n.username, n.addresses[0]);
@@ -3732,7 +3758,7 @@ async function ks(t) {
3732
3758
  t.map((r) => [r, H.get(r)]).filter((r) => r[1] !== void 0)
3733
3759
  );
3734
3760
  }
3735
- async function Es(t) {
3761
+ async function Io(t) {
3736
3762
  t = t.map(ct.toHex);
3737
3763
  const e = t.filter((r) => !H.has(r));
3738
3764
  return e.length > 0 && (await zt({
@@ -3776,9 +3802,9 @@ function Jn(t) {
3776
3802
  if (t.getElementById("cartridge-toast-styles"))
3777
3803
  return;
3778
3804
  const e = t.createElement("style");
3779
- e.id = "cartridge-toast-styles", e.textContent = es(), t.head.appendChild(e);
3805
+ e.id = "cartridge-toast-styles", e.textContent = eo(), t.head.appendChild(e);
3780
3806
  }
3781
- function es() {
3807
+ function eo() {
3782
3808
  return `
3783
3809
  #${x} {
3784
3810
  position: fixed;
@@ -3913,14 +3939,14 @@ const ee = (t = !1) => {
3913
3939
  r.className = t ? "cartridge-close-button translucent" : "cartridge-close-button";
3914
3940
  const n = document.createElementNS("http://www.w3.org/2000/svg", "svg");
3915
3941
  n.setAttribute("width", "20"), n.setAttribute("height", "20"), n.setAttribute("viewBox", "0 0 20 20"), n.setAttribute("fill", "none"), n.style.pointerEvents = "none";
3916
- const s = document.createElementNS("http://www.w3.org/2000/svg", "path");
3917
- s.setAttribute(
3942
+ const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
3943
+ o.setAttribute(
3918
3944
  "d",
3919
3945
  "M15.5465 14.343C15.8881 14.6837 15.8881 15.2364 15.5465 15.5772C15.2049 15.9179 14.6506 15.9178 14.309 15.5772L10.0006 11.2484L5.66162 15.5757C5.32001 15.9164 4.76575 15.9164 4.4241 15.5757C4.08245 15.235 4.08249 14.6822 4.4241 14.3415L8.76455 10.0157L4.4229 5.65573C4.08128 5.31504 4.08128 4.76227 4.4229 4.42155C4.76451 4.08082 5.31877 4.08086 5.66042 4.42155L10.0006 8.78299L14.3396 4.45573C14.6812 4.11504 15.2355 4.11504 15.5771 4.45573C15.9188 4.79642 15.9187 5.34918 15.5771 5.68991L11.2367 10.0157L15.5465 14.343Z"
3920
- ), s.setAttribute("class", "cartridge-close-icon"), n.appendChild(s), r.appendChild(n), r.style.display = "flex", r.style.alignItems = "center", r.style.justifyContent = "center", r.style.border = "none", r.style.background = "transparent", r.style.cursor = "pointer", r.style.borderRadius = "4px", r.style.padding = "10px", r.style.gap = "4px", r.style.transition = "background-color 0.2s ease";
3921
- const o = e.ownerDocument;
3922
- if (!o.getElementById("cartridge-close-button-style")) {
3923
- const a = o.createElement("style");
3946
+ ), o.setAttribute("class", "cartridge-close-icon"), n.appendChild(o), r.appendChild(n), r.style.display = "flex", r.style.alignItems = "center", r.style.justifyContent = "center", r.style.border = "none", r.style.background = "transparent", r.style.cursor = "pointer", r.style.borderRadius = "4px", r.style.padding = "10px", r.style.gap = "4px", r.style.transition = "background-color 0.2s ease";
3947
+ const s = e.ownerDocument;
3948
+ if (!s.getElementById("cartridge-close-button-style")) {
3949
+ const a = s.createElement("style");
3924
3950
  a.id = "cartridge-close-button-style", a.textContent = `
3925
3951
  .cartridge-close-button .cartridge-close-icon {
3926
3952
  fill: rgba(0, 0, 0, 0.48);
@@ -3950,11 +3976,11 @@ const ee = (t = !1) => {
3950
3976
  .cartridge-close-button:active {
3951
3977
  transform: scale(0.95);
3952
3978
  }
3953
- `, o.head.appendChild(a);
3979
+ `, s.head.appendChild(a);
3954
3980
  }
3955
3981
  return e.appendChild(r), e;
3956
3982
  };
3957
- function ts(t) {
3983
+ function to(t) {
3958
3984
  if (t.getElementById("cartridge-toast-error-styles"))
3959
3985
  return;
3960
3986
  const e = t.createElement("style");
@@ -3969,6 +3995,17 @@ function ts(t) {
3969
3995
  position: relative;
3970
3996
  overflow: hidden;
3971
3997
  box-sizing: border-box;
3998
+ transition: background-color 0.2s ease, transform 0.1s ease;
3999
+ }
4000
+
4001
+ /* Clickable state */
4002
+ .cartridge-toast.error[style*="cursor: pointer"]:hover {
4003
+ background-color: #D85555;
4004
+ transform: translateY(-2px);
4005
+ }
4006
+
4007
+ .cartridge-toast.error[style*="cursor: pointer"]:active {
4008
+ transform: translateY(0);
3972
4009
  }
3973
4010
 
3974
4011
  .cartridge-toast.error .label-bar {
@@ -4017,27 +4054,27 @@ function ts(t) {
4017
4054
  }
4018
4055
  `, t.head.appendChild(e);
4019
4056
  }
4020
- function rs(t) {
4057
+ function ro(t) {
4021
4058
  const e = document.createElement("div");
4022
4059
  e.className = "cartridge-toast error";
4023
4060
  const r = document.createElement("div");
4024
4061
  r.className = "label-bar", e.appendChild(r);
4025
4062
  const n = document.createElement("div");
4026
4063
  n.className = "label-container", r.appendChild(n);
4027
- const s = document.createElement("div");
4028
- s.className = "icon-container", s.innerHTML = `
4064
+ const o = document.createElement("div");
4065
+ o.className = "icon-container", o.innerHTML = `
4029
4066
  <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18" fill="none">
4030
4067
  <path fill-rule="evenodd" clip-rule="evenodd" d="M9.79313 0.326989L17.673 8.20771C18.109 8.6437 18.109 9.35713 17.673 9.79229L9.79229 17.673C9.3563 18.109 8.6437 18.109 8.20771 17.673L0.326989 9.79229C-0.108996 9.35713 -0.108996 8.6437 0.326989 8.20771L8.20856 0.326989C8.64454 -0.108996 9.35715 -0.108996 9.79313 0.326989ZM8.26159 4.84378C8.26159 4.37794 8.63953 4 9.10537 4C9.57121 4 9.94915 4.3797 9.94915 4.84378V9.34394C9.94915 9.80978 9.57121 10.1877 9.13701 10.1877C8.70282 10.1877 8.26159 9.81154 8.26159 9.34394V4.84378ZM9.10537 13.5628C8.49503 13.5628 8.00002 13.0678 8.00002 12.4575C8.00002 11.8472 8.49468 11.3521 9.10537 11.3521C9.71605 11.3521 10.2107 11.8472 10.2107 12.4575C10.2093 13.0671 9.71711 13.5628 9.10537 13.5628Z" fill="#0F1410"/>
4031
4068
  </svg>
4032
- `, n.appendChild(s);
4033
- const o = document.createElement("p");
4034
- o.className = "content", o.textContent = t.message || "Error", n.appendChild(o);
4069
+ `, n.appendChild(o);
4070
+ const s = document.createElement("p");
4071
+ s.className = "content", s.textContent = t.message || "Error", n.appendChild(s);
4035
4072
  const a = document.createElement("div");
4036
4073
  a.className = "close-button-container";
4037
4074
  const i = ee(!0);
4038
4075
  return a.appendChild(i), e.appendChild(a), e;
4039
4076
  }
4040
- function ns(t) {
4077
+ function no(t) {
4041
4078
  if (t.getElementById("cartridge-toast-transaction-styles"))
4042
4079
  return;
4043
4080
  const e = t.createElement("style");
@@ -4174,28 +4211,28 @@ function ns(t) {
4174
4211
  }
4175
4212
  `, t.head.appendChild(e);
4176
4213
  }
4177
- function ss(t) {
4214
+ function oo(t) {
4178
4215
  const e = document.createElement("div");
4179
4216
  if (e.className = `cartridge-toast transaction ${t.isExpanded ? "expanded" : "collapsed"}`, t.isExpanded) {
4180
4217
  const r = document.createElement("div");
4181
4218
  r.className = "toast-content";
4182
4219
  const n = document.createElement("div");
4183
4220
  n.className = "label-bar";
4184
- const s = document.createElement("div");
4185
- s.className = "label-container";
4186
4221
  const o = document.createElement("div");
4187
- o.className = "icon-container", t.status === "confirming" ? (o.classList.add("spinning"), o.innerHTML = `
4222
+ o.className = "label-container";
4223
+ const s = document.createElement("div");
4224
+ s.className = "icon-container", t.status === "confirming" ? (s.classList.add("spinning"), s.innerHTML = `
4188
4225
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
4189
4226
  <path d="M11.1111 5.77756C11.1111 5.28673 11.5083 4.88867 12 4.88867C15.9278 4.88867 19.1111 8.07201 19.1111 11.9998C19.1111 13.2942 18.7639 14.5109 18.1583 15.5553C17.9139 15.9803 17.3694 16.1276 16.9194 15.8803C16.5194 15.6359 16.375 15.0914 16.6194 14.6414C17.0722 13.8831 17.3333 12.972 17.3333 11.9748C17.3333 9.03034 14.9444 6.64145 12 6.64145C11.5083 6.64145 11.1111 6.26839 11.1111 5.75256V5.77756Z" fill="white"/>
4190
4227
  <path opacity="0.25" d="M11.975 6.66645C9.03058 6.66645 6.64169 9.03034 6.64169 11.9998C6.64169 14.9442 9.03058 17.3331 11.975 17.3331C13.9472 17.3331 15.6472 16.2914 16.5806 14.7331L16.5834 14.7359C16.3917 15.1498 16.5417 15.647 16.9195 15.8803C17.3695 16.1276 17.9139 15.9803 18.1584 15.5553C18.1639 15.547 18.1695 15.5387 18.1722 15.5303C16.9472 17.6692 14.6417 19.1109 12 19.1109C8.07225 19.1109 4.88892 15.9276 4.88892 11.9998C4.88892 8.07201 8.07225 4.88867 12 4.88867C11.5084 4.88867 11.1111 5.28673 11.1111 5.77756C11.1111 6.26839 11.5084 6.66645 12 6.66645H11.975Z" fill="white" fill-opacity="0.64"/>
4191
4228
  </svg>
4192
- `) : o.innerHTML = `
4229
+ `) : s.innerHTML = `
4193
4230
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
4194
4231
  <path d="M8.36382 18.5465L4 14.1827L5.45427 12.7284L8.36382 15.638L18.5457 5.45508L20 6.91032L8.36382 18.5465Z" fill="#33FF33"/>
4195
4232
  </svg>
4196
4233
  `;
4197
4234
  const a = document.createElement("p");
4198
- if (a.className = "status", a.textContent = t.status === "confirming" ? "Confirming" : "Confirmed", s.appendChild(o), s.appendChild(a), t.label) {
4235
+ if (a.className = "status", a.textContent = t.status === "confirming" ? "Confirming" : "Confirmed", o.appendChild(s), o.appendChild(a), t.label) {
4199
4236
  const c = document.createElement("div");
4200
4237
  c.className = "activity-feed-container";
4201
4238
  const d = document.createElement("div");
@@ -4207,9 +4244,9 @@ function ss(t) {
4207
4244
  const h = document.createElement("div");
4208
4245
  h.className = "activity-label-container";
4209
4246
  const f = document.createElement("span");
4210
- f.className = "activity-label", f.textContent = t.label, h.appendChild(f), c.appendChild(d), c.appendChild(h), s.appendChild(c);
4247
+ f.className = "activity-label", f.textContent = t.label, h.appendChild(f), c.appendChild(d), c.appendChild(h), o.appendChild(c);
4211
4248
  }
4212
- n.appendChild(s), r.appendChild(n);
4249
+ n.appendChild(o), r.appendChild(n);
4213
4250
  const i = document.createElement("div");
4214
4251
  i.className = "close-button-container";
4215
4252
  const l = ee();
@@ -4229,7 +4266,7 @@ function ss(t) {
4229
4266
  }
4230
4267
  return e;
4231
4268
  }
4232
- function os(t) {
4269
+ function so(t) {
4233
4270
  if (t.getElementById("cartridge-toast-network-switch-styles"))
4234
4271
  return;
4235
4272
  const e = t.createElement("style");
@@ -4253,7 +4290,7 @@ function os(t) {
4253
4290
  }
4254
4291
  `, t.head.appendChild(e);
4255
4292
  }
4256
- function as(t) {
4293
+ function ao(t) {
4257
4294
  const e = document.createElement("div");
4258
4295
  e.className = "cartridge-toast network-switch";
4259
4296
  const r = document.createElement(t.networkIcon ? "img" : "div");
@@ -4261,7 +4298,7 @@ function as(t) {
4261
4298
  const n = document.createElement("p");
4262
4299
  return n.className = "content", n.textContent = `Switched to ${t.networkName}`, e.appendChild(r), e.appendChild(n), e;
4263
4300
  }
4264
- function is(t) {
4301
+ function io(t) {
4265
4302
  if (t.getElementById("cartridge-toast-achievement-styles"))
4266
4303
  return;
4267
4304
  const e = t.createElement("style");
@@ -4364,33 +4401,33 @@ function is(t) {
4364
4401
  }
4365
4402
  `, t.head.appendChild(e);
4366
4403
  }
4367
- function cs(t) {
4404
+ function co(t) {
4368
4405
  const e = document.createElement("div");
4369
4406
  e.className = "cartridge-toast achievement";
4370
4407
  const r = document.createElement("div");
4371
4408
  r.className = "image-content-container";
4372
4409
  const n = document.createElement("div");
4373
4410
  n.className = "image-container";
4374
- const s = ls(t.isDraft);
4375
- s.className = "image", n.appendChild(s);
4376
- const o = document.createElement("div");
4377
- o.className = "content";
4411
+ const o = lo(t.isDraft);
4412
+ o.className = "image", n.appendChild(o);
4413
+ const s = document.createElement("div");
4414
+ s.className = "content";
4378
4415
  const a = document.createElement("p");
4379
4416
  a.className = "title", a.textContent = t.title;
4380
4417
  const i = document.createElement("p");
4381
- i.className = "subtitle", i.textContent = t.subtitle || "Earned!", o.appendChild(a), o.appendChild(i), r.appendChild(n), r.appendChild(o);
4418
+ i.className = "subtitle", i.textContent = t.subtitle || "Earned!", s.appendChild(a), s.appendChild(i), r.appendChild(n), r.appendChild(s);
4382
4419
  const l = document.createElement("div");
4383
4420
  l.className = "xp-section-container";
4384
4421
  const c = document.createElement("div");
4385
4422
  c.className = "xp-section";
4386
- const d = ds(!t.isDraft);
4423
+ const d = ho(!t.isDraft);
4387
4424
  d.setAttribute("class", "xp-icon"), c.appendChild(d);
4388
4425
  const h = document.createElement("span");
4389
4426
  h.className = "xp-amount", h.textContent = `${t.xpAmount}`, c.appendChild(h), l.appendChild(c);
4390
4427
  const f = ee(!1);
4391
4428
  return e.appendChild(r), e.appendChild(l), e.appendChild(f), e;
4392
4429
  }
4393
- const ls = (t = !1) => {
4430
+ const lo = (t = !1) => {
4394
4431
  const e = document.createElement("div"), r = document.createElementNS("http://www.w3.org/2000/svg", "svg");
4395
4432
  switch (r.setAttribute("width", "34"), r.setAttribute("height", "34"), r.setAttribute("viewBox", "0 0 30 30"), r.style.width = "100%", r.style.height = "100%", t) {
4396
4433
  case !0:
@@ -4404,7 +4441,7 @@ const ls = (t = !1) => {
4404
4441
  `;
4405
4442
  }
4406
4443
  return e.appendChild(r), e;
4407
- }, ds = (t) => {
4444
+ }, ho = (t) => {
4408
4445
  const e = document.createElementNS(
4409
4446
  "http://www.w3.org/2000/svg",
4410
4447
  "svg"
@@ -4440,7 +4477,7 @@ const ls = (t = !1) => {
4440
4477
  }
4441
4478
  return e;
4442
4479
  };
4443
- function hs(t) {
4480
+ function fo(t) {
4444
4481
  if (t.getElementById("cartridge-toast-marketplace-styles"))
4445
4482
  return;
4446
4483
  const e = t.createElement("style");
@@ -4524,30 +4561,30 @@ function hs(t) {
4524
4561
  }
4525
4562
  `, t.head.appendChild(e);
4526
4563
  }
4527
- function fs(t) {
4564
+ function uo(t) {
4528
4565
  const e = document.createElement("div");
4529
4566
  e.className = "cartridge-toast marketplace";
4530
4567
  const r = document.createElement("div");
4531
4568
  r.className = "image-content-container";
4532
4569
  const n = document.createElement("div");
4533
4570
  n.className = "image-container";
4534
- const s = document.createElement("img");
4535
- s.className = "image", s.src = dt(t.itemImage), s.alt = t.itemName, n.appendChild(s);
4536
- const o = document.createElement("div");
4537
- o.className = "content";
4571
+ const o = document.createElement("img");
4572
+ o.className = "image", o.src = dt(t.itemImage), o.alt = t.itemName, n.appendChild(o);
4573
+ const s = document.createElement("div");
4574
+ s.className = "content";
4538
4575
  const a = {
4539
4576
  purchased: "Purchased!",
4540
4577
  sold: "Sold!"
4541
4578
  }, i = document.createElement("p");
4542
4579
  i.className = "title", i.textContent = a[t.action];
4543
4580
  const l = document.createElement("p");
4544
- l.className = "item-name", l.textContent = t.itemName, o.appendChild(i), o.appendChild(l), r.appendChild(n), r.appendChild(o);
4581
+ l.className = "item-name", l.textContent = t.itemName, s.appendChild(i), s.appendChild(l), r.appendChild(n), r.appendChild(s);
4545
4582
  const c = document.createElement("div");
4546
4583
  c.className = "close-button-container";
4547
4584
  const d = ee(!1);
4548
4585
  return c.appendChild(d), e.appendChild(r), e.appendChild(c), e;
4549
4586
  }
4550
- function us(t) {
4587
+ function po(t) {
4551
4588
  if (t.getElementById("cartridge-toast-quest-styles"))
4552
4589
  return;
4553
4590
  const e = t.createElement("style");
@@ -4650,100 +4687,104 @@ function us(t) {
4650
4687
  }
4651
4688
  `, t.head.appendChild(e);
4652
4689
  }
4653
- function ps(t) {
4690
+ function go(t) {
4654
4691
  const e = document.createElement("div");
4655
4692
  e.className = "cartridge-toast quest";
4656
4693
  const r = document.createElement("div");
4657
4694
  r.className = "image-content-container";
4658
4695
  const n = document.createElement("div");
4659
4696
  n.className = "image-container";
4660
- const s = gs();
4661
- s.className = "image", n.appendChild(s);
4662
- const o = document.createElement("div");
4663
- o.className = "content";
4697
+ const o = mo();
4698
+ o.className = "image", n.appendChild(o);
4699
+ const s = document.createElement("div");
4700
+ s.className = "content";
4664
4701
  const a = document.createElement("p");
4665
4702
  a.className = "title", a.textContent = t.title;
4666
4703
  const i = document.createElement("p");
4667
- i.className = "subtitle", i.textContent = t.subtitle || "Earned!", o.appendChild(a), o.appendChild(i), r.appendChild(n), r.appendChild(o);
4704
+ i.className = "subtitle", i.textContent = t.subtitle || "Earned!", s.appendChild(a), s.appendChild(i), r.appendChild(n), r.appendChild(s);
4668
4705
  const l = ee(!1);
4669
4706
  return e.appendChild(r), e.appendChild(l), e;
4670
4707
  }
4671
- const gs = () => {
4708
+ const mo = () => {
4672
4709
  const t = document.createElement("div"), e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
4673
4710
  return e.setAttribute("width", "34"), e.setAttribute("height", "34"), e.setAttribute("viewBox", "0 0 30 30"), e.style.width = "100%", e.style.height = "100%", e.innerHTML = '<path d="M3 6.5V8C3 8.55312 3.44687 9 4 9H4.5H6V6.5C6 5.67188 5.32812 5 4.5 5C3.67188 5 3 5.67188 3 6.5ZM6.5 5C6.8125 5.41875 7 5.9375 7 6.5V16C7 17.1031 7.89687 18 9 18C10.1031 18 11 17.1031 11 16V15.8344C11 14.8219 11.8219 14 12.8344 14H18V8C18 6.34375 16.6562 5 15 5H6.5ZM17.5 19C19.4344 19 21 17.4344 21 15.5C21 15.225 20.775 15 20.5 15H12.8344C12.375 15 12 15.3719 12 15.8344V16C12 17.6562 10.6562 19 9 19H14.5H17.5Z" fill="white"/>', t.appendChild(e), t;
4674
- }, ms = (t) => {
4711
+ }, wo = (t) => {
4675
4712
  const e = t.borderRadius ?? 8, r = !isFinite(t.duration) || t.duration <= 0, n = document.createElement("div");
4676
4713
  n.className = "cartridge-toast-progress-bar", n.style.position = "absolute", n.style.bottom = "0", n.style.left = "0", n.style.right = "0", n.style.height = "4px", n.style.overflow = "hidden", n.style.borderBottomLeftRadius = `${e}px`, n.style.borderBottomRightRadius = `${e}px`, n.style.backgroundColor = "rgba(255, 255, 255, 0.2)";
4677
- const s = document.createElement("div");
4678
- return s.className = "cartridge-toast-progress-bar-fill", s.style.position = "absolute", s.style.bottom = "0", s.style.left = "0", s.style.height = "100%", s.style.backgroundColor = "rgba(255, 255, 255, 0.8)", s.style.borderBottomLeftRadius = `${e}px`, r ? (s.style.width = "100%", s.style.transition = "none") : (s.style.width = "0%", s.style.transition = `width ${t.duration}ms linear`, requestAnimationFrame(() => {
4714
+ const o = document.createElement("div");
4715
+ return o.className = "cartridge-toast-progress-bar-fill", o.style.position = "absolute", o.style.bottom = "0", o.style.left = "0", o.style.height = "100%", o.style.backgroundColor = "rgba(255, 255, 255, 0.8)", o.style.borderBottomLeftRadius = `${e}px`, r ? (o.style.width = "100%", o.style.transition = "none") : (o.style.width = "0%", o.style.transition = `width ${t.duration}ms linear`, requestAnimationFrame(() => {
4679
4716
  requestAnimationFrame(() => {
4680
- s.style.width = "100%";
4717
+ o.style.width = "100%";
4681
4718
  });
4682
4719
  }), t.onComplete && setTimeout(() => {
4683
4720
  t.onComplete?.();
4684
- }, t.duration)), n.appendChild(s), n;
4721
+ }, t.duration)), n.appendChild(o), n;
4685
4722
  };
4686
4723
  function at(t, e, r, n) {
4687
- const s = ms({
4724
+ const o = wo({
4688
4725
  duration: e,
4689
4726
  onComplete: r,
4690
4727
  borderRadius: n
4691
4728
  });
4692
- t.appendChild(s);
4729
+ t.appendChild(o);
4693
4730
  }
4694
- function ws(t) {
4731
+ function yo(t) {
4695
4732
  switch (t.variant) {
4696
4733
  case "error":
4697
- return rs(t);
4734
+ return ro(t);
4698
4735
  case "transaction":
4699
- return ss(t);
4736
+ return oo(t);
4700
4737
  case "network-switch":
4701
- return as(t);
4738
+ return ao(t);
4702
4739
  case "achievement":
4703
- return cs(t);
4740
+ return co(t);
4704
4741
  case "quest":
4705
- return ps(t);
4742
+ return go(t);
4706
4743
  case "marketplace":
4707
- return fs(t);
4744
+ return uo(t);
4708
4745
  }
4709
4746
  }
4710
- function ys(t, e) {
4747
+ function bo(t, e) {
4711
4748
  switch (e) {
4712
4749
  case "error":
4713
- ts(t);
4750
+ to(t);
4714
4751
  break;
4715
4752
  case "transaction":
4716
- ns(t);
4753
+ no(t);
4717
4754
  break;
4718
4755
  case "network-switch":
4719
- os(t);
4756
+ so(t);
4720
4757
  break;
4721
4758
  case "achievement":
4722
- is(t);
4759
+ io(t);
4723
4760
  break;
4724
4761
  case "quest":
4725
- us(t);
4762
+ po(t);
4726
4763
  break;
4727
4764
  case "marketplace":
4728
- hs(t);
4765
+ fo(t);
4729
4766
  break;
4730
4767
  }
4731
4768
  }
4732
- function $e(t, e) {
4733
- Jn(t), ys(t, e.variant);
4734
- const r = e.position || Zn, n = Gn(t, r), s = ws(e), o = () => Xn(s);
4735
- n.appendChild(s);
4736
- const a = s.querySelector("#close-button");
4737
- a && a.addEventListener("click", o);
4769
+ function Se(t, e) {
4770
+ Jn(t), bo(t, e.variant);
4771
+ const r = e.position || Zn, n = Gn(t, r), o = yo(e), s = () => Xn(o);
4772
+ n.appendChild(o), e.onClick && (o.style.cursor = "pointer", o.addEventListener("click", (d) => {
4773
+ !d.target.closest("#close-button") && e.onClick && e.onClick();
4774
+ }));
4775
+ const a = o.querySelector("#close-button");
4776
+ a && a.addEventListener("click", (d) => {
4777
+ d.stopPropagation(), s();
4778
+ });
4738
4779
  let i = null;
4739
4780
  const l = e.duration ?? qn, c = !isFinite(l) || l <= 0;
4740
4781
  if (e.variant !== "network-switch") {
4741
4782
  const d = e.variant === "error" || e.variant === "transaction" ? 8 : 4;
4742
- c ? at(s, 1 / 0, () => {
4743
- }, d) : at(s, l, o, d);
4744
- } else c || (i = setTimeout(o, l));
4783
+ c ? at(o, 1 / 0, () => {
4784
+ }, d) : at(o, l, s, d);
4785
+ } else c || (i = setTimeout(s, l));
4745
4786
  return () => {
4746
- i && clearTimeout(i), o();
4787
+ i && clearTimeout(i), s();
4747
4788
  };
4748
4789
  }
4749
4790
  let it = !1;
@@ -4751,18 +4792,18 @@ function Dt() {
4751
4792
  it || typeof window > "u" || De() || (window.addEventListener("message", (t) => {
4752
4793
  if (t.data?.type === Ot && t.data?.options) {
4753
4794
  const e = document;
4754
- e && $e(e, t.data.options);
4795
+ e && Se(e, t.data.options);
4755
4796
  }
4756
4797
  }), it = !0);
4757
4798
  }
4758
- function _s(t) {
4799
+ function Co(t) {
4759
4800
  if (typeof window > "u" || typeof document > "u")
4760
4801
  return console.warn("Toast can only be used in a browser environment"), () => {
4761
4802
  };
4762
4803
  if (Dt(), De()) {
4763
4804
  const e = Kn();
4764
4805
  if (e)
4765
- return $e(e, t);
4806
+ return Se(e, t);
4766
4807
  try {
4767
4808
  window.parent && window.parent.postMessage(
4768
4809
  {
@@ -4778,10 +4819,14 @@ function _s(t) {
4778
4819
  return () => {
4779
4820
  };
4780
4821
  } else
4781
- return $e(document, t);
4822
+ return Se(document, t);
4782
4823
  }
4783
4824
  typeof window < "u" && Dt();
4784
- var bs = [
4825
+ const xo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4826
+ __proto__: null,
4827
+ toast: Co
4828
+ }, Symbol.toStringTag, { value: "Module" }));
4829
+ var vo = [
4785
4830
  {
4786
4831
  name: "Wrapped BTC",
4787
4832
  symbol: "WBTC",
@@ -5379,19 +5424,19 @@ async function Fe() {
5379
5424
  return console.error("Error loading configs index:", t), { configs: [], baseUrl: le };
5380
5425
  }
5381
5426
  }
5382
- async function As() {
5427
+ async function So() {
5383
5428
  return (await Fe()).configs;
5384
5429
  }
5385
- async function Is(t) {
5430
+ async function $o(t) {
5386
5431
  try {
5387
- const n = `${(await Fe()).baseUrl || le}/${t}`, s = await fetch(`${n}/config.json`);
5388
- if (!s.ok)
5432
+ const n = `${(await Fe()).baseUrl || le}/${t}`, o = await fetch(`${n}/config.json`);
5433
+ if (!o.ok)
5389
5434
  throw new Error(
5390
- `Failed to load config ${t}: ${s.statusText}`
5435
+ `Failed to load config ${t}: ${o.statusText}`
5391
5436
  );
5392
- const o = await s.json();
5393
- if (o && o.theme) {
5394
- o.theme.icon && !o.theme.icon.startsWith("http") && (o.theme.icon = `${n}/${o.theme.icon}`), o.theme.cover && (typeof o.theme.cover == "string" ? o.theme.cover.startsWith("http") || (o.theme.cover = `${n}/${o.theme.cover}`) : (o.theme.cover.light && !o.theme.cover.light.startsWith("http") && (o.theme.cover.light = `${n}/${o.theme.cover.light}`), o.theme.cover.dark && !o.theme.cover.dark.startsWith("http") && (o.theme.cover.dark = `${n}/${o.theme.cover.dark}`)));
5437
+ const s = await o.json();
5438
+ if (s && s.theme) {
5439
+ s.theme.icon && !s.theme.icon.startsWith("http") && (s.theme.icon = `${n}/${s.theme.icon}`), s.theme.cover && (typeof s.theme.cover == "string" ? s.theme.cover.startsWith("http") || (s.theme.cover = `${n}/${s.theme.cover}`) : (s.theme.cover.light && !s.theme.cover.light.startsWith("http") && (s.theme.cover.light = `${n}/${s.theme.cover.light}`), s.theme.cover.dark && !s.theme.cover.dark.startsWith("http") && (s.theme.cover.dark = `${n}/${s.theme.cover.dark}`)));
5395
5440
  const a = (i) => {
5396
5441
  if (i) {
5397
5442
  for (const l in i)
@@ -5400,75 +5445,75 @@ async function Is(t) {
5400
5445
  i[l][c] && !i[l][c].startsWith("http") && (i[l][c] = `${n}/${i[l][c]}`);
5401
5446
  }
5402
5447
  };
5403
- if (o.theme.optimizedIcon && a(o.theme.optimizedIcon), o.theme.optimizedCover)
5404
- if (typeof o.theme.optimizedCover == "string")
5405
- o.theme.optimizedCover.startsWith("http") || (o.theme.optimizedCover = `${n}/${o.theme.optimizedCover}`);
5406
- else if (o.theme.optimizedCover.light || o.theme.optimizedCover.dark) {
5407
- const i = o.theme.optimizedCover;
5448
+ if (s.theme.optimizedIcon && a(s.theme.optimizedIcon), s.theme.optimizedCover)
5449
+ if (typeof s.theme.optimizedCover == "string")
5450
+ s.theme.optimizedCover.startsWith("http") || (s.theme.optimizedCover = `${n}/${s.theme.optimizedCover}`);
5451
+ else if (s.theme.optimizedCover.light || s.theme.optimizedCover.dark) {
5452
+ const i = s.theme.optimizedCover;
5408
5453
  i.light && a(i.light), i.dark && a(i.dark);
5409
5454
  } else
5410
- a(o.theme.optimizedCover);
5455
+ a(s.theme.optimizedCover);
5411
5456
  }
5412
- return o;
5457
+ return s;
5413
5458
  } catch (e) {
5414
5459
  return console.error(`Error loading config ${t}:`, e), null;
5415
5460
  }
5416
5461
  }
5417
- async function $s() {
5462
+ async function Lo() {
5418
5463
  const t = await Fe(), e = t.configs, r = t.baseUrl || le, n = {};
5419
5464
  return await Promise.all(
5420
- e.map(async (s) => {
5465
+ e.map(async (o) => {
5421
5466
  try {
5422
- const o = await fetch(`${r}/${s}/config.json`);
5423
- if (o.ok) {
5424
- const a = await o.json();
5425
- n[s] = a;
5467
+ const s = await fetch(`${r}/${o}/config.json`);
5468
+ if (s.ok) {
5469
+ const a = await s.json();
5470
+ n[o] = a;
5426
5471
  }
5427
- } catch (o) {
5428
- console.error(`Error loading config ${s}:`, o);
5472
+ } catch (s) {
5473
+ console.error(`Error loading config ${o}:`, s);
5429
5474
  }
5430
5475
  })
5431
5476
  ), n;
5432
5477
  }
5433
5478
  Ft.theme.icon = "https://static.cartridge.gg/presets/cartridge/icon.svg";
5434
- var Ss = bs, Ls = Ft.theme;
5479
+ var No = vo, Bo = Ft.theme;
5435
5480
  export {
5436
- Ps as ALL_AUTH_OPTIONS,
5437
- Ts as AUTH_EXTERNAL_WALLETS,
5481
+ Ro as ALL_AUTH_OPTIONS,
5482
+ Uo as AUTH_EXTERNAL_WALLETS,
5438
5483
  Jr as ArgentWallet,
5439
5484
  nn as BaseWallet,
5440
5485
  jn as BraavosWallet,
5441
- Rs as EMBEDDED_WALLETS,
5442
- Us as EXTERNAL_WALLETS,
5443
- Ms as EXTRA_EXTERNAL_WALLETS,
5486
+ Mo as EMBEDDED_WALLETS,
5487
+ zo as EXTERNAL_WALLETS,
5488
+ Oo as EXTRA_EXTERNAL_WALLETS,
5444
5489
  de as EthereumWalletBase,
5445
- zs as FeeSource,
5446
- Os as IMPLEMENTED_AUTH_OPTIONS,
5447
- sn as MetaMaskWallet,
5448
- _ as NotReadyToConnect,
5490
+ Do as FeeSource,
5491
+ Fo as IMPLEMENTED_AUTH_OPTIONS,
5492
+ on as MetaMaskWallet,
5493
+ A as NotReadyToConnect,
5449
5494
  Qn as PhantomEVMWallet,
5450
5495
  Fn as PhantomWallet,
5451
5496
  Hn as RabbyWallet,
5452
- Q as ResponseCodes,
5497
+ T as ResponseCodes,
5453
5498
  Wn as WalletBridge,
5454
5499
  ge as chainIdToPlatform,
5455
- vs as default,
5456
- Ls as defaultTheme,
5457
- Ss as erc20Metadata,
5458
- As as getAvailableConfigs,
5500
+ _o as default,
5501
+ Bo as defaultTheme,
5502
+ No as erc20Metadata,
5503
+ So as getAvailableConfigs,
5459
5504
  Fe as getConfigsIndex,
5460
- Ds as humanizeString,
5505
+ Qo as humanizeString,
5461
5506
  jt as isMobile,
5462
- $s as loadAllConfigs,
5463
- Is as loadConfig,
5464
- Es as lookupAddresses,
5465
- ks as lookupUsernames,
5466
- Fs as normalizeCalls,
5507
+ Lo as loadAllConfigs,
5508
+ $o as loadConfig,
5509
+ Io as lookupAddresses,
5510
+ Ao as lookupUsernames,
5511
+ Ho as normalizeCalls,
5467
5512
  Yt as parseChainId,
5468
5513
  dt as sanitizeImageSrc,
5469
5514
  Ht as toArray,
5470
- Qs as toSessionPolicies,
5471
- Hs as toWasmPolicies,
5472
- _s as toast
5515
+ jo as toSessionPolicies,
5516
+ Wo as toWasmPolicies,
5517
+ Co as toast
5473
5518
  };
5474
5519
  //# sourceMappingURL=index.js.map