import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import 'leaflet/dist/leaflet.css';
import './index.css';
import './rtl.css';
import { languageReady } from './i18n/i18n';
import App from './App.tsx';
import { ErrorBoundary } from './components/common/ErrorBoundary';
import { Tooltips } from './components/common/Tooltips';
import { installNumberFieldFixes } from './utils/numberFields';

// No "01000" in number fields: see utils/numberFields.ts.
installNumberFieldFixes();

// The first render waits for the saved language: a panel opened in Arabic
// has its dictionary before anything is drawn, instead of flashing English.
// English and Spanish resolve at once.
languageReady.then(() => {
  createRoot(document.getElementById('root')!).render(
    <StrictMode>
      <ErrorBoundary>
        <App />
      </ErrorBoundary>
      {/* Panel-wide tooltips: outside the app's error screen, with its own silent one. */}
      <Tooltips />
    </StrictMode>
  );
});
