export type BasketItemType = 'document' | 'snippet' | 'answer' | 'matter' | 'theme'

export type BasketSelectedFrom =
  | 'search'
  | 'detail'
  | 'qa'
  | 'graph'
  | 'matter'
  | 'topic'
  | 'admin'
  | 'mock'
  | 'research'

export type BasketImportance = 'core' | 'reference'

export interface BasketItemBase {
  item_type: BasketItemType
  title: string
  selected_from: BasketSelectedFrom
  importance: BasketImportance
  note?: string
  added_at: number
  doc_code?: string
  knowledge_category?: string
}

export interface BasketDocumentItem extends BasketItemBase {
  item_type: 'document'
  doc_id: string
  content_hash?: string
}

export interface BasketSnippetItem extends BasketItemBase {
  item_type: 'snippet'
  doc_id: string
  content_hash?: string
  snippet: string
}

export interface BasketAnswerReference {
  doc_id: string
  title: string
  doc_number?: string
}

export interface BasketAnswerItem extends BasketItemBase {
  item_type: 'answer'
  answer: string
  question?: string
  references?: BasketAnswerReference[]
}

export interface BasketMatterItem extends BasketItemBase {
  item_type: 'matter'
  matter_id: string
  governing_doc_ids?: string[]
}

export interface BasketThemeItem extends BasketItemBase {
  item_type: 'theme'
  theme_name: string
  doc_count?: number
  matter_count?: number
}

export type BasketItem =
  | BasketDocumentItem
  | BasketSnippetItem
  | BasketAnswerItem
  | BasketMatterItem
  | BasketThemeItem