"use strict";

exports.__esModule = true;
exports.default = void 0;
var _basePicker = _interopRequireDefault(require("./base-picker"));
var _utils = require("../utils");
var _utils2 = require("../../utils");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var YearPicker = /*#__PURE__*/function (_BasePicker) {
  _inheritsLoose(YearPicker, _BasePicker);
  function YearPicker() {
    return _BasePicker.apply(this, arguments) || this;
  }
  var _proto = YearPicker.prototype;
  _proto.getStep = function getStep() {
    return 'year';
  };
  _proto.getDisableType = function getDisableType() {
    return 'year';
  };
  _proto.getRangeCheck = function getRangeCheck() {
    return {
      date: {
        hasYear: true,
        hasMonth: false,
        hasDay: false
      }
    };
  };
  _proto.getDataSource = function getDataSource(locale) {
    var validRange = this.props.validRange;
    var start = 1970;
    var end = 1970 + 300;
    var yearLocale = (0, _utils2.get)(locale, 'locale.DatePicker.year', '年');
    if (validRange) {
      start = validRange[0].getFullYear();
      end = validRange[1].getFullYear();
    }
    return [this.filterDataSource((0, _utils.rangeOptions)(start, end, yearLocale), function (d, it) {
      (0, _utils.resetMonth)(d);
      (0, _utils.resetTime)(d);
      d.setFullYear(it.value);
    }, 'year')];
  };
  _proto.toDate = function toDate(values) {
    var d = new Date();
    d.setFullYear(values[0]);
    (0, _utils.resetMonth)(d);
    (0, _utils.resetTime)(d);
    return d;
  };
  _proto.toValues = function toValues(d) {
    return [d.getFullYear()];
  };
  return YearPicker;
}(_basePicker.default);
exports.default = YearPicker;