package com.remax.visualnovel.ui.main

/**
 * Created by HJW on 2025/7/14
 */
import androidx.lifecycle.viewModelScope
import com.remax.visualnovel.app.viewmodel.base.UserViewModel
import com.remax.visualnovel.entity.response.AIDict
import com.remax.visualnovel.repository.api.DictRepository
import com.remax.visualnovel.utils.TimeUtils
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.asSharedFlow
import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class MainViewModel @Inject constructor(private val dictRepository: DictRepository) : UserViewModel() {

    var aiDict: AIDict? = null
        private set

    private val _aiDictFlow = MutableSharedFlow<Boolean>()
    val aiDictFlow = _aiDictFlow.asSharedFlow()

    /*suspend fun getAllRole(sendFlow: Boolean = false) = dictRepository.getAIDict().transformResult({
        aiDict = it
        if (sendFlow) {
            _aiDictFlow.emit(true)
        }
    })*/

    var canBack = false
    fun startCanBackTimer() {
        viewModelScope.launch {
            canBack = true
            delay(TimeUtils.ONE_SECOND * 3)
            canBack = false
        }
    }
}
