import type React from 'react';
import { WorkflowFile } from '../../../hooks/usePlayground';

/**
 * Document interface representing file attachments in messages
 */
export interface MessageDocument {
  id: string;
  messageId: string;
  fileId: string;
  fileName: string;
  fileSize: number;
  mimeType: string;
  roundNumber: number;
  taskNumber: number;
  actionNumber: number;
  actionId: string;
}

/**
 * Message interface matching the API response structure
 */
export interface Message {
  id: string;
  workflowId: string;
  parentMessageId?: string;
  documents?: MessageDocument[];
  documentsLabel?: string;
  message?: string;
  summary?: string;
  role?: string;
  status?: string;
  sequenceNr?: number;
  publishedAt?: number;
  success?: boolean;
  actionId?: string;
  actionMethod?: string;
  actionName?: string;
  roundNumber?: number;
  taskNumber?: number;
  actionNumber?: number;
  taskProgress?: string;
  actionProgress?: string;
}

/**
 * Message display variant
 */
export type MessageVariant = 'chat' | 'log';

/**
 * Props for the Messages component
 */
export interface MessagesProps {
  /**
   * Array of messages to display
   */
  messages: Message[];
  
  /**
   * Display variant: 'chat' for bubble UI, 'log' for list/table UI
   * @default 'chat'
   */
  variant?: MessageVariant;
  
  /**
   * Optional className for custom styling
   */
  className?: string;
  
  /**
   * Whether to show document attachments
   * @default true
   */
  showDocuments?: boolean;
  
  /**
   * Whether to show metadata (role, status, timestamps)
   * @default true
   */
  showMetadata?: boolean;
  
  /**
   * Whether to show progress indicators
   * @default true
   */
  showProgress?: boolean;
  
  /**
   * Custom render function for message content
   * If provided, this will be used instead of the default rendering
   */
  renderMessage?: (message: Message, index: number) => React.ReactNode;
  
  /**
   * Custom render function for documents
   * If provided, this will be used instead of the default document rendering
   */
  renderDocument?: (document: MessageDocument, message: Message) => React.ReactNode;
  
  /**
   * Empty state message when no messages are present
   * @default "No messages yet"
   */
  emptyMessage?: string;
  
  /**
   * File operation handlers for documents in messages
   */
  onFileDelete?: (file: WorkflowFile) => Promise<void>;
  onFileRemove?: (file: WorkflowFile) => Promise<void>;
  onFileView?: (file: WorkflowFile) => Promise<void>;
  onFileDownload?: (file: WorkflowFile) => Promise<void>;
  deletingFiles?: Set<string>;
  previewingFiles?: Set<string>;
  removingFiles?: Set<string>;
  downloadingFiles?: Set<string>;
  workflowId?: string;
}

