o
    Yhe                  
   @  s  U 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 d dlmZ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 d dlmZ d d	lmZ d d
lmZm Z  d dl!m"Z"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.m/Z/m0Z0 d dl1m2Z3 d dl4m5Z5 d dl6m7Z7m8Z8 d dl9m:Z:m;Z;m<Z<m=Z=m>Z> erd dl?m@Z@ d dl!mAZA edeBeCZDedeeeZEeeFeD eGd eGeD eGeDeDf f ZHdeId< eeFeE eGd eGeE eGeEeEf f ZJdeId< eDZKdeId< e	ZLdeId< eeBeCe	f ZMdeId< eeBeCeeef ZNdeId< edeBeCeeeZOeeOeeO f ZPdeId < eePeB ePeC ePe ePe ePe f ZQdeId!< eeOeGeO eGeOeOf f ZRdeId"< eeReB eReC eRe eRe eRe f ZSdeId#< d$ZTd%eId&< d'eT ZUd%eId(< ed)d*d*e
jVd+ZWd%eId,< ee3jXee3jYee3jZee3j[ee3j\iZ]d%eId-< e3jZe3j\e3j[fZ^d%eId.< dMd3d4Z_dNd7d8Z`dOd<d=ZadPd?d@ZbdQdDdEZcG dFdG dGeZdeG dHdI dIZeG dJdK dKZfdLS )R    )annotations)Sequence)	dataclass)datedatetimetime	timedeltatimezonetzinfo)IntegralReal)dedent)TYPE_CHECKINGAnyFinal	TypedDictTypeVarUnioncastoverload)	TypeAlias)current_form_id)JSNumberJSNumberBoundsException)LayoutConfigvalidate_width)check_widget_policiesmaybe_raise_label_warnings)KeyLabelVisibilitycompute_and_register_element_id get_label_visibility_proto_valueto_key)StreamlitAPIExceptionStreamlitValueAboveMaxErrorStreamlitValueBelowMinError)Slider)gather_metrics)ScriptRunContextget_script_run_ctx)
WidgetArgsWidgetCallbackWidgetKwargsget_session_stateregister_widget)DeltaGenerator)WidthWithoutContentSliderNumericTSliderDatelikeT r   SliderNumericSpanTSliderDatelikeSpanTStepNumericTStepDatelikeT
SliderStepSliderScalarSliderValueTSliderValueGenericSliderValueSliderReturnGenericSliderReturni@B r   SECONDS_TO_MICROSiQ DAYS_TO_MICROSi     r
   	UTC_EPOCHSUPPORTED_TYPESTIMELIKE_TYPEStime_r   returnr   c                 C  s   t tddd| S )Ni  rA   )r   combiner   )rF   r3   r3   b/var/www/html/Persson_Maskin/env/lib/python3.10/site-packages/streamlit/elements/widgets/slider.py_time_to_datetime   s   rJ   date_r   c                 C  s   t | t S N)r   rH   r   )rK   r3   r3   rI   _date_to_datetime   s   rM   deltar   intc                 C  s   | j | jt  | jt  S rL   )microsecondssecondsr?   daysr@   )rN   r3   r3   rI   _delta_to_micros   s   rS   dtc                 C  s   | j tjd}t|t S NrB   )replacer	   utcrS   rC   )rT   utc_dtr3   r3   rI   _datetime_to_micros   s   rY   microsorig_tztzinfo | Nonec                 C  s   t t| d }|j|dS )zFRestore times/datetimes to original timezone (dates are always naive).)rP   rB   )rC   r   rV   )rZ   r[   rX   r3   r3   rI   _micros_to_datetime   s   r]   c                   @  s.   e Zd ZU ded< ded< ded< ded< dS )	SliderDefaultValuesr9   	min_value	max_valuer8   stepstrformatN)__name__
__module____qualname____annotations__r3   r3   r3   rI   r^      s
   
 r^   c                   @  sL   e Zd ZU ded< ded< ded< ded< dddZdddZdddZdS )SliderSerdelist[float]valuerO   	data_typeboolsingle_valuer\   r[   floatrG   r9   c                 C  s~   | j tjkr
t|S | j tjkrtt|| jS | j tjkr(tt|| j S | j tj	kr=tt|| j
 j| jdS |S rU   )rk   SliderProtoINTrO   DATETIMEr]   r[   DATEr   TIMEr   rV   )selfrj   r3   r3   rI   deserialize_single_value   s   z$SliderSerde.deserialize_single_valueui_valuelist[float] | Noner   c                   s<   |d ur|}n j } fdd|D } jr|d S t|S )Nc                   s   g | ]}  |qS r3   )ru   ).0vrt   r3   rI   
<listcomp>   s    z+SliderSerde.deserialize.<locals>.<listcomp>r   )rj   rm   tuple)rt   rv   valdeserialized_valuesr3   rz   rI   deserialize   s   zSliderSerde.deserializery   	list[Any]c                 C  s|   t |ttf}|rt|n|g}| jtjkrdd |D S | jtjkr*dd |D S | jtjkr7dd |D S dd |D S )Nc                 S     g | ]}t t|qS r3   )rY   rM   rx   r}   r3   r3   rI   r{          z)SliderSerde.serialize.<locals>.<listcomp>c                 S  r   r3   )rY   rJ   r   r3   r3   rI   r{      r   c                 S     g | ]}t |qS r3   )rY   r   r3   r3   rI   r{          c                 S  r   r3   )rn   r   r3   r3   rI   r{      r   )
isinstancelistr|   rk   ro   rr   rs   rq   )rt   ry   range_valueprocessed_valuer3   r3   rI   	serialize   s   zSliderSerde.serializeN)rj   rn   rG   r9   )rv   rw   rG   r   )ry   r   rG   r   )rd   re   rf   rg   ru   r   r   r3   r3   r3   rI   rh      s   
 

rh   c                   @  s   e Zd Ze										dGdddddHd!d"Ze										dGdddddId&d"Ze		dJddddddddddd'
dKd*d"Ze							dLdddddMd+d"Ze									dNdddddOd/d"Ze	dPdddddddddddd0dQd1d"Ze		dJddddddddddd'
dRd2d"Ze		dJddddddddddd'
dSd5d"Ze							dLdddddTd7d"Zed8										dGdddddUd=d"Z										dGddddd>dVdBdCZedWdEdFZdS )XSliderMixinNFvisiblestretch)disabledlabel_visibilitywidthlabelrb   r_   Noner`   rj   ra   
int | Nonerc   
str | Nonekey
Key | Nonehelp	on_changeWidgetCallback | NoneargsWidgetArgs | NonekwargsWidgetKwargs | Noner   rl   r   r   r   r0   rG   rO   c                C     d S rL   r3   rt   r   r_   r`   rj   ra   rc   r   r   r   r   r   r   r   r   r3   r3   rI   slider      zSliderMixin.sliderSliderNumericT | None#StepNumericT[SliderNumericT] | Noner1   c                C  r   rL   r3   r   r3   r3   rI   r      r   )
ra   rc   r   r   r   r   r   r   r   r   "SliderNumericSpanT[SliderNumericT]%tuple[SliderNumericT, SliderNumericT]c                C  r   rL   r3   r   r3   r3   rI   r     r   c                C  r   rL   r3   r   r3   r3   rI   r   )  r   r2   SliderDatelikeT | NoneStepDatelikeT | Nonec                C  r   rL   r3   r   r3   r3   rI   r   ?  r   )rj   ra   rc   r   r   r   r   r   r   r   r   c                C  r   rL   r3   r   r3   r3   rI   r   U  r   c                C  r   rL   r3   r   r3   r3   rI   r   j  r   Xlist[SliderDatelikeT] | tuple[SliderDatelikeT] | tuple[SliderDatelikeT, SliderDatelikeT]'tuple[SliderDatelikeT, SliderDatelikeT]c                C  r   rL   r3   r   r3   r3   rI   r     s   $SliderDatelikeSpanT[SliderDatelikeT]c               C  r   rL   r3   r   r3   r3   rI   r     s   r   SliderScalar | NoneSliderValue | NoneSliderStep | Noner   c                C  s.   t  }| j|||||||||	|
|||||dS )a$  Display a slider widget.

        This supports int, float, date, time, and datetime types.

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

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

        .. note::
            Integer values exceeding +/- ``(1<<53) - 1`` cannot be accurately
            stored or returned by the widget due to serialization constraints
            between the Python server and JavaScript client. You must handle
            such numbers as floats, leading to a loss in precision.

        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

        min_value : a supported type or None
            The minimum permitted value.
            If this is ``None`` (default), the minimum value depends on the
            type as follows:

            - integer: ``0``
            - float: ``0.0``
            - date or datetime: ``value - timedelta(days=14)``
            - time: ``time.min``

        max_value : a supported type or None
            The maximum permitted value.
            If this is ``None`` (default), the maximum value depends on the
            type as follows:

            - integer: ``100``
            - float: ``1.0``
            - date or datetime: ``value + timedelta(days=14)``
            - time: ``time.max``

        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.
            This defaults to ``min_value``. If the type is not otherwise
            specified in any of the numeric parameters, the widget will have an
            integer value.

        step : int, float, timedelta, or None
            The stepping interval.
            Defaults to 1 if the value is an int, 0.01 if a float,
            timedelta(days=1) if a date/datetime, timedelta(minutes=15) if a time
            (or if max_value - min_value < 1 day)

        format : str or None
            A printf-style format string controlling how the interface should
            display numbers. This does not impact the return value.

            For information about formatting integers and floats, see
            `sprintf.js
            <https://github.com/alexei/sprintf.js?tab=readme-ov-file#format-specification>`_.
            For example, ``format="%0.1f"`` adjusts the displayed decimal
            precision to only show one digit after the decimal.

            For information about formatting datetimes, dates, and times, see
            `momentJS <https://momentjs.com/docs/#/displaying/format/>`_.
            For example, ``format="ddd ha"`` adjusts the displayed datetime to
            show the day of the week and the hour ("Tue 8pm").

        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 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 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
        -------
        int/float/date/time/datetime or tuple of int/float/date/time/datetime
            The current value of the slider widget. The return type will match
            the data type of the value parameter.

        Examples
        --------
        >>> import streamlit as st
        >>>
        >>> age = st.slider("How old are you?", 0, 130, 25)
        >>> st.write("I'm ", age, "years old")

        And here's an example of a range slider:

        >>> import streamlit as st
        >>>
        >>> values = st.slider("Select a range of values", 0.0, 100.0, (25.0, 75.0))
        >>> st.write("Values:", values)

        This is a range time slider:

        >>> import streamlit as st
        >>> from datetime import time
        >>>
        >>> appointment = st.slider(
        ...     "Schedule your appointment:", value=(time(11, 30), time(12, 45))
        ... )
        >>> st.write("You're scheduled for:", appointment)

        Finally, a datetime slider:

        >>> import streamlit as st
        >>> from datetime import datetime
        >>>
        >>> start_time = st.slider(
        ...     "When do you start?",
        ...     value=datetime(2020, 1, 1, 9, 30),
        ...     format="MM/DD/YY - hh:mm",
        ... )
        >>> st.write("Start time:", start_time)

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

        )r   r_   r`   rj   ra   rc   r   r   r   r   r   r   r   r   ctx)r)   _slider)rt   r   r_   r`   rj   ra   rc   r   r   r   r   r   r   r   r   r   r3   r3   rI   r     s&    K)r   r   r   r   r   ScriptRunContext | Noner>   c          0        s  t |}t| j||	|d t|| td|| j||||||||d}|d u r`d}t j}|d urA||v rA|| }t|tt	
 }|rL|d urI|nd}n|d urR|nd}|d urZ|nd}||g}t|tt	
 }t|ttfout|dv }|s~|s~td|r|gn|}dGdd dH fdd}||stdttt| t|dkrtjn |d }tj}tj}|tjkrtd|}tjj|d jd}tjj|d jd}|tjtjfv rtd|}|d tdd }|d tdd }tjdddddtjdddddtj||tddd dtj||tddd dtj||td!d"d#di}|d u r1|| d$ }|d u r<|| d% }|d u r_|| d& }|tjtjfv r_|| tddk r_td!d"}|d u rmtd'|| d( }|dkrvtd)|||g}td*d+ |D }td,d+ |D }|tv ot|tot|t|u } |s|s| sd-t|j d.t|j d/t|j d0}!t|!|tjko|}"|tjko|}#|tv o| }$|"s|#s|$sd1t|j d2t|j d.t|j d0}!t|!t||}t||}t|dkrt|d |}t|d |}n(t|d3kr?|\}%}&|%|&kr4|&|%}%}&|%|&f}t|%|}t|&|}n||g}z&|"rTt !|d4 t !|d5 n|#rdt "|d4 t "|d5 n|$rh	 W n t#y| }' ztt$|'d }'~'ww d }(|tjkrtd|}td6|}td6|}ttt%|}t%|}t%|}|tjkrtd7|}td8|}td8|}ttt&|}t&|}t&|}||krtd9| d:| d;|tv rtd|}td<|}td<|}td=|}|tjtjfv r|d jnd }(ttt'|}t'|}t'|}t(|}td>|}t })tj)j*|)_||)_+||)_,||)_-||)j.d d < ||)_||)_td?||)_/||)_0g |)j1d d < t2| j|)_3||)_4t5||)j6_7|d ur_t8||)_9t:||||(}*t;|)j+|	|
||*j<|*j=|d@dA}+|+j>r|*=|+j7},|,D ](}-|*?|-}.|-|)jk rt@|.|*?|)jdB|-|)jkrtA|.|*?|)jdCq|,|)j7d d < d|)_BtC| tD|dD}/| jjEd|)|/dE tdF|+j7S )IN)default_valuer   )
user_keydgr   r_   r`   rj   ra   rc   r   r   Tr   d   )r   rA      zcSlider value should either be an int/float/datetime or a list/tuple of 0 to 2 ints/floats/datetimesry   r   rG   SliderProto.DataType.ValueTypec                 S  s0   t | tr	tt S t | trtt S tt|  S rL   )r   r   rD   r   type)ry   r3   r3   rI   value_to_generic_type  s
   

