Ë
    úmxi&  ã            	      ó  — U d dl mZ d dlZd dlmZmZmZmZ d dlmZm	Z	m
Z
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mZ d d	lmZ d d
lmZ d dlmZmZ d dlmZm Z m!Z! erd dl"m#Z# d dl$m%Z% d dl&m'Z' e(e)z  Z*de+d<   e
d   Z,de+d<   e-e)z  e.z  e(z  e/z  Z0de+d<   eeeeeddee0f   Z1de+d<   	 	 	 	 d d„Z2	 	 	 	 d!d„Z3ed"d„«       Z4ed#d„«       Z4d$d„Z4	 	 	 	 	 	 	 	 d%d„Z5	 d&	 	 	 	 	 	 	 d'd„Z6	 	 	 	 	 	 	 	 	 	 	 	 d(d„Z7d)d„Z8y)*é    )ÚannotationsN)ÚdateÚdatetimeÚtimeÚ	timedelta)ÚTYPE_CHECKINGÚAnyÚLiteralÚ	TypeAliasÚUnionÚoverload)ÚMessage)Úconfig)Úcurrent_form_id)ÚStreamlitDuplicateElementIdÚStreamlitDuplicateElementKey)Ú	ChatInput)ÚLabelVisibilityMessage)ÚScriptRunContextÚget_script_run_ctx)ÚGENERATED_ELEMENT_ID_PREFIXÚTESTING_KEYÚuser_key_from_element_id)Úellipsis)ÚIterable)ÚDeltaGeneratorr   ÚKey)ÚvisibleÚhiddenÚ	collapsedÚLabelVisibilityÚPROTO_SCALAR_VALUEr   ÚSAFE_VALUESc                óØ   — | dk(  rt         j                  j                  S | dk(  rt         j                  j                  S | dk(  rt         j                  j                  S t        d| › �«      ‚)zNReturns one of LabelVisibilityMessage enum constants.py based on string value.r   r   r    z Unknown label visibility value: )r   ÚLabelVisibilityOptionsÚVISIBLEÚHIDDENÚ	COLLAPSEDÚ
ValueError)Úlabel_visibility_strings    úS/home/htdocs/ttos/venv/lib/python3.12/site-packages/streamlit/elements/lib/utils.pyÚ get_label_visibility_proto_valuer,   E   sg   € ð
  )Ò+Ü%×<Ñ<×DÑDÐDØ (Ò*Ü%×<Ñ<×CÑCÐCØ +Ò-Ü%×<Ñ<×FÑFÐFä
Ð7Ð8OÐ7PÐQÓ
RÐRó    c                ó  — | du rt         j                  j                  S | du rt         j                  j                  S | dk(  rt         j                  j                  S | dk(  rt         j                  j
                  S t        d| › �«      ‚)zEReturns one of ChatInput.AcceptFile enum value based on string value.FTÚmultipleÚ	directoryzUnknown accept file value: )r   Ú
AcceptFileÚNONEÚSINGLEÚMULTIPLEÚ	DIRECTORYr)   )Úaccept_file_values    r+   Ú&get_chat_input_accept_file_proto_valuer7   T   s�   € ð
 ˜EÑ!Ü×#Ñ#×(Ñ(Ð(Ø˜DÑ Ü×#Ñ#×*Ñ*Ð*Ø˜JÒ&Ü×#Ñ#×,Ñ,Ð,Ø˜KÒ'Ü×#Ñ#×-Ñ-Ð-ä
Ð2Ð3DÐ2EÐFÓ
GÐGr-   c                 ó   — y ©N© ©Úkeys    r+   Úto_keyr=   e   s   € Ø"r-   c                 ó   — y r9   r:   r;   s    r+   r=   r=   i   s   € Ø r-   c                ó    — | €d S t        | «      S r9   )Ústrr;   s    r+   r=   r=   m   s   € Ø�;ˆ4Ð,¤C¨£HÐ,r-   c                óö   — |syt        |«      x}r5|| j                  vr| j                  j                  |«       nt        |«      ‚|| j                  vr| j                  j                  |«       yt        |«      ‚)aÍ  Register the element ID and key for the given element.

    If the element ID or key is not unique, an error is raised.

    Parameters
    ----------
    element_type : str
        The type of the element to register.

    element_id : str
        The ID of the element to register.

    Raises
    ------
    StreamlitDuplicateElementKey
        If the element key is not unique.

    StreamlitDuplicateElementID
        If the element ID is not unique.

    N)r   Úwidget_user_keys_this_runÚaddr   Úwidget_ids_this_runr   )ÚctxÚelement_typeÚ
