"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FUNNEL_DATE_PRESETS = void 0;
exports.resolveFunnelDateRange = resolveFunnelDateRange;
// Date range presets matching common funnel analysis patterns
exports.FUNNEL_DATE_PRESETS = [
    { value: 'last_7_days', label: 'Last 7 days', days: 7 },
    { value: 'last_14_days', label: 'Last 14 days', days: 14 },
    { value: 'last_30_days', label: 'Last 30 days', days: 30 },
    { value: 'last_90_days', label: 'Last 90 days', days: 90 },
    { value: 'last_6_months', label: 'Last 6 months', days: 180 },
    { value: 'last_12_months', label: 'Last 12 months', days: 365 },
    { value: 'custom', label: 'Custom range', days: null },
];
// Helper to resolve date range to start/end dates
function resolveFunnelDateRange(dateRange) {
    const end = new Date();
    end.setHours(23, 59, 59, 999);
    if (dateRange.type === 'custom') {
        return {
            start: new Date(dateRange.start),
            end: new Date(dateRange.end),
        };
    }
    const preset = exports.FUNNEL_DATE_PRESETS.find((p) => p.value === dateRange.preset);
    if (!preset || preset.days === null) {
        throw new Error(`Invalid preset: ${dateRange.preset}`);
    }
    const start = new Date();
    start.setDate(start.getDate() - preset.days);
    start.setHours(0, 0, 0, 0);
    return { start, end };
}
//# sourceMappingURL=funnel.js.map