const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_utils = require("../products/utils.js");
let dayjs = require("dayjs");
dayjs = require_runtime.__toESM(dayjs);
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
//#region src/components/schedules/calendar/calendarItem.tsx
const CalendarItem = (props) => {
	const { month, schedulesData, selectDate, onSelect, isEdit } = props;
	const scheduleMap = (0, react.useMemo)(() => new Map(schedulesData.map((schedule) => [schedule.date, schedule])), [schedulesData]);
	let startDate = (0, dayjs.default)(month).startOf("month").format("YYYY-MM-DD");
	let endDate = (0, dayjs.default)(month).endOf("month").format("YYYY-MM-DD");
	return /* @__PURE__ */ react.default.createElement("div", { className: "month-item" }, /* @__PURE__ */ react.default.createElement("div", { className: "caleddar-month" }, (0, dayjs.default)(month).format("MMMM")), /* @__PURE__ */ react.default.createElement(antd.Calendar, {
		headerRender: () => null,
		fullscreen: false,
		value: (0, dayjs.default)(month),
		disabledDate: (currentDate) => {
			return currentDate.isAfter(endDate) || currentDate.isBefore(startDate);
		},
		fullCellRender: (e) => {
			const currentDayText = e.format("YYYY-MM-DD");
			const currentDayData = scheduleMap.get(currentDayText);
			const isCurrentMonth = e.format("YYYY-MM") === month;
			const isSelectDate = currentDayText === selectDate;
			const isExcluded = currentDayData === null || currentDayData === void 0 ? void 0 : currentDayData.isExcluded;
			let style = {};
			const colors = !isEdit ? ["#7D89B0"] : (currentDayData === null || currentDayData === void 0 ? void 0 : currentDayData.color) || [];
			style = { background: require_utils.formatBackgroundColors(colors) };
			if (e.isAfter(endDate) || e.isBefore(startDate)) return e.date();
			return /* @__PURE__ */ react.default.createElement("div", {
				className: `caleddar-date-cell ${isSelectDate ? "select" : ""} ${isExcluded ? "excluded" : ""}`,
				onClick: () => onSelect(currentDayText, scheduleMap.get(currentDayText))
			}, /* @__PURE__ */ react.default.createElement("div", {
				className: `caleddar-date ${colors.filter(Boolean).length ? "has-status" : ""} ${isCurrentMonth ? "" : "disabled-date"}`,
				style
			}, e.date()));
		}
	}));
};
//#endregion
exports.default = CalendarItem;
