import { ColumnSizingMap } from '../../AdaptableState/LayoutState';
import { XOR } from '../../Utilities/Extensions/TypeExtensions';
/**
 * Defines how a Column is sorted
 */
export interface ColumnSortModel {
    /**
     * Id of Column being sorted
     */
    ColumnId: string;
    /**
     * How Column is sorted - either 'Asc' or 'Desc'
     */
    SortOrder: 'Asc' | 'Desc';
}
export interface BaseLayoutModel {
    /**
     * @defaultValue 'single'
     */
    RowGroupDisplayType?: 'single' | 'multi';
    /**
     * Those are not actually used by the LayoutManager,
     * but we need to keep them here so we can give the layout
     * fully specified back to Adaptable, with this prop
     * set as it was when we received it from Adaptable
     */
    Ignore_ColumnFilters?: any[];
    /**
     * Same as ColumnFilters, but for Grid Filter
     */
    Ignore_GridFilter?: any;
    /**
     * Same as AutoSizeColumns, but for Pivot Layout
     */
    Ignore_AutoSizeColumns?: any;
    /**
     * Same as above, but for IsReadOnly
     */
    Ignore_IsReadOnly?: boolean;
    /**
     * Same as above, but for Tags
     */
    Ignore_Tags?: any[];
    /**
     * Same as RowSummaries, but for Pivot Layout
     */
    Ignore_RowSummaries?: any;
    /**
     * Same as above, but for Column Headers
     */
    Ignore_ColumnHeaders?: any;
    Ignore_Source?: string;
    Ignore_AdaptableVersion?: string;
    Ignore_Uuid?: string;
    Ignore_Metadata?: any;
    /**
     * The Layout Name
     */
    Name?: string;
    ColumnVisibility?: {
        [columnId: string]: false;
    };
    ColumnSizing?: ColumnSizingMap;
    /**
     * Behaviour for Expanding / Collapsing Row Groups
     */
    RowGroupValues?: {
        RowGroupDisplay: 'always-expanded';
    } | ({
        RowGroupDisplay: 'expanded';
    } & XOR<{
        Values: any[][];
    }, {
        GroupKeys: {
            RowGroupedColumns: string[];
            Values?: any[][];
        }[];
    }>) | {
        RowGroupDisplay: 'always-collapsed';
    } | ({
        RowGroupDisplay: 'collapsed';
    } & XOR<{
        Values: any[][];
    }, {
        GroupKeys: {
            RowGroupedColumns: string[];
            Values?: any[][];
        }[];
    }>);
    /**
     * Behaviour for Expanding / Collapsing Column Groups
     */
    ColumnGroupValues?: {
        ColumnGroupDisplay: 'always-expanded';
    } | {
        ColumnGroupDisplay: 'expanded';
        Values: any[];
    } | {
        ColumnGroupDisplay: 'always-collapsed';
    } | {
        ColumnGroupDisplay: 'collapsed';
        Values: any[];
    };
    /**
     * Hides aggFunc name in the column header: e.g. 'sum(Bank Balance)' will just be 'Bank Balance'
     */
    SuppressAggFuncInHeader?: boolean;
    /**
     * Sorting to apply in the Layout
     */
    ColumnSorts?: ColumnSortModel[];
    ColumnPinning?: {
        [columnId: string]: 'left' | 'right';
    };
    /**
     * Display Grand Total Row of the Pivot Table
     */
    GrandTotalRow?: 'top' | 'bottom' | 'pinnedTop' | 'pinnedBottom' | boolean;
}
export type ColumnAggregationModel = {
    aggFunc: string | true;
    weightedColumnId?: string;
};
export type AggregationColumnsModelItem = {
    ColumnId: string;
    AggFunc: ColumnAggregationModel;
};
export type AggregationColumnsModel = AggregationColumnsModelItem[];
export type PivotAggregationColumnsModel = (AggregationColumnsModelItem & {
    Total?: boolean | 'before' | 'after' | {
        PivotColumnId: string;
        ShowTotal?: boolean | 'before' | 'after';
    }[];
})[];
export interface TableLayoutModel extends BaseLayoutModel {
    TableColumns: string[];
    /**
     * Columns showing aggregated values in Group Rows; 1st value in record is Column name, 2nd is either aggfunc (e.g. sum, avg etc.) or 'true' (to use default aggfunc)
     */
    TableAggregationColumns?: AggregationColumnsModel;
    /**
     * Columns which are row-grouped when the Layout is applied
     */
    RowGroupedColumns?: string[];
    PivotAggregationColumns?: never;
    PivotColumns?: never;
    PivotGroupedColumns?: never;
    PivotExpandLevel?: never;
}
export interface PivotLayoutModel extends BaseLayoutModel {
    TableColumns?: never;
    /**
     * List of Columns which should be pivoted when grid is in pivot mode
     */
    PivotColumns: string[];
    PivotExpandLevel?: number;
    /**
     * Columns showing aggregated values in Group Rows; 1st value in record is Column name, 2nd is either aggfunc (e.g. sum, avg etc.) or 'true' (to use default aggfunc)
     */
    PivotAggregationColumns?: PivotAggregationColumnsModel;
    TableAggregationColumns?: never;
    /**
     * Columns which are row-grouped when the Layout is applied
     */
    PivotGroupedColumns?: string[];
    RowGroupedColumns?: never;
    /**
     * Display Total of all Pivot Columns before or after the Pivot Columns
     */
    PivotGrandTotal?: 'before' | 'after' | boolean;
    /**
     * Display automatically calculated Totals within EACH Pivot Column Group, in the position specified
     */
    PivotColumnTotal?: 'before' | 'after' | boolean;
    PivotResultColumnsOrder?: string[] | boolean;
}
export type LayoutModel = TableLayoutModel | PivotLayoutModel;
