import { createApp } from 'vue'
import { createPinia } from 'pinia'
import 'ant-design-vue/dist/reset.css'
import './styles'
import App from './App.vue'
import router from './router'
import { useAuthStore } from './stores/auth'

const app = createApp(App)
const pinia = createPinia()
app.use(pinia)
app.use(router)

// Kick off the cold-start auth probe BEFORE mount so that
// ``router.beforeEach`` can ``await authStore.waitForStartup()`` instead
// of seeing ``startupState === 'pending'`` and redirecting to /login.
// (Tauri reload bug: the guard ran before App.vue::onMounted had a
// chance to call startupCheck, so every reload bounced to /login.)
const authStore = useAuthStore(pinia)
authStore.beginStartup()

app.mount('#app')
