U
    ˜ARdŒ  ã                   @   s    U d dl 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 erZd dlmZ eeef Zeed< dd	„ Zee ee d
œdd„ZG dd„ dƒZdS )é    )ÚTYPE_CHECKINGÚOptionalÚUnionÚcast)Ú	TypeAlias)ÚStreamlitAPIException)ÚProgress)Ú
clean_text)ÚDeltaGeneratorÚ
FloatOrIntc                 C   s†   t | tƒr4d|   krdkr&n n| S td|  ƒ‚nNt | tƒrpd|   krRdkrbn nt| d ƒS td|  ƒ‚ntdt| ƒj ƒ‚d S )Nr   éd   z-Progress Value has invalid value [0, 100]: %dg        g      ð?z/Progress Value has invalid value [0.0, 1.0]: %fz#Progress Value has invalid type: %s)Ú
isinstanceÚintr   ÚfloatÚtypeÚ__name__)Úvalue© r   ú?/tmp/pip-unpacked-wheel-b9et7o5g/streamlit/elements/progress.pyÚ
_get_value    s    
ÿ
ÿÿr   )ÚtextÚreturnc                 C   s:   | d krd S t | tƒrt| ƒS tdtt| ƒƒ› dƒ‚d S )NzProgress Text is of type zd, which is not an accepted type.Text only accepts: str. Please convert the text to an accepted type.)r   Ústrr	   r   r   )r   r   r   r   Ú	_get_text6   s    
ÿr   c                   @   s6   e Zd Zd	eee ddœdd„Zeddœdd„ƒZdS )
ÚProgressMixinNr
   )r   r   r   c                 C   s4   t ƒ }t|ƒ|_t|ƒ}|dk	r&||_| j d|¡S )aù  Display a progress bar.

        Parameters
        ----------
        value : int or float
            0 <= value <= 100 for int

            0.0 <= value <= 1.0 for float

        text : str or None
            A message to display above the progress bar. The text 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.

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

        Example
        -------
        Here is an example of a progress bar increasing over time:

        >>> import streamlit as st
        >>> import time
        >>>
        >>> progress_text = "Operation in progress. Please wait."
        >>> my_bar = st.progress(0, text=progress_text)
        >>>
        >>> for percent_complete in range(100):
        ...     time.sleep(0.1)
        ...     my_bar.progress(percent_complete + 1, text=progress_text)

        NÚprogress)ÚProgressProtor   r   r   r   ÚdgZ_enqueue)Úselfr   r   Zprogress_protor   r   r   r   B   s    3
zProgressMixin.progress)r   c                 C   s
   t d| ƒS )zGet our DeltaGenerator.r
   )r   )r   r   r   r   r   |   s    zProgressMixin.dg)N)	r   Ú
__module__Ú__qualname__r   r   r   r   Úpropertyr   r   r   r   r   r   A   s    ÿ þ:r   N)Útypingr   r   r   r   Ztyping_extensionsr   Zstreamlit.errorsr   Zstreamlit.proto.Progress_pb2r   r   Zstreamlit.string_utilr	   Zstreamlit.delta_generatorr
   r   r   r   Ú__annotations__r   r   r   r   r   r   r   r   Ú<module>   s    