import type { ReadyQueryResultsPage } from '../index';
import { DimensionType, type ItemsMap } from '../types/field';
import { type ParametersValuesMap } from '../types/parameters';
import { type PivotConfig, type PivotData } from '../types/pivot';
import { type ResultRow } from '../types/results';
import { TimeFrames } from '../types/timeFrames';
type FieldFunction = (fieldId: string) => ItemsMap[string] | undefined;
type FieldLabelFunction = (fieldId: string) => string | undefined;
/**
 * Warehouse-computed row totals, keyed by a stable index-value key (built with
 * `buildPivotRowTotalKey`) → metric fieldId → numeric total. Produced by the
 * `calculate-total` endpoint (`kind: 'rowTotal'`) and fed into the pivot worker
 * so the displayed row totals are correct for every metric type — count
 * distinct, average, ratios — instead of the client-side sum that only holds
 * for additive metrics.
 */
export type PivotRowTotalsByIndex = Record<string, Record<string, number>>;
export declare const buildPivotRowTotalKey: (indexEntries: Array<[fieldId: string, raw: unknown]>) => string;
/**
 * Converts SQL-pivoted results to PivotData format
 * This handles results that are already pivoted at the SQL level (e.g., payments_total_revenue_any_bank_transfer)
 * and transforms them into the same PivotData structure consumed by the pivot table.
 */
export declare const convertSqlPivotedRowsToPivotData: ({ rows, pivotDetails, pivotConfig, getField, getFieldLabel, groupedSubtotals, warehouseRowTotals, warehouseColumnTotals, columnLimit, parameters, }: {
    rows: ResultRow[];
    pivotDetails: NonNullable<ReadyQueryResultsPage["pivotDetails"]>;
    pivotConfig: Pick<PivotConfig, "rowTotals" | "columnTotals" | "metricsAsRows" | "hiddenMetricFieldIds" | "hiddenDimensionFieldIds" | "visibleMetricFieldIds" | "columnOrder">;
    getField: FieldFunction;
    getFieldLabel: FieldLabelFunction;
    groupedSubtotals: Record<string, Record<string, number>[]> | undefined;
    /**
     * Warehouse-computed row totals from `calculate-total` (`kind: 'rowTotal'`).
     * Row totals are exclusively warehouse-computed — there is no client-side
     * fallback — so cells are blank until this resolves (or stay blank if the
     * source query can't be totalled). Drives both the metrics-as-columns and
     * metrics-as-rows layouts.
     */
    warehouseRowTotals?: PivotRowTotalsByIndex;
    /**
     * Warehouse-computed column totals from `calculate-total`
     * (`kind: 'columnTotal'`), keyed by pivot SQL column name. Column totals
     * are exclusively warehouse-computed — there is no client-side fallback —
     * so cells are blank until this resolves (or stay blank if the source
     * query can't be totalled). Drives both layouts.
     */
    warehouseColumnTotals?: Record<string, number>;
    columnLimit?: number;
    parameters?: ParametersValuesMap;
}) => PivotData;
export type PivotResultsDataCell = {
    raw: unknown;
    formatted: string;
    fieldId: string;
};
export type PivotResultsData = {
    headers: string[][];
    dataRows: Array<Array<PivotResultsDataCell>>;
    fieldIds: string[];
    hasIndex: boolean;
};
export declare function timeIntervalToExcelNumFmt(timeInterval: TimeFrames | undefined, dimensionType: DimensionType): string | null;
type PivotResultsParams = {
    pivotConfig: PivotConfig;
    pivotDetails: NonNullable<ReadyQueryResultsPage['pivotDetails']>;
    rows: ResultRow[];
    itemMap: ItemsMap;
    customLabels: Record<string, string> | undefined;
    onlyRaw: boolean;
    undefinedCharacter?: string;
    timezone?: string;
    formatTemporalsForSpreadsheet?: boolean;
};
export declare const pivotResultsAsData: ({ pivotConfig, rows, itemMap, customLabels, onlyRaw, undefinedCharacter, pivotDetails, timezone, formatTemporalsForSpreadsheet, }: PivotResultsParams) => PivotResultsData;
export declare const pivotResultsAsCsv: (params: PivotResultsParams) => string[][];
export {};
//# sourceMappingURL=pivotQueryResults.d.ts.map