import { createApp } from 'vue'
import { createPinia } from 'pinia'
import VueKonva from 'vue-konva'
import '@/styles/global.scss'
import '@/styles/design-v2.scss'
import App from './App.vue'
import router from '@/router'

const app = createApp(App)
app.use(createPinia())
app.use(router)
app.use(VueKonva)
app.mount('#app')

// Register the PWA service worker. Done after mount so the SW
// register call doesn't block first paint. /sw.js (not /build/sw.js)
// so the SW's scope is "/" and covers the whole SPA.
if ('serviceWorker' in navigator) {
  window.addEventListener('load', () => {
    navigator.serviceWorker.register('/sw.js').catch(() => {
      // SW registration failure is non-fatal — PWA install just won't be
      // available, but the app still works.
    })
  })
}
