package app.closer.di

import android.content.Context
import app.closer.domain.repository.SettingsRepository
import app.closer.notifications.NotificationRateLimiter
import app.closer.notifications.PartnerNotificationManager
import app.closer.notifications.QuietHoursManager
import com.google.firebase.messaging.FirebaseMessaging
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object NotificationModule {

    @Provides
    @Singleton
    fun provideFirebaseMessaging(): FirebaseMessaging = FirebaseMessaging.getInstance()

    @Provides
    @Singleton
    fun provideQuietHoursManager(): QuietHoursManager = QuietHoursManager()

    @Provides
    @Singleton
    fun provideNotificationRateLimiter(
        @ApplicationContext context: Context
    ): NotificationRateLimiter = NotificationRateLimiter(context)

    @Provides
    @Singleton
    fun providePartnerNotificationManager(
        @ApplicationContext context: Context,
        settingsRepository: SettingsRepository,
        quietHoursManager: QuietHoursManager,
        rateLimiter: NotificationRateLimiter,
        activeThreadMonitor: app.closer.notifications.ActiveThreadMonitor
    ): PartnerNotificationManager = PartnerNotificationManager(
        context,
        settingsRepository,
        quietHoursManager,
        rateLimiter,
        activeThreadMonitor
    )
}
