
    #7h6                        d dl mZmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
mZmZmZmZmZmZmZmZ ddlmZ ddlmZ dd	lmZmZmZmZ dd
lmZ ddlmZ ddl m!Z! ddl"m#Z# ddl$m%Z%m&Z& ddl'm(Z( ddl)m*Z* e
rd dl+m,Z,  G d de      Z-ede#f   Z.ede-f   Z/ G d de0      Z1 G d de1      Z2 G d d      Z3 G d de      Z4 G d de4      Z5 G d d e4      Z6e& G d! d             Z7e8d"k(  rd d#l9mZ  e       Z e7       Z:e:jw                   e7d$d%&       e7dd'(       e7d)d*+             e:d'   jy                   e7d,-       e7d.d/0             e:d.   jy                   e7d1d/0       e7d2-             e:d2   jw                   e7d3-       e7d4-       e7d5-             e:d,   jw                   e7e:jz                  d6-       e7d7-             e:d1   j}                  d8       ej                  e:       y9y9):    )ABCabstractmethod)islice)
itemgetter)RLock)	TYPE_CHECKINGDictIterableList
NamedTupleOptionalSequenceTupleUnion   )ratio_resolve)Align)ConsoleConsoleOptionsRenderableTypeRenderResult)ReprHighlighter)Panel)Pretty)Region)Result	rich_repr)Segment)	StyleTypeTreec                   2    e Zd ZU dZeed<   eee      ed<   y)LayoutRenderzAn individual layout render.regionrenderN)__name__
__module____qualname____doc__r   __annotations__r   r        U/var/www/urcfiles/bundle/venv/lib/python3.12/site-packages/pip/_vendor/rich/layout.pyr#   r#       s    &Ngr,   r#   Layoutc                       e Zd ZdZy)LayoutErrorzLayout related error.Nr&   r'   r(   r)   r+   r,   r-   r0   r0   +   s    r,   r0   c                       e Zd ZdZy)
NoSplitterz"Requested splitter does not exist.Nr1   r+   r,   r-   r3   r3   /   s    ,r,   r3   c                   H    e Zd ZdZ e       ZddddeddfdZded	e	de
fd
Zy)_Placeholderz4An internal renderable used as a Layout placeholder.layoutr.   stylereturnNc                      || _         || _        y N)r6   r7   )selfr6   r7   s      r-   __init__z_Placeholder.__init__8   s    
r,   consoleoptionsc              #   j  K   |j                   }|j                  xs |j                  j                  }| j                  }|j                  r|j                  d| d| dnd| d| d}t        t        j                  t        |      d      | j                  | j                  |      d|       y w)	Nz (z x )(middle)verticalblue)r7   titleborder_styleheight)	max_widthrG   sizer6   namer   r   centerr   r7   highlighter)r;   r=   r>   widthrG   r6   rE   s          r-   __rich_console__z_Placeholder.__rich_console__<   s      !!67<<#6#6 {{ {{oRwc&3UG3vha( 	
 LL(;**""5)
 	
s   B1B3) )r&   r'   r(   r)   r   rL   r   r<   r   r   r   rN   r+   r,   r-   r5   r5   3   sD    >!#Kx 	 4 

)7
	
r,   r5   c            
       j    e Zd ZU dZdZeed<   edefd       Zede	d   de
deede
f      fd	       Zy
)SplitterzBase class for a splitter.rO   rJ   r8   c                      y)z(Get the icon (emoji) used in layout.treeNr+   r;   s    r-   get_tree_iconzSplitter.get_tree_iconU       r,   childrenr.   r$   c                      y)zDivide a region amongst several child layouts.

        Args:
            children (Sequence(Layout)): A number of child layouts.
            region (Region): A rectangular region to divide.
        Nr+   )r;   rV   r$   s      r-   dividezSplitter.divideY   rU   r,   N)r&   r'   r(   r)   rJ   strr*   r   rT   r   r   r
   r   rX   r+   r,   r-   rQ   rQ   P   sg    $D#N7s 7 7  *4:	%&()	* r,   rQ   c            	       J    e Zd ZdZdZdefdZded   dede	e
