import * as React from 'react';
import SimpleButton from '../../components/SimpleButton';
import { useAdaptable } from '../AdaptableContext';
import { AdaptableObjectListItem } from '../Components/AdaptableObjectList/AdaptableObjectList';
import { Box, Flex } from '../../components/Flex';
export const Dependencies = (props) => {
    const adaptable = 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(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(AdaptableObjectListItem, { deleteTooltip: 'Cannot delete dependencies.', deleteDisabled: true, module: module, data: itemView })));
    })));
};
export const SharedEntityDependencies = (props) => {
    const [isExpanded, setIsExpanded] = React.useState(false);
    return (React.createElement(React.Fragment, null,
        React.createElement(Flex, null,
            React.createElement(Box, { className: 'ab-Adaptable-Object-List__Item__label twa:mr-3' }, "Dependencies"),
            React.createElement(Box, { className: "twa:my-2" }, isExpanded ? (React.createElement(SimpleButton, { onClick: () => setIsExpanded(false), icon: "arrow-up" }, "Collapse")) : (React.createElement(SimpleButton, { onClick: () => setIsExpanded(true), icon: "arrow-down" }, "Expand")))),
        isExpanded && React.createElement(Dependencies, { sharedEntity: props.data })));
};
