"""File generated by TLObjects' generator. All changes will be ERASED"""
from .._misc.tlobject import TLObject, TLRequest
from . import fn
from typing import Optional, List, Union, TYPE_CHECKING
import os
import struct
import dataclasses
from datetime import datetime
if TYPE_CHECKING:
    from . import TypeChat, TypeContact, TypeImportedContact, TypePeer, TypePeerBlocked, TypePopularContact, TypeTopPeerCategoryPeers, TypeUser



@dataclasses.dataclass(init=False, frozen=True)
class Blocked(TLObject):
    """
    Constructor for contacts.Blocked: Instance of either Blocked, BlockedSlice.
    """
    __slots__ = ('blocked', 'chats', 'users',)
    CONSTRUCTOR_ID = 0xade1591
    SUBCLASS_OF_ID = 0xffba4f4f

    blocked: List['TypePeerBlocked']
    chats: List['TypeChat']
    users: List['TypeUser']
    def __init__(self, blocked: List['TypePeerBlocked'], chats: List['TypeChat'], users: List['TypeUser']):
        object.__setattr__(self, 'blocked', blocked)
        object.__setattr__(self, 'chats', chats)
        object.__setattr__(self, 'users', users)

    def _bytes(self):
        return b''.join((
            b'\x91\x15\xde\n',
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.blocked)),b''.join(x._bytes() for x in self.blocked),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.chats)),b''.join(x._bytes() for x in self.chats),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.users)),b''.join(x._bytes() for x in self.users),
        ))

    @classmethod
    def _from_reader(cls, reader):
        reader.read_int()
        _blocked = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _blocked.append(_x)

        reader.read_int()
        _chats = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _chats.append(_x)

        reader.read_int()
        _users = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _users.append(_x)

        return cls(blocked=_blocked, chats=_chats, users=_users)


@dataclasses.dataclass(init=False, frozen=True)
class BlockedSlice(TLObject):
    """
    Constructor for contacts.Blocked: Instance of either Blocked, BlockedSlice.
    """
    __slots__ = ('count', 'blocked', 'chats', 'users',)
    CONSTRUCTOR_ID = 0xe1664194
    SUBCLASS_OF_ID = 0xffba4f4f

    count: int
    blocked: List['TypePeerBlocked']
    chats: List['TypeChat']
    users: List['TypeUser']
    def __init__(self, count: int, blocked: List['TypePeerBlocked'], chats: List['TypeChat'], users: List['TypeUser']):
        object.__setattr__(self, 'count', count)
        object.__setattr__(self, 'blocked', blocked)
        object.__setattr__(self, 'chats', chats)
        object.__setattr__(self, 'users', users)

    def _bytes(self):
        return b''.join((
            b'\x94Af\xe1',
            struct.pack('<i', self.count),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.blocked)),b''.join(x._bytes() for x in self.blocked),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.chats)),b''.join(x._bytes() for x in self.chats),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.users)),b''.join(x._bytes() for x in self.users),
        ))

    @classmethod
    def _from_reader(cls, reader):
        _count = reader.read_int()
        reader.read_int()
        _blocked = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _blocked.append(_x)

        reader.read_int()
        _chats = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _chats.append(_x)

        reader.read_int()
        _users = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _users.append(_x)

        return cls(count=_count, blocked=_blocked, chats=_chats, users=_users)


@dataclasses.dataclass(init=False, frozen=True)
class Contacts(TLObject):
    """
    Constructor for contacts.Contacts: Instance of either ContactsNotModified, Contacts.
    """
    __slots__ = ('contacts', 'saved_count', 'users',)
    CONSTRUCTOR_ID = 0xeae87e42
    SUBCLASS_OF_ID = 0x38be25f6

    contacts: List['TypeContact']
    saved_count: int
    users: List['TypeUser']
    def __init__(self, contacts: List['TypeContact'], saved_count: int, users: List['TypeUser']):
        object.__setattr__(self, 'contacts', contacts)
        object.__setattr__(self, 'saved_count', saved_count)
        object.__setattr__(self, 'users', users)

    def _bytes(self):
        return b''.join((
            b'B~\xe8\xea',
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.contacts)),b''.join(x._bytes() for x in self.contacts),
            struct.pack('<i', self.saved_count),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.users)),b''.join(x._bytes() for x in self.users),
        ))

    @classmethod
    def _from_reader(cls, reader):
        reader.read_int()
        _contacts = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _contacts.append(_x)

        _saved_count = reader.read_int()
        reader.read_int()
        _users = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _users.append(_x)

        return cls(contacts=_contacts, saved_count=_saved_count, users=_users)


