export const TRUSTED_ORIGINS_STORAGE_KEY = "athena_auth_demo_trusted_origins";

export function parseTrustedOrigins(config: string): string[] {
  return config
    .split(",")
    .map((part) => part.trim())
    .filter(Boolean);
}

export function addOriginToTrustedOrigins(config: string, origin: string): string {
  const current = parseTrustedOrigins(config);
  if (current.includes(origin)) return config;
  return [...current, origin].join(",");
}

export function buildTrustedOriginsEnvLine(config: string): string {
  return `TRUSTED_ORIGINS=${config}`;
}
