import React from 'react';
import { SxProps, Theme } from '@mui/material';

import { BackstoryElementProps } from './BackstoryTab';
import { ChatMessage, ChatQuery, ChatMessageMetaData } from 'types/types';

const defaultMessage: ChatMessage = {
  status: 'done',
  type: 'text',
  sessionId: '',
  timestamp: new Date(),
  content: '',
  role: 'assistant',
  metadata: null as unknown as ChatMessageMetaData,
};

type ConversationMode = 'chat' | 'job_description' | 'resume' | 'fact_check' | 'persona';

interface ConversationHandle {
  submitQuery: (query: ChatQuery) => void;
  fetchHistory: () => void;
}

interface ConversationProps extends BackstoryElementProps {
  className?: string; // Override default className
  type: ConversationMode; // Type of Conversation chat
  placeholder?: string; // Prompt to display in TextField input
  actionLabel?: string; // Label to put on the primary button
  resetAction?: () => void; // Callback when Reset is pressed
  resetLabel?: string; // Label to put on Reset button
  defaultPrompts?: React.ReactElement[]; // Set of Elements to display after the TextField
  defaultQuery?: string; // Default text to populate the TextField input
  preamble?: ChatMessage[]; // Messages to display at start of Conversation until Action has been invoked
  hidePreamble?: boolean; // Whether to hide the preamble after an Action has been invoked
  hideDefaultPrompts?: boolean; // Whether to hide the defaultPrompts after an Action has been invoked
  messageFilter?: ((messages: ChatMessage[]) => ChatMessage[]) | undefined; // Filter callback to determine which Messages to display in Conversation
  messages?: ChatMessage[]; //
  sx?: SxProps<Theme>;
  onResponse?: ((message: ChatMessage) => void) | undefined; // Event called when a query completes (provides messages)
}

export type { ConversationProps, ConversationHandle };
