import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { RestoreCharacterForm } from '../components/RestoreCharacterForm'

const el = document.getElementById('restore-character-app')
if (el) {
  const dEl = document.getElementById('restore-character-data')
  const characters = dEl ? JSON.parse(dEl.textContent || '[]') : []
  createRoot(el).render(
    <StrictMode>
      <RestoreCharacterForm url={el.dataset.url || ''} csrfToken={el.dataset.csrf || ''} characters={characters} />
    </StrictMode>,
  )
}
