export var MTableSortDirection;
(function (MTableSortDirection) {
    MTableSortDirection[MTableSortDirection["None"] = 0] = "None";
    MTableSortDirection[MTableSortDirection["Asc"] = 1] = "Asc";
    MTableSortDirection[MTableSortDirection["Dsc"] = -1] = "Dsc";
})(MTableSortDirection || (MTableSortDirection = {}));
export var MTableTextAlign;
(function (MTableTextAlign) {
    MTableTextAlign["Center"] = "center";
    MTableTextAlign["Left"] = "left";
    MTableTextAlign["Right"] = "right";
})(MTableTextAlign || (MTableTextAlign = {}));
export var MTableColspan;
(function (MTableColspan) {
    MTableColspan["AllColumns"] = "all-columns";
})(MTableColspan || (MTableColspan = {}));
export var MTableAccordionIconPosition;
(function (MTableAccordionIconPosition) {
    MTableAccordionIconPosition["Left"] = "left";
    MTableAccordionIconPosition["Right"] = "right";
})(MTableAccordionIconPosition || (MTableAccordionIconPosition = {}));
export var MTableHeadStyle;
(function (MTableHeadStyle) {
    MTableHeadStyle["Dark"] = "dark";
    MTableHeadStyle["Light"] = "light";
    MTableHeadStyle["Lightest"] = "lightest";
    MTableHeadStyle["Any"] = "any";
})(MTableHeadStyle || (MTableHeadStyle = {}));
export var MTableRowsStyle;
(function (MTableRowsStyle) {
    MTableRowsStyle["AlternateBackground"] = "alternate-background";
    MTableRowsStyle["Borders"] = "borders";
    MTableRowsStyle["CellBorders"] = "cell-borders";
})(MTableRowsStyle || (MTableRowsStyle = {}));
export var MTableGroupHeaderStyle;
(function (MTableGroupHeaderStyle) {
    MTableGroupHeaderStyle["Dark"] = "dark";
    MTableGroupHeaderStyle["Light"] = "light";
    MTableGroupHeaderStyle["Any"] = "any";
})(MTableGroupHeaderStyle || (MTableGroupHeaderStyle = {}));
export var getCellAlignmentClass = function (textAlign) {
    return textAlign ? "m--is-text-align-" + textAlign : 'm--is-text-align-left';
};
export var getCellWidthStyle = function (column) {
    var width = column.width || undefined;
    return width ? "width: " + width : undefined;
};
export var getHeadRowsFilterAndSort = function (headRows) {
    var headRowsClone = Object.assign({}, headRows);
    var headRowKeys = Object.keys(headRowsClone).sort(function (a, b) {
        return headRowsClone
            && headRowsClone[a]
            && headRowsClone[b]
            && headRowsClone[a].order
            && headRowsClone[b].order
            ? headRowsClone[a].order - headRowsClone[b].order
            : 0;
    });
    headRows = {};
    headRowKeys.forEach(function (key) {
        headRows[key] = headRowsClone[key];
        if (headRows[key].columns) {
            headRows[key].columns = getColumnFilterAndSorted(headRows[key].columns);
        }
    });
    return headRows;
};
export var getTotalColumnsLength = function (columns) {
    return columns.reduce(function (acc, curr) { return curr.colspan
        && curr.colspan > 0
        && curr.colspan !== MTableColspan.AllColumns
        ? acc + curr.colspan
        : acc + 1; }, 0);
};
var getColumnFilterAndSorted = function (columns) {
    return columns
        .filter(function (c) { return c.visible === undefined || c.visible; })
        .sort(function (a, b) {
        if (a.order && b.order) {
            return a.order - b.order;
        }
        return 0;
    });
};
//# sourceMappingURL=responsive-table-commons.js.map