const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_utils = require("../../utils.js");
const require_index = require("../Divider/index.js");
const require_index$1 = require("./components/Like/index.js");
const require_index$2 = require("./components/SelectResource/index.js");
const require_index$3 = require("./components/SelectHolder/index.js");
const require_index$4 = require("./components/SelectHolderMultiple/index.js");
let react = require("react");
react = require_runtime.__toESM(react);
require("./index.less");
//#region src/components/productCard/components/Time/index.tsx
const prefix = "pisell-lowcode-";
const Time = ({ item, isShowHolder, onLike, isShowChangeResource, changeResource, changeHolder, isShowChangeHolder, holderMode, onAddHolder, isShowAddHolderButton, onClearHolder, onClearResource }) => {
	const { start_date, end_date, holder_title, resource_id, relation_form_name, like_status, resources, is_hide_like, holder_id, holders, multiResources, addHolderButtonText, isErrorHolder, allowClearHolder, allowClearResource, isErrorResource, resourceErrorText, isMultipleResource, isShowChangeHolder: itemIsShowChangeHolder = true, holderMode: itemHolderMode, holderMaxCount } = item;
	const holderCom = (0, react.useMemo)(() => {
		if (!isShowHolder) return null;
		if (isShowChangeHolder && itemIsShowChangeHolder) {
			const Cpt = (itemHolderMode || holderMode) === "multiple" ? require_index$4.default : require_index$3.default;
			return /* @__PURE__ */ react.default.createElement(Cpt, {
				holderMaxCount,
				lists: holders,
				value: holder_id,
				onChange: changeHolder,
				holderMode: itemHolderMode || holderMode,
				isShowAddHolderButton,
				onAddHolder,
				addHolderButtonText,
				onClearHolder,
				isErrorHolder,
				allowClear: allowClearHolder
			});
		}
		if (holder_title) return /* @__PURE__ */ react.default.createElement("div", { className: `${prefix}product-holder-wrap` }, holder_title);
	}, [
		isShowHolder,
		holder_id,
		holder_title,
		holderMode,
		holders,
		isShowAddHolderButton,
		isShowChangeHolder,
		isErrorHolder,
		addHolderButtonText,
		allowClearHolder,
		itemIsShowChangeHolder,
		itemHolderMode,
		holderMaxCount
	]);
	const likeCom = (0, react.useCallback)((status, item) => {
		return /* @__PURE__ */ react.default.createElement(require_index$1.default, {
			isShowChangeResource,
			style: { marginRight: 4 },
			status,
			onLike: (e) => {
				onLike(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, { like_status: e }));
			}
		});
	}, [isShowChangeResource]);
	const resourceCom = (0, react.useCallback)((item) => {
		if ((item === null || item === void 0 ? void 0 : item.hasOwnProperty("isShowChangeResource")) && !item.isShowChangeResource || !isShowChangeResource) return item === null || item === void 0 ? void 0 : item.name;
		return /* @__PURE__ */ react.default.createElement(require_index$2.default, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, {
			lists: item === null || item === void 0 ? void 0 : item.lists,
			value: item === null || item === void 0 ? void 0 : item.id,
			onChange: changeResource,
			onClearResource,
			allowClear: item === null || item === void 0 ? void 0 : item.allowClearResource,
			isErrorResource: item === null || item === void 0 ? void 0 : item.isErrorResource,
			resourceErrorText: item === null || item === void 0 ? void 0 : item.resourceErrorText,
			resourceMode: item.resourceMode,
			maxLength: item.maxLength
		}));
	}, [isShowChangeResource]);
	const likeAndResourceCom = (0, react.useMemo)(() => {
		if (isMultipleResource) {
			if ((multiResources === null || multiResources === void 0 ? void 0 : multiResources.length) > 0) return multiResources.map((resourceItem) => {
				return /* @__PURE__ */ react.default.createElement("div", { key: (resourceItem === null || resourceItem === void 0 ? void 0 : resourceItem.id) + (resourceItem === null || resourceItem === void 0 ? void 0 : resourceItem._id) }, (resourceItem === null || resourceItem === void 0 ? void 0 : resourceItem.id) && !is_hide_like && !resourceItem.is_hide_like ? likeCom(resourceItem === null || resourceItem === void 0 ? void 0 : resourceItem.status, resourceItem) : null, resourceCom(resourceItem));
			});
			return null;
		}
		const _resourceCom = resourceCom({
			name: relation_form_name,
			id: resource_id,
			lists: resources,
			allowClearResource,
			isErrorResource,
			resourceErrorText
		});
		return resource_id && !is_hide_like || _resourceCom ? /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, resource_id && !is_hide_like ? likeCom(like_status, item) : null, _resourceCom) : null;
	}, [
		multiResources,
		resource_id,
		resources,
		relation_form_name,
		is_hide_like,
		isShowChangeResource,
		isMultipleResource,
		allowClearResource,
		isErrorResource,
		resourceErrorText
	]);
	return (0, react.useMemo)(() => {
		return start_date && end_date || holderCom || likeAndResourceCom;
	}, [
		start_date,
		holderCom,
		likeAndResourceCom
	]) ? /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement(require_index.default, null), /* @__PURE__ */ react.default.createElement("div", { className: `${prefix}product-time-wrap` }, start_date && end_date ? /* @__PURE__ */ react.default.createElement("div", { className: `${prefix}product-date` }, require_utils.getServiceTime(item, start_date)) : null, holderCom, likeAndResourceCom ? /* @__PURE__ */ react.default.createElement("div", { className: `${prefix}product-technician ${isShowChangeResource ? "pisell-lowcode-change-resource" : ""} ${(multiResources === null || multiResources === void 0 ? void 0 : multiResources.length) > 0 ? "pisell-lowcode-multi-resources" : ""}` }, likeAndResourceCom) : null)) : null;
};
//#endregion
exports.default = Time;
