@web3jskit/walletkit 0.5.2 → 0.6.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 (161) hide show
  1. package/README.md +1 -4
  2. package/README.zh.md +1 -4
  3. package/dist/assets/fonts/manrope-latin-ext.woff2 +0 -0
  4. package/dist/assets/fonts/manrope-latin.woff2 +0 -0
  5. package/dist/assets/fonts/manrope-vietnamese.woff2 +0 -0
  6. package/dist/base.css +65 -0
  7. package/dist/btcConnector-BDtO-SY1.js +1 -0
  8. package/dist/{btcConnector-D9c29Oxw.mjs → btcConnector-CcZ3Vta3.mjs} +4 -3
  9. package/dist/{btcConnector-CDgcyxQ3.mjs → btcConnector-DMgc1GYB.mjs} +16 -15
  10. package/dist/btcConnector-DfFAwTZX.js +1 -0
  11. package/dist/components/ConnectModal/index.d.ts.map +1 -1
  12. package/dist/components/Modal/index.d.ts +3 -1
  13. package/dist/components/Modal/index.d.ts.map +1 -1
  14. package/dist/components/WalletItem/index.d.ts +3 -0
  15. package/dist/components/WalletItem/index.d.ts.map +1 -1
  16. package/dist/components/WalletKitProvider/ChainProvider.d.ts +1 -2
  17. package/dist/components/WalletKitProvider/ChainProvider.d.ts.map +1 -1
  18. package/dist/components/WalletKitProvider/connectorInitialization.d.ts +12 -0
  19. package/dist/components/WalletKitProvider/connectorInitialization.d.ts.map +1 -0
  20. package/dist/components/WalletKitProvider/index.d.ts +1 -1
  21. package/dist/components/WalletKitProvider/index.d.ts.map +1 -1
  22. package/dist/config/iconDatabase.d.ts +0 -1
  23. package/dist/config/iconDatabase.d.ts.map +1 -1
  24. package/dist/config/walletConfig.d.ts +0 -1
  25. package/dist/config/walletConfig.d.ts.map +1 -1
  26. package/dist/core/connectors/Bitget_Wallet/tronConnector.d.ts +13 -0
  27. package/dist/core/connectors/Bitget_Wallet/tronConnector.d.ts.map +1 -0
  28. package/dist/core/connectors/_sol/discoverWallets.d.ts +4 -0
  29. package/dist/core/connectors/_sol/discoverWallets.d.ts.map +1 -0
  30. package/dist/core/connectors/_sol/discoveredSolConnector.d.ts +12 -0
  31. package/dist/core/connectors/_sol/discoveredSolConnector.d.ts.map +1 -0
  32. package/dist/core/connectors/_sol/wrapStandardSolWallet.d.ts +15 -0
  33. package/dist/core/connectors/_sol/wrapStandardSolWallet.d.ts.map +1 -0
  34. package/dist/core/connectors/_tron/discoverWallets.d.ts +6 -0
  35. package/dist/core/connectors/_tron/discoverWallets.d.ts.map +1 -0
  36. package/dist/core/connectors/_tron/discoveredTronConnector.d.ts +13 -0
  37. package/dist/core/connectors/_tron/discoveredTronConnector.d.ts.map +1 -0
  38. package/dist/core/connectors/_tron/tronConnector.d.ts.map +1 -1
  39. package/dist/core/connectors/_tron/wrapTip6963TronProvider.d.ts +2 -0
  40. package/dist/core/connectors/_tron/wrapTip6963TronProvider.d.ts.map +1 -0
  41. package/dist/core/connectors/connectorLoader.d.ts +3 -0
  42. package/dist/core/connectors/connectorLoader.d.ts.map +1 -0
  43. package/dist/core/connectors/createConnectors.d.ts +5 -1
  44. package/dist/core/connectors/createConnectors.d.ts.map +1 -1
  45. package/dist/core/connectors/publicConnectorApi.d.ts +7 -0
  46. package/dist/core/connectors/publicConnectorApi.d.ts.map +1 -0
  47. package/dist/core/utils/sortConnectModalWallets.d.ts +14 -0
  48. package/dist/core/utils/sortConnectModalWallets.d.ts.map +1 -0
  49. package/dist/core/utils/util.d.ts +7 -0
  50. package/dist/core/utils/util.d.ts.map +1 -1
  51. package/dist/core/utils/walletName.d.ts +5 -0
  52. package/dist/core/utils/walletName.d.ts.map +1 -0
  53. package/dist/createConnectors-C9LH3IR3.mjs +1400 -0
  54. package/dist/createConnectors-CJ8mKxGL.js +4 -0
  55. package/dist/createConnectors-Cv_QLnqK.js +71 -0
  56. package/dist/createConnectors-motkSfb8.mjs +700 -0
  57. package/dist/{deepLinkConnector-BV1AtJUd.mjs → deepLinkConnector-BXnwTb3R.mjs} +1 -1
  58. package/dist/{deepLinkConnector-D2bdmDbP.mjs → deepLinkConnector-BYTD1fC1.mjs} +1 -1
  59. package/dist/deepLinkConnector-BdJyNgRZ.js +1 -0
  60. package/dist/{deepLinkConnector-De3WEuvS.mjs → deepLinkConnector-Bu6KKcGy.mjs} +1 -1
  61. package/dist/deepLinkConnector-Bw-eQd5I.js +1 -0
  62. package/dist/{deepLinkConnector-Cl2lfNcv.mjs → deepLinkConnector-C2hzBr3K.mjs} +1 -1
  63. package/dist/deepLinkConnector-CAwqVe4F.js +1 -0
  64. package/dist/deepLinkConnector-CuHi9EXY.js +1 -0
  65. package/dist/deepLinkConnector-Cvnq6T2g.js +1 -0
  66. package/dist/deepLinkConnector-DIFgHqiu.js +1 -0
  67. package/dist/deepLinkConnector-DNwi0QPz.js +1 -0
  68. package/dist/{deepLinkConnector-Cp3wn9oq.mjs → deepLinkConnector-DZhNx2B3.mjs} +1 -1
  69. package/dist/{deepLinkConnector-ClxWpKnx.mjs → deepLinkConnector-DjjZRYdu.mjs} +1 -1
  70. package/dist/{deepLinkConnector-Cy9w-E2m.mjs → deepLinkConnector-DkxVqLoI.mjs} +6 -5
  71. package/dist/hooks/useWalletKit.d.ts +0 -2
  72. package/dist/hooks/useWalletKit.d.ts.map +1 -1
  73. package/dist/index-AJZEVNvC.js +44 -0
  74. package/dist/index-B2ReClHJ.js +1 -0
  75. package/dist/index-CwrzsL2T.mjs +6179 -0
  76. package/dist/index-D5CDP-Ja.mjs +79 -0
  77. package/dist/index-DBdIuPfj.js +3 -0
  78. package/dist/index-DcNXEbdu.mjs +94 -0
  79. package/dist/index-Dh0IhC3B.mjs +168 -0
  80. package/dist/index-Dqp1KqTh.js +1 -0
  81. package/dist/index-Ds_3MsPA.js +1 -0
  82. package/dist/index-bCuJkrSE.mjs +152 -0
  83. package/dist/index.css +1 -0
  84. package/dist/index.d.ts +1 -4
  85. package/dist/index.d.ts.map +1 -1
  86. package/dist/index.esm.js +19 -20
  87. package/dist/index.js +1 -1
  88. package/dist/index.umd.js +12765 -55583
  89. package/dist/index2.css +1 -0
  90. package/dist/index3.css +1 -0
  91. package/dist/silentConnect-CZY4_0a5.js +1 -0
  92. package/dist/silentConnect-ScWCxMaM.mjs +11 -0
  93. package/dist/stores/helperStore.d.ts +0 -2
  94. package/dist/stores/helperStore.d.ts.map +1 -1
  95. package/dist/style.css +90 -87
  96. package/dist/tronConnector-Bx-nhNWr.mjs +14 -0
  97. package/dist/tronConnector-CXH3d_my.js +1 -0
  98. package/dist/tronConnector-DGnNuwqC.js +1 -0
  99. package/dist/tronConnector-P87k0GEa.mjs +21 -0
  100. package/dist/walletName-BwayBopz.mjs +8 -0
  101. package/dist/walletName-mwS8Jhxj.js +1 -0
  102. package/package.json +11 -4
  103. package/dist/btcConnector-Ca_Ne7hH.js +0 -1
  104. package/dist/btcConnector-PnjTRzcQ.js +0 -1
  105. package/dist/core/connectors/Bitget_Wallet/solConnector.d.ts +0 -13
  106. package/dist/core/connectors/Bitget_Wallet/solConnector.d.ts.map +0 -1
  107. package/dist/core/connectors/GelWallet/evmConnector.d.ts +0 -27
  108. package/dist/core/connectors/GelWallet/evmConnector.d.ts.map +0 -1
  109. package/dist/core/connectors/GelWallet/solConnector.d.ts +0 -15
  110. package/dist/core/connectors/GelWallet/solConnector.d.ts.map +0 -1
  111. package/dist/core/connectors/GelWallet/tronConnector.d.ts +0 -8
  112. package/dist/core/connectors/GelWallet/tronConnector.d.ts.map +0 -1
  113. package/dist/core/connectors/OKX_Wallet/solConnector.d.ts +0 -12
  114. package/dist/core/connectors/OKX_Wallet/solConnector.d.ts.map +0 -1
  115. package/dist/core/connectors/Phantom/solConnector.d.ts +0 -12
  116. package/dist/core/connectors/Phantom/solConnector.d.ts.map +0 -1
  117. package/dist/core/connectors/TronLink/tronConnector.d.ts +0 -13
  118. package/dist/core/connectors/TronLink/tronConnector.d.ts.map +0 -1
  119. package/dist/core/connectors/_gelwallet/gelWalletConnector.d.ts +0 -26
  120. package/dist/core/connectors/_gelwallet/gelWalletConnector.d.ts.map +0 -1
  121. package/dist/dapp.es-BPGP9PnL.mjs +0 -15917
  122. package/dist/dapp.es-sLnregcu.js +0 -103
  123. package/dist/deepLinkConnector-2xq1YA07.js +0 -1
  124. package/dist/deepLinkConnector-B_fjG32i.js +0 -1
  125. package/dist/deepLinkConnector-BjV3gwrJ.js +0 -1
  126. package/dist/deepLinkConnector-BrFUCtcT.js +0 -1
  127. package/dist/deepLinkConnector-COLT9UtB.js +0 -1
  128. package/dist/deepLinkConnector-DvpJaC8p.js +0 -1
  129. package/dist/deepLinkConnector-Dypz-oTG.js +0 -1
  130. package/dist/evmConnector-CDZHCMDp.mjs +0 -163
  131. package/dist/evmConnector-CsLHlVqx.js +0 -1
  132. package/dist/gelWalletConnector-D-BogX91.mjs +0 -76
  133. package/dist/gelWalletConnector-DmGJoazT.js +0 -1
  134. package/dist/index-9qmfDVzH-C-zsxX98.mjs +0 -25638
  135. package/dist/index-9qmfDVzH-C6VVZD9P.js +0 -28
  136. package/dist/index-B3LF1VeP-58KzZv6u.js +0 -1
  137. package/dist/index-B3LF1VeP-IR-fSZI0.mjs +0 -120
  138. package/dist/index-BZdLbTeL.js +0 -138
  139. package/dist/index-CCHY2zSF-OxZZmzOg.mjs +0 -45
  140. package/dist/index-CCHY2zSF-ocS_tvXl.js +0 -1
  141. package/dist/index-CqeMS3Gf-C4g86ca5.js +0 -1
  142. package/dist/index-CqeMS3Gf-DXS8RsUh.mjs +0 -67
  143. package/dist/index-DGMGsMkJ-BTPPfxmS.js +0 -1
  144. package/dist/index-DGMGsMkJ-CHecRdpD.mjs +0 -27
  145. package/dist/index-Dm84KVCU.mjs +0 -9267
  146. package/dist/index-yUF_S07V-Cm9-qVkc.js +0 -1
  147. package/dist/index-yUF_S07V-DHeRsyE0.mjs +0 -48
  148. package/dist/solConnector-2sU1qHsq.mjs +0 -11
  149. package/dist/solConnector-BEPYycHF.js +0 -1
  150. package/dist/solConnector-CVS5qwwy.js +0 -1
  151. package/dist/solConnector-CWIPltdg.mjs +0 -11
  152. package/dist/solConnector-CXejjI9x.mjs +0 -41
  153. package/dist/solConnector-CnQAb35I.mjs +0 -11
  154. package/dist/solConnector-DU5bMwKt.js +0 -1
  155. package/dist/solConnector-xJ3YPYMj.js +0 -1
  156. package/dist/tronConnector-CUnp7Df4.js +0 -1
  157. package/dist/tronConnector-CaEipTWV.mjs +0 -21
  158. package/dist/tronConnector-CpIX5IxL.mjs +0 -13
  159. package/dist/tronConnector-DMLqqMae.mjs +0 -35
  160. package/dist/tronConnector-DesDymhW.js +0 -1
  161. package/dist/tronConnector-tU0iwxHV.js +0 -1
