@rzl-zone/utils-js 3.3.1 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/README.md +94 -45
  2. package/dist/assertions/index.cjs +34 -1
  3. package/dist/assertions/index.d.ts +2 -2
  4. package/dist/assertions/index.js +5 -1
  5. package/dist/chunk-2CQX5CBG.js +247 -1
  6. package/dist/chunk-2IOOEY45.cjs +20 -1
  7. package/dist/chunk-2WA36TC5.cjs +176 -0
  8. package/dist/chunk-3IBQ5MOM.js +6 -1
  9. package/dist/chunk-3VA554KW.js +23 -1
  10. package/dist/chunk-5757UBXJ.cjs +144 -1
  11. package/dist/chunk-5IGC6PBH.js +22 -1
  12. package/dist/chunk-5KJFVIQT.cjs +55 -1
  13. package/dist/chunk-6JFCSH7J.js +24 -1
  14. package/dist/chunk-6JFZL7YE.cjs +14 -1
  15. package/dist/chunk-7ODAAXX5.cjs +361 -1
  16. package/dist/chunk-BAV5T2E3.cjs +5 -1
  17. package/dist/chunk-CAH33WOQ.cjs +25 -1
  18. package/dist/chunk-CDCERIZ2.js +164 -0
  19. package/dist/chunk-CKTLUNWX.js +12 -1
  20. package/dist/chunk-CMW2TBOQ.js +522 -1
  21. package/dist/chunk-D3ENH7H6.cjs +87 -1
  22. package/dist/chunk-DEZZUYE2.js +139 -1
  23. package/dist/chunk-DVMHRLKP.cjs +6 -1
  24. package/dist/chunk-DWF2R5GD.cjs +212 -1
  25. package/dist/chunk-E55EQK2U.cjs +8 -1
  26. package/dist/chunk-E74U6CYP.cjs +8 -1
  27. package/dist/chunk-EL6A35UR.cjs +51 -1
  28. package/dist/chunk-F6IPNNSJ.cjs +531 -1
  29. package/dist/chunk-FJZGG54N.cjs +252 -1
  30. package/dist/chunk-FWCKOJZM.js +519 -1
  31. package/dist/chunk-FWHNWL2P.cjs +409 -1
  32. package/dist/chunk-GGEADHZO.js +78 -1
  33. package/dist/chunk-GQR4R5WY.js +21 -1
  34. package/dist/chunk-H66AC7GK.cjs +81 -1
  35. package/dist/chunk-HQWOFR56.cjs +23 -1
  36. package/dist/chunk-HYRQMTRH.cjs +14 -1
  37. package/dist/chunk-IRFL4MAX.js +53 -1
  38. package/dist/chunk-IVL7CKVH.cjs +26 -1
  39. package/dist/chunk-IZPBKKPO.js +6 -1
  40. package/dist/chunk-JBQMXC5I.cjs +93 -1
  41. package/dist/chunk-JEQEF5WD.js +81 -1
  42. package/dist/chunk-JMJQCN74.js +334 -1
  43. package/dist/chunk-KHO2SBNA.cjs +6 -1
  44. package/dist/chunk-KVAL5PAG.cjs +16 -1
  45. package/dist/chunk-L5RDAVVH.js +5 -1
  46. package/dist/chunk-LS6U7FAY.cjs +98 -1
  47. package/dist/chunk-NBZWMBO6.js +88 -1
  48. package/dist/chunk-NRF6LWBC.cjs +45 -1
  49. package/dist/chunk-OI5XKNZO.js +42 -1
  50. package/dist/chunk-ONZFBJVW.js +5 -1
  51. package/dist/chunk-OYTYSY7G.js +94 -1
  52. package/dist/chunk-PET42Z7W.js +107 -1
  53. package/dist/chunk-PZQ6I4JJ.cjs +559 -1
  54. package/dist/chunk-QBKAEVYG.js +102 -1
  55. package/dist/chunk-QNKGP5DY.js +5 -1
  56. package/dist/chunk-RIPKY4RU.js +407 -1
  57. package/dist/chunk-RZW35UN5.cjs +105 -1
  58. package/dist/chunk-SBFNXGTJ.js +207 -1
  59. package/dist/chunk-SBKGWRS5.js +12 -1
  60. package/dist/chunk-SIM77PU4.js +46 -1
  61. package/dist/chunk-T2T7K3KR.js +18 -1
  62. package/dist/chunk-T7PU2V7X.cjs +111 -1
  63. package/dist/chunk-UDA26MCU.cjs +6 -1
  64. package/dist/chunk-V45XJKHW.cjs +8 -1
  65. package/dist/chunk-VJDDGRIK.cjs +6 -1
  66. package/dist/chunk-W2WNBUDE.js +6 -1
  67. package/dist/chunk-WVSPXFTY.js +5 -1
  68. package/dist/chunk-XABCB3Y7.cjs +563 -1
  69. package/dist/chunk-XEDXFSGI.js +14 -1
  70. package/dist/chunk-YKPSRP5G.js +552 -1
  71. package/dist/chunk-YWHHVDT4.js +4 -1
  72. package/dist/chunk-ZETAZZLD.cjs +27 -1
  73. package/dist/conversions/index.cjs +97 -1
  74. package/dist/conversions/index.d.ts +2 -2
  75. package/dist/conversions/index.js +16 -1
  76. package/dist/events/index.cjs +25 -1
  77. package/dist/events/index.d.ts +1 -1
  78. package/dist/events/index.js +4 -1
  79. package/dist/formatters/index.cjs +55 -1
  80. package/dist/formatters/index.d.ts +2 -2
  81. package/dist/formatters/index.js +10 -1
  82. package/dist/generators/index.cjs +31 -1
  83. package/dist/generators/index.d.ts +2 -2
  84. package/dist/generators/index.js +6 -1
  85. package/dist/index.d.ts +1 -1
  86. package/dist/{isPlainObject-DGJkcFYw.d.ts → isPlainObject-FWmcJF6k.d.ts} +5 -5
  87. package/dist/next/index.cjs +205 -1
  88. package/dist/next/index.d.ts +2 -2
  89. package/dist/next/index.js +200 -1
  90. package/dist/next/server/index.cjs +34 -1
  91. package/dist/next/server/index.d.ts +1 -1
  92. package/dist/next/server/index.js +32 -1
  93. package/dist/operations/index.cjs +26 -1
  94. package/dist/operations/index.d.ts +2 -2
  95. package/dist/operations/index.js +9 -1
  96. package/dist/parsers/index.cjs +11 -1
  97. package/dist/parsers/index.d.ts +1 -1
  98. package/dist/parsers/index.js +2 -1
  99. package/dist/predicates/index.cjs +292 -1
  100. package/dist/predicates/index.d.ts +4 -4
  101. package/dist/predicates/index.js +15 -1
  102. package/dist/promises/index.cjs +18 -1
  103. package/dist/promises/index.d.ts +2 -2
  104. package/dist/promises/index.js +5 -1
  105. package/dist/rzl-utils.global.js +16 -1
  106. package/dist/strings/index.cjs +75 -1
  107. package/dist/strings/index.d.ts +2 -2
  108. package/dist/strings/index.js +6 -1
  109. package/dist/tailwind/index.cjs +36 -1
  110. package/dist/tailwind/index.d.ts +1 -1
  111. package/dist/tailwind/index.js +3 -1
  112. package/dist/urls/index.cjs +44 -1
  113. package/dist/urls/index.d.ts +1 -1
  114. package/dist/urls/index.js +15 -1
  115. package/package.json +16 -24
  116. package/dist/NumberRangeUnion-B6bhM2s7.d.ts +0 -33
  117. package/dist/any-v4TsK9ES.d.ts +0 -66
  118. package/dist/arrays-normalize-recursive-BqmVuFlD.d.ts +0 -72
  119. package/dist/chunk-JYQTCICM.js +0 -1
  120. package/dist/chunk-YLA3DURS.cjs +0 -1
  121. package/dist/extends-DtdRjDyU.d.ts +0 -343
  122. package/dist/if-ChM35c_q.d.ts +0 -19
  123. package/dist/is-array-BJeHxPM3.d.ts +0 -952
  124. package/dist/never-D89PbPh5.d.ts +0 -66
  125. package/dist/nils-CO8zLHSB.d.ts +0 -151
  126. package/dist/or-C6qzKt2I.d.ts +0 -82
  127. package/dist/override-CL2olHE5.d.ts +0 -59
  128. package/dist/pick-BSMX6Xe2.d.ts +0 -15
  129. package/dist/prettify-3o8_Kw6b.d.ts +0 -564
  130. package/dist/promises-LU7K00H0.d.ts +0 -72
  131. package/dist/string-B1jlOnws.d.ts +0 -312
  132. package/dist/types/index.d.ts +0 -3345
