"""File generated by TLObjects' generator. All changes will be ERASED"""
from ...tl.tlobject import TLObject
from typing import Optional, List, Union, TYPE_CHECKING
import os
import struct
from datetime import datetime
if TYPE_CHECKING:
    from ...tl.types import TypeAiComposeTone, TypeUser



class Tones(TLObject):
    CONSTRUCTOR_ID = 0x6c9d0efe
    SUBCLASS_OF_ID = 0xf25ffed9

    def __init__(self, hash: int, tones: List['TypeAiComposeTone'], users: List['TypeUser']):
        """
        Constructor for aicompose.Tones: Instance of either TonesNotModified, Tones.
        """
        self.hash = hash
        self.tones = tones
        self.users = users

    def to_dict(self):
        return {
            '_': 'Tones',
            'hash': self.hash,
            'tones': [] if self.tones is None else [x.to_dict() if isinstance(x, TLObject) else x for x in self.tones],
            'users': [] if self.users is None else [x.to_dict() if isinstance(x, TLObject) else x for x in self.users]
        }

    def _bytes(self):
        return b''.join((
            b'\xfe\x0e\x9dl',
            struct.pack('<q', self.hash),
            b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.tones)),b''.join(x._bytes() for x in self.tones),
            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):
        _hash = reader.read_long()
        reader.read_int()
        _tones = []
        for _ in range(reader.read_int()):
            _x = reader.tgread_object()
            _tones.append(_x)

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

        return cls(hash=_hash, tones=_tones, users=_users)


class TonesNotModified(TLObject):
    CONSTRUCTOR_ID = 0xc1f46103
    SUBCLASS_OF_ID = 0xf25ffed9

    def to_dict(self):
        return {
            '_': 'TonesNotModified'
        }

    def _bytes(self):
        return b''.join((
            b'\x03a\xf4\xc1',
        ))

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

