o
    g%                     @  s   d dl mZ d dlmZ d dlZd dlmZ ddl	m
Z
 ddlmZ dddddZG dd deeeje f ZG dd de
eeje f eZG dd deZddlmZ dS )    )annotationsN)cleandoc   )ImmutableDictMixin)CallbackDictdockeystremptyt.Anytypetype[t.Any] | Noner   
str | Nonereturnc                  s   |du r@d dg}t u r|d n&du r|d n
|dj d  dur6|d d	 |d
 d|}t fddfddfddt|dS )a  Return a new property object for a cache header. Useful if you
    want to add support for a cache extension in a subclass.

    :param key: The attribute name present in the parsed cache-control header dict.
    :param empty: The value to use if the key is present without a value.
    :param type: The type to convert the string value to instead of a string. If
        conversion raises a ``ValueError``, the returned value is ``None``.
    :param doc: The docstring for the property. If not given, it is generated
        based on the other params.

    .. versionchanged:: 3.1
        Added the ``doc`` param.

    .. versionchanged:: 2.0
        Renamed from ``cache_property``.
    NzThe ``z`` attribute.z"A ``bool``, either present or not.z
A ``str``,zA ``z``,z``z`` if present with no value,zor ``None`` if not present. c                   s   |   S N)_get_cache_valuexr   r	   r    g/var/www/html/ecg_monitoring/venv/lib/python3.10/site-packages/werkzeug/datastructures/cache_control.py<lambda>1       z(cache_control_property.<locals>.<lambda>c                   s   |   |S r   )_set_cache_value)r   v)r	   r   r   r   r   2   r   c                   s
   |   S r   )_del_cache_valuer   )r	   r   r   r   3   s   
 r   )boolappend__name__joinpropertyr   )r	   r   r   r   partsr   r   r   cache_control_property   s"   


r$   c                      s   e Zd ZU dZeddeZded< eddeZ	ded< ed	deZ
ded
< eddeZded< 		d)d* fddZd+ddZd,dd Zd-d!d"Zd.d#d$Zd.d%d&Zd.d'd(ZeeZ  ZS )/_CacheControla  Subclass of a dict that stores values for a Cache-Control header.  It
    has accessors for all the cache-control directives specified in RFC 2616.
    The class does not differentiate between request and response directives.

    Because the cache-control directives in the HTTP header use dashes the
    python descriptors use underscores for that.

    To get a header of the :class:`CacheControl` object again you can convert
    the object into a string or call the :meth:`to_header` method.  If you plan
    to subclass it and add your own items have a look at the sourcecode for
    that class.

    .. versionchanged:: 3.1
        Dict values are always ``str | None``. Setting properties will
        convert the value to a string. Setting a non-bool property to
        ``False`` is equivalent to setting it to ``None``. Getting typed
        properties will return ``None`` if conversion raises
        ``ValueError``, rather than the string.

    .. versionchanged:: 2.1
        Setting int properties such as ``max_age`` will convert the
        value to an int.

    .. versionchanged:: 0.4
       Setting ``no_cache`` or ``private`` to ``True`` will set the
       implicit value ``"*"``.
    zno-storeNr   no_storezmax-age
