import React from 'react'
import {createRoot} from 'react-dom/client'
import './style.css'
import App from './App'
import { syncPortablePrefs } from './lib/uiPref'
import { I18nProvider } from './lib/i18n'

const container = document.getElementById('root')

const root = createRoot(container!)

// Pull portable UI prefs (DB → localStorage) before the first render so the
// app's synchronous reads see the values copied along with the data/ folder.
// Render regardless of the outcome so a backend hiccup never blocks startup.
syncPortablePrefs().finally(() => {
    root.render(
        <React.StrictMode>
            <I18nProvider>
                <App/>
            </I18nProvider>
        </React.StrictMode>
    )
})
