/usr/share/cagefs-skeleton/usr/local/lib/python3.9/site-packages/pip/_vendor/rich/__pycache__
a ���hD � @ s� d dl mZ d dlmZ d dlmZmZmZ ddlm Z erHd dl mZ G dd� d�Ze d kr�d d lZd dlmZ d dlmZ d d lmZmZ d dlmZ d dlmZ G dd� d�Ze� Ze�e� � d S )� )�sqrt)� lru_cache)�Sequence�Tuple� TYPE_CHECKING� )�ColorTriplet��Tablec @ sn e Zd ZdZeeeeef d�dd�Zeed�dd�Z dd �d d�Z edd �eeeef ed�dd��ZdS )�PalettezA palette of available colors.)�colorsc C s || _ d S �N)�_colors)�selfr � r �B/usr/local/lib/python3.9/site-packages/pip/_vendor/rich/palette.py�__init__ s zPalette.__init__)�number�returnc C s t | j| � S r )r r )r r r r r �__getitem__ s zPalette.__getitem__r )r c C s� ddl m} ddlm} ddlm} ddlm} |dddd t| j �� d �ddd �}t | j �D ]2\}}|�t|�t |�|d||j|� d�d�� q\|S )Nr ��Color��Style)�Textr �indexZRGBr r z colorsT�right)�title�captionZ highlightZcaption_justifyz )�bgcolor)�style)�pip._vendor.rich.colorr �pip._vendor.rich.styler Zpip._vendor.rich.textr �pip._vendor.rich.tabler �lenr � enumerateZadd_row�str�repr�from_rgb)r r r r r �tabler �colorr r r �__rich__ s( � �zPalette.__rich__i )�maxsize)r* r c sL |\���t � | jj�ttd�� ����fdd�}ttt| j��|d�}|S )z�Find a color from a palette that most closely matches a given color. Args: color (Tuple[int, int, int]): RGB components in range 0 > 255. Returns: int: Index of closes matching color. )r r c sj �| �\}}}�| d }�| }�| }�| }� d| | | d? d| | d| | | d? �S )zGet the distance to a color.� i � � i� r )r Zred2Zgreen2Zblue2Zred_mean�red�green�blue��_sqrtZblue1Z get_colorZgreen1Zred1r r �get_color_distance: s ���z)Palette.match.<locals>.get_color_distance)�key)r r r �int�float�min�ranger$ )r r* r5 Z min_indexr r3 r �match, s z Palette.matchN) �__name__� __module__�__qualname__�__doc__r r r7 r r r r+ r r; r r r r r s r �__main__N)�Iterabler )�Console�ConsoleOptions)�Segmentr c @ s"