import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import router from './router/index.ts'
import { initializeAuthRefresh } from './api/client.ts'
import { useAuthStore } from './stores/auth.ts'
import './assets/main.css'

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

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

initializeAuthRefresh()

const auth = useAuthStore()
if (auth.isAuthenticated) {
  void auth.fetchCurrentUser()
}

app.mount('#app')