/**
 * SidebarComponent type definitions
 * @countermeasure/web-components/sidebar/component
 */

import { type IconSet } from '../icons/index'

export interface SidebarNavItem {
  /** Stable identifier used for selection and badge updates. */
  id: string
  /** Visible label rendered alongside the icon. */
  label: string
  /** Icon name resolved through the active icon set. */
  icon?: string
  /** Numeric badge displayed at the trailing edge of the row. */
  badge?: number
  /** Called when the item is activated. */
  onClick?: () => void
}

export interface SidebarSection {
  /** Stable section identifier. */
  id: string
  /** Optional section heading. */
  label?: string
  /** Nav items rendered within this section. */
  items: SidebarNavItem[]
}

export interface SidebarUser {
  /** Display name shown in the footer. */
  name: string
}

export interface SidebarFooterAction {
  /** Stable identifier for the action. */
  id: string
  /** Icon name resolved through the active icon set. */
  icon: string
  /** Accessible label / tooltip for the action. */
  label: string
  /**
   * Render the action with destructive styling.
   * @default false
   */
  danger?: boolean
  /** Called when the action is activated. */
  onClick?: () => void
}

export interface SidebarComponentConfig {
  /** Container element (or selector) the sidebar is mounted into. */
  container: HTMLElement | string
  /** Visual variant key — passed through as `data-variant` for theming. */
  variant?: string
  /** Sections rendered top-to-bottom. */
  sections: SidebarSection[]
  /** Optional user surface rendered in the footer. */
  user?: SidebarUser
  /** Footer action buttons rendered next to the user surface. */
  footerActions?: SidebarFooterAction[]
  /**
   * Icon set used to resolve `icon` names.
   * @default 'lucide'
   */
  iconSet?: IconSet
  /** Called when a nav item is activated. */
  onNavigate?: (item: SidebarNavItem) => void
  /** Called when the sidebar's collapsed state changes. */
  onCollapse?: (collapsed: boolean) => void
}
