import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useAtomValue } from 'jotai';
import { LayoutVariant } from '@redocly/config';
import { AfterOpenApiTitle } from '@redocly/theme/components/OpenApiDocs/hooks/AfterOpenApiTitle';
import { PageActions } from '@redocly/theme/components/PageActions/PageActions';
import { SamplesMiddlePanel, Row } from '../common/index.js';
import { ExternalDocumentation } from '../ExternalDocumentation/index.js';
import { Markdown } from '../Markdown/index.js';
import { ApiHeader } from './styled.js';
import { globalStoreAtom } from '../../jotai/store.js';
import { saveTextBeforeHeading } from '../../utils/saveTextBeforeHeading.js';
import { getValueFromMdParsedExtension } from '../../utils/helpers.js';
import { RenderHook } from '../RenderHook/index.js';
import { Metadata } from './Metadata.js';
import { useTranslate } from '../../hooks/index.js';
export function ApiInfo({ item, layout, }) {
    const translate = useTranslate();
    const { options: { unstable_hooks, hideInfoMetadata, routingBasePath }, parser: { definition }, } = useAtomValue(globalStoreAtom);
    const info = item.infoDefinition;
    if (!info) {
        return null;
    }
    const description = saveTextBeforeHeading(getValueFromMdParsedExtension(info, 'description') || '');
    const summary = getValueFromMdParsedExtension(info, 'summary') || undefined;
    const externalDocs = definition?.externalDocs || info?.externalDocs;
    const isStacked = layout === LayoutVariant.STACKED;
    return (_jsx(Row, { layout: layout, children: _jsxs(SamplesMiddlePanel, { fullWidth: true, className: "api-info", isStacked: isStacked, children: [_jsxs(ApiHeader, { children: [(info.title || '') + (info.version ? ` (${info.version})` : ''), _jsx(PageActions, { pageSlug: routingBasePath })] }), _jsx(RenderHook, { Hook: AfterOpenApiTitle || unstable_hooks?.AfterApiTitle, props: { info } }), summary && _jsx(Markdown, { source: summary, "data-role": "redoc-summary" }), description && _jsx(Markdown, { source: description, "data-role": "redoc-description" }), externalDocs && _jsx(ExternalDocumentation, { externalDocs: externalDocs }), !hideInfoMetadata && _jsx(Metadata, { metadata: info['x-metadata'], translate: translate })] }) }));
}
//# sourceMappingURL=ApiInfo.js.map