@rzl-zone/utils-js 3.12.1-beta.0 → 3.12.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (239) hide show
  1. package/README.md +7 -7
  2. package/dist/.references/index.d.cts +1 -1
  3. package/dist/.references/index.d.ts +1 -1
  4. package/dist/{assertIsArray-BChqwPiP.cjs → assertIsArray-DJXkjHZs.cjs} +3 -3
  5. package/dist/{assertIsArray-BChqwPiP.cjs.map → assertIsArray-DJXkjHZs.cjs.map} +1 -1
  6. package/dist/{assertIsArray-BfAbIUfa.js → assertIsArray-bTA3XLjq.js} +3 -3
  7. package/dist/{assertIsArray-BfAbIUfa.js.map → assertIsArray-bTA3XLjq.js.map} +1 -1
  8. package/dist/{assertIsBoolean-DozdtbNi.cjs → assertIsBoolean-C8WEXVr2.cjs} +8 -8
  9. package/dist/assertIsBoolean-C8WEXVr2.cjs.map +1 -0
  10. package/dist/{assertIsBoolean-BlBct0Fc.js → assertIsBoolean-DR1SaXPD.js} +8 -8
  11. package/dist/assertIsBoolean-DR1SaXPD.js.map +1 -0
  12. package/dist/{assertIsString-Bvk7bUL7.cjs → assertIsString-BiHQSrB2.cjs} +3 -3
  13. package/dist/{assertIsString-Bvk7bUL7.cjs.map → assertIsString-BiHQSrB2.cjs.map} +1 -1
  14. package/dist/{assertIsString-DqV9NwbI.js → assertIsString-CEB07_83.js} +3 -3
  15. package/dist/{assertIsString-DqV9NwbI.js.map → assertIsString-CEB07_83.js.map} +1 -1
  16. package/dist/assertions/index.cjs +5 -5
  17. package/dist/assertions/index.d.cts +2 -2
  18. package/dist/assertions/index.d.ts +2 -2
  19. package/dist/assertions/index.js +5 -5
  20. package/dist/conversions/index.cjs +6 -6
  21. package/dist/conversions/index.d.cts +2 -2
  22. package/dist/conversions/index.d.ts +2 -2
  23. package/dist/conversions/index.js +6 -6
  24. package/dist/{conversions-EMJa3g-D.js → conversions-BNIh_tCH.js} +16 -18
  25. package/dist/conversions-BNIh_tCH.js.map +1 -0
  26. package/dist/{conversions-CBs8-REq.cjs → conversions-D_Kh0a_C.cjs} +16 -18
  27. package/dist/conversions-D_Kh0a_C.cjs.map +1 -0
  28. package/dist/events/index.cjs +4 -4
  29. package/dist/events/index.cjs.map +1 -1
  30. package/dist/events/index.d.cts +153 -151
  31. package/dist/events/index.d.ts +153 -151
  32. package/dist/events/index.js +4 -4
  33. package/dist/events/index.js.map +1 -1
  34. package/dist/{formatEnvPort-hHNvOim-.cjs → formatEnvPort-B3OLxQk9.cjs} +9 -9
  35. package/dist/formatEnvPort-B3OLxQk9.cjs.map +1 -0
  36. package/dist/{formatEnvPort-DpIXzPAZ.js → formatEnvPort-ByFVLjSV.js} +9 -9
  37. package/dist/formatEnvPort-ByFVLjSV.js.map +1 -0
  38. package/dist/formatters/index.cjs +2 -2
  39. package/dist/formatters/index.d.cts +2 -2
  40. package/dist/formatters/index.d.ts +2 -2
  41. package/dist/formatters/index.js +2 -2
  42. package/dist/{formatters-QcZO_Cpx.js → formatters--1m_vpE8.js} +17 -15
  43. package/dist/formatters--1m_vpE8.js.map +1 -0
  44. package/dist/{formatters-lAYgA11L.cjs → formatters-Cbij0XLU.cjs} +17 -15
  45. package/dist/formatters-Cbij0XLU.cjs.map +1 -0
  46. package/dist/generators/index.cjs +12 -8
  47. package/dist/generators/index.cjs.map +1 -1
  48. package/dist/generators/index.d.cts +2 -2
  49. package/dist/generators/index.d.ts +2 -2
  50. package/dist/generators/index.js +12 -8
  51. package/dist/generators/index.js.map +1 -1
  52. package/dist/index-59zbLcPr.d.ts +340 -0
  53. package/dist/index-B6tawc8L.d.cts +1716 -0
  54. package/dist/index-C267akkJ.d.ts +2158 -0
  55. package/dist/index-CeBC2Vvl.d.cts +2361 -0
  56. package/dist/index-CgRDTI6f.d.ts +822 -0
  57. package/dist/index-CoiUBVmr.d.ts +720 -0
  58. package/dist/index-D4fcasfZ.d.cts +720 -0
  59. package/dist/index-DDrSQKIc.d.ts +1716 -0
  60. package/dist/index-DsGxO31H.d.cts +765 -0
  61. package/dist/index-Hg1qJkjl.d.ts +765 -0
  62. package/dist/index-Qm3iFwd0.d.cts +2158 -0
  63. package/dist/index-UPp94Agr.d.ts +2361 -0
  64. package/dist/index-gBA_8SuF.d.cts +340 -0
  65. package/dist/index-jyDqzicx.d.cts +822 -0
  66. package/dist/{isBigInt-B1cijjqm.cjs → isBigInt-C4krUeAw.cjs} +2 -2
  67. package/dist/{isBigInt-B1cijjqm.cjs.map → isBigInt-C4krUeAw.cjs.map} +1 -1
  68. package/dist/{isBigInt-C0bN0Rhu.js → isBigInt-DKe0M6hp.js} +2 -2
  69. package/dist/{isBigInt-C0bN0Rhu.js.map → isBigInt-DKe0M6hp.js.map} +1 -1
  70. package/dist/{isEmptyObject-DeLVIJpl.js → isEmptyObject-DCipFwxJ.js} +3 -3
  71. package/dist/{isEmptyObject-DeLVIJpl.js.map → isEmptyObject-DCipFwxJ.js.map} +1 -1
  72. package/dist/{isEmptyObject-DI42NEo0.cjs → isEmptyObject-ZkSwRC_D.cjs} +3 -3
  73. package/dist/{isEmptyObject-DI42NEo0.cjs.map → isEmptyObject-ZkSwRC_D.cjs.map} +1 -1
  74. package/dist/{isEmptyString-BTUWYTbw.js → isEmptyString-BXzKAC2j.js} +3 -3
  75. package/dist/{isEmptyString-BTUWYTbw.js.map → isEmptyString-BXzKAC2j.js.map} +1 -1
  76. package/dist/{isEmptyString-CCK3bP74.cjs → isEmptyString-UiiUsSQj.cjs} +3 -3
  77. package/dist/{isEmptyString-CCK3bP74.cjs.map → isEmptyString-UiiUsSQj.cjs.map} +1 -1
  78. package/dist/{isEmptyValue-DMSMFTU8.cjs → isEmptyValue-BQzcjVaL.cjs} +5 -5
  79. package/dist/{isEmptyValue-DMSMFTU8.cjs.map → isEmptyValue-BQzcjVaL.cjs.map} +1 -1
  80. package/dist/{isEmptyValue-fjnfQnt5.js → isEmptyValue-jqOr7OHD.js} +5 -5
  81. package/dist/{isEmptyValue-fjnfQnt5.js.map → isEmptyValue-jqOr7OHD.js.map} +1 -1
  82. package/dist/{isEqual-DhyP8fB_.js → isEqual-BX49cF9m.js} +4 -4
  83. package/dist/{isEqual-DhyP8fB_.js.map → isEqual-BX49cF9m.js.map} +1 -1
  84. package/dist/{isEqual-B1fRgEuU.cjs → isEqual-BvumA3RA.cjs} +4 -4
  85. package/dist/{isEqual-B1fRgEuU.cjs.map → isEqual-BvumA3RA.cjs.map} +1 -1
  86. package/dist/{isFinite-BYMOo0os.js → isFinite-BCnaDpod.js} +3 -3
  87. package/dist/{isFinite-BYMOo0os.js.map → isFinite-BCnaDpod.js.map} +1 -1
  88. package/dist/{isFinite-sFkps2TY.cjs → isFinite-D24ZaE6c.cjs} +3 -3
  89. package/dist/{isFinite-sFkps2TY.cjs.map → isFinite-D24ZaE6c.cjs.map} +1 -1
  90. package/dist/{isInteger-FTCthMre.cjs → isInteger-Caeuz0rB.cjs} +2 -2
  91. package/dist/{isInteger-FTCthMre.cjs.map → isInteger-Caeuz0rB.cjs.map} +1 -1
  92. package/dist/{isInteger-DS9V7l_f.js → isInteger-naMbJsxJ.js} +2 -2
  93. package/dist/{isInteger-DS9V7l_f.js.map → isInteger-naMbJsxJ.js.map} +1 -1
  94. package/dist/isPlainObject-BF-2-phb.d.cts +339 -0
  95. package/dist/isPlainObject-DxNDL8XU.d.ts +339 -0
  96. package/dist/{isServer-q-QLFCqE.cjs → isServer-BJHVnixd.cjs} +2 -2
  97. package/dist/{isServer-q-QLFCqE.cjs.map → isServer-BJHVnixd.cjs.map} +1 -1
  98. package/dist/{isServer-D1TXfOs3.js → isServer-Da3o3XSs.js} +2 -2
  99. package/dist/{isServer-D1TXfOs3.js.map → isServer-Da3o3XSs.js.map} +1 -1
  100. package/dist/{isTypedArray-47R0wdrc.js → isTypedArray-DuNA8tK6.js} +3 -3
  101. package/dist/{isTypedArray-47R0wdrc.js.map → isTypedArray-DuNA8tK6.js.map} +1 -1
  102. package/dist/{isTypedArray-DiCoqffZ.cjs → isTypedArray-TJptiw2b.cjs} +3 -3
  103. package/dist/{isTypedArray-DiCoqffZ.cjs.map → isTypedArray-TJptiw2b.cjs.map} +1 -1
  104. package/dist/{isURL-CQiowFq2.js → isURL-C-kSk6KJ.js} +2 -2
  105. package/dist/{isURL-CQiowFq2.js.map → isURL-C-kSk6KJ.js.map} +1 -1
  106. package/dist/{isURL-WZypXsax.cjs → isURL-DeUPO_oR.cjs} +2 -2
  107. package/dist/{isURL-WZypXsax.cjs.map → isURL-DeUPO_oR.cjs.map} +1 -1
  108. package/dist/{isValidDomain-BSXshgkC.cjs → isValidDomain-BB9IGhJs.cjs} +65 -8
  109. package/dist/isValidDomain-BB9IGhJs.cjs.map +1 -0
  110. package/dist/{isValidDomain-DwA2EN79.js → isValidDomain-DoE98yhJ.js} +54 -9
  111. package/dist/isValidDomain-DoE98yhJ.js.map +1 -0
  112. package/dist/next/index.cjs +7 -7
  113. package/dist/next/index.cjs.map +1 -1
  114. package/dist/next/index.d.cts +185 -191
  115. package/dist/next/index.d.ts +185 -191
  116. package/dist/next/index.js +7 -7
  117. package/dist/next/index.js.map +1 -1
  118. package/dist/next/server/index.cjs +2 -2
  119. package/dist/next/server/index.d.cts +26 -26
  120. package/dist/next/server/index.d.ts +26 -26
  121. package/dist/next/server/index.js +2 -2
  122. package/dist/{noop-B2mTBhW-.cjs → noop-B13_ii35.cjs} +2 -2
  123. package/dist/{noop-B2mTBhW-.cjs.map → noop-B13_ii35.cjs.map} +1 -1
  124. package/dist/{noop-BzktGBVz.js → noop-ubqAIbHD.js} +2 -2
  125. package/dist/{noop-BzktGBVz.js.map → noop-ubqAIbHD.js.map} +1 -1
  126. package/dist/{normalizeSpaces-WS_iERJk.js → normalizeSpaces-Bg2IZW7W.js} +3 -3
  127. package/dist/{normalizeSpaces-WS_iERJk.js.map → normalizeSpaces-Bg2IZW7W.js.map} +1 -1
  128. package/dist/{normalizeSpaces-DQHR3Tlr.cjs → normalizeSpaces-ZXnR4Qzp.cjs} +3 -3
  129. package/dist/{normalizeSpaces-DQHR3Tlr.cjs.map → normalizeSpaces-ZXnR4Qzp.cjs.map} +1 -1
  130. package/dist/{normalizeString-2WLth_Gj.js → normalizeString-BDdkaXui.js} +3 -3
  131. package/dist/{normalizeString-2WLth_Gj.js.map → normalizeString-BDdkaXui.js.map} +1 -1
  132. package/dist/{normalizeString-D8euBcRD.cjs → normalizeString-BE6ELqEb.cjs} +3 -3
  133. package/dist/{normalizeString-D8euBcRD.cjs.map → normalizeString-BE6ELqEb.cjs.map} +1 -1
  134. package/dist/operations/index.cjs +10 -10
  135. package/dist/operations/index.cjs.map +1 -1
  136. package/dist/operations/index.d.cts +120 -120
  137. package/dist/operations/index.d.ts +120 -120
  138. package/dist/operations/index.js +10 -10
  139. package/dist/operations/index.js.map +1 -1
  140. package/dist/parsers/index.cjs +2 -2
  141. package/dist/parsers/index.d.cts +222 -222
  142. package/dist/parsers/index.d.ts +222 -222
  143. package/dist/parsers/index.js +2 -2
  144. package/dist/{parsers-Dpuq-V4u.js → parsers-BSBPgvsq.js} +4 -4
  145. package/dist/{parsers-Dpuq-V4u.js.map → parsers-BSBPgvsq.js.map} +1 -1
  146. package/dist/{parsers-DXtpsDyj.cjs → parsers-OqDeffqc.cjs} +4 -4
  147. package/dist/{parsers-DXtpsDyj.cjs.map → parsers-OqDeffqc.cjs.map} +1 -1
  148. package/dist/{parsing-B43x1sxn.js → parsing-Cao8b358.js} +3 -3
  149. package/dist/{parsing-B43x1sxn.js.map → parsing-Cao8b358.js.map} +1 -1
  150. package/dist/{parsing-lRoxn1Nz.cjs → parsing-DOGSCH6N.cjs} +3 -3
  151. package/dist/{parsing-lRoxn1Nz.cjs.map → parsing-DOGSCH6N.cjs.map} +1 -1
  152. package/dist/predicates/index.cjs +15 -15
  153. package/dist/predicates/index.d.cts +3 -3
  154. package/dist/predicates/index.d.ts +3 -3
  155. package/dist/predicates/index.js +15 -15
  156. package/dist/{predicates-gNepszvo.js → predicates-Bj6meyXV.js} +13 -14
  157. package/dist/{predicates-gNepszvo.js.map → predicates-Bj6meyXV.js.map} +1 -1
  158. package/dist/{predicates-DiaYA7Ps.cjs → predicates-D0ubqgqy.cjs} +13 -14
  159. package/dist/{predicates-DiaYA7Ps.cjs.map → predicates-D0ubqgqy.cjs.map} +1 -1
  160. package/dist/promises/index.cjs +4 -4
  161. package/dist/promises/index.d.cts +101 -101
  162. package/dist/promises/index.d.ts +101 -101
  163. package/dist/promises/index.js +4 -4
  164. package/dist/{punyCode-hmiFzLWT.js → punyCode-8SrbMWfM.js} +6 -6
  165. package/dist/punyCode-8SrbMWfM.js.map +1 -0
  166. package/dist/{punyCode-CTWXVVFo.cjs → punyCode-D-Qu6nj6.cjs} +6 -6
  167. package/dist/punyCode-D-Qu6nj6.cjs.map +1 -0
  168. package/dist/{removeSpaces-BE8lfh-4.js → removeSpaces-Bmc5DX4F.js} +3 -3
  169. package/dist/removeSpaces-Bmc5DX4F.js.map +1 -0
  170. package/dist/{removeSpaces-DRRxNWlb.cjs → removeSpaces-CWIvhZHg.cjs} +3 -3
  171. package/dist/removeSpaces-CWIvhZHg.cjs.map +1 -0
  172. package/dist/rzl-utils.global.js +21 -0
  173. package/dist/{safeJsonParse-CXruaP0p.js → safeJsonParse-BP38mwlj.js} +9 -9
  174. package/dist/safeJsonParse-BP38mwlj.js.map +1 -0
  175. package/dist/{safeJsonParse-BBnQElk8.cjs → safeJsonParse-Sms2CJf4.cjs} +9 -9
  176. package/dist/safeJsonParse-Sms2CJf4.cjs.map +1 -0
  177. package/dist/{safeStableStringify-Cc62pfRp.cjs → safeStableStringify-CJtP89qn.cjs} +4 -4
  178. package/dist/{safeStableStringify-Cc62pfRp.cjs.map → safeStableStringify-CJtP89qn.cjs.map} +1 -1
  179. package/dist/{safeStableStringify-BNh3D0K0.js → safeStableStringify-CXOZ9Ub8.js} +4 -4
  180. package/dist/{safeStableStringify-BNh3D0K0.js.map → safeStableStringify-CXOZ9Ub8.js.map} +1 -1
  181. package/dist/strings/index.cjs +12 -9
  182. package/dist/strings/index.cjs.map +1 -1
  183. package/dist/strings/index.d.cts +2 -2
  184. package/dist/strings/index.d.ts +2 -2
  185. package/dist/strings/index.js +12 -9
  186. package/dist/strings/index.js.map +1 -1
  187. package/dist/tailwind/index.cjs +2 -2
  188. package/dist/tailwind/index.d.cts +2 -2
  189. package/dist/tailwind/index.d.ts +2 -2
  190. package/dist/tailwind/index.js +2 -2
  191. package/dist/{tailwind-IJvOdkZp.js → tailwind-B2ssevxq.js} +5 -5
  192. package/dist/tailwind-B2ssevxq.js.map +1 -0
  193. package/dist/{tailwind-DJ4cmLUw.cjs → tailwind-CHIx9uxu.cjs} +5 -5
  194. package/dist/tailwind-CHIx9uxu.cjs.map +1 -0
  195. package/dist/{toStringArrayUnRecursive-xUaU8Ot9.cjs → toStringArrayUnRecursive-C4zYCja7.cjs} +6 -6
  196. package/dist/{toStringArrayUnRecursive-xUaU8Ot9.cjs.map → toStringArrayUnRecursive-C4zYCja7.cjs.map} +1 -1
  197. package/dist/{toStringArrayUnRecursive-CFs0jTEg.js → toStringArrayUnRecursive-DJGtPsFb.js} +6 -6
  198. package/dist/{toStringArrayUnRecursive-CFs0jTEg.js.map → toStringArrayUnRecursive-DJGtPsFb.js.map} +1 -1
  199. package/dist/urls/index.cjs +15 -14
  200. package/dist/urls/index.cjs.map +1 -1
  201. package/dist/urls/index.d.cts +656 -659
  202. package/dist/urls/index.d.ts +656 -659
  203. package/dist/urls/index.js +15 -14
  204. package/dist/urls/index.js.map +1 -1
  205. package/package.json +2 -2
  206. package/dist/assertIsBoolean-BlBct0Fc.js.map +0 -1
  207. package/dist/assertIsBoolean-DozdtbNi.cjs.map +0 -1
  208. package/dist/conversions-CBs8-REq.cjs.map +0 -1
  209. package/dist/conversions-EMJa3g-D.js.map +0 -1
  210. package/dist/formatEnvPort-DpIXzPAZ.js.map +0 -1
  211. package/dist/formatEnvPort-hHNvOim-.cjs.map +0 -1
  212. package/dist/formatters-QcZO_Cpx.js.map +0 -1
  213. package/dist/formatters-lAYgA11L.cjs.map +0 -1
  214. package/dist/index-26W7ItWx.d.ts +0 -760
  215. package/dist/index-BPPQjAfs.d.cts +0 -2359
  216. package/dist/index-BXjlgBLz.d.cts +0 -2139
  217. package/dist/index-B_Wwo91H.d.ts +0 -2359
  218. package/dist/index-CpufydcI.d.cts +0 -704
  219. package/dist/index-Czc4O526.d.ts +0 -333
  220. package/dist/index-DPs1_p5G.d.cts +0 -760
  221. package/dist/index-DRpOyBSC.d.ts +0 -1703
  222. package/dist/index-DWWvtHUn.d.cts +0 -822
  223. package/dist/index-DnM0LD0n.d.cts +0 -333
  224. package/dist/index-GUZ9fK6T.d.ts +0 -2139
  225. package/dist/index-I4fAzwXV.d.ts +0 -704
  226. package/dist/index-JDrOl_19.d.ts +0 -822
  227. package/dist/index-b66P49Qe.d.cts +0 -1703
  228. package/dist/isPlainObject-DcFGh3_5.d.ts +0 -530
  229. package/dist/isPlainObject-doTI11Ib.d.cts +0 -530
  230. package/dist/isValidDomain-BSXshgkC.cjs.map +0 -1
  231. package/dist/isValidDomain-DwA2EN79.js.map +0 -1
  232. package/dist/punyCode-CTWXVVFo.cjs.map +0 -1
  233. package/dist/punyCode-hmiFzLWT.js.map +0 -1
  234. package/dist/removeSpaces-BE8lfh-4.js.map +0 -1
  235. package/dist/removeSpaces-DRRxNWlb.cjs.map +0 -1
  236. package/dist/safeJsonParse-BBnQElk8.cjs.map +0 -1
  237. package/dist/safeJsonParse-CXruaP0p.js.map +0 -1
  238. package/dist/tailwind-DJ4cmLUw.cjs.map +0 -1
  239. package/dist/tailwind-IJvOdkZp.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatters-Cbij0XLU.cjs","names":["isString","isFinite","getPreciseType","safeStableStringify","hasOwnProp","isBoolean","isInteger","isPlainObject","parseCurrencyString","isNaN","isUndefined","isFunction","isString","isFinite","getPreciseType","AsYouType","isNil","isString","isNumber","getPreciseType","hasOwnProp","isBoolean","isUndefined","safeStableStringify","isNonEmptyString","isUndefined","isNonEmptyString","hasOwnProp","getPreciseType","safeStableStringify","isNil","isInteger","getPreciseType","safeStableStringify","hasOwnProp","normalizeSpaces","isNonEmptyString","hasOwnProp","isInteger","getPreciseType","safeStableStringify","isEmptyString","isNil","isDate","isNonEmptyString","isPlainObject","hasOwnProp","id","enUS","isNaN","isNil","isDate","isNonEmptyString","isNaN","isPlainObject","isNil","isString","isDate","isNonEmptyString","isNaN","isNil","isString","isEmptyString","isDate","isNonEmptyString","isNaN"],"sources":["../src/formatters/currencies/formatCurrency.ts","../src/formatters/numbers/formatNumber.ts","../src/formatters/phones/_private/formatPhoneNumber.utils.ts","../src/formatters/phones/formatPhoneNumber.ts","../src/formatters/strings/_private/censorEmail.utils.ts","../src/formatters/strings/censorEmail.ts","../src/formatters/strings/chunkString.ts","../src/formatters/strings/truncateString.ts","../src/formatters/times/formatDateFns.ts","../src/formatters/times/formatDateIntl.ts","../src/formatters/times/formatDateTime.ts","../src/formatters/times/getGMTOffset.ts"],"sourcesContent":["import type { FormatCurrencyOptions } from \"@/formatters/currencies/formatCurrency.types\";\n\nimport { isNaN } from \"@/predicates/is/isNaN\";\nimport { isFinite } from \"@/predicates/is/isFinite\";\nimport { isString } from \"@/predicates/is/isString\";\nimport { isInteger } from \"@/predicates/is/isInteger\";\nimport { isBoolean } from \"@/predicates/is/isBoolean\";\nimport { isFunction } from \"@/predicates/is/isFunction\";\nimport { hasOwnProp } from \"@/predicates/has/hasOwnProp\";\nimport { isUndefined } from \"@/predicates/is/isUndefined\";\nimport { isPlainObject } from \"@/predicates/is/isPlainObject\";\nimport { getPreciseType } from \"@/predicates/type/getPreciseType\";\n\nimport { assertIsString } from \"@/assertions/strings/assertIsString\";\nimport { assertIsBoolean } from \"@/assertions/booleans/assertIsBoolean\";\nimport { assertIsPlainObject } from \"@/assertions/objects/assertIsPlainObject\";\n\nimport { parseCurrencyString } from \"@/conversions/currency/parsing\";\nimport { safeStableStringify } from \"@/conversions/stringify/safeStableStringify\";\n\n/** ***Util helper for {@link formatCurrency}.***\n *\n * @internal\n */\nconst formatIndianNumber = ({\n numStr,\n separator\n}: {\n numStr?: string;\n separator: string;\n}) => {\n const lastThree = numStr?.slice(-3);\n const rest = numStr?.slice(0, -3);\n if (!rest) return lastThree;\n return (\n rest.replace(/\\B(?=(\\d{2})+(?!\\d))/g, separator) + separator + lastThree\n );\n};\n\n/** -------------------------------------------------------\n * * ***Utility: `formatCurrency`.***\n * -------------------------------------------------------\n * **Formats a number or messy currency string into a\n * beautifully formatted currency string, with highly\n * customizable separators, decimal control, rounding,\n * currency symbols, and negative styling.**\n * - **✅ Highlights:**\n * - ***Accepts:***\n * - Pure numbers: `15300.95`.\n * - Messy currency strings from **any locale**:\n * - `\"Rp 15.000,21\"` ***(Indonesian / Euro)***.\n * - `\"$12,345.60\"` ***(US)***.\n * - `\"CHF 12'345.60\"` ***(Swiss)***.\n * - `\"1,23,456.78\"` ***(Indian)***.\n * - Auto extracts numeric value with smart multi-locale parsing\n * via ***`parseCurrencyString` utility function***.\n * - Strong type checks & clear errors for misconfigured options.\n * - **Handles:**\n * - Thousands separators: `.`, `,`, `'`, ` `.\n * - Decimal separators: `,`, `.`.\n * - Decimal suffix (eg. `\".-\"`, `\" USD\"`).\n * - Currency prefix (eg. `\"Rp \"`, `\"$ \"`).\n * - Rounding: `\"round\"`, `\"ceil\"`, `\"floor\"`, or truncate.\n * - Negative styling: dash `-`, brackets `( )`, absolute, or custom.\n * - **✅ How input is parsed:**\n * - Removes all non-digit except `.`, `,`, `'` and spaces.\n * - Detects bracket negatives: `\"(15.000,10)\"` ➔ `-15000.10`.\n * - Uses last `,` or `.` as decimal separator (others are thousands).\n * - Ignores currency symbols like `Rp`, `$` (must re-apply with `suffixCurrency`).\n * - **ℹ️ Note:**\n * - Always re-apply symbols via `suffixCurrency`.\n * - `parseCurrencyString` smartly detects last decimal,\n * so `\"1.121.234,56\"` and `\"1,121,234.56\"` both parsed correctly.\n * @param {string|number} value\n * ***The input value to format, examples:***\n * - `\"Rp 15.000,21\"`.\n * - `\"$12,345.60\"`.\n * - `\"CHF 12'345.60\"`.\n * - `15300.95`.\n * @param {FormatCurrencyOptions} [options] ***Optional configuration object.***\n * @param {FormatCurrencyOptions[\"separator\"]} [options.separator]\n * ***Thousands separator:***\n * - `{ separator: \".\" }` ➔ `1.000.000`.\n * - *DefaultValue: `\".\"`.*\n * @param {FormatCurrencyOptions[\"separatorDecimals\"]} [options.separatorDecimals]\n * ***Decimal separator:***\n * - `{ separatorDecimals: \",\" }` ➔ `1.000,10`.\n * - *DefaultValue: `\",\"`.*\n * @param {FormatCurrencyOptions[\"suffixCurrency\"]} [options.suffixCurrency]\n * ***Prefix currency string:***\n * - Does **not auto-keep input symbols**.\n * - Must set manually e.g: `{ suffixCurrency: \"Rp \" }`.\n * - `{ suffixCurrency: \"Rp \" }` ➔ `Rp 1.000`.\n * - *DefaultValue: `\"\"`.*\n * @param {FormatCurrencyOptions[\"decimal\"]} [options.decimal]\n * ***Whether to show decimals. If `false`, decimals are truncated:***\n * - If `false`, cut the decimal.\n * - *DefaultValue: `false`.*\n * @param {FormatCurrencyOptions[\"totalDecimal\"]} [options.totalDecimal]\n * ***Total decimal digits:***\n * - If `decimal: true` & `roundedDecimal: false`, simply cuts.\n * - *DefaultValue: `2`.*\n * @param {FormatCurrencyOptions[\"separatorDecimals\"]} [options.suffixDecimal]\n * ***Text appended after decimals:***\n * - E.g: (`\".-\"`, `\" USD\"`).\n * - Example 1: `\".-\"` ➔ `1.000,00.-`.\n * - Example 2: `\" USD\"` ➔ `1.000,00 USD`.\n * - *DefaultValue: `\"\"`.*\n * @param {FormatCurrencyOptions[\"endDecimal\"]} [options.endDecimal]\n * ***Actually append `suffixDecimal`:***\n * - *DefaultValue: `true`.*\n * @param {FormatCurrencyOptions[\"roundedDecimal\"]} [options.roundedDecimal]\n * ***Rounding mode:***\n * - `\"round\"` ➔ nearest.\n * - `\"ceil\"` ➔ always up.\n * - `\"floor\"` ➔ always down.\n * - `false` ➔ truncate.\n * - *DefaultValue: `\"round\"`.*\n * @param {FormatCurrencyOptions[\"negativeFormat\"]} [options.negativeFormat]\n * ***How to format negatives:***\n * - `\"dash\"` ➔ `-15.000`.\n * - `\"brackets\"` ➔ `(15.000)`.\n * - `\"abs\"` ➔ `15.000` (always positive).\n * - Or object: `{ style: \"dash\" | \"brackets\" | \"abs\", space: true | false, custom: (formatted) => string }`.\n * - *DefaultValue: `\"dash\"`.*\n * @param {FormatCurrencyOptions[\"indianFormat\"]} [options.indianFormat]\n * ***Applies Indian Format:***\n * - If `true`, formats as Indian: `12,34,567`.\n * - Also forces `separator: \",\"`, `separatorDecimals: \".\"`.\n * @returns {string}\n * ***Nicely formatted currency string, examples:***\n * - `\"15.000,10\"`.\n * - `\"Rp 15.000,10.-\"`.\n * - `\"15'000.10 USD\"`.\n * - `\"12,34,567.89\"`.\n * @throws **{@link TypeError | `TypeError`}** ***If:***\n * - The `value` is not string or number.\n * - Cannot parse to valid number.\n * - Options have invalid types.\n * @example\n * // --- Number input (default, decimals off) ---\n * formatCurrency(1234567.89);\n * // ➔ \"1.234.567\"\n *\n * // --- Decimals enabled ---\n * formatCurrency(1234567.89, { decimal: true });\n * // ➔ \"1.234.567,89\"\n *\n * // --- Indian format ---\n * formatCurrency(1234567.89, { decimal: true, indianFormat: true });\n * // ➔ \"12,34,567.89\"\n *\n * // --- String input (Indonesian style) ---\n * formatCurrency(\"Rp 15.000,21\", { decimal: true });\n * // ➔ \"15.000,21\"\n *\n * // --- String input (US style) ---\n * formatCurrency(\"$12,345.60\", { decimal: true });\n * // ➔ \"12.345,60\"\n *\n * // --- String input (Swiss style) ---\n * formatCurrency(\"CHF 12'345.60\", { decimal: true });\n * // ➔ \"12'345,60\"\n *\n * // --- String input (Indian style) ---\n * formatCurrency(\"1,23,456.78\", { decimal: true, indianFormat: true });\n * // ➔ \"12,34,567.78\"\n *\n * // --- Negative numbers (dash) ---\n * formatCurrency(-1234.56, { decimal: true });\n * // ➔ \"-1.234,56\"\n *\n * // --- Negative numbers (brackets) ---\n * formatCurrency(-1234.56, {\n * decimal: true,\n * negativeFormat: \"brackets\"\n * });\n * // ➔ \"(1.234,56)\"\n *\n * // --- Negative numbers (custom object style) ---\n * formatCurrency(-1234.56, {\n * decimal: true,\n * negativeFormat: { style: \"brackets\", space: true }\n * });\n * // ➔ \"( 1.234,56 )\"\n *\n * // --- Negative numbers (custom function) ---\n * formatCurrency(-1234.56, {\n * decimal: true,\n * negativeFormat: { custom: (val) => `NEGATIVE[${val}]` }\n * });\n * // ➔ \"NEGATIVE[1.234,56]\"\n *\n * // --- With prefix currency ---\n * formatCurrency(1234.56, {\n * decimal: true,\n * suffixCurrency: \"Rp \"\n * });\n * // ➔ \"Rp 1.234,56\"\n *\n * // --- With suffix decimal ---\n * formatCurrency(1234.56, {\n * decimal: true,\n * suffixDecimal: \".-\"\n * });\n * // ➔ \"1.234,56.-\"\n *\n * // --- With suffix currency + suffix decimal ---\n * formatCurrency(1234.56, {\n * decimal: true,\n * suffixCurrency: \"Rp \",\n * suffixDecimal: \".-\"\n * });\n * // ➔ \"Rp 1.234,56.-\"\n *\n * // --- Custom separators ---\n * formatCurrency(1234567.89, {\n * decimal: true,\n * separator: \"'\",\n * separatorDecimals: \".\"\n * });\n * // ➔ \"1'234'567.89\"\n *\n * // --- Rounding: ceil ---\n * formatCurrency(1234.561, {\n * decimal: true,\n * roundedDecimal: \"ceil\"\n * });\n * // ➔ \"1.234,57\"\n *\n * // --- Rounding: floor ---\n * formatCurrency(1234.569, {\n * decimal: true,\n * roundedDecimal: \"floor\"\n * });\n * // ➔ \"1.234,56\"\n *\n * // --- Rounding: truncate (false) ---\n * formatCurrency(1234.569, {\n * decimal: true,\n * roundedDecimal: false\n * });\n * // ➔ \"1.234,56\"\n *\n * // --- Force no decimals (decimal: false) ---\n * formatCurrency(1234.567, { decimal: false });\n * // ➔ \"1.235\"\n *\n * // --- Edge case: messy input with dots & commas ---\n * formatCurrency(\"1.121.234,561\", {\n * decimal: true,\n * totalDecimal: 2,\n * roundedDecimal: \"ceil\",\n * suffixCurrency: \"Rp \",\n * negativeFormat: { style: \"brackets\" }\n * });\n * // ➔ \"(Rp 1.121.234,57)\"\n *\n * // --- Edge case: integer string input ---\n * formatCurrency(\"1.121.234\", {\n * decimal: true,\n * suffixCurrency: \"Rp \",\n * roundedDecimal: \"ceil\"\n * });\n * // ➔ \"Rp 1.121.234,00\"\n */\nexport const formatCurrency = (\n value: string | number,\n options: FormatCurrencyOptions = {}\n): string => {\n if (!isString(value) && !isFinite(value)) {\n throw new TypeError(\n `First parameter (\\`value\\`) must be of type \\`string\\` or \\`primitive-number\\`, but received: \\`${getPreciseType(\n value\n )}\\`, with value: \\`${safeStableStringify(value, {\n keepUndefined: true\n })}\\`.`\n );\n }\n\n assertIsPlainObject(options, {\n message: ({ currentType, validType }) =>\n `Second parameter (\\`options\\`) must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n const decimal = hasOwnProp(options, \"decimal\") ? options.decimal : false;\n const totalDecimal = hasOwnProp(options, \"totalDecimal\")\n ? options.totalDecimal\n : 2;\n const endDecimal = hasOwnProp(options, \"endDecimal\")\n ? options.endDecimal\n : true;\n const indianFormat = hasOwnProp(options, \"indianFormat\")\n ? options.indianFormat\n : false;\n const suffixCurrency = hasOwnProp(options, \"suffixCurrency\")\n ? options.suffixCurrency\n : \"\";\n const suffixDecimal = hasOwnProp(options, \"suffixDecimal\")\n ? options.suffixDecimal\n : \"\";\n const roundedDecimal = hasOwnProp(options, \"roundedDecimal\")\n ? options.roundedDecimal\n : \"round\";\n const negativeFormat = hasOwnProp(options, \"negativeFormat\")\n ? options.negativeFormat\n : \"dash\";\n let separatorDecimals = hasOwnProp(options, \"separatorDecimals\")\n ? options.separatorDecimals\n : \",\";\n let separator = hasOwnProp(options, \"separator\") ? options.separator : \".\";\n\n // validations\n if (\n !isString(separator) ||\n !isString(separatorDecimals) ||\n !isString(suffixCurrency) ||\n !isString(suffixDecimal)\n ) {\n throw new TypeError(\n `Parameter \\`separator\\`, \\`separatorDecimals\\`, \\`suffixCurrency\\` and \\`suffixDecimal\\` property of the \\`options\\` (second parameter) must be of type \\`string\\`, but received: ['separator': \\`${getPreciseType(\n separator\n )}\\`, 'separatorDecimals': \\`${getPreciseType(\n separatorDecimals\n )}\\`, 'suffixCurrency': \\`${getPreciseType(\n suffixCurrency\n )}\\`, 'suffixDecimal': \\`${getPreciseType(suffixDecimal)}\\`].`\n );\n }\n\n if (\n !isBoolean(decimal) ||\n !isBoolean(endDecimal) ||\n !isBoolean(indianFormat)\n ) {\n throw new TypeError(\n `Parameter \\`decimal\\`, \\`endDecimal\\` and \\`indianFormat\\` property of the \\`options\\` (second parameter) must be of type \\`boolean\\`, but received: ['decimal': \\`${getPreciseType(\n decimal\n )}\\`, 'endDecimal': \\`${getPreciseType(\n endDecimal\n )}\\`, 'indianFormat': \\`${getPreciseType(indianFormat)}\\`].`\n );\n }\n\n if (!isInteger(totalDecimal)) {\n throw new TypeError(\n `Parameter \\`totalDecimal\\` property of the \\`options\\` (second parameter) must be of type \\`integer-number\\`, but received: \\`${getPreciseType(\n totalDecimal\n )}\\`, with value: \\`${safeStableStringify(length, {\n keepUndefined: true\n })}\\`.`\n );\n }\n\n if (\n !(\n roundedDecimal === false ||\n roundedDecimal === \"round\" ||\n roundedDecimal === \"ceil\" ||\n roundedDecimal === \"floor\"\n )\n ) {\n throw new TypeError(\n `Parameter \\`roundedDecimal\\` property of the \\`options\\` (second parameter) must be of type \\`false\\` or \\`string\\` must be one of \"round\" | \"ceil\" | \"floor\", but received: \\`${getPreciseType(\n roundedDecimal\n )}\\`, with value: \\`${safeStableStringify(roundedDecimal, {\n keepUndefined: true\n })}\\`.`\n );\n }\n\n if (\n !(\n negativeFormat === \"abs\" ||\n negativeFormat === \"brackets\" ||\n negativeFormat === \"dash\" ||\n isPlainObject(negativeFormat)\n )\n ) {\n throw new TypeError(\n `Parameter \\`negativeFormat\\` property of the \\`options\\` (second parameter) must be of type \\`string\\` must be one of \"abs\" | \"brackets\" | \"dash\" or \\`plain-object\\` type, but received: \\`${getPreciseType(\n negativeFormat\n )}\\`, with value: \\`${safeStableStringify(negativeFormat, {\n keepUndefined: true\n })}\\`.`\n );\n }\n\n // parse number\n const rawNum = isString(value) ? parseCurrencyString(value) : value;\n if (isNaN(rawNum)) {\n throw new TypeError(\n \"First parameter (`value`) could not be parsed into a valid `number`.\"\n );\n }\n\n let integerPart: string | undefined;\n let decimalPartRaw: string | undefined;\n let num = Math.abs(rawNum);\n const factor = Math.pow(10, totalDecimal);\n\n if (roundedDecimal) {\n const scaled = num * factor;\n switch (roundedDecimal) {\n case \"round\":\n num = Math.round(scaled) / factor;\n break;\n case \"ceil\":\n num = Math.ceil(scaled) / factor;\n break;\n case \"floor\":\n num = Math.floor(scaled) / factor;\n break;\n }\n }\n\n if (roundedDecimal) {\n [integerPart, decimalPartRaw] = num.toFixed(totalDecimal).split(\".\");\n decimalPartRaw = decimalPartRaw ?? \"\".padEnd(totalDecimal, \"0\");\n } else {\n // cut decimal manually\n const split = String(num).split(\".\");\n integerPart = split[0];\n decimalPartRaw = (split[1] || \"\")\n .slice(0, totalDecimal)\n .padEnd(totalDecimal, \"0\");\n }\n\n let formattedInteger: string;\n\n if (indianFormat) {\n separator = \",\";\n separatorDecimals = \".\";\n formattedInteger =\n (suffixCurrency.trim().length ? suffixCurrency : \"\") +\n formatIndianNumber({ numStr: integerPart, separator });\n } else {\n formattedInteger =\n (suffixCurrency.trim().length ? suffixCurrency : \"\") +\n integerPart?.replace(/\\B(?=(\\d{3})+(?!\\d))/g, separator);\n }\n\n if (decimal && !isUndefined(decimalPartRaw) && totalDecimal > 0) {\n let formattedDecimal = separatorDecimals + decimalPartRaw;\n if (endDecimal) formattedDecimal += suffixDecimal;\n formattedInteger += formattedDecimal;\n }\n\n // negative format\n if (rawNum < 0) {\n if (negativeFormat === \"dash\") {\n formattedInteger = \"-\" + formattedInteger;\n } else if (negativeFormat === \"brackets\") {\n formattedInteger = \"(\" + formattedInteger + \")\";\n } else if (negativeFormat === \"abs\") {\n // no sign\n } else if (isPlainObject(negativeFormat)) {\n if (hasOwnProp(negativeFormat, \"custom\")) {\n const formatCustomNegative = negativeFormat.custom;\n\n if (!isFunction(formatCustomNegative)) {\n throw new TypeError(\n `Parameter \\`negativeFormat.custom\\` property of the \\`options\\` (second parameter) must be of type function: \\`(formatted: string) => string\\`, but received: \\`${getPreciseType(\n formatCustomNegative\n )}\\`.`\n );\n }\n\n const result = formatCustomNegative(formattedInteger);\n\n assertIsString(result, {\n message: ({ currentType, validType }) =>\n `Parameter \\`negativeFormat.custom\\` property of the \\`options\\` (second parameter) expected return a \\`${validType}\\` type value, but received: \\`${currentType}\\`.`\n });\n\n formattedInteger = result;\n } else {\n const formatStyleNegative = negativeFormat.style || \"dash\";\n const formatSpaceNegative = !isUndefined(negativeFormat.space)\n ? negativeFormat.space\n : false;\n\n assertIsBoolean(formatSpaceNegative, {\n message: ({ currentType, validType }) =>\n `Parameter \\`negativeFormat.space\\` property of the \\`options\\` (second parameter) must be of type \\`${validType} or undefined\\`, but received: \\`${currentType}\\`.`\n });\n\n if (\n !(\n formatStyleNegative === \"abs\" ||\n formatStyleNegative === \"brackets\" ||\n formatStyleNegative === \"dash\"\n )\n ) {\n throw new TypeError(\n `Parameter \\`negativeFormat.style\\` property of the \\`options\\` (second parameter) must be of type \\`string\\` must be of type \"abs\" | \"brackets\" | \"dash\", but received: \\`${getPreciseType(\n formatStyleNegative\n )}\\`, with value: \\`${safeStableStringify(formatStyleNegative, {\n keepUndefined: true\n })}\\`.`\n );\n }\n\n switch (formatStyleNegative) {\n case \"dash\":\n formattedInteger =\n \"-\" + (formatSpaceNegative ? \" \" : \"\") + formattedInteger;\n break;\n case \"brackets\":\n formattedInteger = formatSpaceNegative\n ? `( ${formattedInteger} )`\n : `(${formattedInteger})`;\n break;\n case \"abs\":\n // no sign\n break;\n }\n }\n }\n }\n\n return formattedInteger;\n};\n","import { isFinite } from \"@/predicates/is/isFinite\";\nimport { isString } from \"@/predicates/is/isString\";\nimport { getPreciseType } from \"@/predicates/type/getPreciseType\";\n\n/** ----------------------------------------------------------\n * * ***Utility: `formatNumber`.***\n * ----------------------------------------------------------\n * **Formats a number or numeric string by adding a custom separator\n * every three digits (thousands separator), and intelligently flips\n * the decimal separator according to the chosen separator.**\n * - **Features:**\n * - Converts a number to string before formatting.\n * - Defaults to using `,` as the thousands separator.\n * - If `.` is used as the separator, the decimal will automatically\n * become `,`, and vice versa.\n * - Handles input with existing formatting (e.g. \"1,234,567.89\") and normalizes it.\n * - Supports custom separators, including spaces.\n * - Preserves decimals even if more than 2 digits.\n * @param {string | number} value - The numeric value or string to format, can be plain numbers, or already formatted strings like `\"1,234,567.89\"`.\n * @param {string} [separator=\",\"] - The thousands separator to use, examples: `\",\"` ***(default)***, `\".\"`, `\" \"`, etc.\n * @returns {string} The formatted string with thousands separators and\n * appropriate decimal separator.\n * @throws **{@link TypeError | `TypeError`}** if `value` is not a string or number, or `separator` is not a string.\n * @example\n * formatNumber(1000000);\n * // ➔ \"1,000,000\"\n * formatNumber(\"987654321\");\n * // ➔ \"987,654,321\"\n * formatNumber(1234567.89);\n * // ➔ \"1,234,567.89\"\n * formatNumber(\"1234567,89\");\n * // ➔ \"1,234,567.89\"\n * formatNumber(\"1234567.892\");\n * // ➔ \"1,234,567.892\"\n * formatNumber(\"1234567.89\", \".\");\n * // ➔ \"1.234.567,89\"\n * formatNumber(\"1234567,89\", \",\");\n * // ➔ \"1,234,567.89\"\n * formatNumber(\"987654321\", \" \");\n * // ➔ \"987 654 321\"\n * formatNumber(\"1,234,567.89\");\n * // ➔ \"1,234,567.89\"\n * formatNumber(\"1.234.567,89\", \",\");\n * // ➔ \"1,234,567.89\"\n * formatNumber(\"1.234.567,893\", \".\");\n * // ➔ \"1.234.567,893\"\n * formatNumber(\"1234.56\", \".\");\n * // ➔ \"1.234,56\"\n * formatNumber(\"1234,56\", \",\");\n * // ➔ \"1,234.56\"\n */\nexport const formatNumber = (\n value: string | number,\n separator: string = \",\"\n): string => {\n if (!isString(value) && !isFinite(value)) {\n throw new TypeError(\n `First parameter (\\`value\\`) must be of type \\`string\\` or \\`primitive number\\`, but received: \\`${getPreciseType(\n value\n )}\\`.`\n );\n }\n\n if (!isString(separator)) {\n throw new TypeError(\n `Second parameter (\\`separator\\`) must be of type \\`string\\` or empty as \\`undefined\\`, but received: \\`${getPreciseType(\n separator\n )}\\`.`\n );\n }\n\n separator = isString(separator) ? separator : \",\";\n const decimalSeparator =\n separator === \".\" ? \",\" : separator === \",\" ? \".\" : \".\";\n\n // Convert value to string\n const stringValue = value.toString().trim();\n\n // --- Normalize input ---\n // Find the last decimal separator from the end\n const lastDot = stringValue.lastIndexOf(\".\");\n const lastComma = stringValue.lastIndexOf(\",\");\n\n let actualDecimal = \"\";\n if (lastDot > lastComma) {\n actualDecimal = \".\";\n } else if (lastComma > lastDot) {\n actualDecimal = \",\";\n }\n\n // Split into integer and decimal parts\n let integerPart = stringValue;\n let decimalPart: string | undefined;\n\n if (actualDecimal) {\n const parts = stringValue.split(actualDecimal);\n integerPart = parts.slice(0, -1).join(actualDecimal); // merge if more than one\n decimalPart = parts.slice(-1)[0];\n }\n\n // Remove all non-digit characters from the integer part\n integerPart = integerPart.replace(/[^\\d]/g, \"\");\n\n // Format integer part with thousands separator\n const formattedInteger = integerPart.replace(\n /\\B(?=(\\d{3})+(?!\\d))/g,\n separator\n );\n\n // Combine with decimal part if exists\n return decimalPart\n ? `${formattedInteger}${decimalSeparator}${decimalPart}`\n : formattedInteger;\n};\n","import type { OmitStrict, Prettify } from \"@rzl-zone/ts-types-plus\";\nimport { isNonEmptyString } from \"@/predicates/is/isNonEmptyString\";\n\n/* eslint-disable @typescript-eslint/no-unused-vars */\nimport type { formatPhoneNumber } from \"../formatPhoneNumber\";\nimport {\n AsYouType,\n type PhoneNumber,\n type CountryCode\n} from \"libphonenumber-js/max\";\n\n/** ***Util constants `country code for special leading zero rule` for {@link formatPhoneNumber}.***\n *\n * @internal\n */\nexport const trunkZeroCountries: Record<string, string> = {\n \"7\": \"Russia, Kazakhstan\",\n \"20\": \"Egypt\",\n \"27\": \"South Africa\",\n \"30\": \"Greece\",\n \"31\": \"Netherlands\",\n \"32\": \"Belgium\",\n \"33\": \"France\",\n \"34\": \"Spain\",\n \"36\": \"Hungary\",\n \"39\": \"Italy, San Marino, Vatican\",\n \"41\": \"Switzerland\",\n \"43\": \"Austria\",\n \"44\": \"United Kingdom\",\n \"45\": \"Denmark\",\n \"46\": \"Sweden\",\n \"47\": \"Norway\",\n \"48\": \"Poland\",\n \"49\": \"Germany\",\n \"51\": \"Peru\",\n \"52\": \"Mexico\",\n \"53\": \"Cuba\",\n \"54\": \"Argentina\",\n \"55\": \"Brazil\",\n \"56\": \"Chile\",\n \"57\": \"Colombia\",\n \"58\": \"Venezuela\",\n \"60\": \"Malaysia\",\n \"61\": \"Australia\",\n \"62\": \"Indonesia\",\n \"63\": \"Philippines\",\n \"64\": \"New Zealand\",\n \"65\": \"Singapore\",\n \"66\": \"Thailand\",\n \"81\": \"Japan\",\n \"82\": \"South Korea\",\n \"84\": \"Vietnam\",\n \"86\": \"China\",\n \"90\": \"Turkey\",\n \"91\": \"India\",\n \"92\": \"Pakistan\",\n \"351\": \"Portugal\",\n \"352\": \"Luxembourg\",\n \"355\": \"Albania\",\n \"356\": \"Malta\",\n \"358\": \"Finland\",\n \"359\": \"Bulgaria\",\n \"370\": \"Lithuania\",\n \"371\": \"Latvia\",\n \"372\": \"Estonia\",\n \"373\": \"Moldova\",\n \"374\": \"Armenia\",\n \"375\": \"Belarus\",\n \"376\": \"Andorra\",\n \"377\": \"Monaco\",\n \"378\": \"San Marino\",\n \"379\": \"Vatican\",\n \"971\": \"UAE\"\n};\n/** ***Util helper for {@link formatPhoneNumber}.***\n *\n * @internal\n */\nexport const isValidPhoneE164 = (value: unknown) => {\n if (!isNonEmptyString(value)) return false;\n return (\n /^(\\+)?[0-9\\s().-]+$/.test(value) && value.replace(/\\D/g, \"\").length <= 15\n );\n};\n\n/** ***Util parsing `phone-number` for {@link formatPhoneNumber}.***\n *\n * @internal\n */\nexport const parsingAsYouType = (\n value: string,\n defaultCountry?: CountryCode\n) => {\n let parsed;\n try {\n parsed = new AsYouType(defaultCountry);\n parsed.input(value);\n return parsed;\n } catch {\n parsed?.reset();\n return undefined;\n }\n};\n\ntype ValidParseAsYouType = Prettify<\n OmitStrict<AsYouType, \"getNumber\"> & {\n getNumber(): PhoneNumber; // override agar tidak nullable\n }\n>;\n\n/** ***Util validation parsing `phone-number` when using `AsYouType` for {@link formatPhoneNumber}.***\n *\n * @internal\n */\nexport const isValidParseAsYouType = (\n parsedAsYouType?: AsYouType\n): parsedAsYouType is ValidParseAsYouType => {\n const parsed = !!parsedAsYouType?.isValid() && !!parsedAsYouType.getNumber();\n return parsed;\n};\n","import type {\n FormatPhoneNumberMain,\n FormatPhoneNumberTakeNumberOnly,\n FormatPhoneNumberCheckValidOnly,\n FormatPhoneNumberTransform,\n ValueFormatPhoneNumber,\n FormatPhoneNumberAllPassing,\n FormatPhoneNumberAllPassingValidOnly,\n FormatPhoneNumberAllPassingTakeOnly,\n OutputFormat\n} from \"./_private/formatPhoneNumber.types\";\n\nimport { isSupportedCountry } from \"libphonenumber-js/max\";\n\nimport { isNil } from \"@/predicates/is/isNil\";\nimport { isNumber } from \"@/predicates/is/isNumber\";\nimport { isString } from \"@/predicates/is/isString\";\nimport { isBoolean } from \"@/predicates/is/isBoolean\";\nimport { hasOwnProp } from \"@/predicates/has/hasOwnProp\";\nimport { isUndefined } from \"@/predicates/is/isUndefined\";\nimport { getPreciseType } from \"@/predicates/type/getPreciseType\";\nimport { isNonEmptyString } from \"@/predicates/is/isNonEmptyString\";\nimport { assertIsPlainObject } from \"@/assertions/objects/assertIsPlainObject\";\n\nimport {\n parsingAsYouType,\n isValidParseAsYouType\n} from \"./_private/formatPhoneNumber.utils\";\nimport { safeStableStringify } from \"@/conversions/stringify/safeStableStringify\";\n\n/** -------------------------------------------------------\n * * ***Utility: `formatPhoneNumber`.***\n * -------------------------------------------------------\n * **Formats a phone number into a customizable local or international style.**\n * - **Type:** ***`Formatting Number`.***\n * - **Can also:**\n * - Return only digits string when **digits-only mode** (`takeNumberOnly`):\n * - Return empty-string (\"\"), if invalid number phone.\n * - Return boolean when **validity-check mode** (`checkValidOnly`):\n * - ***Return `true` if:***\n * - A phone number is \"valid\" when it has valid length, and the actual phone number digits match the\n * regular expressions for its country (parameter options `defaultCountry`).\n * - **E.164 compliance:**\n * - Optional leading `+` is recommended but **not required**.\n * - If Without leading `+`, you must passing `defaultCountry`.\n * @throws **{@link TypeError | `TypeError`}** if `value` is not string, number, null or undefined.\n * @throws **{@link TypeError | `TypeError`}** if `options` is not an object or contains wrong types.\n * @param {ValueFormatPhoneNumber} value\n * ***Phone number to format, accepts:***\n * - `string` (recommended to preserve leading zeros).\n * - `number` (leading zeros will be lost).\n * - `null` or `undefined` (returns empty string).\n * @param {FormatPhoneNumberMain} [options]\n * ***Main options object controlling:***\n * - `separator` (**string**): Group separator, default `\" \"`.\n * - `plusNumberCountry` (**string**): Country code with optional leading `+`.\n * - `openingNumberCountry` (**string**): Characters before the country code, e.g. `\"(\"`.\n * - `closingNumberCountry` (**string**): Characters after the country code, e.g. `\")\"`.\n * - `checkValidOnly` (**boolean**): Return only validity.\n * - `takeNumberOnly` (**boolean**): Return digits only.\n * - `defaultCountry` (**string** - **`<ISO-3166-1 alpha-2>`**): Used to interpret numbers without an explicit `+<countryCode>`.\n * @returns {string|boolean} Formatted phone number string, digits-only string, or boolean.\n * @overload\n * @param {ValueFormatPhoneNumber} value The phone number input (string or number).\n * @param {FormatPhoneNumberCheckValidOnly} [options] With `checkValidOnly: true`.\n * Return a **validity-check mode** when `checkValidOnly: true`.\n * @returns {boolean} A boolean indicating whether the input is a valid phone number.\n * @overload\n * @param {ValueFormatPhoneNumber} value The phone number input (string or number).\n * @param {FormatPhoneNumberTransform} [options] With `takeNumberOnly: true`.\n * Return **digits-only mode** when `takeNumberOnly: true`.\n * @returns {string} A string of digits only.\n * @overload\n * @param {ValueFormatPhoneNumber} value The phone number input (string or number).\n * @param {FormatPhoneNumberTakeNumberOnly} [options] Options to customize format output (country code, separator, etc).\n * Return a **formatted phone number string** with custom formatting and (`checkValidOnly: false`, `takeNumberOnly: false`).\n * @returns {string} Formatting number. return a string of digits only with formatter.\n * @example\n * 1. ***Formatting Phone Number String:***\n * ```ts\n * formatPhoneNumber(\"081234567890\");\n * // ➔ \"0812 3456 7890\"\n * formatPhoneNumber(\"081234567890\", {\n * separator: \"-\",\n * plusNumberCountry: \"+44\",\n * openingNumberCountry: \"(\",\n * closingNumberCountry: \")\"\n * });\n * // ➔ \"(+44) 8123-4567-890\"\n * ```\n * 2. ***Digits-Only Mode:***\n * ```ts\n * formatPhoneNumber(\"(0812) 3456-7890\", {\n * takeNumberOnly: true,\n * defaultCountry: \"ID\"\n * });\n * // ➔ \"081234567890\"\n * formatPhoneNumber(\"(0812) 3456-7890\", { takeNumberOnly: true });\n * // ➔ \"\"\n * formatPhoneNumber(\"(63) 917 123 4567\", {\n * takeNumberOnly: true,\n * defaultCountry: \"PH\"\n * });\n * // ➔ \"0917 123 4567\"\n * formatPhoneNumber(\"(63) 4567-8901\", {\n * takeNumberOnly: true,\n * defaultCountry: \"PH\"\n * });\n * // ➔ \"\" // is not valid number from PH.\n * formatPhoneNumber(\"(63) 917 123 4567\", { takeNumberOnly: true });\n * // ➔ \"\"\n * formatPhoneNumber(\"49 (151) 2345 6789\", {\n * takeNumberOnly: true,\n * defaultCountry: \"DE\"\n * });\n * // ➔ \"015123456789\"\n * formatPhoneNumber(\"49 (151) 2345 6789\", { takeNumberOnly: true });\n * // ➔ \"\"\n * ```\n * 3. ***Validity-Check Mode:***\n * ```ts\n * formatPhoneNumber(\"+6281234567890\", { checkValidOnly: true });\n * // ➔ true\n * formatPhoneNumber(\"0812-3456-7890\", {\n * checkValidOnly: true,\n * defaultCountry: \"ID\"\n * });\n * // ➔ true\n * formatPhoneNumber(\"0812 3456 7890\", { checkValidOnly: true });\n * // ➔ false\n * formatPhoneNumber(\"(0812) 3456-7890\", {\n * checkValidOnly: true,\n * defaultCountry: \"ID\"\n * });\n * // ➔ true\n * formatPhoneNumber(\"(0812) 3456-7890\", { checkValidOnly: true});\n * // ➔ false\n * formatPhoneNumber(\"+44 20 7946 0958\", { checkValidOnly: true });\n * // ➔ true\n * formatPhoneNumber(\"+1 (800) 123-4567\", { checkValidOnly: true });\n * // ➔ true\n * formatPhoneNumber(\"+62.812.3456.7890\", { checkValidOnly: true });\n * // ➔ true\n * formatPhoneNumber(\"+62(812)3456-7890\", { checkValidOnly: true });\n * // ➔ true\n * formatPhoneNumber(\"+62abc123\", { checkValidOnly: true });\n * // ➔ false\n * formatPhoneNumber(\"invalid@@@\", { checkValidOnly: true });\n * // ➔ false\n * formatPhoneNumber(\"0812-3456-hello\", { checkValidOnly: true });\n * // ➔ false\n * ```\n */\nexport function formatPhoneNumber(\n value: ValueFormatPhoneNumber,\n options?: FormatPhoneNumberTransform\n): string;\n/** -------------------------------------------------------\n * * ***Utility: `formatPhoneNumber`.***\n * -------------------------------------------------------\n * **Formats a phone number into a customizable local or international style.**\n * - **Type:** ***`Digits-only Mode`.***\n * - **Can also:**\n * - Return only digits string when **digits-only mode** (`takeNumberOnly`).\n * - Return boolean when **validity-check mode** (`checkValidOnly`) using a\n * regex for international-style phone numbers:\n * - ***Valid if:***\n * - Only contains digits, optional leading `+`, spaces, parentheses `()`,\n * hyphens `-`, or dots `.`.\n * - Digits-only length < 16.\n * - **E.164 compliance:**\n * - Optional leading `+` is recommended but **not required**.\n * - If Without leading `+`, you must passing `defaultCountry`.\n * @throws **{@link TypeError | `TypeError`}** if `value` is not string, number, null or undefined.\n * @throws **{@link TypeError | `TypeError`}** if `options` is not an object or contains wrong types.\n * @param {ValueFormatPhoneNumber} value\n * Phone number to format. Accepts:\n * - `string` (recommended to preserve leading zeros)\n * - `number` (leading zeros will be lost)\n * - `null` or `undefined` (returns empty string).\n * @param {FormatPhoneNumberTakeNumberOnly} [options] Options to customize format output (country code, separator, etc).\n * @returns {string} Digits-only mode, return string a digits-only.\n * @example\n * ```ts\n * formatPhoneNumber(\"(0812) 3456-7890\", {\n * takeNumberOnly: true,\n * defaultCountry: \"ID\"\n * });\n * // ➔ \"081234567890\"\n * formatPhoneNumber(\"(0812) 3456-7890\", { takeNumberOnly: true });\n * // ➔ \"\"\n * formatPhoneNumber(\"(63) 917 123 4567\", {\n * takeNumberOnly: true,\n * defaultCountry: \"PH\"\n * });\n * // ➔ \"0917 123 4567\"\n * formatPhoneNumber(\"(63) 4567-8901\", {\n * takeNumberOnly: true,\n * defaultCountry: \"PH\"\n * });\n * // ➔ \"\" // is not valid number from PH.\n * formatPhoneNumber(\"(63) 917 123 4567\", { takeNumberOnly: true });\n * // ➔ \"\"\n * formatPhoneNumber(\"49 (151) 2345 6789\", {\n * takeNumberOnly: true,\n * defaultCountry: \"DE\"\n * });\n * // ➔ \"015123456789\"\n * formatPhoneNumber(\"49 (151) 2345 6789\", { takeNumberOnly: true });\n * // ➔ \"\"\n * ```\n */\nexport function formatPhoneNumber(\n value: ValueFormatPhoneNumber,\n options?: FormatPhoneNumberTakeNumberOnly\n): string;\n/** -------------------------------------------------------\n * * ***Utility: `formatPhoneNumber`.***\n * -------------------------------------------------------\n * **Formats a phone number into a customizable local or international style.**\n * - **Type:** ***`Validity-check Mode`.***\n * - **Can also:**\n * - Return only digits string when **digits-only mode** (`takeNumberOnly`).\n * - Return boolean when **validity-check mode** (`checkValidOnly`) using a\n * regex for international-style phone numbers:\n * - ***Valid if:***\n * - Only contains digits, optional leading `+`, spaces, parentheses `()`,\n * hyphens `-`, or dots `.`.\n * - Digits-only length < 16.\n * - **E.164 compliance:**\n * - Optional leading `+` is recommended but **not required**.\n * - If Without leading `+`, you must passing `defaultCountry`.\n * @throws **{@link TypeError | `TypeError`}** if `value` is not string, number, null or undefined.\n * @throws **{@link TypeError | `TypeError`}** if `options` is not an object or contains wrong types.\n * @param {ValueFormatPhoneNumber} value\n * Phone number to format. Accepts:\n * - `string` (recommended to preserve leading zeros).\n * - `number` (leading zeros will be lost).\n * - `null` or `undefined` (returns empty string).\n * @param {FormatPhoneNumberTakeNumberOnly} [options] Options to customize format output (country code, separator, etc).\n * @returns {boolean} Validity-check mode, return a boolean.\n * @example\n * ```ts\n * formatPhoneNumber(\"+6281234567890\", { checkValidOnly: true });\n * // ➔ true\n * formatPhoneNumber(\"0812-3456-7890\", {\n * checkValidOnly: true,\n * defaultCountry: \"ID\"\n * });\n * // ➔ true\n * formatPhoneNumber(\"0812 3456 7890\", { checkValidOnly: true });\n * // ➔ false\n * formatPhoneNumber(\"(0812) 3456-7890\", {\n * checkValidOnly: true,\n * defaultCountry: \"ID\"\n * });\n * // ➔ true\n * formatPhoneNumber(\"(0812) 3456-7890\", { checkValidOnly: true});\n * // ➔ false\n * formatPhoneNumber(\"+44 20 7946 0958\", { checkValidOnly: true });\n * // ➔ true\n * formatPhoneNumber(\"+1 (800) 123-4567\", { checkValidOnly: true });\n * // ➔ true\n * formatPhoneNumber(\"+62.812.3456.7890\", { checkValidOnly: true });\n * // ➔ true\n * formatPhoneNumber(\"+62(812)3456-7890\", { checkValidOnly: true });\n * // ➔ true\n * formatPhoneNumber(\"+62abc123\", { checkValidOnly: true });\n * // ➔ false\n * formatPhoneNumber(\"invalid@@@\", { checkValidOnly: true });\n * // ➔ false\n * formatPhoneNumber(\"0812-3456-hello\", { checkValidOnly: true });\n * // ➔ false\n * ```\n */\nexport function formatPhoneNumber(\n value: ValueFormatPhoneNumber,\n options?: FormatPhoneNumberCheckValidOnly\n): boolean;\n/** -------------------------------------------------------\n * * ***Utility: `formatPhoneNumber`.***\n * -------------------------------------------------------\n * **Formats a phone number into a customizable local or international style.**\n * - **Type:** ***Forced to `Validity-check Mode`***, because `checkValidOnly` has set to `true`.\n * - **Can also:**\n * - Return only digits string when **digits-only mode** (`takeNumberOnly`).\n * - Return boolean when **validity-check mode** (`checkValidOnly`) using a\n * regex for international-style phone numbers:\n * - ***Valid if:***\n * - Only contains digits, optional leading `+`, spaces, parentheses `()`,\n * hyphens `-`, or dots `.`.\n * - Digits-only length < 16.\n * - **E.164 compliance:**\n * - Optional leading `+` is recommended but **not required**.\n * - If Without leading `+`, you must passing `defaultCountry`.\n * @throws **{@link TypeError | `TypeError`}** if `value` is not string, number, null or undefined.\n * @throws **{@link TypeError | `TypeError`}** if `options` is not an object or contains wrong types.\n * @param {ValueFormatPhoneNumber} value\n * Phone number to format. Accepts:\n * - `string` (recommended to preserve leading zeros).\n * - `number` (leading zeros will be lost).\n * - `null` or `undefined` (returns empty string).\n * @param {FormatPhoneNumberTakeNumberOnly} [options] Options to customize format output (country code, separator, etc).\n * @returns {boolean} Validity-check mode, return a boolean.\n * @example\n * ```ts\n * formatPhoneNumber(\"+6281234567890\", {\n * // Formatting Phone Number Options\n * separator: \"-\",\n * // Validity-check Mode\n * checkValidOnly: true,\n * });\n * // ➔ true\n * formatPhoneNumber(\"0812-3456-7890\", {\n * defaultCountry: \"ID\",\n * // Formatting Phone Number Options\n * separator: \"-\",\n * // Validity-check Mode\n * checkValidOnly: true,\n * });\n * // ➔ true\n * formatPhoneNumber(\"0812 3456 7890\", {\n * // Formatting Phone Number Options\n * separator: \"-\",\n * // Validity-check Mode\n * checkValidOnly: true,\n * });\n * // ➔ false\n * formatPhoneNumber(\"(0812) 3456-7890\", {\n * defaultCountry: \"ID\",\n * // Formatting Phone Number Options\n * separator: \"-\",\n * // Validity-check Mode\n * checkValidOnly: true,\n * });\n * // ➔ true\n * formatPhoneNumber(\"(0812) 3456-7890\", {\n * // Formatting Phone Number Options\n * separator: \"-\",\n * // Validity-check Mode\n * checkValidOnly: true\n * });\n * // ➔ false\n * formatPhoneNumber(\"+44 20 7946 0958\", {\n * // Formatting Phone Number Options\n * separator: \"-\",\n * // Validity-check Mode\n * checkValidOnly: true\n * });\n * // ➔ true\n * formatPhoneNumber(\"+1 (800) 123-4567\", {\n * // Formatting Phone Number Options\n * separator: \"-\",\n * // Validity-check Mode\n * checkValidOnly: true\n * });\n * // ➔ true\n * formatPhoneNumber(\"+62.812.3456.7890\", {\n * // Formatting Phone Number Options\n * separator: \"-\",\n * // Validity-check Mode\n * checkValidOnly: true\n * });\n * // ➔ true\n * formatPhoneNumber(\"+62(812)3456-7890\", {\n * // Formatting Phone Number Options\n * separator: \"-\",\n * // Validity-check Mode\n * checkValidOnly: true\n * });\n * // ➔ true\n * formatPhoneNumber(\"+62abc123\", {\n * // Formatting Phone Number Options\n * separator: \"-\",\n * // Validity-check Mode\n * checkValidOnly: true\n * });\n * // ➔ false\n * formatPhoneNumber(\"invalid@@@\", {\n * // Formatting Phone Number Options\n * separator: \"-\",\n * // Validity-check Mode\n * checkValidOnly: true\n * });\n * // ➔ false\n * formatPhoneNumber(\"0812-3456-hello\", {\n * // Formatting Phone Number Options\n * separator: \"-\",\n * // Validity-check Mode\n * checkValidOnly: true\n * });\n * // ➔ false\n * ```\n */\nexport function formatPhoneNumber(\n value: ValueFormatPhoneNumber,\n options?: FormatPhoneNumberAllPassingValidOnly\n): boolean;\n/** -------------------------------------------------------\n * * ***Utility: `formatPhoneNumber`.***\n * -------------------------------------------------------\n * **Formats a phone number into a customizable local or international style.**\n * - **Type:** ***Forced to `Digits-only Mode`***, because `takeNumberOnly` has set to `true`.\n * - **Can also:**\n * - Return only digits string when **digits-only mode** (`takeNumberOnly`).\n * - Return boolean when **validity-check mode** (`checkValidOnly`) using a\n * regex for international-style phone numbers:\n * - ***Valid if:***\n * - Only contains digits, optional leading `+`, spaces, parentheses `()`,\n * hyphens `-`, or dots `.`.\n * - Digits-only length < 16.\n * - **E.164 compliance:**\n * - Optional leading `+` is recommended but **not required**.\n * - If Without leading `+`, you must passing `defaultCountry`.\n * @throws **{@link TypeError | `TypeError`}** if `value` is not string, number, null or undefined.\n * @throws **{@link TypeError | `TypeError`}** if `options` is not an object or contains wrong types.\n * @param {ValueFormatPhoneNumber} value\n * Phone number to format. Accepts:\n * - `string` (recommended to preserve leading zeros)\n * - `number` (leading zeros will be lost)\n * - `null` or `undefined` (returns empty string).\n * @param {FormatPhoneNumberTakeNumberOnly} [options] Options to customize format output (country code, separator, etc).\n * @returns {string} Digits-only mode, return string a digits-only.\n * @example\n * ```ts\n * formatPhoneNumber(\"(0812) 3456-7890\", {\n * defaultCountry: \"ID\",\n * // Formatting Phone Number Options\n * separator: \"-\",\n * // Digits-only Mode\n * takeNumberOnly: true,\n * });\n * // ➔ \"081234567890\"\n * formatPhoneNumber(\"(0812) 3456-7890\", {\n * // Formatting Phone Number Options\n * separator: \"-\",\n * // Digits-only Mode\n * takeNumberOnly: true,\n * });\n * // ➔ \"\"\n * formatPhoneNumber(\"(63) 917 123 4567\", {\n * defaultCountry: \"PH\",\n * // Formatting Phone Number Options\n * separator: \"-\",\n * // Digits-only Mode\n * takeNumberOnly: true,\n * });\n * // ➔ \"0917 123 4567\"\n * formatPhoneNumber(\"(63) 4567-8901\", {\n * defaultCountry: \"PH\",\n * // Formatting Phone Number Options\n * separator: \"-\",\n * // Digits-only Mode\n * takeNumberOnly: true,\n * });\n * // ➔ \"\" // is not valid number from PH.\n * formatPhoneNumber(\"(63) 917 123 4567\", { takeNumberOnly: true });\n * // ➔ \"\"\n * formatPhoneNumber(\"49 (151) 2345 6789\", {\n * defaultCountry: \"DE\",\n * // Formatting Phone Number Options\n * separator: \"-\",\n * // Digits-only Mode\n * takeNumberOnly: true,\n * });\n * // ➔ \"015123456789\"\n * formatPhoneNumber(\"49 (151) 2345 6789\", {\n * // Formatting Phone Number Options\n * separator: \"-\",\n * // Digits-only Mode\n * takeNumberOnly: true,\n * });\n * // ➔ \"\"\n * ```\n */\nexport function formatPhoneNumber(\n value: ValueFormatPhoneNumber,\n options?: FormatPhoneNumberAllPassingTakeOnly\n): string;\n/** -------------------------------------------------------\n * * ***Utility: `formatPhoneNumber`.***\n * -------------------------------------------------------\n * **Formats a phone number into a customizable local or international style.**\n * - **Type:** ***Forced to `Validity-check Mode`***, because `checkValidOnly` and `takeNumberOnly` has set to `true`,\n * but `checkValidOnly` will prioritize one.\n * - **Can also:**\n * - Return only digits string when **digits-only mode** (`takeNumberOnly`).\n * - Return boolean when **validity-check mode** (`checkValidOnly`) using a\n * regex for international-style phone numbers:\n * - ***Valid if:***\n * - Only contains digits, optional leading `+`, spaces, parentheses `()`,\n * hyphens `-`, or dots `.`.\n * - Digits-only length < 16.\n * - **E.164 compliance:**\n * - Optional leading `+` is recommended but **not required**.\n * - If Without leading `+`, you must passing `defaultCountry`.\n * @throws **{@link TypeError | `TypeError`}** if `value` is not string, number, null or undefined.\n * @throws **{@link TypeError | `TypeError`}** if `options` is not an object or contains wrong types.\n * @param {ValueFormatPhoneNumber} value\n * Phone number to format. Accepts:\n * - `string` (recommended to preserve leading zeros).\n * - `number` (leading zeros will be lost).\n * - `null` or `undefined` (returns empty string).\n * @param {FormatPhoneNumberTakeNumberOnly} [options] Options to customize format output (country code, separator, etc).\n * @returns {boolean} Validity-check mode, return a boolean.\n * @example\n * ```ts\n * formatPhoneNumber(\"+6281234567890\", {\n * // Formatting Phone Number Options\n * separator: \"-\",\n * // Validity-check Mode\n * checkValidOnly: true,\n * // Digits-only Mode\n * takeNumberOnly: true,\n * });\n * // ➔ true\n * formatPhoneNumber(\"0812-3456-7890\", {\n * defaultCountry: \"ID\",\n * // Formatting Phone Number Options\n * separator: \"-\",\n * // Validity-check Mode\n * checkValidOnly: true,\n * // Digits-only Mode\n * takeNumberOnly: true,\n * });\n * // ➔ true\n * formatPhoneNumber(\"0812 3456 7890\", {\n * // Formatting Phone Number Options\n * separator: \"-\",\n * // Validity-check Mode\n * checkValidOnly: true,\n * // Digits-only Mode\n * takeNumberOnly: true,\n * });\n * // ➔ false\n * formatPhoneNumber(\"(0812) 3456-7890\", {\n * defaultCountry: \"ID\",\n * // Formatting Phone Number Options\n * separator: \"-\",\n * // Validity-check Mode\n * checkValidOnly: true,\n * // Digits-only Mode\n * takeNumberOnly: true,\n * });\n * // ➔ true\n * formatPhoneNumber(\"(0812) 3456-7890\", {\n * // Formatting Phone Number Options\n * separator: \"-\",\n * // Validity-check Mode\n * checkValidOnly: true,\n * // Digits-only Mode\n * takeNumberOnly: true,\n * });\n * // ➔ false\n * formatPhoneNumber(\"+44 20 7946 0958\", {\n * // Formatting Phone Number Options\n * separator: \"-\",\n * // Validity-check Mode\n * checkValidOnly: true,\n * // Digits-only Mode\n * takeNumberOnly: true,\n * });\n * // ➔ true\n * formatPhoneNumber(\"+1 (800) 123-4567\", {\n * // Formatting Phone Number Options\n * separator: \"-\",\n * // Validity-check Mode\n * checkValidOnly: true,\n * // Digits-only Mode\n * takeNumberOnly: true,\n * });\n * // ➔ true\n * formatPhoneNumber(\"+62.812.3456.7890\", {\n * // Formatting Phone Number Options\n * separator: \"-\",\n * // Validity-check Mode\n * checkValidOnly: true,\n * // Digits-only Mode\n * takeNumberOnly: true,\n * });\n * // ➔ true\n * formatPhoneNumber(\"+62(812)3456-7890\", {\n * // Formatting Phone Number Options\n * separator: \"-\",\n * // Validity-check Mode\n * checkValidOnly: true,\n * // Digits-only Mode\n * takeNumberOnly: true,\n * });\n * // ➔ true\n * formatPhoneNumber(\"+62abc123\", {\n * // Formatting Phone Number Options\n * separator: \"-\",\n * // Validity-check Mode\n * checkValidOnly: true,\n * // Digits-only Mode\n * takeNumberOnly: true,\n * });\n * // ➔ false\n * formatPhoneNumber(\"invalid@@@\", {\n * // Formatting Phone Number Options\n * separator: \"-\",\n * // Validity-check Mode\n * checkValidOnly: true,\n * // Digits-only Mode\n * takeNumberOnly: true,\n * });\n * // ➔ false\n * formatPhoneNumber(\"0812-3456-hello\", {\n * // Formatting Phone Number Options\n * separator: \"-\",\n * // Validity-check Mode\n * checkValidOnly: true,\n * // Digits-only Mode\n * takeNumberOnly: true,\n * });\n * // ➔ false\n * ```\n */\nexport function formatPhoneNumber(\n value: ValueFormatPhoneNumber,\n options?: FormatPhoneNumberAllPassing\n): boolean;\nexport function formatPhoneNumber(\n value: ValueFormatPhoneNumber,\n options: FormatPhoneNumberMain = {}\n): string | boolean {\n if (isNil(value)) return \"\";\n\n if (!isString(value) && !isNumber(value)) {\n throw new TypeError(\n `First parameter (\\`value\\`) must be of type \\`string\\`, \\`number\\`, \\`null\\` or \\`undefined\\`, but received: \\`${getPreciseType(\n value\n )}\\`.`\n );\n }\n\n assertIsPlainObject(options, {\n message: ({ currentType, validType }) =>\n `Second parameter (\\`options\\`) must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n const takeNumberOnly = hasOwnProp(options, \"takeNumberOnly\")\n ? options.takeNumberOnly\n : false;\n const checkValidOnly = hasOwnProp(options, \"checkValidOnly\")\n ? options.checkValidOnly\n : false;\n const defaultCountry: typeof options.defaultCountry = hasOwnProp(\n options,\n \"defaultCountry\"\n )\n ? options.defaultCountry\n : undefined;\n\n const separator = hasOwnProp(options, \"separator\") ? options.separator : \" \";\n const prependPlusCountryCode = hasOwnProp(options, \"prependPlusCountryCode\")\n ? options.prependPlusCountryCode\n : true;\n const outputFormat: OutputFormat = hasOwnProp(options, \"outputFormat\")\n ? options.outputFormat\n : \"INTERNATIONAL\";\n const openingNumberCountry = hasOwnProp(options, \"openingNumberCountry\")\n ? options.openingNumberCountry\n : \"\";\n const closingNumberCountry = hasOwnProp(options, \"closingNumberCountry\")\n ? options.closingNumberCountry\n : \"\";\n\n if (\n !isBoolean(takeNumberOnly) ||\n !isBoolean(checkValidOnly) ||\n !isBoolean(prependPlusCountryCode)\n ) {\n throw new TypeError(\n `Parameter \\`takeNumberOnly\\`, \\`checkValidOnly\\` and \\`prependPlusCountryCode\\` property of the \\`options\\` (second parameter) must be of type \\`boolean\\` or unset as \\`undefined\\` value, but received: ['takeNumberOnly': \\`${getPreciseType(\n takeNumberOnly\n )}\\`, 'checkValidOnly': \\`${getPreciseType(\n checkValidOnly\n )}\\`, 'prependPlusCountryCode': \\`${getPreciseType(prependPlusCountryCode)}\\`].`\n );\n }\n\n if (!isUndefined(defaultCountry) && !isSupportedCountry(defaultCountry)) {\n throw new TypeError(\n `Parameter \\`defaultCountry\\` property of the \\`options\\` (second parameter) must be of type \\`string\\` as \\`CountryCode\\` (ISO-3166-1 alpha-2) or unset as \\`undefined\\` value, but received: \\`${getPreciseType(\n defaultCountry\n )}\\`, with value: \\`${safeStableStringify(defaultCountry, {\n keepUndefined: true\n })}\\`.\\n\\nSee: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements, for all ISO 3166-1 alpha-2 code.`\n );\n }\n\n if (\n ![\"INTERNATIONAL\", \"NATIONAL\", \"RFC3966\", \"E.164\"].includes(outputFormat)\n ) {\n throw new TypeError(\n `Parameter \\`outputFormat\\` property of the \\`options\\` (second parameter) must be of type \\`string\\` as \\`OutputFormat\\` (\"NATIONAL\" | \"INTERNATIONAL\" | \"E.164\" | \"RFC3966\") or unset as \\`undefined\\` (default value to: \\`INTERNATIONAL\\`) value, but received: \\`${getPreciseType(\n outputFormat\n )}\\`, with value: ${safeStableStringify(outputFormat, { keepUndefined: true })}.`\n );\n }\n\n if (\n !isString(separator) ||\n !isString(openingNumberCountry) ||\n !isString(closingNumberCountry)\n ) {\n throw new TypeError(\n `Parameter \\`separator\\`, \\`plusNumberCountry\\`, \\`openingNumberCountry\\` and \\`closingNumberCountry\\` property of the \\`options\\` (second parameter) must be of type \\`string\\` or unset as \\`undefined\\` value, but received: ['separator': \\`${getPreciseType(\n separator\n )}\\`,'openingNumberCountry': \\`${getPreciseType(\n openingNumberCountry\n )}\\`, 'closingNumberCountry': \\`${getPreciseType(closingNumberCountry)}\\`].`\n );\n }\n\n if (!isString(value)) value = String(value);\n\n const parsedPhoneNumber = parsingAsYouType(value, defaultCountry);\n const validPhoneNumber = isValidParseAsYouType(parsedPhoneNumber);\n\n if (checkValidOnly) return validPhoneNumber;\n\n // todo: return empty-string is invalid phone-number input.\n if (!validPhoneNumber) return \"\";\n\n if (takeNumberOnly) {\n return parsedPhoneNumber.getNumber().formatNational().replace(/\\D/g, \"\");\n }\n\n const num = parsedPhoneNumber.getNumber();\n // Result example: \"+49 1512 3456789\"\n const intlNumb = num.format(outputFormat);\n\n if (outputFormat === \"INTERNATIONAL\") {\n // Split to: [\"+49\", \"1512\", \"3456789\"]\n const [cc, ...rest] = intlNumb.split(\" \");\n const countryCode = prependPlusCountryCode ? cc : cc?.replace(/^\\++/, \"\");\n const restWithSeparator = rest.join(separator);\n\n if (!countryCode) return restWithSeparator;\n\n if (\n isNonEmptyString(openingNumberCountry) &&\n isNonEmptyString(closingNumberCountry)\n ) {\n return `${openingNumberCountry}${countryCode}${closingNumberCountry} ${restWithSeparator}`;\n }\n\n return `${countryCode} ${restWithSeparator}`;\n }\n\n if (outputFormat === \"NATIONAL\") {\n const restWithSeparator = intlNumb.split(\" \").join(separator);\n\n return `${restWithSeparator}`;\n }\n\n return intlNumb;\n}\n","// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type { censorEmail } from \"../censorEmail\";\nimport { isUndefined } from \"@/predicates/is/isUndefined\";\n\n/** ***Util helper for {@link censorEmail}.***\n *\n * @internal\n */\nexport const hashSeedGenerate = (mode: \"random\" | \"fixed\", email: string) => {\n const generateSeed = () => {\n let hash = 0;\n for (let i = 0; i < email.length; i++) {\n hash = (hash << 5) - hash + email.charCodeAt(i);\n hash |= 0; // Convert to 32bit int\n }\n return Math.abs(hash);\n };\n\n return mode === \"fixed\" ? generateSeed() : undefined;\n};\n\n/** ----------------------------------------------------------\n * * ***Internal Randomly replaces characters in a string with \"\\*\".***\n * ----------------------------------------------------------\n *\n * @param {string} str - The string to censor.\n * @param {number} minCensor - Minimum number of characters to censor.\n * @param {number} maxPercentage - Maximum percentage of characters to censor.\n * @returns {string} - Censored string.\n *\n * @internal ***Util helper for {@link censorEmail}.***\n */\nexport const _censor = (\n str: string,\n minCensor: number,\n maxPercentage: number,\n hashSeed: number | undefined\n): string => {\n if (str.length <= minCensor) return \"*\".repeat(str.length);\n\n const strArr = str.split(\"\");\n const totalCensor = Math.max(\n minCensor,\n Math.ceil(str.length * maxPercentage)\n );\n const indexes = new Set<number>();\n\n let i = 0;\n while (indexes.size < totalCensor) {\n const idx = !isUndefined(hashSeed)\n ? (hashSeed + str.length + i * 31) % str.length\n : Math.floor(Math.random() * str.length);\n indexes.add(idx);\n i++;\n }\n\n for (const index of indexes) {\n strArr[index] = \"*\";\n }\n\n return strArr.join(\"\");\n};\n","import { hasOwnProp } from \"@/predicates/has/hasOwnProp\";\nimport { getPreciseType } from \"@/predicates/type/getPreciseType\";\nimport { isNonEmptyString } from \"@/predicates/is/isNonEmptyString\";\n\nimport { assertIsPlainObject } from \"@/assertions/objects/assertIsPlainObject\";\nimport { safeStableStringify } from \"@/conversions/stringify/safeStableStringify\";\nimport { _censor, hashSeedGenerate } from \"./_private/censorEmail.utils\";\n\ntype CensorEmailOptions = {\n /** ----------------------------------------------------------\n * * ***Censorship Mode.***\n * ----------------------------------------------------------\n * - **Valid value:**\n * - `\"fixed\"` (default) – Deterministic censorship based on a hash of the email, same input always produces the same output.\n * - `\"random\"` – Each character is randomly replaced every time the function is called.\n */\n mode?: \"random\" | \"fixed\";\n};\n\n/** ----------------------------------------------------------\n * * ***Utility: `censorEmail`.***\n * ----------------------------------------------------------\n * **Censors an email by replacing characters with `\"*\"` while supporting random or fixed mode.**\n * - **This function replaces parts of an email with asterisks to protect privacy.**\n * - **Modes:**\n * - `\"fixed\"` (default) – Deterministic censorship based on a hash of the email, same input always produces the same output.\n * - `\"random\"` – Each character is randomly replaced every time the function is called.\n * - **ℹ️ Note:**\n * - Invalid emails or non-string input will return an empty-string (`\"\"`).\n * @param {string | null | undefined} email - The email address to censor.\n * @param {CensorEmailOptions} [options={}] - Options object for mode.\n * @returns {string} The censored email, or an empty string if input is invalid.\n * @throws **{@link TypeError | `TypeError`}** if `options` is not a plain object or `mode` is invalid.\n * @example\n * // Fixed mode (default, deterministic)\n * censorEmail(\"john.doe@gmail.com\");\n * // ➔ \"j**n.**e@g***l.com\"\n *\n * // Fixed mode explicitly\n * censorEmail(\"john.doe@gmail.com\", { mode: \"fixed\" });\n * // ➔ \"j**n.**e@g***l.com\"\n *\n * // Random mode (output may vary each time)\n * censorEmail(\"john.doe@gmail.com\", { mode: \"random\" });\n * // ➔ \"j*hn.***e@g***l.com\" (random)\n *\n * // Invalid email returns empty string\n * censorEmail(\"invalid-email\");\n * // ➔ \"\"\n */\nexport const censorEmail = (\n email: string | null | undefined,\n options: CensorEmailOptions = {}\n): string => {\n if (!isNonEmptyString(email)) return \"\";\n\n assertIsPlainObject(options, {\n message: ({ currentType, validType }) =>\n `Second parameter (\\`options\\`) must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n const mode = hasOwnProp(options, \"mode\") ? options.mode : \"fixed\";\n\n // Ensure mode is either \"random\" or \"fixed\"\n if (mode !== \"random\" && mode !== \"fixed\") {\n throw new TypeError(\n `Parameter \\`mode\\` property of the \\`options\\` (second parameter) must be one of \"fixed\" or \"random\", but received: \\`${getPreciseType(\n mode\n )}\\`, with value: \\`${safeStableStringify(mode, {\n keepUndefined: true\n })}\\`.`\n );\n }\n\n // Strict email validation regex\n const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/;\n if (!emailRegex.test(email)) return \"\";\n\n const [local, domain] = email.split(\"@\");\n const domainParts = domain?.split(\".\"); // Handle multi-level domain (e.g., example.co.uk)\n if (!local || !domainParts || domainParts.length < 2) return \"\"; // Invalid domain structure\n\n const [domainName, ...tldParts] = domainParts;\n\n if (!domainName) return \"\";\n\n const tld = tldParts.join(\".\");\n\n const hashSeed = hashSeedGenerate(mode, email);\n\n const localMinCensor = local.length < 4 ? 1 : 2;\n const domainMinCensor = domainName.length < 4 ? 1 : 2;\n\n const censoredLocal = _censor(local, localMinCensor, 0.6, hashSeed);\n const censoredDomain = _censor(domainName, domainMinCensor, 0.5, hashSeed);\n const censoredTLD = tld.length <= 2 ? tld : _censor(tld, 1, 0.4, hashSeed);\n\n return `${censoredLocal}@${censoredDomain}.${censoredTLD}`;\n};\n","import { isNil } from \"@/predicates/is/isNil\";\nimport { isInteger } from \"@/predicates/is/isInteger\";\nimport { hasOwnProp } from \"@/predicates/has/hasOwnProp\";\nimport { getPreciseType } from \"@/predicates/type/getPreciseType\";\n\nimport { assertIsString } from \"@/assertions/strings/assertIsString\";\nimport { assertIsBoolean } from \"@/assertions/booleans/assertIsBoolean\";\nimport { assertIsPlainObject } from \"@/assertions/objects/assertIsPlainObject\";\n\nimport { normalizeSpaces } from \"@/strings/sanitizations/normalizeSpaces\";\nimport { safeStableStringify } from \"@/conversions/stringify/safeStableStringify\";\n\ntype ChunkStringOptions = {\n /** ***The separator string to insert between characters or words.***\n *\n * - Used when inserting separators every `limiter` characters.\n * - Default is a single space `\" \"`.\n *\n * @default \" \"\n */\n separator?: string;\n\n /** ***Determines whether counting for `limiter` resets after each space.***\n *\n * - If `true`, the string is treated as words separated by spaces,\n * and separators are applied within words, then words are grouped.\n * - If `false` ***(default)***, counting is continuous across the whole string,\n * treating spaces as normal characters.\n *\n * @default false\n */\n reCountAfterSpace?: boolean;\n};\n\n/** ----------------------------------------------\n * * ***Utility: `chunkString`.***\n * ----------------------------------------------\n * **Chunks a string by inserting a separator every `limiter` characters.**\n * - **This function handles two main behaviors based on `reCountAfterSpace`:**\n * 1. ***If `reCountAfterSpace` is `false` (default):***\n * - The separator is inserted strictly every `limiter` characters throughout the entire string, regardless of spaces, spaces are treated as regular characters in the count.\n * - Example: `chunkString(\"1234567890\", 3, \"-\")` ➔ `\"123-456-789-0\"`.\n * - Example: `chunkString(\"Hello World\", 3, \"-\")` ➔ `\"Hel-lo -Wor-ld\"`.\n * 2. ***If `reCountAfterSpace` is `true`:***\n * - The function first processes the input string to replace any multiple consecutive spaces with a\n * single space (e.g., \"A B\" becomes \"A B\").\n * Then, it treats the string as a sequence of \"words\" (segments separated by single spaces).\n * - Each word is processed independently:\n * - if a word's length exceeds the `limiter`, separators are inserted internally within that word.\n * - Words are then grouped. Each group will contain `limiter` number of words.\n * - Words within the same group are joined by the specified `separator`.\n * - Finally, these groups are joined by a single space, preserving the original word separation\n * structure between groups.\n * @param {string} subject - ***The target string to chunk.****\n * @param {number} limiter\n * ***The interval (number of characters) for inserting separators, behavior:***\n * - If `reCountAfterSpace = false`, it counts characters.\n * - If `reCountAfterSpace = true`, it counts both characters within words and words per group.\n * @param {ChunkStringOptions} [options={}] - ***Optional settings for separator and counting behavior.***\n * @returns {string} Return the formatted string with separators.\n * @example\n * // Basic usage\n * chunkString(\"1234567890\", 3);\n * // ➔ \"123 456 789 0\"\n *\n * // Basic usage `reCountAfterSpace = false` (default)\n * chunkString(\"1234567890\", 3, { separator: \"-\");\n * // ➔ \"123-456-789-0\"\n * chunkString(\"HelloWorld\", 2, { separator: \"_\", reCountAfterSpace: false });\n * // ➔ \"He_ll_oW_or_ld\"\n *\n * // Usage with reCountAfterSpace = true:\n * // Multiple spaces are normalized to single spaces before processing.\n * chunkString(\"AB CD EF GH\", 2, { separator: \"-\", reCountAfterSpace: true });\n * // ➔ \"AB-CD EF-GH\" (after normalization to \"AB CD EF GH\")\n * // Words \"AB\" and \"CD\" form a group and are joined by \"-\", \"EF\" and \"GH\" form another group.\n * // The groups \"AB-CD\" and \"EF-GH\" are then joined by a space.\n *\n * // Another usage with reCountAfterSpace = true:\n * chunkString(\"ABC DEF GHI JKL\", 3, { separator: \"-\", reCountAfterSpace: true });\n * // ➔ \"ABC-DEF-GHI JKL\"\n * // Words \"ABC\", \"DEF\", \"GHI\" form a group and are joined by \"-\".\n * // The word \"JKL\" forms its own group (as it's the last word and completes no other group).\n * // The groups \"ABC-DEF-GHI\" and \"JKL\" are then joined by a space.\n */\nexport function chunkString(\n subject: string,\n limiter: number,\n options: ChunkStringOptions = {}\n): string {\n if (isNil(subject) || limiter <= 0) return subject;\n\n assertIsString(subject, {\n message: ({ currentType, validType }) =>\n `First parameter (\\`subject\\`) must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n if (!isInteger(limiter)) {\n throw new TypeError(\n `Second parameter (\\`limiter\\`) must be of type \\`integer-number\\`, but received: \\`${getPreciseType(\n limiter\n )}\\`, with value: \\`${safeStableStringify(limiter, {\n keepUndefined: true\n })}\\`.`\n );\n }\n\n assertIsPlainObject(options, {\n message: ({ currentType, validType }) =>\n `Third parameter (\\`options\\`) must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n const separator = hasOwnProp(options, \"separator\") ? options.separator : \" \";\n const reCountAfterSpace = hasOwnProp(options, \"reCountAfterSpace\")\n ? options.reCountAfterSpace\n : false;\n\n assertIsString(separator, {\n message: ({ currentType, validType }) =>\n `Parameter \\`separator\\` property of the \\`options\\` (third parameter) must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n assertIsBoolean(reCountAfterSpace, {\n message: ({ currentType, validType }) =>\n `Parameter \\`reCountAfterSpace\\` property of the \\`options\\` (third parameter) must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n subject = normalizeSpaces(subject);\n\n // Handle reCountAfterSpace = false (assumed correct from previous iterations)\n if (!reCountAfterSpace) {\n let result = \"\";\n let currentCount = 0;\n\n for (let i = 0; i < subject.length; i++) {\n const char = subject[i];\n if (currentCount === limiter) {\n result += separator;\n currentCount = 0;\n }\n result += char;\n currentCount++;\n }\n return result;\n }\n\n // --- Dynamic Logic for reCountAfterSpace = true ---\n const words = subject.split(\" \"); // Split the string into individual words by spaces\n const finalSegments: string[] = [];\n\n let currentGroup: string[] = [];\n let wordsInCurrentGroupCount = 0; // This counts how many words are in the current group\n\n for (let i = 0; i < words.length; i++) {\n const word = words[i];\n\n // Check if the current word itself needs internal separators (e.g., \"HelloWorld\" with limiter 2)\n // For the given test cases (\"AB\", \"CD\", \"ABC\"), this inner loop doesn't add separators,\n // as the words themselves are shorter than or equal to the limiter.\n let processedWord = \"\";\n let charCountInWord = 0;\n\n if (word) {\n for (let j = 0; j < word.length; j++) {\n processedWord += word[j];\n charCountInWord++;\n if (charCountInWord === limiter && j < word.length - 1) {\n processedWord += separator;\n charCountInWord = 0;\n }\n }\n }\n\n currentGroup.push(processedWord);\n wordsInCurrentGroupCount++;\n\n // If the current group has reached the limiter (e.g., 2 words for limiter=2, or 3 words for limiter=3)\n // OR if it's the last word in the entire subject, finalize the group.\n if (wordsInCurrentGroupCount === limiter || i === words.length - 1) {\n finalSegments.push(currentGroup.join(separator)); // Join words within the group by separator\n currentGroup = []; // Reset group for the next set of words\n wordsInCurrentGroupCount = 0; // Reset group word count\n }\n }\n\n // Finally, join the main segments (groups) with spaces\n return finalSegments.join(\" \");\n}\n","import { isInteger } from \"@/predicates/is/isInteger\";\nimport { hasOwnProp } from \"@/predicates/has/hasOwnProp\";\nimport { isEmptyString } from \"@/predicates/is/isEmptyString\";\nimport { getPreciseType } from \"@/predicates/type/getPreciseType\";\nimport { isNonEmptyString } from \"@/predicates/is/isNonEmptyString\";\n\nimport { safeStableStringify } from \"@/conversions/stringify/safeStableStringify\";\n\nimport { assertIsString } from \"@/assertions/strings/assertIsString\";\nimport { assertIsBoolean } from \"@/assertions/booleans/assertIsBoolean\";\nimport { assertIsPlainObject } from \"@/assertions/objects/assertIsPlainObject\";\n\ntype TruncateStringOptions = {\n /** ***Maximum length of the truncated string **(default: `10`)**.***\n *\n * @default 10\n */\n length?: number;\n\n /** ***String to append if truncation occurs.***\n *\n * - Will be trimmed first; defaults to `\"...\"` if empty.\n *\n * @default \"...\"\n */\n ending?: string;\n\n /** ***Whether to trim the input string before truncation ***(default: `true`)***.***\n *\n * @default true\n */\n trim?: boolean;\n};\n\n/** ----------------------------------------------------------\n * * ***Utility: `truncateString`.***\n * ----------------------------------------------------------\n * **Features:**\n * - Truncates a string to a specified length and optionally appends an ending.\n * - Supports trimming the input before truncation.\n * - If truncation occurs, trailing spaces before the ending are removed.\n * - The `ending` parameter is always trimmed first; if empty, it defaults to `\"...\"`.\n * @param {string|null|undefined} text\n * ***The input string to truncate, behavior:***\n * - If `null`, `undefined`, or empty after trim, returns `\"\"`.\n * @param {TruncateStringOptions} [options]\n * ***Optional settings:***\n * - `length` (number, default 10): Maximum length of the truncated string.\n * - `ending` (string, default `\"...\"`): String to append if truncation occurs.\n * - `trim` (boolean, default `true`): Whether to trim the input before truncation.\n * @returns {string} The truncated string with optional trimming and ending, returns `\"\"` if input is empty or length < 1.\n * @throws **{@link TypeError | `TypeError`}** if `options.length` is not a finite number, or if `options.ending` is not a string, or if `options.trim` is not a boolean.\n * @example\n * truncateString(\"hello world\", { length: 5 });\n * // ➔ \"hello...\"\n * truncateString(\"hello world\", { length: 5, ending: \"---\" });\n * // ➔ \"hello---\"\n * truncateString(\"hello world\", { length: 5, ending: \" \" });\n * // ➔ \"hello...\" (ending trimmed to default)\n * truncateString(\"hello world\", { length: 5, ending: \" !!! \" });\n * // ➔ \"hello!!!\" (ending trimmed)\n * truncateString(\" long data string \", { length: 8, ending: \"...\", trim: true });\n * // ➔ \"long dat...\"\n * truncateString(\" long data string \", { length: 8, ending: \"...\", trim: false });\n * // ➔ \" long ...\"\n * truncateString(null, { length: 5 });\n * // ➔ \"\"\n */\nexport const truncateString = (\n text: string | null | undefined,\n options: TruncateStringOptions = {}\n): string => {\n if (!isNonEmptyString(text)) return \"\";\n\n assertIsPlainObject(options, {\n message: ({ currentType, validType }) =>\n `Seconds parameter (\\`options\\`) must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n const trim = hasOwnProp(options, \"trim\") ? options.trim : true;\n const length = hasOwnProp(options, \"length\") ? options.length : 10;\n let ending = hasOwnProp(options, \"ending\") ? options.ending : \"...\";\n\n if (!isInteger(length)) {\n throw new TypeError(\n `Parameter \\`length\\` property of the \\`options\\` (second parameter) must be of type \\`integer-number\\`, but received: \\`${getPreciseType(\n length\n )}\\`, with value: \\`${safeStableStringify(length, {\n keepUndefined: true\n })}\\`.`\n );\n }\n\n if (length < 1) return \"\";\n\n assertIsString(ending, {\n message: ({ currentType, validType }) =>\n `Parameter \\`ending\\` property of the \\`options\\` (second parameter) must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n assertIsBoolean(trim, {\n message: ({ currentType, validType }) =>\n `Parameter \\`trim\\` property of the \\`options\\` (second parameter) must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n if (isEmptyString(ending)) {\n ending = \"...\";\n } else {\n ending = ending.trim();\n }\n\n const original = trim ? text.trim() : text;\n const originalTrimmedLength = original.length;\n\n if (originalTrimmedLength <= length) return original;\n\n const sliced = original.slice(0, length);\n const cleanSliced = trim ? sliced : sliced.trimEnd();\n\n return cleanSliced + ending;\n};\n","import type { FormatDateFnsOptions } from \"./_private/formatDateFns.types\";\n\nimport { id, enUS } from \"date-fns/locale\";\nimport { format as formatDns, parse } from \"date-fns\";\n\nimport { isNaN } from \"@/predicates/is/isNaN\";\nimport { isNil } from \"@/predicates/is/isNil\";\nimport { isDate } from \"@/predicates/is/isDate\";\nimport { hasOwnProp } from \"@/predicates/has/hasOwnProp\";\nimport { isPlainObject } from \"@/predicates/is/isPlainObject\";\nimport { isNonEmptyString } from \"@/predicates/is/isNonEmptyString\";\n\n/** ----------------------------------------------------------\n * * ***Utility: `formatDateFns`.***\n * ----------------------------------------------------------\n * **Formats a date into a human-readable string using `date-fns`.**\n * - **Features:**\n * - Supports custom output formats using `date-fns/format`.\n * - Can parse localized non-ISO strings via `inputFormat` & `inputLocale`.\n * - Supports `locale` as `\"id\"`, `\"en\"` or `date-fns` `Locale` objects (like `id` or `enUS`).\n * - Returns `null` if the date is invalid, not provided, or parsing fails.\n * @param {string | Date | null | undefined} date\n * ***The date input to format, can be:***\n * - A `Date` object.\n * - An ISO string (e.g. `\"2024-01-01T12:00:00Z\"`).\n * - A localized string (requires `inputFormat` + `inputLocale`).\n * @param {FormatDateFnsOptions} [options] ***Options for formatting and parsing.***\n * @param {FormatDateFnsOptions[\"format\"]} [options.format=\"dd MMM yyyy - HH:mm:ss\"]\n * ***The output format string (passed to `date-fns/format`), e.g:***\n * - `\"dd MMMM yyyy, HH:mm:ss\" ➔ \"14 Juli 2025, 17:25:42\"`.\n * @param {FormatDateFnsOptions[\"locale\"]} [options.locale=\"id\"]\n * The output locale. If string, only `\"id\"` (Indonesian) or `\"en\"` (English)\n * is recognized. Or you can pass a `date-fns` `Locale` object.\n * - Example:\n * ```ts\n * import { ar } from \"date-fns/locale\";\n * formatDateFns(new Date(), { locale: ar, format: \"PPPppp\" });\n * ```\n * @param {FormatDateFnsOptions[\"inputLocale\"]} [options.inputLocale]\n * Required if `date` is a localized non-ISO string. Used with `inputFormat`.\n * - Example for Indonesian string:\n * ```ts\n * formatDateFns(\"14 Juli 2025 10:25:42\", { inputFormat: \"dd MMMM yyyy HH:mm:ss\", inputLocale: \"id\" });\n * ```\n * @param {FormatDateFnsOptions[\"inputFormat\"]} [options.inputFormat]\n * The format string to parse `date` if it is a non-ISO string.\n * Required together with `inputLocale`.\n * @returns {string | null} A formatted date string or `null` if input is invalid.\n * @example\n * formatDateFns(new Date());\n * // ➔ \"14 Jul 2025 - 17:25:42\"\n * formatDateFns(\"2025-07-14T10:25:42Z\", { format: \"dd/MM/yyyy\", locale: \"en\" });\n * // ➔ \"14/07/2025\"\n * formatDateFns(\"14 Juli 2025 10:25:42\", {\n * inputFormat: \"dd MMMM yyyy HH:mm:ss\",\n * inputLocale: \"id\",\n * format: \"yyyy-MM-dd\"\n * });\n * // ➔ \"2025-07-14\"\n * formatDateFns(null);\n * // ➔ null\n */\nexport const formatDateFns = (\n date: string | Date | null | undefined,\n options: FormatDateFnsOptions = {}\n): string | null => {\n if (isNil(date) || !(isDate(date) || isNonEmptyString(date))) return null;\n\n // Ensure options is an object and Defensive options check\n if (!isPlainObject(options)) {\n options = {};\n }\n\n const {\n inputFormat,\n locale = \"en\",\n inputLocale = \"en\",\n ...restOptions\n } = options;\n\n const format =\n hasOwnProp(options, \"format\") && isNonEmptyString(options.format)\n ? options.format\n : \"dd MMM yyyy - HH:mm:ss\";\n\n let parsedDate: Date;\n\n try {\n if (isNonEmptyString(date) && inputFormat && inputLocale) {\n const valueOfInputLocale = isNonEmptyString(inputLocale)\n ? inputLocale === \"id\"\n ? id\n : enUS\n : inputLocale;\n\n parsedDate = parse(date, inputFormat, new Date(), {\n locale: valueOfInputLocale\n });\n } else {\n parsedDate = new Date(date);\n }\n\n if (isNaN(parsedDate.getTime())) return null;\n\n const valueOfLocale = isNonEmptyString(locale)\n ? locale === \"id\"\n ? id\n : enUS\n : locale;\n\n return formatDns(parsedDate, format, {\n ...restOptions,\n locale: valueOfLocale\n });\n } catch {\n return null;\n }\n};\n","import type { FormatDateIntlOptions } from \"./_private/formatDateIntl.types\";\n\nimport { isNaN } from \"@/predicates/is/isNaN\";\nimport { isNil } from \"@/predicates/is/isNil\";\nimport { isDate } from \"@/predicates/is/isDate\";\nimport { isPlainObject } from \"@/predicates/is/isPlainObject\";\nimport { isNonEmptyString } from \"@/predicates/is/isNonEmptyString\";\n\n/** ----------------------------------------------------------\n * * ***Utility: `formatDateIntl`.***\n * ----------------------------------------------------------\n * **Formats a date using the `Intl.DateTimeFormat` API.**\n * - **Features:**\n * - Supports custom locales (type-safe `SupportedLocales`).\n * - Accepts additional `Intl.DateTimeFormatOptions` like `timeZone`, `hour12`, etc.\n * - Defaults to `\"en-US\"` if `locale` is not provided or is an empty string.\n * - Returns `null` if the date is invalid, not provided, or options are invalid.\n * @param {string | Date | null | undefined} date\n * ***The date to format.***\n * - Can be a `Date` object or an ISO string.\n * - If invalid or not provided, returns `null`.\n * @param {FormatDateIntlOptions} [options] ***Optional formatting options for `Intl.DateTimeFormat`, use `locale` to specify the language & region format.***\n * @returns {string | null}\n * - Formatted date string.\n * - Returns `null` if date is invalid or options are of wrong type.\n * @example\n * formatDateIntl(new Date());\n * // ➔ \"7/14/2025\"\n * formatDateIntl(\"2025-07-14T00:00:00Z\", { locale: \"fr-FR\", dateStyle: \"long\" });\n * // ➔ \"14 juillet 2025\"\n * formatDateIntl(null);\n * // ➔ null\n * formatDateIntl(new Date(), { timeZone: \"UTC\", hour: \"2-digit\", minute: \"2-digit\" });\n * // ➔ \"01:30 AM\"\n */\nexport const formatDateIntl = (\n date: string | Date | null | undefined,\n options?: FormatDateIntlOptions\n): string | null => {\n if (isNil(date) || !(isDate(date) || isNonEmptyString(date))) return null;\n\n const parsedDate = new Date(date);\n if (isNaN(parsedDate.getTime())) return null; // Handle invalid dates\n\n // Ensure options is an object and Defensive options check\n if (!isPlainObject(options)) {\n options = {};\n }\n\n const { locale = \"en-US\", ...restProps } = options;\n\n try {\n return new Intl.DateTimeFormat(\n isNonEmptyString(locale) ? locale.trim() : \"en-US\",\n restProps\n ).format(parsedDate);\n } catch {\n return null;\n }\n};\n","import { isNaN } from \"@/predicates/is/isNaN\";\nimport { isNil } from \"@/predicates/is/isNil\";\nimport { isDate } from \"@/predicates/is/isDate\";\nimport { isString } from \"@/predicates/is/isString\";\nimport { isNonEmptyString } from \"@/predicates/is/isNonEmptyString\";\n\n/** ----------------------------------------------------------\n * * ***Utility: `formatDateTime`.***\n * ----------------------------------------------------------\n * **Formats a date and time into a custom string format.**\n * - **Features:**\n * - Supports only `YYYY`, `MM`, `DD`, `hh`, `mm`, and `ss` as placeholders.\n * - Uses a simple string replace (no locale).\n * - Returns `null` if the date is invalid or not provided.\n * - Defaults to `\"YYYY-MM-DD hh:mm:ss\"` format if none is specified.\n * @param {string | Date | null| undefined} date - The date to format.\n * @param {string} [format=\"YYYY-MM-DD hh:mm:ss\"] - The desired date format, if format is `null` or `undefined` will force to defaultValue, defaultValue is: `\"YYYY-MM-DD hh:mm:ss\"`.\n * @returns {string | null} The formatted date string or `null` if invalid.\n * @example\n * formatDateTime(new Date());\n * // ➔ \"2024-02-09 14:30:45\" (example output with current time)\n * formatDateTime(\"2023-07-01T14:30:45\");\n * // ➔ \"2023-07-01 14:30:45\"\n * formatDateTime(\"2023-07-01T14:30:45\", \"DD/MM/YYYY\");\n * // ➔ \"01/07/2023\"\n * formatDateTime(\"2023-07-01T14:30:45\", \"YYYY/MM/DD hh-mm-ss\");\n * // ➔ \"2023/07/01 14-30-45\"\n * formatDateTime(\"2023-07-01T14:30:45\", \"hh:mm\");\n * // ➔ \"14:30\"\n * formatDateTime(\"2023-07-01T14:30:45\", \"DATE: YYYY.MM.DD\");\n * // ➔ \"DATE: 2023.07.01\"\n * formatDateTime(\"2023-07-01T14:30:45\", \"Year: YYYY, Time: hh:mm:ss\");\n * // ➔ \"Year: 2023, Time: 14:30:45\"\n * formatDateTime(\"2023-07-01T14:30:45\", \"YYYY-MM\");\n * // ➔ \"2023-07\"\n * formatDateTime(\"2023-07-01T14:30:45\", \"YYYYYYYY\");\n * // ➔ \"20232023\"\n * formatDateTime(\"2023-07-01T14:30:45\", \"hh:mm:ss:ss\");\n * // ➔ \"14:30:45:45\"\n * formatDateTime(\"invalid-date\");\n * // ➔ null\n * formatDateTime(null);\n * // ➔ null\n * formatDateTime(undefined);\n * // ➔ null\n */\nexport const formatDateTime = (\n date: string | Date | null | undefined,\n format?: string\n): string | null => {\n if (isNil(format)) {\n format = \"YYYY-MM-DD hh:mm:ss\";\n }\n\n if (!isString(format)) return null;\n\n // Handle missing or invalid date input type\n if (isNil(date) || !(isDate(date) || isNonEmptyString(date))) {\n return null;\n }\n\n try {\n const parsedDate = new Date(date);\n if (isNaN(parsedDate.getTime())) return null; // Handle invalid dates\n\n const pad2 = (n: number) => n.toString().padStart(2, \"0\");\n\n const map: Record<string, string> = {\n YYYY: parsedDate.getFullYear().toString(),\n MM: pad2(parsedDate.getMonth() + 1),\n DD: pad2(parsedDate.getDate()),\n hh: pad2(parsedDate.getHours()),\n mm: pad2(parsedDate.getMinutes()),\n ss: pad2(parsedDate.getSeconds())\n };\n\n const result = Object.entries(map).reduce(\n (prev, [key, value]) => prev.split(key).join(value),\n format\n );\n\n return !result.includes(\"NaN\") ? result : null;\n } catch {\n return null;\n }\n};\n","import { isNil } from \"@/predicates/is/isNil\";\nimport { isNaN } from \"@/predicates/is/isNaN\";\nimport { isDate } from \"@/predicates/is/isDate\";\nimport { isString } from \"@/predicates/is/isString\";\nimport { isEmptyString } from \"@/predicates/is/isEmptyString\";\nimport { isNonEmptyString } from \"@/predicates/is/isNonEmptyString\";\n\n/** ----------------------------------------------------------\n * * ***Utility: `getGMTOffset`.***\n * ----------------------------------------------------------\n * **Returns the formatted GMT offset (e.g., `+0700`, `-0500`) for a given date.**\n * - **Features:**\n * - If `date` is **not provided** or empty string, it defaults to the current date/time.\n * - If `date` is **invalid** or of wrong type (like object or number), it returns `\"0\"`.\n * - The returned string follows the **GMT offset format** (`±HHMM`), where:\n * - `±` is `+` if ahead of UTC, `-` if behind.\n * - `HH` is two-digit hours.\n * - `MM` is two-digit minutes.\n * @param {string | Date | null} [date]\n * ***The date to get the GMT offset from.***\n * - Accepts `Date` object or ISO date string (e.g., `\"2024-01-01T12:00:00Z\"`).\n * - If `null`, `undefined`, or empty string, uses current system date.\n * - If invalid date or wrong type (like `123` or `{}`), returns `\"0\"`.\n * @returns {string} The GMT offset string in format `±HHMM`,\n * e.g. `\"+0700\"`, `\"-0530\"`, or `\"0\"` if invalid.\n * @example\n * getGMTOffset();\n * // ➔ \"+0700\" (depends on your system timezone)\n * getGMTOffset(new Date(\"2024-02-09T12:00:00Z\"));\n * // ➔ \"+0000\"\n * getGMTOffset(\"2024-02-09\");\n * // ➔ \"+0700\" (depends on your system timezone)\n * getGMTOffset(\"invalid-date\");\n * // ➔ \"0\"\n * getGMTOffset(123);\n * // ➔ \"0\"\n */\nexport const getGMTOffset = (date?: string | Date | null): string => {\n try {\n if (isNil(date) || (isString(date) && isEmptyString(date))) {\n date = new Date(); // Default to current date\n } else if (!(isDate(date) || isNonEmptyString(date))) {\n return \"0\"; // Invalid type\n }\n\n const parsedDate = new Date(date);\n if (isNaN(parsedDate.getTime())) return \"0\"; // Handle invalid dates\n\n const padZero = (num: number) => num.toString().padStart(2, \"0\");\n\n let offset = parsedDate.getTimezoneOffset();\n const sign = offset < 0 ? \"+\" : \"-\";\n offset = Math.abs(offset);\n\n return `${sign}${padZero(Math.floor(offset / 60))}${padZero(offset % 60)}`;\n } catch {\n return \"0\";\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAM,sBAAsB,EAC1B,QACA,gBAII;CACJ,MAAM,YAAY,QAAQ,MAAM,GAAG;CACnC,MAAM,OAAO,QAAQ,MAAM,GAAG,GAAG;CACjC,IAAI,CAAC,MAAM,OAAO;CAClB,OACE,KAAK,QAAQ,yBAAyB,UAAU,GAAG,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuOnE,MAAa,kBACX,OACA,UAAiC,EAAE,KACxB;CACX,IAAI,CAACA,iCAAS,MAAM,IAAI,CAACC,0BAAS,MAAM,EACtC,MAAM,IAAI,UACR,mGAAmGC,uCACjG,MACD,CAAC,oBAAoBC,gDAAoB,OAAO,EAC/C,eAAe,MAChB,CAAC,CAAC,KACJ;CAGH,4CAAoB,SAAS,EAC3B,UAAU,EAAE,aAAa,gBACvB,oDAAoD,UAAU,sBAAsB,YAAY,MACnG,CAAC;CAEF,MAAM,UAAUC,mCAAW,SAAS,UAAU,GAAG,QAAQ,UAAU;CACnE,MAAM,eAAeA,mCAAW,SAAS,eAAe,GACpD,QAAQ,eACR;CACJ,MAAM,aAAaA,mCAAW,SAAS,aAAa,GAChD,QAAQ,aACR;CACJ,MAAM,eAAeA,mCAAW,SAAS,eAAe,GACpD,QAAQ,eACR;CAC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;;;;;;;;;;;;;;;;;;;;;;;;;;;AC9CX,MAAa,gBAAgB,SAAwC;CACnE,IAAI;EACF,IAAIC,8BAAM,KAAK,IAAKC,iCAAS,KAAK,IAAIC,oCAAc,KAAK,EACvD,uBAAO,IAAI,MAAM;OACZ,IAAI,EAAEC,mCAAO,KAAK,IAAIC,yCAAiB,KAAK,GACjD,OAAO;EAGT,MAAM,aAAa,IAAI,KAAK,KAAK;EACjC,IAAIC,8BAAM,WAAW,SAAS,CAAC,EAAE,OAAO;EAExC,MAAM,WAAW,QAAgB,IAAI,UAAU,CAAC,SAAS,GAAG,IAAI;EAEhE,IAAI,SAAS,WAAW,mBAAmB;EAC3C,MAAM,OAAO,SAAS,IAAI,MAAM;EAChC,SAAS,KAAK,IAAI,OAAO;EAEzB,OAAO,GAAG,OAAO,QAAQ,KAAK,MAAM,SAAS,GAAG,CAAC,GAAG,QAAQ,SAAS,GAAG;SAClE;EACN,OAAO"}
