import { ChartType, getHiddenTableFields, } from '../types/savedCharts';
const getTablePivotConfig = (tableChartConfig, pivotConfig, tableConfig) => pivotConfig && pivotConfig.columns.length > 0
    ? {
        pivotDimensions: pivotConfig.columns,
        metricsAsRows: tableChartConfig.config?.metricsAsRows ?? false,
        hiddenMetricFieldIds: getHiddenTableFields(tableChartConfig),
        columnOrder: tableConfig.columnOrder,
        rowTotals: tableChartConfig.config?.showRowCalculation ?? false,
        columnTotals: tableChartConfig.config?.showColumnCalculation ?? false,
    }
    : undefined;
const getCartesianPivotConfig = (pivotConfig) => pivotConfig && pivotConfig.columns.length > 0
    ? {
        pivotDimensions: pivotConfig.columns,
        metricsAsRows: false,
    }
    : undefined;
export const getPivotConfig = (savedChart) => {
    switch (savedChart.chartConfig.type) {
        case ChartType.TABLE:
            return getTablePivotConfig(savedChart.chartConfig, savedChart.pivotConfig, savedChart.tableConfig);
        case ChartType.CARTESIAN:
            return getCartesianPivotConfig(savedChart.pivotConfig);
        default:
            return undefined;
    }
};
//# sourceMappingURL=pivotConfig.js.map