pakdatakit 1.1.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +907 -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-422X6FEZ.cjs +220 -0
  9. package/dist/chunk-432ZYMYV.js +31 -0
  10. package/dist/chunk-4VVFS6FN.cjs +715 -0
  11. package/dist/chunk-6TSKA2PH.js +38 -0
  12. package/dist/chunk-APXP7OK7.cjs +226 -0
  13. package/dist/chunk-AUATLZA5.cjs +168 -0
  14. package/dist/chunk-BSS4Z7NI.cjs +422 -0
  15. package/dist/chunk-CEPNSHIC.js +33 -0
  16. package/dist/chunk-CQKK3S7A.js +217 -0
  17. package/dist/chunk-CYJJ7KGC.cjs +108 -0
  18. package/dist/chunk-EEVNLTB4.js +32 -0
  19. package/dist/chunk-ENQ7O7VW.js +32 -0
  20. package/dist/chunk-H4DVWUYH.js +231 -0
  21. package/dist/chunk-H6M6L26S.cjs +37 -0
  22. package/dist/chunk-HBOZIITD.js +351 -0
  23. package/dist/chunk-HTCSHHOR.cjs +35 -0
  24. package/dist/chunk-JKE4AMSZ.js +47 -0
  25. package/dist/chunk-K6CZFCX6.js +1642 -0
  26. package/dist/chunk-KEHCTYLO.cjs +52 -0
  27. package/dist/chunk-KQKW2ZEK.cjs +18 -0
  28. package/dist/chunk-L2BDDM2W.js +165 -0
  29. package/dist/chunk-L45UXUWX.js +21 -0
  30. package/dist/chunk-LIYNKIKS.js +709 -0
  31. package/dist/chunk-LVHTH4P7.cjs +41 -0
  32. package/dist/chunk-OVUR47QH.cjs +22 -0
  33. package/dist/chunk-P4CGOJEM.js +16 -0
  34. package/dist/chunk-PHHKIMO2.cjs +35 -0
  35. package/dist/chunk-QQQKISXT.js +223 -0
  36. package/dist/chunk-T3E4B5MJ.js +417 -0
  37. package/dist/chunk-VPBMIYO2.cjs +38 -0
  38. package/dist/chunk-WPKV5JT3.cjs +235 -0
  39. package/dist/chunk-XCXFGTHW.cjs +355 -0
  40. package/dist/chunk-XT4ZNXRC.js +20 -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 +119 -0
  92. package/dist/raast.d.ts +119 -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,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;
