/*!
 * (C) Ionic http://ionicframework.com - MIT License
 */
const o="ion-focused",t=["Tab","ArrowDown","Space","Escape"," ","Shift","Enter","ArrowLeft","ArrowRight","ArrowUp","Home","End"];let e=null;const s=()=>(e||(e=c()),e),n=o=>{s().setFocus(o)},c=e=>{let s=[],n=!0;const c=e?e.shadowRoot:document,u=e||document.body,r=t=>{s.forEach((t=>t.classList.remove(o))),t.forEach((t=>t.classList.add(o))),s=t},d=()=>{n=!1,r([])},f=o=>{n=t.includes(o.key),n||r([])},i=o=>{if(n&&void 0!==o.composedPath){const t=o.composedPath().filter((o=>!!o.classList&&o.classList.contains("ion-focusable")));r(t)}},w=()=>{c.activeElement===u&&r([])};return c.addEventListener("keydown",f),c.addEventListener("focusin",i),c.addEventListener("focusout",w),c.addEventListener("touchstart",d,{passive:!0}),c.addEventListener("mousedown",d),{destroy:()=>{c.removeEventListener("keydown",f),c.removeEventListener("focusin",i),c.removeEventListener("focusout",w),c.removeEventListener("touchstart",d),c.removeEventListener("mousedown",d)},setFocus:r}};export{n as focusElements,s as getOrInitFocusVisibleUtility,c as startFocusVisible}