U
    	fS                     @   s  d Z ddlZddlZddlmZmZ ddlmZmZm	Z	m
Z
mZ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 dd
lmZ ddlmZ ee
eeef e
eeeef f Zeee f Z!ee
eeef e
eeeef f Z"G dd dZ#dZ$dZ%dZ&dZ'dZ(dZ)dZ*de$ e% e$ e% e$ de% e& d
Z+de' e% e( e% e( de% e& d
Z,de$ de$ de$ de& d	Z-de' de( de( de& d	Z.dd dD Z/dej0 Z1eded G d!d" d"ej2Z3e
ed#f e#d$d%d&Z4e e#d$d'd(Z5deee f eee f eee f e	e e#d)d*d+Z6deee f eed-d.d/Z7ede eef e	e d$d0d1Z8de e e e e	e e#d2d3d4Z9eed5d6d7Z:d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKd:dLdMdNdOdPdOdQdRdSdTdUdVdWdXdYdZdZd[d\d]d^d_d_d`dadbdcdddedfdgdhdidjdkdidldmdndodpdqdrdsdtdudvdwdxdydzd{dzd|d}d~ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddZ;ddĄ e;< D Z=dS )aZ  Color definitions are used as per the CSS3
[CSS Color Module Level 3](http://www.w3.org/TR/css3-color/#svg-color) specification.

A few colors have multiple names referring to the sames colors, eg. `grey` and `gray` or `aqua` and `cyan`.

In these cases the _last_ color when sorted alphabetically takes preferences,
eg. `Color((0, 255, 255)).as_named() == 'cyan'` because "cyan" comes after "aqua".

Warning: Deprecated
    The `Color` class is deprecated, use `pydantic_extra_types` instead.
    See [`pydantic-extra-types.Color`](../usage/types/extra_types/color_types.md)
    for more information.
    N)
hls_to_rgb
rgb_to_hls)AnyCallableOptionalTupleTypeUnioncast)
CoreSchemaPydanticCustomErrorcore_schema)
deprecated   )_repr)GetJsonSchemaHandler)JsonSchemaValue)PydanticDeprecatedSince20c                   @   s<   e Zd ZdZdZeeeee dddZeedddZ	d	S )
RGBAz1Internal use only as a representation of a color.rgbalpha_tupler   r   r   r   c                 C   s*   || _ || _|| _|| _||||f| _d S Nr   )selfr   r   r   r    r   Q/var/www/html/apigroqsegura/apigroq/lib/python3.8/site-packages/pydantic/color.py__init__%   s
    zRGBA.__init__)itemreturnc                 C   s
   | j | S r   )r   )r   r!   r   r   r   __getitem__-   s    zRGBA.__getitem__N)
__name__
__module____qualname____doc__	__slots__floatr   r    r   r#   r   r   r   r   r       s   r   z(\d{1,3}(?:\.\d+)?)z\s*,\s*z(\d(?:\.\d+)?|\.\d+|\d{1,2}%)z((-?\d+(?:\.\d+)?|-?\.\d+)(deg|rad|turn)?z(\d{1,3}(?:\.\d+)?)%z8\s*(?:#|0x)?([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])?\s*zD\s*(?:#|0x)?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?\s*z\s*rgba?\(\s*z(?:z
)?\s*\)\s*z\s*hsla?\(\s*z\s+z
(?:\s*/\s*c                 C   s   h | ]}t |d  dqS )      int.0cr   r   r   	<setcomp>C   s     r1   Z0123456789abcdefr*   zThe `Color` class is deprecated, use `pydantic_extra_types` instead. See https://docs.pydantic.dev/latest/api/pydantic_extra_types_color/.)categoryc                   @   sB  e Zd ZdZdZeddddZeej	e
eddd	Zed
ddZddeedddZed
ddZed
ddZddee edddZed
ddZddee edddZed
ddZeee eege	f ej	d d!d"Zeeed d#d$d%Zed
d&d'Z d(d
d)d*Z!eed+d,d-Z"e#d
d.d/Z$dS )0ColorzRepresents a color.)	_original_rgbaNvaluer"   c                 C   sf   |  |  t |ttfr"t|| _n:t |tr8t|| _n$t |trR|j| _|j}n
t	dd|| _d S )Ncolor_errorzAvalue is not a valid color: value must be a tuple, list or string)

