"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "useYears", {
    enumerable: true,
    get: function() {
        return useYears;
    }
});
var _react = require("react");
var _utils = require("../utils");
var _types = require("../store/types");
var useYears = function useYears(param) {
    var date = param.date, value = param.value, startYear = param.startYear, eventList = param.eventList, disabledList = param.disabledList, min = param.min, max = param.max, includeEdgeDates = param.includeEdgeDates;
    return (0, _react.useMemo)(function() {
        // type-coverage:ignore-next-line
        var years = Array.from(Array(_utils.YEAR_RENDER_COUNT), function(_, i) {
            var yearValue = startYear + i;
            return {
                isCurrent: (0, _utils.isCurrentYear)(startYear + i),
                isSelected: Array.isArray(value) ? Boolean(value.find(function(v) {
                    return (0, _utils.isSelectedYear)(yearValue, v);
                })) : (0, _utils.isSelectedYear)(yearValue, value),
                inRange: Array.isArray(value) ? (0, _utils.isDateInRange)(yearValue, 0, 1, value) : false,
                date: {
                    year: yearValue,
                    monthIndex: 0,
                    day: 1
                },
                yearValue: yearValue
            };
        });
        if ((eventList === null || eventList === void 0 ? void 0 : eventList.length) || (disabledList === null || disabledList === void 0 ? void 0 : disabledList.length) || max || min) {
            var modifiedMonths = (0, _utils.getDatesWithModifications)({
                dates: years,
                type: _types.CalendarState.Years,
                min: min,
                max: max,
                includeEdgeDates: includeEdgeDates,
                eventList: eventList,
                disabledList: disabledList
            });
            return (0, _utils.getMatrix)(modifiedMonths, 3);
        }
        return (0, _utils.getMatrix)(years, 3);
    }, [
        date,
        startYear,
        value,
        eventList,
        disabledList,
        max,
        min
    ]);
};
