Ë
    EêñiÎ  ã                  ó„  — U d dl mZ d dlZd dlZd dlZd dl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c 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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' d dl(m)Z) d dl*m+Z+ d dl,m-Z-m.Z. d dl/m0Z0 d dl1m2Z2 d dl3m4Z4m5Z5m6Z6 d dl7m8Z8 d dl9m:Z: d dl;m<Z< d dl=m>Z> d dl?m@Z@ e
r:d dlAmBZB d dlCmDZD d dlEmFZFmGZG d dlHmIZI d dlJmKZK d dlLmMZM d dlNmOZO d dlPmQZQ d d lRmSZSmTZT  eeU«      ZVd!eWd"<    G d#„ d$e«      ZXd.d%„ZY G d&„ d'«      ZZd/d(„Z[d0d)„Z\d1d*„Z]	 d2	 	 	 	 	 	 	 	 	 d3d+„Z^d4d5d,„Z_d6d-„Z`y)7é    )ÚannotationsN)ÚEnum)ÚTYPE_CHECKINGÚAnyÚFinal)Ú	ParseDict)ÚconfigÚenv_utilÚruntime)Ú
get_logger)ÚClientState)ÚFileURLsÚFileURLsRequest)Ú
ForwardMsg)ÚGitInfo)ÚConfigÚCustomThemeConfigÚFontFaceÚ
NewSessionÚUserInfo)Úcaching)ÚForwardMsgQueue)ÚFragmentStorageÚMemoryFragmentStorage)ÚInstallation)ÚPagesManager)Ú	RerunDataÚScriptRunnerÚScriptRunnerEvent)Úsecrets_singleton)Úparse_fonts_with_source)Úto_snake_case)ÚSTREAMLIT_VERSION_STRING)ÚLocalSourcesWatcher)ÚCallable)ÚRepeatedScalarFieldContainer)ÚBackMsgÚDeferredFileRequest)Ú
ScriptData)ÚScriptCache)ÚUserInfoType©ÚSessionState)ÚUploadedFileManager)ÚPageHashÚPageInfor   Ú_LOGGERc                  ó   — e Zd ZdZdZdZy)ÚAppSessionStateÚAPP_NOT_RUNNINGÚAPP_IS_RUNNINGÚSHUTDOWN_REQUESTEDN)Ú__name__Ú
__module__Ú__qualname__r4   r5   r6   © ó    ú_/var/www/pod-logistic/pod-ai/venv/lib/python3.12/site-packages/streamlit/runtime/app_session.pyr3   r3   E   s   „ Ø'€OØ%€NØ-Ñr;   r3   c                 ó<   — t        t        j                  «       «      S )z5Randomly generate a unique ID for a script execution.)ÚstrÚuuidÚuuid4r:   r;   r<   Ú_generate_scriptrun_idrA   K   s   € äŒt�z‰z‹|ÓÐr;   c                  óæ  — e Zd ZdZ	 d&	 	 	 	 	 	 	 	 	 	 	 	 	 d'd„Zd(d„Zd(d„Zd(d„Zd(d„Zd)d„Z	d(d	„Z
d*d
„Zd+d„Zd,d„Zd-d„Zd(d„Zd(d„Zd.d„Zed/d„«       Zd0d„Zd&d1d„Zd2d„Zd&d3d„Z	 	 	 	 	 	 d4	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d5d„Z	 	 	 	 	 	 d4	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d5d„Zd6d„Zd6d„Z	 	 d7	 	 	 	 	 	 	 d8d„Z	 	 	 	 d9d„Zd:d„Zd(d„Z	 d&	 	 	 d-d„Z d(d„Z!d(d „Z"d(d!„Z#d;d"„Z$d<d#„Z%d=d$„Z&	 	 	 	 	 	 d>d%„Z'y)?Ú
AppSessiona!  
    Contains session data for a single "user" of an active app
    (that is, a connected browser tab).

    Each AppSession has its own ScriptData, root DeltaGenerator, ScriptRunner,
    and widget state.

    An AppSession is attached to each thread involved in running its script.

    Nc                óÄ  — |xs t        t        j                  «       «      | _        t	        j
                  «       | _        || _        || _        || _	        t        |j                  | j                  «      | _        t        «       | _        || _        t         j"                  | _        t'        «       | _        d| _        d| _        d| _        t1        j2                  d«      dk7  r| j5                  «        t1        j2                  d«      | _        d| _        ddlm}  |«       | _        || _         d| _!        tE        «       | _#        tH        jK                  d| j                  «       y)aþ  Initialize the AppSession.

        Parameters
        ----------
        script_data
            Object storing parameters related to running a script

        uploaded_file_manager
            Used to manage files uploaded by users via the Streamlit web client.

        script_cache
            The app's ScriptCache instance. Stores cached user scripts. ScriptRunner
            uses the ScriptCache to avoid having to reload user scripts from disk
            on each rerun.

        message_enqueued_callback
            After enqueuing a message, this callable notification will be invoked.

        user_info
            A dict that contains information about the current user. For now,
            it only contains the user's email address.

            {
                "email": "example@example.com"
            }

            Information about the current user is optionally provided when a
            websocket connection is initialized via the "X-Streamlit-User" header.

        session_id_override
            The ID to assign to this session. Setting this can be useful when the
            service that a Streamlit Runtime is running in wants to tie the lifecycle of
            a Streamlit session to some other session-like object that it manages.
        Nzserver.fileWatcherTypeÚnonezserver.runOnSaver   r,   zAppSession initialized (id=%s))&r>   r?   r@   ÚidÚasyncioÚget_running_loopÚ_event_loopÚ_script_dataÚ_uploaded_file_mgrÚ_script_cacher   Úmain_script_pathÚ_pages_managerr   Ú_browser_queueÚ_message_enqueued_callbackr3   r4   Ú_stater   Ú_client_stateÚ_local_sources_watcherÚ_stop_config_listenerÚ_stop_pages_listenerr	   Ú
get_optionÚregister_file_watchersÚ_run_on_saveÚ_scriptrunnerÚstreamlit.runtime.stater-   Ú_session_stateÚ
_user_infoÚ_debug_last_backmsg_idr   Ú_fragment_storager1   Údebug)ÚselfÚscript_dataÚuploaded_file_managerÚscript_cacheÚmessage_enqueued_callbackÚ	user_infoÚsession_id_overrider-   s           r<   Ú__init__zAppSession.__init__\   s!  € ðZ &Ò:¬¬T¯Z©Z«\Ó):ˆŒä"×3Ñ3Ó5ˆÔØ'ˆÔØ"7ˆÔØ)ˆÔÜ*Ø×(Ñ(¨$×*<Ñ*<ó
ˆÔô .Ó/ˆÔØ*CˆÔ'ä%×5Ñ5ˆŒô )›]ˆÔàBFˆÔ#Ø@DˆÔ"Ø?CˆÔ!ä×ÑÐ5Ó6¸&Ò@Ø×'Ñ'Ô)ä"×-Ñ-Ð.@ÓAˆÔà26ˆÔõ 	9á*›nˆÔØ#ˆŒà26ˆÔ#ä2GÓ2IˆÔä�‰Ð6¸¿¹Õ@r;   c                ó$   — | j                  «        y)zGEnsure that we call shutdown() when an AppSession is garbage collected.N)Úshutdown©r`   s    r<   Ú__del__zAppSession.__del__¶   s   € à�‰�r;   c                ó8  — | j                   €t        | j                  «      | _         | j                   j                  | j                  «       t        j                  | j                  d¬«      | _        t        j                  j                  | j                  «       y)a4  Register handlers to be called when various files are changed.

        Files that we watch include:
          - source files that already exist (for edits)
          - `.py` files in the main script's `pages/` directory (for file additions
            and deletions)
          - project and user-level config.toml files
          - the project-level secrets.toml files

        This method is called automatically on AppSession construction, but it may be
        called again in the case when a session is disconnected and is being reconnect
        to.
        NT)Úforce_connect)rS   r$   rN   Úregister_file_change_callbackÚ_on_source_file_changedr	   Úon_config_parsedrT   r    Úfile_change_listenerÚconnectÚ_on_secrets_file_changedrj   s    r<   rW   z!AppSession.register_file_watchersº   s|   € ð ×&Ñ&Ð.Ü*=¸d×>QÑ>QÓ*RˆDÔ'à×#Ñ#×AÑAØ×(Ñ(ô	
ô &,×%<Ñ%<Ø×(Ñ(¸ô&
ˆÔ"ô 	×.Ñ.×6Ñ6°t×7TÑ7TÕUr;   c                ó<  — | j                   �| j                   j                  «        | j                  �| j                  «        | j                  �| j                  «        t        j
                  j                  | j                  «       d| _         d| _        d| _        y)zJDisconnect the file watcher handlers registered by register_file_watchers.N)rS   ÚcloserT   rU   r    rq   Ú
disconnectrs   rj   s    r<   Údisconnect_file_watchersz#AppSession.disconnect_file_watchersÓ   s‚   € à×&Ñ&Ð2Ø×'Ñ'×-Ñ-Ô/Ø×%Ñ%Ð1Ø×&Ñ&Ô(Ø×$Ñ$Ð0Ø×%Ñ%Ô'ä×.Ñ.×9Ñ9¸$×:WÑ:WÔXà&*ˆÔ#Ø%)ˆÔ"Ø$(ˆÕ!r;   c                ó€   — t        j                  | j                  «       t        j                  | j                  «       y)z×Clears session-level caches for this session.

        This should be called when a session is disconnected or shut down, since this
        ensures memory is freed up and resource release hooks are called.
        N)r   Úclear_session_data_cacherF   Úclear_session_resource_cacherj   s    r<   Úclear_session_cacheszAppSession.clear_session_cachesâ   s(   € ô 	×(Ñ(¨¯©Ô1Ü×,Ñ,¨T¯W©WÕ5r;   c                ó6   — | j                   j                  «       S )ai  Clear the forward message queue and return the messages it contained.

        The Server calls this periodically to deliver new messages
        to the browser connected to this app.

        Returns
        -------
        list[ForwardMsg]
            The messages that were removed from the queue and should
            be delivered to the browser.

        )rO   Úflushrj   s    r<   Úflush_browser_queuezAppSession.flush_browser_queueë   s   € ð ×"Ñ"×(Ñ(Ó*Ð*r;   c                ó"  — | j                   t        j                  k7  ròt        j	                  d| j
                  «       | j                  j                  | j
                  «       t        j                  «       rSt        j                  «       }|j                  j                  | j
                  «       |j                  j                  «        | j                  «        t        j                  | _         | j                  «        | j!                  «        yy)ziShut down the AppSession.

        It's an error to use a AppSession after it's been shut down.

        zShutting down (id=%s)N)rQ   r3   r6   r1   r_   rF   rK   Úremove_session_filesr   ÚexistsÚget_instanceÚmedia_file_mgrÚclear_session_refsÚremove_orphaned_filesÚrequest_script_stoprw   r{   )r`   Úrts     r<   ri   zAppSession.shutdownú   sÁ   € ð �;‰;œ/×<Ñ<Ò<Ü�M‰MÐ1°4·7±7Ô;ð ×#Ñ#×8Ñ8¸¿¹ÔAä�~‰~ÔÜ×)Ñ)Ó+�Ø×!Ñ!×4Ñ4°T·W±WÔ=Ø×!Ñ!×7Ñ7Ô9ð
 ×$Ñ$Ô&ä)×<Ñ<ˆDŒKð ×)Ñ)Ô+ð ×%Ñ%Õ'ð/ =r;   c                ó®   — | j                   r| j                   |_        | j                  j                  |«       | j                  r| j	                  «        yy)zöEnqueue a new ForwardMsg to our browser queue.

        This can be called on both the main thread and a ScriptRunner
        run thread.

        Parameters
        ----------
        msg : ForwardMsg
            The message to enqueue

        N)r]   Údebug_last_backmsg_idrO   ÚenqueuerP   ©r`   Úmsgs     r<   Ú_enqueue_forward_msgzAppSession._enqueue_forward_msg  sI   € ð ×&Ò&Ø(,×(CÑ(CˆCÔ%à×Ñ×#Ñ# CÔ(Ø×*Ò*Ø×+Ñ+Õ-ð +r;   c                ó4  — 	 |j                  d«      }|dk(  r9|j                  r|j                  | _        | j                  |j                  «       y|dk(  r| j                  «        y|dk(  r| j                  «        y|dk(  r| j                  «        y|dk(  r| j                  |j                  «       y|dk(  r| j                  «        y|dk(  r| j                  |j                  «       y|d	k(  rWt        j                  | j                  |j                   «      «      }|j#                  d
|j                   j$                  › �«       yt&        j)                  d|«       y# t*        $ r0}t&        j-                  d«       | j/                  |«       Y d}~yd}~ww xY w)zProcess a BackMsg.ÚtypeÚrerun_scriptÚload_git_infoÚclear_cacheÚapp_heartbeatÚset_run_on_saveÚstop_scriptÚfile_urls_requestÚdeferred_file_requestÚdeferred_file_zNo handler for "%s"zError processing back messageN)Ú
WhichOneofr‰   r]   Ú_handle_rerun_script_requestr�   Ú_handle_git_information_requestÚ_handle_clear_cache_requestÚ_handle_app_heartbeat_requestÚ_handle_set_run_on_save_requestr”   Ú_handle_stop_script_requestÚ_handle_file_urls_requestr–   rG   Úcreate_taskÚ_handle_deferred_file_requestr—   Úset_nameÚfile_idr1   ÚwarningÚ	ExceptionÚ	exceptionÚhandle_backmsg_exception)r`   rŒ   Úmsg_typeÚtaskÚexs        r<   Úhandle_backmsgzAppSession.handle_backmsg-  sb  € ð!	.Ø—~‘~ fÓ-ˆHØ˜>Ò)Ø×,Ò,Ø25×2KÑ2K�DÔ/à×1Ñ1°#×2BÑ2BÕCØ˜_Ò,Ø×4Ñ4Õ6Ø˜]Ò*Ø×0Ñ0Õ2Ø˜_Ò,Ø×2Ñ2Õ4ØÐ.Ò.Ø×4Ñ4°S×5HÑ5HÕIØ˜]Ò*Ø×0Ñ0Õ2ØÐ0Ò0Ø×.Ñ.¨s×/DÑ/DÕEØÐ4Ò4ô ×*Ñ*Ø×6Ñ6°s×7PÑ7PÓQó�ð —‘ ¨s×/HÑ/H×/PÑ/PÐ.QÐRÕSä—‘Ð 5°xÕ@øäò 	.Ü×ÑÐ=Ô>Ø×)Ñ)¨"×-Ñ-ûð	.úsI   ‚AE ÁE Á'E Á=E Â E Â4E Ã
 E Ã+AE ÅE Å	FÅ'&FÆFc                óF  ‡ ‡— ‰ j                  ‰ j                  t        j                  «       ‰ j                  ‰ j                  t        j                  d¬«       ‰ j                  ‰ j                  t        j                  «       ‰ j
                  j                  ˆˆ fd„«       y)zGHandle an Exception raised while processing a BackMsg from the browser.Ú )Úpage_script_hashc                 óD   •— ‰j                  ‰j                  ‰ «      «      S ©N)r�   Ú_create_exception_message)Úer`   s   €€r<   ú<lambda>z5AppSession.handle_backmsg_exception.<locals>.<lambda>l  s   ø€ �D×-Ñ-¨d×.LÑ.LÈQÓ.OÓP€ r;   N)Ú_on_scriptrunner_eventrY   r   ÚSCRIPT_STOPPED_WITH_SUCCESSÚSCRIPT_STARTEDrI   Úcall_soon_threadsafe)r`   r³   s   ``r<   r¨   z#AppSession.handle_backmsg_exceptionR  sŠ   ù€ ð 	×#Ñ#Ø×ÑÔ 1× MÑ Mô	
ð 	×#Ñ#Ø×ÑÜ×,Ñ,Øð 	$ô 	
ð
 	×#Ñ#Ø×ÑÔ 1× MÑ Mô	
ð 	×Ñ×-Ñ-ÜPõ	
r;   c                ó^  — | j                   t        j                  k(  rt        j	                  d«       y|rç|j
                  }|r2| j                  j                  |«      st        j                  d|«       y|j                  d«      r/| j                  j                  j                  |j                  «       t        |j                  |j                  |j                   |j"                  |xs d|j$                  t'        |j(                  «      |j                  ¬«      }n
t        «       }| j*                  �jt-        t/        j0                  d«      «      r.|j
                  s"| j*                  j3                  «        d| _        n| j*                  j5                  |«      }|ry| j7                  |«       y)aš  Signal that we're interested in running the script.

        If the script is not already running, it will be started immediately.
        Otherwise, a rerun will be requested.

        Parameters
        ----------
        client_state : streamlit.proto.ClientState_pb2.ClientState | None
            The ClientState protobuf to run the script with, or None
            to use previous client state.

        z'Discarding rerun request after shutdownNznThe fragment with id %s does not exist anymore - it might have been removed during a preceding full-app rerun.Úcontext_info)Úquery_stringÚwidget_statesr¯   Ú	page_nameÚfragment_idÚis_auto_rerunÚcached_message_hashesrº   zrunner.fastReruns)rQ   r3   r6   r1   r¥   r¾   r^   ÚcontainsÚinfoÚHasFieldrR   rº   ÚCopyFromr   r»   r¼   r¯   r½   r¿   ÚsetrÀ   rY   Úboolr	   rV   Úrequest_stopÚrequest_rerunÚ_create_scriptrunner)r`   Úclient_stater¾   Ú
rerun_dataÚsuccesss        r<   rÈ   zAppSession.request_reruno  sf  € ð �;‰;œ/×<Ñ<Ò<Ü�O‰OÐEÔFØáØ&×2Ñ2ˆKñ"  4×#9Ñ#9×#BÑ#BÀ;Ô#OÜ—‘ðTàôð
 à×$Ñ$ ^Ô4Ø×"Ñ"×/Ñ/×8Ñ8¸×9RÑ9RÔSä"Ø)×6Ñ6Ø*×8Ñ8Ø!-×!>Ñ!>Ø&×0Ñ0Ø'Ò/¨4Ø*×8Ñ8Ü&)¨,×*LÑ*LÓ&MØ)×6Ñ6ô	‰Jô #›ˆJà×ÑÐ)ä”V×&Ñ&Ð':Ó;Ô<Ø"×.Ò.ð ×"Ñ"×/Ñ/Ô1Ø%)�Õ"ð
 ×,Ñ,×:Ñ:¸:ÓF�ÙØð
 	×!Ñ! *Õ-r;   c                óR   — | j                   �| j                   j                  «        yy)zgRequest that the scriptrunner stop execution.

        Does nothing if no scriptrunner exists.
        N)rY   rÇ   rj   s    r<   r†   zAppSession.request_script_stopÃ  s'   € ð
 ×ÑÐ)Ø×Ñ×+Ñ+Õ-ð *r;   c                ó8   — | j                   j                  «        y)z%Clear the user info for this session.N)r\   Úclearrj   s    r<   Úclear_user_infozAppSession.clear_user_infoË  s   € à�‰×ÑÕr;   c                ó|  — t        | j                  | j                  j                  | j                  | j
                  | j                  || j                  | j                  | j                  ¬«	      | _
        | j                  j                  j                  | j                  «       | j                  j                  «        y)z;Create and run a new ScriptRunner with the given RerunData.)	Ú
