/**
 * @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 { ChangeDetectionStrategy, Component, EventEmitter, HostBinding, Input, Output, Type, } from '@angular/core';
import { batch, range } from '../../helpers';
import { ElCalendarSize } from '../../model';
import { ElCalendarYearCellComponent } from './calendar-year-cell.component';
import { ElDateService } from '../../services/date.service';
export var YEARS_IN_VIEW = 20;
export var YEARS_IN_COLUMN = 4;
var ElCalendarYearPickerComponent = /** @class */ (function () {
    function ElCalendarYearPickerComponent(dateService) {
        this.dateService = dateService;
        this.cellComponent = ElCalendarYearCellComponent;
        this.size = ElCalendarSize.MEDIUM;
        this.yearChange = new EventEmitter();
    }
    Object.defineProperty(ElCalendarYearPickerComponent.prototype, "_cellComponent", {
        set: function (cellComponent) {
            if (cellComponent) {
                this.cellComponent = cellComponent;
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ElCalendarYearPickerComponent.prototype, "medium", {
        get: function () {
            return this.size === ElCalendarSize.MEDIUM;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ElCalendarYearPickerComponent.prototype, "large", {
        get: function () {
            return this.size === ElCalendarSize.LARGE;
        },
        enumerable: true,
        configurable: true
    });
    ElCalendarYearPickerComponent.prototype.ngOnChanges = function () {
        this.initYears();
    };
    ElCalendarYearPickerComponent.prototype.initYears = function () {
        var _this = this;
        var selectedYear = this.dateService.getYear(this.year);
        var startYear = Math.ceil(selectedYear - YEARS_IN_VIEW / 2);
        var years = range(YEARS_IN_VIEW).map(function (i) { return _this.createYearDateByIndex(i + startYear); });
        this.years = batch(years, YEARS_IN_COLUMN);
    };
    ElCalendarYearPickerComponent.prototype.onSelect = function (year) {
        this.yearChange.emit(year);
    };
    ElCalendarYearPickerComponent.prototype.createYearDateByIndex = function (i) {
        return this.dateService.createDate(i, this.dateService.getMonth(this.year), this.dateService.getDate(this.year));
    };
    __decorate([
        Input(),
        __metadata("design:type", Object)
    ], ElCalendarYearPickerComponent.prototype, "date", void 0);
    __decorate([
        Input(),
        __metadata("design:type", Object)
    ], ElCalendarYearPickerComponent.prototype, "min", void 0);
    __decorate([
        Input(),
        __metadata("design:type", Object)
    ], ElCalendarYearPickerComponent.prototype, "max", void 0);
    __decorate([
        Input(),
        __metadata("design:type", Function)
    ], ElCalendarYearPickerComponent.prototype, "filter", void 0);
    __decorate([
        Input('cellComponent'),
        __metadata("design:type", Type),
        __metadata("design:paramtypes", [Type])
    ], ElCalendarYearPickerComponent.prototype, "_cellComponent", null);
    __decorate([
        Input(),
        __metadata("design:type", String)
    ], ElCalendarYearPickerComponent.prototype, "size", void 0);
    __decorate([
        Input(),
        __metadata("design:type", Object)
    ], ElCalendarYearPickerComponent.prototype, "year", void 0);
    __decorate([
        Output(),
        __metadata("design:type", Object)
    ], ElCalendarYearPickerComponent.prototype, "yearChange", void 0);
    __decorate([
        HostBinding('class.medium'),
        __metadata("design:type", Object),
        __metadata("design:paramtypes", [])
    ], ElCalendarYearPickerComponent.prototype, "medium", null);
    __decorate([
        HostBinding('class.large'),
        __metadata("design:type", Object),
        __metadata("design:paramtypes", [])
    ], ElCalendarYearPickerComponent.prototype, "large", null);
    ElCalendarYearPickerComponent = __decorate([
        Component({
            selector: 'el-calendar-year-picker',
            template: "\n    <el-calendar-picker\n      [data]=\"years\"\n      [min]=\"min\"\n      [max]=\"max\"\n      [filter]=\"filter\"\n      [selectedValue]=\"date\"\n      [visibleDate]=\"year\"\n      [cellComponent]=\"cellComponent\"\n      (select)=\"onSelect($event)\">\n    </el-calendar-picker>\n  ",
            changeDetection: ChangeDetectionStrategy.OnPush
        }),
        __metadata("design:paramtypes", [ElDateService])
    ], ElCalendarYearPickerComponent);
    return ElCalendarYearPickerComponent;
}());
export { ElCalendarYearPickerComponent };
//# sourceMappingURL=calendar-year-picker.component.js.map