§
    ÎAÄj±  ã                   óž   — 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
mZmZmZmZ  G d„ de¦  «        Z ede¬¦  «        Z G d„ d	¦  «        Zd
S )é    )ÚOrderedDict)ÚLock)
ÚAnyÚCallableÚDictÚListÚMappingÚOptionalÚSetÚTupleÚTypeVarÚUnionc                   ó   — e Zd ZdZdS )ÚPyeeExceptionzAn exception internal to pyee.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    úMC:\Projects\Historical\FacebookAutoPoster\venv\Lib\site-packages\pyee/base.pyr   r      s   € € € € € Ø(Ð(Ð(Ð(r   r   ÚHandler)Úboundc                   ó   — e Zd ZdZdd„Zdeeef         fd„Zdeeef         ddfd„Z		 dded	e
e         deeeegef         f         fd
„Zdedeegef         fd„Zded	edefd„Zdededefd„Zd	edeedf         deeef         ddfd„Zdee         fd„Zdededdfd„Zdedeedf         deeef         defd„Zdedededefd„Z	 dded	e
e         defd„Zded	eddfd„Zded	eddfd„Zdde
e         ddfd„Zdedee         fd„Z dS ) ÚEventEmitteraŽ  The base event emitter class. All other event emitters inherit from
    this class.

    Most events are registered with an emitter via the `on` and `once`
    methods, and fired with the `emit` method. However, pyee event emitters
    have two *special* events:

    - `new_listener`: Fires whenever a new listener is created. Listeners for
      this event do not fire upon their own creation.

    - `error`: When emitted raises an Exception by default, behavior can be
      overridden by attaching callback to the event.

      For example:

    ```py
    @ee.on('error')
    def on_error(message):
        logging.err(message)

    ee.emit('error', Exception('something blew up'))
    ```

    All callbacks are handled in a synchronous, blocking manner. As in node.js,
    raised exceptions are not automatically handled for you---you must catch
    your own exceptions, and treat them accordingly.
    ÚreturnNc                 óR   — t          ¦   «         | _        t          ¦   «         | _        d S ©N)ÚdictÚ_eventsr   Ú_lock©Úselfs    r   Ú__init__zEventEmitter.__init__7   s#   € õ ‰FŒFð 	Œõ  ™6œ6ˆŒ
ˆ
ˆ
r   c                 ó>   — | j                              ¦   «         }|d= |S )Nr!   )Ú__dict__Úcopy©r#   Ústates     r   Ú__getstate__zEventEmitter.__getstate__>   s!   € Ø”×"Ò"Ñ$Ô$ˆØ�'ˆNØˆr   r)   c                 ó`   — | j                              |¦  «         t          ¦   «         | _        d S r   )r&   Úupdater   r!   r(   s     r   Ú__setstate__zEventEmitter.__setstate__C   s'   € ØŒ×Ò˜UÑ#Ô#Ð#Ý‘V”VˆŒ
ˆ
ˆ
r   ÚeventÚfc                 ó\   — |€|                       |¦  «        S |                      ||¦  «        S )au  Registers the function `f` to the event name `event`, if provided.

        If `f` isn't provided, this method calls `EventEmitter#listens_to`, and
        otherwise calls `EventEmitter#add_listener`. In other words, you may either
        use it as a decorator:

        ```py
        @ee.on('data')
        def data_handler(data):
            print(data)
        ```

        Or directly:

        ```py
        ee.on('data', data_handler)
        ```

        In both the decorated and undecorated forms, the event handler is
        returned. The upshot of this is that you can call decorated handlers
        directly, as well as use them in remove_listener calls.

        Note that this method's return type is a union type. If you are using
        mypy or pyright, you will probably want to use either
        `EventEmitter#listens_to` or `EventEmitter#add_listener`.
        )Ú
