Current File : /home/inlingua/miniconda3/lib/python3.1/site-packages/rich/__pycache__/panel.cpython-312.pyc
�

~�Eg�+��d�ddlmZmZddlmZddlmZmZddlm	Z	ddl
mZddlm
Z
mZddlmZmZdd	lmZdd
lmZmZddlmZmZerddlmZmZmZmZGd
�de�Ze dk(rJddlmZe�Z!ddlm"Z"mZddlmZeddde"d��Z#e!jI�e!jIe#�yy)�)�
TYPE_CHECKING�Optional�)�AlignMethod)�ROUNDED�Box)�cell_len)�JupyterMixin)�Measurement�measure_renderables)�Padding�PaddingDimensions)�Segment)�Style�	StyleType)�Text�TextType)�Console�ConsoleOptions�RenderableType�RenderResultc �x�eZdZdZefddddddddddddd�d	d
dedeed
edeededee	de	de
de
deedeedede	ddfd�Z
eefdddddddddddd�d	d
dedeed
edeededee	de
de
deedeedede	ddfd��Zedeefd��Zedeefd��Z						d d�Z						d!d�Zy)"�PanelaXA console renderable that draws a border around its contents.

    Example:
        >>> console.print(Panel("Hello, World!"))

    Args:
        renderable (RenderableType): A console renderable object.
        box (Box, optional): A Box instance that defines the look of the border (see :ref:`appendix_box`. Defaults to box.ROUNDED.
        title (Optional[TextType], optional): Optional title displayed in panel header. Defaults to None.
        title_align (AlignMethod, optional): Alignment of title. Defaults to "center".
        subtitle (Optional[TextType], optional): Optional subtitle displayed in panel footer. Defaults to None.
        subtitle_align (AlignMethod, optional): Alignment of subtitle. Defaults to "center".
        safe_box (bool, optional): Disable box characters that don't display on windows legacy terminal with *raster* fonts. Defaults to True.
        expand (bool, optional): If True the panel will stretch to fill the console width, otherwise it will be sized to fit the contents. Defaults to True.
        style (str, optional): The style of the panel (border and contents). Defaults to "none".
        border_style (str, optional): The style of the border. Defaults to "none".
        width (Optional[int], optional): Optional width of panel. Defaults to None to auto-detect.
        height (Optional[int], optional): Optional height of panel. Defaults to None to auto-detect.
        padding (Optional[PaddingDimensions]): Optional padding around renderable. Defaults to 0.
        highlight (bool, optional): Enable automatic highlighting of panel title (if str). Defaults to False.
    N�centerT�none)rrF)�title�title_align�subtitle�subtitle_align�safe_box�expand�style�border_style�width�height�padding�	highlight�
renderabler�boxrrrrr r!r"r#r$r%r&r'�returnc���||_||_||_||_||_||_||_||_|	|_|
|_	||_
||_|
|_||_
y)N)r(r)rrrrr r!r"r#r$r%r&r')�selfr(r)rrrrr r!r"r#r$r%r&r's               �*lib/python3.12/site-packages/rich/panel.py�__init__zPanel.__init__(si��$%��������
�(3��� ��
�,��� ��
������
�(�����
�������"���)rrrrr r"r#r$r%r&r'c�.�||||||||||	|
|||
d��S)z2An alternative constructor that sets expand=False.F)rrrrr r"r#r$r%r&r'r!�)�clsr(r)rrrrr r"r#r$r%r&r's              r-�fitz	Panel.fitIs;��&����#��)���%������
�	
r/c�f�|jr�t|jt�rtj|j�n|jj�}d|_|jjdd�|_d|_	|j�|jd�|Sy�N��
� Tr)r�
isinstance�strr�from_markup�copy�end�plain�replace�no_wrap�expand_tabs�pad)r,�
title_texts  r-�_titlezPanel._titlems����:�:��d�j�j�#�.�� � ����,��Z�Z�_�_�&�
�
 �J�N�)�/�/�7�7��c�B�J��!%�J���"�"�$��N�N�1����r/c�f�|jr�t|jt�rtj|j�n|jj�}d|_|jjdd�|_d|_	|j�|jd�|Syr5)rr9r:rr;r<r=r>r?r@rArB)r,�
subtitle_texts  r-�	_subtitlezPanel._subtitle}s����=�=��d�m�m�S�1�� � ����/��]�]�'�'�)�
�
!#�M��"/�"5�"5�"=�"=�d�C�"H�M��$(�M�!��%�%�'����a� � � �r/c#�\�K�tj|j�}t|�rt|j|�n|j}�j|j�}�j|j�}||z}|j�|jnt|j|j�}|j��jn|j}	|jj||	��}
dtdtdt dt dt"dtf�fd�}|j$}|�|j'|�|j(r|d	z
n.�j+||j-|d	z
��
�j.}
|j0xs|j0xsd}|r|d	z}|�0t|jd	z
t3|
|j4d	z��}
|
d	z}|j7|
||j8��}�j;|||��}t=|
j>|�}t=|
j@�|�}t=jB�}|�|d
kr"t=|
jE|d	z
g�|���n�|||d
z
|jF|
jH|�}t=|
jJ|
jHz|����jM||j-|d
z
��Ed{���t=|
jH|
jNz|���|��|D]}|��|Ed{���|��|���|jP}|�|j'|�|�|d
kr"t=|
jS|d	z
g�|���n�|||d
z
|jT|
jV|�}t=|
jX|
jVz|����jM||j-|d
z
��Ed{���t=|
jV|
jZz|���|��y7��17��7�3�w)N)�safe�textr$�align�	characterr"r*c����|j�}|j|�|t|j�z
}|jr*|j�j
|j��|rr|dk(rtj|||z|fdd��S|dk(r,|dz}tj||z|f||||z
z|fdd��Stj||z|f|dd��S|S)acGets new aligned text.

            Args:
                text (Text): Title or subtitle text.
                width (int): Desired width.
                align (str): Alignment.
                character (str): Character for alignment.
                style (Style): Border style

            Returns:
                Text: New text instance
            �leftTr6)r@r=r�)	r<�truncater	r>r"�stylize�	get_styler�assemble)rJr$rKrLr"�excess_spacerN�consoles       �r-�
