/**
 * Hub URL — single source of truth for targo-hub API base URL.
 *
 * All components, composables, and pages should import from here:
 *   import { HUB_URL } from 'src/config/hub'
 *
 * In dev (localhost), points to local targo-hub instance.
 * In production, uses the SAME-ORIGIN proxy: /ops/hub/* → Traefik strips /ops
 * → ops-frontend nginx `location /hub/` injects the hub service token (Bearer)
 * → targo-hub. This keeps the token server-side (never in the JS bundle), lets
 * EventSource (/sse, /conversations) work, and rides the existing Authentik
 * forward-auth on /ops. Mirrors the /ops/api → ERPNext pattern (config/erpnext.js).
 *
 * Can also be overridden via VITE_HUB_URL env variable.
 */
const _opsBase = (import.meta.env.BASE_URL || '/').replace(/\/$/, '') // '' in dev, '/ops' in prod
export const HUB_URL = import.meta.env.VITE_HUB_URL
  || (window.location.hostname === 'localhost' ? 'http://localhost:3300' : _opsBase + '/hub')