listens_toÚadd_listener©r#   r.   r/   s      r   ÚonzEventEmitter.onG   s1   € ð: ˆ9Ø—?’? 5Ñ)Ô)Ð)à×$Ò$ U¨AÑ.Ô.Ð.r   c                 ó4   ‡ ‡— dt           dt           fˆˆ fd„}|S )aV  Returns a decorator which will register the decorated function to
        the event name `event`:

        ```py
        @ee.listens_to("event")
        def data_handler(data):
            print(data)
        ```

        By only supporting the decorator use case, this method has improved
        type safety over `EventEmitter#on`.
        r/   r   c                 ó6   •— ‰                      ‰| | ¦  «         | S r   ©Ú_add_event_handler)r/   r.   r#   s    €€r   r4   z#EventEmitter.listens_to.<locals>.onw   s    ø€ Ø×#Ò# E¨1¨aÑ0Ô0Ð0ØˆHr   )r   )r#   r.   r4   s   `` r   r1   zEventEmitter.listens_toi   s<   øø€ ð	•'ð 	�gð 	ð 	ð 	ð 	ð 	ð 	ð 	ð ˆ	r   c                 ó4   — |                       |||¦  «         |S )a:  Register the function `f` to the event name `event`:

        ```
        def data_handler(data):
            print(data)

        h = ee.add_listener("event", data_handler)
        ```

        By not supporting the decorator use case, this method has improved
        type safety over `EventEmitter#on`.
        r7   r3   s      r   r2   zEventEmitter.add_listener}   s!   € ð 	×Ò  q¨!Ñ,Ô,Ð,Øˆr   ÚkÚvc                 óÒ   — |                       d||¦  «         | j        5  || j        vrt          ¦   «         | j        |<   || j        |         |<   d d d ¦  «         d S # 1 swxY w Y   d S )NÚnew_listener)Úemitr!   r    r   )r#   r.   r:   r;   s       r   r8   zEventEmitter._add_event_handler�   s´   € à�	Š	�. %¨Ñ+Ô+Ð+ð ŒZð 	'ð 	'Ø˜DœLÐ(Ð(Ý&1¡m¤m�”˜UÑ#Ø%&ˆDŒL˜Ô Ñ"ð	'ð 	'ð 	'ñ 	'ô 	'ð 	'ð 	'ð 	'ð 	'ð 	'ð 	'ð 	'øøøð 	'ð 	'ð 	'ð 	'ð 	'ð 	's   Ÿ0AÁA Á#A Úargs.Úkwargsc                 ó   —  ||i |¤Ž d S r   r   )r#   r/   r?   r@   s       r   Ú	_emit_runzEventEmitter._emit_runš   s   € ð 	
