
    h!                       S SK Jr  S SKrS SKrS SKrS SKrS SKJr  S SKJ	r	J
r
JrJrJrJrJr  S SKJr  / SQrS\R$                  ;   r\" SS	S
9r " S S\\   5      r " S S\
S   5      r " S S\\\4   5      r\" 5       rSS jrS S jrS S jrS S jrS S jrS S jr S S jr!S!S jr"\" S5      r#      S"S jr$S#S jr%S$S jr&\\	/ \'4   \'4   r(S%S jr)S&S'S jjr*g)(    )annotationsN)deque)CallableContextManagerDict	GeneratorGenericTypeVarUnion)wcwidth)EventDummyContext
get_cwidthsuspend_to_background_supportedis_conemu_ansi
is_windowsin_main_threadget_bell_environment_variableget_term_environment_variabletake_using_weightsto_strto_intAnyFloatto_floatis_dumb_terminalzsphinx.ext.autodoc_SenderT)	covariantc                  n    \ rS rSrSr S     SS jjrSS jrSS jrSS jrSS jr	SS	 jr
SS
 jrSrg)r   -   a}  
Simple event to which event handlers can be attached. For instance::

    class Cls:
        def __init__(self):
            # Define event. The first parameter is the sender.
            self.event = Event(self)

    obj = Cls()

    def handler(sender):
        pass

    # Add event handler by using the += operator.
    obj.event += handler

    # Fire event.
    obj.event()
