pakdatakit 1.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +909 -666
  3. package/dist/address.cjs +17 -0
  4. package/dist/address.d.cts +36 -0
  5. package/dist/address.d.ts +36 -0
  6. package/dist/address.js +4 -0
  7. package/dist/chunk-3COX5FSL.cjs +1650 -0
  8. package/dist/chunk-432ZYMYV.js +31 -0
  9. package/dist/chunk-43ULDYUP.cjs +235 -0
  10. package/dist/chunk-44YRK7WO.js +231 -0
  11. package/dist/chunk-4EUKCSLW.js +221 -0
  12. package/dist/chunk-4VVFS6FN.cjs +715 -0
  13. package/dist/chunk-6TSKA2PH.js +38 -0
  14. package/dist/chunk-APXP7OK7.cjs +226 -0
  15. package/dist/chunk-AUATLZA5.cjs +168 -0
  16. package/dist/chunk-BSS4Z7NI.cjs +422 -0
  17. package/dist/chunk-CEPNSHIC.js +33 -0
  18. package/dist/chunk-CYJJ7KGC.cjs +108 -0
  19. package/dist/chunk-E47SNBWQ.cjs +224 -0
  20. package/dist/chunk-E7GAK72W.js +20 -0
  21. package/dist/chunk-EEVNLTB4.js +32 -0
  22. package/dist/chunk-ENQ7O7VW.js +32 -0
  23. package/dist/chunk-H6M6L26S.cjs +37 -0
  24. package/dist/chunk-HBOZIITD.js +351 -0
  25. package/dist/chunk-HTCSHHOR.cjs +35 -0
  26. package/dist/chunk-JKE4AMSZ.js +47 -0
  27. package/dist/chunk-JNP27XW2.cjs +22 -0
  28. package/dist/chunk-K6CZFCX6.js +1642 -0
  29. package/dist/chunk-KEHCTYLO.cjs +52 -0
  30. package/dist/chunk-KQKW2ZEK.cjs +18 -0
  31. package/dist/chunk-L2BDDM2W.js +165 -0
  32. package/dist/chunk-L45UXUWX.js +21 -0
  33. package/dist/chunk-LIYNKIKS.js +709 -0
  34. package/dist/chunk-LVHTH4P7.cjs +41 -0
  35. package/dist/chunk-P4CGOJEM.js +16 -0
  36. package/dist/chunk-PHHKIMO2.cjs +35 -0
  37. package/dist/chunk-QQQKISXT.js +223 -0
  38. package/dist/chunk-T3E4B5MJ.js +417 -0
  39. package/dist/chunk-VPBMIYO2.cjs +38 -0
  40. package/dist/chunk-XCXFGTHW.cjs +355 -0
  41. package/dist/chunk-Y6BUGLXU.js +95 -0
  42. package/dist/chunk-YLWZGSFY.cjs +99 -0
  43. package/dist/chunk-YS7MOLK2.cjs +23 -0
  44. package/dist/chunk-Z5JEIQVW.js +102 -0
  45. package/dist/cli.js +78 -2654
  46. package/dist/cnic.cjs +15 -0
  47. package/dist/cnic.d.cts +35 -0
  48. package/dist/cnic.d.ts +35 -0
  49. package/dist/cnic.js +2 -0
  50. package/dist/format.cjs +14 -0
  51. package/dist/format.d.cts +27 -0
  52. package/dist/format.d.ts +27 -0
  53. package/dist/format.js +1 -0
  54. package/dist/geo.cjs +27 -0
  55. package/dist/geo.d.cts +43 -0
  56. package/dist/geo.d.ts +43 -0
  57. package/dist/geo.js +2 -0
  58. package/dist/hijri.cjs +26 -0
  59. package/dist/hijri.d.cts +62 -0
  60. package/dist/hijri.d.ts +62 -0
  61. package/dist/hijri.js +1 -0
  62. package/dist/holidays.cjs +19 -0
  63. package/dist/holidays.d.cts +72 -0
  64. package/dist/holidays.d.ts +72 -0
  65. package/dist/holidays.js +2 -0
  66. package/dist/iban.cjs +15 -0
  67. package/dist/iban.d.cts +21 -0
  68. package/dist/iban.d.ts +21 -0
  69. package/dist/iban.js +2 -0
  70. package/dist/index.cjs +211 -0
  71. package/dist/index.d.cts +16 -0
  72. package/dist/index.d.ts +16 -300
  73. package/dist/index.js +18 -2764
  74. package/dist/networks.cjs +12 -0
  75. package/dist/networks.d.cts +20 -0
  76. package/dist/networks.d.ts +20 -0
  77. package/dist/networks.js +3 -0
  78. package/dist/numbers.cjs +24 -0
  79. package/dist/numbers.d.cts +53 -0
  80. package/dist/numbers.d.ts +53 -0
  81. package/dist/numbers.js +3 -0
  82. package/dist/phone.cjs +29 -0
  83. package/dist/phone.d.cts +56 -0
  84. package/dist/phone.d.ts +56 -0
  85. package/dist/phone.js +4 -0
  86. package/dist/postal.cjs +27 -0
  87. package/dist/postal.d.cts +40 -0
  88. package/dist/postal.d.ts +40 -0
  89. package/dist/postal.js +2 -0
  90. package/dist/raast.cjs +20 -0
  91. package/dist/raast.d.cts +125 -0
  92. package/dist/raast.d.ts +125 -0
  93. package/dist/raast.js +3 -0
  94. package/dist/rules-GxgPiVws.d.cts +7 -0
  95. package/dist/rules-GxgPiVws.d.ts +7 -0
  96. package/dist/tax.cjs +20 -0
  97. package/dist/tax.d.cts +47 -0
  98. package/dist/tax.d.ts +47 -0
  99. package/dist/tax.js +3 -0
  100. package/dist/text.cjs +23 -0
  101. package/dist/text.d.cts +34 -0
  102. package/dist/text.d.ts +34 -0
  103. package/dist/text.js +2 -0
  104. package/dist/valibot.cjs +47 -0
  105. package/dist/valibot.d.cts +22 -0
  106. package/dist/valibot.d.ts +22 -0
  107. package/dist/valibot.js +25 -0
  108. package/dist/whatsapp.cjs +12 -0
  109. package/dist/whatsapp.d.cts +12 -0
  110. package/dist/whatsapp.d.ts +12 -0
  111. package/dist/whatsapp.js +3 -0
  112. package/dist/words.cjs +14 -0
  113. package/dist/words.d.cts +49 -0
  114. package/dist/words.d.ts +49 -0
  115. package/dist/words.js +1 -0
  116. package/dist/yup.cjs +32 -0
  117. package/dist/yup.d.cts +22 -0
  118. package/dist/yup.d.ts +22 -0
  119. package/dist/yup.js +30 -0
  120. package/dist/zod.cjs +27 -0
  121. package/dist/zod.d.cts +22 -0
  122. package/dist/zod.d.ts +22 -0
  123. package/dist/zod.js +25 -0
  124. package/package.json +309 -77
  125. package/dist/cli.d.ts +0 -1
  126. package/dist/cli.js.map +0 -1
  127. package/dist/index.js.map +0 -1
