o
    ,&]i                     @  s  U d dl mZ d dlZd dlmZmZ d dlmZmZm	Z	 d dl
mZmZmZm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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*m+Z+m,Z, d dl-m.Z/ d dl0m1Z2 d dl3m4Z5 d dl6m7Z8 d dl9m:Z:m;Z; d dl<m=Z=m>Z> erJd dl?m@ZA d dlBmCZD d dlEmFZG d dlHmIZJ d dlKmLZM d dlNmOZP d dlQmRZS d dlTmUZV d dlWmXZY d dlZm[Z\ d dl]m^Z_ d dl`maZb d d lcmdZd d d!lemfZg d d"lhmiZj d d#lkmlZm d d$lnmoZp d d%lqmrZs d d&ltmuZv d d'lwmxZy d d(lzm{Z| d d)l}m~Z d d*lmZ d d+lmZ d d,lmZ d d-lmZ d d.lmZ d d/lmZ ed0ZeG d1d2 d2ZeG d3d4 d4eZ^ed5d6G d7d8 d8e^Zed5d6G d9d: d:e^eZed;e^d<d=ZG d>d? d?ee Zed@ed<d=ZG dAdB dBee ee Zed5d6G dCdD dDe^Zed5d6G dEdF dFeZed5d6G dGdH dHeZed5d6G dIdJ dJeZed5d6G dKdL dLeZed5d6G dMdN dNeZIed5d6G dOdP dPeZOed5d6G dQdR dReZ1ed5d6G dSdT dTe^ZRed5d6G dUdV dVeZUed5d6G dWdX dXe^ZeeB ZdYedZ< ee	e B dB ZdYed[< ed5d6G d\d] d]eZXed5d6G d^d_ d_e^Zaed5d6G d`da dae^eZed5d6G dbdc dceZed5d6G ddde deeZed5d6G dfdg dgeZed5d6G dhdi die^Zied5d6G djdk dke^Z4ed5d6G dldm dme4Zed5d6G dndo doe4Zed5d6G dpdq dqe4Zed5d6G drds dse^Z{ed5d6G dtdu due^Zled5d6G dvdw dweee ZLed5d6G dxdy dyeee ZeeB ZdYedz< ed5d6G d{d| d|eZred5d6G d}d~ d~eee Zued5d6G dd deee Zxed5d6G dd deee ZedeeeeeZed5d6G dd deee Z7ed5d6G dd de^Zed5d6G dd de^Z~ed5d6G dd deZed5d6G dd deZeeB ZdYed< eZdYed< ed5d6G dd deZed5d6G dd deZ[ed5d6G dd de^Zed5d6G dd deZed5d6G dd dZFdddZdddZed5d6G dd deFZed5d6G dd deFZed5d6G dd deFZed5d6G dd deFZed5d6G dd deFZed5d6G dd deFZe^eFB ZdYed< dddZed5d6G dd deFZdddZdS )    )annotationsN)ABCabstractmethod)CallableIteratorSequence)	dataclassfieldfieldsis_dataclass)datedatetimetime	timedelta)TYPE_CHECKINGAnyGeneric	TypeAliasTypeVarcastoverload)Self)dataframe_utilutil)HeadingProtoTag)SelectSliderSerde)SliderSerde
SliderStep)DateInputSerdeDateTimeInputSerdeDateWidgetReturnTimeInputSerde_parse_date_value)Alert)Checkbox)Markdown)Slider)WidgetStateWidgetStates)TESTING_KEYuser_key_from_element_id)	DataFrame)Arrow)Block)Button)ButtonGroup)	ChatInput)Code)ColorPicker)	DateInput)DateTimeInput)Element)	Exception)
ForwardMsg)Heading)Json)Metric)MultiSelect)NumberInput)Radio)	Selectbox)Space)Text)TextArea)	TextInput)	TimeInput)Toast)SafeSessionState)AppTestTc                   @  s   e Zd ZdZdS )InitialValuez0Used to represent the initial value of a widget.N)__name__
__module____qualname____doc__ rM   rM   _/var/www/html/IGF-ODF-V3/venv/lib/python3.10/site-packages/streamlit/testing/v1/element_tree.pyrH   Y   s    rH   c                   @  s   e Zd ZU dZeddZded< eddZded< eddZded	< d
ed< e	d"ddZ
d#ddZee	d$ddZd%ddZddd&ddZd'd d!ZdS )(r5   aL  
    Element base class for testing.

    This class's methods and attributes are universal for all elements
    implemented in testing. For example, ``Caption``, ``Code``, ``Text``, and
    ``Title`` inherit from ``Element``. All widget classes also
    inherit from Element, but have additional methods specific to each
    widget type. See the ``AppTest`` class for the full list of supported
    elements.

    For all element classes, parameters of the original element can be obtained
    as properties. For example, ``Button.label``, ``Caption.help``, and
    ``Toast.icon``.

    Freprstrtyper   protoElementTreeroot
str | NonekeyElementProtoreturnNonec                 C     d S NrM   selfrS   rU   rM   rM   rN   __init__      zElement.__init__Iterator[Self]c                 c  s    | V  d S r\   rM   r^   rM   rM   rN   __iter__   s   
zElement.__iter__c                 C  s   dS )z%The value or contents of the element.NrM   rb   rM   rM   rN   value   s   zElement.valuenamec                 C  s   t | j|S )z4Fallback attempt to get an attribute from the proto.)getattrrS   )r^   re   rM   rM   rN   __getattr__   s   zElement.__getattr__Ntimeoutri   float | NonerF   c                C     | j j|dS )zRun the ``AppTest`` script which contains the element.

        Parameters
        ----------
        timeout
            The maximum number of seconds to run the script. None means
            use the AppTest's default.
        rh   rU   runr^   ri   rM   rM   rN   rm         	zElement.runc                 C  
   t | S r\   r   repr_rb   rM   rM   rN   __repr__      
zElement.__repr__rS   rX   rU   rT   rY   rZ   )rY   ra   rY   r   )re   rQ   rY   r   ri   rj   rY   rF   rY   rQ   )rI   rJ   rK   rL   r	   rR   __annotations__rS   rU   r   r_   rc   propertyrd   rg   rm   rs   rM   rM   rM   rN   r5   i   s   
 

r5   FrO   c                   @  s$   e Zd ZdddZedd
dZdS )UnknownElementrS   rX   rU   rT   rY   rZ   c                 C  s8   | d}|d usJ t||| _|| _|| _d | _d S )NrR   )
WhichOneofrf   rS   rU   rR   rW   r^   rS   rU   tyrM   rM   rN   r_      s   

zUnknownElement.__init__r   c                 C  s>   z| j j}|d usJ || jj W S  ty   | jj Y S w r\   )rU   session_staterS   id
ValueErrorrd   r^   staterM   rM   rN   rd      s   zUnknownElement.valueNru   rv   )rI   rJ   rK   r_   rz   rd   rM   rM   rM   rN   r{      s    
r{   c                   @  sb   e Zd ZU dZeddZded< ded< ded	< d
ed< dddZdddZe	e
dddZdS )WidgetzWidget base class for testing.FrO   rQ   r   booldisabledrV   rW   r   _valuerS   rU   rT   rY   rZ   c                 C  s"   || _ || _t| j| _d | _d S r\   )rS   rU   r*   r   rW   r   r]   rM   rM   rN   r_      s   
zWidget.__init__vr   c                 C  
   || _ | S zSet the value of the widget.r   r^   r   rM   rM   rN   	set_value      zWidget.set_valuer'   c                 C  r[   r\   rM   rb   rM   rM   rN   _widget_state      zWidget._widget_stateN)rS   r   rU   rT   rY   rZ   )r   r   rY   r   rY   r'   )rI   rJ   rK   rL   r	   r   ry   r_   r   rz   r   r   rM   rM   rM   rN   r      s   
 

r   El_coT)bound	covariantc                   @  s   e Zd Zd'ddZd(dd	Zed(d
dZed)ddZed*ddZd+ddZd,ddZ	d-ddZ
d.dd Zd(d!d"Zed/d$d%Zd&S )0ElementListelsSequence[El_co]rY   rZ   c                 C  s
   || _ d S r\   _list)r^   r   rM   rM   rN   r_      rt   zElementList.__init__intc                 C  
   t | jS r\   )lenr   rb   rM   rM   rN   __len__   rt   zElementList.__len__c                 C     t | S r\   )r   rb   rM   rM   rN   r         zElementList.lenidxr   c                 C  r[   r\   rM   r^   r   rM   rM   rN   __getitem__   r`   zElementList.__getitem__sliceElementList[El_co]c                 C  r[   r\   rM   r   rM   rM   rN   r      r`   int | sliceEl_co | ElementList[El_co]c                 C  s"   t |trt| j| S | j| S r\   )
isinstancer   r   r   r   rM   rM   rN   r      s   

Iterator[El_co]c                 c  s    | j E d H  d S r\   r   rb   rM   rM   rN   rc      s   zElementList.__iter__rQ   c                 C  rp   r\   rq   rb   rM   rM   rN   rs      rt   zElementList.__repr__otherElementList[El_co] | objectr   c                 C  s    t |tr| j|jkS | j|kS r\   )r   r   r   )r^   r   rM   rM   rN   __eq__   s   

