@react-hive/honey-utils 3.31.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- const e=e=>new Blob([e],{type:e.type}),t=e=>new DOMRect(e.offsetLeft,e.offsetTop,e.clientWidth,e.clientHeight),n=e=>"A"===e.tagName,r=e=>"true"===e.getAttribute("contenteditable"),a=["INPUT","SELECT","TEXTAREA","BUTTON","A"],l=e=>{if(!e)return!1;const t=window.getComputedStyle(e);if("hidden"===t.visibility||"none"===t.display)return!1;if("disabled"in e&&e.disabled)return!1;const l=e.getAttribute("tabindex");return"-1"!==l&&(a.includes(e.tagName)?!n(e)||""!==e.href:!!r(e)||null!==l)},i=e=>Array.from(e.querySelectorAll("*")).filter(l),o=(e,t=null,{wrap:n=!0,getNextIndex:r}={})=>{const a=document.activeElement,l=t??a?.parentElement;if(!a||!l)return;const o=i(l);if(0===o.length)return;const s=o.indexOf(a);if(-1===s)return;let c;r?c=r(s,e,o):"next"===e?(c=s+1,c>=o.length&&(c=n?0:null)):(c=s-1,c<0&&(c=n?o.length-1:null)),null!==c&&o[c]?.focus()},s=(...e)=>t=>e.reduce((e,t)=>t(e),t),c=(...e)=>t=>e.reduceRight((e,t)=>t(e),t),u=(e,t)=>e.filter(e=>!t.includes(e)),h=e=>[...new Set(e)],f=(...e)=>{if(0===e.length)return[];if(1===e.length)return[...e[0]];const[t,...n]=e;return h(t).filter(e=>n.every(t=>t.includes(e)))};function d(e,t){if(!e)throw new Error(t)}const m=e=>null===e,p=e=>null==e,g=e=>null!=e,y=e=>void 0===e,w=e=>"number"==typeof e,b=e=>"boolean"==typeof e,x=e=>"object"==typeof e,A=e=>x(e)&&!m(e)&&0===Object.keys(e).length,M=e=>e instanceof Date,v=e=>e instanceof Blob,I=e=>e instanceof Error,S=e=>M(e)&&!isNaN(e.getTime()),C=e=>e instanceof RegExp,k=e=>e instanceof Map,E=e=>e instanceof Set,O=e=>"symbol"==typeof e,L=e=>w(e)&&isFinite(e),P=e=>w(e)&&Number.isInteger(e),T=e=>L(e)&&!Number.isInteger(e),X=(e,t)=>(d(t>0,"Chunk size must be greater than 0"),Array.from({length:Math.ceil(e.length/t)},(n,r)=>e.slice(r*t,(r+1)*t))),$=e=>e.filter(Boolean),_=e=>Array.isArray(e),N=e=>_(e)&&0===e.length,Y=(e,t,n)=>{if(!e?.length||!t)return{previousItem:null,currentItem:null,nextItem:null};const r=e.findIndex(e=>n(e,t));return-1===r?{previousItem:null,currentItem:null,nextItem:null}:{previousItem:r>0?e[r-1]:null,currentItem:e[r],nextItem:r<e.length-1?e[r+1]:null}},F=()=>{},R=e=>"function"==typeof e,j=e=>(...t)=>!e(...t),z=e=>{let t,n=!1;return function(...r){return n||(n=!0,t=e.apply(this,r)),t}},U=e=>R(e?.then),W=async(e,t)=>{const n=[];for(let r=0;r<e.length;r++)n.push(await t(e[r],r,e));return n},D=async(e,t)=>Promise.all(e.map(t)),H=async(e,t)=>{const n=[];for(let r=0;r<e.length;r++){const a=e[r];await t(a,r,e)&&n.push(a)}return n},B=async(e,t)=>{const n=await D(e,async(e,n,r)=>!!await t(e,n,r)&&e);return $(n)},V=async(e,t)=>{for(let n=0;n<e.length;n++)if(await t(e[n],n,e))return!0;return!1},Z=async(e,t)=>{for(let n=0;n<e.length;n++)if(!await t(e[n],n,e))return!1;return!0},G=async(e,t,n)=>{let r=n;for(let n=0;n<e.length;n++)r=await t(r,e[n],n,e);return r},J=async(e,t)=>{for(let n=0;n<e.length;n++)if(await t(e[n],n,e))return e[n];return null},q=e=>new Promise(t=>setTimeout(t,e)),K=async(e,t,n="Operation timed out")=>{try{return await Promise.race([e,q(t).then(()=>Promise.reject(new Error(n)))])}finally{}},Q=(e,{maxAttempts:t=3,delayMs:n=300,backoff:r=!0,onRetry:a}={})=>async(...l)=>{let i;for(let o=1;o<=t;o++)try{return await e(...l)}catch(e){if(i=e,o<t){a?.(o,e);const t=r?n*2**(o-1):n;await q(t)}}throw i},ee="application/json",te=(e,t)=>{e.setData(ee,JSON.stringify(t))},ne=e=>{const t=e.getData(ee);if(t)try{return JSON.parse(t)}catch{return}},re=e=>"string"==typeof e,ae=(e,{fileName:t,target:n}={})=>{if(y(document))return;const r=document.createElement("a");let a=null;try{const l=re(e)?e:a=URL.createObjectURL(e);r.href=l,t&&(r.download=t),n&&(r.target=n),document.body.appendChild(r),r.click()}finally{r.remove(),a&&setTimeout(()=>{d(a,"Object URL should not be null"),URL.revokeObjectURL(a)},0)}},le=e=>e.scrollWidth>e.clientWidth,ie=e=>Math.max(0,e.scrollWidth-e.clientWidth),oe=e=>e.scrollHeight>e.clientHeight,se=e=>Math.max(0,e.scrollHeight-e.clientHeight),ce=({containerSize:e,elementOffset:t,elementSize:n})=>-(t+n/2-e/2),ue=(e,t)=>t<=0?0:Math.max(-t,Math.min(e,0)),he=(e,t,{axis:n="both",shouldClamp:r=!0}={})=>{let a=0,l=0;if("x"===n||"both"===n){const n=ce({containerSize:e.clientWidth,elementOffset:t.offsetLeft,elementSize:t.clientWidth});a=r?ue(n,ie(e)):n}if("y"===n||"both"===n){const n=ce({containerSize:e.clientHeight,elementOffset:t.offsetTop,elementSize:t.clientHeight});l=r?ue(n,se(e)):n}e.style.transform=`translate(${a}px, ${l}px)`},fe=e=>{const t=window.getComputedStyle(e).getPropertyValue("transform").match(/^matrix\((.+)\)$/);if(!t)return{translateX:0,translateY:0,scaleX:1,scaleY:1,skewX:0,skewY:0};const[n,r,a,l,i,o]=t[1].split(", ").map(parseFloat);return{translateX:i,translateY:o,scaleX:n,scaleY:l,skewX:a,skewY:r}},de=()=>{if("undefined"==typeof window||!window.localStorage)return!1;try{return window.localStorage.getItem("__non_existing_key__"),!0}catch{return!1}},me=()=>{if(!de())return{readable:!1,writable:!1};try{const e="__test_write__";return window.localStorage.setItem(e,"1"),window.localStorage.removeItem(e),{readable:!0,writable:!0}}catch{}return{readable:!0,writable:!1}},pe=e=>e instanceof File,ge=e=>{if(!e)return[];const t=[];for(let n=0;n<e.length;n++)t.push(e[n]);return t},ye=(e,t)=>new File([e],t,{type:e.type}),we=async(e,{skipFiles:t=[".DS_Store","Thumbs.db","desktop.ini","ehthumbs.db",".Spotlight-V100",".Trashes",".fseventsd","__MACOSX"]}={})=>{const n=new Set(t),r=await(async e=>{const t=e.createReader(),n=async()=>new Promise((e,r)=>{t.readEntries(async t=>{if(t.length)try{const r=await n();e([...t,...r])}catch(e){r(e)}else e([])},r)});return n()})(e);return(await D(r,async e=>e.isDirectory?we(e,{skipFiles:t}):n.has(e.name)?[]:[await new Promise((t,n)=>{e.file(t,n)})])).flat()},be=async(e,t={})=>{const n=e?.items;if(!n)return[];const r=[];for(let e=0;e<n.length;e++){const a=n[e];if("webkitGetAsEntry"in a){const e=a.webkitGetAsEntry?.();if(e?.isDirectory){r.push(we(e,t));continue}if(e?.isFile){r.push(new Promise((t,n)=>e.file(e=>t([e]),n)));continue}}const l=a.getAsFile();l&&r.push(Promise.resolve([l]))}return(await Promise.all(r)).flat()},xe=(e,...t)=>"function"==typeof e?e(...t):e,Ae=({delta:e,value:t,min:n,max:r})=>{if(0===e)return null;const a=t+e;return e<0?t<=n?null:Math.max(a,n):e>0?t>=r?null:Math.min(a,r):null},Me=({value:e,min:t,max:n,velocityPxMs:r,deltaTimeMs:a,friction:l=.002,minVelocityPxMs:i=.01,emaAlpha:o=.2})=>{if(Math.abs(r)<i)return null;const s=Ae({delta:r*a,value:e,min:t,max:n});if(null===s)return null;const c=r*Math.exp(-l*a),u=o>0?r*(1-o)+c*o:c;return Math.abs(u)<i?null:{value:s,velocityPxMs:u}},ve=()=>`${Math.floor(1e3*performance.now()).toString(36)}${Math.random().toString(36).slice(2,10)}`,Ie=(e,t)=>Math.max(0,Math.min(e.right,t.right)-Math.max(e.left,t.left))*Math.max(0,Math.min(e.bottom,t.bottom)-Math.max(e.top,t.top))/(t.width*t.height),Se=(e,t,{allowFallback:n=!0,invert:r=!0}={})=>{const a=r?-1:1;switch(t){case"x":return{deltaX:a*(0!==e.deltaX?e.deltaX:n?e.deltaY:0),deltaY:0};case"y":return{deltaX:0,deltaY:a*e.deltaY};default:return{deltaX:a*e.deltaX,deltaY:a*e.deltaY}}},Ce=(e,t,n,r)=>{const a=n-e,l=r-t;return Math.hypot(a,l)},ke=(e,t)=>Math.abs(e/t),Ee=(e,t)=>e*t/100,Oe=e=>{let t=5381;for(let n=0;n<e.length;n++)t=33*t^e.charCodeAt(n);return(t>>>0).toString(36)},Le=e=>Object.entries(e).reduce((e,[t,n])=>(void 0!==n&&(e[t]=n),e),{}),Pe=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Te=e=>{const t=e.charAt(0),n=e.slice(1);return t.toLowerCase()+n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)},Xe=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1 $2"),$e=e=>0===e.length?[]:e.split(" ").filter(Boolean),_e=e=>""===e||p(e),Ne=e=>{const t=e.lastIndexOf(".");return t<=0||t===e.length-1?[e,""]:[e.slice(0,t),e.slice(t+1).toLowerCase()]},Ye=(e,t)=>{if(0===e.length)return[];const n=t.charCodeAt(0),r=[];for(let t=0;t<e.length;t++)e.charCodeAt(t)===n&&r.push(t);return r},Fe=(e,t,n)=>{if(0===e.length)return;const r=e.length;for(let a=0;a<r;a++){const l=e[a],i={charIndex:a,prevChar:a>0?e[a-1]:null,nextChar:a<r-1?e[a+1]:null};n?.(l,i)||t(l,i)}},Re=(e,t=1/0)=>0===e.length?"":$e(e).slice(0,t).map(e=>e[0]).join("").toUpperCase(),je=(e,t,n,r=t)=>e.split(t).map((e,t)=>n(e.trim(),t)).join(r),ze=(e,t,n,r=[],a=void 0,l=0)=>(e?.forEach(e=>{const{[n]:i,...o}=e,s=e[n],c=Array.isArray(s);if(r.push({...o,parentId:a,depthLevel:l,childCount:c?s.length:0}),c){const a=e[t];ze(s,t,n,r,a,l+1)}}),r),Ue=(e,t,n)=>e.filter(e=>e.parentId===t&&(!n||n(e))),We=(e,t,n,r)=>{const a=$e(r.toLowerCase());if(!a.length)return e;const l=e.reduce((e,n,r)=>(e[n[t]]=r,e),{});return e.reduce((r,i)=>{const o=i[n];if(!o)return r;if(r.some(e=>e[t]===i[t]))return r;const s=$e(o.toLowerCase());if(a.every(e=>s.some(t=>t.startsWith(e))))if(y(i.parentId)){r.push(i);const n=a=>{a.childCount&&e.forEach(e=>{e.parentId===a[t]&&(r.push(e),n(e))})};n(i)}else{const t=n=>{const a=l[n.parentId],i=e[a];y(i.parentId)||t(i);const o=r.length?r[r.length-1].parentId:null;(m(o)||o!==n.parentId)&&(d(i,"[@react-hive/honey-utils]: Parent node was not found."),r.push(i))};t(i),r.push(i)}return r},[])},De=(e,t)=>{d(t>=0&&t<=1,`[@react-hive/honey-utils]: Alpha "${t}" must be a number between 0 and 1.`);const n=e.match(/^#?([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/);d(n,`[@react-hive/honey-utils]: Invalid hex format: ${e}`);const r=n[1];return`#${(3===r.length?r[0]+r[0]+r[1]+r[1]+r[2]+r[2]:r)+Math.round(255*t).toString(16).toUpperCase().padStart(2,"0")}`};export{ee as DATA_TRANSFER_JSON_MIME,a as FOCUSABLE_HTML_TAGS,Me as applyInertiaStep,d as assert,ye as blobToFile,ce as calculateCenterOffset,Ce as calculateEuclideanDistance,ke as calculateMovingSpeed,Ee as calculatePercentage,Te as camelToDashCase,Xe as camelToWords,he as centerElementInContainer,X as chunk,ue as clampOffsetToOverflow,e as cloneBlob,$ as compact,c as compose,Le as definedProps,q as delay,u as difference,ae as downloadFile,Z as everyAsync,ge as fileListToFiles,B as filterParallel,H as filterSequential,J as findAsync,Ye as findCharIndices,ze as flattenTree,Fe as forEachChar,ve as generateEphemeralId,Y as getAdjacentItems,Ie as getDOMRectIntersectionRatio,ne as getDataTransferJson,t as getElementOffsetRect,i as getFocusableHtmlElements,me as getLocalStorageCapabilities,Ue as getTreeChildren,Re as getWordsInitials,ie as getXOverflowWidth,se as getYOverflowHeight,le as hasXOverflow,oe as hasYOverflow,Oe as hashString,De as hexWithAlpha,f as intersection,xe as invokeIfFunction,n as isAnchorHtmlElement,_ as isArray,v as isBlob,b as isBool,r as isContentEditableHtmlElement,M as isDate,T as isDecimal,g as isDefined,N as isEmptyArray,A as isEmptyObject,I as isError,pe as isFile,L as isFiniteNumber,R as isFunction,l as isHtmlElementFocusable,P as isInteger,de as isLocalStorageReadable,k as isMap,p as isNil,_e as isNilOrEmptyString,m as isNull,w as isNumber,x as isObject,U as isPromise,C as isRegExp,E as isSet,re as isString,O as isSymbol,y as isUndefined,S as isValidDate,o as moveFocusWithinContainer,F as noop,j as not,z as once,fe as parse2DMatrix,Ne as parseFileName,s as pipe,be as readFilesFromDataTransfer,G as reduceAsync,Se as resolveAxisDelta,Ae as resolveBoundedDelta,Q as retry,D as runParallel,W as runSequential,We as searchTree,te as setDataTransferJson,V as someAsync,je as splitMapJoin,$e as splitStringIntoWords,K as timeout,Pe as toKebabCase,we as traverseFileSystemDirectory,h as unique};
1
+ const t=t=>new Blob([t],{type:t.type}),e=t=>new DOMRect(t.offsetLeft,t.offsetTop,t.clientWidth,t.clientHeight),n=t=>"A"===t.tagName,r=t=>"true"===t.getAttribute("contenteditable"),a=["INPUT","SELECT","TEXTAREA","BUTTON","A"],l=t=>{if(!t)return!1;const e=window.getComputedStyle(t);if("hidden"===e.visibility||"none"===e.display)return!1;if("disabled"in t&&t.disabled)return!1;const l=t.getAttribute("tabindex");return"-1"!==l&&(a.includes(t.tagName)?!n(t)||""!==t.href:!!r(t)||null!==l)},i=t=>Array.from(t.querySelectorAll("*")).filter(l),o=(t,e=null,{wrap:n=!0,getNextIndex:r}={})=>{const a=document.activeElement,l=e??a?.parentElement;if(!a||!l)return;const o=i(l);if(0===o.length)return;const s=o.indexOf(a);if(-1===s)return;let c;r?c=r(s,t,o):"next"===t?(c=s+1,c>=o.length&&(c=n?0:null)):(c=s-1,c<0&&(c=n?o.length-1:null)),null!==c&&o[c]?.focus()},s=(...t)=>e=>t.reduce((t,e)=>e(t),e),c=(...t)=>e=>t.reduceRight((t,e)=>e(t),e),u=(t,e)=>t.filter(t=>!e.includes(t)),h=t=>[...new Set(t)],f=(...t)=>{if(0===t.length)return[];if(1===t.length)return[...t[0]];const[e,...n]=t;return h(e).filter(t=>n.every(e=>e.includes(t)))};function d(t,e){if(!t)throw new Error(e)}const m=t=>null===t,p=t=>null==t,g=t=>null!=t,y=t=>void 0===t,w=t=>"number"==typeof t,b=t=>"boolean"==typeof t,x=t=>"object"==typeof t,A=t=>x(t)&&!m(t)&&0===Object.keys(t).length,S=t=>t instanceof Date,I=t=>t instanceof Blob,M=t=>t instanceof Error,v=t=>S(t)&&!isNaN(t.getTime()),C=t=>t instanceof RegExp,k=t=>t instanceof Map,E=t=>t instanceof Set,O=t=>"symbol"==typeof t,$=t=>w(t)&&isFinite(t),L=t=>w(t)&&Number.isInteger(t),P=t=>$(t)&&!Number.isInteger(t),T=(t,e)=>(d(e>0,"Chunk size must be greater than 0"),Array.from({length:Math.ceil(t.length/e)},(n,r)=>t.slice(r*e,(r+1)*e))),X=t=>t.filter(Boolean),_=t=>Array.isArray(t),z=t=>_(t)&&0===t.length,N=(t,e,n)=>{if(!t?.length||!e)return{previousItem:null,currentItem:null,nextItem:null};const r=t.findIndex(t=>n(t,e));return-1===r?{previousItem:null,currentItem:null,nextItem:null}:{previousItem:r>0?t[r-1]:null,currentItem:t[r],nextItem:r<t.length-1?t[r+1]:null}},R=()=>{},Y=t=>"function"==typeof t,j=t=>(...e)=>!t(...e),F=t=>{let e,n=!1;return function(...r){return n||(n=!0,e=t.apply(this,r)),e}},U=t=>Y(t?.then),W=async(t,e)=>{const n=[];for(let r=0;r<t.length;r++)n.push(await e(t[r],r,t));return n},B=async(t,e)=>Promise.all(t.map(e)),D=async(t,e)=>{const n=[];for(let r=0;r<t.length;r++){const a=t[r];await e(a,r,t)&&n.push(a)}return n},H=async(t,e)=>{const n=await B(t,async(t,n,r)=>!!await e(t,n,r)&&t);return X(n)},Z=async(t,e)=>{for(let n=0;n<t.length;n++)if(await e(t[n],n,t))return!0;return!1},V=async(t,e)=>{for(let n=0;n<t.length;n++)if(!await e(t[n],n,t))return!1;return!0},G=async(t,e,n)=>{let r=n;for(let n=0;n<t.length;n++)r=await e(r,t[n],n,t);return r},J=async(t,e)=>{for(let n=0;n<t.length;n++)if(await e(t[n],n,t))return t[n];return null},q=t=>new Promise(e=>setTimeout(e,t)),K=async(t,e,n="Operation timed out")=>{try{return await Promise.race([t,q(e).then(()=>Promise.reject(new Error(n)))])}finally{}},Q=(t,{maxAttempts:e=3,delayMs:n=300,backoff:r=!0,onRetry:a}={})=>async(...l)=>{let i;for(let o=1;o<=e;o++)try{return await t(...l)}catch(t){if(i=t,o<e){a?.(o,t);const e=r?n*2**(o-1):n;await q(e)}}throw i},tt=t=>{try{return JSON.parse(t)}catch{return null}},et="application/json",nt=(t,e)=>{t.setData(et,JSON.stringify(e))},rt=t=>{const e=t.getData(et);return e?tt(e):null},at=t=>"string"==typeof t,lt=(t,{fileName:e,target:n}={})=>{if(y(document))return;const r=document.createElement("a");let a=null;try{const l=at(t)?t:a=URL.createObjectURL(t);r.href=l,e&&(r.download=e),n&&(r.target=n),document.body.appendChild(r),r.click()}finally{r.remove(),a&&setTimeout(()=>{d(a,"Object URL should not be null"),URL.revokeObjectURL(a)},0)}},it=t=>t.scrollWidth>t.clientWidth,ot=t=>Math.max(0,t.scrollWidth-t.clientWidth),st=t=>t.scrollHeight>t.clientHeight,ct=t=>Math.max(0,t.scrollHeight-t.clientHeight),ut=({containerSize:t,elementOffset:e,elementSize:n})=>-(e+n/2-t/2),ht=(t,e)=>e<=0?0:Math.max(-e,Math.min(t,0)),ft=(t,e,{axis:n="both",shouldClamp:r=!0}={})=>{let a=0,l=0;if("x"===n||"both"===n){const n=ut({containerSize:t.clientWidth,elementOffset:e.offsetLeft,elementSize:e.clientWidth});a=r?ht(n,ot(t)):n}if("y"===n||"both"===n){const n=ut({containerSize:t.clientHeight,elementOffset:e.offsetTop,elementSize:e.clientHeight});l=r?ht(n,ct(t)):n}t.style.transform=`translate(${a}px, ${l}px)`},dt=t=>{const e=window.getComputedStyle(t).getPropertyValue("transform").match(/^matrix\((.+)\)$/);if(!e)return{translateX:0,translateY:0,scaleX:1,scaleY:1,skewX:0,skewY:0};const[n,r,a,l,i,o]=e[1].split(", ").map(parseFloat);return{translateX:i,translateY:o,scaleX:n,scaleY:l,skewX:a,skewY:r}},mt=()=>{if("undefined"==typeof window||!window.localStorage)return!1;try{return window.localStorage.getItem("__non_existing_key__"),!0}catch{return!1}},pt=()=>{if(!mt())return{readable:!1,writable:!1};try{const t="__test_write__";return window.localStorage.setItem(t,"1"),window.localStorage.removeItem(t),{readable:!0,writable:!0}}catch{}return{readable:!0,writable:!1}},gt=t=>t instanceof File,yt=t=>{if(!t)return[];const e=[];for(let n=0;n<t.length;n++)e.push(t[n]);return e},wt=(t,e)=>new File([t],e,{type:t.type}),bt=async(t,{skipFiles:e=[".DS_Store","Thumbs.db","desktop.ini","ehthumbs.db",".Spotlight-V100",".Trashes",".fseventsd","__MACOSX"]}={})=>{const n=new Set(e),r=await(async t=>{const e=t.createReader(),n=async()=>new Promise((t,r)=>{e.readEntries(async e=>{if(e.length)try{const r=await n();t([...e,...r])}catch(t){r(t)}else t([])},r)});return n()})(t);return(await B(r,async t=>t.isDirectory?bt(t,{skipFiles:e}):n.has(t.name)?[]:[await new Promise((e,n)=>{t.file(e,n)})])).flat()},xt=async(t,e={})=>{const n=t?.items;if(!n)return[];const r=[];for(let t=0;t<n.length;t++){const a=n[t];if("webkitGetAsEntry"in a){const t=a.webkitGetAsEntry?.();if(t?.isDirectory){r.push(bt(t,e));continue}if(t?.isFile){r.push(new Promise((e,n)=>t.file(t=>e([t]),n)));continue}}const l=a.getAsFile();l&&r.push(Promise.resolve([l]))}return(await Promise.all(r)).flat()},At=(t,...e)=>"function"==typeof t?t(...e):t,St=({delta:t,value:e,min:n,max:r})=>{if(0===t)return null;const a=e+t;return t<0?e<=n?null:Math.max(a,n):t>0?e>=r?null:Math.min(a,r):null},It=({value:t,min:e,max:n,velocityPxMs:r,deltaTimeMs:a,friction:l=.002,minVelocityPxMs:i=.01,emaAlpha:o=.2})=>{if(Math.abs(r)<i)return null;const s=St({delta:r*a,value:t,min:e,max:n});if(null===s)return null;const c=r*Math.exp(-l*a),u=o>0?r*(1-o)+c*o:c;return Math.abs(u)<i?null:{value:s,velocityPxMs:u}},Mt=()=>`${Math.floor(1e3*performance.now()).toString(36)}${Math.random().toString(36).slice(2,10)}`,vt=(t,e)=>Math.max(0,Math.min(t.right,e.right)-Math.max(t.left,e.left))*Math.max(0,Math.min(t.bottom,e.bottom)-Math.max(t.top,e.top))/(e.width*e.height),Ct=(t,e,{allowFallback:n=!0,invert:r=!0}={})=>{const a=r?-1:1;switch(e){case"x":return{deltaX:a*(0!==t.deltaX?t.deltaX:n?t.deltaY:0),deltaY:0};case"y":return{deltaX:0,deltaY:a*t.deltaY};default:return{deltaX:a*t.deltaX,deltaY:a*t.deltaY}}},kt=(t,e,n,r)=>{const a=n-t,l=r-e;return Math.hypot(a,l)},Et=(t,e)=>Math.abs(t/e),Ot=(t,e)=>t*e/100,$t=t=>{let e=5381;for(let n=0;n<t.length;n++)e=33*e^t.charCodeAt(n);return(e>>>0).toString(36)},Lt=t=>Object.entries(t).reduce((t,[e,n])=>(void 0!==n&&(t[e]=n),t),{}),Pt=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Tt=t=>{const e=t.charAt(0),n=t.slice(1);return e.toLowerCase()+n.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)},Xt=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1 $2"),_t=t=>0===t.length?[]:t.split(" ").filter(Boolean),zt=t=>""===t||p(t),Nt=t=>{const e=t.lastIndexOf(".");return e<=0||e===t.length-1?[t,""]:[t.slice(0,e),t.slice(e+1).toLowerCase()]},Rt=(t,e)=>{if(0===t.length)return[];const n=e.charCodeAt(0),r=[];for(let e=0;e<t.length;e++)t.charCodeAt(e)===n&&r.push(e);return r},Yt=(t,e,n)=>{if(0===t.length)return;const r=t.length;for(let a=0;a<r;a++){const l=t[a],i={charIndex:a,prevChar:a>0?t[a-1]:null,nextChar:a<r-1?t[a+1]:null};n?.(l,i)||e(l,i)}},jt=(t,e=1/0)=>0===t.length?"":_t(t).slice(0,e).map(t=>t[0]).join("").toUpperCase(),Ft=(t,e,n,r=e)=>t.split(e).map((t,e)=>n(t.trim(),e)).join(r),Ut=(t,e,n,r=[],a=void 0,l=0)=>(t?.forEach(t=>{const{[n]:i,...o}=t,s=t[n],c=Array.isArray(s);if(r.push({...o,parentId:a,depthLevel:l,childCount:c?s.length:0}),c){const a=t[e];Ut(s,e,n,r,a,l+1)}}),r),Wt=(t,e,n)=>t.filter(t=>t.parentId===e&&(!n||n(t))),Bt=(t,e,n,r)=>{const a=_t(r.toLowerCase());if(!a.length)return t;const l=t.reduce((t,n,r)=>(t[n[e]]=r,t),{});return t.reduce((r,i)=>{const o=i[n];if(!o)return r;if(r.some(t=>t[e]===i[e]))return r;const s=_t(o.toLowerCase());if(a.every(t=>s.some(e=>e.startsWith(t))))if(y(i.parentId)){r.push(i);const n=a=>{a.childCount&&t.forEach(t=>{t.parentId===a[e]&&(r.push(t),n(t))})};n(i)}else{const e=n=>{const a=l[n.parentId],i=t[a];y(i.parentId)||e(i);const o=r.length?r[r.length-1].parentId:null;(m(o)||o!==n.parentId)&&(d(i,"[@react-hive/honey-utils]: Parent node was not found."),r.push(i))};e(i),r.push(i)}return r},[])},Dt=(t,e)=>{d(e>=0&&e<=1,`[@react-hive/honey-utils]: Alpha "${e}" must be a number between 0 and 1.`);const n=t.match(/^#?([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/);d(n,`[@react-hive/honey-utils]: Invalid hex format: ${t}`);const r=n[1];return`#${(3===r.length?r[0]+r[0]+r[1]+r[1]+r[2]+r[2]:r)+Math.round(255*e).toString(16).toUpperCase().padStart(2,"0")}`},Ht=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Zt=t=>{try{return Ht.test(t)?"undefined"!=typeof Buffer?Buffer.from(t,"base64").toString("utf-8"):decodeURIComponent(atob(t).split("").map(t=>`%${t.charCodeAt(0).toString(16).padStart(2,"0")}`).join("")):null}catch{return null}},Vt=t=>{const e=Zt(t);return null===e?null:tt(e)};export{et as DATA_TRANSFER_JSON_MIME,a as FOCUSABLE_HTML_TAGS,It as applyInertiaStep,d as assert,wt as blobToFile,ut as calculateCenterOffset,kt as calculateEuclideanDistance,Et as calculateMovingSpeed,Ot as calculatePercentage,Tt as camelToDashCase,Xt as camelToWords,ft as centerElementInContainer,T as chunk,ht as clampOffsetToOverflow,t as cloneBlob,X as compact,c as compose,Zt as decodeBase64,Vt as decodeBase64Json,Lt as definedProps,q as delay,u as difference,lt as downloadFile,V as everyAsync,yt as fileListToFiles,H as filterParallel,D as filterSequential,J as findAsync,Rt as findCharIndices,Ut as flattenTree,Yt as forEachChar,Mt as generateEphemeralId,N as getAdjacentItems,vt as getDOMRectIntersectionRatio,rt as getDataTransferJson,e as getElementOffsetRect,i as getFocusableHtmlElements,pt as getLocalStorageCapabilities,Wt as getTreeChildren,jt as getWordsInitials,ot as getXOverflowWidth,ct as getYOverflowHeight,it as hasXOverflow,st as hasYOverflow,$t as hashString,Dt as hexWithAlpha,f as intersection,At as invokeIfFunction,n as isAnchorHtmlElement,_ as isArray,I as isBlob,b as isBool,r as isContentEditableHtmlElement,S as isDate,P as isDecimal,g as isDefined,z as isEmptyArray,A as isEmptyObject,M as isError,gt as isFile,$ as isFiniteNumber,Y as isFunction,l as isHtmlElementFocusable,L as isInteger,mt as isLocalStorageReadable,k as isMap,p as isNil,zt as isNilOrEmptyString,m as isNull,w as isNumber,x as isObject,U as isPromise,C as isRegExp,E as isSet,at as isString,O as isSymbol,y as isUndefined,v as isValidDate,o as moveFocusWithinContainer,R as noop,j as not,F as once,dt as parse2DMatrix,Nt as parseFileName,tt as parseJson,s as pipe,xt as readFilesFromDataTransfer,G as reduceAsync,Ct as resolveAxisDelta,St as resolveBoundedDelta,Q as retry,B as runParallel,W as runSequential,Bt as searchTree,nt as setDataTransferJson,Z as someAsync,Ft as splitMapJoin,_t as splitStringIntoWords,K as timeout,Pt as toKebabCase,bt as traverseFileSystemDirectory,h as unique};
2
2
  //# sourceMappingURL=index.mjs.map