"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from .document import Document, DocumentTypedDict
from abbyy_document_ai.types import BaseModel
from enum import Enum
import pydantic
from typing import List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class Rotated(str, Enum):
    r"""Rotation of the page relative to the original image."""

    NONE = "none"
    CLOCKWISE = "clockwise"
    COUNTERCLOCKWISE = "counterclockwise"
    UPSIDE_DOWN = "upside-down"


class PositionTypedDict(TypedDict):
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    l: NotRequired[int]
    r"""Left coordinate."""
    t: NotRequired[int]
    r"""Top coordinate."""
    r: NotRequired[int]
    r"""Right coordinate."""
    b: NotRequired[int]
    r"""Bottom coordinate."""


class Position(BaseModel):
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    l: Optional[int] = None
    r"""Left coordinate."""

    t: Optional[int] = None
    r"""Top coordinate."""

    r: Optional[int] = None
    r"""Right coordinate."""

    b: Optional[int] = None
    r"""Bottom coordinate."""


class ExtractedTextTextLayoutPagesTextsPositionTypedDict(TypedDict):
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    l: NotRequired[int]
    r"""Left coordinate."""
    t: NotRequired[int]
    r"""Top coordinate."""
    r: NotRequired[int]
    r"""Right coordinate."""
    b: NotRequired[int]
    r"""Bottom coordinate."""


class ExtractedTextTextLayoutPagesTextsPosition(BaseModel):
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    l: Optional[int] = None
    r"""Left coordinate."""

    t: Optional[int] = None
    r"""Top coordinate."""

    r: Optional[int] = None
    r"""Right coordinate."""

    b: Optional[int] = None
    r"""Bottom coordinate."""


class CharParamsTypedDict(TypedDict):
    r"""Symbol font formatting parameters."""

    bold: NotRequired[bool]
    italic: NotRequired[bool]
    underlined: NotRequired[bool]
    strikeout: NotRequired[bool]
    small_caps: NotRequired[bool]
    superscript: NotRequired[bool]
    subscript: NotRequired[bool]
    scaling: NotRequired[int]
    spacing: NotRequired[int]
    font_size: NotRequired[int]
    font_name: NotRequired[str]
    color: NotRequired[str]
    lang: NotRequired[str]


class CharParams(BaseModel):
    r"""Symbol font formatting parameters."""

    bold: Optional[bool] = None

    italic: Optional[bool] = None

    underlined: Optional[bool] = None

    strikeout: Optional[bool] = None

    small_caps: Annotated[Optional[bool], pydantic.Field(alias="smallCaps")] = None

    superscript: Optional[bool] = None

    subscript: Optional[bool] = None

    scaling: Optional[int] = None

    spacing: Optional[int] = None

    font_size: Annotated[Optional[int], pydantic.Field(alias="fontSize")] = None

    font_name: Annotated[Optional[str], pydantic.Field(alias="fontName")] = None

    color: Optional[str] = None

    lang: Optional[str] = None


class ExtractedTextTextLayoutPagesTextsLinesPositionTypedDict(TypedDict):
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    l: NotRequired[int]
    r"""Left coordinate."""
    t: NotRequired[int]
    r"""Top coordinate."""
    r: NotRequired[int]
    r"""Right coordinate."""
    b: NotRequired[int]
    r"""Bottom coordinate."""


class ExtractedTextTextLayoutPagesTextsLinesPosition(BaseModel):
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    l: Optional[int] = None
    r"""Left coordinate."""

    t: Optional[int] = None
    r"""Top coordinate."""

    r: Optional[int] = None
    r"""Right coordinate."""

    b: Optional[int] = None
    r"""Bottom coordinate."""


class ExtractedTextTextLayoutPagesTextsLinesWordsPositionTypedDict(TypedDict):
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    l: NotRequired[int]
    r"""Left coordinate."""
    t: NotRequired[int]
    r"""Top coordinate."""
    r: NotRequired[int]
    r"""Right coordinate."""
    b: NotRequired[int]
    r"""Bottom coordinate."""


class ExtractedTextTextLayoutPagesTextsLinesWordsPosition(BaseModel):
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    l: Optional[int] = None
    r"""Left coordinate."""

    t: Optional[int] = None
    r"""Top coordinate."""

    r: Optional[int] = None
    r"""Right coordinate."""

    b: Optional[int] = None
    r"""Bottom coordinate."""


class CharsTypedDict(TypedDict):
    confidence: NotRequired[float]
    r"""Confidence."""
    text: NotRequired[str]
    position: NotRequired[ExtractedTextTextLayoutPagesTextsLinesWordsPositionTypedDict]
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""


class Chars(BaseModel):
    confidence: Optional[float] = None
    r"""Confidence."""

    text: Optional[str] = None

    position: Optional[ExtractedTextTextLayoutPagesTextsLinesWordsPosition] = None
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""


class WordsTypedDict(TypedDict):
    r"""An array of words in a line of text ordered by reading direction."""

    confidence: NotRequired[float]
    r"""Confidence."""
    position: NotRequired[ExtractedTextTextLayoutPagesTextsLinesPositionTypedDict]
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""
    text: NotRequired[str]
    chars: NotRequired[List[CharsTypedDict]]


