ó
    {ñ:i\$  ã                   óö   • S r SSKrSSKJr  SSKJrJr  SSKrSSKJ	r	  SSK
Jr  SSKJrJr  SSKJr  SSKr " S	 S
\	R$                  \	R&                  5      r " S S\5      rS rS rS rS rS rS rS rS rg)a   
Add a ``figure-mpl`` directive that is a responsive version of ``figure``.

This implementation is very similar to ``.. figure::``, except it also allows a
``srcset=`` argument to be passed to the image tag, hence allowing responsive
resolution images.

There is no particular reason this could not be used standalone, but is meant
to be used with :doc:`/api/sphinxext_plot_directive_api`.

Note that the directory organization is a bit different than ``.. figure::``.
See the *FigureMpl* documentation below.

é    N)Úrelpath)ÚPurePathÚPath)Únodes)Ú
directives)ÚFigureÚImage)ÚExtensionErrorc                   ó   • \ rS rSrSrg)Ú
figmplnodeé   © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__static_attributes__r   ó    Úh/srv/projetos/modelo_ml_acdoc/venv/lib/python3.13/site-packages/matplotlib/sphinxext/figmpl_directive.pyr   r      s   † Úr   r   c            	       óä   • \ rS rSrSrSrSrSrSr\	R                  \	R                  \	R                  \	R                  \R                  \	R                   \	R                  \	R                  S.rS rSrg	)
Ú	FigureMplé    a&  
Implements a directive to allow an optional hidpi image.

Meant to be used with the *plot_srcset* configuration option in conf.py,
and gets set in the TEMPLATE of plot_directive.py

e.g.::

    .. figure-mpl:: plot_directive/some_plots-1.png
        :alt: bar
        :srcset: plot_directive/some_plots-1.png,
                 plot_directive/some_plots-1.2x.png 2.00x
        :class: plot-directive

The resulting html (at ``some_plots.html``) is::

    <img src="sphx_glr_bar_001_hidpi.png"
        srcset="_images/some_plot-1.png,
                _images/some_plots-1.2x.png 2.00x",
        alt="bar"
        class="plot_directive" />

Note that the handling of subdirectories is different than that used by the sphinx
figure directive::

    .. figure-mpl:: plot_directive/nestedpage/index-1.png
        :alt: bar
        :srcset: plot_directive/nestedpage/index-1.png
                 plot_directive/nestedpage/index-1.2x.png 2.00x
        :class: plot_directive

The resulting html (at ``nestedpage/index.html``)::

    <img src="../_images/nestedpage-index-1.png"
        srcset="../_images/nestedpage-index-1.png,
                ../_images/_images/nestedpage-index-1.2x.png 2.00x",
        alt="bar"
        class="sphx-glr-single-img" />

