"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ContentLayoutBlock = void 0;
const tslib_1 = require("tslib");
const react_1 = require("react");
const jsx_runtime_1 = require("react/jsx-runtime");
const React = tslib_1.__importStar(require("react"));
const components_1 = require("../../components/index.js");
const constants_1 = require("../../constants.js");
const theme_1 = require("../../gravity-blocks/context/theme/index.js");
const windowWidthContext_1 = require("../../gravity-blocks/context/windowWidthContext/index.js");
const grid_1 = require("../../gravity-blocks/grid/index.js");
const sub_blocks_1 = require("../../sub-blocks/index.js");
const utils_1 = require("../../utils/index.js");
const b = (0, utils_1.block)('content-layout-block');
function getFileTextSize(size) {
    switch (size) {
        case 's':
            return 's';
        case 'm':
        case 'l':
        case 'xl':
        default:
            return 'l';
    }
}
function getTextWidth(size) {
    switch (size) {
        case 's':
            return { all: 12, md: 6 };
        case 'l':
            return { all: 12, md: 12 };
        case 'm':
        default:
            return { all: 12, md: 8 };
    }
}
const ContentLayoutBlock = (props) => {
    const windowWidth = (0, windowWidthContext_1.useWindowWidth)();
    const isMobile = windowWidth <= constants_1.BREAKPOINTS.sm;
    const { textContent, fileContent, size = 'l', background, centered, theme = 'default', textWidth = 'm', } = props;
    const colSizes = React.useMemo(() => getTextWidth(textWidth), [textWidth]);
    const globalTheme = (0, theme_1.useTheme)();
    const themedBackground = (0, utils_1.getThemedValue)(background, globalTheme);
    return ((0, jsx_runtime_1.jsx)(grid_1.Grid, { children: (0, jsx_runtime_1.jsxs)("div", { className: b({ size, theme, background: Boolean(background) }), children: [(0, jsx_runtime_1.jsx)(sub_blocks_1.Content, { className: b('content'), ...textContent, size: size, centered: centered, colSizes: colSizes, theme: theme }), fileContent && ((0, jsx_runtime_1.jsx)(grid_1.Col, { className: b('files', { size, centered }), reset: true, sizes: colSizes, children: fileContent.map((file) => ((0, react_1.createElement)(components_1.FileLink, { className: b('file'), ...file, key: file.href, type: "horizontal", textSize: getFileTextSize(size), theme: theme }))) })), background && ((0, jsx_runtime_1.jsx)("div", { className: b('background'), children: (0, jsx_runtime_1.jsx)(components_1.BackgroundImage, { className: b('background-item'), ...themedBackground, hide: isMobile }) }))] }) }));
};
exports.ContentLayoutBlock = ContentLayoutBlock;
exports.default = exports.ContentLayoutBlock;
//# sourceMappingURL=ContentLayout.js.map
