import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2020-2026 GoodData Corporation
import { FormattedMessage } from "react-intl";
import { filterObjRef } from "@gooddata/sdk-model";
import { useDashboardSelector } from "../../../../../model/react/DashboardStoreProvider.js";
import { selectAllCatalogDisplayFormsMap } from "../../../../../model/store/catalog/catalogSelectors.js";
import { DropdownSectionHeader } from "../DropdownSectionHeader.js";
import { DisplayFormParam } from "./DisplayFormParam.js";
export function InsightParametersSection({ attributeDisplayForms, loadingAttributeDisplayForms, insightFilters, onAdd, }) {
    const catalogDisplayForms = useDashboardSelector(selectAllCatalogDisplayFormsMap);
    return (_jsx(_Fragment, { children: (attributeDisplayForms && attributeDisplayForms.length > 0) ||
            loadingAttributeDisplayForms ||
            (insightFilters && insightFilters.length > 0) ? (_jsxs(_Fragment, { children: [
                _jsx(DropdownSectionHeader, { children: _jsx(FormattedMessage, { id: "configurationPanel.drillIntoUrl.editor.insightParametersSectionLabel" }) }), loadingAttributeDisplayForms ? (_jsx("div", { className: "gd-drill-to-url-section-loading s-drill-to-custom-url-attr-section-loading", children: _jsx("div", { className: "gd-spinner small" }) })) : (attributeDisplayForms?.map((item) => (_jsx(DisplayFormParam, { item: item.displayForm, onAdd: onAdd }, item.displayForm.id)))), insightFilters?.map((filter, index) => {
                    const displayFormRef = filterObjRef(filter);
                    const df = catalogDisplayForms.get(displayFormRef);
                    return (df && (_jsx(DisplayFormParam, { item: df, onAdd: () => onAdd(`{attribute_filter_selection(${df.id})}`), iconClassName: "gd-icon-filter", isFilter: true }, index)));
                })] })) : null }));
}
//# sourceMappingURL=InsightParametersSection.js.map