@entifix/core 0.23.7 → 0.23.8
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.
- package/dist/i18n/format.d.ts +4 -3
- package/dist/i18n/format.d.ts.map +1 -1
- package/dist/i18n/format.js +13 -10
- package/dist/i18n/format.js.map +1 -1
- package/dist/i18n/locales.d.ts +15 -0
- package/dist/i18n/locales.d.ts.map +1 -1
- package/dist/i18n/locales.js +25 -1
- package/dist/i18n/locales.js.map +1 -1
- package/dist/i18n/scaled-number.d.ts +6 -5
- package/dist/i18n/scaled-number.d.ts.map +1 -1
- package/dist/i18n/scaled-number.js +26 -16
- package/dist/i18n/scaled-number.js.map +1 -1
- package/package.json +1 -1
package/dist/i18n/format.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Locale } from './locales.js';
|
|
2
2
|
export interface Formatters {
|
|
3
3
|
/** Calendar date only. */
|
|
4
4
|
date(value: Date | string | number): string;
|
|
@@ -9,8 +9,9 @@ export interface Formatters {
|
|
|
9
9
|
relative(value: number, unit: Intl.RelativeTimeFormatUnit): string;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
* Locale-aware formatting
|
|
13
|
-
* formatter is expensive and these
|
|
12
|
+
* Locale-aware formatting in the locale's `formattingLocale`, memoized per
|
|
13
|
+
* that tag because constructing an `Intl.*` formatter is expensive and these
|
|
14
|
+
* run once per table cell.
|
|
14
15
|
*
|
|
15
16
|
* This exists to kill an argument-less `toLocaleString()`, which resolves against
|
|
16
17
|
* the *runtime's* default locale — Node's on the server, the visitor's in the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/i18n/format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/i18n/format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAE7D,MAAM,WAAW,UAAU;IACzB,0BAA0B;IAC1B,IAAI,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAC5C,iCAAiC;IACjC,QAAQ,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAChD,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,GAAG,MAAM,CAAC;IAClE,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAClD,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,sBAAsB,GAAG,MAAM,CAAC;CACpE;AAUD;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAmCzD"}
|
package/dist/i18n/format.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import { formattingLocale } from './locales.js';
|
|
1
2
|
/** `undefined` for an unparseable input, so callers can fall back to the raw value. */ function toDate(value) {
|
|
2
3
|
const date = value instanceof Date ? value : new Date(value);
|
|
3
4
|
return Number.isNaN(date.getTime()) ? undefined : date;
|
|
4
5
|
}
|
|
5
6
|
const cache = new Map();
|
|
6
7
|
/**
|
|
7
|
-
* Locale-aware formatting
|
|
8
|
-
* formatter is expensive and these
|
|
8
|
+
* Locale-aware formatting in the locale's `formattingLocale`, memoized per
|
|
9
|
+
* that tag because constructing an `Intl.*` formatter is expensive and these
|
|
10
|
+
* run once per table cell.
|
|
9
11
|
*
|
|
10
12
|
* This exists to kill an argument-less `toLocaleString()`, which resolves against
|
|
11
13
|
* the *runtime's* default locale — Node's on the server, the visitor's in the
|
|
@@ -13,17 +15,18 @@ const cache = new Map();
|
|
|
13
15
|
* and React reported a hydration mismatch. Passing the negotiated locale
|
|
14
16
|
* explicitly makes both halves agree by construction.
|
|
15
17
|
*/ export function makeFormatters(locale) {
|
|
16
|
-
const
|
|
18
|
+
const tag = formattingLocale(locale);
|
|
19
|
+
const cached = cache.get(tag);
|
|
17
20
|
if (cached !== undefined) return cached;
|
|
18
|
-
const dateFormat = new Intl.DateTimeFormat(
|
|
21
|
+
const dateFormat = new Intl.DateTimeFormat(tag, {
|
|
19
22
|
dateStyle: 'medium'
|
|
20
23
|
});
|
|
21
|
-
const dateTimeFormat = new Intl.DateTimeFormat(
|
|
24
|
+
const dateTimeFormat = new Intl.DateTimeFormat(tag, {
|
|
22
25
|
dateStyle: 'medium',
|
|
23
26
|
timeStyle: 'short'
|
|
24
27
|
});
|
|
25
|
-
const numberFormat = new Intl.NumberFormat(
|
|
26
|
-
const relativeFormat = new Intl.RelativeTimeFormat(
|
|
28
|
+
const numberFormat = new Intl.NumberFormat(tag);
|
|
29
|
+
const relativeFormat = new Intl.RelativeTimeFormat(tag, {
|
|
27
30
|
numeric: 'auto'
|
|
28
31
|
});
|
|
29
32
|
const formatters = {
|
|
@@ -35,14 +38,14 @@ const cache = new Map();
|
|
|
35
38
|
const date = toDate(value);
|
|
36
39
|
return date === undefined ? String(value) : dateTimeFormat.format(date);
|
|
37
40
|
},
|
|
38
|
-
number: (value, options)=>options === undefined ? numberFormat.format(value) : new Intl.NumberFormat(
|
|
39
|
-
currency: (value, currency)=>new Intl.NumberFormat(
|
|
41
|
+
number: (value, options)=>options === undefined ? numberFormat.format(value) : new Intl.NumberFormat(tag, options).format(value),
|
|
42
|
+
currency: (value, currency)=>new Intl.NumberFormat(tag, {
|
|
40
43
|
style: 'currency',
|
|
41
44
|
currency
|
|
42
45
|
}).format(value),
|
|
43
46
|
relative: (value, unit)=>relativeFormat.format(value, unit)
|
|
44
47
|
};
|
|
45
|
-
cache.set(
|
|
48
|
+
cache.set(tag, formatters);
|
|
46
49
|
return formatters;
|
|
47
50
|
}
|
|
48
51
|
|
package/dist/i18n/format.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/i18n/format.ts"],"sourcesContent":["import type
|
|
1
|
+
{"version":3,"sources":["../../src/i18n/format.ts"],"sourcesContent":["import { formattingLocale, type Locale } from './locales.js';\n\nexport interface Formatters {\n /** Calendar date only. */\n date(value: Date | string | number): string;\n /** Date plus wall-clock time. */\n dateTime(value: Date | string | number): string;\n number(value: number, options?: Intl.NumberFormatOptions): string;\n currency(value: number, currency: string): string;\n relative(value: number, unit: Intl.RelativeTimeFormatUnit): string;\n}\n\n/** `undefined` for an unparseable input, so callers can fall back to the raw value. */\nfunction toDate(value: Date | string | number): Date | undefined {\n const date = value instanceof Date ? value : new Date(value);\n return Number.isNaN(date.getTime()) ? undefined : date;\n}\n\nconst cache = new Map<string, Formatters>();\n\n/**\n * Locale-aware formatting in the locale's `formattingLocale`, memoized per\n * that tag because constructing an `Intl.*` formatter is expensive and these\n * run once per table cell.\n *\n * This exists to kill an argument-less `toLocaleString()`, which resolves against\n * the *runtime's* default locale — Node's on the server, the visitor's in the\n * browser. Those disagree, so the same cell rendered twice produced two strings\n * and React reported a hydration mismatch. Passing the negotiated locale\n * explicitly makes both halves agree by construction.\n */\nexport function makeFormatters(locale: Locale): Formatters {\n const tag = formattingLocale(locale);\n const cached = cache.get(tag);\n if (cached !== undefined) return cached;\n\n const dateFormat = new Intl.DateTimeFormat(tag, { dateStyle: 'medium' });\n const dateTimeFormat = new Intl.DateTimeFormat(tag, {\n dateStyle: 'medium',\n timeStyle: 'short',\n });\n const numberFormat = new Intl.NumberFormat(tag);\n const relativeFormat = new Intl.RelativeTimeFormat(tag, {\n numeric: 'auto',\n });\n\n const formatters: Formatters = {\n date: value => {\n const date = toDate(value);\n return date === undefined ? String(value) : dateFormat.format(date);\n },\n dateTime: value => {\n const date = toDate(value);\n return date === undefined ? String(value) : dateTimeFormat.format(date);\n },\n number: (value, options) =>\n options === undefined\n ? numberFormat.format(value)\n : new Intl.NumberFormat(tag, options).format(value),\n currency: (value, currency) =>\n new Intl.NumberFormat(tag, { style: 'currency', currency }).format(value),\n relative: (value, unit) => relativeFormat.format(value, unit),\n };\n\n cache.set(tag, formatters);\n return formatters;\n}\n"],"names":["formattingLocale","toDate","value","date","Date","Number","isNaN","getTime","undefined","cache","Map","makeFormatters","locale","tag","cached","get","dateFormat","Intl","DateTimeFormat","dateStyle","dateTimeFormat","timeStyle","numberFormat","NumberFormat","relativeFormat","RelativeTimeFormat","numeric","formatters","String","format","dateTime","number","options","currency","style","relative","unit","set"],"mappings":"AAAA,SAASA,gBAAgB,QAAqB,eAAe;AAY7D,qFAAqF,GACrF,SAASC,OAAOC,KAA6B;IAC3C,MAAMC,OAAOD,iBAAiBE,OAAOF,QAAQ,IAAIE,KAAKF;IACtD,OAAOG,OAAOC,KAAK,CAACH,KAAKI,OAAO,MAAMC,YAAYL;AACpD;AAEA,MAAMM,QAAQ,IAAIC;AAElB;;;;;;;;;;CAUC,GACD,OAAO,SAASC,eAAeC,MAAc;IAC3C,MAAMC,MAAMb,iBAAiBY;IAC7B,MAAME,SAASL,MAAMM,GAAG,CAACF;IACzB,IAAIC,WAAWN,WAAW,OAAOM;IAEjC,MAAME,aAAa,IAAIC,KAAKC,cAAc,CAACL,KAAK;QAAEM,WAAW;IAAS;IACtE,MAAMC,iBAAiB,IAAIH,KAAKC,cAAc,CAACL,KAAK;QAClDM,WAAW;QACXE,WAAW;IACb;IACA,MAAMC,eAAe,IAAIL,KAAKM,YAAY,CAACV;IAC3C,MAAMW,iBAAiB,IAAIP,KAAKQ,kBAAkB,CAACZ,KAAK;QACtDa,SAAS;IACX;IAEA,MAAMC,aAAyB;QAC7BxB,MAAMD,CAAAA;YACJ,MAAMC,OAAOF,OAAOC;YACpB,OAAOC,SAASK,YAAYoB,OAAO1B,SAASc,WAAWa,MAAM,CAAC1B;QAChE;QACA2B,UAAU5B,CAAAA;YACR,MAAMC,OAAOF,OAAOC;YACpB,OAAOC,SAASK,YAAYoB,OAAO1B,SAASkB,eAAeS,MAAM,CAAC1B;QACpE;QACA4B,QAAQ,CAAC7B,OAAO8B,UACdA,YAAYxB,YACRc,aAAaO,MAAM,CAAC3B,SACpB,IAAIe,KAAKM,YAAY,CAACV,KAAKmB,SAASH,MAAM,CAAC3B;QACjD+B,UAAU,CAAC/B,OAAO+B,WAChB,IAAIhB,KAAKM,YAAY,CAACV,KAAK;gBAAEqB,OAAO;gBAAYD;YAAS,GAAGJ,MAAM,CAAC3B;QACrEiC,UAAU,CAACjC,OAAOkC,OAASZ,eAAeK,MAAM,CAAC3B,OAAOkC;IAC1D;IAEA3B,MAAM4B,GAAG,CAACxB,KAAKc;IACf,OAAOA;AACT"}
|
package/dist/i18n/locales.d.ts
CHANGED
|
@@ -28,6 +28,15 @@ export interface LocaleDefinition {
|
|
|
28
28
|
* catalog key falls back to.
|
|
29
29
|
*/
|
|
30
30
|
readonly defaultLocale: Locale;
|
|
31
|
+
/**
|
|
32
|
+
* The conventions each locale formats numbers, money and dates in, where
|
|
33
|
+
* they are not the language's own: `{ es: 'es-GT' }` writes `64.99` where
|
|
34
|
+
* `es` writes `64,99`. Catalogs, routing and the cookie keep the locale.
|
|
35
|
+
*
|
|
36
|
+
* Left out, what was declared before stands for the locales still listed,
|
|
37
|
+
* so a second declaration of the same locales cannot undo it; `{}` clears it.
|
|
38
|
+
*/
|
|
39
|
+
readonly formattingLocales?: Readonly<Partial<Record<Locale, string>>>;
|
|
31
40
|
}
|
|
32
41
|
/**
|
|
33
42
|
* Declares the host's locales. Call it once, from a module every entry point
|
|
@@ -40,6 +49,12 @@ export interface LocaleDefinition {
|
|
|
40
49
|
* third locale needs no change to entifix.
|
|
41
50
|
*/
|
|
42
51
|
export declare function defineLocales(definition: LocaleDefinition): void;
|
|
52
|
+
/**
|
|
53
|
+
* The tag to hand `Intl` for `locale`: the one the host declared in
|
|
54
|
+
* `formattingLocales`, or the locale itself. Every formatter and parser here
|
|
55
|
+
* asks it, so a caller passes the locale it renders in and nothing else.
|
|
56
|
+
*/
|
|
57
|
+
export declare function formattingLocale(locale: string): string;
|
|
43
58
|
/** The locales the host declared. */
|
|
44
59
|
export declare function locales(): readonly Locale[];
|
|
45
60
|
/** The host's default locale. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locales.d.ts","sourceRoot":"","sources":["../../src/i18n/locales.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,MAAM,WAAW,cAAc;CAAG;AAElC,uEAAuE;AACvE,MAAM,MAAM,MAAM,GAAG,cAAc,SAAS;IAAE,MAAM,EAAE,MAAM,CAAC,SAAS,MAAM,CAAA;CAAE,GAC1E,CAAC,GACD,MAAM,CAAC;AAEX,0DAA0D;AAC1D,MAAM,WAAW,gBAAgB;IAC/B,wEAAwE;IACxE,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC;;;OAGG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"locales.d.ts","sourceRoot":"","sources":["../../src/i18n/locales.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,MAAM,WAAW,cAAc;CAAG;AAElC,uEAAuE;AACvE,MAAM,MAAM,MAAM,GAAG,cAAc,SAAS;IAAE,MAAM,EAAE,MAAM,CAAC,SAAS,MAAM,CAAA;CAAE,GAC1E,CAAC,GACD,MAAM,CAAC;AAEX,0DAA0D;AAC1D,MAAM,WAAW,gBAAgB;IAC/B,wEAAwE;IACxE,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC;;;OAGG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B;;;;;;;OAOG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;CACxE;AAeD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,gBAAgB,GAAG,IAAI,CAuChE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,qCAAqC;AACrC,wBAAgB,OAAO,IAAI,SAAS,MAAM,EAAE,CAE3C;AAED,iCAAiC;AACjC,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,iDAAiD;AACjD,wBAAgB,YAAY,IAAI,IAAI,CAGnC;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,mBAAmB,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,aAAa,qBAAqB,CAAC;AAEhD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAKxD"}
|
package/dist/i18n/locales.js
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
defaultLocale: 'en'
|
|
26
26
|
};
|
|
27
27
|
let declared = UNDECLARED;
|
|
28
|
+
let formatting = new Map();
|
|
28
29
|
/**
|
|
29
30
|
* Declares the host's locales. Call it once, from a module every entry point
|
|
30
31
|
* imports — including a Next middleware, which is bundled on its own and shares
|
|
@@ -35,7 +36,7 @@ let declared = UNDECLARED;
|
|
|
35
36
|
* `['en', 'es']` with `en` first gets English as the fallback everywhere, and a
|
|
36
37
|
* third locale needs no change to entifix.
|
|
37
38
|
*/ export function defineLocales(definition) {
|
|
38
|
-
const { locales: list, defaultLocale: fallback } = definition;
|
|
39
|
+
const { locales: list, defaultLocale: fallback, formattingLocales } = definition;
|
|
39
40
|
if (list.length === 0) {
|
|
40
41
|
throw new Error('defineLocales needs at least one locale.');
|
|
41
42
|
}
|
|
@@ -46,6 +47,20 @@ let declared = UNDECLARED;
|
|
|
46
47
|
if (!list.includes(fallback)) {
|
|
47
48
|
throw new Error(`The default locale "${fallback}" is not one of ${JSON.stringify(list)}.`);
|
|
48
49
|
}
|
|
50
|
+
const next = new Map(formattingLocales === undefined ? [
|
|
51
|
+
...formatting
|
|
52
|
+
].filter(([locale])=>list.includes(locale)) : Object.entries(formattingLocales));
|
|
53
|
+
for (const [locale, tag] of next){
|
|
54
|
+
if (!list.includes(locale)) {
|
|
55
|
+
throw new Error(`The formatting locale's key "${locale}" is not one of ${JSON.stringify(list)}.`);
|
|
56
|
+
}
|
|
57
|
+
// A tag without data formats as the runtime's own locale, which is a
|
|
58
|
+
// different one on the server and in the browser.
|
|
59
|
+
if (Intl.NumberFormat.supportedLocalesOf(tag).length === 0) {
|
|
60
|
+
throw new Error(`Intl has no formats for the locale "${tag}".`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
formatting = next;
|
|
49
64
|
declared = {
|
|
50
65
|
locales: [
|
|
51
66
|
...list
|
|
@@ -53,6 +68,14 @@ let declared = UNDECLARED;
|
|
|
53
68
|
defaultLocale: fallback
|
|
54
69
|
};
|
|
55
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* The tag to hand `Intl` for `locale`: the one the host declared in
|
|
73
|
+
* `formattingLocales`, or the locale itself. Every formatter and parser here
|
|
74
|
+
* asks it, so a caller passes the locale it renders in and nothing else.
|
|
75
|
+
*/ export function formattingLocale(locale) {
|
|
76
|
+
var _formatting_get;
|
|
77
|
+
return (_formatting_get = formatting.get(locale)) != null ? _formatting_get : locale;
|
|
78
|
+
}
|
|
56
79
|
/** The locales the host declared. */ export function locales() {
|
|
57
80
|
return declared.locales;
|
|
58
81
|
}
|
|
@@ -61,6 +84,7 @@ let declared = UNDECLARED;
|
|
|
61
84
|
}
|
|
62
85
|
/** Forgets the host's declaration. For specs. */ export function resetLocales() {
|
|
63
86
|
declared = UNDECLARED;
|
|
87
|
+
formatting = new Map();
|
|
64
88
|
}
|
|
65
89
|
/**
|
|
66
90
|
* Host-scoped so the choice is shared across the fleet's localhost ports in dev,
|
package/dist/i18n/locales.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/i18n/locales.ts"],"sourcesContent":["/**\n * Where a host narrows {@link Locale} to the locales it ships:\n *\n * ```ts\n * declare module '@entifix/core' {\n * interface LocaleRegister {\n * locale: 'es' | 'en';\n * }\n * }\n * ```\n *\n * The same mechanism i18next's `CustomTypeOptions` uses. Without it a locale is\n * any string, which is honest for a framework that does not know which\n * languages its host speaks.\n */\n// An empty interface is the point: a host merges its declaration into it.\n// eslint-disable-next-line @typescript-eslint/no-empty-interface, @typescript-eslint/no-empty-object-type\nexport interface LocaleRegister {}\n\n/** A locale the host declared, or any string when it declared none. */\nexport type Locale = LocaleRegister extends { locale: infer L extends string }\n ? L\n : string;\n\n/** What a host declares through {@link defineLocales}. */\nexport interface LocaleDefinition {\n /** Every locale the host ships, in the order a switcher offers them. */\n readonly locales: readonly Locale[];\n /**\n * The locale a visitor gets when nothing else decides, and the one a missing\n * catalog key falls back to.\n */\n readonly defaultLocale: Locale;\n}\n\n/**\n * What a host gets when it declares nothing: English alone. Neutral rather than\n * any one adopter's choice — the adopter that once supplied the `es` default\n * here now declares it like everyone else (#35).\n */\nconst UNDECLARED: LocaleDefinition = {\n locales: ['en' as Locale],\n defaultLocale: 'en' as Locale,\n};\n\nlet declared: LocaleDefinition = UNDECLARED;\n\n/**\n * Declares the host's locales. Call it once, from a module every entry point\n * imports — including a Next middleware, which is bundled on its own and shares\n * no module state with the server.\n *\n * Read at call time by every helper below and by `@entifix/i18n`,\n * `@entifix/react-controls` and `@entifix/next-i18n`, so a host declaring\n * `['en', 'es']` with `en` first gets English as the fallback everywhere, and a\n * third locale needs no change to entifix.\n */\nexport function defineLocales(definition: LocaleDefinition): void {\n const {
|
|
1
|
+
{"version":3,"sources":["../../src/i18n/locales.ts"],"sourcesContent":["/**\n * Where a host narrows {@link Locale} to the locales it ships:\n *\n * ```ts\n * declare module '@entifix/core' {\n * interface LocaleRegister {\n * locale: 'es' | 'en';\n * }\n * }\n * ```\n *\n * The same mechanism i18next's `CustomTypeOptions` uses. Without it a locale is\n * any string, which is honest for a framework that does not know which\n * languages its host speaks.\n */\n// An empty interface is the point: a host merges its declaration into it.\n// eslint-disable-next-line @typescript-eslint/no-empty-interface, @typescript-eslint/no-empty-object-type\nexport interface LocaleRegister {}\n\n/** A locale the host declared, or any string when it declared none. */\nexport type Locale = LocaleRegister extends { locale: infer L extends string }\n ? L\n : string;\n\n/** What a host declares through {@link defineLocales}. */\nexport interface LocaleDefinition {\n /** Every locale the host ships, in the order a switcher offers them. */\n readonly locales: readonly Locale[];\n /**\n * The locale a visitor gets when nothing else decides, and the one a missing\n * catalog key falls back to.\n */\n readonly defaultLocale: Locale;\n /**\n * The conventions each locale formats numbers, money and dates in, where\n * they are not the language's own: `{ es: 'es-GT' }` writes `64.99` where\n * `es` writes `64,99`. Catalogs, routing and the cookie keep the locale.\n *\n * Left out, what was declared before stands for the locales still listed,\n * so a second declaration of the same locales cannot undo it; `{}` clears it.\n */\n readonly formattingLocales?: Readonly<Partial<Record<Locale, string>>>;\n}\n\n/**\n * What a host gets when it declares nothing: English alone. Neutral rather than\n * any one adopter's choice — the adopter that once supplied the `es` default\n * here now declares it like everyone else (#35).\n */\nconst UNDECLARED: LocaleDefinition = {\n locales: ['en' as Locale],\n defaultLocale: 'en' as Locale,\n};\n\nlet declared: LocaleDefinition = UNDECLARED;\nlet formatting: ReadonlyMap<string, string> = new Map();\n\n/**\n * Declares the host's locales. Call it once, from a module every entry point\n * imports — including a Next middleware, which is bundled on its own and shares\n * no module state with the server.\n *\n * Read at call time by every helper below and by `@entifix/i18n`,\n * `@entifix/react-controls` and `@entifix/next-i18n`, so a host declaring\n * `['en', 'es']` with `en` first gets English as the fallback everywhere, and a\n * third locale needs no change to entifix.\n */\nexport function defineLocales(definition: LocaleDefinition): void {\n const {\n locales: list,\n defaultLocale: fallback,\n formattingLocales,\n } = definition;\n if (list.length === 0) {\n throw new Error('defineLocales needs at least one locale.');\n }\n const duplicate = list.find(\n (locale, index) => list.indexOf(locale) !== index,\n );\n if (duplicate !== undefined) {\n throw new Error(`defineLocales was given \"${duplicate}\" more than once.`);\n }\n if (!list.includes(fallback)) {\n throw new Error(\n `The default locale \"${fallback}\" is not one of ${JSON.stringify(list)}.`,\n );\n }\n const next = new Map(\n formattingLocales === undefined\n ? [...formatting].filter(([locale]) => list.includes(locale as Locale))\n : (Object.entries(formattingLocales) as [string, string][]),\n );\n for (const [locale, tag] of next) {\n if (!list.includes(locale as Locale)) {\n throw new Error(\n `The formatting locale's key \"${locale}\" is not one of ${JSON.stringify(list)}.`,\n );\n }\n // A tag without data formats as the runtime's own locale, which is a\n // different one on the server and in the browser.\n if (Intl.NumberFormat.supportedLocalesOf(tag).length === 0) {\n throw new Error(`Intl has no formats for the locale \"${tag}\".`);\n }\n }\n formatting = next;\n declared = { locales: [...list], defaultLocale: fallback };\n}\n\n/**\n * The tag to hand `Intl` for `locale`: the one the host declared in\n * `formattingLocales`, or the locale itself. Every formatter and parser here\n * asks it, so a caller passes the locale it renders in and nothing else.\n */\nexport function formattingLocale(locale: string): string {\n return formatting.get(locale) ?? locale;\n}\n\n/** The locales the host declared. */\nexport function locales(): readonly Locale[] {\n return declared.locales;\n}\n\n/** The host's default locale. */\nexport function defaultLocale(): Locale {\n return declared.defaultLocale;\n}\n\n/** Forgets the host's declaration. For specs. */\nexport function resetLocales(): void {\n declared = UNDECLARED;\n formatting = new Map();\n}\n\n/**\n * Host-scoped so the choice is shared across the fleet's localhost ports in dev,\n * exactly like `entifix_at`/`entifix_sid`. Written by the locale middleware on every\n * redirect, so a visitor who lands on `/en/...` keeps English on the next visit.\n */\nexport const LOCALE_COOKIE = 'entifix_locale';\n\n/**\n * Request header the locale middleware sets when it rewrites a prefixed path.\n * Server components read it instead of a route param, which is what lets the\n * route tree stay free of an `app/[locale]` segment.\n */\nexport const LOCALE_HEADER = 'x-entifix-locale';\n\nexport function isLocale(value: unknown): value is Locale {\n return (\n typeof value === 'string' &&\n (declared.locales as readonly string[]).includes(value)\n );\n}\n"],"names":["UNDECLARED","locales","defaultLocale","declared","formatting","Map","defineLocales","definition","list","fallback","formattingLocales","length","Error","duplicate","find","locale","index","indexOf","undefined","includes","JSON","stringify","next","filter","Object","entries","tag","Intl","NumberFormat","supportedLocalesOf","formattingLocale","get","resetLocales","LOCALE_COOKIE","LOCALE_HEADER","isLocale","value"],"mappings":"AAAA;;;;;;;;;;;;;;CAcC,GACD,0EAA0E;AAC1E,0GAA0G;AA4B1G;;;;CAIC,GACD,MAAMA,aAA+B;IACnCC,SAAS;QAAC;KAAe;IACzBC,eAAe;AACjB;AAEA,IAAIC,WAA6BH;AACjC,IAAII,aAA0C,IAAIC;AAElD;;;;;;;;;CASC,GACD,OAAO,SAASC,cAAcC,UAA4B;IACxD,MAAM,EACJN,SAASO,IAAI,EACbN,eAAeO,QAAQ,EACvBC,iBAAiB,EAClB,GAAGH;IACJ,IAAIC,KAAKG,MAAM,KAAK,GAAG;QACrB,MAAM,IAAIC,MAAM;IAClB;IACA,MAAMC,YAAYL,KAAKM,IAAI,CACzB,CAACC,QAAQC,QAAUR,KAAKS,OAAO,CAACF,YAAYC;IAE9C,IAAIH,cAAcK,WAAW;QAC3B,MAAM,IAAIN,MAAM,CAAC,yBAAyB,EAAEC,UAAU,iBAAiB,CAAC;IAC1E;IACA,IAAI,CAACL,KAAKW,QAAQ,CAACV,WAAW;QAC5B,MAAM,IAAIG,MACR,CAAC,oBAAoB,EAAEH,SAAS,gBAAgB,EAAEW,KAAKC,SAAS,CAACb,MAAM,CAAC,CAAC;IAE7E;IACA,MAAMc,OAAO,IAAIjB,IACfK,sBAAsBQ,YAClB;WAAId;KAAW,CAACmB,MAAM,CAAC,CAAC,CAACR,OAAO,GAAKP,KAAKW,QAAQ,CAACJ,WAClDS,OAAOC,OAAO,CAACf;IAEtB,KAAK,MAAM,CAACK,QAAQW,IAAI,IAAIJ,KAAM;QAChC,IAAI,CAACd,KAAKW,QAAQ,CAACJ,SAAmB;YACpC,MAAM,IAAIH,MACR,CAAC,6BAA6B,EAAEG,OAAO,gBAAgB,EAAEK,KAAKC,SAAS,CAACb,MAAM,CAAC,CAAC;QAEpF;QACA,qEAAqE;QACrE,kDAAkD;QAClD,IAAImB,KAAKC,YAAY,CAACC,kBAAkB,CAACH,KAAKf,MAAM,KAAK,GAAG;YAC1D,MAAM,IAAIC,MAAM,CAAC,oCAAoC,EAAEc,IAAI,EAAE,CAAC;QAChE;IACF;IACAtB,aAAakB;IACbnB,WAAW;QAAEF,SAAS;eAAIO;SAAK;QAAEN,eAAeO;IAAS;AAC3D;AAEA;;;;CAIC,GACD,OAAO,SAASqB,iBAAiBf,MAAc;QACtCX;IAAP,QAAOA,kBAAAA,WAAW2B,GAAG,CAAChB,mBAAfX,kBAA0BW;AACnC;AAEA,mCAAmC,GACnC,OAAO,SAASd;IACd,OAAOE,SAASF,OAAO;AACzB;AAEA,+BAA+B,GAC/B,OAAO,SAASC;IACd,OAAOC,SAASD,aAAa;AAC/B;AAEA,+CAA+C,GAC/C,OAAO,SAAS8B;IACd7B,WAAWH;IACXI,aAAa,IAAIC;AACnB;AAEA;;;;CAIC,GACD,OAAO,MAAM4B,gBAAgB,iBAAiB;AAE9C;;;;CAIC,GACD,OAAO,MAAMC,gBAAgB,mBAAmB;AAEhD,OAAO,SAASC,SAASC,KAAc;IACrC,OACE,OAAOA,UAAU,YACjB,AAACjC,SAASF,OAAO,CAAuBkB,QAAQ,CAACiB;AAErD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Locale } from './locales.js';
|
|
2
2
|
/**
|
|
3
3
|
* The most decimals a scale can carry and still leave a safe integer room to
|
|
4
4
|
* count with.
|
|
@@ -15,10 +15,11 @@ export declare const MAX_SCALE = 15;
|
|
|
15
15
|
* - either separator opens a fraction (`64,99`, `64.99`), because people type
|
|
16
16
|
* both whatever their locale;
|
|
17
17
|
* - grouping is accepted where it can only be grouping (`1.234,56`,
|
|
18
|
-
* `12.500.000
|
|
19
|
-
* -
|
|
20
|
-
*
|
|
21
|
-
*
|
|
18
|
+
* `12.500.000`);
|
|
19
|
+
* - one separator and three digits could be either. In the decimal separator
|
|
20
|
+
* of the locale's `formattingLocale` it is always a fraction, so `64.999` at
|
|
21
|
+
* scale 2 is refused in `en` and never 64,999. In the other one it is a
|
|
22
|
+
* thousand below scale 3 (`1,000`) and refused from there on.
|
|
22
23
|
*/
|
|
23
24
|
export declare function parseScaled(text: string, scale: number, locale: Locale): number | undefined;
|
|
24
25
|
/** The plain decimal a scaled integer stands for: `3500` at 3 is `'3.5'`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scaled-number.d.ts","sourceRoot":"","sources":["../../src/i18n/scaled-number.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"scaled-number.d.ts","sourceRoot":"","sources":["../../src/i18n/scaled-number.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAE7D;;;GAGG;AACH,eAAO,MAAM,SAAS,KAAK,CAAC;AAsE5B;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,MAAM,GAAG,SAAS,CAUpB;AAED,6EAA6E;AAC7E,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAUpE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,EAAE,QAAe,EAAE,GAAE;IAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAO,GACxD,MAAM,CAYR"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { formattingLocale } from './locales.js';
|
|
1
2
|
/**
|
|
2
3
|
* The most decimals a scale can carry and still leave a safe integer room to
|
|
3
4
|
* count with.
|
|
@@ -5,10 +6,11 @@
|
|
|
5
6
|
const decimalSeparators = new Map();
|
|
6
7
|
/** The character `locale` writes before a fraction. */ function decimalSeparatorOf(locale) {
|
|
7
8
|
var _formatToParts_find;
|
|
8
|
-
const
|
|
9
|
+
const tag = formattingLocale(locale);
|
|
10
|
+
const known = decimalSeparators.get(tag);
|
|
9
11
|
if (known !== undefined) return known;
|
|
10
|
-
const separator = ((_formatToParts_find = new Intl.NumberFormat(
|
|
11
|
-
decimalSeparators.set(
|
|
12
|
+
const separator = ((_formatToParts_find = new Intl.NumberFormat(tag).formatToParts(1.5).find((part)=>part.type === 'decimal')) == null ? void 0 : _formatToParts_find.value) === ',' ? ',' : '.';
|
|
13
|
+
decimalSeparators.set(tag, separator);
|
|
12
14
|
return separator;
|
|
13
15
|
}
|
|
14
16
|
/** Digits grouped in threes by one separator: `1,000`, `12.500.000`. */ const groupedBy = (separator)=>new RegExp(`^[1-9]\\d{0,2}(?:\\${separator}\\d{3})+$`);
|
|
@@ -32,6 +34,11 @@ const GROUPED = {
|
|
|
32
34
|
const other = separator === ',' ? '.' : ',';
|
|
33
35
|
// Both separators: the last opens the fraction, the other groups.
|
|
34
36
|
if (head.includes(other)) {
|
|
37
|
+
// With nothing after it, only the locale's decimal separator opens one:
|
|
38
|
+
// `64.999,` in `en` is a slip, not sixty-four thousand.
|
|
39
|
+
if (tail === '' && separator !== decimalSeparatorOf(locale)) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
35
42
|
return GROUPED[other].test(head) ? [
|
|
36
43
|
head.replaceAll(other, ''),
|
|
37
44
|
tail
|
|
@@ -45,16 +52,17 @@ const GROUPED = {
|
|
|
45
52
|
] : undefined;
|
|
46
53
|
}
|
|
47
54
|
if (GROUPED[separator].test(text)) {
|
|
48
|
-
// `
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
''
|
|
52
|
-
];
|
|
53
|
-
// They fit, so it could be either. The reader's own decimal separator is
|
|
54
|
-
// the one this member is shown with; the other one is refused.
|
|
55
|
-
return separator === decimalSeparatorOf(locale) ? [
|
|
55
|
+
// `64.999` where `.` opens fractions is never sixty-four thousand, however
|
|
56
|
+
// few decimals fit: it is a fraction, and refused where that is too long.
|
|
57
|
+
if (separator === decimalSeparatorOf(locale)) return [
|
|
56
58
|
head,
|
|
57
59
|
tail
|
|
60
|
+
];
|
|
61
|
+
// The other separator groups, unless three decimals fit: then it could be
|
|
62
|
+
// either, and is refused.
|
|
63
|
+
return scale < 3 ? [
|
|
64
|
+
head + tail,
|
|
65
|
+
''
|
|
58
66
|
] : undefined;
|
|
59
67
|
}
|
|
60
68
|
return [
|
|
@@ -73,10 +81,11 @@ const GROUPED = {
|
|
|
73
81
|
* - either separator opens a fraction (`64,99`, `64.99`), because people type
|
|
74
82
|
* both whatever their locale;
|
|
75
83
|
* - grouping is accepted where it can only be grouping (`1.234,56`,
|
|
76
|
-
* `12.500.000
|
|
77
|
-
* -
|
|
78
|
-
*
|
|
79
|
-
*
|
|
84
|
+
* `12.500.000`);
|
|
85
|
+
* - one separator and three digits could be either. In the decimal separator
|
|
86
|
+
* of the locale's `formattingLocale` it is always a fraction, so `64.999` at
|
|
87
|
+
* scale 2 is refused in `en` and never 64,999. In the other one it is a
|
|
88
|
+
* thousand below scale 3 (`1,000`) and refused from there on.
|
|
80
89
|
*/ export function parseScaled(text, scale, locale) {
|
|
81
90
|
var _ref;
|
|
82
91
|
var _exec;
|
|
@@ -107,12 +116,13 @@ const GROUPED = {
|
|
|
107
116
|
var _ref;
|
|
108
117
|
var _decimal_split_;
|
|
109
118
|
const decimal = scaledToDecimal(value, scale);
|
|
119
|
+
const tag = formattingLocale(locale);
|
|
110
120
|
if (!grouping) return decimal.replace('.', decimalSeparatorOf(locale));
|
|
111
121
|
const fraction = (_ref = (_decimal_split_ = decimal.split('.')[1]) == null ? void 0 : _decimal_split_.length) != null ? _ref : 0;
|
|
112
122
|
// `format` takes a decimal string exactly (ES2023), so a long count is never
|
|
113
123
|
// rounded through a float on its way to the screen. The cast is for this
|
|
114
124
|
// package's `lib`, whose typings predate that overload.
|
|
115
|
-
return new Intl.NumberFormat(
|
|
125
|
+
return new Intl.NumberFormat(tag, {
|
|
116
126
|
minimumFractionDigits: fraction,
|
|
117
127
|
maximumFractionDigits: fraction
|
|
118
128
|
}).format(decimal);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/i18n/scaled-number.ts"],"sourcesContent":["import type
|
|
1
|
+
{"version":3,"sources":["../../src/i18n/scaled-number.ts"],"sourcesContent":["import { formattingLocale, type Locale } from './locales.js';\n\n/**\n * The most decimals a scale can carry and still leave a safe integer room to\n * count with.\n */\nexport const MAX_SCALE = 15;\n\nconst decimalSeparators = new Map<string, string>();\n\n/** The character `locale` writes before a fraction. */\nfunction decimalSeparatorOf(locale: Locale): string {\n const tag = formattingLocale(locale);\n const known = decimalSeparators.get(tag);\n if (known !== undefined) return known;\n const separator =\n new Intl.NumberFormat(tag)\n .formatToParts(1.5)\n .find(part => part.type === 'decimal')?.value === ','\n ? ','\n : '.';\n decimalSeparators.set(tag, separator);\n return separator;\n}\n\n/** Digits grouped in threes by one separator: `1,000`, `12.500.000`. */\nconst groupedBy = (separator: string) =>\n new RegExp(`^[1-9]\\\\d{0,2}(?:\\\\${separator}\\\\d{3})+$`);\n\nconst GROUPED = { ',': groupedBy(','), '.': groupedBy('.') } as const;\n\n/**\n * The whole and fraction digits `text` writes, or `undefined` when it writes\n * no number or could write two.\n */\nfunction digitsOf(\n text: string,\n scale: number,\n locale: Locale,\n): readonly [whole: string, fraction: string] | undefined {\n if (!/^[\\d.,]+$/.test(text) || !/\\d/.test(text)) return undefined;\n const last = Math.max(text.lastIndexOf(','), text.lastIndexOf('.'));\n if (last === -1) return [text, ''];\n const separator = text.charAt(last) as ',' | '.';\n const head = text.slice(0, last);\n const tail = text.slice(last + 1);\n const other = separator === ',' ? '.' : ',';\n\n // Both separators: the last opens the fraction, the other groups.\n if (head.includes(other)) {\n // With nothing after it, only the locale's decimal separator opens one:\n // `64.999,` in `en` is a slip, not sixty-four thousand.\n if (tail === '' && separator !== decimalSeparatorOf(locale)) {\n return undefined;\n }\n return GROUPED[other].test(head)\n ? [head.replaceAll(other, ''), tail]\n : undefined;\n }\n // One separator, repeated: it can only be grouping.\n if (head.includes(separator)) {\n return GROUPED[separator].test(text)\n ? [text.replaceAll(separator, ''), '']\n : undefined;\n }\n if (GROUPED[separator].test(text)) {\n // `64.999` where `.` opens fractions is never sixty-four thousand, however\n // few decimals fit: it is a fraction, and refused where that is too long.\n if (separator === decimalSeparatorOf(locale)) return [head, tail];\n // The other separator groups, unless three decimals fit: then it could be\n // either, and is refused.\n return scale < 3 ? [head + tail, ''] : undefined;\n }\n return [head, tail];\n}\n\n/**\n * The integer `text` stands for in `scale` decimals — `'3,5'` at scale 3 is\n * `3500` — or `undefined` when it stands for none. Read digit by digit and\n * never through a float.\n *\n * **It never rounds and never guesses.** More decimals than the scale holds is\n * not a number here, and neither is text with two readings:\n *\n * - either separator opens a fraction (`64,99`, `64.99`), because people type\n * both whatever their locale;\n * - grouping is accepted where it can only be grouping (`1.234,56`,\n * `12.500.000`);\n * - one separator and three digits could be either. In the decimal separator\n * of the locale's `formattingLocale` it is always a fraction, so `64.999` at\n * scale 2 is refused in `en` and never 64,999. In the other one it is a\n * thousand below scale 3 (`1,000`) and refused from there on.\n */\nexport function parseScaled(\n text: string,\n scale: number,\n locale: Locale,\n): number | undefined {\n const compact = text.replace(/[\\s'’]/g, '');\n const sign = /^[+-]/.exec(compact)?.[0] ?? '';\n const digits = digitsOf(compact.slice(sign.length), scale, locale);\n if (digits === undefined) return undefined;\n const [whole, fraction] = digits;\n if (fraction.length > scale) return undefined;\n const magnitude = BigInt(`${whole}${fraction.padEnd(scale, '0')}`);\n if (magnitude > BigInt(Number.MAX_SAFE_INTEGER)) return undefined;\n return magnitude === 0n ? 0 : Number(magnitude) * (sign === '-' ? -1 : 1);\n}\n\n/** The plain decimal a scaled integer stands for: `3500` at 3 is `'3.5'`. */\nexport function scaledToDecimal(value: number, scale: number): string {\n if (!Number.isSafeInteger(value)) {\n throw new RangeError(`${String(value)} is not a scaled integer`);\n }\n const digits = String(Math.abs(value)).padStart(scale + 1, '0');\n const at = digits.length - scale;\n const fraction = digits.slice(at).replace(/0+$/, '');\n return `${value < 0 ? '-' : ''}${digits.slice(0, at)}${\n fraction === '' ? '' : `.${fraction}`\n }`;\n}\n\n/**\n * A scaled integer as the reader's locale writes it, with no more decimals\n * than it has. With `grouping: false` it is the text to edit: Latin digits in\n * the locale's decimal separator, which `parseScaled` reads back exactly.\n */\nexport function formatScaled(\n value: number,\n scale: number,\n locale: Locale,\n { grouping = true }: { readonly grouping?: boolean } = {},\n): string {\n const decimal = scaledToDecimal(value, scale);\n const tag = formattingLocale(locale);\n if (!grouping) return decimal.replace('.', decimalSeparatorOf(locale));\n const fraction = decimal.split('.')[1]?.length ?? 0;\n // `format` takes a decimal string exactly (ES2023), so a long count is never\n // rounded through a float on its way to the screen. The cast is for this\n // package's `lib`, whose typings predate that overload.\n return new Intl.NumberFormat(tag, {\n minimumFractionDigits: fraction,\n maximumFractionDigits: fraction,\n }).format(decimal as unknown as number);\n}\n"],"names":["formattingLocale","MAX_SCALE","decimalSeparators","Map","decimalSeparatorOf","locale","tag","known","get","undefined","separator","Intl","NumberFormat","formatToParts","find","part","type","value","set","groupedBy","RegExp","GROUPED","digitsOf","text","scale","test","last","Math","max","lastIndexOf","charAt","head","slice","tail","other","includes","replaceAll","parseScaled","compact","replace","sign","exec","digits","length","whole","fraction","magnitude","BigInt","padEnd","Number","MAX_SAFE_INTEGER","scaledToDecimal","isSafeInteger","RangeError","String","abs","padStart","at","formatScaled","grouping","decimal","split","minimumFractionDigits","maximumFractionDigits","format"],"mappings":"AAAA,SAASA,gBAAgB,QAAqB,eAAe;AAE7D;;;CAGC,GACD,OAAO,MAAMC,YAAY,GAAG;AAE5B,MAAMC,oBAAoB,IAAIC;AAE9B,qDAAqD,GACrD,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