def      fdZy	)
RowSplitterz!Split a layout region in to rows.rowr8   c                      y)Nu   [layout.tree.row]⬌r+   rS   s    r-   rT   zRowSplitter.get_tree_iconj   s    %r,   rV   r.   r$   c              #      K   |\  }}}}t        ||      }d}t        }	t        ||      D ]  \  }
}|
 |	||z   |||      f ||z  } y wNr   r   r   zip)r;   rV   r$   xyrM   rG   render_widthsoffset_Regionchildchild_widths               r-   rX   zRowSplitter.dividem   sf      %1eV%eX6"%h">E;VQVDDDk!F #?   AA
Nr&   r'   r(   r)   rJ   rY   rT   r   r   r
   r   rX   r+   r,   r-   r[   r[   e   sG    +D&s &	" *	"4:	"	%&()	*	"r,   r[   c            	       J    e Zd ZdZdZdefdZded   dede	e
def      fdZy	)
ColumnSplitterz$Split a layout region in to columns.columnr8   c                      y)Nu   [layout.tree.column]⬍r+   rS   s    r-   rT   zColumnSplitter.get_tree_icon~   s    (r,   rV   r.   r$   c              #      K   |\  }}}}t        ||      }d}t        }	t        ||      D ]  \  }
}|
 |	|||z   ||      f ||z  } y wr_   r`   )r;   rV   r$   rb   rc   rM   rG   render_heightsre   rf   rg   child_heights               r-   rX   zColumnSplitter.divide   sg      %1eV&vx8#&x#@E<AJ|DDDl"F $Ari   Nrj   r+   r,   r-   rl   rl   y   sG    .D)s )	# *	#4:	#	%&()	*	#r,   rl   c                      e Zd ZdZeedZ	 d*dddddddee   dee	   d	ee
   d
e
de
deddfdZdefdZedefd       Zeded    fd       Zedefd       Zde	ded    fdZde	dd fdZed+d       Zddded ef   deee	f   ddfdZded ef   ddfdZded ef   ddfdZded ef   ddfdZd,dZdeddfdZd d!d"e	ddfd#Z d$e
d%e
de!fd&Z"d e#d'e$defd(Z%d e#d'e$de&fd)Z'y)-r.   aB  A renderable to divide a fixed height in to rows or columns.

    Args:
        renderable (RenderableType, optional): Renderable content, or None for placeholder. Defaults to None.
        name (str, optional): Optional identifier for Layout. Defaults to None.
        size (int, optional): Optional fixed size of layout. Defaults to None.
        minimum_size (int, optional): Minimum size of layout. Defaults to 1.
        ratio (int, optional): Optional ratio for flexible layout. Defaults to 1.
        visible (bool, optional): Visibility of layout. Defaults to True.
    )r\   rm   Nr   T)rJ   rI   minimum_sizeratiovisible
renderablerJ   rI   rs   rt   ru   r8   c                    |xs t        |       | _        || _        || _        || _        || _        || _         | j                  d          | _        g | _	        i | _
        t               | _        y )Nrm   )r5   _renderablerI   rs   rt   rJ   ru   	splitterssplitter	_children_render_mapr   _lock)r;   rv   rJ   rI   rs   rt   ru   s          r-   r<   zLayout.__init__   sg     &;d);	(
	":$..":"<')&(W
r,   c              #      K   d| j                   d f d| j                  d f d| j                  df d| j                  df y w)NrJ   rI   rs   r   rt   )rJ   rI   rs   rt   rS   s    r-   __rich_repr__zLayout.__rich_repr__   sL     dii%%dii%%d//22tzz1$$s   AAc                 6    | j                   r| S | j                  S )zLayout renderable.)r{   rx   rS   s    r-   rv   zLayout.renderable   s     ~~t;4+;+;;r,   c                 Z    | j                   D cg c]  }|j                  s| c}S c c}w )zGets (visible) layout children.)r{   ru   )r;   rg   s     r-   rV   zLayout.children   s&     $(>>C>%U]]>CCCs   ((c                     | j                   S )zGet a map of the last render.)r|   rS   s    r-   mapz
Layout.map   s     r,   c                 v    | j                   |k(  r| S | j                  D ]  }|j                  |      }||c S  y)zGet a named layout, or None if it doesn't exist.

        Args:
            name (str): Name of layout.

        Returns:
            Optional[Layout]: Layout instance or None if no layout was found.
        N)rJ   r{   get)r;   rJ   rg   named_layouts       r-   r   z
Layout.get   sA     99K$yy+'' ( r,   c                 H    | j                  |      }|t        d|      |S )NzNo layout with name )r   KeyError)r;   rJ   r6   s      r-   __getitem__zLayout.__getitem__   s,    $>1$:;;r,   c                     ddl m ddlm ddlm} dddffd| } | |      d	|j                  j                   d
      }dfd ||        |S )z/Get a tree renderable to show layout structure.r   )Styled)Tabler    r6   r.   r8   c                     | j                   j                         }j                  d      }| j                  rt	        |       n t	        |       d      }|j                  ||       |}|S )N)r   r   r   r   )paddingdim)rz   rT   gridru   r   add_row)r6   icontabletext_summaryr   r   s        r-   summaryzLayout.tree.<locals>.summary   s`    ??002DJJ|J4E #)..vfVF^U6S  MM$%HOr,   layout.tree.T)guide_style	highlightc                     |j                   D ]9  } | j                   |      d|j                  j                         |       ; y )Nr   )r   )r{   addrz   rJ   )treer6   rg   recurser   s      r-   r   zLayout.tree.<locals>.recurse   sM    ))HH&25>>3F3F2G$H    *r,   )r   r!   r6   r.   r8   N)pip._vendor.rich.styledr   pip._vendor.rich.tabler   pip._vendor.rich.treer!   rz   rJ   )r;   r!   r6   r   r   r   r   r   s       @@@@r-   r   zLayout.tree   sg     	30.
	H 
	 
	 FO&v';';&<=
	 	dr,   rm   )rz   layoutsrz   c                   |D cg c]  }t        |t              r|n
