@reown/appkit-cdn 0.0.4 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/LICENSE +2 -2
  2. package/dist/{W3MFrameProviderSingleton-C0cnhaTp.js → W3MFrameProviderSingleton-B9E01rnL.js} +2875 -2790
  3. package/dist/{W3MFrameProviderSingleton-BPW-iicw.cjs → W3MFrameProviderSingleton-C56DqhGz.cjs} +120 -120
  4. package/dist/ethers.cjs +1 -1
  5. package/dist/ethers.js +2911 -2900
  6. package/dist/{hooks.module-CznhRnD8.cjs → hooks.module-COfcimjS.cjs} +1 -1
  7. package/dist/{hooks.module-DDA9XQhP.js → hooks.module-OoOP-iZR.js} +1 -1
  8. package/dist/{index-mtzTuPjF.cjs → index-BFJW4qjy.cjs} +1 -1
  9. package/dist/{index-BfndvsxR.js → index-BT6RyUGl.js} +10 -10
  10. package/dist/{index-DBXYKiLS.js → index-BeGUtgfx.js} +2 -2
  11. package/dist/{index-DJZpgYw1.cjs → index-Bl5DrNCU.cjs} +1 -1
  12. package/dist/{index-BjDQZhCC.js → index-BmTGKb68.js} +43 -43
  13. package/dist/{index-DDxg-CnX.js → index-BsaPadk9.js} +5 -5
  14. package/dist/index-C0D6DuSI.cjs +64 -0
  15. package/dist/{index-DEDntV4l.js → index-CCzK6s6K.js} +2 -2
  16. package/dist/{index-DUA8iuT-.cjs → index-CG2oM48r.cjs} +1 -1
  17. package/dist/{index-BLj7JLFx.cjs → index-Cm-dsmtL.cjs} +1 -1
  18. package/dist/{index-DzzvtAEu.js → index-CpPWzw23.js} +1 -1
  19. package/dist/{index-CGVAZ4op.cjs → index-DYI6oRae.cjs} +1 -1
  20. package/dist/{index-BUi5SfXe.cjs → index-DbrEGMZZ.cjs} +1 -1
  21. package/dist/{index-D4J5pbXW.cjs → index-Dv8gb9FV.cjs} +1 -1
  22. package/dist/{index-CJlx78Gf.js → index-XErsLRGr.js} +2 -2
  23. package/dist/{index-Ij2u7oAT.js → index-j73t9fcB.js} +36 -36
  24. package/dist/{index.es-oLid2UZg.cjs → index.es-0FqNLiLo.cjs} +2 -2
  25. package/dist/{index.es-CMbAWbN4.js → index.es-BhyAt79s.js} +249 -249
  26. package/dist/{metamask-sdk-8Alxi0fO.js → metamask-sdk-DPJxxXN8.js} +1 -1
  27. package/dist/{metamask-sdk-CMhxptNL.cjs → metamask-sdk-DXmxCf94.cjs} +1 -1
  28. package/dist/{native-CoR5CkbH.cjs → native-BIdabKvi.cjs} +1 -1
  29. package/dist/{native-B_ZKbAy2.js → native-CbXTOHOX.js} +1 -1
  30. package/dist/w3m-modal-BLwMni5B.cjs +149 -0
  31. package/dist/{w3m-modal-zyJFtzIf.js → w3m-modal-BjrYlIco.js} +55 -73
  32. package/dist/{wagmi-BPQ-82KE.js → wagmi-DiP-pZB_.js} +3871 -3851
  33. package/dist/{wagmi-BL69ctC0.cjs → wagmi-MqS1RwHj.cjs} +14 -14
  34. package/dist/wagmi.cjs +1 -1
  35. package/dist/wagmi.js +6 -6
  36. package/package.json +5 -5
  37. package/dist/index-JwYoIh-Y.cjs +0 -64
  38. package/dist/w3m-modal-CiBinOIk.cjs +0 -149
@@ -1,11 +1,11 @@
1
- import { n as fe, s as Ke, T as E, o as Q, R as Ho, a as g, t as P, p as H, y as ae } from "./index-DDxg-CnX.js";
2
- import { bb as Bo, F as R, bY as Zo } from "./W3MFrameProviderSingleton-C0cnhaTp.js";
1
+ import { n as fe, s as Ke, T as E, o as Y, R as Ho, a as g, t as P, p as H, y as ae } from "./index-BsaPadk9.js";
2
+ import { bc as Bo, I as R, bZ as Zo } from "./W3MFrameProviderSingleton-B9E01rnL.js";
3
3
  /**
4
4
  * @license
5
5
  * Copyright 2019 Google LLC
6
6
  * SPDX-License-Identifier: BSD-3-Clause
7
7
  */
