const o="bal-focused",t=["Tab","ArrowDown","Space","Escape"," ","Shift","Enter","ArrowLeft","ArrowRight","ArrowUp","Home","End"],s=()=>{let s=[],e=!0;const c=document,u=document.body,n=t=>{s.forEach((t=>t.classList.remove(o))),t.forEach((t=>t.classList.add(o))),s=t},r=()=>{e=!1,n([])},a=o=>{e=t.includes(o.key),e||n([])},d=o=>{if(e&&void 0!==o.composedPath){const t=o.composedPath().filter((o=>!!o.classList&&o.classList.contains("bal-focusable")));n(t)}},f=()=>{c.activeElement===u&&n([])};return c.addEventListener("keydown",a),c.addEventListener("focusin",d),c.addEventListener("focusout",f),c.addEventListener("touchstart",r),c.addEventListener("mousedown",r),{destroy:()=>{c.removeEventListener("keydown",a),c.removeEventListener("focusin",d),c.removeEventListener("focusout",f),c.removeEventListener("touchstart",r),c.removeEventListener("mousedown",r)},setFocus:n}};export{t as F,s}