
    /_i>                       d dl 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mZ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 d d	lmZmZ d d
l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* d dl+m,Z,m-Z- d dl.m/Z/m0Z0m1Z1m2Z2 d dl3m4Z4 erd dl5m6Z6m7Z7 d dl8m9Z9 d dlm:Z: d dl;m<Z<  ed      Z=ddZ>e G d de	e=                Z? G d d      Z@y)    )annotations)	dataclass)dedent)TYPE_CHECKINGAnyGeneric	TypeGuardTypeVarcastoverload)OptionSequenceconvert_anything_to_list)current_form_id)LayoutConfigvalidate_width)index_maybe_coerce_enummaybe_coerce_enum_sequence)check_widget_policiesmaybe_raise_label_warnings)KeyLabelVisibilitycompute_and_register_element_id get_label_visibility_proto_valuesave_for_app_testingto_key)StreamlitAPIException)Slider)gather_metrics)ScriptRunContextget_script_run_ctx)
WidgetArgsWidgetCallbackWidgetKwargsregister_widget)check_python_comparable)CallableSequence)DeltaGenerator)WidthWithoutContent)RegisterWidgetResultTc                .    t        | t        t        f      S N)
isinstancelisttuple)values    g/var/www/html/land_sniper/venv/lib/python3.12/site-packages/streamlit/elements/widgets/select_slider.py_is_range_valuer4   G   s    edE]++    c                  D    e Zd ZU ded<   ded<   ded<   ddZddZdd	Zy
)SelectSliderSerdezSequence[T]options	list[int]r2   boolis_range_valuec                $    | j                  |      S r.   )_as_index_list)selfvs     r3   	serializezSelectSliderSerde.serializeQ   s    ""1%%r5   c                     |s j                   }t        dt         fd|D                    } j                  r|S |d   S )Ntuple[T, T]c              3  N   K   | ]  }j                   t        |           y wr.   )r8   int).0xr>   s     r3   	<genexpr>z0SelectSliderSerde.deserialize.<locals>.<genexpr>\   s     91$,,s1v&9s   "%r   )r2   r   r1   r;   )r>   ui_valuereturn_values   `  r3   deserializezSelectSliderSerde.deserializeT   sE    zzH %)999%
  $22|GQGr5   c                    t        |      r3|D cg c]  }t        | j                  |       }}|\  }}||kD  r||g}|S t        | j                  |      gS c c}w r.   )r4   r   r8   )r>   r?   valslider_valuestartends         r3   r=   z SelectSliderSerde._as_index_listb   sa    1ABC#F4<<5CLC%JE3s{ #U|t||Q'(( Ds   AN)r?   objectreturnr9   )rH   zlist[int] | NonerQ   T | tuple[T, T]r?   r   rQ   r9   )__name__
__module____qualname____annotations__r@   rJ   r=    r5   r3   r7   r7   K   s$    &H)r5   r7   c                     e Zd Zeedddddfdddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Zeddedddddfdddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Z ed	      ddedddddfdddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd
       Zddedddddddddf	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZedd       Z	y)SelectSliderMixinNFvisiblestretch)disabledlabel_visibilitywidthc
                    y r.   rX   r>   labelr8   r2   format_funckeyhelp	on_changeargskwargsr]   r^   r_   s                r3   select_sliderzSelectSliderMixin.select_sliderm   s      r5   rX   c
                    y r.   rX   ra   s                r3   ri   zSelectSliderMixin.select_slider   s      r5   ri   c
               R    t               }| j                  |||||||||	|
