
    h@                     H   S r SSKJr  SSKrSSKrSSKrSSKrSSKJr  SSK	J
r
JrJr  SSKJr  SSKJr  SSKJrJrJr  S	S
KJrJrJr  S	SKJrJr  S rSSSSSSSS.r " S S\5      r " S S\5      r " S S\5      r " S S5      r \RB                   " S S\5      5       r"g)z,Interactive figures in the IPython notebook.    )	b64encodeN)Comm)display
JavascriptHTML)is_interactiveGcf)_Backend
CloseEventNavigationToolbar2   )FigureCanvasWebAggCoreFigureManagerWebAggNavigationToolbar2WebAgg)TimerTornadoTimerAsyncioc                     [         R                  " 5        V s/ s HU  n SR                  U R                  R                  R                  5       =(       d    SU R                   3U R                  S9PMW     nn [        5       (       d+  UR                  S[        [         R                  5       35        SR                  U5      $ s  sn f )z
Return a string showing the figure and connection status for the backend.

This is intended as a diagnostic tool, and not for general use.
z{fig} - {socket}zFigure )figsocketzFigures pending show: 
)r
   get_all_fig_managersformatcanvasfigure	get_labelnumweb_socketsr   appendlenfigsjoin)managerresults     S/var/www/html/env/lib/python3.13/site-packages/matplotlib/backends/backend_nbagg.pyconnection_infor&      s     //1
 2G	 	!!&&002 ,gkk]+&& 	" 	( 2   .s388}o>?99Vs   ACz
fa fa-homezfa fa-arrow-leftzfa fa-arrow-rightzfa fa-square-ozfa fa-arrowszfa fa-floppy-o)homebackforwardzoom_to_rectmovedownloadNc                       \ rS rSr\R
                  S-    V VVVVVs/ s H  u  pp4U[        ;   d  M  X[        U   U4PM      snnnnnn rSrgs  snnnnnn f )NavigationIPy5   ))DownloadzDownload plotr,   r,    N)__name__
