
    'g%                        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Z G d	 d
eeej                  e   f         Z G d de
eej                  e   f   e      Z G d de      ZddlmZ y)    )annotationsN)cleandoc   )ImmutableDictMixin)CallbackDictdocc               n    |d  dg}t         u r|j                  d       n[|j                  d       n|j                  dj                   d       |j                  dd       |j                  d	       d
j                  |      }t	         fd fd fdt        |            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``.
    z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                *    | j                        S N)_get_cache_value)xemptykeytypes    ]/var/www/html/knws/venv/lib/python3.12/site-packages/werkzeug/datastructures/cache_control.py<lambda>z(cache_control_property.<locals>.<lambda>1   s    !$$S%6     c                *    | j                  |      S r   )_set_cache_value)r   vr   r   s     r   r   z(cache_control_property.<locals>.<lambda>2   s    Q''Q5 r   c                &    | j                        S r   )_del_cache_value)r   r   s    r   r   z(cache_control_property.<locals>.<lambda>3   s    !$$S) r   r   )boolappend__name__joinpropertyr   )r   r   r   r	   partss   ```  r   cache_control_propertyr!      s    & {#m,-4<LL=>|\*tDMM?#67 r%*FGHLL67hhuo65)SM	 r   c                  
    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Z	 	 	 	 	 	 	 	 ddZ	 	 	 	 	 	 	 	 ddZddZddZddZddZ ee      Z x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_errorc                8    t         |   ||       |d u| _        y r   )super__init__provided)selfvalues	on_update	__class__s      r   r+   z_CacheControl.__init__Z   s     
 	+d*r   c                r    |t         u r|| v S || vry| |   x}|S |	  ||      }|S |S # t        $ r Y yw xY w+Used internally by the accessor properties.N)r   
ValueError)r-   r   r   r   values        r   r   z_CacheControl._get_cache_valueb   sf     4<$;d?#YE'LU u  s   * 	66c                    |t         u r|rd| |<   y| j                  |d       y||du r| j                  |d       y|du rd| |<   y| ||      }t        |      | |<   y)r3   NFT)r   popstr)r-   r   r5   r   s       r   r   z_CacheControl._set_cache_valuew   sj     4< S	d#]eunHHS$d]DIUE
DIr   c                    || v r| |= yyr2    )r-   r   s     r   r   z_CacheControl._del_cache_value   s    $;S	 r   c                ,    t        j                  |       S )z6Convert the stored values into a cache control header.)httpdump_headerr-   s    r   	to_headerz_CacheControl.to_header   s    %%r   c                "    | j                         S r   )r?   r>   s    r   __str__z_CacheControl.__str__   s    ~~r   c                    dj                  d t        | j                               D              }dt        |       j                   d| dS )Nr   c              3  0   K   | ]  \  }}| d |  yw)=Nr:   ).0kr   s      r   	<genexpr>z)_CacheControl.__repr__.<locals>.<genexpr>   s     H41aQCq,Hs   <>)r   sorteditemsr   r   )r-   kv_strs     r   __repr__z_CacheControl.__repr__   sA    H6$**,3GHH4:&&'q22r   )r:   N)r.   zBcabc.Mapping[str, t.Any] | cabc.Iterable[tuple[str, t.Any]] | Noner/   z+cabc.Callable[[_CacheControl], None] | None)r   r8   r   t.Anyr   type[t.Any] | NonereturnrN   )r   r8   r5   rN   r   rO   rP   None)r   r8   rP   rQ   )rP   r8   )r   
__module____qualname____doc__r!   r   r$   __annotations__intr&   r'   r(   r+   r   r   r   r?   rA   rM   staticmethodcache_property__classcell__)r0   s   @r   r#   r#   8   s    8 ,JdCHdC0D#FGZF/dKL$K!78H$PS!TNJT VXAE+R+ ?+$,>	*##$#,>#	#&
& 3 ""89Nr   r#   c                      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<   y)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   rR   rS   rT   r!   r   r]   rU   rV   r^   r_   r`   r:   r   r   r[   r[      sa    )V ,JdCHdC.D/I+ 
 3;cJIzJ12BD$ONDOr   r[   c                      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<   y)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.
    r\   TNzstr | t.Literal[True] | Noner]   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   rR   rS   rT   r!   r]   rU   r   rc   rd   re   rf   rV   rg   rh   ri   rj   r:   r   r   rb   rb      s    )V .DD$.H*  *(D$?FD?,B4-G)  33DdDQOTQ34FdSdS1*dCHHjH,[$EItE23DdDQOTQ)? $*J r   rb      )r<   )
r   r8   r   rN   r   rO   r	   z
str | NonerP   rN   )
__future__r   collections.abcabccabctypingtinspectr   mixinsr   
structuresr   r!   r8   Optionalr#   r[   rb    r<   r:   r   r   <module>rw      s    "    & $ LP*	**"4*>H*
*Zb:Lajjo!56 b:J3P,S!**S/-ABM 3Pl:= :| r   