import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { SelectAccount, type GameAccount } from '../components/SelectAccount'

const dataEl = document.getElementById('select-account-data')
const accounts: GameAccount[] = dataEl ? JSON.parse(dataEl.textContent || '[]') : []

const el = document.getElementById('select-account-app')
if (el) {
  createRoot(el).render(
    <StrictMode>
      <SelectAccount
        accounts={accounts}
        selectUrl={el.dataset.selectUrl || '/api/account/select/'}
      />
    </StrictMode>,
  )
}
