U cfD @sddlmZddlmZddlmZmZmZddlm Z erHddl m Z GdddZ e d krdd lZdd lmZdd lmZdd lmZmZddlmZddlmZGdddZeZeed S))sqrt) lru_cache)SequenceTuple TYPE_CHECKING) ColorTripletTablec@sneZdZdZeeeeefdddZeedddZ dd d d Z e d d eeeefedddZ dS)PalettezA palette of available colors.)colorscCs ||_dSN)_colors)selfr rF/opt/hc_python/lib/python3.8/site-packages/pip/_vendor/rich/palette.py__init__szPalette.__init__)numberreturncCst|j|Sr )rr)rrrrr __getitem__szPalette.__getitem__r )rc Csddlm}ddlm}ddlm}ddlm}|dddd t|j d d d d }t |j D]2\}}| t |t ||d||j|ddq\|S)NrColorStyle)Textr indexRGBrr z colorsTright)titlecaption highlightcaption_justifyz )bgcolor)style)pip._vendor.rich.colorrpip._vendor.rich.stylerpip._vendor.rich.textrpip._vendor.rich.tabler lenr enumerateadd_rowstrreprfrom_rgb)rrrrr tablercolorrrr__rich__s(     zPalette.__rich__i)maxsize)r/rcsL|\t|jjttdfdd }ttt|j|d}|S)zFind 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. )rrcsj|\}}}|d}|}|}|}d|||d?d||d|||d?S)zGet the distance to a color.iir)rred2green2blue2red_meanredgreenblue_sqrtblue1 get_colorgreen1red1rrget_color_distance:s  z)Palette.match..get_color_distance)key)rrrintfloatminranger()rr/rB min_indexrr<rmatch,s  z Palette.matchN) __name__ __module__ __qualname____doc__rrrDrrrr0rrIrrrrr s r __main__N)Iterabler)ConsoleConsoleOptions)Segmentrc@s"eZdZeeeedddZdS)ColorBox)consoleoptionsrccs|jjd}td|D]}t|jD]}||j}||d}t||d\}} } t||d|dd\} } } t|d| d| d}t| d| d| d}tdt ||dVq$t VqdS) Nrrg?r2u▄)r/r") sizeheightrG max_widthcolorsys hls_to_rgbrr-rRrline)rrTrUrYyxhlr1g1b1r2g2b2r"r/rrr__rich_console__Ts    zColorBox.__rich_console__N)rJrKrLrPrQrOrRrhrrrrrSSsrS)mathr functoolsrtypingrrr color_tripletrr'r r rJr[rOr$rpip._vendor.rich.consolerPrQZpip._vendor.rich.segmentrRr%rrSrTprintrrrrs    @