
    5i2                        d dl mZ d dl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 erd dlmZ  G d deeef         Zy	)
    )annotations)IterableIteratorMutableMapping)TYPE_CHECKINGAnyoverload)gather_metrics)get_session_state)SupportsKeysAndGetItemc                     e Zd ZdZd dZd!dZd"dZ ed      d#d       Zd$dZ	 ed      d%d	       Z
 ed
      d#d       Zd$dZe	 	 	 	 	 	 d&d       Ze	 	 	 	 	 	 d'd       Zed(d       Zd)d*dZ ed      d%d       Z ed      d+d       Z ed      d*d       Z ed      d,d       Zed-d       Ze	 	 	 	 d.d       Z ed      	 	 	 	 d/d       Zed#d       Zed#d       Zy)0QueryParamsProxyz
    A stateless singleton that proxies ``st.query_params`` interactions
    to the current script thread's QueryParams instance.
    c                t    t               j                         5 }t        |      cd d d        S # 1 sw Y   y xY wN)r   query_paramsiterselfqps     t/home/obispo/Crisostomo_bridge/mision_env/lib/python3.12/site-packages/streamlit/runtime/state/query_params_proxy.py__iter__zQueryParamsProxy.__iter__!   s/     --/ 	28	 	 	   .7c                t    t               j                         5 }t        |      cd d d        S # 1 sw Y   y xY wr   )r   r   lenr   s     r   __len__zQueryParamsProxy.__len__%   /     --/ 	2r7	 	 	r   c                t    t               j                         5 }t        |      cd d d        S # 1 sw Y   y xY wr   )r   r   strr   s     r   __str__zQueryParamsProxy.__str__)   r   r   zquery_params.get_itemc                    t               j                         5 }	 ||   cd d d        S # t        $ r t        | j                  |            w xY w# 1 sw Y   y xY wr   )r   r   KeyErrormissing_key_error_messager   keyr   s      r   __getitem__zQueryParamsProxy.__getitem__-   sh     --/ 	D2D#w	D 	D  Dt==cBCCD	D 	D   A)$AAAc                d    t               j                         5 }||= d d d        y # 1 sw Y   y xY wr   r   r   r#   s      r   __delitem__zQueryParamsProxy.__delitem__5   s/     --/ 	23	 	 	s   &/zquery_params.set_itemc                h    t               j                         5 }|||<   d d d        y # 1 sw Y   y xY wr   r(   r   r$   valuer   s       r   __setitem__zQueryParamsProxy.__setitem__9   1     --/ 	2BsG	 	 	   (1zquery_params.get_attrc                    t               j                         5 }	 ||   cd d d        S # t        $ r t        | j	                  |            w xY w# 1 sw Y   y xY wr   )r   r   r!   AttributeErrormissing_attr_error_messager#   s      r   __getattr__zQueryParamsProxy.__getattr__>   sh     --/ 	K2K#w	K 	K  K$T%D%DS%IJJK	K 	Kr&   c                    t               j                         5 }	 ||= 	 d d d        y # t        $ r t        | j	                  |            w xY w# 1 sw Y   y xY wr   )r   r   r!   r1   r"   r#   s      r   __delattr__zQueryParamsProxy.__delattr__F   sh     --/ 	J2JsG	J 	J  J$T%C%CC%HIIJ	J 	Js   A($AAAc                    y r    r   paramskwdss      r   updatezQueryParamsProxy.updateM            c                    y r   r7   r8   s      r   r;   zQueryParamsProxy.updateR   r<   r=   c                     y r   r7   )r   r:   s     r   r;   zQueryParamsProxy.updateW   s    ;>r=   c                   t               j                         5 } |j                  |fi | ddd       y# 1 sw Y   yxY w)a  
        Update one or more values in query_params at once from a dictionary or
        dictionary-like object.

        See `Mapping.update()` from Python's `collections` library.

        Parameters
        ----------
        other: SupportsKeysAndGetItem[str, str] | Iterable[tuple[str, str]]
            A dictionary or mapping of strings to strings.
        **kwds: str
            Additional key/value pairs to update passed as keyword arguments.
        N)r   r   r;   )r   r9   r:   r   s       r   r;   zQueryParamsProxy.updateZ   s=      --/ 	&2BIIf%%	& 	& 	&s   6?zquery_params.set_attrc                h    t               j                         5 }|||<   d d d        y # 1 sw Y   y xY wr   r(   r+   s       r   __setattr__zQueryParamsProxy.__setattr__k   r.   r/   zquery_params.get_allc                    t               j                         5 }|j                  |      cddd       S # 1 sw Y   yxY w)aK  
        Get a list of all query parameter values associated to a given key.

        When a key is repeated as a query parameter within the URL, this method
        allows all values to be obtained. In contrast, dict-like methods only
        retrieve the last value when a key is repeated in the URL.

        Parameters
        ----------
        key: str
            The label of the query parameter in the URL.

        Returns
        -------
        List[str]
            A list of values associated to the given key. May return zero, one,
            or multiple values.
        N)r   r   get_allr#   s      r   rD   zQueryParamsProxy.get_allp   s5    (  --/ 	#2::c?	# 	# 	#   4=zquery_params.clearc                ~    t               j                         5 }|j                          ddd       y# 1 sw Y   yxY w)zs
        Clear all query parameters from the URL of the app.

        Returns
        -------
        None
        N)r   r   clearr   s     r   rG   zQueryParamsProxy.clear   s3      --/ 	2HHJ	 	 	s   3<zquery_params.to_dictc                ~    t               j                         5 }|j                         cddd       S # 1 sw Y   yxY w)a  
        Get all query parameters as a dictionary.

        This method primarily exists for internal use and is not needed for
        most cases. ``st.query_params`` returns an object that inherits from
        ``dict`` by default.

        When a key is repeated as a query parameter within the URL, this method
        will return only the last value of each unique key.

        Returns
        -------
        Dict[str,str]
            A dictionary of the current query parameters in the app's URL.
        N)r   r   to_dictr   s     r   rI   zQueryParamsProxy.to_dict   s3    "  --/ 	 2::<	  	  	 s   3<c                     y r   r7   r   r9   s     r   	from_dictzQueryParamsProxy.from_dict   s    TWr=   c                     y r   r7   rK   s     r   rL   zQueryParamsProxy.from_dict   r<   r=   zquery_params.from_dictc                    t               j                         5 }|j                  |      cddd       S # 1 sw Y   yxY w)a  
        Set all of the query parameters from a dictionary or dictionary-like object.

        This method primarily exists for advanced users who want to control
        multiple query parameters in a single update. To set individual query
        parameters, use key or attribute notation instead.

        This method inherits limitations from ``st.query_params`` and can't be
        used to set embedding options as described in `Embed your app         <https://docs.streamlit.io/deploy/streamlit-community-cloud/share-your-app/embed-your-app#embed-options>`_.

        To handle repeated keys, the value in a key-value pair should be a list.

        .. note::
            ``.from_dict()`` is not a direct inverse of ``.to_dict()`` if
            you are working with repeated keys. A true inverse operation is
            ``{key: st.query_params.get_all(key) for key in st.query_params}``.

        Parameters
        ----------
        params: dict
            A dictionary used to replace the current query parameters.

        Example
        -------
        >>> import streamlit as st
        >>>
        >>> st.query_params.from_dict({"foo": "bar", "baz": [1, "two"]})

        N)r   r   rL   )r   r9   r   s      r   rL   zQueryParamsProxy.from_dict   s7    H  --/ 	(2<<'	( 	( 	(rE   c                    d|  dS )z3Returns a formatted error message for missing keys.zst.query_params has no key "".r7   r$   s    r   r"   z*QueryParamsProxy.missing_key_error_message   s     .cU"55r=   c                    d|  dS )z9Returns a formatted error message for missing attributes.z"st.query_params has no attribute "rP   r7   rQ   s    r   r2   z+QueryParamsProxy.missing_attr_error_message   s     4C5;;r=   N)returnzIterator[str])rS   int)rS   r   )r$   r   rS   r   )r$   r   rS   None)r$   r   r,   r   rS   rU   )r9   0SupportsKeysAndGetItem[str, str | Iterable[str]]r:   r   rS   rU   )r9   )Iterable[tuple[str, str | Iterable[str]]]r:   r   rS   rU   )r:   zstr | Iterable[str]rS   rU   )r7   )rS   rU   )r$   r   rS   z	list[str])rS   zdict[str, str])r9   rW   rS   rU   )r9   rV   rS   rU   )r9   z\SupportsKeysAndGetItem[str, str | Iterable[str]] | Iterable[tuple[str, str | Iterable[str]]]rS   rU   )__name__
__module____qualname____doc__r   r   r   r
   r%   r)   r-   r3   r5   r	   r;   rB   rD   rG   rI   rL   staticmethodr"   r2   r7   r=   r   r   r      s   
 +,D -D +, - +,K -KJ FSV	  ?LO	  > >&" +, - *+# ,#, ()	 *	 *+  , & W WF	  ,-$(4$( 
	$( .$(L 6 6 < <r=   r   N)
__future__r   collections.abcr   r   r   typingr   r   r	   streamlit.runtime.metrics_utilr
   +streamlit.runtime.state.session_state_proxyr   	_typeshedr   r   r   r7   r=   r   <module>rc      s9    # > > / / 9 I0C<~c3h/ C<r=   