where the subdirectory is included in the image name for uniqueness.
Fé   é   )ÚaltÚheightÚwidthÚscaleÚalignÚclassÚcaptionÚsrcsetc                 ó2  • [        5       nU R                  S   nU R                  R                  SS5      US'   U R                  R                  SS 5      US'   U R                  R                  SS 5      US'   U R                  R                  SS 5      US'   U R                  R                  SS 5      US'   U R                  R                  SS 5      US'   U R                  R                  S	S 5      US	'   X!S
'   U R                  R                  SS 5      US'   U/$ )Nr   r   Ú r   r    r   r   r   r!   Úurir"   )r   Ú	argumentsÚoptionsÚget)ÚselfÚ
image_nodeÚimagenms      r   ÚrunÚFigureMpl.runZ   s  € ä“\ˆ
à—.‘. Ñ#ˆØ ŸL™L×,Ñ,¨U°BÓ7ˆ
�5ÑØ"Ÿl™l×.Ñ.¨w¸Ó=ˆ
�7ÑØ"Ÿl™l×.Ñ.¨w¸Ó=ˆ
�7ÑØ"Ÿl™l×.Ñ.¨w¸Ó=ˆ
�7ÑØ#Ÿ|™|×/Ñ/°¸$Ó?ˆ
�8ÑØ"Ÿl™l×.Ñ.¨w¸Ó=ˆ
�7ÑØ $§¡× 0Ñ 0°¸DÓ Aˆ
�9Ñð $�5ÑØ#Ÿ|™|×/Ñ/°¸$Ó?ˆ
�8Ñàˆ|Ðr   r   N)r   r   r   r   Ú__doc__Úhas_contentÚrequired_argumentsÚoptional_argumentsÚfinal_argument_whitespacer   Ú	unchangedÚlength_or_unitlessÚ length_or_percentage_or_unitlessÚnonnegative_intr	   r   Úclass_optionÚoption_specr,   r   r   r   r   r   r       ss   † ñ(ðT €KØÐØÐØ %Ðà×#Ñ#Ø×/Ñ/Ø×<Ñ<Ø×+Ñ+Ø—‘Ø×(Ñ(Ø×'Ñ'Ø×&Ñ&ñ	€Kõr   r   c                 ó  • U R                  S5      n0 nU Hr  nUR                  5       R                  S5      n[        U5      S:X  a
  US   US'   M;  [        U5      S:X  a  US   SS nUS   U[        U5      '   Me  [	        SU S	35      e   U$ )
z
parse srcset...
Ú,Ú r   r   r   Néÿÿÿÿzsrcset argument "z" is invalid.)ÚsplitÚstripÚlenÚfloatr
   )ÚstÚentriesr"   ÚentryÚsplÚmults         r   Ú_parse_srcsetNodesrF   q   s–   € ð �h‰h�s‹m€GØ€FÛˆØ�k‰k‹m×!Ñ! #Ó&ˆÜˆs‹8�q‹=Ø˜A™ˆF�1‹IÜ�‹X˜‹]Ø�q‘6˜#˜2�;ˆDØ"% a¡&ˆF”5˜“;Óä Ð#4°U°G¸=Ð!IÓJÐJñ ð €Mr   c                 óò  • US   (       a  [        US   5      nOS n[        U R                  S   5      R                  nU R                  R
                  n[        X45      R                  SS5      R                  [        R                  S5      n[        U5      (       a  US-  n[        U R                  R                  U R                  R                  5      n[        U5      R                  SSS9  U(       aJ  UR                  5        H5  n[        X75      nXXR                   -   n	["        R$                  " X†U	-  5        M7     O5[        X1S   5      nXXR                   -   n	["        R$                  " X†U	-  5        XbU4$ )	Nr"   ÚsourceÚ.r$   Ú-T)ÚparentsÚexist_okr%   )rF   r   ÚdocumentÚparentÚbuilderÚsrcdirr   ÚreplaceÚosÚsepr?   ÚoutdirÚimagedirr   ÚmkdirÚvaluesÚnameÚshutilÚcopyfile)
r)   Únoder"   Ú	docsourceÚsrctopÚrelrU   ÚsrcÚabspathrX   s
             r   Ú_copy_images_figmplra   ƒ   s1  € ð ˆH‡~Ü# D¨¡NÓ3‰àˆô ˜Ÿ™ xÑ0Ó1×8Ñ8€Ið �\‰\× Ñ €FÜ
�)Ó
$×
,Ñ
,¨S°"Ó
5×
=Ñ
=¼b¿f¹fÀcÓ
J€CÜ
ˆ3‡x�xØˆs‰
ˆô ˜Ÿ™×+Ñ+¨T¯\©\×-BÑ-BÓC€Hô 	ˆƒN×Ñ °ÐÑ5ö Ø—=‘=–?ˆCä˜yÓ.ˆGØŸ™Ñ%ˆDÜ�OŠO˜G°¡_Ö5ò	 #ô ˜9¨5¡kÓ2ˆØ—\‘\Ñ!ˆÜ�Š˜¨D¡Ô1à˜SÐ Ð r   c           	      ó>  • [        X5      u  p#n[        U R                  S   5      n[        U R                  R                  S5      n[        XV5      n[        U R                  R                  S5      nX‡-  n	[        [        X)R                  5      5      R                  5       n
U R                  R                  S:X  a  SU
 3n
[        US   SS  5      R                  nU
 SU U 3nXÁS   S	.nUnU(       an  S
nSnUR                  5        HN  u  nn[        USS  5      R                  nU
 SU U 3nUU-  nUS:X  a  US-  nO
USUS S3-  nUU:”  d  MJ  UnUnMP     US S US'   US   b  SR                  US   5      US'   S H;  nUU   (       d  M  SU;  a  U SUU    S3US'   M%  US==   U SUU    S3-  ss'   M=     U R                  R                  U R                  USUS   (       a  SUS    3OSS95        U R                  R                  U R                  USSUS9U R                  " US40 UD6-   S -   5        US!   (       a¹  U R                  R                  U R                  US"5      5        U R                  R                  U R                  US#5      5        U R                  R                  U R                  US$S%S95        U R                  R                  US!   5        U R                  R                  S&5        U R                  R                  S'5        g )(NrH   r$   Údirhtmlz..r%   r   Ú/r   )r_   r   r<   r   z, r;   z1.2fzx, éþÿÿÿr"   r    )r   r   r   Ústylez: Ú;Úfigurer   zalign-zalign-center)ÚCLASSÚaz"reference internal image-reference)ri   ÚhrefÚimgz</a>
r!   Ú
figcaptionÚpÚspanzcaption-textz</span></p></figcaption>
z
</figure>
)ra   r   rM   rO   rP   r   rT   rN   Úas_posixrX   ÚitemsÚjoinÚbodyÚappendÚstarttagÚemptytag)r)   r[   rU   r"   r^   r\   r]   Ú	relsourceÚdesttopÚdestÚimagerelÚnmr%   Ú	img_attrsÚmaxsrcÚmaxmultÚsrcsetstrE   r_   Úpathrf   s                        r   Úvisit_figmpl_htmlr�   ª   s,  € ä/°Ó;Ñ€H�cô ˜Ÿ™ xÑ0Ó1€Iô �d—l‘l×)Ñ)¨2Ó.€Fä˜	Ó*€Iä�t—|‘|×*Ñ*¨BÓ/€GàÑ€Dô œ ¯+©+Ó6Ó7×@Ñ@ÓB€HØ‡|�|×Ñ˜IÓ%Ø˜�z�?ˆô 
�$�u‘+˜a˜b�/Ó	"×	'Ñ	'€BØˆJ�a˜�u˜R˜DÐ
!€CØ¨¡KÑ0€Ið €FÞØˆØˆØŸ™ž‰IˆD�#Ü˜#˜a˜b˜'Ó"×'Ñ'ˆBà�Z˜q   b TÐ*ˆDØ˜ÑˆHØ�q‹yØ˜DÑ ‘à˜a  T˜{¨#Ð.Ñ.�à�g�~Ø�Ø’ñ (ð ' s¨˜mˆ	�(ÑàˆG�}Ñ Ø ŸX™X d¨7¡mÓ4ˆ	�'ÑÛ-ˆØ��;‰;Ø˜iÓ'Ø(- w¨b°°e±°¸QÐ%?�	˜'Ó"à˜'Ó"¨¨¨r°$°u±+°¸aÐ&@Ñ@Õ"ñ .ð" 	‡I�I×ÑØ�‰Ø�(Ø.2°7¯m�F˜4 ™=˜/Ñ*Àð 	ð 	QôRð 	‡I�I×ÑØ�‰�d˜CÐ'KØ!ð 	ð 	#à�Š�d˜EÑ/ YÑ/ñ	0ð 	ñ	ôð
 ˆI‡Ø�	‰	×Ñ˜Ÿ™ t¨\Ó:Ô;Ø�	‰	×Ñ˜Ÿ™ t¨SÓ1Ô2Ø�	‰	×Ñ˜Ÿ™ t¨V¸>˜ÐJÔKØ�	‰	×Ñ˜˜i™Ô)Ø�	‰	×ÑÐ5Ô6Ø‡I�I×Ñ�]Õ#r   c                 ó˜   • US   b3  [        X5      u  p#Sn[        USS9n[        X4   5      R                  US'   U R	                  U5        g )Nr"   r<   )Údefaultr%   )ra   Úmaxr   rX   Úvisit_figure)r)   r[   rU   r"   r~   s        r   Úvisit_figmpl_latexr†   ÿ   sN   € àˆH�~Ñ!Ü.¨tÓ:ÑˆØˆä�f bÑ)ˆÜ˜v™Ó/×4Ñ4ˆˆU‰à×Ñ�dÕr   c                 ó   • g ©Nr   ©r)   r[   s     r   Údepart_figmpl_htmlrŠ     s   € Ør   c                 ó&   • U R                  U5        g rˆ   )Údepart_figurer‰   s     r   Údepart_figmpl_latexr�     s   € Ø×Ñ�tÕr   c                 óV   • U R                  [        [        [        4[        [
        4S9  g )N)ÚhtmlÚlatex)Úadd_noder   r�   rŠ   r†   r�   )Úapps    r   Úfigurempl_addnoder“     s(   € Ø‡L�L”Ü(Ô*<Ð=Ü*Ô,?Ð@ð ò Br   c                 óp   • U R                  S[        5        [        U 5        SS[        R                  S.nU$ )Nz
figure-mplT)Úparallel_read_safeÚparallel_write_safeÚversion)Úadd_directiver   r“   Ú
matplotlibÚ__version__)r’   Úmetadatas     r   Úsetuprœ     s4   € Ø×Ñ�l¤IÔ.Ü�cÔØ&*À4Ü%×1Ñ1ñ3€Hà€Or   )r.   rR   Úos.pathr   Úpathlibr   r   rY   Údocutilsr   Údocutils.parsers.rstr   Ú&docutils.parsers.rst.directives.imagesr   r	   Úsphinx.errorsr
   r™   ÚGeneralÚElementr   r   rF   ra   r�   r†   rŠ   r�   r“   rœ   r   r   r   Ú<module>r¥      sx   ðñó 
Ý ß "Û å Ý +ß @Ý (ã ô	�—‘ §¡ô 	ôN�ô Nòbò$$!òNR$òj	ò	òòBór   