U
    ARd                     @   s   d dl 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 erdd dlmZ d dlmZ ee edd	d
ZG dd dZdS )    )TYPE_CHECKINGOptionalcast)StreamlitAPIException)Alert)gather_metrics)
clean_textis_emoji)DeltaGenerator)SupportsStr)maybe_emojireturnc                 C   s,   | d krdS t | r| S td|  dd S )N zThe value "zZ" is not a valid emoji. Shortcodes are not allowed, please use a single character instead.)r	   r   )r    r   </tmp/pip-unpacked-wheel-b9et7o5g/streamlit/elements/alert.pyvalidate_emoji   s    
r   c                   @   s   e Zd Zeddddee ddddZed	dddee ddd
dZeddddee ddddZeddddee ddddZ	e
ddddZdS )
AlertMixinerrorN)iconr   r
   )bodyr   r   c                C   s0   t  }t||_t||_t j|_| jd|S )uH  Display error message.

        Parameters
        ----------
        body : str
            The error text to display.
        icon : str or None
            An optional, keyword-only argument that specifies an emoji to use as
            the icon for the alert. Shortcodes are not allowed, please use a
            single character instead. E.g. "🚨", "🔥", "🤖", etc.
            Defaults to None, which means no icon is displayed.

        Example
        -------
        >>> import streamlit as st
        >>>
        >>> st.error('This is an error', icon="🚨")

        alert)	
AlertProtor   r   r   r   ERRORformatdg_enqueueselfr   r   Zalert_protor   r   r   r   '   s
    

zAlertMixin.errorwarningc                C   s0   t  }t||_t||_t j|_| jd|S )uQ  Display warning message.

        Parameters
        ----------
        body : str
            The warning text to display.
        icon : str or None
            An optional, keyword-only argument that specifies an emoji to use as
            the icon for the alert. Shortcodes are not allowed, please use a
            single character instead. E.g. "🚨", "🔥", "🤖", etc.
            Defaults to None, which means no icon is displayed.

        Example
        -------
        >>> import streamlit as st
        >>>
        >>> st.warning('This is a warning', icon="⚠️")

        r   )	r   r   r   r   r   WARNINGr   r   r   r   r   r   r   r   G   s
    

zAlertMixin.warninginfoc                C   s0   t  }t||_t||_t j|_| jd|S )ui  Display an informational message.

        Parameters
        ----------
        body : str
            The info text to display.
        icon : str or None
            An optional, keyword-only argument that specifies an emoji to use as
            the icon for the alert. Shortcodes are not allowed, please use a
            single character instead. E.g. "🚨", "🔥", "🤖", etc.
            Defaults to None, which means no icon is displayed.

        Example
        -------
        >>> import streamlit as st
        >>>
        >>> st.info('This is a purely informational message', icon="ℹ️")

        r   )	r   r   r   r   r   INFOr   r   r   r   r   r   r   r    g   s
    

zAlertMixin.infosuccessc                C   s0   t  }t||_t||_t j|_| jd|S )uY  Display a success message.

        Parameters
        ----------
        body : str
            The success text to display.
        icon : str or None
            An optional, keyword-only argument that specifies an emoji to use as
            the icon for the alert. Shortcodes are not allowed, please use a
            single character instead. E.g. "🚨", "🔥", "🤖", etc.
            Defaults to None, which means no icon is displayed.

        Example
        -------
        >>> import streamlit as st
        >>>
        >>> st.success('This is a success message!', icon="✅")

        r   )	r   r   r   r   r   SUCCESSr   r   r   r   r   r   r   r"      s
    

zAlertMixin.success)r   c                 C   s
   t d| S )zGet our DeltaGenerator.r
   )r   )r   r   r   r   r      s    zAlertMixin.dg)__name__
__module____qualname__r   r   strr   r   r    r"   propertyr   r   r   r   r   r   &   s<    r   N)typingr   r   r   Zstreamlit.errorsr   Zstreamlit.proto.Alert_pb2r   r   Zstreamlit.runtime.metrics_utilr   Zstreamlit.string_utilr   r	   Zstreamlit.delta_generatorr
   Zstreamlit.type_utilr   r'   r   r   r   r   r   r   <module>   s   