'use client';
import { __rest } from "tslib";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { ChevronDown, ChevronUp, Copy } from '@gravity-ui/icons';
import { Button, Icon, Text } from '@gravity-ui/uikit';
import { block } from "../../../utils/cn.js";
import { ActionButton } from "../../atoms/ActionButton/index.js";
import { Loader } from "../../atoms/Loader/index.js";
import { MarkdownRenderer } from "../../atoms/MarkdownRenderer/index.js";
import { useThinkingMessage } from "./useThinkingMessage.js";
import "./ThinkingMessage.css";
const b = 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
 */
export const ThinkingMessage = (props) => {
    const { className, qa, style, format = 'plain', transformOptions } = props, data = __rest(props, ["className", "qa", "style", "format", "transformOptions"]);
    const markdownTransformOptions = Object.assign(Object.assign({}, defaultTransformOptions), transformOptions);
    const { isExpanded, toggleExpanded, buttonTitle, content, showLoader, handleCopy, showCopyButton, } = useThinkingMessage(data);
    return (_jsxs("div", { className: b(null, className), "data-qa": qa, style: style, children: [_jsxs("div", { className: b('buttons'), children: [_jsxs(Button, { size: "s", onClick: toggleExpanded, children: [buttonTitle, _jsx(Icon, { data: isExpanded ? ChevronUp : ChevronDown })] }), showLoader ? (_jsx(Loader, { view: "loading", size: "xs" })) : (showCopyButton && (_jsx(ActionButton, { size: "s", onClick: handleCopy, children: _jsx(Icon, { data: Copy, size: 16 }) })))] }), isExpanded && (_jsx("div", { className: b('container'), children: content.map((item, index) => format === 'markdown' ? (_jsx(MarkdownRenderer, { className: b('content'), content: item, transformOptions: markdownTransformOptions }, index)) : (_jsx(Text, { className: b('content'), children: item }, index))) }))] }));
};
//# sourceMappingURL=index.js.map
