
    )ini                     (   S SK r S SKJr  S SKJr  S SKJrJr  S SKJ	r	  S SK
JrJrJrJrJrJrJrJr  SSKJr  SS	KJrJrJrJr  SS
KJrJr  SSKJrJr  \" SSSSSS5      r \\!S4   r" " S S5      r#\ " S S5      5       r$\$" 5       r% " S S5      r&g)    N)	lru_cache)
attrgetter)dumpsloads)randint)AnyDictIterableListOptionalTypeUnioncast   )errors)ColorColorParseErrorColorSystem	blend_rgb)Result	rich_repr)DEFAULT_TERMINAL_THEMETerminalTheme_color_bgcolor_attributes_set_attributes_link_metaStylec                   R    \ rS rSrSrS/rS\SS4S jrSS	S
\S	   S\	\
   4S jrSrg)_Bit   z.A descriptor to get/set a style attribute bit.bitbit_noreturnNc                     SU-  U l         g )Nr   r$   )selfr%   s     J/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/rich/style.py__init___Bit.__init__   s    ;    objr    objtypec                 x    UR                   U R                  -  (       a  UR                  U R                  -  S:g  $ g )Nr   )r   r$   r   )r)   r.   r/   s      r*   __get___Bit.__get__   s/    )??TXX-22r-   r(   )__name__
__module____qualname____firstlineno____doc__	__slots__intr+   r   r   boolr1   __static_attributes__ r-   r*   r"   r"      sA    8Is t 7 T'] x~ r-   r"   c            &          \ rS rSr% Sr\\   \S'   \\   \S'   \\S'   \\S'   \\   \S'   \	\S'   \\
   \S	'   / S
QrSSSSSSSSSSSSSS.r0 SS_SS_SS_SS_SS_SS_SS_S S_S!S!_S"S"_S#S#_S$S#_S%S%_S&S%_S'S'_S(S'_S)S)_S)S*S+S,S,S-.ErS.S.S.S.S.S.S.S.S.S.S.S.S.S.S.S.S.S/.S0\\\\4      S1\\\\4      S\\	   S\\	   S\\	   S\\	   S!\\	   S"\\	   S#\\	   S%\\	   S'\\	   S)\\	   S*\\	   S+\\	   S,\\	   S2\\   S3\\\\4      4"S4 jjr\StS6 j5       r\ SuS0\\   S1\\   S5S 4S7 jj5       r\S3\\\\4      S5S 4S8 j5       r\SvS3\\\\4      S9\S5S 4S: jj5       r\" S;5      r\" S<5      r\" S=5      r\" S>5      r\" S?5      r\" S@5      r\" SA5      r\" SB5      r \" SC5      r!\" SD5      r"\" SE5      r#\" SF5      r$\" SG5      r%\&S5\4SH j5       r'S5\4SI jr(S5\	4SJ jr)SK\*S5\4SL jr+\\," SMSN9SO\S5\4SP j5       5       r-\SQ\\.   S5\.4SR j5       r/S5\04SS jr1ST\S5\	4SU jr2ST\S5\	4SV jr3S5\4SW jr4\&S5\\   4SX j5       r5\&S5\\   4SY j5       r6\&S5\\   4SZ j5       r7\&S5\	4S[ j5       r8\&StS\ j5       r9\&S5\\\4   4S] j5       r:\&StS^ j5       r;\\," S_SN9S`\S5S 4Sa j5       5       r<\," SMSN9SvSb\\=   S5\4Sc jj5       r>\Sd\?S    S5S 4Se j5       r@\SwSf j5       rAStSg jrB\," ShSN9StSi j5       rCSvS2\\   S5S 4Sj jjrD Sx\*R                  SkSl.Sm\SK\\*   Sn\	S5\4So jjjrFSvSm\\   S5S.4Sp jjrG\," SMSN9SO\S    S5S 4Sq j5       rHSO\S    S5S 4Sr jrISsrJg.)yr    #   a|  A terminal style.

A terminal style consists of a color (`color`), a background color (`bgcolor`), and a number of attributes, such
as bold, italic etc. The attributes have 3 states: they can either be on
(``True``), off (``False``), or not set (``None``).