zElementList.__eq__c                 C  s   t t| jS r\   )hashtupler   rb   rM   rM   rN   __hash__   s   zElementList.__hash__Sequence[Any]c                 C  s   dd | D S )Nc                 S  s   g | ]}|j qS rM   rd   .0erM   rM   rN   
<listcomp>   s    z&ElementList.values.<locals>.<listcomp>rM   rb   rM   rM   rN   values      zElementList.valuesN)r   r   rY   rZ   rY   r   )r   r   rY   r   )r   r   rY   r   )r   r   rY   r   )rY   r   rx   )r   r   rY   r   )rY   r   )rI   rJ   rK   r_   r   rz   r   r   r   rc   rs   r   r   r   rM   rM   rM   rN   r      s     






r   W_coc                   @  s   e Zd ZdddZdS )	
WidgetListrW   rQ   rY   r   c                 C  s&   | j D ]}|j|kr|  S qt|r\   )r   rW   KeyError)r^   rW   r   rM   rM   rN   __call__   s
   

zWidgetList.__call__N)rW   rQ   rY   r   )rI   rJ   rK   r   rM   rM   rM   rN   r      s    r   c                   @  @   e Zd ZU eddZded< ded< dddZedddZdS )	AlertBaseFrO   
AlertProtorS   rQ   iconrU   rT   rY   rZ   c                 C  s   || _ d | _|| _d S r\   )rS   rW   rU   r]   rM   rM   rN   r_   
     
zAlertBase.__init__c                 C     | j jS r\   rS   bodyrb   rM   rM   rN   rd     r   zAlertBase.valueNrS   r   rU   rT   rY   rZ   rx   	rI   rJ   rK   r	   rS   ry   r_   rz   rd   rM   rM   rM   rN   r     s   
 
r   c                         e Zd Zd	 fddZ  ZS )
ErrorrS   r   rU   rT   rY   rZ   c                      t  || d| _d S Nerrorsuperr_   rR   r]   	__class__rM   rN   r_        
zError.__init__r   rI   rJ   rK   r_   __classcell__rM   rM   r   rN   r         r   c                      r   )
WarningrS   r   rU   rT   rY   rZ   c                   r   Nwarningr   r]   r   rM   rN   r_     r   zWarning.__init__r   r   rM   rM   r   rN   r     r   r   c                      r   )
InforS   r   rU   rT   rY   rZ   c                   r   Ninfor   r]   r   rM   rN   r_   $  r   zInfo.__init__r   r   rM   rM   r   rN   r   "  r   r   c                      r   )
SuccessrS   r   rU   rT   rY   rZ   c                   r   Nsuccessr   r]   r   rM   rN   r_   +  r   zSuccess.__init__r   r   rM   rM   r   rN   r   )  r   r   c                      s   e Zd ZU dZded< eddZded< ded	< ded
< ded< d fddZedddZ	edddZ
dddZd ddZ  ZS )!r.   z@A representation of ``st.button`` and ``st.form_submit_button``.r   r   FrO   ButtonProtorS   rQ   labelhelpform_idrU   rT   rY   rZ   c                   s   t  || d| _d| _d S )NFbuttonr   r_   r   rR   r]   r   rM   rN   r_   ;     
zButton.__init__r'   c                 C     t  }| j|_| j|_|S r\   )r'   r   r   trigger_valuer^   wsrM   rM   rN   r   @     zButton._widget_statec                 C  s0   | j r| j S | jj}|sJ td|t | j S )zThe value of the button. (bool)r   )r   rU   r   r   r)   r   r   rM   rM   rN   rd   G  s
   zButton.valuer   c                 C  r   )zSet the value of the button.r   r   rM   rM   rN   r   P  r   zButton.set_valuec                 C  
   |  dS )z$Set the value of the button to True.Tr   rb   rM   rM   rN   clickU     
zButton.click)rS   r   rU   rT   rY   rZ   r   rY   r   )r   r   rY   r.   )rY   r.   )rI   rJ   rK   rL   ry   r	   rS   r_   rz   r   rd   r   r   r   rM   rM   r   rN   r.   0  s   
 
r.   c                      sl   e Zd ZU dZded< eddZded< ded	< d fddZdddZe	dddZ
e	dddZ  ZS )r0   z&A representation of ``st.chat_input``.rV   r   FrO   ChatInputProtorS   rQ   placeholderrU   rT   rY   rZ   c                   r   N
chat_inputr   r]   r   rM   rN   r_   b  r   zChatInput.__init__r   c                 C  r   r   r   r   rM   rM   rN   r   f  r   zChatInput.set_valuer'   c                 C  s&   t  }| j|_| jd ur| j|j_|S r\   )r'   r   r   string_trigger_valuedatar   rM   rM   rN   r   k  s
   

zChatInput._widget_statec                 C  s*   | j r| j S | jj}|sJ |t | j S )zThe value of the widget. (str))r   rU   r   r)   r   r   rM   rM   rN   rd   s  s
   zChatInput.value)rS   r   rU   rT   rY   rZ   )r   rV   rY   r0   r   rY   rV   rI   rJ   rK   rL   ry   r	   rS   r_   r   rz   r   rd   r   rM   rM   r   rN   r0   Z  s   
 
r0   c                      s   e Zd ZU dZded< eddZded< ded	< ded
< ded< d fddZed ddZ	ed!ddZ
d"ddZd#ddZd#ddZ  ZS )$r$   z$A representation of ``st.checkbox``.bool | Noner   FrO   CheckboxProtorS   rQ   r   r   r   rU   rT   rY   rZ   c                   r   Ncheckboxr   r]   r   rM   rN   r_     r   zCheckbox.__init__r'   c                 C  r   r\   r'   r   rd   
bool_valuer   rM   rM   rN   r     r   zCheckbox._widget_stater   c                 C  0   | j dur| j S | jj}|sJ td|| j S )zThe value of the widget. (bool)Nr   r   rU   r   r   r   r   rM   rM   rN   rd     
   
zCheckbox.valuer   c                 C  r   r   r   r   rM   rM   rN   r     r   zCheckbox.set_valuec                 C  r   )z$Set the value of the widget to True.Tr   rb   rM   rM   rN   check  r   zCheckbox.checkc                 C  r   )z%Set the value of the widget to False.Fr   rb   rM   rM   rN   uncheck  r   zCheckbox.uncheckrS   r   rU   rT   rY   rZ   r   r   )r   r   rY   r$   )rY   r$   )rI   rJ   rK   rL   ry   r	   rS   r_   rz   r   rd   r   r   r   r   rM   rM   r   rN   r$   }  s   
 

r$   c                   @  sT   e Zd ZU dZeddZded< ded< ded	< d
ed< dddZedddZ	dS )r1   z A representation of ``st.code``.FrO   	CodeProtorS   rQ   languager   show_line_numbersrZ   rW   rU   rT   rY   c                 C     || _ d | _|| _d| _d S NcoderS   rW   rU   rR   r]   rM   rM   rN   r_        
zCode.__init__c                 C  r   zThe value of the element. (str))rS   	code_textrb   rM   rM   rN   rd        z
Code.valueN)rS   r  rU   rT   rY   rZ   rx   )
rI   rJ   rK   rL   r	   rS   ry   r_   rz   rd   rM   rM   rM   rN   r1     s   
 
r1   c                      s   e Zd ZU dZded< ded< ded< ded< edd	Zd
ed< d fddZedddZ	edddZ
dddZdddZ  ZS ) r2   z(A representation of ``st.color_picker``.rV   r   rQ   r   r   r   FrO   ColorPickerProtorS   rU   rT   rY   rZ   c                   r   Ncolor_pickerr   r]   r   rM   rN   r_     r   zColorPicker.__init__c                 C  r   )z3The currently selected value as a hex string. (str)NrQ   r   r   rM   rM   rN   rd     r   zColorPicker.valuer'   c                 C  r   )Protobuf message representing the state of the widget, including
        any interactions that have happened.
        Should be the same as the frontend would produce for those interactions.
        r'   r   rd   string_valuer   rM   rM   rN   r     s   zColorPicker._widget_stater   c                 C  r   )z,Set the value of the widget as a hex string.r   r   rM   rM   rN   r     r   zColorPicker.set_valuec                 C  s   | ds
