# This file was auto-generated by Fern from our API Definition.

import typing

import pydantic
import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2
from ..core.serialization import FieldMetadata
from ..core.unchecked_base_model import UncheckedBaseModel
from .page_ranges import PageRanges
from .parse_config_advanced_options_excel_parsing_mode import ParseConfigAdvancedOptionsExcelParsingMode
from .parse_config_advanced_options_return_ocr import ParseConfigAdvancedOptionsReturnOcr


class ParseConfigAdvancedOptions(UncheckedBaseModel):
    page_rotation_enabled: typing_extensions.Annotated[
        typing.Optional[bool], FieldMetadata(alias="pageRotationEnabled")
    ] = pydantic.Field(alias="pageRotationEnabled", default=None)
    """
    Whether to automatically detect and correct page rotation.
    """

    page_ranges: typing_extensions.Annotated[typing.Optional[PageRanges], FieldMetadata(alias="pageRanges")] = (
        pydantic.Field(alias="pageRanges", default=None)
    )
    excel_parsing_mode: typing_extensions.Annotated[
        typing.Optional[ParseConfigAdvancedOptionsExcelParsingMode], FieldMetadata(alias="excelParsingMode")
    ] = pydantic.Field(alias="excelParsingMode", default=None)
    """
    Controls how Excel files are parsed.
    
    * `basic`: Fast, deterministic parsing.
    * `advanced`: Enable layout block detection for complex spreadsheets.
    
    For `.xls` files, `basic` mode is always used.
    """

    excel_skip_hidden_content: typing_extensions.Annotated[
        typing.Optional[bool], FieldMetadata(alias="excelSkipHiddenContent")
    ] = pydantic.Field(alias="excelSkipHiddenContent", default=None)
    """
    Whether to exclude hidden rows, columns, and sheets when parsing Excel files.
    """

    excel_use_raw_cell_values: typing_extensions.Annotated[
        typing.Optional[bool], FieldMetadata(alias="excelUseRawCellValues")
    ] = pydantic.Field(alias="excelUseRawCellValues", default=None)
    """
    Whether to return raw calculated cell values instead of locale-formatted values when parsing Excel files. Useful when downstream processing needs the underlying numeric or unformatted data.
    """

    excel_skip_calculation: typing_extensions.Annotated[
        typing.Optional[bool], FieldMetadata(alias="excelSkipCalculation")
    ] = pydantic.Field(alias="excelSkipCalculation", default=None)
    """
    Whether to skip formula recalculation when opening Excel workbooks. Significantly improves parsing speed for formula-heavy spreadsheets. Disable if cell values depend on volatile functions like NOW() or TODAY().
    """

    vertical_grouping_threshold: typing_extensions.Annotated[
        typing.Optional[float], FieldMetadata(alias="verticalGroupingThreshold")
    ] = pydantic.Field(alias="verticalGroupingThreshold", default=None)
    """
    Multiplier for the Y-axis threshold used to determine if text blocks should be placed on the same line or not (0.1-5.0, default 1.0). Higher values group elements that are further apart vertically. Only applies when the spatial target is set.
    """

    return_ocr: typing_extensions.Annotated[
        typing.Optional[ParseConfigAdvancedOptionsReturnOcr], FieldMetadata(alias="returnOcr")
    ] = pydantic.Field(alias="returnOcr", default=None)
    """
    Options for returning raw OCR data in the response.
    """

    always_convert_to_pdf: typing_extensions.Annotated[
        typing.Optional[bool], FieldMetadata(alias="alwaysConvertToPdf")
    ] = pydantic.Field(alias="alwaysConvertToPdf", default=None)
    """
    Whether to convert supported file types (images, Word documents, PowerPoint, Excel, HTML) to PDF before parsing. This can improve parsing quality for some file types and ensures spatial output with bounding boxes.
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
