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

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