"use client";
import * as React from "react";
import { usePopoverRootContext } from "../root/PopoverRootContext.js";
import { PopoverPortalContext } from "./PopoverPortalContext.js";
import { jsx } from "react/jsx-runtime";
import { FloatingPortal } from "../../floating-ui-react/components/FloatingPortal.js";
const PopoverPortal = /* @__PURE__ */ React.forwardRef(function PopoverPortal2(props, forwardedRef) {
  const {
    keepMounted = false,
    ...portalProps
  } = props;
  const {
    store
  } = usePopoverRootContext();
  const mounted = store.useState("mounted");
  const shouldRender = mounted || keepMounted;
  if (!shouldRender) {
    return null;
  }
  return /* @__PURE__ */ jsx(PopoverPortalContext.Provider, {
    value: keepMounted,
    children: /* @__PURE__ */ jsx(FloatingPortal, {
      ref: forwardedRef,
      ...portalProps,
      renderGuards: false
    })
  });
});
if (process.env.NODE_ENV !== "production") PopoverPortal.displayName = "PopoverPortal";
export {
  PopoverPortal
};
//# sourceMappingURL=PopoverPortal.js.map