class Words(BaseModel):
    r"""An array of words in a line of text ordered by reading direction."""

    confidence: Optional[float] = None
    r"""Confidence."""

    position: Optional[ExtractedTextTextLayoutPagesTextsLinesPosition] = None
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    text: Optional[str] = None

    chars: Optional[List[Chars]] = None


class LinesTypedDict(TypedDict):
    r"""A line of text."""

    confidence: NotRequired[float]
    r"""Confidence."""
    position: NotRequired[ExtractedTextTextLayoutPagesTextsPositionTypedDict]
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""
    text: NotRequired[str]
    r"""A line of text value."""
    char_params: NotRequired[CharParamsTypedDict]
    r"""Symbol font formatting parameters."""
    words: NotRequired[List[WordsTypedDict]]


class Lines(BaseModel):
    r"""A line of text."""

    confidence: Optional[float] = None
    r"""Confidence."""

    position: Optional[ExtractedTextTextLayoutPagesTextsPosition] = None
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    text: Optional[str] = None
    r"""A line of text value."""

    char_params: Annotated[Optional[CharParams], pydantic.Field(alias="charParams")] = (
        None
    )
    r"""Symbol font formatting parameters."""

    words: Optional[List[Words]] = None


class TextsTypedDict(TypedDict):
    r"""Text."""

    id: NotRequired[str]
    r"""Text block ID."""
    position: NotRequired[PositionTypedDict]
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""
    lines: NotRequired[List[LinesTypedDict]]
    r"""An array of text strings in the text block ordered by reading direction."""
    confidence: NotRequired[float]
    r"""Confidence."""


class Texts(BaseModel):
    r"""Text."""

    id: Optional[str] = None
    r"""Text block ID."""

    position: Optional[Position] = None
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    lines: Optional[List[Lines]] = None
    r"""An array of text strings in the text block ordered by reading direction."""

    confidence: Optional[float] = None
    r"""Confidence."""


class ExtractedTextPositionTypedDict(TypedDict):
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    l: NotRequired[int]
    r"""Left coordinate."""
    t: NotRequired[int]
    r"""Top coordinate."""
    r: NotRequired[int]
    r"""Right coordinate."""
    b: NotRequired[int]
    r"""Bottom coordinate."""


class ExtractedTextPosition(BaseModel):
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    l: Optional[int] = None
    r"""Left coordinate."""

    t: Optional[int] = None
    r"""Top coordinate."""

    r: Optional[int] = None
    r"""Right coordinate."""

    b: Optional[int] = None
    r"""Bottom coordinate."""


class ExtractedTextTextLayoutPagesTablesPositionTypedDict(TypedDict):
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    l: NotRequired[int]
    r"""Left coordinate."""
    t: NotRequired[int]
    r"""Top coordinate."""
    r: NotRequired[int]
    r"""Right coordinate."""
    b: NotRequired[int]
    r"""Bottom coordinate."""


class ExtractedTextTextLayoutPagesTablesPosition(BaseModel):
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    l: Optional[int] = None
    r"""Left coordinate."""

    t: Optional[int] = None
    r"""Top coordinate."""

    r: Optional[int] = None
    r"""Right coordinate."""

    b: Optional[int] = None
    r"""Bottom coordinate."""


class ColRowPositionTypedDict(TypedDict):
    r"""Cell coordinate in the Column-Row system {l:leftColumn, t:topRow, r:rightColumn, b:bottomRow}"""

    l: int
    r"""Left separator index."""
    t: int
    r"""Top separator index."""
    r: int
    r"""Right separator index."""
    b: int
    r"""Bottom separator index."""


class ColRowPosition(BaseModel):
    r"""Cell coordinate in the Column-Row system {l:leftColumn, t:topRow, r:rightColumn, b:bottomRow}"""

    l: int
    r"""Left separator index."""

    t: int
    r"""Top separator index."""

    r: int
    r"""Right separator index."""

    b: int
    r"""Bottom separator index."""


class L(str, Enum):
    UNKNOWN = "unknown"
    INVISIBLE = "invisible"
    VISIBLE = "visible"


class T(str, Enum):
    UNKNOWN = "unknown"
    INVISIBLE = "invisible"
    VISIBLE = "visible"


class R(str, Enum):
    UNKNOWN = "unknown"
    INVISIBLE = "invisible"
    VISIBLE = "visible"


class B(str, Enum):
    UNKNOWN = "unknown"
    INVISIBLE = "invisible"
    VISIBLE = "visible"


class BordersTypedDict(TypedDict):
    r"""Table cell border types {l:left, t:top, r:right, b:bottom}"""

    l: NotRequired[L]
    t: NotRequired[T]
    r: NotRequired[R]
    b: NotRequired[B]


class Borders(BaseModel):
    r"""Table cell border types {l:left, t:top, r:right, b:bottom}"""

    l: Optional[L] = None

    t: Optional[T] = None

    r: Optional[R] = None

    b: Optional[B] = None


class ContentType(str, Enum):
    r"""Table cell content type: [text, picture, barcode]."""

    TEXT = "text"
    PICTURE = "picture"
    BARCODE = "barcode"


