import type { MetadataPayload } from '@/types/metadata'

export interface IntentRule {
  id: string
  name: string
  keywords: string[]
  patterns: string[]
  response_type: 'fixed' | 'rag' | 'flow' | 'transfer'
  priority: number
  fixed_reply?: string
  target_kb_ids?: string[]
  flow_id?: string
  transfer_message?: string
  hit_count: number
  is_enabled: boolean
  metadata?: MetadataPayload
  created_at: string
  updated_at: string
}

export interface IntentRuleCreate {
  name: string
  keywords?: string[]
  patterns?: string[]
  response_type: 'fixed' | 'rag' | 'flow' | 'transfer'
  priority: number
  fixed_reply?: string
  target_kb_ids?: string[]
  flow_id?: string
  transfer_message?: string
  is_enabled?: boolean
  metadata?: MetadataPayload
}

export interface IntentRuleUpdate {
  name?: string
  keywords?: string[]
  patterns?: string[]
  response_type?: 'fixed' | 'rag' | 'flow' | 'transfer'
  priority?: number
  fixed_reply?: string
  target_kb_ids?: string[]
  flow_id?: string
  transfer_message?: string
  is_enabled?: boolean
  metadata?: MetadataPayload
}

export interface IntentRuleListResponse {
  data: IntentRule[]
}

export const RESPONSE_TYPE_OPTIONS = [
  { value: 'fixed', label: '固定回复', color: 'primary' },
  { value: 'rag', label: '知识库检索', color: 'success' },
  { value: 'flow', label: '话术流程', color: 'warning' },
  { value: 'transfer', label: '转人工', color: 'danger' }
]

export const RESPONSE_TYPE_MAP: Record<string, { label: string; color: string }> = {
  fixed: { label: '固定回复', color: 'primary' },
  rag: { label: '知识库检索', color: 'success' },
  flow: { label: '话术流程', color: 'warning' },
  transfer: { label: '转人工', color: 'danger' }
}