element_idÚuser_keys       r+   Ú_register_element_idrI   q   st   € ñ2 Øä+¨JÓ7Ð7€xÐ7Ø˜3×8Ñ8Ñ8Ø×)Ñ)×-Ñ-¨hÕ7ä.¨xÓ8Ð8à˜×0Ñ0Ñ0Ø×Ñ×#Ñ# JÕ/ä)¨,Ó7Ð7r-   c                óÀ  — t        j                  dd¬«      }|j                  | j                  d«      «       |r |j                  |j                  d«      «       |j	                  «       D ]W  \  }}|j                  t        |«      j                  d«      «       |j                  t        |«      j                  d«      «       ŒY t        › d|j                  «       › d|› �S )aK  Compute the ID for the given element.

    This ID is stable: a given set of inputs to this function will always produce
    the same ID output. Only stable, deterministic values should be used to compute
    element IDs. Using nondeterministic values as inputs can cause the resulting
    element ID to change between runs.

    The element ID includes the user_key so elements with identical arguments can
    use it to be distinct. The element ID includes an easily identified prefix, and the
    user_key as a suffix, to make it easy to identify it and know if a key maps to it.
    Úmd5F)Úusedforsecurityzutf-8ú-)ÚhashlibÚnewÚupdateÚencodeÚitemsr@   r   Ú	hexdigest)rF   rH   ÚkwargsÚhÚkÚvs         r+   Ú_compute_element_idrX   ™   s²   € ô  	�‰�E¨5Ô1€AØ‡H�Hˆ\× Ñ  Ó)Ô*Ùð
 	
�‰�—‘ Ó)Ô*ð —‘“ò )‰ˆˆ1Ø	�‰”�Q“—‘˜wÓ'Ô(Ø	�‰”�Q“—‘˜wÓ'Õ(ð)ô *Ð*¨!¨A¯K©K«M¨?¸!¸H¸:ÐFÐFr-   c               ó”  — t        «       }|duxr |du xs t        |t        «      }t        |t        «      r+|r)|j                  «       D ��ci c]  \  }}||v sŒ||“Œ }	}}n|ri ni |¥}	|r|j                  |	d<   |r)|s't        |«      |	d<   |j                  j                  |	d<   t        | |fi |	¤Ž}
|rt        || |
«       |
S c c}}w )aD  Compute and register the ID for the given element.

    This ID is stable: a given set of inputs to this function will always produce
    the same ID output. Only stable, deterministic values should be used to compute
    element IDs. Using nondeterministic values as inputs can cause the resulting
    element ID to change between runs.

    The element ID includes the user_key so elements with identical arguments can
    use it to be distinct. The element ID includes an easily identified prefix, and the
    user_key as a suffix, to make it easy to identify it and know if a key maps to it.

    The element ID gets registered to make sure that only one ID and user-specified
    key exists at the same time. If there are duplicated IDs or keys, an error
    is raised.

    Parameters
    ----------
    element_type : str
        The type (command name) of the element to register.

    user_key : str | None
        The user-specified key for the element. `None` if no key is provided
        or if the element doesn't support a specifying a key.

    dg : DeltaGenerator | None
        The DeltaGenerator of each element. `None` if the element is not a widget.

    kwargs : SAFE_VALUES | Iterable[SAFE_VALUES]
        The arguments to use to compute the element ID.
        The arguments must be stable, deterministic values.
        Some common parameters like key, disabled,
        format_func, label_visibility, args, kwargs, on_change, and
        the active_script_hash are not supposed to be added here

    key_as_main_identity : bool | set[str]
        If True and a key is provided by the user, we don't include
        command kwargs in the element ID computation.
        If a set of kwarg names is provided and a key is provided,
        only the kwargs with names in this set will be included
        in the element ID computation.
    NTÚactive_script_hashÚform_idÚactive_dg_root_container)
