"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getEditorBlocksData = getEditorBlocksData;
const tslib_1 = require("tslib");
const models_1 = require("../../models/index.js");
const utils_1 = require("../utils/index.js");
const default_preview_1 = tslib_1.__importDefault(require("./previews/default-preview.js"));
const header_block_1 = tslib_1.__importDefault(require("./previews/header-block.js"));
const getBlockTemplate = (blockType) => import(`./templates/${blockType}.json`).then((data) => data.default);
const getBlockPreview = (blockType) => {
    try {
        if (blockType === models_1.BlockType.HeaderBlock) {
            return header_block_1.default;
        }
        return default_preview_1.default;
    }
    catch (err) {
        /*eslint-disable no-console */
        console.warn(`Preview image for ${blockType} not found`);
        return default_preview_1.default;
    }
};
async function getEditorBlocksData() {
    const EdiorBlockData = {};
    for (const blockType of Object.values(models_1.BlockType)) {
        const template = await getBlockTemplate(blockType);
        const preview = getBlockPreview(blockType);
        template.meta = template.meta || {};
        template.meta.title = template.meta.title || (0, utils_1.formatBlockName)(blockType);
        EdiorBlockData[blockType] = {
            ...template,
            preview,
        };
    }
    return EdiorBlockData;
}
//# sourceMappingURL=index.js.map
