import {
  MessageSquare, AlignLeft, FileText, CheckSquare, Circle, Star,
  SlidersHorizontal, Grip, ArrowRightLeft, Bot, Mic, Clock, User,
  Target, Layers, Volume2, Video, Upload, Code, Image, Globe,
  Tag, BarChart3, Brain, Puzzle, CheckCircle, Hash
} from "lucide-react";
import type { LucideIcon } from "lucide-react";

export interface QuestionTypeDefinition {
  type: string;
  label: string;
  description: string;
  icon: LucideIcon;
  color: string;
  category: "basic" | "media" | "ai" | "specialized" | "assessment";
  supportsOptions: boolean;
  supportsScoring: boolean;
  hasNumericRange: boolean;
}

export const QUESTION_TYPES: QuestionTypeDefinition[] = [
  // Basic
  {
    type: "MULTIPLE_CHOICE",
    label: "Multiple Choice",
    description: "Select one or more from a list of options",
    icon: CheckSquare,
    color: "from-blue-500 to-cyan-500",
    category: "basic",
    supportsOptions: true,
    supportsScoring: true,
    hasNumericRange: false,
  },
  {
    type: "SINGLE_CHOICE",
    label: "Single Choice",
    description: "Select exactly one option from a list",
    icon: Circle,
    color: "from-indigo-500 to-blue-500",
    category: "basic",
    supportsOptions: true,
    supportsScoring: true,
    hasNumericRange: false,
  },
  {
    type: "TEXT_SHORT",
    label: "Short Text",
    description: "Brief text response (1-2 sentences)",
    icon: MessageSquare,
    color: "from-green-500 to-emerald-500",
    category: "basic",
    supportsOptions: false,
    supportsScoring: false,
    hasNumericRange: false,
  },
  {
    type: "TEXT_LONG",
    label: "Long Text",
    description: "Extended text response",
    icon: AlignLeft,
    color: "from-teal-500 to-green-500",
    category: "basic",
    supportsOptions: false,
    supportsScoring: false,
    hasNumericRange: false,
  },
  {
    type: "ESSAY",
    label: "Essay",
    description: "In-depth written response",
    icon: FileText,
    color: "from-emerald-500 to-teal-500",
    category: "basic",
    supportsOptions: false,
    supportsScoring: false,
    hasNumericRange: false,
  },
  {
    type: "RATING_SCALE",
    label: "Rating Scale",
    description: "Numeric rating (e.g., 1-5 or 1-10)",
    icon: Star,
    color: "from-amber-500 to-yellow-500",
    category: "basic",
    supportsOptions: false,
    supportsScoring: true,
    hasNumericRange: true,
  },
  {
    type: "SLIDER",
    label: "Slider",
    description: "Continuous value selection",
    icon: SlidersHorizontal,
    color: "from-orange-500 to-amber-500",
    category: "basic",
    supportsOptions: false,
    supportsScoring: false,
    hasNumericRange: true,
  },
  // Media
  {
    type: "IMAGE_BASED",
    label: "Image Question",
    description: "Question with an image attachment",
    icon: Image,
    color: "from-rose-500 to-pink-500",
    category: "media",
    supportsOptions: true,
    supportsScoring: true,
    hasNumericRange: false,
  },
  {
    type: "AUDIO_QUESTION",
    label: "Audio Question",
    description: "Question with an audio clip",
    icon: Volume2,
    color: "from-purple-500 to-violet-500",
    category: "media",
    supportsOptions: true,
    supportsScoring: false,
    hasNumericRange: false,
  },
  {
    type: "VIDEO_QUESTION",
    label: "Video Question",
    description: "Question with a video clip",
    icon: Video,
    color: "from-violet-500 to-purple-500",
    category: "media",
    supportsOptions: true,
    supportsScoring: false,
    hasNumericRange: false,
  },
  {
    type: "FILE_UPLOAD",
    label: "File Upload",
    description: "Upload a document, image, or file",
    icon: Upload,
    color: "from-slate-500 to-gray-500",
    category: "media",
    supportsOptions: false,
    supportsScoring: false,
    hasNumericRange: false,
  },
  {
    type: "CODE_EDITOR",
    label: "Code Editor",
    description: "Write and run code in the browser",
    icon: Code,
    color: "from-green-600 to-emerald-600",
    category: "media",
    supportsOptions: false,
    supportsScoring: true,
    hasNumericRange: false,
  },
  {
    type: "VOICE_RECORDING",
    label: "Voice Recording",
    description: "Record and submit an audio response",
    icon: Mic,
    color: "from-pink-500 to-rose-500",
    category: "media",
    supportsOptions: false,
    supportsScoring: false,
    hasNumericRange: false,
  },
  // AI
  {
    type: "AI_CONVERSATION",
    label: "AI Conversation",
    description: "Simulate a conversation with an AI assistant",
    icon: Bot,
    color: "from-violet-600 to-indigo-600",
    category: "ai",
    supportsOptions: false,
    supportsScoring: false,
    hasNumericRange: false,
  },
  {
    type: "RLHF_TASK",
    label: "RLHF Task",
    description: "Compare and rank AI responses",
    icon: Brain,
    color: "from-indigo-600 to-violet-600",
    category: "ai",
    supportsOptions: false,
    supportsScoring: true,
    hasNumericRange: false,
  },
  {
    type: "COMPARATIVE_RANKING",
    label: "Comparative Ranking",
    description: "Rank multiple AI outputs",
    icon: BarChart3,
    color: "from-blue-600 to-indigo-600",
    category: "ai",
    supportsOptions: true,
    supportsScoring: true,
    hasNumericRange: false,
  },
  {
    type: "DATA_LABELING",
    label: "Data Labeling",
    description: "Label, classify, or tag content",
    icon: Tag,
    color: "from-cyan-500 to-blue-500",
    category: "ai",
    supportsOptions: true,
    supportsScoring: true,
    hasNumericRange: false,
  },
  // Specialized
  {
    type: "DRAG_DROP_RANKING",
    label: "Drag & Drop Ranking",
    description: "Reorder items by dragging",
    icon: Grip,
    color: "from-orange-500 to-red-500",
    category: "specialized",
    supportsOptions: true,
    supportsScoring: true,
    hasNumericRange: false,
  },
  {
    type: "MATCH_FOLLOWING",
    label: "Match the Following",
    description: "Connect related items on both sides",
    icon: ArrowRightLeft,
    color: "from-teal-500 to-cyan-500",
    category: "specialized",
    supportsOptions: true,
    supportsScoring: true,
    hasNumericRange: false,
  },
  {
    type: "TIMED_QUESTION",
    label: "Timed Question",
    description: "Answer within a time limit",
    icon: Clock,
    color: "from-red-500 to-orange-500",
    category: "specialized",
    supportsOptions: true,
    supportsScoring: true,
    hasNumericRange: false,
  },
  {
    type: "ANNOTATION_TASK",
    label: "Annotation Task",
    description: "Annotate text, images, or other content",
    icon: Layers,
    color: "from-amber-600 to-orange-600",
    category: "specialized",
    supportsOptions: false,
    supportsScoring: false,
    hasNumericRange: false,
  },
  {
    type: "TRANSLATION_TASK",
    label: "Translation Task",
    description: "Translate text between languages",
    icon: Globe,
    color: "from-sky-500 to-blue-500",
    category: "specialized",
    supportsOptions: false,
    supportsScoring: false,
    hasNumericRange: false,
  },
  {
    type: "SENTIMENT_CLASSIFICATION",
    label: "Sentiment Classification",
    description: "Classify text sentiment or emotion",
    icon: Hash,
    color: "from-pink-600 to-rose-600",
    category: "specialized",
    supportsOptions: true,
    supportsScoring: true,
    hasNumericRange: false,
  },
  // Assessment
  {
    type: "PERSONALITY_ASSESSMENT",
    label: "Personality Assessment",
    description: "Multi-dimensional personality mapping",
    icon: User,
    color: "from-purple-600 to-violet-600",
    category: "assessment",
    supportsOptions: true,
    supportsScoring: false,
    hasNumericRange: false,
  },
  {
    type: "SITUATIONAL_JUDGMENT",
    label: "Situational Judgment",
    description: "Evaluate responses to realistic scenarios",
    icon: Target,
    color: "from-green-600 to-teal-600",
    category: "assessment",
    supportsOptions: true,
    supportsScoring: true,
    hasNumericRange: false,
  },
  {
    type: "INTERACTIVE_SCENARIO",
    label: "Interactive Scenario",
    description: "Multi-step decision-making simulation",
    icon: Puzzle,
    color: "from-violet-600 to-purple-600",
    category: "assessment",
    supportsOptions: true,
    supportsScoring: true,
    hasNumericRange: false,
  },
  {
    type: "CAPTCHA_VALIDATION",
    label: "CAPTCHA Validation",
    description: "Verify human responses with challenges",
    icon: CheckCircle,
    color: "from-gray-600 to-slate-600",
    category: "assessment",
    supportsOptions: false,
    supportsScoring: false,
    hasNumericRange: false,
  },
];

export const QUESTION_TYPE_CATEGORIES = {
  basic: "Basic",
  media: "Media & Files",
  ai: "AI Training",
  specialized: "Specialized",
  assessment: "Assessment",
};

export function getQuestionTypeConfig(type: string): QuestionTypeDefinition | undefined {
  return QUESTION_TYPES.find((qt) => qt.type === type);
}
