import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// ============================================================================
// Deep Thinking
// ============================================================================
import { Card, CardBody, ExpandableSection } from '@patternfly/react-core';
import { useState } from 'react';
import MarkdownContent from '../MarkdownContent';
export const DeepThinking = ({ body, cardProps, expandableSectionProps, subheading, toggleContent, isDefaultExpanded = true, cardBodyProps, isToggleContentMarkdown, isSubheadingMarkdown, isBodyMarkdown, markdownContentProps, shouldRetainStyles = false }) => {
    const [isExpanded, setIsExpanded] = useState(isDefaultExpanded);
    const onToggle = (_event, isExpanded) => {
        setIsExpanded(isExpanded);
    };
    const renderToggleContent = () => {
        if (isToggleContentMarkdown && typeof toggleContent === 'string') {
            return (_jsx(MarkdownContent, Object.assign({ shouldRetainStyles: shouldRetainStyles, content: toggleContent }, markdownContentProps)));
        }
        return toggleContent;
    };
    const renderSubheading = () => {
        if (!subheading) {
            return null;
        }
        if (isSubheadingMarkdown) {
            return _jsx(MarkdownContent, Object.assign({ shouldRetainStyles: shouldRetainStyles, content: subheading }, markdownContentProps));
        }
        return subheading;
    };
    const renderBody = () => {
        if (!body) {
            return null;
        }
        if (isBodyMarkdown && typeof body === 'string') {
            return _jsx(MarkdownContent, Object.assign({ shouldRetainStyles: shouldRetainStyles, content: body }, markdownContentProps));
        }
        return body;
    };
    return (_jsx(Card, Object.assign({ isCompact: true, className: "pf-chatbot__deep-thinking" }, cardProps, { children: _jsx(CardBody, Object.assign({}, cardBodyProps, { children: _jsx(ExpandableSection, Object.assign({ toggleContent: renderToggleContent(), onToggle: onToggle, isExpanded: isExpanded, isIndented: true, className: "pf-chatbot__deep-thinking-expandable-section" }, expandableSectionProps, { children: _jsxs("div", { className: "pf-chatbot__deep-thinking-section", children: [subheading && (_jsx("div", { className: "pf-chatbot__deep-thinking-subheading", children: _jsx("span", { children: renderSubheading() }) })), body && _jsx("div", { className: "pf-chatbot__deep-thinking-body", children: renderBody() })] }) })) })) })));
};
export default DeepThinking;
