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

from __future__ import annotations
from dataclasses import dataclass, field
from documenso_sdk.models import DocumensoError
from documenso_sdk.types import (
    BaseModel,
    Nullable,
    OptionalNullable,
    UNSET,
    UNSET_SENTINEL,
)
from enum import Enum
import httpx
import pydantic
from pydantic import model_serializer
from typing import Any, List, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict


class FieldCreateDocumentFieldTypeDropdownRequest1(str, Enum):
    DROPDOWN = "DROPDOWN"


class FieldCreateDocumentFieldTypeDropdownRequest2(str, Enum):
    DROPDOWN = "dropdown"


class FieldCreateDocumentFieldValueDropdownTypedDict(TypedDict):
    value: str


class FieldCreateDocumentFieldValueDropdown(BaseModel):
    value: str


class FieldCreateDocumentFieldFieldMetaDropdownRequestTypedDict(TypedDict):
    type: FieldCreateDocumentFieldTypeDropdownRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldCreateDocumentFieldValueDropdownTypedDict]]
    default_value: NotRequired[str]


class FieldCreateDocumentFieldFieldMetaDropdownRequest(BaseModel):
    type: FieldCreateDocumentFieldTypeDropdownRequest2

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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

    values: Optional[List[FieldCreateDocumentFieldValueDropdown]] = None

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


class FieldCreateDocumentFieldFieldDropdownTypedDict(TypedDict):
    type: FieldCreateDocumentFieldTypeDropdownRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateDocumentFieldFieldMetaDropdownRequestTypedDict]


class FieldCreateDocumentFieldFieldDropdown(BaseModel):
    type: FieldCreateDocumentFieldTypeDropdownRequest1

    recipient_id: Annotated[float, pydantic.Field(alias="recipientId")]

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float

    field_meta: Annotated[
        Optional[FieldCreateDocumentFieldFieldMetaDropdownRequest],
        pydantic.Field(alias="fieldMeta"),
    ] = None


class FieldCreateDocumentFieldTypeCheckboxRequest1(str, Enum):
    CHECKBOX = "CHECKBOX"


class FieldCreateDocumentFieldTypeCheckboxRequest2(str, Enum):
    CHECKBOX = "checkbox"


class FieldCreateDocumentFieldValueCheckboxTypedDict(TypedDict):
    id: float
    checked: bool
    value: str


class FieldCreateDocumentFieldValueCheckbox(BaseModel):
    id: float

    checked: bool

    value: str


class FieldCreateDocumentFieldDirectionCheckbox(str, Enum):
    VERTICAL = "vertical"
    HORIZONTAL = "horizontal"


class FieldCreateDocumentFieldFieldMetaCheckboxRequestTypedDict(TypedDict):
    type: FieldCreateDocumentFieldTypeCheckboxRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldCreateDocumentFieldValueCheckboxTypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[FieldCreateDocumentFieldDirectionCheckbox]


class FieldCreateDocumentFieldFieldMetaCheckboxRequest(BaseModel):
    type: FieldCreateDocumentFieldTypeCheckboxRequest2

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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

    values: Optional[List[FieldCreateDocumentFieldValueCheckbox]] = None

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

    validation_length: Annotated[
        Optional[float], pydantic.Field(alias="validationLength")
    ] = None

    direction: Optional[FieldCreateDocumentFieldDirectionCheckbox] = (
        FieldCreateDocumentFieldDirectionCheckbox.VERTICAL
    )


class FieldCreateDocumentFieldFieldCheckboxTypedDict(TypedDict):
    type: FieldCreateDocumentFieldTypeCheckboxRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateDocumentFieldFieldMetaCheckboxRequestTypedDict]


class FieldCreateDocumentFieldFieldCheckbox(BaseModel):
    type: FieldCreateDocumentFieldTypeCheckboxRequest1

    recipient_id: Annotated[float, pydantic.Field(alias="recipientId")]

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float

    field_meta: Annotated[
        Optional[FieldCreateDocumentFieldFieldMetaCheckboxRequest],
        pydantic.Field(alias="fieldMeta"),
    ] = None


class FieldCreateDocumentFieldTypeRadioRequest1(str, Enum):
    RADIO = "RADIO"


class FieldCreateDocumentFieldTypeRadioRequest2(str, Enum):
    RADIO = "radio"


class FieldCreateDocumentFieldValueRadioTypedDict(TypedDict):
    id: float
    checked: bool
    value: str


class FieldCreateDocumentFieldValueRadio(BaseModel):
    id: float

    checked: bool

    value: str


class FieldCreateDocumentFieldDirectionRadio(str, Enum):
    VERTICAL = "vertical"
    HORIZONTAL = "horizontal"


class FieldCreateDocumentFieldFieldMetaRadioRequestTypedDict(TypedDict):
    type: FieldCreateDocumentFieldTypeRadioRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldCreateDocumentFieldValueRadioTypedDict]]
    direction: NotRequired[FieldCreateDocumentFieldDirectionRadio]


