localBadiDate-locales.mjs 78 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915
  1. /**
  2. * @license BadiDate v3.0.2
  3. * (c) 2018 Jan Greis
  4. * licensed under MIT
  5. */
  6. import { sunset, solarNoon, sunrise, settings } from 'meeussunmoon';
  7. import { DateTime, Duration } from 'luxon';
  8. const month = {
  9. 1: 'Bahá',
  10. 2: 'Jalál',
  11. 3: 'Jamál',
  12. 4: '‘Aẓamat',
  13. 5: 'Núr',
  14. 6: 'Raḥmat',
  15. 7: 'Kalimát',
  16. 8: 'Kamál',
  17. 9: 'Asmá’',
  18. 10: '‘Izzat',
  19. 11: 'Ma_sh_íyyat',
  20. 12: '‘Ilm',
  21. 13: 'Qudrat',
  22. 14: 'Qawl',
  23. 15: 'Masá’il',
  24. 16: '_Sh_araf',
  25. 17: 'Sulṭán',
  26. 18: 'Mulk',
  27. 19: '‘Alá’',
  28. 20: 'Ayyám-i-Há',
  29. };
  30. const monthL = {
  31. 1: 'Splendour',
  32. 2: 'Glory',
  33. 3: 'Beauty',
  34. 4: 'Grandeur',
  35. 5: 'Light',
  36. 6: 'Mercy',
  37. 7: 'Words',
  38. 8: 'Perfection',
  39. 9: 'Names',
  40. 10: 'Might',
  41. 11: 'Will',
  42. 12: 'Knowledge',
  43. 13: 'Power',
  44. 14: 'Speech',
  45. 15: 'Questions',
  46. 16: 'Honour',
  47. 17: 'Sovereignty',
  48. 18: 'Dominion',
  49. 19: 'Loftiness',
  50. 20: 'Ayyám-i-Há',
  51. };
  52. const holyDay = {
  53. 1: 'Naw-Rúz',
  54. 2: 'First day of Riḍván',
  55. 3: 'Ninth day of Riḍván',
  56. 4: 'Twelfth day of Riḍván',
  57. 5: 'Declaration of the Báb',
  58. 6: 'Ascension of Bahá’u’lláh',
  59. 7: 'Martyrdom of the Báb',
  60. 8: 'Birth of the Báb',
  61. 9: 'Birth of Bahá’u’lláh',
  62. 10: 'Day of the Covenant',
  63. 11: 'Ascension of ‘Abdu’l-Bahá',
  64. };
  65. // CAREFUL: Numbering corresponds to Badí' week, i.e. 1 is Jalál (-> Saturday)
  66. const weekday = {
  67. 1: 'Jalál',
  68. 2: 'Jamál',
  69. 3: 'Kamál',
  70. 4: 'Fiḍál',
  71. 5: '‘Idál',
  72. 6: 'Istijlál',
  73. 7: 'Istiqlál',
  74. };
  75. const weekdayAbbr3 = {
  76. 1: 'Jal',
  77. 2: 'Jam',
  78. 3: 'Kam',
  79. 4: 'Fiḍ',
  80. 5: '‘Idá',
  81. 6: 'Isj',
  82. 7: 'Isq',
  83. };
  84. const weekdayAbbr2 = {
  85. 1: 'Jl',
  86. 2: 'Jm',
  87. 3: 'Ka',
  88. 4: 'Fi',
  89. 5: '‘Id',
  90. 6: 'Ij',
  91. 7: 'Iq',
  92. };
  93. const weekdayL = {
  94. 1: 'Glory',
  95. 2: 'Beauty',
  96. 3: 'Perfection',
  97. 4: 'Grace',
  98. 5: 'Justice',
  99. 6: 'Majesty',
  100. 7: 'Independence',
  101. };
  102. const yearInVahid = {
  103. 1: 'Alif',
  104. 2: 'Bá’',
  105. 3: 'Ab',
  106. 4: 'Dál',
  107. 5: 'Báb',
  108. 6: 'Váv',
  109. 7: 'Abad',
  110. 8: 'Jád',
  111. 9: 'Bahá',
  112. 10: 'Ḥubb',
  113. 11: 'Bahháj',
  114. 12: 'Javáb',
  115. 13: 'Aḥad',
  116. 14: 'Vahháb',
  117. 15: 'Vidád',
  118. 16: 'Badí‘',
  119. 17: 'Bahí',
  120. 18: 'Abhá',
  121. 19: 'Váḥid',
  122. };
  123. const vahid = 'Váḥid';
  124. const kulliShay = 'Kull-i-_Sh_ay’';
  125. const BE = 'B.E.';
  126. const badiCalendar = 'Badí‘ Calendar';
  127. const unicodeCharForZero = '0';
  128. const defaultFormat = 'd MM+ y BE';
  129. var en = /*#__PURE__*/Object.freeze({
  130. __proto__: null,
  131. month: month,
  132. monthL: monthL,
  133. holyDay: holyDay,
  134. weekday: weekday,
  135. weekdayAbbr3: weekdayAbbr3,
  136. weekdayAbbr2: weekdayAbbr2,
  137. weekdayL: weekdayL,
  138. yearInVahid: yearInVahid,
  139. vahid: vahid,
  140. kulliShay: kulliShay,
  141. BE: BE,
  142. badiCalendar: badiCalendar,
  143. unicodeCharForZero: unicodeCharForZero,
  144. defaultFormat: defaultFormat
  145. });
  146. const month$1 = {
  147. 1: 'البهاء',
  148. 2: 'الجلال',
  149. 3: 'الجمال',
  150. 4: 'العظمة',
  151. 5: 'النور',
  152. 6: 'الرحمة',
  153. 7: 'الكلمات',
  154. 8: 'الكمال',
  155. 9: 'الأسماء',
  156. 10: 'العزّة',
  157. 11: 'المشية',
  158. 12: 'العلم',
  159. 13: 'القدرة',
  160. 14: 'القول',
  161. 15: 'المسائل',
  162. 16: 'الشرف',
  163. 17: 'السلطان',
  164. 18: 'الملك',
  165. 19: 'العلاء',
  166. 20: 'ايام الهاء',
  167. };
  168. const monthL$1 = month$1;
  169. const holyDay$1 = {
  170. 1: 'عيد النَّيروز',
  171. 2: 'اليوم الأول من عيد الرِّضوان',
  172. 3: 'اليوم التاسع من عيد الرِّضوان',
  173. 4: 'اليوم الثاني عشر من عيد الرِّضوان',
  174. 5: 'يوم إعلان دعوة حضرة الباب',
  175. 6: 'يوم صعود حضرة بهاء الله',
  176. 7: 'يوم استشهاد حضرة الباب',
  177. 8: 'يوم ولادة حضرة الباب',
  178. 9: 'يوم ولادة حضرة بهاء الله',
  179. 10: 'يوم الميثاق',
  180. 11: 'يوم صعود حضرة عبد البهاء',
  181. };
  182. const weekday$1 = {
  183. 1: 'الجلال',
  184. 2: 'الجمال',
  185. 3: 'الكمال',
  186. 4: 'الفضّال',
  187. 5: 'العدّال',
  188. 6: 'الأستجلال',
  189. 7: 'الاستقلال',
  190. };
  191. const weekdayAbbr3$1 = {
  192. 1: 'جلا',
  193. 2: 'جما',
  194. 3: 'كما',
  195. 4: 'فضّا',
  196. 5: 'عدّا',
  197. 6: 'اسج',
  198. 7: 'اسق',
  199. };
  200. const weekdayAbbr2$1 = {
  201. 1: 'جل',
  202. 2: 'جم',
  203. 3: 'كم',
  204. 4: 'فض',
  205. 5: 'عد',
  206. 6: 'اج',
  207. 7: 'اق',
  208. };
  209. const weekdayL$1 = {
  210. 1: 'الجلال',
  211. 2: 'الجمال',
  212. 3: 'الكمال',
  213. 4: 'الفضّال',
  214. 5: 'العدّال',
  215. 6: 'الأستجلال',
  216. 7: 'أستقلال',
  217. };
  218. const yearInVahid$1 = {
  219. 1: 'ألف',
  220. 2: 'باء',
  221. 3: 'أب',
  222. 4: 'دﺍﻝ',
  223. 5: 'باب',
  224. 6: 'وﺍو',
  225. 7: 'أبد',
  226. 8: 'جاد',
  227. 9: 'بهاء',
  228. 10: 'حب',
  229. 11: 'بهاج',
  230. 12: 'جواب',
  231. 13: 'احد',
  232. 14: 'وﻫﺎب',
  233. 15: 'وداد',
  234. 16: 'بدیع',
  235. 17: 'بهي',
  236. 18: 'ابهى',
  237. 19: 'واحد',
  238. };
  239. const vahid$1 = 'واحد';
  240. const kulliShay$1 = 'كل شيء';
  241. const BE$1 = 'بديع';
  242. const badiCalendar$1 = 'تقويم بديع';
  243. const unicodeCharForZero$1 = '٠';
  244. const defaultFormat$1 = '‏d MM y BE‏';
  245. var ar = /*#__PURE__*/Object.freeze({
  246. __proto__: null,
  247. month: month$1,
  248. monthL: monthL$1,
  249. holyDay: holyDay$1,
  250. weekday: weekday$1,
  251. weekdayAbbr3: weekdayAbbr3$1,
  252. weekdayAbbr2: weekdayAbbr2$1,
  253. weekdayL: weekdayL$1,
  254. yearInVahid: yearInVahid$1,
  255. vahid: vahid$1,
  256. kulliShay: kulliShay$1,
  257. BE: BE$1,
  258. badiCalendar: badiCalendar$1,
  259. unicodeCharForZero: unicodeCharForZero$1,
  260. defaultFormat: defaultFormat$1
  261. });
  262. const monthL$2 = {
  263. 1: 'Herrlichkeit',
  264. 2: 'Ruhm',
  265. 3: 'Schönheit',
  266. 4: 'Größe',
  267. 5: 'Licht',
  268. 6: 'Barmherzigkeit',
  269. 7: 'Worte',
  270. 8: 'Vollkommenheit',
  271. 9: 'Namen',
  272. 10: 'Macht',
  273. 11: 'Wille',
  274. 12: 'Wissen',
  275. 13: 'Kraft',
  276. 14: 'Sprache',
  277. 15: 'Fragen',
  278. 16: 'Ehre',
  279. 17: 'Souveränität',
  280. 18: 'Herrschaft',
  281. 19: 'Erhabenheit',
  282. 20: 'Ayyám-i-Há',
  283. };
  284. const holyDay$2 = {
  285. 1: 'Naw-Rúz',
  286. 2: 'Erster Riḍván-Tag',
  287. 3: 'Neunter Riḍván-Tag',
  288. 4: 'Zwölfter Riḍván-Tag',
  289. 5: 'Erklärung des Báb',
  290. 6: 'Hinscheiden Bahá’u’lláhs',
  291. 7: 'Märtyrertod des Báb',
  292. 8: 'Geburt des Báb',
  293. 9: 'Geburt Bahá’u’lláhs',
  294. 10: 'Tag des Bundes',
  295. 11: 'Hinscheiden ‘Abdu’l-Bahás',
  296. };
  297. const weekdayL$2 = {
  298. 1: 'Ruhm',
  299. 2: 'Schönheit',
  300. 3: 'Vollkommenheit',
  301. 4: 'Gnade',
  302. 5: 'Gerechtigkeit',
  303. 6: 'Majestät',
  304. 7: 'Unabhängigkeit',
  305. };
  306. const BE$2 = 'B.E.';
  307. const badiCalendar$2 = 'Badí‘ Kalender';
  308. var de = /*#__PURE__*/Object.freeze({
  309. __proto__: null,
  310. monthL: monthL$2,
  311. holyDay: holyDay$2,
  312. weekdayL: weekdayL$2,
  313. BE: BE$2,
  314. badiCalendar: badiCalendar$2
  315. });
  316. const monthL$3 = {
  317. 1: 'Esplendor',
  318. 2: 'Gloria',
  319. 3: 'Belleza',
  320. 4: 'Grandeza',
  321. 5: 'Luz',
  322. 6: 'Misericordia',
  323. 7: 'Palabras',
  324. 8: 'Perfección',
  325. 9: 'Nombres',
  326. 10: 'Fuerza',
  327. 11: 'Voluntad',
  328. 12: 'Conocimiento',
  329. 13: 'Poder',
  330. 14: 'Discurso',
  331. 15: 'Preguntas',
  332. 16: 'Honor',
  333. 17: 'Soberanía',
  334. 18: 'Dominio',
  335. 19: 'Sublimidad',
  336. 20: 'Ayyám-i-Há',
  337. };
  338. const holyDay$3 = {
  339. 1: 'Naw-Rúz',
  340. 2: 'Primer día de Riḍván',
  341. 3: 'Noveno día de Riḍván',
  342. 4: 'Duodécimo día de Riḍván',
  343. 5: 'Declaración del Báb',
  344. 6: 'Ascensión de Bahá’u’lláh',
  345. 7: 'Martirio del Báb',
  346. 8: 'Nacimiento del Báb',
  347. 9: 'Nacimiento de Bahá’u’lláh',
  348. 10: 'Día de la Alianza',
  349. 11: 'Fallecimiento de ‘Abdu’l-Bahá',
  350. };
  351. const weekdayL$3 = {
  352. 1: 'Gloria',
  353. 2: 'Belleza',
  354. 3: 'Perfección',
  355. 4: 'Gracia',
  356. 5: 'Justicia',
  357. 6: 'Majestuosidad',
  358. 7: 'Independencia',
  359. };
  360. const BE$3 = 'E.B.';
  361. const badiCalendar$3 = 'Calendario Badí‘';
  362. var es = /*#__PURE__*/Object.freeze({
  363. __proto__: null,
  364. monthL: monthL$3,
  365. holyDay: holyDay$3,
  366. weekdayL: weekdayL$3,
  367. BE: BE$3,
  368. badiCalendar: badiCalendar$3
  369. });
  370. const month$2 = {
  371. 1: 'البهاء',
  372. 2: 'الجلال',
  373. 3: 'الجمال',
  374. 4: 'العظمة',
  375. 5: 'النور',
  376. 6: 'الرحمة',
  377. 7: 'الكلمات',
  378. 8: 'الكمال',
  379. 9: 'الأسماء',
  380. 10: 'العزّة',
  381. 11: 'المشية',
  382. 12: 'العلم',
  383. 13: 'القدرة',
  384. 14: 'القول',
  385. 15: 'المسائل',
  386. 16: 'الشرف',
  387. 17: 'السلطان',
  388. 18: 'الملك',
  389. 19: 'العلاء',
  390. 20: 'ايام الهاء',
  391. };
  392. const monthL$4 = {
  393. 1: 'بهاء',
  394. 2: 'جلال',
  395. 3: 'جمال',
  396. 4: 'عظمت',
  397. 5: 'نور',
  398. 6: 'رحمت',
  399. 7: 'كلمات',
  400. 8: 'كمال',
  401. 9: 'أسماء',
  402. 10: 'عزّت',
  403. 11: 'مشيت',
  404. 12: 'علم',
  405. 13: 'قدرت',
  406. 14: 'قول',
  407. 15: 'مسائل',
  408. 16: 'شرف',
  409. 17: 'سلطان',
  410. 18: 'ملك',
  411. 19: 'علاء',
  412. 20: 'ايام ها',
  413. };
  414. const holyDay$4 = {
  415. 1: 'عید نوروز',
  416. 2: 'روز اوّل عید رضوان',
  417. 3: 'روز نهم عید رضوان',
  418. 4: 'روز دوازدهم عید رضوان',
  419. 5: 'بعثت حضرت باب',
  420. 6: 'صعود حضرت بهاالله',
  421. 7: 'شهادت حضرت اعلی',
  422. 8: 'تولّد حضرت اعلی',
  423. 9: 'تولّد حضرت بهالله',
  424. 10: 'روز عهد و میثاق',
  425. 11: 'صعود حضرت عبدالبها',
  426. };
  427. const weekday$2 = {
  428. 1: 'یوم الجلال',
  429. 2: 'یوم الجمال',
  430. 3: 'یوم الكمال',
  431. 4: 'یوم الفضّال',
  432. 5: 'یوم العدّال',
  433. 6: 'یوم الأستجلال',
  434. 7: 'یوم الاستقلال',
  435. };
  436. const weekdayAbbr3$2 = {
  437. 1: 'جلا',
  438. 2: 'جما',
  439. 3: 'كما',
  440. 4: 'فضّا',
  441. 5: 'عدّا',
  442. 6: 'اسج',
  443. 7: 'اسق',
  444. };
  445. const weekdayAbbr2$2 = {
  446. 1: 'جل',
  447. 2: 'جم',
  448. 3: 'كم',
  449. 4: 'فض',
  450. 5: 'عد',
  451. 6: 'اج',
  452. 7: 'اق',
  453. };
  454. const weekdayL$4 = {
  455. 1: 'جلال',
  456. 2: 'جمال',
  457. 3: 'كمال',
  458. 4: 'فضّال',
  459. 5: 'عدّال',
  460. 6: 'استجلال',
  461. 7: 'استقلال',
  462. };
  463. const yearInVahid$2 = {
  464. 1: 'ألف',
  465. 2: 'باء',
  466. 3: 'أب',
  467. 4: 'دﺍﻝ',
  468. 5: 'باب',
  469. 6: 'وﺍو',
  470. 7: 'أبد',
  471. 8: 'جاد',
  472. 9: 'بهاء',
  473. 10: 'حب',
  474. 11: 'بهاج',
  475. 12: 'جواب',
  476. 13: 'احد',
  477. 14: 'وﻫﺎب',
  478. 15: 'وداد',
  479. 16: 'بدیع',
  480. 17: 'بهي',
  481. 18: 'ابهى',
  482. 19: 'واحد',
  483. };
  484. const vahid$2 = 'واحد';
  485. const kulliShay$2 = 'كل شيء';
  486. const BE$4 = 'بديع';
  487. const badiCalendar$4 = 'تقويم بديع';
  488. const unicodeCharForZero$2 = '۰';
  489. const defaultFormat$2 = '‏d MML y BE‏';
  490. var fa = /*#__PURE__*/Object.freeze({
  491. __proto__: null,
  492. month: month$2,
  493. monthL: monthL$4,
  494. holyDay: holyDay$4,
  495. weekday: weekday$2,
  496. weekdayAbbr3: weekdayAbbr3$2,
  497. weekdayAbbr2: weekdayAbbr2$2,
  498. weekdayL: weekdayL$4,
  499. yearInVahid: yearInVahid$2,
  500. vahid: vahid$2,
  501. kulliShay: kulliShay$2,
  502. BE: BE$4,
  503. badiCalendar: badiCalendar$4,
  504. unicodeCharForZero: unicodeCharForZero$2,
  505. defaultFormat: defaultFormat$2
  506. });
  507. const monthL$5 = {
  508. 1: 'Splendeur',
  509. 2: 'Gloire',
  510. 3: 'Beauté',
  511. 4: 'Grandeur',
  512. 5: 'Lumière',
  513. 6: 'Miséricorde',
  514. 7: 'Paroles',
  515. 8: 'Perfection',
  516. 9: 'Noms',
  517. 10: 'Puissance',
  518. 11: 'Volonté',
  519. 12: 'Connaissance',
  520. 13: 'Pouvoir',
  521. 14: 'Discours',
  522. 15: 'Questions',
  523. 16: 'Honneur',
  524. 17: 'Souveraineté',
  525. 18: 'Empire',
  526. 19: 'Élévation',
  527. 20: 'Ayyám-i-Há',
  528. };
  529. const holyDay$5 = {
  530. 1: 'Naw-Rúz',
  531. 2: 'Premier jour de Riḍván',
  532. 3: 'Neuvième jour de Riḍván',
  533. 4: 'Douzième jour de Riḍván',
  534. 5: 'Déclaration du Báb',
  535. 6: 'Ascension de Bahá’u’lláh',
  536. 7: 'Martyre du Báb',
  537. 8: 'Naissance du Báb',
  538. 9: 'Naissance de Bahá’u’lláh',
  539. 10: 'Jour de l’Alliance',
  540. 11: 'Ascension de ‘Abdu’l-Bahá',
  541. };
  542. const weekdayL$5 = {
  543. 1: 'Gloire',
  544. 2: 'Beauté',
  545. 3: 'Perfection',
  546. 4: 'Grâce',
  547. 5: 'Justice',
  548. 6: 'Majesté',
  549. 7: 'Indépendance',
  550. };
  551. const BE$5 = 'E.B.';
  552. const badiCalendar$5 = 'Calendrier Badí‘';
  553. var fr = /*#__PURE__*/Object.freeze({
  554. __proto__: null,
  555. monthL: monthL$5,
  556. holyDay: holyDay$5,
  557. weekdayL: weekdayL$5,
  558. BE: BE$5,
  559. badiCalendar: badiCalendar$5
  560. });
  561. const monthL$6 = {
  562. 1: 'Spožums',
  563. 2: 'Slava',
  564. 3: 'Skaistums',
  565. 4: 'Dižums',
  566. 5: 'Gaisma',
  567. 6: 'Žēlastība',
  568. 7: 'Vārdi',
  569. 8: 'Pilnība',
  570. 9: 'Nosaukumi',
  571. 10: 'Varenība',
  572. 11: 'Griba',
  573. 12: 'Zināšanas',
  574. 13: 'Vara',
  575. 14: 'Runa',
  576. 15: 'Jautājumi',
  577. 16: 'Gods',
  578. 17: 'Suverenitāte',
  579. 18: 'Valdīšana',
  580. 19: 'Cēlums',
  581. 20: 'Ayyám-i-Há',
  582. };
  583. const holyDay$6 = {
  584. 1: 'Naw-Rúz',
  585. 2: 'Riḍván pirmā diena',
  586. 3: 'Riḍván devītā diena',
  587. 4: 'Riḍván divpadsmitā diena',
  588. 5: 'Bába paziņojums',
  589. 6: 'Bahá’u’lláh Debessbraukšana',
  590. 7: 'Bába mocekļa nāve',
  591. 8: 'Bába dzimšanas diena',
  592. 9: 'Bahá’u’lláh dzimšanas diena',
  593. 10: 'Derības diena',
  594. 11: '‘Abdu’l-Bahá Debessbraukšana',
  595. };
  596. const weekdayL$6 = {
  597. 1: 'Slava',
  598. 2: 'Skaistums',
  599. 3: 'Pilnība',
  600. 4: 'Žēlastība',
  601. 5: 'Taisnīgums',
  602. 6: 'Majestātiskums',
  603. 7: 'Neatkarība',
  604. };
  605. const BE$6 = 'B.Ē.';
  606. const badiCalendar$6 = 'Badí‘ kalendārs';
  607. var lv = /*#__PURE__*/Object.freeze({
  608. __proto__: null,
  609. monthL: monthL$6,
  610. holyDay: holyDay$6,
  611. weekdayL: weekdayL$6,
  612. BE: BE$6,
  613. badiCalendar: badiCalendar$6
  614. });
  615. const monthL$7 = {
  616. 1: 'Pracht',
  617. 2: 'Heerlijkheid',
  618. 3: 'Schoonheid',
  619. 4: 'Grootheid',
  620. 5: 'Licht',
  621. 6: 'Barmhartigheid',
  622. 7: 'Woorden',
  623. 8: 'Volmaaktheid',
  624. 9: 'Namen',
  625. 10: 'Macht',
  626. 11: 'Wil',
  627. 12: 'Kennis',
  628. 13: 'Kracht',
  629. 14: 'Spraak',
  630. 15: 'Vragen',
  631. 16: 'Eer',
  632. 17: 'Soevereiniteit',
  633. 18: 'Heerschappij',
  634. 19: 'Verhevenheid',
  635. 20: 'Ayyám-i-Há',
  636. };
  637. const holyDay$7 = {
  638. 1: 'Naw-Rúz',
  639. 2: 'Eerste dag van Riḍván',
  640. 3: 'Negende dag van Riḍván',
  641. 4: 'Twaalfde dag van Riḍván',
  642. 5: 'Verkondiging van de Báb',
  643. 6: 'Heengaan van Bahá’u’lláh',
  644. 7: 'Marteldood van de Báb',
  645. 8: 'Geboortedag van de Báb',
  646. 9: 'Geboortedag van Bahá’u’lláh',
  647. 10: 'Dag van het Verbond',
  648. 11: 'Heengaan van ‘Abdu’l-Bahá',
  649. };
  650. const weekdayL$7 = {
  651. 1: 'Heerlijkheid',
  652. 2: 'Schoonheid',
  653. 3: 'Volmaaktheid',
  654. 4: 'Genade',
  655. 5: 'Gerechtigheid',
  656. 6: 'Majesteit',
  657. 7: 'Onafhankelijkheid',
  658. };
  659. const BE$7 = 'B.E.';
  660. const badiCalendar$7 = 'Badí‘-Kalender';
  661. var nl = /*#__PURE__*/Object.freeze({
  662. __proto__: null,
  663. monthL: monthL$7,
  664. holyDay: holyDay$7,
  665. weekdayL: weekdayL$7,
  666. BE: BE$7,
  667. badiCalendar: badiCalendar$7
  668. });
  669. const monthL$8 = {
  670. 1: 'Esplendor',
  671. 2: 'Glória',
  672. 3: 'Beleza',
  673. 4: 'Grandeza',
  674. 5: 'Luz',
  675. 6: 'Miséricórdia',
  676. 7: 'Palavras',
  677. 8: 'Perfeição',
  678. 9: 'Nomes',
  679. 10: 'Potência',
  680. 11: 'Vontade',
  681. 12: 'Conhecimento',
  682. 13: 'Poder',
  683. 14: 'Discurso',
  684. 15: 'Perguntas',
  685. 16: 'Honra',
  686. 17: 'Soberania',
  687. 18: 'Domínio',
  688. 19: 'Sublimidade',
  689. 20: 'Ayyám-i-Há',
  690. };
  691. const holyDay$8 = {
  692. 1: 'Naw-Rúz',
  693. 2: '1º dia do Riḍván',
  694. 3: '9º dia do Riḍván',
  695. 4: '12º dia do Riḍván',
  696. 5: 'Declaração do Báb',
  697. 6: 'Ascensão de Bahá’u’lláh',
  698. 7: 'Martírio do Báb',
  699. 8: 'Aniversário do Báb',
  700. 9: 'Aniversário de Bahá’u’lláh',
  701. 10: 'Dia do Convênio',
  702. 11: 'Ascensão de ‘Abdu’l-Bahá',
  703. };
  704. const weekdayL$8 = {
  705. 1: 'Glória',
  706. 2: 'Beleza',
  707. 3: 'Perfeição',
  708. 4: 'Graça',
  709. 5: 'Justiça',
  710. 6: 'Majestade',
  711. 7: 'Independência',
  712. };
  713. const BE$8 = 'E.B.';
  714. const badiCalendar$8 = 'Calendário Badí‘';
  715. var pt = /*#__PURE__*/Object.freeze({
  716. __proto__: null,
  717. monthL: monthL$8,
  718. holyDay: holyDay$8,
  719. weekdayL: weekdayL$8,
  720. BE: BE$8,
  721. badiCalendar: badiCalendar$8
  722. });
  723. const month$3 = {
  724. 1: 'Бахā',
  725. 2: 'Джалāл',
  726. 3: 'Джамāл',
  727. 4: '‘Аз̣амат',
  728. 5: 'Нӯр',
  729. 6: 'Рах̣мат',
  730. 7: 'Калимāт',
  731. 8: 'Камāл',
  732. 9: 'Асмā’',
  733. 10: '‘Иззат',
  734. 11: 'Машӣййат',
  735. 12: '‘Илм',
  736. 13: 'К̣удрат',
  737. 14: 'К̣аул',
  738. 15: 'Масā’ил',
  739. 16: 'Шараф',
  740. 17: 'Султ̣ан',
  741. 18: 'Мулк',
  742. 19: '‘Алā’',
  743. 20: 'Аййāм-и Хā',
  744. };
  745. const monthL$9 = {
  746. 1: 'Великолепие',
  747. 2: 'Слава',
  748. 3: 'Красота',
  749. 4: 'Величие',
  750. 5: 'Свет',
  751. 6: 'Милость',
  752. 7: 'Слова',
  753. 8: 'Совершенство',
  754. 9: 'Имена',
  755. 10: 'Мощь',
  756. 11: 'Воля',
  757. 12: 'Знание',
  758. 13: 'Могущество',
  759. 14: 'Речь',
  760. 15: 'Вопросы',
  761. 16: 'Честь',
  762. 17: 'Владычество',
  763. 18: 'Господство',
  764. 19: 'Возвышенность',
  765. 20: 'Аййāм-и Хā',
  766. };
  767. const holyDay$9 = {
  768. 1: 'Нау-Рӯз',
  769. 2: '1-й день Рид̣вāна',
  770. 3: '9-й день Рид̣вāна',
  771. 4: '12-й день Рид̣вāна',
  772. 5: 'Возвещение Баба',
  773. 6: 'Вознесение Бахауллы',
  774. 7: 'Мученическая Баба',
  775. 8: 'рождения Баба',
  776. 9: 'рождения Бахауллы',
  777. 10: 'День Завета',
  778. 11: 'Вознесение Абдул-Баха',
  779. };
  780. const weekday$3 = {
  781. 1: 'Джалāл',
  782. 2: 'Джамāл',
  783. 3: 'Камāл',
  784. 4: 'Фид̣āл',
  785. 5: '‘Идāл',
  786. 6: 'Истиджлāл',
  787. 7: 'Истик̣лāл',
  788. };
  789. const weekdayAbbr3$3 = {
  790. 1: 'Джл',
  791. 2: 'Джм',
  792. 3: 'Кам',
  793. 4: 'Фид̣',
  794. 5: '‘Идā',
  795. 6: 'Исд',
  796. 7: 'Иск̣',
  797. };
  798. const weekdayAbbr2$3 = {
  799. 1: 'Дл',
  800. 2: 'Дм',
  801. 3: 'Ка',
  802. 4: 'Фи',
  803. 5: '‘Ид',
  804. 6: 'Ид',
  805. 7: 'Ик̣',
  806. };
  807. const weekdayL$9 = {
  808. 1: 'Слава',
  809. 2: 'Красота',
  810. 3: 'Совершенство',
  811. 4: 'Благодать',
  812. 5: 'Справедливость',
  813. 6: 'Величие',
  814. 7: 'Независимость',
  815. };
  816. const yearInVahid$3 = {
  817. 1: 'Алиф',
  818. 2: 'Бā’',
  819. 3: 'Аб',
  820. 4: 'Дāл',
  821. 5: 'Бāб',
  822. 6: 'Вāв',
  823. 7: 'Абад',
  824. 8: 'Джāд',
  825. 9: 'Бахā',
  826. 10: 'Х̣убб',
  827. 11: 'Баххāдж',
  828. 12: 'Джавāб',
  829. 13: 'Ах̣ад',
  830. 14: 'Ваххāб',
  831. 15: 'Видāд',
  832. 16: 'Бадӣ‘',
  833. 17: 'Бахӣ',
  834. 18: 'Абхā',
  835. 19: 'Вāх̣ид',
  836. };
  837. const vahid$3 = 'Вāх̣ид';
  838. const kulliShay$3 = 'кулл-и шай’';
  839. const BE$9 = 'Э.Б.';
  840. const badiCalendar$9 = 'Календарь Бадӣ‘';
  841. var ru = /*#__PURE__*/Object.freeze({
  842. __proto__: null,
  843. month: month$3,
  844. monthL: monthL$9,
  845. holyDay: holyDay$9,
  846. weekday: weekday$3,
  847. weekdayAbbr3: weekdayAbbr3$3,
  848. weekdayAbbr2: weekdayAbbr2$3,
  849. weekdayL: weekdayL$9,
  850. yearInVahid: yearInVahid$3,
  851. vahid: vahid$3,
  852. kulliShay: kulliShay$3,
  853. BE: BE$9,
  854. badiCalendar: badiCalendar$9
  855. });
  856. const monthL$a = {
  857. 1: 'Praktfullhet',
  858. 2: 'Härlighet',
  859. 3: 'Skönhet',
  860. 4: 'Storhet',
  861. 5: 'Ljus',
  862. 6: 'Barmhärtighet',
  863. 7: 'Ord',
  864. 8: 'Fullkomlighet',
  865. 9: 'Namn',
  866. 10: 'Makt',
  867. 11: 'Vilja',
  868. 12: 'Kunskap',
  869. 13: 'Kraft',
  870. 14: 'Tal',
  871. 15: 'Frågor',
  872. 16: 'Ära',
  873. 17: 'Överhöghet',
  874. 18: 'Herravälde',
  875. 19: 'Upphöjdhet',
  876. 20: 'Ayyám-i-Há',
  877. };
  878. const holyDay$a = {
  879. 1: 'Naw-Rúz',
  880. 2: 'Första Riḍván',
  881. 3: 'Nionde Riḍván',
  882. 4: 'Tolfte Riḍván',
  883. 5: 'Bábs Deklaration',
  884. 6: 'Bahá’u’lláhs Bortgång',
  885. 7: 'Bábs Martyrskap',
  886. 8: 'Bábs Födelse',
  887. 9: 'Bahá’u’lláhs Födelse',
  888. 10: 'Förbundets dag',
  889. 11: '‘Abdu’l-Bahás Bortgång',
  890. };
  891. const weekdayL$a = {
  892. 1: 'Härlighet',
  893. 2: 'Skönhet',
  894. 3: 'Fullkomlighet',
  895. 4: 'Nåd',
  896. 5: 'Rättvisa',
  897. 6: 'Majestät',
  898. 7: 'Oberoende',
  899. };
  900. const BE$a = 'B.E.';
  901. const badiCalendar$a = 'Badí‘kalendern';
  902. var sv = /*#__PURE__*/Object.freeze({
  903. __proto__: null,
  904. monthL: monthL$a,
  905. holyDay: holyDay$a,
  906. weekdayL: weekdayL$a,
  907. BE: BE$a,
  908. badiCalendar: badiCalendar$a
  909. });
  910. const month$4 = {
  911. 1: '巴哈',
  912. 2: '贾拉勒',
  913. 3: '贾迈勒',
  914. 4: '阿泽迈特',
  915. 5: '努尔',
  916. 6: '拉赫迈特',
  917. 7: '凯利马特',
  918. 8: '卡迈勒',
  919. 9: '艾斯玛',
  920. 10: '伊扎特',
  921. 11: '迈希耶特',
  922. 12: '伊勒姆',
  923. 13: '古德雷特',
  924. 14: '高勒',
  925. 15: '迈萨伊勒',
  926. 16: '谢拉夫',
  927. 17: '苏丹',
  928. 18: '穆勒克',
  929. 19: '阿拉',
  930. 20: '阿亚米哈',
  931. };
  932. const monthL$b = {
  933. 1: '耀',
  934. 2: '辉',
  935. 3: '美',
  936. 4: '宏',
  937. 5: '光',
  938. 6: '仁',
  939. 7: '言',
  940. 8: '完',
  941. 9: '名',
  942. 10: '能',
  943. 11: '意',
  944. 12: '知',
  945. 13: '力',
  946. 14: '语',
  947. 15: '问',
  948. 16: '尊',
  949. 17: '权',
  950. 18: '统',
  951. 19: '崇',
  952. 20: '哈之日',
  953. };
  954. const holyDay$b = {
  955. 1: '诺鲁孜节',
  956. 2: '里兹万节第一日',
  957. 3: '里兹万节第九日',
  958. 4: '里兹万节第十二日',
  959. 5: '巴孛宣示日',
  960. 6: '巴哈欧拉升天日',
  961. 7: '巴孛殉道日',
  962. 8: '巴孛诞辰',
  963. 9: '巴哈欧拉诞辰',
  964. 10: '圣约日',
  965. 11: '阿博都-巴哈升天日',
  966. };
  967. const weekday$4 = {
  968. 1: '贾拉勒',
  969. 2: '贾迈勒',
  970. 3: '卡迈勒',
  971. 4: '菲达勒',
  972. 5: '伊达勒',
  973. 6: '伊斯提杰拉勒',
  974. 7: '伊斯提格拉勒',
  975. };
  976. const weekdayAbbr3$4 = {
  977. 1: '贾拉勒',
  978. 2: '贾迈勒',
  979. 3: '卡迈勒',
  980. 4: '菲达勒',
  981. 5: '伊达勒',
  982. 6: '伊斯杰',
  983. 7: '伊斯格',
  984. };
  985. const weekdayAbbr2$4 = {
  986. 1: '贾拉',
  987. 2: '贾迈',
  988. 3: '卡迈',
  989. 4: '菲达',
  990. 5: '伊达',
  991. 6: '伊杰',
  992. 7: '伊格',
  993. };
  994. const weekdayL$b = {
  995. 1: '辉日',
  996. 2: '美日',
  997. 3: '完日',
  998. 4: '恩日',
  999. 5: '正日',
  1000. 6: '威日',
  1001. 7: '独日',
  1002. };
  1003. const yearInVahid$4 = {
  1004. 1: '艾利夫',
  1005. 2: '巴',
  1006. 3: '艾卜',
  1007. 4: '达勒',
  1008. 5: '巴卜',
  1009. 6: '瓦乌',
  1010. 7: '阿巴德',
  1011. 8: '贾德',
  1012. 9: '巴哈',
  1013. 10: '胡卜',
  1014. 11: '巴哈杰',
  1015. 12: '贾瓦卜',
  1016. 13: '阿哈德',
  1017. 14: '瓦哈卜',
  1018. 15: '维达德',
  1019. 16: '巴迪',
  1020. 17: '巴希',
  1021. 18: '阿卜哈',
  1022. 19: '瓦希德',
  1023. };
  1024. const vahid$4 = '瓦希德';
  1025. const kulliShay$4 = '库里沙伊';
  1026. const BE$b = 'BE';
  1027. const badiCalendar$b = '巴迪历';
  1028. var zh = /*#__PURE__*/Object.freeze({
  1029. __proto__: null,
  1030. month: month$4,
  1031. monthL: monthL$b,
  1032. holyDay: holyDay$b,
  1033. weekday: weekday$4,
  1034. weekdayAbbr3: weekdayAbbr3$4,
  1035. weekdayAbbr2: weekdayAbbr2$4,
  1036. weekdayL: weekdayL$b,
  1037. yearInVahid: yearInVahid$4,
  1038. vahid: vahid$4,
  1039. kulliShay: kulliShay$4,
  1040. BE: BE$b,
  1041. badiCalendar: badiCalendar$b
  1042. });
  1043. const monthL$c = {
  1044. 1: 'Splendor',
  1045. 16: 'Honor',
  1046. };
  1047. var en_us = /*#__PURE__*/Object.freeze({
  1048. __proto__: null,
  1049. monthL: monthL$c
  1050. });
  1051. /* eslint-disable dot-notation, line-comment-position, camelcase, sort-imports */
  1052. const badiLocale = { en, ar, de, es, fa, fr, lv, nl, pt, ru, sv, zh, 'en-us': en_us, default: en };
  1053. const setDefaultLanguage = (language) => {
  1054. if (badiLocale[language] === undefined) {
  1055. // eslint-disable-next-line no-console
  1056. console.log('Chosen language does not exist. Setting has not been changed.');
  1057. }
  1058. else {
  1059. badiLocale['default'] = badiLocale[language];
  1060. }
  1061. };
  1062. let underlineFormat = 'css';
  1063. const setUnderlineFormat = (format) => {
  1064. if (['css', 'u', 'diacritic', 'none'].includes(format)) {
  1065. underlineFormat = format;
  1066. }
  1067. else {
  1068. // eslint-disable-next-line no-console
  1069. console.log('Invalid underline format. Choose one of ["css", "u", "diacritic", "none"]. ' +
  1070. 'Setting has not been changed.');
  1071. }
  1072. };
  1073. const formatTokens = [
  1074. ['DDL', 'DD+', 'MML', 'MM+', 'WWL', 'yyv', 'KiS'],
  1075. ['dd', 'DD', 'mm', 'MM', 'ww', 'WW', 'yv', 'YV', 'vv', 'kk', 'yy', 'BE', 'BC', 'Va'],
  1076. ['d', 'D', 'm', 'M', 'W', 'v', 'k', 'y']
  1077. ];
  1078. // eslint-disable-next-line complexity
  1079. const formatBadiDate = (badiDate, formatString, language) => {
  1080. if (!badiDate.isValid) {
  1081. return 'Not a valid Badí‘ date';
  1082. }
  1083. if (typeof language === 'string' && badiLocale[language] === undefined && language.includes('-')) {
  1084. language = language.split('-')[0];
  1085. }
  1086. if (language === undefined || badiLocale[language] === undefined) {
  1087. language = 'default';
  1088. }
  1089. formatString = formatString !== null && formatString !== void 0 ? formatString : formatItemFallback(language, 'defaultFormat');
  1090. let formattedDate = '';
  1091. const length = formatString.length;
  1092. for (let i = 0; i < length; i++) {
  1093. // Text wrapped in {} is output as-is. A '{' without a matching '}'
  1094. // results in invalid input
  1095. if (formatString[i] === '{' && i < length - 1) {
  1096. for (let j = i + 1; j <= length; j++) {
  1097. if (j === length) {
  1098. return 'Invalid formatting string.';
  1099. }
  1100. if (formatString[j] === '}') {
  1101. i = j;
  1102. break;
  1103. }
  1104. formattedDate += formatString[j];
  1105. }
  1106. }
  1107. else {
  1108. const next1 = formatString[i];
  1109. const next2 = next1 + formatString[i + 1];
  1110. const next3 = next2 + formatString[i + 2];
  1111. if (formatTokens[0].includes(next3)) {
  1112. formattedDate += getFormatItem(badiDate, next3, language);
  1113. i += 2;
  1114. }
  1115. else if (formatTokens[1].includes(next2)) {
  1116. formattedDate += getFormatItem(badiDate, next2, language);
  1117. i += 1;
  1118. }
  1119. else if (formatTokens[2].includes(next1)) {
  1120. formattedDate += getFormatItem(badiDate, next1, language);
  1121. }
  1122. else {
  1123. formattedDate += next1;
  1124. }
  1125. }
  1126. }
  1127. return formattedDate;
  1128. };
  1129. // eslint-disable-next-line complexity
  1130. const getFormatItem = (badiDate, token, language) => {
  1131. switch (token) {
  1132. // Single character tokens
  1133. case 'd':
  1134. return digitRewrite(badiDate.day, language);
  1135. case 'D':
  1136. return postProcessLocaleItem(formatItemFallback(language, 'month', badiDate.day), 3);
  1137. case 'm':
  1138. return digitRewrite(badiDate.month, language);
  1139. case 'M':
  1140. return postProcessLocaleItem(formatItemFallback(language, 'month', badiDate.month), 3);
  1141. case 'W':
  1142. return formatItemFallback(language, 'weekdayAbbr3', (badiDate.gregorianDate.weekday + 1) % 7 + 1);
  1143. case 'y':
  1144. return digitRewrite(badiDate.year, language);
  1145. case 'v':
  1146. return digitRewrite((Math.floor((badiDate.year - 1) / 19) % 19) + 1, language);
  1147. case 'k':
  1148. return digitRewrite(Math.floor((badiDate.year - 1) / 361) + 1, language);
  1149. // Two character tokens
  1150. case 'dd':
  1151. return digitRewrite((`0${String(badiDate.day)}`).slice(-2), language);
  1152. case 'DD':
  1153. return postProcessLocaleItem(formatItemFallback(language, 'month', badiDate.day));
  1154. case 'mm':
  1155. return digitRewrite((`0${String(badiDate.month)}`).slice(-2), language);
  1156. case 'MM':
  1157. return postProcessLocaleItem(formatItemFallback(language, 'month', badiDate.month));
  1158. case 'ww':
  1159. return formatItemFallback(language, 'weekdayAbbr2', (badiDate.gregorianDate.weekday + 1) % 7 + 1);
  1160. case 'WW':
  1161. return formatItemFallback(language, 'weekday', (badiDate.gregorianDate.weekday + 1) % 7 + 1);
  1162. case 'yy':
  1163. return digitRewrite((`00${String(badiDate.year)}`).slice(-3), language);
  1164. case 'yv':
  1165. return digitRewrite((badiDate.year - 1) % 19 + 1, language);
  1166. case 'YV':
  1167. return formatItemFallback(language, 'yearInVahid', (badiDate.year - 1) % 19 + 1);
  1168. case 'vv':
  1169. return digitRewrite((`0${String((Math.floor((badiDate.year - 1) / 19) + 2) % 19 - 1)}`).slice(-2), language);
  1170. case 'kk':
  1171. return digitRewrite((`0${String(Math.floor((badiDate.year - 1) / 361) + 1)}`).slice(-2), language);
  1172. case 'Va':
  1173. return formatItemFallback(language, 'vahid');
  1174. case 'BE':
  1175. return formatItemFallback(language, 'BE');
  1176. case 'BC':
  1177. return formatItemFallback(language, 'badiCalendar');
  1178. // Three character tokens
  1179. case 'DDL':
  1180. return formatItemFallback(language, 'monthL', badiDate.day);
  1181. case 'DD+': {
  1182. const day = postProcessLocaleItem(formatItemFallback(language, 'month', badiDate.day));
  1183. const dayL = formatItemFallback(language, 'monthL', badiDate.day);
  1184. if (day === dayL) {
  1185. return day;
  1186. }
  1187. if (badiLocale[language] === badiLocale.fa) {
  1188. return `<span dir="rtl">${day} (${dayL})</span>`;
  1189. }
  1190. return `${day} (${dayL})`;
  1191. }
  1192. case 'MML':
  1193. return formatItemFallback(language, 'monthL', badiDate.month);
  1194. case 'MM+': {
  1195. const month = postProcessLocaleItem(formatItemFallback(language, 'month', badiDate.month));
  1196. const monthL = formatItemFallback(language, 'monthL', badiDate.month);
  1197. if (month === monthL) {
  1198. return month;
  1199. }
  1200. if (badiLocale[language] === badiLocale.fa) {
  1201. return `<span dir="rtl">${month} (${monthL})</span>`;
  1202. }
  1203. return `${month} (${monthL})`;
  1204. }
  1205. case 'WWL':
  1206. return formatItemFallback(language, 'weekdayL', (badiDate.gregorianDate.weekday + 1) % 7 + 1);
  1207. case 'yyv':
  1208. return digitRewrite((`0${String((badiDate.year - 1) % 19 + 1)}`).slice(-2), language);
  1209. case 'KiS':
  1210. return postProcessLocaleItem(formatItemFallback(language, 'kulliShay'));
  1211. // istanbul ignore next
  1212. default:
  1213. return '';
  1214. }
  1215. };
  1216. const postProcessLocaleItem = (item, crop) => {
  1217. if (crop && crop < item.length) {
  1218. let char = 0;
  1219. let counter = 0;
  1220. while (counter < crop) {
  1221. if (!'_’‘'.includes(item[char])) {
  1222. counter++;
  1223. }
  1224. char++;
  1225. }
  1226. if ('_’‘'.includes(item[char])) {
  1227. char++;
  1228. }
  1229. item = item.slice(0, char);
  1230. if (item.split('_').length % 2 === 0) {
  1231. item += '_';
  1232. }
  1233. }
  1234. const stringComponents = item.split('_');
  1235. for (let i = 1; i < stringComponents.length; i += 2) {
  1236. stringComponents[i] = underlineString(stringComponents[i]);
  1237. }
  1238. return stringComponents.join('');
  1239. };
  1240. const underlineString = (str) => {
  1241. switch (underlineFormat) {
  1242. case 'css':
  1243. return `<span style="text-decoration:underline">${str}</span>`;
  1244. case 'diacritic':
  1245. return str.split('').map(char => `${char}\u0332`).join('');
  1246. case 'u':
  1247. return `<u>${str}</u>`;
  1248. case 'none':
  1249. return str;
  1250. // istanbul ignore next
  1251. default:
  1252. throw new TypeError('Unexpected underlineFormat');
  1253. }
  1254. };
  1255. const digitRewrite = (number, language) => {
  1256. number = String(number);
  1257. const unicodeOffset = formatItemFallback(language, 'unicodeCharForZero').charCodeAt(0) - '0'.charCodeAt(0);
  1258. if (unicodeOffset === 0) {
  1259. return number;
  1260. }
  1261. const codePoints = [...number].map(num => num.charCodeAt(0) + unicodeOffset);
  1262. return String.fromCharCode(...codePoints);
  1263. };
  1264. const formatItemFallback = (language, category, index) => {
  1265. var _a;
  1266. if (index === undefined) {
  1267. while (badiLocale[language][category] === undefined) {
  1268. language = languageFallback(language);
  1269. }
  1270. return badiLocale[language][category];
  1271. }
  1272. while (((_a = badiLocale[language][category]) === null || _a === void 0 ? void 0 : _a[index]) === undefined) {
  1273. language = languageFallback(language);
  1274. }
  1275. return badiLocale[language][category][index];
  1276. };
  1277. const languageFallback = (languageCode) => {
  1278. if (languageCode.includes('-')) {
  1279. return languageCode.split('-')[0];
  1280. // eslint-disable-next-line no-negated-condition
  1281. }
  1282. else if (languageCode !== 'default') {
  1283. return 'default';
  1284. }
  1285. return 'en';
  1286. };
  1287. const badiYears = [
  1288. 'l4da', 'k4ci', 'k5c7', 'l4d6', 'l4ce', 'k4c4', 'k5d4', 'l4cb', 'l4c1', 'k4cj', 'k5c8', 'l4d7', 'l4cf', 'k4c5',
  1289. 'k4d5', 'k5ce', 'l4c2', 'k4d2', 'k4ca', 'k5da', 'l4ch', 'k4c6', 'k4d6', 'k5cf', 'l4c4', 'k4d4', 'k4cc', 'k5c1',
  1290. 'l4cj', 'k4c8', 'k4d8', 'k5cg', 'l4c5', 'k4d5', 'k4ce', 'k5c3', 'l4d2', 'k4ca', 'k4d9', 'k5ci', 'l4c6', 'k4d6',
  1291. 'k4cf', 'k4c4', 'k5d4', 'k4cb', 'k4bj', 'k4cj', 'k5c9', 'k4d8', 'k4cg', 'k4c6', 'k5d6', 'k4cd', 'k4c2', 'k4d2',
  1292. 'k5ca', 'k4d9', 'k4ci', 'k4c7', 'k5d7', 'k4cf', 'k4c4', 'k4d4', 'k5cc', 'k4bj', 'k4cj', 'k4c9', 'k5d9', 'k4cg',
  1293. 'k4c6', 'k4d5', 'k5cd', 'k4c2', 'k4d1', 'k4ca', 'k4da', 'j5cj', 'k4c7', 'k4d7', 'k4cf', 'j5c4', 'k4d3', 'k4cb',
  1294. 'k4c1', 'k5d1', 'l4c9', 'l4d9', 'l4ch', 'k5c6', 'l4d5', 'l4cd', 'l4c2', 'k5d2', 'l4ca', 'l4da', 'l4cj', 'k5c8',
  1295. 'l4d7', 'l4cf', 'l4c4', 'k5d4', 'l4cb', 'l4c1', 'l4d1', 'k5c9', 'l4d8', 'l4cg', 'l4c5', 'k4d5', 'k5ce', 'l4c2',
  1296. 'l4d2', 'k4cb', 'k5db', 'l4ci', 'l4c7', 'k4d7', 'k5cf', 'l4c4', 'l4d4', 'k4cc', 'k5c2', 'l4d1', 'l4c9', 'k4d9',
  1297. 'k5ch', 'l4c5', 'l4d5', 'k4ce', 'k5c3', 'l4d2', 'l4cb', 'k4da', 'k5ci', 'l4c6', 'l4d6', 'k4cf', 'k5c5', 'l4d4',
  1298. 'l4cc', 'k4c1', 'k4d1', 'k5c9', 'l4d8', 'k4cg', 'k4c6', 'k5d6', 'l4ce', 'k4c3', 'k4d3', 'k5cb', 'l4da', 'k4ci',
  1299. 'k4c7', 'k5d7', 'l4cf', 'k4c5', 'k4d5', 'k5cd', 'l4c1', 'k4cj', 'k4c9', 'k5d9', 'l4cg', 'k4c6', 'k4d6', 'k5ce',
  1300. 'l4c3', 'k4d2', 'k4ca', 'k5bj', 'l4ci', 'k4c7', 'k4d7', 'k4cg', 'k5c5', 'k4d4', 'k4cc', 'k4c1', 'k5d1', 'k4c9',
  1301. 'k4d9', 'k4ch', 'k5c7', 'l4d6', 'l4ce', 'l4c3', 'l5d3', 'l4ca', 'l4da', 'l4cj', 'l5c8', 'l4d7', 'l4cg', 'l4c5',
  1302. 'l5d4', 'l4cb', 'l4c1', 'l4d1', 'l5ca', 'l4d9', 'l4ch', 'l4c6', 'l5d6', 'l4cd', 'l4c2', 'l4d2', 'l4cb', 'k5c1',
  1303. 'l4cj', 'l4c8', 'l4d8', 'k5cg', 'l4c4', 'l4d4', 'l4cc', 'k5c2', 'l4d1', 'l4ca', 'l4da', 'k5ci', 'l4c6', 'l4d5',
  1304. 'l4ce', 'k5c3', 'l4d2', 'l4cb', 'l4db', 'k5cj', 'l4c8', 'l4d7', 'l4cf', 'k5c5', 'l4d4', 'l4cc', 'l4c2', 'k5d2',
  1305. 'l4c9', 'l4d9', 'l4ch', 'k4c6', 'k5d6', 'l4ce', 'l4c3', 'k4d3', 'k5cc', 'l4db', 'l4cj', 'k4c8', 'k5d8', 'l4cf',
  1306. 'l4c4', 'k4d5', 'k5cd', 'l4c2', 'l4d2', 'k4ca', 'k5d9', 'l4cg', 'l4c6', 'k4d6', 'k5cf', 'l4c3', 'l4d3', 'k4cb',
  1307. 'k5bj', 'l4ci', 'l4c7', 'k4d7', 'k5cg', 'l4c5', 'l4d5', 'k4cd', 'k4c2', 'k5d2', 'l4c9', 'k4d9', 'k4ch', 'k5c7',
  1308. 'l4d6', 'k4cf', 'k4c4', 'k5d4', 'l4cb', 'l4bj', 'l4cj', 'l5c8', 'm4d7', 'l4cg', 'l4c5', 'l5d5', 'm4cc', 'l4c1',
  1309. 'l4d1', 'l5ca', 'm4d9', 'l4ch', 'l4c7', 'l5d7', 'm4ce', 'l4c3', 'l4d3', 'l5cb', 'm4bi', 'l4ci', 'l4c8', 'l4d8',
  1310. 'l5ch', 'l4c5', 'l4d5', 'l4cd', 'l5c2', 'l4d1', 'l4c9', 'l4da', 'l5ci', 'l4c7', 'l4d7', 'l4cf', 'l5c4', 'l4d2',
  1311. 'l4cb', 'l4bj', 'l5d1', 'l4c8', 'l4d8', 'l4cg', 'l5c5', 'l4d4', 'l4cc', 'l4c2', 'l5d2', 'l4c9', 'l4da', 'l4ci',
  1312. ];
  1313. class BadiDate {
  1314. constructor(date) {
  1315. this._holyDay = undefined;
  1316. this._valid = true;
  1317. this._invalidReason = undefined;
  1318. try {
  1319. if (this._isDateObject(date)) {
  1320. this._gregorianDate = DateTime.fromObject({ year: date.getFullYear(), month: date.getMonth() + 1, day: date.getDate(), zone: 'UTC' });
  1321. }
  1322. else if (DateTime.isDateTime(date)) {
  1323. this._gregorianDate = DateTime.fromObject({ year: date.year, month: date.month, day: date.day, zone: 'UTC' });
  1324. }
  1325. else if (this._isYearMonthDay(date) || this._isYearHolyDayNumber(date)) {
  1326. this._setFromBadiDate(date);
  1327. }
  1328. else {
  1329. throw new TypeError('Unrecognized input format');
  1330. }
  1331. if (this._year === undefined) {
  1332. // We haven't set the Badí' date yet
  1333. this._setFromGregorianDate();
  1334. }
  1335. this._setHolyDay();
  1336. }
  1337. catch (err) {
  1338. this._setInvalid(err);
  1339. }
  1340. Object.freeze(this);
  1341. }
  1342. format(formatString, language) {
  1343. return formatBadiDate(this, formatString, language);
  1344. }
  1345. _isDateObject(arg) {
  1346. return Object.prototype.toString.call(arg) === '[object Date]';
  1347. }
  1348. _isYearMonthDay(arg) {
  1349. return typeof arg.year === 'number' && typeof arg.month === 'number' &&
  1350. typeof arg.day === 'number';
  1351. }
  1352. _isYearHolyDayNumber(arg) {
  1353. return typeof arg.year === 'number' && arg.month === undefined &&
  1354. arg.day === undefined && typeof arg.holyDayNumber === 'number';
  1355. }
  1356. _notInValidGregorianDateRange(datetime) {
  1357. const lowerBound = DateTime.fromObject({ year: 1844, month: 3, day: 21, zone: 'UTC' });
  1358. const upperBound = DateTime.fromObject({ year: 2351, month: 3, day: 20, zone: 'UTC' });
  1359. return datetime < lowerBound || datetime > upperBound;
  1360. }
  1361. _setFromGregorianDate() {
  1362. if (this._notInValidGregorianDateRange(this._gregorianDate)) {
  1363. throw new RangeError('Input date outside of valid range (1844-03-21 - 2351-03-20)');
  1364. }
  1365. const gregorianYear = this._gregorianDate.year;
  1366. const oldImplementationCutoff = DateTime.fromObject({ year: 2015, month: 3, day: 21, zone: 'UTC' });
  1367. if (this._gregorianDate < oldImplementationCutoff) {
  1368. const { month, day } = this._gregorianDate;
  1369. if (month < 3 || (month === 3 && day < 21)) {
  1370. this._nawRuz = DateTime.fromObject({ year: gregorianYear - 1, month: 3, day: 21, zone: 'UTC' });
  1371. this._year = gregorianYear - 1844;
  1372. }
  1373. else {
  1374. this._nawRuz = DateTime.fromObject({ year: gregorianYear, month: 3, day: 21, zone: 'UTC' });
  1375. this._year = gregorianYear - 1843;
  1376. }
  1377. this._setOldAyyamiHaLength();
  1378. this._yearTwinBirthdays = [12, 5, 13, 9];
  1379. }
  1380. else {
  1381. this._year = gregorianYear - 1843;
  1382. this._setBadiYearInfo(true);
  1383. }
  1384. this._setBadiMonthAndDay();
  1385. }
  1386. /**
  1387. * Set Badí' month and day from Gregorian date
  1388. */
  1389. _setBadiMonthAndDay() {
  1390. const dayOfBadiYear = this._dayOfYear(this._gregorianDate);
  1391. if (dayOfBadiYear < 343) {
  1392. this._month = Math.floor((dayOfBadiYear - 1) / 19 + 1);
  1393. this._day = (dayOfBadiYear - 1) % 19 + 1;
  1394. }
  1395. else if (dayOfBadiYear < 343 + this._ayyamiHaLength) {
  1396. this._month = 20;
  1397. this._day = dayOfBadiYear - 342;
  1398. }
  1399. else {
  1400. this._month = 19;
  1401. this._day = dayOfBadiYear - (342 + this._ayyamiHaLength);
  1402. }
  1403. }
  1404. _setFromBadiDate(date) {
  1405. this._year = date.year;
  1406. if (this._year < 1 || this._year > 507) {
  1407. throw new RangeError('Input date outside of valid range (1 - 507 B.E.)');
  1408. }
  1409. else if (this._year < 172) {
  1410. this._nawRuz = DateTime.fromObject({ year: 1843 + this._year, month: 3, day: 21, zone: 'UTC' });
  1411. this._setOldAyyamiHaLength();
  1412. this._yearTwinBirthdays = [12, 5, 13, 9];
  1413. }
  1414. else {
  1415. this._setBadiYearInfo();
  1416. }
  1417. if (this._isYearMonthDay(date)) {
  1418. this._month = date.month;
  1419. this._day = date.day;
  1420. if (this._month === 20 && this._day > this._ayyamiHaLength) {
  1421. // If only off by one day, we'll bubble up so that 5th Ayyám-i-Há in a year with only 4 days of
  1422. // Ayyám-i-Há can be salvaged
  1423. if (this._day - this._ayyamiHaLength === 1) {
  1424. this._month = 19;
  1425. this._day = 1;
  1426. }
  1427. else {
  1428. throw new TypeError('Input numbers do not designate a valid date');
  1429. }
  1430. }
  1431. if (this._month < 1 || this._month > 20 || this._day < 1 || this.day > 19) {
  1432. throw new TypeError('Input numbers do not designate a valid date');
  1433. }
  1434. }
  1435. else {
  1436. if (date.holyDayNumber < 1 || date.holyDayNumber > 11) {
  1437. throw new TypeError('Input numbers do not designate a valid Holy Day');
  1438. }
  1439. this._holyDay = date.holyDayNumber;
  1440. [this._month, this._day] = this._holyDayMapping()[this._holyDay];
  1441. }
  1442. this._gregorianDate = this._nawRuz.plus(Duration.fromObject({ days: this._dayOfYear([this._year, this._month, this._day]) - 1 }));
  1443. }
  1444. _setOldAyyamiHaLength() {
  1445. if (DateTime.fromObject({ year: this._nawRuz.year + 1 }).isInLeapYear) {
  1446. this._ayyamiHaLength = 5;
  1447. }
  1448. else {
  1449. this._ayyamiHaLength = 4;
  1450. }
  1451. }
  1452. _setBadiYearInfo(fromGregorianDate = false) {
  1453. let yearData = this._extractBadiYearInfo();
  1454. if (fromGregorianDate && this._gregorianDate < yearData.nawRuz) {
  1455. this._year -= 1;
  1456. yearData = this._extractBadiYearInfo();
  1457. }
  1458. this._nawRuz = yearData.nawRuz;
  1459. this._ayyamiHaLength = yearData.ayyamiHaLength;
  1460. this._yearTwinBirthdays = yearData.twinBirthdays;
  1461. }
  1462. _extractBadiYearInfo() {
  1463. let nawRuz, ayyamiHaLength, twinBirthdays;
  1464. // Check whether data needs to be unpacked or exists in the verbose version
  1465. // istanbul ignore else
  1466. if (badiYears[0] === 'l4da') {
  1467. const components = badiYears[this._year - 172].split('');
  1468. nawRuz = DateTime.fromObject({ year: this._year - 172 + 2015, month: 3, day: parseInt(components[0], 36), zone: 'UTC' });
  1469. ayyamiHaLength = parseInt(components[1], 36);
  1470. const TB1 = [parseInt(components[2], 36), parseInt(components[3], 36)];
  1471. const TB2 = TB1[1] < 19 ? [TB1[0], TB1[1] + 1] : [TB1[0] + 1, 1];
  1472. twinBirthdays = [TB1[0], TB1[1], TB2[0], TB2[1]];
  1473. }
  1474. else {
  1475. ({ nawRuz, ayyamiHaLength, twinBirthdays } = badiYears[this._year]);
  1476. nawRuz = DateTime.fromISO(nawRuz, { zone: 'UTC' });
  1477. }
  1478. return { nawRuz, ayyamiHaLength, twinBirthdays };
  1479. }
  1480. _dayOfYear(date) {
  1481. // Naw-Rúz is day 1
  1482. if (Array.isArray(date)) {
  1483. // We have a Badí' date
  1484. if (date[1] < 19) {
  1485. return 19 * (date[1] - 1) + date[2];
  1486. }
  1487. else if (date[1] === 20) {
  1488. return 342 + date[2];
  1489. }
  1490. // date[1] === 19
  1491. return 342 + this._ayyamiHaLength + date[2];
  1492. }
  1493. return date.diff(this._nawRuz).as('days') + 1;
  1494. }
  1495. _setInvalid(invalidReason) {
  1496. this._gregorianDate = DateTime.invalid('Not a valid Badí‘ date');
  1497. this._year = NaN;
  1498. this._month = NaN;
  1499. this._day = NaN;
  1500. this._ayyamiHaLength = NaN;
  1501. this._nawRuz = DateTime.invalid('Not a valid Badí‘ date');
  1502. this._valid = false;
  1503. this._invalidReason = invalidReason;
  1504. }
  1505. _setHolyDay() {
  1506. const mapping = this._holyDayMapping();
  1507. this._holyDay = parseInt(Object.keys(mapping)
  1508. .find(key => mapping[key][0] === this._month && mapping[key][1] === this._day), 10);
  1509. }
  1510. _holyDayMapping() {
  1511. return {
  1512. [1 /* NawRuz */]: [1, 1],
  1513. [2 /* FirstRidvan */]: [2, 13],
  1514. [3 /* NinthRidvan */]: [3, 2],
  1515. [4 /* TwelfthRidvan */]: [3, 5],
  1516. [5 /* DeclarationOfTheBab */]: [4, this._year < 172 ? 7 : 8],
  1517. [6 /* AscensionOfBahaullah */]: [4, 13],
  1518. [7 /* MartyrdomOfTheBab */]: [6, this._year < 172 ? 16 : 17],
  1519. [8 /* BirthOfTheBab */]: [this._yearTwinBirthdays[0], this._yearTwinBirthdays[1]],
  1520. [9 /* BirthOfBahaullah */]: [this._yearTwinBirthdays[2], this._yearTwinBirthdays[3]],
  1521. [10 /* DayOfTheCovenant */]: [14, 4],
  1522. [11 /* AscensionOfAbdulBaha */]: [14, 6],
  1523. };
  1524. }
  1525. _leapYearsBefore() {
  1526. let leapYearsBefore = Math.floor(Math.min(this.year - 1, 171) / 4);
  1527. if (this.year > 172) {
  1528. // istanbul ignore else
  1529. if (badiYears[0] === 'l4da') {
  1530. leapYearsBefore += badiYears.slice(0, this.year - 172).filter(entry => entry[1] === '5').length;
  1531. }
  1532. else {
  1533. leapYearsBefore += Object.entries(badiYears)
  1534. .filter(([year, data]) => parseInt(year, 10) < this.year &&
  1535. data.ayyamiHaLength === 5).length;
  1536. }
  1537. }
  1538. return leapYearsBefore;
  1539. }
  1540. holyDay(language = undefined) {
  1541. if (!this._holyDay) {
  1542. return '';
  1543. }
  1544. if (language === undefined || badiLocale[language] === undefined) {
  1545. language = 'default';
  1546. }
  1547. return formatItemFallback(language, 'holyDay', this._holyDay);
  1548. }
  1549. valueOf() {
  1550. return this._dayOfYear([this.year, this.month, this.day]) + this._leapYearsBefore() + (this.year - 1) * 365;
  1551. }
  1552. equals(other) {
  1553. return this.isValid && other.isValid && this.valueOf() === other.valueOf();
  1554. }
  1555. get isValid() {
  1556. return this._valid;
  1557. }
  1558. get invalidReason() {
  1559. return this._invalidReason;
  1560. }
  1561. get day() {
  1562. return this._day;
  1563. }
  1564. get month() {
  1565. return this._month;
  1566. }
  1567. get year() {
  1568. return this._year;
  1569. }
  1570. // number of the Badí' weekday between 1 (Jalál ~> Saturday) and 7 (Istiqlál ~> Friday).
  1571. get weekday() {
  1572. return (this._gregorianDate.weekday + 1) % 7 + 1;
  1573. }
  1574. get yearInVahid() {
  1575. return (this._year - 1) % 19 + 1;
  1576. }
  1577. get vahid() {
  1578. return (Math.floor((this._year - 1) / 19) % 19) + 1;
  1579. }
  1580. get kullIShay() {
  1581. return Math.floor((this._year - 1) / 361) + 1;
  1582. }
  1583. // Gregorian date on whose sunset the Badí' date ends.
  1584. get gregorianDate() {
  1585. return this._gregorianDate;
  1586. }
  1587. get ayyamiHaLength() {
  1588. return this._ayyamiHaLength;
  1589. }
  1590. get holyDayNumber() {
  1591. return this._holyDay ? this._holyDay : undefined;
  1592. }
  1593. get workSuspended() {
  1594. return this._holyDay ? this.holyDayNumber < 10 : undefined;
  1595. }
  1596. get nextMonth() {
  1597. let { year, month } = this;
  1598. switch (month) {
  1599. case 18:
  1600. month = 20;
  1601. break;
  1602. case 19:
  1603. month = 1;
  1604. year += 1;
  1605. break;
  1606. case 20:
  1607. month = 19;
  1608. break;
  1609. default:
  1610. month += 1;
  1611. }
  1612. return new BadiDate({ year, month, day: 1 });
  1613. }
  1614. get previousMonth() {
  1615. let { year, month } = this;
  1616. switch (month) {
  1617. case 1:
  1618. month = 19;
  1619. year -= 1;
  1620. break;
  1621. case 19:
  1622. month = 20;
  1623. break;
  1624. case 20:
  1625. month = 18;
  1626. break;
  1627. default:
  1628. month -= 1;
  1629. }
  1630. return new BadiDate({ year, month, day: 1 });
  1631. }
  1632. get nextDay() {
  1633. if (this._day === 19 || (this._month === 20 && this._day === this._ayyamiHaLength)) {
  1634. return this.nextMonth;
  1635. }
  1636. return new BadiDate({ year: this._year, month: this._month, day: this._day + 1 });
  1637. }
  1638. get previousDay() {
  1639. if (this._day === 1) {
  1640. const { previousMonth } = this;
  1641. let day = 19;
  1642. if (this._month === 19) {
  1643. day = this._ayyamiHaLength;
  1644. }
  1645. return new BadiDate({
  1646. year: previousMonth.year,
  1647. month: previousMonth.month,
  1648. day,
  1649. });
  1650. }
  1651. return new BadiDate({ year: this._year, month: this._month, day: this._day - 1 });
  1652. }
  1653. }
  1654. const badiDateSettings = (settings) => {
  1655. if (settings.defaultLanguage) {
  1656. setDefaultLanguage(settings.defaultLanguage);
  1657. }
  1658. if (settings.underlineFormat) {
  1659. setUnderlineFormat(settings.underlineFormat);
  1660. }
  1661. };
  1662. /* eslint-disable max-len, complexity */
  1663. const clockLocations = {
  1664. Canada: [[[-63.29333, 60], [-138.9386, 60], [-139.1889, 60.08888], [-139.0681, 60.35222], [-139.6767, 60.34055], [-139.9794, 60.18777], [-140.45081, 60.30972], [-140.52139, 60.22221], [-140.9955, 60.30721], [-140.99686, 61.8948], [-141.00005, 65.84028], [-141.00206, 68.42821], [-141.00296, 69.58786], [-141.00477, 69.58884], [-140.99813, 70.12335], [-124.80692, 77.04204], [-117.95462, 78.95431], [-99.46935, 82.3539], [-75.0348, 84.79736], [-59.3117, 83.84122], [-60.98493, 82.07503], [-69.57686, 80.21588], [-71.1173, 79.6183], [-74.13178, 79.24647], [-73.93259, 78.5692], [-75.69878, 77.78571], [-77.43842, 77.49355], [-77.55793, 76.52414], [-78.54063, 76.17887], [-79.31085, 74.25332], [-75.79174, 73.25735], [-73.13581, 72.0489], [-69.1652, 71.09276], [-66.31007, 69.91087], [-66.05776, 68.70243], [-60.73262, 66.89639], [-62.3129, 65.07708], [-63.60102, 64.69197], [-64.19861, 60.84087], [-63.29333, 60.00012]]],
  1665. Finland: [[[31.5848296, 62.9070356], [31.4390606, 62.785375], [31.3454013, 62.64032620000001], [31.2218346, 62.49829550000001], [31.138311, 62.4420838], [30.720412, 62.20890580000002], [30.6564061, 62.2085877], [30.602068, 62.14134890000001], [30.4231749, 62.02237140000001], [30.3061104, 61.964546], [30.1556605, 61.8579888], [30.0752371, 61.8183646], [30.0387281, 61.76500110000001], [29.8185491, 61.6549278], [29.74029919999999, 61.5737044], [29.5030724, 61.461338900000015], [29.3304371, 61.3526198], [29.2330501, 61.268169], [29.0298879, 61.191815300000016], [28.9583837, 61.1514492], [28.818984, 61.1216471], [28.7136921, 61.0443349], [28.6578963, 60.95109439999999], [28.5246697, 60.9571371], [28.1354613, 60.7408695], [27.873414, 60.604559], [27.7736111, 60.53333330000002], [27.725, 60.3913889], [27.4550934, 60.223534], [27.2938862, 60.2003975], [26.8756332, 60.200342100000015], [26.6110136, 60.161753200000014], [26.2947105, 60.0465237], [26.0173046, 59.97679690000001], [25.1693516, 59.9434386], [24.2815873, 59.79155570000002], [23.4566746, 59.67247360000001], [22.9224144, 59.6384411], [22.6345729, 59.6079549], [22.3965563, 59.5130947], [21.4475658, 59.4772985], [20.7608658, 59.5324815], [20.3839584, 59.4576178], [20.2843364, 59.4660819], [19.083209799999988, 60.19169020000001], [19.2202109, 60.61151010000001], [20.0251664, 60.72755450000001], [20.7714495, 61.12690790000001], [20.903203, 61.6462488], [20.1658123, 63.1648577], [20.4010006, 63.3318822], [20.8175143, 63.5011379], [21.4628083, 63.6552312], [21.8845783, 63.70121190000001], [22.9611467, 64.2200974], [23.835799, 64.66547409999997], [24.1545056, 65.29247769999998], [24.131900100000014, 65.5153846], [24.1776819, 65.6603564], [24.1318042, 65.7716089], [24.152978, 65.862572], [24.0536762, 65.95152940000006], [24.0491701, 65.99502970000003], [23.9394784, 66.07568309999998], [23.9170552, 66.16186640000002], [23.7313763, 66.19408560000002], [23.6489848, 66.30377249999997], [23.6880374, 66.3815611], [23.650965700000015, 66.4557476], [23.8605347, 66.5595503], [23.86853209999999, 66.6568254], [23.9078441, 66.72140390000003], [23.880337, 66.76350940000003], [23.99566289999999, 66.822049], [23.8525565, 66.9573479], [23.677678, 67.0620298], [23.5545444, 67.16789390000002], [23.596079, 67.20820560000003], [23.5637833, 67.2606725], [23.7311639, 67.28763560000003], [23.7172209, 67.38530669999997], [23.7639366, 67.42772120000002], [23.408239899999984, 67.46939490000003], [23.4059159, 67.50091320000003], [23.5452477, 67.5838871], [23.492249099999984, 67.6652745], [23.47871239999999, 67.8419848], [23.5171915, 67.88433529999998], [23.6407972, 67.9151784], [23.6525654, 67.9589433], [23.3937061, 68.0452571], [23.3077618, 68.14837649999997], [23.1656349, 68.13315060000002], [23.152641, 68.2333806], [23.0702517, 68.29970360000003], [22.9181313, 68.3335115], [22.8028778, 68.39328420000002], [22.3437523, 68.45688960000003], [22.2960914, 68.4840408], [22.045040799999988, 68.479329], [21.8898693, 68.5844051], [21.7010887, 68.59686950000003], [21.6061629, 68.6678769], [21.4298688, 68.691352], [21.39042, 68.76478960000003], [20.9988391, 68.89612380000003], [20.8441913, 68.93656440000004], [20.9116456, 68.96882420000003], [20.775042799999987, 69.0326073], [20.5523258, 69.0600767], [20.7173208, 69.1197912], [21.057543, 69.03628970000003], [21.1086742, 69.1039291], [20.9875741, 69.19192740000003], [21.0961691, 69.260912], [21.2788202, 69.3118841], [21.6270859, 69.27658829999997], [22.1757622, 68.95632440000003], [22.1918678, 68.9187737], [22.3407806, 68.82722570000003], [22.3745217, 68.71666660000004], [22.5353893, 68.74451260000004], [22.800824, 68.68754809999997], [23.0459522, 68.6893436], [23.1675822, 68.6285189], [23.4406356, 68.6921635], [23.6735202, 68.70552140000002], [23.7753915, 68.81885129999998], [23.983330799999987, 68.82714340000003], [24.0755916, 68.7799668], [24.30226, 68.71735020000003], [24.6083879, 68.6819016], [24.9170187, 68.60529109999997], [25.1193208, 68.6428308], [25.1212144, 68.7458351], [25.1573697, 68.80006390000003], [25.2931271, 68.8600372], [25.47250939999999, 68.90329120000003], [25.6543285, 68.90577049999997], [25.745596499999987, 69.03984729999998], [25.742717799999987, 69.14430209999998], [25.6939225, 69.1957144], [25.7410164, 69.31839509999998], [25.8462009, 69.3929115], [25.8084981, 69.4259367], [25.8768225, 69.5261298], [25.9760403, 69.610225], [25.8925512, 69.66539549999997], [26.0071395, 69.7228555], [26.1255598, 69.7345401], [26.3835888, 69.8541585], [26.4653759, 69.93980490000003], [26.6834067, 69.96301920000003], [26.8407548, 69.9603025], [27.0316081, 69.9107924], [27.3049484, 69.95762760000004], [27.43070959999999, 70.0194461], [27.5206048, 70.02243659999996], [27.614207, 70.074151], [27.9593778, 70.0921111], [27.9842853, 70.0139707], [28.160713, 69.92099370000003], [28.3452694, 69.88083179999997], [28.4042254, 69.818425], [29.1339095, 69.69534039999996], [29.1705369, 69.6390414], [29.3364956, 69.47832269999998], [29.2193395, 69.39763620000002], [28.831539, 69.2243617], [28.80543, 69.1111558], [28.929451, 69.0519407], [28.4953735, 68.9300403], [28.468076, 68.8855137], [28.66118, 68.8864737], [28.8014499, 68.8693665], [28.7072131, 68.732555], [28.4341202, 68.53979460000002], [28.6478382, 68.19591340000002], [29.3271337, 68.0745162], [29.6593888, 67.80297219999996], [30.0173409, 67.67356889999996], [29.9305102, 67.5228214], [29.8567823, 67.48926540000004], [29.6361151, 67.332861], [29.522709499999987, 67.3099172], [29.48660609999999, 67.26011490000003], [29.0732544, 66.99615390000004], [29.0331239, 66.92547219999996], [29.0607529, 66.85269279999997], [29.3507185, 66.6439171], [29.4726751, 66.5434478], [29.6969469, 66.277347], [29.9239353, 66.1262486], [29.997268, 65.97889249999997], [30.0647878, 65.90105890000002], [30.138463, 65.66868749999998], [30.0170916, 65.6965272], [29.722432799999986, 65.637045], [29.8637508, 65.5604702], [29.7331208, 65.472637], [29.7467636, 65.347391], [29.6018471, 65.2599435], [29.893525, 65.19295509999998], [29.8193446, 65.1444587], [29.896916, 65.1051579], [29.7328054, 65.09129760000003], [29.6255535, 65.06020520000003], [29.5993537, 64.99509809999998], [29.6470353, 64.8674467], [29.739663, 64.7897553], [30.0430007, 64.7928625], [30.0416232, 64.74110840000003], [30.1365729, 64.6488835], [29.9894058, 64.58761530000002], [29.9869609, 64.5338998], [30.0583348, 64.4508749], [30.0448933, 64.4020122], [30.482439699999983, 64.2623385], [30.466399899999985, 64.2044319], [30.5534271, 64.1322443], [30.5280169, 64.0488769], [30.320039, 63.9082685], [30.260416, 63.82200320000001], [29.9718903, 63.7571676], [30.24571609999999, 63.60696830000001], [30.385620199999988, 63.54577980000001], [30.4841978, 63.4670887], [30.789711, 63.4050884], [30.9330443, 63.3559208], [30.9798739, 63.3078177], [31.1483116, 63.26151890000002], [31.2416464, 63.2166421], [31.2658547, 63.1154671], [31.46252279999998, 63.02421930000001], [31.5848296, 62.9070356]]],
  1666. // Greenland: [[[-57.44887, 82.28507], [-60.15022, 82.05782], [-61.87928, 81.82771], [-62.2191, 81.7294], [-63.42448, 81.28486], [-65.32658, 80.98138], [-66.57577, 80.83605], [-67.38791, 80.54753], [-67.66468, 80.1436], [-68.73755, 79.10919], [-72.47765, 78.62618], [-72.96065, 78.36972], [-73.1359, 78.13036], [-72.78968, 77.34387], [-73.38382, 76.66424], [-72.79822, 76.5702], [-69.80615, 76.29664], [-68.45971, 75.97179], [-66.32252, 75.80508], [-64.89914, 75.80081], [-63.13809, 76.04018], [-62.31741, 75.9034], [-60.47087, 75.78371], [-60.19731, 75.62983], [-58.94919, 75.49305], [-58.81241, 74.92883], [-58.38497, 74.89464], [-58.21399, 74.63817], [-57.47879, 74.17654], [-57.15394, 73.47554], [-55.83743, 71.40673], [-55.23901, 70.48346], [-55.10223, 69.40632], [-53.87121, 68.825], [-54.21316, 66.80748], [-53.75152, 65.52517], [-52.5034, 63.43926], [-47.39122, 59.6265], [-42.68939, 59.38714], [-41.16771, 61.50723], [-30.05428, 67.67946], [-26.83993, 68.124], [-21.04386, 70.27829], [-21.24903, 72.74034], [-16.78656, 74.91174], [-16.39331, 77.2541], [-17.64144, 78.51933], [-16.82075, 79.78455], [-11.02468, 81.34043], [-11.93085, 82.02433], [-19.48798, 82.45177], [-19.71024, 83.01599], [-27.19898, 83.85377], [-39.64602, 83.80248], [-50.82784, 82.9476], [-57.44887, 82.28507]]],
  1667. Iceland: [[[-25.0, 63.0], [-12.8, 63.0], [-12.8, 66.8], [-25.0, 66.8]]],
  1668. Norway: [[[30.79367, 69.78758], [30.89032, 69.73729], [30.95448, 69.63243], [30.93257, 69.55989], [30.81756, 69.52877], [30.51593, 69.54042], [30.41768, 69.58992], [30.23373, 69.65016], [30.13777, 69.64353], [30.18838, 69.56846], [30.12305, 69.51749], [30.11721, 69.46989], [30.00876, 69.41591], [29.85802, 69.42374], [29.7244, 69.38965], [29.56938, 69.31756], [29.39594, 69.32384], [29.28845, 69.29618], [29.31313, 69.23752], [29.24224, 69.11306], [29.05666, 69.01528], [28.85456, 69.07664], [28.80541, 69.11116], [28.83152, 69.22436], [29.21932, 69.39764], [29.33647, 69.47832], [29.17052, 69.63904], [29.13389, 69.69534], [28.40421, 69.81842], [28.33046, 69.84919], [28.34506, 69.8808], [28.1607, 69.92099], [27.98428, 70.01397], [27.94828, 70.09187], [27.79768, 70.07731], [27.61245, 70.07456], [27.52598, 70.02346], [27.42855, 70.01921], [27.27471, 69.97591], [27.29177, 69.95225], [27.03749, 69.91039], [26.89776, 69.93245], [26.85129, 69.96013], [26.71807, 69.94499], [26.67869, 69.96477], [26.46435, 69.93939], [26.38594, 69.85535], [26.24129, 69.81453], [26.13562, 69.73861], [26.01418, 69.72334], [25.89149, 69.6655], [25.97672, 69.61067], [25.93749, 69.57253], [25.83994, 69.54298], [25.87704, 69.5222], [25.80934, 69.42639], [25.8461, 69.39325], [25.75938, 69.34038], [25.74753, 69.28679], [25.70204, 69.25366], [25.69302, 69.19674], [25.74351, 69.13879], [25.72429, 69.0796], [25.77744, 69.01828], [25.71241, 68.98063], [25.65423, 68.90587], [25.60033, 68.88487], [25.48119, 68.90507], [25.2677, 68.85099], [25.15713, 68.79989], [25.11152, 68.70252], [25.11924, 68.6428], [24.91692, 68.60525], [24.85717, 68.56221], [24.78342, 68.63623], [24.60839, 68.6819], [24.30226, 68.71735], [24.07559, 68.77997], [23.98333, 68.82714], [23.87146, 68.83652], [23.77539, 68.81885], [23.73106, 68.75075], [23.67352, 68.70552], [23.44064, 68.69216], [23.16758, 68.62852], [23.04595, 68.68934], [22.80082, 68.68755], [22.53539, 68.74451], [22.37452, 68.71667], [22.34078, 68.82723], [22.19187, 68.91877], [22.17576, 68.95632], [21.98361, 69.07289], [21.8464, 69.14416], [21.62709, 69.27659], [21.27882, 69.31188], [21.09617, 69.26091], [21.00331, 69.22234], [20.98758, 69.19193], [21.05563, 69.12209], [21.10868, 69.10393], [21.05754, 69.03629], [20.71732, 69.11979], [20.55233, 69.06008], [20.06005, 69.04576], [20.30659, 68.92618], [20.33587, 68.80231], [20.20284, 68.66592], [20.05225, 68.59107], [19.9375, 68.55794], [20.02589, 68.53081], [20.22654, 68.49081], [19.97796, 68.38816], [19.9214, 68.35601], [18.9838, 68.51696], [18.62122, 68.50696], [18.40569, 68.58188], [18.12592, 68.53652], [18.10109, 68.40605], [18.15135, 68.19879], [17.89976, 67.96937], [17.66475, 68.03838], [17.28152, 68.11881], [17.18051, 68.05046], [16.73812, 67.91421], [16.55628, 67.64719], [16.40757, 67.53403], [16.158, 67.51916], [16.08983, 67.43528], [16.4041, 67.20497], [16.38776, 67.04546], [16.19402, 66.98259], [16.03876, 66.91245], [15.99364, 66.87323], [15.62137, 66.59434], [15.37723, 66.4843], [15.48473, 66.28246], [15.03568, 66.15356], [14.51629, 66.13258], [14.58441, 65.90134], [14.62548, 65.81181], [14.54147, 65.70075], [14.49877, 65.5213], [14.50683, 65.30973], [14.3788, 65.24762], [14.32598, 65.11892], [14.12989, 64.97856], [13.70547, 64.63996], [13.65426, 64.58034], [13.89118, 64.50713], [14.08523, 64.47825], [14.11387, 64.46248], [14.15711, 64.19505], [13.96752, 64.00797], [13.7154, 64.04629], [13.21111, 64.09537], [12.92672, 64.05795], [12.68356, 63.97422], [12.48023, 63.81876], [12.33057, 63.71507], [12.29946, 63.67198], [12.14977, 63.59395], [12.21288, 63.47859], [12.08407, 63.35558], [11.97458, 63.26923], [12.21823, 63.00033], [12.07469, 62.90254], [12.13638, 62.74792], [12.05614, 62.61192], [12.29937, 62.26749], [12.13766, 61.72382], [12.41961, 61.56298], [12.56932, 61.56875], [12.87085, 61.3565], [12.83383, 61.25846], [12.79035, 61.19705], [12.70703, 61.14327], [12.68258, 61.06122], [12.61251, 61.04683], [12.44761, 61.05073], [12.22399, 61.01308], [12.33279, 60.89017], [12.33448, 60.85236], [12.39537, 60.73389], [12.51102, 60.64246], [12.51578, 60.60015], [12.60688, 60.51274], [12.60605, 60.40593], [12.49879, 60.32365], [12.54191, 60.19338], [12.50064, 60.09908], [12.44856, 60.03917], [12.34114, 59.96567], [12.23104, 59.92759], [12.17429, 59.88981], [12.05346, 59.88594], [11.98518, 59.90072], [11.84045, 59.84174], [11.92597, 59.794], [11.93988, 59.69458], [11.88922, 59.69321], [11.85571, 59.64829], [11.72056, 59.62549], [11.69113, 59.58955], [11.75993, 59.45818], [11.77987, 59.38646], [11.81625, 59.34474], [11.82979, 59.24223], [11.78393, 59.20838], [11.77539, 59.08659], [11.71051, 59.03368], [11.68908, 58.95685], [11.59063, 58.89072], [11.45623, 58.89021], [11.45853, 58.99597], [11.34184, 59.12041], [11.20498, 59.08311], [11.17718, 59.09736], [11.1, 59], [11.0203, 58.97], [9.67858, 58.87844], [8.51901, 58.15871], [7.92368, 57.95878], [6.62638, 57.9188], [5.34686, 58.63409], [4.70265, 59.35382], [4.57381, 61.1576], [4.78262, 62.0506], [5.46681, 62.55263], [6.79965, 62.99691], [8.29243, 63.77884], [9.92293, 64.11205], [10.71819, 65.0095], [11.4246, 65.12057], [11.79779, 65.84919], [11.95329, 67.64852], [13.20171, 68.29717], [14.5701, 68.89694], [16.08064, 69.41675], [17.91552, 69.8166], [19.1906, 70.36306], [19.81259, 70.33196], [20.19467, 70.19424], [21.78519, 70.50523], [21.89626, 70.73182], [23.70892, 70.96284], [23.91773, 71.1139], [24.46864, 71.07391], [24.71744, 71.21608], [25.89478, 71.26051], [26.77445, 71.08724], [27.79185, 71.22052], [28.65819, 71.06503], [30.03102, 70.78069], [31.23946, 70.43859], [31.19482, 70.34084], [30.79367, 69.78758]], [[4.2, 80.84], [-11.5, 70.1], [19.2, 73.5], [39.2, 81.4]]],
  1669. Sweden: [[[15.4538561, 66.34534869999999], [15.3772302, 66.4843117], [15.625833, 66.605833], [15.80794, 66.735271], [16.0387632, 66.9124213], [16.195223, 66.982232], [16.3877, 67.0455], [16.4040109, 67.2049795], [16.09015, 67.435232], [16.1566, 67.519458], [16.407797, 67.533978], [16.555733, 67.647289], [16.7381292, 67.91418620000002], [17.180003, 68.050508], [17.2818957, 68.1188101], [17.6648128, 68.0384733], [17.8998048, 67.9693359], [18.1514126, 68.198755], [18.1010915, 68.406043], [18.1258499, 68.5364954], [18.4056102, 68.5818554], [18.6211478, 68.5069382], [18.9836971, 68.5169473], [19.921397, 68.3560137], [19.9778586, 68.3881535], [20.2264196, 68.4908071], [19.9375039, 68.5579418], [20.0521233, 68.5910515], [20.2027029, 68.6659076], [20.3358646, 68.8023404], [20.3064282, 68.9261735], [20.0600472, 69.0457578], [20.5486422, 69.05996990000001], [20.7750428, 69.0326073], [20.9137291, 68.9603927], [20.8441913, 68.93656440000002], [20.9156942, 68.8971424], [20.9967921, 68.896741], [21.2340165, 68.8140862], [21.3194271, 68.7592708], [21.3893348, 68.76495460000002], [21.4298688, 68.691352], [21.5651505, 68.6752534], [21.7013706, 68.6305605], [21.7016655, 68.5963461], [21.8898693, 68.5844051], [21.9919125, 68.5339794], [22.0182391, 68.495951], [22.1528153, 68.4701805], [22.2945732, 68.4838241], [22.4661749, 68.4413001], [22.6482126, 68.41604160000001], [22.7362404, 68.3852018], [22.8041064, 68.39294], [22.9181313, 68.3335115], [23.0702517, 68.29970360000002], [23.1528179, 68.2310713], [23.1415318, 68.1543005], [23.2783645, 68.15733889999998], [23.3216014, 68.1347101], [23.3966203, 68.044179], [23.5310194, 68.0067455], [23.6632301, 67.94218640000001], [23.6407972, 67.9151784], [23.5098377, 67.87994509999999], [23.4739757, 67.81714420000002], [23.4946531, 67.7903019], [23.493057, 67.6641861], [23.5588847, 67.6192741], [23.5450496, 67.5829545], [23.4081036, 67.50173829999999], [23.4104738, 67.46759370000002], [23.5365192, 67.4599963], [23.7632859, 67.4262029], [23.7179667, 67.384843], [23.7750768, 67.3393805], [23.7311639, 67.28763560000002], [23.5834506, 67.269308], [23.5535126, 67.2468025], [23.5958386, 67.2071971], [23.5569385, 67.16578719999998], [23.6536532, 67.1042345], [23.6739708, 67.0650834], [23.8564714, 66.9558968], [23.8640579, 66.9221303], [23.9330592, 66.8845665], [23.9945079, 66.82348849999998], [23.9782068, 66.78409040000001], [23.8797209, 66.7620511], [23.9078441, 66.72140390000001], [23.8685321, 66.6568254], [23.8846737, 66.61277119999998], [23.8605347, 66.5595503], [23.7853219, 66.5333886], [23.6509657, 66.4557476], [23.6880374, 66.3815611], [23.6489848, 66.3037725], [23.7263744, 66.1968556], [23.9159179, 66.1621612], [23.936749, 66.0794759], [24.0374327, 66.0090364], [24.0421963, 65.9633925], [24.152978, 65.862572], [24.1318042, 65.7716089], [24.1721721, 65.72528229999999], [24.1776819, 65.6603564], [24.1319001, 65.5153846], [24.1444599, 65.3956667], [23.1299456, 65.2854532], [21.8250561, 64.8363612], [22.0872366, 64.43431070000001], [21.5096176, 64.04121570000002], [21.4570471, 63.7528427], [20.20662871333013, 63.274568586669865], [19.4322896, 63.0737152], [18.2961641, 62.4173632], [17.7755886, 61.1718712], [17.8981165, 60.9377595], [17.7095869, 60.7102649], [17.3865202, 60.6893467], [17.3489744, 60.5862714], [17.3024177, 60.508762], [17.29774, 60.4647038], [17.2565412, 60.4243351], [17.1955585, 60.4105852], [17.1986283, 60.3077815], [17.0585097, 60.2727725], [16.908878, 60.281498], [16.9048859, 60.2394077], [16.7046001, 60.1950497], [16.6294785, 60.2384924], [16.6154023, 60.2786235], [16.5166127, 60.3554293], [16.3927146, 60.3794045], [16.2589904, 60.4931441], [16.1947891, 60.5354328], [16.13651, 60.6103267], [16.2382972, 60.6230491], [16.3769218, 60.7434488], [16.386117, 60.7868], [16.2552139, 60.8636119], [16.1310092, 60.9920575], [15.9216155, 61.00763], [15.7619207, 61.0496869], [15.6803816, 61.11321], [15.6573361, 61.2154788], [15.4760187, 61.3149858], [15.3370007, 61.4016369], [15.20475, 61.503826], [15.1531933, 61.5956892], [14.8564014, 61.7835491], [14.7971, 61.798451], [14.6666465, 61.8918775], [14.5296202, 61.783626], [14.4997464, 61.62599], [14.3947754, 61.5637652], [14.3364964, 61.59913920000001], [14.1822587, 61.6175455], [13.9769516, 61.6213397], [13.8902353, 61.6525473], [13.6131488, 61.6726273], [13.564749, 61.656455], [13.5066718, 61.6929666], [13.5145384, 61.7377738], [13.4160916, 61.8280592], [13.2092287, 61.9365972], [13.0799221, 62.0376119], [13.0423631, 62.0182008], [12.9513736, 62.1334555], [12.9026405, 62.1418727], [12.8059683, 62.2205277], [12.6078489, 62.214806], [12.299389, 62.2659814], [12.056144, 62.6119191], [12.1363845, 62.7479169], [12.074689, 62.9025463], [12.218233, 63.0003345], [11.9745822, 63.2692252], [12.0840901, 63.3555796], [12.2128783, 63.4785906], [12.1497625, 63.593946], [12.2975812, 63.6732169], [12.3399662, 63.7269855], [12.4797773, 63.8196667], [12.6860556, 63.9738931], [12.9268369, 64.05783829999999], [13.2109436, 64.0951725], [13.7151219, 64.045304], [13.981667, 64.013056], [14.1579301, 64.1860759], [14.120556, 64.452778], [14.086006, 64.47814109999999], [13.8924406, 64.507004], [13.6540802, 64.579929], [13.7050997, 64.6396655], [14.1081927, 64.96225790000001], [14.3257603, 65.1190618], [14.3790211, 65.24804960000002], [14.5056577, 65.3099238], [14.4967711, 65.5174317], [14.5295213, 65.682227], [14.6240045, 65.81419090000001], [14.584253, 65.9013501], [14.5162846, 66.132567], [15.035653, 66.1535649], [15.4847146, 66.282458], [15.4538561, 66.34534869999999]]],
  1670. USA: [[[-130.01989, 55.9153], [-130.17038, 55.77749], [-130.13861, 55.55335], [-129.99201, 55.28955], [-130.25933, 54.99635], [-130.66666, 54.71444], [-131.17048, 54.72103], [-132.10046, 54.6269], [-132.86477, 54.63066], [-133.60649, 54.72479], [-134.93933, 56.02375], [-136.80681, 57.75192], [-137.09296, 58.25079], [-139.07716, 59.1017], [-141.32115, 59.76436], [-143.47102, 59.81707], [-146.37014, 59.17701], [-149.21654, 59.54598], [-152.0253, 57.0535], [-155.80544, 55.02035], [-159.93198, 54.32757], [-173.1399, 51.33056], [-179.49537, 50.84863], [-179.28453, 52.29443], [-171.78447, 63.95114], [-169.94709, 63.91437], [-169.09903, 65.86662], [-168.1474, 65.7885], [-164.9772, 66.85025], [-167.15342, 68.37135], [-166.29498, 69.12437], [-161.71663, 70.74335], [-156.23466, 71.55661], [-143.75716, 70.6304], [-141.58847, 70.26895], [-141.56335, 69.73575], [-141.39798, 69.64277], [-141.00304, 69.64616], [-141.00189, 60.6745], [-141.00157, 60.30507], [-140.52034, 60.21906], [-140.44797, 60.30796], [-139.97408, 60.18451], [-139.68007, 60.33572], [-139.05208, 60.35373], [-139.17702, 60.08286], [-138.70578, 59.90624], [-138.60921, 59.76], [-137.60744, 59.24348], [-137.45151, 58.90854], [-136.82468, 59.1598], [-136.58199, 59.16554], [-136.19525, 59.63881], [-135.9476, 59.66343], [-135.47958, 59.7981], [-135.02888, 59.56364], [-135.10063, 59.42776], [-134.95978, 59.28104], [-134.7007, 59.2489], [-134.48273, 59.13097], [-134.258, 58.86087], [-133.84105, 58.72985], [-133.37997, 58.43181], [-133.45987, 58.38848], [-133.17195, 58.15383], [-132.55389, 57.4967], [-132.2478, 57.21112], [-132.36871, 57.09167], [-132.0448, 57.0451], [-132.12311, 56.8739], [-131.87311, 56.80627], [-131.83539, 56.59912], [-131.5813, 56.6123], [-131.08698, 56.40613], [-130.7818, 56.36713], [-130.4682, 56.24329], [-130.42548, 56.14172], [-130.10541, 56.12268], [-130.01989, 55.9153]], [[179.9, 52.2], [172.0, 53.3], [172.0, 52.4], [179.9, 51.0]]],
  1671. };
  1672. /* eslint-enable max-len */
  1673. let usingClockLocations = true;
  1674. const useClockLocations = (useClockLocations) => {
  1675. usingClockLocations = useClockLocations;
  1676. };
  1677. const pointInPolygon = (coords, polygon) => {
  1678. const [x, y] = coords;
  1679. let inside = false;
  1680. for (let i = 0, j = polygon.length - 1; i < polygon.length; i++) {
  1681. const [xi, yi] = polygon[i];
  1682. const [xj, yj] = polygon[j];
  1683. // Check that a) the segment crosses the y coordinate of the point
  1684. // b) at least one of the two vertices is left of the point
  1685. // c) at the y coordinate of the point, the segment is left of it
  1686. if ((((yi < y) !== (yj < y)) && (xi <= x || xj <= x)) && ((xi + (y - yi) * (xj - xi) / (yj - yi)) < x)) {
  1687. inside = !inside;
  1688. }
  1689. j = i;
  1690. }
  1691. return inside;
  1692. };
  1693. // The name of a country being returned doesn't just mean that the coordinates are within that country, but that they
  1694. // are within the region of that country where a fixed time rule applies.
  1695. const clockLocationFromPolygons = (latitude, longitude) => {
  1696. if (!usingClockLocations) {
  1697. return undefined;
  1698. }
  1699. // First exclude as large an area as possible from having to check polygons
  1700. if (latitude < 51.0) {
  1701. return undefined;
  1702. }
  1703. if (latitude < 57.0 && longitude > -129.0 && longitude < 172.0) {
  1704. return undefined;
  1705. }
  1706. // Make a list of plausible areas based on longitude, then only check those
  1707. const countries = [];
  1708. const labels = [];
  1709. if (longitude < -129.9 || longitude > 172.4) {
  1710. countries.push(clockLocations.USA);
  1711. labels.push('USA');
  1712. }
  1713. if (longitude > -141.1 && longitude < -61.1) {
  1714. countries.push(clockLocations.Canada);
  1715. labels.push('Canada');
  1716. }
  1717. // Greenland doesn't currently have a rule for this
  1718. // if (longitude > -73.1 && longitude < -11.3) {
  1719. // countries.push(clockLocations.Greenland);
  1720. // labels.push('Greenland');
  1721. // }
  1722. if (longitude > -25.0 && longitude < -12.8) {
  1723. countries.push(clockLocations.Iceland);
  1724. labels.push('Iceland');
  1725. }
  1726. if (longitude > -9.2 && longitude < 33.6) {
  1727. countries.push(clockLocations.Norway);
  1728. labels.push('Norway');
  1729. }
  1730. if (longitude > 10.9 && longitude < 24.2) {
  1731. countries.push(clockLocations.Sweden);
  1732. labels.push('Sweden');
  1733. }
  1734. if (longitude > 19.1 && longitude < 31.6) {
  1735. countries.push(clockLocations.Finland);
  1736. labels.push('Finland');
  1737. }
  1738. // Russia currently doesn't have a rule for this
  1739. // if (longitude > 27.3 || longitude < -169.6) {
  1740. // countries.push(clockLocations.Russia);
  1741. // labels.push('Russia');
  1742. // }
  1743. for (let i = 0; i < countries.length; i++) {
  1744. for (let j = 0; j < countries[i].length; j++) {
  1745. if (pointInPolygon([longitude, latitude], countries[i][j])) {
  1746. return labels[i];
  1747. }
  1748. }
  1749. }
  1750. return undefined;
  1751. };
  1752. /* eslint-disable complexity */
  1753. class LocalBadiDate {
  1754. constructor(date, latitude, longitude, timezoneId) {
  1755. this._latitude = latitude;
  1756. this._longitude = longitude;
  1757. this._timezoneId = timezoneId;
  1758. // If a datetime object is being passed, we use date and time, not just the
  1759. // date. For a JS Date object, we can't assume it's in the correct timezone,
  1760. // so in that case we use the date information only.
  1761. this._badiDate = new BadiDate(this._setInputDateToCorrectDay(date, latitude, longitude));
  1762. const gregDate = this._badiDate.gregorianDate.setZone(timezoneId, { keepLocalTime: true });
  1763. this._clockLocation = clockLocationFromPolygons(latitude, longitude);
  1764. if (!this._clockLocation ||
  1765. (this._clockLocation === 'Finland' &&
  1766. this._badiDate.month === 19)) {
  1767. this._end = sunset(gregDate, latitude, longitude);
  1768. this._solarNoon = solarNoon(gregDate, longitude);
  1769. this._sunrise = sunrise(gregDate, latitude, longitude);
  1770. this._start = sunset(gregDate.minus({ days: 1 }), latitude, longitude);
  1771. }
  1772. else {
  1773. // First we set times to 18:00, 06:00, 12:00, 18:00, modifications are
  1774. // then made depending on the region.
  1775. this._start = gregDate.minus({ days: 1 }).set({ hour: 18 });
  1776. this._solarNoon = gregDate.set({ hour: 12 });
  1777. this._sunrise = gregDate.set({ hour: 6 });
  1778. this._end = gregDate.set({ hour: 18 });
  1779. if (this._clockLocation === 'Canada') {
  1780. this._sunrise = this._sunrise.plus({ minutes: 30 });
  1781. }
  1782. else if (this._clockLocation === 'Iceland') {
  1783. this._solarNoon = this._solarNoon.plus({ hours: 1 });
  1784. }
  1785. else if (this._clockLocation === 'Finland' ||
  1786. this._clockLocation === 'USA') {
  1787. if (this._end.isInDST) {
  1788. this._sunrise = this._sunrise.plus({ hours: 1 });
  1789. this._solarNoon = this._solarNoon.plus({ hours: 1 });
  1790. this._end = this._end.plus({ hours: 1 });
  1791. }
  1792. if (this._start.isInDST) {
  1793. this._start = this._start.plus({ hours: 1 });
  1794. }
  1795. }
  1796. }
  1797. switch (this._badiDate.holyDayNumber) {
  1798. case 2:
  1799. // First Day of Ridvan: 15:00 local standard time
  1800. this._holyDayCommemoration = gregDate.set({ hour: gregDate.isInDST ? 16 : 15 });
  1801. break;
  1802. case 5:
  1803. // Declaration of the Báb: 2 hours 11 minutes after sunset
  1804. this._holyDayCommemoration = this._start.plus({ minutes: 131 });
  1805. break;
  1806. case 6:
  1807. // Ascension of Bahá'u'lláh: 03:00 local standard time
  1808. this._holyDayCommemoration = gregDate.set({ hour: gregDate.isInDST ? 4 : 3 });
  1809. break;
  1810. case 7:
  1811. // Martyrdom of the Báb: solar noon
  1812. this._holyDayCommemoration = this._solarNoon;
  1813. break;
  1814. case 11:
  1815. // Ascension of 'Abdu'l-Bahá: 01:00 local standard time
  1816. this._holyDayCommemoration = gregDate.set({ hour: gregDate.isInDST ? 2 : 1 });
  1817. break;
  1818. // skip default
  1819. }
  1820. }
  1821. _setInputDateToCorrectDay(date, latitude, longitude) {
  1822. if (DateTime.isDateTime(date)) {
  1823. const sunset$1 = sunset(date, latitude, longitude);
  1824. return (date > sunset$1) ? date.plus({ days: 1 }) : date;
  1825. }
  1826. return date;
  1827. }
  1828. get badiDate() {
  1829. return this._badiDate;
  1830. }
  1831. get start() {
  1832. return this._start;
  1833. }
  1834. get sunrise() {
  1835. return this._sunrise;
  1836. }
  1837. get solarNoon() {
  1838. return this._solarNoon;
  1839. }
  1840. get end() {
  1841. return this._end;
  1842. }
  1843. get holyDayCommemoration() {
  1844. return this._holyDayCommemoration;
  1845. }
  1846. get clockLocation() {
  1847. return this._clockLocation;
  1848. }
  1849. get latitude() {
  1850. return this._latitude;
  1851. }
  1852. get longitude() {
  1853. return this._longitude;
  1854. }
  1855. get timezoneId() {
  1856. return this._timezoneId;
  1857. }
  1858. get nextMonth() {
  1859. return new LocalBadiDate(this.badiDate.nextMonth, this._latitude, this._longitude, this._timezoneId);
  1860. }
  1861. get previousMonth() {
  1862. return new LocalBadiDate(this.badiDate.previousMonth, this._latitude, this._longitude, this._timezoneId);
  1863. }
  1864. get nextDay() {
  1865. return new LocalBadiDate(this.badiDate.nextDay, this._latitude, this._longitude, this._timezoneId);
  1866. }
  1867. get previousDay() {
  1868. return new LocalBadiDate(this.badiDate.previousDay, this._latitude, this._longitude, this._timezoneId);
  1869. }
  1870. }
  1871. const badiDateSettings$1 = (settings) => {
  1872. if (typeof settings.defaultLanguage === 'string' ||
  1873. typeof settings.underlineFormat === 'string') {
  1874. badiDateSettings(settings);
  1875. }
  1876. if (typeof settings.useClockLocations === 'boolean') {
  1877. useClockLocations(settings.useClockLocations);
  1878. }
  1879. };
  1880. settings({ returnTimeForNoEventCase: true, roundToNearestMinute: true });
  1881. export { BadiDate, LocalBadiDate, badiDateSettings$1 as badiDateSettings };