session_idrM   Úsession_stateÚuploaded_file_mgrrc   Úinitial_rerun_datare   Úfragment_storageÚpages_managerN)r   rF   rJ   rM   r[   rK   rL   r\   r^   rN   rY   Úon_eventrr   rµ   Ústart)r`   rÕ   s     r<   rÉ   zAppSession._create_scriptrunnerÏ  s�   € ä)Ø—w‘wØ!×.Ñ.×?Ñ?Ø×-Ñ-Ø"×5Ñ5Ø×+Ñ+Ø1Ø—o‘oØ!×3Ñ3Ø×-Ñ-ô

ˆÔð 	×Ñ×#Ñ#×+Ñ+¨D×,GÑ,GÔHØ×Ñ× Ñ Õ"r;   c                ó   — | j                   S r±   )r[   rj   s    r<   rÓ   zAppSession.session_stateß  s   € à×"Ñ"Ð"r;   c                óª   ‡‡— | j                   j                  «       Št        t        ˆˆfd„‰«      d «      }|�| j                  j
                  }||k(  S y)Nc                ó   •— ‰|    d   ‰k(  S )NÚscript_pathr:   )ÚkÚfilepathÚpagess    €€r<   r´   z9AppSession._should_rerun_on_file_change.<locals>.<lambda>ç  s   ø€ ˜U 1™X mÑ4¸Ñ@€ r;   T)rN   Ú	get_pagesÚnextÚfilterrR   r¯   )r`   rß   Úchanged_page_script_hashÚcurrent_page_script_hashrà   s    `  @r<   Ú_should_rerun_on_file_changez'AppSession._should_rerun_on_file_changeã  sY   ù€ Ø×#Ñ#×-Ñ-Ó/ˆä#'ÜÔ@À%ÓHØó$
Ð ð
 $Ð/Ø'+×'9Ñ'9×'JÑ'JÐ$Ø+Ð/GÑGÐGàr;   c                óî   — | j                   j                  «        |�| j                  |«      sy| j                  r| j	                  | j
                  «       y| j                  | j                  «       «       y)zfOne of our source files changed. Clear the cache and schedule a rerun if
        appropriate.
        N)rL   rÏ   ræ   rX   rÈ   rR   r�   Ú_create_file_change_message)r`   rß   s     r<   ro   z"AppSession._on_source_file_changedñ  s`   € ð 	×Ñ× Ñ Ô"àÐ¨×(IÑ(IÈ(Ô(SØà×ÒØ×Ñ˜t×1Ñ1Õ2à×%Ñ% d×&FÑ&FÓ&HÕIr;   c                ó$   — | j                  «        y)z:Called when `secrets.file_change_listener` emits a Signal.N)ro   )r`   Ú_s     r<   rs   z#AppSession._on_secrets_file_changedÿ  s   € ð 	×$Ñ$Õ&r;   c                ó>   — | j                   j                  d|¬«       y )NT)Úretain_lifecycle_msgsÚfragment_ids_this_run)rO   rÏ   )r`   rí   s     r<   Ú_clear_queuezAppSession._clear_queue  s!   € Ø×Ñ×!Ñ!Ø"&Ð>Sð 	"õ 	
r;   c	                ób   ‡ ‡‡‡‡‡‡‡‡— ‰ j                   j                  ˆˆˆˆˆˆˆˆ ˆf	d„«       y)a  Called when our ScriptRunner emits an event.

        This is generally called from the sender ScriptRunner's script thread.
        We forward the event on to _handle_scriptrunner_event_on_event_loop,
        which will be called on the main thread.
        c            
     ó4   •	— ‰j                  ‰‰‰‰‰ ‰‰‰«      S r±   )Ú(_handle_scriptrunner_event_on_event_loop)	rÊ   Úeventr§   Úforward_msgrí   r¯   rà   r`   Úsenders	   €€€€€€€€€r<   r´   z3AppSession._on_scriptrunner_event.<locals>.<lambda>"  s*   ø€ �D×AÑAØØØØØØ Ø%Øó	€ r;   N)rI   r¸   )	r`   rô   rò   ró   r§   rÊ   r¯   rí   rà   s	   `````````r<   rµ   z!AppSession._on_scriptrunner_event  s$   ÿø€ ð" 	×Ñ×-Ñ-÷	ó 	õ	
r;   c	                óˆ  — | j                   t        j                  «       k7  rt        d«      ‚|| j                  urt
        j                  d|«       y| j                  }	|t        j                  k(  r | j                  t        j                  k7  rt        j                  | _        |€t        d«      ‚|| j                  j                  k7  r|| j                  _        | j                  |«       | j!                  |||«      }
| j#                  |
«       �nÝ|t        j$                  t        j&                  t        j(                  hv �rj| j                  t        j                  k7  rt        j*                  | _        |t        j$                  k(  rt,        j.                  }n4|t        j(                  k(  rt,        j0                  }nt,        j2                  }| j#                  | j5                  |«      «       d| _        |t        j$                  t        j(                  hv rC| j8                  �rË| j8                  j;                  «        | j8                  j=                  «        �n•|€t        d«      ‚t-        «       }
t?        j@                  |
jB                  jD                  |«       | j#                  |
«       �nA|t        jF                  k(  rjt        j*                  | _        | j#                  | j5                  t,        jH                  «      «       | j8                  rß| j8                  j;                  «        nÄ|t        jJ                  k(  r€|€t        d«      ‚| j                  t        j                  k(  rGtM        jN                  «       jP                  jS                  | jT                  «       | jW                  «        || _        d| _        n1|t        jX                  k(  r|€t        d«      ‚| j#                  |«       |	t        j                  k(  }| j                  t        j                  k(  }||k7  r | j#                  | j[                  «       «       yy)af  Handle a ScriptRunner event.

        This function must only be called on our eventloop thread.

        Parameters
        ----------
        sender : ScriptRunner | None
            The ScriptRunner that emitted the event. (This may be set to
            None when called from `handle_backmsg_exception`, if no
            ScriptRunner was active when the backmsg exception was raised.)

        event : ScriptRunnerEvent
            The event type.

        forward_msg : ForwardMsg | None
            The ForwardMsg to send to the frontend. Set only for the
            ENQUEUE_FORWARD_MSG event.

        exception : BaseException | None
            An exception thrown during compilation. Set only for the
            SCRIPT_STOPPED_WITH_COMPILE_ERROR event.

        client_state : streamlit.proto.ClientState_pb2.ClientState | None
            The ScriptRunner's final ClientState. Set only for the
            SHUTDOWN event.

        page_script_hash : str | None
            A hash of the script path corresponding to the page currently being
            run. Set only for the SCRIPT_STARTED event.

        fragment_ids_this_run : list[str] | None
            The fragment IDs of the fragments being executed in this script run. Only
            set for the SCRIPT_STARTED event. If this value is falsy, this script run
            must be for the full script.
        zrThis function must only be called on the eventloop thread the AppSession was created on. This should never happen.z0Ignoring event from non-current ScriptRunner: %sNzTpage_script_hash must be set for the SCRIPT_STARTED event. This should never happen.z`exception must be set for the SCRIPT_STOPPED_WITH_COMPILE_ERROR event. This should never happen.zJclient_state must be set for the SHUTDOWN event. This should never happen.zHnull forward_msg in ENQUEUE_FORWARD_MSG event. This should never happen.).rI   rG   rH   ÚRuntimeErrorrY   r1   r_   rQ   r   r·   r3   r6   r5   rR   r¯   rî   Ú_create_new_session_messager�   r¶   Ú!SCRIPT_STOPPED_WITH_COMPILE_ERRORÚFRAGMENT_STOPPED_WITH_SUCCESSr4   r   ÚFINISHED_SUCCESSFULLYÚ"FINISHED_FRAGMENT_RUN_SUCCESSFULLYÚFINISHED_WITH_COMPILE_ERRORÚ_create_script_finished_messager]   rS   Úupdate_watched_modulesÚupdate_watched_pagesÚexception_utilsÚmarshallÚsession_eventÚscript_compilation_exceptionÚSCRIPT_STOPPED_FOR_RERUNÚFINISHED_EARLY_FOR_RERUNÚSHUTDOWNr   r‚   rƒ   r„   rF   r{   ÚENQUEUE_FORWARD_MSGÚ&_create_session_status_changed_message)r`   rô   rò   ró   r§   rÊ   r¯   rí   rà   Ú
