funtool
Version:
A modern, efficient, and modular JavaScript utility library designed to enhance developer productivity.
3 lines (2 loc) • 28.8 kB
JavaScript
const e="1.2.1";function t(e,t){const n=e.length;if(0!==n)return t<0&&(t=n+t),e[t]}function n(e,t){return e.filter((e=>t.includes(e)))}function r(e,t){return e.filter((e=>!t.includes(e)))}function i(e,t){return[...new Set([...e,...t])]}function o(e){return[...new Set(e)]}function u(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===Object.prototype.toString.call(e)}function s(e){return"[object ArrayBuffer]"===Object.prototype.toString.call(e)}function a(e){return"undefined"!=typeof Blob&&e instanceof Blob}function c(e){return"[object Boolean]"===Object.prototype.toString.call(e)}function l(e){return"undefined"!=typeof Buffer&&"function"==typeof Buffer.isBuffer&&Buffer.isBuffer(e)}function f(e){return e instanceof DataView&&"[object DataView]"===Object.prototype.toString.call(e)}function p(e){return"[object Date]"===Object.prototype.toString.call(e)}function h(e){return"object"==typeof e&&null!==e&&"number"==typeof e.nodeType&&1===e.nodeType&&"string"==typeof e.nodeName&&"undefined"!=typeof Element&&e instanceof Element}function d(e){return"undefined"!=typeof Node&&e instanceof Node&&e.nodeType===Node.TEXT_NODE}function m(e){return"undefined"!=typeof Node&&e instanceof Node&&e.nodeType===Node.COMMENT_NODE}function g(e){return"undefined"!=typeof Document&&e instanceof Document}function y(e){return"undefined"!=typeof Node&&e instanceof Node&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function b(e){return"undefined"!=typeof Node&&e instanceof Node}function v(e){return"undefined"!=typeof window&&e===window}function w(e){return"[object Number]"===Object.prototype.toString.call(e)}function x(e){return w(e)&&e%1==0}function O(e){return"[object BigInt]"===Object.prototype.toString.call(e)}function j(e){return w(e)&&e%1!=0}function A(e){return"function"==typeof Number.isNaN?Number.isNaN(e)&&"number"==typeof e:"number"==typeof e&&A(e)}function _(e){return"function"==typeof e||"object"==typeof e&&null!==e}function S(e){return null!=e&&"object"==typeof e}function $(e){if(!_(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype||null===Object.getPrototypeOf(t)}function E(e){return"[object String]"===Object.prototype.toString.call(e)}function C(e){return null==e||(E(e)?0===e.trim().length:w(e)?0===e||A(e):u(e)?0===e.length:$(e)?0===Object.keys(e).length:!!p(e)&&A(e.getTime()))}function N(e){return"[object Map]"===Object.prototype.toString.call(e)&&e instanceof Map}function T(e){return"[object WeakMap]"===Object.prototype.toString.call(e)&&e instanceof WeakMap}function P(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function R(e){return"[object Set]"===Object.prototype.toString.call(e)&&e instanceof Set}function I(e){return"[object WeakSet]"===Object.prototype.toString.call(e)&&e instanceof WeakSet}function M(e){return"symbol"==typeof e}function U(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function k(e,t,n=!0,r=new WeakMap){const i=c(n)?{ordered:n}:n||{ordered:!0};if(e===t)return!0;if(null==e||null==t||typeof e!=typeof t)return!1;if(w(e)&&w(t)&&A(e)&&A(t))return!0;if(M(e)&&M(t))return e.description===t.description;if(O(e)&&O(t))return e===t;if(c(e)&&c(t))return e===t;if(p(e)&&p(t))return e.getTime()===t.getTime();if(P(e)&&P(t))return e.source===t.source&&e.flags===t.flags;if(u(e)&&u(t))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(!k(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 u=0;u<t.length;u++)if(!i[u]&&k(o,t[u],n,r)){i[u]=!0,e=!0;break}if(!e)return!1}return!0}}(e,t,i,r);if(s(e)&&s(t)){if(e.byteLength!==t.byteLength)return!1;const n=new Uint8Array(e),r=new Uint8Array(t);for(const[e,t]of n.entries())if(t!==r[e])return!1;return!0}if(U(e)&&U(t)){if(e.constructor!==t.constructor||e.byteLength!==t.byteLength)return!1;const n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);for(const[e,t]of n.entries())if(t!==r[e])return!1;return!0}if(f(e)&&f(t)){if(e.constructor!==t.constructor||e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.byteLength;n++)if(e.getUint8(n)!==t.getUint8(n))return!1;return!0}return R(e)&&R(t)?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(!k(e.value,t.value,n,r))return!1}return!0}(e,t,{ordered:!0},r):N(e)&&N(t)?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[u,s]=e.value,[a,c]=t.value;if(!k(u,a,n,r)||!k(s,c,n,r))return!1}return!0}(e,t,{ordered:!0},r):!(!$(e)||!$(t))&&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(!k(e[o],t[o],n,r))return!1}return!0}(e,t,{ordered:!1},r)}function D(e){return"function"==typeof e}function F(){return"undefined"!=typeof process&&!!process.versions?.node}function L(e){return"[object Null]"===Object.prototype.toString.call(e)}function V(e){return null==e}function B(e){return"object"!=typeof e&&"function"!=typeof e||null==e}function W(e){return e&&"function"==typeof e.then}function z(e){return"[object Undefined]"===Object.prototype.toString.call(e)}function Z(e){return null===e?"null":Array.isArray(e)?"array":typeof e}function q(e,t){if(B(e))return e;if(u(e))return e.map(((e,n)=>{if(D(t)){return t(e,n)}return e}));if(p(e))return new Date(e.getTime());if(P(e))return new RegExp(e.source,e.flags);if(N(e))return new Map(e);if(R(e))return new Set(e);if(U(e))return e.slice();if(f(e))return new DataView(e.buffer.slice(0));if(_(e)){const n=Object.getPrototypeOf(e),r=Object.create(n);for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)){const i=e[n],o=t?.(i,n);r[n]=void 0!==o?o:i}return r}return e}function H(e){return q(e)}function K(e,t){return q(e,t)}function X(e,t){return!B(e)&&Object.prototype.hasOwnProperty.call(e,t)}function G(e,t){if(B(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&&(D(t)?t(n,r):r.enumerable)}))}const J={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 Q(e,t,n,r){if(L(e)||!S(e))return e;if(D(e)||M(e)||O(e)||T(e)||I(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 J)return J[i](e,t,n);const o={};return t.set(e,o),G(e).forEach((i=>{if(X(e,i)){const u=e[i],s=r?.(u,i,e);o[i]=void 0!==s?s:n(u,t)}})),o}function Y(e,t=new WeakMap){return Q(e,t,Y)}function ee(e,t,n=new WeakMap){const r=(e,i=n)=>{const o=t(e);return void 0!==o?o:Q(e,i,r,t)};return r(e)}function te(e,t,n=0){return u(e)?e.slice(n).includes(t):E(e)?-1!==e.indexOf(String(t),n):N(e)||R(e)?e.has(t):!!$(e)&&Object.values(e).includes(t)}class ne{constructor(e,t){if(e){if(!ne.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 ne(e)}static createWithPrefix(e){return e+(new ne).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(!ne.isValid(e))throw new Error(`Invalid strict ObjectId: ${e}`);return new ne(e)}const n=e.match(/[a-fA-F0-9]{24}/);if(!n)throw new Error(`Invalid format for ObjectId: ${e}`);return new ne(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 ne(this.hex)}toJSON(){return this.toHexString()}}function re(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]))}function ie(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",u=atob(n),s=Uint8Array.from(u,(e=>e.charCodeAt(0)));return{blob:new Blob([s],{type:i}),mime:i,ext:o}}function oe(e,t){const{blob:n,ext:r}=ie(e),i=t?.key||"file";let o=t?.filename;o?o.includes(".")||(o+=`.${r}`):o=`${Date.now()}.${r}`;const u=new FormData;return u.append(i,n,o),u}function ue(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}()}function se(e,t=500){let n=null,r=null,i=null,o=null,u=null;const s=()=>{if(r)try{const t=e.apply(i,r);return o?.(t),a(),t}catch(e){throw u?.(e),a(),e}},a=()=>{n=null,r=null,i=null,o=null,u=null};function c(...e){return n&&clearTimeout(n),r=e,i=this,new Promise(((e,r)=>{o=e,u=r,n=setTimeout((()=>{s()}),t)}))}return c.cancel=function(){n&&clearTimeout(n),u?.("Debounced call canceled"),a()},c.flush=function(){return n&&clearTimeout(n),Promise.resolve(s())},c.pending=function(){return!!n},c}function ae(e,t=500){let n=null,r=null,i=null;const o=()=>{n=null,r=null,i=null},u=()=>{if(r)try{const t=e.apply(i,r);return o(),t}catch(e){throw o(),e}};function s(...e){n&&clearTimeout(n),r=e,i=this,n=setTimeout((()=>{u()}),t)}return s.cancel=()=>{n&&clearTimeout(n),o()},s.flush=()=>(n&&clearTimeout(n),u()),s.pending=()=>!!n,s}function ce(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("")}const le=[{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.]+)/}],fe=[{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.]+)/}],pe=[{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/}],he=[{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 de(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 le){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 fe){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 he){const i=t.match(r);if(i){n.engine={name:e,version:i[1]||null};break}}for(const{type:e,regex:r}of pe)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}function me(){const e=de();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}}function ge(e){return void 0!==e?e:"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function ye(){}const be=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("&"),ve=(e,t)=>"object"!=typeof e||null==e?"":Object.entries(e).map((([e,n])=>t(e,n))).filter((e=>"string"==typeof e)).join("&"),we=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("&")},xe=(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("&")};function Oe(e=0,t=1){return Math.floor(Math.random()*(t-e))+e}function je(e=0,t=1){return Math.random()*(t-e)+e}function Ae(e,t=500){let n=null,r=null,i=null,o=null,u=null;const s=()=>{n=Date.now();const t=e.apply(o,i);return u?.(t),a(),t},a=()=>{r=null,i=null,o=null,u=null};function c(...e){const a=Date.now(),c=n?t-(a-n):0;return i=e,o=this,new Promise((e=>{u=e,c<=0?s():r||(r=setTimeout(s,c))}))}return c.cancel=()=>{r&&clearTimeout(r),a()},c.flush=()=>r?(clearTimeout(r),Promise.resolve(s())):Promise.resolve(void 0),c.pending=()=>Boolean(r),c}function _e(e,t=500){let n=null,r=null,i=null,o=null;const u=()=>{n=Date.now(),e.apply(o,i),s()},s=()=>{r=null,i=null,o=null};function a(...e){const s=Date.now(),a=n?t-(s-n):0;i=e,o=this,a<=0?u():r||(r=setTimeout(u,a))}return a.cancel=()=>{r&&clearTimeout(r),s()},a.flush=()=>{r&&(clearTimeout(r),u())},a.pending=()=>Boolean(r),a}function Se(e){const[t,n]=e.split("#"),[r,i]=t.split("?");let o="",u="",s="/";const a=r.match(/^([a-zA-Z]+:)?\/\//);if(a){o=a[1]||"";const e=r.slice(o.length+2),t=e.indexOf("/");t>=0?(u=e.slice(0,t),s=e.slice(t)||"/"):(u=e,s="/")}else s=r||"/";let c=u,l="";const f=u.indexOf(":");f>=0&&(c=u.slice(0,f),l=u.slice(f+1));const p=o+"//"+u,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:u,hostname:c,pathname:s,port:l,protocol:o,origin:p,href:e,search:i?`?${i}`:"",hash:n?`#${decodeURIComponent(n)}`:"",query:h}}function $e(e){const{protocol:t="",hostname:n,port:r="",pathname:i="/",query:o={},hash:u=""}=e,s=t?t.endsWith(":")?t:`${t}:`:"",a=r?`${n}:${r}`:n,c=i.startsWith("/")?i:`/${i}`,l=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`${s}//${a}${c}${l?`?${l}`:""}${u?u.startsWith("#")?u:`#${u}`:""}`}const Ee=globalThis.Math;class Ce{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 Ce(e??this._value,this._precision,this._rounding)}_round(e){if(!isFinite(e))return e;if(Ee.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 Ee.ceil(e*t)/t;case"down":return Ee.floor(e*t)/t;default:return Ee.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=Ee.abs(this._value),this}sqrt(){if(this._value<0)throw new Error("Square root of negative numbers is not supported.");return this._value=Ee.sqrt(this._value),this}cbrt(){return this._value=Ee.cbrt(this._value),this}pow(e){return 1!==this._value||isFinite(e)?this._value=Ee.pow(this._value,e):this._value=1,this}floor(){return this._value=Ee.floor(this._value),this}ceil(){return this._value=Ee.ceil(this._value),this}round(){return this._value=Ee.round(this._value),this}sign(){return this._value=Ee.sign(this._value),this}degToRad(){return this._value=this._value*Ee.PI/180,this}radToDeg(){return this._value=180*this._value/Ee.PI,this}max(...e){return this._value=Ee.max(this._value,...e),this}min(...e){return this._value=Ee.min(this._value,...e),this}sin(){return this._value=Ee.sin(this._value),this}cos(){return this._value=Ee.cos(this._value),this}tan(){return this._value=Ee.tan(this._value),this}asin(){return this._value=Ee.asin(this._value),this}acos(){return this._value=Ee.acos(this._value),this}atan(){return this._value=Ee.atan(this._value),this}log(){return this._value=Ee.log(this._value),this}log10(){return this._value=Ee.log10(this._value),this}exp(){return this._value=Ee.exp(this._value),this}toExponential(e){return void 0===e?this._value.toExponential():this._value.toExponential(e)}}function Ne(e,t){const n={...e};return G(t).forEach((e=>{const r=Object.getOwnPropertyDescriptor(t,e);r&&Object.defineProperty(n,e,r)})),n}function Te(e,t){if(u(e)&&u(t)){const n=Math.max(e.length,t.length),r=[];for(let i=0;i<n;i++){const n=e[i],o=t[i];B(n)||B(o)?r[i]=void 0!==o?o:n:r[i]=Te(n,o)}return r}if($(e)&&$(t)){const n={...e};return G(t).forEach((r=>{const i=e[r],o=t[r];B(i)||B(o)?n[r]=o:n[r]=Te(i,o)})),n}return t}function Pe(e,t){const n={};return G(e).forEach((r=>{t.includes(r)||(n[r]=e[r])})),n}function Re(e,t){const n={};return G(e).forEach((r=>{t(e[r],r)||(n[r]=e[r])})),n}function Ie(e,t){const n={};for(const r of t)r in e&&(n[r]=e[r]);return n}function Me(e,t){const n={};for(const r in e)t(e[r],r)&&(n[r]=e[r]);return n}function Ue(e,t){if(B(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&&(D(t)?t(n,r):r.enumerable)})).map((t=>e[t]))}class ke{constructor(){this.plugins=new Map,this.internalRuleNames=new Set,this.listeners=[],this.plugins=new Map,this.internalRuleNames=new Set,this.listeners=[]}static getInstance(){return ke.instance||(ke.instance=new ke),ke.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()}}ke.instance=null;const De=ke.getInstance();class Fe{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=De.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 Le{constructor(e){this.input=e}use(e){if(e instanceof RegExp)this.pattern=e;else{const t=De.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 Ve(e){return De.register(e,!0),e}const Be={email:Ve({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:Ve({name:"mobile",pattern:/^1[3|4|5|6|7|8|9][0-9]{9}$/,validate:e=>e.pattern.test(e.input)}),alpha:Ve({name:"alpha",pattern:/^[a-zA-Z]+$/,validate:e=>e.pattern.test(e.input)}),chinese:Ve({name:"chinese",pattern:/^\p{Script=Han}+$/u,validate:e=>e.pattern.test(e.input)}),ipv6:Ve({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:Ve({name:"postal",pattern:/\d{6}/,validate:e=>e.pattern.test(e.input)}),username:Ve({name:"username",pattern:/^[a-zA-Z][a-zA-Z0-9_]{4,15}$/,validate:e=>e.pattern.test(e.input)}),ipv4:Ve({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:Ve({name:"IDCard",pattern:/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,validate:e=>e.pattern.test(e.input)}),url:Ve({name:"url",pattern:/^((https|http|ftp|rtsp|mms)?:\/\/)[^\s]+/,validate:e=>e.pattern.test(e.input)}),qq:Ve({name:"qq",pattern:/^[1-9][0-9]{4,9}$/,validate:e=>e.pattern.test(e.input)}),landline:Ve({name:"landline",pattern:/^0\d{2,3}-?\d{7,8}$/,validate:e=>e.pattern.test(e.input)}),number:Ve({name:"number",pattern:/^[0-9]$/,validate:e=>e.pattern.test(e.input)}),nonAscii:Ve({name:"nonAscii",pattern:/[^\x00-\xff]/,validate:e=>e.pattern.test(e.input)}),nonLatin:Ve({name:"nonLatin",pattern:/[^\u0000-\u024F]/,validate:e=>e.pattern.test(e.input)}),password:Ve({name:"password",pattern:/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,validate:e=>e.pattern.test(e.input)}),html:Ve({name:"html",pattern:/<("[^"]*"|'[^']*'|[^'">])*>/,validate:e=>e.pattern.test(e.input)})};class We{constructor(){for(const e in Be)this[e]=Be[e]}static getInstance(){return We.instance||(We.instance=new We),We.instance}checker(e){return new Fe(e)}replacer(e){return new Le(e)}definePlugin(e){if(De.isInternal(e.name))throw new Error(`Cannot register plugin with reserved name: '${e.name}'`);return De.register(e),e}}We.instance=null;const ze=We.getInstance();function Ze(e){return e?e.charAt(0).toUpperCase()+e.slice(1):""}function qe(e,t){return(e.match(new RegExp(t,"g"))||[]).length}function He(e,t){return e.indexOf(t)}function Ke(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)}function Xe(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)}function Ge(e){return e?e.charAt(0).toLowerCase()+e.slice(1):""}function Je(e,t,n=" "){return e.padEnd(t,n)}function Qe(e,t,n=" "){return e.padStart(t,n)}function Ye(e,t){const n="number"==typeof t?t:e.indexOf(t);return n>=0?e.slice(0,n+1):e}function et(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)}function tt(e,t){const n="number"==typeof t?t:e.indexOf(t);return n>=0?e.slice(n):e}function nt(e,t){return e.repeat(t)}function rt(e,t,n){return e.split(t).join(n)}function it(e){return e.split("").reverse().join("")}function ot(e,t,n){return e.substring(t,n)}function ut(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)||[]))}function st(e){if(!e)return"";const[t,...n]=ut(e);return[t.toLowerCase(),...n.map((e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))].join("")}function at(e){return ut(e).map((e=>e.toLowerCase())).join("-")}function ct(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)}function lt(e){return e.toString().toLowerCase()}function ft(e){return ut(e).map((e=>/^[A-Z0-9]+$/.test(e)?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())).join("")}function pt(e){return ut(e).map((e=>e.toLowerCase())).join("_")}function ht(e){return e.toLowerCase().replace(/[_\-]+/g," ").replace(/\b([a-z])([a-z]*)/g,((e,t,n)=>t.toUpperCase()+n))}function dt(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)}function mt(e){return e.toString().toUpperCase()}function gt(e){return e.toString().replace(/^\s+|\s+$/g,"")}function yt(e){return e.toString().replace(/\s+$/g,"")}function bt(e){return e.toString().replace(/^\s+/g,"")}export{Ce as MathX,ne as ObjectId,e as VERSION,t as at,re as awaitTo,ie as base64ToBlob,oe as base64ToFormData,Ze as capitalizeFirstLetter,H as clone,Y as cloneDeep,ee as cloneDeepWith,K as cloneWith,qe as count,ue as currying,se as debounce,ae as debounceSync,He as findIndex,ce as generateVerificationCode,me as getBrowserType,ge as getUA,X as hasOwn,te as includes,Ke as insertAfter,Xe as insertBefore,n as intersect,u as isArray,s as isArrayBuffer,O as isBigInt,a as isBlob,c as isBoolean,l as isBuffer,m as isCommentNode,f as isDataView,p as isDate,g as isDocument,y as isDocumentFragment,h as isElement,C as isEmpty,k as isEqual,j as isFloat,D as isFunction,x as isInt,N as isMap,A as isNaN,V as isNil,b as isNode,F as isNodeJS,L as isNull,w as isNumber,_ as isObject,S as isObjectLike,$ as isPlainObject,B as isPrimitive,W as isPromise,P as isRegExp,R as isSet,E as isString,M as isSymbol,d as isTextNode,U as isTypedArray,z as isUndefined,T as isWeakMap,I as isWeakSet,v as isWindow,G as keys,Ge as lowercaseFirstLetter,Ne as merge,Te as mergeDeep,ye as noop,Pe as omit,Re as omitBy,Je as padEnd,Qe as padStart,be as parseQuery,we as parseQueryDeep,xe as parseQueryDeepWith,ve as parseQueryWith,de as parseUA,Ie as pick,Me as pickBy,je as randomFloat,Oe as randomInt,ze as regex,r as remove,Ye as removeAfter,et as removeAt,tt as removeBefore,nt as repeat,rt as replaceAll,it as reverse,ot as substring,Ae as throttle,_e as throttleSync,st as toCamelCase,at as toKebabCase,ct as toLowerAt,lt as toLowerCase,ft as toPascalCase,pt as toSnakeCase,ht as toTitleCase,dt as toUpperAt,mt as toUpperCase,gt as trim,yt as trimEnd,bt as trimStart,Z as typeOf,i as union,o as unique,Se as urlParse,$e as urlStringify,Ue as values,ut as words};
//# sourceMappingURL=index.esm.js.map