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

from __future__ import annotations

from typing import Literal, Union

from pydantic import BaseModel, Field, RootModel


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


class Item(RootModel[UserMessage | AssistantMessage]):
    root: UserMessage | AssistantMessage


class InputItem(RootModel[EasyInputMessage | Item | ItemReference]):
    root: EasyInputMessage | Item | ItemReference


class GroupedItem(RootModel[Item | ItemReference]):
    root: Item | ItemReference = Field(..., discriminator='type')


class MixedItem(RootModel[str | ItemReference | None]):
    root: str | ItemReference | None


class MessageWrapper(RootModel[UserMessage]):
    root: UserMessage


class WrappedItem(RootModel[MessageWrapper | UserMessage | ItemReference]):
    root: MessageWrapper | UserMessage | ItemReference


class MissingType(BaseModel):
    value: str


class MissingTypeWrapper(RootModel[MissingType]):
    root: MissingType


class NestedMissingType(RootModel[MissingTypeWrapper | ItemReference]):
    root: MissingTypeWrapper | ItemReference


class RecursiveItem(RootModel[Union["RecursiveItem", ItemReference]]):
    root: Union["RecursiveItem", ItemReference]


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


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


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


class UniqueInner(RootModel[UniqueA | UniqueB]):
    root: UniqueA | UniqueB = Field(..., discriminator='type')


class UniqueOuter(RootModel[UniqueInner | UniqueC]):
    root: UniqueInner | UniqueC = Field(..., discriminator='type')


class NullableUnique(RootModel[UniqueA | UniqueB | None]):
    root: UniqueA | UniqueB | None = Field(..., discriminator='type')


class ContainerItem(RootModel[list[UniqueA | UniqueB] | ItemReference]):
    root: list[UniqueA | UniqueB] | ItemReference


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


RecursiveItem.model_rebuild()