align_textz*Panel.__rich_console__.<locals>.align_text�s�����9�9�;�D��M�M�%� � �8�D�J�J�#7�7�L��z�z����W�.�.�t�z�z�:�;���F�?��=�=��"�\�1�5�9� $��	���h�&�'�1�,�D��=�=�"�T�)�5�1��"�l�T�&9�:�E�B� $���� �=�=�"�\�1�5�9�� $��	���Kr/rO)�options)r$r%r')r"�).r
�unpackr&�anyr(rRr"r#r$�	max_width�minr r)�
substituter�intr:rrD�stylize_beforer!�measure�update_width�maximumr%�maxr	�updater'�render_linesr�mid_left�	mid_right�line�get_topr�top�top_left�render�	top_rightrG�
get_bottomr�bottom�bottom_left�bottom_right)r,rUrW�_paddingr(r"�partial_border_styler#r$r r)rVrC�child_width�child_height�
child_options�lines�
line_start�line_end�new_linerhrFs `                    r-�__rich_console__zPanel.__rich_console__�s�������>�>�$�,�,�/��25�h�-�G�D�O�O�X�.�T�_�_�	��!�!�$�*�*�-��&�0�0��1B�1B�C���3�3���z�z�!�
����W�&�&��
�
�3�	�.2�]�]�-B��)�)��
�
���h�h�!�!�'��!�9��-	��-	�"�-	�+.�-	�;>�-	�GL�-	�
�-	�^�[�[�
��!��%�%�&:�;��{�{�
�A�I�����G�$8�$8����$C�!���g�	��{�{�<�g�n�n�<�����A��L��!���!�!�A�%�s�;�
�8K�8K�a�8O�'P��K��a�������l�d�n�n�'�
�
��$�$�Z��e�$�L���S�\�\�<�8�
��c�m�m�_�|�<���<�<�>�����!���#�+�+�u�q�y�k�2�L�A�A�#����	�� � ������J��#�,�,����0�,�?�?��~�~�j�-�2L�2L�U�UV�Y�2W�X�X�X��#�'�'�C�M�M�1�<�@�@����D����O�O��N��N�	����
��$��(�(�)=�>�� �E�Q�J��#�.�.�%�!�)��5�|�D�D�&����	��#�#��
�
���M��#�/�/�C�J�J�6��E�E��~�~��}�9�9�%�!�)�D��
�
��#�*�*�s�'7�'7�7��F�F���=
Y��
��&
�s7�K1P,�4P%�5;P,�0P(�1CP,�6P*�7/P,�(P,�*P,c�h�|j}tj|j�\}}}}||z}|r|j|gn|jg}|j
�=t
||j|j|z
dz
�|�j|zdz}	n|j
}	t|	|	�S)NrO)rDr
rYr&r(r$rrar[rbr)
r,rUrWrD�_�rightrNr&�renderablesr$s
          r-�__rich_measure__zPanel.__rich_measure__s�������#�N�N�4�<�<�8���5�!�T���,��39�t����/����?P���:�:��#���(�(��):�):�W�)D�q�)H�I����'����
�
��J�J�E��5�%�(�(r/)rUrrWrr*r)rUrrWrr*r)�__name__�
__module__�__qualname__�__doc__rrrrr�boolrr^rr.�classmethodr3�propertyrrDrGr{r�r1r/r-rrsF���2�#�
%)�#+�'+�&.�#'��!�"(�#� $�%+��!#�$�#��#�
��!�#�!�
#��8�$�#�$�#��4�.�#��#��#� �#���}�#���
�#�#�#� �!#�"
�##�B��!
�
%)�#+�'+�&.�#'�!�"(�#� $�%+��!
�$�!
��!
�
��!�!
�!�
!
��8�$�!
�$�!
��4�.�!
��!
� �!
���}�!
���
�!
�#�!
��!
� 
�!!
��!
�F�
����
��
��
�8�D�>�
��
�G� �G�+;�G�	�G�R)� �)�+;�)�	�)r/r�__main__)r)�DOUBLEr)r
z
Hello, World!z
rich.Panelz
white on blue)rr"r)r&N)%�typingrrrKrr)rr�cellsr	�jupyterr
r`rrr&r
r�segmentrr"rrrJrrrUrrrrrr��cr��p�printr1r/r-�<module>r�s���*����!�5�/��#� ��N�N�Y)�L�Y)�x�z�� ��	�A�$� �
������	�A��G�G�I��G�G�A�J�#r/