import { jsx, Fragment } from "react/jsx-runtime";
import "react";
import "clsx";
import { useMantineEnv } from "../../core/MantineProvider/Mantine.context.mjs";
import { factory } from "../../core/factory/factory.mjs";
import { Portal } from "./Portal.mjs";
const OptionalPortal = factory(
  ({ withinPortal = true, children, ...others }, ref) => {
    const env = useMantineEnv();
    if (env === "test" || !withinPortal) {
      return /* @__PURE__ */ jsx(Fragment, { children });
    }
    return /* @__PURE__ */ jsx(Portal, { ref, ...others, children });
  }
);
OptionalPortal.displayName = "@mantine/core/OptionalPortal";
export {
  OptionalPortal
};
