@formatjs/intl-datetimeformat 6.16.5 → 6.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/README.md +1 -1
  2. package/lib/src/abstract/BestFitFormatMatcher.js +1 -1
  3. package/lib/src/abstract/FormatDateTimeRangeToParts.d.ts +2 -1
  4. package/lib/src/abstract/PartitionDateTimeRangePattern.d.ts +1 -1
  5. package/lib/src/abstract/PartitionDateTimeRangePattern.js +2 -2
  6. package/lib/src/core.js +5 -5
  7. package/lib/src/data/all-tz.d.ts +2 -2
  8. package/lib/src/data/all-tz.js +2 -1
  9. package/package.json +5 -5
  10. package/polyfill.iife.js +2424 -43
  11. package/src/abstract/BestFitFormatMatcher.js +1 -1
  12. package/src/abstract/FormatDateTimeRangeToParts.d.ts +2 -1
  13. package/src/abstract/PartitionDateTimeRangePattern.d.ts +1 -1
  14. package/src/abstract/PartitionDateTimeRangePattern.js +1 -1
  15. package/src/core.js +5 -5
  16. package/src/data/all-tz.d.ts +2 -2
  17. package/src/data/all-tz.js +2 -1
  18. package/index.js.map +0 -1
  19. package/lib/index.js.map +0 -1
  20. package/lib/polyfill-force.js.map +0 -1
  21. package/lib/polyfill.js.map +0 -1
  22. package/lib/should-polyfill.js.map +0 -1
  23. package/lib/src/abstract/BasicFormatMatcher.js.map +0 -1
  24. package/lib/src/abstract/BestFitFormatMatcher.js.map +0 -1
  25. package/lib/src/abstract/DateTimeStyleFormat.js.map +0 -1
  26. package/lib/src/abstract/FormatDateTime.js.map +0 -1
  27. package/lib/src/abstract/FormatDateTimePattern.js.map +0 -1
  28. package/lib/src/abstract/FormatDateTimeRange.js.map +0 -1
  29. package/lib/src/abstract/FormatDateTimeRangeToParts.js.map +0 -1
  30. package/lib/src/abstract/FormatDateTimeToParts.js.map +0 -1
  31. package/lib/src/abstract/InitializeDateTimeFormat.js.map +0 -1
  32. package/lib/src/abstract/PartitionDateTimePattern.js.map +0 -1
  33. package/lib/src/abstract/PartitionDateTimeRangePattern.js.map +0 -1
  34. package/lib/src/abstract/ToDateTimeOptions.js.map +0 -1
  35. package/lib/src/abstract/ToLocalTime.js.map +0 -1
  36. package/lib/src/abstract/skeleton.js.map +0 -1
  37. package/lib/src/abstract/utils.js.map +0 -1
  38. package/lib/src/core.js.map +0 -1
  39. package/lib/src/data/all-tz.js.map +0 -1
  40. package/lib/src/data/links.js.map +0 -1
  41. package/lib/src/get_internal_slots.js.map +0 -1
  42. package/lib/src/packer.js.map +0 -1
  43. package/lib/src/to_locale_string.js.map +0 -1
  44. package/lib/src/types.js.map +0 -1
  45. package/lib/supported-locales.generated.js.map +0 -1
  46. package/lib/test262-main.js.map +0 -1
  47. package/polyfill-force.js.map +0 -1
  48. package/polyfill.js.map +0 -1
  49. package/should-polyfill.js.map +0 -1
  50. package/src/abstract/BasicFormatMatcher.js.map +0 -1
  51. package/src/abstract/BestFitFormatMatcher.js.map +0 -1
  52. package/src/abstract/DateTimeStyleFormat.js.map +0 -1
  53. package/src/abstract/FormatDateTime.js.map +0 -1
  54. package/src/abstract/FormatDateTimePattern.js.map +0 -1
  55. package/src/abstract/FormatDateTimeRange.js.map +0 -1
  56. package/src/abstract/FormatDateTimeRangeToParts.js.map +0 -1
  57. package/src/abstract/FormatDateTimeToParts.js.map +0 -1
  58. package/src/abstract/InitializeDateTimeFormat.js.map +0 -1
  59. package/src/abstract/PartitionDateTimePattern.js.map +0 -1
  60. package/src/abstract/PartitionDateTimeRangePattern.js.map +0 -1
  61. package/src/abstract/ToDateTimeOptions.js.map +0 -1
  62. package/src/abstract/ToLocalTime.js.map +0 -1
  63. package/src/abstract/skeleton.js.map +0 -1
  64. package/src/abstract/utils.js.map +0 -1
  65. package/src/core.js.map +0 -1
  66. package/src/data/all-tz.js.map +0 -1
  67. package/src/data/links.js.map +0 -1
  68. package/src/get_internal_slots.js.map +0 -1
  69. package/src/packer.js.map +0 -1
  70. package/src/to_locale_string.js.map +0 -1
  71. package/src/types.js.map +0 -1
  72. package/supported-locales.generated.js.map +0 -1
  73. package/test262-main.js.map +0 -1
package/polyfill.iife.js CHANGED
@@ -52,6 +52,2361 @@
52
52
  return ianaTimeZone;
53
53
  }
54
54
 
