import './forceServerApi';
import React from 'react';
import ReactDOM from 'react-dom/client';
import { initStorage, refreshApiBaseFromStorage } from '@goldenchart/shared';
import { installDesktopBridge } from './bridge/installDesktopBridge';
import { ensureDesktopApiBase } from './ensureDesktopApiBase';
import { StartupUpdateGate } from './StartupUpdateGate';
import App from '@frontend/App';

installDesktopBridge();

async function bootstrap() {
  await initStorage();
  ensureDesktopApiBase();
  refreshApiBaseFromStorage();

  ReactDOM.createRoot(document.getElementById('root')!).render(
    <React.StrictMode>
      <StartupUpdateGate>
        <App />
      </StartupUpdateGate>
    </React.StrictMode>,
  );
}

void bootstrap();
