o
    ßñh
  ã                   @  sv   d dl mZ d dlmZmZ d dlmZ d dlmZ er"d dl	m
Z
 G dd„ deƒZddd„Zddd„Zddd„ZdS )é    )Úannotations)ÚTYPE_CHECKINGÚ
NamedTuple)Úruntime)Úcontext_dg_stack)ÚDeltaGeneratorc                   @  s   e Zd ZU dZded< dS )ÚFormDataz%Form data stored on a DeltaGenerator.ÚstrÚform_idN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__© r   r   úU/var/www/vscode/kcb/lib/python3.10/site-packages/streamlit/elements/lib/form_utils.pyr      s   
 r   Úthis_dgr   ÚreturnúFormData | Nonec                 C  sr   t  ¡ sdS | jdur| jS | | jkr(tt ¡ ƒD ]}|jdur%|j  S qdS | j}|dur7|jdur7|jS dS )zåFind the FormData for the given DeltaGenerator.

    Forms are blocks, and can have other blocks nested inside them.
    To find the current form, we walk up the dg_stack until we find
    a DeltaGenerator that has FormData.
    N)r   ÚexistsÚ
_form_dataÚ_main_dgÚreversedr   ÚgetÚ_parent)r   ÚdgÚparentr   r   r   Ú_current_form!   s   



ÿ	ür   r   r	   c                 C  s   t | ƒ}|du r
dS |jS )z÷Return the form_id for the current form, or the empty string if we're
    not inside an `st.form` block.

    (We return the empty string, instead of None, because this value is
    assigned to protobuf message fields, and None is not valid.)
    NÚ )r   r
   )r   Ú	form_datar   r   r   Úcurrent_form_id>   s   r    Úboolc                 C  s   t | ƒdkS )z6True if the DeltaGenerator is inside an st.form block.r   )r    )r   r   r   r   Ú
is_in_formK   s   r"   N)r   r   r   r   )r   r   r   r	   )r   r   r   r!   )Ú
__future__r   Útypingr   r   Ú	streamlitr   Ú$streamlit.delta_generator_singletonsr   Ústreamlit.delta_generatorr   r   r   r    r"   r   r   r   r   Ú<module>   s   

