import { jsx as _jsx } from "react/jsx-runtime";
import { useAtom } from 'jotai';
import { MaximizeIcon } from '@redocly/theme/icons/MaximizeIcon/MaximizeIcon';
import { Button } from '@redocly/theme/components/Button/Button';
import { operationStore } from '../../jotai/operation.js';
import { useTelemetry, useTranslate } from '../../hooks/index.js';
import { styled } from '../../styled-components.js';
export const ExpandAllButton = ({ operationPointer, type, onPanelToggle, }) => {
    const translate = useTranslate();
    const [operationState, setOperationState] = useAtom(operationStore(operationPointer));
    const telemetry = useTelemetry();
    const handleToggle = () => {
        const expandedAll = !operationState[type].expandedAll;
        telemetry.send({
            type: 'openapi_docs.expand_collapse_all.clicked',
            payload: { isExpanded: expandedAll },
        });
        setOperationState({
            [type]: {
                expandedAll,
            },
        });
        onPanelToggle?.(expandedAll, type === 'request' ? 'request' : 'responses');
    };
    return (_jsx(StyledButton, { icon: _jsx(MaximizeIcon, {}), iconPosition: "right", size: "small", variant: "ghost", onClick: handleToggle, children: operationState[type].expandedAll
            ? translate('openapi.collapseAll', 'Collapse all')
            : translate('openapi.expandAll', 'Expand all') }));
};
const StyledButton = styled(Button) `
  margin-left: auto;
`;
//# sourceMappingURL=ExpandAllButton.js.map