"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReactWidgetDescriptor = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const uikit_1 = require("@gravity-ui/uikit");
const ErrorBoundary_1 = require("../../../react-utils/ErrorBoundary.js");
const ReactRenderer_1 = require("../ReactRenderer/index.js");
const WidgetDescriptor_1 = require("./WidgetDescriptor.js");
class ReactWidgetDescriptor extends WidgetDescriptor_1.WidgetDescriptor {
    renderItem;
    remove() {
        this.renderItem?.remove();
        this.renderItem = undefined;
    }
    renderWidget() {
        this.renderItem = this.renderItem ?? this.createRenderItem();
        this.renderItem.rerender();
        return this.getDomElem();
    }
    createRenderItem() {
        return (0, ReactRenderer_1.getReactRendererFromState)(this.view.state).createItem('widget', () => ((0, jsx_runtime_1.jsx)(uikit_1.Portal, { container: this.getDomElem(), children: (0, jsx_runtime_1.jsx)(ErrorBoundary_1.ErrorLoggerBoundary, { children: this.renderReactElement(this.view, this.getPos) }) })));
    }
}
exports.ReactWidgetDescriptor = ReactWidgetDescriptor;
//# sourceMappingURL=ReactWidgetDescriptor.js.map
