import dayjs from 'dayjs';
import { type AnyType } from '../types/any';
import type { CatalogField, MetricWithAssociatedTimeDimension } from '../types/catalog';
import { type CompiledTable } from '../types/explore';
import { DimensionType, type CompiledDimension, type CompiledMetric, type CustomSqlDimension, type Dimension } from '../types/field';
import { FilterOperator, type DateFilterSettings, type FieldTarget, type FilterRule } from '../types/filter';
import { type MetricExploreDataPoint, type MetricExplorerDateRange, type MetricExplorerQuery } from '../types/metricsExplorer';
import { type WarehouseTypes } from '../types/projects';
import { TimeFrames, type DefaultTimeDimension } from '../types/timeFrames';
type DateFilter = FilterRule<FilterOperator, FieldTarget, unknown, DateFilterSettings>;
type ImpelemntedTimeframe = TimeFrames.DAY | TimeFrames.WEEK | TimeFrames.MONTH | TimeFrames.YEAR;
type UnimplementedTimeframe = Exclude<TimeFrames, ImpelemntedTimeframe>;
export declare const assertUnimplementedTimeframe: (timeframe: UnimplementedTimeframe) => never;
export declare const getFieldIdForDateDimension: (fieldId: string, timeframe: TimeFrames) => string;
export declare const getDateCalcUtils: (timeFrame: TimeFrames, grain?: TimeFrames) => {
    forward: (date: Date) => Date;
    back: (date: Date) => Date;
};
export declare const METRICS_EXPLORER_DATE_FORMAT = "YYYY-MM-DD";
export declare const getDateRangeFromString: (dateRange: [string, string]) => MetricExplorerDateRange;
export declare const getGrainForDateRange: (dateRange: [Date, Date]) => ImpelemntedTimeframe;
export declare const getMetricsExplorerSegmentFilters: (segmentDimension: string | null, segments: string[]) => FilterRule[];
export declare const getMetricExplorerDateRangeFilters: (timeDimensionConfig: TimeDimensionConfig, dateRange: MetricExplorerDateRange) => DateFilter[];
export declare const parseMetricValue: (value: unknown) => number | null;
export declare const MAX_SEGMENT_DIMENSION_UNIQUE_VALUES = 10;
export declare const getMetricExplorerDataPoints: (dimension: Dimension, metric: MetricWithAssociatedTimeDimension, metricRows: Record<string, AnyType>[], segmentDimensionId: string | null) => {
    dataPoints: Array<MetricExploreDataPoint>;
    isSegmentDimensionFiltered: boolean;
};
export declare const getMetricExplorerDataPointsWithCompare: (dimension: Dimension, compareDimension: Dimension, metric: MetricWithAssociatedTimeDimension, metricRows: Record<string, AnyType>[], compareMetricRows: Record<string, AnyType>[], query: MetricExplorerQuery, timeFrame: TimeFrames) => {
    dataPoints: Array<MetricExploreDataPoint>;
};
/**
 * Get the date range for a given time interval, based on the current date and the time interval
 * Time grain Year: -> past 3 years (i.e. 3 completed years + this uncompleted year)
 * Time grain Month -> past 12 months (i.e. 12 completed months + this uncompleted month)
 * Time grain Week -> past 12 weeks (i.e. 12 completed weeks + this uncompleted week)
 * Time grain Day -> past 30 days (i.e. 30 completed days + this uncompleted day)
 * @param timeInterval - The time interval
 * @returns The date range
 */
export declare const getDefaultDateRangeFromInterval: (timeInterval: TimeFrames) => MetricExplorerDateRange;
export declare const getDefaultMetricTreeNodeDateRange: (timeFrame: TimeFrames) => MetricExplorerDateRange;
/**
 * Default time interval to use when no time interval is provided.
 * For example, when there is no default time dimension defined for a metric or table.
 */
