import { jsxs as n, jsx as t } from "react/jsx-runtime";
import e from "prop-types";
import { Close as D } from "@mui/icons-material";
import { Dialog as M, Box as w, useTheme as v, useMediaQuery as N, Typography as C, DialogContent as B, DialogActions as A, IconButton as T } from "@mui/material";
import { styled as h } from "../Theme/index.js";
function $({
  children: o,
  title: l = "",
  prepend: d = null,
  toolbar: c = null,
  actions: g = null,
  showCloseButton: a = !0,
  actionsPosition: y = "right",
  PaperProps: s = {},
  slotProps: u = {},
  ...p
}) {
  const _ = v(), i = N(_.breakpoints.down("md")), b = l || a || c, x = (r, j) => {
    const { onClose: m } = p;
    m && m(r, j);
  };
  s.style = Object.assign(
    {
      minWidth: 300,
      minHeight: 300
    },
    s.style
  );
  const f = /* @__PURE__ */ t(T, { className: "ux-dialog_closeButton", onClick: (r) => x(r, "closeButton"), children: /* @__PURE__ */ t(D, {}) });
  return /* @__PURE__ */ n(H, { fullScreen: i, onClose: x, PaperProps: s, ...p, children: [
    b && /* @__PURE__ */ n(O, { ...u.header, className: "ux-dialog_header", isMobile: i, children: [
      /* @__PURE__ */ n("div", { className: "ux-dialog_left", children: [
        a && i && f,
        d && /* @__PURE__ */ t("div", { className: "ux-dialog_prepend", children: d }),
        l && /* @__PURE__ */ t(C, { variant: "h6", className: "ux-dialog_title", children: l })
      ] }),
      /* @__PURE__ */ n("div", { className: "ux-dialog_right", children: [
        /* @__PURE__ */ t("div", { className: "ux-dialog_toolbar", children: c }),
        a && !i && f
      ] })
    ] }),
    /* @__PURE__ */ t(B, { ...u.content, children: o }),
    g && /* @__PURE__ */ t(A, { className: `ux-dialog_actions--${y}`, children: g })
  ] });
}
$.propTypes = {
  children: e.node.isRequired,
  title: e.node,
  // 在 title 之前追加内容, 比如返回按钮
  prepend: e.node,
  // 顶部工具栏, 在 close button 另一侧
  toolbar: e.node,
  actions: e.node,
  showCloseButton: e.bool,
  actionsPosition: e.oneOf(["left", "center", "right"]),
  PaperProps: e.object,
  slotProps: e.shape({
    content: e.object,
    header: e.object
  }),
  onClose: e.func
};
const H = h(M)`
  .MuiDialog-paper {
    ${(o) => o.fullScreen ? "border-radius: 0;" : ""};
  }
  .MuiDialogContent-root {
    padding: 16px 24px;
  }
  .MuiDialogActions-root {
    padding: 8px 24px 16px 24px;
  }
  .MuiDialogActions-root.ux-dialog_actions--left {
    justify-content: flex-start;
  }
  .MuiDialogActions-root.ux-dialog_actions--right {
    justify-content: flex-end;
  }
  .MuiDialogActions-root.ux-dialog_actions--center {
    justify-content: center;
  }
`, O = h(w, { shouldForwardProp: (o) => o !== "isMobile" })`
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  .ux-dialog_left {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    min-width: 0;
  }
  .ux-dialog_right {
    display: flex;
    justify-content: flex-end;
    align-items: center;
  }
  .ux-dialog_toolbar {
    display: flex;
    align-items: center;
  }
  .ux-dialog_title {
    margin: 0;
    font-size: 18px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .ux-dialog_closeButton {
    /* 使 closeButton 与 content 左/右对齐 */
    ${(o) => o.isMobile ? "margin-left: -12px;" : "margin-right: -12px;"}
    transition: transform 0.3s;
    transform: rotate(0deg);
    &:hover {
      transform: rotate(90deg);
    }
  }
`;
export {
  $ as default
};
