@react-hive/honey-utils 3.32.0 → 4.1.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 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,O=t=>t instanceof Map,k=t=>t instanceof Set,E=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),N=t=>_(t)&&0===t.length,z=(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},J=async(t,e)=>{for(let n=0;n<t.length;n++)if(!await e(t[n],n,t))return!1;return!0},V=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},G=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="application/json",et=(t,e)=>{t.setData(tt,JSON.stringify(e))},nt=t=>{const e=t.getData(tt);if(e)try{return JSON.parse(e)}catch{return}},rt=t=>"string"==typeof t,at=(t,{fileName:e,target:n}={})=>{if(y(document))return;const r=document.createElement("a");let a=null;try{const l=rt(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)}},lt=t=>t.scrollWidth>t.clientWidth,it=t=>Math.max(0,t.scrollWidth-t.clientWidth),ot=t=>t.scrollHeight>t.clientHeight,st=t=>Math.max(0,t.scrollHeight-t.clientHeight),ct=({containerSize:t,elementOffset:e,elementSize:n})=>-(e+n/2-t/2),ut=(t,e)=>e<=0?0:Math.max(-e,Math.min(t,0)),ht=(t,e,{axis:n="both",shouldClamp:r=!0}={})=>{let a=0,l=0;if("x"===n||"both"===n){const n=ct({containerSize:t.clientWidth,elementOffset:e.offsetLeft,elementSize:e.clientWidth});a=r?ut(n,it(t)):n}if("y"===n||"both"===n){const n=ct({containerSize:t.clientHeight,elementOffset:e.offsetTop,elementSize:e.clientHeight});l=r?ut(n,st(t)):n}t.style.transform=`translate(${a}px, ${l}px)`},ft=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}},dt=()=>{if("undefined"==typeof window||!window.localStorage)return!1;try{return window.localStorage.getItem("__non_existing_key__"),!0}catch{return!1}},mt=()=>{if(!dt())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}},pt=t=>t instanceof File,gt=t=>{if(!t)return[];const e=[];for(let n=0;n<t.length;n++)e.push(t[n]);return e},yt=(t,e)=>new File([t],e,{type:t.type}),wt=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?wt(t,{skipFiles:e}):n.has(t.name)?[]:[await new Promise((e,n)=>{t.file(e,n)})])).flat()},bt=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(wt(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()},xt=(t,...e)=>"function"==typeof t?t(...e):t,At=({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},St=({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=At({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}},It=()=>`${Math.floor(1e3*performance.now()).toString(36)}${Math.random().toString(36).slice(2,10)}`,Mt=(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),vt=(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}}},Ct=(t,e,n,r)=>{const a=n-t,l=r-e;return Math.hypot(a,l)},Ot=(t,e)=>Math.abs(t/e),kt=(t,e)=>t*e/100,Et=t=>{let e=5381;for(let n=0;n<t.length;n++)e=33*e^t.charCodeAt(n);return(e>>>0).toString(36)},$t=t=>Object.entries(t).reduce((t,[e,n])=>(void 0!==n&&(t[e]=n),t),{}),Lt=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Pt=t=>{const e=t.charAt(0),n=t.slice(1);return e.toLowerCase()+n.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)},Tt=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1 $2"),Xt=t=>0===t.length?[]:t.split(" ").filter(Boolean),_t=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()]},zt=(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},Rt=(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)}},Yt=(t,e=1/0)=>0===t.length?"":Xt(t).slice(0,e).map(t=>t[0]).join("").toUpperCase(),jt=(t,e,n,r=e)=>t.split(e).map((t,e)=>n(t.trim(),e)).join(r),Ft=(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];Ft(s,e,n,r,a,l+1)}}),r),Ut=(t,e,n)=>t.filter(t=>t.parentId===e&&(!n||n(t))),Wt=(t,e,n,r)=>{const a=Xt(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=Xt(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},[])},Bt=(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")}`},Dt=t=>{try{return JSON.parse(t)}catch{return null}},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}},Jt=t=>{const e=Zt(t);return null===e?null:Dt(e)};export{tt as DATA_TRANSFER_JSON_MIME,a as FOCUSABLE_HTML_TAGS,St as applyInertiaStep,d as assert,yt as blobToFile,ct as calculateCenterOffset,Ct as calculateEuclideanDistance,Ot as calculateMovingSpeed,kt as calculatePercentage,Pt as camelToDashCase,Tt as camelToWords,ht as centerElementInContainer,T as chunk,ut as clampOffsetToOverflow,t as cloneBlob,X as compact,c as compose,Zt as decodeBase64,Jt as decodeBase64Json,$t as definedProps,q as delay,u as difference,at as downloadFile,J as everyAsync,gt as fileListToFiles,H as filterParallel,D as filterSequential,G as findAsync,zt as findCharIndices,Ft as flattenTree,Rt as forEachChar,It as generateEphemeralId,z as getAdjacentItems,Mt as getDOMRectIntersectionRatio,nt as getDataTransferJson,e as getElementOffsetRect,i as getFocusableHtmlElements,mt as getLocalStorageCapabilities,Ut as getTreeChildren,Yt as getWordsInitials,it as getXOverflowWidth,st as getYOverflowHeight,lt as hasXOverflow,ot as hasYOverflow,Et as hashString,Bt as hexWithAlpha,f as intersection,xt 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,N as isEmptyArray,A as isEmptyObject,M as isError,pt as isFile,$ as isFiniteNumber,Y as isFunction,l as isHtmlElementFocusable,L as isInteger,dt as isLocalStorageReadable,O as isMap,p as isNil,_t as isNilOrEmptyString,m as isNull,w as isNumber,x as isObject,U as isPromise,C as isRegExp,k as isSet,rt as isString,E as isSymbol,y as isUndefined,v as isValidDate,o as moveFocusWithinContainer,R as noop,j as not,F as once,ft as parse2DMatrix,Nt as parseFileName,Dt as parseJson,s as pipe,bt as readFilesFromDataTransfer,V as reduceAsync,vt as resolveAxisDelta,At as resolveBoundedDelta,Q as retry,B as runParallel,W as runSequential,Wt as searchTree,et as setDataTransferJson,Z as someAsync,jt as splitMapJoin,Xt as splitStringIntoWords,K as timeout,Lt as toKebabCase,wt 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)},o=t=>Array.from(t.querySelectorAll("*")).filter(l),i=(t,e=null,{wrap:n=!0,getNextIndex:r}={})=>{const a=document.activeElement,l=e??a?.parentElement;if(!a||!l)return;const i=o(l);if(0===i.length)return;const s=i.indexOf(a);if(-1===s)return;let c;r?c=r(s,t,i):"next"===t?(c=s+1,c>=i.length&&(c=n?0:null)):(c=s-1,c<0&&(c=n?i.length-1:null)),null!==c&&i[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)),f=t=>[...new Set(t)],h=(...t)=>{if(0===t.length)return[];if(1===t.length)return[...t[0]];const[e,...n]=t;return f(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,y=t=>null!=t,g=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,M=t=>t instanceof Blob,v=t=>t instanceof Error,I=t=>S(t)&&!isNaN(t.getTime()),C=t=>t instanceof RegExp,O=t=>t instanceof Map,$=t=>t instanceof Set,E=t=>"symbol"==typeof t,k=t=>w(t)&&isFinite(t),L=t=>w(t)&&Number.isInteger(t),T=t=>k(t)&&!Number.isInteger(t),P=(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))),B=t=>t.filter(Boolean),X=t=>Array.isArray(t),_=t=>X(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}},z=(t,e,n)=>{const r=t.includes(e);return r===(n??!r)?t:r?u(t,[e]):[...t,e]},U=()=>{},Y=t=>"function"==typeof t,F=t=>(...e)=>!t(...e),R=t=>{let e,n=!1;return function(...r){return n||(n=!0,e=t.apply(this,r)),e}},j=t=>Y(t?.then),D=async(t,e)=>{const n=[];for(let r=0;r<t.length;r++)n.push(await e(t[r],r,t));return n},W=async(t,e)=>Promise.all(t.map(e)),H=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},Z=async(t,e)=>{const n=await W(t,async(t,n,r)=>!!await e(t,n,r)&&t);return B(n)},J=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},q=async(t,e)=>{for(let n=0;n<t.length;n++)if(await e(t[n],n,t))return t[n];return null},K=t=>new Promise(e=>setTimeout(e,t)),Q=async(t,e,n="Operation timed out")=>{try{return await Promise.race([t,K(e).then(()=>Promise.reject(new Error(n)))])}finally{}},tt=(t,{maxAttempts:e=3,delayMs:n=300,backoff:r=!0,onRetry:a}={})=>async(...l)=>{let o;for(let i=1;i<=e;i++)try{return await t(...l)}catch(t){if(o=t,i<e){a?.(i,t);const e=r?n*2**(i-1):n;await K(e)}}throw o},et=t=>{try{return JSON.parse(t)}catch{return null}},nt="application/json",rt=(t,e)=>{t.setData(nt,JSON.stringify(e))},at=t=>{const e=t.getData(nt);return e?et(e):null},lt=t=>"string"==typeof t,ot=(t,{fileName:e,target:n}={})=>{if(g(document))return;const r=document.createElement("a");let a=null;try{const l=lt(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=>{const e=t.toString();window.history.replaceState(window.history.state,"",`${window.location.pathname}${e?`?${e}`:""}${window.location.hash}`)},st=t=>t.scrollWidth>t.clientWidth,ct=t=>Math.max(0,t.scrollWidth-t.clientWidth),ut=t=>t.scrollHeight>t.clientHeight,ft=t=>Math.max(0,t.scrollHeight-t.clientHeight),ht=({containerSize:t,elementOffset:e,elementSize:n})=>-(e+n/2-t/2),dt=(t,e)=>e<=0?0:Math.max(-e,Math.min(t,0)),mt=(t,e,{axis:n="both",shouldClamp:r=!0}={})=>{let a=0,l=0;if("x"===n||"both"===n){const n=ht({containerSize:t.clientWidth,elementOffset:e.offsetLeft,elementSize:e.clientWidth});a=r?dt(n,ct(t)):n}if("y"===n||"both"===n){const n=ht({containerSize:t.clientHeight,elementOffset:e.offsetTop,elementSize:e.clientHeight});l=r?dt(n,ft(t)):n}t.style.transform=`translate(${a}px, ${l}px)`},pt=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,o,i]=e[1].split(", ").map(parseFloat);return{translateX:o,translateY:i,scaleX:n,scaleY:l,skewX:a,skewY:r}},yt=()=>{if("undefined"==typeof window||!window.localStorage)return!1;try{return window.localStorage.getItem("__non_existing_key__"),!0}catch{return!1}},gt=()=>{if(!yt())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}},wt=t=>t instanceof File,bt=t=>{if(!t)return[];const e=[];for(let n=0;n<t.length;n++)e.push(t[n]);return e},xt=(t,e)=>new File([t],e,{type:t.type}),At=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 W(r,async t=>t.isDirectory?At(t,{skipFiles:e}):n.has(t.name)?[]:[await new Promise((e,n)=>{t.file(e,n)})])).flat()},St=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(At(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()},Mt=(t,...e)=>"function"==typeof t?t(...e):t,vt=({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:o=.01,emaAlpha:i=.2})=>{if(Math.abs(r)<o)return null;const s=vt({delta:r*a,value:t,min:e,max:n});if(null===s)return null;const c=r*Math.exp(-l*a),u=i>0?r*(1-i)+c*i:c;return Math.abs(u)<o?null:{value:s,velocityPxMs:u}},Ct=()=>`${Math.floor(1e3*performance.now()).toString(36)}${Math.random().toString(36).slice(2,10)}`,Ot=(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),$t=(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}}},Et=(t,e,n,r)=>{const a=n-t,l=r-e;return Math.hypot(a,l)},kt=(t,e)=>Math.abs(t/e),Lt=(t,e)=>t*e/100,Tt=t=>{let e=5381;for(let n=0;n<t.length;n++)e=33*e^t.charCodeAt(n);return(e>>>0).toString(36)},Pt=(t,e,n)=>Math.min(Math.max(t,e),n),Bt=t=>Object.entries(t).reduce((t,[e,n])=>(void 0!==n&&(t[e]=n),t),{}),Xt=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),_t=t=>{const e=t.charAt(0),n=t.slice(1);return e.toLowerCase()+n.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)},Nt=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1 $2"),zt=t=>0===t.length?[]:t.split(" ").filter(Boolean),Ut=t=>""===t||p(t),Yt=t=>{const e=t.lastIndexOf(".");return e<=0||e===t.length-1?[t,""]:[t.slice(0,e),t.slice(e+1).toLowerCase()]},Ft=(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},Rt=(t,e,n)=>{if(0===t.length)return;const r=t.length;for(let a=0;a<r;a++){const l=t[a],o={charIndex:a,prevChar:a>0?t[a-1]:null,nextChar:a<r-1?t[a+1]:null};n?.(l,o)||e(l,o)}},jt=(t,e=1/0)=>0===t.length?"":zt(t).slice(0,e).map(t=>t[0]).join("").toUpperCase(),Dt=(t,e,n,r=e)=>t.split(e).map((t,e)=>n(t.trim(),e)).join(r),Wt=(t,e,n,r=[],a=void 0,l=0)=>(t?.forEach(t=>{const{[n]:o,...i}=t,s=t[n],c=Array.isArray(s);if(r.push({...i,parentId:a,depthLevel:l,childCount:c?s.length:0}),c){const a=t[e];Wt(s,e,n,r,a,l+1)}}),r),Ht=(t,e,n)=>t.filter(t=>t.parentId===e&&(!n||n(t))),Zt=(t,e,n,r)=>{const a=zt(r.toLowerCase());if(!a.length)return t;const l=t.reduce((t,n,r)=>(t[n[e]]=r,t),{});return t.reduce((r,o)=>{const i=o[n];if(!i)return r;if(r.some(t=>t[e]===o[e]))return r;const s=zt(i.toLowerCase());if(a.every(t=>s.some(e=>e.startsWith(t))))if(g(o.parentId)){r.push(o);const n=a=>{a.childCount&&t.forEach(t=>{t.parentId===a[e]&&(r.push(t),n(t))})};n(o)}else{const e=n=>{const a=l[n.parentId],o=t[a];g(o.parentId)||e(o);const i=r.length?r[r.length-1].parentId:null;(m(i)||i!==n.parentId)&&(d(o,"[@react-hive/honey-utils]: Parent node was not found."),r.push(o))};e(o),r.push(o)}return r},[])},Jt=(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")}`},Vt=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Gt=t=>{if(!Vt.test(t))return null;try{return new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}).decode((t=>{if("function"==typeof Uint8Array.fromBase64)return Uint8Array.fromBase64(t);if("undefined"!=typeof Buffer)return Buffer.from(t,"base64");const e=atob(t),n=new Uint8Array(e.length);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);return n})(t))}catch{return null}},qt=t=>{const e=Gt(t);return null===e?null:et(e)},Kt=t=>(t=>{if("function"==typeof t.toBase64)return t.toBase64();if("undefined"!=typeof Buffer)return Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64");let e="";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)})((new TextEncoder).encode(t)),Qt=t=>Kt(JSON.stringify(t));export{nt as DATA_TRANSFER_JSON_MIME,a as FOCUSABLE_HTML_TAGS,It as applyInertiaStep,d as assert,xt as blobToFile,ht as calculateCenterOffset,Et as calculateEuclideanDistance,kt as calculateMovingSpeed,Lt as calculatePercentage,_t as camelToDashCase,Nt as camelToWords,mt as centerElementInContainer,P as chunk,Pt as clamp,dt as clampOffsetToOverflow,t as cloneBlob,B as compact,c as compose,Gt as decodeBase64,qt as decodeBase64Json,Bt as definedProps,K as delay,u as difference,ot as downloadFile,Kt as encodeBase64,Qt as encodeBase64Json,V as everyAsync,bt as fileListToFiles,Z as filterParallel,H as filterSequential,q as findAsync,Ft as findCharIndices,Wt as flattenTree,Rt as forEachChar,Ct as generateEphemeralId,N as getAdjacentItems,Ot as getDOMRectIntersectionRatio,at as getDataTransferJson,e as getElementOffsetRect,o as getFocusableHtmlElements,gt as getLocalStorageCapabilities,Ht as getTreeChildren,jt as getWordsInitials,ct as getXOverflowWidth,ft as getYOverflowHeight,st as hasXOverflow,ut as hasYOverflow,Tt as hashString,Jt as hexWithAlpha,h as intersection,Mt as invokeIfFunction,n as isAnchorHtmlElement,X as isArray,M as isBlob,b as isBool,r as isContentEditableHtmlElement,S as isDate,T as isDecimal,y as isDefined,_ as isEmptyArray,A as isEmptyObject,v as isError,wt as isFile,k as isFiniteNumber,Y as isFunction,l as isHtmlElementFocusable,L as isInteger,yt as isLocalStorageReadable,O as isMap,p as isNil,Ut as isNilOrEmptyString,m as isNull,w as isNumber,x as isObject,j as isPromise,C as isRegExp,$ as isSet,lt as isString,E as isSymbol,g as isUndefined,I as isValidDate,i as moveFocusWithinContainer,U as noop,F as not,R as once,pt as parse2DMatrix,Yt as parseFileName,et as parseJson,s as pipe,St as readFilesFromDataTransfer,G as reduceAsync,it as replaceHistorySearchParams,$t as resolveAxisDelta,vt as resolveBoundedDelta,tt as retry,W as runParallel,D as runSequential,Zt as searchTree,rt as setDataTransferJson,J as someAsync,Dt as splitMapJoin,zt as splitStringIntoWords,Q as timeout,Xt as toKebabCase,z as toggleArrayItem,At as traverseFileSystemDirectory,f as unique};
2
2
  //# sourceMappingURL=index.mjs.map