prev_staterŒ   ÚstatusÚapp_was_runningÚapp_is_runnings                 r<   rñ   z3AppSession._handle_scriptrunner_event_on_event_loop.  s˜  € ð` ×Ñ¤× 8Ñ 8Ó :Ò:äð,óð ð
 ˜×+Ñ+Ñ+ô �M‰MÐLÈeÔTØà—[‘[ˆ
àÔ%×4Ñ4Ò4Ø�{‰{œo×@Ñ@Ò@Ü-×<Ñ<�”ØÐ'Ü"Øjóð ð   4×#5Ñ#5×#FÑ#FÒFØ6F�×"Ñ"Ô3à×ÑÐ3Ô4à×2Ñ2Ø Ð"7¸óˆCð ×%Ñ% cÖ*àÜ×9Ñ9Ü×?Ñ?Ü×;Ñ;ð
ò 
ð
 �{‰{œo×@Ñ@Ò@Ü-×=Ñ=�”àÔ)×EÑEÒEÜ#×9Ñ9‘ØÔ+×IÑIÒIÜ#×FÑF‘ä#×?Ñ?�à×%Ñ% d×&JÑ&JÈ6Ó&RÔSØ*.ˆDÔ'àÜ!×=Ñ=Ü!×?Ñ?ðñ ð ×.Ó.Ø×/Ñ/×FÑFÔHØ×/Ñ/×DÑDÖFð Ð$Ü&ð4óð ô !“l�Ü×(Ñ(Ø×%Ñ%×BÑBÀIôð ×)Ñ)¨#Ö.àÔ'×@Ñ@Ò@Ü)×9Ñ9ˆDŒKØ×%Ñ%Ø×4Ñ4Ü×7Ñ7óôð
 ×*Ò*Ø×+Ñ+×BÑBÕDàÔ'×0Ñ0Ò0ØÐ#Ü"Ø`óð ð �{‰{œo×@Ñ@Ò@ô ×$Ñ$Ó&×5Ñ5×HÑHÈÏÉÔQØ×)Ñ)Ô+à!-ˆDÔØ!%ˆDÕàÔ'×;Ñ;Ò;ØÐ"Ü"Ø^óð ð ×%Ñ% kÔ2ð %¬×(FÑ(FÑFˆØŸ™¬×(FÑ(FÑFˆØ˜_Ò,Ø×%Ñ% d×&QÑ&QÓ&SÕTð -r;   c                ó¨   — t        «       }| j                  |j                  _        | j                  t
        j                  k(  |j                  _        |S )z6Create and return a session_status_changed ForwardMsg.)r   rX   Úsession_status_changedÚrun_on_saverQ   r3   r5   Úscript_is_runningr‹   s     r<   r  z1AppSession._create_session_status_changed_message×  sD   € ä‹lˆØ15×1BÑ1Bˆ×"Ñ"Ô.à�K‰Kœ?×9Ñ9Ñ9ð 	×"Ñ"Ô4ð ˆ
