@injectivelabs/wallet-base 1.16.24 → 1.16.25-alpha.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 (58) hide show
  1. package/dist/cjs/index.cjs +1805 -0
  2. package/dist/cjs/index.d.cts +436 -0
  3. package/dist/cjs/package.json +2 -2
  4. package/dist/esm/chunk-BIPRnmEv.js +23 -0
  5. package/dist/esm/index.d.ts +436 -3
  6. package/dist/esm/index.js +1496 -3
  7. package/dist/esm/package.json +2 -2
  8. package/package.json +17 -17
  9. package/dist/cjs/base.d.ts +0 -9
  10. package/dist/cjs/base.js +0 -17
  11. package/dist/cjs/index.d.ts +0 -3
  12. package/dist/cjs/index.js +0 -24
  13. package/dist/cjs/types/enums.d.ts +0 -64
  14. package/dist/cjs/types/enums.js +0 -53
  15. package/dist/cjs/types/index.d.ts +0 -3
  16. package/dist/cjs/types/index.js +0 -18
  17. package/dist/cjs/types/provider.d.ts +0 -38
  18. package/dist/cjs/types/provider.js +0 -2
  19. package/dist/cjs/types/strategy.d.ts +0 -256
  20. package/dist/cjs/types/strategy.js +0 -8
  21. package/dist/cjs/utils/address.d.ts +0 -2
  22. package/dist/cjs/utils/address.js +0 -30
  23. package/dist/cjs/utils/alchemy.d.ts +0 -1
  24. package/dist/cjs/utils/alchemy.js +0 -11
  25. package/dist/cjs/utils/constants.d.ts +0 -6
  26. package/dist/cjs/utils/constants.js +0 -9
  27. package/dist/cjs/utils/cosmos.d.ts +0 -2
  28. package/dist/cjs/utils/cosmos.js +0 -13
  29. package/dist/cjs/utils/index.d.ts +0 -6
  30. package/dist/cjs/utils/index.js +0 -22
  31. package/dist/cjs/utils/tx.d.ts +0 -31
  32. package/dist/cjs/utils/tx.js +0 -14
  33. package/dist/cjs/utils/wallet.d.ts +0 -7
  34. package/dist/cjs/utils/wallet.js +0 -52
  35. package/dist/esm/base.d.ts +0 -9
  36. package/dist/esm/base.js +0 -14
  37. package/dist/esm/types/enums.d.ts +0 -64
  38. package/dist/esm/types/enums.js +0 -50
  39. package/dist/esm/types/index.d.ts +0 -3
  40. package/dist/esm/types/index.js +0 -2
  41. package/dist/esm/types/provider.d.ts +0 -38
  42. package/dist/esm/types/provider.js +0 -1
  43. package/dist/esm/types/strategy.d.ts +0 -256
  44. package/dist/esm/types/strategy.js +0 -5
  45. package/dist/esm/utils/address.d.ts +0 -2
  46. package/dist/esm/utils/address.js +0 -25
  47. package/dist/esm/utils/alchemy.d.ts +0 -1
  48. package/dist/esm/utils/alchemy.js +0 -7
  49. package/dist/esm/utils/constants.d.ts +0 -6
  50. package/dist/esm/utils/constants.js +0 -6
  51. package/dist/esm/utils/cosmos.d.ts +0 -2
  52. package/dist/esm/utils/cosmos.js +0 -9
  53. package/dist/esm/utils/index.d.ts +0 -6
  54. package/dist/esm/utils/index.js +0 -6
  55. package/dist/esm/utils/tx.d.ts +0 -31
  56. package/dist/esm/utils/tx.js +0 -10
  57. package/dist/esm/utils/wallet.d.ts +0 -7
  58. package/dist/esm/utils/wallet.js +0 -43
