/**
 * Minified by jsDelivr using Terser v5.37.0.
 * Original file: /npm/tafqit@0.0.1/tafqit.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
/*********************************************************************
* @function      : tafqit(Number [,{options}])
* @purpose       : Converts Numbers to Arabic Words with Grammar Rules
* @version       : 1.60
* @author        : Mohsen Alyafei
* @date          : 04 August 2020
* @Licence       : MIT
* @param         : {Number} [Integer in Numeric or String form]
*                  Number may be in Arabic-Indic format (as a string)
* @param         : [{options}] 9 Options passed as object {name:value} as follows:
*
* {Feminine}     : "on": Generate string for a Feminine subject (أرقام بصيغة المؤنث).
*                        The default is the Masculine form.
* {Miah}         : "on": Use Mi'ah for Hundreds (مئة بدل مائة). Default is Ma'ah "مائة".
* {Comma}        : "on": Insert comma between triplet words.
* {SplitHund}    : "on": Split number from hundred words (فصل الرقم عن المئة).
                   i.e. ثلاث مائة. Default "No Split" i.e. (ثلاثمائة).
* {Billions}     : "on": Use Billions (بليون) instead of Miliard (مليار).
* {TextToFollow} : "on": Indicates that there will be text to follow the resulting text.
*                  This permits proper subject name to be added after the resulting text.
* {AG}           : "on": Text is produced in Accusative/Genitive (جر/نصب) case.
*                  The default is the Nominative cse (رفع).
*
* {Subjec}       : An optional array holding the Subject Name to be counted in 4 forms as follows:
*                  [0] = Deafult Name Singular      (e.g. "كتاب/تفاحة/دينار").
*                  [1] = Name for 2's (double)      (e.g. "كتابان/تفاحتان/ديناران").
*                  [2] = Name for plural            (e.g. "كتب/تفاحات/دنانير").
*                  [3] = Name Singular with Tanween (e.g. "كتابًا/تفاحةً/دينارًا").
*                  The subject name will be added to the resulting string in acordance
*                  with the number grammar rules.
* {Legal}        : "on" Uses the lagal form of output text.
*
* @returns       : {string} The wordified number string in Arabic.
**********************************************************************/
const TableScales=["","ألف","مليون","مليار","ترليون","كوادرليون","كوينتليون","سكستليون"],TableScalesP=["","آلاف","ملايين","مليارات"],TableMale=["","واحد","اثنان","ثلاثة","أربعة","خمسة","ستة","سبعة","ثمانية","تسعة","عشرة"],TableFemale=["","واحدة","اثنتان","ثلاث","أربع","خمس","ست","سبع","ثمان","تسع","عشر"];function tafqit(e=0,{Feminine:l,Comma:a,SplitHund:t,Miah:b,Billions:n,TextToFollow:T,AG:i,Subject:r,Legal:s}={}){if(0==e)return"صفر";let c,o,m,u,f,F,S,g="",M=!1;const h="on",p=i===h,A=" و",d="إحدى",x=p?"تي":"تا",y=p?"تين":"تان",P=p?"ي":"ا",j=p?"ين":"ان",q=p?"اثني":"اثنا",w=p?"اثنتي":"اثنتا",B=p?"اثنين":"اثنان",C=p?"اثنتين":"اثنتان",G=p?"ين":"ون",H=Array.isArray(r)&&4===r.length;T=T===h,H&&(T=!1),e=""+(e+="").replace(/[٠-٩]/g,(e=>"٠١٢٣٤٥٦٧٨٩".indexOf(e))),b=b===h?"مئة":"مائة",f=[...TableMale],F=[...TableMale],F[0]=TableFemale[10],F[1]="أحد",F[2]=q,f[2]=B;let L=(e="0".repeat(2*e.length%3)+e).length;for(let l=L;l>0;l-=3)c=+e.substr(L-l,3),M=!+e.substr(L-l+3),c&&(m=l/3-1,o=TableScales[m],u=m<4?TableScalesP[m]:TableScales[m]+"ات",n&&3===m&&(o="بليون",u="بلايين"),g+=k(),M||(g+=(a===h?"،":"")+A));let O="";if(H){let e=M?" ":"";c=+(c+"").slice(-2),O=e+r[0],c>10?O=e+r[3]:c>2?O=e+r[2]:c>0&&(O=r[c-1]+" "+f[S])}return g+O;function k(){S=c%100;let e=~~(c/100),a=S%10,n=~~(S/10),i="",r="";l===h&&M&&(f=[...TableFemale],F=[...TableFemale],F[0]=TableMale[10],F[1]=d,F[2]=w,f[2]=C,S>19&&(f[1]=d)),e&&(i=e>2?TableFemale[e]+(t===h?" ":"")+b:1===e?b:b.slice(0,-1)+(o&&!S||T?x:y)),S>19?r=f[a]+(a?A:"")+(2===n?"عشر":TableFemale[n])+G:S>10?r=F[S-10]+" "+F[0]:(S>2||!S||!H)&&(r=f[S]);let m=i+(e&&S?A:"")+r;if(o){let l=(e?i+(s===h&&S<3?" "+o:"")+A:"")+o;S>2?m+=" "+(S>10?o+(M&&T?"":"ًا"):u):S?m=1===S?l:l+(M&&T?P:j):m+=" "+o}return m}}
//# sourceMappingURL=/sm/e601d2cc3e4c9734fe421890fc2655d76d595b67427bb5f8a346e3ed81c5c79e.map