"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getBaseUrlFromConfiguration = getBaseUrlFromConfiguration;
exports.getClusterSpecificUiSettings = getClusterSpecificUiSettings;
const merge_ui_settings_1 = require("../../shared/utils/merge-ui-settings");
const cluster_params_1 = require("../components/cluster-params");
const base_url_1 = require("../../shared/utils/base-url");
async function getBaseUrlFromConfiguration(req, { cluster, isDeveloper, uiSettingsFieldName, }) {
    const uiSettings = await getClusterSpecificUiSettings(req, {
        cluster,
        isDeveloper,
    });
    return (0, base_url_1.getBaseUrlDetails)(uiSettings, uiSettingsFieldName);
}
async function getClusterSpecificUiSettings(req, { cluster, isDeveloper }) {
    const { uiSettings } = req.ctx.config;
    const uiConfig = await (0, cluster_params_1.getPreloadedClusterUiConfig)(cluster, req.ctx, isDeveloper);
    return (0, merge_ui_settings_1.mergeUiSettings)({ uiSettings, uiConfig });
}
