var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
import { jsx as _jsx } from "react/jsx-runtime";
import { useCallback } from 'react';
import Plotly from 'plotly.js-dist-min';
import { ChartPanel, } from '@deephaven/dashboard-core-plugins';
import { ChartTheme } from '@deephaven/chart';
import { useApi } from '@deephaven/jsapi-bootstrap';
import PlotlyExpressChartModel from './PlotlyExpressChartModel';
import { getWidgetData, getDataMappings, } from './PlotlyExpressChartUtils';
function PlotlyExpressChartPanel(props) {
    const dh = useApi();
    const { fetch } = props, rest = __rest(props, ["fetch"]);
    const makeModel = useCallback(async () => {
        var _a;
        const widgetInfo = await fetch();
        const data = getWidgetData(widgetInfo);
        const { plotly, deephaven } = data;
        const isDefaultTemplate = !deephaven.is_user_set_template;
        const tableColumnReplacementMap = await getDataMappings(widgetInfo);
        return new PlotlyExpressChartModel(dh, tableColumnReplacementMap, plotly.data, (_a = plotly.layout) !== null && _a !== void 0 ? _a : {}, isDefaultTemplate, ChartTheme);
    }, [dh, fetch]);
    return (_jsx(ChartPanel
    // eslint-disable-next-line react/jsx-props-no-spreading
    , Object.assign({}, rest, { makeModel: makeModel, Plotly: Plotly })));
}
PlotlyExpressChartPanel.displayName = 'PlotlyExpressChartPanel';
export default PlotlyExpressChartPanel;
//# sourceMappingURL=PlotlyExpressChartPanel.js.map