var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { h } from '@stencil/core';
import { MapToComponentField } from 'vega-slimmer/core';
import { WeekdayLongNames } from '../../../../../helpers/calendar/utils';
import { VegaCalendarDateBlockRenderer, } from '../../common/renderers/vega-calendar-date-block-renderer.abstract';
/** The `VegaCalendarViewWithTimeRenderer` class in TypeScript React renders a day view for a calendar component with title, content, and hour blocks. */
export class VegaCalendarViewWithTimeRenderer extends VegaCalendarDateBlockRenderer {
  /**
   * The render function in TypeScript React returns an array of HTMLElements containing the week calendar view for a specific day.
   *
   * @returns {HTMLElement} An array of HTMLElement elements containing the rendered content of a calendar view for a
   * specific day in the week. The content includes the title and the main content of the calendar view
   * for that day.
   */
  render() {
    return (h("div", { class: "calendar-view-container" },
      this.renderViewTitle(),
      this.renderViewContent()));
  }
  /**
   * emit vega click event when click the date block
   *
   * @param {CalendarDate} calendarDate the calendar date object
   */
  handleDateBlockClick(e, calendarDate, hour) {
    const { year, month, date } = calendarDate;
    const { clientX, clientY } = e;
    const eventInfo = {
      year,
      month,
      date,
      hour,
      mouseEventInfo: { clientX, clientY },
    };
    this.emit(e, eventInfo);
  }
  /**
   * The function `renderViewTitle` renders a calendar view title and events based on the provided source data.
   *
   * @returns {HTMLElement} The `renderViewTitle` function returns an HTML element (HTMLElement) that contains a calendar view title container with rows for each day's information.
   */
  renderViewTitle() {
    const source = this.calendarView.dateItems[0];
    const weekHead = this.calendarView.weekdays;
    return (h("div", { class: "calendar-view-title-container" },
      h("div", { class: "calendar-view-row" },
        h("div", { class: "time-line-empty" }),
        h("div", { class: "calendar-view-title" }, source.map((item, index) => (h("div", { key: item.date, class: { active: item.isToday(this.timezone) }, role: "group", tabIndex: -1, "aria-label": `${this.translationSlimmer.t(WeekdayLongNames[weekHead[index].toLowerCase()])}, ${item.getMonthName()} ${item.date} ${item.year}` },
          h("div", { "aria-hidden": "true" }, this.translationSlimmer.t(weekHead[index])),
          h("div", { class: "week-day", "aria-hidden": "true" }, item.date)))))),
      h("div", { class: "calendar-view-row calendar-view-event-all-container border-divider-bottom" },
        h("div", { class: "time-line-all" }, this.translationSlimmer.t('All Day')),
        this.dayViewFullDayEventRenderer.render())));
  }
  /**
   * The `renderViewContent` function in TypeScript React renders a calendar view with day blocks and time markers based on the provided data.
   *
   * @returns {HTMLElement} An HTMLElement containing a calendar view row with day containers, a timeline renderer, a content container, a day list, and hour blocks for each item in the source array.
   */
  renderViewContent() {
    const source = this.calendarView.dateItems[0];
    return (h("div", { class: "calendar-view-row calendar-view-day-container" },
      this.timeLineRenderer.render(),
      h("div", { class: "calendar-view-content-container" },
        h("div", { class: "calendar-view-content" }, source.map((item) => {
          var _a;
          const isDisabled = (_a = this.isDateDisabled) === null || _a === void 0 ? void 0 : _a.call(this, item.toDate());
          return (h("div", { class: {
              'grid-col border-divider-left': true,
              'disabled': isDisabled,
            }, key: item.date },
            h("div", { class: "hour-empty border-divider-top" }),
            this.renderHourBlock(item, isDisabled)));
        })),
        this.dayViewTimedEventRenderer.render(),
        this.timeMarkerRenderer.render(source))));
  }
  /**
   * The function `renderHourBlock` returns an array of HTML elements representing hour blocks with time information.
   *
   * @param {CalendarDate} calendarDate then current calendar date object
   * @returns {HTMLElement[]} An array of HTMLElements is being returned. Each HTMLElement represents an hour block with a time value inside a div element.
   */
  renderHourBlock(calendarDate, isDisabled) {
    const timeLineSource = Array(24).fill('');
    return timeLineSource.map((_item, index) => {
      var _a;
      let isHourDisabled = false;
      if (!isDisabled) {
        const dateWithHour = new Date(calendarDate.toDate().setHours(index));
        isHourDisabled = (_a = this.isDateDisabled) === null || _a === void 0 ? void 0 : _a.call(this, dateWithHour);
      }
      const renderProps = this.generateDateBlockRenderProps(isDisabled || isHourDisabled, calendarDate, index);
      return (h("div", Object.assign({ key: index, class: {
          'grid-cell border-divider-top': true,
          'disabled': isDisabled || isHourDisabled,
        } }, renderProps)));
    });
  }
}
__decorate([
  MapToComponentField()
], VegaCalendarViewWithTimeRenderer.prototype, "viewMode", void 0);
__decorate([
  MapToComponentField()
], VegaCalendarViewWithTimeRenderer.prototype, "timeLineRenderer", void 0);
__decorate([
  MapToComponentField()
], VegaCalendarViewWithTimeRenderer.prototype, "timeMarkerRenderer", void 0);
__decorate([
  MapToComponentField()
], VegaCalendarViewWithTimeRenderer.prototype, "dayViewTimedEventRenderer", void 0);
__decorate([
  MapToComponentField()
], VegaCalendarViewWithTimeRenderer.prototype, "dayViewFullDayEventRenderer", void 0);
__decorate([
  MapToComponentField()
], VegaCalendarViewWithTimeRenderer.prototype, "calendarView", void 0);
__decorate([
  MapToComponentField()
], VegaCalendarViewWithTimeRenderer.prototype, "translationSlimmer", void 0);
__decorate([
  MapToComponentField()
], VegaCalendarViewWithTimeRenderer.prototype, "isDateDisabled", void 0);
__decorate([
  MapToComponentField()
], VegaCalendarViewWithTimeRenderer.prototype, "enableDateClick", void 0);
__decorate([
  MapToComponentField()
], VegaCalendarViewWithTimeRenderer.prototype, "timezone", void 0);
