function withoutTrailingSlash(value: string): string { return value.replace(/\/$/, ""); } function defaultEnvBase(): string { if (typeof window === "undefined") return "http://127.0.0.1:8100"; const host = window.location.hostname; const localHosts = new Set(["localhost", "127.0.0.1", "0.0.0.0"]); if (localHosts.has(host)) return "http://127.0.0.1:8100"; return window.location.origin; } export const API_BASE = withoutTrailingSlash((import.meta.env.VITE_API_BASE as string | undefined) ?? "/api"); export const ENV_BASE = withoutTrailingSlash( (import.meta.env.VITE_ENV_BASE as string | undefined) ?? defaultEnvBase(), ); export const PAGES = [ "Home", "Dashboard", "PatientWorkbench", "EpisodeReplay", "PolicyCompare", "PrecisionDosing", "TrainingMonitor", "SafetyInspector", ] as const; export type PageName = (typeof PAGES)[number];