Ë
    úmxi!P  ã            
      ó�  — 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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mZ d d
lmZ  d dl!m"Z" d dl#m$Z$m%Z%m&Z& erd dl'm(Z( d dl)m*Z* e$e+z  dz  Z,de-d<   e$e+z  dz  Z.de-d<   e
d   Z/de-d<   e
d   Z0de-d<   e jb                  jd                  e jb                  jf                  e jb                  jh                  e jb                  jj                  e jb                  jl                  e jb                  jn                  e jb                  jp                  e jb                  jp                  e jb                  jr                  dœ	Z:de-d<   dddhe:jw                  «       £Z<de-d<    ed¬ «       G d!„ d"«      «       Z= G d#„ d$«      Z>	 	 	 	 d,d%„Z?d-d&„Z@d.d'„ZAd/d(„ZBd0d)„ZC	 	 	 	 	 	 d1d*„ZDd2d+„ZEy)3é    )Úannotations)Ú	dataclass)Údedent)ÚTYPE_CHECKINGÚAnyÚFinalÚLiteralÚ	TypeAliasÚcast)ÚOptionSequenceÚconvert_anything_to_list)ÚHeightÚLayoutConfigÚWidthÚvalidate_heightÚvalidate_width)Úmaybe_raise_label_warnings)ÚLabelVisibilityÚ get_label_visibility_proto_value)ÚStreamlitAPIExceptionÚStreamlitValueError)ÚMetric)Úgather_metrics)Ú	AnyNumberÚ
clean_textÚfrom_number)ÚDeltaGenerator)ÚNumberFormatNr
   ÚValueÚDelta)ÚnormalÚinverseÚoffÚredÚorangeÚyellowÚgreenÚblueÚvioletÚgrayÚgreyÚprimaryÚ