isinstancetuplelistparse_tupler5   str	parse_strr3   r4   r   )r   r7   r   r   r   r    Q   s    

 zColor.__init__)r   handlerr"   c                 C   s   i }|j ddd |S )Nstringcolor)typeformat)update)clsr   r?   field_schemar   r   r   __get_pydantic_json_schema__c   s    z"Color.__get_pydantic_json_schema__)r"   c                 C   s   | j S )z!Original value passed to `Color`.)r4   r   r   r   r   originalk   s    zColor.originalFfallback)rK   r"   c             
   C   s~   | j jdkrrtttttf |  }z
t| W S  tk
rn } z"|rT|   W Y S t	d|W 5 d}~X Y qzX n|  S dS )a<  Returns the name of the color if it can be found in `COLORS_BY_VALUE` dictionary,
        otherwise returns the hexadecimal representation of the color or raises `ValueError`.

        Args:
            fallback: If True, falls back to returning the hexadecimal representation of
                the color instead of raising a ValueError when no named color is found.

        Returns:
            The name of the color, or the hexadecimal representation of the color.

        Raises:
            ValueError: When no named color is found and fallback is `False`.
        Nz=no named color found, use fallback=True, as_hex() or as_rgb())
r5   r   r
   r   r-   as_rgb_tupleCOLORS_BY_VALUEKeyErroras_hex
ValueError)r   rK   rgber   r   r   as_namedo   s    
zColor.as_namedc                    s   dd | j dd D }| j jdk	r6|t| j j ddd |D  tdd |D rd fd	dtd
t dD  d  S )aS  Returns the hexadecimal representation of the color.

        Hex string representing the color can be 3, 4, 6, or 8 characters depending on whether the string
        a "short" representation of the color is possible and whether there's an alpha channel.

        Returns:
            The hexadecimal representation of the color.
        c                 S   s   g | ]}t |qS r   float_to_255r.   r   r   r   
<listcomp>   s     z Color.as_hex.<locals>.<listcomp>N    c                 s   s   | ]}|d V  qdS )Z02xNr   r/   vr   r   r   	<genexpr>   s     zColor.as_hex.<locals>.<genexpr>c                 s   s   | ]}|t kV  qd S r   )repeat_colorsr.   r   r   r   r[      s     c                 3   s   | ]} | V  qd S r   r   r.   rO   r   r   r[      s     r   r*   #)r5   r   appendrU   joinallrangelen)r   valuesr   r]   r   rO      s    	$zColor.as_hexc              
   C   s   | j jdkr<dt| j j dt| j j dt| j j dS dt| j j dt| j j dt| j j dt|  d d	S dS )zFColor as an `rgb(<r>, <g>, <b>)` or `rgba(<r>, <g>, <b>, <a>)` string.Nzrgb(, )zrgba(r*   )r5   r   rU   r   r   r   round_alpha_floatrH   r   r   r   as_rgb   s    0>zColor.as_rgbr   )r   r"   c                C   sp   dd | j dd D \}}}|dkrN| j jdkr<|||fS ||||  fS n|rb||||  fS |||fS dS )a  Returns the color as an RGB or RGBA tuple.

        Args:
            alpha: Whether to include the alpha channel. There are three options for this input:

                - `None` (default): Include alpha only if it's set. (e.g. not `None`)
                - `True`: Always include alpha.
                - `False`: Always omit alpha.

        Returns:
            A tuple that contains the values of the red, green, and blue channels in the range 0 to 255.
                If alpha is included, it is in the range 0 to 1.
        c                 s   s   | ]}t |V  qd S r   rT   r.   r   r   r   r[      s     z%Color.as_rgb_tuple.<locals>.<genexpr>NrW   )r5   r   rh   )r   r   r   r   r   r   r   r   rL      s    
zColor.as_rgb_tuplec              
   C   s   | j jdkr@| jdd\}}}d|d dd|dd|dd	S | jd