Args:
    color (Union[Color, str], optional): Color of terminal text. Defaults to None.
    bgcolor (Union[Color, str], optional): Color of terminal background. Defaults to None.
    bold (bool, optional): Enable bold text. Defaults to None.
    dim (bool, optional): Enable dim text. Defaults to None.
    italic (bool, optional): Enable italic text. Defaults to None.
    underline (bool, optional): Enable underlined text. Defaults to None.
    blink (bool, optional): Enabled blinking text. Defaults to None.
    blink2 (bool, optional): Enable fast blinking text. Defaults to None.
    reverse (bool, optional): Enabled reverse text. Defaults to None.
    conceal (bool, optional): Enable concealed text. Defaults to None.
    strike (bool, optional): Enable strikethrough text. Defaults to None.
    underline2 (bool, optional): Enable doubly underlined text. Defaults to None.
    frame (bool, optional): Enable framed text. Defaults to None.
    encircle (bool, optional): Enable encircled text. Defaults to None.
    overline (bool, optional): Enable overlined text. Defaults to None.
    link (str, link): Link URL. Defaults to None.

r   r   r   r   _hash_nullr   )r   r   r   r   r   _link_id_ansi_style_definitionr?   r@   r   12345678921515253)r   r                        	   
         dimdboldbitalici	underlineublinkblink2reverserconcealcstrikes
