
    Yh                     x   % S SK Jr  S SKJrJrJrJrJrJrJ	r	J
r
Jr  S SKrS SKJr  S SKJr  \
" S\S9r\" 5       r\\\/ S4   4   \S'   S	\S
S4S jrS\S\S\S\S
S4
S jr\" SSSSS9r\\\\\4   4   \S'   \\S   \S   \S   4   r\\S   \S   \S   \S   4   r  S"S\	\   S\S\S\S\S \S
\4S! jjrg)#    )wraps)	AnyCallablecastDictOptionalTupleTypeTypeVarUnionN)Literal)EventEmitterUpliftingEventEmitter)boundEMIT_WRAPPERSevent_emitterreturnc                 6    U [         ;   a  [         U    " 5         gg)zAUnwrap an uplifted EventEmitter, returning it to its prior state.N)r   )r   s    =/var/www/html/env/lib/python3.13/site-packages/pyee/uplift.pyunwrapr      s    %m$& &    leftrighterror_handlerproxy_new_listenerc           	      $  ^ ^^^^^ T R                   m[        R                  T 5      m[        T5      S[        S[
        S[
        S[        4UU UU4S jj5       nSU 4S jjnSU UUU4S jjnU[        [
        T 5      l         U[        T '   UT l        g )	Neventargskwargsr   c                    > TR                  XU5      nT(       d  U S:w  a  T	R                  XU5      nOSnU=(       d    UnU(       d  TR                  X(       a  US   OS 5        U$ )Nnew_listenerFr   )_call_handlers_emit_handle_potential_error)
r   r   r   left_handledright_handledhandledr   r   r   r   s
         r   wrapped_emit_wrap.<locals>.wrapped_emit    se    !00fE .!8!00fEM!M/- 66ud1gSWXr   c                  Z   > [         R                  " [        S5      5        [        T 5        g )NzjPatched ee.unwrap() is deprecated and will be removed in a future release. Use pyee.uplift.unwrap instead.)warningswarnDeprecationWarningr   )r   s   r   _unwrap_wrap.<locals>._unwrap3   s&    B	
 	tr   c                     > T[        [        T 5      l        T(       a
  T[        T '   O	[        T 	 T ?T[        [        T 5      l        [	        T5        g )N)r   r   emitr   r   )r   	left_emitleft_unwrapr   s   r   unwrap_hook_wrap.<locals>.unwrap_hook<   s@    (S$"-M$d#(S$ur   )r   N)	r0   r   getr   strr   boolr   r   )	r   r   r   r   r'   r-   r3   r1   r2   s	   ````   @@r   _wrapr8      s     		I0=0A0A$0GK
9C  s t   $	 	 (DdO%M$DKr   )FT)TF)TT)FF)forwardbackwardbothneither_PROXY_NEW_LISTENER_SETTINGSnew
underlyingr<   r9   r:   r;   clserror_handlingr   r   c                     [         U   u  nnU " U0 UD6n[        X4X4X4S9n	X   u  p[        XX5        [        XX5        U$ )a  A helper to create instances of an event emitter `cls` that inherits
event behavior from an `underlying` event emitter instance.

This is mostly helpful if you have a simple underlying event emitter
that you don't have direct control over, but you want to use that
event emitter in a new context - for example, you may want to `uplift` a
`EventEmitter` supplied by a third party library into an
`AsyncIOEventEmitter` so that you may register async event handlers
in your `asyncio` app but still be able to receive events from the
underlying event emitter and call the underlying event emitter's existing
handlers.

When called, `uplift` instantiates a new instance of `cls`, passing
along any unrecognized arguments, and overwrites the `emit` method on
the `underlying` event emitter to also emit events on the new event
emitter and vice versa. In both cases, they return whether the `emit`
method was handled by either emitter. Execution order prefers the event
emitter on which `emit` was called.

The `unwrap` function may be called on either instance; this will
unwrap both `emit` methods.

The `error_handling` flag can be configured to control what happens to
unhandled errors:

- 'new': Error handling for the new event emitter is always used and the
  underlying library's non-event-based error handling is inert.
- 'underlying': Error handling on the underlying event emitter is always
  used and the new event emitter can not implement non-event-based error
  handling.
- 'neither': Error handling for the new event emitter is used if the
  handler was registered on the new event emitter, and vice versa.

Tuning this option can be useful depending on how the underlying event
emitter does error handling. The default is 'new'.

The `proxy_new_listener` option can be configured to control how
`new_listener` events are treated:

- 'forward': `new_listener` events are propagated from the underlying
  event emitter to the new event emitter but not vice versa.
- 'both': `new_listener` events are propagated as with other events.
- 'neither': `new_listener` events are only fired on their respective
  event emitters.
- 'backward': `new_listener` events are propagated from the new event
  emitter to the underlying event emitter, but not vice versa.

Tuning this option can be useful depending on how the `new_listener`
event is used by the underlying event emitter, if at all. The default is
'forward', since `underlying` may not know how to handle certain
handlers, such as asyncio coroutines.

Each event emitter tracks its own internal table of handlers.
`remove_listener`, `remove_all_listeners` and `listeners` all
work independently. This means you will have to remember which event
emitter an event handler was added to!

Note that both the new event emitter returned by `cls` and the
underlying event emitter should inherit from `EventEmitter`, or at
least implement the interface for the undocumented `_call_handlers` and
`_emit_handle_potential_error` methods.
)r>   r?   r<   )r=   dictr8   )r@   r?   rA   r   r   r   new_proxy_new_listenerunderlying_proxy_new_listenerr>   uplift_error_handlersnew_error_handlerunderlying_error_handlers               r   upliftrI   [   so    T 	%%78% "%d!5f!5CJNJJ#;cEVK 3H2W/	#,E	*3SJr   )r>   r9   )	functoolsr   typingr   r   r   r   r   r	   r
   r   r   r*   typing_extensionsr   	pyee.baser   r   rC   r   __annotations__r   r7   r8   r=   r6   ErrorStrategyProxyStrategyrI    r   r   <module>rR      sm    S S S  % " 7|L  9=tL(2t8"445 >', '4 '3
33 3 	3
 
3l >B		> d3dDj(9#9:  gengl&;WY=OOPI
+WV_gi>PP %*(1	W	#	$WW "W &	W
 W W Wr   