funtool
Version:
A modern, efficient, and modular JavaScript utility library designed to enhance developer productivity.
3 lines (2 loc) • 28.5 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).funtool={})}(this,(function(e){"use strict";function t(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===Object.prototype.toString.call(e)}function n(e){return"[object ArrayBuffer]"===Object.prototype.toString.call(e)}function r(e){return"[object Boolean]"===Object.prototype.toString.call(e)}function i(e){return e instanceof DataView&&"[object DataView]"===Object.prototype.toString.call(e)}function o(e){return"[object Date]"===Object.prototype.toString.call(e)}function s(e){return"[object Number]"===Object.prototype.toString.call(e)}function a(e){return"[object BigInt]"===Object.prototype.toString.call(e)}function u(e){return"function"==typeof Number.isNaN?Number.isNaN(e)&&"number"==typeof e:"number"==typeof e&&u(e)}function l(e){return"function"==typeof e||"object"==typeof e&&null!==e}function c(e){return null!=e&&"object"==typeof e}function f(e){if(!l(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype||null===Object.getPrototypeOf(t)}function p(e){return"[object String]"===Object.prototype.toString.call(e)}function h(e){return"[object Map]"===Object.prototype.toString.call(e)&&e instanceof Map}function d(e){return"[object WeakMap]"===Object.prototype.toString.call(e)&&e instanceof WeakMap}function m(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function g(e){return"[object Set]"===Object.prototype.toString.call(e)&&e instanceof Set}function y(e){return"[object WeakSet]"===Object.prototype.toString.call(e)&&e instanceof WeakSet}function b(e){return"symbol"==typeof e}function v(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function w(e,l,c=!0,p=new WeakMap){const d=r(c)?{ordered:c}:c||{ordered:!0};if(e===l)return!0;if(null==e||null==l||typeof e!=typeof l)return!1;if(s(e)&&s(l)&&u(e)&&u(l))return!0;if(b(e)&&b(l))return e.description===l.description;if(a(e)&&a(l))return e===l;if(r(e)&&r(l))return e===l;if(o(e)&&o(l))return e.getTime()===l.getTime();if(m(e)&&m(l))return e.source===l.source&&e.flags===l.flags;if(t(e)&&t(l))return function(e,t,n,r){if(e.length!==t.length)return!1;if(n.ordered){for(let i=0;i<e.length;i++)if(!w(e[i],t[i],n,r))return!1;return!0}{const i=new Array(t.length).fill(!1);for(const o of e){let e=!1;for(let s=0;s<t.length;s++)if(!i[s]&&w(o,t[s],n,r)){i[s]=!0,e=!0;break}if(!e)return!1}return!0}}(e,l,d,p);if(n(e)&&n(l)){if(e.byteLength!==l.byteLength)return!1;const t=new Uint8Array(e),n=new Uint8Array(l);for(const[e,r]of t.entries())if(r!==n[e])return!1;return!0}if(v(e)&&v(l)){if(e.constructor!==l.constructor||e.byteLength!==l.byteLength)return!1;const t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n=new Uint8Array(l.buffer,l.byteOffset,l.byteLength);for(const[e,r]of t.entries())if(r!==n[e])return!1;return!0}if(i(e)&&i(l)){if(e.constructor!==l.constructor||e.byteLength!==l.byteLength)return!1;for(let t=0;t<e.byteLength;t++)if(e.getUint8(t)!==l.getUint8(t))return!1;return!0}return g(e)&&g(l)?function(e,t,n,r){if(e.size!==t.size)return!1;const i=e.values(),o=t.values();for(;;){const e=i.next(),t=o.next();if(e.done&&t.done)break;if(e.done||t.done)return!1;if(!w(e.value,t.value,n,r))return!1}return!0}(e,l,{ordered:!0},p):h(e)&&h(l)?function(e,t,n,r){if(e.size!==t.size)return!1;const i=e.entries(),o=t.entries();for(;;){const e=i.next(),t=o.next();if(e.done&&t.done)break;if(e.done||t.done)return!1;const[s,a]=e.value,[u,l]=t.value;if(!w(s,u,n,r)||!w(a,l,n,r))return!1}return!0}(e,l,{ordered:!0},p):!(!f(e)||!f(l))&&function(e,t,n,r){const i=Object.keys(e),o=Object.keys(t);if(i.length!==o.length)return!1;for(const o of i){if(!Object.prototype.hasOwnProperty.call(t,o))return!1;if(!w(e[o],t[o],n,r))return!1}return!0}(e,l,{ordered:!1},p)}function x(e){return"function"==typeof e}function O(e){return"[object Null]"===Object.prototype.toString.call(e)}function j(e){return"object"!=typeof e&&"function"!=typeof e||null==e}function A(e,n){if(j(e))return e;if(t(e))return e.map(((e,t)=>{if(x(n)){return n(e,t)}return e}));if(o(e))return new Date(e.getTime());if(m(e))return new RegExp(e.source,e.flags);if(h(e))return new Map(e);if(g(e))return new Set(e);if(v(e))return e.slice();if(i(e))return new DataView(e.buffer.slice(0));if(l(e)){const t=Object.getPrototypeOf(e),r=Object.create(t);for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)){const i=e[t],o=n?.(i,t);r[t]=void 0!==o?o:i}return r}return e}function S(e,t){return!j(e)&&Object.prototype.hasOwnProperty.call(e,t)}function _(e,t){if(j(e))return[];return("undefined"!=typeof Reflect&&"function"==typeof Reflect.ownKeys?Reflect.ownKeys(e):[...Object.getOwnPropertyNames?Object.getOwnPropertyNames(e):[],...Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e):[]]).filter((n=>{const r=Object.getOwnPropertyDescriptor(e,n);return!!r&&(x(t)?t(n,r):r.enumerable)}))}const $={Date:e=>new Date(e.getTime()),RegExp:e=>new RegExp(e.source,e.flags),Array:(e,t,n)=>{const r=[];return t.set(e,r),e.forEach(((e,i)=>{r[i]=n(e,t)})),r},Map:(e,t,n)=>{const r=new Map;return t.set(e,r),e.forEach(((e,i)=>{r.set(i,n(e,t))})),r},Set:(e,t,n)=>{const r=new Set;return t.set(e,r),e.forEach((e=>{r.add(n(e,t))})),r}};function E(e,t,n,r){if(O(e)||!c(e))return e;if(x(e)||b(e)||a(e)||d(e)||y(e)){const t="object"==typeof e&&null!==e&&"constructor"in e&&e.constructor?.name||typeof e;return console.warn(`⚠️ Warning: Unsupported type "${t}" encountered, returning original.`),e}if(t.has(e))return t.get(e);const i=Object.prototype.toString.call(e).slice(8,-1);if(i in $)return $[i](e,t,n);const o={};return t.set(e,o),_(e).forEach((i=>{if(S(e,i)){const s=e[i],a=r?.(s,i,e);o[i]=void 0!==a?a:n(s,t)}})),o}class C{constructor(e,t){if(e){if(!C.isValid(e))throw new Error("Invalid ObjectId hex string.");this.hex=e.toLowerCase()}else this.hex=function(e=Math.random){return(Math.floor(Date.now()/1e3).toString(16).padStart(8,"0")+Array.from({length:16},(()=>Math.floor(16*e()).toString(16))).join("")).slice(0,24)}(t)}static isValid(e){return"string"==typeof e&&/^[a-fA-F0-9]{24}$/.test(e)}static createFromHexString(e){return new C(e)}static createWithPrefix(e){return e+(new C).toHexString()}toHex(){return this.hex}toBuffer(){const e=new Uint8Array(12);for(let t=0;t<12;t++)e[t]=parseInt(this.hex.slice(2*t,2*t+2),16);return e}equals(e){return this.hex===e.hex}static parse(e,t=!1){if(t){if(!C.isValid(e))throw new Error(`Invalid strict ObjectId: ${e}`);return new C(e)}const n=e.match(/[a-fA-F0-9]{24}/);if(!n)throw new Error(`Invalid format for ObjectId: ${e}`);return new C(n[0])}toHexString(){return this.hex}toUUIDString(){const e=this.hex.padEnd(32,"0");return[e.slice(0,8),e.slice(8,12),e.slice(12,16),e.slice(16,20),e.slice(20)].join("-")}toString(){return this.toHexString()}toBase64(){return Buffer.from(this.toBuffer()).toString("base64")}short(e=""){return e+this.toBase64().replace(/=+$/,"")}getTimestamp(){return 1e3*parseInt(this.hex.slice(0,8),16)}compare(e){return this.hex.localeCompare(e.hex)}clone(){return new C(this.hex)}toJSON(){return this.toHexString()}}function N(e){const[t,n]=e.split(",");if(!t||!n)throw new Error("Invalid base64 format");const r=t.match(/:(.*?);/),i=r?.[1]||"application/octet-stream",o=i.split("/")[1]||"bin",s=atob(n),a=Uint8Array.from(s,(e=>e.charCodeAt(0)));return{blob:new Blob([a],{type:i}),mime:i,ext:o}}const T=[{name:"Edge (Chromium)",regex:/Edg\/([\d.]+)/},{name:"Edge (Legacy)",regex:/Edge\/([\d.]+)/},{name:"Opera",regex:/OPR\/([\d.]+)/},{name:"Vivaldi",regex:/Vivaldi\/([\d.]+)/},{name:"Chrome",regex:/Chrome\/([\d.]+)/},{name:"Firefox",regex:/Firefox\/([\d.]+)/},{name:"Safari",regex:/Version\/([\d.]+).*Safari/},{name:"Internet Explorer",regex:/MSIE ([\d.]+);/},{name:"Internet Explorer",regex:/Trident\/7.0.*rv:([\d.]+)/},{name:"Samsung Internet",regex:/SamsungBrowser\/([\d.]+)/}],P=[{name:"Windows",regex:/Windows NT ([\d.]+)/},{name:"macOS",regex:/Mac OS X ([\d_]+)/,versionReplace:/_/g},{name:"iOS",regex:/\(iP(?:hone|ad|od); CPU (?:iPhone )?OS ([\d_]+)/,versionReplace:/_/g},{name:"Android",regex:/Android ([\d.]+)/},{name:"Linux",regex:/Linux/},{name:"Chrome OS",regex:/CrOS [\w\d_]+ ([\d.]+)/},{name:"Windows Phone",regex:/Windows Phone ([\d.]+)/}],I=[{type:"Mobile",regex:/Mobile|iPhone|Android/},{type:"Tablet",regex:/Tablet|iPad/},{type:"SmartTV",regex:/SmartTV|SMART-TV|Smart-TV|NetCast.TV|AppleTV|Roku/},{type:"Console",regex:/Xbox|PlayStation/},{type:"Wearable",regex:/Watch|Wearable/}],R=[{name:"Blink",regex:/Chrome\/([\d.]+)/},{name:"WebKit",regex:/AppleWebKit\/([\d.]+)/},{name:"Gecko",regex:/Gecko\/([\d.]+)/},{name:"Trident",regex:/Trident\/([\d.]+)/},{name:"EdgeHTML",regex:/EdgeHTML\/([\d.]+)/}];function M(e){const t=e||("undefined"!=typeof navigator?navigator.userAgent:""),n={browser:{name:null,version:null,majorVersion:null},os:{name:null,version:null,majorVersion:null},device:{type:"Unknown",model:null,vendor:null},engine:{name:null,version:null},originalUA:t};for(const{name:e,regex:r}of T){const i=t.match(r);if(i){const t=i[1];n.browser={name:e,version:t,majorVersion:t?.split(".")[0]??null};break}}for(const{name:e,regex:r,versionReplace:i}of P){const o=t.match(r);if(o){let t=o[1]||null;t&&i&&(t=t.replace(i,".")),n.os={name:e,version:t,majorVersion:t?.split(".")[0]??null};break}}for(const{name:e,regex:r}of R){const i=t.match(r);if(i){n.engine={name:e,version:i[1]||null};break}}for(const{type:e,regex:r}of I)if(r.test(t)){n.device.type=e,/iPhone/.test(t)?n.device.model="iPhone":/iPad/.test(t)?n.device.model="iPad":/Android/.test(t)&&(n.device.model="Android Device");break}return"Unknown"===n.device.type&&(n.device.type="Desktop"),n}const U=globalThis.Math;class D{constructor(e=0,t=2,n="half-up"){this._precision=t,this._rounding=n,this._value=e}set(e){return this._value=this._round(e),this}value(){return this._round(this._value)}setPrecision(e){return this._precision=e,this}setRounding(e){return this._rounding=e,this}clone(e){return new D(e??this._value,this._precision,this._rounding)}_round(e){if(!isFinite(e))return e;if(U.abs(e)>=1e15){const t=e.toExponential(),[n,r]=t.split("e"),i=Number(Number(n).toFixed(this._precision));return Number(`${i}e${r}`)}const t=10**this._precision;switch(this._rounding){case"up":return U.ceil(e*t)/t;case"down":return U.floor(e*t)/t;default:return U.round(e*t)/t}}add(e){return this._value=this._value+e,this}subtract(e){return this._value=this._value-e,this}multiply(e){return this._value=this._value*e,this}divide(e){if(0===e)throw new Error("Division by zero is not allowed.");return this._value=this._value/e,this}abs(){return this._value=U.abs(this._value),this}sqrt(){if(this._value<0)throw new Error("Square root of negative numbers is not supported.");return this._value=U.sqrt(this._value),this}cbrt(){return this._value=U.cbrt(this._value),this}pow(e){return 1!==this._value||isFinite(e)?this._value=U.pow(this._value,e):this._value=1,this}floor(){return this._value=U.floor(this._value),this}ceil(){return this._value=U.ceil(this._value),this}round(){return this._value=U.round(this._value),this}sign(){return this._value=U.sign(this._value),this}degToRad(){return this._value=this._value*U.PI/180,this}radToDeg(){return this._value=180*this._value/U.PI,this}max(...e){return this._value=U.max(this._value,...e),this}min(...e){return this._value=U.min(this._value,...e),this}sin(){return this._value=U.sin(this._value),this}cos(){return this._value=U.cos(this._value),this}tan(){return this._value=U.tan(this._value),this}asin(){return this._value=U.asin(this._value),this}acos(){return this._value=U.acos(this._value),this}atan(){return this._value=U.atan(this._value),this}log(){return this._value=U.log(this._value),this}log10(){return this._value=U.log10(this._value),this}exp(){return this._value=U.exp(this._value),this}toExponential(e){return void 0===e?this._value.toExponential():this._value.toExponential(e)}}class k{constructor(){this.plugins=new Map,this.internalRuleNames=new Set,this.listeners=[],this.plugins=new Map,this.internalRuleNames=new Set,this.listeners=[]}static getInstance(){return k.instance||(k.instance=new k),k.instance}subscribe(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter((t=>t!==e))}}notify(){for(const e of this.listeners)e(this.getAll())}register(e,t=!1){(Array.isArray(e)?e:[e]).forEach((e=>{if(this.plugins.has(e.name))throw new Error(`Rule '${e.name}' is already registered.`);if(t)this.internalRuleNames.add(e.name),Object.defineProperty(e,"_internal",{value:!0,writable:!1,enumerable:!1,configurable:!1});else if(this.internalRuleNames.has(e.name))throw new Error(`Rule name '${e.name}' is reserved and cannot be overridden.`);this.plugins.set(e.name,e)})),this.notify()}get(e){if(this.plugins.has(e))return this.plugins.get(e)}getAll(){return Object.fromEntries(this.plugins)}isInternal(e){return this.internalRuleNames.has(e)}reset(){this.plugins.clear(),this.internalRuleNames.clear(),this.listeners=[],this.notify()}}k.instance=null;const F=k.getInstance();class B{constructor(e){this.input="",this.result=!0,this.isNegated=!1,this.input=e}use(e){let t=!1;if(e instanceof RegExp)t=e.test(this.input);else{const n=F.get(e);if(!n)throw new Error(`Unknown rule: '${e}'`);t=n.validate({input:this.input,name:n.name,pattern:n.pattern})}return this.result=this.isNegated?!t:t,this.isNegated=!1,this}not(){return this.isNegated=!0,this}isValid(){return this.result}}class L{constructor(e){this.input=e}use(e){if(e instanceof RegExp)this.pattern=e;else{const t=F.get(e);if(!t)throw new Error(`Unknown rule: '${e}'`);this.pattern=t.pattern}return this}with(e){if(!this.pattern)throw new Error("No pattern defined. Call .use() first.");return this.input=this.input.replace(this.pattern,e),this}result(){return this.input}}function W(e){return F.register(e,!0),e}const V={email:W({name:"email",pattern:/\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/i,validate:e=>e.pattern.test(e.input)}),mobile:W({name:"mobile",pattern:/^1[3|4|5|6|7|8|9][0-9]{9}$/,validate:e=>e.pattern.test(e.input)}),alpha:W({name:"alpha",pattern:/^[a-zA-Z]+$/,validate:e=>e.pattern.test(e.input)}),chinese:W({name:"chinese",pattern:/^\p{Script=Han}+$/u,validate:e=>e.pattern.test(e.input)}),ipv6:W({name:"ipv6",pattern:/^(?:[a-fA-F0-9]{1,4}:){7}[a-fA-F0-9]{1,4}$|^(?:[a-fA-F0-9]{1,4}:){1,7}:$|^(?:[a-fA-F0-9]{1,4}:){1,6}:[a-fA-F0-9]{1,4}$|^(?:[a-fA-F0-9]{1,4}:){1,5}(?::[a-fA-F0-9]{1,4}){1,2}$|^(?:[a-fA-F0-9]{1,4}:){1,4}(?::[a-fA-F0-9]{1,4}){1,3}$|^(?:[a-fA-F0-9]{1,4}:){1,3}(?::[a-fA-F0-9]{1,4}){1,4}$|^(?:[a-fA-F0-9]{1,4}:){1,2}(?::[a-fA-F0-9]{1,4}){1,5}$|^[a-fA-F0-9]{1,4}:(?:(?::[a-fA-F0-9]{1,4}){1,6})$|^:(?:(?::[a-fA-F0-9]{1,4}){1,7}|:)$/,validate:e=>e.pattern.test(e.input)}),postal:W({name:"postal",pattern:/\d{6}/,validate:e=>e.pattern.test(e.input)}),username:W({name:"username",pattern:/^[a-zA-Z][a-zA-Z0-9_]{4,15}$/,validate:e=>e.pattern.test(e.input)}),ipv4:W({name:"ipv4",pattern:/^(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)){3}$/,validate:e=>e.pattern.test(e.input)}),IDCard:W({name:"IDCard",pattern:/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,validate:e=>e.pattern.test(e.input)}),url:W({name:"url",pattern:/^((https|http|ftp|rtsp|mms)?:\/\/)[^\s]+/,validate:e=>e.pattern.test(e.input)}),qq:W({name:"qq",pattern:/^[1-9][0-9]{4,9}$/,validate:e=>e.pattern.test(e.input)}),landline:W({name:"landline",pattern:/^0\d{2,3}-?\d{7,8}$/,validate:e=>e.pattern.test(e.input)}),number:W({name:"number",pattern:/^[0-9]$/,validate:e=>e.pattern.test(e.input)}),nonAscii:W({name:"nonAscii",pattern:/[^\x00-\xff]/,validate:e=>e.pattern.test(e.input)}),nonLatin:W({name:"nonLatin",pattern:/[^\u0000-\u024F]/,validate:e=>e.pattern.test(e.input)}),password:W({name:"password",pattern:/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,validate:e=>e.pattern.test(e.input)}),html:W({name:"html",pattern:/<("[^"]*"|'[^']*'|[^'">])*>/,validate:e=>e.pattern.test(e.input)})};class z{constructor(){for(const e in V)this[e]=V[e]}static getInstance(){return z.instance||(z.instance=new z),z.instance}checker(e){return new B(e)}replacer(e){return new L(e)}definePlugin(e){if(F.isInternal(e.name))throw new Error(`Cannot register plugin with reserved name: '${e.name}'`);return F.register(e),e}}z.instance=null;const q=z.getInstance();function Z(e){return e.replace(/[_\-\s]+/g," ").trim().split(/\s+/).flatMap((e=>e.match(/[A-Z]{2,}(?=[A-Z][a-z]|[0-9]|$)|[A-Z]?[a-z]+|[A-Z]+|[0-9]+/g)||[]))}e.MathX=D,e.ObjectId=C,e.VERSION="1.2.1",e.at=function(e,t){const n=e.length;if(0!==n)return t<0&&(t=n+t),e[t]},e.awaitTo=function(e){var t;return(null!==(t=e)&&"object"==typeof t&&"function"==typeof t.then?e:Promise.resolve(e)).then((e=>[null,e])).catch((e=>[e,void 0]))},e.base64ToBlob=N,e.base64ToFormData=function(e,t){const{blob:n,ext:r}=N(e),i=t?.key||"file";let o=t?.filename;o?o.includes(".")||(o+=`.${r}`):o=`${Date.now()}.${r}`;const s=new FormData;return s.append(i,n,o),s},e.capitalizeFirstLetter=function(e){return e?e.charAt(0).toUpperCase()+e.slice(1):""},e.clone=function(e){return A(e)},e.cloneDeep=function e(t,n=new WeakMap){return E(t,n,e)},e.cloneDeepWith=function(e,t,n=new WeakMap){const r=(e,i=n)=>{const o=t(e);return void 0!==o?o:E(e,i,r,t)};return r(e)},e.cloneWith=function(e,t){return A(e,t)},e.count=function(e,t){return(e.match(new RegExp(t,"g"))||[]).length},e.currying=function(e){const{fn:t,done:n}=e;return function e(r=[]){const i=(...i)=>{const o=[...r,...i];return n&&n(o)?t(...o):e(o)};return i.map=t=>e(r.map(t)),i.filter=t=>e(r.filter(t)),i.value=()=>t(...r),i.valueOf=()=>i.value(),i.toString=()=>String(i.value()),i}()},e.debounce=function(e,t=500){let n=null,r=null,i=null,o=null,s=null;const a=()=>{if(r)try{const t=e.apply(i,r);return o?.(t),u(),t}catch(e){throw s?.(e),u(),e}},u=()=>{n=null,r=null,i=null,o=null,s=null};function l(...e){return n&&clearTimeout(n),r=e,i=this,new Promise(((e,r)=>{o=e,s=r,n=setTimeout((()=>{a()}),t)}))}return l.cancel=function(){n&&clearTimeout(n),s?.("Debounced call canceled"),u()},l.flush=function(){return n&&clearTimeout(n),Promise.resolve(a())},l.pending=function(){return!!n},l},e.debounceSync=function(e,t=500){let n=null,r=null,i=null;const o=()=>{n=null,r=null,i=null},s=()=>{if(r)try{const t=e.apply(i,r);return o(),t}catch(e){throw o(),e}};function a(...e){n&&clearTimeout(n),r=e,i=this,n=setTimeout((()=>{s()}),t)}return a.cancel=()=>{n&&clearTimeout(n),o()},a.flush=()=>(n&&clearTimeout(n),s()),a.pending=()=>!!n,a},e.findIndex=function(e,t){return e.indexOf(t)},e.generateVerificationCode=function(e=4,t){if(e<=0)return"";const n=/[0Ool1]/g;let r=t?.charset||"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";if(!1!==t?.excludeConfusing&&(r=r.replace(n,"")),!r)throw new Error("Character set is empty after removing confusing characters.");return Array.from({length:e},(()=>{const e=Math.floor(Math.random()*r.length);return r.charAt(e)})).join("")},e.getBrowserType=function(){const e=M();if(!e.browser.name||!e.browser.version)return null;const t=e.browser.name.toLowerCase(),n=parseInt(e.browser.majorVersion||"0");switch(t){case"internet explorer":return n>=7&&n<=10?`IE${n}`:11===n?"IE11":null;case"edge (chromium)":case"edge (legacy)":return"Edge";case"firefox":return"FireFox";case"opera":return"Opera";case"chrome":return"Chrome";case"safari":return"Safari";default:return null}},e.getUA=function(e){return void 0!==e?e:"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""},e.hasOwn=S,e.includes=function(e,n,r=0){return t(e)?e.slice(r).includes(n):p(e)?-1!==e.indexOf(String(n),r):h(e)||g(e)?e.has(n):!!f(e)&&Object.values(e).includes(n)},e.insertAfter=function(e,t,n){const r="number"==typeof n?n:e.indexOf(n);return r<0||r>=e.length?e:e.slice(0,r+1)+t+e.slice(r+1)},e.insertBefore=function(e,t,n){const r="number"==typeof n?n:e.indexOf(n);return r<0||r>e.length?e:e.slice(0,r)+t+e.slice(r)},e.intersect=function(e,t){return e.filter((e=>t.includes(e)))},e.isArray=t,e.isArrayBuffer=n,e.isBigInt=a,e.isBlob=function(e){return"undefined"!=typeof Blob&&e instanceof Blob},e.isBoolean=r,e.isBuffer=function(e){return"undefined"!=typeof Buffer&&"function"==typeof Buffer.isBuffer&&Buffer.isBuffer(e)},e.isCommentNode=function(e){return"undefined"!=typeof Node&&e instanceof Node&&e.nodeType===Node.COMMENT_NODE},e.isDataView=i,e.isDate=o,e.isDocument=function(e){return"undefined"!=typeof Document&&e instanceof Document},e.isDocumentFragment=function(e){return"undefined"!=typeof Node&&e instanceof Node&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE},e.isElement=function(e){return"object"==typeof e&&null!==e&&"number"==typeof e.nodeType&&1===e.nodeType&&"string"==typeof e.nodeName&&"undefined"!=typeof Element&&e instanceof Element},e.isEmpty=function(e){return null==e||(p(e)?0===e.trim().length:s(e)?0===e||u(e):t(e)?0===e.length:f(e)?0===Object.keys(e).length:!!o(e)&&u(e.getTime()))},e.isEqual=w,e.isFloat=function(e){return s(e)&&e%1!=0},e.isFunction=x,e.isInt=function(e){return s(e)&&e%1==0},e.isMap=h,e.isNaN=u,e.isNil=function(e){return null==e},e.isNode=function(e){return"undefined"!=typeof Node&&e instanceof Node},e.isNodeJS=function(){return"undefined"!=typeof process&&!!process.versions?.node},e.isNull=O,e.isNumber=s,e.isObject=l,e.isObjectLike=c,e.isPlainObject=f,e.isPrimitive=j,e.isPromise=function(e){return e&&"function"==typeof e.then},e.isRegExp=m,e.isSet=g,e.isString=p,e.isSymbol=b,e.isTextNode=function(e){return"undefined"!=typeof Node&&e instanceof Node&&e.nodeType===Node.TEXT_NODE},e.isTypedArray=v,e.isUndefined=function(e){return"[object Undefined]"===Object.prototype.toString.call(e)},e.isWeakMap=d,e.isWeakSet=y,e.isWindow=function(e){return"undefined"!=typeof window&&e===window},e.keys=_,e.lowercaseFirstLetter=function(e){return e?e.charAt(0).toLowerCase()+e.slice(1):""},e.merge=function(e,t){const n={...e};return _(t).forEach((e=>{const r=Object.getOwnPropertyDescriptor(t,e);r&&Object.defineProperty(n,e,r)})),n},e.mergeDeep=function e(n,r){if(t(n)&&t(r)){const t=Math.max(n.length,r.length),i=[];for(let o=0;o<t;o++){const t=n[o],s=r[o];j(t)||j(s)?i[o]=void 0!==s?s:t:i[o]=e(t,s)}return i}if(f(n)&&f(r)){const t={...n};return _(r).forEach((i=>{const o=n[i],s=r[i];j(o)||j(s)?t[i]=s:t[i]=e(o,s)})),t}return r},e.noop=function(){},e.omit=function(e,t){const n={};return _(e).forEach((r=>{t.includes(r)||(n[r]=e[r])})),n},e.omitBy=function(e,t){const n={};return _(e).forEach((r=>{t(e[r],r)||(n[r]=e[r])})),n},e.padEnd=function(e,t,n=" "){return e.padEnd(t,n)},e.padStart=function(e,t,n=" "){return e.padStart(t,n)},e.parseQuery=e=>"object"!=typeof e||null==e?"":Object.keys(e).map((t=>{const n=e[t];return null==n?"":`${encodeURIComponent(t)}=${encodeURIComponent(n)}`})).filter(Boolean).join("&"),e.parseQueryDeep=e=>{const t=(e,n)=>null==e?[]:"object"!=typeof e||Array.isArray(e)?Array.isArray(e)?e.flatMap((e=>t(e,`${n}[]`))):[`${n}=${encodeURIComponent(String(e))}`]:Object.keys(e).flatMap((r=>t(e[r],`${n}[${encodeURIComponent(r)}]`)));return"object"!=typeof e||null==e?"":Object.keys(e).flatMap((n=>t(e[n],encodeURIComponent(n)))).join("&")},e.parseQueryDeepWith=(e,t)=>{const n=(e,r)=>{if(null==e)return[];if("object"==typeof e&&!Array.isArray(e))return Object.keys(e).flatMap((t=>n(e[t],[...r,t])));if(Array.isArray(e))return e.flatMap(((e,t)=>n(e,[...r,String(t)])));return[`${t(r.map(encodeURIComponent))}=${encodeURIComponent(String(e))}`]};return"object"!=typeof e||null==e?"":Object.keys(e).flatMap((t=>n(e[t],[t]))).join("&")},e.parseQueryWith=(e,t)=>"object"!=typeof e||null==e?"":Object.entries(e).map((([e,n])=>t(e,n))).filter((e=>"string"==typeof e)).join("&"),e.parseUA=M,e.pick=function(e,t){const n={};for(const r of t)r in e&&(n[r]=e[r]);return n},e.pickBy=function(e,t){const n={};for(const r in e)t(e[r],r)&&(n[r]=e[r]);return n},e.randomFloat=function(e=0,t=1){return Math.random()*(t-e)+e},e.randomInt=function(e=0,t=1){return Math.floor(Math.random()*(t-e))+e},e.regex=q,e.remove=function(e,t){return e.filter((e=>!t.includes(e)))},e.removeAfter=function(e,t){const n="number"==typeof t?t:e.indexOf(t);return n>=0?e.slice(0,n+1):e},e.removeAt=function(e,t){const n="number"==typeof t?t:e.indexOf(t);return n<0||n>=e.length?e:e.slice(0,n)+e.slice(n+1)},e.removeBefore=function(e,t){const n="number"==typeof t?t:e.indexOf(t);return n>=0?e.slice(n):e},e.repeat=function(e,t){return e.repeat(t)},e.replaceAll=function(e,t,n){return e.split(t).join(n)},e.reverse=function(e){return e.split("").reverse().join("")},e.substring=function(e,t,n){return e.substring(t,n)},e.throttle=function(e,t=500){let n=null,r=null,i=null,o=null,s=null;const a=()=>{n=Date.now();const t=e.apply(o,i);return s?.(t),u(),t},u=()=>{r=null,i=null,o=null,s=null};function l(...e){const u=Date.now(),l=n?t-(u-n):0;return i=e,o=this,new Promise((e=>{s=e,l<=0?a():r||(r=setTimeout(a,l))}))}return l.cancel=()=>{r&&clearTimeout(r),u()},l.flush=()=>r?(clearTimeout(r),Promise.resolve(a())):Promise.resolve(void 0),l.pending=()=>Boolean(r),l},e.throttleSync=function(e,t=500){let n=null,r=null,i=null,o=null;const s=()=>{n=Date.now(),e.apply(o,i),a()},a=()=>{r=null,i=null,o=null};function u(...e){const a=Date.now(),u=n?t-(a-n):0;i=e,o=this,u<=0?s():r||(r=setTimeout(s,u))}return u.cancel=()=>{r&&clearTimeout(r),a()},u.flush=()=>{r&&(clearTimeout(r),s())},u.pending=()=>Boolean(r),u},e.toCamelCase=function(e){if(!e)return"";const[t,...n]=Z(e);return[t.toLowerCase(),...n.map((e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))].join("")},e.toKebabCase=function(e){return Z(e).map((e=>e.toLowerCase())).join("-")},e.toLowerAt=function(e,t){const n="number"==typeof t?t:e.indexOf(t);return n<0||n>=e.length?e:e.slice(0,n)+e[n].toLowerCase()+e.slice(n+1)},e.toLowerCase=function(e){return e.toString().toLowerCase()},e.toPascalCase=function(e){return Z(e).map((e=>/^[A-Z0-9]+$/.test(e)?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())).join("")},e.toSnakeCase=function(e){return Z(e).map((e=>e.toLowerCase())).join("_")},e.toTitleCase=function(e){return e.toLowerCase().replace(/[_\-]+/g," ").replace(/\b([a-z])([a-z]*)/g,((e,t,n)=>t.toUpperCase()+n))},e.toUpperAt=function(e,t){const n="number"==typeof t?t:e.indexOf(t);return n<0||n>=e.length?e:e.slice(0,n)+e[n].toUpperCase()+e.slice(n+1)},e.toUpperCase=function(e){return e.toString().toUpperCase()},e.trim=function(e){return e.toString().replace(/^\s+|\s+$/g,"")},e.trimEnd=function(e){return e.toString().replace(/\s+$/g,"")},e.trimStart=function(e){return e.toString().replace(/^\s+/g,"")},e.typeOf=function(e){return null===e?"null":Array.isArray(e)?"array":typeof e},e.union=function(e,t){return[...new Set([...e,...t])]},e.unique=function(e){return[...new Set(e)]},e.urlParse=function(e){const[t,n]=e.split("#"),[r,i]=t.split("?");let o="",s="",a="/";const u=r.match(/^([a-zA-Z]+:)?\/\//);if(u){o=u[1]||"";const e=r.slice(o.length+2),t=e.indexOf("/");t>=0?(s=e.slice(0,t),a=e.slice(t)||"/"):(s=e,a="/")}else a=r||"/";let l=s,c="";const f=s.indexOf(":");f>=0&&(l=s.slice(0,f),c=s.slice(f+1));const p=o+"//"+s,h={};if(i){const e=i.split("&");for(const t of e){if(!t)continue;const[e,n]=t.split("="),r=decodeURIComponent(e||"").trim();if(!r)continue;const i=void 0!==n?decodeURIComponent(n).trim():"";let o;o=/^\d+(\.\d+)?$/.test(i)?Number(i):"true"===i||"false"!==i&&i,h.hasOwnProperty(r)?Array.isArray(h[r])?h[r].push(o):h[r]=[h[r],o]:h[r]=o}}return{host:s,hostname:l,pathname:a,port:c,protocol:o,origin:p,href:e,search:i?`?${i}`:"",hash:n?`#${decodeURIComponent(n)}`:"",query:h}},e.urlStringify=function(e){const{protocol:t="",hostname:n,port:r="",pathname:i="/",query:o={},hash:s=""}=e,a=t?t.endsWith(":")?t:`${t}:`:"",u=r?`${n}:${r}`:n,l=i.startsWith("/")?i:`/${i}`,c=Object.entries(o).flatMap((([e,t])=>{if(!e||null==t)return[];const n=e=>encodeURIComponent(String(e));return Array.isArray(t)?t.map((t=>`${encodeURIComponent(e)}=${n(t)}`)):`${encodeURIComponent(e)}=${n(t)}`})).join("&");return`${a}//${u}${l}${c?`?${c}`:""}${s?s.startsWith("#")?s:`#${s}`:""}`},e.values=function(e,t){return j(e)?[]:("undefined"!=typeof Reflect&&"function"==typeof Reflect.ownKeys?Reflect.ownKeys(e):[...Object.getOwnPropertyNames?Object.getOwnPropertyNames(e):[],...Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e):[]]).filter((n=>{const r=Object.getOwnPropertyDescriptor(e,n);return!!r&&(x(t)?t(n,r):r.enumerable)})).map((t=>e[t]))},e.words=Z}));
//# sourceMappingURL=index.umd.js.map