import { jsx as r, jsxs as C, Fragment as g } from "react/jsx-runtime";
import o from "prop-types";
import { useMemoizedFn as q } from "ahooks";
import c from "../Button/index.js";
import y from "./dialog.js";
function R({
  title: a,
  children: d,
  onConfirm: m,
  onCancel: i,
  showCloseButton: f = !0,
  showCancelButton: n = !0,
  showConfirmButton: s = !0,
  fullScreen: x = !1,
  confirmButton: p = {
    text: "Confirm"
  },
  cancelButton: l = {
    text: "Cancel"
  },
  PaperProps: t = {},
  ...b
}) {
  t.style = Object.assign(
    {
      minHeight: 0
    },
    t.style
  );
  const h = q((e, u) => {
    ["backdropClick", "escapeKeyDown"].includes(u) || (e.stopPropagation(), i(e, u));
  });
  return /* @__PURE__ */ r(
    y,
    {
      title: a,
      PaperProps: t,
      ...b,
      onClose: h,
      showCloseButton: f,
      fullScreen: x,
      slotProps: {
        header: {
          sx: {
            ".ux-dialog_title": {
              lineHeight: 1
            }
          }
        },
        content: {
          sx: {
            paddingTop: "0!important",
            border: "none!important"
          }
        }
      },
      actions: n || s ? /* @__PURE__ */ C(g, { children: [
        n && /* @__PURE__ */ r(
          c,
          {
            onClick: (e) => {
              e.stopPropagation(), i(e, "closeButton");
            },
            color: "primary",
            ...l.props,
            children: l.text
          }
        ),
        s && /* @__PURE__ */ r(
          c,
          {
            onClick: (e) => {
              e.stopPropagation(), m(e);
            },
            color: "primary",
            autoFocus: !0,
            ...p.props,
            children: p.text
          }
        )
      ] }) : null,
      children: d
    }
  );
}
R.propTypes = {
  title: o.node.isRequired,
  open: o.bool.isRequired,
  onConfirm: o.func.isRequired,
  onCancel: o.func.isRequired,
  children: o.node.isRequired,
  showCancelButton: o.bool,
  showConfirmButton: o.bool,
  showCloseButton: o.bool,
  fullScreen: o.bool,
  // 可以传入 {text: ..., props: ...}
  confirmButton: o.shape({
    text: o.node.isRequired,
    props: o.object
  }),
  cancelButton: o.shape({
    text: o.node.isRequired,
    props: o.object
  }),
  PaperProps: o.object
};
export {
  R as default
};
