Ë
    ÁvžjB  ã                   óÔ  — d Z ddlZddlZddlZddlm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 ddlmZmZ ddlmZ ddlmZmZmZ ddlmZ dd	lmZ dd
lmZ 	 ddl m!Z! ddl#m$Z$  e%«       Z& ejN                   ejP                  e)«      «      Z*	 	 	 	 	 	 	 dd„Z+	 	 	 	 	 	 dd„Z,	 dd„Z-	 dd„Z.d„ Z/dd„Z0dd„Z1dd„Z2d„ Z3y# e$ r ddlmZmZ Y Œ¡w xY w# e$ r	 ddl"m!Z! Y Œ�w xY w)z?Utilities for installing Javascript extensions for the notebooké    N)ÚPath)ÚPackageNotFoundErrorÚversion)ÚbasenameÚnormpath)Újoin)ÚENV_JUPYTER_PATHÚSYSTEM_JUPYTER_PATHÚjupyter_data_dir)Úensure_dir_exists)ÚArgumentConflict)Úget_federated_extensions)Úloadé   )Ú_test_overlapc                 óZ  — d}t        |||¬«      }	t        |	«       t        | t        t        f«      rd}
t        |
«      ‚|st        t        | «      «      }t        t        |	|«      «      }|ržt        j                  j                  |«      r|r|j                  d|› �«       t        j                  j                  |«      r5t        j                  j                  |«      st        j                   |«       nt        j"                  |«       t        j$                  t        j                  j'                  |«      d¬«       |r¡t        j                  j)                  | «      } t        j                  j+                  |«      s2|r|j                  d|› d| › �«       	 t        j,                  | |«       |S t        j                  j                  |«      s|› d�}
t5        |
«      ‚|S t        j                  j                  | «      rØt        t        j                  j)                  | «      d«      } t        j6                  | «      D ]•  \  }}}t        ||t9        | «      d «      }t        j                  j+                  |«      s+|r|j                  d|› �«       t        j$                  |«       |D ](  }t        ||«      }t        ||«      }t;        |||¬«       Œ* Œ— |S | }t;        |||¬«       |S # t.        $ r7}t1        j0                  «       j3                  d	«      rd
}
t/        |
«      |‚‚ d}~ww xY w)aZ  Install a prebuilt extension for JupyterLab

    Stages files and/or directories into the labextensions directory.
    By default, this compares modification time, and only stages files that need updating.
    If `overwrite` is specified, matching files are purged before proceeding.

    Parameters
    ----------

    path : path to file, directory, zip or tarball archive, or URL to install
        By default, the file will be installed with its base name, so '/path/to/foo'
        will install to 'labextensions/foo'. See the destination argument below to change this.
        Archives (zip or tarballs) will be extracted into the labextensions directory.
    user : bool [default: False]
        Whether to install to the user's labextensions directory.
        Otherwise do a system-wide install (e.g. /usr/local/share/jupyter/labextensions).
    overwrite : bool [default: False]
        If True, always install the files, regardless of what may already be installed.
    symlink : bool [default: True]
        If True, create a symlink in labextensions, rather than copying files.
        Windows support for symlinks requires a permission bit which only admin users
        have by default, so don't rely on it.
    labextensions_dir : str [optional]
        Specify absolute path of labextensions directory explicitly.
    destination : str [optional]
        name the labextension is installed to.  For example, if destination is 'foo', then
        the source file will be installed to 'labextensions/foo', regardless of the source name.
    logger : Jupyter logger [optional]
        Logger instance to use
    N)ÚuserÚ
