import { StrictMode } from 'react' import { createRoot } from 'react-dom/client' import '@xenia/ui/tokens.css' // shared --x-* tokens; the waiter's own --bg/--text… stay as they are import './index.css' import App from './App.jsx' import db from './db/posdb.js' import { deliveryMode, getActiveVenue } from './config/server' // Ensure the IndexedDB schema is fully open before any component mounts. // Without this, table accessors (db.tables, db.orders, etc.) can be undefined // when components try to use them synchronously on first render. // // Native app before pairing: there is no venue yet, so don't create a database // under the wrong (un-namespaced) name — App renders only the pairing screen. const native = deliveryMode() === 'native' if (native) { import('./native/backButton').then(m => m.installBackButtonHandler()) } // Native: hand the paired venues' TLS key pins to the WebView before any request const trust = native ? import('./native/tls').then(m => m.syncTrustedKeys()) : Promise.resolve() const ready = trust.then(() => (native && !getActiveVenue() ? null : db.open())) ready.catch(err => console.error('[IDB] open failed:', err)).finally(() => { createRoot(document.getElementById('root')).render( , ) })