import React from 'react'
import ReactDOM from 'react-dom/client'
import './index.css'

/** Inlined here (not via `sitePublic`) so Vite can drop the unused branch at build time (CS1). */
const FULL_SITE_BUILD = import.meta.env.VITE_FULL_SITE === 'true'

async function mount() {
  const rootEl = document.getElementById('root')
  if (!rootEl) return

  if (FULL_SITE_BUILD) {
    const [{ default: AppFull }, { AuthProvider }, { CartProvider }] = await Promise.all([
      import('./AppFull'),
      import('./features/auth/AuthContext'),
      import('./features/cart/CartContext'),
    ])
    ReactDOM.createRoot(rootEl).render(
      <React.StrictMode>
        <AuthProvider>
          <CartProvider>
            <AppFull />
          </CartProvider>
        </AuthProvider>
      </React.StrictMode>,
    )
    return
  }

  const { ComingSoonApp } = await import('./comingSoon/ComingSoonApp')
  ReactDOM.createRoot(rootEl).render(
    <React.StrictMode>
      <ComingSoonApp />
    </React.StrictMode>,
  )
}

void mount()
