react-intl 9.0.0 → 10.1.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.
@@ -2,27 +2,11 @@
2
2
  var ReactIntl = (() => {
3
3
  var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
5
- var __defProps = Object.defineProperties;
6
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
8
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
9
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
10
7
  var __getProtoOf = Object.getPrototypeOf;
11
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
12
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
13
9
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
14
- var __spreadValues = (a, b) => {
15
- for (var prop in b || (b = {}))
16
- if (__hasOwnProp.call(b, prop))
17
- __defNormalProp(a, prop, b[prop]);
18
- if (__getOwnPropSymbols)
19
- for (var prop of __getOwnPropSymbols(b)) {
20
- if (__propIsEnum.call(b, prop))
21
- __defNormalProp(a, prop, b[prop]);
22
- }
23
- return a;
24
- };
25
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
26
10
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
27
11
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
28
12
  }) : x)(function(x) {
@@ -30,18 +14,6 @@ var ReactIntl = (() => {
30
14
  return require.apply(this, arguments);
31
15
  throw Error('Dynamic require of "' + x + '" is not supported');
32
16
  });
33
- var __objRest = (source, exclude) => {
34
- var target = {};
35
- for (var prop in source)
36
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
37
- target[prop] = source[prop];
38
- if (source != null && __getOwnPropSymbols)
39
- for (var prop of __getOwnPropSymbols(source)) {
40
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
41
- target[prop] = source[prop];
42
- }
43
- return target;
44
- };
45
17
  var __export = (target, all) => {
46
18
  for (var name in all)
47
19
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -54,15 +26,15 @@ var ReactIntl = (() => {
54
26
  }
55
27
  return to;
56
28
  };
57
- var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(
29
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
58
30
  // If the importer is in node compatibility mode or this is not an ESM
59
31
  // file that has been converted to a CommonJS file using a Babel-
60
32
  // compatible transform (i.e. "__esModule" has not been set), then set
61
33
  // "default" to the CommonJS "module.exports" for node compatibility.
62
- isNodeMode || !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target,
63
- mod2
34
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
+ mod
64
36
  ));
65
- var __toCommonJS = (mod2) => __copyProps(__defProp({}, "__esModule", { value: true }), mod2);
37
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
66
38
  var __publicField = (obj, key, value) => {
67
39
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
68
40
  return value;
@@ -388,14 +360,24 @@ var ReactIntl = (() => {
388
360
  result.compactDisplay = "long";
389
361
  continue;
390
362
  case "scientific":
391
- result = __spreadValues(__spreadProps(__spreadValues({}, result), {
392
- notation: "scientific"
393
- }), token.options.reduce((all, opt) => __spreadValues(__spreadValues({}, all), parseNotationOptions(opt)), {}));
363
+ result = {
364
+ ...result,
365
+ notation: "scientific",
366
+ ...token.options.reduce((all, opt) => ({
367
+ ...all,
368
+ ...parseNotationOptions(opt)
369
+ }), {})
370
+ };
394
371
  continue;
395
372
  case "engineering":
396
- result = __spreadValues(__spreadProps(__spreadValues({}, result), {
397
- notation: "engineering"
398
- }), token.options.reduce((all, opt) => __spreadValues(__spreadValues({}, all), parseNotationOptions(opt)), {}));
373
+ result = {
374
+ ...result,
375
+ notation: "engineering",
376
+ ...token.options.reduce((all, opt) => ({
377
+ ...all,
378
+ ...parseNotationOptions(opt)
379
+ }), {})
380
+ };
399
381
  continue;
400
382
  case "notation-simple":
401
383
  result.notation = "standard";
@@ -479,25 +461,38 @@ var ReactIntl = (() => {
479
461
  });
480
462
  const opt = token.options[0];
481
463
  if (opt === "w") {
482
- result = __spreadProps(__spreadValues({}, result), {
464
+ result = {
465
+ ...result,
483
466
  trailingZeroDisplay: "stripIfInteger"
484
- });
467
+ };
485
468
  } else if (opt) {
486
- result = __spreadValues(__spreadValues({}, result), parseSignificantPrecision(opt));
469
+ result = {
470
+ ...result,
471
+ ...parseSignificantPrecision(opt)
472
+ };
487
473
  }
488
474
  continue;
489
475
  }
490
476
  if (SIGNIFICANT_PRECISION_REGEX.test(token.stem)) {
491
- result = __spreadValues(__spreadValues({}, result), parseSignificantPrecision(token.stem));
477
+ result = {
478
+ ...result,
479
+ ...parseSignificantPrecision(token.stem)
480
+ };
492
481
  continue;
493
482
  }
494
483
  const signOpts = parseSign(token.stem);
495
484
  if (signOpts) {
496
- result = __spreadValues(__spreadValues({}, result), signOpts);
485
+ result = {
486
+ ...result,
487
+ ...signOpts
488
+ };
497
489
  }
498
490
  const conciseScientificAndEngineeringOpts = parseConciseScientificAndEngineeringStem(token.stem);
499
491
  if (conciseScientificAndEngineeringOpts) {
500
- result = __spreadValues(__spreadValues({}, result), conciseScientificAndEngineeringOpts);
492
+ result = {
493
+ ...result,
494
+ ...conciseScientificAndEngineeringOpts
495
+ };
501
496
  }
502
497
  }
503
498
  return result;
@@ -1845,10 +1840,9 @@ var ReactIntl = (() => {
1845
1840
  };
1846
1841
  var IDENTIFIER_PREFIX_RE = new RegExp("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu");
1847
1842
  function matchIdentifierAtIndex(s, index) {
1848
- var _a;
1849
1843
  IDENTIFIER_PREFIX_RE.lastIndex = index;
1850
1844
  const match = IDENTIFIER_PREFIX_RE.exec(s);
1851
- return (_a = match[1]) != null ? _a : "";
1845
+ return match[1] ?? "";
1852
1846
  }
1853
1847
  var Parser = class {
1854
1848
  constructor(message, options = {}) {
@@ -2156,7 +2150,6 @@ var ReactIntl = (() => {
2156
2150
  };
2157
2151
  }
2158
2152
  parseArgumentOptions(nestingLevel, expectingCloseTag, value, openingBracePosition) {
2159
- var _a;
2160
2153
  let typeStartPosition = this.clonePosition();
2161
2154
  let argType = this.parseIdentifierIfPossible().value;
2162
2155
  let typeEndPosition = this.clonePosition();
@@ -2237,7 +2230,7 @@ var ReactIntl = (() => {
2237
2230
  type: argType === "number" ? TYPE.number : argType === "date" ? TYPE.date : TYPE.time,
2238
2231
  value,
2239
2232
  location,
2240
- style: (_a = styleAndLocation == null ? void 0 : styleAndLocation.style) != null ? _a : null
2233
+ style: styleAndLocation?.style ?? null
2241
2234
  },
2242
2235
  err: null
2243
2236
  };
@@ -2248,7 +2241,7 @@ var ReactIntl = (() => {
2248
2241
  const typeEndPosition2 = this.clonePosition();
2249
2242
  this.bumpSpace();
2250
2243
  if (!this.bumpIf(",")) {
2251
- return this.error(ErrorKind.EXPECT_SELECT_ARGUMENT_OPTIONS, createLocation(typeEndPosition2, __spreadValues({}, typeEndPosition2)));
2244
+ return this.error(ErrorKind.EXPECT_SELECT_ARGUMENT_OPTIONS, createLocation(typeEndPosition2, { ...typeEndPosition2 }));
2252
2245
  }
2253
2246
  this.bumpSpace();
2254
2247
  let identifierAndLocation = this.parseIdentifierIfPossible();
@@ -2361,7 +2354,7 @@ var ReactIntl = (() => {
2361
2354
  let tokens = [];
2362
2355
  try {
2363
2356
  tokens = parseNumberSkeletonFromString(skeleton);
2364
- } catch (e) {
2357
+ } catch {
2365
2358
  return this.error(ErrorKind.INVALID_NUMBER_SKELETON, location);
2366
2359
  }
2367
2360
  return {
@@ -2442,11 +2435,11 @@ var ReactIntl = (() => {
2442
2435
  };
2443
2436
  }
2444
2437
  tryParseDecimalInteger(expectNumberError, invalidNumberError) {
2445
- let sign2 = 1;
2438
+ let sign = 1;
2446
2439
  const startingPosition = this.clonePosition();
2447
2440
  if (this.bumpIf("+")) {
2448
2441
  } else if (this.bumpIf("-")) {
2449
- sign2 = -1;
2442
+ sign = -1;
2450
2443
  }
2451
2444
  let hasDigits = false;
2452
2445
  let decimal = 0;
@@ -2464,7 +2457,7 @@ var ReactIntl = (() => {
2464
2457
  if (!hasDigits) {
2465
2458
  return this.error(expectNumberError, location);
2466
2459
  }
2467
- decimal *= sign2;
2460
+ decimal *= sign;
2468
2461
  if (!Number.isSafeInteger(decimal)) {
2469
2462
  return this.error(invalidNumberError, location);
2470
2463
  }
@@ -2596,7 +2589,7 @@ var ReactIntl = (() => {
2596
2589
  const code = this.char();
2597
2590
  const offset = this.offset();
2598
2591
  const nextCode = this.message.charCodeAt(offset + (code >= 65536 ? 2 : 1));
2599
- return nextCode != null ? nextCode : null;
2592
+ return nextCode ?? null;
2600
2593
  }
2601
2594
  };
2602
2595
  function _isAlpha(codepoint) {
@@ -2631,10 +2624,11 @@ var ReactIntl = (() => {
2631
2624
  });
2632
2625
  }
2633
2626
  function parse(message, opts = {}) {
2634
- opts = __spreadValues({
2627
+ opts = {
2635
2628
  shouldParseSkeletons: true,
2636
- requiresOtherClause: true
2637
- }, opts);
2629
+ requiresOtherClause: true,
2630
+ ...opts
2631
+ };
2638
2632
  const result = new Parser(message, opts).parse();
2639
2633
  if (result.err) {
2640
2634
  const error = SyntaxError(ErrorKind[result.err.kind]);
@@ -2642,2377 +2636,652 @@ var ReactIntl = (() => {
2642
2636
  error.originalMessage = result.err.message;
2643
2637
  throw error;
2644
2638
  }
2645
- if (!(opts == null ? void 0 : opts.captureLocation)) {
2639
+ if (!opts?.captureLocation) {
2646
2640
  pruneLocation(result.val);
2647
2641
  }
2648
2642
  return result.val;
2649
2643
  }
2650
2644
 
2651
- // node_modules/.aspect_rules_js/decimal.js@10.6.0/node_modules/decimal.js/decimal.mjs
2652
- var EXP_LIMIT = 9e15;
2653
- var MAX_DIGITS = 1e9;
2654
- var NUMERALS = "0123456789abcdef";
2655
- var LN10 = "2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058";
2656
- var PI = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789";
2657
- var DEFAULTS = {
2658
- // These values must be integers within the stated ranges (inclusive).
2659
- // Most of these values can be changed at run-time using the `Decimal.config` method.
2660
- // The maximum number of significant digits of the result of a calculation or base conversion.
2661
- // E.g. `Decimal.config({ precision: 20 });`
2662
- precision: 20,
2663
- // 1 to MAX_DIGITS
2664
- // The rounding mode used when rounding to `precision`.
2665
- //
2666
- // ROUND_UP 0 Away from zero.
2667
- // ROUND_DOWN 1 Towards zero.
2668
- // ROUND_CEIL 2 Towards +Infinity.
2669
- // ROUND_FLOOR 3 Towards -Infinity.
2670
- // ROUND_HALF_UP 4 Towards nearest neighbour. If equidistant, up.
2671
- // ROUND_HALF_DOWN 5 Towards nearest neighbour. If equidistant, down.
2672
- // ROUND_HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour.
2673
- // ROUND_HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity.
2674
- // ROUND_HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
2675
- //
2676
- // E.g.
2677
- // `Decimal.rounding = 4;`
2678
- // `Decimal.rounding = Decimal.ROUND_HALF_UP;`
2679
- rounding: 4,
2680
- // 0 to 8
2681
- // The modulo mode used when calculating the modulus: a mod n.
2682
- // The quotient (q = a / n) is calculated according to the corresponding rounding mode.
2683
- // The remainder (r) is calculated as: r = a - n * q.
2684
- //
2685
- // UP 0 The remainder is positive if the dividend is negative, else is negative.
2686
- // DOWN 1 The remainder has the same sign as the dividend (JavaScript %).
2687
- // FLOOR 3 The remainder has the same sign as the divisor (Python %).
2688
- // HALF_EVEN 6 The IEEE 754 remainder function.
2689
- // EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)). Always positive.
2690
- //
2691
- // Truncated division (1), floored division (3), the IEEE 754 remainder (6), and Euclidian
2692
- // division (9) are commonly used for the modulus operation. The other rounding modes can also
2693
- // be used, but they may not give useful results.
2694
- modulo: 1,
2695
- // 0 to 9
2696
- // The exponent value at and beneath which `toString` returns exponential notation.
2697
- // JavaScript numbers: -7
2698
- toExpNeg: -7,
2699
- // 0 to -EXP_LIMIT
2700
- // The exponent value at and above which `toString` returns exponential notation.
2701
- // JavaScript numbers: 21
2702
- toExpPos: 21,
2703
- // 0 to EXP_LIMIT
2704
- // The minimum exponent value, beneath which underflow to zero occurs.
2705
- // JavaScript numbers: -324 (5e-324)
2706
- minE: -EXP_LIMIT,
2707
- // -1 to -EXP_LIMIT
2708
- // The maximum exponent value, above which overflow to Infinity occurs.
2709
- // JavaScript numbers: 308 (1.7976931348623157e+308)
2710
- maxE: EXP_LIMIT,
2711
- // 1 to EXP_LIMIT
2712
- // Whether to use cryptographically-secure random number generation, if available.
2713
- crypto: false
2714
- // true/false
2715
- };
2716
- var inexact;
2717
- var quadrant;
2718
- var external = true;
2719
- var decimalError = "[DecimalError] ";
2720
- var invalidArgument = decimalError + "Invalid argument: ";
2721
- var precisionLimitExceeded = decimalError + "Precision limit exceeded";
2722
- var cryptoUnavailable = decimalError + "crypto unavailable";
2723
- var tag = "[object Decimal]";
2724
- var mathfloor = Math.floor;
2725
- var mathpow = Math.pow;
2726
- var isBinary = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i;
2727
- var isHex = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i;
2728
- var isOctal = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i;
2729
- var isDecimal = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;
2730
- var BASE = 1e7;
2731
- var LOG_BASE = 7;
2732
- var MAX_SAFE_INTEGER = 9007199254740991;
2733
- var LN10_PRECISION = LN10.length - 1;
2734
- var PI_PRECISION = PI.length - 1;
2735
- var P = { toStringTag: tag };
2736
- P.absoluteValue = P.abs = function() {
2737
- var x = new this.constructor(this);
2738
- if (x.s < 0)
2739
- x.s = 1;
2740
- return finalise(x);
2741
- };
2742
- P.ceil = function() {
2743
- return finalise(new this.constructor(this), this.e + 1, 2);
2744
- };
2745
- P.clampedTo = P.clamp = function(min2, max2) {
2746
- var k, x = this, Ctor = x.constructor;
2747
- min2 = new Ctor(min2);
2748
- max2 = new Ctor(max2);
2749
- if (!min2.s || !max2.s)
2750
- return new Ctor(NaN);
2751
- if (min2.gt(max2))
2752
- throw Error(invalidArgument + max2);
2753
- k = x.cmp(min2);
2754
- return k < 0 ? min2 : x.cmp(max2) > 0 ? max2 : new Ctor(x);
2755
- };
2756
- P.comparedTo = P.cmp = function(y) {
2757
- var i, j, xdL, ydL, x = this, xd = x.d, yd = (y = new x.constructor(y)).d, xs = x.s, ys = y.s;
2758
- if (!xd || !yd) {
2759
- return !xs || !ys ? NaN : xs !== ys ? xs : xd === yd ? 0 : !xd ^ xs < 0 ? 1 : -1;
2760
- }
2761
- if (!xd[0] || !yd[0])
2762
- return xd[0] ? xs : yd[0] ? -ys : 0;
2763
- if (xs !== ys)
2764
- return xs;
2765
- if (x.e !== y.e)
2766
- return x.e > y.e ^ xs < 0 ? 1 : -1;
2767
- xdL = xd.length;
2768
- ydL = yd.length;
2769
- for (i = 0, j = xdL < ydL ? xdL : ydL; i < j; ++i) {
2770
- if (xd[i] !== yd[i])
2771
- return xd[i] > yd[i] ^ xs < 0 ? 1 : -1;
2772
- }
2773
- return xdL === ydL ? 0 : xdL > ydL ^ xs < 0 ? 1 : -1;
2774
- };
2775
- P.cosine = P.cos = function() {
2776
- var pr, rm, x = this, Ctor = x.constructor;
2777
- if (!x.d)
2778
- return new Ctor(NaN);
2779
- if (!x.d[0])
2780
- return new Ctor(1);
2781
- pr = Ctor.precision;
2782
- rm = Ctor.rounding;
2783
- Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
2784
- Ctor.rounding = 1;
2785
- x = cosine(Ctor, toLessThanHalfPi(Ctor, x));
2786
- Ctor.precision = pr;
2787
- Ctor.rounding = rm;
2788
- return finalise(quadrant == 2 || quadrant == 3 ? x.neg() : x, pr, rm, true);
2789
- };
2790
- P.cubeRoot = P.cbrt = function() {
2791
- var e, m, n, r, rep, s, sd, t, t3, t3plusx, x = this, Ctor = x.constructor;
2792
- if (!x.isFinite() || x.isZero())
2793
- return new Ctor(x);
2794
- external = false;
2795
- s = x.s * mathpow(x.s * x, 1 / 3);
2796
- if (!s || Math.abs(s) == 1 / 0) {
2797
- n = digitsToString(x.d);
2798
- e = x.e;
2799
- if (s = (e - n.length + 1) % 3)
2800
- n += s == 1 || s == -2 ? "0" : "00";
2801
- s = mathpow(n, 1 / 3);
2802
- e = mathfloor((e + 1) / 3) - (e % 3 == (e < 0 ? -1 : 2));
2803
- if (s == 1 / 0) {
2804
- n = "5e" + e;
2805
- } else {
2806
- n = s.toExponential();
2807
- n = n.slice(0, n.indexOf("e") + 1) + e;
2808
- }
2809
- r = new Ctor(n);
2810
- r.s = x.s;
2811
- } else {
2812
- r = new Ctor(s.toString());
2813
- }
2814
- sd = (e = Ctor.precision) + 3;
2815
- for (; ; ) {
2816
- t = r;
2817
- t3 = t.times(t).times(t);
2818
- t3plusx = t3.plus(x);
2819
- r = divide(t3plusx.plus(x).times(t), t3plusx.plus(t3), sd + 2, 1);
2820
- if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
2821
- n = n.slice(sd - 3, sd + 1);
2822
- if (n == "9999" || !rep && n == "4999") {
2823
- if (!rep) {
2824
- finalise(t, e + 1, 0);
2825
- if (t.times(t).times(t).eq(x)) {
2826
- r = t;
2827
- break;
2828
- }
2829
- }
2830
- sd += 4;
2831
- rep = 1;
2832
- } else {
2833
- if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
2834
- finalise(r, e + 1, 1);
2835
- m = !r.times(r).times(r).eq(x);
2836
- }
2837
- break;
2838
- }
2839
- }
2840
- }
2841
- external = true;
2842
- return finalise(r, e, Ctor.rounding, m);
2843
- };
2844
- P.decimalPlaces = P.dp = function() {
2845
- var w, d = this.d, n = NaN;
2846
- if (d) {
2847
- w = d.length - 1;
2848
- n = (w - mathfloor(this.e / LOG_BASE)) * LOG_BASE;
2849
- w = d[w];
2850
- if (w)
2851
- for (; w % 10 == 0; w /= 10)
2852
- n--;
2853
- if (n < 0)
2854
- n = 0;
2855
- }
2856
- return n;
2857
- };
2858
- P.dividedBy = P.div = function(y) {
2859
- return divide(this, new this.constructor(y));
2860
- };
2861
- P.dividedToIntegerBy = P.divToInt = function(y) {
2862
- var x = this, Ctor = x.constructor;
2863
- return finalise(divide(x, new Ctor(y), 0, 1, 1), Ctor.precision, Ctor.rounding);
2864
- };
2865
- P.equals = P.eq = function(y) {
2866
- return this.cmp(y) === 0;
2867
- };
2868
- P.floor = function() {
2869
- return finalise(new this.constructor(this), this.e + 1, 3);
2870
- };
2871
- P.greaterThan = P.gt = function(y) {
2872
- return this.cmp(y) > 0;
2873
- };
2874
- P.greaterThanOrEqualTo = P.gte = function(y) {
2875
- var k = this.cmp(y);
2876
- return k == 1 || k === 0;
2877
- };
2878
- P.hyperbolicCosine = P.cosh = function() {
2879
- var k, n, pr, rm, len, x = this, Ctor = x.constructor, one = new Ctor(1);
2880
- if (!x.isFinite())
2881
- return new Ctor(x.s ? 1 / 0 : NaN);
2882
- if (x.isZero())
2883
- return one;
2884
- pr = Ctor.precision;
2885
- rm = Ctor.rounding;
2886
- Ctor.precision = pr + Math.max(x.e, x.sd()) + 4;
2887
- Ctor.rounding = 1;
2888
- len = x.d.length;
2889
- if (len < 32) {
2890
- k = Math.ceil(len / 3);
2891
- n = (1 / tinyPow(4, k)).toString();
2892
- } else {
2893
- k = 16;
2894
- n = "2.3283064365386962890625e-10";
2645
+ // node_modules/.aspect_rules_js/@formatjs+bigdecimal@0.0.0/node_modules/@formatjs/bigdecimal/index.js
2646
+ var DIV_PRECISION = 40;
2647
+ var SpecialValue = function(SpecialValue2) {
2648
+ SpecialValue2[SpecialValue2["NONE"] = 0] = "NONE";
2649
+ SpecialValue2[SpecialValue2["NAN"] = 1] = "NAN";
2650
+ SpecialValue2[SpecialValue2["POSITIVE_INFINITY"] = 2] = "POSITIVE_INFINITY";
2651
+ SpecialValue2[SpecialValue2["NEGATIVE_INFINITY"] = 3] = "NEGATIVE_INFINITY";
2652
+ return SpecialValue2;
2653
+ }(SpecialValue || {});
2654
+ function removeTrailingZeros(mantissa, exponent) {
2655
+ if (mantissa === 0n)
2656
+ return [0n, 0];
2657
+ while (mantissa % 10n === 0n) {
2658
+ mantissa /= 10n;
2659
+ exponent++;
2660
+ }
2661
+ return [mantissa, exponent];
2662
+ }
2663
+ function bigintAbs(n) {
2664
+ return n < 0n ? -n : n;
2665
+ }
2666
+ function digitCount(n) {
2667
+ if (n === 0n)
2668
+ return 1;
2669
+ if (n < 0n)
2670
+ n = -n;
2671
+ let count = 0;
2672
+ const big15 = 1000000000000000n;
2673
+ while (n >= big15) {
2674
+ n /= big15;
2675
+ count += 15;
2676
+ }
2677
+ let r = Number(n);
2678
+ while (r >= 1) {
2679
+ r /= 10;
2680
+ count++;
2681
+ }
2682
+ return count;
2683
+ }
2684
+ var TEN_BIGINT = 10n;
2685
+ function bigintPow10(n) {
2686
+ if (n <= 0)
2687
+ return 1n;
2688
+ let result = 1n;
2689
+ let base = TEN_BIGINT;
2690
+ let exp = n;
2691
+ while (exp > 0) {
2692
+ if (exp & 1)
2693
+ result *= base;
2694
+ base *= base;
2695
+ exp >>= 1;
2895
2696
  }
2896
- x = taylorSeries(Ctor, 1, x.times(n), new Ctor(1), true);
2897
- var cosh2_x, i = k, d8 = new Ctor(8);
2898
- for (; i--; ) {
2899
- cosh2_x = x.times(x);
2900
- x = one.minus(cosh2_x.times(d8.minus(cosh2_x.times(d8))));
2901
- }
2902
- return finalise(x, Ctor.precision = pr, Ctor.rounding = rm, true);
2903
- };
2904
- P.hyperbolicSine = P.sinh = function() {
2905
- var k, pr, rm, len, x = this, Ctor = x.constructor;
2906
- if (!x.isFinite() || x.isZero())
2907
- return new Ctor(x);
2908
- pr = Ctor.precision;
2909
- rm = Ctor.rounding;
2910
- Ctor.precision = pr + Math.max(x.e, x.sd()) + 4;
2911
- Ctor.rounding = 1;
2912
- len = x.d.length;
2913
- if (len < 3) {
2914
- x = taylorSeries(Ctor, 2, x, x, true);
2915
- } else {
2916
- k = 1.4 * Math.sqrt(len);
2917
- k = k > 16 ? 16 : k | 0;
2918
- x = x.times(1 / tinyPow(5, k));
2919
- x = taylorSeries(Ctor, 2, x, x, true);
2920
- var sinh2_x, d5 = new Ctor(5), d16 = new Ctor(16), d20 = new Ctor(20);
2921
- for (; k--; ) {
2922
- sinh2_x = x.times(x);
2923
- x = x.times(d5.plus(sinh2_x.times(d16.times(sinh2_x).plus(d20))));
2924
- }
2925
- }
2926
- Ctor.precision = pr;
2927
- Ctor.rounding = rm;
2928
- return finalise(x, pr, rm, true);
2929
- };
2930
- P.hyperbolicTangent = P.tanh = function() {
2931
- var pr, rm, x = this, Ctor = x.constructor;
2932
- if (!x.isFinite())
2933
- return new Ctor(x.s);
2934
- if (x.isZero())
2935
- return new Ctor(x);
2936
- pr = Ctor.precision;
2937
- rm = Ctor.rounding;
2938
- Ctor.precision = pr + 7;
2939
- Ctor.rounding = 1;
2940
- return divide(x.sinh(), x.cosh(), Ctor.precision = pr, Ctor.rounding = rm);
2941
- };
2942
- P.inverseCosine = P.acos = function() {
2943
- var x = this, Ctor = x.constructor, k = x.abs().cmp(1), pr = Ctor.precision, rm = Ctor.rounding;
2944
- if (k !== -1) {
2945
- return k === 0 ? x.isNeg() ? getPi(Ctor, pr, rm) : new Ctor(0) : new Ctor(NaN);
2946
- }
2947
- if (x.isZero())
2948
- return getPi(Ctor, pr + 4, rm).times(0.5);
2949
- Ctor.precision = pr + 6;
2950
- Ctor.rounding = 1;
2951
- x = new Ctor(1).minus(x).div(x.plus(1)).sqrt().atan();
2952
- Ctor.precision = pr;
2953
- Ctor.rounding = rm;
2954
- return x.times(2);
2955
- };
2956
- P.inverseHyperbolicCosine = P.acosh = function() {
2957
- var pr, rm, x = this, Ctor = x.constructor;
2958
- if (x.lte(1))
2959
- return new Ctor(x.eq(1) ? 0 : NaN);
2960
- if (!x.isFinite())
2961
- return new Ctor(x);
2962
- pr = Ctor.precision;
2963
- rm = Ctor.rounding;
2964
- Ctor.precision = pr + Math.max(Math.abs(x.e), x.sd()) + 4;
2965
- Ctor.rounding = 1;
2966
- external = false;
2967
- x = x.times(x).minus(1).sqrt().plus(x);
2968
- external = true;
2969
- Ctor.precision = pr;
2970
- Ctor.rounding = rm;
2971
- return x.ln();
2972
- };
2973
- P.inverseHyperbolicSine = P.asinh = function() {
2974
- var pr, rm, x = this, Ctor = x.constructor;
2975
- if (!x.isFinite() || x.isZero())
2976
- return new Ctor(x);
2977
- pr = Ctor.precision;
2978
- rm = Ctor.rounding;
2979
- Ctor.precision = pr + 2 * Math.max(Math.abs(x.e), x.sd()) + 6;
2980
- Ctor.rounding = 1;
2981
- external = false;
2982
- x = x.times(x).plus(1).sqrt().plus(x);
2983
- external = true;
2984
- Ctor.precision = pr;
2985
- Ctor.rounding = rm;
2986
- return x.ln();
2987
- };
2988
- P.inverseHyperbolicTangent = P.atanh = function() {
2989
- var pr, rm, wpr, xsd, x = this, Ctor = x.constructor;
2990
- if (!x.isFinite())
2991
- return new Ctor(NaN);
2992
- if (x.e >= 0)
2993
- return new Ctor(x.abs().eq(1) ? x.s / 0 : x.isZero() ? x : NaN);
2994
- pr = Ctor.precision;
2995
- rm = Ctor.rounding;
2996
- xsd = x.sd();
2997
- if (Math.max(xsd, pr) < 2 * -x.e - 1)
2998
- return finalise(new Ctor(x), pr, rm, true);
2999
- Ctor.precision = wpr = xsd - x.e;
3000
- x = divide(x.plus(1), new Ctor(1).minus(x), wpr + pr, 1);
3001
- Ctor.precision = pr + 4;
3002
- Ctor.rounding = 1;
3003
- x = x.ln();
3004
- Ctor.precision = pr;
3005
- Ctor.rounding = rm;
3006
- return x.times(0.5);
3007
- };
3008
- P.inverseSine = P.asin = function() {
3009
- var halfPi, k, pr, rm, x = this, Ctor = x.constructor;
3010
- if (x.isZero())
3011
- return new Ctor(x);
3012
- k = x.abs().cmp(1);
3013
- pr = Ctor.precision;
3014
- rm = Ctor.rounding;
3015
- if (k !== -1) {
3016
- if (k === 0) {
3017
- halfPi = getPi(Ctor, pr + 4, rm).times(0.5);
3018
- halfPi.s = x.s;
3019
- return halfPi;
3020
- }
3021
- return new Ctor(NaN);
3022
- }
3023
- Ctor.precision = pr + 6;
3024
- Ctor.rounding = 1;
3025
- x = x.div(new Ctor(1).minus(x.times(x)).sqrt().plus(1)).atan();
3026
- Ctor.precision = pr;
3027
- Ctor.rounding = rm;
3028
- return x.times(2);
3029
- };
3030
- P.inverseTangent = P.atan = function() {
3031
- var i, j, k, n, px, t, r, wpr, x2, x = this, Ctor = x.constructor, pr = Ctor.precision, rm = Ctor.rounding;
3032
- if (!x.isFinite()) {
3033
- if (!x.s)
3034
- return new Ctor(NaN);
3035
- if (pr + 4 <= PI_PRECISION) {
3036
- r = getPi(Ctor, pr + 4, rm).times(0.5);
3037
- r.s = x.s;
3038
- return r;
3039
- }
3040
- } else if (x.isZero()) {
3041
- return new Ctor(x);
3042
- } else if (x.abs().eq(1) && pr + 4 <= PI_PRECISION) {
3043
- r = getPi(Ctor, pr + 4, rm).times(0.25);
3044
- r.s = x.s;
3045
- return r;
3046
- }
3047
- Ctor.precision = wpr = pr + 10;
3048
- Ctor.rounding = 1;
3049
- k = Math.min(28, wpr / LOG_BASE + 2 | 0);
3050
- for (i = k; i; --i)
3051
- x = x.div(x.times(x).plus(1).sqrt().plus(1));
3052
- external = false;
3053
- j = Math.ceil(wpr / LOG_BASE);
3054
- n = 1;
3055
- x2 = x.times(x);
3056
- r = new Ctor(x);
3057
- px = x;
3058
- for (; i !== -1; ) {
3059
- px = px.times(x2);
3060
- t = r.minus(px.div(n += 2));
3061
- px = px.times(x2);
3062
- r = t.plus(px.div(n += 2));
3063
- if (r.d[j] !== void 0)
3064
- for (i = j; r.d[i] === t.d[i] && i--; )
3065
- ;
3066
- }
3067
- if (k)
3068
- r = r.times(2 << k - 1);
3069
- external = true;
3070
- return finalise(r, Ctor.precision = pr, Ctor.rounding = rm, true);
3071
- };
3072
- P.isFinite = function() {
3073
- return !!this.d;
3074
- };
3075
- P.isInteger = P.isInt = function() {
3076
- return !!this.d && mathfloor(this.e / LOG_BASE) > this.d.length - 2;
3077
- };
3078
- P.isNaN = function() {
3079
- return !this.s;
3080
- };
3081
- P.isNegative = P.isNeg = function() {
3082
- return this.s < 0;
3083
- };
3084
- P.isPositive = P.isPos = function() {
3085
- return this.s > 0;
3086
- };
3087
- P.isZero = function() {
3088
- return !!this.d && this.d[0] === 0;
3089
- };
3090
- P.lessThan = P.lt = function(y) {
3091
- return this.cmp(y) < 0;
3092
- };
3093
- P.lessThanOrEqualTo = P.lte = function(y) {
3094
- return this.cmp(y) < 1;
3095
- };
3096
- P.logarithm = P.log = function(base) {
3097
- var isBase10, d, denominator, k, inf, num, sd, r, arg = this, Ctor = arg.constructor, pr = Ctor.precision, rm = Ctor.rounding, guard = 5;
3098
- if (base == null) {
3099
- base = new Ctor(10);
3100
- isBase10 = true;
3101
- } else {
3102
- base = new Ctor(base);
3103
- d = base.d;
3104
- if (base.s < 0 || !d || !d[0] || base.eq(1))
3105
- return new Ctor(NaN);
3106
- isBase10 = base.eq(10);
3107
- }
3108
- d = arg.d;
3109
- if (arg.s < 0 || !d || !d[0] || arg.eq(1)) {
3110
- return new Ctor(d && !d[0] ? -1 / 0 : arg.s != 1 ? NaN : d ? 0 : 1 / 0);
3111
- }
3112
- if (isBase10) {
3113
- if (d.length > 1) {
3114
- inf = true;
3115
- } else {
3116
- for (k = d[0]; k % 10 === 0; )
3117
- k /= 10;
3118
- inf = k !== 1;
3119
- }
3120
- }
3121
- external = false;
3122
- sd = pr + guard;
3123
- num = naturalLogarithm(arg, sd);
3124
- denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
3125
- r = divide(num, denominator, sd, 1);
3126
- if (checkRoundingDigits(r.d, k = pr, rm)) {
3127
- do {
3128
- sd += 10;
3129
- num = naturalLogarithm(arg, sd);
3130
- denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
3131
- r = divide(num, denominator, sd, 1);
3132
- if (!inf) {
3133
- if (+digitsToString(r.d).slice(k + 1, k + 15) + 1 == 1e14) {
3134
- r = finalise(r, pr + 1, 0);
3135
- }
3136
- break;
3137
- }
3138
- } while (checkRoundingDigits(r.d, k += 10, rm));
3139
- }
3140
- external = true;
3141
- return finalise(r, pr, rm);
3142
- };
3143
- P.minus = P.sub = function(y) {
3144
- var d, e, i, j, k, len, pr, rm, xd, xe, xLTy, yd, x = this, Ctor = x.constructor;
3145
- y = new Ctor(y);
3146
- if (!x.d || !y.d) {
3147
- if (!x.s || !y.s)
3148
- y = new Ctor(NaN);
3149
- else if (x.d)
3150
- y.s = -y.s;
3151
- else
3152
- y = new Ctor(y.d || x.s !== y.s ? x : NaN);
3153
- return y;
3154
- }
3155
- if (x.s != y.s) {
3156
- y.s = -y.s;
3157
- return x.plus(y);
3158
- }
3159
- xd = x.d;
3160
- yd = y.d;
3161
- pr = Ctor.precision;
3162
- rm = Ctor.rounding;
3163
- if (!xd[0] || !yd[0]) {
3164
- if (yd[0])
3165
- y.s = -y.s;
3166
- else if (xd[0])
3167
- y = new Ctor(x);
3168
- else
3169
- return new Ctor(rm === 3 ? -0 : 0);
3170
- return external ? finalise(y, pr, rm) : y;
3171
- }
3172
- e = mathfloor(y.e / LOG_BASE);
3173
- xe = mathfloor(x.e / LOG_BASE);
3174
- xd = xd.slice();
3175
- k = xe - e;
3176
- if (k) {
3177
- xLTy = k < 0;
3178
- if (xLTy) {
3179
- d = xd;
3180
- k = -k;
3181
- len = yd.length;
3182
- } else {
3183
- d = yd;
3184
- e = xe;
3185
- len = xd.length;
3186
- }
3187
- i = Math.max(Math.ceil(pr / LOG_BASE), len) + 2;
3188
- if (k > i) {
3189
- k = i;
3190
- d.length = 1;
3191
- }
3192
- d.reverse();
3193
- for (i = k; i--; )
3194
- d.push(0);
3195
- d.reverse();
3196
- } else {
3197
- i = xd.length;
3198
- len = yd.length;
3199
- xLTy = i < len;
3200
- if (xLTy)
3201
- len = i;
3202
- for (i = 0; i < len; i++) {
3203
- if (xd[i] != yd[i]) {
3204
- xLTy = xd[i] < yd[i];
3205
- break;
3206
- }
3207
- }
3208
- k = 0;
3209
- }
3210
- if (xLTy) {
3211
- d = xd;
3212
- xd = yd;
3213
- yd = d;
3214
- y.s = -y.s;
3215
- }
3216
- len = xd.length;
3217
- for (i = yd.length - len; i > 0; --i)
3218
- xd[len++] = 0;
3219
- for (i = yd.length; i > k; ) {
3220
- if (xd[--i] < yd[i]) {
3221
- for (j = i; j && xd[--j] === 0; )
3222
- xd[j] = BASE - 1;
3223
- --xd[j];
3224
- xd[i] += BASE;
3225
- }
3226
- xd[i] -= yd[i];
3227
- }
3228
- for (; xd[--len] === 0; )
3229
- xd.pop();
3230
- for (; xd[0] === 0; xd.shift())
3231
- --e;
3232
- if (!xd[0])
3233
- return new Ctor(rm === 3 ? -0 : 0);
3234
- y.d = xd;
3235
- y.e = getBase10Exponent(xd, e);
3236
- return external ? finalise(y, pr, rm) : y;
3237
- };
3238
- P.modulo = P.mod = function(y) {
3239
- var q, x = this, Ctor = x.constructor;
3240
- y = new Ctor(y);
3241
- if (!x.d || !y.s || y.d && !y.d[0])
3242
- return new Ctor(NaN);
3243
- if (!y.d || x.d && !x.d[0]) {
3244
- return finalise(new Ctor(x), Ctor.precision, Ctor.rounding);
3245
- }
3246
- external = false;
3247
- if (Ctor.modulo == 9) {
3248
- q = divide(x, y.abs(), 0, 3, 1);
3249
- q.s *= y.s;
3250
- } else {
3251
- q = divide(x, y, 0, Ctor.modulo, 1);
3252
- }
3253
- q = q.times(y);
3254
- external = true;
3255
- return x.minus(q);
3256
- };
3257
- P.naturalExponential = P.exp = function() {
3258
- return naturalExponential(this);
3259
- };
3260
- P.naturalLogarithm = P.ln = function() {
3261
- return naturalLogarithm(this);
3262
- };
3263
- P.negated = P.neg = function() {
3264
- var x = new this.constructor(this);
3265
- x.s = -x.s;
3266
- return finalise(x);
3267
- };
3268
- P.plus = P.add = function(y) {
3269
- var carry, d, e, i, k, len, pr, rm, xd, yd, x = this, Ctor = x.constructor;
3270
- y = new Ctor(y);
3271
- if (!x.d || !y.d) {
3272
- if (!x.s || !y.s)
3273
- y = new Ctor(NaN);
3274
- else if (!x.d)
3275
- y = new Ctor(y.d || x.s === y.s ? x : NaN);
3276
- return y;
3277
- }
3278
- if (x.s != y.s) {
3279
- y.s = -y.s;
3280
- return x.minus(y);
3281
- }
3282
- xd = x.d;
3283
- yd = y.d;
3284
- pr = Ctor.precision;
3285
- rm = Ctor.rounding;
3286
- if (!xd[0] || !yd[0]) {
3287
- if (!yd[0])
3288
- y = new Ctor(x);
3289
- return external ? finalise(y, pr, rm) : y;
3290
- }
3291
- k = mathfloor(x.e / LOG_BASE);
3292
- e = mathfloor(y.e / LOG_BASE);
3293
- xd = xd.slice();
3294
- i = k - e;
3295
- if (i) {
3296
- if (i < 0) {
3297
- d = xd;
3298
- i = -i;
3299
- len = yd.length;
3300
- } else {
3301
- d = yd;
3302
- e = k;
3303
- len = xd.length;
3304
- }
3305
- k = Math.ceil(pr / LOG_BASE);
3306
- len = k > len ? k + 1 : len + 1;
3307
- if (i > len) {
3308
- i = len;
3309
- d.length = 1;
3310
- }
3311
- d.reverse();
3312
- for (; i--; )
3313
- d.push(0);
3314
- d.reverse();
3315
- }
3316
- len = xd.length;
3317
- i = yd.length;
3318
- if (len - i < 0) {
3319
- i = len;
3320
- d = yd;
3321
- yd = xd;
3322
- xd = d;
3323
- }
3324
- for (carry = 0; i; ) {
3325
- carry = (xd[--i] = xd[i] + yd[i] + carry) / BASE | 0;
3326
- xd[i] %= BASE;
3327
- }
3328
- if (carry) {
3329
- xd.unshift(carry);
3330
- ++e;
3331
- }
3332
- for (len = xd.length; xd[--len] == 0; )
3333
- xd.pop();
3334
- y.d = xd;
3335
- y.e = getBase10Exponent(xd, e);
3336
- return external ? finalise(y, pr, rm) : y;
3337
- };
3338
- P.precision = P.sd = function(z) {
3339
- var k, x = this;
3340
- if (z !== void 0 && z !== !!z && z !== 1 && z !== 0)
3341
- throw Error(invalidArgument + z);
3342
- if (x.d) {
3343
- k = getPrecision(x.d);
3344
- if (z && x.e + 1 > k)
3345
- k = x.e + 1;
3346
- } else {
3347
- k = NaN;
3348
- }
3349
- return k;
3350
- };
3351
- P.round = function() {
3352
- var x = this, Ctor = x.constructor;
3353
- return finalise(new Ctor(x), x.e + 1, Ctor.rounding);
3354
- };
3355
- P.sine = P.sin = function() {
3356
- var pr, rm, x = this, Ctor = x.constructor;
3357
- if (!x.isFinite())
3358
- return new Ctor(NaN);
3359
- if (x.isZero())
3360
- return new Ctor(x);
3361
- pr = Ctor.precision;
3362
- rm = Ctor.rounding;
3363
- Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
3364
- Ctor.rounding = 1;
3365
- x = sine(Ctor, toLessThanHalfPi(Ctor, x));
3366
- Ctor.precision = pr;
3367
- Ctor.rounding = rm;
3368
- return finalise(quadrant > 2 ? x.neg() : x, pr, rm, true);
3369
- };
3370
- P.squareRoot = P.sqrt = function() {
3371
- var m, n, sd, r, rep, t, x = this, d = x.d, e = x.e, s = x.s, Ctor = x.constructor;
3372
- if (s !== 1 || !d || !d[0]) {
3373
- return new Ctor(!s || s < 0 && (!d || d[0]) ? NaN : d ? x : 1 / 0);
3374
- }
3375
- external = false;
3376
- s = Math.sqrt(+x);
3377
- if (s == 0 || s == 1 / 0) {
3378
- n = digitsToString(d);
3379
- if ((n.length + e) % 2 == 0)
3380
- n += "0";
3381
- s = Math.sqrt(n);
3382
- e = mathfloor((e + 1) / 2) - (e < 0 || e % 2);
3383
- if (s == 1 / 0) {
3384
- n = "5e" + e;
3385
- } else {
3386
- n = s.toExponential();
3387
- n = n.slice(0, n.indexOf("e") + 1) + e;
3388
- }
3389
- r = new Ctor(n);
3390
- } else {
3391
- r = new Ctor(s.toString());
3392
- }
3393
- sd = (e = Ctor.precision) + 3;
3394
- for (; ; ) {
3395
- t = r;
3396
- r = t.plus(divide(x, t, sd + 2, 1)).times(0.5);
3397
- if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
3398
- n = n.slice(sd - 3, sd + 1);
3399
- if (n == "9999" || !rep && n == "4999") {
3400
- if (!rep) {
3401
- finalise(t, e + 1, 0);
3402
- if (t.times(t).eq(x)) {
3403
- r = t;
3404
- break;
3405
- }
3406
- }
3407
- sd += 4;
3408
- rep = 1;
3409
- } else {
3410
- if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
3411
- finalise(r, e + 1, 1);
3412
- m = !r.times(r).eq(x);
3413
- }
3414
- break;
3415
- }
3416
- }
3417
- }
3418
- external = true;
3419
- return finalise(r, e, Ctor.rounding, m);
3420
- };
3421
- P.tangent = P.tan = function() {
3422
- var pr, rm, x = this, Ctor = x.constructor;
3423
- if (!x.isFinite())
3424
- return new Ctor(NaN);
3425
- if (x.isZero())
3426
- return new Ctor(x);
3427
- pr = Ctor.precision;
3428
- rm = Ctor.rounding;
3429
- Ctor.precision = pr + 10;
3430
- Ctor.rounding = 1;
3431
- x = x.sin();
3432
- x.s = 1;
3433
- x = divide(x, new Ctor(1).minus(x.times(x)).sqrt(), pr + 10, 0);
3434
- Ctor.precision = pr;
3435
- Ctor.rounding = rm;
3436
- return finalise(quadrant == 2 || quadrant == 4 ? x.neg() : x, pr, rm, true);
3437
- };
3438
- P.times = P.mul = function(y) {
3439
- var carry, e, i, k, r, rL, t, xdL, ydL, x = this, Ctor = x.constructor, xd = x.d, yd = (y = new Ctor(y)).d;
3440
- y.s *= x.s;
3441
- if (!xd || !xd[0] || !yd || !yd[0]) {
3442
- return new Ctor(!y.s || xd && !xd[0] && !yd || yd && !yd[0] && !xd ? NaN : !xd || !yd ? y.s / 0 : y.s * 0);
3443
- }
3444
- e = mathfloor(x.e / LOG_BASE) + mathfloor(y.e / LOG_BASE);
3445
- xdL = xd.length;
3446
- ydL = yd.length;
3447
- if (xdL < ydL) {
3448
- r = xd;
3449
- xd = yd;
3450
- yd = r;
3451
- rL = xdL;
3452
- xdL = ydL;
3453
- ydL = rL;
3454
- }
3455
- r = [];
3456
- rL = xdL + ydL;
3457
- for (i = rL; i--; )
3458
- r.push(0);
3459
- for (i = ydL; --i >= 0; ) {
3460
- carry = 0;
3461
- for (k = xdL + i; k > i; ) {
3462
- t = r[k] + yd[i] * xd[k - i - 1] + carry;
3463
- r[k--] = t % BASE | 0;
3464
- carry = t / BASE | 0;
3465
- }
3466
- r[k] = (r[k] + carry) % BASE | 0;
3467
- }
3468
- for (; !r[--rL]; )
3469
- r.pop();
3470
- if (carry)
3471
- ++e;
3472
- else
3473
- r.shift();
3474
- y.d = r;
3475
- y.e = getBase10Exponent(r, e);
3476
- return external ? finalise(y, Ctor.precision, Ctor.rounding) : y;
3477
- };
3478
- P.toBinary = function(sd, rm) {
3479
- return toStringBinary(this, 2, sd, rm);
3480
- };
3481
- P.toDecimalPlaces = P.toDP = function(dp, rm) {
3482
- var x = this, Ctor = x.constructor;
3483
- x = new Ctor(x);
3484
- if (dp === void 0)
3485
- return x;
3486
- checkInt32(dp, 0, MAX_DIGITS);
3487
- if (rm === void 0)
3488
- rm = Ctor.rounding;
3489
- else
3490
- checkInt32(rm, 0, 8);
3491
- return finalise(x, dp + x.e + 1, rm);
3492
- };
3493
- P.toExponential = function(dp, rm) {
3494
- var str, x = this, Ctor = x.constructor;
3495
- if (dp === void 0) {
3496
- str = finiteToString(x, true);
3497
- } else {
3498
- checkInt32(dp, 0, MAX_DIGITS);
3499
- if (rm === void 0)
3500
- rm = Ctor.rounding;
3501
- else
3502
- checkInt32(rm, 0, 8);
3503
- x = finalise(new Ctor(x), dp + 1, rm);
3504
- str = finiteToString(x, true, dp + 1);
3505
- }
3506
- return x.isNeg() && !x.isZero() ? "-" + str : str;
3507
- };
3508
- P.toFixed = function(dp, rm) {
3509
- var str, y, x = this, Ctor = x.constructor;
3510
- if (dp === void 0) {
3511
- str = finiteToString(x);
3512
- } else {
3513
- checkInt32(dp, 0, MAX_DIGITS);
3514
- if (rm === void 0)
3515
- rm = Ctor.rounding;
3516
- else
3517
- checkInt32(rm, 0, 8);
3518
- y = finalise(new Ctor(x), dp + x.e + 1, rm);
3519
- str = finiteToString(y, false, dp + y.e + 1);
3520
- }
3521
- return x.isNeg() && !x.isZero() ? "-" + str : str;
3522
- };
3523
- P.toFraction = function(maxD) {
3524
- var d, d0, d1, d2, e, k, n, n0, n1, pr, q, r, x = this, xd = x.d, Ctor = x.constructor;
3525
- if (!xd)
3526
- return new Ctor(x);
3527
- n1 = d0 = new Ctor(1);
3528
- d1 = n0 = new Ctor(0);
3529
- d = new Ctor(d1);
3530
- e = d.e = getPrecision(xd) - x.e - 1;
3531
- k = e % LOG_BASE;
3532
- d.d[0] = mathpow(10, k < 0 ? LOG_BASE + k : k);
3533
- if (maxD == null) {
3534
- maxD = e > 0 ? d : n1;
3535
- } else {
3536
- n = new Ctor(maxD);
3537
- if (!n.isInt() || n.lt(n1))
3538
- throw Error(invalidArgument + n);
3539
- maxD = n.gt(d) ? e > 0 ? d : n1 : n;
3540
- }
3541
- external = false;
3542
- n = new Ctor(digitsToString(xd));
3543
- pr = Ctor.precision;
3544
- Ctor.precision = e = xd.length * LOG_BASE * 2;
3545
- for (; ; ) {
3546
- q = divide(n, d, 0, 1, 1);
3547
- d2 = d0.plus(q.times(d1));
3548
- if (d2.cmp(maxD) == 1)
3549
- break;
3550
- d0 = d1;
3551
- d1 = d2;
3552
- d2 = n1;
3553
- n1 = n0.plus(q.times(d2));
3554
- n0 = d2;
3555
- d2 = d;
3556
- d = n.minus(q.times(d2));
3557
- n = d2;
3558
- }
3559
- d2 = divide(maxD.minus(d0), d1, 0, 1, 1);
3560
- n0 = n0.plus(d2.times(n1));
3561
- d0 = d0.plus(d2.times(d1));
3562
- n0.s = n1.s = x.s;
3563
- r = divide(n1, d1, e, 1).minus(x).abs().cmp(divide(n0, d0, e, 1).minus(x).abs()) < 1 ? [n1, d1] : [n0, d0];
3564
- Ctor.precision = pr;
3565
- external = true;
3566
- return r;
3567
- };
3568
- P.toHexadecimal = P.toHex = function(sd, rm) {
3569
- return toStringBinary(this, 16, sd, rm);
3570
- };
3571
- P.toNearest = function(y, rm) {
3572
- var x = this, Ctor = x.constructor;
3573
- x = new Ctor(x);
3574
- if (y == null) {
3575
- if (!x.d)
3576
- return x;
3577
- y = new Ctor(1);
3578
- rm = Ctor.rounding;
3579
- } else {
3580
- y = new Ctor(y);
3581
- if (rm === void 0) {
3582
- rm = Ctor.rounding;
3583
- } else {
3584
- checkInt32(rm, 0, 8);
3585
- }
3586
- if (!x.d)
3587
- return y.s ? x : y;
3588
- if (!y.d) {
3589
- if (y.s)
3590
- y.s = x.s;
3591
- return y;
3592
- }
2697
+ return result;
2698
+ }
2699
+ function parseDecimalString(s) {
2700
+ s = s.trim();
2701
+ if (s === "NaN") {
2702
+ return {
2703
+ mantissa: 0n,
2704
+ exponent: 0,
2705
+ special: SpecialValue.NAN,
2706
+ negativeZero: false
2707
+ };
3593
2708
  }
3594
- if (y.d[0]) {
3595
- external = false;
3596
- x = divide(x, y, 0, rm, 1).times(y);
3597
- external = true;
3598
- finalise(x);
3599
- } else {
3600
- y.s = x.s;
3601
- x = y;
2709
+ if (s === "Infinity" || s === "+Infinity") {
2710
+ return {
2711
+ mantissa: 0n,
2712
+ exponent: 0,
2713
+ special: SpecialValue.POSITIVE_INFINITY,
2714
+ negativeZero: false
2715
+ };
3602
2716
  }
3603
- return x;
3604
- };
3605
- P.toNumber = function() {
3606
- return +this;
3607
- };
3608
- P.toOctal = function(sd, rm) {
3609
- return toStringBinary(this, 8, sd, rm);
3610
- };
3611
- P.toPower = P.pow = function(y) {
3612
- var e, k, pr, r, rm, s, x = this, Ctor = x.constructor, yn = +(y = new Ctor(y));
3613
- if (!x.d || !y.d || !x.d[0] || !y.d[0])
3614
- return new Ctor(mathpow(+x, yn));
3615
- x = new Ctor(x);
3616
- if (x.eq(1))
3617
- return x;
3618
- pr = Ctor.precision;
3619
- rm = Ctor.rounding;
3620
- if (y.eq(1))
3621
- return finalise(x, pr, rm);
3622
- e = mathfloor(y.e / LOG_BASE);
3623
- if (e >= y.d.length - 1 && (k = yn < 0 ? -yn : yn) <= MAX_SAFE_INTEGER) {
3624
- r = intPow(Ctor, x, k, pr);
3625
- return y.s < 0 ? new Ctor(1).div(r) : finalise(r, pr, rm);
3626
- }
3627
- s = x.s;
3628
- if (s < 0) {
3629
- if (e < y.d.length - 1)
3630
- return new Ctor(NaN);
3631
- if ((y.d[e] & 1) == 0)
3632
- s = 1;
3633
- if (x.e == 0 && x.d[0] == 1 && x.d.length == 1) {
3634
- x.s = s;
3635
- return x;
3636
- }
3637
- }
3638
- k = mathpow(+x, yn);
3639
- e = k == 0 || !isFinite(k) ? mathfloor(yn * (Math.log("0." + digitsToString(x.d)) / Math.LN10 + x.e + 1)) : new Ctor(k + "").e;
3640
- if (e > Ctor.maxE + 1 || e < Ctor.minE - 1)
3641
- return new Ctor(e > 0 ? s / 0 : 0);
3642
- external = false;
3643
- Ctor.rounding = x.s = 1;
3644
- k = Math.min(12, (e + "").length);
3645
- r = naturalExponential(y.times(naturalLogarithm(x, pr + k)), pr);
3646
- if (r.d) {
3647
- r = finalise(r, pr + 5, 1);
3648
- if (checkRoundingDigits(r.d, pr, rm)) {
3649
- e = pr + 10;
3650
- r = finalise(naturalExponential(y.times(naturalLogarithm(x, e + k)), e), e + 5, 1);
3651
- if (+digitsToString(r.d).slice(pr + 1, pr + 15) + 1 == 1e14) {
3652
- r = finalise(r, pr + 1, 0);
3653
- }
3654
- }
2717
+ if (s === "-Infinity") {
2718
+ return {
2719
+ mantissa: 0n,
2720
+ exponent: 0,
2721
+ special: SpecialValue.NEGATIVE_INFINITY,
2722
+ negativeZero: false
2723
+ };
3655
2724
  }
3656
- r.s = s;
3657
- external = true;
3658
- Ctor.rounding = rm;
3659
- return finalise(r, pr, rm);
3660
- };
3661
- P.toPrecision = function(sd, rm) {
3662
- var str, x = this, Ctor = x.constructor;
3663
- if (sd === void 0) {
3664
- str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
2725
+ let negative = false;
2726
+ let idx = 0;
2727
+ if (s[idx] === "-") {
2728
+ negative = true;
2729
+ idx++;
2730
+ } else if (s[idx] === "+") {
2731
+ idx++;
2732
+ }
2733
+ let eIdx = s.indexOf("e", idx);
2734
+ if (eIdx === -1)
2735
+ eIdx = s.indexOf("E", idx);
2736
+ let sciExp = 0;
2737
+ let numPart;
2738
+ if (eIdx !== -1) {
2739
+ sciExp = parseInt(s.substring(eIdx + 1), 10);
2740
+ numPart = s.substring(idx, eIdx);
3665
2741
  } else {
3666
- checkInt32(sd, 1, MAX_DIGITS);
3667
- if (rm === void 0)
3668
- rm = Ctor.rounding;
3669
- else
3670
- checkInt32(rm, 0, 8);
3671
- x = finalise(new Ctor(x), sd, rm);
3672
- str = finiteToString(x, sd <= x.e || x.e <= Ctor.toExpNeg, sd);
3673
- }
3674
- return x.isNeg() && !x.isZero() ? "-" + str : str;
3675
- };
3676
- P.toSignificantDigits = P.toSD = function(sd, rm) {
3677
- var x = this, Ctor = x.constructor;
3678
- if (sd === void 0) {
3679
- sd = Ctor.precision;
3680
- rm = Ctor.rounding;
2742
+ numPart = s.substring(idx);
2743
+ }
2744
+ const dotIdx = numPart.indexOf(".");
2745
+ let intPart;
2746
+ let fracPart;
2747
+ if (dotIdx !== -1) {
2748
+ intPart = numPart.substring(0, dotIdx);
2749
+ fracPart = numPart.substring(dotIdx + 1);
3681
2750
  } else {
3682
- checkInt32(sd, 1, MAX_DIGITS);
3683
- if (rm === void 0)
3684
- rm = Ctor.rounding;
3685
- else
3686
- checkInt32(rm, 0, 8);
2751
+ intPart = numPart;
2752
+ fracPart = "";
3687
2753
  }
3688
- return finalise(new Ctor(x), sd, rm);
3689
- };
3690
- P.toString = function() {
3691
- var x = this, Ctor = x.constructor, str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
3692
- return x.isNeg() && !x.isZero() ? "-" + str : str;
3693
- };
3694
- P.truncated = P.trunc = function() {
3695
- return finalise(new this.constructor(this), this.e + 1, 1);
3696
- };
3697
- P.valueOf = P.toJSON = function() {
3698
- var x = this, Ctor = x.constructor, str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
3699
- return x.isNeg() ? "-" + str : str;
3700
- };
3701
- function digitsToString(d) {
3702
- var i, k, ws, indexOfLastWord = d.length - 1, str = "", w = d[0];
3703
- if (indexOfLastWord > 0) {
3704
- str += w;
3705
- for (i = 1; i < indexOfLastWord; i++) {
3706
- ws = d[i] + "";
3707
- k = LOG_BASE - ws.length;
3708
- if (k)
3709
- str += getZeroString(k);
3710
- str += ws;
3711
- }
3712
- w = d[i];
3713
- ws = w + "";
3714
- k = LOG_BASE - ws.length;
3715
- if (k)
3716
- str += getZeroString(k);
3717
- } else if (w === 0) {
3718
- return "0";
3719
- }
3720
- for (; w % 10 === 0; )
3721
- w /= 10;
3722
- return str + w;
3723
- }
3724
- function checkInt32(i, min2, max2) {
3725
- if (i !== ~~i || i < min2 || i > max2) {
3726
- throw Error(invalidArgument + i);
2754
+ const combined = intPart + fracPart;
2755
+ const exponent = sciExp - fracPart.length;
2756
+ if (combined === "" || combined === "0" || /^0+$/.test(combined)) {
2757
+ return {
2758
+ mantissa: 0n,
2759
+ exponent: 0,
2760
+ special: SpecialValue.NONE,
2761
+ negativeZero: negative
2762
+ };
3727
2763
  }
2764
+ let mantissa = BigInt(combined);
2765
+ if (negative)
2766
+ mantissa = -mantissa;
2767
+ const [normMantissa, normExponent] = removeTrailingZeros(mantissa, exponent);
2768
+ return {
2769
+ mantissa: normMantissa,
2770
+ exponent: normExponent,
2771
+ special: SpecialValue.NONE,
2772
+ negativeZero: false
2773
+ };
3728
2774
  }
3729
- function checkRoundingDigits(d, i, rm, repeating) {
3730
- var di, k, r, rd;
3731
- for (k = d[0]; k >= 10; k /= 10)
3732
- --i;
3733
- if (--i < 0) {
3734
- i += LOG_BASE;
3735
- di = 0;
3736
- } else {
3737
- di = Math.ceil((i + 1) / LOG_BASE);
3738
- i %= LOG_BASE;
3739
- }
3740
- k = mathpow(10, LOG_BASE - i);
3741
- rd = d[di] % k | 0;
3742
- if (repeating == null) {
3743
- if (i < 3) {
3744
- if (i == 0)
3745
- rd = rd / 100 | 0;
3746
- else if (i == 1)
3747
- rd = rd / 10 | 0;
3748
- r = rm < 4 && rd == 99999 || rm > 3 && rd == 49999 || rd == 5e4 || rd == 0;
3749
- } else {
3750
- 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;
3751
- }
3752
- } else {
3753
- if (i < 4) {
3754
- if (i == 0)
3755
- rd = rd / 1e3 | 0;
3756
- else if (i == 1)
3757
- rd = rd / 100 | 0;
3758
- else if (i == 2)
3759
- rd = rd / 10 | 0;
3760
- r = (repeating || rm < 4) && rd == 9999 || !repeating && rm > 3 && rd == 4999;
3761
- } else {
3762
- 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;
2775
+ var BigDecimal = class _BigDecimal {
2776
+ constructor(value) {
2777
+ __publicField(this, "_mantissa");
2778
+ __publicField(this, "_exponent");
2779
+ __publicField(this, "_special");
2780
+ __publicField(this, "_negativeZero");
2781
+ if (typeof value === "bigint") {
2782
+ const [m, e] = removeTrailingZeros(value, 0);
2783
+ this._mantissa = m;
2784
+ this._exponent = e;
2785
+ this._special = SpecialValue.NONE;
2786
+ this._negativeZero = false;
2787
+ return;
3763
2788
  }
3764
- }
3765
- return r;
3766
- }
3767
- function convertBase(str, baseIn, baseOut) {
3768
- var j, arr = [0], arrL, i = 0, strL = str.length;
3769
- for (; i < strL; ) {
3770
- for (arrL = arr.length; arrL--; )
3771
- arr[arrL] *= baseIn;
3772
- arr[0] += NUMERALS.indexOf(str.charAt(i++));
3773
- for (j = 0; j < arr.length; j++) {
3774
- if (arr[j] > baseOut - 1) {
3775
- if (arr[j + 1] === void 0)
3776
- arr[j + 1] = 0;
3777
- arr[j + 1] += arr[j] / baseOut | 0;
3778
- arr[j] %= baseOut;
2789
+ if (typeof value === "number") {
2790
+ if (Number.isNaN(value)) {
2791
+ this._mantissa = 0n;
2792
+ this._exponent = 0;
2793
+ this._special = SpecialValue.NAN;
2794
+ this._negativeZero = false;
2795
+ return;
3779
2796
  }
3780
- }
3781
- }
3782
- return arr.reverse();
3783
- }
3784
- function cosine(Ctor, x) {
3785
- var k, len, y;
3786
- if (x.isZero())
3787
- return x;
3788
- len = x.d.length;
3789
- if (len < 32) {
3790
- k = Math.ceil(len / 3);
3791
- y = (1 / tinyPow(4, k)).toString();
3792
- } else {
3793
- k = 16;
3794
- y = "2.3283064365386962890625e-10";
3795
- }
3796
- Ctor.precision += k;
3797
- x = taylorSeries(Ctor, 1, x.times(y), new Ctor(1));
3798
- for (var i = k; i--; ) {
3799
- var cos2x = x.times(x);
3800
- x = cos2x.times(cos2x).minus(cos2x).times(8).plus(1);
3801
- }
3802
- Ctor.precision -= k;
3803
- return x;
3804
- }
3805
- var divide = /* @__PURE__ */ function() {
3806
- function multiplyInteger(x, k, base) {
3807
- var temp, carry = 0, i = x.length;
3808
- for (x = x.slice(); i--; ) {
3809
- temp = x[i] * k + carry;
3810
- x[i] = temp % base | 0;
3811
- carry = temp / base | 0;
3812
- }
3813
- if (carry)
3814
- x.unshift(carry);
3815
- return x;
3816
- }
3817
- function compare(a, b, aL, bL) {
3818
- var i, r;
3819
- if (aL != bL) {
3820
- r = aL > bL ? 1 : -1;
3821
- } else {
3822
- for (i = r = 0; i < aL; i++) {
3823
- if (a[i] != b[i]) {
3824
- r = a[i] > b[i] ? 1 : -1;
3825
- break;
3826
- }
2797
+ if (value === Infinity) {
2798
+ this._mantissa = 0n;
2799
+ this._exponent = 0;
2800
+ this._special = SpecialValue.POSITIVE_INFINITY;
2801
+ this._negativeZero = false;
2802
+ return;
3827
2803
  }
3828
- }
3829
- return r;
3830
- }
3831
- function subtract(a, b, aL, base) {
3832
- var i = 0;
3833
- for (; aL--; ) {
3834
- a[aL] -= i;
3835
- i = a[aL] < b[aL] ? 1 : 0;
3836
- a[aL] = i * base + a[aL] - b[aL];
3837
- }
3838
- for (; !a[0] && a.length > 1; )
3839
- a.shift();
3840
- }
3841
- return function(x, y, pr, rm, dp, base) {
3842
- 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;
3843
- if (!xd || !xd[0] || !yd || !yd[0]) {
3844
- return new Ctor(
3845
- // Return NaN if either NaN, or both Infinity or 0.
3846
- !x.s || !y.s || (xd ? yd && xd[0] == yd[0] : !yd) ? NaN : (
3847
- // Return ±0 if x is 0 or y is ±Infinity, or return ±Infinity as y is 0.
3848
- xd && xd[0] == 0 || !yd ? sign2 * 0 : sign2 / 0
3849
- )
3850
- );
3851
- }
3852
- if (base) {
3853
- logBase = 1;
3854
- e = x.e - y.e;
3855
- } else {
3856
- base = BASE;
3857
- logBase = LOG_BASE;
3858
- e = mathfloor(x.e / logBase) - mathfloor(y.e / logBase);
3859
- }
3860
- yL = yd.length;
3861
- xL = xd.length;
3862
- q = new Ctor(sign2);
3863
- qd = q.d = [];
3864
- for (i = 0; yd[i] == (xd[i] || 0); i++)
3865
- ;
3866
- if (yd[i] > (xd[i] || 0))
3867
- e--;
3868
- if (pr == null) {
3869
- sd = pr = Ctor.precision;
3870
- rm = Ctor.rounding;
3871
- } else if (dp) {
3872
- sd = pr + (x.e - y.e) + 1;
3873
- } else {
3874
- sd = pr;
3875
- }
3876
- if (sd < 0) {
3877
- qd.push(1);
3878
- more = true;
3879
- } else {
3880
- sd = sd / logBase + 2 | 0;
3881
- i = 0;
3882
- if (yL == 1) {
3883
- k = 0;
3884
- yd = yd[0];
3885
- sd++;
3886
- for (; (i < xL || k) && sd--; i++) {
3887
- t = k * base + (xd[i] || 0);
3888
- qd[i] = t / yd | 0;
3889
- k = t % yd | 0;
3890
- }
3891
- more = k || i < xL;
3892
- } else {
3893
- k = base / (yd[0] + 1) | 0;
3894
- if (k > 1) {
3895
- yd = multiplyInteger(yd, k, base);
3896
- xd = multiplyInteger(xd, k, base);
3897
- yL = yd.length;
3898
- xL = xd.length;
3899
- }
3900
- xi = yL;
3901
- rem = xd.slice(0, yL);
3902
- remL = rem.length;
3903
- for (; remL < yL; )
3904
- rem[remL++] = 0;
3905
- yz = yd.slice();
3906
- yz.unshift(0);
3907
- yd0 = yd[0];
3908
- if (yd[1] >= base / 2)
3909
- ++yd0;
3910
- do {
3911
- k = 0;
3912
- cmp = compare(yd, rem, yL, remL);
3913
- if (cmp < 0) {
3914
- rem0 = rem[0];
3915
- if (yL != remL)
3916
- rem0 = rem0 * base + (rem[1] || 0);
3917
- k = rem0 / yd0 | 0;
3918
- if (k > 1) {
3919
- if (k >= base)
3920
- k = base - 1;
3921
- prod = multiplyInteger(yd, k, base);
3922
- prodL = prod.length;
3923
- remL = rem.length;
3924
- cmp = compare(prod, rem, prodL, remL);
3925
- if (cmp == 1) {
3926
- k--;
3927
- subtract(prod, yL < prodL ? yz : yd, prodL, base);
3928
- }
3929
- } else {
3930
- if (k == 0)
3931
- cmp = k = 1;
3932
- prod = yd.slice();
3933
- }
3934
- prodL = prod.length;
3935
- if (prodL < remL)
3936
- prod.unshift(0);
3937
- subtract(rem, prod, remL, base);
3938
- if (cmp == -1) {
3939
- remL = rem.length;
3940
- cmp = compare(yd, rem, yL, remL);
3941
- if (cmp < 1) {
3942
- k++;
3943
- subtract(rem, yL < remL ? yz : yd, remL, base);
3944
- }
3945
- }
3946
- remL = rem.length;
3947
- } else if (cmp === 0) {
3948
- k++;
3949
- rem = [0];
3950
- }
3951
- qd[i++] = k;
3952
- if (cmp && rem[0]) {
3953
- rem[remL++] = xd[xi] || 0;
3954
- } else {
3955
- rem = [xd[xi]];
3956
- remL = 1;
3957
- }
3958
- } while ((xi++ < xL || rem[0] !== void 0) && sd--);
3959
- more = rem[0] !== void 0;
2804
+ if (value === -Infinity) {
2805
+ this._mantissa = 0n;
2806
+ this._exponent = 0;
2807
+ this._special = SpecialValue.NEGATIVE_INFINITY;
2808
+ this._negativeZero = false;
2809
+ return;
3960
2810
  }
3961
- if (!qd[0])
3962
- qd.shift();
3963
- }
3964
- if (logBase == 1) {
3965
- q.e = e;
3966
- inexact = more;
3967
- } else {
3968
- for (i = 1, k = qd[0]; k >= 10; k /= 10)
3969
- i++;
3970
- q.e = i + e * logBase - 1;
3971
- finalise(q, dp ? pr + q.e + 1 : pr, rm, more);
3972
- }
3973
- return q;
3974
- };
3975
- }();
3976
- function finalise(x, sd, rm, isTruncated) {
3977
- var digits, i, j, k, rd, roundUp, w, xd, xdi, Ctor = x.constructor;
3978
- out:
3979
- if (sd != null) {
3980
- xd = x.d;
3981
- if (!xd)
3982
- return x;
3983
- for (digits = 1, k = xd[0]; k >= 10; k /= 10)
3984
- digits++;
3985
- i = sd - digits;
3986
- if (i < 0) {
3987
- i += LOG_BASE;
3988
- j = sd;
3989
- w = xd[xdi = 0];
3990
- rd = w / mathpow(10, digits - j - 1) % 10 | 0;
3991
- } else {
3992
- xdi = Math.ceil((i + 1) / LOG_BASE);
3993
- k = xd.length;
3994
- if (xdi >= k) {
3995
- if (isTruncated) {
3996
- for (; k++ <= xdi; )
3997
- xd.push(0);
3998
- w = rd = 0;
3999
- digits = 1;
4000
- i %= LOG_BASE;
4001
- j = i - LOG_BASE + 1;
4002
- } else {
4003
- break out;
4004
- }
4005
- } else {
4006
- w = k = xd[xdi];
4007
- for (digits = 1; k >= 10; k /= 10)
4008
- digits++;
4009
- i %= LOG_BASE;
4010
- j = i - LOG_BASE + digits;
4011
- rd = j < 0 ? 0 : w / mathpow(10, digits - j - 1) % 10 | 0;
4012
- }
2811
+ if (value === 0) {
2812
+ this._mantissa = 0n;
2813
+ this._exponent = 0;
2814
+ this._special = SpecialValue.NONE;
2815
+ this._negativeZero = Object.is(value, -0);
2816
+ return;
4013
2817
  }
4014
- isTruncated = isTruncated || sd < 0 || xd[xdi + 1] !== void 0 || (j < 0 ? w : w % mathpow(10, digits - j - 1));
4015
- 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.
4016
- (i > 0 ? j > 0 ? w / mathpow(10, digits - j) : 0 : xd[xdi - 1]) % 10 & 1 || rm == (x.s < 0 ? 8 : 7));
4017
- if (sd < 1 || !xd[0]) {
4018
- xd.length = 0;
4019
- if (roundUp) {
4020
- sd -= x.e + 1;
4021
- xd[0] = mathpow(10, (LOG_BASE - sd % LOG_BASE) % LOG_BASE);
4022
- x.e = -sd || 0;
4023
- } else {
4024
- xd[0] = x.e = 0;
4025
- }
4026
- return x;
2818
+ value = String(value);
2819
+ }
2820
+ const parsed = parseDecimalString(value);
2821
+ this._mantissa = parsed.mantissa;
2822
+ this._exponent = parsed.exponent;
2823
+ this._special = parsed.special;
2824
+ this._negativeZero = parsed.negativeZero;
2825
+ }
2826
+ // Private constructor for internal use
2827
+ static _create(mantissa, exponent, special, negativeZero) {
2828
+ const bd = Object.create(_BigDecimal.prototype);
2829
+ bd._mantissa = mantissa;
2830
+ bd._exponent = exponent;
2831
+ bd._special = special;
2832
+ bd._negativeZero = negativeZero;
2833
+ return bd;
2834
+ }
2835
+ // Auto-coerce to BigDecimal for decimal.js compat
2836
+ static _coerce(v) {
2837
+ return v instanceof _BigDecimal ? v : new _BigDecimal(v);
2838
+ }
2839
+ // --- Arithmetic ---
2840
+ times(y) {
2841
+ const other = _BigDecimal._coerce(y);
2842
+ if (this._special || other._special) {
2843
+ return this._specialArith(other, "times");
2844
+ }
2845
+ if (this._mantissa === 0n || other._mantissa === 0n) {
2846
+ const negZero = this._isSignNegative() ? !other._isSignNegative() : other._isSignNegative();
2847
+ return _BigDecimal._create(0n, 0, SpecialValue.NONE, negZero);
2848
+ }
2849
+ const m = this._mantissa * other._mantissa;
2850
+ const e = this._exponent + other._exponent;
2851
+ const [nm, ne] = removeTrailingZeros(m, e);
2852
+ return _BigDecimal._create(nm, ne, SpecialValue.NONE, false);
2853
+ }
2854
+ div(y) {
2855
+ const other = _BigDecimal._coerce(y);
2856
+ if (this._special || other._special) {
2857
+ return this._specialArith(other, "div");
2858
+ }
2859
+ if (other._mantissa === 0n) {
2860
+ if (this._mantissa === 0n) {
2861
+ return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
4027
2862
  }
4028
- if (i == 0) {
4029
- xd.length = xdi;
4030
- k = 1;
4031
- xdi--;
4032
- } else {
4033
- xd.length = xdi + 1;
4034
- k = mathpow(10, LOG_BASE - i);
4035
- xd[xdi] = j > 0 ? (w / mathpow(10, digits - j) % mathpow(10, j) | 0) * k : 0;
2863
+ const neg = this._isSignNegative() !== other._isSignNegative();
2864
+ return _BigDecimal._create(0n, 0, neg ? SpecialValue.NEGATIVE_INFINITY : SpecialValue.POSITIVE_INFINITY, false);
2865
+ }
2866
+ if (this._mantissa === 0n) {
2867
+ const negZero = this._isSignNegative() !== other._isSignNegative();
2868
+ return _BigDecimal._create(0n, 0, SpecialValue.NONE, negZero);
2869
+ }
2870
+ const scaledNumerator = this._mantissa * bigintPow10(DIV_PRECISION);
2871
+ const quotient = scaledNumerator / other._mantissa;
2872
+ const newExponent = this._exponent - other._exponent - DIV_PRECISION;
2873
+ const [nm, ne] = removeTrailingZeros(quotient, newExponent);
2874
+ return _BigDecimal._create(nm, ne, SpecialValue.NONE, false);
2875
+ }
2876
+ plus(y) {
2877
+ const other = _BigDecimal._coerce(y);
2878
+ if (this._special || other._special) {
2879
+ return this._specialArith(other, "plus");
2880
+ }
2881
+ if (this._mantissa === 0n && other._mantissa === 0n) {
2882
+ const negZero = this._negativeZero && other._negativeZero;
2883
+ return _BigDecimal._create(0n, 0, SpecialValue.NONE, negZero);
2884
+ }
2885
+ if (this._mantissa === 0n)
2886
+ return other;
2887
+ if (other._mantissa === 0n)
2888
+ return this;
2889
+ let m1 = this._mantissa;
2890
+ let m2 = other._mantissa;
2891
+ const e1 = this._exponent;
2892
+ const e2 = other._exponent;
2893
+ const minE = Math.min(e1, e2);
2894
+ if (e1 > minE)
2895
+ m1 *= bigintPow10(e1 - minE);
2896
+ if (e2 > minE)
2897
+ m2 *= bigintPow10(e2 - minE);
2898
+ const sum = m1 + m2;
2899
+ if (sum === 0n) {
2900
+ return _BigDecimal._create(0n, 0, SpecialValue.NONE, false);
2901
+ }
2902
+ const [nm, ne] = removeTrailingZeros(sum, minE);
2903
+ return _BigDecimal._create(nm, ne, SpecialValue.NONE, false);
2904
+ }
2905
+ minus(y) {
2906
+ return this.plus(_BigDecimal._coerce(y).negated());
2907
+ }
2908
+ mod(y) {
2909
+ const other = _BigDecimal._coerce(y);
2910
+ if (this._special || other._special) {
2911
+ if (this._special === SpecialValue.NAN || other._special === SpecialValue.NAN) {
2912
+ return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
4036
2913
  }
4037
- if (roundUp) {
4038
- for (; ; ) {
4039
- if (xdi == 0) {
4040
- for (i = 1, j = xd[0]; j >= 10; j /= 10)
4041
- i++;
4042
- j = xd[0] += k;
4043
- for (k = 1; j >= 10; j /= 10)
4044
- k++;
4045
- if (i != k) {
4046
- x.e++;
4047
- if (xd[0] == BASE)
4048
- xd[0] = 1;
4049
- }
4050
- break;
4051
- } else {
4052
- xd[xdi] += k;
4053
- if (xd[xdi] != BASE)
4054
- break;
4055
- xd[xdi--] = 0;
4056
- k = 1;
4057
- }
4058
- }
2914
+ if (this._special === SpecialValue.POSITIVE_INFINITY || this._special === SpecialValue.NEGATIVE_INFINITY) {
2915
+ return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
2916
+ }
2917
+ if (other._special === SpecialValue.POSITIVE_INFINITY || other._special === SpecialValue.NEGATIVE_INFINITY) {
2918
+ return this;
4059
2919
  }
4060
- for (i = xd.length; xd[--i] === 0; )
4061
- xd.pop();
4062
2920
  }
4063
- if (external) {
4064
- if (x.e > Ctor.maxE) {
4065
- x.d = null;
4066
- x.e = NaN;
4067
- } else if (x.e < Ctor.minE) {
4068
- x.e = 0;
4069
- x.d = [0];
2921
+ if (other._mantissa === 0n) {
2922
+ return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
2923
+ }
2924
+ if (this._mantissa === 0n) {
2925
+ return this;
2926
+ }
2927
+ let m1 = this._mantissa;
2928
+ let m2 = other._mantissa;
2929
+ const e1 = this._exponent;
2930
+ const e2 = other._exponent;
2931
+ const minE = Math.min(e1, e2);
2932
+ if (e1 > minE)
2933
+ m1 *= bigintPow10(e1 - minE);
2934
+ if (e2 > minE)
2935
+ m2 *= bigintPow10(e2 - minE);
2936
+ const remainder = m1 % m2;
2937
+ if (remainder === 0n) {
2938
+ return _BigDecimal._create(0n, 0, SpecialValue.NONE, false);
2939
+ }
2940
+ const [nm, ne] = removeTrailingZeros(remainder, minE);
2941
+ return _BigDecimal._create(nm, ne, SpecialValue.NONE, false);
2942
+ }
2943
+ abs() {
2944
+ if (this._special === SpecialValue.NAN)
2945
+ return this;
2946
+ if (this._special === SpecialValue.NEGATIVE_INFINITY) {
2947
+ return _BigDecimal._create(0n, 0, SpecialValue.POSITIVE_INFINITY, false);
2948
+ }
2949
+ return _BigDecimal._create(bigintAbs(this._mantissa), this._exponent, this._special, false);
2950
+ }
2951
+ negated() {
2952
+ if (this._special === SpecialValue.NAN)
2953
+ return this;
2954
+ if (this._special === SpecialValue.POSITIVE_INFINITY) {
2955
+ return _BigDecimal._create(0n, 0, SpecialValue.NEGATIVE_INFINITY, false);
2956
+ }
2957
+ if (this._special === SpecialValue.NEGATIVE_INFINITY) {
2958
+ return _BigDecimal._create(0n, 0, SpecialValue.POSITIVE_INFINITY, false);
2959
+ }
2960
+ if (this._mantissa === 0n) {
2961
+ return _BigDecimal._create(0n, 0, SpecialValue.NONE, !this._negativeZero);
2962
+ }
2963
+ return _BigDecimal._create(-this._mantissa, this._exponent, SpecialValue.NONE, false);
2964
+ }
2965
+ pow(n) {
2966
+ if (this._special === SpecialValue.NAN)
2967
+ return this;
2968
+ if (n === 0)
2969
+ return new _BigDecimal(1);
2970
+ if (n < 0) {
2971
+ return new _BigDecimal(1).div(this.pow(-n));
2972
+ }
2973
+ if (this._special === SpecialValue.POSITIVE_INFINITY)
2974
+ return this;
2975
+ if (this._special === SpecialValue.NEGATIVE_INFINITY) {
2976
+ return n % 2 === 0 ? _BigDecimal._create(0n, 0, SpecialValue.POSITIVE_INFINITY, false) : this;
2977
+ }
2978
+ if (this._mantissa === 0n)
2979
+ return new _BigDecimal(0);
2980
+ const m = this._mantissa ** BigInt(n);
2981
+ const e = this._exponent * n;
2982
+ const [nm, ne] = removeTrailingZeros(m, e);
2983
+ return _BigDecimal._create(nm, ne, SpecialValue.NONE, false);
2984
+ }
2985
+ floor() {
2986
+ if (this._special !== SpecialValue.NONE)
2987
+ return this;
2988
+ if (this._mantissa === 0n)
2989
+ return this;
2990
+ if (this._exponent >= 0)
2991
+ return this;
2992
+ const divisor = bigintPow10(-this._exponent);
2993
+ const m = this._mantissa;
2994
+ let q = m / divisor;
2995
+ if (m < 0n && m % divisor !== 0n) {
2996
+ q -= 1n;
2997
+ }
2998
+ if (q === 0n) {
2999
+ const negZero = this._mantissa < 0n;
3000
+ return _BigDecimal._create(0n, 0, SpecialValue.NONE, negZero);
3001
+ }
3002
+ const [nm, ne] = removeTrailingZeros(q, 0);
3003
+ return _BigDecimal._create(nm, ne, SpecialValue.NONE, false);
3004
+ }
3005
+ ceil() {
3006
+ if (this._special !== SpecialValue.NONE)
3007
+ return this;
3008
+ if (this._mantissa === 0n)
3009
+ return this;
3010
+ if (this._exponent >= 0)
3011
+ return this;
3012
+ const divisor = bigintPow10(-this._exponent);
3013
+ const m = this._mantissa;
3014
+ let q = m / divisor;
3015
+ if (m > 0n && m % divisor !== 0n) {
3016
+ q += 1n;
3017
+ }
3018
+ if (q === 0n) {
3019
+ return _BigDecimal._create(0n, 0, SpecialValue.NONE, false);
3020
+ }
3021
+ const [nm, ne] = removeTrailingZeros(q, 0);
3022
+ return _BigDecimal._create(nm, ne, SpecialValue.NONE, false);
3023
+ }
3024
+ log(base) {
3025
+ if (this._special === SpecialValue.NAN)
3026
+ return this;
3027
+ if (this._special === SpecialValue.NEGATIVE_INFINITY) {
3028
+ return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
3029
+ }
3030
+ if (this._special === SpecialValue.POSITIVE_INFINITY) {
3031
+ return _BigDecimal._create(0n, 0, SpecialValue.POSITIVE_INFINITY, false);
3032
+ }
3033
+ if (this._mantissa < 0n) {
3034
+ return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
3035
+ }
3036
+ if (this._mantissa === 0n) {
3037
+ return _BigDecimal._create(0n, 0, SpecialValue.NEGATIVE_INFINITY, false);
3038
+ }
3039
+ if (base === 10) {
3040
+ return this._log10();
3041
+ }
3042
+ const log10x = this._log10();
3043
+ const log10b = new _BigDecimal(Math.log10(base));
3044
+ return log10x.div(log10b);
3045
+ }
3046
+ _log10() {
3047
+ const absMantissa = bigintAbs(this._mantissa);
3048
+ const digits = digitCount(absMantissa);
3049
+ let log10Mantissa;
3050
+ if (digits <= 15) {
3051
+ log10Mantissa = Math.log10(Number(absMantissa));
3052
+ } else {
3053
+ const shift = digits - 17;
3054
+ const leading = absMantissa / bigintPow10(shift);
3055
+ log10Mantissa = Math.log10(Number(leading)) + shift;
4070
3056
  }
3057
+ const totalLog10 = log10Mantissa + this._exponent;
3058
+ return new _BigDecimal(totalLog10);
4071
3059
  }
4072
- return x;
4073
- }
4074
- function finiteToString(x, isExp, sd) {
4075
- if (!x.isFinite())
4076
- return nonFiniteToString(x);
4077
- var k, e = x.e, str = digitsToString(x.d), len = str.length;
4078
- if (isExp) {
4079
- if (sd && (k = sd - len) > 0) {
4080
- str = str.charAt(0) + "." + str.slice(1) + getZeroString(k);
4081
- } else if (len > 1) {
4082
- str = str.charAt(0) + "." + str.slice(1);
4083
- }
4084
- str = str + (x.e < 0 ? "e" : "e+") + x.e;
4085
- } else if (e < 0) {
4086
- str = "0." + getZeroString(-e - 1) + str;
4087
- if (sd && (k = sd - len) > 0)
4088
- str += getZeroString(k);
4089
- } else if (e >= len) {
4090
- str += getZeroString(e + 1 - len);
4091
- if (sd && (k = sd - e - 1) > 0)
4092
- str = str + "." + getZeroString(k);
4093
- } else {
4094
- if ((k = e + 1) < len)
4095
- str = str.slice(0, k) + "." + str.slice(k);
4096
- if (sd && (k = sd - len) > 0) {
4097
- if (e + 1 === len)
4098
- str += ".";
4099
- str += getZeroString(k);
4100
- }
3060
+ // --- Comparison ---
3061
+ eq(y) {
3062
+ const other = _BigDecimal._coerce(y);
3063
+ if (this._special === SpecialValue.NAN || other._special === SpecialValue.NAN)
3064
+ return false;
3065
+ if (this._special !== other._special)
3066
+ return false;
3067
+ if (this._special !== SpecialValue.NONE)
3068
+ return true;
3069
+ if (this._mantissa === 0n && other._mantissa === 0n)
3070
+ return true;
3071
+ return this._mantissa === other._mantissa && this._exponent === other._exponent;
4101
3072
  }
4102
- return str;
4103
- }
4104
- function getBase10Exponent(digits, e) {
4105
- var w = digits[0];
4106
- for (e *= LOG_BASE; w >= 10; w /= 10)
4107
- e++;
4108
- return e;
4109
- }
4110
- function getLn10(Ctor, sd, pr) {
4111
- if (sd > LN10_PRECISION) {
4112
- external = true;
4113
- if (pr)
4114
- Ctor.precision = pr;
4115
- throw Error(precisionLimitExceeded);
4116
- }
4117
- return finalise(new Ctor(LN10), sd, 1, true);
4118
- }
4119
- function getPi(Ctor, sd, rm) {
4120
- if (sd > PI_PRECISION)
4121
- throw Error(precisionLimitExceeded);
4122
- return finalise(new Ctor(PI), sd, rm, true);
4123
- }
4124
- function getPrecision(digits) {
4125
- var w = digits.length - 1, len = w * LOG_BASE + 1;
4126
- w = digits[w];
4127
- if (w) {
4128
- for (; w % 10 == 0; w /= 10)
4129
- len--;
4130
- for (w = digits[0]; w >= 10; w /= 10)
4131
- len++;
4132
- }
4133
- return len;
4134
- }
4135
- function getZeroString(k) {
4136
- var zs = "";
4137
- for (; k--; )
4138
- zs += "0";
4139
- return zs;
4140
- }
4141
- function intPow(Ctor, x, n, pr) {
4142
- var isTruncated, r = new Ctor(1), k = Math.ceil(pr / LOG_BASE + 4);
4143
- external = false;
4144
- for (; ; ) {
4145
- if (n % 2) {
4146
- r = r.times(x);
4147
- if (truncate(r.d, k))
4148
- isTruncated = true;
4149
- }
4150
- n = mathfloor(n / 2);
4151
- if (n === 0) {
4152
- n = r.d.length - 1;
4153
- if (isTruncated && r.d[n] === 0)
4154
- ++r.d[n];
4155
- break;
3073
+ _compareTo(other) {
3074
+ if (this._special === SpecialValue.NAN || other._special === SpecialValue.NAN) {
3075
+ return NaN;
4156
3076
  }
4157
- x = x.times(x);
4158
- truncate(x.d, k);
4159
- }
4160
- external = true;
4161
- return r;
4162
- }
4163
- function isOdd(n) {
4164
- return n.d[n.d.length - 1] & 1;
4165
- }
4166
- function maxOrMin(Ctor, args, n) {
4167
- var k, y, x = new Ctor(args[0]), i = 0;
4168
- for (; ++i < args.length; ) {
4169
- y = new Ctor(args[i]);
4170
- if (!y.s) {
4171
- x = y;
4172
- break;
3077
+ if (this._special === SpecialValue.POSITIVE_INFINITY) {
3078
+ return other._special === SpecialValue.POSITIVE_INFINITY ? 0 : 1;
4173
3079
  }
4174
- k = x.cmp(y);
4175
- if (k === n || k === 0 && x.s === n) {
4176
- x = y;
3080
+ if (this._special === SpecialValue.NEGATIVE_INFINITY) {
3081
+ return other._special === SpecialValue.NEGATIVE_INFINITY ? 0 : -1;
4177
3082
  }
3083
+ if (other._special === SpecialValue.POSITIVE_INFINITY)
3084
+ return -1;
3085
+ if (other._special === SpecialValue.NEGATIVE_INFINITY)
3086
+ return 1;
3087
+ const thisZero = this._mantissa === 0n;
3088
+ const otherZero = other._mantissa === 0n;
3089
+ if (thisZero && otherZero)
3090
+ return 0;
3091
+ if (thisZero)
3092
+ return other._mantissa > 0n ? -1 : 1;
3093
+ if (otherZero)
3094
+ return this._mantissa > 0n ? 1 : -1;
3095
+ const thisNeg = this._mantissa < 0n;
3096
+ const otherNeg = other._mantissa < 0n;
3097
+ if (thisNeg !== otherNeg)
3098
+ return thisNeg ? -1 : 1;
3099
+ let m1 = this._mantissa;
3100
+ let m2 = other._mantissa;
3101
+ const e1 = this._exponent;
3102
+ const e2 = other._exponent;
3103
+ const minE = Math.min(e1, e2);
3104
+ if (e1 > minE)
3105
+ m1 *= bigintPow10(e1 - minE);
3106
+ if (e2 > minE)
3107
+ m2 *= bigintPow10(e2 - minE);
3108
+ if (m1 < m2)
3109
+ return -1;
3110
+ if (m1 > m2)
3111
+ return 1;
3112
+ return 0;
4178
3113
  }
4179
- return x;
4180
- }
4181
- function naturalExponential(x, sd) {
4182
- var denominator, guard, j, pow2, sum2, t, wpr, rep = 0, i = 0, k = 0, Ctor = x.constructor, rm = Ctor.rounding, pr = Ctor.precision;
4183
- if (!x.d || !x.d[0] || x.e > 17) {
4184
- return new Ctor(x.d ? !x.d[0] ? 1 : x.s < 0 ? 0 : 1 / 0 : x.s ? x.s < 0 ? 0 : x : 0 / 0);
4185
- }
4186
- if (sd == null) {
4187
- external = false;
4188
- wpr = pr;
4189
- } else {
4190
- wpr = sd;
4191
- }
4192
- t = new Ctor(0.03125);
4193
- while (x.e > -2) {
4194
- x = x.times(t);
4195
- k += 5;
4196
- }
4197
- guard = Math.log(mathpow(2, k)) / Math.LN10 * 2 + 5 | 0;
4198
- wpr += guard;
4199
- denominator = pow2 = sum2 = new Ctor(1);
4200
- Ctor.precision = wpr;
4201
- for (; ; ) {
4202
- pow2 = finalise(pow2.times(x), wpr, 1);
4203
- denominator = denominator.times(++i);
4204
- t = sum2.plus(divide(pow2, denominator, wpr, 1));
4205
- if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum2.d).slice(0, wpr)) {
4206
- j = k;
4207
- while (j--)
4208
- sum2 = finalise(sum2.times(sum2), wpr, 1);
4209
- if (sd == null) {
4210
- if (rep < 3 && checkRoundingDigits(sum2.d, wpr - guard, rm, rep)) {
4211
- Ctor.precision = wpr += 10;
4212
- denominator = pow2 = t = new Ctor(1);
4213
- i = 0;
4214
- rep++;
4215
- } else {
4216
- return finalise(sum2, Ctor.precision = pr, rm, external = true);
4217
- }
4218
- } else {
4219
- Ctor.precision = pr;
4220
- return sum2;
4221
- }
4222
- }
4223
- sum2 = t;
3114
+ lessThan(y) {
3115
+ const c = this._compareTo(_BigDecimal._coerce(y));
3116
+ return c === -1;
4224
3117
  }
4225
- }
4226
- function naturalLogarithm(y, sd) {
4227
- 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;
4228
- if (x.s < 0 || !xd || !xd[0] || !x.e && xd[0] == 1 && xd.length == 1) {
4229
- return new Ctor(xd && !xd[0] ? -1 / 0 : x.s != 1 ? NaN : xd ? 0 : x);
4230
- }
4231
- if (sd == null) {
4232
- external = false;
4233
- wpr = pr;
4234
- } else {
4235
- wpr = sd;
4236
- }
4237
- Ctor.precision = wpr += guard;
4238
- c = digitsToString(xd);
4239
- c0 = c.charAt(0);
4240
- if (Math.abs(e = x.e) < 15e14) {
4241
- while (c0 < 7 && c0 != 1 || c0 == 1 && c.charAt(1) > 3) {
4242
- x = x.times(y);
4243
- c = digitsToString(x.d);
4244
- c0 = c.charAt(0);
4245
- n++;
4246
- }
4247
- e = x.e;
4248
- if (c0 > 1) {
4249
- x = new Ctor("0." + c);
4250
- e++;
4251
- } else {
4252
- x = new Ctor(c0 + "." + c.slice(1));
4253
- }
4254
- } else {
4255
- t = getLn10(Ctor, wpr + 2, pr).times(e + "");
4256
- x = naturalLogarithm(new Ctor(c0 + "." + c.slice(1)), wpr - guard).plus(t);
4257
- Ctor.precision = pr;
4258
- return sd == null ? finalise(x, pr, rm, external = true) : x;
4259
- }
4260
- x1 = x;
4261
- sum2 = numerator = x = divide(x.minus(1), x.plus(1), wpr, 1);
4262
- x2 = finalise(x.times(x), wpr, 1);
4263
- denominator = 3;
4264
- for (; ; ) {
4265
- numerator = finalise(numerator.times(x2), wpr, 1);
4266
- t = sum2.plus(divide(numerator, new Ctor(denominator), wpr, 1));
4267
- if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum2.d).slice(0, wpr)) {
4268
- sum2 = sum2.times(2);
4269
- if (e !== 0)
4270
- sum2 = sum2.plus(getLn10(Ctor, wpr + 2, pr).times(e + ""));
4271
- sum2 = divide(sum2, new Ctor(n), wpr, 1);
4272
- if (sd == null) {
4273
- if (checkRoundingDigits(sum2.d, wpr - guard, rm, rep)) {
4274
- Ctor.precision = wpr += guard;
4275
- t = numerator = x = divide(x1.minus(1), x1.plus(1), wpr, 1);
4276
- x2 = finalise(x.times(x), wpr, 1);
4277
- denominator = rep = 1;
4278
- } else {
4279
- return finalise(sum2, Ctor.precision = pr, rm, external = true);
4280
- }
4281
- } else {
4282
- Ctor.precision = pr;
4283
- return sum2;
4284
- }
4285
- }
4286
- sum2 = t;
4287
- denominator += 2;
3118
+ greaterThan(y) {
3119
+ const c = this._compareTo(_BigDecimal._coerce(y));
3120
+ return c === 1;
4288
3121
  }
4289
- }
4290
- function nonFiniteToString(x) {
4291
- return String(x.s * x.s / 0);
4292
- }
4293
- function parseDecimal(x, str) {
4294
- var e, i, len;
4295
- if ((e = str.indexOf(".")) > -1)
4296
- str = str.replace(".", "");
4297
- if ((i = str.search(/e/i)) > 0) {
4298
- if (e < 0)
4299
- e = i;
4300
- e += +str.slice(i + 1);
4301
- str = str.substring(0, i);
4302
- } else if (e < 0) {
4303
- e = str.length;
4304
- }
4305
- for (i = 0; str.charCodeAt(i) === 48; i++)
4306
- ;
4307
- for (len = str.length; str.charCodeAt(len - 1) === 48; --len)
4308
- ;
4309
- str = str.slice(i, len);
4310
- if (str) {
4311
- len -= i;
4312
- x.e = e = e - i - 1;
4313
- x.d = [];
4314
- i = (e + 1) % LOG_BASE;
4315
- if (e < 0)
4316
- i += LOG_BASE;
4317
- if (i < len) {
4318
- if (i)
4319
- x.d.push(+str.slice(0, i));
4320
- for (len -= LOG_BASE; i < len; )
4321
- x.d.push(+str.slice(i, i += LOG_BASE));
4322
- str = str.slice(i);
4323
- i = LOG_BASE - str.length;
4324
- } else {
4325
- i -= len;
4326
- }
4327
- for (; i--; )
4328
- str += "0";
4329
- x.d.push(+str);
4330
- if (external) {
4331
- if (x.e > x.constructor.maxE) {
4332
- x.d = null;
4333
- x.e = NaN;
4334
- } else if (x.e < x.constructor.minE) {
4335
- x.e = 0;
4336
- x.d = [0];
4337
- }
4338
- }
4339
- } else {
4340
- x.e = 0;
4341
- x.d = [0];
3122
+ lessThanOrEqualTo(y) {
3123
+ const c = this._compareTo(_BigDecimal._coerce(y));
3124
+ return c === 0 || c === -1;
4342
3125
  }
4343
- return x;
4344
- }
4345
- function parseOther(x, str) {
4346
- var base, Ctor, divisor, i, isFloat, len, p, xd, xe;
4347
- if (str.indexOf("_") > -1) {
4348
- str = str.replace(/(\d)_(?=\d)/g, "$1");
4349
- if (isDecimal.test(str))
4350
- return parseDecimal(x, str);
4351
- } else if (str === "Infinity" || str === "NaN") {
4352
- if (!+str)
4353
- x.s = NaN;
4354
- x.e = NaN;
4355
- x.d = null;
4356
- return x;
4357
- }
4358
- if (isHex.test(str)) {
4359
- base = 16;
4360
- str = str.toLowerCase();
4361
- } else if (isBinary.test(str)) {
4362
- base = 2;
4363
- } else if (isOctal.test(str)) {
4364
- base = 8;
4365
- } else {
4366
- throw Error(invalidArgument + str);
3126
+ greaterThanOrEqualTo(y) {
3127
+ const c = this._compareTo(_BigDecimal._coerce(y));
3128
+ return c === 0 || c === 1;
4367
3129
  }
4368
- i = str.search(/p/i);
4369
- if (i > 0) {
4370
- p = +str.slice(i + 1);
4371
- str = str.substring(2, i);
4372
- } else {
4373
- str = str.slice(2);
4374
- }
4375
- i = str.indexOf(".");
4376
- isFloat = i >= 0;
4377
- Ctor = x.constructor;
4378
- if (isFloat) {
4379
- str = str.replace(".", "");
4380
- len = str.length;
4381
- i = len - i;
4382
- divisor = intPow(Ctor, new Ctor(base), i, i * 2);
4383
- }
4384
- xd = convertBase(str, base, BASE);
4385
- xe = xd.length - 1;
4386
- for (i = xe; xd[i] === 0; --i)
4387
- xd.pop();
4388
- if (i < 0)
4389
- return new Ctor(x.s * 0);
4390
- x.e = getBase10Exponent(xd, xe);
4391
- x.d = xd;
4392
- external = false;
4393
- if (isFloat)
4394
- x = divide(x, divisor, len * 4);
4395
- if (p)
4396
- x = x.times(Math.abs(p) < 54 ? mathpow(2, p) : Decimal.pow(2, p));
4397
- external = true;
4398
- return x;
4399
- }
4400
- function sine(Ctor, x) {
4401
- var k, len = x.d.length;
4402
- if (len < 3) {
4403
- return x.isZero() ? x : taylorSeries(Ctor, 2, x, x);
4404
- }
4405
- k = 1.4 * Math.sqrt(len);
4406
- k = k > 16 ? 16 : k | 0;
4407
- x = x.times(1 / tinyPow(5, k));
4408
- x = taylorSeries(Ctor, 2, x, x);
4409
- var sin2_x, d5 = new Ctor(5), d16 = new Ctor(16), d20 = new Ctor(20);
4410
- for (; k--; ) {
4411
- sin2_x = x.times(x);
4412
- x = x.times(d5.plus(sin2_x.times(d16.times(sin2_x).minus(d20))));
4413
- }
4414
- return x;
4415
- }
4416
- function taylorSeries(Ctor, n, x, y, isHyperbolic) {
4417
- var j, t, u, x2, i = 1, pr = Ctor.precision, k = Math.ceil(pr / LOG_BASE);
4418
- external = false;
4419
- x2 = x.times(x);
4420
- u = new Ctor(y);
4421
- for (; ; ) {
4422
- t = divide(u.times(x2), new Ctor(n++ * n++), pr, 1);
4423
- u = isHyperbolic ? y.plus(t) : y.minus(t);
4424
- y = divide(t.times(x2), new Ctor(n++ * n++), pr, 1);
4425
- t = u.plus(y);
4426
- if (t.d[k] !== void 0) {
4427
- for (j = k; t.d[j] === u.d[j] && j--; )
4428
- ;
4429
- if (j == -1)
4430
- break;
4431
- }
4432
- j = u;
4433
- u = y;
4434
- y = t;
4435
- t = j;
4436
- i++;
3130
+ // --- Queries ---
3131
+ isZero() {
3132
+ return this._special === SpecialValue.NONE && this._mantissa === 0n;
4437
3133
  }
4438
- external = true;
4439
- t.d.length = k + 1;
4440
- return t;
4441
- }
4442
- function tinyPow(b, e) {
4443
- var n = b;
4444
- while (--e)
4445
- n *= b;
4446
- return n;
4447
- }
4448
- function toLessThanHalfPi(Ctor, x) {
4449
- var t, isNeg = x.s < 0, pi = getPi(Ctor, Ctor.precision, 1), halfPi = pi.times(0.5);
4450
- x = x.abs();
4451
- if (x.lte(halfPi)) {
4452
- quadrant = isNeg ? 4 : 1;
4453
- return x;
4454
- }
4455
- t = x.divToInt(pi);
4456
- if (t.isZero()) {
4457
- quadrant = isNeg ? 3 : 2;
4458
- } else {
4459
- x = x.minus(t.times(pi));
4460
- if (x.lte(halfPi)) {
4461
- quadrant = isOdd(t) ? isNeg ? 2 : 3 : isNeg ? 4 : 1;
4462
- return x;
4463
- }
4464
- quadrant = isOdd(t) ? isNeg ? 1 : 4 : isNeg ? 3 : 2;
3134
+ isNaN() {
3135
+ return this._special === SpecialValue.NAN;
4465
3136
  }
4466
- return x.minus(pi).abs();
4467
- }
4468
- function toStringBinary(x, baseOut, sd, rm) {
4469
- var base, e, i, k, len, roundUp, str, xd, y, Ctor = x.constructor, isExp = sd !== void 0;
4470
- if (isExp) {
4471
- checkInt32(sd, 1, MAX_DIGITS);
4472
- if (rm === void 0)
4473
- rm = Ctor.rounding;
4474
- else
4475
- checkInt32(rm, 0, 8);
4476
- } else {
4477
- sd = Ctor.precision;
4478
- rm = Ctor.rounding;
3137
+ isFinite() {
3138
+ return this._special === SpecialValue.NONE;
4479
3139
  }
4480
- if (!x.isFinite()) {
4481
- str = nonFiniteToString(x);
4482
- } else {
4483
- str = finiteToString(x);
4484
- i = str.indexOf(".");
4485
- if (isExp) {
4486
- base = 2;
4487
- if (baseOut == 16) {
4488
- sd = sd * 4 - 3;
4489
- } else if (baseOut == 8) {
4490
- sd = sd * 3 - 2;
4491
- }
4492
- } else {
4493
- base = baseOut;
4494
- }
4495
- if (i >= 0) {
4496
- str = str.replace(".", "");
4497
- y = new Ctor(1);
4498
- y.e = str.length - i;
4499
- y.d = convertBase(finiteToString(y), 10, base);
4500
- y.e = y.d.length;
4501
- }
4502
- xd = convertBase(str, 10, base);
4503
- e = len = xd.length;
4504
- for (; xd[--len] == 0; )
4505
- xd.pop();
4506
- if (!xd[0]) {
4507
- str = isExp ? "0p+0" : "0";
4508
- } else {
4509
- if (i < 0) {
4510
- e--;
4511
- } else {
4512
- x = new Ctor(x);
4513
- x.d = xd;
4514
- x.e = e;
4515
- x = divide(x, y, sd, rm, 0, base);
4516
- xd = x.d;
4517
- e = x.e;
4518
- roundUp = inexact;
4519
- }
4520
- i = xd[sd];
4521
- k = base / 2;
4522
- roundUp = roundUp || xd[sd + 1] !== void 0;
4523
- 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));
4524
- xd.length = sd;
4525
- if (roundUp) {
4526
- for (; ++xd[--sd] > base - 1; ) {
4527
- xd[sd] = 0;
4528
- if (!sd) {
4529
- ++e;
4530
- xd.unshift(1);
4531
- }
4532
- }
4533
- }
4534
- for (len = xd.length; !xd[len - 1]; --len)
4535
- ;
4536
- for (i = 0, str = ""; i < len; i++)
4537
- str += NUMERALS.charAt(xd[i]);
4538
- if (isExp) {
4539
- if (len > 1) {
4540
- if (baseOut == 16 || baseOut == 8) {
4541
- i = baseOut == 16 ? 4 : 3;
4542
- for (--len; len % i; len++)
4543
- str += "0";
4544
- xd = convertBase(str, base, baseOut);
4545
- for (len = xd.length; !xd[len - 1]; --len)
4546
- ;
4547
- for (i = 1, str = "1."; i < len; i++)
4548
- str += NUMERALS.charAt(xd[i]);
4549
- } else {
4550
- str = str.charAt(0) + "." + str.slice(1);
4551
- }
4552
- }
4553
- str = str + (e < 0 ? "p" : "p+") + e;
4554
- } else if (e < 0) {
4555
- for (; ++e; )
4556
- str = "0" + str;
4557
- str = "0." + str;
4558
- } else {
4559
- if (++e > len)
4560
- for (e -= len; e--; )
4561
- str += "0";
4562
- else if (e < len)
4563
- str = str.slice(0, e) + "." + str.slice(e);
4564
- }
4565
- }
4566
- str = (baseOut == 16 ? "0x" : baseOut == 2 ? "0b" : baseOut == 8 ? "0o" : "") + str;
3140
+ isNegative() {
3141
+ if (this._special === SpecialValue.NAN)
3142
+ return false;
3143
+ if (this._special === SpecialValue.NEGATIVE_INFINITY)
3144
+ return true;
3145
+ if (this._special === SpecialValue.POSITIVE_INFINITY)
3146
+ return false;
3147
+ if (this._mantissa === 0n)
3148
+ return this._negativeZero;
3149
+ return this._mantissa < 0n;
4567
3150
  }
4568
- return x.s < 0 ? "-" + str : str;
4569
- }
4570
- function truncate(arr, len) {
4571
- if (arr.length > len) {
4572
- arr.length = len;
4573
- return true;
3151
+ isPositive() {
3152
+ if (this._special === SpecialValue.NAN)
3153
+ return false;
3154
+ if (this._special === SpecialValue.POSITIVE_INFINITY)
3155
+ return true;
3156
+ if (this._special === SpecialValue.NEGATIVE_INFINITY)
3157
+ return false;
3158
+ if (this._mantissa === 0n)
3159
+ return !this._negativeZero;
3160
+ return this._mantissa > 0n;
4574
3161
  }
4575
- }
4576
- function abs(x) {
4577
- return new this(x).abs();
4578
- }
4579
- function acos(x) {
4580
- return new this(x).acos();
4581
- }
4582
- function acosh(x) {
4583
- return new this(x).acosh();
4584
- }
4585
- function add(x, y) {
4586
- return new this(x).plus(y);
4587
- }
4588
- function asin(x) {
4589
- return new this(x).asin();
4590
- }
4591
- function asinh(x) {
4592
- return new this(x).asinh();
4593
- }
4594
- function atan(x) {
4595
- return new this(x).atan();
4596
- }
4597
- function atanh(x) {
4598
- return new this(x).atanh();
4599
- }
4600
- function atan2(y, x) {
4601
- y = new this(y);
4602
- x = new this(x);
4603
- var r, pr = this.precision, rm = this.rounding, wpr = pr + 4;
4604
- if (!y.s || !x.s) {
4605
- r = new this(NaN);
4606
- } else if (!y.d && !x.d) {
4607
- r = getPi(this, wpr, 1).times(x.s > 0 ? 0.25 : 0.75);
4608
- r.s = y.s;
4609
- } else if (!x.d || y.isZero()) {
4610
- r = x.s < 0 ? getPi(this, pr, rm) : new this(0);
4611
- r.s = y.s;
4612
- } else if (!y.d || x.isZero()) {
4613
- r = getPi(this, wpr, 1).times(0.5);
4614
- r.s = y.s;
4615
- } else if (x.s < 0) {
4616
- this.precision = wpr;
4617
- this.rounding = 1;
4618
- r = this.atan(divide(y, x, wpr, 1));
4619
- x = getPi(this, wpr, 1);
4620
- this.precision = pr;
4621
- this.rounding = rm;
4622
- r = y.s < 0 ? r.minus(x) : r.plus(x);
4623
- } else {
4624
- r = this.atan(divide(y, x, wpr, 1));
3162
+ isInteger() {
3163
+ if (this._special !== SpecialValue.NONE)
3164
+ return false;
3165
+ if (this._mantissa === 0n)
3166
+ return true;
3167
+ return this._exponent >= 0;
3168
+ }
3169
+ // --- Conversion ---
3170
+ toJSON() {
3171
+ return this.toString();
3172
+ }
3173
+ toNumber() {
3174
+ if (this._special === SpecialValue.NAN)
3175
+ return NaN;
3176
+ if (this._special === SpecialValue.POSITIVE_INFINITY)
3177
+ return Infinity;
3178
+ if (this._special === SpecialValue.NEGATIVE_INFINITY)
3179
+ return -Infinity;
3180
+ if (this._mantissa === 0n)
3181
+ return this._negativeZero ? -0 : 0;
3182
+ return Number(this.toString());
4625
3183
  }
4626
- return r;
4627
- }
4628
- function cbrt(x) {
4629
- return new this(x).cbrt();
4630
- }
4631
- function ceil(x) {
4632
- return finalise(x = new this(x), x.e + 1, 2);
4633
- }
4634
- function clamp(x, min2, max2) {
4635
- return new this(x).clamp(min2, max2);
4636
- }
4637
- function config(obj) {
4638
- if (!obj || typeof obj !== "object")
4639
- throw Error(decimalError + "Object expected");
4640
- var i, p, v, useDefaults = obj.defaults === true, ps = [
4641
- "precision",
4642
- 1,
4643
- MAX_DIGITS,
4644
- "rounding",
4645
- 0,
4646
- 8,
4647
- "toExpNeg",
4648
- -EXP_LIMIT,
4649
- 0,
4650
- "toExpPos",
4651
- 0,
4652
- EXP_LIMIT,
4653
- "maxE",
4654
- 0,
4655
- EXP_LIMIT,
4656
- "minE",
4657
- -EXP_LIMIT,
4658
- 0,
4659
- "modulo",
4660
- 0,
4661
- 9
4662
- ];
4663
- for (i = 0; i < ps.length; i += 3) {
4664
- if (p = ps[i], useDefaults)
4665
- this[p] = DEFAULTS[p];
4666
- if ((v = obj[p]) !== void 0) {
4667
- if (mathfloor(v) === v && v >= ps[i + 1] && v <= ps[i + 2])
4668
- this[p] = v;
4669
- else
4670
- throw Error(invalidArgument + p + ": " + v);
4671
- }
4672
- }
4673
- if (p = "crypto", useDefaults)
4674
- this[p] = DEFAULTS[p];
4675
- if ((v = obj[p]) !== void 0) {
4676
- if (v === true || v === false || v === 0 || v === 1) {
4677
- if (v) {
4678
- if (typeof crypto != "undefined" && crypto && (crypto.getRandomValues || crypto.randomBytes)) {
4679
- this[p] = true;
4680
- } else {
4681
- throw Error(cryptoUnavailable);
4682
- }
4683
- } else {
4684
- this[p] = false;
4685
- }
3184
+ toString() {
3185
+ if (this._special === SpecialValue.NAN)
3186
+ return "NaN";
3187
+ if (this._special === SpecialValue.POSITIVE_INFINITY)
3188
+ return "Infinity";
3189
+ if (this._special === SpecialValue.NEGATIVE_INFINITY)
3190
+ return "-Infinity";
3191
+ if (this._mantissa === 0n)
3192
+ return "0";
3193
+ const negative = this._mantissa < 0n;
3194
+ const absStr = bigintAbs(this._mantissa).toString();
3195
+ const prefix = negative ? "-" : "";
3196
+ if (this._exponent === 0) {
3197
+ return prefix + absStr;
3198
+ }
3199
+ if (this._exponent > 0) {
3200
+ return prefix + absStr + "0".repeat(this._exponent);
3201
+ }
3202
+ const decimalPlaces = -this._exponent;
3203
+ if (decimalPlaces < absStr.length) {
3204
+ const intPart = absStr.slice(0, absStr.length - decimalPlaces);
3205
+ const fracPart = absStr.slice(absStr.length - decimalPlaces);
3206
+ return prefix + intPart + "." + fracPart;
4686
3207
  } else {
4687
- throw Error(invalidArgument + p + ": " + v);
3208
+ const leadingZeros = decimalPlaces - absStr.length;
3209
+ return prefix + "0." + "0".repeat(leadingZeros) + absStr;
4688
3210
  }
4689
3211
  }
4690
- return this;
4691
- }
4692
- function cos(x) {
4693
- return new this(x).cos();
4694
- }
4695
- function cosh(x) {
4696
- return new this(x).cosh();
4697
- }
4698
- function clone(obj) {
4699
- var i, p, ps;
4700
- function Decimal2(v) {
4701
- var e, i2, t, x = this;
4702
- if (!(x instanceof Decimal2))
4703
- return new Decimal2(v);
4704
- x.constructor = Decimal2;
4705
- if (isDecimalInstance(v)) {
4706
- x.s = v.s;
4707
- if (external) {
4708
- if (!v.d || v.e > Decimal2.maxE) {
4709
- x.e = NaN;
4710
- x.d = null;
4711
- } else if (v.e < Decimal2.minE) {
4712
- x.e = 0;
4713
- x.d = [0];
4714
- } else {
4715
- x.e = v.e;
4716
- x.d = v.d.slice();
4717
- }
4718
- } else {
4719
- x.e = v.e;
4720
- x.d = v.d ? v.d.slice() : v.d;
4721
- }
4722
- return;
3212
+ // --- Static ---
3213
+ static pow(base, exp) {
3214
+ const n = typeof exp === "number" ? exp : exp.toNumber();
3215
+ if (typeof base === "number" && base === 10) {
3216
+ return _BigDecimal._create(1n, n, SpecialValue.NONE, false);
4723
3217
  }
4724
- t = typeof v;
4725
- if (t === "number") {
4726
- if (v === 0) {
4727
- x.s = 1 / v < 0 ? -1 : 1;
4728
- x.e = 0;
4729
- x.d = [0];
4730
- return;
4731
- }
4732
- if (v < 0) {
4733
- v = -v;
4734
- x.s = -1;
4735
- } else {
4736
- x.s = 1;
4737
- }
4738
- if (v === ~~v && v < 1e7) {
4739
- for (e = 0, i2 = v; i2 >= 10; i2 /= 10)
4740
- e++;
4741
- if (external) {
4742
- if (e > Decimal2.maxE) {
4743
- x.e = NaN;
4744
- x.d = null;
4745
- } else if (e < Decimal2.minE) {
4746
- x.e = 0;
4747
- x.d = [0];
4748
- } else {
4749
- x.e = e;
4750
- x.d = [v];
4751
- }
4752
- } else {
4753
- x.e = e;
4754
- x.d = [v];
3218
+ const bd = base instanceof _BigDecimal ? base : new _BigDecimal(base);
3219
+ return bd.pow(n);
3220
+ }
3221
+ static set(_config) {
3222
+ }
3223
+ // --- Internal helpers ---
3224
+ _isSignNegative() {
3225
+ if (this._special === SpecialValue.NEGATIVE_INFINITY)
3226
+ return true;
3227
+ if (this._mantissa < 0n)
3228
+ return true;
3229
+ if (this._mantissa === 0n)
3230
+ return this._negativeZero;
3231
+ return false;
3232
+ }
3233
+ _specialArith(other, op) {
3234
+ const a = this._special;
3235
+ const b = other._special;
3236
+ if (a === SpecialValue.NAN || b === SpecialValue.NAN) {
3237
+ return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
3238
+ }
3239
+ const aNeg = this._isSignNegative();
3240
+ const bNeg = other._isSignNegative();
3241
+ const aInf = a === SpecialValue.POSITIVE_INFINITY || a === SpecialValue.NEGATIVE_INFINITY;
3242
+ const bInf = b === SpecialValue.POSITIVE_INFINITY || b === SpecialValue.NEGATIVE_INFINITY;
3243
+ if (op === "times") {
3244
+ if (aInf || bInf) {
3245
+ if (aInf && other._mantissa === 0n && !bInf || bInf && this._mantissa === 0n && !aInf) {
3246
+ return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
4755
3247
  }
4756
- return;
3248
+ const neg = aNeg !== bNeg;
3249
+ return _BigDecimal._create(0n, 0, neg ? SpecialValue.NEGATIVE_INFINITY : SpecialValue.POSITIVE_INFINITY, false);
4757
3250
  }
4758
- if (v * 0 !== 0) {
4759
- if (!v)
4760
- x.s = NaN;
4761
- x.e = NaN;
4762
- x.d = null;
4763
- return;
4764
- }
4765
- return parseDecimal(x, v.toString());
4766
3251
  }
4767
- if (t === "string") {
4768
- if ((i2 = v.charCodeAt(0)) === 45) {
4769
- v = v.slice(1);
4770
- x.s = -1;
4771
- } else {
4772
- if (i2 === 43)
4773
- v = v.slice(1);
4774
- x.s = 1;
3252
+ if (op === "div") {
3253
+ if (aInf && bInf) {
3254
+ return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
4775
3255
  }
4776
- return isDecimal.test(v) ? parseDecimal(x, v) : parseOther(x, v);
4777
- }
4778
- if (t === "bigint") {
4779
- if (v < 0) {
4780
- v = -v;
4781
- x.s = -1;
4782
- } else {
4783
- x.s = 1;
3256
+ if (aInf) {
3257
+ const neg = aNeg !== bNeg;
3258
+ return _BigDecimal._create(0n, 0, neg ? SpecialValue.NEGATIVE_INFINITY : SpecialValue.POSITIVE_INFINITY, false);
4784
3259
  }
4785
- return parseDecimal(x, v.toString());
4786
- }
4787
- throw Error(invalidArgument + v);
4788
- }
4789
- Decimal2.prototype = P;
4790
- Decimal2.ROUND_UP = 0;
4791
- Decimal2.ROUND_DOWN = 1;
4792
- Decimal2.ROUND_CEIL = 2;
4793
- Decimal2.ROUND_FLOOR = 3;
4794
- Decimal2.ROUND_HALF_UP = 4;
4795
- Decimal2.ROUND_HALF_DOWN = 5;
4796
- Decimal2.ROUND_HALF_EVEN = 6;
4797
- Decimal2.ROUND_HALF_CEIL = 7;
4798
- Decimal2.ROUND_HALF_FLOOR = 8;
4799
- Decimal2.EUCLID = 9;
4800
- Decimal2.config = Decimal2.set = config;
4801
- Decimal2.clone = clone;
4802
- Decimal2.isDecimal = isDecimalInstance;
4803
- Decimal2.abs = abs;
4804
- Decimal2.acos = acos;
4805
- Decimal2.acosh = acosh;
4806
- Decimal2.add = add;
4807
- Decimal2.asin = asin;
4808
- Decimal2.asinh = asinh;
4809
- Decimal2.atan = atan;
4810
- Decimal2.atanh = atanh;
4811
- Decimal2.atan2 = atan2;
4812
- Decimal2.cbrt = cbrt;
4813
- Decimal2.ceil = ceil;
4814
- Decimal2.clamp = clamp;
4815
- Decimal2.cos = cos;
4816
- Decimal2.cosh = cosh;
4817
- Decimal2.div = div;
4818
- Decimal2.exp = exp;
4819
- Decimal2.floor = floor;
4820
- Decimal2.hypot = hypot;
4821
- Decimal2.ln = ln;
4822
- Decimal2.log = log;
4823
- Decimal2.log10 = log10;
4824
- Decimal2.log2 = log2;
4825
- Decimal2.max = max;
4826
- Decimal2.min = min;
4827
- Decimal2.mod = mod;
4828
- Decimal2.mul = mul;
4829
- Decimal2.pow = pow;
4830
- Decimal2.random = random;
4831
- Decimal2.round = round;
4832
- Decimal2.sign = sign;
4833
- Decimal2.sin = sin;
4834
- Decimal2.sinh = sinh;
4835
- Decimal2.sqrt = sqrt;
4836
- Decimal2.sub = sub;
4837
- Decimal2.sum = sum;
4838
- Decimal2.tan = tan;
4839
- Decimal2.tanh = tanh;
4840
- Decimal2.trunc = trunc;
4841
- if (obj === void 0)
4842
- obj = {};
4843
- if (obj) {
4844
- if (obj.defaults !== true) {
4845
- ps = ["precision", "rounding", "toExpNeg", "toExpPos", "maxE", "minE", "modulo", "crypto"];
4846
- for (i = 0; i < ps.length; )
4847
- if (!obj.hasOwnProperty(p = ps[i++]))
4848
- obj[p] = this[p];
4849
- }
4850
- }
4851
- Decimal2.config(obj);
4852
- return Decimal2;
4853
- }
4854
- function div(x, y) {
4855
- return new this(x).div(y);
4856
- }
4857
- function exp(x) {
4858
- return new this(x).exp();
4859
- }
4860
- function floor(x) {
4861
- return finalise(x = new this(x), x.e + 1, 3);
4862
- }
4863
- function hypot() {
4864
- var i, n, t = new this(0);
4865
- external = false;
4866
- for (i = 0; i < arguments.length; ) {
4867
- n = new this(arguments[i++]);
4868
- if (!n.d) {
4869
- if (n.s) {
4870
- external = true;
4871
- return new this(1 / 0);
4872
- }
4873
- t = n;
4874
- } else if (t.d) {
4875
- t = t.plus(n.times(n));
4876
- }
4877
- }
4878
- external = true;
4879
- return t.sqrt();
4880
- }
4881
- function isDecimalInstance(obj) {
4882
- return obj instanceof Decimal || obj && obj.toStringTag === tag || false;
4883
- }
4884
- function ln(x) {
4885
- return new this(x).ln();
4886
- }
4887
- function log(x, y) {
4888
- return new this(x).log(y);
4889
- }
4890
- function log2(x) {
4891
- return new this(x).log(2);
4892
- }
4893
- function log10(x) {
4894
- return new this(x).log(10);
4895
- }
4896
- function max() {
4897
- return maxOrMin(this, arguments, -1);
4898
- }
4899
- function min() {
4900
- return maxOrMin(this, arguments, 1);
4901
- }
4902
- function mod(x, y) {
4903
- return new this(x).mod(y);
4904
- }
4905
- function mul(x, y) {
4906
- return new this(x).mul(y);
4907
- }
4908
- function pow(x, y) {
4909
- return new this(x).pow(y);
4910
- }
4911
- function random(sd) {
4912
- var d, e, k, n, i = 0, r = new this(1), rd = [];
4913
- if (sd === void 0)
4914
- sd = this.precision;
4915
- else
4916
- checkInt32(sd, 1, MAX_DIGITS);
4917
- k = Math.ceil(sd / LOG_BASE);
4918
- if (!this.crypto) {
4919
- for (; i < k; )
4920
- rd[i++] = Math.random() * 1e7 | 0;
4921
- } else if (crypto.getRandomValues) {
4922
- d = crypto.getRandomValues(new Uint32Array(k));
4923
- for (; i < k; ) {
4924
- n = d[i];
4925
- if (n >= 429e7) {
4926
- d[i] = crypto.getRandomValues(new Uint32Array(1))[0];
4927
- } else {
4928
- rd[i++] = n % 1e7;
3260
+ if (bInf) {
3261
+ const negZero = aNeg !== bNeg;
3262
+ return _BigDecimal._create(0n, 0, SpecialValue.NONE, negZero);
4929
3263
  }
4930
3264
  }
4931
- } else if (crypto.randomBytes) {
4932
- d = crypto.randomBytes(k *= 4);
4933
- for (; i < k; ) {
4934
- n = d[i] + (d[i + 1] << 8) + (d[i + 2] << 16) + ((d[i + 3] & 127) << 24);
4935
- if (n >= 214e7) {
4936
- crypto.randomBytes(4).copy(d, i);
4937
- } else {
4938
- rd.push(n % 1e7);
4939
- i += 4;
3265
+ if (op === "plus") {
3266
+ if (aInf && bInf) {
3267
+ if (aNeg !== bNeg) {
3268
+ return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
3269
+ }
3270
+ return this;
4940
3271
  }
3272
+ if (aInf)
3273
+ return this;
3274
+ if (bInf)
3275
+ return other;
4941
3276
  }
4942
- i = k / 4;
4943
- } else {
4944
- throw Error(cryptoUnavailable);
4945
- }
4946
- k = rd[--i];
4947
- sd %= LOG_BASE;
4948
- if (k && sd) {
4949
- n = mathpow(10, LOG_BASE - sd);
4950
- rd[i] = (k / n | 0) * n;
4951
- }
4952
- for (; rd[i] === 0; i--)
4953
- rd.pop();
4954
- if (i < 0) {
4955
- e = 0;
4956
- rd = [0];
4957
- } else {
4958
- e = -1;
4959
- for (; rd[0] === 0; e -= LOG_BASE)
4960
- rd.shift();
4961
- for (k = 1, n = rd[0]; n >= 10; n /= 10)
4962
- k++;
4963
- if (k < LOG_BASE)
4964
- e -= LOG_BASE - k;
4965
- }
4966
- r.e = e;
4967
- r.d = rd;
4968
- return r;
4969
- }
4970
- function round(x) {
4971
- return finalise(x = new this(x), x.e + 1, this.rounding);
4972
- }
4973
- function sign(x) {
4974
- x = new this(x);
4975
- return x.d ? x.d[0] ? x.s : 0 * x.s : x.s || NaN;
4976
- }
4977
- function sin(x) {
4978
- return new this(x).sin();
4979
- }
4980
- function sinh(x) {
4981
- return new this(x).sinh();
4982
- }
4983
- function sqrt(x) {
4984
- return new this(x).sqrt();
4985
- }
4986
- function sub(x, y) {
4987
- return new this(x).sub(y);
4988
- }
4989
- function sum() {
4990
- var i = 0, args = arguments, x = new this(args[i]);
4991
- external = false;
4992
- for (; x.s && ++i < args.length; )
4993
- x = x.plus(args[i]);
4994
- external = true;
4995
- return finalise(x, this.precision, this.rounding);
4996
- }
4997
- function tan(x) {
4998
- return new this(x).tan();
4999
- }
5000
- function tanh(x) {
5001
- return new this(x).tanh();
5002
- }
5003
- function trunc(x) {
5004
- return finalise(x = new this(x), x.e + 1, 1);
5005
- }
5006
- P[Symbol.for("nodejs.util.inspect.custom")] = P.toString;
5007
- P[Symbol.toStringTag] = "Decimal";
5008
- var Decimal = P.constructor = clone(DEFAULTS);
5009
- LN10 = new Decimal(LN10);
5010
- PI = new Decimal(PI);
3277
+ return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
3278
+ }
3279
+ };
5011
3280
 
5012
3281
  // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/constants.js
5013
- var TEN = new Decimal(10);
5014
- var ZERO = new Decimal(0);
5015
- var NEGATIVE_ZERO = new Decimal(-0);
3282
+ var TEN = new BigDecimal(10);
3283
+ var ZERO = new BigDecimal(0);
3284
+ var NEGATIVE_ZERO = new BigDecimal(-0);
5016
3285
 
5017
3286
  // node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/index.js
5018
3287
  function memoize(fn, options) {
@@ -5148,15 +3417,9 @@ var ReactIntl = (() => {
5148
3417
 
5149
3418
  // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/decimal-cache.js
5150
3419
  var getPowerOf10 = memoize((exponent) => {
5151
- return Decimal.pow(10, exponent);
3420
+ return BigDecimal.pow(10, exponent);
5152
3421
  });
5153
3422
 
5154
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/ComputeExponentForMagnitude.js
5155
- Decimal.set({ toExpPos: 100 });
5156
-
5157
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/ToRawFixed.js
5158
- Decimal.set({ toExpPos: 100 });
5159
-
5160
3423
  // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/regex.generated.js
5161
3424
  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\u0888\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-\u20C1\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-\u2429\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E5\u31EF\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-\uFBD2\uFD40-\uFD4F\uFD90\uFD91\uFDC8-\uFDCF\uFDFC-\uFDFF\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]|\uD803[\uDD8E\uDD8F\uDED1-\uDED8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDC00-\uDCEF\uDCFA-\uDCFC\uDD00-\uDEB3\uDEBA-\uDED0\uDEE0-\uDEF0\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\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-\uDED8\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0-\uDCBB\uDCC0\uDCC1\uDCD0-\uDCD8\uDD00-\uDE57\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF-\uDEF8\uDF00-\uDF92\uDF94-\uDFEF\uDFFA]/;
5162
3425
 
@@ -8350,9 +6613,8 @@ var ReactIntl = (() => {
8350
6613
  // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/utils.js
8351
6614
  var PROCESSED_DATA;
8352
6615
  function processData() {
8353
- var _a, _b;
8354
6616
  if (!PROCESSED_DATA) {
8355
- const paradigmLocales = (_b = (_a = data.supplemental.languageMatching["written-new"][0]) == null ? void 0 : _a.paradigmLocales) == null ? void 0 : _b._locales.split(" ");
6617
+ const paradigmLocales = data.supplemental.languageMatching["written-new"][0]?.paradigmLocales?._locales.split(" ");
8356
6618
  const matchVariables = data.supplemental.languageMatching["written-new"].slice(1, 5);
8357
6619
  const data2 = data.supplemental.languageMatching["written-new"].slice(5);
8358
6620
  const matches = data2.map((d) => {
@@ -8664,10 +6926,17 @@ Try polyfilling it using "@formatjs/intl-pluralrules"
8664
6926
  if (!c2) {
8665
6927
  return c1;
8666
6928
  }
8667
- return __spreadValues(__spreadValues(__spreadValues({}, c1), c2), Object.keys(c1).reduce((all, k) => {
8668
- all[k] = __spreadValues(__spreadValues({}, c1[k]), c2[k]);
8669
- return all;
8670
- }, {}));
6929
+ return {
6930
+ ...c1,
6931
+ ...c2,
6932
+ ...Object.keys(c1).reduce((all, k) => {
6933
+ all[k] = {
6934
+ ...c1[k],
6935
+ ...c2[k]
6936
+ };
6937
+ return all;
6938
+ }, {})
6939
+ };
8671
6940
  }
8672
6941
  function mergeConfigs(defaultConfig, configs) {
8673
6942
  if (!configs) {
@@ -8676,7 +6945,7 @@ Try polyfilling it using "@formatjs/intl-pluralrules"
8676
6945
  return Object.keys(defaultConfig).reduce((all, k) => {
8677
6946
  all[k] = mergeConfig(defaultConfig[k], configs[k]);
8678
6947
  return all;
8679
- }, __spreadValues({}, defaultConfig));
6948
+ }, { ...defaultConfig });
8680
6949
  }
8681
6950
  function createFastMemoizeCache(store) {
8682
6951
  return { create() {
@@ -8742,10 +7011,7 @@ Try polyfilling it using "@formatjs/intl-pluralrules"
8742
7011
  return result;
8743
7012
  });
8744
7013
  __publicField(this, "formatToParts", (values) => formatToParts2(this.ast, this.locales, this.formatters, this.formats, values, void 0, this.message));
8745
- __publicField(this, "resolvedOptions", () => {
8746
- var _a;
8747
- return { locale: ((_a = this.resolvedLocale) == null ? void 0 : _a.toString()) || Intl.NumberFormat.supportedLocalesOf(this.locales)[0] };
8748
- });
7014
+ __publicField(this, "resolvedOptions", () => ({ locale: this.resolvedLocale?.toString() || Intl.NumberFormat.supportedLocalesOf(this.locales)[0] }));
8749
7015
  __publicField(this, "getAst", () => this.ast);
8750
7016
  this.locales = locales;
8751
7017
  this.resolvedLocale = _IntlMessageFormat.resolveLocale(locales);
@@ -8754,10 +7020,11 @@ Try polyfilling it using "@formatjs/intl-pluralrules"
8754
7020
  if (!_IntlMessageFormat.__parse) {
8755
7021
  throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");
8756
7022
  }
8757
- const parseOpts = __objRest(opts || {}, []);
8758
- this.ast = _IntlMessageFormat.__parse(message, __spreadProps(__spreadValues({}, parseOpts), {
7023
+ const { ...parseOpts } = opts || {};
7024
+ this.ast = _IntlMessageFormat.__parse(message, {
7025
+ ...parseOpts,
8759
7026
  locale: this.resolvedLocale
8760
- }));
7027
+ });
8761
7028
  } else {
8762
7029
  this.ast = message;
8763
7030
  }
@@ -8895,9 +7162,9 @@ Locale: ${locale}
8895
7162
  var MessageFormatError = class extends IntlFormatError {
8896
7163
  constructor(message, locale, descriptor, exception) {
8897
7164
  super(`${message}
8898
- MessageID: ${descriptor == null ? void 0 : descriptor.id}
8899
- Default Message: ${descriptor == null ? void 0 : descriptor.defaultMessage}
8900
- Description: ${descriptor == null ? void 0 : descriptor.description}
7165
+ MessageID: ${descriptor?.id}
7166
+ Default Message: ${descriptor?.defaultMessage}
7167
+ Description: ${descriptor?.description}
8901
7168
  `, locale, exception);
8902
7169
  __publicField(this, "descriptor");
8903
7170
  __publicField(this, "locale");
@@ -8907,10 +7174,7 @@ Description: ${descriptor == null ? void 0 : descriptor.description}
8907
7174
  };
8908
7175
  var MissingTranslationError = class extends IntlError {
8909
7176
  constructor(descriptor, locale) {
8910
- super(IntlErrorCode.MISSING_TRANSLATION, `Missing message: "${descriptor.id}" for locale "${locale}", using ${descriptor.defaultMessage ? `default message (${typeof descriptor.defaultMessage === "string" ? descriptor.defaultMessage : descriptor.defaultMessage.map((e) => {
8911
- var _a;
8912
- return (_a = e.value) != null ? _a : JSON.stringify(e);
8913
- }).join()})` : "id"} as fallback.`);
7177
+ super(IntlErrorCode.MISSING_TRANSLATION, `Missing message: "${descriptor.id}" for locale "${locale}", using ${descriptor.defaultMessage ? `default message (${typeof descriptor.defaultMessage === "string" ? descriptor.defaultMessage : descriptor.defaultMessage.map((e) => e.value ?? JSON.stringify(e)).join()})` : "id"} as fallback.`);
8914
7178
  __publicField(this, "descriptor");
8915
7179
  this.descriptor = descriptor;
8916
7180
  }
@@ -8994,13 +7258,14 @@ Description: ${descriptor == null ? void 0 : descriptor.description}
8994
7258
  return {
8995
7259
  getDateTimeFormat,
8996
7260
  getNumberFormat,
8997
- getMessageFormat: memoize((message, locales, overrideFormats, opts) => new IntlMessageFormat(message, locales, overrideFormats, __spreadValues({
7261
+ getMessageFormat: memoize((message, locales, overrideFormats, opts) => new IntlMessageFormat(message, locales, overrideFormats, {
8998
7262
  formatters: {
8999
7263
  getNumberFormat,
9000
7264
  getDateTimeFormat,
9001
7265
  getPluralRules
9002
- }
9003
- }, opts)), {
7266
+ },
7267
+ ...opts
7268
+ }), {
9004
7269
  cache: createFastMemoizeCache2(cache.message),
9005
7270
  strategy: strategies.variadic
9006
7271
  }),
@@ -9034,16 +7299,23 @@ Description: ${descriptor == null ? void 0 : descriptor.description}
9034
7299
  // node_modules/.aspect_rules_js/@formatjs+intl@0.0.0/node_modules/@formatjs/intl/src/message.js
9035
7300
  function setTimeZoneInOptions(opts, timeZone) {
9036
7301
  return Object.keys(opts).reduce((all, k) => {
9037
- all[k] = __spreadValues({
9038
- timeZone
9039
- }, opts[k]);
7302
+ all[k] = {
7303
+ timeZone,
7304
+ ...opts[k]
7305
+ };
9040
7306
  return all;
9041
7307
  }, {});
9042
7308
  }
9043
7309
  function deepMergeOptions(opts1, opts2) {
9044
- const keys = Object.keys(__spreadValues(__spreadValues({}, opts1), opts2));
7310
+ const keys = Object.keys({
7311
+ ...opts1,
7312
+ ...opts2
7313
+ });
9045
7314
  return keys.reduce((all, k) => {
9046
- all[k] = __spreadValues(__spreadValues({}, opts1[k]), opts2[k]);
7315
+ all[k] = {
7316
+ ...opts1[k],
7317
+ ...opts2[k]
7318
+ };
9047
7319
  return all;
9048
7320
  }, {});
9049
7321
  }
@@ -9052,10 +7324,12 @@ Description: ${descriptor == null ? void 0 : descriptor.description}
9052
7324
  return f1;
9053
7325
  }
9054
7326
  const mfFormats = IntlMessageFormat.formats;
9055
- return __spreadProps(__spreadValues(__spreadValues({}, mfFormats), f1), {
7327
+ return {
7328
+ ...mfFormats,
7329
+ ...f1,
9056
7330
  date: deepMergeOptions(setTimeZoneInOptions(mfFormats.date, timeZone), setTimeZoneInOptions(f1.date || {}, timeZone)),
9057
7331
  time: deepMergeOptions(setTimeZoneInOptions(mfFormats.time, timeZone), setTimeZoneInOptions(f1.time || {}, timeZone))
9058
- });
7332
+ };
9059
7333
  }
9060
7334
  var formatMessage = ({ locale, formats, messages, defaultLocale, defaultFormats, fallbackOnEmptyString, onError, timeZone, defaultRichTextElements }, state, messageDescriptor = { id: "" }, values, opts) => {
9061
7335
  const { id: msgId, defaultMessage } = messageDescriptor;
@@ -9069,7 +7343,10 @@ to autofix this issue`);
9069
7343
  if (Array.isArray(message) && message.length === 1 && message[0].type === TYPE.literal) {
9070
7344
  return message[0].value;
9071
7345
  }
9072
- values = __spreadValues(__spreadValues({}, defaultRichTextElements), values);
7346
+ values = {
7347
+ ...defaultRichTextElements,
7348
+ ...values
7349
+ };
9073
7350
  formats = deepMergeFormatsAndSetTimeZone(formats, timeZone);
9074
7351
  defaultFormats = deepMergeFormatsAndSetTimeZone(defaultFormats, timeZone);
9075
7352
  if (!message) {
@@ -9091,9 +7368,10 @@ to autofix this issue`);
9091
7368
  return id;
9092
7369
  }
9093
7370
  try {
9094
- const formatter = state.getMessageFormat(message, locale, formats, __spreadValues({
9095
- formatters: state
9096
- }, opts));
7371
+ const formatter = state.getMessageFormat(message, locale, formats, {
7372
+ formatters: state,
7373
+ ...opts
7374
+ });
9097
7375
  return formatter.format(values);
9098
7376
  } catch (e) {
9099
7377
  onError(new MessageFormatError(`Error formatting message: "${id}", using ${defaultMessage ? "default message" : "id"} as fallback.`, locale, messageDescriptor, e));
@@ -9138,59 +7416,63 @@ to autofix this issue`);
9138
7416
  ];
9139
7417
  function getFormatter({ locale, formats, onError, timeZone }, type, getDateTimeFormat, options = {}) {
9140
7418
  const { format } = options;
9141
- const defaults = __spreadValues(__spreadValues({}, timeZone && { timeZone }), format && getNamedFormat(formats, type, format, onError));
7419
+ const defaults = {
7420
+ ...timeZone && { timeZone },
7421
+ ...format && getNamedFormat(formats, type, format, onError)
7422
+ };
9142
7423
  let filteredOptions = filterProps(options, DATE_TIME_FORMAT_OPTIONS, defaults);
9143
7424
  if (type === "time" && !filteredOptions.hour && !filteredOptions.minute && !filteredOptions.second && !filteredOptions.timeStyle && !filteredOptions.dateStyle) {
9144
- filteredOptions = __spreadProps(__spreadValues({}, filteredOptions), {
7425
+ filteredOptions = {
7426
+ ...filteredOptions,
9145
7427
  hour: "numeric",
9146
7428
  minute: "numeric"
9147
- });
7429
+ };
9148
7430
  }
9149
7431
  return getDateTimeFormat(locale, filteredOptions);
9150
7432
  }
9151
- function formatDate(config2, getDateTimeFormat, value, options = {}) {
7433
+ function formatDate(config, getDateTimeFormat, value, options = {}) {
9152
7434
  const date = typeof value === "string" ? new Date(value || 0) : value;
9153
7435
  try {
9154
- return getFormatter(config2, "date", getDateTimeFormat, options).format(date);
7436
+ return getFormatter(config, "date", getDateTimeFormat, options).format(date);
9155
7437
  } catch (e) {
9156
- config2.onError(new IntlFormatError("Error formatting date.", config2.locale, e));
7438
+ config.onError(new IntlFormatError("Error formatting date.", config.locale, e));
9157
7439
  }
9158
7440
  return String(date);
9159
7441
  }
9160
- function formatTime(config2, getDateTimeFormat, value, options = {}) {
7442
+ function formatTime(config, getDateTimeFormat, value, options = {}) {
9161
7443
  const date = typeof value === "string" ? new Date(value || 0) : value;
9162
7444
  try {
9163
- return getFormatter(config2, "time", getDateTimeFormat, options).format(date);
7445
+ return getFormatter(config, "time", getDateTimeFormat, options).format(date);
9164
7446
  } catch (e) {
9165
- config2.onError(new IntlFormatError("Error formatting time.", config2.locale, e));
7447
+ config.onError(new IntlFormatError("Error formatting time.", config.locale, e));
9166
7448
  }
9167
7449
  return String(date);
9168
7450
  }
9169
- function formatDateTimeRange(config2, getDateTimeFormat, from, to, options = {}) {
7451
+ function formatDateTimeRange(config, getDateTimeFormat, from, to, options = {}) {
9170
7452
  const fromDate = typeof from === "string" ? new Date(from || 0) : from;
9171
7453
  const toDate = typeof to === "string" ? new Date(to || 0) : to;
9172
7454
  try {
9173
- return getFormatter(config2, "dateTimeRange", getDateTimeFormat, options).formatRange(fromDate, toDate);
7455
+ return getFormatter(config, "dateTimeRange", getDateTimeFormat, options).formatRange(fromDate, toDate);
9174
7456
  } catch (e) {
9175
- config2.onError(new IntlFormatError("Error formatting date time range.", config2.locale, e));
7457
+ config.onError(new IntlFormatError("Error formatting date time range.", config.locale, e));
9176
7458
  }
9177
7459
  return String(fromDate);
9178
7460
  }
9179
- function formatDateToParts(config2, getDateTimeFormat, value, options = {}) {
7461
+ function formatDateToParts(config, getDateTimeFormat, value, options = {}) {
9180
7462
  const date = typeof value === "string" ? new Date(value || 0) : value;
9181
7463
  try {
9182
- return getFormatter(config2, "date", getDateTimeFormat, options).formatToParts(date);
7464
+ return getFormatter(config, "date", getDateTimeFormat, options).formatToParts(date);
9183
7465
  } catch (e) {
9184
- config2.onError(new IntlFormatError("Error formatting date.", config2.locale, e));
7466
+ config.onError(new IntlFormatError("Error formatting date.", config.locale, e));
9185
7467
  }
9186
7468
  return [];
9187
7469
  }
9188
- function formatTimeToParts(config2, getDateTimeFormat, value, options = {}) {
7470
+ function formatTimeToParts(config, getDateTimeFormat, value, options = {}) {
9189
7471
  const date = typeof value === "string" ? new Date(value || 0) : value;
9190
7472
  try {
9191
- return getFormatter(config2, "time", getDateTimeFormat, options).formatToParts(date);
7473
+ return getFormatter(config, "time", getDateTimeFormat, options).formatToParts(date);
9192
7474
  } catch (e) {
9193
- config2.onError(new IntlFormatError("Error formatting time.", config2.locale, e));
7475
+ config.onError(new IntlFormatError("Error formatting time.", config.locale, e));
9194
7476
  }
9195
7477
  return [];
9196
7478
  }
@@ -9255,9 +7537,10 @@ Try polyfilling it using "@formatjs/intl-listformat"
9255
7537
  }
9256
7538
  return String(v);
9257
7539
  });
9258
- return getListFormat(locale, filteredOptions).formatToParts(serializedValues).map((part) => part.type === "literal" ? part : __spreadProps(__spreadValues({}, part), {
7540
+ return getListFormat(locale, filteredOptions).formatToParts(serializedValues).map((part) => part.type === "literal" ? part : {
7541
+ ...part,
9259
7542
  value: richValues[part.value] || part.value
9260
- }));
7543
+ });
9261
7544
  } catch (e) {
9262
7545
  onError(new IntlFormatError("Error formatting list.", locale, e));
9263
7546
  }
@@ -9289,20 +7572,20 @@ Try polyfilling it using "@formatjs/intl-pluralrules"
9289
7572
  const filteredOptions = filterProps(options, RELATIVE_TIME_FORMAT_OPTIONS, defaults);
9290
7573
  return getRelativeTimeFormat(locale, filteredOptions);
9291
7574
  }
9292
- function formatRelativeTime(config2, getRelativeTimeFormat, value, unit, options = {}) {
7575
+ function formatRelativeTime(config, getRelativeTimeFormat, value, unit, options = {}) {
9293
7576
  if (!unit) {
9294
7577
  unit = "second";
9295
7578
  }
9296
7579
  const RelativeTimeFormat = Intl.RelativeTimeFormat;
9297
7580
  if (!RelativeTimeFormat) {
9298
- config2.onError(new FormatError(`Intl.RelativeTimeFormat is not available in this environment.
7581
+ config.onError(new FormatError(`Intl.RelativeTimeFormat is not available in this environment.
9299
7582
  Try polyfilling it using "@formatjs/intl-relativetimeformat"
9300
7583
  `, ErrorCode.MISSING_INTL_API));
9301
7584
  }
9302
7585
  try {
9303
- return getFormatter2(config2, getRelativeTimeFormat, options).format(value, unit);
7586
+ return getFormatter2(config, getRelativeTimeFormat, options).format(value, unit);
9304
7587
  } catch (e) {
9305
- config2.onError(new IntlFormatError("Error formatting relative time.", config2.locale, e));
7588
+ config.onError(new IntlFormatError("Error formatting relative time.", config.locale, e));
9306
7589
  }
9307
7590
  return String(value);
9308
7591
  }
@@ -9338,19 +7621,19 @@ Try polyfilling it using "@formatjs/intl-relativetimeformat"
9338
7621
  const filteredOptions = filterProps(options, NUMBER_FORMAT_OPTIONS, defaults);
9339
7622
  return getNumberFormat(locale, filteredOptions);
9340
7623
  }
9341
- function formatNumber(config2, getNumberFormat, value, options = {}) {
7624
+ function formatNumber(config, getNumberFormat, value, options = {}) {
9342
7625
  try {
9343
- return getFormatter3(config2, getNumberFormat, options).format(value);
7626
+ return getFormatter3(config, getNumberFormat, options).format(value);
9344
7627
  } catch (e) {
9345
- config2.onError(new IntlFormatError("Error formatting number.", config2.locale, e));
7628
+ config.onError(new IntlFormatError("Error formatting number.", config.locale, e));
9346
7629
  }
9347
7630
  return String(value);
9348
7631
  }
9349
- function formatNumberToParts(config2, getNumberFormat, value, options = {}) {
7632
+ function formatNumberToParts(config, getNumberFormat, value, options = {}) {
9350
7633
  try {
9351
- return getFormatter3(config2, getNumberFormat, options).formatToParts(value);
7634
+ return getFormatter3(config, getNumberFormat, options).formatToParts(value);
9352
7635
  } catch (e) {
9353
- config2.onError(new IntlFormatError("Error formatting number.", config2.locale, e));
7636
+ config.onError(new IntlFormatError("Error formatting number.", config.locale, e));
9354
7637
  }
9355
7638
  return [];
9356
7639
  }
@@ -9360,16 +7643,19 @@ Try polyfilling it using "@formatjs/intl-relativetimeformat"
9360
7643
  const firstMessage = messages ? messages[Object.keys(messages)[0]] : void 0;
9361
7644
  return typeof firstMessage === "string";
9362
7645
  }
9363
- function verifyConfigMessages(config2) {
9364
- if (config2.onWarn && config2.defaultRichTextElements && messagesContainString(config2.messages || {})) {
9365
- config2.onWarn(`[@formatjs/intl] "defaultRichTextElements" was specified but "message" was not pre-compiled.
7646
+ function verifyConfigMessages(config) {
7647
+ if (config.onWarn && config.defaultRichTextElements && messagesContainString(config.messages || {})) {
7648
+ config.onWarn(`[@formatjs/intl] "defaultRichTextElements" was specified but "message" was not pre-compiled.
9366
7649
  Please consider using "@formatjs/cli" to pre-compile your messages for performance.
9367
7650
  For more details see https://formatjs.github.io/docs/getting-started/message-distribution`);
9368
7651
  }
9369
7652
  }
9370
- function createIntl(config2, cache) {
7653
+ function createIntl(config, cache) {
9371
7654
  const formatters = createFormatters(cache);
9372
- const resolvedConfig = __spreadValues(__spreadValues({}, DEFAULT_INTL_CONFIG), config2);
7655
+ const resolvedConfig = {
7656
+ ...DEFAULT_INTL_CONFIG,
7657
+ ...config
7658
+ };
9373
7659
  const { locale, defaultLocale, onError } = resolvedConfig;
9374
7660
  if (!locale) {
9375
7661
  if (onError) {
@@ -9382,7 +7668,8 @@ For more details see https://formatjs.github.io/docs/getting-started/message-dis
9382
7668
  onError(new MissingDataError(`Missing locale data for locale: "${locale}" in Intl.DateTimeFormat. Using default locale: "${defaultLocale}" as fallback. See https://formatjs.github.io/docs/react-intl#runtime-requirements for more details`));
9383
7669
  }
9384
7670
  verifyConfigMessages(resolvedConfig);
9385
- return __spreadProps(__spreadValues({}, resolvedConfig), {
7671
+ return {
7672
+ ...resolvedConfig,
9386
7673
  formatters,
9387
7674
  formatNumber: formatNumber.bind(null, resolvedConfig, formatters.getNumberFormat),
9388
7675
  formatNumberToParts: formatNumberToParts.bind(null, resolvedConfig, formatters.getNumberFormat),
@@ -9398,7 +7685,7 @@ For more details see https://formatjs.github.io/docs/getting-started/message-dis
9398
7685
  formatList: formatList.bind(null, resolvedConfig, formatters.getListFormat),
9399
7686
  formatListToParts: formatListToParts.bind(null, resolvedConfig, formatters.getListFormat),
9400
7687
  formatDisplayName: formatDisplayName.bind(null, resolvedConfig, formatters.getDisplayNames)
9401
- });
7688
+ };
9402
7689
  }
9403
7690
 
9404
7691
  // packages/react-intl/src/utils.tsx
@@ -9413,9 +7700,10 @@ For more details see https://formatjs.github.io/docs/getting-started/message-dis
9413
7700
  "[React Intl] Could not find required `intl` object. <IntlProvider> needs to exist in the component ancestry."
9414
7701
  );
9415
7702
  }
9416
- var DEFAULT_INTL_CONFIG2 = __spreadProps(__spreadValues({}, DEFAULT_INTL_CONFIG), {
7703
+ var DEFAULT_INTL_CONFIG2 = {
7704
+ ...DEFAULT_INTL_CONFIG,
9417
7705
  textComponent: React.Fragment
9418
- });
7706
+ };
9419
7707
  var toKeyedReactNodeArray = (children) => {
9420
7708
  const childrenArray = React.Children.toArray(children);
9421
7709
  return childrenArray.map((child, index) => {
@@ -9484,20 +7772,20 @@ For more details see https://formatjs.github.io/docs/getting-started/message-dis
9484
7772
  })(DisplayNameParts || {});
9485
7773
  var FormattedNumberParts = (props) => {
9486
7774
  const intl = useIntl();
9487
- const _a = props, { value, children } = _a, formatProps = __objRest(_a, ["value", "children"]);
7775
+ const { value, children, ...formatProps } = props;
9488
7776
  return children(intl.formatNumberToParts(value, formatProps));
9489
7777
  };
9490
7778
  FormattedNumberParts.displayName = "FormattedNumberParts";
9491
7779
  var FormattedListParts = (props) => {
9492
7780
  const intl = useIntl();
9493
- const _a = props, { value, children } = _a, formatProps = __objRest(_a, ["value", "children"]);
7781
+ const { value, children, ...formatProps } = props;
9494
7782
  return children(intl.formatListToParts(value, formatProps));
9495
7783
  };
9496
7784
  FormattedNumberParts.displayName = "FormattedNumberParts";
9497
7785
  function createFormattedDateTimePartsComponent(name) {
9498
7786
  const ComponentParts = (props) => {
9499
7787
  const intl = useIntl();
9500
- const _a = props, { value, children } = _a, formatProps = __objRest(_a, ["value", "children"]);
7788
+ const { value, children, ...formatProps } = props;
9501
7789
  const date = typeof value === "string" ? new Date(value || 0) : value;
9502
7790
  const formattedParts = name === "formatDate" ? intl.formatDateToParts(date, formatProps) : intl.formatTimeToParts(date, formatProps);
9503
7791
  return children(formattedParts);
@@ -9508,7 +7796,7 @@ For more details see https://formatjs.github.io/docs/getting-started/message-dis
9508
7796
  function createFormattedComponent(name) {
9509
7797
  const Component = (props) => {
9510
7798
  const intl = useIntl();
9511
- const _a = props, { value, children } = _a, formatProps = __objRest(_a, ["value", "children"]);
7799
+ const { value, children, ...formatProps } = props;
9512
7800
  const formattedValue = intl[name](value, formatProps);
9513
7801
  if (typeof children === "function") {
9514
7802
  return children(formattedValue);
@@ -9531,10 +7819,10 @@ For more details see https://formatjs.github.io/docs/getting-started/message-dis
9531
7819
  return acc;
9532
7820
  }, {});
9533
7821
  }
9534
- var formatMessage2 = (config2, formatters, descriptor, rawValues, ...rest) => {
7822
+ var formatMessage2 = (config, formatters, descriptor, rawValues, ...rest) => {
9535
7823
  const values = assignUniqueKeysToFormatXMLElementFnArgument(rawValues);
9536
7824
  const chunks = formatMessage(
9537
- config2,
7825
+ config,
9538
7826
  formatters,
9539
7827
  descriptor,
9540
7828
  values,
@@ -9545,15 +7833,16 @@ For more details see https://formatjs.github.io/docs/getting-started/message-dis
9545
7833
  }
9546
7834
  return chunks;
9547
7835
  };
9548
- var createIntl2 = (_a, cache) => {
9549
- var _b = _a, { defaultRichTextElements: rawDefaultRichTextElements } = _b, config2 = __objRest(_b, ["defaultRichTextElements"]);
7836
+ var createIntl2 = ({ defaultRichTextElements: rawDefaultRichTextElements, ...config }, cache) => {
9550
7837
  const defaultRichTextElements = assignUniqueKeysToFormatXMLElementFnArgument(
9551
7838
  rawDefaultRichTextElements
9552
7839
  );
9553
7840
  const coreIntl = createIntl(
9554
- __spreadProps(__spreadValues(__spreadValues({}, DEFAULT_INTL_CONFIG2), config2), {
7841
+ {
7842
+ ...DEFAULT_INTL_CONFIG2,
7843
+ ...config,
9555
7844
  defaultRichTextElements
9556
- }),
7845
+ },
9557
7846
  cache
9558
7847
  );
9559
7848
  const resolvedConfig = {
@@ -9567,21 +7856,22 @@ For more details see https://formatjs.github.io/docs/getting-started/message-dis
9567
7856
  onError: coreIntl.onError,
9568
7857
  defaultRichTextElements
9569
7858
  };
9570
- return __spreadProps(__spreadValues({}, coreIntl), {
7859
+ return {
7860
+ ...coreIntl,
9571
7861
  formatMessage: formatMessage2.bind(
9572
7862
  null,
9573
7863
  resolvedConfig,
9574
7864
  coreIntl.formatters
9575
7865
  ),
9576
7866
  $t: formatMessage2.bind(null, resolvedConfig, coreIntl.formatters)
9577
- });
7867
+ };
9578
7868
  };
9579
7869
 
9580
7870
  // packages/react-intl/src/components/dateTimeRange.tsx
9581
7871
  var React5 = __toESM(window.React);
9582
7872
  var FormattedDateTimeRange = (props) => {
9583
7873
  const intl = useIntl();
9584
- const _a = props, { from, to, children } = _a, formatProps = __objRest(_a, ["from", "to", "children"]);
7874
+ const { from, to, children, ...formatProps } = props;
9585
7875
  const formattedValue = intl.formatDateTimeRange(from, to, formatProps);
9586
7876
  if (typeof children === "function") {
9587
7877
  return children(formattedValue);
@@ -9595,8 +7885,8 @@ For more details see https://formatjs.github.io/docs/getting-started/message-dis
9595
7885
  // packages/react-intl/src/components/message.tsx
9596
7886
  var React6 = __toESM(window.React);
9597
7887
  function areEqual(prevProps, nextProps) {
9598
- const _a = prevProps, { values } = _a, otherProps = __objRest(_a, ["values"]);
9599
- const _b = nextProps, { values: nextValues } = _b, nextOtherProps = __objRest(_b, ["values"]);
7888
+ const { values, ...otherProps } = prevProps;
7889
+ const { values: nextValues, ...nextOtherProps } = nextProps;
9600
7890
  return shallowEqual(nextValues, values) && shallowEqual(otherProps, nextOtherProps);
9601
7891
  }
9602
7892
  function FormattedMessage(props) {
@@ -9651,20 +7941,20 @@ For more details see https://formatjs.github.io/docs/getting-started/message-dis
9651
7941
 
9652
7942
  // packages/react-intl/src/components/provider.tsx
9653
7943
  var React8 = __toESM(window.React);
9654
- function processIntlConfig(config2) {
7944
+ function processIntlConfig(config) {
9655
7945
  return {
9656
- locale: config2.locale,
9657
- timeZone: config2.timeZone,
9658
- fallbackOnEmptyString: config2.fallbackOnEmptyString,
9659
- formats: config2.formats,
9660
- textComponent: config2.textComponent,
9661
- messages: config2.messages,
9662
- defaultLocale: config2.defaultLocale,
9663
- defaultFormats: config2.defaultFormats,
9664
- onError: config2.onError,
9665
- onWarn: config2.onWarn,
9666
- wrapRichTextChunksInFragment: config2.wrapRichTextChunksInFragment,
9667
- defaultRichTextElements: config2.defaultRichTextElements
7946
+ locale: config.locale,
7947
+ timeZone: config.timeZone,
7948
+ fallbackOnEmptyString: config.fallbackOnEmptyString,
7949
+ formats: config.formats,
7950
+ textComponent: config.textComponent,
7951
+ messages: config.messages,
7952
+ defaultLocale: config.defaultLocale,
7953
+ defaultFormats: config.defaultFormats,
7954
+ onError: config.onError,
7955
+ onWarn: config.onWarn,
7956
+ wrapRichTextChunksInFragment: config.wrapRichTextChunksInFragment,
7957
+ defaultRichTextElements: config.defaultRichTextElements
9668
7958
  };
9669
7959
  }
9670
7960
  function IntlProviderImpl(props) {
@@ -9677,10 +7967,13 @@ For more details see https://formatjs.github.io/docs/getting-started/message-dis
9677
7967
  filteredProps[key] = props[key];
9678
7968
  }
9679
7969
  }
9680
- const config2 = processIntlConfig(__spreadValues(__spreadValues({}, DEFAULT_INTL_CONFIG2), filteredProps));
9681
- if (!prevConfigRef.current || !shallowEqual(prevConfigRef.current, config2)) {
9682
- prevConfigRef.current = config2;
9683
- intlRef.current = createIntl2(config2, cacheRef.current);
7970
+ const config = processIntlConfig({
7971
+ ...DEFAULT_INTL_CONFIG2,
7972
+ ...filteredProps
7973
+ });
7974
+ if (!prevConfigRef.current || !shallowEqual(prevConfigRef.current, config)) {
7975
+ prevConfigRef.current = config;
7976
+ intlRef.current = createIntl2(config, cacheRef.current);
9684
7977
  }
9685
7978
  invariantIntlContext(intlRef.current);
9686
7979
  return React8.createElement(Provider, { value: intlRef.current }, props.children);
@@ -9742,7 +8035,7 @@ For more details see https://formatjs.github.io/docs/getting-started/message-dis
9742
8035
  }
9743
8036
  var SimpleFormattedRelativeTime = (props) => {
9744
8037
  const { formatRelativeTime: formatRelativeTime2, textComponent: Text } = useIntl();
9745
- const _a = props, { children, value, unit } = _a, otherProps = __objRest(_a, ["children", "value", "unit"]);
8038
+ const { children, value, unit, ...otherProps } = props;
9746
8039
  const formattedRelativeTime = formatRelativeTime2(value || 0, unit, otherProps);
9747
8040
  if (typeof children === "function") {
9748
8041
  return children(formattedRelativeTime);
@@ -9752,16 +8045,12 @@ For more details see https://formatjs.github.io/docs/getting-started/message-dis
9752
8045
  }
9753
8046
  return React9.createElement(React9.Fragment, null, formattedRelativeTime);
9754
8047
  };
9755
- var FormattedRelativeTime = (_a) => {
9756
- var _b = _a, {
9757
- value = 0,
9758
- unit = "second",
9759
- updateIntervalInSeconds
9760
- } = _b, otherProps = __objRest(_b, [
9761
- "value",
9762
- "unit",
9763
- "updateIntervalInSeconds"
9764
- ]);
8048
+ var FormattedRelativeTime = ({
8049
+ value = 0,
8050
+ unit = "second",
8051
+ updateIntervalInSeconds,
8052
+ ...otherProps
8053
+ }) => {
9765
8054
  invariant4(
9766
8055
  !updateIntervalInSeconds || !!(updateIntervalInSeconds && canIncrement(unit)),
9767
8056
  "Cannot schedule update with unit longer than hour"
@@ -9814,10 +8103,11 @@ For more details see https://formatjs.github.io/docs/getting-started/message-dis
9814
8103
  }
9815
8104
  return React9.createElement(
9816
8105
  SimpleFormattedRelativeTime,
9817
- __spreadValues({
8106
+ {
9818
8107
  value: currentValue,
9819
- unit: currentUnit
9820
- }, otherProps)
8108
+ unit: currentUnit,
8109
+ ...otherProps
8110
+ }
9821
8111
  );
9822
8112
  };
9823
8113
  FormattedRelativeTime.displayName = "FormattedRelativeTime";
@@ -9839,15 +8129,4 @@ For more details see https://formatjs.github.io/docs/getting-started/message-dis
9839
8129
  var FormattedTimeParts = createFormattedDateTimePartsComponent("formatTime");
9840
8130
  return __toCommonJS(react_intl_exports);
9841
8131
  })();
9842
- /*! Bundled license information:
9843
-
9844
- decimal.js/decimal.mjs:
9845
- (*!
9846
- * decimal.js v10.6.0
9847
- * An arbitrary-precision Decimal type for JavaScript.
9848
- * https://github.com/MikeMcl/decimal.js
9849
- * Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
9850
- * MIT Licence
9851
- *)
9852
- */
9853
8132
  //# sourceMappingURL=react-intl.esbuild.iife.js.map