r;   c                ó<   — t        «       }d|j                  _        |S )z8Create and return a 'script_changed_on_disk' ForwardMsg.T)r   r  Úscript_changed_on_diskr‹   s     r<   rè   z&AppSession._create_file_change_messageà  s   € ä‹lˆØ37ˆ×ÑÔ0Øˆ
r;   c                óJ  — t        «       }t        «       |j                  _        | j                  j
                  |j                  _        | j                  j                  |j                  _        | j                  j                  |j                  _        ||j                  _	        |r%|j                  j                  j                  |«       | j                  |j                  |xs | j                  j                  «       «       t        |j                  j                  «       t!        |j                  j"                  «       t!        |j                  j"                  j$                  dt        j&                  j(                  j*                  › �«       t!        |j                  j"                  j,                  dt        j&                  j.                  j*                  › �«       t!        |j                  j"                  j0                  dt        j&                  j2                  j*                  › �«       t!        |j                  j"                  j$                  j0                  dt        j&                  j4                  j*                  › �«       t!        |j                  j"                  j,                  j0                  dt        j&                  j6                  j*                  › �«       |j                  j8                  }t;        |j<                  «       t>        |j@                  _!        djE                  tG        tH        tJ        jL                  «      «      |j@                  _'        tP        jR                  |j@                  _*        dtV        jX                  v xs dtV        jX                  v |j@                  _-        | j\                  |j^                  _0        | jb                  td        jf                  k(  |j^                  _4        | j                  jj                  |_5        | jl                  |_7        |S )z+Create and return a new_session ForwardMsg.ztheme.ú.ÚDISPLAYÚWAYLAND_DISPLAY)8r   rA   Únew_sessionÚscript_run_idrJ   ÚnamerN   rM   Úmain_script_hashr¯   rí   ÚextendÚ_populate_app_pagesrá   Ú_populate_config_msgr	   Ú_populate_theme_msgÚcustom_themeÚlightÚCustomThemeCategoriesÚLIGHTÚvalueÚdarkÚDARKÚsidebarÚSIDEBARÚLIGHT_SIDEBARÚDARK_SIDEBARÚ
