// (C) 2026 GoodData Corporation
import { call, put, select } from "redux-saga/effects";
import { measureValueFilterRemoved } from "../../../events/filters.js";
import { invalidArgumentsProvided } from "../../../events/general.js";
import { dispatchDashboardEvent } from "../../../store/_infra/eventDispatcher.js";
import { selectFilterContextMeasureValueFilterByLocalId } from "../../../store/tabs/filterContext/filterContextSelectors.js";
import { tabsActions } from "../../../store/tabs/index.js";
import { dispatchFilterContextChanged } from "../common.js";
export function* removeMeasureValueFilterHandler(ctx, cmd) {
    const { localIdentifier } = cmd.payload;
    const affectedFilter = yield select(selectFilterContextMeasureValueFilterByLocalId(localIdentifier));
    if (!affectedFilter) {
        throw invalidArgumentsProvided(ctx, cmd, `Filter with localIdentifier ${localIdentifier} not found.`);
    }
    yield put(tabsActions.removeMeasureValueFilter({ localIdentifier }));
    yield put(tabsActions.removeMeasureValueFilterConfig(localIdentifier));
    yield dispatchDashboardEvent(measureValueFilterRemoved(ctx, affectedFilter, cmd.correlationId));
    yield call(dispatchFilterContextChanged, ctx, cmd);
}
//# sourceMappingURL=removeMeasureValueFilterHandler.js.map