@tokemak/hooks 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,1542 @@
1
+ "use strict";
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 __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+ var __export = (target, all) => {
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
+
33
+ // ../../node_modules/numbro/dist/numbro.min.js
34
+ var require_numbro_min = __commonJS({
35
+ "../../node_modules/numbro/dist/numbro.min.js"(exports, module2) {
36
+ !function(e) {
37
+ if ("object" == typeof exports && "undefined" != typeof module2)
38
+ module2.exports = e();
39
+ else if ("function" == typeof define && define.amd)
40
+ define([], e);
41
+ else {
42
+ ("undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : this).numbro = e();
43
+ }
44
+ }(function() {
45
+ return function a(o, u, c) {
46
+ function s(t, e2) {
47
+ if (!u[t]) {
48
+ if (!o[t]) {
49
+ var r = "function" == typeof require && require;
50
+ if (!e2 && r)
51
+ return r(t, true);
52
+ if (l)
53
+ return l(t, true);
54
+ var n = new Error("Cannot find module '" + t + "'");
55
+ throw n.code = "MODULE_NOT_FOUND", n;
56
+ }
57
+ var i = u[t] = { exports: {} };
58
+ o[t][0].call(i.exports, function(e3) {
59
+ return s(o[t][1][e3] || e3);
60
+ }, i, i.exports, a, o, u, c);
61
+ }
62
+ return u[t].exports;
63
+ }
64
+ for (var l = "function" == typeof require && require, e = 0; e < c.length; e++)
65
+ s(c[e]);
66
+ return s;
67
+ }({ 1: [function(e, r, t) {
68
+ !function(e2) {
69
+ "use strict";
70
+ var t2, T = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i, C = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator, U = Math.ceil, R = Math.floor, I = "[BigNumber Error] ", $ = I + "Number primitive has more than 15 significant digits: ", G = 1e14, V = 14, q = 9007199254740991, Z = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13], z = 1e7, W = 1e9;
71
+ function H(e3) {
72
+ var t3 = 0 | e3;
73
+ return 0 < e3 || e3 === t3 ? t3 : t3 - 1;
74
+ }
75
+ function Y(e3) {
76
+ for (var t3, r2, n = 1, i = e3.length, a = e3[0] + ""; n < i; ) {
77
+ for (t3 = e3[n++] + "", r2 = V - t3.length; r2--; t3 = "0" + t3)
78
+ ;
79
+ a += t3;
80
+ }
81
+ for (i = a.length; 48 === a.charCodeAt(--i); )
82
+ ;
83
+ return a.slice(0, i + 1 || 1);
84
+ }
85
+ function K(e3, t3) {
86
+ var r2, n, i = e3.c, a = t3.c, o = e3.s, u = t3.s, c = e3.e, s = t3.e;
87
+ if (!o || !u)
88
+ return null;
89
+ if (r2 = i && !i[0], n = a && !a[0], r2 || n)
90
+ return r2 ? n ? 0 : -u : o;
91
+ if (o != u)
92
+ return o;
93
+ if (r2 = o < 0, n = c == s, !i || !a)
94
+ return n ? 0 : !i ^ r2 ? 1 : -1;
95
+ if (!n)
96
+ return s < c ^ r2 ? 1 : -1;
97
+ for (u = (c = i.length) < (s = a.length) ? c : s, o = 0; o < u; o++)
98
+ if (i[o] != a[o])
99
+ return i[o] > a[o] ^ r2 ? 1 : -1;
100
+ return c == s ? 0 : s < c ^ r2 ? 1 : -1;
101
+ }
102
+ function J(e3, t3, r2, n) {
103
+ if (e3 < t3 || r2 < e3 || e3 !== R(e3))
104
+ throw Error(I + (n || "Argument") + ("number" == typeof e3 ? e3 < t3 || r2 < e3 ? " out of range: " : " not an integer: " : " not a primitive number: ") + String(e3));
105
+ }
106
+ function X(e3) {
107
+ var t3 = e3.c.length - 1;
108
+ return H(e3.e / V) == t3 && e3.c[t3] % 2 != 0;
109
+ }
110
+ function Q(e3, t3) {
111
+ return (1 < e3.length ? e3.charAt(0) + "." + e3.slice(1) : e3) + (t3 < 0 ? "e" : "e+") + t3;
112
+ }
113
+ function ee(e3, t3, r2) {
114
+ var n, i;
115
+ if (t3 < 0) {
116
+ for (i = r2 + "."; ++t3; i += r2)
117
+ ;
118
+ e3 = i + e3;
119
+ } else if (++t3 > (n = e3.length)) {
120
+ for (i = r2, t3 -= n; --t3; i += r2)
121
+ ;
122
+ e3 += i;
123
+ } else
124
+ t3 < n && (e3 = e3.slice(0, t3) + "." + e3.slice(t3));
125
+ return e3;
126
+ }
127
+ (t2 = function e3(t3) {
128
+ var v, f, g, r2, s, m, o, u, c, l, p, n = A.prototype = { constructor: A, toString: null, valueOf: null }, h = new A(1), y = 20, b = 4, d = -7, w = 21, S = -1e7, O = 1e7, x = false, a = 1, N = 0, B = { prefix: "", groupSize: 3, secondaryGroupSize: 0, groupSeparator: ",", decimalSeparator: ".", fractionGroupSize: 0, fractionGroupSeparator: "\xA0", suffix: "" }, M = "0123456789abcdefghijklmnopqrstuvwxyz";
129
+ function A(e4, t4) {
130
+ var r3, n2, i2, a2, o2, u2, c2, s2, l2 = this;
131
+ if (!(l2 instanceof A))
132
+ return new A(e4, t4);
133
+ if (null == t4) {
134
+ if (e4 && true === e4._isBigNumber)
135
+ return l2.s = e4.s, void (!e4.c || e4.e > O ? l2.c = l2.e = null : e4.e < S ? l2.c = [l2.e = 0] : (l2.e = e4.e, l2.c = e4.c.slice()));
136
+ if ((u2 = "number" == typeof e4) && 0 * e4 == 0) {
137
+ if (l2.s = 1 / e4 < 0 ? (e4 = -e4, -1) : 1, e4 === ~~e4) {
138
+ for (a2 = 0, o2 = e4; 10 <= o2; o2 /= 10, a2++)
139
+ ;
140
+ return void (O < a2 ? l2.c = l2.e = null : (l2.e = a2, l2.c = [e4]));
141
+ }
142
+ s2 = String(e4);
143
+ } else {
144
+ if (!T.test(s2 = String(e4)))
145
+ return g(l2, s2, u2);
146
+ l2.s = 45 == s2.charCodeAt(0) ? (s2 = s2.slice(1), -1) : 1;
147
+ }
148
+ -1 < (a2 = s2.indexOf(".")) && (s2 = s2.replace(".", "")), 0 < (o2 = s2.search(/e/i)) ? (a2 < 0 && (a2 = o2), a2 += +s2.slice(o2 + 1), s2 = s2.substring(0, o2)) : a2 < 0 && (a2 = s2.length);
149
+ } else {
150
+ if (J(t4, 2, M.length, "Base"), 10 == t4)
151
+ return j(l2 = new A(e4), y + l2.e + 1, b);
152
+ if (s2 = String(e4), u2 = "number" == typeof e4) {
153
+ if (0 * e4 != 0)
154
+ return g(l2, s2, u2, t4);
155
+ if (l2.s = 1 / e4 < 0 ? (s2 = s2.slice(1), -1) : 1, A.DEBUG && 15 < s2.replace(/^0\.0*|\./, "").length)
156
+ throw Error($ + e4);
157
+ } else
158
+ l2.s = 45 === s2.charCodeAt(0) ? (s2 = s2.slice(1), -1) : 1;
159
+ for (r3 = M.slice(0, t4), a2 = o2 = 0, c2 = s2.length; o2 < c2; o2++)
160
+ if (r3.indexOf(n2 = s2.charAt(o2)) < 0) {
161
+ if ("." == n2) {
162
+ if (a2 < o2) {
163
+ a2 = c2;
164
+ continue;
165
+ }
166
+ } else if (!i2 && (s2 == s2.toUpperCase() && (s2 = s2.toLowerCase()) || s2 == s2.toLowerCase() && (s2 = s2.toUpperCase()))) {
167
+ i2 = true, o2 = -1, a2 = 0;
168
+ continue;
169
+ }
170
+ return g(l2, String(e4), u2, t4);
171
+ }
172
+ u2 = false, -1 < (a2 = (s2 = f(s2, t4, 10, l2.s)).indexOf(".")) ? s2 = s2.replace(".", "") : a2 = s2.length;
173
+ }
174
+ for (o2 = 0; 48 === s2.charCodeAt(o2); o2++)
175
+ ;
176
+ for (c2 = s2.length; 48 === s2.charCodeAt(--c2); )
177
+ ;
178
+ if (s2 = s2.slice(o2, ++c2)) {
179
+ if (c2 -= o2, u2 && A.DEBUG && 15 < c2 && (q < e4 || e4 !== R(e4)))
180
+ throw Error($ + l2.s * e4);
181
+ if ((a2 = a2 - o2 - 1) > O)
182
+ l2.c = l2.e = null;
183
+ else if (a2 < S)
184
+ l2.c = [l2.e = 0];
185
+ else {
186
+ if (l2.e = a2, l2.c = [], o2 = (a2 + 1) % V, a2 < 0 && (o2 += V), o2 < c2) {
187
+ for (o2 && l2.c.push(+s2.slice(0, o2)), c2 -= V; o2 < c2; )
188
+ l2.c.push(+s2.slice(o2, o2 += V));
189
+ o2 = V - (s2 = s2.slice(o2)).length;
190
+ } else
191
+ o2 -= c2;
192
+ for (; o2--; s2 += "0")
193
+ ;
194
+ l2.c.push(+s2);
195
+ }
196
+ } else
197
+ l2.c = [l2.e = 0];
198
+ }
199
+ function D(e4, t4, r3, n2) {
200
+ for (var i2, a2, o2 = [0], u2 = 0, c2 = e4.length; u2 < c2; ) {
201
+ for (a2 = o2.length; a2--; o2[a2] *= t4)
202
+ ;
203
+ for (o2[0] += n2.indexOf(e4.charAt(u2++)), i2 = 0; i2 < o2.length; i2++)
204
+ o2[i2] > r3 - 1 && (null == o2[i2 + 1] && (o2[i2 + 1] = 0), o2[i2 + 1] += o2[i2] / r3 | 0, o2[i2] %= r3);
205
+ }
206
+ return o2.reverse();
207
+ }
208
+ function E(e4, t4, r3) {
209
+ var n2, i2, a2, o2, u2 = 0, c2 = e4.length, s2 = t4 % z, l2 = t4 / z | 0;
210
+ for (e4 = e4.slice(); c2--; )
211
+ u2 = ((i2 = s2 * (a2 = e4[c2] % z) + (n2 = l2 * a2 + (o2 = e4[c2] / z | 0) * s2) % z * z + u2) / r3 | 0) + (n2 / z | 0) + l2 * o2, e4[c2] = i2 % r3;
212
+ return u2 && (e4 = [u2].concat(e4)), e4;
213
+ }
214
+ function F(e4, t4, r3, n2) {
215
+ var i2, a2;
216
+ if (r3 != n2)
217
+ a2 = n2 < r3 ? 1 : -1;
218
+ else
219
+ for (i2 = a2 = 0; i2 < r3; i2++)
220
+ if (e4[i2] != t4[i2]) {
221
+ a2 = e4[i2] > t4[i2] ? 1 : -1;
222
+ break;
223
+ }
224
+ return a2;
225
+ }
226
+ function k(e4, t4, r3, n2) {
227
+ for (var i2 = 0; r3--; )
228
+ e4[r3] -= i2, i2 = e4[r3] < t4[r3] ? 1 : 0, e4[r3] = i2 * n2 + e4[r3] - t4[r3];
229
+ for (; !e4[0] && 1 < e4.length; e4.splice(0, 1))
230
+ ;
231
+ }
232
+ function i(e4, t4, r3, n2) {
233
+ var i2, a2, o2, u2, c2;
234
+ if (null == r3 ? r3 = b : J(r3, 0, 8), !e4.c)
235
+ return e4.toString();
236
+ if (i2 = e4.c[0], o2 = e4.e, null == t4)
237
+ c2 = Y(e4.c), c2 = 1 == n2 || 2 == n2 && (o2 <= d || w <= o2) ? Q(c2, o2) : ee(c2, o2, "0");
238
+ else if (a2 = (e4 = j(new A(e4), t4, r3)).e, u2 = (c2 = Y(e4.c)).length, 1 == n2 || 2 == n2 && (t4 <= a2 || a2 <= d)) {
239
+ for (; u2 < t4; c2 += "0", u2++)
240
+ ;
241
+ c2 = Q(c2, a2);
242
+ } else if (t4 -= o2, c2 = ee(c2, a2, "0"), u2 < a2 + 1) {
243
+ if (0 < --t4)
244
+ for (c2 += "."; t4--; c2 += "0")
245
+ ;
246
+ } else if (0 < (t4 += a2 - u2))
247
+ for (a2 + 1 == u2 && (c2 += "."); t4--; c2 += "0")
248
+ ;
249
+ return e4.s < 0 && i2 ? "-" + c2 : c2;
250
+ }
251
+ function _(e4, t4) {
252
+ for (var r3, n2 = 1, i2 = new A(e4[0]); n2 < e4.length; n2++) {
253
+ if (!(r3 = new A(e4[n2])).s) {
254
+ i2 = r3;
255
+ break;
256
+ }
257
+ t4.call(i2, r3) && (i2 = r3);
258
+ }
259
+ return i2;
260
+ }
261
+ function L(e4, t4, r3) {
262
+ for (var n2 = 1, i2 = t4.length; !t4[--i2]; t4.pop())
263
+ ;
264
+ for (i2 = t4[0]; 10 <= i2; i2 /= 10, n2++)
265
+ ;
266
+ return (r3 = n2 + r3 * V - 1) > O ? e4.c = e4.e = null : r3 < S ? e4.c = [e4.e = 0] : (e4.e = r3, e4.c = t4), e4;
267
+ }
268
+ function j(e4, t4, r3, n2) {
269
+ var i2, a2, o2, u2, c2, s2, l2, f2 = e4.c, g2 = Z;
270
+ if (f2) {
271
+ e: {
272
+ for (i2 = 1, u2 = f2[0]; 10 <= u2; u2 /= 10, i2++)
273
+ ;
274
+ if ((a2 = t4 - i2) < 0)
275
+ a2 += V, o2 = t4, l2 = (c2 = f2[s2 = 0]) / g2[i2 - o2 - 1] % 10 | 0;
276
+ else if ((s2 = U((a2 + 1) / V)) >= f2.length) {
277
+ if (!n2)
278
+ break e;
279
+ for (; f2.length <= s2; f2.push(0))
280
+ ;
281
+ c2 = l2 = 0, o2 = (a2 %= V) - V + (i2 = 1);
282
+ } else {
283
+ for (c2 = u2 = f2[s2], i2 = 1; 10 <= u2; u2 /= 10, i2++)
284
+ ;
285
+ l2 = (o2 = (a2 %= V) - V + i2) < 0 ? 0 : c2 / g2[i2 - o2 - 1] % 10 | 0;
286
+ }
287
+ if (n2 = n2 || t4 < 0 || null != f2[s2 + 1] || (o2 < 0 ? c2 : c2 % g2[i2 - o2 - 1]), n2 = r3 < 4 ? (l2 || n2) && (0 == r3 || r3 == (e4.s < 0 ? 3 : 2)) : 5 < l2 || 5 == l2 && (4 == r3 || n2 || 6 == r3 && (0 < a2 ? 0 < o2 ? c2 / g2[i2 - o2] : 0 : f2[s2 - 1]) % 10 & 1 || r3 == (e4.s < 0 ? 8 : 7)), t4 < 1 || !f2[0])
288
+ return f2.length = 0, n2 ? (t4 -= e4.e + 1, f2[0] = g2[(V - t4 % V) % V], e4.e = -t4 || 0) : f2[0] = e4.e = 0, e4;
289
+ if (0 == a2 ? (f2.length = s2, u2 = 1, s2--) : (f2.length = s2 + 1, u2 = g2[V - a2], f2[s2] = 0 < o2 ? R(c2 / g2[i2 - o2] % g2[o2]) * u2 : 0), n2)
290
+ for (; ; ) {
291
+ if (0 == s2) {
292
+ for (a2 = 1, o2 = f2[0]; 10 <= o2; o2 /= 10, a2++)
293
+ ;
294
+ for (o2 = f2[0] += u2, u2 = 1; 10 <= o2; o2 /= 10, u2++)
295
+ ;
296
+ a2 != u2 && (e4.e++, f2[0] == G && (f2[0] = 1));
297
+ break;
298
+ }
299
+ if (f2[s2] += u2, f2[s2] != G)
300
+ break;
301
+ f2[s2--] = 0, u2 = 1;
302
+ }
303
+ for (a2 = f2.length; 0 === f2[--a2]; f2.pop())
304
+ ;
305
+ }
306
+ e4.e > O ? e4.c = e4.e = null : e4.e < S && (e4.c = [e4.e = 0]);
307
+ }
308
+ return e4;
309
+ }
310
+ function P(e4) {
311
+ var t4, r3 = e4.e;
312
+ return null === r3 ? e4.toString() : (t4 = Y(e4.c), t4 = r3 <= d || w <= r3 ? Q(t4, r3) : ee(t4, r3, "0"), e4.s < 0 ? "-" + t4 : t4);
313
+ }
314
+ return A.clone = e3, A.ROUND_UP = 0, A.ROUND_DOWN = 1, A.ROUND_CEIL = 2, A.ROUND_FLOOR = 3, A.ROUND_HALF_UP = 4, A.ROUND_HALF_DOWN = 5, A.ROUND_HALF_EVEN = 6, A.ROUND_HALF_CEIL = 7, A.ROUND_HALF_FLOOR = 8, A.EUCLID = 9, A.config = A.set = function(e4) {
315
+ var t4, r3;
316
+ if (null != e4) {
317
+ if ("object" != typeof e4)
318
+ throw Error(I + "Object expected: " + e4);
319
+ if (e4.hasOwnProperty(t4 = "DECIMAL_PLACES") && (J(r3 = e4[t4], 0, W, t4), y = r3), e4.hasOwnProperty(t4 = "ROUNDING_MODE") && (J(r3 = e4[t4], 0, 8, t4), b = r3), e4.hasOwnProperty(t4 = "EXPONENTIAL_AT") && ((r3 = e4[t4]) && r3.pop ? (J(r3[0], -W, 0, t4), J(r3[1], 0, W, t4), d = r3[0], w = r3[1]) : (J(r3, -W, W, t4), d = -(w = r3 < 0 ? -r3 : r3))), e4.hasOwnProperty(t4 = "RANGE"))
320
+ if ((r3 = e4[t4]) && r3.pop)
321
+ J(r3[0], -W, -1, t4), J(r3[1], 1, W, t4), S = r3[0], O = r3[1];
322
+ else {
323
+ if (J(r3, -W, W, t4), !r3)
324
+ throw Error(I + t4 + " cannot be zero: " + r3);
325
+ S = -(O = r3 < 0 ? -r3 : r3);
326
+ }
327
+ if (e4.hasOwnProperty(t4 = "CRYPTO")) {
328
+ if ((r3 = e4[t4]) !== !!r3)
329
+ throw Error(I + t4 + " not true or false: " + r3);
330
+ if (r3) {
331
+ if ("undefined" == typeof crypto || !crypto || !crypto.getRandomValues && !crypto.randomBytes)
332
+ throw x = !r3, Error(I + "crypto unavailable");
333
+ x = r3;
334
+ } else
335
+ x = r3;
336
+ }
337
+ if (e4.hasOwnProperty(t4 = "MODULO_MODE") && (J(r3 = e4[t4], 0, 9, t4), a = r3), e4.hasOwnProperty(t4 = "POW_PRECISION") && (J(r3 = e4[t4], 0, W, t4), N = r3), e4.hasOwnProperty(t4 = "FORMAT")) {
338
+ if ("object" != typeof (r3 = e4[t4]))
339
+ throw Error(I + t4 + " not an object: " + r3);
340
+ B = r3;
341
+ }
342
+ if (e4.hasOwnProperty(t4 = "ALPHABET")) {
343
+ if ("string" != typeof (r3 = e4[t4]) || /^.$|[+-.\s]|(.).*\1/.test(r3))
344
+ throw Error(I + t4 + " invalid: " + r3);
345
+ M = r3;
346
+ }
347
+ }
348
+ return { DECIMAL_PLACES: y, ROUNDING_MODE: b, EXPONENTIAL_AT: [d, w], RANGE: [S, O], CRYPTO: x, MODULO_MODE: a, POW_PRECISION: N, FORMAT: B, ALPHABET: M };
349
+ }, A.isBigNumber = function(e4) {
350
+ if (!e4 || true !== e4._isBigNumber)
351
+ return false;
352
+ if (!A.DEBUG)
353
+ return true;
354
+ var t4, r3, n2 = e4.c, i2 = e4.e, a2 = e4.s;
355
+ e:
356
+ if ("[object Array]" == {}.toString.call(n2)) {
357
+ if ((1 === a2 || -1 === a2) && -W <= i2 && i2 <= W && i2 === R(i2)) {
358
+ if (0 === n2[0]) {
359
+ if (0 === i2 && 1 === n2.length)
360
+ return true;
361
+ break e;
362
+ }
363
+ if ((t4 = (i2 + 1) % V) < 1 && (t4 += V), String(n2[0]).length == t4) {
364
+ for (t4 = 0; t4 < n2.length; t4++)
365
+ if ((r3 = n2[t4]) < 0 || G <= r3 || r3 !== R(r3))
366
+ break e;
367
+ if (0 !== r3)
368
+ return true;
369
+ }
370
+ }
371
+ } else if (null === n2 && null === i2 && (null === a2 || 1 === a2 || -1 === a2))
372
+ return true;
373
+ throw Error(I + "Invalid BigNumber: " + e4);
374
+ }, A.maximum = A.max = function() {
375
+ return _(arguments, n.lt);
376
+ }, A.minimum = A.min = function() {
377
+ return _(arguments, n.gt);
378
+ }, A.random = (r2 = 9007199254740992, s = Math.random() * r2 & 2097151 ? function() {
379
+ return R(Math.random() * r2);
380
+ } : function() {
381
+ return 8388608 * (1073741824 * Math.random() | 0) + (8388608 * Math.random() | 0);
382
+ }, function(e4) {
383
+ var t4, r3, n2, i2, a2, o2 = 0, u2 = [], c2 = new A(h);
384
+ if (null == e4 ? e4 = y : J(e4, 0, W), i2 = U(e4 / V), x)
385
+ if (crypto.getRandomValues) {
386
+ for (t4 = crypto.getRandomValues(new Uint32Array(i2 *= 2)); o2 < i2; )
387
+ 9e15 <= (a2 = 131072 * t4[o2] + (t4[o2 + 1] >>> 11)) ? (r3 = crypto.getRandomValues(new Uint32Array(2)), t4[o2] = r3[0], t4[o2 + 1] = r3[1]) : (u2.push(a2 % 1e14), o2 += 2);
388
+ o2 = i2 / 2;
389
+ } else {
390
+ if (!crypto.randomBytes)
391
+ throw x = false, Error(I + "crypto unavailable");
392
+ for (t4 = crypto.randomBytes(i2 *= 7); o2 < i2; )
393
+ 9e15 <= (a2 = 281474976710656 * (31 & t4[o2]) + 1099511627776 * t4[o2 + 1] + 4294967296 * t4[o2 + 2] + 16777216 * t4[o2 + 3] + (t4[o2 + 4] << 16) + (t4[o2 + 5] << 8) + t4[o2 + 6]) ? crypto.randomBytes(7).copy(t4, o2) : (u2.push(a2 % 1e14), o2 += 7);
394
+ o2 = i2 / 7;
395
+ }
396
+ if (!x)
397
+ for (; o2 < i2; )
398
+ (a2 = s()) < 9e15 && (u2[o2++] = a2 % 1e14);
399
+ for (i2 = u2[--o2], e4 %= V, i2 && e4 && (a2 = Z[V - e4], u2[o2] = R(i2 / a2) * a2); 0 === u2[o2]; u2.pop(), o2--)
400
+ ;
401
+ if (o2 < 0)
402
+ u2 = [n2 = 0];
403
+ else {
404
+ for (n2 = -1; 0 === u2[0]; u2.splice(0, 1), n2 -= V)
405
+ ;
406
+ for (o2 = 1, a2 = u2[0]; 10 <= a2; a2 /= 10, o2++)
407
+ ;
408
+ o2 < V && (n2 -= V - o2);
409
+ }
410
+ return c2.e = n2, c2.c = u2, c2;
411
+ }), A.sum = function() {
412
+ for (var e4 = 1, t4 = arguments, r3 = new A(t4[0]); e4 < t4.length; )
413
+ r3 = r3.plus(t4[e4++]);
414
+ return r3;
415
+ }, m = "0123456789", f = function(e4, t4, r3, n2, i2) {
416
+ var a2, o2, u2, c2, s2, l2, f2, g2, p2 = e4.indexOf("."), d2 = y, h2 = b;
417
+ for (0 <= p2 && (c2 = N, N = 0, e4 = e4.replace(".", ""), l2 = (g2 = new A(t4)).pow(e4.length - p2), N = c2, g2.c = D(ee(Y(l2.c), l2.e, "0"), 10, r3, m), g2.e = g2.c.length), u2 = c2 = (f2 = D(e4, t4, r3, i2 ? (a2 = M, m) : (a2 = m, M))).length; 0 == f2[--c2]; f2.pop())
418
+ ;
419
+ if (!f2[0])
420
+ return a2.charAt(0);
421
+ if (p2 < 0 ? --u2 : (l2.c = f2, l2.e = u2, l2.s = n2, f2 = (l2 = v(l2, g2, d2, h2, r3)).c, s2 = l2.r, u2 = l2.e), p2 = f2[o2 = u2 + d2 + 1], c2 = r3 / 2, s2 = s2 || o2 < 0 || null != f2[o2 + 1], s2 = h2 < 4 ? (null != p2 || s2) && (0 == h2 || h2 == (l2.s < 0 ? 3 : 2)) : c2 < p2 || p2 == c2 && (4 == h2 || s2 || 6 == h2 && 1 & f2[o2 - 1] || h2 == (l2.s < 0 ? 8 : 7)), o2 < 1 || !f2[0])
422
+ e4 = s2 ? ee(a2.charAt(1), -d2, a2.charAt(0)) : a2.charAt(0);
423
+ else {
424
+ if (f2.length = o2, s2)
425
+ for (--r3; ++f2[--o2] > r3; )
426
+ f2[o2] = 0, o2 || (++u2, f2 = [1].concat(f2));
427
+ for (c2 = f2.length; !f2[--c2]; )
428
+ ;
429
+ for (p2 = 0, e4 = ""; p2 <= c2; e4 += a2.charAt(f2[p2++]))
430
+ ;
431
+ e4 = ee(e4, u2, a2.charAt(0));
432
+ }
433
+ return e4;
434
+ }, v = function(e4, t4, r3, n2, i2) {
435
+ var a2, o2, u2, c2, s2, l2, f2, g2, p2, d2, h2, v2, m2, y2, b2, w2, S2, O2 = e4.s == t4.s ? 1 : -1, x2 = e4.c, N2 = t4.c;
436
+ if (!(x2 && x2[0] && N2 && N2[0]))
437
+ return new A(e4.s && t4.s && (x2 ? !N2 || x2[0] != N2[0] : N2) ? x2 && 0 == x2[0] || !N2 ? 0 * O2 : O2 / 0 : NaN);
438
+ for (p2 = (g2 = new A(O2)).c = [], O2 = r3 + (o2 = e4.e - t4.e) + 1, i2 || (i2 = G, o2 = H(e4.e / V) - H(t4.e / V), O2 = O2 / V | 0), u2 = 0; N2[u2] == (x2[u2] || 0); u2++)
439
+ ;
440
+ if (N2[u2] > (x2[u2] || 0) && o2--, O2 < 0)
441
+ p2.push(1), c2 = true;
442
+ else {
443
+ for (y2 = x2.length, w2 = N2.length, O2 += 2, 1 < (s2 = R(i2 / (N2[u2 = 0] + 1))) && (N2 = E(N2, s2, i2), x2 = E(x2, s2, i2), w2 = N2.length, y2 = x2.length), m2 = w2, h2 = (d2 = x2.slice(0, w2)).length; h2 < w2; d2[h2++] = 0)
444
+ ;
445
+ S2 = N2.slice(), S2 = [0].concat(S2), b2 = N2[0], N2[1] >= i2 / 2 && b2++;
446
+ do {
447
+ if (s2 = 0, (a2 = F(N2, d2, w2, h2)) < 0) {
448
+ if (v2 = d2[0], w2 != h2 && (v2 = v2 * i2 + (d2[1] || 0)), 1 < (s2 = R(v2 / b2)))
449
+ for (i2 <= s2 && (s2 = i2 - 1), f2 = (l2 = E(N2, s2, i2)).length, h2 = d2.length; 1 == F(l2, d2, f2, h2); )
450
+ s2--, k(l2, w2 < f2 ? S2 : N2, f2, i2), f2 = l2.length, a2 = 1;
451
+ else
452
+ 0 == s2 && (a2 = s2 = 1), f2 = (l2 = N2.slice()).length;
453
+ if (f2 < h2 && (l2 = [0].concat(l2)), k(d2, l2, h2, i2), h2 = d2.length, -1 == a2)
454
+ for (; F(N2, d2, w2, h2) < 1; )
455
+ s2++, k(d2, w2 < h2 ? S2 : N2, h2, i2), h2 = d2.length;
456
+ } else
457
+ 0 === a2 && (s2++, d2 = [0]);
458
+ p2[u2++] = s2, d2[0] ? d2[h2++] = x2[m2] || 0 : (d2 = [x2[m2]], h2 = 1);
459
+ } while ((m2++ < y2 || null != d2[0]) && O2--);
460
+ c2 = null != d2[0], p2[0] || p2.splice(0, 1);
461
+ }
462
+ if (i2 == G) {
463
+ for (u2 = 1, O2 = p2[0]; 10 <= O2; O2 /= 10, u2++)
464
+ ;
465
+ j(g2, r3 + (g2.e = u2 + o2 * V - 1) + 1, n2, c2);
466
+ } else
467
+ g2.e = o2, g2.r = +c2;
468
+ return g2;
469
+ }, o = /^(-?)0([xbo])(?=\w[\w.]*$)/i, u = /^([^.]+)\.$/, c = /^\.([^.]+)$/, l = /^-?(Infinity|NaN)$/, p = /^\s*\+(?=[\w.])|^\s+|\s+$/g, g = function(e4, t4, r3, n2) {
470
+ var i2, a2 = r3 ? t4 : t4.replace(p, "");
471
+ if (l.test(a2))
472
+ e4.s = isNaN(a2) ? null : a2 < 0 ? -1 : 1;
473
+ else {
474
+ if (!r3 && (a2 = a2.replace(o, function(e5, t5, r4) {
475
+ return i2 = "x" == (r4 = r4.toLowerCase()) ? 16 : "b" == r4 ? 2 : 8, n2 && n2 != i2 ? e5 : t5;
476
+ }), n2 && (i2 = n2, a2 = a2.replace(u, "$1").replace(c, "0.$1")), t4 != a2))
477
+ return new A(a2, i2);
478
+ if (A.DEBUG)
479
+ throw Error(I + "Not a" + (n2 ? " base " + n2 : "") + " number: " + t4);
480
+ e4.s = null;
481
+ }
482
+ e4.c = e4.e = null;
483
+ }, n.absoluteValue = n.abs = function() {
484
+ var e4 = new A(this);
485
+ return e4.s < 0 && (e4.s = 1), e4;
486
+ }, n.comparedTo = function(e4, t4) {
487
+ return K(this, new A(e4, t4));
488
+ }, n.decimalPlaces = n.dp = function(e4, t4) {
489
+ var r3, n2, i2;
490
+ if (null != e4)
491
+ return J(e4, 0, W), null == t4 ? t4 = b : J(t4, 0, 8), j(new A(this), e4 + this.e + 1, t4);
492
+ if (!(r3 = this.c))
493
+ return null;
494
+ if (n2 = ((i2 = r3.length - 1) - H(this.e / V)) * V, i2 = r3[i2])
495
+ for (; i2 % 10 == 0; i2 /= 10, n2--)
496
+ ;
497
+ return n2 < 0 && (n2 = 0), n2;
498
+ }, n.dividedBy = n.div = function(e4, t4) {
499
+ return v(this, new A(e4, t4), y, b);
500
+ }, n.dividedToIntegerBy = n.idiv = function(e4, t4) {
501
+ return v(this, new A(e4, t4), 0, 1);
502
+ }, n.exponentiatedBy = n.pow = function(e4, t4) {
503
+ var r3, n2, i2, a2, o2, u2, c2, s2, l2 = this;
504
+ if ((e4 = new A(e4)).c && !e4.isInteger())
505
+ throw Error(I + "Exponent not an integer: " + P(e4));
506
+ if (null != t4 && (t4 = new A(t4)), o2 = 14 < e4.e, !l2.c || !l2.c[0] || 1 == l2.c[0] && !l2.e && 1 == l2.c.length || !e4.c || !e4.c[0])
507
+ return s2 = new A(Math.pow(+P(l2), o2 ? 2 - X(e4) : +P(e4))), t4 ? s2.mod(t4) : s2;
508
+ if (u2 = e4.s < 0, t4) {
509
+ if (t4.c ? !t4.c[0] : !t4.s)
510
+ return new A(NaN);
511
+ (n2 = !u2 && l2.isInteger() && t4.isInteger()) && (l2 = l2.mod(t4));
512
+ } else {
513
+ if (9 < e4.e && (0 < l2.e || l2.e < -1 || (0 == l2.e ? 1 < l2.c[0] || o2 && 24e7 <= l2.c[1] : l2.c[0] < 8e13 || o2 && l2.c[0] <= 9999975e7)))
514
+ return a2 = l2.s < 0 && X(e4) ? -0 : 0, -1 < l2.e && (a2 = 1 / a2), new A(u2 ? 1 / a2 : a2);
515
+ N && (a2 = U(N / V + 2));
516
+ }
517
+ for (c2 = o2 ? (r3 = new A(0.5), u2 && (e4.s = 1), X(e4)) : (i2 = Math.abs(+P(e4))) % 2, s2 = new A(h); ; ) {
518
+ if (c2) {
519
+ if (!(s2 = s2.times(l2)).c)
520
+ break;
521
+ a2 ? s2.c.length > a2 && (s2.c.length = a2) : n2 && (s2 = s2.mod(t4));
522
+ }
523
+ if (i2) {
524
+ if (0 === (i2 = R(i2 / 2)))
525
+ break;
526
+ c2 = i2 % 2;
527
+ } else if (j(e4 = e4.times(r3), e4.e + 1, 1), 14 < e4.e)
528
+ c2 = X(e4);
529
+ else {
530
+ if (0 == (i2 = +P(e4)))
531
+ break;
532
+ c2 = i2 % 2;
533
+ }
534
+ l2 = l2.times(l2), a2 ? l2.c && l2.c.length > a2 && (l2.c.length = a2) : n2 && (l2 = l2.mod(t4));
535
+ }
536
+ return n2 ? s2 : (u2 && (s2 = h.div(s2)), t4 ? s2.mod(t4) : a2 ? j(s2, N, b, void 0) : s2);
537
+ }, n.integerValue = function(e4) {
538
+ var t4 = new A(this);
539
+ return null == e4 ? e4 = b : J(e4, 0, 8), j(t4, t4.e + 1, e4);
540
+ }, n.isEqualTo = n.eq = function(e4, t4) {
541
+ return 0 === K(this, new A(e4, t4));
542
+ }, n.isFinite = function() {
543
+ return !!this.c;
544
+ }, n.isGreaterThan = n.gt = function(e4, t4) {
545
+ return 0 < K(this, new A(e4, t4));
546
+ }, n.isGreaterThanOrEqualTo = n.gte = function(e4, t4) {
547
+ return 1 === (t4 = K(this, new A(e4, t4))) || 0 === t4;
548
+ }, n.isInteger = function() {
549
+ return !!this.c && H(this.e / V) > this.c.length - 2;
550
+ }, n.isLessThan = n.lt = function(e4, t4) {
551
+ return K(this, new A(e4, t4)) < 0;
552
+ }, n.isLessThanOrEqualTo = n.lte = function(e4, t4) {
553
+ return -1 === (t4 = K(this, new A(e4, t4))) || 0 === t4;
554
+ }, n.isNaN = function() {
555
+ return !this.s;
556
+ }, n.isNegative = function() {
557
+ return this.s < 0;
558
+ }, n.isPositive = function() {
559
+ return 0 < this.s;
560
+ }, n.isZero = function() {
561
+ return !!this.c && 0 == this.c[0];
562
+ }, n.minus = function(e4, t4) {
563
+ var r3, n2, i2, a2, o2 = this, u2 = o2.s;
564
+ if (t4 = (e4 = new A(e4, t4)).s, !u2 || !t4)
565
+ return new A(NaN);
566
+ if (u2 != t4)
567
+ return e4.s = -t4, o2.plus(e4);
568
+ var c2 = o2.e / V, s2 = e4.e / V, l2 = o2.c, f2 = e4.c;
569
+ if (!c2 || !s2) {
570
+ if (!l2 || !f2)
571
+ return l2 ? (e4.s = -t4, e4) : new A(f2 ? o2 : NaN);
572
+ if (!l2[0] || !f2[0])
573
+ return f2[0] ? (e4.s = -t4, e4) : new A(l2[0] ? o2 : 3 == b ? -0 : 0);
574
+ }
575
+ if (c2 = H(c2), s2 = H(s2), l2 = l2.slice(), u2 = c2 - s2) {
576
+ for ((i2 = (a2 = u2 < 0) ? (u2 = -u2, l2) : (s2 = c2, f2)).reverse(), t4 = u2; t4--; i2.push(0))
577
+ ;
578
+ i2.reverse();
579
+ } else
580
+ for (n2 = (a2 = (u2 = l2.length) < (t4 = f2.length)) ? u2 : t4, u2 = t4 = 0; t4 < n2; t4++)
581
+ if (l2[t4] != f2[t4]) {
582
+ a2 = l2[t4] < f2[t4];
583
+ break;
584
+ }
585
+ if (a2 && (i2 = l2, l2 = f2, f2 = i2, e4.s = -e4.s), 0 < (t4 = (n2 = f2.length) - (r3 = l2.length)))
586
+ for (; t4--; l2[r3++] = 0)
587
+ ;
588
+ for (t4 = G - 1; u2 < n2; ) {
589
+ if (l2[--n2] < f2[n2]) {
590
+ for (r3 = n2; r3 && !l2[--r3]; l2[r3] = t4)
591
+ ;
592
+ --l2[r3], l2[n2] += G;
593
+ }
594
+ l2[n2] -= f2[n2];
595
+ }
596
+ for (; 0 == l2[0]; l2.splice(0, 1), --s2)
597
+ ;
598
+ return l2[0] ? L(e4, l2, s2) : (e4.s = 3 == b ? -1 : 1, e4.c = [e4.e = 0], e4);
599
+ }, n.modulo = n.mod = function(e4, t4) {
600
+ var r3, n2, i2 = this;
601
+ return e4 = new A(e4, t4), !i2.c || !e4.s || e4.c && !e4.c[0] ? new A(NaN) : !e4.c || i2.c && !i2.c[0] ? new A(i2) : (9 == a ? (n2 = e4.s, e4.s = 1, r3 = v(i2, e4, 0, 3), e4.s = n2, r3.s *= n2) : r3 = v(i2, e4, 0, a), (e4 = i2.minus(r3.times(e4))).c[0] || 1 != a || (e4.s = i2.s), e4);
602
+ }, n.multipliedBy = n.times = function(e4, t4) {
603
+ var r3, n2, i2, a2, o2, u2, c2, s2, l2, f2, g2, p2, d2, h2, v2, m2 = this, y2 = m2.c, b2 = (e4 = new A(e4, t4)).c;
604
+ if (!(y2 && b2 && y2[0] && b2[0]))
605
+ return !m2.s || !e4.s || y2 && !y2[0] && !b2 || b2 && !b2[0] && !y2 ? e4.c = e4.e = e4.s = null : (e4.s *= m2.s, y2 && b2 ? (e4.c = [0], e4.e = 0) : e4.c = e4.e = null), e4;
606
+ for (n2 = H(m2.e / V) + H(e4.e / V), e4.s *= m2.s, (c2 = y2.length) < (f2 = b2.length) && (d2 = y2, y2 = b2, b2 = d2, i2 = c2, c2 = f2, f2 = i2), i2 = c2 + f2, d2 = []; i2--; d2.push(0))
607
+ ;
608
+ for (h2 = G, v2 = z, i2 = f2; 0 <= --i2; ) {
609
+ for (r3 = 0, g2 = b2[i2] % v2, p2 = b2[i2] / v2 | 0, a2 = i2 + (o2 = c2); i2 < a2; )
610
+ r3 = ((s2 = g2 * (s2 = y2[--o2] % v2) + (u2 = p2 * s2 + (l2 = y2[o2] / v2 | 0) * g2) % v2 * v2 + d2[a2] + r3) / h2 | 0) + (u2 / v2 | 0) + p2 * l2, d2[a2--] = s2 % h2;
611
+ d2[a2] = r3;
612
+ }
613
+ return r3 ? ++n2 : d2.splice(0, 1), L(e4, d2, n2);
614
+ }, n.negated = function() {
615
+ var e4 = new A(this);
616
+ return e4.s = -e4.s || null, e4;
617
+ }, n.plus = function(e4, t4) {
618
+ var r3, n2 = this, i2 = n2.s;
619
+ if (t4 = (e4 = new A(e4, t4)).s, !i2 || !t4)
620
+ return new A(NaN);
621
+ if (i2 != t4)
622
+ return e4.s = -t4, n2.minus(e4);
623
+ var a2 = n2.e / V, o2 = e4.e / V, u2 = n2.c, c2 = e4.c;
624
+ if (!a2 || !o2) {
625
+ if (!u2 || !c2)
626
+ return new A(i2 / 0);
627
+ if (!u2[0] || !c2[0])
628
+ return c2[0] ? e4 : new A(u2[0] ? n2 : 0 * i2);
629
+ }
630
+ if (a2 = H(a2), o2 = H(o2), u2 = u2.slice(), i2 = a2 - o2) {
631
+ for ((r3 = 0 < i2 ? (o2 = a2, c2) : (i2 = -i2, u2)).reverse(); i2--; r3.push(0))
632
+ ;
633
+ r3.reverse();
634
+ }
635
+ for ((i2 = u2.length) - (t4 = c2.length) < 0 && (r3 = c2, c2 = u2, u2 = r3, t4 = i2), i2 = 0; t4; )
636
+ i2 = (u2[--t4] = u2[t4] + c2[t4] + i2) / G | 0, u2[t4] = G === u2[t4] ? 0 : u2[t4] % G;
637
+ return i2 && (u2 = [i2].concat(u2), ++o2), L(e4, u2, o2);
638
+ }, n.precision = n.sd = function(e4, t4) {
639
+ var r3, n2, i2;
640
+ if (null != e4 && e4 !== !!e4)
641
+ return J(e4, 1, W), null == t4 ? t4 = b : J(t4, 0, 8), j(new A(this), e4, t4);
642
+ if (!(r3 = this.c))
643
+ return null;
644
+ if (n2 = (i2 = r3.length - 1) * V + 1, i2 = r3[i2]) {
645
+ for (; i2 % 10 == 0; i2 /= 10, n2--)
646
+ ;
647
+ for (i2 = r3[0]; 10 <= i2; i2 /= 10, n2++)
648
+ ;
649
+ }
650
+ return e4 && this.e + 1 > n2 && (n2 = this.e + 1), n2;
651
+ }, n.shiftedBy = function(e4) {
652
+ return J(e4, -q, q), this.times("1e" + e4);
653
+ }, n.squareRoot = n.sqrt = function() {
654
+ var e4, t4, r3, n2, i2, a2 = this, o2 = a2.c, u2 = a2.s, c2 = a2.e, s2 = y + 4, l2 = new A("0.5");
655
+ if (1 !== u2 || !o2 || !o2[0])
656
+ return new A(!u2 || u2 < 0 && (!o2 || o2[0]) ? NaN : o2 ? a2 : 1 / 0);
657
+ if ((r3 = 0 == (u2 = Math.sqrt(+P(a2))) || u2 == 1 / 0 ? (((t4 = Y(o2)).length + c2) % 2 == 0 && (t4 += "0"), u2 = Math.sqrt(+t4), c2 = H((c2 + 1) / 2) - (c2 < 0 || c2 % 2), new A(t4 = u2 == 1 / 0 ? "1e" + c2 : (t4 = u2.toExponential()).slice(0, t4.indexOf("e") + 1) + c2)) : new A(u2 + "")).c[0]) {
658
+ for ((u2 = (c2 = r3.e) + s2) < 3 && (u2 = 0); ; )
659
+ if (i2 = r3, r3 = l2.times(i2.plus(v(a2, i2, s2, 1))), Y(i2.c).slice(0, u2) === (t4 = Y(r3.c)).slice(0, u2)) {
660
+ if (r3.e < c2 && --u2, "9999" != (t4 = t4.slice(u2 - 3, u2 + 1)) && (n2 || "4999" != t4)) {
661
+ +t4 && (+t4.slice(1) || "5" != t4.charAt(0)) || (j(r3, r3.e + y + 2, 1), e4 = !r3.times(r3).eq(a2));
662
+ break;
663
+ }
664
+ if (!n2 && (j(i2, i2.e + y + 2, 0), i2.times(i2).eq(a2))) {
665
+ r3 = i2;
666
+ break;
667
+ }
668
+ s2 += 4, u2 += 4, n2 = 1;
669
+ }
670
+ }
671
+ return j(r3, r3.e + y + 1, b, e4);
672
+ }, n.toExponential = function(e4, t4) {
673
+ return null != e4 && (J(e4, 0, W), e4++), i(this, e4, t4, 1);
674
+ }, n.toFixed = function(e4, t4) {
675
+ return null != e4 && (J(e4, 0, W), e4 = e4 + this.e + 1), i(this, e4, t4);
676
+ }, n.toFormat = function(e4, t4, r3) {
677
+ var n2;
678
+ if (null == r3)
679
+ null != e4 && t4 && "object" == typeof t4 ? (r3 = t4, t4 = null) : e4 && "object" == typeof e4 ? (r3 = e4, e4 = t4 = null) : r3 = B;
680
+ else if ("object" != typeof r3)
681
+ throw Error(I + "Argument not an object: " + r3);
682
+ if (n2 = this.toFixed(e4, t4), this.c) {
683
+ var i2, a2 = n2.split("."), o2 = +r3.groupSize, u2 = +r3.secondaryGroupSize, c2 = r3.groupSeparator || "", s2 = a2[0], l2 = a2[1], f2 = this.s < 0, g2 = f2 ? s2.slice(1) : s2, p2 = g2.length;
684
+ if (u2 && (i2 = o2, o2 = u2, p2 -= u2 = i2), 0 < o2 && 0 < p2) {
685
+ for (i2 = p2 % o2 || o2, s2 = g2.substr(0, i2); i2 < p2; i2 += o2)
686
+ s2 += c2 + g2.substr(i2, o2);
687
+ 0 < u2 && (s2 += c2 + g2.slice(i2)), f2 && (s2 = "-" + s2);
688
+ }
689
+ n2 = l2 ? s2 + (r3.decimalSeparator || "") + ((u2 = +r3.fractionGroupSize) ? l2.replace(new RegExp("\\d{" + u2 + "}\\B", "g"), "$&" + (r3.fractionGroupSeparator || "")) : l2) : s2;
690
+ }
691
+ return (r3.prefix || "") + n2 + (r3.suffix || "");
692
+ }, n.toFraction = function(e4) {
693
+ var t4, r3, n2, i2, a2, o2, u2, c2, s2, l2, f2, g2, p2 = this, d2 = p2.c;
694
+ if (null != e4 && (!(u2 = new A(e4)).isInteger() && (u2.c || 1 !== u2.s) || u2.lt(h)))
695
+ throw Error(I + "Argument " + (u2.isInteger() ? "out of range: " : "not an integer: ") + P(u2));
696
+ if (!d2)
697
+ return new A(p2);
698
+ for (t4 = new A(h), s2 = r3 = new A(h), n2 = c2 = new A(h), g2 = Y(d2), a2 = t4.e = g2.length - p2.e - 1, t4.c[0] = Z[(o2 = a2 % V) < 0 ? V + o2 : o2], e4 = !e4 || 0 < u2.comparedTo(t4) ? 0 < a2 ? t4 : s2 : u2, o2 = O, O = 1 / 0, u2 = new A(g2), c2.c[0] = 0; l2 = v(u2, t4, 0, 1), 1 != (i2 = r3.plus(l2.times(n2))).comparedTo(e4); )
699
+ r3 = n2, n2 = i2, s2 = c2.plus(l2.times(i2 = s2)), c2 = i2, t4 = u2.minus(l2.times(i2 = t4)), u2 = i2;
700
+ return i2 = v(e4.minus(r3), n2, 0, 1), c2 = c2.plus(i2.times(s2)), r3 = r3.plus(i2.times(n2)), c2.s = s2.s = p2.s, f2 = v(s2, n2, a2 *= 2, b).minus(p2).abs().comparedTo(v(c2, r3, a2, b).minus(p2).abs()) < 1 ? [s2, n2] : [c2, r3], O = o2, f2;
701
+ }, n.toNumber = function() {
702
+ return +P(this);
703
+ }, n.toPrecision = function(e4, t4) {
704
+ return null != e4 && J(e4, 1, W), i(this, e4, t4, 2);
705
+ }, n.toString = function(e4) {
706
+ var t4, r3 = this, n2 = r3.s, i2 = r3.e;
707
+ return null === i2 ? n2 ? (t4 = "Infinity", n2 < 0 && (t4 = "-" + t4)) : t4 = "NaN" : (t4 = null == e4 ? i2 <= d || w <= i2 ? Q(Y(r3.c), i2) : ee(Y(r3.c), i2, "0") : 10 === e4 ? ee(Y((r3 = j(new A(r3), y + i2 + 1, b)).c), r3.e, "0") : (J(e4, 2, M.length, "Base"), f(ee(Y(r3.c), i2, "0"), 10, e4, n2, true)), n2 < 0 && r3.c[0] && (t4 = "-" + t4)), t4;
708
+ }, n.valueOf = n.toJSON = function() {
709
+ return P(this);
710
+ }, n._isBigNumber = true, C && (n[Symbol.toStringTag] = "BigNumber", n[Symbol.for("nodejs.util.inspect.custom")] = n.valueOf), null != t3 && A.set(t3), A;
711
+ }()).default = t2.BigNumber = t2, void 0 !== r && r.exports ? r.exports = t2 : (e2 = e2 || ("undefined" != typeof self && self ? self : window)).BigNumber = t2;
712
+ }(this);
713
+ }, {}], 2: [function(e, t, r) {
714
+ "use strict";
715
+ t.exports = { languageTag: "en-US", delimiters: { thousands: ",", decimal: "." }, abbreviations: { thousand: "k", million: "m", billion: "b", trillion: "t" }, spaceSeparated: false, ordinal: function(e2) {
716
+ var t2 = e2 % 10;
717
+ return 1 == ~~(e2 % 100 / 10) ? "th" : 1 == t2 ? "st" : 2 == t2 ? "nd" : 3 == t2 ? "rd" : "th";
718
+ }, bytes: { binarySuffixes: ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"], decimalSuffixes: ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"] }, currency: { symbol: "$", position: "prefix", code: "USD" }, currencyFormat: { thousandSeparated: true, totalLength: 4, spaceSeparated: true, spaceSeparatedCurrency: true }, formats: { fourDigits: { totalLength: 4, spaceSeparated: true }, fullWithTwoDecimals: { output: "currency", thousandSeparated: true, mantissa: 2 }, fullWithTwoDecimalsNoCurrency: { thousandSeparated: true, mantissa: 2 }, fullWithNoDecimals: { output: "currency", thousandSeparated: true, mantissa: 0 } } };
719
+ }, {}], 3: [function(e, t, r) {
720
+ "use strict";
721
+ function I(e2, t2) {
722
+ return function(e3) {
723
+ if (Array.isArray(e3))
724
+ return e3;
725
+ }(e2) || function(e3, t3) {
726
+ if (!(Symbol.iterator in Object(e3) || "[object Arguments]" === Object.prototype.toString.call(e3)))
727
+ return;
728
+ var r2 = [], n2 = true, i2 = false, a2 = void 0;
729
+ try {
730
+ for (var o2, u2 = e3[Symbol.iterator](); !(n2 = (o2 = u2.next()).done) && (r2.push(o2.value), !t3 || r2.length !== t3); n2 = true)
731
+ ;
732
+ } catch (e4) {
733
+ i2 = true, a2 = e4;
734
+ } finally {
735
+ try {
736
+ n2 || null == u2.return || u2.return();
737
+ } finally {
738
+ if (i2)
739
+ throw a2;
740
+ }
741
+ }
742
+ return r2;
743
+ }(e2, t2) || function() {
744
+ throw new TypeError("Invalid attempt to destructure non-iterable instance");
745
+ }();
746
+ }
747
+ var $ = e("./globalState"), o = e("./validating"), u = e("./parsing"), i = e("bignumber.js"), G = { trillion: Math.pow(10, 12), billion: Math.pow(10, 9), million: Math.pow(10, 6), thousand: Math.pow(10, 3) }, V = { totalLength: 0, characteristic: 0, forceAverage: false, average: false, mantissa: -1, optionalMantissa: true, thousandSeparated: false, spaceSeparated: false, negative: "sign", forceSign: false, roundingFunction: Math.round, spaceSeparatedAbbreviation: false }, n = $.currentBytes(), d = n.binarySuffixes, h = n.decimalSuffixes, a = { general: { scale: 1024, suffixes: h, marker: "bd" }, binary: { scale: 1024, suffixes: d, marker: "b" }, decimal: { scale: 1e3, suffixes: h, marker: "d" } };
748
+ function c(e2) {
749
+ var t2 = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : {}, r2 = 2 < arguments.length ? arguments[2] : void 0;
750
+ if ("string" == typeof t2 && (t2 = u.parseFormat(t2)), !o.validateFormat(t2))
751
+ return "ERROR: invalid format";
752
+ var n2 = t2.prefix || "", i2 = t2.postfix || "", a2 = function(e3, t3, r3) {
753
+ switch (t3.output) {
754
+ case "currency":
755
+ return t3 = s(t3, $.currentCurrencyDefaultFormat()), function(e4, t4, r4) {
756
+ var n3 = r4.currentCurrency(), i3 = Object.assign({}, t4), a3 = Object.assign({}, V, i3), o2 = void 0, u2 = "", c2 = !!a3.totalLength || !!a3.forceAverage || a3.average, s2 = i3.currencyPosition || n3.position, l = i3.currencySymbol || n3.symbol, f = void 0 !== a3.spaceSeparatedCurrency ? a3.spaceSeparatedCurrency : a3.spaceSeparated;
757
+ void 0 === i3.lowPrecision && (i3.lowPrecision = false);
758
+ f && (u2 = " ");
759
+ "infix" === s2 && (o2 = u2 + l + u2);
760
+ var g2 = m({ instance: e4, providedFormat: i3, state: r4, decimalSeparator: o2 });
761
+ "prefix" === s2 && (g2 = e4._value < 0 && "sign" === a3.negative ? "-".concat(u2).concat(l).concat(g2.slice(1)) : 0 < e4._value && a3.forceSign ? "+".concat(u2).concat(l).concat(g2.slice(1)) : l + u2 + g2);
762
+ s2 && "postfix" !== s2 || (u2 = !a3.spaceSeparatedAbbreviation && c2 ? "" : u2, g2 = g2 + u2 + l);
763
+ return g2;
764
+ }(e3, t3, $);
765
+ case "percent":
766
+ return t3 = s(t3, $.currentPercentageDefaultFormat()), function(e4, t4, r4, n3) {
767
+ var i3 = t4.prefixSymbol, a3 = m({ instance: n3(100 * e4._value), providedFormat: t4, state: r4 }), o2 = Object.assign({}, V, t4);
768
+ if (i3)
769
+ return "%".concat(o2.spaceSeparated ? " " : "").concat(a3);
770
+ return "".concat(a3).concat(o2.spaceSeparated ? " " : "", "%");
771
+ }(e3, t3, $, r3);
772
+ case "byte":
773
+ return t3 = s(t3, $.currentByteDefaultFormat()), function(e4, t4, r4, n3) {
774
+ var i3 = t4.base || "binary", a3 = Object.assign({}, V, t4), o2 = r4.currentBytes(), u2 = o2.binarySuffixes, c2 = o2.decimalSuffixes, s2 = { general: { scale: 1024, suffixes: c2 || h, marker: "bd" }, binary: { scale: 1024, suffixes: u2 || d, marker: "b" }, decimal: { scale: 1e3, suffixes: c2 || h, marker: "d" } }[i3], l = v(e4._value, s2.suffixes, s2.scale), f = l.value, g2 = l.suffix, p = m({ instance: n3(f), providedFormat: t4, state: r4, defaults: r4.currentByteDefaultFormat() });
775
+ return "".concat(p).concat(a3.spaceSeparated ? " " : "").concat(g2);
776
+ }(e3, t3, $, r3);
777
+ case "time":
778
+ return t3 = s(t3, $.currentTimeDefaultFormat()), function(e4) {
779
+ var t4 = Math.floor(e4._value / 60 / 60), r4 = Math.floor((e4._value - 60 * t4 * 60) / 60), n3 = Math.round(e4._value - 60 * t4 * 60 - 60 * r4);
780
+ return "".concat(t4, ":").concat(r4 < 10 ? "0" : "").concat(r4, ":").concat(n3 < 10 ? "0" : "").concat(n3);
781
+ }(e3);
782
+ case "ordinal":
783
+ return t3 = s(t3, $.currentOrdinalDefaultFormat()), function(e4, t4, r4) {
784
+ var n3 = r4.currentOrdinal(), i3 = Object.assign({}, V, t4), a3 = m({ instance: e4, providedFormat: t4, state: r4 }), o2 = n3(e4._value);
785
+ return "".concat(a3).concat(i3.spaceSeparated ? " " : "").concat(o2);
786
+ }(e3, t3, $);
787
+ case "number":
788
+ default:
789
+ return m({ instance: e3, providedFormat: t3, numbro: r3 });
790
+ }
791
+ }(e2, t2, r2);
792
+ return a2 = (a2 = n2 + a2) + i2;
793
+ }
794
+ function v(e2, t2, r2) {
795
+ var n2 = t2[0], i2 = Math.abs(e2);
796
+ if (r2 <= i2) {
797
+ for (var a2 = 1; a2 < t2.length; ++a2) {
798
+ var o2 = Math.pow(r2, a2), u2 = Math.pow(r2, a2 + 1);
799
+ if (o2 <= i2 && i2 < u2) {
800
+ n2 = t2[a2], e2 /= o2;
801
+ break;
802
+ }
803
+ }
804
+ n2 === t2[0] && (e2 /= Math.pow(r2, t2.length - 1), n2 = t2[t2.length - 1]);
805
+ }
806
+ return { value: e2, suffix: n2 };
807
+ }
808
+ function g(e2) {
809
+ for (var t2 = "", r2 = 0; r2 < e2; r2++)
810
+ t2 += "0";
811
+ return t2;
812
+ }
813
+ function q(e2, t2, r2) {
814
+ var n2 = 2 < arguments.length && void 0 !== r2 ? r2 : Math.round;
815
+ return -1 !== e2.toString().indexOf("e") ? function(e3, t3) {
816
+ var r3 = e3.toString(), n3 = I(r3.split("e"), 2), i2 = n3[0], a2 = n3[1], o2 = I(i2.split("."), 2), u2 = o2[0], c2 = o2[1], s2 = void 0 === c2 ? "" : c2;
817
+ if (0 < +a2)
818
+ r3 = u2 + s2 + g(a2 - s2.length);
819
+ else {
820
+ var l = ".";
821
+ l = +u2 < 0 ? "-0".concat(l) : "0".concat(l);
822
+ var f = (g(-a2 - 1) + Math.abs(u2) + s2).substr(0, t3);
823
+ f.length < t3 && (f += g(t3 - f.length)), r3 = l + f;
824
+ }
825
+ return 0 < +a2 && 0 < t3 && (r3 += ".".concat(g(t3))), r3;
826
+ }(e2, t2) : new i(n2(+"".concat(e2, "e+").concat(t2)) / Math.pow(10, t2)).toFixed(t2);
827
+ }
828
+ function Z(e2, t2, r2, n2, i2) {
829
+ var a2 = n2.currentDelimiters(), o2 = a2.thousands;
830
+ i2 = i2 || a2.decimal;
831
+ var u2 = a2.thousandsSize || 3, c2 = e2.toString(), s2 = c2.split(".")[0], l = c2.split(".")[1], f = t2 < 0 && 0 === s2.indexOf("-");
832
+ r2 && (f && (s2 = s2.slice(1)), function(e3, t3) {
833
+ for (var r3 = [], n3 = 0, i3 = e3; 0 < i3; i3--)
834
+ n3 === t3 && (r3.unshift(i3), n3 = 0), n3++;
835
+ return r3;
836
+ }(s2.length, u2).forEach(function(e3, t3) {
837
+ s2 = s2.slice(0, e3 + t3) + o2 + s2.slice(e3 + t3);
838
+ }), f && (s2 = "-".concat(s2)));
839
+ return c2 = l ? s2 + i2 + l : s2;
840
+ }
841
+ function m(e2) {
842
+ var t2 = e2.instance, r2 = e2.providedFormat, n2 = e2.state, i2 = void 0 === n2 ? $ : n2, a2 = e2.decimalSeparator, o2 = e2.defaults, u2 = void 0 === o2 ? i2.currentDefaults() : o2, c2 = t2._value;
843
+ if (0 === c2 && i2.hasZeroFormat())
844
+ return i2.getZeroFormat();
845
+ if (!isFinite(c2))
846
+ return c2.toString();
847
+ var s2, l, f, g2, p, d2, h2, v2, m2 = Object.assign({}, V, u2, r2), y = m2.totalLength, b = y ? 0 : m2.characteristic, w = m2.optionalCharacteristic, S = m2.forceAverage, O = m2.lowPrecision, x = !!y || !!S || m2.average, N = y ? -1 : x && void 0 === r2.mantissa ? 0 : m2.mantissa, B = !y && (void 0 === r2.optionalMantissa ? -1 === N : m2.optionalMantissa), M = m2.trimMantissa, A = m2.thousandSeparated, D = m2.spaceSeparated, E = m2.negative, F = m2.forceSign, k = m2.exponential, _ = m2.roundingFunction, L = "";
848
+ if (x) {
849
+ var j = function(e3) {
850
+ var t3 = e3.value, r3 = e3.forceAverage, n3 = e3.lowPrecision, i3 = void 0 === n3 || n3, a3 = e3.abbreviations, o3 = e3.spaceSeparated, u3 = void 0 !== o3 && o3, c3 = e3.totalLength, s3 = void 0 === c3 ? 0 : c3, l2 = e3.roundingFunction, f2 = void 0 === l2 ? Math.round : l2, g3 = "", p2 = Math.abs(t3), d3 = -1;
851
+ if (r3 && a3[r3] && G[r3] ? (g3 = a3[r3], t3 /= G[r3]) : p2 >= G.trillion || i3 && 1 === f2(p2 / G.trillion) ? (g3 = a3.trillion, t3 /= G.trillion) : p2 < G.trillion && p2 >= G.billion || i3 && 1 === f2(p2 / G.billion) ? (g3 = a3.billion, t3 /= G.billion) : p2 < G.billion && p2 >= G.million || i3 && 1 === f2(p2 / G.million) ? (g3 = a3.million, t3 /= G.million) : (p2 < G.million && p2 >= G.thousand || i3 && 1 === f2(p2 / G.thousand)) && (g3 = a3.thousand, t3 /= G.thousand), g3 = g3 && (u3 ? " " : "") + g3, s3) {
852
+ var h3 = t3 < 0, v3 = t3.toString().split(".")[0], m3 = h3 ? v3.length - 1 : v3.length;
853
+ d3 = Math.max(s3 - m3, 0);
854
+ }
855
+ return { value: t3, abbreviation: g3, mantissaPrecision: d3 };
856
+ }({ value: c2, forceAverage: S, lowPrecision: O, abbreviations: i2.currentAbbreviations(), spaceSeparated: D, roundingFunction: _, totalLength: y });
857
+ c2 = j.value, L += j.abbreviation, y && (N = j.mantissaPrecision);
858
+ }
859
+ if (k) {
860
+ var P = (l = (s2 = { value: c2, characteristicPrecision: b }).value, f = s2.characteristicPrecision, g2 = void 0 === f ? 0 : f, p = I(l.toExponential().split("e"), 2), d2 = p[0], h2 = p[1], v2 = +d2, g2 && 1 < g2 && (v2 *= Math.pow(10, g2 - 1), h2 = 0 <= (h2 -= g2 - 1) ? "+".concat(h2) : h2), { value: v2, abbreviation: "e".concat(h2) });
861
+ c2 = P.value, L = P.abbreviation + L;
862
+ }
863
+ var T, C, U, R = function(e3, t3, r3, n3, i3, a3) {
864
+ if (-1 === n3)
865
+ return e3;
866
+ var o3 = q(t3, n3, a3), u3 = I(o3.toString().split("."), 2), c3 = u3[0], s3 = u3[1], l2 = void 0 === s3 ? "" : s3;
867
+ if (l2.match(/^0+$/) && (r3 || i3))
868
+ return c3;
869
+ var f2 = l2.match(/0+$/);
870
+ return i3 && f2 ? "".concat(c3, ".").concat(l2.toString().slice(0, f2.index)) : o3.toString();
871
+ }(c2.toString(), c2, B, N, M, _);
872
+ return R = Z(R = function(e3, t3, r3, n3) {
873
+ var i3 = e3, a3 = I(i3.toString().split("."), 2), o3 = a3[0], u3 = a3[1];
874
+ if (o3.match(/^-?0$/) && r3)
875
+ return u3 ? "".concat(o3.replace("0", ""), ".").concat(u3) : o3.replace("0", "");
876
+ var c3 = t3 < 0 && 0 === o3.indexOf("-");
877
+ if (c3 && (o3 = o3.slice(1), i3 = i3.slice(1)), o3.length < n3)
878
+ for (var s3 = n3 - o3.length, l2 = 0; l2 < s3; l2++)
879
+ i3 = "0".concat(i3);
880
+ return c3 && (i3 = "-".concat(i3)), i3.toString();
881
+ }(R, c2, w, b), c2, A, i2, a2), (x || k) && (R = R + L), (F || c2 < 0) && (T = R, U = E, R = 0 === (C = c2) ? T : 0 == +T ? T.replace("-", "") : 0 < C ? "+".concat(T) : "sign" === U ? T : "(".concat(T.replace("-", ""), ")")), R;
882
+ }
883
+ function s(e2, t2) {
884
+ if (!e2)
885
+ return t2;
886
+ var r2 = Object.keys(e2);
887
+ return 1 === r2.length && "output" === r2[0] ? t2 : e2;
888
+ }
889
+ t.exports = function(n2) {
890
+ return { format: function() {
891
+ for (var e2 = arguments.length, t2 = new Array(e2), r2 = 0; r2 < e2; r2++)
892
+ t2[r2] = arguments[r2];
893
+ return c.apply(void 0, t2.concat([n2]));
894
+ }, getByteUnit: function() {
895
+ for (var e2 = arguments.length, t2 = new Array(e2), r2 = 0; r2 < e2; r2++)
896
+ t2[r2] = arguments[r2];
897
+ return function(e3) {
898
+ var t3 = a.general;
899
+ return v(e3._value, t3.suffixes, t3.scale).suffix;
900
+ }.apply(void 0, t2.concat([n2]));
901
+ }, getBinaryByteUnit: function() {
902
+ for (var e2 = arguments.length, t2 = new Array(e2), r2 = 0; r2 < e2; r2++)
903
+ t2[r2] = arguments[r2];
904
+ return function(e3) {
905
+ var t3 = a.binary;
906
+ return v(e3._value, t3.suffixes, t3.scale).suffix;
907
+ }.apply(void 0, t2.concat([n2]));
908
+ }, getDecimalByteUnit: function() {
909
+ for (var e2 = arguments.length, t2 = new Array(e2), r2 = 0; r2 < e2; r2++)
910
+ t2[r2] = arguments[r2];
911
+ return function(e3) {
912
+ var t3 = a.decimal;
913
+ return v(e3._value, t3.suffixes, t3.scale).suffix;
914
+ }.apply(void 0, t2.concat([n2]));
915
+ }, formatOrDefault: s };
916
+ };
917
+ }, { "./globalState": 4, "./parsing": 8, "./validating": 10, "bignumber.js": 1 }], 4: [function(e, t, r) {
918
+ "use strict";
919
+ var i = e("./en-US"), n = e("./validating"), a = e("./parsing"), o = {}, u = void 0, c = {}, s = null, l = {};
920
+ function f(e2) {
921
+ u = e2;
922
+ }
923
+ function g() {
924
+ return c[u];
925
+ }
926
+ o.languages = function() {
927
+ return Object.assign({}, c);
928
+ }, o.currentLanguage = function() {
929
+ return u;
930
+ }, o.currentBytes = function() {
931
+ return g().bytes || {};
932
+ }, o.currentCurrency = function() {
933
+ return g().currency;
934
+ }, o.currentAbbreviations = function() {
935
+ return g().abbreviations;
936
+ }, o.currentDelimiters = function() {
937
+ return g().delimiters;
938
+ }, o.currentOrdinal = function() {
939
+ return g().ordinal;
940
+ }, o.currentDefaults = function() {
941
+ return Object.assign({}, g().defaults, l);
942
+ }, o.currentOrdinalDefaultFormat = function() {
943
+ return Object.assign({}, o.currentDefaults(), g().ordinalFormat);
944
+ }, o.currentByteDefaultFormat = function() {
945
+ return Object.assign({}, o.currentDefaults(), g().byteFormat);
946
+ }, o.currentPercentageDefaultFormat = function() {
947
+ return Object.assign({}, o.currentDefaults(), g().percentageFormat);
948
+ }, o.currentCurrencyDefaultFormat = function() {
949
+ return Object.assign({}, o.currentDefaults(), g().currencyFormat);
950
+ }, o.currentTimeDefaultFormat = function() {
951
+ return Object.assign({}, o.currentDefaults(), g().timeFormat);
952
+ }, o.setDefaults = function(e2) {
953
+ e2 = a.parseFormat(e2), n.validateFormat(e2) && (l = e2);
954
+ }, o.getZeroFormat = function() {
955
+ return s;
956
+ }, o.setZeroFormat = function(e2) {
957
+ return s = "string" == typeof e2 ? e2 : null;
958
+ }, o.hasZeroFormat = function() {
959
+ return null !== s;
960
+ }, o.languageData = function(e2) {
961
+ if (e2) {
962
+ if (c[e2])
963
+ return c[e2];
964
+ throw new Error('Unknown tag "'.concat(e2, '"'));
965
+ }
966
+ return g();
967
+ }, o.registerLanguage = function(e2) {
968
+ var t2 = 1 < arguments.length && void 0 !== arguments[1] && arguments[1];
969
+ if (!n.validateLanguage(e2))
970
+ throw new Error("Invalid language data");
971
+ c[e2.languageTag] = e2, t2 && f(e2.languageTag);
972
+ }, o.setLanguage = function(e2) {
973
+ var t2 = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : i.languageTag;
974
+ if (!c[e2]) {
975
+ var r2 = e2.split("-")[0], n2 = Object.keys(c).find(function(e3) {
976
+ return e3.split("-")[0] === r2;
977
+ });
978
+ return c[n2] ? void f(n2) : void f(t2);
979
+ }
980
+ f(e2);
981
+ }, o.registerLanguage(i), u = i.languageTag, t.exports = o;
982
+ }, { "./en-US": 2, "./parsing": 8, "./validating": 10 }], 5: [function(n, e, t) {
983
+ "use strict";
984
+ e.exports = function(t2) {
985
+ return { loadLanguagesInNode: function(e2) {
986
+ return r = t2, void e2.forEach(function(t3) {
987
+ var e3 = void 0;
988
+ try {
989
+ e3 = n("../languages/".concat(t3));
990
+ } catch (e4) {
991
+ console.error('Unable to load "'.concat(t3, '". No matching language file found.'));
992
+ }
993
+ e3 && r.registerLanguage(e3);
994
+ });
995
+ var r;
996
+ } };
997
+ };
998
+ }, {}], 6: [function(e, t, r) {
999
+ "use strict";
1000
+ var c = e("bignumber.js");
1001
+ function a(e2, t2, r2) {
1002
+ var n = new c(e2._value), i = t2;
1003
+ return r2.isNumbro(t2) && (i = t2._value), i = new c(i), e2._value = n.minus(i).toNumber(), e2;
1004
+ }
1005
+ t.exports = function(u) {
1006
+ return { add: function(e2, t2) {
1007
+ return n = t2, i = u, a2 = new c((r2 = e2)._value), o = n, i.isNumbro(n) && (o = n._value), o = new c(o), r2._value = a2.plus(o).toNumber(), r2;
1008
+ var r2, n, i, a2, o;
1009
+ }, subtract: function(e2, t2) {
1010
+ return a(e2, t2, u);
1011
+ }, multiply: function(e2, t2) {
1012
+ return n = t2, i = u, a2 = new c((r2 = e2)._value), o = n, i.isNumbro(n) && (o = n._value), o = new c(o), r2._value = a2.times(o).toNumber(), r2;
1013
+ var r2, n, i, a2, o;
1014
+ }, divide: function(e2, t2) {
1015
+ return n = t2, i = u, a2 = new c((r2 = e2)._value), o = n, i.isNumbro(n) && (o = n._value), o = new c(o), r2._value = a2.dividedBy(o).toNumber(), r2;
1016
+ var r2, n, i, a2, o;
1017
+ }, set: function(e2, t2) {
1018
+ return r2 = e2, i = n = t2, u.isNumbro(n) && (i = n._value), r2._value = i, r2;
1019
+ var r2, n, i;
1020
+ }, difference: function(e2, t2) {
1021
+ return r2 = t2, a(i = (n = u)(e2._value), r2, n), Math.abs(i._value);
1022
+ var r2, n, i;
1023
+ }, BigNumber: c };
1024
+ };
1025
+ }, { "bignumber.js": 1 }], 7: [function(e, t, r) {
1026
+ "use strict";
1027
+ function i(e2, t2) {
1028
+ for (var r2 = 0; r2 < t2.length; r2++) {
1029
+ var n2 = t2[r2];
1030
+ n2.enumerable = n2.enumerable || false, n2.configurable = true, "value" in n2 && (n2.writable = true), Object.defineProperty(e2, n2.key, n2);
1031
+ }
1032
+ }
1033
+ var a = e("./globalState"), n = e("./validating"), o = e("./loading")(p), u = e("./unformatting"), c = e("./formatting")(p), s = e("./manipulating")(p), l = e("./parsing"), f = function() {
1034
+ function t2(e3) {
1035
+ !function(e4, t3) {
1036
+ if (!(e4 instanceof t3))
1037
+ throw new TypeError("Cannot call a class as a function");
1038
+ }(this, t2), this._value = e3;
1039
+ }
1040
+ var e2, r2, n2;
1041
+ return e2 = t2, (r2 = [{ key: "clone", value: function() {
1042
+ return p(this._value);
1043
+ } }, { key: "format", value: function(e3) {
1044
+ var t3 = 0 < arguments.length && void 0 !== e3 ? e3 : {};
1045
+ return c.format(this, t3);
1046
+ } }, { key: "formatCurrency", value: function(e3) {
1047
+ return "string" == typeof e3 && (e3 = l.parseFormat(e3)), (e3 = c.formatOrDefault(e3, a.currentCurrencyDefaultFormat())).output = "currency", c.format(this, e3);
1048
+ } }, { key: "formatTime", value: function(e3) {
1049
+ var t3 = 0 < arguments.length && void 0 !== e3 ? e3 : {};
1050
+ return t3.output = "time", c.format(this, t3);
1051
+ } }, { key: "binaryByteUnits", value: function() {
1052
+ return c.getBinaryByteUnit(this);
1053
+ } }, { key: "decimalByteUnits", value: function() {
1054
+ return c.getDecimalByteUnit(this);
1055
+ } }, { key: "byteUnits", value: function() {
1056
+ return c.getByteUnit(this);
1057
+ } }, { key: "difference", value: function(e3) {
1058
+ return s.difference(this, e3);
1059
+ } }, { key: "add", value: function(e3) {
1060
+ return s.add(this, e3);
1061
+ } }, { key: "subtract", value: function(e3) {
1062
+ return s.subtract(this, e3);
1063
+ } }, { key: "multiply", value: function(e3) {
1064
+ return s.multiply(this, e3);
1065
+ } }, { key: "divide", value: function(e3) {
1066
+ return s.divide(this, e3);
1067
+ } }, { key: "set", value: function(e3) {
1068
+ return s.set(this, g(e3));
1069
+ } }, { key: "value", value: function() {
1070
+ return this._value;
1071
+ } }, { key: "valueOf", value: function() {
1072
+ return this._value;
1073
+ } }]) && i(e2.prototype, r2), n2 && i(e2, n2), t2;
1074
+ }();
1075
+ function g(e2) {
1076
+ var t2 = e2;
1077
+ return p.isNumbro(e2) ? t2 = e2._value : "string" == typeof e2 ? t2 = p.unformat(e2) : isNaN(e2) && (t2 = NaN), t2;
1078
+ }
1079
+ function p(e2) {
1080
+ return new f(g(e2));
1081
+ }
1082
+ p.version = "2.3.6", p.isNumbro = function(e2) {
1083
+ return e2 instanceof f;
1084
+ }, p.language = a.currentLanguage, p.registerLanguage = a.registerLanguage, p.setLanguage = a.setLanguage, p.languages = a.languages, p.languageData = a.languageData, p.zeroFormat = a.setZeroFormat, p.defaultFormat = a.currentDefaults, p.setDefaults = a.setDefaults, p.defaultCurrencyFormat = a.currentCurrencyDefaultFormat, p.validate = n.validate, p.loadLanguagesInNode = o.loadLanguagesInNode, p.unformat = u.unformat, p.BigNumber = s.BigNumber, t.exports = p;
1085
+ }, { "./formatting": 3, "./globalState": 4, "./loading": 5, "./manipulating": 6, "./parsing": 8, "./unformatting": 9, "./validating": 10 }], 8: [function(e, t, r) {
1086
+ "use strict";
1087
+ t.exports = { parseFormat: function(e2) {
1088
+ var t2, r2, n, i, a, o, u, c, s, l, f, g, p, d, h, v, m, y, b, w, S, O, x = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : {};
1089
+ return "string" != typeof e2 ? e2 : (r2 = x, e2 = (n = (t2 = e2).match(/^{([^}]*)}/)) ? (r2.prefix = n[1], t2.slice(n[0].length)) : t2, a = x, function(e3, t3) {
1090
+ if (-1 === e3.indexOf("$")) {
1091
+ if (-1 === e3.indexOf("%"))
1092
+ return -1 !== e3.indexOf("bd") ? (t3.output = "byte", t3.base = "general") : -1 !== e3.indexOf("b") ? (t3.output = "byte", t3.base = "binary") : -1 !== e3.indexOf("d") ? (t3.output = "byte", t3.base = "decimal") : -1 === e3.indexOf(":") ? -1 !== e3.indexOf("o") && (t3.output = "ordinal") : t3.output = "time";
1093
+ t3.output = "percent";
1094
+ } else
1095
+ t3.output = "currency";
1096
+ }(e2 = (o = (i = e2).match(/{([^}]*)}$/)) ? (a.postfix = o[1], i.slice(0, -o[0].length)) : i, x), u = x, (c = e2.match(/[1-9]+[0-9]*/)) && (u.totalLength = +c[0]), s = x, (l = e2.split(".")[0].match(/0+/)) && (s.characteristic = l[0].length), function(e3, t3) {
1097
+ if (-1 !== e3.indexOf(".")) {
1098
+ var r3 = e3.split(".")[0];
1099
+ t3.optionalCharacteristic = -1 === r3.indexOf("0");
1100
+ }
1101
+ }(e2, x), f = x, -1 !== e2.indexOf("a") && (f.average = true), p = x, -1 !== (g = e2).indexOf("K") ? p.forceAverage = "thousand" : -1 !== g.indexOf("M") ? p.forceAverage = "million" : -1 !== g.indexOf("B") ? p.forceAverage = "billion" : -1 !== g.indexOf("T") && (p.forceAverage = "trillion"), function(e3, t3) {
1102
+ var r3 = e3.split(".")[1];
1103
+ if (r3) {
1104
+ var n2 = r3.match(/0+/);
1105
+ n2 && (t3.mantissa = n2[0].length);
1106
+ }
1107
+ }(e2, x), h = x, (d = e2).match(/\[\.]/) ? h.optionalMantissa = true : d.match(/\./) && (h.optionalMantissa = false), v = x, (m = e2.split(".")[1]) && (v.trimMantissa = -1 !== m.indexOf("[")), y = x, -1 !== e2.indexOf(",") && (y.thousandSeparated = true), b = x, -1 !== e2.indexOf(" ") && (b.spaceSeparated = true, b.spaceSeparatedCurrency = true, (b.average || b.forceAverage) && (b.spaceSeparatedAbbreviation = true)), S = x, (w = e2).match(/^\+?\([^)]*\)$/) && (S.negative = "parenthesis"), w.match(/^\+?-/) && (S.negative = "sign"), O = x, e2.match(/^\+/) && (O.forceSign = true), x);
1108
+ } };
1109
+ }, {}], 9: [function(g, e, t) {
1110
+ "use strict";
1111
+ var M = [{ key: "ZiB", factor: Math.pow(1024, 7) }, { key: "ZB", factor: Math.pow(1e3, 7) }, { key: "YiB", factor: Math.pow(1024, 8) }, { key: "YB", factor: Math.pow(1e3, 8) }, { key: "TiB", factor: Math.pow(1024, 4) }, { key: "TB", factor: Math.pow(1e3, 4) }, { key: "PiB", factor: Math.pow(1024, 5) }, { key: "PB", factor: Math.pow(1e3, 5) }, { key: "MiB", factor: Math.pow(1024, 2) }, { key: "MB", factor: Math.pow(1e3, 2) }, { key: "KiB", factor: Math.pow(1024, 1) }, { key: "KB", factor: Math.pow(1e3, 1) }, { key: "GiB", factor: Math.pow(1024, 3) }, { key: "GB", factor: Math.pow(1e3, 3) }, { key: "EiB", factor: Math.pow(1024, 6) }, { key: "EB", factor: Math.pow(1e3, 6) }, { key: "B", factor: 1 }];
1112
+ function A(e2) {
1113
+ return e2.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
1114
+ }
1115
+ function p(e2, t2, r, n, i, a, o) {
1116
+ var u = 2 < arguments.length && void 0 !== r ? r : "", c = 3 < arguments.length ? n : void 0, s = 4 < arguments.length ? i : void 0, l = 5 < arguments.length ? a : void 0, f = 6 < arguments.length ? o : void 0;
1117
+ if ("" !== e2)
1118
+ return e2 === s ? 0 : function e3(t3, r2, n2, i2, a2, o2, u2) {
1119
+ var c2 = 2 < arguments.length && void 0 !== n2 ? n2 : "", s2 = 3 < arguments.length ? i2 : void 0, l2 = 4 < arguments.length ? a2 : void 0, f2 = 5 < arguments.length ? o2 : void 0, g2 = 6 < arguments.length ? u2 : void 0;
1120
+ if (!isNaN(+t3))
1121
+ return +t3;
1122
+ var p2 = "", d = t3.replace(/(^[^(]*)\((.*)\)([^)]*$)/, "$1$2$3");
1123
+ if (d !== t3)
1124
+ return -1 * e3(d, r2, c2, s2, l2, f2, g2);
1125
+ for (var h = 0; h < M.length; h++) {
1126
+ var v = M[h];
1127
+ if ((p2 = t3.replace(RegExp("([0-9 ])(".concat(v.key, ")$")), "$1")) !== t3)
1128
+ return e3(p2, r2, c2, s2, l2, f2, g2) * v.factor;
1129
+ }
1130
+ if ((p2 = t3.replace("%", "")) !== t3)
1131
+ return e3(p2, r2, c2, s2, l2, f2, g2) / 100;
1132
+ var m = parseFloat(t3);
1133
+ if (!isNaN(m)) {
1134
+ var y = s2(m);
1135
+ if (y && "." !== y && (p2 = t3.replace(new RegExp("".concat(A(y), "$")), "")) !== t3)
1136
+ return e3(p2, r2, c2, s2, l2, f2, g2);
1137
+ var b = {};
1138
+ Object.keys(f2).forEach(function(e4) {
1139
+ b[f2[e4]] = e4;
1140
+ });
1141
+ for (var w = Object.keys(b).sort().reverse(), S = w.length, O = 0; O < S; O++) {
1142
+ var x = w[O], N = b[x];
1143
+ if ((p2 = t3.replace(x, "")) !== t3) {
1144
+ var B = void 0;
1145
+ switch (N) {
1146
+ case "thousand":
1147
+ B = Math.pow(10, 3);
1148
+ break;
1149
+ case "million":
1150
+ B = Math.pow(10, 6);
1151
+ break;
1152
+ case "billion":
1153
+ B = Math.pow(10, 9);
1154
+ break;
1155
+ case "trillion":
1156
+ B = Math.pow(10, 12);
1157
+ }
1158
+ return e3(p2, r2, c2, s2, l2, f2, g2) * B;
1159
+ }
1160
+ }
1161
+ }
1162
+ }(function(e3, t3, r2) {
1163
+ var n2 = 2 < arguments.length && void 0 !== r2 ? r2 : "", i2 = e3.replace(n2, "");
1164
+ return i2 = (i2 = i2.replace(new RegExp("([0-9])".concat(A(t3.thousands), "([0-9])"), "g"), "$1$2")).replace(t3.decimal, ".");
1165
+ }(e2, t2, u), t2, u, c, s, l, f);
1166
+ }
1167
+ e.exports = { unformat: function(e2, t2) {
1168
+ var r, n, i, a = g("./globalState"), o = a.currentDelimiters(), u = a.currentCurrency().symbol, c = a.currentOrdinal(), s = a.getZeroFormat(), l = a.currentAbbreviations(), f = void 0;
1169
+ if ("string" == typeof e2)
1170
+ f = function(e3, t3) {
1171
+ if (e3.indexOf(":") && ":" !== t3.thousands) {
1172
+ var r2 = e3.split(":");
1173
+ if (3 === r2.length) {
1174
+ var n2 = +r2[0], i2 = +r2[1], a2 = +r2[2];
1175
+ return !isNaN(n2) && !isNaN(i2) && !isNaN(a2);
1176
+ }
1177
+ }
1178
+ }(e2, o) ? (r = e2.split(":"), n = +r[0], i = +r[1], +r[2] + 60 * i + 3600 * n) : p(e2, o, u, c, s, l, t2);
1179
+ else {
1180
+ if ("number" != typeof e2)
1181
+ return;
1182
+ f = e2;
1183
+ }
1184
+ if (void 0 !== f)
1185
+ return f;
1186
+ } };
1187
+ }, { "./globalState": 4 }], 10: [function(e, t, r) {
1188
+ "use strict";
1189
+ function n(e2) {
1190
+ return function(e3) {
1191
+ if (Array.isArray(e3)) {
1192
+ for (var t2 = 0, r2 = new Array(e3.length); t2 < e3.length; t2++)
1193
+ r2[t2] = e3[t2];
1194
+ return r2;
1195
+ }
1196
+ }(e2) || function(e3) {
1197
+ if (Symbol.iterator in Object(e3) || "[object Arguments]" === Object.prototype.toString.call(e3))
1198
+ return Array.from(e3);
1199
+ }(e2) || function() {
1200
+ throw new TypeError("Invalid attempt to spread non-iterable instance");
1201
+ }();
1202
+ }
1203
+ function f(e2) {
1204
+ return (f = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e3) {
1205
+ return typeof e3;
1206
+ } : function(e3) {
1207
+ return e3 && "function" == typeof Symbol && e3.constructor === Symbol && e3 !== Symbol.prototype ? "symbol" : typeof e3;
1208
+ })(e2);
1209
+ }
1210
+ var i = e("./unformatting"), a = /^[a-z]{2,3}(-[a-zA-Z]{4})?(-([A-Z]{2}|[0-9]{3}))?$/, g = { output: { type: "string", validValues: ["currency", "percent", "byte", "time", "ordinal", "number"] }, base: { type: "string", validValues: ["decimal", "binary", "general"], restriction: function(e2, t2) {
1211
+ return "byte" === t2.output;
1212
+ }, message: "`base` must be provided only when the output is `byte`", mandatory: function(e2) {
1213
+ return "byte" === e2.output;
1214
+ } }, characteristic: { type: "number", restriction: function(e2) {
1215
+ return 0 <= e2;
1216
+ }, message: "value must be positive" }, prefix: "string", postfix: "string", forceAverage: { type: "string", validValues: ["trillion", "billion", "million", "thousand"] }, average: "boolean", lowPrecision: { type: "boolean", restriction: function(e2, t2) {
1217
+ return true === t2.average;
1218
+ }, message: "`lowPrecision` must be provided only when the option `average` is set" }, currencyPosition: { type: "string", validValues: ["prefix", "infix", "postfix"] }, currencySymbol: "string", totalLength: { type: "number", restrictions: [{ restriction: function(e2) {
1219
+ return 0 <= e2;
1220
+ }, message: "value must be positive" }, { restriction: function(e2, t2) {
1221
+ return !t2.exponential;
1222
+ }, message: "`totalLength` is incompatible with `exponential`" }] }, mantissa: { type: "number", restriction: function(e2) {
1223
+ return 0 <= e2;
1224
+ }, message: "value must be positive" }, optionalMantissa: "boolean", trimMantissa: "boolean", roundingFunction: "function", optionalCharacteristic: "boolean", thousandSeparated: "boolean", spaceSeparated: "boolean", spaceSeparatedCurrency: "boolean", spaceSeparatedAbbreviation: "boolean", abbreviations: { type: "object", children: { thousand: "string", million: "string", billion: "string", trillion: "string" } }, negative: { type: "string", validValues: ["sign", "parenthesis"] }, forceSign: "boolean", exponential: { type: "boolean" }, prefixSymbol: { type: "boolean", restriction: function(e2, t2) {
1225
+ return "percent" === t2.output;
1226
+ }, message: "`prefixSymbol` can be provided only when the output is `percent`" } }, o = { languageTag: { type: "string", mandatory: true, restriction: function(e2) {
1227
+ return e2.match(a);
1228
+ }, message: "the language tag must follow the BCP 47 specification (see https://tools.ieft.org/html/bcp47)" }, delimiters: { type: "object", children: { thousands: "string", decimal: "string", thousandsSize: "number" }, mandatory: true }, abbreviations: { type: "object", children: { thousand: { type: "string", mandatory: true }, million: { type: "string", mandatory: true }, billion: { type: "string", mandatory: true }, trillion: { type: "string", mandatory: true } }, mandatory: true }, spaceSeparated: "boolean", spaceSeparatedCurrency: "boolean", ordinal: { type: "function", mandatory: true }, bytes: { type: "object", children: { binarySuffixes: "object", decimalSuffixes: "object" } }, currency: { type: "object", children: { symbol: "string", position: "string", code: "string" }, mandatory: true }, defaults: "format", ordinalFormat: "format", byteFormat: "format", percentageFormat: "format", currencyFormat: "format", timeDefaults: "format", formats: { type: "object", children: { fourDigits: { type: "format", mandatory: true }, fullWithTwoDecimals: { type: "format", mandatory: true }, fullWithTwoDecimalsNoCurrency: { type: "format", mandatory: true }, fullWithNoDecimals: { type: "format", mandatory: true } } } };
1229
+ function u(e2) {
1230
+ return void 0 !== i.unformat(e2);
1231
+ }
1232
+ function p(c2, s, l, e2) {
1233
+ var t2 = 3 < arguments.length && void 0 !== e2 && e2, r2 = Object.keys(c2).map(function(e3) {
1234
+ if (!s[e3])
1235
+ return console.error("".concat(l, " Invalid key: ").concat(e3)), false;
1236
+ var t3 = c2[e3], r3 = s[e3];
1237
+ if ("string" == typeof r3 && (r3 = { type: r3 }), "format" === r3.type) {
1238
+ if (!p(t3, g, "[Validate ".concat(e3, "]"), true))
1239
+ return false;
1240
+ } else if (f(t3) !== r3.type)
1241
+ return console.error("".concat(l, " ").concat(e3, ' type mismatched: "').concat(r3.type, '" expected, "').concat(f(t3), '" provided')), false;
1242
+ if (r3.restrictions && r3.restrictions.length)
1243
+ for (var n2 = r3.restrictions.length, i2 = 0; i2 < n2; i2++) {
1244
+ var a2 = r3.restrictions[i2], o2 = a2.restriction, u2 = a2.message;
1245
+ if (!o2(t3, c2))
1246
+ return console.error("".concat(l, " ").concat(e3, " invalid value: ").concat(u2)), false;
1247
+ }
1248
+ if (r3.restriction && !r3.restriction(t3, c2))
1249
+ return console.error("".concat(l, " ").concat(e3, " invalid value: ").concat(r3.message)), false;
1250
+ if (r3.validValues && -1 === r3.validValues.indexOf(t3))
1251
+ return console.error("".concat(l, " ").concat(e3, " invalid value: must be among ").concat(JSON.stringify(r3.validValues), ', "').concat(t3, '" provided')), false;
1252
+ if (r3.children && !p(t3, r3.children, "[Validate ".concat(e3, "]")))
1253
+ return false;
1254
+ return true;
1255
+ });
1256
+ return t2 || r2.push.apply(r2, n(Object.keys(s).map(function(e3) {
1257
+ var t3 = s[e3];
1258
+ if ("string" == typeof t3 && (t3 = { type: t3 }), t3.mandatory) {
1259
+ var r3 = t3.mandatory;
1260
+ if ("function" == typeof r3 && (r3 = r3(c2)), r3 && void 0 === c2[e3])
1261
+ return console.error("".concat(l, ' Missing mandatory key "').concat(e3, '"')), false;
1262
+ }
1263
+ return true;
1264
+ }))), r2.reduce(function(e3, t3) {
1265
+ return e3 && t3;
1266
+ }, true);
1267
+ }
1268
+ function c(e2) {
1269
+ return p(e2, g, "[Validate format]");
1270
+ }
1271
+ t.exports = { validate: function(e2, t2) {
1272
+ var r2 = u(e2), n2 = c(t2);
1273
+ return r2 && n2;
1274
+ }, validateFormat: c, validateInput: u, validateLanguage: function(e2) {
1275
+ return p(e2, o, "[Validate language]");
1276
+ } };
1277
+ }, { "./unformatting": 9 }] }, {}, [7])(7);
1278
+ });
1279
+ }
1280
+ });
1281
+
1282
+ // src/index.ts
1283
+ var src_exports = {};
1284
+ __export(src_exports, {
1285
+ useAmountPrice: () => useAmountPrice,
1286
+ useAutoSlippage: () => useAutoSlippage,
1287
+ useBrowserDetect: () => useBrowserDetect,
1288
+ useClipboard: () => useClipboard,
1289
+ useCoreConfig: () => useCoreConfig,
1290
+ useDebounce: () => useDebounce,
1291
+ useInputErrors: () => useInputErrors,
1292
+ useIsChainSupported: () => useIsChainSupported,
1293
+ useIsDev: () => useIsDev,
1294
+ useLocalStorageState: () => useLocalStorageState,
1295
+ useMainnetConfig: () => useMainnetConfig,
1296
+ useUserAccount: () => useUserAccount
1297
+ });
1298
+ module.exports = __toCommonJS(src_exports);
1299
+
1300
+ // src/ui/useClipboard.ts
1301
+ var import_react = require("react");
1302
+ var useClipboard = () => {
1303
+ const [isCopied, setIsCopied] = (0, import_react.useState)(false);
1304
+ const copyToClipboard = (text) => {
1305
+ setIsCopied(true);
1306
+ navigator.clipboard.writeText(text);
1307
+ setTimeout(() => setIsCopied(false), 1e3);
1308
+ };
1309
+ return { isCopied, copyToClipboard };
1310
+ };
1311
+
1312
+ // src/ui/useInputErrors.ts
1313
+ var import_react2 = require("react");
1314
+ var useInputErrors = (balance, amount) => {
1315
+ const hasError = (0, import_react2.useMemo)(() => {
1316
+ if (parseFloat(amount) < 0)
1317
+ return true;
1318
+ if (balance)
1319
+ return parseFloat(amount) > parseFloat(balance);
1320
+ }, [amount, balance]);
1321
+ const inputMsg = (0, import_react2.useMemo)(() => {
1322
+ if (!amount || parseFloat(amount) === 0) {
1323
+ return "Enter an amount";
1324
+ }
1325
+ if (parseFloat(amount) < 0) {
1326
+ return "Invalid amount";
1327
+ }
1328
+ if (balance) {
1329
+ if (parseFloat(amount) > parseFloat(balance)) {
1330
+ return "Insufficient balance";
1331
+ }
1332
+ }
1333
+ }, [amount, balance]);
1334
+ return { hasError, inputMsg };
1335
+ };
1336
+
1337
+ // src/web3/useCoreConfig.ts
1338
+ var import_config = require("@tokemak/config");
1339
+ var import_react3 = require("react");
1340
+ var import_chains = require("viem/chains");
1341
+ var import_wagmi = require("wagmi");
1342
+ var useCoreConfig = (chainId) => {
1343
+ const { chain } = (0, import_wagmi.useAccount)();
1344
+ const tokemakConfig = (0, import_react3.useMemo)(() => {
1345
+ if (chainId && (0, import_config.isSupportedChainId)(chainId)) {
1346
+ return (0, import_config.getCoreConfig)(chainId);
1347
+ }
1348
+ if (chain && (0, import_config.isSupportedChainId)(chain.id)) {
1349
+ return (0, import_config.getCoreConfig)(chain.id);
1350
+ }
1351
+ return (0, import_config.getCoreConfig)(import_chains.mainnet.id);
1352
+ }, [chain, chainId]);
1353
+ return tokemakConfig;
1354
+ };
1355
+
1356
+ // src/web3/useUserAccount.tsx
1357
+ var import_react4 = require("react");
1358
+ var import_utils = require("@tokemak/utils");
1359
+ var import_wagmi2 = require("wagmi");
1360
+ var useUserAccount = () => {
1361
+ const { address } = (0, import_wagmi2.useAccount)();
1362
+ const { data: ensName } = (0, import_wagmi2.useEnsName)({ address });
1363
+ const { data: ensAvatar } = (0, import_wagmi2.useEnsAvatar)({ name: ensName || "" });
1364
+ const truncatedAddress = (0, import_react4.useMemo)(() => (0, import_utils.truncateAddress)(address), [address]);
1365
+ return { address, ensName, ensAvatar, truncatedAddress };
1366
+ };
1367
+
1368
+ // src/web3/useIsChainSupported.ts
1369
+ var import_react5 = require("react");
1370
+ var import_wagmi3 = require("wagmi");
1371
+ var useIsChainSupported = () => {
1372
+ const { chain } = (0, import_wagmi3.useAccount)();
1373
+ const { chains } = (0, import_wagmi3.useConfig)();
1374
+ const isChainSupported = (0, import_react5.useMemo)(
1375
+ () => chain && chains.some((item) => item.id === chain.id),
1376
+ [chain, chains]
1377
+ );
1378
+ return !!isChainSupported;
1379
+ };
1380
+
1381
+ // src/web3/useMainnetConfig.ts
1382
+ var import_config2 = require("@tokemak/config");
1383
+ var import_react6 = require("react");
1384
+ var import_wagmi4 = require("wagmi");
1385
+ var useMainnetConfig = () => {
1386
+ const { chain } = (0, import_wagmi4.useAccount)();
1387
+ const config = (0, import_react6.useMemo)(() => {
1388
+ if (chain === void 0) {
1389
+ return import_config2.mainnetConfig;
1390
+ } else {
1391
+ return import_config2.mainnetConfig;
1392
+ }
1393
+ }, [chain]);
1394
+ return config;
1395
+ };
1396
+
1397
+ // src/web3/useAmountPrice.ts
1398
+ var import_utils2 = require("@tokemak/utils");
1399
+ var import_numbro = __toESM(require_numbro_min());
1400
+ var import_react7 = require("react");
1401
+ var useAmountPrice = (amount, price) => {
1402
+ return (0, import_react7.useMemo)(
1403
+ () => amount && price ? (0, import_utils2.formatCurrency)(parseFloat(amount) * price) : (0, import_numbro.default)(0).formatCurrency({ mantissa: 2 }),
1404
+ [amount, price]
1405
+ );
1406
+ };
1407
+
1408
+ // src/web3/useAutoSlippage.ts
1409
+ var import_react8 = require("react");
1410
+ var MAX_SLIPPAGE_DEFAULT = 0.02;
1411
+ var MARGIN_DEFAULT = 2e-3;
1412
+ var DEFAULT_SLIPPAGE = 5e-3;
1413
+ var calculateAutoSlippage = (priceImpact, margin, maxSlippage) => {
1414
+ const slippage = priceImpact + margin;
1415
+ return Math.min(slippage, maxSlippage);
1416
+ };
1417
+ var useAutoSlippage = ({
1418
+ estimatedPriceImpact,
1419
+ maxSlippage = MAX_SLIPPAGE_DEFAULT,
1420
+ margin = MARGIN_DEFAULT,
1421
+ defaultSlippage = DEFAULT_SLIPPAGE
1422
+ }) => {
1423
+ const autoSlippage = (0, import_react8.useMemo)(() => {
1424
+ if (estimatedPriceImpact !== void 0 && !isNaN(estimatedPriceImpact)) {
1425
+ return calculateAutoSlippage(estimatedPriceImpact, margin, maxSlippage);
1426
+ }
1427
+ return defaultSlippage;
1428
+ }, [estimatedPriceImpact]);
1429
+ return autoSlippage;
1430
+ };
1431
+
1432
+ // src/utils/useDebounce.ts
1433
+ var import_react9 = require("react");
1434
+ var useDebounce = (value, delay) => {
1435
+ const [debouncedValue, setDebouncedValue] = (0, import_react9.useState)(value);
1436
+ const [isLoading, setIsLoading] = (0, import_react9.useState)(false);
1437
+ (0, import_react9.useEffect)(() => {
1438
+ setIsLoading(true);
1439
+ const handler = setTimeout(() => {
1440
+ setDebouncedValue(value);
1441
+ setIsLoading(false);
1442
+ }, delay);
1443
+ return () => {
1444
+ clearTimeout(handler);
1445
+ setIsLoading(false);
1446
+ };
1447
+ }, [value, delay]);
1448
+ return [debouncedValue, isLoading];
1449
+ };
1450
+
1451
+ // src/utils/useLocalStorageState.ts
1452
+ var import_react10 = require("react");
1453
+ function useLocalStorageState(key, defaultValue) {
1454
+ const [state, setState] = (0, import_react10.useState)(() => {
1455
+ try {
1456
+ const localStorageValue = localStorage.getItem(key);
1457
+ return localStorageValue !== null ? JSON.parse(localStorageValue) : defaultValue;
1458
+ } catch (error) {
1459
+ console.error("Error reading localStorage key", key, error);
1460
+ return defaultValue;
1461
+ }
1462
+ });
1463
+ (0, import_react10.useEffect)(() => {
1464
+ try {
1465
+ localStorage.setItem(key, JSON.stringify(state));
1466
+ } catch (error) {
1467
+ console.error("Error setting localStorage key", key, error);
1468
+ }
1469
+ }, [key, state]);
1470
+ return [state, setState];
1471
+ }
1472
+
1473
+ // src/utils/useIsDev.ts
1474
+ var useIsDev = () => {
1475
+ return process.env.NEXT_PUBLIC_ENV === "development";
1476
+ };
1477
+
1478
+ // src/utils/useBrowserDetect.ts
1479
+ var import_react11 = require("react");
1480
+ var useBrowserDetect = () => {
1481
+ const [isChrome, setIsChrome] = (0, import_react11.useState)(false);
1482
+ const [isSafari, setIsSafari] = (0, import_react11.useState)(false);
1483
+ const [isFirefox, setIsFirefox] = (0, import_react11.useState)(false);
1484
+ const [isEdge, setIsEdge] = (0, import_react11.useState)(false);
1485
+ const [isOpera, setIsOpera] = (0, import_react11.useState)(false);
1486
+ const [isIE, setIsIE] = (0, import_react11.useState)(false);
1487
+ const [isIOS, setIsIOS] = (0, import_react11.useState)(false);
1488
+ const [isAndroid, setIsAndroid] = (0, import_react11.useState)(false);
1489
+ const [isWindows, setIsWindows] = (0, import_react11.useState)(false);
1490
+ const [isMacOS, setIsMacOS] = (0, import_react11.useState)(false);
1491
+ const [isLinux, setIsLinux] = (0, import_react11.useState)(false);
1492
+ (0, import_react11.useEffect)(() => {
1493
+ const userAgent = navigator.userAgent;
1494
+ setIsChrome(
1495
+ /chrome|crios/i.test(userAgent) && !/edge|opr\//i.test(userAgent)
1496
+ );
1497
+ setIsSafari(
1498
+ /^((?!chrome|android).)*safari/i.test(userAgent) && !/crios|edgios|fxios/i.test(userAgent)
1499
+ );
1500
+ setIsFirefox(/firefox|fxios/i.test(userAgent));
1501
+ setIsEdge(/edg/i.test(userAgent));
1502
+ setIsOpera(/opr\//i.test(userAgent));
1503
+ setIsIE(/msie|trident/i.test(userAgent));
1504
+ setIsIOS(
1505
+ /iPad|iPhone|iPod/.test(userAgent) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1
1506
+ );
1507
+ setIsAndroid(/android/i.test(userAgent));
1508
+ setIsWindows(/win/i.test(userAgent));
1509
+ setIsMacOS(
1510
+ /mac/i.test(navigator.platform) && !/iPhone|iPad|iPod/.test(userAgent)
1511
+ );
1512
+ setIsLinux(/linux/i.test(userAgent) && !/android/i.test(userAgent));
1513
+ }, []);
1514
+ return {
1515
+ isChrome,
1516
+ isSafari,
1517
+ isFirefox,
1518
+ isEdge,
1519
+ isOpera,
1520
+ isIE,
1521
+ isIOS,
1522
+ isAndroid,
1523
+ isWindows,
1524
+ isMacOS,
1525
+ isLinux
1526
+ };
1527
+ };
1528
+ // Annotate the CommonJS export names for ESM import in node:
1529
+ 0 && (module.exports = {
1530
+ useAmountPrice,
1531
+ useAutoSlippage,
1532
+ useBrowserDetect,
1533
+ useClipboard,
1534
+ useCoreConfig,
1535
+ useDebounce,
1536
+ useInputErrors,
1537
+ useIsChainSupported,
1538
+ useIsDev,
1539
+ useLocalStorageState,
1540
+ useMainnetConfig,
1541
+ useUserAccount
1542
+ });