// (C) 2021-2026 GoodData Corporation
import { put, select } from "redux-saga/effects";
import { insightWidgetDescriptionChanged, } 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* changeInsightWidgetDescriptionHandler(ctx, cmd) {
    const { payload: { description }, correlationId, } = cmd;
    const widgets = yield select(selectWidgetsMap);
    const insightWidget = validateExistingInsightWidget(widgets, cmd, ctx);
    yield put(tabsActions.replaceWidgetDescription({
        ref: insightWidget.ref,
        description,
        undo: {
            cmd,
        },
    }));
    return insightWidgetDescriptionChanged(ctx, insightWidget.ref, description, correlationId);
}
//# sourceMappingURL=changeInsightWidgetDescriptionHandler.js.map