r   Ú
isinstanceÚsetrR   rZ   r   Ú
_active_dgÚ_root_containerrX   rI   )rF   rH   ÚdgÚkey_as_main_identityrT   rE   Úignore_command_kwargsrV   rW   Úkwargs_to_userG   s              r+   Úcompute_and_register_element_idre   ¹   sé   € ôb Ó
€Cð
 %¨DÐ0ò Ø	 Ð	%ÒO¬*Ð5IÌ3Ó*Oð ô Ð&¬Ô,±à*0¯,©,«.×V¡$ ! Q¸AÐAUÒ<U˜˜A™ÐVˆÒVá3™¸¸F¸ˆá
ð /2×.DÑ.DˆÐ*Ñ+á	Ñ'Ü#2°2Ó#6ˆ�iÑ ð 57·M±M×4QÑ4QˆÐ0Ñ1ä$ \°8ÑM¸}ÑM€Já
Ü˜S ,°
Ô;ØÐùó+ Ws   ÁCÁCc                ó¦   — t        j                  d«      r	 || j                  t           |<   y y # t        $ r ||i| j                  t        <   Y y w xY w)Nzglobal.appTest)r   Ú
get_optionÚsession_stater   ÚKeyError)rE   rV   rW   s      r+   Úsave_for_app_testingrj     sU   € Ü×ÑÐ)Ô*ð	4Ø01ˆC×ÑœkÑ*¨1Ò-ð +øô ò 	4Ø./°¨VˆC×ÑœkÓ*ð	4ús   —/ ¯AÁA)r*   r!   Úreturnz7LabelVisibilityMessage.LabelVisibilityOptions.ValueType)r6   z'Literal['multiple', 'directory'] | boolrk   zChatInput.AcceptFile.ValueType)r<   ÚNonerk   rl   )r<   r   rk   r@   )r<   z
Key | Nonerk   ú
str | None)rE   r   rF   r@   rG   r@   rk   rl   r9   )rF   r@   rH   rm   rT   ú#SAFE_VALUES | Iterable[SAFE_VALUES]rk   r@   )rF   r@   rH   rm   ra   zDeltaGenerator | Nonerb   zbool | set[str]rT   rn   rk   r@   )rE   r   rV   r@   rW   r	   rk   rl   )9Ú
__future__r   rN   r   r   r   r   Útypingr   r	   r
   r   r   r   Úgoogle.protobuf.messager   Ú	streamlitr   Ú!streamlit.elements.lib.form_utilsr   Ústreamlit.errorsr   r   Ústreamlit.proto.ChatInput_pb2r   Ú*streamlit.proto.LabelVisibilityMessage_pb2r   Ú7streamlit.runtime.scriptrunner_utils.script_run_contextr   r   Ústreamlit.runtime.state.commonr   r   r   Úbuiltinsr   Úcollections.abcr   Ústreamlit.delta_generatorr   r@   Úintr   Ú__annotations__r!   ÚfloatÚboolÚbytesr"   r#   r,   r7   r=   rI   rX   re   rj   r:   r-   r+   ú<module>r�      sµ  ðö #ã ß 4Ó 4÷÷ õ ,å Ý =ß VÝ 3Ý M÷÷ñ ñ Ý!Ý(å8ð �s‘€€YÓ à$Ð%EÑF€�Ó Fà %¨¡¨dÑ 2°SÑ 8¸5Ñ @Ð �IÓ @ØØØØØØØØØðñ	€ˆYó 	ðSØ,ðSà<óSðHØ>ðHà#óHð" 
Ú "ó 
Ø "ð 
Ú  ó 
Ø  ó-ð%8Ø	ð%8Ø),ð%8Ø:=ð%8à	ó%8ðT  ðGØðGàðGð 2ðGð 	ó	Gð@QØðQð ðQð 	ð	Qð
 *ðQð 2ðQð 	óQôh4r-   