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, HostListener, Input, Output, } from '@angular/core';
import { ElDateService } from '../calendar-kit/services/date.service';
let ElCalendarRangeDayCellComponent = class ElCalendarRangeDayCellComponent {
    constructor(dateService) {
        this.dateService = dateService;
        this.select = new EventEmitter(true);
    }
    get inRange() {
        return this.date && this.selectedValue
            && (this.selectedValue.start && this.dateService.compareDates(this.date, this.selectedValue.start) >= 0)
            && (this.selectedValue.end && this.dateService.compareDates(this.date, this.selectedValue.end) <= 0);
    }
    get start() {
        return this.date && this.selectedValue && this.selectedValue.end
            && (this.selectedValue.start && this.dateService.isSameDay(this.date, this.selectedValue.start));
    }
    get end() {
        return this.date && this.selectedValue &&
            (this.selectedValue.end && this.dateService.isSameDay(this.date, this.selectedValue.end));
    }
    get today() {
        return this.date && this.dateService.isSameDay(this.date, this.dateService.today());
    }
    get boundingMonth() {
        return !this.dateService.isSameMonthSafe(this.date, this.visibleDate);
    }
    get selected() {
        return this.date && this.selectedValue
            && (this.selectedValue.start && this.dateService.isSameDay(this.date, this.selectedValue.start)) || this.end;
    }
    get empty() {
        return !this.date;
    }
    get disabled() {
        return this.smallerThanMin() || this.greaterThanMax() || this.dontFitFilter();
    }
    get day() {
        return this.date && this.dateService.getDate(this.date);
    }
    onClick() {
        if (this.disabled || this.empty) {
            return;
        }
        this.select.emit(this.date);
    }
    smallerThanMin() {
        return this.date && this.min && this.dateService.compareDates(this.date, this.min) < 0;
    }
    greaterThanMax() {
        return this.date && this.max && this.dateService.compareDates(this.date, this.max) > 0;
    }
    dontFitFilter() {
        return this.date && this.filter && !this.filter(this.date);
    }
};
__decorate([
    Input(),
    __metadata("design:type", Object)
], ElCalendarRangeDayCellComponent.prototype, "date", void 0);
__decorate([
    Input(),
    __metadata("design:type", Object)
], ElCalendarRangeDayCellComponent.prototype, "selectedValue", void 0);
__decorate([
    Input(),
    __metadata("design:type", Object)
], ElCalendarRangeDayCellComponent.prototype, "visibleDate", void 0);
__decorate([
    Input(),
    __metadata("design:type", Object)
], ElCalendarRangeDayCellComponent.prototype, "min", void 0);
__decorate([
    Input(),
    __metadata("design:type", Object)
], ElCalendarRangeDayCellComponent.prototype, "max", void 0);
__decorate([
    Input(),
    __metadata("design:type", Function)
], ElCalendarRangeDayCellComponent.prototype, "filter", void 0);
__decorate([
    Output(),
    __metadata("design:type", EventEmitter)
], ElCalendarRangeDayCellComponent.prototype, "select", void 0);
__decorate([
    HostBinding('class.in-range'),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [])
], ElCalendarRangeDayCellComponent.prototype, "inRange", null);
__decorate([
    HostBinding('class.start'),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [])
], ElCalendarRangeDayCellComponent.prototype, "start", null);
__decorate([
    HostBinding('class.end'),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [])
], ElCalendarRangeDayCellComponent.prototype, "end", null);
ElCalendarRangeDayCellComponent = __decorate([
    Component({
        selector: 'el-calendar-range-day-cell',
        template: `
    <div
      class="day-cell"
      [class.today]="today"
      [class.selected]="selected"
      [class.bounding-month]="boundingMonth"
      [class.start]="start"
      [class.end]="end"
      [class.in-range]="inRange"
      [class.disabled]="disabled">
      {{ day }}
    </div>
  `,
        changeDetection: ChangeDetectionStrategy.OnPush,
        host: { '(click)': 'onClick()', 'class': 'range-cell' }
    }),
    __metadata("design:paramtypes", [ElDateService])
], ElCalendarRangeDayCellComponent);
export { ElCalendarRangeDayCellComponent };
let ElCalendarRangeYearCellComponent = class ElCalendarRangeYearCellComponent {
    constructor(dateService) {
        this.dateService = dateService;
        this.select = new EventEmitter(true);
    }
    get selected() {
        return this.selectedValue && this.dateService.isSameYear(this.date, this.selectedValue.start);
    }
    get today() {
        return this.date && this.dateService.isSameYear(this.date, this.dateService.today());
    }
    get disabled() {
        return this.smallerThanMin() || this.greaterThanMax();
    }
    get year() {
        return this.dateService.getYear(this.date);
    }
    onClick() {
        if (this.disabled) {
            return;
        }
        this.select.emit(this.date);
    }
    smallerThanMin() {
        return this.date && this.min && this.dateService.compareDates(this.yearEnd(), this.min) < 0;
    }
    greaterThanMax() {
        return this.date && this.max && this.dateService.compareDates(this.yearStart(), this.max) > 0;
    }
    yearStart() {
        return this.dateService.getYearStart(this.date);
    }
    yearEnd() {
        return this.dateService.getYearEnd(this.date);
    }
};
__decorate([
    Input(),
    __metadata("design:type", Object)
], ElCalendarRangeYearCellComponent.prototype, "date", void 0);
__decorate([
    Input(),
    __metadata("design:type", Object)
], ElCalendarRangeYearCellComponent.prototype, "min", void 0);
__decorate([
    Input(),
    __metadata("design:type", Object)
], ElCalendarRangeYearCellComponent.prototype, "max", void 0);
__decorate([
    Input(),
    __metadata("design:type", Object)
], ElCalendarRangeYearCellComponent.prototype, "selectedValue", void 0);
__decorate([
    Output(),
    __metadata("design:type", EventEmitter)
], ElCalendarRangeYearCellComponent.prototype, "select", void 0);
__decorate([
    HostBinding('class.selected'),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [])
], ElCalendarRangeYearCellComponent.prototype, "selected", null);
__decorate([
    HostBinding('class.today'),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [])
], ElCalendarRangeYearCellComponent.prototype, "today", null);
__decorate([
    HostBinding('class.disabled'),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [])
], ElCalendarRangeYearCellComponent.prototype, "disabled", null);
__decorate([
    HostListener('click'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], ElCalendarRangeYearCellComponent.prototype, "onClick", null);
ElCalendarRangeYearCellComponent = __decorate([
    Component({
        selector: 'el-calendar-range-year-cell',
        template: `{{ year }}`,
        changeDetection: ChangeDetectionStrategy.OnPush,
        host: { 'class': 'year-cell' }
    }),
    __metadata("design:paramtypes", [ElDateService])
], ElCalendarRangeYearCellComponent);
export { ElCalendarRangeYearCellComponent };
//# sourceMappingURL=calendar-range-cells.js.map