"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "rootComparator", {
    enumerable: true,
    get: function() {
        return rootComparator;
    }
});
const _sortService = require("./sortService");
function rootComparator(sortingOrders, columnMetas) {
    return function(rowIndexWithValues, nextRowIndexWithValues) {
        // We sort array of arrays. Single array is in form [rowIndex, ...values].
        // We compare just values, stored at second index of array.
        const [, ...values] = rowIndexWithValues;
        const [, ...nextValues] = nextRowIndexWithValues;
        return function getCompareResult(column) {
            const sortingOrder = sortingOrders[column];
            const columnMeta = columnMetas[column];
            const value = values[column];
            const nextValue = nextValues[column];
            const pluginSettings = columnMeta.columnSorting;
            const compareFunctionFactory = pluginSettings.compareFunctionFactory ? pluginSettings.compareFunctionFactory : (0, _sortService.getCompareFunctionFactory)(columnMeta.type);
            const compareResult = compareFunctionFactory(sortingOrder, columnMeta, pluginSettings)(value, nextValue);
            // DIFF - MultiColumnSorting & ColumnSorting: removed iteration through next sorted columns.
            return compareResult;
        }(0);
    };
}
