import { _objectSpread2 } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import Modal$1 from "../../../modal/index.js";
import { sizeMap } from "../../constants.js";
import React, { useMemo } from "react";
import { isBoolean, isUndefined } from "@pisell/utils";
import { Button } from "antd";
import classNames from "classnames";
import XClose from "@pisell/icon/es/XClose";
import Delete_wght300_24px from "@pisell/icon/es/Delete_wght300_24px";
import "./index.less";
//#region src/components/pisellModal/components/PcModal/index.tsx
const PcModal = (props) => {
	const { wrapClassName, okButtonProps, cancelButtonProps, width: propsWidth, size = "middle", closeIcon: propsCloseIcon, headerDivider, footerDivider, title, centered = true, deleteButtonProps, onDelete, cancelVisible = true, okVisible = true, actions, footer, header } = props;
	const width = useMemo(() => {
		return propsWidth || sizeMap[size];
	}, [propsWidth, size]);
	const closeIcon = useMemo(() => {
		if (isUndefined(propsCloseIcon)) return /* @__PURE__ */ React.createElement(XClose, { style: { fontSize: 20 } });
	}, [propsCloseIcon]);
	const deleteBtn = useMemo(() => {
		if (!deleteButtonProps) return null;
		return /* @__PURE__ */ React.createElement("span", { style: { flexShrink: 0 } }, /* @__PURE__ */ React.createElement(Button, _objectSpread2(_objectSpread2({
			icon: /* @__PURE__ */ React.createElement(Delete_wght300_24px, { style: { fontSize: 20 } }),
			size: "large"
		}, deleteButtonProps), {}, { onClick: (e) => {
			var _deleteButtonProps$on;
			deleteButtonProps === null || deleteButtonProps === void 0 || (_deleteButtonProps$on = deleteButtonProps.onClick) === null || _deleteButtonProps$on === void 0 || _deleteButtonProps$on.call(deleteButtonProps, e);
			onDelete === null || onDelete === void 0 || onDelete();
		} })));
	}, [deleteButtonProps]);
	const isHideFooter = useMemo(() => {
		return isBoolean(footer) && !footer || footer === null;
	}, [footer]);
	const isHideHeader = useMemo(() => {
		return isBoolean(header) && !header || header === null;
	}, [header]);
	const renderFooter = (_, { OkBtn, CancelBtn }) => {
		if (footer) return footer;
		if ([
			deleteBtn,
			actions,
			cancelVisible,
			okVisible
		].every((item) => !item)) return null;
		return /* @__PURE__ */ React.createElement(React.Fragment, null, deleteBtn, actions, cancelVisible && /* @__PURE__ */ React.createElement(CancelBtn, null), okVisible && /* @__PURE__ */ React.createElement(OkBtn, null));
	};
	return /* @__PURE__ */ React.createElement(Modal$1, _objectSpread2(_objectSpread2({ keyboard: false }, props), {}, {
		centered,
		title: title || /* @__PURE__ */ React.createElement("div", { style: { height: 24 } }),
		width,
		wrapClassName: classNames("pisell-pc-modal", { [wrapClassName]: wrapClassName }),
		closeIcon,
		footer: isHideFooter ? null : renderFooter,
		okButtonProps: _objectSpread2({
			block: true,
			size: "large",
			style: { margin: 0 }
		}, okButtonProps || {}),
		cancelButtonProps: _objectSpread2({
			block: true,
			size: "large"
		}, cancelButtonProps || {}),
		styles: {
			header: {
				borderBottom: headerDivider ? "1px solid var(--Gray-200, #EAECF0)" : "none",
				display: isHideHeader ? "none" : "block"
			},
			footer: { borderTop: footerDivider ? "1px solid var(--Gray-200, #EAECF0)" : "none" }
		}
	}));
};
//#endregion
export { PcModal as default };
