import{k as t}from"./key-a66127fc.js";import{F as e}from"./constants-7c047c0d.js";import{d as n,r as o}from"./disposable-d2c2d283.js";import{L as s}from"./logicaltreehelper-67db40f1.js";import"./_commonjsHelpers-41cdd1e7.js";import"./string-2448bf95.js";import"./browser-3fc721b7.js";import"./layouthelper-67dd777a.js";import"./point-e4ec110e.js";const r="data-dx-focus-hidden";function i(t){t.setAttribute(r,"")}function u(t){t.removeAttribute(r)}function c(t){return null!==t.getAttribute(r)}function d(e){let n=e;function o(t){const e="mousedown"===t.type&&0===t.detail,o=null==n?void 0:n.hasAttribute(r);e||!n||o||s.containsElement(n,t.target)&&i(n)}function c(t){if(!n)return;const e=t.relatedTarget;e&&!s.containsElement(n,e)&&document.hasFocus()&&u(n)}function d(e){n&&t.KeyUtils.getEventKeyCode(e)===t.KeyCode.Tab&&u(n)}const l=document.documentElement;return l.addEventListener("touchstart",o),l.addEventListener("mousedown",o),n.addEventListener("keydown",d),n.addEventListener("focusout",c),()=>{l.removeEventListener("touchstart",o),l.removeEventListener("mousedown",o),null==n||n.removeEventListener("keydown",d),null==n||n.removeEventListener("focusout",c),n=null}}function l(t){if(!t)return;n(t);const e=d(t);o(t,e)}function a(t){return null!==t&&t.matches(e)}function m(t){return null!==t&&null!==t.closest(e)}const f={initFocusHidingEvents:l};export{r as FocusHiddenAttributeName,i as addFocusHiddenAttribute,d as attachEventsForFocusHiding,c as containsFocusHiddenAttribute,f as default,m as hasClosestFocusableElement,l as initFocusHidingEvents,a as isFocusableElement,u as removeFocusHiddenAttribute};
