import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2019-2026 GoodData Corporation
import { FormattedMessage } from "react-intl";
import { Typography } from "@gooddata/sdk-ui-kit";
import { DrillFiltersConfig } from "../DrillFilters/DrillFiltersConfig.js";
import { DrillOriginSelector } from "../DrillOriginSelector/DrillOriginSelector.js";
import { InsightDrillConfigList } from "../InsightDrillConfigList.js";
import { ZoomInsightConfiguration } from "../ZoomInsightConfiguration.js";
import { useInsightDrillConfigPanel } from "./useInsightDrillConfigPanel.js";
/**
 * @internal
 */
export function InsightDrillConfigPanel({ widgetRef }) {
    const { widget, insight, drillConfigItems, selectedDrillItem, originSelectorItems, isOriginSelectorVisible, isLoaded, onChangeItem, onOriginSelect, onSetupItem, onUpdateDrillItem, onDeleteItem, } = useInsightDrillConfigPanel({ widgetRef });
    if (selectedDrillItem) {
        return _jsx(DrillFiltersConfig, { item: selectedDrillItem, onUpdateDrillItem: onUpdateDrillItem });
    }
    return (_jsxs(_Fragment, { children: [
            _jsx(ZoomInsightConfiguration, { widget: widget }), _jsxs("div", { className: "configuration-category s-drill-config-panel", children: [
                    _jsx(Typography, { tagName: "h3", children: _jsx("span", { children: _jsx(FormattedMessage, { id: "configurationPanel.drillConfig.interactions" }) }) }), _jsx(InsightDrillConfigList, { disableDrillDown: insight?.insight?.properties?.["controls"]?.disableDrillDown, drillConfigItems: drillConfigItems, onDelete: onDeleteItem, onSetup: onSetupItem, onIncompleteChange: onChangeItem }), isOriginSelectorVisible ? (_jsx(DrillOriginSelector, { widgetRef: widgetRef, items: originSelectorItems, onSelect: onOriginSelect })) : isLoaded ? null : (_jsx("div", { className: "gd-spinner small" }))] })
        ] }));
}
