@arkyn/shared 3.0.1-beta.116 → 3.0.1-beta.118

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 (92) hide show
  1. package/dist/bundle.js +385 -283
  2. package/dist/bundle.umd.cjs +6 -6
  3. package/dist/formats/formatDate.d.ts +43 -15
  4. package/dist/formats/formatDate.d.ts.map +1 -1
  5. package/dist/formats/formatDate.js +60 -25
  6. package/dist/formats/formatJsonObject.d.ts +6 -7
  7. package/dist/formats/formatJsonObject.d.ts.map +1 -1
  8. package/dist/formats/formatJsonObject.js +17 -17
  9. package/dist/formats/formatToCep.d.ts +5 -12
  10. package/dist/formats/formatToCep.d.ts.map +1 -1
  11. package/dist/formats/formatToCep.js +11 -16
  12. package/dist/formats/formatToCnpj.d.ts +3 -13
  13. package/dist/formats/formatToCnpj.d.ts.map +1 -1
  14. package/dist/formats/formatToCnpj.js +9 -17
  15. package/dist/formats/formatToCpf.d.ts +5 -13
  16. package/dist/formats/formatToCpf.d.ts.map +1 -1
  17. package/dist/formats/formatToCpf.js +11 -17
  18. package/dist/formats/formatToCurrency.d.ts +18 -14
  19. package/dist/formats/formatToCurrency.d.ts.map +1 -1
  20. package/dist/formats/formatToCurrency.js +21 -14
  21. package/dist/formats/formatToEllipsis.d.ts +8 -5
  22. package/dist/formats/formatToEllipsis.d.ts.map +1 -1
  23. package/dist/formats/formatToEllipsis.js +21 -7
  24. package/dist/formats/formatToHiddenDigits.d.ts +16 -16
  25. package/dist/formats/formatToHiddenDigits.d.ts.map +1 -1
  26. package/dist/formats/formatToHiddenDigits.js +19 -19
  27. package/dist/formats/formatToPhone.d.ts +1 -1
  28. package/dist/formats/formatToPhone.d.ts.map +1 -1
  29. package/dist/formats/formatToPhone.js +3 -3
  30. package/dist/generators/generateColorByString.d.ts +7 -4
  31. package/dist/generators/generateColorByString.d.ts.map +1 -1
  32. package/dist/generators/generateColorByString.js +10 -6
  33. package/dist/generators/generateId.d.ts +3 -3
  34. package/dist/generators/generateSlug.d.ts +10 -3
  35. package/dist/generators/generateSlug.d.ts.map +1 -1
  36. package/dist/generators/generateSlug.js +11 -4
  37. package/dist/index.d.ts +10 -10
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +12 -10
  40. package/dist/{services/truncateLargeFields.d.ts → parsers/parseLargeFields.d.ts} +9 -11
  41. package/dist/parsers/parseLargeFields.d.ts.map +1 -0
  42. package/dist/{services/truncateLargeFields.js → parsers/parseLargeFields.js} +12 -13
  43. package/dist/parsers/parseSensitiveData.d.ts +23 -0
  44. package/dist/parsers/parseSensitiveData.d.ts.map +1 -0
  45. package/dist/{services/maskSensitiveData.js → parsers/parseSensitiveData.js} +10 -12
  46. package/dist/parsers/parseToDate.d.ts +41 -0
  47. package/dist/parsers/parseToDate.d.ts.map +1 -0
  48. package/dist/parsers/parseToDate.js +67 -0
  49. package/dist/services/validateDateService.d.ts +85 -0
  50. package/dist/services/validateDateService.d.ts.map +1 -0
  51. package/dist/services/validateDateService.js +132 -0
  52. package/dist/{services → utilities}/calculateCardInstallment.d.ts +16 -18
  53. package/dist/utilities/calculateCardInstallment.d.ts.map +1 -0
  54. package/dist/{services → utilities}/calculateCardInstallment.js +12 -15
  55. package/dist/utilities/ensureQuotes.d.ts +21 -0
  56. package/dist/utilities/ensureQuotes.d.ts.map +1 -0
  57. package/dist/{services → utilities}/ensureQuotes.js +12 -4
  58. package/dist/utilities/isHtml.d.ts +22 -0
  59. package/dist/utilities/isHtml.d.ts.map +1 -0
  60. package/dist/utilities/isHtml.js +24 -0
  61. package/dist/{services → utilities}/removeCurrencySymbols.d.ts +6 -4
  62. package/dist/utilities/removeCurrencySymbols.d.ts.map +1 -0
  63. package/dist/{services → utilities}/removeCurrencySymbols.js +8 -7
  64. package/dist/utilities/removeNonNumeric.d.ts +16 -0
  65. package/dist/utilities/removeNonNumeric.d.ts.map +1 -0
  66. package/dist/utilities/removeNonNumeric.js +17 -0
  67. package/dist/utilities/stripHtmlTags.d.ts +19 -0
  68. package/dist/utilities/stripHtmlTags.d.ts.map +1 -0
  69. package/dist/utilities/stripHtmlTags.js +24 -0
  70. package/package.json +1 -4
  71. package/dist/formats/formatToCpfCnpj.d.ts +0 -24
  72. package/dist/formats/formatToCpfCnpj.d.ts.map +0 -1
  73. package/dist/formats/formatToCpfCnpj.js +0 -33
  74. package/dist/formats/formatToDate.d.ts +0 -32
  75. package/dist/formats/formatToDate.d.ts.map +0 -1
  76. package/dist/formats/formatToDate.js +0 -50
  77. package/dist/services/calculateCardInstallment.d.ts.map +0 -1
  78. package/dist/services/ensureQuotes.d.ts +0 -14
  79. package/dist/services/ensureQuotes.d.ts.map +0 -1
  80. package/dist/services/isHtml.d.ts +0 -22
  81. package/dist/services/isHtml.d.ts.map +0 -1
  82. package/dist/services/isHtml.js +0 -24
  83. package/dist/services/maskSensitiveData.d.ts +0 -26
  84. package/dist/services/maskSensitiveData.d.ts.map +0 -1
  85. package/dist/services/removeCurrencySymbols.d.ts.map +0 -1
  86. package/dist/services/removeNonNumeric.d.ts +0 -16
  87. package/dist/services/removeNonNumeric.d.ts.map +0 -1
  88. package/dist/services/removeNonNumeric.js +0 -16
  89. package/dist/services/stripHtmlTags.d.ts +0 -16
  90. package/dist/services/stripHtmlTags.d.ts.map +0 -1
  91. package/dist/services/stripHtmlTags.js +0 -16
  92. package/dist/services/truncateLargeFields.d.ts.map +0 -1
