import React from 'react';
import { Box } from '@wix/design-system';
function isFirstColumnMobileConfig(col) {
    return col.mobile?.column === 'first';
}
export function buildMobileColumns(columns) {
    const hasMobileConfig = columns.some((col) => col.mobile?.column);
    if (!hasMobileConfig) {
        return [
            {
                id: 'tableColumn',
                title: '',
                render: (params, index) => (React.createElement(Box, { direction: "vertical", gap: "SP1" },
                    columns[0] && React.createElement("div", null, columns[0].render?.(params, index)),
                    columns[1] && React.createElement("div", null, columns[1].render?.(params, index)))),
            },
        ];
    }
    const firstColumns = columns
        .filter(isFirstColumnMobileConfig)
        .sort((a, b) => {
        const orderA = a.mobile?.order ?? Infinity;
        const orderB = b.mobile?.order ?? Infinity;
        return orderA - orderB;
    });
    const secondColumn = columns.find((col) => col.mobile?.column === 'second');
    const result = [];
    if (firstColumns.length > 0) {
        result.push({
            id: 'mobile-first-column',
            title: '',
            render: (params, index) => (React.createElement(Box, { direction: "vertical", gap: "SP1" }, firstColumns.map((col, colIndex) => (React.createElement("div", { key: `first-col-${colIndex}` }, col.render?.(params, index)))))),
        });
    }
    if (secondColumn) {
        result.push({
            id: 'mobile-second-column',
            title: '',
            render: (params, index) => secondColumn.render?.(params, index),
        });
    }
    return result;
}
//# sourceMappingURL=buildMobileColumns.js.map