
    &eU3                        d dl mZ d dlmZ d dlmZmZmZmZ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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$m%Z%m&Z&m'Z' d dl(m)Z)m*Z* d dl+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3 d dl4m5Z5 erd dl6m7Z7 dee/ee/         f         deee/                  fdZ8e G d dee/                               Z9 G d d          Z:dS )    )	dataclass)dedent)
TYPE_CHECKINGAnyCallableGenericListOptionalSequenceTupleUnioncast)	TypeGuard)current_form_id)check_callback_rulescheck_session_state_rules get_label_visibility_proto_valuemaybe_coerce_enummaybe_coerce_enum_sequence)StreamlitAPIException)Slider)gather_metrics)ScriptRunContextget_script_run_ctx)
WidgetArgsWidgetCallbackWidgetKwargsregister_widget)RegisterWidgetResultcompute_widget_id)KeyLabelVisibilityOptionSequenceTcheck_python_comparableensure_indexablemaybe_raise_label_warningsto_keyindex_)DeltaGeneratorvaluereturnc                 :    t          | t          t          f          S N)
isinstancelisttuple)r,   s    Hlib/python3.11/site-packages/streamlit/elements/widgets/select_slider.py_is_range_valuer4   C   s    edE]+++    c                       e Zd ZU ee         ed<   ee         ed<   eed<   de	dee         fdZ
	 ddeee                  d	edeeeeef         f         fd
