import { StrictMode } from 'react' import { createRoot } from 'react-dom/client' import '@xenia/ui/styles.css' // shared --x-* tokens (the waiter's --bg/--text… are made of them, 4.6) + the .x-* components (4.8) import './index.css' // The theme before anything renders (no light flash on a dark phone): the user's light/dark // (themeStore, default dark) and the waiter's default accent until bootstrap says the venue's. try { const saved = JSON.parse(localStorage.getItem('pos-theme') || 'null') document.documentElement.setAttribute('data-theme', saved?.state?.dark === false ? 'light' : 'dark') } catch { document.documentElement.setAttribute('data-theme', 'dark') } document.documentElement.setAttribute('data-venue-theme', 'amber') 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( , ) })