"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const React = tslib_1.__importStar(require("react"));
const __1 = require("../index.js");
const FormsContext_1 = require("../../gravity-blocks/context/formsContext/FormsContext.js");
const theme_1 = require("../../gravity-blocks/context/theme/index.js");
const models_1 = require("../../models/index.js");
const sub_blocks_1 = require("../../sub-blocks/index.js");
const utils_1 = require("../../utils/index.js");
const InnerForm = (props) => {
    const { formData, onContentLoad, className } = props;
    const formsConfig = React.useContext(FormsContext_1.FormsContext);
    const theme = (0, theme_1.useTheme)();
    React.useEffect(() => {
        if ((0, models_1.isHubspotDataForm)(formData)) {
            onContentLoad();
        }
    }, [onContentLoad, formData]);
    if ((0, models_1.isYandexDataForm)(formData)) {
        const { onLoad, ...rest } = (0, utils_1.getThemedValue)(formData.yandex, theme);
        return ((0, jsx_runtime_1.jsx)("div", { className: className, children: (0, jsx_runtime_1.jsx)(__1.YandexForm, { ...formsConfig.yandex, ...rest, onLoad: () => {
                    onContentLoad();
                    onLoad?.();
                } }) }));
    }
    if ((0, models_1.isHubspotDataForm)(formData)) {
        const themedFormData = (0, utils_1.getThemedValue)(formData.hubspot, theme);
        return ((0, jsx_runtime_1.jsx)(sub_blocks_1.HubspotForm, { createDOMElement: true, ...formsConfig.hubspot, ...themedFormData }));
    }
    return null;
};
exports.default = InnerForm;
//# sourceMappingURL=InnerForm.js.map