DeltaColor©ÚautoÚupÚdownr#   Ú
DeltaArrow)	r$   r%   r&   r'   r(   r)   r*   r+   r,   z3Final[dict[str, MetricProto.MetricColor.ValueType]]Ú_DELTA_COLOR_TO_PROTOr!   r"   r#   zFinal[set[str]]Ú_VALID_DELTA_COLORST)Úfrozenc                  ó"   — e Zd ZU ded<   ded<   y)ÚMetricColorAndDirectionz!MetricProto.MetricColor.ValueTypeÚcolorz%MetricProto.MetricDirection.ValueTypeÚ	directionN)Ú__name__Ú
__module__Ú__qualname__Ú__annotations__© ó    úP/home/htdocs/ttos/venv/lib/python3.12/site-packages/streamlit/elements/metric.pyr7   r7   T   s   … à,Ó,Ø4Ô4r?   r7   c                  óŽ   — e Zd Z ed«      	 	 ddddddddddd	œ		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd
„«       Zedd„«       Zy)ÚMetricMixinÚmetricNÚvisibleFÚstretchÚcontentÚliner/   )	ÚhelpÚlabel_visibilityÚborderÚwidthÚheightÚ
chart_dataÚ
chart_typeÚdelta_arrowÚformatc       	   
     ó^  — t        ||«       t        «       }t        |«      |_        t	        |«      |_        t        |«      |_        ||_        |�t        |«      |_
        t        t        dt        |«      «      |«      }|j                  |_        |j                  |_        t!        t        dt        |«      «      «      }|dk7  rn|dk(  r t        j"                  j$                  |_        nI|dk(  r t        j"                  j&                  |_        n$|dk(  rt        j"                  j(                  |_        t+        |«      |j,                  _        |
�Vg }t1        |
«      D ]  }	 |j3                  t5        |«      «       Œ t=        |«      dkD  r|j>                  jA                  |«       tC        |«      |_"        |�||_#        tI        |	d¬«       tK        |d¬«       tM        ||	¬«      }| jN                  jQ                  d||¬«      S # t6        $ r!}t9        d|› d	t;        |«      › d
�«      |‚d}~ww xY w)u¼-  Display a metric in big bold font, with an optional indicator of how the metric changed.

        Parameters
        ----------
        label : str
            The header or title for the metric. 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.

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

        value : int, float, decimal.Decimal, str, or None
            Value of the metric. ``None`` is rendered as a long dash.

            The value can optionally contain GitHub-flavored Markdown, subject
            to the same limitations described in the ``label`` parameter.

        delta : int, float, decimal.Decimal, str, or None
            Amount or indicator of change in the metric. An arrow is shown next
            to the delta, oriented according to its sign:

            - If the delta is ``None`` or an empty string, no arrow is shown.
            - If the delta is a negative number or starts with a minus sign,
              the arrow points down and the delta is red.
            - Otherwise, the arrow points up and the delta is green.

            You can modify the display, color, and orientation of the arrow
            using the ``delta_color`` and ``delta_arrow`` parameters.

            The delta can optionally contain GitHub-flavored Markdown, subject
            to the same limitations described in the ``label`` parameter.

        delta_color : str
            The color of the delta and chart. This can be one of the following:

            - ``"normal"`` (default): The color is red when the delta is
              negative and green otherwise.
            - ``"inverse"``: The color is green when the delta is negative and
              red otherwise. This is useful when a negative change is
              considered good, like a decrease in cost.
            - ``"off"``: The color is gray regardless of the delta.
            - A named color from the basic palette: The chart and delta are the
              specified color regardless of their value. This can be one of the
              following: ``"red"``, ``"orange"``, ``"yellow"``, ``"green"``,
              ``"blue"``, ``"violet"``, ``"gray"``/``"grey"``, or
              ``"primary"``.

        help : str or None
            A tooltip that gets displayed next to the metric 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``.

        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.

        border : bool
            Whether to show a border around the metric container. If this is
            ``False`` (default), no border is shown. If this is ``True``, a
            border is shown.

        height : "content", "stretch", or int
            The height of the metric element. This can be one of the following:

            - ``"content"`` (default): The height of the element matches the
              height of its content.
            - ``"stretch"``: The height of the element matches the height of
              its content or the height of the parent container, whichever is
              larger. If the element is not in a parent container, the height
              of the element matches the height of its content.
            - An integer specifying the height in pixels: The element has a
              fixed height. If the content is larger than the specified
              height, scrolling is enabled.

        width : "stretch", "content", or int
            The width of the metric element. This can be one of the following:

            - ``"stretch"`` (default): The width of the element matches the
              width of the parent container.
            - ``"content"``: The width of the element matches the width of its
              content, but doesn't exceed the width of the parent container.
            - An integer specifying the width in pixels: The element has a
              fixed width. If the specified width is greater than the width of
              the parent container, the width of the element matches the width
              of the parent container.

        chart_data : Iterable or None
            A sequence of numeric values to display as a sparkline chart. If
            this is ``None`` (default), no chart is displayed. The sequence can
            be anything supported by ``st.dataframe``, including a ``list`` or
            ``set``. If the sequence is dataframe-like, the first column will
            be used. Each value will be cast to ``float`` internally by
            default.

            The chart uses the color of the delta indicator, which can be
            modified using the ``delta_color`` parameter.

        chart_type : "line", "bar", or "area"
            The type of sparkline chart to display. This can be one of the
            following:

            - ``"line"`` (default): A simple sparkline.
            - ``"area"``: A sparkline with area shading.
            - ``"bar"``: A bar chart.

        delta_arrow : "auto", "up", "down", or "off"
            Controls the direction of the delta indicator arrow. This can be
            one of the following strings:

            - ``"auto"`` (default): The arrow direction follows the sign of
              ``delta``.
            - ``"up"`` or ``"down"``: The arrow is forced to point in the
              specified direction.
            - ``"off"``: No arrow is shown, but the delta value remains
              visible.

        format : str or None
            A format string controlling how numbers are displayed for ``value``
            and ``delta``. The format is only applied if the value or delta is
            numeric. If the value or delta is a string with non-numeric
            characters, the format is ignored. The format can be one of the
            following values:

            - ``None`` (default): No formatting is applied.
            - ``"plain"``: Show the full number without any formatting (e.g. "1234.567").
            - ``"localized"``: Show the number in the default locale format (e.g. "1,234.567").
            - ``"percent"``: Show the number as a percentage (e.g. "123456.70%").
            - ``"dollar"``: Show the number as a dollar amount (e.g. "$1,234.57").
            - ``"euro"``: Show the number as a euro amount (e.g. "â‚¬1,234.57").
            - ``"yen"``: Show the number as a yen amount (e.g. "Â¥1,235").
            - ``"accounting"``: Show the number in an accounting format (e.g. "1,234.00").
            - ``"bytes"``: Show the number in a byte format (e.g. "1.2KB").
            - ``"compact"``: Show the number in a compact format (e.g. "1.2K").
            - ``"scientific"``: Show the number in scientific notation (e.g. "1.235E3").
            - ``"engineering"``: Show the number in engineering notation (e.g. "1.235E3").
            - printf-style format string: Format the number with a printf
              specifier, like ``"%d"`` to show a signed integer (e.g. "1234") or
              ``"%.2f"`` to show a float with 2 decimal places.

        Examples
        --------
                **Example 1: Show a metric**

                >>> import streamlit as st
                >>>
                >>> st.metric(label="Temperature", value="70 Â°F", delta="1.2 Â°F")

                .. output::
                    https://doc-metric-example1.streamlit.app/
                    height: 210px

                **Example 2: Create a row of metrics**

                ``st.metric`` looks especially nice in combination with ``st.columns``.

                >>> import streamlit as st
                >>>
                >>> col1, col2, col3 = st.columns(3)
                >>> col1.metric("Temperature", "70 Â°F", "1.2 Â°F")
                >>> col2.metric("Wind", "9 mph", "-8%")
                >>> col3.metric("Humidity", "86%", "4%")

                .. output::
                    https://doc-metric-example2.streamlit.app/
                    height: 210px

                **Example 3: Modify the delta indicator**

                The delta indicator color can also be inverted or turned off.

                >>> import streamlit as st
                >>>
                >>> st.metric(
                ...     label="Gas price", value=4, delta=-0.5, delta_color="inverse"
                ... )
                >>>
                >>> st.metric(
                ...     label="Active developers",
                ...     value=123,
                ...     delta=123,
                ...     delta_color="off",
                ... )

                .. output::
                    https://doc-metric-example3.streamlit.app/
                    height: 320px

                **Example 4: Create a grid of metric cards**

                Add borders to your metrics to create a dashboard look.

                >>> import streamlit as st
                >>>
                >>> a, b = st.columns(2)
                >>> c, d = st.columns(2)
                >>>
                >>> a.metric("Temperature", "30Â°F", "-9Â°F", border=True)
                >>> b.metric("Wind", "4 mph", "2 mph", border=True)
                >>>
                >>> c.metric("Humidity", "77%", "5%", border=True)
                >>> d.metric("Pressure", "30.34 inHg", "-2 inHg", border=True)

                .. output::
                    https://doc-metric-example4.streamlit.app/
                    height: 350px

                **Example 5: Show sparklines**

                To show trends over time, add sparklines.

                >>> import streamlit as st
                >>> from numpy.random import default_rng as rng
                >>>
                >>> changes = list(rng(4).standard_normal(20))
                >>> data = [sum(changes[:i]) for i in range(20)]
                >>> delta = round(data[-1], 2)
                >>>
                >>> row = st.container(horizontal=True)
                >>> with row:
                >>>     st.metric(
                ...         "Line", 10, delta, chart_data=data, chart_type="line", border=True
                ...     )
                >>>     st.metric(
                ...         "Area", 10, delta, chart_data=data, chart_type="area", border=True
                ...     )
                >>>     st.metric(
                ...         "Bar", 10, delta, chart_data=data, chart_type="bar", border=True
                ...     )

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

        Nr-   r2   r/   r#   r0   r1   zFOnly numeric values are supported for chart data sequence. The value 'ú' is of type z" and cannot be converted to float.r   T)Úallow_content)rK   rL   rC   )Úlayout_config))r   ÚMetricProtoÚ_parse_valueÚbodyÚ_parse_labelÚlabelÚ_parse_deltaÚdeltaÚshow_borderr   rH   Ú$_determine_delta_color_and_directionr   r   r8   r9   Ú_parse_delta_arrowÚMetricDirectionÚNONEÚUPÚDOWNr   rI   Úvaluer   ÚappendÚfloatÚ	Exceptionr   ÚtypeÚlenrM   ÚextendÚ_parse_chart_typerN   rP   r   r   r   ÚdgÚ_enqueue)ÚselfrY   rc   r[   Údelta_colorrH   rI   rJ   rK   rL   rM   rN   rO   rP   Úmetric_protoÚcolor_and_directionÚparsed_delta_arrowÚprepared_dataÚvalÚexrT   s                        r@   rC   zMetricMixin.metric[   s  € ôX 	# 5Ð*:Ô;ä"“}ˆÜ(¨Ó/ˆÔÜ)¨%Ó0ˆÔÜ)¨%Ó0ˆÔØ#)ˆÔ ØÐÜ & t£ˆLÔäBÜ�œz¨+Ó6Ó7¸ó
