Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

993 B
Raw Blame
import { renamedColorTokens, themeColorTokens } from '@librechat/client';

const toEnvName = (token) => `REACT_APP_THEME_${token.slice(4).toUpperCase().replace(/-/g, '_')}`;

/**
 * Loads the canonical color-token registry from build-time environment variables.
 * Values are inlined by Vite and continue to use the existing REACT_APP_THEME_* names.
 * @param {Record<string, string | undefined>} [env] Environment source, defaults to the build-time env
 * @returns {import('@librechat/client').IThemeRGB | undefined}
 */
export function getThemeFromEnv(env = import.meta.env) {
  const theme = themeColorTokens.reduce((colors, token) => {
    const value = env[toEnvName(token)];
    if (value) {
      colors[token] = value;
    }
    return colors;
  }, {});
  renamedColorTokens.forEach(([from, to]) => {
    const value = env[toEnvName(from)];
    if (value && theme[to] === undefined) {
      theme[to] = value;
    }
  });

  return Object.keys(theme).length > 0 ? theme : undefined;
}