# generated by datamodel-codegen:
#   filename:  discriminator_duplicate_value.yaml
#   timestamp: 2019-07-26T00:00:00+00:00

from __future__ import annotations

from typing import Annotated, Literal, Union

from pydantic import BaseModel, Field
from typing_extensions import TypeAliasType


class UserMessage(BaseModel):
    type: Literal['message']
    role: Literal['user']
    content: str


class AssistantMessage(BaseModel):
    type: Literal['message']
    role: Literal['assistant']
    content: str


class EasyInputMessage(BaseModel):
    type: Literal['message']
    role: Literal['easy']
    content: str


class ItemReference(BaseModel):
    type: Literal['item_reference']
    id: str


Item = TypeAliasType("Item", UserMessage | AssistantMessage)


InputItem = TypeAliasType("InputItem", EasyInputMessage | Item | ItemReference)


GroupedItem = TypeAliasType(
    "GroupedItem", Annotated[Item | ItemReference, Field(..., discriminator='type')]
)


MixedItem = TypeAliasType("MixedItem", str | ItemReference | None)


MessageWrapper = TypeAliasType("MessageWrapper", UserMessage)


WrappedItem = TypeAliasType("WrappedItem", MessageWrapper | UserMessage | ItemReference)


class MissingType(BaseModel):
    value: str


MissingTypeWrapper = TypeAliasType("MissingTypeWrapper", MissingType)


NestedMissingType = TypeAliasType("NestedMissingType", MissingTypeWrapper | ItemReference)


RecursiveItem = TypeAliasType("RecursiveItem", Union["RecursiveItem", ItemReference])


class UniqueA(BaseModel):
    type: Literal['a']


class UniqueB(BaseModel):
    type: Literal['b']


class UniqueC(BaseModel):
    type: Literal['c']


UniqueInner = TypeAliasType(
    "UniqueInner", Annotated[UniqueA | UniqueB, Field(..., discriminator='type')]
)


UniqueOuter = TypeAliasType(
    "UniqueOuter", Annotated[UniqueInner | UniqueC, Field(..., discriminator='type')]
)


NullableUnique = TypeAliasType(
    "NullableUnique",
    Annotated[
        UniqueA | UniqueB | None, Field(..., discriminator='type')
    ],
)


ContainerItem = TypeAliasType("ContainerItem", list[UniqueA | UniqueB] | ItemReference)


class Envelope(BaseModel):
    items: list[InputItem]
    grouped: GroupedItem
    mixed: MixedItem
    wrapped: WrappedItem
    nested_missing: NestedMissingType
    container: ContainerItem
    recursive: RecursiveItem
    unique: UniqueOuter
    nullable_unique: NullableUnique