class ExtractedTextTextLayoutPagesTablesCellsPositionTypedDict(TypedDict):
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    l: NotRequired[int]
    r"""Left coordinate."""
    t: NotRequired[int]
    r"""Top coordinate."""
    r: NotRequired[int]
    r"""Right coordinate."""
    b: NotRequired[int]
    r"""Bottom coordinate."""


class ExtractedTextTextLayoutPagesTablesCellsPosition(BaseModel):
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    l: Optional[int] = None
    r"""Left coordinate."""

    t: Optional[int] = None
    r"""Top coordinate."""

    r: Optional[int] = None
    r"""Right coordinate."""

    b: Optional[int] = None
    r"""Bottom coordinate."""


class ExtractedTextCharParamsTypedDict(TypedDict):
    r"""Symbol font formatting parameters."""

    bold: NotRequired[bool]
    italic: NotRequired[bool]
    underlined: NotRequired[bool]
    strikeout: NotRequired[bool]
    small_caps: NotRequired[bool]
    superscript: NotRequired[bool]
    subscript: NotRequired[bool]
    scaling: NotRequired[int]
    spacing: NotRequired[int]
    font_size: NotRequired[int]
    font_name: NotRequired[str]
    color: NotRequired[str]
    lang: NotRequired[str]


class ExtractedTextCharParams(BaseModel):
    r"""Symbol font formatting parameters."""

    bold: Optional[bool] = None

    italic: Optional[bool] = None

    underlined: Optional[bool] = None

    strikeout: Optional[bool] = None

    small_caps: Annotated[Optional[bool], pydantic.Field(alias="smallCaps")] = None

    superscript: Optional[bool] = None

    subscript: Optional[bool] = None

    scaling: Optional[int] = None

    spacing: Optional[int] = None

    font_size: Annotated[Optional[int], pydantic.Field(alias="fontSize")] = None

    font_name: Annotated[Optional[str], pydantic.Field(alias="fontName")] = None

    color: Optional[str] = None

    lang: Optional[str] = None


class ExtractedTextTextLayoutPagesTablesCellsLinesPositionTypedDict(TypedDict):
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    l: NotRequired[int]
    r"""Left coordinate."""
    t: NotRequired[int]
    r"""Top coordinate."""
    r: NotRequired[int]
    r"""Right coordinate."""
    b: NotRequired[int]
    r"""Bottom coordinate."""


class ExtractedTextTextLayoutPagesTablesCellsLinesPosition(BaseModel):
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    l: Optional[int] = None
    r"""Left coordinate."""

    t: Optional[int] = None
    r"""Top coordinate."""

    r: Optional[int] = None
    r"""Right coordinate."""

    b: Optional[int] = None
    r"""Bottom coordinate."""


class ExtractedTextTextLayoutPagesTablesCellsLinesWordsPositionTypedDict(TypedDict):
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    l: NotRequired[int]
    r"""Left coordinate."""
    t: NotRequired[int]
    r"""Top coordinate."""
    r: NotRequired[int]
    r"""Right coordinate."""
    b: NotRequired[int]
    r"""Bottom coordinate."""


class ExtractedTextTextLayoutPagesTablesCellsLinesWordsPosition(BaseModel):
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    l: Optional[int] = None
    r"""Left coordinate."""

    t: Optional[int] = None
    r"""Top coordinate."""

    r: Optional[int] = None
    r"""Right coordinate."""

    b: Optional[int] = None
    r"""Bottom coordinate."""


class ExtractedTextCharsTypedDict(TypedDict):
    confidence: NotRequired[float]
    r"""Confidence."""
    text: NotRequired[str]
    position: NotRequired[
        ExtractedTextTextLayoutPagesTablesCellsLinesWordsPositionTypedDict
    ]
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""


class ExtractedTextChars(BaseModel):
    confidence: Optional[float] = None
    r"""Confidence."""

    text: Optional[str] = None

    position: Optional[ExtractedTextTextLayoutPagesTablesCellsLinesWordsPosition] = None
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""


class ExtractedTextWordsTypedDict(TypedDict):
    r"""An array of words in a line of text ordered by reading direction."""

    confidence: NotRequired[float]
    r"""Confidence."""
    position: NotRequired[ExtractedTextTextLayoutPagesTablesCellsLinesPositionTypedDict]
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""
    text: NotRequired[str]
    chars: NotRequired[List[ExtractedTextCharsTypedDict]]


class ExtractedTextWords(BaseModel):
    r"""An array of words in a line of text ordered by reading direction."""

    confidence: Optional[float] = None
    r"""Confidence."""

    position: Optional[ExtractedTextTextLayoutPagesTablesCellsLinesPosition] = None
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    text: Optional[str] = None

    chars: Optional[List[ExtractedTextChars]] = None


class ExtractedTextLinesTypedDict(TypedDict):
    r"""A line of text."""

    confidence: NotRequired[float]
    r"""Confidence."""
    position: NotRequired[ExtractedTextTextLayoutPagesTablesCellsPositionTypedDict]
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""
    text: NotRequired[str]
    r"""A line of text value."""
    char_params: NotRequired[ExtractedTextCharParamsTypedDict]
    r"""Symbol font formatting parameters."""
    words: NotRequired[List[ExtractedTextWordsTypedDict]]