__module____qualname____firstlineno__r   	toolitems_FONT_AWESOME_CLASSES__static_attributes__).0texttooltip_text
image_filename_of_methodr7   s   000000r%   r.   r.   5   sf     (11MN9 9N DT "77E$'
3^EN9I 9s
   AAr.   c                      ^  \ rS rSr\=rrU 4S jr\S 5       r	S r
S rS r\S 5       r\SU 4S jj5       rS	 rS
 rS rS rSrU =r$ )FigureManagerNbAgg@   c                 2   > SU l         [        TU ]	  X5        g )NF)_shownsuper__init__)selfr   r   	__class__s      r%   rD   FigureManagerNbAgg.__init__C   s    %    c                    ^^^ U" U5      mU " TU5      m[        5       (       a   TR                  5         TR                  5         UUU4S jnTR                  SU5      mT$ )Nc                 T   > TR                  T5        [        R                  " T5        g N)mpl_disconnectr
   destroy)eventr   cidr#   s    r%   rM   6FigureManagerNbAgg.create_with_canvas.<locals>.destroyO   s    !!#&KK rH   close_event)r   show	draw_idlempl_connect)clscanvas_classr   r   rM   r   rO   r#   s        @@@r%   create_with_canvas%FigureManagerNbAgg.create_with_canvasG   sU    f%fc"LLN	!   8rH   c                 P    [        [        [        R                  5       5      5        g rK   )r   r   r?   get_javascriptrE   s    r%   
display_jsFigureManagerNbAgg.display_jsV   s     	
-<<>?@rH   c                    U R                   (       d!  U R                  5         U R                  5         OU R                  R	                  5         SU l         [        U S5      (       a%  U R                  R                  U R                  5        [        5       (       d-  SSK	J
n  UR                  R                  U R                  S 5        g g )NT_cidgcfr   r	   )rB   r\   _create_commr   rS   hasattrrL   r_   r   matplotlib._pylab_helpersr
   r!   popr   )rE   r
   s     r%   rR   FigureManagerNbAgg.show\   s    {{OOKK!!#
 4##KK&&t||45HHLL4(  rH   c                 2    SU l         U R                  5         g)z:
A special method to re-show the figure in the notebook.

FN)rB   rR   r[   s    r%   reshowFigureManagerNbAgg.reshowm   s    
 		rH   c                 ,    [        U R                  5      $ rK   )boolr   r[   s    r%   	connectedFigureManagerNbAgg.connectedu   s    D$$%%rH   c                   > Uc  [         R                  " 5       nOUn[        TU ]  US9  UR	                  [
        R                  " [        5      R                  S-  R                  SS95        Uc  UR                  5       $ g )N)streamzweb_backend/js/nbagg_mpl.jszutf-8)encoding)ioStringIOrC   rZ   writepathlibPath__file__parent	read_textgetvalue)rU   rm   outputrF   s      r%   rZ   !FigureManagerNbAgg.get_javascripty   sr    >[[]FFf-gll8,3356ii1	3 >??$$ rH   c                 >    [        U 5      nU R                  U5        U$ rK   )
CommSocketadd_web_socketrE   comms     r%   r`   FigureManagerNbAgg._create_comm   s    $D!rH   c                     U R                  S5        [        U R                  5       H  nUR                  5         M     U R	                  5         g )Nclose)_send_eventlistr   on_closeclearup_closedr}   s     r%   rM   FigureManagerNbAgg.destroy   s:    !))*DMMO +rH   c                     U R                    Vs1 s H  nUR                  5       (       d  M  UiM     snU l         [        U R                   5      S:X  a%  [        SU R                  5      R                  5         ggs  snf )zClear up any closed Comms.r   rQ   N)r   is_openr    r   r   _process)rE   r   s     r%   r   !FigureManagerNbAgg.clearup_closed   sh    151A1A 11Av%~~/ #1A 1 t A%}dkk2;;= &1s
   A9A9c                     U R                    Vs1 s H!  nUR                  R                  U:w  d  M  UiM#     snU l         g s  snf rK   )r   r~   comm_id)rE   r   r   s      r%   remove_commFigureManagerNbAgg.remove_comm   s?    151A1A ?1Av%{{22g= #1A ? ?s
   A A )rB   r   rK   )r2   r3   r4   r5   r.   _toolbar2_class
ToolbarClsrD   classmethodrW   r\   rR   rf   propertyrj   rZ   r`   rM   r   r   r8   __classcell__)rF   s   @r%   r?   r?   @   sw    #00Oj&  A)" & & 
% 
%
>? ?rH   r?   c                       \ rS rSr\rSrg)FigureCanvasNbAgg   r1   N)r2   r3   r4   r5   r?   manager_classr8   r1   rH   r%   r   r      s    &MrH   r   c                   <    \ rS rSrSrS rS rS rS rS r	S r
S	rg
)r{      a4  
Manages the Comm connection between IPython and the browser (client).

Comms are 2 way, with the CommSocket being able to publish a message
via the send_json method, and handle a message with on_message. On the
JS side figure.send_message and figure.ws.onmessage do the sending and
receiving respectively.

c                   ^ ^ S T l         TT l        [        [        R                  " 5       5      T l        [        [        ST R                  -  5      5         [        SST R                  0S9T l        T R                  R                  T R                  5        T R                  mST l        UU 4S jnT R                  R                  U5        g ! [         a  n[        S5      UeS nAff = f)Nz<div id=%r></div>
matplotlibid)datazTUnable to create an IPython notebook Comm instance. Are you in the IPython notebook?Fc                 b   > STl         TR                  U S   S   5        TR                  5         g )NTcontentr   )
_ext_closer   r   )close_messager#   rE   s    r%   	_on_close&CommSocket.__init__.<locals>._on_close   s.    "DOi 8 CD""$rH   )supports_binaryr#   struuiduuid4r   r   r   r~   AttributeErrorRuntimeErroron_msg
on_messager   r   )rE   r#   errr   s   ``  r%   rD   CommSocket.__init__   s    #

%	 	(499456	5\tyy0ABDI
 			),,	%
 			9%  	5  + ,145	5s   C 
C'C""C'c                 ^    U R                   =(       d    U R                  R                  (       + $ rK   )r   r~   _closedr[   s    r%   r   CommSocket.is_open   s    OO8tyy'8'899rH   c                     U R                  5       (       a   U R                  R                  5         g g ! [         a     g f = frK   )r   r~   r   KeyErrorr[   s    r%   r   CommSocket.on_close   s;     <<>>		!   s   3 
A A c                 f    U R                   R                  S[        R                  " U5      05        g )Nr   )r~   sendjsondumps)rE   r   s     r%   	send_jsonCommSocket.send_json   s     		

7 345rH   c                     U R                   (       a  U R                  R                  SS0U/S9  g [        U5      R	                  S5      nSU 3nU R                  R                  SU05        g )Nblobz	image/png)buffersasciizdata:image/png;base64,r   )r   r~   r   r   decode)rE   r   r   data_uris       r%   send_binaryCommSocket.send_binary   s]    IINNFK04&NA T?))'2D/v6HIINNFH-.rH   c                    [         R                  " US   S   5      nUS   S:X  a+  U R                  5         U R                  R	                  5         g US   S:X  a  US   U l        g U R                  R                  U5        g )Nr   r   typeclosingr   value)r   loadsr   r#   r   r   handle_json)rE   messages     r%   r   CommSocket.on_message   sm     **WY/786?i'MMOLL'')V_ 11#*7#3D LL$$W-rH   )r   r~   r#   r   r   N)r2   r3   r4   r5   __doc__rD   r   r   r   r   r   r8   r1   rH   r%   r{   r{      s%    &2:6/.rH   r{   c                       \ rS rSr\r\rSrg)_BackendNbAgg   r1   N)	r2   r3   r4   r5   r   FigureCanvasr?   FigureManagerr8   r1   rH   r%   r   r      s    $L&MrH   r   )#r   base64r   ro   r   rr   r   ipykernel.commr   IPython.displayr   r   r   r   r   rb   r
   matplotlib.backend_basesr   r   r   backend_webagg_corer   r   r   r   r   r&   r7   r.   r?   r   r{   exportr   r1   rH   r%   <module>r      s    2
  	     5 5 % ) M MK K & "$ 
 9, 9\?, \?~'. 'J. J.Z 
'H ' 'rH   