@@ -0,0 +1,422 @@
1
+ 'use strict';
2
+
3
+ var chunkYLWZGSFY_cjs = require('./chunk-YLWZGSFY.cjs');
4
+ var chunkVPBMIYO2_cjs = require('./chunk-VPBMIYO2.cjs');
5
+
6
+ // data/area-codes.json
7
+ var area_codes_default = [
8
+ {
9
+ code: "21",
10
+ cities: ["Karachi"]
11
+ },
12
+ {
13
+ code: "22",
14
+ cities: ["Hyderabad"]
15
+ },
16
+ {
17
+ code: "232",
18
+ cities: ["Tharparkar"]
19
+ },
20
+ {
21
+ code: "233",
22
+ cities: ["Mirpur Khas"]
23
+ },
24
+ {
25
+ code: "235",
26
+ cities: ["Sanghar"]
27
+ },
28
+ {
29
+ code: "238",
30
+ cities: ["Umerkot"]
31
+ },
32
+ {
33
+ code: "242",
34
+ cities: ["Naushero Feroze"]
35
+ },
36
+ {
37
+ code: "243",
38
+ cities: ["Khairpur"]
39
+ },
40
+ {
41
+ code: "244",
42
+ cities: ["Nawabshah"]
43
+ },
44
+ {
45
+ code: "25",
46
+ cities: ["Dadu"]
47
+ },
48
+ {
49
+ code: "297",
50
+ cities: ["Badin"]
51
+ },
52
+ {
53
+ code: "298",
54
+ cities: ["Thatta"]
55
+ },
56
+ {
57
+ code: "40",
58
+ cities: ["Sahiwal"]
59
+ },
60
+ {
61
+ code: "41",
62
+ cities: ["Faisalabad"]
63
+ },
64
+ {
65
+ code: "42",
66
+ cities: ["Lahore"]
67
+ },
68
+ {
69
+ code: "44",
70
+ cities: ["Okara"]
71
+ },
72
+ {
73
+ code: "453",
74
+ cities: ["Bhakkar"]
75
+ },
76
+ {
77
+ code: "454",
78
+ cities: ["Khushab"]
79
+ },
80
+ {
81
+ code: "457",
82
+ cities: ["Pakpattan"]
83
+ },
84
+ {
85
+ code: "459",
86
+ cities: ["Mianwali"]
87
+ },
88
+ {
89
+ code: "46",
90
+ cities: ["Toba Tek Singh"]
91
+ },
92
+ {
93
+ code: "47",
94
+ cities: ["Jhang"]
95
+ },
96
+ {
97
+ code: "48",
98
+ cities: ["Sargodha"]
99
+ },
100
+ {
101
+ code: "49",
102
+ cities: ["Kasur"]
103
+ },
104
+ {
105
+ code: "51",
106
+ cities: ["Islamabad", "Rawalpindi"]
107
+ },
108
+ {
109
+ code: "52",
110
+ cities: ["Sialkot"]
111
+ },
112
+ {
113
+ code: "53",
114
+ cities: ["Gujrat"]
115
+ },
116
+ {
117
+ code: "542",
118
+ cities: ["Narowal"]
119
+ },
120
+ {
121
+ code: "543",
122
+ cities: ["Chakwal"]
123
+ },
124
+ {
125
+ code: "544",
126
+ cities: ["Jhelum"]
127
+ },
128
+ {
129
+ code: "546",
130
+ cities: ["Mandi Bahauddin"]
131
+ },
132
+ {
133
+ code: "547",
134
+ cities: ["Hafizabad"]
135
+ },
136
+ {
137
+ code: "55",
138
+ cities: ["Gujranwala"]
139
+ },
140
+ {
141
+ code: "56",
142
+ cities: ["Sheikhupura"]
143
+ },
144
+ {
145
+ code: "57",
146
+ cities: ["Attock"]
147
+ },
148
+ {
149
+ code: "604",
150
+ cities: ["Rajanpur"]
151
+ },
152
+ {
153
+ code: "606",
154
+ cities: ["Layyah"]
155
+ },
156
+ {
157
+ code: "608",
158
+ cities: ["Lodhran"]
159
+ },
160
+ {
161
+ code: "61",
162
+ cities: ["Multan"]
163
+ },
164
+ {
165
+ code: "62",
166
+ cities: ["Bahawalpur"]
167
+ },
168
+ {
169
+ code: "63",
170
+ cities: ["Bahawalnagar"]
171
+ },
172
+ {
173
+ code: "64",
174
+ cities: ["Dera Ghazi Khan"]
175
+ },
176
+ {
177
+ code: "65",
178
+ cities: ["Khanewal"]
179
+ },
180
+ {
181
+ code: "66",
182
+ cities: ["Muzaffargarh"]
183
+ },
184
+ {
185
+ code: "67",
186
+ cities: ["Vehari"]
187
+ },
188
+ {
189
+ code: "68",
190
+ cities: ["Rahim Yar Khan"]
191
+ },
192
+ {
193
+ code: "71",
194
+ cities: ["Sukkur"]
195
+ },
196
+ {
197
+ code: "722",
198
+ cities: ["Jacobabad"]
199
+ },
200
+ {
201
+ code: "723",
202
+ cities: ["Ghotki"]
203
+ },
204
+ {
205
+ code: "726",
206
+ cities: ["Shikarpur"]
207
+ },
208
+ {
209
+ code: "74",
210
+ cities: ["Larkana"]
211
+ },
212
+ {
213
+ code: "81",
214
+ cities: ["Quetta"]
215
+ },
216
+ {
217
+ code: "848",
218
+ cities: ["Khuzdar"]
219
+ },
220
+ {
221
+ code: "852",
222
+ cities: ["Turbat"]
223
+ },
224
+ {
225
+ code: "86",
226
+ cities: ["Gwadar"]
227
+ },
228
+ {
229
+ code: "91",
230
+ cities: ["Peshawar", "Charsadda"]
231
+ },
232
+ {
233
+ code: "922",
234
+ cities: ["Kohat"]
235
+ },
236
+ {
237
+ code: "923",
238
+ cities: ["Nowshera"]
239
+ },
240
+ {
241
+ code: "925",
242
+ cities: ["Hangu"]
243
+ },
244
+ {
245
+ code: "926",
246
+ cities: ["Kurram"]
247
+ },
248
+ {
249
+ code: "927",
250
+ cities: ["Karak"]
251
+ },
252
+ {
253
+ code: "928",
254
+ cities: ["Bannu"]
255
+ },
256
+ {
257
+ code: "937",
258
+ cities: ["Mardan"]
259
+ },
260
+ {
261
+ code: "938",
262
+ cities: ["Swabi"]
263
+ },
264
+ {
265
+ code: "943",
266
+ cities: ["Chitral"]
267
+ },
268
+ {
269
+ code: "946",
270
+ cities: ["Swat", "Mingora"]
271
+ },
272
+ {
273
+ code: "963",
274
+ cities: ["Tank"]
275
+ },
276
+ {
277
+ code: "966",
278
+ cities: ["Dera Ismail Khan"]
279
+ },
280
+ {
281
+ code: "969",
282
+ cities: ["Lakki Marwat"]
283
+ },
284
+ {
285
+ code: "992",
286
+ cities: ["Abbottabad"]
287
+ },
288
+ {
289
+ code: "995",
290
+ cities: ["Haripur"]
291
+ },
292
+ {
293
+ code: "997",
294
+ cities: ["Mansehra"]
295
+ },
296
+ {
297
+ code: "998",
298
+ cities: ["Kohistan"]
299
+ }
300
+ ];
301
+
302
+ // src/numbers.ts
303
+ var FIXED_LINE = /^(?:(?:(?:21|42)[2-9]|58[126])\d{7}|(?:2[25]|4[0146-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91)[2-9]\d{6,7}|(?:2(?:3[2358]|4[2-4]|9[2-8])|45[3479]|54[2-467]|60[468]|72[236]|8(?:2[2-689]|3[23578]|4[3478]|5[2356])|9(?:2[2-8]|3[27-9]|4[2-6]|6[3569]|9[25-8]))[2-9]\d{5,6})$/;
304
+ var UAN = /^((?:2(?:[125]|3[2358]|4[2-4]|9[2-8])|4(?:[0-246-9]|5[3479])|5(?:[1-35-7]|4[2-467])|6(?:0[468]|[1-8])|7(?:[14]|2[236])|8(?:[16]|2[2-689]|3[23578]|4[3478]|5[2356])|9(?:1|22|3[27-9]|4[2-6]|6[3569]|9[2-7])))111(\d{6})$/;
305
+ var UAN_WITHOUT_AREA_CODE = /^111(\d{6})$/;
306
+ var TOLL_FREE = /^800(\d{5}(?:\d{3})?)$/;
307
+ var PREMIUM = /^900(\d{5})$/;
308
+ var PERSONAL = /^122(\d{6})$/;
309
+ var areaCodes = chunkVPBMIYO2_cjs.lazy(() => area_codes_default);
310
+ var areaCodeMap = chunkVPBMIYO2_cjs.lazy(
311
+ () => new Map(areaCodes().map((entry) => [entry.code, entry.cities]))
312
+ );
313
+ function toNationalNumber(input) {
314
+ let digits = chunkVPBMIYO2_cjs.stripSeparators(chunkVPBMIYO2_cjs.toAsciiDigits(input));
315
+ if (digits.startsWith("+")) {
316
+ digits = digits.slice(1);
317
+ if (!digits.startsWith("92")) return null;
318
+ digits = digits.slice(2);
319
+ } else if (digits.startsWith("0092")) {
320
+ digits = digits.slice(4);
321
+ } else if (digits.startsWith("92") && digits.length >= 11) {
322
+ digits = digits.slice(2);
323
+ }
324
+ if (digits.startsWith("0")) {
325
+ digits = digits.slice(1);
326
+ }
327
+ return /^\d{8,12}$/.test(digits) ? digits : null;
328
+ }
329
+ function findAreaCode(national) {
330
+ for (let length = 4; length >= 2; length -= 1) {
331
+ const prefix = national.slice(0, length);
332
+ if (areaCodeMap().has(prefix)) {
333
+ return prefix;
334
+ }
335
+ }
336
+ return null;
337
+ }
338
+ function groupDigits(digits, size = 3) {
339
+ return digits.match(new RegExp(`\\d{1,${size}}`, "g"))?.join("-") ?? digits;
340
+ }
341
+ function analyzeNumber(phone) {
342
+ const mobile = chunkYLWZGSFY_cjs.normalizePhoneDigits(phone);
343
+ if (mobile !== null) {
344
+ const national2 = mobile.slice(2);
345
+ return {
346
+ type: "mobile",
347
+ formatted: `0${national2.slice(0, 3)}-${national2.slice(3)}`,
348
+ e164: `+${mobile}`,
349
+ areaCode: null,
350
+ cities: []
351
+ };
352
+ }
353
+ const bareUan = UAN_WITHOUT_AREA_CODE.exec(
354
+ chunkVPBMIYO2_cjs.stripSeparators(chunkVPBMIYO2_cjs.toAsciiDigits(phone))
355
+ );
356
+ if (bareUan) {
357
+ return {
358
+ type: "uan",
359
+ formatted: `111-${groupDigits(bareUan[1])}`,
360
+ e164: null,
361
+ areaCode: null,
362
+ cities: []
363
+ };
364
+ }
365
+ const national = toNationalNumber(phone);
366
+ if (national === null) {
367
+ return null;
368
+ }
369
+ const service = (type, prefix, rest) => ({
370
+ type,
371
+ formatted: `0${prefix}-${rest}`,
372
+ e164: `+92${national}`,
373
+ areaCode: null,
374
+ cities: []
375
+ });
376
+ const tollFree = TOLL_FREE.exec(national);
377
+ if (tollFree) return service("toll-free", "800", tollFree[1]);
378
+ const premium = PREMIUM.exec(national);
379
+ if (premium) return service("premium", "900", premium[1]);
380
+ const personal = PERSONAL.exec(national);
381
+ if (personal) return service("personal", "122", personal[1]);
382
+ const uan = UAN.exec(national);
383
+ if (uan) {
384
+ const code = uan[1];
385
+ return {
386
+ type: "uan",
387
+ formatted: `0${code}-111-${groupDigits(uan[2])}`,
388
+ e164: `+92${national}`,
389
+ areaCode: `0${code}`,
390
+ cities: areaCodeMap().get(code) ?? []
391
+ };
392
+ }
393
+ if (FIXED_LINE.test(national)) {
394
+ const code = findAreaCode(national);
395
+ return {
396
+ type: "landline",
397
+ formatted: code ? `0${code}-${national.slice(code.length)}` : `0${national}`,
398
+ e164: `+92${national}`,
399
+ areaCode: code ? `0${code}` : null,
400
+ cities: code ? areaCodeMap().get(code) ?? [] : []
401
+ };
402
+ }
403
+ return null;
404
+ }
405
+ function getNumberType(phone) {
406
+ return analyzeNumber(phone)?.type ?? null;
407
+ }
408
+ function validateLandline(phone) {
409
+ return getNumberType(phone) === "landline";
410
+ }
411
+ function getAreaCode(city) {
412
+ const key = chunkVPBMIYO2_cjs.normalizeKey(city);
413
+ const entry = areaCodes().find(
414
+ (item) => item.cities.some((name) => chunkVPBMIYO2_cjs.normalizeKey(name) === key)
415
+ );
416
+ return entry ? `0${entry.code}` : null;
417
+ }
418
+
419
+ exports.analyzeNumber = analyzeNumber;
420
+ exports.getAreaCode = getAreaCode;
421
+ exports.getNumberType = getNumberType;
422
+ exports.validateLandline = validateLandline;
@@ -0,0 +1,33 @@
1
+ import { validateCNIC } from './chunk-EEVNLTB4.js';
2
+ import { toAsciiDigits, stripSeparators } from './chunk-ENQ7O7VW.js';
3
+
4
+ // src/tax.ts
5
+ function analyzeNTN(ntn) {
6
+ const trimmed = toAsciiDigits(ntn.trim());
7
+ if (validateCNIC(trimmed)) {
8
+ const digits = stripSeparators(trimmed);
9
+ return {
10
+ type: "individual",
11
+ digits,
12
+ formatted: `${digits.slice(0, 5)}-${digits.slice(5, 12)}-${digits[12]}`
13
+ };
14
+ }
15
+ const match = /^(\d{7})(?:[-‐‑‒–— ]?(\d))?$/.exec(trimmed);
16
+ if (!match) {
17
+ return null;
18
+ }
19
+ const [, base, check] = match;
20
+ return {
21
+ type: "business",
22
+ digits: `${base}${check ?? ""}`,
23
+ formatted: check === void 0 ? base : `${base}-${check}`
24
+ };
25
+ }
26
+ function validateNTN(ntn) {
27
+ return analyzeNTN(ntn) !== null;
28
+ }
29
+ function validateSTRN(strn) {
30
+ return /^\d{13}$/.test(stripSeparators(toAsciiDigits(strn)));
31
+ }
32
+
33
+ export { analyzeNTN, validateNTN, validateSTRN };
@@ -0,0 +1,108 @@
1
+ 'use strict';
2
+
3
+ // src/hijri.ts
4
+ var HIJRI_MONTHS = [
5
+ "Muharram",
6
+ "Safar",
7
+ "Rabi al-Awwal",
8
+ "Rabi al-Thani",
9
+ "Jumada al-Awwal",
10
+ "Jumada al-Thani",
11
+ "Rajab",
12
+ "Shaaban",
13
+ "Ramadan",
14
+ "Shawwal",
15
+ "Dhu al-Qadah",
16
+ "Dhu al-Hijjah"
17
+ ];
18
+ function toHijri(date, options = {}) {
19
+ assertValidDate(date);
20
+ const jdn = gregorianToJulianDayNumber(
21
+ date.getFullYear(),
22
+ date.getMonth() + 1,
23
+ date.getDate()
24
+ );
25
+ return julianDayNumberToHijri(jdn + resolveOffset(options));
26
+ }
27
+ function fromHijri(hijri, options = {}) {
28
+ assertValidHijri(hijri);
29
+ const jdn = hijriToJulianDayNumber(hijri.year, hijri.month, hijri.day) - resolveOffset(options);
30
+ const { year, month, day } = julianDayNumberToGregorian(jdn);
31
+ const result = new Date(year, month - 1, day);
32
+ result.setFullYear(year);
33
+ return result;
34
+ }
35
+ function formatHijri(date, options = {}) {
36
+ const hijri = toHijri(date, options);
37
+ return `${hijri.day} ${HIJRI_MONTHS[hijri.month - 1]} ${hijri.year}`;
38
+ }
39
+ function getHijriMonthName(month) {
40
+ if (!Number.isInteger(month) || month < 1 || month > 12) {
41
+ return null;
42
+ }
43
+ return HIJRI_MONTHS[month - 1] ?? null;
44
+ }
45
+ function isRamadan(date, options = {}) {
46
+ return toHijri(date, options).month === 9;
47
+ }
48
+ function assertValidDate(date) {
49
+ if (!(date instanceof Date) || Number.isNaN(date.getTime())) {
50
+ throw new RangeError("Invalid Date");
51
+ }
52
+ }
53
+ function assertValidHijri(hijri) {
54
+ const { year, month, day } = hijri;
55
+ if (!Number.isInteger(year) || !Number.isInteger(month) || !Number.isInteger(day) || year < 1 || month < 1 || month > 12 || day < 1 || day > 30) {
56
+ throw new RangeError(
57
+ `Invalid Hijri date: ${String(year)}-${String(month)}-${String(day)}`
58
+ );
59
+ }
60
+ }
61
+ function resolveOffset(options) {
62
+ const offset = options.offset ?? 0;
63
+ if (!Number.isInteger(offset)) {
64
+ throw new RangeError(
65
+ `Hijri offset must be an integer, received ${String(offset)}`
66
+ );
67
+ }
68
+ return offset;
69
+ }
70
+ function gregorianToJulianDayNumber(year, month, day) {
71
+ const a = Math.floor((14 - month) / 12);
72
+ const y = year + 4800 - a;
73
+ const m = month + 12 * a - 3;
74
+ return day + Math.floor((153 * m + 2) / 5) + 365 * y + Math.floor(y / 4) - Math.floor(y / 100) + Math.floor(y / 400) - 32045;
75
+ }
76
+ function julianDayNumberToGregorian(jdn) {
77
+ const a = jdn + 32044;
78
+ const b = Math.floor((4 * a + 3) / 146097);
79
+ const c = a - Math.floor(146097 * b / 4);
80
+ const d = Math.floor((4 * c + 3) / 1461);
81
+ const e = c - Math.floor(1461 * d / 4);
82
+ const m = Math.floor((5 * e + 2) / 153);
83
+ return {
84
+ day: e - Math.floor((153 * m + 2) / 5) + 1,
85
+ month: m + 3 - 12 * Math.floor(m / 10),
86
+ year: 100 * b + d - 4800 + Math.floor(m / 10)
87
+ };
88
+ }
89
+ function julianDayNumberToHijri(jdn) {
90
+ const l = jdn - 1948440 + 10632;
91
+ const n = Math.floor((l - 1) / 10631);
92
+ const l2 = l - 10631 * n + 354;
93
+ const j = Math.floor((10985 - l2) / 5316) * Math.floor(50 * l2 / 17719) + Math.floor(l2 / 5670) * Math.floor(43 * l2 / 15238);
94
+ const l3 = l2 - Math.floor((30 - j) / 15) * Math.floor(17719 * j / 50) - Math.floor(j / 16) * Math.floor(15238 * j / 43) + 29;
95
+ const month = Math.floor(24 * l3 / 709);
96
+ const day = l3 - Math.floor(709 * month / 24);
97
+ const year = 30 * n + j - 30;
98
+ return { year, month, day };
99
+ }
100
+ function hijriToJulianDayNumber(year, month, day) {
101
+ return Math.floor((11 * year + 3) / 30) + 354 * year + 30 * month - Math.floor((month - 1) / 2) + day + 1948440 - 385;
102
+ }
103
+
104
+ exports.formatHijri = formatHijri;
105
+ exports.fromHijri = fromHijri;
106
+ exports.getHijriMonthName = getHijriMonthName;
107
+ exports.isRamadan = isRamadan;
108
+ exports.toHijri = toHijri;