"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const jsx_runtime_1 = require("react/jsx-runtime");
const uikit_1 = require("@gravity-ui/uikit");
const components_1 = require("../../components/index.js");
const grid_1 = require("../../gravity-blocks/grid/index.js");
const utils_1 = require("../../utils/index.js");
const blocks_1 = require("../../utils/blocks.js");
const b = (0, utils_1.block)('content');
function getTextSize(size) {
    switch (size) {
        case 's':
            return 's';
        case 'm':
            return 'sm';
        case 'l':
            return 'm';
        case 'xl':
            return 'l';
        default:
            return 'm';
    }
}
const Content = (props) => {
    const { title, titleId: titleIdFromProps, text, textId, additionalInfo, size = 'l', links, buttons, colSizes = { all: 12, sm: 8 }, centered, theme, className, list, qa, controlPosition, } = props;
    const qaAttributes = (0, blocks_1.getQaAttrubutes)(qa, ['links', 'link', 'buttons', 'button', 'list']);
    const titleProps = !title || typeof title === 'string'
        ? { text: title, textSize: getTextSize(size) }
        : title;
    const hasTitle = Boolean(title);
    const defaultTitleId = (0, uikit_1.useUniqId)();
    const titleId = titleIdFromProps || defaultTitleId;
    return ((0, jsx_runtime_1.jsxs)(grid_1.Col, { className: b({ size, centered, theme, 'control-position': controlPosition }, className), reset: true, sizes: colSizes, qa: qaAttributes.container, children: [title && ((0, jsx_runtime_1.jsx)(components_1.Title, { className: b('title'), title: titleProps, colSizes: { all: 12 }, id: titleId })), text && ((0, jsx_runtime_1.jsx)("div", { className: b('text', { ['without-title']: !hasTitle }), children: (0, jsx_runtime_1.jsx)(components_1.YFMWrapper, { content: text, modifiers: { constructor: true, [`constructor-size-${size}`]: true }, id: textId, qa: qaAttributes.list }) })), list?.length ? ((0, jsx_runtime_1.jsx)("div", { className: b('list'), children: (0, jsx_runtime_1.jsx)(components_1.ContentList, { list: list, size: size, qa: qaAttributes.list, theme: theme }) })) : null, additionalInfo && ((0, jsx_runtime_1.jsx)("div", { className: b('notice'), children: (0, jsx_runtime_1.jsx)(components_1.YFMWrapper, { content: additionalInfo, modifiers: {
                        constructor: true,
                        'constructor-notice': true,
                        [`constructor-size-${size}`]: true,
                    } }) })), links && ((0, jsx_runtime_1.jsx)(components_1.Links, { className: b('links'), size: size, links: links, titleId: titleId, qa: qaAttributes.links, linkQa: qaAttributes.link })), buttons && ((0, jsx_runtime_1.jsx)(components_1.Buttons, { className: b('buttons'), size: size, buttons: buttons, titleId: titleId, qa: qaAttributes.buttons, buttonQa: qaAttributes.button }))] }));
};
exports.default = Content;
//# sourceMappingURL=Content.js.map
