// (C) 2025-2026 GoodData Corporation
import { areObjRefsEqual, dashboardAttributeFilterItemDisplayForm, isDashboardAttributeFilterItem, isDashboardCommonDateFilter, isDashboardDateFilter, isInsightWidget, } from "@gooddata/sdk-model";
/**
 * @internal
 */
export function removeIgnoredWidgetFilters(filters, widget) {
    if (!isInsightWidget(widget)) {
        return filters;
    }
    return filters.filter((filter) => isDashboardCommonDateFilter(filter)
        ? !!widget.dateDataSet
        : !widget.ignoreDashboardFilters.some((ignoredFilter) => {
            if (isDashboardDateFilter(filter) && ignoredFilter.type === "dateFilterReference") {
                return areObjRefsEqual(ignoredFilter.dataSet, filter.dateFilter.dataSet);
            }
            if (isDashboardAttributeFilterItem(filter) &&
                ignoredFilter.type === "attributeFilterReference") {
                return areObjRefsEqual(ignoredFilter.displayForm, dashboardAttributeFilterItemDisplayForm(filter));
            }
            return false;
        }));
}
/**
 * @internal
 */
export function removeDateFilters(filters) {
    return filters.filter(isDashboardAttributeFilterItem);
}
//# sourceMappingURL=widgetFilters.js.map