// Generated by alef. Do not edit by hand.
@file:Suppress(
    "ktlint:standard:trailing-comma-on-call-site",
    "ktlint:standard:trailing-comma-on-declaration-site",
    "ktlint:standard:spacing-between-declarations-with-comments",
    "ktlint:standard:spacing-between-declarations-with-annotations",
    "ktlint:standard:when-entry-bracing",
    "ktlint:standard:blank-line-between-when-conditions",
    "ktlint:standard:blank-line-before-declaration",
    "ktlint:standard:chain-method-continuation",
    "ktlint:standard:annotation",
    "ktlint:standard:max-line-length",
    "ktlint:standard:no-semi",
    "ktlint:standard:statement-wrapping",
    "MaxLineLength",
    "TooManyFunctions",
    "FunctionParameterNaming",
    "LongParameterList",
    "CyclomaticComplexMethod",
    "LongMethod",
)

package dev.kreuzberg

/**
 * General extraction result used by the core extraction API.
 *
 * This is the main result type returned by all extraction functions.
 */
data class ExtractionResult(
    val content: String = "",
    val mimeType: String = "",
    val metadata: Metadata = Metadata(),
    /**
     * Extraction strategy used to produce the returned text.
     *
     * Populated when the extractor can reliably distinguish native text extraction,
     * OCR-only extraction, or mixed native/OCR output.
     */
    val extractionMethod: ExtractionMethod? = null,
    val tables: List<Table> = emptyList(),
    val detectedLanguages: List<String>? = null,
    /**
     * Text chunks when chunking is enabled.
     *
     * When chunking configuration is provided, the content is split into
     * overlapping chunks for efficient processing. Each chunk contains the text,
     * optional embeddings (if enabled), and metadata about its position.
     */
    val chunks: List<Chunk>? = null,
    /**
     * Extracted images from the document.
     *
     * When image extraction is enabled via `ImageExtractionConfig`, this field
     * contains all images found in the document with their raw data and metadata.
     * Each image may optionally contain a nested `ocr_result` if OCR was performed.
     */
    val images: List<ExtractedImage>? = null,
    /**
     * Per-page content when page extraction is enabled.
     *
     * When page extraction is configured, the document is split into per-page content
     * with tables and images mapped to their respective pages.
     */
    val pages: List<PageContent>? = null,
    /**
     * Semantic elements when element-based result format is enabled.
     *
     * When result_format is set to ElementBased, this field contains semantic
     * elements with type classification, unique identifiers, and metadata for
     * Unstructured-compatible element-based processing.
     */
    val elements: List<Element>? = null,
    /**
     * Rich Djot content structure (when extracting Djot documents).
     *
     * When extracting Djot documents with structured extraction enabled,
     * this field contains the full semantic structure including:
     *
     * - Block-level elements with nesting
     * - Inline formatting with attributes
     * - Links, images, footnotes
     * - Math expressions
     * - Complete attribute information
     *
     * The `content` field still contains plain text for backward compatibility.
     *
     * Always `null` for non-Djot documents.
     */
    val djotContent: DjotContent? = null,
    /**
     * OCR elements with full spatial and confidence metadata.
     *
     * When OCR is performed with element extraction enabled, this field contains
     * the structured representation of detected text including:
     *
     * - Bounding geometry (rectangles or quadrilaterals)
     * - Confidence scores (detection and recognition)
     * - Rotation information
     * - Hierarchical relationships (Tesseract only)
     *
     * This field preserves all metadata that would otherwise be lost when
     * converting to plain text or markdown output formats.
     *
     * Only populated when `OcrElementConfig.include_elements` is true.
     */
    val ocrElements: List<OcrElement>? = null,
    /**
     * Structured document tree (when document structure extraction is enabled).
     *
     * When `include_document_structure` is true in `ExtractionConfig`, this field
     * contains the full hierarchical representation of the document including:
     *
     * - Heading-driven section nesting
     * - Table grids with cell-level metadata
     * - Content layer classification (body, header, footer, footnote)
     * - Inline text annotations (formatting, links)
     * - Bounding boxes and page numbers
     *
     * Independent of `result_format` — can be combined with Unified or ElementBased.
     */
    val document: DocumentStructure? = null,
    /**
     * Extracted keywords when keyword extraction is enabled.
     *
     * When keyword extraction (RAKE or YAKE) is configured, this field contains
     * the extracted keywords with scores, algorithm info, and position data.
     * Previously stored in `metadata.additional["keywords"]`.
     */
    val extractedKeywords: List<Keyword>? = null,
    /**
     * Document quality score from quality analysis.
     *
     * A value between 0.0 and 1.0 indicating the overall text quality.
     * Previously stored in `metadata.additional["quality_score"]`.
     */
    val qualityScore: Double? = null,
    /**
     * Non-fatal warnings collected during processing pipeline stages.
     *
     * Captures errors from optional pipeline features (embedding, chunking,
     * language detection, output formatting) that don't prevent extraction
     * but may indicate degraded results.
     * Previously stored as individual keys in `metadata.additional`.
     */
    val processingWarnings: List<ProcessingWarning> = emptyList(),
    /**
     * PDF annotations extracted from the document.
     *
     * When annotation extraction is enabled via `PdfConfig.extract_annotations`,
     * this field contains text notes, highlights, links, stamps, and other
     * annotations found in PDF documents.
     */
    val annotations: List<PdfAnnotation>? = null,
    /**
     * Nested extraction results from archive contents.
     *
     * When extracting archives, each processable file inside produces its own
     * full extraction result. Set to `null` for non-archive formats.
     * Use `max_archive_depth` in config to control recursion depth.
     */
    val children: List<ArchiveEntry>? = null,
    /**
     * URIs/links discovered during document extraction.
     *
     * Contains hyperlinks, image references, citations, email addresses, and
     * other URI-like references found in the document. Always extracted when
     * present in the source document.
     */
    val uris: List<ExtractedUri>? = null,
    /**
     * Tracked changes embedded in the source document.
     *
     * Populated by per-format extractors that understand change-tracking
     * metadata (DOCX `w:ins`/`w:del`/`w:rPrChange`, ODT `text:change-*`,
     * …). Every extractor defaults to `null` until its format-specific
     * implementation is added. Extractors that do populate this field follow
     * the "accepted-changes" convention: inserted text is present in
     * `content`, deleted text is absent — the revision list is the separate
     * audit trail.
     */
    val revisions: List<DocumentRevision>? = null,
    /**
     * Structured extraction output from LLM-based JSON schema extraction.
     *
     * When `structured_extraction` is configured in `ExtractionConfig`, the
     * extracted document content is sent to a VLM with the provided JSON schema.
     * The response is parsed and stored here as a JSON value matching the schema.
     */
    val structuredOutput: Any? = null,
    /**
     * Code intelligence results from tree-sitter analysis.
     *
     * Populated when extracting source code files with the `tree-sitter` feature.
     * Contains metrics, structural analysis, imports/exports, comments,
     * docstrings, symbols, diagnostics, and optionally chunked code segments.
     *
     * Stored as an opaque JSON value so that all language bindings (Go, Java,
     * C#, …) can deserialize it as a raw JSON object rather than a typed struct.
     * The underlying type is `tree_sitter_language_pack.ProcessResult`.
     */
    val codeIntelligence: Any? = null,
    /**
     * LLM token usage and cost data for all LLM calls made during this extraction.
     *
     * Contains one entry per LLM call. Multiple entries are produced when
     * VLM OCR, structured extraction, or LLM embeddings run during
     * the same extraction.
     *
     * `null` when no LLM was used.
     */
    val llmUsage: List<LlmUsage>? = null,
    /**
     * Pre-rendered content in the requested output format.
     *
     * Populated during `derive_extraction_result` before tree derivation consumes
     * element data. `apply_output_format` swaps this into `content` at the end
     * of the pipeline, after post-processors have operated on plain text.
     */
    val formattedContent: String? = null,
    /**
     * Structured hOCR document for the OCR+layout pipeline.
     *
     * When tesseract produces hOCR output, the parsed `InternalDocument` carries
     * paragraph structure with bounding boxes and confidence scores. The layout
     * classification step enriches these elements before final rendering.
     */
    val ocrInternalDocument: String? = null,
)