class FieldCreateDocumentFieldFieldMetaRadioRequest(BaseModel):
    type: FieldCreateDocumentFieldTypeRadioRequest2

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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

    values: Optional[List[FieldCreateDocumentFieldValueRadio]] = None

    direction: Optional[FieldCreateDocumentFieldDirectionRadio] = (
        FieldCreateDocumentFieldDirectionRadio.VERTICAL
    )


class FieldCreateDocumentFieldFieldRadioTypedDict(TypedDict):
    type: FieldCreateDocumentFieldTypeRadioRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateDocumentFieldFieldMetaRadioRequestTypedDict]


class FieldCreateDocumentFieldFieldRadio(BaseModel):
    type: FieldCreateDocumentFieldTypeRadioRequest1

    recipient_id: Annotated[float, pydantic.Field(alias="recipientId")]

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float

    field_meta: Annotated[
        Optional[FieldCreateDocumentFieldFieldMetaRadioRequest],
        pydantic.Field(alias="fieldMeta"),
    ] = None


class FieldCreateDocumentFieldTypeNumberRequest1(str, Enum):
    NUMBER = "NUMBER"


class FieldCreateDocumentFieldTypeNumberRequest2(str, Enum):
    NUMBER = "number"


class FieldCreateDocumentFieldTextAlignNumber(str, Enum):
    LEFT = "left"
    CENTER = "center"
    RIGHT = "right"


class FieldCreateDocumentFieldVerticalAlignNumber(str, Enum):
    TOP = "top"
    MIDDLE = "middle"
    BOTTOM = "bottom"


class FieldCreateDocumentFieldFieldMetaNumberRequestTypedDict(TypedDict):
    type: FieldCreateDocumentFieldTypeNumberRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    number_format: NotRequired[Nullable[str]]
    value: NotRequired[str]
    min_value: NotRequired[Nullable[float]]
    max_value: NotRequired[Nullable[float]]
    text_align: NotRequired[FieldCreateDocumentFieldTextAlignNumber]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[FieldCreateDocumentFieldVerticalAlignNumber]]


class FieldCreateDocumentFieldFieldMetaNumberRequest(BaseModel):
    type: FieldCreateDocumentFieldTypeNumberRequest2

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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

    number_format: Annotated[
        OptionalNullable[str], pydantic.Field(alias="numberFormat")
    ] = UNSET

    value: Optional[str] = None

    min_value: Annotated[OptionalNullable[float], pydantic.Field(alias="minValue")] = (
        UNSET
    )

    max_value: Annotated[OptionalNullable[float], pydantic.Field(alias="maxValue")] = (
        UNSET
    )

    text_align: Annotated[
        Optional[FieldCreateDocumentFieldTextAlignNumber],
        pydantic.Field(alias="textAlign"),
    ] = None

    line_height: Annotated[
        OptionalNullable[float], pydantic.Field(alias="lineHeight")
    ] = UNSET

    letter_spacing: Annotated[
        OptionalNullable[float], pydantic.Field(alias="letterSpacing")
    ] = UNSET

    vertical_align: Annotated[
        OptionalNullable[FieldCreateDocumentFieldVerticalAlignNumber],
        pydantic.Field(alias="verticalAlign"),
    ] = UNSET

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "label",
            "placeholder",
            "required",
            "readOnly",
            "fontSize",
            "numberFormat",
            "value",
            "minValue",
            "maxValue",
            "textAlign",
            "lineHeight",
            "letterSpacing",
            "verticalAlign",
        ]
        nullable_fields = [
            "numberFormat",
            "minValue",
            "maxValue",
            "lineHeight",
            "letterSpacing",
            "verticalAlign",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class FieldCreateDocumentFieldFieldNumberTypedDict(TypedDict):
    type: FieldCreateDocumentFieldTypeNumberRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateDocumentFieldFieldMetaNumberRequestTypedDict]


class FieldCreateDocumentFieldFieldNumber(BaseModel):
    type: FieldCreateDocumentFieldTypeNumberRequest1

    recipient_id: Annotated[float, pydantic.Field(alias="recipientId")]

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float

    field_meta: Annotated[
        Optional[FieldCreateDocumentFieldFieldMetaNumberRequest],
        pydantic.Field(alias="fieldMeta"),
    ] = None


class FieldCreateDocumentFieldTypeTextRequest1(str, Enum):
    TEXT = "TEXT"


class FieldCreateDocumentFieldTypeTextRequest2(str, Enum):
    TEXT = "text"


class FieldCreateDocumentFieldTextAlignText(str, Enum):
    LEFT = "left"
    CENTER = "center"
    RIGHT = "right"


class FieldCreateDocumentFieldVerticalAlignText(str, Enum):
    TOP = "top"
    MIDDLE = "middle"
    BOTTOM = "bottom"


class FieldCreateDocumentFieldFieldMetaTextRequestTypedDict(TypedDict):
    type: FieldCreateDocumentFieldTypeTextRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text: NotRequired[str]
    character_limit: NotRequired[float]
    text_align: NotRequired[FieldCreateDocumentFieldTextAlignText]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[FieldCreateDocumentFieldVerticalAlignText]]


