import { augmentAnalyticsConfigWithAtomicVersion, augmentAnalyticsConfigWithDocument, augmentAnalyticsWithAtomicVersion, augmentWithExternalMiddleware, getNextAnalyticsConfig } from "../../common/interface/analytics-config.js";
function getAnalyticsConfig(recsConfig, enabled) {
    switch(recsConfig.analytics?.analyticsMode){
        case 'next':
            return getNextAnalyticsConfig(recsConfig, enabled);
        default:
            return getLegacyAnalyticsConfig(recsConfig, enabled);
    }
}
function getLegacyAnalyticsConfig(recsConfig, enabled) {
    const analyticsClientMiddleware = (event, payload)=>augmentAnalytics(event, payload, recsConfig);
    const defaultAnalyticsConfig = {
        analyticsClientMiddleware,
        enabled,
        ...augmentAnalyticsConfigWithDocument(),
        ...augmentAnalyticsConfigWithAtomicVersion()
    };
    if (recsConfig.analytics) return {
        ...defaultAnalyticsConfig,
        ...recsConfig.analytics,
        analyticsClientMiddleware
    };
    return defaultAnalyticsConfig;
}
function augmentAnalytics(event, payload, recsConfig) {
    let result = augmentWithExternalMiddleware(event, payload, recsConfig);
    result = augmentAnalyticsWithAtomicVersion(result);
    return result;
}
export { getAnalyticsConfig };
