export interface Document {
  id: string
  filename: string
  contentType: string | null
  fileSize: number | null
  pageCount: number | null
  createdAt: string
}

export interface PipelineOptions {
  do_ocr?: boolean
  do_table_structure?: boolean
  table_mode?: 'accurate' | 'fast'
  do_code_enrichment?: boolean
  do_formula_enrichment?: boolean
  do_picture_classification?: boolean
  do_picture_description?: boolean
  generate_picture_images?: boolean
  generate_page_images?: boolean
  images_scale?: number
}

export type AnalysisStatus = 'PENDING' | 'RUNNING' | 'COMPLETED' | 'FAILED'

export interface Analysis {
  id: string
  documentId: string
  documentFilename: string | null
  status: AnalysisStatus
  contentMarkdown: string | null
  contentHtml: string | null
  pagesJson: string | null
  chunksJson: string | null
  hasDocumentJson: boolean
  errorMessage: string | null
  progressCurrent: number | null
  progressTotal: number | null
  startedAt: string | null
  completedAt: string | null
  createdAt: string
}

export interface ChunkingOptions {
  chunker_type?: 'hybrid' | 'hierarchical'
  max_tokens?: number
  merge_peers?: boolean
  repeat_table_header?: boolean
}

export interface ChunkBbox {
  page: number
  bbox: [number, number, number, number]
}

export interface Chunk {
  text: string
  headings: string[]
  sourcePage: number | null
  tokenCount: number
  bboxes: ChunkBbox[]
  modified?: boolean
  deleted?: boolean
}

export interface PageElement {
  type: string
  bbox: [number, number, number, number]
  content: string
  level: number
}

// Backend serializes with snake_case (dataclasses.asdict)
export interface Page {
  page_number: number
  width: number
  height: number
  elements: PageElement[]
}

export type ElementType =
  | 'title'
  | 'section_header'
  | 'text'
  | 'table'
  | 'picture'
  | 'list'
  | 'formula'
  | 'code'
  | 'caption'
  | 'floating'

export interface Scale {
  sx: number
  sy: number
}

export interface Rect {
  x: number
  y: number
  w: number
  h: number
}

export type Locale = 'fr' | 'en'
export type Theme = 'dark' | 'light'
