"use client";
import { CalendarDay as F } from "../classes/CalendarDay.js";
import { CalendarWeek as N } from "../classes/CalendarWeek.js";
import { CalendarMonth as P } from "../classes/CalendarMonth.js";
function j(l, f, e, c) {
  const { addDays: y, endOfBroadcastWeek: D, endOfISOWeek: h, endOfMonth: k, endOfWeek: C, getISOWeek: I, getWeek: M, startOfBroadcastWeek: S, startOfISOWeek: g, startOfWeek: w } = c, o = l.reduce((W, t) => {
    const x = e.broadcastCalendar ? S(t, c) : e.ISOWeek ? g(t) : w(t), d = e.broadcastCalendar ? D(t) : e.ISOWeek ? h(k(t)) : C(k(t)), s = f.filter((r) => r >= x && r <= d), i = e.broadcastCalendar ? 35 : 42;
    if (e.fixedWeeks && s.length < i) {
      const r = f.filter((n) => {
        const a = i - s.length;
        return n > d && n <= y(d, a);
      });
      s.push(...r);
    }
    const b = s.reduce((r, n) => {
      const a = e.ISOWeek ? I(n) : M(n), u = r.find((B) => B.weekNumber === a), O = new F(n, t, c);
      return u ? u.days.push(O) : r.push(new N(a, [O])), r;
    }, []), v = new P(t, b);
    return W.push(v), W;
  }, []);
  return e.reverseMonths ? o.reverse() : o;
}
export {
  j as getMonths
};
