import { eachDayOfInterval, endOfMonth, endOfWeek, parseISO, startOfMonth, startOfWeek } from "date-fns";
//#region src/components/molecules/data/Calendar/_shared/date-helpers.ts
/** Stable date key for Map lookups (avoids string allocation per isSameDay). */
function getDateKey(date) {
	return `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`;
}
function parseEventDate(date) {
	if (typeof date === "string") return parseISO(date);
	return date;
}
function getEventHour(date) {
	const d = parseEventDate(date);
	return d.getHours() + d.getMinutes() / 60;
}
function getEventDuration(start, end) {
	if (!end) return 1;
	const startDate = parseEventDate(start);
	return (parseEventDate(end).getTime() - startDate.getTime()) / (1e3 * 60 * 60);
}
function formatHour(hour) {
	if (hour === 0 || hour === 24) return "12 AM";
	if (hour === 12) return "12 PM";
	if (hour > 12) return `${hour - 12} PM`;
	return `${hour} AM`;
}
/** Build a grid of weeks for a month calendar. Returns array of 7-day week arrays. */
function buildCalendarGrid(referenceDate, weekStartsOn) {
	const monthStart = startOfMonth(referenceDate);
	const monthEnd = endOfMonth(referenceDate);
	const days = eachDayOfInterval({
		start: startOfWeek(monthStart, { weekStartsOn }),
		end: endOfWeek(monthEnd, { weekStartsOn })
	});
	const weeks = [];
	for (let i = 0; i < days.length; i += 7) weeks.push(days.slice(i, i + 7));
	return weeks;
}
//#endregion
export { buildCalendarGrid, formatHour, getDateKey, getEventDuration, getEventHour, parseEventDate };

//# sourceMappingURL=index57.js.map