initializeÚ_populate_user_info_msgre   r#   Úenvironment_infoÚstreamlit_versionÚjoinÚmapr>   ÚsysÚversion_infoÚpython_versionr
   ÚSYSTEMÚ	server_osÚosÚenvironÚhas_displayrX   Úsession_statusr  rQ   r3   r5   r  Úis_hellorF   rÒ   )r`   r¯   rí   rà   rŒ   Úimsgs         r<   r÷   z&AppSession._create_new_session_messageæ  sî  € ô ‹lˆä(>Ó(@ˆ�‰Ô%Ø#×0Ñ0×5Ñ5ˆ�‰ÔØ+/×+>Ñ+>×+OÑ+Oˆ�‰Ô(Ø+/×+>Ñ+>×+OÑ+Oˆ�‰Ô(Ø+;ˆ�‰Ô(á Ø�O‰O×1Ñ1×8Ñ8Ð9NÔOà× Ñ Ø�O‰O˜UÒE d×&9Ñ&9×&CÑ&CÓ&Eô	
ô 	˜SŸ_™_×3Ñ3Ô4ô 	˜CŸO™O×8Ñ8Ô9äØ�O‰O×(Ñ(×.Ñ.Ø”V×1Ñ1×7Ñ7×=Ñ=Ð>Ð?ô	
ô
 	Ø�O‰O×(Ñ(×-Ñ-Ø”V×1Ñ1×6Ñ6×<Ñ<Ð=Ð>ô	
ô
 	Ø�O‰O×(Ñ(×0Ñ0Ø”V×1Ñ1×9Ñ9×?Ñ?Ð@ÐAô	
ô
 	Ø�O‰O×(Ñ(×.Ñ.×6Ñ6Ø”V×1Ñ1×?Ñ?×EÑEÐFÐGô	
ô
 	Ø�O‰O×(Ñ(×-Ñ-×5Ñ5Ø”V×1Ñ1×>Ñ>×DÑDÐEÐFô	
ð �‰×)Ñ)ˆä §¡Ô/ä2Jˆ×ÑÔ/Ø/2¯x©x¼¼CÄ×AQÑAQÓ8RÓ/Sˆ×ÑÔ,Ü*2¯/©/ˆ×ÑÔ'àœŸ™Ð#ÒFÐ'8¼B¿J¹JÐ'Fð 	×ÑÔ)ð +/×*;Ñ*;ˆ×ÑÔ'à�K‰Kœ?×9Ñ9Ñ9ð 	×ÑÔ-ð ×)Ñ)×2Ñ2ˆŒØŸ'™'ˆŒàˆ
r;   c                ó(   — t        «       }||_        |S )z/Create and return a script_finished ForwardMsg.)r   Úscript_finished)r`   r
  rŒ   s      r<   rý   z*AppSession._create_script_finished_message3  s   € ô ‹lˆØ$ˆÔØˆ
r;   c                ó‚   — t        «       }t        j                  |j                  j                  j
                  |«       |S )z*Create and return an Exception ForwardMsg.)r   r   r  ÚdeltaÚnew_elementr§   )r`   r³   rŒ   s      r<   r²   z$AppSession._create_exception_message;  s.   € ä‹lˆÜ× Ñ  §¡×!6Ñ!6×!@Ñ!@À!ÔDØˆ
r;   c                óº  — t        «       }	 ddlm}  || j                  j                  «      }|j                  «       }|€y |\  }}}|j                  d«      }||j                  _        ||j                  _	        ||j                  _
        |j                  xs g |j                  j                  d d  |j                  xs g |j                  j                  d d  |j                  r*t        j                  j                   |j                  _        nw|j$                  rBt'        |j$                  «      dkD  r*t        j                  j(                  |j                  _        n)t        j                  j*                  |j                  _        t,        j/                  d|||«       | j1                  |«       y # t2        $ r!}t,        j/                  d|¬«       Y d }~y d }~ww xY w)Nr   )ÚGitRepoz.gitz7Git information found. Name: %s, Branch: %s, Module: %sz+Obtaining Git information produced an error©Úexc_info)r   Ústreamlit.git_utilrA  rJ   rM   Úget_repo_infoÚremovesuffixÚgit_info_changedÚ
repositoryÚbranchÚmoduleÚuntracked_filesÚuncommitted_filesÚis_head_detachedr   Ú	GitStatesÚHEAD_DETACHEDÚstateÚahead_commitsÚlenÚAHEAD_OF_REMOTEÚDEFAULTr1   r_   r�   r¦   )	r`   rŒ   rA  ÚrepoÚ	repo_infoÚrepository_namerI  rJ  r«   s	            r<   r›   z*AppSession._handle_git_information_requestA  s‹  € Ü‹lˆð%	VÝ2á˜4×,Ñ,×=Ñ=Ó>ˆDà×*Ñ*Ó,ˆIØÐ Øà.7Ñ+ˆO˜V Và-×:Ñ:¸6ÓBˆOà.=ˆC× Ñ Ô+Ø*0ˆC× Ñ Ô'Ø*0ˆC× Ñ Ô'à6:×6JÑ6JÒ6PÈbˆC× Ñ ×0Ñ0±Ð3Ø8<×8NÑ8NÒ8TÐRTˆC× Ñ ×2Ñ2±1Ð5à×$Ò$Ü-4×->Ñ->×-LÑ-L�×$Ñ$Õ*Ø×#Ò#¬¨D×,>Ñ,>Ó(?À!Ò(CÜ-4×->Ñ->×-NÑ-N�×$Ñ$Õ*ä-4×->Ñ->×-FÑ-F�×$Ñ$Ô*ä�M‰MØIØØØô	ð ×%Ñ% cÕ*øÜò 	Vô �M‰MÐGÐRTˆM×UÑUûð	Vús   Œ4F0 ÁE.F0 Æ0	GÆ9GÇGc                ó&   — | j                  |«       y)a  Tell the ScriptRunner to re-run its script.

        Parameters
        ----------
        client_state : streamlit.proto.ClientState_pb2.ClientState | None
            The ClientState protobuf to run the script with, or None
            to use previous client state.

        N)rÈ   )r`   rÊ   s     r<   rš   z'AppSession._handle_rerun_script_requestk  s   € ð 	×Ñ˜<Õ(r;   c                ó$   — | j                  «        y)z1Tell the ScriptRunner to stop running its script.N)r†   rj   s    r<   rŸ   z&AppSession._handle_stop_script_requesty  s   € à× Ñ Õ"r;   c                ó°   — t         j                  j                  «        t         j                  j                  «        | j                  j                  «        y)zjClear this app's cache.

        Because this cache is global, it will be cleared for all users.

        N)r   Ú
cache_datarÏ   Úcache_resourcer[   rj   s    r<   rœ   z&AppSession._handle_clear_cache_request}  s:   € ô 	×Ñ× Ñ Ô"Ü×Ñ×$Ñ$Ô&Ø×Ñ×!Ñ!Õ#r;   c                óH   — t        «       }d|_        | j                  |«       y)a&  Handle an incoming app heartbeat.

        The heartbeat indicates the frontend is active and keeps the
        websocket from going idle and disconnecting.

        We respond with a heartbeat_ack so the frontend can verify the
        connection is healthy and detect network issues.
        TN)r   Úheartbeat_ackr�   r‹   s     r<   r�   z(AppSession._handle_app_heartbeat_request‡  s!   € ô ‹lˆØ ˆÔØ×!Ñ! #Õ&r;   c                óP   — || _         | j                  | j                  «       «       y)zÐChange our run_on_save flag to the given value.

        The browser will be notified of the change.

        Parameters
        ----------
        new_value : bool
            New run_on_save value

        N)rX   r�   r  )r`   Ú	new_values     r<   rž   z*AppSession._handle_set_run_on_save_request”  s#   € ð &ˆÔØ×!Ñ! $×"MÑ"MÓ"OÕPr;   c                ó|  — t        «       }|j                  |j                  _        | j                  j                  | j                  |j                  «      }|D ]Q  }|j                  j                  j                  t        |j                  |j                  |j                  ¬«      «       ŒS | j                  |«       y)z6Handle a file_urls_request BackMsg sent by the client.)r¤   Ú