underline2frameencircleoverline)uurm   rn   ro   oN)colorbgcolorr^   r\   r`   rb   rd   re   rf   rh   rj   rl   rm   rn   ro   linkmetarr   rs   rt   ru   c                J   S U l         S U l        S[        [        [        4   S[        4S jnUc  S OU" U5      U l        Uc  S OU" U5      U l        [        US LUS L=(       a    SUS L=(       a    SUS L=(       a    SUS L=(       a    SUS L=(       a    SU	S L=(       a    S	U
S L=(       a    S
US L=(       a    SUS L=(       a    SUS L=(       a    SUS L=(       a    SUS L=(       a    S45      U l        U R                  (       Ga  [        U=(       a    S=(       d    SU=(       a    S=(       d    SU=(       a    S=(       d    SU=(       a    S=(       d    SU=(       a    S=(       d    SU=(       a    S=(       d    SU	=(       a    S	=(       d    SU
=(       a    S
=(       d    SU=(       a    S=(       d    SU=(       a    S=(       d    SU=(       a    S=(       d    SU=(       a    S=(       d    SU=(       a    S=(       d    S45      OSU l	        UU l
        Uc  S O
[        U5      U l        U(       d  U(       a#  [        SS5       [        U R                  5       3OSU l        S U l        U R                  =(       d    U=(       d    U=(       d    U=(       d    U(       + U l        g )Nrr   r&   c                 \    [        U [        5      (       a  U $ [        R                  " U 5      $ N)
isinstancer   parse)rr   s    r*   _make_color#Style.__init__.<locals>._make_color   s"    &ue445L%++e:LLr-   rQ   rS   rW          @                     r   r   ?B  )rB   rC   r   r   strr   r   sumr   r   r   r   r   r   hashrA   r?   r@   )r)   rr   rs   r^   r\   r`   rb   rd   re   rf   rh   rj   rl   rm   rn   ro   rt   ru   r{   s                      r*   r+   Style.__init__   sG   * %)
04	MuUCZ0 	MU 	M $mdU1C '[5I"D 4%Ad"(q%+!T!(bd")rt#*t#+d"*s$&.3T!*d$-$- 
F #### JQO!IANLq%AO!(qLb%AMr&QN'aO(qNs'a&3+!Nd'a%*%*$ ' 	, 
!\TuT{
:>$wq&!"4

#3"45R 	 %)
..R%R7RdRdS
r-   r&   c                     [         $ )zCCreate an 'null' style, equivalent to Style(), but more performant.)
NULL_STYLE)clss    r*   null
Style.null   s
     r-   c                     U R                  [        5      nSUl        SUl        Xl        X#l        SUl        SUl        SUl        SUl	        SUl
        U=(       d    U(       + Ul        SUl        U$ )zCreate a new style with colors and no attributes.

Returns:
    color (Optional[Color]): A (foreground) color, or None for no color. Defaults to None.
    bgcolor (Optional[Color]): A (background) color, or None for no color. Defaults to None.
Nr   r   )__new__r    rB   rC   r   r   r   r   r   rA   r   r@   r?   )r   rr   rs   styles       r*   
from_colorStyle.from_color   sk     {{5)"&  ! +G,r-   c                 (   U R                  [        5      nSUl        SUl        SUl        SUl        SUl        SUl        SUl        [        U5      Ul
        [        SS5       [        UR                  5       3Ul        SUl        U(       + Ul        U$ )zCreate a new style with meta data.

Returns:
    meta (Optional[Dict[str, Any]]): A dictionary of meta data. Defaults to None.
Nr   r   )r   r    rB   rC   r   r   r   r   r   r   r   r   r   rA   r?   r@   )r   ru   r   s      r*   	from_metaStyle.from_meta   s     {{5)"& !Dk#Av./U[[0A/BCjr-   handlersc                     Uc  0 OUnUR                  UR                  5        VVs0 s H  u  p4SU 3U_M     snn5        U R                  U5      $ s  snnf )a@  Create a blank style with meta information.

Example:
    style = Style.on(click=self.on_click)

Args:
    meta (Optional[Dict[str, Any]], optional): An optional dict of meta information.
    **handlers (Any): Keyword arguments are translated in to handlers.

Returns:
    Style: A Style with meta information attached.
@)updateitemsr   )r   ru   r   keyvalues        r*   onStyle.on   sU     \rt8HI8H*#qY%8HIJ}}T"" Js   A
r   r   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   c                     U R                   $ )z+Get a link id, used in ansi code for links.)rA   r)   s    r*   link_idStyle.link_id       }}r-   c                    U R                   Gc  / nUR                  nU R                  nUS-  (       a  US-  (       a  U" U R                  (       a  SOS5        US-  (       a  U" U R                  (       a  SOS5        US-  (       a  U" U R
                  (       a  S	OS
5        US-  (       a  U" U R                  (       a  SOS5        US-  (       a  US-  (       a  U" U R                  (       a  SOS5        US-  (       a  U" U R                  (       a  SOS5        US-  (       a  U" U R                  (       a  SOS5        US-  (       a  U" U R                  (       a  SOS5        US-  (       a  U" U R                  (       a  SOS5        US-  (       a  US-  (       a  U" U R                  (       a  S OS!5        US"-  (       a  U" U R                  (       a  S#OS$5        US%-  (       a  U" U R                  (       a  S&OS'5        US(-  (       a  U" U R                  (       a  S)OS*5        U R                   b  U" U R                   R"                  5        U R$                  b$  U" S+5        U" U R$                  R"                  5        U R&                  (       a  U" S,5        U" U R&                  5        S-R)                  U5      =(       d    S.U l         U R                   $ )/z-Re-generate style definition from attributes.   r   r^   znot boldrQ   r\   znot dimrS   r`   z
not italicrW   rb   znot underline  r}   rd   z	not blinkr~   re   z
not blink2r   rf   znot reverser   rh   znot concealr   rj   z
not strike   r   rl   znot underline2r   rm   z	not framer   rn   znot encircler   ro   znot overliner   rt    none)rC   appendr   r^   r\   r`   rb   rd   re   rf   rh   rj   rl   rm   rn   ro   r   namer   r   join)r)   
attributesr   bitss       r*   __str__Style.__str__"  s   !!)$&J&&F''Do%!8TYY6J?6?DHH5)<6?t{{8E6?$..;oNo%6?djj7kB6?t{{8E6?9-H6?9-H6?t{{8Eo%6?4??<@PQ7#djj7kB7#:NK7#:NK{{&t{{''(}}(tt}}))*zzvtzz"%(XXj%9%CVD"%%%r-   c                 $    U R                   (       + $ )z;A Style is false if it has no attributes, colors, or links.)r@   r   s    r*   __bool__Style.__bool__P  s    ::~r-   color_systemc                 h   U R                   Gc  / nUR                  nU R                  nU R                  U R                  -  nU(       a  US-  (       a  U" US   5        US-  (       a  U" US   5        US-  (       a  U" US   5        US-  (       a  U" US   5        US-  (       a,  [        SS5       H  nUSU-  -  (       d  M  U" XF   5        M     US	-  (       a,  [        SS
5       H  nUSU-  -  (       d  M  U" XF   5        M     U R                  b8  UR                  U R                  R                  U5      R                  5       5        U R                  b7  UR                  U R                  R                  U5      R                  SS95        SR                  U5      U l         U R                   $ )zGenerate ANSI codes for this style.

Args:
    color_system (ColorSystem): Color system.

Returns:
    str: String containing codes.
r   r   rQ   rS   rW   rR   r   rX   r      F
foreground;)rB   r   
_style_mapr   r   ranger   extend	downgradeget_ansi_codesr   r   )r)   r   sgrr   r   r   r$   s          r*   _make_ansi_codesStyle._make_ansi_codesT  su    ::CZZFJ))D,@,@@J>:a=)>:a=)>:a=)>:a=)/$Q{%c22":?3  + /$Q|%c22":?3  , {{&

4;;00>MMOP}}(

MM++L9HH#( I 
 #DJzzr-   r   )maxsizer   c                      [        U R                  U5      5      $ ! [        R                   a!    UR	                  5       R                  5       s $ f = f)zNormalize a style definition so that styles with the same effect have the same string
representation.

Args:
    style (str): A style definition.

Returns:
    str: Normal form of style definition.
)r   rz   r   StyleSyntaxErrorstriplower)r   r   s     r*   	normalizeStyle.normalize  sE    	)syy'((&& 	);;=&&((	)s    2AAvaluesc                 8    U H
  nUc  M  Us  $    [        S5      e)zPick first non-None style.z$expected at least one non-None style)
ValueError)r   r   r   s      r*   
pick_firstStyle.pick_first  s'     E   ?@@r-   c              #   N  #    SU R                   S 4v   SU R                  S 4v   SU R                  S 4v   SU R                  S 4v   SU R                  S 4v   SU R
                  S 4v   SU R                  S 4v   SU R                  S 4v   S	U R                  S 4v   S
U R                  S 4v   SU R                  S 4v   SU R                  S 4v   SU R                  S 4v   SU R                  S 4v   SU R                  S 4v   U R                  (       a  SU R                   4v   g g 7f)Nrr   rs   r^   r\   r`   rb   rd   re   rf   rh   rj   rl   rm   rn   rt   ru   )rr   rs   r^   r\   r`   rb   rd   re   rf   rh   rj   rl   rm   rn   rt   r   ru   r   s    r*   __rich_repr__Style.__rich_repr__  s    tzz4''t++dii&&TXXt$$T))4>>400tzz4''T))t++t++T))DOOT11tzz4''$----dii%%::$))## s   D#D%otherc                 z    [        U[        5      (       d  [        $ U R                  5       UR                  5       :H  $ rx   ry   r    NotImplemented__hash__r)   r   s     r*   __eq__Style.__eq__  -    %''!!}}%.."222r-   c                 z    [        U[        5      (       d  [        $ U R                  5       UR                  5       :g  $ rx   r   r   s     r*   __ne__Style.__ne__  r   r-   c                 ~    U R                   b  U R                   $ [        [        U 5      5      U l         U R                   $ rx   )r?   r   _hash_getterr   s    r*   r   Style.__hash__  s1    ::!::,t,-
zzr-   c                     U R                   $ )z.The foreground color or None if it is not set.)r   r   s    r*   rr   Style.color  s     {{r-   c                     U R                   $ )z.The background color or None if it is not set.)r   r   s    r*   rs   Style.bgcolor  r   r-   c                     U R                   $ )zLink text, if set.)r   r   s    r*   rt   
Style.link  s     zzr-   c                 X    U R                   SL =(       d    U R                   R                  $ )z6Check if the style specified a transparent background.N)rs   
is_defaultr   s    r*   transparent_backgroundStyle.transparent_background  s"     ||t#>t||'>'>>r-   c                 (    [        U R                  S9$ )zA Style with background only.)rs   )r    rs   r   s    r*   background_styleStyle.background_style  s     T\\**r-   c                     U R                   c  0 $ [        [        [        [        4   [        U R                   5      5      $ )z=Get meta information (can not be changed after construction).)r   r   r	   r   r   r   r   s    r*   ru   
Style.meta  s0     ZZ'rTT$sCx.%

BS-TTr-   c                 p   U R                   (       a  [        $ U R                  [        5      nSUl        SUl        SUl        SUl        U R                  Ul        U R                  Ul	        U R                  Ul
        U R                  (       a  [        SS5       OSUl        SUl         SUl        SUl        U$ )z+Get a copy of the style with color removed.Nr   r   r   F)r@   r   r   r    rB   rC   r   r   r   r   r   r   rA   r   r?   r)   r   s     r*   without_colorStyle.without_color  s     ::||E*"& ,, $ 4 4jj48JJGAv./Br-   r   style_definitionc                    UR                  5       S:X  d  U(       d  U R                  5       $ U R                  nSnSn0 nSn[        UR	                  5       5      nU H  nUR                  5       n	U	S:X  aD  [        US5      n	U	(       d  [        R                  " S5      e [        R                  " U	5        U	nM]  U	S:X  a@  [        US5      n	UR                  U	5      nUc  [        R                  " S	U	< 35      eS
X['   M  U	S:X  a-  [        US5      n	U	(       d  [        R                  " S5      eU	nM  X;   a	  SXRU	   '   M   [        R                  " U	5        U	nM     [        SX4US.UD6nU$ ! [         a#  n
[        R                  " SU	< SU
 35      SeSn
A
ff = f! [         a#  n
[        R                  " SU	< SU
 35      SeSn
A
ff = f)zParse a style definition.

Args:
    style_definition (str): A string containing a style.

Raises:
    errors.StyleSyntaxError: If the style definition syntax is invalid.

Returns:
    `Style`: A Style instance.
r   Nr   r   zcolor expected after 'on'zunable to parse z as background color; notz,expected style attribute after 'not', found Frt   zURL expected after 'link'Tz as color; )rr   rs   rt   r<   )r   r   STYLE_ATTRIBUTESitersplitr   nextr   r   r   rz   r   getr    )r   r   r   rr   rs   r   rt   wordsoriginal_wordworderror	attributer   s                r*   rz   Style.parse  s    !!#v-5E88://#!%/1
"%++-."M &&(Dt|E2 112MNN KK%
 E2,006	$ 11FthO  ).
%E2 112MNN)59
D12 KK%
 O #P LELLC '   11*4(2HP  6 '   11*4(+eWE  s0   E, F,
F6FF
G	&GG	themec                 0   U=(       d    [         n/ nUR                  nU R                  nU R                  nU R                  (       a  XTpTU R
                  (       aJ  Uc  UR                  OUR                  U5      n[        R                  " [        XaR                  S5      5      nUb;  UR                  U5      nU" SUR                   35        U" SUR                   35        Ub%  UR                  USS9nU" SUR                   35        U R                  (       a  U" S5        U R                  (       a  U" S5        U R                  (       a  U" S	5        U R                   (       a  U" S
5        U R"                  (       a  U" S5        SR%                  U5      $ )zGet a CSS style rule.g      ?zcolor: ztext-decoration-color: Fr   zbackground-color: zfont-weight: boldzfont-style: italicztext-decoration: underlineztext-decoration: line-throughztext-decoration: overlinez; )r   r   rr   rs   rf   r\   foreground_colorget_truecolorr   from_tripletr   background_colorhexr^   r`   rb   rj   ro   r   )r)   r  cssr   rr   rs   r  theme_colors           r*   get_html_styleStyle.get_html_style/  sT    //

,,<<$788*/-&&U=P=PQV=W  &&*,B,BCHE --e4KW[__-./,[__,=>?!//%/HK''89:99&';;'(>>/0;;23==./yy~r-   stylesc                 B    [        U5      n[        U[        U5      5      $ )zCombine styles and get result.

Args:
    styles (Iterable[Style]): Styles to combine.

Returns:
    Style: A new style instance.
r   r   r   r   r  iter_styless      r*   combineStyle.combineT       6l;[ 122r-   c                 B    [        U5      n[        U[        U5      5      $ )zCombine styles from positional argument in to a single style.

Args:
    *styles (Iterable[Style]): Styles to combine.

Returns:
    Style: A new style instance.
r  r  s      r*   chainStyle.chaina  r  r-   c                    U R                   (       a  [        $ U R                  [        5      nU R                  Ul        U R
                  Ul        U R                  Ul        U R                  Ul        U R                  Ul        U R                  Ul	        U R                  Ul
        U R                  (       a  [        SS5       OSUl        U R                  Ul        SUl         U R                  Ul        U$ )z_Get a copy of this style.

Returns:
    Style: A new Style instance with identical attributes.
r   r   r   F)r@   r   r   r    rB   rC   r   r   r   r   r   r   rA   r?   r   r   s     r*   copy
Style.copyn  s     ::||E*jj"&"8"8{{ ,, $ 4 4jj48JJGAv./Bjjjjr-   r   c                 p   U R                   (       a  [        $ U R                  [        5      nU R                  Ul        U R
                  Ul        U R                  Ul        U R                  Ul        U R                  Ul        U R                  Ul	        SUl
        SUl        SUl        SUl         SUl        U$ )zhGet a copy of this style with link and meta information removed.

Returns:
    Style: New style object.
Nr   F)r@   r   r   r    rB   rC   r   r   r   r   r   rA   r?   r   r   s     r*   clear_meta_and_linksStyle.clear_meta_and_links  s     ::||E*jj"&"8"8{{ ,, $ 4 4r-   c                 |   U R                  [        5      nU R                  Ul        U R                  Ul        U R                  Ul        U R
                  Ul        U R                  Ul        U R                  Ul        Xl        U(       a  [        SS5       OSUl
        SUl        SUl        U R                  Ul        U$ )zGet a copy with a different value for link.

Args:
    link (str, optional): New value for link. Defaults to None.

Returns:
    Style: A new Style instance.
r   r   r   NF)r   r    rB   rC   r   r   r   r   r   r   rA   r?   r@   r   )r)   rt   r   s      r*   update_linkStyle.update_link  s     ||E*jj"&"8"8{{ ,, $ 4 448GAv./bjjr-   F)r   legacy_windowstextr#  c                    U(       a  Uc  U$ U R                   =(       d    U R                  U5      nU(       a	  SU SU S3OUnU R                  (       a'  U(       d   SU R                   SU R                   SU S3nU$ )a  Render the ANSI codes for the style.

Args:
    text (str, optional): A string to style. Defaults to "".
    color_system (Optional[ColorSystem], optional): Color system to render to. Defaults to ColorSystem.TRUECOLOR.

Returns:
    str: A string containing ANSI style codes.
z[mz[0mz]8;id=r   z\z]8;;\)rB   r   r   rA   )r)   r$  r   r#  attrsrendereds         r*   renderStyle.render  sw      |+K

Ad33LA49U5'4&0t::nT]]O1TZZLxjW  r-   c                     U=(       d    [        U 5      n[        R                  R                  U R	                  U5       S35        g)zWrite text with style directly to terminal.

This method is for testing purposes only.

Args:
    text (Optional[str], optional): Text to style or None for style name.


N)r   sysstdoutwriter)  )r)   r$  s     r*   test
Style.test  s5      s4y

DKK-.b12r-   c                 z   Ub  UR                   (       a  U $ U R                   (       a  U$ U R                  [        5      nS Ul        S Ul        UR
                  =(       d    U R
                  Ul        UR                  =(       d    U R                  Ul        U R                  UR                  ) -  UR                  UR                  -  -  Ul        U R                  UR                  -  Ul        UR                  =(       d    U R                  Ul	        UR                  =(       d    U R                  Ul
        UR                   Ul         U R                  (       a:  UR                  (       a)  [        0 U R                  EUR                  E5      Ul        O$U R                  =(       d    UR                  Ul        S Ul        U$ rx   )r@   r   r    rB   rC   r   r   r   r   r   rA   r   r   ru   r?   )r)   r   	new_styles      r*   _add
Style._add  s6   =EKKK::L<<.		&*	# <<64;;	"^^<t}}	!%!1!1U5J5J4J!J 5 55!
	 %)$8$85;P;P$P	!++3	"^^<t}}	++	::%++#$?tyy$?EJJ$?@IO"jj7EKKIO	r-   c                 j    U R                  U5      nUR                  (       a  UR                  5       $ U$ rx   )r4  rt   r  )r)   r   combined_styles      r*   __add__Style.__add__  s,    5)(6(;(;~""$OOr-   )rB   r   r   r   r?   r   rA   r   r@   r   rC   )r&   r    )NNrx   )r  r    r&   r    )r   )Kr3   r4   r5   r6   r7   r   r   __annotations__r9   r:   bytesr8   r   r   r   r   r	   r   r+   classmethodr   r   r   r   r"   r^   r\   r`   rb   rd   re   rf   rh   rj   rl   rm   rn   ro   propertyr   r   r   r   r   r   r   	StyleTyper   r   r   r   r   r   rr   rs   rt   r   r   ru   r   rz   r   r  r
   r  r  r  r  r!  	TRUECOLORr)  r0  r4  r8  r;   r<   r-   r*   r    r    #   s   4 UOuoC=KE?I  J uU 	 	V	
 	( 	X 	[ 	[ 	 	( 	9 	Y 	9 	Y 	(  	X!" 	l#$ -8 .2/3#"!%$( $!%"&"&!%%) $#'#'")-'JT eSj)*JT %s
+,	JT
 tnJT d^JT JT D>JT ~JT JT $JT $JT JT TNJT ~JT  4.!JT" 4.#JT$ sm%JT& tCH~&'JTX   GKUO5=e_	 . Xd38n5 '  ( #htCH~. #3 #7 # #" 7D
q'C!WFQIGE!WF1gG1gG!WFaJHEBxHBxH  ,& ,&\$ )[ )S )V t)c )c )  ) A)!4 A A A$v $&3C 3D 3
3C 3D 3
#  x   %   hsm   ? ? ? + + Ud38n U U  $ t?S ?W ?  ?B t"H]$; "s " "H 
3Xg. 
37 
3 
3 
3 
3, s ,  2  /:.C.C$ {+	
  
4
3# 
3$ 
3 t(7+   0PXg. P7 Pr-   c                   n    \ rS rSrSrS/rSS jrS\4S jr\	S\
4S j5       rS	\
SS4S
 jrS\
4S jrSrg)
StyleStacki  zA stack of styles._stackr&   Nc                     U/U l         g rx   rB  )r)   default_styles     r*   r+   StyleStack.__init__  s    $1?r-   c                 $    SU R                   < S3$ )Nz<stylestack >rD  r   s    r*   __repr__StyleStack.__repr__  s    dkk_A..r-   c                      U R                   S   $ )z&Get the Style at the top of the stack.rD  r   s    r*   currentStyleStack.current  s     {{2r-   r   c                 Z    U R                   R                  U R                   S   U-   5        g)zePush a new style on to the stack.

Args:
    style (Style): New style to combine with current style.
rL  N)rB  r   r   s     r*   pushStyleStack.push	  s#     	4;;r?U23r-   c                 T    U R                   R                  5         U R                   S   $ )zePop last style and discard.

Returns:
    Style: New current style (also available as stack.current)
rL  )rB  popr   s    r*   rS  StyleStack.pop  s      	{{2r-   rD  )rE  r    r&   N)r3   r4   r5   r6   r7   r8   r+   r   rI  r=  r    rM  rP  rS  r;   r<   r-   r*   rA  rA    sW    
I3/# /   4% 4D 4U r-   rA  )'r-  	functoolsr   operatorr   pickler   r   randomr   typingr   r	   r
   r   r   r   r   r   r   r   rr   r   r   r   r   reprr   r   terminal_themer   r   r   r   r>  r"   r    r   rA  r<   r-   r*   <module>r\     s    
     I I I  A A # Aj-):GW
 #w,	  OP OP OPd W
 r-   