
    AHj                    |    d dl mZ d dlmZmZ d dlmZmZmZ d dl	m
Z
 d dlmZ d dlmZ erd dlmZ  G d d	      Zy
)    )annotations)TYPE_CHECKINGIterable)ConsoleConsoleOptionsRenderResult)Segment)Style)Color)Screenc                  V    e Zd ZdZ	 	 	 	 	 	 ddZe	 	 	 	 	 	 dd       Z	 	 	 	 	 	 ddZy)	BackgroundScreenz,Tints a renderable and removes links / meta.c                "    || _         	 || _        y)zInitialize a BackgroundScreen instance.

        Args:
            screen: A Screen instance.
            color: A color (presumably with alpha).
        N)screencolor)selfr   r   s      ]/root/tools/cai/cai_env/lib/python3.12/site-packages/textual/renderables/background_screen.py__init__zBackgroundScreen.__init__   s      
1    c              #    K   t         j                  }t        j                  }t        }t               }|j
                  dk(  r3|D ]-  }|\  }}	}
|
r|  |||	|n|	j                         |
       / y|D ]  }|\  }}	}
|
r| |	|n|	j                         }	 |||	 ||	j                   ||	j                        |z   j                  nd|	j                   ||	j                        |z   j                  nd      z   |
        yw)zApply tint to segments and remove meta + styles

        Args:
            segments: Incoming segments.
            color: Color of tint.

        Returns:
            Segments with applied tint.
        r   N)
r   from_rich_colorr
   
from_colorr	   aclear_meta_and_linksr   
rich_colorbgcolor)clssegmentsr   r   style_from_color_Segment
NULL_STYLEsegmenttextstylecontrols              r   process_segmentsz!BackgroundScreen.process_segments"   s/      // ++W
77a<# 	'.$eW!M"&+m
9S9S9U 	  	G#* D%&+m
9S9S9U* $);;#: "1!=!E Q Q%) $)==#< "1!?%!G S S%) # 	s   DD
c                    |j                  | j                  j                  |      }| j                  }| j	                  ||      S )N)renderr   _compositorr   r&   )r   consoleoptionsr   r   s        r   __rich_console__z!BackgroundScreen.__rich_console__]   s:     >>$++"9"97C

$$Xu55r   N)r   r   r   r   returnNone)r   Iterable[Segment]r   r   r-   r/   )r*   r   r+   r   r-   r   )__name__
__module____qualname____doc__r   classmethodr&   r,    r   r   r   r      sp    622 2 
	2  8(8168	8 8t66)76	6r   r   N)
__future__r   typingr   r   rich.consoler   r   r   rich.segmentr	   
rich.styler
   textual.colorr   textual.screenr   r   r5   r   r   <module>r=      s,    " * > >    %S6 S6r   