z2SliderMixin._slider.<locals>.value_to_generic_typeitemsrl   c                   s   t tt | dk S )Nr   )lensetmap)r   r   r3   rI   all_same_type  s   z*SliderMixin._slider.<locals>.all_same_typezASlider tuple/list components must be of the same type.
But were: zSequence[time]rB   zSequence[datetime]   )rR   rA   z%d)r_   r`   ra   rc   g        g      ?g{Gz?z%0.2fz
YYYY-MM-DD   )minuteszHH:mmr_   r`   ra   rb   rc   z1Slider components cannot be passed a `step` of 0.c                 s  s    | ]}t |tV  qd S rL   )r   r   rx   ar3   r3   rI   	<genexpr>0  s    z&SliderMixin._slider.<locals>.<genexpr>c                 s  s&    | ]}t |tot |t V  qd S rL   )r   r   r   r   r3   r3   rI   r   1  s    
zBSlider value arguments must be of matching types.
`min_value` has z type.
`max_value` has z type.
`step` has z type.z?Both value and arguments must be of the same type.
`value` has z type.
`min_value` has r   z`min_value`z`max_value`r   zSequence[date]r   zFSlider `min_value` must be less than the `max_value`.
The values were z and .r   r   ri   rn   double_array_value)on_change_handlerr   r   deserializer
serializerr   
value_type)rj   r_   )rj   r`   )r   )layout_configr>   )ry   r   rG   r   )r   r   rG   rl   )Fr"   r   r   r   r    r-   filtered_stater   r|   rD   keysr   r   r#   r   r   ro   rp   r   minmaxrs   r   rV   r
   rq   rr   r   FLOATallrE   rd   r   validate_int_boundsvalidate_float_boundsr   rb   rJ   rM   rY   rS   TypeSLIDERidr   rc   defaultra   rk   optionsr   form_idr   r!   r   rj   r   r   rh   r.   r   r   value_changedru   r%   r$   	set_valuer   r   _enqueue)0rt   r   r_   r`   rj   ra   rc   r   r   r   r   r   r   r   r   r   
