import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import * as Sentry from '@sentry/react'
import { Buffer } from 'buffer'
import './index.css'
import { Providers } from '@/app/providers'
import App from './App.tsx'
import { ErrorBoundary } from '@/components/ErrorBoundary'

// Initialize Sentry as early as possible, before the app renders.
Sentry.init({
  dsn: 'https://ed237bf5afc4eff1ccacb3a62d0067c9@o4511596333367296.ingest.us.sentry.io/4511596337889280',
  dataCollection: {
    // To disable sending user data and HTTP bodies, uncomment the lines below. For more info visit:
    // https://docs.sentry.io/platforms/javascript/guides/react/configuration/options/#dataCollection
    // userInfo: false,
    // httpBodies: []
  },
})

// Polyfill Buffer for @react-pdf/renderer
window.Buffer = Buffer

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