@amboras-dev/money 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/README.md +15 -8
  2. package/dist/ai.cjs +12 -13
  3. package/dist/ai.d.cts +5 -9
  4. package/dist/ai.d.ts +5 -9
  5. package/dist/ai.js +12 -13
  6. package/dist/{allocate-CZRg4TOP.cjs → allocate-AusholrC.cjs} +3 -4
  7. package/dist/{allocate-X7_jAtOj.js → allocate-BBRfdaSC.js} +3 -4
  8. package/dist/{amount-BV0O-aN8.cjs → amount-CwFzcxUl.cjs} +29 -12
  9. package/dist/{amount-BoYBMgK9.js → amount-DHFOK2Yd.js} +29 -12
  10. package/dist/{arithmetic-BhNwisjb.js → arithmetic-C97-YafD.js} +4 -5
  11. package/dist/{arithmetic-DjT4Kzgt.cjs → arithmetic-D8A6IeZ0.cjs} +4 -5
  12. package/dist/billing.cjs +5 -8
  13. package/dist/billing.d.cts +1 -9
  14. package/dist/billing.d.ts +1 -9
  15. package/dist/billing.js +5 -8
  16. package/dist/commerce.cjs +15 -23
  17. package/dist/commerce.d.cts +2 -16
  18. package/dist/commerce.d.ts +2 -16
  19. package/dist/commerce.js +15 -23
  20. package/dist/{format-DLhno7eX.cjs → format-92fzvTXY.cjs} +9 -9
  21. package/dist/{format-BdPnijvn.js → format-BJC513u4.js} +9 -9
  22. package/dist/fx.cjs +12 -18
  23. package/dist/fx.d.cts +5 -15
  24. package/dist/fx.d.ts +5 -15
  25. package/dist/fx.js +12 -18
  26. package/dist/index.cjs +10 -12
  27. package/dist/index.d.cts +17 -23
  28. package/dist/index.d.ts +17 -23
  29. package/dist/index.js +10 -12
  30. package/dist/input.cjs +7 -10
  31. package/dist/input.d.cts +9 -16
  32. package/dist/input.d.ts +9 -16
  33. package/dist/input.js +7 -10
  34. package/dist/{iso-minor-wSwJN57T.cjs → iso-minor-DyNjT9A1.cjs} +2 -3
  35. package/dist/{iso-minor-CqkWDxHS.js → iso-minor-odkY-e6I.js} +2 -3
  36. package/dist/{medusa-lRY9xlsf.cjs → medusa-CzVK0bth.cjs} +3 -4
  37. package/dist/{medusa-DBXJXXvF.d.ts → medusa-DofdvIgQ.d.cts} +1 -3
  38. package/dist/{medusa-4K8N1pUc.d.cts → medusa-DrbYmD2Y.d.ts} +1 -3
  39. package/dist/{medusa-DqJY1qpj.js → medusa-pKGlImn9.js} +3 -4
  40. package/dist/{money-B-3aFjNJ.d.cts → money-BkMeYDEW.d.cts} +0 -6
  41. package/dist/{money-B-3aFjNJ.d.ts → money-BkMeYDEW.d.ts} +0 -6
  42. package/dist/{money-WhnGiI00.js → money-BxbAw7BP.js} +7 -15
  43. package/dist/{money-B3wH_Z4S.cjs → money-DWBjuuEK.cjs} +7 -15
  44. package/dist/{number-text-DE-q4jO5.js → number-text-Bj-gZXiF.js} +3 -4
  45. package/dist/{number-text-BWu67jUq.cjs → number-text-CWuVwrlg.cjs} +3 -4
  46. package/dist/{own-oP9DXFWv.cjs → own-C5imDkyB.cjs} +1 -2
  47. package/dist/{own-D7544D3k.js → own-DHxqIYqL.js} +1 -2
  48. package/dist/{percent-D1VB9xXG.js → percent-CB3Ixjc_.js} +2 -3
  49. package/dist/{percent-C0InC2t2.cjs → percent-DABHiSBs.cjs} +2 -3
  50. package/dist/{rate-DBPiYgT1.d.ts → rate-BvvZUdSu.d.ts} +1 -3
  51. package/dist/{rate-tqK8ijG0.d.cts → rate-CEakW3ia.d.cts} +1 -3
  52. package/dist/{rate-CVeMii4a.cjs → rate-CEjWTATc.cjs} +3 -4
  53. package/dist/{rate-DicStBue.js → rate-D6S2_wgZ.js} +3 -4
  54. package/dist/{reporting-tpGJbqYp.d.ts → reporting-DFNyDBdi.d.cts} +2 -4
  55. package/dist/{reporting-CG-ai2sM.d.cts → reporting-jIBILvnr.d.ts} +2 -4
  56. package/dist/{retail-DRUTTQoJ.d.ts → retail-B04CjW3b.d.ts} +1 -3
  57. package/dist/{retail-Cml8YSKg.cjs → retail-CYGPU4ea.cjs} +4 -5
  58. package/dist/{retail-C_BPLvMj.d.cts → retail-CmEyJQOH.d.cts} +1 -3
  59. package/dist/{retail-1mu888J1.js → retail-DXgs11ov.js} +4 -5
  60. package/dist/{rounding-DHBtNCHG.cjs → rounding-4QKTRbMQ.cjs} +2 -3
  61. package/dist/{rounding-g9rvye0k.js → rounding-CA1PVP3b.js} +2 -3
  62. package/dist/sql.cjs +9 -15
  63. package/dist/sql.d.cts +2 -12
  64. package/dist/sql.d.ts +2 -12
  65. package/dist/sql.js +9 -15
  66. package/dist/testing.cjs +39198 -12
  67. package/dist/testing.d.cts +20 -13
  68. package/dist/testing.d.ts +20 -13
  69. package/dist/testing.js +39198 -13
  70. package/dist/{wire-sW0yzqth.js → wire-B4QU8O3W.js} +350 -93
  71. package/dist/{wire-CaUN9Vf_.d.ts → wire-CVNicirK.d.ts} +165 -46
  72. package/dist/{wire-xjYXv4go.d.cts → wire-CtNJmWVP.d.cts} +165 -46
  73. package/dist/{wire-Bhuut8cW.cjs → wire-u2tmHY0Y.cjs} +403 -92
  74. package/dist/wire.cjs +10 -1
  75. package/dist/wire.d.cts +2 -2
  76. package/dist/wire.d.ts +2 -2
  77. package/dist/wire.js +1 -2
  78. package/package.json +4 -3
