import { merge } from 'lodash-es';
import { buildWidgetControlsFromPresets, GLOBAL_CONTEXT_DISPLAY_MODE, REFRESH_OPTION } from '@c8y/ngx-components/global-context';
import { defaultWidgetIds } from '@c8y/ngx-components/widgets/definitions';

const getBaselineControls = () => buildWidgetControlsFromPresets({ presets: ['default'] });
/**
 * Produces the baseline alarm list controls preset mirroring the default
 * widget behaviour.
 *
 * @returns Fresh baseline controls instance for the alarm list widget.
 */
function createAlarmListControls() {
    return getBaselineControls();
}
/**
 * Produces the legacy alarm controls preset shared by the "recent" and
 * "critical" alarm widgets. It hides the refresh interval and exposes the
 * manual refresh button inline.
 *
 * @returns Alarm controls tailored for legacy alarm widgets.
 */
function createLegacyAlarmControls() {
    return mergeWithBaseline({
        configSettings: {
            [GLOBAL_CONTEXT_DISPLAY_MODE.CONFIG]: {
                [REFRESH_OPTION.HISTORY]: {
                    showTimeContext: true,
                    showAggregation: false
                }
            },
            [GLOBAL_CONTEXT_DISPLAY_MODE.VIEW_AND_CONFIG]: {
                [REFRESH_OPTION.HISTORY]: {
                    showTimeContext: true,
                    showAggregation: false
                }
            }
        },
        settings: {
            [GLOBAL_CONTEXT_DISPLAY_MODE.CONFIG]: {
                [REFRESH_OPTION.LIVE]: {
                    showRefreshInterval: false,
                    showRefresh: true
                },
                [REFRESH_OPTION.HISTORY]: {
                    showTimeContext: true,
                    showAggregation: false
                }
            },
            [GLOBAL_CONTEXT_DISPLAY_MODE.VIEW_AND_CONFIG]: {
                [REFRESH_OPTION.HISTORY]: {
                    showTimeContext: true,
                    showAggregation: false
                }
            }
        }
    });
}
/**
 * Helper that clones the baseline controls and applies the provided overrides.
 *
 * @param overrides Partial control information to merge into the baseline.
 * @returns Combined control definition.
 */
function mergeWithBaseline(overrides) {
    return merge(getBaselineControls(), overrides);
}
/**
 * Resolves the appropriate controls preset based on the widget identifier.
 *
 * @param widgetId Optional widget id coming from the widget config/definition.
 * @returns Fully materialised controls for the widget.
 */
function resolveAlarmControls(widgetId) {
    switch (widgetId) {
        case defaultWidgetIds.ALL_CRITICAL_ALARMS:
        case defaultWidgetIds.RECENT_ALARMS:
            return createLegacyAlarmControls();
        default:
            return createAlarmListControls();
    }
}

/**
 * Generated bundle index. Do not edit.
 */

export { createAlarmListControls, createLegacyAlarmControls, resolveAlarmControls };
//# sourceMappingURL=c8y-ngx-components-widgets-definitions-alarms-alarm-widget-controls.presets.mjs.map
