const require_runtime = require("../../../../../_virtual/_rolldown/runtime.js");
const require_index = require("../../../../Sales/Step/index.js");
const require_index$1 = require("../../../../Sales/Cart/index.js");
const require_index$2 = require("../../../../Sales/Holder/index.js");
const require_SelectHolderModal = require("../SelectHolderModal.js");
const require_index$3 = require("../InformationOptionsModal/index.js");
const require_RemoveOptionConfirmModal = require("../RemoveOptionConfirmModal.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
require("./index.less");
//#region src/components/eventBooking/components/Provider/Information/index.tsx
const Information = () => {
	const { onHolderOpen, open } = require_index$2.useHolder();
	const { cartDataHolderList } = require_index$1.useCart();
	const { selectHolder, deleteHolderById } = require_index$2.useHolder();
	const { prevStep } = require_index.useStep();
	const [openOption, setOpenOption] = (0, react.useState)(false);
	const [holderItem, setHolderItem] = (0, react.useState)(null);
	const [removeOpen, setRemoveOpen] = (0, react.useState)(false);
	/**
	* @title: 选项
	* @description:
	* @return {*}
	* @Author: WangHan
	* @Date: 2025-01-19 10:44
	*/
	const options = [{
		key: "edit",
		label: /* @__PURE__ */ react.default.createElement("span", { className: "dropdown-menu-item" }, _pisell_utils.locales.getText("pisell2.event.edit.event"))
	}, {
		key: "remove",
		label: /* @__PURE__ */ react.default.createElement("span", { className: "dropdown-menu-item dropdown-menu-remove-item" }, _pisell_utils.locales.getText("pisell2.event.remove"))
	}];
	/**
	* @title: 点击item触发
	* @description:
	* @param {string} key
	* @return {*}
	* @Author: WangHan
	* @Date: 2025-01-18 16:14
	*/
	const handleClick = ({ key }, item) => {
		if (key === "edit") {
			selectHolder(item || holderItem, "createCartItem");
			prevStep();
			return;
		}
		setRemoveOpen(true);
	};
	/**
	* @title: 渲染options
	* @description:
	* @param {any} item
	* @return {*}
	* @Author: WangHan
	* @Date: 2025-01-19 11:44
	*/
	const renderOptionButton = (item) => {
		if ((0, _pisell_utils.isMobile)()) return /* @__PURE__ */ react.default.createElement(_pisell_materials.Button, {
			size: "large",
			onClick: () => {
				setHolderItem(item);
				setOpenOption(true);
			}
		}, _pisell_utils.locales.getText("pisell2.event.option"));
		return /* @__PURE__ */ react.default.createElement(antd.Dropdown, {
			menu: {
				items: options,
				onClick: (e) => {
					setHolderItem(item);
					handleClick(e, item);
				}
			},
			placement: "bottomRight",
			overlayClassName: "provider-information-custom-dropdown-menu"
		}, /* @__PURE__ */ react.default.createElement(_pisell_materials.Button, null, _pisell_utils.locales.getText("pisell2.event.option")));
	};
	return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement("div", {
		className: "provider-information-wrap",
		id: "information"
	}, /* @__PURE__ */ react.default.createElement("span", { className: "title" }, _pisell_utils.locales.getText("pisell2.event.confirm.information.tip")), cartDataHolderList === null || cartDataHolderList === void 0 ? void 0 : cartDataHolderList.map((item) => {
		var _item$children;
		return /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellCard, {
			key: item.id,
			padding: 20,
			className: "information-card",
			isClickable: false
		}, /* @__PURE__ */ react.default.createElement("div", { className: "information-header" }, /* @__PURE__ */ react.default.createElement("div", { className: "information-left" }, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellAvatar, {
			src: item.avatar,
			size: "md"
		}), /* @__PURE__ */ react.default.createElement("div", { className: "information-title" }, /* @__PURE__ */ react.default.createElement("span", null, item.name), /* @__PURE__ */ react.default.createElement("span", { className: "subtitle" }, `${_pisell_utils.locales.getText("pisell2.event.title")((_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length)}`))), renderOptionButton(item)), item.children.map((child) => {
			return /* @__PURE__ */ react.default.createElement("div", { className: "child-wrap" }, child.name);
		}));
	}), /* @__PURE__ */ react.default.createElement("span", { className: "add-tip" }, _pisell_utils.locales.getText("pisell2.event.confirm.information.other")), /* @__PURE__ */ react.default.createElement(_pisell_materials.Button, {
		size: "large",
		style: { width: "max-content" },
		onClick: () => {
			onHolderOpen();
		},
		className: "provider-information-add-button"
	}, /* @__PURE__ */ react.default.createElement(_pisell_materials.Iconfont, {
		type: "pisell2-plus",
		style: { fontSize: "20px" }
	}), _pisell_utils.locales.getText("pisell2.event.add.others"))), /* @__PURE__ */ react.default.createElement(require_SelectHolderModal.default, {
		open,
		type: "create"
	}), /* @__PURE__ */ react.default.createElement(require_index$3.default, {
		options,
		open: openOption,
		holderItem,
		onCancel: () => setOpenOption(false),
		onClick: handleClick
	}), /* @__PURE__ */ react.default.createElement(require_RemoveOptionConfirmModal.default, {
		removeOpen,
		onCancel: () => setRemoveOpen(false),
		onOk: () => {
			deleteHolderById(holderItem.id);
			setRemoveOpen(false);
			setOpenOption(false);
		}
	}));
};
//#endregion
exports.default = Information;
