import type { LucideIcon } from "lucide-react";
import {
  CalendarClock,
  ClipboardList,
  Coins,
  FileSpreadsheet,
  Globe,
  KeyRound,
  Landmark,
  LayoutDashboard,
  LogIn,
  Network,
  Percent,
  Scale,
  ScrollText,
  Receipt,
  Settings,
  ShieldAlert,
  SlidersHorizontal,
  Ticket,
  Trophy,
  UserCog,
  Users,
  Wallet,
} from "lucide-react";

import type { AdminNavItem } from "@/modules/_config/admin-nav";

/** 与 {@link AdminNavItem}["segment"] 一一对应 */
export const adminNavIconBySegment: Record<AdminNavItem["segment"], LucideIcon> =
  {
    dashboard: LayoutDashboard,
    agents: Network,
    players: Users,
    draws: CalendarClock,
    rules_plays: ClipboardList,
    rules_odds: Percent,
    jackpot: Trophy,
    risk_cap: ShieldAlert,
    tickets: Ticket,
    wallet: Wallet,
    reports: FileSpreadsheet,
    risk: ShieldAlert,
    settlement: Landmark,
    settlement_center: Receipt,
    reconcile: Scale,
    audit: ScrollText,
    admin_users: UserCog,
    admin_roles: KeyRound,
    currencies: Coins,
    integration: Globe,
    settings: Settings,
  };

/** 旧版 localStorage / 接口缓存中的 segment，避免首屏侧栏崩溃 */
const legacyAdminNavIconBySegment: Record<string, LucideIcon> = {
  agent_list: Users,
  config: SlidersHorizontal,
};

export function resolveAdminNavIcon(segment: string): LucideIcon {
  return (
    adminNavIconBySegment[segment as AdminNavItem["segment"]] ??
    legacyAdminNavIconBySegment[segment] ??
    LayoutDashboard
  );
}

export { LogIn };
