import z from "./index-objectWithoutPropertiesLoose.js";
import i from "./index-extends.js";
import * as g from "react";
import o from "./index-_virtual16.js";
import { clsx as k } from "./index-clsx.js";
import d from "./index-styled.js";
import y, { getDialogUtilityClass as H } from "./index-dialogClasses.js";
import U from "./index-DialogContext.js";
import V from "./index-useTheme.js";
import { jsx as s } from "react/jsx-runtime";
import { useDefaultProps as q } from "./index-DefaultPropsProvider.js";
import B from "./index-Paper.js";
import X from "./index-Fade.js";
import G from "./index-useId2.js";
import t from "./index-capitalize.js";
import J from "./index-composeClasses.js";
import Q from "./index-Modal2.js";
import Z from "./index-Backdrop.js";
const oo = ["aria-describedby", "aria-labelledby", "BackdropComponent", "BackdropProps", "children", "className", "disableEscapeKeyDown", "fullScreen", "fullWidth", "maxWidth", "onBackdropClick", "onClick", "onClose", "open", "PaperComponent", "PaperProps", "scroll", "TransitionComponent", "transitionDuration", "TransitionProps"], eo = d(Z, {
  name: "MuiDialog",
  slot: "Backdrop",
  overrides: (r, e) => e.backdrop
})({
  // Improve scrollable dialog support.
  zIndex: -1
}), ro = (r) => {
  const {
    classes: e,
    scroll: a,
    maxWidth: l,
    fullWidth: p,
    fullScreen: m
  } = r, u = {
    root: ["root"],
    container: ["container", `scroll${t(a)}`],
    paper: ["paper", `paperScroll${t(a)}`, `paperWidth${t(String(l))}`, p && "paperFullWidth", m && "paperFullScreen"]
  };
  return J(u, H, e);
}, ao = d(Q, {
  name: "MuiDialog",
  slot: "Root",
  overridesResolver: (r, e) => e.root
})({
  "@media print": {
    // Use !important to override the Modal inline-style.
    position: "absolute !important"
  }
}), io = d("div", {
  name: "MuiDialog",
  slot: "Container",
  overridesResolver: (r, e) => {
    const {
      ownerState: a
    } = r;
    return [e.container, e[`scroll${t(a.scroll)}`]];
  }
})(({
  ownerState: r
}) => i({
  height: "100%",
  "@media print": {
    height: "auto"
  },
  // We disable the focus ring for mouse, touch and keyboard users.
  outline: 0
}, r.scroll === "paper" && {
  display: "flex",
  justifyContent: "center",
  alignItems: "center"
}, r.scroll === "body" && {
  overflowY: "auto",
  overflowX: "hidden",
  textAlign: "center",
  "&::after": {
    content: '""',
    display: "inline-block",
    verticalAlign: "middle",
    height: "100%",
    width: "0"
  }
})), no = d(B, {
  name: "MuiDialog",
  slot: "Paper",
  overridesResolver: (r, e) => {
    const {
      ownerState: a
    } = r;
    return [e.paper, e[`scrollPaper${t(a.scroll)}`], e[`paperWidth${t(String(a.maxWidth))}`], a.fullWidth && e.paperFullWidth, a.fullScreen && e.paperFullScreen];
  }
})(({
  theme: r,
  ownerState: e
}) => i({
  margin: 32,
  position: "relative",
  overflowY: "auto",
  // Fix IE11 issue, to remove at some point.
  "@media print": {
    overflowY: "visible",
    boxShadow: "none"
  }
}, e.scroll === "paper" && {
  display: "flex",
  flexDirection: "column",
  maxHeight: "calc(100% - 64px)"
}, e.scroll === "body" && {
  display: "inline-block",
  verticalAlign: "middle",
  textAlign: "left"
  // 'initial' doesn't work on IE11
}, !e.maxWidth && {
  maxWidth: "calc(100% - 64px)"
}, e.maxWidth === "xs" && {
  maxWidth: r.breakpoints.unit === "px" ? Math.max(r.breakpoints.values.xs, 444) : `max(${r.breakpoints.values.xs}${r.breakpoints.unit}, 444px)`,
  [`&.${y.paperScrollBody}`]: {
    [r.breakpoints.down(Math.max(r.breakpoints.values.xs, 444) + 64)]: {
      maxWidth: "calc(100% - 64px)"
    }
  }
}, e.maxWidth && e.maxWidth !== "xs" && {
  maxWidth: `${r.breakpoints.values[e.maxWidth]}${r.breakpoints.unit}`,
  [`&.${y.paperScrollBody}`]: {
    [r.breakpoints.down(r.breakpoints.values[e.maxWidth] + 64)]: {
      maxWidth: "calc(100% - 64px)"
    }
  }
}, e.fullWidth && {
  width: "calc(100% - 64px)"
}, e.fullScreen && {
  margin: 0,
  width: "100%",
  maxWidth: "100%",
  height: "100%",
  maxHeight: "none",
  borderRadius: 0,
  [`&.${y.paperScrollBody}`]: {
    margin: 0,
    maxWidth: "100%"
  }
})), to = /* @__PURE__ */ g.forwardRef(function(e, a) {
  const l = q({
    props: e,
    name: "MuiDialog"
  }), p = V(), m = {
    enter: p.transitions.duration.enteringScreen,
    exit: p.transitions.duration.leavingScreen
  }, {
    "aria-describedby": u,
    "aria-labelledby": w,
    BackdropComponent: S,
    BackdropProps: $,
    children: M,
    className: R,
    disableEscapeKeyDown: C = !1,
    fullScreen: j = !1,
    fullWidth: N = !1,
    maxWidth: O = "sm",
    onBackdropClick: W,
    onClick: D,
    onClose: f,
    open: P,
    PaperComponent: E = B,
    PaperProps: v = {},
    scroll: A = "paper",
    TransitionComponent: F = X,
    transitionDuration: T = m,
    TransitionProps: I
  } = l, K = z(l, oo), c = i({}, l, {
    disableEscapeKeyDown: C,
    fullScreen: j,
    fullWidth: N,
    maxWidth: O,
    scroll: A
  }), b = ro(c), x = g.useRef(), _ = (n) => {
    x.current = n.target === n.currentTarget;
  }, L = (n) => {
    D && D(n), x.current && (x.current = null, W && W(n), f && f(n, "backdropClick"));
  }, h = G(w), Y = g.useMemo(() => ({
    titleId: h
  }), [h]);
  return /* @__PURE__ */ s(ao, i({
    className: k(b.root, R),
    closeAfterTransition: !0,
    components: {
      Backdrop: eo
    },
    componentsProps: {
      backdrop: i({
        transitionDuration: T,
        as: S
      }, $)
    },
    disableEscapeKeyDown: C,
    onClose: f,
    open: P,
    ref: a,
    onClick: L,
    ownerState: c
  }, K, {
    children: /* @__PURE__ */ s(F, i({
      appear: !0,
      in: P,
      timeout: T,
      role: "presentation"
    }, I, {
      children: /* @__PURE__ */ s(io, {
        className: k(b.container),
        onMouseDown: _,
        ownerState: c,
        children: /* @__PURE__ */ s(no, i({
          as: E,
          elevation: 24,
          role: "dialog",
          "aria-describedby": u,
          "aria-labelledby": h
        }, v, {
          className: k(b.paper, v.className),
          ownerState: c,
          children: /* @__PURE__ */ s(U.Provider, {
            value: Y,
            children: M
          })
        }))
      })
    }))
  }));
});
process.env.NODE_ENV !== "production" && (to.propTypes = {
  // ┌────────────────────────────── Warning ──────────────────────────────┐
  // │ These PropTypes are generated from the TypeScript type definitions. │
  // │    To update them, edit the d.ts file and run `pnpm proptypes`.     │
  // └─────────────────────────────────────────────────────────────────────┘
  /**
   * The id(s) of the element(s) that describe the dialog.
   */
  "aria-describedby": o.string,
  /**
   * The id(s) of the element(s) that label the dialog.
   */
  "aria-labelledby": o.string,
  /**
   * A backdrop component. This prop enables custom backdrop rendering.
   * @deprecated Use `slots.backdrop` instead. While this prop currently works, it will be removed in the next major version.
   * Use the `slots.backdrop` prop to make your application ready for the next version of Material UI.
   * @default styled(Backdrop, {
   *   name: 'MuiModal',
   *   slot: 'Backdrop',
   *   overridesResolver: (props, styles) => {
   *     return styles.backdrop;
   *   },
   * })({
   *   zIndex: -1,
   * })
   */
  BackdropComponent: o.elementType,
  /**
   * @ignore
   */
  BackdropProps: o.object,
  /**
   * Dialog children, usually the included sub-components.
   */
  children: o.node,
  /**
   * Override or extend the styles applied to the component.
   */
  classes: o.object,
  /**
   * @ignore
   */
  className: o.string,
  /**
   * If `true`, hitting escape will not fire the `onClose` callback.
   * @default false
   */
  disableEscapeKeyDown: o.bool,
  /**
   * If `true`, the dialog is full-screen.
   * @default false
   */
  fullScreen: o.bool,
  /**
   * If `true`, the dialog stretches to `maxWidth`.
   *
   * Notice that the dialog width grow is limited by the default margin.
   * @default false
   */
  fullWidth: o.bool,
  /**
   * Determine the max-width of the dialog.
   * The dialog width grows with the size of the screen.
   * Set to `false` to disable `maxWidth`.
   * @default 'sm'
   */
  maxWidth: o.oneOfType([o.oneOf(["xs", "sm", "md", "lg", "xl", !1]), o.string]),
  /**
   * Callback fired when the backdrop is clicked.
   * @deprecated Use the `onClose` prop with the `reason` argument to handle the `backdropClick` events.
   */
  onBackdropClick: o.func,
  /**
   * @ignore
   */
  onClick: o.func,
  /**
   * Callback fired when the component requests to be closed.
   *
   * @param {object} event The event source of the callback.
   * @param {string} reason Can be: `"escapeKeyDown"`, `"backdropClick"`.
   */
  onClose: o.func,
  /**
   * If `true`, the component is shown.
   */
  open: o.bool.isRequired,
  /**
   * The component used to render the body of the dialog.
   * @default Paper
   */
  PaperComponent: o.elementType,
  /**
   * Props applied to the [`Paper`](/material-ui/api/paper/) element.
   * @default {}
   */
  PaperProps: o.object,
  /**
   * Determine the container for scrolling the dialog.
   * @default 'paper'
   */
  scroll: o.oneOf(["body", "paper"]),
  /**
   * The system prop that allows defining system overrides as well as additional CSS styles.
   */
  sx: o.oneOfType([o.arrayOf(o.oneOfType([o.func, o.object, o.bool])), o.func, o.object]),
  /**
   * The component used for the transition.
   * [Follow this guide](/material-ui/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.
   * @default Fade
   */
  TransitionComponent: o.elementType,
  /**
   * The duration for the transition, in milliseconds.
   * You may specify a single timeout for all transitions, or individually with an object.
   * @default {
   *   enter: theme.transitions.duration.enteringScreen,
   *   exit: theme.transitions.duration.leavingScreen,
   * }
   */
  transitionDuration: o.oneOfType([o.number, o.shape({
    appear: o.number,
    enter: o.number,
    exit: o.number
  })]),
  /**
   * Props applied to the transition element.
   * By default, the element is based on this [`Transition`](https://reactcommunity.org/react-transition-group/transition/) component.
   */
  TransitionProps: o.object
});
export {
  to as default
};