upload_urlÚ
delete_urlN)r   Ú
request_idÚfile_urls_responseÚresponse_idrK   Úget_upload_urlsrF   Ú
file_namesÚ	file_urlsÚappendr   r¤   rb  rc  r�   )r`   r–   rŒ   Úupload_url_infosÚupload_url_infos        r<   r    z$AppSession._handle_file_urls_request¢  s¢   € ä‹lˆØ->×-IÑ-Iˆ×ÑÔ*à×2Ñ2×BÑBØ�G‰GÐ&×1Ñ1ó
Ðð  0ò 	ˆOØ×"Ñ"×,Ñ,×3Ñ3ÜØ+×3Ñ3Ø.×9Ñ9Ø.×9Ñ9ôõð	ð 	×!Ñ! #Õ&r;   c              ƒ  óÜ  K  — t        «       }|j                  |j                  _        	 t        j                  t        j                  «       j                  j                  |j                  «      ƒ d{  –—† }||j                  _	        | j                  |«       y7 Œ'# t        $ rD}t        j                  d|j                  «       t        |«      |j                  _        Y d}~Œ\d}~ww xY w­w)zúHandle a deferred_file_request BackMsg sent by the client.

        Execute the deferred callable in a separate thread and send the URL back
        to the frontend. This prevents blocking the main event loop if the callable
        is slow.
        Nz0Error executing deferred callable for file_id %s)r   r¤   Údeferred_file_responserG   Ú	to_threadr   r‚   rƒ   Úexecute_deferredÚurlr¦   r1   r§   r>   Ú	error_msgr�   )r`   ÚrequestÚresponserq  r³   s        r<   r¢   z(AppSession._handle_deferred_file_request¶  sÀ   è ø€ ô “<ˆØ29·/±/ˆ×'Ñ'Ô/ð	?ô  ×)Ñ)Ü×$Ñ$Ó&×5Ñ5×FÑFØ—‘ó÷ ˆCð 36ˆH×+Ñ+Ô/ð 	×!Ñ! (Õ+ðùô
 ò 	?ä×ÑØBÀGÇOÁOôô 9<¸A»ˆH×+Ñ+×5Ñ5ûð	?üsA   ‚&C,©A	B Á2BÁ3B ÂC,ÂB Â	C)Â%:C$ÃC,Ã$C)Ã)C,c                óÒ   — |j                  «       D ]T  \  }}|j                  j                  «       }||_        |d   j	                  dd«      |_        |d   |_        |d   |_        ŒV y )Nr½   rê   ú Úicon)ÚitemsÚ	app_pagesÚaddr¯   Úreplacer½   Úurl_pathnamerw  )r`   rŒ   rà   r¯   Ú	page_infoÚ
page_protos         r<   r  zAppSession._populate_app_pagesÒ  sl   € ð ,1¯;©;«=ò 	0Ñ'Ð˜iØŸ™×*Ñ*Ó,ˆJà*:ˆJÔ'Ø#,¨[Ñ#9×#AÑ#AÀ#ÀsÓ#KˆJÔ Ø&/°Ñ&<ˆJÔ#Ø'¨Ñ/ˆJ�Oñ	0r;   r±   )ra   r)   rb   r.   rc   r*   rd   zCallable[[], None] | Nonere   r+   rf   ú
str | NoneÚreturnÚNone)r€  r�  )r€  zlist[ForwardMsg])rŒ   r   r€  r�  )rŒ   r'   r€  r�  )r³   ÚBaseExceptionr€  r�  )rÊ   úClientState | Noner€  r�  )rÕ   r   r€  r�  )r€  r-   )rß   r>   r€  rÆ   )rß   r  r€  r�  )rê   r   r€  r�  )rí   úlist[str] | Noner€  r�  )NNNNNN)rô   zScriptRunner | Nonerò   r   ró   zForwardMsg | Noner§   zBaseException | NonerÊ   rƒ  r¯   r  rí   r„  rà   údict[PageHash, PageInfo] | Noner€  r�  )r€  r   )NN)r¯   r>   rí   r„  rà   r…  r€  r   )r
  z)ForwardMsg.ScriptFinishedStatus.ValueTyper€  r   )r³   r‚  r€  r   )r`  rÆ   r€  r�  )r–   r   r€  r�  )rs  r(   r€  r�  )rŒ   r   rà   zdict[PageHash, PageInfo]r€  r�  )(r7   r8   r9   Ú__doc__rg   rk   rW   rw   r{   r~   ri   r�   r¬   r¨   rÈ   r†   rÐ   rÉ   ÚpropertyrÓ   ræ   ro   rs   rî   rµ   rñ   r  rè   r÷   rý   r²   r›   rš   rŸ   rœ   r�   rž   r    r¢   r  r:   r;   r<   rC   rC   P   s†  „ ñ	ð$ +/ðXAàðXAð  3ðXAð "ð	XAð
 $=ðXAð  ðXAð (ðXAð 
óXAótóVó2)ó6ó+ó(ó>.ó(#.óJ
ó:R.óh.ó ó#ð  ò#ó ð#óôJó
'ô
ð *.Ø*.Ø+/Ø'+Ø26Ø15ð
à#ð
ð !ð
ð 'ð	
ð
 (ð
ð )ð
ð %ð
ð  0ð
ð /ð
ð 
ó
ðD *.Ø*.Ø+/Ø'+Ø26Ø15ðgUà#ðgUð !ðgUð 'ð	gUð
 (ðgUð )ðgUð %ðgUð  0ðgUð /ðgUð 
ógUóRóð 37Ø15ð	KàðKð  0ðKð /ð	Kð
 
óKðZØ?ðà	óóó(VðV 26ð)Ø.ð)à	ó)ó#ó$ó'óQó'ó(,ð8	0Øð	0Ø&>ð	0à	ô	0r;   rC   c                 ó  — d} t        j                  | «      }t        t        j                  |j                  «       «      }|€Hdj                  d„ t        j                  j                  «       D «       «      }t        d| ›d|› d|› �«      ‚|S )Nzclient.toolbarModeú, c              3  ó<   K  — | ]  }|j                  «       –— Œ y ­wr±   )Úlower)Ú.0rÞ   s     r<   ú	<genexpr>z$_get_toolbar_mode.<locals>.<genexpr>ê  s   è ø€ Ò"P° 1§7¡7§9Ñ"Pùs   ‚úConfig ú. expects to have one of the following values: ú. Current value: )	r	   rV   Úgetattrr   ÚToolbarModeÚupperr.  ÚkeysÚ
ValueError)Ú
config_keyÚconfig_valueÚ
enum_valueÚallowed_valuess       r<   Ú_get_toolbar_moderš  ã  s–   € Ø%€JÜ×$Ñ$ ZÓ0€LÜ6=Ü×Ñ˜L×.Ñ.Ó0ó7€Jð ÐØŸ™Ñ"P´f×6HÑ6H×6MÑ6MÓ6OÔ"PÓPˆÜØ�j�^ð $%Ø%3Ð$4ð 5Ø*˜^ð-ó
ð 	
ð
 Ðr;   c                 ó¤  — d} t        j                  | «      }|du rt        j                  j                  S |du rt        j                  j
                  S g d¢}t        j                  j                  t        j                  j                  t        j                  j
                  dœ}||vr#t        d| ›ddj                  |«      › d|› �«      ‚||   S )	Nzclient.showErrorLinksTF)ÚautoÚtrueÚfalserŽ  r�  r‰  r�  )	r	   rV   r   ÚShowErrorLinksÚSHOW_ERROR_LINKS_TRUEÚSHOW_ERROR_LINKS_FALSEÚSHOW_ERROR_LINKS_AUTOr•  r.  )r–  r—  r™  Úvalue_to_enums       r<   Ú_get_show_error_linksr¤  ó  s×   € Ø(€JÜ×$Ñ$ ZÓ0€Lð �tÑÜ×$Ñ$×:Ñ:Ð:Ø�uÑÜ×$Ñ$×;Ñ;Ð;ò /€Nä×%Ñ%×;Ñ;Ü×%Ñ%×;Ñ;Ü×&Ñ&×=Ñ=ñ€Mð
 ˜>Ñ)ÜØ�j�^ð $%Ø%)§Y¡Y¨~Ó%>Ð$?ð @Ø*˜^ð-ó
