import { useMonth } from "@datepicker-react/hooks";
import { SizableText, Stack, XStack } from "tamagui";
import { useMemo } from "react";
import { Day } from "./Day.mjs";
import { jsx, jsxs } from "react/jsx-runtime";
function Month({
  year,
  ...props
}) {
  const {
      days,
      weekdayLabels
    } = useMonth({
      ...props,
      year,
      dayLabelFormat: date => new Intl.DateTimeFormat(void 0, {
        day: "numeric"
      }).format(date),
      weekdayLabelFormat: date => new Intl.DateTimeFormat(void 0, {
        weekday: "narrow"
      }).format(date)
    }),
    weeks = useMemo(() => splitIntoWeeks(days), [days]);
  return /* @__PURE__ */jsxs(Stack, {
    maxWidth: "100%",
    flexDirection: "column",
    gap: 12,
    children: [/* @__PURE__ */jsx(XStack, {
      pb: 16,
      children: weekdayLabels.map((dayLabel, index) => /* @__PURE__ */jsx(SizableText, {
        w: "14%",
        ta: "center",
        col: "$onSurfaceVariant",
        children: dayLabel
      }, `day-label-${index}`))
    }), weeks.map((week, index) => /* @__PURE__ */jsx(XStack, {
      children: week.map((day, index2) => /* @__PURE__ */jsx(Stack, {
        w: "14%",
        ai: "center",
        children: typeof day == "object" && /* @__PURE__ */jsx(Day, {
          dayLabel: day.dayLabel,
          date: day.date
        }, day.date.toString())
      }, `month-day-${index2}`))
    }, `week-${index}`))]
  });
}
function splitIntoWeeks(array) {
  const result = [];
  for (let i = 0; i < array.length; i += 7) {
    const week = array.slice(i, i + 7);
    result.push(week);
  }
  return result;
}
export { Month };
//# sourceMappingURL=Month.mjs.map
