/**
 * 陪练功能类型定义
 */

// ==================== 枚举类型 ====================

/** 场景类型 */
export type SceneType = 'phone' | 'face' | 'complaint' | 'after-sales' | 'product-intro'

/** 难度等级 */
export type Difficulty = 'beginner' | 'junior' | 'intermediate' | 'senior' | 'expert'

/** 场景状态 */
export type SceneStatus = 'active' | 'inactive'

/** 聊天模式 */
export enum ChatModel {
  TEXT = 'text',
  VOICE = 'voice'
}

/** 连接状态 */
export enum ConnectionStatus {
  UNCONNECTED = 'unconnected',
  CONNECTING = 'connecting',
  CONNECTED = 'connected',
  DISCONNECTED = 'disconnected',
  ERROR = 'error',
  WAITING = 'waiting',
  LISTENING = 'listening'
}

// ==================== 数据模型 ====================

/** 陪练场景 */
export interface PracticeScene {
  id: number
  name: string
  description?: string
  type: SceneType
  difficulty: Difficulty
  status: SceneStatus
  background: string
  ai_role: string
  objectives: string[]
  keywords?: string[]
  duration: number
  usage_count: number
  rating: number
  created_by?: number
  updated_by?: number
  created_at: string
  updated_at: string
}

/** 消息对象 */
export interface Message {
  id: string
  role: 'user' | 'assistant'
  content: string
  timestamp: number
  loading?: boolean
  prologue?: boolean
}

/** Bot信息 */
export interface BotInfo {
  bot_id: string
  name: string
  description: string
  icon_url: string
  onboarding_info?: {
    prologue: string
    suggested_questions: string[]
  }
}

// ==================== 请求/响应 ====================

/** 获取场景列表请求参数 */
export interface GetScenesParams {
  page?: number
  size?: number
  type?: SceneType
  difficulty?: Difficulty
  search?: string
}

/** 开始陪练请求参数 */
export interface StartPracticeParams {
  scene_id?: number
  scene_name?: string
  scene_description?: string
  scene_background?: string
  scene_ai_role?: string
  scene_objectives?: string[]
  scene_keywords?: string[]
  user_message: string
  conversation_id?: string
  is_first: boolean
}

/** 中断对话请求参数 */
export interface InterruptPracticeParams {
  conversation_id: string
  chat_id: string
}

/** 分页响应 */
export interface PaginatedResponse<T> {
  items: T[]
  total: number
  page: number
  page_size: number
  pages: number
}

/** 统一响应格式 */
export interface ResponseModel<T = any> {
  code: number
  message: string
  data: T
  request_id?: string
}

// ==================== SSE事件 ====================

/** SSE事件类型 */
export type SSEEventType = 
  | 'conversation.chat.created'
  | 'message.delta'
  | 'message.completed'
  | 'conversation.completed'
  | 'error'
  | 'done'

/** SSE事件数据 */
export interface SSEEventData {
  conversation_id?: string
  chat_id?: string
  content?: string
  token_count?: number
  input_count?: number
  output_count?: number
  error?: string
}



