export const DateRangePreset = {
    NONE: 'NONE',
    SEVEN_DAYS: 'SEVEN_DAYS',
    FOURTEEN_DAYS: 'FOURTEEN_DAYS',
    MONTH: 'MONTH',
    TODAY: 'TODAY',
    TOMORROW: 'TOMORROW',
    NEXT_THREE_DAYS: 'NEXT_THREE_DAYS',
    NEXT_SEVEN_DAYS: 'NEXT_SEVEN_DAYS',
    NEXT_THIRTY_DAYS: 'NEXT_THIRTY_DAYS',
    CUSTOM: 'CUSTOM',
};
export const MAP_DATE_PRESET_TO_KEY = {
    [DateRangePreset.NONE]: 'cairo.filtersPanel.date.none',
    [DateRangePreset.SEVEN_DAYS]: 'cairo.filtersPanel.date.7days',
    [DateRangePreset.FOURTEEN_DAYS]: 'cairo.filtersPanel.date.14days',
    [DateRangePreset.MONTH]: 'cairo.filtersPanel.date.lastMonth',
    [DateRangePreset.CUSTOM]: 'cairo.filtersPanel.date.custom',
    [DateRangePreset.TODAY]: 'cairo.filtersPanel.date.today',
    [DateRangePreset.TOMORROW]: 'cairo.filtersPanel.date.tomorrow',
    [DateRangePreset.NEXT_THREE_DAYS]: 'cairo.filtersPanel.date.next3Days',
    [DateRangePreset.NEXT_SEVEN_DAYS]: 'cairo.filtersPanel.date.next7Days',
    [DateRangePreset.NEXT_THIRTY_DAYS]: 'cairo.filtersPanel.date.next30Days',
};
export const DefaultDateRangePreset = {
    NONE: 'NONE',
    SEVEN_DAYS: 'SEVEN_DAYS',
    FOURTEEN_DAYS: 'FOURTEEN_DAYS',
    MONTH: 'MONTH',
    CUSTOM: 'CUSTOM',
};
export const shouldRenderPresetTag = (preset) => preset &&
    Object.values(DateRangePreset).includes(preset) &&
    preset !== DateRangePreset.NONE &&
    preset !== DateRangePreset.CUSTOM;
export const presetToDaysAmount = {
    [DateRangePreset.SEVEN_DAYS]: {
        days: -7,
    },
    [DateRangePreset.FOURTEEN_DAYS]: {
        days: -14,
    },
    [DateRangePreset.MONTH]: {
        months: -1,
    },
    [DateRangePreset.TODAY]: {
        days: 0,
    },
    [DateRangePreset.TOMORROW]: {
        days: 1,
    },
    [DateRangePreset.NEXT_THREE_DAYS]: {
        days: 3,
    },
    [DateRangePreset.NEXT_SEVEN_DAYS]: {
        days: 7,
    },
    [DateRangePreset.NEXT_THIRTY_DAYS]: {
        days: 30,
    },
};
export const getDatesFromPreset = (preset) => {
    const today = new Date();
    const presetDiff = preset ? presetToDaysAmount[preset] : undefined;
    if (!presetDiff) {
        return { from: null, to: null };
    }
    const fromDate = new Date(today.getTime());
    const { days, months, years } = presetDiff;
    if (days) {
        fromDate.setDate(today.getDate() + days);
        // tomorrow preset is the ony preset which does not include today
        if (preset === DateRangePreset.TOMORROW) {
            today.setDate(today.getDate() + days);
        }
    }
    if (months) {
        fromDate.setMonth(today.getMonth() + months);
    }
    if (years) {
        fromDate.setFullYear(today.getFullYear() + years);
    }
    if (fromDate.getTime() > today.getTime()) {
        today.setHours(0, 0, 0, 0);
        fromDate.setHours(23, 59, 59, 999);
        return { from: today, to: fromDate, preset };
    }
    fromDate.setHours(0, 0, 0, 0);
    today.setHours(23, 59, 59, 999);
    return { from: fromDate, to: today, preset };
};
//# sourceMappingURL=dateRangeUtils.js.map