UNPKG

@utilify/core

Version:

Modern, strongly typed, and safe utility function library for JavaScript and TypeScript. Includes type checking, manipulation of arrays, objects, strings, dates, colors, numbers, regular expressions, and more. Compatible with Browser, Node.js, Deno, and B

1 lines 51 kB
function e(e){if(null===e||"object"!=typeof e&&"function"!=typeof e)return null;const r=Object.getPrototypeOf(e)?.constructor;return r?r.name:null}function r(e){if("number"!=typeof e||!Number.isInteger(e)||e<=0)throw new TypeError("Expected a positive integer for 'value'");const r=[];for(let t=1;t<=e;t++)e%t===0&&r.push(t);return r}function t(e,r,t){if("number"!=typeof e)throw new TypeError("Expected a number for 'value'");if("number"!=typeof r)throw new TypeError("Expected a number for 'min'");if("number"!=typeof t)throw new TypeError("Expected a number for 'max'");return r<=e&&e<=t}function n(e){if("number"!=typeof e)throw new TypeError("Expected a number for 'value'");return e%2==0}function o(e){return e!=e}function i(e){if("number"!=typeof e)throw new TypeError("Expected a number for 'value'");return!o(e)&&e!==1/0&&e!==-1/0}function f(e){if("number"!=typeof e)throw new TypeError("Expected a number for 'value'");return!Number.isInteger(e)&&Number.isFinite(e)}function a(e){if("number"!=typeof e)throw new TypeError("Expected a number for 'value'");return e===1/0||e===-1/0}function u(e){if("number"!=typeof e)throw new TypeError("Expected a number for 'value'");return Number.isInteger(e)&&e==e&&e!==1/0&&e!==-1/0}function c(e){if("number"!=typeof e)throw new TypeError("Expected a number for 'value'");return e<0}function s(e){if("number"!=typeof e)throw new TypeError("Expected a number for 'value'");return e%2!=0}function p(e){if("number"!=typeof e)throw new TypeError("Expected a number for 'value'");return e>0}function l(e){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("Expected an integer for 'value'");if(e<2)return!1;if(2===e)return!0;if(e%2==0)return!1;const r=Math.sqrt(e);for(let e=3;e<=r;e+=2)if(e%e===0)return!1;return!0}function y(e,r,t=1){if("number"!=typeof e)throw new TypeError("Expected a number for 'start'");if("number"!=typeof r)throw new TypeError("Expected a number for 'end'");if("number"!=typeof t)throw new TypeError("Expected a number for 'step'");if(0===t)throw new Error("step cannot be zero");const n=[];if(t>0)for(let o=e;o<r;o+=t)n.push(Math.trunc(100*o)/100);else for(let o=e;o>r;o+=t)n.push(o);return n}function d(e){if("number"!=typeof e)throw new TypeError("Expected a number for 'value'");return e.toString().split("").reduce((e,r)=>e+parseInt(r,10),0)}function w(e){return"[object Array]"===Object.prototype.toString.call(e)}function h(e){return null===e}function E(e){const r=typeof e;if("number"===r){if(o(e))return"nan";if(a(e))return"infinity"}else if("object"===r){if(h(e))return"null";if(w(e))return"array"}return r}function g(e){return"function"==typeof e}function m(e){return g(e)&&"AsyncFunction"===e.constructor.name}function b(e){return g(e)&&"AsyncGeneratorFunction"===e.constructor.name}function x(e){return"bigint"==typeof e}function T(e){return"boolean"==typeof e}function v(e){return e instanceof Date}function A(e){return[void 0,null,!1,NaN,0,0n,""].includes(e)}function F(e){return g(e)&&"GeneratorFunction"===e.constructor.name}function S(e){return e instanceof Map}function $(e){return null==e}function M(e){return"number"==typeof e&&!a(e)&&!o(e)}function D(e){return"object"==typeof e&&!h(e)&&!w(e)}function k(e){return h(e)||"object"!=typeof e&&!g(e)}function j(e){return e instanceof Promise}function O(e){return e instanceof RegExp}function z(e){return e instanceof Set}function N(e){return"string"==typeof e}function I(e){return"symbol"==typeof e}function L(e){return void 0===e}function R(e){return e instanceof WeakMap}function U(e){return e instanceof WeakSet}function C(e){return e instanceof WeakRef}function B(e,r,t){if(!w(e))throw new TypeError("Expected an array for 'array'");if(0===e.length)return[];if("number"!=typeof r)throw new TypeError("Expected a number for 'index'");if("function"!=typeof t)throw new TypeError("Expected a function for 'fn'");const n=e.length;return e[(r+n)%n]=t(e[(r+n)%n]),e}function P(e,r){if(!w(e)&&!N(e))throw new TypeError("Expected an array-like for 'array'");if("number"!=typeof r)throw new TypeError("Expected a number for 'index'");return e.slice(r+1)}function W(e,r=1){if(!w(e))throw new TypeError("Expected an array for 'array'");if("number"!=typeof r||r<=0)throw new TypeError("Expected 'size' to be a number greater than 0");return Array.from({length:e.length-r+1},(t,n)=>e.slice(n,n+r))}function q(e,r){if(!w(e))throw new TypeError("Expected an array for 'array'");return[...e,r]}function Z(e,r=(e,r)=>r,t=e=>e){if(!w(e))throw new TypeError("Expected an array for 'array'");if("function"!=typeof r)throw new TypeError("Expected a function for 'keyFn'");if("function"!=typeof t)throw new TypeError("Expected a function for 'valueFn'");const n={};for(let o=0;o<e.length;o++)n[r(e[o],o,e)]=t(e[o],o,e);return n}function _(e,r){if(!w(e)&&!N(e))throw new TypeError("Expected an array-like for 'array'");if("number"!=typeof r)throw new TypeError("Expected a number for 'index'");return e.slice(0,r)}function H(e,r=1){if(!w(e)&&!N(e))throw new TypeError("Expected an array for 'array'");if("number"!=typeof r||r<=0)throw new TypeError("Expected a non-zero integer number for 'size'");const t=[];for(let n=0;n<e.length;n+=r)t.push(e.slice(n,n+r));return t}function Y(e,r=(e,r)=>r){if(!w(e))throw new TypeError("Expected an array for 'array'");if("function"!=typeof r)throw new TypeError("Expected a function for 'keySelector'");const t={};for(let n=0;n<e.length;n++){const o=e[n],i=r(o,n);i in t||(t[i]=[]),t[i].push(o)}return t}function G(e,r){if(!w(e))throw new TypeError("Expected an array for 'array'");if("function"!=typeof r)throw new TypeError("Expected a function for 'keySelector'");const t=Y(e,r);return Object.values(t)}function V(e){if(!w(e))throw new TypeError("Expected an array for 'array'");return e.filter(Boolean)}function K(e,r){if(!w(e))throw new TypeError("Expected an array for 'array'");if("function"!=typeof r)throw new TypeError("Expected a function for 'predicate'");let t=0;for(const n of e)r(n)&&t++;return t}function J(e){if(!w(e))throw new TypeError("Expected an array for 'array'");let r=-1;return()=>{if(0!==e.length)return r=(r+1)%e.length,e[r]}}function Q(e){return structuredClone(e)}function X(e){if("[object Object]"!==Object.prototype.toString.call(e))return!1;const r=Object.getPrototypeOf(e);return null===r||r===Object.prototype}function ee(e){const r={};return function e(t,n=""){w(t)?t.forEach((t,o)=>{const i=n?`${n}[${o}]`:`[${o}]`;X(t)||w(t)?e(t,i):r[i]=t}):X(t)?Object.entries(t).forEach(([t,o])=>{const i=t.includes(".")?`[${t}]`:t,f=n?`${n}.${i}`:i;X(o)||w(o)?e(o,f):r[f]=o}):r[n]=t}(e),r}function re(e){return"object"==typeof e&&null!==e}function te(e){const r=Object.freeze(e);if(!D(r))return r;for(const e of Reflect.ownKeys(r)){re(r[e])&&te(r[e])}return r}function ne(e,r,t){const n=Array.isArray(r)?r.map(e=>e.replace(/^\[(\d+)\]$/g,"$1")):r.replace(/\[(\d+)\]/g,".$1").split(".");let o=e;for(const e of n){if(!Object.hasOwn(o,e))return t;o=o[e]}return o??t}function oe(e,r){const t=Array.isArray(r)?r.map(e=>e.replace(/^\[(\d+)\]$/g,"$1")):r.replace(/\[(\d+)\]/g,".$1").split(".");let n=e;for(const e of t){if(!Object.hasOwn(n,e))return!1;n=n[e]}return!0}function ie(e,r){function t(e,r,n=new WeakMap){return!!Object.is(e,r)||!(!re(e)||!re(r))&&(w(e)&&w(r)?function(e,r,n){const o=Object.keys(e),i=Object.keys(r);if(o.length!==i.length)return!1;for(let o=0;o<e.length;o++)if(!t(e[o],r[o],n))return!1;return!0}(e,r,n):v(e)&&v(r)?function(e,r){return e.getTime()===r.getTime()}(e,r):O(e)&&O(r)?function(e,r){return e.source===r.source&&e.flags===r.flags}(e,r):S(e)&&S(r)?function(e,r,n){if(e.size!==r.size)return!1;for(const[o,i]of e)if(!r.has(o)||!t(i,r.get(o),n))return!1;return!0}(e,r,n):z(e)&&z(r)?function(e,r){if(e.size!==r.size)return!1;for(const t of e)if(!r.has(t))return!1;return!0}(e,r):ArrayBuffer.isView(e)&&ArrayBuffer.isView(r)?function(e,r){if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(r)||e.byteLength!==r.byteLength)return!1;const t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);for(let e=0;e<t.length;e++)if(t[e]!==n[e])return!1;return!0}(e,r):e instanceof ArrayBuffer&&r instanceof ArrayBuffer?function(e,r){if(e.byteLength!==r.byteLength)return!1;const t=new Uint8Array(e),n=new Uint8Array(r);for(let e=0;e<t.length;e++)if(t[e]!==n[e])return!1;return!0}(e,r):!(!X(e)||!X(r))&&function(e,r,n){if(n.has(e)&&n.has(r))return!0;n.set(e,!0),n.set(r,!0);const o=Reflect.ownKeys(e),i=Reflect.ownKeys(r);if(o.length!==i.length)return!1;for(const f of o)if(!i.includes(f)||!t(e[f],r[f],n))return!1;return!0}(e,r,n))}return t(e,r)}function fe(e){return Object.isFrozen(e)}function ae(e){return Object.isSealed(e)}function ue(e,r){if("object"!=typeof e||null===e)return r;const t=w(e);if(t!==w(r))return r;const n=t?[...e]:{...e};for(const e of Reflect.ownKeys(r)){const t=n[e],o=r[e];X(t)&&X(o)||w(t)&&w(o)?n[e]=ue(t,o):n[e]=o}return n}function ce(e,r){const t=Q(e);for(const e of r)Object.hasOwn(t,e)&&delete t[e];return t}function se(e,r){return r.reduce((r,t)=>(Object.hasOwn(e,t)&&(r[t]=e[t]),r),{})}function pe(e){const r=Object.seal(e);if(!D(r))return r;for(const e of Reflect.ownKeys(r)){const t=r[e];re(t)&&pe(t)}return r}function le(e,r,t){const n=Array.isArray(r)?r:r.replace(/\[(\d+)\]/g,".$1").split(".");let o=e;const i=n.slice(0,-1),f=n[n.length-1];for(const e of i)Object.hasOwn(o,e)||(o[e]={}),o=o[e];return o[f]=t,e}function ye(e){const r=[];let t="",n=!1;for(let o=0;o<e.length;o++){const i=e[o];"["===i?(t&&(r.push(t),t=""),n=!0,t+=i):"]"===i?(t+=i,r.push(/^\[\d+\]$/.test(t)?t:t.slice(1,-1)),t="",n=!1):"."!==i||n?t+=i:t&&(r.push(t),t="")}return t&&r.push(t),r}function de(e){if(!X(e))return e;if(0===Object.keys(e).length)return e;const r=Object.keys(e).every(e=>/^\[\d+\]/.test(e))?[]:{};for(const t in e){if(!Object.hasOwn(e,t))continue;const n=ye(t);if(!n)continue;let o=r;for(let e=0;e<n.length-1;e++){const r=n[e],t=r.startsWith("[")&&r.endsWith("]")?+r.slice(1,-1):r,i=n[e+1],f=i?.startsWith?.("[")&&i.endsWith("]");t in o||(o[t]=f?[]:{}),o=o[t]}const i=n[n.length-1];o[i.startsWith("[")&&i.endsWith("]")?+i.slice(1,-1):i]=e[t]}return r}function we(e,r){if(!w(e))throw new TypeError("Expected an array for 'array'");for(const t of e)if(ie(t,r))return!0;return!1}function he(e,r){if(!w(e))throw new TypeError("Expected an array for 'array1'");if(!w(r))throw new TypeError("Expected an array for 'array2'");return e.filter(e=>!we(r,e))}function Ee(e,r=1){if(!w(e)&&!N(e))throw new TypeError("Expected an array-like for 'array'");if("number"!=typeof r||r<0)throw new TypeError("Expected 'count' to be a non-negative number");return e.slice(0,r)}function ge(e,r){if(!w(e))throw new TypeError("Expected an array for 'array'");if("function"!=typeof r)throw new TypeError("Expected a function for 'fn'");return e.map(r).flat(1)}function me(e,r=1/0){if(!w(e))throw new TypeError("Expected an array for 'array'");if("number"!=typeof r||r<0)throw new TypeError("Expected a non-negative number for 'depth'");return e.flat(r)}function be(e){return null!=e&&"function"==typeof e[Symbol.iterator]}function xe(e,r=1){if(!w(e)&&!N(e))throw new TypeError("Expected an array-like for 'array'");if("number"!=typeof r||r<0)throw new TypeError("Expected 'count' to be a non-negative number");return e.slice(-r)}function Te(...e){if(!Array.isArray(e)||!e.every(e=>"function"==typeof e))throw new TypeError("Expected all arguments to be functions");return r=>e.reduceRight((e,r)=>r(e),r)}function ve(e){return e}function Ae(e,{cacheTimeout:r,serializer:t}={serializer:JSON.stringify}){if("function"!=typeof e)throw new TypeError("Expected a function for 'callback'");if(void 0!==r&&"number"!=typeof r)throw new TypeError("Expected a number for 'cacheTimeout'");if("function"!=typeof t)throw new TypeError("Expected a function for 'serializer'");const n=new Map;return(...o)=>{const i=t(o);return n.has(i)||(n.set(i,e(...o)),r&&setTimeout(()=>n.delete(i),r)),n.get(i)}}function Fe(){}function Se(e){if("function"!=typeof e)throw new TypeError("Expected a function for 'fn'");return(...r)=>!e(...r)}function $e(e){if("function"!=typeof e)throw new TypeError("Expected a function for 'callback'");let r,t=!1;return(...n)=>{if(!t){t=!0;try{r=e(...n)}catch(e){throw e}}return r}}function Me(e,...r){if("function"!=typeof e)throw new TypeError("Expected a function for 'callback'");return(...t)=>e(...r,...t)}function De(e,...r){if("function"!=typeof e)throw new TypeError("Expected a function for 'callback'");return(...t)=>e(...t,...r)}function ke(...e){if(!Array.isArray(e)||!e.every(e=>"function"==typeof e))throw new TypeError("Expected 'callbacks' to be an array of functions");return r=>e.reduce((e,r)=>r(e),r)}function je(e,r){if("function"!=typeof e)throw new TypeError("Expected a function for 'callback'");if("number"!=typeof r||!Number.isInteger(r)||r<0)throw new TypeError("Expected a non-negative integer for 'count'");const t=[];for(let n=0;n<r;n++)t.push(e(n));return t}function Oe(e,r){if("function"!=typeof e)throw new TypeError("Expected a function for 'predicate'");if("function"!=typeof r)throw new TypeError("Expected a function for 'callback'");return(...t)=>e(...t)?r(...t):void 0}function ze(e,r){if(!w(e))throw new TypeError("Expected an array for 'array'");if("function"!=typeof r)throw new TypeError("Expected a function for 'fn'");return e.filter(Se(r))}function Ne(e,r){if("number"!=typeof r)throw new TypeError("Expected a number for 'count'");if(r<0)throw new RangeError("Expected a non-negative integer for 'count'");return"string"==typeof e?e.repeat(r):Array(r).fill(e)}function Ie(e,r){if(!w(e))throw new TypeError("Expected an array for 'array'");if("number"!=typeof r)throw new TypeError("Expected a number for 'offset'");const t=e.length;return r=(r%t+t)%t,e.slice(r).concat(e.slice(0,r))}function Le(e){if(!w(e))throw new TypeError("Expected an array for 'array'");if(0===e.length)return;return e[Math.floor(Math.random()*e.length)]}function Re(e){if(!w(e))throw new TypeError("Expected an array for 'array'");for(let r=e.length-1;r>0;r--){const t=Math.floor(Math.random()*(r+1));[e[r],e[t]]=[e[t],e[r]]}return e}function Ue(e,r,t){if(!w(e))throw new TypeError("Expected an array for 'array'");if("number"!=typeof r)throw new TypeError("Expected 'fromIndex' to be a number");if(r<0||r>=e.length)throw new RangeError("'fromIndex' is out of bounds");if("number"!=typeof t)throw new TypeError("Expected 'toIndex' to be a number");if(t<0||t>=e.length)throw new RangeError("'toIndex' is out of bounds");return[e[r],e[t]]=[e[t],e[r]],e}function Ce(e){if(!w(e))throw new TypeError("Expected an array for 'array'");const r=[];for(const t of e)r.includes(t)||r.push(t);return r}function Be(...e){if(!e.every(w))throw new TypeError("Expected all arguments to be arrays");const r=[];for(const t of e)r.push(...t);return Ce(r)}function Pe(e){if(!w(e))throw new TypeError("Expected an array for 'zip'");if(!e.every(w))throw new TypeError("Expected all elements in 'zip' to be arrays");if(!e.length)return[];const r=e[0].length,t=Array.from({length:r},()=>[]);for(const r of e)r.forEach((e,r)=>t[r].push(e));return t}function We(...e){if(!e.every(w))throw new TypeError("Expected all arguments to be arrays");const r=Math.min(...e.map(e=>e.length)),t=[];for(let n=0;n<r;n++){const r=e.map(e=>e[n]);t.push(r)}return t}function qe(){return"object"==typeof Deno&&Object.hasOwn(Deno,"version")}function Ze(e,r){let t;return t=qe()?Deno.env.get(e):process.env[e],t??r}function _e(e,r){const t=Ze(e);return Array.isArray(r)?r.includes(t):t===r}function He(){return"undefined"==typeof window||"undefined"==typeof document}function Ye(){if(!He())return;if("userAgentData"in navigator)return navigator.userAgentData.platform;const e=navigator.userAgent;return/Android/i.test(e)?"Android":/iPhone|iPad|iPod/i.test(e)?"iOS":/Linux/i.test(e)?"Linux":/Windows/i.test(e)?"Windows":/Mac/i.test(e)?"macOS":"Unknown"}function Ge(){return"undefined"!=typeof window&&"undefined"!=typeof document}function Ve(){return"object"==typeof Bun&&Object.hasOwn(Bun,"version")}function Ke(){return"undefined"!=typeof global&&"undefined"!=typeof process}function Je(){return Ge()?"Browser":qe()?"Deno":Ve()?"Bun":Ke()?"Node":"Unknown"}function Qe(e){let r;return r=qe()?Deno.env.get(e):process.env[e],void 0!==r}function Xe(){return"undefined"!=typeof DedicatedWorkerGlobalScope&&self instanceof DedicatedWorkerGlobalScope}function er(){return _e("NODE_ENV","development")}function rr(){if(!He())return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}function tr(){return _e("NODE_ENV","production")}function nr(){return"undefined"!=typeof ServiceWorkerGlobalScope&&self instanceof ServiceWorkerGlobalScope}function or(){return"undefined"!=typeof SharedWorkerGlobalScope&&self instanceof SharedWorkerGlobalScope}function ir(){return _e("NODE_ENV","test")}function fr(){return Xe()||or()||nr()}function ar(e){let r;if(r=qe()?Deno.env.get(e):process.env[e],void 0===r)throw new Error("Expected a valid value for 'key'");return r}function ur(){if(!He())return!!(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled)}async function cr(){if(!He())return ur()?document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen?document.msExitFullscreen():void 0:Promise.reject(new Error("Fullscreen API is not supported."))}function sr(){if(!He())return navigator.language.slice(0,2)}function pr(){if(!He())return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function lr(){if(!He())return navigator.cookieEnabled}function yr(){if(!He())return navigator.onLine}function dr(e){return!(He()||!navigator.share)&&(!e||!navigator.canShare||navigator.canShare(e))}function wr(){if(!He())return"visible"===document.visibilityState}function hr(){if(!He())return"ontouchstart"in window||navigator.maxTouchPoints>0}function Er(e,r,t,n){if(!He())return e.addEventListener(r,t,n),()=>{e.removeEventListener(r,t,n)}}function gr(e){return Er(window,"offline",e)}function mr(e){return Er(window,"online",e)}function br(e){return Er(document,"visibilitychange",()=>e(document.visibilityState))}async function xr(e){if(!He())return ur()?e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen?e.msRequestFullscreen():void 0:Promise.reject(new Error("Fullscreen API is not supported."))}function Tr(e,r={behavior:"smooth",block:"start"}){if(!He()){if(!e)throw new Error("Expected an element for 'element'");e.scrollIntoView(r)}}function vr(e="smooth"){He()||window.scrollTo({top:0,behavior:e})}function Ar(e){if(!He())return dr(e)?navigator.share(e):Promise.reject(new Error("The Web Share API is not available or the data is not shareable."))}function Fr(e){return"string"==typeof e&&/^#([A-Fa-f0-9]{3,4}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$/.test(e)}function Sr(e){if(!Fr(e))throw new Error("Expected a valid hex color string");const r=H(e=e.trim().replace("#",""),e.length>4?2:1),t=r.slice(0,3).map(e=>Number.parseInt(e.padEnd(2,e),16));return 4===r.length&&t.push(Math.trunc(Number.parseInt(r[3],16)/255*100)/100),`rgb${4===r.length?"a":""}(${t.join(", ")})`}function $r(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'color'");Fr(e=e.trim())&&(e=Sr(e));const r=e.match(/^rgba?\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})(?:,\s*([0-1]?\.?\d+))?\)$/i);if(r){const e=parseInt(r[1]),t=parseInt(r[2]),n=parseInt(r[3]),o=void 0!==r[4]?parseFloat(r[4]):1;if(e<=255&&t<=255&&n<=255)return{model:"rgb",values:[e,t,n],alpha:o}}const t=e.match(/^hsla?\((\d{1,3}),\s*(\d{1,3})%,\s*(\d{1,3})%(?:,\s*([0-1]?\.?\d+))?\)$/i);if(t){const e=parseInt(t[1]),r=parseInt(t[2]),n=parseInt(t[3]),o=void 0!==t[4]?parseFloat(t[4]):1;if(e<=360&&r<=100&&n<=100)return{model:"hsl",values:[e,r,n],alpha:o}}return null}function Mr(e){return"string"==typeof e&&/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$|^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(?:0(?:\.\d+)?|1(?:\.0+)?)\s*\)$/i.test(e)}function Dr(e){if(!Mr(e))throw new Error("Expected a valid rgb color string");let[r,t,n,o]=e.trim().replace(/^rgba?\((.*)\)$/,"$1").split(",");r/=255,t/=255,n/=255;const i=Math.max(r,t,n),f=Math.min(r,t,n);let a,u,c=(i+f)/2;if(i===f)a=u=0;else{const e=i-f;switch(u=c>.5?e/(2-i-f):e/(i+f),i){case r:a=(t-n)/e+(t<n?6:0);break;case t:a=(n-r)/e+2;break;case n:a=(r-t)/e+4}a/=6}a=Math.round(360*a*100)/100,u=Math.round(100*u*100)/100+"%",c=Math.round(100*c*100)/100+"%";const s=[a,u,c];return o&&s.push(o),`hsl${o?"a":""}(${s.join(", ")})`}function kr(e){return Dr(Sr(e))}function jr(e){if(!Mr(e))throw new Error("Expected a valid rgb color string");const r=e.trim().replace(/^rgba?\((.*)\)$/,"$1").split(","),t=r.slice(0,3).map(e=>Number(e).toString(16).padStart(2,"0"));return 4===r.length&&t.push(Math.ceil(255*Number.parseFloat(r[3])).toString(16)),`#${t.join("")}`}function Or(e){return"string"==typeof e&&/^hsl\(\s*(\d{1,3}(?:\.\d+)?)\s*,\s*(\d{1,3}(?:\.\d+)?)%\s*,\s*(\d{1,3}(?:\.\d+)?)%\s*\)$|^hsla\(\s*(\d{1,3}(?:\.\d+)?)\s*,\s*(\d{1,3}(?:\.\d+)?)%\s*,\s*(\d{1,3}(?:\.\d+)?)%\s*,\s*(?:0(?:\.\d+)?|1(?:\.0+)?)\s*\)$/i.test(e)}function zr(e){if(!Or(e))throw new Error("Expected a valid hsl color");let[r,t,n,o]=e.trim().replace(/^hsla?\((.*)\)$/,"$1").replace(/%/g,"").split(",");r%=360,t/=100,n/=100;const i=(1-Math.abs(2*n-1))*t,f=i*(1-Math.abs(r/60%2-1)),a=n-i/2;let u=0,c=0,s=0;0<=r&&r<60?(u=i,c=f):60<=r&&r<120?(u=f,c=i):120<=r&&r<180?(c=i,s=f):180<=r&&r<240?(c=f,s=i):240<=r&&r<300?(u=f,s=i):300<=r&&r<360&&(u=i,s=f),u=Math.round(255*(u+a)),c=Math.round(255*(c+a)),s=Math.round(255*(s+a));const p=[u,c,s];return o&&p.push(o),`rgb${o?"a":""}(${p.join(", ")})`}function Nr(e){return jr(zr(e))}function Ir(...e){if(!e.every(e=>"number"==typeof e))throw new TypeError("Expected an array of numbers for 'values'");return e.reduce((e,r)=>e+r,0)}function Lr(e,r,t){if("number"!=typeof e)throw new TypeError("Expected a number for 'value'");if("number"!=typeof r)throw new TypeError("Expected a number for 'min'");if("number"!=typeof t)throw new TypeError("Expected a number for 'max'");if(r>t)throw new RangeError("Expected 'min' to be less than or equal to 'max'");return e>=t?t:e<=r?r:e}function Rr(e,r){if("number"!=typeof e||"number"!=typeof r)throw new TypeError("Expected a number for 'dividend' and 'divisor'");if(0===r)throw new Error("Cannot divide by zero.");return e/r}function Ur(e){if("number"!=typeof e||!Number.isInteger(e)||e<0)throw new TypeError("Expected a non-negative integer for 'value'");let r=1;for(let t=e;t>=1;t--)r*=t;return r}function Cr(e){if("number"!=typeof e||!Number.isInteger(e)||e<0)throw new TypeError("Expected a non-negative integer for 'num'");return e<=1?e:Cr(e-1)+Cr(e-2)}function Br(e){if(!Array.isArray(e))throw new TypeError("Expected an array for 'arr'");return e.reduce((e,r)=>(e[String(r)]=(e[String(r)]||0)+1,e),{})}function Pr(e,r,t){if("number"!=typeof e)throw new TypeError("Expected a number for 'start'");if("number"!=typeof r)throw new TypeError("Expected a number for 'end'");if("number"!=typeof t)throw new TypeError("Expected a number for 'amount'");return e+(r-e)*t}function Wr(e){if(!Array.isArray(e)||!e.every(e=>"number"==typeof e))throw new TypeError("Expected an array of numbers for 'values'");return e.length?Ir(...e)/e.length:0}function qr(e){if(!Array.isArray(e)||!e.every(e=>"number"==typeof e))throw new TypeError("Expected an array of numbers for 'arr'");if(0===e.length)throw new Error("Input array cannot be empty.");const r=[...e].sort((e,r)=>e-r),t=Math.floor(r.length/2);return r.length%2==0?(r[t-1]+r[t])/2:r[t]}function Zr(e,r){if("number"!=typeof e||"number"!=typeof r)throw new TypeError("Expected a number for 'dividend' and 'divisor'");if(0===r)throw new Error("Cannot calculate modulo with zero divisor.");return(e%r+r)%r}function _r(e){if(!Array.isArray(e)||!e.every(e=>"number"==typeof e))throw new TypeError("Expected an array of numbers for 'arr'");if(0===e.length)return[];const r=new Map;let t=0;for(const n of e){const e=(r.get(n)||0)+1;r.set(n,e),e>t&&(t=e)}const n=[];for(const[e,o]of r.entries())o===t&&n.push(e);return n.sort((e,r)=>e-r)}function Hr(...e){if(!e.every(e=>"number"==typeof e))throw new TypeError("Expected an array of numbers for 'values'");return e.reduce((e,r)=>e*r,1)}function Yr(e,r){if("number"!=typeof e||"number"!=typeof r)throw new TypeError("Expected a number for 'base' and 'exponent'");return Math.pow(e,r)}function Gr(e=0,r=10){if("number"!=typeof e)throw new TypeError("Expected a number for 'min'");if("number"!=typeof r)throw new TypeError("Expected a number for 'max'");if(e>r)throw new RangeError(`Expected 'min' (${e}) to be less than or equal to 'max' (${r})`);return Math.floor(Math.random()*(r-e+1)+e)}function Vr(e,r=0){if("number"!=typeof e)throw new TypeError("Expected a number for 'value'");if("number"!=typeof r)throw new TypeError("Expected a number for 'precision'");if(!Number.isInteger(r)||r<0)throw new TypeError("Expected a non-negative integer for 'precision'");const t=10**r;return Math.round(e*t)/t}function Kr(e){if(!Array.isArray(e))throw new TypeError("Expect an array for 'arr'");if(e.length<2)throw new Error("Array must contain at least two values.");const r=e.filter(e=>"number"==typeof e&&!isNaN(e));if(r.length<2)throw new Error("Input array must contain at least two numeric values.");const t=r.length,n=r.reduce((e,r)=>e+r,0)/t,o=r.reduce((e,r)=>e+Math.pow(r-n,2),0);return Math.sqrt(o/(t-1))}function Jr(...e){if(0===e.length||!e.every(e=>"number"==typeof e))throw new TypeError("Expected an array of numbers for 'values'");return e.slice(1).reduce((e,r)=>e-r,e[0])}function Qr(e){if(!Array.isArray(e))throw new TypeError("Expect an array for 'arr'");if(e.length<2)throw new Error("Input array must contain at least two values.");const r=e.filter(e=>"number"==typeof e&&!isNaN(e));if(r.length<2)throw new Error("Input array must contain at least two numeric values.");const t=r.length,n=r.reduce((e,r)=>e+r,0)/t;return r.reduce((e,r)=>e+Math.pow(r-n,2),0)/(t-1)}function Xr(e="rgb",r){if("string"!=typeof e||!["hex","rgb","hsl"].includes(e))throw new Error('Expected "hex", "rgb", or "hsl" for \'format\'');const t=Gr(0,255),n=Gr(0,255),o=Gr(0,255),i=r?Gr(0,10)/10:void 0,f=`rgb${r?"a":""}(${t}, ${n}, ${o}${r?`,${i}`:""})`;return"hsl"===e?Dr(f):"hex"===e?jr(f):f}function et(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'value'");return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}function rt(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'value'");return/^[A-Za-z0-9_-]+$/.test(e)}function tt(e,r=!1){if(r){if(!rt(e))throw new Error("Expected a valid base64url string for 'input'")}else if(!et(e))throw new Error("Expected a valid base64 string for 'input'");let t=e;if(r){t=t.replace(/-/g,"+").replace(/_/g,"/");const e=t.length%4;0!==e&&(t+="=".repeat(4-e))}if("undefined"!=typeof Buffer&&"function"==typeof Buffer.from)return new Uint8Array(Buffer.from(t,"base64"));if("function"==typeof atob){const e=atob(t),r=new Uint8Array(e.length);for(let t=0;t<e.length;t++)r[t]=e.charCodeAt(t);return r}throw new Error("No base64 decoder available in this environment")}function nt(e){return re(e)&&"[object Uint8Array]"===Object.prototype.toString.call(e)}function ot(e,r=!1){const t=nt(e)?e:new Uint8Array(e);let n;if("undefined"!=typeof Buffer&&"function"==typeof Buffer.from)n=Buffer.from(t).toString("base64");else{if("function"!=typeof btoa)throw new Error("No base64 encoder available in this environment");n=btoa(String.fromCharCode(...t))}return r&&(n=n.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")),n}function it(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'str'");let r=5381;for(let t=0;t<e.length;t++)r=(r<<5)+r+e.charCodeAt(t);return r>>>0}function ft(e=16){if(e<=0)throw new Error("Expected positive multiple of 8 for 'length'");const r=new Uint8Array(e);return crypto.getRandomValues(r),r}function at(){return crypto.randomUUID()}function ut(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'value'");return/^[A-Fa-f0-9]+$/.test(e)}function ct(e){if(!ut(e)||e.length%2!=0)throw new Error("Invalid hex string");const r=new Uint8Array(e.length/2);for(let t=0;t<e.length;t+=2)r[t/2]=parseInt(e.slice(t,t+2),16);return r}function st(e){const r=nt(e)?e:new Uint8Array(e);return Array.from(r).map(e=>e.toString(16).padStart(2,"0")).join("")}function pt(e){return re(e)&&"[object ArrayBuffer]"===Object.prototype.toString.call(e)}function lt(e,r="SHA-256"){if("string"!=typeof e)throw new TypeError("Expected a string for 'hash'");if(!/^[0-9a-fA-F]+$/.test(e))return!1;switch(r){case"SHA-1":return 40===e.length;case"SHA-256":return 64===e.length;case"SHA-384":return 96===e.length;case"SHA-512":return 128===e.length;default:throw new Error("Expected a valid hash algorithm for 'algorithm'")}}function yt(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'value', but received "+typeof e);return/^[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}$/.test(e)}function dt(e){const r=nt(e)?e:new Uint8Array(e);if("undefined"!=typeof TextDecoder)return new TextDecoder("utf-8").decode(r);if("undefined"!=typeof Buffer)return Buffer.from(r).toString("utf8");throw new Error("No UTF-8 decoder available in this environment")}function wt(e){if(!N(e))throw new TypeError("Expected a string for 'input'");let r=e;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(r);if("undefined"!=typeof Buffer)return new Uint8Array(Buffer.from(r,"utf8"));throw new Error("No UTF-8 encoder available in this environment")}function ht(e){return v(e)&&!o(e.getTime())}function Et(e,r){if(!ht(e))throw new TypeError("Expected a valid Date, string, or number for 'date'");if(r.years&&e.setFullYear(e.getFullYear()+r.years),r.months){const o=e.getDate();e.setMonth(e.getMonth()+r.months,1);const i=(t=e.getFullYear(),n=e.getMonth(),new Date(t,n+1,0).getDate());e.setDate(Math.min(o,i))}var t,n;return r.days&&e.setDate(e.getDate()+r.days),r.hours&&e.setHours(e.getHours()+r.hours),r.minutes&&e.setMinutes(e.getMinutes()+r.minutes),r.seconds&&e.setSeconds(e.getSeconds()+r.seconds),r.milliseconds&&e.setMilliseconds(e.getMilliseconds()+r.milliseconds),e}function gt(e,r){if(!ht(e))throw new TypeError("Expected a valid date for 'date'");const t=60*r-e.getTimezoneOffset();return new Date(e.getTime()+60*t*1e3)}function mt(e,r="iso"){if(!ht(e))throw new TypeError("Expected a valid Date for 'date'");return"timestamp"===r?e.getTime():"utc"===r?e.toUTCString():"iso"===r?e.toISOString():e.toString()}function bt(e,r,t){if("number"!=typeof e)throw new TypeError("Expected a number for 'time'");if("string"!=typeof r)throw new TypeError("Expected a string for 'from'");if("string"!=typeof t)throw new TypeError("Expected a string for 'to'");const n={milliseconds:1,seconds:1e3,minutes:6e4,hours:36e5,days:864e5,years:31536e6},o=e*n[r];return Math.floor(o/n[t])}function xt(e,r=new Date,t){if(!ht(e))throw new TypeError("Expected a valid Date for 'from'");if(!ht(r))throw new TypeError("Expected a valid Date for 'to'");const n=Math.abs(r.getTime()-e.getTime());switch(t){case"years":return Math.floor(n/31536e6);case"days":return Math.floor(n/864e5);case"hours":return Math.floor(n/36e5);case"minutes":return Math.floor(n/6e4);case"seconds":return Math.floor(n/1e3);case"milliseconds":return n;default:throw new TypeError(`Invalid time unit: ${t}`)}}function Tt(e,r,t="/"){if(!ht(e))throw new TypeError("Expected a valid Date for 'date'");const n=e.getDate().toString().padStart(2,"0"),o=(e.getMonth()+1).toString().padStart(2,"0"),i=e.getFullYear();switch(r){case"DMY":return`${n}${t}${o}${t}${i}`;case"MDY":return`${o}${t}${n}${t}${i}`;case"YMD":return`${i}${t}${o}${t}${n}`;default:throw new TypeError("Expected a string for 'format'")}}function vt(e,r="hh:mm:ss",t=!0){if("number"!=typeof e)throw new TypeError("Expected a number for 'ms'");if("string"!=typeof r)throw new TypeError("Expected a string for 'format'");const n=String(Math.floor(e/36e5)),o=String(Math.floor(e%36e5/6e4)).padStart(2,"0"),i=String(Math.floor(e%6e4/1e3)).padStart(2,"0"),f=String(e%1e3).padStart(3,"0");let a=r.toLowerCase();return t&&"0"===n&&(a=a.slice(a.indexOf("mm"))),a.replace("hh",n).replace("mm",o).replace("ss",i).replace("ms",f)}function At(e,r="hh:mm"){if(!ht(e))throw new TypeError("Expected a valid Date for 'date'");const t=-1!==r.search("a"),n=String(t?e.getHours()%12||12:e.getHours()),o=String(e.getMinutes()).padStart(2,"0"),i=String(e.getSeconds()).padStart(2,"0"),f=String(e.getMilliseconds()).padStart(3,"0"),a=e.getHours()>=12?"PM":"AM";return r.toLowerCase().replace("hh",n).replace("mm",o).replace("ss",i).replace("ms",f).replace("a",a)}function Ft(e,r,t,n=!0){if(!ht(e))throw new TypeError("Expected a valid Date for 'date'");if(!ht(r))throw new TypeError("Expected a valid Date for 'start'");if(!ht(t))throw new TypeError("Expected a valid Date for 'end'");return n?e.getTime()>=r.getTime()&&e.getTime()<=t.getTime():e.getTime()>r.getTime()&&e.getTime()<t.getTime()}function St(e){return(e=Number(e))%4==0&&(e%100!=0||e%400==0)}function $t(e,r){if(!ht(e))throw new TypeError("Expected valid Date for 'date1'");if(!ht(r))throw new TypeError("Expected valid Date for 'date2'");return e.getFullYear()===r.getFullYear()&&e.getMonth()===r.getMonth()&&e.getDate()===r.getDate()}function Mt(e){if(!ht(e))throw new TypeError("Expected a valid Date for 'date'");return $t(e,new Date)}function Dt(e){if(!ht(e))throw new TypeError("Expected a valid Date for 'date'");const r=new Date;return r.setDate(r.getDate()+1),$t(e,r)}function kt(e){if("string"!=typeof e)throw new TypeError("Expected a datestring for 'date'");return!isNaN(new Date(e).getTime())}function jt(e){if(!ht(e))throw new TypeError("Expected a valid Date for 'date'");const r=e.getDay();return 0!==r&&6!==r}function Ot(e){if(!ht(e))throw new TypeError("Expected a valid Date for 'date'");const r=e.getDay();return 0===r||6===r}function zt(e){if(!ht(e))throw new TypeError("Expected a valid Date for 'date'");const r=new Date;return r.setDate(r.getDate()-1),$t(e,r)}function Nt(e){return v(e)?new Date(e.getTime()):"string"==typeof e||"number"==typeof e?new Date(e):new Date(NaN)}function It(e){const r=Nt(e);if(!ht(r))throw new TypeError("Expected a valid Date for 'date'");return r}function Lt(e){if(!ht(e))throw new TypeError("Expected a valid Date for 'date'");return e.setHours(0,0,0,0),e}function Rt(e){return class r extends Error{constructor(t,n){super(t,n),this.name=e,"captureStackTrace"in Error&&Error.captureStackTrace(this,r)}}}function Ut(e){return"undefined"!=typeof AggregateError&&e instanceof AggregateError}function Ct(e){return e instanceof DOMException}function Bt(e){return D(e)&&"string"==typeof e.name&&"string"==typeof e.message}function Pt(e){return e instanceof EvalError}function Wt(e){return e instanceof RangeError}function qt(e){return e instanceof ReferenceError}function Zt(e){return e instanceof SyntaxError}function _t(e){return e instanceof TypeError}function Ht(e){return e instanceof URIError}async function Yt(e){if("number"!=typeof e)throw new TypeError("Expected a non-negative number for 'timeout'");return new Promise(r=>setTimeout(()=>r(),e))}const Gt="exponential",Vt=500,Kt="full",Jt=5,Qt=6e4;async function Xt(e,{initialDelay:r=Vt,backoffMode:t=Gt,jitterMode:n=Kt,maxAttempts:o=Jt,maxDelay:i=Qt,onRetry:f}={}){if("function"!=typeof e)throw new Error("Expected a function for 'action'");if(r<=0)throw new Error("Expected a positive number for 'initialDelay'");if(o<=0)throw new Error("Expected a positive number for 'maxAttempts'");if(i<=0)throw new Error("Expected a positive number for 'maxDelay'");let a=r;const u=function(e){switch(e){case"fixed":return()=>r;case"linear":return e=>r*e;case"exponential":return e=>r*2**(e-1);default:throw new Error(`Invalid backoff mode: ${e}`)}}(t),c=function(e,r,t){switch(e){case"none":return e=>Math.min(e,t);case"full":return e=>Math.random()*Math.min(e,t);case"equal":return e=>{const r=Math.min(e,t);return r/2+Math.random()*r/2};case"decorrelated":return(e,n)=>Math.min(r+Math.random()*(3*n-r),t);default:throw new Error(`Invalid jitter mode: ${e}`)}}(n,r,i);for(let r=1;r<=o;r++)try{return await e()}catch(e){if(r===o)throw e;a=c(u(r),a),f?.(r,a),await Yt(a)}}async function en(e,r=1){if("function"!=typeof e)throw new TypeError("Expected a function for 'callback'");if("number"!=typeof r||r<1)throw new TypeError("Expected a number greater than 0 for 'iterations'");const t=[];for(let n=0;n<r;n++){const r=performance.now();await e();const n=performance.now();t.push(n-r)}return Wr(t)}function rn(e,r=300,t={}){const{leading:n=!1,trailing:o=!0,maxWait:i}=t;if(!n&&!o)throw new Error("debounce: 'leading' and 'trailing' cannot both be false.");let f=null,a=null,u=null;function c(r){u=r,e(...a),a=null}function s(...e){const t=performance.now();a=e;(n&&!f||null!=i&&(null===u?1/0:t-u)>=i)&&(f&&(clearTimeout(f),f=null),c(t)),f&&clearTimeout(f),f=setTimeout(()=>{f=null,o&&a&&c(performance.now())},r)}return s.cancel=()=>{f&&(clearTimeout(f),f=null),a=null},s.flush=()=>{f&&a&&(clearTimeout(f),f=null,c(performance.now()))},s}function tn(e){if("function"!=typeof e)throw new TypeError("Expected a function for 'callback'");setTimeout(e,1)}function nn(e,r={queue:!0}){let t=!1;const n=[],o=async()=>{if(0===n.length)return void(t=!1);const e=n.shift();try{await e()}catch(e){throw r.onError?.(e),e}await o()};return async(...i)=>{if(t){if(r.onLocked&&await r.onLocked(),!r.queue)return;return new Promise((r,t)=>{n.push(async()=>{try{r(await e(...i))}catch(e){t(e)}})})}t=!0;try{return await e(...i)}catch(e){throw r.onError?.(e),e}finally{await o()}}}async function on(...e){if(!e.every(e=>"function"==typeof e))throw new TypeError("Expect an array of functions for 'callbacks'");return Promise.all(e.map(e=>e()))}function fn(e,r,t){if("function"!=typeof e)throw new TypeError("Expected a function for 'callback'");let n=0;if("number"!=typeof r||r<=0)throw new TypeError("Expected 'limit' to be a positive number");if("number"!=typeof t||t<=0)throw new TypeError("Expected 'interval' to be a positive number");return(...o)=>n<r&&(0===n&&setTimeout(()=>{n=0},t),n++,e(...o),!0)}function an(e,r){if("function"!=typeof e)throw new TypeError("Expected a function for 'callback'");if("number"!=typeof r||!Number.isInteger(r)||r<1)throw new TypeError("The 'attempts' parameter must be a positive integer. Received: "+typeof r);for(let t=0;t<r;t++)try{return e()}catch(e){if(t===r-1)throw new Error(`Function failed after ${r} attempts: ${e.message}`)}throw new Error("Unexpected error: retry loop completed without success or final throw.")}function un(e,r,{leading:t=!0,trailing:n=!0,maxWait:o}={}){if("function"!=typeof e)throw new TypeError("Expected a function for 'callback'");let i=null,f=null,a=null,u=0;const c=()=>performance.now();function s(r){u=r,e(...f),f=null}function p(e,r){return setTimeout(e,r)}function l(e){i=null,n&&f&&s(e)}function y(...e){const y=c();var d;null===a&&(a=y),f=e,d=y,null===a||d-a>=r||void 0!==o&&d-u>=o?null===i?t?s(y):n&&(i=p(()=>l(c()),r)):void 0!==o&&y-u>=o&&s(y):null===i&&n&&(i=p(()=>l(c()),function(e){const t=r-(e-(a??0)),n=void 0!==o?o-(e-u):1/0;return Math.min(t,n)}(y))),a=y}return y.cancel=()=>{null!==i&&(clearTimeout(i),i=null),f=null,a=null},y.flush=()=>{null!==i&&f&&(clearTimeout(i),i=null,l(c()))},y}function cn(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'value'");return/^\p{L}+$/u.test(e)}function sn(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'value'");return/^[a-zA-Z0-9]+$/.test(e)}function pn(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'value'");return/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(e)}function ln(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'value'");return/^(https?:\/\/)?(www\.)?([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})(:[0-9]{1,5})?(\/[a-zA-Z0-9._~:/?#[\]@!$&'()*+,;=-]*)?$/.test(e)}function yn(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'value'");return/^(?:4[0-9]{12}(?:[0-9]{3})?|[25][1-7][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$/.test(e)}function dn(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'value'");return/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e)}function wn(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'value'");return/^((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])(?::(?:[0-9]|[1-9][0-9]{1,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))?$/.test(e)}function hn(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'value'");return/^(?:(?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))|\[(?:(?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))\](?::(?:[0-9]|[1-9][0-9]{1,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))?$/i.test(e)}function En(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'value'");return/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(e)}function gn(e,r){if("string"!=typeof e)throw new TypeError("Expected a string for 'fileName'");if("string"!=typeof r&&!Array.isArray(r))throw new TypeError("Expected a string or array for 'extensions'");if(""===e.trim())return!1;const t=e.trim().split(".").pop()?.toLowerCase();return!!t&&(Array.isArray(r)?r.some(e=>t===e.toLowerCase().replace(/^\./,"")):"string"==typeof r&&t===r.toLowerCase().replace(/^\./,""))}function mn(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'str'");return e.charAt(0).toUpperCase().concat(e.slice(1).toLowerCase())}function bn(e,r){if("string"!=typeof e)throw new TypeError("Expected a string for 'str'");if("string"!=typeof r||1!==r.length)throw new TypeError("Expected a single character string for 'char'");let t=0;for(let n=0;n<e.length;n++)e[n]===r&&t++;return t}function xn(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'str'");return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Tn(e,r,t=/{{(.*?)}}/g){if("string"!=typeof e)throw new TypeError("Expected a string for 'str'");return e.replace(t,(e,t)=>{const n=t.trim(),o=r[n];return $(o)?e:String(o)})}function vn(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'str'");return/^(?!.*[A-Z]).*[a-z].*$/.test(e.replace(/\s+/g,""))}function An(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'str'");return/^(?!.*[a-z]).*[A-Z].*$/.test(e.replace(/\s+/g,""))}function Fn(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'str'");return e.split("").map(e=>vn(e)?e.toUpperCase():An(e)?e.toLowerCase():e).join("")}function Sn(e,r,t,n){if("string"!=typeof e)throw new TypeError("Expected a string for 'str'");if("string"!=typeof r)throw new TypeError("Expected a string for 'mask'");if("number"!=typeof t)throw new TypeError("Expected a number for 'maskStart'");if(t<0)throw new RangeError("'maskStart' must be >= 0");if("number"!=typeof n)throw new TypeError("Expected a number for 'maskLength'");if(n<0)throw new RangeError("'maskLength' must be >= 0");if(t>e.length)throw new RangeError("'maskStart' cannot be greater than 'maskLength'");n=Math.min(n,e.length-t);const o=e.slice(0,t),i=e.slice(t+n);return o+r.repeat(n)+i}function $n(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'str'");return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")}function Mn(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'str'");return e.trim().replace(/[!@#$%^&*()\-=+[\]{}|\\~;:'",.<>?\/]/g,"").toLowerCase().replace(/\s+/g,"-").normalize("NFD").replace(/[\u0300-\u036f]/g,"")}function Dn(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'html'");return e.replace(/<[^>]*>/g,"")}function kn(e,r){if("string"!=typeof e)throw new TypeError("Expected a string for 'str'");const{pattern:t,escape:n}={pattern:/{{(.*?)}}/g,...r};if(!O(t))throw new TypeError("Expected a RegExp for 'pattern'");if(n&&!g(n))throw new TypeError("Expected a function for 'escape'");return r=>{if(!D(r))throw new TypeError("Expected a plain object for 'data'");let o={...r};if(n)for(const[e,t]of Object.entries(r))o[e]=n(String(t),e);return Tn(e,o,t)}}function jn(e){if("string"!=typeof e)throw new TypeError("Expected a string, but received "+typeof e);const r=e.trim().toLowerCase().split(" ");return r.shift()+r.map(e=>e[0].toUpperCase().concat(e.slice(1))).join("")}function On(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'str'");return e.trim().toLowerCase().replace(/\s+/g,"-")}function zn(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'str'");return e.trim().split(" ").map(e=>e[0].toUpperCase().concat(e.slice(1))).join(" ").replace(/\s+/g,"")}function Nn(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'str'");return e.trim().toLowerCase().replace(/\s+/g,"_")}function In(e,r){if("string"!=typeof e)throw new TypeError("Expected a string for 'text'");return e.slice(0,r).concat("...")}function Ln(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'str'");return e.trim().split(/\s+/).filter(Boolean).length}export{Ir as add,B as adjust,Et as adjustDate,gt as adjustTimezone,P as after,W as aperture,q as append,Z as arrayToObject,Xt as backoff,tt as base64Decode,ot as base64Encode,_ as before,en as benchmark,mn as capitalize,bn as charCount,H as chunk,Lr as clamp,Q as clone,G as collectBy,V as compact,Te as compose,mt as convertDateTo,bt as convertTimeUnit,K as count,Rt as customError,J as cycle,rn as debounce,tn as defer,he as difference,Rr as divide,r as divisors,it as djb2,xt as elapsedTime,_e as equalsEnv,xn as escapeHtml,cr as exitFullscreen,Ur as factorial,Cr as fibonacci,Ee as first,me as flat,ge as flatMap,ee as flattenObj,Tt as formatDate,vt as formatDuration,At as formatTime,te as freeze,Br as frequency,ft as generateNonce,at as generateUUID,ne as get,Ze as getEnv,e as getInstanceType,sr as getLanguage,Ye as getOS,Je as getRuntime,pr as getTheme,E as getType,Y as groupBy,oe as has,Qe as hasEnv,ct as hexDecode,st as hexEncode,kr as hexToHsl,Sr as hexToRgb,Nr as hslToHex,zr as hslToRgb,ve as identity,t as inRange,we as includes,Tn as interpolate,Fn as invertCase,Ut as isAggregateError,cn as isAlpha,sn as isAlphanumeric,w as isArray,pt as isArrayBuffer,m as isAsyncFunction,b as isAsyncGeneratorFunction,et as isBase64,rt as isBase64URL,Ft as isBetween,x as isBigint,T as isBoolean,Ge as isBrowser,Ve as isBun,lr as isCookieEnabled,yn as isCreditCard,Ct as isDOMException,v as isDate,Xe as isDedicatedWorker,qe as isDeno,er as isDev,pn as isEmail,ie as isEqual,Bt as isError,Pt as isEvalError,n as isEven,A as isFalsy,gn as isFileExtension,i as isFinite,f as isFloat,fe as isFrozen,ur as isFullscreenEnabled,g as isFunction,F as isGeneratorFunction,lt as isHash,ut as isHex,Fr as isHexColor,Or as isHslColor,wn as isIPV4,hn as isIPV6,a as isInfinity,u as isInteger,be as isIterable,En as isJWT,St as isLeapYear,vn as isLowerCase,S as isMap,rr as isMobile,o as isNaN,c as isNegative,$ as isNil,Ke as isNode,re as isNotNullObject,h as isNull,M as isNumber,D as isObject,s as isOdd,yr as isOnline,X as isPlainObject,p as isPositive,l as isPrime,k as isPrimitive,tr as isProd,j as isPromise,Wt as isRangeError,qt as isReferenceError,O as isRegExp,Mr as isRgbColor,$t as isSameDay,ae as isSealed,He as isServer,nr as isServiceWorker,z as isSet,dr as isShareable,or as isSharedWorker,dn as isSlug,N as isString,I as isSymbol,Zt as isSyntaxError,wr as isTabActive,ir as isTest,Mt as isToday,Dt as isTomorrow,hr as isTouchDevice,_t as isTypeError,Ht as isURIError,ln as isURL,yt as isUUID,nt as isUint8Array,L as isUndefined,An as isUpperCase,ht as isValidDate,kt as isValidDateString,R as isWeakMap,C as isWeakRef,U as isWeakSet,fr as isWebWorker,jt as isWeekday,Ot as isWeekend,zt as isYesterday,xe as last,Pr as lerp,nn as lock,Sn as maskString,Wr as mean,qr as media