Ðð 1×6Ñ6ˆÔØ!4×!>Ñ!>ˆÔÜ/Ü�œz¨+Ó6Ó7ó
Ðð  Ò'Ø! UÒ*Ü)4×)DÑ)D×)IÑ)I�Õ&Ø# tÒ+Ü)4×)DÑ)D×)GÑ)G�Õ&Ø# vÒ-Ü)4×)DÑ)D×)IÑ)I�Ô&Ü.NØó/
ˆ×%Ñ%Ô+ð Ð!Ø)+ˆMÜ/°
Ó;ò �ðØ!×(Ñ(¬¨s«Õ4ðô �=Ó! AÒ%Ø×'Ñ'×.Ñ.¨}Ô=ä"3°JÓ"?ˆÔàÐØ"(ˆLÔä˜¨dÕ3Ü�u¨DÕ1Ü$¨5¸Ô@ˆà�w‰w×Ñ ¨,ÀmÐÓTÐTøô% !ò Ü/ð"Ø"%  m´D¸³I°;ð ?8ð8óð ð	ûðús   ÅHÈ	H,ÈH'È'H,c                ó   — t        d| «      S )Nr   )r   )rm   s    r@   rk   zMetricMixin.dgž  s   € äÐ$ dÓ+Ð+r?   )Nr!   )rY   Ústrrc   r   r[   r    rn   r-   rH   z
str | NonerI   r   rJ   ÚboolrK   r   rL   r   rM   zOptionSequence[Any] | NonerN   úLiteral['line', 'bar', 'area']rO   r2   rP   zstr | NumberFormat | NoneÚreturnr   )ry   r   )r:   r;   r<   r   rC   Úpropertyrk   r>   r?   r@   rB   rB   Z   s  „ Ù�HÓð
 Ø"*ð@Uð  Ø,5ØØ Ø"Ø15Ø5;Ø"(Ø,0ñ@Uàð@Uð ð@Uð ð	@Uð
  ð@Uð ð@Uð *ð@Uð ð@Uð ð@Uð ð@Uð /ð@Uð 3ð@Uð  ð@Uð *ð@Uð  
