"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Portal = Portal;
exports.PortalHost = PortalHost;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const react_dom_1 = require("react-dom");
function Portal({ children, hostName = "INTERNAL_PRIMITIVE_DEFAULT_HOST_NAME", }) {
    const [hostElement, setHostElement] = (0, react_1.useState)(null);
    (0, react_1.useEffect)(() => {
        const element = document.querySelector(`[data-portal-host="${hostName}"]`);
        setHostElement(element);
    }, [hostName]);
    if (!hostElement) {
        return null;
    }
    return (0, react_dom_1.createPortal)(children, hostElement);
}
function PortalHost({ name = "INTERNAL_PRIMITIVE_DEFAULT_HOST_NAME", }) {
    return (0, jsx_runtime_1.jsx)("div", { "data-portal-host": name });
}
//# sourceMappingURL=portal.web.js.map