d| }| |S )zESet the value of the widget as a hex string. May omit the "#" prefix.#)
startswithr   r   rM   rM   rN   pick  s   


zColorPicker.pick)rS   r  rU   rT   rY   rZ   rx   r   )r   rQ   rY   r2   )rI   rJ   rK   rL   ry   r	   rS   r_   rz   rd   r   r   r  r   rM   rM   r   rN   r2     s   
 

r2   c                   @  8   e Zd ZU eddZded< dd	d
ZedddZdS )	DataframeFrO   
ArrowProtorS   rU   rT   rY   rZ   c                 C     d | _ || _|| _d| _d S Narrow_data_framerW   rS   rU   rR   r]   rM   rM   rN   r_     r  zDataframe.__init__PandasDataframec                 C     t | jjS r\   r    convert_arrow_bytes_to_pandas_dfrS   r   rb   rM   rM   rN   rd     r   zDataframe.valueNrS   r  rU   rT   rY   rZ   rY   r  r   rM   rM   rM   rN   r    
   
 
r  r   SingleDateValue	DateValuec                      s   e Zd ZU dZded< eddZded< ded	< d
ed< d
ed< ded< ded< ded< d! fddZd"ddZe	d#ddZ
e	d$dd Z  ZS )%r3   z&A representation of ``st.date_input``.zDateValue | None | InitialValuer   FrO   DateInputProtorS   rQ   r   r   minmaxr   is_ranger   r   rU   rT   rY   rZ   c                   sH   t  || t | _d| _t|jd | _t|j	d | _	d S )N
date_inputz%Y/%m/%d)
r   r_   rH   r   rR   r   strptimer&  r   r'  r]   r   rM   rN   r_     s
   zDateInput.__init__r   r$  c                 C  r   r   r   r   rM   rM   rN   r     r   zDateInput.set_valuer'   c                 C  s2   t  }| j|_td }|| j|jjd d < |S r\   )r'   r   r   	serializerd   string_array_valuer   )r^   r   serderM   rM   rN   r     s
   zDateInput._widget_stater    c                 C  sH   t | jtst| j\}}|durt|S dS | jj}|sJ || j S )z0The value of the widget. (date or Tuple of date)N)r   r   rH   r"   r   rU   r   r   )r^   parsed_r   rM   rM   rN   rd   $  s   
zDateInput.value)rS   r%  rU   rT   rY   rZ   )r   r$  rY   r3   r   )rY   r    r   rM   rM   r   rN   r3     s    
 
r3   c                   @  sF   e Zd ZU ded< ded< ded< ded< dddZedddZdS )r6   rQ   messager   is_markdown	list[str]stack_trace
is_warningrS   ExceptionProtorU   rT   rY   rZ   c                 C  s0   d | _ || _|| _d| _|j| _t|j| _d S N	exception)rW   rU   rS   rR   message_is_markdownr1  listr3  r]   rM   rM   rN   r_   6  s   zException.__init__c                 C  s   | j S r\   )r0  rb   rM   rM   rN   rd   ?  s   zException.valueN)rS   r5  rU   rT   rY   rZ   rx   rI   rJ   rK   ry   r_   rz   rd   rM   rM   rM   rN   r6   /  s   
 
	r6   c                   @  sX   e Zd ZU eddZded< ded< ded< d	ed
< ded< dddZedddZdS )HeadingBaseFrO   HeadingProtorS   rQ   tagrV   anchorr   hide_anchorrZ   rW   rU   rT   type_rY   c                 C  s   || _ d | _|| _|| _d S r\   r  )r^   rS   rU   r@  rM   rM   rN   r_   M  r  zHeadingBase.__init__c                 C  r   r\   r   rb   rM   rM   rN   rd   S  r   zHeadingBase.valueN)rS   r<  rU   rT   r@  rQ   rY   rZ   rx   r   rM   rM   rM   rN   r;  D  s   
 
r;  c                      r   )
HeaderrS   r<  rU   rT   rY   rZ   c                      t  ||d d S Nheaderr   r_   r]   r   rM   rN   r_   Z     zHeader.__init__rS   r<  rU   rT   rY   rZ   r   rM   rM   r   rN   rA  X  r   rA  c                      r   )
	SubheaderrS   r<  rU   rT   rY   rZ   c                   rB  N	subheaderrE  r]   r   rM   rN   r_   `  rF  zSubheader.__init__rG  r   rM   rM   r   rN   rH  ^  r   rH  c                      r   )
TitlerS   r<  rU   rT   rY   rZ   c                   rB  NtitlerE  r]   r   rM   rN   r_   f  rF  zTitle.__init__rG  r   rM   rM   r   rN   rK  d  r   rK  c                   @  s@   e Zd ZU eddZded< ded< dddZedddZdS )r9   FrO   	JsonProtorS   r   expandedrU   rT   rY   rZ   c                 C  r  Njsonr  r]   rM   rM   rN   r_   p  r  zJson.__init__rQ   c                 C  r   r\   r   rb   rM   rM   rN   rd   v  r   z
Json.valueN)rS   rN  rU   rT   rY   rZ   rx   r   rM   rM   rM   rN   r9   j  s   
 
r9   c                   @  sP   e Zd ZU eddZded< ded< ded< ded	< dddZedddZdS )r%   FrO   MarkdownProtorS   r   
is_caption
allow_htmlrZ   rW   rU   rT   rY   c                 C  r  Nmarkdownr  r]   rM   rM   rN   r_     r  zMarkdown.__init__rQ   c                 C  r   r\   r   rb   rM   rM   rN   rd     r   zMarkdown.valueNrS   rR  rU   rT   rY   rZ   rx   r   rM   rM   rM   rN   r%   {  s   
 
r%   c                      r   )
CaptionrS   rR  rU   rT   rY   rZ   c                   r   Ncaptionr   r]   r   rM   rN   r_     r   zCaption.__init__rW  r   rM   rM   r   rN   rX    r   rX  c                      r   )
DividerrS   rR  rU   rT   rY   rZ   c                   r   Ndividerr   r]   r   rM   rN   r_     r   zDivider.__init__rW  r   rM   rM   r   rN   r[    r   r[  c                      r   )
LatexrS   rR  rU   rT   rY   rZ   c                   r   Nlatexr   r]   r   rM   rN   r_     r   zLatex.__init__rW  r   rM   rM   r   rN   r^    r   r^  c                   @  s:   e Zd ZU dZeddZded< dZded< dddZdS )r?   z)A representation of st.space for testing.FrO   
SpaceProtorS   NrZ   rW   rU   rT   rY   c                 C     || _ || _d| _d S )NspacerS   rU   rR   r]   rM   rM   rN   r_     r   zSpace.__init__)rS   ra  rU   rT   rY   rZ   )	rI   rJ   rK   rL   r	   rS   ry   rW   r_   rM   rM   rM   rN   r?     s
   
 r?   c                   @  sN   e Zd ZU ded< ded< ded< ded< ded< dddZedddZdS )r:   MetricProtorS   rQ   r   deltacolorr   rU   rT   rY   rZ   c                 C  r  Nmetricr  r]   rM   rM   rN   r_     r  zMetric.__init__c                 C  r   r\   r   rb   rM   rM   rN   rd     r   zMetric.valueN)rS   re  rU   rT   rY   rZ   rx   r:  rM   rM   rM   rN   r:     s   
 
r:   c                      s   e Zd ZU dZded< eddZded< ded	< d
ed< d' fddZed(ddZ	ed)ddZ
ed*ddZed+ddZd,d d!Zd-d#d$Zd-d%d&Z  ZS ).r/   zAA representation of button_group that is used by ``st.feedback``.list[T] | Noner   FrO   ButtonGroupProtorS   zlist[ButtonGroupProto.Option]optionsrQ   r   rU   rT   rY   rZ   c                   $   t  || d| _t|j| _d S Nbutton_groupr   r_   rR   r9  rl  r]   r   rM   rN   r_        zButtonGroup.__init__r'   c                 C  $   t  }| j|_| j|jjdd< |S r  N)r'   r   indicesint_array_valuer   r   rM   rM   rN   r        zButtonGroup._widget_statelist[T]c                 C  r   6The currently selected values from the options. (list)Nrw  r   r   rM   rM   rN   rd     r   zButtonGroup.valueSequence[int]c                       fdd j D S )EThe indices of the currently selected values from the options. (list)c                      g | ]} j  |qS rM   rl  indexformat_funcr   r   rb   rM   rN   r         z'ButtonGroup.indices.<locals>.<listcomp>r   rb   rM   rb   rN   rt       zButtonGroup.indicesCallable[[Any], Any]c                 C     | j j}td|t | j S zCThe widget's formatting function for displaying options. (callable)r  rU   r   r   r)   r   r^   ssrM   rM   rN   r       zButtonGroup.format_funcr   ButtonGroup[T]c                 C  r   z/Set the value of the multiselect widget. (list)r   r   rM   rM   rN   r        zButtonGroup.set_valuerG   c                 C  2   | j }||v r	| S | }|| | | | S z
        Add a selection to the widget. Do nothing if the value is already selected.        If testing a multiselect widget with repeated options, use ``set_value``        instead.
        rd   copyappendr   r^   r   currentnewrM   rM   rN   select     

zButtonGroup.selectc                 C  B   | j }||vr	| S | }||v r|| ||v s| | | S z
        Remove a selection from the widget. Do nothing if the value is not        already selected. If a value is selected multiple times, the first        instance is removed.
        rd   r  remover   r  rM   rM   rN   unselect     

zButtonGroup.unselect)rS   rk  rU   rT   rY   rZ   r   rY   rw  rY   rz  rY   r  )r   rw  rY   r  )r   rG   rY   r  )rI   rJ   rK   rL   ry   r	   rS   r_   rz   r   rd   rt  r  r   r  r  r   rM   rM   r   rN   r/     s$   
 


r/   c                      s   e Zd ZU dZded< eddZded< ded	< d
ed< ded< ded< ded< d. fddZed/ddZ	ed0ddZ
ed1ddZed2d d!Zed3d#d$Zd4d'd(Zd5d*d+Zd5d,d-Z  ZS )6Multiselectz'A representation of ``st.multiselect``.rj  r   FrO   MultiSelectProtorS   rQ   r   r2  rl  r   max_selectionsr   r   rU   rT   rY   rZ   c                   rm  Nmultiselectrp  r]   r   rM   rN   r_   #  rq  zMultiselect.__init__r'   c                 C  rr  rs  )r'   r   r   r,  r   r   rM   rM   rN   r   (  rv  zMultiselect._widget_staterw  c                 C  r   rx  r   r   rM   rM   rN   rd   3  r   zMultiselect.valuerz  c                   r{  )r|  c                   r}  rM   r~  r  rb   rM   rN   r   ?  r  z'Multiselect.indices.<locals>.<listcomp>r   rb   rM   rb   rN   rt  <  r  zMultiselect.indicesSequence[str]c                   r{  )ry  c                      g | ]}  |qS rM   r  r  rb   rM   rN   r   D      z&Multiselect.values.<locals>.<listcomp>r   rb   rM   rb   rN   r   A  r  zMultiselect.valuesr  c                 C  r  r  r  r  rM   rM   rN   r  F  r  zMultiselect.format_funcr   Multiselect[T]c                 C  r   r  r   r   rM   rM   rN   r   L  r  zMultiselect.set_valuerG   c                 C  r  r  r  r  rM   rM   rN   r  R  r  zMultiselect.selectc                 C  r  r  r  r  rM   rM   rN   r  `  r  zMultiselect.unselect)rS   r  rU   rT   rY   rZ   r   r  r  )rY   r  r  )r   rw  rY   r  )r   rG   rY   r  )rI   rJ   rK   rL   ry   r	   rS   r_   rz   r   rd   rt  r   r  r   r  r  r   rM   rM   r   rN   r    s.   
 