class FieldCreateDocumentFieldFieldMetaTextRequest(BaseModel):
    type: FieldCreateDocumentFieldTypeTextRequest2

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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

    text: Optional[str] = None

    character_limit: Annotated[
        Optional[float], pydantic.Field(alias="characterLimit")
    ] = None

    text_align: Annotated[
        Optional[FieldCreateDocumentFieldTextAlignText],
        pydantic.Field(alias="textAlign"),
    ] = None

    line_height: Annotated[
        OptionalNullable[float], pydantic.Field(alias="lineHeight")
    ] = UNSET

    letter_spacing: Annotated[
        OptionalNullable[float], pydantic.Field(alias="letterSpacing")
    ] = UNSET

    vertical_align: Annotated[
        OptionalNullable[FieldCreateDocumentFieldVerticalAlignText],
        pydantic.Field(alias="verticalAlign"),
    ] = UNSET

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "label",
            "placeholder",
            "required",
            "readOnly",
            "fontSize",
            "text",
            "characterLimit",
            "textAlign",
            "lineHeight",
            "letterSpacing",
            "verticalAlign",
        ]
        nullable_fields = ["lineHeight", "letterSpacing", "verticalAlign"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class FieldCreateDocumentFieldFieldTextTypedDict(TypedDict):
    type: FieldCreateDocumentFieldTypeTextRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateDocumentFieldFieldMetaTextRequestTypedDict]


class FieldCreateDocumentFieldFieldText(BaseModel):
    type: FieldCreateDocumentFieldTypeTextRequest1

    recipient_id: Annotated[float, pydantic.Field(alias="recipientId")]

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float

    field_meta: Annotated[
        Optional[FieldCreateDocumentFieldFieldMetaTextRequest],
        pydantic.Field(alias="fieldMeta"),
    ] = None


class FieldCreateDocumentFieldTypeDateRequest1(str, Enum):
    DATE = "DATE"


class FieldCreateDocumentFieldTypeDateRequest2(str, Enum):
    DATE = "date"


class FieldCreateDocumentFieldTextAlignDate(str, Enum):
    LEFT = "left"
    CENTER = "center"
    RIGHT = "right"


class FieldCreateDocumentFieldFieldMetaDateRequestTypedDict(TypedDict):
    type: FieldCreateDocumentFieldTypeDateRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateDocumentFieldTextAlignDate]


class FieldCreateDocumentFieldFieldMetaDateRequest(BaseModel):
    type: FieldCreateDocumentFieldTypeDateRequest2

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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

    text_align: Annotated[
        Optional[FieldCreateDocumentFieldTextAlignDate],
        pydantic.Field(alias="textAlign"),
    ] = None


class FieldCreateDocumentFieldFieldDateTypedDict(TypedDict):
    type: FieldCreateDocumentFieldTypeDateRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateDocumentFieldFieldMetaDateRequestTypedDict]


class FieldCreateDocumentFieldFieldDate(BaseModel):
    type: FieldCreateDocumentFieldTypeDateRequest1

    recipient_id: Annotated[float, pydantic.Field(alias="recipientId")]

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float

    field_meta: Annotated[
        Optional[FieldCreateDocumentFieldFieldMetaDateRequest],
        pydantic.Field(alias="fieldMeta"),
    ] = None


class FieldCreateDocumentFieldTypeEmailRequest1(str, Enum):
    EMAIL = "EMAIL"


class FieldCreateDocumentFieldTypeEmailRequest2(str, Enum):
    EMAIL = "email"


class FieldCreateDocumentFieldTextAlignEmail(str, Enum):
    LEFT = "left"
    CENTER = "center"
    RIGHT = "right"


class FieldCreateDocumentFieldFieldMetaEmailRequestTypedDict(TypedDict):
    type: FieldCreateDocumentFieldTypeEmailRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateDocumentFieldTextAlignEmail]


class FieldCreateDocumentFieldFieldMetaEmailRequest(BaseModel):
    type: FieldCreateDocumentFieldTypeEmailRequest2

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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

    text_align: Annotated[
        Optional[FieldCreateDocumentFieldTextAlignEmail],
        pydantic.Field(alias="textAlign"),
    ] = None


class FieldCreateDocumentFieldFieldEmailTypedDict(TypedDict):
    type: FieldCreateDocumentFieldTypeEmailRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateDocumentFieldFieldMetaEmailRequestTypedDict]


class FieldCreateDocumentFieldFieldEmail(BaseModel):
    type: FieldCreateDocumentFieldTypeEmailRequest1

    recipient_id: Annotated[float, pydantic.Field(alias="recipientId")]

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float

    field_meta: Annotated[
        Optional[FieldCreateDocumentFieldFieldMetaEmailRequest],
        pydantic.Field(alias="fieldMeta"),
    ] = None


class FieldCreateDocumentFieldTypeNameRequest1(str, Enum):
    NAME = "NAME"


class FieldCreateDocumentFieldTypeNameRequest2(str, Enum):
    NAME = "name"


class FieldCreateDocumentFieldTextAlignName(str, Enum):
    LEFT = "left"
    CENTER = "center"
    RIGHT = "right"


class FieldCreateDocumentFieldFieldMetaNameRequestTypedDict(TypedDict):
    type: FieldCreateDocumentFieldTypeNameRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateDocumentFieldTextAlignName]


