export type ExpandStrategy = 'brave' | 'llm' | 'hybrid'

export interface ResearchItemData {
  title?: string
  url?: string
  snippet?: string
  query?: string
}

export interface ResearchMapData {
  audience_summary?: string
  content_goal?: string
  questions?: string[]
  pillars?: string[]
  exclusions?: string[]
  research_items?: ResearchItemData[]
  expand_strategy?: ExpandStrategy | string
  patrol_keywords?: string[]
}

export interface BrandProductData {
  id: string
  label: string
  product_context: string
  match_tags?: string[]
  create_at: number
  update_at: number
}

export interface BrandData {
  id: string
  display_name?: string
  topic_name?: string
  seed_query?: string
  brief?: string
  product_brief?: string
  product_context?: string
  product_id?: string
  products?: BrandProductData[]
  target_audience?: string
  goals?: string
  research_map?: ResearchMapData
  create_at: number
  update_at: number
}

export interface ListBrandProductsData {
  list: BrandProductData[]
}

export interface ListBrandsData {
  list: BrandData[]
}

export interface CreatePlacementTopicData {
  brand: BrandData
  job_id: string
  status: string
  message?: string
}

export function hasResearchMap(brand: BrandData | null | undefined): boolean {
  const map = brand?.research_map
  return !!(
    map?.audience_summary ||
    (map?.questions?.length ?? 0) > 0 ||
    (map?.research_items?.length ?? 0) > 0
  )
}