sys_prefixÚlabextensions_dirz�path must be a string pointing to a single extension to install; call this function multiple times to install multiple extensionsz
Removing: T)Úexist_okzSymlinking: ú -> ÚWindowszýSymlinks can be activated on Windows 10 for Python version 3.8 or higher by activating the 'Developer Mode'. That may not be allowed by your administrators.
See https://docs.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-developmentz exists and is not a symlinkÚ zMaking directory: ©Úlogger)Ú_get_labextension_dirr   Ú
isinstanceÚlistÚtupleÚ	TypeErrorr   r   ÚpjoinÚosÚpathÚlexistsÚinfoÚisdirÚislinkÚshutilÚrmtreeÚremoveÚmakedirsÚdirnameÚabspathÚexistsÚsymlinkÚOSErrorÚplatformÚ
startswithÚ
ValueErrorÚwalkÚlenÚ_maybe_copy)r#   r/   Ú	overwriter   r   Údestinationr   r   Ú	full_destÚlabextÚmsgÚeÚparentÚ_ÚfilesÚdest_dirÚ	file_nameÚsrcÚ	dest_files                      ús/workspace/moltex-experiments/.pixi/envs/default/lib/python3.12/site-packages/jupyterlab/federated_labextensions.pyÚdevelop_labextensionrE   .   s“  € ðR €Iä"Ø˜jÐ<Mô€Fô �fÔä�$œœu˜Ô&ð RˆÜ˜‹nÐáÜœx¨›~Ó.ˆäœ˜v {Ó3Ó4€IÙ”R—W‘W—_‘_ YÔ/ÙØ�K‰K˜* Y KÐ0Ô1Ü�7‰7�=‰=˜Ô#¬B¯G©G¯N©N¸9Ô,EÜ�M‰M˜)Õ$ä�I‰I�iÔ ô ‡K�K”—‘—‘ 	Ó*°TÕ:áÜ�w‰w�‰˜tÓ$ˆÜ�w‰w�~‰~˜iÔ(ÙØ—‘˜l¨9¨+°T¸$¸Ð@ÔAð
Ü—
‘
˜4 Ô+ð> Ðô) —‘—‘ 	Ô*Ø�KÐ;Ð<ˆCÜ˜S“/Ð!ð$ Ðô! 
�‰�‰�tÔ	Ü”R—W‘W—_‘_ TÓ*¨BÓ/ˆÜ "§¡¨¦ÑˆF�A�uÜ˜Y¨¬s°4«y¨{Ð(;Ó<ˆHÜ—7‘7—>‘> (Ô+ÙØ—K‘KÐ"4°X°JÐ ?Ô@Ü—‘˜HÔ%Û"�	Ü˜F IÓ.�Ü! (¨IÓ6�	Ü˜C °6Ö:ñ #ð !.ð Ðð ˆÜ�C˜¨6Õ2àÐøô= ò Ü×$Ñ$Ó&×1Ñ1°)Ô<ð{ð ô
 " #›,¨AÐ-Øûðús   ÆK* Ë*	L*Ë32L%Ì%L*c                 ó®  — t        | «      \  }}t        j                  j                  |j                  «      d   }	g }
|D ]“  }t        j                  j                  |	|d   «      }|d   }|r|j                  d|› d|› �«       t        j                  j                  |«      st        |	|¬«       t        ||||||||¬«      }|
j                  |«       Œ• |
S )z¢Develop a labextension bundled in a Python package.

    Returns a list of installed/updated directories.

    See develop_labextension for parameter information.r   rB   ÚdestzInstalling r   r   )r7   r/   r   r   r   r8   r   )Ú_get_labextension_metadatar"   r#   ÚsplitÚ__file__r   r%   r.   Úbuild_labextensionrE   Úappend)Úmoduler   r   r7   r/   r   r   ÚmÚlabextsÚ	base_pathÚ
