o
    沪g1                     @  s  U d dl mZ d dlZd dl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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 d dlmZmZmZmZ d dl m!Z!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. d dl/m0Z1 d dl2m3Z4 d dl5m6Z6 d dl7m8Z8m9Z9 d dl:m;Z;m<Z<m=Z=m>Z> d dl?m@Z@ d dlAmBZB erd dlCmDZD dZEdeFd< eeGeHeeejIf ZJdeFd< eG dd dZKG d d! d!ZL	d.d/d,d-ZMdS )0    )annotationsN)	dataclass)Path)dedent)TYPE_CHECKINGBinaryIOFinalLiteralTextIOUnioncast)	TypeAlias)runtime)current_form_id
is_in_form)check_widget_policies)Keycompute_and_register_element_idsave_for_app_testingto_key)StreamlitAPIExceptionStreamlitMissingPageLabelErrorStreamlitPageNotFoundError)get_main_script_directorynormalize_path_join)StreamlitPage)Button)DownloadButton)
LinkButton)PageLink)gather_metrics)ScriptRunContextget_script_run_ctx)
WidgetArgsWidgetCallbackWidgetKwargsregister_widget)validate_icon_or_emoji)is_url)DeltaGeneratorz

For more information, refer to the
[documentation for forms](https://docs.streamlit.io/develop/api-reference/execution-flow/st.form).
r   FORM_DOCS_INFOr   DownloadButtonDataTypec                   @  s"   e Zd ZdddZddddZdS )ButtonSerdevboolreturnc                 C  s   t |S N)r.   )selfr-    r2   ]/var/www/html/chatdoc2/venv/lib/python3.10/site-packages/streamlit/elements/widgets/button.py	serializeO      zButtonSerde.serialize ui_valuebool | None	widget_idstrc                 C  s   |pdS )NFr2   )r1   r7   r9   r2   r2   r3   deserializeR   r5   zButtonSerde.deserializeN)r-   r.   r/   r.   )r6   )r7   r8   r9   r:   r/   r.   )__name__
__module____qualname__r4   r;   r2   r2   r2   r3   r,   M   s    
r,   c                   @  s(  e Zd Zed					d=dddddd>ddZed							d?dddddd@d d!Zed"dddddd#dAd&d'Zed(dddddd)dBd-d.Z							d?dddddd/dCd2d3ZddddddAd4d5Z	dddddd)dBd6d7Z
			dDdddddd/dEd9d:ZedFd;d<ZdS )GButtonMixinbuttonN	secondaryF)typeicondisableduse_container_widthlabelr:   key
