ó
    NÎhA  ã                  ó  • % S SK Jr  S SKJr  S SKJr  S SKJrJrJ	r	  \(       a  S SK
Jr  S SKJr  SSKJr  / S	Qr " S
 S5      r\" S\" 5       S9rS\S'   SS jrSS jrSS jr\SS j5       r\ S     SS jj5       r\SS j5       rg)é    )Úannotations)Úcontextmanager)Ú
ContextVar)ÚTYPE_CHECKINGÚAnyÚ	Generator)ÚInput)ÚOutputé   )ÚApplication)Ú
AppSessionÚget_app_sessionÚget_appÚget_app_or_noneÚset_appÚcreate_app_sessionÚcreate_app_session_from_ttyc                  ód   • \ rS rSrSr S	     S
S jjrSS jr\SS j5       r\SS j5       r	Sr
g)r   é   a-  
An AppSession is an interactive session, usually connected to one terminal.
Within one such session, interaction with many applications can happen, one
after the other.

The input/output device is not supposed to change during one session.

Warning: Always use the `create_app_session` function to create an
instance, so that it gets activated correctly.

:param input: Use this as a default input for all applications
    running in this session, unless an input is passed to the `Application`
    explicitly.
:param output: Use this as a default output.
Nc                ó*   • Xl         X l        S U l        g ©N©Ú_inputÚ_outputÚapp)ÚselfÚinputÚoutputs      Ú_/home/mande/repo/quber/.venv/lib/python3.13/site-packages/prompt_toolkit/application/current.pyÚ__init__ÚAppSession.__init__)   s   € ð ŒØŒð -1ˆ�ó    c                ó$   • SU R                   < S3$ )NzAppSession(app=Ú))r   )r   s    r   Ú__repr__ÚAppSession.__repr__3   s   € Ø  §¡¡¨AÐ.Ð.r"   c                óX   • U R                   c  SSKJn  U" 5       U l         U R                   $ )Nr   ©Úcreate_input)r   Úprompt_toolkit.input.defaultsr)   )r   r)   s     r   r   ÚAppSession.input6   s"   € à�;‰;ÑÝBá&›.ˆDŒKØ�{‰{Ðr"   c                óX   • U R                   c  SSKJn  U" 5       U l         U R                   $ )Nr   ©Úcreate_output)r   Úprompt_toolkit.output.defaultsr.   )r   r.   s     r   r   ÚAppSession.output>   s"   € à�<‰<ÑÝDá(›?ˆDŒLØ�|‰|Ðr"   r   ©NN)r   úInput | Noner   úOutput | NoneÚreturnÚNone)r4   Ústr)r4   r	   )r4   r
   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r    r%   Úpropertyr   r   Ú__static_attributes__© r"   r   r   r      sX   † ñð" CGð1Ø!ð1Ø2?ð1à	õ1ô/ð óó ðð óó ór"   r   Ú_current_app_session)ÚdefaultzContextVar[AppSession]c                 ó*   • [         R                  5       $ r   )r?   Úgetr>   r"   r   r   r   L   s   € Ü×#Ñ#Ó%Ð%r"   c                 óv   • [         R                  5       n U R                  b  U R                  $ SSKJn  U" 5       $ )aï  
Get the current active (running) Application.
An :class:`.Application` is active during the
:meth:`.Application.run_async` call.

We assume that there can only be one :class:`.Application` active at the
same time. There is only one terminal window, with only one stdin and
stdout. This makes the code significantly easier than passing around the
:class:`.Application` everywhere.

If no :class:`.Application` is running, then return by default a
:class:`.DummyApplication`. For practical reasons, we prefer to not raise
an exception. This way, we don't have to check all over the place whether
an actual `Application` was returned.

(For applications like pymux where we can have more than one `Application`,
we'll use a work-around to handle that.)
r   )ÚDummyApplication)r?   rB   r   ÚdummyrD   )ÚsessionrD   s     r   r   r   P   s2   € ô& #×&Ñ&Ó(€GØ‡{�{ÑØ�{‰{Ðå'áÓÐr"   c                 óB   • [         R                  5       n U R                  $ )z^
Get the current active (running) Application, or return `None` if no
application is running.
©r?   rB   r   )rF   s    r   r   r   l   s   € ô
 #×&Ñ&Ó(€GØ�;‰;Ðr"   c              #  ó„   #   • [         R                  5       nUR                  nXl         Sv •  X!l        g! X!l        f = f7f)a•  
Context manager that sets the given :class:`.Application` active in an
`AppSession`.

This should only be called by the `Application` itself.
The application will automatically be active while its running. If you want
the application to be active in other threads/coroutines, where that's not
the case, use `contextvars.copy_context()`, or use `Application.context` to
run it in the appropriate context.
NrH   )r   rF   Úprevious_apps      r   r   r   u   s5   é € ô #×&Ñ&Ó(€Gà—;‘;€LØ„Kð#Ûà"�ø�l�üs   ‚'A ª5 ®A µ=½A Nc              #  ó  #   • U c  [        5       R                  n Uc  [        5       R                  n[        XS9n[        R                  U5      n Uv •  [        R                  U5        g! [        R                  U5        f = f7f)z—
Create a separate AppSession.

This is useful if there can be multiple individual ``AppSession``'s going
on. Like in the case of a Telnet/SSH server.
N©r   r   )r   r   r   r   r?   ÚsetÚreset)r   r   rF   Útokens       r   r   r   ‹   sp   é € ð$ �}ÜÓ!×(Ñ(ˆØ�~Ü Ó"×*Ñ*ˆô ˜uÑ4€Gä ×$Ñ$ WÓ-€Eð*ØŠä×"Ñ" 5Õ)øÔ×"Ñ" 5Õ)üs   ‚ABÁA* ÁBÁ*BÂBc               #  óŠ   #   • SSK Jn   SSKJn  U " SS9nU" SS9n[	        X#S9 nUv •  SSS5        g! , (       d  f       g= f7f)am  
Create `AppSession` that always prefers the TTY input/output.

Even if `sys.stdin` and `sys.stdout` are connected to input/output pipes,
this will still use the terminal for interaction (because `sys.stderr` is
still connected to the terminal).

Usage::

    from prompt_toolkit.shortcuts import prompt

    with create_app_session_from_tty():
        prompt('>')
r   r(   r-   T)Úalways_prefer_ttyrL   N)r*   r)   r/   r.   r   )r)   r.   r   r   Úapp_sessions        r   r   r   ¬   s<   é € õ  ;Ý<á¨4Ñ0€EÙ¨TÑ2€Fä	 %Ò	7¸;ØÒ÷ 
8×	7Ö	7üs   ‚"A¤2©	A²
A ¼A)r4   r   )r4   úApplication[Any])r4   zApplication[Any] | None)r   rS   r4   zGenerator[None, None, None]r1   )r   r2   r   r3   r4   ú!Generator[AppSession, None, None])r4   rT   )Ú
__future__r   Ú
contextlibr   Úcontextvarsr   Útypingr   r   r   Úprompt_toolkit.input.baser	   Úprompt_toolkit.output.baser
   Úapplicationr   Ú__all__r   r?   Ú__annotations__r   r   r   r   r   r   r>   r"   r   Ú<module>r^      sµ   ðÞ "å %Ý "ß 0Ñ 0æÝ/Ý1å(ò€÷,ñ ,ñ^ 0:Ø¡J£Lñ0Ð Ð,ó ô
&ôô8ð ó#ó ð#ð* à8<ð*Øð*Ø(5ð*à&ô*ó ð*ð@ óó ñr"   