import { useMemo } from 'react';
import { filterSelectedRanges, optimizeRangeDates } from './utils';
export const useLogic = ({ selectedRanges, selectedDate, hoveredDate, isMondayFirst = true, baseDate, }) => {
    const accumulator = useMemo(() => new Map(), [baseDate]);
    const { dateA: memoizedSelectedDate, dateB: memoizedHoveredDate } = useMemo(() => optimizeRangeDates({
        baseDate,
        dateA: selectedDate,
        dateB: hoveredDate,
        isMondayFirst,
        accumulator,
    }), [hoveredDate, selectedDate, baseDate]);
    const memoizedSelectedRanges = useMemo(() => filterSelectedRanges(baseDate, isMondayFirst, selectedRanges), [selectedRanges, baseDate]);
    return {
        memoizedSelectedDate,
        memoizedHoveredDate,
        memoizedSelectedRanges,
    };
};
