import{Q as e,V as t,et as n,nt as r}from"./client.js";import{t as i}from"./index-client.js";var a={allowItemHover:!0,position:`bottom`},o=(o,s,c=a)=>{let l={...a,...c},u=n(!1),d=r(()=>new i(`(max-width: 780px)`).current);function f(){let e=o()?.getBoundingClientRect(),n=s()?.getBoundingClientRect();return!e||!n?{}:t(d)?{top:`-${n.height+24}px`,left:`-${n.width-e.width}px`}:{top:c.position===`top`?`-${n.height-e.height}px`:s()?.style.left||`0px`}}function p(t){if(!s||!o)return;let n=t?.relatedTarget;l.allowItemHover&&n&&(s()?.contains(n)||o()?.contains(n))||(s()?.classList.add(`mc-sidebar__floating-item--hidden`),e(u,!1),document.removeEventListener(`mousedown`,m))}function m(e){let t=e.composedPath?e.composedPath():[];!t.includes(o())&&!t.includes(s())&&p(e)}function h(){let n=s();if(n?.classList.toggle(`mc-sidebar__floating-item--hidden`),e(u,!n?.classList.contains(`mc-sidebar__floating-item--hidden`)),!t(u)||!n)return;let{left:r,top:i}=f();i&&(n.style.top=i),r&&(n.style.left=r),e(u,!0),document.addEventListener(`mousedown`,m)}function g(e){s&&([`ArrowDown`,`Enter`,` `].includes(e.key)&&(e.preventDefault(),h(),_()),e.key===`Tab`&&p())}function _(){(s()?.querySelector(`button, [href], [tabindex]:not([tabindex="-1"])`))?.focus()}function v(e){e.key===`Escape`&&(e.preventDefault(),p(),o()?.focus())}return{floatingItemIsDisplayed:t(u),hideFloatingItem:p,showFloatingItem:h,onTriggerKeydown:g,onListboxKeydown:v}};export{o as t};
//# sourceMappingURL=floating-item.svelte.js.map