toolbox-x 1.0.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 (190) hide show
  1. package/LICENSE +201 -0
  2. package/dist/Color-B3mgF9Dh.d.cts +486 -0
  3. package/dist/Color-D38Xrw65.d.mts +486 -0
  4. package/dist/Stylog-Df7eq3-j.d.cts +519 -0
  5. package/dist/Stylog-jvlLcMQq.d.mts +519 -0
  6. package/dist/array-DvW0zIu6.d.mts +130 -0
  7. package/dist/array-rUnEVisO.d.cts +130 -0
  8. package/dist/basics-D_eSv0cu.cjs +132 -0
  9. package/dist/basics-Dp_aEK81.mjs +115 -0
  10. package/dist/basics-WEYWlnRO.d.cts +95 -0
  11. package/dist/basics-uBSfkBEI.d.mts +95 -0
  12. package/dist/case-BWIt8Ash.mjs +449 -0
  13. package/dist/case-C-S-b5YP.d.cts +327 -0
  14. package/dist/case-CS8Ii3A7.cjs +526 -0
  15. package/dist/case-CybASFPD.d.mts +327 -0
  16. package/dist/change-case.cjs +32 -0
  17. package/dist/change-case.d.cts +18 -0
  18. package/dist/change-case.d.mts +18 -0
  19. package/dist/change-case.mjs +19 -0
  20. package/dist/colors.cjs +574 -0
  21. package/dist/colors.d.cts +355 -0
  22. package/dist/colors.d.mts +355 -0
  23. package/dist/colors.mjs +547 -0
  24. package/dist/constants-2gAw23_7.mjs +144 -0
  25. package/dist/constants-B34K0QPi.d.cts +21 -0
  26. package/dist/constants-BIBDKY1u.cjs +924 -0
  27. package/dist/constants-BWT-810U.cjs +158 -0
  28. package/dist/constants-BwbHnXlM.mjs +662 -0
  29. package/dist/constants-BxN9l5el.cjs +74 -0
  30. package/dist/constants-CLS_bgKD.d.mts +847 -0
  31. package/dist/constants-D73iFu8g.mjs +171 -0
  32. package/dist/constants-DAfRxaa8.mjs +62 -0
  33. package/dist/constants-DQYeCjlx.cjs +207 -0
  34. package/dist/constants-Deeie-iH.d.mts +21 -0
  35. package/dist/constants-DpTG9RP6.d.mts +29 -0
  36. package/dist/constants-DqwnkJ_d.cjs +740 -0
  37. package/dist/constants-DvRUY_FY.cjs +150 -0
  38. package/dist/constants-VcRtQu0K.d.cts +29 -0
  39. package/dist/constants-X5hm1UtB.mjs +912 -0
  40. package/dist/constants-eNd-iYsV.mjs +134 -0
  41. package/dist/constants-qm8FafmD.d.cts +847 -0
  42. package/dist/constants.cjs +415 -0
  43. package/dist/constants.d.cts +184 -0
  44. package/dist/constants.d.mts +184 -0
  45. package/dist/constants.mjs +378 -0
  46. package/dist/convert-BOCgUv2D.cjs +252 -0
  47. package/dist/convert-Bn4jFomQ.mjs +169 -0
  48. package/dist/convert-BrzlG-m_.cjs +475 -0
  49. package/dist/convert-DhaUoPVU.mjs +368 -0
  50. package/dist/converter-1P90_RcP.d.mts +402 -0
  51. package/dist/converter-CmkcAppi.d.cts +402 -0
  52. package/dist/converter.cjs +780 -0
  53. package/dist/converter.d.cts +29 -0
  54. package/dist/converter.d.mts +29 -0
  55. package/dist/converter.mjs +771 -0
  56. package/dist/countries-CIpmtEzV.cjs +1469 -0
  57. package/dist/countries-Cy0xiqS3.mjs +1463 -0
  58. package/dist/css-colors-Bx947Ng3.d.cts +179 -0
  59. package/dist/css-colors-CXCDqQbG.cjs +186 -0
  60. package/dist/css-colors-CXTp1vvy.d.mts +179 -0
  61. package/dist/css-colors-DfUW3nTR.mjs +180 -0
  62. package/dist/date.cjs +332 -0
  63. package/dist/date.d.cts +213 -0
  64. package/dist/date.d.mts +213 -0
  65. package/dist/date.mjs +298 -0
  66. package/dist/dom.cjs +461 -0
  67. package/dist/dom.d.cts +228 -0
  68. package/dist/dom.d.mts +228 -0
  69. package/dist/dom.mjs +429 -0
  70. package/dist/form-BMFVGUrN.d.mts +118 -0
  71. package/dist/form-DRFbryvK.d.cts +118 -0
  72. package/dist/guards-3kaUX66g.mjs +157 -0
  73. package/dist/guards-C8gkvIHb.cjs +240 -0
  74. package/dist/guards-DdyU4h4o.mjs +110 -0
  75. package/dist/guards-Efhp1mNy.cjs +151 -0
  76. package/dist/guards.cjs +172 -0
  77. package/dist/guards.d.cts +399 -0
  78. package/dist/guards.d.mts +399 -0
  79. package/dist/guards.mjs +75 -0
  80. package/dist/hash-B6JPEyAz.d.mts +131 -0
  81. package/dist/hash-NTpeKYB_.d.cts +131 -0
  82. package/dist/hash.cjs +2126 -0
  83. package/dist/hash.d.cts +1239 -0
  84. package/dist/hash.d.mts +1239 -0
  85. package/dist/hash.mjs +2095 -0
  86. package/dist/http-status-BAZdtr7-.d.mts +65 -0
  87. package/dist/http-status-U_3MtoGb.d.cts +65 -0
  88. package/dist/http-status.cjs +173 -0
  89. package/dist/http-status.d.cts +142 -0
  90. package/dist/http-status.d.mts +142 -0
  91. package/dist/http-status.mjs +171 -0
  92. package/dist/index.cjs +2551 -0
  93. package/dist/index.d.cts +1493 -0
  94. package/dist/index.d.mts +1493 -0
  95. package/dist/index.mjs +2357 -0
  96. package/dist/object-B0TV3eHx.d.mts +8052 -0
  97. package/dist/object-Blq0Amdv.d.cts +8052 -0
  98. package/dist/objectify-CDs0Fbr1.mjs +417 -0
  99. package/dist/objectify-DIJ-OBmo.cjs +524 -0
  100. package/dist/paginator.cjs +245 -0
  101. package/dist/paginator.d.cts +144 -0
  102. package/dist/paginator.d.mts +144 -0
  103. package/dist/paginator.mjs +243 -0
  104. package/dist/parse-2ubxXZRp.cjs +211 -0
  105. package/dist/parse-N7g942uy.mjs +164 -0
  106. package/dist/pluralizer-BjMIc6uT.d.mts +42 -0
  107. package/dist/pluralizer-Cb6ZmrDl.d.cts +42 -0
  108. package/dist/pluralizer.cjs +678 -0
  109. package/dist/pluralizer.d.cts +152 -0
  110. package/dist/pluralizer.d.mts +152 -0
  111. package/dist/pluralizer.mjs +676 -0
  112. package/dist/primitives-B26uZolQ.cjs +228 -0
  113. package/dist/primitives-KsFUp3kQ.mjs +144 -0
  114. package/dist/specials-D48_IZbd.d.mts +108 -0
  115. package/dist/specials-DzLr1ZgU.cjs +477 -0
  116. package/dist/specials-LVONlKbQ.d.cts +108 -0
  117. package/dist/specials-uhDuRg8H.mjs +292 -0
  118. package/dist/string-CBAbxaG1.d.mts +258 -0
  119. package/dist/string-CsNsm_65.d.cts +258 -0
  120. package/dist/stylog.cjs +621 -0
  121. package/dist/stylog.d.cts +49 -0
  122. package/dist/stylog.d.mts +49 -0
  123. package/dist/stylog.mjs +614 -0
  124. package/dist/timezone-B2OYK6Fh.mjs +5589 -0
  125. package/dist/timezone-Beh9IGpw.cjs +5625 -0
  126. package/dist/types/array.cjs +16 -0
  127. package/dist/types/array.d.cts +18 -0
  128. package/dist/types/array.d.mts +18 -0
  129. package/dist/types/array.mjs +17 -0
  130. package/dist/types/colors.cjs +16 -0
  131. package/dist/types/colors.d.cts +18 -0
  132. package/dist/types/colors.d.mts +18 -0
  133. package/dist/types/colors.mjs +17 -0
  134. package/dist/types/converter.cjs +16 -0
  135. package/dist/types/converter.d.cts +18 -0
  136. package/dist/types/converter.d.mts +18 -0
  137. package/dist/types/converter.mjs +17 -0
  138. package/dist/types/form.cjs +16 -0
  139. package/dist/types/form.d.cts +18 -0
  140. package/dist/types/form.d.mts +18 -0
  141. package/dist/types/form.mjs +17 -0
  142. package/dist/types/hash.cjs +16 -0
  143. package/dist/types/hash.d.cts +18 -0
  144. package/dist/types/hash.d.mts +18 -0
  145. package/dist/types/hash.mjs +17 -0
  146. package/dist/types/http-status.cjs +16 -0
  147. package/dist/types/http-status.d.cts +18 -0
  148. package/dist/types/http-status.d.mts +18 -0
  149. package/dist/types/http-status.mjs +17 -0
  150. package/dist/types/index.cjs +16 -0
  151. package/dist/types/index.d.cts +18 -0
  152. package/dist/types/index.d.mts +18 -0
  153. package/dist/types/index.mjs +17 -0
  154. package/dist/types/number.cjs +16 -0
  155. package/dist/types/number.d.cts +18 -0
  156. package/dist/types/number.d.mts +18 -0
  157. package/dist/types/number.mjs +17 -0
  158. package/dist/types/object.cjs +16 -0
  159. package/dist/types/object.d.cts +18 -0
  160. package/dist/types/object.d.mts +18 -0
  161. package/dist/types/object.mjs +17 -0
  162. package/dist/types/pluralizer.cjs +16 -0
  163. package/dist/types/pluralizer.d.cts +18 -0
  164. package/dist/types/pluralizer.d.mts +18 -0
  165. package/dist/types/pluralizer.mjs +17 -0
  166. package/dist/types/string.cjs +16 -0
  167. package/dist/types/string.d.cts +18 -0
  168. package/dist/types/string.d.mts +18 -0
  169. package/dist/types/string.mjs +17 -0
  170. package/dist/types/stylog.cjs +16 -0
  171. package/dist/types/stylog.d.cts +18 -0
  172. package/dist/types/stylog.d.mts +18 -0
  173. package/dist/types/stylog.mjs +17 -0
  174. package/dist/types/utils.cjs +16 -0
  175. package/dist/types/utils.d.cts +18 -0
  176. package/dist/types/utils.d.mts +18 -0
  177. package/dist/types/utils.mjs +17 -0
  178. package/dist/types/verbalizer.cjs +16 -0
  179. package/dist/types/verbalizer.d.cts +30 -0
  180. package/dist/types/verbalizer.d.mts +30 -0
  181. package/dist/types/verbalizer.mjs +17 -0
  182. package/dist/utilities-CLUmdQeV.cjs +140 -0
  183. package/dist/utilities-m5yFKqLd.mjs +105 -0
  184. package/dist/utils-ClW9LA6f.mjs +449 -0
  185. package/dist/utils-DLFRgXUC.cjs +568 -0
  186. package/dist/verbalizer.cjs +998 -0
  187. package/dist/verbalizer.d.cts +148 -0
  188. package/dist/verbalizer.d.mts +148 -0
  189. package/dist/verbalizer.mjs +996 -0
  190. package/package.json +249 -0