element_idrm   session_statestate_valuemnmxr   prepared_valuer   rk   datetime_mindatetime_maxdefaultsslider_argsint_args
float_argstimelike_argsmsgall_ints
all_floatsall_timelikesstartender[   slider_protoserdewidget_stateserialized_valuesserialized_valuedeserialized_valuer   r3   r   rI   r     s  






!
































zSliderMixin._sliderr/   c                 C  s
   t d| S )zGet our DeltaGenerator.r/   )r   rz   r3   r3   rI   r     s   
zSliderMixin.dg)
NNNNNNNNNN)r   rb   r_   r   r`   r   rj   r   ra   r   rc   r   r   r   r   r   r   r   r   r   r   r   r   rl   r   r   r   r0   rG   rO   )r   rb   r_   r   r`   r   rj   r   ra   r   rc   r   r   r   r   r   r   r   r   r   r   r   r   rl   r   r   r   r0   rG   r1   )NN)r   rb   r_   r   r`   r   rj   r   ra   r   rc   r   r   r   r   r   r   r   r   r   r   r   r   rl   r   r   r   r0   rG   r   )NNNNNNN)r   rb   r_   r1   r`   r1   rj   r   ra   r   rc   r   r   r   r   r   r   r   r   r   r   r   r   rl   r   r   r   r0   rG   r   )	NNNNNNNNN)r   rb   r_   r2   r`   r   rj   r   ra   r   rc   r   r   r   r   r   r   r   r   r   r   r   r   rl   r   r   r   r0   rG   r2   rL   )r   rb   r_   r   r`   r2   rj   r   ra   r   rc   r   r   r   r   r   r   r   r   r   r   r   r   rl   r   r   r   r0   rG   r2   )r   rb   r_   r   r`   r   rj   r2   ra   r   rc   r   r   r   r   r   r   r   r   r   r   r   r   rl   r   r   r   r0   rG   r2   )r   rb   r_   r   r`   r   rj   r   ra   r   rc   r   r   r   r   r   r   r   r   r   r   r   r   rl   r   r   r   r0   rG   r   )ra   r   rc   r   r   r   r   r   r   r   r   r   r   r   r   rb   r_   r2   r`   r2   rj   r   r   rl   r   r   r   r0   rG   r   )r   rb   r_   r   r`   r   rj   r   ra   r   rc   r   r   r   r   r   r   r   r   r   r   r   r   rl   r   r   r   r0   rG   r   ) r   rb   r_   r   r`   r   rj   r   ra   r   rc   r   r   r   r   r   r   r   r   r   r   r   r   rl   r   r   r   r0   r   r   rG   r>   )rG   r/   )	rd   re   rf   r   r   r'   r   propertyr   r3   r3   r3   rI   r      sV   	 `  dr   N)rF   r   rG   r   )rK   r   rG   r   )rN   r   rG   rO   )rT   r   rG   rO   )rZ   rO   r[   r\   rG   r   )g
__future__r   collections.abcr   dataclassesr   r   r   r   r   r	   r
   numbersr   r   textwrapr   typingr   r   r   r   r   r   r   r   typing_extensionsr   !streamlit.elements.lib.form_utilsr    streamlit.elements.lib.js_numberr   r   #streamlit.elements.lib.layout_utilsr   r   streamlit.elements.lib.policiesr   r   streamlit.elements.lib.utilsr   r   r    r!   r"   streamlit.errorsr#   r$   r%   streamlit.proto.Slider_pb2r&   ro   streamlit.runtime.metrics_utilr'   streamlit.runtime.scriptrunnerr(   r)   streamlit.runtime.stater*   r+   r,   r-   r.   streamlit.delta_generatorr/   r0   rO   rn   r1   r2   r   r|   r4   rg   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rW   rC   rp   r   rq   rr   rs   rD   rE   rJ   rM   rS   rY   r]   r^   rh   r   r3   r3   r3   rI   <module>   s    (








5