"use client";
import * as React from "react";
import { inertValue } from "../../../../utils/esm/inertValue.js";
import { useDialogRootContext } from "../root/DialogRootContext.js";
import { DialogPortalContext } from "./DialogPortalContext.js";
import { InternalBackdrop } from "../../utils/InternalBackdrop.js";
import { jsx, jsxs } from "react/jsx-runtime";
import { FloatingPortal } from "../../floating-ui-react/components/FloatingPortal.js";
const DialogPortal = /* @__PURE__ */ React.forwardRef(function DialogPortal2(props, forwardedRef) {
  const {
    keepMounted = false,
    ...portalProps
  } = props;
  const {
    store
  } = useDialogRootContext();
  const mounted = store.useState("mounted");
  const modal = store.useState("modal");
  const shouldRender = mounted || keepMounted;
  if (!shouldRender) {
    return null;
  }
  return /* @__PURE__ */ jsx(DialogPortalContext.Provider, {
    value: keepMounted,
    children: /* @__PURE__ */ jsxs(FloatingPortal, {
      ref: forwardedRef,
      ...portalProps,
      children: [mounted && modal === true && /* @__PURE__ */ jsx(InternalBackdrop, {
        ref: store.context.internalBackdropRef,
        inert: inertValue(!open)
      }), props.children]
    })
  });
});
if (process.env.NODE_ENV !== "production") DialogPortal.displayName = "DialogPortal";
export {
  DialogPortal
};
//# sourceMappingURL=DialogPortal.js.map
