/**
 * FileTree type definitions
 * @countermeasure/web-components/visualization/file-tree
 */

export interface FileTreeNode {
  /** Stable identifier used for selection, expansion, and drag-and-drop. */
  id: string
  /** Display name shown to the user. */
  name: string
  /** Whether the node is a leaf file or a folder that may contain children. */
  type: 'file' | 'folder'
  /** Optional inline SVG/HTML icon overriding the default file/folder icon. */
  icon?: string
  /** Child nodes — only meaningful for folders. */
  children?: FileTreeNode[]
  /**
   * Initial expanded state for folders.
   * @default false
   */
  expanded?: boolean
  /**
   * Initial selected state.
   * @default false
   */
  selected?: boolean
  /** Free-form metadata tag map associated with the node. */
  data?: Record<string, string>
}

export interface FileTreeConfig {
  /** Container element (or selector) the tree is mounted into. */
  container: HTMLElement | string
  /** Root nodes rendered at depth 0. */
  data: FileTreeNode[]
  /**
   * Allow rows to be selected by click/keyboard.
   * @default false
   */
  selectable?: boolean
  /**
   * Allow multiple rows to be selected at once (Ctrl/Cmd-click).
   * @default false
   */
  multiSelect?: boolean
  /**
   * Enable HTML5 drag-and-drop reordering / nesting.
   * @default false
   */
  draggable?: boolean
  /**
   * Render file/folder icons before each label.
   * @default true
   */
  showIcons?: boolean
  /**
   * Pixel indent applied per depth level.
   * @default 16
   */
  indent?: number
  /** Fired when a row is selected. */
  onSelect?: (node: FileTreeNode) => void
  /** Fired when a folder is expanded or collapsed. */
  onExpand?: (node: FileTreeNode) => void
  /** Fired when a row is dropped onto another row (drag-and-drop). */
  onDrop?: (source: FileTreeNode, target: FileTreeNode) => void
  /** Additional CSS class names. */
  className?: string
}