Nc                .    Xl         / U l        Ub  X-  n g g N)sender	_handlers)selfr"   handlers      gC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\prompt_toolkit/utils.py__init__Event.__init__B   s"     :<OD     c                N    U R                    H  nU" U R                  5        M     g)zFire event.Nr#   r"   r$   r%   s     r&   __call__Event.__call__K   s    ~~GDKK  &r)   c                    U " 5         g)z!Alias for just calling the event.N r$   s    r&   fire
Event.fireP   s    r)   c                :    U R                   R                  U5        g)z{
Add another handler to this callback.
(Handler should be a callable that takes exactly one parameter: the
sender object.)
N)r#   appendr,   s     r&   add_handlerEvent.add_handlerT   s     	g&r)   c                Z    XR                   ;   a  U R                   R                  U5        gg)z&
Remove a handler from this callback.
N)r#   remover,   s     r&   remove_handlerEvent.remove_handler]   s%     nn$NN!!'* %r)   c                (    U R                  U5        U $ )z3
`event += handler` notation for adding a handler.
)r6   r,   s     r&   __iadd__Event.__iadd__d   s     	!r)   c                (    U R                  U5        U $ )z5
`event -= handler` notation for removing a handler.
)r:   r,   s     r&   __isub__Event.__isub__k   s     	G$r)   r+   r!   )r"   r   r%   z Callable[[_Sender], None] | NonereturnNonerB   rC   )r%   Callable[[_Sender], None]rB   rC   )r%   rE   rB   zEvent[_Sender])__name__
__module____qualname____firstlineno____doc__r'   r-   r2   r6   r:   r=   r@   __static_attributes__r0   r)   r&   r   r   -   sI    * LP(H	!
'+r)   r   c                  ,    \ rS rSrSrSS jrSS jrSrg)	r   s   z-
(contextlib.nested is not available on Py3)
c                    g r!   r0   r1   s    r&   	__enter__DummyContext.__enter__x       r)   c                    g r!   r0   )r$   as     r&   __exit__DummyContext.__exit__{   rQ   r)   r0   NrD   )rS   objectrB   rC   )rF   rG   rH   rI   rJ   rO   rT   rK   r0   r)   r&   r   r   s   s    r)   r   c                  B   ^  \ rS rSrSrSrSrSU 4S jjrS	S jrSr	U =r
$ )
_CharSizesCache   z
Cache for wcwidth sizes.
@      c                @   > [         TU ]  5         [        5       U l        g r!   )superr'   r   _long_strings)r$   	__class__s    r&   r'   _CharSizesCache.__init__   s    ).r)   c                V  ^  [        U5      S:X  a  [        S[        U5      5      nO[        U 4S jU 5       5      nUT U'   [        U5      T R                  :  aO  T R
                  nUR                  U5        [        U5      T R                  :  a  UR                  5       nUT ;   a  T U	 U$ )N   r   c              3  .   >#    U  H
  nTU   v   M     g 7fr!   r0   ).0cr$   s     r&   	<genexpr>._CharSizesCache.__missing__.<locals>.<genexpr>   s     1&Qa&s   )	lenmaxr   sumLONG_STRING_MIN_LENr^   r5   MAX_LONG_STRINGSpopleft)r$   stringresultlong_stringskey_to_removes   `    r&   __missing___CharSizesCache.__missing__   s     v;!GFO,F1&11F V v;111--L'< 4#8#88 , 4 4 6 D(]+r)   )r^   rD   rn   strrB   int)rF   rG   rH   rI   rJ   rk   rl   r'   rr   rK   __classcell__)r_   s   @r&   rX   rX      s%     1
 r)   rX   c                    [         U    $ )z7
Return width of a string. Wrapper around ``wcwidth``.
)_CHAR_SIZES_CACHE)rn   s    r&   r   r      s     V$$r)   c                 "    [        [        S5      $ )z}
Returns `True` when the Python implementation supports
suspend-to-background. This is typically `False' on Windows systems.
SIGTSTP)hasattrsignalr0   r)   r&   r   r      s    
 69%%r)   c                 (    [         R                  S:H  $ )z!
True when we are using Windows.
win32)sysplatformr0   r)   r&   r   r      s     <<7""r)   c                 F    [         R                  S:X  a  SSKJn   U " 5       $ g)zK
True when we are using Windows, but VT100 escape sequences are supported.
r   r   is_win_vt100_enabledF)r   r   prompt_toolkit.output.windows10r   r   s    r&   is_windows_vt100_supportedr      s     ||wH#%%r)   c                 |    [         R                  S:H  =(       a#    [        R                  R	                  SS5      S:H  $ )z/
True when the ConEmu Windows console is used.
r   
ConEmuANSIOFFON)r   r   osenvirongetr0   r)   r&   r   r      s,     <<7"Rrzz~~lE'Jd'RRr)   c                 Z    [         R                  " 5       R                  R                  S:H  $ )z2
True when the current thread is the main thread.
_MainThread)	threadingcurrent_threadr_   rF   r0   r)   r&   r   r      s$     ##%//88MIIr)   c                 h    [         R                  R                  SS5      n U R                  5       S;   $ )z<
True if env variable is set to true (true, TRUE, True, 1).
PROMPT_TOOLKIT_BELLtrue)1r   )r   r   r   lowervalues    r&   r   r      s*     JJNN0&9E;;=M))r)   c                 B    [         R                  R                  SS5      $ )z&Return the $TERM environment variable.TERM )r   r   r   r0   r)   r&   r   r      s    ::>>&"%%r)   _Tc              #  8  #    [        U 5      [        U5      :X  d   e[        U 5      S:  d   e/ n/ n[        X5       H/  u  pEUS:  d  M  UR                  U5        UR                  U5        M1     Un UnU (       d  [        S5      eU  Vs/ s H  nSPM     nn[        U 5      n[	        U5      n	Sn Sn
U
(       aT  Sn
[        [        U5      X5       H0  u  pnX{   Xl-  [        U	5      -  :  d  M  Uv   X{==   S-  ss'   Sn
M2     U
(       a  MT  US-  nMd  s  snf 7f)a  
Generator that keeps yielding items from the items list, in proportion to
their weight. For instance::

    # Getting the first 70 items from this generator should have yielded 10
    # times A, 20 times B and 40 times C, all distributed equally..
    take_using_weights(['A', 'B', 'C'], [5, 10, 20])

:param items: List of items to take from.
:param weights: Integers representing the weight. (Numbers have to be
                integers, not floats.)
r   z+Did't got any items with a positive weight.TFrb   )rh   zipr5   
ValueErrorri   rangefloat)itemsweightsitems2weights2itemwialready_taken
item_count
max_weightaddingitem_iweights                r&   r   r      s*     u:W%%%u:>> FHu&q5MM$OOA '
 EG FGG !&&1QM&UJWJ	A
F(+E*,=u(N$f (1:j8I+IIJ!)Q.)!F	 )O f 	
Q  's&   AD
A D
DAD/DDc                X    [        U 5      (       a  [        U " 5       5      $ [        U 5      $ )z$Turn callable or string into string.)callabler   ru   r   s    r&   r   r   "  !    eg5zr)   c                X    [        U 5      (       a  [        U " 5       5      $ [        U 5      $ )zTurn callable or int into int.)r   r   rv   r   s    r&   r   r   *  r   r)   c                X    [        U 5      (       a  [        U " 5       5      $ [        U 5      $ )z"Turn callable or float into float.)r   r   r   r   s    r&   r   r   5  s"      U|r)   c                    U c)  [        [        R                  R                  SS5      5      $ U R	                  5       S;   $ )z
True if this terminal type is considered "dumb".

If so, we should fall back to the simplest possible form of line editing,
without cursor positioning and color support.
r   r   )dumbunknown)r   r   r   r   r   )terms    r&   r   r   =  s5     |

vr :;;::<...r)   rt   )rB   bool)rB   ru   )r   zlist[_T]r   z	list[int]rB   zGenerator[_T, None, None])r   zCallable[[], str] | strrB   ru   )r   zCallable[[], int] | intrB   rv   )r   r   rB   r   r!   )r   z
str | NonerB   r   )+
__future__r   r   r}   r   r   collectionsr   typingr   r   r   r   r	   r
   r   r   __all__modulesSPHINX_AUTODOC_RUNNINGr   r   r   ru   rv   rX   ry   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r0   r)   r&   <module>r      s   " 	  
     ( .< 
)t
,CGG CL	>$' 	&d38n &R $% %&#
SJ*&
 T]33'33l "e)$e+,
/r)   