package dev.ulfrx.recipe.auth

import dev.ulfrx.recipe.ui.screens.auth.LoginViewModel
import dev.ulfrx.recipe.ui.screens.auth.PostLoginViewModel
import io.ktor.client.HttpClient
import org.koin.dsl.module
import org.koin.plugin.module.dsl.viewModel

val authModule =
    module {
        single<SecureAuthStateStore> { SecureAuthStateStore(get()) }
        single<OidcClient> { OidcClient(get()) }
        single<AuthSession> {
            AuthSession(
                oidcClient = get<OidcClient>(),
                store = get<SecureAuthStateStore>(),
            )
        }
        single<HttpClient> { AuthHttpClient.create(get()) }

        // Phase 2 auth-gate ViewModels (02-07). Registered here so the same module that
        // owns AuthSession also owns its UI consumers; Koin scopes them per Composable.
        viewModel<LoginViewModel>()
        viewModel<PostLoginViewModel>()
    }
