o
    hQ                     @  s   d dl mZ d dlZd dlmZ 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mZ er>d d	lmZ G d
d dZdddZdS )    )annotationsN)Path)TYPE_CHECKINGAnycast)Html)gather_metrics)
clean_text)SupportsReprHtmlSupportsStrhas_callable_attr)DeltaGeneratorc                   @  s,   e Zd ZeddddZeddd	Zd
S )	HtmlMixinhtmlbody+str | Path | SupportsStr | SupportsReprHtmlreturnr   c                 C  s   t  }t|drtd| |_n0t|tst|r9ttd|dd}|	 |_W d   n1 s3w   Y  nt
td||_| jd|S )	a  Insert HTML into your app.

        Adding custom HTML to your app impacts safety, styling, and
        maintainability. We sanitize HTML with `DOMPurify
        <https://github.com/cure53/DOMPurify>`_, but inserting HTML remains a
        developer risk. Passing untrusted code to ``st.html`` or dynamically
        loading external code can increase the risk of vulnerabilities in your
        app.

        ``st.html`` content is **not** iframed. Executing JavaScript is not
        supported at this time.

        Parameters
        ----------
        body : any
            The HTML code to insert. This can be one of the following:

            - A string of HTML code.
            - A path to a local file with HTML code. The path can be a ``str``
              or ``Path`` object. Paths can be absolute or relative to the
              working directory (where you execute ``streamlit run``).
            - Any object. If ``body`` is not a string or path, Streamlit will
              convert the object to a string. ``body._repr_html_()`` takes
              precedence over ``str(body)`` when available.

        Example
        -------
        >>> import streamlit as st
        >>>
        >>> st.html(
        ...     "<p><span style='text-decoration: line-through double red;'>Oops</span>!</p>"
        ... )

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

        _repr_html_r
   strzutf-8)encodingNr   r   )	HtmlProtor   r   r   r   
isinstancer   _is_fileopenreadr	   dg_enqueue)selfr   
html_protof r    K/var/www/vscode/kcb/lib/python3.10/site-packages/streamlit/elements/html.pyr      s   +
zHtmlMixin.htmlc                 C  s
   t d| S )zGet our DeltaGenerator.r   )r   )r   r    r    r!   r   [   s   
zHtmlMixin.dgN)r   r   r   r   )r   r   )__name__
__module____qualname__r   r   propertyr   r    r    r    r!   r      s
    ;r   objr   r   boolc                 C  s$   zt j| W S  ty   Y dS w )zbChecks if obj is a file, and doesn't throw if not.

    The "not throwing" part is important!
    F)ospathisfile	TypeError)r&   r    r    r!   r   a   s
   r   )r&   r   r   r'   )
__future__r   r(   pathlibr   typingr   r   r   streamlit.proto.Html_pb2r   r   streamlit.runtime.metrics_utilr   streamlit.string_utilr	   streamlit.type_utilr
   r   r   streamlit.delta_generatorr   r   r   r    r    r    r!   <module>   s   C