import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { BrowserRouter, HashRouter } from 'react-router-dom'
import './index.css'
import App from './App.tsx'
import { AuthProvider } from './auth/AuthContext'
import { applyBrand } from './lib/brand'

applyBrand()

// The packaged desktop app loads the bundled SPA over file://, where the
// History API has no server to back path routing — use HashRouter there.
// The web build (served over http behind nginx) keeps clean BrowserRouter URLs.
const Router = window.location.protocol === 'file:' ? HashRouter : BrowserRouter

createRoot(document.getElementById('root')!).render(
  <StrictMode>
    <Router>
      <AuthProvider>
        <App />
      </AuthProvider>
    </Router>
  </StrictMode>,
)
