Ë
    :vžjÕ-  ã                   ó¬   — d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ dd	lmZ d
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ ZdZ G d„ d«      Zy)é    )Úwraps)Údeepcopy)Ú
TraitError)ÚConfig)Ú
JupyterApp)Ú	ServerApp)ÚExtensionAppé   )ÚNotebookAppTraitsc                 ó&   — dj                  | ¬«      S )NzÛ'{trait_name}' was found in both NotebookApp and ServerApp. This is likely a recent change. This config will only be set in NotebookApp. Please check if you should also config these traits in ServerApp for your purpose.©Ú
trait_name©Úformatr   s    úc/workspace/moltex-experiments/.pixi/envs/default/lib/python3.12/site-packages/notebook_shim/shim.pyÚNBAPP_AND_SVAPP_SHIM_MSGr      s    € ð"÷ #)¡&Øð #)ó #ð+ó    c                 ó&   — dj                  | ¬«      S )Nz—'{trait_name}' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.r   r   r   s    r   ÚNBAPP_TO_SVAPP_SHIM_MSGr      s    € ð÷ ™Øð ó ð	*r   c                 ó(   — dj                  | |¬«      S )Nzð'{trait_name}' is found in {extapp_name}, NotebookApp, and ServerApp. This is a recent change. This config will only be set in {extapp_name}. Please check if you should also config these traits in NotebookApp and ServerApp for your purpose.©r   Úextapp_namer   r   s     r   Ú#EXTAPP_AND_NBAPP_AND_SVAPP_SHIM_MSGr   "   s$   € ð2÷ 39±&ØØð 39ó 3ð	Cr   c                 ó(   — dj                  | |¬«      S )Nz×'{trait_name}' is found in both {extapp_name} and ServerApp. This is a recent change. This config will only be set in {extapp_name}. Please check if you should also config these traits in ServerApp for your purpose.r   r   r   s     r   ÚEXTAPP_AND_SVAPP_SHIM_MSGr   .   s#   € ð"÷ #)¡&ØØð #)ó #ð	9r   c                 ó(   — dj                  | |¬«      S )NzÛ'{trait_name}' is found in both {extapp_name} and NotebookApp. This is a recent change. This config will only be set in {extapp_name}. Please check if you should also config these traits in NotebookApp for your purpose.r   r   r   s     r   ÚEXTAPP_AND_NBAPP_SHIM_MSGr   :   s#   € ð$÷ %+¡FØØð %+ó %ð	9r   c                 ó(   — dj                  | |¬«      S )Na  '{trait_name}' is not found in {extapp_name}, but it was found in both NotebookApp and ServerApp. This is likely a recent change. This config will only be set in ServerApp. Please check if you should also config these traits in NotebookApp for your purpose.r   r   r   s     r   Ú#NOT_EXTAPP_NBAPP_AND_SVAPP_SHIM_MSGr   F   s$   € ð$÷
 %+¡FØØð %+ó %ð
Cr   c                 ó(   — dj                  | |¬«      S )Nzp'{trait_name}' has moved from {extapp_name} to ServerApp. Be sure to update your config before our next release.r   r   r   s     r   ÚEXTAPP_TO_SVAPP_SHIM_MSGr!   S   ó!   € ðç™ØØð ó ð8r   c                 ó(   — dj                  | |¬«      S )Nzr'{trait_name}' has moved from {extapp_name} to NotebookApp. Be sure to update your config before our next release.r   r   r   s     r   ÚEXTAPP_TO_NBAPP_SHIM_MSGr$   ]   r"   r   )Úopen_browserÚ	log_levelÚ
log_formatÚdefault_urlÚshow_bannerc                   óR   ‡ — e Zd ZdZ eej                  «      ˆ fd„«       Zd„ Zˆ xZS )ÚNotebookConfigShimMixinaô  A Mixin class for shimming configuration from
    NotebookApp to ServerApp. This class handles warnings, errors,
    etc.

    This class should be used during a transition period for apps
    that are switching from depending on NotebookApp to ServerApp.

    After one release cycle, this class can be safely removed
    from the inheriting class.

    TL;DR

    The entry point to shimming is at the `update_config` method.
    Once traits are loaded, before updating config across all
    configurable objects, this class injects a method to reroute
    traits to their *most logical* classes.

    This class raises warnings when:
        1. a trait has moved.
        2. a trait is redundant across classes.

    Redundant traits across multiple classes now must be
    configured separately, *or* removed from their old
    location to avoid this warning.

    For a longer description on how individual traits are handled,
    read the docstring under `shim_config_from_notebook_to_jupyter_server`.
    c                 óF   •— | j                  |«      }t        ‰| �	  |«       y )N)Ú+shim_config_from_notebook_to_jupyter_serverÚsuperÚupdate_config)ÚselfÚconfigÚshimmed_configÚ	__class__s      €r   r/   z%NotebookConfigShimMixin.update_configŠ   s%   ø€ ð ×IÑIØóˆä‰Ñ˜nÕ-r   c                 óà  — | j                   j                  }|j                  di «      }|j                  di «      }|j                  |i «      }t        |«      }i }i }i }	| j                   j	                  «       t        j                  «       z   }