d\}}}}d|d dd|dd|ddt|d d		S dS )zEColor as an `hsl(<h>, <s>, <l>)` or `hsl(<h>, <s>, <l>, <a>)` string.NFrj   zhsl(h  z0.0fre   z0.0%rf   Tr*   )r5   r   as_hsl_tuplerg   )r   hsZliar   r   r   as_hsl   s
    "zColor.as_hslc                C   sn   t | jj| jj| jj\}}}|dkrL| jjdkr<|||fS ||||  fS |r`||||  fS |||fS dS )aS  Returns the color as an HSL or HSLA tuple.

        Args:
            alpha: Whether to include the alpha channel.

                - `None` (default): Include the alpha channel only if it's set (e.g. not `None`).
                - `True`: Always include alpha.
                - `False`: Always omit alpha.

        Returns:
            The color as a tuple of hue, saturation, lightness, and alpha (if included).
                All elements are in the range 0 to 1.

        Note:
            This is HSL as used in HTML and most other places, not HLS as used in Python's `colorsys`.
        N)r   r5   r   r   r   r   rh   )r   r   rm   lrn   r   r   r   rl      s    
zColor.as_hsl_tuplec                 C   s   | j jd krdS | j jS )Nr   )r5   r   rH   r   r   r   rh      s    zColor._alpha_float)sourcer?   r"   c                 C   s   t j| jt  dS )N)serialization)r   "with_info_plain_validator_function	_validateto_string_ser_schema)rE   rr   r?   r   r   r   __get_pydantic_core_schema__   s     z"Color.__get_pydantic_core_schema__)_Color__input_value_r"   c                 C   s   | |S r   r   )rE   rx   ry   r   r   r   ru      s    zColor._validatec                 C   s   | j ddS )NTrJ   )rS   rH   r   r   r   __str__   s    zColor.__str__z_repr.ReprArgsc                 C   s    d | j ddfgd|  fg S )NTrJ   rQ   )rS   rL   rH   r   r   r   __repr_args__   s    zColor.__repr_args__)otherr"   c                 C   s   t |to|  | kS r   )r9   r3   rL   )r   r|   r   r   r   __eq__   s    zColor.__eq__c                 C   s   t |  S r   )hashrL   rH   r   r   r   __hash__   s    zColor.__hash__)%r$   r%   r&   r'   r(   	ColorTyper    classmethodr   r   _GetJsonSchemaHandlerr   rG   rI   boolr=   rS   rO   ri   r   
ColorTuplerL   rp   HslColorTuplerl   r)   rh   r   r   r   rw   ru   rz   r{   r}   r-   r   r   r   r   r   r3   G   s6    
	 r3   .r6   c                 C   sz   t | dkr.dd | D \}}}t|||dS t | dkrldd | dd D \}}}t|||t| d S tdddS )	zParse a tuple or list to get RGBA values.

    Args:
        value: A tuple or list.

    Returns:
        An `RGBA` tuple parsed from the input tuple.

    Raises:
        PydanticCustomError: If tuple is not valid.
    rW   c                 s   s   | ]}t |V  qd S r   parse_color_valuerY   r   r   r   r[     s     zparse_tuple.<locals>.<genexpr>N   c                 s   s   | ]}t |V  qd S r   r   rY   r   r   r   r[     s     r8   z:value is not a valid color: tuples must have length 3 or 4)rc   r   parse_float_alphar   )r7   r   r   r   r   r   r   r<     s    r<   c           	      C   sX  |   }zt| \}}}W n tk
r.   Y nX t|||dS tt|}|r| ^ }}dd |D \}}}|rt|d dd }nd}t||||S tt	|}|r| ^ }}dd |D \}}}|rt|dd }nd}t||||S tt
|p
tt|}|rt|  S tt|p6tt|}|rJt|  S tdd	dS )
a8  Parse a string representing a color to an RGBA tuple.

    Possible formats for the input string include:

    * named color, see `COLORS_BY_NAME`
    * hex short eg. `<prefix>fff` (prefix can be `#`, `0x` or nothing)
    * hex long eg. `<prefix>ffffff` (prefix can be `#`, `0x` or nothing)
    * `rgb(<r>, <g>, <b>)`
    * `rgba(<r>, <g>, <b>, <a>)`

    Args:
        value: A string representing a color.

    Returns:
        An `RGBA` tuple parsed from the input string.

    Raises:
        ValueError: If the input string cannot be parsed to an RGBA tuple.
    Nc                 s   s   | ]}t |d  dV  qdS )r*   r+   Nr,   rY   r   r   r   r[   6  s     zparse_str.<locals>.<genexpr>r*   r+      c                 s   s   | ]}t |d V  qdS )r+   Nr,   rY   r   r   r   r[   @  s     r8   zBvalue is not a valid color: string not recognised as a valid color)lowerCOLORS_BY_NAMErN   ints_to_rgbare	fullmatchr_hex_shortgroupsr-   