class FieldCreateDocumentFieldFieldMetaNameRequest(BaseModel):
    type: FieldCreateDocumentFieldTypeNameRequest2

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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

    text_align: Annotated[
        Optional[FieldCreateDocumentFieldTextAlignName],
        pydantic.Field(alias="textAlign"),
    ] = None


class FieldCreateDocumentFieldFieldNameTypedDict(TypedDict):
    type: FieldCreateDocumentFieldTypeNameRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateDocumentFieldFieldMetaNameRequestTypedDict]


class FieldCreateDocumentFieldFieldName(BaseModel):
    type: FieldCreateDocumentFieldTypeNameRequest1

    recipient_id: Annotated[float, pydantic.Field(alias="recipientId")]

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float

    field_meta: Annotated[
        Optional[FieldCreateDocumentFieldFieldMetaNameRequest],
        pydantic.Field(alias="fieldMeta"),
    ] = None


class FieldCreateDocumentFieldTypeInitialsRequest1(str, Enum):
    INITIALS = "INITIALS"


class FieldCreateDocumentFieldTypeInitialsRequest2(str, Enum):
    INITIALS = "initials"


class FieldCreateDocumentFieldTextAlignInitials(str, Enum):
    LEFT = "left"
    CENTER = "center"
    RIGHT = "right"


class FieldCreateDocumentFieldFieldMetaInitialsRequestTypedDict(TypedDict):
    type: FieldCreateDocumentFieldTypeInitialsRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateDocumentFieldTextAlignInitials]


class FieldCreateDocumentFieldFieldMetaInitialsRequest(BaseModel):
    type: FieldCreateDocumentFieldTypeInitialsRequest2

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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

    text_align: Annotated[
        Optional[FieldCreateDocumentFieldTextAlignInitials],
        pydantic.Field(alias="textAlign"),
    ] = None


class FieldCreateDocumentFieldFieldInitialsTypedDict(TypedDict):
    type: FieldCreateDocumentFieldTypeInitialsRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateDocumentFieldFieldMetaInitialsRequestTypedDict]


class FieldCreateDocumentFieldFieldInitials(BaseModel):
    type: FieldCreateDocumentFieldTypeInitialsRequest1

    recipient_id: Annotated[float, pydantic.Field(alias="recipientId")]

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float

    field_meta: Annotated[
        Optional[FieldCreateDocumentFieldFieldMetaInitialsRequest],
        pydantic.Field(alias="fieldMeta"),
    ] = None


class FieldCreateDocumentFieldTypeFreeSignature(str, Enum):
    FREE_SIGNATURE = "FREE_SIGNATURE"


class FieldCreateDocumentFieldFieldFreeSignatureTypedDict(TypedDict):
    type: FieldCreateDocumentFieldTypeFreeSignature
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float


class FieldCreateDocumentFieldFieldFreeSignature(BaseModel):
    type: FieldCreateDocumentFieldTypeFreeSignature

    recipient_id: Annotated[float, pydantic.Field(alias="recipientId")]

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float


class FieldCreateDocumentFieldTypeSignatureRequest1(str, Enum):
    SIGNATURE = "SIGNATURE"


class FieldCreateDocumentFieldTypeSignatureRequest2(str, Enum):
    SIGNATURE = "signature"


class FieldCreateDocumentFieldFieldMetaSignatureRequestTypedDict(TypedDict):
    type: FieldCreateDocumentFieldTypeSignatureRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]


class FieldCreateDocumentFieldFieldMetaSignatureRequest(BaseModel):
    type: FieldCreateDocumentFieldTypeSignatureRequest2

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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


class FieldCreateDocumentFieldFieldSignatureTypedDict(TypedDict):
    type: FieldCreateDocumentFieldTypeSignatureRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateDocumentFieldFieldMetaSignatureRequestTypedDict]


class FieldCreateDocumentFieldFieldSignature(BaseModel):
    type: FieldCreateDocumentFieldTypeSignatureRequest1

    recipient_id: Annotated[float, pydantic.Field(alias="recipientId")]

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float

    field_meta: Annotated[
        Optional[FieldCreateDocumentFieldFieldMetaSignatureRequest],
        pydantic.Field(alias="fieldMeta"),
    ] = None


FieldCreateDocumentFieldFieldUnionTypedDict = TypeAliasType(
    "FieldCreateDocumentFieldFieldUnionTypedDict",
    Union[
        FieldCreateDocumentFieldFieldFreeSignatureTypedDict,
        FieldCreateDocumentFieldFieldSignatureTypedDict,
        FieldCreateDocumentFieldFieldInitialsTypedDict,
        FieldCreateDocumentFieldFieldNameTypedDict,
        FieldCreateDocumentFieldFieldEmailTypedDict,
        FieldCreateDocumentFieldFieldDateTypedDict,
        FieldCreateDocumentFieldFieldTextTypedDict,
        FieldCreateDocumentFieldFieldNumberTypedDict,
        FieldCreateDocumentFieldFieldRadioTypedDict,
        FieldCreateDocumentFieldFieldCheckboxTypedDict,
        FieldCreateDocumentFieldFieldDropdownTypedDict,
    ],
)


