'use strict';

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

var vue = require('vue');
var PanelBody = require('../PanelBody.cjs');
var useMergeProps = require('../../hooks/useMergeProps.cjs');
var constant = require('./constant.cjs');

const DECADE_COL_COUNT = 3;
const DECADE_ROW_COUNT = 4;
function DecadeBody(_props) {
  const props = useMergeProps.default(_props);
  const DECADE_UNIT_DIFF_DES = constant.DECADE_UNIT_DIFF - 1;
  const {
    prefixCls,
    viewDate,
    generateConfig
  } = props;
  const cellPrefixCls = `${prefixCls}-cell`;
  const yearNumber = generateConfig.getYear(viewDate);
  const decadeYearNumber = Math.floor(yearNumber / constant.DECADE_UNIT_DIFF) * constant.DECADE_UNIT_DIFF;
  const startDecadeYear = Math.floor(yearNumber / constant.DECADE_DISTANCE_COUNT) * constant.DECADE_DISTANCE_COUNT;
  const endDecadeYear = startDecadeYear + constant.DECADE_DISTANCE_COUNT - 1;
  const baseDecadeYear = generateConfig.setYear(viewDate, startDecadeYear - Math.ceil((DECADE_COL_COUNT * DECADE_ROW_COUNT * constant.DECADE_UNIT_DIFF - constant.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, {
    ...props,
    "rowNum": DECADE_ROW_COUNT,
    "colNum": 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 * constant.DECADE_UNIT_DIFF)
  }, null);
}
DecadeBody.displayName = "DecadeBody";
DecadeBody.inheritAttrs = false;

exports.DECADE_COL_COUNT = DECADE_COL_COUNT;
exports.default = DecadeBody;
//# sourceMappingURL=DecadeBody.cjs.map
