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