t        |      ! }}	 t        |t              r|n | j                  |          | _        || j                  dd yc c}w # t
        $ r t        d|      w xY w)zSplit the layout in to multiple sub-layouts.

        Args:
            *layouts (Layout): Positional arguments should be (sub) Layout instances.
            splitter (Union[Splitter, str]): Splitter instance or name of splitter.
        zNo splitter called N)
isinstancer.   rQ   ry   rz   r   r3   r{   )r;   rz   r   r6   _layoutss        r-   splitzLayout.split  s     "
! !0FfVnD! 	 
	A h1 -T^^H-/ M %q
  	A28,?@@	As   $A'+A, ,Bc                 L    d |D        }| j                   j                  |       y)zAdd a new layout(s) to existing split.

        Args:
            *layouts (Union[Layout, RenderableType]): Positional arguments should be renderables or (sub) Layout instances.

        c              3   V   K   | ]!  }t        |t              r|n
t        |       # y wr:   )r   r.   ).0r6   s     r-   	<genexpr>z#Layout.add_split.<locals>.<genexpr>%  s*      
! !0FfVnD!s   ')N)r{   extend)r;   r   r   s      r-   	add_splitzLayout.add_split  s%    
!
 	h'r,   c                 (     | j                   |ddi y)zSplit the layout in to a row (layouts side by side).

        Args:
            *layouts (Layout): Positional arguments should be (sub) Layout instances.
        rz   r\   Nr   r;   r   s     r-   	split_rowzLayout.split_row+  s     	

G,e,r,   c                 (     | j                   |ddi y)zSplit the layout in to a column (layouts stacked on top of each other).

        Args:
            *layouts (Layout): Positional arguments should be (sub) Layout instances.
        rz   rm   Nr   r   s     r-   split_columnzLayout.split_column3  s     	

G/h/r,   c                 "    | j                   dd= y)zReset splits to initial state.N)r{   rS   s    r-   unsplitzLayout.unsplit;  s    NN1r,   c                 T    | j                   5  || _        ddd       y# 1 sw Y   yxY w)zjUpdate renderable.

        Args:
            renderable (RenderableType): New renderable object.
        N)r}   rx   )r;   rv   s     r-   updatezLayout.update?  s     ZZ)D ZZs   'r=   r   layout_namec                 2   | j                   5  | |   }| j                  |   \  }}|\  }}}}	|j                  ||j                  j	                  ||	            }
t        ||
      | j                  |<   |j                  |
||       ddd       y# 1 sw Y   yxY w)zRefresh a sub-layout.

        Args:
            console (Console): Console instance where Layout is to be rendered.
            layout_name (str): Name of layout.
        N)r}   r|   render_linesr>   update_dimensionsr#   update_screen_lines)r;   r=   r   r6   r$   _linesrb   rc   rM   rG   liness              r-   refresh_screenzLayout.refresh_screenH  s     ZZ+&F!--f5NFF$*!Q5&((99%HE (4FE'BDV$''q!4 ZZs   A7BBrM   rG   c                 t   | t        dd||      fg}|j                  }|j                  }g }|j                  }|rO | |              |d   \  }}	|j                  }