@dataclasses.dataclass(init=False, frozen=True)
class ContactsNotModified(TLObject):
    """
    Constructor for contacts.Contacts: Instance of either ContactsNotModified, Contacts.
    """
    __slots__ = ()
    CONSTRUCTOR_ID = 0xb74ba9d2
    SUBCLASS_OF_ID = 0x38be25f6

    def _bytes(self):
        return b''.join((
            b'\xd2\xa9K\xb7',
        ))

    @classmethod
    def _from_reader(cls, reader):
        return cls()


@dataclasses.dataclass(init=False, frozen=True)
class Found(TLObject):
    """
    Constructor for contacts.Found: Instance of Found.
    """
    __slots__ = ('my_results', 'results', 'chats', 'users',)
    CONSTRUCTOR_ID = 0xb3134d9d
    SUBCLASS_OF_ID = 0x4386a2e3

    my_results: List['TypePeer']
    results: List['TypePeer']
    chats: List['TypeChat']
    users: List['TypeUser']
    def __init__(self, my_results: List['TypePeer'], results: List['TypePeer'], chats: List['TypeChat'], users: List['TypeUser']):
        object.__setattr__(self, 'my_results', my_results)
        object.__setattr__(self, 'results', results)
        object.__setattr__(self, 'chats', chats)
        object.__setattr__(self, 'users', users)

    def _bytes(self):
        return b''.join((
            b'\x9dM\x13\xb3',
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.my_results)),b''.join(x._bytes() for x in self.my_results),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.results)),b''.join(x._bytes() for x in self.results),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.chats)),b''.join(x._bytes() for x in self.chats),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.users)),b''.join(x._bytes() for x in self.users),
        ))

    @classmethod
    def _from_reader(cls, reader):
        reader.read_int()
        _my_results = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _my_results.append(_x)

        reader.read_int()
        _results = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _results.append(_x)

        reader.read_int()
        _chats = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _chats.append(_x)

        reader.read_int()
        _users = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _users.append(_x)

        return cls(my_results=_my_results, results=_results, chats=_chats, users=_users)


@dataclasses.dataclass(init=False, frozen=True)
class ImportedContacts(TLObject):
    """
    Constructor for contacts.ImportedContacts: Instance of ImportedContacts.
    """
    __slots__ = ('imported', 'popular_invites', 'retry_contacts', 'users',)
    CONSTRUCTOR_ID = 0x77d01c3b
    SUBCLASS_OF_ID = 0x8172ad93

    imported: List['TypeImportedContact']
    popular_invites: List['TypePopularContact']
    retry_contacts: List[int]
    users: List['TypeUser']
    def __init__(self, imported: List['TypeImportedContact'], popular_invites: List['TypePopularContact'], retry_contacts: List[int], users: List['TypeUser']):
        object.__setattr__(self, 'imported', imported)
        object.__setattr__(self, 'popular_invites', popular_invites)
        object.__setattr__(self, 'retry_contacts', retry_contacts)
        object.__setattr__(self, 'users', users)

    def _bytes(self):
        return b''.join((
            b';\x1c\xd0w',
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.imported)),b''.join(x._bytes() for x in self.imported),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.popular_invites)),b''.join(x._bytes() for x in self.popular_invites),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.retry_contacts)),b''.join(struct.pack('<q', x) for x in self.retry_contacts),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.users)),b''.join(x._bytes() for x in self.users),
        ))

    @classmethod
    def _from_reader(cls, reader):
        reader.read_int()
        _imported = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _imported.append(_x)

        reader.read_int()
        _popular_invites = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _popular_invites.append(_x)

        reader.read_int()
        _retry_contacts = []
        for _ in range(reader.read_int()):
            _x = reader.read_long()
            _retry_contacts.append(_x)

        reader.read_int()
        _users = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _users.append(_x)

        return cls(imported=_imported, popular_invites=_popular_invites, retry_contacts=_retry_contacts, users=_users)


