@timardex/cluemart-shared 1.5.807 → 1.5.808

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.
@@ -88,10 +88,12 @@ __export(utils_exports, {
88
88
  isFutureDatesBeforeThreshold: () => isFutureDatesBeforeThreshold,
89
89
  isIsoDateString: () => isIsoDateString,
90
90
  isResourceImageActive: () => isResourceImageActive,
91
+ isValidIrdNumber: () => isValidIrdNumber,
91
92
  licenseNiceNames: () => licenseNiceNames,
92
93
  mapArrayToOptions: () => mapArrayToOptions,
93
94
  matchesCategory: () => matchesCategory,
94
95
  matchesSelectedDate: () => matchesSelectedDate,
96
+ normalizeIrdNumber: () => normalizeIrdNumber,
95
97
  normalizeResourceImage: () => normalizeResourceImage,
96
98
  normalizeUrl: () => normalizeUrl,
97
99
  nzStartOfDay: () => nzStartOfDay,
@@ -1885,6 +1887,44 @@ var AFFILIATE_PARTICIPANT_TYPE_LABELS = {
1885
1887
  ["SOLE_TRADER" /* SOLE_TRADER */]: "Sole Trader",
1886
1888
  ["COMPANY" /* COMPANY */]: "Company"
1887
1889
  };
1890
+
1891
+ // src/utils/irdNumber.ts
1892
+ var PRIMARY_WEIGHTS = [3, 2, 7, 6, 5, 4, 3, 2];
1893
+ var SECONDARY_WEIGHTS = [7, 4, 3, 2, 5, 2, 7, 6];
1894
+ var IRD_MIN = 1e7;
1895
+ var IRD_MAX = 2e8;
1896
+ function calculateCheckDigit(baseDigits, weights) {
1897
+ const sum = [...baseDigits].reduce(
1898
+ (acc, digit, index) => acc + Number(digit) * weights[index],
1899
+ 0
1900
+ );
1901
+ const remainder = sum % 11;
1902
+ return remainder === 0 ? 0 : 11 - remainder;
1903
+ }
1904
+ function normalizeIrdNumber(value) {
1905
+ return value.replace(/\D/g, "");
1906
+ }
1907
+ function isValidIrdNumber(value) {
1908
+ const digits = normalizeIrdNumber(value);
1909
+ if (!/^\d{8,9}$/.test(digits)) {
1910
+ return false;
1911
+ }
1912
+ const ird = Number(digits);
1913
+ if (ird < IRD_MIN || ird > IRD_MAX) {
1914
+ return false;
1915
+ }
1916
+ const padded = digits.padStart(9, "0");
1917
+ const baseDigits = padded.slice(0, -1);
1918
+ const checkDigit = Number(padded.slice(-1));
1919
+ let calculated = calculateCheckDigit(baseDigits, PRIMARY_WEIGHTS);
1920
+ if (calculated === 10) {
1921
+ calculated = calculateCheckDigit(baseDigits, SECONDARY_WEIGHTS);
1922
+ if (calculated === 10) {
1923
+ return false;
1924
+ }
1925
+ }
1926
+ return calculated === checkDigit;
1927
+ }
1888
1928
  // Annotate the CommonJS export names for ESM import in node:
1889
1929
  0 && (module.exports = {
1890
1930
  AFFILIATE_PARTICIPANT_TYPE_LABELS,
@@ -1945,10 +1985,12 @@ var AFFILIATE_PARTICIPANT_TYPE_LABELS = {
1945
1985
  isFutureDatesBeforeThreshold,
1946
1986
  isIsoDateString,
1947
1987
  isResourceImageActive,
1988
+ isValidIrdNumber,
1948
1989
  licenseNiceNames,
1949
1990
  mapArrayToOptions,
1950
1991
  matchesCategory,
1951
1992
  matchesSelectedDate,
1993
+ normalizeIrdNumber,
1952
1994
  normalizeResourceImage,
1953
1995
  normalizeUrl,
1954
1996
  nzStartOfDay,