// lib/puck/iconMap.ts
// Single source of truth for all available icons in the Puck editor.
// Used by: IconNavGrid, CategoryGrid, ProcessSteps, HighlightCards, etc.

import {
  // Finance
  Wallet, CreditCard, PiggyBank, TrendingUp, DollarSign, Banknote, Coins,
  Receipt, BarChart3, LineChart, Percent, CircleDollarSign, BadgePercent,
  // Communication
  Mail, Phone, MessageCircle, Send, Bell, Megaphone,
  // Content
  Newspaper, BookOpen, FileText, Pen, Quote, Video, Image as ImageIcon,
  // Navigation
  Home, Search, ExternalLink, ArrowRight, ChevronRight, Map, Compass,
  // People
  Users, User, UserCheck, GraduationCap, Building2,
  // General
  Gift, Lightbulb, Star, Heart, Shield, Trophy, Clock, Calendar,
  CheckCircle2, HelpCircle, Info, Sparkles, Zap, Globe, Eye,
  Lock, Rocket, Target, Award, Flame, ThumbsUp,
} from 'lucide-react';
import type { LucideIcon } from 'lucide-react';

export interface IconEntry {
  name: string;       // kebab-case key used in data
  label: string;      // display name in picker
  category: string;
  component: LucideIcon;
}

export const ICON_LIST: IconEntry[] = [
  // Finance
  { name: 'wallet', label: 'Wallet', category: 'Finance', component: Wallet },
  { name: 'credit-card', label: 'Credit Card', category: 'Finance', component: CreditCard },
  { name: 'piggy-bank', label: 'Piggy Bank', category: 'Finance', component: PiggyBank },
  { name: 'trending-up', label: 'Trending Up', category: 'Finance', component: TrendingUp },
  { name: 'dollar-sign', label: 'Dollar Sign', category: 'Finance', component: DollarSign },
  { name: 'banknote', label: 'Banknote', category: 'Finance', component: Banknote },
  { name: 'coins', label: 'Coins', category: 'Finance', component: Coins },
  { name: 'receipt', label: 'Receipt', category: 'Finance', component: Receipt },
  { name: 'bar-chart', label: 'Bar Chart', category: 'Finance', component: BarChart3 },
  { name: 'line-chart', label: 'Line Chart', category: 'Finance', component: LineChart },
  { name: 'percent', label: 'Percent', category: 'Finance', component: Percent },
  { name: 'circle-dollar', label: 'Circle Dollar', category: 'Finance', component: CircleDollarSign },
  { name: 'badge-percent', label: 'Badge Percent', category: 'Finance', component: BadgePercent },

  // Communication
  { name: 'mail', label: 'Mail', category: 'Communication', component: Mail },
  { name: 'phone', label: 'Phone', category: 'Communication', component: Phone },
  { name: 'message', label: 'Message', category: 'Communication', component: MessageCircle },
  { name: 'send', label: 'Send', category: 'Communication', component: Send },
  { name: 'bell', label: 'Bell', category: 'Communication', component: Bell },
  { name: 'megaphone', label: 'Megaphone', category: 'Communication', component: Megaphone },

  // Content
  { name: 'newspaper', label: 'Newspaper', category: 'Content', component: Newspaper },
  { name: 'book-open', label: 'Book Open', category: 'Content', component: BookOpen },
  { name: 'file-text', label: 'File Text', category: 'Content', component: FileText },
  { name: 'pen', label: 'Pen', category: 'Content', component: Pen },
  { name: 'quote', label: 'Quote', category: 'Content', component: Quote },
  { name: 'video', label: 'Video', category: 'Content', component: Video },
  { name: 'image', label: 'Image', category: 'Content', component: ImageIcon },

  // Navigation
  { name: 'home', label: 'Home', category: 'Navigation', component: Home },
  { name: 'search', label: 'Search', category: 'Navigation', component: Search },
  { name: 'external-link', label: 'External Link', category: 'Navigation', component: ExternalLink },
  { name: 'arrow-right', label: 'Arrow Right', category: 'Navigation', component: ArrowRight },
  { name: 'chevron-right', label: 'Chevron Right', category: 'Navigation', component: ChevronRight },
  { name: 'map', label: 'Map', category: 'Navigation', component: Map },
  { name: 'compass', label: 'Compass', category: 'Navigation', component: Compass },

  // People
  { name: 'users', label: 'Users', category: 'People', component: Users },
  { name: 'user', label: 'User', category: 'People', component: User },
  { name: 'user-check', label: 'User Check', category: 'People', component: UserCheck },
  { name: 'graduation-cap', label: 'Graduation Cap', category: 'People', component: GraduationCap },
  { name: 'building', label: 'Building', category: 'People', component: Building2 },

  // General
  { name: 'gift', label: 'Gift', category: 'General', component: Gift },
  { name: 'lightbulb', label: 'Lightbulb', category: 'General', component: Lightbulb },
  { name: 'star', label: 'Star', category: 'General', component: Star },
  { name: 'heart', label: 'Heart', category: 'General', component: Heart },
  { name: 'shield', label: 'Shield', category: 'General', component: Shield },
  { name: 'trophy', label: 'Trophy', category: 'General', component: Trophy },
  { name: 'clock', label: 'Clock', category: 'General', component: Clock },
  { name: 'calendar', label: 'Calendar', category: 'General', component: Calendar },
  { name: 'check-circle', label: 'Check Circle', category: 'General', component: CheckCircle2 },
  { name: 'help-circle', label: 'Help Circle', category: 'General', component: HelpCircle },
  { name: 'info', label: 'Info', category: 'General', component: Info },
  { name: 'sparkles', label: 'Sparkles', category: 'General', component: Sparkles },
  { name: 'zap', label: 'Zap', category: 'General', component: Zap },
  { name: 'globe', label: 'Globe', category: 'General', component: Globe },
  { name: 'eye', label: 'Eye', category: 'General', component: Eye },
  { name: 'lock', label: 'Lock', category: 'General', component: Lock },
  { name: 'rocket', label: 'Rocket', category: 'General', component: Rocket },
  { name: 'target', label: 'Target', category: 'General', component: Target },
  { name: 'award', label: 'Award', category: 'General', component: Award },
  { name: 'flame', label: 'Flame', category: 'General', component: Flame },
  { name: 'thumbs-up', label: 'Thumbs Up', category: 'General', component: ThumbsUp },
];

// Fast lookup map: name -> component
export const ICON_MAP: Record<string, LucideIcon> =
  Object.fromEntries(ICON_LIST.map((icon) => [icon.name, icon.component]));

// All unique categories
export const ICON_CATEGORIES = [...new Set(ICON_LIST.map((i) => i.category))];

// Helper to resolve icon name to component (with fallback)
export function resolveIcon(name: string | undefined): LucideIcon {
  return ICON_MAP[name || ''] || Newspaper;
}
