Ë
    v¹1hˆ  ã                   óÜ   — d dl mZ d dlmZ d dlmZmZmZmZm	Z	m
Z
 d dlmZ e G d„ d«      «       Z G d„ d«      Z e«       Zd	ed
eegef   fd„Zdeded
efd„Z e
de	¬«      Zded
efd„Zy)é    )Ú	dataclass)Úwraps)ÚAnyÚCallableÚIteratorÚListÚTypeÚTypeVar)ÚEventEmitterc                   ó"   — e Zd ZU eed<   eed<   y)ÚHandlerÚeventÚmethodN)Ú__name__Ú
__module__Ú__qualname__ÚstrÚ__annotations__r   © ó    úF/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/pyee/cls.pyr   r      s   … àƒJØÔr   r   c                   ó4   — e Zd Zdd„Zdd„Zdee   fd„Zd„ Zy)ÚHandlersÚreturnNc                 ó   — g | _         y ©N©Ú	_handlers©Úselfs    r   Ú__init__zHandlers.__init__   s	   € Ø(*ˆ�r   c                 ó:   — | j                   j                  |«       y r   )r   Úappend)r    Úhandlers     r   r#   zHandlers.append   s   € Ø�‰×Ñ˜gÕ&r   c                 ó,   — t        | j                  «      S r   )Úiterr   r   s    r   Ú__iter__zHandlers.__iter__   s   € Ü�D—N‘NÓ#Ð#r   c                 ó   — g | _         y r   r   r   s    r   ÚresetzHandlers.reset   s	   € Øˆ�r   )r   N)	r   r   r   r!   r#   r   r   r'   r)   r   r   r   r   r      s"   „ ó+ó'ð$˜( 7Ñ+ó $ór   r   r   r   c                 ó,   ‡ — dt         dt         fˆ fd„}|S )zr
    Register an event handler on an evented class. See the `evented` class
    decorator for a full example.
    r   r   c                 óH   •— t         j                  t        ‰| ¬«      «       | S )N)r   r   )r   r#   r   )r   r   s    €r   Ú	decoratorzon.<locals>.decorator%   s   ø€ Ü×Ñœ u°VÔ<Ô=Øˆr   )r   )r   r,   s   ` r   Úonr-      s   ø€ ðœ(ð ¤xõ ð Ðr   r    r   c                 ó@   ‡ ‡— t        ‰«      dt        fˆˆ fd„«       }|S )Nr   c                  ó   •—  ‰‰g| ¢­i |¤ŽS r   r   )ÚargsÚkwargsr   r    s     €€r   Úboundz_bind.<locals>.bound-   s   ø€ á�dÐ,˜TÒ, VÑ,Ð,r   )r   r   )r    r   r2   s   `` r   Ú_bindr3   ,   s'   ù€ Ü
ˆ6ƒ]ð-¤#õ -ó ð-ð €Lr   ÚCls)r2   Úclsc           	      óÜ   ‡‡— t        t        «      Št        j                  «        | j                  Št	        | j                  «      dt
        dt
        dt
        ddfˆˆfd„«       }|| _        | S )aQ  
    Configure an evented class.

    Evented classes are classes which use an EventEmitter to call instance
    methods during runtime. To achieve this without this helper, you would
    instantiate an `EventEmitter` in the `__init__` method and then call
    `event_emitter.on` for every method on `self`.

    This decorator and the `on` function help make things look a little nicer
    by defining the event handler on the method in the class and then adding
    the `__init__` hook in a wrapper:

    ```py
    from pyee.cls import evented, on

    @evented
    class Evented:
        @on("event")
        def event_handler(self, *args, **kwargs):
            print(self, args, kwargs)

    evented_obj = Evented()

    evented_obj.event_emitter.emit(
        "event", "hello world", numbers=[1, 2, 3]
    )
    ```

    The `__init__` wrapper will create a `self.event_emitter: EventEmitter`
    automatically but you can also define your own event_emitter inside your
    class's unwrapped `__init__` method. For example, to use this
    decorator with a `TwistedEventEmitter`::

    ```py
    @evented
    class Evented:
        def __init__(self):
            self.event_emitter = TwistedEventEmitter()

        @on("event")
        async def event_handler(self, *args, **kwargs):
            await self.some_async_action(*args, **kwargs)
    ```
    r    r0   r1   r   Nc                 óÖ   •—  ‰| g|¢­i |¤Ž t        | d«      st        «       | _        ‰D ]<  }| j                  j                  |j                  t        | |j                  «      «       Œ> y )NÚevent_emitter)Úhasattrr   r8   r-   r   r3   r   )r    r0   r1   ÚhÚhandlersÚog_inits       €€r   Úinitzevented.<locals>.initi   s_   ø€ á�Ð&�tÒ&˜vÒ&Ü�t˜_Ô-Ü!-£ˆDÔàò 	BˆAØ×Ñ×!Ñ! !§'¡'¬5°°q·x±xÓ+@ÕAñ	Br   )Úlistr   r)   r!   r   r   )r5   r=   r;   r<   s     @@r   Úeventedr?   7   sm   ù€ ôZ #¤9›o€HÜ‡O�OÔàŸ™€Gä
ˆ3�<‰<ÓðB”3ð Bœsð B¬cð B°dõ Bó ðBð €C„Là€Jr   N)Údataclassesr   Ú	functoolsr   Útypingr   r   r   r   r	   r
   Úpyeer   r   r   r   r   r-   r3   r4   r?   r   r   r   ú<module>rD      sš   ðÝ !Ý ß ?× ?å ð ÷ð ó ð÷
ñ ñ ‹J€	ð
ˆcð 
�h ˜z¨8Ð3Ñ4ó 
ð�ð ˜Sð  Só ñ ˆe˜4Ô €ð=�ð =˜ô =r   