import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import router from './router'
import { i18n } from './i18n'
import './assets/index.css'
import { registerSW } from 'virtual:pwa-register'
import 'vue-sonner/style.css'

const app = createApp(App)
const pinia = createPinia()

app.use(router)
app.use(i18n)
app.use(pinia)

// Simple periodic service worker updates
const intervalMS = 60 * 60 * 1000 // 1 hour
registerSW({
  onRegistered(r) {
    r && setInterval(() => {
      r.update()
    }, intervalMS)
  },
  onOfflineReady() {
    console.log('App ready to work offline')
  }
})

app.mount('#app')
