import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.tsx'
import { ErrorBoundary } from './components/ErrorBoundary'
import { initPwa } from './pwa'
import { migrateStorage } from './utils/storage'
import { initChartStore } from './utils/chartStore'

// Carry a journal saved under the pre-rename keys forward before React reads
// any state initialisers. Failure here must never block rendering.
migrateStorage()
void initChartStore()

initPwa()

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