ò!@Uó ð@UðD
 ò,ó ñ,r?   rB   c                ó²   — | dk(  rt         j                  j                  S | dk(  rt         j                  j                  S t         j                  j                  S )NÚbarÚarea)rU   Ú	ChartTypeÚBARÚAREAÚLINE)rN   s    r@   rj   rj   £  sJ   € ð �UÒÜ×$Ñ$×(Ñ(Ð(Ø�VÒÜ×$Ñ$×)Ñ)Ð)ä× Ñ ×%Ñ%Ð%r?   c                ó*   — | dvrt        dg d¢«      ‚| S )N>   r0   r#   r/   r1   rO   r.   )r   )rO   s    r@   r^   r^   ®  s   € ØÐ7Ñ7Ü! -Ò1NÓOÐOØÐr?   c                ó\   — t        | t        «      st        d| › dt        | «      › d�«      ‚| S )Nú'rR   zg, which is not an accepted type. label only accepts: str. Please convert the label to an accepted type.)Ú
isinstancerv   Ú	TypeErrorrg   )rY   s    r@   rX   rX   ´  s=   € Ü�eœSÔ!ÜØ�ˆw�m¤D¨£K =ð 1Vð Vó
ð 	
ð €Lr?   c                óB   — | €yt        | t        «      r| S t        | «      S )Nu   â€”)r…   rv   r   )rc   s    r@   rV   rV   ½  s$   € Ø€}ØÜ�%œÔØˆÜ�uÓÐr?   c                ó^   — | �| dk(  ryt        | t        «      rt        | «      S t        | «      S )NÚ )r…   rv   r   r   ©r[   s    r@   rZ   rZ   Å  s/   € Ø€}˜ šØÜ�%œÔÜ�e‹}ÐÜ�uÓÐr?   c                óæ  — | t         vrt        d| › d�«      ‚|�|dk(  r=t        t        j                  j
                  t        j                  j                  ¬«      S t        |«      rt        j                  j                  nt        j                  j                  }| t        v rt        t        |    |¬«      S |t        j                  j                  k(  }| dk(  r7|rt        j                  j                  nt        j                  j                  }nV| dk(  r7|rt        j                  j                  nt        j                  j                  }nt        j                  j
                  }t        ||¬«      S )Nr„   z²' is not an accepted value. delta_color only accepts: 'normal', 'inverse', 'off', or a color name ('red', 'orange', 'yellow', 'green', 'blue', 'violet', 'gray'/'grey', 'primary')r‰   )r8   r9   r!   r"   )r4   r   r7   rU   ÚMetricColorÚGRAYr_   r`   Ú_is_negative_deltarb   ra   r3   ÚREDÚGREEN)rn   r[   Úcd_directionÚis_negativeÚcd_colors        r@   r]   r]   Í  s[  € ð Ô-Ñ-Ü#Ø�ˆ}ð Cð Có
