import type { ReadyQueryResultsPage } from '../index';
import { DimensionType, type ItemsMap } from '../types/field';
import { type ParametersValuesMap } from '../types/parameters';
import { type PivotConfig, type PivotData, type PivotRowTotalsByIndex } 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;
export declare const normalizePivotMatchRaw: (raw: unknown) => string | null;
export declare const buildPivotRowTotalKey: (indexEntries: Array<[fieldId: string, raw: unknown]>) => string;
/**
 * Flatten the single wide totals row from a `calculate-total`
 * (`kind: 'columnTotal'`) response into the `warehouseColumnTotals` map keyed by
 * pivot SQL column name. Non-numeric cells are dropped — the lookup only uses
 * numbers. Shared by the frontend hook and the backend export path so both
 * produce identical column totals.
 */
export declare const buildWarehouseColumnTotals: (rows: ResultRow[]) => Record<string, number>;
/**
 * Build the `warehouseRowTotals` map from a `calculate-total`
 * (`kind: 'rowTotal'`) response — one flat row per index-value combination, each
 * keyed by its index-dimension values (`buildPivotRowTotalKey`) → metric fieldId
 * → numeric total. `indexFieldIds` must match the index dims the pivot worker
 * uses so the keys align. Shared by the frontend hook and the backend export
 * path.
 */
export declare const buildWarehouseRowTotals: (rows: ResultRow[], indexFieldIds: string[]) => PivotRowTotalsByIndex;
/**
 * 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, groupedRowSubtotals, warehouseRowTotals, warehouseColumnTotals, warehouseGrandTotals, columnLimit, parameters, }: {
    rows: ResultRow[];
    pivotDetails: NonNullable<ReadyQueryResultsPage["pivotDetails"]>;
    pivotConfig: Pick<PivotConfig, "rowTotals" | "columnTotals" | "metricsAsRows" | "hiddenMetricFieldIds" | "hiddenDimensionFieldIds" | "visibleMetricFieldIds" | "columnOrder" | "rowFieldIds">;
    getField: FieldFunction;
    getFieldLabel: FieldLabelFunction;
    groupedSubtotals: Record<string, Record<string, number>[]> | undefined;
    groupedRowSubtotals?: PivotData["groupedRowSubtotals"];
    /**
     * 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>;
    /**
     * Warehouse-computed grand totals from `calculate-total`
     * (`kind: 'grandTotal'`), keyed by metric field id. These are only used
     * when both total axes are enabled.
     */
    warehouseGrandTotals?: 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;
    warehouseRowTotals?: PivotRowTotalsByIndex;
    warehouseColumnTotals?: Record<string, number>;
    warehouseGrandTotals?: Record<string, number>;
};
export declare const pivotResultsAsData: ({ pivotConfig, rows, itemMap, customLabels, onlyRaw, undefinedCharacter, pivotDetails, timezone, formatTemporalsForSpreadsheet, warehouseRowTotals, warehouseColumnTotals, warehouseGrandTotals, }: PivotResultsParams) => PivotResultsData;
export declare const pivotResultsAsCsv: (params: PivotResultsParams) => string[][];
export {};
//# sourceMappingURL=pivotQueryResults.d.ts.map