'use client';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ThinkingMessage = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const icons_1 = require("@gravity-ui/icons");
const uikit_1 = require("@gravity-ui/uikit");
const cn_1 = require("../../../utils/cn.js");
const ActionButton_1 = require("../../atoms/ActionButton/index.js");
const Loader_1 = require("../../atoms/Loader/index.js");
const MarkdownRenderer_1 = require("../../atoms/MarkdownRenderer/index.js");
const useThinkingMessage_1 = require("./useThinkingMessage.js");
require("./ThinkingMessage.css");
const b = (0, cn_1.block)('thinking-message');
const defaultTransformOptions = {
    disableCommonAnchors: true,
};
/**
 * ThinkingMessage component displays AI model's internal reasoning process.
 * Shows a collapsible block with thinking content and a copy button.
 * Displays a loader when the thinking process is still in progress.
 *
 * @param props - Component props
 * @returns Rendered thinking message component
 */
const ThinkingMessage = (props) => {
    const { className, qa, style, format = 'plain', transformOptions } = props, data = tslib_1.__rest(props, ["className", "qa", "style", "format", "transformOptions"]);
    const markdownTransformOptions = Object.assign(Object.assign({}, defaultTransformOptions), transformOptions);
    const { isExpanded, toggleExpanded, buttonTitle, content, showLoader, handleCopy, showCopyButton, } = (0, useThinkingMessage_1.useThinkingMessage)(data);
    return ((0, jsx_runtime_1.jsxs)("div", { className: b(null, className), "data-qa": qa, style: style, children: [(0, jsx_runtime_1.jsxs)("div", { className: b('buttons'), children: [(0, jsx_runtime_1.jsxs)(uikit_1.Button, { size: "s", onClick: toggleExpanded, children: [buttonTitle, (0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: isExpanded ? icons_1.ChevronUp : icons_1.ChevronDown })] }), showLoader ? ((0, jsx_runtime_1.jsx)(Loader_1.Loader, { view: "loading", size: "xs" })) : (showCopyButton && ((0, jsx_runtime_1.jsx)(ActionButton_1.ActionButton, { size: "s", onClick: handleCopy, children: (0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: icons_1.Copy, size: 16 }) })))] }), isExpanded && ((0, jsx_runtime_1.jsx)("div", { className: b('container'), children: content.map((item, index) => format === 'markdown' ? ((0, jsx_runtime_1.jsx)(MarkdownRenderer_1.MarkdownRenderer, { className: b('content'), content: item, transformOptions: markdownTransformOptions }, index)) : ((0, jsx_runtime_1.jsx)(uikit_1.Text, { className: b('content'), children: item }, index))) }))] }));
};
exports.ThinkingMessage = ThinkingMessage;
//# sourceMappingURL=index.js.map
