"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SharedEntityDependencies = exports.Dependencies = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const SimpleButton_1 = tslib_1.__importDefault(require("../../components/SimpleButton"));
const AdaptableContext_1 = require("../AdaptableContext");
const AdaptableObjectList_1 = require("../Components/AdaptableObjectList/AdaptableObjectList");
const Flex_1 = require("../../components/Flex");
const Dependencies = (props) => {
    const adaptable = (0, AdaptableContext_1.useAdaptable)();
    const dependencies = adaptable.api.teamSharingApi.internalApi.getSharedEntryDependencies(props.sharedEntity);
    return (React.createElement(React.Fragment, null, dependencies.map((sharedEntity) => {
        const module = adaptable.ModuleService.getModuleById('TeamSharing');
        const itemView = module.toView(sharedEntity);
        return (React.createElement(Flex_1.Box, { as: "ul", key: sharedEntity.Uuid, className: "ab-Shared-Entity-Shared-Object twa:mb-2 twa:p-0 twa:flex twa:flex-col twa:gap-3" },
            React.createElement(AdaptableObjectList_1.AdaptableObjectListItem, { deleteTooltip: 'Cannot delete dependencies.', deleteDisabled: true, module: module, data: itemView })));
    })));
};
exports.Dependencies = Dependencies;
const SharedEntityDependencies = (props) => {
    const [isExpanded, setIsExpanded] = React.useState(false);
    return (React.createElement(React.Fragment, null,
        React.createElement(Flex_1.Flex, null,
            React.createElement(Flex_1.Box, { className: 'ab-Adaptable-Object-List__Item__label twa:mr-3' }, "Dependencies"),
            React.createElement(Flex_1.Box, { className: "twa:my-2" }, isExpanded ? (React.createElement(SimpleButton_1.default, { onClick: () => setIsExpanded(false), icon: "arrow-up" }, "Collapse")) : (React.createElement(SimpleButton_1.default, { onClick: () => setIsExpanded(true), icon: "arrow-down" }, "Expand")))),
        isExpanded && React.createElement(exports.Dependencies, { sharedEntity: props.data })));
};
exports.SharedEntityDependencies = SharedEntityDependencies;
