import { VegaCalendarBaseEventLayoutCell } from './base-event-layout-cell';
/** The `VegaCalendarLongEventLayoutRow` class in TypeScript manages the layout of long events in a calendar by updating slots and checking for overlaps. */
export class VegaCalendarFullDayEventLayoutRow extends VegaCalendarBaseEventLayoutCell {
  constructor() {
    super(...arguments);
    this.slots = VegaCalendarFullDayEventLayoutRow.defaultSlots;
  }
  /**
   * The function `updateRowSlots` updates a row of slots in a calendar view with a long event.
   *
   * @param {VegaCalendarFullDayEventView} eventView - The `eventView` parameter in the `updateRowSlots` method is of type `VegaCalendarFullDayEventView`. It contains information about a long event in a
   */
  updateSlots(eventView) {
    const { start, end } = eventView;
    this.slots = this.slots
      .slice(0, start)
      .concat(Array(end - start + 1).fill(eventView.event), this.slots.slice(end + 1));
  }
  /**
   * The function checks if a given event overlaps with existing events in a calendar view.
   *
   * @param {VegaCalendarFullDayEventView} eventView - The `eventView` parameter in the `hasOverlapEvent`
   * function represents a view of a long event in a Vega calendar. It contains the `start` and `end`
   * properties which specify the start and end times of the event. The function checks if there is any
   * overlap with existing events in
   * @returns {boolean} The function `hasOverlapEvent` returns a boolean value indicating whether there is an
   * overlap in the slots between the start and end times of the given `VegaCalendarFullDayEventView` event.
   */
  hasOverlapEvent(eventView) {
    const { start, end } = eventView;
    let overlapFlag = false;
    for (let i = start; i < end + 1; i++) {
      if (this.slots[i]) {
        overlapFlag = true;
        break;
      }
    }
    return overlapFlag;
  }
}
VegaCalendarFullDayEventLayoutRow.defaultSlots = Array(7).fill(null);