package/dist/input.js CHANGED
@@ -1,8 +1,8 @@
1
- import { B as decimalOf, Q as MoneyError, at as fractionDigitsOf, dt as roundToScale, it as formatDecimal, pt as toDecimalText, s as storedDecimal, tt as compareDecimal } from "./money-WhnGiI00.js";
2
- import { n as readNumberText } from "./number-text-DE-q4jO5.js";
3
- import { c as rateFromDecimal, o as rate } from "./rate-DicStBue.js";
4
- import { a as inputStep, i as inputPlaceholder, n as formatAmountInput, o as localeSeparators, r as groupDigits, s as parseAmountInput, t as decimalOfText } from "./amount-BoYBMgK9.js";
5
- //#region src/input/import.ts
1
+ import { B as decimalOf, Q as MoneyError, at as fractionDigitsOf, dt as roundToScale, it as formatDecimal, pt as toDecimalText, s as storedDecimal, tt as compareDecimal } from "./money-BxbAw7BP.js";
2
+ import { n as readNumberText } from "./number-text-Bj-gZXiF.js";
3
+ import { c as rateFromDecimal, o as rate } from "./rate-D6S2_wgZ.js";
4
+ import { a as inputStep, i as inputPlaceholder, n as formatAmountInput, o as localeSeparators, r as groupDigits, s as parseAmountInput, t as decimalOfText } from "./amount-DHFOK2Yd.js";
5
+ // src/input/import.ts
6
6
  /**
7
7
  * Amount text from a file or a third party to canonical DecimalText (major units, exactly as
8
8
  * written: `'1.299,00'` gives `'1299'`), or null when it is not an amount (empty, exponent,
@@ -52,8 +52,7 @@ function parseDecimalInput(text, options) {
52
52
  value: toDecimalText(value)
53
53
  };
54
54
  }
55
- //#endregion
56
- //#region src/input/percent-rate.ts
55
+ // src/input/percent-rate.ts
57
56
  /**
58
57
  * A typed percent (`'20'`, `'12.5'`, `'12,5 %'` in de-DE) as DecimalText. A `%` before or after
59
58
  * the number is allowed. Default range 0..100 with 2 decimals; below 0 (with a non-negative
@@ -102,8 +101,7 @@ function parseRateInput(text, options = {}) {
102
101
  throw error;
103
102
  }
104
103
  }
105
- //#endregion
106
- //#region src/input/template.ts
104
+ // src/input/template.ts
107
105
  const DEFAULT_TEMPLATE = Object.freeze({
108
106
  prefix: "",
109
107
  suffix: "",
@@ -149,5 +147,4 @@ function formatWithTemplate(m, template) {
149
147
  const tail = fraction === void 0 ? "" : `${template.decimalSeparator}${fraction}`;
150
148
  return `${template.prefix}${negative ? "-" : ""}${grouped}${tail}${template.suffix}`;
151
149
  }
152
- //#endregion
153
150
  export { formatAmountInput, formatWithTemplate, inputPlaceholder, inputStep, moneyTemplateOf, parseAmountInput, parseDecimalInput, parseImportAmount, parsePercentInput, parseRateInput };
@@ -1,5 +1,5 @@
1
- const require_money = require("./money-B3wH_Z4S.cjs");
2
- //#region src/iso-minor.ts
1
+ const require_money = require("./money-DWBjuuEK.cjs");
2
+ // src/iso-minor.ts
3
3
  /**
4
4
  * Internal: stored units per ISO minor unit at `digits`, `storageScale / 10^digits` (100 for
5
5
  * a zero-digit count on a x100 currency, 1 when the digits match the storage exponent).
@@ -44,7 +44,6 @@ function fromIsoMinor(value, currency, options = {}) {
44
44
  if (BigInt(integer) % excess !== 0n) throw new require_money.MoneyError("precision", `${integer} at ${digits} digits is not a whole ${info.code} storage unit`);
45
45
  return require_money.boundedMoney(BigInt(integer) / excess, info);
46
46
  }
47
- //#endregion
48
47
  Object.defineProperty(exports, "fromIsoMinor", {
49
48
  enumerable: true,
50
49
  get: function() {
@@ -1,5 +1,5 @@
1
- import { $ as describeValue, E as resolveCurrency, Q as MoneyError, X as mulDiv, k as storageExponent, lt as parseDecimal, s as storedDecimal, t as boundedMoney, ut as pow10 } from "./money-WhnGiI00.js";
2
- //#region src/iso-minor.ts
1
+ import { $ as describeValue, E as resolveCurrency, Q as MoneyError, X as mulDiv, k as storageExponent, lt as parseDecimal, s as storedDecimal, t as boundedMoney, ut as pow10 } from "./money-BxbAw7BP.js";
2
+ // src/iso-minor.ts
3
3
  /**
4
4
  * Internal: stored units per ISO minor unit at `digits`, `storageScale / 10^digits` (100 for
5
5
  * a zero-digit count on a x100 currency, 1 when the digits match the storage exponent).
@@ -44,5 +44,4 @@ function fromIsoMinor(value, currency, options = {}) {
44
44
  if (BigInt(integer) % excess !== 0n) throw new MoneyError("precision", `${integer} at ${digits} digits is not a whole ${info.code} storage unit`);
45
45
  return boundedMoney(BigInt(integer) / excess, info);
46
46
  }
47
- //#endregion
48
47
  export { isoMinorFactor as n, toIsoMinor as r, fromIsoMinor as t };
@@ -1,6 +1,6 @@
1
- const require_money = require("./money-B3wH_Z4S.cjs");
2
- const require_own = require("./own-oP9DXFWv.cjs");
3
- //#region src/medusa.ts
1
+ const require_money = require("./money-DWBjuuEK.cjs");
2
+ const require_own = require("./own-C5imDkyB.cjs");
3
+ // src/medusa.ts
4
4
  const isObject = (value) => typeof value === "object" && value !== null;
5
5
  /** Internal: `row['raw_' + key]` when it is not null/undefined, else `row[key]` (undefined for a non-object row). */
