import builtins
from typing import Any, Literal

class TlError(Exception): ...

class TlSchema:
    def __init__(
        self,
        id: bytes | None,
        name: str | None,
        class_name: str | None,
        args: dict[str, str],
    ) -> None: ...
    @property
    def id(self) -> bytes: ...
    def little_id(self) -> bytes: ...
    @property
    def name(self) -> str: ...
    @property
    def class_name(self) -> str: ...
    @property
    def boxed(self) -> bool: ...
    @boxed.setter
    def boxed(self, is_boxed: bool) -> None: ...
    @property
    def args(self) -> dict[str, str]: ...
    def is_empty(self) -> bool: ...
    @classmethod
    def empty(cls) -> TlSchema: ...
    def __repr__(self) -> str: ...

class TlSchemas:
    base_types: dict[str, int | None]
    list: builtins.list[TlSchema]
    id_map: dict[bytes, TlSchema]
    name_map: dict[str, TlSchema]
    class_name_map: dict[str, builtins.list[TlSchema]]
    untouchables: dict[str, set[str]]

    def __init__(self, schemas: builtins.list[TlSchema], auto_deserialize: bool = ...) -> None: ...
    def get_by_id(
        self,
        tl_id: bytes | int,
        byteorder: Literal["little", "big"] = ...,
    ) -> TlSchema | None: ...
    def get_by_name(self, name: str) -> TlSchema | None: ...
    def get_by_class_name(self, class_name: str) -> builtins.list[TlSchema] | None: ...
    def generate_map(self) -> None: ...
    def set_default_untouchables(self) -> None: ...
    def serialize_field(self, type_: str, value: object) -> bytes: ...
    def serialize(self, schema: TlSchema | str, data: dict[str, Any], boxed: bool = ...) -> bytes: ...
    def deserialize(
        self,
        data: bytes,
        boxed: bool = ...,
        args: dict[str, str] | None = ...,
    ) -> tuple[dict[str, Any] | bytes, int]: ...
    def __repr__(self) -> str: ...

class TlRegistrator:
    def __init__(self) -> None: ...
    def register(self, schema: str) -> TlSchema: ...
    @staticmethod
    def clear(schema: str) -> str: ...
    @staticmethod
    def crc32(schema: str) -> int: ...
    def get_id(self, schema: str) -> bytes: ...
    def get_params(self, schema: str) -> dict[str, str]: ...

class TlGenerator:
    def __init__(self, path: str, registrator: TlRegistrator | None = ...) -> None: ...
    @classmethod
    def with_default_schemas(cls) -> TlGenerator: ...
    def generate(self) -> TlSchemas: ...
    def from_file(self, file_path: str) -> builtins.list[TlSchema]: ...
