import type { LucideIcon } from 'lucide-react'
import {
  BarChart3,
  Bell,
  BookOpen,
  BrainCircuit,
  Building2,
  ClipboardList,
  FileText,
  GitPullRequest,
  HelpCircle,
  LayoutDashboard,
  Monitor,
  Package,
  PlayCircle,
  Radar,
  Rocket,
  Settings,
  ShieldCheck,
  Terminal,
} from 'lucide-react'

export type ProductNavItem = {
  id: string
  href: string
  labelKey: string
  Icon: LucideIcon
  aliases?: string[]
  relatedPaths?: string[]
  exact?: boolean
  badge?: boolean
}

export type ProductNavSection = {
  sectionKey: string
  items: ProductNavItem[]
}

export type WorkflowNavItem = {
  labelKey: string
  href: string
  exact?: boolean
}

// Canonical product IA map. This is the single source for the global shell; page
// layouts can reference this map for titles and context, but must not recreate
// a second navigation tree.
export const PRODUCT_NAV_SECTIONS: ProductNavSection[] = [
  {
    sectionKey: 'workspaces',
    items: [
      { id: 'command-center', href: '/', labelKey: 'commandCenter', Icon: LayoutDashboard },
      { id: 'delivery', href: '/delivery', labelKey: 'delivery', Icon: Rocket },
      {
        id: 'awooop-overview',
        href: '/awooop',
        labelKey: 'awooopHome',
        Icon: BrainCircuit,
        exact: true,
      },
    ],
  },
  {
    sectionKey: 'queues',
    items: [
      {
        id: 'awooop-work-items',
        href: '/awooop/work-items',
        labelKey: 'workItems',
        Icon: ClipboardList,
      },
      {
        id: 'awooop-runs',
        href: '/awooop/runs',
        labelKey: 'runMonitor',
        Icon: PlayCircle,
      },
      {
        id: 'awooop-approvals',
        href: '/awooop/approvals',
        labelKey: 'approvalQueue',
        Icon: ShieldCheck,
        aliases: ['/authorizations'],
        badge: true,
      },
      {
        id: 'awooop-contracts',
        href: '/awooop/contracts',
        labelKey: 'contracts',
        Icon: FileText,
      },
      {
        id: 'awooop-tenants',
        href: '/awooop/tenants',
        labelKey: 'tenants',
        Icon: Building2,
      },
    ],
  },
  {
    sectionKey: 'monitoring',
    items: [
      {
        id: 'observability',
        href: '/observability',
        labelKey: 'observability',
        Icon: Monitor,
        aliases: ['/monitoring', '/apm', '/errors', '/apps', '/services', '/topology'],
      },
      {
        id: 'alerts',
        href: '/alerts',
        labelKey: 'alerts',
        Icon: Bell,
        aliases: ['/alert-operation-logs', '/notifications'],
      },
      {
        id: 'iwooos-security',
        href: '/iwooos',
        labelKey: 'iwooos',
        Icon: ShieldCheck,
        aliases: ['/security-compliance'],
        relatedPaths: ['/security', '/compliance'],
      },
      {
        id: 'code-review',
        href: '/code-review',
        labelKey: 'codeReview',
        Icon: GitPullRequest,
      },
    ],
  },
  {
    sectionKey: 'knowledge',
    items: [
      {
        id: 'knowledge-automation',
        href: '/knowledge-base',
        labelKey: 'knowledgeAutomation',
        Icon: BookOpen,
        aliases: ['/knowledge', '/automation', '/auto-repair', '/drift', '/neural-command'],
      },
      {
        id: 'reports',
        href: '/reports',
        labelKey: 'reports',
        Icon: BarChart3,
      },
      {
        id: 'operations',
        href: '/operations',
        labelKey: 'operationsOverview',
        Icon: Package,
        aliases: ['/deployments', '/tickets', '/cost', '/billing', '/action-logs'],
      },
    ],
  },
  {
    sectionKey: 'system',
    items: [
      { id: 'terminal', href: '/terminal', labelKey: 'terminal', Icon: Terminal },
      { id: 'settings', href: '/settings', labelKey: 'settings', Icon: Settings },
      { id: 'classic', href: '/classic', labelKey: 'classicAICenter', Icon: Radar },
    ],
  },
]

export const PRODUCT_BOTTOM_NAV_ITEMS: ProductNavItem[] = [
  { id: 'help', href: '/help', labelKey: 'help', Icon: HelpCircle },
]

export const AWOOOP_WORKFLOW_ITEMS: WorkflowNavItem[] = [
  {
    labelKey: 'overview',
    href: '/awooop',
    exact: true,
  },
  {
    labelKey: 'workItems',
    href: '/awooop/work-items',
  },
  {
    labelKey: 'runs',
    href: '/awooop/runs',
  },
  {
    labelKey: 'approvals',
    href: '/awooop/approvals',
  },
  {
    labelKey: 'contracts',
    href: '/awooop/contracts',
  },
  {
    labelKey: 'tenants',
    href: '/awooop/tenants',
  },
]
