import * as React from 'react';
import { Box } from 'rebass';
import { useAdaptable } from '../../AdaptableContext';
import { AdaptableObjectList } from '../../Components/AdaptableObjectList';
import { useRerender } from '../../../components/utils/useRerender';
import { useEffect } from 'react';
export const AdaptableObjectsSummary = () => {
    const adaptable = useAdaptable();
    const rerender = useRerender();
    useEffect(() => {
        return adaptable.api.eventApi.on('AdaptableStateChanged', rerender);
    }, [adaptable]);
    const modules = adaptable.ModuleService.getModuleCollection();
    const baseClassName = 'ab-AdaptableObjectsSummary';
    return (React.createElement(Box, { className: baseClassName }, [...modules].map(([moduleName, module]) => {
        if (!module.isModuleAvailable()) {
            return null;
        }
        const items = module?.toViewAll?.();
        if (!items?.length) {
            return null;
        }
        return (React.createElement(Box, { "data-name": module.moduleInfo.ModuleName, className: `${baseClassName}__module-list`, key: module.moduleInfo.ModuleName },
            React.createElement("b", { className: `${baseClassName}__header` }, module.moduleInfo.FriendlyName),
            items?.length && React.createElement(AdaptableObjectList, { items: items, module: module })));
    })));
};
