import { CommonModule } from '@angular/common';
import { EventEmitter, ChangeDetectorRef, Optional, Inject, Input, Output, Component, ViewEncapsulation, ChangeDetectionStrategy, ViewChild, InjectionToken, ElementRef, Attribute, Self, NgModule } from '@angular/core';
import { DateAdapter, NT_DATE_FORMATS, BOTTOM_LEFT, TOP_LEFT, NtOverlayComponent, fadeOut, fadeIn, NtOverlayModule, NtPseudoInputModule } from '@ng-tangram/components/core';
import { Subject } from 'rxjs';
import { debounceTime } from 'rxjs/operators';
import { trigger, transition } from '@angular/animations';
import { coerceBooleanProperty } from '@angular/cdk/coercion';
import { CdkOverlayOrigin } from '@angular/cdk/overlay';
import { NgControl } from '@angular/forms';
import { NtFormFieldControl } from '@ng-tangram/components/forms';

function createMissingDateImplError(provider) {
    return Error("NtDatepickerComponent: No provider found for " + provider + ". You must import one of the following " +
        "modules at your application root: NtNativeDateModule or provide a " +
        "custom implementation.");
}

var NtDatePickerCell = (function () {
    function NtDatePickerCell(value, displayValue, enabled) {
        this.value = value;
        this.displayValue = displayValue;
        this.enabled = enabled;
    }
    return NtDatePickerCell;
}());

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 __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var __read = (this && this.__read) || function (o, n) {
    var m = typeof Symbol === "function" && o[Symbol.iterator];
    if (!m) return o;
    var i = m.call(o), r, ar = [], e;
    try {
        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
    }
    catch (error) { e = { error: error }; }
    finally {
        try {
            if (r && !r.done && (m = i["return"])) m.call(i);
        }
        finally { if (e) throw e.error; }
    }
    return ar;
};
var __spread = (this && this.__spread) || function () {
    for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
    return ar;
};
var DAYS_PER_WEEK = 7;
var DAYS_MAX_ROWS = 6;
var NtDatePickerMonthComponent = (function () {
    function NtDatePickerMonthComponent(_changeDetectorRef, _dateAdapter, _dateFormats) {
        this._changeDetectorRef = _changeDetectorRef;
        this._dateAdapter = _dateAdapter;
        this._dateFormats = _dateFormats;
        this.selectedChange = new EventEmitter();
        this.activeDateChange = new EventEmitter();
        if (!this._dateAdapter) {
            throw createMissingDateImplError('DateAdapter');
        }
        if (!this._dateFormats) {
            throw createMissingDateImplError('NT_DATE_FORMATS');
        }
        var firstDayOfWeek = this._dateAdapter.getFirstDayOfWeek();
        var narrowWeekdays = this._dateAdapter.getDayOfWeekNames('narrow');
        var longWeekdays = this._dateAdapter.getDayOfWeekNames('long');
        var weekdays = longWeekdays.map(function (long, i) {
            return { long: long, narrow: narrowWeekdays[i] };
        });
        this._weekdays = weekdays.slice(firstDayOfWeek).concat(weekdays.slice(0, firstDayOfWeek));
        this._activeDate = this._dateAdapter.today();
    }
    Object.defineProperty(NtDatePickerMonthComponent.prototype, "activeDate", {
        get: function () { return this._activeDate; },
        set: function (value) {
            var oldActiveDate = this._activeDate;
            var validDate = this._getValidDateOrNull(this._dateAdapter.deserialize(value)) || this._dateAdapter.today();
            this._activeDate = this._dateAdapter.clampDate(validDate, this.minDate, this.maxDate);
            if (!this._hasSameMonthAndYear(oldActiveDate, this._activeDate)) {
                this._init();
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NtDatePickerMonthComponent.prototype, "selected", {
        get: function () { return this._selected; },
        set: function (value) {
            this._selected = this._getValidDateOrNull(this._dateAdapter.deserialize(value));
            this._selectedDate = this._getDateInCurrentMonth(this._selected);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NtDatePickerMonthComponent.prototype, "minDate", {
        get: function () { return this._minDate; },
        set: function (value) {
            this._minDate = this._getValidDateOrNull(this._dateAdapter.deserialize(value));
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NtDatePickerMonthComponent.prototype, "maxDate", {
        get: function () { return this._maxDate; },
        set: function (value) {
            this._maxDate = this._getValidDateOrNull(this._dateAdapter.deserialize(value));
        },
        enumerable: true,
        configurable: true
    });
    NtDatePickerMonthComponent.prototype.ngAfterContentInit = function () {
        this._init();
    };
    NtDatePickerMonthComponent.prototype._dateSelected = function (cell) {
        if (cell.enabled && this._selectedDate !== cell.value) {
            var selectedYear = this._dateAdapter.getYear(this.activeDate);
            var selectedMonth = this._dateAdapter.getMonth(this.activeDate);
            var selectedDate = this._dateAdapter.createDate(selectedYear, selectedMonth, cell.value);
            this.selectedChange.emit(selectedDate);
        }
    };
    NtDatePickerMonthComponent.prototype._init = function () {
        this._selectedDate = this._getDateInCurrentMonth(this.selected);
        this._todayDate = this._getDateInCurrentMonth(this._dateAdapter.today());
        this._monthLabel = this._dateAdapter.getMonthNames('short')[this._dateAdapter.getMonth(this.activeDate)]
            .toLocaleUpperCase();
        var firstOfMonth = this._dateAdapter.createDate(this._dateAdapter.getYear(this.activeDate), this._dateAdapter.getMonth(this.activeDate), 1);
        this._firstWeekOffset = (DAYS_PER_WEEK + this._dateAdapter.getDayOfWeek(firstOfMonth) -
            this._dateAdapter.getFirstDayOfWeek()) % DAYS_PER_WEEK;
        this._createWeekCells();
        this._changeDetectorRef.markForCheck();
    };
    NtDatePickerMonthComponent.prototype._createWeekCells = function () {
        var daysInMonth = this._dateAdapter.getNumDaysInMonth(this.activeDate);
        var dateNames = this._dateAdapter.getDateNames();
        this._weeks = [[]];
        for (var i = 0, cell = this._firstWeekOffset; i < daysInMonth; i++, cell++) {
            if (cell === DAYS_PER_WEEK) {
                this._weeks.push([]);
                cell = 0;
            }
            var date = this._dateAdapter.createDate(this._dateAdapter.getYear(this.activeDate), this._dateAdapter.getMonth(this.activeDate), i + 1);
            var enabled = this._shouldEnableDate(date);
            this._weeks[this._weeks.length - 1].push(new NtDatePickerCell(i + 1, dateNames[i], enabled));
        }
        this._fillBeforeCells();
        this._fillAfterCells();
    };
    NtDatePickerMonthComponent.prototype._getWeekOffset = function () {
        var firstDayForCurrentMonth = this._dateAdapter.createDate(this._dateAdapter.getYear(this.activeDate), this._dateAdapter.getMonth(this.activeDate), 1);
        var firstDayForWeek = this._dateAdapter.getDayOfWeek(firstDayForCurrentMonth);
        return firstDayForWeek - this._dateAdapter.getFirstDayOfWeek() >= 0
            ? firstDayForWeek - this._dateAdapter.getFirstDayOfWeek()
            : firstDayForWeek - this._dateAdapter.getFirstDayOfWeek() + DAYS_PER_WEEK;
    };
    NtDatePickerMonthComponent.prototype._fillBeforeCells = function () {
        var beforeMonth = this._dateAdapter.addCalendarMonths(this._dateAdapter.clone(this.activeDate), -1);
        var daysInBeforeMonth = this._dateAdapter.getNumDaysInMonth(beforeMonth);
        var dateNames = this._dateAdapter.getDateNames();
        var beforeWeeks = [];
        for (var i = daysInBeforeMonth - this._firstWeekOffset; i < daysInBeforeMonth; i++) {
            beforeWeeks.push(new NtDatePickerCell(i + 1, dateNames[i], false));
        }
        this._weeks[0] = beforeWeeks.concat(this._weeks[0]);
    };
    NtDatePickerMonthComponent.prototype._fillAfterCells = function () {
        var _a;
        var afterMonth = this._dateAdapter.addCalendarMonths(this._dateAdapter.clone(this.activeDate), 1);
        var lastRow = this._weeks[this._weeks.length - 1];
        var dateNames = this._dateAdapter.getDateNames();
        var afterWeeks = [], afterRows = [];
        for (var i = 0; i < DAYS_PER_WEEK - lastRow.length; i++) {
            afterWeeks.push(new NtDatePickerCell(i + 1, dateNames[i], false));
        }
        lastRow.push.apply(lastRow, __spread(afterWeeks));
        for (var i = 0; i < DAYS_PER_WEEK * (DAYS_MAX_ROWS - this._weeks.length); i++) {
            afterRows.push(new NtDatePickerCell(afterWeeks.length + i + 1, dateNames[afterWeeks.length + i], false));
        }
        (_a = this._weeks).push.apply(_a, __spread(afterRows.map(function (_) { return afterRows.splice(0, DAYS_PER_WEEK); }).filter(function (row) { return !!row; })));
    };
    NtDatePickerMonthComponent.prototype._shouldEnableDate = function (date) {
        return !!date &&
            (!this.dateFilter || this.dateFilter(date)) &&
            (!this.minDate || this._dateAdapter.compareDate(date, this.minDate) >= 0) &&
            (!this.maxDate || this._dateAdapter.compareDate(date, this.maxDate) <= 0);
    };
    NtDatePickerMonthComponent.prototype._getDateInCurrentMonth = function (date) {
        return date && this._hasSameMonthAndYear(date, this.activeDate) ?
            this._dateAdapter.getDate(date) : null;
    };
    NtDatePickerMonthComponent.prototype._hasSameMonthAndYear = function (d1, d2) {
        return !!(d1 && d2 && this._dateAdapter.getMonth(d1) === this._dateAdapter.getMonth(d2) &&
            this._dateAdapter.getYear(d1) === this._dateAdapter.getYear(d2));
    };
    NtDatePickerMonthComponent.prototype._getValidDateOrNull = function (obj) {
        return (this._dateAdapter.isDateInstance(obj) && this._dateAdapter.isValid(obj)) ? obj : null;
    };
    NtDatePickerMonthComponent.ctorParameters = function () { return [
        { type: ChangeDetectorRef },
        { type: DateAdapter, decorators: [{ type: Optional }] },
        { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [NT_DATE_FORMATS,] }] }
    ]; };
    __decorate([
        Input()
    ], NtDatePickerMonthComponent.prototype, "activeDate", null);
    __decorate([
        Input()
    ], NtDatePickerMonthComponent.prototype, "selected", null);
    __decorate([
        Input()
    ], NtDatePickerMonthComponent.prototype, "minDate", null);
    __decorate([
        Input()
    ], NtDatePickerMonthComponent.prototype, "maxDate", null);
    __decorate([
        Input()
    ], NtDatePickerMonthComponent.prototype, "dateFilter", void 0);
    __decorate([
        Output()
    ], NtDatePickerMonthComponent.prototype, "selectedChange", void 0);
    __decorate([
        Output()
    ], NtDatePickerMonthComponent.prototype, "activeDateChange", void 0);
    NtDatePickerMonthComponent = __decorate([
        Component({
            selector: 'nt-datepicker-month',
            template: "<table>\n  <thead>\n    <tr>\n      <th *ngFor=\"let week of _weekdays\">{{week.narrow}}</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr *ngFor=\"let _rows of _weeks\">\n      <td *ngFor=\"let week of _rows\"\n        [class.disabled]=\"!week.enabled\"\n        [class.selected]=\"week.value === _selectedDate && week.enabled\"\n        [class.active]=\"_todayDate === week.value && week.enabled\">\n        <span (click)=\"_dateSelected(week)\">{{ week.displayValue }}</span>\n      </td>\n    </tr>\n  </tbody>\n</table>\n<!-- <button class=\"button tiny expanded clear margin-bottom-0\" [disabled]=\"_isTodaySelected()\" (click)=\"_todaySelected()\">\u4ECA\u65E5</button> -->\n",
            encapsulation: ViewEncapsulation.None,
            changeDetection: ChangeDetectionStrategy.OnPush,
            host: {
                'class': 'nt-datepicker-month'
            }
        }),
        __param(1, Optional()),
        __param(2, Optional()), __param(2, Inject(NT_DATE_FORMATS))
    ], NtDatePickerMonthComponent);
    return NtDatePickerMonthComponent;
}());

var __decorate$1 = (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 __param$1 = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var yearsPerPage = 12;
var yearsPerRow = 3;
var NtDatePickerMultiYearComponent = (function () {
    function NtDatePickerMultiYearComponent(_changeDetectorRef, _dateAdapter) {
        this._changeDetectorRef = _changeDetectorRef;
        this._dateAdapter = _dateAdapter;
        this.selectedChange = new EventEmitter();
        this.yearSelected = new EventEmitter();
        if (!this._dateAdapter) {
            throw createMissingDateImplError('DateAdapter');
        }
        this._activeDate = this._dateAdapter.today();
    }
    Object.defineProperty(NtDatePickerMultiYearComponent.prototype, "activeDate", {
        get: function () { return this._activeDate; },
        set: function (value) {
            var oldActiveDate = this._activeDate;
            var validDate = this._getValidDateOrNull(this._dateAdapter.deserialize(value)) || this._dateAdapter.today();
            this._activeDate = this._dateAdapter.clampDate(validDate, this.minDate, this.maxDate);
            if (Math.floor(this._dateAdapter.getYear(oldActiveDate) / yearsPerPage) !==
                Math.floor(this._dateAdapter.getYear(this._activeDate) / yearsPerPage)) {
                this._init();
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NtDatePickerMultiYearComponent.prototype, "selected", {
        get: function () { return this._selected; },
        set: function (value) {
            this._selected = this._getValidDateOrNull(this._dateAdapter.deserialize(value));
            this._selectedYear = this._selected && this._dateAdapter.getYear(this._selected);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NtDatePickerMultiYearComponent.prototype, "minDate", {
        get: function () { return this._minDate; },
        set: function (value) {
            this._minDate = this._getValidDateOrNull(this._dateAdapter.deserialize(value));
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NtDatePickerMultiYearComponent.prototype, "maxDate", {
        get: function () { return this._maxDate; },
        set: function (value) {
            this._maxDate = this._getValidDateOrNull(this._dateAdapter.deserialize(value));
        },
        enumerable: true,
        configurable: true
    });
    NtDatePickerMultiYearComponent.prototype.ngAfterContentInit = function () {
        this._init();
    };
    NtDatePickerMultiYearComponent.prototype._init = function () {
        var _this = this;
        this._todayYear = this._dateAdapter.getYear(this._dateAdapter.today());
        var activeYear = this._dateAdapter.getYear(this._activeDate);
        var activeOffset = activeYear % yearsPerPage;
        this._years = [];
        for (var i = 0, row = []; i < yearsPerPage; i++) {
            row.push(activeYear - activeOffset + i);
            if (row.length === yearsPerRow) {
                this._years.push(row.map(function (year) { return _this._createCellForYear(year); }));
                row = [];
            }
        }
        this._changeDetectorRef.markForCheck();
    };
    NtDatePickerMultiYearComponent.prototype._yearSelected = function (year) {
        this.yearSelected.emit(this._dateAdapter.createDate(year, 0, 1));
        var month = this._dateAdapter.getMonth(this.activeDate);
        var daysInMonth = this._dateAdapter.getNumDaysInMonth(this._dateAdapter.createDate(year, month, 1));
        this.selectedChange.emit(this._dateAdapter.createDate(year, month, Math.min(this._dateAdapter.getDate(this.activeDate), daysInMonth)));
    };
    NtDatePickerMultiYearComponent.prototype._createCellForYear = function (year) {
        var yearName = this._dateAdapter.getYearName(this._dateAdapter.createDate(year, 0, 1));
        return new NtDatePickerCell(year, yearName, this._shouldEnableYear(year));
    };
    NtDatePickerMultiYearComponent.prototype._shouldEnableYear = function (year) {
        if (year === undefined || year === null ||
            (this.maxDate && year > this._dateAdapter.getYear(this.maxDate)) ||
            (this.minDate && year < this._dateAdapter.getYear(this.minDate))) {
            return false;
        }
        if (!this.dateFilter) {
            return true;
        }
        var firstOfYear = this._dateAdapter.createDate(year, 0, 1);
        for (var date = firstOfYear; this._dateAdapter.getYear(date) === year; date = this._dateAdapter.addCalendarDays(date, 1)) {
            if (this.dateFilter(date)) {
                return true;
            }
        }
        return false;
    };
    NtDatePickerMultiYearComponent.prototype._getValidDateOrNull = function (obj) {
        return (this._dateAdapter.isDateInstance(obj) && this._dateAdapter.isValid(obj)) ? obj : null;
    };
    NtDatePickerMultiYearComponent.ctorParameters = function () { return [
        { type: ChangeDetectorRef },
        { type: DateAdapter, decorators: [{ type: Optional }] }
    ]; };
    __decorate$1([
        Input()
    ], NtDatePickerMultiYearComponent.prototype, "activeDate", null);
    __decorate$1([
        Input()
    ], NtDatePickerMultiYearComponent.prototype, "selected", null);
    __decorate$1([
        Input()
    ], NtDatePickerMultiYearComponent.prototype, "minDate", null);
    __decorate$1([
        Input()
    ], NtDatePickerMultiYearComponent.prototype, "maxDate", null);
    __decorate$1([
        Input()
    ], NtDatePickerMultiYearComponent.prototype, "dateFilter", void 0);
    __decorate$1([
        Output()
    ], NtDatePickerMultiYearComponent.prototype, "selectedChange", void 0);
    __decorate$1([
        Output()
    ], NtDatePickerMultiYearComponent.prototype, "yearSelected", void 0);
    NtDatePickerMultiYearComponent = __decorate$1([
        Component({
            selector: 'nt-datepicker-multi-year',
            template: "<table>\n  <tbody>\n    <tr *ngFor=\"let _rows of _years\">\n      <td *ngFor=\"let year of _rows\"\n        [class.disabled]=\"!year.enabled\"\n        [class.selected]=\"year.value === _selectedYear && year.enabled\"\n        (click)=\"_yearSelected(year.value)\">\n        <span *ngIf=\"year.enabled\">{{ year.displayValue }}</span>\n        <span *ngIf=\"!year.enabled\">{{ year.displayValue }}</span>\n      </td>\n    </tr>\n  </tbody>\n</table>\n",
            encapsulation: ViewEncapsulation.None,
            changeDetection: ChangeDetectionStrategy.OnPush,
            host: {
                'class': 'nt-datepicker-multi-year'
            }
        }),
        __param$1(1, Optional())
    ], NtDatePickerMultiYearComponent);
    return NtDatePickerMultiYearComponent;
}());

var __decorate$2 = (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 __param$2 = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var NtDatePickerYearComponent = (function () {
    function NtDatePickerYearComponent(_changeDetectorRef, _dateAdapter, _dateFormats) {
        this._changeDetectorRef = _changeDetectorRef;
        this._dateAdapter = _dateAdapter;
        this._dateFormats = _dateFormats;
        this.selectedChange = new EventEmitter();
        this.monthSelected = new EventEmitter();
        if (!this._dateAdapter) {
            throw createMissingDateImplError('DateAdapter');
        }
        if (!this._dateFormats) {
            throw createMissingDateImplError('NT_DATE_FORMATS');
        }
        this._activeDate = this._dateAdapter.today();
    }
    Object.defineProperty(NtDatePickerYearComponent.prototype, "activeDate", {
        get: function () { return this._activeDate; },
        set: function (value) {
            var oldActiveDate = this._activeDate;
            var validDate = this._getValidDateOrNull(this._dateAdapter.deserialize(value)) || this._dateAdapter.today();
            this._activeDate = this._dateAdapter.clampDate(validDate, this.minDate, this.maxDate);
            if (this._dateAdapter.getYear(oldActiveDate) !== this._dateAdapter.getYear(this._activeDate)) {
                this._init();
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NtDatePickerYearComponent.prototype, "activeYear", {
        get: function () { return this._activeDate ? this._dateAdapter.getYear(this._activeDate) : null; },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NtDatePickerYearComponent.prototype, "selected", {
        get: function () { return this._selected; },
        set: function (value) {
            this._selected = this._getValidDateOrNull(this._dateAdapter.deserialize(value));
            this._selectedMonth = this._getMonthInCurrentYear(this._selected);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NtDatePickerYearComponent.prototype, "minDate", {
        get: function () { return this._minDate; },
        set: function (value) {
            this._minDate = this._getValidDateOrNull(this._dateAdapter.deserialize(value));
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NtDatePickerYearComponent.prototype, "maxDate", {
        get: function () { return this._maxDate; },
        set: function (value) {
            this._maxDate = this._getValidDateOrNull(this._dateAdapter.deserialize(value));
        },
        enumerable: true,
        configurable: true
    });
    NtDatePickerYearComponent.prototype.ngAfterContentInit = function () {
        this._init();
    };
    NtDatePickerYearComponent.prototype._init = function () {
        var _this = this;
        this._selectedMonth = this._getMonthInCurrentYear(this.selected);
        this._todayMonth = this._getMonthInCurrentYear(this._dateAdapter.today());
        var monthNames = this._dateAdapter.getMonthNames('short');
        this._months = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11]].map(function (row) { return row.map(function (month) { return _this._createCellForMonth(month, monthNames[month]); }); });
        this._changeDetectorRef.markForCheck();
    };
    NtDatePickerYearComponent.prototype._monthSelected = function (month) {
        var normalizedDate = this._dateAdapter.createDate(this._dateAdapter.getYear(this.activeDate), month, 1);
        this.monthSelected.emit(normalizedDate);
        var daysInMonth = this._dateAdapter.getNumDaysInMonth(normalizedDate);
        this.selectedChange.emit(this._dateAdapter.createDate(this._dateAdapter.getYear(this.activeDate), month, Math.min(this._dateAdapter.getDate(this.activeDate), daysInMonth)));
    };
    NtDatePickerYearComponent.prototype._createCellForMonth = function (month, monthName) {
        return new NtDatePickerCell(month, monthName.toLocaleUpperCase(), this._shouldEnableMonth(month));
    };
    NtDatePickerYearComponent.prototype._shouldEnableMonth = function (month) {
        var activeYear = this._dateAdapter.getYear(this.activeDate);
        if (month === undefined || month === null ||
            this._isYearAndMonthAfterMaxDate(activeYear, month) ||
            this._isYearAndMonthBeforeMinDate(activeYear, month)) {
            return false;
        }
        if (!this.dateFilter) {
            return true;
        }
        var firstOfMonth = this._dateAdapter.createDate(activeYear, month, 1);
        for (var date = firstOfMonth; this._dateAdapter.getMonth(date) === month; date = this._dateAdapter.addCalendarDays(date, 1)) {
            if (this.dateFilter(date)) {
                return true;
            }
        }
        return false;
    };
    NtDatePickerYearComponent.prototype._isYearAndMonthAfterMaxDate = function (year, month) {
        if (this.maxDate) {
            var maxYear = this._dateAdapter.getYear(this.maxDate);
            var maxMonth = this._dateAdapter.getMonth(this.maxDate);
            return year > maxYear || (year === maxYear && month > maxMonth);
        }
        return false;
    };
    NtDatePickerYearComponent.prototype._isYearAndMonthBeforeMinDate = function (year, month) {
        if (this.minDate) {
            var minYear = this._dateAdapter.getYear(this.minDate);
            var minMonth = this._dateAdapter.getMonth(this.minDate);
            return year < minYear || (year === minYear && month < minMonth);
        }
        return false;
    };
    NtDatePickerYearComponent.prototype._getMonthInCurrentYear = function (date) {
        return date && this._dateAdapter.getYear(date) === this._dateAdapter.getYear(this.activeDate) ?
            this._dateAdapter.getMonth(date) : null;
    };
    NtDatePickerYearComponent.prototype._getValidDateOrNull = function (obj) {
        return (this._dateAdapter.isDateInstance(obj) && this._dateAdapter.isValid(obj)) ? obj : null;
    };
    NtDatePickerYearComponent.ctorParameters = function () { return [
        { type: ChangeDetectorRef },
        { type: DateAdapter, decorators: [{ type: Optional }] },
        { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [NT_DATE_FORMATS,] }] }
    ]; };
    __decorate$2([
        Input()
    ], NtDatePickerYearComponent.prototype, "activeDate", null);
    __decorate$2([
        Input()
    ], NtDatePickerYearComponent.prototype, "selected", null);
    __decorate$2([
        Input()
    ], NtDatePickerYearComponent.prototype, "minDate", null);
    __decorate$2([
        Input()
    ], NtDatePickerYearComponent.prototype, "maxDate", null);
    __decorate$2([
        Input()
    ], NtDatePickerYearComponent.prototype, "dateFilter", void 0);
    __decorate$2([
        Output()
    ], NtDatePickerYearComponent.prototype, "selectedChange", void 0);
    __decorate$2([
        Output()
    ], NtDatePickerYearComponent.prototype, "monthSelected", void 0);
    NtDatePickerYearComponent = __decorate$2([
        Component({
            selector: 'nt-datepicker-year',
            template: "<table>\n  <tbody>\n    <tr *ngFor=\"let _rows of _months\">\n      <td *ngFor=\"let month of _rows\"\n        [class.disabled]=\"!month.enabled\"\n        [class.selected]=\"month.value === _selectedMonth && month.enabled\"\n        (click)=\"_monthSelected(month.value)\">\n        <span *ngIf=\"month.enabled\">{{ month.displayValue }}</span>\n        <span *ngIf=\"!month.enabled\">{{ month.displayValue }}</span>\n      </td>\n    </tr>\n  </tbody>\n</table>\n",
            encapsulation: ViewEncapsulation.None,
            changeDetection: ChangeDetectionStrategy.OnPush,
            host: {
                'class': 'nt-datepicker-year'
            }
        }),
        __param$2(1, Optional()),
        __param$2(2, Optional()), __param$2(2, Inject(NT_DATE_FORMATS))
    ], NtDatePickerYearComponent);
    return NtDatePickerYearComponent;
}());

var __decorate$3 = (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 __param$3 = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var NtDatePickerCalendarComponent = (function () {
    function NtDatePickerCalendarComponent(_changeDetectorRef, _dateAdapter, _dateFormats) {
        this._changeDetectorRef = _changeDetectorRef;
        this._dateAdapter = _dateAdapter;
        this._dateFormats = _dateFormats;
        this._viewType = 'month';
        this._currentView = 'month';
        this.selectedChange = new EventEmitter();
        this.yearSelected = new EventEmitter();
        this.monthSelected = new EventEmitter();
        if (!this._dateAdapter) {
            throw createMissingDateImplError('DateAdapter');
        }
        if (!this._dateFormats) {
            throw createMissingDateImplError('NT_DATE_FORMATS');
        }
    }
    Object.defineProperty(NtDatePickerCalendarComponent.prototype, "startAt", {
        get: function () { return this._startAt; },
        set: function (value) { this._startAt = this._getValidDateOrNull(this._dateAdapter.deserialize(value)); },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NtDatePickerCalendarComponent.prototype, "selected", {
        get: function () { return this._selected; },
        set: function (value) { this._selected = this._getValidDateOrNull(this._dateAdapter.deserialize(value)); },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NtDatePickerCalendarComponent.prototype, "minDate", {
        get: function () { return this._minDate; },
        set: function (value) { this._minDate = this._getValidDateOrNull(this._dateAdapter.deserialize(value)); },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NtDatePickerCalendarComponent.prototype, "maxDate", {
        get: function () { return this._maxDate; },
        set: function (value) { this._maxDate = this._getValidDateOrNull(this._dateAdapter.deserialize(value)); },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NtDatePickerCalendarComponent.prototype, "_activeDate", {
        get: function () { return this._clampedActiveDate; },
        set: function (value) { this._clampedActiveDate = this._dateAdapter.clampDate(value, this.minDate, this.maxDate); },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NtDatePickerCalendarComponent.prototype, "_monthLabel", {
        get: function () {
            return this._dateAdapter.format(this._activeDate, this._dateFormats.display.monthLabel).toLocaleUpperCase();
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NtDatePickerCalendarComponent.prototype, "_yearLabel", {
        get: function () { return this._dateAdapter.getYearName(this._activeDate); },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NtDatePickerCalendarComponent.prototype, "_multiYearLabel", {
        get: function () {
            var activeYear = this._dateAdapter.getYear(this._activeDate);
            var firstYearInView = this._dateAdapter.getYearName(this._dateAdapter.createDate(activeYear - activeYear % yearsPerPage, 0, 1), 'en-US');
            var lastYearInView = this._dateAdapter.getYearName(this._dateAdapter.createDate(activeYear + yearsPerPage - 1 - activeYear % yearsPerPage, 0, 1), 'en-US');
            return firstYearInView + " \u2013 " + lastYearInView;
        },
        enumerable: true,
        configurable: true
    });
    NtDatePickerCalendarComponent.prototype.ngAfterContentInit = function () {
        this._init();
    };
    NtDatePickerCalendarComponent.prototype.ngOnChanges = function (changes) {
        var change = changes.minDate || changes.maxDate || changes.dateFilter;
        if (change && !change.firstChange) {
            var view = this.monthView || this.yearView || this.multiYearView;
            if (view) {
                view._init();
            }
        }
    };
    NtDatePickerCalendarComponent.prototype.ngOnDestroy = function () {
    };
    NtDatePickerCalendarComponent.prototype.prevMonth = function () {
        this._activeDate = this._dateAdapter.addCalendarMonths(this._activeDate, -1);
    };
    NtDatePickerCalendarComponent.prototype.nextMonth = function () {
        this._activeDate = this._dateAdapter.addCalendarMonths(this._activeDate, 1);
    };
    NtDatePickerCalendarComponent.prototype.prevYear = function () {
        this._activeDate = this._dateAdapter.addCalendarYears(this._activeDate, -1);
    };
    NtDatePickerCalendarComponent.prototype.nextYear = function () {
        this._activeDate = this._dateAdapter.addCalendarYears(this._activeDate, 1);
    };
    NtDatePickerCalendarComponent.prototype.prevYearArray = function () {
        this._activeDate = this._dateAdapter.addCalendarYears(this._activeDate, -yearsPerPage);
    };
    NtDatePickerCalendarComponent.prototype.nextYearArray = function () {
        this._activeDate = this._dateAdapter.addCalendarYears(this._activeDate, yearsPerPage);
    };
    NtDatePickerCalendarComponent.prototype._init = function () {
        this._activeDate = this.startAt || this._dateAdapter.today();
        this._currentView = this._viewType;
        this._changeDetectorRef.markForCheck();
    };
    NtDatePickerCalendarComponent.prototype._dateSelected = function (date) {
        if (!this._dateAdapter.sameDate(date, this.selected)) {
            this.selectedChange.emit(date);
        }
    };
    NtDatePickerCalendarComponent.prototype._yearSelectedInMultiYearView = function (normalizedYear) {
        this.yearSelected.emit(normalizedYear);
    };
    NtDatePickerCalendarComponent.prototype._monthSelectedInYearView = function (normalizedMonth) {
        this.monthSelected.emit(normalizedMonth);
    };
    NtDatePickerCalendarComponent.prototype._goToDateInView = function (date, view) {
        this._activeDate = date;
        this._currentView = view;
    };
    NtDatePickerCalendarComponent.prototype._getValidDateOrNull = function (obj) {
        return (this._dateAdapter.isDateInstance(obj) && this._dateAdapter.isValid(obj)) ? obj : null;
    };
    NtDatePickerCalendarComponent.ctorParameters = function () { return [
        { type: ChangeDetectorRef },
        { type: DateAdapter, decorators: [{ type: Optional }] },
        { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [NT_DATE_FORMATS,] }] }
    ]; };
    __decorate$3([
        Input()
    ], NtDatePickerCalendarComponent.prototype, "startAt", null);
    __decorate$3([
        Input()
    ], NtDatePickerCalendarComponent.prototype, "selected", null);
    __decorate$3([
        Input()
    ], NtDatePickerCalendarComponent.prototype, "minDate", null);
    __decorate$3([
        Input()
    ], NtDatePickerCalendarComponent.prototype, "maxDate", null);
    __decorate$3([
        Input()
    ], NtDatePickerCalendarComponent.prototype, "dateFilter", void 0);
    __decorate$3([
        Output()
    ], NtDatePickerCalendarComponent.prototype, "selectedChange", void 0);
    __decorate$3([
        Output()
    ], NtDatePickerCalendarComponent.prototype, "yearSelected", void 0);
    __decorate$3([
        Output()
    ], NtDatePickerCalendarComponent.prototype, "monthSelected", void 0);
    __decorate$3([
        ViewChild(NtDatePickerMonthComponent)
    ], NtDatePickerCalendarComponent.prototype, "monthView", void 0);
    __decorate$3([
        ViewChild(NtDatePickerYearComponent)
    ], NtDatePickerCalendarComponent.prototype, "yearView", void 0);
    __decorate$3([
        ViewChild(NtDatePickerMultiYearComponent)
    ], NtDatePickerCalendarComponent.prototype, "multiYearView", void 0);
    NtDatePickerCalendarComponent = __decorate$3([
        Component({
            selector: 'nt-datepicker-calendar',
            template: "<div class=\"nt-datepicker-pane\" [ngSwitch]=\"_currentView\">\n  <table>\n    <thead>\n      <tr *ngSwitchCase=\"'month'\"><ng-container *ngTemplateOutlet=\"monthControl\"></ng-container></tr>\n      <tr *ngSwitchCase=\"'year'\"><ng-container *ngTemplateOutlet=\"yearControl\"></ng-container></tr>\n      <tr *ngSwitchCase=\"'multi-year'\"><ng-container *ngTemplateOutlet=\"multiYearControl\"></ng-container></tr>\n    </thead>\n  </table>\n  <nt-datepicker-month\n    *ngSwitchCase=\"'month'\"\n    [(activeDate)]=\"_activeDate\"\n    [selected]=\"selected\"\n    [dateFilter]=\"dateFilter\"\n    [maxDate]=\"maxDate\"\n    [minDate]=\"minDate\"\n    (selectedChange)=\"_dateSelected($event)\">\n  </nt-datepicker-month>\n  <nt-datepicker-year\n    *ngSwitchCase=\"'year'\"\n    [activeDate]=\"_activeDate\"\n    [selected]=\"selected\"\n    [dateFilter]=\"dateFilter\"\n    [maxDate]=\"maxDate\"\n    [minDate]=\"minDate\"\n    (monthSelected)=\"_monthSelectedInYearView($event)\"\n    (selectedChange)=\"_goToDateInView($event, 'month')\">\n  </nt-datepicker-year>\n  <nt-datepicker-multi-year\n    *ngSwitchCase=\"'multi-year'\"\n    [activeDate]=\"_activeDate\"\n    [selected]=\"selected\"\n    [dateFilter]=\"dateFilter\"\n    [maxDate]=\"maxDate\"\n    [minDate]=\"minDate\"\n    (yearSelected)=\"_yearSelectedInMultiYearView($event)\"\n    (selectedChange)=\"_goToDateInView($event, 'year')\">\n  </nt-datepicker-multi-year>\n</div>\n\n<ng-template #monthControl>\n  <th (click)=\"prevYear()\" [class.disabled]=\"\"><span>&laquo;</span></th>\n  <th (click)=\"prevMonth()\" [class.disabled]=\"\"><span>&lsaquo;</span></th>\n  <th colspan=\"3\">\n    <span (click)=\" _currentView = 'multi-year' \">{{ _yearLabel }}</span>\n    <span (click)=\" _currentView = 'year' \">{{ _monthLabel }}</span>\n  </th>\n  <th (click)=\"nextMonth()\" [class.disabled]=\"\"><span>&rsaquo;</span></th>\n  <th (click)=\"nextYear()\" [class.disabled]=\"\"><span>&raquo;</span></th>\n</ng-template>\n<ng-template #yearControl>\n  <th (click)=\"prevYear()\" [class.disabled]=\"\"><span>&laquo;</span></th>\n  <th>&nbsp;</th>\n  <th colspan=\"3\">\n    <span (click)=\" _currentView = 'multi-year' \">{{ _yearLabel }}</span>\n  </th>\n  <th>&nbsp;</th>\n  <th (click)=\"nextYear()\" [class.disabled]=\"\"><span>&raquo;</span></th>\n</ng-template>\n<ng-template #multiYearControl>\n  <th (click)=\"prevYearArray()\"><span>&laquo;</span></th>\n  <th>&nbsp;</th>\n  <th colspan=\"3\">{{_multiYearLabel}}</th>\n  <th>&nbsp;</th>\n  <th (click)=\"nextYearArray()\"><span>&raquo;</span></th>\n</ng-template>\n",
            encapsulation: ViewEncapsulation.None,
            changeDetection: ChangeDetectionStrategy.OnPush
        }),
        __param$3(1, Optional()),
        __param$3(2, Optional()), __param$3(2, Inject(NT_DATE_FORMATS))
    ], NtDatePickerCalendarComponent);
    return NtDatePickerCalendarComponent;
}());

var DEFAULT_DATEPICKER_ICONS = {
    caret: 'far fa-calendar-alt',
    clear: 'fa fa-times'
};
var NT_DATEPICKER_ICONS = new InjectionToken('nt-datepicker-icons');

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __decorate$4 = (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 __param$4 = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var NtDatePickerComponent = (function (_super) {
    __extends(NtDatePickerComponent, _super);
    function NtDatePickerComponent(_elementRef, _dateAdapter, _dateFormats, tabIndex, ngControl, icons) {
        var _this = _super.call(this) || this;
        _this._elementRef = _elementRef;
        _this._dateAdapter = _dateAdapter;
        _this._dateFormats = _dateFormats;
        _this.ngControl = ngControl;
        _this.icons = icons;
        _this._overlayToggle = new Subject();
        _this._positionPairs = [BOTTOM_LEFT, TOP_LEFT];
        _this._displayValue = '';
        _this._placeholder = '';
        _this._disabled = false;
        _this._required = false;
        _this._readonly = false;
        _this.afterOpen = new EventEmitter();
        _this.afterClosed = new EventEmitter();
        _this.beforeOpen = new EventEmitter();
        _this.beforeClosed = new EventEmitter();
        _this.positionChange = new EventEmitter();
        _this._onChange = function () { };
        _this._onTouched = function () { };
        _this.origin = new CdkOverlayOrigin(_elementRef);
        if (_this.ngControl) {
            _this.ngControl.valueAccessor = _this;
        }
        _this.icons = __assign(__assign({}, DEFAULT_DATEPICKER_ICONS), icons);
        _this.tabIndex = parseInt(tabIndex) || 0;
        _this._overlayToggle.pipe(debounceTime(10)).subscribe(function (open) { return open
            ? _this.overlay.open()
            : _this.overlay.toggle(); });
        return _this;
    }
    NtDatePickerComponent_1 = NtDatePickerComponent;
    Object.defineProperty(NtDatePickerComponent.prototype, "empty", {
        get: function () { return !this.value; },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NtDatePickerComponent.prototype, "value", {
        get: function () { return this._value; },
        set: function (value) {
            value = this._getValidDateOrNull(this._dateAdapter.deserialize(value));
            this._value = value;
            this._displayValue = value ? this._dateAdapter.format(value, this._dateFormats.display.dateInput) : '';
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NtDatePickerComponent.prototype, "placeholder", {
        get: function () { return this._placeholder; },
        set: function (value) { this._placeholder = value; },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NtDatePickerComponent.prototype, "disabled", {
        get: function () { return this._disabled; },
        set: function (value) { this._disabled = coerceBooleanProperty(value); },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NtDatePickerComponent.prototype, "required", {
        get: function () { return this._required; },
        set: function (value) { this._required = coerceBooleanProperty(value); },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NtDatePickerComponent.prototype, "readonly", {
        get: function () { return this._readonly; },
        set: function (value) { this._readonly = coerceBooleanProperty(value); },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NtDatePickerComponent.prototype, "startAt", {
        get: function () { return this._startAt || this.value; },
        set: function (value) { this._startAt = this._getValidDateOrNull(this._dateAdapter.deserialize(value)); },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NtDatePickerComponent.prototype, "minDate", {
        get: function () { return this._minDate; },
        set: function (value) { this._minDate = this._getValidDateOrNull(this._dateAdapter.deserialize(value)); },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NtDatePickerComponent.prototype, "maxDate", {
        get: function () { return this._maxDate; },
        set: function (value) { this._maxDate = this._getValidDateOrNull(this._dateAdapter.deserialize(value)); },
        enumerable: true,
        configurable: true
    });
    NtDatePickerComponent.prototype.writeValue = function (value) {
        this.value = value;
    };
    NtDatePickerComponent.prototype.registerOnChange = function (fn) {
        this._onChange = fn;
    };
    NtDatePickerComponent.prototype.registerOnTouched = function (fn) {
        this._onTouched = fn;
    };
    NtDatePickerComponent.prototype.select = function (date) {
        this.value = date;
        this.overlay.close();
        this._onChange(date);
    };
    NtDatePickerComponent.prototype.focus = function () {
        this.overlay.open();
    };
    NtDatePickerComponent.prototype._afterOpen = function (event) {
        this.afterOpen.next(event);
    };
    NtDatePickerComponent.prototype._afterClosed = function (event) {
        this.afterClosed.next(event);
    };
    NtDatePickerComponent.prototype._beforeOpen = function (event) {
        this.calendar._init();
        this.beforeOpen.next(event);
    };
    NtDatePickerComponent.prototype._beforeClosed = function (event) {
        typeof this._onTouched === 'function' && this._onTouched();
        this.beforeClosed.next(event);
    };
    NtDatePickerComponent.prototype._positionChange = function (change) {
        this.positionChange.next(change);
    };
    NtDatePickerComponent.prototype._onClick = function (event) {
        if (!this.disabled) {
            this.overlay.toggle();
        }
        event.stopPropagation();
    };
    NtDatePickerComponent.prototype._onClear = function (event) {
        if (this.value !== null && !this.disabled) {
            this.value = null;
            this._onChange(this.value);
        }
        event.stopPropagation();
    };
    NtDatePickerComponent.prototype.setDisabledState = function (isDisabled) {
        this._disabled = isDisabled;
    };
    NtDatePickerComponent.prototype._getValidDateOrNull = function (obj) {
        return (this._dateAdapter.isDateInstance(obj) && this._dateAdapter.isValid(obj)) ? obj : null;
    };
    var NtDatePickerComponent_1;
    NtDatePickerComponent.ctorParameters = function () { return [
        { type: ElementRef },
        { type: DateAdapter },
        { type: undefined, decorators: [{ type: Inject, args: [NT_DATE_FORMATS,] }] },
        { type: String, decorators: [{ type: Attribute, args: ['tabindex',] }] },
        { type: NgControl, decorators: [{ type: Optional }, { type: Self }] },
        { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [NT_DATEPICKER_ICONS,] }] }
    ]; };
    __decorate$4([
        Input()
    ], NtDatePickerComponent.prototype, "placeholder", null);
    __decorate$4([
        Input()
    ], NtDatePickerComponent.prototype, "disabled", null);
    __decorate$4([
        Input()
    ], NtDatePickerComponent.prototype, "required", null);
    __decorate$4([
        Input()
    ], NtDatePickerComponent.prototype, "readonly", null);
    __decorate$4([
        Input()
    ], NtDatePickerComponent.prototype, "startAt", null);
    __decorate$4([
        Input()
    ], NtDatePickerComponent.prototype, "minDate", null);
    __decorate$4([
        Input()
    ], NtDatePickerComponent.prototype, "maxDate", null);
    __decorate$4([
        Input()
    ], NtDatePickerComponent.prototype, "dateFilter", void 0);
    __decorate$4([
        Output()
    ], NtDatePickerComponent.prototype, "afterOpen", void 0);
    __decorate$4([
        Output()
    ], NtDatePickerComponent.prototype, "afterClosed", void 0);
    __decorate$4([
        Output()
    ], NtDatePickerComponent.prototype, "beforeOpen", void 0);
    __decorate$4([
        Output()
    ], NtDatePickerComponent.prototype, "beforeClosed", void 0);
    __decorate$4([
        Output()
    ], NtDatePickerComponent.prototype, "positionChange", void 0);
    __decorate$4([
        ViewChild(NtOverlayComponent, { static: true })
    ], NtDatePickerComponent.prototype, "overlay", void 0);
    __decorate$4([
        ViewChild(NtDatePickerCalendarComponent, { static: true })
    ], NtDatePickerComponent.prototype, "calendar", void 0);
    NtDatePickerComponent = NtDatePickerComponent_1 = __decorate$4([
        Component({
            selector: 'nt-datepicker',
            template: "\n<nt-pseudo-input\n  [style.margin.px]=\"0\"\n  [attr.tabindex]=\"tabIndex\"\n  [value]=\"_displayValue\"\n  [placeholder]=\"placeholder\"\n  [disabled]=\"disabled\">\n  <nt-pseudo-caret *ngIf=\"!value || disabled\">\n    <span [class]=\"icons.caret\"></span>\n  </nt-pseudo-caret>\n  <nt-pseudo-caret class=\"nt-datepicker-clear\" (click)=\"_onClear($event)\" *ngIf=\"value && !disabled\">\n    <span [class]=\"icons.clear\"></span>\n  </nt-pseudo-caret>\n</nt-pseudo-input>\n\n<nt-overlay\n  [origin]=\"origin\"\n  [positionPairs]=\"_positionPairs\"\n  arrow\n  (afterOpen)=\"_afterOpen($event)\"\n  (afterClosed)=\"_afterClosed($event)\"\n  (beforeOpen)=\"_beforeOpen($event)\"\n  (beforeClosed)=\"_beforeClosed($event)\"\n  (positionChange)=\"_positionChange($event)\">\n  <nt-datepicker-calendar\n    [selected]=\"value\"\n    [dateFilter]=\"dateFilter\"\n    [startAt]=\"startAt\"\n    [maxDate]=\"maxDate\"\n    [minDate]=\"minDate\"\n    (selectedChange)=\"select($event)\">\n  </nt-datepicker-calendar>\n</nt-overlay>\n",
            encapsulation: ViewEncapsulation.None,
            host: {
                'class': 'nt-datepicker',
                '(click)': '_onClick($event)',
            },
            animations: [
                trigger('fade', [
                    transition('* => void', fadeOut(.15)),
                    transition('void => *', fadeIn(.15))
                ])
            ],
            providers: [
                { provide: NtFormFieldControl, useExisting: NtDatePickerComponent_1 }
            ]
        }),
        __param$4(2, Inject(NT_DATE_FORMATS)),
        __param$4(3, Attribute('tabindex')),
        __param$4(4, Optional()), __param$4(4, Self()),
        __param$4(5, Optional()), __param$4(5, Inject(NT_DATEPICKER_ICONS))
    ], NtDatePickerComponent);
    return NtDatePickerComponent;
}(NtFormFieldControl));

var __decorate$5 = (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 NtDatePickerModule = (function () {
    function NtDatePickerModule() {
    }
    NtDatePickerModule = __decorate$5([
        NgModule({
            imports: [
                CommonModule,
                NtOverlayModule,
                NtPseudoInputModule,
            ],
            exports: [NtDatePickerComponent],
            declarations: [
                NtDatePickerComponent,
                NtDatePickerCalendarComponent,
                NtDatePickerMonthComponent,
                NtDatePickerYearComponent,
                NtDatePickerMultiYearComponent
            ]
        })
    ], NtDatePickerModule);
    return NtDatePickerModule;
}());

export { DEFAULT_DATEPICKER_ICONS, NT_DATEPICKER_ICONS, NtDatePickerCalendarComponent, NtDatePickerCell, NtDatePickerComponent, NtDatePickerModule, NtDatePickerMonthComponent, NtDatePickerMultiYearComponent, NtDatePickerYearComponent, createMissingDateImplError, yearsPerPage, yearsPerRow };
//# sourceMappingURL=datepicker.js.map