int | Nonemax_agezno-transformno_transformzstale-if-errorstale_if_errorr   valuesBcabc.Mapping[str, t.Any] | cabc.Iterable[tuple[str, t.Any]] | None	on_update+cabc.Callable[[_CacheControl], None] | Nonec                   s   t  || |d u| _d S r   )super__init__provided)selfr+   r-   	__class__r   r   r0   Z   s   z_CacheControl.__init__r	   r
   r   r   r   r   r   c                 C  s`   |t u r|| v S || vrdS | |  }du r|S |dur.z||}W |S  ty-   Y dS w |S +Used internally by the accessor properties.N)r   
ValueError)r2   r	   r   r   valuer   r   r   r   b   s   
z_CacheControl._get_cache_valuer8   Nonec                 C  s|   |t u r|rd| |< dS | |d dS |du s|du r$| |d dS |du r.d| |< dS |dur6||}t|| |< dS )r6   NFT)r   popr
   )r2   r	   r8   r   r   r   r   r   w   s   z_CacheControl._set_cache_valuec                 C  s   || v r	| |= dS dS r5   r   )r2   r	   r   r   r   r      s   
z_CacheControl._del_cache_valuec                 C  s
   t | S )z6Convert the stored values into a cache control header.)httpdump_headerr2   r   r   r   	to_header   s   
z_CacheControl.to_headerc                 C  s   |   S r   )r>   r=   r   r   r   __str__   s   z_CacheControl.__str__c                 C  s4   d dd t|  D }dt| j d| dS )Nr   c                 s  s"    | ]\}}| d |V  qdS )=Nr   ).0kr   r   r   r   	<genexpr>   s     z)_CacheControl.__repr__.<locals>.<genexpr><>)r!   sorteditemsr   r    )r2   kv_strr   r   r   __repr__   s   z_CacheControl.__repr__)r   N)r+   r,   r-   r.   )r	   r
   r   r   r   r   r   r   )r	   r
   r8   r   r   r   r   r9   )r	   r
   r   r9   )r   r
   )r    
__module____qualname____doc__r$   r   r&   __annotations__intr(   r)   r*   r0   r   r   r   r>   r?   rI   staticmethodcache_property__classcell__r   r   r3   r   r%   8   s    
 





r%   c                   @  sb   e Zd ZU dZeddeZded< eddeZ	ded	< ed
deZ
ded< eddeZded< dS )RequestCacheControla  A cache control for requests.  This is immutable and gives access
    to all the request-relevant cache control headers.

    To get a header of the :class:`RequestCacheControl` object again you can
    convert the object into a string or call the :meth:`to_header` method.  If
    you plan to subclass it and add your own items have a look at the sourcecode
    for that class.

    .. versionchanged:: 3.1
        Dict values are always ``str | None``. Setting properties will
        convert the value to a string. Setting a non-bool property to
        ``False`` is equivalent to setting it to ``None``. Getting typed
        properties will return ``None`` if conversion raises
        ``ValueError``, rather than the string.

    .. versionchanged:: 3.1
       ``max_age`` is ``None`` if present without a value, rather
       than ``-1``.

    .. versionchanged:: 3.1
        ``no_cache`` is a boolean, it is ``True`` instead of ``"*"``
        when present.

    .. versionchanged:: 3.1
        ``max_stale`` is ``True`` if present without a value, rather
        than ``"*"``.

    .. versionchanged:: 3.1
       ``no_transform`` is a boolean. Previously it was mistakenly
       always ``None``.

    .. versionchanged:: 3.1
       ``min_fresh`` is ``None`` if present without a value, rather
       than ``"*"``.

    .. versionchanged:: 2.1
        Setting int properties such as ``max_age`` will convert the
        value to an int.

    .. versionadded:: 0.5
        Response-only properties are not present on this request class.
    no-cacheNr   no_cachez	max-staleTzint | t.Literal[True] | None	max_stalez	min-freshr'   	min_freshzonly-if-cachedonly_if_cached)r    rJ   rK   rL   r$   r   rT   rM   rN   rU   rV   rW   r   r   r   r   rR      s   
 +rR   c                   @  s   e Zd ZU dZedddZded< eddeZded< ed	ddZ	ded	< ed
deZ
ded< eddeZded< eddeZded< eddeZded< eddeZded< eddeZded< dS )ResponseCacheControla  A cache control for responses.  Unlike :class:`RequestCacheControl`
    this is mutable and gives access to response-relevant cache control
    headers.

    To get a header of the :class:`ResponseCacheControl` object again you can
    convert the object into a string or call the :meth:`to_header` method.  If
    you plan to subclass it and add your own items have a look at the sourcecode
    for that class.

    .. versionchanged:: 3.1
        Dict values are always ``str | None``. Setting properties will
        convert the value to a string. Setting a non-bool property to
        ``False`` is equivalent to setting it to ``None``. Getting typed
        properties will return ``None`` if conversion raises
        ``ValueError``, rather than the string.

    .. versionchanged:: 3.1
        ``no_cache`` is ``True`` if present without a value, rather than
        ``"*"``.

    .. versionchanged:: 3.1
        ``private`` is ``True`` if present without a value, rather than
        ``"*"``.

    .. versionchanged:: 3.1
       ``no_transform`` is a boolean. Previously it was mistakenly
       always ``None``.

    .. versionchanged:: 3.1
        Added the ``must_understand``, ``stale_while_revalidate``, and
        ``stale_if_error`` properties.

    .. versionchanged:: 2.1.1
        ``s_maxage`` converts the value to an int.

    .. versionchanged:: 2.1
        Setting int properties such as ``max_age`` will convert the
        value to an int.

    .. versionadded:: 0.5
       Request-only properties are not present on this response class.
    rS   TNzstr | t.Literal[True] | NonerT   publicr   privatezmust-revalidatemust_revalidatezproxy-revalidateproxy_revalidatezs-maxager'   s_maxage	immutablezmust-understandmust_understandzstale-while-revalidatestale_while_revalidate)r    rJ   rK   rL   r$   rT   rM   r   rY   rZ   r[   r\   rN   r]   r^   r_   r`   r   r   r   r   rX      s"   
 +rX      )r;   )
r	   r
   r   r   r   r   r   r   r   r   )
__future__r   collections.abcabccabctypingtinspectr   mixinsr   
structuresr   r$   r
   Optionalr%   rR   rX    r;   r   r   r   r   <module>   s    - e6>