class ExtractedTextLines(BaseModel):
    r"""A line of text."""

    confidence: Optional[float] = None
    r"""Confidence."""

    position: Optional[ExtractedTextTextLayoutPagesTablesCellsPosition] = None
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    text: Optional[str] = None
    r"""A line of text value."""

    char_params: Annotated[
        Optional[ExtractedTextCharParams], pydantic.Field(alias="charParams")
    ] = None
    r"""Symbol font formatting parameters."""

    words: Optional[List[ExtractedTextWords]] = None


class CellsTypedDict(TypedDict):
    r"""Table cell."""

    id: NotRequired[str]
    r"""Table cell ID."""
    position: NotRequired[ExtractedTextTextLayoutPagesTablesPositionTypedDict]
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""
    confidence: NotRequired[float]
    r"""Confidence."""
    col_row_position: NotRequired[ColRowPositionTypedDict]
    r"""Cell coordinate in the Column-Row system {l:leftColumn, t:topRow, r:rightColumn, b:bottomRow}"""
    borders: NotRequired[BordersTypedDict]
    r"""Table cell border types {l:left, t:top, r:right, b:bottom}"""
    content_type: NotRequired[ContentType]
    r"""Table cell content type: [text, picture, barcode]."""
    lines: NotRequired[List[ExtractedTextLinesTypedDict]]
    r"""An array of text strings in the text block ordered by reading direction."""


class Cells(BaseModel):
    r"""Table cell."""

    id: Optional[str] = None
    r"""Table cell ID."""

    position: Optional[ExtractedTextTextLayoutPagesTablesPosition] = None
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    confidence: Optional[float] = None
    r"""Confidence."""

    col_row_position: Annotated[
        Optional[ColRowPosition], pydantic.Field(alias="colRowPosition")
    ] = None
    r"""Cell coordinate in the Column-Row system {l:leftColumn, t:topRow, r:rightColumn, b:bottomRow}"""

    borders: Optional[Borders] = None
    r"""Table cell border types {l:left, t:top, r:right, b:bottom}"""

    content_type: Annotated[
        Optional[ContentType], pydantic.Field(alias="contentType")
    ] = None
    r"""Table cell content type: [text, picture, barcode]."""

    lines: Optional[List[ExtractedTextLines]] = None
    r"""An array of text strings in the text block ordered by reading direction."""


class TablesTypedDict(TypedDict):
    r"""Table."""

    id: NotRequired[str]
    r"""Table block ID."""
    confidence: NotRequired[float]
    r"""Confidence."""
    position: NotRequired[ExtractedTextPositionTypedDict]
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""
    cells: NotRequired[List[CellsTypedDict]]
    r"""Table cells."""


class Tables(BaseModel):
    r"""Table."""

    id: Optional[str] = None
    r"""Table block ID."""

    confidence: Optional[float] = None
    r"""Confidence."""

    position: Optional[ExtractedTextPosition] = None
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    cells: Optional[List[Cells]] = None
    r"""Table cells."""


class ExtractedTextTextPositionTypedDict(TypedDict):
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    l: NotRequired[int]
    r"""Left coordinate."""
    t: NotRequired[int]
    r"""Top coordinate."""
    r: NotRequired[int]
    r"""Right coordinate."""
    b: NotRequired[int]
    r"""Bottom coordinate."""


class ExtractedTextTextPosition(BaseModel):
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    l: Optional[int] = None
    r"""Left coordinate."""

    t: Optional[int] = None
    r"""Top coordinate."""

    r: Optional[int] = None
    r"""Right coordinate."""

    b: Optional[int] = None
    r"""Bottom coordinate."""


class Value(str, Enum):
    CHECKED = "checked"
    UNCHECKED = "unchecked"
    CORRECTED = "corrected"
    UNKNOWN = "unknown"


class CheckmarksTypedDict(TypedDict):
    position: NotRequired[ExtractedTextTextPositionTypedDict]
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""
    confidence: NotRequired[float]
    r"""Confidence."""
    value: NotRequired[Value]


class Checkmarks(BaseModel):
    position: Optional[ExtractedTextTextPosition] = None
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    confidence: Optional[float] = None
    r"""Confidence."""

    value: Optional[Value] = None


class ExtractedTextTextLayoutPositionTypedDict(TypedDict):
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    l: NotRequired[int]
    r"""Left coordinate."""
    t: NotRequired[int]
    r"""Top coordinate."""
    r: NotRequired[int]
    r"""Right coordinate."""
    b: NotRequired[int]
    r"""Bottom coordinate."""


class ExtractedTextTextLayoutPosition(BaseModel):
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    l: Optional[int] = None
    r"""Left coordinate."""

    t: Optional[int] = None
    r"""Top coordinate."""

    r: Optional[int] = None
    r"""Right coordinate."""

    b: Optional[int] = None
    r"""Bottom coordinate."""