|
r)|j                  j                  |
|	      D ]
  } ||        |rOt        |t        d            D 	ci c]  \  }}	||	
 }}}	|S c c}	}w )z,Create a dict that maps layout on to Region.r   r   )key)r   appendpoprV   rz   rX   sortedr   )r;   rM   rG   stackpushr   layout_regionsappend_layout_regionr6   r$   rV   child_and_region
region_maps                r-   _make_region_mapzLayout._make_region_mapY  s    /3VAq%5P.Q-R||ii68-44 '+B/NFFH(.(>(>x(P$)* )Q  #)Z]"K
"K FN"K 	 
 	
s   "B4r>   c                    |j                   }|j                  xs |j                  }| j                  ||      }|j                         D cg c]  \  }}|j                  s||f }}}i }	|j
                  }
|j                  }|D ]B  \  }} |
|j                   ||j                  |j                              }t        ||      |	|<   D |	S c c}}w )zRender the sub_layouts.

        Args:
            console (Console): Console instance.
            options (ConsoleOptions): Console options.

        Returns:
            RenderMap: A dict that maps Layout on to a tuple of Region, lines
        )
rH   rG   r   itemsrV   r   r   rv   rM   r#   )r;   r=   r>   render_widthrender_heightr   r6   r$   r   
render_mapr   r   r   s                r-   r%   zLayout.rendern  s     ((8'..**<G
 #-"2"2"4
"4?? V"4 	 

 68
++#55,NFF !!#4V\\6==#QE ".fe!<Jv	 -
 
s   Cc           
   #   D  K   | j                   5  |j                  xs |j                  }|j                  xs |j                  }| j	                  ||j                  ||            }|| _        t        |      D cg c]  }g  }}t        }|j                         D ]<  \  }	}
|	\  }}}}t         |||||z         |
      D ]  \  }}|j                  |        > t        j                         }|D ]  }|E d {    |  	 d d d        y c c}w 7 # 1 sw Y   y xY wwr:   )r}   rH   rM   rG   r%   r   r|   ranger   valuesra   r   r   line)r;   r=   r>   rM   rG   r   _layout_lines_islicer$   r   _xrc   _layout_widthlayout_heightr\   r   new_line
layout_rows                      r-   rN   zLayout.__rich_console__  s     ZZ%%6E^^5w~~FWg.G.Gv.VWJ)D=B6]0K]]L0KG!+!2!2!46<3A}m!$L!Q->?"IC JJt$" "5 ||~H*
%%% + Z
 1L &! Zs<   D A+D:	DA5D8D9
D	D DDD r:   )r8   r!   )r8   N)(r&   r'   r(   r)   r[   rl   ry   r   r   rY   intboolr<   r   r   propertyrv   r   rV   	RenderMapr   r   r   r   r   rQ   r   r   r   r   r   r   r   	RegionMapr   r   r   r%   r   rN   r+   r,   r-   r.   r.      s;   	 $~>I 04 #"^, sm	
 sm    
*%v % <N < < D$x. D D  Y      2 $   $ $R *2%.01% #&% 
	%2(%.(@"A (d (-%.(@"A -d -0U8^+C%D 0 0* *D *5i 5c 5d 5"c 3 9 *g  9 :)7	r,   __main__)r   header   )rJ   rI   main)rt   rJ   
   footer)rI   rJ   side)rJ   body   )rJ   rt   contents2toprB   bottomleft1left2fooN)@abcr   r   	itertoolsr   operatorr   	threadingr   typingr   r	   r
   r   r   r   r   r   r   _ratior   alignr   r=   r   r   r   r   rL   r   panelr   prettyr   r$   r   reprr   r   segmentr   r7   r   r   r!   r#   r   r   	Exceptionr0   r3   r5   rQ   r[   rl   r.   r&   pip._vendor.rich.consoler6   r   r   r   r   printr+   r,   r-   <module>r      s   #   
 
 
 "  J J (    #  * :   6!"	<'(	 )  - -
 
:s *"( "(#X #( Q Q Qh z0iGXF
H1%QV$BX& 6NV0&fA2NO
6NV!<f$>OP
4LEF16x3H 6Nv{{ A6wCWX
9U#MM&1 r,   