FieldCreateDocumentFieldFieldUnion = TypeAliasType(
    "FieldCreateDocumentFieldFieldUnion",
    Union[
        FieldCreateDocumentFieldFieldFreeSignature,
        FieldCreateDocumentFieldFieldSignature,
        FieldCreateDocumentFieldFieldInitials,
        FieldCreateDocumentFieldFieldName,
        FieldCreateDocumentFieldFieldEmail,
        FieldCreateDocumentFieldFieldDate,
        FieldCreateDocumentFieldFieldText,
        FieldCreateDocumentFieldFieldNumber,
        FieldCreateDocumentFieldFieldRadio,
        FieldCreateDocumentFieldFieldCheckbox,
        FieldCreateDocumentFieldFieldDropdown,
    ],
)


class FieldCreateDocumentFieldRequestTypedDict(TypedDict):
    document_id: float
    field: FieldCreateDocumentFieldFieldUnionTypedDict


class FieldCreateDocumentFieldRequest(BaseModel):
    document_id: Annotated[float, pydantic.Field(alias="documentId")]

    field: FieldCreateDocumentFieldFieldUnion


class FieldCreateDocumentFieldInternalServerErrorIssueTypedDict(TypedDict):
    message: str


class FieldCreateDocumentFieldInternalServerErrorIssue(BaseModel):
    message: str


class FieldCreateDocumentFieldInternalServerErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldCreateDocumentFieldInternalServerErrorIssue]] = None


@dataclass(unsafe_hash=True)
class FieldCreateDocumentFieldInternalServerError(DocumensoError):
    r"""Internal server error"""

    data: FieldCreateDocumentFieldInternalServerErrorData = field(hash=False)

    def __init__(
        self,
        data: FieldCreateDocumentFieldInternalServerErrorData,
        raw_response: httpx.Response,
        body: Optional[str] = None,
    ):
        fallback = body or raw_response.text
        message = str(data.message) or fallback
        super().__init__(message, raw_response, body)
        object.__setattr__(self, "data", data)


class FieldCreateDocumentFieldForbiddenIssueTypedDict(TypedDict):
    message: str


class FieldCreateDocumentFieldForbiddenIssue(BaseModel):
    message: str


class FieldCreateDocumentFieldForbiddenErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldCreateDocumentFieldForbiddenIssue]] = None


@dataclass(unsafe_hash=True)
class FieldCreateDocumentFieldForbiddenError(DocumensoError):
    r"""Insufficient access"""

    data: FieldCreateDocumentFieldForbiddenErrorData = field(hash=False)

    def __init__(
        self,
        data: FieldCreateDocumentFieldForbiddenErrorData,
        raw_response: httpx.Response,
        body: Optional[str] = None,
    ):
        fallback = body or raw_response.text
        message = str(data.message) or fallback
        super().__init__(message, raw_response, body)
        object.__setattr__(self, "data", data)


class FieldCreateDocumentFieldUnauthorizedIssueTypedDict(TypedDict):
    message: str


class FieldCreateDocumentFieldUnauthorizedIssue(BaseModel):
    message: str


class FieldCreateDocumentFieldUnauthorizedErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldCreateDocumentFieldUnauthorizedIssue]] = None


@dataclass(unsafe_hash=True)
class FieldCreateDocumentFieldUnauthorizedError(DocumensoError):
    r"""Authorization not provided"""

    data: FieldCreateDocumentFieldUnauthorizedErrorData = field(hash=False)

    def __init__(
        self,
        data: FieldCreateDocumentFieldUnauthorizedErrorData,
        raw_response: httpx.Response,
        body: Optional[str] = None,
    ):
        fallback = body or raw_response.text
        message = str(data.message) or fallback
        super().__init__(message, raw_response, body)
        object.__setattr__(self, "data", data)


class FieldCreateDocumentFieldBadRequestIssueTypedDict(TypedDict):
    message: str


class FieldCreateDocumentFieldBadRequestIssue(BaseModel):
    message: str


class FieldCreateDocumentFieldBadRequestErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldCreateDocumentFieldBadRequestIssue]] = None


@dataclass(unsafe_hash=True)
class FieldCreateDocumentFieldBadRequestError(DocumensoError):
    r"""Invalid input data"""

    data: FieldCreateDocumentFieldBadRequestErrorData = field(hash=False)

    def __init__(
        self,
        data: FieldCreateDocumentFieldBadRequestErrorData,
        raw_response: httpx.Response,
        body: Optional[str] = None,
    ):
        fallback = body or raw_response.text
        message = str(data.message) or fallback
        super().__init__(message, raw_response, body)
        object.__setattr__(self, "data", data)


class FieldCreateDocumentFieldTypeResponse(str, Enum):
    SIGNATURE = "SIGNATURE"
    FREE_SIGNATURE = "FREE_SIGNATURE"
    INITIALS = "INITIALS"
    NAME = "NAME"
    EMAIL = "EMAIL"
    DATE = "DATE"
    TEXT = "TEXT"
    NUMBER = "NUMBER"
    RADIO = "RADIO"
    CHECKBOX = "CHECKBOX"
    DROPDOWN = "DROPDOWN"


class FieldCreateDocumentFieldFieldMetaTypeDropdown(str, Enum):
    DROPDOWN = "dropdown"


