const require_runtime = require("../../../../../_virtual/_rolldown/runtime.js");
const require_utils = require("../../../utils.js");
const require_index = require("../like/index.js");
const require_index$1 = require("../../../components/collapsibleList/index.js");
const require_utils$1 = require("../../../components/collapsibleList/utils.js");
const require_index$2 = require("../actions/index.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/booking/info/service/serviceItem/index.tsx
const ServiceItem = ({ d, handleEditService, state, handleLike, resourceItem, errorMessage, handleDeleteService }) => {
	var _d$_extend3, _d$_extend4, _d$_extend5, _d$_extend6, _d$_extend7, _d$_extend8, _d$_extend9, _d$_extend$relation_d;
	let resourceName = (resourceItem === null || resourceItem === void 0 ? void 0 : resourceItem.labelText) || d.relation_form_name;
	const isDiscount = (0, react.useMemo)(() => {
		var _d$_extend, _d$_extend2;
		return Number((_d$_extend = d._extend) === null || _d$_extend === void 0 ? void 0 : _d$_extend.total) != Number((_d$_extend2 = d._extend) === null || _d$_extend2 === void 0 ? void 0 : _d$_extend2.origin_total);
	}, [(_d$_extend3 = d._extend) === null || _d$_extend3 === void 0 ? void 0 : _d$_extend3.total, (_d$_extend4 = d._extend) === null || _d$_extend4 === void 0 ? void 0 : _d$_extend4.origin_total]);
	return /* @__PURE__ */ react.default.createElement("div", {
		key: d._id,
		className: "pisell-lowcode__booking-service-item",
		onClick: () => {
			handleEditService(d);
		}
	}, !state.channelDisabledEdit && /* @__PURE__ */ react.default.createElement("div", {
		className: "pisell-lowcode__booking-service-item-delete",
		onClick: (e) => {
			e.stopPropagation();
			handleDeleteService(d);
		}
	}, /* @__PURE__ */ react.default.createElement(antd.Button, {
		type: "text",
		icon: /* @__PURE__ */ react.default.createElement(_pisell_materials.Iconfont, { type: "pisell2-trash-01" })
	})), d.id || d.isCustomItem ? /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__booking-service-item-title" }, d.title) : null, d._extend ? /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, state.renderType !== "eventBooking" && /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__booking-service-item-date" }, require_utils.getServiceTime(d, state.date.value)), /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__booking-service-item-technician" }, d._extend.resource ? /* @__PURE__ */ react.default.createElement(require_index.default, {
		style: { marginRight: 4 },
		status: d._extend.like_status,
		onChange: (e) => {
			handleLike(e, d);
		}
	}) : null, resourceName)) : null, (((_d$_extend5 = d._extend) === null || _d$_extend5 === void 0 || (_d$_extend5 = _d$_extend5.other) === null || _d$_extend5 === void 0 ? void 0 : _d$_extend5.bundle) || []).length ? /* @__PURE__ */ react.default.createElement(require_index$1.default, {
		border: true,
		list: ((_d$_extend6 = d._extend) === null || _d$_extend6 === void 0 || (_d$_extend6 = _d$_extend6.other) === null || _d$_extend6 === void 0 ? void 0 : _d$_extend6.bundle) || [],
		renderItem: (item) => require_utils$1.renderBundles(item, state.amountSymbol)
	}) : null, d.id || d.isCustomItem ? /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__booking-service-item-price-wrap" }, /* @__PURE__ */ react.default.createElement("span", { className: "pisell-lowcode__booking-service-item-price" }, (0, _pisell_utils.formatAmount)((_d$_extend7 = d._extend) === null || _d$_extend7 === void 0 ? void 0 : _d$_extend7.total, 2, state.amountSymbol)), isDiscount ? /* @__PURE__ */ react.default.createElement("span", { className: "pisell-lowcode__booking-service-item-original-price" }, (0, _pisell_utils.formatAmount)(d._extend.origin_total, 2, state.amountSymbol)) : null)) : null, isDiscount && ((_d$_extend8 = d._extend) === null || _d$_extend8 === void 0 ? void 0 : _d$_extend8.discount_reason) ? /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__booking-service-item-discount-reason" }, /* @__PURE__ */ react.default.createElement("span", null, _pisell_utils.locales.getText("pisell2.text.discount-reason"), ":"), " ", (_d$_extend9 = d._extend) === null || _d$_extend9 === void 0 ? void 0 : _d$_extend9.discount_reason) : null, ((_d$_extend$relation_d = d._extend.relation_details) === null || _d$_extend$relation_d === void 0 ? void 0 : _d$_extend$relation_d.length) ? /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__booking-service-item-relation-details" }, /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__booking-service-item-title" }, _pisell_utils.locales.getText("page.booking.text.sales")), d._extend.relation_details.map((item, index) => {
		return /* @__PURE__ */ react.default.createElement("div", {
			className: "pisell-lowcode__booking-service-item-relation-detail",
			key: item.id
		}, /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__booking-service-item-relation-detail-title" }, item.product_title), /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__booking-service-item-relation-detail-info" }, /* @__PURE__ */ react.default.createElement("span", { className: "pisell-lowcode__booking-service-item-relation-detail-info-price" }, (0, _pisell_utils.formatAmount)(item.payment_price, 2, state.amountSymbol)), /* @__PURE__ */ react.default.createElement("span", { className: "pisell-lowcode__booking-service-item-relation-detail-info-unit" }, "x"), /* @__PURE__ */ react.default.createElement("span", { className: "pisell-lowcode__booking-service-item-relation-detail-info-quantity" }, item.product_quantity)));
	})) : null, /* @__PURE__ */ react.default.createElement(require_index$2.default, { currentService: d }), errorMessage ? /* @__PURE__ */ react.default.createElement(antd.Alert, {
		message: errorMessage,
		type: "warning",
		showIcon: true,
		className: "pisell-lowcode__booking-service-item-error"
	}) : null);
};
//#endregion
exports.default = ServiceItem;
