import { ServerCogIcon, SettingsIcon } from 'lucide-react'
import { type ReactNode } from 'react'

export type SettingsSection = 'ui' | 'bird'

export type SettingsTabItem = {
  value: SettingsSection
  label: string
  icon: ReactNode
}

/** Side rail items — settings-7 AccountSettings DNA. */
export const SETTINGS_TAB_ITEMS: SettingsTabItem[] = [
  {
    value: 'ui',
    label: 'Настройки UI',
    icon: <SettingsIcon aria-hidden="true" />,
  },
  {
    value: 'bird',
    label: 'Настройки BIRD',
    icon: <ServerCogIcon aria-hidden="true" />,
  },
]

const LEGACY_BIRD = new Set(['bird', 'revision', 'runtime-logs', 'additional'])

/** Maps current and legacy `?tab=` values onto the unified settings rail. */
export function parseSettingsSection(value: unknown): SettingsSection {
  if (typeof value === 'string' && LEGACY_BIRD.has(value)) return 'bird'
  return 'ui'
}
