/** 관리자 화면 9-섹션 메뉴 트리 */

export interface AdminMenuItem {
  id: string;
  label: string;
  icon?: string;
  children?: AdminMenuItem[];
}

export const ADMIN_MENU: AdminMenuItem[] = [
  {
    id: 'env-settings',
    label: '환경설정',
    icon: '⚙️',
    children: [
      { id: 'menus', label: '메뉴관리' },
      { id: 'settings', label: '시스템설정' },
      { id: 'system-arch', label: '시스템구조' },
    ],
  },
  {
    id: 'user-info',
    label: '사용자정보',
    icon: '👥',
    children: [
      { id: 'users', label: '사용자관리' },
      { id: 'permissions', label: '권한관리' },
    ],
  },
  {
    id: 'board-mgmt',
    label: '게시판관리',
    icon: '📋',
    children: [
      { id: 'notice', label: '공지사항' },
      { id: 'board', label: '게시판' },
      { id: 'qna', label: 'QNA' },
    ],
  },
  {
    id: 'reference',
    label: '기준정보',
    icon: '🗺️',
    children: [
      {
        id: 'map-mgmt',
        label: '지도관리',
        children: [
          { id: 'map-base', label: '지도백데이터' },
          { id: 'map-layer', label: '레이어' },
        ],
      },
      {
        id: 'sensitive-map',
        label: '민감자원지도',
        children: [
          { id: 'env-ecology', label: '환경/생태' },
          { id: 'social-economy', label: '사회/경제' },
        ],
      },
      {
        id: 'coast-guard-assets',
        label: '해경자산',
        children: [
          { id: 'cleanup-equip', label: '방제장비' },
          { id: 'asset-upload', label: '자산현행화' },
          { id: 'dispersant-zone', label: '유처리제 제한구역' },
          { id: 'vessel-materials', label: '방제선 보유자재' },
        ],
      },
    ],
  },
  {
    id: 'external',
    label: '연계관리',
    icon: '🔗',
    children: [
      {
        id: 'collection',
        label: '수집자료',
        children: [
          { id: 'collect-vessel-signal', label: '선박신호' },
          { id: 'collect-hr', label: '인사정보' },
        ],
      },
      {
        id: 'monitoring',
        label: '연계모니터링',
        children: [
          { id: 'monitor-realtime', label: '실시간 관측자료' },
          { id: 'monitor-forecast', label: '수치예측자료' },
          { id: 'monitor-vessel', label: '선박위치정보' },
        ],
      },
      {
        id: 'rnd',
        label: 'R&D과제',
        children: [
          { id: 'rnd-poseidon', label: '유출유확산예측(포세이돈)' },
          { id: 'rnd-kosps', label: '유출유확산예측(KOSPS)' },
          { id: 'rnd-hns-atmos', label: 'HNS대기확산(충북대)' },
          { id: 'rnd-rescue', label: '긴급구난과제' },
        ],
      },
      { id: 'deidentify', label: '비식별화조치' },
    ],
  },
];

/** 메뉴 ID로 라벨을 찾는 유틸리티 */
export function findMenuLabel(id: string, items: AdminMenuItem[] = ADMIN_MENU): string | null {
  for (const item of items) {
    if (item.id === id) return item.label;
    if (item.children) {
      const found = findMenuLabel(id, item.children);
      if (found) return found;
    }
  }
  return null;
}