ð 	
ð
 ˜Ñ&Ð&r;   c                óL  — t        j                  d«      | _        t        j                  d«      | _        t        j                  d«      | _        t        j                  d«      | _        t        j                  d«      du rd| _        t        «       | _        t        «       | _
        y )Nzbrowser.gatherUsageStatszglobal.maxCachedMessageAgezserver.allowRunOnSavezui.hideTopBarzclient.showSidebarNavigationFT)r	   rV   Úgather_usage_statsÚmax_cached_message_ageÚallow_run_on_saveÚhide_top_barÚhide_sidebar_navrš  Útoolbar_moder¤  Úshow_error_links)rŒ   s    r<   r  r    sƒ   € Ü#×.Ñ.Ð/IÓJ€CÔÜ!'×!2Ñ!2Ð3OÓ!P€CÔÜ"×-Ñ-Ð.EÓF€CÔÜ×(Ñ(¨Ó9€CÔÜ×ÑÐ7Ó8¸EÑAØ#ˆÔÜ(Ó*€CÔÜ0Ó2€CÕr;   c                óâ  — | j                  |«      }t        |t        «      r	 t        j                  |«      }|�L|�0t        |«      |k7  r"t        j                  d||t        |«      «       y|D ]  }	 |j                  |«       Œ yy# t        j
                  $ r%}t        j                  d|||¬«       d}Y d}~Œ‚d}~ww xY w# t        $ r#}t        j                  d|||¬«       Y d}~Œ{d}~ww xY w)aÛ  Parse and populate chart colors from theme config to protobuf message field.

    Parameters
    ----------
    theme_opts
        Dictionary of theme options from config.get_options_for_section.
    config_key
        The key in theme_opts to look for (e.g., "chartCategoricalColors").
    msg_field
        The protobuf repeated string field to append colors to.
    required_length
        If provided, log an error if the colors array doesn't have this exact length.
    z/Failed to parse the theme.%s config option: %s.rB  NzbConfig theme.%s should have %s color values, but got %s. Defaulting to Streamlit's default colors.)ÚgetÚ
isinstancer>   ÚjsonÚloadsÚJSONDecodeErrorr1   r¥   rR  Úerrorrj  r¦   )Ú
theme_optsr–  Ú	msg_fieldÚrequired_lengthÚcolorsr³   Úcolors          r<   Ú _parse_and_populate_chart_colorsr¹    s  € ð& �^‰^˜JÓ'€Fô
 �&œ#Ôð		Ü—Z‘Z Ó'ˆFð ÐàÐ&¬3¨v«;¸/Ò+IÜ�M‰MðHàØÜ�F“ôð Øò 		ˆEðØ× Ñ  Õ'ñ		ð øô ×#Ñ#ò 	Ü�O‰OØAØØØð	 ô ð �Fûð	ûô. ò Ü—‘ØEØØØð	  ÷ ñ ûðús/   £B Á2CÂB?ÂB:Â:B?Ã	C.ÃC)Ã)C.c           	     óÞ	  — t        j                  |«      }t        d„ |j                  «       D «       «      ry |j	                  «       D ]#  \  }}|dvsŒ|€Œt        | t        |«      |«       Œ% | j                  j                  | j                  j                  dœ}|j                  dd «      }|�=||vr/t        j                  d|t        |j                  «       «      «       n
||   | _        t!        | |j                  dd «      |j                  dd «      |j                  dd «      |«      } |j                  d	d «      }t#        |t$        «      r	 t'        j(                  |«      }|�€|D ]{  }		 t#        |	t,        «      r;d|	v rd|	vr|	d   |	d<   |	d= d|	v r$t#        |	d   t$        «      st%        |	d   «      |	d<   | j.                  j1                  t3        |	t5        «       «      «       Œ} |j                  dd «      }
t#        |
t$        «      rL|
j7                  «       j9                  «       }
|
j;                  d«      r|
gdz  }
n	 t'        j(                  |
«      }
|
�J|
rt=        |
«      dkD  rt?        dt=        |
«      › �«      ‚|
D ]  }	 | j@                  j1                  |«       Œ  |j                  dd «      }t#        |t$        «      r	 t'        j(                  |«      }t#        |tB        «      r-tE        dd«      D ]  }| jF                  j1                  |«       Œ nrt#        |t        «      rb|rt=        |«      dkD  rt?        dt=        |«      › �«      ‚|d d dgdt=        |«      z
  z  z   }|D ]  }	 | jF                  j1                  |«       Œ  tI        |d| jJ                  «       tI        |d| jL                  d¬«       tI        |d | jN                  d¬«       y # t*        $ r%}t        j                  d
||¬«       d }Y d }~�Œ–d }~ww xY w# t*        $ r#}t        j                  d|	|¬«       Y d }~�ŒÁd }~ww xY w# t*        $ r%}t        j                  d|
|¬«       d }
Y d }~�Œd }~ww xY w# t*        $ r#}t        j                  d||¬«       Y d }~�Œ
d }~ww xY w# t*        $ r%}t        j                  d||¬«       d }Y d }~�Œâd }~ww xY w# t*        $ r#}t        j                  d||¬«       Y d }~�Œƒd }~ww xY w)!Nc              3  ó$   K  — | ]  }|d u –— Œ
 y ­wr±   r:   )rŒ  Úvals     r<   r�  z&_populate_theme_msg.<locals>.<genexpr>U  s   è ø€ Ò
