+
    Ri6                        R t ^ RIHt ^ RIHtHtHt ^ RIHt ^RI	H
t
HtHtHtHt ^RIHtHtHt . ROt]]]]]
3,          t ! R R4      t ! R	 R]4      tRR
 R lltR# )z
Wrapper for the layout.
)annotations)	GeneratorIterableUnion)Buffer)AnyContainerConditionalContainer	ContainerWindowto_container)BufferControlSearchBufferControl	UIControlLayoutInvalidLayoutErrorc                     ] tR t^tRtR8R R lltR R ltR R ltR	 R
 ltR R lt	R R lt
]R R l4       t]P                  R R l4       t]R R l4       t]P                  R R l4       t]R R l4       t]R R l4       tR R ltR R lt]R R  l4       tR! R" lt]R# R$ l4       t]R% R& l4       tR' R( ltR) R* ltR+ R, ltR- R. ltR/ R0 ltR1 R2 ltR3 R4 ltR5 R6 ltR7tR# )9r   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               $    V ^8  d   QhRRRRRR/# )   	containerr   focused_elementzFocusableElement | NonereturnNone )formats   "[/home/ubuntu/hermes-agent/venv/lib/python3.14/site-packages/prompt_toolkit/layout/layout.py__annotate__Layout.__annotate__(   s(      0  0 0 1 0 
	 0    c                	.   \        V4      V n        . V n        / V n        / V n        Vf5    V P                  P                  \        V P                  4       4      4       MV P                  V4       . V n        R #   \         d   p\        R4      ThR p?ii ; i)Nz>Invalid layout. The layout does not contain any Window object.)r   r   _stacksearch_links_child_to_parentappendnextfind_all_windowsStopIterationr   focusvisible_windows)selfr   r   es   &&& r   __init__Layout.__init__(   s    
 &i0$& GI
 =?"""4(=(=(?#@A JJ' .0 ! (Ts   2A8 8BBBc                   V ^8  d   QhRR/# )r   r   strr   )r   s   "r   r   r   J   s     U U# Ur   c                	@    R V P                   : RV P                  : R2# )zLayout(z, current_window=))r   current_windowr(   s   &r   __repr__Layout.__repr__J   s%    **;D<O<O;RRSTTr   c                   V ^8  d   QhRR/# )r   r   zGenerator[Window, None, None]r   )r   s   "r   r   r   M   s      "? r   c              #  t   "   V P                  4        F  p\        V\        4      '       g   K  Vx  K!  	  R# 5i)z:
Find all the :class:`.UIControl` objects in this layout.
N)walk
isinstancer
   )r(   items   & r   r$   Layout.find_all_windowsM   s)      IIKD$''
  s   '8
8c                   V ^8  d   QhRR/# )r   r   zIterable[UIControl]r   )r   s   "r   r   r   U   s     $ $#6 $r   c              #  	X   "   V P                  4        F  pVP                  x  K  	  R # 5iN)r$   contentr(   r   s   & r   find_all_controlsLayout.find_all_controlsU   s$     ..0I### 1s   (*c                    V ^8  d   QhRRRR/# )r   valueFocusableElementr   r   r   )r   s   "r   r   r   Y   s     L L+ L Lr   c                   \        V\        4      '       do   V P                  4        FJ  p\        V\        4      '       g   K  VP                  P
                  V8X  g   K8  V P                  V4        R# 	  \        RV: R24      h\        V\        4      '       de   V P                  4        F@  p\        V\        4      '       g   K  VP                  V8X  g   K.  V P                  V4        R# 	  \        RV: R24      h\        V\        4      '       dI   WP                  4       9  d   \        R4      hVP                  4       '       g   \        R4      hWn        R# \        V4      p\        V\        4      '       d,   WP                  4       9  d   \        RV: 24      hWn        R# . p\!        VRR7       FN  p\        V\        4      '       g   K  VP"                  P                  4       '       g   K=  VP%                  V4       KP  	  \'        V P(                  4       F  pWS9   g   K  WPn         R# 	  V'       d   V^ ,          V n        R# \        R	V: 24      h)
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_hiddenz,Invalid value. Container cannot be focused: )r7   r-   r?   r   buffernamer&   
ValueErrorr   r   is_focusablecurrent_controlr   r
   r$   r0   r6   r=   r"   reversedr   )r(   rB   controlwindowscws   &&    r   r&   Layout.focusY   s    eS!!113g}55'..:M:MQV:VJJw' 4 KE9TUVWW v&&113g}55'..E:QJJw' 4 KE9TUVWW y))2244 M  %%'' !MNN#(  !'E%(( 5 5 77$OPUyY  ',# e6A!!V,,1G1G1I1Iq) 7
 "$++.A|./+ / *1!*D' B5)L r   c                    V ^8  d   QhRRRR/# )r   rB   rC   r   boolr   )r   s   "r   r   r      s      / D r   c                   \        V\        4      '       d*   V P                  f   R# V P                  P                  V8H  # \        V\        4      '       d   V P                  V8H  # \        V\
        4      '       d   V P                  V8H  # \        V4      p\        V\        4      '       d   V P                  V8H  # \        V4       F  pW P                  8X  g   K   R# 	  R# )zp
Check whether the given control has the focus.
:param value: :class:`.UIControl` or :class:`.Window` instance.
FT)r7   r-   current_bufferrI   r   r   rL   r   r
   r0   r6   )r(   rB   elements   && r   	has_focusLayout.has_focus   s    
 eS!!""*&&++u44eV$$&&%//eY''''500 'E%((**e33  $E{G"5"55#  + r   c                   V ^8  d   QhRR/# r   r   r   r   )r   s   "r   r   r      s     ' ' 'r   c                <    V P                   R,          P                  # )z9
Get the :class:`.UIControl` to currently has the focus.
)r   r=   r1   s   &r   rL   Layout.current_control   s    
 {{2&&&r   c                    V ^8  d   QhRRRR/# )r   rN   r   r   r   r   )r   s   "r   r   r      s     	E 	Ey 	ET 	Er   c                z    V P                  4        F  pVP                  V8X  g   K  W n         R# 	  \        R4      h)z3
Set the :class:`.UIControl` to receive the focus.
Nz(Control not found in the user interface.)r$   r=   r0   rJ   )r(   rN   windows   && r   rL   r^      s:    
 ++-F~~(&,# .
 CDDr   c                   V ^8  d   QhRR/# )r   r   r
   r   )r   s   "r   r   r      s       r   c                (    V P                   R,          # )z=Return the :class:`.Window` object that is currently focused.r]   )r   r1   s   &r   r0   Layout.current_window   s     {{2r   c                    V ^8  d   QhRRRR/# )r   rB   r
   r   r   r   )r   s   "r   r   r      s     " "F "t "r   c                <    V P                   P                  V4       R# )z8Set the :class:`.Window` object to be currently focused.N)r   r"   )r(   rB   s   &&r   r0   rd      s     	5!r   c                   V ^8  d   QhRR/# r   r   rT   r   )r   s   "r   r   r      s     9 9d 9r   c                4    V P                   V P                  9   # )z#True if we are searching right now.)rL   r    r1   s   &r   is_searchingLayout.is_searching   s     ##t'8'888r   c                   V ^8  d   QhRR/# )r   r   zBufferControl | Noner   )r   s   "r   r   r      s      .B r   c                    V P                   p\        V\        4      '       d   V P                  P	                  V4      # R# )zI
Return the :class:`.BufferControl` in which we are searching or `None`.
N)rL   r7   r   r    get)r(   rN   s   & r   search_target_buffer_control#Layout.search_target_buffer_control   s7     &&g233$$((11r   c                   V ^8  d   QhRR/# )r   r   zIterable[Window]r   )r   s   "r   r   r      s      '7 r   c              #     "   V P                  4        FA  p\        V\        4      '       g   K  VP                  P	                  4       '       g   K=  Vx  KC  	  R# 5i)zT
Return all the :class:`.Window` objects which are focusable (in the
'modal' area).
N)walk_through_modal_arear7   r
   r=   rK   )r(   rQ   s   & r   get_focusable_windowsLayout.get_focusable_windows   s>     
 --/A!V$$)?)?)A)A 0s   'AA
Ac                   V ^8  d   QhRR/# )r   r   zlist[Window]r   )r   s   "r   r   r      s     Q Q| Qr   c                t    V P                   pV P                  4        Uu. uF  q"V9   g   K  VNK  	  up# u upi )z?
Return a list of :class:`.Window` objects that are focusable.
)r'   rt   )r(   r'   rQ   s   &  r   get_visible_focusable_windows$Layout.get_visible_focusable_windows   s9     ..557P7a;O7PPPs   55c                   V ^8  d   QhRR/# )r   r   Buffer | Noner   )r   s   "r   r   r     s       r   c                b    V P                   p\        V\        4      '       d   VP                  # R# )z4
The currently focused :class:`~.Buffer` or `None`.
N)rL   r7   r   rH   r(   
ui_controls   & r   rV   Layout.current_buffer  s+    
 ))
j-00$$$r   c                    V ^8  d   QhRRRR/# )r   buffer_namer-   r   r{   r   )r   s   "r   r   r     s     	 	c 	m 	r   c                "   V P                  4        Fz  p\        V\        4      '       g   K  \        VP                  \        4      '       g   K=  VP                  P
                  P                  V8X  g   Kd  VP                  P
                  u # 	  R# )z\
Look in the layout for a buffer with the given name.
Return `None` when nothing was found.
N)r6   r7   r
   r=   r   rH   rI   )r(   r   rQ   s   && r   get_buffer_by_nameLayout.get_buffer_by_name  s^    
 A!V$$AII})M)M99##((K799+++  r   c                   V ^8  d   QhRR/# rh   r   )r   s   "r   r   r     s     5 5$ 5r   c                :    V P                   p\        V\        4      # )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.)
)rL   r7   r   r}   s   & r   buffer_has_focusLayout.buffer_has_focus  s     ))
*m44r   c                   V ^8  d   QhRR/# r[   r   )r   s   "r   r   r   "  s     + +) +r   c                     V P                   R,          P                  #   \         d!    T P                   R,          P                  u # i ; i)z:
Get the :class:`.UIControl` to previously had the focus.
r]   )r   r=   
IndexErrorr1   s   &r   previous_controlLayout.previous_control!  s>    
	+;;r?*** 	+;;r?***	+s    (A
	A
c                   V ^8  d   QhRR/# r   r   r   r   )r   s   "r   r   r   +  s     + +D +r   c                f    \        V P                  4      ^8  d   V P                  RR V n        R# R# )z-
Give the focus to the last focused control.
Nr]   )lenr   r1   s   &r   
focus_lastLayout.focus_last+  s,     t{{a++cr*DK  r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   2  s     ' 'D 'r   c                   V P                  4       p\        V4      ^ 8  dO    VP                  V P                  4      pV^,           \        V4      ,          pV P                  W,          4       R# R#   \         d    ^ p L*i ; i)z*
Focus the next visible/focusable Window.
Nrx   r   indexr0   rJ   r&   r(   rO   r   s   &  r   
focus_nextLayout.focus_next2  t     446w<!3d&9&9: c'l2JJw~&      A1 1B Bc                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   B  s     ' ' 'r   c                   V P                  4       p\        V4      ^ 8  dO    VP                  V P                  4      pV^,
          \        V4      ,          pV P                  W,          4       R# R#   \         d    ^ p L*i ; i)z.
Focus the previous visible/focusable Window.
Nr   r   s   &  r   focus_previousLayout.focus_previousB  r   r   c                   V ^8  d   QhRR/# r   r   Iterable[Container]r   )r   s   "r   r   r   R  s     ( () (r   c              #  L   "   \        V P                  4       Rj  xL
  R#  L5i)zH
Walk through all the layout nodes (and their children) and yield them.
N)r6   r   r1   s   &r   r6   Layout.walkR  s      '''s   $"$c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   X  s      )< r   c              #     "   V P                   pVP                  4       '       g&   WP                  9   d   V P                  V,          pK;  \        V4       Rj  xL
  R#  L5i)zV
Walk through all the containers which are in the current 'modal' part
of the layout.
N)r0   is_modalr!   r6   )r(   roots   & r   rs   Layout.walk_through_modal_areaX  sE      ----//d.C.C&C((.D:s   "A!3A!AA!c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   e  s     ( ($ (r   c                T   aa / oR VV3R lloS! V P                   4       SV n        R# )z-
Update child->parent relationships mapping.
c                    V ^8  d   QhRRRR/# )r   r)   r	   r   r   r   )r   s   "r   r   5Layout.update_parents_relations.<locals>.__annotate__k  s     	 	I 	$ 	r   c                P   < V P                  4        F  pV SV&   S! V4       K  	  R # r<   )get_children)r)   rP   parentsr6   s   & r   r6   -Layout.update_parents_relations.<locals>.walkk  s$    ^^%
Q &r   N)r   r!   )r(   r   r6   s   &@@r   update_parents_relationsLayout.update_parents_relationse  s*     	 	
 	T^^ 'r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   t  s      t r   c                	n    V P                   P                  4        V P                  P                  4        R # r<   )r    clearr   resetr1   s   &r   r   Layout.resett  s&    
 	!r   c                    V ^8  d   QhRRRR/# )r   r   r	   r   zContainer | Noner   )r   s   "r   r   r   }  s      I 2B r   c                N     V P                   V,          #   \         d     R# i ; i)zW
Return the parent container for the given container, or ``None``, if it
wasn't found.
N)r!   KeyErrorr>   s   &&r   
get_parentLayout.get_parent}  s*    
	((33 		s    $$)r!   r   r   rL   r0   r    r'   r<   ) __name__
__module____qualname____firstlineno____doc__r*   r2   r$   r?   r&   rX   propertyrL   setterr0   rj   ro   rt   rx   rV   r   r   r   r   r   r   r6   rs   r   r   r   __static_attributes__r   r   r   r   r      s(    0DU$L\2 ' ' 	E 	E   " " 9 9  Q  	 5 5 + ++' ' (( r   c                      ] tR tRtRtR# )r   i  r   N)r   r   r   r   r   r   r   r   r   r     s    r   c               $    V ^8  d   QhRRRRRR/# )r   r   r	   rG   rT   r   r   r   )r   s   "r   r   r     s"     4 4I 4D 4=P 4r   c              #     "   V'       d/   \        V \        4      '       d   V P                  4       '       g   R# V x  V P                  4        F  p\	        W!R7       Rj  xL
  K  	  R#  L
5i)z2
Walk through layout, starting at this container.
NrF   )r7   r   filterr   r6   )r   rG   rP   s   && r   r6   r6     sS      	y"677  ""
O##%333 &3s   4A,(A,A* A,N)r   r   r6   )F)r   
__future__r   typingr   r   r   prompt_toolkit.bufferr   
containersr   r   r	   r
   r   controlsr   r   r   __all__r-   rC   r   	Exceptionr   r6   r   r   r   <module>r      sk    # - - (  D C fi=> h hV	 	4 4r   