r  Numberc                      s   e Zd ZU dZded< eddZded< ded	< d
ed< d
ed< ded< ded< ded< d# fddZd$ddZe	d%ddZ
e	d&ddZd'dd Zd'd!d"Z  ZS )(r<   z(A representation of ``st.number_input``.zNumber | None | InitialValuer   FrO   NumberInputProtorS   rQ   r   Number | Noner&  r'  r  stepr   r   rU   rT   rY   rZ   c                   sJ   t  || t | _d| _|jr|jnd | _|jr |j| _d S d | _d S Nnumber_input)	r   r_   rH   r   rR   has_minr&  has_maxr'  r]   r   rM   rN   r_     s
   zNumberInput.__init__r   c                 C  r   )z0Set the value of the ``st.number_input`` widget.r   r   rM   rM   rN   r     r   zNumberInput.set_valuer'   c                 C  $   t  }| j|_| jd ur| j|_|S r\   )r'   r   rd   double_valuer   rM   rM   rN   r     
   
zNumberInput._widget_statec                 C  ,   t | jts	| jS | jj}|sJ || j S )z8Get the current value of the ``st.number_input`` widget.r   r   rH   rU   r   r   r   rM   rM   rN   rd     s
   
zNumberInput.valuec                 C  s4   | j du r| S t| j | j | jptd}| |S )zDIncrement the ``st.number_input`` widget as if the user clicked "+".Ninf)rd   r&  r  r'  floatr   r   rM   rM   rN   	increment     

zNumberInput.incrementc                 C  s4   | j du r| S t| j | j | jptd}| |S )zDDecrement the ``st.number_input`` widget as if the user clicked "-".Nz-inf)rd   r'  r  r&  r  r   r   rM   rM   rN   	decrement  r  zNumberInput.decrement)rS   r  rU   rT   rY   rZ   )r   r  rY   r<   r   )rY   r  )rY   r<   rI   rJ   rK   rL   ry   r	   rS   r_   r   rz   r   rd   r  r  r   rM   rM   r   rN   r<   s  s$   
 


r<   c                      s   e Zd ZU dZded< eddZded< ded	< d
ed< ded< ded< ded< d& fddZed'ddZ	ed(ddZ
ed)ddZd*d!d"Zed+d$d%Z  ZS ),r=   z!A representation of ``st.radio``.T | None | InitialValuer   FrO   
RadioProtorS   rQ   r   r2  rl  r   
horizontalr   r   rU   rT   rY   rZ   c                   ,   t  || t | _d| _t|j| _d S Nradior   r_   rH   r   rR   r9  rl  r]   r   rM   rN   r_        zRadio.__init__
int | Nonec                 C  s"   | j du rdS | j| | j S ))The index of the current selection. (int)N)rd   rl  r  r  rb   rM   rM   rN   r    s   
zRadio.indexT | Nonec                 C  2   t | jts	| jS | jj}|sJ td|| j S z4The currently selected value from the options. (Any)rG   r   r   rH   rU   r   r   r   r   rM   rM   rN   rd     
   zRadio.valuer  c                 C  r  r  r  r  rM   rM   rN   r    r  zRadio.format_funcr   Radio[T]c                 C  r   zSet the selection by value.r   r   rM   rM   rN   r     r   zRadio.set_valuer'   c                 C  s$   t  }| j|_| jdur| j|_|S rs  )r'   r   r  	int_valuer   rM   rM   rN   r     s
   
zRadio._widget_state)rS   r  rU   rT   rY   rZ   rY   r  rY   r  r  )r   r  rY   r  r   )rI   rJ   rK   rL   ry   r	   rS   r_   rz   r  rd   r  r   r   r   rM   rM   r   rN   r=     s&   
 
r=   c                      s   e Zd ZU dZded< eddZded< ded	< d
ed< ded< ded< d) fddZed*ddZ	ed+ddZ
ed,ddZd-dd Zd-d!d"Zd.d$d%Zed/d'd(Z  ZS )0r>   z%A representation of ``st.selectbox``.r  r   FrO   SelectboxProtorS   rQ   r   r2  rl  r   r   rU   rT   rY   rZ   c                   r  N	selectboxr  r]   r   rM   rN   r_     r  zSelectbox.__init__r  c                 C  s4   | j du rdS t| jdkrdS | j| | j S )r  Nr   )rd   r   rl  r  r  rb   rM   rM   rN   r    s
   
zSelectbox.indexr  c                 C  r  r  r  r   rM   rM   rN   rd     r  zSelectbox.valuer  c                 C  r  r  r  r  rM   rM   rN   r    r  zSelectbox.format_funcr   Selectbox[T]c                 C  r   r  r   r   rM   rM   rN   r     r   zSelectbox.set_valuec                 C  s
   |  |S r  r   r   rM   rM   rN   r    r   zSelectbox.selectr  c                 C  s(   |du r	|  dS |  td| j| S )zSet the selection by index.NrG   )r   r   rl  )r^   r  rM   rM   rN   select_index  s   
