const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
const require_index = require("../ErrorTip/index.js");
const require_mock = require("../../mock.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
require("./index.less");
//#region src/components/eventBooking/components/selectHolder/index.tsx
const PisellSelectHolder = ({ open = false, onCancel, onOk, onClick, onAdd, options = require_mock.mock.holder || [], value, title, okText, showCancel, disabled, errorTipText }) => {
	const [errorTip, setErrorTip] = (0, react.useState)();
	(0, react.useEffect)(() => {
		if (open && !disabled) setErrorTip("");
	}, [open, disabled]);
	/**
	* @title: 渲染卡片
	* @description:
	* @param {any} item
	* @return {*}
	* @Author: WangHan
	* @Date: 2025-01-13 12:19
	*/
	const renderCard = (item) => {
		return /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellCard, {
			key: item.id,
			padding: 20,
			selected: value == item.id
		}, /* @__PURE__ */ react.default.createElement("div", { className: "select-holder-card" }, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellAvatar, {
			src: item.avatar,
			size: "xxl"
		}), /* @__PURE__ */ react.default.createElement("span", { className: "select-holder-name" }, item.name)));
	};
	/**
	* @title: 渲染添加项
	* @description:
	* @return {*}
	* @Author: WangHan
	* @Date: 2025-01-13 12:04
	*/
	const renderAddItem = () => {
		return /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellCard, { padding: 20 }, /* @__PURE__ */ react.default.createElement("div", { className: `select-holder-card select-holder-add-card` }, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellAvatar, {
			size: "xxl",
			className: "select-holder-card-avatar"
		}), /* @__PURE__ */ react.default.createElement("span", { className: "select-holder-name" }, _pisell_utils.locales.getText("pisell2.event.create"))));
	};
	return /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellModal, {
		open,
		title: (0, _pisell_utils.isMobile)() ? "" : title,
		platform: (0, _pisell_utils.isMobile)() ? "h5" : "pc",
		okText,
		cancelVisible: false,
		closable: showCancel,
		onCancel,
		onOk: (e) => {
			if (disabled) return setErrorTip(errorTipText);
			onOk && onOk(e);
		},
		bodyStyle: { padding: (0, _pisell_utils.isMobile)() ? "0 16px 16px" : 20 },
		mobileModalHeight: "auto",
		destroyOnClose: true,
		className: `select-holder-modal ${(0, _pisell_utils.isMobile)() ? "select-holder-modal-mobile" : ""}`,
		headerDivider: false
	}, (0, _pisell_utils.isMobile)() ? /* @__PURE__ */ react.default.createElement("div", { className: "select-holder-modal-title" }, title) : null, errorTip ? /* @__PURE__ */ react.default.createElement(require_index.default, { text: errorTip }) : null, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellCustomCheckboxGroup, {
		dataSource: options,
		renderItem: renderCard,
		renderAddItem,
		columns: (0, _pisell_utils.isMobile)() ? 2 : 3,
		horizontalGap: 16,
		verticalGap: 16,
		allowAdd: true,
		onClick: (e) => onClick && onClick(e)
	}));
};
//#endregion
exports.default = PisellSelectHolder;
