import type { AIDecisionProgress, AIMove } from './ai';
import type { CardInferenceSnapshot } from './card-inference';
import type { CardTrackerSnapshot } from './card-tracker';
import type { Difficulty, GameState, PlayerIndex } from './types';

export interface AIWorkerChooseMoveRequest {
  type: 'choose-move';
  requestId: string;
  state: GameState;
  playerIdx: PlayerIndex;
  difficulty: Difficulty;
  trackerSnapshot: CardTrackerSnapshot | null;
  inferenceSnapshot: CardInferenceSnapshot | null;
}

export interface AIWorkerProgressMessage {
  type: 'progress';
  requestId: string;
  progress: AIDecisionProgress;
}

export interface AIWorkerResultMessage {
  type: 'result';
  requestId: string;
  move: AIMove;
}

export interface AIWorkerSerializedError {
  message: string;
  name: string;
  stack?: string;
}

export interface AIWorkerErrorMessage {
  type: 'error';
  requestId: string;
  error: AIWorkerSerializedError;
}

export type AIWorkerRequestMessage = AIWorkerChooseMoveRequest;

export type AIWorkerResponseMessage =
  | AIWorkerProgressMessage
  | AIWorkerResultMessage
  | AIWorkerErrorMessage;