Key | Nonehelp
str | Noneon_clickWidgetCallback | NoneargsWidgetArgs | NonekwargsWidgetKwargs | NonerB   +Literal['primary', 'secondary', 'tertiary']rC   rD   r.   rE   r/   c                C  sJ   t |}t }|dvrtd| d| jj|||d||||	|||
|dS )u  Display a button widget.

        Parameters
        ----------
        label : str
            A short label explaining to the user what this button 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.

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

        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 when the button is hovered over. 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_click : callable
            An optional callback invoked when this button is clicked.

        args : tuple
            An optional tuple of args to pass to the callback.

        kwargs : dict
            An optional dict of kwargs to pass to the callback.

        type : "primary", "secondary", or "tertiary"
            An optional string that specifies the button type. This can be one
            of the following:

            - ``"primary"``: The button's background is the app's primary color
              for additional emphasis.
            - ``"secondary"`` (default): The button's background coordinates
              with the app's background color for normal emphasis.
            - ``"tertiary"``: The button is plain text without a border or
              background for subtly.

        icon : str or None
            An optional emoji or icon to display next to the button label. If ``icon``
            is ``None`` (default), no icon is displayed. If ``icon`` is a
            string, the following options are valid:

            - A single-character emoji. For example, you can set ``icon="🚨"``
              or ``icon="🔥"``. Emoji short codes are not supported.

            - An icon from the Material Symbols library (rounded style) in the
              format ``":material/icon_name:"`` where "icon_name" is the name
              of the icon in snake case.

              For example, ``icon=":material/thumb_up:"`` will display the
              Thumb Up icon. Find additional icons in the `Material Symbols \
              <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
              font library.

        disabled : bool
            An optional boolean that disables the button if set to ``True``.
            The default is ``False``.

        use_container_width : bool
            Whether to expand the button's width to fill its parent container.
            If ``use_container_width`` is ``False`` (default), Streamlit sizes
            the button to fit its contents. If ``use_container_width`` is
            ``True``, the width of the button matches its parent container.

            In both cases, if the contents of the button are wider than the
            parent container, the contents will line wrap.

        Returns
        -------
        bool
            True if the button was clicked on the last run of the app,
            False otherwise.

        Examples
        --------

        **Example 1: Customize your button type**

        >>> import streamlit as st
        >>>
        >>> st.button("Reset", type="primary")
        >>> if st.button("Say hello"):
        ...     st.write("Why hello there")
        ... else:
        ...     st.write("Goodbye")
        >>>
        >>> if st.button("Aloha", type="tertiary"):
        ...     st.write("Ciao")

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

        **Example 2: Add icons to your button**

        Although you can add icons to your buttons through Markdown, the
        ``icon`` parameter is a convenient and consistent alternative.

        >>> import streamlit as st
        >>>
        >>> left, middle, right = st.columns(3)
        >>> if left.button("Plain button", use_container_width=True):
        ...     left.markdown("You clicked the plain button.")
        >>> if middle.button("Emoji button", icon="😃", use_container_width=True):
        ...     middle.markdown("You clicked the emoji button.")
        >>> if right.button("Material button", icon=":material/mood:", use_container_width=True):
        ...     right.markdown("You clicked the Material button.")

        .. output::
           https://doc-button-icons.streamlit.app/
           height: 220px

        primaryrA   tertiaryzhThe type argument to st.button must be "primary", "secondary", or "tertiary". 
The argument passed was "".F)	is_form_submitterrK   rM   rO   rD   rB   rC   rE   ctx)r   r"   r   dg_button)r1   rF   rG   rI   rK   rM   rO   rB   rC   rD   rE   rW   r2   r2   r3   r@   W   s.    zButtonMixin.buttondownload_buttondatar+   	file_namemimec
                C  sD   t  }|
dvrtd|
 d| j|||||||||	|
||||dS )uU  Display a download button widget.

        This is useful when you would like to provide a way for your users
        to download a file directly from your app.

        Note that the data to be downloaded is stored in-memory while the
        user is connected, so it's a good idea to keep file sizes under a
        couple hundred megabytes to conserve memory.

        If you want to prevent your app from rerunning when a user clicks the
        download button, wrap the download button in a `fragment
        <https://docs.streamlit.io/develop/concepts/architecture/fragments>`_.

        Parameters
        ----------
        label : str
            A short label explaining to the user what this button 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.

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

        data : str or bytes or file
            The contents of the file to be downloaded. See example below for
            caching techniques to avoid recomputing this data unnecessarily.

        file_name: str
            An optional string to use as the name of the file to be downloaded,
            such as 'my_file.csv'. If not specified, the name will be
            automatically generated.

        mime : str or None
            The MIME type of the data. If None, defaults to "text/plain"
            (if data is of type *str* or is a textual *file*) or
            "application/octet-stream" (if data is of type *bytes* or is a
            binary *file*).

        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 when the button is hovered over. 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_click : callable
            An optional callback invoked when this button is clicked.

        args : tuple
            An optional tuple of args to pass to the callback.

        kwargs : dict
            An optional dict of kwargs to pass to the callback.

        type : "primary", "secondary", or "tertiary"
            An optional string that specifies the button type. This can be one
            of the following:

            - ``"primary"``: The button's background is the app's primary color
              for additional emphasis.
            - ``"secondary"`` (default): The button's background coordinates
              with the app's background color for normal emphasis.
            - ``"tertiary"``: The button is plain text without a border or
              background for subtly.

        icon : str or None
            An optional emoji or icon to display next to the button label. If ``icon``
            is ``None`` (default), no icon is displayed. If ``icon`` is a
            string, the following options are valid:

            - A single-character emoji. For example, you can set ``icon="🚨"``
              or ``icon="🔥"``. Emoji short codes are not supported.

            - An icon from the Material Symbols library (rounded style) in the
              format ``":material/icon_name:"`` where "icon_name" is the name
              of the icon in snake case.

              For example, ``icon=":material/thumb_up:"`` will display the
              Thumb Up icon. Find additional icons in the `Material Symbols \
              <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
              font library.

        disabled : bool
            An optional boolean that disables the download button if set to
            ``True``. The default is ``False``.

        use_container_width : bool
            Whether to expand the button's width to fill its parent container.
            If ``use_container_width`` is ``False`` (default), Streamlit sizes
            the button to fit its contents. If ``use_container_width`` is
            ``True``, the width of the button matches its parent container.

            In both cases, if the contents of the button are wider than the
            parent container, the contents will line wrap.

        Returns
        -------
        bool
            True if the button was clicked on the last run of the app,
            False otherwise.

        Examples
        --------
        Download a large DataFrame as a CSV:

        >>> import streamlit as st
        >>>
        >>> @st.cache_data
        ... def convert_df(df):
        ...     # IMPORTANT: Cache the conversion to prevent computation on every rerun
        ...     return df.to_csv().encode("utf-8")
        >>>
        >>> csv = convert_df(my_large_df)
        >>>
        >>> st.download_button(
        ...     label="Download data as CSV",
        ...     data=csv,
        ...     file_name="large_df.csv",
        ...     mime="text/csv",
        ... )

        Download a string as a file:

        >>> import streamlit as st
        >>>
        >>> text_contents = '''This is some text'''
        >>> st.download_button("Download some text", text_contents)

        Download a binary file:

        >>> import streamlit as st
        >>>
        >>> binary_contents = b"example content"
        >>> # Defaults to "application/octet-stream"
        >>> st.download_button("Download binary file", binary_contents)

        Download an image:

        >>> import streamlit as st
        >>>
        >>> with open("flower.png", "rb") as file:
        ...     btn = st.download_button(
        ...         label="Download image",
        ...         data=file,
        ...         file_name="flower.png",
        ...         mime="image/png",
        ...     )

        .. output::
           https://doc-download-buton.streamlit.app/
           height: 335px

        rR   zqThe type argument to st.download_button must be "primary", "secondary", or "tertiary". 
The argument passed was "rU   )rF   r[   r\   r]   rG   rI   rK   rM   rO   rB   rC   rD   rE   rW   )r"   r   _download_button)r1   rF   r[   r\   r]   rG   rI   rK   rM   rO   rB   rC   rD   rE   rW   r2   r2   r3   rZ     s0    <zButtonMixin.download_buttonlink_button)rI   rB   rC   rD   rE   urlr)   c             	   C  s0   |dvrt d| d| j|||||||dS )u  Display a link button element.

        When clicked, a new tab will be opened to the specified URL. This will
        create a new session for the user if directed within the app.

        Parameters
        ----------
        label : str
            A short label explaining to the user what this button 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.

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

        url : str
            The url to be opened on user click

        help : str or None
            A tooltip that gets displayed when the button is hovered over. 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``.

        type : "primary", "secondary", or "tertiary"
            An optional string that specifies the button type. This can be one
            of the following:

            - ``"primary"``: The button's background is the app's primary color
              for additional emphasis.
            - ``"secondary"`` (default): The button's background coordinates
              with the app's background color for normal emphasis.
            - ``"tertiary"``: The button is plain text without a border or
              background for subtly.

        icon : str or None
            An optional emoji or icon to display next to the button label. If ``icon``
            is ``None`` (default), no icon is displayed. If ``icon`` is a
            string, the following options are valid:

            - A single-character emoji. For example, you can set ``icon="🚨"``
              or ``icon="🔥"``. Emoji short codes are not supported.

            - An icon from the Material Symbols library (rounded style) in the
              format ``":material/icon_name:"`` where "icon_name" is the name
              of the icon in snake case.

              For example, ``icon=":material/thumb_up:"`` will display the
              Thumb Up icon. Find additional icons in the `Material Symbols \
              <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
              font library.

        disabled : bool
            An optional boolean that disables the link button if set to
            ``True``. The default is ``False``.

        use_container_width : bool
            Whether to expand the button's width to fill its parent container.
            If ``use_container_width`` is ``False`` (default), Streamlit sizes
            the button to fit its contents. If ``use_container_width`` is
            ``True``, the width of the button matches its parent container.

            In both cases, if the contents of the button are wider than the
            parent container, the contents will line wrap.

        Example
        -------
        >>> import streamlit as st
        >>>
        >>> st.link_button("Go to gallery", "https://streamlit.io/gallery")

        .. output::
           https://doc-link-button.streamlit.app/
           height: 200px

        rR   zmThe type argument to st.link_button must be "primary", "secondary", or "tertiary". 
