"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeLocalModeConfig = makeLocalModeConfig;
const constants_1 = require("./constants");
const ServerFactory_1 = require("./ServerFactory");
const localProxy = process.env.PROXY;
const localThemes = {
    [constants_1.YT_LOCAL_CLUSTER_ID]: 'grapefruit',
    [localProxy]: 'grapefruit',
};
function makeClusterConfig(id, name, proxy) {
    const { localmodeClusterConfig, allowPasswordAuth } = (0, ServerFactory_1.getApp)().config ?? {};
    return {
        ...localmodeClusterConfig,
        id,
        name,
        proxy,
        authentication: allowPasswordAuth ? 'basic' : 'none',
        secure: false,
        theme: localThemes[id] ?? 'mint',
        description: 'Local',
        environment: 'development',
    };
}
function makeLocalClusters() {
    const localClusters = localProxy
        ? {
            [constants_1.YT_LOCAL_CLUSTER_ID]: makeClusterConfig(constants_1.YT_LOCAL_CLUSTER_ID, 'Local', localProxy),
            [localProxy]: makeClusterConfig(localProxy, 'Local as remote', localProxy),
        }
        : {};
    return localClusters;
}
function makeLocalModeConfig(proxy) {
    const proxyClusters = proxy && proxy !== constants_1.YT_LOCAL_CLUSTER_ID
        ? { [proxy]: makeClusterConfig(proxy, 'Local as remote', proxy) }
        : {};
    return {
        isLocalCluster: true,
        environment: 'localmode',
        clusters: {
            ...makeLocalClusters(),
            ...proxyClusters,
        },
    };
}
