Ë
    úmxi�  ã                  óÊ   — U d Z ddlmZ ddlmZ ddlmZmZmZm	Z	 ddl
mZ ddlmZmZ erddlmZ  ee«      Zded	<    G d
„ de«      Z G d„ de«      Zdd„Zdaded<   dd„Zy)z"Runtime-related utility functions.é    )Úannotations)Ú	getLogger)ÚTYPE_CHECKINGÚAnyÚFinalÚcast)Úconfig)ÚMarkdownFormattedExceptionÚStreamlitAPIException)Ú
ForwardMsgr   Ú_LOGGERc                  ó,   ‡ — e Zd ZdZdˆ fd„Zdd„Zˆ xZS )ÚMessageSizeErrorzNException raised when a websocket message is larger than the configured limit.c                óF   •— | j                  |«      }t        ‰| �	  |«       y )N)Ú_get_messageÚsuperÚ__init__)ÚselfÚfailed_msg_strÚmsgÚ	__class__s      €úU/home/htdocs/ttos/venv/lib/python3.12/site-packages/streamlit/runtime/runtime_util.pyr   zMessageSizeError.__init__"   s    ø€ Ø×Ñ Ó/ˆÜ‰Ñ˜Õó    c                ób   — dt        |«      dz  d›dt        «       dz  › d�j                  d«      S )Nz
**Data of size ç    €„.Az.1fz& MB exceeds the message size limit of
aÌ   MB.**

This is often caused by a large chart or dataframe. Please decrease the amount of data sent
to the browser, or increase the limit by setting the config option `server.maxMessageSize`.
[Click here to learn more about config options](https://docs.streamlit.io/develop/api-reference/configuration/config.toml).

_Note that increasing the limit may lead to long loading times and large memory consumption
of the client's browser and the Streamlit server._
ú
)ÚlenÚget_max_message_size_bytesÚstrip)r   r   s     r   r   zMessageSizeError._get_message&   sF   € ðÜ�NÓ# cÑ)¨#Ð.ð /ÜÓ Ñ#Ð $ð %ð
÷ ‰%�‹+ð	r   )r   r   ÚreturnÚNone)r   r   r    Ústr)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__classcell__)r   s   @r   r   r      s   ø„ ÙXõ÷r   r   c                  ó   — e Zd ZdZdd„Zy)ÚBadDurationStringErrorz5Raised when a bad duration argument string is passed.c                ó6   — t        j                  | d|› �«       y )NzcTTL string doesn't look right. It should be formatted as`'1d2h34m'` or `2 days`, for example. Got: )r
   r   )r   Údurations     r   r   zBadDurationStringError.__init__:   s#   € Ü"×+Ñ+Øð:Ø:B¸ðEõ	
r   N)r+   r"   r    r!   )r#   r$   r%   r&   r   © r   r   r)   r)   7   s
   „ Ù?ô
r   r)   c                óB  — | j                  «       }t        |«      t        «       kD  rxddlm} t        |«      }t        j                  d|«       |j                  | j                  j                  j                  |«       d| j                  _        | j                  «       }|S )zŒSerialize a ForwardMsg to send to a client.

    If the message is too large, it will be converted to an exception message
    instead.
    r   )Ú	exceptionzDWebsocket message size limit exceeded. Showing error to the user: %sF)ÚSerializeToStringr   r   Ústreamlit.elementsr.   r   r   ÚwarningÚmarshallÚdeltaÚnew_elementÚmetadataÚ	cacheable)r   Úmsg_strr.   Úmsg_size_errors       r   Úserialize_forward_msgr9   B   s„   € ð ×#Ñ#Ó%€Gä
ˆ7ƒ|Ô0Ó2Ò2õ 	1ä)¨'Ó2ˆÜ�‰ØRØô	
ð 	×Ñ˜3Ÿ9™9×0Ñ0×:Ñ:¸NÔKà!&ˆ�‰ÔØ×'Ñ'Ó)ˆà€Nr   Nz
int | NoneÚ_max_message_size_bytesc                 óp   — t         €!t        j                  d«      t        d«      z  a t	        dt         «      S )z�Returns the max websocket message size in bytes.

    This will lazyload the value from the config and store it in the global symbol table.
    zserver.maxMessageSizer   Úint)r:   r	   Ú
get_optionr<   r   r,   r   r   r   r   b   s4   € ô Ð&Ü"(×"3Ñ"3Ð4KÓ"LÌsÐSVËxÑ"WÐä�Ô.Ó/Ð/r   )r   r   r    Úbytes)r    r<   )r&   Ú
__future__r   Úloggingr   Útypingr   r   r   r   Ú	streamlitr	   Ústreamlit.errorsr
   r   Ústreamlit.proto.ForwardMsg_pb2r   r#   r   Ú__annotations__r   r)   r9   r:   r   r,   r   r   ú<module>rF      sb   ðò )å "å ß 2Ó 2å ß NáÝ9á˜8Ó$€ˆÓ $ôÐ1ô ô0
Ð2ô 
óð: '+Ð ˜Ó *ô
0r   