/**
 * 章节类型
 */
export enum ChapterType {
  BACKGROUND = 'BACKGROUND',
  RESEARCH_STATUS = 'RESEARCH_STATUS',
  RESEARCH = 'RESEARCH',
  INNOVATION = 'INNOVATION',
  SOLVE_PROBLEM = 'SOLVE_PROBLEM',
  SOLUTION = 'SOLUTION',
  USER_DEFINED = 'USER_DEFINED',
  PROGRESS = 'PROGRESS',
  BUDGET = 'BUDGET',
  MARKET = 'MARKET',
  BENEFIT_ANALYSIS = 'BENEFIT_ANALYSIS',
  RISK = 'RISK',
  UNKNOWN = 'UNKNOWN',
}

export const ChapterTypeLabels = [
  {
    key: ChapterType.BACKGROUND,
    label: '立项背景与意义'
  },
  {
    key: ChapterType.RESEARCH_STATUS,
    label: '国内外研究现状与发展趋势'
  },
  {
    key: ChapterType.RESEARCH,
    label: '项目主要研究内容'
  },
  {
    key: ChapterType.INNOVATION,
    label: '关键技术与创新点'
  },
  {
    key: ChapterType.SOLVE_PROBLEM,
    label: '拟解决的关键问题'
  },
  {
    key: ChapterType.SOLUTION,
    label: '实施方案及进度安排'
  },
  // {
  //   key: ChapterType.PROGRESS,
  //   label: '进度安排、计划内容'
  // },
  {
    key: ChapterType.BUDGET,
    label: '经费预算'
  },
  // {
  //   key: ChapterType.MARKET,
  //   label: '应用或产业化前景与市场需求分析'
  // },
  {
    key: ChapterType.BENEFIT_ANALYSIS,
    label: '经济及社会效益分析'
  },
  {
    key: ChapterType.RISK,
    label: '项目风险分析和对策'
  },
  {
    key: ChapterType.USER_DEFINED,
    label: '自定义章节'
  },
]

export const ChapterTypeKeywords = [
  {
    key: ChapterType.BACKGROUND,
    keywords: ['必要性'],
  },
  {
    key: ChapterType.RESEARCH_STATUS,
    keywords: ['研究现状', '发展趋势'],
  },
  {
    key: ChapterType.RESEARCH,
    keywords: ['技术特点', '技术研究', '实际应用'],
  },
  {
    key: ChapterType.INNOVATION,
    keywords: ['关键技术', '创新点'],
  },
  {
    key: ChapterType.SOLVE_PROBLEM,
    keywords: ['解决的问题', '解决的关键问题'],
  },
  {
    key: ChapterType.SOLUTION,
    keywords: ['实施方案'],
  },
  // {
  //   key: ChapterType.PROGRESS,
  //   keywords: [],
  // },
  {
    key: ChapterType.BUDGET,
    keywords: [],
  },
  // {
  //   key: ChapterType.MARKET,
  //   keywords: [],
  // },
  {
    key: ChapterType.BENEFIT_ANALYSIS,
    keywords: ['经济效益', '社会效益', '经济效益分析', '社会效益分析'],
  },
  {
    key: ChapterType.RISK,
    keywords: ['风险分析', '风险对策'],
  },
  {
    key: ChapterType.USER_DEFINED,
    keywords: []
  },
]

export interface SelectedChapterType {
  type: ChapterType;
  keywords: string[];
}

export interface ReportCreateRequest {
  templateId: number | null;
}

export interface ReportMetadataItem {
  name: string;
  value: string;
  type: 'text' | 'date' | 'dateRange';
}

export interface Chapter {
  title: string;
  fullTitle?: string;
  content: string;
  chapterType: ChapterType;
  keywords: string[]
}

export interface ReportChapterRequest extends Chapter {
  id: number;
}

export interface ReportBasic {
  id: number;
  companyId: number;
  companyName?: string;
  name: string;
  logoPath: string;
  keywords: string;
  reportName: string;
  supervisor: string;
  metadata: ReportMetadataItem[];
  userId: number;
  createAt?: string;
  updateAt?: string;
  status:number
}

export interface ReportSaveRequest extends ReportBasic {
    chapters: ReportChapterRequest[];
}

export interface ReportsResponse {
  total: number;
  reports: ReportBasic[];
}

export interface ReportTemplateSave {
  id: number;
  companyId: number;
  name: string;
  reportName: string;
  logoPath: string;
  metadata: ReportMetadataItem[];
  chapters: Chapter[];
  tags: string[];
  createAt?: string;
  updateAt?: string;
}

export interface ReportTemplatesResponse {
  total: number;
  items: ReportTemplateSave[];
}

export interface Logo {
  name: string;
  url: string;
}

export interface DuplicateCheckRequest{
  from?: number;
  size?: number;
  reportId: string;
  similarity?: string;
  contents: string[];
}

export interface DuplicateCheckResponse{
  repetitiveRate: number[];
}
