import { InternalDateGetter } from './InternalDateGetter.js';
import { InternalDateComponentType } from './types.js';
var InternalDateCalculator = /** @class */ (function () {
    function InternalDateCalculator() {
    }
    InternalDateCalculator.calcRangeStartDateComponent = function (type, _a, _b) {
        var year = _a.year, month = _a.month;
        var startYear = _b.year, startMonth = _b.month, startDate = _b.date;
        if (type === InternalDateComponentType.Year) {
            return startYear;
        }
        else if (type === InternalDateComponentType.Month) {
            return year === startYear ? startMonth : InternalDateGetter.getDefaultMin(type);
        }
        return year === startYear && month === startMonth ? startDate : InternalDateGetter.getDefaultMin(type);
    };
    InternalDateCalculator.calcRangeEndDateComponent = function (type, _a, _b) {
        var year = _a.year, month = _a.month, date = _a.date;
        var endYear = _b.year, endMonth = _b.month, endDate = _b.date;
        if (type === InternalDateComponentType.Year) {
            return endYear;
        }
        else if (type === InternalDateComponentType.Month) {
            return year === endYear ? endMonth : InternalDateGetter.getDefaultMax(type);
        }
        return year === endYear && month === endMonth
            ? endDate
            : InternalDateGetter.getDefaultMax(type, { year: year, month: month, date: date });
    };
    InternalDateCalculator.calcShiftValueDateComponent = function (step, prevValue, start, end, isLoop) {
        if (isLoop === void 0) { isLoop = true; }
        var value = step + Number(prevValue);
        if (step !== 0 && (start - value > Math.abs(step) || value - end > Math.abs(step))) {
            return step < 0 ? end : start;
        }
        if (isLoop) {
            if (value < start) {
                return end;
            }
            else if (value > end) {
                return start;
            }
            return value;
        }
        if (value < start) {
            return start;
        }
        else if (value > end) {
            return end;
        }
        return value;
    };
    return InternalDateCalculator;
}());
export { InternalDateCalculator };
//# sourceMappingURL=InternalDateCalculator.js.map