'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
var PanelBody = require('../PanelBody.js');
var useMergeProps = require('../../hooks/useMergeProps.js');
var constants = require('../constants.js');

const DECADE_ROW_COUNT = 4;
function DecadeBody(_props) {
  const props = useMergeProps.default(_props);
  const DECADE_UNIT_DIFF_DES = constants.DECADE_UNIT_DIFF - 1;
  const {
    prefixCls,
    viewDate,
    generateConfig
  } = props;
  const cellPrefixCls = `${prefixCls}-cell`;
  const yearNumber = generateConfig.getYear(viewDate);
  const decadeYearNumber = Math.floor(yearNumber / constants.DECADE_UNIT_DIFF) * constants.DECADE_UNIT_DIFF;
  const startDecadeYear = Math.floor(yearNumber / constants.DECADE_DISTANCE_COUNT) * constants.DECADE_DISTANCE_COUNT;
  const endDecadeYear = startDecadeYear + constants.DECADE_DISTANCE_COUNT - 1;
  const baseDecadeYear = generateConfig.setYear(viewDate, startDecadeYear - Math.ceil((constants.DECADE_COL_COUNT * DECADE_ROW_COUNT * constants.DECADE_UNIT_DIFF - constants.DECADE_DISTANCE_COUNT) / 2));
  const getCellClassName = (date) => {
    const startDecadeNumber = generateConfig.getYear(date);
    const endDecadeNumber = startDecadeNumber + DECADE_UNIT_DIFF_DES;
    return {
      [`${cellPrefixCls}-in-view`]: startDecadeYear <= startDecadeNumber && endDecadeNumber <= endDecadeYear,
      [`${cellPrefixCls}-selected`]: startDecadeNumber === decadeYearNumber
    };
  };
  return vue.createVNode(PanelBody.default, vue.mergeProps(props, {
    "rowNum": DECADE_ROW_COUNT,
    "colNum": constants.DECADE_COL_COUNT,
    "baseDate": baseDecadeYear,
    "getCellText": (date) => {
      const startDecadeNumber = generateConfig.getYear(date);
      return `${startDecadeNumber}-${startDecadeNumber + DECADE_UNIT_DIFF_DES}`;
    },
    "getCellClassName": getCellClassName,
    "getCellDate": (date, offset) => generateConfig.addYear(date, offset * constants.DECADE_UNIT_DIFF)
  }), null);
}
DecadeBody.displayName = "DecadeBody";
DecadeBody.inheritAttrs = false;

exports.default = DecadeBody;
//# sourceMappingURL=DecadeBody.js.map
