import { jsx as _jsx } from "react/jsx-runtime";
import { ScrollableItem } from "@gooddata/sdk-ui-kit";
import { DrillConfigItem } from "./InsightDrillConfigItem.js";
import { useDrillTargetTypeItems } from "./useDrillTargetTypeItems.js";
export function InsightDrillConfigList({ drillConfigItems = [], disableDrillDown, onDelete, onSetup, onIncompleteChange, }) {
    const enabledDrillTargetTypeItems = useDrillTargetTypeItems(disableDrillDown);
    const shouldScrollToContainer = (item, isLast) => {
        return !item.complete && isLast;
    };
    const isLast = (index) => {
        return index === drillConfigItems.length - 1;
    };
    return (_jsx("div", { className: "s-drill-config-list", children: drillConfigItems.map((item, index) => {
            const shouldScroll = shouldScrollToContainer(item, isLast(index));
            return (_jsx(ScrollableItem, { scrollIntoView: shouldScroll, children: _jsx(DrillConfigItem, { item: item, onDelete: onDelete, onSetup: onSetup, onIncompleteChange: onIncompleteChange, enabledDrillTargetTypeItems: enabledDrillTargetTypeItems }, item.localIdentifier + item.drillTargetType) }, item.localIdentifier + item.drillTargetType));
        }) }));
}