ˆˆ4Ð�6ÐÐÐÐÐr   c                 óN   — t          | j                             ¦   «         ¦  «        S )z6Get a set of events that this emitter is listening to.)Úsetr    Úkeysr"   s    r   Úevent_nameszEventEmitter.event_names¢   s   € å�4”<×$Ò$Ñ&Ô&Ñ'Ô'Ð'r   Úerrorc                 ód   — |dk    r)t          |t          ¦  «        r|‚t          d|› �¦  «        ‚d S )NrG   z%Uncaught, unspecified 'error' event: )Ú
isinstanceÚ	Exceptionr   )r#   r.   rG   s      r   Ú_emit_handle_potential_errorz)EventEmitter._emit_handle_potential_error¦   sD   € Ø�GÒÐÝ˜%¥Ñ+Ô+ð UØ�å#Ð$SÈEÐ$SÐ$SÑTÔTÐTð	 Ðr   c                 ó  — d}| j         5  t          | j                             |t	          ¦   «         ¦  «                             ¦   «         ¦  «        }d d d ¦  «         n# 1 swxY w Y   |D ]}|                      |||¦  «         d}Œ|S )NFT)r!   Úlistr    Úgetr   ÚvaluesrB   )r#   r.   r?   r@   ÚhandledÚfuncsr/   s          r   Ú_call_handlerszEventEmitter._call_handlers­   s×   € ð ˆàŒZð 	Jð 	JÝ˜œ×)Ò)¨%µ±´Ñ?Ô?×FÒFÑHÔHÑIÔIˆEð	Jð 	Jð 	Jñ 	Jô 	Jð 	Jð 	Jð 	Jð 	Jð 	Jð 	Jøøøð 	Jð 	Jð 	Jð 	Jàð 	ð 	ˆAØ�NŠN˜1˜d FÑ+Ô+Ð+ØˆGˆGàˆs   ŠAAÁA!Á$A!c                 óx   — |                       |||¦  «        }|s |                      ||r|d         nd¦  «         |S )ac  Emit `event`, passing `*args` and `**kwargs` to each attached
        function. Returns `True` if any functions are attached to `event`;
        otherwise returns `False`.

        Example:

        ```py
        ee.emit('data', '00101001')
        ```

        Assuming `data` is an attached function, this will call
        `data('00101001')'`.
        r   N)rR   rK   )r#   r.   r?   r@   rP   s        r   r>   zEventEmitter.emit½   sL   € ð& ×%Ò% e¨T°6Ñ:Ô:ˆàð 	PØ×-Ò-¨eÀÐ5N°T¸!´W°WÈ$ÑOÔOÐOàˆr   c                 óN   ‡ ‡— dt           dt           fˆˆ fd„}|€|S  ||¦  «        S )zkThe same as `ee.on`, except that the listener is automatically
        removed after being called.
        r/   r   c                 ór   •‡ — dt           dt           dt           fˆˆ ˆfd„}‰                     ‰‰ |¦  «         ‰ S )Nr?   r@   r   c                  óÎ   •— ‰j         5  ‰‰j        v r&‰‰j        ‰         v r‰                     ‰‰¦  «         n	 d d d ¦  «         d S 	 d d d ¦  «         n# 1 swxY w Y    ‰| i |¤ŽS r   )r!   r    Ú_remove_listener)r?   r@   r.   r/   r#   s     €€€r   Úgz.EventEmitter.once.<locals>._wrapper.<locals>.gá   sâ   ø€ ð ”Zð $ð $ð  ¤Ð,Ð,°°d´lÀ5Ô6IÐ1IÐ1IØ×-Ò-¨e°QÑ7Ô7Ð7Ð7à#ð$ð $ð $ñ $ô $ð $ð $ð $ð 8ð	$ð $ð $ñ $ô $ð $ð $ð $ð $ð $ð $øøøð $ð $ð $ð $ð �q˜$Ð) &Ð)Ð)Ð)s   ‰1AÁAÁA)r   r8   )r/   rX   r.   r#   s   ` €€r   Ú_wrapperz#EventEmitter.once.<locals>._wrapperà   se   øø€ ð*Ýð*åð*õ ð*ð *ð *ð *ð *ð *ð *ð *ð ×#Ò# E¨1¨aÑ0Ô0Ð0ØˆHr   )r   )r#   r.   r/   rY   s   ``  r   ÚoncezEventEmitter.once×   sO   øø€ ð	�ð 	¥Xð 	ð 	ð 	ð 	ð 	ð 	ð 	ð& ˆ9ØˆOà�8˜A‘;”;Ðr   c                 óŽ   — | j         |                              |¦  «         t          | j         |         ¦  «        s
