import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App, { HOSTED } from './App.tsx'
import { installStandaloneBridge } from './customer-grid/apiBridge'
import { initializeHostBridge } from './customer-grid/hostBridge'

initializeHostBridge()

// EXIT wave 1 (X2): the standalone write path. THE ONE WIRING POINT — the embed
// bundle runs this file too, and the branch below is the whole of the wave's
// "standalone-only branches" promise. `HOSTED` is App.tsx's own constant, not a
// second copy of the predicate: a component-mode page must never register an
// HTTP sink for events that belong to the Streamlit value slot, and the two
// halves of that rule have to be reading the same answer. Ordered BEFORE render
// so the sink exists by the time the grid's first effect can emit.
if (!HOSTED) installStandaloneBridge()

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