import { Cell, Field, NestField, RecordOrRepeatedRecordCell, RecordOrRepeatedRecordField, SortableField } from '../../data_tree';
/**
 * Represents a unique combination of dimension values in a pivot.
 * Each PivotedField corresponds to one set of column headers.
 */
export type PivotedField = {
    /** JSON-stringified key for lookup (includes parent field name and dimension values) */
    key: string;
    /** The dimension cell values for this pivot combination */
    values: Cell[];
    /** The parent nested field being pivoted */
    parentField: RecordOrRepeatedRecordField;
    /** Number of non-dimension (measure) columns this spans */
    span: number;
    /** Map from dimension field name to cell value for quick lookup */
    fieldValueMap: Map<string, Cell>;
};
/**
 * Represents a single column in a pivoted table.
 * Combines a specific dimension value combination with a measure field.
 */
export type PivotedColumnField = {
    /** The pivot dimension combination */
    pivotedField: PivotedField;
    /** The actual measure field to render */
    field: Field;
    /** User-defined dimension fields (if specified) */
    userDefinedPivotDimensions?: string[];
};
export type { SortableField };
/**
 * Complete configuration for a pivot field.
 */
export type PivotConfig = {
    /** The nested field being pivoted */
    field: NestField;
    /** Dimension fields (used for column headers) */
    dimensions: SortableField[];
    /** Non-dimension fields (measures to display) */
    nonDimensions: SortableField[];
    /** All unique dimension value combinations, sorted */
    pivotedFields: PivotedField[];
    /** Expanded column list: pivotedFields * nonDimensions */
    columnFields: PivotedColumnField[];
    /** Max number of dimension levels (for header row depth) */
    pivotDepth: number;
};
/** Maximum number of pivot columns allowed */
export declare const PIVOT_COLUMN_LIMIT = 30;
/**
 * Creates a unique key for a pivot dimension combination.
 */
export declare function createPivotKey(parentField: RecordOrRepeatedRecordField, values: Cell[]): string;
/**
 * Separates fields into dimensions and non-dimensions (measures).
 *
 * @param field The nested field being pivoted
 * @param userDimensions Optional explicit dimension field names
 * @returns Object with dimensions and nonDimensions arrays
 */
export declare function calculatePivotDimensions(field: NestField, userDimensions?: string[]): {
    dimensions: SortableField[];
    nonDimensions: SortableField[];
};
/**
 * Collects all unique dimension value combinations across all rows of data.
 *
 * @param field The nested field being pivoted
 * @param data The parent table data
 * @param dimensions The dimension fields to extract values from
 * @returns Map of pivot keys to PivotedField objects
 */
export declare function collectPivotedFields(field: NestField, data: RecordOrRepeatedRecordCell, dimensions: SortableField[], nonDimensionCount: number): Map<string, PivotedField>;
/**
 * Sorts pivoted fields by their dimension values.
 * Uses Cell.compareTo() for type-appropriate sorting.
 *
 * @param pivotedFields Array of PivotedField objects
 * @param dimensions Dimension fields with sort direction
 * @returns Sorted array
 */
export declare function sortPivotedFields(pivotedFields: PivotedField[], dimensions: SortableField[]): PivotedField[];
/**
 * Expands sorted pivot fields into individual column fields.
 * Each pivot combination * each non-dimension = one column.
 *
 * @param pivotedFields Sorted array of PivotedField objects
 * @param nonDimensions Non-dimension (measure) fields
 * @param userDimensions Optional user-specified dimension names
 * @returns Array of PivotedColumnField objects
 */
export declare function expandPivotColumns(pivotedFields: PivotedField[], nonDimensions: SortableField[], userDimensions?: string[]): PivotedColumnField[];
/**
 * Builds a complete pivot configuration for a nested field.
 *
 * @param field The nested field with # pivot tag
 * @param data The parent table data
 * @param userDimensions Optional explicit dimension field names
 * @returns PivotConfig or null if pivot cannot be created
 */
export declare function buildPivotConfig(field: NestField, data: RecordOrRepeatedRecordCell, userDimensions?: string[]): PivotConfig;
/**
 * Generates a map of pivot keys to cell values for a single row's nested data.
 * Used during rendering to look up the correct cell for each pivot column.
 *
 * @param nestedCell The nested record data for one row
 * @param pivotConfig The pivot configuration
 * @returns Map from pivot key to map of field name to cell
 */
export declare function generatePivotedCellsMap(nestedCell: RecordOrRepeatedRecordCell, pivotConfig: PivotConfig): Map<string, Map<string, Cell>>;
/**
 * Gets the pivot dimension values to display in a cell.
 * Used for rendering dimension value header cells.
 */
export declare function getPivotDimensionValue(pivotedField: PivotedField, dimensionIndex: number): Cell | undefined;
/**
 * Checks if a field should be rendered as a pivot table.
 * Syntax: # pivot
 */
export declare function shouldPivot(field: Field): boolean;
/**
 * Gets user-defined pivot dimensions from the pre-resolved tag config.
 * Syntax: # pivot { dimensions=[d1, d2] }
 */
export declare function getUserDefinedDimensions(field: Field): string[] | undefined;
