"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ToolHeader = ToolHeader;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = tslib_1.__importDefault(require("react"));
const uikit_1 = require("@gravity-ui/uikit");
const actionUtils_1 = require("../../../utils/actionUtils.js");
const cn_1 = require("../../../utils/cn.js");
const ActionButton_1 = require("../../atoms/ActionButton/index.js");
const ButtonGroup_1 = require("../ButtonGroup/index.js");
const ToolStatus_1 = require("../ToolStatus/index.js");
require("./ToolHeader.css");
const b = (0, cn_1.block)('tool-header');
function ToolHeader(props) {
    const { toolIcon, toolName, content, actions, status, className, qa } = props;
    const hasActions = actions && actions.length > 0;
    return ((0, jsx_runtime_1.jsxs)("div", { className: b('', className), "data-qa": qa, children: [(0, jsx_runtime_1.jsxs)("div", { className: b('left'), children: [toolIcon, (0, jsx_runtime_1.jsx)(uikit_1.Text, { children: toolName }), content] }), (0, jsx_runtime_1.jsxs)("div", { className: b('right'), children: [hasActions && ((0, jsx_runtime_1.jsx)(ButtonGroup_1.ButtonGroup, { children: actions.map((action, index) => {
                            // Check if action is a ReactNode (not an object with properties)
                            if (!(0, actionUtils_1.isActionConfig)(action)) {
                                return (0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: action }, index);
                            }
                            // TypeScript now knows that action is ActionConfig
                            return ((0, jsx_runtime_1.jsx)(ActionButton_1.ActionButton, { tooltipTitle: action.label, view: action.view || 'flat-secondary', size: "s", onClick: action.onClick, children: action.icon }, index));
                        }) })), (0, jsx_runtime_1.jsx)(ToolStatus_1.ToolStatus, { status: status })] })] }));
}
//# sourceMappingURL=index.js.map