zSelectbox.select_indexr'   c                 C  s8   t  }| j|_| jdurt| jdkr| j| j |_|S )r  Nr   )r'   r   r  r   rl  r  r   rM   rM   rN   r   %  s
   zSelectbox._widget_state)rS   r  rU   rT   rY   rZ   r  r  r  )r   r  rY   r  )r  r  rY   r  r   )rI   rJ   rK   rL   ry   r	   rS   r_   rz   r  rd   r  r   r  r  r   r   rM   rM   r   rN   r>     s(   
 	


r>   c                      s   e Zd ZU dZded< eddZded< ded	< d
ed< ded< ded< ded< d( fddZd)ddZe	d*ddZ
e	d+ddZe	d,d!d"Zd-d&d'Z  ZS ).SelectSliderz)A representation of ``st.select_slider``.zT | Sequence[T] | Noner   FrO   SliderProtorS   rQ   r   SliderProto.DataType.ValueType	data_typer2  rl  r   r   rU   rT   rY   rZ   c                   rm  Nselect_sliderrp  r]   r   rM   rN   r_   ?  rq  zSelectSlider.__init__r   T | Sequence[T]SelectSlider[T]c                 C  r   )z$Set the (single) selection by value.r   r   rM   rM   rN   r   D  r   zSelectSlider.set_valuer'   c              	     s   t  jg d}z|  j}W n& ttfy8   z| fdd jD }W n   td j Y nw t } j|_||j	j
d d < |S )NFc                   r  rM   r  )r   valrb   rM   rN   r   P  r  z.SelectSlider._widget_state.<locals>.<listcomp>zCould not find index for )r   rl  r+  r  rd   r   	TypeErrorr'   r   double_array_valuer   )r^   r-  r   r   rM   rb   rN   r   I  s   zSelectSlider._widget_statec                 C  *   | j dur| j S | jj}|sJ || j S z?The currently selected value or range. (Any or Sequence of Any)Nr   rU   r   r   r   rM   rM   rN   rd   Y  
   

zSelectSlider.valuer  c                 C  r  r  r  r  rM   rM   rN   r  c  r  zSelectSlider.format_funclowerrG   upperc                 C     |  ||gS )z#Set the ranged selection by values.r   r^   r  r  rM   rM   rN   	set_rangei  r   zSelectSlider.set_rangerS   r  rU   rT   rY   rZ   )r   r  rY   r  r   )rY   r  r  )r  rG   r  rG   rY   r  )rI   rJ   rK   rL   ry   r	   rS   r_   r   rz   r   rd   r  r  r   rM   rM   r   rN   r  2  s$   
 
	r  SliderValueTc                      s   e Zd ZU dZded< eddZded< ded	< d
ed< ded< ded< ded< ded< ded< d' fddZd(ddZe	d)dd Z
e	d*d!d"Zd+d%d&Z  ZS ),r&   z"A representation of ``st.slider``.z,SliderValueT | Sequence[SliderValueT] | Noner   FrO   r  rS   rQ   r   r  r  r  r&  r'  r   r  r   r   rU   rT   rY   rZ   c                   r   Nsliderr   r]   r   rM   rN   r_     r   zSlider.__init__r   %SliderValueT | Sequence[SliderValueT]Slider[SliderValueT]c                 C  r   )z%Set the (single) value of the slider.r   r   rM   rM   rN   r     s   zSlider.set_valuer'   c                 C  sD   | j j}tg |dd }|| j}t }| j|_||jjd d < |S )NT)	rS   r  r   r+  rd   r'   r   r  r   )r^   r  r-  r   r   rM   rM   rN   r     s   zSlider._widget_statec                 C  r  r  r  r   rM   rM   rN   rd     r  zSlider.valuer  r  c                 C  r  )z#Set the ranged value of the slider.r   r  rM   rM   rN   r    s   zSlider.set_ranger  )r   r  rY   r  r   )rY   r  )r  r  r  r  rY   r  )rI   rJ   rK   rL   ry   r	   rS   r_   r   rz   r   rd   r  r   rM   rM   r   rN   r&   q  s$   
 

	r&   c                   @  r  )TableFrO   r  rS   rU   rT   rY   rZ   c                 C  r  Narrow_tabler  r]   rM   rM   rN   r_     r  zTable.__init__r  c                 C  r  r\   r  rb   rM   rM   rN   rd     r   zTable.valueNr   r!  r   rM   rM   rM   rN   r    r"  r  c                   @  sD   e Zd ZU eddZded< dZded< dddZedddZ	dS )r@   FrO   	TextProtorS   NrZ   rW   rU   rT   rY   c                 C  rb  Ntextrd  r]   rM   rM   rN   r_     r   zText.__init__rQ   c                 C  r   r	  r   rb   rM   rM   rN   rd     r  z
Text.value)rS   r  rU   rT   rY   rZ   rx   )
rI   rJ   rK   r	   rS   ry   rW   r_   rz   rd   rM   rM   rM   rN   r@     s   
 
r@   c                      s   e Zd ZU dZded< eddZded< ded	< d
ed< ded< ded< ded< d  fddZd!ddZe	d"ddZ
e	d#ddZd$ddZ  ZS )%rA   z%A representation of ``st.text_area``.str | None | InitialValuer   FrO   TextAreaProtorS   rQ   r   r   	max_charsr   r   r   rU   rT   rY   rZ   c                       t  || t | _d| _d S N	text_arear   r_   rH   r   rR   r]   r   rM   rN   r_        
zTextArea.__init__r   rV   c                 C  r   r   r   r   rM   rM   rN   r     r   zTextArea.set_valuer'   c                 C  r  r\   r  r   rM   rM   rN   r     r  zTextArea._widget_statec                 C  r  z&The current value of the widget. (str)r  r   rM   rM   rN   rd     
   
zTextArea.valuec                 C  "   | j rt|| j kr| S | |S zv
        Set the value of the widget only if the value does not exceed the        maximum allowed characters.
        r  r   r   r   rM   rM   rN   input     
zTextArea.input)rS   r  rU   rT   rY   rZ   )r   rV   rY   rA   r   r   )r   rQ   rY   rA   rI   rJ   rK   rL   ry   r	   rS   r_   r   rz   r   rd   r  r   rM   rM   r   rN   rA     s    
 
	rA   c                      s   e Zd ZU dZded< eddZded< ded	< d
ed< ded< ded< ded< ded< d! fddZd"ddZe	d#ddZ
e	d$ddZd%dd Z  ZS )&rB   z&A representation of ``st.text_input``.r  r   FrO   TextInputProtorS   rQ   r   r   r  autocompleter   r   r   rU   rT   rY   rZ   c                   r  N
text_inputr  r]   r   rM   rN   r_     r  zTextInput.__init__r   rV   c                 C  r   r   r   r   rM   rM   rN   r     r   zTextInput.set_valuer'   c                 C  r  r\   r  r   rM   rM   rN   r     r  zTextInput._widget_statec                 C  r  r  r  r   rM   rM   rN   rd     r   zTextInput.valuec                 C  r  r  r  r   rM   rM   rN   r  $  r  zTextInput.input)rS   r  rU   rT   rY   rZ   )r   rV   rY   rB   r   r   )r   rQ   rY   rB   r  rM   rM   r   rN   rB     s"   
 
	rB   	TimeValueDateTimeWidgetValuec                      s   e Zd ZU dZded< eddZded< ded	< d
ed< ded< ded< d" fddZd#ddZe	d$ddZ
e	d%ddZd&ddZd&d d!Z  ZS )'rC   z&A representation of ``st.time_input``.zTimeValue | None | InitialValuer   FrO   TimeInputProtorS   rQ   r   r   r  r   r   rU   rT   rY   rZ   c                   r  N
time_inputr  r]   r   rM   rN   r_   >  r  zTimeInput.__init__r   TimeValue | Nonec                 C  r   r   r   r   rM   rM   rN   r   C  r   zTimeInput.set_valuer'   c                 C  s4   t  }| j|_td }|| j}|d ur||_|S r\   )r'   r   r!   r+  rd   r  )r^   r   r-  serialized_valuerM   rM   rN   r   H  s   zTimeInput._widget_statetime | Nonec                 C  sB   t | jts| j}t |tr| S |S | jj}|sJ || j S )z'The current value of the widget. (time))r   r   rH   r   r   rU   r   r   )r^   r   r   rM   rM   rN   rd   S  s   
zTimeInput.valuec                 C  s:   | j du r| S tt | j t| jd }| | S )zSelect the next available time.Nseconds	rd   r   combiner   todayr   r  r   r   r^   dtrM   rM   rN   r  ]     
zTimeInput.incrementc                 C  s:   | j du r| S tt | j t| jd }| | S )z#Select the previous available time.Nr  r  r  rM   rM   rN   r  d  r  zTimeInput.decrement)rS   r  rU   rT   rY   rZ   )r   r  rY   rC   r   )rY   r  )rY   rC   r  rM   rM   r   rN   rC   3  s    
 


	rC   c                      s   e Zd ZU dZded< eddZded< ded	< ded