t        j                  «       }t        j                  «       t        j                  «       z   }|j                  |«       d}|j                  «       D ]»  \  }}||v }||v }|t        v r|j                  ||i«       nt|r!|rt        |«      }|j                  ||i«       nQ|rt        |«      }|j                  ||i«       n0|r|j                  ||i«       nt        dj                  |«      «      ‚|sŒ¡| j                  j!                  |«       Œ½ d}|j                  «       D �]\  \  }}||
v }||v }||v }|t        v r|	j                  ||i«       �nt#        |||g«      r t%        ||«      }|	j                  ||i«       nà|r"|r t'        ||«      }|	j                  ||i«       n¼|r"|r t)        ||«      }|	j                  ||i«       n˜|r|	j                  ||i«       n‚|r"|r t+        ||«      }|j                  ||i«       n^|r t-        ||«      }|j                  ||i«       n<|r t/        ||«      }|j                  ||i«       nt        dj                  |«      «      ‚|s�ŒB| j                  j!                  |«       �Œ_ t1        ||dœ«      }|	r0|j                  t1        | j                   j                  |	i«      «       |j                  |«       |S )uÜ  Reorganizes a config object to reroute traits to their expected destinations
        after the transition from NotebookApp to ServerApp.

        A detailed explanation of how traits are handled:

        1. If the argument is prefixed with `ServerApp`,
            pass this trait to `ServerApp`.
        2. If the argument is prefixed with `NotebookApp`,
            * If the argument is a trait of `NotebookApp` *and* `ServerApp`:
                1. Raise a warningâ€”**for the extension developers**â€”that
                    there's redundant traits.
                2. Pass trait to `NotebookApp`.
            * If the argument is a trait of just `ServerApp` only
                (i.e. the trait moved from `NotebookApp` to `ServerApp`):
                1. Raise a "this trait has moved" **for the user**.
                3. Pass trait to `ServerApp`.
            * If the argument is a trait of `NotebookApp` only, pass trait
                to `NotebookApp`.
            * If the argument is not found in any object, raise a
                `"Trait not found."` error.
        3. If the argument is prefixed with `ExtensionApp`:
            * If the argument is a trait of `ExtensionApp`,
                `NotebookApp`, and `ServerApp`,
                1. Raise a warning about redundancy.
                2. Pass to the ExtensionApp
            * If the argument is a trait of `ExtensionApp` and `NotebookApp`,
                1. Raise a warning about redundancy.
                2. Pass to ExtensionApp.
            * If the argument is a trait of `ExtensionApp` and `ServerApp`,
                1. Raise a warning about redundancy.
                2. Pass to ExtensionApp.
            * If the argument is a trait of `ExtensionApp`.
                1. Pass to ExtensionApp.
            * If the argument is a trait of `NotebookApp` but not `ExtensionApp`,
                1. Raise a warning that trait has likely moved to NotebookApp.
                2. Pass to NotebookApp
            * If the arguent is a trait of `ServerApp` but not `ExtensionApp`,
                1. Raise a warning that the trait has likely moved to ServerApp.
                2. Pass to ServerApp.
            * else
                * Raise a TraitError: "trait not found."
        ÚNotebookAppr   NzTrait, {}, not found.)r5   r   )r3   Ú__name__Úpopr   Úclass_trait_namesr	   r   r   ÚupdateÚitemsÚIGNORED_TRAITSr   r   r   r   ÚlogÚwarningÚallr   r   r   r   r!   r$   r   )r0   r1   r   Únbapp_configÚsvapp_configÚextapp_configÚconfig_shimÚsvapp_config_shimÚnbapp_config_shimÚextapp_config_shimÚextapp_traitsÚsvapp_traitsÚnbapp_traitsÚwarning_msgr   Útrait_valueÚin_svappÚin_nbappÚ	in_extappÚ
