const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
const require_utils = require("../../schedules/utils.js");
let dayjs = require("dayjs");
dayjs = require_runtime.__toESM(dayjs);
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _pisell_utils = require("@pisell/utils");
require("./index.less");
//#region src/components/schedules/components/ScheduleDetailList/index.tsx
const formatTimeAmPm = (str) => {
	return (0, dayjs.default)(str).format("hh:mm A");
};
const startEndTime = (start, end) => {
	return `${formatTimeAmPm(start)} - ${formatTimeAmPm(end)}`;
};
const ScheduleTimeItem = (props) => {
	var _scheduleMap$item$id;
	const { item, scheduleMap } = props;
	const renderFormat = ((_scheduleMap$item$id = scheduleMap[item.id]) === null || _scheduleMap$item$id === void 0 ? void 0 : _scheduleMap$item$id.dateRangeFormat) || [];
	if (!renderFormat.length || renderFormat.some((item) => require_utils.isAllDay({
		start_time: item.start,
		end_time: item.end
	}))) return /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__schedule-detail-item-time-item" }, _pisell_utils.locales.getText("pisell2.text.schedules.all-day"));
	return renderFormat.map((item) => {
		return /* @__PURE__ */ react.default.createElement("div", {
			className: "pisell-lowcode__schedule-detail-item-time-item",
			key: item.start + item.end
		}, require_utils.isAllDay({
			start_time: item.start,
			end_time: item.end
		}) ? _pisell_utils.locales.getText("pisell2.text.schedules.all-day") : startEndTime(item.start, item.end));
	});
};
/**
* 日程列表 展示日程中详细时间段信息
* @param props
* @constructor
*/
const ScheduleDetailList = (props) => {
	const { dataSource, onOpenDetail, loading, scheduleMap } = props;
	const content = (0, react.useMemo)(() => {
		return dataSource.map((item) => {
			return /* @__PURE__ */ react.default.createElement("div", {
				className: "pisell-lowcode__schedule-detail-item",
				key: item.id
			}, /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__schedule-detail-item-title" }, /* @__PURE__ */ react.default.createElement("div", {
				className: "pisell-lowcode__schedule-detail-item-title-color",
				style: { backgroundColor: item.color }
			}), /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__schedule-detail-item-title-name" }, item.name)), /* @__PURE__ */ react.default.createElement(ScheduleTimeItem, {
				item,
				scheduleMap
			}), /* @__PURE__ */ react.default.createElement(antd.Button, {
				className: "pisell-lowcode__schedule-detail-item-button",
				onClick: () => onOpenDetail === null || onOpenDetail === void 0 ? void 0 : onOpenDetail(item.id),
				size: "large"
			}, _pisell_utils.locales.getText("pisell2.text.schedules.edit-schedule")));
		});
	}, [dataSource, scheduleMap]);
	return /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__schedule-detail-list" }, loading ? /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__schedule-detail-item" }, /* @__PURE__ */ react.default.createElement(antd.Skeleton, null)) : content);
};
//#endregion
exports.default = ScheduleDetailList;
