import {
  Activity,
  AlertTriangle,
  Boxes,
  Building2,
  Check,
  ChevronDown,
  ChevronLeft,
  ChevronRight,
  Circle,
  ClipboardList,
  Copy,
  Database,
  Download,
  ExternalLink,
  FileText,
  FolderOpen,
  Globe2,
  Image,
  Inbox,
  KeyRound,
  LayoutDashboard,
  ListChecks,
  LocateFixed,
  LockKeyhole,
  MailPlus,
  Maximize2,
  Minimize2,
  Network,
  PanelTop,
  Pencil,
  Plus,
  RefreshCw,
  Save,
  Search,
  Settings,
  ShieldCheck,
  SlidersHorizontal,
  Trash2,
  UploadCloud,
  UserCircle,
  UsersRound,
  Video,
  X,
  type LucideIcon,
  type LucideProps,
} from "lucide-react";

const icons = {
  activity: Activity,
  alert: AlertTriangle,
  apps: Boxes,
  building: Building2,
  check: Check,
  "chevron-down": ChevronDown,
  "chevron-left": ChevronLeft,
  "chevron-right": ChevronRight,
  circle: Circle,
  clipboard: ClipboardList,
  close: X,
  copy: Copy,
  database: Database,
  download: Download,
  edit: Pencil,
  expand: Maximize2,
  external: ExternalLink,
  file: FileText,
  folder: FolderOpen,
  globe: Globe2,
  grid: LayoutDashboard,
  image: Image,
  inbox: Inbox,
  key: KeyRound,
  list: ListChecks,
  target: LocateFixed,
  lock: LockKeyhole,
  mail: MailPlus,
  minimize: Minimize2,
  network: Network,
  panel: PanelTop,
  plus: Plus,
  profile: UserCircle,
  refresh: RefreshCw,
  save: Save,
  search: Search,
  settings: Settings,
  shield: ShieldCheck,
  sliders: SlidersHorizontal,
  trash: Trash2,
  upload: UploadCloud,
  users: UsersRound,
  video: Video,
} satisfies Record<string, LucideIcon>;

export type IconName = keyof typeof icons;

export interface IconProps extends Omit<LucideProps, "ref"> {
  name: IconName;
  label?: string;
}

export function Icon({ name, label, size = 16, strokeWidth = 1.6, ...props }: IconProps) {
  const IconComponent = icons[name];

  return (
    <IconComponent
      size={size}
      strokeWidth={strokeWidth}
      aria-hidden={label ? undefined : "true"}
      aria-label={label}
      role={label ? "img" : undefined}
      focusable="false"
      {...props}
    />
  );
}
