import { CalendarViewGenerator } from './calendar-view-generator.abstract';
import { CalendarDate } from '../calendar-date';
import { CalendarView } from '../calendar-view';
/**
 * Calendar week view generator
 */
export class WeekViewGenerator extends CalendarViewGenerator {
  /**
   * @inheritDoc
   */
  generate(period) {
    const dates = this.generateDates(period);
    const showWeekends = period.showWeekends;
    let weekDays = this.generateWeekHead();
    let dateItems = [dates.map((date) => CalendarDate.from(date))];
    if (showWeekends === false) {
      weekDays = weekDays.slice(1, 6);
      dateItems = dateItems.map((items) => items.slice(1, 6));
    }
    return new CalendarView(weekDays, dateItems);
  }
}
