import{ref as a,h as m}from"vue";import{Hidden as c,Features as s}from'../internal/hidden.js';import{getOwnerDocument as d}from'../utils/owner.js';import{dom as H}from'../utils/dom.js';function p({defaultContainers:r=[],portals:t}={}){let o=a(null),l=d(o);function u(){var i;let n=[];for(let e of r)e!==null&&(e instanceof HTMLElement?n.push(e):"value"in e&&e.value instanceof HTMLElement&&n.push(e.value));if(t!=null&&t.value)for(let e of t.value)n.push(e);for(let e of(i=l==null?void 0:l.querySelectorAll("html > *, body > *"))!=null?i:[])e!==document.body&&e!==document.head&&e instanceof HTMLElement&&e.id!=="headlessui-portal-root"&&(e.contains(H(o))||n.some(f=>e.contains(f))||n.push(e));return n}return{resolveContainers:u,contains(n){return u().some(i=>i.contains(n))},mainTreeNodeRef:o,MainTreeNode(){return m(c,{features:s.Hidden,ref:o})}}}export{p as useRootContainers};
