import { merge } from "lodash";
/**
 * Returns the merged configuration from path and fallbackPath.
 * Configuration of fallbackPath does not override the configuration from path.
 * @param config configuration.
 * @param path primary path.
 * @param fallbackPath fallback path.
 * @returns
 */
export function findConfig(config, path, fallbackPath = undefined) {
    const mainConfig = findConfigImpl(config, path);
    const fallbackConfig = findConfigImpl(config, fallbackPath);
    if (!fallbackConfig) {
        return mainConfig;
    }
    return merge({}, { data: fallbackConfig }, { data: mainConfig }).data;
}
function findConfigImpl(config, path) {
    if (!config || !path) {
        return undefined;
    }
    if (typeof path === "string") {
        path = path.split("/");
    }
    if (path.length === 0) {
        return config;
    }
    const first = path.shift();
    return findConfigImpl(config[first], path);
}
//# sourceMappingURL=configTools.js.map