// (C) 2026 GoodData Corporation
import { omit } from "lodash-es";
import { isAllValuesAttributeFilter, } from "@gooddata/sdk-model";
export function sanitizeAutomationForSave(automation) {
    let sanitized = { ...automation };
    if (sanitized.schedule) {
        sanitized.schedule = omit(sanitized.schedule, ["cronDescription"]);
    }
    if (sanitized.alert?.execution?.filters) {
        sanitized = {
            ...sanitized,
            alert: {
                ...sanitized.alert,
                execution: {
                    ...sanitized.alert.execution,
                    filters: removeNoopFiltersFromAlertFilters(sanitized.alert.execution.filters),
                },
            },
        };
    }
    return sanitized;
}
function removeNoopFiltersFromAlertFilters(filters) {
    return filters.filter((filter) => !isAllValuesAttributeFilter(filter));
}