r_hex_longr_rgbr_rgb_v4_styler_hslr_hsl_v4_style	parse_hslr   )	r7   Zvalue_lowerr   r   r   mrQ   ro   r   r   r   r   r>     s:    r>   )r   r   r   r   r"   c                 C   s   t t| t|t|t|S )a  Converts integer or string values for RGB color and an optional alpha value to an `RGBA` object.

    Args:
        r: An integer or string representing the red color value.
        g: An integer or string representing the green color value.
        b: An integer or string representing the blue color value.
        alpha: A float representing the alpha value. Defaults to None.

    Returns:
        An instance of the `RGBA` class with the corresponding color and alpha values.
    )r   r   r   r   r   r   r   r   R  s    r   r   )r7   max_valr"   c                 C   s`   zt | }W n tk
r*   tddY nX d|  kr@|krLn n|| S tddd|idS )a8  Parse the color value provided and return a number between 0 and 1.

    Args:
        value: An integer or string color value.
        max_val: Maximum range value. Defaults to 255.

    Raises:
        PydanticCustomError: If the value is not a valid color.

    Returns:
        A number between 0 and 1.
    r8   z?value is not a valid color: color values must be a valid numberr   zLvalue is not a valid color: color values must be in the range 0 to {max_val}r   N)r)   rP   r   )r7   r   rA   r   r   r   r   a  s    r   c                 C   s   | dkrdS z6t | tr8| dr8t| dd d }nt| }W n tk
r`   tddY nX t|drrdS d|  krdkrn n|S tdd	dS )
aZ  Parse an alpha value checking it's a valid float in the range 0 to 1.

    Args:
        value: The input value to parse.

    Returns:
        The parsed value as a float, or `None` if the value was None or equal 1.

    Raises:
        PydanticCustomError: If the input value cannot be successfully parsed as a float in the expected range.
    N%d   r8   z>value is not a valid color: alpha values must be a valid floatr   r   zDvalue is not a valid color: alpha values must be in the range 0 to 1)r9   r=   endswithr)   rP   r   mathisclose)r7   r   r   r   r   r   |  s    r   )rm   h_unitssatlightr   r"   c                 C   sv   t |dt |d }}t| }|dkr4|d d }n|dkrJ|t t }n|d }t|||\}}	}
t||	|
t|S )a.  Parse raw hue, saturation, lightness, and alpha values and convert to RGBA.

    Args:
        h: The hue value.
        h_units: The unit for hue value.
        sat: The saturation value.
        light: The lightness value.
        alpha: Alpha value.

    Returns:
        An instance of `RGBA`.
    r   >   Ndegrk   Zradr   )r   r)   radsr   r   r   )rm   r   r   r   r   Zs_valueZl_valueZh_valuer   r   r   r   r   r   r     s    r   )r0   r"   c                 C   s   t t| d S )a  Converts a float value between 0 and 1 (inclusive) to an integer between 0 and 255 (inclusive).

    Args:
        c: The float value to be converted. Must be between 0 and 1 (inclusive).

    Returns:
        The integer equivalent of the given float value rounded to the nearest whole number.

    Raises:
        ValueError: If the given float value is outside the acceptable range of 0 to 1 (inclusive).
    r   )r-   rg   )r0   r   r   r   rU     s    rU   )      r   )         )r   r   r   )   r      )r   r   r   )   r      )r         )r   r   r   )r   r      )r   r   r   )   +      )   *   r   )         )_         )r   r   r   )   i      )r   r   P   )r         )r   r   r   )r      <   )r   r      )r   r   r   )r         )   r   r   )r   r   r   )      k   )r   r   r   )U   r   /   )r      r   )   2      )r   r   r   )      z   )      r   )H   =   r   )r   O   r   )r         )   r      )r   r      )r      r   )r   r   r   )r      r   )   "   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )   r       )   r   r   )r   r   r   )   r   r   )r   r   r   )r   r      )r   \   r   )K   r      )r   r   r   )r      r   )r   r   r   )r   r   r   )|      r   )r   r   r   )r      r   )r   r   r   )   r   r   )r   r   r   )r   r   r   )r      r   )r         )r   r   r   )r   r      )r   r   r   )w      r   )   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )f   r   r   )r   r   r   )   r   r   )r   p      )r      q   ){   h   r   )r   r      )r   r   r   )         )   r  r   )r   r   r   )r   r      )r   r      )r   r   r   )r   r   r   )   r   r   )r   r   r   )r      #   )r   r   r   )r   E   r   )r   r      )r      r   )      r  )   r   r   )r   r   r   )r         )r   r      )r   r  ?   )r         )   r   r  )r   r   r   )r   r   r   )r   r   r   )r   r   r   )A   r   r  )r   r     )r   r   r   )      `   ).   r   W   )r   r   r   )r   R   -   )r  r  r  )r   r   r   )j   Z   r   )r   r   r   )r   r   r   )r   r   r   )F   r   r   )r   r   r   )r   r   r   )r   r   r   )r   c   G   )@   r      )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )Z	aliceblueZantiquewhiteZaquaZ
