const PUBLIC_AWOOOI_HOSTS = new Set(["aiops.wooo.work", "awoooi.wooo.work"]);

export function getRuntimeApiBaseUrl(): string {
  if (typeof window !== "undefined" && PUBLIC_AWOOOI_HOSTS.has(window.location.hostname)) {
    return window.location.origin;
  }

  return (process.env.NEXT_PUBLIC_API_URL ?? "").replace(/\/+$/, "");
}

export function getRuntimeApiV1BaseUrl(): string {
  const baseUrl = getRuntimeApiBaseUrl();
  if (!baseUrl) return "";
  return baseUrl.endsWith("/api/v1") ? baseUrl : `${baseUrl}/api/v1`;
}
