import "@fontsource/inter";
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.tsx'
import './index.css'
import { registerSW } from 'virtual:pwa-register'
import { ThemeProvider } from '@emotion/react'
import { createTheme } from '@mui/material'
import { ruRU } from '@mui/material/locale'
import { usePrefStore } from "./store/preferences.ts";

const theme = createTheme(
  {
    typography: {
      fontFamily: [
        'Inter'
      ].join(',')
    },
    components: {
      MuiButtonBase: {
        defaultProps: {
          //disableRipple: true,
        }
      },
      MuiButtonGroup: {
        defaultProps: {
          //disableRipple: true,
        }
      }
    },
    palette: {
      primary: { main: '#1976d2' },
    },
  },
  ruRU,
);

const updateSW = registerSW({
  onNeedRefresh() {
    if (confirm("New content available. Reload?")) {
      updateSW(true);
    }
  },
  onOfflineReady() {
    console.log("offline ready");
  },
});

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
  <React.StrictMode>
    <ThemeProvider theme={theme}>
      <App />
    </ThemeProvider>
  </React.StrictMode>,
)