| j         |= dS dS )zNaked unprotected removal.N)r    ÚpopÚlenr3   s      r   rW   zEventEmitter._remove_listenerø   sN   € àŒ�UÔ×Ò Ñ"Ô"Ð"Ý�4”< Ô&Ñ'Ô'ð 	$Ø”˜UÐ#Ð#Ð#ð	$ð 	$r   c                 ór   — | j         5  |                      ||¦  «         ddd¦  «         dS # 1 swxY w Y   dS )z&Removes the function `f` from `event`.N)r!   rW   r3   s      r   Úremove_listenerzEventEmitter.remove_listenerþ   s„   € àŒZð 	,ð 	,Ø×!Ò! %¨Ñ+Ô+Ð+ð	,ð 	,ð 	,ñ 	,ô 	,ð 	,ð 	,ð 	,ð 	,ð 	,ð 	,ð 	,øøøð 	,ð 	,ð 	,ð 	,ð 	,ð 	,s   ˆ,¬0³0c                 óž   — | j         5  |�t          ¦   «         | j        |<   nt          ¦   «         | _        ddd¦  «         dS # 1 swxY w Y   dS )ztRemove all listeners attached to `event`.
        If `event` is `None`, remove all listeners on all events.
        N)r!   r   r    r   ©r#   r.   s     r   Úremove_all_listenersz!EventEmitter.remove_all_listeners  s”   € ð ŒZð 	&ð 	&ØÐ Ý&1¡m¤m�”˜UÑ#Ð#å#™vœv�”ð		&ð 	&ð 	&ñ 	&ô 	&ð 	&ð 	&ð 	&ð 	&ð 	&ð 	&ð 	&øøøð 	&ð 	&ð 	&ð 	&ð 	&ð 	&s   ˆ-AÁAÁ	Ac                 óŽ   — t          | j                             |t          ¦   «         ¦  «                             ¦   «         ¦  «        S )z:Returns a list of all listeners registered to the `event`.)rM   r    rN   r   rE   ra   s     r   Ú	listenerszEventEmitter.listeners  s2   € å�D”L×$Ò$ U­K©M¬MÑ:Ô:×?Ò?ÑAÔAÑBÔBÐBr   )r   Nr   )!r   r   r   r   r$   r	   Ústrr   r*   r-   r
   r   r   r   r4   r1   r2   r8   r   r   rB   r   rF   rK   ÚboolrR   r>   rZ   rW   r_   rb   r   rd   r   r   r   r   r      s[  € € € € € ðð ð8"ð "ð "ð "ð˜g c¨3 hÔ/ð ð ð ð ð
 '¨#¨s¨(Ô"3ð ¸ð ð ð ð ð
 26ð /ð  /Øð /Ø% gÔ.ð /à	ˆw˜ ' ¨GÐ!3Ô4Ð4Ô	5ð /ð  /ð  /ð  /ðD ð ¨°'°¸GÐ1CÔ(Dð ð ð ð ð( #ð ¨'ð °gð ð ð ð ð '¨ð '°ð '¸Xð 'ð 'ð 'ð 'ðàðð �C˜�HŒoðð �S˜#�X”ð	ð
 
ðð ð ð ð(˜S œXð (ð (ð (ð (ðU°#ð U¸cð UÀdð Uð Uð Uð Uðàðð �C˜�HŒoðð �S˜#�X”ð	ð
 
ðð ð ð ð àðð ðð ð	ð
 
ðð ð ð ð: !%ðð àðð �HÔðð 
ð	ð ð ð ðB$ cð $¨hð $¸4ð $ð $ð $ð $ð, Sð ,¨Xð ,¸$ð ,ð ,ð ,ð ,ð
&ð &¨(°3¬-ð &À4ð &ð &ð &ð &ðC˜sð C t¨H¤~ð Cð Cð Cð Cð Cð Cr   r   N)Úcollectionsr   Ú	threadingr   Útypingr   r   r   r   r	   r
   r   r   r   r   rJ   r   r   r   r   r   r   ú<module>rj      s)  ðð $Ð #Ð #Ð #Ð #Ð #Ø Ð Ð Ð Ð Ð ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð)ð )ð )ð )ð )�Iñ )ô )ð )ð ˆ'�) 8Ð
,Ñ
,Ô
,€ðuCð uCð uCð uCð uCñ uCô uCð uCð uCð uCr   