export declare const DEFAULT_METRICS_EXPLORER_TIME_INTERVAL = TimeFrames.MONTH;
export type TimeDimensionConfig = DefaultTimeDimension & {
    table: string;
};
export declare const getFirstAvailableTimeDimension: (metric: MetricWithAssociatedTimeDimension) => TimeDimensionConfig | undefined;
export declare const getDefaultTimeDimension: (metric: CompiledMetric, table?: CompiledTable) => DefaultTimeDimension | undefined;
export declare const getAvailableTimeDimensionsFromTables: (tables: Record<string, CompiledTable>) => (CompiledDimension & {
    type: DimensionType.DATE | DimensionType.TIMESTAMP;
})[];
/**
 * Returns dimensions that can be used for filtering based on type constraints only.
 * Only STRING and BOOLEAN dimensions are allowed, excluding time-derived dimensions.
 * Does NOT apply spotlight settings - frontend handles that with metric allowlist.
 */
export declare const getTypeValidFilterDimensions: (dimensions: CompiledDimension[]) => CompiledDimension[];
/**
 * Filters dimensions for a specific metric, applying metric's spotlight allowlist.
 * Dimensions should already be type-valid from the backend.
 */
export declare const getFilterDimensionsForMetric: (dimensions: CompiledDimension[], metric: Pick<CatalogField, "spotlightFilterBy"> | undefined) => CompiledDimension[];
/**
 * Returns dimensions that can be used for segmenting based on type constraints only.
 * Only STRING and BOOLEAN dimensions are allowed, excluding time-derived dimensions.
 * Does NOT apply spotlight settings - frontend handles that with metric allowlist.
 */
export declare const getTypeValidSegmentDimensions: (dimensions: CompiledDimension[]) => CompiledDimension[];
/**
 * Filters dimensions for a specific metric, applying metric's spotlight allowlist.
 * Dimensions should already be type-valid from the backend.
 */
export declare const getSegmentDimensionsForMetric: (dimensions: CompiledDimension[], metric: Pick<CatalogField, "spotlightSegmentBy"> | undefined) => CompiledDimension[];
/**
 * Resolve the metric's spotlight `default_segment` (a dimension ref, bare or
 * joined like "customers.first_name") to the explorer's fieldId, but only if it
 * is one of the dimensions currently available to segment by.
 * Returns null when there is no default or it is not available.
 */
export declare const getInitialDefaultSegment: (metric: Pick<CatalogField, "spotlightDefaultSegment" | "tableName"> | undefined, availableSegmentDimensions: CompiledDimension[]) => string | null;
/**
 * Build the Metrics Explorer `FilterRule` from the metric's spotlight
 * `default_filter`. Returns undefined when there is no default or the dimension
 * is not available to filter by.
 */
export declare const getInitialDefaultFilterRule: (metric: Pick<CatalogField, "spotlightDefaultFilter" | "tableName"> | undefined, availableFilterDimensions: CompiledDimension[]) => FilterRule | undefined;
export declare const getAvailableCompareMetrics: (metrics: MetricWithAssociatedTimeDimension[]) => MetricWithAssociatedTimeDimension[];
/**
 * Calculate date ranges for rolling period comparisons.
 * Current period: yesterday - (days-1) days ago to yesterday
 * Previous period: (days*2) days ago to (days+1) days ago
 *
 * Example for 7 days (if today is Feb 4):
 * Current:  Jan 28 - Feb 3
 * Previous: Jan 21 - Jan 27
 */
export declare const getRollingPeriodDates: (days: number) => {
    current: {
        start: dayjs.Dayjs;
        end: dayjs.Dayjs;
    };
    previous: {
        start: dayjs.Dayjs;
        end: dayjs.Dayjs;
    };
};
/**
 * Build a custom SQL dimension that buckets data into periods:
 * - 0 = current period
 * - 1 = previous period
 * - NULL = outside both periods
 */
export declare const buildRollingPeriodCustomDimension: (timeDimensionFieldRef: string, // e.g., "${orders.order_date_day}"
table: string, rollingDays: number, adapterType: WarehouseTypes) => CustomSqlDimension;
export {};
//# sourceMappingURL=metricsExplorer.d.ts.map