import Foundation

/// Manual dependency container (no third-party DI). Wires the session, API client, and
/// repositories once, from the app entry point.
final class AppContainer {
    let session = SessionStore()
    private let config = APIConfig.local
    private lazy var client: APIClient = {
        let c = APIClient(session: session)
        // The client needs to know where to refresh; it is built before the repositories that
        // otherwise carry the config.
        c.authBaseURL = config.auth
        return c
    }()

    lazy var authRepository = AuthRepository(client: client, session: session, config: config)
    lazy var rideRepository = RideRepository(client: client, config: config)
    lazy var walletRepository = WalletRepository(client: client, session: session, config: config)
    lazy var zoneRepository = ZoneRepository(client: client, config: config)
    lazy var legalRepository = LegalRepository(client: client, config: config)

    /// One answer to "where is the rider", shared by the map and the view models.
    let location = LocationProvider()

    /// Provider port for the end-of-ride parking photo  stubbed until storage is wired.
    lazy var photoUploader: PhotoUploader = StubPhotoUploader()
}
