"use strict";

exports.__esModule = true;
exports.default = void 0;
var _datePicker = _interopRequireDefault(require("../embed-picker/date-picker"));
var _dayjs = _interopRequireDefault(require("dayjs"));
var _utils = 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 EmbedMinutePicker = /*#__PURE__*/function (_DatePicker) {
  _inheritsLoose(EmbedMinutePicker, _DatePicker);
  function EmbedMinutePicker() {
    return _DatePicker.apply(this, arguments) || this;
  }
  var _proto = EmbedMinutePicker.prototype;
  _proto.getStep = function getStep() {
    return 'minute';
  };
  _proto.getDisableType = function getDisableType() {
    return 'minute';
  };
  _proto.getRangeCheck = function getRangeCheck() {
    return {
      date: {
        hasYear: true,
        hasMonth: true,
        hasDay: true
      },
      time: {
        hasHour: true,
        hasMinute: true,
        hasSecond: false
      }
    };
  };
  _proto.getDataSource = function getDataSource(locale) {
    var _this = this;
    var result = _DatePicker.prototype.getDataSource.call(this, locale);
    var hourLocale = (0, _utils.get)(locale, 'locale.DatePicker.hour', '时');
    var minuteLocale = (0, _utils.get)(locale, 'locale.DatePicker.minute', '分');
    var year = this.value.getFullYear();
    var month = this.value.getMonth();
    var date = this.value.getDate();
    var hourOpts = (0, _utils.range)(24).map(function (_, index) {
      return {
        label: "" + index + hourLocale,
        value: index
      };
    });
    var minuteOpts = (0, _utils.range)(60).map(function (_, index) {
      return {
        label: "" + index + minuteLocale,
        value: index
      };
    });
    return [].concat(result, [this.filterDataSource(hourOpts, function (d, it) {
      d.setMinutes(0);
      d.setMilliseconds(0);
      d.setFullYear(year);
      d.setMonth(month);
      d.setDate(date);
      d.setHours(it.value);
    }, 'hour'), this.filterDataSource(minuteOpts, function (d, it) {
      d.setMilliseconds(0);
      d.setFullYear(year);
      d.setMonth(month);
      d.setDate(date);
      d.setHours(_this.value.getHours());
      d.setMinutes(it.value);
    }, 'minute')]);
  };
  _proto.toDate = function toDate(values) {
    var d = _DatePicker.prototype.toDate.call(this, values);
    return (0, _dayjs.default)(d).month(values[1] - 1).date(values[2]).hour(values[3]).minute(values[4]).toDate();
  };
  _proto.toValues = function toValues(d) {
    var values = _DatePicker.prototype.toValues.call(this, d);
    return [].concat(values, [d.getHours(), d.getMinutes()]);
  };
  return EmbedMinutePicker;
}(_datePicker.default);
exports.default = EmbedMinutePicker;