|||      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 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

        options : Iterable
            Labels for the select options in an ``Iterable``. This can be a
            ``list``, ``set``, or anything supported by ``st.dataframe``. If
            ``options`` is dataframe-like, the first column will be 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. 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 select_slider's value changes.

        args : list or tuple
            An optional list or 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 select slider 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 aligned with other widgets.
            If this is ``"collapsed"``, Streamlit displays no label or spacer.

        width : "stretch" or int
            The width of the slider widget. This can be one of the
            following:

            - ``"stretch"`` (default): The width of the widget matches the
              width of the parent container.
            - An integer specifying the width in pixels: The widget has a
              fixed width. If the specified width is greater than the width of
              the parent container, the width of the widget matches the width
              of the parent container.

        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.

            This contains copies of the selected options, not the originals.

        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

        )rb   r8   r2   rc   rd   re   rf   rg   rh   r]   r^   ctxr_   )r!   _select_slider)r>   rb   r8   r2   rc   rd   re   rf   rg   rh   r]   r^   r_   rl   s                 r3   ri   zSelectSliderMixin.select_slider   sL    H !"""#- # 
 	
r5   c                   t        |      }t        | j                  ||       t        ||       t	        |      t               t              dk(  rt        d      dfd} |      }t        d|ddh| j                  |D cg c]  }t         ||             c}|||	      }t               }||_        t        j                  j                  |_        ||_        d	|_        ||j"                  d d  d|_        t              d
z
  |_        d
|_        t        j*                  |_        D cg c]  }t         ||             c}|j.                  d d  t1        | j                        |_        |
|_        t7        |      |j8                  _        |t=        |      |_        tA        |       tC        |      }tE        |tG                    }tI        |j                  |||	|jJ                  |jL                  |d      }tO        |j:                  tP              rtS        tU        d|      |      }ntW        ||      }|jX                  r/|jM                  |j:                        |j:                  d d  d|_-        |rt]        |||       | j                  j_                  d||       |j:                  S c c}w c c}w )N)default_valuer   z,The `options` argument needs to be non-emptyc                    t        |       r)| D cg c]  }t        |       }}|\  }}||kD  r||g}|S 	 t        |       gS c c}w # t        $ r	  dgcY S w xY w)Nr   )r4   r   
ValueError)r?   rL   rM   rN   rO   optr2   s        r3   as_index_listz7SelectSliderMixin._select_slider.<locals>.as_index_listf  s~    q!<=>SsC 0>>)
s3;$'<L##sA''  ?  $s
	s   AA	 	AAri   r8   rc   )user_keykey_as_main_identitydgrb   r8   r2   re   r_   z%s   )r_   double_array_value)on_change_handlerrg   rh   deserializer
serializerrl   
value_typez!RegisterWidgetResult[tuple[T, T]]Tslider)layout_configrS   )0r   r   rv   r   r   r&   lenr   r   strSliderProtoidTypeSELECT_SLIDERtyperb   formatdefaultminmaxstepINT	data_typer8   r   form_idr]   r   r^   r2   r   re   r   r   r7   r4   r%   rJ   r@   r/   r1   r   r   r   value_changed	set_valuer   _enqueue)r>   rb   r8   r2   rc   rd   re   rf   rg   rh   r]   r^   rl   r_   rs   rM   option
element_idslider_protor~   serdewidget_staterr   s      `                  @r3   rm   z SelectSliderMixin._select_sliderF  s     SkGG		
 	#5*:;&w/$s8q='(VWW	" %U+4 #,]!;ww<?@&SV,-@

 #}$',,::""".Qs8a<!,JM"N3{6':#;"NQ.tww7 (.N/
%%+  &tLu$51!#|_U5KL&OO'**+	
 l((%058,GRUL -\7CHL%%$)OOL4F4F$GLq!%)L" j+><}M!!!o A  #Os   J;5K c                    t        d|       S )zGet our DeltaGenerator.r)   )r   )r>   s    r3   rv   zSelectSliderMixin.dg  s     $d++r5   )rb   r   r8   OptionSequence[T]r2   ztuple[T, T] | list[T]rc   Callable[[Any], Any]rd   
Key | Nonere   
str | Nonerf   WidgetCallback | Nonerg   WidgetArgs | Nonerh   WidgetKwargs | Noner]   r:   r^   r   r_   r*   rQ   rB   )rb   r   r8   r   r2   zT | Nonerc   r   rd   r   re   r   rf   r   rg   r   rh   r   r]   r:   r^   r   r_   r*   rQ   r,   )rb   r   r8   r   r2   T | Sequence[T] | Nonerc   r   rd   r   re   r   rf   r   rg   r   rh   r   r]   r:   r^   r   r_   r*   rQ   rR   )rb   r   r8   r   r2   r   rc   r   rd   r   re   r   rf   r   rg   r   rh   r   r]   r:   r^   r   rl   zScriptRunContext | Noner_   r*   rQ   rR   )rQ   r)   )
rT   rU   rV   r   r   ri   r   rm   propertyrv   rX   r5   r3   rZ   rZ   l   s#    -0+/"&&* ,5%. # %	
 *   )   $  * # 
 "  &(,/+/"&&* ,5%. # 	
 *   )   $  * # 
 " O$ &((,,/+/"&&*r
 ,5%.r
r
 #r
 &	r

 *r
 r
 r
 )r
  r
 $r
 r
 *r
 #r
 
r
 %r
n &((,,/+/"&&*,5'+%.s"s" #s" &	s"
 *s" s" s" )s"  s" $s" s" *s" %s" #s" 
s"j , ,r5   rZ   N)r2   zT | Sequence[T]rQ   zTypeGuard[Sequence[T]])A
__future__r   dataclassesr   textwrapr   typingr   r   r   r	   r
   r   r   streamlit.dataframe_utilr   r   !streamlit.elements.lib.form_utilsr   #streamlit.elements.lib.layout_utilsr   r   -streamlit.elements.lib.options_selector_utilsr   r   r   streamlit.elements.lib.policiesr   r   streamlit.elements.lib.utilsr   r   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.type_utilr&   collections.abcr'   r(   streamlit.delta_generatorr)   r*   streamlit.runtime.state.commonr+   r,   r4   r7   rZ   rX   r5   r3   <module>r      s    # !    N = L 
  3 < 9 O  828GCCL, )
 ) )@R, R,r5   