js-cool
Version:
Collection of common JavaScript / TypeScript utilities
8 lines (7 loc) • 35.7 kB
JavaScript
/*!
* js-cool v5.23.1
* Collection of common JavaScript / TypeScript utilities
* (c) 2021-2025 saqqdy
* Released under the MIT License.
*/
import e from"load-source";export{default as loadSource}from"load-source";import r from"mount-css";export{default as mountCss}from"mount-css";import n from"mount-image";export{default as mountImg}from"mount-image";import t from"mount-script";export{default as mountJs}from"mount-script";import o from"mount-style";export{default as mountStyle}from"mount-style";import{download as i}from"use-downloads";export{download}from"use-downloads";import a from"await-to-done";export{default as awaitTo}from"await-to-done";import{__read as u,__spreadArray as c,__assign as l,__values as s}from"tslib";var f=function(e,r){void 0===e&&(e=""),void 0===r&&(r=navigator.userAgent);var n=r.toLowerCase();return e?r.includes(e):{IE:n.includes("msie")&&!n.includes("opera"),GECKO:n.includes("gecko")&&!n.includes("khtml"),WEBKIT:n.includes("applewebkit"),OPERA:n.includes("opera")&&n.includes("presto"),TRIDENT:n.includes("trident"),MOBILE:!!r.match(/AppleWebKit.*Mobile.*/),IOS:!!r.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),ANDROID:r.includes("Android")||r.includes("Adr"),IPHONE:r.includes("iPhone"),IPAD:r.includes("iPad"),QQBROWSER:r.includes("QQBrowser"),WEIXIN:r.includes("MicroMessenger"),QQ:r.match(/\sQQ/i)}},d={any:/[\w\W]+/,number:/^(\-|\+)?(0|[1-9]\d*)(\.\d+)?$/,string:/^[\u4E00-\u9FA5\uF900-\uFA2D\w\.\s]+$/,postcode:/^[0-9]{6}$/,url:/^(\w+:\/\/)?\w+(\.\w+)+.*$/,username:/^[a-zA-Z0-9\_\-\.]{3,15}$/,float:/^[0-9]+\.{0,1}[0-9]{0,2}$/,email:/^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/,mobile:/^1[3|4|5|7|8][0-9]\d{8,8}$/,chinese:/^[\u4E00-\u9FA5\uF900-\uFA2D]$/,tel:/^(([0\+]\d{2,3}-)?(0\d{2,3})-)?(\d{7,8})(-(\d{3,}))?$/,qq:/^[1-9][0-9]{5,13}$/,pass:/^(?![0-9\W\_]+$)(?![a-zA-Z\W\_]+$)[0-9a-zA-Z\W\_]{6,16}$/,json:/^\{[\s\S]*\}$/,arrjson:/^\[\{[\s\S]*\}\]$/,array:/^\[[\s\S]*\]$/,isjson:/[\s\S]*(\{[\s\S]*\})[\s\S]*/,textarea:/[\u4E00-\u9FA5_a-zA-Z0-9\,\.\/\?\;\:\'\"\[\]\-\*\(\)()\%\$\@\\\!,《》。、?;:‘’“”…¥!]/,mac:/^((([a-f0-9]{2}:){5})|(([a-f0-9]{2}-){5}))[a-f0-9]{2}$/i,ip4:/^(([1-9]?\d|1\d{2}|2[0-4]\d|25[0-5]).){3}([1-9]?\d|1\d{2}|2[0-4]\d|25[0-5])$/,ip4_pri:/^1(((0|27)(.(([1-9]?|1[0-9])[0-9]|2([0-4][0-9]|5[0-5])))|(72.(1[6-9]|2[0-9]|3[01])|92.168))(.(([1-9]?|1[0-9])[0-9]|2([0-4][0-9]|5[0-5]))){2})$/};function p(e){return e.replace(/(^\s+)|(\s+$)/g,"")}function m(e){return e.replace(/<([a-zA-Z1-7]+)\s*[^><]*>/g,"<$1>")}function v(e){return e.replace(/<\/?.+?>/g,"").replace(/[\r\n]/g,"")}function h(e){var r={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,(function(e){return r[e]}))}function g(e){var r={"&":"&","<":"<",">":">",""":'"',"'":"'"};return e.replace(/&|<|>|"|'/g,(function(e){return r[e]}))}function b(e){return e.replace(/[^0-9.]/gi,"")}function y(e){return e.replace(/([A-Z]{1,1})/g,"-$1").replace(/^-/,"").toLocaleLowerCase()}function w(e){return e.replace(/[\-]{1,1}([a-z]{1,1})/g,(function(){return arguments[1].toLocaleUpperCase()}))}function S(e){return e.slice(0,1).toLocaleUpperCase()+e.slice(1)}function x(e,r){return void 0===e&&(e=1),void 0===r&&(r=10),e+Math.round(Math.random()*(r-e))}function C(e,r){var n,t,o,i,a,c,l,s;return r||e||0===e?(e?"number"==typeof e?o=i=a=e:(o=(n=u(e,3))[0],i=n[1],a=n[2]):o=i=a=0,r?"number"==typeof r?c=l=s=r:(c=(t=u(r,3))[0],l=t[1],s=t[2]):c=l=s=255,"#".concat(x(o,c).toString(16).padStart(2,"0")).concat(x(i,l).toString(16).padStart(2,"0")).concat(x(a,s).toString(16).padStart(2,"0"))):"#".concat(Math.random().toString(16).slice(2,8).padEnd(6,"0"))}function A(e,r){var n=-1,t=!1;"string"==typeof e&&(e=e.split(""),t=!0);var o=e.length,i=o-1;for(r=void 0===r?o:r;++n<r;){var a=n+Math.floor(Math.random()*(i-n+1)),u=e[a];e[a]=e[n],e[n]=u}return e.length=r,t?e.join(""):e}function E(e,r,n){if(null!=e||(e=1),null!=r||(r=100),null!=n||(n=!0),n&&r<e)throw new Error('When "noZero" is true, "sum" cannot be less than "n"');for(var t=0,o=Math.round(r/e),i=[];--e>0;){var a=x(n?1:0,o);t+=a,i.push(a)}return i.push(r-t),A(i)}function j(e){return j="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},j(e)}function O(e,r){var n,t,o,i=["uppercase","lowercase","number"],a=!1,u=!1,c="";"number"!=typeof e&&(e="object"===j(r=e)&&null!==(n=r.length)&&void 0!==n?n:32),"boolean"==typeof r?r&&i.push("special"):r&&(r.charTypes&&r.charTypes.length&&(i=[].concat(r.charTypes)),a=null!==(t=r.noConfuse)&&void 0!==t?t:a,u=null!==(o=r.strict)&&void 0!==o?o:u);var l={uppercase:a?"ABCDEFGHJKMNPQRSTWXYZ":"ABCDEFGHIJKLMNOPQRSTUVWXYZ",lowercase:a?"abcdefghjkmnpqrstwxyz":"abcdefghijklmnopqrstuvwxyz",number:a?"2345678":"0123456789",special:"~!@#$%^&*_+|:-=[];,."};if(!u)return T(e,i.map((function(e){return l[e]})).join(""));var s=E(i.length,e);return i.forEach((function(e,r){c+=T(s[r],l[e])})),A(c)}function T(e,r){for(var n="",t=r.length,o=0;o<e;o++)n+=r.charAt(Math.floor(Math.random()*t));return n}var N="undefined"!=typeof window;function I(e){if(!N)return null;e||(e=location.host);var r=document.createElement("canvas"),n=r.getContext("2d");n.textBaseline="top",n.font="14px 'Arial'",n.fillStyle="#f60",n.fillRect(125,1,62,20),n.fillStyle="#069",n.fillText(e,2,15),n.fillStyle="rgba(102, 204, 0, 0.7)",n.fillText(e,4,17);var t=r.toDataURL().replace("data:image/png;base64,","");return function(e){var r,n,t,o="";for(r=0,n=(e+="").length;r<n;r++)o+=(t=e.charCodeAt(r).toString(16)).length<2?"0"+t:t;return o}(atob(t).slice(-16,-12))}function B(e){return e.replace(/[^\x00-\xFF]/g,"**").length}function P(e,r,n){if(void 0===r&&(r=e.length),void 0===n&&(n=!1),!e)return"";for(var t=0,o="",i="",a=/[^\x00-\xFF]/g,u=e.replace(a,"**").length,c=0;c<u&&(null!=(i=e.charAt(c).toString()).match(a)?t+=2:t++,!(t>r));c++)o+=i;return n&&u>r&&(o+="..."),o}function $(e){return/^[0-9]*$/.test(e)}function k(e){return"function"==typeof function(e){var r=Function;try{return new r("return "+e)()}catch(e){return}}(e)}function D(e){return Object.prototype.toString.call(e).includes("Array")}var F=function(e,r,n,t){if(e===r)return 0!==e||1/e==1/r;if(null==e||null==r)return e===r;var o=toString.call(e);if(o!==toString.call(r))return!1;switch(o){case"[object RegExp]":case"[object String]":return""+e==""+r;case"[object Number]":return+e!=+e?+r!=+r:0==+e?1/+e==1/r:+e==+r;case"[object Date]":case"[object Boolean]":return+e==+r}var i=D(e)&&D(r);if(!i){if("object"!=j(e)||"object"!=j(r))return!1;var a=e.constructor,u=r.constructor;if(a!==u&&!("function"==typeof a&&a instanceof a&&"function"==typeof u&&u instanceof u)&&"constructor"in e&&"constructor"in r)return!1}t=t||[];for(var c=(n=n||[]).length;c--;)if(n[c]===e)return t[c]===r;if(n.push(e),t.push(r),i){if((c=e.length)!==r.length)return!1;for(;c--;)if(!F(e[c],r[c],n,t))return!1}else{var l=Object.keys(e),s=void 0;if(c=l.length,Object.keys(r).length!==c)return!1;for(;c--;)if(!((s=l[c])in r)||!F(e[s],r[s],n,t))return!1}return n.pop(),t.pop(),!0};function M(e,r){return F(e,r)}function R(e){try{return void 0!==e}catch(e){}return!1}function U(e){return null===e?"null":"object"===j(e)||"function"==typeof e?{"[object Array]":"array","[object Boolean]":"boolean","[object Date]":"date","[object Promise]":"promise","[object Function]":"function","[object AsyncFunction]":"function","[object GeneratorFunction]":"function","[object Math]":"math","[object Window]":"window","[object Navigator]":"navigator","[object global]":"global","[object HTMLDocument]":"document","[object Symbol]":"symbol","[object Number]":"number","[object Object]":"object","[object RegExp]":"regexp","[object String]":"string","[object Undefined]":"undefined","[object Null]":"null","[object Error]":"error"}[Object.prototype.toString.call(e)]||"object":j(e)}function W(e){return e&&"object"===U(e)}function q(e){return e&&W(e)&&e===e.window}function L(e){return"[object Object]"===Object.prototype.toString.call(e)&&!q(e)&&Object.getPrototypeOf(e)===Object.prototype}function Q(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}function V(e){return e&&"date"===U(e)}function H(e){return e&&"regexp"===U(e)}function z(e){return null!=e&&Symbol.iterator in e}var _="undefined"!=typeof global;function Z(e){return!(!e&&!N)&&(function(e){e=e||navigator.userAgent;var r=e.toLowerCase();if(r.includes("360se")||r.includes("360ee"))return!0;if(e.includes("Safari")&&r.includes("wow64"))return!0;return!1}(e=e||navigator.userAgent)||function(e){if(navigator.userAgent.includes("Safari"))for(var r in navigator.plugins)if(navigator.plugins[r].filename===e)return!0;return!1}("np-mswmp.dll")||function(e,r){var n=navigator.mimeTypes;for(var t in n)if(n[t][e]===r)return!0;return!1}("type","application/vnd.chromium.remoting-viewer"))}function J(){var e={width:0,height:0};return window.innerWidth?(e.width=window.innerWidth,e.height=window.innerHeight):document.body&&document.body.clientWidth&&(e.width=document.body.clientWidth,e.height=document.body.clientHeight),document.documentElement&&document.documentElement.clientWidth&&(e.width=document.documentElement.clientWidth,e.height=document.documentElement.clientHeight),e}function X(e,r,n){n=n||navigator.userAgent;var t=new RegExp(e+"\\/([\\d\\.]+)","i"),o=n.includes(e),i=n.match(t);return i?r?i?i[0]:"":i?i[1]:"":!o&&null}function K(e,r,n){if(!e||"string"!=typeof e)return console.info("appName is required"),null;if("boolean"==typeof r||!r){if(!N)return console.info("ua is required"),null;"boolean"==typeof r&&(n=r),r=navigator.userAgent}"boolean"!=typeof n&&(n=!0);var t=new RegExp("".concat(e,"/(\\d+(?:.\\d+)*(?:-\\w+.\\d+)*)"),n?"i":""),o=r.match(t);return o?o[1]:null}function Y(e,r,n){n=n||navigator.userAgent;var t,o=e,i=["iPhone","iPad","iPod","iWatch","Mac","iMac","iOS"].indexOf(e);i>-1&&n.includes("like Mac OS X")&&(o="OS");var a=new RegExp(o+"\\s[\\d\\_]+","ig");return t=(n.match(a)+"").replace(/\s/gi,"/").replace(/_/gi,"."),i>-1&&(t=t.replace(/OS\//gi,e+"/")),X(e,r,t)}function G(e){if(!e){if(!N)return console.info("url is required"),null;e=navigator.userAgent}e=e.toLowerCase();var r,n={Windows:/windows nt\s+([\w.]+)/,MacOS:/mac os x\s+([\w_]+)/,Android:/android\s+([\d.]+)/,iOS:/i(?:pad|phone|pod)(?:.*)cpu(?: i(?:pad|phone|pod))? os (\d+(?:[\.|_]\d+)+) like/,WindowsPhone:/Windows Phone(?: OS)? ([\d.]+);/,Debian:/Debian\/([\d.]+)/,WebOS:/hpwOS\/([\d.]+);/,Harmony:/openharmony\s+([\d.]+)/};for(r in n){var t=e.match(n[r]);if(t){var o=(t[1]||"").replace(/_/g,".");if("Windows"===r){o={10:"10 || 11",6.3:"8.1",6.2:"8",6.1:"7","6.0":"Vista",5.2:"XP 64-Bit",5.1:"XP","5.0":"2000","4.0":"NT 4.0","3.5.1":"NT 3.5.1",3.5:"NT 3.5",3.1:"NT 3.1"}[o]||o}return{name:r,version:o}}}return null}function ee(e){if(!e){if(!N)return console.info("url is required"),null;e=navigator.userAgent}var r,n={Safari:/Version\/([\d.]+)/,Chrome:/(?:Chrome|CriOS)\/([\d.]+)/,IE:/(?:MSIE |rv:)([\d.]+)/,Edge:/Edge\/([\d.]+)/,Firefox:/(?:Firefox|FxiOS)\/([\d.]+)/,"Firefox Focus":/Focus\/([\d.]+)/,Chromium:/Chromium\/([\d.]+)/,Opera:/(?:Opera|OPR)\/([\d.]+)/,Vivaldi:/Vivaldi\/([\d.]+)/,Yandex:/YaBrowser\/([\d.]+)/,Arora:/Arora\/([\d.]+)/,Lunascape:/Lunascape[\/\s]([\d.]+)/,QupZilla:/QupZilla[\/\s]([\d.]+)/,"Coc Coc":/coc_coc_browser\/([\d.]+)/,Kindle:/Version\/([\d.]+)/,Iceweasel:/Iceweasel\/([\d.]+)/,Konqueror:/Konqueror\/([\d.]+)/,Iceape:/Iceape\/([\d.]+)/,SeaMonkey:/SeaMonkey\/([\d.]+)/,Epiphany:/Epiphany\/([\d.]+)/,360:/QihooBrowser\/([\d.]+)/,"360SE":/Chrome\/([\d.]+)/,"360EE":/Chrome\/([\d.]+)/,Maxthon:/Maxthon\/([\d.]+)/,QQBrowser:/QQBrowser\/([\d.]+)/,QQ:/QQ\/([\d.]+)/,Baidu:/BIDUBrowser[\s\/]([\d.]+)/,UC:/UC?Browser\/([\d.]+)/,Sogou:/(?:SE |SogouMobileBrowser\/)([\d.X]+)/,Liebao:/(?:LieBaoFast|Chrome)\/([\d.]+)/,LBBROWSER:/(?:LieBaoFast|Chrome)\/([\d.]+)/,"2345Explorer":/2345Explorer\/([\d.]+)/,"115Browser":/115Browser\/([\d.]+)/,TheWorld:/TheWorld ([\d.]+)/,XiaoMi:/MiuiBrowser\/([\d.]+)/,Vivo:/VivoBrowser\/([\d.]+)/,Quark:/Quark\/([\d.]+)/,Qiyu:/Qiyu\/([\d.]+)/,Wechat:/MicroMessenger\/([\d.]+)/,WechatWork:/wxwork\/([\d.]+)/,Taobao:/AliApp\(TB\/([\d.]+)/,Alipay:/AliApp\(AP\/([\d.]+)/,Weibo:/weibo__([\d.]+)/,Douban:/com.douban.frodo\/([\d.]+)/,Suning:/SNEBUY-APP([\d.]+)/,iQiYi:/IqiyiVersion\/([\d.]+)/,DingTalk:/DingTalk\/([\d.]+)/,Huawei:/(?:Version|HuaweiBrowser|HBPC)\/([\d.]+)/};for(r in n){var t=e.match(n[r]);if(t){var o=(t[1]||"").replace(/_/g,".");if("360SE"===r)o={63:"10.0",55:"9.1",45:"8.1",42:"8.0",31:"7.0",21:"6.3"}[o]||o;else if("360EE"===r){o={69:"11.0",63:"9.5",55:"9.0",50:"8.7",30:"7.5"}[o]||o}else if(["Liebao","LBBROWSER"].includes(r)){o={57:"6.5",49:"6.0",46:"5.9",42:"5.3",39:"5.2",34:"5.0",29:"4.5",21:"4.0"}[o]||o}return{name:r,version:o}}}return null}function re(e,r){for(var n=["alpha","beta","rc"],t=u(e.split("-"),2),o=t[0],i=t[1],a=void 0===i?"":i,c=u(r.split("-"),2),l=c[0],s=c[1],f=void 0===s?"":s,d=o.split("."),p=l.split("."),m=Math.max(d.length,p.length);d.length<m;)d.push("0");for(;p.length<m;)p.push("0");for(var v=0;v<m;v++){var h=parseInt(d[v]),g=parseInt(p[v]);if(h>g)return 1;if(h<g)return-1}if(!a&&!f)return 0;if(!f)return-1;if(!a)return 1;var b=a.split("."),y=f.split(".");return b[0]=n.indexOf(b[0])+1+"",y[0]=n.indexOf(y[0])+1+"",re(b.join("."),y.join("."))}function ne(e,r){if(void 0===r&&(r=!1),!e)return console.info("url is required"),{};e=e.substring(e.lastIndexOf("?")+1);var n={null:null,undefined:void 0,true:!0,false:!1,NaN:NaN,Infinity:1/0,"-Infinity":-1/0},t={};return e.replace(/([^?&=]+)=([^?&=]*)/g,(function(e,o,i){var a=decodeURIComponent(o);return i=decodeURIComponent(i),t[a]=i,r&&(i in n?t[a]=n[i]:d.number.test(i)&&(t[a]=Number(i))),e})),t}function te(e,r){var n,t,o,i;if(void 0===r&&(r=!1),!e)return console.info("params is required"),"";var a,u=!1,c=!0;"object"===j(r)&&(u=null!==(n=r.encode)&&void 0!==n&&n,c=null===(t=r.withQuestionsMark)||void 0===t||t,r=null!==(o=r.covert)&&void 0!==o&&o);var l=[];for(a in e)if("string"==typeof a){var s=""+(r?null!==(i=e[a])&&void 0!==i?i:"":e[a]);l.push("".concat(a,"=").concat(u?encodeURIComponent(s):s))}return c?"?"+l.join("&"):l.join("&")}function oe(e,r){void 0===r&&(r=!0);var n={undefined:void 0,NaN:NaN,Infinity:1/0,"-Infinity":-1/0};return JSON.parse(e,(function(e,t){return r&&["Infinity","-Infinity","undefined","NaN"].includes(t)?n[t]:"string"==typeof t&&/^(\-|\+)?\d+(\.\d+)?$/.test(t)&&!Number.isSafeInteger(+t)?BigInt(t):t}))}function ie(e,r){return void 0===r&&(r=!0),JSON.stringify(e,(function(e,n){if(r){if([1/0,-1/0,void 0,NaN].includes(n))return String(n);if("number"==typeof n&&!Number.isSafeInteger(n))return String(BigInt(n))}else if("bigint"==typeof n)return String(n);return n}))}function ae(e){var r=""!==e&&void 0!==e?e.replace(/^http[s]?:\/\/[^\/]+([\s\S]*)/,"$1"):location.pathname;r=r.replace(/^\//,"");var n={path:[],host:""};if(""!==e&&void 0!==e){var t=e.match(/^http[s]?:\/\/[^\/]+/);t&&(n.host=t[0])}else n.host=location.host;return r.includes("/")&&(n.path=decodeURI(r).split("/")),n}function ue(e,r){if(e){if(!r){if(!N)return void console.info("url is required");r=location.href}var n=u(r.split("#"),2),t=n[0];return ne(r=(r=n[1]||t).slice(r.lastIndexOf("?")))[e]}console.info("key is required")}function ce(e,r){if(!e||"boolean"==typeof e){if(!N)return console.info("url is required"),null;"boolean"==typeof e&&(r=e),e=location.href}var n=u(e.split("#"),2),t=n[0];return ne(e=(e=n[1]||t).slice(e.lastIndexOf("?")),r)}function le(e,r){if(e){if(r)r=r.slice(r.indexOf("?")).split("#")[0];else{if(!N)return void console.info("url is required");r=location.search}return ne(r)[e]}console.info("key is required")}function se(e,r){if(e&&"boolean"!=typeof e)e=e.slice(e.indexOf("?")).split("#")[0];else{if(!N)return console.info("url is required"),null;"boolean"==typeof e&&(r=e),e=location.search}return ne(e,r)}function fe(e){var r=localStorage.getItem(e);if(!r)return null;try{var n=new Date,t=JSON.parse(r);if("value"in t||"expires"in t)return!t.expires||t.expires>n.getTime()?t.value:(sessionStorage.removeItem(e),null)}catch(e){return r}}function de(e,r,n){"string"==typeof n&&(n=parseInt(n));var t={value:r,expires:n?(new Date).getTime()+1e3*n:void 0};localStorage.setItem(e,JSON.stringify(t))}function pe(e){localStorage.removeItem(e)}function me(e){var r=sessionStorage.getItem(e);if(!r)return null;try{var n=new Date,t=JSON.parse(r);if("value"in t||"expires"in t)return!t.expires||t.expires>n.getTime()?t.value:(sessionStorage.removeItem(e),null)}catch(e){return r}}function ve(e,r,n){"string"==typeof n&&(n=parseInt(n));var t={value:r,expires:n?(new Date).getTime()+1e3*n:void 0};sessionStorage.setItem(e,JSON.stringify(t))}function he(e){sessionStorage.removeItem(e)}function ge(e){var r=new RegExp("(^| )"+e+"=([^;]*)(;|$)"),n=document.cookie.match(r);return n?decodeURIComponent(n[2]):null}function be(){for(var e={},r=decodeURIComponent(document.cookie).split("; "),n=r.length-1;n>=0;n--){var t=r[n].split("=");["null","undefined","NaN"].includes(t[1])&&(t[1]=""),e[t[0]]=t[1]}return e}function ye(e,r,n,t,o){void 0===t&&(t="/"),void 0===o&&(o=!0),"string"==typeof n&&(n=parseInt(n));var i=new Date;n||(n=86400),i.setTime(i.getTime()+1e3*n);var a="".concat(e,"=").concat(encodeURIComponent(r),";expires=").concat(i.toUTCString(),";path=").concat(t);o&&"https:"===location.protocol&&(a+=";SameSite=None;Secure"),document.cookie=a}function we(e){var r=new Date;r.setTime(r.getTime()-1);var n=ge(e);null!==n&&(document.cookie=e+"="+n+";expires="+r.toUTCString()+";path=/")}function Se(e){e=e.replace(/\r\n/g,"\n");for(var r="",n=0;n<e.length;n++){var t=e.charCodeAt(n);t<128?r+=String.fromCharCode(t):t>127&&t<2048?(r+=String.fromCharCode(t>>6|192),r+=String.fromCharCode(63&t|128)):(r+=String.fromCharCode(t>>12|224),r+=String.fromCharCode(t>>6&63|128),r+=String.fromCharCode(63&t|128))}return r}var xe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Ce(e){var r,n,t,o,i,a,u,c="",l=0;for(e=Se(e);l<e.length;)o=(r=e.charCodeAt(l++))>>2,i=(3&r)<<4|(n=e.charCodeAt(l++))>>4,a=(15&n)<<2|(t=e.charCodeAt(l++))>>6,u=63&t,isNaN(n)?a=u=64:isNaN(t)&&(u=64),c=c+xe.charAt(o)+xe.charAt(i)+xe.charAt(a)+xe.charAt(u);return c}function Ae(e){for(var r="",n=0,t=0,o=0,i=0;n<e.length;)(t=e.charCodeAt(n))<128?(r+=String.fromCharCode(t),n++):t>191&&t<224?(o=e.charCodeAt(n+1),r+=String.fromCharCode((31&t)<<6|63&o),n+=2):(o=e.charCodeAt(n+1),i=e.charCodeAt(n+2),r+=String.fromCharCode((15&t)<<12|(63&o)<<6|63&i),n+=3);return r}var Ee="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function je(e){var r,n,t,o,i,a,u="",c=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");c<e.length;)r=Ee.indexOf(e.charAt(c++))<<2|(o=Ee.indexOf(e.charAt(c++)))>>4,n=(15&o)<<4|(i=Ee.indexOf(e.charAt(c++)))>>2,t=(3&i)<<6|(a=Ee.indexOf(e.charAt(c++))),u+=String.fromCharCode(r),64!==i&&(u+=String.fromCharCode(n)),64!==a&&(u+=String.fromCharCode(t));return u=Ae(u)}function Oe(e){return e&&e.stopPropagation?e.stopPropagation():e.cancelBubble=!0,!1}function Te(e){return e&&e.preventDefault?e.preventDefault():window.event.returnValue=!1,!1}function Ne(e,r,n){if(e.addEventListener)e.addEventListener(r,n,!1);else{n.$$guid||(n.$$guid=Ne.guid++),e.events||(e.events={});var t=e.events[r];t||(t=e.events[r]={},e["on"+r]&&(t[0]=e["on"+r])),t[n.$$guid]=n,e["on"+r]=Ie}}function Ie(e){var r=!0,n=this;e=e||Be(((n.ownerDocument||n.document||n).parentWindow||window).event);var t=this.events[e.type];for(var o in t)this.$$handleEvent=t[o],!1===this.$$handleEvent(e)&&(r=!1);return r}function Be(e){return e.preventDefault=Be.preventDefault,e.stopPropagation=Be.stopPropagation,e}function Pe(e,r,n){e.removeEventListener?e.removeEventListener(r,n,!1):e.events&&e.events[r]&&delete e.events[r][n.$$guid]}function $e(){var e=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,r=document.documentElement.scrollTop,n=document.body.scrollTop,t=document.documentElement.scrollHeight,o=document.body.scrollHeight,i=0,a=0;if(0===r){if(i=n,a=o,0===n)return"top"}else i=r,a=t;if(e+Math.floor(i)===a||e+Math.ceil(i)===a)return"bottom"}function ke(e,r){void 0===e&&(e=5e3),void 0===r&&(r=1e4);var n=[e];return Array.prototype.forEach.call(document.querySelectorAll("body > *"),(function(t){var o=["SCRIPT","META","STYLE","LINK"].includes(t.tagName)?0:+window.getComputedStyle(t).zIndex||0;o>e&&o<r&&n.push(o)})),n.sort((function(e,r){return r-e})),n[0]+1}function De(e,r,n){void 0===n&&(n="");var t=function(e){var r,n,t,o,i,a={major:0,minor:0,patch:0,preid:"",release:void 0},c=u(e.split("-"),2),l=c[0],s=c[1],f=void 0===s?"":s;r=u(l.split(".").map((function(e){return+e})),3),n=r[0],a.major=void 0===n?0:n,t=r[1],a.minor=void 0===t?0:t,o=r[2],a.patch=void 0===o?0:o,f.includes(".")?(i=u(f.split(".").map((function(e,r){return r>0?+e:e})),2),a.preid=i[0],a.release=i[1]):f&&(a.release=+f);return a}(e);switch(r){case"major":(t.minor||t.patch||!t.preid)&&t.major++,t.minor=0,t.patch=0,t.preid="",t.release=void 0;break;case"minor":!t.patch&&t.preid||t.minor++,t.patch=0,t.preid="",t.release=void 0;break;case"premajor":t.major++,t.minor=0,t.patch=0,t.preid=n,t.release=0;break;case"preminor":t.minor++,t.patch=0,t.preid=n,t.release=0;break;case"prepatch":t.patch++,t.preid=n,t.release=0;break;case"prerelease":n&&t.preid!==n?(void 0===t.release&&t.patch++,t.preid=n,t.release=0):void 0===t.release?(t.patch++,t.release=0):t.release++;break;default:void 0===t.release&&t.patch++,t.preid="",t.release=void 0}return function(e){var r,n=[e.major,e.minor,e.patch].join("."),t="".concat(e.preid?e.preid+".":"").concat(null!==(r=e.release)&&void 0!==r?r:"");return"".concat(n).concat(t?"-"+t:"")}(t)}function Fe(e,r){for(var n=[],t=2;t<arguments.length;t++)n[t-2]=arguments[t];e();var o={count:1,timer:null,clear:function(){return this.timer&&(clearTimeout(this.timer),this.timer=null),o=null}},i=(new Date).getTime(),a=function(){e();var t=o.count*r,l=(new Date).getTime()-i;o.count++;var s=l-t;o.timer=setTimeout.apply(void 0,c([a,r-s],u(n),!1))};return o.timer=setTimeout.apply(void 0,c([a,r],u(n),!1)),o}function Me(e,r){return l(l({},e),{then:function(e,n){return r().then(e,n)}})}function Re(e,r){void 0===r&&(r=2);var n=new RegExp("^(.*\\..{"+r+"}).*$");if(e=""+e,!d.number.test(e))throw new Error('"number" is not a number');return parseFloat(e.replace(n,"$1"))}function Ue(e,r){if(!e||!r)throw new Error('"tmp" & "data" is required');var n=e.match(/\$\{(\w+)\}/g)?/\$\{(\w+)\}/g:/\{?\{(\w+)\}\}?/g;return""+e.replace(n,(function(e,n){if("function"==typeof r)return""+r(n);for(var t in r)if(n===t)return""+r[t];return e}))}function We(e,r,n){var t;for(t in r)r.hasOwnProperty(t)&&(n&&(L(r[t])||D(r[t]))?(L(r[t])&&!L(e[t])&&(e[t]={}),D(r[t])&&!D(e[t])&&(e[t]=[]),We(e[t],r[t],n)):void 0!==r[t]&&(e[t]=r[t]))}function qe(e){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var t=!1;return"boolean"==typeof e&&(t=e,e=r.shift()),r.forEach((function(r){We(e,r,t)})),e}function Le(e){var r=[],n=[],t=function(e){if(null===e||"object"!==j(e))return e;var o,i,a,u;D(e)?o=[]:H(e)?(o=new RegExp(e.source,(u="",(a=e).global&&(u+="g"),a.ignoreCase&&(u+="i"),a.multiline&&(u+="m"),u)),e.lastIndex&&(o.lastIndex=e.lastIndex)):V(e)?o=new Date(e.getTime()):(i=Object.getPrototypeOf(e),o=Object.create(i));var c=r.indexOf(e);if(-1!==c)return n[c];for(var l in r.push(e),n.push(o),e)o[l]=t(e[l]);return o};return t(e)}function Qe(){return{map:{},register:function(e,r,n,t){var o=this;t?(this.map[e]||r(),this.map[e]={id:e,fn:r,time:n,boo:t,timeout:setTimeout((function(){o.destroy(e)}),n)}):(this.map[e]&&this.destroy(e),this.map[e]={id:e,fn:r,time:n,boo:t,timeout:setTimeout(r,n)})},destroy:function(e){this.map[e]&&(clearTimeout(this.map[e].timeout),delete this.map[e])}}}function Ve(e){if(!e)throw new Error('"url" is required');var r=e.split("."),n=r[r.length-1].toLocaleLowerCase(),t="other";return["png","jpg","jpeg","bmp","gif","webp","tiff","tif"].includes(n)?t="image":["txt"].includes(n)?t="txt":["xls","xlsx"].includes(n)?t="excel":["doc","docx"].includes(n)?t="word":["pdf"].includes(n)?t="pdf":["ppt","pptx"].includes(n)?t="ppt":["rar","zip","7z"].includes(n)?t="zip":["mp4","m2v","mkv","rmvb","wmv","avi","flv","mov","m4v"].includes(n)?t="video":["mp3","wav","wmv"].includes(n)&&(t="audio"),{suffix:n,type:t}}function He(e,r){return function(n,t){return function(){try{"".localeCompare("","i")}catch(e){return"RangeError"===e.name}return!1}()?String(n).localeCompare(String(t),e,r):String(n).localeCompare(String(t))}}function ze(e,r,n){void 0===n&&(n={});var t=/[^\x00-\xFF]+/g.test(String(e)),o=/[^\x00-\xFF]+/g.test(String(r));return t&&!o?1:!t&&o?-1:He(["zh-Hans-CN","en-u-kn-true","de-DE-u-co-phonebk"],l({ignorePunctuation:!0,sensitivity:"variant",numeric:!0,collation:"pinyin",caseFirst:"false"},n))(e,r)}function _e(e,r,n){var t={};if(e){if(!r)return e;if(D(r))r.forEach((function(r){e.hasOwnProperty(r)?t[r]=e[r]:void 0!==n&&(t[r]=n)}));else if("object"===j(r))for(var o in r)"function"==typeof r[o]?t[o]=r[o](e):(r[o]||(r[o]=o),e.hasOwnProperty(r[o])?t[o]=e[r[o]]:void 0!==n&&(t[o]=n));return t}}function Ze(e,r,n,t){void 0===t&&(t=0);var o=[],i=t>0;return n&&"object"===j(n)||(n={childName:"child",keyName:"name"}),"[object Object]"===Object.prototype.toString.call(e)&&(e=[e]),function e(r,a){for(var u,c,f=0;f<r.length;f++){r[f][n.childName]&&r[f][n.childName].length>0&&e(r[f][n.childName],a);var d=!0;if("object"===j(a)){var p=Object.keys(a);try{for(var m=(u=void 0,s(p)),v=m.next();!v.done;v=m.next()){var h=v.value;if(a[h]!==r[f][h]){d=!1;break}}}catch(e){u={error:e}}finally{try{v&&!v.done&&(c=m.return)&&c.call(m)}finally{if(u)throw u.error}}}else d="function"==typeof a?a.call(r[f],r[f]):r[f][n.keyName]===a;if(i){if(!(t>0))break;d&&(delete(g=l({},r[f]))[n.childName],o.push(g),t--)}else{var g;if(d)delete(g=l({},r[f]))[n.childName],o.push(g)}}}(e,r),o}function Je(e){var r=document.createElement("a");r.style.display="none",r.href=e,r.setAttribute("target","_blank"),document.body.appendChild(r),r.click(),document.body.removeChild(r)}function Xe(e){if(N){var r=document.createElement("textarea");r.style.position="absolute",r.style.opacity="0",r.innerText=e,document.body.appendChild(r),r.select();var n=document.execCommand("copy");return document.body.removeChild(r),n}}function Ke(e){return e?1===(e=e.toString()).split(".").length?e.toString().replace(/(\d)(?=(?:\d{3})+$)/g,"$1,"):e.split(".")[0].replace(/(\d)(?=(?:\d{3})+$)/g,"$&,")+"."+e.split(".")[1]:0===e||"0"===e?"0":""}Ne.guid=1,Be.preventDefault=function(){this.returnValue=!1},Be.stopPropagation=function(){this.cancelBubble=!0};var Ye=function(e,r){return e.every(r)},Ge=function(e,r){return e.some(r)},er=function(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(function(e){return(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16)}))},rr=function(e,r,n){return void 0===r&&(r=","),void 0===n&&(n=!1),e.slice(n?e.indexOf("\n")+1:0).split("\n").map((function(e){return e.split(r)}))},nr=function(e,r){return void 0===r&&(r=","),e.map((function(e){return e.map((function(e){return isNaN(e)?'"'.concat(e.replace(/"/g,'""'),'"'):e})).join(r)})).join("\n")};function tr(e,r){void 0===r&&(r=",");var n=e.slice(0,e.indexOf("\n")).split(r);return e.slice(e.indexOf("\n")+1).split("\n").map((function(e){var t=e.split(r);return n.reduce((function(e,r,n){return e[r]=t[n],e}),{})}))}var or=function(e,r,n){return void 0===n&&(n=","),c([r.join(n)],u(e.map((function(e){return r.reduce((function(r,t){return"".concat(r).concat(r.length?n:"",'"').concat(e[t]?e[t]:"",'"')}),"")}))),!1).join("\n")},ir=function(e,r,n){return((e<<16)+(r<<8)+n).toString(16).padStart(6,"0")};function ar(e,r){var n,t;try{for(var o=s(e),i=o.next();!i.done;i=o.next()){if(i.value===r)return!0}}catch(e){n={error:e}}finally{try{i&&!i.done&&(t=o.return)&&t.call(o)}finally{if(n)throw n.error}}return!1}function ur(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return e.reduce((function(e,r){return e.filter((function(e){return ar(r,e)}))}))}function cr(e){var r,n,t=[];try{for(var o=s(e),i=o.next();!i.done;i=o.next()){var a=i.value;!ar(t,a)&&t.push(a)}}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return t}function lr(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return cr(e.reduce((function(e,r){return e.concat(r.filter((function(r){return!ar(e,r)})))})))}function sr(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return e.reduce((function(e,r,n){return 1===n&&(e=cr(e)),e.filter((function(e){return!ar(r,e)}))}))}function fr(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var n=ur.apply(void 0,c([],u(e),!1));return lr.apply(void 0,c([],u(e),!1)).filter((function(e){return!ar(n,e)}))}function dr(e){return e.replace(/\w+/g,(function(e){return("000"+e).substr(-4)})).replace(/(\w*)::(\w*)/,(function(r,n,t){for(var o=8-e.match(/:/g).length,i=":";o--;)i+="0000:";return(n||"0000")+i+(t||"0000")}))}function pr(e,r,n){var t,o;if(!e)throw new Error("target is required");if(!r)return e;r instanceof Function&&(r=r());var i=r.split("."),a=function(r){var n=-1;(r=r.replace(/\[(\d+)\]$/,(function(e,r){return n=parseInt(r),""})))&&(e=null==e?void 0:e[r]),-1!==n&&e&&(e=null==e?void 0:e[n])};try{for(var u=s(i),c=u.next();!c.done;c=u.next()){a(c.value)}}catch(e){t={error:e}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(t)throw t.error}}return void 0===n||e||0==e?e:n}function mr(e,r,n){if(!e)throw new Error("target is required");if(!r)throw new Error("prop is required");r instanceof Function&&(r=r());var t=r.split("."),o=e;return t.forEach((function(e,r){var i,a,u,c=-1;e=e.replace(/\[(\d+)\]$/,(function(e,r){return c=parseInt(r),""})),r!==t.length-1?(e&&(null!==(i=o[e])&&void 0!==i||(o[e]={}),o=o[e]),-1!==c&&o&&(null!==(a=o[c])&&void 0!==a||(o[c]=[]),o=o[c])):-1!==c?(e&&(null!==(u=o[e])&&void 0!==u||(o[e]=[]),o=o[e]),o[c]=n):e&&(o[e]=n)})),e}function vr(e){var r,n,t=!1;if(!e)throw new Error('"images" is required');"string"==typeof e&&(t=!0,e=[].concat(e));var o={};try{for(var i=s(e),a=i.next();!a.done;a=i.next()){var u=a.value;o[u]=new Image,o[u].src=u}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return t?o[e[0]]:o}var hr=function(e,r){return void 0===r&&(r=!1),new Promise((function(n,t){return setTimeout(r?t:n,e)}))};function gr(e,r){var n=String.fromCharCode.apply(String,c([],u(new Uint8Array(e)),!1));return r?"data:".concat(r,";base64,").concat(btoa(n)):btoa(n)}function br(e,r){return void 0===r&&(r="image/png"),new Blob([e],{type:r})}function yr(e){var r=u(e.split(","),2),n=r[0],t=r[1];if(!n)throw new Error("Not a valid base64");if(t||(t=n,n=""),N){for(var o=atob(t),i=o.length,a=new Uint8Array(i);i--;)a[i]=o.charCodeAt(i);return a}return Buffer.from(t,"base64")}function wr(e){var r,n=u(e.split(","),1)[0];if(!n)throw new Error("Not a valid base64");var t=null===(r=n.match(/:(.*?);/))||void 0===r?void 0:r[1],o=yr(e);return new Blob([o],{type:t})}function Sr(e,r){var n,t=u(e.split(","),1)[0];if(!t)throw new Error("Not a valid base64");var o=null===(n=t.match(/:(.*?);/))||void 0===n?void 0:n[1],i=yr(e);return new File([i],r,{type:o})}function xr(e){return new Promise((function(r,n){var t=new FileReader;t.onload=function(){return r(t.result)},t.onerror=n,t.readAsArrayBuffer(e)}))}function Cr(e){return new Promise((function(r,n){var t=new FileReader;t.onload=function(){return r(t.result)},t.onerror=n,t.readAsDataURL(e)}))}function Ar(e){return URL.createObjectURL(e)}function Er(e){return Cr(e)}function jr(e){return new Blob([e],{type:"image/svg+xml"})}function Or(e){return new Promise((function(r,n){if(fetch)fetch(e).then((function(e){r(e.blob())})).catch(n);else{var t=new XMLHttpRequest;t.open("get",e,!0),t.responseType="blob",t.onload=function(){200===t.status&&r(t.response)},t.onerror=n,t.send()}}))}var Tr={version:"5.23.1",download:i,RGBToHex:ir,addEvent:Ne,all:Ye,any:Ge,getCache:fe,setCache:de,delCache:pe,getSession:me,setSession:ve,delSession:he,getCookie:ge,getCookies:be,setCookie:ye,delCookie:we,camel2Dash:y,cleanData:_e,clearAttr:m,clearHtml:v,escape:h,unescape:g,client:f,complement:fr,contains:ar,CSVToArray:rr,arrayToCSV:nr,CSVToJSON:tr,JSONToCSV:or,cutCHSString:P,dash2Camel:w,decodeBase64:je,decodeUtf8:Ae,delay:Qe,encodeBase64:Ce,encodeUtf8:Se,extend:qe,clone:Le,fillIPv6:dr,fixNumber:Re,mapTemplate:Ue,getAppVersion:X,appVersion:K,getCHSLength:B,getDirParam:ae,compareVersion:re,getNumber:b,getOsVersion:Y,osVersion:G,browserVersion:ee,getQueryParam:ue,getQueryParams:ce,getProperty:pr,randomColor:C,randomNumber:x,randomNumbers:E,randomString:O,shuffle:A,fingerprint:I,getScrollPosition:$e,getType:U,getFileType:Ve,sorter:He,sortPinyin:ze,parseUrlParam:ne,spliceUrlParam:te,safeParse:oe,safeStringify:ie,getUrlParam:le,getUrlParams:se,intersect:ur,isDigitals:$,isExitsFunction:k,isExitsVariable:R,isEqual:M,isWindow:q,isObject:W,isDate:V,isRegExp:H,isArray:D,isIterable:z,isPlainObject:L,isDarkMode:Q,inBrowser:N,inNodeJs:_,isNumberBrowser:Z,minus:sr,nextIndex:ke,nextVersion:De,punctualTimer:Fe,promiseFactory:Me,waiting:hr,awaitTo:a,arrayBufferToBase64:gr,arrayBufferToBlob:br,base64ToArrayBuffer:yr,base64ToBlob:wr,base64ToFile:Sr,blobToArrayBuffer:xr,blobToBase64:Cr,blobToUrl:Ar,fileToBase64:Er,svgToBlob:jr,urlToBlob:Or,openUrl:Je,copy:Xe,pattern:d,removeEvent:Pe,searchObject:Ze,setProperty:mr,stopBubble:Oe,stopDefault:Te,toThousands:Ke,trim:p,union:lr,unique:cr,upperFirst:S,uuid:er,windowSize:J,loadSource:e,mountCss:r,mountImg:n,mountJs:t,mountStyle:o,preloader:vr},Nr="5.23.1";export{rr as CSVToArray,tr as CSVToJSON,or as JSONToCSV,ir as RGBToHex,Ne as addEvent,Ye as all,Ge as any,K as appVersion,gr as arrayBufferToBase64,br as arrayBufferToBlob,nr as arrayToCSV,yr as base64ToArrayBuffer,wr as base64ToBlob,Sr as base64ToFile,xr as blobToArrayBuffer,Cr as blobToBase64,Ar as blobToUrl,ee as browserVersion,y as camel2Dash,_e as cleanData,m as clearAttr,v as clearHtml,f as client,Le as clone,re as compareVersion,fr as complement,ar as contains,Xe as copy,P as cutCHSString,w as dash2Camel,je as decodeBase64,Ae as decodeUtf8,Tr as default,pe as delCache,we as delCookie,he as delSession,Qe as delay,Ce as encodeBase64,Se as encodeUtf8,h as escape,qe as extend,Er as fileToBase64,dr as fillIPv6,I as fingerprint,Re as fixNumber,X as getAppVersion,B as getCHSLength,fe as getCache,ge as getCookie,be as getCookies,ae as getDirParam,Ve as getFileType,b as getNumber,Y as getOsVersion,pr as getProperty,ue as getQueryParam,ce as getQueryParams,$e as getScrollPosition,me as getSession,U as getType,le as getUrlParam,se as getUrlParams,N as inBrowser,_ as inNodeJs,ur as intersect,D as isArray,Q as isDarkMode,V as isDate,$ as isDigitals,M as isEqual,k as isExitsFunction,R as isExitsVariable,z as isIterable,Z as isNumberBrowser,W as isObject,L as isPlainObject,H as isRegExp,q as isWindow,Ue as mapTemplate,sr as minus,ke as nextIndex,De as nextVersion,Je as openUrl,G as osVersion,ne as parseUrlParam,d as pattern,vr as preloader,Me as promiseFactory,Fe as punctualTimer,C as randomColor,x as randomNumber,E as randomNumbers,O as randomString,Pe as removeEvent,oe as safeParse,ie as safeStringify,Ze as searchObject,de as setCache,ye as setCookie,mr as setProperty,ve as setSession,A as shuffle,ze as sortPinyin,He as sorter,te as spliceUrlParam,Oe as stopBubble,Te as stopDefault,jr as svgToBlob,Ke as toThousands,p as trim,g as unescape,lr as union,cr as unique,S as upperFirst,Or as urlToBlob,er as uuid,Nr as version,hr as waiting,J as windowSize};