@@ -0,0 +1,32 @@
1
+ import { toAsciiDigits } from './chunk-ENQ7O7VW.js';
2
+
3
+ // src/cnic.ts
4
+ var CNIC_PATTERN = /^[1-8]\d{4}([-‐‑‒–—. ]?)\d{7}\1\d$/;
5
+ function validateCNIC(cnic) {
6
+ return CNIC_PATTERN.test(toAsciiDigits(cnic.trim()));
7
+ }
8
+ var CNIC_PROVINCES = {
9
+ "1": "Khyber Pakhtunkhwa",
10
+ "2": "Khyber Pakhtunkhwa",
11
+ "3": "Punjab",
12
+ "4": "Sindh",
13
+ "5": "Balochistan",
14
+ "6": "Islamabad Capital Territory",
15
+ "7": "Gilgit-Baltistan",
16
+ "8": "Azad Jammu and Kashmir"
17
+ };
18
+ function getCNICInfo(cnic) {
19
+ if (!validateCNIC(cnic)) {
20
+ return null;
21
+ }
22
+ const digits = toAsciiDigits(cnic).replace(/\D/g, "");
23
+ const lastDigit = Number(digits[12]);
24
+ return {
25
+ digits,
26
+ formatted: `${digits.slice(0, 5)}-${digits.slice(5, 12)}-${digits[12]}`,
27
+ province: CNIC_PROVINCES[digits[0]],
28
+ gender: lastDigit % 2 === 1 ? "male" : "female"
29
+ };
30
+ }
31
+
32
+ export { getCNICInfo, validateCNIC };
@@ -0,0 +1,32 @@
1
+ // src/internal/normalize.ts
2
+ var URDU_DIGITS = "\u06F0\u06F1\u06F2\u06F3\u06F4\u06F5\u06F6\u06F7\u06F8\u06F9";
3
+ var ARABIC_INDIC_DIGITS = "\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669";
4
+ var NON_LATIN_DIGIT_PATTERN = /[۰-۹٠-٩]/g;
5
+ function toAsciiDigits(input) {
6
+ return input.replace(NON_LATIN_DIGIT_PATTERN, (char) => {
7
+ const urdu = URDU_DIGITS.indexOf(char);
8
+ return String(urdu >= 0 ? urdu : ARABIC_INDIC_DIGITS.indexOf(char));
9
+ });
10
+ }
11
+ function stripSeparators(input) {
12
+ return input.replace(/[\s\-‐‑‒–—./()]/g, "");
13
+ }
14
+ function normalizeWhitespace(input) {
15
+ return input.trim().replace(/\s+/g, " ");
16
+ }
17
+ function normalizeKey(input) {
18
+ return normalizeWhitespace(input).toLowerCase();
19
+ }
20
+ function lazy(factory) {
21
+ let value;
22
+ let ready = false;
23
+ return () => {
24
+ if (!ready) {
25
+ value = factory();
26
+ ready = true;
27
+ }
28
+ return value;
29
+ };
30
+ }
31
+
32
+ export { lazy, normalizeKey, normalizeWhitespace, stripSeparators, toAsciiDigits };
@@ -0,0 +1,231 @@
1
+ import { validateIBAN } from './chunk-CQKK3S7A.js';
2
+ import { stripSeparators } from './chunk-ENQ7O7VW.js';
3
+
4
+ // src/internal/emv.ts
5
+ function isTemplateId(id) {
6
+ const n = Number(id);
7
+ return n >= 26 && n <= 51 || n === 62 || n === 64 || n >= 80 && n <= 99;
8
+ }
9
+ function crc16(text) {
10
+ let crc = 65535;
11
+ for (const byte of new TextEncoder().encode(text)) {
12
+ crc ^= byte << 8;
13
+ for (let bit = 0; bit < 8; bit += 1) {
14
+ crc = crc & 32768 ? (crc << 1 ^ 4129) & 65535 : crc << 1 & 65535;
15
+ }
16
+ }
17
+ return crc.toString(16).toUpperCase().padStart(4, "0");
18
+ }
19
+ function encodeField(id, value) {
20
+ const length = [...value].length;
21
+ if (length > 99) {
22
+ throw new RangeError(`EMV field ${id} is longer than 99 characters`);
23
+ }
24
+ return `${id}${String(length).padStart(2, "0")}${value}`;
25
+ }
26
+ function parseFields(data, nested = true) {
27
+ const chars = [...data];
28
+ const fields = [];
29
+ let i = 0;
30
+ while (i < chars.length) {
31
+ const header = chars.slice(i, i + 4).join("");
32
+ if (!/^\d{4}$/.test(header)) {
33
+ throw new SyntaxError(`Malformed EMV field at position ${i}`);
34
+ }
35
+ const id = header.slice(0, 2);
36
+ const length = Number(header.slice(2));
37
+ if (i + 4 + length > chars.length) {
38
+ throw new SyntaxError(`EMV field ${id} is truncated`);
39
+ }
40
+ const value = chars.slice(i + 4, i + 4 + length).join("");
41
+ const field = { id, value };
42
+ if (nested && isTemplateId(id)) {
43
+ field.children = parseFields(value, false);
44
+ }
45
+ fields.push(field);
46
+ i += 4 + length;
47
+ }
48
+ return fields;
49
+ }
50
+ function withCrc(payload) {
51
+ const data = `${payload}6304`;
52
+ return `${data}${crc16(data)}`;
53
+ }
54
+
55
+ // src/raast.ts
56
+ var PK_IBAN_PATTERN = /^PK\d{2}[A-Z]{4}[A-Z0-9]{16}$/;
57
+ var RAAST_P2P_SCHEME = "30";
58
+ function formatAmount(amount, maxLength, label) {
59
+ if (!Number.isFinite(amount) || amount <= 0) {
60
+ throw new RangeError(`${label} must be a positive number`);
61
+ }
62
+ const text = amount.toFixed(2);
63
+ if (text.length > maxLength) {
64
+ throw new RangeError(`${label} is too large for a Raast QR code`);
65
+ }
66
+ return text;
67
+ }
68
+ function checkLength(value, max, label) {
69
+ if ([...value].length > max) {
70
+ throw new RangeError(`${label} must be at most ${max} characters`);
71
+ }
72
+ return value;
73
+ }
74
+ function normalizeIban(iban) {
75
+ const normalized = stripSeparators(iban).toUpperCase();
76
+ if (!validateIBAN(normalized)) {
77
+ throw new RangeError(`Invalid Pakistani IBAN: ${iban}`);
78
+ }
79
+ return normalized;
80
+ }
81
+ function createRaastP2PQr(options) {
82
+ const iban = normalizeIban(options.iban);
83
+ let payload = encodeField("00", "02") + encodeField("01", options.amount === void 0 ? "11" : "12") + encodeField("02", RAAST_P2P_SCHEME);
84
+ if (options.bankName) {
85
+ payload += encodeField("03", checkLength(options.bankName, 25, "bankName"));
86
+ }
87
+ payload += encodeField("04", iban);
88
+ if (options.amount !== void 0) {
89
+ payload += encodeField("05", formatAmount(options.amount, 10, "amount"));
90
+ }
91
+ if (options.particulars) {
92
+ payload += encodeField(
93
+ "06",
94
+ checkLength(options.particulars, 30, "particulars")
95
+ );
96
+ }
97
+ const data = `${payload}1004`;
98
+ return `${data}${crc16(data)}`;
99
+ }
100
+ function createMerchantQr(options) {
101
+ const tag = options.merchantAccount.tag ?? "28";
102
+ if (!/^(2[6-9]|[34]\d|5[01])$/.test(tag)) {
103
+ throw new RangeError("merchantAccount.tag must be between 26 and 51");
104
+ }
105
+ const accountFields = Object.entries(options.merchantAccount.fields);
106
+ if (accountFields.length === 0) {
107
+ throw new RangeError("merchantAccount.fields must not be empty");
108
+ }
109
+ const mcc = options.mcc ?? "0000";
110
+ if (!/^\d{4}$/.test(mcc)) {
111
+ throw new RangeError("mcc must be 4 digits");
112
+ }
113
+ if (options.dueDate === void 0 !== (options.amountAfterDueDate === void 0)) {
114
+ throw new RangeError(
115
+ "dueDate and amountAfterDueDate must be used together"
116
+ );
117
+ }
118
+ const dynamic = options.dynamic ?? options.amount !== void 0;
119
+ const account = accountFields.map(([id, value]) => {
120
+ if (!/^\d{2}$/.test(id)) {
121
+ throw new RangeError(`Invalid merchant account sub-field ID: ${id}`);
122
+ }
123
+ return encodeField(id, value);
124
+ }).join("");
125
+ let payload = encodeField("00", "01") + encodeField("01", dynamic ? "12" : "11") + encodeField(tag, account) + encodeField("52", mcc) + encodeField("53", "586");
126
+ if (options.amount !== void 0) {
127
+ payload += encodeField("54", formatAmount(options.amount, 13, "amount"));
128
+ }
129
+ payload += encodeField("58", "PK") + encodeField("59", checkLength(options.merchantName, 25, "merchantName")) + encodeField("60", checkLength(options.city, 15, "city"));
130
+ let additional = "";
131
+ if (options.billNumber) {
132
+ additional += encodeField(
133
+ "01",
134
+ checkLength(options.billNumber, 25, "billNumber")
135
+ );
136
+ }
137
+ if (options.mobileNumber) {
138
+ additional += encodeField(
139
+ "02",
140
+ checkLength(options.mobileNumber, 15, "mobileNumber")
141
+ );
142
+ }
143
+ if (options.reference) {
144
+ additional += encodeField(
145
+ "05",
146
+ checkLength(options.reference, 25, "reference")
147
+ );
148
+ }
149
+ if (options.dueDate !== void 0 && options.amountAfterDueDate !== void 0) {
150
+ const d = options.dueDate;
151
+ if (Number.isNaN(d.getTime())) {
152
+ throw new RangeError("dueDate is invalid");
153
+ }
154
+ const ddmmyyyy = String(d.getDate()).padStart(2, "0") + String(d.getMonth() + 1).padStart(2, "0") + String(d.getFullYear()).padStart(4, "0");
155
+ additional += encodeField("50", ddmmyyyy) + encodeField(
156
+ "51",
157
+ formatAmount(options.amountAfterDueDate, 13, "amountAfterDueDate")
158
+ );
159
+ }
160
+ if (additional) {
161
+ payload += encodeField("62", additional);
162
+ }
163
+ const result = withCrc(payload);
164
+ if ([...result].length > 512) {
165
+ throw new RangeError("QR payload exceeds 512 characters");
166
+ }
167
+ return result;
168
+ }
169
+ function fieldValue(fields, id) {
170
+ return fields.find((field) => field.id === id)?.value ?? null;
171
+ }
172
+ function toAmount(value) {
173
+ if (value === null) return null;
174
+ const amount = Number(value);
175
+ return Number.isFinite(amount) ? amount : null;
176
+ }
177
+ function parseRaastQr(payload) {
178
+ const text = payload.trim();
179
+ let fields;
180
+ try {
181
+ fields = parseFields(text);
182
+ } catch {
183
+ return null;
184
+ }
185
+ const format = fieldValue(fields, "00");
186
+ const kind = format === "02" ? "p2p" : format === "01" ? "merchant" : null;
187
+ if (kind === null) {
188
+ return null;
189
+ }
190
+ const crcId = kind === "p2p" ? "10" : "63";
191
+ const last = fields[fields.length - 1];
192
+ const crcValid = last?.id === crcId && last.value.length === 4 && crc16(text.slice(0, -4)) === last.value.toUpperCase();
193
+ let iban = null;
194
+ if (kind === "p2p") {
195
+ iban = fieldValue(fields, "04");
196
+ } else {
197
+ for (const field of fields) {
198
+ const n = Number(field.id);
199
+ if (n >= 26 && n <= 51) {
200
+ const match = field.children?.find(
201
+ (child) => PK_IBAN_PATTERN.test(child.value)
202
+ );
203
+ if (match) {
204
+ iban = match.value;
205
+ break;
206
+ }
207
+ }
208
+ }
209
+ }
210
+ const additional = fields.find((field) => field.id === "62")?.children ?? [];
211
+ const due = fieldValue(additional, "50");
212
+ return {
213
+ kind,
214
+ dynamic: fieldValue(fields, "01") === "12",
215
+ crcValid,
216
+ iban,
217
+ ibanValid: iban !== null && validateIBAN(iban),
218
+ amount: toAmount(fieldValue(fields, kind === "p2p" ? "05" : "54")),
219
+ bankName: kind === "p2p" ? fieldValue(fields, "03") : null,
220
+ particulars: kind === "p2p" ? fieldValue(fields, "06") : null,
221
+ merchantName: kind === "merchant" ? fieldValue(fields, "59") : null,
222
+ city: kind === "merchant" ? fieldValue(fields, "60") : null,
223
+ mcc: kind === "merchant" ? fieldValue(fields, "52") : null,
224
+ billNumber: fieldValue(additional, "01"),
225
+ dueDate: due && /^\d{8}$/.test(due) ? `${due.slice(4)}-${due.slice(2, 4)}-${due.slice(0, 2)}` : null,
226
+ amountAfterDueDate: toAmount(fieldValue(additional, "51")),
227
+ fields
228
+ };
229
+ }
230
+
231
+ export { createMerchantQr, createRaastP2PQr, parseRaastQr };
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ var chunkHTCSHHOR_cjs = require('./chunk-HTCSHHOR.cjs');
4
+ var chunkVPBMIYO2_cjs = require('./chunk-VPBMIYO2.cjs');
5
+
6
+ // src/tax.ts
7
+ function analyzeNTN(ntn) {
8
+ const trimmed = chunkVPBMIYO2_cjs.toAsciiDigits(ntn.trim());
9
+ if (chunkHTCSHHOR_cjs.validateCNIC(trimmed)) {
10
+ const digits = chunkVPBMIYO2_cjs.stripSeparators(trimmed);
11
+ return {
12
+ type: "individual",
13
+ digits,
14
+ formatted: `${digits.slice(0, 5)}-${digits.slice(5, 12)}-${digits[12]}`
15
+ };
16
+ }
17
+ const match = /^(\d{7})(?:[-‐‑‒–— ]?(\d))?$/.exec(trimmed);
18
+ if (!match) {
19
+ return null;
20
+ }
21
+ const [, base, check] = match;
22
+ return {
23
+ type: "business",
24
+ digits: `${base}${check ?? ""}`,
25
+ formatted: check === void 0 ? base : `${base}-${check}`
26
+ };
27
+ }
28
+ function validateNTN(ntn) {
29
+ return analyzeNTN(ntn) !== null;
30
+ }
31
+ function validateSTRN(strn) {
32
+ return /^\d{13}$/.test(chunkVPBMIYO2_cjs.stripSeparators(chunkVPBMIYO2_cjs.toAsciiDigits(strn)));
33
+ }
34
+
35
+ exports.analyzeNTN = analyzeNTN;
36
+ exports.validateNTN = validateNTN;
37
+ exports.validateSTRN = validateSTRN;