class FieldCreateDocumentFieldValueResponse3TypedDict(TypedDict):
    value: str


class FieldCreateDocumentFieldValueResponse3(BaseModel):
    value: str


class FieldCreateDocumentFieldFieldMetaDropdownResponseTypedDict(TypedDict):
    type: FieldCreateDocumentFieldFieldMetaTypeDropdown
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldCreateDocumentFieldValueResponse3TypedDict]]
    default_value: NotRequired[str]


class FieldCreateDocumentFieldFieldMetaDropdownResponse(BaseModel):
    type: FieldCreateDocumentFieldFieldMetaTypeDropdown

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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

    values: Optional[List[FieldCreateDocumentFieldValueResponse3]] = None

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


class FieldCreateDocumentFieldFieldMetaTypeCheckbox(str, Enum):
    CHECKBOX = "checkbox"


class FieldCreateDocumentFieldValueResponse2TypedDict(TypedDict):
    id: float
    checked: bool
    value: str


class FieldCreateDocumentFieldValueResponse2(BaseModel):
    id: float

    checked: bool

    value: str


class FieldCreateDocumentFieldDirectionResponse2(str, Enum):
    VERTICAL = "vertical"
    HORIZONTAL = "horizontal"


class FieldCreateDocumentFieldFieldMetaCheckboxResponseTypedDict(TypedDict):
    type: FieldCreateDocumentFieldFieldMetaTypeCheckbox
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldCreateDocumentFieldValueResponse2TypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[FieldCreateDocumentFieldDirectionResponse2]


class FieldCreateDocumentFieldFieldMetaCheckboxResponse(BaseModel):
    type: FieldCreateDocumentFieldFieldMetaTypeCheckbox

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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

    values: Optional[List[FieldCreateDocumentFieldValueResponse2]] = None

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

    validation_length: Annotated[
        Optional[float], pydantic.Field(alias="validationLength")
    ] = None

    direction: Optional[FieldCreateDocumentFieldDirectionResponse2] = (
        FieldCreateDocumentFieldDirectionResponse2.VERTICAL
    )


class FieldCreateDocumentFieldFieldMetaTypeRadio(str, Enum):
    RADIO = "radio"


class FieldCreateDocumentFieldValueResponse1TypedDict(TypedDict):
    id: float
    checked: bool
    value: str


class FieldCreateDocumentFieldValueResponse1(BaseModel):
    id: float

    checked: bool

    value: str


class FieldCreateDocumentFieldDirectionResponse1(str, Enum):
    VERTICAL = "vertical"
    HORIZONTAL = "horizontal"


class FieldCreateDocumentFieldFieldMetaRadioResponseTypedDict(TypedDict):
    type: FieldCreateDocumentFieldFieldMetaTypeRadio
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldCreateDocumentFieldValueResponse1TypedDict]]
    direction: NotRequired[FieldCreateDocumentFieldDirectionResponse1]


class FieldCreateDocumentFieldFieldMetaRadioResponse(BaseModel):
    type: FieldCreateDocumentFieldFieldMetaTypeRadio

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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

    values: Optional[List[FieldCreateDocumentFieldValueResponse1]] = None

    direction: Optional[FieldCreateDocumentFieldDirectionResponse1] = (
        FieldCreateDocumentFieldDirectionResponse1.VERTICAL
    )


class FieldCreateDocumentFieldFieldMetaTypeNumber(str, Enum):
    NUMBER = "number"


class FieldCreateDocumentFieldTextAlignResponse6(str, Enum):
    LEFT = "left"
    CENTER = "center"
    RIGHT = "right"


class FieldCreateDocumentFieldVerticalAlignResponse2(str, Enum):
    TOP = "top"
    MIDDLE = "middle"
    BOTTOM = "bottom"


class FieldCreateDocumentFieldFieldMetaNumberResponseTypedDict(TypedDict):
    type: FieldCreateDocumentFieldFieldMetaTypeNumber
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    number_format: NotRequired[Nullable[str]]
    value: NotRequired[str]
    min_value: NotRequired[Nullable[float]]
    max_value: NotRequired[Nullable[float]]
    text_align: NotRequired[FieldCreateDocumentFieldTextAlignResponse6]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[
        Nullable[FieldCreateDocumentFieldVerticalAlignResponse2]
    ]


