
    g/                        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mZ d dl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mZ d dlmZmZmZm Z  erd dl!m"Z" e G d d             Z# G d d      Z$y)    )annotations)	dataclass)dedent)TYPE_CHECKINGcast)current_form_id)check_widget_policiesmaybe_raise_label_warnings)KeyLabelVisibilitycompute_and_register_element_id get_label_visibility_proto_valueto_key)Checkbox)gather_metrics)ScriptRunContextget_script_run_ctx)
WidgetArgsWidgetCallbackWidgetKwargsregister_widget)DeltaGeneratorc                  *    e Zd ZU ded<   ddZdddZy)	CheckboxSerdeboolvaluec                    t        |      S N)r   )selfvs     X/var/www/openai/venv/lib/python3.12/site-packages/streamlit/elements/widgets/checkbox.py	serializezCheckboxSerde.serialize3   s    Aw    c                <    t        ||      S | j                        S r   )r   r   )r   ui_value	widget_ids      r!   deserializezCheckboxSerde.deserialize6   s     4HEE$**EEr#   N)r    r   returnr   ) )r%   zbool | Noner&   strr(   r   )__name__
__module____qualname____annotations__r"   r'    r#   r!   r   r   /   s    KFr#   r   c                  J   e Zd Z ed      	 	 	 	 	 	 dddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Z ed      	 	 	 	 	 	 dddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Z	 	 	 	 	 	 dddej                  j                  dd		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd
Z	e
dd       Zy)CheckboxMixincheckboxFNvisible)disabledlabel_visibilityc               ~    t               }
| j                  |||||||||	t        j                  j                  |
      S )at  Display a checkbox widget.

        Parameters
        ----------
        label : str
            A short label explaining to the user what this checkbox is for.
            The label can optionally contain GitHub-flavored Markdown of the
            following types: Bold, Italics, Strikethroughs, Inline Code, Links,
            and Images. Images display like icons, with a max height equal to
            the font height.

            Unsupported Markdown elements are unwrapped so only their children
            (text contents) render. Display unsupported elements as literal
            characters by backslash-escaping them. E.g.,
            ``"1\. Not an ordered list"``.

            See the ``body`` parameter of |st.markdown|_ for additional,
            supported Markdown directives.

            For accessibility reasons, you should never set an empty label, but
            you can hide it with ``label_visibility`` if needed. In the future,
            we may disallow empty labels by raising an exception.

            .. |st.markdown| replace:: ``st.markdown``
            .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown

        value : bool
            Preselect the checkbox when it first renders. This will be
            cast to bool internally.

        key : str or int
            An optional string or integer to use as the unique key for the widget.
            If this is omitted, a key will be generated for the widget
            based on its content. No two widgets may have the same key.

        help : str or None
            A tooltip that gets displayed next to the widget label. Streamlit
            only displays the tooltip when ``label_visibility="visible"``. If
            this is ``None`` (default), no tooltip is displayed.

            The tooltip can optionally contain GitHub-flavored Markdown,
            including the Markdown directives described in the ``body``
            parameter of ``st.markdown``.

        on_change : callable
            An optional callback invoked when this checkbox's value changes.

        args : tuple
            An optional tuple of args to pass to the callback.

        kwargs : dict
            An optional dict of kwargs to pass to the callback.

        disabled : bool
            An optional boolean that disables the checkbox if set to ``True``.
            The default is ``False``.

        label_visibility : "visible", "hidden", or "collapsed"
            The visibility of the label. The default is ``"visible"``. If this
            is ``"hidden"``, Streamlit displays an empty spacer instead of the
            label, which can help keep the widget alligned with other widgets.
            If this is ``"collapsed"``, Streamlit displays no label or spacer.

        Returns
        -------
        bool
            Whether or not the checkbox is checked.

        Example
        -------
        >>> import streamlit as st
        >>>
        >>> agree = st.checkbox("I agree")
        >>>
        >>> if agree:
        ...     st.write("Great!")

        .. output::
           https://doc-checkbox.streamlit.app/
           height: 220px

        labelr   keyhelp	on_changeargskwargsr4   r5   typectx)r   	_checkboxCheckboxProto	StyleTypeDEFAULTr   r8   r   r9   r:   r;   r<   r=   r4   r5   r?   s              r!   r2   zCheckboxMixin.checkbox;   sP    @ !"~~-((00  
 	
