import{d as h,I as v,n as N}from"./factory-BR3bc_RM.js";var y=t=>h(t)&&t.tagName==="IFRAME",T=/^(audio|video|details)$/;function x(t){const s=t.getAttribute("tabindex");return s?parseInt(s,10):NaN}var w=t=>!Number.isNaN(x(t)),R=t=>x(t)<0;function S(t,s){if(!s)return null;if(s===!0)return t.shadowRoot||null;const o=s(t);return(o===!0?t.shadowRoot:o)||null}function A(t,s,o){const n=[...t],r=[...t],i=new Set,e=new Map;t.forEach((l,d)=>e.set(l,d));let a=0;for(;a<r.length;){const l=r[a++];if(!l||i.has(l))continue;i.add(l);const d=S(l,s);if(d){const c=Array.from(d.querySelectorAll(m)).filter(o),E=e.get(l);if(E!==void 0){const f=E+1;n.splice(f,0,...c),c.forEach((u,p)=>{e.set(u,f+p)});for(let u=f+c.length;u<n.length;u++)e.set(n[u],u)}else{const f=n.length;n.push(...c),c.forEach((u,p)=>{e.set(u,f+p)})}r.push(...c)}}return n}var m="input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false']), details > summary:first-of-type",B=(t,s={})=>{if(!t)return[];const{includeContainer:o=!1,getShadowRoot:n}=s,r=Array.from(t.querySelectorAll(m));(o==!0||o=="if-empty"&&r.length===0)&&h(t)&&b(t)&&r.unshift(t);const e=[];for(const a of r)if(b(a)){if(y(a)&&a.contentDocument){const l=a.contentDocument.body;e.push(...B(l,{getShadowRoot:n}));continue}e.push(a)}return n?A(e,n,b):e};function b(t){return!h(t)||t.closest("[inert]")?!1:t.matches(m)&&v(t)}function I(t,s={}){if(!t)return[];const{includeContainer:o,getShadowRoot:n}=s,r=Array.from(t.querySelectorAll(m));o&&g(t)&&r.unshift(t);const i=[];for(const e of r)if(g(e)){if(y(e)&&e.contentDocument){const a=e.contentDocument.body;i.push(...I(a,{getShadowRoot:n}));continue}i.push(e)}if(n){const e=A(i,n,g);return!e.length&&o?r:e}return!i.length&&o?r:i}function g(t){return h(t)&&t.tabIndex>0?!0:b(t)&&!R(t)}function F(t,s={}){const o=I(t,s),n=o[0]||null,r=o[o.length-1]||null;return[n,r]}function M(t){return t.tabIndex<0&&(T.test(t.localName)||N(t))&&!w(t)?0:t.tabIndex}export{B as a,M as b,b as c,F as d,I as g,g as i};