6˜3ˆ3�$Œ;Ñ
6ùs   ‚>
   ÚbaseÚfontÚcodeFontÚ	fontFacesÚheadingFontÚheadingFontSizesÚheadingFontWeightsÚchartDivergingColorsÚchartSequentialColorsÚchartCategoricalColors)r   r$  r½  zb"%s" is an invalid value for theme.base. Allowed values include %s. Setting theme.base to "light".r¾  r¿  rÁ  rÀ  zFFailed to parse the theme.fontFaces config option with json.loads: %s.rB  ÚweightÚweight_rangez6Failed to parse the theme.fontFaces config option: %s.rÂ  )ÚpxÚremé   zMFailed to parse the theme.headingFontSizes config option with json.loads: %s.zUConfig theme.headingFontSizes should have 1-6 values corresponding to h1-h6, but got z=Failed to parse the theme.headingFontSizes config option: %s.rÃ  zOFailed to parse the theme.headingFontWeights config option with json.loads: %s.é   é   zWConfig theme.headingFontWeights should have 1-6 values corresponding to h1-h6, but got iX  z?Failed to parse the theme.headingFontWeights config option: %s.rÆ  rÅ  é
   )r¶  rÄ  )(r	   Úget_options_for_sectionÚallÚvaluesrx  Úsetattrr"   Ú	BaseThemer"  r%  r®  r1   r¥   Úlistr”  r½  r!   r¯  r>   r°  r±  r¦   ÚdictÚ
font_facesrj  r   r   Ústripr‹  ÚendswithrR  r•  Úheading_font_sizesÚintÚrangeÚheading_font_weightsr¹  Úchart_categorical_colorsÚchart_sequential_colorsÚchart_diverging_colors)rŒ   Úsectionr´  Úoption_nameÚ
option_valÚbase_mapr½  rÖ  r³   Ú	font_facerÙ  ÚsizerÜ  rê   Úheading_weightsrÇ  s                   r<   r  r  S  s3  € Ü×/Ñ/°Ó8€JÜ
Ñ
6 *×"3Ñ"3Ó"5Ô
6Ô6Øà#-×#3Ñ#3Ó#5ò AÑˆ�Zð ðòð Ñ&ä�Cœ {Ó3°ZÕ@ð'Að2 —‘×$Ñ$Ø—‘×"Ñ"ñ€Hð �>‰>˜& $Ó'€DØÐØ�xÑÜ�O‰Oð1àÜ�X—]‘]“_Ó%õ	ð   ‘~ˆCŒHô "ØØ�‰�v˜tÓ$Ø�‰�z 4Ó(Ø�‰�} dÓ+Øó€Cð —‘ ¨TÓ2€Jô �*œcÔ"ð	ÜŸ™ JÓ/ˆJð ÐØ#ò 	ˆIðÜ˜i¬Ô.à 9Ñ,Ø)°Ñ:Ø8AÀ(Ñ8K˜I nÑ5Ø% hÐ/Ø%¨Ñ2¼:Ø! .Ñ1´3ô<ô 58¸	À.Ñ8QÓ4R˜	 .Ñ1Ø—‘×%Ñ%¤i°	¼8»:Ó&FÕGð	ð( $Ÿ™Ð(:¸DÓAÐô
 Ð$¤cÔ*Ø/×5Ñ5Ó7×=Ñ=Ó?ÐØ×&Ñ& }Ô5à"4Ð!5¸Ñ!9Ñð*Ü%)§Z¡ZÐ0BÓ%CÐ"ð Ð%á!¤SÐ);Ó%<¸qÒ%@ÜðÜÐ1Ó2Ð3ð5óð ð 'ò 	ˆDðØ×&Ñ&×-Ñ-¨dÕ3ð	ð &Ÿ>™>Ð*>ÀÓEÐô Ð&¬Ô,ð	(Ü#'§:¡:Ð.BÓ#CÐ ô Ð&¬Ô,ä�q˜!“ò 	BˆAØ×$Ñ$×+Ñ+Ð,@ÕAñ	Bä	Ð(¬$Ô	/á#¤sÐ+?Ó'@À1Ò'DÜðÜÐ3Ó4Ð5ð7óð ð
 /¨r°Ð2°c°UØ”Ð(Ó)Ñ)ñ6
ñ 
ˆð &ò 	ˆFðØ×(Ñ(×/Ñ/°Õ7ð	ô %ØÐ,¨c×.JÑ.Jôô %ØØØ×#Ñ#Øõ	ô %ØØØ×"Ñ"Øö	øôo ò 	Ü�O‰OØXØØð ô ð
 ŽJûð	ûô, ò Ü—‘ØLØØð  ÷ ò ûðûô* ò *Ü—‘ØcØ&Øð  ô ð
 &*Ö"ûð*ûô$ ò Ü—‘ØSØØð  ÷ ò ûðûô ò 	(Ü�O‰OØaØ$Øð ô ð
 $(Ö ûð	(ûô6 ò Ü—‘ØUØØð  ÷ ò ûðús‘   ÅO Å*A8P È=P/ ÊQ ËR Í(S Ï	O=ÏO8Ï8O=Ð 	P,Ð	P'Ð'P,Ð/	QÐ8QÑQÑ 	RÑ)RÒRÒ	R=ÒR8Ò8R=Ó 	S,Ó	S'Ó'S,c                ó’   — t        j                  «       }|j                  | _        |j                  | _        |j                  | _        y r±   )r   ÚinstanceÚinstallation_idÚinstallation_id_v3Úinstallation_id_v4)rŒ   Úinsts     r<   r+  r+    s:   € Ü× Ñ Ó"€DØ×.Ñ.€CÔØ!×4Ñ4€CÔØ!×4Ñ4€CÕr;   )r€  r>   )r€  zConfig.ToolbarMode.ValueType)r€  zConfig.ShowErrorLinks.ValueType)rŒ   r   r€  r�  r±   )
r´  zdict[str, Any]r–  r>   rµ  z!RepeatedScalarFieldContainer[str]r¶  z
int | Noner€  r�  )Útheme)rŒ   r   rà  r>   r€  r�  )rŒ   r   r€  r�  )aÚ
__future__r   rG   r°  r5  r0  r?   Úenumr   Útypingr   r   r   Úgoogle.protobuf.json_formatr   Ústreamlit.elements.exceptionÚelementsr§   r   Ú	streamlitr	   r
   r   Ústreamlit.loggerr   Ústreamlit.proto.ClientState_pb2r   Ústreamlit.proto.Common_pb2r   r   Ústreamlit.proto.ForwardMsg_pb2r   Ústreamlit.proto.GitInfo_pb2r   Ústreamlit.proto.NewSession_pb2r   r   r   r   r   Ústreamlit.runtimer   Ú#streamlit.runtime.forward_msg_queuer   Ústreamlit.runtime.fragmentr   r   Ústreamlit.runtime.metrics_utilr   Ústreamlit.runtime.pages_managerr   Ústreamlit.runtime.scriptrunnerr   r   r   Ústreamlit.runtime.secretsr    Ústreamlit.runtime.theme_utilr!   Ústreamlit.string_utilr"   Ústreamlit.versionr#   Ústreamlit.watcherr$   Úcollections.abcr%   Ú#google.protobuf.internal.containersr&   Ústreamlit.proto.BackMsg_pb2r'   r(   Ústreamlit.runtime.script_datar)   Ú+streamlit.runtime.scriptrunner.script_cacher*   Ú7streamlit.runtime.scriptrunner_utils.script_run_contextr+   rZ   r-   Ú'streamlit.runtime.uploaded_file_managerr.   Ústreamlit.source_utilr/   r0   r7   r1   Ú__annotations__r3   rA   rC   rš  r¤  r  r¹  r  r+  r:   r;   r<   ú<module>r     s  ðö #ã Û Û 	Û 
Û Ý ß ,Ñ ,å 1ç 6Ð 6ß /Ñ /Ý 'Ý 7ß @Ý 5Ý /÷õ õ &Ý ?ß MÝ 7Ý 8ß UÑ UÝ 7Ý @Ý /Ý 6Ý 1áÝ(åPçHÝ8ÝGÝTÝ4ÝKß8á˜HÓ%€ˆÓ %ô.�dô .ó÷
K0ñ K0ófó 'ó43ð #'ð	8Øð8àð8ð 1ð8ð  ð	8ð
 
ó8ôvzôz5r;   