@@ -0,0 +1,1400 @@
1
+ import { g as wt, f as We, h as pt, a as lt, w as He, n as he, s as gt, C as ae, r as vt, e as mt, m as Nt, j as Et } from "./index-CwrzsL2T.mjs";
2
+ function yt(m) {
3
+ if (typeof window > "u")
4
+ return;
5
+ const f = (g) => m(g.detail);
6
+ return window.addEventListener("eip6963:announceProvider", f), window.dispatchEvent(new CustomEvent("eip6963:requestProvider")), () => window.removeEventListener("eip6963:announceProvider", f);
7
+ }
8
+ function Ct() {
9
+ const m = /* @__PURE__ */ new Set();
10
+ let f = [];
11
+ const g = () => yt((a) => {
12
+ f.some(({ info: p }) => p.uuid === a.info.uuid) || (f = [...f, a], m.forEach((p) => p(f, { added: [a] })));
13
+ });
14
+ let c = g();
15
+ return {
16
+ _listeners() {
17
+ return m;
18
+ },
19
+ clear() {
20
+ m.forEach((a) => a([], { removed: [...f] })), f = [];
21
+ },
22
+ destroy() {
23
+ this.clear(), m.clear(), c == null || c();
24
+ },
25
+ findProvider({ rdns: a }) {
26
+ return f.find((p) => p.info.rdns === a);
27
+ },
28
+ getProviders() {
29
+ return f;
30
+ },
31
+ reset() {
32
+ this.clear(), c == null || c(), c = g();
33
+ },
34
+ subscribe(a, { emitImmediately: p } = {}) {
35
+ return m.add(a), p && a(f, { added: f }), () => m.delete(a);
36
+ }
37
+ };
38
+ }
39
+ var xt = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i, Re = Math.ceil, K = Math.floor, z = "[BigNumber Error] ", Ve = z + "Number primitive has more than 15 significant digits: ", Z = 1e14, M = 14, Ue = 9007199254740991, be = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13], re = 1e7, F = 1e9;
40
+ function ut(m) {
41
+ var f, g, c, a = v.prototype = { constructor: v, toString: null, valueOf: null }, p = new v(1), N = 20, E = 4, y = -7, S = 21, A = -1e7, _ = 1e7, k = !1, P = 1, I = 0, G = {
42
+ prefix: "",
43
+ groupSize: 3,
44
+ secondaryGroupSize: 0,
45
+ groupSeparator: ",",
46
+ decimalSeparator: ".",
47
+ fractionGroupSize: 0,
48
+ fractionGroupSeparator: " ",
49
+ // non-breaking space
50
+ suffix: ""
51
+ }, O = "0123456789abcdefghijklmnopqrstuvwxyz", V = !0;
52
+ function v(e, t) {
53
+ var n, u, r, o, d, s, i, h, l = this;
54
+ if (!(l instanceof v)) return new v(e, t);
55
+ if (t == null) {
56
+ if (e && e._isBigNumber === !0) {
57
+ l.s = e.s, !e.c || e.e > _ ? l.c = l.e = null : e.e < A ? l.c = [l.e = 0] : (l.e = e.e, l.c = e.c.slice());
58
+ return;
59
+ }
60
+ if ((s = typeof e == "number") && e * 0 == 0) {
61
+ if (l.s = 1 / e < 0 ? (e = -e, -1) : 1, e === ~~e) {
62
+ for (o = 0, d = e; d >= 10; d /= 10, o++) ;
63
+ o > _ ? l.c = l.e = null : (l.e = o, l.c = [e]);
64
+ return;
65
+ }
66
+ h = String(e);
67
+ } else {
68
+ if (!xt.test(h = String(e))) return c(l, h, s);
69
+ l.s = h.charCodeAt(0) == 45 ? (h = h.slice(1), -1) : 1;
70
+ }
71
+ (o = h.indexOf(".")) > -1 && (h = h.replace(".", "")), (d = h.search(/e/i)) > 0 ? (o < 0 && (o = d), o += +h.slice(d + 1), h = h.substring(0, d)) : o < 0 && (o = h.length);
72
+ } else {
73
+ if (D(t, 2, O.length, "Base"), t == 10 && V)
74
+ return l = new v(e), j(l, N + l.e + 1, E);
75
+ if (h = String(e), s = typeof e == "number") {
76
+ if (e * 0 != 0) return c(l, h, s, t);
77
+ if (l.s = 1 / e < 0 ? (h = h.slice(1), -1) : 1, v.DEBUG && h.replace(/^0\.0*|\./, "").length > 15)
78
+ throw Error(Ve + e);
79
+ } else
80
+ l.s = h.charCodeAt(0) === 45 ? (h = h.slice(1), -1) : 1;
81
+ for (n = O.slice(0, t), o = d = 0, i = h.length; d < i; d++)
82
+ if (n.indexOf(u = h.charAt(d)) < 0) {
83
+ if (u == ".") {
84
+ if (d > o) {
85
+ o = i;
86
+ continue;
87
+ }
88
+ } else if (!r && (h == h.toUpperCase() && (h = h.toLowerCase()) || h == h.toLowerCase() && (h = h.toUpperCase()))) {
89
+ r = !0, d = -1, o = 0;
90
+ continue;
91
+ }
92
+ return c(l, String(e), s, t);
93
+ }
94
+ s = !1, h = g(h, t, 10, l.s), (o = h.indexOf(".")) > -1 ? h = h.replace(".", "") : o = h.length;
95
+ }
96
+ for (d = 0; h.charCodeAt(d) === 48; d++) ;
97
+ for (i = h.length; h.charCodeAt(--i) === 48; ) ;
98
+ if (h = h.slice(d, ++i)) {
99
+ if (i -= d, s && v.DEBUG && i > 15 && (e > Ue || e !== K(e)))
100
+ throw Error(Ve + l.s * e);
101
+ if ((o = o - d - 1) > _)
102
+ l.c = l.e = null;
103
+ else if (o < A)
104
+ l.c = [l.e = 0];
105
+ else {
106
+ if (l.e = o, l.c = [], d = (o + 1) % M, o < 0 && (d += M), d < i) {
107
+ for (d && l.c.push(+h.slice(0, d)), i -= M; d < i; )
108
+ l.c.push(+h.slice(d, d += M));
109
+ d = M - (h = h.slice(d)).length;
110
+ } else
111
+ d -= i;
112
+ for (; d--; h += "0") ;
113
+ l.c.push(+h);
114
+ }
115
+ } else
116
+ l.c = [l.e = 0];
117
+ }
118
+ v.clone = ut, v.ROUND_UP = 0, v.ROUND_DOWN = 1, v.ROUND_CEIL = 2, v.ROUND_FLOOR = 3, v.ROUND_HALF_UP = 4, v.ROUND_HALF_DOWN = 5, v.ROUND_HALF_EVEN = 6, v.ROUND_HALF_CEIL = 7, v.ROUND_HALF_FLOOR = 8, v.EUCLID = 9, v.config = v.set = function(e) {
119
+ var t, n;
120
+ if (e != null)
121
+ if (typeof e == "object") {
122
+ if (e.hasOwnProperty(t = "DECIMAL_PLACES") && (n = e[t], D(n, 0, F, t), N = n), e.hasOwnProperty(t = "ROUNDING_MODE") && (n = e[t], D(n, 0, 8, t), E = n), e.hasOwnProperty(t = "EXPONENTIAL_AT") && (n = e[t], n && n.pop ? (D(n[0], -F, 0, t), D(n[1], 0, F, t), y = n[0], S = n[1]) : (D(n, -F, F, t), y = -(S = n < 0 ? -n : n))), e.hasOwnProperty(t = "RANGE"))
123
+ if (n = e[t], n && n.pop)
124
+ D(n[0], -F, -1, t), D(n[1], 1, F, t), A = n[0], _ = n[1];
125
+ else if (D(n, -F, F, t), n)
126
+ A = -(_ = n < 0 ? -n : n);
127
+ else
128
+ throw Error(z + t + " cannot be zero: " + n);
129
+ if (e.hasOwnProperty(t = "CRYPTO"))
130
+ if (n = e[t], n === !!n)
131
+ if (n)
132
+ if (typeof crypto < "u" && crypto && (crypto.getRandomValues || crypto.randomBytes))
133
+ k = n;
134
+ else
135
+ throw k = !n, Error(z + "crypto unavailable");
136
+ else
137
+ k = n;
138
+ else
139
+ throw Error(z + t + " not true or false: " + n);
140
+ if (e.hasOwnProperty(t = "MODULO_MODE") && (n = e[t], D(n, 0, 9, t), P = n), e.hasOwnProperty(t = "POW_PRECISION") && (n = e[t], D(n, 0, F, t), I = n), e.hasOwnProperty(t = "FORMAT"))
141
+ if (n = e[t], typeof n == "object") G = n;
142
+ else throw Error(z + t + " not an object: " + n);
143
+ if (e.hasOwnProperty(t = "ALPHABET"))
144
+ if (n = e[t], typeof n == "string" && !/^.?$|[+\-.\s]|(.).*\1/.test(n))
145
+ V = n.slice(0, 10) == "0123456789", O = n;
146
+ else
147
+ throw Error(z + t + " invalid: " + n);
148
+ } else
149
+ throw Error(z + "Object expected: " + e);
150
+ return {
151
+ DECIMAL_PLACES: N,
152
+ ROUNDING_MODE: E,
153
+ EXPONENTIAL_AT: [y, S],
154
+ RANGE: [A, _],
155
+ CRYPTO: k,
156
+ MODULO_MODE: P,
157
+ POW_PRECISION: I,
158
+ FORMAT: G,
159
+ ALPHABET: O
160
+ };
161
+ }, v.isBigNumber = function(e) {
162
+ if (!e || e._isBigNumber !== !0) return !1;
163
+ if (!v.DEBUG) return !0;
164
+ var t, n, u = e.c, r = e.e, o = e.s;
165
+ e: if ({}.toString.call(u) == "[object Array]") {
166
+ if ((o === 1 || o === -1) && r >= -F && r <= F && r === K(r)) {
167
+ if (u[0] === 0) {
168
+ if (r === 0 && u.length === 1) return !0;
169
+ break e;
170
+ }
171
+ if (t = (r + 1) % M, t < 1 && (t += M), String(u[0]).length == t) {
172
+ for (t = 0; t < u.length; t++)
173
+ if (n = u[t], n < 0 || n >= Z || n !== K(n)) break e;
174
+ if (n !== 0) return !0;
175
+ }
176
+ }
177
+ } else if (u === null && r === null && (o === null || o === 1 || o === -1))
178
+ return !0;
179
+ throw Error(z + "Invalid BigNumber: " + e);
180
+ }, v.maximum = v.max = function() {
181
+ return ue(arguments, -1);
182
+ }, v.minimum = v.min = function() {
183
+ return ue(arguments, 1);
184
+ }, v.random = (function() {
185
+ var e = 9007199254740992, t = Math.random() * e & 2097151 ? function() {
186
+ return K(Math.random() * e);
187
+ } : function() {
188
+ return (Math.random() * 1073741824 | 0) * 8388608 + (Math.random() * 8388608 | 0);
189
+ };
190
+ return function(n) {
191
+ var u, r, o, d, s, i = 0, h = [], l = new v(p);
192
+ if (n == null ? n = N : D(n, 0, F), d = Re(n / M), k)
193
+ if (crypto.getRandomValues) {
194
+ for (u = crypto.getRandomValues(new Uint32Array(d *= 2)); i < d; )
195
+ s = u[i] * 131072 + (u[i + 1] >>> 11), s >= 9e15 ? (r = crypto.getRandomValues(new Uint32Array(2)), u[i] = r[0], u[i + 1] = r[1]) : (h.push(s % 1e14), i += 2);
196
+ i = d / 2;
197
+ } else if (crypto.randomBytes) {
198
+ for (u = crypto.randomBytes(d *= 7); i < d; )
199
+ s = (u[i] & 31) * 281474976710656 + u[i + 1] * 1099511627776 + u[i + 2] * 4294967296 + u[i + 3] * 16777216 + (u[i + 4] << 16) + (u[i + 5] << 8) + u[i + 6], s >= 9e15 ? crypto.randomBytes(7).copy(u, i) : (h.push(s % 1e14), i += 7);
200
+ i = d / 7;
201
+ } else
202
+ throw k = !1, Error(z + "crypto unavailable");
203
+ if (!k)
204
+ for (; i < d; )
205
+ s = t(), s < 9e15 && (h[i++] = s % 1e14);
206
+ for (d = h[--i], n %= M, d && n && (s = be[M - n], h[i] = K(d / s) * s); h[i] === 0; h.pop(), i--) ;
207
+ if (i < 0)
208
+ h = [o = 0];
209
+ else {
210
+ for (o = -1; h[0] === 0; h.splice(0, 1), o -= M) ;
211
+ for (i = 1, s = h[0]; s >= 10; s /= 10, i++) ;
212
+ i < M && (o -= M - i);
213
+ }
214
+ return l.e = o, l.c = h, l;
215
+ };
216
+ })(), v.sum = function() {
217
+ for (var e = 1, t = arguments, n = new v(t[0]); e < t.length; ) n = n.plus(t[e++]);
218
+ return n;
219
+ }, g = /* @__PURE__ */ (function() {
220
+ var e = "0123456789";
221
+ function t(n, u, r, o) {
222
+ for (var d, s = [0], i, h = 0, l = n.length; h < l; ) {
223
+ for (i = s.length; i--; s[i] *= u) ;
224
+ for (s[0] += o.indexOf(n.charAt(h++)), d = 0; d < s.length; d++)
225
+ s[d] > r - 1 && (s[d + 1] == null && (s[d + 1] = 0), s[d + 1] += s[d] / r | 0, s[d] %= r);
226
+ }
227
+ return s.reverse();
228
+ }
229
+ return function(n, u, r, o, d) {
230
+ var s, i, h, l, w, C, x, L, B = n.indexOf("."), b = N, T = E;
231
+ for (B >= 0 && (l = I, I = 0, n = n.replace(".", ""), L = new v(u), C = L.pow(n.length - B), I = l, L.c = t(
232
+ se(Y(C.c), C.e, "0"),
233
+ 10,
234
+ r,
235
+ e
236
+ ), L.e = L.c.length), x = t(n, u, r, d ? (s = O, e) : (s = e, O)), h = l = x.length; x[--l] == 0; x.pop()) ;
237
+ if (!x[0]) return s.charAt(0);
238
+ if (B < 0 ? --h : (C.c = x, C.e = h, C.s = o, C = f(C, L, b, T, r), x = C.c, w = C.r, h = C.e), i = h + b + 1, B = x[i], l = r / 2, w = w || i < 0 || x[i + 1] != null, w = T < 4 ? (B != null || w) && (T == 0 || T == (C.s < 0 ? 3 : 2)) : B > l || B == l && (T == 4 || w || T == 6 && x[i - 1] & 1 || T == (C.s < 0 ? 8 : 7)), i < 1 || !x[0])
239
+ n = w ? se(s.charAt(1), -b, s.charAt(0)) : s.charAt(0);
240
+ else {
241
+ if (x.length = i, w)
242
+ for (--r; ++x[--i] > r; )
243
+ x[i] = 0, i || (++h, x = [1].concat(x));
244
+ for (l = x.length; !x[--l]; ) ;
245
+ for (B = 0, n = ""; B <= l; n += s.charAt(x[B++])) ;
246
+ n = se(n, h, s.charAt(0));
247
+ }
248
+ return n;
249
+ };
250
+ })(), f = /* @__PURE__ */ (function() {
251
+ function e(u, r, o) {
252
+ var d, s, i, h, l = 0, w = u.length, C = r % re, x = r / re | 0;
253
+ for (u = u.slice(); w--; )
254
+ i = u[w] % re, h = u[w] / re | 0, d = x * i + h * C, s = C * i + d % re * re + l, l = (s / o | 0) + (d / re | 0) + x * h, u[w] = s % o;
255
+ return l && (u = [l].concat(u)), u;
256
+ }
257
+ function t(u, r, o, d) {
258
+ var s, i;
259
+ if (o != d)
260
+ i = o > d ? 1 : -1;
261
+ else
262
+ for (s = i = 0; s < o; s++)
263
+ if (u[s] != r[s]) {
264
+ i = u[s] > r[s] ? 1 : -1;
265
+ break;
266
+ }
267
+ return i;
268
+ }
269
+ function n(u, r, o, d) {
270
+ for (var s = 0; o--; )
271
+ u[o] -= s, s = u[o] < r[o] ? 1 : 0, u[o] = s * d + u[o] - r[o];
272
+ for (; !u[0] && u.length > 1; u.splice(0, 1)) ;
273
+ }
274
+ return function(u, r, o, d, s) {
275
+ var i, h, l, w, C, x, L, B, b, T, q, W, fe, De, Be, ee, ce, J = u.s == r.s ? 1 : -1, H = u.c, R = r.c;
276
+ if (!H || !H[0] || !R || !R[0])
277
+ return new v(
278
+ // Return NaN if either NaN, or both Infinity or 0.
279
+ !u.s || !r.s || (H ? R && H[0] == R[0] : !R) ? NaN : (
280
+ // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
281
+ H && H[0] == 0 || !R ? J * 0 : J / 0
282
+ )
283
+ );
284
+ for (B = new v(J), b = B.c = [], h = u.e - r.e, J = o + h + 1, s || (s = Z, h = Q(u.e / M) - Q(r.e / M), J = J / M | 0), l = 0; R[l] == (H[l] || 0); l++) ;
285
+ if (R[l] > (H[l] || 0) && h--, J < 0)
286
+ b.push(1), w = !0;
287
+ else {
288
+ for (De = H.length, ee = R.length, l = 0, J += 2, C = K(s / (R[0] + 1)), C > 1 && (R = e(R, C, s), H = e(H, C, s), ee = R.length, De = H.length), fe = ee, T = H.slice(0, ee), q = T.length; q < ee; T[q++] = 0) ;
289
+ ce = R.slice(), ce = [0].concat(ce), Be = R[0], R[1] >= s / 2 && Be++;
290
+ do {
291
+ if (C = 0, i = t(R, T, ee, q), i < 0) {
292
+ if (W = T[0], ee != q && (W = W * s + (T[1] || 0)), C = K(W / Be), C > 1)
293
+ for (C >= s && (C = s - 1), x = e(R, C, s), L = x.length, q = T.length; t(x, T, L, q) == 1; )
294
+ C--, n(x, ee < L ? ce : R, L, s), L = x.length, i = 1;
295
+ else
296
+ C == 0 && (i = C = 1), x = R.slice(), L = x.length;
297
+ if (L < q && (x = [0].concat(x)), n(T, x, q, s), q = T.length, i == -1)
298
+ for (; t(R, T, ee, q) < 1; )
299
+ C++, n(T, ee < q ? ce : R, q, s), q = T.length;
300
+ } else i === 0 && (C++, T = [0]);
301
+ b[l++] = C, T[0] ? T[q++] = H[fe] || 0 : (T = [H[fe]], q = 1);
302
+ } while ((fe++ < De || T[0] != null) && J--);
303
+ w = T[0] != null, b[0] || b.splice(0, 1);
304
+ }
305
+ if (s == Z) {
306
+ for (l = 1, J = b[0]; J >= 10; J /= 10, l++) ;
307
+ j(B, o + (B.e = l + h * M - 1) + 1, d, w);
308
+ } else
309
+ B.e = h, B.r = +w;
310
+ return B;
311
+ };
312
+ })();
313
+ function $(e, t, n, u) {
314
+ var r, o, d, s, i;
315
+ if (n == null ? n = E : D(n, 0, 8), !e.c) return e.toString();
316
+ if (r = e.c[0], d = e.e, t == null)
317
+ i = Y(e.c), i = u == 1 || u == 2 && (d <= y || d >= S) ? we(i, d) : se(i, d, "0");
318
+ else if (e = j(new v(e), t, n), o = e.e, i = Y(e.c), s = i.length, u == 1 || u == 2 && (t <= o || o <= y)) {
319
+ for (; s < t; i += "0", s++) ;
320
+ i = we(i, o);
321
+ } else if (t -= d + (u === 2 && o > d), i = se(i, o, "0"), o + 1 > s) {
322
+ if (--t > 0) for (i += "."; t--; i += "0") ;
323
+ } else if (t += o - s, t > 0)
324
+ for (o + 1 == s && (i += "."); t--; i += "0") ;
325
+ return e.s < 0 && r ? "-" + i : i;
326
+ }
327
+ function ue(e, t) {
328
+ for (var n, u, r = 1, o = new v(e[0]); r < e.length; r++)
329
+ u = new v(e[r]), (!u.s || (n = ie(o, u)) === t || n === 0 && o.s === t) && (o = u);
330
+ return o;
331
+ }
332
+ function te(e, t, n) {
333
+ for (var u = 1, r = t.length; !t[--r]; t.pop()) ;
334
+ for (r = t[0]; r >= 10; r /= 10, u++) ;
335
+ return (n = u + n * M - 1) > _ ? e.c = e.e = null : n < A ? e.c = [e.e = 0] : (e.e = n, e.c = t), e;
336
+ }
337
+ c = /* @__PURE__ */ (function() {
338
+ var e = /^(-?)0([xbo])(?=\w[\w.]*$)/i, t = /^([^.]+)\.$/, n = /^\.([^.]+)$/, u = /^-?(Infinity|NaN)$/, r = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
339
+ return function(o, d, s, i) {
340
+ var h, l = s ? d : d.replace(r, "");
341
+ if (u.test(l))
342
+ o.s = isNaN(l) ? null : l < 0 ? -1 : 1;
343
+ else {
344
+ if (!s && (l = l.replace(e, function(w, C, x) {
345
+ return h = (x = x.toLowerCase()) == "x" ? 16 : x == "b" ? 2 : 8, !i || i == h ? C : w;
346
+ }), i && (h = i, l = l.replace(t, "$1").replace(n, "0.$1")), d != l))
347
+ return new v(l, h);
348
+ if (v.DEBUG)
349
+ throw Error(z + "Not a" + (i ? " base " + i : "") + " number: " + d);
350
+ o.s = null;
351
+ }
352
+ o.c = o.e = null;
353
+ };
354
+ })();
355
+ function j(e, t, n, u) {
356
+ var r, o, d, s, i, h, l, w = e.c, C = be;
357
+ if (w) {
358
+ e: {
359
+ for (r = 1, s = w[0]; s >= 10; s /= 10, r++) ;
360
+ if (o = t - r, o < 0)
361
+ o += M, d = t, i = w[h = 0], l = K(i / C[r - d - 1] % 10);
362
+ else if (h = Re((o + 1) / M), h >= w.length)
363
+ if (u) {
364
+ for (; w.length <= h; w.push(0)) ;
365
+ i = l = 0, r = 1, o %= M, d = o - M + 1;
366
+ } else
367
+ break e;
368
+ else {
369
+ for (i = s = w[h], r = 1; s >= 10; s /= 10, r++) ;
370
+ o %= M, d = o - M + r, l = d < 0 ? 0 : K(i / C[r - d - 1] % 10);
371
+ }
372
+ if (u = u || t < 0 || // Are there any non-zero digits after the rounding digit?
373
+ // The expression n % pows10[d - j - 1] returns all digits of n to the right
374
+ // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
375
+ w[h + 1] != null || (d < 0 ? i : i % C[r - d - 1]), u = n < 4 ? (l || u) && (n == 0 || n == (e.s < 0 ? 3 : 2)) : l > 5 || l == 5 && (n == 4 || u || n == 6 && // Check whether the digit to the left of the rounding digit is odd.
376
+ (o > 0 ? d > 0 ? i / C[r - d] : 0 : w[h - 1]) % 10 & 1 || n == (e.s < 0 ? 8 : 7)), t < 1 || !w[0])
377
+ return w.length = 0, u ? (t -= e.e + 1, w[0] = C[(M - t % M) % M], e.e = -t || 0) : w[0] = e.e = 0, e;
378
+ if (o == 0 ? (w.length = h, s = 1, h--) : (w.length = h + 1, s = C[M - o], w[h] = d > 0 ? K(i / C[r - d] % C[d]) * s : 0), u)
379
+ for (; ; )
380
+ if (h == 0) {
381
+ for (o = 1, d = w[0]; d >= 10; d /= 10, o++) ;
382
+ for (d = w[0] += s, s = 1; d >= 10; d /= 10, s++) ;
383
+ o != s && (e.e++, w[0] == Z && (w[0] = 1));
384
+ break;
385
+ } else {
386
+ if (w[h] += s, w[h] != Z) break;
387
+ w[h--] = 0, s = 1;
388
+ }
389
+ for (o = w.length; w[--o] === 0; w.pop()) ;
390
+ }
391
+ e.e > _ ? e.c = e.e = null : e.e < A && (e.c = [e.e = 0]);
392
+ }
393
+ return e;
394
+ }
395
+ function ne(e) {
396
+ var t, n = e.e;
397
+ return n === null ? e.toString() : (t = Y(e.c), t = n <= y || n >= S ? we(t, n) : se(t, n, "0"), e.s < 0 ? "-" + t : t);
398
+ }
399
+ return a.absoluteValue = a.abs = function() {
400
+ var e = new v(this);
401
+ return e.s < 0 && (e.s = 1), e;
402
+ }, a.comparedTo = function(e, t) {
403
+ return ie(this, new v(e, t));
404
+ }, a.decimalPlaces = a.dp = function(e, t) {
405
+ var n, u, r, o = this;
406
+ if (e != null)
407
+ return D(e, 0, F), t == null ? t = E : D(t, 0, 8), j(new v(o), e + o.e + 1, t);
408
+ if (!(n = o.c)) return null;
409
+ if (u = ((r = n.length - 1) - Q(this.e / M)) * M, r = n[r]) for (; r % 10 == 0; r /= 10, u--) ;
410
+ return u < 0 && (u = 0), u;
411
+ }, a.dividedBy = a.div = function(e, t) {
412
+ return f(this, new v(e, t), N, E);
413
+ }, a.dividedToIntegerBy = a.idiv = function(e, t) {
414
+ return f(this, new v(e, t), 0, 1);
415
+ }, a.exponentiatedBy = a.pow = function(e, t) {
416
+ var n, u, r, o, d, s, i, h, l, w = this;
417
+ if (e = new v(e), e.c && !e.isInteger())
418
+ throw Error(z + "Exponent not an integer: " + ne(e));
419
+ if (t != null && (t = new v(t)), s = e.e > 14, !w.c || !w.c[0] || w.c[0] == 1 && !w.e && w.c.length == 1 || !e.c || !e.c[0])
420
+ return l = new v(Math.pow(+ne(w), s ? e.s * (2 - de(e)) : +ne(e))), t ? l.mod(t) : l;
421
+ if (i = e.s < 0, t) {
422
+ if (t.c ? !t.c[0] : !t.s) return new v(NaN);
423
+ u = !i && w.isInteger() && t.isInteger(), u && (w = w.mod(t));
424
+ } else {
425
+ if (e.e > 9 && (w.e > 0 || w.e < -1 || (w.e == 0 ? w.c[0] > 1 || s && w.c[1] >= 24e7 : w.c[0] < 8e13 || s && w.c[0] <= 9999975e7)))
426
+ return o = w.s < 0 && de(e) ? -0 : 0, w.e > -1 && (o = 1 / o), new v(i ? 1 / o : o);
427
+ I && (o = Re(I / M + 2));
428
+ }
429
+ for (s ? (n = new v(0.5), i && (e.s = 1), h = de(e)) : (r = Math.abs(+ne(e)), h = r % 2), l = new v(p); ; ) {
430
+ if (h) {
431
+ if (l = l.times(w), !l.c) break;
432
+ o ? l.c.length > o && (l.c.length = o) : u && (l = l.mod(t));
433
+ }
434
+ if (r) {
435
+ if (r = K(r / 2), r === 0) break;
436
+ h = r % 2;
437
+ } else if (e = e.times(n), j(e, e.e + 1, 1), e.e > 14)
438
+ h = de(e);
439
+ else {
440
+ if (r = +ne(e), r === 0) break;
441
+ h = r % 2;
442
+ }
443
+ w = w.times(w), o ? w.c && w.c.length > o && (w.c.length = o) : u && (w = w.mod(t));
444
+ }
445
+ return u ? l : (i && (l = p.div(l)), t ? l.mod(t) : o ? j(l, I, E, d) : l);
446
+ }, a.integerValue = function(e) {
447
+ var t = new v(this);
448
+ return e == null ? e = E : D(e, 0, 8), j(t, t.e + 1, e);
449
+ }, a.isEqualTo = a.eq = function(e, t) {
450
+ return ie(this, new v(e, t)) === 0;
451
+ }, a.isFinite = function() {
452
+ return !!this.c;
453
+ }, a.isGreaterThan = a.gt = function(e, t) {
454
+ return ie(this, new v(e, t)) > 0;
455
+ }, a.isGreaterThanOrEqualTo = a.gte = function(e, t) {
456
+ return (t = ie(this, new v(e, t))) === 1 || t === 0;
457
+ }, a.isInteger = function() {
458
+ return !!this.c && Q(this.e / M) > this.c.length - 2;
459
+ }, a.isLessThan = a.lt = function(e, t) {
460
+ return ie(this, new v(e, t)) < 0;
461
+ }, a.isLessThanOrEqualTo = a.lte = function(e, t) {
462
+ return (t = ie(this, new v(e, t))) === -1 || t === 0;
463
+ }, a.isNaN = function() {
464
+ return !this.s;
465
+ }, a.isNegative = function() {
466
+ return this.s < 0;
467
+ }, a.isPositive = function() {
468
+ return this.s > 0;
469
+ }, a.isZero = function() {
470
+ return !!this.c && this.c[0] == 0;
471
+ }, a.minus = function(e, t) {
472
+ var n, u, r, o, d = this, s = d.s;
473
+ if (e = new v(e, t), t = e.s, !s || !t) return new v(NaN);
474
+ if (s != t)
475
+ return e.s = -t, d.plus(e);
476
+ var i = d.e / M, h = e.e / M, l = d.c, w = e.c;
477
+ if (!i || !h) {
478
+ if (!l || !w) return l ? (e.s = -t, e) : new v(w ? d : NaN);
479
+ if (!l[0] || !w[0])
480
+ return w[0] ? (e.s = -t, e) : new v(l[0] ? d : (
481
+ // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
482
+ E == 3 ? -0 : 0
483
+ ));
484
+ }
485
+ if (i = Q(i), h = Q(h), l = l.slice(), s = i - h) {
486
+ for ((o = s < 0) ? (s = -s, r = l) : (h = i, r = w), r.reverse(), t = s; t--; r.push(0)) ;
487
+ r.reverse();
488
+ } else
489
+ for (u = (o = (s = l.length) < (t = w.length)) ? s : t, s = t = 0; t < u; t++)
490
+ if (l[t] != w[t]) {
491
+ o = l[t] < w[t];
492
+ break;
493
+ }
494
+ if (o && (r = l, l = w, w = r, e.s = -e.s), t = (u = w.length) - (n = l.length), t > 0) for (; t--; l[n++] = 0) ;
495
+ for (t = Z - 1; u > s; ) {
496
+ if (l[--u] < w[u]) {
497
+ for (n = u; n && !l[--n]; l[n] = t) ;
498
+ --l[n], l[u] += Z;
499
+ }
500
+ l[u] -= w[u];
501
+ }
502
+ for (; l[0] == 0; l.splice(0, 1), --h) ;
503
+ return l[0] ? te(e, l, h) : (e.s = E == 3 ? -1 : 1, e.c = [e.e = 0], e);
504
+ }, a.modulo = a.mod = function(e, t) {
505
+ var n, u, r = this;
506
+ return e = new v(e, t), !r.c || !e.s || e.c && !e.c[0] ? new v(NaN) : !e.c || r.c && !r.c[0] ? new v(r) : (P == 9 ? (u = e.s, e.s = 1, n = f(r, e, 0, 3), e.s = u, n.s *= u) : n = f(r, e, 0, P), e = r.minus(n.times(e)), !e.c[0] && P == 1 && (e.s = r.s), e);
507
+ }, a.multipliedBy = a.times = function(e, t) {
508
+ var n, u, r, o, d, s, i, h, l, w, C, x, L, B, b, T = this, q = T.c, W = (e = new v(e, t)).c;
509
+ if (!q || !W || !q[0] || !W[0])
510
+ return !T.s || !e.s || q && !q[0] && !W || W && !W[0] && !q ? e.c = e.e = e.s = null : (e.s *= T.s, !q || !W ? e.c = e.e = null : (e.c = [0], e.e = 0)), e;
511
+ for (u = Q(T.e / M) + Q(e.e / M), e.s *= T.s, i = q.length, w = W.length, i < w && (L = q, q = W, W = L, r = i, i = w, w = r), r = i + w, L = []; r--; L.push(0)) ;
512
+ for (B = Z, b = re, r = w; --r >= 0; ) {
513
+ for (n = 0, C = W[r] % b, x = W[r] / b | 0, d = i, o = r + d; o > r; )
514
+ h = q[--d] % b, l = q[d] / b | 0, s = x * h + l * C, h = C * h + s % b * b + L[o] + n, n = (h / B | 0) + (s / b | 0) + x * l, L[o--] = h % B;
515
+ L[o] = n;
516
+ }
517
+ return n ? ++u : L.splice(0, 1), te(e, L, u);
518
+ }, a.negated = function() {
519
+ var e = new v(this);
520
+ return e.s = -e.s || null, e;
521
+ }, a.plus = function(e, t) {
522
+ var n, u = this, r = u.s;
523
+ if (e = new v(e, t), t = e.s, !r || !t) return new v(NaN);
524
+ if (r != t)
525
+ return e.s = -t, u.minus(e);
526
+ var o = u.e / M, d = e.e / M, s = u.c, i = e.c;
527
+ if (!o || !d) {
528
+ if (!s || !i) return new v(r / 0);
529
+ if (!s[0] || !i[0]) return i[0] ? e : new v(s[0] ? u : r * 0);
530
+ }
531
+ if (o = Q(o), d = Q(d), s = s.slice(), r = o - d) {
532
+ for (r > 0 ? (d = o, n = i) : (r = -r, n = s), n.reverse(); r--; n.push(0)) ;
533
+ n.reverse();
534
+ }
535
+ for (r = s.length, t = i.length, r - t < 0 && (n = i, i = s, s = n, t = r), r = 0; t; )
536
+ r = (s[--t] = s[t] + i[t] + r) / Z | 0, s[t] = Z === s[t] ? 0 : s[t] % Z;
537
+ return r && (s = [r].concat(s), ++d), te(e, s, d);
538
+ }, a.precision = a.sd = function(e, t) {
539
+ var n, u, r, o = this;
540
+ if (e != null && e !== !!e)
541
+ return D(e, 1, F), t == null ? t = E : D(t, 0, 8), j(new v(o), e, t);
542
+ if (!(n = o.c)) return null;
543
+ if (r = n.length - 1, u = r * M + 1, r = n[r]) {
544
+ for (; r % 10 == 0; r /= 10, u--) ;
545
+ for (r = n[0]; r >= 10; r /= 10, u++) ;
546
+ }
547
+ return e && o.e + 1 > u && (u = o.e + 1), u;
548
+ }, a.shiftedBy = function(e) {
549
+ return D(e, -Ue, Ue), this.times("1e" + e);
550
+ }, a.squareRoot = a.sqrt = function() {
551
+ var e, t, n, u, r, o = this, d = o.c, s = o.s, i = o.e, h = N + 4, l = new v("0.5");
552
+ if (s !== 1 || !d || !d[0])
553
+ return new v(!s || s < 0 && (!d || d[0]) ? NaN : d ? o : 1 / 0);
554
+ if (s = Math.sqrt(+ne(o)), s == 0 || s == 1 / 0 ? (t = Y(d), (t.length + i) % 2 == 0 && (t += "0"), s = Math.sqrt(+t), i = Q((i + 1) / 2) - (i < 0 || i % 2), s == 1 / 0 ? t = "5e" + i : (t = s.toExponential(), t = t.slice(0, t.indexOf("e") + 1) + i), n = new v(t)) : n = new v(s + ""), n.c[0]) {
555
+ for (i = n.e, s = i + h, s < 3 && (s = 0); ; )
556
+ if (r = n, n = l.times(r.plus(f(o, r, h, 1))), Y(r.c).slice(0, s) === (t = Y(n.c)).slice(0, s))
557
+ if (n.e < i && --s, t = t.slice(s - 3, s + 1), t == "9999" || !u && t == "4999") {
558
+ if (!u && (j(r, r.e + N + 2, 0), r.times(r).eq(o))) {
559
+ n = r;
560
+ break;
561
+ }
562
+ h += 4, s += 4, u = 1;
563
+ } else {
564
+ (!+t || !+t.slice(1) && t.charAt(0) == "5") && (j(n, n.e + N + 2, 1), e = !n.times(n).eq(o));
565
+ break;
566
+ }
567
+ }
568
+ return j(n, n.e + N + 1, E, e);
569
+ }, a.toExponential = function(e, t) {
570
+ return e != null && (D(e, 0, F), e++), $(this, e, t, 1);
571
+ }, a.toFixed = function(e, t) {
572
+ return e != null && (D(e, 0, F), e = e + this.e + 1), $(this, e, t);
573
+ }, a.toFormat = function(e, t, n) {
574
+ var u, r = this;
575
+ if (n == null)
576
+ e != null && t && typeof t == "object" ? (n = t, t = null) : e && typeof e == "object" ? (n = e, e = t = null) : n = G;
577
+ else if (typeof n != "object")
578
+ throw Error(z + "Argument not an object: " + n);
579
+ if (u = r.toFixed(e, t), r.c) {
580
+ var o, d = u.split("."), s = +n.groupSize, i = +n.secondaryGroupSize, h = n.groupSeparator || "", l = d[0], w = d[1], C = r.s < 0, x = C ? l.slice(1) : l, L = x.length;
581
+ if (i && (o = s, s = i, i = o, L -= o), s > 0 && L > 0) {
582
+ for (o = L % s || s, l = x.substr(0, o); o < L; o += s) l += h + x.substr(o, s);
583
+ i > 0 && (l += h + x.slice(o)), C && (l = "-" + l);
584
+ }
585
+ u = w ? l + (n.decimalSeparator || "") + ((i = +n.fractionGroupSize) ? w.replace(
586
+ new RegExp("\\d{" + i + "}\\B", "g"),
587
+ "$&" + (n.fractionGroupSeparator || "")
588
+ ) : w) : l;
589
+ }
590
+ return (n.prefix || "") + u + (n.suffix || "");
591
+ }, a.toFraction = function(e) {
592
+ var t, n, u, r, o, d, s, i, h, l, w, C, x = this, L = x.c;
593
+ if (e != null && (s = new v(e), !s.isInteger() && (s.c || s.s !== 1) || s.lt(p)))
594
+ throw Error(z + "Argument " + (s.isInteger() ? "out of range: " : "not an integer: ") + ne(s));
595
+ if (!L) return new v(x);
596
+ for (t = new v(p), h = n = new v(p), u = i = new v(p), C = Y(L), o = t.e = C.length - x.e - 1, t.c[0] = be[(d = o % M) < 0 ? M + d : d], e = !e || s.comparedTo(t) > 0 ? o > 0 ? t : h : s, d = _, _ = 1 / 0, s = new v(C), i.c[0] = 0; l = f(s, t, 0, 1), r = n.plus(l.times(u)), r.comparedTo(e) != 1; )
597
+ n = u, u = r, h = i.plus(l.times(r = h)), i = r, t = s.minus(l.times(r = t)), s = r;
598
+ return r = f(e.minus(n), u, 0, 1), i = i.plus(r.times(h)), n = n.plus(r.times(u)), i.s = h.s = x.s, o = o * 2, w = f(h, u, o, E).minus(x).abs().comparedTo(
599
+ f(i, n, o, E).minus(x).abs()
600
+ ) < 1 ? [h, u] : [i, n], _ = d, w;
601
+ }, a.toNumber = function() {
602
+ return +ne(this);
603
+ }, a.toPrecision = function(e, t) {
604
+ return e != null && D(e, 1, F), $(this, e, t, 2);
605
+ }, a.toString = function(e) {
606
+ var t, n = this, u = n.s, r = n.e;
607
+ return r === null ? u ? (t = "Infinity", u < 0 && (t = "-" + t)) : t = "NaN" : (e == null ? t = r <= y || r >= S ? we(Y(n.c), r) : se(Y(n.c), r, "0") : e === 10 && V ? (n = j(new v(n), N + r + 1, E), t = se(Y(n.c), n.e, "0")) : (D(e, 2, O.length, "Base"), t = g(se(Y(n.c), r, "0"), 10, e, u, !0)), u < 0 && n.c[0] && (t = "-" + t)), t;
608
+ }, a.valueOf = a.toJSON = function() {
609
+ return ne(this);
610
+ }, a._isBigNumber = !0, a[Symbol.toStringTag] = "BigNumber", a[Symbol.for("nodejs.util.inspect.custom")] = a.valueOf, m != null && v.set(m), v;
611
+ }
612
+ function Q(m) {
613
+ var f = m | 0;
614
+ return m > 0 || m === f ? f : f - 1;
615
+ }
616
+ function Y(m) {
617
+ for (var f, g, c = 1, a = m.length, p = m[0] + ""; c < a; ) {
618
+ for (f = m[c++] + "", g = M - f.length; g--; f = "0" + f) ;
619
+ p += f;
620
+ }
621
+ for (a = p.length; p.charCodeAt(--a) === 48; ) ;
622
+ return p.slice(0, a + 1 || 1);
623
+ }
624
+ function ie(m, f) {
625
+ var g, c, a = m.c, p = f.c, N = m.s, E = f.s, y = m.e, S = f.e;
626
+ if (!N || !E) return null;
627
+ if (g = a && !a[0], c = p && !p[0], g || c) return g ? c ? 0 : -E : N;
628
+ if (N != E) return N;
629
+ if (g = N < 0, c = y == S, !a || !p) return c ? 0 : !a ^ g ? 1 : -1;
630
+ if (!c) return y > S ^ g ? 1 : -1;
631
+ for (E = (y = a.length) < (S = p.length) ? y : S, N = 0; N < E; N++) if (a[N] != p[N]) return a[N] > p[N] ^ g ? 1 : -1;
632
+ return y == S ? 0 : y > S ^ g ? 1 : -1;
633
+ }
634
+ function D(m, f, g, c) {
635
+ if (m < f || m > g || m !== K(m))
636
+ throw Error(z + (c || "Argument") + (typeof m == "number" ? m < f || m > g ? " out of range: " : " not an integer: " : " not a primitive number: ") + String(m));
637
+ }
638
+ function de(m) {
639
+ var f = m.c.length - 1;
640
+ return Q(m.e / M) == f && m.c[f] % 2 != 0;
641
+ }
642
+ function we(m, f) {
643
+ return (m.length > 1 ? m.charAt(0) + "." + m.slice(1) : m) + (f < 0 ? "e" : "e+") + f;
644
+ }
645
+ function se(m, f, g) {
646
+ var c, a;
647
+ if (f < 0) {
648
+ for (a = g + "."; ++f; a += g) ;
649
+ m = a + m;
650
+ } else if (c = m.length, ++f > c) {
651
+ for (a = g, f -= c; --f; a += g) ;
652
+ m += a;
653
+ } else f < c && (m = m.slice(0, f) + "." + m.slice(f));
654
+ return m;
655
+ }
656
+ var ze = ut();
657
+ class le extends Error {
658
+ constructor(f, g = {}) {
659
+ const c = (() => {
660
+ var N;
661
+ return g.cause instanceof le ? g.cause.details : (N = g.cause) != null && N.message ? g.cause.message : g.details;
662
+ })(), a = g.cause instanceof le && g.cause.docsPath || g.docsPath, p = [
663
+ f || "An error occurred.",
664
+ "",
665
+ ...g.metaMessages ? [...g.metaMessages, ""] : [],
666
+ ...c ? [`Details: ${c}`] : []
667
+ ].join(`
668
+ `);
669
+ super(p), this.name = "BaseError", g.cause && (this.cause = g.cause), this.details = c, this.docsPath = a, this.metaMessages = g.metaMessages, this.name = g.name ?? this.name, this.shortMessage = f;
670
+ }
671
+ walk(f) {
672
+ return ft(this, f);
673
+ }
674
+ }
675
+ function ft(m, f) {
676
+ return f != null && f(m) ? m : m && typeof m == "object" && "cause" in m ? ft(m.cause, f) : f ? null : m;
677
+ }
678
+ const _t = (m, f, g) => JSON.stringify(
679
+ m,
680
+ (c, a) => typeof a == "bigint" ? a.toString() : a,
681
+ g
682
+ ), St = (m) => m;
683
+ class Ot extends le {
684
+ constructor({
685
+ body: f,
686
+ error: g,
687
+ url: c
688
+ }) {
689
+ super("RPC Request failed.", {
690
+ cause: g,
691
+ details: g.message,
692
+ metaMessages: [`URL: ${St(c)}`, `Request body: ${_t(f)}`],
693
+ name: "RpcRequestError"
694
+ }), this.code = g.code;
695
+ }
696
+ }
697
+ const At = -1;
698
+ class X extends le {
699
+ constructor(f, { code: g, docsPath: c, metaMessages: a, name: p, shortMessage: N }) {
700
+ super(N, {
701
+ cause: f,
702
+ docsPath: c,
703
+ metaMessages: a || (f == null ? void 0 : f.metaMessages),
704
+ name: p || "RpcError"
705
+ }), this.name = p || f.name, this.code = f instanceof Ot ? f.code : g ?? At;
706
+ }
707
+ }
708
+ class oe extends X {
709
+ constructor(f, g) {
710
+ super(f, g), this.data = g.data;
711
+ }
712
+ }
713
+ const me = class me extends X {
714
+ constructor(f) {
715
+ super(f, {
716
+ code: me.code,
717
+ name: "ParseRpcError",
718
+ shortMessage: "Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."
719
+ });
720
+ }
721
+ };
722
+ me.code = -32700;
723
+ let Xe = me;
724
+ const Ne = class Ne extends X {
725
+ constructor(f) {
726
+ super(f, {
727
+ code: Ne.code,
728
+ name: "InvalidRequestRpcError",
729
+ shortMessage: "JSON is not a valid request object."
730
+ });
731
+ }
732
+ };
733
+ Ne.code = -32600;
734
+ let je = Ne;
735
+ const Ee = class Ee extends X {
736
+ constructor(f, { method: g } = {}) {
737
+ super(f, {
738
+ code: Ee.code,
739
+ name: "MethodNotFoundRpcError",
740
+ shortMessage: `The method${g ? ` "${g}"` : ""} does not exist / is not available.`
741
+ });
742
+ }
743
+ };
744
+ Ee.code = -32601;
745
+ let Je = Ee;
746
+ const ye = class ye extends X {
747
+ constructor(f) {
748
+ super(f, {
749
+ code: ye.code,
750
+ name: "InvalidParamsRpcError",
751
+ shortMessage: [
752
+ "Invalid parameters were provided to the RPC method.",
753
+ "Double check you have provided the correct parameters."
754
+ ].join(`
755
+ `)
756
+ });
757
+ }
758
+ };
759
+ ye.code = -32602;
760
+ let Ye = ye;
761
+ const Ce = class Ce extends X {
762
+ constructor(f) {
763
+ super(f, {
764
+ code: Ce.code,
765
+ name: "InternalRpcError",
766
+ shortMessage: "An internal error was received."
767
+ });
768
+ }
769
+ };
770
+ Ce.code = -32603;
771
+ let Ke = Ce;
772
+ const xe = class xe extends X {
773
+ constructor(f) {
774
+ super(f, {
775
+ code: xe.code,
776
+ name: "InvalidInputRpcError",
777
+ shortMessage: ["Missing or invalid parameters.", "Double check you have provided the correct parameters."].join(
778
+ `
779
+ `
780
+ )
781
+ });
782
+ }
783
+ };
784
+ xe.code = -32e3;
785
+ let Qe = xe;
786
+ const _e = class _e extends X {
787
+ constructor(f) {
788
+ super(f, {
789
+ code: _e.code,
790
+ name: "ResourceNotFoundRpcError",
791
+ shortMessage: "Requested resource not found."
792
+ }), this.name = "ResourceNotFoundRpcError";
793
+ }
794
+ };
795
+ _e.code = -32001;
796
+ let Ze = _e;
797
+ const Se = class Se extends X {
798
+ constructor(f) {
799
+ super(f, {
800
+ code: Se.code,
801
+ name: "ResourceUnavailableRpcError",
802
+ shortMessage: "Requested resource not available."
803
+ });
804
+ }
805
+ };
806
+ Se.code = -32002;
807
+ let ve = Se;
808
+ const Oe = class Oe extends X {
809
+ constructor(f) {
810
+ super(f, {
811
+ code: Oe.code,
812
+ name: "TransactionRejectedRpcError",
813
+ shortMessage: "Transaction creation failed."
814
+ });
815
+ }
816
+ };
817
+ Oe.code = -32003;
818
+ let et = Oe;
819
+ const Ae = class Ae extends X {
820
+ constructor(f, { method: g } = {}) {
821
+ super(f, {
822
+ code: Ae.code,
823
+ name: "MethodNotSupportedRpcError",
824
+ shortMessage: `Method${g ? ` "${g}"` : ""} is not implemented.`
825
+ });
826
+ }
827
+ };
828
+ Ae.code = -32004;
829
+ let tt = Ae;
830
+ const Me = class Me extends X {
831
+ constructor(f) {
832
+ super(f, {
833
+ code: Me.code,
834
+ name: "LimitExceededRpcError",
835
+ shortMessage: "Request exceeds defined limit."
836
+ });
837
+ }
838
+ };
839
+ Me.code = -32005;
840
+ let nt = Me;
841
+ const ke = class ke extends X {
842
+ constructor(f) {
843
+ super(f, {
844
+ code: ke.code,
845
+ name: "JsonRpcVersionUnsupportedError",
846
+ shortMessage: "Version of JSON-RPC protocol is not supported."
847
+ });
848
+ }
849
+ };
850
+ ke.code = -32006;
851
+ let st = ke;
852
+ const Te = class Te extends oe {
853
+ constructor(f) {
854
+ super(f, {
855
+ code: Te.code,
856
+ name: "UserRejectedRequestError",
857
+ shortMessage: "User rejected the request."
858
+ });
859
+ }
860
+ };
861
+ Te.code = 4001;
862
+ let U = Te;
863
+ const Ie = class Ie extends oe {
864
+ constructor(f) {
865
+ super(f, {
866
+ code: Ie.code,
867
+ name: "UnauthorizedProviderError",
868
+ shortMessage: "The requested method and/or account has not been authorized by the user."
869
+ });
870
+ }
871
+ };
872
+ Ie.code = 4100;
873
+ let rt = Ie;
874
+ const Le = class Le extends oe {
875
+ constructor(f, { method: g } = {}) {
876
+ super(f, {
877
+ code: Le.code,
878
+ name: "UnsupportedProviderMethodError",
879
+ shortMessage: `The Provider does not support the requested method${g ? ` " ${g}"` : ""}.`
880
+ });
881
+ }
882
+ };
883
+ Le.code = 4200;
884
+ let it = Le;
885
+ const Pe = class Pe extends oe {
886
+ constructor(f) {
887
+ super(f, {
888
+ code: Pe.code,
889
+ name: "ProviderDisconnectedError",
890
+ shortMessage: "The Provider is disconnected from all chains."
891
+ });
892
+ }
893
+ };
894
+ Pe.code = 4900;
895
+ let ot = Pe;
896
+ const qe = class qe extends oe {
897
+ constructor(f) {
898
+ super(f, {
899
+ code: qe.code,
900
+ name: "ChainDisconnectedError",
901
+ shortMessage: "The Provider is not connected to the requested chain."
902
+ });
903
+ }
904
+ };
905
+ qe.code = 4901;
906
+ let ct = qe;
907
+ const $e = class $e extends oe {
908
+ constructor(f) {
909
+ super(f, {
910
+ code: $e.code,
911
+ name: "SwitchChainError",
912
+ shortMessage: "An error occurred when attempting to switch chain."
913
+ });
914
+ }
915
+ };
916
+ $e.code = 4902;
917
+ let Fe = $e;
918
+ const Ge = 256;
919
+ let pe = Ge, ge;
920
+ function Mt(m = 11) {
921
+ if (!ge || pe + m > Ge * 2) {
922
+ ge = "", pe = 0;
923
+ for (let f = 0; f < Ge; f++)
924
+ ge += (256 + Math.random() * 256 | 0).toString(16).substring(1);
925
+ }
926
+ return ge.substring(pe, pe++ + m);
927
+ }
928
+ var ht = { exports: {} };
929
+ (function(m) {
930
+ var f = Object.prototype.hasOwnProperty, g = "~";
931
+ function c() {
932
+ }
933
+ Object.create && (c.prototype = /* @__PURE__ */ Object.create(null), new c().__proto__ || (g = !1));
934
+ function a(y, S, A) {
935
+ this.fn = y, this.context = S, this.once = A || !1;
936
+ }
937
+ function p(y, S, A, _, k) {
938
+ if (typeof A != "function")
939
+ throw new TypeError("The listener must be a function");
940
+ var P = new a(A, _ || y, k), I = g ? g + S : S;
941
+ return y._events[I] ? y._events[I].fn ? y._events[I] = [y._events[I], P] : y._events[I].push(P) : (y._events[I] = P, y._eventsCount++), y;
942
+ }
943
+ function N(y, S) {
944
+ --y._eventsCount === 0 ? y._events = new c() : delete y._events[S];
945
+ }
946
+ function E() {
947
+ this._events = new c(), this._eventsCount = 0;
948
+ }
949
+ E.prototype.eventNames = function() {
950
+ var S = [], A, _;
951
+ if (this._eventsCount === 0) return S;
952
+ for (_ in A = this._events)
953
+ f.call(A, _) && S.push(g ? _.slice(1) : _);
954
+ return Object.getOwnPropertySymbols ? S.concat(Object.getOwnPropertySymbols(A)) : S;
955
+ }, E.prototype.listeners = function(S) {
956
+ var A = g ? g + S : S, _ = this._events[A];
957
+ if (!_) return [];
958
+ if (_.fn) return [_.fn];
959
+ for (var k = 0, P = _.length, I = new Array(P); k < P; k++)
960
+ I[k] = _[k].fn;
961
+ return I;
962
+ }, E.prototype.listenerCount = function(S) {
963
+ var A = g ? g + S : S, _ = this._events[A];
964
+ return _ ? _.fn ? 1 : _.length : 0;
965
+ }, E.prototype.emit = function(S, A, _, k, P, I) {
966
+ var G = g ? g + S : S;
967
+ if (!this._events[G]) return !1;
968
+ var O = this._events[G], V = arguments.length, v, $;
969
+ if (O.fn) {
970
+ switch (O.once && this.removeListener(S, O.fn, void 0, !0), V) {
971
+ case 1:
972
+ return O.fn.call(O.context), !0;
973
+ case 2:
974
+ return O.fn.call(O.context, A), !0;
975
+ case 3:
976
+ return O.fn.call(O.context, A, _), !0;
977
+ case 4:
978
+ return O.fn.call(O.context, A, _, k), !0;
979
+ case 5:
980
+ return O.fn.call(O.context, A, _, k, P), !0;
981
+ case 6:
982
+ return O.fn.call(O.context, A, _, k, P, I), !0;
983
+ }
984
+ for ($ = 1, v = new Array(V - 1); $ < V; $++)
985
+ v[$ - 1] = arguments[$];
986
+ O.fn.apply(O.context, v);
987
+ } else {
988
+ var ue = O.length, te;
989
+ for ($ = 0; $ < ue; $++)
990
+ switch (O[$].once && this.removeListener(S, O[$].fn, void 0, !0), V) {
991
+ case 1:
992
+ O[$].fn.call(O[$].context);
993
+ break;
994
+ case 2:
995
+ O[$].fn.call(O[$].context, A);
996
+ break;
997
+ case 3:
998
+ O[$].fn.call(O[$].context, A, _);
999
+ break;
1000
+ case 4:
1001
+ O[$].fn.call(O[$].context, A, _, k);
1002
+ break;
1003
+ default:
1004
+ if (!v) for (te = 1, v = new Array(V - 1); te < V; te++)
1005
+ v[te - 1] = arguments[te];
1006
+ O[$].fn.apply(O[$].context, v);
1007
+ }
1008
+ }
1009
+ return !0;
1010
+ }, E.prototype.on = function(S, A, _) {
1011
+ return p(this, S, A, _, !1);
1012
+ }, E.prototype.once = function(S, A, _) {
1013
+ return p(this, S, A, _, !0);
1014
+ }, E.prototype.removeListener = function(S, A, _, k) {
1015
+ var P = g ? g + S : S;
1016
+ if (!this._events[P]) return this;
1017
+ if (!A)
1018
+ return N(this, P), this;
1019
+ var I = this._events[P];
1020
+ if (I.fn)
1021
+ I.fn === A && (!k || I.once) && (!_ || I.context === _) && N(this, P);
1022
+ else {
1023
+ for (var G = 0, O = [], V = I.length; G < V; G++)
1024
+ (I[G].fn !== A || k && !I[G].once || _ && I[G].context !== _) && O.push(I[G]);
1025
+ O.length ? this._events[P] = O.length === 1 ? O[0] : O : N(this, P);
1026
+ }
1027
+ return this;
1028
+ }, E.prototype.removeAllListeners = function(S) {
1029
+ var A;
1030
+ return S ? (A = g ? g + S : S, this._events[A] && N(this, A)) : (this._events = new c(), this._eventsCount = 0), this;
1031
+ }, E.prototype.off = E.prototype.removeListener, E.prototype.addListener = E.prototype.on, E.prefixed = g, E.EventEmitter = E, m.exports = E;
1032
+ })(ht);
1033
+ var kt = ht.exports;
1034
+ const dt = /* @__PURE__ */ wt(kt);
1035
+ class Tt {
1036
+ constructor(f, g) {
1037
+ this.getNetworkId = async () => this.store.getState().currentNetworkId, this.getProvider = () => this.provider || {}, this.beforeConnecting = async () => {
1038
+ this.store.setState({
1039
+ isConnecting: {
1040
+ icon: this.icon,
1041
+ name: this.name
1042
+ }
1043
+ });
1044
+ }, this.connectError = async () => {
1045
+ this.store.setState({
1046
+ isConnecting: !1
1047
+ });
1048
+ }, this.connectSuccess = async (c) => {
1049
+ this.walletAddress = c, this.store.setState({
1050
+ connectStatus: We.Connected,
1051
+ walletAddress: c,
1052
+ currentConnector: this,
1053
+ currentConnectorName: this.name,
1054
+ provider: this.getProvider(),
1055
+ isConnecting: !1
1056
+ }), this.icon && pt.getState().setAvatar({
1057
+ icon: this.icon
1058
+ });
1059
+ }, this.getWalletAddress = () => this.walletAddress, this.resetStatus = async () => {
1060
+ this.store.setState({
1061
+ connectStatus: We.Disconnected,
1062
+ currentConnector: null,
1063
+ walletAddress: "",
1064
+ provider: null,
1065
+ isConnecting: !1
1066
+ });
1067
+ }, this.on = (c, a) => {
1068
+ this.walletEventEmitter.on(c, a);
1069
+ }, this.off = (c, a) => {
1070
+ this.walletEventEmitter.off(c, a);
1071
+ }, this.once = (c, a) => {
1072
+ this.walletEventEmitter.once(c, a);
1073
+ }, this.name = f.name, this.icon = f.icon, this.deepLink = f.deepLink, this.extension = f.extension, this.downloadUrl = f.downloadUrl, this.walletAddress = "", this.provider = g, this.connectorType = lt.More, this.walletEventEmitter = new dt(), this.store = He, this.supportedNetworks = He.getState().getSupportNets();
1074
+ }
1075
+ // public readonly onDisconnect = (callback: () => void) => {
1076
+ // this.walletEventEmitter.on('disconnect', callback);
1077
+ // };
1078
+ // public readonly onAccountsChanged = (callback: (address: string) => void) => {
1079
+ // this.walletEventEmitter.on('accountsChanged', callback);
1080
+ // };
1081
+ // public readonly onChainChanged = (callback: (chainId: string) => void) => {
1082
+ // this.walletEventEmitter.on('chainChanged', callback);
1083
+ // };
1084
+ // protected readonly emitConnect = (address: string) => {
1085
+ // this.walletEventEmitter.emit('connect', address);
1086
+ // };
1087
+ // protected readonly emitDisconnect = () => {
1088
+ // this.walletEventEmitter.emit('disconnect');
1089
+ // };
1090
+ // protected readonly emitAccountsChanged = (address: string) => {
1091
+ // this.walletEventEmitter.emit('accountsChanged', address);
1092
+ // };
1093
+ // protected readonly emitChainChanged = (chainId: string) => {
1094
+ // this.walletEventEmitter.emit('chainChanged', chainId);
1095
+ // };
1096
+ }
1097
+ class It {
1098
+ constructor(f) {
1099
+ this.uid = f, this._emitter = new dt();
1100
+ }
1101
+ on(f, g) {
1102
+ this._emitter.on(f, g);
1103
+ }
1104
+ once(f, g) {
1105
+ this._emitter.once(f, g);
1106
+ }
1107
+ off(f, g) {
1108
+ this._emitter.off(f, g);
1109
+ }
1110
+ emit(f, ...g) {
1111
+ const c = g[0];
1112
+ this._emitter.emit(f, { uid: this.uid, ...c });
1113
+ }
1114
+ listenerCount(f) {
1115
+ return this._emitter.listenerCount(f);
1116
+ }
1117
+ }
1118
+ function Lt(m) {
1119
+ return new It(m);
1120
+ }
1121
+ class at extends Tt {
1122
+ constructor(f, g) {
1123
+ super(f.info, f.provider), this.addEventListener = (c) => {
1124
+ this.$_connect && (c.removeListener("connect", this.$_connect), this.$_connect = void 0), this.$_accountsChanged || (this.$_accountsChanged = this.__onAccountsChanged.bind(this), c.on("accountsChanged", this.$_accountsChanged)), this.$_chainChanged || (this.$_chainChanged = this.__onChainChanged.bind(this), c.on("chainChanged", this.$_chainChanged)), this.$_disconnect || (this.$_disconnect = this.__onDisconnect.bind(this), c.on("disconnect", this.$_disconnect));
1125
+ }, this.removeEventListener = (c) => {
1126
+ this.$_accountsChanged && (c.removeListener("accountsChanged", this.$_accountsChanged), this.$_accountsChanged = void 0), this.$_chainChanged && (c.removeListener("chainChanged", this.$_chainChanged), this.$_chainChanged = void 0), this.$_disconnect && (c.removeListener("disconnect", this.$_disconnect), this.$_disconnect = void 0);
1127
+ }, this.setIsConnected = async () => {
1128
+ var N;
1129
+ const c = (N = await this.getAccounts()) == null ? void 0 : N[0], a = { name: this.name, address: c, isConnected: !!c }, p = new Event("WalletChange");
1130
+ p.info = a, p.provider = this.provider, window.dispatchEvent(p);
1131
+ }, this.connect = async () => {
1132
+ const c = await this.getProvider(), a = await this.getNetworkId();
1133
+ let p, N = !1;
1134
+ try {
1135
+ this.beforeConnecting();
1136
+ const E = await c.request({
1137
+ method: "eth_requestAccounts"
1138
+ });
1139
+ p = await this.getChainId(), N = Number(p) !== Number(a), N && await this.switchNetwork(a);
1140
+ const y = E[0];
1141
+ return this.connectSuccess(y), this.addEventListener(c), localStorage.setItem("isWalletConnected", "true"), this.setIsConnected(), this.walletEventEmitter.emit("connect", y), y;
1142
+ } catch (E) {
1143
+ this.connectError(), N && this.store.getState().setCurrentNetwork(Number(p));
1144
+ const y = E;
1145
+ throw y.code === U.code ? new U(y) : y.code === ve.code ? new ve(y) : y;
1146
+ }
1147
+ }, this.autoConnect = async () => {
1148
+ const c = await this.getProvider(), a = c.selectedAddress;
1149
+ if (!a) return;
1150
+ const p = await this.getChainId(), N = await this.getNetworkId();
1151
+ p !== N && await this.store.getState().setCurrentNetwork(Number(p)), this.connectSuccess(a), this.addEventListener(c), localStorage.setItem("isWalletConnected", "true"), this.setIsConnected(), this.walletEventEmitter.emit("connect", a);
1152
+ }, this.reconnection = async () => {
1153
+ try {
1154
+ const c = await this.getProvider(), p = (await this.getAccounts())[0];
1155
+ p ? (this.connectSuccess(p), this.addEventListener(c)) : this.disconnect();
1156
+ } catch (c) {
1157
+ console.error(c);
1158
+ }
1159
+ }, this.disconnect = async () => {
1160
+ var a;
1161
+ const c = await this.getProvider();
1162
+ this.removeEventListener(c), this.__onDisconnect(), (a = c == null ? void 0 : c.disconnect) == null || a.call(c), c == null || c.request({
1163
+ method: "wallet_revokePermissions",
1164
+ params: [
1165
+ {
1166
+ eth_accounts: {}
1167
+ }
1168
+ ]
1169
+ });
1170
+ }, this.getAccounts = async () => await (await this.getProvider()).request({ method: "eth_accounts" }), this.getChainId = async () => {
1171
+ const a = await (await this.getProvider()).request({ method: "eth_chainId" });
1172
+ return Number(a);
1173
+ }, this.switchChain = async ({ addEthereumChainParameter: c, chainId: a }) => {
1174
+ var E, y, S, A;
1175
+ const p = await this.getProvider(), N = this.config.chains.find((_) => _.id === a);
1176
+ try {
1177
+ return await Promise.all([
1178
+ p.request({
1179
+ method: "wallet_switchEthereumChain",
1180
+ params: [{ chainId: he(a) }]
1181
+ }).then(async () => {
1182
+ await this.getChainId() === a && this.emitter.emit("change", { chainId: a });
1183
+ }),
1184
+ new Promise((_) => {
1185
+ const k = ((P) => {
1186
+ "chainId" in P && P.chainId === a && (this.emitter.off("change", k), _());
1187
+ });
1188
+ this.emitter.on("change", k);
1189
+ })
1190
+ ]), N;
1191
+ } catch (_) {
1192
+ const k = _;
1193
+ if (k.code === 4902 || // Unwrapping for MetaMask Mobile
1194
+ // https://github.com/MetaMask/metamask-mobile/issues/2944#issuecomment-976988719
1195
+ ((y = (E = k == null ? void 0 : k.data) == null ? void 0 : E.originalError) == null ? void 0 : y.code) === 4902)
1196
+ try {
1197
+ const { default: P, ...I } = N.blockExplorers ?? {};
1198
+ let G;
1199
+ c != null && c.blockExplorerUrls ? G = c.blockExplorerUrls : P && (G = [P.url, ...Object.values(I).map(($) => $.url)]);
1200
+ let O;
1201
+ (S = c == null ? void 0 : c.rpcUrls) != null && S.length ? O = c.rpcUrls : O = [((A = N.rpcUrls.default) == null ? void 0 : A.http[0]) ?? ""];
1202
+ const V = {
1203
+ blockExplorerUrls: G,
1204
+ chainId: he(a),
1205
+ chainName: (c == null ? void 0 : c.chainName) ?? N.name,
1206
+ iconUrls: c == null ? void 0 : c.iconUrls,
1207
+ nativeCurrency: (c == null ? void 0 : c.nativeCurrency) ?? N.nativeCurrency,
1208
+ rpcUrls: O
1209
+ };
1210
+ if (await p.request({
1211
+ method: "wallet_addEthereumChain",
1212
+ params: [V]
1213
+ }), await this.getChainId() !== a)
1214
+ throw new U(new Error("User rejected switch after adding network."));
1215
+ return N;
1216
+ } catch (P) {
1217
+ throw new U(P);
1218
+ }
1219
+ throw k.code === U.code ? new U(k) : new Fe(k);
1220
+ }
1221
+ }, this.__onConnect = async (c) => {
1222
+ console.log("__onConnect---", c);
1223
+ }, this.__onAccountsChanged = (c) => {
1224
+ if (this.store.getState().isConnecting) return;
1225
+ const p = c == null ? void 0 : c[0];
1226
+ console.log("__onAccountsChanged---", p), p ? (this.connectSuccess(p), this.walletEventEmitter.emit("accountsChanged", p)) : this.__onDisconnect();
1227
+ }, this.__onChainChanged = async (c) => {
1228
+ this.store.getState().setCurrentNetwork(Number(c)), this.walletEventEmitter.emit("chainChanged", c);
1229
+ }, this.__onDisconnect = (c) => {
1230
+ var a;
1231
+ (a = (c == null ? void 0 : c.message) || "") != null && a.includes("Attempting to connect") || (this.walletEventEmitter.emit("disconnect", c), this.resetStatus(), localStorage.setItem("isWalletConnected", "false"));
1232
+ }, this.signMessage = async (c) => {
1233
+ const a = await this.getProvider();
1234
+ try {
1235
+ const p = gt(c);
1236
+ return await a.request({
1237
+ method: "personal_sign",
1238
+ params: [p, this.walletAddress]
1239
+ });
1240
+ } catch (p) {
1241
+ const N = p;
1242
+ throw N.code === U.code ? new U(N) : N;
1243
+ }
1244
+ }, this.multipleRequests = async (c) => {
1245
+ const a = await this.getProvider();
1246
+ try {
1247
+ return await Promise.all(
1248
+ c.map(
1249
+ (p) => a.request({
1250
+ chainType: ae.EVM,
1251
+ method: p.method,
1252
+ params: p.params
1253
+ })
1254
+ )
1255
+ );
1256
+ } catch (p) {
1257
+ const N = p;
1258
+ throw N.code === U.code ? new U(N) : N;
1259
+ }
1260
+ }, this.sendTransaction = async (c) => {
1261
+ const a = await this.getProvider();
1262
+ c.value && (c.value = ze(c.value).gt(0) ? c.value : "0x0");
1263
+ try {
1264
+ return await a.request({
1265
+ chainType: ae.EVM,
1266
+ method: "eth_sendTransaction",
1267
+ params: [c]
1268
+ });
1269
+ } catch (p) {
1270
+ const N = p;
1271
+ throw N.code === U.code ? new U(N) : N;
1272
+ }
1273
+ }, this.waitForTransactionReceipt = async (c, a = 6e4) => {
1274
+ const p = await this.getProvider(), N = Date.now();
1275
+ for (; Date.now() - N < a; )
1276
+ try {
1277
+ const E = await p.request({
1278
+ chainType: ae.EVM,
1279
+ method: "eth_getTransactionReceipt",
1280
+ params: [c]
1281
+ });
1282
+ if (E) return E;
1283
+ await new Promise((y) => setTimeout(y, 1e3));
1284
+ } catch (E) {
1285
+ throw E;
1286
+ }
1287
+ throw new Error("Transaction receipt timeout");
1288
+ }, this.readContract = async (c) => {
1289
+ try {
1290
+ const a = this.store.getState().currentNetwork;
1291
+ return await vt({
1292
+ ...c,
1293
+ network: a
1294
+ });
1295
+ } catch (a) {
1296
+ throw a;
1297
+ }
1298
+ }, this.writeContract = async (c) => {
1299
+ const a = await this.getProvider();
1300
+ c.value && (c.value = ze(c.value).gt(0) ? c.value : "0x0");
1301
+ try {
1302
+ const p = mt({
1303
+ abi: c.abi,
1304
+ functionName: c.functionName,
1305
+ args: c.args || []
1306
+ }), N = {
1307
+ from: this.walletAddress,
1308
+ to: c.address,
1309
+ data: p,
1310
+ value: c.value
1311
+ }, E = await a.request({
1312
+ chainType: ae.EVM,
1313
+ method: "eth_sendTransaction",
1314
+ params: [N]
1315
+ });
1316
+ return console.log(E), E;
1317
+ } catch (p) {
1318
+ console.log("evmConnector:writeContract--------------------", p);
1319
+ const N = p;
1320
+ throw N.code === U.code ? new U(N) : N;
1321
+ }
1322
+ }, this.multicall = async (c, a) => {
1323
+ try {
1324
+ const p = this.store.getState().currentNetwork;
1325
+ return await Nt(
1326
+ c,
1327
+ {
1328
+ ...a,
1329
+ network: p
1330
+ }
1331
+ );
1332
+ } catch (p) {
1333
+ const N = p;
1334
+ throw N.code === U.code ? new U(N) : N;
1335
+ }
1336
+ }, this.switchNetwork = async (c) => {
1337
+ const a = await this.getProvider();
1338
+ try {
1339
+ await a.request({
1340
+ chainType: ae.EVM,
1341
+ method: "wallet_switchEthereumChain",
1342
+ params: [{ chainId: he(c) }]
1343
+ }), this.store.getState().setCurrentNetwork(Number(c));
1344
+ } catch (p) {
1345
+ if ((p == null ? void 0 : p.code) === 4902) {
1346
+ const E = this.supportedNetworks.find((y) => y.chainId === c);
1347
+ if (E) {
1348
+ const y = {
1349
+ ...E,
1350
+ chainId: he(E == null ? void 0 : E.chainId)
1351
+ };
1352
+ await a.request({
1353
+ method: "wallet_addEthereumChain",
1354
+ params: [y]
1355
+ });
1356
+ }
1357
+ return;
1358
+ }
1359
+ const N = p;
1360
+ throw N.code === U.code ? new U(N) : N;
1361
+ }
1362
+ }, this.id = f.info.rdns, this.uid = Mt(), this.emitter = Lt(this.uid), this.connectorType = lt.Installed, window.walletProvider = {
1363
+ ...window.walletProvider ?? {},
1364
+ [this.name]: this
1365
+ }, window.addEventListener("load", () => {
1366
+ const { walletConnectName: c, isWalletConnected: a } = localStorage;
1367
+ JSON.parse(a ?? !1) && c === this.name && this.setIsConnected();
1368
+ });
1369
+ }
1370
+ }
1371
+ async function Pt() {
1372
+ const m = typeof window < "u" ? Ct() : void 0, f = Et(() => {
1373
+ const g = [], c = /* @__PURE__ */ new Set();
1374
+ if (m) {
1375
+ const a = m.getProviders();
1376
+ for (const p of a)
1377
+ c.has(p.info.rdns) || g.push(new at(p));
1378
+ }
1379
+ return g;
1380
+ });
1381
+ return m == null || m.subscribe((g) => {
1382
+ const c = /* @__PURE__ */ new Set();
1383
+ for (const p of f.getState())
1384
+ c.add(p.id);
1385
+ const a = [];
1386
+ for (const p of g)
1387
+ c.has(p.info.rdns) || a.push(new at(p));
1388
+ f.setState((p) => [...p, ...a], !0);
1389
+ }), [...f.getState()];
1390
+ }
1391
+ const $t = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1392
+ __proto__: null,
1393
+ createConnectors: Pt
1394
+ }, Symbol.toStringTag, { value: "Module" }));
1395
+ export {
1396
+ Tt as B,
1397
+ at as E,
1398
+ $t as a,
1399
+ Pt as c
1400
+ };