solar-time
Version:
This library provides functions to calculate local solar time, also known as local apparent time, based on a given location and date.
1,045 lines • 59.9 kB
JavaScript
var Ae = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function Ie(e) {
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
var Fe = { exports: {} };
(function(e, n) {
(function(t, i) {
e.exports = i();
})(Ae, function() {
var t = 1e3, i = 6e4, r = 36e5, s = "millisecond", o = "second", u = "minute", c = "hour", f = "day", a = "week", l = "month", h = "quarter", m = "year", k = "date", S = "Invalid Date", Z = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, L = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, V = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function($) {
var g = ["th", "st", "nd", "rd"], p = $ % 100;
return "[" + $ + (g[(p - 20) % 10] || g[p] || g[0]) + "]";
} }, _ = function($, g, p) {
var N = String($);
return !N || N.length >= g ? $ : "" + Array(g + 1 - N.length).join(p) + $;
}, I = { s: _, z: function($) {
var g = -$.utcOffset(), p = Math.abs(g), N = Math.floor(p / 60), w = p % 60;
return (g <= 0 ? "+" : "-") + _(N, 2, "0") + ":" + _(w, 2, "0");
}, m: function $(g, p) {
if (g.date() < p.date()) return -$(p, g);
var N = 12 * (p.year() - g.year()) + (p.month() - g.month()), w = g.clone().add(N, l), D = p - w < 0, O = g.clone().add(N + (D ? -1 : 1), l);
return +(-(N + (p - w) / (D ? w - O : O - w)) || 0);
}, a: function($) {
return $ < 0 ? Math.ceil($) || 0 : Math.floor($);
}, p: function($) {
return { M: l, y: m, w: a, d: f, D: k, h: c, m: u, s: o, ms: s, Q: h }[$] || String($ || "").toLowerCase().replace(/s$/, "");
}, u: function($) {
return $ === void 0;
} }, X = "en", H = {};
H[X] = V;
var ae = "$isDayjsObject", ee = function($) {
return $ instanceof z || !(!$ || !$[ae]);
}, Q = function $(g, p, N) {
var w;
if (!g) return X;
if (typeof g == "string") {
var D = g.toLowerCase();
H[D] && (w = D), p && (H[D] = p, w = D);
var O = g.split("-");
if (!w && O.length > 1) return $(O[0]);
} else {
var b = g.name;
H[b] = g, w = b;
}
return !N && w && (X = w), w || !N && X;
}, q = function($, g) {
if (ee($)) return $.clone();
var p = typeof g == "object" ? g : {};
return p.date = $, p.args = arguments, new z(p);
}, C = I;
C.l = Q, C.i = ee, C.w = function($, g) {
return q($, { locale: g.$L, utc: g.$u, x: g.$x, $offset: g.$offset });
};
var z = function() {
function $(p) {
this.$L = Q(p.locale, null, !0), this.parse(p), this.$x = this.$x || p.x || {}, this[ae] = !0;
}
var g = $.prototype;
return g.parse = function(p) {
this.$d = function(N) {
var w = N.date, D = N.utc;
if (w === null) return /* @__PURE__ */ new Date(NaN);
if (C.u(w)) return /* @__PURE__ */ new Date();
if (w instanceof Date) return new Date(w);
if (typeof w == "string" && !/Z$/i.test(w)) {
var O = w.match(Z);
if (O) {
var b = O[2] - 1 || 0, P = (O[7] || "0").substring(0, 3);
return D ? new Date(Date.UTC(O[1], b, O[3] || 1, O[4] || 0, O[5] || 0, O[6] || 0, P)) : new Date(O[1], b, O[3] || 1, O[4] || 0, O[5] || 0, O[6] || 0, P);
}
}
return new Date(w);
}(p), this.init();
}, g.init = function() {
var p = this.$d;
this.$y = p.getFullYear(), this.$M = p.getMonth(), this.$D = p.getDate(), this.$W = p.getDay(), this.$H = p.getHours(), this.$m = p.getMinutes(), this.$s = p.getSeconds(), this.$ms = p.getMilliseconds();
}, g.$utils = function() {
return C;
}, g.isValid = function() {
return this.$d.toString() !== S;
}, g.isSame = function(p, N) {
var w = q(p);
return this.startOf(N) <= w && w <= this.endOf(N);
}, g.isAfter = function(p, N) {
return q(p) < this.startOf(N);
}, g.isBefore = function(p, N) {
return this.endOf(N) < q(p);
}, g.$g = function(p, N, w) {
return C.u(p) ? this[N] : this.set(w, p);
}, g.unix = function() {
return Math.floor(this.valueOf() / 1e3);
}, g.valueOf = function() {
return this.$d.getTime();
}, g.startOf = function(p, N) {
var w = this, D = !!C.u(N) || N, O = C.p(p), b = function(fe, Y) {
var ne = C.w(w.$u ? Date.UTC(w.$y, Y, fe) : new Date(w.$y, Y, fe), w);
return D ? ne : ne.endOf(f);
}, P = function(fe, Y) {
return C.w(w.toDate()[fe].apply(w.toDate("s"), (D ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(Y)), w);
}, F = this.$W, R = this.$M, y = this.$D, le = "set" + (this.$u ? "UTC" : "");
switch (O) {
case m:
return D ? b(1, 0) : b(31, 11);
case l:
return D ? b(1, R) : b(0, R + 1);
case a:
var ue = this.$locale().weekStart || 0, pe = (F < ue ? F + 7 : F) - ue;
return b(D ? y - pe : y + (6 - pe), R);
case f:
case k:
return P(le + "Hours", 0);
case c:
return P(le + "Minutes", 1);
case u:
return P(le + "Seconds", 2);
case o:
return P(le + "Milliseconds", 3);
default:
return this.clone();
}
}, g.endOf = function(p) {
return this.startOf(p, !1);
}, g.$set = function(p, N) {
var w, D = C.p(p), O = "set" + (this.$u ? "UTC" : ""), b = (w = {}, w[f] = O + "Date", w[k] = O + "Date", w[l] = O + "Month", w[m] = O + "FullYear", w[c] = O + "Hours", w[u] = O + "Minutes", w[o] = O + "Seconds", w[s] = O + "Milliseconds", w)[D], P = D === f ? this.$D + (N - this.$W) : N;
if (D === l || D === m) {
var F = this.clone().set(k, 1);
F.$d[b](P), F.init(), this.$d = F.set(k, Math.min(this.$D, F.daysInMonth())).$d;
} else b && this.$d[b](P);
return this.init(), this;
}, g.set = function(p, N) {
return this.clone().$set(p, N);
}, g.get = function(p) {
return this[C.p(p)]();
}, g.add = function(p, N) {
var w, D = this;
p = Number(p);
var O = C.p(N), b = function(R) {
var y = q(D);
return C.w(y.date(y.date() + Math.round(R * p)), D);
};
if (O === l) return this.set(l, this.$M + p);
if (O === m) return this.set(m, this.$y + p);
if (O === f) return b(1);
if (O === a) return b(7);
var P = (w = {}, w[u] = i, w[c] = r, w[o] = t, w)[O] || 1, F = this.$d.getTime() + p * P;
return C.w(F, this);
}, g.subtract = function(p, N) {
return this.add(-1 * p, N);
}, g.format = function(p) {
var N = this, w = this.$locale();
if (!this.isValid()) return w.invalidDate || S;
var D = p || "YYYY-MM-DDTHH:mm:ssZ", O = C.z(this), b = this.$H, P = this.$m, F = this.$M, R = w.weekdays, y = w.months, le = w.meridiem, ue = function(Y, ne, ge, me) {
return Y && (Y[ne] || Y(N, D)) || ge[ne].slice(0, me);
}, pe = function(Y) {
return C.s(b % 12 || 12, Y, "0");
}, fe = le || function(Y, ne, ge) {
var me = Y < 12 ? "AM" : "PM";
return ge ? me.toLowerCase() : me;
};
return D.replace(L, function(Y, ne) {
return ne || function(ge) {
switch (ge) {
case "YY":
return String(N.$y).slice(-2);
case "YYYY":
return C.s(N.$y, 4, "0");
case "M":
return F + 1;
case "MM":
return C.s(F + 1, 2, "0");
case "MMM":
return ue(w.monthsShort, F, y, 3);
case "MMMM":
return ue(y, F);
case "D":
return N.$D;
case "DD":
return C.s(N.$D, 2, "0");
case "d":
return String(N.$W);
case "dd":
return ue(w.weekdaysMin, N.$W, R, 2);
case "ddd":
return ue(w.weekdaysShort, N.$W, R, 3);
case "dddd":
return R[N.$W];
case "H":
return String(b);
case "HH":
return C.s(b, 2, "0");
case "h":
return pe(1);
case "hh":
return pe(2);
case "a":
return fe(b, P, !0);
case "A":
return fe(b, P, !1);
case "m":
return String(P);
case "mm":
return C.s(P, 2, "0");
case "s":
return String(N.$s);
case "ss":
return C.s(N.$s, 2, "0");
case "SSS":
return C.s(N.$ms, 3, "0");
case "Z":
return O;
}
return null;
}(Y) || O.replace(":", "");
});
}, g.utcOffset = function() {
return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
}, g.diff = function(p, N, w) {
var D, O = this, b = C.p(N), P = q(p), F = (P.utcOffset() - this.utcOffset()) * i, R = this - P, y = function() {
return C.m(O, P);
};
switch (b) {
case m:
D = y() / 12;
break;
case l:
D = y();
break;
case h:
D = y() / 3;
break;
case a:
D = (R - F) / 6048e5;
break;
case f:
D = (R - F) / 864e5;
break;
case c:
D = R / r;
break;
case u:
D = R / i;
break;
case o:
D = R / t;
break;
default:
D = R;
}
return w ? D : C.a(D);
}, g.daysInMonth = function() {
return this.endOf(l).$D;
}, g.$locale = function() {
return H[this.$L];
}, g.locale = function(p, N) {
if (!p) return this.$L;
var w = this.clone(), D = Q(p, N, !0);
return D && (w.$L = D), w;
}, g.clone = function() {
return C.w(this.$d, this);
}, g.toDate = function() {
return new Date(this.valueOf());
}, g.toJSON = function() {
return this.isValid() ? this.toISOString() : null;
}, g.toISOString = function() {
return this.$d.toISOString();
}, g.toString = function() {
return this.$d.toUTCString();
}, $;
}(), oe = z.prototype;
return q.prototype = oe, [["$ms", s], ["$s", o], ["$m", u], ["$H", c], ["$W", f], ["$M", l], ["$y", m], ["$D", k]].forEach(function($) {
oe[$[1]] = function(g) {
return this.$g(g, $[0], $[1]);
};
}), q.extend = function($, g) {
return $.$i || ($(g, z, q), $.$i = !0), q;
}, q.locale = Q, q.isDayjs = ee, q.unix = function($) {
return q(1e3 * $);
}, q.en = H[X], q.Ls = H, q.p = {}, q;
});
})(Fe);
var Xe = Fe.exports;
const ce = /* @__PURE__ */ Ie(Xe);
var Ze = { exports: {} };
(function(e, n) {
(function(t, i) {
e.exports = i();
})(Ae, function() {
return function(t, i, r) {
i.prototype.dayOfYear = function(s) {
var o = Math.round((r(this).startOf("day") - r(this).startOf("year")) / 864e5) + 1;
return s == null ? o : this.add(s - o, "day");
};
};
});
})(Ze);
var Qe = Ze.exports;
const Ke = /* @__PURE__ */ Ie(Qe);
ce.extend(Ke);
const ze = (e, n, t) => {
const i = (t == null ? void 0 : t.utc) ?? ce(e).utcOffset() / 60, r = 15 * Math.abs(i), s = 360 / 365 * (ce(e).dayOfYear() - 81), o = s * (Math.PI / 180), u = 9.87 * Math.sin(2 * o) - 7.53 * Math.cos(o) - 1.5 * Math.sin(o), c = 4 * (n - r) + u;
return { LST: ce(e).add(c, "minute"), TC: c, EoT: u, B: s, LSTM: r };
}, Gn = (e, n) => ze(/* @__PURE__ */ new Date(), e, n);
/*!
* 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 he = 9e15, se = 1e9, Oe = "0123456789abcdef", Ne = "2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058", Me = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789", ke = {
// 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: -he,
// -1 to -EXP_LIMIT
// The maximum exponent value, above which overflow to Infinity occurs.
// JavaScript numbers: 308 (1.7976931348623157e+308)
maxE: he,
// 1 to EXP_LIMIT
// Whether to use cryptographically-secure random number generation, if available.
crypto: !1
// true/false
}, He, x, E = !0, Se = "[DecimalError] ", re = Se + "Invalid argument: ", Ue = Se + "Precision limit exceeded", Re = Se + "crypto unavailable", Be = "[object Decimal]", B = Math.floor, A = Math.pow, xe = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i, en = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i, nn = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i, Ye = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i, G = 1e7, M = 7, tn = 9007199254740991, rn = Ne.length - 1, Ce = Me.length - 1, d = { toStringTag: Be };
d.absoluteValue = d.abs = function() {
var e = new this.constructor(this);
return e.s < 0 && (e.s = 1), v(e);
};
d.ceil = function() {
return v(new this.constructor(this), this.e + 1, 2);
};
d.clampedTo = d.clamp = function(e, n) {
var t, i = this, r = i.constructor;
if (e = new r(e), n = new r(n), !e.s || !n.s) return new r(NaN);
if (e.gt(n)) throw Error(re + n);
return t = i.cmp(e), t < 0 ? e : i.cmp(n) > 0 ? n : new r(i);
};
d.comparedTo = d.cmp = function(e) {
var n, t, i, r, s = this, o = s.d, u = (e = new s.constructor(e)).d, c = s.s, f = e.s;
if (!o || !u)
return !c || !f ? NaN : c !== f ? c : o === u ? 0 : !o ^ c < 0 ? 1 : -1;
if (!o[0] || !u[0]) return o[0] ? c : u[0] ? -f : 0;
if (c !== f) return c;
if (s.e !== e.e) return s.e > e.e ^ c < 0 ? 1 : -1;
for (i = o.length, r = u.length, n = 0, t = i < r ? i : r; n < t; ++n)
if (o[n] !== u[n]) return o[n] > u[n] ^ c < 0 ? 1 : -1;
return i === r ? 0 : i > r ^ c < 0 ? 1 : -1;
};
d.cosine = d.cos = function() {
var e, n, t = this, i = t.constructor;
return t.d ? t.d[0] ? (e = i.precision, n = i.rounding, i.precision = e + Math.max(t.e, t.sd()) + M, i.rounding = 1, t = sn(i, Je(i, t)), i.precision = e, i.rounding = n, v(x == 2 || x == 3 ? t.neg() : t, e, n, !0)) : new i(1) : new i(NaN);
};
d.cubeRoot = d.cbrt = function() {
var e, n, t, i, r, s, o, u, c, f, a = this, l = a.constructor;
if (!a.isFinite() || a.isZero()) return new l(a);
for (E = !1, s = a.s * A(a.s * a, 1 / 3), !s || Math.abs(s) == 1 / 0 ? (t = U(a.d), e = a.e, (s = (e - t.length + 1) % 3) && (t += s == 1 || s == -2 ? "0" : "00"), s = A(t, 1 / 3), e = B((e + 1) / 3) - (e % 3 == (e < 0 ? -1 : 2)), s == 1 / 0 ? t = "5e" + e : (t = s.toExponential(), t = t.slice(0, t.indexOf("e") + 1) + e), i = new l(t), i.s = a.s) : i = new l(s.toString()), o = (e = l.precision) + 3; ; )
if (u = i, c = u.times(u).times(u), f = c.plus(a), i = T(f.plus(a).times(u), f.plus(c), o + 2, 1), U(u.d).slice(0, o) === (t = U(i.d)).slice(0, o))
if (t = t.slice(o - 3, o + 1), t == "9999" || !r && t == "4999") {
if (!r && (v(u, e + 1, 0), u.times(u).times(u).eq(a))) {
i = u;
break;
}
o += 4, r = 1;
} else {
(!+t || !+t.slice(1) && t.charAt(0) == "5") && (v(i, e + 1, 1), n = !i.times(i).times(i).eq(a));
break;
}
return E = !0, v(i, e, l.rounding, n);
};
d.decimalPlaces = d.dp = function() {
var e, n = this.d, t = NaN;
if (n) {
if (e = n.length - 1, t = (e - B(this.e / M)) * M, e = n[e], e) for (; e % 10 == 0; e /= 10) t--;
t < 0 && (t = 0);
}
return t;
};
d.dividedBy = d.div = function(e) {
return T(this, new this.constructor(e));
};
d.dividedToIntegerBy = d.divToInt = function(e) {
var n = this, t = n.constructor;
return v(T(n, new t(e), 0, 1, 1), t.precision, t.rounding);
};
d.equals = d.eq = function(e) {
return this.cmp(e) === 0;
};
d.floor = function() {
return v(new this.constructor(this), this.e + 1, 3);
};
d.greaterThan = d.gt = function(e) {
return this.cmp(e) > 0;
};
d.greaterThanOrEqualTo = d.gte = function(e) {
var n = this.cmp(e);
return n == 1 || n === 0;
};
d.hyperbolicCosine = d.cosh = function() {
var e, n, t, i, r, s = this, o = s.constructor, u = new o(1);
if (!s.isFinite()) return new o(s.s ? 1 / 0 : NaN);
if (s.isZero()) return u;
t = o.precision, i = o.rounding, o.precision = t + Math.max(s.e, s.sd()) + 4, o.rounding = 1, r = s.d.length, r < 32 ? (e = Math.ceil(r / 3), n = (1 / De(4, e)).toString()) : (e = 16, n = "2.3283064365386962890625e-10"), s = de(o, 1, s.times(n), new o(1), !0);
for (var c, f = e, a = new o(8); f--; )
c = s.times(s), s = u.minus(c.times(a.minus(c.times(a))));
return v(s, o.precision = t, o.rounding = i, !0);
};
d.hyperbolicSine = d.sinh = function() {
var e, n, t, i, r = this, s = r.constructor;
if (!r.isFinite() || r.isZero()) return new s(r);
if (n = s.precision, t = s.rounding, s.precision = n + Math.max(r.e, r.sd()) + 4, s.rounding = 1, i = r.d.length, i < 3)
r = de(s, 2, r, r, !0);
else {
e = 1.4 * Math.sqrt(i), e = e > 16 ? 16 : e | 0, r = r.times(1 / De(5, e)), r = de(s, 2, r, r, !0);
for (var o, u = new s(5), c = new s(16), f = new s(20); e--; )
o = r.times(r), r = r.times(u.plus(o.times(c.times(o).plus(f))));
}
return s.precision = n, s.rounding = t, v(r, n, t, !0);
};
d.hyperbolicTangent = d.tanh = function() {
var e, n, t = this, i = t.constructor;
return t.isFinite() ? t.isZero() ? new i(t) : (e = i.precision, n = i.rounding, i.precision = e + 7, i.rounding = 1, T(t.sinh(), t.cosh(), i.precision = e, i.rounding = n)) : new i(t.s);
};
d.inverseCosine = d.acos = function() {
var e, n = this, t = n.constructor, i = n.abs().cmp(1), r = t.precision, s = t.rounding;
return i !== -1 ? i === 0 ? n.isNeg() ? J(t, r, s) : new t(0) : new t(NaN) : n.isZero() ? J(t, r + 4, s).times(0.5) : (t.precision = r + 6, t.rounding = 1, n = n.asin(), e = J(t, r + 4, s).times(0.5), t.precision = r, t.rounding = s, e.minus(n));
};
d.inverseHyperbolicCosine = d.acosh = function() {
var e, n, t = this, i = t.constructor;
return t.lte(1) ? new i(t.eq(1) ? 0 : NaN) : t.isFinite() ? (e = i.precision, n = i.rounding, i.precision = e + Math.max(Math.abs(t.e), t.sd()) + 4, i.rounding = 1, E = !1, t = t.times(t).minus(1).sqrt().plus(t), E = !0, i.precision = e, i.rounding = n, t.ln()) : new i(t);
};
d.inverseHyperbolicSine = d.asinh = function() {
var e, n, t = this, i = t.constructor;
return !t.isFinite() || t.isZero() ? new i(t) : (e = i.precision, n = i.rounding, i.precision = e + 2 * Math.max(Math.abs(t.e), t.sd()) + 6, i.rounding = 1, E = !1, t = t.times(t).plus(1).sqrt().plus(t), E = !0, i.precision = e, i.rounding = n, t.ln());
};
d.inverseHyperbolicTangent = d.atanh = function() {
var e, n, t, i, r = this, s = r.constructor;
return r.isFinite() ? r.e >= 0 ? new s(r.abs().eq(1) ? r.s / 0 : r.isZero() ? r : NaN) : (e = s.precision, n = s.rounding, i = r.sd(), Math.max(i, e) < 2 * -r.e - 1 ? v(new s(r), e, n, !0) : (s.precision = t = i - r.e, r = T(r.plus(1), new s(1).minus(r), t + e, 1), s.precision = e + 4, s.rounding = 1, r = r.ln(), s.precision = e, s.rounding = n, r.times(0.5))) : new s(NaN);
};
d.inverseSine = d.asin = function() {
var e, n, t, i, r = this, s = r.constructor;
return r.isZero() ? new s(r) : (n = r.abs().cmp(1), t = s.precision, i = s.rounding, n !== -1 ? n === 0 ? (e = J(s, t + 4, i).times(0.5), e.s = r.s, e) : new s(NaN) : (s.precision = t + 6, s.rounding = 1, r = r.div(new s(1).minus(r.times(r)).sqrt().plus(1)).atan(), s.precision = t, s.rounding = i, r.times(2)));
};
d.inverseTangent = d.atan = function() {
var e, n, t, i, r, s, o, u, c, f = this, a = f.constructor, l = a.precision, h = a.rounding;
if (f.isFinite()) {
if (f.isZero())
return new a(f);
if (f.abs().eq(1) && l + 4 <= Ce)
return o = J(a, l + 4, h).times(0.25), o.s = f.s, o;
} else {
if (!f.s) return new a(NaN);
if (l + 4 <= Ce)
return o = J(a, l + 4, h).times(0.5), o.s = f.s, o;
}
for (a.precision = u = l + 10, a.rounding = 1, t = Math.min(28, u / M + 2 | 0), e = t; e; --e) f = f.div(f.times(f).plus(1).sqrt().plus(1));
for (E = !1, n = Math.ceil(u / M), i = 1, c = f.times(f), o = new a(f), r = f; e !== -1; )
if (r = r.times(c), s = o.minus(r.div(i += 2)), r = r.times(c), o = s.plus(r.div(i += 2)), o.d[n] !== void 0) for (e = n; o.d[e] === s.d[e] && e--; ) ;
return t && (o = o.times(2 << t - 1)), E = !0, v(o, a.precision = l, a.rounding = h, !0);
};
d.isFinite = function() {
return !!this.d;
};
d.isInteger = d.isInt = function() {
return !!this.d && B(this.e / M) > this.d.length - 2;
};
d.isNaN = function() {
return !this.s;
};
d.isNegative = d.isNeg = function() {
return this.s < 0;
};
d.isPositive = d.isPos = function() {
return this.s > 0;
};
d.isZero = function() {
return !!this.d && this.d[0] === 0;
};
d.lessThan = d.lt = function(e) {
return this.cmp(e) < 0;
};
d.lessThanOrEqualTo = d.lte = function(e) {
return this.cmp(e) < 1;
};
d.logarithm = d.log = function(e) {
var n, t, i, r, s, o, u, c, f = this, a = f.constructor, l = a.precision, h = a.rounding, m = 5;
if (e == null)
e = new a(10), n = !0;
else {
if (e = new a(e), t = e.d, e.s < 0 || !t || !t[0] || e.eq(1)) return new a(NaN);
n = e.eq(10);
}
if (t = f.d, f.s < 0 || !t || !t[0] || f.eq(1))
return new a(t && !t[0] ? -1 / 0 : f.s != 1 ? NaN : t ? 0 : 1 / 0);
if (n)
if (t.length > 1)
s = !0;
else {
for (r = t[0]; r % 10 === 0; ) r /= 10;
s = r !== 1;
}
if (E = !1, u = l + m, o = ie(f, u), i = n ? $e(a, u + 10) : ie(e, u), c = T(o, i, u, 1), we(c.d, r = l, h))
do
if (u += 10, o = ie(f, u), i = n ? $e(a, u + 10) : ie(e, u), c = T(o, i, u, 1), !s) {
+U(c.d).slice(r + 1, r + 15) + 1 == 1e14 && (c = v(c, l + 1, 0));
break;
}
while (we(c.d, r += 10, h));
return E = !0, v(c, l, h);
};
d.minus = d.sub = function(e) {
var n, t, i, r, s, o, u, c, f, a, l, h, m = this, k = m.constructor;
if (e = new k(e), !m.d || !e.d)
return !m.s || !e.s ? e = new k(NaN) : m.d ? e.s = -e.s : e = new k(e.d || m.s !== e.s ? m : NaN), e;
if (m.s != e.s)
return e.s = -e.s, m.plus(e);
if (f = m.d, h = e.d, u = k.precision, c = k.rounding, !f[0] || !h[0]) {
if (h[0]) e.s = -e.s;
else if (f[0]) e = new k(m);
else return new k(c === 3 ? -0 : 0);
return E ? v(e, u, c) : e;
}
if (t = B(e.e / M), a = B(m.e / M), f = f.slice(), s = a - t, s) {
for (l = s < 0, l ? (n = f, s = -s, o = h.length) : (n = h, t = a, o = f.length), i = Math.max(Math.ceil(u / M), o) + 2, s > i && (s = i, n.length = 1), n.reverse(), i = s; i--; ) n.push(0);
n.reverse();
} else {
for (i = f.length, o = h.length, l = i < o, l && (o = i), i = 0; i < o; i++)
if (f[i] != h[i]) {
l = f[i] < h[i];
break;
}
s = 0;
}
for (l && (n = f, f = h, h = n, e.s = -e.s), o = f.length, i = h.length - o; i > 0; --i) f[o++] = 0;
for (i = h.length; i > s; ) {
if (f[--i] < h[i]) {
for (r = i; r && f[--r] === 0; ) f[r] = G - 1;
--f[r], f[i] += G;
}
f[i] -= h[i];
}
for (; f[--o] === 0; ) f.pop();
for (; f[0] === 0; f.shift()) --t;
return f[0] ? (e.d = f, e.e = Ee(f, t), E ? v(e, u, c) : e) : new k(c === 3 ? -0 : 0);
};
d.modulo = d.mod = function(e) {
var n, t = this, i = t.constructor;
return e = new i(e), !t.d || !e.s || e.d && !e.d[0] ? new i(NaN) : !e.d || t.d && !t.d[0] ? v(new i(t), i.precision, i.rounding) : (E = !1, i.modulo == 9 ? (n = T(t, e.abs(), 0, 3, 1), n.s *= e.s) : n = T(t, e, 0, i.modulo, 1), n = n.times(e), E = !0, t.minus(n));
};
d.naturalExponential = d.exp = function() {
return _e(this);
};
d.naturalLogarithm = d.ln = function() {
return ie(this);
};
d.negated = d.neg = function() {
var e = new this.constructor(this);
return e.s = -e.s, v(e);
};
d.plus = d.add = function(e) {
var n, t, i, r, s, o, u, c, f, a, l = this, h = l.constructor;
if (e = new h(e), !l.d || !e.d)
return !l.s || !e.s ? e = new h(NaN) : l.d || (e = new h(e.d || l.s === e.s ? l : NaN)), e;
if (l.s != e.s)
return e.s = -e.s, l.minus(e);
if (f = l.d, a = e.d, u = h.precision, c = h.rounding, !f[0] || !a[0])
return a[0] || (e = new h(l)), E ? v(e, u, c) : e;
if (s = B(l.e / M), i = B(e.e / M), f = f.slice(), r = s - i, r) {
for (r < 0 ? (t = f, r = -r, o = a.length) : (t = a, i = s, o = f.length), s = Math.ceil(u / M), o = s > o ? s + 1 : o + 1, r > o && (r = o, t.length = 1), t.reverse(); r--; ) t.push(0);
t.reverse();
}
for (o = f.length, r = a.length, o - r < 0 && (r = o, t = a, a = f, f = t), n = 0; r; )
n = (f[--r] = f[r] + a[r] + n) / G | 0, f[r] %= G;
for (n && (f.unshift(n), ++i), o = f.length; f[--o] == 0; ) f.pop();
return e.d = f, e.e = Ee(f, i), E ? v(e, u, c) : e;
};
d.precision = d.sd = function(e) {
var n, t = this;
if (e !== void 0 && e !== !!e && e !== 1 && e !== 0) throw Error(re + e);
return t.d ? (n = We(t.d), e && t.e + 1 > n && (n = t.e + 1)) : n = NaN, n;
};
d.round = function() {
var e = this, n = e.constructor;
return v(new n(e), e.e + 1, n.rounding);
};
d.sine = d.sin = function() {
var e, n, t = this, i = t.constructor;
return t.isFinite() ? t.isZero() ? new i(t) : (e = i.precision, n = i.rounding, i.precision = e + Math.max(t.e, t.sd()) + M, i.rounding = 1, t = un(i, Je(i, t)), i.precision = e, i.rounding = n, v(x > 2 ? t.neg() : t, e, n, !0)) : new i(NaN);
};
d.squareRoot = d.sqrt = function() {
var e, n, t, i, r, s, o = this, u = o.d, c = o.e, f = o.s, a = o.constructor;
if (f !== 1 || !u || !u[0])
return new a(!f || f < 0 && (!u || u[0]) ? NaN : u ? o : 1 / 0);
for (E = !1, f = Math.sqrt(+o), f == 0 || f == 1 / 0 ? (n = U(u), (n.length + c) % 2 == 0 && (n += "0"), f = Math.sqrt(n), c = B((c + 1) / 2) - (c < 0 || c % 2), f == 1 / 0 ? n = "5e" + c : (n = f.toExponential(), n = n.slice(0, n.indexOf("e") + 1) + c), i = new a(n)) : i = new a(f.toString()), t = (c = a.precision) + 3; ; )
if (s = i, i = s.plus(T(o, s, t + 2, 1)).times(0.5), U(s.d).slice(0, t) === (n = U(i.d)).slice(0, t))
if (n = n.slice(t - 3, t + 1), n == "9999" || !r && n == "4999") {
if (!r && (v(s, c + 1, 0), s.times(s).eq(o))) {
i = s;
break;
}
t += 4, r = 1;
} else {
(!+n || !+n.slice(1) && n.charAt(0) == "5") && (v(i, c + 1, 1), e = !i.times(i).eq(o));
break;
}
return E = !0, v(i, c, a.rounding, e);
};
d.tangent = d.tan = function() {
var e, n, t = this, i = t.constructor;
return t.isFinite() ? t.isZero() ? new i(t) : (e = i.precision, n = i.rounding, i.precision = e + 10, i.rounding = 1, t = t.sin(), t.s = 1, t = T(t, new i(1).minus(t.times(t)).sqrt(), e + 10, 0), i.precision = e, i.rounding = n, v(x == 2 || x == 4 ? t.neg() : t, e, n, !0)) : new i(NaN);
};
d.times = d.mul = function(e) {
var n, t, i, r, s, o, u, c, f, a = this, l = a.constructor, h = a.d, m = (e = new l(e)).d;
if (e.s *= a.s, !h || !h[0] || !m || !m[0])
return new l(!e.s || h && !h[0] && !m || m && !m[0] && !h ? NaN : !h || !m ? e.s / 0 : e.s * 0);
for (t = B(a.e / M) + B(e.e / M), c = h.length, f = m.length, c < f && (s = h, h = m, m = s, o = c, c = f, f = o), s = [], o = c + f, i = o; i--; ) s.push(0);
for (i = f; --i >= 0; ) {
for (n = 0, r = c + i; r > i; )
u = s[r] + m[i] * h[r - i - 1] + n, s[r--] = u % G | 0, n = u / G | 0;
s[r] = (s[r] + n) % G | 0;
}
for (; !s[--o]; ) s.pop();
return n ? ++t : s.shift(), e.d = s, e.e = Ee(s, t), E ? v(e, l.precision, l.rounding) : e;
};
d.toBinary = function(e, n) {
return be(this, 2, e, n);
};
d.toDecimalPlaces = d.toDP = function(e, n) {
var t = this, i = t.constructor;
return t = new i(t), e === void 0 ? t : (j(e, 0, se), n === void 0 ? n = i.rounding : j(n, 0, 8), v(t, e + t.e + 1, n));
};
d.toExponential = function(e, n) {
var t, i = this, r = i.constructor;
return e === void 0 ? t = K(i, !0) : (j(e, 0, se), n === void 0 ? n = r.rounding : j(n, 0, 8), i = v(new r(i), e + 1, n), t = K(i, !0, e + 1)), i.isNeg() && !i.isZero() ? "-" + t : t;
};
d.toFixed = function(e, n) {
var t, i, r = this, s = r.constructor;
return e === void 0 ? t = K(r) : (j(e, 0, se), n === void 0 ? n = s.rounding : j(n, 0, 8), i = v(new s(r), e + r.e + 1, n), t = K(i, !1, e + i.e + 1)), r.isNeg() && !r.isZero() ? "-" + t : t;
};
d.toFraction = function(e) {
var n, t, i, r, s, o, u, c, f, a, l, h, m = this, k = m.d, S = m.constructor;
if (!k) return new S(m);
if (f = t = new S(1), i = c = new S(0), n = new S(i), s = n.e = We(k) - m.e - 1, o = s % M, n.d[0] = A(10, o < 0 ? M + o : o), e == null)
e = s > 0 ? n : f;
else {
if (u = new S(e), !u.isInt() || u.lt(f)) throw Error(re + u);
e = u.gt(n) ? s > 0 ? n : f : u;
}
for (E = !1, u = new S(U(k)), a = S.precision, S.precision = s = k.length * M * 2; l = T(u, n, 0, 1, 1), r = t.plus(l.times(i)), r.cmp(e) != 1; )
t = i, i = r, r = f, f = c.plus(l.times(r)), c = r, r = n, n = u.minus(l.times(r)), u = r;
return r = T(e.minus(t), i, 0, 1, 1), c = c.plus(r.times(f)), t = t.plus(r.times(i)), c.s = f.s = m.s, h = T(f, i, s, 1).minus(m).abs().cmp(T(c, t, s, 1).minus(m).abs()) < 1 ? [f, i] : [c, t], S.precision = a, E = !0, h;
};
d.toHexadecimal = d.toHex = function(e, n) {
return be(this, 16, e, n);
};
d.toNearest = function(e, n) {
var t = this, i = t.constructor;
if (t = new i(t), e == null) {
if (!t.d) return t;
e = new i(1), n = i.rounding;
} else {
if (e = new i(e), n === void 0 ? n = i.rounding : j(n, 0, 8), !t.d) return e.s ? t : e;
if (!e.d)
return e.s && (e.s = t.s), e;
}
return e.d[0] ? (E = !1, t = T(t, e, 0, n, 1).times(e), E = !0, v(t)) : (e.s = t.s, t = e), t;
};
d.toNumber = function() {
return +this;
};
d.toOctal = function(e, n) {
return be(this, 8, e, n);
};
d.toPower = d.pow = function(e) {
var n, t, i, r, s, o, u = this, c = u.constructor, f = +(e = new c(e));
if (!u.d || !e.d || !u.d[0] || !e.d[0]) return new c(A(+u, f));
if (u = new c(u), u.eq(1)) return u;
if (i = c.precision, s = c.rounding, e.eq(1)) return v(u, i, s);
if (n = B(e.e / M), n >= e.d.length - 1 && (t = f < 0 ? -f : f) <= tn)
return r = je(c, u, t, i), e.s < 0 ? new c(1).div(r) : v(r, i, s);
if (o = u.s, o < 0) {
if (n < e.d.length - 1) return new c(NaN);
if (e.d[n] & 1 || (o = 1), u.e == 0 && u.d[0] == 1 && u.d.length == 1)
return u.s = o, u;
}
return t = A(+u, f), n = t == 0 || !isFinite(t) ? B(f * (Math.log("0." + U(u.d)) / Math.LN10 + u.e + 1)) : new c(t + "").e, n > c.maxE + 1 || n < c.minE - 1 ? new c(n > 0 ? o / 0 : 0) : (E = !1, c.rounding = u.s = 1, t = Math.min(12, (n + "").length), r = _e(e.times(ie(u, i + t)), i), r.d && (r = v(r, i + 5, 1), we(r.d, i, s) && (n = i + 10, r = v(_e(e.times(ie(u, n + t)), n), n + 5, 1), +U(r.d).slice(i + 1, i + 15) + 1 == 1e14 && (r = v(r, i + 1, 0)))), r.s = o, E = !0, c.rounding = s, v(r, i, s));
};
d.toPrecision = function(e, n) {
var t, i = this, r = i.constructor;
return e === void 0 ? t = K(i, i.e <= r.toExpNeg || i.e >= r.toExpPos) : (j(e, 1, se), n === void 0 ? n = r.rounding : j(n, 0, 8), i = v(new r(i), e, n), t = K(i, e <= i.e || i.e <= r.toExpNeg, e)), i.isNeg() && !i.isZero() ? "-" + t : t;
};
d.toSignificantDigits = d.toSD = function(e, n) {
var t = this, i = t.constructor;
return e === void 0 ? (e = i.precision, n = i.rounding) : (j(e, 1, se), n === void 0 ? n = i.rounding : j(n, 0, 8)), v(new i(t), e, n);
};
d.toString = function() {
var e = this, n = e.constructor, t = K(e, e.e <= n.toExpNeg || e.e >= n.toExpPos);
return e.isNeg() && !e.isZero() ? "-" + t : t;
};
d.truncated = d.trunc = function() {
return v(new this.constructor(this), this.e + 1, 1);
};
d.valueOf = d.toJSON = function() {
var e = this, n = e.constructor, t = K(e, e.e <= n.toExpNeg || e.e >= n.toExpPos);
return e.isNeg() ? "-" + t : t;
};
function U(e) {
var n, t, i, r = e.length - 1, s = "", o = e[0];
if (r > 0) {
for (s += o, n = 1; n < r; n++)
i = e[n] + "", t = M - i.length, t && (s += te(t)), s += i;
o = e[n], i = o + "", t = M - i.length, t && (s += te(t));
} else if (o === 0)
return "0";
for (; o % 10 === 0; ) o /= 10;
return s + o;
}
function j(e, n, t) {
if (e !== ~~e || e < n || e > t)
throw Error(re + e);
}
function we(e, n, t, i) {
var r, s, o, u;
for (s = e[0]; s >= 10; s /= 10) --n;
return --n < 0 ? (n += M, r = 0) : (r = Math.ceil((n + 1) / M), n %= M), s = A(10, M - n), u = e[r] % s | 0, i == null ? n < 3 ? (n == 0 ? u = u / 100 | 0 : n == 1 && (u = u / 10 | 0), o = t < 4 && u == 99999 || t > 3 && u == 49999 || u == 5e4 || u == 0) : o = (t < 4 && u + 1 == s || t > 3 && u + 1 == s / 2) && (e[r + 1] / s / 100 | 0) == A(10, n - 2) - 1 || (u == s / 2 || u == 0) && (e[r + 1] / s / 100 | 0) == 0 : n < 4 ? (n == 0 ? u = u / 1e3 | 0 : n == 1 ? u = u / 100 | 0 : n == 2 && (u = u / 10 | 0), o = (i || t < 4) && u == 9999 || !i && t > 3 && u == 4999) : o = ((i || t < 4) && u + 1 == s || !i && t > 3 && u + 1 == s / 2) && (e[r + 1] / s / 1e3 | 0) == A(10, n - 3) - 1, o;
}
function ve(e, n, t) {
for (var i, r = [0], s, o = 0, u = e.length; o < u; ) {
for (s = r.length; s--; ) r[s] *= n;
for (r[0] += Oe.indexOf(e.charAt(o++)), i = 0; i < r.length; i++)
r[i] > t - 1 && (r[i + 1] === void 0 && (r[i + 1] = 0), r[i + 1] += r[i] / t | 0, r[i] %= t);
}
return r.reverse();
}
function sn(e, n) {
var t, i, r;
if (n.isZero()) return n;
i = n.d.length, i < 32 ? (t = Math.ceil(i / 3), r = (1 / De(4, t)).toString()) : (t = 16, r = "2.3283064365386962890625e-10"), e.precision += t, n = de(e, 1, n.times(r), new e(1));
for (var s = t; s--; ) {
var o = n.times(n);
n = o.times(o).minus(o).times(8).plus(1);
}
return e.precision -= t, n;
}
var T = /* @__PURE__ */ function() {
function e(i, r, s) {
var o, u = 0, c = i.length;
for (i = i.slice(); c--; )
o = i[c] * r + u, i[c] = o % s | 0, u = o / s | 0;
return u && i.unshift(u), i;
}
function n(i, r, s, o) {
var u, c;
if (s != o)
c = s > o ? 1 : -1;
else
for (u = c = 0; u < s; u++)
if (i[u] != r[u]) {
c = i[u] > r[u] ? 1 : -1;
break;
}
return c;
}
function t(i, r, s, o) {
for (var u = 0; s--; )
i[s] -= u, u = i[s] < r[s] ? 1 : 0, i[s] = u * o + i[s] - r[s];
for (; !i[0] && i.length > 1; ) i.shift();
}
return function(i, r, s, o, u, c) {
var f, a, l, h, m, k, S, Z, L, V, _, I, X, H, ae, ee, Q, q, C, z, oe = i.constructor, $ = i.s == r.s ? 1 : -1, g = i.d, p = r.d;
if (!g || !g[0] || !p || !p[0])
return new oe(
// Return NaN if either NaN, or both Infinity or 0.
!i.s || !r.s || (g ? p && g[0] == p[0] : !p) ? NaN : (
// Return ±0 if x is 0 or y is ±Infinity, or return ±Infinity as y is 0.
g && g[0] == 0 || !p ? $ * 0 : $ / 0
)
);
for (c ? (m = 1, a = i.e - r.e) : (c = G, m = M, a = B(i.e / m) - B(r.e / m)), C = p.length, Q = g.length, L = new oe($), V = L.d = [], l = 0; p[l] == (g[l] || 0); l++) ;
if (p[l] > (g[l] || 0) && a--, s == null ? (H = s = oe.precision, o = oe.rounding) : u ? H = s + (i.e - r.e) + 1 : H = s, H < 0)
V.push(1), k = !0;
else {
if (H = H / m + 2 | 0, l = 0, C == 1) {
for (h = 0, p = p[0], H++; (l < Q || h) && H--; l++)
ae = h * c + (g[l] || 0), V[l] = ae / p | 0, h = ae % p | 0;
k = h || l < Q;
} else {
for (h = c / (p[0] + 1) | 0, h > 1 && (p = e(p, h, c), g = e(g, h, c), C = p.length, Q = g.length), ee = C, _ = g.slice(0, C), I = _.length; I < C; ) _[I++] = 0;
z = p.slice(), z.unshift(0), q = p[0], p[1] >= c / 2 && ++q;
do
h = 0, f = n(p, _, C, I), f < 0 ? (X = _[0], C != I && (X = X * c + (_[1] || 0)), h = X / q | 0, h > 1 ? (h >= c && (h = c - 1), S = e(p, h, c), Z = S.length, I = _.length, f = n(S, _, Z, I), f == 1 && (h--, t(S, C < Z ? z : p, Z, c))) : (h == 0 && (f = h = 1), S = p.slice()), Z = S.length, Z < I && S.unshift(0), t(_, S, I, c), f == -1 && (I = _.length, f = n(p, _, C, I), f < 1 && (h++, t(_, C < I ? z : p, I, c))), I = _.length) : f === 0 && (h++, _ = [0]), V[l++] = h, f && _[0] ? _[I++] = g[ee] || 0 : (_ = [g[ee]], I = 1);
while ((ee++ < Q || _[0] !== void 0) && H--);
k = _[0] !== void 0;
}
V[0] || V.shift();
}
if (m == 1)
L.e = a, He = k;
else {
for (l = 1, h = V[0]; h >= 10; h /= 10) l++;
L.e = l + a * m - 1, v(L, u ? s + L.e + 1 : s, o, k);
}
return L;
};
}();
function v(e, n, t, i) {
var r, s, o, u, c, f, a, l, h, m = e.constructor;
e: if (n != null) {
if (l = e.d, !l) return e;
for (r = 1, u = l[0]; u >= 10; u /= 10) r++;
if (s = n - r, s < 0)
s += M, o = n, a = l[h = 0], c = a / A(10, r - o - 1) % 10 | 0;
else if (h = Math.ceil((s + 1) / M), u = l.length, h >= u)
if (i) {
for (; u++ <= h; ) l.push(0);
a = c = 0, r = 1, s %= M, o = s - M + 1;
} else
break e;
else {
for (a = u = l[h], r = 1; u >= 10; u /= 10) r++;
s %= M, o = s - M + r, c = o < 0 ? 0 : a / A(10, r - o - 1) % 10 | 0;
}
if (i = i || n < 0 || l[h + 1] !== void 0 || (o < 0 ? a : a % A(10, r - o - 1)), f = t < 4 ? (c || i) && (t == 0 || t == (e.s < 0 ? 3 : 2)) : c > 5 || c == 5 && (t == 4 || i || t == 6 && // Check whether the digit to the left of the rounding digit is odd.
(s > 0 ? o > 0 ? a / A(10, r - o) : 0 : l[h - 1]) % 10 & 1 || t == (e.s < 0 ? 8 : 7)), n < 1 || !l[0])
return l.length = 0, f ? (n -= e.e + 1, l[0] = A(10, (M - n % M) % M), e.e = -n || 0) : l[0] = e.e = 0, e;
if (s == 0 ? (l.length = h, u = 1, h--) : (l.length = h + 1, u = A(10, M - s), l[h] = o > 0 ? (a / A(10, r - o) % A(10, o) | 0) * u : 0), f)
for (; ; )
if (h == 0) {
for (s = 1, o = l[0]; o >= 10; o /= 10) s++;
for (o = l[0] += u, u = 1; o >= 10; o /= 10) u++;
s != u && (e.e++, l[0] == G && (l[0] = 1));
break;
} else {
if (l[h] += u, l[h] != G) break;
l[h--] = 0, u = 1;
}
for (s = l.length; l[--s] === 0; ) l.pop();
}
return E && (e.e > m.maxE ? (e.d = null, e.e = NaN) : e.e < m.minE && (e.e = 0, e.d = [0])), e;
}
function K(e, n, t) {
if (!e.isFinite()) return ye(e);
var i, r = e.e, s = U(e.d), o = s.length;
return n ? (t && (i = t - o) > 0 ? s = s.charAt(0) + "." + s.slice(1) + te(i) : o > 1 && (s = s.charAt(0) + "." + s.slice(1)), s = s + (e.e < 0 ? "e" : "e+") + e.e) : r < 0 ? (s = "0." + te(-r - 1) + s, t && (i = t - o) > 0 && (s += te(i))) : r >= o ? (s += te(r + 1 - o), t && (i = t - r - 1) > 0 && (s = s + "." + te(i))) : ((i = r + 1) < o && (s = s.slice(0, i) + "." + s.slice(i)), t && (i = t - o) > 0 && (r + 1 === o && (s += "."), s += te(i))), s;
}
function Ee(e, n) {
var t = e[0];
for (n *= M; t >= 10; t /= 10) n++;
return n;
}
function $e(e, n, t) {
if (n > rn)
throw E = !0, t && (e.precision = t), Error(Ue);
return v(new e(Ne), n, 1, !0);
}
function J(e, n, t) {
if (n > Ce) throw Error(Ue);
return v(new e(Me), n, t, !0);
}
function We(e) {
var n = e.length - 1, t = n * M + 1;
if (n = e[n], n) {
for (; n % 10 == 0; n /= 10) t--;
for (n = e[0]; n >= 10; n /= 10) t++;
}
return t;
}
function te(e) {
for (var n = ""; e--; ) n += "0";
return n;
}
function je(e, n, t, i) {
var r, s = new e(1), o = Math.ceil(i / M + 4);
for (E = !1; ; ) {
if (t % 2 && (s = s.times(n), qe(s.d, o) && (r = !0)), t = B(t / 2), t === 0) {
t = s.d.length - 1, r && s.d[t] === 0 && ++s.d[t];
break;
}
n = n.times(n), qe(n.d, o);
}
return E = !0, s;
}
function Le(e) {
return e.d[e.d.length - 1] & 1;
}
function Ve(e, n, t) {
for (var i, r = new e(n[0]), s = 0; ++s < n.length; )
if (i = new e(n[s]), i.s)
r[t](i) && (r = i);
else {
r = i;
break;
}
return r;
}
function _e(e, n) {
var t, i, r, s, o, u, c, f = 0, a = 0, l = 0, h = e.constructor, m = h.rounding, k = h.precision;
if (!e.d || !e.d[0] || e.e > 17)
return new h(e.d ? e.d[0] ? e.s < 0 ? 0 : 1 / 0 : 1 : e.s ? e.s < 0 ? 0 : e : NaN);
for (n == null ? (E = !1, c = k) : c = n, u = new h(0.03125); e.e > -2; )
e = e.times(u), l += 5;
for (i = Math.log(A(2, l)) / Math.LN10 * 2 + 5 | 0, c += i, t = s = o = new h(1), h.precision = c; ; ) {
if (s = v(s.times(e), c, 1), t = t.times(++a), u = o.plus(T(s, t, c, 1)), U(u.d).slice(0, c) === U(o.d).slice(0, c)) {
for (r = l; r--; ) o = v(o.times(o), c, 1);
if (n == null)
if (f < 3 && we(o.d, c - i, m, f))
h.precision = c += 10, t = s = u = new h(1), a = 0, f++;
else
return v(o, h.precision = k, m, E = !0);
else
return h.precision = k, o;
}
o = u;
}
}
function ie(e, n) {
var t, i, r, s, o, u, c, f, a, l, h, m = 1, k = 10, S = e, Z = S.d, L = S.constructor, V = L.rounding, _ = L.precision;
if (S.s < 0 || !Z || !Z[0] || !S.e && Z[0] == 1 && Z.length == 1)
return new L(Z && !Z[0] ? -1 / 0 : S.s != 1 ? NaN : Z ? 0 : S);
if (n == null ? (E = !1, a = _) : a = n, L.precision = a += k, t = U(Z), i = t.charAt(0), Math.abs(s = S.e) < 15e14) {
for (; i < 7 && i != 1 || i == 1 && t.charAt(1) > 3; )
S = S.times(e), t = U(S.d), i = t.charAt(0), m++;
s = S.e, i > 1 ? (S = new L("0." + t), s++) : S = new L(i + "." + t.slice(1));
} else
return f = $e(L, a + 2, _).times(s + ""), S = ie(new L(i + "." + t.slice(1)), a - k).plus(f), L.precision = _, n == null ? v(S, _, V, E = !0) : S;
for (l = S, c = o = S = T(S.minus(1), S.plus(1), a, 1), h = v(S.times(S), a, 1), r = 3; ; ) {
if (o = v(o.times(h), a, 1), f = c.plus(T(o, new L(r), a, 1)), U(f.d).slice(0, a) === U(c.d).slice(0, a))
if (c = c.times(2), s !== 0 && (c = c.plus($e(L, a + 2, _).times(s + ""))), c = T(c, new L(m), a, 1), n == null)
if (we(c.d, a - k, V, u))
L.precision = a += k, f = o = S = T(l.minus(1), l.plus(1), a, 1), h = v(S.times(S), a, 1), r = u = 1;
else
return v(c, L.precision = _, V, E = !0);
else
return L.precision = _, c;
c = f, r += 2;
}
}
function ye(e) {
return String(e.s * e.s / 0);
}
function Te(e, n) {
var t, i, r;
for ((t = n.indexOf(".")) > -1 && (n = n.replace(".", "")), (i = n.search(/e/i)) > 0 ? (t < 0 && (t = i), t += +n.slice(i + 1), n = n.substring(0, i)) : t < 0 && (t = n.length), i = 0; n.charCodeAt(i) === 48; i++) ;
for (r = n.length; n.charCodeAt(r - 1) === 48; --r) ;
if (n = n.slice(i, r), n) {
if (r -= i, e.e = t = t - i - 1, e.d = [], i = (t + 1) % M, t < 0 && (i += M), i < r) {
for (i && e.d.push(+n.slice(0, i)), r -= M; i < r; ) e.d.push(+n.slice(i, i += M));
n = n.slice(i), i = M - n.length;
} else
i -= r;
for (; i--; ) n += "0";
e.d.push(+n), E && (e.e > e.constructor.maxE ? (e.d = null, e.e = NaN) : e.e < e.constructor.minE && (e.e = 0, e.d = [0]));
} else
e.e = 0, e.d = [0];
return e;
}
function on(e, n) {
var t, i, r, s, o, u, c, f, a;
if (n.indexOf("_") > -1) {
if (n = n.replace(/(\d)_(?=\d)/g, "$1"), Ye.test(n)) return Te(e, n);
} else if (n === "Infinity" || n === "NaN")
return +n || (e.s = NaN), e.e = NaN, e.d = null, e;
if (en.test(n))
t = 16, n = n.toLowerCase();
else if (xe.test(n))
t = 2;
else if (nn.test(n))
t = 8;
else
throw Error(re + n);
for (s = n.search(/p/i), s > 0 ? (c = +n.slice(s + 1), n = n.substring(2, s)) : n = n.slice(2), s = n.indexOf("."), o = s >= 0, i = e.constructor, o && (n = n.replace(".", ""), u = n.length, s = u - s, r = je(i, new i(t), s, s * 2)), f = ve(n, t, G), a = f.length - 1, s = a; f[s] === 0; --s) f.pop();
return s < 0 ? new i(e.s * 0) : (e.e = Ee(f, a), e.d = f, E = !1, o && (e = T(e, r, u * 4)), c && (e = e.times(Math.abs(c) < 54 ? A(2, c) : W.pow(2, c))), E = !0, e);
}
function un(e, n) {
var t, i = n.d.length;
if (i < 3)
return n.isZero() ? n : de(e, 2, n, n);
t = 1.4 * Math.sqrt(i), t = t > 16 ? 16 : t | 0, n = n.times(1 / De(5, t)), n = de(e, 2, n, n);
for (var r, s = new e(5), o = new e(16), u = new e(20); t--; )
r = n.times(n), n = n.times(s.plus(r.times(o.times(r).minus(u))));
return n;
}
function de(e, n, t, i, r) {
var s, o, u, c, f = e.precision, a = Math.ceil(f / M);
for (E = !1, c = t.times(t), u = new e(i); ; ) {
if (o = T(u.times(c), new e(n++ * n++), f, 1), u = r ? i.plus(o) : i.minus(o), i = T(o.times(c), new e(n++ * n++), f, 1), o = u.plus(i), o.d[a] !== void 0) {
for (s = a; o.d[s] === u.d[s] && s--; ) ;
if (s == -1) break;
}
s = u, u = i, i = o, o = s;
}
return E = !0, o.d.length = a + 1, o;
}
function De(e, n) {
for (var t = e; --n; ) t *= e;
return t;
}
function Je(e, n) {
var t, i = n.s < 0, r = J(e, e.precision, 1), s = r.times(0.5);
if (n = n.abs(), n.lte(s))
return x = i ? 4 : 1, n;
if (t = n.divToInt(r), t.isZe