import dayjs from 'dayjs';
import { ReactNode } from 'react';

export type TimeDimension = '月' | '季度' | '年';
export type AnalysisType = '岗位发布数量' | '招聘增长率';
export type QuarterFormat = `${number}-${'Q1'|'Q2'|'Q3'|'Q4'|'第一季度'|'第二季度'|'第三季度'|'第四季度'}`;
export type AnalysisCategory = 'industry' | 'area' | 'salary';
export type SalaryRange = '3k-5k' | '5k-8k' | '8k-10k' | '10k+';
export type WorkYearRange = '应届' | '1-3年' | '3-5年' | '5年以上';
export type EducationLevel = '大专' | '本科' | '硕士' | '博士' | '不限';
export interface IndustryDataItem {
  date: string;
  category: string;
  value: number;
}
export interface AreaDataItem {
  name: string;    
  value: number;   
  time: string;
}
export interface IndustryTrendParams {
  timeDimension: TimeDimension;
  type: AnalysisType;
  startTime: string;
  endTime: string;
  selectedIndustry: string;
}

export interface IndustryTrendState extends IndustryTrendParams {
  selectedWorkYearRange(): unknown;
  selectedIndustry: string;
}

export interface IndustryTrendApiResult {
  data: IndustryDataItem[];
  code: number;
  msg: string;
}

export interface TooltipItem {
  name: string;
  value: number;
  color: string;
  data: {
    date: string;
    category: string;
    value: number;
  };
}

export interface ChartConfig {
  data: IndustryDataItem[];
  height: number;
  xField: string;
  yField: string;
  seriesField: string;
  xAxis: {
    type: string;
    label: {
      formatter: (text: string) => string;
    };
  };
  yAxis: {
    label: {
      formatter: (val: string) => string;
    };
  };
  tooltip: {
    showTitle?: boolean;
    title?: string | ((title: string, data?: TooltipItem[]) => string); 
    customContent?: (title: string, items: TooltipItem[]) => ReactNode;
  };
  point: {
    size: number;
    shape: string;
  };
  animation: {
    appear: {
      animation: string;
      duration: number;
    };
  };
  smooth: boolean;
  interactions?: Array<{
    type: string;
    cfg: {
      render: (event: any, { title, items }: { title: string; items: TooltipItem[] }) => ReactNode;
    };
  }>;
  legend?: boolean;
}
export interface IndustryTrendState {
  timeDimension: TimeDimension;
  type: AnalysisType;
  startTime: string;
  endTime: string;
  selectedIndustry: string;
  selectedSalaryRange: string;
  analysisCategory: AnalysisCategory; // 新增分析类别
}
export type DateFormatter = (dateStr: string, dimension: TimeDimension) => string;
export type QuarterFormatter = (dateStr: string) => QuarterFormat;
export type ApiDataConverter = (apiData: any) => IndustryDataItem[];