"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AdaptableObjectsSummary = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const rebass_1 = require("rebass");
const AdaptableContext_1 = require("../../AdaptableContext");
const AdaptableObjectList_1 = require("../../Components/AdaptableObjectList");
const useRerender_1 = require("../../../components/utils/useRerender");
const react_1 = require("react");
const AdaptableObjectsSummary = () => {
    const adaptable = (0, AdaptableContext_1.useAdaptable)();
    const rerender = (0, useRerender_1.useRerender)();
    (0, react_1.useEffect)(() => {
        return adaptable.api.eventApi.on('AdaptableStateChanged', rerender);
    }, [adaptable]);
    const modules = adaptable.ModuleService.getModuleCollection();
    const baseClassName = 'ab-AdaptableObjectsSummary';
    return (React.createElement(rebass_1.Box, { className: baseClassName }, [...modules].map(([moduleName, module]) => {
        if (!module.isModuleVisible()) {
            return null;
        }
        const items = module?.toViewAll?.();
        if (!items?.length) {
            return null;
        }
        return (React.createElement(rebass_1.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_1.AdaptableObjectList, { items: items, module: module })));
    })));
};
exports.AdaptableObjectsSummary = AdaptableObjectsSummary;
