
    Fg	                          S SK JrJr  S SKJrJrJr  S SKr	S SK
Jr  S SKJr   " S S5      r " S S	\5      rS
 rg! \ a     N1f = f)    )needs_local_scoperegister_cell_magic)argumentmagic_argumentsparse_argstringN)App)BaseReloaderc                   $    \ rS rSrSrS rS rSrg)CellIdTracker   zqDetermines the most recently run cell in the notebook.

Needed to keep track of which demo the user is updating.
c                 j    UR                   R                  SU R                  5        Xl        SU l        g )Npre_run_cell )eventsregisterr   shellcurrent_cell)selfipythons     c/Users/admin/workspace/ai/PDFMathTranslate/myenv/lib/python3.13/site-packages/gradio/ipython_ext.py__init__CellIdTracker.__init__   s)    0A0AB
!#    c                 &    UR                   U l        g N)cell_id_current_cell)r   infos     r   r   CellIdTracker.pre_run_cell   s    !\\r   )r   r   r   N)__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes__ r   r   r   r      s    
$
*r   r   c                      ^  \ rS rSrSrSU 4S jjr\S 5       r\S\4S j5       r	\S 5       r
S\4S jrS	\R                  4S
 jrSrU =r$ )JupyterReloader   zHSwap a running blocks class in a notebook with the latest cell contents.returnc                 P   > [         TU ]  5         [        U5      U l        0 U l        g r   )superr   r   _cell_tracker_running)r   r   	__class__s     r   r   JupyterReloader.__init__!   s"    *73.0r   c                 .    U R                   R                  $ r   )r-   r   r   s    r   r   JupyterReloader.current_cell&   s    !!...r   c                     U R                   R                  (       d  [        S5      eU R                   R                  R                  $ )NzServer not running)running_demoserverRuntimeErrorrunning_appr2   s    r   r8   JupyterReloader.running_app*   s5      ''344  ''333r   c                 4    U R                   U R                     $ r   r.   r   r2   s    r   r5   JupyterReloader.running_demo0   s    }}T..//r   c                 4    U R                   U R                  ;   $ r   )r   r.   r2   s    r   demo_trackedJupyterReloader.demo_tracked4   s      DMM11r   democ                 4    XR                   U R                  '   g r   r;   )r   r@   s     r   trackJupyterReloader.track7   s    +/d''(r   )r-   r.   )r*   N)r    r!   r"   r#   r$   r   propertyr   r   r8   r5   boolr>   grBlocksrB   r%   __classcell__)r/   s   @r   r(   r(      so    R1
 / / 4S 4 4
 0 02d 20")) 0 0r   r(   c           
         ^^ [        U 5      m[        5       [        SSSS9[        SSSSS	S
9[        [        UU4S j5       5       5       5       5       mg )Nz--demo-namer@   zName of gradio blocks instance.)defaulthelpz--shareFT?z9Whether to launch with sharing. Will slow down reloading.)rJ   constnargsrK   c                    > [        TU 5      n[        USU5        X#R                     nTR                  5       (       d+  UR	                  UR
                  S9  TR                  U5        gTR                  U5        TR                  R                  $ )z/Launch a demo defined in a cell in reload mode.N)share)
r   exec	demo_namer>   launchrP   rB   swap_blocksr5   artifact)linecelllocal_nsargsr@   blocksreloaders        r   rZ   &load_ipython_extension.<locals>.blocks>   sv     vt,T4"">>2$$&&KKdjjK)NN4   &((111r   )r(   r   r   r   r   )r   rZ   r[   s    @@r   load_ipython_extensionr]   ;   sc    w'HmV2STH 2   U 2r   )IPython.core.magicr   r   IPython.core.magic_argumentsr   r   r   ImportErrorgradiorF   gradio.routesr   gradio.utilsr	   r   r(   r]   r&   r   r   <module>rd      sS   	 XW   %* *0l 0:2i  		s   = AA