class ExtractedTextTextType(str, Enum):
    r"""Barcode type."""

    CODE39 = "Code39"
    INTERLEAVED25 = "Interleaved25"
    EAN13 = "EAN13"
    CODE128 = "Code128"
    EAN8 = "EAN8"
    PDF417 = "PDF417"
    CODABAR = "Codabar"
    UPCE = "UPCE"
    INDUSTRIAL25 = "Industrial25"
    IATA25 = "IATA25"
    MATRIX25 = "Matrix25"
    CODE93 = "Code93"
    POST_NET = "PostNet"
    UCC128 = "UCC128"
    PATCH = "Patch"
    AZTEC = "Aztec"
    DATA_MATRIX = "DataMatrix"
    QR_CODE = "QRCode"
    UPCA = "UPCA"
    MAXI_CODE = "MaxiCode"
    CODE32 = "Code32"
    FULL_ASCII = "FullAscii"
    INTELLIGENT_MAIL = "IntelligentMail"
    ROYAL_MAIL4_STATE = "RoyalMail4State"
    KIX = "KIX"
    AUSTRALIA4_STATE = "Australia4State"
    JAPAN_POST = "JapanPost"
    NOT_FOUND = "NotFound"


class SupplementType(str, Enum):
    r"""Supplement type."""

    NONE = "none"
    TWODIGITS = "2digits"
    FIVEDIGITS = "5digits"


class BarcodesTypedDict(TypedDict):
    r"""Barcode."""

    id: NotRequired[str]
    r"""Barcode block ID."""
    confidence: NotRequired[float]
    r"""Confidence."""
    position: NotRequired[ExtractedTextTextLayoutPositionTypedDict]
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""
    type: NotRequired[ExtractedTextTextType]
    r"""Barcode type."""
    value: NotRequired[str]
    r"""Barcode value."""
    supplement_value: NotRequired[str]
    r"""Supplement value."""
    supplement_type: NotRequired[SupplementType]
    r"""Supplement type."""


class Barcodes(BaseModel):
    r"""Barcode."""

    id: Optional[str] = None
    r"""Barcode block ID."""

    confidence: Optional[float] = None
    r"""Confidence."""

    position: Optional[ExtractedTextTextLayoutPosition] = None
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    type: Optional[ExtractedTextTextType] = None
    r"""Barcode type."""

    value: Optional[str] = None
    r"""Barcode value."""

    supplement_value: Annotated[
        Optional[str], pydantic.Field(alias="supplementValue")
    ] = None
    r"""Supplement value."""

    supplement_type: Annotated[
        Optional[SupplementType], pydantic.Field(alias="supplementType")
    ] = None
    r"""Supplement type."""


class ExtractedTextTextLayoutPagesPositionTypedDict(TypedDict):
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    l: NotRequired[int]
    r"""Left coordinate."""
    t: NotRequired[int]
    r"""Top coordinate."""
    r: NotRequired[int]
    r"""Right coordinate."""
    b: NotRequired[int]
    r"""Bottom coordinate."""


class ExtractedTextTextLayoutPagesPosition(BaseModel):
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    l: Optional[int] = None
    r"""Left coordinate."""

    t: Optional[int] = None
    r"""Top coordinate."""

    r: Optional[int] = None
    r"""Right coordinate."""

    b: Optional[int] = None
    r"""Bottom coordinate."""


class PicturesTypedDict(TypedDict):
    r"""Block with image."""

    confidence: NotRequired[float]
    r"""Confidence."""
    id: NotRequired[str]
    r"""Picture block ID."""
    position: NotRequired[ExtractedTextTextLayoutPagesPositionTypedDict]
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""


class Pictures(BaseModel):
    r"""Block with image."""

    confidence: Optional[float] = None
    r"""Confidence."""

    id: Optional[str] = None
    r"""Picture block ID."""

    position: Optional[ExtractedTextTextLayoutPagesPosition] = None
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""


class ExtractedTextTextLayoutPagesSeparatorsPositionTypedDict(TypedDict):
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    l: NotRequired[int]
    r"""Left coordinate."""
    t: NotRequired[int]
    r"""Top coordinate."""
    r: NotRequired[int]
    r"""Right coordinate."""
    b: NotRequired[int]
    r"""Bottom coordinate."""


class ExtractedTextTextLayoutPagesSeparatorsPosition(BaseModel):
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    l: Optional[int] = None
    r"""Left coordinate."""

    t: Optional[int] = None
    r"""Top coordinate."""

    r: Optional[int] = None
    r"""Right coordinate."""

    b: Optional[int] = None
    r"""Bottom coordinate."""


class ExtractedTextType(str, Enum):
    r"""Separator type."""

    SOLID = "solid"
    UNKNOWN = "unknown"
    DOTTED = "dotted"


class EndPointsTypedDict(TypedDict):
    start_x: NotRequired[int]
    r"""Start point X-coordinate."""
    start_y: NotRequired[int]
    r"""Start point Y-coordinate."""
    end_x: NotRequired[int]
    r"""End point X-coordinate."""
    end_y: NotRequired[int]
    r"""End point Y-coordinate."""


class EndPoints(BaseModel):
    start_x: Annotated[Optional[int], pydantic.Field(alias="startX")] = None
    r"""Start point X-coordinate."""

    start_y: Annotated[Optional[int], pydantic.Field(alias="startY")] = None
    r"""Start point Y-coordinate."""

    end_x: Annotated[Optional[int], pydantic.Field(alias="endX")] = None
    r"""End point X-coordinate."""

    end_y: Annotated[Optional[int], pydantic.Field(alias="endY")] = None
    r"""End point Y-coordinate."""


