// (C) 2024-2026 GoodData Corporation
import { put, select } from "redux-saga/effects";
import { insightWidgetIgnoreCrossFilteringChanged, } from "../../events/insight.js";
import { tabsActions } from "../../store/tabs/index.js";
import { selectWidgetsMap } from "../../store/tabs/layout/layoutSelectors.js";
import { validateExistingInsightWidget } from "./validation/widgetValidations.js";
export function* changeInsightWidgetIgnoreCrossFilteringHandler(ctx, cmd) {
    const { payload: { ignoreCrossFiltering }, correlationId, } = cmd;
    const widgets = yield select(selectWidgetsMap);
    const insightWidget = validateExistingInsightWidget(widgets, cmd, ctx);
    yield put(tabsActions.changeWidgetIgnoreCrossFiltering({
        ref: insightWidget.ref,
        ignoreCrossFiltering,
        undo: {
            cmd,
        },
    }));
    return insightWidgetIgnoreCrossFilteringChanged(ctx, insightWidget.ref, ignoreCrossFiltering, correlationId);
}