6
6
  function storedFieldValue(row, key) {
@@ -112,7 +112,6 @@ function isPositiveAmount(raw) {
112
112
  const value = require_money.medusaAmountDecimal(raw);
113
113
  return value !== null && require_money.isPositiveDecimal(value);
114
114
  }
115
- //#endregion
116
115
  Object.defineProperty(exports, "isPositiveAmount", {
117
116
  enumerable: true,
118
117
  get: function() {
@@ -1,5 +1,4 @@
1
- import { R as DecimalText, a as ReadStoredOptions, i as Money, o as StoredAmount } from "./money-B-3aFjNJ.js";
2
- //#region src/medusa.d.ts
1
+ import { R as DecimalText, a as ReadStoredOptions, i as Money, o as StoredAmount } from "./money-BkMeYDEW.cjs";
3
2
  /**
4
3
  * `row['raw_' + key]` when it is not null/undefined (a failure to read it is final: no
5
4
  * fallback to the lossy plain key), else `row[key]`, read like `readStored`.
@@ -83,5 +82,4 @@ interface PriceLike {
83
82
  declare function moneyFor(source: MoneyByCurrency | readonly PriceLike[], currency: string): Money | null;
84
83
  /** Whether unknown Medusa input holds an amount above zero. `''`, null and garbage are false, never a throw. */
85
84
  declare function isPositiveAmount(raw: unknown): boolean;
86
- //#endregion
87
85
  export { isPositiveAmount as a, readCalculatedPrice as c, readStoredLiteral as d, toMedusaAmountInput as f, ReadStoredDecimalOptions as i, readStoredDecimal as l, MoneyByCurrency as n, moneyByCurrency as o, toMedusaRaw as p, PriceLike as r, moneyFor as s, MedusaRaw as t, readStoredField as u };
@@ -1,5 +1,4 @@
1
- import { R as DecimalText, a as ReadStoredOptions, i as Money, o as StoredAmount } from "./money-B-3aFjNJ.cjs";
2
- //#region src/medusa.d.ts
1
+ import { R as DecimalText, a as ReadStoredOptions, i as Money, o as StoredAmount } from "./money-BkMeYDEW.js";
3
2
  /**
4
3
  * `row['raw_' + key]` when it is not null/undefined (a failure to read it is final: no
5
4
  * fallback to the lossy plain key), else `row[key]`, read like `readStored`.
@@ -83,5 +82,4 @@ interface PriceLike {
83
82
  declare function moneyFor(source: MoneyByCurrency | readonly PriceLike[], currency: string): Money | null;
84
83
  /** Whether unknown Medusa input holds an amount above zero. `''`, null and garbage are false, never a throw. */
85
84
  declare function isPositiveAmount(raw: unknown): boolean;
86
- //#endregion
87
85
  export { isPositiveAmount as a, readCalculatedPrice as c, readStoredLiteral as d, toMedusaAmountInput as f, ReadStoredDecimalOptions as i, readStoredDecimal as l, MoneyByCurrency as n, moneyByCurrency as o, toMedusaRaw as p, PriceLike as r, moneyFor as s, MedusaRaw as t, readStoredField as u };
@@ -1,6 +1,6 @@
1
- import { $ as describeValue, B as decimalOf, D as sameCurrency, E as resolveCurrency, G as isDecimalLiteral, Q as MoneyError, a as money, b as firstCurrency, d as currencyCode, ft as strictNumberDecimal, i as medusaAmountDecimal, o as readStored, ot as isPositiveDecimal, pt as toDecimalText, r as isStoredAmount, s as storedDecimal } from "./money-WhnGiI00.js";
2
- import { t as hasOwnKey } from "./own-D7544D3k.js";
3
- //#region src/medusa.ts
1
+ import { $ as describeValue, B as decimalOf, D as sameCurrency, E as resolveCurrency, G as isDecimalLiteral, Q as MoneyError, a as money, b as firstCurrency, d as currencyCode, ft as strictNumberDecimal, i as medusaAmountDecimal, o as readStored, ot as isPositiveDecimal, pt as toDecimalText, r as isStoredAmount, s as storedDecimal } from "./money-BxbAw7BP.js";
2
+ import { t as hasOwnKey } from "./own-DHxqIYqL.js";
3
+ // src/medusa.ts
4
4
  const isObject = (value) => typeof value === "object" && value !== null;
5
5
  /** Internal: `row['raw_' + key]` when it is not null/undefined, else `row[key]` (undefined for a non-object row). */
6
6
  function storedFieldValue(row, key) {
@@ -112,5 +112,4 @@ function isPositiveAmount(raw) {
112
112
  const value = medusaAmountDecimal(raw);
113
113
  return value !== null && isPositiveDecimal(value);
114
114
  }
115
- //#endregion
116
115
  export { readStoredDecimal as a, storedFieldValue as c, readCalculatedPrice as i, toMedusaAmountInput as l, moneyByCurrency as n, readStoredField as o, moneyFor as r, readStoredLiteral as s, isPositiveAmount as t, toMedusaRaw as u };
@@ -1,4 +1,3 @@
1
- //#region src/decimal.d.ts
2
1
  /**
3
2
  * How a value between two representable amounts is resolved. `half-up` rounds a tie away from zero.
4
3
  * `floor-after-tenth` is Shopify's discount truncation: round to a tenth of the unit (half-up), then
@@ -10,8 +9,6 @@ declare const DECIMAL_TEXT_BRAND: unique symbol;
10
9
  type DecimalText = string & {
11
10
  readonly [DECIMAL_TEXT_BRAND]: true;
12
11
  };
13
- //#endregion
14
- //#region src/registry.d.ts
15
12
  declare const CURRENCY_CODE: unique symbol;
16
13
  /** An upper-case code this package knows. Obtain one from `currencyCode` or `isCurrencyCode`. */
17
14
  type CurrencyCode = string & {
@@ -128,8 +125,6 @@ declare function localeForCurrency(code: string): string;
128
125
  * numbers, as Medusa does, so these sites agree with Medusa's own `payment_status`.
129
126
  */
130
127
  declare function medusaEpsilon(code: string): DecimalText;
131
- //#endregion
132
- //#region src/money.d.ts
133
128
  declare const STORED_AMOUNT: unique symbol;
134
129
  declare const MAJOR_DECIMAL: unique symbol;
135
130
  /** An amount in Amboras storage units (major x storageScale): a safe integer. */
@@ -244,5 +239,4 @@ declare function readStored(raw: unknown, currency: string, options?: ReadStored
244
239
  mode?: 'strict';
245
240
  }): Money;
246
241
  declare function readStored(raw: unknown, currency: string, options?: ReadStoredOptions): Money | null;
247
- //#endregion
248
242
  export { isCurrencyCode as A, currencyInfo as C, currencySymbol as D, currencyOptions as E, sameCurrency as F, storageDigits as I, storageScale as L, medusaCurrencyCode as M, medusaEpsilon as N, displayDigits as O, parseCurrencyCode as P, DecimalText as R, currencyCode as S, currencyName as T, CurrencyCodeOptions as _, ReadStoredOptions as a, FractionDigits as b, ToMajorDecimalOptions as c, money as d, readStored as f, CurrencyCode as g, CURRENCIES as h, Money as i, localeForCurrency as j, firstCurrency as k, fromMajor as l, toMajorNumber as m, FromMajorOptions as n, StoredAmount as o, toMajorDecimal as p, MajorDecimal as r, StoredAmountOptions as s, FractionalMoney as t, isStoredAmount as u, CurrencyInfo as v, currencyLabel as w, StorageScale as x, CurrencyStatus as y, RoundingMode as z };
@@ -1,4 +1,3 @@
1
- //#region src/decimal.d.ts
2
1
  /**
3
2
  * How a value between two representable amounts is resolved. `half-up` rounds a tie away from zero.
4
3
  * `floor-after-tenth` is Shopify's discount truncation: round to a tenth of the unit (half-up), then
@@ -10,8 +9,6 @@ declare const DECIMAL_TEXT_BRAND: unique symbol;
10
9
  type DecimalText = string & {
11
10
  readonly [DECIMAL_TEXT_BRAND]: true;
12
11
  };
13
- //#endregion
14
- //#region src/registry.d.ts
15
12
  declare const CURRENCY_CODE: unique symbol;
16
13
  /** An upper-case code this package knows. Obtain one from `currencyCode` or `isCurrencyCode`. */
17
14
  type CurrencyCode = string & {
@@ -128,8 +125,6 @@ declare function localeForCurrency(code: string): string;
128
125
  * numbers, as Medusa does, so these sites agree with Medusa's own `payment_status`.
129
126
  */
130
127
  declare function medusaEpsilon(code: string): DecimalText;
131
- //#endregion
132
- //#region src/money.d.ts
133
128
  declare const STORED_AMOUNT: unique symbol;
134
129
  declare const MAJOR_DECIMAL: unique symbol;
135
130
  /** An amount in Amboras storage units (major x storageScale): a safe integer. */
@@ -244,5 +239,4 @@ declare function readStored(raw: unknown, currency: string, options?: ReadStored
244
239
  mode?: 'strict';
245
240
  }): Money;
246
241
  declare function readStored(raw: unknown, currency: string, options?: ReadStoredOptions): Money | null;
247
- //#endregion
248
242
  export { isCurrencyCode as A, currencyInfo as C, currencySymbol as D, currencyOptions as E, sameCurrency as F, storageDigits as I, storageScale as L, medusaCurrencyCode as M, medusaEpsilon as N, displayDigits as O, parseCurrencyCode as P, DecimalText as R, currencyCode as S, currencyName as T, CurrencyCodeOptions as _, ReadStoredOptions as a, FractionDigits as b, ToMajorDecimalOptions as c, money as d, readStored as f, CurrencyCode as g, CURRENCIES as h, Money as i, localeForCurrency as j, firstCurrency as k, fromMajor as l, toMajorNumber as m, FromMajorOptions as n, StoredAmount as o, toMajorDecimal as p, MajorDecimal as r, StoredAmountOptions as s, FractionalMoney as t, isStoredAmount as u, CurrencyInfo as v, currencyLabel as w, StorageScale as x, CurrencyStatus as y, RoundingMode as z };
@@ -137,8 +137,7 @@ function withinFloatNoise(major, digits) {
137
137
  function unitsWithin(d, limit) {
138
138
  return (d.units < 0n ? -d.units : d.units) <= limit;
139
139
  }
140
- //#endregion
141
- //#region src/errors.ts
140
+ // src/errors.ts
142
141
  /** The one error this package throws for bad money input. Check `code`, not the message. */
143
142
  var MoneyError = class extends Error {
144
143
  constructor(code, message, options = {}) {
@@ -157,8 +156,7 @@ function describeValue(value) {
157
156
  return Object.prototype.toString.call(value);
158
157
  }
159
158
  }
160
- //#endregion
161
- //#region src/internal/rational.ts
159
+ // src/internal/rational.ts
162
160
  /** `a x b / c` rounded by `mode`. `c` must not be zero; its sign is folded into the numerator. */
163
161
  function mulDiv(a, b, c, mode) {
164
162
  if (c === 0n) throw new RangeError("mulDiv: division by zero");
@@ -185,8 +183,7 @@ function gcd(a, b) {
185
183
  while (y !== 0n) [x, y] = [y, x % y];
186
184
  return x;
187
185
  }
188
- //#endregion
189
- //#region src/decimal-text.ts
186
+ // src/decimal-text.ts
190
187
  /**
191
188
  * Internal: `input` as an exact Decimal. Text must be plain decimal (`'-12.50'`, `'7'`):
192
189
  * no blank, whitespace, exponent, hex, `'.5'` or `'1.'` (`parse`). Numbers are taken by
@@ -308,8 +305,7 @@ function decimalWithin(a, b, tolerance, options = {}) {
308
305
  }, limit);
309
306
  return options.inclusive === false ? gap < 0 : gap <= 0;
310
307
  }
311
- //#endregion
312
- //#region src/data/currencies.ts
308
+ // src/data/currencies.ts
313
309
  const CURRENCY_ROWS = [
314
310
  {
315
311
  code: "AED",
@@ -3227,8 +3223,7 @@ const CURRENCY_ROWS = [
3227
3223
  commaDecimal: false
3228
3224
  }
3229
3225
  ];
3230
- //#endregion
3231
- //#region src/internal/intl.ts
3226
+ // src/internal/intl.ts
3232
3227
  const DEFAULT_LOCALE = "en-US";
3233
3228
  /**
3234
3229
  * `locale` when the runtime supports it, else `'en-US'`. Blank, malformed or unsupported
@@ -3265,8 +3260,7 @@ function separatorsOf(locale) {
3265
3260
  group: parts.find((p) => p.type === "group")?.value ?? (decimal === "." ? "," : ".")
3266
3261
  };
3267
3262
  }
3268
- //#endregion
3269
- //#region src/registry.ts
3263
+ // src/registry.ts
3270
3264
  /** Every currency this package knows, active and historic, sorted by code. */
3271
3265
  const CURRENCIES = Object.freeze(CURRENCY_ROWS.map((row) => Object.freeze({
3272
3266
  ...row,
@@ -3425,8 +3419,7 @@ function medusaEpsilon(code) {
3425
3419
  scale: currencyInfo(code).medusaDigits
3426
3420
  });
3427
3421
  }
3428
- //#endregion
3429
- //#region src/money.ts
3422
+ // src/money.ts
3430
3423
  const MAX_UNITS = 2n ** 46n;
3431
3424
  const anyKnownCurrency = (currency, field) => resolveCurrency(currency, {
3432
3425
  allowHistoric: true,
@@ -3579,5 +3572,4 @@ function readStored(raw, currency, options = {}) {
3579
3572
  if (options.mode === "lenient") return null;
3580
3573
  throw new MoneyError("amount_invalid", `Invalid stored amount: ${describeValue(raw)}`, { field: options.field });
3581
3574
  }
3582
- //#endregion
3583
3575
  export { describeValue as $, storageScale as A, decimalOf as B, medusaCurrencyCode as C, sameCurrency as D, resolveCurrency as E, decimalClamp as F, isDecimalLiteral as G, decimalSubtract as H, decimalCompare as I, compareRatio as J, parseDecimalText as K, decimalDivide as L, resolveLocale as M, separatorsOf as N, storageDigits as O, assertDecimalLiteral as P, MoneyError as Q, decimalEquals as R, localeForCurrency as S, parseCurrencyCode as T, decimalSum as U, decimalRound as V, decimalWithin as W, mulDiv as X, gcd as Y, ratioToDecimal as Z, currencySymbol as _, money as a, fractionDigitsOf as at, firstCurrency as b, toMajorDecimal as c, normalizeDecimal as ct, currencyCode as d, roundToScale as dt, addDecimal as et, currencyInfo as f, strictNumberDecimal as ft, currencyOptions as g, currencyName as h, medusaAmountDecimal as i, formatDecimal as it, numberFormat as j, storageExponent as k, toMajorNumber as l, parseDecimal as lt, currencyMarks as m, unitsWithin as mt, fromMajor as n, decimalFromNumber as nt, readStored as o, isPositiveDecimal as ot, currencyLabel as p, toDecimalText as pt, trimDecimalZeros as q, isStoredAmount as r, divRound as rt, storedDecimal as s, multiplyDecimal as st, boundedMoney as t, compareDecimal as tt, CURRENCIES as u, pow10 as ut, displayDigits as v, medusaEpsilon as w, isCurrencyCode as x, findCurrency as y, decimalMultiply as z };
@@ -137,8 +137,7 @@ function withinFloatNoise(major, digits) {
137
137
  function unitsWithin(d, limit) {
138
138
  return (d.units < 0n ? -d.units : d.units) <= limit;
139
139
  }
140
- //#endregion
141
- //#region src/errors.ts
140
+ // src/errors.ts
142
141
  /** The one error this package throws for bad money input. Check `code`, not the message. */
143
142
  var MoneyError = class extends Error {
144
143
  constructor(code, message, options = {}) {
@@ -157,8 +156,7 @@ function describeValue(value) {
157
156
  return Object.prototype.toString.call(value);
158
157
  }
159
158
  }
160
- //#endregion
161
- //#region src/internal/rational.ts
159
+ // src/internal/rational.ts
162
160
  /** `a x b / c` rounded by `mode`. `c` must not be zero; its sign is folded into the numerator. */
163
161
  function mulDiv(a, b, c, mode) {
164
162
  if (c === 0n) throw new RangeError("mulDiv: division by zero");
@@ -185,8 +183,7 @@ function gcd(a, b) {
185
183
  while (y !== 0n) [x, y] = [y, x % y];
186
184
  return x;
187
185
  }
188
- //#endregion
189
- //#region src/decimal-text.ts
186
+ // src/decimal-text.ts
190
187
  /**
191
188
  * Internal: `input` as an exact Decimal. Text must be plain decimal (`'-12.50'`, `'7'`):
192
189
  * no blank, whitespace, exponent, hex, `'.5'` or `'1.'` (`parse`). Numbers are taken by
@@ -308,8 +305,7 @@ function decimalWithin(a, b, tolerance, options = {}) {
308
305
  }, limit);
309
306
  return options.inclusive === false ? gap < 0 : gap <= 0;
310
307
  }
311
- //#endregion
312
- //#region src/data/currencies.ts
308
+ // src/data/currencies.ts
313
309
  const CURRENCY_ROWS = [
314
310
  {
315
311
  code: "AED",
@@ -3227,8 +3223,7 @@ const CURRENCY_ROWS = [
3227
3223
  commaDecimal: false
3228
3224
  }
3229
3225
  ];
3230
- //#endregion
3231
- //#region src/internal/intl.ts
3226
+ // src/internal/intl.ts
3232
3227
  const DEFAULT_LOCALE = "en-US";
3233
3228
  /**
3234
3229
  * `locale` when the runtime supports it, else `'en-US'`. Blank, malformed or unsupported
@@ -3265,8 +3260,7 @@ function separatorsOf(locale) {
3265
3260
  group: parts.find((p) => p.type === "group")?.value ?? (decimal === "." ? "," : ".")
3266
3261
  };
3267
3262
  }
3268
- //#endregion
3269
- //#region src/registry.ts
3263
+ // src/registry.ts
3270
3264
  /** Every currency this package knows, active and historic, sorted by code. */
3271
3265
  const CURRENCIES = Object.freeze(CURRENCY_ROWS.map((row) => Object.freeze({
3272
3266
  ...row,
@@ -3425,8 +3419,7 @@ function medusaEpsilon(code) {
3425
3419
  scale: currencyInfo(code).medusaDigits
3426
3420
  });
3427
3421
  }
3428
- //#endregion
3429
- //#region src/money.ts
3422
+ // src/money.ts
3430
3423
  const MAX_UNITS = 2n ** 46n;
3431
3424
  const anyKnownCurrency = (currency, field) => resolveCurrency(currency, {
3432
3425
  allowHistoric: true,
@@ -3579,7 +3572,6 @@ function readStored(raw, currency, options = {}) {
3579
3572
  if (options.mode === "lenient") return null;
3580
3573
  throw new MoneyError("amount_invalid", `Invalid stored amount: ${describeValue(raw)}`, { field: options.field });
3581
3574
  }
3582
- //#endregion
3583
3575
  Object.defineProperty(exports, "CURRENCIES", {
3584
3576
  enumerable: true,
3585
3577
  get: function() {
@@ -1,5 +1,5 @@
1
- import { $ as describeValue, E as resolveCurrency, dt as roundToScale, m as currencyMarks } from "./money-WhnGiI00.js";
2
- //#region src/internal/number-text.ts
1
+ import { $ as describeValue, E as resolveCurrency, dt as roundToScale, m as currencyMarks } from "./money-BxbAw7BP.js";
2
+ // src/internal/number-text.ts
3
3
  const MINUS = /^[-−]/;
4
4
  const escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
5
5
  const unparseable = Object.freeze({ reason: "unparseable" });
@@ -123,12 +123,11 @@ function readNumberText(text, options = {}) {
123
123
  negative = true;
124
124
  rest = rest.slice(1);
125
125
  }
126
- const read = auto ? readAuto(negative, rest, info, options.keepFraction ? null : options.rounding ?? "half-up") : readExplicit(negative, rest, decimal, group, info);
126
+ const read = auto ? readAuto(negative, rest, info, options.keepFraction ? null : options.rounding ?? "half-up") : readExplicit(negative, rest, decimal, group, options.wholeCurrencyGrouping === false ? null : info);
127
127
  if ("reason" in read) return read;
128
128
  return {
129
129
  ...read,
130
130
  groupMark: groupMarkOf(written, read.decimalMark)
131
131
  };
132
132
  }
133
- //#endregion
134
133
  export { readNumberText as n, digitGroupingSource as t };
@@ -1,5 +1,5 @@
1
- const require_money = require("./money-B3wH_Z4S.cjs");
2
- //#region src/internal/number-text.ts
1
+ const require_money = require("./money-DWBjuuEK.cjs");
2
+ // src/internal/number-text.ts
3
3
  const MINUS = /^[-−]/;
4
4
  const escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
5
5
  const unparseable = Object.freeze({ reason: "unparseable" });
@@ -123,14 +123,13 @@ function readNumberText(text, options = {}) {
123
123
  negative = true;
124
124
  rest = rest.slice(1);
125
125
  }
126
- const read = auto ? readAuto(negative, rest, info, options.keepFraction ? null : options.rounding ?? "half-up") : readExplicit(negative, rest, decimal, group, info);
126
+ const read = auto ? readAuto(negative, rest, info, options.keepFraction ? null : options.rounding ?? "half-up") : readExplicit(negative, rest, decimal, group, options.wholeCurrencyGrouping === false ? null : info);
127
127
  if ("reason" in read) return read;
128
128
  return {
129
129
  ...read,
130
130
  groupMark: groupMarkOf(written, read.decimalMark)
131
131
  };
132
132
  }
133
- //#endregion
134
133
  Object.defineProperty(exports, "digitGroupingSource", {
135
134
  enumerable: true,
136
135
  get: function() {
@@ -1,6 +1,5 @@
1
- //#region src/internal/own.ts
1
+ // src/internal/own.ts
2
2
  const hasOwnKey = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key);
3
- //#endregion
4
3
  Object.defineProperty(exports, "hasOwnKey", {
5
4
  enumerable: true,
6
5
  get: function() {
@@ -1,4 +1,3 @@
1
- //#region src/internal/own.ts
1
+ // src/internal/own.ts
2
2
  const hasOwnKey = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key);
3
- //#endregion
4
3
  export { hasOwnKey as t };
@@ -1,5 +1,5 @@
1
- import { X as mulDiv, Z as ratioToDecimal, ut as pow10 } from "./money-WhnGiI00.js";
2
- //#region src/internal/percent.ts
1
+ import { X as mulDiv, Z as ratioToDecimal, ut as pow10 } from "./money-BxbAw7BP.js";
2
+ // src/internal/percent.ts
3
3
  /** 100% for a percent written with `scale` fraction digits: the denominator of its units. */
4
4
  function hundredPercent(scale) {
5
5
  return 100n * pow10(scale);
@@ -16,5 +16,4 @@ function basisPointsOf(units, bps, mode, denominator = 1n) {
16
16
  function percentRatio(a, b, digits) {
17
17
  return ratioToDecimal(a * 100n, b, digits);
18
18
  }
19
- //#endregion
20
19
  export { percentRatio as i, hundredPercent as n, percentOfUnits as r, basisPointsOf as t };
@@ -1,5 +1,5 @@
1
- const require_money = require("./money-B3wH_Z4S.cjs");
2
- //#region src/internal/percent.ts
1
+ const require_money = require("./money-DWBjuuEK.cjs");
2
+ // src/internal/percent.ts
3
3
  /** 100% for a percent written with `scale` fraction digits: the denominator of its units. */
4
4
  function hundredPercent(scale) {
5
5
  return 100n * require_money.pow10(scale);
@@ -16,7 +16,6 @@ function basisPointsOf(units, bps, mode, denominator = 1n) {
16
16
  function percentRatio(a, b, digits) {
17
17
  return require_money.ratioToDecimal(a * 100n, b, digits);
18
18
  }
19
- //#endregion
20
19
  Object.defineProperty(exports, "basisPointsOf", {
21
20
  enumerable: true,
22
21
  get: function() {
@@ -1,5 +1,4 @@
1
- import { R as DecimalText } from "./money-B-3aFjNJ.js";
2
- //#region src/fx/rate.d.ts
1
+ import { R as DecimalText } from "./money-BkMeYDEW.js";
3
2
  /** 1 base unit = numerator / denominator quote units, both in major units. Positive integers. */
4
3
  interface Rate {
5
4
  readonly numerator: bigint;
@@ -59,5 +58,4 @@ declare function invertRate(r: Rate): Rate;
59
58
  declare function crossRate(table: Readonly<Record<string, Rate>>, from: string, to: string, base: string): Rate | null;
60
59
  /** Same value (cross-multiplied), whatever the parts: 2/4 equals 1/2. */
61
60
  declare function rateEquals(a: Rate, b: Rate): boolean;
62
- //#endregion
63
61
  export { RateRow as a, rate as c, rateFromRow as d, rateToDecimal as f, RateFromDecimalOptions as i, rateEquals as l, RATE_REF as n, crossRate as o, rateToNumber as p, Rate as r, invertRate as s, RATE_BOUNDS as t, rateFromDecimal as u };
@@ -1,5 +1,4 @@
1
- import { R as DecimalText } from "./money-B-3aFjNJ.cjs";
2
- //#region src/fx/rate.d.ts
1
+ import { R as DecimalText } from "./money-BkMeYDEW.cjs";
3
2
  /** 1 base unit = numerator / denominator quote units, both in major units. Positive integers. */
4
3
  interface Rate {
5
4
  readonly numerator: bigint;
@@ -59,5 +58,4 @@ declare function invertRate(r: Rate): Rate;
59
58
  declare function crossRate(table: Readonly<Record<string, Rate>>, from: string, to: string, base: string): Rate | null;
60
59
  /** Same value (cross-multiplied), whatever the parts: 2/4 equals 1/2. */
61
60
  declare function rateEquals(a: Rate, b: Rate): boolean;
62
- //#endregion
63
61
  export { RateRow as a, rate as c, rateFromRow as d, rateToDecimal as f, RateFromDecimalOptions as i, rateEquals as l, RATE_REF as n, crossRate as o, rateToNumber as p, Rate as r, invertRate as s, RATE_BOUNDS as t, rateFromDecimal as u };
@@ -1,6 +1,6 @@
1
- const require_money = require("./money-B3wH_Z4S.cjs");
2
- const require_own = require("./own-oP9DXFWv.cjs");
3
- //#region src/fx/rate.ts
1
+ const require_money = require("./money-DWBjuuEK.cjs");
2
+ const require_own = require("./own-C5imDkyB.cjs");
3
+ // src/fx/rate.ts
4
4
  /** Denominator of every locked rate (`store_currency_rate.rate_denominator` default): 7 decimals. */
5
5
  const RATE_REF = 10000000n;
6
6
  /** Inclusive bounds of a locked rate's value: `lockedRateNumerator` (n >= 1 at RATE_REF, value <= 1e9). */
@@ -148,7 +148,6 @@ function rateEquals(a, b) {
148
148
  const y = checkRate(b);
149
149
  return require_money.compareRatio(x.numerator, x.denominator, y.numerator, y.denominator) === 0;
150
150
  }
151
- //#endregion
152
151
  Object.defineProperty(exports, "RATE_BOUNDS", {
153
152
  enumerable: true,
154
153
  get: function() {
@@ -1,6 +1,6 @@
1
- import { $ as describeValue, B as decimalOf, J as compareRatio, Q as MoneyError, Z as ratioToDecimal, dt as roundToScale, lt as parseDecimal, pt as toDecimalText, ut as pow10 } from "./money-WhnGiI00.js";
2
- import { t as hasOwnKey } from "./own-D7544D3k.js";
3
- //#region src/fx/rate.ts
1
+ import { $ as describeValue, B as decimalOf, J as compareRatio, Q as MoneyError, Z as ratioToDecimal, dt as roundToScale, lt as parseDecimal, pt as toDecimalText, ut as pow10 } from "./money-BxbAw7BP.js";
2
+ import { t as hasOwnKey } from "./own-DHxqIYqL.js";
3
+ // src/fx/rate.ts
4
4
  /** Denominator of every locked rate (`store_currency_rate.rate_denominator` default): 7 decimals. */
5
5
  const RATE_REF = 10000000n;
6
6
  /** Inclusive bounds of a locked rate's value: `lockedRateNumerator` (n >= 1 at RATE_REF, value <= 1e9). */
@@ -148,5 +148,4 @@ function rateEquals(a, b) {
148
148
  const y = checkRate(b);
149
149
  return compareRatio(x.numerator, x.denominator, y.numerator, y.denominator) === 0;
150
150
  }
151
- //#endregion
152
151
  export { invertRate as a, rateFromDecimal as c, rateToNumber as d, crossRate as i, rateFromRow as l, RATE_REF as n, rate as o, checkRate as r, rateEquals as s, RATE_BOUNDS as t, rateToDecimal as u };
@@ -1,6 +1,5 @@
1
- import { R as DecimalText, g as CurrencyCode, i as Money } from "./money-B-3aFjNJ.js";
2
- import { a as RateRow } from "./rate-DBPiYgT1.js";
3
- //#region src/fx/reporting.d.ts
1
+ import { R as DecimalText, g as CurrencyCode, i as Money } from "./money-BkMeYDEW.cjs";
2
+ import { a as RateRow } from "./rate-CEakW3ia.cjs";
4
3
  /** `factors[lower code]` takes a stored amount in that currency to a stored amount in `base`. */
5
4
  interface FactorTable {
6
5
  readonly base: CurrencyCode;
@@ -27,5 +26,4 @@ interface ReportingTotal {
27
26
  * Items whose currency has no factor are excluded and reported in `missing`.
28
27
  */
29
28
  declare function toReporting(items: readonly Money[], table: FactorTable): ReportingTotal;
30
- //#endregion
31
29
  export { toReporting as i, ReportingTotal as n, storeFactors as r, FactorTable as t };
@@ -1,6 +1,5 @@
1
- import { R as DecimalText, g as CurrencyCode, i as Money } from "./money-B-3aFjNJ.cjs";
2
- import { a as RateRow } from "./rate-tqK8ijG0.cjs";
3
- //#region src/fx/reporting.d.ts
1
+ import { R as DecimalText, g as CurrencyCode, i as Money } from "./money-BkMeYDEW.js";
2
+ import { a as RateRow } from "./rate-BvvZUdSu.js";
4
3
  /** `factors[lower code]` takes a stored amount in that currency to a stored amount in `base`. */
5
4
  interface FactorTable {
6
5
  readonly base: CurrencyCode;
@@ -27,5 +26,4 @@ interface ReportingTotal {
27
26
  * Items whose currency has no factor are excluded and reported in `missing`.
28
27
  */
29
28
  declare function toReporting(items: readonly Money[], table: FactorTable): ReportingTotal;
30
- //#endregion
31
29
  export { toReporting as i, ReportingTotal as n, storeFactors as r, FactorTable as t };
@@ -1,5 +1,4 @@
1
- import { i as Money } from "./money-B-3aFjNJ.js";
2
- //#region src/fx/retail.d.ts
1
+ import { i as Money } from "./money-BkMeYDEW.js";
3
2
  /**
4
3
  * - `'none'`: Medusa `applyRounding` 'none': a zero-decimal currency is rounded to a whole
5
4
  * unit (half toward +infinity, as `Math.round`: JPY 150050 gives 150100, since there is no
@@ -27,5 +26,4 @@ declare function priceRoundingParams(currency: string): {
27
26
  majorUnit: 100 | 1000;
28
27
  charm: number | null;
29
28
  };
30
- //#endregion
31
29
  export { priceRoundingParams as n, roundRetail as r, RetailRounding as t };
@@ -1,7 +1,7 @@
1
- const require_money = require("./money-B3wH_Z4S.cjs");
2
- const require_rounding = require("./rounding-DHBtNCHG.cjs");
3
- const require_percent = require("./percent-C0InC2t2.cjs");
4
- //#region src/fx/retail.ts
1
+ const require_money = require("./money-DWBjuuEK.cjs");
2
+ const require_rounding = require("./rounding-4QKTRbMQ.cjs");
3
+ const require_percent = require("./percent-DABHiSBs.cjs");
4
+ // src/fx/retail.ts
5
5
  const RETAIL_ROUNDINGS = [
6
6
  "none",
7
7
  "nearest",
@@ -65,7 +65,6 @@ function priceRoundingParams(currency) {
65
65
  charm: info.storageDigits === 0 ? null : Number(charmOf(scale))
66
66
  };
67
67
  }
68
- //#endregion
69
68
  Object.defineProperty(exports, "priceRoundingParams", {
70
69
  enumerable: true,
71
70
  get: function() {
@@ -1,5 +1,4 @@
1
- import { i as Money } from "./money-B-3aFjNJ.cjs";
2
- //#region src/fx/retail.d.ts
1
+ import { i as Money } from "./money-BkMeYDEW.cjs";
3
2
  /**
4
3
  * - `'none'`: Medusa `applyRounding` 'none': a zero-decimal currency is rounded to a whole
5
4
  * unit (half toward +infinity, as `Math.round`: JPY 150050 gives 150100, since there is no
@@ -27,5 +26,4 @@ declare function priceRoundingParams(currency: string): {
27
26
  majorUnit: 100 | 1000;
28
27
  charm: number | null;
29
28
  };
30
- //#endregion
31
29
  export { priceRoundingParams as n, roundRetail as r, RetailRounding as t };
@@ -1,7 +1,7 @@
1
- import { $ as describeValue, E as resolveCurrency, Q as MoneyError, rt as divRound, s as storedDecimal, t as boundedMoney } from "./money-WhnGiI00.js";
2
- import { a as unitSize, t as mulDivToUnit } from "./rounding-g9rvye0k.js";
3
- import { r as percentOfUnits } from "./percent-D1VB9xXG.js";
4
- //#region src/fx/retail.ts
1
+ import { $ as describeValue, E as resolveCurrency, Q as MoneyError, rt as divRound, s as storedDecimal, t as boundedMoney } from "./money-BxbAw7BP.js";
2
+ import { a as unitSize, t as mulDivToUnit } from "./rounding-CA1PVP3b.js";
3
+ import { r as percentOfUnits } from "./percent-CB3Ixjc_.js";
4
+ // src/fx/retail.ts
5
5
  const RETAIL_ROUNDINGS = [
6
6
  "none",
7
7
  "nearest",
@@ -65,5 +65,4 @@ function priceRoundingParams(currency) {
65
65
  charm: info.storageDigits === 0 ? null : Number(charmOf(scale))
66
66
  };
67
67
  }
68
- //#endregion
69
68
  export { retailUnits as n, roundRetail as r, priceRoundingParams as t };
@@ -1,5 +1,5 @@
1
- const require_money = require("./money-B3wH_Z4S.cjs");
2
- //#region src/rounding.ts
1
+ const require_money = require("./money-DWBjuuEK.cjs");
2
+ // src/rounding.ts
3
3
  /** Internal: the size of `unit` in storage units. */
4
4
  function unitSize(info, unit) {
5
5
  if (unit === "storage") return 1n;
@@ -46,7 +46,6 @@ function roundMajor(major, currency, options = {}) {
46
46
  const digits = options.digits === "storage" ? info.storageDigits : info.displayDigits;
47
47
  return Number(require_money.formatDecimal(require_money.roundToScale(value, digits, options.rounding ?? "half-up")));
48
48
  }
49
- //#endregion
50
49
  Object.defineProperty(exports, "mulDivToUnit", {
51
50
  enumerable: true,
52
51
  get: function() {
@@ -1,5 +1,5 @@
1
- import { B as decimalOf, E as resolveCurrency, Q as MoneyError, X as mulDiv, dt as roundToScale, it as formatDecimal, s as storedDecimal, t as boundedMoney, ut as pow10 } from "./money-WhnGiI00.js";
2
- //#region src/rounding.ts
1
+ import { B as decimalOf, E as resolveCurrency, Q as MoneyError, X as mulDiv, dt as roundToScale, it as formatDecimal, s as storedDecimal, t as boundedMoney, ut as pow10 } from "./money-BxbAw7BP.js";
2
+ // src/rounding.ts
3
3
  /** Internal: the size of `unit` in storage units. */
4
4
  function unitSize(info, unit) {
5
5
  if (unit === "storage") return 1n;
@@ -46,5 +46,4 @@ function roundMajor(major, currency, options = {}) {
46
46
  const digits = options.digits === "storage" ? info.storageDigits : info.displayDigits;
47
47
  return Number(formatDecimal(roundToScale(value, digits, options.rounding ?? "half-up")));
48
48
  }
49
- //#endregion
50
49
  export { unitSize as a, roundToUnit as i, roundMajor as n, roundStoredDecimal as r, mulDivToUnit as t };