class SeparatorsTypedDict(TypedDict):
    r"""Separator."""

    confidence: NotRequired[float]
    r"""Confidence."""
    position: NotRequired[ExtractedTextTextLayoutPagesSeparatorsPositionTypedDict]
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""
    type: NotRequired[ExtractedTextType]
    r"""Separator type."""
    color: NotRequired[int]
    r"""Separator color."""
    thickness: NotRequired[int]
    r"""Separator thickness."""
    end_points: NotRequired[EndPointsTypedDict]


class Separators(BaseModel):
    r"""Separator."""

    confidence: Optional[float] = None
    r"""Confidence."""

    position: Optional[ExtractedTextTextLayoutPagesSeparatorsPosition] = None
    r"""Rectangle {r:left, t:top, r:right, b:bottom}"""

    type: Optional[ExtractedTextType] = None
    r"""Separator type."""

    color: Optional[int] = None
    r"""Separator color."""

    thickness: Optional[int] = None
    r"""Separator thickness."""

    end_points: Annotated[Optional[EndPoints], pydantic.Field(alias="endPoints")] = None


class PagesTypedDict(TypedDict):
    r"""Document page."""

    width: NotRequired[float]
    r"""The width of the page in pixels."""
    height: NotRequired[float]
    r"""The height of the page in points."""
    rotated: NotRequired[Rotated]
    r"""Rotation of the page relative to the original image."""
    texts: NotRequired[List[TextsTypedDict]]
    r"""An array of blocks with text."""
    tables: NotRequired[List[TablesTypedDict]]
    r"""An array of blocks with a table."""
    checkmarks: NotRequired[List[CheckmarksTypedDict]]
    barcodes: NotRequired[List[BarcodesTypedDict]]
    r"""Array of blocks with barcode."""
    pictures: NotRequired[List[PicturesTypedDict]]
    r"""Array of blocks with a picture."""
    separators: NotRequired[List[SeparatorsTypedDict]]
    r"""Array of blocks with separator."""


class Pages(BaseModel):
    r"""Document page."""

    width: Optional[float] = None
    r"""The width of the page in pixels."""

    height: Optional[float] = None
    r"""The height of the page in points."""

    rotated: Optional[Rotated] = None
    r"""Rotation of the page relative to the original image."""

    texts: Optional[List[Texts]] = None
    r"""An array of blocks with text."""

    tables: Optional[List[Tables]] = None
    r"""An array of blocks with a table."""

    checkmarks: Optional[List[Checkmarks]] = None

    barcodes: Optional[List[Barcodes]] = None
    r"""Array of blocks with barcode."""

    pictures: Optional[List[Pictures]] = None
    r"""Array of blocks with a picture."""

    separators: Optional[List[Separators]] = None
    r"""Array of blocks with separator."""


class LayoutTypedDict(TypedDict):
    r"""Layout (physical structure)."""

    pages: List[PagesTypedDict]
    r"""Array of document pages ordered from first to last."""
    corrected: NotRequired[bool]
    r"""Coordinates for the corrected image on the output."""


class Layout(BaseModel):
    r"""Layout (physical structure)."""

    pages: List[Pages]
    r"""Array of document pages ordered from first to last."""

    corrected: Optional[bool] = None
    r"""Coordinates for the corrected image on the output."""


class Role(str, Enum):
    r"""Paragraph role in the document."""

    OTHER = "other"
    TEXT = "text"
    HEADING = "heading"
    HEADING_NUMBER = "headingNumber"
    TABLE_OF_CONTENTS = "tableOfContents"
    TABLE_TEXT = "tableText"
    RUNNING_TITLE = "runningTitle"
    END_NOTE = "endNote"
    FOOT_NOTE = "footNote"
    TABLE_CAPTION = "tableCaption"
    TABLE_HEADING = "tableHeading"
    PICTURE_CAPTION = "pictureCaption"
    ARTEFACT = "artefact"


class Aligning(str, Enum):
    r"""Text aligning in the paragraph."""

    LEFT = "left"
    CENTER = "center"
    RIGHT = "right"
    JUSTIFIED = "justified"
    JUSTIFIED_FOR_ARABIC = "justifiedForArabic"


class FormattingTypedDict(TypedDict):
    r"""Paragraph formatting."""

    aligning: NotRequired[Aligning]
    r"""Text aligning in the paragraph."""
    line_spacing: NotRequired[int]
    r"""Paragraph line spacing."""


class Formatting(BaseModel):
    r"""Paragraph formatting."""

    aligning: Optional[Aligning] = None
    r"""Text aligning in the paragraph."""

    line_spacing: Annotated[Optional[int], pydantic.Field(alias="lineSpacing")] = 0
    r"""Paragraph line spacing."""


class BlockType(str, Enum):
    r"""Paragraph container type."""

    TEXT = "text"
    CELL = "cell"


class LayoutReferencesTypedDict(TypedDict):
    r"""Reference block/cell id, paragraph index and line range in the block/cell."""

    block_id: str
    r"""Containing text block or table cell ID."""
    block_type: BlockType
    r"""Paragraph container type."""
    section_index: int
    r"""Index of logical section on page (or -1 if there is no section containing the paragraph - like headers, footers etc.)."""
    column_index: int
    r"""Index of column in logical section (or -1 if there is no column containing the paragraph - like incuts, footnotes etc)."""
    line_numbering: bool
    r"""true if the paragraph is contained in line numbering area."""
    par_index: int
    r"""Paragraph index in block or table cell."""
    first_line: int
    r"""Index of the first line of the paragraph in block or table cell."""
    last_line: int
    r"""Index of the last line of the paragraph in block or table cell."""


