text: import { Component, EventEmitter, Input, Output } from '@angular/core';
  import { DateFormatter } from './date-formatter';
  // const MIN_DATE:Date = void 0;
  // const MAX_DATE:Date = void 0;
  // const DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
  /*
   const KEYS = {
   13: 'enter',
   32: 'space',
   33: 'pageup',
   34: 'pagedown',
   35: 'end',
   36: 'home',
   37: 'left',
   38: 'up',
   39: 'right',
   40: 'down'
   };
   */
  export var DatePickerInnerComponent = (function () {
      function DatePickerInnerComponent() {
          this.selectionDone = new EventEmitter(undefined);
          this.update = new EventEmitter(false);
          this.stepDay = {};
          this.stepMonth = {};
          this.stepYear = {};
          this.modes = ['day', 'month', 'year'];
          this.dateFormatter = new DateFormatter();
      }
      Object.defineProperty(DatePickerInnerComponent.prototype, "activeDate", {
          get: function () {
              return this._activeDate;
          },
          set: function (value) {
              this._activeDate = value;
          },
          enumerable: true,
          configurable: true
      });
      // todo: add formatter value to Date object
      DatePickerInnerComponent.prototype.ngOnInit = function () {
          // todo: use date for unique value
          this.uniqueId = 'datepicker-' + '-' + Math.floor(Math.random() * 10000);
          if (this.initDate) {
              this.activeDate = this.initDate;
              this.selectedDate = new Date(this.activeDate.valueOf());
              this.update.emit(this.activeDate);
          }
          else if (this.activeDate === undefined) {
              this.activeDate = new Date();
          }
      };
      // this.refreshView should be called here to reflect the changes on the fly
      // tslint:disable-next-line:no-unused-variable
      DatePickerInnerComponent.prototype.ngOnChanges = function (changes) {
          this.refreshView();
      };
      DatePickerInnerComponent.prototype.setCompareHandler = function (handler, type) {
          if (type === 'day') {
              this.compareHandlerDay = handler;
          }
          if (type === 'month') {
              this.compareHandlerMonth = handler;
          }
          if (type === 'year') {
              this.compareHandlerYear = handler;
          }
      };
      DatePickerInnerComponent.prototype.compare = function (date1, date2) {
          if (date1 === undefined || date2 === undefined) {
              return undefined;
          }
          if (this.datepickerMode === 'day' && this.compareHandlerDay) {
              return this.compareHandlerDay(date1, date2);
          }
          if (this.datepickerMode === 'month' && this.compareHandlerMonth) {
              return this.compareHandlerMonth(date1, date2);
          }
          if (this.datepickerMode === 'year' && this.compareHandlerYear) {
              return this.compareHandlerYear(date1, date2);
          }
          return void 0;
      };
      DatePickerInnerComponent.prototype.setRefreshViewHandler = function (handler, type) {
          if (type === 'day') {
              this.refreshViewHandlerDay = handler;
          }
          if (type === 'month') {
              this.refreshViewHandlerMonth = handler;
          }
          if (type === 'year') {
              this.refreshViewHandlerYear = handler;
          }
      };
      DatePickerInnerComponent.prototype.refreshView = function () {
          if (this.datepickerMode === 'day' && this.refreshViewHandlerDay) {
              this.refreshViewHandlerDay();
          }
          if (this.datepickerMode === 'month' && this.refreshViewHandlerMonth) {
              this.refreshViewHandlerMonth();
          }
          if (this.datepickerMode === 'year' && this.refreshViewHandlerYear) {
              this.refreshViewHandlerYear();
          }
      };
      DatePickerInnerComponent.prototype.dateFilter = function (date, format) {
          return this.dateFormatter.format(date, format);
      };
      DatePickerInnerComponent.prototype.isActive = function (dateObject) {
          if (this.compare(dateObject.date, this.activeDate) === 0) {
              this.activeDateId = dateObject.uid;
              return true;
          }
          return false;
      };
      DatePickerInnerComponent.prototype.createDateObject = function (date, format) {
          var dateObject = {};
          dateObject.date = new Date(date.getFullYear(), date.getMonth(), date.getDate());
          dateObject.label = this.dateFilter(date, format);
          dateObject.selected = this.compare(date, this.selectedDate) === 0;
          dateObject.disabled = this.isDisabled(date);
          dateObject.current = this.compare(date, new Date()) === 0;
          dateObject.customClass = this.getCustomClassForDate(dateObject.date);
          return dateObject;
      };
      DatePickerInnerComponent.prototype.split = function (arr, size) {
          var arrays = [];
          while (arr.length > 0) {
              arrays.push(arr.splice(0, size));
          }
          return arrays;
      };
      // Fix a hard-reproducible bug with timezones
      // The bug depends on OS, browser, current timezone and current date
      // i.e.
      // var date = new Date(2014, 0, 1);
      // console.log(date.getFullYear(), date.getMonth(), date.getDate(),
      // date.getHours()); can result in "2013 11 31 23" because of the bug.
      DatePickerInnerComponent.prototype.fixTimeZone = function (date) {
          var hours = date.getHours();
          return new Date(date.getFullYear(), date.getMonth(), date.getDate(), hours === 23 ? hours + 2 : 0);
      };
      DatePickerInnerComponent.prototype.select = function (date, isManual) {
          if (isManual === void 0) { isManual = true; }
          if (this.datepickerMode === this.minMode) {
              if (!this.activeDate) {
                  this.activeDate = new Date(0, 0, 0, 0, 0, 0, 0);
              }
              this.activeDate = new Date(date.getFullYear(), date.getMonth(), date.getDate());
              if (isManual) {
                  this.selectionDone.emit(this.activeDate);
              }
          }
          else {
              this.activeDate = new Date(date.getFullYear(), date.getMonth(), date.getDate());
              this.datepickerMode = this.modes[this.modes.indexOf(this.datepickerMode) - 1];
          }
          this.selectedDate = new Date(this.activeDate.valueOf());
          this.update.emit(this.activeDate);
          this.refreshView();
      };
      DatePickerInnerComponent.prototype.move = function (direction) {
          var expectedStep;
          if (this.datepickerMode === 'day') {
              expectedStep = this.stepDay;
          }
          if (this.datepickerMode === 'month') {
              expectedStep = this.stepMonth;
          }
          if (this.datepickerMode === 'year') {
              expectedStep = this.stepYear;
          }
          if (expectedStep) {
              var year = this.activeDate.getFullYear() + direction * (expectedStep.years || 0);
              var month = this.activeDate.getMonth() + direction * (expectedStep.months || 0);
              this.activeDate = new Date(year, month, 1);
              this.refreshView();
          }
      };
      DatePickerInnerComponent.prototype.toggleMode = function (direction) {
          direction = direction || 1;
          if ((this.datepickerMode === this.maxMode && direction === 1) ||
              (this.datepickerMode === this.minMode && direction === -1)) {
              return;
          }
          this.datepickerMode = this.modes[this.modes.indexOf(this.datepickerMode) + direction];
          this.refreshView();
      };
      DatePickerInnerComponent.prototype.getCustomClassForDate = function (date) {
          var _this = this;
          if (!this.customClass) {
              return '';
          }
          // todo: build a hash of custom classes, it will work faster
          var customClassObject = this.customClass
              .find(function (customClass) {
              return customClass.date.valueOf() === date.valueOf() &&
                  customClass.mode === _this.datepickerMode;
          }, this);
          return customClassObject === undefined ? '' : customClassObject.clazz;
      };
      DatePickerInnerComponent.prototype.compareDateDisabled = function (date1Disabled, date2) {
          if (date1Disabled === undefined || date2 === undefined) {
              return undefined;
          }
          if (date1Disabled.mode === 'day' && this.compareHandlerDay) {
              return this.compareHandlerDay(date1Disabled.date, date2);
          }
          if (date1Disabled.mode === 'month' && this.compareHandlerMonth) {
              return this.compareHandlerMonth(date1Disabled.date, date2);
          }
          if (date1Disabled.mode === 'year' && this.compareHandlerYear) {
              return this.compareHandlerYear(date1Disabled.date, date2);
          }
          return undefined;
      };
      DatePickerInnerComponent.prototype.isDisabled = function (date) {
          var _this = this;
          var isDateDisabled = false;
          if (this.dateDisabled) {
              this.dateDisabled.forEach(function (disabledDate) {
                  if (_this.compareDateDisabled(disabledDate, date) === 0) {
                      isDateDisabled = true;
                  }
              });
          }
          return (isDateDisabled || (this.minDate && this.compare(date, this.minDate) < 0) ||
              (this.maxDate && this.compare(date, this.maxDate) > 0));
      };
      DatePickerInnerComponent.decorators = [
          { type: Component, args: [{
                      selector: 'datepicker-inner',
                      template: "\n    <div *ngIf=\"datepickerMode\" class=\"well well-sm bg-faded p-a card\" role=\"application\" ><!--&lt;!&ndash;ng-keydown=\"keydown($event)\"&ndash;&gt;-->\n      <ng-content></ng-content>\n    </div>\n  "
                  },] },
      ];
      /** @nocollapse */
      DatePickerInnerComponent.ctorParameters = function () { return []; };
      DatePickerInnerComponent.propDecorators = {
          'datepickerMode': [{ type: Input },],
          'startingDay': [{ type: Input },],
          'yearRange': [{ type: Input },],
          'minDate': [{ type: Input },],
          'maxDate': [{ type: Input },],
          'minMode': [{ type: Input },],
          'maxMode': [{ type: Input },],
          'showWeeks': [{ type: Input },],
          'formatDay': [{ type: Input },],
          'formatMonth': [{ type: Input },],
          'formatYear': [{ type: Input },],
          'formatDayHeader': [{ type: Input },],
          'formatDayTitle': [{ type: Input },],
          'formatMonthTitle': [{ type: Input },],
          'onlyCurrentMonth': [{ type: Input },],
          'shortcutPropagation': [{ type: Input },],
          'customClass': [{ type: Input },],
          'monthColLimit': [{ type: Input },],
          'yearColLimit': [{ type: Input },],
          'dateDisabled': [{ type: Input },],
          'initDate': [{ type: Input },],
          'selectionDone': [{ type: Output },],
          'update': [{ type: Output },],
          'activeDate': [{ type: Input },],
      };
      return DatePickerInnerComponent;
  }());
  //# sourceMappingURL=datepicker-inner.component.js.map