import React from 'react'
import ReactDOM from 'react-dom/client'
import App from '@/App.jsx'
import '@/index.css'
import { initializeCapacitorPlugins, isIosPlatform } from '@/capacitor'

if (typeof document !== 'undefined' && isIosPlatform()) {
  document.documentElement.classList.add('ios');
}

ReactDOM.createRoot(document.getElementById('root')).render(
  <App />
)

if (typeof window !== 'undefined') {
  requestAnimationFrame(() => {
    setTimeout(async () => {
      try {
        const { splashScreen } = (await initializeCapacitorPlugins()) || {};
        await splashScreen?.hide();
      } catch {
        // Ignore splash errors on web or unsupported native states.
      }
    }, 50);
  });
}
