arqam 1.1.1 → 2.0.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.
- package/LICENSE +21 -0
- package/README.md +888 -0
- package/dist/SRI.txt +5 -0
- package/dist/arqamAR.d.mts +683 -0
- package/dist/arqamAR.mjs +2 -0
- package/dist/arqamEN.d.mts +161 -0
- package/dist/arqamEN.mjs +2 -0
- package/dist/arqamExplain.d.mts +80 -0
- package/dist/arqamExplain.mjs +2 -0
- package/dist/arqamUnits.d.mts +29 -0
- package/dist/arqamUnits.mjs +2 -0
- package/dist/arqamWordsToNumbers.d.mts +63 -0
- package/dist/arqamWordsToNumbers.mjs +2 -0
- package/package.json +109 -20
- package/numberToWordsAr.js +0 -122
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
// TypeScript declarations of the English engine arqamEN: English numbers and amounts in words.
|
|
2
|
+
// import arqamEN from "arqam/en";
|
|
3
|
+
// arqamEN.toWords("1250.50", "QAR") // One Thousand Two Hundred Fifty Qatari Riyals and Fifty Dirhams
|
|
4
|
+
// @author : Mohsen Alyafei
|
|
5
|
+
export type ArqamENNumber = string | number | bigint;
|
|
6
|
+
export type ArqamENSwitch = "on" | "off" | "";
|
|
7
|
+
export interface ArqamENOptions {
|
|
8
|
+
/** "" numbers (default), "currency" or "c" an amount, "ordinals" or "o" ordinals */
|
|
9
|
+
mode?: "" | "currency" | "c" | "ordinals" | "o";
|
|
10
|
+
/** The ISO code of the currency: "QAR", "USD" … (the name Intl gives it) */
|
|
11
|
+
currency?: string;
|
|
12
|
+
/** "end" (default) or "start": the currency after or before the number */
|
|
13
|
+
currencyPos?: "" | "start" | "end";
|
|
14
|
+
/** "on" drops the country adjective: "Dollar" not "US Dollar" */
|
|
15
|
+
noCountry?: ArqamENSwitch;
|
|
16
|
+
/** The country adjective, major and minor names of a currency given in the call */
|
|
17
|
+
demonym?: string; major?: string; majorPl?: string; minor?: string; minorPl?: string;
|
|
18
|
+
/** "uk" writes "and" before the tens and units (One Hundred and One); "" US (default) */
|
|
19
|
+
style?: "" | "us" | "uk";
|
|
20
|
+
/** "on" puts a comma between the scale groups */
|
|
21
|
+
comma?: ArqamENSwitch;
|
|
22
|
+
/** The figure in brackets: "start", "end", or "" none */
|
|
23
|
+
brackets?: "" | "start" | "end";
|
|
24
|
+
/** The label in the brackets: "" the ISO code, "c" adjective and major name, "i" ISO code, "l" Latin symbol,
|
|
25
|
+
* "n" native symbol, or any other text as given */
|
|
26
|
+
symbol?: string;
|
|
27
|
+
/** "U" upper case, "L" lower case, "S" sentence case, "" title case (default) */
|
|
28
|
+
textFormat?: "" | "U" | "L" | "S";
|
|
29
|
+
/** Decimal places kept; "" the currency's places (2 if unknown) or 10 for numbers */
|
|
30
|
+
decRound?: number | string;
|
|
31
|
+
/** The form of the fraction: "" point digits, "w" point words, "n" point figure, "." and 0.12, "/" and 12/100,
|
|
32
|
+
* "th" and twelve hundredths, "tn" and 12 hundredths, "p" parts of one hundred, "pn", "nn" */
|
|
33
|
+
decFormat?: string;
|
|
34
|
+
/** decFormat for amounts only */
|
|
35
|
+
decFormatC?: string;
|
|
36
|
+
/** decFormat for numbers only */
|
|
37
|
+
decFormatN?: string;
|
|
38
|
+
/** The word before the fraction */
|
|
39
|
+
decWord?: string;
|
|
40
|
+
/** "on" writes the groups as figures: "12 Million 123 Thousand 1" */
|
|
41
|
+
compact?: ArqamENSwitch;
|
|
42
|
+
/** The word for a negative number (default "Negative") */
|
|
43
|
+
negativeWord?: string;
|
|
44
|
+
/** The separators of the figure in brackets */
|
|
45
|
+
sepDecimal?: string; sepThousands?: string;
|
|
46
|
+
/** "on" rounds extra decimal digits (half up); "" or "off" cuts them */
|
|
47
|
+
rounding?: ArqamENSwitch;
|
|
48
|
+
/** Returned when the input is not a number */
|
|
49
|
+
isNaN?: string;
|
|
50
|
+
/** "on" writes the fraction as given (no padding, trailing zeros dropped) */
|
|
51
|
+
openDecimals?: ArqamENSwitch;
|
|
52
|
+
/** "end" writes "Only" after the words, "start" before them */
|
|
53
|
+
only?: "" | "start" | "end";
|
|
54
|
+
/** "on" puts colour markers in the words (|p…| |c…| |f| and "|" between groups) */
|
|
55
|
+
split?: ArqamENSwitch;
|
|
56
|
+
/** "indian" counts in lakh and crore (One Lakh Twenty-Three Thousand); "" or "short": thousand, million … */
|
|
57
|
+
scale?: "" | "short" | "indian";
|
|
58
|
+
}
|
|
59
|
+
/** The attributes of a currency given to registerCurrency() */
|
|
60
|
+
export interface ArqamENCurrencyAttributes {
|
|
61
|
+
demonym?: string; major?: string; majorPl?: string; minor?: string; minorPl?: string;
|
|
62
|
+
symbolLatin?: string; symbolNative?: string;
|
|
63
|
+
/** The places of the minor unit (default 2) */
|
|
64
|
+
decimals?: number | string;
|
|
65
|
+
/** Decimals written as given (crypto) */
|
|
66
|
+
openDecimals?: boolean | string;
|
|
67
|
+
}
|
|
68
|
+
/** A row of the currency table: [demonym, major, majorPl, symbolLatin, symbolNative, minor, minorPl, decimals, openDecimals] */
|
|
69
|
+
export type ArqamENCurrencyRow = (string | number | null | undefined)[];
|
|
70
|
+
/** Options of arqamEN.NumberFormat: Intl's names, variant and scale, and every toWords option but style (Intl's here).
|
|
71
|
+
* When an Intl name and an Arqam name are both given, Arqam's wins (mode, symbol). Unknown names are a TypeError;
|
|
72
|
+
* Intl's options for figures (useGrouping, notation, minimumFractionDigits …) a RangeError. */
|
|
73
|
+
export interface ArqamENNumberFormatOptions extends Omit<ArqamENOptions, "style" | "textFormat"> {
|
|
74
|
+
/** "decimal" (default) · "currency" · "percent" (the number times 100, as Intl) · "ordinal" (Arqam's own) */
|
|
75
|
+
style?: "decimal" | "currency" | "percent" | "ordinal";
|
|
76
|
+
/** style "currency": an ISO code; required unless the currency's names are given (major …) */
|
|
77
|
+
currency?: string;
|
|
78
|
+
/** style "currency": the label of the figure in brackets: code (default) · symbol / narrowSymbol (QR, $) · name · native (ر.ق.) */
|
|
79
|
+
currencyDisplay?: "code" | "symbol" | "narrowSymbol" | "name" | "native";
|
|
80
|
+
/** The places of the number (0–100). Default, as Intl: 3 for a decimal, 0 for a percentage; a currency rounds to its minor unit */
|
|
81
|
+
maximumFractionDigits?: number;
|
|
82
|
+
/** "halfExpand" (round half away from zero, the default, as Intl) or "trunc" (cut) */
|
|
83
|
+
roundingMode?: "trunc" | "halfExpand";
|
|
84
|
+
/** "auto" / "negative": «Negative» before a negative number (default) · "always": «Plus» before a number that is not
|
|
85
|
+
* negative · "exceptZero": «Plus» before a number above zero · "never": no sign, in the words or the figure */
|
|
86
|
+
signDisplay?: "auto" | "always" | "exceptZero" | "negative" | "never";
|
|
87
|
+
/** "us": no «and» (One Hundred Twenty-One) · "uk": «and»; default: the locale's (en and the American locales: us) */
|
|
88
|
+
variant?: "us" | "uk";
|
|
89
|
+
/** "indian": lakh and crore · "short": thousand, million; default: the locale's (en-IN, en-PK, en-BD, en-NP: indian) */
|
|
90
|
+
scale?: "indian" | "short";
|
|
91
|
+
/** The case of the words: by name, or the codes of toWords */
|
|
92
|
+
textFormat?: "" | "title" | "upper" | "lower" | "sentence" | "U" | "L" | "S";
|
|
93
|
+
/** "latn" only */
|
|
94
|
+
numberingSystem?: "latn";
|
|
95
|
+
localeMatcher?: "lookup" | "best fit";
|
|
96
|
+
}
|
|
97
|
+
/** A part of the words: Intl's type names where Intl has one; Arqam's own: minorCurrency, denominator, ordinal, prefix,
|
|
98
|
+
* suffix («Only») and figure (the figure in brackets, with its own parts as Intl cuts figures) */
|
|
99
|
+
export interface ArqamENPart {
|
|
100
|
+
type: "literal" | "integer" | "decimal" | "fraction" | "currency" | "minorCurrency" | "denominator" | "minusSign" |
|
|
101
|
+
"percentSign" | "ordinal" | "prefix" | "suffix" | "figure";
|
|
102
|
+
value: string;
|
|
103
|
+
parts?: {type: "literal" | "currency" | "minusSign" | "integer" | "group" | "decimal" | "fraction" | "percentSign"; value: string}[];
|
|
104
|
+
}
|
|
105
|
+
export interface ArqamENRangePart extends ArqamENPart { source: "startRange" | "endRange" | "shared" }
|
|
106
|
+
export interface ArqamENResolvedOptions extends ArqamENNumberFormatOptions {
|
|
107
|
+
locale: string; numberingSystem: "latn"; style: "decimal" | "currency" | "percent" | "ordinal";
|
|
108
|
+
roundingMode: "trunc" | "halfExpand"; signDisplay: "auto" | "always" | "exceptZero" | "negative" | "never"; variant: "us" | "uk"; scale: "indian" | "short";
|
|
109
|
+
}
|
|
110
|
+
/** A formatter: its methods are bound (list.map(nf.format) works); the object is frozen */
|
|
111
|
+
export interface ArqamENNumberFormat {
|
|
112
|
+
format(x: ArqamENNumber): string;
|
|
113
|
+
format(x: ArqamENNumber[]): string[];
|
|
114
|
+
formatToParts(x: ArqamENNumber): ArqamENPart[];
|
|
115
|
+
formatToParts(x: ArqamENNumber[]): ArqamENPart[][];
|
|
116
|
+
/** «From A to B»; «Only» and the figure once; equal values give one value; a start after the end is a RangeError */
|
|
117
|
+
formatRange(start: ArqamENNumber, end: ArqamENNumber): string;
|
|
118
|
+
formatRangeToParts(start: ArqamENNumber, end: ArqamENNumber): ArqamENRangePart[];
|
|
119
|
+
resolvedOptions(): ArqamENResolvedOptions;
|
|
120
|
+
}
|
|
121
|
+
/** arqamEN.NumberFormat: with or without new; the locale is optional ("en"), and an object first is the options */
|
|
122
|
+
export interface ArqamENNumberFormatConstructor {
|
|
123
|
+
new (locales?: string | string[], options?: ArqamENNumberFormatOptions): ArqamENNumberFormat;
|
|
124
|
+
new (options?: ArqamENNumberFormatOptions): ArqamENNumberFormat;
|
|
125
|
+
(locales?: string | string[], options?: ArqamENNumberFormatOptions): ArqamENNumberFormat;
|
|
126
|
+
(options?: ArqamENNumberFormatOptions): ArqamENNumberFormat;
|
|
127
|
+
/** The English locales of the list, in their canonical form */
|
|
128
|
+
supportedLocalesOf(locales?: string | string[]): string[];
|
|
129
|
+
readonly styles: string[];
|
|
130
|
+
}
|
|
131
|
+
export interface ArqamEN {
|
|
132
|
+
/** The words of a number with the shape, option names and methods of Intl.NumberFormat */
|
|
133
|
+
readonly NumberFormat: ArqamENNumberFormatConstructor;
|
|
134
|
+
readonly version: string;
|
|
135
|
+
/** The words of a number or an amount; a string as the second argument is a currency code */
|
|
136
|
+
toWords(n: ArqamENNumber, options?: ArqamENOptions | string): string;
|
|
137
|
+
toWords(n: ArqamENNumber[], options?: ArqamENOptions | string): string[];
|
|
138
|
+
/** Sets options for the calls that follow; "default" puts back the defaults */
|
|
139
|
+
config(options: ArqamENOptions | "default"): void;
|
|
140
|
+
/** Adds a currency, or changes one, for the rest of the session; returns its row. A new code needs major. */
|
|
141
|
+
registerCurrency(code: string, attributes: ArqamENCurrencyAttributes): ArqamENCurrencyRow;
|
|
142
|
+
/** Puts back the defaults */
|
|
143
|
+
reset(): void;
|
|
144
|
+
/** A copy of the options in force */
|
|
145
|
+
options(): Required<ArqamENOptions>;
|
|
146
|
+
/** The defaults */
|
|
147
|
+
readonly defaults: Required<ArqamENOptions>;
|
|
148
|
+
/** The currency table, by ISO code */
|
|
149
|
+
readonly currencies: Record<string, ArqamENCurrencyRow>;
|
|
150
|
+
}
|
|
151
|
+
declare const arqamEN: ArqamEN;
|
|
152
|
+
export default arqamEN;
|
|
153
|
+
export declare const version: string;
|
|
154
|
+
export declare const currencies: Record<string, ArqamENCurrencyRow>;
|
|
155
|
+
export declare function toWords(n: ArqamENNumber, options?: ArqamENOptions | string): string;
|
|
156
|
+
export declare function toWords(n: ArqamENNumber[], options?: ArqamENOptions | string): string[];
|
|
157
|
+
export declare function config(options: ArqamENOptions | "default"): void;
|
|
158
|
+
export declare function registerCurrency(code: string, attributes: ArqamENCurrencyAttributes): ArqamENCurrencyRow;
|
|
159
|
+
export declare function reset(): void;
|
|
160
|
+
export declare function options(): Required<ArqamENOptions>;
|
|
161
|
+
export declare const NumberFormat: ArqamENNumberFormatConstructor;
|
package/dist/arqamEN.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! arqamEN v1.27 — number-to-words engine by Mohsen Alyafei. ES module, self-contained: no dependencies, no network. MIT licence. Built from arqamEN.js. Readable source: https://github.com/MohsenAlyafei/arqam. */
|
|
2
|
+
const e=function(){let e=new class{toWords(e,n){return function arqamEnglishToWords(e=0,n){const r={options:{...d},settings:{...y}};try{return function arqamEnglishToWordsOnce(e=0,n){n&&arqamE_Config("object"==typeof n?n:{mode:"currency",currency:n});const r=y.split,a=r?"|":"",P=e=>r&&""!==e.trim()?"|p"+e+"|":e,C=e=>!r&&"S"!==y.textFormat||""===e?e:"|c"+e+"|",c=r?"|f|":"";return Array.isArray(e)?e.filter(()=>!0).map(e=>doOne(e)):doOne(e);function doOne(e){if("number"==typeof e&&Number.isFinite(e)&&(e=e.toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:20})),(e+="").endsWith("%")&&/^-?(\d+\.?\d*|\.\d+)%$/.test(e)&&!y.isCurrency&&!y.isOrdinal){const n=doOne(e.slice(0,-1));return n===y.nanText?n:n+" "+formatd("Percent")}if(!/^-?(\d+\.?\d*|\.\d+)$/.test(e))return y.nanText;let n="";"-"===e[0]&&(n=y.negativeWord?P(y.negativeWord)+" ":"",e=e.slice(1));let[l,u]=function numberSplit(e,n,r=!1){const a=(e+"").split(f);let t=a[0],i=a[1];return""!==n&&void 0!==n&&n>=0&&(2===a.length?y.rounding?[t,i=""]=function toFixedTrue(e,n){const[r="",a=""]=String(e).split("."),t=r.startsWith("-"),i=BigInt((t?r.slice(1):r)+a.slice(0,n).padEnd(n,"0")||"0")+(a[n]>="5"?1n:0n),o=String(i).padStart(n+1,"0"),s=o.length-n;return(t?"-":"")+o.slice(0,s)+(n?"."+o.slice(s):"")}((t||"0")+"."+i,n).split("."):(i=i.slice(0,n),r||(i=i.padEnd(n,"0"))):i="",r&&(i=i.replace(/0+$/g,""))),[+t?t:"",+i?i:""]}(e,y.places,!y.isCurrency||y.openDecimals);if(l=l.replace(/^0+/,""),y.isOrdinal)return function NumberToOrdinalString(e=0){if(!+e)return"Zeroth";const n=arqamE_groups(e+""),r=n.length-1,a=["",...t.slice(1)];let s="";return n.forEach(([e,c],l)=>{if(!+e)return;const u=n.slice(l+1).every(([e])=>!+e),m=+e[0],d=+e.slice(1),p=u&&!c?o:a;s+=(s?(s&&l>0&&(m&&d||l!==r)?y.comma:l===r?y.and:"")+" ":"")+(m?t[m]+" "+i[10]:"")+(c||d?"":"th")+(m&&d?y.and+" ":"")+(d<20?d>12?t[d]+"th":p[d]:e[2]>0?i[+e[1]]+"-"+p[+e[2]]:c?i[+e[1]]:i[+e[1]].slice(0,-1)+"ieth"),s+=(s&&c?" ":"")+c+(c&&u?"th":"")}),s}(l);const m=l>1?y.majorPl:y.major,p=u>1?y.minorPl:y.minor;y.brackets&&y.isCurrency&&!y.symbol&&(y.symbol=y.majorPl);let[g,h]=numToWords(l);const S=(h?y.comma:"")+s[0]+" ";let b="",v=C(m);y.currencyFirst&&(v="",b=C(m)),b&&(b+=" "),v&&(v=" "+v);const D=P(S)+c+"0"+y.sepDecimal+u,T=u.replace(/0+$/,""),N=u.replace(/^0+/,""),F=y.isCurrency?N:N.replace(/0+$/,""),E=formatd(numToWords(u)[0]),$="1"+"0".repeat((y.isCurrency?u:T).length),R=F>1?s[4]:s[3],L=_cr3(E," ",D),A=_cr3(N," ",D);if(u)switch(y.decFormat.toLowerCase()){case"/":y.isCurrency||(u=T),g+=P(S)+c+u.replace(/^0+/,"")+"/1"+"0".repeat(u.length),y.isCurrency&&(g=_cr(g));break;case".":g=y.isCurrency?_cr(g+D):g+D;break;case"n":g=y.isCurrency?A:g+P(y.decWord)+c+u;break;case"th":g=th(!1);break;case"tn":g=th(!0);break;case"w":if(y.isCurrency)g=L;else{const e=u.slice(0,u.length-N.length);g+=_point(e)+(e?" ":"")+formatd(numToWords(N)[0])}break;case"p":g=parts(!1,numToWords(F)[0],numToWords($)[0],E);break;case"pn":g=parts(!0,numThousandSep(F),numToWords($)[0],F);break;case"nn":g=parts(!0,numThousandSep(F),numThousandSep($),F);break;default:g=y.isCurrency?L:g+_point(T)}else y.isCurrency&&(g=_cr(g));if(g=n+g,"end"===d.only?g+=" Only":"start"===d.only&&(g="Only "+g),y.brackets){!y.isCurrency||u||y.openDecimals||(u="0".repeat(y.places));const e=P("(")+(y.symbol?C(y.symbol)+" ":"")+(n?P("-"):"")+(l?numThousandSep(l):"0")+(u?P(y.sepDecimal)+c+u:"")+P(")");g=-1===y.brackets?e+" "+g:g+" "+e}if("U"===y.textFormat)return g.replace(/\|f\||\|[pc]|[^|]+/g,e=>/^\|[pcf]/.test(e)?e:e.toUpperCase());if("L"===y.textFormat&&!y.isCurrency)return g.toLowerCase();if("S"===y.textFormat){let e=!1;const n=g.replace(/\|f\||\|[pc]|\||[^|]+/g,n=>("|c"===n?e=!0:"|"===n&&(e=!1),"|"===n[0]||e?n:n.toLowerCase())).replace(/^((?:\|[pcf]\|?)*)(.)/,(e,n,r)=>n+r.toUpperCase());return r?n:n.replace(/\|c([^|]*)\|/g,"$1")}return g;function parts(e,n,r,a){if(y.isCurrency&&p)return e?A:L;const t=P(S)+c+n+P(R)+r;return y.isCurrency?_cr3(a,R,t):g+t}function th(e){if(y.isCurrency&&p)return e?A:L;if(!y.isCurrency)return g+P(S)+c+doTH(T,e);const n=doTH(u,e);return _cr3(n,s[2],P(S)+c+n)}function _cr(e){return b+formatd(e)+v}function _cr3(e,n,r){return _cr(g)+(p?P(S)+c+e+P(n)+C(p):r)}function _point(e){return P(y.decWord)+c+[...e].map(e=>t[e]).join(" ")}function formatd(e){return"L"===y.textFormat||"S"===y.textFormat?e.toLowerCase():e}function doTH(e,n){let r=formatd(numToWords("1"+"0".repeat(e.length))[0].replace(/\|/g,"").replace(RegExp(t[1]),"").trim())+"th";return e>1&&(r+="s"),n?e.replace(/^0+/,"")+" "+r:formatd(numToWords(e)[0]+" "+r)}function numThousandSep(e){return e.replace(/\B(?=(\d{3})+(?!\d))/g,P(y.sepThousand))}function numToWords(e){if(!e)return[t[0]+a,""];const n=arqamE_groups(e+""),r=n.length-1;let o="",s="";return n.forEach(([e,n],c)=>{if(+e){if(y.compact)s=o&&c>0&&c!==r,o+=P(s?y.comma:o&&c===r&&!+e[0]?y.and:""),o+=(o?" ":"")+String(+e);else{const n=+e[0],a=+e.slice(1),l=+e[2];s=o&&c>0&&(n&&a||c!==r),o+=P(s?y.comma:o&&c===r&&!n?y.and:"")+(o?" ":"")+(n?t[n]+" "+i[10]:"")+(n&&a?y.and+" ":"")+(a&&a<20?t[a]:i[+e[1]]+(l?"-"+t[l]:""))}o+=(o&&n?" ":"")+n+a}}),[o,s]}}}(e,n)}finally{d=r.options,y=r.settings}}(e,n)}config(e){arqamE_Config(e)}registerCurrency(e,a){return function arqamE_RegisterCurrency(e,a={}){n++;const t={demonym:0,major:1,majorPl:2,symbolLatin:3,symbolNative:4,minor:5,minorPl:6,decimals:7,openDecimals:8},fail=e=>{throw new TypeError("arqamEN.registerCurrency: "+e)};"string"==typeof e&&/^[A-Za-z]{3,5}$/.test(e)||fail('the code must be 3 to 5 letters, e.g. "ZZZ"'),a&&"object"==typeof a||fail("the second argument must be an object of attributes");for(const n in a)n in t||fail('unknown attribute "'+n+'"; use: '+Object.keys(t).join(", "));e=e.toUpperCase();const i=r[e];i||a.major||fail("a new currency needs major"),!("decimals"in a)||Number.isInteger(+a.decimals)&&+a.decimals>=0&&+a.decimals<=18||fail("decimals must be a whole number from 0 to 18");const o=i?i.slice():["",void 0,void 0,void 0,void 0,"","",2];i||!a.minor||"minorPl"in a||(o[6]=void 0);for(const n in a){let e=a[n];e="decimals"===n?+e:"openDecimals"===n?e?1:void 0:null==e?"":String(e).trim(),o[t[n]]=e}return r[e]=o,d.currency===e&&arqamE_Config({currency:e}),o.slice()}(e,a)}reset(){arqamE_Config("default")}options(){return{...d}}get defaults(){return{...m}}get currencies(){return Object.fromEntries(Object.entries(r).map(([e,n])=>[e,Array.isArray(n)?[...n]:n]))}[Symbol.for("arqam.standing")](){return[n+JSON.stringify(d),d.errorLanguage]}},n=0,r={AED:["UAE","Dirham",,"د.إ.","د.إ.",5,0],AFN:["Afghan","Afghani",0,"Af","؋","Pul",0],ALL:["Albanian","Lek","Lekë",,"L","Qindarka",0],AMD:["Armenian","Dram",0,"֏","դր","Luma",0],ARTSAKH:["Artsakh","Dram",0,,"դր.","Luma",0],ABKHAZIA:["Abkhazian","Apsar","Apsark",,"",0,,0],ANG:["Netherlands Antillean","Guilder",,,"ƒ",0,,,,2025],AOA:["Angolan","Kwanza",,,"Kz",3,,],ARS:["Argentine",4,,"AR$","$",1,,],AUD:["Australian",0,,"AU$","$",0,,],AWG:["Aruban","Florin",0,,"ƒ",0,,],AZN:["Azerbaijani","Manat",0,"ман","₼","Qapik",0],BAM:["Bosnia-Herzegovina","Convertible Mark","Convertible Marks",,"КМ","Fening",0],BBD:["Barbadian",0,,"BBD$","$",0,,],BDT:["Bangladeshi","Taka",0,,"৳","Poisha",0],BGN:["Bulgarian","Lev","Leva",,"лв.","Stotinka","Stotinki"],BHD:["Bahraini",3,,"BD","د.ب.",5,0,3],BIF:["Burundian",1,,,"FBu",2,,],BMD:["Bermudian",0,,,"$",0,,],BND:["Brunei",0,,"B$","$",0,,],BOB:["Bolivian","Boliviano",,,"Bs.",1,,],BRL:["Brazilian","Real","Reais",,"R$",1,,],BSD:["Bahamian",0,,,"$",0,,],BTN:["Bhutanese","Ngultrum",,,"Nu.","Chetrum",,],BWP:["Botswana","Pula",0,,"P","Thebe",0],BYN:["Belarusian","Ruble",,"Br","руб.","Kapiejka",0],BZD:["Belize",0,,"BZ$","$",0,,],CAD:["Canadian",0,,"CA$","$",0,,],CDF:["Congolese",1,,"FC","₣",2,,],CHF:["Swiss",1,,"Fr.","₣",2,,],CKD:["Cook Islands",0,,,"$",0,,],CLP:["Chilean",4,,"CL$","$",1,,],CNY:["Chinese","Yuan",0,"CN¥","¥元","Fen",0],COP:["Colombian",4,,"CO$","$",1,,],CRC:["Costa Rican","Colón","Colones",,"₡",3,,],CUC:["Cuban Convertible",4,,"CUC$","$",1,,,,2021],CUP:["Cuban",4,,"$MN","₱",1,,],CVE:["Cabo Verdean","Escudo",,"CV$","$",1,,],CZK:["Czech","Koruna",,"Kč","Kč","Haléř",0],DJF:["Djiboutian",1,,"Fdj","ف.ج.",2,,],DKK:["Danish","Krone","Kroner",,"kr.","Øre",0],DOP:["Dominican",4,,"RD$","$",1,,],DZD:["Algerian",3,,"DA","د.ج.","Santeem",,],EGP:["Egyptian",2,,"E£","ج.م.",6,0],EHP:["Sahrawi","Peseta",,,"Ptas.",3,,],ERN:["Eritrean","Nakfa",0,"Nkf","ناكفا",0,,],ETB:["Ethiopian","Birr",0,"Br","ብር","Santim",0],EUR:["","Euro",,,"€",0,,],FJD:["Fijian",0,,"FJ$","$",0,,],FKP:["Falkland Islands",2,,"FK£","£",4,"Pence"],FOK:["Faroese","Króna",,,"kr","Oyra",0],GBP:["","Pound Sterling","Pounds Sterling",,"£",4,"Pence"],GEL:["Georgian","Lari",0,,"₾","Tetri",0],GGP:["Guernsey",2,,,"£",4,"Pence"],GHS:["Ghanaian","Cedi",,"GH₵","₵","Pesewa",,],GIP:["Gibraltar",2,,,"£",4,"Pence"],GMD:["Gambian","Dalasi",,,"D","Butut",,],GNF:["Guinean",1,,,"FG",2,,],GTQ:["Guatemalan","Quetzal","Quetzales","Q","$",1,,],GYD:["Guyanese",0,,"G$","$",0,,],HKD:["Hong Kong",0,,"HK$","$",0,,],HNL:["Honduran","Lempira",,,"L",1,,],HRK:["Croatian","Kuna",0,,"kn","Lipa",0,,,2023],HTG:["Haitian","Gourde",,,"G",2,,],HUF:["Hungarian","Forint",0,,"Ft","Fillér",0],IDR:["Indonesian","Rupiah",0,,"Rp","Sen",0],ILS:["Israeli","Shekel",,,"₪","Agora",,],IMP:["Manx",2,,,"£",4,"Pence"],INR:["Indian",5,,"Rs.","₹","Paisa","Paise"],IQD:["Iraqi",3,,"د.ع.","د.ع.",5,0,3],IRR:["Iranian","Rial",,,"﷼","Dinar",,],ISK:["Icelandic","Króna","Krónur",,"kr","Aurar",0],JEP:["Jersey",2,,,"£",4,"Pence"],JMD:["Jamaican",0,,"J$","$",0,,],JOD:["Jordanian",3,,"JD","د.أ.",5,0,3],JPY:["Japanese","Yen",0,,"¥","Sen",0],KES:["Kenyan",6,,,"KSh",0,,],KGS:["Kyrgyz","Som",,,"с","Tyiyn",0],KHR:["Cambodian","Riel",,,"៛","Sen",0],KID:["Kiribati",0,,,"$",0,,],KMF:["Comorian",1,,,"CF",2,,],KPW:["North Korean","Won",0,,"₩","Chon",0],KRW:["South Korean","Won",0,,"₩","Jeon",0],KWD:["Kuwaiti",3,,"KD","د.ك.",5,0,3],KYD:["Cayman Islands",0,,"CI$","$",0,,],KZT:["Kazakhstani","Tenge",0,,"₸","Tıyn",0],LAK:["Lao","Kip",0,"₭N","₭","Att",0],LBP:["Lebanese",2,,"LL.","ل.ل.",6,0],LKR:["Sri Lankan",5,,"Rs.","රු",0,,],LRD:["Liberian",0,,"L$","$",0,,],LSL:["Lesotho","Loti","Maloti",,"L","Sente","Lisente"],LYD:["Libyan",3,,"LD","ل.د.","Dirham",,3],MAD:["Moroccan","Dirham",,"DH","د.م.",2,,],MDL:["Moldovan","Leu","Lei",,"L","Ban","Bani"],MGA:["Malagasy","Ariary",0,,"Ar","Iraimbilanja",0,0],MKD:["Macedonian","Denar","Denari","den","ден","Deni",0],MMK:["Myanmar","Kyat",0,,"Ks","Pya",0],MNT:["Mongolian","Tugrik",0,,"₮","Möngö",0],MOP:["Macanese","Pataca",,,"MOP$","Avo",,],MRU:["Mauritanian","Ouguiya",0,"UM","أ.م.","Centime"],MUR:["Mauritian",5,,"Rs.","रु ",0,,],MVR:["Maldivian","Rufiyaa",0,"MRf",".ރ","Laari",0],MWK:["Malawian","Kwacha",0,,"MK","Tambala",0],MXN:["Mexican",4,,"MX$","$",1,,],MYR:["Malaysian","Ringgit",0,,"RM","Sen",0],MZN:["Mozambican","Metical","Meticais","MTn","MT",1,,],NAD:["Namibian",0,,"N$","$",0,,],NGN:["Nigerian","Naira",0,,"₦","Kobo",0],NIO:["Nicaraguan","Córdoba",,,"C$",1,,],NOK:["Norwegian","Krone","Kroner",,"kr","Øre",0],NPR:["Nepalese",5,,"Rs.","रू","Paisa","Paise"],NZD:["New Zealand",0,,"NZ$","$",0,,],OMR:["Omani","Rial",,"OR","ر.ع.","Baisa",0,3],PAB:["Panamanian","Balboa",,,"B/.","Centésimo",,],PEN:["Peruvian","Sol","Soles",,"S/.",3,,],PGK:["Papua New Guinean","Kina",0,,"K","Toea",0],PHP:["Philippine",4,,,"₱","Sentimo",0],PKR:["Pakistani",5,,,"Rs.","Paisa","Paise"],PLN:["Polish","Zloty",,"zł","zł","Grosz",0],PND:["Pitcairn Islands",0,,,"$",0,,],PRB:["Transnistrian","Ruble",,,"р.","Kopek",,],PYG:["Paraguayan","Guaraní","Guaraníes",,"₲",3,,],QAR:["Qatari","Riyal",,"QR","ر.ق.","Dirham",,],RON:["Romanian","Leu","Lei",,"L","Ban","Bani"],RSD:["Serbian",3,,"din","дин","Para",0],RUB:["Russian","Ruble",,,"₽","Kopek",,],RWF:["Rwandan",1,,"FRw","R₣",2,,],SAR:["Saudi","Riyal",,"SR","ر.س.","Halalah",,],SBD:["Solomon Islands",0,,"SI$","$",0,,],SCR:["Seychellois",5,,,"Rs.",0,,],SDG:["Sudanese",2,,"£SD","ج.س.",6,0],SEK:["Swedish","Krona","Kronor",,"kr","Öre",0],SGD:["Singapore",0,,"S$","$",0,,],SHP:["Saint Helena",2,,,"£",4,"Pence"],SLL:["Sierra Leonean","Leone",,,"Le",0,,,,2024],SLS:["Somaliland",6,,,"Sl",0,,],SOS:["Somali",6,,"Sh.So.","Ssh","Senti",0],SRD:["Surinamese",0,,"Sr$","$",0,,],SSP:["South Sudanese",2,,,"SS£",6,0],STN:["São Tomé and Príncipe","Dobra",,,"Db",3,,],SVC:["Salvadoran","Colón","Colones",,"₡",1,,],SYP:["Syrian",2,,"LS","ل.س.",6,0],SZL:["Swazi","Lilangeni","Emalangeni",,"L",0,,],THB:["Thai","Baht",0,,"฿","Satang",0],TJS:["Tajikistani","Somoni",0,,"SM","Diram",0],TMT:["Turkmenistan","Manat",0,"m.","T","Tenge",0],TND:["Tunisian",3,,"DT","د.ت.","Millime",0,3],TOP:["Tongan","Pa'anga",0,"T$","PT","Seniti",0],TRY:["Turkish","Lira",0,"TL","₺","Kuruş",0],TTD:["Trinidad and Tobago",0,,"TT$","$",0,,],TVD:["Tuvaluan",0,,,"$",0,,],TWD:["New Taiwan",0,,"NT$","圓",0,,],TZS:["Tanzanian",6,,,"TSh","Senti",0],UAH:["Ukrainian","Hryvnia",,"₴","грн","Kopiyka","Kopiyky"],UGX:["Ugandan",6,,"USh","Sh",0,,],USD:["US",0,,,"$",0,,],UYU:["Uruguayan",4,,"$U","$","Centésimo",,],UZS:["Uzbekistani","Som",0,,"сум","Tiyin",0],VED:["Venezuelan","Bolívar Digital","Bolívares Digitales",,"Bs.",3,,],VES:["Venezuelan","Bolívar","Bolívares",,"Bs.F",3,,],VND:["Vietnamese","Dong",0,,"₫","Hào",0],VUV:["Vanuatu","Vatu",0,,"VT","","",0],WST:["Samoan","Tala",0,"T","ST","Sene",0],XAF:["Central African CFA",1,,,"Fr.",2,,],XCD:["East Caribbean",0,,,"$",0,,],XOF:["West African CFA",1,,,"₣",2,,],XPF:["CFP",1,,,"₣",2,,],YER:["Yemeni","Rial",,"YR","ر.ي.",5,0],ZAR:["South African","Rand",0,,"R",0,,],ZMW:["Zambian","Kwacha",0,,"ZK","Ngwee",0],ZWB:["RTGS",0,,,"","","",0],ZWL:["Zimbabwean",0,,"Z$","$",0,,,,2024],ZWG:["Zimbabwe","Gold",0,"ZiG","ZiG",0,,],SLE:["Sierra Leonean","Leone",,,"Le",0,,],XCG:["Caribbean","Guilder",,,"Cg",0,,],BTC:["","Bitcoin",,,"₿","","",8,1],BCH:["","Bitcoin Cash",0,,"BCH","","",8,1],LTC:["","Litecoin",,,"Ł","","",8,1],ETH:["","Ether",0,,"Ξ","","",18,1],BNB:["","Binance Coin",,,"BNB","","",18,1],USDT:["","Tether",0,,"₮","","",6,1],SOL:["","Sol",0,,"SOL","","",9,1],DASH:["","Dash",0,,"DASH","","",8,1],ADA:["","Cardano",0,,"₳","","",6,1],DOT:["","Polkadot",0,,"DOT","","",10,1],USDC:["","USD Coin",0,,"USDC","","",6,1],XRP:["","Ripple",0,,"XRP","","",6,1],DOGE:["","Dogecoin",,,"Ð","","",8,1]},a=[],t=["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"],i=["","","Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety","Hundred"],o=["","First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth","Eleventh","Twelfth"],s=[" and","point"," of a "," part of "," parts of "],c=["Dollar","Franc","Pound","Dinar","Peso","Rupee","Shilling"],l=["Cent","Centavo","Centime","Centimo","Penny","Fils","Qirsh"],u={mode:["currency","c","ordinals","o","numbers","n"],currencyPos:["start","end"],noCountry:["on","off"],style:["us","uk"],comma:["on","off"],brackets:["start","end"],textFormat:["U","L","S"],decFormat:["w","n",".","/","th","tn","p","pn","nn"],decFormatC:["w","n",".","/","th","tn","p","pn","nn"],decFormatN:["w","n",".","/","th","tn","p","pn","nn"],compact:["on","off"],rounding:["on","off"],openDecimals:["on","off"],only:["start","end"],split:["on","off"],scale:["indian","short"]},m={mode:"",currency:"",currencyPos:"end",noCountry:"",demonym:"",major:"",majorPl:"",minor:"",minorPl:"",style:"",comma:"",brackets:"",symbol:"",textFormat:"",decRound:"",decFormat:"",decFormatC:"",decFormatN:"",decWord:"",compact:"",negativeWord:"Negative",sepDecimal:"",sepThousands:"",rounding:"",isNaN:"",openDecimals:"",only:"",split:"",scale:""},d={...m},y={},p=.1.toLocaleString().slice(1,2),g=1e3.toLocaleString().slice(1,2);const f=".";arqamE_getScales(1e3),e.config({});for(const S of["BIF","CLP","DJF","GNF","ISK","JPY","KMF","KRW","PYG","RWF","UGX","VND","XAF","XOF","XPF"])r[S]&&(r[S][7]=0);function arqamE_Config(e){e&&"object"==typeof e&&e!==d&&function arqamE_CheckOptions(e){if("code"in e)throw new TypeError('arqamEN: unknown option "code"; did you mean "currency"?');delete e.trimZeros,delete e.ordinals;for(const r of Object.keys(e)){if(r in m)continue;const e=arqamE_NearestName(r,Object.keys(m));throw new TypeError(`arqamEN: unknown option "${r}"`+(e?`; did you mean "${e}"?`:""))}for(const[r,a]of Object.entries(u)){if(void 0===e[r]||""===e[r])continue;!0!==e[r]&&!1!==e[r]||(e[r]=e[r]?"on":"off");const n=e[r];if("string"!=typeof n||!a.some(e=>e.toLowerCase()===n.trim().toLowerCase()))throw new TypeError(`arqamEN: ${r} must be one of ${["",...a].map(e=>JSON.stringify(e)).join(", ")} (got ${JSON.stringify(n)})`)}const n=e.decRound;if("decRound"in e&&""!==n&&!(Number.isInteger(+n)&&+n>=0))throw new TypeError(`arqamEN: decRound must be a whole number of 0 or more (got ${JSON.stringify(n)})`)}(e={...e}),"default"===e&&(d={...m},arqamE_getScales(1e3),e=d),"currency"in e&&""!==e.currency&&function arqamE_ApplyCurrency(e){let n=r[e.currency];if(!n&&"string"==typeof e.currency){const a=e.currency.trim().toUpperCase();r[a]&&(e.currency=a,n=r[a])}if(!n&&!e.major)throw new TypeError(`arqamEN: unknown currency code ${JSON.stringify(e.currency)}: add it with registerCurrency(), or give major and majorPl in the same call`);if(!n)return d.demonym=d.major=d.majorPl="",void(d.minor=d.minorPl=d.openDecimals="");const name=(e,r)=>r[n[e]]??n[e],plural=(e,r)=>null==n[e]?r+"s":0===n[e]||""===n[e]?r:n[e];e.demonym=n[0],e.major=name(1,c),e.majorPl=plural(2,e.major),e.minor=name(5,l),e.minorPl=plural(6,e.minor),e.decRound=n[7]??2,e.openDecimals=1===n[8]?"on":"",y.symbolLatin=n[3]??n[4],y.symbolNative=n[4]}(e);for(const n in e)n in d&&(d[n]=e[n]);e.currency&&void 0===e.mode&&!d.mode&&(d.mode="currency"),function arqamE_WorkOutSettings(){const e=d,n=y;if(""===e.style&&(e.style="us"),""===e.currencyPos&&(e.currencyPos="end"),""===e.noCountry&&(e.noCountry="off"),""===e.comma&&(e.comma="off"),""===e.decWord&&(e.decWord=s[1]),"c"===e.mode&&(e.mode="currency"),"o"===e.mode&&(e.mode="ordinals"),Object.assign(n,{decWord:" "+e.decWord+" ",textFormat:e.textFormat,noCountry:"on"===e.noCountry,demonym:"on"===e.noCountry?"":e.demonym,major:e.major,majorPl:e.majorPl,minor:e.minor,minorPl:e.minorPl,symbol:e.symbol,comma:"on"===e.comma?",":"",and:"uk"===e.style?s[0]:"",currencyFirst:"start"===e.currencyPos,brackets:"start"===e.brackets?-1:"end"===e.brackets,compact:"on"===e.compact,isCurrency:"currency"===e.mode,isOrdinal:"ordinals"===e.mode,negativeWord:e.negativeWord,sepDecimal:arqamE_Separator(e.sepDecimal,.1,p),sepThousand:arqamE_Separator(e.sepThousands,1e3,g),rounding:"on"===e.rounding,nanText:e.isNaN,openDecimals:"on"===e.openDecimals,split:"on"===e.split,indian:"indian"===e.scale}),n.isCurrency){""!==n.major&&""==n.majorPl&&(n.majorPl=n.major),""!==n.minor&&""==n.minorPl&&(n.minorPl=n.minor);const r=n.demonym?n.demonym+" ":"";n.major=r+n.major,n.majorPl=r+n.majorPl;const a=String(n.symbol).toLowerCase();"c"===a?n.symbol=n.major:"i"===a?n.symbol=e.currency:"l"===a?n.symbol=n.symbolLatin:"n"===a?n.symbol=n.symbolNative:""===a&&(n.symbol=n.noCountry?"":e.currency)}n.places=""===e.decRound?n.isCurrency?2:10:+e.decRound;const r=""===e.decFormatC?e.decFormat:e.decFormatC,a=""===e.decFormatN?e.decFormat:e.decFormatN;n.decFormat=n.isCurrency?r:a}()}function arqamE_NearestName(e,n){const distance=(e,n)=>{const r=[...Array(n.length+1).keys()];for(let a=1;a<=e.length;a++){let t=r[0];r[0]=a;for(let i=1;i<=n.length;i++){const o=r[i],s=e[a-1].toLowerCase()===n[i-1].toLowerCase()?0:1;r[i]=Math.min(r[i]+1,r[i-1]+1,t+s),t=o}}return r[n.length]};let r="",a=3;for(const t of n){const n=distance(e,t);n<a&&(a=n,r=t)}return r}function arqamE_Separator(e,n,r){if(""===e)return r;if(!(e.length>1))return e;try{return new Intl.NumberFormat(e).format(n).slice(1,2)}catch{return r}}function arqamE_groups(e){if(!y.indian||e.length<=3){const n=("0".repeat(2*e.length%3)+e).match(/.{3}/g),r=n.length-1;return n.map((e,n)=>{return[e,(t=r-n,void 0!==a[t]?a[t]:a[t]=getScaleNameEn(t))];var t})}const n=[],r=e.slice(-3),t=e.slice(-5,-3),i=e.slice(-7,-5),o=e.slice(0,-7).replace(/^0+/,"");if(o){const e=arqamE_groups(o);let r=e.length-1;for(;r>0&&!+e[r][0];)r--;e[r]=[e[r][0],e[r][1]?e[r][1]+" Crore":"Crore"],n.push(...e.slice(0,r+1),...e.slice(r+1).map(([e])=>[e,""]))}return i&&n.push([i.padStart(3,"0"),"Lakh"]),t&&n.push([t.padStart(3,"0"),"Thousand"]),n.push([r,""]),n}function arqamE_getScales(e){let n=Math.ceil(+e/3);n<3&&(n=3);for(let r=0;r<n;r++)a[r]=getScaleNameEn(r)}function getScaleNameEn(e=0){const n=arqamE_ScalePartsOf(),r=BigInt(e);if(0n===r)return"";if(1n===r)return"Thousand";const a=r-1n;let t;if(a<10n)t=n.stems[Number(a)]+"illion";else if(a<1000n)t=arqamE_illionStem(Number(a))+"llion";else{const e=[];for(let n=a;n>0n;n/=1000n)e.unshift(Number(n%1000n));t=e.map((r,a)=>(0===r?"n":r<10?n.stems[r]:arqamE_illionStem(r).slice(0,-1))+(a===e.length-1?"illion":"illi")).join("")}return t.charAt(0).toUpperCase()+t.slice(1)}function arqamE_illionStem(e){const n=arqamE_ScalePartsOf(),r=Math.floor(e/100),a=Math.floor(e%100/10),t=e%10;let i=n.units[t],o=n.tens[a][0],s=n.hund[r][0];return!r&&n.tens[a][2]&&(o=o.slice(0,-1)+"i"),a?o=n.tens[a][1][t]+o:r&&(s=n.hund[r][1][t]+s),i+o+s}function arqamE_ScalePartsOf(){return arqamE_ScalePartsOf.v||(arqamE_ScalePartsOf.v={stems:["","m","b","tr","quadr","quint","sext","sept","oct","non"],units:["","un","duo","tre","quattuor","quin","se","septe","octo","nove"],tens:[["",["","","","","","","","","",""],!1],["deci",["","","","","","","","n","","n"],!1],["viginti",["","","","s","","","s","m","","m"],!1],["triginta",["","","","s","","","s","n","","n"],!0],["quadraginta",["","","","s","","","s","n","","n"],!0],["quinquaginta",["","","","s","","","s","n","","n"],!0],["sexaginta",["","","","","","","","n","","n"],!0],["septuaginta",["","","","","","","","n","","n"],!0],["octoginta",["","","","s","","","x","m","","m"],!0],["nonaginta",["","","","","","","","","",""],!0]],hund:[["",["","","","","","","","","",""]],["centi",["","","","s","","","x","n","","n"]],["ducenti",["","","","","","","","n","","n"]],["trecenti",["","","","s","","","s","n","","n"]],["quadringenti",["","","","s","","","s","n","","n"]],["quingenti",["","","","s","","","s","n","","n"]],["sescenti",["","","","","","","","n","","n"]],["septingenti",["","","","","","","","n","","n"]],["octingenti",["","","","s","","","x","m","","m"]],["nongenti",["","","","","","","","","",""]]]})}e.NumberFormat=function(){const n=["","US","PH","PR","AS","GU","MP","UM","VI"],r=["IN","PK","BD","NP"],a=["decimal","currency","percent","ordinal"],t={code:"i",symbol:"l",narrowSymbol:"l",name:"c",native:"n"},i={title:"",upper:"U",lower:"L",sentence:"S"},o=["minimumIntegerDigits","minimumFractionDigits","minimumSignificantDigits","maximumSignificantDigits","useGrouping","notation","compactDisplay","currencySign","unit","unitDisplay","roundingIncrement","roundingPriority","trailingZeroDisplay"],s=Object.keys(m).filter(e=>"style"!==e),c=["style","currency","currencyDisplay","maximumFractionDigits","roundingMode","signDisplay","numberingSystem","localeMatcher","variant","scale"].concat(s),fail=(e,n)=>{throw new e("arqamEN.NumberFormat: "+n)},near=e=>arqamE_NearestName(e,c),english=e=>/^en(-|$)/i.test(e),canonical=e=>{try{return Intl.getCanonicalLocales(void 0===e?[]:e)}catch(n){fail(RangeError,n.message)}},isNum=e=>/^-?(\d+\.?\d*|\.\d+)$/.test(e);function NumberFormat(l,u){l&&"object"==typeof l&&!Array.isArray(l)&&void 0===u&&(u=l,l=void 0),void 0===u||null!==u&&"object"==typeof u||fail(TypeError,"the options must be an object");const y=Object.assign({},u),p=canonical(l),g=p.find(english)||(p.length?fail(RangeError,`no English locale in ${JSON.stringify(l)}`):"en");for(const e of Object.keys(y))if(o.includes(e)&&fail(RangeError,`${e} is an option of Intl's figures; the words do not use it`),!c.includes(e)){const n="code"===e?"currency":near(e);fail(TypeError,`unknown option "${e}"`+(n?`; did you mean "${n}"?`:""))}const pick=(e,n,r)=>{const a=void 0===y[e]?r:y[e];return n.includes(a)||fail(RangeError,`${e} must be ${n.map(e=>JSON.stringify(e)).join(", ")}`),a},f=(g.match(/^en(?:-[A-Za-z]{4})?-([A-Za-z]{2}|\d{3})(?:-|$)/)||["",""])[1].toUpperCase(),h=d,S=pick("style",a,(void 0!==y.currency?""!==y.currency:h.currency&&!h.mode)||"currency"===y.mode||"c"===y.mode||void 0===y.mode&&["currency","c"].includes(h.mode)?"currency":"decimal"),b=pick("variant",["us","uk"],n.includes(f)?"us":"uk"),v=pick("scale",["indian","short"],r.includes(f)?"indian":"short"),D=pick("roundingMode",["halfExpand","trunc"],"halfExpand"),T=pick("signDisplay",["auto","always","exceptZero","negative","never"],"auto");pick("numberingSystem",["latn"],"latn"),pick("localeMatcher",["lookup","best fit"],"best fit");const N=void 0!==y.maximumFractionDigits?y.maximumFractionDigits:"decimal"===S?3:"percent"===S?0:void 0;void 0===N||Number.isInteger(N)&&N>=0&&N<=100||fail(RangeError,"maximumFractionDigits must be a whole number from 0 to 100");const F={};for(const e of s)void 0!==y[e]&&(F[e]=y[e]);const E=void 0!==F.mode?F.mode:"currency"===S?"currency":"ordinal"===S?"o":"",$="o"===E||"ordinals"===E,R="c"===E||"currency"===E,L="percent"===S&&!R&&!$;if(F.mode=E,F.style="uk"===b?"uk":"",F.scale="indian"===v?"indian":"",void 0===y.currency||R||fail(TypeError,`currency needs style "currency" (got style "${S}")`),R){const e=F.currency||h.currency||void 0;e||F.major||fail(TypeError,"currency is required with style currency"),void 0!==e&&(/^[A-Za-z]{3,}$/.test(e)||fail(RangeError,`invalid currency ${JSON.stringify(e)}`),F.currency=String(e).toUpperCase())}var A;void 0!==y.currencyDisplay&&void 0===F.symbol&&(F.symbol=t[pick("currencyDisplay",Object.keys(t),"code")]),void 0!==F.textFormat&&void 0!==i[F.textFormat]&&(F.textFormat=i[F.textFormat]),"halfExpand"!==D||void 0!==N||void 0!==y[A="rounding"]||void 0!==h[A]&&String(h[A])!==String(m[A])||(F.rounding="on"),"never"===T&&(F.negativeWord="");const B=void 0!==F.brackets?F.brackets:h.brackets,O="start"===B||"end"===B?B:"";F.brackets="";const k=F.only;delete F.split;const w=(e=>{let n;try{n=new Intl.NumberFormat(e).formatToParts(1234567.5)}catch(i){n=[]}const r=n.filter(e=>"integer"===e.type).map(e=>e.value),a=n.find(e=>"group"===e.type),t=n.find(e=>"decimal"===e.type);return{group:a?a.value:",",decimal:t?t.value:".",primary:r.length>1?r[r.length-1].length:3,secondary:r.length>2?r[r.length-2].length:3}})(g),input=e=>{let n=(e=>("number"==typeof e&&Number.isFinite(e)&&(e=e.toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:20})),String(e)))(e);return"never"===T&&(n=n.replace(/^-/,"")),L&&(n=(e=>{if(!isNum(e))return e;let[,n,r,a=""]=e.match(/^(-?)(\d*)\.?(\d*)$/);a=a.padEnd(2,"0");const t=((r||"")+a.slice(0,2)).replace(/^0+(?=\d)/,""),i=a.slice(2).replace(/0+$/,"");return n+(t||"0")+(i?"."+i:"")})(n)),void 0!==N&&(n=((e,n,r)=>{if(!isNum(e))return e;let[,a,t,i=""]=e.match(/^(-?)(\d*)\.?(\d*)$/);if(t=t||"0",i.length<=n)return e;const o=r&&i[n]>="5";let s=(t+i.slice(0,n)).split("").map(Number);if(o){let e=s.length-1;for(;e>=0&&9===s[e];)s[e--]=0;e<0?s.unshift(1):s[e]++}const c=s.join(""),l=c.slice(0,c.length-n)||"0",u=c.slice(c.length-n);return a+l+(n?"."+u:"")})(n,N,"halfExpand"===D)),n},engine=(n,r)=>e.toWords(n,Object.assign({},F,r)),caseOf=e=>{const n=F.textFormat||"";return"U"===n?e.toUpperCase():"L"===n?e.toLowerCase():e},percentWord=()=>caseOf(engine("1%",{only:""}).split(" ").pop()),words=(e,n={})=>{if(!isNum(e))return engine(e,n);const r="only"in n?n.only:k;let a=engine(e,Object.assign({},n,{only:L?"":r}));if(L){const e="on"===n.split;a+=(e?"| |p":" ")+percentWord()+(e?"|":""),"end"===r?a+=" "+caseOf("Only"):"start"===r&&(a=caseOf("Only")+" "+a)}if((e=>isNum(e)&&!e.startsWith("-")&&("always"===T||"exceptZero"===T&&!/^[0.]*$/.test(e)))(e)){const e="on"===n.split,t=caseOf("Plus"),i=L||"start"!==r?"":caseOf("Only")+" ";let o=i&&a.startsWith(i)?a.slice(i.length):a;"S"===(F.textFormat||"")&&(o=o.replace(/[A-Z]/,e=>e.toLowerCase())),a=(i&&a.startsWith(i)?i:"")+(e?"|p"+t+"| ":t+" ")+o}return a},figure=e=>{if($||!isNum(e))return null;const n=engine(e,{brackets:"end",only:"",split:"",sepThousands:"",sepDecimal:""}),r=n.lastIndexOf("(");if(r<0)return null;const a=n.slice(r).match(/^\(((?:[^\u0001\u0002\d-][^\u0001\u0002]*? )?)(-?)(\d[\d\u0001]*)(?:\u0002(\d*))?\)$/);if(!a)return null;const[,t,i,o,s]=a,c=[{type:"literal",value:"("}];t&&c.push({type:"currency",value:t.slice(0,-1)},{type:"literal",value:" "}),i&&c.push({type:"minusSign",value:"-"});const l=((e,n)=>{if(e.length<=n.primary)return e;let r=e.slice(-n.primary),a=e.slice(0,-n.primary);for(;a.length>n.secondary;)r=a.slice(-n.secondary)+n.group+r,a=a.slice(0,-n.secondary);return a+n.group+r})(o.replace(/\u0001/g,""),w).split(w.group);return l.forEach((e,n)=>{n&&c.push({type:"group",value:w.group}),c.push({type:"integer",value:e})}),void 0!==s&&""!==s&&c.push({type:"decimal",value:w.decimal},{type:"fraction",value:s}),L&&c.push({type:"percentSign",value:"%"}),c.push({type:"literal",value:")"}),[c.map(e=>e.value).join(""),c]},one=e=>{const n=input(e),r=O&&figure(n);return((e,n)=>n?"start"===O?n+" "+e:e+" "+n:e)(words(n),r&&r[0])},wordParts=(e,n={})=>{if(!isNum(e))return[{type:"literal",value:words(e,n)}];if($)return[{type:"ordinal",value:words(e,n)}];const r=words(e,Object.assign({split:"on"},n)),a=[],push=(e,n)=>{if(""===n)return;const r=a[a.length-1];!r||r.type!==e||"integer"!==e&&"fraction"!==e&&"literal"!==e?a.push({type:e,value:n}):r.value+=n},t=caseOf("Only"),i=R&&(F.decFormatC||F.decFormat)||"";let o=!1,s=!0;const text=e=>{const n=e.match(/^\s*/)[0],r=e.slice(n.length).match(/\s*$/)[0],i=e.slice(n.length,e.length-r.length);push("literal",n),i&&(i===t?push(s?"prefix":"suffix",i):s&&i.startsWith(t+" ")?(push("prefix",t),push("literal"," "),push(o?"fraction":"integer",i.slice(t.length+1))):i.endsWith(" "+t)?(push(o?"fraction":"integer",i.slice(0,-t.length-1)),push("literal"," "),push("suffix",t)):o&&a.some(e=>"fraction"===e.type)&&/^(parts? of .+|\S+ths?)$/i.test(i)?push("denominator",i):push(o?"fraction":"integer",i)),push("literal",r),s=!1},c=/\|f\||\|([pc])([^|]*)\||\|/g;let l,u=0;for(;l=c.exec(r);){if(l.index>u&&text(r.slice(u,l.index)),"|f|"===l[0])o=!0;else if("c"===l[1])push(o&&"."!==i&&"/"!==i?"minorCurrency":"currency",l[2]),s=!1;else if("p"===l[1]){const e=l[2],n=e.trim(),r=e.match(/^\s*/)[0],a=e.slice(r.length+n.length);s&&n&&n===caseOf(void 0===F.negativeWord?"Negative":F.negativeWord)?(push("minusSign",n),push("literal",a)):n===caseOf("Plus")&&"auto"!==T?(push("plusSign",n),push("literal",a)):L&&n===percentWord()?(push("literal",r),push("percentSign",n),push("literal",a)):R||o||!/^\S+$/.test(n)||","===n||"and"===n.toLowerCase()?push("literal",e):(push("literal",r),push("decimal",n),push("literal",a)),s=!1}u=c.lastIndex}return u<r.length&&text(r.slice(u)),a},partsOne=e=>{const n=input(e),r=wordParts(n),a=O&&figure(n);if(!a)return r;const t={type:"figure",value:a[0],parts:a[1]};return"start"===O?[t,{type:"literal",value:" "},...r]:[...r,{type:"literal",value:" "},t]},rangeParts=(e,n)=>{const r=input(e),a=input(n);isNum(r)&&isNum(a)||fail(RangeError,"formatRange needs two numbers");const t=((e,n)=>{const parts=e=>{const[,n,r,a=""]=e.match(/^(-?)(\d*)\.?(\d*)$/);return[n?-1:1,(r||"0").replace(/^0+(?=\d)/,""),a.replace(/0+$/,"")]};let[r,a,t]=parts(e),[i,o,s]=parts(n);if(/^0*$/.test(a+t)&&(r=1),/^0*$/.test(o+s)&&(i=1),r!==i)return r<i?-1:1;const c=Math.max(t.length,s.length),l=a.padStart(o.length,"0")+t.padEnd(c,"0"),u=o.padStart(a.length,"0")+s.padEnd(c,"0");return(l<u?-1:l>u?1:0)*r})(r,a);if(t>0&&fail(RangeError,"the start of the range is after its end"),0===t)return partsOne(e).map(e=>Object.assign({},e,{source:"shared"}));const src=(e,n)=>e.map(e=>Object.assign({},e,{source:n})),i=wordParts(r,{only:""}),o=wordParts(a,{only:""});if("S"===(F.textFormat||""))for(const y of[i,o]){const e=y.find(e=>"literal"!==e.type);e&&"currency"!==e.type&&(e.value=e.value[0].toLowerCase()+e.value.slice(1))}const s=F.textFormat||"",c="U"===s?"FROM":"L"===s?"from":"From",l="U"===s?"TO":"to";let u=[{type:"literal",value:c+" ",source:"shared"},...src(i,"startRange"),{type:"literal",value:" "+l+" ",source:"shared"},...src(o,"endRange")];"end"===k&&u.push({type:"literal",value:" ",source:"shared"},{type:"suffix",value:caseOf("Only"),source:"shared"}),"start"===k&&(u=[{type:"prefix",value:caseOf("Only"),source:"shared"},{type:"literal",value:" "+("S"===s?c.toLowerCase():c)+" ",source:"shared"},...u.slice(1)]);const m=O&&figure(r),d=O&&figure(a);if(m&&d){const e=d[1].filter(e=>"currency"!==e.type&&!("literal"===e.type&&")"!==e.value&&"("!==e.value)),n=[...m[1].slice(0,-1),{type:"literal",value:"–"},...e.slice(1)],r={type:"figure",value:n.map(e=>e.value).join(""),parts:n,source:"shared"};u="start"===O?[r,{type:"literal",value:" ",source:"shared"},...u]:[...u,{type:"literal",value:" ",source:"shared"},r]}return u},K=Object.assign({locale:g,numberingSystem:"latn",style:S},R&&F.currency?{currency:F.currency}:{},R?{currencyDisplay:y.currencyDisplay||"code"}:{},void 0!==N?{maximumFractionDigits:N}:{},{roundingMode:D,signDisplay:T,variant:b,scale:v},...s.filter(e=>void 0!==y[e]&&"scale"!==e&&"currency"!==e).map(e=>({[e]:y[e]})));return Object.freeze({format:e=>Array.isArray(e)?e.map(one):one(e),formatToParts:e=>Array.isArray(e)?e.map(partsOne):partsOne(e),formatRange:(e,n)=>rangeParts(e,n).map(e=>e.value).join(""),formatRangeToParts:(e,n)=>rangeParts(e,n),resolvedOptions:()=>Object.assign({},K)})}return NumberFormat.supportedLocalesOf=e=>canonical(e).filter(english),NumberFormat.styles=a.slice(),NumberFormat}();try{const n=globalThis[Symbol.for("arqam.languages")]||(globalThis[Symbol.for("arqam.languages")]={});n.en||(n.en=e)}catch(h){}return e.version="1.27",e}();export default e;export const version=e.version,currencies=e.currencies;export const toWords=(n,r)=>e.toWords(n,r),config=n=>e.config(n),registerCurrency=(n,r)=>e.registerCurrency(n,r),reset=()=>e.reset(),options=()=>e.options();export const NumberFormat=e.NumberFormat;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/*! arqamExplain — TypeScript declarations for dist/arqamExplain.mjs. MIT licence.
|
|
2
|
+
* Copied to dist/ by tools/build_dist.py; tests/dist.test.js checks that every export of the module is declared here
|
|
3
|
+
* and that the declarations compile. The module imports the engine (arqamAR.mjs) and attaches arqamAR.explain.
|
|
4
|
+
* @author: Mohsen Alyafei */
|
|
5
|
+
import type { ArqamNumber, ArqamOptions, ArqamDate, ArqamDateOptions, ArqamTime, ArqamTimeOptions, ArqamFraction, ArqamFractionOptions, ArqamNumberFormatOptions } from "./arqamAR.mjs";
|
|
6
|
+
|
|
7
|
+
/** What a word is in the text. "word" is any other word (فقط، سالب، بالمائة، لا غير …). */
|
|
8
|
+
export type ArqamExplainPart = "number" | "scale" | "noun" | "adjective" | "qualifier" | "idafa" | "separator" | "word" | "approx";
|
|
9
|
+
|
|
10
|
+
/** One word of the text, with its grammar. */
|
|
11
|
+
export interface ArqamExplainWord {
|
|
12
|
+
/** the word as written (with the tashkeel asked for) */
|
|
13
|
+
word: string;
|
|
14
|
+
/** the word without marks (أ إ آ written ا) */
|
|
15
|
+
plain: string;
|
|
16
|
+
part: ArqamExplainPart;
|
|
17
|
+
/** the value of a number word (ثلاثة -> 3), when it has one */
|
|
18
|
+
value?: number;
|
|
19
|
+
/** the case in one line (the «مختصر» level) */
|
|
20
|
+
short: string;
|
|
21
|
+
/** the reason for the form (the «مفصّل» level) */
|
|
22
|
+
why: string;
|
|
23
|
+
/** the ids of the rules used, keys of ArqamExplanation.rules */
|
|
24
|
+
rules: string[];
|
|
25
|
+
/** up to three comparisons: [the same word in another count, gender or case, a note] */
|
|
26
|
+
compare: [string, string][];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** A rule of the grammar. */
|
|
30
|
+
export interface ArqamExplainRule {
|
|
31
|
+
title: string;
|
|
32
|
+
text: string;
|
|
33
|
+
example: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The result of explain() and explainDate(). An input that gives no words gives text "" and empty lists. */
|
|
37
|
+
export interface ArqamExplanation {
|
|
38
|
+
/** the same text as toWords() / toDate() with these options (no colour markers) */
|
|
39
|
+
text: string;
|
|
40
|
+
words: ArqamExplainWord[];
|
|
41
|
+
/** the rules used, by id */
|
|
42
|
+
rules: Record<string, ArqamExplainRule>;
|
|
43
|
+
/** the rule ids in order of first use */
|
|
44
|
+
order: string[];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The script's function: arqamExplain(number, options) and arqamExplain.date(input, options). */
|
|
48
|
+
export interface ArqamExplain {
|
|
49
|
+
(number: ArqamNumber, options?: ArqamOptions): ArqamExplanation;
|
|
50
|
+
/** A list gives one explanation per item, as toWords(list) gives one text per item. */
|
|
51
|
+
(numbers: ArqamNumber[], options?: ArqamOptions): ArqamExplanation[];
|
|
52
|
+
/** The words of toDate(), word by word. */
|
|
53
|
+
date(input: ArqamDate, options?: ArqamDateOptions): ArqamExplanation;
|
|
54
|
+
/** The words of toTime(), word by word. */
|
|
55
|
+
time(input: ArqamTime, options?: ArqamTimeOptions): ArqamExplanation;
|
|
56
|
+
/** The words of toFraction(), word by word. */
|
|
57
|
+
fraction(input: ArqamFraction, options?: ArqamFractionOptions): ArqamExplanation;
|
|
58
|
+
/** The words of NumberFormat(options).formatRange(from, to), word by word; options as NumberFormat's. */
|
|
59
|
+
range(from: ArqamNumber | ArqamTime | ArqamFraction | ArqamDate, to: ArqamNumber | ArqamTime | ArqamFraction | ArqamDate, options?: ArqamNumberFormatOptions): ArqamExplanation;
|
|
60
|
+
/** Every rule the library knows, by id. */
|
|
61
|
+
readonly rules: Record<string, ArqamExplainRule>;
|
|
62
|
+
readonly version: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
declare const arqamExplain: ArqamExplain;
|
|
66
|
+
export default arqamExplain;
|
|
67
|
+
export declare const version: string;
|
|
68
|
+
export declare const rules: Record<string, ArqamExplainRule>;
|
|
69
|
+
/** The grammar of the words of toWords(number, options), word by word. Options as for toWords(). */
|
|
70
|
+
export declare function explain(number: ArqamNumber, options?: ArqamOptions): ArqamExplanation;
|
|
71
|
+
/** A list gives one explanation per item. */
|
|
72
|
+
export declare function explain(numbers: ArqamNumber[], options?: ArqamOptions): ArqamExplanation[];
|
|
73
|
+
/** The grammar of the words of toDate(input, options), word by word. */
|
|
74
|
+
export declare function explainDate(input: ArqamDate, options?: ArqamDateOptions): ArqamExplanation;
|
|
75
|
+
/** The grammar of the words of toTime(input, options), word by word. */
|
|
76
|
+
export declare function explainTime(input: ArqamTime, options?: ArqamTimeOptions): ArqamExplanation;
|
|
77
|
+
/** The grammar of the words of toFraction(input, options), word by word. */
|
|
78
|
+
export declare function explainFraction(input: ArqamFraction, options?: ArqamFractionOptions): ArqamExplanation;
|
|
79
|
+
/** The grammar of the words of NumberFormat(options).formatRange(from, to), word by word. */
|
|
80
|
+
export declare function explainRange(from: ArqamNumber | ArqamTime | ArqamFraction | ArqamDate, to: ArqamNumber | ArqamTime | ArqamFraction | ArqamDate, options?: ArqamNumberFormatOptions): ArqamExplanation;
|