/** This code snippet is defining an abstract class named `VegaCalendarBaseEventLayoutCell`. Here's a breakdown of what it does: */
export class VegaCalendarBaseEventLayoutCell {
  /**
   * This function retrieves a calendar event based on the slot index provided.
   *
   * @param {number} index - The `index` parameter is a number that represents the position of a slot in an array.
   * @returns {Nullable<CalendarEvent>} The `getEventBySlotIndex` method is returning a `CalendarEvent` object from the `slots` array at the specified `index`.
   */
  getEventBySlotIndex(index) {
    return this.slots[index];
  }
  /**
   * The function `getEventStartIndex` returns the index of a given `CalendarEvent` object within an array of `CalendarEvent` objects.
   *
   * @param {CalendarEvent} eventItem - CalendarEvent
   * @returns {number} The function `getEventStartIndex` returns the index of the `eventItem` within the `slots` array.
   */
  getEventStartIndex(eventItem) {
    return this.slots.findIndex((item) => item === eventItem);
  }
  /**
   * This TypeScript function calculates the end index of a calendar event within a specified range of slots.
   *
   * @param {CalendarEvent} eventItem - CalendarEvent - the event item for which we want to find the end index in the calendar.
   * @returns {number} The `getEventEndIndex` function returns the index of the end of the calendar event in the `VegaCalendarLongEventLayoutRow.defaultSlots` array.
   */
  getEventEndIndex(eventItem) {
    const startIndex = this.getEventStartIndex(eventItem);
    let endIndex = startIndex;
    if (startIndex >= 0) {
      for (let i = startIndex + 1; i < this.slots.length; i++) {
        if (this.slots[i] !== eventItem) {
          endIndex = i - 1;
          break;
        }
        else if (i === this.slots.length - 1) {
          endIndex = i;
        }
      }
    }
    return endIndex;
  }
}