full_destsr:   rB   rG   r9   s                  rD   Údevelop_labextension_pyrR   š   sÍ   € ô ,¨FÓ3�J€A€wÜ—‘—‘˜aŸj™jÓ)¨!Ñ,€Ià€JãˆÜ�g‰g�l‰l˜9 f¨U¡mÓ4ˆØ�f‰~ˆÙØ�K‰K˜+ c U¨$¨t¨fÐ5Ô6ä�w‰w�~‰~˜cÔ"Ü˜y°Õ8ä(ØØØØØ!Ø/ØØô	
ˆ	ð 	×Ñ˜)Õ$ð' ð* Ðó    c                 óº  — |€t        j                  t        d«      n!t        t	        |«      j                  «       «      }t        t	        | «      j                  «       «      }|r|j                  d| › �«       t        ||«      }d|d||g}|�|j                  d|g«       |r|j                  d«       |r|j                  d«       t        j                  ||¬	«       y)
z&Build a labextension in the given pathNÚstagingúBuilding extension in Únodeú--core-pathz--static-urlú--developmentú--source-map©Úcwd)Úospr   ÚHEREÚstrr   Úresolver%   Ú_ensure_builderÚextendrL   Ú
subprocessÚ
check_call)	r#   r   ÚdevelopmentÚ
static_urlÚ
source_mapÚ	core_pathÚext_pathÚbuilderÚ	argumentss	            rD   rK   rK   Å   sÂ   € ð .7Ð->”—‘œ˜yÔ)ÄCÌÈYË×H_ÑH_ÓHaÓDb€Iä”4˜“:×%Ñ%Ó'Ó(€HáØ�‰Ð,¨T¨FÐ3Ô4ä˜h¨	Ó2€Gà˜ -°¸HÐE€IØÐØ×Ñ˜.¨*Ð5Ô6ÙØ×Ñ˜Ô)ÙØ×Ñ˜Ô(ä×Ñ˜)¨Ö2rS   c                 ó>  — |€t        j                  t        d«      n!t        t	        |«      j                  «       «      }t        t	        | «      j                  «       «      }|r|j                  d| › �«       t        |«      }t        t        |d«      «      5 }t        j                  |«      }	ddd«       	d   |vrt        |d¬«       nwt        ||	d      d   |	d   «      }
t        ||	d	   j                  d
d«      «      }t        j                  |
«      s+t        j                   |
«       t#        j$                  ||
«       t'        ||«      }d|d|d|g}|r|j)                  d«       |r|j)                  d«       t+        j,                  ||¬«       y# 1 sw Y   ŒçxY w)z$Watch a labextension in a given pathNrU   rV   úpackage.jsonÚnameT)r   Úext_dirÚ
jupyterlabÚ	outputDirÚstaticrW   rX   z--watchrY   rZ   r[   )r]   r   r^   r_   r   r`   r%   r   Úopenr!   Újsonr   rR   Úgetr'   r(   r)   r"   r/   ra   rL   rc   rd   )r#   Úlabextensions_pathr   re   rg   rh   ri   Úfederated_extensionsÚfidÚext_datar9   Ú
output_dirrj   rk   s                 rD   Úwatch_labextensionr{   Ý   se  € ð .7Ð->”—‘œ˜yÔ)ÄCÌÈYË×H_ÑH_ÓHaÓDb€IÜ”4˜“:×%Ñ%Ó'Ó(€HáØ�‰Ð,¨T¨FÐ3Ô4ô 4Ð4FÓGÐä	Œe�H˜nÓ-Ô	.°#Ü—9‘9˜S“>ˆ÷ 
/ð �ÑÐ3Ñ3Ü °TÖ:äÐ.¨x¸Ñ/?Ñ@ÀÑKÈXÐV\ÑM]Ó^ˆ	Ü˜8 X¨lÑ%;×%?Ñ%?ÀÈXÓ%VÓWˆ
Ü�z‰z˜)Ô$Ü�M‰M˜)Ô$Ü�J‰J�z 9Ô-ä˜h¨	Ó2€GØ˜ -°¸IÀxÐP€IÙØ×Ñ˜Ô)ÙØ×Ñ˜Ô(ä×Ñ˜)¨Ö2÷' 
/Ð	.ús   ÂFÆFc           	      ó¢  — t        t        j                  |d«      «      5 }t        j                  |«      }ddd«       t        t        j                  | d«      «      5 }t        j                  |«      }ddd«       d   d   }j                  di «      j                  d«      }|xs! |j                  di «      j                  d«      }|€d|› �}t        |«      ‚d|v rMt        t        j                  | |d«      «      5 }t        j                  |«      j                  d«      }ddd«       t        j                  t        j                  | d	«      «      st        j                  d
g| ¬«       | }t        j                  t        j                  |d	dd«      «      sft        j                  |«      |k(  rd}t        |«      ‚t        j                  |«      }t        j                  t        j                  |d	dd«      «      sŒft        ||dd¬«      }	|	s^t        t        j                  |d	ddd«      «      5 }t        j                  |«      j                  d«      }ddd«       t        ||dd¬«      }	|	sd|› d|› �}t        |«      ‚t        j                  |d	dddd«      S # 1 sw Y   �ŒjxY w# 1 sw Y   �Œ:xY w# 1 sw Y   �Œ–xY w# 1 sw Y   ŒnxY w)zIEnsure that we can build the extension and return the builder script pathrm   NÚdevDependenciesz@jupyterlab/builderÚdependenciesz:Extensions require a devDependency on @jupyterlab/builder@Ú/r   Únode_modulesÚjlpmr[   z@jupyterlabrj   z"Could not find @jupyterlab/builderT)Údrop_prerelease1Údrop_prerelease2z, you have a dependency on Úlibzbuild-labextension.js)rs   r]   r   rt   r   ru   r3   r.   rc   rd   r,   r   )
ri   rh   rx   Ú	core_datary   Údep_version1Údep_version2r;   ÚtargetÚoverlaps
             rD   ra   ra     sr  € ô 
Œc�h‰h�y .Ó1Ô	2°cÜ—I‘I˜c“Nˆ	÷ 
3ä	Œc�h‰h�x Ó0Ô	1°SÜ—9‘9˜S“>ˆ÷ 
2àÐ.Ñ/Ð0EÑF€LØ—<‘<Ð 1°2Ó6×:Ñ:Ð;PÓQ€LØÒ^ 8§<¡<°ÀÓ#C×#GÑ#GÐH]Ó#^€LØÐØJÈ<È.ÐYˆÜ˜‹oÐð ˆlÑÜ”#—(‘(˜8 \°>ÓBÔCÀsÜŸ9™9 S›>×-Ñ-¨iÓ8ˆL÷ Dä�:‰:”c—h‘h˜x¨Ó8Ô9Ü×Ñ˜v˜h¨HÕ5ð €FÜ�j‰jœŸ™ &¨.¸-ÈÓSÔTÜ�;‰;�vÓ &Ò(Ø6ˆCÜ˜S“/Ð!Ü—‘˜VÓ$ˆô	 �j‰jœŸ™ &¨.¸-ÈÓSÕTô Ø�l°TÈDô€Gñ ÜÜ�H‰H�V˜^¨]¸IÀ~ÓVô
àÜŸ9™9 S›>×-Ñ-¨iÓ8ˆL÷
ô  Ø˜,¸ÐPTô
ˆñ ØJÈ<È.ÐXsð  uAð  tBð  CˆÜ˜‹oÐä�8‰8Ø� ¨y¸%ÐAXóð ÷Y 
3Ñ	2úç	1Ñ	1ú÷ DÑCú÷$
ð 
ús/    JÁJ+Ã?%J8È3%KÊJ(Ê+J5Ê8KËKc                 ó"  — t         j                  j                  |«      syt        j                  | «      j                  t        j                  |«      j                  z
  dkD  r|r|j                  d|› �«       y|r|j                  d|› �«       y)am  Should a file be copied, if it doesn't exist, or is newer?

    Returns whether the file needs to be updated.

    Parameters
    ----------

    src : string
        A path that should exist from which to copy a file
    src : string
        A path that might exist to which to copy a file
    logger : Jupyter logger [optional]
        Logger instance to use
    Tg�íµ ÷Æ°>zOut of date: zUp to date: F)r"   r#   r.   ÚstatÚst_mtimeÚwarningr%   ©rB   rG   r   s      rD   Ú_should_copyr�   9  st   € ô �7‰7�>‰>˜$ÔØÜ	‡w�wˆsƒ|×ÑœrŸw™w t›}×5Ñ5Ñ5¸Ò<ñ Ø�N‰N˜]¨4¨&Ð1Ô2ØÙØ�‰�l 4 &Ð)Ô*ØrS   c                 ó€   — t        | ||¬«      r0|r|j                  d| › d|› �«       t        j                  | |«       yy)a!  Copy a file if it needs updating.

    Parameters
    ----------

    src : string
        A path that should exist from which to copy a file
    src : string
        A path that might exist to which to copy a file
    logger : Jupyter logger [optional]
        Logger instance to use
    r   z	Copying: r   N)r�   r%   r(   Úcopy2rŽ   s      rD   r6   r6   U  s?   € ô �C˜ fÕ-ÙØ�K‰K˜) C 5¨¨T¨FÐ3Ô4Ü�‰�S˜$Õð .rS   c                 óŒ  — d| fd|fd|fd|fg}|D ��cg c]  \  }}|sŒ	|› d|›�‘Œ }}}t        |«      dkD  r+dj                  dj                  |«      «      }t        |«      ‚| rt	        t        «       d	«      }	|	S |rt	        t        d
   d	«      }	|	S |rt	        |ddd	«      }	|	S |r|}	|	S t	        t        d
   d	«      }	|	S c c}}w )a‘  Return the labextension directory specified

    Parameters
    ----------

    user : bool [default: False]
        Get the user's .jupyter/labextensions directory
    sys_prefix : bool [default: False]
        Get sys.prefix, i.e. ~/.envs/my-env/share/jupyter/labextensions
    prefix : str [optional]
        Get custom prefix
    labextensions_dir : str [optional]
        Get what you put in
    r   Úprefixr   r   Ú=r   z[cannot specify more than one of user, sys_prefix, prefix, or labextensions_dir, but got: {}z, Úlabextensionsr   ÚshareÚjupyter)r5   Úformatr   r   r!   r   r	   r
   )
r   r   r“   r   ÚconflictingÚnÚvÚconflicting_setr;   r:   s
             rD   r   r   h  s  € ð  
�ˆØ	�6ÐØ	Ð/Ð0Ø	�zÐ"ð	€Kñ 1<ÔA±©¨¨1ºq˜!˜˜A˜a˜U’|°€OÑAÜ
ˆ?Ó˜aÒØk×rÑrØ�I‰I�oÓ&ó
ˆô ˜sÓ#Ð#ÙÜÔ'Ó)¨?Ó;ˆð €Mñ 
ÜÔ'¨Ñ*¨OÓ<ˆð €Mñ 
Ü�v˜w¨	°?ÓCˆð
 €Mñ	 
Ø"ˆð €Mô Ô*¨1Ñ-¨Ó?ˆØ€Mùó! Bs
   ”
C Ÿ	C c           	      óº  — t        j                  | «      }t        j                  |«      sd|› d�}t        |«      ‚g }	 t	        j
                  | «      }t        |d«      r||j                  «       fS 	 d}t        j                  j                  t        j                  j                  |d«      «      r_t        t        j                  j                  |d«      d«      5 }t        |«      }ddd«       j                  di «      j                  d«      }|sF	 t!        j"                  t$        j&                  d	d
g|¬«      j)                  d«      j+                  «       }	 t/        |«       ddlm}	m}
 |j=                  dd«      g}|j?                   |
|«      «       |j?                   |	|«      «       |D ]8  }	 t	        j
                  |«      }t        |d«      r||j                  «       fc S Œ: d| › d|› �}tA        |«      ‚# t        $ r}|j                  |«       Y d}~�Œ«d}~ww xY w# 1 sw Y   �Œ@xY w# t         j,                  $ r d| › d�}t        |«      d‚w xY w# t0        $ rM t!        j2                  t$        j&                  dddd|g«       t$        j                  j5                  d|«       Y �ŒLw xY w# t        $ r}|j                  |«       Y d}~�Œ%d}~ww xY w)af  Get the list of labextension paths associated with a Python module.

    Returns a tuple of (the module path,             [{
        'src': 'mockextension',
        'dest': '_mockdestination'
    }])

    Parameters
    ----------

    module : str
        Importable Python module exposing the
        magic-named `_jupyter_labextension_paths` function
    z
The path `z` does not exist.Ú_jupyter_labextension_pathsNzpyproject.tomlÚrbÚprojectrn   zsetup.pyz--namer[   Úutf8zThe Python package `z<` is not a valid package, it is missing the `setup.py` file.z-mÚpipÚinstallz-er   )Úfind_namespace_packagesÚfind_packagesÚ-r>   zThere is no labextension at z. Errors encountered: )!r]   r-   r.   ÚFileNotFoundErrorÚ	importlibÚimport_moduleÚhasattrrž   Ú	ExceptionrL   r"   r#   r   rs   r   ru   rc   Úcheck_outputÚsysÚ
executableÚdecodeÚstripÚCalledProcessErrorr   r   rd   ÚinsertÚ
setuptoolsr¤   r¥   Úreplacerb   ÚModuleNotFoundError)rM   Úmod_pathr;   ÚerrorsrN   ÚexcÚpackagerx   Údatar¤   r¥   Úpackage_candidatess               rD   rH   rH   �  s¨  € ô �{‰{˜6Ó"€HÜ�:‰:�hÔØ˜8˜*Ð$5Ð6ˆÜ Ó$Ð$à€FðÜ×#Ñ# FÓ+ˆÜ�1Ð3Ô4Ø�a×3Ñ3Ó5Ð5Ð5ð 5ð €Gô 
‡w�w‡~�~”b—g‘g—l‘l 8Ð-=Ó>Ô?Ü”"—'‘'—,‘,˜xÐ)9Ó:¸DÔAÀSÜ˜“9ˆD÷ Bà—(‘(˜9 bÓ)×-Ñ-¨fÓ5ˆñ ð	3ä×'Ñ'Ü—^‘^ Z°Ð:Ø ô÷ ‘˜“ß‘“ð ð %Ü�Ô÷
 Bð 	�‰˜˜SÓ!ðÐð ×Ñ™m¨HÓ5Ô6Ø×ÑÙ Ó)ôó &ˆð	Ü×'Ñ'¨Ó0ˆAÜ�qÐ7Ô8Ø˜!×7Ñ7Ó9Ð9Ò9ð 9ð &ð )¨¨Ð0FÀvÀhÐ
O€CÜ
˜cÓ
"Ð"øôq ò Ø�‰�c×Òûðú÷ BÑAûô ×,Ñ,ò 	3à& v hð /5ð 5ð ô $ CÓ(¨dÐ2ð	3ûô  ò %Ü×ÑœsŸ~™~¨t°U¸IÀtÈXÐVÔWÜ�‰�‰˜˜8×$ð%ûô& ò 	Ø�M‰M˜#×Òûð	ús[   ¿2G> ÃH&ÄAH3 ÅI Æ42J5Ç>	H#ÈHÈH#È&H0È3&IÉAJ2Ê1J2Ê5	KÊ>KËK)TFFNNNF)FFTTNN)NFNFN)NFFN)N)FFNN)4Ú__doc__r¨   rt   r"   Úos.pathr#   r]   r1   r(   rc   r­   Úpathlibr   Úimportlib.metadatar   r   ÚImportErrorÚimportlib_metadatar   r   r   r!   Újupyter_core.pathsr	   r
   r   Újupyter_core.utilsr   Ú(jupyter_server.extension.serverextensionr   Újupyterlab_server.configr   Útomllibr   ÚtomliÚcommandsr   ÚobjectÚDEPRECATED_ARGUMENTr-   r,   rJ   r^   rE   rR   rK   r{   ra   r�   r6   r   rH   © rS   rD   Ú<module>rÌ      s  ðÙ Eó
 Û Û 	Ý Û Û Û Û 
Ý ðAß@÷ 'Ý !ç VÑ VÝ 0Ý EÝ =ðÝõ $á“hÐ à€s‡{�{�;�3—;‘;˜xÓ(Ó)€ð ØØ	ØØØØóið\ 
ØØØØØó(ðX X\ó3ð2 [_ó 3òP1óhó8 ó&%óPS#øð} ò Aß@Ñ@ðAûð ò ßðús#   ¬C ÁC ÃCÃCÃC'Ã&C'