ð 	
ð €}˜ šÜ&Ü×)Ñ)×.Ñ.Ü!×1Ñ1×6Ñ6ô
ð 	
ô ˜eÔ$ô 	×#Ñ#×(Ò(ä×(Ñ(×+Ñ+ð ð Ô+Ñ+Ü&Ü'¨Ñ4Ø"ô
ð 	
ð ¤+×"=Ñ"=×"BÑ"BÑB€KØ�hÒñ ô ×#Ñ#×'Ò'ä×(Ñ(×.Ñ.ñ 	ð
 
˜	Ò	!ñ ô ×#Ñ#×)Ò)ä×(Ñ(×,Ñ,ñ 	ô ×*Ñ*×/Ñ/ˆä"ØØôð r?   c                óH   — t        t        | «      «      j                  d«      S )Nú-)r   rv   Ú
startswithrŠ   s    r@   rŽ   rŽ     s   € Ü”#�e“*Ó×(Ñ(¨Ó-Ð-r?   )rN   rx   ry   zMetricProto.ChartType.ValueType)rO   r2   ry   r2   )rY   rv   ry   rv   )rc   r   ry   rv   )r[   r    ry   rv   )rn   r-   r[   r    ry   r7   )r[   r    ry   rw   )FÚ
__future__r   Údataclassesr   Útextwrapr   Útypingr   r   r   r	   r
   r   Ústreamlit.dataframe_utilr   r   Ú#streamlit.elements.lib.layout_utilsr   r   r   r   r   Ústreamlit.elements.lib.policiesr   Ústreamlit.elements.lib.utilsr   r   Ústreamlit.errorsr   r   Ústreamlit.proto.Metric_pb2r   rU   Ústreamlit.runtime.metrics_utilr   Ústreamlit.string_utilr   r   r   Ústreamlit.delta_generatorr   Ú#streamlit.elements.lib.column_typesr   rv   r   r=   r    r-   r2   rŒ   r�   ÚORANGEÚYELLOWr�   ÚBLUEÚVIOLETr�   ÚPRIMARYr3   Úkeysr4   r7   rB   rj   r^   rX   rV   rZ   r]   rŽ   r>   r?   r@   ú<module>r«      sÙ  ðö #å !Ý ß F× Fç M÷õ õ G÷÷ HÝ <Ý 9ß DÑ DáÝ8Ý@ð ˜s‘? TÑ)€€yÓ )Ø˜s‘? TÑ)€€yÓ )Øðñ€
ˆIó ð  Ð ;Ñ<€
ˆIÓ <ð ×"Ñ"×&Ñ&Ø×%Ñ%×,Ñ,Ø×%Ñ%×,Ñ,Ø×$Ñ$×*Ñ*Ø×#Ñ#×(Ñ(Ø×%Ñ%×,Ñ,Ø×#Ñ#×(Ñ(Ø×#Ñ#×(Ñ(Ø×&Ñ&×.Ñ.ñ
NÐ ÐJó 
ð ØØ	ð(ð ×ÑÓ!ð	(Ð �_ó ñ �$Ô÷5ð 5ó ð5÷
F,ñ F,ðR
&Ø.ð&à$ó&óóóóð3Øð3àð3ð ó3ôl.r?   