UNPKG

@atlantis-l/radix-tool

Version:

A tool to interact with the radix network

1,187 lines (1,186 loc) 7.18 MB
var Po = Object.defineProperty; var vo = (A, I, Q) => I in A ? Po(A, I, { enumerable: !0, configurable: !0, writable: !0, value: Q }) : A[I] = Q; var eI = (A, I, Q) => (vo(A, typeof I != "symbol" ? I + "" : I, Q), Q); var _o = Object.defineProperty, $o = (A, I, Q) => I in A ? _o(A, I, { enumerable: !0, configurable: !0, writable: !0, value: Q }) : A[I] = Q, T = (A, I, Q) => ($o(A, typeof I != "symbol" ? I + "" : I, Q), Q), Cg, oE, ME, GE, aE, kE; /*! * decimal.js v10.4.3 * An arbitrary-precision Decimal type for JavaScript. * https://github.com/MikeMcl/decimal.js * Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com> * MIT Licence */ var dB = 9e15, DB = 1e9, eE = "0123456789abcdef", QC = "2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058", BC = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789", pE = { // These values must be integers within the stated ranges (inclusive). // Most of these values can be changed at run-time using the `Decimal.config` method. // The maximum number of significant digits of the result of a calculation or base conversion. // E.g. `Decimal.config({ precision: 20 });` precision: 20, // 1 to MAX_DIGITS // The rounding mode used when rounding to `precision`. // // ROUND_UP 0 Away from zero. // ROUND_DOWN 1 Towards zero. // ROUND_CEIL 2 Towards +Infinity. // ROUND_FLOOR 3 Towards -Infinity. // ROUND_HALF_UP 4 Towards nearest neighbour. If equidistant, up. // ROUND_HALF_DOWN 5 Towards nearest neighbour. If equidistant, down. // ROUND_HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour. // ROUND_HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity. // ROUND_HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity. // // E.g. // `Decimal.rounding = 4;` // `Decimal.rounding = Decimal.ROUND_HALF_UP;` rounding: 4, // 0 to 8 // The modulo mode used when calculating the modulus: a mod n. // The quotient (q = a / n) is calculated according to the corresponding rounding mode. // The remainder (r) is calculated as: r = a - n * q. // // UP 0 The remainder is positive if the dividend is negative, else is negative. // DOWN 1 The remainder has the same sign as the dividend (JavaScript %). // FLOOR 3 The remainder has the same sign as the divisor (Python %). // HALF_EVEN 6 The IEEE 754 remainder function. // EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)). Always positive. // // Truncated division (1), floored division (3), the IEEE 754 remainder (6), and Euclidian // division (9) are commonly used for the modulus operation. The other rounding modes can also // be used, but they may not give useful results. modulo: 1, // 0 to 9 // The exponent value at and beneath which `toString` returns exponential notation. // JavaScript numbers: -7 toExpNeg: -7, // 0 to -EXP_LIMIT // The exponent value at and above which `toString` returns exponential notation. // JavaScript numbers: 21 toExpPos: 21, // 0 to EXP_LIMIT // The minimum exponent value, beneath which underflow to zero occurs. // JavaScript numbers: -324 (5e-324) minE: -dB, // -1 to -EXP_LIMIT // The maximum exponent value, above which overflow to Infinity occurs. // JavaScript numbers: 308 (1.7976931348623157e+308) maxE: dB, // 1 to EXP_LIMIT // Whether to use cryptographically-secure random number generation, if available. crypto: !1 // true/false }, li, tQ, oA = !0, sC = "[DecimalError] ", QB = sC + "Invalid argument: ", fi = sC + "Precision limit exceeded", ji = sC + "crypto unavailable", xi = "[object Decimal]", OI = Math.floor, aI = Math.pow, AM = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i, IM = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i, QM = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i, Zi = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i, EQ = 1e7, DA = 7, BM = 9007199254740991, gM = QC.length - 1, dE = BC.length - 1, x = { toStringTag: xi }; x.absoluteValue = x.abs = function() { var A = new this.constructor(this); return A.s < 0 && (A.s = 1), IA(A); }; x.ceil = function() { return IA(new this.constructor(this), this.e + 1, 2); }; x.clampedTo = x.clamp = function(A, I) { var Q, B = this, g = B.constructor; if (A = new g(A), I = new g(I), !A.s || !I.s) return new g(NaN); if (A.gt(I)) throw Error(QB + I); return Q = B.cmp(A), Q < 0 ? A : B.cmp(I) > 0 ? I : new g(B); }; x.comparedTo = x.cmp = function(A) { var I, Q, B, g, C = this, E = C.d, D = (A = new C.constructor(A)).d, i = C.s, w = A.s; if (!E || !D) return !i || !w ? NaN : i !== w ? i : E === D ? 0 : !E ^ i < 0 ? 1 : -1; if (!E[0] || !D[0]) return E[0] ? i : D[0] ? -w : 0; if (i !== w) return i; if (C.e !== A.e) return C.e > A.e ^ i < 0 ? 1 : -1; for (B = E.length, g = D.length, I = 0, Q = B < g ? B : g; I < Q; ++I) if (E[I] !== D[I]) return E[I] > D[I] ^ i < 0 ? 1 : -1; return B === g ? 0 : B > g ^ i < 0 ? 1 : -1; }; x.cosine = x.cos = function() { var A, I, Q = this, B = Q.constructor; return Q.d ? Q.d[0] ? (A = B.precision, I = B.rounding, B.precision = A + Math.max(Q.e, Q.sd()) + DA, B.rounding = 1, Q = CM(B, ui(B, Q)), B.precision = A, B.rounding = I, IA(tQ == 2 || tQ == 3 ? Q.neg() : Q, A, I, !0)) : new B(1) : new B(NaN); }; x.cubeRoot = x.cbrt = function() { var A, I, Q, B, g, C, E, D, i, w, o = this, a = o.constructor; if (!o.isFinite() || o.isZero()) return new a(o); for (oA = !1, C = o.s * aI(o.s * o, 1 / 3), !C || Math.abs(C) == 1 / 0 ? (Q = qI(o.d), A = o.e, (C = (A - Q.length + 1) % 3) && (Q += C == 1 || C == -2 ? "0" : "00"), C = aI(Q, 1 / 3), A = OI((A + 1) / 3) - (A % 3 == (A < 0 ? -1 : 2)), C == 1 / 0 ? Q = "5e" + A : (Q = C.toExponential(), Q = Q.slice(0, Q.indexOf("e") + 1) + A), B = new a(Q), B.s = o.s) : B = new a(C.toString()), E = (A = a.precision) + 3; ; ) if (D = B, i = D.times(D).times(D), w = i.plus(o), B = lA(w.plus(o).times(D), w.plus(i), E + 2, 1), qI(D.d).slice(0, E) === (Q = qI(B.d)).slice(0, E)) if (Q = Q.slice(E - 3, E + 1), Q == "9999" || !g && Q == "4999") { if (!g && (IA(D, A + 1, 0), D.times(D).times(D).eq(o))) { B = D; break; } E += 4, g = 1; } else { (!+Q || !+Q.slice(1) && Q.charAt(0) == "5") && (IA(B, A + 1, 1), I = !B.times(B).times(B).eq(o)); break; } return oA = !0, IA(B, A, a.rounding, I); }; x.decimalPlaces = x.dp = function() { var A, I = this.d, Q = NaN; if (I) { if (A = I.length - 1, Q = (A - OI(this.e / DA)) * DA, A = I[A], A) for (; A % 10 == 0; A /= 10) Q--; Q < 0 && (Q = 0); } return Q; }; x.dividedBy = x.div = function(A) { return lA(this, new this.constructor(A)); }; x.dividedToIntegerBy = x.divToInt = function(A) { var I = this, Q = I.constructor; return IA(lA(I, new Q(A), 0, 1, 1), Q.precision, Q.rounding); }; x.equals = x.eq = function(A) { return this.cmp(A) === 0; }; x.floor = function() { return IA(new this.constructor(this), this.e + 1, 3); }; x.greaterThan = x.gt = function(A) { return this.cmp(A) > 0; }; x.greaterThanOrEqualTo = x.gte = function(A) { var I = this.cmp(A); return I == 1 || I === 0; }; x.hyperbolicCosine = x.cosh = function() { var A, I, Q, B, g, C = this, E = C.constructor, D = new E(1); if (!C.isFinite()) return new E(C.s ? 1 / 0 : NaN); if (C.isZero()) return D; Q = E.precision, B = E.rounding, E.precision = Q + Math.max(C.e, C.sd()) + 4, E.rounding = 1, g = C.d.length, g < 32 ? (A = Math.ceil(g / 3), I = (1 / YC(4, A)).toString()) : (A = 16, I = "2.3283064365386962890625e-10"), C = fB(E, 1, C.times(I), new E(1), !0); for (var i, w = A, o = new E(8); w--; ) i = C.times(C), C = D.minus(i.times(o.minus(i.times(o)))); return IA(C, E.precision = Q, E.rounding = B, !0); }; x.hyperbolicSine = x.sinh = function() { var A, I, Q, B, g = this, C = g.constructor; if (!g.isFinite() || g.isZero()) return new C(g); if (I = C.precision, Q = C.rounding, C.precision = I + Math.max(g.e, g.sd()) + 4, C.rounding = 1, B = g.d.length, B < 3) g = fB(C, 2, g, g, !0); else { A = 1.4 * Math.sqrt(B), A = A > 16 ? 16 : A | 0, g = g.times(1 / YC(5, A)), g = fB(C, 2, g, g, !0); for (var E, D = new C(5), i = new C(16), w = new C(20); A--; ) E = g.times(g), g = g.times(D.plus(E.times(i.times(E).plus(w)))); } return C.precision = I, C.rounding = Q, IA(g, I, Q, !0); }; x.hyperbolicTangent = x.tanh = function() { var A, I, Q = this, B = Q.constructor; return Q.isFinite() ? Q.isZero() ? new B(Q) : (A = B.precision, I = B.rounding, B.precision = A + 7, B.rounding = 1, lA(Q.sinh(), Q.cosh(), B.precision = A, B.rounding = I)) : new B(Q.s); }; x.inverseCosine = x.acos = function() { var A, I = this, Q = I.constructor, B = I.abs().cmp(1), g = Q.precision, C = Q.rounding; return B !== -1 ? B === 0 ? I.isNeg() ? gQ(Q, g, C) : new Q(0) : new Q(NaN) : I.isZero() ? gQ(Q, g + 4, C).times(0.5) : (Q.precision = g + 6, Q.rounding = 1, I = I.asin(), A = gQ(Q, g + 4, C).times(0.5), Q.precision = g, Q.rounding = C, A.minus(I)); }; x.inverseHyperbolicCosine = x.acosh = function() { var A, I, Q = this, B = Q.constructor; return Q.lte(1) ? new B(Q.eq(1) ? 0 : NaN) : Q.isFinite() ? (A = B.precision, I = B.rounding, B.precision = A + Math.max(Math.abs(Q.e), Q.sd()) + 4, B.rounding = 1, oA = !1, Q = Q.times(Q).minus(1).sqrt().plus(Q), oA = !0, B.precision = A, B.rounding = I, Q.ln()) : new B(Q); }; x.inverseHyperbolicSine = x.asinh = function() { var A, I, Q = this, B = Q.constructor; return !Q.isFinite() || Q.isZero() ? new B(Q) : (A = B.precision, I = B.rounding, B.precision = A + 2 * Math.max(Math.abs(Q.e), Q.sd()) + 6, B.rounding = 1, oA = !1, Q = Q.times(Q).plus(1).sqrt().plus(Q), oA = !0, B.precision = A, B.rounding = I, Q.ln()); }; x.inverseHyperbolicTangent = x.atanh = function() { var A, I, Q, B, g = this, C = g.constructor; return g.isFinite() ? g.e >= 0 ? new C(g.abs().eq(1) ? g.s / 0 : g.isZero() ? g : NaN) : (A = C.precision, I = C.rounding, B = g.sd(), Math.max(B, A) < 2 * -g.e - 1 ? IA(new C(g), A, I, !0) : (C.precision = Q = B - g.e, g = lA(g.plus(1), new C(1).minus(g), Q + A, 1), C.precision = A + 4, C.rounding = 1, g = g.ln(), C.precision = A, C.rounding = I, g.times(0.5))) : new C(NaN); }; x.inverseSine = x.asin = function() { var A, I, Q, B, g = this, C = g.constructor; return g.isZero() ? new C(g) : (I = g.abs().cmp(1), Q = C.precision, B = C.rounding, I !== -1 ? I === 0 ? (A = gQ(C, Q + 4, B).times(0.5), A.s = g.s, A) : new C(NaN) : (C.precision = Q + 6, C.rounding = 1, g = g.div(new C(1).minus(g.times(g)).sqrt().plus(1)).atan(), C.precision = Q, C.rounding = B, g.times(2))); }; x.inverseTangent = x.atan = function() { var A, I, Q, B, g, C, E, D, i, w = this, o = w.constructor, a = o.precision, J = o.rounding; if (w.isFinite()) { if (w.isZero()) return new o(w); if (w.abs().eq(1) && a + 4 <= dE) return E = gQ(o, a + 4, J).times(0.25), E.s = w.s, E; } else { if (!w.s) return new o(NaN); if (a + 4 <= dE) return E = gQ(o, a + 4, J).times(0.5), E.s = w.s, E; } for (o.precision = D = a + 10, o.rounding = 1, Q = Math.min(28, D / DA + 2 | 0), A = Q; A; --A) w = w.div(w.times(w).plus(1).sqrt().plus(1)); for (oA = !1, I = Math.ceil(D / DA), B = 1, i = w.times(w), E = new o(w), g = w; A !== -1; ) if (g = g.times(i), C = E.minus(g.div(B += 2)), g = g.times(i), E = C.plus(g.div(B += 2)), E.d[I] !== void 0) for (A = I; E.d[A] === C.d[A] && A--; ) ; return Q && (E = E.times(2 << Q - 1)), oA = !0, IA(E, o.precision = a, o.rounding = J, !0); }; x.isFinite = function() { return !!this.d; }; x.isInteger = x.isInt = function() { return !!this.d && OI(this.e / DA) > this.d.length - 2; }; x.isNaN = function() { return !this.s; }; x.isNegative = x.isNeg = function() { return this.s < 0; }; x.isPositive = x.isPos = function() { return this.s > 0; }; x.isZero = function() { return !!this.d && this.d[0] === 0; }; x.lessThan = x.lt = function(A) { return this.cmp(A) < 0; }; x.lessThanOrEqualTo = x.lte = function(A) { return this.cmp(A) < 1; }; x.logarithm = x.log = function(A) { var I, Q, B, g, C, E, D, i, w = this, o = w.constructor, a = o.precision, J = o.rounding, Y = 5; if (A == null) A = new o(10), I = !0; else { if (A = new o(A), Q = A.d, A.s < 0 || !Q || !Q[0] || A.eq(1)) return new o(NaN); I = A.eq(10); } if (Q = w.d, w.s < 0 || !Q || !Q[0] || w.eq(1)) return new o(Q && !Q[0] ? -1 / 0 : w.s != 1 ? NaN : Q ? 0 : 1 / 0); if (I) if (Q.length > 1) C = !0; else { for (g = Q[0]; g % 10 === 0; ) g /= 10; C = g !== 1; } if (oA = !1, D = a + Y, E = $Q(w, D), B = I ? gC(o, D + 10) : $Q(A, D), i = lA(E, B, D, 1), hg(i.d, g = a, J)) do if (D += 10, E = $Q(w, D), B = I ? gC(o, D + 10) : $Q(A, D), i = lA(E, B, D, 1), !C) { +qI(i.d).slice(g + 1, g + 15) + 1 == 1e14 && (i = IA(i, a + 1, 0)); break; } while (hg(i.d, g += 10, J)); return oA = !0, IA(i, a, J); }; x.minus = x.sub = function(A) { var I, Q, B, g, C, E, D, i, w, o, a, J, Y = this, q = Y.constructor; if (A = new q(A), !Y.d || !A.d) return !Y.s || !A.s ? A = new q(NaN) : Y.d ? A.s = -A.s : A = new q(A.d || Y.s !== A.s ? Y : NaN), A; if (Y.s != A.s) return A.s = -A.s, Y.plus(A); if (w = Y.d, J = A.d, D = q.precision, i = q.rounding, !w[0] || !J[0]) { if (J[0]) A.s = -A.s; else if (w[0]) A = new q(Y); else return new q(i === 3 ? -0 : 0); return oA ? IA(A, D, i) : A; } if (Q = OI(A.e / DA), o = OI(Y.e / DA), w = w.slice(), C = o - Q, C) { for (a = C < 0, a ? (I = w, C = -C, E = J.length) : (I = J, Q = o, E = w.length), B = Math.max(Math.ceil(D / DA), E) + 2, C > B && (C = B, I.length = 1), I.reverse(), B = C; B--; ) I.push(0); I.reverse(); } else { for (B = w.length, E = J.length, a = B < E, a && (E = B), B = 0; B < E; B++) if (w[B] != J[B]) { a = w[B] < J[B]; break; } C = 0; } for (a && (I = w, w = J, J = I, A.s = -A.s), E = w.length, B = J.length - E; B > 0; --B) w[E++] = 0; for (B = J.length; B > C; ) { if (w[--B] < J[B]) { for (g = B; g && w[--g] === 0; ) w[g] = EQ - 1; --w[g], w[B] += EQ; } w[B] -= J[B]; } for (; w[--E] === 0; ) w.pop(); for (; w[0] === 0; w.shift()) --Q; return w[0] ? (A.d = w, A.e = cC(w, Q), oA ? IA(A, D, i) : A) : new q(i === 3 ? -0 : 0); }; x.modulo = x.mod = function(A) { var I, Q = this, B = Q.constructor; return A = new B(A), !Q.d || !A.s || A.d && !A.d[0] ? new B(NaN) : !A.d || Q.d && !Q.d[0] ? IA(new B(Q), B.precision, B.rounding) : (oA = !1, B.modulo == 9 ? (I = lA(Q, A.abs(), 0, 3, 1), I.s *= A.s) : I = lA(Q, A, 0, B.modulo, 1), I = I.times(A), oA = !0, Q.minus(I)); }; x.naturalExponential = x.exp = function() { return nE(this); }; x.naturalLogarithm = x.ln = function() { return $Q(this); }; x.negated = x.neg = function() { var A = new this.constructor(this); return A.s = -A.s, IA(A); }; x.plus = x.add = function(A) { var I, Q, B, g, C, E, D, i, w, o, a = this, J = a.constructor; if (A = new J(A), !a.d || !A.d) return !a.s || !A.s ? A = new J(NaN) : a.d || (A = new J(A.d || a.s === A.s ? a : NaN)), A; if (a.s != A.s) return A.s = -A.s, a.minus(A); if (w = a.d, o = A.d, D = J.precision, i = J.rounding, !w[0] || !o[0]) return o[0] || (A = new J(a)), oA ? IA(A, D, i) : A; if (C = OI(a.e / DA), B = OI(A.e / DA), w = w.slice(), g = C - B, g) { for (g < 0 ? (Q = w, g = -g, E = o.length) : (Q = o, B = C, E = w.length), C = Math.ceil(D / DA), E = C > E ? C + 1 : E + 1, g > E && (g = E, Q.length = 1), Q.reverse(); g--; ) Q.push(0); Q.reverse(); } for (E = w.length, g = o.length, E - g < 0 && (g = E, Q = o, o = w, w = Q), I = 0; g; ) I = (w[--g] = w[g] + o[g] + I) / EQ | 0, w[g] %= EQ; for (I && (w.unshift(I), ++B), E = w.length; w[--E] == 0; ) w.pop(); return A.d = w, A.e = cC(w, B), oA ? IA(A, D, i) : A; }; x.precision = x.sd = function(A) { var I, Q = this; if (A !== void 0 && A !== !!A && A !== 1 && A !== 0) throw Error(QB + A); return Q.d ? (I = Wi(Q.d), A && Q.e + 1 > I && (I = Q.e + 1)) : I = NaN, I; }; x.round = function() { var A = this, I = A.constructor; return IA(new I(A), A.e + 1, I.rounding); }; x.sine = x.sin = function() { var A, I, Q = this, B = Q.constructor; return Q.isFinite() ? Q.isZero() ? new B(Q) : (A = B.precision, I = B.rounding, B.precision = A + Math.max(Q.e, Q.sd()) + DA, B.rounding = 1, Q = DM(B, ui(B, Q)), B.precision = A, B.rounding = I, IA(tQ > 2 ? Q.neg() : Q, A, I, !0)) : new B(NaN); }; x.squareRoot = x.sqrt = function() { var A, I, Q, B, g, C, E = this, D = E.d, i = E.e, w = E.s, o = E.constructor; if (w !== 1 || !D || !D[0]) return new o(!w || w < 0 && (!D || D[0]) ? NaN : D ? E : 1 / 0); for (oA = !1, w = Math.sqrt(+E), w == 0 || w == 1 / 0 ? (I = qI(D), (I.length + i) % 2 == 0 && (I += "0"), w = Math.sqrt(I), i = OI((i + 1) / 2) - (i < 0 || i % 2), w == 1 / 0 ? I = "5e" + i : (I = w.toExponential(), I = I.slice(0, I.indexOf("e") + 1) + i), B = new o(I)) : B = new o(w.toString()), Q = (i = o.precision) + 3; ; ) if (C = B, B = C.plus(lA(E, C, Q + 2, 1)).times(0.5), qI(C.d).slice(0, Q) === (I = qI(B.d)).slice(0, Q)) if (I = I.slice(Q - 3, Q + 1), I == "9999" || !g && I == "4999") { if (!g && (IA(C, i + 1, 0), C.times(C).eq(E))) { B = C; break; } Q += 4, g = 1; } else { (!+I || !+I.slice(1) && I.charAt(0) == "5") && (IA(B, i + 1, 1), A = !B.times(B).eq(E)); break; } return oA = !0, IA(B, i, o.rounding, A); }; x.tangent = x.tan = function() { var A, I, Q = this, B = Q.constructor; return Q.isFinite() ? Q.isZero() ? new B(Q) : (A = B.precision, I = B.rounding, B.precision = A + 10, B.rounding = 1, Q = Q.sin(), Q.s = 1, Q = lA(Q, new B(1).minus(Q.times(Q)).sqrt(), A + 10, 0), B.precision = A, B.rounding = I, IA(tQ == 2 || tQ == 4 ? Q.neg() : Q, A, I, !0)) : new B(NaN); }; x.times = x.mul = function(A) { var I, Q, B, g, C, E, D, i, w, o = this, a = o.constructor, J = o.d, Y = (A = new a(A)).d; if (A.s *= o.s, !J || !J[0] || !Y || !Y[0]) return new a(!A.s || J && !J[0] && !Y || Y && !Y[0] && !J ? NaN : !J || !Y ? A.s / 0 : A.s * 0); for (Q = OI(o.e / DA) + OI(A.e / DA), i = J.length, w = Y.length, i < w && (C = J, J = Y, Y = C, E = i, i = w, w = E), C = [], E = i + w, B = E; B--; ) C.push(0); for (B = w; --B >= 0; ) { for (I = 0, g = i + B; g > B; ) D = C[g] + Y[B] * J[g - B - 1] + I, C[g--] = D % EQ | 0, I = D / EQ | 0; C[g] = (C[g] + I) % EQ | 0; } for (; !C[--E]; ) C.pop(); return I ? ++Q : C.shift(), A.d = C, A.e = cC(C, Q), oA ? IA(A, a.precision, a.rounding) : A; }; x.toBinary = function(A, I) { return kD(this, 2, A, I); }; x.toDecimalPlaces = x.toDP = function(A, I) { var Q = this, B = Q.constructor; return Q = new B(Q), A === void 0 ? Q : (jI(A, 0, DB), I === void 0 ? I = B.rounding : jI(I, 0, 8), IA(Q, A + Q.e + 1, I)); }; x.toExponential = function(A, I) { var Q, B = this, g = B.constructor; return A === void 0 ? Q = JQ(B, !0) : (jI(A, 0, DB), I === void 0 ? I = g.rounding : jI(I, 0, 8), B = IA(new g(B), A + 1, I), Q = JQ(B, !0, A + 1)), B.isNeg() && !B.isZero() ? "-" + Q : Q; }; x.toFixed = function(A, I) { var Q, B, g = this, C = g.constructor; return A === void 0 ? Q = JQ(g) : (jI(A, 0, DB), I === void 0 ? I = C.rounding : jI(I, 0, 8), B = IA(new C(g), A + g.e + 1, I), Q = JQ(B, !1, A + B.e + 1)), g.isNeg() && !g.isZero() ? "-" + Q : Q; }; x.toFraction = function(A) { var I, Q, B, g, C, E, D, i, w, o, a, J, Y = this, q = Y.d, L = Y.constructor; if (!q) return new L(Y); if (w = Q = new L(1), B = i = new L(0), I = new L(B), C = I.e = Wi(q) - Y.e - 1, E = C % DA, I.d[0] = aI(10, E < 0 ? DA + E : E), A == null) A = C > 0 ? I : w; else { if (D = new L(A), !D.isInt() || D.lt(w)) throw Error(QB + D); A = D.gt(I) ? C > 0 ? I : w : D; } for (oA = !1, D = new L(qI(q)), o = L.precision, L.precision = C = q.length * DA * 2; a = lA(D, I, 0, 1, 1), g = Q.plus(a.times(B)), g.cmp(A) != 1; ) Q = B, B = g, g = w, w = i.plus(a.times(g)), i = g, g = I, I = D.minus(a.times(g)), D = g; return g = lA(A.minus(Q), B, 0, 1, 1), i = i.plus(g.times(w)), Q = Q.plus(g.times(B)), i.s = w.s = Y.s, J = lA(w, B, C, 1).minus(Y).abs().cmp(lA(i, Q, C, 1).minus(Y).abs()) < 1 ? [w, B] : [i, Q], L.precision = o, oA = !0, J; }; x.toHexadecimal = x.toHex = function(A, I) { return kD(this, 16, A, I); }; x.toNearest = function(A, I) { var Q = this, B = Q.constructor; if (Q = new B(Q), A == null) { if (!Q.d) return Q; A = new B(1), I = B.rounding; } else { if (A = new B(A), I === void 0 ? I = B.rounding : jI(I, 0, 8), !Q.d) return A.s ? Q : A; if (!A.d) return A.s && (A.s = Q.s), A; } return A.d[0] ? (oA = !1, Q = lA(Q, A, 0, I, 1).times(A), oA = !0, IA(Q)) : (A.s = Q.s, Q = A), Q; }; x.toNumber = function() { return +this; }; x.toOctal = function(A, I) { return kD(this, 8, A, I); }; x.toPower = x.pow = function(A) { var I, Q, B, g, C, E, D = this, i = D.constructor, w = +(A = new i(A)); if (!D.d || !A.d || !D.d[0] || !A.d[0]) return new i(aI(+D, w)); if (D = new i(D), D.eq(1)) return D; if (B = i.precision, C = i.rounding, A.eq(1)) return IA(D, B, C); if (I = OI(A.e / DA), I >= A.d.length - 1 && (Q = w < 0 ? -w : w) <= BM) return g = mi(i, D, Q, B), A.s < 0 ? new i(1).div(g) : IA(g, B, C); if (E = D.s, E < 0) { if (I < A.d.length - 1) return new i(NaN); if (A.d[I] & 1 || (E = 1), D.e == 0 && D.d[0] == 1 && D.d.length == 1) return D.s = E, D; } return Q = aI(+D, w), I = Q == 0 || !isFinite(Q) ? OI(w * (Math.log("0." + qI(D.d)) / Math.LN10 + D.e + 1)) : new i(Q + "").e, I > i.maxE + 1 || I < i.minE - 1 ? new i(I > 0 ? E / 0 : 0) : (oA = !1, i.rounding = D.s = 1, Q = Math.min(12, (I + "").length), g = nE(A.times($Q(D, B + Q)), B), g.d && (g = IA(g, B + 5, 1), hg(g.d, B, C) && (I = B + 10, g = IA(nE(A.times($Q(D, I + Q)), I), I + 5, 1), +qI(g.d).slice(B + 1, B + 15) + 1 == 1e14 && (g = IA(g, B + 1, 0)))), g.s = E, oA = !0, i.rounding = C, IA(g, B, C)); }; x.toPrecision = function(A, I) { var Q, B = this, g = B.constructor; return A === void 0 ? Q = JQ(B, B.e <= g.toExpNeg || B.e >= g.toExpPos) : (jI(A, 1, DB), I === void 0 ? I = g.rounding : jI(I, 0, 8), B = IA(new g(B), A, I), Q = JQ(B, A <= B.e || B.e <= g.toExpNeg, A)), B.isNeg() && !B.isZero() ? "-" + Q : Q; }; x.toSignificantDigits = x.toSD = function(A, I) { var Q = this, B = Q.constructor; return A === void 0 ? (A = B.precision, I = B.rounding) : (jI(A, 1, DB), I === void 0 ? I = B.rounding : jI(I, 0, 8)), IA(new B(Q), A, I); }; x.toString = function() { var A = this, I = A.constructor, Q = JQ(A, A.e <= I.toExpNeg || A.e >= I.toExpPos); return A.isNeg() && !A.isZero() ? "-" + Q : Q; }; x.truncated = x.trunc = function() { return IA(new this.constructor(this), this.e + 1, 1); }; x.valueOf = x.toJSON = function() { var A = this, I = A.constructor, Q = JQ(A, A.e <= I.toExpNeg || A.e >= I.toExpPos); return A.isNeg() ? "-" + Q : Q; }; function qI(A) { var I, Q, B, g = A.length - 1, C = "", E = A[0]; if (g > 0) { for (C += E, I = 1; I < g; I++) B = A[I] + "", Q = DA - B.length, Q && (C += vQ(Q)), C += B; E = A[I], B = E + "", Q = DA - B.length, Q && (C += vQ(Q)); } else if (E === 0) return "0"; for (; E % 10 === 0; ) E /= 10; return C + E; } function jI(A, I, Q) { if (A !== ~~A || A < I || A > Q) throw Error(QB + A); } function hg(A, I, Q, B) { var g, C, E, D; for (C = A[0]; C >= 10; C /= 10) --I; return --I < 0 ? (I += DA, g = 0) : (g = Math.ceil((I + 1) / DA), I %= DA), C = aI(10, DA - I), D = A[g] % C | 0, B == null ? I < 3 ? (I == 0 ? D = D / 100 | 0 : I == 1 && (D = D / 10 | 0), E = Q < 4 && D == 99999 || Q > 3 && D == 49999 || D == 5e4 || D == 0) : E = (Q < 4 && D + 1 == C || Q > 3 && D + 1 == C / 2) && (A[g + 1] / C / 100 | 0) == aI(10, I - 2) - 1 || (D == C / 2 || D == 0) && (A[g + 1] / C / 100 | 0) == 0 : I < 4 ? (I == 0 ? D = D / 1e3 | 0 : I == 1 ? D = D / 100 | 0 : I == 2 && (D = D / 10 | 0), E = (B || Q < 4) && D == 9999 || !B && Q > 3 && D == 4999) : E = ((B || Q < 4) && D + 1 == C || !B && Q > 3 && D + 1 == C / 2) && (A[g + 1] / C / 1e3 | 0) == aI(10, I - 3) - 1, E; } function zg(A, I, Q) { for (var B, g = [0], C, E = 0, D = A.length; E < D; ) { for (C = g.length; C--; ) g[C] *= I; for (g[0] += eE.indexOf(A.charAt(E++)), B = 0; B < g.length; B++) g[B] > Q - 1 && (g[B + 1] === void 0 && (g[B + 1] = 0), g[B + 1] += g[B] / Q | 0, g[B] %= Q); } return g.reverse(); } function CM(A, I) { var Q, B, g; if (I.isZero()) return I; B = I.d.length, B < 32 ? (Q = Math.ceil(B / 3), g = (1 / YC(4, Q)).toString()) : (Q = 16, g = "2.3283064365386962890625e-10"), A.precision += Q, I = fB(A, 1, I.times(g), new A(1)); for (var C = Q; C--; ) { var E = I.times(I); I = E.times(E).minus(E).times(8).plus(1); } return A.precision -= Q, I; } var lA = function() { function A(B, g, C) { var E, D = 0, i = B.length; for (B = B.slice(); i--; ) E = B[i] * g + D, B[i] = E % C | 0, D = E / C | 0; return D && B.unshift(D), B; } function I(B, g, C, E) { var D, i; if (C != E) i = C > E ? 1 : -1; else for (D = i = 0; D < C; D++) if (B[D] != g[D]) { i = B[D] > g[D] ? 1 : -1; break; } return i; } function Q(B, g, C, E) { for (var D = 0; C--; ) B[C] -= D, D = B[C] < g[C] ? 1 : 0, B[C] = D * E + B[C] - g[C]; for (; !B[0] && B.length > 1; ) B.shift(); } return function(B, g, C, E, D, i) { var w, o, a, J, Y, q, L, f, l, W, d, u, X, gA, cA, wA, P, qA, K, M, F = B.constructor, s = B.s == g.s ? 1 : -1, y = B.d, U = g.d; if (!y || !y[0] || !U || !U[0]) return new F( // Return NaN if either NaN, or both Infinity or 0. !B.s || !g.s || (y ? U && y[0] == U[0] : !U) ? NaN : ( // Return ±0 if x is 0 or y is ±Infinity, or return ±Infinity as y is 0. y && y[0] == 0 || !U ? s * 0 : s / 0 ) ); for (i ? (Y = 1, o = B.e - g.e) : (i = EQ, Y = DA, o = OI(B.e / Y) - OI(g.e / Y)), K = U.length, P = y.length, l = new F(s), W = l.d = [], a = 0; U[a] == (y[a] || 0); a++) ; if (U[a] > (y[a] || 0) && o--, C == null ? (gA = C = F.precision, E = F.rounding) : D ? gA = C + (B.e - g.e) + 1 : gA = C, gA < 0) W.push(1), q = !0; else { if (gA = gA / Y + 2 | 0, a = 0, K == 1) { for (J = 0, U = U[0], gA++; (a < P || J) && gA--; a++) cA = J * i + (y[a] || 0), W[a] = cA / U | 0, J = cA % U | 0; q = J || a < P; } else { for (J = i / (U[0] + 1) | 0, J > 1 && (U = A(U, J, i), y = A(y, J, i), K = U.length, P = y.length), wA = K, d = y.slice(0, K), u = d.length; u < K; ) d[u++] = 0; M = U.slice(), M.unshift(0), qA = U[0], U[1] >= i / 2 && ++qA; do J = 0, w = I(U, d, K, u), w < 0 ? (X = d[0], K != u && (X = X * i + (d[1] || 0)), J = X / qA | 0, J > 1 ? (J >= i && (J = i - 1), L = A(U, J, i), f = L.length, u = d.length, w = I(L, d, f, u), w == 1 && (J--, Q(L, K < f ? M : U, f, i))) : (J == 0 && (w = J = 1), L = U.slice()), f = L.length, f < u && L.unshift(0), Q(d, L, u, i), w == -1 && (u = d.length, w = I(U, d, K, u), w < 1 && (J++, Q(d, K < u ? M : U, u, i))), u = d.length) : w === 0 && (J++, d = [0]), W[a++] = J, w && d[0] ? d[u++] = y[wA] || 0 : (d = [y[wA]], u = 1); while ((wA++ < P || d[0] !== void 0) && gA--); q = d[0] !== void 0; } W[0] || W.shift(); } if (Y == 1) l.e = o, li = q; else { for (a = 1, J = W[0]; J >= 10; J /= 10) a++; l.e = a + o * Y - 1, IA(l, D ? C + l.e + 1 : C, E, q); } return l; }; }(); function IA(A, I, Q, B) { var g, C, E, D, i, w, o, a, J, Y = A.constructor; A: if (I != null) { if (a = A.d, !a) return A; for (g = 1, D = a[0]; D >= 10; D /= 10) g++; if (C = I - g, C < 0) C += DA, E = I, o = a[J = 0], i = o / aI(10, g - E - 1) % 10 | 0; else if (J = Math.ceil((C + 1) / DA), D = a.length, J >= D) if (B) { for (; D++ <= J; ) a.push(0); o = i = 0, g = 1, C %= DA, E = C - DA + 1; } else break A; else { for (o = D = a[J], g = 1; D >= 10; D /= 10) g++; C %= DA, E = C - DA + g, i = E < 0 ? 0 : o / aI(10, g - E - 1) % 10 | 0; } if (B = B || I < 0 || a[J + 1] !== void 0 || (E < 0 ? o : o % aI(10, g - E - 1)), w = Q < 4 ? (i || B) && (Q == 0 || Q == (A.s < 0 ? 3 : 2)) : i > 5 || i == 5 && (Q == 4 || B || Q == 6 && // Check whether the digit to the left of the rounding digit is odd. (C > 0 ? E > 0 ? o / aI(10, g - E) : 0 : a[J - 1]) % 10 & 1 || Q == (A.s < 0 ? 8 : 7)), I < 1 || !a[0]) return a.length = 0, w ? (I -= A.e + 1, a[0] = aI(10, (DA - I % DA) % DA), A.e = -I || 0) : a[0] = A.e = 0, A; if (C == 0 ? (a.length = J, D = 1, J--) : (a.length = J + 1, D = aI(10, DA - C), a[J] = E > 0 ? (o / aI(10, g - E) % aI(10, E) | 0) * D : 0), w) for (; ; ) if (J == 0) { for (C = 1, E = a[0]; E >= 10; E /= 10) C++; for (E = a[0] += D, D = 1; E >= 10; E /= 10) D++; C != D && (A.e++, a[0] == EQ && (a[0] = 1)); break; } else { if (a[J] += D, a[J] != EQ) break; a[J--] = 0, D = 1; } for (C = a.length; a[--C] === 0; ) a.pop(); } return oA && (A.e > Y.maxE ? (A.d = null, A.e = NaN) : A.e < Y.minE && (A.e = 0, A.d = [0])), A; } function JQ(A, I, Q) { if (!A.isFinite()) return bi(A); var B, g = A.e, C = qI(A.d), E = C.length; return I ? (Q && (B = Q - E) > 0 ? C = C.charAt(0) + "." + C.slice(1) + vQ(B) : E > 1 && (C = C.charAt(0) + "." + C.slice(1)), C = C + (A.e < 0 ? "e" : "e+") + A.e) : g < 0 ? (C = "0." + vQ(-g - 1) + C, Q && (B = Q - E) > 0 && (C += vQ(B))) : g >= E ? (C += vQ(g + 1 - E), Q && (B = Q - g - 1) > 0 && (C = C + "." + vQ(B))) : ((B = g + 1) < E && (C = C.slice(0, B) + "." + C.slice(B)), Q && (B = Q - E) > 0 && (g + 1 === E && (C += "."), C += vQ(B))), C; } function cC(A, I) { var Q = A[0]; for (I *= DA; Q >= 10; Q /= 10) I++; return I; } function gC(A, I, Q) { if (I > gM) throw oA = !0, Q && (A.precision = Q), Error(fi); return IA(new A(QC), I, 1, !0); } function gQ(A, I, Q) { if (I > dE) throw Error(fi); return IA(new A(BC), I, Q, !0); } function Wi(A) { var I = A.length - 1, Q = I * DA + 1; if (I = A[I], I) { for (; I % 10 == 0; I /= 10) Q--; for (I = A[0]; I >= 10; I /= 10) Q++; } return Q; } function vQ(A) { for (var I = ""; A--; ) I += "0"; return I; } function mi(A, I, Q, B) { var g, C = new A(1), E = Math.ceil(B / DA + 4); for (oA = !1; ; ) { if (Q % 2 && (C = C.times(I), _D(C.d, E) && (g = !0)), Q = OI(Q / 2), Q === 0) { Q = C.d.length - 1, g && C.d[Q] === 0 && ++C.d[Q]; break; } I = I.times(I), _D(I.d, E); } return oA = !0, C; } function vD(A) { return A.d[A.d.length - 1] & 1; } function Vi(A, I, Q) { for (var B, g = new A(I[0]), C = 0; ++C < I.length; ) if (B = new A(I[C]), B.s) g[Q](B) && (g = B); else { g = B; break; } return g; } function nE(A, I) { var Q, B, g, C, E, D, i, w = 0, o = 0, a = 0, J = A.constructor, Y = J.rounding, q = J.precision; if (!A.d || !A.d[0] || A.e > 17) return new J(A.d ? A.d[0] ? A.s < 0 ? 0 : 1 / 0 : 1 : A.s ? A.s < 0 ? 0 : A : 0 / 0); for (I == null ? (oA = !1, i = q) : i = I, D = new J(0.03125); A.e > -2; ) A = A.times(D), a += 5; for (B = Math.log(aI(2, a)) / Math.LN10 * 2 + 5 | 0, i += B, Q = C = E = new J(1), J.precision = i; ; ) { if (C = IA(C.times(A), i, 1), Q = Q.times(++o), D = E.plus(lA(C, Q, i, 1)), qI(D.d).slice(0, i) === qI(E.d).slice(0, i)) { for (g = a; g--; ) E = IA(E.times(E), i, 1); if (I == null) if (w < 3 && hg(E.d, i - B, Y, w)) J.precision = i += 10, Q = C = D = new J(1), o = 0, w++; else return IA(E, J.precision = q, Y, oA = !0); else return J.precision = q, E; } E = D; } } function $Q(A, I) { var Q, B, g, C, E, D, i, w, o, a, J, Y = 1, q = 10, L = A, f = L.d, l = L.constructor, W = l.rounding, d = l.precision; if (L.s < 0 || !f || !f[0] || !L.e && f[0] == 1 && f.length == 1) return new l(f && !f[0] ? -1 / 0 : L.s != 1 ? NaN : f ? 0 : L); if (I == null ? (oA = !1, o = d) : o = I, l.precision = o += q, Q = qI(f), B = Q.charAt(0), Math.abs(C = L.e) < 15e14) { for (; B < 7 && B != 1 || B == 1 && Q.charAt(1) > 3; ) L = L.times(A), Q = qI(L.d), B = Q.charAt(0), Y++; C = L.e, B > 1 ? (L = new l("0." + Q), C++) : L = new l(B + "." + Q.slice(1)); } else return w = gC(l, o + 2, d).times(C + ""), L = $Q(new l(B + "." + Q.slice(1)), o - q).plus(w), l.precision = d, I == null ? IA(L, d, W, oA = !0) : L; for (a = L, i = E = L = lA(L.minus(1), L.plus(1), o, 1), J = IA(L.times(L), o, 1), g = 3; ; ) { if (E = IA(E.times(J), o, 1), w = i.plus(lA(E, new l(g), o, 1)), qI(w.d).slice(0, o) === qI(i.d).slice(0, o)) if (i = i.times(2), C !== 0 && (i = i.plus(gC(l, o + 2, d).times(C + ""))), i = lA(i, new l(Y), o, 1), I == null) if (hg(i.d, o - q, W, D)) l.precision = o += q, w = E = L = lA(a.minus(1), a.plus(1), o, 1), J = IA(L.times(L), o, 1), g = D = 1; else return IA(i, l.precision = d, W, oA = !0); else return l.precision = d, i; i = w, g += 2; } } function bi(A) { return String(A.s * A.s / 0); } function rE(A, I) { var Q, B, g; for ((Q = I.indexOf(".")) > -1 && (I = I.replace(".", "")), (B = I.search(/e/i)) > 0 ? (Q < 0 && (Q = B), Q += +I.slice(B + 1), I = I.substring(0, B)) : Q < 0 && (Q = I.length), B = 0; I.charCodeAt(B) === 48; B++) ; for (g = I.length; I.charCodeAt(g - 1) === 48; --g) ; if (I = I.slice(B, g), I) { if (g -= B, A.e = Q = Q - B - 1, A.d = [], B = (Q + 1) % DA, Q < 0 && (B += DA), B < g) { for (B && A.d.push(+I.slice(0, B)), g -= DA; B < g; ) A.d.push(+I.slice(B, B += DA)); I = I.slice(B), B = DA - I.length; } else B -= g; for (; B--; ) I += "0"; A.d.push(+I), oA && (A.e > A.constructor.maxE ? (A.d = null, A.e = NaN) : A.e < A.constructor.minE && (A.e = 0, A.d = [0])); } else A.e = 0, A.d = [0]; return A; } function EM(A, I) { var Q, B, g, C, E, D, i, w, o; if (I.indexOf("_") > -1) { if (I = I.replace(/(\d)_(?=\d)/g, "$1"), Zi.test(I)) return rE(A, I); } else if (I === "Infinity" || I === "NaN") return +I || (A.s = NaN), A.e = NaN, A.d = null, A; if (IM.test(I)) Q = 16, I = I.toLowerCase(); else if (AM.test(I)) Q = 2; else if (QM.test(I)) Q = 8; else throw Error(QB + I); for (C = I.search(/p/i), C > 0 ? (i = +I.slice(C + 1), I = I.substring(2, C)) : I = I.slice(2), C = I.indexOf("."), E = C >= 0, B = A.constructor, E && (I = I.replace(".", ""), D = I.length, C = D - C, g = mi(B, new B(Q), C, C * 2)), w = zg(I, Q, EQ), o = w.length - 1, C = o; w[C] === 0; --C) w.pop(); return C < 0 ? new B(A.s * 0) : (A.e = cC(w, o), A.d = w, oA = !1, E && (A = lA(A, g, D * 4)), i && (A = A.times(Math.abs(i) < 54 ? aI(2, i) : FI.pow(2, i))), oA = !0, A); } function DM(A, I) { var Q, B = I.d.length; if (B < 3) return I.isZero() ? I : fB(A, 2, I, I); Q = 1.4 * Math.sqrt(B), Q = Q > 16 ? 16 : Q | 0, I = I.times(1 / YC(5, Q)), I = fB(A, 2, I, I); for (var g, C = new A(5), E = new A(16), D = new A(20); Q--; ) g = I.times(I), I = I.times(C.plus(g.times(E.times(g).minus(D)))); return I; } function fB(A, I, Q, B, g) { var C, E, D, i, w = A.precision, o = Math.ceil(w / DA); for (oA = !1, i = Q.times(Q), D = new A(B); ; ) { if (E = lA(D.times(i), new A(I++ * I++), w, 1), D = g ? B.plus(E) : B.minus(E), B = lA(E.times(i), new A(I++ * I++), w, 1), E = D.plus(B), E.d[o] !== void 0) { for (C = o; E.d[C] === D.d[C] && C--; ) ; if (C == -1) break; } C = D, D = B, B = E, E = C; } return oA = !0, E.d.length = o + 1, E; } function YC(A, I) { for (var Q = A; --I; ) Q *= A; return Q; } function ui(A, I) { var Q, B = I.s < 0, g = gQ(A, A.precision, 1), C = g.times(0.5); if (I = I.abs(), I.lte(C)) return tQ = B ? 4 : 1, I; if (Q = I.divToInt(g), Q.isZero()) tQ = B ? 3 : 2; else { if (I = I.minus(Q.times(g)), I.lte(C)) return tQ = vD(Q) ? B ? 2 : 3 : B ? 4 : 1, I; tQ = vD(Q) ? B ? 1 : 4 : B ? 3 : 2; } return I.minus(g).abs(); } function kD(A, I, Q, B) { var g, C, E, D, i, w, o, a, J, Y = A.constructor, q = Q !== void 0; if (q ? (jI(Q, 1, DB), B === void 0 ? B = Y.rounding : jI(B, 0, 8)) : (Q = Y.precision, B = Y.rounding), !A.isFinite()) o = bi(A); else { for (o = JQ(A), E = o.indexOf("."), q ? (g = 2, I == 16 ? Q = Q * 4 - 3 : I == 8 && (Q = Q * 3 - 2)) : g = I, E >= 0 && (o = o.replace(".", ""), J = new Y(1), J.e = o.length - E, J.d = zg(JQ(J), 10, g), J.e = J.d.length), a = zg(o, 10, g), C = i = a.length; a[--i] == 0; ) a.pop(); if (!a[0]) o = q ? "0p+0" : "0"; else { if (E < 0 ? C-- : (A = new Y(A), A.d = a, A.e = C, A = lA(A, J, Q, B, 0, g), a = A.d, C = A.e, w = li), E = a[Q], D = g / 2, w = w || a[Q + 1] !== void 0, w = B < 4 ? (E !== void 0 || w) && (B === 0 || B === (A.s < 0 ? 3 : 2)) : E > D || E === D && (B === 4 || w || B === 6 && a[Q - 1] & 1 || B === (A.s < 0 ? 8 : 7)), a.length = Q, w) for (; ++a[--Q] > g - 1; ) a[Q] = 0, Q || (++C, a.unshift(1)); for (i = a.length; !a[i - 1]; --i) ; for (E = 0, o = ""; E < i; E++) o += eE.charAt(a[E]); if (q) { if (i > 1) if (I == 16 || I == 8) { for (E = I == 16 ? 4 : 3, --i; i % E; i++) o += "0"; for (a = zg(o, g, I), i = a.length; !a[i - 1]; --i) ; for (E = 1, o = "1."; E < i; E++) o += eE.charAt(a[E]); } else o = o.charAt(0) + "." + o.slice(1); o = o + (C < 0 ? "p" : "p+") + C; } else if (C < 0) { for (; ++C; ) o = "0" + o; o = "0." + o; } else if (++C > i) for (C -= i; C--; ) o += "0"; else C < i && (o = o.slice(0, C) + "." + o.slice(C)); } o = (I == 16 ? "0x" : I == 2 ? "0b" : I == 8 ? "0o" : "") + o; } return A.s < 0 ? "-" + o : o; } function _D(A, I) { if (A.length > I) return A.length = I, !0; } function iM(A) { return new this(A).abs(); } function wM(A) { return new this(A).acos(); } function oM(A) { return new this(A).acosh(); } function MM(A, I) { return new this(A).plus(I); } function GM(A) { return new this(A).asin(); } function aM(A) { return new this(A).asinh(); } function kM(A) { return new this(A).atan(); } function NM(A) { return new this(A).atanh(); } function FM(A, I) { A = new this(A), I = new this(I); var Q, B = this.precision, g = this.rounding, C = B + 4; return !A.s || !I.s ? Q = new this(NaN) : !A.d && !I.d ? (Q = gQ(this, C, 1).times(I.s > 0 ? 0.25 : 0.75), Q.s = A.s) : !I.d || A.isZero() ? (Q = I.s < 0 ? gQ(this, B, g) : new this(0), Q.s = A.s) : !A.d || I.isZero() ? (Q = gQ(this, C, 1).times(0.5), Q.s = A.s) : I.s < 0 ? (this.precision = C, this.rounding = 1, Q = this.atan(lA(A, I, C, 1)), I = gQ(this, C, 1), this.precision = B, this.rounding = g, Q = A.s < 0 ? Q.minus(I) : Q.plus(I)) : Q = this.atan(lA(A, I, C, 1)), Q; } function JM(A) { return new this(A).cbrt(); } function hM(A) { return IA(A = new this(A), A.e + 1, 2); } function RM(A, I, Q) { return new this(A).clamp(I, Q); } function yM(A) { if (!A || typeof A != "object") throw Error(sC + "Object expected"); var I, Q, B, g = A.defaults === !0, C = [ "precision", 1, DB, "rounding", 0, 8, "toExpNeg", -dB, 0, "toExpPos", 0, dB, "maxE", 0, dB, "minE", -dB, 0, "modulo", 0, 9 ]; for (I = 0; I < C.length; I += 3) if (Q = C[I], g && (this[Q] = pE[Q]), (B = A[Q]) !== void 0) if (OI(B) === B && B >= C[I + 1] && B <= C[I + 2]) this[Q] = B; else throw Error(QB + Q + ": " + B); if (Q = "crypto", g && (this[Q] = pE[Q]), (B = A[Q]) !== void 0) if (B === !0 || B === !1 || B === 0 || B === 1) if (B) if (typeof crypto < "u" && crypto && (crypto.getRandomValues || crypto.randomBytes)) this[Q] = !0; else throw Error(ji); else this[Q] = !1; else throw Error(QB + Q + ": " + B); return this; } function sM(A) { return new this(A).cos(); } function cM(A) { return new this(A).cosh(); } function zi(A) { var I, Q, B; function g(C) { var E, D, i, w = this; if (!(w instanceof g)) return new g(C); if (w.constructor = g, $D(C)) { w.s = C.s, oA ? !C.d || C.e > g.maxE ? (w.e = NaN, w.d = null) : C.e < g.minE ? (w.e = 0, w.d = [0]) : (w.e = C.e, w.d = C.d.slice()) : (w.e = C.e, w.d = C.d ? C.d.slice() : C.d); return; } if (i = typeof C, i === "number") { if (C === 0) { w.s = 1 / C < 0 ? -1 : 1, w.e = 0, w.d = [0]; return; } if (C < 0 ? (C = -C, w.s = -1) : w.s = 1, C === ~~C && C < 1e7) { for (E = 0, D = C; D >= 10; D /= 10) E++; oA ? E > g.maxE ? (w.e = NaN, w.d = null) : E < g.minE ? (w.e = 0, w.d = [0]) : (w.e = E, w.d = [C]) : (w.e = E, w.d = [C]); return; } else if (C * 0 !== 0) { C || (w.s = NaN), w.e = NaN, w.d = null; return; } return rE(w, C.toString()); } else if (i !== "string") throw Error(QB + C); return (D = C.charCodeAt(0)) === 45 ? (C = C.slice(1), w.s = -1) : (D === 43 && (C = C.slice(1)), w.s = 1), Zi.test(C) ? rE(w, C) : EM(w, C); } if (g.prototype = x, g.ROUND_UP = 0, g.ROUND_DOWN = 1, g.ROUND_CEIL = 2, g.ROUND_FLOOR = 3, g.ROUND_HALF_UP = 4, g.ROUND_HALF_DOWN = 5, g.ROUND_HALF_EVEN = 6, g.ROUND_HALF_CEIL = 7, g.ROUND_HALF_FLOOR = 8, g.EUCLID = 9, g.config = g.set = yM, g.clone = zi, g.isDecimal = $D, g.abs = iM, g.acos = wM, g.acosh = oM, g.add = MM, g.asin = GM, g.asinh = aM, g.atan = kM, g.atanh = NM, g.atan2 = FM, g.cbrt = JM, g.ceil = hM, g.clamp = RM, g.cos = sM, g.cosh = cM, g.div = YM, g.exp = UM, g.floor = SM, g.hypot = KM, g.ln = qM, g.log = LM, g.log10 = tM, g.log2 = HM, g.max = eM, g.min = pM, g.mod = dM, g.mul = nM, g.pow = rM, g.random = TM, g.round = OM, g.sign = lM, g.sin = fM, g.sinh = jM, g.sqrt = xM, g.sub = ZM, g.sum = WM, g.tan = mM, g.tanh = VM, g.trunc = bM, A === void 0 && (A = {}), A && A.defaults !== !0) for (B = ["precision", "rounding", "toExpNeg", "toExpPos", "maxE", "minE", "modulo", "crypto"], I = 0; I < B.length; ) A.hasOwnProperty(Q = B[I++]) || (A[Q] = this[Q]); return g.config(A), g; } function YM(A, I) { return new this(A).div(I); } function UM(A) { return new this(A).exp(); } function SM(A) { return IA(A = new this(A), A.e + 1, 3); } function KM() { var A, I, Q = new this(0); for (oA = !1, A = 0; A < arguments.length; ) if (I = new this(arguments[A++]), I.d) Q.d && (Q = Q.plus(I.times(I))); else { if (I.s) return oA = !0, new this(1 / 0); Q = I; } return oA = !0, Q.sqrt(); } function $D(A) { return A instanceof FI || A && A.toStringTag === xi || !1; } function qM(A) { return new this(A).ln(); } function LM(A, I) { return new this(A).log(I); } function HM(A) { return new this(A).log(2); } function tM(A) { return new this(A).log(10); } function eM() { return Vi(this, arguments, "lt"); } function pM() { return Vi(this, arguments, "gt"); } function dM(A, I) { return new this(A).mod(I); } function nM(A, I) { return new this(A).mul(I); } function rM(A, I) { return new this(A).pow(I); } function TM(A) { var I, Q, B, g, C = 0, E = new this(1), D = []; if (A === void 0 ? A = this.precision : jI(A, 1, DB), B = Math.ceil(A / DA), this.crypto) if (crypto.getRandomValues) for (I = crypto.getRandomValues(new Uint32Array(B)); C < B; ) g = I[C], g >= 429e7 ? I[C] = crypto.getRandomValues(new Uint32Array(1))[0] : D[C++] = g % 1e7; else if (crypto.randomBytes) { for (I = crypto.randomBytes(B *= 4); C < B; ) g = I[C] + (I[C + 1] << 8) + (I[C + 2] << 16) + ((I[C + 3] & 127) << 24), g >= 214e7 ? crypto.randomBytes(4).copy(I, C) : (D.push(g % 1e7), C += 4); C = B / 4; } else throw Error(ji); else for (; C < B; ) D[C++] = Math.random() * 1e7 | 0; for (B = D[--C], A %= DA, B && A && (g = aI(10, DA - A), D[C] = (B / g | 0) * g); D[C] === 0; C--) D.pop(); if (C < 0) Q = 0, D = [0]; else { for (Q = -1; D[0] === 0; Q -= DA) D.shift(); for (B = 1, g = D[0]; g >= 10; g /= 10) B++; B < DA && (Q -= DA - B); } return E.e = Q, E.d = D, E; } function OM(A) { return IA(A = new this(A), A.e + 1, this.rounding); } function lM(A) { return A = new this(A), A.d ? A.d[0] ? A.s : 0 * A.s : A.s || NaN; } function fM(A) { return new this(A).sin(); } function jM(A) { return new this(A).sinh(); } function xM(A) { return new this(A).sqrt(); } function ZM(A, I) { return new this(A).sub(I); } function WM() { var A = 0, I = arguments, Q = new this(I[A]); for (oA = !1; Q.s && ++A < I.length; ) Q = Q.plus(I[A]); return oA = !0, IA(Q, this.precision, this.rounding); } function mM(A) { return new this(A).tan(); } function VM(A) { return new this(A).tanh(); } function bM(A) { return IA(A = new this(A), A.e + 1, 1); } x[Symbol.for("nodejs.util.inspect.custom")] = x.toString; x[Symbol.toStringTag] = "Decimal"; var FI = x.constructor = zi(pE); QC = new FI(QC); BC = new FI(BC); class Rg { constructor() { T(this, "instructions", []), T(this, "blobs", []), T(this, "idAllocator", new uM()); } takeAllFromWorktop(I, Q) { const B = { kind: "TakeAllFromWorktop", resourceAddress: I }; this.instructions.push(B); const g = this.idAllocator.bucket(); return Q(this, g); } takeFromWorktop(I, Q, B) { const g = { kind: "TakeFromWorktop", resourceAddress: I, amount: Q }; this.instructions.push(g); const C = this.idAllocator.bucket(); return B(this, C); } takeNonFungiblesFromWorktop(I, Q, B) { const g = { kind: "TakeNonFungiblesFromWorktop", resourceAddress: I, ids: Q }; this.instructions.push(g); const C = this.idAllocator.bucket(); return B(this, C); } returnToWorktop(I) { const Q = { kind: "ReturnToWorktop", bucketId: I }; return this.instructions.push(Q), this; } assertWorktopContainsAny(I) { const Q = { kind: "AssertWorktopContainsAny", resourceAddress: I }; return this.instructions.push(Q), this; } assertWorktopContains(I, Q) { const B = { kind: "AssertWorktopContains", resourceAddress: I, amount: Q }; return this.instructions.push(B), this; } assertWorktopContainsNonFungibles(I, Q) { const B = { kind: "AssertWorktopContainsNonFungibles", resourceAddress: I, ids: Q }; return this.instructions.push(B), this; } popFromAuthZone(I) { const Q = { kind: "PopFromAuthZone" }; this.instructions.push(Q); const B = this.idAllocator.proof(); return I(this, B); } pushToAuthZone(I) {