import { jsx as _jsx } from "react/jsx-runtime";
// (C) 2023-2025 GoodData Corporation
import { useEffect, useMemo } from "react";
import { injectIntl } from "react-intl";
import { ErrorCodes, ErrorComponent, IntlWrapper, newErrorMapping } from "@gooddata/sdk-ui";
import { AbstractPluggableVisualization } from "./AbstractPluggableVisualization.js";
function LocalizedUnknownVisualizationClass({ intl, onAfterRender, }) {
    const errorDetails = useMemo(() => newErrorMapping(intl)[ErrorCodes.VISUALIZATION_CLASS_UNKNOWN], [intl]);
    useEffect(() => {
        onAfterRender?.();
    }, [onAfterRender]);
    const { message, description } = errorDetails;
    return _jsx(ErrorComponent, { message: message, description: description });
}
export const IntlLocalizedUnknownVisualizationClass = injectIntl(LocalizedUnknownVisualizationClass);
export class PluggableUnknownChart extends AbstractPluggableVisualization {
    renderFun;
    unmountFun;
    constructor(props) {
        super(props);
        this.renderFun = props.renderFun;
        this.unmountFun = props.unmountFun;
    }
    getExtendedReferencePoint(referencePoint) {
        return Promise.resolve({ ...referencePoint, uiConfig: null });
    }
    getExecution(_options, _insight, _executionFactory) {
        return null;
    }
    renderConfigurationPanel(_insight) { }
    renderVisualization(options, _insight, _executionFactory) {
        this.renderFun(_jsx(IntlWrapper, { locale: options.locale, children: _jsx(IntlLocalizedUnknownVisualizationClass, { onAfterRender: this.afterRender }) }), this.getElement());
        this.onLoadingChanged?.({ isLoading: false });
    }
    unmount() {
        this.unmountFun([this.getElement()]);
    }
}
//# sourceMappingURL=PluggableUnknownChart.js.map