@@ -0,0 +1,1805 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
13
+ key = keys[i];
14
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
+ get: ((k) => from[k]).bind(null, key),
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
22
+ value: mod,
23
+ enumerable: true
24
+ }) : target, mod));
25
+
26
+ //#endregion
27
+ let __injectivelabs_exceptions = require("@injectivelabs/exceptions");
28
+ let __injectivelabs_sdk_ts = require("@injectivelabs/sdk-ts");
29
+
30
+ //#region src/types/enums.ts
31
+ const BroadcastMode = {
32
+ Block: "block",
33
+ Sync: "sync",
34
+ Async: "async"
35
+ };
36
+ const Wallet = {
37
+ Leap: "leap",
38
+ Keplr: "keplr",
39
+ Ninji: "ninji",
40
+ Magic: "magic",
41
+ Rabby: "rabby",
42
+ Ledger: "ledger",
43
+ BitGet: "BitGet",
44
+ OWallet: "owallet",
45
+ Phantom: "phantom",
46
+ Rainbow: "rainbow",
47
+ Turnkey: "turnkey",
48
+ Metamask: "metamask",
49
+ OkxWallet: "okx-wallet",
50
+ PrivateKey: "private-key",
51
+ TrustWallet: "trust-wallet",
52
+ TrezorBip32: "trezor-bip32",
53
+ TrezorBip44: "trezor-bip44",
54
+ Cosmostation: "cosmostation",
55
+ LedgerCosmos: "ledger-cosmos",
56
+ LedgerLegacy: "ledger-legacy",
57
+ WalletConnect: "wallet-connect",
58
+ CosmostationEth: "cosmostation-eth"
59
+ };
60
+ const MagicProvider = {
61
+ Email: "email",
62
+ Apple: "apple",
63
+ Github: "github",
64
+ Google: "google",
65
+ Discord: "discord",
66
+ Twitter: "twitter",
67
+ Facebook: "facebook"
68
+ };
69
+ const WalletDeviceType = {
70
+ Mobile: "mobile",
71
+ Other: "other",
72
+ Browser: "browser",
73
+ Hardware: "hardware"
74
+ };
75
+ const WalletEventListener = {
76
+ AccountChange: "account-change",
77
+ ChainIdChange: "chain-id-change"
78
+ };
79
+ const WalletAction = { ...__injectivelabs_exceptions.WalletErrorActionModule };
80
+
81
+ //#endregion
82
+ //#region src/types/strategy.ts
83
+ const TurnkeyProvider = {
84
+ Email: "email",
85
+ Google: "google",
86
+ Apple: "apple"
87
+ };
88
+
89
+ //#endregion
90
+ //#region ../../../node_modules/.pnpm/bignumber.js@9.1.2/node_modules/bignumber.js/bignumber.mjs
91
+ var isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i, mathceil = Math.ceil, mathfloor = Math.floor, bignumberError = "[BigNumber Error] ", tooManyDigits = bignumberError + "Number primitive has more than 15 significant digits: ", BASE = 0x5af3107a4000, LOG_BASE = 14, MAX_SAFE_INTEGER = 9007199254740991, POWS_TEN = [
92
+ 1,
93
+ 10,
94
+ 100,
95
+ 1e3,
96
+ 1e4,
97
+ 1e5,
98
+ 1e6,
99
+ 1e7,
100
+ 1e8,
101
+ 1e9,
102
+ 1e10,
103
+ 1e11,
104
+ 0xe8d4a51000,
105
+ 0x9184e72a000
106
+ ], SQRT_BASE = 1e7, MAX = 1e9;
107
+ function clone(configObject) {
108
+ var div, convertBase, parseNumeric, P = BigNumber$1.prototype = {
109
+ constructor: BigNumber$1,
110
+ toString: null,
111
+ valueOf: null
112
+ }, ONE = new BigNumber$1(1), DECIMAL_PLACES = 20, ROUNDING_MODE = 4, TO_EXP_NEG = -7, TO_EXP_POS = 21, MIN_EXP = -1e7, MAX_EXP = 1e7, CRYPTO = false, MODULO_MODE = 1, POW_PRECISION = 0, FORMAT = {
113
+ prefix: "",
114
+ groupSize: 3,
115
+ secondaryGroupSize: 0,
116
+ groupSeparator: ",",
117
+ decimalSeparator: ".",
118
+ fractionGroupSize: 0,
119
+ fractionGroupSeparator: "\xA0",
120
+ suffix: ""
121
+ }, ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz", alphabetHasNormalDecimalDigits = true;
122
+ function BigNumber$1(v, b) {
123
+ var alphabet, c, caseChanged, e, i, isNum, len, str, x = this;
124
+ if (!(x instanceof BigNumber$1)) return new BigNumber$1(v, b);
125
+ if (b == null) {
126
+ if (v && v._isBigNumber === true) {
127
+ x.s = v.s;
128
+ if (!v.c || v.e > MAX_EXP) x.c = x.e = null;
129
+ else if (v.e < MIN_EXP) x.c = [x.e = 0];
130
+ else {
131
+ x.e = v.e;
132
+ x.c = v.c.slice();
133
+ }
134
+ return;
135
+ }
136
+ if ((isNum = typeof v == "number") && v * 0 == 0) {
137
+ x.s = 1 / v < 0 ? (v = -v, -1) : 1;
138
+ if (v === ~~v) {
139
+ for (e = 0, i = v; i >= 10; i /= 10, e++);
140
+ if (e > MAX_EXP) x.c = x.e = null;
141
+ else {
142
+ x.e = e;
143
+ x.c = [v];
144
+ }
145
+ return;
146
+ }
147
+ str = String(v);
148
+ } else {
149
+ if (!isNumeric.test(str = String(v))) return parseNumeric(x, str, isNum);
150
+ x.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1;
151
+ }
152
+ if ((e = str.indexOf(".")) > -1) str = str.replace(".", "");
153
+ if ((i = str.search(/e/i)) > 0) {
154
+ if (e < 0) e = i;
155
+ e += +str.slice(i + 1);
156
+ str = str.substring(0, i);
157
+ } else if (e < 0) e = str.length;
158
+ } else {
159
+ intCheck(b, 2, ALPHABET.length, "Base");
160
+ if (b == 10 && alphabetHasNormalDecimalDigits) {
161
+ x = new BigNumber$1(v);
162
+ return round(x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE);
163
+ }
164
+ str = String(v);
165
+ if (isNum = typeof v == "number") {
166
+ if (v * 0 != 0) return parseNumeric(x, str, isNum, b);
167
+ x.s = 1 / v < 0 ? (str = str.slice(1), -1) : 1;
168
+ if (BigNumber$1.DEBUG && str.replace(/^0\.0*|\./, "").length > 15) throw Error(tooManyDigits + v);
169
+ } else x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;
170
+ alphabet = ALPHABET.slice(0, b);
171
+ e = i = 0;
172
+ for (len = str.length; i < len; i++) if (alphabet.indexOf(c = str.charAt(i)) < 0) {
173
+ if (c == ".") {
174
+ if (i > e) {
175
+ e = len;
176
+ continue;
177
+ }
178
+ } else if (!caseChanged) {
179
+ if (str == str.toUpperCase() && (str = str.toLowerCase()) || str == str.toLowerCase() && (str = str.toUpperCase())) {
180
+ caseChanged = true;
181
+ i = -1;
182
+ e = 0;
183
+ continue;
184
+ }
185
+ }
186
+ return parseNumeric(x, String(v), isNum, b);
187
+ }
188
+ isNum = false;
189
+ str = convertBase(str, b, 10, x.s);
190
+ if ((e = str.indexOf(".")) > -1) str = str.replace(".", "");
191
+ else e = str.length;
192
+ }
193
+ for (i = 0; str.charCodeAt(i) === 48; i++);
194
+ for (len = str.length; str.charCodeAt(--len) === 48;);
195
+ if (str = str.slice(i, ++len)) {
196
+ len -= i;
197
+ if (isNum && BigNumber$1.DEBUG && len > 15 && (v > MAX_SAFE_INTEGER || v !== mathfloor(v))) throw Error(tooManyDigits + x.s * v);
198
+ if ((e = e - i - 1) > MAX_EXP) x.c = x.e = null;
199
+ else if (e < MIN_EXP) x.c = [x.e = 0];
200
+ else {
201
+ x.e = e;
202
+ x.c = [];
203
+ i = (e + 1) % LOG_BASE;
204
+ if (e < 0) i += LOG_BASE;
205
+ if (i < len) {
206
+ if (i) x.c.push(+str.slice(0, i));
207
+ for (len -= LOG_BASE; i < len;) x.c.push(+str.slice(i, i += LOG_BASE));
208
+ i = LOG_BASE - (str = str.slice(i)).length;
209
+ } else i -= len;
210
+ for (; i--; str += "0");
211
+ x.c.push(+str);
212
+ }
213
+ } else x.c = [x.e = 0];
214
+ }
215
+ BigNumber$1.clone = clone;
216
+ BigNumber$1.ROUND_UP = 0;
217
+ BigNumber$1.ROUND_DOWN = 1;
218
+ BigNumber$1.ROUND_CEIL = 2;
219
+ BigNumber$1.ROUND_FLOOR = 3;
220
+ BigNumber$1.ROUND_HALF_UP = 4;
221
+ BigNumber$1.ROUND_HALF_DOWN = 5;
222
+ BigNumber$1.ROUND_HALF_EVEN = 6;
223
+ BigNumber$1.ROUND_HALF_CEIL = 7;
224
+ BigNumber$1.ROUND_HALF_FLOOR = 8;
225
+ BigNumber$1.EUCLID = 9;
226
+ BigNumber$1.config = BigNumber$1.set = function(obj) {
227
+ var p, v;
228
+ if (obj != null) if (typeof obj == "object") {
229
+ if (obj.hasOwnProperty(p = "DECIMAL_PLACES")) {
230
+ v = obj[p];
231
+ intCheck(v, 0, MAX, p);
232
+ DECIMAL_PLACES = v;
233
+ }
234
+ if (obj.hasOwnProperty(p = "ROUNDING_MODE")) {
235
+ v = obj[p];
236
+ intCheck(v, 0, 8, p);
237
+ ROUNDING_MODE = v;
238
+ }
239
+ if (obj.hasOwnProperty(p = "EXPONENTIAL_AT")) {
240
+ v = obj[p];
241
+ if (v && v.pop) {
242
+ intCheck(v[0], -MAX, 0, p);
243
+ intCheck(v[1], 0, MAX, p);
244
+ TO_EXP_NEG = v[0];
245
+ TO_EXP_POS = v[1];
246
+ } else {
247
+ intCheck(v, -MAX, MAX, p);
248
+ TO_EXP_NEG = -(TO_EXP_POS = v < 0 ? -v : v);
249
+ }
250
+ }
251
+ if (obj.hasOwnProperty(p = "RANGE")) {
252
+ v = obj[p];
253
+ if (v && v.pop) {
254
+ intCheck(v[0], -MAX, -1, p);
255
+ intCheck(v[1], 1, MAX, p);
256
+ MIN_EXP = v[0];
257
+ MAX_EXP = v[1];
258
+ } else {
259
+ intCheck(v, -MAX, MAX, p);
260
+ if (v) MIN_EXP = -(MAX_EXP = v < 0 ? -v : v);
261
+ else throw Error(bignumberError + p + " cannot be zero: " + v);
262
+ }
263
+ }
264
+ if (obj.hasOwnProperty(p = "CRYPTO")) {
265
+ v = obj[p];
266
+ if (v === !!v) if (v) if (typeof crypto != "undefined" && crypto && (crypto.getRandomValues || crypto.randomBytes)) CRYPTO = v;
267
+ else {
268
+ CRYPTO = !v;
269
+ throw Error(bignumberError + "crypto unavailable");
270
+ }
271
+ else CRYPTO = v;
272
+ else throw Error(bignumberError + p + " not true or false: " + v);
273
+ }
274
+ if (obj.hasOwnProperty(p = "MODULO_MODE")) {
275
+ v = obj[p];
276
+ intCheck(v, 0, 9, p);
277
+ MODULO_MODE = v;
278
+ }
279
+ if (obj.hasOwnProperty(p = "POW_PRECISION")) {
280
+ v = obj[p];
281
+ intCheck(v, 0, MAX, p);
282
+ POW_PRECISION = v;
283
+ }
284
+ if (obj.hasOwnProperty(p = "FORMAT")) {
285
+ v = obj[p];
286
+ if (typeof v == "object") FORMAT = v;
287
+ else throw Error(bignumberError + p + " not an object: " + v);
288
+ }
289
+ if (obj.hasOwnProperty(p = "ALPHABET")) {
290
+ v = obj[p];
291
+ if (typeof v == "string" && !/^.?$|[+\-.\s]|(.).*\1/.test(v)) {
292
+ alphabetHasNormalDecimalDigits = v.slice(0, 10) == "0123456789";
293
+ ALPHABET = v;
294
+ } else throw Error(bignumberError + p + " invalid: " + v);
295
+ }
296
+ } else throw Error(bignumberError + "Object expected: " + obj);
297
+ return {
298
+ DECIMAL_PLACES,
299
+ ROUNDING_MODE,
300
+ EXPONENTIAL_AT: [TO_EXP_NEG, TO_EXP_POS],
301
+ RANGE: [MIN_EXP, MAX_EXP],
302
+ CRYPTO,
303
+ MODULO_MODE,
304
+ POW_PRECISION,
305
+ FORMAT,
306
+ ALPHABET
307
+ };
308
+ };
309
+ BigNumber$1.isBigNumber = function(v) {
310
+ if (!v || v._isBigNumber !== true) return false;
311
+ if (!BigNumber$1.DEBUG) return true;
312
+ var i, n, c = v.c, e = v.e, s = v.s;
313
+ out: if ({}.toString.call(c) == "[object Array]") {
314
+ if ((s === 1 || s === -1) && e >= -MAX && e <= MAX && e === mathfloor(e)) {
315
+ if (c[0] === 0) {
316
+ if (e === 0 && c.length === 1) return true;
317
+ break out;
318
+ }
319
+ i = (e + 1) % LOG_BASE;
320
+ if (i < 1) i += LOG_BASE;
321
+ if (String(c[0]).length == i) {
322
+ for (i = 0; i < c.length; i++) {
323
+ n = c[i];
324
+ if (n < 0 || n >= BASE || n !== mathfloor(n)) break out;
325
+ }
326
+ if (n !== 0) return true;
327
+ }
328
+ }
329
+ } else if (c === null && e === null && (s === null || s === 1 || s === -1)) return true;
330
+ throw Error(bignumberError + "Invalid BigNumber: " + v);
331
+ };
332
+ BigNumber$1.maximum = BigNumber$1.max = function() {
333
+ return maxOrMin(arguments, -1);
334
+ };
335
+ BigNumber$1.minimum = BigNumber$1.min = function() {
336
+ return maxOrMin(arguments, 1);
337
+ };
338
+ BigNumber$1.random = (function() {
339
+ var pow2_53 = 9007199254740992;
340
+ var random53bitInt = Math.random() * pow2_53 & 2097151 ? function() {
341
+ return mathfloor(Math.random() * pow2_53);
342
+ } : function() {
343
+ return (Math.random() * 1073741824 | 0) * 8388608 + (Math.random() * 8388608 | 0);
344
+ };
345
+ return function(dp) {
346
+ var a, b, e, k, v, i = 0, c = [], rand = new BigNumber$1(ONE);
347
+ if (dp == null) dp = DECIMAL_PLACES;
348
+ else intCheck(dp, 0, MAX);
349
+ k = mathceil(dp / LOG_BASE);
350
+ if (CRYPTO) if (crypto.getRandomValues) {
351
+ a = crypto.getRandomValues(new Uint32Array(k *= 2));
352
+ for (; i < k;) {
353
+ v = a[i] * 131072 + (a[i + 1] >>> 11);
354
+ if (v >= 9e15) {
355
+ b = crypto.getRandomValues(new Uint32Array(2));
356
+ a[i] = b[0];
357
+ a[i + 1] = b[1];
358
+ } else {
359
+ c.push(v % 0x5af3107a4000);
360
+ i += 2;
361
+ }
362
+ }
363
+ i = k / 2;
364
+ } else if (crypto.randomBytes) {
365
+ a = crypto.randomBytes(k *= 7);
366
+ for (; i < k;) {
367
+ v = (a[i] & 31) * 281474976710656 + a[i + 1] * 1099511627776 + a[i + 2] * 4294967296 + a[i + 3] * 16777216 + (a[i + 4] << 16) + (a[i + 5] << 8) + a[i + 6];
368
+ if (v >= 9e15) crypto.randomBytes(7).copy(a, i);
369
+ else {
370
+ c.push(v % 0x5af3107a4000);
371
+ i += 7;
372
+ }
373
+ }
374
+ i = k / 7;
375
+ } else {
376
+ CRYPTO = false;
377
+ throw Error(bignumberError + "crypto unavailable");
378
+ }
379
+ if (!CRYPTO) for (; i < k;) {
380
+ v = random53bitInt();
381
+ if (v < 9e15) c[i++] = v % 0x5af3107a4000;
382
+ }
383
+ k = c[--i];
384
+ dp %= LOG_BASE;
385
+ if (k && dp) {
386
+ v = POWS_TEN[LOG_BASE - dp];
387
+ c[i] = mathfloor(k / v) * v;
388
+ }
389
+ for (; c[i] === 0; c.pop(), i--);
390
+ if (i < 0) c = [e = 0];
391
+ else {
392
+ for (e = -1; c[0] === 0; c.splice(0, 1), e -= LOG_BASE);
393
+ for (i = 1, v = c[0]; v >= 10; v /= 10, i++);
394
+ if (i < LOG_BASE) e -= LOG_BASE - i;
395
+ }
396
+ rand.e = e;
397
+ rand.c = c;
398
+ return rand;
399
+ };
400
+ })();
401
+ BigNumber$1.sum = function() {
402
+ var i = 1, args = arguments, sum = new BigNumber$1(args[0]);
403
+ for (; i < args.length;) sum = sum.plus(args[i++]);
404
+ return sum;
405
+ };
406
+ convertBase = (function() {
407
+ var decimal = "0123456789";
408
+ function toBaseOut(str, baseIn, baseOut, alphabet) {
409
+ var j, arr = [0], arrL, i = 0, len = str.length;
410
+ for (; i < len;) {
411
+ for (arrL = arr.length; arrL--; arr[arrL] *= baseIn);
412
+ arr[0] += alphabet.indexOf(str.charAt(i++));
413
+ for (j = 0; j < arr.length; j++) if (arr[j] > baseOut - 1) {
414
+ if (arr[j + 1] == null) arr[j + 1] = 0;
415
+ arr[j + 1] += arr[j] / baseOut | 0;
416
+ arr[j] %= baseOut;
417
+ }
418
+ }
419
+ return arr.reverse();
420
+ }
421
+ return function(str, baseIn, baseOut, sign, callerIsToString) {
422
+ var alphabet, d, e, k, r, x, xc, y, i = str.indexOf("."), dp = DECIMAL_PLACES, rm = ROUNDING_MODE;
423
+ if (i >= 0) {
424
+ k = POW_PRECISION;
425
+ POW_PRECISION = 0;
426
+ str = str.replace(".", "");
427
+ y = new BigNumber$1(baseIn);
428
+ x = y.pow(str.length - i);
429
+ POW_PRECISION = k;
430
+ y.c = toBaseOut(toFixedPoint(coeffToString(x.c), x.e, "0"), 10, baseOut, decimal);
431
+ y.e = y.c.length;
432
+ }
433
+ xc = toBaseOut(str, baseIn, baseOut, callerIsToString ? (alphabet = ALPHABET, decimal) : (alphabet = decimal, ALPHABET));
434
+ e = k = xc.length;
435
+ for (; xc[--k] == 0; xc.pop());
436
+ if (!xc[0]) return alphabet.charAt(0);
437
+ if (i < 0) --e;
438
+ else {
439
+ x.c = xc;
440
+ x.e = e;
441
+ x.s = sign;
442
+ x = div(x, y, dp, rm, baseOut);
443
+ xc = x.c;
444
+ r = x.r;
445
+ e = x.e;
446
+ }
447
+ d = e + dp + 1;
448
+ i = xc[d];
449
+ k = baseOut / 2;
450
+ r = r || d < 0 || xc[d + 1] != null;
451
+ r = rm < 4 ? (i != null || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : i > k || i == k && (rm == 4 || r || rm == 6 && xc[d - 1] & 1 || rm == (x.s < 0 ? 8 : 7));
452
+ if (d < 1 || !xc[0]) str = r ? toFixedPoint(alphabet.charAt(1), -dp, alphabet.charAt(0)) : alphabet.charAt(0);
453
+ else {
454
+ xc.length = d;
455
+ if (r) for (--baseOut; ++xc[--d] > baseOut;) {
456
+ xc[d] = 0;
457
+ if (!d) {
458
+ ++e;
459
+ xc = [1].concat(xc);
460
+ }
461
+ }
462
+ for (k = xc.length; !xc[--k];);
463
+ for (i = 0, str = ""; i <= k; str += alphabet.charAt(xc[i++]));
464
+ str = toFixedPoint(str, e, alphabet.charAt(0));
465
+ }
466
+ return str;
467
+ };
468
+ })();
469
+ div = (function() {
470
+ function multiply(x, k, base) {
471
+ var m, temp, xlo, xhi, carry = 0, i = x.length, klo = k % SQRT_BASE, khi = k / SQRT_BASE | 0;
472
+ for (x = x.slice(); i--;) {
473
+ xlo = x[i] % SQRT_BASE;
474
+ xhi = x[i] / SQRT_BASE | 0;
475
+ m = khi * xlo + xhi * klo;
476
+ temp = klo * xlo + m % SQRT_BASE * SQRT_BASE + carry;
477
+ carry = (temp / base | 0) + (m / SQRT_BASE | 0) + khi * xhi;
478
+ x[i] = temp % base;
479
+ }
480
+ if (carry) x = [carry].concat(x);
481
+ return x;
482
+ }
483
+ function compare$1(a, b, aL, bL) {
484
+ var i, cmp;
485
+ if (aL != bL) cmp = aL > bL ? 1 : -1;
486
+ else for (i = cmp = 0; i < aL; i++) if (a[i] != b[i]) {
487
+ cmp = a[i] > b[i] ? 1 : -1;
488
+ break;
489
+ }
490
+ return cmp;
491
+ }
492
+ function subtract(a, b, aL, base) {
493
+ var i = 0;
494
+ for (; aL--;) {
495
+ a[aL] -= i;
496
+ i = a[aL] < b[aL] ? 1 : 0;
497
+ a[aL] = i * base + a[aL] - b[aL];
498
+ }
499
+ for (; !a[0] && a.length > 1; a.splice(0, 1));
500
+ }
501
+ return function(x, y, dp, rm, base) {
502
+ var cmp, e, i, more, n, prod, prodL, q, qc, rem, remL, rem0, xi, xL, yc0, yL, yz, s = x.s == y.s ? 1 : -1, xc = x.c, yc = y.c;
503
+ if (!xc || !xc[0] || !yc || !yc[0]) return new BigNumber$1(!x.s || !y.s || (xc ? yc && xc[0] == yc[0] : !yc) ? NaN : xc && xc[0] == 0 || !yc ? s * 0 : s / 0);
504
+ q = new BigNumber$1(s);
505
+ qc = q.c = [];
506
+ e = x.e - y.e;
507
+ s = dp + e + 1;
508
+ if (!base) {
509
+ base = BASE;
510
+ e = bitFloor(x.e / LOG_BASE) - bitFloor(y.e / LOG_BASE);
511
+ s = s / LOG_BASE | 0;
512
+ }
513
+ for (i = 0; yc[i] == (xc[i] || 0); i++);
514
+ if (yc[i] > (xc[i] || 0)) e--;
515
+ if (s < 0) {
516
+ qc.push(1);
517
+ more = true;
518
+ } else {
519
+ xL = xc.length;
520
+ yL = yc.length;
521
+ i = 0;
522
+ s += 2;
523
+ n = mathfloor(base / (yc[0] + 1));
524
+ if (n > 1) {
525
+ yc = multiply(yc, n, base);
526
+ xc = multiply(xc, n, base);
527
+ yL = yc.length;
528
+ xL = xc.length;
529
+ }
530
+ xi = yL;
531
+ rem = xc.slice(0, yL);
532
+ remL = rem.length;
533
+ for (; remL < yL; rem[remL++] = 0);
534
+ yz = yc.slice();
535
+ yz = [0].concat(yz);
536
+ yc0 = yc[0];
537
+ if (yc[1] >= base / 2) yc0++;
538
+ do {
539
+ n = 0;
540
+ cmp = compare$1(yc, rem, yL, remL);
541
+ if (cmp < 0) {
542
+ rem0 = rem[0];
543
+ if (yL != remL) rem0 = rem0 * base + (rem[1] || 0);
544
+ n = mathfloor(rem0 / yc0);
545
+ if (n > 1) {
546
+ if (n >= base) n = base - 1;
547
+ prod = multiply(yc, n, base);
548
+ prodL = prod.length;
549
+ remL = rem.length;
550
+ while (compare$1(prod, rem, prodL, remL) == 1) {
551
+ n--;
552
+ subtract(prod, yL < prodL ? yz : yc, prodL, base);
553
+ prodL = prod.length;
554
+ cmp = 1;
555
+ }
556
+ } else {
557
+ if (n == 0) cmp = n = 1;
558
+ prod = yc.slice();
559
+ prodL = prod.length;
560
+ }
561
+ if (prodL < remL) prod = [0].concat(prod);
562
+ subtract(rem, prod, remL, base);
563
+ remL = rem.length;
564
+ if (cmp == -1) while (compare$1(yc, rem, yL, remL) < 1) {
565
+ n++;
566
+ subtract(rem, yL < remL ? yz : yc, remL, base);
567
+ remL = rem.length;
568
+ }
569
+ } else if (cmp === 0) {
570
+ n++;
571
+ rem = [0];
572
+ }
573
+ qc[i++] = n;
574
+ if (rem[0]) rem[remL++] = xc[xi] || 0;
575
+ else {
576
+ rem = [xc[xi]];
577
+ remL = 1;
578
+ }
579
+ } while ((xi++ < xL || rem[0] != null) && s--);
580
+ more = rem[0] != null;
581
+ if (!qc[0]) qc.splice(0, 1);
582
+ }
583
+ if (base == BASE) {
584
+ for (i = 1, s = qc[0]; s >= 10; s /= 10, i++);
585
+ round(q, dp + (q.e = i + e * LOG_BASE - 1) + 1, rm, more);
586
+ } else {
587
+ q.e = e;
588
+ q.r = +more;
589
+ }
590
+ return q;
591
+ };
592
+ })();
593
+ function format(n, i, rm, id) {
594
+ var c0, e, ne, len, str;
595
+ if (rm == null) rm = ROUNDING_MODE;
596
+ else intCheck(rm, 0, 8);
597
+ if (!n.c) return n.toString();
598
+ c0 = n.c[0];
599
+ ne = n.e;
600
+ if (i == null) {
601
+ str = coeffToString(n.c);
602
+ str = id == 1 || id == 2 && (ne <= TO_EXP_NEG || ne >= TO_EXP_POS) ? toExponential(str, ne) : toFixedPoint(str, ne, "0");
603
+ } else {
604
+ n = round(new BigNumber$1(n), i, rm);
605
+ e = n.e;
606
+ str = coeffToString(n.c);
607
+ len = str.length;
608
+ if (id == 1 || id == 2 && (i <= e || e <= TO_EXP_NEG)) {
609
+ for (; len < i; str += "0", len++);
610
+ str = toExponential(str, e);
611
+ } else {
612
+ i -= ne;
613
+ str = toFixedPoint(str, e, "0");
614
+ if (e + 1 > len) {
615
+ if (--i > 0) for (str += "."; i--; str += "0");
616
+ } else {
617
+ i += e - len;
618
+ if (i > 0) {
619
+ if (e + 1 == len) str += ".";
620
+ for (; i--; str += "0");
621
+ }
622
+ }
623
+ }
624
+ }
625
+ return n.s < 0 && c0 ? "-" + str : str;
626
+ }
627
+ function maxOrMin(args, n) {
628
+ var k, y, i = 1, x = new BigNumber$1(args[0]);
629
+ for (; i < args.length; i++) {
630
+ y = new BigNumber$1(args[i]);
631
+ if (!y.s || (k = compare(x, y)) === n || k === 0 && x.s === n) x = y;
632
+ }
633
+ return x;
634
+ }
635
+ function normalise(n, c, e) {
636
+ var i = 1, j = c.length;
637
+ for (; !c[--j]; c.pop());
638
+ for (j = c[0]; j >= 10; j /= 10, i++);
639
+ if ((e = i + e * LOG_BASE - 1) > MAX_EXP) n.c = n.e = null;
640
+ else if (e < MIN_EXP) n.c = [n.e = 0];
641
+ else {
642
+ n.e = e;
643
+ n.c = c;
644
+ }
645
+ return n;
646
+ }
647
+ parseNumeric = (function() {
648
+ var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i, dotAfter = /^([^.]+)\.$/, dotBefore = /^\.([^.]+)$/, isInfinityOrNaN = /^-?(Infinity|NaN)$/, whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
649
+ return function(x, str, isNum, b) {
650
+ var base, s = isNum ? str : str.replace(whitespaceOrPlus, "");
651
+ if (isInfinityOrNaN.test(s)) x.s = isNaN(s) ? null : s < 0 ? -1 : 1;
652
+ else {
653
+ if (!isNum) {
654
+ s = s.replace(basePrefix, function(m, p1, p2) {
655
+ base = (p2 = p2.toLowerCase()) == "x" ? 16 : p2 == "b" ? 2 : 8;
656
+ return !b || b == base ? p1 : m;
657
+ });
658
+ if (b) {
659
+ base = b;
660
+ s = s.replace(dotAfter, "$1").replace(dotBefore, "0.$1");
661
+ }
662
+ if (str != s) return new BigNumber$1(s, base);
663
+ }
664
+ if (BigNumber$1.DEBUG) throw Error(bignumberError + "Not a" + (b ? " base " + b : "") + " number: " + str);
665
+ x.s = null;
666
+ }
667
+ x.c = x.e = null;
668
+ };
669
+ })();
670
+ function round(x, sd, rm, r) {
671
+ var d, i, j, k, n, ni, rd, xc = x.c, pows10 = POWS_TEN;
672
+ if (xc) {
673
+ out: {
674
+ for (d = 1, k = xc[0]; k >= 10; k /= 10, d++);
675
+ i = sd - d;
676
+ if (i < 0) {
677
+ i += LOG_BASE;
678
+ j = sd;
679
+ n = xc[ni = 0];
680
+ rd = mathfloor(n / pows10[d - j - 1] % 10);
681
+ } else {
682
+ ni = mathceil((i + 1) / LOG_BASE);
683
+ if (ni >= xc.length) if (r) {
684
+ for (; xc.length <= ni; xc.push(0));
685
+ n = rd = 0;
686
+ d = 1;
687
+ i %= LOG_BASE;
688
+ j = i - LOG_BASE + 1;
689
+ } else break out;
690
+ else {
691
+ n = k = xc[ni];
692
+ for (d = 1; k >= 10; k /= 10, d++);
693
+ i %= LOG_BASE;
694
+ j = i - LOG_BASE + d;
695
+ rd = j < 0 ? 0 : mathfloor(n / pows10[d - j - 1] % 10);
696
+ }
697
+ }
698
+ r = r || sd < 0 || xc[ni + 1] != null || (j < 0 ? n : n % pows10[d - j - 1]);
699
+ r = rm < 4 ? (rd || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : rd > 5 || rd == 5 && (rm == 4 || r || rm == 6 && (i > 0 ? j > 0 ? n / pows10[d - j] : 0 : xc[ni - 1]) % 10 & 1 || rm == (x.s < 0 ? 8 : 7));
700
+ if (sd < 1 || !xc[0]) {
701
+ xc.length = 0;
702
+ if (r) {
703
+ sd -= x.e + 1;
704
+ xc[0] = pows10[(LOG_BASE - sd % LOG_BASE) % LOG_BASE];
705
+ x.e = -sd || 0;
706
+ } else xc[0] = x.e = 0;
707
+ return x;
708
+ }
709
+ if (i == 0) {
710
+ xc.length = ni;
711
+ k = 1;
712
+ ni--;
713
+ } else {
714
+ xc.length = ni + 1;
715
+ k = pows10[LOG_BASE - i];
716
+ xc[ni] = j > 0 ? mathfloor(n / pows10[d - j] % pows10[j]) * k : 0;
717
+ }
718
+ if (r) for (;;) if (ni == 0) {
719
+ for (i = 1, j = xc[0]; j >= 10; j /= 10, i++);
720
+ j = xc[0] += k;
721
+ for (k = 1; j >= 10; j /= 10, k++);
722
+ if (i != k) {
723
+ x.e++;
724
+ if (xc[0] == BASE) xc[0] = 1;
725
+ }
726
+ break;
727
+ } else {
728
+ xc[ni] += k;
729
+ if (xc[ni] != BASE) break;
730
+ xc[ni--] = 0;
731
+ k = 1;
732
+ }
733
+ for (i = xc.length; xc[--i] === 0; xc.pop());
734
+ }
735
+ if (x.e > MAX_EXP) x.c = x.e = null;
736
+ else if (x.e < MIN_EXP) x.c = [x.e = 0];
737
+ }
738
+ return x;
739
+ }
740
+ function valueOf(n) {
741
+ var str, e = n.e;
742
+ if (e === null) return n.toString();
743
+ str = coeffToString(n.c);
744
+ str = e <= TO_EXP_NEG || e >= TO_EXP_POS ? toExponential(str, e) : toFixedPoint(str, e, "0");
745
+ return n.s < 0 ? "-" + str : str;
746
+ }
747
+ P.absoluteValue = P.abs = function() {
748
+ var x = new BigNumber$1(this);
749
+ if (x.s < 0) x.s = 1;
750
+ return x;
751
+ };
752
+ P.comparedTo = function(y, b) {
753
+ return compare(this, new BigNumber$1(y, b));
754
+ };
755
+ P.decimalPlaces = P.dp = function(dp, rm) {
756
+ var c, n, v, x = this;
757
+ if (dp != null) {
758
+ intCheck(dp, 0, MAX);
759
+ if (rm == null) rm = ROUNDING_MODE;
760
+ else intCheck(rm, 0, 8);
761
+ return round(new BigNumber$1(x), dp + x.e + 1, rm);
762
+ }
763
+ if (!(c = x.c)) return null;
764
+ n = ((v = c.length - 1) - bitFloor(this.e / LOG_BASE)) * LOG_BASE;
765
+ if (v = c[v]) for (; v % 10 == 0; v /= 10, n--);
766
+ if (n < 0) n = 0;
767
+ return n;
768
+ };
769
+ P.dividedBy = P.div = function(y, b) {
770
+ return div(this, new BigNumber$1(y, b), DECIMAL_PLACES, ROUNDING_MODE);
771
+ };
772
+ P.dividedToIntegerBy = P.idiv = function(y, b) {
773
+ return div(this, new BigNumber$1(y, b), 0, 1);
774
+ };
775
+ P.exponentiatedBy = P.pow = function(n, m) {
776
+ var half, isModExp, i, k, more, nIsBig, nIsNeg, nIsOdd, y, x = this;
777
+ n = new BigNumber$1(n);
778
+ if (n.c && !n.isInteger()) throw Error(bignumberError + "Exponent not an integer: " + valueOf(n));
779
+ if (m != null) m = new BigNumber$1(m);
780
+ nIsBig = n.e > 14;
781
+ if (!x.c || !x.c[0] || x.c[0] == 1 && !x.e && x.c.length == 1 || !n.c || !n.c[0]) {
782
+ y = new BigNumber$1(Math.pow(+valueOf(x), nIsBig ? n.s * (2 - isOdd(n)) : +valueOf(n)));
783
+ return m ? y.mod(m) : y;
784
+ }
785
+ nIsNeg = n.s < 0;
786
+ if (m) {
787
+ if (m.c ? !m.c[0] : !m.s) return new BigNumber$1(NaN);
788
+ isModExp = !nIsNeg && x.isInteger() && m.isInteger();
789
+ if (isModExp) x = x.mod(m);
790
+ } else if (n.e > 9 && (x.e > 0 || x.e < -1 || (x.e == 0 ? x.c[0] > 1 || nIsBig && x.c[1] >= 24e7 : x.c[0] < 8e13 || nIsBig && x.c[0] <= 9999975e7))) {
791
+ k = x.s < 0 && isOdd(n) ? -0 : 0;
792
+ if (x.e > -1) k = 1 / k;
793
+ return new BigNumber$1(nIsNeg ? 1 / k : k);
794
+ } else if (POW_PRECISION) k = mathceil(POW_PRECISION / LOG_BASE + 2);
795
+ if (nIsBig) {
796
+ half = new BigNumber$1(.5);
797
+ if (nIsNeg) n.s = 1;
798
+ nIsOdd = isOdd(n);
799
+ } else {
800
+ i = Math.abs(+valueOf(n));
801
+ nIsOdd = i % 2;
802
+ }
803
+ y = new BigNumber$1(ONE);
804
+ for (;;) {
805
+ if (nIsOdd) {
806
+ y = y.times(x);
807
+ if (!y.c) break;
808
+ if (k) {
809
+ if (y.c.length > k) y.c.length = k;
810
+ } else if (isModExp) y = y.mod(m);
811
+ }
812
+ if (i) {
813
+ i = mathfloor(i / 2);
814
+ if (i === 0) break;
815
+ nIsOdd = i % 2;
816
+ } else {
817
+ n = n.times(half);
818
+ round(n, n.e + 1, 1);
819
+ if (n.e > 14) nIsOdd = isOdd(n);
820
+ else {
821
+ i = +valueOf(n);
822
+ if (i === 0) break;
823
+ nIsOdd = i % 2;
824
+ }
825
+ }
826
+ x = x.times(x);
827
+ if (k) {
828
+ if (x.c && x.c.length > k) x.c.length = k;
829
+ } else if (isModExp) x = x.mod(m);
830
+ }
831
+ if (isModExp) return y;
832
+ if (nIsNeg) y = ONE.div(y);
833
+ return m ? y.mod(m) : k ? round(y, POW_PRECISION, ROUNDING_MODE, more) : y;
834
+ };
835
+ P.integerValue = function(rm) {
836
+ var n = new BigNumber$1(this);
837
+ if (rm == null) rm = ROUNDING_MODE;
838
+ else intCheck(rm, 0, 8);
839
+ return round(n, n.e + 1, rm);
840
+ };
841
+ P.isEqualTo = P.eq = function(y, b) {
842
+ return compare(this, new BigNumber$1(y, b)) === 0;
843
+ };
844
+ P.isFinite = function() {
845
+ return !!this.c;
846
+ };
847
+ P.isGreaterThan = P.gt = function(y, b) {
848
+ return compare(this, new BigNumber$1(y, b)) > 0;
849
+ };
850
+ P.isGreaterThanOrEqualTo = P.gte = function(y, b) {
851
+ return (b = compare(this, new BigNumber$1(y, b))) === 1 || b === 0;
852
+ };
853
+ P.isInteger = function() {
854
+ return !!this.c && bitFloor(this.e / LOG_BASE) > this.c.length - 2;
855
+ };
856
+ P.isLessThan = P.lt = function(y, b) {
857
+ return compare(this, new BigNumber$1(y, b)) < 0;
858
+ };
859
+ P.isLessThanOrEqualTo = P.lte = function(y, b) {
860
+ return (b = compare(this, new BigNumber$1(y, b))) === -1 || b === 0;
861
+ };
862
+ P.isNaN = function() {
863
+ return !this.s;
864
+ };
865
+ P.isNegative = function() {
866
+ return this.s < 0;
867
+ };
868
+ P.isPositive = function() {
869
+ return this.s > 0;
870
+ };
871
+ P.isZero = function() {
872
+ return !!this.c && this.c[0] == 0;
873
+ };
874
+ P.minus = function(y, b) {
875
+ var i, j, t, xLTy, x = this, a = x.s;
876
+ y = new BigNumber$1(y, b);
877
+ b = y.s;
878
+ if (!a || !b) return new BigNumber$1(NaN);
879
+ if (a != b) {
880
+ y.s = -b;
881
+ return x.plus(y);
882
+ }
883
+ var xe = x.e / LOG_BASE, ye = y.e / LOG_BASE, xc = x.c, yc = y.c;
884
+ if (!xe || !ye) {
885
+ if (!xc || !yc) return xc ? (y.s = -b, y) : new BigNumber$1(yc ? x : NaN);
886
+ if (!xc[0] || !yc[0]) return yc[0] ? (y.s = -b, y) : new BigNumber$1(xc[0] ? x : ROUNDING_MODE == 3 ? -0 : 0);
887
+ }
888
+ xe = bitFloor(xe);
889
+ ye = bitFloor(ye);
890
+ xc = xc.slice();
891
+ if (a = xe - ye) {
892
+ if (xLTy = a < 0) {
893
+ a = -a;
894
+ t = xc;
895
+ } else {
896
+ ye = xe;
897
+ t = yc;
898
+ }
899
+ t.reverse();
900
+ for (b = a; b--; t.push(0));
901
+ t.reverse();
902
+ } else {
903
+ j = (xLTy = (a = xc.length) < (b = yc.length)) ? a : b;
904
+ for (a = b = 0; b < j; b++) if (xc[b] != yc[b]) {
905
+ xLTy = xc[b] < yc[b];
906
+ break;
907
+ }
908
+ }
909
+ if (xLTy) {
910
+ t = xc;
911
+ xc = yc;
912
+ yc = t;
913
+ y.s = -y.s;
914
+ }
915
+ b = (j = yc.length) - (i = xc.length);
916
+ if (b > 0) for (; b--; xc[i++] = 0);
917
+ b = BASE - 1;
918
+ for (; j > a;) {
919
+ if (xc[--j] < yc[j]) {
920
+ for (i = j; i && !xc[--i]; xc[i] = b);
921
+ --xc[i];
922
+ xc[j] += BASE;
923
+ }
924
+ xc[j] -= yc[j];
925
+ }
926
+ for (; xc[0] == 0; xc.splice(0, 1), --ye);
927
+ if (!xc[0]) {
928
+ y.s = ROUNDING_MODE == 3 ? -1 : 1;
929
+ y.c = [y.e = 0];
930
+ return y;
931
+ }
932
+ return normalise(y, xc, ye);
933
+ };
934
+ P.modulo = P.mod = function(y, b) {
935
+ var q, s, x = this;
936
+ y = new BigNumber$1(y, b);
937
+ if (!x.c || !y.s || y.c && !y.c[0]) return new BigNumber$1(NaN);
938
+ else if (!y.c || x.c && !x.c[0]) return new BigNumber$1(x);
939
+ if (MODULO_MODE == 9) {
940
+ s = y.s;
941
+ y.s = 1;
942
+ q = div(x, y, 0, 3);
943
+ y.s = s;
944
+ q.s *= s;
945
+ } else q = div(x, y, 0, MODULO_MODE);
946
+ y = x.minus(q.times(y));
947
+ if (!y.c[0] && MODULO_MODE == 1) y.s = x.s;
948
+ return y;
949
+ };
950
+ P.multipliedBy = P.times = function(y, b) {
951
+ var c, e, i, j, k, m, xcL, xlo, xhi, ycL, ylo, yhi, zc, base, sqrtBase, x = this, xc = x.c, yc = (y = new BigNumber$1(y, b)).c;
952
+ if (!xc || !yc || !xc[0] || !yc[0]) {
953
+ if (!x.s || !y.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc) y.c = y.e = y.s = null;
954
+ else {
955
+ y.s *= x.s;
956
+ if (!xc || !yc) y.c = y.e = null;
957
+ else {
958
+ y.c = [0];
959
+ y.e = 0;
960
+ }
961
+ }
962
+ return y;
963
+ }
964
+ e = bitFloor(x.e / LOG_BASE) + bitFloor(y.e / LOG_BASE);
965
+ y.s *= x.s;
966
+ xcL = xc.length;
967
+ ycL = yc.length;
968
+ if (xcL < ycL) {
969
+ zc = xc;
970
+ xc = yc;
971
+ yc = zc;
972
+ i = xcL;
973
+ xcL = ycL;
974
+ ycL = i;
975
+ }
976
+ for (i = xcL + ycL, zc = []; i--; zc.push(0));
977
+ base = BASE;
978
+ sqrtBase = SQRT_BASE;
979
+ for (i = ycL; --i >= 0;) {
980
+ c = 0;
981
+ ylo = yc[i] % sqrtBase;
982
+ yhi = yc[i] / sqrtBase | 0;
983
+ for (k = xcL, j = i + k; j > i;) {
984
+ xlo = xc[--k] % sqrtBase;
985
+ xhi = xc[k] / sqrtBase | 0;
986
+ m = yhi * xlo + xhi * ylo;
987
+ xlo = ylo * xlo + m % sqrtBase * sqrtBase + zc[j] + c;
988
+ c = (xlo / base | 0) + (m / sqrtBase | 0) + yhi * xhi;
989
+ zc[j--] = xlo % base;
990
+ }
991
+ zc[j] = c;
992
+ }
993
+ if (c) ++e;
994
+ else zc.splice(0, 1);
995
+ return normalise(y, zc, e);
996
+ };
997
+ P.negated = function() {
998
+ var x = new BigNumber$1(this);
999
+ x.s = -x.s || null;
1000
+ return x;
1001
+ };
1002
+ P.plus = function(y, b) {
1003
+ var t, x = this, a = x.s;
1004
+ y = new BigNumber$1(y, b);
1005
+ b = y.s;
1006
+ if (!a || !b) return new BigNumber$1(NaN);
1007
+ if (a != b) {
1008
+ y.s = -b;
1009
+ return x.minus(y);
1010
+ }
1011
+ var xe = x.e / LOG_BASE, ye = y.e / LOG_BASE, xc = x.c, yc = y.c;
1012
+ if (!xe || !ye) {
1013
+ if (!xc || !yc) return new BigNumber$1(a / 0);
1014
+ if (!xc[0] || !yc[0]) return yc[0] ? y : new BigNumber$1(xc[0] ? x : a * 0);
1015
+ }
1016
+ xe = bitFloor(xe);
1017
+ ye = bitFloor(ye);
1018
+ xc = xc.slice();
1019
+ if (a = xe - ye) {
1020
+ if (a > 0) {
1021
+ ye = xe;
1022
+ t = yc;
1023
+ } else {
1024
+ a = -a;
1025
+ t = xc;
1026
+ }
1027
+ t.reverse();
1028
+ for (; a--; t.push(0));
1029
+ t.reverse();
1030
+ }
1031
+ a = xc.length;
1032
+ b = yc.length;
1033
+ if (a - b < 0) {
1034
+ t = yc;
1035
+ yc = xc;
1036
+ xc = t;
1037
+ b = a;
1038
+ }
1039
+ for (a = 0; b;) {
1040
+ a = (xc[--b] = xc[b] + yc[b] + a) / BASE | 0;
1041
+ xc[b] = BASE === xc[b] ? 0 : xc[b] % BASE;
1042
+ }
1043
+ if (a) {
1044
+ xc = [a].concat(xc);
1045
+ ++ye;
1046
+ }
1047
+ return normalise(y, xc, ye);
1048
+ };
1049
+ P.precision = P.sd = function(sd, rm) {
1050
+ var c, n, v, x = this;
1051
+ if (sd != null && sd !== !!sd) {
1052
+ intCheck(sd, 1, MAX);
1053
+ if (rm == null) rm = ROUNDING_MODE;
1054
+ else intCheck(rm, 0, 8);
1055
+ return round(new BigNumber$1(x), sd, rm);
1056
+ }
1057
+ if (!(c = x.c)) return null;
1058
+ v = c.length - 1;
1059
+ n = v * LOG_BASE + 1;
1060
+ if (v = c[v]) {
1061
+ for (; v % 10 == 0; v /= 10, n--);
1062
+ for (v = c[0]; v >= 10; v /= 10, n++);
1063
+ }
1064
+ if (sd && x.e + 1 > n) n = x.e + 1;
1065
+ return n;
1066
+ };
1067
+ P.shiftedBy = function(k) {
1068
+ intCheck(k, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);
1069
+ return this.times("1e" + k);
1070
+ };
1071
+ P.squareRoot = P.sqrt = function() {
1072
+ var m, n, r, rep, t, x = this, c = x.c, s = x.s, e = x.e, dp = DECIMAL_PLACES + 4, half = new BigNumber$1("0.5");
1073
+ if (s !== 1 || !c || !c[0]) return new BigNumber$1(!s || s < 0 && (!c || c[0]) ? NaN : c ? x : Infinity);
1074
+ s = Math.sqrt(+valueOf(x));
1075
+ if (s == 0 || s == Infinity) {
1076
+ n = coeffToString(c);
1077
+ if ((n.length + e) % 2 == 0) n += "0";
1078
+ s = Math.sqrt(+n);
1079
+ e = bitFloor((e + 1) / 2) - (e < 0 || e % 2);
1080
+ if (s == Infinity) n = "5e" + e;
1081
+ else {
1082
+ n = s.toExponential();
1083
+ n = n.slice(0, n.indexOf("e") + 1) + e;
1084
+ }
1085
+ r = new BigNumber$1(n);
1086
+ } else r = new BigNumber$1(s + "");
1087
+ if (r.c[0]) {
1088
+ e = r.e;
1089
+ s = e + dp;
1090
+ if (s < 3) s = 0;
1091
+ for (;;) {
1092
+ t = r;
1093
+ r = half.times(t.plus(div(x, t, dp, 1)));
1094
+ if (coeffToString(t.c).slice(0, s) === (n = coeffToString(r.c)).slice(0, s)) {
1095
+ if (r.e < e) --s;
1096
+ n = n.slice(s - 3, s + 1);
1097
+ if (n == "9999" || !rep && n == "4999") {
1098
+ if (!rep) {
1099
+ round(t, t.e + DECIMAL_PLACES + 2, 0);
1100
+ if (t.times(t).eq(x)) {
1101
+ r = t;
1102
+ break;
1103
+ }
1104
+ }
1105
+ dp += 4;
1106
+ s += 4;
1107
+ rep = 1;
1108
+ } else {
1109
+ if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
1110
+ round(r, r.e + DECIMAL_PLACES + 2, 1);
1111
+ m = !r.times(r).eq(x);
1112
+ }
1113
+ break;
1114
+ }
1115
+ }
1116
+ }
1117
+ }
1118
+ return round(r, r.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m);
1119
+ };
1120
+ P.toExponential = function(dp, rm) {
1121
+ if (dp != null) {
1122
+ intCheck(dp, 0, MAX);
1123
+ dp++;
1124
+ }
1125
+ return format(this, dp, rm, 1);
1126
+ };
1127
+ P.toFixed = function(dp, rm) {
1128
+ if (dp != null) {
1129
+ intCheck(dp, 0, MAX);
1130
+ dp = dp + this.e + 1;
1131
+ }
1132
+ return format(this, dp, rm);
1133
+ };
1134
+ P.toFormat = function(dp, rm, format$1) {
1135
+ var str, x = this;
1136
+ if (format$1 == null) if (dp != null && rm && typeof rm == "object") {
1137
+ format$1 = rm;
1138
+ rm = null;
1139
+ } else if (dp && typeof dp == "object") {
1140
+ format$1 = dp;
1141
+ dp = rm = null;
1142
+ } else format$1 = FORMAT;
1143
+ else if (typeof format$1 != "object") throw Error(bignumberError + "Argument not an object: " + format$1);
1144
+ str = x.toFixed(dp, rm);
1145
+ if (x.c) {
1146
+ var i, arr = str.split("."), g1 = +format$1.groupSize, g2 = +format$1.secondaryGroupSize, groupSeparator = format$1.groupSeparator || "", intPart = arr[0], fractionPart = arr[1], isNeg = x.s < 0, intDigits = isNeg ? intPart.slice(1) : intPart, len = intDigits.length;
1147
+ if (g2) {
1148
+ i = g1;
1149
+ g1 = g2;
1150
+ g2 = i;
1151
+ len -= i;
1152
+ }
1153
+ if (g1 > 0 && len > 0) {
1154
+ i = len % g1 || g1;
1155
+ intPart = intDigits.substr(0, i);
1156
+ for (; i < len; i += g1) intPart += groupSeparator + intDigits.substr(i, g1);
1157
+ if (g2 > 0) intPart += groupSeparator + intDigits.slice(i);
1158
+ if (isNeg) intPart = "-" + intPart;
1159
+ }
1160
+ str = fractionPart ? intPart + (format$1.decimalSeparator || "") + ((g2 = +format$1.fractionGroupSize) ? fractionPart.replace(new RegExp("\\d{" + g2 + "}\\B", "g"), "$&" + (format$1.fractionGroupSeparator || "")) : fractionPart) : intPart;
1161
+ }
1162
+ return (format$1.prefix || "") + str + (format$1.suffix || "");
1163
+ };
1164
+ P.toFraction = function(md) {
1165
+ var d, d0, d1, d2, e, exp, n, n0, n1, q, r, s, x = this, xc = x.c;
1166
+ if (md != null) {
1167
+ n = new BigNumber$1(md);
1168
+ if (!n.isInteger() && (n.c || n.s !== 1) || n.lt(ONE)) throw Error(bignumberError + "Argument " + (n.isInteger() ? "out of range: " : "not an integer: ") + valueOf(n));
1169
+ }
1170
+ if (!xc) return new BigNumber$1(x);
1171
+ d = new BigNumber$1(ONE);
1172
+ n1 = d0 = new BigNumber$1(ONE);
1173
+ d1 = n0 = new BigNumber$1(ONE);
1174
+ s = coeffToString(xc);
1175
+ e = d.e = s.length - x.e - 1;
1176
+ d.c[0] = POWS_TEN[(exp = e % LOG_BASE) < 0 ? LOG_BASE + exp : exp];
1177
+ md = !md || n.comparedTo(d) > 0 ? e > 0 ? d : n1 : n;
1178
+ exp = MAX_EXP;
1179
+ MAX_EXP = Infinity;
1180
+ n = new BigNumber$1(s);
1181
+ n0.c[0] = 0;
1182
+ for (;;) {
1183
+ q = div(n, d, 0, 1);
1184
+ d2 = d0.plus(q.times(d1));
1185
+ if (d2.comparedTo(md) == 1) break;
1186
+ d0 = d1;
1187
+ d1 = d2;
1188
+ n1 = n0.plus(q.times(d2 = n1));
1189
+ n0 = d2;
1190
+ d = n.minus(q.times(d2 = d));
1191
+ n = d2;
1192
+ }
1193
+ d2 = div(md.minus(d0), d1, 0, 1);
1194
+ n0 = n0.plus(d2.times(n1));
1195
+ d0 = d0.plus(d2.times(d1));
1196
+ n0.s = n1.s = x.s;
1197
+ e = e * 2;
1198
+ r = div(n1, d1, e, ROUNDING_MODE).minus(x).abs().comparedTo(div(n0, d0, e, ROUNDING_MODE).minus(x).abs()) < 1 ? [n1, d1] : [n0, d0];
1199
+ MAX_EXP = exp;
1200
+ return r;
1201
+ };
1202
+ P.toNumber = function() {
1203
+ return +valueOf(this);
1204
+ };
1205
+ P.toPrecision = function(sd, rm) {
1206
+ if (sd != null) intCheck(sd, 1, MAX);
1207
+ return format(this, sd, rm, 2);
1208
+ };
1209
+ P.toString = function(b) {
1210
+ var str, n = this, s = n.s, e = n.e;
1211
+ if (e === null) if (s) {
1212
+ str = "Infinity";
1213
+ if (s < 0) str = "-" + str;
1214
+ } else str = "NaN";
1215
+ else {
1216
+ if (b == null) str = e <= TO_EXP_NEG || e >= TO_EXP_POS ? toExponential(coeffToString(n.c), e) : toFixedPoint(coeffToString(n.c), e, "0");
1217
+ else if (b === 10 && alphabetHasNormalDecimalDigits) {
1218
+ n = round(new BigNumber$1(n), DECIMAL_PLACES + e + 1, ROUNDING_MODE);
1219
+ str = toFixedPoint(coeffToString(n.c), n.e, "0");
1220
+ } else {
1221
+ intCheck(b, 2, ALPHABET.length, "Base");
1222
+ str = convertBase(toFixedPoint(coeffToString(n.c), e, "0"), 10, b, s, true);
1223
+ }
1224
+ if (s < 0 && n.c[0]) str = "-" + str;
1225
+ }
1226
+ return str;
1227
+ };
1228
+ P.valueOf = P.toJSON = function() {
1229
+ return valueOf(this);
1230
+ };
1231
+ P._isBigNumber = true;
1232
+ P[Symbol.toStringTag] = "BigNumber";
1233
+ P[Symbol.for("nodejs.util.inspect.custom")] = P.valueOf;
1234
+ if (configObject != null) BigNumber$1.set(configObject);
1235
+ return BigNumber$1;
1236
+ }
1237
+ function bitFloor(n) {
1238
+ var i = n | 0;
1239
+ return n > 0 || n === i ? i : i - 1;
1240
+ }
1241
+ function coeffToString(a) {
1242
+ var s, z, i = 1, j = a.length, r = a[0] + "";
1243
+ for (; i < j;) {
1244
+ s = a[i++] + "";
1245
+ z = LOG_BASE - s.length;
1246
+ for (; z--; s = "0" + s);
1247
+ r += s;
1248
+ }
1249
+ for (j = r.length; r.charCodeAt(--j) === 48;);
1250
+ return r.slice(0, j + 1 || 1);
1251
+ }
1252
+ function compare(x, y) {
1253
+ var a, b, xc = x.c, yc = y.c, i = x.s, j = y.s, k = x.e, l = y.e;
1254
+ if (!i || !j) return null;
1255
+ a = xc && !xc[0];
1256
+ b = yc && !yc[0];
1257
+ if (a || b) return a ? b ? 0 : -j : i;
1258
+ if (i != j) return i;
1259
+ a = i < 0;
1260
+ b = k == l;
1261
+ if (!xc || !yc) return b ? 0 : !xc ^ a ? 1 : -1;
1262
+ if (!b) return k > l ^ a ? 1 : -1;
1263
+ j = (k = xc.length) < (l = yc.length) ? k : l;
1264
+ for (i = 0; i < j; i++) if (xc[i] != yc[i]) return xc[i] > yc[i] ^ a ? 1 : -1;
1265
+ return k == l ? 0 : k > l ^ a ? 1 : -1;
1266
+ }
1267
+ function intCheck(n, min, max, name) {
1268
+ if (n < min || n > max || n !== mathfloor(n)) throw Error(bignumberError + (name || "Argument") + (typeof n == "number" ? n < min || n > max ? " out of range: " : " not an integer: " : " not a primitive number: ") + String(n));
1269
+ }
1270
+ function isOdd(n) {
1271
+ var k = n.c.length - 1;
1272
+ return bitFloor(n.e / LOG_BASE) == k && n.c[k] % 2 != 0;
1273
+ }
1274
+ function toExponential(str, e) {
1275
+ return (str.length > 1 ? str.charAt(0) + "." + str.slice(1) : str) + (e < 0 ? "e" : "e+") + e;
1276
+ }
1277
+ function toFixedPoint(str, e, z) {
1278
+ var len, zs;
1279
+ if (e < 0) {
1280
+ for (zs = z + "."; ++e; zs += z);
1281
+ str = zs + str;
1282
+ } else {
1283
+ len = str.length;
1284
+ if (++e > len) {
1285
+ for (zs = z, e -= len; --e; zs += z);
1286
+ str += zs;
1287
+ } else if (e < len) str = str.slice(0, e) + "." + str.slice(e);
1288
+ }
1289
+ return str;
1290
+ }
1291
+ var BigNumber = clone();
1292
+
1293
+ //#endregion
1294
+ //#region ../../utils/dist/esm/constants-BxcSsKjm.js
1295
+ var BigNumber_default = BigNumber;
1296
+ /**
1297
+ * Converts a value to BigNumber if it isn't already
1298
+ */
1299
+ const toBigNumber = (value) => {
1300
+ if (value instanceof BigNumber) return value;
1301
+ return new BigNumber(value);
1302
+ };
1303
+ /**
1304
+ * Converts a value to Wei (multiplies by 10^decimals) default to 18 decimals
1305
+ */
1306
+ const toChainFormat = (value, decimals = 18) => {
1307
+ return toBigNumber(value).multipliedBy(new BigNumber(10).pow(decimals));
1308
+ };
1309
+ const DEFAULT_GAS_LIMIT = 4e5;
1310
+ const DEFAULT_GAS_PRICE = 16e7;
1311
+ const DEFAULT_BLOCK_TIMEOUT_HEIGHT = 120;
1312
+ const DEFAULT_BLOCK_TIME_IN_SECONDS = .7;
1313
+ /**
1314
+ * Default timeout for transaction block inclusion polling.
1315
+ *
1316
+ * Calculation: 120 blocks × 0.7 seconds/block = 84 seconds = 84,000ms
1317
+ */
1318
+ const DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS = Math.floor(DEFAULT_BLOCK_TIMEOUT_HEIGHT * DEFAULT_BLOCK_TIME_IN_SECONDS * 1e3);
1319
+ const DEFAULT_TIMESTAMP_TIMEOUT_MS = 60 * 1e3 * 3;
1320
+ const getDefaultStdFee = () => ({
1321
+ amount: [{
1322
+ amount: new BigNumber_default(DEFAULT_GAS_LIMIT).times(DEFAULT_GAS_PRICE).toString(),
1323
+ denom: "inj"
1324
+ }],
1325
+ gas: DEFAULT_GAS_LIMIT.toString(),
1326
+ payer: "",
1327
+ granter: "",
1328
+ feePayer: ""
1329
+ });
1330
+
1331
+ //#endregion
1332
+ //#region ../../../node_modules/.pnpm/@bangjelkoski+store2@2.14.3/node_modules/@bangjelkoski/store2/dist/store2.js
1333
+ var require_store2 = /* @__PURE__ */ __commonJS({ "../../../node_modules/.pnpm/@bangjelkoski+store2@2.14.3/node_modules/@bangjelkoski/store2/dist/store2.js": ((exports, module) => {
1334
+ (function(window, define) {
1335
+ var _ = {
1336
+ version: "2.14.3",
1337
+ areas: {},
1338
+ apis: {},
1339
+ nsdelim: ".",
1340
+ inherit: function(api, o) {
1341
+ for (var p in api) if (!o.hasOwnProperty(p)) Object.defineProperty(o, p, Object.getOwnPropertyDescriptor(api, p));
1342
+ return o;
1343
+ },
1344
+ stringify: function(d, fn) {
1345
+ return d === void 0 || typeof d === "function" ? d + "" : JSON.stringify(d, fn || _.replace);
1346
+ },
1347
+ parse: function(s, fn) {
1348
+ try {
1349
+ return JSON.parse(s, fn || _.revive);
1350
+ } catch (e) {
1351
+ return s;
1352
+ }
1353
+ },
1354
+ fn: function(name, fn) {
1355
+ _.storeAPI[name] = fn;
1356
+ for (var api in _.apis) _.apis[api][name] = fn;
1357
+ },
1358
+ get: function(area, key) {
1359
+ return area.getItem(key);
1360
+ },
1361
+ set: function(area, key, string) {
1362
+ area.setItem(key, string);
1363
+ },
1364
+ remove: function(area, key) {
1365
+ area.removeItem(key);
1366
+ },
1367
+ key: function(area, i) {
1368
+ return area.key(i);
1369
+ },
1370
+ length: function(area) {
1371
+ return area.length;
1372
+ },
1373
+ clear: function(area) {
1374
+ area.clear();
1375
+ },
1376
+ Store: function(id, area, namespace) {
1377
+ var store$2 = _.inherit(_.storeAPI, function(key, data, overwrite) {
1378
+ if (arguments.length === 0) return store$2.getAll();
1379
+ if (typeof data === "function") return store$2.transact(key, data, overwrite);
1380
+ if (data !== void 0) return store$2.set(key, data, overwrite);
1381
+ if (typeof key === "string" || typeof key === "number") return store$2.get(key);
1382
+ if (typeof key === "function") return store$2.each(key);
1383
+ if (!key) return store$2.clear();
1384
+ return store$2.setAll(key, data);
1385
+ });
1386
+ store$2._id = id;
1387
+ try {
1388
+ var testKey = "__store2_test";
1389
+ area.setItem(testKey, "ok");
1390
+ store$2._area = area;
1391
+ area.removeItem(testKey);
1392
+ } catch (e) {
1393
+ store$2._area = _.storage("fake");
1394
+ }
1395
+ store$2._ns = namespace || "";
1396
+ if (!_.areas[id]) _.areas[id] = store$2._area;
1397
+ if (!_.apis[store$2._ns + store$2._id]) _.apis[store$2._ns + store$2._id] = store$2;
1398
+ return store$2;
1399
+ },
1400
+ storeAPI: {
1401
+ area: function(id, area) {
1402
+ var store$2 = this[id];
1403
+ if (!store$2 || !store$2.area) {
1404
+ store$2 = _.Store(id, area, this._ns);
1405
+ if (!this[id]) this[id] = store$2;
1406
+ }
1407
+ return store$2;
1408
+ },
1409
+ namespace: function(namespace, singleArea, delim) {
1410
+ delim = delim || this._delim || _.nsdelim;
1411
+ if (!namespace) return this._ns ? this._ns.substring(0, this._ns.length - delim.length) : "";
1412
+ var ns = namespace, store$2 = this[ns];
1413
+ if (!store$2 || !store$2.namespace) {
1414
+ store$2 = _.Store(this._id, this._area, this._ns + ns + delim);
1415
+ store$2._delim = delim;
1416
+ if (!this[ns]) this[ns] = store$2;
1417
+ if (!singleArea) for (var name in _.areas) store$2.area(name, _.areas[name]);
1418
+ }
1419
+ return store$2;
1420
+ },
1421
+ isFake: function(force) {
1422
+ if (force) {
1423
+ this._real = this._area;
1424
+ this._area = _.storage("fake");
1425
+ } else if (force === false) this._area = this._real || this._area;
1426
+ return this._area.name === "fake";
1427
+ },
1428
+ toString: function() {
1429
+ return "store" + (this._ns ? "." + this.namespace() : "") + "[" + this._id + "]";
1430
+ },
1431
+ has: function(key) {
1432
+ if (this._area.has) return this._area.has(this._in(key));
1433
+ return !!(this._in(key) in this._area);
1434
+ },
1435
+ size: function() {
1436
+ return this.keys().length;
1437
+ },
1438
+ each: function(fn, fill) {
1439
+ for (var i = 0, m = _.length(this._area); i < m; i++) {
1440
+ var key = this._out(_.key(this._area, i));
1441
+ if (key !== void 0) {
1442
+ if (fn.call(this, key, this.get(key), fill) === false) break;
1443
+ }
1444
+ if (m > _.length(this._area)) {
1445
+ m--;
1446
+ i--;
1447
+ }
1448
+ }
1449
+ return fill || this;
1450
+ },
1451
+ keys: function(fillList) {
1452
+ return this.each(function(k, v, list) {
1453
+ list.push(k);
1454
+ }, fillList || []);
1455
+ },
1456
+ get: function(key, alt) {
1457
+ var s = _.get(this._area, this._in(key)), fn;
1458
+ if (typeof alt === "function") {
1459
+ fn = alt;
1460
+ alt = null;
1461
+ }
1462
+ return s !== null ? _.parse(s, fn) : alt != null ? alt : s;
1463
+ },
1464
+ getAll: function(fillObj) {
1465
+ return this.each(function(k, v, all) {
1466
+ all[k] = v;
1467
+ }, fillObj || {});
1468
+ },
1469
+ transact: function(key, fn, alt) {
1470
+ var val = this.get(key, alt), ret = fn(val);
1471
+ this.set(key, ret === void 0 ? val : ret);
1472
+ return this;
1473
+ },
1474
+ set: function(key, data, overwrite) {
1475
+ var d = this.get(key), replacer;
1476
+ if (d != null && overwrite === false) return data;
1477
+ if (typeof overwrite === "function") {
1478
+ replacer = overwrite;
1479
+ overwrite = void 0;
1480
+ }
1481
+ return _.set(this._area, this._in(key), _.stringify(data, replacer), overwrite) || d;
1482
+ },
1483
+ setAll: function(data, overwrite) {
1484
+ var changed, val;
1485
+ for (var key in data) {
1486
+ val = data[key];
1487
+ if (this.set(key, val, overwrite) !== val) changed = true;
1488
+ }
1489
+ return changed;
1490
+ },
1491
+ add: function(key, data, replacer) {
1492
+ var d = this.get(key);
1493
+ if (d instanceof Array) data = d.concat(data);
1494
+ else if (d !== null) {
1495
+ var type = typeof d;
1496
+ if (type === typeof data && type === "object") {
1497
+ for (var k in data) d[k] = data[k];
1498
+ data = d;
1499
+ } else data = d + data;
1500
+ }
1501
+ _.set(this._area, this._in(key), _.stringify(data, replacer));
1502
+ return data;
1503
+ },
1504
+ remove: function(key, alt) {
1505
+ var d = this.get(key, alt);
1506
+ _.remove(this._area, this._in(key));
1507
+ return d;
1508
+ },
1509
+ clear: function() {
1510
+ if (!this._ns) _.clear(this._area);
1511
+ else this.each(function(k) {
1512
+ _.remove(this._area, this._in(k));
1513
+ }, 1);
1514
+ return this;
1515
+ },
1516
+ clearAll: function() {
1517
+ var area = this._area;
1518
+ for (var id in _.areas) if (_.areas.hasOwnProperty(id)) {
1519
+ this._area = _.areas[id];
1520
+ this.clear();
1521
+ }
1522
+ this._area = area;
1523
+ return this;
1524
+ },
1525
+ _in: function(k) {
1526
+ if (typeof k !== "string") k = _.stringify(k);
1527
+ return this._ns ? this._ns + k : k;
1528
+ },
1529
+ _out: function(k) {
1530
+ return this._ns ? k && k.indexOf(this._ns) === 0 ? k.substring(this._ns.length) : void 0 : k;
1531
+ }
1532
+ },
1533
+ storage: function(name) {
1534
+ return _.inherit(_.storageAPI, {
1535
+ items: {},
1536
+ name
1537
+ });
1538
+ },
1539
+ storageAPI: {
1540
+ length: 0,
1541
+ has: function(k) {
1542
+ return this.items.hasOwnProperty(k);
1543
+ },
1544
+ key: function(i) {
1545
+ var c = 0;
1546
+ for (var k in this.items) if (this.has(k) && i === c++) return k;
1547
+ },
1548
+ setItem: function(k, v) {
1549
+ if (!this.has(k)) this.length++;
1550
+ this.items[k] = v;
1551
+ },
1552
+ removeItem: function(k) {
1553
+ if (this.has(k)) {
1554
+ delete this.items[k];
1555
+ this.length--;
1556
+ }
1557
+ },
1558
+ getItem: function(k) {
1559
+ return this.has(k) ? this.items[k] : null;
1560
+ },
1561
+ clear: function() {
1562
+ for (var k in this.items) this.removeItem(k);
1563
+ }
1564
+ }
1565
+ };
1566
+ var store$1 = _.Store("local", (function() {
1567
+ try {
1568
+ return localStorage;
1569
+ } catch (e) {}
1570
+ })());
1571
+ store$1.local = store$1;
1572
+ store$1._ = _;
1573
+ store$1.area("session", (function() {
1574
+ try {
1575
+ return sessionStorage;
1576
+ } catch (e) {}
1577
+ })());
1578
+ store$1.area("page", _.storage("page"));
1579
+ if (typeof define === "function" && define.amd !== void 0) define("store2", [], function() {
1580
+ return store$1;
1581
+ });
1582
+ else if (typeof module !== "undefined" && module.exports) {
1583
+ module.exports = store$1;
1584
+ module.exports.store = store$1;
1585
+ } else {
1586
+ if (window.store) _.conflict = window.store;
1587
+ window.store = store$1;
1588
+ }
1589
+ })(exports, exports && exports.define);
1590
+ }) });
1591
+
1592
+ //#endregion
1593
+ //#region ../../utils/dist/esm/index.js
1594
+ var import_store2 = require_store2();
1595
+ const getStdFeeFromObject = (args) => {
1596
+ if (!args) return getDefaultStdFee();
1597
+ const { payer, granter, feePayer, gasPrice = DEFAULT_GAS_PRICE, gas = DEFAULT_GAS_LIMIT.toString() } = args;
1598
+ const gasNormalized = toBigNumber(gas).toFixed(0);
1599
+ const gasPriceNormalized = toBigNumber(gasPrice).toFixed(0);
1600
+ return {
1601
+ amount: [{
1602
+ denom: "inj",
1603
+ amount: toBigNumber(gasNormalized).times(gasPriceNormalized).toFixed()
1604
+ }],
1605
+ gas: toBigNumber(gasNormalized).toFixed(),
1606
+ payer,
1607
+ granter,
1608
+ feePayer
1609
+ };
1610
+ };
1611
+ const getStdFeeFromString = (gasPrice) => {
1612
+ const matchResult = gasPrice.match(/^([0-9.]+)([a-zA-Z][a-zA-Z0-9/:._-]*)$/);
1613
+ if (!matchResult) throw new Error("Invalid gas price string");
1614
+ const [_, amount] = matchResult;
1615
+ return getStdFeeFromObject({
1616
+ gas: toChainFormat(amount, 18).dividedBy(DEFAULT_GAS_PRICE).toFixed(0),
1617
+ gasPrice: DEFAULT_GAS_PRICE
1618
+ });
1619
+ };
1620
+ const getStdFee = (args) => {
1621
+ if (!args) return getDefaultStdFee();
1622
+ if (typeof args === "string") return getStdFeeFromString(args);
1623
+ return getStdFeeFromObject({ ...args });
1624
+ };
1625
+
1626
+ //#endregion
1627
+ //#region src/utils/tx.ts
1628
+ const createEip712StdSignDoc = ({ memo, chainId, accountNumber, timeoutHeight, sequence, gas, msgs }) => ({
1629
+ chain_id: chainId,
1630
+ timeout_height: timeoutHeight || "",
1631
+ account_number: accountNumber.toString(),
1632
+ sequence: sequence.toString(),
1633
+ fee: getStdFee({ gas }),
1634
+ msgs: msgs.map((m) => m.toEip712()),
1635
+ memo: memo || ""
1636
+ });
1637
+
1638
+ //#endregion
1639
+ //#region src/utils/wallet.ts
1640
+ const isEvmWallet = (wallet) => [
1641
+ Wallet.Magic,
1642
+ Wallet.Rabby,
1643
+ Wallet.BitGet,
1644
+ Wallet.Ledger,
1645
+ Wallet.Phantom,
1646
+ Wallet.Rainbow,
1647
+ Wallet.Turnkey,
1648
+ Wallet.Metamask,
1649
+ Wallet.OkxWallet,
1650
+ Wallet.PrivateKey,
1651
+ Wallet.TrezorBip32,
1652
+ Wallet.TrezorBip44,
1653
+ Wallet.TrustWallet,
1654
+ Wallet.LedgerLegacy,
1655
+ Wallet.WalletConnect,
1656
+ Wallet.CosmostationEth
1657
+ ].includes(wallet);
1658
+ const isCosmosWallet = (wallet) => !isEvmWallet(wallet);
1659
+ const isEvmBrowserWallet = (wallet) => [
1660
+ Wallet.Rabby,
1661
+ Wallet.BitGet,
1662
+ Wallet.Phantom,
1663
+ Wallet.Rainbow,
1664
+ Wallet.Metamask,
1665
+ Wallet.OkxWallet,
1666
+ Wallet.TrustWallet
1667
+ ].includes(wallet);
1668
+ const isCosmosBrowserWallet = (wallet) => [
1669
+ Wallet.Leap,
1670
+ Wallet.Keplr,
1671
+ Wallet.Ninji,
1672
+ Wallet.OWallet,
1673
+ Wallet.Cosmostation
1674
+ ].includes(wallet);
1675
+ const isEip712V2OnlyWallet = (wallet) => [
1676
+ Wallet.Magic,
1677
+ Wallet.Phantom,
1678
+ Wallet.Metamask,
1679
+ Wallet.WalletConnect
1680
+ ].includes(wallet);
1681
+ const isCosmosAminoOnlyWallet = (wallet) => [Wallet.LedgerCosmos].includes(wallet);
1682
+
1683
+ //#endregion
1684
+ //#region src/utils/cosmos.ts
1685
+ const createCosmosSignDocFromSignDoc = (signDoc) => {
1686
+ return __injectivelabs_sdk_ts.CosmosTxV1Beta1TxPb.SignDoc.create({
1687
+ bodyBytes: signDoc.bodyBytes,
1688
+ authInfoBytes: signDoc.authInfoBytes,
1689
+ accountNumber: BigInt(signDoc.accountNumber),
1690
+ chainId: signDoc.chainId
1691
+ });
1692
+ };
1693
+
1694
+ //#endregion
1695
+ //#region src/utils/address.ts
1696
+ const getInjectiveSignerAddress = (address) => {
1697
+ if (!address) return "";
1698
+ if (address.startsWith("inj")) return address;
1699
+ if (address.startsWith("0x")) return (0, __injectivelabs_sdk_ts.getInjectiveAddress)(address);
1700
+ return "";
1701
+ };
1702
+ const getEthereumSignerAddress = (address) => {
1703
+ if (!address) return "";
1704
+ if (address.startsWith("0x")) return address;
1705
+ if (address.startsWith("inj")) return (0, __injectivelabs_sdk_ts.getEthereumAddress)(address);
1706
+ return "";
1707
+ };
1708
+
1709
+ //#endregion
1710
+ //#region src/utils/alchemy.ts
1711
+ const getKeyFromRpcUrl = (rpcUrl) => {
1712
+ if (!rpcUrl.includes("alchemyapi.io") && !rpcUrl.includes("alchemy.com")) return rpcUrl;
1713
+ const [key] = rpcUrl.split("/").reverse();
1714
+ return key;
1715
+ };
1716
+
1717
+ //#endregion
1718
+ //#region src/utils/constants.ts
1719
+ const GWEI_IN_WEI = toBigNumber(1e9);
1720
+ const TIP_IN_GWEI = toBigNumber(2).times(GWEI_IN_WEI);
1721
+ const DEFAULT_BASE_DERIVATION_PATH = "m/44'/60'";
1722
+ const DEFAULT_NUM_ADDRESSES_TO_FETCH = 5;
1723
+ const DEFAULT_ADDRESS_SEARCH_LIMIT = 100;
1724
+
1725
+ //#endregion
1726
+ //#region \0@oxc-project+runtime@0.96.0/helpers/typeof.js
1727
+ function _typeof(o) {
1728
+ "@babel/helpers - typeof";
1729
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
1730
+ return typeof o$1;
1731
+ } : function(o$1) {
1732
+ return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
1733
+ }, _typeof(o);
1734
+ }
1735
+
1736
+ //#endregion
1737
+ //#region \0@oxc-project+runtime@0.96.0/helpers/toPrimitive.js
1738
+ function toPrimitive(t, r) {
1739
+ if ("object" != _typeof(t) || !t) return t;
1740
+ var e = t[Symbol.toPrimitive];
1741
+ if (void 0 !== e) {
1742
+ var i = e.call(t, r || "default");
1743
+ if ("object" != _typeof(i)) return i;
1744
+ throw new TypeError("@@toPrimitive must return a primitive value.");
1745
+ }
1746
+ return ("string" === r ? String : Number)(t);
1747
+ }
1748
+
1749
+ //#endregion
1750
+ //#region \0@oxc-project+runtime@0.96.0/helpers/toPropertyKey.js
1751
+ function toPropertyKey(t) {
1752
+ var i = toPrimitive(t, "string");
1753
+ return "symbol" == _typeof(i) ? i : i + "";
1754
+ }
1755
+
1756
+ //#endregion
1757
+ //#region \0@oxc-project+runtime@0.96.0/helpers/defineProperty.js
1758
+ function _defineProperty(e, r, t) {
1759
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
1760
+ value: t,
1761
+ enumerable: !0,
1762
+ configurable: !0,
1763
+ writable: !0
1764
+ }) : e[r] = t, e;
1765
+ }
1766
+
1767
+ //#endregion
1768
+ //#region src/base.ts
1769
+ var BaseConcreteStrategy = class {
1770
+ constructor(args) {
1771
+ _defineProperty(this, "chainId", void 0);
1772
+ _defineProperty(this, "evmChainId", void 0);
1773
+ _defineProperty(this, "listeners", {});
1774
+ _defineProperty(this, "metadata", void 0);
1775
+ this.evmChainId = "evmOptions" in args && args.evmOptions ? args.evmOptions.evmChainId : void 0;
1776
+ this.chainId = args.chainId;
1777
+ this.metadata = args.metadata;
1778
+ }
1779
+ };
1780
+
1781
+ //#endregion
1782
+ exports.BaseConcreteStrategy = BaseConcreteStrategy;
1783
+ exports.BroadcastMode = BroadcastMode;
1784
+ exports.DEFAULT_ADDRESS_SEARCH_LIMIT = DEFAULT_ADDRESS_SEARCH_LIMIT;
1785
+ exports.DEFAULT_BASE_DERIVATION_PATH = DEFAULT_BASE_DERIVATION_PATH;
1786
+ exports.DEFAULT_NUM_ADDRESSES_TO_FETCH = DEFAULT_NUM_ADDRESSES_TO_FETCH;
1787
+ exports.GWEI_IN_WEI = GWEI_IN_WEI;
1788
+ exports.MagicProvider = MagicProvider;
1789
+ exports.TIP_IN_GWEI = TIP_IN_GWEI;
1790
+ exports.TurnkeyProvider = TurnkeyProvider;
1791
+ exports.Wallet = Wallet;
1792
+ exports.WalletAction = WalletAction;
1793
+ exports.WalletDeviceType = WalletDeviceType;
1794
+ exports.WalletEventListener = WalletEventListener;
1795
+ exports.createCosmosSignDocFromSignDoc = createCosmosSignDocFromSignDoc;
1796
+ exports.createEip712StdSignDoc = createEip712StdSignDoc;
1797
+ exports.getEthereumSignerAddress = getEthereumSignerAddress;
1798
+ exports.getInjectiveSignerAddress = getInjectiveSignerAddress;
1799
+ exports.getKeyFromRpcUrl = getKeyFromRpcUrl;
1800
+ exports.isCosmosAminoOnlyWallet = isCosmosAminoOnlyWallet;
1801
+ exports.isCosmosBrowserWallet = isCosmosBrowserWallet;
1802
+ exports.isCosmosWallet = isCosmosWallet;
1803
+ exports.isEip712V2OnlyWallet = isEip712V2OnlyWallet;
1804
+ exports.isEvmBrowserWallet = isEvmBrowserWallet;
1805
+ exports.isEvmWallet = isEvmWallet;