55
+ // node_modules/.aspect_rules_js/decimal.js@10.4.3/node_modules/decimal.js/decimal.mjs
56
+ var EXP_LIMIT = 9e15;
57
+ var MAX_DIGITS = 1e9;
58
+ var NUMERALS = "0123456789abcdef";
59
+ var LN10 = "2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058";
60
+ var PI = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789";
61
+ var DEFAULTS = {
62
+ // These values must be integers within the stated ranges (inclusive).
63
+ // Most of these values can be changed at run-time using the `Decimal.config` method.
64
+ // The maximum number of significant digits of the result of a calculation or base conversion.
65
+ // E.g. `Decimal.config({ precision: 20 });`
66
+ precision: 20,
67
+ // 1 to MAX_DIGITS
68
+ // The rounding mode used when rounding to `precision`.
69
+ //
70
+ // ROUND_UP 0 Away from zero.
71
+ // ROUND_DOWN 1 Towards zero.
72
+ // ROUND_CEIL 2 Towards +Infinity.
73
+ // ROUND_FLOOR 3 Towards -Infinity.
74
+ // ROUND_HALF_UP 4 Towards nearest neighbour. If equidistant, up.
75
+ // ROUND_HALF_DOWN 5 Towards nearest neighbour. If equidistant, down.
76
+ // ROUND_HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour.
77
+ // ROUND_HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity.
78
+ // ROUND_HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
79
+ //
80
+ // E.g.
81
+ // `Decimal.rounding = 4;`
82
+ // `Decimal.rounding = Decimal.ROUND_HALF_UP;`
83
+ rounding: 4,
84
+ // 0 to 8
85
+ // The modulo mode used when calculating the modulus: a mod n.
86
+ // The quotient (q = a / n) is calculated according to the corresponding rounding mode.
87
+ // The remainder (r) is calculated as: r = a - n * q.
88
+ //
89
+ // UP 0 The remainder is positive if the dividend is negative, else is negative.
90
+ // DOWN 1 The remainder has the same sign as the dividend (JavaScript %).
91
+ // FLOOR 3 The remainder has the same sign as the divisor (Python %).
92
+ // HALF_EVEN 6 The IEEE 754 remainder function.
93
+ // EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)). Always positive.
94
+ //
95
+ // Truncated division (1), floored division (3), the IEEE 754 remainder (6), and Euclidian
96
+ // division (9) are commonly used for the modulus operation. The other rounding modes can also
97
+ // be used, but they may not give useful results.
98
+ modulo: 1,
99
+ // 0 to 9
100
+ // The exponent value at and beneath which `toString` returns exponential notation.
101
+ // JavaScript numbers: -7
102
+ toExpNeg: -7,
103
+ // 0 to -EXP_LIMIT
104
+ // The exponent value at and above which `toString` returns exponential notation.
105
+ // JavaScript numbers: 21
106
+ toExpPos: 21,
107
+ // 0 to EXP_LIMIT
108
+ // The minimum exponent value, beneath which underflow to zero occurs.
109
+ // JavaScript numbers: -324 (5e-324)
110
+ minE: -EXP_LIMIT,
111
+ // -1 to -EXP_LIMIT
112
+ // The maximum exponent value, above which overflow to Infinity occurs.
113
+ // JavaScript numbers: 308 (1.7976931348623157e+308)
114
+ maxE: EXP_LIMIT,
115
+ // 1 to EXP_LIMIT
116
+ // Whether to use cryptographically-secure random number generation, if available.
117
+ crypto: false
118
+ // true/false
119
+ };
120
+ var inexact;
121
+ var quadrant;
122
+ var external = true;
123
+ var decimalError = "[DecimalError] ";
124
+ var invalidArgument = decimalError + "Invalid argument: ";
125
+ var precisionLimitExceeded = decimalError + "Precision limit exceeded";
126
+ var cryptoUnavailable = decimalError + "crypto unavailable";
127
+ var tag = "[object Decimal]";
128
+ var mathfloor = Math.floor;
129
+ var mathpow = Math.pow;
130
+ var isBinary = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i;
131
+ var isHex = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i;
132
+ var isOctal = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i;
133
+ var isDecimal = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;
134
+ var BASE = 1e7;
135
+ var LOG_BASE = 7;
136
+ var MAX_SAFE_INTEGER = 9007199254740991;
137
+ var LN10_PRECISION = LN10.length - 1;
138
+ var PI_PRECISION = PI.length - 1;
139
+ var P = { toStringTag: tag };
140
+ P.absoluteValue = P.abs = function() {
141
+ var x = new this.constructor(this);
142
+ if (x.s < 0)
143
+ x.s = 1;
144
+ return finalise(x);
145
+ };
146
+ P.ceil = function() {
147
+ return finalise(new this.constructor(this), this.e + 1, 2);
148
+ };
149
+ P.clampedTo = P.clamp = function(min2, max2) {
150
+ var k, x = this, Ctor = x.constructor;
151
+ min2 = new Ctor(min2);
152
+ max2 = new Ctor(max2);
153
+ if (!min2.s || !max2.s)
154
+ return new Ctor(NaN);
155
+ if (min2.gt(max2))
156
+ throw Error(invalidArgument + max2);
157
+ k = x.cmp(min2);
158
+ return k < 0 ? min2 : x.cmp(max2) > 0 ? max2 : new Ctor(x);
159
+ };
160
+ P.comparedTo = P.cmp = function(y) {
161
+ var i, j, xdL, ydL, x = this, xd = x.d, yd = (y = new x.constructor(y)).d, xs = x.s, ys = y.s;
162
+ if (!xd || !yd) {
163
+ return !xs || !ys ? NaN : xs !== ys ? xs : xd === yd ? 0 : !xd ^ xs < 0 ? 1 : -1;
164
+ }
165
+ if (!xd[0] || !yd[0])
166
+ return xd[0] ? xs : yd[0] ? -ys : 0;
167
+ if (xs !== ys)
168
+ return xs;
169
+ if (x.e !== y.e)
170
+ return x.e > y.e ^ xs < 0 ? 1 : -1;
171
+ xdL = xd.length;
172
+ ydL = yd.length;
173
+ for (i = 0, j = xdL < ydL ? xdL : ydL; i < j; ++i) {
174
+ if (xd[i] !== yd[i])
175
+ return xd[i] > yd[i] ^ xs < 0 ? 1 : -1;
176
+ }
177
+ return xdL === ydL ? 0 : xdL > ydL ^ xs < 0 ? 1 : -1;
178
+ };
179
+ P.cosine = P.cos = function() {
180
+ var pr, rm, x = this, Ctor = x.constructor;
181
+ if (!x.d)
182
+ return new Ctor(NaN);
183
+ if (!x.d[0])
184
+ return new Ctor(1);
185
+ pr = Ctor.precision;
186
+ rm = Ctor.rounding;
187
+ Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
188
+ Ctor.rounding = 1;
189
+ x = cosine(Ctor, toLessThanHalfPi(Ctor, x));
190
+ Ctor.precision = pr;
191
+ Ctor.rounding = rm;
192
+ return finalise(quadrant == 2 || quadrant == 3 ? x.neg() : x, pr, rm, true);
193
+ };
194
+ P.cubeRoot = P.cbrt = function() {
195
+ var e, m, n, r, rep, s, sd, t, t3, t3plusx, x = this, Ctor = x.constructor;
196
+ if (!x.isFinite() || x.isZero())
197
+ return new Ctor(x);
198
+ external = false;
199
+ s = x.s * mathpow(x.s * x, 1 / 3);
200
+ if (!s || Math.abs(s) == 1 / 0) {
201
+ n = digitsToString(x.d);
202
+ e = x.e;
203
+ if (s = (e - n.length + 1) % 3)
204
+ n += s == 1 || s == -2 ? "0" : "00";
205
+ s = mathpow(n, 1 / 3);
206
+ e = mathfloor((e + 1) / 3) - (e % 3 == (e < 0 ? -1 : 2));
207
+ if (s == 1 / 0) {
208
+ n = "5e" + e;
209
+ } else {
210
+ n = s.toExponential();
211
+ n = n.slice(0, n.indexOf("e") + 1) + e;
212
+ }
213
+ r = new Ctor(n);
214
+ r.s = x.s;
215
+ } else {
216
+ r = new Ctor(s.toString());
217
+ }
218
+ sd = (e = Ctor.precision) + 3;
219
+ for (; ; ) {
220
+ t = r;
221
+ t3 = t.times(t).times(t);
222
+ t3plusx = t3.plus(x);
223
+ r = divide(t3plusx.plus(x).times(t), t3plusx.plus(t3), sd + 2, 1);
224
+ if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
225
+ n = n.slice(sd - 3, sd + 1);
226
+ if (n == "9999" || !rep && n == "4999") {
227
+ if (!rep) {
228
+ finalise(t, e + 1, 0);
229
+ if (t.times(t).times(t).eq(x)) {
230
+ r = t;
231
+ break;
232
+ }
233
+ }
234
+ sd += 4;
235
+ rep = 1;
236
+ } else {
237
+ if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
238
+ finalise(r, e + 1, 1);
239
+ m = !r.times(r).times(r).eq(x);
240
+ }
241
+ break;
242
+ }
243
+ }
244
+ }
245
+ external = true;
246
+ return finalise(r, e, Ctor.rounding, m);
247
+ };
248
+ P.decimalPlaces = P.dp = function() {
249
+ var w, d = this.d, n = NaN;
250
+ if (d) {
251
+ w = d.length - 1;
252
+ n = (w - mathfloor(this.e / LOG_BASE)) * LOG_BASE;
253
+ w = d[w];
254
+ if (w)
255
+ for (; w % 10 == 0; w /= 10)
256
+ n--;
257
+ if (n < 0)
258
+ n = 0;
259
+ }
260
+ return n;
261
+ };
262
+ P.dividedBy = P.div = function(y) {
263
+ return divide(this, new this.constructor(y));
264
+ };
265
+ P.dividedToIntegerBy = P.divToInt = function(y) {
266
+ var x = this, Ctor = x.constructor;
267
+ return finalise(divide(x, new Ctor(y), 0, 1, 1), Ctor.precision, Ctor.rounding);
268
+ };
269
+ P.equals = P.eq = function(y) {
270
+ return this.cmp(y) === 0;
271
+ };
272
+ P.floor = function() {
273
+ return finalise(new this.constructor(this), this.e + 1, 3);
274
+ };
275
+ P.greaterThan = P.gt = function(y) {
276
+ return this.cmp(y) > 0;
277
+ };
278
+ P.greaterThanOrEqualTo = P.gte = function(y) {
279
+ var k = this.cmp(y);
280
+ return k == 1 || k === 0;
281
+ };
282
+ P.hyperbolicCosine = P.cosh = function() {
283
+ var k, n, pr, rm, len, x = this, Ctor = x.constructor, one = new Ctor(1);
284
+ if (!x.isFinite())
285
+ return new Ctor(x.s ? 1 / 0 : NaN);
286
+ if (x.isZero())
287
+ return one;
288
+ pr = Ctor.precision;
289
+ rm = Ctor.rounding;
290
+ Ctor.precision = pr + Math.max(x.e, x.sd()) + 4;
291
+ Ctor.rounding = 1;
292
+ len = x.d.length;
293
+ if (len < 32) {
294
+ k = Math.ceil(len / 3);
295
+ n = (1 / tinyPow(4, k)).toString();
296
+ } else {
297
+ k = 16;
298
+ n = "2.3283064365386962890625e-10";
299
+ }
300
+ x = taylorSeries(Ctor, 1, x.times(n), new Ctor(1), true);
301
+ var cosh2_x, i = k, d8 = new Ctor(8);
302
+ for (; i--; ) {
303
+ cosh2_x = x.times(x);
304
+ x = one.minus(cosh2_x.times(d8.minus(cosh2_x.times(d8))));
305
+ }
306
+ return finalise(x, Ctor.precision = pr, Ctor.rounding = rm, true);
307
+ };
308
+ P.hyperbolicSine = P.sinh = function() {
309
+ var k, pr, rm, len, x = this, Ctor = x.constructor;
310
+ if (!x.isFinite() || x.isZero())
311
+ return new Ctor(x);
312
+ pr = Ctor.precision;
313
+ rm = Ctor.rounding;
314
+ Ctor.precision = pr + Math.max(x.e, x.sd()) + 4;
315
+ Ctor.rounding = 1;
316
+ len = x.d.length;
317
+ if (len < 3) {
318
+ x = taylorSeries(Ctor, 2, x, x, true);
319
+ } else {
320
+ k = 1.4 * Math.sqrt(len);
321
+ k = k > 16 ? 16 : k | 0;
322
+ x = x.times(1 / tinyPow(5, k));
323
+ x = taylorSeries(Ctor, 2, x, x, true);
324
+ var sinh2_x, d5 = new Ctor(5), d16 = new Ctor(16), d20 = new Ctor(20);
325
+ for (; k--; ) {
326
+ sinh2_x = x.times(x);
327
+ x = x.times(d5.plus(sinh2_x.times(d16.times(sinh2_x).plus(d20))));
328
+ }
329
+ }
330
+ Ctor.precision = pr;
331
+ Ctor.rounding = rm;
332
+ return finalise(x, pr, rm, true);
333
+ };
334
+ P.hyperbolicTangent = P.tanh = function() {
335
+ var pr, rm, x = this, Ctor = x.constructor;
336
+ if (!x.isFinite())
337
+ return new Ctor(x.s);
338
+ if (x.isZero())
339
+ return new Ctor(x);
340
+ pr = Ctor.precision;
341
+ rm = Ctor.rounding;
342
+ Ctor.precision = pr + 7;
343
+ Ctor.rounding = 1;
344
+ return divide(x.sinh(), x.cosh(), Ctor.precision = pr, Ctor.rounding = rm);
345
+ };
346
+ P.inverseCosine = P.acos = function() {
347
+ var halfPi, x = this, Ctor = x.constructor, k = x.abs().cmp(1), pr = Ctor.precision, rm = Ctor.rounding;
348
+ if (k !== -1) {
349
+ return k === 0 ? x.isNeg() ? getPi(Ctor, pr, rm) : new Ctor(0) : new Ctor(NaN);
350
+ }
351
+ if (x.isZero())
352
+ return getPi(Ctor, pr + 4, rm).times(0.5);
353
+ Ctor.precision = pr + 6;
354
+ Ctor.rounding = 1;
355
+ x = x.asin();
356
+ halfPi = getPi(Ctor, pr + 4, rm).times(0.5);
357
+ Ctor.precision = pr;
358
+ Ctor.rounding = rm;
359
+ return halfPi.minus(x);
360
+ };
361
+ P.inverseHyperbolicCosine = P.acosh = function() {
362
+ var pr, rm, x = this, Ctor = x.constructor;
363
+ if (x.lte(1))
364
+ return new Ctor(x.eq(1) ? 0 : NaN);
365
+ if (!x.isFinite())
366
+ return new Ctor(x);
367
+ pr = Ctor.precision;
368
+ rm = Ctor.rounding;
369
+ Ctor.precision = pr + Math.max(Math.abs(x.e), x.sd()) + 4;
370
+ Ctor.rounding = 1;
371
+ external = false;
372
+ x = x.times(x).minus(1).sqrt().plus(x);
373
+ external = true;
374
+ Ctor.precision = pr;
375
+ Ctor.rounding = rm;
376
+ return x.ln();
377
+ };
378
+ P.inverseHyperbolicSine = P.asinh = function() {
379
+ var pr, rm, x = this, Ctor = x.constructor;
380
+ if (!x.isFinite() || x.isZero())
381
+ return new Ctor(x);
382
+ pr = Ctor.precision;
383
+ rm = Ctor.rounding;
384
+ Ctor.precision = pr + 2 * Math.max(Math.abs(x.e), x.sd()) + 6;
385
+ Ctor.rounding = 1;
386
+ external = false;
387
+ x = x.times(x).plus(1).sqrt().plus(x);
388
+ external = true;
389
+ Ctor.precision = pr;
390
+ Ctor.rounding = rm;
391
+ return x.ln();
392
+ };
393
+ P.inverseHyperbolicTangent = P.atanh = function() {
394
+ var pr, rm, wpr, xsd, x = this, Ctor = x.constructor;
395
+ if (!x.isFinite())
396
+ return new Ctor(NaN);
397
+ if (x.e >= 0)
398
+ return new Ctor(x.abs().eq(1) ? x.s / 0 : x.isZero() ? x : NaN);
399
+ pr = Ctor.precision;
400
+ rm = Ctor.rounding;
401
+ xsd = x.sd();
402
+ if (Math.max(xsd, pr) < 2 * -x.e - 1)
403
+ return finalise(new Ctor(x), pr, rm, true);
404
+ Ctor.precision = wpr = xsd - x.e;
405
+ x = divide(x.plus(1), new Ctor(1).minus(x), wpr + pr, 1);
406
+ Ctor.precision = pr + 4;
407
+ Ctor.rounding = 1;
408
+ x = x.ln();
409
+ Ctor.precision = pr;
410
+ Ctor.rounding = rm;
411
+ return x.times(0.5);
412
+ };
413
+ P.inverseSine = P.asin = function() {
414
+ var halfPi, k, pr, rm, x = this, Ctor = x.constructor;
415
+ if (x.isZero())
416
+ return new Ctor(x);
417
+ k = x.abs().cmp(1);
418
+ pr = Ctor.precision;
419
+ rm = Ctor.rounding;
420
+ if (k !== -1) {
421
+ if (k === 0) {
422
+ halfPi = getPi(Ctor, pr + 4, rm).times(0.5);
423
+ halfPi.s = x.s;
424
+ return halfPi;
425
+ }
426
+ return new Ctor(NaN);
427
+ }
428
+ Ctor.precision = pr + 6;
429
+ Ctor.rounding = 1;
430
+ x = x.div(new Ctor(1).minus(x.times(x)).sqrt().plus(1)).atan();
431
+ Ctor.precision = pr;
432
+ Ctor.rounding = rm;
433
+ return x.times(2);
434
+ };
435
+ P.inverseTangent = P.atan = function() {
436
+ var i, j, k, n, px, t, r, wpr, x2, x = this, Ctor = x.constructor, pr = Ctor.precision, rm = Ctor.rounding;
437
+ if (!x.isFinite()) {
438
+ if (!x.s)
439
+ return new Ctor(NaN);
440
+ if (pr + 4 <= PI_PRECISION) {
441
+ r = getPi(Ctor, pr + 4, rm).times(0.5);
442
+ r.s = x.s;
443
+ return r;
444
+ }
445
+ } else if (x.isZero()) {
446
+ return new Ctor(x);
447
+ } else if (x.abs().eq(1) && pr + 4 <= PI_PRECISION) {
448
+ r = getPi(Ctor, pr + 4, rm).times(0.25);
449
+ r.s = x.s;
450
+ return r;
451
+ }
452
+ Ctor.precision = wpr = pr + 10;
453
+ Ctor.rounding = 1;
454
+ k = Math.min(28, wpr / LOG_BASE + 2 | 0);
455
+ for (i = k; i; --i)
456
+ x = x.div(x.times(x).plus(1).sqrt().plus(1));
457
+ external = false;
458
+ j = Math.ceil(wpr / LOG_BASE);
459
+ n = 1;
460
+ x2 = x.times(x);
461
+ r = new Ctor(x);
462
+ px = x;
463
+ for (; i !== -1; ) {
464
+ px = px.times(x2);
465
+ t = r.minus(px.div(n += 2));
466
+ px = px.times(x2);
467
+ r = t.plus(px.div(n += 2));
468
+ if (r.d[j] !== void 0)
469
+ for (i = j; r.d[i] === t.d[i] && i--; )
470
+ ;
471
+ }
472
+ if (k)
473
+ r = r.times(2 << k - 1);
474
+ external = true;
475
+ return finalise(r, Ctor.precision = pr, Ctor.rounding = rm, true);
476
+ };
477
+ P.isFinite = function() {
478
+ return !!this.d;
479
+ };
480
+ P.isInteger = P.isInt = function() {
481
+ return !!this.d && mathfloor(this.e / LOG_BASE) > this.d.length - 2;
482
+ };
483
+ P.isNaN = function() {
484
+ return !this.s;
485
+ };
486
+ P.isNegative = P.isNeg = function() {
487
+ return this.s < 0;
488
+ };
489
+ P.isPositive = P.isPos = function() {
490
+ return this.s > 0;
491
+ };
492
+ P.isZero = function() {
493
+ return !!this.d && this.d[0] === 0;
494
+ };
495
+ P.lessThan = P.lt = function(y) {
496
+ return this.cmp(y) < 0;
497
+ };
498
+ P.lessThanOrEqualTo = P.lte = function(y) {
499
+ return this.cmp(y) < 1;
500
+ };
501
+ P.logarithm = P.log = function(base) {
502
+ var isBase10, d, denominator, k, inf, num, sd, r, arg = this, Ctor = arg.constructor, pr = Ctor.precision, rm = Ctor.rounding, guard = 5;
503
+ if (base == null) {
504
+ base = new Ctor(10);
505
+ isBase10 = true;
506
+ } else {
507
+ base = new Ctor(base);
508
+ d = base.d;
509
+ if (base.s < 0 || !d || !d[0] || base.eq(1))
510
+ return new Ctor(NaN);
511
+ isBase10 = base.eq(10);
512
+ }
513
+ d = arg.d;
514
+ if (arg.s < 0 || !d || !d[0] || arg.eq(1)) {
515
+ return new Ctor(d && !d[0] ? -1 / 0 : arg.s != 1 ? NaN : d ? 0 : 1 / 0);
516
+ }
517
+ if (isBase10) {
518
+ if (d.length > 1) {
519
+ inf = true;
520
+ } else {
521
+ for (k = d[0]; k % 10 === 0; )
522
+ k /= 10;
523
+ inf = k !== 1;
524
+ }
525
+ }
526
+ external = false;
527
+ sd = pr + guard;
528
+ num = naturalLogarithm(arg, sd);
529
+ denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
530
+ r = divide(num, denominator, sd, 1);
531
+ if (checkRoundingDigits(r.d, k = pr, rm)) {
532
+ do {
533
+ sd += 10;
534
+ num = naturalLogarithm(arg, sd);
535
+ denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
536
+ r = divide(num, denominator, sd, 1);
537
+ if (!inf) {
538
+ if (+digitsToString(r.d).slice(k + 1, k + 15) + 1 == 1e14) {
539
+ r = finalise(r, pr + 1, 0);
540
+ }
541
+ break;
542
+ }
543
+ } while (checkRoundingDigits(r.d, k += 10, rm));
544
+ }
545
+ external = true;
546
+ return finalise(r, pr, rm);
547
+ };
548
+ P.minus = P.sub = function(y) {
549
+ var d, e, i, j, k, len, pr, rm, xd, xe, xLTy, yd, x = this, Ctor = x.constructor;
550
+ y = new Ctor(y);
551
+ if (!x.d || !y.d) {
552
+ if (!x.s || !y.s)
553
+ y = new Ctor(NaN);
554
+ else if (x.d)
555
+ y.s = -y.s;
556
+ else
557
+ y = new Ctor(y.d || x.s !== y.s ? x : NaN);
558
+ return y;
559
+ }
560
+ if (x.s != y.s) {
561
+ y.s = -y.s;
562
+ return x.plus(y);
563
+ }
564
+ xd = x.d;
565
+ yd = y.d;
566
+ pr = Ctor.precision;
567
+ rm = Ctor.rounding;
568
+ if (!xd[0] || !yd[0]) {
569
+ if (yd[0])
570
+ y.s = -y.s;
571
+ else if (xd[0])
572
+ y = new Ctor(x);
573
+ else
574
+ return new Ctor(rm === 3 ? -0 : 0);
575
+ return external ? finalise(y, pr, rm) : y;
576
+ }
577
+ e = mathfloor(y.e / LOG_BASE);
578
+ xe = mathfloor(x.e / LOG_BASE);
579
+ xd = xd.slice();
580
+ k = xe - e;
581
+ if (k) {
582
+ xLTy = k < 0;
583
+ if (xLTy) {
584
+ d = xd;
585
+ k = -k;
586
+ len = yd.length;
587
+ } else {
588
+ d = yd;
589
+ e = xe;
590
+ len = xd.length;
591
+ }
592
+ i = Math.max(Math.ceil(pr / LOG_BASE), len) + 2;
593
+ if (k > i) {
594
+ k = i;
595
+ d.length = 1;
596
+ }
597
+ d.reverse();
598
+ for (i = k; i--; )
599
+ d.push(0);
600
+ d.reverse();
601
+ } else {
602
+ i = xd.length;
603
+ len = yd.length;
604
+ xLTy = i < len;
605
+ if (xLTy)
606
+ len = i;
607
+ for (i = 0; i < len; i++) {
608
+ if (xd[i] != yd[i]) {
609
+ xLTy = xd[i] < yd[i];
610
+ break;
611
+ }
612
+ }
613
+ k = 0;
614
+ }
615
+ if (xLTy) {
616
+ d = xd;
617
+ xd = yd;
618
+ yd = d;
619
+ y.s = -y.s;
620
+ }
621
+ len = xd.length;
622
+ for (i = yd.length - len; i > 0; --i)
623
+ xd[len++] = 0;
624
+ for (i = yd.length; i > k; ) {
625
+ if (xd[--i] < yd[i]) {
626
+ for (j = i; j && xd[--j] === 0; )
627
+ xd[j] = BASE - 1;
628
+ --xd[j];
629
+ xd[i] += BASE;
630
+ }
631
+ xd[i] -= yd[i];
632
+ }
633
+ for (; xd[--len] === 0; )
634
+ xd.pop();
635
+ for (; xd[0] === 0; xd.shift())
636
+ --e;
637
+ if (!xd[0])
638
+ return new Ctor(rm === 3 ? -0 : 0);
639
+ y.d = xd;
640
+ y.e = getBase10Exponent(xd, e);
641
+ return external ? finalise(y, pr, rm) : y;
642
+ };
643
+ P.modulo = P.mod = function(y) {
644
+ var q, x = this, Ctor = x.constructor;
645
+ y = new Ctor(y);
646
+ if (!x.d || !y.s || y.d && !y.d[0])
647
+ return new Ctor(NaN);
648
+ if (!y.d || x.d && !x.d[0]) {
649
+ return finalise(new Ctor(x), Ctor.precision, Ctor.rounding);
650
+ }
651
+ external = false;
652
+ if (Ctor.modulo == 9) {
653
+ q = divide(x, y.abs(), 0, 3, 1);
654
+ q.s *= y.s;
655
+ } else {
656
+ q = divide(x, y, 0, Ctor.modulo, 1);
657
+ }
658
+ q = q.times(y);
659
+ external = true;
660
+ return x.minus(q);
661
+ };
662
+ P.naturalExponential = P.exp = function() {
663
+ return naturalExponential(this);
664
+ };
665
+ P.naturalLogarithm = P.ln = function() {
666
+ return naturalLogarithm(this);
667
+ };
668
+ P.negated = P.neg = function() {
669
+ var x = new this.constructor(this);
670
+ x.s = -x.s;
671
+ return finalise(x);
672
+ };
673
+ P.plus = P.add = function(y) {
674
+ var carry, d, e, i, k, len, pr, rm, xd, yd, x = this, Ctor = x.constructor;
675
+ y = new Ctor(y);
676
+ if (!x.d || !y.d) {
677
+ if (!x.s || !y.s)
678
+ y = new Ctor(NaN);
679
+ else if (!x.d)
680
+ y = new Ctor(y.d || x.s === y.s ? x : NaN);
681
+ return y;
682
+ }
683
+ if (x.s != y.s) {
684
+ y.s = -y.s;
685
+ return x.minus(y);
686
+ }
687
+ xd = x.d;
688
+ yd = y.d;
689
+ pr = Ctor.precision;
690
+ rm = Ctor.rounding;
691
+ if (!xd[0] || !yd[0]) {
692
+ if (!yd[0])
693
+ y = new Ctor(x);
694
+ return external ? finalise(y, pr, rm) : y;
695
+ }
696
+ k = mathfloor(x.e / LOG_BASE);
697
+ e = mathfloor(y.e / LOG_BASE);
698
+ xd = xd.slice();
699
+ i = k - e;
700
+ if (i) {
701
+ if (i < 0) {
702
+ d = xd;
703
+ i = -i;
704
+ len = yd.length;
705
+ } else {
706
+ d = yd;
707
+ e = k;
708
+ len = xd.length;
709
+ }
710
+ k = Math.ceil(pr / LOG_BASE);
711
+ len = k > len ? k + 1 : len + 1;
712
+ if (i > len) {
713
+ i = len;
714
+ d.length = 1;
715
+ }
716
+ d.reverse();
717
+ for (; i--; )
718
+ d.push(0);
719
+ d.reverse();
720
+ }
721
+ len = xd.length;
722
+ i = yd.length;
723
+ if (len - i < 0) {
724
+ i = len;
725
+ d = yd;
726
+ yd = xd;
727
+ xd = d;
728
+ }
729
+ for (carry = 0; i; ) {
730
+ carry = (xd[--i] = xd[i] + yd[i] + carry) / BASE | 0;
731
+ xd[i] %= BASE;
732
+ }
733
+ if (carry) {
734
+ xd.unshift(carry);
735
+ ++e;
736
+ }
737
+ for (len = xd.length; xd[--len] == 0; )
738
+ xd.pop();
739
+ y.d = xd;
740
+ y.e = getBase10Exponent(xd, e);
741
+ return external ? finalise(y, pr, rm) : y;
742
+ };
743
+ P.precision = P.sd = function(z) {
744
+ var k, x = this;
745
+ if (z !== void 0 && z !== !!z && z !== 1 && z !== 0)
746
+ throw Error(invalidArgument + z);
747
+ if (x.d) {
748
+ k = getPrecision(x.d);
749
+ if (z && x.e + 1 > k)
750
+ k = x.e + 1;
751
+ } else {
752
+ k = NaN;
753
+ }
754
+ return k;
755
+ };
756
+ P.round = function() {
757
+ var x = this, Ctor = x.constructor;
758
+ return finalise(new Ctor(x), x.e + 1, Ctor.rounding);
759
+ };
760
+ P.sine = P.sin = function() {
761
+ var pr, rm, x = this, Ctor = x.constructor;
762
+ if (!x.isFinite())
763
+ return new Ctor(NaN);
764
+ if (x.isZero())
765
+ return new Ctor(x);
766
+ pr = Ctor.precision;
767
+ rm = Ctor.rounding;
768
+ Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
769
+ Ctor.rounding = 1;
770
+ x = sine(Ctor, toLessThanHalfPi(Ctor, x));
771
+ Ctor.precision = pr;
772
+ Ctor.rounding = rm;
773
+ return finalise(quadrant > 2 ? x.neg() : x, pr, rm, true);
774
+ };
775
+ P.squareRoot = P.sqrt = function() {
776
+ var m, n, sd, r, rep, t, x = this, d = x.d, e = x.e, s = x.s, Ctor = x.constructor;
777
+ if (s !== 1 || !d || !d[0]) {
778
+ return new Ctor(!s || s < 0 && (!d || d[0]) ? NaN : d ? x : 1 / 0);
779
+ }
780
+ external = false;
781
+ s = Math.sqrt(+x);
782
+ if (s == 0 || s == 1 / 0) {
783
+ n = digitsToString(d);
784
+ if ((n.length + e) % 2 == 0)
785
+ n += "0";
786
+ s = Math.sqrt(n);
787
+ e = mathfloor((e + 1) / 2) - (e < 0 || e % 2);
788
+ if (s == 1 / 0) {
789
+ n = "5e" + e;
790
+ } else {
791
+ n = s.toExponential();
792
+ n = n.slice(0, n.indexOf("e") + 1) + e;
793
+ }
794
+ r = new Ctor(n);
795
+ } else {
796
+ r = new Ctor(s.toString());
797
+ }
798
+ sd = (e = Ctor.precision) + 3;
799
+ for (; ; ) {
800
+ t = r;
801
+ r = t.plus(divide(x, t, sd + 2, 1)).times(0.5);
802
+ if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
803
+ n = n.slice(sd - 3, sd + 1);
804
+ if (n == "9999" || !rep && n == "4999") {
805
+ if (!rep) {
806
+ finalise(t, e + 1, 0);
807
+ if (t.times(t).eq(x)) {
808
+ r = t;
809
+ break;
810
+ }
811
+ }
812
+ sd += 4;
813
+ rep = 1;
814
+ } else {
815
+ if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
816
+ finalise(r, e + 1, 1);
817
+ m = !r.times(r).eq(x);
818
+ }
819
+ break;
820
+ }
821
+ }
822
+ }
823
+ external = true;
824
+ return finalise(r, e, Ctor.rounding, m);
825
+ };
826
+ P.tangent = P.tan = function() {
827
+ var pr, rm, x = this, Ctor = x.constructor;
828
+ if (!x.isFinite())
829
+ return new Ctor(NaN);
830
+ if (x.isZero())
831
+ return new Ctor(x);
832
+ pr = Ctor.precision;
833
+ rm = Ctor.rounding;
834
+ Ctor.precision = pr + 10;
835
+ Ctor.rounding = 1;
836
+ x = x.sin();
837
+ x.s = 1;
838
+ x = divide(x, new Ctor(1).minus(x.times(x)).sqrt(), pr + 10, 0);
839
+ Ctor.precision = pr;
840
+ Ctor.rounding = rm;
841
+ return finalise(quadrant == 2 || quadrant == 4 ? x.neg() : x, pr, rm, true);
842
+ };
843
+ P.times = P.mul = function(y) {
844
+ var carry, e, i, k, r, rL, t, xdL, ydL, x = this, Ctor = x.constructor, xd = x.d, yd = (y = new Ctor(y)).d;
845
+ y.s *= x.s;
846
+ if (!xd || !xd[0] || !yd || !yd[0]) {
847
+ return new Ctor(!y.s || xd && !xd[0] && !yd || yd && !yd[0] && !xd ? NaN : !xd || !yd ? y.s / 0 : y.s * 0);
848
+ }
849
+ e = mathfloor(x.e / LOG_BASE) + mathfloor(y.e / LOG_BASE);
850
+ xdL = xd.length;
851
+ ydL = yd.length;
852
+ if (xdL < ydL) {
853
+ r = xd;
854
+ xd = yd;
855
+ yd = r;
856
+ rL = xdL;
857
+ xdL = ydL;
858
+ ydL = rL;
859
+ }
860
+ r = [];
861
+ rL = xdL + ydL;
862
+ for (i = rL; i--; )
863
+ r.push(0);
864
+ for (i = ydL; --i >= 0; ) {
865
+ carry = 0;
866
+ for (k = xdL + i; k > i; ) {
867
+ t = r[k] + yd[i] * xd[k - i - 1] + carry;
868
+ r[k--] = t % BASE | 0;
869
+ carry = t / BASE | 0;
870
+ }
871
+ r[k] = (r[k] + carry) % BASE | 0;
872
+ }
873
+ for (; !r[--rL]; )
874
+ r.pop();
875
+ if (carry)
876
+ ++e;
877
+ else
878
+ r.shift();
879
+ y.d = r;
880
+ y.e = getBase10Exponent(r, e);
881
+ return external ? finalise(y, Ctor.precision, Ctor.rounding) : y;
882
+ };
883
+ P.toBinary = function(sd, rm) {
884
+ return toStringBinary(this, 2, sd, rm);
885
+ };
886
+ P.toDecimalPlaces = P.toDP = function(dp, rm) {
887
+ var x = this, Ctor = x.constructor;
888
+ x = new Ctor(x);
889
+ if (dp === void 0)
890
+ return x;
891
+ checkInt32(dp, 0, MAX_DIGITS);
892
+ if (rm === void 0)
893
+ rm = Ctor.rounding;
894
+ else
895
+ checkInt32(rm, 0, 8);
896
+ return finalise(x, dp + x.e + 1, rm);
897
+ };
898
+ P.toExponential = function(dp, rm) {
899
+ var str, x = this, Ctor = x.constructor;
900
+ if (dp === void 0) {
901
+ str = finiteToString(x, true);
902
+ } else {
903
+ checkInt32(dp, 0, MAX_DIGITS);
904
+ if (rm === void 0)
905
+ rm = Ctor.rounding;
906
+ else
907
+ checkInt32(rm, 0, 8);
908
+ x = finalise(new Ctor(x), dp + 1, rm);
909
+ str = finiteToString(x, true, dp + 1);
910
+ }
911
+ return x.isNeg() && !x.isZero() ? "-" + str : str;
912
+ };
913
+ P.toFixed = function(dp, rm) {
914
+ var str, y, x = this, Ctor = x.constructor;
915
+ if (dp === void 0) {
916
+ str = finiteToString(x);
917
+ } else {
918
+ checkInt32(dp, 0, MAX_DIGITS);
919
+ if (rm === void 0)
920
+ rm = Ctor.rounding;
921
+ else
922
+ checkInt32(rm, 0, 8);
923
+ y = finalise(new Ctor(x), dp + x.e + 1, rm);
924
+ str = finiteToString(y, false, dp + y.e + 1);
925
+ }
926
+ return x.isNeg() && !x.isZero() ? "-" + str : str;
927
+ };
928
+ P.toFraction = function(maxD) {
929
+ var d, d0, d1, d2, e, k, n, n0, n1, pr, q, r, x = this, xd = x.d, Ctor = x.constructor;
930
+ if (!xd)
931
+ return new Ctor(x);
932
+ n1 = d0 = new Ctor(1);
933
+ d1 = n0 = new Ctor(0);
934
+ d = new Ctor(d1);
935
+ e = d.e = getPrecision(xd) - x.e - 1;
936
+ k = e % LOG_BASE;
937
+ d.d[0] = mathpow(10, k < 0 ? LOG_BASE + k : k);
938
+ if (maxD == null) {
939
+ maxD = e > 0 ? d : n1;
940
+ } else {
941
+ n = new Ctor(maxD);
942
+ if (!n.isInt() || n.lt(n1))
943
+ throw Error(invalidArgument + n);
944
+ maxD = n.gt(d) ? e > 0 ? d : n1 : n;
945
+ }
946
+ external = false;
947
+ n = new Ctor(digitsToString(xd));
948
+ pr = Ctor.precision;
949
+ Ctor.precision = e = xd.length * LOG_BASE * 2;
950
+ for (; ; ) {
951
+ q = divide(n, d, 0, 1, 1);
952
+ d2 = d0.plus(q.times(d1));
953
+ if (d2.cmp(maxD) == 1)
954
+ break;
955
+ d0 = d1;
956
+ d1 = d2;
957
+ d2 = n1;
958
+ n1 = n0.plus(q.times(d2));
959
+ n0 = d2;
960
+ d2 = d;
961
+ d = n.minus(q.times(d2));
962
+ n = d2;
963
+ }
964
+ d2 = divide(maxD.minus(d0), d1, 0, 1, 1);
965
+ n0 = n0.plus(d2.times(n1));
966
+ d0 = d0.plus(d2.times(d1));
967
+ n0.s = n1.s = x.s;
968
+ r = divide(n1, d1, e, 1).minus(x).abs().cmp(divide(n0, d0, e, 1).minus(x).abs()) < 1 ? [n1, d1] : [n0, d0];
969
+ Ctor.precision = pr;
970
+ external = true;
971
+ return r;
972
+ };
973
+ P.toHexadecimal = P.toHex = function(sd, rm) {
974
+ return toStringBinary(this, 16, sd, rm);
975
+ };
976
+ P.toNearest = function(y, rm) {
977
+ var x = this, Ctor = x.constructor;
978
+ x = new Ctor(x);
979
+ if (y == null) {
980
+ if (!x.d)
981
+ return x;
982
+ y = new Ctor(1);
983
+ rm = Ctor.rounding;
984
+ } else {
985
+ y = new Ctor(y);
986
+ if (rm === void 0) {
987
+ rm = Ctor.rounding;
988
+ } else {
989
+ checkInt32(rm, 0, 8);
990
+ }
991
+ if (!x.d)
992
+ return y.s ? x : y;
993
+ if (!y.d) {
994
+ if (y.s)
995
+ y.s = x.s;
996
+ return y;
997
+ }
998
+ }
999
+ if (y.d[0]) {
1000
+ external = false;
1001
+ x = divide(x, y, 0, rm, 1).times(y);
1002
+ external = true;
1003
+ finalise(x);
1004
+ } else {
1005
+ y.s = x.s;
1006
+ x = y;
1007
+ }
1008
+ return x;
1009
+ };
1010
+ P.toNumber = function() {
1011
+ return +this;
1012
+ };
1013
+ P.toOctal = function(sd, rm) {
1014
+ return toStringBinary(this, 8, sd, rm);
1015
+ };
1016
+ P.toPower = P.pow = function(y) {
1017
+ var e, k, pr, r, rm, s, x = this, Ctor = x.constructor, yn = +(y = new Ctor(y));
1018
+ if (!x.d || !y.d || !x.d[0] || !y.d[0])
1019
+ return new Ctor(mathpow(+x, yn));
1020
+ x = new Ctor(x);
1021
+ if (x.eq(1))
1022
+ return x;
1023
+ pr = Ctor.precision;
1024
+ rm = Ctor.rounding;
1025
+ if (y.eq(1))
1026
+ return finalise(x, pr, rm);
1027
+ e = mathfloor(y.e / LOG_BASE);
1028
+ if (e >= y.d.length - 1 && (k = yn < 0 ? -yn : yn) <= MAX_SAFE_INTEGER) {
1029
+ r = intPow(Ctor, x, k, pr);
1030
+ return y.s < 0 ? new Ctor(1).div(r) : finalise(r, pr, rm);
1031
+ }
1032
+ s = x.s;
1033
+ if (s < 0) {
1034
+ if (e < y.d.length - 1)
1035
+ return new Ctor(NaN);
1036
+ if ((y.d[e] & 1) == 0)
1037
+ s = 1;
1038
+ if (x.e == 0 && x.d[0] == 1 && x.d.length == 1) {
1039
+ x.s = s;
1040
+ return x;
1041
+ }
1042
+ }
1043
+ k = mathpow(+x, yn);
1044
+ e = k == 0 || !isFinite(k) ? mathfloor(yn * (Math.log("0." + digitsToString(x.d)) / Math.LN10 + x.e + 1)) : new Ctor(k + "").e;
1045
+ if (e > Ctor.maxE + 1 || e < Ctor.minE - 1)
1046
+ return new Ctor(e > 0 ? s / 0 : 0);
1047
+ external = false;
1048
+ Ctor.rounding = x.s = 1;
1049
+ k = Math.min(12, (e + "").length);
1050
+ r = naturalExponential(y.times(naturalLogarithm(x, pr + k)), pr);
1051
+ if (r.d) {
1052
+ r = finalise(r, pr + 5, 1);
1053
+ if (checkRoundingDigits(r.d, pr, rm)) {
1054
+ e = pr + 10;
1055
+ r = finalise(naturalExponential(y.times(naturalLogarithm(x, e + k)), e), e + 5, 1);
1056
+ if (+digitsToString(r.d).slice(pr + 1, pr + 15) + 1 == 1e14) {
1057
+ r = finalise(r, pr + 1, 0);
1058
+ }
1059
+ }
1060
+ }
1061
+ r.s = s;
1062
+ external = true;
1063
+ Ctor.rounding = rm;
1064
+ return finalise(r, pr, rm);
1065
+ };
1066
+ P.toPrecision = function(sd, rm) {
1067
+ var str, x = this, Ctor = x.constructor;
1068
+ if (sd === void 0) {
1069
+ str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
1070
+ } else {
1071
+ checkInt32(sd, 1, MAX_DIGITS);
1072
+ if (rm === void 0)
1073
+ rm = Ctor.rounding;
1074
+ else
1075
+ checkInt32(rm, 0, 8);
1076
+ x = finalise(new Ctor(x), sd, rm);
1077
+ str = finiteToString(x, sd <= x.e || x.e <= Ctor.toExpNeg, sd);
1078
+ }
1079
+ return x.isNeg() && !x.isZero() ? "-" + str : str;
1080
+ };
1081
+ P.toSignificantDigits = P.toSD = function(sd, rm) {
1082
+ var x = this, Ctor = x.constructor;
1083
+ if (sd === void 0) {
1084
+ sd = Ctor.precision;
1085
+ rm = Ctor.rounding;
1086
+ } else {
1087
+ checkInt32(sd, 1, MAX_DIGITS);
1088
+ if (rm === void 0)
1089
+ rm = Ctor.rounding;
1090
+ else
1091
+ checkInt32(rm, 0, 8);
1092
+ }
1093
+ return finalise(new Ctor(x), sd, rm);
1094
+ };
1095
+ P.toString = function() {
1096
+ var x = this, Ctor = x.constructor, str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
1097
+ return x.isNeg() && !x.isZero() ? "-" + str : str;
1098
+ };
1099
+ P.truncated = P.trunc = function() {
1100
+ return finalise(new this.constructor(this), this.e + 1, 1);
1101
+ };
1102
+ P.valueOf = P.toJSON = function() {
1103
+ var x = this, Ctor = x.constructor, str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
1104
+ return x.isNeg() ? "-" + str : str;
1105
+ };
1106
+ function digitsToString(d) {
1107
+ var i, k, ws, indexOfLastWord = d.length - 1, str = "", w = d[0];
1108
+ if (indexOfLastWord > 0) {
1109
+ str += w;
1110
+ for (i = 1; i < indexOfLastWord; i++) {
1111
+ ws = d[i] + "";
1112
+ k = LOG_BASE - ws.length;
1113
+ if (k)
1114
+ str += getZeroString(k);
1115
+ str += ws;
1116
+ }
1117
+ w = d[i];
1118
+ ws = w + "";
1119
+ k = LOG_BASE - ws.length;
1120
+ if (k)
1121
+ str += getZeroString(k);
1122
+ } else if (w === 0) {
1123
+ return "0";
1124
+ }
1125
+ for (; w % 10 === 0; )
1126
+ w /= 10;
1127
+ return str + w;
1128
+ }
1129
+ function checkInt32(i, min2, max2) {
1130
+ if (i !== ~~i || i < min2 || i > max2) {
1131
+ throw Error(invalidArgument + i);
1132
+ }
1133
+ }
1134
+ function checkRoundingDigits(d, i, rm, repeating) {
1135
+ var di, k, r, rd;
1136
+ for (k = d[0]; k >= 10; k /= 10)
1137
+ --i;
1138
+ if (--i < 0) {
1139
+ i += LOG_BASE;
1140
+ di = 0;
1141
+ } else {
1142
+ di = Math.ceil((i + 1) / LOG_BASE);
1143
+ i %= LOG_BASE;
1144
+ }
1145
+ k = mathpow(10, LOG_BASE - i);
1146
+ rd = d[di] % k | 0;
1147
+ if (repeating == null) {
1148
+ if (i < 3) {
1149
+ if (i == 0)
1150
+ rd = rd / 100 | 0;
1151
+ else if (i == 1)
1152
+ rd = rd / 10 | 0;
1153
+ r = rm < 4 && rd == 99999 || rm > 3 && rd == 49999 || rd == 5e4 || rd == 0;
1154
+ } else {
1155
+ r = (rm < 4 && rd + 1 == k || rm > 3 && rd + 1 == k / 2) && (d[di + 1] / k / 100 | 0) == mathpow(10, i - 2) - 1 || (rd == k / 2 || rd == 0) && (d[di + 1] / k / 100 | 0) == 0;
1156
+ }
1157
+ } else {
1158
+ if (i < 4) {
1159
+ if (i == 0)
1160
+ rd = rd / 1e3 | 0;
1161
+ else if (i == 1)
1162
+ rd = rd / 100 | 0;
1163
+ else if (i == 2)
1164
+ rd = rd / 10 | 0;
1165
+ r = (repeating || rm < 4) && rd == 9999 || !repeating && rm > 3 && rd == 4999;
1166
+ } else {
1167
+ r = ((repeating || rm < 4) && rd + 1 == k || !repeating && rm > 3 && rd + 1 == k / 2) && (d[di + 1] / k / 1e3 | 0) == mathpow(10, i - 3) - 1;
1168
+ }
1169
+ }
1170
+ return r;
1171
+ }
1172
+ function convertBase(str, baseIn, baseOut) {
1173
+ var j, arr = [0], arrL, i = 0, strL = str.length;
1174
+ for (; i < strL; ) {
1175
+ for (arrL = arr.length; arrL--; )
1176
+ arr[arrL] *= baseIn;
1177
+ arr[0] += NUMERALS.indexOf(str.charAt(i++));
1178
+ for (j = 0; j < arr.length; j++) {
1179
+ if (arr[j] > baseOut - 1) {
1180
+ if (arr[j + 1] === void 0)
1181
+ arr[j + 1] = 0;
1182
+ arr[j + 1] += arr[j] / baseOut | 0;
1183
+ arr[j] %= baseOut;
1184
+ }
1185
+ }
1186
+ }
1187
+ return arr.reverse();
1188
+ }
1189
+ function cosine(Ctor, x) {
1190
+ var k, len, y;
1191
+ if (x.isZero())
1192
+ return x;
1193
+ len = x.d.length;
1194
+ if (len < 32) {
1195
+ k = Math.ceil(len / 3);
1196
+ y = (1 / tinyPow(4, k)).toString();
1197
+ } else {
1198
+ k = 16;
1199
+ y = "2.3283064365386962890625e-10";
1200
+ }
1201
+ Ctor.precision += k;
1202
+ x = taylorSeries(Ctor, 1, x.times(y), new Ctor(1));
1203
+ for (var i = k; i--; ) {
1204
+ var cos2x = x.times(x);
1205
+ x = cos2x.times(cos2x).minus(cos2x).times(8).plus(1);
1206
+ }
1207
+ Ctor.precision -= k;
1208
+ return x;
1209
+ }
1210
+ var divide = /* @__PURE__ */ function() {
1211
+ function multiplyInteger(x, k, base) {
1212
+ var temp, carry = 0, i = x.length;
1213
+ for (x = x.slice(); i--; ) {
1214
+ temp = x[i] * k + carry;
1215
+ x[i] = temp % base | 0;
1216
+ carry = temp / base | 0;
1217
+ }
1218
+ if (carry)
1219
+ x.unshift(carry);
1220
+ return x;
1221
+ }
1222
+ function compare(a, b, aL, bL) {
1223
+ var i, r;
1224
+ if (aL != bL) {
1225
+ r = aL > bL ? 1 : -1;
1226
+ } else {
1227
+ for (i = r = 0; i < aL; i++) {
1228
+ if (a[i] != b[i]) {
1229
+ r = a[i] > b[i] ? 1 : -1;
1230
+ break;
1231
+ }
1232
+ }
1233
+ }
1234
+ return r;
1235
+ }
1236
+ function subtract(a, b, aL, base) {
1237
+ var i = 0;
1238
+ for (; aL--; ) {
1239
+ a[aL] -= i;
1240
+ i = a[aL] < b[aL] ? 1 : 0;
1241
+ a[aL] = i * base + a[aL] - b[aL];
1242
+ }
1243
+ for (; !a[0] && a.length > 1; )
1244
+ a.shift();
1245
+ }
1246
+ return function(x, y, pr, rm, dp, base) {
1247
+ var cmp, e, i, k, logBase, more, prod, prodL, q, qd, rem, remL, rem0, sd, t, xi, xL, yd0, yL, yz, Ctor = x.constructor, sign2 = x.s == y.s ? 1 : -1, xd = x.d, yd = y.d;
1248
+ if (!xd || !xd[0] || !yd || !yd[0]) {
1249
+ return new Ctor(
1250
+ // Return NaN if either NaN, or both Infinity or 0.
1251
+ !x.s || !y.s || (xd ? yd && xd[0] == yd[0] : !yd) ? NaN : (
1252
+ // Return ±0 if x is 0 or y is ±Infinity, or return ±Infinity as y is 0.
1253
+ xd && xd[0] == 0 || !yd ? sign2 * 0 : sign2 / 0
1254
+ )
1255
+ );
1256
+ }
1257
+ if (base) {
1258
+ logBase = 1;
1259
+ e = x.e - y.e;
1260
+ } else {
1261
+ base = BASE;
1262
+ logBase = LOG_BASE;
1263
+ e = mathfloor(x.e / logBase) - mathfloor(y.e / logBase);
1264
+ }
1265
+ yL = yd.length;
1266
+ xL = xd.length;
1267
+ q = new Ctor(sign2);
1268
+ qd = q.d = [];
1269
+ for (i = 0; yd[i] == (xd[i] || 0); i++)
1270
+ ;
1271
+ if (yd[i] > (xd[i] || 0))
1272
+ e--;
1273
+ if (pr == null) {
1274
+ sd = pr = Ctor.precision;
1275
+ rm = Ctor.rounding;
1276
+ } else if (dp) {
1277
+ sd = pr + (x.e - y.e) + 1;
1278
+ } else {
1279
+ sd = pr;
1280
+ }
1281
+ if (sd < 0) {
1282
+ qd.push(1);
1283
+ more = true;
1284
+ } else {
1285
+ sd = sd / logBase + 2 | 0;
1286
+ i = 0;
1287
+ if (yL == 1) {
1288
+ k = 0;
1289
+ yd = yd[0];
1290
+ sd++;
1291
+ for (; (i < xL || k) && sd--; i++) {
1292
+ t = k * base + (xd[i] || 0);
1293
+ qd[i] = t / yd | 0;
1294
+ k = t % yd | 0;
1295
+ }
1296
+ more = k || i < xL;
1297
+ } else {
1298
+ k = base / (yd[0] + 1) | 0;
1299
+ if (k > 1) {
1300
+ yd = multiplyInteger(yd, k, base);
1301
+ xd = multiplyInteger(xd, k, base);
1302
+ yL = yd.length;
1303
+ xL = xd.length;
1304
+ }
1305
+ xi = yL;
1306
+ rem = xd.slice(0, yL);
1307
+ remL = rem.length;
1308
+ for (; remL < yL; )
1309
+ rem[remL++] = 0;
1310
+ yz = yd.slice();
1311
+ yz.unshift(0);
1312
+ yd0 = yd[0];
1313
+ if (yd[1] >= base / 2)
1314
+ ++yd0;
1315
+ do {
1316
+ k = 0;
1317
+ cmp = compare(yd, rem, yL, remL);
1318
+ if (cmp < 0) {
1319
+ rem0 = rem[0];
1320
+ if (yL != remL)
1321
+ rem0 = rem0 * base + (rem[1] || 0);
1322
+ k = rem0 / yd0 | 0;
1323
+ if (k > 1) {
1324
+ if (k >= base)
1325
+ k = base - 1;
1326
+ prod = multiplyInteger(yd, k, base);
1327
+ prodL = prod.length;
1328
+ remL = rem.length;
1329
+ cmp = compare(prod, rem, prodL, remL);
1330
+ if (cmp == 1) {
1331
+ k--;
1332
+ subtract(prod, yL < prodL ? yz : yd, prodL, base);
1333
+ }
1334
+ } else {
1335
+ if (k == 0)
1336
+ cmp = k = 1;
1337
+ prod = yd.slice();
1338
+ }
1339
+ prodL = prod.length;
1340
+ if (prodL < remL)
1341
+ prod.unshift(0);
1342
+ subtract(rem, prod, remL, base);
1343
+ if (cmp == -1) {
1344
+ remL = rem.length;
1345
+ cmp = compare(yd, rem, yL, remL);
1346
+ if (cmp < 1) {
1347
+ k++;
1348
+ subtract(rem, yL < remL ? yz : yd, remL, base);
1349
+ }
1350
+ }
1351
+ remL = rem.length;
1352
+ } else if (cmp === 0) {
1353
+ k++;
1354
+ rem = [0];
1355
+ }
1356
+ qd[i++] = k;
1357
+ if (cmp && rem[0]) {
1358
+ rem[remL++] = xd[xi] || 0;
1359
+ } else {
1360
+ rem = [xd[xi]];
1361
+ remL = 1;
1362
+ }
1363
+ } while ((xi++ < xL || rem[0] !== void 0) && sd--);
1364
+ more = rem[0] !== void 0;
1365
+ }
1366
+ if (!qd[0])
1367
+ qd.shift();
1368
+ }
1369
+ if (logBase == 1) {
1370
+ q.e = e;
1371
+ inexact = more;
1372
+ } else {
1373
+ for (i = 1, k = qd[0]; k >= 10; k /= 10)
1374
+ i++;
1375
+ q.e = i + e * logBase - 1;
1376
+ finalise(q, dp ? pr + q.e + 1 : pr, rm, more);
1377
+ }
1378
+ return q;
1379
+ };
1380
+ }();
1381
+ function finalise(x, sd, rm, isTruncated) {
1382
+ var digits, i, j, k, rd, roundUp, w, xd, xdi, Ctor = x.constructor;
1383
+ out:
1384
+ if (sd != null) {
1385
+ xd = x.d;
1386
+ if (!xd)
1387
+ return x;
1388
+ for (digits = 1, k = xd[0]; k >= 10; k /= 10)
1389
+ digits++;
1390
+ i = sd - digits;
1391
+ if (i < 0) {
1392
+ i += LOG_BASE;
1393
+ j = sd;
1394
+ w = xd[xdi = 0];
1395
+ rd = w / mathpow(10, digits - j - 1) % 10 | 0;
1396
+ } else {
1397
+ xdi = Math.ceil((i + 1) / LOG_BASE);
1398
+ k = xd.length;
1399
+ if (xdi >= k) {
1400
+ if (isTruncated) {
1401
+ for (; k++ <= xdi; )
1402
+ xd.push(0);
1403
+ w = rd = 0;
1404
+ digits = 1;
1405
+ i %= LOG_BASE;
1406
+ j = i - LOG_BASE + 1;
1407
+ } else {
1408
+ break out;
1409
+ }
1410
+ } else {
1411
+ w = k = xd[xdi];
1412
+ for (digits = 1; k >= 10; k /= 10)
1413
+ digits++;
1414
+ i %= LOG_BASE;
1415
+ j = i - LOG_BASE + digits;
1416
+ rd = j < 0 ? 0 : w / mathpow(10, digits - j - 1) % 10 | 0;
1417
+ }
1418
+ }
1419
+ isTruncated = isTruncated || sd < 0 || xd[xdi + 1] !== void 0 || (j < 0 ? w : w % mathpow(10, digits - j - 1));
1420
+ roundUp = rm < 4 ? (rd || isTruncated) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : rd > 5 || rd == 5 && (rm == 4 || isTruncated || rm == 6 && // Check whether the digit to the left of the rounding digit is odd.
1421
+ (i > 0 ? j > 0 ? w / mathpow(10, digits - j) : 0 : xd[xdi - 1]) % 10 & 1 || rm == (x.s < 0 ? 8 : 7));
1422
+ if (sd < 1 || !xd[0]) {
1423
+ xd.length = 0;
1424
+ if (roundUp) {
1425
+ sd -= x.e + 1;
1426
+ xd[0] = mathpow(10, (LOG_BASE - sd % LOG_BASE) % LOG_BASE);
1427
+ x.e = -sd || 0;
1428
+ } else {
1429
+ xd[0] = x.e = 0;
1430
+ }
1431
+ return x;
1432
+ }
1433
+ if (i == 0) {
1434
+ xd.length = xdi;
1435
+ k = 1;
1436
+ xdi--;
1437
+ } else {
1438
+ xd.length = xdi + 1;
1439
+ k = mathpow(10, LOG_BASE - i);
1440
+ xd[xdi] = j > 0 ? (w / mathpow(10, digits - j) % mathpow(10, j) | 0) * k : 0;
1441
+ }
1442
+ if (roundUp) {
1443
+ for (; ; ) {
1444
+ if (xdi == 0) {
1445
+ for (i = 1, j = xd[0]; j >= 10; j /= 10)
1446
+ i++;
1447
+ j = xd[0] += k;
1448
+ for (k = 1; j >= 10; j /= 10)
1449
+ k++;
1450
+ if (i != k) {
1451
+ x.e++;
1452
+ if (xd[0] == BASE)
1453
+ xd[0] = 1;
1454
+ }
1455
+ break;
1456
+ } else {
1457
+ xd[xdi] += k;
1458
+ if (xd[xdi] != BASE)
1459
+ break;
1460
+ xd[xdi--] = 0;
1461
+ k = 1;
1462
+ }
1463
+ }
1464
+ }
1465
+ for (i = xd.length; xd[--i] === 0; )
1466
+ xd.pop();
1467
+ }
1468
+ if (external) {
1469
+ if (x.e > Ctor.maxE) {
1470
+ x.d = null;
1471
+ x.e = NaN;
1472
+ } else if (x.e < Ctor.minE) {
1473
+ x.e = 0;
1474
+ x.d = [0];
1475
+ }
1476
+ }
1477
+ return x;
1478
+ }
1479
+ function finiteToString(x, isExp, sd) {
1480
+ if (!x.isFinite())
1481
+ return nonFiniteToString(x);
1482
+ var k, e = x.e, str = digitsToString(x.d), len = str.length;
1483
+ if (isExp) {
1484
+ if (sd && (k = sd - len) > 0) {
1485
+ str = str.charAt(0) + "." + str.slice(1) + getZeroString(k);
1486
+ } else if (len > 1) {
1487
+ str = str.charAt(0) + "." + str.slice(1);
1488
+ }
1489
+ str = str + (x.e < 0 ? "e" : "e+") + x.e;
1490
+ } else if (e < 0) {
1491
+ str = "0." + getZeroString(-e - 1) + str;
1492
+ if (sd && (k = sd - len) > 0)
1493
+ str += getZeroString(k);
1494
+ } else if (e >= len) {
1495
+ str += getZeroString(e + 1 - len);
1496
+ if (sd && (k = sd - e - 1) > 0)
1497
+ str = str + "." + getZeroString(k);
1498
+ } else {
1499
+ if ((k = e + 1) < len)
1500
+ str = str.slice(0, k) + "." + str.slice(k);
1501
+ if (sd && (k = sd - len) > 0) {
1502
+ if (e + 1 === len)
1503
+ str += ".";
1504
+ str += getZeroString(k);
1505
+ }
1506
+ }
1507
+ return str;
1508
+ }
1509
+ function getBase10Exponent(digits, e) {
1510
+ var w = digits[0];
1511
+ for (e *= LOG_BASE; w >= 10; w /= 10)
1512
+ e++;
1513
+ return e;
1514
+ }
1515
+ function getLn10(Ctor, sd, pr) {
1516
+ if (sd > LN10_PRECISION) {
1517
+ external = true;
1518
+ if (pr)
1519
+ Ctor.precision = pr;
1520
+ throw Error(precisionLimitExceeded);
1521
+ }
1522
+ return finalise(new Ctor(LN10), sd, 1, true);
1523
+ }
1524
+ function getPi(Ctor, sd, rm) {
1525
+ if (sd > PI_PRECISION)
1526
+ throw Error(precisionLimitExceeded);
1527
+ return finalise(new Ctor(PI), sd, rm, true);
1528
+ }
1529
+ function getPrecision(digits) {
1530
+ var w = digits.length - 1, len = w * LOG_BASE + 1;
1531
+ w = digits[w];
1532
+ if (w) {
1533
+ for (; w % 10 == 0; w /= 10)
1534
+ len--;
1535
+ for (w = digits[0]; w >= 10; w /= 10)
1536
+ len++;
1537
+ }
1538
+ return len;
1539
+ }
1540
+ function getZeroString(k) {
1541
+ var zs = "";
1542
+ for (; k--; )
1543
+ zs += "0";
1544
+ return zs;
1545
+ }
1546
+ function intPow(Ctor, x, n, pr) {
1547
+ var isTruncated, r = new Ctor(1), k = Math.ceil(pr / LOG_BASE + 4);
1548
+ external = false;
1549
+ for (; ; ) {
1550
+ if (n % 2) {
1551
+ r = r.times(x);
1552
+ if (truncate(r.d, k))
1553
+ isTruncated = true;
1554
+ }
1555
+ n = mathfloor(n / 2);
1556
+ if (n === 0) {
1557
+ n = r.d.length - 1;
1558
+ if (isTruncated && r.d[n] === 0)
1559
+ ++r.d[n];
1560
+ break;
1561
+ }
1562
+ x = x.times(x);
1563
+ truncate(x.d, k);
1564
+ }
1565
+ external = true;
1566
+ return r;
1567
+ }
1568
+ function isOdd(n) {
1569
+ return n.d[n.d.length - 1] & 1;
1570
+ }
1571
+ function maxOrMin(Ctor, args, ltgt) {
1572
+ var y, x = new Ctor(args[0]), i = 0;
1573
+ for (; ++i < args.length; ) {
1574
+ y = new Ctor(args[i]);
1575
+ if (!y.s) {
1576
+ x = y;
1577
+ break;
1578
+ } else if (x[ltgt](y)) {
1579
+ x = y;
1580
+ }
1581
+ }
1582
+ return x;
1583
+ }
1584
+ function naturalExponential(x, sd) {
1585
+ var denominator, guard, j, pow2, sum2, t, wpr, rep = 0, i = 0, k = 0, Ctor = x.constructor, rm = Ctor.rounding, pr = Ctor.precision;
1586
+ if (!x.d || !x.d[0] || x.e > 17) {
1587
+ return new Ctor(x.d ? !x.d[0] ? 1 : x.s < 0 ? 0 : 1 / 0 : x.s ? x.s < 0 ? 0 : x : 0 / 0);
1588
+ }
1589
+ if (sd == null) {
1590
+ external = false;
1591
+ wpr = pr;
1592
+ } else {
1593
+ wpr = sd;
1594
+ }
1595
+ t = new Ctor(0.03125);
1596
+ while (x.e > -2) {
1597
+ x = x.times(t);
1598
+ k += 5;
1599
+ }
1600
+ guard = Math.log(mathpow(2, k)) / Math.LN10 * 2 + 5 | 0;
1601
+ wpr += guard;
1602
+ denominator = pow2 = sum2 = new Ctor(1);
1603
+ Ctor.precision = wpr;
1604
+ for (; ; ) {
1605
+ pow2 = finalise(pow2.times(x), wpr, 1);
1606
+ denominator = denominator.times(++i);
1607
+ t = sum2.plus(divide(pow2, denominator, wpr, 1));
1608
+ if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum2.d).slice(0, wpr)) {
1609
+ j = k;
1610
+ while (j--)
1611
+ sum2 = finalise(sum2.times(sum2), wpr, 1);
1612
+ if (sd == null) {
1613
+ if (rep < 3 && checkRoundingDigits(sum2.d, wpr - guard, rm, rep)) {
1614
+ Ctor.precision = wpr += 10;
1615
+ denominator = pow2 = t = new Ctor(1);
1616
+ i = 0;
1617
+ rep++;
1618
+ } else {
1619
+ return finalise(sum2, Ctor.precision = pr, rm, external = true);
1620
+ }
1621
+ } else {
1622
+ Ctor.precision = pr;
1623
+ return sum2;
1624
+ }
1625
+ }
1626
+ sum2 = t;
1627
+ }
1628
+ }
1629
+ function naturalLogarithm(y, sd) {
1630
+ var c, c0, denominator, e, numerator, rep, sum2, t, wpr, x1, x2, n = 1, guard = 10, x = y, xd = x.d, Ctor = x.constructor, rm = Ctor.rounding, pr = Ctor.precision;
1631
+ if (x.s < 0 || !xd || !xd[0] || !x.e && xd[0] == 1 && xd.length == 1) {
1632
+ return new Ctor(xd && !xd[0] ? -1 / 0 : x.s != 1 ? NaN : xd ? 0 : x);
1633
+ }
1634
+ if (sd == null) {
1635
+ external = false;
1636
+ wpr = pr;
1637
+ } else {
1638
+ wpr = sd;
1639
+ }
1640
+ Ctor.precision = wpr += guard;
1641
+ c = digitsToString(xd);
1642
+ c0 = c.charAt(0);
1643
+ if (Math.abs(e = x.e) < 15e14) {
1644
+ while (c0 < 7 && c0 != 1 || c0 == 1 && c.charAt(1) > 3) {
1645
+ x = x.times(y);
1646
+ c = digitsToString(x.d);
1647
+ c0 = c.charAt(0);
1648
+ n++;
1649
+ }
1650
+ e = x.e;
1651
+ if (c0 > 1) {
1652
+ x = new Ctor("0." + c);
1653
+ e++;
1654
+ } else {
1655
+ x = new Ctor(c0 + "." + c.slice(1));
1656
+ }
1657
+ } else {
1658
+ t = getLn10(Ctor, wpr + 2, pr).times(e + "");
1659
+ x = naturalLogarithm(new Ctor(c0 + "." + c.slice(1)), wpr - guard).plus(t);
1660
+ Ctor.precision = pr;
1661
+ return sd == null ? finalise(x, pr, rm, external = true) : x;
1662
+ }
1663
+ x1 = x;
1664
+ sum2 = numerator = x = divide(x.minus(1), x.plus(1), wpr, 1);
1665
+ x2 = finalise(x.times(x), wpr, 1);
1666
+ denominator = 3;
1667
+ for (; ; ) {
1668
+ numerator = finalise(numerator.times(x2), wpr, 1);
1669
+ t = sum2.plus(divide(numerator, new Ctor(denominator), wpr, 1));
1670
+ if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum2.d).slice(0, wpr)) {
1671
+ sum2 = sum2.times(2);
1672
+ if (e !== 0)
1673
+ sum2 = sum2.plus(getLn10(Ctor, wpr + 2, pr).times(e + ""));
1674
+ sum2 = divide(sum2, new Ctor(n), wpr, 1);
1675
+ if (sd == null) {
1676
+ if (checkRoundingDigits(sum2.d, wpr - guard, rm, rep)) {
1677
+ Ctor.precision = wpr += guard;
1678
+ t = numerator = x = divide(x1.minus(1), x1.plus(1), wpr, 1);
1679
+ x2 = finalise(x.times(x), wpr, 1);
1680
+ denominator = rep = 1;
1681
+ } else {
1682
+ return finalise(sum2, Ctor.precision = pr, rm, external = true);
1683
+ }
1684
+ } else {
1685
+ Ctor.precision = pr;
1686
+ return sum2;
1687
+ }
1688
+ }
1689
+ sum2 = t;
1690
+ denominator += 2;
1691
+ }
1692
+ }
1693
+ function nonFiniteToString(x) {
1694
+ return String(x.s * x.s / 0);
1695
+ }
1696
+ function parseDecimal(x, str) {
1697
+ var e, i, len;
1698
+ if ((e = str.indexOf(".")) > -1)
1699
+ str = str.replace(".", "");
1700
+ if ((i = str.search(/e/i)) > 0) {
1701
+ if (e < 0)
1702
+ e = i;
1703
+ e += +str.slice(i + 1);
1704
+ str = str.substring(0, i);
1705
+ } else if (e < 0) {
1706
+ e = str.length;
1707
+ }
1708
+ for (i = 0; str.charCodeAt(i) === 48; i++)
1709
+ ;
1710
+ for (len = str.length; str.charCodeAt(len - 1) === 48; --len)
1711
+ ;
1712
+ str = str.slice(i, len);
1713
+ if (str) {
1714
+ len -= i;
1715
+ x.e = e = e - i - 1;
1716
+ x.d = [];
1717
+ i = (e + 1) % LOG_BASE;
1718
+ if (e < 0)
1719
+ i += LOG_BASE;
1720
+ if (i < len) {
1721
+ if (i)
1722
+ x.d.push(+str.slice(0, i));
1723
+ for (len -= LOG_BASE; i < len; )
1724
+ x.d.push(+str.slice(i, i += LOG_BASE));
1725
+ str = str.slice(i);
1726
+ i = LOG_BASE - str.length;
1727
+ } else {
1728
+ i -= len;
1729
+ }
1730
+ for (; i--; )
1731
+ str += "0";
1732
+ x.d.push(+str);
1733
+ if (external) {
1734
+ if (x.e > x.constructor.maxE) {
1735
+ x.d = null;
1736
+ x.e = NaN;
1737
+ } else if (x.e < x.constructor.minE) {
1738
+ x.e = 0;
1739
+ x.d = [0];
1740
+ }
1741
+ }
1742
+ } else {
1743
+ x.e = 0;
1744
+ x.d = [0];
1745
+ }
1746
+ return x;
1747
+ }
1748
+ function parseOther(x, str) {
1749
+ var base, Ctor, divisor, i, isFloat, len, p, xd, xe;
1750
+ if (str.indexOf("_") > -1) {
1751
+ str = str.replace(/(\d)_(?=\d)/g, "$1");
1752
+ if (isDecimal.test(str))
1753
+ return parseDecimal(x, str);
1754
+ } else if (str === "Infinity" || str === "NaN") {
1755
+ if (!+str)
1756
+ x.s = NaN;
1757
+ x.e = NaN;
1758
+ x.d = null;
1759
+ return x;
1760
+ }
1761
+ if (isHex.test(str)) {
1762
+ base = 16;
1763
+ str = str.toLowerCase();
1764
+ } else if (isBinary.test(str)) {
1765
+ base = 2;
1766
+ } else if (isOctal.test(str)) {
1767
+ base = 8;
1768
+ } else {
1769
+ throw Error(invalidArgument + str);
1770
+ }
1771
+ i = str.search(/p/i);
1772
+ if (i > 0) {
1773
+ p = +str.slice(i + 1);
1774
+ str = str.substring(2, i);
1775
+ } else {
1776
+ str = str.slice(2);
1777
+ }
1778
+ i = str.indexOf(".");
1779
+ isFloat = i >= 0;
1780
+ Ctor = x.constructor;
1781
+ if (isFloat) {
1782
+ str = str.replace(".", "");
1783
+ len = str.length;
1784
+ i = len - i;
1785
+ divisor = intPow(Ctor, new Ctor(base), i, i * 2);
1786
+ }
1787
+ xd = convertBase(str, base, BASE);
1788
+ xe = xd.length - 1;
1789
+ for (i = xe; xd[i] === 0; --i)
1790
+ xd.pop();
1791
+ if (i < 0)
1792
+ return new Ctor(x.s * 0);
1793
+ x.e = getBase10Exponent(xd, xe);
1794
+ x.d = xd;
1795
+ external = false;
1796
+ if (isFloat)
1797
+ x = divide(x, divisor, len * 4);
1798
+ if (p)
1799
+ x = x.times(Math.abs(p) < 54 ? mathpow(2, p) : Decimal.pow(2, p));
1800
+ external = true;
1801
+ return x;
1802
+ }
1803
+ function sine(Ctor, x) {
1804
+ var k, len = x.d.length;
1805
+ if (len < 3) {
1806
+ return x.isZero() ? x : taylorSeries(Ctor, 2, x, x);
1807
+ }
1808
+ k = 1.4 * Math.sqrt(len);
1809
+ k = k > 16 ? 16 : k | 0;
1810
+ x = x.times(1 / tinyPow(5, k));
1811
+ x = taylorSeries(Ctor, 2, x, x);
1812
+ var sin2_x, d5 = new Ctor(5), d16 = new Ctor(16), d20 = new Ctor(20);
1813
+ for (; k--; ) {
1814
+ sin2_x = x.times(x);
1815
+ x = x.times(d5.plus(sin2_x.times(d16.times(sin2_x).minus(d20))));
1816
+ }
1817
+ return x;
1818
+ }
1819
+ function taylorSeries(Ctor, n, x, y, isHyperbolic) {
1820
+ var j, t, u, x2, i = 1, pr = Ctor.precision, k = Math.ceil(pr / LOG_BASE);
1821
+ external = false;
1822
+ x2 = x.times(x);
1823
+ u = new Ctor(y);
1824
+ for (; ; ) {
1825
+ t = divide(u.times(x2), new Ctor(n++ * n++), pr, 1);
1826
+ u = isHyperbolic ? y.plus(t) : y.minus(t);
1827
+ y = divide(t.times(x2), new Ctor(n++ * n++), pr, 1);
1828
+ t = u.plus(y);
1829
+ if (t.d[k] !== void 0) {
1830
+ for (j = k; t.d[j] === u.d[j] && j--; )
1831
+ ;
1832
+ if (j == -1)
1833
+ break;
1834
+ }
1835
+ j = u;
1836
+ u = y;
1837
+ y = t;
1838
+ t = j;
1839
+ i++;
1840
+ }
1841
+ external = true;
1842
+ t.d.length = k + 1;
1843
+ return t;
1844
+ }
1845
+ function tinyPow(b, e) {
1846
+ var n = b;
1847
+ while (--e)
1848
+ n *= b;
1849
+ return n;
1850
+ }
1851
+ function toLessThanHalfPi(Ctor, x) {
1852
+ var t, isNeg = x.s < 0, pi = getPi(Ctor, Ctor.precision, 1), halfPi = pi.times(0.5);
1853
+ x = x.abs();
1854
+ if (x.lte(halfPi)) {
1855
+ quadrant = isNeg ? 4 : 1;
1856
+ return x;
1857
+ }
1858
+ t = x.divToInt(pi);
1859
+ if (t.isZero()) {
1860
+ quadrant = isNeg ? 3 : 2;
1861
+ } else {
1862
+ x = x.minus(t.times(pi));
1863
+ if (x.lte(halfPi)) {
1864
+ quadrant = isOdd(t) ? isNeg ? 2 : 3 : isNeg ? 4 : 1;
1865
+ return x;
1866
+ }
1867
+ quadrant = isOdd(t) ? isNeg ? 1 : 4 : isNeg ? 3 : 2;
1868
+ }
1869
+ return x.minus(pi).abs();
1870
+ }
1871
+ function toStringBinary(x, baseOut, sd, rm) {
1872
+ var base, e, i, k, len, roundUp, str, xd, y, Ctor = x.constructor, isExp = sd !== void 0;
1873
+ if (isExp) {
1874
+ checkInt32(sd, 1, MAX_DIGITS);
1875
+ if (rm === void 0)
1876
+ rm = Ctor.rounding;
1877
+ else
1878
+ checkInt32(rm, 0, 8);
1879
+ } else {
1880
+ sd = Ctor.precision;
1881
+ rm = Ctor.rounding;
1882
+ }
1883
+ if (!x.isFinite()) {
1884
+ str = nonFiniteToString(x);
1885
+ } else {
1886
+ str = finiteToString(x);
1887
+ i = str.indexOf(".");
1888
+ if (isExp) {
1889
+ base = 2;
1890
+ if (baseOut == 16) {
1891
+ sd = sd * 4 - 3;
1892
+ } else if (baseOut == 8) {
1893
+ sd = sd * 3 - 2;
1894
+ }
1895
+ } else {
1896
+ base = baseOut;
1897
+ }
1898
+ if (i >= 0) {
1899
+ str = str.replace(".", "");
1900
+ y = new Ctor(1);
1901
+ y.e = str.length - i;
1902
+ y.d = convertBase(finiteToString(y), 10, base);
1903
+ y.e = y.d.length;
1904
+ }
1905
+ xd = convertBase(str, 10, base);
1906
+ e = len = xd.length;
1907
+ for (; xd[--len] == 0; )
1908
+ xd.pop();
1909
+ if (!xd[0]) {
1910
+ str = isExp ? "0p+0" : "0";
1911
+ } else {
1912
+ if (i < 0) {
1913
+ e--;
1914
+ } else {
1915
+ x = new Ctor(x);
1916
+ x.d = xd;
1917
+ x.e = e;
1918
+ x = divide(x, y, sd, rm, 0, base);
1919
+ xd = x.d;
1920
+ e = x.e;
1921
+ roundUp = inexact;
1922
+ }
1923
+ i = xd[sd];
1924
+ k = base / 2;
1925
+ roundUp = roundUp || xd[sd + 1] !== void 0;
1926
+ roundUp = rm < 4 ? (i !== void 0 || roundUp) && (rm === 0 || rm === (x.s < 0 ? 3 : 2)) : i > k || i === k && (rm === 4 || roundUp || rm === 6 && xd[sd - 1] & 1 || rm === (x.s < 0 ? 8 : 7));
1927
+ xd.length = sd;
1928
+ if (roundUp) {
1929
+ for (; ++xd[--sd] > base - 1; ) {
1930
+ xd[sd] = 0;
1931
+ if (!sd) {
1932
+ ++e;
1933
+ xd.unshift(1);
1934
+ }
1935
+ }
1936
+ }
1937
+ for (len = xd.length; !xd[len - 1]; --len)
1938
+ ;
1939
+ for (i = 0, str = ""; i < len; i++)
1940
+ str += NUMERALS.charAt(xd[i]);
1941
+ if (isExp) {
1942
+ if (len > 1) {
1943
+ if (baseOut == 16 || baseOut == 8) {
1944
+ i = baseOut == 16 ? 4 : 3;
1945
+ for (--len; len % i; len++)
1946
+ str += "0";
1947
+ xd = convertBase(str, base, baseOut);
1948
+ for (len = xd.length; !xd[len - 1]; --len)
1949
+ ;
1950
+ for (i = 1, str = "1."; i < len; i++)
1951
+ str += NUMERALS.charAt(xd[i]);
1952
+ } else {
1953
+ str = str.charAt(0) + "." + str.slice(1);
1954
+ }
1955
+ }
1956
+ str = str + (e < 0 ? "p" : "p+") + e;
1957
+ } else if (e < 0) {
1958
+ for (; ++e; )
1959
+ str = "0" + str;
1960
+ str = "0." + str;
1961
+ } else {
1962
+ if (++e > len)
1963
+ for (e -= len; e--; )
1964
+ str += "0";
1965
+ else if (e < len)
1966
+ str = str.slice(0, e) + "." + str.slice(e);
1967
+ }
1968
+ }
1969
+ str = (baseOut == 16 ? "0x" : baseOut == 2 ? "0b" : baseOut == 8 ? "0o" : "") + str;
1970
+ }
1971
+ return x.s < 0 ? "-" + str : str;
1972
+ }
1973
+ function truncate(arr, len) {
1974
+ if (arr.length > len) {
1975
+ arr.length = len;
1976
+ return true;
1977
+ }
1978
+ }
1979
+ function abs(x) {
1980
+ return new this(x).abs();
1981
+ }
1982
+ function acos(x) {
1983
+ return new this(x).acos();
1984
+ }
1985
+ function acosh(x) {
1986
+ return new this(x).acosh();
1987
+ }
1988
+ function add(x, y) {
1989
+ return new this(x).plus(y);
1990
+ }
1991
+ function asin(x) {
1992
+ return new this(x).asin();
1993
+ }
1994
+ function asinh(x) {
1995
+ return new this(x).asinh();
1996
+ }
1997
+ function atan(x) {
1998
+ return new this(x).atan();
1999
+ }
2000
+ function atanh(x) {
2001
+ return new this(x).atanh();
2002
+ }
2003
+ function atan2(y, x) {
2004
+ y = new this(y);
2005
+ x = new this(x);
2006
+ var r, pr = this.precision, rm = this.rounding, wpr = pr + 4;
2007
+ if (!y.s || !x.s) {
2008
+ r = new this(NaN);
2009
+ } else if (!y.d && !x.d) {
2010
+ r = getPi(this, wpr, 1).times(x.s > 0 ? 0.25 : 0.75);
2011
+ r.s = y.s;
2012
+ } else if (!x.d || y.isZero()) {
2013
+ r = x.s < 0 ? getPi(this, pr, rm) : new this(0);
2014
+ r.s = y.s;
2015
+ } else if (!y.d || x.isZero()) {
2016
+ r = getPi(this, wpr, 1).times(0.5);
2017
+ r.s = y.s;
2018
+ } else if (x.s < 0) {
2019
+ this.precision = wpr;
2020
+ this.rounding = 1;
2021
+ r = this.atan(divide(y, x, wpr, 1));
2022
+ x = getPi(this, wpr, 1);
2023
+ this.precision = pr;
2024
+ this.rounding = rm;
2025
+ r = y.s < 0 ? r.minus(x) : r.plus(x);
2026
+ } else {
2027
+ r = this.atan(divide(y, x, wpr, 1));
2028
+ }
2029
+ return r;
2030
+ }
2031
+ function cbrt(x) {
2032
+ return new this(x).cbrt();
2033
+ }
2034
+ function ceil(x) {
2035
+ return finalise(x = new this(x), x.e + 1, 2);
2036
+ }
2037
+ function clamp(x, min2, max2) {
2038
+ return new this(x).clamp(min2, max2);
2039
+ }
2040
+ function config(obj) {
2041
+ if (!obj || typeof obj !== "object")
2042
+ throw Error(decimalError + "Object expected");
2043
+ var i, p, v, useDefaults = obj.defaults === true, ps = [
2044
+ "precision",
2045
+ 1,
2046
+ MAX_DIGITS,
2047
+ "rounding",
2048
+ 0,
2049
+ 8,
2050
+ "toExpNeg",
2051
+ -EXP_LIMIT,
2052
+ 0,
2053
+ "toExpPos",
2054
+ 0,
2055
+ EXP_LIMIT,
2056
+ "maxE",
2057
+ 0,
2058
+ EXP_LIMIT,
2059
+ "minE",
2060
+ -EXP_LIMIT,
2061
+ 0,
2062
+ "modulo",
2063
+ 0,
2064
+ 9
2065
+ ];
2066
+ for (i = 0; i < ps.length; i += 3) {
2067
+ if (p = ps[i], useDefaults)
2068
+ this[p] = DEFAULTS[p];
2069
+ if ((v = obj[p]) !== void 0) {
2070
+ if (mathfloor(v) === v && v >= ps[i + 1] && v <= ps[i + 2])
2071
+ this[p] = v;
2072
+ else
2073
+ throw Error(invalidArgument + p + ": " + v);
2074
+ }
2075
+ }
2076
+ if (p = "crypto", useDefaults)
2077
+ this[p] = DEFAULTS[p];
2078
+ if ((v = obj[p]) !== void 0) {
2079
+ if (v === true || v === false || v === 0 || v === 1) {
2080
+ if (v) {
2081
+ if (typeof crypto != "undefined" && crypto && (crypto.getRandomValues || crypto.randomBytes)) {
2082
+ this[p] = true;
2083
+ } else {
2084
+ throw Error(cryptoUnavailable);
2085
+ }
2086
+ } else {
2087
+ this[p] = false;
2088
+ }
2089
+ } else {
2090
+ throw Error(invalidArgument + p + ": " + v);
2091
+ }
2092
+ }
2093
+ return this;
2094
+ }
2095
+ function cos(x) {
2096
+ return new this(x).cos();
2097
+ }
2098
+ function cosh(x) {
2099
+ return new this(x).cosh();
2100
+ }
2101
+ function clone(obj) {
2102
+ var i, p, ps;
2103
+ function Decimal2(v) {
2104
+ var e, i2, t, x = this;
2105
+ if (!(x instanceof Decimal2))
2106
+ return new Decimal2(v);
2107
+ x.constructor = Decimal2;
2108
+ if (isDecimalInstance(v)) {
2109
+ x.s = v.s;
2110
+ if (external) {
2111
+ if (!v.d || v.e > Decimal2.maxE) {
2112
+ x.e = NaN;
2113
+ x.d = null;
2114
+ } else if (v.e < Decimal2.minE) {
2115
+ x.e = 0;
2116
+ x.d = [0];
2117
+ } else {
2118
+ x.e = v.e;
2119
+ x.d = v.d.slice();
2120
+ }
2121
+ } else {
2122
+ x.e = v.e;
2123
+ x.d = v.d ? v.d.slice() : v.d;
2124
+ }
2125
+ return;
2126
+ }
2127
+ t = typeof v;
2128
+ if (t === "number") {
2129
+ if (v === 0) {
2130
+ x.s = 1 / v < 0 ? -1 : 1;
2131
+ x.e = 0;
2132
+ x.d = [0];
2133
+ return;
2134
+ }
2135
+ if (v < 0) {
2136
+ v = -v;
2137
+ x.s = -1;
2138
+ } else {
2139
+ x.s = 1;
2140
+ }
2141
+ if (v === ~~v && v < 1e7) {
2142
+ for (e = 0, i2 = v; i2 >= 10; i2 /= 10)
2143
+ e++;
2144
+ if (external) {
2145
+ if (e > Decimal2.maxE) {
2146
+ x.e = NaN;
2147
+ x.d = null;
2148
+ } else if (e < Decimal2.minE) {
2149
+ x.e = 0;
2150
+ x.d = [0];
2151
+ } else {
2152
+ x.e = e;
2153
+ x.d = [v];
2154
+ }
2155
+ } else {
2156
+ x.e = e;
2157
+ x.d = [v];
2158
+ }
2159
+ return;
2160
+ } else if (v * 0 !== 0) {
2161
+ if (!v)
2162
+ x.s = NaN;
2163
+ x.e = NaN;
2164
+ x.d = null;
2165
+ return;
2166
+ }
2167
+ return parseDecimal(x, v.toString());
2168
+ } else if (t !== "string") {
2169
+ throw Error(invalidArgument + v);
2170
+ }
2171
+ if ((i2 = v.charCodeAt(0)) === 45) {
2172
+ v = v.slice(1);
2173
+ x.s = -1;
2174
+ } else {
2175
+ if (i2 === 43)
2176
+ v = v.slice(1);
2177
+ x.s = 1;
2178
+ }
2179
+ return isDecimal.test(v) ? parseDecimal(x, v) : parseOther(x, v);
2180
+ }
2181
+ Decimal2.prototype = P;
2182
+ Decimal2.ROUND_UP = 0;
2183
+ Decimal2.ROUND_DOWN = 1;
2184
+ Decimal2.ROUND_CEIL = 2;
2185
+ Decimal2.ROUND_FLOOR = 3;
2186
+ Decimal2.ROUND_HALF_UP = 4;
2187
+ Decimal2.ROUND_HALF_DOWN = 5;
2188
+ Decimal2.ROUND_HALF_EVEN = 6;
2189
+ Decimal2.ROUND_HALF_CEIL = 7;
2190
+ Decimal2.ROUND_HALF_FLOOR = 8;
2191
+ Decimal2.EUCLID = 9;
2192
+ Decimal2.config = Decimal2.set = config;
2193
+ Decimal2.clone = clone;
2194
+ Decimal2.isDecimal = isDecimalInstance;
2195
+ Decimal2.abs = abs;
2196
+ Decimal2.acos = acos;
2197
+ Decimal2.acosh = acosh;
2198
+ Decimal2.add = add;
2199
+ Decimal2.asin = asin;
2200
+ Decimal2.asinh = asinh;
2201
+ Decimal2.atan = atan;
2202
+ Decimal2.atanh = atanh;
2203
+ Decimal2.atan2 = atan2;
2204
+ Decimal2.cbrt = cbrt;
2205
+ Decimal2.ceil = ceil;
2206
+ Decimal2.clamp = clamp;
2207
+ Decimal2.cos = cos;
2208
+ Decimal2.cosh = cosh;
2209
+ Decimal2.div = div;
2210
+ Decimal2.exp = exp;
2211
+ Decimal2.floor = floor;
2212
+ Decimal2.hypot = hypot;
2213
+ Decimal2.ln = ln;
2214
+ Decimal2.log = log;
2215
+ Decimal2.log10 = log10;
2216
+ Decimal2.log2 = log2;
2217
+ Decimal2.max = max;
2218
+ Decimal2.min = min;
2219
+ Decimal2.mod = mod;
2220
+ Decimal2.mul = mul;
2221
+ Decimal2.pow = pow;
2222
+ Decimal2.random = random;
2223
+ Decimal2.round = round;
2224
+ Decimal2.sign = sign;
2225
+ Decimal2.sin = sin;
2226
+ Decimal2.sinh = sinh;
2227
+ Decimal2.sqrt = sqrt;
2228
+ Decimal2.sub = sub;
2229
+ Decimal2.sum = sum;
2230
+ Decimal2.tan = tan;
2231
+ Decimal2.tanh = tanh;
2232
+ Decimal2.trunc = trunc;
2233
+ if (obj === void 0)
2234
+ obj = {};
2235
+ if (obj) {
2236
+ if (obj.defaults !== true) {
2237
+ ps = ["precision", "rounding", "toExpNeg", "toExpPos", "maxE", "minE", "modulo", "crypto"];
2238
+ for (i = 0; i < ps.length; )
2239
+ if (!obj.hasOwnProperty(p = ps[i++]))
2240
+ obj[p] = this[p];
2241
+ }
2242
+ }
2243
+ Decimal2.config(obj);
2244
+ return Decimal2;
2245
+ }
2246
+ function div(x, y) {
2247
+ return new this(x).div(y);
2248
+ }
2249
+ function exp(x) {
2250
+ return new this(x).exp();
2251
+ }
2252
+ function floor(x) {
2253
+ return finalise(x = new this(x), x.e + 1, 3);
2254
+ }
2255
+ function hypot() {
2256
+ var i, n, t = new this(0);
2257
+ external = false;
2258
+ for (i = 0; i < arguments.length; ) {
2259
+ n = new this(arguments[i++]);
2260
+ if (!n.d) {
2261
+ if (n.s) {
2262
+ external = true;
2263
+ return new this(1 / 0);
2264
+ }
2265
+ t = n;
2266
+ } else if (t.d) {
2267
+ t = t.plus(n.times(n));
2268
+ }
2269
+ }
2270
+ external = true;
2271
+ return t.sqrt();
2272
+ }
2273
+ function isDecimalInstance(obj) {
2274
+ return obj instanceof Decimal || obj && obj.toStringTag === tag || false;
2275
+ }
2276
+ function ln(x) {
2277
+ return new this(x).ln();
2278
+ }
2279
+ function log(x, y) {
2280
+ return new this(x).log(y);
2281
+ }
2282
+ function log2(x) {
2283
+ return new this(x).log(2);
2284
+ }
2285
+ function log10(x) {
2286
+ return new this(x).log(10);
2287
+ }
2288
+ function max() {
2289
+ return maxOrMin(this, arguments, "lt");
2290
+ }
2291
+ function min() {
2292
+ return maxOrMin(this, arguments, "gt");
2293
+ }
2294
+ function mod(x, y) {
2295
+ return new this(x).mod(y);
2296
+ }
2297
+ function mul(x, y) {
2298
+ return new this(x).mul(y);
2299
+ }
2300
+ function pow(x, y) {
2301
+ return new this(x).pow(y);
2302
+ }
2303
+ function random(sd) {
2304
+ var d, e, k, n, i = 0, r = new this(1), rd = [];
2305
+ if (sd === void 0)
2306
+ sd = this.precision;
2307
+ else
2308
+ checkInt32(sd, 1, MAX_DIGITS);
2309
+ k = Math.ceil(sd / LOG_BASE);
2310
+ if (!this.crypto) {
2311
+ for (; i < k; )
2312
+ rd[i++] = Math.random() * 1e7 | 0;
2313
+ } else if (crypto.getRandomValues) {
2314
+ d = crypto.getRandomValues(new Uint32Array(k));
2315
+ for (; i < k; ) {
2316
+ n = d[i];
2317
+ if (n >= 429e7) {
2318
+ d[i] = crypto.getRandomValues(new Uint32Array(1))[0];
2319
+ } else {
2320
+ rd[i++] = n % 1e7;
2321
+ }
2322
+ }
2323
+ } else if (crypto.randomBytes) {
2324
+ d = crypto.randomBytes(k *= 4);
2325
+ for (; i < k; ) {
2326
+ n = d[i] + (d[i + 1] << 8) + (d[i + 2] << 16) + ((d[i + 3] & 127) << 24);
2327
+ if (n >= 214e7) {
2328
+ crypto.randomBytes(4).copy(d, i);
2329
+ } else {
2330
+ rd.push(n % 1e7);
2331
+ i += 4;
2332
+ }
2333
+ }
2334
+ i = k / 4;
2335
+ } else {
2336
+ throw Error(cryptoUnavailable);
2337
+ }
2338
+ k = rd[--i];
2339
+ sd %= LOG_BASE;
2340
+ if (k && sd) {
2341
+ n = mathpow(10, LOG_BASE - sd);
2342
+ rd[i] = (k / n | 0) * n;
2343
+ }
2344
+ for (; rd[i] === 0; i--)
2345
+ rd.pop();
2346
+ if (i < 0) {
2347
+ e = 0;
2348
+ rd = [0];
2349
+ } else {
2350
+ e = -1;
2351
+ for (; rd[0] === 0; e -= LOG_BASE)
2352
+ rd.shift();
2353
+ for (k = 1, n = rd[0]; n >= 10; n /= 10)
2354
+ k++;
2355
+ if (k < LOG_BASE)
2356
+ e -= LOG_BASE - k;
2357
+ }
2358
+ r.e = e;
2359
+ r.d = rd;
2360
+ return r;
2361
+ }
2362
+ function round(x) {
2363
+ return finalise(x = new this(x), x.e + 1, this.rounding);
2364
+ }
2365
+ function sign(x) {
2366
+ x = new this(x);
2367
+ return x.d ? x.d[0] ? x.s : 0 * x.s : x.s || NaN;
2368
+ }
2369
+ function sin(x) {
2370
+ return new this(x).sin();
2371
+ }
2372
+ function sinh(x) {
2373
+ return new this(x).sinh();
2374
+ }
2375
+ function sqrt(x) {
2376
+ return new this(x).sqrt();
2377
+ }
2378
+ function sub(x, y) {
2379
+ return new this(x).sub(y);
2380
+ }
2381
+ function sum() {
2382
+ var i = 0, args = arguments, x = new this(args[i]);
2383
+ external = false;
2384
+ for (; x.s && ++i < args.length; )
2385
+ x = x.plus(args[i]);
2386
+ external = true;
2387
+ return finalise(x, this.precision, this.rounding);
2388
+ }
2389
+ function tan(x) {
2390
+ return new this(x).tan();
2391
+ }
2392
+ function tanh(x) {
2393
+ return new this(x).tanh();
2394
+ }
2395
+ function trunc(x) {
2396
+ return finalise(x = new this(x), x.e + 1, 1);
2397
+ }
2398
+ P[Symbol.for("nodejs.util.inspect.custom")] = P.toString;
2399
+ P[Symbol.toStringTag] = "Decimal";
2400
+ var Decimal = P.constructor = clone(DEFAULTS);
2401
+ LN10 = new Decimal(LN10);
2402
+ PI = new Decimal(PI);
2403
+ var decimal_default = Decimal;
2404
+
2405
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/constants.js
2406
+ var TEN = new decimal_default(10);
2407
+ var ZERO = new decimal_default(0);
2408
+ var NEGATIVE_ZERO = new decimal_default(-0);
2409
+
55
2410
  // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/262.js
