"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExtendedFeaturesBlock = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const components_1 = require("../../components/index.js");
const Image_1 = tslib_1.__importDefault(require("../../components/Image/Image.js"));
const utils_1 = require("../../components/Media/Image/utils.js");
const theme_1 = require("../../gravity-blocks/context/theme/index.js");
const grid_1 = require("../../gravity-blocks/grid/index.js");
const sub_blocks_1 = require("../../sub-blocks/index.js");
const utils_2 = require("../../utils/index.js");
const b = (0, utils_2.block)('ExtendedFeaturesBlock');
const DEFAULT_SIZES = {
    all: 12,
    sm: 6,
    md: 4,
};
const ExtendedFeaturesBlock = ({ title, description, items, colSizes = DEFAULT_SIZES, animated, }) => {
    const theme = (0, theme_1.useTheme)();
    const itemTitleHeadingTag = title ? 'h3' : 'h2';
    return ((0, jsx_runtime_1.jsx)(components_1.AnimateBlock, { className: b(), animate: animated, children: (0, jsx_runtime_1.jsxs)(grid_1.Grid, { children: [(0, jsx_runtime_1.jsx)(components_1.Title, { title: title, subtitle: description, className: b('header') }), (0, jsx_runtime_1.jsx)("div", { className: b('items'), children: (0, jsx_runtime_1.jsx)(grid_1.Row, { children: items &&
                            items.map(({ title: itemTitle, text, list, link, links, label, icon, buttons, additionalInfo, }) => {
                                const itemLinks = links || [];
                                const iconThemed = icon && (0, utils_2.getThemedValue)(icon, theme);
                                const iconData = iconThemed && (0, utils_1.getMediaImage)(iconThemed);
                                if (link) {
                                    itemLinks.push(link);
                                }
                                return ((0, jsx_runtime_1.jsxs)(grid_1.Col, { className: b('item'), sizes: colSizes, children: [iconData && ((0, jsx_runtime_1.jsx)("div", { className: b('icon-wrap'), "aria-hidden": true, children: (0, jsx_runtime_1.jsx)(Image_1.default, { ...iconData, className: b('icon') }) })), (0, jsx_runtime_1.jsxs)("div", { className: b('container'), children: [itemTitle && ((0, jsx_runtime_1.jsx)(components_1.YFMWrapper, { tagName: itemTitleHeadingTag, content: itemTitle, className: b('item-title-container'), contentClassName: b('item-title'), modifiers: {
                                                        constructor: true,
                                                    }, children: label && ((0, jsx_runtime_1.jsx)("span", { className: b('item-label'), children: label })) })), (0, jsx_runtime_1.jsx)(sub_blocks_1.Content, { text: text, links: itemLinks, size: "s", list: list, colSizes: { all: 12, md: 12 }, buttons: buttons, additionalInfo: additionalInfo })] })] }, text || itemTitle));
                            }) }) })] }) }));
};
exports.ExtendedFeaturesBlock = ExtendedFeaturesBlock;
exports.default = exports.ExtendedFeaturesBlock;
//# sourceMappingURL=ExtendedFeatures.js.map
