import * as React from 'react';
import ReactDOM__default from 'react-dom';
import { P as Primitive } from './index-DhnfW8wQ.js';
import { u as useLayoutEffect2 } from './index-DOzu5J1s.js';
import { jsx } from 'react/jsx-runtime';

var PORTAL_NAME = "Portal";
var Portal = React.forwardRef((props, forwardedRef) => {
  const { container: containerProp, ...portalProps } = props;
  const [mounted, setMounted] = React.useState(false);
  useLayoutEffect2(() => setMounted(true), []);
  const container = containerProp || mounted && globalThis?.document?.body;
  return container ? ReactDOM__default.createPortal(/* @__PURE__ */ jsx(Primitive.div, { ...portalProps, ref: forwardedRef }), container) : null;
});
Portal.displayName = PORTAL_NAME;

export { Portal as P };
//# sourceMappingURL=index-fV_U4ZJM.js.map
