import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import { BrowserRouter } from 'react-router-dom';
import { App } from './App';
import { ZinoProvider } from './api/provider';
import './styles/styles.css';

const baseUrl = import.meta.env.VITE_ZINO_API_URL || 'https://qa.getzino.in';
// Keep client routes under Vite's base (e.g. /lead-to-policy) so a refresh on
// an in-app route hits the preview's per-slug SPA fallback. '/' in dev.
const routerBase = import.meta.env.BASE_URL.replace(/\/$/, '');

createRoot(document.getElementById('root')!).render(
  <StrictMode>
    <ZinoProvider baseUrl={baseUrl}>
      <BrowserRouter basename={routerBase}>
        <App />
      </BrowserRouter>
    </ZinoProvider>
  </StrictMode>,
);
