"use strict";
const React = require("react");
const merge = require("../../../../../../../../lodash@4.17.21/node_modules/lodash/merge.js");
const dayjs = require("../../../_util/dayjs.js");
const classNames = require("../../../_util/classNames.js");
const index = require("../../../ConfigProvider/index.js");
const header = require("../header.js");
const body = require("../body.js");
const constant = require("../../../_util/constant.js");
const context = require("../../context.js");
const emotionReactJsxRuntime_browser_esm = require("../../../../../../../../@emotion_react@11.10.4_3toe27fv7etiytxb5kxc7fxaw4/node_modules/@emotion/react/jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js");
var __assign = globalThis && globalThis.__assign || function() {
  __assign = Object.assign || function(t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
      s = arguments[i];
      for (var p in s)
        if (Object.prototype.hasOwnProperty.call(s, p))
          t[p] = s[p];
    }
    return t;
  };
  return __assign.apply(this, arguments);
};
var __rest = globalThis && globalThis.__rest || function(s, e) {
  var t = {};
  for (var p in s)
    if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
      t[p] = s[p];
  if (s != null && typeof Object.getOwnPropertySymbols === "function")
    for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
      if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
        t[p[i]] = s[p[i]];
    }
  return t;
};
function YearPicker(props) {
  var pageShowDate = props.pageShowDate, style = props.style, onMouseEnterCell = props.onMouseEnterCell, onMouseLeaveCell = props.onMouseLeaveCell, dateRender = props.dateRender, disabledDate = props.disabledDate, value = props.value, locale = props.locale, isRangePicker = props.isRangePicker, onSelect = props.onSelect, rangeValues = props.rangeValues, onSuperPrev = props.onSuperPrev, onSuperNext = props.onSuperNext, format = props.format, icons = props.icons, originMode = props.originMode, rest = __rest(props, ["pageShowDate", "style", "onMouseEnterCell", "onMouseLeaveCell", "dateRender", "disabledDate", "value", "locale", "isRangePicker", "onSelect", "rangeValues", "onSuperPrev", "onSuperNext", "format", "icons", "originMode"]);
  var _a = React.useContext(index.ConfigContext), globalLocale = _a.locale, getPrefixCls = _a.getPrefixCls, rtl = _a.rtl;
  var DATEPICKER_LOCALE = merge(globalLocale.DatePicker, locale);
  var CALENDAR_LOCALE = DATEPICKER_LOCALE.Calendar;
  var _b = React.useContext(context), utcOffset = _b.utcOffset, timezone = _b.timezone;
  var prefixCls = getPrefixCls("panel-year");
  var classNames$1 = classNames(prefixCls);
  var bodyProps = isRangePicker ? {
    rangeValues
  } : {
    value
  };
  var showYear = pageShowDate ? pageShowDate.year() : dayjs.getNow(utcOffset, timezone).year();
  var startYear = Math.floor(showYear / 10) * 10 - 1;
  var groupRow = constant.newArray(3).map(function(_) {
    return "";
  });
  var rows = constant.newArray(4).map(function(_) {
    return groupRow;
  }).map(function(arr, i) {
    return arr.map(function(_, j) {
      return {
        name: startYear + i * 3 + j,
        time: dayjs.dayjs("" + (startYear + i * 3 + j), "YYYY").endOf("year"),
        isPrev: i === 0 && j === 0,
        isNext: i === 3 && j === 2
      };
    });
  });
  function renderCalendar() {
    return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(body, {
      ...__assign({}, rest, bodyProps, {
        prefixCls: getPrefixCls("picker"),
        rows,
        onSelectDate: onSelect,
        isSameTime: function(current, target) {
          return current.isSame(target, "year");
        },
        onMouseEnterCell,
        onMouseLeaveCell,
        dateRender,
        disabledDate,
        CALENDAR_LOCALE,
        mode: "year",
        originMode,
        format
      })
    });
  }
  var headerOperations = {
    onSuperPrev,
    onSuperNext
  };
  return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsxs("div", {
    className: classNames$1,
    style,
    children: [/* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(header, {
      ...__assign({
        prefixCls: getPrefixCls("picker"),
        icons,
        title: rows[0][1].name + " - " + rows[3][2].name,
        rtl
      }, headerOperations)
    }), renderCalendar()]
  });
}
YearPicker.defaultProps = {
  pickerType: "year"
};
module.exports = YearPicker;
//# sourceMappingURL=index.js.map
