import { AccountsRoute, AdminDashboardRoute, ApiReferenceRoute, AppApiRoute, DashboardRoute, DocsRoute, FileRoute, HomeRoute, IdentityRoute, ProbeIngestRoute, IntegrationRoute, NotificationRoute, PublicDashboardRoute, RealtimeRoute, StatusPageApiRoute, StatusPageRoute, WorkflowRoute, RunbookRoute, TelemetryRoute, } from "../ServiceRoute";
import Hostname from "../Types/API/Hostname";
import Protocol from "../Types/API/Protocol";
import URL from "../Types/API/URL";
import Route from "../Types/API/Route";
import SubscriptionPlan from "../Types/Billing/SubscriptionPlan";
import Version from "../Types/Version";
export const getAllEnvVars = () => {
    var _a;
    const envVars = ((_a = window === null || window === void 0 ? void 0 : window.process) === null || _a === void 0 ? void 0 : _a.env) || (process === null || process === void 0 ? void 0 : process.env) || {};
    return envVars;
};
export const env = (key) => {
    const allEnv = getAllEnvVars();
    return allEnv[key] || "";
};
export const HTTP_PROTOCOL = env("HTTP_PROTOCOL") === "https" ? Protocol.HTTPS : Protocol.HTTP;
export const HOST = env("HOST") || "";
export const BILLING_ENABLED = env("BILLING_ENABLED") === "true";
export const IS_ENTERPRISE_EDITION = env("IS_ENTERPRISE_EDITION") === "true";
export const BILLING_PUBLIC_KEY = env("BILLING_PUBLIC_KEY") || "";
export const CAPTCHA_ENABLED = env("CAPTCHA_ENABLED") === "true";
export const CAPTCHA_SITE_KEY = env("CAPTCHA_SITE_KEY") || "";
// VAPID Configuration for Push Notifications
export const VAPID_PUBLIC_KEY = env("VAPID_PUBLIC_KEY") || "";
export const VERSION = new Version(env("VERSION") || "1.0.0");
export const APP_HOSTNAME = Hostname.fromString(HOST);
export const IDENTITY_HOSTNAME = Hostname.fromString(HOST);
export const NOTIFICATION_HOSTNAME = Hostname.fromString(HOST);
export const DASHBOARD_HOSTNAME = Hostname.fromString(HOST);
// realtime
export const REALTIME_HOSTNAME = Hostname.fromString(HOST);
export const INTEGRATION_HOSTNAME = Hostname.fromString(HOST);
export const STATUS_PAGE_HOSTNAME = Hostname.fromString(HOST);
export const WORKFLOW_HOSTNAME = Hostname.fromString(HOST);
export const TELEMETRY_HOSTNAME = Hostname.fromString(HOST);
export const HELM_HOSTNAME = Hostname.fromString(HOST);
export const API_DOCS_HOSTNAME = Hostname.fromString(HOST);
export const ADMIN_DASHBOARD_HOSTNAME = Hostname.fromString(HOST);
export const ACCOUNTS_HOSTNAME = Hostname.fromString(HOST);
export const HOME_HOSTNAME = Hostname.fromString(HOST);
export const FILE_HOSTNAME = Hostname.fromString(HOST);
export const APP_API_URL = new URL(HTTP_PROTOCOL, APP_HOSTNAME, new Route(AppApiRoute.toString()));
export const REALTIME_URL = new URL(HTTP_PROTOCOL, REALTIME_HOSTNAME, new Route(RealtimeRoute.toString()));
export const DOCS_URL = new URL(HTTP_PROTOCOL, REALTIME_HOSTNAME, new Route(DocsRoute.toString()));
export const STATUS_PAGE_API_URL = new URL(HTTP_PROTOCOL, STATUS_PAGE_HOSTNAME, new Route(StatusPageApiRoute.toString()));
export const TELEMETRY_URL = new URL(HTTP_PROTOCOL, TELEMETRY_HOSTNAME, new Route(TelemetryRoute.toString()));
export const IDENTITY_URL = new URL(HTTP_PROTOCOL, IDENTITY_HOSTNAME, new Route(IdentityRoute.toString()));
export const NOTIFICATION_URL = new URL(HTTP_PROTOCOL, NOTIFICATION_HOSTNAME, new Route(NotificationRoute.toString()));
export const WORKFLOW_URL = new URL(HTTP_PROTOCOL, WORKFLOW_HOSTNAME, new Route(WorkflowRoute.toString()));
export const RUNBOOK_URL = new URL(HTTP_PROTOCOL, APP_HOSTNAME, new Route(RunbookRoute.toString()));
export const PROBE_INGEST_URL = new URL(HTTP_PROTOCOL, TELEMETRY_HOSTNAME, new Route(ProbeIngestRoute.toString()));
export const STATUS_PAGE_URL = new URL(HTTP_PROTOCOL, STATUS_PAGE_HOSTNAME, new Route(StatusPageRoute.toString()));
export const FILE_URL = new URL(HTTP_PROTOCOL, FILE_HOSTNAME, new Route(FileRoute.toString()));
export const DASHBOARD_URL = new URL(HTTP_PROTOCOL, DASHBOARD_HOSTNAME, new Route(DashboardRoute.toString()));
export const PUBLIC_DASHBOARD_URL = new URL(HTTP_PROTOCOL, DASHBOARD_HOSTNAME, new Route(PublicDashboardRoute.toString()));
export const INTEGRATION_URL = new URL(HTTP_PROTOCOL, INTEGRATION_HOSTNAME, new Route(IntegrationRoute.toString()));
export const API_DOCS_URL = new URL(HTTP_PROTOCOL, API_DOCS_HOSTNAME, new Route(ApiReferenceRoute.toString()));
export const ADMIN_DASHBOARD_URL = new URL(HTTP_PROTOCOL, ADMIN_DASHBOARD_HOSTNAME, new Route(AdminDashboardRoute.toString()));
export const ACCOUNTS_URL = new URL(HTTP_PROTOCOL, ACCOUNTS_HOSTNAME, new Route(AccountsRoute.toString()));
export const HOME_URL = new URL(HTTP_PROTOCOL, HOME_HOSTNAME, new Route(HomeRoute.toString()));
export const SubscriptionPlans = SubscriptionPlan.getSubscriptionPlans(getAllEnvVars());
export const StatusPageCNameRecord = env("STATUS_PAGE_CNAME_RECORD") || "";
export const DashboardCNameRecord = env("DASHBOARD_CNAME_RECORD") || "";
export const AnalyticsKey = env("ANALYTICS_KEY") || "";
export const AnalyticsHost = env("ANALYTICS_HOST");
export const GitSha = env("GIT_SHA") || "";
export const AppVersion = env("APP_VERSION") || "";
export const OpenTelemetryExporterOtlpEndpoint = env("OPENTELEMETRY_EXPORTER_OTLP_ENDPOINT")
    ? URL.fromString(env("OPENTELEMETRY_EXPORTER_OTLP_ENDPOINT").toString())
    : null;
const getOpenTelemetryExporterOtlpHeaders = () => {
    if (!env("OPENTELEMETRY_EXPORTER_OTLP_HEADERS")) {
        return {};
    }
    const headersStrings = env("OPENTELEMETRY_EXPORTER_OTLP_HEADERS")
        .toString()
        .split(";");
    const headers = {};
    for (const headerString of headersStrings) {
        const header = headerString.split("=");
        if (header.length === 2) {
            headers[header[0].toString()] = header[1].toString();
        }
    }
    return headers;
};
export const OpenTelemetryExporterOtlpHeaders = getOpenTelemetryExporterOtlpHeaders();
export const DisableTelemetry = env("DISABLE_TELEMETRY") === "true";
export const SlackAppClientId = env("SLACK_APP_CLIENT_ID") || null;
export const MicrosoftTeamsAppClientId = env("MICROSOFT_TEAMS_APP_CLIENT_ID") || null;
export const GitHubAppClientId = env("GITHUB_APP_CLIENT_ID") || null;
export const GitHubAppName = env("GITHUB_APP_NAME") || null;
export const INBOUND_EMAIL_DOMAIN = env("INBOUND_EMAIL_DOMAIN") || undefined;
//# sourceMappingURL=Config.js.map