localBadiDate-msm-locales.js 117 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694
  1. /**
  2. * @license BadiDate v3.0.2
  3. * (c) 2018 Jan Greis
  4. * licensed under MIT
  5. */
  6. (function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('luxon')) :
  8. typeof define === 'function' && define.amd ? define(['exports', 'luxon'], factory) :
  9. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.window = global.window || {}, global.luxon));
  10. }(this, (function (exports, luxon) { 'use strict';
  11. /**
  12. * @license MeeusSunMoon v3.0.0
  13. * (c) 2018 Jan Greis
  14. * licensed under MIT
  15. */
  16. /**
  17. * Converts angles in degrees to radians.
  18. * @param {number} deg Angle in degrees.
  19. * @returns {number} Angle in radians.
  20. */
  21. const deg2rad = (deg) => deg * 0.017453292519943295;
  22. /**
  23. * Converts angles in radians to degrees.
  24. * @param {number} rad Angle in radians.
  25. * @returns {number} Angle in degrees.
  26. */
  27. const rad2deg = (rad) => rad * 57.29577951308232;
  28. /**
  29. * Calculates the sine of an angle given in degrees.
  30. * @param {number} deg Angle in degrees.
  31. * @returns {number} Sine of the angle.
  32. */
  33. const sind = (deg) => Math.sin(deg2rad(deg));
  34. /**
  35. * Calculates the cosine of an angle given in degrees.
  36. * @param {number} deg Angle in degrees.
  37. * @returns {number} Cosine of the angle.
  38. */
  39. const cosd = (deg) => Math.cos(deg2rad(deg));
  40. /**
  41. * Reduces an angle to the interval 0-360°.
  42. * @param {number} angle Angle in degrees.
  43. * @returns {number} Reduced angle in degrees.
  44. */
  45. const reduceAngle = (angle) => angle - (360 * Math.floor(angle / 360));
  46. /**
  47. * Evaluates a polynomial in the form A + Bx + Cx^2...
  48. * @param {number} variable Value of x in the polynomial.
  49. * @param {array} coeffs Array of coefficients [A, B, C...].
  50. * @returns {number} Sum of the polynomial.
  51. */
  52. const polynomial = (variable, coeffs) => {
  53. let varPower = 1;
  54. let sum = 0.0;
  55. const numCoeffs = coeffs.length;
  56. for (let i = 0; i < numCoeffs; i++) {
  57. sum += varPower * coeffs[i];
  58. varPower *= variable;
  59. }
  60. return sum;
  61. };
  62. /**
  63. * Interpolates a value from 3 known values (see AA p24 Eq3.3).
  64. * @param {number} y1 Start value of the interval.
  65. * @param {number} y2 Middle value of the interval.
  66. * @param {number} y3 End value of the interval.
  67. * @param {number} n Location (-0.5 >= n >= 0.5) of result in the interval.
  68. * @param {boolean} normalize Whether the final result should be normalized.
  69. * @returns {number} Interpolated result.
  70. */
  71. const interpolateFromThree = (y1, y2, y3, n, normalize = false) => {
  72. let a = y2 - y1;
  73. let b = y3 - y2;
  74. if (typeof normalize !== 'undefined' && normalize) {
  75. if (a < 0) {
  76. a += 360;
  77. }
  78. if (b < 0) {
  79. b += 360;
  80. }
  81. }
  82. const c = b - a;
  83. return y2 + (n / 2) * (a + b + n * c);
  84. };
  85. /**
  86. * Converts a datetime in UTC to the corresponding Julian Date (see AA p60f).
  87. * @param {DateTime} datetime Datetime to be converted.
  88. * @returns {number} Julian date (fractional number of days since 1 January
  89. * 4713BC according to the proleptic Julian calendar.
  90. */
  91. const datetimeToJD = (datetime) => {
  92. let Y = datetime.year;
  93. let M = datetime.month;
  94. const D = datetime.day + (datetime.hour + (datetime.minute + datetime.second / 60) / 60) / 24;
  95. if (M < 3) {
  96. Y -= 1;
  97. M += 12;
  98. }
  99. const A = Math.floor(Y / 100);
  100. // Need a different B if we are before introduction of the Gregorian Calendar
  101. const gregorianCutoff = luxon.DateTime.fromISO('1582-10-15T12:00:00Z', { zone: 'UTC' });
  102. let B = 0;
  103. if (datetime > gregorianCutoff) {
  104. B = 2 - A + Math.floor(A / 4);
  105. }
  106. return Math.floor(365.25 * (Y + 4716)) + Math.floor(30.6001 * (M + 1)) + D + B - 1524.5;
  107. };
  108. /**
  109. * Converts a Julian date to the number of Julian centuries since
  110. * 2000-01-01T12:00:00Z (see AA p87 Eq12.1).
  111. * @param {number} JD Julian date.
  112. * @returns {number} T.
  113. */
  114. const JDToT = (JD) => (JD - 2451545) / 36525;
  115. /**
  116. * Converts a datetime in UTC to the number of Julian centuries since
  117. * 2000-01-01T12:00:00Z.
  118. * @param {DateTime} datetime Datetime to be converted.
  119. * @returns {number} T.
  120. */
  121. const datetimeToT = (datetime) => JDToT(datetimeToJD(datetime));
  122. /* eslint-disable complexity */
  123. /**
  124. * Calculates the value of ΔT=TT−UT (see
  125. * http://eclipse.gsfc.nasa.gov/SEcat5/deltatpoly.html).
  126. * @param {DateTime} datetime Datetime for which ΔT should be calculated.
  127. * @returns {number} ΔT.
  128. */
  129. const DeltaT = (datetime) => {
  130. let y = datetime.year;
  131. y += (datetime.month - 0.5) / 12;
  132. let u;
  133. let t;
  134. switch (true) {
  135. case y < -1999 || y > 3000:
  136. throw 'DeltaT can only be calculated between 1999 BCE and 3000 CE';
  137. case y < -500:
  138. u = (y - 1820) / 100;
  139. return -20 + 32 * Math.pow(u, 2);
  140. case y < 500:
  141. u = y / 100;
  142. return polynomial(u, [10583.6, -1014.41, 33.78311, -5.952053, -0.1798452, 0.022174192, 0.0090316521]);
  143. case y < 1600:
  144. u = (y - 1000) / 100;
  145. return polynomial(u, [1574.2, -556.01, 71.23472, 0.319781, -0.8503463, -0.005050998, 0.0083572073]);
  146. case y < 1700:
  147. t = y - 1600;
  148. return polynomial(t, [120, -0.9808, -0.01532, 1 / 7129]);
  149. case y < 1800:
  150. t = y - 1700;
  151. return polynomial(t, [8.83, 0.1603, -0.0059285, 0.00013336, -1 / 1174000]);
  152. case y < 1860:
  153. t = y - 1800;
  154. return polynomial(t, [13.72, -0.332447, 0.0068612, 0.0041116, -0.00037436, 0.0000121272, -0.0000001699, 0.000000000875]);
  155. case y < 1900:
  156. t = y - 1860;
  157. return polynomial(t, [7.62, 0.5737, -0.251754, 0.01680668, -0.0004473624, 1 / 233174]);
  158. case y < 1920:
  159. t = y - 1900;
  160. return polynomial(t, [-2.79, 1.494119, -0.0598939, 0.0061966, -0.000197]);
  161. case y < 1941:
  162. t = y - 1920;
  163. return polynomial(t, [21.20, 0.84493, -0.076100, 0.0020936]);
  164. case y < 1961:
  165. t = y - 1950;
  166. return polynomial(t, [29.07, 0.407, -1 / 233, 1 / 2547]);
  167. case y < 1986:
  168. t = y - 1975;
  169. return polynomial(t, [45.45, 1.067, -1 / 260, -1 / 718]);
  170. case y < 2005:
  171. t = y - 2000;
  172. return polynomial(t, [63.86, 0.3345, -0.060374, 0.0017275, 0.000651814, 0.00002373599]);
  173. case y < 2050:
  174. t = y - 2000;
  175. return polynomial(t, [62.92, 0.32217, 0.005589]);
  176. case y < 2150:
  177. return -20 + 32 * Math.pow(((y - 1820) / 100), 2) - 0.5628 * (2150 - y);
  178. default:
  179. u = (y - 1820) / 100;
  180. return -20 + 32 * Math.pow(u, 2);
  181. }
  182. };
  183. let roundToNearestMinute = false;
  184. let returnTimeForNoEventCase = false;
  185. let dateFormatKeys = {
  186. SUN_HIGH: '‡',
  187. SUN_LOW: '†',
  188. };
  189. const settings = (settings) => {
  190. if (typeof settings.roundToNearestMinute === 'boolean') {
  191. roundToNearestMinute = settings.roundToNearestMinute;
  192. }
  193. if (typeof settings.returnTimeForNoEventCase === 'boolean') {
  194. returnTimeForNoEventCase = settings.returnTimeForNoEventCase;
  195. }
  196. if (typeof settings.dateFormatKeys === 'object') {
  197. dateFormatKeys = settings.dateFormatKeys;
  198. }
  199. };
  200. /** See AA p144 */
  201. const sunMeanAnomaly = [357.52772, 35999.050340, -0.0001603, -1 / 300000];
  202. /** See AA p163 Eq 25.2 */
  203. const sunMeanLongitude = [280.46646, 36000.76983, 0.0003032];
  204. /** See AA p147 Eq22.3 */
  205. const meanObliquityOfEcliptic = [84381.448 / 3600, -4680.93 / 3600, -1.55 / 3600, 1999.25 / 3600, -51.38 / 3600, -249.67 / 3600, -39.05 / 3600,
  206. 7.12 / 3600, 27.87 / 3600, 5.79 / 3600, 2.45 / 3600];
  207. /** See AA p144 */
  208. const moonArgumentOfLatitude = [93.27191, 483202.017538, -0.0036825, 1 / 327270];
  209. /** See AA p144 */
  210. const moonAscendingNodeLongitude = [125.04452, -1934.136261, 0.0020708, 1 / 450000];
  211. /** See AA p144 */
  212. const moonMeanAnomaly = [134.96298, 477198.867398, 0.0086972, 1 / 56250];
  213. /** See AA p144 */
  214. const moonMeanElongation = [297.85036, 445267.111480, -0.0019142, 1 / 189474];
  215. /* eslint-disable no-multi-spaces, array-bracket-spacing */
  216. /**
  217. * Nutations in longitude and obliquity
  218. * See AA p145f
  219. */
  220. const nutations = [
  221. [0, 0, 0, 0, 1, -171996, -174.2, 92025, 8.9],
  222. [-2, 0, 0, 2, 2, -13187, -1.6, 5736, -3.1],
  223. [0, 0, 0, 2, 2, -2274, -0.2, 977, -0.5],
  224. [0, 0, 0, 0, 2, 2062, 0.2, -895, 0.5],
  225. [0, 1, 0, 0, 0, 1426, -3.4, 54, -0.1],
  226. [0, 0, 1, 0, 0, 712, 0.1, -7, 0],
  227. [-2, 1, 0, 2, 2, -517, 1.2, 224, -0.6],
  228. [0, 0, 0, 2, 1, -386, -0.4, 200, 0],
  229. [0, 0, 1, 2, 2, -301, 0, 129, -0.1],
  230. [-2, -1, 0, 2, 2, 217, -0.5, -95, 0.3],
  231. [-2, 0, 1, 0, 0, -158, 0, 0, 0],
  232. [-2, 0, 0, 2, 1, 129, 0.1, -70, 0],
  233. [0, 0, -1, 2, 2, 123, 0, -53, 0],
  234. [2, 0, 0, 0, 0, 63, 0, 0, 0],
  235. [0, 0, 1, 0, 1, 63, 0.1, -33, 0],
  236. [2, 0, -1, 2, 2, -59, 0, 26, 0],
  237. [0, 0, -1, 0, 1, -58, -0.1, 32, 0],
  238. [0, 0, 1, 2, 1, -51, 0, 27, 0],
  239. [-2, 0, 2, 0, 0, 48, 0, 0, 0],
  240. [0, 0, -2, 2, 1, 46, 0, -24, 0],
  241. [2, 0, 0, 2, 2, -38, 0, 16, 0],
  242. [0, 0, 2, 2, 2, -31, 0, 13, 0],
  243. [0, 0, 2, 0, 0, 29, 0, 0, 0],
  244. [-2, 0, 1, 2, 2, 29, 0, -12, 0],
  245. [0, 0, 0, 2, 0, 26, 0, 0, 0],
  246. [-2, 0, 0, 2, 0, -22, 0, 0, 0],
  247. [0, 0, -1, 2, 1, 21, 0, -10, 0],
  248. [0, 2, 0, 0, 0, 17, -0.1, 0, 0],
  249. [2, 0, -1, 0, 1, 16, 0, -8, 0],
  250. [-2, 2, 0, 2, 2, -16, 0.1, 7, 0],
  251. [0, 1, 0, 0, 1, -15, 0, 9, 0],
  252. [-2, 0, 1, 0, 1, -13, 0, 7, 0],
  253. [0, -1, 0, 0, 1, -12, 0, 6, 0],
  254. [0, 0, 2, -2, 0, 11, 0, 0, 0],
  255. [2, 0, -1, 2, 1, -10, 0, 5, 0],
  256. [2, 0, 1, 2, 2, -8, 0, 3, 0],
  257. [0, 1, 0, 2, 2, 7, 0, -3, 0],
  258. [-2, 1, 1, 0, 0, -7, 0, 0, 0],
  259. [0, -1, 0, 2, 2, -7, 0, 3, 0],
  260. [2, 0, 0, 2, 1, -7, 0, 3, 0],
  261. [2, 0, 1, 0, 0, 6, 0, 0, 0],
  262. [-2, 0, 2, 2, 2, 6, 0, -3, 0],
  263. [-2, 0, 1, 2, 1, 6, 0, -3, 0],
  264. [2, 0, -2, 0, 1, -6, 0, 3, 0],
  265. [2, 0, 0, 0, 1, -6, 0, 3, 0],
  266. [0, -1, 1, 0, 0, 5, 0, 0, 0],
  267. [-2, -1, 0, 2, 1, -5, 0, 3, 0],
  268. [-2, 0, 0, 0, 1, -5, 0, 3, 0],
  269. [0, 0, 2, 2, 1, -5, 0, 3, 0],
  270. [-2, 0, 2, 0, 1, 4, 0, 0, 0],
  271. [-2, 1, 0, 2, 1, 4, 0, 0, 0],
  272. [0, 0, 1, -2, 0, 4, 0, 0, 0],
  273. [-1, 0, 1, 0, 0, -4, 0, 0, 0],
  274. [-2, 1, 0, 0, 0, -4, 0, 0, 0],
  275. [1, 0, 0, 0, 0, -4, 0, 0, 0],
  276. [0, 0, 1, 2, 0, 3, 0, 0, 0],
  277. [0, 0, -2, 2, 2, -3, 0, 0, 0],
  278. [-1, -1, 1, 0, 0, -3, 0, 0, 0],
  279. [0, 1, 1, 0, 0, -3, 0, 0, 0],
  280. [0, -1, 1, 2, 2, -3, 0, 0, 0],
  281. [2, -1, -1, 2, 2, -3, 0, 0, 0],
  282. [0, 0, 3, 2, 2, 3, 0, 0, 0],
  283. [2, -1, 0, 2, 2, -3, 0, 0, 0],
  284. ];
  285. /**
  286. * Calculates the solar transit time on a date at a given longitude (see AA
  287. * p102f).
  288. * @param {DateTime} datetime Date for which transit is calculated.
  289. * @param {number} L Longitude.
  290. * @returns {DateTime} Solar transit time.
  291. */
  292. const sunTransit = (datetime, L) => {
  293. const timezone = datetime.zone;
  294. let transit = datetime.set({ hour: 0, minute: 0, second: 0, millisecond: 0 })
  295. .setZone('UTC', { keepLocalTime: true });
  296. const deltaT = DeltaT(transit);
  297. const T = datetimeToT(transit);
  298. const Theta0 = apparentSiderealTimeGreenwich(T);
  299. // Want 0h TD for this, not UT
  300. const TD = T - (deltaT / (3600 * 24 * 36525));
  301. const alpha = sunApparentRightAscension(TD);
  302. // Sign flip for longitude from AA as we take East as positive
  303. let m = (alpha - L - Theta0) / 360;
  304. m = normalizeM(m, datetime.offset);
  305. const DeltaM = sunTransitCorrection(T, Theta0, deltaT, L, m);
  306. m += DeltaM;
  307. transit = transit.plus({ seconds: Math.floor(m * 3600 * 24 + 0.5) });
  308. if (roundToNearestMinute) {
  309. transit = transit.plus({ seconds: 30 }).set({ second: 0 });
  310. }
  311. return transit.setZone(timezone);
  312. };
  313. /**
  314. * Calculates the sunrise or sunset time on a date at a given latitude and
  315. * longitude (see AA p102f).
  316. * @param {DateTime} datetime Date for which sunrise or sunset is calculated.
  317. * @param {number} phi Latitude.
  318. * @param {number} L Longitude.
  319. * @param {string} flag 'RISE' or 'SET' depending on which event should be
  320. * calculated.
  321. * @param {number} offset number of degrees below the horizon for the desired
  322. * event (50/60 for sunrise/set, 6 for civil, 12 for nautical, 18 for
  323. * astronomical dawn/dusk.
  324. * @returns {DateTime} Sunrise or sunset time.
  325. */
  326. // eslint-disable-next-line complexity,require-jsdoc
  327. const sunRiseSet = (datetime, phi, L, flag, offset = 50 / 60) => {
  328. const timezone = datetime.zone;
  329. let suntime = datetime.set({ hour: 0, minute: 0, second: 0, millisecond: 0 })
  330. .setZone('UTC', { keepLocalTime: true });
  331. const deltaT = DeltaT(suntime);
  332. const T = datetimeToT(suntime);
  333. const Theta0 = apparentSiderealTimeGreenwich(T);
  334. // Want 0h TD for this, not UT
  335. const TD = T - (deltaT / (3600 * 24 * 36525));
  336. const alpha = sunApparentRightAscension(TD);
  337. const delta = sunApparentDeclination(TD);
  338. const H0 = approxLocalHourAngle(phi, delta, offset);
  339. // Sign flip for longitude from AA as we take East as positive
  340. let m0 = (alpha - L - Theta0) / 360;
  341. m0 = normalizeM(m0, datetime.offset);
  342. let m;
  343. if (flag === 'RISE') {
  344. m = m0 - H0 / 360;
  345. }
  346. else {
  347. m = m0 + H0 / 360;
  348. }
  349. let counter = 0;
  350. let DeltaM = 1;
  351. // Repeat if correction is larger than ~9s
  352. while ((Math.abs(DeltaM) > 0.0001) && (counter < 3)) {
  353. DeltaM = sunRiseSetCorrection(T, Theta0, deltaT, phi, L, m, offset);
  354. m += DeltaM;
  355. counter++;
  356. }
  357. if (m > 0) {
  358. suntime = suntime.plus({ seconds: Math.floor(m * 3600 * 24 + 0.5) });
  359. }
  360. else {
  361. suntime = suntime.minus({ seconds: Math.floor(m * 3600 * 24 + 0.5) });
  362. }
  363. if (roundToNearestMinute) {
  364. suntime = suntime.plus({ seconds: 30 }).set({ second: 0 });
  365. }
  366. return suntime.setZone(timezone);
  367. };
  368. /**
  369. * Returns a fixed time as given by the hour parameter, an hour later during DST) if the
  370. * specified event does not occur on the date and returnTimeForNoEventCase is true. If
  371. * false, return whether the reason for no event is the sun being too high ('SUN_HIGH')
  372. * or too low ('SUN_LOW').
  373. * @param {DateTime} date The original date from which the event was calculated.
  374. * @param {string|undefined} errorCode The error code in case no event was found
  375. * @param {number} hour Hour to which the returned datetime should be set.
  376. * @param {number} minute Minute to which the returned datetime should be set.
  377. * @returns {(DateTime|string)} Time given by parameter 'hour' (+ correction for
  378. * DST if applicable) or a string indicating why there was no event ('SUN_HIGH'
  379. * or 'SUN_LOW')
  380. */
  381. const handleNoEventCase = (date, errorCode, hour, minute = 0) => {
  382. if (returnTimeForNoEventCase) {
  383. const returnDate = date.set({ hour, minute, second: 0 }).plus({ minutes: date.isInDST ? 60 : 0 });
  384. returnDate.errorCode = errorCode;
  385. return returnDate;
  386. }
  387. return errorCode;
  388. };
  389. /**
  390. * Calculates the approximate local hour angle of the sun at sunrise or sunset.
  391. * @param {number} phi Latitude (see AA p102 Eq15.1).
  392. * @param {number} delta Apparent declination of the sun.
  393. * @param {number} offset number of degrees below the horizon for the desired
  394. * event (50/60 for sunrise/set, 6 for civil, 12 for nautical, 18 for
  395. * astronomical dawn/dusk.
  396. * @returns {number} Approximate local hour angle.
  397. */
  398. const approxLocalHourAngle = (phi, delta, offset) => {
  399. const cosH0 = (sind(-offset) -
  400. sind(phi) * sind(delta)) /
  401. (cosd(phi) * cosd(delta));
  402. if (cosH0 < -1) {
  403. throw noEventCodes.SUN_HIGH;
  404. }
  405. else if (cosH0 > 1) {
  406. throw noEventCodes.SUN_LOW;
  407. }
  408. return rad2deg(Math.acos(cosH0));
  409. };
  410. /**
  411. * Normalizes a fractional time of day to be on the correct date.
  412. * @param {number} m Fractional time of day
  413. * @param {number} utcOffset Offset in minutes from UTC.
  414. * @returns {number} m Normalized m.
  415. */
  416. const normalizeM = (m, utcOffset) => {
  417. const localM = m + utcOffset / 1440;
  418. if (localM < 0) {
  419. return m + 1;
  420. }
  421. else if (localM > 1) {
  422. return m - 1;
  423. }
  424. return m;
  425. };
  426. /**
  427. * Calculates the correction for the solar transit time (see AA p103).
  428. * @param {number} T Fractional number of Julian centuries since
  429. * 2000-01-01T12:00:00Z.
  430. * @param {number} Theta0 Apparent sidereal time at Greenwich.
  431. * @param {number} deltaT ΔT = TT − UT.
  432. * @param {number} L Longitude.
  433. * @param {number} m Fractional time of day of the event.
  434. * @returns {number} Currection for the solar transit time.
  435. */
  436. const sunTransitCorrection = (T, Theta0, deltaT, L, m) => {
  437. const theta0 = Theta0 + 360.985647 * m;
  438. const n = m + deltaT / 864000;
  439. const alpha = interpolatedRa(T, n);
  440. const H = localHourAngle(theta0, L, alpha);
  441. return -H / 360;
  442. };
  443. /**
  444. * Calculates the correction for the sunrise/sunset time (see AA p103).
  445. * @param {number} T Fractional number of Julian centuries since
  446. * 2000-01-01T12:00:00Z.
  447. * @param {number} Theta0 Apparent sidereal time at Greenwich.
  448. * @param {number} deltaT ΔT = TT − UT.
  449. * @param {number} phi Latitude.
  450. * @param {number} L Longitude.
  451. * @param {number} m Fractional time of day of the event.
  452. * @param {number} offset number of degrees below the horizon for the desired
  453. * event (50/60 for sunrise/set, 6 for civil, 12 for nautical, 18 for
  454. * astronomical dawn/dusk.
  455. * @returns {number} Correction for the sunrise/sunset time.
  456. */
  457. const sunRiseSetCorrection = (T, Theta0, deltaT, phi, L, m, offset) => {
  458. const theta0 = Theta0 + 360.985647 * m;
  459. const n = m + deltaT / 864000;
  460. const alpha = interpolatedRa(T, n);
  461. const delta = interpolatedDec(T, n);
  462. const H = localHourAngle(theta0, L, alpha);
  463. const h = altitude(phi, delta, H);
  464. return (h + offset) / (360 * cosd(delta) * cosd(phi) * sind(H));
  465. };
  466. /**
  467. * Calculates the local hour angle of the sun (see AA p103).
  468. * @param {number} theta0 Sidereal time at Greenwich in degrees.
  469. * @param {number} L Longitude.
  470. * @param {number} alpha Apparent right ascension of the sun.
  471. * @returns {number} Local hour angle of the sun.
  472. */
  473. const localHourAngle = (theta0, L, alpha) => {
  474. // Sign flip for longitude
  475. let H = reduceAngle(theta0 + L - alpha);
  476. if (H > 180) {
  477. H -= 360;
  478. }
  479. return H;
  480. };
  481. /**
  482. * Calculates the altitude of the sun above the horizon (see AA P93 Eq13.6).
  483. * @param {number} phi Latitude.
  484. * @param {number} delta Apparent declination of the sun.
  485. * @param {number} H Local hour angle of the sun.
  486. * @returns {number} Altitude of the sun above the horizon.
  487. */
  488. const altitude = (phi, delta, H) => rad2deg(Math.asin(sind(phi) * sind(delta) + cosd(phi) * cosd(delta) * cosd(H)));
  489. /**
  490. * Interpolates the sun's right ascension (see AA p103).
  491. * @param {number} T Fractional number of Julian centuries since
  492. * 2000-01-01T12:00:00Z.
  493. * @param {number} n Fractional time of day of the event corrected by ΔT.
  494. * @returns {number} Interpolated right ascension.
  495. */
  496. const interpolatedRa = (T, n) => {
  497. const alpha1 = sunApparentRightAscension(T - (1 / 36525));
  498. const alpha2 = sunApparentRightAscension(T);
  499. const alpha3 = sunApparentRightAscension(T + (1 / 36525));
  500. const alpha = interpolateFromThree(alpha1, alpha2, alpha3, n, true);
  501. return reduceAngle(alpha);
  502. };
  503. /**
  504. * Interpolates the sun's declination (see AA p103).
  505. * @param {number} T Fractional number of Julian centuries since
  506. * 2000-01-01T12:00:00Z.
  507. * @param {number} n Fractional time of day of the event corrected by ΔT.
  508. * @returns {number} Interpolated declination.
  509. */
  510. const interpolatedDec = (T, n) => {
  511. const delta1 = sunApparentDeclination(T - (1 / 36525));
  512. const delta2 = sunApparentDeclination(T);
  513. const delta3 = sunApparentDeclination(T + (1 / 36525));
  514. const delta = interpolateFromThree(delta1, delta2, delta3, n);
  515. return reduceAngle(delta);
  516. };
  517. /**
  518. * Calculates the apparent right ascension of the sun (see AA p165 Eq25.6).
  519. * @param {number} T Fractional number of Julian centuries since
  520. * 2000-01-01T12:00:00Z.
  521. * @returns {number} Apparent right ascension of the sun.
  522. */
  523. const sunApparentRightAscension = (T) => {
  524. const Omega = moonAscendingNodeLongitude$1(T);
  525. const epsilon = trueObliquityOfEcliptic(T) + 0.00256 * cosd(Omega);
  526. const lambda = sunApparentLongitude(T);
  527. const alpha = rad2deg(Math.atan2(cosd(epsilon) * sind(lambda), cosd(lambda)));
  528. return reduceAngle(alpha);
  529. };
  530. /**
  531. * Calculates the apparent declination of the sun (see AA p165 Eq25.7).
  532. * @param {number} T Fractional number of Julian centuries since
  533. * 2000-01-01T12:00:00Z.
  534. * @returns {number} Apparent declination of the sun.
  535. */
  536. const sunApparentDeclination = (T) => {
  537. const Omega = moonAscendingNodeLongitude$1(T);
  538. const epsilon = trueObliquityOfEcliptic(T) + 0.00256 * cosd(Omega);
  539. const lambda = sunApparentLongitude(T);
  540. return rad2deg(Math.asin(sind(epsilon) * sind(lambda)));
  541. };
  542. /**
  543. * Calculates the apparent sidereal time at Greenwich (see AA p88).
  544. * @param {number} T Fractional number of Julian centuries since
  545. * 2000-01-01T12:00:00Z.
  546. * @returns {number} Apparent sidereal time at Greenwich
  547. */
  548. const apparentSiderealTimeGreenwich = (T) => {
  549. const theta0 = meanSiderealTimeGreenwich(T);
  550. const epsilon = trueObliquityOfEcliptic(T);
  551. const DeltaPsi = nutationInLongitude(T);
  552. const theta = theta0 + DeltaPsi * cosd(epsilon);
  553. return reduceAngle(theta);
  554. };
  555. /**
  556. * Calculates the mean sidereal time at Greenwich (see AA p88 Eq12.4).
  557. * @param {number} T Fractional number of Julian centuries since
  558. * 2000-01-01T12:00:00Z.
  559. * @returns {number} Mean sidereal time at Greenwich
  560. */
  561. const meanSiderealTimeGreenwich = (T) => {
  562. const JD2000 = T * 36525;
  563. return 280.46061837 + 360.98564736629 * JD2000 + 0.000387933 * Math.pow(T, 2) - Math.pow(T, 3) / 38710000;
  564. };
  565. /**
  566. * Calculates the true obliquity of the ecliptic (see AA p147).
  567. * @param {number} T Fractional number of Julian centuries since
  568. * 2000-01-01T12:00:00Z.
  569. * @returns {number} True obliquity of the ecliptic.
  570. */
  571. const trueObliquityOfEcliptic = (T) => {
  572. const epsilon0 = meanObliquityOfEcliptic$1(T);
  573. const DeltaEpsilon = nutationInObliquity(T);
  574. return epsilon0 + DeltaEpsilon;
  575. };
  576. /**
  577. * Calculates the mean obliquity of the ecliptic (see AA p147 Eq 22.3).
  578. * @param {number} T Fractional number of Julian centuries since
  579. * 2000-01-01T12:00:00Z.
  580. * @returns {number} Mean obliquity of the ecliptic.
  581. */
  582. const meanObliquityOfEcliptic$1 = (T) => {
  583. const U = T / 100;
  584. return polynomial(U, meanObliquityOfEcliptic);
  585. };
  586. /**
  587. * Calculates the apparent longitude of the sun (see AA p164).
  588. * @param {number} T Fractional number of Julian centuries since
  589. * 2000-01-01T12:00:00Z.
  590. * @returns {number} Apparent longitude of the sun.
  591. */
  592. const sunApparentLongitude = (T) => {
  593. const Sol = sunTrueLongitude(T);
  594. const Omega = moonAscendingNodeLongitude$1(T);
  595. return Sol - 0.00569 - 0.00478 * sind(Omega);
  596. };
  597. /**
  598. * Calculates the true longitude of the sun (see AA p164).
  599. * @param {number} T Fractional number of Julian centuries since
  600. * 2000-01-01T12:00:00Z.
  601. * @returns {number} True longitude of the sun.
  602. */
  603. const sunTrueLongitude = (T) => {
  604. const L0 = sunMeanLongitude$1(T);
  605. const C = sunEquationOfCenter(T);
  606. return L0 + C;
  607. };
  608. /**
  609. * Calculates the equation of center of the sun (see AA p164).
  610. * @param {number} T Fractional number of Julian centuries since
  611. * 2000-01-01T12:00:00Z.
  612. * @returns {number} Equation of center of the sun.
  613. */
  614. const sunEquationOfCenter = (T) => {
  615. const M = sunMeanAnomaly$1(T);
  616. return (1.914602 - 0.004817 * T - 0.000014 * Math.pow(T, 2)) * sind(M) +
  617. (0.019993 - 0.000101 * T) * sind(2 * M) + 0.000290 * sind(3 * M);
  618. };
  619. /**
  620. * Calculates the nutation in longitude of the sun (see AA p144ff).
  621. * @param {number} T Fractional number of Julian centuries since
  622. * 2000-01-01T12:00:00Z.
  623. * @returns {number} Nutation in longitude of the sun.
  624. */
  625. const nutationInLongitude = (T) => {
  626. const D = moonMeanElongation$1(T);
  627. const M = sunMeanAnomaly$1(T);
  628. const MPrime = moonMeanAnomaly$1(T);
  629. const F = moonArgumentOfLatitude$1(T);
  630. const Omega = moonAscendingNodeLongitude$1(T);
  631. let DeltaPsi = 0;
  632. let sineArg;
  633. for (let i = 0; i < 63; i++) {
  634. sineArg = nutations[i][0] * D + nutations[i][1] * M + nutations[i][2] * MPrime +
  635. nutations[i][3] * F + nutations[i][4] * Omega;
  636. DeltaPsi += (nutations[i][5] + nutations[i][6] * T) * sind(sineArg);
  637. }
  638. return DeltaPsi / 36000000;
  639. };
  640. /**
  641. * Calculates the nutation in obliquity of the sun (see AA p144ff).
  642. * @param {number} T Fractional number of Julian centuries since
  643. * 2000-01-01T12:00:00Z.
  644. * @returns {number} Nutation in obliquity of the sun.
  645. */
  646. const nutationInObliquity = (T) => {
  647. const D = moonMeanElongation$1(T);
  648. const M = sunMeanAnomaly$1(T);
  649. const MPrime = moonMeanAnomaly$1(T);
  650. const F = moonArgumentOfLatitude$1(T);
  651. const Omega = moonAscendingNodeLongitude$1(T);
  652. let DeltaEpsilon = 0;
  653. let cosArg;
  654. for (let i = 0; i < 63; i++) {
  655. cosArg = nutations[i][0] * D + nutations[i][1] * M + nutations[i][2] * MPrime +
  656. nutations[i][3] * F + nutations[i][4] * Omega;
  657. DeltaEpsilon += (nutations[i][7] + nutations[i][8] * T) * cosd(cosArg);
  658. }
  659. return DeltaEpsilon / 36000000;
  660. };
  661. /**
  662. * Calculates the argument of latitude of the moon (see AA p144).
  663. * @param {number} T Fractional number of Julian centuries since
  664. * 2000-01-01T12:00:00Z.
  665. * @returns {number} Argument of latitude of the moon.
  666. */
  667. const moonArgumentOfLatitude$1 = (T) => {
  668. const F = polynomial(T, moonArgumentOfLatitude);
  669. return reduceAngle(F);
  670. };
  671. /**
  672. * Calculates the longitude of the ascending node of the Moon's mean orbit on
  673. * the ecliptic, measured from the mean equinox of the datea (see AA p144).
  674. * @param {number} T Fractional number of Julian centuries since
  675. * 2000-01-01T12:00:00Z.
  676. * @returns {number} Longitude of the asc. node of the moon's mean orbit.
  677. */
  678. const moonAscendingNodeLongitude$1 = (T) => {
  679. const Omega = polynomial(T, moonAscendingNodeLongitude);
  680. return reduceAngle(Omega);
  681. };
  682. /**
  683. * Calculates the mean anomaly of the moon (see AA p144).
  684. * @param {number} T Fractional number of Julian centuries since
  685. * 2000-01-01T12:00:00Z.
  686. * @returns {number} Mean anomaly of the moon.
  687. */
  688. const moonMeanAnomaly$1 = (T) => {
  689. const MPrime = polynomial(T, moonMeanAnomaly);
  690. return reduceAngle(MPrime);
  691. };
  692. /**
  693. * Calculates the mean elongation of the moon from the sun (see AA p144).
  694. * @param {number} T Fractional number of Julian centuries since
  695. * 2000-01-01T12:00:00Z.
  696. * @returns {number} Mean elongation of the moon from the sun.
  697. */
  698. const moonMeanElongation$1 = (T) => {
  699. const D = polynomial(T, moonMeanElongation);
  700. return reduceAngle(D);
  701. };
  702. /**
  703. * Calculates the mean anomaly of the sun (see AA p144).
  704. * @param {number} T Fractional number of Julian centuries since
  705. * 2000-01-01T12:00:00Z.
  706. * @returns {number} Mean anomaly of the sun.
  707. */
  708. const sunMeanAnomaly$1 = (T) => {
  709. const M = polynomial(T, sunMeanAnomaly);
  710. return reduceAngle(M);
  711. };
  712. /**
  713. * Calculates the mean longitude of the sun referred to the mean equinox of the
  714. * date (see AA p163).
  715. * @param {number} T Fractional number of Julian centuries since
  716. * 2000-01-01T12:00:00Z.
  717. * @returns {number} Mean longitude of the sun referred to the mean equinox of
  718. * the date.
  719. */
  720. const sunMeanLongitude$1 = (T) => {
  721. const L0 = polynomial(T, sunMeanLongitude);
  722. return reduceAngle(L0);
  723. };
  724. const noEventCodes = {
  725. SUN_HIGH: 'SUN_HIGH',
  726. SUN_LOW: 'SUN_LOW',
  727. };
  728. /**
  729. * Calculates sunrise on the provided date.
  730. * @param {DateTime} datetime Datetime for which sunrise is calculated. Should
  731. * always contain a timezone or be in UTC, lone UTC offsets might lead to
  732. * unexpected behaviour.
  733. * @param {number} latitude Latitude of target location.
  734. * @param {number} longitude longitude of target location.
  735. * @returns {(DateTime|string)} Time of sunrise or a string indicating that no
  736. * event could be calculated as the sun was too high ('SUN_HIGH') or too low
  737. * ('SUN_LOW') during the entire day (unless returnTimeForNoEventCase is true).
  738. */
  739. const sunrise = (datetime, latitude, longitude) => {
  740. try {
  741. return sunRiseSet(datetime, latitude, longitude, 'RISE');
  742. }
  743. catch (err) {
  744. return handleNoEventCase(datetime, err, 6);
  745. }
  746. };
  747. /**
  748. * Calculates sunset on the provided date.
  749. * @param {DateTime} datetime Datetime for which sunset is calculated. Should
  750. * always contain a timezone or be in UTC, lone UTC offsets might lead to
  751. * unexpected behaviour.
  752. * @param {number} latitude Latitude of target location.
  753. * @param {number} longitude longitude of target location.
  754. * @returns {(DateTime|string)} Time of sunset or a string indicating that no
  755. * event could be calculated as the sun was too high ('SUN_HIGH') or too low
  756. * ('SUN_LOW') during the entire day (unless returnTimeForNoEventCase is true).
  757. */
  758. const sunset = (datetime, latitude, longitude) => {
  759. try {
  760. return sunRiseSet(datetime, latitude, longitude, 'SET');
  761. }
  762. catch (err) {
  763. return handleNoEventCase(datetime, err, 18);
  764. }
  765. };
  766. /**
  767. * Calculates solar noon on the provided date.
  768. * @param {DateTime} datetime Datetime for which solar noon is calculated. Should
  769. * always contain a timezone or be in UTC, lone UTC offsets might lead to
  770. * unexpected behaviour.
  771. * @param {number} longitude longitude of target location.
  772. * @returns {DateTime} Time of solar noon at the given longitude.
  773. */
  774. const solarNoon = (datetime, longitude) => sunTransit(datetime, longitude);
  775. const month = {
  776. 1: 'Bahá',
  777. 2: 'Jalál',
  778. 3: 'Jamál',
  779. 4: '‘Aẓamat',
  780. 5: 'Núr',
  781. 6: 'Raḥmat',
  782. 7: 'Kalimát',
  783. 8: 'Kamál',
  784. 9: 'Asmá’',
  785. 10: '‘Izzat',
  786. 11: 'Ma_sh_íyyat',
  787. 12: '‘Ilm',
  788. 13: 'Qudrat',
  789. 14: 'Qawl',
  790. 15: 'Masá’il',
  791. 16: '_Sh_araf',
  792. 17: 'Sulṭán',
  793. 18: 'Mulk',
  794. 19: '‘Alá’',
  795. 20: 'Ayyám-i-Há',
  796. };
  797. const monthL = {
  798. 1: 'Splendour',
  799. 2: 'Glory',
  800. 3: 'Beauty',
  801. 4: 'Grandeur',
  802. 5: 'Light',
  803. 6: 'Mercy',
  804. 7: 'Words',
  805. 8: 'Perfection',
  806. 9: 'Names',
  807. 10: 'Might',
  808. 11: 'Will',
  809. 12: 'Knowledge',
  810. 13: 'Power',
  811. 14: 'Speech',
  812. 15: 'Questions',
  813. 16: 'Honour',
  814. 17: 'Sovereignty',
  815. 18: 'Dominion',
  816. 19: 'Loftiness',
  817. 20: 'Ayyám-i-Há',
  818. };
  819. const holyDay = {
  820. 1: 'Naw-Rúz',
  821. 2: 'First day of Riḍván',
  822. 3: 'Ninth day of Riḍván',
  823. 4: 'Twelfth day of Riḍván',
  824. 5: 'Declaration of the Báb',
  825. 6: 'Ascension of Bahá’u’lláh',
  826. 7: 'Martyrdom of the Báb',
  827. 8: 'Birth of the Báb',
  828. 9: 'Birth of Bahá’u’lláh',
  829. 10: 'Day of the Covenant',
  830. 11: 'Ascension of ‘Abdu’l-Bahá',
  831. };
  832. // CAREFUL: Numbering corresponds to Badí' week, i.e. 1 is Jalál (-> Saturday)
  833. const weekday = {
  834. 1: 'Jalál',
  835. 2: 'Jamál',
  836. 3: 'Kamál',
  837. 4: 'Fiḍál',
  838. 5: '‘Idál',
  839. 6: 'Istijlál',
  840. 7: 'Istiqlál',
  841. };
  842. const weekdayAbbr3 = {
  843. 1: 'Jal',
  844. 2: 'Jam',
  845. 3: 'Kam',
  846. 4: 'Fiḍ',
  847. 5: '‘Idá',
  848. 6: 'Isj',
  849. 7: 'Isq',
  850. };
  851. const weekdayAbbr2 = {
  852. 1: 'Jl',
  853. 2: 'Jm',
  854. 3: 'Ka',
  855. 4: 'Fi',
  856. 5: '‘Id',
  857. 6: 'Ij',
  858. 7: 'Iq',
  859. };
  860. const weekdayL = {
  861. 1: 'Glory',
  862. 2: 'Beauty',
  863. 3: 'Perfection',
  864. 4: 'Grace',
  865. 5: 'Justice',
  866. 6: 'Majesty',
  867. 7: 'Independence',
  868. };
  869. const yearInVahid = {
  870. 1: 'Alif',
  871. 2: 'Bá’',
  872. 3: 'Ab',
  873. 4: 'Dál',
  874. 5: 'Báb',
  875. 6: 'Váv',
  876. 7: 'Abad',
  877. 8: 'Jád',
  878. 9: 'Bahá',
  879. 10: 'Ḥubb',
  880. 11: 'Bahháj',
  881. 12: 'Javáb',
  882. 13: 'Aḥad',
  883. 14: 'Vahháb',
  884. 15: 'Vidád',
  885. 16: 'Badí‘',
  886. 17: 'Bahí',
  887. 18: 'Abhá',
  888. 19: 'Váḥid',
  889. };
  890. const vahid = 'Váḥid';
  891. const kulliShay = 'Kull-i-_Sh_ay’';
  892. const BE = 'B.E.';
  893. const badiCalendar = 'Badí‘ Calendar';
  894. const unicodeCharForZero = '0';
  895. const defaultFormat = 'd MM+ y BE';
  896. var en = /*#__PURE__*/Object.freeze({
  897. __proto__: null,
  898. month: month,
  899. monthL: monthL,
  900. holyDay: holyDay,
  901. weekday: weekday,
  902. weekdayAbbr3: weekdayAbbr3,
  903. weekdayAbbr2: weekdayAbbr2,
  904. weekdayL: weekdayL,
  905. yearInVahid: yearInVahid,
  906. vahid: vahid,
  907. kulliShay: kulliShay,
  908. BE: BE,
  909. badiCalendar: badiCalendar,
  910. unicodeCharForZero: unicodeCharForZero,
  911. defaultFormat: defaultFormat
  912. });
  913. const month$1 = {
  914. 1: 'البهاء',
  915. 2: 'الجلال',
  916. 3: 'الجمال',
  917. 4: 'العظمة',
  918. 5: 'النور',
  919. 6: 'الرحمة',
  920. 7: 'الكلمات',
  921. 8: 'الكمال',
  922. 9: 'الأسماء',
  923. 10: 'العزّة',
  924. 11: 'المشية',
  925. 12: 'العلم',
  926. 13: 'القدرة',
  927. 14: 'القول',
  928. 15: 'المسائل',
  929. 16: 'الشرف',
  930. 17: 'السلطان',
  931. 18: 'الملك',
  932. 19: 'العلاء',
  933. 20: 'ايام الهاء',
  934. };
  935. const monthL$1 = month$1;
  936. const holyDay$1 = {
  937. 1: 'عيد النَّيروز',
  938. 2: 'اليوم الأول من عيد الرِّضوان',
  939. 3: 'اليوم التاسع من عيد الرِّضوان',
  940. 4: 'اليوم الثاني عشر من عيد الرِّضوان',
  941. 5: 'يوم إعلان دعوة حضرة الباب',
  942. 6: 'يوم صعود حضرة بهاء الله',
  943. 7: 'يوم استشهاد حضرة الباب',
  944. 8: 'يوم ولادة حضرة الباب',
  945. 9: 'يوم ولادة حضرة بهاء الله',
  946. 10: 'يوم الميثاق',
  947. 11: 'يوم صعود حضرة عبد البهاء',
  948. };
  949. const weekday$1 = {
  950. 1: 'الجلال',
  951. 2: 'الجمال',
  952. 3: 'الكمال',
  953. 4: 'الفضّال',
  954. 5: 'العدّال',
  955. 6: 'الأستجلال',
  956. 7: 'الاستقلال',
  957. };
  958. const weekdayAbbr3$1 = {
  959. 1: 'جلا',
  960. 2: 'جما',
  961. 3: 'كما',
  962. 4: 'فضّا',
  963. 5: 'عدّا',
  964. 6: 'اسج',
  965. 7: 'اسق',
  966. };
  967. const weekdayAbbr2$1 = {
  968. 1: 'جل',
  969. 2: 'جم',
  970. 3: 'كم',
  971. 4: 'فض',
  972. 5: 'عد',
  973. 6: 'اج',
  974. 7: 'اق',
  975. };
  976. const weekdayL$1 = {
  977. 1: 'الجلال',
  978. 2: 'الجمال',
  979. 3: 'الكمال',
  980. 4: 'الفضّال',
  981. 5: 'العدّال',
  982. 6: 'الأستجلال',
  983. 7: 'أستقلال',
  984. };
  985. const yearInVahid$1 = {
  986. 1: 'ألف',
  987. 2: 'باء',
  988. 3: 'أب',
  989. 4: 'دﺍﻝ',
  990. 5: 'باب',
  991. 6: 'وﺍو',
  992. 7: 'أبد',
  993. 8: 'جاد',
  994. 9: 'بهاء',
  995. 10: 'حب',
  996. 11: 'بهاج',
  997. 12: 'جواب',
  998. 13: 'احد',
  999. 14: 'وﻫﺎب',
  1000. 15: 'وداد',
  1001. 16: 'بدیع',
  1002. 17: 'بهي',
  1003. 18: 'ابهى',
  1004. 19: 'واحد',
  1005. };
  1006. const vahid$1 = 'واحد';
  1007. const kulliShay$1 = 'كل شيء';
  1008. const BE$1 = 'بديع';
  1009. const badiCalendar$1 = 'تقويم بديع';
  1010. const unicodeCharForZero$1 = '٠';
  1011. const defaultFormat$1 = '&#8207;d MM y BE&#8207;';
  1012. var ar = /*#__PURE__*/Object.freeze({
  1013. __proto__: null,
  1014. month: month$1,
  1015. monthL: monthL$1,
  1016. holyDay: holyDay$1,
  1017. weekday: weekday$1,
  1018. weekdayAbbr3: weekdayAbbr3$1,
  1019. weekdayAbbr2: weekdayAbbr2$1,
  1020. weekdayL: weekdayL$1,
  1021. yearInVahid: yearInVahid$1,
  1022. vahid: vahid$1,
  1023. kulliShay: kulliShay$1,
  1024. BE: BE$1,
  1025. badiCalendar: badiCalendar$1,
  1026. unicodeCharForZero: unicodeCharForZero$1,
  1027. defaultFormat: defaultFormat$1
  1028. });
  1029. const monthL$2 = {
  1030. 1: 'Herrlichkeit',
  1031. 2: 'Ruhm',
  1032. 3: 'Schönheit',
  1033. 4: 'Größe',
  1034. 5: 'Licht',
  1035. 6: 'Barmherzigkeit',
  1036. 7: 'Worte',
  1037. 8: 'Vollkommenheit',
  1038. 9: 'Namen',
  1039. 10: 'Macht',
  1040. 11: 'Wille',
  1041. 12: 'Wissen',
  1042. 13: 'Kraft',
  1043. 14: 'Sprache',
  1044. 15: 'Fragen',
  1045. 16: 'Ehre',
  1046. 17: 'Souveränität',
  1047. 18: 'Herrschaft',
  1048. 19: 'Erhabenheit',
  1049. 20: 'Ayyám-i-Há',
  1050. };
  1051. const holyDay$2 = {
  1052. 1: 'Naw-Rúz',
  1053. 2: 'Erster Riḍván-Tag',
  1054. 3: 'Neunter Riḍván-Tag',
  1055. 4: 'Zwölfter Riḍván-Tag',
  1056. 5: 'Erklärung des Báb',
  1057. 6: 'Hinscheiden Bahá’u’lláhs',
  1058. 7: 'Märtyrertod des Báb',
  1059. 8: 'Geburt des Báb',
  1060. 9: 'Geburt Bahá’u’lláhs',
  1061. 10: 'Tag des Bundes',
  1062. 11: 'Hinscheiden ‘Abdu’l-Bahás',
  1063. };
  1064. const weekdayL$2 = {
  1065. 1: 'Ruhm',
  1066. 2: 'Schönheit',
  1067. 3: 'Vollkommenheit',
  1068. 4: 'Gnade',
  1069. 5: 'Gerechtigkeit',
  1070. 6: 'Majestät',
  1071. 7: 'Unabhängigkeit',
  1072. };
  1073. const BE$2 = 'B.E.';
  1074. const badiCalendar$2 = 'Badí‘ Kalender';
  1075. var de = /*#__PURE__*/Object.freeze({
  1076. __proto__: null,
  1077. monthL: monthL$2,
  1078. holyDay: holyDay$2,
  1079. weekdayL: weekdayL$2,
  1080. BE: BE$2,
  1081. badiCalendar: badiCalendar$2
  1082. });
  1083. const monthL$3 = {
  1084. 1: 'Esplendor',
  1085. 2: 'Gloria',
  1086. 3: 'Belleza',
  1087. 4: 'Grandeza',
  1088. 5: 'Luz',
  1089. 6: 'Misericordia',
  1090. 7: 'Palabras',
  1091. 8: 'Perfección',
  1092. 9: 'Nombres',
  1093. 10: 'Fuerza',
  1094. 11: 'Voluntad',
  1095. 12: 'Conocimiento',
  1096. 13: 'Poder',
  1097. 14: 'Discurso',
  1098. 15: 'Preguntas',
  1099. 16: 'Honor',
  1100. 17: 'Soberanía',
  1101. 18: 'Dominio',
  1102. 19: 'Sublimidad',
  1103. 20: 'Ayyám-i-Há',
  1104. };
  1105. const holyDay$3 = {
  1106. 1: 'Naw-Rúz',
  1107. 2: 'Primer día de Riḍván',
  1108. 3: 'Noveno día de Riḍván',
  1109. 4: 'Duodécimo día de Riḍván',
  1110. 5: 'Declaración del Báb',
  1111. 6: 'Ascensión de Bahá’u’lláh',
  1112. 7: 'Martirio del Báb',
  1113. 8: 'Nacimiento del Báb',
  1114. 9: 'Nacimiento de Bahá’u’lláh',
  1115. 10: 'Día de la Alianza',
  1116. 11: 'Fallecimiento de ‘Abdu’l-Bahá',
  1117. };
  1118. const weekdayL$3 = {
  1119. 1: 'Gloria',
  1120. 2: 'Belleza',
  1121. 3: 'Perfección',
  1122. 4: 'Gracia',
  1123. 5: 'Justicia',
  1124. 6: 'Majestuosidad',
  1125. 7: 'Independencia',
  1126. };
  1127. const BE$3 = 'E.B.';
  1128. const badiCalendar$3 = 'Calendario Badí‘';
  1129. var es = /*#__PURE__*/Object.freeze({
  1130. __proto__: null,
  1131. monthL: monthL$3,
  1132. holyDay: holyDay$3,
  1133. weekdayL: weekdayL$3,
  1134. BE: BE$3,
  1135. badiCalendar: badiCalendar$3
  1136. });
  1137. const month$2 = {
  1138. 1: 'البهاء',
  1139. 2: 'الجلال',
  1140. 3: 'الجمال',
  1141. 4: 'العظمة',
  1142. 5: 'النور',
  1143. 6: 'الرحمة',
  1144. 7: 'الكلمات',
  1145. 8: 'الكمال',
  1146. 9: 'الأسماء',
  1147. 10: 'العزّة',
  1148. 11: 'المشية',
  1149. 12: 'العلم',
  1150. 13: 'القدرة',
  1151. 14: 'القول',
  1152. 15: 'المسائل',
  1153. 16: 'الشرف',
  1154. 17: 'السلطان',
  1155. 18: 'الملك',
  1156. 19: 'العلاء',
  1157. 20: 'ايام الهاء',
  1158. };
  1159. const monthL$4 = {
  1160. 1: 'بهاء',
  1161. 2: 'جلال',
  1162. 3: 'جمال',
  1163. 4: 'عظمت',
  1164. 5: 'نور',
  1165. 6: 'رحمت',
  1166. 7: 'كلمات',
  1167. 8: 'كمال',
  1168. 9: 'أسماء',
  1169. 10: 'عزّت',
  1170. 11: 'مشيت',
  1171. 12: 'علم',
  1172. 13: 'قدرت',
  1173. 14: 'قول',
  1174. 15: 'مسائل',
  1175. 16: 'شرف',
  1176. 17: 'سلطان',
  1177. 18: 'ملك',
  1178. 19: 'علاء',
  1179. 20: 'ايام ها',
  1180. };
  1181. const holyDay$4 = {
  1182. 1: 'عید نوروز',
  1183. 2: 'روز اوّل عید رضوان',
  1184. 3: 'روز نهم عید رضوان',
  1185. 4: 'روز دوازدهم عید رضوان',
  1186. 5: 'بعثت حضرت باب',
  1187. 6: 'صعود حضرت بهاالله',
  1188. 7: 'شهادت حضرت اعلی',
  1189. 8: 'تولّد حضرت اعلی',
  1190. 9: 'تولّد حضرت بهالله',
  1191. 10: 'روز عهد و میثاق',
  1192. 11: 'صعود حضرت عبدالبها',
  1193. };
  1194. const weekday$2 = {
  1195. 1: 'یوم الجلال',
  1196. 2: 'یوم الجمال',
  1197. 3: 'یوم الكمال',
  1198. 4: 'یوم الفضّال',
  1199. 5: 'یوم العدّال',
  1200. 6: 'یوم الأستجلال',
  1201. 7: 'یوم الاستقلال',
  1202. };
  1203. const weekdayAbbr3$2 = {
  1204. 1: 'جلا',
  1205. 2: 'جما',
  1206. 3: 'كما',
  1207. 4: 'فضّا',
  1208. 5: 'عدّا',
  1209. 6: 'اسج',
  1210. 7: 'اسق',
  1211. };
  1212. const weekdayAbbr2$2 = {
  1213. 1: 'جل',
  1214. 2: 'جم',
  1215. 3: 'كم',
  1216. 4: 'فض',
  1217. 5: 'عد',
  1218. 6: 'اج',
  1219. 7: 'اق',
  1220. };
  1221. const weekdayL$4 = {
  1222. 1: 'جلال',
  1223. 2: 'جمال',
  1224. 3: 'كمال',
  1225. 4: 'فضّال',
  1226. 5: 'عدّال',
  1227. 6: 'استجلال',
  1228. 7: 'استقلال',
  1229. };
  1230. const yearInVahid$2 = {
  1231. 1: 'ألف',
  1232. 2: 'باء',
  1233. 3: 'أب',
  1234. 4: 'دﺍﻝ',
  1235. 5: 'باب',
  1236. 6: 'وﺍو',
  1237. 7: 'أبد',
  1238. 8: 'جاد',
  1239. 9: 'بهاء',
  1240. 10: 'حب',
  1241. 11: 'بهاج',
  1242. 12: 'جواب',
  1243. 13: 'احد',
  1244. 14: 'وﻫﺎب',
  1245. 15: 'وداد',
  1246. 16: 'بدیع',
  1247. 17: 'بهي',
  1248. 18: 'ابهى',
  1249. 19: 'واحد',
  1250. };
  1251. const vahid$2 = 'واحد';
  1252. const kulliShay$2 = 'كل شيء';
  1253. const BE$4 = 'بديع';
  1254. const badiCalendar$4 = 'تقويم بديع';
  1255. const unicodeCharForZero$2 = '۰';
  1256. const defaultFormat$2 = '&#8207;d MML y BE&#8207;';
  1257. var fa = /*#__PURE__*/Object.freeze({
  1258. __proto__: null,
  1259. month: month$2,
  1260. monthL: monthL$4,
  1261. holyDay: holyDay$4,
  1262. weekday: weekday$2,
  1263. weekdayAbbr3: weekdayAbbr3$2,
  1264. weekdayAbbr2: weekdayAbbr2$2,
  1265. weekdayL: weekdayL$4,
  1266. yearInVahid: yearInVahid$2,
  1267. vahid: vahid$2,
  1268. kulliShay: kulliShay$2,
  1269. BE: BE$4,
  1270. badiCalendar: badiCalendar$4,
  1271. unicodeCharForZero: unicodeCharForZero$2,
  1272. defaultFormat: defaultFormat$2
  1273. });
  1274. const monthL$5 = {
  1275. 1: 'Splendeur',
  1276. 2: 'Gloire',
  1277. 3: 'Beauté',
  1278. 4: 'Grandeur',
  1279. 5: 'Lumière',
  1280. 6: 'Miséricorde',
  1281. 7: 'Paroles',
  1282. 8: 'Perfection',
  1283. 9: 'Noms',
  1284. 10: 'Puissance',
  1285. 11: 'Volonté',
  1286. 12: 'Connaissance',
  1287. 13: 'Pouvoir',
  1288. 14: 'Discours',
  1289. 15: 'Questions',
  1290. 16: 'Honneur',
  1291. 17: 'Souveraineté',
  1292. 18: 'Empire',
  1293. 19: 'Élévation',
  1294. 20: 'Ayyám-i-Há',
  1295. };
  1296. const holyDay$5 = {
  1297. 1: 'Naw-Rúz',
  1298. 2: 'Premier jour de Riḍván',
  1299. 3: 'Neuvième jour de Riḍván',
  1300. 4: 'Douzième jour de Riḍván',
  1301. 5: 'Déclaration du Báb',
  1302. 6: 'Ascension de Bahá’u’lláh',
  1303. 7: 'Martyre du Báb',
  1304. 8: 'Naissance du Báb',
  1305. 9: 'Naissance de Bahá’u’lláh',
  1306. 10: 'Jour de l’Alliance',
  1307. 11: 'Ascension de ‘Abdu’l-Bahá',
  1308. };
  1309. const weekdayL$5 = {
  1310. 1: 'Gloire',
  1311. 2: 'Beauté',
  1312. 3: 'Perfection',
  1313. 4: 'Grâce',
  1314. 5: 'Justice',
  1315. 6: 'Majesté',
  1316. 7: 'Indépendance',
  1317. };
  1318. const BE$5 = 'E.B.';
  1319. const badiCalendar$5 = 'Calendrier Badí‘';
  1320. var fr = /*#__PURE__*/Object.freeze({
  1321. __proto__: null,
  1322. monthL: monthL$5,
  1323. holyDay: holyDay$5,
  1324. weekdayL: weekdayL$5,
  1325. BE: BE$5,
  1326. badiCalendar: badiCalendar$5
  1327. });
  1328. const monthL$6 = {
  1329. 1: 'Spožums',
  1330. 2: 'Slava',
  1331. 3: 'Skaistums',
  1332. 4: 'Dižums',
  1333. 5: 'Gaisma',
  1334. 6: 'Žēlastība',
  1335. 7: 'Vārdi',
  1336. 8: 'Pilnība',
  1337. 9: 'Nosaukumi',
  1338. 10: 'Varenība',
  1339. 11: 'Griba',
  1340. 12: 'Zināšanas',
  1341. 13: 'Vara',
  1342. 14: 'Runa',
  1343. 15: 'Jautājumi',
  1344. 16: 'Gods',
  1345. 17: 'Suverenitāte',
  1346. 18: 'Valdīšana',
  1347. 19: 'Cēlums',
  1348. 20: 'Ayyám-i-Há',
  1349. };
  1350. const holyDay$6 = {
  1351. 1: 'Naw-Rúz',
  1352. 2: 'Riḍván pirmā diena',
  1353. 3: 'Riḍván devītā diena',
  1354. 4: 'Riḍván divpadsmitā diena',
  1355. 5: 'Bába paziņojums',
  1356. 6: 'Bahá’u’lláh Debessbraukšana',
  1357. 7: 'Bába mocekļa nāve',
  1358. 8: 'Bába dzimšanas diena',
  1359. 9: 'Bahá’u’lláh dzimšanas diena',
  1360. 10: 'Derības diena',
  1361. 11: '‘Abdu’l-Bahá Debessbraukšana',
  1362. };
  1363. const weekdayL$6 = {
  1364. 1: 'Slava',
  1365. 2: 'Skaistums',
  1366. 3: 'Pilnība',
  1367. 4: 'Žēlastība',
  1368. 5: 'Taisnīgums',
  1369. 6: 'Majestātiskums',
  1370. 7: 'Neatkarība',
  1371. };
  1372. const BE$6 = 'B.Ē.';
  1373. const badiCalendar$6 = 'Badí‘ kalendārs';
  1374. var lv = /*#__PURE__*/Object.freeze({
  1375. __proto__: null,
  1376. monthL: monthL$6,
  1377. holyDay: holyDay$6,
  1378. weekdayL: weekdayL$6,
  1379. BE: BE$6,
  1380. badiCalendar: badiCalendar$6
  1381. });
  1382. const monthL$7 = {
  1383. 1: 'Pracht',
  1384. 2: 'Heerlijkheid',
  1385. 3: 'Schoonheid',
  1386. 4: 'Grootheid',
  1387. 5: 'Licht',
  1388. 6: 'Barmhartigheid',
  1389. 7: 'Woorden',
  1390. 8: 'Volmaaktheid',
  1391. 9: 'Namen',
  1392. 10: 'Macht',
  1393. 11: 'Wil',
  1394. 12: 'Kennis',
  1395. 13: 'Kracht',
  1396. 14: 'Spraak',
  1397. 15: 'Vragen',
  1398. 16: 'Eer',
  1399. 17: 'Soevereiniteit',
  1400. 18: 'Heerschappij',
  1401. 19: 'Verhevenheid',
  1402. 20: 'Ayyám-i-Há',
  1403. };
  1404. const holyDay$7 = {
  1405. 1: 'Naw-Rúz',
  1406. 2: 'Eerste dag van Riḍván',
  1407. 3: 'Negende dag van Riḍván',
  1408. 4: 'Twaalfde dag van Riḍván',
  1409. 5: 'Verkondiging van de Báb',
  1410. 6: 'Heengaan van Bahá’u’lláh',
  1411. 7: 'Marteldood van de Báb',
  1412. 8: 'Geboortedag van de Báb',
  1413. 9: 'Geboortedag van Bahá’u’lláh',
  1414. 10: 'Dag van het Verbond',
  1415. 11: 'Heengaan van ‘Abdu’l-Bahá',
  1416. };
  1417. const weekdayL$7 = {
  1418. 1: 'Heerlijkheid',
  1419. 2: 'Schoonheid',
  1420. 3: 'Volmaaktheid',
  1421. 4: 'Genade',
  1422. 5: 'Gerechtigheid',
  1423. 6: 'Majesteit',
  1424. 7: 'Onafhankelijkheid',
  1425. };
  1426. const BE$7 = 'B.E.';
  1427. const badiCalendar$7 = 'Badí‘-Kalender';
  1428. var nl = /*#__PURE__*/Object.freeze({
  1429. __proto__: null,
  1430. monthL: monthL$7,
  1431. holyDay: holyDay$7,
  1432. weekdayL: weekdayL$7,
  1433. BE: BE$7,
  1434. badiCalendar: badiCalendar$7
  1435. });
  1436. const monthL$8 = {
  1437. 1: 'Esplendor',
  1438. 2: 'Glória',
  1439. 3: 'Beleza',
  1440. 4: 'Grandeza',
  1441. 5: 'Luz',
  1442. 6: 'Miséricórdia',
  1443. 7: 'Palavras',
  1444. 8: 'Perfeição',
  1445. 9: 'Nomes',
  1446. 10: 'Potência',
  1447. 11: 'Vontade',
  1448. 12: 'Conhecimento',
  1449. 13: 'Poder',
  1450. 14: 'Discurso',
  1451. 15: 'Perguntas',
  1452. 16: 'Honra',
  1453. 17: 'Soberania',
  1454. 18: 'Domínio',
  1455. 19: 'Sublimidade',
  1456. 20: 'Ayyám-i-Há',
  1457. };
  1458. const holyDay$8 = {
  1459. 1: 'Naw-Rúz',
  1460. 2: '1º dia do Riḍván',
  1461. 3: '9º dia do Riḍván',
  1462. 4: '12º dia do Riḍván',
  1463. 5: 'Declaração do Báb',
  1464. 6: 'Ascensão de Bahá’u’lláh',
  1465. 7: 'Martírio do Báb',
  1466. 8: 'Aniversário do Báb',
  1467. 9: 'Aniversário de Bahá’u’lláh',
  1468. 10: 'Dia do Convênio',
  1469. 11: 'Ascensão de ‘Abdu’l-Bahá',
  1470. };
  1471. const weekdayL$8 = {
  1472. 1: 'Glória',
  1473. 2: 'Beleza',
  1474. 3: 'Perfeição',
  1475. 4: 'Graça',
  1476. 5: 'Justiça',
  1477. 6: 'Majestade',
  1478. 7: 'Independência',
  1479. };
  1480. const BE$8 = 'E.B.';
  1481. const badiCalendar$8 = 'Calendário Badí‘';
  1482. var pt = /*#__PURE__*/Object.freeze({
  1483. __proto__: null,
  1484. monthL: monthL$8,
  1485. holyDay: holyDay$8,
  1486. weekdayL: weekdayL$8,
  1487. BE: BE$8,
  1488. badiCalendar: badiCalendar$8
  1489. });
  1490. const month$3 = {
  1491. 1: 'Бахā',
  1492. 2: 'Джалāл',
  1493. 3: 'Джамāл',
  1494. 4: '‘Аз̣амат',
  1495. 5: 'Нӯр',
  1496. 6: 'Рах̣мат',
  1497. 7: 'Калимāт',
  1498. 8: 'Камāл',
  1499. 9: 'Асмā’',
  1500. 10: '‘Иззат',
  1501. 11: 'Машӣййат',
  1502. 12: '‘Илм',
  1503. 13: 'К̣удрат',
  1504. 14: 'К̣аул',
  1505. 15: 'Масā’ил',
  1506. 16: 'Шараф',
  1507. 17: 'Султ̣ан',
  1508. 18: 'Мулк',
  1509. 19: '‘Алā’',
  1510. 20: 'Аййāм-и Хā',
  1511. };
  1512. const monthL$9 = {
  1513. 1: 'Великолепие',
  1514. 2: 'Слава',
  1515. 3: 'Красота',
  1516. 4: 'Величие',
  1517. 5: 'Свет',
  1518. 6: 'Милость',
  1519. 7: 'Слова',
  1520. 8: 'Совершенство',
  1521. 9: 'Имена',
  1522. 10: 'Мощь',
  1523. 11: 'Воля',
  1524. 12: 'Знание',
  1525. 13: 'Могущество',
  1526. 14: 'Речь',
  1527. 15: 'Вопросы',
  1528. 16: 'Честь',
  1529. 17: 'Владычество',
  1530. 18: 'Господство',
  1531. 19: 'Возвышенность',
  1532. 20: 'Аййāм-и Хā',
  1533. };
  1534. const holyDay$9 = {
  1535. 1: 'Нау-Рӯз',
  1536. 2: '1-й день Рид̣вāна',
  1537. 3: '9-й день Рид̣вāна',
  1538. 4: '12-й день Рид̣вāна',
  1539. 5: 'Возвещение Баба',
  1540. 6: 'Вознесение Бахауллы',
  1541. 7: 'Мученическая Баба',
  1542. 8: 'рождения Баба',
  1543. 9: 'рождения Бахауллы',
  1544. 10: 'День Завета',
  1545. 11: 'Вознесение Абдул-Баха',
  1546. };
  1547. const weekday$3 = {
  1548. 1: 'Джалāл',
  1549. 2: 'Джамāл',
  1550. 3: 'Камāл',
  1551. 4: 'Фид̣āл',
  1552. 5: '‘Идāл',
  1553. 6: 'Истиджлāл',
  1554. 7: 'Истик̣лāл',
  1555. };
  1556. const weekdayAbbr3$3 = {
  1557. 1: 'Джл',
  1558. 2: 'Джм',
  1559. 3: 'Кам',
  1560. 4: 'Фид̣',
  1561. 5: '‘Идā',
  1562. 6: 'Исд',
  1563. 7: 'Иск̣',
  1564. };
  1565. const weekdayAbbr2$3 = {
  1566. 1: 'Дл',
  1567. 2: 'Дм',
  1568. 3: 'Ка',
  1569. 4: 'Фи',
  1570. 5: '‘Ид',
  1571. 6: 'Ид',
  1572. 7: 'Ик̣',
  1573. };
  1574. const weekdayL$9 = {
  1575. 1: 'Слава',
  1576. 2: 'Красота',
  1577. 3: 'Совершенство',
  1578. 4: 'Благодать',
  1579. 5: 'Справедливость',
  1580. 6: 'Величие',
  1581. 7: 'Независимость',
  1582. };
  1583. const yearInVahid$3 = {
  1584. 1: 'Алиф',
  1585. 2: 'Бā’',
  1586. 3: 'Аб',
  1587. 4: 'Дāл',
  1588. 5: 'Бāб',
  1589. 6: 'Вāв',
  1590. 7: 'Абад',
  1591. 8: 'Джāд',
  1592. 9: 'Бахā',
  1593. 10: 'Х̣убб',
  1594. 11: 'Баххāдж',
  1595. 12: 'Джавāб',
  1596. 13: 'Ах̣ад',
  1597. 14: 'Ваххāб',
  1598. 15: 'Видāд',
  1599. 16: 'Бадӣ‘',
  1600. 17: 'Бахӣ',
  1601. 18: 'Абхā',
  1602. 19: 'Вāх̣ид',
  1603. };
  1604. const vahid$3 = 'Вāх̣ид';
  1605. const kulliShay$3 = 'кулл-и шай’';
  1606. const BE$9 = 'Э.Б.';
  1607. const badiCalendar$9 = 'Календарь Бадӣ‘';
  1608. var ru = /*#__PURE__*/Object.freeze({
  1609. __proto__: null,
  1610. month: month$3,
  1611. monthL: monthL$9,
  1612. holyDay: holyDay$9,
  1613. weekday: weekday$3,
  1614. weekdayAbbr3: weekdayAbbr3$3,
  1615. weekdayAbbr2: weekdayAbbr2$3,
  1616. weekdayL: weekdayL$9,
  1617. yearInVahid: yearInVahid$3,
  1618. vahid: vahid$3,
  1619. kulliShay: kulliShay$3,
  1620. BE: BE$9,
  1621. badiCalendar: badiCalendar$9
  1622. });
  1623. const monthL$a = {
  1624. 1: 'Praktfullhet',
  1625. 2: 'Härlighet',
  1626. 3: 'Skönhet',
  1627. 4: 'Storhet',
  1628. 5: 'Ljus',
  1629. 6: 'Barmhärtighet',
  1630. 7: 'Ord',
  1631. 8: 'Fullkomlighet',
  1632. 9: 'Namn',
  1633. 10: 'Makt',
  1634. 11: 'Vilja',
  1635. 12: 'Kunskap',
  1636. 13: 'Kraft',
  1637. 14: 'Tal',
  1638. 15: 'Frågor',
  1639. 16: 'Ära',
  1640. 17: 'Överhöghet',
  1641. 18: 'Herravälde',
  1642. 19: 'Upphöjdhet',
  1643. 20: 'Ayyám-i-Há',
  1644. };
  1645. const holyDay$a = {
  1646. 1: 'Naw-Rúz',
  1647. 2: 'Första Riḍván',
  1648. 3: 'Nionde Riḍván',
  1649. 4: 'Tolfte Riḍván',
  1650. 5: 'Bábs Deklaration',
  1651. 6: 'Bahá’u’lláhs Bortgång',
  1652. 7: 'Bábs Martyrskap',
  1653. 8: 'Bábs Födelse',
  1654. 9: 'Bahá’u’lláhs Födelse',
  1655. 10: 'Förbundets dag',
  1656. 11: '‘Abdu’l-Bahás Bortgång',
  1657. };
  1658. const weekdayL$a = {
  1659. 1: 'Härlighet',
  1660. 2: 'Skönhet',
  1661. 3: 'Fullkomlighet',
  1662. 4: 'Nåd',
  1663. 5: 'Rättvisa',
  1664. 6: 'Majestät',
  1665. 7: 'Oberoende',
  1666. };
  1667. const BE$a = 'B.E.';
  1668. const badiCalendar$a = 'Badí‘kalendern';
  1669. var sv = /*#__PURE__*/Object.freeze({
  1670. __proto__: null,
  1671. monthL: monthL$a,
  1672. holyDay: holyDay$a,
  1673. weekdayL: weekdayL$a,
  1674. BE: BE$a,
  1675. badiCalendar: badiCalendar$a
  1676. });
  1677. const month$4 = {
  1678. 1: '巴哈',
  1679. 2: '贾拉勒',
  1680. 3: '贾迈勒',
  1681. 4: '阿泽迈特',
  1682. 5: '努尔',
  1683. 6: '拉赫迈特',
  1684. 7: '凯利马特',
  1685. 8: '卡迈勒',
  1686. 9: '艾斯玛',
  1687. 10: '伊扎特',
  1688. 11: '迈希耶特',
  1689. 12: '伊勒姆',
  1690. 13: '古德雷特',
  1691. 14: '高勒',
  1692. 15: '迈萨伊勒',
  1693. 16: '谢拉夫',
  1694. 17: '苏丹',
  1695. 18: '穆勒克',
  1696. 19: '阿拉',
  1697. 20: '阿亚米哈',
  1698. };
  1699. const monthL$b = {
  1700. 1: '耀',
  1701. 2: '辉',
  1702. 3: '美',
  1703. 4: '宏',
  1704. 5: '光',
  1705. 6: '仁',
  1706. 7: '言',
  1707. 8: '完',
  1708. 9: '名',
  1709. 10: '能',
  1710. 11: '意',
  1711. 12: '知',
  1712. 13: '力',
  1713. 14: '语',
  1714. 15: '问',
  1715. 16: '尊',
  1716. 17: '权',
  1717. 18: '统',
  1718. 19: '崇',
  1719. 20: '哈之日',
  1720. };
  1721. const holyDay$b = {
  1722. 1: '诺鲁孜节',
  1723. 2: '里兹万节第一日',
  1724. 3: '里兹万节第九日',
  1725. 4: '里兹万节第十二日',
  1726. 5: '巴孛宣示日',
  1727. 6: '巴哈欧拉升天日',
  1728. 7: '巴孛殉道日',
  1729. 8: '巴孛诞辰',
  1730. 9: '巴哈欧拉诞辰',
  1731. 10: '圣约日',
  1732. 11: '阿博都-巴哈升天日',
  1733. };
  1734. const weekday$4 = {
  1735. 1: '贾拉勒',
  1736. 2: '贾迈勒',
  1737. 3: '卡迈勒',
  1738. 4: '菲达勒',
  1739. 5: '伊达勒',
  1740. 6: '伊斯提杰拉勒',
  1741. 7: '伊斯提格拉勒',
  1742. };
  1743. const weekdayAbbr3$4 = {
  1744. 1: '贾拉勒',
  1745. 2: '贾迈勒',
  1746. 3: '卡迈勒',
  1747. 4: '菲达勒',
  1748. 5: '伊达勒',
  1749. 6: '伊斯杰',
  1750. 7: '伊斯格',
  1751. };
  1752. const weekdayAbbr2$4 = {
  1753. 1: '贾拉',
  1754. 2: '贾迈',
  1755. 3: '卡迈',
  1756. 4: '菲达',
  1757. 5: '伊达',
  1758. 6: '伊杰',
  1759. 7: '伊格',
  1760. };
  1761. const weekdayL$b = {
  1762. 1: '辉日',
  1763. 2: '美日',
  1764. 3: '完日',
  1765. 4: '恩日',
  1766. 5: '正日',
  1767. 6: '威日',
  1768. 7: '独日',
  1769. };
  1770. const yearInVahid$4 = {
  1771. 1: '艾利夫',
  1772. 2: '巴',
  1773. 3: '艾卜',
  1774. 4: '达勒',
  1775. 5: '巴卜',
  1776. 6: '瓦乌',
  1777. 7: '阿巴德',
  1778. 8: '贾德',
  1779. 9: '巴哈',
  1780. 10: '胡卜',
  1781. 11: '巴哈杰',
  1782. 12: '贾瓦卜',
  1783. 13: '阿哈德',
  1784. 14: '瓦哈卜',
  1785. 15: '维达德',
  1786. 16: '巴迪',
  1787. 17: '巴希',
  1788. 18: '阿卜哈',
  1789. 19: '瓦希德',
  1790. };
  1791. const vahid$4 = '瓦希德';
  1792. const kulliShay$4 = '库里沙伊';
  1793. const BE$b = 'BE';
  1794. const badiCalendar$b = '巴迪历';
  1795. var zh = /*#__PURE__*/Object.freeze({
  1796. __proto__: null,
  1797. month: month$4,
  1798. monthL: monthL$b,
  1799. holyDay: holyDay$b,
  1800. weekday: weekday$4,
  1801. weekdayAbbr3: weekdayAbbr3$4,
  1802. weekdayAbbr2: weekdayAbbr2$4,
  1803. weekdayL: weekdayL$b,
  1804. yearInVahid: yearInVahid$4,
  1805. vahid: vahid$4,
  1806. kulliShay: kulliShay$4,
  1807. BE: BE$b,
  1808. badiCalendar: badiCalendar$b
  1809. });
  1810. const monthL$c = {
  1811. 1: 'Splendor',
  1812. 16: 'Honor',
  1813. };
  1814. var en_us = /*#__PURE__*/Object.freeze({
  1815. __proto__: null,
  1816. monthL: monthL$c
  1817. });
  1818. /* eslint-disable dot-notation, line-comment-position, camelcase, sort-imports */
  1819. const badiLocale = { en, ar, de, es, fa, fr, lv, nl, pt, ru, sv, zh, 'en-us': en_us, default: en };
  1820. const setDefaultLanguage = (language) => {
  1821. if (badiLocale[language] === undefined) {
  1822. // eslint-disable-next-line no-console
  1823. console.log('Chosen language does not exist. Setting has not been changed.');
  1824. }
  1825. else {
  1826. badiLocale['default'] = badiLocale[language];
  1827. }
  1828. };
  1829. let underlineFormat = 'css';
  1830. const setUnderlineFormat = (format) => {
  1831. if (['css', 'u', 'diacritic', 'none'].includes(format)) {
  1832. underlineFormat = format;
  1833. }
  1834. else {
  1835. // eslint-disable-next-line no-console
  1836. console.log('Invalid underline format. Choose one of ["css", "u", "diacritic", "none"]. ' +
  1837. 'Setting has not been changed.');
  1838. }
  1839. };
  1840. const formatTokens = [
  1841. ['DDL', 'DD+', 'MML', 'MM+', 'WWL', 'yyv', 'KiS'],
  1842. ['dd', 'DD', 'mm', 'MM', 'ww', 'WW', 'yv', 'YV', 'vv', 'kk', 'yy', 'BE', 'BC', 'Va'],
  1843. ['d', 'D', 'm', 'M', 'W', 'v', 'k', 'y']
  1844. ];
  1845. // eslint-disable-next-line complexity
  1846. const formatBadiDate = (badiDate, formatString, language) => {
  1847. if (!badiDate.isValid) {
  1848. return 'Not a valid Badí‘ date';
  1849. }
  1850. if (typeof language === 'string' && badiLocale[language] === undefined && language.includes('-')) {
  1851. language = language.split('-')[0];
  1852. }
  1853. if (language === undefined || badiLocale[language] === undefined) {
  1854. language = 'default';
  1855. }
  1856. formatString = formatString !== null && formatString !== void 0 ? formatString : formatItemFallback(language, 'defaultFormat');
  1857. let formattedDate = '';
  1858. const length = formatString.length;
  1859. for (let i = 0; i < length; i++) {
  1860. // Text wrapped in {} is output as-is. A '{' without a matching '}'
  1861. // results in invalid input
  1862. if (formatString[i] === '{' && i < length - 1) {
  1863. for (let j = i + 1; j <= length; j++) {
  1864. if (j === length) {
  1865. return 'Invalid formatting string.';
  1866. }
  1867. if (formatString[j] === '}') {
  1868. i = j;
  1869. break;
  1870. }
  1871. formattedDate += formatString[j];
  1872. }
  1873. }
  1874. else {
  1875. const next1 = formatString[i];
  1876. const next2 = next1 + formatString[i + 1];
  1877. const next3 = next2 + formatString[i + 2];
  1878. if (formatTokens[0].includes(next3)) {
  1879. formattedDate += getFormatItem(badiDate, next3, language);
  1880. i += 2;
  1881. }
  1882. else if (formatTokens[1].includes(next2)) {
  1883. formattedDate += getFormatItem(badiDate, next2, language);
  1884. i += 1;
  1885. }
  1886. else if (formatTokens[2].includes(next1)) {
  1887. formattedDate += getFormatItem(badiDate, next1, language);
  1888. }
  1889. else {
  1890. formattedDate += next1;
  1891. }
  1892. }
  1893. }
  1894. return formattedDate;
  1895. };
  1896. // eslint-disable-next-line complexity
  1897. const getFormatItem = (badiDate, token, language) => {
  1898. switch (token) {
  1899. // Single character tokens
  1900. case 'd':
  1901. return digitRewrite(badiDate.day, language);
  1902. case 'D':
  1903. return postProcessLocaleItem(formatItemFallback(language, 'month', badiDate.day), 3);
  1904. case 'm':
  1905. return digitRewrite(badiDate.month, language);
  1906. case 'M':
  1907. return postProcessLocaleItem(formatItemFallback(language, 'month', badiDate.month), 3);
  1908. case 'W':
  1909. return formatItemFallback(language, 'weekdayAbbr3', (badiDate.gregorianDate.weekday + 1) % 7 + 1);
  1910. case 'y':
  1911. return digitRewrite(badiDate.year, language);
  1912. case 'v':
  1913. return digitRewrite((Math.floor((badiDate.year - 1) / 19) % 19) + 1, language);
  1914. case 'k':
  1915. return digitRewrite(Math.floor((badiDate.year - 1) / 361) + 1, language);
  1916. // Two character tokens
  1917. case 'dd':
  1918. return digitRewrite((`0${String(badiDate.day)}`).slice(-2), language);
  1919. case 'DD':
  1920. return postProcessLocaleItem(formatItemFallback(language, 'month', badiDate.day));
  1921. case 'mm':
  1922. return digitRewrite((`0${String(badiDate.month)}`).slice(-2), language);
  1923. case 'MM':
  1924. return postProcessLocaleItem(formatItemFallback(language, 'month', badiDate.month));
  1925. case 'ww':
  1926. return formatItemFallback(language, 'weekdayAbbr2', (badiDate.gregorianDate.weekday + 1) % 7 + 1);
  1927. case 'WW':
  1928. return formatItemFallback(language, 'weekday', (badiDate.gregorianDate.weekday + 1) % 7 + 1);
  1929. case 'yy':
  1930. return digitRewrite((`00${String(badiDate.year)}`).slice(-3), language);
  1931. case 'yv':
  1932. return digitRewrite((badiDate.year - 1) % 19 + 1, language);
  1933. case 'YV':
  1934. return formatItemFallback(language, 'yearInVahid', (badiDate.year - 1) % 19 + 1);
  1935. case 'vv':
  1936. return digitRewrite((`0${String((Math.floor((badiDate.year - 1) / 19) + 2) % 19 - 1)}`).slice(-2), language);
  1937. case 'kk':
  1938. return digitRewrite((`0${String(Math.floor((badiDate.year - 1) / 361) + 1)}`).slice(-2), language);
  1939. case 'Va':
  1940. return formatItemFallback(language, 'vahid');
  1941. case 'BE':
  1942. return formatItemFallback(language, 'BE');
  1943. case 'BC':
  1944. return formatItemFallback(language, 'badiCalendar');
  1945. // Three character tokens
  1946. case 'DDL':
  1947. return formatItemFallback(language, 'monthL', badiDate.day);
  1948. case 'DD+': {
  1949. const day = postProcessLocaleItem(formatItemFallback(language, 'month', badiDate.day));
  1950. const dayL = formatItemFallback(language, 'monthL', badiDate.day);
  1951. if (day === dayL) {
  1952. return day;
  1953. }
  1954. if (badiLocale[language] === badiLocale.fa) {
  1955. return `<span dir="rtl">${day} (${dayL})</span>`;
  1956. }
  1957. return `${day} (${dayL})`;
  1958. }
  1959. case 'MML':
  1960. return formatItemFallback(language, 'monthL', badiDate.month);
  1961. case 'MM+': {
  1962. const month = postProcessLocaleItem(formatItemFallback(language, 'month', badiDate.month));
  1963. const monthL = formatItemFallback(language, 'monthL', badiDate.month);
  1964. if (month === monthL) {
  1965. return month;
  1966. }
  1967. if (badiLocale[language] === badiLocale.fa) {
  1968. return `<span dir="rtl">${month} (${monthL})</span>`;
  1969. }
  1970. return `${month} (${monthL})`;
  1971. }
  1972. case 'WWL':
  1973. return formatItemFallback(language, 'weekdayL', (badiDate.gregorianDate.weekday + 1) % 7 + 1);
  1974. case 'yyv':
  1975. return digitRewrite((`0${String((badiDate.year - 1) % 19 + 1)}`).slice(-2), language);
  1976. case 'KiS':
  1977. return postProcessLocaleItem(formatItemFallback(language, 'kulliShay'));
  1978. // istanbul ignore next
  1979. default:
  1980. return '';
  1981. }
  1982. };
  1983. const postProcessLocaleItem = (item, crop) => {
  1984. if (crop && crop < item.length) {
  1985. let char = 0;
  1986. let counter = 0;
  1987. while (counter < crop) {
  1988. if (!'_’‘'.includes(item[char])) {
  1989. counter++;
  1990. }
  1991. char++;
  1992. }
  1993. if ('_’‘'.includes(item[char])) {
  1994. char++;
  1995. }
  1996. item = item.slice(0, char);
  1997. if (item.split('_').length % 2 === 0) {
  1998. item += '_';
  1999. }
  2000. }
  2001. const stringComponents = item.split('_');
  2002. for (let i = 1; i < stringComponents.length; i += 2) {
  2003. stringComponents[i] = underlineString(stringComponents[i]);
  2004. }
  2005. return stringComponents.join('');
  2006. };
  2007. const underlineString = (str) => {
  2008. switch (underlineFormat) {
  2009. case 'css':
  2010. return `<span style="text-decoration:underline">${str}</span>`;
  2011. case 'diacritic':
  2012. return str.split('').map(char => `${char}\u0332`).join('');
  2013. case 'u':
  2014. return `<u>${str}</u>`;
  2015. case 'none':
  2016. return str;
  2017. // istanbul ignore next
  2018. default:
  2019. throw new TypeError('Unexpected underlineFormat');
  2020. }
  2021. };
  2022. const digitRewrite = (number, language) => {
  2023. number = String(number);
  2024. const unicodeOffset = formatItemFallback(language, 'unicodeCharForZero').charCodeAt(0) - '0'.charCodeAt(0);
  2025. if (unicodeOffset === 0) {
  2026. return number;
  2027. }
  2028. const codePoints = [...number].map(num => num.charCodeAt(0) + unicodeOffset);
  2029. return String.fromCharCode(...codePoints);
  2030. };
  2031. const formatItemFallback = (language, category, index) => {
  2032. var _a;
  2033. if (index === undefined) {
  2034. while (badiLocale[language][category] === undefined) {
  2035. language = languageFallback(language);
  2036. }
  2037. return badiLocale[language][category];
  2038. }
  2039. while (((_a = badiLocale[language][category]) === null || _a === void 0 ? void 0 : _a[index]) === undefined) {
  2040. language = languageFallback(language);
  2041. }
  2042. return badiLocale[language][category][index];
  2043. };
  2044. const languageFallback = (languageCode) => {
  2045. if (languageCode.includes('-')) {
  2046. return languageCode.split('-')[0];
  2047. // eslint-disable-next-line no-negated-condition
  2048. }
  2049. else if (languageCode !== 'default') {
  2050. return 'default';
  2051. }
  2052. return 'en';
  2053. };
  2054. const badiYears = [
  2055. 'l4da', 'k4ci', 'k5c7', 'l4d6', 'l4ce', 'k4c4', 'k5d4', 'l4cb', 'l4c1', 'k4cj', 'k5c8', 'l4d7', 'l4cf', 'k4c5',
  2056. 'k4d5', 'k5ce', 'l4c2', 'k4d2', 'k4ca', 'k5da', 'l4ch', 'k4c6', 'k4d6', 'k5cf', 'l4c4', 'k4d4', 'k4cc', 'k5c1',
  2057. 'l4cj', 'k4c8', 'k4d8', 'k5cg', 'l4c5', 'k4d5', 'k4ce', 'k5c3', 'l4d2', 'k4ca', 'k4d9', 'k5ci', 'l4c6', 'k4d6',
  2058. 'k4cf', 'k4c4', 'k5d4', 'k4cb', 'k4bj', 'k4cj', 'k5c9', 'k4d8', 'k4cg', 'k4c6', 'k5d6', 'k4cd', 'k4c2', 'k4d2',
  2059. 'k5ca', 'k4d9', 'k4ci', 'k4c7', 'k5d7', 'k4cf', 'k4c4', 'k4d4', 'k5cc', 'k4bj', 'k4cj', 'k4c9', 'k5d9', 'k4cg',
  2060. 'k4c6', 'k4d5', 'k5cd', 'k4c2', 'k4d1', 'k4ca', 'k4da', 'j5cj', 'k4c7', 'k4d7', 'k4cf', 'j5c4', 'k4d3', 'k4cb',
  2061. 'k4c1', 'k5d1', 'l4c9', 'l4d9', 'l4ch', 'k5c6', 'l4d5', 'l4cd', 'l4c2', 'k5d2', 'l4ca', 'l4da', 'l4cj', 'k5c8',
  2062. 'l4d7', 'l4cf', 'l4c4', 'k5d4', 'l4cb', 'l4c1', 'l4d1', 'k5c9', 'l4d8', 'l4cg', 'l4c5', 'k4d5', 'k5ce', 'l4c2',
  2063. 'l4d2', 'k4cb', 'k5db', 'l4ci', 'l4c7', 'k4d7', 'k5cf', 'l4c4', 'l4d4', 'k4cc', 'k5c2', 'l4d1', 'l4c9', 'k4d9',
  2064. 'k5ch', 'l4c5', 'l4d5', 'k4ce', 'k5c3', 'l4d2', 'l4cb', 'k4da', 'k5ci', 'l4c6', 'l4d6', 'k4cf', 'k5c5', 'l4d4',
  2065. 'l4cc', 'k4c1', 'k4d1', 'k5c9', 'l4d8', 'k4cg', 'k4c6', 'k5d6', 'l4ce', 'k4c3', 'k4d3', 'k5cb', 'l4da', 'k4ci',
  2066. 'k4c7', 'k5d7', 'l4cf', 'k4c5', 'k4d5', 'k5cd', 'l4c1', 'k4cj', 'k4c9', 'k5d9', 'l4cg', 'k4c6', 'k4d6', 'k5ce',
  2067. 'l4c3', 'k4d2', 'k4ca', 'k5bj', 'l4ci', 'k4c7', 'k4d7', 'k4cg', 'k5c5', 'k4d4', 'k4cc', 'k4c1', 'k5d1', 'k4c9',
  2068. 'k4d9', 'k4ch', 'k5c7', 'l4d6', 'l4ce', 'l4c3', 'l5d3', 'l4ca', 'l4da', 'l4cj', 'l5c8', 'l4d7', 'l4cg', 'l4c5',
  2069. 'l5d4', 'l4cb', 'l4c1', 'l4d1', 'l5ca', 'l4d9', 'l4ch', 'l4c6', 'l5d6', 'l4cd', 'l4c2', 'l4d2', 'l4cb', 'k5c1',
  2070. 'l4cj', 'l4c8', 'l4d8', 'k5cg', 'l4c4', 'l4d4', 'l4cc', 'k5c2', 'l4d1', 'l4ca', 'l4da', 'k5ci', 'l4c6', 'l4d5',
  2071. 'l4ce', 'k5c3', 'l4d2', 'l4cb', 'l4db', 'k5cj', 'l4c8', 'l4d7', 'l4cf', 'k5c5', 'l4d4', 'l4cc', 'l4c2', 'k5d2',
  2072. 'l4c9', 'l4d9', 'l4ch', 'k4c6', 'k5d6', 'l4ce', 'l4c3', 'k4d3', 'k5cc', 'l4db', 'l4cj', 'k4c8', 'k5d8', 'l4cf',
  2073. 'l4c4', 'k4d5', 'k5cd', 'l4c2', 'l4d2', 'k4ca', 'k5d9', 'l4cg', 'l4c6', 'k4d6', 'k5cf', 'l4c3', 'l4d3', 'k4cb',
  2074. 'k5bj', 'l4ci', 'l4c7', 'k4d7', 'k5cg', 'l4c5', 'l4d5', 'k4cd', 'k4c2', 'k5d2', 'l4c9', 'k4d9', 'k4ch', 'k5c7',
  2075. 'l4d6', 'k4cf', 'k4c4', 'k5d4', 'l4cb', 'l4bj', 'l4cj', 'l5c8', 'm4d7', 'l4cg', 'l4c5', 'l5d5', 'm4cc', 'l4c1',
  2076. 'l4d1', 'l5ca', 'm4d9', 'l4ch', 'l4c7', 'l5d7', 'm4ce', 'l4c3', 'l4d3', 'l5cb', 'm4bi', 'l4ci', 'l4c8', 'l4d8',
  2077. 'l5ch', 'l4c5', 'l4d5', 'l4cd', 'l5c2', 'l4d1', 'l4c9', 'l4da', 'l5ci', 'l4c7', 'l4d7', 'l4cf', 'l5c4', 'l4d2',
  2078. 'l4cb', 'l4bj', 'l5d1', 'l4c8', 'l4d8', 'l4cg', 'l5c5', 'l4d4', 'l4cc', 'l4c2', 'l5d2', 'l4c9', 'l4da', 'l4ci',
  2079. ];
  2080. class BadiDate {
  2081. constructor(date) {
  2082. this._holyDay = undefined;
  2083. this._valid = true;
  2084. this._invalidReason = undefined;
  2085. try {
  2086. if (this._isDateObject(date)) {
  2087. this._gregorianDate = luxon.DateTime.fromObject({ year: date.getFullYear(), month: date.getMonth() + 1, day: date.getDate(), zone: 'UTC' });
  2088. }
  2089. else if (luxon.DateTime.isDateTime(date)) {
  2090. this._gregorianDate = luxon.DateTime.fromObject({ year: date.year, month: date.month, day: date.day, zone: 'UTC' });
  2091. }
  2092. else if (this._isYearMonthDay(date) || this._isYearHolyDayNumber(date)) {
  2093. this._setFromBadiDate(date);
  2094. }
  2095. else {
  2096. throw new TypeError('Unrecognized input format');
  2097. }
  2098. if (this._year === undefined) {
  2099. // We haven't set the Badí' date yet
  2100. this._setFromGregorianDate();
  2101. }
  2102. this._setHolyDay();
  2103. }
  2104. catch (err) {
  2105. this._setInvalid(err);
  2106. }
  2107. Object.freeze(this);
  2108. }
  2109. format(formatString, language) {
  2110. return formatBadiDate(this, formatString, language);
  2111. }
  2112. _isDateObject(arg) {
  2113. return Object.prototype.toString.call(arg) === '[object Date]';
  2114. }
  2115. _isYearMonthDay(arg) {
  2116. return typeof arg.year === 'number' && typeof arg.month === 'number' &&
  2117. typeof arg.day === 'number';
  2118. }
  2119. _isYearHolyDayNumber(arg) {
  2120. return typeof arg.year === 'number' && arg.month === undefined &&
  2121. arg.day === undefined && typeof arg.holyDayNumber === 'number';
  2122. }
  2123. _notInValidGregorianDateRange(datetime) {
  2124. const lowerBound = luxon.DateTime.fromObject({ year: 1844, month: 3, day: 21, zone: 'UTC' });
  2125. const upperBound = luxon.DateTime.fromObject({ year: 2351, month: 3, day: 20, zone: 'UTC' });
  2126. return datetime < lowerBound || datetime > upperBound;
  2127. }
  2128. _setFromGregorianDate() {
  2129. if (this._notInValidGregorianDateRange(this._gregorianDate)) {
  2130. throw new RangeError('Input date outside of valid range (1844-03-21 - 2351-03-20)');
  2131. }
  2132. const gregorianYear = this._gregorianDate.year;
  2133. const oldImplementationCutoff = luxon.DateTime.fromObject({ year: 2015, month: 3, day: 21, zone: 'UTC' });
  2134. if (this._gregorianDate < oldImplementationCutoff) {
  2135. const { month, day } = this._gregorianDate;
  2136. if (month < 3 || (month === 3 && day < 21)) {
  2137. this._nawRuz = luxon.DateTime.fromObject({ year: gregorianYear - 1, month: 3, day: 21, zone: 'UTC' });
  2138. this._year = gregorianYear - 1844;
  2139. }
  2140. else {
  2141. this._nawRuz = luxon.DateTime.fromObject({ year: gregorianYear, month: 3, day: 21, zone: 'UTC' });
  2142. this._year = gregorianYear - 1843;
  2143. }
  2144. this._setOldAyyamiHaLength();
  2145. this._yearTwinBirthdays = [12, 5, 13, 9];
  2146. }
  2147. else {
  2148. this._year = gregorianYear - 1843;
  2149. this._setBadiYearInfo(true);
  2150. }
  2151. this._setBadiMonthAndDay();
  2152. }
  2153. /**
  2154. * Set Badí' month and day from Gregorian date
  2155. */
  2156. _setBadiMonthAndDay() {
  2157. const dayOfBadiYear = this._dayOfYear(this._gregorianDate);
  2158. if (dayOfBadiYear < 343) {
  2159. this._month = Math.floor((dayOfBadiYear - 1) / 19 + 1);
  2160. this._day = (dayOfBadiYear - 1) % 19 + 1;
  2161. }
  2162. else if (dayOfBadiYear < 343 + this._ayyamiHaLength) {
  2163. this._month = 20;
  2164. this._day = dayOfBadiYear - 342;
  2165. }
  2166. else {
  2167. this._month = 19;
  2168. this._day = dayOfBadiYear - (342 + this._ayyamiHaLength);
  2169. }
  2170. }
  2171. _setFromBadiDate(date) {
  2172. this._year = date.year;
  2173. if (this._year < 1 || this._year > 507) {
  2174. throw new RangeError('Input date outside of valid range (1 - 507 B.E.)');
  2175. }
  2176. else if (this._year < 172) {
  2177. this._nawRuz = luxon.DateTime.fromObject({ year: 1843 + this._year, month: 3, day: 21, zone: 'UTC' });
  2178. this._setOldAyyamiHaLength();
  2179. this._yearTwinBirthdays = [12, 5, 13, 9];
  2180. }
  2181. else {
  2182. this._setBadiYearInfo();
  2183. }
  2184. if (this._isYearMonthDay(date)) {
  2185. this._month = date.month;
  2186. this._day = date.day;
  2187. if (this._month === 20 && this._day > this._ayyamiHaLength) {
  2188. // 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
  2189. // Ayyám-i-Há can be salvaged
  2190. if (this._day - this._ayyamiHaLength === 1) {
  2191. this._month = 19;
  2192. this._day = 1;
  2193. }
  2194. else {
  2195. throw new TypeError('Input numbers do not designate a valid date');
  2196. }
  2197. }
  2198. if (this._month < 1 || this._month > 20 || this._day < 1 || this.day > 19) {
  2199. throw new TypeError('Input numbers do not designate a valid date');
  2200. }
  2201. }
  2202. else {
  2203. if (date.holyDayNumber < 1 || date.holyDayNumber > 11) {
  2204. throw new TypeError('Input numbers do not designate a valid Holy Day');
  2205. }
  2206. this._holyDay = date.holyDayNumber;
  2207. [this._month, this._day] = this._holyDayMapping()[this._holyDay];
  2208. }
  2209. this._gregorianDate = this._nawRuz.plus(luxon.Duration.fromObject({ days: this._dayOfYear([this._year, this._month, this._day]) - 1 }));
  2210. }
  2211. _setOldAyyamiHaLength() {
  2212. if (luxon.DateTime.fromObject({ year: this._nawRuz.year + 1 }).isInLeapYear) {
  2213. this._ayyamiHaLength = 5;
  2214. }
  2215. else {
  2216. this._ayyamiHaLength = 4;
  2217. }
  2218. }
  2219. _setBadiYearInfo(fromGregorianDate = false) {
  2220. let yearData = this._extractBadiYearInfo();
  2221. if (fromGregorianDate && this._gregorianDate < yearData.nawRuz) {
  2222. this._year -= 1;
  2223. yearData = this._extractBadiYearInfo();
  2224. }
  2225. this._nawRuz = yearData.nawRuz;
  2226. this._ayyamiHaLength = yearData.ayyamiHaLength;
  2227. this._yearTwinBirthdays = yearData.twinBirthdays;
  2228. }
  2229. _extractBadiYearInfo() {
  2230. let nawRuz, ayyamiHaLength, twinBirthdays;
  2231. // Check whether data needs to be unpacked or exists in the verbose version
  2232. // istanbul ignore else
  2233. if (badiYears[0] === 'l4da') {
  2234. const components = badiYears[this._year - 172].split('');
  2235. nawRuz = luxon.DateTime.fromObject({ year: this._year - 172 + 2015, month: 3, day: parseInt(components[0], 36), zone: 'UTC' });
  2236. ayyamiHaLength = parseInt(components[1], 36);
  2237. const TB1 = [parseInt(components[2], 36), parseInt(components[3], 36)];
  2238. const TB2 = TB1[1] < 19 ? [TB1[0], TB1[1] + 1] : [TB1[0] + 1, 1];
  2239. twinBirthdays = [TB1[0], TB1[1], TB2[0], TB2[1]];
  2240. }
  2241. else {
  2242. ({ nawRuz, ayyamiHaLength, twinBirthdays } = badiYears[this._year]);
  2243. nawRuz = luxon.DateTime.fromISO(nawRuz, { zone: 'UTC' });
  2244. }
  2245. return { nawRuz, ayyamiHaLength, twinBirthdays };
  2246. }
  2247. _dayOfYear(date) {
  2248. // Naw-Rúz is day 1
  2249. if (Array.isArray(date)) {
  2250. // We have a Badí' date
  2251. if (date[1] < 19) {
  2252. return 19 * (date[1] - 1) + date[2];
  2253. }
  2254. else if (date[1] === 20) {
  2255. return 342 + date[2];
  2256. }
  2257. // date[1] === 19
  2258. return 342 + this._ayyamiHaLength + date[2];
  2259. }
  2260. return date.diff(this._nawRuz).as('days') + 1;
  2261. }
  2262. _setInvalid(invalidReason) {
  2263. this._gregorianDate = luxon.DateTime.invalid('Not a valid Badí‘ date');
  2264. this._year = NaN;
  2265. this._month = NaN;
  2266. this._day = NaN;
  2267. this._ayyamiHaLength = NaN;
  2268. this._nawRuz = luxon.DateTime.invalid('Not a valid Badí‘ date');
  2269. this._valid = false;
  2270. this._invalidReason = invalidReason;
  2271. }
  2272. _setHolyDay() {
  2273. const mapping = this._holyDayMapping();
  2274. this._holyDay = parseInt(Object.keys(mapping)
  2275. .find(key => mapping[key][0] === this._month && mapping[key][1] === this._day), 10);
  2276. }
  2277. _holyDayMapping() {
  2278. return {
  2279. [1 /* NawRuz */]: [1, 1],
  2280. [2 /* FirstRidvan */]: [2, 13],
  2281. [3 /* NinthRidvan */]: [3, 2],
  2282. [4 /* TwelfthRidvan */]: [3, 5],
  2283. [5 /* DeclarationOfTheBab */]: [4, this._year < 172 ? 7 : 8],
  2284. [6 /* AscensionOfBahaullah */]: [4, 13],
  2285. [7 /* MartyrdomOfTheBab */]: [6, this._year < 172 ? 16 : 17],
  2286. [8 /* BirthOfTheBab */]: [this._yearTwinBirthdays[0], this._yearTwinBirthdays[1]],
  2287. [9 /* BirthOfBahaullah */]: [this._yearTwinBirthdays[2], this._yearTwinBirthdays[3]],
  2288. [10 /* DayOfTheCovenant */]: [14, 4],
  2289. [11 /* AscensionOfAbdulBaha */]: [14, 6],
  2290. };
  2291. }
  2292. _leapYearsBefore() {
  2293. let leapYearsBefore = Math.floor(Math.min(this.year - 1, 171) / 4);
  2294. if (this.year > 172) {
  2295. // istanbul ignore else
  2296. if (badiYears[0] === 'l4da') {
  2297. leapYearsBefore += badiYears.slice(0, this.year - 172).filter(entry => entry[1] === '5').length;
  2298. }
  2299. else {
  2300. leapYearsBefore += Object.entries(badiYears)
  2301. .filter(([year, data]) => parseInt(year, 10) < this.year &&
  2302. data.ayyamiHaLength === 5).length;
  2303. }
  2304. }
  2305. return leapYearsBefore;
  2306. }
  2307. holyDay(language = undefined) {
  2308. if (!this._holyDay) {
  2309. return '';
  2310. }
  2311. if (language === undefined || badiLocale[language] === undefined) {
  2312. language = 'default';
  2313. }
  2314. return formatItemFallback(language, 'holyDay', this._holyDay);
  2315. }
  2316. valueOf() {
  2317. return this._dayOfYear([this.year, this.month, this.day]) + this._leapYearsBefore() + (this.year - 1) * 365;
  2318. }
  2319. equals(other) {
  2320. return this.isValid && other.isValid && this.valueOf() === other.valueOf();
  2321. }
  2322. get isValid() {
  2323. return this._valid;
  2324. }
  2325. get invalidReason() {
  2326. return this._invalidReason;
  2327. }
  2328. get day() {
  2329. return this._day;
  2330. }
  2331. get month() {
  2332. return this._month;
  2333. }
  2334. get year() {
  2335. return this._year;
  2336. }
  2337. // number of the Badí' weekday between 1 (Jalál ~> Saturday) and 7 (Istiqlál ~> Friday).
  2338. get weekday() {
  2339. return (this._gregorianDate.weekday + 1) % 7 + 1;
  2340. }
  2341. get yearInVahid() {
  2342. return (this._year - 1) % 19 + 1;
  2343. }
  2344. get vahid() {
  2345. return (Math.floor((this._year - 1) / 19) % 19) + 1;
  2346. }
  2347. get kullIShay() {
  2348. return Math.floor((this._year - 1) / 361) + 1;
  2349. }
  2350. // Gregorian date on whose sunset the Badí' date ends.
  2351. get gregorianDate() {
  2352. return this._gregorianDate;
  2353. }
  2354. get ayyamiHaLength() {
  2355. return this._ayyamiHaLength;
  2356. }
  2357. get holyDayNumber() {
  2358. return this._holyDay ? this._holyDay : undefined;
  2359. }
  2360. get workSuspended() {
  2361. return this._holyDay ? this.holyDayNumber < 10 : undefined;
  2362. }
  2363. get nextMonth() {
  2364. let { year, month } = this;
  2365. switch (month) {
  2366. case 18:
  2367. month = 20;
  2368. break;
  2369. case 19:
  2370. month = 1;
  2371. year += 1;
  2372. break;
  2373. case 20:
  2374. month = 19;
  2375. break;
  2376. default:
  2377. month += 1;
  2378. }
  2379. return new BadiDate({ year, month, day: 1 });
  2380. }
  2381. get previousMonth() {
  2382. let { year, month } = this;
  2383. switch (month) {
  2384. case 1:
  2385. month = 19;
  2386. year -= 1;
  2387. break;
  2388. case 19:
  2389. month = 20;
  2390. break;
  2391. case 20:
  2392. month = 18;
  2393. break;
  2394. default:
  2395. month -= 1;
  2396. }
  2397. return new BadiDate({ year, month, day: 1 });
  2398. }
  2399. get nextDay() {
  2400. if (this._day === 19 || (this._month === 20 && this._day === this._ayyamiHaLength)) {
  2401. return this.nextMonth;
  2402. }
  2403. return new BadiDate({ year: this._year, month: this._month, day: this._day + 1 });
  2404. }
  2405. get previousDay() {
  2406. if (this._day === 1) {
  2407. const { previousMonth } = this;
  2408. let day = 19;
  2409. if (this._month === 19) {
  2410. day = this._ayyamiHaLength;
  2411. }
  2412. return new BadiDate({
  2413. year: previousMonth.year,
  2414. month: previousMonth.month,
  2415. day,
  2416. });
  2417. }
  2418. return new BadiDate({ year: this._year, month: this._month, day: this._day - 1 });
  2419. }
  2420. }
  2421. const badiDateSettings = (settings) => {
  2422. if (settings.defaultLanguage) {
  2423. setDefaultLanguage(settings.defaultLanguage);
  2424. }
  2425. if (settings.underlineFormat) {
  2426. setUnderlineFormat(settings.underlineFormat);
  2427. }
  2428. };
  2429. /* eslint-disable max-len, complexity */
  2430. const clockLocations = {
  2431. 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]]],
  2432. 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]]],
  2433. // 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]]],
  2434. Iceland: [[[-25.0, 63.0], [-12.8, 63.0], [-12.8, 66.8], [-25.0, 66.8]]],
  2435. 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]]],
  2436. 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]]],
  2437. 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]]],
  2438. };
  2439. /* eslint-enable max-len */
  2440. let usingClockLocations = true;
  2441. const useClockLocations = (useClockLocations) => {
  2442. usingClockLocations = useClockLocations;
  2443. };
  2444. const pointInPolygon = (coords, polygon) => {
  2445. const [x, y] = coords;
  2446. let inside = false;
  2447. for (let i = 0, j = polygon.length - 1; i < polygon.length; i++) {
  2448. const [xi, yi] = polygon[i];
  2449. const [xj, yj] = polygon[j];
  2450. // Check that a) the segment crosses the y coordinate of the point
  2451. // b) at least one of the two vertices is left of the point
  2452. // c) at the y coordinate of the point, the segment is left of it
  2453. if ((((yi < y) !== (yj < y)) && (xi <= x || xj <= x)) && ((xi + (y - yi) * (xj - xi) / (yj - yi)) < x)) {
  2454. inside = !inside;
  2455. }
  2456. j = i;
  2457. }
  2458. return inside;
  2459. };
  2460. // The name of a country being returned doesn't just mean that the coordinates are within that country, but that they
  2461. // are within the region of that country where a fixed time rule applies.
  2462. const clockLocationFromPolygons = (latitude, longitude) => {
  2463. if (!usingClockLocations) {
  2464. return undefined;
  2465. }
  2466. // First exclude as large an area as possible from having to check polygons
  2467. if (latitude < 51.0) {
  2468. return undefined;
  2469. }
  2470. if (latitude < 57.0 && longitude > -129.0 && longitude < 172.0) {
  2471. return undefined;
  2472. }
  2473. // Make a list of plausible areas based on longitude, then only check those
  2474. const countries = [];
  2475. const labels = [];
  2476. if (longitude < -129.9 || longitude > 172.4) {
  2477. countries.push(clockLocations.USA);
  2478. labels.push('USA');
  2479. }
  2480. if (longitude > -141.1 && longitude < -61.1) {
  2481. countries.push(clockLocations.Canada);
  2482. labels.push('Canada');
  2483. }
  2484. // Greenland doesn't currently have a rule for this
  2485. // if (longitude > -73.1 && longitude < -11.3) {
  2486. // countries.push(clockLocations.Greenland);
  2487. // labels.push('Greenland');
  2488. // }
  2489. if (longitude > -25.0 && longitude < -12.8) {
  2490. countries.push(clockLocations.Iceland);
  2491. labels.push('Iceland');
  2492. }
  2493. if (longitude > -9.2 && longitude < 33.6) {
  2494. countries.push(clockLocations.Norway);
  2495. labels.push('Norway');
  2496. }
  2497. if (longitude > 10.9 && longitude < 24.2) {
  2498. countries.push(clockLocations.Sweden);
  2499. labels.push('Sweden');
  2500. }
  2501. if (longitude > 19.1 && longitude < 31.6) {
  2502. countries.push(clockLocations.Finland);
  2503. labels.push('Finland');
  2504. }
  2505. // Russia currently doesn't have a rule for this
  2506. // if (longitude > 27.3 || longitude < -169.6) {
  2507. // countries.push(clockLocations.Russia);
  2508. // labels.push('Russia');
  2509. // }
  2510. for (let i = 0; i < countries.length; i++) {
  2511. for (let j = 0; j < countries[i].length; j++) {
  2512. if (pointInPolygon([longitude, latitude], countries[i][j])) {
  2513. return labels[i];
  2514. }
  2515. }
  2516. }
  2517. return undefined;
  2518. };
  2519. /* eslint-disable complexity */
  2520. class LocalBadiDate {
  2521. constructor(date, latitude, longitude, timezoneId) {
  2522. this._latitude = latitude;
  2523. this._longitude = longitude;
  2524. this._timezoneId = timezoneId;
  2525. // If a datetime object is being passed, we use date and time, not just the
  2526. // date. For a JS Date object, we can't assume it's in the correct timezone,
  2527. // so in that case we use the date information only.
  2528. this._badiDate = new BadiDate(this._setInputDateToCorrectDay(date, latitude, longitude));
  2529. const gregDate = this._badiDate.gregorianDate.setZone(timezoneId, { keepLocalTime: true });
  2530. this._clockLocation = clockLocationFromPolygons(latitude, longitude);
  2531. if (!this._clockLocation ||
  2532. (this._clockLocation === 'Finland' &&
  2533. this._badiDate.month === 19)) {
  2534. this._end = sunset(gregDate, latitude, longitude);
  2535. this._solarNoon = solarNoon(gregDate, longitude);
  2536. this._sunrise = sunrise(gregDate, latitude, longitude);
  2537. this._start = sunset(gregDate.minus({ days: 1 }), latitude, longitude);
  2538. }
  2539. else {
  2540. // First we set times to 18:00, 06:00, 12:00, 18:00, modifications are
  2541. // then made depending on the region.
  2542. this._start = gregDate.minus({ days: 1 }).set({ hour: 18 });
  2543. this._solarNoon = gregDate.set({ hour: 12 });
  2544. this._sunrise = gregDate.set({ hour: 6 });
  2545. this._end = gregDate.set({ hour: 18 });
  2546. if (this._clockLocation === 'Canada') {
  2547. this._sunrise = this._sunrise.plus({ minutes: 30 });
  2548. }
  2549. else if (this._clockLocation === 'Iceland') {
  2550. this._solarNoon = this._solarNoon.plus({ hours: 1 });
  2551. }
  2552. else if (this._clockLocation === 'Finland' ||
  2553. this._clockLocation === 'USA') {
  2554. if (this._end.isInDST) {
  2555. this._sunrise = this._sunrise.plus({ hours: 1 });
  2556. this._solarNoon = this._solarNoon.plus({ hours: 1 });
  2557. this._end = this._end.plus({ hours: 1 });
  2558. }
  2559. if (this._start.isInDST) {
  2560. this._start = this._start.plus({ hours: 1 });
  2561. }
  2562. }
  2563. }
  2564. switch (this._badiDate.holyDayNumber) {
  2565. case 2:
  2566. // First Day of Ridvan: 15:00 local standard time
  2567. this._holyDayCommemoration = gregDate.set({ hour: gregDate.isInDST ? 16 : 15 });
  2568. break;
  2569. case 5:
  2570. // Declaration of the Báb: 2 hours 11 minutes after sunset
  2571. this._holyDayCommemoration = this._start.plus({ minutes: 131 });
  2572. break;
  2573. case 6:
  2574. // Ascension of Bahá'u'lláh: 03:00 local standard time
  2575. this._holyDayCommemoration = gregDate.set({ hour: gregDate.isInDST ? 4 : 3 });
  2576. break;
  2577. case 7:
  2578. // Martyrdom of the Báb: solar noon
  2579. this._holyDayCommemoration = this._solarNoon;
  2580. break;
  2581. case 11:
  2582. // Ascension of 'Abdu'l-Bahá: 01:00 local standard time
  2583. this._holyDayCommemoration = gregDate.set({ hour: gregDate.isInDST ? 2 : 1 });
  2584. break;
  2585. // skip default
  2586. }
  2587. }
  2588. _setInputDateToCorrectDay(date, latitude, longitude) {
  2589. if (luxon.DateTime.isDateTime(date)) {
  2590. const sunset$1 = sunset(date, latitude, longitude);
  2591. return (date > sunset$1) ? date.plus({ days: 1 }) : date;
  2592. }
  2593. return date;
  2594. }
  2595. get badiDate() {
  2596. return this._badiDate;
  2597. }
  2598. get start() {
  2599. return this._start;
  2600. }
  2601. get sunrise() {
  2602. return this._sunrise;
  2603. }
  2604. get solarNoon() {
  2605. return this._solarNoon;
  2606. }
  2607. get end() {
  2608. return this._end;
  2609. }
  2610. get holyDayCommemoration() {
  2611. return this._holyDayCommemoration;
  2612. }
  2613. get clockLocation() {
  2614. return this._clockLocation;
  2615. }
  2616. get latitude() {
  2617. return this._latitude;
  2618. }
  2619. get longitude() {
  2620. return this._longitude;
  2621. }
  2622. get timezoneId() {
  2623. return this._timezoneId;
  2624. }
  2625. get nextMonth() {
  2626. return new LocalBadiDate(this.badiDate.nextMonth, this._latitude, this._longitude, this._timezoneId);
  2627. }
  2628. get previousMonth() {
  2629. return new LocalBadiDate(this.badiDate.previousMonth, this._latitude, this._longitude, this._timezoneId);
  2630. }
  2631. get nextDay() {
  2632. return new LocalBadiDate(this.badiDate.nextDay, this._latitude, this._longitude, this._timezoneId);
  2633. }
  2634. get previousDay() {
  2635. return new LocalBadiDate(this.badiDate.previousDay, this._latitude, this._longitude, this._timezoneId);
  2636. }
  2637. }
  2638. const badiDateSettings$1 = (settings) => {
  2639. if (typeof settings.defaultLanguage === 'string' ||
  2640. typeof settings.underlineFormat === 'string') {
  2641. badiDateSettings(settings);
  2642. }
  2643. if (typeof settings.useClockLocations === 'boolean') {
  2644. useClockLocations(settings.useClockLocations);
  2645. }
  2646. };
  2647. settings({ returnTimeForNoEventCase: true, roundToNearestMinute: true });
  2648. exports.BadiDate = BadiDate;
  2649. exports.LocalBadiDate = LocalBadiDate;
  2650. exports.badiDateSettings = badiDateSettings$1;
  2651. Object.defineProperty(exports, '__esModule', { value: true });
  2652. })));