"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../utils/disposables.js"),t=require("../utils/owner.js"),r=require("./use-is-top-layer.js"),i=require("./use-iso-morphic-effect.js");let n=new Map,l=new Map;function s(e){var t;let r=null!=(t=l.get(e))?t:0;return l.set(e,r+1),0!==r||(n.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0),()=>o(e)}function o(e){var t;let r=null!=(t=l.get(e))?t:1;if(1===r?l.delete(e):l.set(e,r-1),1!==r)return;let i=n.get(e);i&&(null===i["aria-hidden"]?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",i["aria-hidden"]),e.inert=i.inert,n.delete(e))}exports.useInertOthers=function(n){let{allowed:l,disallowed:o}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},u=r.useIsTopLayer(n,"inert-others");i.useIsoMorphicEffect((()=>{var r,i;if(!u)return;let n=e.disposables();for(let e of null!=(r=null==o?void 0:o())?r:[])e&&n.add(s(e));let d=null!=(i=null==l?void 0:l())?i:[];for(let e of d){if(!e)continue;let r=t.getOwnerDocument(e);if(!r)continue;let i=e.parentElement;for(;i&&i!==r.body;){for(let e of i.children)d.some((t=>e.contains(t)))||n.add(s(e));i=i.parentElement}}return n.dispose}),[u,l,o])};
//# sourceMappingURL=use-inert-others.js.map
