/* eslint-disable no-use-before-define */ /* eslint-disable no-nested-ternary */ import { sanitizeConfig } from './sanitize.js';
/**
 * @description Builds and validates Payload configuration
 * @param config Payload Config
 * @returns Built and sanitized Payload Config
 */ export async function buildConfig(config) {
    if (Array.isArray(config.plugins)) {
        const configAfterPlugins = await config.plugins.reduce(async (acc, plugin)=>{
            const configAfterPlugin = await acc;
            return plugin(configAfterPlugin);
        }, Promise.resolve(config));
        const sanitizedConfig = sanitizeConfig(configAfterPlugins);
        return sanitizedConfig;
    }
    return sanitizeConfig(config);
}

//# sourceMappingURL=build.js.map