class LayoutReferences(BaseModel):
    r"""Reference block/cell id, paragraph index and line range in the block/cell."""

    block_id: Annotated[str, pydantic.Field(alias="blockId")]
    r"""Containing text block or table cell ID."""

    block_type: Annotated[BlockType, pydantic.Field(alias="blockType")]
    r"""Paragraph container type."""

    section_index: Annotated[int, pydantic.Field(alias="sectionIndex")]
    r"""Index of logical section on page (or -1 if there is no section containing the paragraph - like headers, footers etc.)."""

    column_index: Annotated[int, pydantic.Field(alias="columnIndex")]
    r"""Index of column in logical section (or -1 if there is no column containing the paragraph - like incuts, footnotes etc)."""

    line_numbering: Annotated[bool, pydantic.Field(alias="lineNumbering")]
    r"""true if the paragraph is contained in line numbering area."""

    par_index: Annotated[int, pydantic.Field(alias="parIndex")]
    r"""Paragraph index in block or table cell."""

    first_line: Annotated[int, pydantic.Field(alias="firstLine")]
    r"""Index of the first line of the paragraph in block or table cell."""

    last_line: Annotated[int, pydantic.Field(alias="lastLine")]
    r"""Index of the last line of the paragraph in block or table cell."""


class ListReferenceTypedDict(TypedDict):
    r"""Reference to list containing the paragraph."""

    id: NotRequired[str]
    r"""List ID."""
    level_index: NotRequired[int]
    r"""Current list item level index."""
    ordinal_number: NotRequired[int]
    r"""Current list item ordinal number."""


class ListReference(BaseModel):
    r"""Reference to list containing the paragraph."""

    id: Optional[str] = None
    r"""List ID."""

    level_index: Annotated[Optional[int], pydantic.Field(alias="levelIndex")] = 0
    r"""Current list item level index."""

    ordinal_number: Annotated[Optional[int], pydantic.Field(alias="ordinalNumber")] = 0
    r"""Current list item ordinal number."""


class ParagraphsTypedDict(TypedDict):
    r"""Document paragraph."""

    id: NotRequired[str]
    r"""Paragraph ID of the document."""
    role: NotRequired[Role]
    r"""Paragraph role in the document."""
    formatting: NotRequired[FormattingTypedDict]
    r"""Paragraph formatting."""
    layout_references: NotRequired[List[LayoutReferencesTypedDict]]
    r"""An array of document paragraph parts sources in the page block structure, in the order of the text in the paragraph."""
    text: NotRequired[str]
    r"""Paragraph text."""
    list_reference: NotRequired[ListReferenceTypedDict]
    r"""Reference to list containing the paragraph."""


class Paragraphs(BaseModel):
    r"""Document paragraph."""

    id: Optional[str] = None
    r"""Paragraph ID of the document."""

    role: Optional[Role] = None
    r"""Paragraph role in the document."""

    formatting: Optional[Formatting] = None
    r"""Paragraph formatting."""

    layout_references: Annotated[
        Optional[List[LayoutReferences]], pydantic.Field(alias="layoutReferences")
    ] = None
    r"""An array of document paragraph parts sources in the page block structure, in the order of the text in the paragraph."""

    text: Optional[str] = None
    r"""Paragraph text."""

    list_reference: Annotated[
        Optional[ListReference], pydantic.Field(alias="listReference")
    ] = None
    r"""Reference to list containing the paragraph."""