Zde	dee         fdZdS )SelectSliderSerdeoptionsr,   is_range_valuevr-   c                 ,    |                      |          S r/   )_as_index_list)selfr:   s     r3   	serializezSelectSliderSerde.serializeM   s    ""1%%%r5    ui_value	widget_idc           	           |s j         }t          t          t          t          f         t	          t           fd|                              } j        r|n|d         S )Nc                 8    j         t          |                    S r/   )r8   int)xr=   s    r3   <lambda>z/SelectSliderSerde.deserialize.<locals>.<lambda>\   s    SVV 4 r5   r   )r,   r   r   r$   r2   mapr9   )r=   r@   rA   return_values   `   r3   deserializezSelectSliderSerde.deserializeP   sg    
  	"zH %)!Q$K#4444h??@@%
 %
  $2G||QGr5   c                      t          |          r fd|D             }|\  }}||k    r||g}|S t           j        |          gS )Nc                 :    g | ]}t          j        |          S  )r*   r8   ).0valr=   s     r3   
<listcomp>z4SelectSliderSerde._as_index_list.<locals>.<listcomp>d   s%    CCC#F4<55CCCr5   )r4   r*   r8   )r=   r:   slider_valuestartends   `    r3   r<   z SelectSliderSerde._as_index_listb   sb    1 	-CCCCCCCL%JE3s{{ #U|4<++,,r5   N)r?   )__name__
__module____qualname__r   r$   __annotations__r	   rD   boolobjectr>   r
   strr   r   rI   r<   rL   r5   r3   r7   r7   G   s         a[9&6 &d3i & & & & H H49%H H 
q%1+~		H H H H$- -49 - - - - - -r5   r7   c                      e Zd Z ed          ddedddddfddddedee         d	ed
ee	ge	f         de
e         de
e         de
e         de
e         de
e         dededeeeeef         f         fd            Zddeddddddddfdedee         d	ed
ee	ge	f         de
e         de
e         de
e         de
e         de
e         dedede
e         deeeeef         f         fdZedd            ZdS )SelectSliderMixinselect_sliderrL   NFvisible)disabledlabel_visibilitylabelr8   r,   format_funckeyhelp	on_changeargskwargsr^   r_   r-   c
                `    t                      }|                     |||||||||	|
||          S )a  
        Display a slider widget to select items from a list.

        This also allows you to render a range slider by passing a two-element
        tuple or list as the ``value``.

        The difference between ``st.select_slider`` and ``st.slider`` is that
        ``select_slider`` accepts any datatype and takes an iterable set of
        options, while ``st.slider`` only accepts numerical or date/time data and
        takes a range as input.

        Parameters
        ----------
        label : str
            A short label explaining to the user what this slider is for.
            The label can optionally contain Markdown and supports the following
            elements: Bold, Italics, Strikethroughs, Inline Code, Emojis, and Links.

            This also supports:

            * Emoji shortcodes, such as ``:+1:``  and ``:sunglasses:``.
              For a list of all supported codes,
              see https://share.streamlit.io/streamlit/emoji-shortcodes.

            * LaTeX expressions, by wrapping them in "$" or "$$" (the "$$"
              must be on their own lines). Supported LaTeX functions are listed
              at https://katex.org/docs/supported.html.

            * Colored text, using the syntax ``:color[text to be colored]``,
              where ``color`` needs to be replaced with any of the following
              supported colors: blue, green, orange, red, violet, gray/grey, rainbow.

            Unsupported 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``.

            For accessibility reasons, you should never set an empty label (label="")
            but hide it with label_visibility if needed. In the future, we may disallow
            empty labels by raising an exception.
        options : Iterable
            Labels for the select options in an Iterable. For example, this can
            be a list, numpy.ndarray, pandas.Series, pandas.DataFrame, or
            pandas.Index. For pandas.DataFrame, the first column is used.
            Each label will be cast to str internally by default.
        value : a supported type or a tuple/list of supported types or None
            The value of the slider when it first renders. If a tuple/list
            of two values is passed here, then a range slider with those lower
            and upper bounds is rendered. For example, if set to `(1, 10)` the
            slider will have a selectable range between 1 and 10.
            Defaults to first option.
        format_func : function
            Function to modify the display of the labels from the options.
            argument. It receives the option as an argument and its output
            will be cast to str.
        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. Multiple widgets of the same type may
            not share the same key.
        help : str
            An optional tooltip that gets displayed next to the select slider.
        on_change : callable
            An optional callback invoked when this select_slider'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, which disables the select slider if set to True.
            The default is False.
        label_visibility : "visible", "hidden", or "collapsed"
            The visibility of the label. If "hidden", the label doesn't show but there
            is still empty space for it above the widget (equivalent to label="").
            If "collapsed", both the label and the space are removed. Default is
            "visible".

        Returns
        -------
        any value or tuple of any value
            The current value of the slider widget. The return type will match
            the data type of the value parameter.

        Examples
        --------
        >>> import streamlit as st
        >>>
        >>> color = st.select_slider(
        ...     'Select a color of the rainbow',
        ...     options=['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'])
        >>> st.write('My favorite color is', color)

        And here's an example of a range select slider:

        >>> import streamlit as st
        >>>
        >>> start_color, end_color = st.select_slider(
        ...     'Select a range of color wavelength',
        ...     options=['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'],
        ...     value=('red', 'blue'))
        >>> st.write('You selected wavelengths between', start_color, 'and', end_color)

        .. output::
           https://doc-select-slider.streamlit.app/
           height: 450px

        )r`   r8   r,   ra   rb   rc   rd   re   rf   r^   r_   ctx)r   _select_slider)r=   r`   r8   r,   ra   rb   rc   rd   re   rf   r^   r_   rh   s                r3   r\   zSelectSliderMixin.select_slidern   sQ    t !""""#- # 
 
 	
r5   rh   c                    t          |          }t          | j        |           t          |           t	          ||           t          |          t                     t                    dk    rt          d          dt          dt          t                   ffd} |          }t          d||fdD             |||t          | j                  |r|j        nd 		  	        }t                      }||_        t          j        j        |_        ||_        d
|_        ||j        d d <   d|_        t                    dz
  |_        d|_        t          j        |_        fdD             |j        d d <   t          | j                  |_        |
|_        t?          |          |j         _!        |tE          |          |_#        tI          |tK                              }tM          d|||||	|j'        |j(        |	  	        }tS          |j!        tT                    rBtW          tY          tZ          t\          t^          t^          f                  |          |          }nta          ||          }|j1        r+|(                    |j!                  |j!        d d <   d|_2        | j        3                    d|           |j!        S )N)default_valuerb   r   z,The `options` argument needs to be non-emptyr:   r-   c                     t          |           rfd| D             }|\  }}||k    r||g}|S 	 t          |           gS # t          $ r	  dgcY S w xY w)Nc                 0    g | ]}t          |          S rL   r)   )rM   rN   opts     r3   rO   zKSelectSliderMixin._select_slider.<locals>.as_index_list.<locals>.<listcomp>  s#    >>>SsC 0 0>>>r5   r   )r4   r*   
ValueError)r:   rP   rQ   rR   rn   r,   s       r3   as_index_listz7SelectSliderMixin._select_slider.<locals>.as_index_list  s    q!! >>>>A>>>)
s3;;$'<L##"3NN++!   (3JJJ	s   A AAr\   c                 @    g | ]}t           |                    S rL   rY   rM   optionra   s     r3   rO   z4SelectSliderMixin._select_slider.<locals>.<listcomp>)  s+    @@@&SV,,--@@@r5   )user_keyr`   r8   r,   rb   rc   form_idpagez%s   c                 @    g | ]}t           |                    S rL   rr   rs   s     r3   rO   z4SelectSliderMixin._select_slider.<locals>.<listcomp>;  s+    "N"N"N3{{6':':#;#;"N"N"Nr5   slider)ru   on_change_handlerre   rf   deserializer
serializerrh   T)4r(   r   dgr   r'   r&   r%   lenr   rX   r	   rD   r    r   page_script_hashSliderProtoidTypeSELECT_SLIDERtyper`   formatdefaultminmaxstepINT	data_typer8   rv   r^   r   r_   r,   r   rc   r7   r4   r   rI   r>   r0   r2   r   r   r   r   r$   r   value_changed	set_value_enqueue)r=   r`   r8   r,   ra   rb   rc   rd   re   rf   r^   r_   rh   rp   rP   r   slider_protoserdewidget_statern   s      ``              @r3   ri   z SelectSliderMixin._select_slider   s    SkkTWi000!3????"5*:;;;w''$$$s88q=='(VWWW	V 	S	 	 	 	 	 	 	 	$ %}U++@@@@C@@@#DG,,),6%%$

 

 

 #}}',:""".QQQs88a<!,"N"N"N"N#"N"N"NQQQ.tw77 (.N/
 /
%+  &tL!#|_U5K5KLL&'*

 

 

 l(%00 	I5)%1+6EEwPS LL -\7CHHL% 	*$)OOL4F$G$GLqqq!%)L"<000!!r5   r+   c                 "    t          d|           S )zGet our DeltaGenerator.r+   )r   )r=   s    r3   r~   zSelectSliderMixin.dg_  s     $d+++r5   )r-   r+   )rS   rT   rU   r   rY   r#   r$   rX   r   r   r
   r!   r   r   r   rW   r"   r   r   r\   r   ri   propertyr~   rL   r5   r3   r[   r[   m   s]       ^O$$ &(,/!".2%))-G
 ,5G
 G
 G