aquamarineZazureZbeigeZbisqueblackZblanchedalmondblueZ
bluevioletZbrownZ	burlywoodZ	cadetblueZ
chartreuseZ	chocolateZcoralZcornflowerblueZcornsilkZcrimsoncyanZdarkblueZdarkcyanZdarkgoldenrodZdarkgrayZ	darkgreenZdarkgreyZ	darkkhakiZdarkmagentaZdarkolivegreenZ
darkorangeZ
darkorchidZdarkredZ
darksalmonZdarkseagreenZdarkslateblueZdarkslategrayZdarkslategreyZdarkturquoiseZ
darkvioletZdeeppinkZdeepskyblueZdimgrayZdimgreyZ
dodgerblueZ	firebrickZfloralwhiteZforestgreenZfuchsiaZ	gainsboroZ
ghostwhiteZgoldZ	goldenrodZgraygreenZgreenyellowZgreyZhoneydewZhotpinkZ	indianredZindigoZivoryZkhakiZlavenderZlavenderblushZ	lawngreenZlemonchiffonZ	lightblueZ
lightcoralZ	lightcyanZlightgoldenrodyellowZ	lightgrayZ
lightgreenZ	lightgreyZ	lightpinkZlightsalmonZlightseagreenZlightskyblueZlightslategrayZlightslategreyZlightsteelblueZlightyellowZlimeZ	limegreenZlinenmagentaZmaroonZmediumaquamarineZ
mediumblueZmediumorchidZmediumpurpleZmediumseagreenZmediumslateblueZmediumspringgreenZmediumturquoiseZmediumvioletredZmidnightblueZ	mintcreamZ	mistyroseZmoccasinZnavajowhiteZnavyZoldlaceZoliveZ	olivedrabZorangeZ	orangeredZorchidZpalegoldenrodZ	palegreenZpaleturquoiseZpalevioletredZ
papayawhipZ	peachpuffZperuZpinkZplumZ
powderblueZpurpleredZ	rosybrownZ	royalblueZsaddlebrownZsalmonZ
sandybrownZseagreenZseashellZsiennaZsilverZskyblueZ	slateblueZ	slategrayZ	slategreyZsnowZspringgreenZ	steelbluetanZtealZthistleZtomatoZ	turquoiseZvioletZwheatwhiteZ
whitesmokeyellowZyellowgreenc                 C   s   i | ]\}}||qS r   r   )r/   krZ   r   r   r   
<dictcomp>[  s      r0  )N)r   )N)>r'   r   r   Zcolorsysr   r   typingr   r   r   r   r   r	   r
   pydantic_corer   r   r   typing_extensionsr   	_internalr   Z#_internal._schema_generation_sharedr   r   json_schemar   warningsr   r-   r)   r   r=   r   r   r   Z_r_255Z_r_commaZ_r_alphaZ_r_hZ_r_slr   r   r   r   r   r   r\   pir   Representationr3   r<   r>   r   r   r   r   rU   r   itemsrM   r   r   r   r   <module>   s~  $""&&
 6;4   