o
    5˜Žj  ã                   @   sþ   d dl Z d dlmZ d dlmZ d dlmZ d dlmZm	Z	m
Z
 d dlmZ G dd„ de
ƒZd	ed
eeeef ddf fdd„Zd	ed
eeeef ddf fdd„ZG dd„ de	ƒZedi edd�¤ŽG dd„ dƒƒZd	ed
eeeef ddf fdd„ZdS )é    N)Ú	Generator)Ú	dataclass)Ú
itemgetter)ÚAnyÚ
NamedTupleÚProtocol)Údataclass_kwargsc                   @   s0   e Zd Zdedeeeef ddf fdd„ZdS )ÚClassAttrsResolverÚclsÚreturnNc                 C   s   d S ©N© )Úselfr
   r   r   ú_/var/www/kodo/Anonymous/send/lib/python3.10/site-packages/aiogram/utils/class_attrs_resolver.pyÚ__call__   s    zClassAttrsResolver.__call__)	Ú__name__Ú
__module__Ú__qualname__Útyper   ÚtupleÚstrr   r   r   r   r   r   r	   
   s    (r	   r
   r   c                 c   s   � t  | ¡E dH  dS )a7  
    Inspects and resolves attributes of a given class.

    This function uses the `inspect.getmembers` utility to yield all attributes of
    a provided class. The output is a generator that produces tuples containing
    attribute names and their corresponding values. This function is suitable for
    analyzing class attributes dynamically. However, it guarantees alphabetical
    order of attributes.

    :param cls: The class for which the attributes will be resolved.
    :return: A generator yielding tuples containing attribute names and their values.
    N)ÚinspectÚ
getmembers)r
   r   r   r   Úinspect_members_resolver   s   €r   c                 c   sR   � t ƒ }tt | ¡ƒD ]}|j ¡ D ]\}}||v rq||fV  | |¡ qqdS )aá  
    Resolve and yield attributes from the reversed method resolution order (MRO) of a given class.

    This function iterates through the reversed MRO of a class and yields attributes
    that have not yet been encountered. It avoids duplicates by keeping track of
    attribute names that have already been processed.

    :param cls: The class for which the attributes will be resolved.
    :return: A generator yielding tuples containing attribute names and their values.
    N)ÚsetÚreversedr   ÚgetmroÚ__dict__ÚitemsÚadd)r
   Úknown_attrsÚbaseÚnameÚvaluer   r   r   Ú&get_reversed_mro_unique_attrs_resolver   s   €
ûÿr$   c                   @   s   e Zd ZU eed< eed< dS )Ú	_PositionÚin_mroÚin_classN)r   r   r   ÚintÚ__annotations__r   r   r   r   r%   3   s   
 r%   T)Úslotsc                   @   s0   e Zd ZU eed< eed< dd defdd„ZdS )Ú_AttributeContainerÚpositionr#   Úotherr   c                 C   s   | j |j k S r   )r,   )r   r-   r   r   r   Ú__lt__=   s   z_AttributeContainer.__lt__N)r   r   r   r%   r)   r   Úboolr.   r   r   r   r   r+   8   s   
 r+   c           	      c   sš   � i }t t | ¡ƒD ]+\}}t t|ƒ ¡ ƒD ]\}\}}t||ƒ}| |¡ }r,||_qt||d�||< qq
t	| ¡ t
dƒd�D ]
\}}||jfV  q@dS )a  
    Resolve and yield attributes from the method resolution order (MRO) of a given class.

    Iterates through a class's method resolution order (MRO) and collects its attributes
    along with their respective positions in the MRO and the class hierarchy. This generator
    yields a tuple containing the name of each attribute and its associated value.

    :param cls: The class for which the attributes will be resolved.
    :return: A generator yielding tuples containing attribute names and their values.
    )r#   r,   é   )ÚkeyN)Ú	enumerater   r   Úvarsr   r%   Úgetr,   r+   Úsortedr   r#   )	r
   Ú
attributesÚposition_in_mror!   Úposition_in_classr"   r#   r,   Ú	attributer   r   r   Úget_sorted_mro_attrs_resolverA   s   €
úÿr:   r   )r   Úcollections.abcr   Údataclassesr   Úoperatorr   Útypingr   r   r   Úaiogram.utils.dataclassr   r	   r   r   r   r   r$   r%   r+   r:   r   r   r   r   Ú<module>   s    $$(