/**
 * ML Overlay Types
 * Type definitions for ML predictions overlays on trading charts
 */

// ============================================================================
// ML Prediction Types
// ============================================================================

export type PredictionType = 'buy' | 'sell' | 'neutral';

export interface MLPrediction {
  timestamp: number;
  price: number;
  confidence: number;
  type: PredictionType;
}

// ============================================================================
// Signal Marker Types
// ============================================================================

export type MarkerPosition = 'aboveBar' | 'belowBar';
export type MarkerShape = 'arrowUp' | 'arrowDown' | 'circle';

export interface SignalMarker {
  time: number;
  position: MarkerPosition;
  color: string;
  text: string;
  shape: MarkerShape;
}

// ============================================================================
// ICT Concept Types
// ============================================================================

export type ICTConceptType = 'OrderBlock' | 'FVG' | 'Liquidity';

export interface ICTConcept {
  type: ICTConceptType;
  timeStart: number;
  timeEnd: number;
  priceTop: number;
  priceBottom: number;
}

// ============================================================================
// AMD Zone Types
// ============================================================================

export type AMDPhaseType = 'accumulation' | 'manipulation' | 'distribution' | 'unknown';

export interface AMDZone {
  phase: AMDPhaseType;
  startTime: number;
  endTime: number;
  priceHigh: number;
  priceLow: number;
  confidence: number;
}

export interface AMDZoneColors {
  accumulation: string;
  manipulation: string;
  distribution: string;
  unknown: string;
}

export const DEFAULT_AMD_COLORS: AMDZoneColors = {
  accumulation: 'rgba(59, 130, 246, 0.15)',   // Blue - calm, building
  manipulation: 'rgba(249, 115, 22, 0.15)',   // Orange - caution, volatility
  distribution: 'rgba(239, 68, 68, 0.15)',    // Red - selling pressure
  unknown: 'rgba(107, 114, 128, 0.1)',        // Gray - uncertain
};

// ============================================================================
// Overlay Configuration Types
// ============================================================================

export interface MLOverlayConfig {
  showPredictions: boolean;
  showSignals: boolean;
  showICTConcepts: boolean;
  predictionLineColor: string;
  predictionLineWidth: number;
  signalColors: {
    buy: string;
    sell: string;
  };
  ictColors: {
    OrderBlock: string;
    FVG: string;
    Liquidity: string;
  };
}

export const DEFAULT_OVERLAY_CONFIG: MLOverlayConfig = {
  showPredictions: true,
  showSignals: true,
  showICTConcepts: true,
  predictionLineColor: '#3b82f6',
  predictionLineWidth: 2,
  signalColors: {
    buy: '#10b981',
    sell: '#ef4444',
  },
  ictColors: {
    OrderBlock: '#3b82f6',
    FVG: '#fbbf24',
    Liquidity: '#f97316',
  },
};

// ============================================================================
// API Response Types
// ============================================================================

export interface MLPredictionResponse {
  symbol: string;
  timeframe: string;
  predictions: MLPrediction[];
  signals: SignalMarker[];
  ictConcepts: ICTConcept[];
  generatedAt: string;
}

export interface MLOverlayData {
  predictions: MLPrediction[];
  signals: SignalMarker[];
  ictConcepts: ICTConcept[];
  isLoading: boolean;
  error: string | null;
  lastUpdated: string | null;
}
