import { jsx as _jsx } from "react/jsx-runtime";
import { Portal } from '@gravity-ui/uikit';
import { ErrorLoggerBoundary } from "../../../react-utils/ErrorBoundary.js";
import { getReactRendererFromState } from "../ReactRenderer/index.js";
import { WidgetDescriptor } from "./WidgetDescriptor.js";
export class ReactWidgetDescriptor extends WidgetDescriptor {
    renderItem;
    remove() {
        this.renderItem?.remove();
        this.renderItem = undefined;
    }
    renderWidget() {
        this.renderItem = this.renderItem ?? this.createRenderItem();
        this.renderItem.rerender();
        return this.getDomElem();
    }
    createRenderItem() {
        return getReactRendererFromState(this.view.state).createItem('widget', () => (_jsx(Portal, { container: this.getDomElem(), children: _jsx(ErrorLoggerBoundary, { children: this.renderReactElement(this.view, this.getPos) }) })));
    }
}
//# sourceMappingURL=ReactWidgetDescriptor.js.map
