/** @dense-labs/utils v1.2.14 by move11@126.com */ "use strict";function t(e){return Object.prototype.toString.call(e)}function e(e){return null===e}function r(t){var r=typeof t;return!e(t)&&("object"==r||"function"==r)}function n(t){if(!/^[1-9]\d{5}(18|19|20)\d{2}(0\d|1[0-2])([0-2]\d|3[0-1])\d{3}[\dX]$/.test(t))return!1;var r=[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2];let n=0;for(let e=0;en[e])}function d(e){return(e=e.toString())[1]?e:"0"+e}function p(e){return[e.getFullYear(),e.getMonth()+1,e.getDate()].map(d).join("-")}class f{static STORAGE_PREFIX="__ex_local_storage_";static getStorageKey(e){return""+f.STORAGE_PREFIX+e}setItem(e,t,r){t={value:t};r&&(t.expireTime=Date.now()+r),localStorage.setItem(f.getStorageKey(e),JSON.stringify(t))}getItem(e){var t=localStorage.getItem(f.getStorageKey(e));return t?(t=JSON.parse(t),Date.now()>t.expireTime?(localStorage.removeItem(f.getStorageKey(e)),null):t.value):null}removeItem(e){localStorage.removeItem(f.getStorageKey(e))}clear(){localStorage.clear()}}function g(e){e=document.cookie.match(new RegExp("(^| )"+e+"=([^;]+)"));return e?e[2]:null}exports.ExLocalStorage=f,exports.addClass=s,exports.base64ToBlob=function(e,t="text/plain"){var r=atob(e),n=[];for(let e=0;ee.blob()),e=URL.createObjectURL(e),r=document.createElement("a");r.href=e,r.download=t,r.click(),URL.revokeObjectURL(e)},exports.copyToClipboard=async function(e){if(navigator.clipboard)try{return await navigator.clipboard.writeText(e),console.log("Text copied to clipboard"),!0}catch(e){return console.error("Error copying text: ",e),!1}else{var t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t),t.focus(),t.select();try{const e=document.execCommand("copy");return document.body.removeChild(t),e?(console.log("Text copied to clipboard"),!0):(console.error("Unable to copy text to clipboard"),!1)}catch(e){return console.error("Error copying text: ",e),!1}}},exports.dateFormat=u,exports.debounce=function(r,n,o={leading:!1}){let a,i;function e(...e){a&&clearTimeout(a);var t=!a&&o?.leading;return a=setTimeout(s,n,this,e),i=t?r.apply(this,e):i}const s=(e,t)=>{a=null,t&&(i=r.apply(e,t))};return e.cancel=function(){clearTimeout(a),a=null},e},exports.deleteCookie=function(e){document.cookie=e+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"},exports.fileToBase64=async function(r){const n=new FileReader;return new Promise((t,e)=>{n.onload=()=>{var e=n.result;t(e.split(",")[1])},n.onerror=()=>{e(n.error)},n.readAsDataURL(r)})},exports.formatCurrency=function(e,t=","){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,t)},exports.formatDate=p,exports.formatNumber=d,exports.formatString=function(e,...n){return e.replace(/\{(\d+)\}/g,(e,t)=>{var r=n[t];return t in n?r.toString():e})},exports.formatTimeFromSeconds=function(e,t=!1){var r,n,o;if(e)return r=Math.floor(e/86400),e%=86400,n=Math.floor(e/3600),e%=3600,o=Math.floor(e/60),e%=60,t?{days:r,hours:n,minutes:o,seconds:e}:(0new Promise(t=>{const r=document.createElement("video"),n=document.createElement("canvas"),o=n.getContext("2d");r.src=e,r.style.cssText="position: fixed; top: -100%; left: -100%; width: 400px; display: none; visibility: hidden;",r.controls=!0,r.crossOrigin="Anonymous",r.currentTime=a,r.addEventListener("loadedmetadata",function(){n.width=r.videoWidth,n.height=r.videoHeight,o&&o.drawImage(r,0,0,n.width,n.height);var e=n.toDataURL("image/png");t(e)}),t("")}),exports.getGender=function(e){if(n(e))return parseInt(e.substring(16,17))%2==0?"女":"男";throw new Error("Invalid idCard number")},exports.getLatelyDay=function(e){var t=(new Date).getTime();return new Date(t-864e5*e)},exports.getLatelyMonth=function(e){var e=e||1,t=new Date;return t.setMonth(t.getMonth()-e),t.getFullYear()+"-"+(t.getMonth()+1<10?"0":"")+(t.getMonth()+1)+"-"+(t.getDate()<10?"0":"")+t.getDate()},exports.getNextDay=function(e){return p(new Date((new Date).getTime()+24*e*60*60*1e3))},exports.getScrollBarWidth=function(){var e,t,r;return void 0===l&&((e=document.createElement("div")).className="scrollbar__wrap",e.style.visibility="hidden",e.style.width="100px",e.style.position="absolute",e.style.top="-9999px",document.body.appendChild(e),t=e.offsetWidth,e.style.overflow="scroll",(r=document.createElement("div")).style.width="100%",e.appendChild(r),r=r.offsetWidth,e.parentNode?.removeChild(e),l=t-r),l},exports.getUrlParameter=function(e,t){var e=e.split("?")[1]||e.split("#")[1];return e&&(t=new RegExp("(^|&)"+t+"=([^&]*)(&|$)"),null!=(e=e.match(t)))?decodeURIComponent(e[2]):null},exports.getWeekByDay=function(e){var t,r;return e?([e,t,r]=e.split("-").map(Number),e=new Date(e,t-1,r),"星期"+"日一二三四五六".charAt(e.getDay())):""},exports.getYearsAroundCurrent=function(r,e,n=(new Date).getFullYear()){if(r<0||e<0)throw new Error("yearsBefore or yearsAfter Must be a positive integer ");return Array.from({length:r+e+1},(e,t)=>n-r+t)},exports.hasClass=i,exports.hasCookie=function(e){return null!==g(e)},exports.imageUrlToBase64=function(e){const o=new Image;return new Promise((r,n)=>{o.addEventListener("load",()=>{var e=document.createElement("canvas"),t=(e.width=o.width,e.height=o.height,e.getContext("2d"));if(t){t.drawImage(o,0,0);const n=e.toDataURL();r(n)}else n(new Error("Failed to convert image URL to Base64"))}),o.addEventListener("error",()=>{n(new Error("Failed to load image"))}),o.src=e})},exports.isArray=function(e){return Array.isArray(e)},exports.isBigInt=function(e){return"bigint"==typeof e},exports.isBoolean=function(e){return"boolean"==typeof e},exports.isDate=function(e){return!(!e||"string"==typeof e&&isNaN(Date.parse(e))||"Invalid Date"===(e=new Date(e)).toString()||isNaN(e.getTime()))},exports.isEarlierThanMonth=function(e,t){return ee.length?e.length:t,r.repeat(t)+e.slice(t)},exports.maskRight=function(e,t,r="*"){if(t<0)throw new Error("Invalid number of characters");return 0===(t=t>e.length?e.length:t)?e:e.slice(0,-t)+r.repeat(t)},exports.maskString=function(e,t=0,r=e.length,n="*"){if(t<0||r>e.length||r<=t)throw new Error("Invalid start or end position");var o=r-t;return e.substring(0,t)+n.repeat(o)+e.substring(r)},exports.openLink=function(e,t="_blank"){var r=document.createElement("a"),e=(r.setAttribute("href",e),r.setAttribute("target",t),r.setAttribute("rel","noreferrer noopener"),r.setAttribute("id","external"),document.getElementById("external"));e&&document.body.removeChild(e),document.body.appendChild(r),r.click(),r.remove()},exports.pasteFromClipboard=async function(){if(navigator.clipboard)try{return await navigator.clipboard.readText()}catch(e){return console.error("Error pasting text: ",e),""}else{var e=document.createElement("textarea");e.style.position="fixed",e.style.position="fixed",e.style.position="absolute",e.style.left="-9999px",document.body.appendChild(e),e.focus();try{var t=document.execCommand("paste");return(document.body.removeChild(e),t)?e.value:(console.error("Unable to paste text from clipboard"),"")}catch(e){return console.error("Error pasting text: ",e),""}}},exports.removeClass=c,exports.serialize=function(t){let r=[];return Object.keys(t).forEach(e=>{r.push(e+"="+t[e])}),r.join("&")},exports.setCookie=function(e,t,r){let n=e+"="+t;r&&(n+="; expires="+r.toUTCString()),document.cookie=n},exports.shuffle=function(e){return e.sort(()=>Math.random()-.5)},exports.shuffleArray=function e(r,t=!1){if(r.length<=1)return r;let n;if(t){n=[...r];for(let e=0;ee===r[t]);)n=e(r,!0);return n},exports.shuffleObject=function e(t,r=!0){var n=r?JSON.parse(JSON.stringify(t)):t,o=Object.keys(n);if(o.length<=1)return n;for(let e=o.length-1;0new Promise(e=>setTimeout(e,t)),exports.storageLocal=function(){return new f},exports.throttle=function(n,o,a={leading:!1,trailing:!1}){let i,s,l,u,c=0;function e(...e){var t=Date.now(),r=(c||!1!==a.leading||(c=t),o-(t-c));return s=this,l=e,r<=0||o{c=!1===a.leading?0:Date.now(),i=null,u=n.apply(s,l),i||(s=l=null)};return e.cancel=function(){clearTimeout(i),c=0,i=s=l=null},e},exports.toggleClass=function(e,t){(i(e,t)?c:s)(e,t)},exports.trim=e=>e.toString().replace(/^\s+|\s+$/g,"");