
    AHj-
                    |    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	 d dl
mZ d dlmZmZ d dlmZ  G d	 d
      Zy)    )annotations)Iterable)RenderableType)Segment)Style)TerminalTheme)TRANSPARENTColor)ANSIToTruecolorc                  L    e Zd ZdZ	 	 	 	 	 	 ddZeef	 	 	 	 	 	 	 	 	 dd       Zy)Tintz1Applies a color on top of an existing renderable.c                     || _         || _        y)zWrap a renderable to apply a tint color.

        Args:
            renderable: A renderable.
            color: A color (presumably with alpha).
        N)
renderablecolor)selfr   r   s      P/root/tools/cai/cai_env/lib/python3.12/site-packages/textual/renderables/tint.py__init__zTint.__init__   s     %
    c              #    K   t         j                  }t        j                  }t        }t        |      j                  }|j                  }	t               }
|D ]  }|\  }}}|r| |	 |||	      n|
} ||| ||j                   ||j                        |z   j                  nd|j                   ||j                        |z   j                  nd      z   |        yw)a0  Apply tint to segments.

        Args:
            segments: Incoming segments.
            color: Color of tint.
            ansi_theme: The TerminalTheme defining how to map ansi colors to hex.
            background: Background color.

        Returns:
            Segments with applied tint.
        N)
r
   from_rich_colorr   
from_colorr   r   truecolor_style
rich_colorr   bgcolor)clssegmentsr   
ansi_theme
backgroundr   style_from_color_Segmentr   background_rich_color
NULL_STYLEsegmenttextstylecontrols                  r   process_segmentszTint.process_segments   s     &  // ++)*5EE * 5 5W
 	G#* D% ( $E+@A# 
 * $);;#: "1!=!E Q Q%) $)==#< "1!?%!G S S%) # 	s   C C"N)r   r   r   r
   returnNone)
r   Iterable[Segment]r   r
   r   r   r   r
   r(   r*   )__name__
__module____qualname____doc__r   classmethodr	   r'    r   r   r   r      so    ;"  
	  (6#6 6 "	6
 6 
6 6r   r   N)
__future__r   typingr   rich.consoler   rich.segmentr   
rich.styler   rich.terminal_themer   textual.colorr	   r
   textual.filterr   r   r0   r   r   <module>r9      s)    "  '    - , *H Hr   