"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");exports.usePortal=function(t){var n=e.useRef(null);e.useEffect((function(){var e=document.querySelector("#".concat(t)),r=e||function(e){var t=document.createElement("div");return t.setAttribute("id",e),t}(t);return e||function(e){try{document.body.lastElementChild?document.body.insertBefore(e,document.body.lastElementChild.nextElementSibling):console.warn("Failed to add root element, document.body is empty")}catch(t){console.warn("Failed to add root element")}}(r),n.current&&r.appendChild(n.current),function(){n.current&&n.current.remove(),-1===r.childNodes.length&&r.remove()}}),[]);return n.current||"undefined"==typeof document||(n.current=document.createElement("div")),n.current};