56
2411
  function ToString(o) {
57
2412
  if (typeof o === "symbol") {
@@ -61,36 +2416,30 @@
61
2416
  }
62
2417
  function ToNumber(val) {
63
2418
  if (val === void 0) {
64
- return NaN;
2419
+ return new Decimal(NaN);
65
2420
  }
66
2421
  if (val === null) {
67
- return 0;
2422
+ return ZERO;
68
2423
  }
69
2424
  if (typeof val === "boolean") {
70
- return val ? 1 : 0;
71
- }
72
- if (typeof val === "number") {
73
- return val;
2425
+ return new Decimal(val ? 1 : 0);
74
2426
  }
75
2427
  if (typeof val === "symbol" || typeof val === "bigint") {
76
2428
  throw new TypeError("Cannot convert symbol/bigint to number");
77
2429
  }
78
- return Number(val);
2430
+ return new Decimal(Number(val));
79
2431
  }
80
2432
  function ToInteger(n) {
81
2433
  var number = ToNumber(n);
82
- if (isNaN(number) || SameValue(number, -0)) {
83
- return 0;
2434
+ if (number.isNaN() || number.isZero()) {
2435
+ return ZERO;
84
2436
  }
85
- if (isFinite(number)) {
2437
+ if (number.isFinite()) {
86
2438
  return number;
87
2439
  }
88
- var integer = Math.floor(Math.abs(number));
89
- if (number < 0) {
90
- integer = -integer;
91
- }
92
- if (SameValue(integer, -0)) {
93
- return 0;
2440
+ var integer = number.abs().floor();
2441
+ if (number.isNegative()) {
2442
+ integer = integer.negated();
94
2443
  }
95
2444
  return integer;
96
2445
  }
@@ -101,7 +2450,7 @@
101
2450
  if (Math.abs(time) > 8.64 * 1e15) {
102
2451
  return NaN;
103
2452
  }
104
- return ToInteger(time);
2453
+ return ToInteger(time).toNumber();
105
2454
  }
106
2455
  function ToObject(arg) {
107
2456
  if (arg == null) {
@@ -148,14 +2497,14 @@
148
2497
  }
149
2498
  }
150
2499
  var MS_PER_DAY = 864e5;
151
- function mod(x, y) {
2500
+ function mod2(x, y) {
152
2501
  return x - Math.floor(x / y) * y;
153
2502
  }
154
2503
  function Day(t) {
155
2504
  return Math.floor(t / MS_PER_DAY);
156
2505
  }
157
2506
  function WeekDay(t) {
158
- return mod(Day(t) + 4, 7);
2507
+ return mod2(Day(t) + 4, 7);
159
2508
  }
160
2509
  function DayFromYear(y) {
161
2510
  return Date.UTC(y, 0) / MS_PER_DAY;
@@ -271,13 +2620,13 @@
271
2620
  var MS_PER_MINUTE = MS_PER_SECOND * SECONDS_PER_MINUTE;
272
2621
  var MS_PER_HOUR = MS_PER_MINUTE * MINUTES_PER_HOUR;
273
2622
  function HourFromTime(t) {
274
- return mod(Math.floor(t / MS_PER_HOUR), HOURS_PER_DAY);
2623
+ return mod2(Math.floor(t / MS_PER_HOUR), HOURS_PER_DAY);
275
2624
  }
276
2625
  function MinFromTime(t) {
277
- return mod(Math.floor(t / MS_PER_MINUTE), MINUTES_PER_HOUR);
2626
+ return mod2(Math.floor(t / MS_PER_MINUTE), MINUTES_PER_HOUR);
278
2627
  }
279
2628
  function SecFromTime(t) {
280
- return mod(Math.floor(t / MS_PER_SECOND), SECONDS_PER_MINUTE);
2629
+ return mod2(Math.floor(t / MS_PER_SECOND), SECONDS_PER_MINUTE);
281
2630
  }
282
2631
  function IsCallable(fn) {
283
2632
  return typeof fn === "function";
@@ -293,24 +2642,24 @@
293
2642
  if (typeof O !== "object") {
294
2643
  return false;
295
2644
  }
296
- var P = C.prototype;
297
- if (typeof P !== "object") {
2645
+ var P2 = C.prototype;
2646
+ if (typeof P2 !== "object") {
298
2647
  throw new TypeError("OrdinaryHasInstance called on an object with an invalid prototype property.");
299
2648
  }
300
- return Object.prototype.isPrototypeOf.call(P, O);
2649
+ return Object.prototype.isPrototypeOf.call(P2, O);
301
2650
  }
302
2651
  function msFromTime(t) {
303
- return mod(t, MS_PER_SECOND);
2652
+ return mod2(t, MS_PER_SECOND);
304
2653
  }
305
2654
 
306
2655
  // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/DefaultNumberOption.js
307
- function DefaultNumberOption(inputVal, min, max, fallback) {
2656
+ function DefaultNumberOption(inputVal, min2, max2, fallback) {
308
2657
  if (inputVal === void 0) {
309
2658
  return fallback;
310
2659
  }
311
2660
  var val = Number(inputVal);
312
- if (isNaN(val) || val < min || val > max) {
313
- throw new RangeError("".concat(val, " is outside of range [").concat(min, ", ").concat(max, "]"));
2661
+ if (isNaN(val) || val < min2 || val > max2) {
2662
+ throw new RangeError("".concat(val, " is outside of range [").concat(min2, ", ").concat(max2, "]"));
314
2663
  }
315
2664
  return Math.floor(val);
316
2665
  }
@@ -496,15 +2845,21 @@
496
2845
  var serializerDefault = function() {
497
2846
  return JSON.stringify(arguments);
498
2847
  };
499
- function ObjectWithoutPrototypeCache() {
500
- this.cache = /* @__PURE__ */ Object.create(null);
501
- }
502
- ObjectWithoutPrototypeCache.prototype.get = function(key) {
503
- return this.cache[key];
504
- };
505
- ObjectWithoutPrototypeCache.prototype.set = function(key, value) {
506
- this.cache[key] = value;
507
- };
2848
+ var ObjectWithoutPrototypeCache = (
2849
+ /** @class */
2850
+ function() {
2851
+ function ObjectWithoutPrototypeCache2() {
2852
+ this.cache = /* @__PURE__ */ Object.create(null);
2853
+ }
2854
+ ObjectWithoutPrototypeCache2.prototype.get = function(key) {
2855
+ return this.cache[key];
2856
+ };
2857
+ ObjectWithoutPrototypeCache2.prototype.set = function(key, value) {
2858
+ this.cache[key] = value;
2859
+ };
2860
+ return ObjectWithoutPrototypeCache2;
2861
+ }()
2862
+ );
508
2863
  var cacheDefault = {
509
2864
  create: function create() {
510
2865
  return new ObjectWithoutPrototypeCache();
@@ -584,6 +2939,21 @@
584
2939
  strategy: strategies.variadic
585
2940
  });
586
2941
 
2942
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/NumberFormat/ComputeExponentForMagnitude.js
2943
+ decimal_default.set({
2944
+ toExpPos: 100
2945
+ });
2946
+
2947
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/NumberFormat/ToRawFixed.js
2948
+ decimal_default.set({
2949
+ toExpPos: 100
2950
+ });
2951
+
2952
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/NumberFormat/ToRawPrecision.js
2953
+ decimal_default.set({
2954
+ toExpPos: 100
2955
+ });
2956
+
587
2957
  // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/regex.generated.js
588
2958
  var S_UNICODE_REGEX = /[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20BF\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC1\uFDFC\uFDFD\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDE8\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEE0-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF73\uDF80-\uDFD8\uDFE0-\uDFEB]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDD78\uDD7A-\uDDCB\uDDCD-\uDE53\uDE60-\uDE6D\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6\uDF00-\uDF92\uDF94-\uDFCA]/;
589
2959
 
@@ -6683,7 +9053,7 @@
6683
9053
  if (date === void 0) {
6684
9054
  date = Date.now();
6685
9055
  } else {
6686
- date = ToNumber(date);
9056
+ date = ToNumber(date).toNumber();
6687
9057
  }
6688
9058
  return FormatDateTimeToParts(this, date, {
6689
9059
  getInternalSlots,
@@ -6702,8 +9072,8 @@
6702
9072
  if (startDate === void 0 || endDate === void 0) {
6703
9073
  throw new TypeError("startDate/endDate cannot be undefined");
6704
9074
  }
6705
- const x = ToNumber(startDate);
6706
- const y = ToNumber(endDate);
9075
+ const x = ToNumber(startDate).toNumber();
9076
+ const y = ToNumber(endDate).toNumber();
6707
9077
  return FormatDateTimeRangeToParts(dtf, x, y, {
6708
9078
  getInternalSlots,
6709
9079
  localeData: DateTimeFormat4.localeData,
@@ -6721,8 +9091,8 @@
6721
9091
  if (startDate === void 0 || endDate === void 0) {
6722
9092
  throw new TypeError("startDate/endDate cannot be undefined");
6723
9093
  }
6724
- const x = ToNumber(startDate);
6725
- const y = ToNumber(endDate);
9094
+ const x = ToNumber(startDate).toNumber();
9095
+ const y = ToNumber(endDate).toNumber();
6726
9096
  return FormatDateTimeRange(dtf, x, y, {
6727
9097
  getInternalSlots,
6728
9098
  localeData: DateTimeFormat4.localeData,
@@ -6936,4 +9306,15 @@
6936
9306
  });
6937
9307
  }
6938
9308
  })();
9309
+ /*! Bundled license information:
9310
+
9311
+ decimal.js/decimal.mjs:
9312
+ (*!
9313
+ * decimal.js v10.4.3
9314
+ * An arbitrary-precision Decimal type for JavaScript.
9315
+ * https://github.com/MikeMcl/decimal.js
9316
+ * Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com>
9317
+ * MIT Licence
9318
+ *)
9319
+ */
6939
9320
  //# sourceMappingURL=polyfill.iife.js.map