/*! * (C) Ionic http://ionicframework.com - MIT License */ var ION_FOCUSED="ion-focused";var ION_FOCUSABLE="ion-focusable";var FOCUS_KEYS=["Tab","ArrowDown","Space","Escape"," ","Shift","Enter","ArrowLeft","ArrowRight","ArrowUp","Home","End"];var startFocusVisible=function(r){var o=[];var n=true;var t=r?r.shadowRoot:document;var u=r?r:document.body;var e=function(r){o.forEach((function(r){return r.classList.remove(ION_FOCUSED)}));r.forEach((function(r){return r.classList.add(ION_FOCUSED)}));o=r};var a=function(){n=false;e([])};var i=function(r){n=FOCUS_KEYS.includes(r.key);if(!n){e([])}};var c=function(r){if(n&&r.composedPath!==undefined){var o=r.composedPath().filter((function(r){if(r.classList){return r.classList.contains(ION_FOCUSABLE)}return false}));e(o)}};var f=function(){if(t.activeElement===u){e([])}};t.addEventListener("keydown",i);t.addEventListener("focusin",c);t.addEventListener("focusout",f);t.addEventListener("touchstart",a,{passive:true});t.addEventListener("mousedown",a);var s=function(){t.removeEventListener("keydown",i);t.removeEventListener("focusin",c);t.removeEventListener("focusout",f);t.removeEventListener("touchstart",a);t.removeEventListener("mousedown",a)};return{destroy:s,setFocus:e}};export{startFocusVisible};