/**
 * TypeScript interfaces for the GSD-Lite Worklog Reader
 * Ported from Python POC (LOG-048)
 */

/** Represents a single LOG entry in the worklog */
export interface LogEntry {
  id: string;           // e.g., "LOG-049"
  type: string;         // e.g., "DECISION", "EXEC", "MILESTONE"
  title: string;        // e.g., "The Hot Reload Pivot"
  task?: string;        // e.g., "READER-002"
  superseded: boolean;  // true if title contains ~~strikethrough~~
  lineNumber: number;   // Original line number in WORK.md (1-indexed, start of entry)
  endLine: number;      // End line number (1-indexed, last line of content)
  level: number;        // Header level (2 = ##, 3 = ###)
  content: string;      // Full content including nested sections
  rawText: string;      // Exact text from file (header + content) for edit blocks
  children: Section[];  // Nested H4/H5 sections under this log
}

/** Represents a section header in the worklog */
export interface Section {
  title: string;
  level: number;
  lineNumber: number;   // Start line (1-indexed)
  endLine: number;      // End line (1-indexed, last line of content)
  children: Section[];
  content?: string;     // Content between this section and next header
  rawText?: string;     // Exact text from file (header + content) for edit blocks
  logs?: LogEntry[];    // Optional - not always populated
}

/** Parsed worklog structure */
export interface WorklogAST {
  title: string;
  sections: Section[];
  logs: LogEntry[];
  metadata: {
    totalLines: number;
    totalLogs: number;
    parseTime: number;
  };
}

/** Root-level section extracted from PROJECT.md / ARCHITECTURE.md */
export interface DocSection {
  key: string;
  title: string;
  lineNumber: number;   // Start line (1-indexed)
  endLine: number;      // End line (1-indexed)
  anchorId: string;
  markdown: string;
  rawText: string;      // Exact text from file for edit blocks
  content: string;
}

/** Parsed context document (PROJECT.md or ARCHITECTURE.md) */
export interface ContextDocument {
  kind: 'project' | 'architecture';
  fileName: string;
  title: string;
  totalLines: number;
  sections: DocSection[];
}

/** Mermaid diagram extracted from content */
export interface MermaidDiagram {
  id: string;
  code: string;
  lineNumber: number;
}

/** Render options for the viewer */
export interface RenderOptions {
  theme: 'light' | 'dark';
  showLineNumbers: boolean;
  collapseSections: boolean;
  highlightLogId?: string;
}