import { useState as c, useRef as d, useId as l, useLayoutEffect as i } from "react";
function m(t) {
  const [r, o] = c(null), n = d(null), u = l();
  return i(() => {
    if (typeof document > "u")
      return;
    let e = document.getElementById(u);
    return !e && t && (e = document.createElement("div"), e.id = u, document.body.appendChild(e)), n.current !== e && (o(e), n.current = e), () => {
      n.current && (n.current.remove(), n.current = null);
    };
  }, [u, t, n]), t ? r : null;
}
export {
  m as usePopoverContainer
};