The argument passed was "rU   )rF   r`   rI   rD   rB   rC   rE   )r   _link_button)r1   rF   r`   rI   rB   rC   rD   rE   r2   r2   r3   r_     s   ezButtonMixin.link_button	page_link)rF   rC   rI   rD   rE   pagestr | Path | StreamlitPager8   c                C  s   | j ||||||dS )uv  Display a link to another page in a multipage app or to an external page.

        If another page in a multipage app is specified, clicking ``st.page_link``
        stops the current page execution and runs the specified page as if the
        user clicked on it in the sidebar navigation.

        If an external page is specified, clicking ``st.page_link`` opens a new
        tab to the specified page. The current script run will continue if not
        complete.

        Parameters
        ----------
        page : str, Path, or st.Page
            The file path (relative to the main script) or an st.Page indicating
            the page to switch to. Alternatively, this can be the URL to an
            external page (must start with "http://" or "https://").

        label : str
            The label for the page link. Labels are required for external pages.
            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

        icon : str or None
            An optional emoji or icon to display next to the button label. If ``icon``
            is ``None`` (default), no icon is displayed. If ``icon`` is a
            string, the following options are valid:

            - A single-character emoji. For example, you can set ``icon="🚨"``
              or ``icon="🔥"``. Emoji short codes are not supported.

            - An icon from the Material Symbols library (rounded style) in the
              format ``":material/icon_name:"`` where "icon_name" is the name
              of the icon in snake case.

              For example, ``icon=":material/thumb_up:"`` will display the
              Thumb Up icon. Find additional icons in the `Material Symbols \
              <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
              font library.

        help : str or None
            A tooltip that gets displayed when the link is hovered over. 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``.

        disabled : bool
            An optional boolean that disables the page link if set to ``True``.
            The default is ``False``.

        use_container_width : bool
            Whether to expand the link's width to fill its parent container.
            The default is ``True`` for page links in the sidebar and ``False``
            for those in the main app.

        Example
        -------
        Consider the following example given this file structure:

        >>> your-repository/
        >>> ├── pages/
        >>> │   ├── page_1.py
        >>> │   └── page_2.py
        >>> └── your_app.py

        >>> import streamlit as st
        >>>
        >>> st.page_link("your_app.py", label="Home", icon="🏠")
        >>> st.page_link("pages/page_1.py", label="Page 1", icon="1️⃣")
        >>> st.page_link("pages/page_2.py", label="Page 2", icon="2️⃣", disabled=True)
        >>> st.page_link("http://www.google.com", label="Google", icon="🌎")

        The default navigation is shown here for comparison, but you can hide
        the default navigation using the |client.showSidebarNavigation|_
        configuration option. This allows you to create custom, dynamic
        navigation menus for your apps!

        .. |client.showSidebarNavigation| replace:: ``client.showSidebarNavigation``
        .. _client.showSidebarNavigation: https://docs.streamlit.io/develop/api-reference/configuration/config.toml#client

        .. output ::
            https://doc-page-link.streamlit.app/
            height: 350px

        )rc   rF   rC   rI   rD   rE   )
_page_link)r1   rc   rF   rC   rI   rD   rE   r2   r2   r3   rb   K  s   ozButtonMixin.page_link)rB   rC   rD   rE   rW   rW   ScriptRunContext | Nonec
                C  s   t |}t| j||d dd td|d ||||||
|d
}t| jr(tdt t }||_||_	||_
d|_|
|_t| j |||| ||_|d urQt||_|d urZt||_t }t|j|||	|j|j|dd}| jd| |jS )NF)default_valuewrites_allowedrZ   )	user_keyform_idrF   rC   r\   r]   rI   rB   rE   z7`st.download_button()` can't be used in an `st.form()`.trigger_valueon_change_handlerrM   rO   deserializer
serializerrW   
value_type)r   r   rX   r   r   r   r*   DownloadButtonProtoidrE   rF   defaultrB   marshall_file_get_delta_path_strrD   r   rI   r'   rC   r,   r&   r;   r4   _enqueuevalue)r1   rF   r[   r\   r]   rG   rI   rK   rM   rO   rB   rC   rD   rE   rW   
element_iddownload_button_protoserdebutton_stater2   r2   r3   r^     sf   


zButtonMixin._download_buttonc          	      C  sV   t  }||_||_||_||_||_|d urt||_|d ur$t||_	| j
d|S )Nr_   )LinkButtonProtorF   r`   rB   rE   rD   r   rI   r'   rC   rX   rv   )	r1   rF   r`   rI   rB   rC   rD   rE   link_button_protor2   r2   r3   ra     s   

