ó
    OÎhˆ6  ã                  ó¶   • S r SSKJr  SSKJrJrJr  SSKJr  SSK	J
r
JrJrJrJr  SSKJrJrJr  / SQr\\\\\
4   r " S	 S
5      r " S S\5      rSSS jjrg)z
Wrapper for the layout.
é    )Úannotations)Ú	GeneratorÚIterableÚUnion)ÚBufferé   )ÚAnyContainerÚConditionalContainerÚ	ContainerÚWindowÚto_container)ÚBufferControlÚSearchBufferControlÚ	UIControl)ÚLayoutÚInvalidLayoutErrorÚwalkc                  ó®  • \ 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5       r\R                  S'S j5       r\S(S j5       r\R                  S)S j5       r\S*S j5       r\S+S j5       rS,S jrS-S jr\S.S j5       rS/S jr\S*S j5       r\S&S j5       rS0S jrS0S jrS0S jrS1S jrS1S jrS0S jrS0S jrS2S jrSrg)3r   é   a0  
The layout for a prompt_toolkit
:class:`~prompt_toolkit.application.Application`.
This also keeps track of which user control is focused.

:param container: The "root" container for the layout.
:param focused_element: element to be focused initially. (Can be anything
    the `focus` function accepts.)
Nc                ó(  • [        U5      U l        / U l        0 U l        0 U l        Uc4   U R                  R                  [        U R                  5       5      5        OU R                  U5        / U l        g ! [         a  n[        S5      UeS nAff = f)Nz>Invalid layout. The layout does not contain any Window object.)r   Ú	containerÚ_stackÚsearch_linksÚ_child_to_parentÚappendÚnextÚfind_all_windowsÚStopIterationr   ÚfocusÚvisible_windows)Úselfr   Úfocused_elementÚes       ÚY/home/mande/repo/quber/.venv/lib/python3.13/site-packages/prompt_toolkit/layout/layout.pyÚ__init__ÚLayout.__init__(   s•   € ô
 & iÓ0ˆŒØ$&ˆŒð GIˆÔð
 =?ˆÔàÑ"ðØ—‘×"Ñ"¤4¨×(=Ñ(=Ó(?Ó#@ÕAð �J‰J�Ô'ð .0ˆÕøô !ó Ü(ØTóàðûðús   ª2A6 Á6
BÂ BÂBc                ó@   • SU R                   < SU R                  < S3$ )NzLayout(z, current_window=Ú))r   Úcurrent_window©r!   s    r$   Ú__repr__ÚLayout.__repr__J   s%   € Ø˜Ÿ™Ñ*Ð*;¸D×<OÑ<OÑ;RÐRSÐTÐTó    c              #  óp   #   • U R                  5        H  n[        U[        5      (       d  M  Uv •  M      g7f)z:
Find all the :class:`.UIControl` objects in this layout.
N)r   Ú
isinstancer   )r!   Úitems     r$   r   ÚLayout.find_all_windowsM   s)   é € ð —I‘I–KˆDÜ˜$¤×'Ó'Ø”
ò  ùs   ‚'6­	6c              #  óV   #   • U R                  5        H  nUR                  v •  M     g 7f©N)r   Úcontent©r!   r   s     r$   Úfind_all_controlsÚLayout.find_all_controlsU   s$   é € Ø×.Ñ.Ö0ˆIØ×#Ñ#Ô#ò 1ùs   ‚')c                ó€  • [        U[        5      (       ak  U R                  5        HG  n[        U[        5      (       d  M  UR                  R
                  U:X  d  M6  U R                  U5          g   [        SU< S35      e[        U[        5      (       aa  U R                  5        H=  n[        U[        5      (       d  M  UR                  U:X  d  M,  U R                  U5          g   [        SU< S35      e[        U[        5      (       aE  XR                  5       ;  a  [        S5      eUR                  5       (       d  [        S5      eXl        g[        U5      n[        U[        5      (       a)  XR                  5       ;  a  [        SU< 35      eXl        g/ n[!        USS9 HL  n[        U[        5      (       d  M  UR"                  R                  5       (       d  M;  UR%                  U5        MN     ['        U R(                  5       H  nXS;   d  M
  XPl          g   U(       a  US	   U l        g[        S
U< 35      e)a`  
Focus the given UI element.

`value` can be either:

- a :class:`.UIControl`
- a :class:`.Buffer` instance or the name of a :class:`.Buffer`
- a :class:`.Window`
- Any container object. In this case we will focus the :class:`.Window`
  from this container that was focused most recent, or the very first
  focusable :class:`.Window` of the container.
Nz,Couldn't find Buffer in the current layout: Ú.z7Invalid value. Container does not appear in the layout.z*Invalid value. UIControl is not focusable.z5Invalid value. Window does not appear in the layout: T©Úskip_hiddenr   z,Invalid value. Container cannot be focused: )r/   Ústrr6   r   ÚbufferÚnamer   Ú
ValueErrorr   r   Úis_focusableÚcurrent_controlr   r   r   r)   r   r4   r   Úreversedr   )r!   ÚvalueÚcontrolÚwindowsÚcÚws         r$   r   ÚLayout.focusY   sõ  € ô �eœS×!Ñ!Ø×1Ñ1Ö3�Ü˜g¤}×5Ó5¸'¿.¹.×:MÑ:MÐQVÕ:VØ—J‘J˜wÔ'Ùñ 4ô ÐKÈEÉ9ÐTUÐVÓWÐWô ˜œv×&Ñ&Ø×1Ñ1Ö3�Ü˜g¤}×5Ó5¸'¿.¹.ÈEÕ:QØ—J‘J˜wÔ'Ùñ 4ô ÐKÈEÉ9ÐTUÐVÓWÐWô ˜œy×)Ñ)Ø×2Ñ2Ó4Ó4Ü ØMóð ð ×%Ñ%×'Ñ'Ü Ð!MÓNÐNà#(Õ ô ! Ó'ˆEä˜%¤×(Ñ(à× 5Ñ 5Ó 7Ó7Ü$ØOÐPUÉyÐYóð ð ',Õ#ð �Ü˜e°Ô6�AÜ! !¤V×,Ó,°·±×1GÑ1G×1IÓ1IØŸ™ qÖ)ñ 7ô
 " $§+¡+Ö.�AØ•|Ø./Ô+Ùñ /ö Ø*1°!©*�DÔ'Øä ØBÀ5Á)ÐLóð r-   c                ó°  • [        U[        5      (       a'  U R                  c  gU R                  R                  U:H  $ [        U[        5      (       a  U R                  U:H  $ [        U[
        5      (       a  U R                  U:H  $ [        U5      n[        U[        5      (       a  U R                  U:H  $ [        U5       H  nX R                  :X  d  M    g   g)zp
Check whether the given control has the focus.
:param value: :class:`.UIControl` or :class:`.Window` instance.
FT)r/   r<   Úcurrent_bufferr>   r   r   rA   r   r   r)   r   )r!   rC   Úelements      r$   Ú	has_focusÚLayout.has_focus§   s¿   € ô
 �eœS×!Ñ!Ø×"Ñ"Ñ*ØØ×&Ñ&×+Ñ+¨uÑ4Ð4Ü�eœV×$Ñ$Ø×&Ñ&¨%Ñ/Ð/Ü�eœY×'Ñ'Ø×'Ñ'¨5Ñ0Ð0ä  Ó'ˆEÜ˜%¤×(Ñ(Ø×*Ñ*¨eÑ3Ð3ô  $ Ež{�GØ×"5Ñ"5Õ5Ù#ñ  +ð r-   c                ó4   • U R                   S   R                  $ )z9
Get the :class:`.UIControl` to currently has the focus.
éÿÿÿÿ)r   r4   r*   s    r$   rA   ÚLayout.current_controlÀ   s   € ð
 �{‰{˜2‰×&Ñ&Ð&r-   c                óv   • U R                  5        H  nUR                  U:X  d  M  X l          g   [        S5      e)z3
Set the :class:`.UIControl` to receive the focus.
Nz(Control not found in the user interface.)r   r4   r)   r?   )r!   rD   Úwindows      r$   rA   rP   Ç   s:   € ð
 ×+Ñ+Ö-ˆFØ�~‰~ Õ(Ø&,Ô#Ùñ .ô
 ÐCÓDÐDr-   c                ó    • U R                   S   $ )z=Return the :class:`.Window` object that is currently focused.rO   )r   r*   s    r$   r)   ÚLayout.current_windowÓ   s   € ð �{‰{˜2‰Ðr-   c                ó:   • U R                   R                  U5        g)z8Set the :class:`.Window` object to be currently focused.N)r   r   )r!   rC   s     r$   r)   rT   Ø   s   € ð 	�‰×Ñ˜5Õ!r-   c                ó4   • U R                   U R                  ;   $ )z#True if we are searching right now.)rA   r   r*   s    r$   Úis_searchingÚLayout.is_searchingÝ   s   € ð ×#Ñ# t×'8Ñ'8Ñ8Ð8r-   c                ó|   • U R                   n[        U[        5      (       a  U R                  R	                  U5      $ g)zI
Return the :class:`.BufferControl` in which we are searching or `None`.
N)rA   r/   r   r   Úget)r!   rD   s     r$   Úsearch_target_buffer_controlÚ#Layout.search_target_buffer_controlâ   s7   € ð ×&Ñ&ˆä�gÔ2×3Ñ3Ø×$Ñ$×(Ñ(¨Ó1Ð1àr-   c              #  ó²   #   • U R                  5        H?  n[        U[        5      (       d  M  UR                  R	                  5       (       d  M;  Uv •  MA     g7f)zT
Return all the :class:`.Window` objects which are focusable (in the
'modal' area).
N)Úwalk_through_modal_arear/   r   r4   r@   )r!   rG   s     r$   Úget_focusable_windowsÚLayout.get_focusable_windowsð   s>   é € ð
 ×-Ñ-Ö/ˆAÜ˜!œV×$Ó$¨¯©×)?Ñ)?×)AÓ)AØ”ò 0ùs   ‚'A­AÁ	Ac                ót   • U R                   nU R                  5        Vs/ s H  o"U;   d  M
  UPM     sn$ s  snf )z?
Return a list of :class:`.Window` objects that are focusable.
)r    r_   )r!   r    rG   s      r$   Úget_visible_focusable_windowsÚ$Layout.get_visible_focusable_windowsù   s7   € ð ×.Ñ.ˆØ×5Ñ5Ô7ÓPÒ7�aÀÑ;O—Ñ7ÑPÐPùÒPs   Ÿ	5¬5c                ó^   • U R                   n[        U[        5      (       a  UR                  $ g)z4
The currently focused :class:`~.Buffer` or `None`.
N)rA   r/   r   r=   ©r!   Ú
ui_controls     r$   rJ   ÚLayout.current_buffer  s+   € ð
 ×)Ñ)ˆ
Ü�j¤-×0Ñ0Ø×$Ñ$Ð$Ør-   c                ó  • U R                  5        Hw  n[        U[        5      (       d  M  [        UR                  [        5      (       d  M;  UR                  R
                  R                  U:X  d  Ma  UR                  R
                  s  $    g)z\
Look in the layout for a buffer with the given name.
Return `None` when nothing was found.
N)r   r/   r   r4   r   r=   r>   )r!   Úbuffer_namerG   s      r$   Úget_buffer_by_nameÚLayout.get_buffer_by_name  s^   € ð
 —‘–ˆAÜ˜!œV×$Ó$¬°A·I±I¼}×)MÓ)MØ—9‘9×#Ñ#×(Ñ(¨KÕ7ØŸ9™9×+Ñ+Ò+ñ ð r-   c                ó:   • U R                   n[        U[        5      $ )zª
Return `True` if the currently focused control is a
:class:`.BufferControl`. (For instance, used to determine whether the
default key bindings should be active or not.)
)rA   r/   r   re   s     r$   Úbuffer_has_focusÚLayout.buffer_has_focus  s   € ð ×)Ñ)ˆ
Ü˜*¤mÓ4Ð4r-   c                óˆ   •  U R                   S   R                  $ ! [         a    U R                   S   R                  s $ f = f)z:
Get the :class:`.UIControl` to previously had the focus.
éþÿÿÿrO   )r   r4   Ú
IndexErrorr*   s    r$   Úprevious_controlÚLayout.previous_control!  s>   € ð
	+Ø—;‘;˜r‘?×*Ñ*Ð*øÜó 	+Ø—;‘;˜r‘?×*Ñ*Ò*ð	+ús   ‚ ›#AÁ Ac                ó`   • [        U R                  5      S:”  a  U R                  SS U l        gg)z-
Give the focus to the last focused control.
r   NrO   )Úlenr   r*   s    r$   Ú
focus_lastÚLayout.focus_last+  s,   € ô ˆt�{‰{Ó˜aÓØŸ+™+ c rÐ*ˆD�Kð  r-   c                óè   • U R                  5       n[        U5      S:”  aA   UR                  U R                  5      nUS-   [        U5      -  nU R                  X   5        gg! [         a    Sn N#f = f)z*
Focus the next visible/focusable Window.
r   r   N©rb   ru   Úindexr)   r?   r   ©r!   rE   rz   s      r$   Ú
focus_nextÚLayout.focus_next2  ót   € ð ×4Ñ4Ó6ˆäˆw‹<˜!Óð3ØŸ™ d×&9Ñ&9Ó:�ð  ™¤c¨'£lÑ2�à�J‰J�w‘~Õ&ð øô ó Ø’ðúó   ¡A" Á"A1Á0A1c                óè   • U R                  5       n[        U5      S:”  aA   UR                  U R                  5      nUS-
  [        U5      -  nU R                  X   5        gg! [         a    Sn N#f = f)z.
Focus the previous visible/focusable Window.
r   r   Nry   r{   s      r$   Úfocus_previousÚLayout.focus_previousB  r~   r   c              #  óJ   #   • [        U R                  5       Sh  v•N   g N7f)zH
Walk through all the layout nodes (and their children) and yield them.
N)r   r   r*   s    r$   r   ÚLayout.walkR  s   é € ô ˜Ÿ™Ó'×'Ó'ùs   ‚#›!œ#c              #  ó   #   • U R                   nUR                  5       (       dD  XR                  ;   a5  U R                  U   nUR                  5       (       d  XR                  ;   a  M5  [        U5       Sh  v•N   g N7f)zV
Walk through all the containers which are in the current 'modal' part
of the layout.
N)r)   Úis_modalr   r   )r!   Úroots     r$   r^   ÚLayout.walk_through_modal_areaX  s_   é € ð ×-Ñ-ˆØ—-‘-—/‘/ d×.CÑ.CÓ&CØ×(Ñ(¨Ñ.ˆDð —-‘-—/‘/ d×.CÑ.CÕ&Cô ˜“:×Óùs   ‚A$A>Á(A>Á6A<Á7A>c                óP   ^^• 0 mSUU4S jjmT" U R                   5        TU l        g)z-
Update child->parent relationships mapping.
c                óN   >• U R                  5        H  nU TU'   T" U5        M     g r3   )Úget_children)r#   rF   Úparentsr   s     €€r$   r   Ú-Layout.update_parents_relations.<locals>.walkk  s$   ø€ Ø—^‘^Ö%�Ø�˜‘
Ù�Q–ò &r-   N)r#   r   ÚreturnÚNone)r   r   )r!   rŒ   r   s    @@r$   Úupdate_parents_relationsÚLayout.update_parents_relationse  s*   ù€ ð ˆ÷	ð 	ñ
 	ˆT�^‰^Ôà 'ˆÕr-   c                ól   • U R                   R                  5         U R                  R                  5         g r3   )r   Úclearr   Úresetr*   s    r$   r”   ÚLayout.resett  s&   € ð
 	×Ñ×ÑÔ!à�‰×ÑÕr-   c                óB   •  U R                   U   $ ! [         a     gf = f)zW
Return the parent container for the given container, or ``None``, if it
wasn't found.
N)r   ÚKeyErrorr5   s     r$   Ú
get_parentÚLayout.get_parent}  s*   € ð
	Ø×(Ñ(¨Ñ3Ð3øÜó 	Ùð	ús   ‚ ‘
�)r   r   r   rA   r)   r   r    r3   )r   r	   r"   zFocusableElement | NonerŽ   r�   )rŽ   r<   )rŽ   zGenerator[Window, None, None])rŽ   zIterable[UIControl])rC   ÚFocusableElementrŽ   r�   )rC   rš   rŽ   Úbool)rŽ   r   )rD   r   rŽ   r�   )rŽ   r   )rC   r   rŽ   r�   )rŽ   r›   )rŽ   zBufferControl | None)rŽ   zIterable[Window])rŽ   zlist[Window])rŽ   úBuffer | None)ri   r<   rŽ   rœ   )rŽ   r�   )rŽ   úIterable[Container])r   r   rŽ   zContainer | None) Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r%   r+   r   r6   r   rL   ÚpropertyrA   Úsetterr)   rW   r[   r_   rb   rJ   rj   rm   rr   rv   r|   r�   r   r^   r�   r”   r˜   Ú__static_attributes__© r-   r$   r   r      sD  † ñð 48ð 0àð 0ð 1ð 0ð 
õ	 0ôDUôô$ôLô\ð2 ó'ó ð'ð ×Ñó	Eó ð	Eð óó ðð ×Ñó"ó ð"ð ó9ó ð9ð óó ðôôQð óó ðô	ð ó5ó ð5ð ó+ó ð+ô+ô'ô 'ô (ôô(ô÷r-   r   c                  ó   • \ rS rSrSrg)r   iˆ  r¦   N)rž   rŸ   r    r¡   r¥   r¦   r-   r$   r   r   ˆ  s   † Úr-   r   c              #  óÌ   #   • U(       a+  [        U [        5      (       a  U R                  5       (       d  gU v •  U R                  5        H  n[	        X!S9 Sh  v•N   M     g N	7f)z2
Walk through layout, starting at this container.
Nr:   )r/   r
   Úfilterr‹   r   )r   r;   rF   s      r$   r   r   Œ  sS   é € ö 	Ü�yÔ"6×7Ñ7Ø× Ñ ×"Ñ"àà
‚Oà×#Ñ#Ö%ˆä˜Ñ3×3Ò3ò &á3ùs   ‚AA$ÁA"Á
A$N)F)r   r   r;   r›   rŽ   r�   )r¢   Ú
__future__r   Útypingr   r   r   Úprompt_toolkit.bufferr   Ú
containersr	   r
   r   r   r   Úcontrolsr   r   r   Ú__all__r<   rš   r   Ú	Exceptionr   r   r¦   r-   r$   Ú<module>r±      sf   ðñõ #ç -Ñ -å (÷õ ÷ DÑ Cò€ð ˜˜f i°Ð=Ñ>Ð ÷hñ hôV	˜ô 	÷4r-   