
    ]j_                        U d Z ddl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 ddlmZmZ ddlmZ ddlmZ  e       Zeed	<   ej.                  ej0                  ej2                  ej4                  ej6                  ej8                  ej:                  ej<                  ej>                  ej@                  d

Z!ee"ef   ed<   dee#ee#df   f   de"defdZ$dee#ee#   f   defdZ%dee#ee#   f   defdZ&g dZ'dddddddddddddede"ded
   dee#ee#   f   dee#ee#   f   d ed   d!ed   d"e"d#ed   d$e"d%ed   d&e(fd'Z)y)(z
Package boxen allows you to create customizable boxes in the terminal

It is built on top of Rich, and is fully compatible with most Rich styling syntax and Rich renderables
    )AnyLiteralUnionDictTuple)box)Align)Box)ConsoleGroup)Padding)Panelconsole)
asciiascii2ascii_double_headsquaresquare_double_headminimalhorizontalsroundedheavydouble	ALL_BOXESsize.instancereturnc                    t        | t              rt        |       dvrt        | d      t        | t              rt        |       dk(  r| d   x}}| d   x}}nct        | t              r#t        |       dk(  r| d   }| d   }| d   }| d   }n0t        | t              r| | dz  | | dz  f\  }}}}nt        | d      ||||fS )	N)      z9 tuples must have either a total of 2 or 4 elements in itr   r      r       z$ must be either int or tuple of ints)
isinstancetuplelen
ValueErrorint	TypeError)r   r   topbottomrightlefts         6/root/env/lib/python3.12/site-packages/pyboxen/main.py
parse_sizer.       s    $3t9F#:jQR
 	
 
D%	 SY!^AwfAw	D%	 SY!^1gQaAw	D#	 $(4#A UFD8*$HIJJ%%    marginc                     t        | d      S )Nr0   r.   )r0   s    r-   make_marginr3   B   s    fh''r/   paddingc                     t        | d      S )Nr4   r2   )r4   s    r-   make_paddingr6   F   s    gy))r/   )r,   centerr+   whiter   r7   r,   NF)colorstyler4   r0   text_alignmentbox_alignmenttitletitle_alignmentsubtitlesubtitle_alignment	fullwidthtextr9   r:   r;   r<   r=   r>   r?   r@   rA   c                 4   	
  
	f	d} |        dt         f 
	fd}t        j                         5 }t        j                   |              ddd       |j	                         S # 1 sw Y   j	                         S xY w)a  
    Create a customizable box to be displayed in the terminal

    :param: *text: A variable set of strings to display in the box, or any other Rich renderable(s)
    :type: Any
    :param color: The color of the box in color or hex code starting with #, defaults to white
    :type color: str (optional)
    :param style: The style of the box, defaults to rounded
    :type style: str (optional)
    :param padding: The padding between the text and the box in int or tuple of ints, defaults to 0
    :type padding: Union[int, Tuple[int]] (optional)
    :param margin: The margin around the box in int or tuple of ints, defaults to 0
    :type margin: Union[int, Tuple[int]] (optional)
    :param text_alignment: The alignment of the text inside the box, defaults to center
    :type text_alignment: Literal["left", "center", "right"] (optional)
    :param box_alignment: The alignment of the box in the terminal, defaults to left
    :type box_alignment: Literal["left", "center", "right"] (optional)
    :param title: The title of the box, displayed on the top of the box, if provided
    :type title: str
    :param title_alignment: The alignment of the title, defaults to left
    :type title_alignment: Literal["left", "center", "right"] (optional)
    :param subtitle: str The subtitle of the box, displayed on the bottom of the box, if provided
    :type subtitle: str
    :param subtitle_alignment: The alignment of the subtitle, defaults to left
    :type subtitle_alignment: Literal["left", "center", "right"] (optional)
    :param fullwidth: If True, the box will expand to fill the entire terminal width, defaults to False
    :type fullwidth: bool (optional)
    :return: A string
    c                    	 rt        t              st        d      rt        t              st        d      rt        t              st        d      r]t        t              r$j                         t        j                         vr)t        dt        t        j                                      r*t        t              rt        vrt        dt                r*t         t              r t        vrt        dt               r*t        t              rt        vrt        dt               r*t        t              rt        vrt        dt               rt        t              st        d	      y y )
Nzcolor must be a stringztitle must be a stringzsubtitle must be a stringzstyle must be one of ztext alignment must be one of zbox alignment must be one of ztitle alignment must be one of z"subtitle alignment must be one of z&fullwidth must be either True or False)
r#   strr(   lowerr   keysr&   listPOSITION_TYPESbool)	r<   r9   rA   r:   r?   r@   r;   r=   r>   s	   r-   validate_argszboxen.<locals>.validate_args   sP    E3/455E3/455Jx57885#&%++-y~~?O*O4T)..:J5K4LMNN>3/>3W=n=MNOO=#.-~2U<^<LMNN?C0n4>~>NOPP-s3!7A.AQRSSZ	48DEE 99r/   r   c                      t        t        t        t        t         	      t        j                            t              
d
      t                           S )N)alignF)

renderabler   border_styleexpandr4   r=   title_alignr?   subtitle_align	highlight)pad)r	   Marginr   r   r   rF   r6   r3   )r<   r9   rA   r0   r4   r:   r?   r@   rB   r;   r=   r>   s   r-   	build_boxzboxen.<locals>.build_box   sh    $UD\H!%++-0!&$(1 /%#5#  '  !
 	
r/   N)r   r   captureprintget)r9   r:   r4   r0   r;   r<   r=   r>   r?   r@   rA   rB   rK   rV   rW   s   ````````````   r-   boxenrZ   M   sw    n#F #FJ O
u 
 
 
( 
	 #gik"# ;;=# ;;=s   A??B)*__doc__typingr   r   r   r   r   richr   
rich.alignr	   rich.boxr
   rich.consoler   r   rich.paddingr   rU   
rich.panelr   r   __annotations__ASCIIASCII2ASCII_DOUBLE_HEADSQUARESQUARE_DOUBLE_HEADMINIMALHORIZONTALSROUNDEDHEAVYDOUBLEr   rE   r'   r.   r3   r6   rI   rJ   rZ    r/   r-   <module>ro      s   4 3    ' * 9  YYjj..jj00{{??{{YYjj	4S> &U3c3h/0 &C &E &D(c5:o. (5 (*%U3Z0 *U * -
  	&'%&9A8>:@=C/uuu 		u 3c
?#u  #uSz/"!u" 56#u$ 45%u& 'u( 67)u* +u,   9:-u. /ur/   