zButtonMixin._link_buttonc                C  s  t  }t }|s| jd|S ||_|d ur||_|d ur"t||_|d ur+t||_	|d ur2||_
t|trH|j|_|j|_|d u rG|j|_n}t|trQt|}t|rm|d u s]|dkr`t ||_d|_| jd|S d}	i }
|j}	|j }
t|	}tjt||}|
 D ]#}|d }|d }||kr|d u r| dd|_|d |_||_ nq|jdkr|jd uo|jj!d	k}t"|||d
| jd|S )Nrb   r6   Tscript_path	page_name_ page_script_hash   )	is_mpa_v2rc   main_script_directory)#PageLinkProtor"   rX   rv   rD   rF   r'   rC   r   rI   rE   
isinstancer   _script_hashr   url_pathrc   titler   r:   r(   r   externalmain_script_pathpages_manager	get_pagesr   ospathrealpathr   valuesreplacempa_versionr   )r1   rc   rF   rC   rI   rD   rE   page_link_protorW   ctx_main_scriptall_app_pagesr   requested_page	page_data	full_pathr   r   r2   r2   r3   re   -  sl   







zButtonMixin._page_linkrV   c                C  s0  t |}t| j||d d| d |rt| jnd}td||||	||||d	}t rFt| jr8|s8tdt	 t| jsF|rFtdt	 t
 }||_||_d|_||_||_||_||_|
|_|d urjt||_|	d urst|	|_t }t|j||||j|j|dd	}|rt|||j | jd| |jS )
NF)rg   rh   enable_check_callback_rulesr6   r@   )ri   rj   rF   rC   rI   rV   rB   rE   z.`st.button()` can't be used in an `st.form()`.z=`st.form_submit_button()` must be used inside an `st.form()`.rk   rl   )r   r   rX   r   r   r   existsr   r   r*   ButtonProtorr   rF   rs   rV   rj   rB   rE   rD   r   rI   r'   rC   r,   r&   r;   r4   r   rw   rv   )r1   rF   rG   rI   rV   rK   rM   rO   rB   rC   rD   rE   rW   rj   rx   button_protorz   r{   r2   r2   r3   rY     st   


zButtonMixin._buttonc                 C  s
   t d| S )zGet our DeltaGenerator.r)   )r   )r1   r2   r2   r3   rX     s   
zButtonMixin.dg)NNNNN)rF   r:   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rB   rQ   rC   rJ   rD   r.   rE   r.   r/   r.   )NNNNNNN)rF   r:   r[   r+   r\   rJ   r]   rJ   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rB   rQ   rC   rJ   rD   r.   rE   r.   r/   r.   )rF   r:   r`   r:   rI   rJ   rB   rQ   rC   rJ   rD   r.   rE   r.   r/   r)   )rc   rd   rF   rJ   rC   rJ   rI   rJ   rD   r.   rE   r8   r/   r)   )rF   r:   r[   r+   r\   rJ   r]   rJ   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rB   rQ   rC   rJ   rD   r.   rE   r.   rW   rf   r/   r.   )NNN)rF   r:   rG   rJ   rI   rJ   rV   r.   rK   rL   rM   rN   rO   rP   rB   rQ   rC   rJ   rD   r.   rE   r.   rW   rf   r/   r.   )r/   r)   )r<   r=   r>   r    r@   rZ   r_   rb   r^   ra   re   rY   propertyrX   r2   r2   r2   r3   r?   V   s    	 + Tt{VY
\r?   coordinatesr:   r[   proto_download_buttonrq   mimetyperJ   r\   r/   Nonec                 C  s  t |tr| }|pd}net |tjr!| }| }|pd}nRt |tr-|}|p+d}nFt |tjrA|d |	 }|p?d}n2t |tj
rU|d | }|pSd}nt |tjrk|d | ped}|pid}ntdt| t rt jj||| |dd}nd}||_d S )	Nz
text/plainzapplication/octet-streamr       zInvalid binary data format: %sT)r\   is_for_static_downloadr6   )r   r:   encodeioTextIOWrapperreadbytesBytesIOseekgetvalueBufferedReader	RawIOBaseRuntimeErrorrB   r   r   get_instancemedia_file_mgraddr`   )r   r[   r   r   r\   data_as_bytesstring_datafile_urlr2   r2   r3   rt     sB   











	
rt   r0   )r   r:   r[   r+   r   rq   r   rJ   r\   rJ   r/   r   )N
__future__r   r   r   dataclassesr   pathlibr   textwrapr   typingr   r   r   r	   r
   r   r   typing_extensionsr   	streamlitr   !streamlit.elements.lib.form_utilsr   r   streamlit.elements.lib.policiesr   streamlit.elements.lib.utilsr   r   r   r   streamlit.errorsr   r   r   streamlit.file_utilr   r   streamlit.navigation.pager   streamlit.proto.Button_pb2r   r   "streamlit.proto.DownloadButton_pb2r   rq   streamlit.proto.LinkButton_pb2r   r|   streamlit.proto.PageLink_pb2r   r   streamlit.runtime.metrics_utilr    streamlit.runtime.scriptrunnerr!   r"   streamlit.runtime.stater#   r$   r%   r&   streamlit.string_utilr'   streamlit.url_utilr(   streamlit.delta_generatorr)   r*   __annotations__r:   r   r   r+   r,   r?   rt   r2   r2   r2   r3   <module>   sP   $
       