< ded< ded< ded< ded< ded< d! fddZd"ddZe	d#ddZ
e	d$dd Z  ZS )%r4   z*A representation of ``st.datetime_input``.z)DateTimeWidgetValue | None | InitialValuer   FrO   DateTimeInputProtorS   rQ   r   formatr&  r'  r   r  r   r   rU   rT   rY   rZ   c                   r  Ndate_time_inputr  r]   r   rM   rN   r_   z  r  zDateTimeInput.__init__r   DateTimeWidgetValue | Nonec                 C  r   r   r   r   rM   rM   rN   r     r   zDateTimeInput.set_valuer'   c                 C  sp   ddl m } d}t }| j|_|| j|}|| j|}td ||d}|| j}|d ur6||j	j
d d < |S )Nr   )r   z%Y/%m/%d, %H:%M)rd   r&  r'  )r   r'   r   r*  r&  r'  r   r+  rd   r,  r   )r^   r   datetime_ui_formatr   min_dtmax_dtr-  r  rM   rM   rN   r     s   zDateTimeInput._widget_statedatetime | Nonec                 C  r  )z+The current value of the widget. (datetime)r  r   rM   rM   rN   rd     s
   
zDateTimeInput.value)rS   r  rU   rT   rY   rZ   )r   r  rY   r4   r   )rY   r#  r   rM   rM   r   rN   r4   l  s"   
 
r4   c                   @  r   )rD   FrO   
ToastProtorS   rQ   r   rU   rT   rY   rZ   c                 C  r  Ntoastr  r]   rM   rM   rN   r_     r  zToast.__init__c                 C  r   r\   r   rb   rM   rM   rN   rd     r   zToast.valueN)rS   r$  rU   rT   rY   rZ   rx   r   rM   rM   rM   rN   rD     s   
 
rD   c                      s|   e Zd ZU dZded< eddZded< ded	< ded
< ded< d fddZedddZ	edddZ
dddZ  ZS )Togglez"A representation of ``st.toggle``.r   r   FrO   r   rS   rQ   r   r   r   rU   rT   rY   rZ   c                   s   t  || d | _d| _d S Ntoggler   r]   r   rM   rN   r_     r   zToggle.__init__r'   c                 C  r   r\   r   r   rM   rM   rN   r     r   zToggle._widget_stater   c                 C  r   )z'The current value of the widget. (bool)Nr   r   r   rM   rM   rN   rd     r   zToggle.valuer   c                 C  r   r   r   r   rM   rM   rN   r     r   zToggle.set_valuer   r   r   )r   r   rY   r'  )rI   rJ   rK   rL   ry   r	   rS   r_   rz   r   rd   r   r   rM   rM   r   rN   r'    s   
 r'  c                   @  s  e Zd ZU dZded< ded< eddZded	< eddZd
ed< dddZdddZ	dddZ
dddZedddZeddd Zedd"d#Zedd%d&Zedd(d)Zedd+d,Zedd.d/Zedd1d2Zedd4d5Zedd7d8Zedd:d;Zedd=d>Zedd@dAZeddCdDZeddFdGZeddIdJZeddLdMZeddOdPZeddRdSZeddUdVZ eddXdYZ!edd[d\Z"edd^d_Z#eddadbZ$eddddeZ%eddgdhZ&eddjdkZ'eddmdnZ(eddpdqZ)eddsdtZ*eddvdwZ+eddydzZ,edd|d}Z-edddZ.edddZ/edddZ0edddZ1edddZ2edddZ3edddZ4edddZ5edddZ6dddZ7dddddZ8dddZ9dS )r-   ad  A container of other elements.

    Elements within a Block can be inspected and interacted with. This follows
    the same syntax as inspecting and interacting within an ``AppTest`` object.

    For all container classes, parameters of the original element can be
    obtained as properties. For example, ``ChatMessage.avatar`` and
    ``Tab.label``.
    rQ   rR   zdict[int, Node]childrenFrO   r   rS   rT   rU   BlockProto | NonerY   rZ   c                 C  sB   i | _ || _|r|d}|d ur|| _nd| _nd| _|| _d S )NrR   	containerunknown)r*  rS   r|   rR   rU   r}   rM   rM   rN   r_     s   

zBlock.__init__r   c                 C  r   r\   )r   r*  rb   rM   rM   rN   r     rt   zBlock.__len__Iterator[Node]c                 c  s(    | V  | j D ]
}| j | E d H  qd S r\   r*  )r^   	child_idxrM   rM   rN   rc     s
   
zBlock.__iter__kNodec                 C  s
   | j | S r\   r/  )r^   r1  rM   rM   rN   r     rt   zBlock.__getitem__rV   c                 C  r[   r\   rM   rb   rM   rM   rN   rW     r   z	Block.keyWidgetList[Button]c                 C     t | dS )Nr   r   getrb   rM   rM   rN   r     r   zBlock.buttonWidgetList[ButtonGroup[Any]]c                 C  r4  rn  r5  rb   rM   rM   rN   ro    r   zBlock.button_groupElementList[Caption]c                 C  r4  rY  r   r6  rb   rM   rM   rN   rZ    r   zBlock.captionWidgetList[ChatInput]c                 C  r4  r   r5  rb   rM   rM   rN   r     r   zBlock.chat_inputSequence[ChatMessage]c                 C  r   Nchat_messager6  rb   rM   rM   rN   r=    r   zBlock.chat_messageWidgetList[Checkbox]c                 C  r4  r   r5  rb   rM   rM   rN   r     r   zBlock.checkboxElementList[Code]c                 C  r4  r  r9  rb   rM   rM   rN   r  #  r   z
