"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isValidOrderForColumnGroups = exports.PIVOT_AGGREGATION_TOTAL_COLUMN_TYPE = exports.PIVOT_COLUMN_TOTAL_COLUMN_TYPE = exports.PIVOT_GRAND_TOTAL_COLUMN_TYPE = exports.PIVOT_ANY_TOTAL_COLUMN_TYPE = exports.FDC3_COLUMN_TYPE = exports.ACTION_COLUMN_TYPE = exports.FREE_TEXT_COLUMN_TYPE = exports.CALCULATED_COLUMN_TYPE = exports.hiddenColDefConfig = exports.HIDDEN_COLUMN_TYPE = void 0;
exports.getColumnTypeFriendlyName = getColumnTypeFriendlyName;
const src_1 = require("../../layout-manager/src");
exports.HIDDEN_COLUMN_TYPE = 'hiddenColumn';
exports.hiddenColDefConfig = {
    initialHide: true,
    hide: true,
    lockVisible: true,
    suppressColumnsToolPanel: true,
};
exports.CALCULATED_COLUMN_TYPE = 'calculatedColumn';
exports.FREE_TEXT_COLUMN_TYPE = 'freeTextColumn';
exports.ACTION_COLUMN_TYPE = 'actionColumn';
exports.FDC3_COLUMN_TYPE = 'fdc3Column';
exports.PIVOT_ANY_TOTAL_COLUMN_TYPE = src_1.PIVOT_ANY_TOTAL_COL_TYPE;
exports.PIVOT_GRAND_TOTAL_COLUMN_TYPE = src_1.PIVOT_GRAND_TOTAL_COL_TYPE;
exports.PIVOT_COLUMN_TOTAL_COLUMN_TYPE = src_1.PIVOT_COLUMN_TOTAL_COL_TYPE;
exports.PIVOT_AGGREGATION_TOTAL_COLUMN_TYPE = src_1.PIVOT_AGGREGATION_TOTAL_COL_TYPE;
function getColumnTypeFriendlyName(columnType) {
    switch (columnType) {
        case exports.CALCULATED_COLUMN_TYPE:
            return 'Calculated Column';
        case exports.FREE_TEXT_COLUMN_TYPE:
            return 'Free Text Column';
        case exports.ACTION_COLUMN_TYPE:
            return 'Action Column';
        case exports.FDC3_COLUMN_TYPE:
            return 'FDC3 Column';
        case exports.PIVOT_ANY_TOTAL_COLUMN_TYPE:
            return 'Pivot Total (any total type)';
        case exports.PIVOT_GRAND_TOTAL_COLUMN_TYPE:
            return 'Pivot Grand Total';
        case exports.PIVOT_COLUMN_TOTAL_COLUMN_TYPE:
            return 'Pivot Column Total';
        case exports.PIVOT_AGGREGATION_TOTAL_COLUMN_TYPE:
            return 'Pivot Aggregation Total';
        default:
            return columnType;
    }
}
// this is only implemented for 1 level groups
const isValidOrderForColumnGroups = ({ oldColumns, newColumns, }) => {
    const getGroups = (columns) => {
        let prevGroup = '';
        let count = 0;
        columns.forEach((column) => {
            if (column &&
                column.columnGroup &&
                column.columnGroup.groupCount > 1 &&
                !column.columnGroup.allowGroupSplit) {
                if (prevGroup !== column.columnGroup.columnGroupId) {
                    count++;
                }
            }
            prevGroup = column?.columnGroup?.columnGroupId ?? '';
        });
        return count;
    };
    if (getGroups(oldColumns) != getGroups(newColumns)) {
        return false;
    }
    return true;
};
exports.isValidOrderForColumnGroups = isValidOrderForColumnGroups;