@dataclasses.dataclass(init=False, frozen=True)
class ResolvedPeer(TLObject):
    """
    Constructor for contacts.ResolvedPeer: Instance of ResolvedPeer.
    """
    __slots__ = ('peer', 'chats', 'users',)
    CONSTRUCTOR_ID = 0x7f077ad9
    SUBCLASS_OF_ID = 0xf065b3a8

    peer: 'TypePeer'
    chats: List['TypeChat']
    users: List['TypeUser']
    def __init__(self, peer: 'TypePeer', chats: List['TypeChat'], users: List['TypeUser']):
        object.__setattr__(self, 'peer', peer)
        object.__setattr__(self, 'chats', chats)
        object.__setattr__(self, 'users', users)

    def _bytes(self):
        return b''.join((
            b'\xd9z\x07\x7f',
            self.peer._bytes(),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.chats)),b''.join(x._bytes() for x in self.chats),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.users)),b''.join(x._bytes() for x in self.users),
        ))

    @classmethod
    def _from_reader(cls, reader):
        _peer = reader.tgread_object()
        reader.read_int()
        _chats = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _chats.append(_x)

        reader.read_int()
        _users = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _users.append(_x)

        return cls(peer=_peer, chats=_chats, users=_users)


@dataclasses.dataclass(init=False, frozen=True)
class TopPeers(TLObject):
    """
    Constructor for contacts.TopPeers: Instance of either TopPeersNotModified, TopPeers, TopPeersDisabled.
    """
    __slots__ = ('categories', 'chats', 'users',)
    CONSTRUCTOR_ID = 0x70b772a8
    SUBCLASS_OF_ID = 0x9ee8bb88

    categories: List['TypeTopPeerCategoryPeers']
    chats: List['TypeChat']
    users: List['TypeUser']
    def __init__(self, categories: List['TypeTopPeerCategoryPeers'], chats: List['TypeChat'], users: List['TypeUser']):
        object.__setattr__(self, 'categories', categories)
        object.__setattr__(self, 'chats', chats)
        object.__setattr__(self, 'users', users)

    def _bytes(self):
        return b''.join((
            b'\xa8r\xb7p',
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.categories)),b''.join(x._bytes() for x in self.categories),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.chats)),b''.join(x._bytes() for x in self.chats),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.users)),b''.join(x._bytes() for x in self.users),
        ))

    @classmethod
    def _from_reader(cls, reader):
        reader.read_int()
        _categories = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _categories.append(_x)

        reader.read_int()
        _chats = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _chats.append(_x)

        reader.read_int()
        _users = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _users.append(_x)

        return cls(categories=_categories, chats=_chats, users=_users)


@dataclasses.dataclass(init=False, frozen=True)
class TopPeersDisabled(TLObject):
    """
    Constructor for contacts.TopPeers: Instance of either TopPeersNotModified, TopPeers, TopPeersDisabled.
    """
    __slots__ = ()
    CONSTRUCTOR_ID = 0xb52c939d
    SUBCLASS_OF_ID = 0x9ee8bb88

    def _bytes(self):
        return b''.join((
            b'\x9d\x93,\xb5',
        ))

    @classmethod
    def _from_reader(cls, reader):
        return cls()


@dataclasses.dataclass(init=False, frozen=True)
class TopPeersNotModified(TLObject):
    """
    Constructor for contacts.TopPeers: Instance of either TopPeersNotModified, TopPeers, TopPeersDisabled.
    """
    __slots__ = ()
    CONSTRUCTOR_ID = 0xde266ef5
    SUBCLASS_OF_ID = 0x9ee8bb88

    def _bytes(self):
        return b''.join((
            b'\xf5n&\xde',
        ))

    @classmethod
    def _from_reader(cls, reader):
        return cls()

