import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2020-2026 GoodData Corporation
import { Fragment } from "react";
import { FormattedMessage } from "react-intl";
import { filterLocalIdentifier, 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 DashboardParametersSection({ dashboardFilters, attributeFilterConfigs, onAdd, }) {
    const catalogDisplayFormsMap = useDashboardSelector(selectAllCatalogDisplayFormsMap);
    return dashboardFilters && dashboardFilters.length > 0 ? (_jsxs(_Fragment, { children: [
            _jsx(DropdownSectionHeader, { children: _jsx(FormattedMessage, { id: "configurationPanel.drillIntoUrl.editor.dashboardParametersSectionLabel" }) }), dashboardFilters?.map((filter, index) => {
                const df = catalogDisplayFormsMap.get(filterObjRef(filter));
                const filterIdentifier = df?.id;
                const config = attributeFilterConfigs?.find((c) => c.localIdentifier === filterLocalIdentifier(filter));
                const secondaryDf = config?.displayAsLabel
                    ? catalogDisplayFormsMap.get(config?.displayAsLabel)
                    : undefined;
                const filterSecondaryIdentifier = secondaryDf?.id;
                const areDfsDifferent = filterIdentifier !== filterSecondaryIdentifier;
                return (_jsxs(Fragment, { children: [df ? (_jsx(DisplayFormParam, { item: df, iconClassName: "gd-icon-filter", onAdd: () => {
                                onAdd(`{dash_attribute_filter_selection(${filterIdentifier})}`);
                            }, isFilter: true })) : null, secondaryDf && areDfsDifferent ? (_jsx(DisplayFormParam, { item: secondaryDf, iconClassName: "gd-icon-filter", onAdd: () => {
                                onAdd(`{dash_attribute_filter_selection(${filterSecondaryIdentifier})}`);
                            }, isFilter: true })) : null] }, index));
            })] })) : null;
}
//# sourceMappingURL=DashboardParametersSection.js.map