@@ -2,17 +2,17 @@
2
2
  * ========================================================================
3
3
  * @rzl-zone/utils-js
4
4
  * ------------------------------------------------------------------------
5
- * Version: `3.12.1-beta.0`
5
+ * Version: `3.12.1-beta.1`
6
6
  * Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
7
7
  * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
8
8
  * ========================================================================
9
9
  */
10
10
  "use strict";
11
11
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
12
- const require_assertIsBoolean = require('../assertIsBoolean-DozdtbNi.cjs');
13
- const require_safeStableStringify = require('../safeStableStringify-Cc62pfRp.cjs');
14
- const require_noop = require('../noop-B2mTBhW-.cjs');
15
- const require_isInteger = require('../isInteger-FTCthMre.cjs');
12
+ const require_assertIsBoolean = require('../assertIsBoolean-C8WEXVr2.cjs');
13
+ const require_safeStableStringify = require('../safeStableStringify-CJtP89qn.cjs');
14
+ const require_noop = require('../noop-B13_ii35.cjs');
15
+ const require_isInteger = require('../isInteger-Caeuz0rB.cjs');
16
16
  function getRandomItem(array) {
17
17
  if (!require_assertIsBoolean.isNonEmptyArray(array)) return void 0;
18
18
  return array[Math.floor(Math.random() * (array.length || 0))];
@@ -103,9 +103,13 @@ function generateUUIDv4() {
103
103
  if (hasCryptoRandomUUID()) return crypto.randomUUID();
104
104
  if (hasCryptoGetRandomValues()) {
105
105
  const rnd = crypto.getRandomValues(new Uint8Array(16));
106
+ if (!rnd[0] || !rnd[1] || !rnd[2] || !rnd[3] || !rnd[4] || !rnd[5] || !rnd[6] || !rnd[7] || !rnd[8] || !rnd[9] || !rnd[10] || !rnd[11] || !rnd[12] || !rnd[13] || !rnd[14] || !rnd[15]) return "";
107
+ const byteToHex0 = byteToHex[rnd[0]];
108
+ const byteToHex1 = byteToHex[rnd[1]];
109
+ if (!byteToHex0 || !byteToHex1) return "";
106
110
  rnd[6] = rnd[6] & 15 | 64;
107
111
  rnd[8] = rnd[8] & 63 | 128;
108
- return byteToHex[rnd[0]] + byteToHex[rnd[1]] + byteToHex[rnd[2]] + byteToHex[rnd[3]] + "-" + byteToHex[rnd[4]] + byteToHex[rnd[5]] + "-" + byteToHex[rnd[6]] + byteToHex[rnd[7]] + "-" + byteToHex[rnd[8]] + byteToHex[rnd[9]] + "-" + byteToHex[rnd[10]] + byteToHex[rnd[11]] + byteToHex[rnd[12]] + byteToHex[rnd[13]] + byteToHex[rnd[14]] + byteToHex[rnd[15]];
112
+ return byteToHex0 + byteToHex1 + byteToHex[rnd[2]] + byteToHex[rnd[3]] + "-" + byteToHex[rnd[4]] + byteToHex[rnd[5]] + "-" + byteToHex[rnd[6]] + byteToHex[rnd[7]] + "-" + byteToHex[rnd[8]] + byteToHex[rnd[9]] + "-" + byteToHex[rnd[10]] + byteToHex[rnd[11]] + byteToHex[rnd[12]] + byteToHex[rnd[13]] + byteToHex[rnd[14]] + byteToHex[rnd[15]];
109
113
  }
110
114
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
111
115
  const r = Math.random() * 16 | 0;
@@ -142,8 +146,8 @@ function generateUUIDv7({ monotonic = false } = {}) {
142
146
  monotonicState.lastTimestampMs = nowMs;
143
147
  rand = fresh;
144
148
  }
145
- rand[0] = rand[0] & 15 | 112;
146
- rand[2] = rand[2] & 63 | 128;
149
+ rand[0] = rand[0] ? rand[0] & 15 | 112 : 0;
150
+ rand[2] = rand[2] ? rand[2] & 63 | 128 : 0;
147
151
  const randHex = Array.from(rand, (b) => byteToHex[b]).join("");
148
152
  return [
149
153
  tsHex.slice(0, 8),
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["isNonEmptyArray","isInteger","getPreciseType","safeStableStringify","isNumber","isPlainObject","isInteger","getPreciseType","safeStableStringify","isPlainObject","isInteger","getPreciseType","safeStableStringify","isNaN","isPlainObject","getPreciseType","safeStableStringify","isNonEmptyString","isBoolean"],"sources":["../../src/generators/random/array/getRandomItem.ts","../../src/generators/random/integer/randomInt.ts","../../src/generators/random/integer/randomIntByLength.ts","../../src/generators/random/string/randomStr.ts","../../src/generators/random/uuid/randomUUID.ts"],"sourcesContent":["import type {\n Extends,\n FixNeverArrayRecursive,\n IfNonEmptyArray,\n NullToUndefined\n} from \"@rzl-zone/ts-types-plus\";\n\nimport { isNonEmptyArray } from \"@/predicates/is/isNonEmptyArray\";\n\n/** ---------------------------------\n * * ***Utility: `getRandomItem`.***\n * ---------------------------------\n * **Function to get a random element from a given array.**\n * @template T - The type of the input array.\n * @param {*} array - The input array, can be `null`, `undefined`, or an empty array.\n * @returns\n * - If `array` is a non-empty tuple, returns one of its elements.\n * - If `array` is empty, `null`, or `undefined`, returns `undefined`.\n * @example\n * getRandomItem([]);\n * // ➔ undefined\n * getRandomItem(null);\n * // ➔ undefined\n * getRandomItem(undefined);\n * // ➔ undefined\n * getRandomItem([1, 2, 3, 4]);\n * // ➔ number\n * getRandomItem([\"apple\", \"banana\", \"cherry\"]);\n * // ➔ string\n * getRandomItem([\"apple\", 123, true]);\n * // ➔ string | number | boolean\n * getRandomItem([\"apple\", 123, true, null]);\n * // ➔ string | number | boolean | undefined\n * getRandomItem([\"apple\", 123, true, undefined]);\n * // ➔ string | number | boolean | undefined\n *\n * // Tuple example:\n * const tuple = [1, \"two\", true] as const;\n * getRandomItem(tuple); // 1 | \"two\" | true\n */\nexport function getRandomItem(array: undefined): undefined;\nexport function getRandomItem(array: []): undefined;\nexport function getRandomItem<T extends readonly unknown[]>(\n array: T\n): T extends never[][]\n ? undefined\n : number extends T[\"length\"]\n ? NullToUndefined<FixNeverArrayRecursive<T[number]>>\n : IfNonEmptyArray<\n T,\n NullToUndefined<FixNeverArrayRecursive<T[number]>>,\n undefined\n >;\nexport function getRandomItem<T extends readonly unknown[] | undefined | null>(\n array: T\n): T extends readonly unknown[]\n ? NullToUndefined<FixNeverArrayRecursive<T[number]>> | undefined\n : undefined;\nexport function getRandomItem<T>(array: T): unknown extends T\n ? unknown\n : // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Extends<any[] | readonly any[], T> extends true\n ? Extract<T, unknown[] | readonly unknown[]>[number] | undefined\n : // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Extends<any[], T> extends true\n ? Extract<T, unknown[] | readonly unknown[]>[number] | undefined\n : // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Extends<readonly any[], T> extends true\n ? Extract<T, unknown[] | readonly unknown[]>[number] | undefined\n : undefined;\nexport function getRandomItem(array: unknown): unknown {\n if (!isNonEmptyArray(array)) return undefined;\n\n const randomIndex = Math.floor(Math.random() * (array.length || 0));\n return array[randomIndex];\n}\n","import { isNumber } from \"@/predicates/is/isNumber\";\nimport { isInteger } from \"@/predicates/is/isInteger\";\nimport { getPreciseType } from \"@/predicates/type/getPreciseType\";\nimport { safeStableStringify } from \"@/conversions/stringify/safeStableStringify\";\n\n/** -----------------------------------------------------------------------\n * * ***Utility: `randomInt`.***\n * ------------------------------------------------------------------------\n * **Generates a random integer within a specified range (inclusive).**\n * - **Generates a random integer between `min` and `max` (inclusive), with safety constraints:**\n * - `min` will be forced to be at least `1`.\n * - `max` will be capped at `Number.MAX_SAFE_INTEGER`.\n * @param {number} min - The minimum value (inclusive), must be an integer.\n * @param {number} max - The maximum value (inclusive), must be an integer.\n * @returns {number} A random integer N where `min ≤ N ≤ max`.\n * @throws **{@link TypeError | `TypeError`}** if:\n * - `min` or `max` is not an integer, or value is `Number.MIN_VALUE`.\n * - `min` is greater than `max`.\n * @example\n * randomInt(1, 10); // ➔ returns 1 up-to 10 (random)\n * randomInt(50, 100); // ➔ returns 50 up-to 100 (random)\n * randomInt(5, 5); // ➔ always returns 5 (exact)\n * randomInt(-5, 3); // ➔ always returns ≥ 1, since min is adjusted (exact)\n * randomInt(1, Number.MAX_SAFE_INTEGER + 10000);\n * // ➔ still safely capped at MAX_SAFE_INTEGER\n * randomInt(Number.MIN_VALUE, 3);\n * // ➔ Error, min or max cant be as `Number.MIN_VALUE` value.\n */\nexport const randomInt = (min: number, max: number): number => {\n if (!isInteger(min) || !isInteger(max)) {\n throw new TypeError(\n `First parameter (\\`min\\`) and second parameter (\\`max\\`) must be of type \\`integer-number\\`${minValueNote(\n min,\n max\n )}value, but received: ['min': \\`${getPreciseType(\n min\n )}\\` - (with value: \\`${safeStableStringify(min, {\n keepUndefined: true\n })})\\`, 'max': \\`${getPreciseType(max)}\\` - (with value: \\`${safeStableStringify(\n max,\n {\n keepUndefined: true\n }\n )}\\`)].`\n );\n }\n if (min > max) {\n throw new RangeError(\n `First parameter (\\`min\\`) must be less than or equal to second parameter (\\`max\\`), but received: ['min': ${formatValue(\n min\n )} - (with value: \\`${safeStableStringify(min, {\n keepUndefined: true\n })})\\`, 'max': ${formatValue(max)} - (with value: \\`${safeStableStringify(\n max,\n {\n keepUndefined: true\n }\n )})\\`].`\n );\n }\n\n // Ensure `min` is at least 1\n min = Math.max(1, min);\n\n // Ensure `max` does not exceed Number.MAX_SAFE_INTEGER\n max = Math.min(Number.MAX_SAFE_INTEGER, max);\n\n return Math.floor(Math.random() * (max - min + 1)) + min;\n};\n\nconst formatValue = (value: unknown): string => {\n return isNumber(value, { includeNaN: true })\n ? value === Number.MIN_VALUE\n ? \"`Number.MIN_VALUE`\"\n : `${value}`\n : `\\`${getPreciseType(value)}\\``;\n};\n\nconst minValueNote = (...values: unknown[]) => {\n return values.some(\n (v) => isNumber(v, { includeNaN: true }) && v === Number.MIN_VALUE\n )\n ? \" and can't be `Number.MIN_VALUE` \"\n : \" \";\n};\n","import { randomInt } from \"./randomInt\";\nimport { isInteger } from \"@/predicates/is/isInteger\";\nimport { isPlainObject } from \"@/predicates/is/isPlainObject\";\nimport { getPreciseType } from \"@/predicates/type/getPreciseType\";\nimport { assertIsBoolean } from \"@/assertions/booleans/assertIsBoolean\";\nimport { safeStableStringify } from \"@/conversions/stringify/safeStableStringify\";\n\ntype OptionsRandomIntByLength = {\n /** * Minimum length of the random number, the `allowed minimal value` `integer` is `1` `and not bigger than value of` `maxLength`, defaultValue: `1`.\n *\n * @default 1\n */\n minLength?: number;\n /** * Maximum length of the random number, the `allowed maximal value` `integer` is `16`, defaultValue: `16`.\n *\n * @default 16\n */\n maxLength?: number;\n /** * If true, prevents the result from being zero, defaultValue: `false`.\n *\n * @default false\n */\n avoidZero?: boolean;\n};\n\n/** ----------------------------------------------------------------------------\n * * ***Utility: `randomIntByLength`.***\n * -----------------------------------------------------------------------------\n * **Generates a random integer within a specified range of digit lengths.**\n * @description\n * This function allows generating random integers that strictly conform to a specified minimum and\n * maximum digit length, it is useful for scenarios such as generating realistic-looking IDs, codes,\n * or random test data.\n * - **The function ensures:**\n * - `minLength` is at least 1 and not greater than `maxLength`.\n * - `maxLength` is no more than 16 (due to JavaScript's `Number.MAX_SAFE_INTEGER`).\n * - If `avoidZero` is `true`, ensures that `0` is never returned.\n * @param {OptionsRandomIntByLength} [options] - Configuration options.\n * @param {OptionsRandomIntByLength[\"minLength\"]} [options.minLength=1] - Minimum number of digits (must be ≥ `1` and ≤ `maxLength`).\n * @param {OptionsRandomIntByLength[\"maxLength\"]} [options.maxLength=16] - Maximum number of digits (must be ≤ `16`).\n * @param {OptionsRandomIntByLength[\"avoidZero\"]} [options.avoidZero=false] - If true, will ensure the result is never zero.\n * @returns {number} A randomly generated integer within the specified constraints.\n * @throws **{@link TypeError | `TypeError`}** if parameters are invalid, such as:\n * - `minLength` < `1`\n * - `maxLength` > `16`\n * - `minLength` > `maxLength`\n * - non-integer values for `minLength` or `maxLength`\n * @example\n * randomIntByLength({ minLength: 3, maxLength: 5 });\n * // ➔ `4829` (random), `192` (random) or `71492` (random).\n * randomIntByLength({ minLength: 4, maxLength: 4 });\n * // ➔ `5930` (exact 4 digits)\n * randomIntByLength({ avoidZero: true });\n * // ➔ never 0\n */\nexport const randomIntByLength = (\n options?: OptionsRandomIntByLength\n): number => {\n // Ensure options is an object and Defensive options check\n if (!isPlainObject(options)) {\n options = {};\n }\n\n const { minLength = 1, maxLength = 16, avoidZero = false } = options;\n\n assertIsBoolean(avoidZero, {\n message({ currentType, validType }) {\n return `Parameters \\`avoidZero\\` must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`;\n }\n });\n\n // Validate `minLength` & `maxLength` type\n if (!isInteger(minLength) || !isInteger(maxLength)) {\n throw new TypeError(\n `Parameters \\`minLength\\` and \\`maxLength\\` must be of type \\`integer-number\\`, but received: ['minLength': \\`${getPreciseType(\n minLength\n )}\\` - (with value: ${safeStableStringify(minLength, {\n keepUndefined: true\n })}), 'maxLength': \\`${getPreciseType(\n maxLength\n )}\\` - (with value: ${safeStableStringify(maxLength, {\n keepUndefined: true\n })})].`\n );\n }\n\n // Validate `minLength` & `maxLength` range.\n if (minLength < 1 || maxLength > 16 || minLength > maxLength) {\n throw new RangeError(\n `Invalid range at parameters \\`minLength\\` must be ≥ 1, \\`maxLength\\` must be ≤ 16, and \\`minLength\\` ≤ \\`maxLength\\`, but received: ['minLength': \\`${minLength}\\`, 'maxLength': \\`${maxLength}\\`].`\n );\n }\n\n // Generate a random length between minLength and maxLength\n const randomLength =\n minLength === maxLength ? minLength : randomInt(minLength, maxLength);\n\n // Define min and max value based on the selected length\n const minValue = 10 ** (randomLength - 1); // Example: minLength=3 ➔ minValue=100\n const maxValue = 10 ** randomLength - 1; // Example: maxLength=4 ➔ maxValue=9999\n\n // Generate a random number within the valid range\n let result = randomInt(minValue, maxValue);\n\n // Ensure the number is not zero if `avoidZero` is true\n if (avoidZero && result === 0) {\n result = minValue; // Assign the smallest valid number instead of looping\n }\n\n return result;\n};\n","import type { OptionsRandomStr } from \"./_private/randomSTR.types\";\n\nimport { randomInt } from \"../integer/randomInt\";\n\nimport { isNaN } from \"@/predicates/is/isNaN\";\nimport { isInteger } from \"@/predicates/is/isInteger\";\nimport { isPlainObject } from \"@/predicates/is/isPlainObject\";\nimport { getPreciseType } from \"@/predicates/type/getPreciseType\";\n\nimport { assertIsBoolean } from \"@/assertions/booleans/assertIsBoolean\";\nimport { safeStableStringify } from \"@/conversions/stringify/safeStableStringify\";\n\n/** ---------------------------------------------------------------------------------\n * * ***Utility: `randomStr`.***\n * ---------------------------------------------------------------------------------\n * **Generates a random alphanumeric string or number with a specified length range.**\n * @description\n * This function allows you to generate random strings or numbers with fully\n * customizable options, such as length range, character sets, inclusion of\n * additional characters, and whether to avoid whitespace.\n * @param {OptionsRandomStr} [options] - Configuration options for generating the string.\n * @param {OptionsRandomStr[\"minLength\"]} [options.minLength=40] - Minimum length of the generated string (must be `≥` `1`).\n * @param {OptionsRandomStr[\"maxLength\"]} [options.maxLength=40] - Maximum length of the generated string (must be `≤` `5000`).\n * @param {OptionsRandomStr[\"type\"]} [options.type=\"string\"] - Whether to generate a general alphanumeric string or purely numeric string.\n * @param {OptionsRandomStr[\"avoidWhiteSpace\"]} [options.avoidWhiteSpace=true] - If true, removes all whitespace, tabs, and newlines from the character set before generating.\n * @param {OptionsRandomStr[\"replaceGenStr\"]} [options.replaceGenStr] - A custom character set to use when `type` is `\"string\"`.\n * @param {OptionsRandomStr[\"replaceGenInt\"]} [options.replaceGenInt] - A custom character set to use when `type` is `\"number\"`.\n * @param {OptionsRandomStr[\"addChar\"]} [options.addChar] - Additional characters to always include in the character set.\n * @returns {string} The randomly generated string or numeric string of the desired length.\n * @throws **{@link TypeError | `TypeError`}** if provided options are invalid (such as minLength > maxLength, invalid type, or empty character set).\n * @example\n * randomStr();\n * // ➔ Generates a 40-character random alphanumeric string\n * randomStr({ minLength: 10, maxLength: 20 });\n * // ➔ Generates a string between 10 and 20 characters\n * randomStr({ type: \"number\", minLength: 5, maxLength: 5 });\n * // ➔ \"48302\"\n * randomStr({ replaceGenStr: \"ABC \", avoidWhiteSpace: false });\n * // ➔ String using A, B, C and space\n * randomStr({ addChar: \"!@#\", minLength: 15, maxLength: 15 });\n * // ➔ Guaranteed to include !@# in the set\n */\nexport const randomStr = (options?: OptionsRandomStr): string => {\n // Ensure options is an object and Defensive options check\n if (!isPlainObject(options)) {\n options = {};\n }\n\n const {\n minLength = 40,\n maxLength = 40,\n type = \"string\",\n avoidWhiteSpace = true\n } = options;\n\n // Validate `avoidWhiteSpace`\n assertIsBoolean(avoidWhiteSpace, {\n message({ currentType, validType }) {\n return `Parameters \\`avoidWhiteSpace\\` property of the \\`options\\` (first-parameter) must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`;\n }\n });\n\n // Validate `minLength` & `maxLength` type\n if (!isInteger(minLength) || !isInteger(maxLength)) {\n throw new TypeError(\n `Parameters \\`minLength\\` and \\`maxLength\\` must be of type \\`integer-number\\`, but received: ['minLength': \\`${getPreciseType(\n minLength\n )}\\` - (with value: ${safeStableStringify(minLength, {\n keepUndefined: true\n })}), 'maxLength': \\`${getPreciseType(\n maxLength\n )}\\` - (with value: ${safeStableStringify(maxLength, {\n keepUndefined: true\n })})].`\n );\n }\n\n // Validate `minLength` & `maxLength` range.\n if (minLength < 1 || maxLength > 5000 || minLength > maxLength) {\n throw new RangeError(\n `Invalid range at parameters \\`minLength\\` must be ≥ 1, \\`maxLength\\` must be ≤ 5000, and \\`minLength\\` ≤ \\`maxLength\\`, but received: ['minLength': \\`${minLength}\\`, 'maxLength': \\`${maxLength}\\`].`\n );\n }\n\n // Validate `type` value props (is not typeof)\n if (type !== \"string\" && type !== \"number\") {\n throw new TypeError(\n `Parameter \\`type\\` must be of type \\`string\\` with value one of \"string\" | \"number\", but received: \\`${getPreciseType(\n type\n )}\\`, with value: ${safeStableStringify(type, {\n keepUndefined: true\n })}.`\n );\n }\n\n // Generate a random length within the range\n const length = randomInt(minLength, maxLength);\n\n // Function to clean characters based on `avoidWhiteSpace`\n const cleanCharacters = (charSet: string) => {\n return avoidWhiteSpace ? charSet.replace(/\\s|\\n|\\t/g, \"\") : charSet;\n };\n\n // Define character sets\n const defaultNumberSet = \"0123456789\";\n const defaultStringSet =\n \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\n\n const baseCharSet =\n type === \"number\"\n ? ((!isNaN(Number(options.replaceGenInt))\n ? options.replaceGenInt\n : undefined) ?? defaultNumberSet)\n : ((options.replaceGenStr ? options.replaceGenStr : undefined) ??\n defaultStringSet);\n\n // Get the final character set\n const characterSet = cleanCharacters(baseCharSet) + (options.addChar || \"\");\n\n // Ensure characterSet is not empty\n if (!characterSet.length) {\n const errCharSet = () => {\n if (type === \"number\") {\n if (avoidWhiteSpace) {\n return \"If `avoidWhiteSpace` is true, and `replaceGenInt` cant be empty-string value, ensure `replaceGenInt` has valid characters and non-nan string number.\";\n }\n return \"Ensure `replaceGenInt` has valid characters and not a NaN number string while convert to number.\";\n }\n return \"Ensure `replaceGenStr` has valid characters and non empty string.\";\n };\n\n throw new Error(`Character set is empty. ${errCharSet()}`);\n }\n\n // Generate random string\n let result = \"\";\n for (let i = 0; i < length; i++) {\n result += characterSet.charAt(\n Math.floor(Math.random() * characterSet.length)\n );\n }\n\n return result;\n};\n","import { isBoolean } from \"@/predicates/is/isBoolean\";\nimport { isPlainObject } from \"@/predicates/is/isPlainObject\";\nimport { getPreciseType } from \"@/predicates/type/getPreciseType\";\nimport { isNonEmptyString } from \"@/predicates/is/isNonEmptyString\";\nimport { safeStableStringify } from \"@/conversions/stringify/safeStableStringify\";\n\n/**\n * Configuration options for `randomUUID()`.\n */\ntype OptionsRandomUUID = {\n /**\n * Specifies which UUID version to generate.\n *\n * - `\"v4\"` — Fully random UUID (RFC 4122). No timestamp, no ordering guarantees.\n * - `\"v7\"` — Time-ordered UUID (RFC 9562). Uses Unix timestamp + randomness.\n *\n * @default \"v4\"\n *\n * @example\n * // Random v4 UUID\n * randomUUID({ version: \"v4\" }); // ➔ \"3ec0de5a-b8a9-4ffb-a62a-fcc76851e9c2\"\n *\n * @example\n * // Time-ordered v7 UUID\n * randomUUID({ version: \"v7\" }); // ➔ \"0199f3f6-3c5e-744b-affa-46b2cfd496f8\"\n */\n version?: \"v4\" | \"v7\";\n\n /**\n * Enables monotonic sequencing for UUID v7.\n *\n * - Guarantees that multiple UUIDs generated within the same millisecond\n * are strictly non-decreasing (lexicographically and timestamp-wise).\n * - Only valid when `version === \"v7\"`. Using with `v4` will throw a `TypeError`.\n * - Useful for database inserts, logs, or any system where order matters.\n *\n * @default false\n *\n * @example\n * // Monotonic v7 UUIDs\n * const a = randomUUID({ version: \"v7\", monotonic: true });\n * const b = randomUUID({ version: \"v7\", monotonic: true });\n * console.log(a < b); // true, guaranteed\n */\n monotonic?: boolean;\n};\n\n/** -----------------------------------------------------------------------\n * * ***Utility: `randomUUID`.***\n * ------------------------------------------------------------------------\n * **Generates a UUID string according to the specified version and options.**\n *\n * - **Supported versions**:\n * - **`\"v4\"` (default)** ➔ Fully random UUID, RFC 4122 compliant.\n * - Uses `crypto.randomUUID()` if available.\n * - Falls back to `crypto.getRandomValues()` or `Math.random()`\n * if needed.\n * - **`\"v7\"`** ➔ Time-ordered UUID, RFC 9562 compliant.\n * - Timestamp (Unix ms, 48 bits) + 80 bits randomness.\n * - Good for database indexing / sorting.\n * - **`\"v7\"` + `monotonic: true`** ➔ Ensures strictly non-decreasing UUIDs\n * for multiple calls in the same millisecond (per-process).\n *\n * - **Behavior / Safety Notes**:\n * - **v4**: Fully random; probability of duplicates is astronomically low.\n * - **v7**: Time-ordered; collisions extremely unlikely unless same ms + random repeat.\n * - **Monotonic v7**: Guaranteed ordering per-process if multiple UUIDs are generated\n * in the same millisecond.\n * - **All versions**: Fallback safely if `crypto` APIs are unavailable.\n *\n * @param {object} [options] - Optional settings object.\n * @param {\"v4\" | \"v7\"} [options.version=\"v4\"] - UUID version to generate.\n * @param {boolean} [options.monotonic=false] - For v7 only: generate monotonic UUIDs\n * to maintain strict lexicographic order\n * when generating multiple UUIDs within the same ms.\n *\n * @returns {string} A 36-character UUID string compliant with the selected version.\n *\n * @throws **{@link TypeError | `TypeError`}** if:\n * - `options` is not a plain object.\n * - `options.version` is provided but not a string.\n * - `options.monotonic` is provided but not a boolean.\n * - `monotonic: true` is used with `version` other than `\"v7\"`.\n * @throws **{@link RangeError | `RangeError`}** if `options.version` is provided but not `\"v4\"` or `\"v7\"`.\n *\n * @example\n * // Default (v4)\n * const id = randomUUID();\n * // ➔ \"3b12f1df-5232-4804-897e-917bf397618a\"\n *\n * @example\n * // Explicit v4\n * const id4 = randomUUID({ version: \"v4\" });\n *\n * @example\n * // Time-ordered v7\n * const id7 = randomUUID({ version: \"v7\" });\n * // ➔ \"018f48d2-84c1-7ccd-b5a3-2f9463b3a889\"\n *\n * @example\n * // Monotonic v7\n * const a = randomUUID({ version: \"v7\", monotonic: true });\n * const b = randomUUID({ version: \"v7\", monotonic: true });\n * // a < b lexicographically (guaranteed)\n *\n * @example\n * // Throws TypeError\n * randomUUID(\"v4\" as any); // options must be object\n * randomUUID({ version: 123 as any }); // version must be string\n * randomUUID({ version: \"v4\", monotonic: true } as any); // monotonic only for v7\n *\n * @example\n * // Throws RangeError\n * randomUUID({ version: \"v1\" as any }); // unsupported version\n */\nexport function randomUUID(options: OptionsRandomUUID = {}): string {\n // Validate options is a plain object if provided\n if (!isPlainObject(options)) {\n throw new TypeError(\n `First parameter (\\`options\\`) must be a plain object with optional properties \\`version\\` and \\`monotonic\\`, but received: \\`${getPreciseType(\n options\n )}\\` - (with value: \\`${safeStableStringify(options, { keepUndefined: true })}\\`).`\n );\n }\n\n const { version = \"v4\", monotonic = false } = options;\n\n // Validate version type\n if (!isNonEmptyString(version)) {\n throw new TypeError(\n `Parameter \\`version\\` property of the \\`options\\` (first parameter) must be a \\`string\\` of either \"v4\" or \"v7\", but received type: \\`${getPreciseType(\n version\n )}\\` - (with value: \\`${safeStableStringify(version, { keepUndefined: true })}\\`).`\n );\n }\n\n if (version !== \"v4\" && version !== \"v7\") {\n throw new RangeError(\n `Unsupported UUID version. Allowed values are \"v4\" or \"v7\". (received: \\`${safeStableStringify(\n version,\n {\n keepUndefined: true\n }\n )}\\`).`\n );\n }\n\n // Validate monotonic type\n if (!isBoolean(monotonic)) {\n throw new TypeError(\n `Parameter \\`monotonic\\` property of the \\`options\\` (first parameter) must be a \\`boolean\\` when provided, but received type: \\`${getPreciseType(\n monotonic\n )}\\` - (with value: \\`${safeStableStringify(monotonic, {\n keepUndefined: true\n })}\\`).`\n );\n }\n\n // monotonic only allowed with v7\n if (monotonic && version !== \"v7\") {\n throw new TypeError(\n `Parameter \\`monotonic\\` property of the \\`options\\` (first parameter) is only supported for version \"v7\". Received: version=${safeStableStringify(\n version,\n { keepUndefined: true }\n )}.`\n );\n }\n\n if (version === \"v4\") {\n return generateUUIDv4();\n }\n\n // version === \"v7\"\n return generateUUIDv7({ monotonic });\n}\n\n//todo: Helpers & Implementations\n\nfunction hasCryptoGetRandomValues(): boolean {\n return (\n typeof crypto !== \"undefined\" &&\n typeof crypto.getRandomValues === \"function\"\n );\n}\n\nfunction hasCryptoRandomUUID(): boolean {\n return (\n typeof crypto !== \"undefined\" && typeof crypto.randomUUID === \"function\"\n );\n}\n\nfunction getRandomBytes(len: number): Uint8Array {\n if (hasCryptoGetRandomValues()) {\n return crypto.getRandomValues(new Uint8Array(len));\n }\n // Fallback: not cryptographically secure, but avoids crash\n const arr = new Uint8Array(len);\n for (let i = 0; i < len; i++) {\n arr[i] = Math.floor(Math.random() * 256);\n }\n return arr;\n}\n\nconst byteToHex: string[] = (() => {\n const arr: string[] = [];\n for (let i = 0; i < 256; ++i) {\n arr.push((i + 0x100).toString(16).substring(1));\n }\n return arr;\n})();\n\nfunction generateUUIDv4(): string {\n // Prefer native if available\n if (hasCryptoRandomUUID()) {\n return crypto.randomUUID();\n }\n\n // If crypto.getRandomValues available, use it for 16 bytes\n if (hasCryptoGetRandomValues()) {\n const rnd = crypto.getRandomValues(new Uint8Array(16));\n // Per RFC 4122: set version and variant\n rnd[6] = (rnd[6] & 0x0f) | 0x40; // version 4\n rnd[8] = (rnd[8] & 0x3f) | 0x80; // variant 10xx\n\n return (\n byteToHex[rnd[0]] +\n byteToHex[rnd[1]] +\n byteToHex[rnd[2]] +\n byteToHex[rnd[3]] +\n \"-\" +\n byteToHex[rnd[4]] +\n byteToHex[rnd[5]] +\n \"-\" +\n byteToHex[rnd[6]] +\n byteToHex[rnd[7]] +\n \"-\" +\n byteToHex[rnd[8]] +\n byteToHex[rnd[9]] +\n \"-\" +\n byteToHex[rnd[10]] +\n byteToHex[rnd[11]] +\n byteToHex[rnd[12]] +\n byteToHex[rnd[13]] +\n byteToHex[rnd[14]] +\n byteToHex[rnd[15]]\n );\n }\n\n // Last-resort fallback using Math.random (not crypto-secure)\n return \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g, (c) => {\n const r = (Math.random() * 16) | 0;\n const v = c === \"x\" ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n}\n\n/* ---------------------------\n Monotonic state (singleton per-process)\n --------------------------- */\n\n/**\n * Internal monotonic state:\n * - lastTimestampMs: last generated timestamp (ms)\n * - lastRand: last random 10-byte block used for v7 (used to increment on same ms)\n */\nconst monotonicState: {\n lastTimestampMs: number;\n lastRand: Uint8Array | null;\n} = {\n lastTimestampMs: -1,\n lastRand: null\n};\n\nfunction incrementUint8ArrayBigEndian(arr: Uint8Array): boolean {\n // Increment arr in big-endian order. Return true if overflowed back to zero.\n for (let i = arr.length - 1; i >= 0; i--) {\n if (arr[i] === 0xff) {\n arr[i] = 0x00;\n continue;\n }\n arr[i] = (arr[i] + 1) & 0xff;\n return false; // no overflow\n }\n // overflowed (wrapped to zero)\n return true;\n}\n\nfunction generateUUIDv7({\n monotonic = false\n}: { monotonic?: boolean } = {}): string {\n const nowMs = Date.now();\n const tsHex = BigInt(nowMs).toString(16).padStart(12, \"0\"); // 48 bits ➔ 12 hex chars\n\n // We'll use 10 random bytes (80 bits)\n let rand = getRandomBytes(10);\n\n if (monotonic) {\n // ensure monotonicState is consistent per-process\n if (monotonicState.lastTimestampMs === nowMs && monotonicState.lastRand) {\n // We are in the same ms bucket — increment lastRand (big-endian)\n const copy = new Uint8Array(monotonicState.lastRand); // copy for use\n const overflow = incrementUint8ArrayBigEndian(copy);\n if (overflow) {\n // Practically impossible (2^80 increments in 1ms). Throw to be safe.\n throw new RangeError(\n \"Monotonic UUID sequence overflow: too many UUIDs generated within the same millisecond.\"\n );\n }\n // use incremented copy as rand\n rand = copy;\n // update state\n monotonicState.lastRand = copy;\n } else {\n // New ms: generate fresh randomness and store\n const fresh = getRandomBytes(10);\n monotonicState.lastRand = new Uint8Array(fresh);\n monotonicState.lastTimestampMs = nowMs;\n rand = fresh;\n }\n }\n\n // If not monotonic, rand remains randomly generated above.\n\n // Now set version & variant bits into proper positions.\n // For v7 layout we used: timestamp (48 bits) + rand[0..9] (80 bits)\n // We must set version nibble into high nibble of rand[0] (time_hi_and_version)\n // and set variant bits into rand[2]'s high bits (clock_seq_hi_and_reserved)\n rand[0] = (rand[0] & 0x0f) | 0x70; // version 7 (0x7 << 4)\n rand[2] = (rand[2] & 0x3f) | 0x80; // variant 10xx\n\n const randHex = Array.from(rand, (b) => byteToHex[b]).join(\"\");\n\n // Assemble UUID groups:\n // - 8 hex (timestamp[0..7])\n // - 4 hex (timestamp[8..11])\n // - 4 hex (rand[0..1]) ➔ contains version in high nibble of rand[0]\n // - 4 hex (rand[2..3]) ➔ contains variant in high bits of rand[2]\n // - 12 hex (rand[4..9])\n const part1 = tsHex.slice(0, 8);\n const part2 = tsHex.slice(8, 12);\n const part3 = randHex.slice(0, 4);\n const part4 = randHex.slice(4, 8);\n const part5 = randHex.slice(8, 20);\n\n return [part1, part2, part3, part4, part5].join(\"-\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAsEA,SAAgB,cAAc,OAAyB;CACrD,IAAI,CAACA,wCAAgB,MAAM,EAAE,OAAO;CAGpC,OAAO,MADa,KAAK,MAAM,KAAK,QAAQ,IAAI,MAAM,UAAU,GACxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC9C1B,MAAa,aAAa,KAAa,QAAwB;CAC7D,IAAI,CAACC,4BAAU,IAAI,IAAI,CAACA,4BAAU,IAAI,EACpC,MAAM,IAAI,UACR,8FAA8F,aAC5F,KACA,IACD,CAAC,iCAAiCC,uCACjC,IACD,CAAC,sBAAsBC,gDAAoB,KAAK,EAC/C,eAAe,MAChB,CAAC,CAAC,gBAAgBD,uCAAe,IAAI,CAAC,sBAAsBC,gDAC3D,KACA,EACE,eAAe,MAChB,CACF,CAAC,OACH;CAEH,IAAI,MAAM,KACR,MAAM,IAAI,WACR,6GAA6G,YAC3G,IACD,CAAC,oBAAoBA,gDAAoB,KAAK,EAC7C,eAAe,MAChB,CAAC,CAAC,cAAc,YAAY,IAAI,CAAC,oBAAoBA,gDACpD,KACA,EACE,eAAe,MAChB,CACF,CAAC,OACH;CAIH,MAAM,KAAK,IAAI,GAAG,IAAI;CAGtB,MAAM,KAAK,IAAI,OAAO,kBAAkB,IAAI;CAE5C,OAAO,KAAK,MAAM,KAAK,QAAQ,IAAI,MAAM,MAAM,GAAG,GAAG;;AAGvD,MAAM,eAAe,UAA2B;CAC9C,OAAOC,iCAAS,OAAO,EAAE,YAAY,MAAM,CAAC,GACxC,UA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,CAAC,SAAS,GAAG,CAAC,SAAS,IAAI,IAAI;CAG1D,IAAI,OAAO,eAAe,GAAG;CAE7B,IAAI,WAEF,IAAI,eAAe,oBAAoB,SAAS,eAAe,UAAU;EAEvE,MAAM,OAAO,IAAI,WAAW,eAAe,SAAS;EAEpD,IADiB,6BAA6B,KAClC,EAEV,MAAM,IAAI,WACR,0FACD;EAGH,OAAO;EAEP,eAAe,WAAW;QACrB;EAEL,MAAM,QAAQ,eAAe,GAAG;EAChC,eAAe,WAAW,IAAI,WAAW,MAAM;EAC/C,eAAe,kBAAkB;EACjC,OAAO;;CAUX,KAAK,KAAM,KAAK,KAAK,KAAQ;CAC7B,KAAK,KAAM,KAAK,KAAK,KAAQ;CAE7B,MAAM,UAAU,MAAM,KAAK,OAAO,MAAM,UAAU,GAAG,CAAC,KAAK,GAAG;CAc9D,OAAO;EANO,MAAM,MAAM,GAAG,EAMhB;EALC,MAAM,MAAM,GAAG,GAKT;EAJN,QAAQ,MAAM,GAAG,EAIJ;EAHb,QAAQ,MAAM,GAAG,EAGG;EAFpB,QAAQ,MAAM,GAAG,GAEU;EAAC,CAAC,KAAK,IAAI"}
1
+ {"version":3,"file":"index.cjs","names":["isNonEmptyArray","isInteger","getPreciseType","safeStableStringify","isNumber","isPlainObject","isInteger","getPreciseType","safeStableStringify","isPlainObject","isInteger","getPreciseType","safeStableStringify","isNaN","isPlainObject","getPreciseType","safeStableStringify","isNonEmptyString","isBoolean"],"sources":["../../src/generators/random/array/getRandomItem.ts","../../src/generators/random/integer/randomInt.ts","../../src/generators/random/integer/randomIntByLength.ts","../../src/generators/random/string/randomStr.ts","../../src/generators/random/uuid/randomUUID.ts"],"sourcesContent":["import type {\n Extends,\n FixNeverArrayRecursive,\n IfNonEmptyArray,\n NullToUndefined\n} from \"@rzl-zone/ts-types-plus\";\n\nimport { isNonEmptyArray } from \"@/predicates/is/isNonEmptyArray\";\n\n/** ---------------------------------\n * * ***Utility: `getRandomItem`.***\n * ---------------------------------\n * **Function to get a random element from a given array.**\n * @template T - The type of the input array.\n * @param {*} array - The input array, can be `null`, `undefined`, or an empty array.\n * @returns\n * - If `array` is a non-empty tuple, returns one of its elements.\n * - If `array` is empty, `null`, or `undefined`, returns `undefined`.\n * @example\n * getRandomItem([]);\n * // ➔ undefined\n * getRandomItem(null);\n * // ➔ undefined\n * getRandomItem(undefined);\n * // ➔ undefined\n * getRandomItem([1, 2, 3, 4]);\n * // ➔ number\n * getRandomItem([\"apple\", \"banana\", \"cherry\"]);\n * // ➔ string\n * getRandomItem([\"apple\", 123, true]);\n * // ➔ string | number | boolean\n * getRandomItem([\"apple\", 123, true, null]);\n * // ➔ string | number | boolean | undefined\n * getRandomItem([\"apple\", 123, true, undefined]);\n * // ➔ string | number | boolean | undefined\n *\n * // Tuple example:\n * const tuple = [1, \"two\", true] as const;\n * getRandomItem(tuple); // 1 | \"two\" | true\n */\nexport function getRandomItem(array: undefined): undefined;\nexport function getRandomItem(array: []): undefined;\nexport function getRandomItem<T extends readonly unknown[]>(\n array: T\n): T extends never[][]\n ? undefined\n : number extends T[\"length\"]\n ? NullToUndefined<FixNeverArrayRecursive<T[number]>>\n : IfNonEmptyArray<\n T,\n NullToUndefined<FixNeverArrayRecursive<T[number]>>,\n undefined\n >;\nexport function getRandomItem<T extends readonly unknown[] | undefined | null>(\n array: T\n): T extends readonly unknown[]\n ? NullToUndefined<FixNeverArrayRecursive<T[number]>> | undefined\n : undefined;\nexport function getRandomItem<T>(array: T): unknown extends T\n ? unknown\n : // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Extends<any[] | readonly any[], T> extends true\n ? Extract<T, unknown[] | readonly unknown[]>[number] | undefined\n : // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Extends<any[], T> extends true\n ? Extract<T, unknown[] | readonly unknown[]>[number] | undefined\n : // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Extends<readonly any[], T> extends true\n ? Extract<T, unknown[] | readonly unknown[]>[number] | undefined\n : undefined;\nexport function getRandomItem(array: unknown): unknown {\n if (!isNonEmptyArray(array)) return undefined;\n\n const randomIndex = Math.floor(Math.random() * (array.length || 0));\n return array[randomIndex];\n}\n","import { isNumber } from \"@/predicates/is/isNumber\";\nimport { isInteger } from \"@/predicates/is/isInteger\";\nimport { getPreciseType } from \"@/predicates/type/getPreciseType\";\nimport { safeStableStringify } from \"@/conversions/stringify/safeStableStringify\";\n\n/** -----------------------------------------------------------------------\n * * ***Utility: `randomInt`.***\n * ------------------------------------------------------------------------\n * **Generates a random integer within a specified range (inclusive).**\n * - **Generates a random integer between `min` and `max` (inclusive), with safety constraints:**\n * - `min` will be forced to be at least `1`.\n * - `max` will be capped at `Number.MAX_SAFE_INTEGER`.\n * @param {number} min - The minimum value (inclusive), must be an integer.\n * @param {number} max - The maximum value (inclusive), must be an integer.\n * @returns {number} A random integer N where `min ≤ N ≤ max`.\n * @throws **{@link TypeError | `TypeError`}** if:\n * - `min` or `max` is not an integer, or value is `Number.MIN_VALUE`.\n * - `min` is greater than `max`.\n * @example\n * randomInt(1, 10); // ➔ returns 1 up-to 10 (random)\n * randomInt(50, 100); // ➔ returns 50 up-to 100 (random)\n * randomInt(5, 5); // ➔ always returns 5 (exact)\n * randomInt(-5, 3); // ➔ always returns ≥ 1, since min is adjusted (exact)\n * randomInt(1, Number.MAX_SAFE_INTEGER + 10000);\n * // ➔ still safely capped at MAX_SAFE_INTEGER\n * randomInt(Number.MIN_VALUE, 3);\n * // ➔ Error, min or max cant be as `Number.MIN_VALUE` value.\n */\nexport const randomInt = (min: number, max: number): number => {\n if (!isInteger(min) || !isInteger(max)) {\n throw new TypeError(\n `First parameter (\\`min\\`) and second parameter (\\`max\\`) must be of type \\`integer-number\\`${minValueNote(\n min,\n max\n )}value, but received: ['min': \\`${getPreciseType(\n min\n )}\\` - (with value: \\`${safeStableStringify(min, {\n keepUndefined: true\n })})\\`, 'max': \\`${getPreciseType(max)}\\` - (with value: \\`${safeStableStringify(\n max,\n {\n keepUndefined: true\n }\n )}\\`)].`\n );\n }\n if (min > max) {\n throw new RangeError(\n `First parameter (\\`min\\`) must be less than or equal to second parameter (\\`max\\`), but received: ['min': ${formatValue(\n min\n )} - (with value: \\`${safeStableStringify(min, {\n keepUndefined: true\n })})\\`, 'max': ${formatValue(max)} - (with value: \\`${safeStableStringify(\n max,\n {\n keepUndefined: true\n }\n )})\\`].`\n );\n }\n\n // Ensure `min` is at least 1\n min = Math.max(1, min);\n\n // Ensure `max` does not exceed Number.MAX_SAFE_INTEGER\n max = Math.min(Number.MAX_SAFE_INTEGER, max);\n\n return Math.floor(Math.random() * (max - min + 1)) + min;\n};\n\nconst formatValue = (value: unknown): string => {\n return isNumber(value, { includeNaN: true })\n ? value === Number.MIN_VALUE\n ? \"`Number.MIN_VALUE`\"\n : `${value}`\n : `\\`${getPreciseType(value)}\\``;\n};\n\nconst minValueNote = (...values: unknown[]) => {\n return values.some(\n (v) => isNumber(v, { includeNaN: true }) && v === Number.MIN_VALUE\n )\n ? \" and can't be `Number.MIN_VALUE` \"\n : \" \";\n};\n","import { randomInt } from \"./randomInt\";\nimport { isInteger } from \"@/predicates/is/isInteger\";\nimport { isPlainObject } from \"@/predicates/is/isPlainObject\";\nimport { getPreciseType } from \"@/predicates/type/getPreciseType\";\nimport { assertIsBoolean } from \"@/assertions/booleans/assertIsBoolean\";\nimport { safeStableStringify } from \"@/conversions/stringify/safeStableStringify\";\n\ntype OptionsRandomIntByLength = {\n /** * Minimum length of the random number, the `allowed minimal value` `integer` is `1` `and not bigger than value of` `maxLength`, defaultValue: `1`.\n *\n * @default 1\n */\n minLength?: number;\n /** * Maximum length of the random number, the `allowed maximal value` `integer` is `16`, defaultValue: `16`.\n *\n * @default 16\n */\n maxLength?: number;\n /** * If true, prevents the result from being zero, defaultValue: `false`.\n *\n * @default false\n */\n avoidZero?: boolean;\n};\n\n/** ----------------------------------------------------------------------------\n * * ***Utility: `randomIntByLength`.***\n * -----------------------------------------------------------------------------\n * **Generates a random integer within a specified range of digit lengths.**\n * @description\n * This function allows generating random integers that strictly conform to a specified minimum and\n * maximum digit length, it is useful for scenarios such as generating realistic-looking IDs, codes,\n * or random test data.\n * - **The function ensures:**\n * - `minLength` is at least 1 and not greater than `maxLength`.\n * - `maxLength` is no more than 16 (due to JavaScript's `Number.MAX_SAFE_INTEGER`).\n * - If `avoidZero` is `true`, ensures that `0` is never returned.\n * @param {OptionsRandomIntByLength} [options] - Configuration options.\n * @param {OptionsRandomIntByLength[\"minLength\"]} [options.minLength=1] - Minimum number of digits (must be ≥ `1` and ≤ `maxLength`).\n * @param {OptionsRandomIntByLength[\"maxLength\"]} [options.maxLength=16] - Maximum number of digits (must be ≤ `16`).\n * @param {OptionsRandomIntByLength[\"avoidZero\"]} [options.avoidZero=false] - If true, will ensure the result is never zero.\n * @returns {number} A randomly generated integer within the specified constraints.\n * @throws **{@link TypeError | `TypeError`}** if parameters are invalid, such as:\n * - `minLength` < `1`\n * - `maxLength` > `16`\n * - `minLength` > `maxLength`\n * - non-integer values for `minLength` or `maxLength`\n * @example\n * randomIntByLength({ minLength: 3, maxLength: 5 });\n * // ➔ `4829` (random), `192` (random) or `71492` (random).\n * randomIntByLength({ minLength: 4, maxLength: 4 });\n * // ➔ `5930` (exact 4 digits)\n * randomIntByLength({ avoidZero: true });\n * // ➔ never 0\n */\nexport const randomIntByLength = (\n options?: OptionsRandomIntByLength\n): number => {\n // Ensure options is an object and Defensive options check\n if (!isPlainObject(options)) {\n options = {};\n }\n\n const { minLength = 1, maxLength = 16, avoidZero = false } = options;\n\n assertIsBoolean(avoidZero, {\n message({ currentType, validType }) {\n return `Parameters \\`avoidZero\\` must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`;\n }\n });\n\n // Validate `minLength` & `maxLength` type\n if (!isInteger(minLength) || !isInteger(maxLength)) {\n throw new TypeError(\n `Parameters \\`minLength\\` and \\`maxLength\\` must be of type \\`integer-number\\`, but received: ['minLength': \\`${getPreciseType(\n minLength\n )}\\` - (with value: ${safeStableStringify(minLength, {\n keepUndefined: true\n })}), 'maxLength': \\`${getPreciseType(\n maxLength\n )}\\` - (with value: ${safeStableStringify(maxLength, {\n keepUndefined: true\n })})].`\n );\n }\n\n // Validate `minLength` & `maxLength` range.\n if (minLength < 1 || maxLength > 16 || minLength > maxLength) {\n throw new RangeError(\n `Invalid range at parameters \\`minLength\\` must be ≥ 1, \\`maxLength\\` must be ≤ 16, and \\`minLength\\` ≤ \\`maxLength\\`, but received: ['minLength': \\`${minLength}\\`, 'maxLength': \\`${maxLength}\\`].`\n );\n }\n\n // Generate a random length between minLength and maxLength\n const randomLength =\n minLength === maxLength ? minLength : randomInt(minLength, maxLength);\n\n // Define min and max value based on the selected length\n const minValue = 10 ** (randomLength - 1); // Example: minLength=3 ➔ minValue=100\n const maxValue = 10 ** randomLength - 1; // Example: maxLength=4 ➔ maxValue=9999\n\n // Generate a random number within the valid range\n let result = randomInt(minValue, maxValue);\n\n // Ensure the number is not zero if `avoidZero` is true\n if (avoidZero && result === 0) {\n result = minValue; // Assign the smallest valid number instead of looping\n }\n\n return result;\n};\n","import type { OptionsRandomStr } from \"./_private/randomSTR.types\";\n\nimport { randomInt } from \"../integer/randomInt\";\n\nimport { isNaN } from \"@/predicates/is/isNaN\";\nimport { isInteger } from \"@/predicates/is/isInteger\";\nimport { isPlainObject } from \"@/predicates/is/isPlainObject\";\nimport { getPreciseType } from \"@/predicates/type/getPreciseType\";\n\nimport { assertIsBoolean } from \"@/assertions/booleans/assertIsBoolean\";\nimport { safeStableStringify } from \"@/conversions/stringify/safeStableStringify\";\n\n/** ---------------------------------------------------------------------------------\n * * ***Utility: `randomStr`.***\n * ---------------------------------------------------------------------------------\n * **Generates a random alphanumeric string or number with a specified length range.**\n * @description\n * This function allows you to generate random strings or numbers with fully\n * customizable options, such as length range, character sets, inclusion of\n * additional characters, and whether to avoid whitespace.\n * @param {OptionsRandomStr} [options] - Configuration options for generating the string.\n * @param {OptionsRandomStr[\"minLength\"]} [options.minLength=40] - Minimum length of the generated string (must be `≥` `1`).\n * @param {OptionsRandomStr[\"maxLength\"]} [options.maxLength=40] - Maximum length of the generated string (must be `≤` `5000`).\n * @param {OptionsRandomStr[\"type\"]} [options.type=\"string\"] - Whether to generate a general alphanumeric string or purely numeric string.\n * @param {OptionsRandomStr[\"avoidWhiteSpace\"]} [options.avoidWhiteSpace=true] - If true, removes all whitespace, tabs, and newlines from the character set before generating.\n * @param {OptionsRandomStr[\"replaceGenStr\"]} [options.replaceGenStr] - A custom character set to use when `type` is `\"string\"`.\n * @param {OptionsRandomStr[\"replaceGenInt\"]} [options.replaceGenInt] - A custom character set to use when `type` is `\"number\"`.\n * @param {OptionsRandomStr[\"addChar\"]} [options.addChar] - Additional characters to always include in the character set.\n * @returns {string} The randomly generated string or numeric string of the desired length.\n * @throws **{@link TypeError | `TypeError`}** if provided options are invalid (such as minLength > maxLength, invalid type, or empty character set).\n * @example\n * randomStr();\n * // ➔ Generates a 40-character random alphanumeric string\n * randomStr({ minLength: 10, maxLength: 20 });\n * // ➔ Generates a string between 10 and 20 characters\n * randomStr({ type: \"number\", minLength: 5, maxLength: 5 });\n * // ➔ \"48302\"\n * randomStr({ replaceGenStr: \"ABC \", avoidWhiteSpace: false });\n * // ➔ String using A, B, C and space\n * randomStr({ addChar: \"!@#\", minLength: 15, maxLength: 15 });\n * // ➔ Guaranteed to include !@# in the set\n */\nexport const randomStr = (options?: OptionsRandomStr): string => {\n // Ensure options is an object and Defensive options check\n if (!isPlainObject(options)) {\n options = {};\n }\n\n const {\n minLength = 40,\n maxLength = 40,\n type = \"string\",\n avoidWhiteSpace = true\n } = options;\n\n // Validate `avoidWhiteSpace`\n assertIsBoolean(avoidWhiteSpace, {\n message({ currentType, validType }) {\n return `Parameters \\`avoidWhiteSpace\\` property of the \\`options\\` (first-parameter) must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`;\n }\n });\n\n // Validate `minLength` & `maxLength` type\n if (!isInteger(minLength) || !isInteger(maxLength)) {\n throw new TypeError(\n `Parameters \\`minLength\\` and \\`maxLength\\` must be of type \\`integer-number\\`, but received: ['minLength': \\`${getPreciseType(\n minLength\n )}\\` - (with value: ${safeStableStringify(minLength, {\n keepUndefined: true\n })}), 'maxLength': \\`${getPreciseType(\n maxLength\n )}\\` - (with value: ${safeStableStringify(maxLength, {\n keepUndefined: true\n })})].`\n );\n }\n\n // Validate `minLength` & `maxLength` range.\n if (minLength < 1 || maxLength > 5000 || minLength > maxLength) {\n throw new RangeError(\n `Invalid range at parameters \\`minLength\\` must be ≥ 1, \\`maxLength\\` must be ≤ 5000, and \\`minLength\\` ≤ \\`maxLength\\`, but received: ['minLength': \\`${minLength}\\`, 'maxLength': \\`${maxLength}\\`].`\n );\n }\n\n // Validate `type` value props (is not typeof)\n if (type !== \"string\" && type !== \"number\") {\n throw new TypeError(\n `Parameter \\`type\\` must be of type \\`string\\` with value one of \"string\" | \"number\", but received: \\`${getPreciseType(\n type\n )}\\`, with value: ${safeStableStringify(type, {\n keepUndefined: true\n })}.`\n );\n }\n\n // Generate a random length within the range\n const length = randomInt(minLength, maxLength);\n\n // Function to clean characters based on `avoidWhiteSpace`\n const cleanCharacters = (charSet: string) => {\n return avoidWhiteSpace ? charSet.replace(/\\s|\\n|\\t/g, \"\") : charSet;\n };\n\n // Define character sets\n const defaultNumberSet = \"0123456789\";\n const defaultStringSet =\n \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\n\n const baseCharSet =\n type === \"number\"\n ? ((!isNaN(Number(options.replaceGenInt))\n ? options.replaceGenInt\n : undefined) ?? defaultNumberSet)\n : ((options.replaceGenStr ? options.replaceGenStr : undefined) ??\n defaultStringSet);\n\n // Get the final character set\n const characterSet = cleanCharacters(baseCharSet) + (options.addChar || \"\");\n\n // Ensure characterSet is not empty\n if (!characterSet.length) {\n const errCharSet = () => {\n if (type === \"number\") {\n if (avoidWhiteSpace) {\n return \"If `avoidWhiteSpace` is true, and `replaceGenInt` cant be empty-string value, ensure `replaceGenInt` has valid characters and non-nan string number.\";\n }\n return \"Ensure `replaceGenInt` has valid characters and not a NaN number string while convert to number.\";\n }\n return \"Ensure `replaceGenStr` has valid characters and non empty string.\";\n };\n\n throw new Error(`Character set is empty. ${errCharSet()}`);\n }\n\n // Generate random string\n let result = \"\";\n for (let i = 0; i < length; i++) {\n result += characterSet.charAt(\n Math.floor(Math.random() * characterSet.length)\n );\n }\n\n return result;\n};\n","import { isBoolean } from \"@/predicates/is/isBoolean\";\nimport { isPlainObject } from \"@/predicates/is/isPlainObject\";\nimport { getPreciseType } from \"@/predicates/type/getPreciseType\";\nimport { isNonEmptyString } from \"@/predicates/is/isNonEmptyString\";\nimport { safeStableStringify } from \"@/conversions/stringify/safeStableStringify\";\n\n/**\n * Configuration options for `randomUUID()`.\n */\ntype OptionsRandomUUID = {\n /**\n * Specifies which UUID version to generate.\n *\n * - `\"v4\"` — Fully random UUID (RFC 4122). No timestamp, no ordering guarantees.\n * - `\"v7\"` — Time-ordered UUID (RFC 9562). Uses Unix timestamp + randomness.\n *\n * @default \"v4\"\n *\n * @example\n * // Random v4 UUID\n * randomUUID({ version: \"v4\" }); // ➔ \"3ec0de5a-b8a9-4ffb-a62a-fcc76851e9c2\"\n *\n * @example\n * // Time-ordered v7 UUID\n * randomUUID({ version: \"v7\" }); // ➔ \"0199f3f6-3c5e-744b-affa-46b2cfd496f8\"\n */\n version?: \"v4\" | \"v7\";\n\n /**\n * Enables monotonic sequencing for UUID v7.\n *\n * - Guarantees that multiple UUIDs generated within the same millisecond\n * are strictly non-decreasing (lexicographically and timestamp-wise).\n * - Only valid when `version === \"v7\"`. Using with `v4` will throw a `TypeError`.\n * - Useful for database inserts, logs, or any system where order matters.\n *\n * @default false\n *\n * @example\n * // Monotonic v7 UUIDs\n * const a = randomUUID({ version: \"v7\", monotonic: true });\n * const b = randomUUID({ version: \"v7\", monotonic: true });\n * console.log(a < b); // true, guaranteed\n */\n monotonic?: boolean;\n};\n\n/** -----------------------------------------------------------------------\n * * ***Utility: `randomUUID`.***\n * ------------------------------------------------------------------------\n * **Generates a UUID string according to the specified version and options.**\n *\n * - **Supported versions**:\n * - **`\"v4\"` (default)** ➔ Fully random UUID, RFC 4122 compliant.\n * - Uses `crypto.randomUUID()` if available.\n * - Falls back to `crypto.getRandomValues()` or `Math.random()`\n * if needed.\n * - **`\"v7\"`** ➔ Time-ordered UUID, RFC 9562 compliant.\n * - Timestamp (Unix ms, 48 bits) + 80 bits randomness.\n * - Good for database indexing / sorting.\n * - **`\"v7\"` + `monotonic: true`** ➔ Ensures strictly non-decreasing UUIDs\n * for multiple calls in the same millisecond (per-process).\n *\n * - **Behavior / Safety Notes**:\n * - **v4**: Fully random; probability of duplicates is astronomically low.\n * - **v7**: Time-ordered; collisions extremely unlikely unless same ms + random repeat.\n * - **Monotonic v7**: Guaranteed ordering per-process if multiple UUIDs are generated\n * in the same millisecond.\n * - **All versions**: Fallback safely if `crypto` APIs are unavailable.\n *\n * @param {object} [options] - Optional settings object.\n * @param {\"v4\" | \"v7\"} [options.version=\"v4\"] - UUID version to generate.\n * @param {boolean} [options.monotonic=false] - For v7 only: generate monotonic UUIDs\n * to maintain strict lexicographic order\n * when generating multiple UUIDs within the same ms.\n *\n * @returns {string} A 36-character UUID string compliant with the selected version.\n *\n * @throws **{@link TypeError | `TypeError`}** if:\n * - `options` is not a plain object.\n * - `options.version` is provided but not a string.\n * - `options.monotonic` is provided but not a boolean.\n * - `monotonic: true` is used with `version` other than `\"v7\"`.\n * @throws **{@link RangeError | `RangeError`}** if `options.version` is provided but not `\"v4\"` or `\"v7\"`.\n *\n * @example\n * // Default (v4)\n * const id = randomUUID();\n * // ➔ \"3b12f1df-5232-4804-897e-917bf397618a\"\n *\n * @example\n * // Explicit v4\n * const id4 = randomUUID({ version: \"v4\" });\n *\n * @example\n * // Time-ordered v7\n * const id7 = randomUUID({ version: \"v7\" });\n * // ➔ \"018f48d2-84c1-7ccd-b5a3-2f9463b3a889\"\n *\n * @example\n * // Monotonic v7\n * const a = randomUUID({ version: \"v7\", monotonic: true });\n * const b = randomUUID({ version: \"v7\", monotonic: true });\n * // a < b lexicographically (guaranteed)\n *\n * @example\n * // Throws TypeError\n * randomUUID(\"v4\" as any); // options must be object\n * randomUUID({ version: 123 as any }); // version must be string\n * randomUUID({ version: \"v4\", monotonic: true } as any); // monotonic only for v7\n *\n * @example\n * // Throws RangeError\n * randomUUID({ version: \"v1\" as any }); // unsupported version\n */\nexport function randomUUID(options: OptionsRandomUUID = {}): string {\n // Validate options is a plain object if provided\n if (!isPlainObject(options)) {\n throw new TypeError(\n `First parameter (\\`options\\`) must be a plain object with optional properties \\`version\\` and \\`monotonic\\`, but received: \\`${getPreciseType(\n options\n )}\\` - (with value: \\`${safeStableStringify(options, { keepUndefined: true })}\\`).`\n );\n }\n\n const { version = \"v4\", monotonic = false } = options;\n\n // Validate version type\n if (!isNonEmptyString(version)) {\n throw new TypeError(\n `Parameter \\`version\\` property of the \\`options\\` (first parameter) must be a \\`string\\` of either \"v4\" or \"v7\", but received type: \\`${getPreciseType(\n version\n )}\\` - (with value: \\`${safeStableStringify(version, { keepUndefined: true })}\\`).`\n );\n }\n\n if (version !== \"v4\" && version !== \"v7\") {\n throw new RangeError(\n `Unsupported UUID version. Allowed values are \"v4\" or \"v7\". (received: \\`${safeStableStringify(\n version,\n {\n keepUndefined: true\n }\n )}\\`).`\n );\n }\n\n // Validate monotonic type\n if (!isBoolean(monotonic)) {\n throw new TypeError(\n `Parameter \\`monotonic\\` property of the \\`options\\` (first parameter) must be a \\`boolean\\` when provided, but received type: \\`${getPreciseType(\n monotonic\n )}\\` - (with value: \\`${safeStableStringify(monotonic, {\n keepUndefined: true\n })}\\`).`\n );\n }\n\n // monotonic only allowed with v7\n if (monotonic && version !== \"v7\") {\n throw new TypeError(\n `Parameter \\`monotonic\\` property of the \\`options\\` (first parameter) is only supported for version \"v7\". Received: version=${safeStableStringify(\n version,\n { keepUndefined: true }\n )}.`\n );\n }\n\n if (version === \"v4\") {\n return generateUUIDv4();\n }\n\n // version === \"v7\"\n return generateUUIDv7({ monotonic });\n}\n\n//todo: Helpers & Implementations\n\nfunction hasCryptoGetRandomValues(): boolean {\n return (\n typeof crypto !== \"undefined\" &&\n typeof crypto.getRandomValues === \"function\"\n );\n}\n\nfunction hasCryptoRandomUUID(): boolean {\n return (\n typeof crypto !== \"undefined\" && typeof crypto.randomUUID === \"function\"\n );\n}\n\nfunction getRandomBytes(len: number): Uint8Array {\n if (hasCryptoGetRandomValues()) {\n return crypto.getRandomValues(new Uint8Array(len));\n }\n // Fallback: not cryptographically secure, but avoids crash\n const arr = new Uint8Array(len);\n for (let i = 0; i < len; i++) {\n arr[i] = Math.floor(Math.random() * 256);\n }\n return arr;\n}\n\nconst byteToHex: string[] = (() => {\n const arr: string[] = [];\n for (let i = 0; i < 256; ++i) {\n arr.push((i + 0x100).toString(16).substring(1));\n }\n return arr;\n})();\n\nfunction generateUUIDv4(): string {\n // Prefer native if available\n if (hasCryptoRandomUUID()) {\n return crypto.randomUUID();\n }\n\n // If crypto.getRandomValues available, use it for 16 bytes\n if (hasCryptoGetRandomValues()) {\n const rnd = crypto.getRandomValues(new Uint8Array(16));\n\n if (\n !rnd[0] ||\n !rnd[1] ||\n !rnd[2] ||\n !rnd[3] ||\n !rnd[4] ||\n !rnd[5] ||\n !rnd[6] ||\n !rnd[7] ||\n !rnd[8] ||\n !rnd[9] ||\n !rnd[10] ||\n !rnd[11] ||\n !rnd[12] ||\n !rnd[13] ||\n !rnd[14] ||\n !rnd[15]\n ) {\n return \"\";\n }\n\n const byteToHex0 = byteToHex[rnd[0]];\n const byteToHex1 = byteToHex[rnd[1]];\n\n if (!byteToHex0 || !byteToHex1) return \"\";\n\n // Per RFC 4122: set version and variant\n rnd[6] = (rnd[6]! & 0x0f) | 0x40; // version 4\n rnd[8] = (rnd[8]! & 0x3f) | 0x80; // variant 10xx\n\n return (\n byteToHex0 +\n byteToHex1 +\n byteToHex[rnd[2]] +\n byteToHex[rnd[3]] +\n \"-\" +\n byteToHex[rnd[4]] +\n byteToHex[rnd[5]] +\n \"-\" +\n byteToHex[rnd[6]] +\n byteToHex[rnd[7]] +\n \"-\" +\n byteToHex[rnd[8]] +\n byteToHex[rnd[9]] +\n \"-\" +\n byteToHex[rnd[10]] +\n byteToHex[rnd[11]] +\n byteToHex[rnd[12]] +\n byteToHex[rnd[13]] +\n byteToHex[rnd[14]] +\n byteToHex[rnd[15]]\n );\n }\n\n // Last-resort fallback using Math.random (not crypto-secure)\n return \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g, (c) => {\n const r = (Math.random() * 16) | 0;\n const v = c === \"x\" ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n}\n\n/* ---------------------------\n Monotonic state (singleton per-process)\n --------------------------- */\n\n/**\n * Internal monotonic state:\n * - lastTimestampMs: last generated timestamp (ms)\n * - lastRand: last random 10-byte block used for v7 (used to increment on same ms)\n */\nconst monotonicState: {\n lastTimestampMs: number;\n lastRand: Uint8Array | null;\n} = {\n lastTimestampMs: -1,\n lastRand: null\n};\n\nfunction incrementUint8ArrayBigEndian(arr: Uint8Array): boolean {\n // Increment arr in big-endian order. Return true if overflowed back to zero.\n for (let i = arr.length - 1; i >= 0; i--) {\n if (arr[i] === 0xff) {\n arr[i] = 0x00;\n continue;\n }\n\n arr[i] = (arr[i]! + 1) & 0xff;\n\n return false; // no overflow\n }\n // overflowed (wrapped to zero)\n return true;\n}\n\nfunction generateUUIDv7({\n monotonic = false\n}: { monotonic?: boolean } = {}): string {\n const nowMs = Date.now();\n const tsHex = BigInt(nowMs).toString(16).padStart(12, \"0\"); // 48 bits ➔ 12 hex chars\n\n // We'll use 10 random bytes (80 bits)\n let rand = getRandomBytes(10);\n\n if (monotonic) {\n // ensure monotonicState is consistent per-process\n if (monotonicState.lastTimestampMs === nowMs && monotonicState.lastRand) {\n // We are in the same ms bucket — increment lastRand (big-endian)\n const copy = new Uint8Array(monotonicState.lastRand); // copy for use\n const overflow = incrementUint8ArrayBigEndian(copy);\n if (overflow) {\n // Practically impossible (2^80 increments in 1ms). Throw to be safe.\n throw new RangeError(\n \"Monotonic UUID sequence overflow: too many UUIDs generated within the same millisecond.\"\n );\n }\n // use incremented copy as rand\n rand = copy;\n // update state\n monotonicState.lastRand = copy;\n } else {\n // New ms: generate fresh randomness and store\n const fresh = getRandomBytes(10);\n monotonicState.lastRand = new Uint8Array(fresh);\n monotonicState.lastTimestampMs = nowMs;\n rand = fresh;\n }\n }\n\n // if (!rand[0] || !rand[2]) return \"\";\n // If not monotonic, rand remains randomly generated above.\n\n // Now set version & variant bits into proper positions.\n // For v7 layout we used: timestamp (48 bits) + rand[0..9] (80 bits)\n // We must set version nibble into high nibble of rand[0] (time_hi_and_version)\n // and set variant bits into rand[2]'s high bits (clock_seq_hi_and_reserved)\n rand[0] = rand[0] ? (rand[0] & 0x0f) | 0x70 : 0; // version 7 (0x7 << 4)\n rand[2] = rand[2] ? (rand[2] & 0x3f) | 0x80 : 0; // variant 10xx\n\n const randHex = Array.from(rand, (b) => byteToHex[b]).join(\"\");\n\n // Assemble UUID groups:\n // - 8 hex (timestamp[0..7])\n // - 4 hex (timestamp[8..11])\n // - 4 hex (rand[0..1]) ➔ contains version in high nibble of rand[0]\n // - 4 hex (rand[2..3]) ➔ contains variant in high bits of rand[2]\n // - 12 hex (rand[4..9])\n const part1 = tsHex.slice(0, 8);\n const part2 = tsHex.slice(8, 12);\n const part3 = randHex.slice(0, 4);\n const part4 = randHex.slice(4, 8);\n const part5 = randHex.slice(8, 20);\n\n return [part1, part2, part3, part4, part5].join(\"-\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAsEA,SAAgB,cAAc,OAAyB;CACrD,IAAI,CAACA,wCAAgB,MAAM,EAAE,OAAO;CAGpC,OAAO,MADa,KAAK,MAAM,KAAK,QAAQ,IAAI,MAAM,UAAU,GACxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC9C1B,MAAa,aAA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U;EAEvE,MAAM,OAAO,IAAI,WAAW,eAAe,SAAS;EAEpD,IADiB,6BAA6B,KAClC,EAEV,MAAM,IAAI,WACR,0FACD;EAGH,OAAO;EAEP,eAAe,WAAW;QACrB;EAEL,MAAM,QAAQ,eAAe,GAAG;EAChC,eAAe,WAAW,IAAI,WAAW,MAAM;EAC/C,eAAe,kBAAkB;EACjC,OAAO;;CAWX,KAAK,KAAK,KAAK,KAAM,KAAK,KAAK,KAAQ,MAAO;CAC9C,KAAK,KAAK,KAAK,KAAM,KAAK,KAAK,KAAQ,MAAO;CAE9C,MAAM,UAAU,MAAM,KAAK,OAAO,MAAM,UAAU,GAAG,CAAC,KAAK,GAAG;CAc9D,OAAO;EANO,MAAM,MAAM,GAAG,EAMhB;EALC,MAAM,MAAM,GAAG,GAKT;EAJN,QAAQ,MAAM,GAAG,EAIJ;EAHb,QAAQ,MAAM,GAAG,EAGG;EAFpB,QAAQ,MAAM,GAAG,GAEU;EAAC,CAAC,KAAK,IAAI"}
@@ -2,11 +2,11 @@
2
2
  * ========================================================================
3
3
  * @rzl-zone/utils-js
4
4
  * ------------------------------------------------------------------------
5
- * Version: `3.12.1-beta.0`
5
+ * Version: `3.12.1-beta.1`
6
6
  * Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
7
7
  * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
8
8
  * ========================================================================
9
9
  */
10
10
 
11
- import { a as randomInt, i as randomIntByLength, n as randomUUID, o as getRandomItem, r as randomStr, t as noop } from "../index-DnM0LD0n.cjs";
11
+ import { a as randomInt, i as randomIntByLength, n as randomUUID, o as getRandomItem, r as randomStr, t as noop } from "../index-gBA_8SuF.cjs";
12
12
  export { getRandomItem, noop, randomInt, randomIntByLength, randomStr, randomUUID };
@@ -2,11 +2,11 @@
2
2
  * ========================================================================
3
3
  * @rzl-zone/utils-js
4
4
  * ------------------------------------------------------------------------
5
- * Version: `3.12.1-beta.0`
5
+ * Version: `3.12.1-beta.1`
6
6
  * Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
7
7
  * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
8
8
  * ========================================================================
9
9
  */
10
10
 
11
- import { a as randomInt, i as randomIntByLength, n as randomUUID, o as getRandomItem, r as randomStr, t as noop } from "../index-Czc4O526.js";
11
+ import { a as randomInt, i as randomIntByLength, n as randomUUID, o as getRandomItem, r as randomStr, t as noop } from "../index-59zbLcPr.js";
12
12
  export { getRandomItem, noop, randomInt, randomIntByLength, randomStr, randomUUID };
@@ -2,15 +2,15 @@
2
2
  * ========================================================================
3
3
  * @rzl-zone/utils-js
4
4
  * ------------------------------------------------------------------------
5
- * Version: `3.12.1-beta.0`
5
+ * Version: `3.12.1-beta.1`
6
6
  * Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
7
7
  * Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
8
8
  * ========================================================================
9
9
  */
10
- import { A as isPlainObject, D as isNaN, F as isBoolean, p as isNonEmptyArray, r as getPreciseType, t as assertIsBoolean, w as isNumber, y as isNonEmptyString } from "../assertIsBoolean-BlBct0Fc.js";
11
- import { t as safeStableStringify } from "../safeStableStringify-BNh3D0K0.js";
12
- import { t as noop } from "../noop-BzktGBVz.js";
13
- import { t as isInteger } from "../isInteger-DS9V7l_f.js";
10
+ import { A as isPlainObject, D as isNaN, F as isBoolean, p as isNonEmptyArray, r as getPreciseType, t as assertIsBoolean, w as isNumber, y as isNonEmptyString } from "../assertIsBoolean-DR1SaXPD.js";
11
+ import { t as safeStableStringify } from "../safeStableStringify-CXOZ9Ub8.js";
12
+ import { t as noop } from "../noop-ubqAIbHD.js";
13
+ import { t as isInteger } from "../isInteger-naMbJsxJ.js";
14
14
  function getRandomItem(array) {
15
15
  if (!isNonEmptyArray(array)) return void 0;
16
16
  return array[Math.floor(Math.random() * (array.length || 0))];
@@ -101,9 +101,13 @@ function generateUUIDv4() {
101
101
  if (hasCryptoRandomUUID()) return crypto.randomUUID();
102
102
  if (hasCryptoGetRandomValues()) {
103
103
  const rnd = crypto.getRandomValues(new Uint8Array(16));
104
+ if (!rnd[0] || !rnd[1] || !rnd[2] || !rnd[3] || !rnd[4] || !rnd[5] || !rnd[6] || !rnd[7] || !rnd[8] || !rnd[9] || !rnd[10] || !rnd[11] || !rnd[12] || !rnd[13] || !rnd[14] || !rnd[15]) return "";
105
+ const byteToHex0 = byteToHex[rnd[0]];
106
+ const byteToHex1 = byteToHex[rnd[1]];
107
+ if (!byteToHex0 || !byteToHex1) return "";
104
108
  rnd[6] = rnd[6] & 15 | 64;
105
109
  rnd[8] = rnd[8] & 63 | 128;
106
- return byteToHex[rnd[0]] + byteToHex[rnd[1]] + byteToHex[rnd[2]] + byteToHex[rnd[3]] + "-" + byteToHex[rnd[4]] + byteToHex[rnd[5]] + "-" + byteToHex[rnd[6]] + byteToHex[rnd[7]] + "-" + byteToHex[rnd[8]] + byteToHex[rnd[9]] + "-" + byteToHex[rnd[10]] + byteToHex[rnd[11]] + byteToHex[rnd[12]] + byteToHex[rnd[13]] + byteToHex[rnd[14]] + byteToHex[rnd[15]];
110
+ return byteToHex0 + byteToHex1 + byteToHex[rnd[2]] + byteToHex[rnd[3]] + "-" + byteToHex[rnd[4]] + byteToHex[rnd[5]] + "-" + byteToHex[rnd[6]] + byteToHex[rnd[7]] + "-" + byteToHex[rnd[8]] + byteToHex[rnd[9]] + "-" + byteToHex[rnd[10]] + byteToHex[rnd[11]] + byteToHex[rnd[12]] + byteToHex[rnd[13]] + byteToHex[rnd[14]] + byteToHex[rnd[15]];
107
111
  }
108
112
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
109
113
  const r = Math.random() * 16 | 0;
@@ -140,8 +144,8 @@ function generateUUIDv7({ monotonic = false } = {}) {
140
144
  monotonicState.lastTimestampMs = nowMs;
141
145
  rand = fresh;
142
146
  }
143
- rand[0] = rand[0] & 15 | 112;
144
- rand[2] = rand[2] & 63 | 128;
147
+ rand[0] = rand[0] ? rand[0] & 15 | 112 : 0;
148
+ rand[2] = rand[2] ? rand[2] & 63 | 128 : 0;
145
149
  const randHex = Array.from(rand, (b) => byteToHex[b]).join("");
146
150
  return [
147
151
  tsHex.slice(0, 8),