import { useActionCellColumnBase, useRenderActionCellColumn, } from '../ActionCell';
import { useMemo } from 'react';
import { isFolderKeyedItem, isItemKeyedItem } from '../../state';
export function useOrFolderActionCellColumn(params) {
    const { state: { items, folders }, actionCell, folderActionCell, actionCellProps, actionCellWidth, } = params;
    const baseColumn = useActionCellColumnBase({
        actionCellProps,
        actionCellWidth,
    });
    const renderItem = useRenderActionCellColumn({
        actionCell,
        sticky: true,
        collection: items,
    });
    const renderFolder = useRenderActionCellColumn({
        actionCell: folderActionCell,
        sticky: true,
        collection: folders,
    });
    return useMemo(() => {
        if (renderItem == null && renderFolder == null) {
            return null;
        }
        return {
            ...baseColumn,
            render: (keyedItem, rowNum) => {
                if (isItemKeyedItem(keyedItem)) {
                    return renderItem?.(keyedItem.item.originalKeyedItem, rowNum);
                }
                if (isFolderKeyedItem(keyedItem)) {
                    return renderFolder?.(keyedItem.item.originalKeyedItem, rowNum);
                }
                return null;
            },
        };
    }, [baseColumn, renderItem, renderFolder]);
}
//# sourceMappingURL=useOrFolderActionCellColumn.js.map