
    g
                    v    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e      ZddZdd	Zdd
Zy)    )annotations)TYPE_CHECKING
NamedTuple)runtime)context_dg_stack)DeltaGeneratorc                      e Zd ZU dZded<   y)FormDataz%Form data stored on a DeltaGenerator.strform_idN)__name__
__module____qualname____doc____annotations__     V/var/www/openai/venv/lib/python3.12/site-packages/streamlit/elements/lib/form_utils.pyr
   r
      s    / Lr   r
   c                B   t        j                         sy| j                  | j                  S | | j                  k(  r=t	        t        j                               D ]  }|j                  |j                  c S  y| j                  }||j                  |j                  S y)zFind 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)this_dgdgparents      r   _current_formr   !   s     >>%!!!'""" +//12B}}(}}$ 3 	 &"3"3"?$$$r   c                6    t        |       }|y|j                  S )zReturn 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.)
     )r   r   )r   	form_datas     r   current_form_idr#   >   s#     b!Ir   c                    t        |       dk7  S )z6True if the DeltaGenerator is inside an st.form block.r!   )r#   )r   s    r   
is_in_formr%   K   s    2"$$r   N)r   r   returnzFormData | None)r   r   r&   r   )r   r   r&   bool)
__future__r   typingr   r   	streamlitr   $streamlit.delta_generator_singletonsr   streamlit.delta_generatorr   r
   r   r#   r%   r   r   r   <module>r-      s4    # ,  A8z :
%r   