import type {SeriesEncoding} from './palette';

/**
 * One prop shape shared by every chart view, so a module can swap a line for
 * bars without rewriting its data plumbing.
 */
export interface Series<T> {
  key: Extract<keyof T, string>;
  label: string;
  /**
   * Override the auto-assigned gray. Use ONLY when the colour carries meaning
   * (over/under target, positive/negative delta) — never to separate series.
   */
  color?: string;
  /** The non-chromatic channel. Defaults by series position. */
  encoding?: SeriesEncoding;
  format?: (v: number) => string;
}

export interface ChartViewProps<T> {
  data: T[];
  xKey: Extract<keyof T, string>;
  series: Series<T>[];
  /** Workspace default 260; Loyaly AI column 180; sparkline 40. */
  height?: number | `${number}%`;
  yFormat?: (v: number) => string;
  xFormat?: (v: string | number) => string;
  reference?: {
    y: number;
    label: string;
    tone?: 'neutral' | 'positive' | 'negative';
  };
  /** Overridden to false by prefers-reduced-motion regardless of this value. */
  isAnimated?: boolean;
  /** Hide axes and grid — for dense small-multiples. */
  isBare?: boolean;
}
