// (C) 2021-2026 GoodData Corporation
import { invariant } from "ts-invariant";
import { EmptyDashboardDescriptor } from "./metaState.js";
const setMeta = (state, action) => {
    const { dashboard, initialContent } = action.payload;
    state.persistedDashboard = dashboard;
    state.descriptor = dashboard
        ? {
            title: dashboard.title,
            description: dashboard.description,
            tags: dashboard.tags,
            shareStatus: dashboard.shareStatus,
            evaluationFrequency: dashboard.evaluationFrequency,
            isUnderStrictControl: dashboard.isUnderStrictControl,
            isLocked: dashboard.isLocked,
            disableCrossFiltering: dashboard.disableCrossFiltering,
            disableUserFilterReset: dashboard.disableUserFilterReset,
            disableUserFilterSave: dashboard.disableUserFilterSave,
            disableFilterViews: dashboard.disableFilterViews,
            sectionHeadersDateDataSet: dashboard.sectionHeadersDateDataSet,
        }
        : { ...EmptyDashboardDescriptor };
    state.initialContent = initialContent;
};
const setDashboardTitle = (state, action) => {
    invariant(state.descriptor);
    state.descriptor.title = action.payload;
};
const setDisableCrossFiltering = (state, action) => {
    invariant(state.descriptor);
    state.descriptor.disableCrossFiltering = action.payload;
};
const setDisableUserFilterReset = (state, action) => {
    invariant(state.descriptor);
    state.descriptor.disableUserFilterReset = action.payload;
};
const setDisableUserFilterSave = (state, action) => {
    invariant(state.descriptor);
    state.descriptor.disableUserFilterSave = action.payload;
};
const setDisableFilterViews = (state, action) => {
    invariant(state.descriptor);
    state.descriptor.disableFilterViews = action.payload;
};
const setEvaluationFrequency = (state, action) => {
    invariant(state.descriptor);
    state.descriptor.evaluationFrequency = action.payload || undefined;
};
const setSectionHeadersDateDataSet = (state, action) => {
    invariant(state.descriptor);
    state.descriptor.sectionHeadersDateDataSet = action.payload;
};
export const metaReducers = {
    setMeta,
    setDashboardTitle,
    setDisableCrossFiltering,
    setDisableUserFilterReset,
    setDisableUserFilterSave,
    setDisableFilterViews,
    setEvaluationFrequency,
    setSectionHeadersDateDataSet,
};
//# sourceMappingURL=metaReducers.js.map