G
  "G
 	G

 seSj)G
 c]G
 smG
 N+G
 z"G
 &G
 G
 *G
 
q%1+~	G
 G
 G
 %$G
X &(,/!".2%))-,5*.e" e"e"  "e" 	e"
 seSj)e" c]e" sme" N+e" z"e" &e" e" *e" &'e" 
q%1+~	e" e" e" e"N , , , X, , ,r5   r[   N);dataclassesr   textwrapr   typingr   r   r   r   r	   r
   r   r   r   r   typing_extensionsr   streamlit.elements.formr   streamlit.elements.utilsr   r   r   r   r   streamlit.errorsr   streamlit.proto.Slider_pb2r   r   streamlit.runtime.metrics_utilr   streamlit.runtime.scriptrunnerr   r   streamlit.runtime.stater   r   r   r   streamlit.runtime.state.commonr   r    streamlit.type_utilr!   r"   r#   r$   r%   r&   r'   r(   streamlit.utilr*   streamlit.delta_generatorr+   r4   r7   r[   rL   r5   r3   <module>r      s   " ! ! ! ! !                              ( ' ' ' ' ' 3 3 3 3 3 3              3 2 2 2 2 2 < < < < < < 9 9 9 9 9 9 O O O O O O O O            S R R R R R R R	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 " ! ! ! ! ! 9888888,5HQK0 ,Yx{5K , , , , "- "- "- "- "-
 "- "- "-Ju, u, u, u, u, u, u, u, u, u,r5   