import request from '@/utils/request'
import { AI_REQUEST_CONFIG, withAiRequestTimeout } from './aiRequest'

export type AiAnalysisType =
    | 'match'
    | 'match_full'
    | 'article'
    | 'post'
    | 'lottery'
    | 'lottery_module'
    | 'credibility'

export function requestAiAnalysis(data: Record<string, any> & { type: AiAnalysisType }) {
    return request.get(
        withAiRequestTimeout({ url: '/ai/analyze', data }),
        { ...AI_REQUEST_CONFIG, isAuth: true }
    )
}

/**
 * @description 赛事AI预测（完整）
 */
export function getMatchPredict(data: { match_id: number }) {
    return requestAiAnalysis({ type: 'match_full', ...data })
}

/**
 * @description 赛事AI预测 - 分段请求
 */
export function getMatchPredictSection(data: { match_id: number; section: string }) {
    return requestAiAnalysis({ type: 'match', ...data })
}

/**
 * @description 资讯AI分析
 */
export function getArticleAnalysis(data: { article_id: number }) {
    return requestAiAnalysis({ type: 'article', ...data })
}

/**
 * @description 查询比赛解锁状态
 */
export function checkAiUnlock(data: { match_id: number }) {
    return request.get({ url: '/ai/checkUnlock', data })
}

/**
 * @description 用户可信度分析
 */
export function getUserCredibility(data: { user_id: number }) {
    return requestAiAnalysis({ type: 'credibility', ...data })
}

/**
 * @description 彩票概率分析
 */
export function getLotteryAnalysis(data: { type: string }) {
    const { type, ...rest } = data
    return requestAiAnalysis({ type: 'lottery', code: type, ...rest })
}
