// @bun
import {
  getClaudeAIOAuthTokens,
  init_auth
} from "./chunk-s2t5anwv.js";
import {
  getOauthConfig,
  init_oauth
} from "./chunk-qfsn720k.js";
import {
  init_envUtils,
  isEnvTruthy
} from "./chunk-s3hafnk3.js";
import {
  __esm
} from "./chunk-hhsxm2yr.js";

// src/bridge/bridgeEnv.ts
function getRedScopeEnvWithLegacy(primaryName, legacyName) {
  return process.env[primaryName] || process.env[legacyName] || undefined;
}
function getBridgeBaseUrlOverrideEnv() {
  return getRedScopeEnvWithLegacy(REDSCOPE_BRIDGE_BASE_URL_ENV, LEGACY_BRIDGE_BASE_URL_ENV);
}
function getBridgeTokenOverrideEnv() {
  return getRedScopeEnvWithLegacy(REDSCOPE_BRIDGE_OAUTH_TOKEN_ENV, LEGACY_BRIDGE_OAUTH_TOKEN_ENV);
}
function getBridgeSessionIngressUrl(baseUrl) {
  return getRedScopeEnvWithLegacy(REDSCOPE_BRIDGE_SESSION_INGRESS_URL_ENV, LEGACY_BRIDGE_SESSION_INGRESS_URL_ENV) ?? baseUrl;
}
function isBridgeCcrV2OverrideEnabled() {
  return isEnvTruthy(process.env[REDSCOPE_BRIDGE_USE_CCR_V2_ENV]) || isEnvTruthy(process.env[LEGACY_BRIDGE_USE_CCR_V2_ENV]);
}
var REDSCOPE_BRIDGE_BASE_URL_ENV = "REDSCOPE_BRIDGE_BASE_URL", LEGACY_BRIDGE_BASE_URL_ENV = "CLAUDE_BRIDGE_BASE_URL", REDSCOPE_BRIDGE_OAUTH_TOKEN_ENV = "REDSCOPE_BRIDGE_OAUTH_TOKEN", LEGACY_BRIDGE_OAUTH_TOKEN_ENV = "CLAUDE_BRIDGE_OAUTH_TOKEN", REDSCOPE_BRIDGE_SESSION_INGRESS_URL_ENV = "REDSCOPE_BRIDGE_SESSION_INGRESS_URL", LEGACY_BRIDGE_SESSION_INGRESS_URL_ENV = "CLAUDE_BRIDGE_SESSION_INGRESS_URL", REDSCOPE_BRIDGE_USE_CCR_V2_ENV = "REDSCOPE_BRIDGE_USE_CCR_V2", LEGACY_BRIDGE_USE_CCR_V2_ENV = "CLAUDE_BRIDGE_USE_CCR_V2";
var init_bridgeEnv = __esm(() => {
  init_envUtils();
});

// src/bridge/bridgeConfig.ts
function getBridgeTokenOverride() {
  return getBridgeTokenOverrideEnv();
}
function getBridgeBaseUrlOverride() {
  return getBridgeBaseUrlOverrideEnv();
}
function getBridgeAccessToken() {
  return getBridgeTokenOverride() ?? getClaudeAIOAuthTokens()?.accessToken;
}
function getBridgeBaseUrl() {
  return getBridgeBaseUrlOverride() ?? getOauthConfig().BASE_API_URL;
}
function isSelfHostedBridge() {
  return !!getBridgeBaseUrlOverride();
}
var init_bridgeConfig = __esm(() => {
  init_oauth();
  init_auth();
  init_bridgeEnv();
});

export { getBridgeSessionIngressUrl, isBridgeCcrV2OverrideEnabled, init_bridgeEnv, getBridgeTokenOverride, getBridgeBaseUrlOverride, getBridgeAccessToken, getBridgeBaseUrl, isSelfHostedBridge, init_bridgeConfig };