8
- const Ye = window, Bt = Ye.ShadowRoot && (Ye.ShadyCSS === void 0 || Ye.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, Zt = Symbol(), qt = /* @__PURE__ */ new WeakMap();
8
+ const Qe = window, Bt = Qe.ShadowRoot && (Qe.ShadyCSS === void 0 || Qe.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, Zt = Symbol(), qt = /* @__PURE__ */ new WeakMap();
9
9
  let $o = class {
10
10
  constructor(e, o, i) {
11
11
  if (this._$cssResult$ = !0, i !== Zt)
@@ -36,7 +36,7 @@ const zo = (t) => new $o(typeof t == "string" ? t : t + "", void 0, Zt), C = (t,
36
36
  return new $o(o, t, Zt);
37
37
  }, Vo = (t, e) => {
38
38
  Bt ? t.adoptedStyleSheets = e.map((o) => o instanceof CSSStyleSheet ? o : o.styleSheet) : e.forEach((o) => {
39
- const i = document.createElement("style"), r = Ye.litNonce;
39
+ const i = document.createElement("style"), r = Qe.litNonce;
40
40
  r !== void 0 && i.setAttribute("nonce", r), i.textContent = o.cssText, t.appendChild(i);
41
41
  });
42
42
  }, Kt = Bt ? (t) => t : (t) => t instanceof CSSStyleSheet ? ((e) => {
@@ -51,7 +51,7 @@ const zo = (t) => new $o(typeof t == "string" ? t : t + "", void 0, Zt), C = (t,
51
51
  * SPDX-License-Identifier: BSD-3-Clause
52
52
  */
53
53
  var rt;
54
- const Ge = window, Yt = Ge.trustedTypes, Fo = Yt ? Yt.emptyScript : "", Qt = Ge.reactiveElementPolyfillSupport, Pt = { toAttribute(t, e) {
54
+ const Ge = window, Qt = Ge.trustedTypes, Fo = Qt ? Qt.emptyScript : "", Yt = Ge.reactiveElementPolyfillSupport, Pt = { toAttribute(t, e) {
55
55
  switch (e) {
56
56
  case Boolean:
57
57
  t = t ? Fo : null;
@@ -259,22 +259,22 @@ let ue = class extends HTMLElement {
259
259
  firstUpdated(e) {
260
260
  }
261
261
  };
262
- ue[Wt] = !0, ue.elementProperties = /* @__PURE__ */ new Map(), ue.elementStyles = [], ue.shadowRootOptions = { mode: "open" }, Qt == null || Qt({ ReactiveElement: ue }), ((rt = Ge.reactiveElementVersions) !== null && rt !== void 0 ? rt : Ge.reactiveElementVersions = []).push("1.6.3");
262
+ ue[Wt] = !0, ue.elementProperties = /* @__PURE__ */ new Map(), ue.elementStyles = [], ue.shadowRootOptions = { mode: "open" }, Yt == null || Yt({ ReactiveElement: ue }), ((rt = Ge.reactiveElementVersions) !== null && rt !== void 0 ? rt : Ge.reactiveElementVersions = []).push("1.6.3");
263
263
  /**
264
264
  * @license
265
265
  * Copyright 2017 Google LLC
266
266
  * SPDX-License-Identifier: BSD-3-Clause
267
267
  */
268
268
  var nt;
269
- const Xe = window, be = Xe.trustedTypes, Gt = be ? be.createPolicy("lit-html", { createHTML: (t) => t }) : void 0, Nt = "$lit$", Y = `lit$${(Math.random() + "").slice(9)}$`, Ao = "?" + Y, qo = `<${Ao}>`, se = document, Se = () => se.createComment(""), Le = (t) => t === null || typeof t != "object" && typeof t != "function", _o = Array.isArray, Ko = (t) => _o(t) || typeof (t == null ? void 0 : t[Symbol.iterator]) == "function", at = `[
269
+ const Xe = window, be = Xe.trustedTypes, Gt = be ? be.createPolicy("lit-html", { createHTML: (t) => t }) : void 0, Nt = "$lit$", Q = `lit$${(Math.random() + "").slice(9)}$`, Ao = "?" + Q, qo = `<${Ao}>`, se = document, Se = () => se.createComment(""), Le = (t) => t === null || typeof t != "object" && typeof t != "function", _o = Array.isArray, Ko = (t) => _o(t) || typeof (t == null ? void 0 : t[Symbol.iterator]) == "function", at = `[
270
270
  \f\r]`, Ce = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, Xt = /-->/g, Jt = />/g, ee = RegExp(`>|${at}(?:([^\\s"'>=/]+)(${at}*=${at}*(?:[^
271
- \f\r"'\`<>=]|("|')|))|$)`, "g"), eo = /'/g, to = /"/g, Eo = /^(?:script|style|textarea|title)$/i, ko = (t) => (e, ...o) => ({ _$litType$: t, strings: e, values: o }), l = ko(1), Qe = ko(2), le = Symbol.for("lit-noChange"), T = Symbol.for("lit-nothing"), oo = /* @__PURE__ */ new WeakMap(), ie = se.createTreeWalker(se, 129, null, !1);
271
+ \f\r"'\`<>=]|("|')|))|$)`, "g"), eo = /'/g, to = /"/g, Eo = /^(?:script|style|textarea|title)$/i, ko = (t) => (e, ...o) => ({ _$litType$: t, strings: e, values: o }), l = ko(1), Ye = ko(2), le = Symbol.for("lit-noChange"), T = Symbol.for("lit-nothing"), oo = /* @__PURE__ */ new WeakMap(), ie = se.createTreeWalker(se, 129, null, !1);
272
272
  function Oo(t, e) {
273
273
  if (!Array.isArray(t) || !t.hasOwnProperty("raw"))
274
274
  throw Error("invalid template strings array");
275
275
  return Gt !== void 0 ? Gt.createHTML(e) : e;
276
276
  }
277
- const Yo = (t, e) => {
277
+ const Qo = (t, e) => {
278
278
  const o = t.length - 1, i = [];
279
279
  let r, n = e === 2 ? "<svg>" : "", a = Ce;
280
280
  for (let s = 0; s < o; s++) {
@@ -283,7 +283,7 @@ const Yo = (t, e) => {
283
283
  for (; m < c.length && (a.lastIndex = m, x = a.exec(c), x !== null); )
284
284
  m = a.lastIndex, a === Ce ? x[1] === "!--" ? a = Xt : x[1] !== void 0 ? a = Jt : x[2] !== void 0 ? (Eo.test(x[2]) && (r = RegExp("</" + x[2], "g")), a = ee) : x[3] !== void 0 && (a = ee) : a === ee ? x[0] === ">" ? (a = r ?? Ce, $ = -1) : x[1] === void 0 ? $ = -2 : ($ = a.lastIndex - x[2].length, d = x[1], a = x[3] === void 0 ? ee : x[3] === '"' ? to : eo) : a === to || a === eo ? a = ee : a === Xt || a === Jt ? a = Ce : (a = ee, r = void 0);
285
285
  const _ = a === ee && t[s + 1].startsWith("/>") ? " " : "";
286
- n += a === Ce ? c + qo : $ >= 0 ? (i.push(d), c.slice(0, $) + Nt + c.slice($) + Y + _) : c + Y + ($ === -2 ? (i.push(void 0), s) : _);
286
+ n += a === Ce ? c + qo : $ >= 0 ? (i.push(d), c.slice(0, $) + Nt + c.slice($) + Q + _) : c + Q + ($ === -2 ? (i.push(void 0), s) : _);
287
287
  }
288
288
  return [Oo(t, n + (t[o] || "<?>") + (e === 2 ? "</svg>" : "")), i];
289
289
  };
@@ -292,7 +292,7 @@ class Pe {
292
292
  let r;
293
293
  this.parts = [];
294
294
  let n = 0, a = 0;
295
- const s = e.length - 1, c = this.parts, [d, x] = Yo(e, o);
295
+ const s = e.length - 1, c = this.parts, [d, x] = Qo(e, o);
296
296
  if (this.el = Pe.createElement(d, i), ie.currentNode = this.el.content, o === 2) {
297
297
  const $ = this.el.content, m = $.firstChild;
298
298
  m.remove(), $.append(...m.childNodes);
@@ -302,10 +302,10 @@ class Pe {
302
302
  if (r.hasAttributes()) {
303
303
  const $ = [];
304
304
  for (const m of r.getAttributeNames())
305
- if (m.endsWith(Nt) || m.startsWith(Y)) {
305
+ if (m.endsWith(Nt) || m.startsWith(Q)) {
306
306
  const _ = x[a++];
307
307
  if ($.push(m), _ !== void 0) {
308
- const f = r.getAttribute(_.toLowerCase() + Nt).split(Y), u = /([.?@])?(.*)/.exec(_);
308
+ const f = r.getAttribute(_.toLowerCase() + Nt).split(Q), u = /([.?@])?(.*)/.exec(_);
309
309
  c.push({ type: 1, index: n, name: u[2], strings: f, ctor: u[1] === "." ? Go : u[1] === "?" ? Jo : u[1] === "@" ? er : ot });
310
310
  } else
311
311
  c.push({ type: 6, index: n });
@@ -314,7 +314,7 @@ class Pe {
314
314
  r.removeAttribute(m);
315
315
  }
316
316
  if (Eo.test(r.tagName)) {
317
- const $ = r.textContent.split(Y), m = $.length - 1;
317
+ const $ = r.textContent.split(Q), m = $.length - 1;
318
318
  if (m > 0) {
319
319
  r.textContent = be ? be.emptyScript : "";
320
320
  for (let _ = 0; _ < m; _++)
@@ -327,8 +327,8 @@ class Pe {
327
327
  c.push({ type: 2, index: n });
328
328
  else {
329
329
  let $ = -1;
330
- for (; ($ = r.data.indexOf(Y, $ + 1)) !== -1; )
331
- c.push({ type: 7, index: n }), $ += Y.length - 1;
330
+ for (; ($ = r.data.indexOf(Q, $ + 1)) !== -1; )
331
+ c.push({ type: 7, index: n }), $ += Q.length - 1;
332
332
  }
333
333
  n++;
334
334
  }
@@ -346,7 +346,7 @@ function ye(t, e, o = t, i) {
346
346
  const d = Le(e) ? void 0 : e._$litDirective$;
347
347
  return (c == null ? void 0 : c.constructor) !== d && ((n = c == null ? void 0 : c._$AO) === null || n === void 0 || n.call(c, !1), d === void 0 ? c = void 0 : (c = new d(t), c._$AT(t, o, i)), i !== void 0 ? ((a = (s = o)._$Co) !== null && a !== void 0 ? a : s._$Co = [])[i] = c : o._$Cl = c), c !== void 0 && (e = ye(t, c._$AS(t, e.values), c, i)), e;
348
348
  }
349
- class Qo {
349
+ class Yo {
350
350
  constructor(e, o) {
351
351
  this._$AV = [], this._$AN = void 0, this._$AD = e, this._$AM = o;
352
352
  }
@@ -414,7 +414,7 @@ class Ne {
414
414
  if (((o = this._$AH) === null || o === void 0 ? void 0 : o._$AD) === n)
415
415
  this._$AH.v(i);
416
416
  else {
417
- const a = new Qo(n, this), s = a.u(this.options);
417
+ const a = new Yo(n, this), s = a.u(this.options);
418
418
  a.v(i), this.$(s), this._$AH = a;
419
419
  }
420
420
  }
@@ -1113,9 +1113,9 @@ function ne(t, e, o) {
1113
1113
  * SPDX-License-Identifier: BSD-3-Clause
1114
1114
  */
1115
1115
  const L = (t) => t ?? T;
1116
- var Yr = Object.defineProperty, ho = Object.getOwnPropertySymbols, Qr = Object.prototype.hasOwnProperty, Gr = Object.prototype.propertyIsEnumerable, mo = (t, e, o) => e in t ? Yr(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o, pt = (t, e) => {
1116
+ var Qr = Object.defineProperty, ho = Object.getOwnPropertySymbols, Yr = Object.prototype.hasOwnProperty, Gr = Object.prototype.propertyIsEnumerable, mo = (t, e, o) => e in t ? Qr(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o, pt = (t, e) => {
1117
1117
  for (var o in e || (e = {}))
1118
- Qr.call(e, o) && mo(t, o, e[o]);
1118
+ Yr.call(e, o) && mo(t, o, e[o]);
1119
1119
  if (ho)
1120
1120
  for (var o of ho(e))
1121
1121
  Gr.call(e, o) && mo(t, o, e[o]);
@@ -1283,9 +1283,9 @@ const h = { MOBILE_BREAKPOINT: 600, WCM_RECENT_WALLET_DATA: "WCM_RECENT_WALLET_D
1283
1283
  const { walletConnectUri: t } = H.state;
1284
1284
  if (t)
1285
1285
  try {
1286
- await navigator.clipboard.writeText(t), Q.openToast("Link copied", "success");
1286
+ await navigator.clipboard.writeText(t), Y.openToast("Link copied", "success");
1287
1287
  } catch {
1288
- Q.openToast("Failed to copy", "error");
1288
+ Y.openToast("Failed to copy", "error");
1289
1289
  }
1290
1290
  }, getCustomImageUrls() {
1291
1291
  const { walletImages: t } = ae.state, e = Object.values(t ?? {});
@@ -1382,16 +1382,16 @@ var yi = Object.defineProperty, xi = Object.getOwnPropertyDescriptor, uo = (t, e
1382
1382
  };
1383
1383
  let He = class extends w {
1384
1384
  constructor() {
1385
- super(), this.open = !1, this.unsubscribe = void 0, this.timeout = void 0, this.unsubscribe = Q.subscribe((t) => {
1386
- t.open ? (this.open = !0, this.timeout = setTimeout(() => Q.closeToast(), 2200)) : (this.open = !1, clearTimeout(this.timeout));
1385
+ super(), this.open = !1, this.unsubscribe = void 0, this.timeout = void 0, this.unsubscribe = Y.subscribe((t) => {
1386
+ t.open ? (this.open = !0, this.timeout = setTimeout(() => Y.closeToast(), 2200)) : (this.open = !1, clearTimeout(this.timeout));
1387
1387
  });
1388
1388
  }
1389
1389
  disconnectedCallback() {
1390
1390
  var t;
1391
- (t = this.unsubscribe) == null || t.call(this), clearTimeout(this.timeout), Q.closeToast();
1391
+ (t = this.unsubscribe) == null || t.call(this), clearTimeout(this.timeout), Y.closeToast();
1392
1392
  }
1393
1393
  render() {
1394
- const { message: t, variant: e } = Q.state, o = { "wcm-success": e === "success", "wcm-error": e === "error" };
1394
+ const { message: t, variant: e } = Y.state, o = { "wcm-success": e === "success", "wcm-error": e === "error" };
1395
1395
  return this.open ? l`<div class="${Z(o)}">${e === "success" ? A.CHECKMARK_ICON : null} ${e === "error" ? A.CROSS_ICON : null}<wcm-text variant="small-regular">${t}</wcm-text></div>` : null;
1396
1396
  }
1397
1397
  };
@@ -1410,7 +1410,7 @@ const Ai = { generate(t, e, o) {
1410
1410
  const O = (a.length - B) * s * f, b = (a.length - B) * s * u, M = 0.45;
1411
1411
  for (let S = 0; S < c.length; S += 1) {
1412
1412
  const N = s * (B - S * 2);
1413
- n.push(Qe`<rect fill="${S % 2 === 0 ? i : r}" height="${N}" rx="${N * M}" ry="${N * M}" width="${N}" x="${O + s * S}" y="${b + s * S}">`);
1413
+ n.push(Ye`<rect fill="${S % 2 === 0 ? i : r}" height="${N}" rx="${N * M}" ry="${N * M}" width="${N}" x="${O + s * S}" y="${b + s * S}">`);
1414
1414
  }
1415
1415
  });
1416
1416
  const d = Math.floor((o + 25) / s), x = a.length / 2 - d / 2, $ = a.length / 2 + d / 2 - 1, m = [];
@@ -1430,7 +1430,7 @@ const Ai = { generate(t, e, o) {
1430
1430
  return [Number(f), O];
1431
1431
  }).forEach(([f, u]) => {
1432
1432
  u.forEach((O) => {
1433
- n.push(Qe`<circle cx="${f}" cy="${O}" fill="${i}" r="${s / go}">`);
1433
+ n.push(Ye`<circle cx="${f}" cy="${O}" fill="${i}" r="${s / go}">`);
1434
1434
  });
1435
1435
  }), Object.entries(_).filter(([f, u]) => u.length > 1).map(([f, u]) => {
1436
1436
  const O = u.filter((b) => u.some((M) => yt(b, M, s)));
@@ -1445,7 +1445,7 @@ const Ai = { generate(t, e, o) {
1445
1445
  return [f, O.map((b) => [b[0], b[b.length - 1]])];
1446
1446
  }).forEach(([f, u]) => {
1447
1447
  u.forEach(([O, b]) => {
1448
- n.push(Qe`<line x1="${f}" x2="${f}" y1="${O}" y2="${b}" stroke="${i}" stroke-width="${s / (go / 2)}" stroke-linecap="round">`);
1448
+ n.push(Ye`<line x1="${f}" x2="${f}" y1="${O}" y2="${b}" stroke="${i}" stroke-width="${s / (go / 2)}" stroke-linecap="round">`);
1449
1449
  });
1450
1450
  }), n;
1451
1451
  } }, _i = C`@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}div{position:relative;user-select:none;display:block;overflow:hidden;aspect-ratio:1/1;animation:fadeIn ease .2s}.wcm-dark{background-color:#fff;border-radius:var(--wcm-container-border-radius);padding:18px;box-shadow:0 2px 5px #000}svg:first-child,wcm-wallet-image{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{width:25%;height:25%;border-radius:var(--wcm-wallet-icon-border-radius)}svg:first-child{transform:translateY(-50%) translateX(-50%) scale(.9)}svg:first-child path:first-child{fill:var(--wcm-accent-color)}svg:first-child path:last-child{stroke:var(--wcm-color-overlay)}`;
@@ -1460,7 +1460,7 @@ let F = class extends w {
1460
1460
  }
1461
1461
  svgTemplate() {
1462
1462
  const t = fe.state.themeMode === "light" ? this.size : this.size - 36;
1463
- return Qe`<svg height="${t}" width="${t}">${Ai.generate(this.uri, t, t / 4)}</svg>`;
1463
+ return Ye`<svg height="${t}" width="${t}">${Ai.generate(this.uri, t, t / 4)}</svg>`;
1464
1464
  }
1465
1465
  render() {
1466
1466
  const t = { "wcm-dark": fe.state.themeMode === "dark" };
@@ -1582,7 +1582,7 @@ let Ct = class extends w {
1582
1582
  try {
1583
1583
  this.preload && (this.preload = !1, await Promise.all([this.preloadListings(), this.preloadCustomImages()]));
1584
1584
  } catch (t) {
1585
- console.error(t), Q.openToast("Failed preloading", "error");
1585
+ console.error(t), Y.openToast("Failed preloading", "error");
1586
1586
  }
1587
1587
  }
1588
1588
  };
@@ -1622,8 +1622,8 @@ let At = class extends w {
1622
1622
  };
1623
1623
  At.styles = [v.globalCss, Vi], At = Fi([y("wcm-android-wallet-selection")], At);
1624
1624
  const qi = C`@keyframes loading{to{stroke-dashoffset:0}}@keyframes shake{10%,90%{transform:translate3d(-1px,0,0)}20%,80%{transform:translate3d(1px,0,0)}30%,50%,70%{transform:translate3d(-2px,0,0)}40%,60%{transform:translate3d(2px,0,0)}}:host{display:flex;flex-direction:column;align-items:center}div{position:relative;width:110px;height:110px;display:flex;justify-content:center;align-items:center;margin:40px 0 20px 0;transform:translate3d(0,0,0)}svg{position:absolute;width:110px;height:110px;fill:none;stroke:transparent;stroke-linecap:round;stroke-width:2px;top:0;left:0}use{stroke:var(--wcm-accent-color);animation:loading 1s linear infinite}wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:90px;height:90px}wcm-text{margin-bottom:40px}.wcm-error svg{stroke:var(--wcm-error-color)}.wcm-error use{display:none}.wcm-error{animation:shake .4s cubic-bezier(.36,.07,.19,.97) both}.wcm-stale svg,.wcm-stale use{display:none}`;
1625
- var Ki = Object.defineProperty, Yi = Object.getOwnPropertyDescriptor, me = (t, e, o, i) => {
1626
- for (var r = i > 1 ? void 0 : i ? Yi(e, o) : e, n = t.length - 1, a; n >= 0; n--)
1625
+ var Ki = Object.defineProperty, Qi = Object.getOwnPropertyDescriptor, me = (t, e, o, i) => {
1626
+ for (var r = i > 1 ? void 0 : i ? Qi(e, o) : e, n = t.length - 1, a; n >= 0; n--)
1627
1627
  (a = t[n]) && (r = (i ? a(e, o, r) : a(r)) || r);
1628
1628
  return i && r && Ki(e, o, r), r;
1629
1629
  };
@@ -1665,7 +1665,7 @@ const ve = { manualWallets() {
1665
1665
  const t = ve.recentWallet();
1666
1666
  if (t)
1667
1667
  return l`<wcm-wallet-button name="${t.name}" walletId="${t.id}" imageId="${L(t.image_id)}" .recent="${!0}" .onClick="${() => this.onConnecting(t)}"></wcm-wallet-button>`;
1668
- } }, Qi = C`.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-desktop-title,.wcm-mobile-title{display:flex;align-items:center}.wcm-mobile-title{justify-content:space-between;margin-bottom:20px;margin-top:-10px}.wcm-desktop-title{margin-bottom:10px;padding:0 10px}.wcm-subtitle{display:flex;align-items:center}.wcm-subtitle:last-child path{fill:var(--wcm-color-fg-3)}.wcm-desktop-title svg,.wcm-mobile-title svg{margin-right:6px}.wcm-desktop-title path,.wcm-mobile-title path{fill:var(--wcm-accent-color)}`;
1668
+ } }, Yi = C`.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-desktop-title,.wcm-mobile-title{display:flex;align-items:center}.wcm-mobile-title{justify-content:space-between;margin-bottom:20px;margin-top:-10px}.wcm-desktop-title{margin-bottom:10px;padding:0 10px}.wcm-subtitle{display:flex;align-items:center}.wcm-subtitle:last-child path{fill:var(--wcm-color-fg-3)}.wcm-desktop-title svg,.wcm-mobile-title svg{margin-right:6px}.wcm-desktop-title path,.wcm-mobile-title path{fill:var(--wcm-accent-color)}`;
1669
1669
  var Gi = (t, e, o, i) => {
1670
1670
  for (var r = e, n = t.length - 1, a; n >= 0; n--)
1671
1671
  (a = t[n]) && (r = a(r) || r);
@@ -1683,7 +1683,7 @@ let _t = class extends w {
1683
1683
  return l`<wcm-modal-header .border="${!0}" title="Connect your wallet" .onAction="${h.handleUriCopy}" .actionIcon="${A.COPY_ICON}"></wcm-modal-header><wcm-modal-content><div class="wcm-mobile-title"><div class="wcm-subtitle">${A.MOBILE_ICON}<wcm-text variant="small-regular" color="accent">Mobile</wcm-text></div><div class="wcm-subtitle">${A.SCAN_ICON}<wcm-text variant="small-regular" color="secondary">Scan with your wallet</wcm-text></div></div><wcm-walletconnect-qr></wcm-walletconnect-qr></wcm-modal-content>${c ? l`<wcm-modal-footer><div class="wcm-desktop-title">${A.DESKTOP_ICON}<wcm-text variant="small-regular" color="accent">Desktop</wcm-text></div><div class="wcm-grid">${s} ${a ? l`<wcm-view-all-wallets-button></wcm-view-all-wallets-button>` : null}</div></wcm-modal-footer>` : null}`;
1684
1684
  }
1685
1685
  };
1686
- _t.styles = [v.globalCss, Qi], _t = Gi([y("wcm-desktop-wallet-selection")], _t);
1686
+ _t.styles = [v.globalCss, Yi], _t = Gi([y("wcm-desktop-wallet-selection")], _t);
1687
1687
  const Xi = C`div{background-color:var(--wcm-color-bg-2);padding:10px 20px 15px 20px;border-top:1px solid var(--wcm-color-bg-3);text-align:center}a{color:var(--wcm-accent-color);text-decoration:none;transition:opacity .2s ease-in-out;display:inline}a:active{opacity:.8}@media(hover:hover){a:hover{opacity:.8}}`;
1688
1688
  var Ji = (t, e, o, i) => {
1689
1689
  for (var r = e, n = t.length - 1, a; n >= 0; n--)
@@ -2001,7 +2001,7 @@ let re = class extends w {
2001
2001
  const a = (t = H.state.chains) == null ? void 0 : t.join(","), { listings: s } = await P.getWallets({ page: this.firstFetch ? 1 : n + 1, entries: Lt, search: this.search, version: 2, chains: a }), c = s.map((d) => h.getWalletIcon(d));
2002
2002
  await Promise.all([...c.map(async (d) => h.preloadImage(d)), g.wait(300)]), this.endReached = this.isLastPage();
2003
2003
  } catch (a) {
2004
- console.error(a), Q.openToast(h.getErrorMessage(a), "error");
2004
+ console.error(a), Y.openToast(h.getErrorMessage(a), "error");
2005
2005
  } finally {
2006
2006
  this.loading = !1, this.firstFetch = !1;
2007
2007
  }
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("./W3MFrameProviderSingleton-BPW-iicw.cjs"),Uw=":";function $n(i){const[t,e]=i.split(Uw);return{namespace:t,reference:e}}function Gl(i,t=[]){const e=[];return Object.keys(i).forEach(s=>{if(t.length&&!t.includes(s))return;const o=i[s];e.push(...o.accounts)}),e}function Ap(i,t){return i.includes(":")?[i]:t.chains||[]}var $w=Object.defineProperty,Yl=Object.getOwnPropertySymbols,zw=Object.prototype.hasOwnProperty,Lw=Object.prototype.propertyIsEnumerable,Wl=(i,t,e)=>t in i?$w(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Zl=(i,t)=>{for(var e in t||(t={}))zw.call(t,e)&&Wl(i,e,t[e]);if(Yl)for(var e of Yl(t))Lw.call(t,e)&&Wl(i,e,t[e]);return i};const Kw="ReactNative",mr={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},Hw="js";function Hn(){return typeof A.process$1<"u"&&typeof A.process$1.versions<"u"&&typeof A.process$1.versions.node<"u"}function Gn(){return!A.getDocument_1()&&!!A.getNavigator_1()&&navigator.product===Kw}function Yn(){return!Hn()&&!!A.getNavigator_1()&&!!A.getDocument_1()}function Wn(){return Gn()?mr.reactNative:Hn()?mr.node:Yn()?mr.browser:mr.unknown}function Vw(){var i;try{return Gn()&&typeof A.global<"u"&&typeof(A.global==null?void 0:A.global.Application)<"u"?(i=A.global.Application)==null?void 0:i.applicationId:void 0}catch{return}}function Jw(i,t){let e=A.queryString.parse(i);return e=Zl(Zl({},e),t),i=A.queryString.stringify(e),i}function Qw(){return A.getWindowMetadata_1()||{name:"",description:"",url:"",icons:[""]}}function Gw(){if(Wn()===mr.reactNative&&typeof A.global<"u"&&typeof(A.global==null?void 0:A.global.Platform)<"u"){const{OS:e,Version:s}=A.global.Platform;return[e,s].join("-")}const i=A.detect();if(i===null)return"unknown";const t=i.os?i.os.replace(" ","").toLowerCase():"unknown";return i.type==="browser"?[t,i.name,i.version].join("-"):[t,i.version].join("-")}function Yw(){var i;const t=Wn();return t===mr.browser?[t,((i=A.getLocation_1())==null?void 0:i.host)||"unknown"].join(":"):t}function Ww(i,t,e){const s=Gw(),o=Yw();return[[i,t].join("-"),[Hw,e].join("-"),s,o].join("/")}function Zw({protocol:i,version:t,relayUrl:e,sdkVersion:s,auth:o,projectId:a,useOnCloseEvent:h,bundleId:p}){const v=e.split("?"),y=Ww(i,t,s),M={auth:o,ua:y,projectId:a,useOnCloseEvent:h||void 0,origin:p||void 0},P=Jw(v[1]||"",M);return v[0]+"?"+P}function ws(i,t){return i.filter(e=>t.includes(e)).length===i.length}function Ep(i){return Object.fromEntries(i.entries())}function Ip(i){return new Map(Object.entries(i))}function ys(i=A.cjs.FIVE_MINUTES,t){const e=A.cjs.toMiliseconds(i||A.cjs.FIVE_MINUTES);let s,o,a;return{resolve:h=>{a&&s&&(clearTimeout(a),s(h))},reject:h=>{a&&o&&(clearTimeout(a),o(h))},done:()=>new Promise((h,p)=>{a=setTimeout(()=>{p(new Error(t))},e),s=h,o=p})}}function Qs(i,t,e){return new Promise(async(s,o)=>{const a=setTimeout(()=>o(new Error(e)),t);try{const h=await i;s(h)}catch(h){o(h)}clearTimeout(a)})}function Sp(i,t){if(typeof t=="string"&&t.startsWith(`${i}:`))return t;if(i.toLowerCase()==="topic"){if(typeof t!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}else if(i.toLowerCase()==="id"){if(typeof t!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw new Error(`Unknown expirer target type: ${i}`)}function Xw(i){return Sp("topic",i)}function tb(i){return Sp("id",i)}function Pp(i){const[t,e]=i.split(":"),s={id:void 0,topic:void 0};if(t==="topic"&&typeof e=="string")s.topic=e;else if(t==="id"&&Number.isInteger(Number(e)))s.id=Number(e);else throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${e}`);return s}function Ue(i,t){return A.cjs.fromMiliseconds(Date.now()+A.cjs.toMiliseconds(i))}function rs(i){return Date.now()>=A.cjs.toMiliseconds(i)}function It(i,t){return`${i}${t?`:${t}`:""}`}function Yo(i=[],t=[]){return[...new Set([...i,...t])]}async function eb({id:i,topic:t,wcDeepLink:e}){var s;try{if(!e)return;const o=typeof e=="string"?JSON.parse(e):e;let a=o==null?void 0:o.href;if(typeof a!="string")return;a.endsWith("/")&&(a=a.slice(0,-1));const h=`${a}/wc?requestId=${i}&sessionTopic=${t}`,p=Wn();if(p===mr.browser){if(!((s=A.getDocument_1())!=null&&s.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}h.startsWith("https://")||h.startsWith("http://")?window.open(h,"_blank","noreferrer noopener"):window.open(h,"_self","noreferrer noopener")}else p===mr.reactNative&&typeof(A.global==null?void 0:A.global.Linking)<"u"&&await A.global.Linking.openURL(h)}catch(o){console.error(o)}}async function rb(i,t){try{return await i.getItem(t)||(Yn()?localStorage.getItem(t):void 0)}catch(e){console.error(e)}}function ib(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,i=>{const t=Math.random()*16|0;return(i==="x"?t:t&3|8).toString(16)})}var Mp=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof A.global<"u"?A.global:typeof self<"u"?self:{};function sb(i){var t=i.default;if(typeof t=="function"){var e=function(){return t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(i).forEach(function(s){var o=Object.getOwnPropertyDescriptor(i,s);Object.defineProperty(e,s,o.get?o:{enumerable:!0,get:function(){return i[s]}})}),e}var Cp={exports:{}};/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("./W3MFrameProviderSingleton-C56DqhGz.cjs"),Uw=":";function $n(i){const[t,e]=i.split(Uw);return{namespace:t,reference:e}}function Gl(i,t=[]){const e=[];return Object.keys(i).forEach(s=>{if(t.length&&!t.includes(s))return;const o=i[s];e.push(...o.accounts)}),e}function Ap(i,t){return i.includes(":")?[i]:t.chains||[]}var $w=Object.defineProperty,Yl=Object.getOwnPropertySymbols,zw=Object.prototype.hasOwnProperty,Lw=Object.prototype.propertyIsEnumerable,Wl=(i,t,e)=>t in i?$w(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Zl=(i,t)=>{for(var e in t||(t={}))zw.call(t,e)&&Wl(i,e,t[e]);if(Yl)for(var e of Yl(t))Lw.call(t,e)&&Wl(i,e,t[e]);return i};const Kw="ReactNative",mr={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},Hw="js";function Hn(){return typeof A.process$1<"u"&&typeof A.process$1.versions<"u"&&typeof A.process$1.versions.node<"u"}function Gn(){return!A.getDocument_1()&&!!A.getNavigator_1()&&navigator.product===Kw}function Yn(){return!Hn()&&!!A.getNavigator_1()&&!!A.getDocument_1()}function Wn(){return Gn()?mr.reactNative:Hn()?mr.node:Yn()?mr.browser:mr.unknown}function Vw(){var i;try{return Gn()&&typeof A.global<"u"&&typeof(A.global==null?void 0:A.global.Application)<"u"?(i=A.global.Application)==null?void 0:i.applicationId:void 0}catch{return}}function Jw(i,t){let e=A.queryString.parse(i);return e=Zl(Zl({},e),t),i=A.queryString.stringify(e),i}function Qw(){return A.getWindowMetadata_1()||{name:"",description:"",url:"",icons:[""]}}function Gw(){if(Wn()===mr.reactNative&&typeof A.global<"u"&&typeof(A.global==null?void 0:A.global.Platform)<"u"){const{OS:e,Version:s}=A.global.Platform;return[e,s].join("-")}const i=A.detect();if(i===null)return"unknown";const t=i.os?i.os.replace(" ","").toLowerCase():"unknown";return i.type==="browser"?[t,i.name,i.version].join("-"):[t,i.version].join("-")}function Yw(){var i;const t=Wn();return t===mr.browser?[t,((i=A.getLocation_1())==null?void 0:i.host)||"unknown"].join(":"):t}function Ww(i,t,e){const s=Gw(),o=Yw();return[[i,t].join("-"),[Hw,e].join("-"),s,o].join("/")}function Zw({protocol:i,version:t,relayUrl:e,sdkVersion:s,auth:o,projectId:a,useOnCloseEvent:h,bundleId:p}){const v=e.split("?"),y=Ww(i,t,s),M={auth:o,ua:y,projectId:a,useOnCloseEvent:h||void 0,origin:p||void 0},P=Jw(v[1]||"",M);return v[0]+"?"+P}function ws(i,t){return i.filter(e=>t.includes(e)).length===i.length}function Ep(i){return Object.fromEntries(i.entries())}function Ip(i){return new Map(Object.entries(i))}function ys(i=A.cjs.FIVE_MINUTES,t){const e=A.cjs.toMiliseconds(i||A.cjs.FIVE_MINUTES);let s,o,a;return{resolve:h=>{a&&s&&(clearTimeout(a),s(h))},reject:h=>{a&&o&&(clearTimeout(a),o(h))},done:()=>new Promise((h,p)=>{a=setTimeout(()=>{p(new Error(t))},e),s=h,o=p})}}function Qs(i,t,e){return new Promise(async(s,o)=>{const a=setTimeout(()=>o(new Error(e)),t);try{const h=await i;s(h)}catch(h){o(h)}clearTimeout(a)})}function Sp(i,t){if(typeof t=="string"&&t.startsWith(`${i}:`))return t;if(i.toLowerCase()==="topic"){if(typeof t!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}else if(i.toLowerCase()==="id"){if(typeof t!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw new Error(`Unknown expirer target type: ${i}`)}function Xw(i){return Sp("topic",i)}function tb(i){return Sp("id",i)}function Pp(i){const[t,e]=i.split(":"),s={id:void 0,topic:void 0};if(t==="topic"&&typeof e=="string")s.topic=e;else if(t==="id"&&Number.isInteger(Number(e)))s.id=Number(e);else throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${e}`);return s}function Ue(i,t){return A.cjs.fromMiliseconds(Date.now()+A.cjs.toMiliseconds(i))}function rs(i){return Date.now()>=A.cjs.toMiliseconds(i)}function It(i,t){return`${i}${t?`:${t}`:""}`}function Yo(i=[],t=[]){return[...new Set([...i,...t])]}async function eb({id:i,topic:t,wcDeepLink:e}){var s;try{if(!e)return;const o=typeof e=="string"?JSON.parse(e):e;let a=o==null?void 0:o.href;if(typeof a!="string")return;a.endsWith("/")&&(a=a.slice(0,-1));const h=`${a}/wc?requestId=${i}&sessionTopic=${t}`,p=Wn();if(p===mr.browser){if(!((s=A.getDocument_1())!=null&&s.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}h.startsWith("https://")||h.startsWith("http://")?window.open(h,"_blank","noreferrer noopener"):window.open(h,"_self","noreferrer noopener")}else p===mr.reactNative&&typeof(A.global==null?void 0:A.global.Linking)<"u"&&await A.global.Linking.openURL(h)}catch(o){console.error(o)}}async function rb(i,t){try{return await i.getItem(t)||(Yn()?localStorage.getItem(t):void 0)}catch(e){console.error(e)}}function ib(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,i=>{const t=Math.random()*16|0;return(i==="x"?t:t&3|8).toString(16)})}var Mp=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof A.global<"u"?A.global:typeof self<"u"?self:{};function sb(i){var t=i.default;if(typeof t=="function"){var e=function(){return t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(i).forEach(function(s){var o=Object.getOwnPropertyDescriptor(i,s);Object.defineProperty(e,s,o.get?o:{enumerable:!0,get:function(){return i[s]}})}),e}var Cp={exports:{}};/**
2
2
  * [js-sha3]{@link https://github.com/emn178/js-sha3}
3
3
  *
4
4
  * @version 0.8.0
@@ -40,4 +40,4 @@ __p += '`),Rt&&(J+=`' +
40
40
  function print() { __p += __j.call(arguments, '') }
41
41
  `:`;
42
42
  `)+J+`return __p
43
- }`;var _t=Vl(function(){return qt(_,nt+"return "+J).apply(e,x)});if(_t.source=J,mc(_t))throw _t;return _t}function Jy(r){return jt(r).toLowerCase()}function Qy(r){return jt(r).toUpperCase()}function Gy(r,n,c){if(r=jt(r),r&&(c||n===e))return eu(r);if(!r||!(n=fr(n)))return r;var l=kr(r),g=kr(n),_=ru(l,g),x=iu(l,g)+1;return Xi(l,_,x).join("")}function Yy(r,n,c){if(r=jt(r),r&&(c||n===e))return r.slice(0,nu(r)+1);if(!r||!(n=fr(n)))return r;var l=kr(r),g=iu(l,kr(n))+1;return Xi(l,0,g).join("")}function Wy(r,n,c){if(r=jt(r),r&&(c||n===e))return r.replace(Jt,"");if(!r||!(n=fr(n)))return r;var l=kr(r),g=ru(l,kr(n));return Xi(l,g).join("")}function Zy(r,n){var c=Te,l=Ct;if(be(n)){var g="separator"in n?n.separator:g;c="length"in n?bt(n.length):c,l="omission"in n?fr(n.omission):l}r=jt(r);var _=r.length;if(Ns(r)){var x=kr(r);_=x.length}if(c>=_)return r;var R=c-Os(l);if(R<1)return l;var F=x?Xi(x,0,R).join(""):r.slice(0,R);if(g===e)return F+l;if(x&&(R+=F.length-R),vc(g)){if(r.slice(R).search(g)){var z,L=F;for(g.global||(g=Ta(g.source,jt(Zt.exec(g))+"g")),g.lastIndex=0;z=g.exec(L);)var J=z.index;F=F.slice(0,J===e?R:J)}}else if(r.indexOf(fr(g),R)!=R){var Z=F.lastIndexOf(g);Z>-1&&(F=F.slice(0,Z))}return F+l}function Xy(r){return r=jt(r),r&&se.test(r)?r.replace(Yt,C0):r}var tw=js(function(r,n,c){return r+(c?" ":"")+n.toUpperCase()}),bc=Ju("toUpperCase");function Hl(r,n,c){return r=jt(r),n=c?e:n,n===e?E0(r)?N0(r):d0(r):r.match(n)||[]}var Vl=At(function(r,n){try{return ur(r,e,n)}catch(c){return mc(c)?c:new vt(c)}}),ew=Oi(function(r,n){return br(n,function(c){c=oi(c),Ri(r,c,dc(r[c],r))}),r});function rw(r){var n=r==null?0:r.length,c=ft();return r=n?we(r,function(l){if(typeof l[1]!="function")throw new _r(h);return[c(l[0]),l[1]]}):[],At(function(l){for(var g=-1;++g<n;){var _=r[g];if(ur(_[0],this,l))return ur(_[1],this,l)}})}function iw(r){return Cg(Er(r,P))}function _c(r){return function(){return r}}function sw(r,n){return r==null||r!==r?n:r}var nw=Gu(),ow=Gu(!0);function rr(r){return r}function Ac(r){return Su(typeof r=="function"?r:Er(r,P))}function aw(r){return Mu(Er(r,P))}function cw(r,n){return Cu(r,Er(n,P))}var hw=At(function(r,n){return function(c){return An(c,r,n)}}),uw=At(function(r,n){return function(c){return An(r,c,n)}});function Ec(r,n,c){var l=Fe(n),g=Ao(n,l);c==null&&!(be(n)&&(g.length||!l.length))&&(c=n,n=r,r=this,g=Ao(n,Fe(n)));var _=!(be(c)&&"chain"in c)||!!c.chain,x=Fi(r);return br(g,function(R){var F=n[R];r[R]=F,x&&(r.prototype[R]=function(){var z=this.__chain__;if(_||z){var L=r(this.__wrapped__),J=L.__actions__=Xe(this.__actions__);return J.push({func:F,args:arguments,thisArg:r}),L.__chain__=z,L}return F.apply(r,Ji([this.value()],arguments))})}),r}function lw(){return qe._===this&&(qe._=k0),this}function Ic(){}function fw(r){return r=bt(r),At(function(n){return xu(n,r)})}var pw=ec(we),dw=ec(Yh),gw=ec(Pa);function Jl(r){return cc(r)?Ma(oi(r)):Hg(r)}function mw(r){return function(n){return r==null?e:ls(r,n)}}var vw=Wu(),yw=Wu(!0);function Sc(){return[]}function Pc(){return!1}function ww(){return{}}function bw(){return""}function _w(){return!0}function Aw(r,n){if(r=bt(r),r<1||r>N)return[];var c=f,l=Le(r,f);n=ft(n),r-=f;for(var g=Ra(l,n);++c<r;)n(c);return g}function Ew(r){return yt(r)?we(r,oi):pr(r)?[r]:Xe(pl(jt(r)))}function Iw(r){var n=++D0;return jt(r)+n}var Sw=Co(function(r,n){return r+n},0),Pw=rc("ceil"),Mw=Co(function(r,n){return r/n},1),Cw=rc("floor");function xw(r){return r&&r.length?_o(r,rr,$a):e}function Rw(r,n){return r&&r.length?_o(r,ft(n,2),$a):e}function Nw(r){return Xh(r,rr)}function Ow(r,n){return Xh(r,ft(n,2))}function Tw(r){return r&&r.length?_o(r,rr,Ha):e}function Fw(r,n){return r&&r.length?_o(r,ft(n,2),Ha):e}var Dw=Co(function(r,n){return r*n},1),qw=rc("round"),kw=Co(function(r,n){return r-n},0);function Bw(r){return r&&r.length?xa(r,rr):0}function jw(r,n){return r&&r.length?xa(r,ft(n,2)):0}return w.after=av,w.ary=Il,w.assign=Qv,w.assignIn=Bl,w.assignInWith=$o,w.assignWith=Gv,w.at=Yv,w.before=Sl,w.bind=dc,w.bindAll=ew,w.bindKey=Pl,w.castArray=wv,w.chain=_l,w.chunk=C1,w.compact=x1,w.concat=R1,w.cond=rw,w.conforms=iw,w.constant=_c,w.countBy=Bm,w.create=Wv,w.curry=Ml,w.curryRight=Cl,w.debounce=xl,w.defaults=Zv,w.defaultsDeep=Xv,w.defer=cv,w.delay=hv,w.difference=N1,w.differenceBy=O1,w.differenceWith=T1,w.drop=F1,w.dropRight=D1,w.dropRightWhile=q1,w.dropWhile=k1,w.fill=B1,w.filter=Um,w.flatMap=Lm,w.flatMapDeep=Km,w.flatMapDepth=Hm,w.flatten=vl,w.flattenDeep=j1,w.flattenDepth=U1,w.flip=uv,w.flow=nw,w.flowRight=ow,w.fromPairs=$1,w.functions=oy,w.functionsIn=ay,w.groupBy=Vm,w.initial=L1,w.intersection=K1,w.intersectionBy=H1,w.intersectionWith=V1,w.invert=hy,w.invertBy=uy,w.invokeMap=Qm,w.iteratee=Ac,w.keyBy=Gm,w.keys=Fe,w.keysIn=er,w.map=Do,w.mapKeys=fy,w.mapValues=py,w.matches=aw,w.matchesProperty=cw,w.memoize=ko,w.merge=dy,w.mergeWith=jl,w.method=hw,w.methodOf=uw,w.mixin=Ec,w.negate=Bo,w.nthArg=fw,w.omit=gy,w.omitBy=my,w.once=lv,w.orderBy=Ym,w.over=pw,w.overArgs=fv,w.overEvery=dw,w.overSome=gw,w.partial=gc,w.partialRight=Rl,w.partition=Wm,w.pick=vy,w.pickBy=Ul,w.property=Jl,w.propertyOf=mw,w.pull=Y1,w.pullAll=wl,w.pullAllBy=W1,w.pullAllWith=Z1,w.pullAt=X1,w.range=vw,w.rangeRight=yw,w.rearg=pv,w.reject=tv,w.remove=tm,w.rest=dv,w.reverse=fc,w.sampleSize=rv,w.set=wy,w.setWith=by,w.shuffle=iv,w.slice=em,w.sortBy=ov,w.sortedUniq=cm,w.sortedUniqBy=hm,w.split=Ly,w.spread=gv,w.tail=um,w.take=lm,w.takeRight=fm,w.takeRightWhile=pm,w.takeWhile=dm,w.tap=xm,w.throttle=mv,w.thru=Fo,w.toArray=Dl,w.toPairs=$l,w.toPairsIn=zl,w.toPath=Ew,w.toPlainObject=kl,w.transform=_y,w.unary=vv,w.union=gm,w.unionBy=mm,w.unionWith=vm,w.uniq=ym,w.uniqBy=wm,w.uniqWith=bm,w.unset=Ay,w.unzip=pc,w.unzipWith=bl,w.update=Ey,w.updateWith=Iy,w.values=zs,w.valuesIn=Sy,w.without=_m,w.words=Hl,w.wrap=yv,w.xor=Am,w.xorBy=Em,w.xorWith=Im,w.zip=Sm,w.zipObject=Pm,w.zipObjectDeep=Mm,w.zipWith=Cm,w.entries=$l,w.entriesIn=zl,w.extend=Bl,w.extendWith=$o,Ec(w,w),w.add=Sw,w.attempt=Vl,w.camelCase=xy,w.capitalize=Ll,w.ceil=Pw,w.clamp=Py,w.clone=bv,w.cloneDeep=Av,w.cloneDeepWith=Ev,w.cloneWith=_v,w.conformsTo=Iv,w.deburr=Kl,w.defaultTo=sw,w.divide=Mw,w.endsWith=Ry,w.eq=jr,w.escape=Ny,w.escapeRegExp=Oy,w.every=jm,w.find=$m,w.findIndex=gl,w.findKey=ty,w.findLast=zm,w.findLastIndex=ml,w.findLastKey=ey,w.floor=Cw,w.forEach=Al,w.forEachRight=El,w.forIn=ry,w.forInRight=iy,w.forOwn=sy,w.forOwnRight=ny,w.get=yc,w.gt=Sv,w.gte=Pv,w.has=cy,w.hasIn=wc,w.head=yl,w.identity=rr,w.includes=Jm,w.indexOf=z1,w.inRange=My,w.invoke=ly,w.isArguments=ds,w.isArray=yt,w.isArrayBuffer=Mv,w.isArrayLike=tr,w.isArrayLikeObject=Ee,w.isBoolean=Cv,w.isBuffer=ts,w.isDate=xv,w.isElement=Rv,w.isEmpty=Nv,w.isEqual=Ov,w.isEqualWith=Tv,w.isError=mc,w.isFinite=Fv,w.isFunction=Fi,w.isInteger=Nl,w.isLength=jo,w.isMap=Ol,w.isMatch=Dv,w.isMatchWith=qv,w.isNaN=kv,w.isNative=Bv,w.isNil=Uv,w.isNull=jv,w.isNumber=Tl,w.isObject=be,w.isObjectLike=_e,w.isPlainObject=Cn,w.isRegExp=vc,w.isSafeInteger=$v,w.isSet=Fl,w.isString=Uo,w.isSymbol=pr,w.isTypedArray=$s,w.isUndefined=zv,w.isWeakMap=Lv,w.isWeakSet=Kv,w.join=J1,w.kebabCase=Ty,w.last=Sr,w.lastIndexOf=Q1,w.lowerCase=Fy,w.lowerFirst=Dy,w.lt=Hv,w.lte=Vv,w.max=xw,w.maxBy=Rw,w.mean=Nw,w.meanBy=Ow,w.min=Tw,w.minBy=Fw,w.stubArray=Sc,w.stubFalse=Pc,w.stubObject=ww,w.stubString=bw,w.stubTrue=_w,w.multiply=Dw,w.nth=G1,w.noConflict=lw,w.noop=Ic,w.now=qo,w.pad=qy,w.padEnd=ky,w.padStart=By,w.parseInt=jy,w.random=Cy,w.reduce=Zm,w.reduceRight=Xm,w.repeat=Uy,w.replace=$y,w.result=yy,w.round=qw,w.runInContext=O,w.sample=ev,w.size=sv,w.snakeCase=zy,w.some=nv,w.sortedIndex=rm,w.sortedIndexBy=im,w.sortedIndexOf=sm,w.sortedLastIndex=nm,w.sortedLastIndexBy=om,w.sortedLastIndexOf=am,w.startCase=Ky,w.startsWith=Hy,w.subtract=kw,w.sum=Bw,w.sumBy=jw,w.template=Vy,w.times=Aw,w.toFinite=Di,w.toInteger=bt,w.toLength=ql,w.toLower=Jy,w.toNumber=Pr,w.toSafeInteger=Jv,w.toString=jt,w.toUpper=Qy,w.trim=Gy,w.trimEnd=Yy,w.trimStart=Wy,w.truncate=Zy,w.unescape=Xy,w.uniqueId=Iw,w.upperCase=tw,w.upperFirst=bc,w.each=Al,w.eachRight=El,w.first=yl,Ec(w,function(){var r={};return si(w,function(n,c){Qt.call(w.prototype,c)||(r[c]=n)}),r}(),{chain:!1}),w.VERSION=s,br(["bind","bindKey","curry","curryRight","partial","partialRight"],function(r){w[r].placeholder=w}),br(["drop","take"],function(r,n){St.prototype[r]=function(c){c=c===e?1:Re(bt(c),0);var l=this.__filtered__&&!n?new St(this):this.clone();return l.__filtered__?l.__takeCount__=Le(c,l.__takeCount__):l.__views__.push({size:Le(c,f),type:r+(l.__dir__<0?"Right":"")}),l},St.prototype[r+"Right"]=function(c){return this.reverse()[r](c).reverse()}}),br(["filter","map","takeWhile"],function(r,n){var c=n+1,l=c==d||c==I;St.prototype[r]=function(g){var _=this.clone();return _.__iteratees__.push({iteratee:ft(g,3),type:c}),_.__filtered__=_.__filtered__||l,_}}),br(["head","last"],function(r,n){var c="take"+(n?"Right":"");St.prototype[r]=function(){return this[c](1).value()[0]}}),br(["initial","tail"],function(r,n){var c="drop"+(n?"":"Right");St.prototype[r]=function(){return this.__filtered__?new St(this):this[c](1)}}),St.prototype.compact=function(){return this.filter(rr)},St.prototype.find=function(r){return this.filter(r).head()},St.prototype.findLast=function(r){return this.reverse().find(r)},St.prototype.invokeMap=At(function(r,n){return typeof r=="function"?new St(this):this.map(function(c){return An(c,r,n)})}),St.prototype.reject=function(r){return this.filter(Bo(ft(r)))},St.prototype.slice=function(r,n){r=bt(r);var c=this;return c.__filtered__&&(r>0||n<0)?new St(c):(r<0?c=c.takeRight(-r):r&&(c=c.drop(r)),n!==e&&(n=bt(n),c=n<0?c.dropRight(-n):c.take(n-r)),c)},St.prototype.takeRightWhile=function(r){return this.reverse().takeWhile(r).reverse()},St.prototype.toArray=function(){return this.take(f)},si(St.prototype,function(r,n){var c=/^(?:filter|find|map|reject)|While$/.test(n),l=/^(?:head|last)$/.test(n),g=w[l?"take"+(n=="last"?"Right":""):n],_=l||/^find/.test(n);g&&(w.prototype[n]=function(){var x=this.__wrapped__,R=l?[1]:arguments,F=x instanceof St,z=R[0],L=F||yt(x),J=function(Et){var Rt=g.apply(w,Ji([Et],R));return l&&Z?Rt[0]:Rt};L&&c&&typeof z=="function"&&z.length!=1&&(F=L=!1);var Z=this.__chain__,nt=!!this.__actions__.length,pt=_&&!Z,_t=F&&!nt;if(!_&&L){x=_t?x:new St(this);var dt=r.apply(x,R);return dt.__actions__.push({func:Fo,args:[J],thisArg:e}),new Ar(dt,Z)}return pt&&_t?r.apply(this,R):(dt=this.thru(J),pt?l?dt.value()[0]:dt.value():dt)})}),br(["pop","push","shift","sort","splice","unshift"],function(r){var n=no[r],c=/^(?:push|sort|unshift)$/.test(r)?"tap":"thru",l=/^(?:pop|shift)$/.test(r);w.prototype[r]=function(){var g=arguments;if(l&&!this.__chain__){var _=this.value();return n.apply(yt(_)?_:[],g)}return this[c](function(x){return n.apply(yt(x)?x:[],g)})}}),si(St.prototype,function(r,n){var c=w[n];if(c){var l=c.name+"";Qt.call(qs,l)||(qs[l]=[]),qs[l].push({name:n,func:c})}}),qs[Mo(e,Q).name]=[{name:"wrapper",func:e}],St.prototype.clone=X0,St.prototype.reverse=tg,St.prototype.value=eg,w.prototype.at=Rm,w.prototype.chain=Nm,w.prototype.commit=Om,w.prototype.next=Tm,w.prototype.plant=Dm,w.prototype.reverse=qm,w.prototype.toJSON=w.prototype.valueOf=w.prototype.value=km,w.prototype.first=w.prototype.head,gn&&(w.prototype[gn]=Fm),w},Ts=O0();os?((os.exports=Ts)._=Ts,Aa._=Ts):qe._=Ts}).call(kn)})(lh,lh.exports);var jI=Object.defineProperty,UI=Object.defineProperties,$I=Object.getOwnPropertyDescriptors,up=Object.getOwnPropertySymbols,zI=Object.prototype.hasOwnProperty,LI=Object.prototype.propertyIsEnumerable,lp=(i,t,e)=>t in i?jI(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Jo=(i,t)=>{for(var e in t||(t={}))zI.call(t,e)&&lp(i,e,t[e]);if(up)for(var e of up(t))LI.call(t,e)&&lp(i,e,t[e]);return i},KI=(i,t)=>UI(i,$I(t));function Qr(i,t,e){var s;const o=$n(i);return((s=t.rpcMap)==null?void 0:s[o.reference])||`${BI}?chainId=${o.namespace}:${o.reference}&projectId=${e}`}function Ss(i){return i.includes(":")?i.split(":")[1]:i}function qd(i){return i.map(t=>`${t.split(":")[0]}:${t.split(":")[1]}`)}function HI(i,t){const e=Object.keys(t.namespaces).filter(o=>o.includes(i));if(!e.length)return[];const s=[];return e.forEach(o=>{const a=t.namespaces[o].accounts;s.push(...a)}),s}function Qc(i={},t={}){const e=fp(i),s=fp(t);return lh.exports.merge(e,s)}function fp(i){var t,e,s,o;const a={};if(!Qn(i))return a;for(const[h,p]of Object.entries(i)){const v=bh(h)?[h]:p.chains,y=p.methods||[],M=p.events||[],P=p.rpcMap||{},T=Un(h);a[T]=KI(Jo(Jo({},a[T]),p),{chains:Yo(v,(t=a[T])==null?void 0:t.chains),methods:Yo(y,(e=a[T])==null?void 0:e.methods),events:Yo(M,(s=a[T])==null?void 0:s.events),rpcMap:Jo(Jo({},P),(o=a[T])==null?void 0:o.rpcMap)})}return a}function VI(i){return i.includes(":")?i.split(":")[2]:i}function pp(i){const t={};for(const[e,s]of Object.entries(i)){const o=s.methods||[],a=s.events||[],h=s.accounts||[],p=bh(e)?[e]:s.chains?s.chains:qd(s.accounts);t[e]={chains:p,methods:o,events:a,accounts:h}}return t}function Gc(i){return typeof i=="number"?i:i.includes("0x")?parseInt(i,16):(i=i.includes(":")?i.split(":")[1]:i,isNaN(Number(i))?i:Number(i))}const kd={},Ut=i=>kd[i],Yc=(i,t)=>{kd[i]=t};class JI{constructor(t){this.name="polkadot",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const o=Ss(e);t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}}var QI=Object.defineProperty,GI=Object.defineProperties,YI=Object.getOwnPropertyDescriptors,dp=Object.getOwnPropertySymbols,WI=Object.prototype.hasOwnProperty,ZI=Object.prototype.propertyIsEnumerable,gp=(i,t,e)=>t in i?QI(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,mp=(i,t)=>{for(var e in t||(t={}))WI.call(t,e)&&gp(i,e,t[e]);if(dp)for(var e of dp(t))ZI.call(t,e)&&gp(i,e,t[e]);return i},vp=(i,t)=>GI(i,YI(t));class XI{constructor(t){this.name="eip155",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(t){switch(t.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(t);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(t)}return this.namespace.methods.includes(t.request.method)?await this.client.request(t):this.getHttpProvider().request(t.request)}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(parseInt(t),e),this.chainId=parseInt(t),this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}createHttpProvider(t,e){const s=e||Qr(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const o=parseInt(Ss(e));t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}getHttpProvider(){const t=this.chainId,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}async handleSwitchChain(t){var e,s;let o=t.request.params?(e=t.request.params[0])==null?void 0:e.chainId:"0x0";o=o.startsWith("0x")?o:`0x${o}`;const a=parseInt(o,16);if(this.isChainApproved(a))this.setDefaultChain(`${a}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:t.topic,request:{method:t.request.method,params:[{chainId:o}]},chainId:(s=this.namespace.chains)==null?void 0:s[0]}),this.setDefaultChain(`${a}`);else throw new Error(`Failed to switch to chain 'eip155:${a}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(t){return this.namespace.chains.includes(`${this.name}:${t}`)}async getCapabilities(t){var e,s,o;const a=(s=(e=t.request)==null?void 0:e.params)==null?void 0:s[0];if(!a)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const h=this.client.session.get(t.topic),p=((o=h==null?void 0:h.sessionProperties)==null?void 0:o.capabilities)||{};if(p!=null&&p[a])return p==null?void 0:p[a];const v=await this.client.request(t);try{await this.client.session.update(t.topic,{sessionProperties:vp(mp({},h.sessionProperties||{}),{capabilities:vp(mp({},p||{}),{[a]:v})})})}catch(y){console.warn("Failed to update session with capabilities",y)}return v}}class t8{constructor(t){this.name="solana",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const o=Ss(e);t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}}class e8{constructor(t){this.name="cosmos",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const o=Ss(e);t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}}class r8{constructor(t){this.name="algorand",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){if(!this.httpProviders[t]){const s=e||Qr(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;t[e]=this.createHttpProvider(e,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace,this.client.core.projectId);return typeof s>"u"?void 0:new A.o(new A.f$1(s,Ut("disableProviderPing")))}}class i8{constructor(t){this.name="cip34",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{const s=this.getCardanoRPCUrl(e),o=Ss(e);t[o]=this.createHttpProvider(o,s)}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}getCardanoRPCUrl(t){const e=this.namespace.rpcMap;if(e)return e[t]}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||this.getCardanoRPCUrl(t);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}}class s8{constructor(t){this.name="elrond",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const o=Ss(e);t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}}class n8{constructor(t){this.name="multiversx",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const o=Ss(e);t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}}class o8{constructor(t){this.name="near",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){if(this.chainId=t,!this.httpProviders[t]){const s=e||Qr(`${this.name}:${t}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;t[e]=this.createHttpProvider(e,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace);return typeof s>"u"?void 0:new A.o(new A.f$1(s,Ut("disableProviderPing")))}}class a8{constructor(t){this.name=Hs,this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(t.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(t.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(t.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(t.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider(t.chainId).request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){var t,e;const s={};return(e=(t=this.namespace)==null?void 0:t.accounts)==null||e.forEach(o=>{const a=$n(o);s[`${a.namespace}:${a.reference}`]=this.createHttpProvider(o)}),s}getHttpProvider(t){const e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}}var c8=Object.defineProperty,h8=Object.defineProperties,u8=Object.getOwnPropertyDescriptors,yp=Object.getOwnPropertySymbols,l8=Object.prototype.hasOwnProperty,f8=Object.prototype.propertyIsEnumerable,wp=(i,t,e)=>t in i?c8(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Qo=(i,t)=>{for(var e in t||(t={}))l8.call(t,e)&&wp(i,e,t[e]);if(yp)for(var e of yp(t))f8.call(t,e)&&wp(i,e,t[e]);return i},Wc=(i,t)=>h8(i,u8(t));class Ph{constructor(t){this.events=new A.Gg,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=t,this.logger=typeof(t==null?void 0:t.logger)<"u"&&typeof(t==null?void 0:t.logger)!="string"?t.logger:A.Wg(A.k({level:(t==null?void 0:t.logger)||cp})),this.disableProviderPing=(t==null?void 0:t.disableProviderPing)||!1}static async init(t){const e=new Ph(t);return await e.initialize(),e}async request(t,e,s){const[o,a]=this.validateChain(e);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(o).request({request:Qo({},t),chainId:`${o}:${a}`,topic:this.session.topic,expiry:s})}sendAsync(t,e,s,o){const a=new Date().getTime();this.request(t,s,o).then(h=>e(null,A.formatJsonRpcResult(a,h))).catch(h=>e(h,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var t;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(t=this.session)==null?void 0:t.topic,reason:Gt("USER_DISCONNECTED")}),await this.cleanup()}async connect(t){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(t),await this.cleanupPendingPairings(),!t.skipPairing)return await this.pair(t.pairingTopic)}async authenticate(t){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(t),await this.cleanupPendingPairings();const{uri:e,response:s}=await this.client.authenticate(t);e&&(this.uri=e,this.events.emit("display_uri",e));const o=await s();if(this.session=o.session,this.session){const a=pp(this.session.namespaces);this.namespaces=Qc(this.namespaces,a),this.persist("namespaces",this.namespaces),this.onConnect()}return o}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}removeListener(t,e){this.events.removeListener(t,e)}off(t,e){this.events.off(t,e)}get isWalletConnect(){return!0}async pair(t){this.shouldAbortPairingAttempt=!1;let e=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(e>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:s,approval:o}=await this.client.connect({pairingTopic:t,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});s&&(this.uri=s,this.events.emit("display_uri",s)),await o().then(a=>{this.session=a;const h=pp(a.namespaces);this.namespaces=Qc(this.namespaces,h),this.persist("namespaces",this.namespaces)}).catch(a=>{if(a.message!==Dd)throw a;e++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(t,e){try{if(!this.session)return;const[s,o]=this.validateChain(t),a=this.getProvider(s);a.name===Hs?a.setDefaultChain(`${s}:${o}`,e):a.setDefaultChain(o,e)}catch(s){if(!/Please call connect/.test(s.message))throw s}}async cleanupPendingPairings(t={}){this.logger.info("Cleaning up inactive pairings...");const e=this.client.pairing.getAll();if(yi(e)){for(const s of e)t.deletePairings?this.client.core.expirer.set(s.topic,0):await this.client.core.relayer.subscriber.unsubscribe(s.topic);this.logger.info(`Inactive pairings cleared: ${e.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const t=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[t]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await Sh.init({core:this.providerOpts.core,logger:this.providerOpts.logger||cp,relayUrl:this.providerOpts.relayUrl||DI,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const t=[...new Set(Object.keys(this.session.namespaces).map(e=>Un(e)))];Yc("client",this.client),Yc("events",this.events),Yc("disableProviderPing",this.disableProviderPing),t.forEach(e=>{if(!this.session)return;const s=HI(e,this.session),o=qd(s),a=Qc(this.namespaces,this.optionalNamespaces),h=Wc(Qo({},a[e]),{accounts:s,chains:o});switch(e){case"eip155":this.rpcProviders[e]=new XI({namespace:h});break;case"algorand":this.rpcProviders[e]=new r8({namespace:h});break;case"solana":this.rpcProviders[e]=new t8({namespace:h});break;case"cosmos":this.rpcProviders[e]=new e8({namespace:h});break;case"polkadot":this.rpcProviders[e]=new JI({namespace:h});break;case"cip34":this.rpcProviders[e]=new i8({namespace:h});break;case"elrond":this.rpcProviders[e]=new s8({namespace:h});break;case"multiversx":this.rpcProviders[e]=new n8({namespace:h});break;case"near":this.rpcProviders[e]=new o8({namespace:h});break;default:this.rpcProviders[Hs]?this.rpcProviders[Hs].updateNamespace(h):this.rpcProviders[Hs]=new a8({namespace:h})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",t=>{this.events.emit("session_ping",t)}),this.client.on("session_event",t=>{const{params:e}=t,{event:s}=e;if(s.name==="accountsChanged"){const o=s.data;o&&yi(o)&&this.events.emit("accountsChanged",o.map(VI))}else if(s.name==="chainChanged"){const o=e.chainId,a=e.event.data,h=Un(o),p=Gc(o)!==Gc(a)?`${h}:${Gc(a)}`:o;this.onChainChanged(p)}else this.events.emit(s.name,s.data);this.events.emit("session_event",t)}),this.client.on("session_update",({topic:t,params:e})=>{var s;const{namespaces:o}=e,a=(s=this.client)==null?void 0:s.session.get(t);this.session=Wc(Qo({},a),{namespaces:o}),this.onSessionUpdate(),this.events.emit("session_update",{topic:t,params:e})}),this.client.on("session_delete",async t=>{await this.cleanup(),this.events.emit("session_delete",t),this.events.emit("disconnect",Wc(Qo({},Gt("USER_DISCONNECTED")),{data:t.topic}))}),this.on(Gr.DEFAULT_CHAIN_CHANGED,t=>{this.onChainChanged(t,!0)})}getProvider(t){return this.rpcProviders[t]||this.rpcProviders[Hs]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(t=>{var e;this.getProvider(t).updateNamespace((e=this.session)==null?void 0:e.namespaces[t])})}setNamespaces(t){const{namespaces:e,optionalNamespaces:s,sessionProperties:o}=t;e&&Object.keys(e).length&&(this.namespaces=e),s&&Object.keys(s).length&&(this.optionalNamespaces=s),this.sessionProperties=o,this.persist("namespaces",e),this.persist("optionalNamespaces",s)}validateChain(t){const[e,s]=(t==null?void 0:t.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[e,s];if(e&&!Object.keys(this.namespaces||{}).map(h=>Un(h)).includes(e))throw new Error(`Namespace '${e}' is not configured. Please call connect() first with namespace config.`);if(e&&s)return[e,s];const o=Un(Object.keys(this.namespaces)[0]),a=this.rpcProviders[o].getDefaultChain();return[o,a]}async requestAccounts(){const[t]=this.validateChain();return await this.getProvider(t).requestAccounts()}onChainChanged(t,e=!1){if(!this.namespaces)return;const[s,o]=this.validateChain(t);o&&(e||this.getProvider(s).setDefaultChain(o),this.namespaces[s]?this.namespaces[s].defaultChain=o:this.namespaces[`${s}:${o}`]?this.namespaces[`${s}:${o}`].defaultChain=o:this.namespaces[`${s}:${o}`]={defaultChain:o},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",o))}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(t,e){this.client.core.storage.setItem(`${hp}/${t}`,e)}async getFromStore(t){return await this.client.core.storage.getItem(`${hp}/${t}`)}}const p8=Ph,d8="wc",g8="ethereum_provider",m8=`${d8}@2:${g8}:`,v8="https://rpc.walletconnect.com/v1/",ua=["eth_sendTransaction","personal_sign"],Bd=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_sendCalls","wallet_getCapabilities","wallet_getCallsStatus","wallet_showCallsStatus"],la=["chainChanged","accountsChanged"],jd=["chainChanged","accountsChanged","message","disconnect","connect"];var y8=Object.defineProperty,w8=Object.defineProperties,b8=Object.getOwnPropertyDescriptors,bp=Object.getOwnPropertySymbols,_8=Object.prototype.hasOwnProperty,A8=Object.prototype.propertyIsEnumerable,_p=(i,t,e)=>t in i?y8(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Vs=(i,t)=>{for(var e in t||(t={}))_8.call(t,e)&&_p(i,e,t[e]);if(bp)for(var e of bp(t))A8.call(t,e)&&_p(i,e,t[e]);return i},Zc=(i,t)=>w8(i,b8(t));function fa(i){return Number(i[0].split(":")[1])}function Go(i){return`0x${i.toString(16)}`}function E8(i){const{chains:t,optionalChains:e,methods:s,optionalMethods:o,events:a,optionalEvents:h,rpcMap:p}=i;if(!yi(t))throw new Error("Invalid chains");const v={chains:t,methods:s||ua,events:a||la,rpcMap:Vs({},t.length?{[fa(t)]:p[fa(t)]}:{})},y=a==null?void 0:a.filter(D=>!la.includes(D)),M=s==null?void 0:s.filter(D=>!ua.includes(D));if(!e&&!h&&!o&&!(y!=null&&y.length)&&!(M!=null&&M.length))return{required:t.length?v:void 0};const P=(y==null?void 0:y.length)&&(M==null?void 0:M.length)||!e,T={chains:[...new Set(P?v.chains.concat(e||[]):e)],methods:[...new Set(v.methods.concat(o!=null&&o.length?o:Bd))],events:[...new Set(v.events.concat(h!=null&&h.length?h:jd))],rpcMap:p};return{required:t.length?v:void 0,optional:e.length?T:void 0}}class ma{constructor(){this.events=new A.eventsExports.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=m8,this.on=(t,e)=>(this.events.on(t,e),this),this.once=(t,e)=>(this.events.once(t,e),this),this.removeListener=(t,e)=>(this.events.removeListener(t,e),this),this.off=(t,e)=>(this.events.off(t,e),this),this.parseAccount=t=>this.isCompatibleChainId(t)?this.parseAccountId(t).address:t,this.signer={},this.rpc={}}static async init(t){const e=new ma;return await e.initialize(t),e}async request(t,e){return await this.signer.request(t,this.formatChainId(this.chainId),e)}sendAsync(t,e,s){this.signer.sendAsync(t,e,this.formatChainId(this.chainId),s)}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(t);const{required:e,optional:s}=E8(this.rpc);try{const o=await new Promise(async(h,p)=>{var v;this.rpc.showQrModal&&((v=this.modal)==null||v.subscribeModal(y=>{!y.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),p(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(Zc(Vs({namespaces:Vs({},e&&{[this.namespace]:e})},s&&{optionalNamespaces:{[this.namespace]:s}}),{pairingTopic:t==null?void 0:t.pairingTopic})).then(y=>{h(y)}).catch(y=>{p(new Error(y.message))})});if(!o)return;const a=Gl(o.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:a),this.setAccounts(a),this.events.emit("connect",{chainId:Go(this.chainId)})}catch(o){throw this.signer.logger.error(o),o}finally{this.modal&&this.modal.closeModal()}}async authenticate(t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts({chains:t==null?void 0:t.chains});try{const e=await new Promise(async(o,a)=>{var h;this.rpc.showQrModal&&((h=this.modal)==null||h.subscribeModal(p=>{!p.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),a(new Error("Connection request reset. Please try again.")))})),await this.signer.authenticate(Zc(Vs({},t),{chains:this.rpc.chains})).then(p=>{o(p)}).catch(p=>{a(new Error(p.message))})}),s=e.session;if(s){const o=Gl(s.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:o),this.setAccounts(o),this.events.emit("connect",{chainId:Go(this.chainId)})}return e}catch(e){throw this.signer.logger.error(e),e}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",t=>{const{params:e}=t,{event:s}=e;s.name==="accountsChanged"?(this.accounts=this.parseAccounts(s.data),this.events.emit("accountsChanged",this.accounts)):s.name==="chainChanged"?this.setChainId(this.formatChainId(s.data)):this.events.emit(s.name,s.data),this.events.emit("session_event",t)}),this.signer.on("chainChanged",t=>{const e=parseInt(t);this.chainId=e,this.events.emit("chainChanged",Go(this.chainId)),this.persist()}),this.signer.on("session_update",t=>{this.events.emit("session_update",t)}),this.signer.on("session_delete",t=>{this.reset(),this.events.emit("session_delete",t),this.events.emit("disconnect",Zc(Vs({},Gt("USER_DISCONNECTED")),{data:t.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",t=>{var e,s;this.rpc.showQrModal&&((e=this.modal)==null||e.closeModal(),(s=this.modal)==null||s.openModal({uri:t})),this.events.emit("display_uri",t)})}switchEthereumChain(t){this.request({method:"wallet_switchEthereumChain",params:[{chainId:t.toString(16)}]})}isCompatibleChainId(t){return typeof t=="string"?t.startsWith(`${this.namespace}:`):!1}formatChainId(t){return`${this.namespace}:${t}`}parseChainId(t){return Number(t.split(":")[1])}setChainIds(t){const e=t.filter(s=>this.isCompatibleChainId(s)).map(s=>this.parseChainId(s));e.length&&(this.chainId=e[0],this.events.emit("chainChanged",Go(this.chainId)),this.persist())}setChainId(t){if(this.isCompatibleChainId(t)){const e=this.parseChainId(t);this.chainId=e,this.switchEthereumChain(e)}}parseAccountId(t){const[e,s,o]=t.split(":");return{chainId:`${e}:${s}`,address:o}}setAccounts(t){this.accounts=t.filter(e=>this.parseChainId(this.parseAccountId(e).chainId)===this.chainId).map(e=>this.parseAccountId(e).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(t){var e,s;const o=(e=t==null?void 0:t.chains)!=null?e:[],a=(s=t==null?void 0:t.optionalChains)!=null?s:[],h=o.concat(a);if(!h.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const p=o.length?(t==null?void 0:t.methods)||ua:[],v=o.length?(t==null?void 0:t.events)||la:[],y=(t==null?void 0:t.optionalMethods)||[],M=(t==null?void 0:t.optionalEvents)||[],P=(t==null?void 0:t.rpcMap)||this.buildRpcMap(h,t.projectId),T=(t==null?void 0:t.qrModalOptions)||void 0;return{chains:o==null?void 0:o.map(D=>this.formatChainId(D)),optionalChains:a.map(D=>this.formatChainId(D)),methods:p,events:v,optionalMethods:y,optionalEvents:M,rpcMap:P,showQrModal:!!(t!=null&&t.showQrModal),qrModalOptions:T,projectId:t.projectId,metadata:t.metadata}}buildRpcMap(t,e){const s={};return t.forEach(o=>{s[o]=this.getRpcUrl(o,e)}),s}async initialize(t){if(this.rpc=this.getRpcConfig(t),this.chainId=this.rpc.chains.length?fa(this.rpc.chains):fa(this.rpc.optionalChains),this.signer=await p8.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:t.disableProviderPing,relayUrl:t.relayUrl,storageOptions:t.storageOptions,customStoragePrefix:t.customStoragePrefix,telemetryEnabled:t.telemetryEnabled}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let e;try{const{WalletConnectModal:s}=await Promise.resolve().then(()=>require("./index-D4J5pbXW.cjs")).then(o=>o.index);e=s}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(e)try{this.modal=new e(Vs({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}catch(s){throw this.signer.logger.error(s),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(t){if(!t)return;const{chains:e,optionalChains:s,rpcMap:o}=t;e&&yi(e)&&(this.rpc.chains=e.map(a=>this.formatChainId(a)),e.forEach(a=>{this.rpc.rpcMap[a]=(o==null?void 0:o[a])||this.getRpcUrl(a)})),s&&yi(s)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=s==null?void 0:s.map(a=>this.formatChainId(a)),s.forEach(a=>{this.rpc.rpcMap[a]=(o==null?void 0:o[a])||this.getRpcUrl(a)}))}getRpcUrl(t,e){var s;return((s=this.rpc.rpcMap)==null?void 0:s[t])||`${v8}?chainId=eip155:${t}&projectId=${e||this.rpc.projectId}`}async loadPersistedSession(){if(this.session)try{const t=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),e=this.session.namespaces[`${this.namespace}:${t}`]?this.session.namespaces[`${this.namespace}:${t}`]:this.session.namespaces[this.namespace];this.setChainIds(t?[this.formatChainId(t)]:e==null?void 0:e.accounts),this.setAccounts(e==null?void 0:e.accounts)}catch(t){this.signer.logger.error("Failed to load persisted session, clearing state..."),this.signer.logger.error(t),await this.disconnect().catch(e=>this.signer.logger.warn(e))}}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(t){return typeof t=="string"||t instanceof String?[this.parseAccount(t)]:t.map(e=>this.parseAccount(e))}}const I8=ma;exports.EthereumProvider=I8;exports.OPTIONAL_EVENTS=jd;exports.OPTIONAL_METHODS=Bd;exports.REQUIRED_EVENTS=la;exports.REQUIRED_METHODS=ua;exports.default=ma;
43
+ }`;var _t=Vl(function(){return qt(_,nt+"return "+J).apply(e,x)});if(_t.source=J,mc(_t))throw _t;return _t}function Jy(r){return jt(r).toLowerCase()}function Qy(r){return jt(r).toUpperCase()}function Gy(r,n,c){if(r=jt(r),r&&(c||n===e))return eu(r);if(!r||!(n=fr(n)))return r;var l=kr(r),g=kr(n),_=ru(l,g),x=iu(l,g)+1;return Xi(l,_,x).join("")}function Yy(r,n,c){if(r=jt(r),r&&(c||n===e))return r.slice(0,nu(r)+1);if(!r||!(n=fr(n)))return r;var l=kr(r),g=iu(l,kr(n))+1;return Xi(l,0,g).join("")}function Wy(r,n,c){if(r=jt(r),r&&(c||n===e))return r.replace(Jt,"");if(!r||!(n=fr(n)))return r;var l=kr(r),g=ru(l,kr(n));return Xi(l,g).join("")}function Zy(r,n){var c=Te,l=Ct;if(be(n)){var g="separator"in n?n.separator:g;c="length"in n?bt(n.length):c,l="omission"in n?fr(n.omission):l}r=jt(r);var _=r.length;if(Ns(r)){var x=kr(r);_=x.length}if(c>=_)return r;var R=c-Os(l);if(R<1)return l;var F=x?Xi(x,0,R).join(""):r.slice(0,R);if(g===e)return F+l;if(x&&(R+=F.length-R),vc(g)){if(r.slice(R).search(g)){var z,L=F;for(g.global||(g=Ta(g.source,jt(Zt.exec(g))+"g")),g.lastIndex=0;z=g.exec(L);)var J=z.index;F=F.slice(0,J===e?R:J)}}else if(r.indexOf(fr(g),R)!=R){var Z=F.lastIndexOf(g);Z>-1&&(F=F.slice(0,Z))}return F+l}function Xy(r){return r=jt(r),r&&se.test(r)?r.replace(Yt,C0):r}var tw=js(function(r,n,c){return r+(c?" ":"")+n.toUpperCase()}),bc=Ju("toUpperCase");function Hl(r,n,c){return r=jt(r),n=c?e:n,n===e?E0(r)?N0(r):d0(r):r.match(n)||[]}var Vl=At(function(r,n){try{return ur(r,e,n)}catch(c){return mc(c)?c:new vt(c)}}),ew=Oi(function(r,n){return br(n,function(c){c=oi(c),Ri(r,c,dc(r[c],r))}),r});function rw(r){var n=r==null?0:r.length,c=ft();return r=n?we(r,function(l){if(typeof l[1]!="function")throw new _r(h);return[c(l[0]),l[1]]}):[],At(function(l){for(var g=-1;++g<n;){var _=r[g];if(ur(_[0],this,l))return ur(_[1],this,l)}})}function iw(r){return Cg(Er(r,P))}function _c(r){return function(){return r}}function sw(r,n){return r==null||r!==r?n:r}var nw=Gu(),ow=Gu(!0);function rr(r){return r}function Ac(r){return Su(typeof r=="function"?r:Er(r,P))}function aw(r){return Mu(Er(r,P))}function cw(r,n){return Cu(r,Er(n,P))}var hw=At(function(r,n){return function(c){return An(c,r,n)}}),uw=At(function(r,n){return function(c){return An(r,c,n)}});function Ec(r,n,c){var l=Fe(n),g=Ao(n,l);c==null&&!(be(n)&&(g.length||!l.length))&&(c=n,n=r,r=this,g=Ao(n,Fe(n)));var _=!(be(c)&&"chain"in c)||!!c.chain,x=Fi(r);return br(g,function(R){var F=n[R];r[R]=F,x&&(r.prototype[R]=function(){var z=this.__chain__;if(_||z){var L=r(this.__wrapped__),J=L.__actions__=Xe(this.__actions__);return J.push({func:F,args:arguments,thisArg:r}),L.__chain__=z,L}return F.apply(r,Ji([this.value()],arguments))})}),r}function lw(){return qe._===this&&(qe._=k0),this}function Ic(){}function fw(r){return r=bt(r),At(function(n){return xu(n,r)})}var pw=ec(we),dw=ec(Yh),gw=ec(Pa);function Jl(r){return cc(r)?Ma(oi(r)):Hg(r)}function mw(r){return function(n){return r==null?e:ls(r,n)}}var vw=Wu(),yw=Wu(!0);function Sc(){return[]}function Pc(){return!1}function ww(){return{}}function bw(){return""}function _w(){return!0}function Aw(r,n){if(r=bt(r),r<1||r>N)return[];var c=f,l=Le(r,f);n=ft(n),r-=f;for(var g=Ra(l,n);++c<r;)n(c);return g}function Ew(r){return yt(r)?we(r,oi):pr(r)?[r]:Xe(pl(jt(r)))}function Iw(r){var n=++D0;return jt(r)+n}var Sw=Co(function(r,n){return r+n},0),Pw=rc("ceil"),Mw=Co(function(r,n){return r/n},1),Cw=rc("floor");function xw(r){return r&&r.length?_o(r,rr,$a):e}function Rw(r,n){return r&&r.length?_o(r,ft(n,2),$a):e}function Nw(r){return Xh(r,rr)}function Ow(r,n){return Xh(r,ft(n,2))}function Tw(r){return r&&r.length?_o(r,rr,Ha):e}function Fw(r,n){return r&&r.length?_o(r,ft(n,2),Ha):e}var Dw=Co(function(r,n){return r*n},1),qw=rc("round"),kw=Co(function(r,n){return r-n},0);function Bw(r){return r&&r.length?xa(r,rr):0}function jw(r,n){return r&&r.length?xa(r,ft(n,2)):0}return w.after=av,w.ary=Il,w.assign=Qv,w.assignIn=Bl,w.assignInWith=$o,w.assignWith=Gv,w.at=Yv,w.before=Sl,w.bind=dc,w.bindAll=ew,w.bindKey=Pl,w.castArray=wv,w.chain=_l,w.chunk=C1,w.compact=x1,w.concat=R1,w.cond=rw,w.conforms=iw,w.constant=_c,w.countBy=Bm,w.create=Wv,w.curry=Ml,w.curryRight=Cl,w.debounce=xl,w.defaults=Zv,w.defaultsDeep=Xv,w.defer=cv,w.delay=hv,w.difference=N1,w.differenceBy=O1,w.differenceWith=T1,w.drop=F1,w.dropRight=D1,w.dropRightWhile=q1,w.dropWhile=k1,w.fill=B1,w.filter=Um,w.flatMap=Lm,w.flatMapDeep=Km,w.flatMapDepth=Hm,w.flatten=vl,w.flattenDeep=j1,w.flattenDepth=U1,w.flip=uv,w.flow=nw,w.flowRight=ow,w.fromPairs=$1,w.functions=oy,w.functionsIn=ay,w.groupBy=Vm,w.initial=L1,w.intersection=K1,w.intersectionBy=H1,w.intersectionWith=V1,w.invert=hy,w.invertBy=uy,w.invokeMap=Qm,w.iteratee=Ac,w.keyBy=Gm,w.keys=Fe,w.keysIn=er,w.map=Do,w.mapKeys=fy,w.mapValues=py,w.matches=aw,w.matchesProperty=cw,w.memoize=ko,w.merge=dy,w.mergeWith=jl,w.method=hw,w.methodOf=uw,w.mixin=Ec,w.negate=Bo,w.nthArg=fw,w.omit=gy,w.omitBy=my,w.once=lv,w.orderBy=Ym,w.over=pw,w.overArgs=fv,w.overEvery=dw,w.overSome=gw,w.partial=gc,w.partialRight=Rl,w.partition=Wm,w.pick=vy,w.pickBy=Ul,w.property=Jl,w.propertyOf=mw,w.pull=Y1,w.pullAll=wl,w.pullAllBy=W1,w.pullAllWith=Z1,w.pullAt=X1,w.range=vw,w.rangeRight=yw,w.rearg=pv,w.reject=tv,w.remove=tm,w.rest=dv,w.reverse=fc,w.sampleSize=rv,w.set=wy,w.setWith=by,w.shuffle=iv,w.slice=em,w.sortBy=ov,w.sortedUniq=cm,w.sortedUniqBy=hm,w.split=Ly,w.spread=gv,w.tail=um,w.take=lm,w.takeRight=fm,w.takeRightWhile=pm,w.takeWhile=dm,w.tap=xm,w.throttle=mv,w.thru=Fo,w.toArray=Dl,w.toPairs=$l,w.toPairsIn=zl,w.toPath=Ew,w.toPlainObject=kl,w.transform=_y,w.unary=vv,w.union=gm,w.unionBy=mm,w.unionWith=vm,w.uniq=ym,w.uniqBy=wm,w.uniqWith=bm,w.unset=Ay,w.unzip=pc,w.unzipWith=bl,w.update=Ey,w.updateWith=Iy,w.values=zs,w.valuesIn=Sy,w.without=_m,w.words=Hl,w.wrap=yv,w.xor=Am,w.xorBy=Em,w.xorWith=Im,w.zip=Sm,w.zipObject=Pm,w.zipObjectDeep=Mm,w.zipWith=Cm,w.entries=$l,w.entriesIn=zl,w.extend=Bl,w.extendWith=$o,Ec(w,w),w.add=Sw,w.attempt=Vl,w.camelCase=xy,w.capitalize=Ll,w.ceil=Pw,w.clamp=Py,w.clone=bv,w.cloneDeep=Av,w.cloneDeepWith=Ev,w.cloneWith=_v,w.conformsTo=Iv,w.deburr=Kl,w.defaultTo=sw,w.divide=Mw,w.endsWith=Ry,w.eq=jr,w.escape=Ny,w.escapeRegExp=Oy,w.every=jm,w.find=$m,w.findIndex=gl,w.findKey=ty,w.findLast=zm,w.findLastIndex=ml,w.findLastKey=ey,w.floor=Cw,w.forEach=Al,w.forEachRight=El,w.forIn=ry,w.forInRight=iy,w.forOwn=sy,w.forOwnRight=ny,w.get=yc,w.gt=Sv,w.gte=Pv,w.has=cy,w.hasIn=wc,w.head=yl,w.identity=rr,w.includes=Jm,w.indexOf=z1,w.inRange=My,w.invoke=ly,w.isArguments=ds,w.isArray=yt,w.isArrayBuffer=Mv,w.isArrayLike=tr,w.isArrayLikeObject=Ee,w.isBoolean=Cv,w.isBuffer=ts,w.isDate=xv,w.isElement=Rv,w.isEmpty=Nv,w.isEqual=Ov,w.isEqualWith=Tv,w.isError=mc,w.isFinite=Fv,w.isFunction=Fi,w.isInteger=Nl,w.isLength=jo,w.isMap=Ol,w.isMatch=Dv,w.isMatchWith=qv,w.isNaN=kv,w.isNative=Bv,w.isNil=Uv,w.isNull=jv,w.isNumber=Tl,w.isObject=be,w.isObjectLike=_e,w.isPlainObject=Cn,w.isRegExp=vc,w.isSafeInteger=$v,w.isSet=Fl,w.isString=Uo,w.isSymbol=pr,w.isTypedArray=$s,w.isUndefined=zv,w.isWeakMap=Lv,w.isWeakSet=Kv,w.join=J1,w.kebabCase=Ty,w.last=Sr,w.lastIndexOf=Q1,w.lowerCase=Fy,w.lowerFirst=Dy,w.lt=Hv,w.lte=Vv,w.max=xw,w.maxBy=Rw,w.mean=Nw,w.meanBy=Ow,w.min=Tw,w.minBy=Fw,w.stubArray=Sc,w.stubFalse=Pc,w.stubObject=ww,w.stubString=bw,w.stubTrue=_w,w.multiply=Dw,w.nth=G1,w.noConflict=lw,w.noop=Ic,w.now=qo,w.pad=qy,w.padEnd=ky,w.padStart=By,w.parseInt=jy,w.random=Cy,w.reduce=Zm,w.reduceRight=Xm,w.repeat=Uy,w.replace=$y,w.result=yy,w.round=qw,w.runInContext=O,w.sample=ev,w.size=sv,w.snakeCase=zy,w.some=nv,w.sortedIndex=rm,w.sortedIndexBy=im,w.sortedIndexOf=sm,w.sortedLastIndex=nm,w.sortedLastIndexBy=om,w.sortedLastIndexOf=am,w.startCase=Ky,w.startsWith=Hy,w.subtract=kw,w.sum=Bw,w.sumBy=jw,w.template=Vy,w.times=Aw,w.toFinite=Di,w.toInteger=bt,w.toLength=ql,w.toLower=Jy,w.toNumber=Pr,w.toSafeInteger=Jv,w.toString=jt,w.toUpper=Qy,w.trim=Gy,w.trimEnd=Yy,w.trimStart=Wy,w.truncate=Zy,w.unescape=Xy,w.uniqueId=Iw,w.upperCase=tw,w.upperFirst=bc,w.each=Al,w.eachRight=El,w.first=yl,Ec(w,function(){var r={};return si(w,function(n,c){Qt.call(w.prototype,c)||(r[c]=n)}),r}(),{chain:!1}),w.VERSION=s,br(["bind","bindKey","curry","curryRight","partial","partialRight"],function(r){w[r].placeholder=w}),br(["drop","take"],function(r,n){St.prototype[r]=function(c){c=c===e?1:Re(bt(c),0);var l=this.__filtered__&&!n?new St(this):this.clone();return l.__filtered__?l.__takeCount__=Le(c,l.__takeCount__):l.__views__.push({size:Le(c,f),type:r+(l.__dir__<0?"Right":"")}),l},St.prototype[r+"Right"]=function(c){return this.reverse()[r](c).reverse()}}),br(["filter","map","takeWhile"],function(r,n){var c=n+1,l=c==d||c==I;St.prototype[r]=function(g){var _=this.clone();return _.__iteratees__.push({iteratee:ft(g,3),type:c}),_.__filtered__=_.__filtered__||l,_}}),br(["head","last"],function(r,n){var c="take"+(n?"Right":"");St.prototype[r]=function(){return this[c](1).value()[0]}}),br(["initial","tail"],function(r,n){var c="drop"+(n?"":"Right");St.prototype[r]=function(){return this.__filtered__?new St(this):this[c](1)}}),St.prototype.compact=function(){return this.filter(rr)},St.prototype.find=function(r){return this.filter(r).head()},St.prototype.findLast=function(r){return this.reverse().find(r)},St.prototype.invokeMap=At(function(r,n){return typeof r=="function"?new St(this):this.map(function(c){return An(c,r,n)})}),St.prototype.reject=function(r){return this.filter(Bo(ft(r)))},St.prototype.slice=function(r,n){r=bt(r);var c=this;return c.__filtered__&&(r>0||n<0)?new St(c):(r<0?c=c.takeRight(-r):r&&(c=c.drop(r)),n!==e&&(n=bt(n),c=n<0?c.dropRight(-n):c.take(n-r)),c)},St.prototype.takeRightWhile=function(r){return this.reverse().takeWhile(r).reverse()},St.prototype.toArray=function(){return this.take(f)},si(St.prototype,function(r,n){var c=/^(?:filter|find|map|reject)|While$/.test(n),l=/^(?:head|last)$/.test(n),g=w[l?"take"+(n=="last"?"Right":""):n],_=l||/^find/.test(n);g&&(w.prototype[n]=function(){var x=this.__wrapped__,R=l?[1]:arguments,F=x instanceof St,z=R[0],L=F||yt(x),J=function(Et){var Rt=g.apply(w,Ji([Et],R));return l&&Z?Rt[0]:Rt};L&&c&&typeof z=="function"&&z.length!=1&&(F=L=!1);var Z=this.__chain__,nt=!!this.__actions__.length,pt=_&&!Z,_t=F&&!nt;if(!_&&L){x=_t?x:new St(this);var dt=r.apply(x,R);return dt.__actions__.push({func:Fo,args:[J],thisArg:e}),new Ar(dt,Z)}return pt&&_t?r.apply(this,R):(dt=this.thru(J),pt?l?dt.value()[0]:dt.value():dt)})}),br(["pop","push","shift","sort","splice","unshift"],function(r){var n=no[r],c=/^(?:push|sort|unshift)$/.test(r)?"tap":"thru",l=/^(?:pop|shift)$/.test(r);w.prototype[r]=function(){var g=arguments;if(l&&!this.__chain__){var _=this.value();return n.apply(yt(_)?_:[],g)}return this[c](function(x){return n.apply(yt(x)?x:[],g)})}}),si(St.prototype,function(r,n){var c=w[n];if(c){var l=c.name+"";Qt.call(qs,l)||(qs[l]=[]),qs[l].push({name:n,func:c})}}),qs[Mo(e,Q).name]=[{name:"wrapper",func:e}],St.prototype.clone=X0,St.prototype.reverse=tg,St.prototype.value=eg,w.prototype.at=Rm,w.prototype.chain=Nm,w.prototype.commit=Om,w.prototype.next=Tm,w.prototype.plant=Dm,w.prototype.reverse=qm,w.prototype.toJSON=w.prototype.valueOf=w.prototype.value=km,w.prototype.first=w.prototype.head,gn&&(w.prototype[gn]=Fm),w},Ts=O0();os?((os.exports=Ts)._=Ts,Aa._=Ts):qe._=Ts}).call(kn)})(lh,lh.exports);var jI=Object.defineProperty,UI=Object.defineProperties,$I=Object.getOwnPropertyDescriptors,up=Object.getOwnPropertySymbols,zI=Object.prototype.hasOwnProperty,LI=Object.prototype.propertyIsEnumerable,lp=(i,t,e)=>t in i?jI(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Jo=(i,t)=>{for(var e in t||(t={}))zI.call(t,e)&&lp(i,e,t[e]);if(up)for(var e of up(t))LI.call(t,e)&&lp(i,e,t[e]);return i},KI=(i,t)=>UI(i,$I(t));function Qr(i,t,e){var s;const o=$n(i);return((s=t.rpcMap)==null?void 0:s[o.reference])||`${BI}?chainId=${o.namespace}:${o.reference}&projectId=${e}`}function Ss(i){return i.includes(":")?i.split(":")[1]:i}function qd(i){return i.map(t=>`${t.split(":")[0]}:${t.split(":")[1]}`)}function HI(i,t){const e=Object.keys(t.namespaces).filter(o=>o.includes(i));if(!e.length)return[];const s=[];return e.forEach(o=>{const a=t.namespaces[o].accounts;s.push(...a)}),s}function Qc(i={},t={}){const e=fp(i),s=fp(t);return lh.exports.merge(e,s)}function fp(i){var t,e,s,o;const a={};if(!Qn(i))return a;for(const[h,p]of Object.entries(i)){const v=bh(h)?[h]:p.chains,y=p.methods||[],M=p.events||[],P=p.rpcMap||{},T=Un(h);a[T]=KI(Jo(Jo({},a[T]),p),{chains:Yo(v,(t=a[T])==null?void 0:t.chains),methods:Yo(y,(e=a[T])==null?void 0:e.methods),events:Yo(M,(s=a[T])==null?void 0:s.events),rpcMap:Jo(Jo({},P),(o=a[T])==null?void 0:o.rpcMap)})}return a}function VI(i){return i.includes(":")?i.split(":")[2]:i}function pp(i){const t={};for(const[e,s]of Object.entries(i)){const o=s.methods||[],a=s.events||[],h=s.accounts||[],p=bh(e)?[e]:s.chains?s.chains:qd(s.accounts);t[e]={chains:p,methods:o,events:a,accounts:h}}return t}function Gc(i){return typeof i=="number"?i:i.includes("0x")?parseInt(i,16):(i=i.includes(":")?i.split(":")[1]:i,isNaN(Number(i))?i:Number(i))}const kd={},Ut=i=>kd[i],Yc=(i,t)=>{kd[i]=t};class JI{constructor(t){this.name="polkadot",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const o=Ss(e);t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}}var QI=Object.defineProperty,GI=Object.defineProperties,YI=Object.getOwnPropertyDescriptors,dp=Object.getOwnPropertySymbols,WI=Object.prototype.hasOwnProperty,ZI=Object.prototype.propertyIsEnumerable,gp=(i,t,e)=>t in i?QI(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,mp=(i,t)=>{for(var e in t||(t={}))WI.call(t,e)&&gp(i,e,t[e]);if(dp)for(var e of dp(t))ZI.call(t,e)&&gp(i,e,t[e]);return i},vp=(i,t)=>GI(i,YI(t));class XI{constructor(t){this.name="eip155",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(t){switch(t.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(t);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(t)}return this.namespace.methods.includes(t.request.method)?await this.client.request(t):this.getHttpProvider().request(t.request)}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(parseInt(t),e),this.chainId=parseInt(t),this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}createHttpProvider(t,e){const s=e||Qr(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const o=parseInt(Ss(e));t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}getHttpProvider(){const t=this.chainId,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}async handleSwitchChain(t){var e,s;let o=t.request.params?(e=t.request.params[0])==null?void 0:e.chainId:"0x0";o=o.startsWith("0x")?o:`0x${o}`;const a=parseInt(o,16);if(this.isChainApproved(a))this.setDefaultChain(`${a}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:t.topic,request:{method:t.request.method,params:[{chainId:o}]},chainId:(s=this.namespace.chains)==null?void 0:s[0]}),this.setDefaultChain(`${a}`);else throw new Error(`Failed to switch to chain 'eip155:${a}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(t){return this.namespace.chains.includes(`${this.name}:${t}`)}async getCapabilities(t){var e,s,o;const a=(s=(e=t.request)==null?void 0:e.params)==null?void 0:s[0];if(!a)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const h=this.client.session.get(t.topic),p=((o=h==null?void 0:h.sessionProperties)==null?void 0:o.capabilities)||{};if(p!=null&&p[a])return p==null?void 0:p[a];const v=await this.client.request(t);try{await this.client.session.update(t.topic,{sessionProperties:vp(mp({},h.sessionProperties||{}),{capabilities:vp(mp({},p||{}),{[a]:v})})})}catch(y){console.warn("Failed to update session with capabilities",y)}return v}}class t8{constructor(t){this.name="solana",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const o=Ss(e);t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}}class e8{constructor(t){this.name="cosmos",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const o=Ss(e);t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}}class r8{constructor(t){this.name="algorand",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){if(!this.httpProviders[t]){const s=e||Qr(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;t[e]=this.createHttpProvider(e,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace,this.client.core.projectId);return typeof s>"u"?void 0:new A.o(new A.f$1(s,Ut("disableProviderPing")))}}class i8{constructor(t){this.name="cip34",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{const s=this.getCardanoRPCUrl(e),o=Ss(e);t[o]=this.createHttpProvider(o,s)}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}getCardanoRPCUrl(t){const e=this.namespace.rpcMap;if(e)return e[t]}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||this.getCardanoRPCUrl(t);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}}class s8{constructor(t){this.name="elrond",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const o=Ss(e);t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}}class n8{constructor(t){this.name="multiversx",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const o=Ss(e);t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}}class o8{constructor(t){this.name="near",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){if(this.chainId=t,!this.httpProviders[t]){const s=e||Qr(`${this.name}:${t}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;t[e]=this.createHttpProvider(e,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace);return typeof s>"u"?void 0:new A.o(new A.f$1(s,Ut("disableProviderPing")))}}class a8{constructor(t){this.name=Hs,this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(t.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(t.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(t.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(t.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider(t.chainId).request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){var t,e;const s={};return(e=(t=this.namespace)==null?void 0:t.accounts)==null||e.forEach(o=>{const a=$n(o);s[`${a.namespace}:${a.reference}`]=this.createHttpProvider(o)}),s}getHttpProvider(t){const e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}}var c8=Object.defineProperty,h8=Object.defineProperties,u8=Object.getOwnPropertyDescriptors,yp=Object.getOwnPropertySymbols,l8=Object.prototype.hasOwnProperty,f8=Object.prototype.propertyIsEnumerable,wp=(i,t,e)=>t in i?c8(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Qo=(i,t)=>{for(var e in t||(t={}))l8.call(t,e)&&wp(i,e,t[e]);if(yp)for(var e of yp(t))f8.call(t,e)&&wp(i,e,t[e]);return i},Wc=(i,t)=>h8(i,u8(t));class Ph{constructor(t){this.events=new A.Gg,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=t,this.logger=typeof(t==null?void 0:t.logger)<"u"&&typeof(t==null?void 0:t.logger)!="string"?t.logger:A.Wg(A.k({level:(t==null?void 0:t.logger)||cp})),this.disableProviderPing=(t==null?void 0:t.disableProviderPing)||!1}static async init(t){const e=new Ph(t);return await e.initialize(),e}async request(t,e,s){const[o,a]=this.validateChain(e);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(o).request({request:Qo({},t),chainId:`${o}:${a}`,topic:this.session.topic,expiry:s})}sendAsync(t,e,s,o){const a=new Date().getTime();this.request(t,s,o).then(h=>e(null,A.formatJsonRpcResult(a,h))).catch(h=>e(h,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var t;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(t=this.session)==null?void 0:t.topic,reason:Gt("USER_DISCONNECTED")}),await this.cleanup()}async connect(t){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(t),await this.cleanupPendingPairings(),!t.skipPairing)return await this.pair(t.pairingTopic)}async authenticate(t){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(t),await this.cleanupPendingPairings();const{uri:e,response:s}=await this.client.authenticate(t);e&&(this.uri=e,this.events.emit("display_uri",e));const o=await s();if(this.session=o.session,this.session){const a=pp(this.session.namespaces);this.namespaces=Qc(this.namespaces,a),this.persist("namespaces",this.namespaces),this.onConnect()}return o}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}removeListener(t,e){this.events.removeListener(t,e)}off(t,e){this.events.off(t,e)}get isWalletConnect(){return!0}async pair(t){this.shouldAbortPairingAttempt=!1;let e=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(e>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:s,approval:o}=await this.client.connect({pairingTopic:t,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});s&&(this.uri=s,this.events.emit("display_uri",s)),await o().then(a=>{this.session=a;const h=pp(a.namespaces);this.namespaces=Qc(this.namespaces,h),this.persist("namespaces",this.namespaces)}).catch(a=>{if(a.message!==Dd)throw a;e++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(t,e){try{if(!this.session)return;const[s,o]=this.validateChain(t),a=this.getProvider(s);a.name===Hs?a.setDefaultChain(`${s}:${o}`,e):a.setDefaultChain(o,e)}catch(s){if(!/Please call connect/.test(s.message))throw s}}async cleanupPendingPairings(t={}){this.logger.info("Cleaning up inactive pairings...");const e=this.client.pairing.getAll();if(yi(e)){for(const s of e)t.deletePairings?this.client.core.expirer.set(s.topic,0):await this.client.core.relayer.subscriber.unsubscribe(s.topic);this.logger.info(`Inactive pairings cleared: ${e.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const t=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[t]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await Sh.init({core:this.providerOpts.core,logger:this.providerOpts.logger||cp,relayUrl:this.providerOpts.relayUrl||DI,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const t=[...new Set(Object.keys(this.session.namespaces).map(e=>Un(e)))];Yc("client",this.client),Yc("events",this.events),Yc("disableProviderPing",this.disableProviderPing),t.forEach(e=>{if(!this.session)return;const s=HI(e,this.session),o=qd(s),a=Qc(this.namespaces,this.optionalNamespaces),h=Wc(Qo({},a[e]),{accounts:s,chains:o});switch(e){case"eip155":this.rpcProviders[e]=new XI({namespace:h});break;case"algorand":this.rpcProviders[e]=new r8({namespace:h});break;case"solana":this.rpcProviders[e]=new t8({namespace:h});break;case"cosmos":this.rpcProviders[e]=new e8({namespace:h});break;case"polkadot":this.rpcProviders[e]=new JI({namespace:h});break;case"cip34":this.rpcProviders[e]=new i8({namespace:h});break;case"elrond":this.rpcProviders[e]=new s8({namespace:h});break;case"multiversx":this.rpcProviders[e]=new n8({namespace:h});break;case"near":this.rpcProviders[e]=new o8({namespace:h});break;default:this.rpcProviders[Hs]?this.rpcProviders[Hs].updateNamespace(h):this.rpcProviders[Hs]=new a8({namespace:h})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",t=>{this.events.emit("session_ping",t)}),this.client.on("session_event",t=>{const{params:e}=t,{event:s}=e;if(s.name==="accountsChanged"){const o=s.data;o&&yi(o)&&this.events.emit("accountsChanged",o.map(VI))}else if(s.name==="chainChanged"){const o=e.chainId,a=e.event.data,h=Un(o),p=Gc(o)!==Gc(a)?`${h}:${Gc(a)}`:o;this.onChainChanged(p)}else this.events.emit(s.name,s.data);this.events.emit("session_event",t)}),this.client.on("session_update",({topic:t,params:e})=>{var s;const{namespaces:o}=e,a=(s=this.client)==null?void 0:s.session.get(t);this.session=Wc(Qo({},a),{namespaces:o}),this.onSessionUpdate(),this.events.emit("session_update",{topic:t,params:e})}),this.client.on("session_delete",async t=>{await this.cleanup(),this.events.emit("session_delete",t),this.events.emit("disconnect",Wc(Qo({},Gt("USER_DISCONNECTED")),{data:t.topic}))}),this.on(Gr.DEFAULT_CHAIN_CHANGED,t=>{this.onChainChanged(t,!0)})}getProvider(t){return this.rpcProviders[t]||this.rpcProviders[Hs]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(t=>{var e;this.getProvider(t).updateNamespace((e=this.session)==null?void 0:e.namespaces[t])})}setNamespaces(t){const{namespaces:e,optionalNamespaces:s,sessionProperties:o}=t;e&&Object.keys(e).length&&(this.namespaces=e),s&&Object.keys(s).length&&(this.optionalNamespaces=s),this.sessionProperties=o,this.persist("namespaces",e),this.persist("optionalNamespaces",s)}validateChain(t){const[e,s]=(t==null?void 0:t.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[e,s];if(e&&!Object.keys(this.namespaces||{}).map(h=>Un(h)).includes(e))throw new Error(`Namespace '${e}' is not configured. Please call connect() first with namespace config.`);if(e&&s)return[e,s];const o=Un(Object.keys(this.namespaces)[0]),a=this.rpcProviders[o].getDefaultChain();return[o,a]}async requestAccounts(){const[t]=this.validateChain();return await this.getProvider(t).requestAccounts()}onChainChanged(t,e=!1){if(!this.namespaces)return;const[s,o]=this.validateChain(t);o&&(e||this.getProvider(s).setDefaultChain(o),this.namespaces[s]?this.namespaces[s].defaultChain=o:this.namespaces[`${s}:${o}`]?this.namespaces[`${s}:${o}`].defaultChain=o:this.namespaces[`${s}:${o}`]={defaultChain:o},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",o))}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(t,e){this.client.core.storage.setItem(`${hp}/${t}`,e)}async getFromStore(t){return await this.client.core.storage.getItem(`${hp}/${t}`)}}const p8=Ph,d8="wc",g8="ethereum_provider",m8=`${d8}@2:${g8}:`,v8="https://rpc.walletconnect.com/v1/",ua=["eth_sendTransaction","personal_sign"],Bd=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_sendCalls","wallet_getCapabilities","wallet_getCallsStatus","wallet_showCallsStatus"],la=["chainChanged","accountsChanged"],jd=["chainChanged","accountsChanged","message","disconnect","connect"];var y8=Object.defineProperty,w8=Object.defineProperties,b8=Object.getOwnPropertyDescriptors,bp=Object.getOwnPropertySymbols,_8=Object.prototype.hasOwnProperty,A8=Object.prototype.propertyIsEnumerable,_p=(i,t,e)=>t in i?y8(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Vs=(i,t)=>{for(var e in t||(t={}))_8.call(t,e)&&_p(i,e,t[e]);if(bp)for(var e of bp(t))A8.call(t,e)&&_p(i,e,t[e]);return i},Zc=(i,t)=>w8(i,b8(t));function fa(i){return Number(i[0].split(":")[1])}function Go(i){return`0x${i.toString(16)}`}function E8(i){const{chains:t,optionalChains:e,methods:s,optionalMethods:o,events:a,optionalEvents:h,rpcMap:p}=i;if(!yi(t))throw new Error("Invalid chains");const v={chains:t,methods:s||ua,events:a||la,rpcMap:Vs({},t.length?{[fa(t)]:p[fa(t)]}:{})},y=a==null?void 0:a.filter(D=>!la.includes(D)),M=s==null?void 0:s.filter(D=>!ua.includes(D));if(!e&&!h&&!o&&!(y!=null&&y.length)&&!(M!=null&&M.length))return{required:t.length?v:void 0};const P=(y==null?void 0:y.length)&&(M==null?void 0:M.length)||!e,T={chains:[...new Set(P?v.chains.concat(e||[]):e)],methods:[...new Set(v.methods.concat(o!=null&&o.length?o:Bd))],events:[...new Set(v.events.concat(h!=null&&h.length?h:jd))],rpcMap:p};return{required:t.length?v:void 0,optional:e.length?T:void 0}}class ma{constructor(){this.events=new A.eventsExports.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=m8,this.on=(t,e)=>(this.events.on(t,e),this),this.once=(t,e)=>(this.events.once(t,e),this),this.removeListener=(t,e)=>(this.events.removeListener(t,e),this),this.off=(t,e)=>(this.events.off(t,e),this),this.parseAccount=t=>this.isCompatibleChainId(t)?this.parseAccountId(t).address:t,this.signer={},this.rpc={}}static async init(t){const e=new ma;return await e.initialize(t),e}async request(t,e){return await this.signer.request(t,this.formatChainId(this.chainId),e)}sendAsync(t,e,s){this.signer.sendAsync(t,e,this.formatChainId(this.chainId),s)}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(t);const{required:e,optional:s}=E8(this.rpc);try{const o=await new Promise(async(h,p)=>{var v;this.rpc.showQrModal&&((v=this.modal)==null||v.subscribeModal(y=>{!y.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),p(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(Zc(Vs({namespaces:Vs({},e&&{[this.namespace]:e})},s&&{optionalNamespaces:{[this.namespace]:s}}),{pairingTopic:t==null?void 0:t.pairingTopic})).then(y=>{h(y)}).catch(y=>{p(new Error(y.message))})});if(!o)return;const a=Gl(o.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:a),this.setAccounts(a),this.events.emit("connect",{chainId:Go(this.chainId)})}catch(o){throw this.signer.logger.error(o),o}finally{this.modal&&this.modal.closeModal()}}async authenticate(t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts({chains:t==null?void 0:t.chains});try{const e=await new Promise(async(o,a)=>{var h;this.rpc.showQrModal&&((h=this.modal)==null||h.subscribeModal(p=>{!p.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),a(new Error("Connection request reset. Please try again.")))})),await this.signer.authenticate(Zc(Vs({},t),{chains:this.rpc.chains})).then(p=>{o(p)}).catch(p=>{a(new Error(p.message))})}),s=e.session;if(s){const o=Gl(s.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:o),this.setAccounts(o),this.events.emit("connect",{chainId:Go(this.chainId)})}return e}catch(e){throw this.signer.logger.error(e),e}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",t=>{const{params:e}=t,{event:s}=e;s.name==="accountsChanged"?(this.accounts=this.parseAccounts(s.data),this.events.emit("accountsChanged",this.accounts)):s.name==="chainChanged"?this.setChainId(this.formatChainId(s.data)):this.events.emit(s.name,s.data),this.events.emit("session_event",t)}),this.signer.on("chainChanged",t=>{const e=parseInt(t);this.chainId=e,this.events.emit("chainChanged",Go(this.chainId)),this.persist()}),this.signer.on("session_update",t=>{this.events.emit("session_update",t)}),this.signer.on("session_delete",t=>{this.reset(),this.events.emit("session_delete",t),this.events.emit("disconnect",Zc(Vs({},Gt("USER_DISCONNECTED")),{data:t.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",t=>{var e,s;this.rpc.showQrModal&&((e=this.modal)==null||e.closeModal(),(s=this.modal)==null||s.openModal({uri:t})),this.events.emit("display_uri",t)})}switchEthereumChain(t){this.request({method:"wallet_switchEthereumChain",params:[{chainId:t.toString(16)}]})}isCompatibleChainId(t){return typeof t=="string"?t.startsWith(`${this.namespace}:`):!1}formatChainId(t){return`${this.namespace}:${t}`}parseChainId(t){return Number(t.split(":")[1])}setChainIds(t){const e=t.filter(s=>this.isCompatibleChainId(s)).map(s=>this.parseChainId(s));e.length&&(this.chainId=e[0],this.events.emit("chainChanged",Go(this.chainId)),this.persist())}setChainId(t){if(this.isCompatibleChainId(t)){const e=this.parseChainId(t);this.chainId=e,this.switchEthereumChain(e)}}parseAccountId(t){const[e,s,o]=t.split(":");return{chainId:`${e}:${s}`,address:o}}setAccounts(t){this.accounts=t.filter(e=>this.parseChainId(this.parseAccountId(e).chainId)===this.chainId).map(e=>this.parseAccountId(e).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(t){var e,s;const o=(e=t==null?void 0:t.chains)!=null?e:[],a=(s=t==null?void 0:t.optionalChains)!=null?s:[],h=o.concat(a);if(!h.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const p=o.length?(t==null?void 0:t.methods)||ua:[],v=o.length?(t==null?void 0:t.events)||la:[],y=(t==null?void 0:t.optionalMethods)||[],M=(t==null?void 0:t.optionalEvents)||[],P=(t==null?void 0:t.rpcMap)||this.buildRpcMap(h,t.projectId),T=(t==null?void 0:t.qrModalOptions)||void 0;return{chains:o==null?void 0:o.map(D=>this.formatChainId(D)),optionalChains:a.map(D=>this.formatChainId(D)),methods:p,events:v,optionalMethods:y,optionalEvents:M,rpcMap:P,showQrModal:!!(t!=null&&t.showQrModal),qrModalOptions:T,projectId:t.projectId,metadata:t.metadata}}buildRpcMap(t,e){const s={};return t.forEach(o=>{s[o]=this.getRpcUrl(o,e)}),s}async initialize(t){if(this.rpc=this.getRpcConfig(t),this.chainId=this.rpc.chains.length?fa(this.rpc.chains):fa(this.rpc.optionalChains),this.signer=await p8.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:t.disableProviderPing,relayUrl:t.relayUrl,storageOptions:t.storageOptions,customStoragePrefix:t.customStoragePrefix,telemetryEnabled:t.telemetryEnabled}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let e;try{const{WalletConnectModal:s}=await Promise.resolve().then(()=>require("./index-Dv8gb9FV.cjs")).then(o=>o.index);e=s}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(e)try{this.modal=new e(Vs({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}catch(s){throw this.signer.logger.error(s),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(t){if(!t)return;const{chains:e,optionalChains:s,rpcMap:o}=t;e&&yi(e)&&(this.rpc.chains=e.map(a=>this.formatChainId(a)),e.forEach(a=>{this.rpc.rpcMap[a]=(o==null?void 0:o[a])||this.getRpcUrl(a)})),s&&yi(s)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=s==null?void 0:s.map(a=>this.formatChainId(a)),s.forEach(a=>{this.rpc.rpcMap[a]=(o==null?void 0:o[a])||this.getRpcUrl(a)}))}getRpcUrl(t,e){var s;return((s=this.rpc.rpcMap)==null?void 0:s[t])||`${v8}?chainId=eip155:${t}&projectId=${e||this.rpc.projectId}`}async loadPersistedSession(){if(this.session)try{const t=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),e=this.session.namespaces[`${this.namespace}:${t}`]?this.session.namespaces[`${this.namespace}:${t}`]:this.session.namespaces[this.namespace];this.setChainIds(t?[this.formatChainId(t)]:e==null?void 0:e.accounts),this.setAccounts(e==null?void 0:e.accounts)}catch(t){this.signer.logger.error("Failed to load persisted session, clearing state..."),this.signer.logger.error(t),await this.disconnect().catch(e=>this.signer.logger.warn(e))}}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(t){return typeof t=="string"||t instanceof String?[this.parseAccount(t)]:t.map(e=>this.parseAccount(e))}}const I8=ma;exports.EthereumProvider=I8;exports.OPTIONAL_EVENTS=jd;exports.OPTIONAL_METHODS=Bd;exports.REQUIRED_EVENTS=la;exports.REQUIRED_METHODS=ua;exports.default=ma;