export type DataSourceType = 'api' | 'dataSource' | 'static' | 'upload';

export interface FieldMapping {
  source: string;
  target: string;
}

export interface ParamBinding {
  paramName: string;
  globalKey: string;
}

export interface DataSourceConfig {
  type: DataSourceType;
  dataSourceCode?: string;
  apiUrl?: string;
  apiMethod?: 'GET' | 'POST';
  apiHeaders?: Record<string, string>;
  apiParams?: Record<string, any>;
  apiBody?: Record<string, any>;
  dataPath?: string;
  fieldMappings?: FieldMapping[];
  paramBindings?: ParamBinding[];
  refreshInterval?: number;
  refreshEnabled?: boolean;
}

export type WidgetType =
  | 'announcement-list'
  | 'approval-center'
  | 'calendar'
  | 'chart-area'
  | 'chart-bar'
  | 'chart-funnel'
  | 'chart-gauge'
  | 'chart-heatmap'
  | 'chart-kline'
  | 'chart-line'
  | 'chart-pie'
  | 'chart-radar'
  | 'chart-ring'
  | 'chart-sankey'
  | 'chart-scatter'
  | 'clock'
  | 'countdown'
  | 'data-table'
  | 'filter-date'
  | 'filter-date-range'
  | 'filter-input'
  | 'filter-select'
  | 'form-render'
  | 'iframe'
  | 'image'
  | 'image-carousel'
  | 'my-apps'
  | 'notice-list'
  | 'progress-card'
  | 'quick-links'
  | 'ranking-list'
  | 'server-monitor'
  | 'stat-card'
  | 'todo-list'
  | 'video-player'
  | 'weather'
  | 'welcome-card';

export interface WidgetStyle {
  backgroundColor?: string;
  backgroundImage?: string;
  backgroundSize?: 'auto' | 'contain' | 'cover';
  borderWidth?: number;
  borderColor?: string;
  borderStyle?: 'dashed' | 'dotted' | 'none' | 'solid';
  borderRadius?: number;
  shadowEnabled?: boolean;
  shadowColor?: string;
  shadowBlur?: number;
  shadowOffsetX?: number;
  shadowOffsetY?: number;
  padding?: number;
  titleShow?: boolean;
  titleFontSize?: number;
  titleColor?: string;
  titleAlign?: 'center' | 'left' | 'right';
  titleFontWeight?: 'bold' | 'normal';
}

export interface DashboardWidget {
  id: string;
  type: WidgetType;
  i: string;
  x: number;
  y: number;
  w: number;
  h: number;
  minW?: number;
  minH?: number;
  maxW?: number;
  maxH?: number;
  title?: string;
  props: Record<string, any>;
  style?: WidgetStyle;
  dataSource?: DataSourceConfig;
}

export interface DashboardConfig {
  id: string;
  name: string;
  columns: number;
  rowHeight: number;
  margin: [number, number];
  backgroundColor?: string;
  showOuterMargin?: boolean;
  widgets: DashboardWidget[];
}