class NumberingStyle(str, Enum):
    r"""List numbering style."""

    NONE = "None"
    DECIMAL = "Decimal"
    UPPER_ROMAN = "UpperRoman"
    LOWER_ROMAN = "LowerRoman"
    UPPER_LETTER = "UpperLetter"
    LOWER_LETTER = "LowerLetter"
    ORDINAL = "Ordinal"
    CARDINAL_TEXT = "CardinalText"
    ORDINAL_TEXT = "OrdinalText"
    HEX = "Hex"
    CHICAGO = "Chicago"
    IDEOGRAPH_DIGITAL = "IdeographDigital"
    JAPANESE_COUNTING = "JapaneseCounting"
    AIUEO = "Aiueo"
    IROHA = "Iroha"
    DECIMAL_FULL_WIDTH = "DecimalFullWidth"
    DECIMAL_HALF_WIDTH = "DecimalHalfWidth"
    JAPANESE_LEGAL = "JapaneseLegal"
    JAPANESE_DIGITAL_TEN_THOUSAND = "JapaneseDigitalTenThousand"
    DECIMAL_ENCLOSED_CIRCLE = "DecimalEnclosedCircle"
    DECIMAL_FULL_WIDTH2 = "DecimalFullWidth2"
    AIUEO_FULL_WIDTH = "AiueoFullWidth"
    IROHA_FULL_WIDTH = "IrohaFullWidth"
    DECIMAL_ZERO = "DecimalZero"
    BULLET = "Bullet"
    GANADA = "Ganada"
    CHOSUNG = "Chosung"
    DECIMAL_ENCLOSED_FULLSTOP = "DecimalEnclosedFullstop"
    DECIMAL_ENCLOSED_PAREN = "DecimalEnclosedParen"
    DECIMAL_ENCLOSED_CIRCLE_CHINESE = "DecimalEnclosedCircleChinese"
    IDEOGRAPH_ENCLOSED_CIRCLE = "IdeographEnclosedCircle"
    IDEOGRAPH_TRADITIONAL = "IdeographTraditional"
    IDEOGRAPH_ZODIAC = "IdeographZodiac"
    IDEOGRAPH_ZODIAC_TRADITIONAL = "IdeographZodiacTraditional"
    TAIWANESE_COUNTING = "TaiwaneseCounting"
    IDEOGRAPH_LEGAL_TRADITIONAL = "IdeographLegalTraditional"
    TAIWANESE_COUNTING_THOUSAND = "TaiwaneseCountingThousand"
    TAIWANESE_DIGITAL = "TaiwaneseDigital"
    CHINESE_COUNTING = "ChineseCounting"
    CHINESE_LEGAL_SIMPLIFIED = "ChineseLegalSimplified"
    CHINESE_COUNTING_THOUSAND = "ChineseCountingThousand"
    APPLICATION_DEFINED = "ApplicationDefined"
    KOREAN_DIGITAL = "KoreanDigital"
    KOREAN_COUNTING = "KoreanCounting"
    KOREAN_LEGAL = "KoreanLegal"
    KOREAN_DIGITAL2 = "KoreanDigital2"
    HEBREW1 = "Hebrew1"
    ARABIC_ALPHA = "ArabicAlpha"
    HEBREW2 = "Hebrew2"
    ARABIC_ABJAD = "ArabicAbjad"
    HINDI_VOWELS = "HindiVowels"
    HINDI_CONSONANTS = "HindiConsonants"
    HINDI_NUMBERS = "HindiNumbers"
    HINDI_COUNTING = "HindiCounting"
    THAI_LETTERS = "ThaiLetters"
    THAI_NUMBERS = "ThaiNumbers"
    THAI_COUNTING = "ThaiCounting"
    VIETNAMESE_COUNTING = "VietnameseCounting"
    NUMBER_IN_DASH = "NumberInDash"
    RUSSIAN_LOWER = "RussianLower"
    RUSSIAN_UPPER = "RussianUpper"
    BURMESE = "Burmese"
    UNNUMBERED = "Unnumbered"


class ListLevelsTypedDict(TypedDict):
    r"""List level desctiption"""

    level_index: int
    r"""Level index."""
    numbering_style: NumberingStyle
    r"""List numbering style."""
    start_number: int
    r"""Start number."""


class ListLevels(BaseModel):
    r"""List level desctiption"""

    level_index: Annotated[int, pydantic.Field(alias="levelIndex")]
    r"""Level index."""

    numbering_style: Annotated[NumberingStyle, pydantic.Field(alias="numberingStyle")]
    r"""List numbering style."""

    start_number: Annotated[int, pydantic.Field(alias="startNumber")]
    r"""Start number."""


class ListsTypedDict(TypedDict):
    r"""List description."""

    id: NotRequired[str]
    r"""List ID in the document."""
    list_levels: NotRequired[List[ListLevelsTypedDict]]
    r"""An array of list level descriptions."""


class Lists(BaseModel):
    r"""List description."""

    id: Optional[str] = None
    r"""List ID in the document."""

    list_levels: Annotated[
        Optional[List[ListLevels]], pydantic.Field(alias="listLevels")
    ] = None
    r"""An array of list level descriptions."""


class ContentTypedDict(TypedDict):
    r"""Document content (logical structure)."""

    paragraphs: NotRequired[List[ParagraphsTypedDict]]
    r"""An array of document paragraphs ordered by reading direction."""
    lists: NotRequired[List[ListsTypedDict]]
    r"""An array of lists found in the document."""


class Content(BaseModel):
    r"""Document content (logical structure)."""

    paragraphs: Optional[List[Paragraphs]] = None
    r"""An array of document paragraphs ordered by reading direction."""

    lists: Optional[List[Lists]] = None
    r"""An array of lists found in the document."""


class TextTypedDict(TypedDict):
    languages: List[str]
    r"""List of document languages."""
    layout: NotRequired[LayoutTypedDict]
    r"""Layout (physical structure)."""
    content: NotRequired[ContentTypedDict]
    r"""Document content (logical structure)."""


class Text(BaseModel):
    languages: List[str]
    r"""List of document languages."""

    layout: Optional[Layout] = None
    r"""Layout (physical structure)."""

    content: Optional[Content] = None
    r"""Document content (logical structure)."""


class ExtractedTextTypedDict(TypedDict):
    r"""The response from the `getExtractedText` endpoint."""

    meta: DocumentTypedDict
    r"""Represents a document that has been submitted for processing."""
    text: NotRequired[TextTypedDict]


class ExtractedText(BaseModel):
    r"""The response from the `getExtractedText` endpoint."""

    meta: Document
    r"""Represents a document that has been submitted for processing."""

    text: Optional[Text] = None