@@ -0,0 +1,157 @@
1
+ /**
2
+ * Copyright 2026 - present Nazmul Hassan
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { t as CSS_COLORS } from "./css-colors-DfUW3nTR.mjs";
18
+
19
+ //#region src/colors/helpers.ts
20
+ /**
21
+ * * Applies an opacity value to a color string.
22
+ * @param color The color string in hex to apply opacity to.
23
+ * @param opacity The opacity value as a percentage (0-100).
24
+ * @returns The color string with the opacity value applied.
25
+ */
26
+ const _applyOpacity = (color, opacity) => {
27
+ return color?.slice(0, 7).concat(opacity);
28
+ };
29
+ /**
30
+ * * Helper function to generate a random HSL color.
31
+ *
32
+ * @returns A random HSL color string.
33
+ */
34
+ const _generateRandomHSL = () => {
35
+ return `hsl(${Math.floor(Math.random() * 360)}, ${75 + Math.floor(Math.random() * 25)}%, ${50 + Math.floor(Math.random() * 15)}%)`;
36
+ };
37
+ /**
38
+ * * Helper function to check if the new color is visually too similar to the previous one.
39
+ * * It compares the hue, saturation, and lightness difference between the new color and the last one generated.
40
+ *
41
+ * @param recentColors - Array of recently generated colors.
42
+ * @param newColor - The new color to compare.
43
+ * @returns `Boolean` : `true` if the new color is similar to the previous one.
44
+ */
45
+ const _isSimilarToLast = (recentColors, newColor) => {
46
+ if (recentColors?.length === 0) return false;
47
+ const newHSL = newColor.match(/hsl\((\d+), (\d+)%, (\d+)%\)/);
48
+ const lastHSL = recentColors[recentColors?.length - 1].match(/hsl\((\d+), (\d+)%, (\d+)%\)/);
49
+ if (!newHSL || !lastHSL) return false;
50
+ const newHue = parseInt(newHSL[1], 10);
51
+ const newSaturation = parseInt(newHSL[2], 10);
52
+ const newLightness = parseInt(newHSL[3], 10);
53
+ const lastHue = parseInt(lastHSL[1], 10);
54
+ const lastSaturation = parseInt(lastHSL[2], 10);
55
+ const lastLightness = parseInt(lastHSL[3], 10);
56
+ const hueDifference = Math.abs(newHue - lastHue);
57
+ const saturationDifference = Math.abs(newSaturation - lastSaturation);
58
+ const lightnessDifference = Math.abs(newLightness - lastLightness);
59
+ return hueDifference < 48 && saturationDifference < 24 && lightnessDifference < 16;
60
+ };
61
+ /**
62
+ * @private Checks if a number is valid alpha value.
63
+ *
64
+ * @param value Alpha value to check.
65
+ * @returns `true` if it's a valid alpha value, `false` if not.
66
+ */
67
+ function _isValidAlpha(value) {
68
+ return value >= 0 && value <= 1 && !isNaN(value);
69
+ }
70
+ /** @private Validates RGB component (0–255). */
71
+ function _isValidRGBComponent(value) {
72
+ return value >= 0 && value <= 255;
73
+ }
74
+ /** @private Validates HSL hue (0–360). */
75
+ function _isValidHue(value) {
76
+ return value >= 0 && value <= 360;
77
+ }
78
+ /** @private Validates HSL percentage components (0–100). */
79
+ function _isValidPercentage(value) {
80
+ return value >= 0 && value <= 100;
81
+ }
82
+
83
+ //#endregion
84
+ //#region src/colors/guards.ts
85
+ /**
86
+ * Checks if a color is in `Hex` format.
87
+ *
88
+ * @param color Color to check.
89
+ * @returns Boolean: `true` if it's a `Hex` color, `false` if not.
90
+ */
91
+ function isHex6(color) {
92
+ return /^#[0-9A-Fa-f]{6}$/.test(color?.trim());
93
+ }
94
+ /**
95
+ * Checks if a color is in `Hex8` format.
96
+ *
97
+ * @param color Color to check.
98
+ * @returns Boolean: `true` if it's a `Hex8` color, `false` if not.
99
+ */
100
+ function isHex8(color) {
101
+ return /^#[0-9A-Fa-f]{8}$/.test(color?.trim());
102
+ }
103
+ /**
104
+ * Checks if a color is in `RGB` format and within valid ranges.
105
+ *
106
+ * @param color Color to check.
107
+ * @returns `true` if it's a `RGB` color, `false` if not.
108
+ */
109
+ function isRGB(color) {
110
+ const match = color?.trim()?.match(/^rgb\(\s*(\d{1,3}(?:\.\d+)?),\s*(\d{1,3}(?:\.\d+)?),\s*(\d{1,3}(?:\.\d+)?)\s*\)$/);
111
+ if (!match) return false;
112
+ const [r, g, b] = match.slice(1).map(Number);
113
+ return _isValidRGBComponent(r) && _isValidRGBComponent(g) && _isValidRGBComponent(b);
114
+ }
115
+ /**
116
+ * Checks if a color is in `RGBA` format and within valid ranges.
117
+ *
118
+ * @param color Color to check.
119
+ * @returns `true` if it's a `RGBA` color, `false` if not.
120
+ */
121
+ function isRGBA(color) {
122
+ const match = color?.trim()?.match(/^rgba\(\s*(\d{1,3}(?:\.\d+)?),\s*(\d{1,3}(?:\.\d+)?),\s*(\d{1,3}(?:\.\d+)?),\s*(0|1|0?\.\d+)\s*\)$/);
123
+ if (!match) return false;
124
+ const [r, g, b, a] = match.slice(1).map(Number);
125
+ return _isValidRGBComponent(r) && _isValidRGBComponent(g) && _isValidRGBComponent(b) && _isValidAlpha(a);
126
+ }
127
+ /**
128
+ * Checks if a color is in `HSL` format and within valid ranges.
129
+ *
130
+ * @param color Color to check.
131
+ * @returns `true` if it's a `HSL` color, `false` if not.
132
+ */
133
+ function isHSL(color) {
134
+ const match = color?.trim()?.match(/^hsl\(\s*(\d{1,3}(?:\.\d+)?),\s*(\d{1,3}(?:\.\d+)?)%,\s*(\d{1,3}(?:\.\d+)?)%\s*\)$/);
135
+ if (!match) return false;
136
+ const [h, s, l] = match.slice(1).map(Number);
137
+ return _isValidHue(h) && _isValidPercentage(s) && _isValidPercentage(l);
138
+ }
139
+ /**
140
+ * Checks if a color is in `HSLA` format and within valid ranges.
141
+ *
142
+ * @param color Color to check.
143
+ * @returns `true` if it's a `HSLA` color, `false` if not.
144
+ */
145
+ function isHSLA(color) {
146
+ const match = color?.trim().match(/^hsla\(\s*(\d{1,3}(?:\.\d+)?),\s*(\d{1,3}(?:\.\d+)?)%,\s*(\d{1,3}(?:\.\d+)?)%,\s*(0|1|0?\.\d+)\s*\)$/);
147
+ if (!match) return false;
148
+ const [h, s, l, a] = match.slice(1).map(Number);
149
+ return _isValidHue(h) && _isValidPercentage(s) && _isValidPercentage(l) && _isValidAlpha(a);
150
+ }
151
+ /** * Check if a string represents a valid `CSSColor`. */
152
+ function isCSSColor(value) {
153
+ return value in CSS_COLORS;
154
+ }
155
+
156
+ //#endregion
157
+ export { isHex8 as a, _applyOpacity as c, _isValidAlpha as d, _isValidHue as f, isHex6 as i, _generateRandomHSL as l, _isValidRGBComponent as m, isHSL as n, isRGB as o, _isValidPercentage as p, isHSLA as r, isRGBA as s, isCSSColor as t, _isSimilarToLast as u };
@@ -0,0 +1,240 @@
1
+ /**
2
+ * Copyright 2026 - present Nazmul Hassan
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ const require_css_colors = require('./css-colors-CXCDqQbG.cjs');
18
+
19
+ //#region src/colors/helpers.ts
20
+ /**
21
+ * * Applies an opacity value to a color string.
22
+ * @param color The color string in hex to apply opacity to.
23
+ * @param opacity The opacity value as a percentage (0-100).
24
+ * @returns The color string with the opacity value applied.
25
+ */
26
+ const _applyOpacity = (color, opacity) => {
27
+ return color?.slice(0, 7).concat(opacity);
28
+ };
29
+ /**
30
+ * * Helper function to generate a random HSL color.
31
+ *
32
+ * @returns A random HSL color string.
33
+ */
34
+ const _generateRandomHSL = () => {
35
+ return `hsl(${Math.floor(Math.random() * 360)}, ${75 + Math.floor(Math.random() * 25)}%, ${50 + Math.floor(Math.random() * 15)}%)`;
36
+ };
37
+ /**
38
+ * * Helper function to check if the new color is visually too similar to the previous one.
39
+ * * It compares the hue, saturation, and lightness difference between the new color and the last one generated.
40
+ *
41
+ * @param recentColors - Array of recently generated colors.
42
+ * @param newColor - The new color to compare.
43
+ * @returns `Boolean` : `true` if the new color is similar to the previous one.
44
+ */
45
+ const _isSimilarToLast = (recentColors, newColor) => {
46
+ if (recentColors?.length === 0) return false;
47
+ const newHSL = newColor.match(/hsl\((\d+), (\d+)%, (\d+)%\)/);
48
+ const lastHSL = recentColors[recentColors?.length - 1].match(/hsl\((\d+), (\d+)%, (\d+)%\)/);
49
+ if (!newHSL || !lastHSL) return false;
50
+ const newHue = parseInt(newHSL[1], 10);
51
+ const newSaturation = parseInt(newHSL[2], 10);
52
+ const newLightness = parseInt(newHSL[3], 10);
53
+ const lastHue = parseInt(lastHSL[1], 10);
54
+ const lastSaturation = parseInt(lastHSL[2], 10);
55
+ const lastLightness = parseInt(lastHSL[3], 10);
56
+ const hueDifference = Math.abs(newHue - lastHue);
57
+ const saturationDifference = Math.abs(newSaturation - lastSaturation);
58
+ const lightnessDifference = Math.abs(newLightness - lastLightness);
59
+ return hueDifference < 48 && saturationDifference < 24 && lightnessDifference < 16;
60
+ };
61
+ /**
62
+ * @private Checks if a number is valid alpha value.
63
+ *
64
+ * @param value Alpha value to check.
65
+ * @returns `true` if it's a valid alpha value, `false` if not.
66
+ */
67
+ function _isValidAlpha(value) {
68
+ return value >= 0 && value <= 1 && !isNaN(value);
69
+ }
70
+ /** @private Validates RGB component (0–255). */
71
+ function _isValidRGBComponent(value) {
72
+ return value >= 0 && value <= 255;
73
+ }
74
+ /** @private Validates HSL hue (0–360). */
75
+ function _isValidHue(value) {
76
+ return value >= 0 && value <= 360;
77
+ }
78
+ /** @private Validates HSL percentage components (0–100). */
79
+ function _isValidPercentage(value) {
80
+ return value >= 0 && value <= 100;
81
+ }
82
+
83
+ //#endregion
84
+ //#region src/colors/guards.ts
85
+ /**
86
+ * Checks if a color is in `Hex` format.
87
+ *
88
+ * @param color Color to check.
89
+ * @returns Boolean: `true` if it's a `Hex` color, `false` if not.
90
+ */
91
+ function isHex6(color) {
92
+ return /^#[0-9A-Fa-f]{6}$/.test(color?.trim());
93
+ }
94
+ /**
95
+ * Checks if a color is in `Hex8` format.
96
+ *
97
+ * @param color Color to check.
98
+ * @returns Boolean: `true` if it's a `Hex8` color, `false` if not.
99
+ */
100
+ function isHex8(color) {
101
+ return /^#[0-9A-Fa-f]{8}$/.test(color?.trim());
102
+ }
103
+ /**
104
+ * Checks if a color is in `RGB` format and within valid ranges.
105
+ *
106
+ * @param color Color to check.
107
+ * @returns `true` if it's a `RGB` color, `false` if not.
108
+ */
109
+ function isRGB(color) {
110
+ const match = color?.trim()?.match(/^rgb\(\s*(\d{1,3}(?:\.\d+)?),\s*(\d{1,3}(?:\.\d+)?),\s*(\d{1,3}(?:\.\d+)?)\s*\)$/);
111
+ if (!match) return false;
112
+ const [r, g, b] = match.slice(1).map(Number);
113
+ return _isValidRGBComponent(r) && _isValidRGBComponent(g) && _isValidRGBComponent(b);
114
+ }
115
+ /**
116
+ * Checks if a color is in `RGBA` format and within valid ranges.
117
+ *
118
+ * @param color Color to check.
119
+ * @returns `true` if it's a `RGBA` color, `false` if not.
120
+ */
121
+ function isRGBA(color) {
122
+ const match = color?.trim()?.match(/^rgba\(\s*(\d{1,3}(?:\.\d+)?),\s*(\d{1,3}(?:\.\d+)?),\s*(\d{1,3}(?:\.\d+)?),\s*(0|1|0?\.\d+)\s*\)$/);
123
+ if (!match) return false;
124
+ const [r, g, b, a] = match.slice(1).map(Number);
125
+ return _isValidRGBComponent(r) && _isValidRGBComponent(g) && _isValidRGBComponent(b) && _isValidAlpha(a);
126
+ }
127
+ /**
128
+ * Checks if a color is in `HSL` format and within valid ranges.
129
+ *
130
+ * @param color Color to check.
131
+ * @returns `true` if it's a `HSL` color, `false` if not.
132
+ */
133
+ function isHSL(color) {
134
+ const match = color?.trim()?.match(/^hsl\(\s*(\d{1,3}(?:\.\d+)?),\s*(\d{1,3}(?:\.\d+)?)%,\s*(\d{1,3}(?:\.\d+)?)%\s*\)$/);
135
+ if (!match) return false;
136
+ const [h, s, l] = match.slice(1).map(Number);
137
+ return _isValidHue(h) && _isValidPercentage(s) && _isValidPercentage(l);
138
+ }
139
+ /**
140
+ * Checks if a color is in `HSLA` format and within valid ranges.
141
+ *
142
+ * @param color Color to check.
143
+ * @returns `true` if it's a `HSLA` color, `false` if not.
144
+ */
145
+ function isHSLA(color) {
146
+ const match = color?.trim().match(/^hsla\(\s*(\d{1,3}(?:\.\d+)?),\s*(\d{1,3}(?:\.\d+)?)%,\s*(\d{1,3}(?:\.\d+)?)%,\s*(0|1|0?\.\d+)\s*\)$/);
147
+ if (!match) return false;
148
+ const [h, s, l, a] = match.slice(1).map(Number);
149
+ return _isValidHue(h) && _isValidPercentage(s) && _isValidPercentage(l) && _isValidAlpha(a);
150
+ }
151
+ /** * Check if a string represents a valid `CSSColor`. */
152
+ function isCSSColor(value) {
153
+ return value in require_css_colors.CSS_COLORS;
154
+ }
155
+
156
+ //#endregion
157
+ Object.defineProperty(exports, '_applyOpacity', {
158
+ enumerable: true,
159
+ get: function () {
160
+ return _applyOpacity;
161
+ }
162
+ });
163
+ Object.defineProperty(exports, '_generateRandomHSL', {
164
+ enumerable: true,
165
+ get: function () {
166
+ return _generateRandomHSL;
167
+ }
168
+ });
169
+ Object.defineProperty(exports, '_isSimilarToLast', {
170
+ enumerable: true,
171
+ get: function () {
172
+ return _isSimilarToLast;
173
+ }
174
+ });
175
+ Object.defineProperty(exports, '_isValidAlpha', {
176
+ enumerable: true,
177
+ get: function () {
178
+ return _isValidAlpha;
179
+ }
180
+ });
181
+ Object.defineProperty(exports, '_isValidHue', {
182
+ enumerable: true,
183
+ get: function () {
184
+ return _isValidHue;
185
+ }
186
+ });
187
+ Object.defineProperty(exports, '_isValidPercentage', {
188
+ enumerable: true,
189
+ get: function () {
190
+ return _isValidPercentage;
191
+ }
192
+ });
193
+ Object.defineProperty(exports, '_isValidRGBComponent', {
194
+ enumerable: true,
195
+ get: function () {
196
+ return _isValidRGBComponent;
197
+ }
198
+ });
199
+ Object.defineProperty(exports, 'isCSSColor', {
200
+ enumerable: true,
201
+ get: function () {
202
+ return isCSSColor;
203
+ }
204
+ });
205
+ Object.defineProperty(exports, 'isHSL', {
206
+ enumerable: true,
207
+ get: function () {
208
+ return isHSL;
209
+ }
210
+ });
211
+ Object.defineProperty(exports, 'isHSLA', {
212
+ enumerable: true,
213
+ get: function () {
214
+ return isHSLA;
215
+ }
216
+ });
217
+ Object.defineProperty(exports, 'isHex6', {
218
+ enumerable: true,
219
+ get: function () {
220
+ return isHex6;
221
+ }
222
+ });
223
+ Object.defineProperty(exports, 'isHex8', {
224
+ enumerable: true,
225
+ get: function () {
226
+ return isHex8;
227
+ }
228
+ });
229
+ Object.defineProperty(exports, 'isRGB', {
230
+ enumerable: true,
231
+ get: function () {
232
+ return isRGB;
233
+ }
234
+ });
235
+ Object.defineProperty(exports, 'isRGBA', {
236
+ enumerable: true,
237
+ get: function () {
238
+ return isRGBA;
239
+ }
240
+ });
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Copyright 2026 - present Nazmul Hassan
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { a as isNonEmptyString, d as isString, n as isBoolean } from "./primitives-KsFUp3kQ.mjs";
18
+ import { n as NATIVE_TZ_IDS, t as IANA_TZ_IDS } from "./timezone-B2OYK6Fh.mjs";
19
+ import { T as isObject, b as isFunction, d as isNumericString } from "./specials-uhDuRg8H.mjs";
20
+ import { a as normalizeNumber } from "./utilities-m5yFKqLd.mjs";
21
+
22
+ //#region src/date/guards.ts
23
+ /**
24
+ * * Checks if the provided value is a valid time string in "HH:MM" format.
25
+ *
26
+ * @param value - The value to check.
27
+ * @returns `true` if the value is a valid time string, `false` otherwise.
28
+ */
29
+ function isValidTime(value) {
30
+ if (!isNonEmptyString(value)) return false;
31
+ const [hourStr, minuteStr] = value.split(":");
32
+ if (!isNumericString(hourStr) || !isNumericString(minuteStr)) return false;
33
+ const hour = Number(hourStr);
34
+ const minute = Number(minuteStr);
35
+ return hour >= 0 && hour <= 23 && minute >= 0 && minute <= 59;
36
+ }
37
+ /**
38
+ * * Checks if the provided value is a valid `UTCOffset` (e.g. `UTC-01:30`).
39
+ *
40
+ * @param value - The value to check.
41
+ * @returns `true` if the value is a valid utc offset, `false` otherwise.
42
+ */
43
+ function isValidUTCOffset(value) {
44
+ return isString(value) ? /^UTC[+-]?\d{1,2}:\d{2}$/.test(value) : false;
45
+ }
46
+ /**
47
+ * * Validates whether the provided value is a recognized IANA time zone identifier (excluding `"Factory"`), based on the {@link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones IANA TZ Database}.
48
+ *
49
+ * @remarks
50
+ * - Relies on a large constant map of time zone identifiers, which can increase bundle size in browser environments. Matches against `597` identifiers.
51
+ * - Prefer {@link isNativeTimeZoneId} when you want a lightweight, native-only validation approach. Matches against `418` identifiers.
52
+ *
53
+ * @param value Time zone identifier to validate.
54
+ * @returns `true` if the value is a valid IANA time zone identifier, otherwise `false`.
55
+ */
56
+ function isValidTimeZoneId(value) {
57
+ return isNonEmptyString(value) ? new Set([...IANA_TZ_IDS]).has(value) : false;
58
+ }
59
+ /**
60
+ * * Validates whether the provided value is a supported time zone identifier using the native JavaScript API (`Intl.supportedValuesOf('timeZone')`).
61
+ *
62
+ * @remarks
63
+ * - Uses only native {@link Intl} capabilities—minimal code footprint, highly performant. Matches against `418` identifiers.
64
+ * - Prefer {@link isValidTimeZoneId} when validation must align strictly with the full
65
+ * {@link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones IANA TZ Database}. Matches against `597` identifiers.
66
+ *
67
+ * @param value Time zone identifier to validate.
68
+ * @returns `true` if the value is a valid native JS-supported time zone identifier, otherwise `false`.
69
+ */
70
+ function isNativeTimeZoneId(value) {
71
+ return isNonEmptyString(value) ? new Set(NATIVE_TZ_IDS).has(value) : false;
72
+ }
73
+ /**
74
+ * * Checks if the year is a leap year.
75
+ *
76
+ * - A year is a leap year if it is divisible by 4, but not divisible by 100, unless it is also divisible by 400.
77
+ * - For example, 2000 and 2400 are leap years, but 1900 and 2100 are not.
78
+ * @param year The year to check.
79
+ * @returns `true` if the year is a leap year, `false` otherwise.
80
+ */
81
+ function isLeapYear(year) {
82
+ const $year = normalizeNumber(year);
83
+ return $year ? $year % 4 === 0 && $year % 100 !== 0 || $year % 400 === 0 : false;
84
+ }
85
+ /**
86
+ * * Checks if a value is a date-like object from `Date`, `Chronos`, `Moment.js`, `Day.js`, `Luxon`, `JS-Joda`, or `Temporal`
87
+ * @param value Value to check if it is date-like object.
88
+ * @returns `true` if the value is date-like object, otherwise `false`.
89
+ */
90
+ function isDateLike(value) {
91
+ if (value instanceof Date) return true;
92
+ if (isObject(value)) {
93
+ if (isFunction(value.format) && isFunction(value.toJSON) && isFunction(value.toISOString)) return true;
94
+ if (isFunction(value.toISO) && isFunction(value.toFormat) && isBoolean(value.isValid)) return true;
95
+ if (isFunction(value.plus) && isFunction(value.minus) && isFunction(value.equals) && isFunction(value.getClass)) return true;
96
+ if (isFunction(value.toJSON) && isFunction(value.toString) && [
97
+ "PlainDate",
98
+ "ZonedDateTime",
99
+ "Instant"
100
+ ].includes(value.constructor?.name ?? "")) return true;
101
+ }
102
+ return false;
103
+ }
104
+ /** Checks if a value represents time value (number) with different forms of {@link TimeWithUnit units} */
105
+ function isTimeWithUnit(value) {
106
+ return isNonEmptyString(value) && /^-?\d*\.?\d+ *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|months?|mo|years?|yrs?|y)?$/i.test(value);
107
+ }
108
+
109
+ //#endregion
110
+ export { isValidTime as a, isTimeWithUnit as i, isLeapYear as n, isValidTimeZoneId as o, isNativeTimeZoneId as r, isValidUTCOffset as s, isDateLike as t };
@@ -0,0 +1,151 @@
1
+ /**
2
+ * Copyright 2026 - present Nazmul Hassan
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ const require_primitives = require('./primitives-B26uZolQ.cjs');
18
+ const require_timezone = require('./timezone-Beh9IGpw.cjs');
19
+ const require_specials = require('./specials-DzLr1ZgU.cjs');
20
+ const require_utilities = require('./utilities-CLUmdQeV.cjs');
21
+
22
+ //#region src/date/guards.ts
23
+ /**
24
+ * * Checks if the provided value is a valid time string in "HH:MM" format.
25
+ *
26
+ * @param value - The value to check.
27
+ * @returns `true` if the value is a valid time string, `false` otherwise.
28
+ */
29
+ function isValidTime(value) {
30
+ if (!require_primitives.isNonEmptyString(value)) return false;
31
+ const [hourStr, minuteStr] = value.split(":");
32
+ if (!require_specials.isNumericString(hourStr) || !require_specials.isNumericString(minuteStr)) return false;
33
+ const hour = Number(hourStr);
34
+ const minute = Number(minuteStr);
35
+ return hour >= 0 && hour <= 23 && minute >= 0 && minute <= 59;
36
+ }
37
+ /**
38
+ * * Checks if the provided value is a valid `UTCOffset` (e.g. `UTC-01:30`).
39
+ *
40
+ * @param value - The value to check.
41
+ * @returns `true` if the value is a valid utc offset, `false` otherwise.
42
+ */
43
+ function isValidUTCOffset(value) {
44
+ return require_primitives.isString(value) ? /^UTC[+-]?\d{1,2}:\d{2}$/.test(value) : false;
45
+ }
46
+ /**
47
+ * * Validates whether the provided value is a recognized IANA time zone identifier (excluding `"Factory"`), based on the {@link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones IANA TZ Database}.
48
+ *
49
+ * @remarks
50
+ * - Relies on a large constant map of time zone identifiers, which can increase bundle size in browser environments. Matches against `597` identifiers.
51
+ * - Prefer {@link isNativeTimeZoneId} when you want a lightweight, native-only validation approach. Matches against `418` identifiers.
52
+ *
53
+ * @param value Time zone identifier to validate.
54
+ * @returns `true` if the value is a valid IANA time zone identifier, otherwise `false`.
55
+ */
56
+ function isValidTimeZoneId(value) {
57
+ return require_primitives.isNonEmptyString(value) ? new Set([...require_timezone.IANA_TZ_IDS]).has(value) : false;
58
+ }
59
+ /**
60
+ * * Validates whether the provided value is a supported time zone identifier using the native JavaScript API (`Intl.supportedValuesOf('timeZone')`).
61
+ *
62
+ * @remarks
63
+ * - Uses only native {@link Intl} capabilities—minimal code footprint, highly performant. Matches against `418` identifiers.
64
+ * - Prefer {@link isValidTimeZoneId} when validation must align strictly with the full
65
+ * {@link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones IANA TZ Database}. Matches against `597` identifiers.
66
+ *
67
+ * @param value Time zone identifier to validate.
68
+ * @returns `true` if the value is a valid native JS-supported time zone identifier, otherwise `false`.
69
+ */
70
+ function isNativeTimeZoneId(value) {
71
+ return require_primitives.isNonEmptyString(value) ? new Set(require_timezone.NATIVE_TZ_IDS).has(value) : false;
72
+ }
73
+ /**
74
+ * * Checks if the year is a leap year.
75
+ *
76
+ * - A year is a leap year if it is divisible by 4, but not divisible by 100, unless it is also divisible by 400.
77
+ * - For example, 2000 and 2400 are leap years, but 1900 and 2100 are not.
78
+ * @param year The year to check.
79
+ * @returns `true` if the year is a leap year, `false` otherwise.
80
+ */
81
+ function isLeapYear(year) {
82
+ const $year = require_utilities.normalizeNumber(year);
83
+ return $year ? $year % 4 === 0 && $year % 100 !== 0 || $year % 400 === 0 : false;
84
+ }
85
+ /**
86
+ * * Checks if a value is a date-like object from `Date`, `Chronos`, `Moment.js`, `Day.js`, `Luxon`, `JS-Joda`, or `Temporal`
87
+ * @param value Value to check if it is date-like object.
88
+ * @returns `true` if the value is date-like object, otherwise `false`.
89
+ */
90
+ function isDateLike(value) {
91
+ if (value instanceof Date) return true;
92
+ if (require_specials.isObject(value)) {
93
+ if (require_specials.isFunction(value.format) && require_specials.isFunction(value.toJSON) && require_specials.isFunction(value.toISOString)) return true;
94
+ if (require_specials.isFunction(value.toISO) && require_specials.isFunction(value.toFormat) && require_primitives.isBoolean(value.isValid)) return true;
95
+ if (require_specials.isFunction(value.plus) && require_specials.isFunction(value.minus) && require_specials.isFunction(value.equals) && require_specials.isFunction(value.getClass)) return true;
96
+ if (require_specials.isFunction(value.toJSON) && require_specials.isFunction(value.toString) && [
97
+ "PlainDate",
98
+ "ZonedDateTime",
99
+ "Instant"
100
+ ].includes(value.constructor?.name ?? "")) return true;
101
+ }
102
+ return false;
103
+ }
104
+ /** Checks if a value represents time value (number) with different forms of {@link TimeWithUnit units} */
105
+ function isTimeWithUnit(value) {
106
+ return require_primitives.isNonEmptyString(value) && /^-?\d*\.?\d+ *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|months?|mo|years?|yrs?|y)?$/i.test(value);
107
+ }
108
+
109
+ //#endregion
110
+ Object.defineProperty(exports, 'isDateLike', {
111
+ enumerable: true,
112
+ get: function () {
113
+ return isDateLike;
114
+ }
115
+ });
116
+ Object.defineProperty(exports, 'isLeapYear', {
117
+ enumerable: true,
118
+ get: function () {
119
+ return isLeapYear;
120
+ }
121
+ });
122
+ Object.defineProperty(exports, 'isNativeTimeZoneId', {
123
+ enumerable: true,
124
+ get: function () {
125
+ return isNativeTimeZoneId;
126
+ }
127
+ });
128
+ Object.defineProperty(exports, 'isTimeWithUnit', {
129
+ enumerable: true,
130
+ get: function () {
131
+ return isTimeWithUnit;
132
+ }
133
+ });
134
+ Object.defineProperty(exports, 'isValidTime', {
135
+ enumerable: true,
136
+ get: function () {
137
+ return isValidTime;
138
+ }
139
+ });
140
+ Object.defineProperty(exports, 'isValidTimeZoneId', {
141
+ enumerable: true,
142
+ get: function () {
143
+ return isValidTimeZoneId;
144
+ }
145
+ });
146
+ Object.defineProperty(exports, 'isValidUTCOffset', {
147
+ enumerable: true,
148
+ get: function () {
149
+ return isValidUTCOffset;
150
+ }
151
+ });