package com.atmob.keyboard_android.mvvm.repository

import com.atmob.keyboard_android.mvvm.base.BaseRepository
import com.atmob.keyboard_android.util.bridge.FlutterBridgeManager
import com.atmob.keyboard_android.util.bridge.model.base.EmptyResp
import com.atmob.keyboard_android.util.bridge.model.req.SuperReplyReq
import com.atmob.keyboard_android.util.bridge.model.req.SuperSpeakReq
import com.atmob.keyboard_android.util.bridge.model.resp.CharacterListResp
import com.atmob.keyboard_android.util.bridge.model.resp.KeyboardInfo
import com.atmob.keyboard_android.util.bridge.model.resp.KeyboardListResp
import com.atmob.keyboard_android.util.bridge.model.resp.PrologueListResp
import com.atmob.keyboard_android.util.bridge.model.resp.PrologueResp
import com.atmob.keyboard_android.util.bridge.model.resp.SuperReplyResp
import com.atmob.keyboard_android.util.bridge.model.resp.SuperSpeakResp

/**
 * 键盘Repository
 */
class KeyboardRepository : BaseRepository() {
    /**
     * 用户是否已登录
     */
    fun isLogin(
        onSuccess: (resultObj: Boolean) -> Unit,
        onFail: (errorCode: Int, errorMsg: String) -> Unit
    ) {
        FlutterBridgeManager.isLogin(onSuccess, onFail)
    }

    /**
     * 用户是否为VIP
     */
    fun isMember(
        onSuccess: (resultObj: Boolean) -> Unit,
        onFail: (errorCode: Int, errorMsg: String) -> Unit
    ) {
        FlutterBridgeManager.isMember(onSuccess, onFail)
    }

    /**
     * 获取键盘列表
     */
    fun getKeyboardList(
        onSuccess: (resultObj: KeyboardListResp) -> Unit,
        onFail: (errorCode: Int, errorMsg: String) -> Unit
    ) {
        FlutterBridgeManager.getKeyboardList(onSuccess, onFail)
    }

    /**
     * 选择键盘
     */
    fun selectedKeyboard(
        keyboardId: String,
        onSuccess: (resultObj: EmptyResp) -> Unit,
        onFail: (errorCode: Int, errorMsg: String) -> Unit
    ) {
        FlutterBridgeManager.selectedKeyboard(
            keyboardId,
            onSuccess,
            onFail
        )
    }

    /**
     * 获取当前键盘信息
     */
    fun getCurrentKeyboardInfo(
        onSuccess: (resultObj: KeyboardInfo) -> Unit,
        onFail: (errorCode: Int, errorMsg: String) -> Unit
    ) {
        FlutterBridgeManager.getCurrentKeyboardInfo(onSuccess, onFail)
    }

    /**
     * 获取人设列表
     */
    fun getCharacterList(
        keyboardId: String,
        onSuccess: (CharacterListResp) -> Unit,
        onFail: (errorCode: Int, errorMsg: String) -> Unit
    ) {
        FlutterBridgeManager.getCharacterList(keyboardId, onSuccess, onFail)
    }

    /**
     * 获取开场白列表
     */
    fun getPrologueList(
        onSuccess: (PrologueListResp) -> Unit,
        onFail: (errorCode: Int, errorMsg: String) -> Unit
    ) {
        FlutterBridgeManager.getPrologueList(onSuccess, onFail)
    }

    /**
     * AI聊天-超会回（帮聊）
     */
    fun chatSuperReply(
        req: SuperReplyReq,
        onSuccess: (SuperReplyResp) -> Unit,
        onFail: (errorCode: Int, errorMsg: String) -> Unit
    ) {
        FlutterBridgeManager.chatSuperReply(req, onSuccess, onFail)
    }

    /**
     * AI聊天-超会说（教你说）
     */
    fun chatSuperSpeak(
        req: SuperSpeakReq,
        onSuccess: (SuperSpeakResp) -> Unit,
        onFail: (errorCode: Int, errorMsg: String) -> Unit
    ) {
        FlutterBridgeManager.chatSuperSpeak(req, onSuccess, onFail)
    }

    /**
     * AI聊天-开场白
     */
    fun chatPrologue(
        name: String,
        onSuccess: (PrologueResp) -> Unit,
        onFail: (errorCode: Int, errorMsg: String) -> Unit
    ) {
        FlutterBridgeManager.chatPrologue(name, onSuccess, onFail)
    }
}