class FieldCreateDocumentFieldFieldMetaNumberResponse(BaseModel):
    type: FieldCreateDocumentFieldFieldMetaTypeNumber

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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

    number_format: Annotated[
        OptionalNullable[str], pydantic.Field(alias="numberFormat")
    ] = UNSET

    value: Optional[str] = None

    min_value: Annotated[OptionalNullable[float], pydantic.Field(alias="minValue")] = (
        UNSET
    )

    max_value: Annotated[OptionalNullable[float], pydantic.Field(alias="maxValue")] = (
        UNSET
    )

    text_align: Annotated[
        Optional[FieldCreateDocumentFieldTextAlignResponse6],
        pydantic.Field(alias="textAlign"),
    ] = None

    line_height: Annotated[
        OptionalNullable[float], pydantic.Field(alias="lineHeight")
    ] = UNSET

    letter_spacing: Annotated[
        OptionalNullable[float], pydantic.Field(alias="letterSpacing")
    ] = UNSET

    vertical_align: Annotated[
        OptionalNullable[FieldCreateDocumentFieldVerticalAlignResponse2],
        pydantic.Field(alias="verticalAlign"),
    ] = UNSET

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "label",
            "placeholder",
            "required",
            "readOnly",
            "fontSize",
            "numberFormat",
            "value",
            "minValue",
            "maxValue",
            "textAlign",
            "lineHeight",
            "letterSpacing",
            "verticalAlign",
        ]
        nullable_fields = [
            "numberFormat",
            "minValue",
            "maxValue",
            "lineHeight",
            "letterSpacing",
            "verticalAlign",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class FieldCreateDocumentFieldFieldMetaTypeText(str, Enum):
    TEXT = "text"


class FieldCreateDocumentFieldTextAlignResponse5(str, Enum):
    LEFT = "left"
    CENTER = "center"
    RIGHT = "right"


class FieldCreateDocumentFieldVerticalAlignResponse1(str, Enum):
    TOP = "top"
    MIDDLE = "middle"
    BOTTOM = "bottom"


class FieldCreateDocumentFieldFieldMetaTextResponseTypedDict(TypedDict):
    type: FieldCreateDocumentFieldFieldMetaTypeText
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text: NotRequired[str]
    character_limit: NotRequired[float]
    text_align: NotRequired[FieldCreateDocumentFieldTextAlignResponse5]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[
        Nullable[FieldCreateDocumentFieldVerticalAlignResponse1]
    ]


class FieldCreateDocumentFieldFieldMetaTextResponse(BaseModel):
    type: FieldCreateDocumentFieldFieldMetaTypeText

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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

    text: Optional[str] = None

    character_limit: Annotated[
        Optional[float], pydantic.Field(alias="characterLimit")
    ] = None

    text_align: Annotated[
        Optional[FieldCreateDocumentFieldTextAlignResponse5],
        pydantic.Field(alias="textAlign"),
    ] = None

    line_height: Annotated[
        OptionalNullable[float], pydantic.Field(alias="lineHeight")
    ] = UNSET

    letter_spacing: Annotated[
        OptionalNullable[float], pydantic.Field(alias="letterSpacing")
    ] = UNSET

    vertical_align: Annotated[
        OptionalNullable[FieldCreateDocumentFieldVerticalAlignResponse1],
        pydantic.Field(alias="verticalAlign"),
    ] = UNSET

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "label",
            "placeholder",
            "required",
            "readOnly",
            "fontSize",
            "text",
            "characterLimit",
            "textAlign",
            "lineHeight",
            "letterSpacing",
            "verticalAlign",
        ]
        nullable_fields = ["lineHeight", "letterSpacing", "verticalAlign"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class FieldCreateDocumentFieldFieldMetaTypeDate(str, Enum):
    DATE = "date"


class FieldCreateDocumentFieldTextAlignResponse4(str, Enum):
    LEFT = "left"
    CENTER = "center"
    RIGHT = "right"


class FieldCreateDocumentFieldFieldMetaDateResponseTypedDict(TypedDict):
    type: FieldCreateDocumentFieldFieldMetaTypeDate
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateDocumentFieldTextAlignResponse4]


class FieldCreateDocumentFieldFieldMetaDateResponse(BaseModel):
    type: FieldCreateDocumentFieldFieldMetaTypeDate

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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

    text_align: Annotated[
        Optional[FieldCreateDocumentFieldTextAlignResponse4],
        pydantic.Field(alias="textAlign"),
    ] = None


class FieldCreateDocumentFieldFieldMetaTypeEmail(str, Enum):
    EMAIL = "email"


class FieldCreateDocumentFieldTextAlignResponse3(str, Enum):
    LEFT = "left"
    CENTER = "center"
    RIGHT = "right"


class FieldCreateDocumentFieldFieldMetaEmailResponseTypedDict(TypedDict):
    type: FieldCreateDocumentFieldFieldMetaTypeEmail
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateDocumentFieldTextAlignResponse3]


class FieldCreateDocumentFieldFieldMetaEmailResponse(BaseModel):
    type: FieldCreateDocumentFieldFieldMetaTypeEmail

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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

    text_align: Annotated[
        Optional[FieldCreateDocumentFieldTextAlignResponse3],
        pydantic.Field(alias="textAlign"),
    ] = None


class FieldCreateDocumentFieldFieldMetaTypeName(str, Enum):
    NAME = "name"


class FieldCreateDocumentFieldTextAlignResponse2(str, Enum):
    LEFT = "left"
    CENTER = "center"
    RIGHT = "right"


class FieldCreateDocumentFieldFieldMetaNameResponseTypedDict(TypedDict):
    type: FieldCreateDocumentFieldFieldMetaTypeName
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateDocumentFieldTextAlignResponse2]


class FieldCreateDocumentFieldFieldMetaNameResponse(BaseModel):
    type: FieldCreateDocumentFieldFieldMetaTypeName

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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

    text_align: Annotated[
        Optional[FieldCreateDocumentFieldTextAlignResponse2],
        pydantic.Field(alias="textAlign"),
    ] = None


