/**
 * 品牌相关类型定义
 */

// 查询频率枚举
export type QueryFrequency = "daily" | "weekly" | "monthly";

// 品牌状态枚举
export type BrandStatus = "active" | "inactive" | "pending";

// 平台评分
export interface PlatformScore {
  overall: number;
  [platform: string]: number;
}

// 竞品信息
export interface Competitor {
  id: string;
  name: string;
  aliases: string[];
  score: number;
  last_queried_at: string | null;
}

// 品牌列表项
export interface BrandListItem {
  id: string;
  name: string;
  aliases: string[];
  platforms: string[];
  frequency: QueryFrequency;
  status: BrandStatus;
  score: number | null;
  last_queried_at: string | null;
  next_query_at: string | null;
  created_at: string;
}

// 品牌详情
export interface BrandDetail {
  id: string;
  name: string;
  aliases: string[];
  platforms: string[];
  frequency: QueryFrequency;
  status: BrandStatus;
  score: PlatformScore | null;
  last_queried_at: string | null;
  next_query_at: string | null;
  created_at: string;
  website: string | null;
  industry: string | null;
  competitors: Competitor[];
}

// 创建品牌请求
export interface CreateBrandRequest {
  name: string;
  aliases?: string[];
  website?: string;
  industry?: string;
  platforms: string[];
  frequency: QueryFrequency;
}

// 更新品牌请求
export interface UpdateBrandRequest {
  aliases?: string[];
  website?: string;
  industry?: string;
  platforms?: string[];
  frequency?: QueryFrequency;
}

// 品牌列表响应
export interface BrandListResponse {
  items: BrandListItem[];
  total: number;
}

// 维度对比项
export interface DimensionCompareItem {
  name: string;
  score: number;
  max_score: number;
  percentage: number;
  trend: "up" | "down" | "stable";
  trend_value: number;
}

// 对比项
export interface CompareItem {
  entity_id: string;
  entity_name: string;
  entity_type: "brand" | "competitor";
  mention_rate_score: number;
  sov_score: number;
  quality_score: number;
  overall_score: number;
  citation_count: number;
  // V2 多维度对比
  dimensions: DimensionCompareItem[];
  // 趋势
  overall_trend: "up" | "down" | "stable";
  overall_trend_value: number;
}

// 竞品对比响应
export interface CompareResponse {
  brand_id: string;
  brand_name: string;
  items: CompareItem[];
  // 雷达图数据
  radar_data: RadarDataItem[];
}

// 雷达图数据项
export interface RadarDataItem {
  dimension: string;
  label: string;
  [brandName: string]: string | number;
}

// 竞品列表响应
export interface CompetitorListResponse {
  items: Competitor[];
  total: number;
}

// 创建竞品请求
export interface CreateCompetitorRequest {
  name: string;
  aliases?: string[];
}

// 竞品推荐项
export interface CompetitorRecommendationItem {
  name: string;
  reason: string;
  industry: string | null;
}

// 竞品推荐响应
export interface CompetitorRecommendationResponse {
  brand_name: string;
  industry: string | null;
  recommendations: CompetitorRecommendationItem[];
}

// 立即查询请求
export interface QueryNowRequest {
  platforms?: string[];
}

// 立即查询响应
export interface QueryNowResponse {
  task_id: string;
  status: string;
  message: string;
}

// 频率选项
export const FREQUENCY_OPTIONS = [
  { value: "daily", label: "每日" },
  { value: "weekly", label: "每周" },
  { value: "monthly", label: "每月" },
] as const;

// 行业选项
export const INDUSTRY_OPTIONS = [
  { value: "technology", label: "科技" },
  { value: "finance", label: "金融" },
  { value: "retail", label: "零售" },
  { value: "healthcare", label: "医疗健康" },
  { value: "education", label: "教育" },
  { value: "manufacturing", label: "制造业" },
  { value: "entertainment", label: "娱乐" },
  { value: "travel", label: "旅游" },
  { value: "food", label: "餐饮" },
  { value: "automotive", label: "汽车" },
  { value: "real_estate", label: "房地产" },
  { value: "other", label: "其他" },
] as const;
