import{BUBBLE_PREFIX as t}from"./kd/tooltipLibrary.js";function e(t){const e=[];return a(t,n=>{try{(function({element:t,rootContainer:e}){const n=t.localName;if("input"===n&&"hidden"===n.type)return!1;const o=t.getAttribute("tabindex");if("-1"===o)return!1;if(t.disabled&&u.includes(t.localName))return!1;const r="0"===o||0===t.tabIndex&&c.includes(t.localName);return r&&function(t){const{width:e,height:n}=t.getBoundingClientRect();return(e>0||n>0)&&"hidden"!==getComputedStyle(t).visibility}(t)&&function({element:t,rootContainer:e}){const n=e.getRootNode(),{ownerDocument:o}=t;let r=t.getRootNode();for(;r!==n&&r!==o;){const{host:t}=r;if("-1"===t.getAttribute("tabindex"))return!1;r=t&&t.getRootNode()}return!0}({element:t,rootContainer:e})})({element:n,rootContainer:t})&&e.push(n)}catch(t){}}),e}const n=/^input$|^select$|^textarea$|^a$|^button$/;function o(t){const e=[];return a(t,t=>{n.test(t.tagName.toLowerCase())&&e.push(t)}),e}function r(){let t=document.activeElement;for(;t;)if(t.shadowRoot){const e=t.shadowRoot.activeElement;if(!e)return t;t=e}else{if(!t.contentDocument)return t;{const e=t.contentDocument.activeElement;if(!e)return t;t=e}}}function i(t){const e=document.body.contains(t);if(t){if(e)return t.focus(),!0;const n=function(t){let e=t;for(;e&&e.parentNode;){if(e.parentNode===document)return!0;e=e.parentNode instanceof DocumentFragment?e.parentNode.host:e.parentNode}return!1}(t);if(n)return t.focus(),!0}return!1}function a(t,e){if(!t)return;if(t.nodeType===Node.ELEMENT_NODE){if(t.hasAttribute("inert"))return;if(function(t){return"IFRAME"===t.tagName||t instanceof HTMLIFrameElement}(t))return void(t.contentDocument?a(t.contentDocument,e):e&&e(t));if(e&&e(t),t.shadowRoot)return void a(t.shadowRoot,e);if("slot"===t.localName){const n=t.assignedNodes({flatten:!0});for(let t=0;t<n.length;t++)a(n[t],e);return}}let n=t.firstChild;for(;null!==n;)a(n,e),n=n.nextSibling}const u=["button","select","textarea","input"],c=["a","select","textarea","input","button","iframe","object","area","frame"];const s=t=>"tooltip"===t.getAttribute("role"),f=t=>t.classList.contains("ignore-autofocus"),l=e=>{const n="button"===e.tagName.toLowerCase(),o=e.getAttribute("aria-describedby"),r=!!o&&0===String(o).indexOf(t);return n&&r},d=t=>{if(!t)return!1;return![s(t),l(t),f(t)].some(t=>!0===t)};function m(t){return t&&Array.isArray(t)&&t.length>0?t.filter(d):[]}export{o as a,m as b,e as f,r as g,i as r};