package/dist/bundle.js CHANGED
@@ -1,102 +1,189 @@
1
- function E(_, n) {
2
- const e = (a) => a.toString().padStart(2, "0"), s = {
3
- YYYY: _.getFullYear().toString(),
4
- YY: _.getFullYear().toString().slice(-2),
5
- MM: e(_.getMonth() + 1),
6
- DD: e(_.getDate()),
7
- hh: e(_.getHours()),
8
- mm: e(_.getMinutes()),
9
- ss: e(_.getSeconds())
1
+ class I {
2
+ isLeapYear(_) {
3
+ return _ % 4 === 0 && _ % 100 !== 0 || _ % 400 === 0;
4
+ }
5
+ getDaysInMonth(_, s) {
6
+ const n = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
7
+ return _ === 2 && this.isLeapYear(s) ? 29 : n[_ - 1];
8
+ }
9
+ validateDayInMonth(_, s, n) {
10
+ const e = this.getDaysInMonth(s, n);
11
+ if (_ > e) {
12
+ const c = `Day ${_} is not valid for ${[
13
+ "January",
14
+ "February",
15
+ "March",
16
+ "April",
17
+ "May",
18
+ "June",
19
+ "July",
20
+ "August",
21
+ "September",
22
+ "October",
23
+ "November",
24
+ "December"
25
+ ][s - 1]}`, i = `Day ${_} is not valid for February ${n} (non-leap year)`;
26
+ throw s === 2 && _ === 29 ? new Error(i) : new Error(c);
27
+ }
28
+ }
29
+ /**
30
+ * Validates the components of a date (year, month, and day).
31
+ *
32
+ * @param {number} year - The year to validate (must be 4 digits).
33
+ * @param {number} month - The month to validate (must be between 1 and 12).
34
+ * @param {number} day - The day to validate (must be between 1 and 31, and valid for the month).
35
+ *
36
+ * @throws {Error} "Year should be four digits" - If the year doesn't have exactly 4 digits.
37
+ * @throws {Error} "Month should be between 1 and 12" - If the month is out of valid range.
38
+ * @throws {Error} "Day should be between 1 and 31" - If the day is out of valid range.
39
+ * @throws {Error} Month-specific error - If the day is invalid for the specific month.
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * const service = new ValidateDateService();
44
+ * service.validateDateParts(2024, 2, 29); // Valid leap year date
45
+ * service.validateDateParts(2023, 2, 29); // Throws error - not a leap year
46
+ * service.validateDateParts(2024, 4, 31); // Throws error - April has only 30 days
47
+ * ```
48
+ */
49
+ validateDateParts(_, s, n) {
50
+ const e = {
51
+ year: "Year should be four digits",
52
+ month: "Month should be between 1 and 12",
53
+ day: "Day should be between 1 and 31"
54
+ };
55
+ if (`${_}`.length !== 4) throw new Error(e.year);
56
+ if (s < 1 || s > 12) throw new Error(e.month);
57
+ if (n < 1 || n > 31) throw new Error(e.day);
58
+ this.validateDayInMonth(n, s, _);
59
+ }
60
+ /**
61
+ * Validates that a given format string is supported.
62
+ *
63
+ * @param {string} format - The format string to validate.
64
+ *
65
+ * @throws {Error} "Invalid input format: {format}" - If the format is not one of the valid formats.
66
+ *
67
+ * @remarks
68
+ * Valid formats are:
69
+ * - "brazilianDate": DD/MM/YYYY format
70
+ * - "isoDate": MM-DD-YYYY format
71
+ * - "timestamp": YYYY-MM-DD format
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * const service = new ValidateDateService();
76
+ * service.validateInputFormat("brazilianDate"); // Valid
77
+ * service.validateInputFormat("isoDate"); // Valid
78
+ * service.validateInputFormat("timestamp"); // Valid
79
+ * service.validateInputFormat("customFormat"); // Throws error
80
+ * ```
81
+ */
82
+ validateInputFormat(_) {
83
+ if (!["brazilianDate", "isoDate", "timestamp"].includes(_))
84
+ throw new Error(`Invalid input format: ${_}`);
85
+ }
86
+ }
87
+ function P(a, _) {
88
+ const s = (e) => e.toString().padStart(2, "0"), n = {
89
+ YYYY: a.getUTCFullYear().toString(),
90
+ YY: a.getUTCFullYear().toString().slice(-2),
91
+ MM: s(a.getUTCMonth() + 1),
92
+ DD: s(a.getUTCDate()),
93
+ hh: s(a.getUTCHours()),
94
+ mm: s(a.getUTCMinutes()),
95
+ ss: s(a.getUTCSeconds())
10
96
  };
11
- return n.replace(
97
+ return _.replace(
12
98
  /YYYY|YY|MM|DD|hh|mm|ss/g,
13
- (a) => s[a]
99
+ (e) => n[e]
14
100
  );
15
101
  }
16
- const Z = ([_, n = "00:00:00"], e, s, a = 0) => {
17
- const o = _.split(/[-/]/).map(Number), c = n.split(".")[0].split(":").map(Number);
18
- let r, t, i;
19
- const [p = 0, y = 0, m = 0] = c;
20
- switch (e) {
102
+ function Z([a, _ = "00:00:00"], s, n, e = 0) {
103
+ const t = new I();
104
+ t.validateInputFormat(s);
105
+ const c = a.split(/[-/]/).map(Number), i = _.split(".")[0].split(":").map(Number);
106
+ let o, r, g;
107
+ const [h = 0, C = 0, m = 0] = i;
108
+ switch (s) {
21
109
  case "brazilianDate":
22
- [r, t, i] = o;
110
+ [o, r, g] = c, t.validateDateParts(g, r, o);
23
111
  break;
24
112
  case "isoDate":
25
- [i, t, r] = o;
113
+ [r, o, g] = c, t.validateDateParts(g, r, o);
26
114
  break;
27
115
  case "timestamp":
28
- [i, t, r] = o.map(Number);
116
+ [g, r, o] = c, t.validateDateParts(g, r, o);
29
117
  break;
30
- default:
31
- throw new Error("Invalid input format");
32
118
  }
33
- const k = new Date(i, t - 1, r, p, y, m);
34
- if (isNaN(k.getTime())) throw new Error("Invalid date");
35
- return k.setUTCHours(k.getUTCHours() + a), E(k, s);
36
- }, f = (_, n) => {
37
- const e = " ".repeat(n);
38
- let s = "";
39
- if (typeof _ == "object" && _ !== null)
40
- if (Array.isArray(_))
41
- _.length === 0 ? s += "[]" : (s += `[
42
- `, _.forEach((a, o) => {
43
- s += e + " " + f(a, n + 1), o < _.length - 1 && (s += ","), s += `
119
+ const d = new Date(
120
+ Date.UTC(g, r - 1, o, h, C, m)
121
+ );
122
+ if (isNaN(d.getTime())) throw new Error("Invalid date");
123
+ return d.setUTCHours(d.getUTCHours() + e), P(d, n);
124
+ }
125
+ const y = (a, _) => {
126
+ const s = " ".repeat(_);
127
+ let n = "";
128
+ if (typeof a == "object" && a !== null)
129
+ if (Array.isArray(a))
130
+ a.length === 0 ? n += "[]" : (n += `[
131
+ `, a.forEach((e, t) => {
132
+ n += s + " " + y(e, _ + 1), t < a.length - 1 && (n += ","), n += `
44
133
  `;
45
- }), s += e + "]");
134
+ }), n += s + "]");
46
135
  else {
47
- const a = Object.keys(_);
48
- a.length === 0 ? s += "{}" : (s += `{
49
- `, a.forEach((o, c) => {
50
- s += e + ' "' + o + '": ' + f(_[o], n + 1), c < a.length - 1 && (s += ","), s += `
136
+ const e = Object.keys(a);
137
+ e.length === 0 ? n += "{}" : (n += `{
138
+ `, e.forEach((t, c) => {
139
+ n += s + ' "' + t + '": ' + y(a[t], _ + 1), c < e.length - 1 && (n += ","), n += `
51
140
  `;
52
- }), s += e + "}");
141
+ }), n += s + "}");
53
142
  }
54
- else if (typeof _ == "string")
143
+ else if (typeof a == "string")
55
144
  try {
56
- const a = JSON.parse(_);
57
- s += f(a, n);
145
+ const e = JSON.parse(a);
146
+ n += y(e, _);
58
147
  } catch {
59
- s += '"' + _ + '"';
148
+ n += '"' + a + '"';
60
149
  }
61
150
  else
62
- s += _;
63
- return s;
64
- }, q = (_) => {
151
+ n += a;
152
+ return n;
153
+ }, q = (a) => {
65
154
  try {
66
- const n = JSON.parse(_);
67
- return f(n, 0);
68
- } catch (n) {
155
+ const _ = JSON.parse(a);
156
+ return y(_, 0);
157
+ } catch (_) {
69
158
  throw new Error(`Invalid JSON string
70
- ${n}`);
159
+ ${_}`);
71
160
  }
72
161
  };
73
- function j(_) {
74
- return _.split(" ").map((s) => {
75
- const a = s.charAt(0).toUpperCase(), o = s.slice(1).toLowerCase();
76
- return a + o;
162
+ function j(a) {
163
+ return a.split(" ").map((n) => {
164
+ const e = n.charAt(0).toUpperCase(), t = n.slice(1).toLowerCase();
165
+ return e + t;
77
166
  }).join(" ");
78
167
  }
79
- const g = (_) => _.replace(/[^0-9]/g, ""), Q = (_) => {
80
- const e = g(_).match(/^(\d{5})(\d{3})$/);
81
- if (e) return `${e[1]}-${e[2]}`;
82
- throw new Error("Invalid CEP format");
83
- }, D = (_) => {
84
- const e = g(_).match(/^(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})$/);
85
- if (e)
86
- return `${e[1]}.${e[2]}.${e[3]}/${e[4]}-${e[5]}`;
87
- throw new Error("Invalid CNPJ length");
88
- }, L = (_) => {
89
- const e = g(_).match(/^(\d{3})(\d{3})(\d{3})(\d{2})$/);
90
- if (e) return `${e[1]}.${e[2]}.${e[3]}-${e[4]}`;
91
- throw new Error("Invalid CPF format");
92
- }, X = (_) => {
93
- const n = _.replace(/\D/g, "");
94
- if (n.length === 11)
95
- return L(n);
96
- if (n.length === 14)
97
- return D(n);
98
- throw new Error("Invalid CPF or CNPJ length");
99
- }, N = [
168
+ function k(a) {
169
+ return a.replace(/[^0-9]/g, "");
170
+ }
171
+ function Q(a) {
172
+ const s = k(a).match(/^(\d{5})(\d{3})$/), n = `CEP must be contain 8 numeric digits: ${a}`;
173
+ if (!s) throw new Error(n);
174
+ return `${s[1]}-${s[2]}`;
175
+ }
176
+ function X(a) {
177
+ const s = k(a).match(/^(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})$/), n = `CNPJ must be contain 14 numeric digits: ${a}`;
178
+ if (!s) throw new Error(n);
179
+ return `${s[1]}.${s[2]}.${s[3]}/${s[4]}-${s[5]}`;
180
+ }
181
+ function aa(a) {
182
+ const s = k(a).match(/^(\d{3})(\d{3})(\d{3})(\d{2})$/), n = `CPF must be contain 11 numeric digits: ${a}`;
183
+ if (!s) throw new Error(n);
184
+ return `${s[1]}.${s[2]}.${s[3]}-${s[4]}`;
185
+ }
186
+ const N = [
100
187
  {
101
188
  name: "Afghanistan",
102
189
  code: "+93",
@@ -2049,7 +2136,7 @@ const g = (_) => _.replace(/[^0-9]/g, ""), Q = (_) => {
2049
2136
  flag: "https://cdn.kcak11.com/CountryFlags/countries/zw.svg",
2050
2137
  mask: "_-______"
2051
2138
  }
2052
- ], C = {
2139
+ ], f = {
2053
2140
  USD: { countryLanguage: "en-US", countryCurrency: "USD" },
2054
2141
  EUR: { countryLanguage: "de-DE", countryCurrency: "EUR" },
2055
2142
  JPY: { countryLanguage: "ja-JP", countryCurrency: "JPY" },
@@ -2072,266 +2159,281 @@ const g = (_) => _.replace(/[^0-9]/g, ""), Q = (_) => {
2072
2159
  TRY: { countryLanguage: "tr-TR", countryCurrency: "TRY" },
2073
2160
  IDR: { countryLanguage: "id-ID", countryCurrency: "IDR" },
2074
2161
  THB: { countryLanguage: "th-TH", countryCurrency: "THB" }
2075
- }, R = (_) => _.replace(new RegExp("(?:R\\$|\\p{Sc}|[$€¥£])", "gu"), "").trim(), __ = (_, n, e = { showPrefix: !0 }) => {
2076
- if (!C[n])
2162
+ };
2163
+ function L(a) {
2164
+ return a.replace(new RegExp("(?:R\\$|\\p{Sc}|[$€¥£])", "gu"), "").trim();
2165
+ }
2166
+ function _a(a, _, s) {
2167
+ if (!(f != null && f[_]))
2077
2168
  throw new Error("Unsupported currency code");
2078
- const { countryCurrency: s, countryLanguage: a } = C[n], o = new Intl.NumberFormat(a, {
2169
+ const n = (s == null ? void 0 : s.showPrefix) ?? !0, { countryCurrency: e, countryLanguage: t } = f[_], c = new Intl.NumberFormat(t, {
2079
2170
  style: "currency",
2080
- currency: s
2081
- }).format(_);
2082
- return e.showPrefix ? o.replace(/\s/g, " ") : R(o).replace(/\s/g, " ");
2083
- }, n_ = ([_, n = "00:00:00"], e, s = 0) => {
2084
- const a = _.split(/[-/]/).map(Number), o = n.split(".")[0].split(":").map(Number);
2085
- let c, r, t;
2086
- const [i = 0, p = 0, y = 0] = o;
2087
- switch (e) {
2088
- case "brazilianDate":
2089
- [c, r, t] = a;
2090
- break;
2091
- case "isoDate":
2092
- [t, r, c] = a;
2093
- break;
2094
- case "timestamp":
2095
- [t, r, c] = a.map(Number);
2096
- break;
2097
- default:
2098
- throw new Error("Invalid input format");
2099
- }
2100
- const m = new Date(
2101
- Date.UTC(t, r - 1, c, i - s, p, y)
2102
- );
2103
- if (isNaN(m.getTime())) throw new Error("Invalid date");
2104
- return m;
2105
- }, a_ = (_, n) => {
2106
- if (_.length > n) {
2107
- let e = _.substring(0, n).trimEnd();
2108
- return e = e.replace(/[.,!?;:]$/, ""), `${e}...`;
2171
+ currency: e
2172
+ }).format(a);
2173
+ return n ? c.replace(/\s/g, " ") : L(c).replace(/\s/g, " ");
2174
+ }
2175
+ function na(a, _) {
2176
+ if (a.length > _) {
2177
+ let s = a.substring(0, _);
2178
+ const n = s.lastIndexOf(" ");
2179
+ return n > 0 && (s = s.substring(0, n)), s = s.replace(/[\s.,!?;:]+$/, ""), s.trim().length === 0 || /^[.,!?;:\s]+$/.test(s) ? "..." : `${s}...`;
2109
2180
  }
2110
- return _;
2111
- }, G = /^\d$/, P = (_) => {
2112
- let n = 0;
2113
- const e = _.split("").map((s) => G.test(s) ? { character: s, kind: "digit", digit: ++n } : { character: s, kind: "other" });
2114
- return { digits: n, children: e, kind: "root" };
2115
- }, B = (_, n) => Array.isArray(_) ? _ : _ >= 0 ? [0, _] : [n + 1 - Math.abs(_), n], U = (_, n) => n >= _[0] && n <= _[1], s_ = (_, n) => {
2116
- const e = P(_), s = B(n.range ?? 3, e.digits);
2117
- return e.children.map((a) => a.kind === "digit" && U(s, a.digit) ? n.hider ?? "*" : a.character).join("");
2118
- };
2119
- function K(_) {
2120
- return _.length > 10 ? "NINE" : "EIGTH";
2181
+ return a;
2121
2182
  }
2122
- const w = {
2123
- EIGTH: "(99) 9999-9999",
2183
+ const R = /^\d$/, G = (a) => {
2184
+ let _ = 0;
2185
+ const s = a.split("").map((n) => R.test(n) ? { character: n, kind: "digit", digit: ++_ } : { character: n, kind: "other" });
2186
+ return { digits: _, children: s, kind: "root" };
2187
+ }, U = (a, _) => Array.isArray(a) ? a : a >= 0 ? [0, a] : [_ + 1 - Math.abs(a), _], B = (a, _) => _ >= a[0] && _ <= a[1];
2188
+ function sa(a, _) {
2189
+ const s = G(a), n = U((_ == null ? void 0 : _.range) ?? 3, s.digits);
2190
+ return s.children.map((t) => t.kind === "digit" && B(n, t.digit) ? (_ == null ? void 0 : _.hider) ?? "*" : t.character).join("");
2191
+ }
2192
+ function H(a) {
2193
+ return a.length > 10 ? "NINE" : "EIGHT";
2194
+ }
2195
+ const D = {
2196
+ EIGHT: "(99) 9999-9999",
2124
2197
  NINE: "(99) 99999-9999"
2125
- }, H = g(w.NINE).length;
2126
- function O(_, n) {
2127
- let e = "", s = 0;
2128
- for (let a = 0; a < n.length; a++)
2129
- if (n[a] === "9")
2130
- if (s < _.length)
2131
- e += _[s], s++;
2198
+ }, K = k(D.NINE).length;
2199
+ function O(a, _) {
2200
+ let s = "", n = 0;
2201
+ for (let e = 0; e < _.length; e++)
2202
+ if (_[e] === "9")
2203
+ if (n < a.length)
2204
+ s += a[n], n++;
2132
2205
  else
2133
2206
  break;
2134
- else if (s < _.length)
2135
- e += n[a];
2207
+ else if (n < a.length)
2208
+ s += _[e];
2136
2209
  else
2137
2210
  break;
2138
- return e;
2211
+ return s;
2139
2212
  }
2140
- function v(_, n) {
2141
- if (n.code === "+55") {
2142
- let a = g(_);
2143
- const o = K(a);
2144
- return a.length > H || (a = O(a, w[o])), a;
2213
+ function x(a, _) {
2214
+ if (_.code === "+55") {
2215
+ let e = k(a);
2216
+ const t = H(e);
2217
+ return e.length > K || (e = O(e, D[t])), e;
2145
2218
  }
2146
- let s = n.mask;
2147
- if (n.prefix) {
2148
- const a = /\$+/g;
2149
- s = s.replace(a, n.prefix);
2219
+ let n = _.mask;
2220
+ if (_.prefix) {
2221
+ const e = /\$+/g;
2222
+ n = n.replace(e, _.prefix);
2150
2223
  }
2151
- for (let a = 0, o = 0; a < s.length && o < _.length; a++)
2152
- s[a] === "_" && (s = s.substring(0, a) + _[o] + s.substring(a + 1), o++);
2153
- return s;
2224
+ for (let e = 0, t = 0; e < n.length && t < a.length; e++)
2225
+ n[e] === "_" && (n = n.substring(0, e) + a[t] + n.substring(e + 1), t++);
2226
+ return n;
2154
2227
  }
2155
- function z(_, n) {
2156
- const e = N.find(
2157
- (s) => s.code === _ && s.prefix === n
2228
+ function z(a, _) {
2229
+ const s = N.find(
2230
+ (n) => n.code === a && n.prefix === _
2158
2231
  );
2159
- if (!e) throw new Error("Invalid country code or prefix");
2160
- if (e.prefix !== n)
2232
+ if (!s) throw new Error("Invalid country code or prefix");
2233
+ if (s.prefix !== _)
2161
2234
  throw new Error("Invalid country code or prefix");
2162
- if (!e.prefix)
2235
+ if (!s.prefix)
2163
2236
  throw new Error("Invalid country code or prefix");
2164
- return e;
2237
+ return s;
2165
2238
  }
2166
- function J(_) {
2167
- const n = N.find((e) => e.code === _);
2168
- if (!n) throw new Error("Invalid country code");
2169
- if (n.prefix) throw new Error("Invalid country code");
2170
- return n;
2239
+ function Y(a) {
2240
+ const _ = N.find((s) => s.code === a);
2241
+ if (!_) throw new Error("Invalid country code");
2242
+ if (_.prefix) throw new Error("Invalid country code");
2243
+ return _;
2171
2244
  }
2172
- const e_ = (_) => {
2173
- if (!/^\+\d{1,4}(-\d{1,4})? \d+$/.test(_))
2245
+ const ea = (a) => {
2246
+ if (!/^\+\d{1,4}(-\d{1,4})? \d+$/.test(a))
2174
2247
  throw new Error(
2175
2248
  "Invalid phone number format. Expected format: +<countryCode>-<optionalPrefix> <phoneNumber>"
2176
2249
  );
2177
- const e = _.split(" ")[0].split("-")[0], s = _.split(" ")[0].split("-")[1], a = _.split(" ")[1];
2178
- if (!e || !a)
2250
+ const s = a.split(" ")[0].split("-")[0], n = a.split(" ")[0].split("-")[1], e = a.split(" ")[1];
2251
+ if (!s || !e)
2179
2252
  throw new Error("Invalid phone number format");
2180
- if (s) {
2181
- const c = z(e, s);
2182
- return v(a, c);
2253
+ if (n) {
2254
+ const c = z(s, n);
2255
+ return x(e, c);
2183
2256
  }
2184
- const o = J(e);
2185
- return v(a, o);
2186
- }, o_ = (_) => {
2187
- for (var n = 0, e = 0; e < _.length; e++)
2188
- n = _.charCodeAt(e) + ((n << 5) - n);
2189
- var s = (n & 16711680) >> 16, a = (n & 65280) >> 8, o = n & 255, c = s.toString(16).padStart(2, "0"), r = a.toString(16).padStart(2, "0"), t = o.toString(16).padStart(2, "0");
2190
- return "#" + c + r + t;
2257
+ const t = Y(s);
2258
+ return x(e, t);
2191
2259
  };
2260
+ function ta(a) {
2261
+ for (var _ = 0, s = 0; s < a.length; s++)
2262
+ _ = a.charCodeAt(s) + ((_ << 5) - _);
2263
+ var n = (_ & 16711680) >> 16, e = (_ & 65280) >> 8, t = _ & 255, c = n.toString(16).padStart(2, "0"), i = e.toString(16).padStart(2, "0"), o = t.toString(16).padStart(2, "0");
2264
+ return "#" + c + i + o;
2265
+ }
2192
2266
  var l = [];
2193
- for (var h = 0; h < 256; ++h)
2194
- l.push((h + 256).toString(16).slice(1));
2195
- function M(_, n = 0) {
2196
- return (l[_[n + 0]] + l[_[n + 1]] + l[_[n + 2]] + l[_[n + 3]] + "-" + l[_[n + 4]] + l[_[n + 5]] + "-" + l[_[n + 6]] + l[_[n + 7]] + "-" + l[_[n + 8]] + l[_[n + 9]] + "-" + l[_[n + 10]] + l[_[n + 11]] + l[_[n + 12]] + l[_[n + 13]] + l[_[n + 14]] + l[_[n + 15]]).toLowerCase();
2267
+ for (var v = 0; v < 256; ++v)
2268
+ l.push((v + 256).toString(16).slice(1));
2269
+ function T(a, _ = 0) {
2270
+ return (l[a[_ + 0]] + l[a[_ + 1]] + l[a[_ + 2]] + l[a[_ + 3]] + "-" + l[a[_ + 4]] + l[a[_ + 5]] + "-" + l[a[_ + 6]] + l[a[_ + 7]] + "-" + l[a[_ + 8]] + l[a[_ + 9]] + "-" + l[a[_ + 10]] + l[a[_ + 11]] + l[a[_ + 12]] + l[a[_ + 13]] + l[a[_ + 14]] + l[a[_ + 15]]).toLowerCase();
2197
2271
  }
2198
- var d, Y = new Uint8Array(16);
2199
- function T() {
2200
- if (!d && (d = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !d))
2272
+ var p, J = new Uint8Array(16);
2273
+ function A() {
2274
+ if (!p && (p = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !p))
2201
2275
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
2202
- return d(Y);
2276
+ return p(J);
2203
2277
  }
2204
2278
  var $ = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
2205
- const x = {
2279
+ const F = {
2206
2280
  randomUUID: $
2207
2281
  };
2208
- function V(_, n, e) {
2209
- if (x.randomUUID && !_)
2210
- return x.randomUUID();
2211
- _ = _ || {};
2212
- var s = _.random || (_.rng || T)();
2213
- return s[6] = s[6] & 15 | 64, s[8] = s[8] & 63 | 128, M(s);
2282
+ function V(a, _, s) {
2283
+ if (F.randomUUID && !a)
2284
+ return F.randomUUID();
2285
+ a = a || {};
2286
+ var n = a.random || (a.rng || A)();
2287
+ return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, T(n);
2214
2288
  }
2215
- var F = null, S = null, u = 0;
2216
- function W(_, n, e) {
2217
- _ = _ || {};
2218
- var s = 0, a = new Uint8Array(16), o = _.random || (_.rng || T)(), c = _.msecs !== void 0 ? _.msecs : Date.now(), r = _.seq !== void 0 ? _.seq : null, t = S, i = F;
2219
- return c > u && _.msecs === void 0 && (u = c, r !== null && (t = null, i = null)), r !== null && (r > 2147483647 && (r = 2147483647), t = r >>> 19 & 4095, i = r & 524287), (t === null || i === null) && (t = o[6] & 127, t = t << 8 | o[7], i = o[8] & 63, i = i << 8 | o[9], i = i << 5 | o[10] >>> 3), c + 1e4 > u && r === null ? ++i > 524287 && (i = 0, ++t > 4095 && (t = 0, u++)) : u = c, S = t, F = i, a[s++] = u / 1099511627776 & 255, a[s++] = u / 4294967296 & 255, a[s++] = u / 16777216 & 255, a[s++] = u / 65536 & 255, a[s++] = u / 256 & 255, a[s++] = u & 255, a[s++] = t >>> 4 & 15 | 112, a[s++] = t & 255, a[s++] = i >>> 13 & 63 | 128, a[s++] = i >>> 5 & 255, a[s++] = i << 3 & 255 | o[10] & 7, a[s++] = o[11], a[s++] = o[12], a[s++] = o[13], a[s++] = o[14], a[s++] = o[15], n || M(a);
2289
+ var b = null, S = null, u = 0;
2290
+ function W(a, _, s) {
2291
+ a = a || {};
2292
+ var n = 0, e = new Uint8Array(16), t = a.random || (a.rng || A)(), c = a.msecs !== void 0 ? a.msecs : Date.now(), i = a.seq !== void 0 ? a.seq : null, o = S, r = b;
2293
+ return c > u && a.msecs === void 0 && (u = c, i !== null && (o = null, r = null)), i !== null && (i > 2147483647 && (i = 2147483647), o = i >>> 19 & 4095, r = i & 524287), (o === null || r === null) && (o = t[6] & 127, o = o << 8 | t[7], r = t[8] & 63, r = r << 8 | t[9], r = r << 5 | t[10] >>> 3), c + 1e4 > u && i === null ? ++r > 524287 && (r = 0, ++o > 4095 && (o = 0, u++)) : u = c, S = o, b = r, e[n++] = u / 1099511627776 & 255, e[n++] = u / 4294967296 & 255, e[n++] = u / 16777216 & 255, e[n++] = u / 65536 & 255, e[n++] = u / 256 & 255, e[n++] = u & 255, e[n++] = o >>> 4 & 15 | 112, e[n++] = o & 255, e[n++] = r >>> 13 & 63 | 128, e[n++] = r >>> 5 & 255, e[n++] = r << 3 & 255 | t[10] & 7, e[n++] = t[11], e[n++] = t[12], e[n++] = t[13], e[n++] = t[14], e[n++] = t[15], _ || T(e);
2220
2294
  }
2221
- function A(_) {
2222
- _ = _.replace(/-/g, "");
2223
- const n = new Uint8Array(_.length / 2);
2224
- for (let e = 0; e < _.length; e += 2)
2225
- n[e / 2] = parseInt(_.substring(e, e + 2), 16);
2226
- return n;
2295
+ function E(a) {
2296
+ a = a.replace(/-/g, "");
2297
+ const _ = new Uint8Array(a.length / 2);
2298
+ for (let s = 0; s < a.length; s += 2)
2299
+ _[s / 2] = parseInt(a.substring(s, s + 2), 16);
2300
+ return _;
2227
2301
  }
2228
- function b() {
2229
- const _ = V();
2230
- return { text: _, binary: A(_) };
2302
+ function M() {
2303
+ const a = V();
2304
+ return { text: a, binary: E(a) };
2231
2305
  }
2232
- function I() {
2233
- const _ = W();
2234
- return { text: _, binary: A(_) };
2306
+ function w() {
2307
+ const a = W();
2308
+ return { text: a, binary: E(a) };
2235
2309
  }
2236
- function t_(_, n) {
2237
- if (_ === "text" && n === "v4") return b().text;
2238
- if (_ === "binary" && n === "v4") return b().binary;
2239
- if (_ === "text" && n === "v7") return I().text;
2240
- if (_ === "binary" && n === "v7") return I().binary;
2310
+ function oa(a, _) {
2311
+ if (a === "text" && _ === "v4") return M().text;
2312
+ if (a === "binary" && _ === "v4") return M().binary;
2313
+ if (a === "text" && _ === "v7") return w().text;
2314
+ if (a === "binary" && _ === "v7") return w().binary;
2241
2315
  throw new Error("Invalid type or format");
2242
2316
  }
2243
- function c_(_) {
2244
- let n = _.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
2245
- return n = n.replace(/[^\w\s-]/g, "").replace(/\s+/g, "-").toLowerCase(), n = n.replace(/-{2,}/g, "-"), n = n.replace(/^-+|-+$/g, ""), n;
2317
+ function ca(a) {
2318
+ let _ = a.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
2319
+ return _ = _.replace(/[^\w\s-]/g, "").replace(/\s+/g, "-").toLowerCase(), _ = _.replace(/-{2,}/g, "-"), _ = _.replace(/^-+|-+$/g, ""), _;
2246
2320
  }
2247
- const r_ = (_) => {
2248
- const { cashPrice: n, numberInstallments: e, fees: s = 0.0349 } = _;
2249
- if (s === 0 || e === 1)
2250
- return {
2251
- totalPrice: n,
2252
- installmentPrice: n / e
2253
- };
2254
- if (e <= 0)
2255
- throw new Error("Number of installments must be greater than 0");
2256
- if (s < 0)
2257
- throw new Error("Fees must be greater than or equal to 0");
2258
- let a = 0, o = 0, c = Math.pow(1 + s, e) * s, r = Math.pow(1 + s, e) - 1;
2259
- return a = n * (c / r), o = e * a, {
2260
- totalPrice: +o.toFixed(2),
2261
- installmentPrice: +a.toFixed(2)
2262
- };
2263
- }, i_ = (_) => {
2264
- const n = _.startsWith("'") && _.endsWith("'"), e = _.startsWith('"') && _.endsWith('"');
2265
- return n || e ? _ : `"${_}"`;
2266
- };
2267
- function l_(_) {
2268
- return /<\/?[a-z][\s\S]*>/i.test(_);
2269
- }
2270
- const u_ = (_, n = ["password", "confirmPassword", "creditCard"]) => {
2271
- function e(a, o) {
2272
- return n.includes(a) ? "****" : o;
2321
+ function ra(a, _ = 1e3) {
2322
+ function s(e) {
2323
+ return typeof e == "string" && e.length > _ ? `To large information: field as ${e.length} characters` : e;
2273
2324
  }
2274
- function s(a) {
2275
- return Array.isArray(a) ? a.map((o) => s(o)) : a !== null && typeof a == "object" ? Object.keys(a).reduce((o, c) => {
2276
- let r = a[c];
2277
- if (typeof r == "string")
2278
- try {
2279
- const t = JSON.parse(r);
2280
- typeof t == "object" && (r = JSON.stringify(s(t)));
2281
- } catch {
2282
- }
2283
- return o[c] = s(e(c, r)), o;
2284
- }, {}) : a;
2325
+ function n(e) {
2326
+ return Array.isArray(e) ? e.map((t) => n(t)) : e !== null && typeof e == "object" ? Object.fromEntries(
2327
+ Object.entries(e).map(([t, c]) => [
2328
+ t,
2329
+ n(c)
2330
+ ])
2331
+ ) : s(e);
2285
2332
  }
2286
2333
  try {
2287
- const a = JSON.parse(_), o = s(a);
2288
- return JSON.stringify(o);
2334
+ const e = JSON.parse(a), t = n(e);
2335
+ return JSON.stringify(t);
2289
2336
  } catch {
2290
- return _;
2337
+ throw new Error("Invalid JSON string");
2291
2338
  }
2292
- }, g_ = (_) => _.replace(/<\/?[^>]+(>|$)/g, ""), m_ = (_, n = 1e3) => {
2293
- function e(a) {
2294
- return typeof a == "string" && a.length > n ? `To large information: field as ${a.length} characters` : a;
2339
+ }
2340
+ function ia(a, _ = ["password", "confirmPassword", "creditCard"]) {
2341
+ function s(e, t) {
2342
+ return _.includes(e) ? "****" : t;
2295
2343
  }
2296
- function s(a) {
2297
- return Array.isArray(a) ? a.map((o) => s(o)) : a !== null && typeof a == "object" ? Object.fromEntries(
2298
- Object.entries(a).map(([o, c]) => [
2299
- o,
2300
- s(c)
2301
- // Corrigido para aplicar recursão corretamente
2302
- ])
2303
- ) : e(a);
2344
+ function n(e) {
2345
+ return Array.isArray(e) ? e.map((t) => n(t)) : e !== null && typeof e == "object" ? Object.keys(e).reduce((t, c) => {
2346
+ let i = e[c];
2347
+ if (typeof i == "string")
2348
+ try {
2349
+ const o = JSON.parse(i);
2350
+ typeof o == "object" && (i = JSON.stringify(n(o)));
2351
+ } catch {
2352
+ }
2353
+ return t[c] = n(s(c, i)), t;
2354
+ }, {}) : e;
2304
2355
  }
2305
2356
  try {
2306
- const a = JSON.parse(_), o = s(a);
2307
- return JSON.stringify(o);
2357
+ const e = JSON.parse(a), t = n(e);
2358
+ return JSON.stringify(t);
2308
2359
  } catch {
2309
- throw new Error("Invalid JSON string");
2360
+ return a;
2310
2361
  }
2311
- };
2362
+ }
2363
+ function la([a, _ = "00:00:00"], s, n = 0) {
2364
+ const e = new I();
2365
+ e.validateInputFormat(s);
2366
+ const t = a.split(/[-/]/).map(Number), c = _.split(".")[0].split(":").map(Number);
2367
+ let i, o, r;
2368
+ const [g = 0, h = 0, C = 0] = c;
2369
+ switch (s) {
2370
+ case "brazilianDate":
2371
+ [i, o, r] = t, e.validateDateParts(r, o, i);
2372
+ break;
2373
+ case "isoDate":
2374
+ [o, i, r] = t, e.validateDateParts(r, o, i);
2375
+ break;
2376
+ case "timestamp":
2377
+ [r, o, i] = t, e.validateDateParts(r, o, i);
2378
+ break;
2379
+ }
2380
+ const m = new Date(
2381
+ Date.UTC(r, o - 1, i, g, h, C)
2382
+ );
2383
+ if (isNaN(m.getTime())) throw new Error("Invalid date");
2384
+ return m.setUTCHours(m.getUTCHours() + n), m;
2385
+ }
2386
+ function ua(a) {
2387
+ const { cashPrice: _, numberInstallments: s, fees: n = 0.0349 } = a;
2388
+ if (n === 0 || s === 1)
2389
+ return {
2390
+ totalPrice: _,
2391
+ installmentPrice: _ / s
2392
+ };
2393
+ if (s <= 0)
2394
+ throw new Error("Number of installments must be greater than 0");
2395
+ if (n < 0)
2396
+ throw new Error("Fees must be greater than or equal to 0");
2397
+ let e = Math.pow(1 + n, s) * n, t = Math.pow(1 + n, s) - 1;
2398
+ const c = +(_ * (e / t)).toFixed(2);
2399
+ return {
2400
+ totalPrice: +(+(c * s).toFixed(2)).toFixed(2),
2401
+ installmentPrice: +c.toFixed(2)
2402
+ };
2403
+ }
2404
+ function ga(a) {
2405
+ const _ = a.startsWith("'") && a.endsWith("'"), s = a.startsWith('"') && a.endsWith('"');
2406
+ return _ || s ? a : `"${a}"`;
2407
+ }
2408
+ function ma(a) {
2409
+ return /<\/?[a-z][\s\S]*>/i.test(a);
2410
+ }
2411
+ function ka(a) {
2412
+ return a.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").replace(/<style\b[^<]*(?:(?!<\/style>)<[^<]*)*<\/style>/gi, "").replace(/<!--[\s\S]*?-->/g, "").replace(/<\/?[a-z][a-z0-9]*[^>]*>/gi, "");
2413
+ }
2312
2414
  export {
2313
- r_ as calculateCardInstallment,
2314
- i_ as ensureQuotes,
2415
+ I as ValidateDateService,
2416
+ ua as calculateCardInstallment,
2417
+ ga as ensureQuotes,
2315
2418
  Z as formatDate,
2316
- f as formatJsonObject,
2419
+ y as formatJsonObject,
2317
2420
  q as formatJsonString,
2318
2421
  j as formatToCapitalizeFirstWordLetter,
2319
2422
  Q as formatToCep,
2320
- D as formatToCnpj,
2321
- L as formatToCpf,
2322
- X as formatToCpfCnpj,
2323
- __ as formatToCurrency,
2324
- n_ as formatToDate,
2325
- a_ as formatToEllipsis,
2326
- s_ as formatToHiddenDigits,
2327
- e_ as formatToPhone,
2328
- o_ as generateColorByString,
2329
- t_ as generateId,
2330
- c_ as generateSlug,
2331
- l_ as isHtml,
2332
- u_ as maskSensitiveData,
2333
- R as removeCurrencySymbols,
2334
- g as removeNonNumeric,
2335
- g_ as stripHtmlTags,
2336
- m_ as truncateLargeFields
2423
+ X as formatToCnpj,
2424
+ aa as formatToCpf,
2425
+ _a as formatToCurrency,
2426
+ na as formatToEllipsis,
2427
+ sa as formatToHiddenDigits,
2428
+ ea as formatToPhone,
2429
+ ta as generateColorByString,
2430
+ oa as generateId,
2431
+ ca as generateSlug,
2432
+ ma as isHtml,
2433
+ ra as parseLargeFields,
2434
+ ia as parseSensitiveData,
2435
+ la as parseToDate,
2436
+ L as removeCurrencySymbols,
2437
+ k as removeNonNumeric,
2438
+ ka as stripHtmlTags
2337
2439
  };