Block.codeWidgetList[ColorPicker]c                 C  r4  r  r5  rb   rM   rM   rN   r  '  r   zBlock.color_pickerSequence[Column]c                 C  r   Ncolumnr>  rb   rM   rM   rN   columns+  r   zBlock.columnsElementList[Dataframe]c                 C  r4  r  r9  rb   rM   rM   rN   	dataframe/  r   zBlock.dataframeWidgetList[DateInput]c                 C  r4  )Nr)  r5  rb   rM   rM   rN   r)  3  r   zBlock.date_inputWidgetList[DateTimeInput]c                 C  r4  r  r5  rb   rM   rM   rN   datetime_input7  r   zBlock.datetime_inputElementList[Divider]c                 C  r4  r\  r9  rb   rM   rM   rN   r]  ;  r   zBlock.dividerElementList[Error]c                 C  r4  r   r9  rb   rM   rM   rN   r   ?  r   zBlock.errorElementList[Exception]c                 C  r4  r6  r9  rb   rM   rM   rN   r7  C  r   zBlock.exceptionSequence[Expander]c                 C  r   Nexpanderr>  rb   rM   rM   rN   rP  G  r   zBlock.expanderElementList[Header]c                 C  r4  rC  r9  rb   rM   rM   rN   rD  K  r   zBlock.headerElementList[Info]c                 C  r4  r   r9  rb   rM   rM   rN   r   O  r   z
Block.infoElementList[Json]c                 C  r4  rP  r9  rb   rM   rM   rN   rQ  S  r   z
Block.jsonElementList[Latex]c                 C  r4  r_  r9  rb   rM   rM   rN   r`  W  r   zBlock.latexElementList[Markdown]c                 C  r4  rU  r9  rb   rM   rM   rN   rV  [  r   zBlock.markdownElementList[Metric]c                 C  r4  rh  r9  rb   rM   rM   rN   ri  _  r   zBlock.metricWidgetList[Multiselect[Any]]c                 C  r4  r  r5  rb   rM   rM   rN   r  c  r   zBlock.multiselectWidgetList[NumberInput]c                 C  r4  r  r5  rb   rM   rM   rN   r  g  r   zBlock.number_inputWidgetList[Radio[Any]]c                 C  r4  r  r5  rb   rM   rM   rN   r  k  r   zBlock.radioWidgetList[SelectSlider[Any]]c                 C  r4  r  r5  rb   rM   rM   rN   r  o  r   zBlock.select_sliderWidgetList[Selectbox[Any]]c                 C  r4  r  r5  rb   rM   rM   rN   r  s  r   zBlock.selectboxWidgetList[Slider[Any]]c                 C  r4  r  r5  rb   rM   rM   rN   r  w  r   zBlock.sliderSequence[Status]c                 C  r   Nstatusr>  rb   rM   rM   rN   r_  {  r   zBlock.statusElementList[Subheader]c                 C  r4  rI  r9  rb   rM   rM   rN   rJ    r   zBlock.subheaderElementList[Success]c                 C  r4  r   r9  rb   rM   rM   rN   r     r   zBlock.successElementList[Table]c                 C  r4  r  r9  rb   rM   rM   rN   table  r   zBlock.tableSequence[Tab]c                 C  r   Ntabr>  rb   rM   rM   rN   tabs  r   z
Block.tabsElementList[Text]c                 C  r4  r  r9  rb   rM   rM   rN   r    r   z
Block.textWidgetList[TextArea]c                 C  r4  r  r5  rb   rM   rM   rN   r    r   zBlock.text_areaWidgetList[TextInput]c                 C  r4  r	  r5  rb   rM   rM   rN   r
    r   zBlock.text_inputWidgetList[TimeInput]c                 C  r4  r  r5  rb   rM   rM   rN   r    r   zBlock.time_inputElementList[Title]c                 C  r4  rL  r9  rb   rM   rM   rN   rM    r   zBlock.titleElementList[Toast]c                 C  r4  r%  r9  rb   rM   rM   rN   r&    r   zBlock.toastWidgetList[Toggle]c                 C  r4  r(  r5  rb   rM   rM   rN   r)    r   zBlock.toggleElementList[Warning]c                 C  r4  r   r9  rb   rM   rM   rN   r     r   zBlock.warningelement_typeSequence[Node]c                   s    fdd| D S )Nc                   s   g | ]	}|j  kr|qS rM   )rR   r   rp  rM   rN   r     s    zBlock.get.<locals>.<listcomp>rM   )r^   rp  rM   rr  rN   r6    s   z	Block.getNrh   ri   rj   rF   c                C  rk   )Run the script with updated widget values.

        Parameters
        ----------
        timeout
            The maximum number of seconds to run the script. None means
            use the AppTest's default.
        rh   rl   rn   rM   rM   rN   rm     ro   z	Block.runc                 C  r   r\   )rr   rb   rM   rM   rN   rs     s   zBlock.__repr__)rS   r+  rU   rT   rY   rZ   r   )rY   r.  )r1  r   rY   r2  r   )rY   r3  )rY   r7  )rY   r8  )rY   r:  )rY   r;  )rY   r?  )rY   r@  )rY   rA  )rY   rB  )rY   rF  )rY   rH  )rY   rI  )rY   rK  )rY   rL  )rY   rM  )rY   rN  )rY   rQ  )rY   rR  )rY   rS  )rY   rT  )rY   rU  )rY   rV  )rY   rW  )rY   rX  )rY   rY  )rY   rZ  )rY   r[  )rY   r\  )rY   r]  )rY   r`  )rY   ra  )rY   rb  )rY   rd  )rY   rh  )rY   ri  )rY   rj  )rY   rk  )rY   rl  )rY   rm  )rY   rn  )rY   ro  )rp  rQ   rY   rq  rw   rx   ):rI   rJ   rK   rL   ry   r	   rS   rU   r_   r   rc   r   rz   rW   r   ro  rZ  r   r=  r   r  r  rE  rG  r)  rJ  r]  r   r7  rP  rD  r   rQ  r`  rV  ri  r  r  r  r  r  r  r_  rJ  r   rc  rg  r  r  r
  r  rM  r&  r)  r   r6  rm   rs   rM   rM   rM   rN   r-     s   
 





r-   r^   objectrY   rQ   c                   s   j j}dddg t i g tr fddtD }n fddj D }g }|D ]\}}t|tr@| dt	| n| d|}|
| q.d|d	  |d	< d
|}t|d}| d| dS )ziA custom repr similar to `streamlit.util.repr_` but that shows tree
    structure using indentation.
    N Fc                 3  sJ    | ] }|j r"t|j|jkr"t|j vr|jt|jfV  qd S r\   )rP   rf   re   default)r   fdefaultsr^   rM   rN   	<genexpr>  s    zrepr_.<locals>.<genexpr>c                 3  s$    | ]\}}| vr||fV  qd S r\   rM   )r   rw  r   )ry  rM   rN   rz    s   " =
r   ,
    (z
))r   rI   setr   r
   __dict__itemsr   dictformat_dictr  jointextwrapindent)r^   	classnamefields_valsreprs
field_namerd   linefield_reprsrM   rx  rN   rr     s$   
rr   ddict[Any, Any]c                 C  sP   g }|   D ]\}}| d|}|| qd|}t|d}d| dS )Nz: r}  r~  z{
z
})r  r  r  r  r  )r  linesr1  r   r  rrM   rM   rN   r    s   
r  c                   @  s   e Zd ZdZ	ddddZdS )SpecialBlockz4Base class for the sidebar and main body containers.NrS   r+  rU   rT   rR   rV   rY   rZ   c                 C  sT   i | _ || _|r|| _n|r"|dr"|d}|d usJ || _nd| _|| _d S )NrR   r-  )r*  rS   rR   r|   rU   )r^   rS   rU   rR   r~   rM   rM   rN   r_     s   

zSpecialBlock.__init__r\   )rS   r+  rU   rT   rR   rV   rY   rZ   )rI   rJ   rK   rL   r_   rM   rM   rM   rN   r    s    r  c                   @  sP   e Zd ZU dZeddZded< eddZded< ded< ded	< dddZdS )ChatMessagez(A representation of ``st.chat_message``.FrO   rQ   rR   BlockProto.ChatMessagerS   re   avatarrU   rT   rY   rZ   c                 C  ,   i | _ || _|| _d| _|j| _|j| _d S r<  )r*  rS   rU   rR   re   r  r]   rM   rM   rN   r_        zChatMessage.__init__N)rS   r  rU   rT   rY   rZ   	rI   rJ   rK   rL   r	   rR   ry   rS   r_   rM   rM   rM   rN   r       
 r  c                   @  sP   e Zd ZU dZeddZded< eddZded< ded	< ded
< dddZdS )Columnz3A representation of a column within ``st.columns``.FrO   rQ   rR   BlockProto.ColumnrS   r  weightgaprU   rT   rY   rZ   c                 C  r  rC  )r*  rS   rU   rR   r  r  r]   rM   rM   rN   r_   $  r  zColumn.__init__N)rS   r  rU   rT   rY   rZ   r  rM   rM   rM   rN   r    r  r  c                   @  sL   e Zd ZU eddZded< eddZded< ded< ded< dddZdS )ExpanderFrO   rQ   rR   BlockProto.ExpandablerS   r   r   rU   rT   rY   rZ   c                 C  r  rO  r*  rS   rU   rR   r   r   r]   rM   rM   rN   r_   8  s   zExpander.__init__NrS   r  rU   rT   rY   rZ   )rI   rJ   rK   r	   rR   ry   rS   r_   rM   rM   rM   rN   r  1  s   
 r  c                   @  sZ   e Zd ZU eddZded< eddZded< ded< ded< dddZedddZ	dS )StatusFrO   rQ   rR   r  rS   r   r   rU   rT   rY   rZ   c                 C  r  r^  r  r]   rM   rM   rN   r_   J  s   zStatus.__init__c                 C  s2   | j dkrdS | j dkrdS | j dkrdS td)Nspinnerrunningz:material/check:completez:material/error:r   zUnknown Status state)r   r   rb   rM   rM   rN   r   R  s   


zStatus.stateNr  rx   )
rI   rJ   rK   r	   rR   ry   rS   r_   rz   r   rM   rM   rM   rN   r  C  s   
 
r  c                   @  sH   e Zd ZU dZeddZded< eddZded< ded< dddZdS )Tabz+A representation of tab within ``st.tabs``.FrO   rQ   rR   BlockProto.TabrS   r   rU   rT   rY   rZ   c                 C  s$   i | _ || _|| _d| _|j| _d S re  )r*  rS   rU   rR   r   r]   rM   rM   rN   r_   e  s
   zTab.__init__N)rS   r  rU   rT   rY   rZ   r  rM   rM   rM   rN   r  ]  s   
 r  r2  nodeWidgetState | Nonec                 C  s   t | tr| jS d S r\   )r   r   r   )r  rM   rM   rN   get_widget_statet  s   
r  c                   @  s~   e Zd ZU dZedddZded< dd	d
Zed ddZ	ed ddZ
ed!ddZd"ddZddd#ddZd$ddZdS )%rT   ax  A tree of the elements produced by running a streamlit script.

    Elements can be queried in three ways:
    - By element type, using `.foo` properties to get a list of all of that element,
    in the order they appear in the app
    - By user key, for widgets, by calling the above list with a key: `.foo(key='bar')`
    - Positionally, using list indexing syntax (`[...]`) to access a child of a
    block element. Not recommended because the exact tree structure can be surprising.

    Element queries made on a block container will return only the elements
    descending from that block.

    Returned elements have methods for accessing whatever attributes are relevant.
    For very simple elements this may be only its value, while complex elements
    like widgets have many.

    Widgets provide a fluent API for faking frontend interaction and rerunning
    the script with the new widget values. All widgets provide a low level `set_value`
    method, along with higher level methods specific to that type of widget.
    After an interaction, calling `.run()` will update the AppTest with the
    results of that script run.
    FN)rP   rv  zAppTest | None_runnerrY   rZ   c                 C  s   i | _ | | _d| _d S )NrU   )r*  rU   rR   rb   rM   rM   rN   r_     r   zElementTree.__init__r-   c                 C     | d }t |tsJ |S )Nr   r   r-   )r^   mrM   rM   rN   main     zElementTree.mainc                 C  r  )N   r  )r^   srM   rM   rN   sidebar  r  zElementTree.sidebarrE   c                 C  s   | j d usJ | j jS r\   )r  r   rb   rM   rM   rN   r     s   zElementTree.session_stater(   c                 C  s0   t  }| D ]}t|}|d ur|j| q|S r\   )r(   r  widgetsr  )r^   r   r  wrM   rM   rN   get_widget_states  s   zElementTree.get_widget_statesrh   ri   rj   rF   c                C  s&   | j dusJ |  }| j j||dS )rs  Nrh   )r  r  _run)r^   ri   widget_statesrM   rM   rN   rm     s   	zElementTree.runrQ   c                 C  r   r\   )r  r*  rb   rM   rM   rN   rs     rt   zElementTree.__repr__)rY   rZ   )rY   r-   )rY   rE   )rY   r(   rw   rx   )rI   rJ   rK   rL   r	   r  ry   r_   rz   r  r  r   r  rm   rs   rM   rM   rM   rN   rT   z  s   
 

	rT   messageslist[ForwardMsg]c                 C  sl  t  }td|ddtd|ddtd|ddd|_| D ]}|ds$q|jj}|j}|dd	kr|j}|d}|d
kr|j	j
}|tjjkrRt|j	|d}n|tjjkrat|j	|d}n|tjjkrpt|j	|d}nx|tjjkrt|j	|d}nitd|j	j
 |dkrt|j|d}nS|dkrt|j|d}nF|dkrt|j|d}n9|dkrt|j|d}n,|dkrt|j|d}n|dkr|j j!}	|	t"j#j$krt%|j |d}nt&|j |d}n|dkrt'|j(|d}n|dkrt)|j*|d}n|dkrt+|j,|d}n|dkr t-|j.|d}n|dkr.t/|j0|d}n|dkrr|j1j2t3j4j5krEt6|j1|d}n|j1j2t3j7j5krWt8|j1|d}n|j1j2t3j9j5krit:|j1|d}ntd|j1j2 |dkrt;|j<|d}nh|dkr|j=j>t?j@jAkrtB|j=|d}nQ|j=j>t?j@jCkrtD|j=|d}n?|j=j>t?j@jEkrtF|j=|d}n-|j=j>t?j@jGkrtH|j=|d}ntd|j=j> |dkrtI|jJ|d}n|dkrtK|jL|d}n|dkrtM|jN|d}n|d krtO|jP|d}n|d!krtQ|jR|d}n|d"krG|jSj!tTj@jUkr.tV|jS|d}n|jSj!tTj@jWkr?tX|jS|d}ntd#|jS |d$krTtY|jZ|d}n|d%krat[|j\|d}n|d&krnt]|j^|d}nz|d'kr{t_|j`|d}nm|d(krta|jb|d}n`tc||d}nY|dd)kr|jd}
|
d}|d*krte|
jf|d}n<|d+krtg|
jh|d}n/|d,kr|
jijjrtk|
ji|d}ntl|
ji|d}n|d-krtm|
jn|d}nto|
|d.}nq|}|dd/ D ]$}|j}|p|}|du r	tod|d.}|||< tq|tosJ |}qtq|tor,|jp|d/ }|dur,|j|_||j|d/ < q|S )0zTransform a list of `ForwardMsg` into a tree matching the implicit
    tree structure of blocks and elements in a streamlit app.

    Returns the root of the tree, which acts as the entrypoint for the query
    and interaction API.
    r  N)rR   rU   rS   r  event)r   r     rf  rR   new_elementalert)rU   zUnknown alert type with format r  r  r   ro  r   r   r  r  r)  r  r7  headingzUnknown heading type with tag rQ  rV  zUnknown markdown type ri  r  r  r  r  r  zSlider with unknown type r  r  r
  r  r&  	add_blockr=  rD  
expandablerf  )rS   rU   )rrT   r  r*  HasFieldmetadata
delta_pathrf  r|   r  r  r  r   FormatERRORr   INFOr   SUCCESSr   WARNINGr   r   r  r  r  r  r.   r   r/   ro  r0   r   r   rR   r   	StyleTypeTOGGLEr'  r$   r1   r  r2   r  r3   r)  r4   r  r6   r7  r  r=  r   	TITLE_TAGrd   rK  
HEADER_TAGrA  SUBHEADER_TAGrH  r9   rQ  rV  rp  rR  TypeNATIVEr%   CAPTIONrX  LATEXr^  DIVIDERr[  r:   ri  r  r  r<   r  r=   r  r>   r  r  r  SLIDERr&   SELECT_SLIDERr  r@   r  rA   r  rB   r
  rC   r  rD   r&  r{   r  r  r=  r  rD  r  r   r  r  r  rf  r-   r6  r   )r  rU   msgr  rf  eltr~   alert_formatnew_nodestyleblockbtycurrent_noder   r*  childplaceholder_blockrM   rM   rN   parse_tree_from_messages  s  





























r  )r^   rt  rY   rQ   )r  r  rY   rQ   )r  r2  rY   r  )r  r  rY   rT   )
__future__r   r  abcr   r   collections.abcr   r   r   dataclassesr   r	   r
   r   r   r   r   r   typingr   r   r   r   r   r   r   typing_extensionsr   	streamlitr   r   streamlit.elements.headingr   (streamlit.elements.widgets.select_sliderr   !streamlit.elements.widgets.sliderr   r   'streamlit.elements.widgets.time_widgetsr   r   r    r!   r"   streamlit.proto.Alert_pb2r#   r   streamlit.proto.Checkbox_pb2r$   r   streamlit.proto.Markdown_pb2r%   rR  streamlit.proto.Slider_pb2r&   r   streamlit.proto.WidgetStates_pb2r'   r(   streamlit.runtime.state.commonr)   r*   pandasr+   r  streamlit.proto.Arrow_pb2r,   r  streamlit.proto.Block_pb2r-   
BlockProtostreamlit.proto.Button_pb2r.   r   streamlit.proto.ButtonGroup_pb2r/   rk  streamlit.proto.ChatInput_pb2r0   r   streamlit.proto.Code_pb2r1   r  streamlit.proto.ColorPicker_pb2r2   r  streamlit.proto.DateInput_pb2r3   r%  !streamlit.proto.DateTimeInput_pb2r4   r  streamlit.proto.Element_pb2r5   rX   streamlit.proto.Exception_pb2r6   r5  streamlit.proto.ForwardMsg_pb2r7   streamlit.proto.Heading_pb2r8   r<  streamlit.proto.Json_pb2r9   rN  streamlit.proto.Metric_pb2r:   re  streamlit.proto.MultiSelect_pb2r;   r  streamlit.proto.NumberInput_pb2r<   r  streamlit.proto.Radio_pb2r=   r  streamlit.proto.Selectbox_pb2r>   r  streamlit.proto.Space_pb2r?   ra  streamlit.proto.Text_pb2r@   r  streamlit.proto.TextArea_pb2rA   r  streamlit.proto.TextInput_pb2rB   r  streamlit.proto.TimeInput_pb2rC   r  streamlit.proto.Toast_pb2rD   r$  *streamlit.runtime.state.safe_session_staterE   streamlit.testing.v1.app_testrF   rG   rH   r{   r   r   r   r   r   r   r   r   r   r   r  r#  ry   r$  r;  rA  rH  rK  rX  r[  r^  r  r   r  r  r  r  r  r  r  r'  rr   r  r  r  r  r  r  r  r2  r  rT   r  rM   rM   rM   rN   <module>   sN  $
5)	)",.,QY<:F;53384% 
j
#

K