"use client";
import { cn } from "./index3.js";
import { useCalendarContext } from "./index76.js";
import * as React from "react";
import { jsx } from "react/jsx-runtime";
import { endOfWeek, format, isSameMonth, startOfWeek } from "date-fns";
//#region src/components/molecules/data/Calendar/CalendarTitle.tsx
function CalendarTitle({ className }) {
	const { view, selectedDate, weekStartsOn } = useCalendarContext();
	const title = React.useMemo(() => {
		switch (view) {
			case "month": return format(selectedDate, "MMMM yyyy");
			case "week": {
				const weekStart = startOfWeek(selectedDate, { weekStartsOn });
				const weekEnd = endOfWeek(selectedDate, { weekStartsOn });
				if (isSameMonth(weekStart, weekEnd)) return `${format(weekStart, "MMMM d")} – ${format(weekEnd, "d, yyyy")}`;
				return `${format(weekStart, "MMM d")} – ${format(weekEnd, "MMM d, yyyy")}`;
			}
			case "day": return format(selectedDate, "EEEE, MMMM d, yyyy");
		}
	}, [
		view,
		selectedDate,
		weekStartsOn
	]);
	return /* @__PURE__ */ jsx("h2", {
		"data-slot": "calendar-title",
		className: cn("text-base font-semibold text-foreground", className),
		children: title
	});
}
CalendarTitle.displayName = "CalendarTitle";
//#endregion
export { CalendarTitle };

//# sourceMappingURL=index74.js.map