import type { LucideIcon } from "lucide-react";
import {
  CalendarClock,
  CircleDollarSign,
  FileSpreadsheet,
  Landmark,
  LayoutDashboard,
  LogIn,
  Scale,
  ScrollText,
  Settings,
  ShieldAlert,
  ShieldCheck,
  SlidersHorizontal,
  Ticket,
  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,
    players: Users,
    draws: CalendarClock,
    rules_plays: SlidersHorizontal,
    rules_odds: SlidersHorizontal,
    jackpot: CircleDollarSign,
    risk_cap: ShieldAlert,
    tickets: Ticket,
    wallet: Wallet,
    reports: FileSpreadsheet,
    risk: ShieldAlert,
    settlement: Landmark,
    reconcile: Scale,
    audit: ScrollText,
    admin_users: ShieldCheck,
    admin_roles: ShieldCheck,
    currencies: CircleDollarSign,
    settings: Settings,
  };

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

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

export { LogIn };