@@ -1 +1,552 @@
1
- import{normalizeSpaces as e}from"./chunk-T2T7K3KR.js";import{parseCurrencyString as t}from"./chunk-IRFL4MAX.js";import{isFinite as r}from"./chunk-3IBQ5MOM.js";import{isInteger as o}from"./chunk-WVSPXFTY.js";import{isEmptyString as n}from"./chunk-W2WNBUDE.js";import{assertIsString as a}from"./chunk-SBKGWRS5.js";import{safeStableStringify as i,isDate as s}from"./chunk-PET42Z7W.js";import{isString as u,getPreciseType as p,assertIsPlainObject as l,hasOwnProp as m,isBoolean as c,isPlainObject as d,isNaN as f,isUndefined as y,isFunction as h,assertIsBoolean as b,isNil as g,isNumber as $,isNonEmptyString as v}from"./chunk-CMW2TBOQ.js";import{isSupportedCountry as T,AsYouType as w}from"libphonenumber-js/max";import{id as N,enUS as C}from"date-fns/locale";import{parse as D,format as E}from"date-fns";var k=(e,n={})=>{if(!u(e)&&!r(e))throw new TypeError(`First parameter (\`value\`) must be of type \`string\` or \`primitive-number\`, but received: \`${p(e)}\`, with value: \`${i(e)}\`.`);l(n,{message:({currentType:e,validType:t})=>`Second parameter (\`options\`) must be of type \`${t}\`, but received: \`${e}\`.`});const s=!!m(n,"decimal")&&n.decimal,g=m(n,"totalDecimal")?n.totalDecimal:2,$=!m(n,"endDecimal")||n.endDecimal,v=!!m(n,"indianFormat")&&n.indianFormat,T=m(n,"suffixCurrency")?n.suffixCurrency:"",w=m(n,"suffixDecimal")?n.suffixDecimal:"",N=m(n,"roundedDecimal")?n.roundedDecimal:"round",C=m(n,"negativeFormat")?n.negativeFormat:"dash";let D=m(n,"separatorDecimals")?n.separatorDecimals:",",E=m(n,"separator")?n.separator:".";if(!(u(E)&&u(D)&&u(T)&&u(w)))throw new TypeError(`Parameter \`separator\`, \`separatorDecimals\`, \`suffixCurrency\` and \`suffixDecimal\` property of the \`options\` (second parameter) must be of type \`string\`, but received: ['separator': \`${p(E)}\`, 'separatorDecimals': \`${p(D)}\`, 'suffixCurrency': \`${p(T)}\`, 'suffixDecimal': \`${p(w)}\`].`);if(!c(s)||!c($)||!c(v))throw new TypeError(`Parameter \`decimal\`, \`endDecimal\` and \`indianFormat\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: ['decimal': \`${p(s)}\`, 'endDecimal': \`${p($)}\`, 'indianFormat': \`${p(v)}\`].`);if(!o(g))throw new TypeError(`Parameter \`totalDecimal\` property of the \`options\` (second parameter) must be of type \`integer-number\`, but received: \`${p(g)}\`, with value: \`${i(length)}\`.`);if(!1!==N&&"round"!==N&&"ceil"!==N&&"floor"!==N)throw new TypeError(`Parameter \`roundedDecimal\` property of the \`options\` (second parameter) must be of type \`false\` or \`string\` must be one of "round" | "ceil" | "floor", but received: \`${p(N)}\`, with value: \`${i(N)}\`.`);if("abs"!==C&&"brackets"!==C&&"dash"!==C&&!d(C))throw new TypeError(`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: \`${p(C)}\`, with value: \`${i(C)}\`.`);const k=u(e)?t(e):e;if(f(k))throw new TypeError("First parameter (`value`) could not be parsed into a valid `number`.");let F="",S="",O=Math.abs(k);const M=Math.pow(10,g);if(N){const e=O*M;switch(N){case"round":O=Math.round(e)/M;break;case"ceil":O=Math.ceil(e)/M;break;case"floor":O=Math.floor(e)/M}}if(N)[F,S]=O.toFixed(g).split("."),S=S??"".padEnd(g,"0");else{const e=String(O).split(".");F=e[0],S=(e[1]||"").slice(0,g).padEnd(g,"0")}let P;if(v?(E=",",D=".",P=(T.trim().length?T:"")+((e,t)=>{const r=e.slice(-3),o=e.slice(0,-3);return o?o.replace(/\B(?=(\d{2})+(?!\d))/g,t)+t+r:r})(F,E)):P=(T.trim().length?T:"")+F.replace(/\B(?=(\d{3})+(?!\d))/g,E),s&&!y(S)&&g>0){let e=D+S;$&&(e+=w),P+=e}if(k<0)if("dash"===C)P="-"+P;else if("brackets"===C)P="("+P+")";else if("abs"===C);else if(d(C))if(m(C,"custom")){const e=C.custom;if(!h(e))throw new TypeError(`Parameter \`negativeFormat.custom\` property of the \`options\` (second parameter) must be of type function: \`(formatted: string) => string\`, but received: \`${p(e)}\`.`);const t=e(P);a(t,{message:({currentType:e,validType:t})=>`Parameter \`negativeFormat.custom\` property of the \`options\` (second parameter) expected return a \`${t}\` type value, but received: \`${e}\`.`}),P=t}else{const e=C.style||"dash",t=!y(C.space)&&C.space;if(b(t,{message:({currentType:e,validType:t})=>`Parameter \`negativeFormat.space\` property of the \`options\` (second parameter) must be of type \`${t} or undefined\`, but received: \`${e}\`.`}),"abs"!==e&&"brackets"!==e&&"dash"!==e)throw new TypeError(`Parameter \`negativeFormat.style\` property of the \`options\` (second parameter) must be of type \`string\` must be of type "abs" | "brackets" | "dash", but received: \`${p(e)}\`, with value: \`${i(e)}\`.`);switch(e){case"dash":P="-"+(t?" ":"")+P;break;case"brackets":P=t?`( ${P} )`:`(${P})`}}return P},F=(e,t=",")=>{if(!u(e)&&!r(e))throw new TypeError(`First parameter (\`value\`) must be of type \`string\` or \`primitive number\`, but received: \`${p(e)}\`.`);if(!u(t))throw new TypeError(`Second parameter (\`separator\`) must be of type \`string\` or empty as \`undefined\`, but received: \`${p(t)}\`.`);const o="."===(t=u(t)?t:",")?",":".",n=e.toString().trim(),a=n.lastIndexOf("."),i=n.lastIndexOf(",");let s="";a>i?s=".":i>a&&(s=",");let l=n,m="";if(s){const e=n.split(s);l=e.slice(0,-1).join(s),m=e.slice(-1)[0]}l=l.replace(/[^\d]/g,"");const c=l.replace(/\B(?=(\d{3})+(?!\d))/g,t);return m?`${c}${o}${m}`:c};function S(e,t={}){if(g(e))return"";if(!u(e)&&!$(e))throw new TypeError(`First parameter (\`value\`) must be of type \`string\`, \`number\`, \`null\` or \`undefined\`, but received: \`${p(e)}\`.`);l(t,{message:({currentType:e,validType:t})=>`Second parameter (\`options\`) must be of type \`${t}\`, but received: \`${e}\`.`});const r=!!m(t,"takeNumberOnly")&&t.takeNumberOnly,o=!!m(t,"checkValidOnly")&&t.checkValidOnly,n=m(t,"defaultCountry")?t.defaultCountry:void 0,a=m(t,"separator")?t.separator:" ",s=!m(t,"prependPlusCountryCode")||t.prependPlusCountryCode,d=m(t,"outputFormat")?t.outputFormat:"INTERNATIONAL",f=m(t,"openingNumberCountry")?t.openingNumberCountry:"",h=m(t,"closingNumberCountry")?t.closingNumberCountry:"";if(!c(r)||!c(o)||!c(s))throw new TypeError(`Parameter \`takeNumberOnly\`, \`checkValidOnly\` and \`prependPlusCountryCode\` property of the \`options\` (second parameter) must be of type \`boolean\` or unset as \`undefined\` value, but received: ['takeNumberOnly': \`${p(r)}\`, 'checkValidOnly': \`${p(o)}\`, 'prependPlusCountryCode': \`${p(s)}\`].`);if(!y(n)&&!T(n))throw new TypeError(`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: \`${p(n)}\`, with value: \`${i(n,{keepUndefined:!0})}\`.\n\nSee: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements, for all ISO 3166-1 alpha-2 code.`);if(!["INTERNATIONAL","NATIONAL","RFC3966","E.164"].includes(d))throw new TypeError(`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: \`${p(d)}\`, with value: ${i(d,{keepUndefined:!0})}.`);if(!u(a)||!u(f)||!u(h))throw new TypeError(`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': \`${p(a)}\`,'openingNumberCountry': \`${p(f)}\`, 'closingNumberCountry': \`${p(h)}\`].`);u(e)||(e=String(e));const b=((e,t)=>{let r;try{return r=new w(t),r.input(e),r}catch{return void r?.reset()}})(e,n),N=(C=b,!!C?.isValid()&&!!C.getNumber());var C;if(o)return N;if(!N)return"";if(r)return b.getNumber().formatNational().replace(/\D/g,"");const D=b.getNumber().format(d);if("INTERNATIONAL"===d){const[e,...t]=D.split(" "),r=s?e:e.replace(/^\++/,""),o=t.join(a);return v(f)&&v(h)?`${f}${r}${h} ${o}`:`${r} ${o}`}if("NATIONAL"===d){return`${D.split(" ").join(a)}`}return D}var O=(e,t,r,o)=>{if(e.length<=t)return"*".repeat(e.length);const n=e.split(""),a=Math.max(t,Math.ceil(e.length*r)),i=new Set;let s=0;for(;i.size<a;){const t=y(o)?Math.floor(Math.random()*e.length):(o+e.length+31*s)%e.length;i.add(t),s++}for(const e of i)n[e]="*";return n.join("")},M=(e,t={})=>{if(!v(e))return"";l(t,{message:({currentType:e,validType:t})=>`Second parameter (\`options\`) must be of type \`${t}\`, but received: \`${e}\`.`});const r=m(t,"mode")?t.mode:"fixed";if("random"!==r&&"fixed"!==r)throw new TypeError(`Parameter \`mode\` property of the \`options\` (second parameter) must be one of "fixed" or "random", but received: \`${p(r)}\`, with value: \`${i(r)}\`.`);if(!/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(e))return"";const[o,n]=e.split("@"),a=n.split(".");if(a.length<2)return"";const[s,...u]=a,c=u.join("."),d=((e,t)=>"fixed"===e?(()=>{let e=0;for(let r=0;r<t.length;r++)e=(e<<5)-e+t.charCodeAt(r),e|=0;return Math.abs(e)})():void 0)(r,e),f=o.length<4?1:2,y=s.length<4?1:2;return`${O(o,f,.6,d)}@${O(s,y,.5,d)}.${c.length<=2?c:O(c,1,.4,d)}`};function P(t,r,n={}){if(g(t)||r<=0)return t;if(a(t,{message:({currentType:e,validType:t})=>`First parameter (\`subject\`) must be of type \`${t}\`, but received: \`${e}\`.`}),!o(r))throw new TypeError(`Second parameter (\`limiter\`) must be of type \`integer-number\`, but received: \`${p(r)}\`, with value: \`${i(r)}\`.`);l(n,{message:({currentType:e,validType:t})=>`Third parameter (\`options\`) must be of type \`${t}\`, but received: \`${e}\`.`});const s=m(n,"separator")?n.separator:" ",u=!!m(n,"reCountAfterSpace")&&n.reCountAfterSpace;if(a(s,{message:({currentType:e,validType:t})=>`Parameter \`separator\` property of the \`options\` (third parameter) must be of type \`${t}\`, but received: \`${e}\`.`}),b(u,{message:({currentType:e,validType:t})=>`Parameter \`reCountAfterSpace\` property of the \`options\` (third parameter) must be of type \`${t}\`, but received: \`${e}\`.`}),t=e(t),!u){let e="",o=0;for(let n=0;n<t.length;n++){o===r&&(e+=s,o=0),e+=t[n],o++}return e}const c=t.split(" "),d=[];let f=[],y=0;for(let e=0;e<c.length;e++){const t=c[e];let o="",n=0;for(let e=0;e<t.length;e++)o+=t[e],n++,n===r&&e<t.length-1&&(o+=s,n=0);f.push(o),y++,y!==r&&e!==c.length-1||(d.push(f.join(s)),f=[],y=0)}return d.join(" ")}var A=(e,t={})=>{if(!v(e))return"";l(t,{message:({currentType:e,validType:t})=>`Seconds parameter (\`options\`) must be of type \`${t}\`, but received: \`${e}\`.`});const r=!m(t,"trim")||t.trim,s=m(t,"length")?t.length:10;let u=m(t,"ending")?t.ending:"...";if(!o(s))throw new TypeError(`Parameter \`length\` property of the \`options\` (second parameter) must be of type \`integer-number\`, but received: \`${p(s)}\`, with value: \`${i(s)}\`.`);if(s<1)return"";a(u,{message:({currentType:e,validType:t})=>`Parameter \`ending\` property of the \`options\` (second parameter) must be of type \`${t}\`, but received: \`${e}\`.`}),b(r,{message:({currentType:e,validType:t})=>`Parameter \`trim\` property of the \`options\` (second parameter) must be of type \`${t}\`, but received: \`${e}\`.`}),u=n(u)?"...":u.trim();const c=r?e.trim():e;if(c.length<=s)return c;const d=c.slice(0,s);return(r?d:d.trimEnd())+u},I=(e,t={})=>{if(g(e)||!s(e)&&!v(e))return null;d(t)||(t={});const{inputFormat:r,locale:o="en",inputLocale:n="en",...a}=t,i=m(t,"format")&&v(t.format)?t.format:"dd MMM yyyy - HH:mm:ss";let u;try{if(v(e)&&r&&n){const t=v(n)?"id"===n?N:C:n;u=D(e,r,new Date,{locale:t})}else u=new Date(e);if(f(u.getTime()))return null;const t=v(o)?"id"===o?N:C:o;return E(u,i,{...a,locale:t})}catch{return null}},j=(e,t)=>{if(g(e)||!s(e)&&!v(e))return null;const r=new Date(e);if(f(r.getTime()))return null;d(t)||(t={});const{locale:o="en-US",...n}=t;try{return new Intl.DateTimeFormat(v(o)?o.trim():"en-US",n).format(r)}catch{return null}},x=(e,t)=>{if(g(t)&&(t="YYYY-MM-DD hh:mm:ss"),!u(t))return null;if(g(e)||!s(e)&&!v(e))return null;try{const r=new Date(e);if(f(r.getTime()))return null;const o=e=>e.toString().padStart(2,"0"),n={YYYY:r.getFullYear().toString(),MM:o(r.getMonth()+1),DD:o(r.getDate()),hh:o(r.getHours()),mm:o(r.getMinutes()),ss:o(r.getSeconds())},a=Object.entries(n).reduce((e,[t,r])=>e.split(t).join(r),t);return a.includes("NaN")?null:a}catch{return null}},L=e=>{try{if(g(e)||u(e)&&n(e))e=new Date;else if(!s(e)&&!v(e))return"0";const t=new Date(e);if(f(t.getTime()))return"0";const r=e=>e.toString().padStart(2,"0");let o=t.getTimezoneOffset();const a=o<0?"+":"-";return o=Math.abs(o),`${a}${r(Math.floor(o/60))}${r(o%60)}`}catch{return"0"}};export{M as censorEmail,P as chunkString,k as formatCurrency,I as formatDateFns,j as formatDateIntl,x as formatDateTime,F as formatNumber,S as formatPhoneNumber,L as getGMTOffset,A as truncateString};
1
+ import { normalizeSpaces } from './chunk-T2T7K3KR.js';
2
+ import { parseCurrencyString } from './chunk-IRFL4MAX.js';
3
+ import { isFinite } from './chunk-3IBQ5MOM.js';
4
+ import { isInteger } from './chunk-WVSPXFTY.js';
5
+ import { isEmptyString } from './chunk-W2WNBUDE.js';
6
+ import { assertIsString } from './chunk-SBKGWRS5.js';
7
+ import { safeStableStringify, isDate } from './chunk-PET42Z7W.js';
8
+ import { isString, getPreciseType, assertIsPlainObject, hasOwnProp, isBoolean, isPlainObject, isNaN, isUndefined, isFunction, assertIsBoolean, isNil, isNumber, isNonEmptyString } from './chunk-CMW2TBOQ.js';
9
+ import { isSupportedCountry, AsYouType } from 'libphonenumber-js/max';
10
+ import { id, enUS } from 'date-fns/locale';
11
+ import { parse, format } from 'date-fns';
12
+ var formatIndianNumber = (numStr, separator) => {
13
+ const lastThree = numStr.slice(-3);
14
+ const rest = numStr.slice(0, -3);
15
+ if (!rest) return lastThree;
16
+ return rest.replace(/\B(?=(\d{2})+(?!\d))/g, separator) + separator + lastThree;
17
+ };
18
+ var formatCurrency = (value, options = {}) => {
19
+ if (!isString(value) && !isFinite(value)) {
20
+ throw new TypeError(
21
+ `First parameter (\`value\`) must be of type \`string\` or \`primitive-number\`, but received: \`${getPreciseType(
22
+ value
23
+ )}\`, with value: \`${safeStableStringify(value)}\`.`
24
+ );
25
+ }
26
+ assertIsPlainObject(options, {
27
+ message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
28
+ });
29
+ const decimal = hasOwnProp(options, "decimal") ? options.decimal : false;
30
+ const totalDecimal = hasOwnProp(options, "totalDecimal") ? options.totalDecimal : 2;
31
+ const endDecimal = hasOwnProp(options, "endDecimal") ? options.endDecimal : true;
32
+ const indianFormat = hasOwnProp(options, "indianFormat") ? options.indianFormat : false;
33
+ const suffixCurrency = hasOwnProp(options, "suffixCurrency") ? options.suffixCurrency : "";
34
+ const suffixDecimal = hasOwnProp(options, "suffixDecimal") ? options.suffixDecimal : "";
35
+ const roundedDecimal = hasOwnProp(options, "roundedDecimal") ? options.roundedDecimal : "round";
36
+ const negativeFormat = hasOwnProp(options, "negativeFormat") ? options.negativeFormat : "dash";
37
+ let separatorDecimals = hasOwnProp(options, "separatorDecimals") ? options.separatorDecimals : ",";
38
+ let separator = hasOwnProp(options, "separator") ? options.separator : ".";
39
+ if (!isString(separator) || !isString(separatorDecimals) || !isString(suffixCurrency) || !isString(suffixDecimal)) {
40
+ throw new TypeError(
41
+ `Parameter \`separator\`, \`separatorDecimals\`, \`suffixCurrency\` and \`suffixDecimal\` property of the \`options\` (second parameter) must be of type \`string\`, but received: ['separator': \`${getPreciseType(
42
+ separator
43
+ )}\`, 'separatorDecimals': \`${getPreciseType(
44
+ separatorDecimals
45
+ )}\`, 'suffixCurrency': \`${getPreciseType(
46
+ suffixCurrency
47
+ )}\`, 'suffixDecimal': \`${getPreciseType(suffixDecimal)}\`].`
48
+ );
49
+ }
50
+ if (!isBoolean(decimal) || !isBoolean(endDecimal) || !isBoolean(indianFormat)) {
51
+ throw new TypeError(
52
+ `Parameter \`decimal\`, \`endDecimal\` and \`indianFormat\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: ['decimal': \`${getPreciseType(
53
+ decimal
54
+ )}\`, 'endDecimal': \`${getPreciseType(
55
+ endDecimal
56
+ )}\`, 'indianFormat': \`${getPreciseType(indianFormat)}\`].`
57
+ );
58
+ }
59
+ if (!isInteger(totalDecimal)) {
60
+ throw new TypeError(
61
+ `Parameter \`totalDecimal\` property of the \`options\` (second parameter) must be of type \`integer-number\`, but received: \`${getPreciseType(
62
+ totalDecimal
63
+ )}\`, with value: \`${safeStableStringify(length)}\`.`
64
+ );
65
+ }
66
+ if (!(roundedDecimal === false || roundedDecimal === "round" || roundedDecimal === "ceil" || roundedDecimal === "floor")) {
67
+ throw new TypeError(
68
+ `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(
69
+ roundedDecimal
70
+ )}\`, with value: \`${safeStableStringify(roundedDecimal)}\`.`
71
+ );
72
+ }
73
+ if (!(negativeFormat === "abs" || negativeFormat === "brackets" || negativeFormat === "dash" || isPlainObject(negativeFormat))) {
74
+ throw new TypeError(
75
+ `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(
76
+ negativeFormat
77
+ )}\`, with value: \`${safeStableStringify(negativeFormat)}\`.`
78
+ );
79
+ }
80
+ const rawNum = isString(value) ? parseCurrencyString(value) : value;
81
+ if (isNaN(rawNum)) {
82
+ throw new TypeError(
83
+ `First parameter (\`value\`) could not be parsed into a valid \`number\`.`
84
+ );
85
+ }
86
+ let integerPart = "";
87
+ let decimalPartRaw = "";
88
+ let num = Math.abs(rawNum);
89
+ const factor = Math.pow(10, totalDecimal);
90
+ if (roundedDecimal) {
91
+ const scaled = num * factor;
92
+ switch (roundedDecimal) {
93
+ case "round":
94
+ num = Math.round(scaled) / factor;
95
+ break;
96
+ case "ceil":
97
+ num = Math.ceil(scaled) / factor;
98
+ break;
99
+ case "floor":
100
+ num = Math.floor(scaled) / factor;
101
+ break;
102
+ }
103
+ }
104
+ if (roundedDecimal) {
105
+ [integerPart, decimalPartRaw] = num.toFixed(totalDecimal).split(".");
106
+ decimalPartRaw = decimalPartRaw ?? "".padEnd(totalDecimal, "0");
107
+ } else {
108
+ const split = String(num).split(".");
109
+ integerPart = split[0];
110
+ decimalPartRaw = (split[1] || "").slice(0, totalDecimal).padEnd(totalDecimal, "0");
111
+ }
112
+ let formattedInteger;
113
+ if (indianFormat) {
114
+ separator = ",";
115
+ separatorDecimals = ".";
116
+ formattedInteger = (suffixCurrency.trim().length ? suffixCurrency : "") + formatIndianNumber(integerPart, separator);
117
+ } else {
118
+ formattedInteger = (suffixCurrency.trim().length ? suffixCurrency : "") + integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separator);
119
+ }
120
+ if (decimal && !isUndefined(decimalPartRaw) && totalDecimal > 0) {
121
+ let formattedDecimal = separatorDecimals + decimalPartRaw;
122
+ if (endDecimal) formattedDecimal += suffixDecimal;
123
+ formattedInteger += formattedDecimal;
124
+ }
125
+ if (rawNum < 0) {
126
+ if (negativeFormat === "dash") {
127
+ formattedInteger = "-" + formattedInteger;
128
+ } else if (negativeFormat === "brackets") {
129
+ formattedInteger = "(" + formattedInteger + ")";
130
+ } else if (negativeFormat === "abs") ; else if (isPlainObject(negativeFormat)) {
131
+ if (hasOwnProp(negativeFormat, "custom")) {
132
+ const formatCustomNegative = negativeFormat.custom;
133
+ if (!isFunction(formatCustomNegative)) {
134
+ throw new TypeError(
135
+ `Parameter \`negativeFormat.custom\` property of the \`options\` (second parameter) must be of type function: \`(formatted: string) => string\`, but received: \`${getPreciseType(
136
+ formatCustomNegative
137
+ )}\`.`
138
+ );
139
+ }
140
+ const result = formatCustomNegative(formattedInteger);
141
+ assertIsString(result, {
142
+ message: ({ currentType, validType }) => `Parameter \`negativeFormat.custom\` property of the \`options\` (second parameter) expected return a \`${validType}\` type value, but received: \`${currentType}\`.`
143
+ });
144
+ formattedInteger = result;
145
+ } else {
146
+ const formatStyleNegative = negativeFormat.style || "dash";
147
+ const formatSpaceNegative = !isUndefined(negativeFormat.space) ? negativeFormat.space : false;
148
+ assertIsBoolean(formatSpaceNegative, {
149
+ message: ({ currentType, validType }) => `Parameter \`negativeFormat.space\` property of the \`options\` (second parameter) must be of type \`${validType} or undefined\`, but received: \`${currentType}\`.`
150
+ });
151
+ if (!(formatStyleNegative === "abs" || formatStyleNegative === "brackets" || formatStyleNegative === "dash")) {
152
+ throw new TypeError(
153
+ `Parameter \`negativeFormat.style\` property of the \`options\` (second parameter) must be of type \`string\` must be of type "abs" | "brackets" | "dash", but received: \`${getPreciseType(
154
+ formatStyleNegative
155
+ )}\`, with value: \`${safeStableStringify(formatStyleNegative)}\`.`
156
+ );
157
+ }
158
+ switch (formatStyleNegative) {
159
+ case "dash":
160
+ formattedInteger = "-" + (formatSpaceNegative ? " " : "") + formattedInteger;
161
+ break;
162
+ case "brackets":
163
+ formattedInteger = formatSpaceNegative ? `( ${formattedInteger} )` : `(${formattedInteger})`;
164
+ break;
165
+ }
166
+ }
167
+ }
168
+ }
169
+ return formattedInteger;
170
+ };
171
+ var formatNumber = (value, separator = ",") => {
172
+ if (!isString(value) && !isFinite(value)) {
173
+ throw new TypeError(
174
+ `First parameter (\`value\`) must be of type \`string\` or \`primitive number\`, but received: \`${getPreciseType(
175
+ value
176
+ )}\`.`
177
+ );
178
+ }
179
+ if (!isString(separator)) {
180
+ throw new TypeError(
181
+ `Second parameter (\`separator\`) must be of type \`string\` or empty as \`undefined\`, but received: \`${getPreciseType(
182
+ separator
183
+ )}\`.`
184
+ );
185
+ }
186
+ separator = isString(separator) ? separator : ",";
187
+ const decimalSeparator = separator === "." ? "," : separator === "," ? "." : ".";
188
+ const stringValue = value.toString().trim();
189
+ const lastDot = stringValue.lastIndexOf(".");
190
+ const lastComma = stringValue.lastIndexOf(",");
191
+ let actualDecimal = "";
192
+ if (lastDot > lastComma) {
193
+ actualDecimal = ".";
194
+ } else if (lastComma > lastDot) {
195
+ actualDecimal = ",";
196
+ }
197
+ let integerPart = stringValue;
198
+ let decimalPart = "";
199
+ if (actualDecimal) {
200
+ const parts = stringValue.split(actualDecimal);
201
+ integerPart = parts.slice(0, -1).join(actualDecimal);
202
+ decimalPart = parts.slice(-1)[0];
203
+ }
204
+ integerPart = integerPart.replace(/[^\d]/g, "");
205
+ const formattedInteger = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separator);
206
+ return decimalPart ? `${formattedInteger}${decimalSeparator}${decimalPart}` : formattedInteger;
207
+ };
208
+ var parsingAsYouType = (value, defaultCountry) => {
209
+ let parsed;
210
+ try {
211
+ parsed = new AsYouType(defaultCountry);
212
+ parsed.input(value);
213
+ return parsed;
214
+ } catch {
215
+ parsed?.reset();
216
+ return void 0;
217
+ }
218
+ };
219
+ var isValidParseAsYouType = (parsedAsYouType) => {
220
+ const parsed = !!parsedAsYouType?.isValid() && !!parsedAsYouType.getNumber();
221
+ return parsed;
222
+ };
223
+ function formatPhoneNumber(value, options = {}) {
224
+ if (isNil(value)) return "";
225
+ if (!isString(value) && !isNumber(value)) {
226
+ throw new TypeError(
227
+ `First parameter (\`value\`) must be of type \`string\`, \`number\`, \`null\` or \`undefined\`, but received: \`${getPreciseType(
228
+ value
229
+ )}\`.`
230
+ );
231
+ }
232
+ assertIsPlainObject(options, {
233
+ message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
234
+ });
235
+ const takeNumberOnly = hasOwnProp(options, "takeNumberOnly") ? options.takeNumberOnly : false;
236
+ const checkValidOnly = hasOwnProp(options, "checkValidOnly") ? options.checkValidOnly : false;
237
+ const defaultCountry = hasOwnProp(
238
+ options,
239
+ "defaultCountry"
240
+ ) ? options.defaultCountry : void 0;
241
+ const separator = hasOwnProp(options, "separator") ? options.separator : " ";
242
+ const prependPlusCountryCode = hasOwnProp(options, "prependPlusCountryCode") ? options.prependPlusCountryCode : true;
243
+ const outputFormat = hasOwnProp(options, "outputFormat") ? options.outputFormat : "INTERNATIONAL";
244
+ const openingNumberCountry = hasOwnProp(options, "openingNumberCountry") ? options.openingNumberCountry : "";
245
+ const closingNumberCountry = hasOwnProp(options, "closingNumberCountry") ? options.closingNumberCountry : "";
246
+ if (!isBoolean(takeNumberOnly) || !isBoolean(checkValidOnly) || !isBoolean(prependPlusCountryCode)) {
247
+ throw new TypeError(
248
+ `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(
249
+ takeNumberOnly
250
+ )}\`, 'checkValidOnly': \`${getPreciseType(
251
+ checkValidOnly
252
+ )}\`, 'prependPlusCountryCode': \`${getPreciseType(prependPlusCountryCode)}\`].`
253
+ );
254
+ }
255
+ if (!isUndefined(defaultCountry) && !isSupportedCountry(defaultCountry)) {
256
+ throw new TypeError(
257
+ `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(
258
+ defaultCountry
259
+ )}\`, with value: \`${safeStableStringify(defaultCountry, {
260
+ keepUndefined: true
261
+ })}\`.
262
+
263
+ See: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements, for all ISO 3166-1 alpha-2 code.`
264
+ );
265
+ }
266
+ if (!["INTERNATIONAL", "NATIONAL", "RFC3966", "E.164"].includes(outputFormat)) {
267
+ throw new TypeError(
268
+ `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(
269
+ outputFormat
270
+ )}\`, with value: ${safeStableStringify(outputFormat, { keepUndefined: true })}.`
271
+ );
272
+ }
273
+ if (!isString(separator) || !isString(openingNumberCountry) || !isString(closingNumberCountry)) {
274
+ throw new TypeError(
275
+ `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(
276
+ separator
277
+ )}\`,'openingNumberCountry': \`${getPreciseType(
278
+ openingNumberCountry
279
+ )}\`, 'closingNumberCountry': \`${getPreciseType(closingNumberCountry)}\`].`
280
+ );
281
+ }
282
+ if (!isString(value)) value = String(value);
283
+ const parsedPhoneNumber = parsingAsYouType(value, defaultCountry);
284
+ const validPhoneNumber = isValidParseAsYouType(parsedPhoneNumber);
285
+ if (checkValidOnly) return validPhoneNumber;
286
+ if (!validPhoneNumber) return "";
287
+ if (takeNumberOnly) {
288
+ return parsedPhoneNumber.getNumber().formatNational().replace(/\D/g, "");
289
+ }
290
+ const num = parsedPhoneNumber.getNumber();
291
+ const intlNumb = num.format(outputFormat);
292
+ if (outputFormat === "INTERNATIONAL") {
293
+ const [cc, ...rest] = intlNumb.split(" ");
294
+ const countryCode = prependPlusCountryCode ? cc : cc.replace(/^\++/, "");
295
+ const restWithSeparator = rest.join(separator);
296
+ if (isNonEmptyString(openingNumberCountry) && isNonEmptyString(closingNumberCountry)) {
297
+ return `${openingNumberCountry}${countryCode}${closingNumberCountry} ${restWithSeparator}`;
298
+ }
299
+ return `${countryCode} ${restWithSeparator}`;
300
+ }
301
+ if (outputFormat === "NATIONAL") {
302
+ const restWithSeparator = intlNumb.split(" ").join(separator);
303
+ return `${restWithSeparator}`;
304
+ }
305
+ return intlNumb;
306
+ }
307
+ var hashSeedGenerate = (mode, email) => {
308
+ const generateSeed = () => {
309
+ let hash = 0;
310
+ for (let i = 0; i < email.length; i++) {
311
+ hash = (hash << 5) - hash + email.charCodeAt(i);
312
+ hash |= 0;
313
+ }
314
+ return Math.abs(hash);
315
+ };
316
+ return mode === "fixed" ? generateSeed() : void 0;
317
+ };
318
+ var _censor = (str, minCensor, maxPercentage, hashSeed) => {
319
+ if (str.length <= minCensor) return "*".repeat(str.length);
320
+ const strArr = str.split("");
321
+ const totalCensor = Math.max(minCensor, Math.ceil(str.length * maxPercentage));
322
+ const indexes = /* @__PURE__ */ new Set();
323
+ let i = 0;
324
+ while (indexes.size < totalCensor) {
325
+ const idx = !isUndefined(hashSeed) ? (hashSeed + str.length + i * 31) % str.length : Math.floor(Math.random() * str.length);
326
+ indexes.add(idx);
327
+ i++;
328
+ }
329
+ for (const index of indexes) {
330
+ strArr[index] = "*";
331
+ }
332
+ return strArr.join("");
333
+ };
334
+ var censorEmail = (email, options = {}) => {
335
+ if (!isNonEmptyString(email)) return "";
336
+ assertIsPlainObject(options, {
337
+ message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
338
+ });
339
+ const mode = hasOwnProp(options, "mode") ? options.mode : "fixed";
340
+ if (mode !== "random" && mode !== "fixed") {
341
+ throw new TypeError(
342
+ `Parameter \`mode\` property of the \`options\` (second parameter) must be one of "fixed" or "random", but received: \`${getPreciseType(
343
+ mode
344
+ )}\`, with value: \`${safeStableStringify(mode)}\`.`
345
+ );
346
+ }
347
+ const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
348
+ if (!emailRegex.test(email)) return "";
349
+ const [local, domain] = email.split("@");
350
+ const domainParts = domain.split(".");
351
+ if (domainParts.length < 2) return "";
352
+ const [domainName, ...tldParts] = domainParts;
353
+ const tld = tldParts.join(".");
354
+ const hashSeed = hashSeedGenerate(mode, email);
355
+ const localMinCensor = local.length < 4 ? 1 : 2;
356
+ const domainMinCensor = domainName.length < 4 ? 1 : 2;
357
+ const censoredLocal = _censor(local, localMinCensor, 0.6, hashSeed);
358
+ const censoredDomain = _censor(domainName, domainMinCensor, 0.5, hashSeed);
359
+ const censoredTLD = tld.length <= 2 ? tld : _censor(tld, 1, 0.4, hashSeed);
360
+ return `${censoredLocal}@${censoredDomain}.${censoredTLD}`;
361
+ };
362
+ function chunkString(subject, limiter, options = {}) {
363
+ if (isNil(subject) || limiter <= 0) return subject;
364
+ assertIsString(subject, {
365
+ message: ({ currentType, validType }) => `First parameter (\`subject\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
366
+ });
367
+ if (!isInteger(limiter)) {
368
+ throw new TypeError(
369
+ `Second parameter (\`limiter\`) must be of type \`integer-number\`, but received: \`${getPreciseType(
370
+ limiter
371
+ )}\`, with value: \`${safeStableStringify(limiter)}\`.`
372
+ );
373
+ }
374
+ assertIsPlainObject(options, {
375
+ message: ({ currentType, validType }) => `Third parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
376
+ });
377
+ const separator = hasOwnProp(options, "separator") ? options.separator : " ";
378
+ const reCountAfterSpace = hasOwnProp(options, "reCountAfterSpace") ? options.reCountAfterSpace : false;
379
+ assertIsString(separator, {
380
+ message: ({ currentType, validType }) => `Parameter \`separator\` property of the \`options\` (third parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`
381
+ });
382
+ assertIsBoolean(reCountAfterSpace, {
383
+ message: ({ currentType, validType }) => `Parameter \`reCountAfterSpace\` property of the \`options\` (third parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`
384
+ });
385
+ subject = normalizeSpaces(subject);
386
+ if (!reCountAfterSpace) {
387
+ let result = "";
388
+ let currentCount = 0;
389
+ for (let i = 0; i < subject.length; i++) {
390
+ const char = subject[i];
391
+ if (currentCount === limiter) {
392
+ result += separator;
393
+ currentCount = 0;
394
+ }
395
+ result += char;
396
+ currentCount++;
397
+ }
398
+ return result;
399
+ }
400
+ const words = subject.split(" ");
401
+ const finalSegments = [];
402
+ let currentGroup = [];
403
+ let wordsInCurrentGroupCount = 0;
404
+ for (let i = 0; i < words.length; i++) {
405
+ const word = words[i];
406
+ let processedWord = "";
407
+ let charCountInWord = 0;
408
+ for (let j = 0; j < word.length; j++) {
409
+ processedWord += word[j];
410
+ charCountInWord++;
411
+ if (charCountInWord === limiter && j < word.length - 1) {
412
+ processedWord += separator;
413
+ charCountInWord = 0;
414
+ }
415
+ }
416
+ currentGroup.push(processedWord);
417
+ wordsInCurrentGroupCount++;
418
+ if (wordsInCurrentGroupCount === limiter || i === words.length - 1) {
419
+ finalSegments.push(currentGroup.join(separator));
420
+ currentGroup = [];
421
+ wordsInCurrentGroupCount = 0;
422
+ }
423
+ }
424
+ return finalSegments.join(" ");
425
+ }
426
+ var truncateString = (text, options = {}) => {
427
+ if (!isNonEmptyString(text)) return "";
428
+ assertIsPlainObject(options, {
429
+ message: ({ currentType, validType }) => `Seconds parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
430
+ });
431
+ const trim = hasOwnProp(options, "trim") ? options.trim : true;
432
+ const length2 = hasOwnProp(options, "length") ? options.length : 10;
433
+ let ending = hasOwnProp(options, "ending") ? options.ending : "...";
434
+ if (!isInteger(length2)) {
435
+ throw new TypeError(
436
+ `Parameter \`length\` property of the \`options\` (second parameter) must be of type \`integer-number\`, but received: \`${getPreciseType(
437
+ length2
438
+ )}\`, with value: \`${safeStableStringify(length2)}\`.`
439
+ );
440
+ }
441
+ if (length2 < 1) return "";
442
+ assertIsString(ending, {
443
+ message: ({ currentType, validType }) => `Parameter \`ending\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`
444
+ });
445
+ assertIsBoolean(trim, {
446
+ message: ({ currentType, validType }) => `Parameter \`trim\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`
447
+ });
448
+ if (isEmptyString(ending)) {
449
+ ending = "...";
450
+ } else {
451
+ ending = ending.trim();
452
+ }
453
+ const original = trim ? text.trim() : text;
454
+ const originalTrimmedLength = original.length;
455
+ if (originalTrimmedLength <= length2) return original;
456
+ const sliced = original.slice(0, length2);
457
+ const cleanSliced = trim ? sliced : sliced.trimEnd();
458
+ return cleanSliced + ending;
459
+ };
460
+ var formatDateFns = (date, options = {}) => {
461
+ if (isNil(date) || !(isDate(date) || isNonEmptyString(date))) return null;
462
+ if (!isPlainObject(options)) {
463
+ options = {};
464
+ }
465
+ const { inputFormat, locale = "en", inputLocale = "en", ...restOptions } = options;
466
+ const format$1 = hasOwnProp(options, "format") && isNonEmptyString(options.format) ? options.format : "dd MMM yyyy - HH:mm:ss";
467
+ let parsedDate;
468
+ try {
469
+ if (isNonEmptyString(date) && inputFormat && inputLocale) {
470
+ const valueOfInputLocale = isNonEmptyString(inputLocale) ? inputLocale === "id" ? id : enUS : inputLocale;
471
+ parsedDate = parse(date, inputFormat, /* @__PURE__ */ new Date(), {
472
+ locale: valueOfInputLocale
473
+ });
474
+ } else {
475
+ parsedDate = new Date(date);
476
+ }
477
+ if (isNaN(parsedDate.getTime())) return null;
478
+ const valueOfLocale = isNonEmptyString(locale) ? locale === "id" ? id : enUS : locale;
479
+ return format(parsedDate, format$1, {
480
+ ...restOptions,
481
+ locale: valueOfLocale
482
+ });
483
+ } catch {
484
+ return null;
485
+ }
486
+ };
487
+ var formatDateIntl = (date, options) => {
488
+ if (isNil(date) || !(isDate(date) || isNonEmptyString(date))) return null;
489
+ const parsedDate = new Date(date);
490
+ if (isNaN(parsedDate.getTime())) return null;
491
+ if (!isPlainObject(options)) {
492
+ options = {};
493
+ }
494
+ const { locale = "en-US", ...restProps } = options;
495
+ try {
496
+ return new Intl.DateTimeFormat(
497
+ isNonEmptyString(locale) ? locale.trim() : "en-US",
498
+ restProps
499
+ ).format(parsedDate);
500
+ } catch {
501
+ return null;
502
+ }
503
+ };
504
+ var formatDateTime = (date, format) => {
505
+ if (isNil(format)) {
506
+ format = "YYYY-MM-DD hh:mm:ss";
507
+ }
508
+ if (!isString(format)) return null;
509
+ if (isNil(date) || !(isDate(date) || isNonEmptyString(date))) {
510
+ return null;
511
+ }
512
+ try {
513
+ const parsedDate = new Date(date);
514
+ if (isNaN(parsedDate.getTime())) return null;
515
+ const pad2 = (n) => n.toString().padStart(2, "0");
516
+ const map = {
517
+ YYYY: parsedDate.getFullYear().toString(),
518
+ MM: pad2(parsedDate.getMonth() + 1),
519
+ DD: pad2(parsedDate.getDate()),
520
+ hh: pad2(parsedDate.getHours()),
521
+ mm: pad2(parsedDate.getMinutes()),
522
+ ss: pad2(parsedDate.getSeconds())
523
+ };
524
+ const result = Object.entries(map).reduce(
525
+ (prev, [key, value]) => prev.split(key).join(value),
526
+ format
527
+ );
528
+ return !result.includes("NaN") ? result : null;
529
+ } catch {
530
+ return null;
531
+ }
532
+ };
533
+ var getGMTOffset = (date) => {
534
+ try {
535
+ if (isNil(date) || isString(date) && isEmptyString(date)) {
536
+ date = /* @__PURE__ */ new Date();
537
+ } else if (!(isDate(date) || isNonEmptyString(date))) {
538
+ return "0";
539
+ }
540
+ const parsedDate = new Date(date);
541
+ if (isNaN(parsedDate.getTime())) return "0";
542
+ const padZero = (num) => num.toString().padStart(2, "0");
543
+ let offset = parsedDate.getTimezoneOffset();
544
+ const sign = offset < 0 ? "+" : "-";
545
+ offset = Math.abs(offset);
546
+ return `${sign}${padZero(Math.floor(offset / 60))}${padZero(offset % 60)}`;
547
+ } catch {
548
+ return "0";
549
+ }
550
+ };
551
+
552
+ export { censorEmail, chunkString, formatCurrency, formatDateFns, formatDateIntl, formatDateTime, formatNumber, formatPhoneNumber, getGMTOffset, truncateString };
@@ -1 +1,4 @@
1
- var r=()=>{};export{r as noop};
1
+ var noop = () => {
2
+ };
3
+
4
+ export { noop };
@@ -1 +1,27 @@
1
- "use strict";var e=require("./chunk-PZQ6I4JJ.cjs");exports.isEmptyArray=t=>!e.isArray(t)||0===t.length,exports.isEmptyObject=function(t,r={}){if(!e.isObject(t))return!0;e.assertIsPlainObject(r,{message:({currentType:e,validType:t})=>`Second parameter (\`options\`) must be of type \`${t}\`, but received: \`${e}\`.`});const s=!!e.hasOwnProp(r,"checkSymbols")&&r.checkSymbols;e.assertIsBoolean(s,{message:({currentType:e,validType:t})=>`Parameter \`checkSymbols\` property of the \`options\` (second parameter) must be of type \`${t}\`, but received: \`${e}\`.`});const c=0===Object.keys(t).length;return s?c&&0===Object.getOwnPropertySymbols(t).length:c};
1
+ 'use strict';
2
+
3
+ var chunkPZQ6I4JJ_cjs = require('./chunk-PZQ6I4JJ.cjs');
4
+ var isEmptyArray = (value) => {
5
+ if (!chunkPZQ6I4JJ_cjs.isArray(value)) return true;
6
+ return value.length === 0;
7
+ };
8
+ function isEmptyObject(value, options = {}) {
9
+ if (!chunkPZQ6I4JJ_cjs.isObject(value)) {
10
+ return true;
11
+ }
12
+ chunkPZQ6I4JJ_cjs.assertIsPlainObject(options, {
13
+ message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
14
+ });
15
+ const checkSymbols = chunkPZQ6I4JJ_cjs.hasOwnProp(options, "checkSymbols") ? options.checkSymbols : false;
16
+ chunkPZQ6I4JJ_cjs.assertIsBoolean(checkSymbols, {
17
+ message: ({ currentType, validType }) => `Parameter \`checkSymbols\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`
18
+ });
19
+ const hasNoKeys = Object.keys(value).length === 0;
20
+ if (checkSymbols) {
21
+ return hasNoKeys && Object.getOwnPropertySymbols(value).length === 0;
22
+ }
23
+ return hasNoKeys;
24
+ }
25
+
26
+ exports.isEmptyArray = isEmptyArray;
27
+ exports.isEmptyObject = isEmptyObject;