/**
 * @license
 * Copyright Endlessjs. All Rights Reserved.
 * Licensed under the MIT License. See License.txt in the project root for license information.
 */
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;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { Component, EventEmitter, HostBinding, Input, Output, Type } from '@angular/core';
import { YEARS_IN_VIEW } from '../calendar-kit/components/calendar-year-picker/calendar-year-picker.component';
import { ElCalendarSize, ElCalendarViewMode } from '../calendar-kit/model';
import { ElDateService } from '../calendar-kit/services/date.service';
import { convertToBoolProperty } from '../helpers';
/**
 * The basis for calendar and range calendar components.
 * Encapsulates common behavior - store calendar state and perform navigation
 * between pickers.
 * */
var ElBaseCalendarComponent = /** @class */ (function () {
    function ElBaseCalendarComponent(dateService) {
        this.dateService = dateService;
        /**
         * Defines if we should render previous and next months
         * in the current month view.
         * */
        this.boundingMonth = true;
        /**
         * Defines active view for calendar.
         * */
        this.activeViewMode = ElCalendarViewMode.DATE;
        /**
         * Size of the calendar and entire components.
         * Can be 'medium' which is default or 'large'.
         * */
        this.size = ElCalendarSize.MEDIUM;
        /**
         * Determines should we show calendars header or not.
         * */
        this.showHeader = true;
        this._showWeekNumber = false;
        /**
         * Emits date when selected.
         * */
        this.dateChange = new EventEmitter();
        this.ViewMode = ElCalendarViewMode;
    }
    Object.defineProperty(ElBaseCalendarComponent.prototype, "showWeekNumber", {
        /**
         * Determines should we show week numbers column.
         * False by default.
         * */
        get: function () {
            return this._showWeekNumber;
        },
        set: function (value) {
            this._showWeekNumber = convertToBoolProperty(value);
        },
        enumerable: true,
        configurable: true
    });
    ElBaseCalendarComponent.prototype.ngOnInit = function () {
        if (!this.visibleDate) {
            this.visibleDate = this.dateService.today();
        }
    };
    Object.defineProperty(ElBaseCalendarComponent.prototype, "medium", {
        get: function () {
            return this.size === ElCalendarSize.MEDIUM;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ElBaseCalendarComponent.prototype, "large", {
        get: function () {
            return this.size === ElCalendarSize.LARGE;
        },
        enumerable: true,
        configurable: true
    });
    ElBaseCalendarComponent.prototype.setViewMode = function (viewMode) {
        this.activeViewMode = viewMode;
    };
    ElBaseCalendarComponent.prototype.setVisibleDate = function (visibleDate) {
        this.visibleDate = visibleDate;
    };
    ElBaseCalendarComponent.prototype.prevMonth = function () {
        this.changeVisibleMonth(-1);
    };
    ElBaseCalendarComponent.prototype.nextMonth = function () {
        this.changeVisibleMonth(1);
    };
    ElBaseCalendarComponent.prototype.prevYears = function () {
        this.changeVisibleYear(-1);
    };
    ElBaseCalendarComponent.prototype.nextYears = function () {
        this.changeVisibleYear(1);
    };
    ElBaseCalendarComponent.prototype.navigateToday = function () {
        this.setViewMode(ElCalendarViewMode.DATE);
        this.visibleDate = this.dateService.today();
    };
    ElBaseCalendarComponent.prototype.changeVisibleMonth = function (direction) {
        this.visibleDate = this.dateService.addMonth(this.visibleDate, direction);
    };
    ElBaseCalendarComponent.prototype.changeVisibleYear = function (direction) {
        this.visibleDate = this.dateService.addYear(this.visibleDate, direction * YEARS_IN_VIEW);
    };
    __decorate([
        Input(),
        __metadata("design:type", Boolean)
    ], ElBaseCalendarComponent.prototype, "boundingMonth", void 0);
    __decorate([
        Input('startView'),
        __metadata("design:type", String)
    ], ElBaseCalendarComponent.prototype, "activeViewMode", void 0);
    __decorate([
        Input(),
        __metadata("design:type", Object)
    ], ElBaseCalendarComponent.prototype, "min", void 0);
    __decorate([
        Input(),
        __metadata("design:type", Object)
    ], ElBaseCalendarComponent.prototype, "max", void 0);
    __decorate([
        Input(),
        __metadata("design:type", Function)
    ], ElBaseCalendarComponent.prototype, "filter", void 0);
    __decorate([
        Input(),
        __metadata("design:type", Type)
    ], ElBaseCalendarComponent.prototype, "dayCellComponent", void 0);
    __decorate([
        Input(),
        __metadata("design:type", Type)
    ], ElBaseCalendarComponent.prototype, "monthCellComponent", void 0);
    __decorate([
        Input(),
        __metadata("design:type", Type)
    ], ElBaseCalendarComponent.prototype, "yearCellComponent", void 0);
    __decorate([
        Input(),
        __metadata("design:type", String)
    ], ElBaseCalendarComponent.prototype, "size", void 0);
    __decorate([
        Input(),
        __metadata("design:type", Object)
    ], ElBaseCalendarComponent.prototype, "visibleDate", void 0);
    __decorate([
        Input(),
        __metadata("design:type", Boolean)
    ], ElBaseCalendarComponent.prototype, "showHeader", void 0);
    __decorate([
        Input(),
        __metadata("design:type", Object)
    ], ElBaseCalendarComponent.prototype, "date", void 0);
    __decorate([
        Input(),
        HostBinding('class.has-week-number'),
        __metadata("design:type", Boolean),
        __metadata("design:paramtypes", [Boolean])
    ], ElBaseCalendarComponent.prototype, "showWeekNumber", null);
    __decorate([
        Input(),
        __metadata("design:type", String)
    ], ElBaseCalendarComponent.prototype, "weekNumberSymbol", void 0);
    __decorate([
        Output(),
        __metadata("design:type", EventEmitter)
    ], ElBaseCalendarComponent.prototype, "dateChange", void 0);
    __decorate([
        HostBinding('class.medium'),
        __metadata("design:type", Object),
        __metadata("design:paramtypes", [])
    ], ElBaseCalendarComponent.prototype, "medium", null);
    __decorate([
        HostBinding('class.large'),
        __metadata("design:type", Object),
        __metadata("design:paramtypes", [])
    ], ElBaseCalendarComponent.prototype, "large", null);
    ElBaseCalendarComponent = __decorate([
        Component({
            selector: 'el-base-calendar',
            template: "<el-card>\n  <el-card-header *ngIf=\"showHeader\">\n    <el-calendar-header (navigateToday)=\"navigateToday()\"></el-calendar-header>\n  </el-card-header>\n\n  <el-card-body [ngSwitch]=\"activeViewMode\">\n\n    <ng-container *ngSwitchCase=\"ViewMode.DATE\">\n\n      <el-calendar-pageable-navigation\n        *ngSwitchCase=\"ViewMode.DATE\"\n        [date]=\"visibleDate\"\n        (next)=\"nextMonth()\"\n        (prev)=\"prevMonth()\"\n        (changeMode)=\"setViewMode(ViewMode.YEAR)\">\n      </el-calendar-pageable-navigation>\n\n      <el-calendar-day-picker\n        [boundingMonths]=\"boundingMonth\"\n        [cellComponent]=\"dayCellComponent\"\n        [min]=\"min\"\n        [max]=\"max\"\n        [filter]=\"filter\"\n        [visibleDate]=\"visibleDate\"\n        [size]=\"size\"\n        [date]=\"date\"\n        [showWeekNumber]=\"showWeekNumber\"\n        (dateChange)=\"dateChange.emit($event)\"\n        [weekNumberSymbol]=\"weekNumberSymbol\">\n      </el-calendar-day-picker>\n\n    </ng-container>\n\n    <ng-container *ngSwitchCase=\"ViewMode.YEAR\">\n\n      <el-calendar-pageable-navigation\n        [date]=\"visibleDate\"\n        (next)=\"nextYears()\"\n        (prev)=\"prevYears()\"\n        (changeMode)=\"setViewMode(ViewMode.DATE)\">\n      </el-calendar-pageable-navigation>\n\n      <el-calendar-year-picker\n        [cellComponent]=\"yearCellComponent\"\n        [date]=\"date\"\n        [min]=\"min\"\n        [max]=\"max\"\n        [filter]=\"filter\"\n        [size]=\"size\"\n        [year]=\"visibleDate\"\n        (yearChange)=\"setVisibleDate($event); setViewMode(ViewMode.MONTH)\">\n      </el-calendar-year-picker>\n\n    </ng-container>\n\n    <ng-container *ngSwitchCase=\"ViewMode.MONTH\">\n\n      <el-calendar-navigation\n        [date]=\"visibleDate\"\n        (changeMode)=\"setViewMode(ViewMode.DATE)\">\n      </el-calendar-navigation>\n\n      <el-calendar-month-picker\n        [cellComponent]=\"monthCellComponent\"\n        [min]=\"min\"\n        [max]=\"max\"\n        [filter]=\"filter\"\n        [size]=\"size\"\n        [month]=\"visibleDate\"\n        (monthChange)=\"setVisibleDate($event); setViewMode(ViewMode.DATE)\">\n      </el-calendar-month-picker>\n\n    </ng-container>\n\n  </el-card-body>\n\n</el-card>\n"
        }),
        __metadata("design:paramtypes", [ElDateService])
    ], ElBaseCalendarComponent);
    return ElBaseCalendarComponent;
}());
export { ElBaseCalendarComponent };
//# sourceMappingURL=base-calendar.component.js.map