a
    ”˜ëj¦  ã                   @   sŽ   d Z ddlmZmZ ddddddœZdee ee eeef d
œdd„Zeeedœdd„Z	eedœdd„Z
deee eee d	dœdd„Zd	S )zHandle chained inputs.é    )ÚOptionalÚTextIOz36;1z33;1z38;5;200z32;1z31;1)ZblueZyellowZpinkZgreenZredN)ÚitemsÚexcluded_colorsÚreturnc                    s<   t t ¡ ƒ‰ ˆdur&‡fdd„ˆ D ƒ‰ ‡ fdd„t| ƒD ƒS )zÊGet mapping for items to a support color.

    Args:
        items: The items to map to colors.
        excluded_colors: The colors to exclude.

    Returns:
        The mapping of items to colors.
    Nc                    s   g | ]}|ˆ vr|‘qS © r   )Ú.0Úc)r   r   úY/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/langchain_core/utils/input.pyÚ
<listcomp>   ó    z%get_color_mapping.<locals>.<listcomp>c                    s"   i | ]\}}|ˆ |t ˆ ƒ  “qS r   )Úlen)r   ÚiÚitem)Úcolorsr   r
   Ú
<dictcomp>   r   z%get_color_mapping.<locals>.<dictcomp>)ÚlistÚ_TEXT_COLOR_MAPPINGÚkeysÚ	enumerate)r   r   r   )r   r   r
   Úget_color_mapping   s    r   )ÚtextÚcolorr   c                 C   s   t | }d|› d| › d�S )z‹Get colored text.

    Args:
        text: The text to color.
        color: The color to use.

    Returns:
        The colored text.
    z[zm[1;3mú[0m)r   )r   r   Z	color_strr   r   r
   Úget_colored_text    s    
r   )r   r   c                 C   s   d| › d�S )zgGet bolded text.

    Args:
        text: The text to bold.

    Returns:
        The bolded text.
    z[1mr   r   )r   r   r   r
   Úget_bolded_text.   s    	r   Ú )r   r   ÚendÚfiler   c                 C   s0   |rt | |ƒn| }t|||d� |r,| ¡  dS )a‹  Print text with highlighting and no end characters.

    If a color is provided, the text will be printed in that color.
    If a file is provided, the text will be written to that file.

    Args:
        text: The text to print.
        color: The color to use. Defaults to None.
        end: The end character to use. Defaults to "".
        file: The file to write to. Defaults to None.
    )r   r   N)r   ÚprintÚflush)r   r   r   r   Ztext_to_printr   r   r
   Ú
print_text:   s    r!   )N)Nr   N)Ú__doc__Útypingr   r   r   r   ÚstrÚdictr   r   r   r!   r   r   r   r
   Ú<module>   s&   û
 ÿ
þ ÿþ