util-helpers 4.6.1 → 4.7.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.
@@ -1,2 +1,2 @@
1
- !function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).utilHelpers={})}(this,(function(t){"use strict";const n=Object.prototype.toString;function e(t,e){return n.call(t)===`[object ${e}]`}function r(t){return e(t,"String")}function o(t){return r(t)?t:String(t)}const i=/^1[3456789]\d{9}$/;const s=/^(0\d{2,3}\-)?([2-9]\d{6,7})(\-\d{1,6})?$/;const u=/^\d{6}$/;const c=/^[1-9]\d{5}(19|20)?\d{2}((0[1-9])|(1[012]))(([0-2][1-9])|10|20|30|31)\d{3}(\d|X)?$/i;function a(t,{loose:n=!1,checkCode:e=!0}={}){const r=o(t);return 15===r.length&&n?c.test(r):!(18!==r.length||!c.test(r))&&(!e||function(t){let n,e,r;for(e=n=0;n<17;n++)e+=Math.pow(2,17-n)%11*Number(t[n]);return r=(12-e%11)%11,r<10?r===Number(t[17]):"X"==t[17]}(r))}const d=/^[\da-z]+([\-\.\_]?[\da-z]+)*@[\da-z]+([\-\.]?[\da-z]+)*(\.[a-z]{2,})+$/i;const l=/^[1-9]\d{4,10}$/;const f=/^[a-z]([-_a-z0-9]{5,19})+$/i;const g=/^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([A-Z0-9]{4}[A-Z0-9挂学警港澳]{1})|([A-Z0-9]{5}[DF])|([DF][A-Z0-9]{5}))$/;const p=/^[1-9]\d{9,20}$/,h=/^\d{8,30}$/;const b=/^[\dA-HJ-NPQRTUWXY]{2}\d{6}[\dA-HJ-NPQRTUWXY]{10}$/,$="0123456789ABCDEFGHJKLMNPQRTUWXY".split(""),m=[1,3,9,27,19,26,16,17,20,29,25,13,8,24,10,30,28];function y(t){let n;return $.some(((e,r)=>e===t&&(n=r,!0))),n}const w={disableWarning:!0};const A=/[\d]/,x=/[a-z]/,F=/[A-Z]/,M=/[\d|a-z]/gi;function v(t){return t.indexOf("\\x")>-1||t.indexOf("\\u")>-1}function C(t,{level:n=2,ignoreCase:e=!1,special:r="\\x21-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7E"}={}){let o=t;"string"!=typeof t&&(w.disableWarning||console.warn("[validatePassword] value must be a string."),o="");let i=0;const s=(u=o,A.test(u));var u;const c=function(t){return x.test(t)}(o),a=function(t){return F.test(t)}(o),d=function(t,n=""){if(!n)return!1;const e=t.replace(M,""),r=v(n)?new RegExp(`[${n}]`):null;if(r)return r.test(e);let o=!1;return e.split("").some((t=>(n.indexOf(t)>-1&&(o=!0),o))),o}(o,r),l=function(t,n=""){const e=t.replace(M,"");if(!n&&e)return!0;const r=v(n)?new RegExp(`[^${n}]`):null;if(r)return r.test(e);let o=!1;return e.split("").some((t=>(-1===n.indexOf(t)&&(o=!0),o))),o}(o,r);s&&(i+=1),e?(c||a)&&(i+=1):(c&&(i+=1),a&&(i+=1)),d&&(i+=1);return{validated:i>=n&&!l,level:i,containes:{number:s,lowerCaseLetter:c,upperCaseLetter:a,specialCharacter:d,unallowableCharacter:l}}}const N=/^((e[\da-z])|(de)|(se)|(pe)|(k[\da-z])|(kj)|(ma))[\da-z]{7}$/i;const B="[一-龥]",E="[麦-鿯]",P="[㐀-䶵]",R="[𠀀-𪛖]",z="[𪜀-𫜴]",T="[𫝀-𫠝]",S="[𫠠-𬺡]",D="[𬺰-𮯠]";let W=B+"+",j="^"+B+"+$";const L=RegExp.prototype.hasOwnProperty("unicode");L&&(W="(?:"+B+"|"+E+"|"+P+"|"+R+"|"+z+"|"+T+"|"+S+"|"+D+")+",j="^(?:"+B+"|"+E+"|"+P+"|"+R+"|"+z+"|"+T+"|"+S+"|"+D+")+$");const Z=/^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;const _=/^((([0-9A-F]{1,4}:){7}([0-9A-F]{1,4}|:))|(([0-9A-F]{1,4}:){6}(:[0-9A-F]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3})|:))|(([0-9A-F]{1,4}:){5}(((:[0-9A-F]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3})|:))|(([0-9A-F]{1,4}:){4}(((:[0-9A-F]{1,4}){1,3})|((:[0-9A-F]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(([0-9A-F]{1,4}:){3}(((:[0-9A-F]{1,4}){1,4})|((:[0-9A-F]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(([0-9A-F]{1,4}:){2}(((:[0-9A-F]{1,4}){1,5})|((:[0-9A-F]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(([0-9A-F]{1,4}:){1}(((:[0-9A-F]{1,4}){1,6})|((:[0-9A-F]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(:(((:[0-9A-F]{1,4}){1,7})|((:[0-9A-F]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:)))(%.+)?$/i;const I=/(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/;const O=/^\d{15}$/;const U=/^[hm]{1}([0-9]{10}|[0-9]{8})$/i;const k=/^(\d{8}|[\da-z]{10})$/i;const X=Number.MAX_SAFE_INTEGER||9007199254740991,H=Number.MIN_SAFE_INTEGER||-9007199254740991;function Q(t){return/\d+\.?\d*e[\+\-]*\d+/i.test(t)}function G(t,n=12){return+parseFloat(t.toPrecision(n))}function Y(t){const n=t.toString().split(/e/i),e=(n[0].split(".")[1]||"").length-+(n[1]||0);return e>0?e:0}function J(t){if(!Q(t.toString()))return Number(t.toString().replace(".",""));const n=Y(t);return n>0?G(+t*Math.pow(10,n)):+t}function K(t){(+t>X||+t<H)&&(w.disableWarning||console.warn(`${t} is beyond boundary when transfer to integer, the results may not be accurate`))}function V(t){const n=/^([+-])?(0+)([0-9\.]+)$/.exec(t);let e;return n?(e=n[1]||"",e+("."===n[3][0]?"0"+n[3]:n[3])):t}function q(t){return e(t,"Number")&&isNaN(t)}const tt=/^[+-]?\d*\.?\d*$/;function nt(t){return function(t){return void 0===t}(t)||function(t){return null===t}(t)}function et(t){return nt(t)?"":o(t)}const rt=["零","一","二","三","四","五","六","七","八","九"],ot=["","十","百","千"],it=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],st=["","拾","佰","仟"];let ut,ct,at;function dt(t){let n="",e="",r=!1,o=0;for(;t>0;){let i=t%10;0==i?r&&(r=!1,e=ut[i]+e):(r=!0,n=ut[i],n+=ct[o],e=n+e),o++,t=Math.floor(t/10)}return e}function lt(t){const n=t+"";let e="";for(let t=0,r=n.length;t<r;t++)e+=ut[parseInt(n[t])];return e}const ft=/^(?<province>\d{2})(?<city>\d{2})(?<area>\d{2})(?<year>(?:\d{2})?\d{2})(?<month>\d{2})(?<day>\d{2})\d{2}(?<gender>\d)(?:\d|X)?$/i,gt=[["11","北京市"],["12","天津市"],["13","河北省"],["14","山西省"],["15","内蒙古自治区"],["21","辽宁省"],["22","吉林省"],["23","黑龙江省"],["31","上海市"],["32","江苏省"],["33","浙江省"],["34","安徽省"],["35","福建省"],["36","江西省"],["37","山东省"],["41","河南省"],["42","湖北省"],["43","湖南省"],["44","广东省"],["45","广西壮族自治区"],["46","海南省"],["50","重庆市"],["51","四川省"],["52","贵州省"],["53","云南省"],["54","西藏自治区"],["61","陕西省"],["62","甘肃省"],["63","青海省"],["64","宁夏回族自治区"],["65","新疆维吾尔自治区"],["71","台湾省"],["83","台湾省"],["81","香港特别行政区"],["82","澳门特别行政区"]];function pt(t){return e(t,"Number")}function ht(...t){const[n,e,...o]=t;if(o.length>0)return ht(ht(n,e),...o);if((!pt(e)||q(e))&&!r(e))return n;const i=J(n),s=J(e),u=Y(n)+Y(e),c=i*s;return K(c),c/Math.pow(10,u)}function bt(...t){const[n,e,...o]=t;if(o.length>0)return bt(bt(n,e),...o);if((!pt(e)||q(e))&&!r(e))return n;const i=J(n),s=J(e);return K(i),K(s),ht(i/s,G(Math.pow(10,Y(e)-Y(n))))}t.blobToDataURL=function(t){return new Promise(((n,e)=>{const r=new FileReader;r.readAsDataURL(t),r.onload=()=>n(r.result),r.onerror=t=>e(t)}))},t.bytesToSize=function(t){if(0===t)return"0 B";const n=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],e=Math.floor(Math.log(t)/Math.log(1024));return n[e]?`${Number((t/Math.pow(1024,e)).toFixed(2))} ${n[e]}`:t+""},t.calculateCursorPosition=function(t,n,e,r,{placeholderChar:o=" ",maskReg:i=/\D/g,type:s}={}){const u=et(n),c=et(e),a=Array.isArray(o)?o:[o],d=c.length-u.length;let l=t;if(d>0){let t=c.substring(l-d,l).replace(i,"").length;l-=d-t;let n=0;for(;t>0;)-1!==a.indexOf(r.charAt(l-t+n))?n++:t--;l+=n}return("mobile"===s&&(4===l||9===l)||"bankCard"===s&&l>0&&l%5==0)&&(l-=1),l},t.dataURLToBlob=function(t){const n=t.split(","),e=n[0].match(/:(.*?);/)[1],r=atob(n[1]);let o=r.length;const i=new Uint8Array(o);for(;o--;)i[o]=r.charCodeAt(o);return new Blob([i],{type:e})},t.divide=bt,t.formatBankCard=function(t="",{char:n=" ",length:e=4}={}){const r=new RegExp(`(.{${e}})`,"g"),o=new RegExp(`${n}`,"g"),i=et(t).replace(o,""),s=i.replace(r,`$1${n}`);return i.length%e==0?s.substring(0,s.length-1):s},t.formatMobile=function(t,{char:n=" "}={}){const e=new RegExp(n,"g"),r=et(t).replace(e,"").substring(0,11);return r.length>7?r.replace(/^(...)(....)/g,`$1${n}$2${n}`):r.length>3?r.replace(/^(...)/g,`$1${n}`):r},t.formatMoney=(t,{precision:n=2,symbol:e,thousand:r=",",decimal:o="."}={})=>{if(!function(t){return!tt.test(t)&&!Q(t)||q(t)||"number"!=typeof t&&"string"!=typeof t||""===t?(w.disableWarning||console.warn(`${t} invalid parameter.`),!1):("number"==typeof t&&K(t),!0)}(t))return"";"number"!=typeof n||q(n)||n<0?n=2:n>10&&(n=10),e="string"==typeof e?e:"",r="string"==typeof r?r:",",o="string"==typeof o?o:".";const i=function(t){if(Q(t.toString())){const n="0",e=String(t).toLowerCase().split("e"),r=e.pop(),o=Math.abs(r),i=r/o,s=e[0].split(".");if(-1===i)t=n+"."+new Array(o).join(n)+s.join("");else{const e=s[1];t=o-e.length<0?V(s[0]+e.substring(0,o))+"."+e.substring(o):s.join("")+new Array(o-e.length+1).join(n)}}return t}(t)+"",[s,u]=i.split(".");return e+function(t,n){let e="";t="+"===(t=V(t))[0]?t.substring(1):t;const r=Number(t)<0?"-":"",o=r?t.substring(1).split("").reverse():t.split("").reverse();for(let t=0;t<o.length;t++)e+=o[t]+((t+1)%3==0&&t+1!==o.length?n:"");return r+e.split("").reverse().join("")}(s,r)+function(t,n,e){if(0===n)return"";let r="";r=t&&Number(t)>0?parseFloat("0."+t).toFixed(n).substring(2):(0).toFixed(n).substring(2);return e+r}(u,n,o)},t.isBankCard=function(t,{loose:n=!1}={}){const e=o(t);return n?h.test(e):p.test(e)},t.isBusinessLicense=function(t,{loose:n=!1}={}){const e=o(t),r=O.test(e);if(n||!r)return r;const i=e.substring(0,14),s=e.substring(e.length-1),u=function(t){let n,e=10;for(let n=0;n<14;n++){let r=(e+Number(t[n]))%10;r=0===r?10:r,e=2*r%11}return n=10===e||1===e?1:11-e,n}(i);return s===String(u)},t.isChinese=function(t,{loose:n=!1}={}){const e=o(t);return new RegExp(n?W:j,L?"u":void 0).test(e)},t.isEmail=function(t){const n=o(t);return d.test(n)},t.isHMCard=function(t){const n=o(t);return U.test(n)},t.isIPv4=function(t){const n=o(t);return Z.test(n)},t.isIPv6=function(t){const n=o(t);return _.test(n)},t.isIdCard=a,t.isMobile=function(t){const n=o(t);return i.test(n)},t.isPassport=function(t){const n=o(t);return N.test(n)},t.isPassword=function(t,{level:n=2,ignoreCase:e=!1,special:r="\\x21-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7E"}={}){return C(t,{level:n,ignoreCase:e,special:r}).validated},t.isPostcode=function(t){const n=o(t);return u.test(n)},t.isPromiseLike=function(t){return null!==t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then},t.isQQ=function(t){const n=o(t);return l.test(n)},t.isSocialCreditCode=function(t,{loose:n=!1}={}){const e=o(t),r=b.test(e);if(n||!r)return r;const i=e.substring(0,17);return e.substring(e.length-1)===function(t){let n=0;for(let e=0;e<17;e++)n+=y(t[e])*m[e];return $[31-n%31]}(i)},t.isTWCard=function(t){const n=o(t);return k.test(n)},t.isTelephone=function(t){const n=o(t);return s.test(n)},t.isUrl=function(t){const n=o(t);return I.test(n)},t.isVehicle=function(t){const n=o(t);return g.test(n)},t.isWX=function(t){const n=o(t);return f.test(n)},t.minus=function t(...n){const[e,o,...i]=n;if(i.length>0)return t(t(e,o),...i);if((!pt(o)||q(o))&&!r(o))return e;const s=Math.pow(10,Math.max(Y(e),Y(o)));return(ht(e,s)-ht(o,s))/s},t.normalizeString=et,t.numberToChinese=function(t,{big5:n=!1,unit:e=!0,decimal:r="点",zero:o="",negative:i="负",unitConfig:s={w:"万",y:"亿"}}={}){if("number"!=typeof t||isNaN(t))return w.disableWarning||console.warn(`参数错误 ${t},请传入数字`),"";K(t),n?(ut=it.slice(),ct=st.slice()):(ut=rt.slice(),ct=ot.slice()),at=["",s.w||"万",s.y||"亿",s.w&&s.y?s.w+s.y:"万亿"],o&&(ut[0]=o);const u=t<0?i:"";let c,a;return c=e?function(t){let n=0,e="",r="",o=!1;if(0===(t=Math.floor(t)))return ut[0];for(;t>0;){var i=t%1e4;o&&(r=ut[0]+r),e=dt(i),e+=0!==i?at[n]:at[0],r=e+r,o=i<1e3&&i>0,t=Math.floor(t/1e4),n++}return r}(t):lt(Math.floor(t)),a=function(t){const n=t+"",e=n.indexOf(".");let r="";if(e>-1){let t=n.slice(e+1);r=lt(parseInt(t))}return r}(t),a?`${u}${c}${r}${a}`:`${u}${c}`},t.parseIdCard=function(t){if(!a(t,{loose:!0}))return null;const n=ft.exec(t);if(!n)return null;let e={province:"",city:"",area:"",year:"",month:"",day:"",gender:""};e=n.groups?n.groups:{province:n[1],city:n[2],area:n[3],year:n[4],month:n[5],day:n[6],gender:n[7]};const r=gt.find((t=>t[0]===e.province));if(!r)return null;const o=`${e.year}-${e.month}-${e.day}`,i=Number(e.gender)%2==0?"女":"男";return{province:r[1],birthday:o,gender:i,origin:e}},t.plus=function t(...n){const[e,o,...i]=n;if(i.length>0)return t(t(e,o),...i);if((!pt(o)||q(o))&&!r(o))return e;const s=Math.pow(10,Math.max(Y(e),Y(o)));return(ht(e,s)+ht(o,s))/s},t.replaceChar=function(t="",{start:n=3,end:e=-4,char:r="*",repeat:o,exclude:i}={}){const s=t.length;if(Math.abs(n)>=s)return t;if((n=n>=0?n:s+n)>=(e=e>=0?e:s+e))return t;let u=t.substring(n,e);if(i){const t=new RegExp(`[^${i}]`,"g");u=u.replace(t,r)}else o="number"==typeof o&&o>=0?o:u.length,u=r.repeat(o);return t.substring(0,n)+u+t.substring(e)},t.round=function(t,n=0){const e=Math.pow(10,n);return bt(Math.round(ht(t,e)),e)},t.safeDate=function(t,...n){const e="string"==typeof t?t.replace(/[\\.-]/g,"/"):t;return n&&n.length>0?new Date(e,...n):nt(e)?new Date:new Date(e)},t.setDataURLPrefix=function(t,n="image/png",e=!0){return`data:${n}${e?";base64":""},${t}`},t.setDisableWarning=function(t){w.disableWarning=!!t},t.times=ht,t.validatePassword=C,t.waitTime=function(t=1e3){return new Promise((n=>{setTimeout(n,t)}))},Object.defineProperty(t,"__esModule",{value:!0})}));
1
+ !function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).utilHelpers={})}(this,(function(t){"use strict";const n=Object.prototype.toString;function e(t,e){return n.call(t)===`[object ${e}]`}function r(t){return e(t,"String")}function o(t){return r(t)?t:String(t)}const i=/^1[3456789]\d{9}$/;const s=/^(0\d{2,3}\-)?([2-9]\d{6,7})(\-\d{1,6})?$/;const u=/^\d{6}$/;const c=/^[1-9]\d{5}(19|20)?\d{2}((0[1-9])|(1[012]))(([0-2][1-9])|10|20|30|31)\d{3}(\d|X)?$/i;function a(t,{loose:n=!1,checkCode:e=!0}={}){const r=o(t);return 15===r.length&&n?c.test(r):!(18!==r.length||!c.test(r))&&(!e||function(t){let n,e,r;for(e=n=0;n<17;n++)e+=Math.pow(2,17-n)%11*Number(t[n]);return r=(12-e%11)%11,r<10?r===Number(t[17]):"X"==t[17]}(r))}const d=/^[\da-z]+([\-\.\_]?[\da-z]+)*@[\da-z]+([\-\.]?[\da-z]+)*(\.[a-z]{2,})+$/i;const l=/^[1-9]\d{4,10}$/;const f=/^[a-z]([-_a-z0-9]{5,19})+$/i;const g=/^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([A-Z0-9]{4}[A-Z0-9挂学警港澳]{1})|([A-Z0-9]{5}[DF])|([DF][A-Z0-9]{5}))$/;const p=/^[1-9]\d{9,20}$/,h=/^\d{8,30}$/;const b=/^[\dA-HJ-NPQRTUWXY]{2}\d{6}[\dA-HJ-NPQRTUWXY]{10}$/,$="0123456789ABCDEFGHJKLMNPQRTUWXY".split(""),m=[1,3,9,27,19,26,16,17,20,29,25,13,8,24,10,30,28];function y(t){let n;return $.some(((e,r)=>e===t&&(n=r,!0))),n}const w={disableWarning:!0};const A=/[\d]/,x=/[a-z]/,F=/[A-Z]/,M=/[\d|a-z]/gi;function v(t){return t.indexOf("\\x")>-1||t.indexOf("\\u")>-1}function C(t,{level:n=2,ignoreCase:e=!1,special:r="\\x21-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7E"}={}){let o=t;"string"!=typeof t&&(w.disableWarning||console.warn("[validatePassword] value must be a string."),o="");let i=0;const s=(u=o,A.test(u));var u;const c=function(t){return x.test(t)}(o),a=function(t){return F.test(t)}(o),d=function(t,n=""){if(!n)return!1;const e=t.replace(M,""),r=v(n)?new RegExp(`[${n}]`):null;if(r)return r.test(e);let o=!1;return e.split("").some((t=>(n.indexOf(t)>-1&&(o=!0),o))),o}(o,r),l=function(t,n=""){const e=t.replace(M,"");if(!n&&e)return!0;const r=v(n)?new RegExp(`[^${n}]`):null;if(r)return r.test(e);let o=!1;return e.split("").some((t=>(-1===n.indexOf(t)&&(o=!0),o))),o}(o,r);s&&(i+=1),e?(c||a)&&(i+=1):(c&&(i+=1),a&&(i+=1)),d&&(i+=1);return{validated:i>=n&&!l,level:i,containes:{number:s,lowerCaseLetter:c,upperCaseLetter:a,specialCharacter:d,unallowableCharacter:l}}}const N=/^((e[\da-z])|(de)|(se)|(pe)|(k[\da-z])|(kj)|(ma))[\da-z]{7}$/i;const B="[一-龥]",E="[麦-鿯]",P="[㐀-䶵]",R="[𠀀-𪛖]",z="[𪜀-𫜴]",T="[𫝀-𫠝]",S="[𫠠-𬺡]",D="[𬺰-𮯠]";let W=B+"+",j="^"+B+"+$";const Z=RegExp.prototype.hasOwnProperty("unicode");Z&&(W="(?:"+B+"|"+E+"|"+P+"|"+R+"|"+z+"|"+T+"|"+S+"|"+D+")+",j="^(?:"+B+"|"+E+"|"+P+"|"+R+"|"+z+"|"+T+"|"+S+"|"+D+")+$");const L=/^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;const _=/^((([0-9A-F]{1,4}:){7}([0-9A-F]{1,4}|:))|(([0-9A-F]{1,4}:){6}(:[0-9A-F]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3})|:))|(([0-9A-F]{1,4}:){5}(((:[0-9A-F]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3})|:))|(([0-9A-F]{1,4}:){4}(((:[0-9A-F]{1,4}){1,3})|((:[0-9A-F]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(([0-9A-F]{1,4}:){3}(((:[0-9A-F]{1,4}){1,4})|((:[0-9A-F]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(([0-9A-F]{1,4}:){2}(((:[0-9A-F]{1,4}){1,5})|((:[0-9A-F]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(([0-9A-F]{1,4}:){1}(((:[0-9A-F]{1,4}){1,6})|((:[0-9A-F]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(:(((:[0-9A-F]{1,4}){1,7})|((:[0-9A-F]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:)))(%.+)?$/i;const I=/(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/;const O=/^\d{15}$/;const U=/^[hm]{1}([0-9]{10}|[0-9]{8})$/i;const k=/^(\d{8}|[\da-z]{10})$/i;const X=Number.MAX_SAFE_INTEGER||9007199254740991,H=Number.MIN_SAFE_INTEGER||-9007199254740991;function Q(t){return/\d+\.?\d*e[\+\-]*\d+/i.test(t)}function G(t,n=12){return+parseFloat(t.toPrecision(n))}function Y(t){const n=t.toString().split(/e/i),e=(n[0].split(".")[1]||"").length-+(n[1]||0);return e>0?e:0}function J(t){if(!Q(t.toString()))return Number(t.toString().replace(".",""));const n=Y(t);return n>0?G(+t*Math.pow(10,n)):+t}function K(t){(+t>X||+t<H)&&(w.disableWarning||console.warn(`${t} is beyond boundary when transfer to integer, the results may not be accurate`))}function V(t){const n=/^([+-])?(0+)([0-9\.]+)$/.exec(t);let e;return n?(e=n[1]||"",e+("."===n[3][0]?"0"+n[3]:n[3])):t}function q(t){return e(t,"Number")&&isNaN(t)}const tt=/^[+-]?\d*\.?\d*$/;function nt(t){return function(t){return void 0===t}(t)||function(t){return null===t}(t)}function et(t){return nt(t)?"":o(t)}const rt=["零","一","二","三","四","五","六","七","八","九"],ot=["","十","百","千"],it=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],st=["","拾","佰","仟"];let ut,ct,at;function dt(t){let n="",e="",r=!1,o=0;for(;t>0;){let i=t%10;0==i?r&&(r=!1,e=ut[i]+e):(r=!0,n=ut[i],n+=ct[o],e=n+e),o++,t=Math.floor(t/10)}return e}function lt(t){const n=t+"";let e="";for(let t=0,r=n.length;t<r;t++)e+=ut[parseInt(n[t])];return e}const ft=/^(?<province>\d{2})(?<city>\d{2})(?<area>\d{2})(?<year>(?:\d{2})?\d{2})(?<month>\d{2})(?<day>\d{2})\d{2}(?<gender>\d)(?:\d|X)?$/i,gt=[["11","北京市"],["12","天津市"],["13","河北省"],["14","山西省"],["15","内蒙古自治区"],["21","辽宁省"],["22","吉林省"],["23","黑龙江省"],["31","上海市"],["32","江苏省"],["33","浙江省"],["34","安徽省"],["35","福建省"],["36","江西省"],["37","山东省"],["41","河南省"],["42","湖北省"],["43","湖南省"],["44","广东省"],["45","广西壮族自治区"],["46","海南省"],["50","重庆市"],["51","四川省"],["52","贵州省"],["53","云南省"],["54","西藏自治区"],["61","陕西省"],["62","甘肃省"],["63","青海省"],["64","宁夏回族自治区"],["65","新疆维吾尔自治区"],["71","台湾省"],["83","台湾省"],["81","香港特别行政区"],["82","澳门特别行政区"]];function pt(t){return e(t,"Number")}function ht(...t){const[n,e,...o]=t;if(o.length>0)return ht(ht(n,e),...o);if((!pt(e)||q(e))&&!r(e))return n;const i=J(n),s=J(e),u=Y(n)+Y(e),c=i*s;return K(c),c/Math.pow(10,u)}function bt(...t){const[n,e,...o]=t;if(o.length>0)return bt(bt(n,e),...o);if((!pt(e)||q(e))&&!r(e))return n;const i=J(n),s=J(e);return K(i),K(s),ht(i/s,G(Math.pow(10,Y(e)-Y(n))))}t.blobToDataURL=function(t){return new Promise(((n,e)=>{const r=new FileReader;r.readAsDataURL(t),r.onload=()=>n(r.result),r.onerror=t=>e(t)}))},t.bytesToSize=function(t){if(0===t)return"0 B";const n=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],e=Math.floor(Math.log(t)/Math.log(1024));return n[e]?`${Number((t/Math.pow(1024,e)).toFixed(2))} ${n[e]}`:t+""},t.calculateCursorPosition=function(t,n,e,r,{placeholderChar:o=" ",maskReg:i=/\D/g,type:s}={}){const u=et(n),c=et(e),a=Array.isArray(o)?o:[o],d=c.length-u.length;let l=t;if(d>0){let t=c.substring(l-d,l).replace(i,"").length;l-=d-t;let n=0;for(;t>0;)-1!==a.indexOf(r.charAt(l-t+n))?n++:t--;l+=n}return("mobile"===s&&(4===l||9===l)||"bankCard"===s&&l>0&&l%5==0)&&(l-=1),l},t.dataURLToBlob=function(t){const n=t.split(","),e=n[0].match(/:(.*?);/)[1],r=atob(n[1]);let o=r.length;const i=new Uint8Array(o);for(;o--;)i[o]=r.charCodeAt(o);return new Blob([i],{type:e})},t.divide=bt,t.formatBankCard=function(t="",{char:n=" ",length:e=4}={}){const r=new RegExp(`(.{${e}})`,"g"),o=new RegExp(`${n}`,"g"),i=et(t).replace(o,""),s=i.replace(r,`$1${n}`);return i.length%e==0?s.substring(0,s.length-1):s},t.formatMobile=function(t,{char:n=" "}={}){const e=new RegExp(n,"g"),r=et(t).replace(e,"").substring(0,11);return r.length>7?r.replace(/^(...)(....)/g,`$1${n}$2${n}`):r.length>3?r.replace(/^(...)/g,`$1${n}`):r},t.formatMoney=(t,{precision:n=2,symbol:e,thousand:r=",",decimal:o="."}={})=>{if(!function(t){return!tt.test(t)&&!Q(t)||q(t)||"number"!=typeof t&&"string"!=typeof t||""===t?(w.disableWarning||console.warn(`${t} invalid parameter.`),!1):("number"==typeof t&&K(t),!0)}(t))return"";"number"!=typeof n||q(n)||n<0?n=2:n>10&&(n=10),e="string"==typeof e?e:"",r="string"==typeof r?r:",",o="string"==typeof o?o:".";const i=function(t){if(Q(t.toString())){const n="0",e=String(t).toLowerCase().split("e"),r=e.pop(),o=Math.abs(r),i=r/o,s=e[0].split(".");if(-1===i)t=n+"."+new Array(o).join(n)+s.join("");else{const e=s[1];t=o-e.length<0?V(s[0]+e.substring(0,o))+"."+e.substring(o):s.join("")+new Array(o-e.length+1).join(n)}}return t}(t)+"",[s,u]=i.split(".");return e+function(t,n){let e="";t="+"===(t=V(t))[0]?t.substring(1):t;const r=Number(t)<0?"-":"",o=r?t.substring(1).split("").reverse():t.split("").reverse();for(let t=0;t<o.length;t++)e+=o[t]+((t+1)%3==0&&t+1!==o.length?n:"");return r+e.split("").reverse().join("")}(s,r)+function(t,n,e){if(0===n)return"";let r="";r=t&&Number(t)>0?parseFloat("0."+t).toFixed(n).substring(2):(0).toFixed(n).substring(2);return e+r}(u,n,o)},t.isBankCard=function(t,{loose:n=!1}={}){const e=o(t);return n?h.test(e):p.test(e)},t.isBusinessLicense=function(t,{loose:n=!1}={}){const e=o(t),r=O.test(e);if(n||!r)return r;const i=e.substring(0,14),s=e.substring(e.length-1),u=function(t){let n,e=10;for(let n=0;n<14;n++){let r=(e+Number(t[n]))%10;r=0===r?10:r,e=2*r%11}return n=10===e||1===e?1:11-e,n}(i);return s===String(u)},t.isChinese=function(t,{loose:n=!1}={}){const e=o(t);return new RegExp(n?W:j,Z?"u":void 0).test(e)},t.isEmail=function(t){const n=o(t);return d.test(n)},t.isHMCard=function(t){const n=o(t);return U.test(n)},t.isIPv4=function(t){const n=o(t);return L.test(n)},t.isIPv6=function(t){const n=o(t);return _.test(n)},t.isIdCard=a,t.isMobile=function(t){const n=o(t);return i.test(n)},t.isPassport=function(t){const n=o(t);return N.test(n)},t.isPassword=function(t,{level:n=2,ignoreCase:e=!1,special:r="\\x21-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7E"}={}){return C(t,{level:n,ignoreCase:e,special:r}).validated},t.isPostcode=function(t){const n=o(t);return u.test(n)},t.isPromiseLike=function(t){return null!==t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then},t.isQQ=function(t){const n=o(t);return l.test(n)},t.isSocialCreditCode=function(t,{loose:n=!1}={}){const e=o(t),r=b.test(e);if(n||!r)return r;const i=e.substring(0,17);return e.substring(e.length-1)===function(t){let n=0;for(let e=0;e<17;e++)n+=y(t[e])*m[e];return $[31-n%31]}(i)},t.isTWCard=function(t){const n=o(t);return k.test(n)},t.isTelephone=function(t){const n=o(t);return s.test(n)},t.isUrl=function(t){const n=o(t);return I.test(n)},t.isVehicle=function(t){const n=o(t);return g.test(n)},t.isWX=function(t){const n=o(t);return f.test(n)},t.minus=function t(...n){const[e,o,...i]=n;if(i.length>0)return t(t(e,o),...i);if((!pt(o)||q(o))&&!r(o))return e;const s=Math.pow(10,Math.max(Y(e),Y(o)));return(ht(e,s)-ht(o,s))/s},t.normalizeString=et,t.numberToChinese=function(t,{big5:n=!1,unit:e=!0,decimal:r="点",zero:o="",negative:i="负",unitConfig:s={w:"万",y:"亿"}}={}){if("number"!=typeof t||isNaN(t))return w.disableWarning||console.warn(`参数错误 ${t},请传入数字`),"";K(t),n?(ut=it.slice(),ct=st.slice()):(ut=rt.slice(),ct=ot.slice()),at=["",s.w||"万",s.y||"亿",s.w&&s.y?s.w+s.y:"万亿"],o&&(ut[0]=o);const u=t<0?i:"";let c,a;return c=e?function(t){let n=0,e="",r="",o=!1;if(0===(t=Math.floor(t)))return ut[0];for(;t>0;){var i=t%1e4;o&&(r=ut[0]+r),e=dt(i),e+=0!==i?at[n]:at[0],r=e+r,o=i<1e3&&i>0,t=Math.floor(t/1e4),n++}return r}(t):lt(Math.floor(t)),a=function(t){const n=t+"",e=n.indexOf(".");let r="";if(e>-1){let t=n.slice(e+1);r=lt(parseInt(t))}return r}(t),a?`${u}${c}${r}${a}`:`${u}${c}`},t.padZero=function(t,n=2){const e=et(t),r=e.length;return("number"!=typeof n||n<0)&&(n=0),r<n?"0".repeat(n-r)+e:e},t.parseIdCard=function(t){if(!a(t,{loose:!0}))return null;const n=ft.exec(t);if(!n)return null;let e={province:"",city:"",area:"",year:"",month:"",day:"",gender:""};e=n.groups?n.groups:{province:n[1],city:n[2],area:n[3],year:n[4],month:n[5],day:n[6],gender:n[7]};const r=gt.find((t=>t[0]===e.province));if(!r)return null;const o=`${e.year}-${e.month}-${e.day}`,i=Number(e.gender)%2==0?"女":"男";return{province:r[1],birthday:o,gender:i,origin:e}},t.plus=function t(...n){const[e,o,...i]=n;if(i.length>0)return t(t(e,o),...i);if((!pt(o)||q(o))&&!r(o))return e;const s=Math.pow(10,Math.max(Y(e),Y(o)));return(ht(e,s)+ht(o,s))/s},t.replaceChar=function(t="",{start:n=3,end:e=-4,char:r="*",repeat:o,exclude:i}={}){const s=t.length;if(Math.abs(n)>=s)return t;if((n=n>=0?n:s+n)>=(e=e>=0?e:s+e))return t;let u=t.substring(n,e);if(i){const t=new RegExp(`[^${i}]`,"g");u=u.replace(t,r)}else o="number"==typeof o&&o>=0?o:u.length,u=r.repeat(o);return t.substring(0,n)+u+t.substring(e)},t.round=function(t,n=0){const e=Math.pow(10,n);return bt(Math.round(ht(t,e)),e)},t.safeDate=function(t,...n){const e="string"==typeof t?t.replace(/[\\.-]/g,"/"):t;return n&&n.length>0?new Date(e,...n):nt(e)?new Date:new Date(e)},t.setDataURLPrefix=function(t,n="image/png",e=!0){return`data:${n}${e?";base64":""},${t}`},t.setDisableWarning=function(t){w.disableWarning=!!t},t.times=ht,t.validatePassword=C,t.waitTime=function(t=1e3){return new Promise((n=>{setTimeout(n,t)}))},Object.defineProperty(t,"__esModule",{value:!0})}));
2
2
  //# sourceMappingURL=util-helpers.min.js.map