class FieldCreateDocumentFieldFieldMetaTypeInitials(str, Enum):
    INITIALS = "initials"


class FieldCreateDocumentFieldTextAlignResponse1(str, Enum):
    LEFT = "left"
    CENTER = "center"
    RIGHT = "right"


class FieldCreateDocumentFieldFieldMetaInitialsResponseTypedDict(TypedDict):
    type: FieldCreateDocumentFieldFieldMetaTypeInitials
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateDocumentFieldTextAlignResponse1]


class FieldCreateDocumentFieldFieldMetaInitialsResponse(BaseModel):
    type: FieldCreateDocumentFieldFieldMetaTypeInitials

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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

    text_align: Annotated[
        Optional[FieldCreateDocumentFieldTextAlignResponse1],
        pydantic.Field(alias="textAlign"),
    ] = None


class FieldCreateDocumentFieldFieldMetaTypeSignature(str, Enum):
    SIGNATURE = "signature"


class FieldCreateDocumentFieldFieldMetaSignatureResponseTypedDict(TypedDict):
    type: FieldCreateDocumentFieldFieldMetaTypeSignature
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]


class FieldCreateDocumentFieldFieldMetaSignatureResponse(BaseModel):
    type: FieldCreateDocumentFieldFieldMetaTypeSignature

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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


FieldCreateDocumentFieldFieldMetaUnionTypedDict = TypeAliasType(
    "FieldCreateDocumentFieldFieldMetaUnionTypedDict",
    Union[
        FieldCreateDocumentFieldFieldMetaSignatureResponseTypedDict,
        FieldCreateDocumentFieldFieldMetaInitialsResponseTypedDict,
        FieldCreateDocumentFieldFieldMetaNameResponseTypedDict,
        FieldCreateDocumentFieldFieldMetaEmailResponseTypedDict,
        FieldCreateDocumentFieldFieldMetaDateResponseTypedDict,
        FieldCreateDocumentFieldFieldMetaRadioResponseTypedDict,
        FieldCreateDocumentFieldFieldMetaDropdownResponseTypedDict,
        FieldCreateDocumentFieldFieldMetaCheckboxResponseTypedDict,
        FieldCreateDocumentFieldFieldMetaTextResponseTypedDict,
        FieldCreateDocumentFieldFieldMetaNumberResponseTypedDict,
    ],
)


FieldCreateDocumentFieldFieldMetaUnion = TypeAliasType(
    "FieldCreateDocumentFieldFieldMetaUnion",
    Union[
        FieldCreateDocumentFieldFieldMetaSignatureResponse,
        FieldCreateDocumentFieldFieldMetaInitialsResponse,
        FieldCreateDocumentFieldFieldMetaNameResponse,
        FieldCreateDocumentFieldFieldMetaEmailResponse,
        FieldCreateDocumentFieldFieldMetaDateResponse,
        FieldCreateDocumentFieldFieldMetaRadioResponse,
        FieldCreateDocumentFieldFieldMetaDropdownResponse,
        FieldCreateDocumentFieldFieldMetaCheckboxResponse,
        FieldCreateDocumentFieldFieldMetaTextResponse,
        FieldCreateDocumentFieldFieldMetaNumberResponse,
    ],
)


class FieldCreateDocumentFieldResponseTypedDict(TypedDict):
    r"""Successful response"""

    envelope_id: str
    envelope_item_id: str
    type: FieldCreateDocumentFieldTypeResponse
    id: float
    secondary_id: str
    recipient_id: float
    page: float
    position_x: Any
    position_y: Any
    width: Any
    height: Any
    custom_text: str
    inserted: bool
    field_meta: Nullable[FieldCreateDocumentFieldFieldMetaUnionTypedDict]
    document_id: NotRequired[Nullable[float]]
    template_id: NotRequired[Nullable[float]]


class FieldCreateDocumentFieldResponse(BaseModel):
    r"""Successful response"""

    envelope_id: Annotated[str, pydantic.Field(alias="envelopeId")]

    envelope_item_id: Annotated[str, pydantic.Field(alias="envelopeItemId")]

    type: FieldCreateDocumentFieldTypeResponse

    id: float

    secondary_id: Annotated[str, pydantic.Field(alias="secondaryId")]

    recipient_id: Annotated[float, pydantic.Field(alias="recipientId")]

    page: float

    position_x: Annotated[Any, pydantic.Field(alias="positionX")]

    position_y: Annotated[Any, pydantic.Field(alias="positionY")]

    width: Any

    height: Any

    custom_text: Annotated[str, pydantic.Field(alias="customText")]

    inserted: bool

    field_meta: Annotated[
        Nullable[FieldCreateDocumentFieldFieldMetaUnion],
        pydantic.Field(alias="fieldMeta"),
    ]

    document_id: Annotated[
        OptionalNullable[float], pydantic.Field(alias="documentId")
    ] = UNSET

    template_id: Annotated[
        OptionalNullable[float], pydantic.Field(alias="templateId")
    ] = UNSET

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["documentId", "templateId"]
        nullable_fields = ["fieldMeta", "documentId", "templateId"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m
