import { jsx as _jsx } from "react/jsx-runtime";
import { useEffect, useState } from 'react';
import { Fragment } from 'react/jsx-runtime';
import { ffid } from '../../../../utils/ffID/ffid';
import Branches from '../Branches/Branches';
import './ConnectingBranches.scss';
const ConnectingBranches = ({ machineBranchInstances, machineColumnCount, machineColumnWidth, onAddBrowser, onDeleteBrowser, onAddRunBrowser, onUpdateDataSetList, onUpdateAddBrowserInstance, addInstanceLabel = '', scriptType = '', projectType = 'Web', readOnly = false, maxRunCount, }) => {
    const [machineInstance, setMachineInstance] = useState(machineBranchInstances);
    useEffect(() => {
        setMachineInstance(machineBranchInstances);
    }, [machineBranchInstances]);
    const getMachineBranchInstancesChunk = (machineBranchInstances, chunkSize) => {
        const machineBranchInstancesChunk = [];
        for (let i = 0; i < machineBranchInstances.length; i += chunkSize) {
            machineBranchInstancesChunk.push(machineBranchInstances.slice(i, i + chunkSize));
        }
        return machineBranchInstancesChunk;
    };
    const machineInstancesRow = getMachineBranchInstancesChunk(machineInstance, machineColumnCount);
    return (_jsx("div", { className: "ff-connecting-branch-grid-wrapper", children: machineInstancesRow.map((machineInstances, index) => (_jsx(Fragment, { children: _jsx(Branches, { machineInstances: machineInstances, rowIndex: index, machineColumnCount: machineColumnCount, machineColumnWidth: machineColumnWidth, onAddBrowser: onAddBrowser, onDeleteBrowser: onDeleteBrowser, onAddRunBrowser: onAddRunBrowser, nextRowMachineInstance: machineInstancesRow[index + 1]?.[0], previousRowMachineInstance: machineInstancesRow[index - 1]?.[machineColumnCount - 1], onUpdateDataSetList: onUpdateDataSetList, onUpdateAddBrowserInstance: onUpdateAddBrowserInstance, addInstanceLabel: addInstanceLabel, scriptType: scriptType, projectType: projectType, readOnly: readOnly, maxRunCount: maxRunCount }) }, ffid()))) }));
};
export default ConnectingBranches;
//# sourceMappingURL=ConnectingBranches.js.map