new_configs                       r   r-   zCNotebookConfigShimMixin.shim_config_from_notebook_to_jupyter_server‘   sž  € ðV —n‘n×-Ñ-ˆð —z‘z -°Ó4ˆØ—z‘z +¨rÓ2ˆØŸ
™
 ;°Ó3ˆô ˜vÓ&ˆØÐØÐØÐð �N‰N×,Ñ,Ó.Ü×*Ñ*Ó,ñ-ð 	ô !×2Ñ2Ó4ˆä×/Ñ/Ó1Ü×*Ñ*Ó,ñ-ð 	ð 	× Ñ  Ô.ð ˆØ'3×'9Ñ'9Ö';Ñ#ˆJ˜Ø! \Ð1ˆHØ! \Ð1ˆHØœ^Ñ+à!×(Ñ(¨*°kÐ)BÕCÙ™hÜ6°zÓB�Ø!×(Ñ(¨*°kÐ)BÕCÙÜ5°jÓA�Ø!×(Ñ(¨*°kÐ)BÕCÙØ!×(Ñ(¨*°kÐ)BÕCä Ð!8×!?Ñ!?À
Ó!KÓLÐLò Ø—‘× Ñ  Õ-ð' (<ð, ˆØ'4×':Ñ':×'<Ñ#ˆJ˜Ø" mÐ3ˆIØ! \Ð1ˆHØ! \Ð1ˆHØœ^Ñ+à"×)Ñ)¨:°{Ð*CÖDÜ�i ¨8Ð4Ô5ÜAØØó�ð #×)Ñ)¨:°{Ð*CÕDÙ™xÜ7ØØó�ð #×)Ñ)¨:°{Ð*CÕDÙ™xÜ7ØØó�ð #×)Ñ)¨:°{Ð*CÕDÙØ"×)Ñ)¨:°{Ð*CÕDÙ™hÜAØØó�ð "×(Ñ(¨*°kÐ)BÕCÙÜ6ØØó�ð "×(Ñ(¨*°kÐ)BÕCÙÜ6ØØó�ð "×(Ñ(¨*°kÐ)BÕCä Ð!8×!?Ñ!?À
Ó!KÓLÐLó Ø—‘× Ñ  Ö-ðe (=ôj Ø,Ø*ñ
ó ˆ
ñ Ø×ÑœfØ—‘×'Ñ'Ð);ð&ó ô ð 	×Ñ˜:Ô&ØÐr   )	r6   Ú
__module__Ú__qualname__Ú__doc__r   r   r/   r-   Ú__classcell__)r3   s   @r   r+   r+   l   s-   ø„ ññ: ˆ:×#Ñ#Ó$ó.ó %ð.ö^r   r+   N)Ú	functoolsr   Úcopyr   Ú	traitletsr   Útraitlets.config.loaderr   Újupyter_core.applicationr   Újupyter_server.serverappr   Ú$jupyter_server.extension.applicationr	   Útraitsr   r   r   r   r   r   r   r!   r$   r;   r+   © r   r   Ú<module>r\      s]   ðÝ Ý Ý  õõ 0Ý .Ý =Ý %òòò	ò	ò	ò
òòð [€÷Cò Cr   