r#   togglec               ~    t               }
| j                  |||||||||	t        j                  j                  |
      S )as  Display a toggle widget.

        Parameters
        ----------
        label : str
            A short label explaining to the user what this toggle is for.
            The label can optionally contain GitHub-flavored Markdown of the
            following types: Bold, Italics, Strikethroughs, Inline Code, Links,
            and Images. Images display like icons, with a max height equal to
            the font height.

            Unsupported Markdown elements are unwrapped so only their children
            (text contents) render. Display unsupported elements as literal
            characters by backslash-escaping them. E.g.,
            ``"1\. Not an ordered list"``.

            See the ``body`` parameter of |st.markdown|_ for additional,
            supported Markdown directives.

            For accessibility reasons, you should never set an empty label, but
            you can hide it with ``label_visibility`` if needed. In the future,
            we may disallow empty labels by raising an exception.

            .. |st.markdown| replace:: ``st.markdown``
            .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown

        value : bool
            Preselect the toggle when it first renders. This will be
            cast to bool internally.

        key : str or int
            An optional string or integer to use as the unique key for the widget.
            If this is omitted, a key will be generated for the widget
            based on its content. No two widgets may have the same key.

        help : str or None
            A tooltip that gets displayed next to the widget label. Streamlit
            only displays the tooltip when ``label_visibility="visible"``. If
            this is ``None`` (default), no tooltip is displayed.

            The tooltip can optionally contain GitHub-flavored Markdown,
            including the Markdown directives described in the ``body``
            parameter of ``st.markdown``.

        on_change : callable
            An optional callback invoked when this toggle's value changes.

        args : tuple
            An optional tuple of args to pass to the callback.

        kwargs : dict
            An optional dict of kwargs to pass to the callback.

        disabled : bool
            An optional boolean that disables the toggle if set to ``True``.
            The default is ``False``.

        label_visibility : "visible", "hidden", or "collapsed"
            The visibility of the label. The default is ``"visible"``. If this
            is ``"hidden"``, Streamlit displays an empty spacer instead of the
            label, which can help keep the widget alligned with other widgets.
            If this is ``"collapsed"``, Streamlit displays no label or spacer.

        Returns
        -------
        bool
            Whether or not the toggle is checked.

        Example
        -------
        >>> import streamlit as st
        >>>
        >>> on = st.toggle("Activate feature")
        >>>
        >>> if on:
        ...     st.write("Feature activated!")

        .. output::
           https://doc-toggle.streamlit.app/
           height: 220px

        r7   )r   r@   rA   rB   TOGGLErD   s              r!   rE   zCheckboxMixin.toggle   sP    @ !"~~-((//  
 	
r#   )r4   r5   r>   r?   c          
        t        |      }t        | j                  |||du rd n|       t        ||	       t	        |
t
        j                  j                  k(  rdnd|t        | j                        |t        |      |      }t               }||_
        ||_        t        |      |_        |
|_        t        | j                        |_        ||_        t!        |	      |j"                  _        |t'        |      |_        t+        |      }t-        |j                  ||||j.                  |j0                  |d      }|j2                  r|j$                  |_        d|_        | j                  j7                  d|       |j$                  S )	NF)default_valuerE   r2   )user_keyform_idr8   r   r:   
bool_value)on_change_handlerr<   r=   deserializer
serializerr?   
value_typeT)r   r	   dgr
   r   rA   rB   rG   r   r   idr8   defaultr>   rK   r4   r   r5   r   r   r:   r   r   r'   r"   value_changed	set_value_enqueue)r   r8   r   r9   r:   r;   r<   r=   r4   r5   r>   r?   
element_idcheckbox_protoserdecheckbox_states                   r!   r@   zCheckboxMixin._checkbox  se    SkGG"'5.$e		
 	#5*:;4 7 7 > >>HJ#DGG,u+

 '&$!%e"!0!9"*0P1
''- "(,Ne$('**#	
 ''#1#7#7N '+N$^4###r#   c                    t        d|       S )zGet our DeltaGenerator.r   )r   )r   s    r!   rQ   zCheckboxMixin.dg]  s     $d++r#   )FNNNNN)r8   r*   r   r   r9   
Key | Noner:   
str | Noner;   WidgetCallback | Noner<   WidgetArgs | Noner=   WidgetKwargs | Noner4   r   r5   r   r(   r   )r8   r*   r   r   r9   r\   r:   r]   r;   r^   r<   r_   r=   r`   r4   r   r5   r   r>   z!CheckboxProto.StyleType.ValueTyper?   zScriptRunContext | Noner(   r   )r(   r   )r+   r,   r-   r   r2   rE   rA   rB   rC   r@   propertyrQ   r/   r#   r!   r1   r1   :   s%   J +/"&&*l
 ,5l
l
 l
 	l

 l
 )l
  l
 $l
 l
 *l
 
l
  l
\ H +/"&&*l
 ,5l
l
 l
 	l

 l
 )l
  l
 $l
 l
 *l
 
l
 l
b +/"&&*B$ ,52?2I2I2Q2Q'+B$B$ B$ 	B$
 B$ )B$  B$ $B$ B$ *B$ 0B$ %B$ 
B$H , ,r#   r1   N)%
__future__r   dataclassesr   textwrapr   typingr   r   !streamlit.elements.lib.form_utilsr   streamlit.elements.lib.policiesr	   r
   streamlit.elements.lib.utilsr   r   r   r   r   streamlit.proto.Checkbox_pb2r   rA   streamlit.runtime.metrics_utilr   streamlit.runtime.scriptrunnerr   r   streamlit.runtime.stater   r   r   r   streamlit.delta_generatorr   r   r1   r/   r#   r!   <module>rn      sk    # !  & =  C 9 O  8 F F Ff, f,r#   