Ë
    W¨œjÎ  ã            	       óB  — d Z ddlmZmZmZ ddlmZmZmZ ddl	Z	ddl
Z
ddlZddlZddlmZ erddlmZ  e
j$                  d«      Z G d	„ d
e«      Z	 	 ddededed   defd„Zdee   dee   deddfd„Zdedej8                  fd„Zddee   dedej8                  fd„Zy)zÂ
Parse SVG path element d-strings into svgpathtools Path objects.

This submodule contains the parse_path() function.  Note: this file was
taken (nearly) as is from the svg.path module (v 2.0).
é    )ÚdivisionÚabsolute_importÚprint_function)ÚOptionalÚSequenceÚTYPE_CHECKINGNé   ©ÚPath)ÚElementz5[+-]?([0-9]+(\.[0-9]*)?|\.[0-9]+)([eE][+-]?[0-9]+)?\Zc                   ó   — e Zd ZdZy)ÚSVGSyntaxWarningzACategory for warnings about invalid SVG syntax handled leniently.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    úd/workspace/moltex-experiments/.pixi/envs/default/lib/python3.12/site-packages/svgpathtools/parser.pyr   r      s   „ ÚKr   r   ÚpathdefÚcurrent_posÚtree_elementr   Úreturnc                 ó   — t        | ||¬«      S )z8Convert an SVG path element d-string into a Path object.)r   r   r
   )r   r   r   s      r   Ú
parse_pathr   "   s   € ô � [¸|ÔLÐLr   ÚvaluesÚallowedÚtransform_substrc           	      óB  ‡ — t        ˆ fd„|D «       «      sŠt        |«      dkD  r&t        dj                  |t        ‰ «      |‰ «      «      ‚|d   dk7  r)t        dj                  |d   |t        ‰ «      ‰ «      «      ‚t        dj                  |t        ‰ «      ‰ «      «      ‚y )Nc              3   ó:   •K  — | ]  }|t        ‰«      k(  –— Œ y ­w©N)Úlen)Ú.0Únumr   s     €r   Ú	<genexpr>z+_check_num_parsed_values.<locals>.<genexpr>*   s   øè ø€ Ð5©W cˆs”c˜&“kÕ!©Wùs   ƒr	   zVExpected one of the following number of values {0}, but found {1} values in {2!r}: {3}r   z,Expected {0} values in {1!r}, found {2}: {3}z)Expected 1 value in {0!r}, found {1}: {2})Úanyr"   Ú
ValueErrorÚformat)r   r   r   s   `  r   Ú_check_num_parsed_valuesr)   (   s¬   ø€ äÓ5©WÓ5Ô5Üˆw‹<˜!ÒÜð Bç$™f W¬c°&«kÐ;KÈVÓTóVð Vð �Q‰Z˜1Š_ÜÐKß$™f W¨Q¡ZÐ1AÄ3ÀvÃ;ÐPVÓWóYð Yô ÐHß$™fÐ%5´s¸6³{ÀFÓKóMð Mð 6r   c                 ón  — | j                  d«      dk7  rt        dj                  | «      «      ‚| j                  d«      \  }}|j	                  d«      }|j                  dd«      j                  «       }t        d„ |D «       «      st        dj                  | «      «      ‚|D �cg c]  }t        |«      ‘Œ }}t        d„ |D «       «      st        d	j                  | «      «      ‚t        j                  d
«      }|dk(  r<t        |dg| «       t        j                  |ddd…   |ddd…   g«      |dd…dd
…f<   |S |dk(  r/t        |ddg| «       |d   |d<   t        |«      dkD  r|d   |d<   |S |dk(  r5t        |ddg| «       |d   }t        |«      dkD  r|d   n|}||d<   ||d<   |S |dk(  �rbt        |dd
g| «       |d   t        j                  z  dz  }	t        |«      d
k(  r|dd
 }
nd}
t        j                  d
«      }t        j                  |
d   g|
d   gg«      |dd…dd
…f<   t        j                  d
«      }t        j                  t        j                  |	«      t        j                  |	«       gt        j                  |	«      t        j                  |	«      gg«      |dd…dd…f<   t        j                  d
«      }t        j                  |
d    g|
d    gg«      |dd…dd
…f<   |j!                  |«      j!                  |«      }|S |dk(  r?t        |dg| «       t        j"                  |d   t        j                  z  dz  «      |d<   |S |dk(  r?t        |dg| «       t        j"                  |d   t        j                  z  dz  «      |d<   |S t        dj                  |«      «      ‚c c}w )zÁ
    Convert a single SVG transform substring into a 3x3 matrix.

    A well-formed transform substring has the form `type(v1 v2 ...)`.
    Raises a ValueError on invalid transform syntax.
    Ú(r	   ú&Invalid SVG transform substring: {0!r}ú, 	
Ú,Ú c              3   óF   K  — | ]  }t         j                  |«      –— Œ y ­wr!   )Ú
_NUMBER_REÚmatch)r#   Úts     r   r%   z*_parse_transform_substr.<locals>.<genexpr>F   s   è ø€ Ð3©F qŒz×Ñ ×"©Fùó   ‚!c              3   óF   K  — | ]  }t        j                  |«      –— Œ y ­wr!   )ÚmathÚisfinite)r#   Úvs     r   r%   z*_parse_transform_substr.<locals>.<genexpr>J   s   è ø€ Ð0© AŒt�}‰}˜Q×©ùr4   z2Non-finite value in SVG transform substring: {0!r}é   Úmatrixé   r   é   Ú	translate)r   r<   )r	   r<   Úscale)r   r   )r	   r	   Úrotateg     €f@ÚskewX)r   r	   ÚskewY)r	   r   zUnknown SVG transform type: {0})Úcountr'   r(   ÚsplitÚstripÚreplaceÚallÚfloatÚnpÚidentityr)   Úarrayr"   ÚpiÚcosÚsinÚdotÚtan)r   Útype_strÚ	value_strÚtokensr3   r   Ú	transformÚx_scaleÚy_scaleÚangleÚoffsetÚ	tf_offsetÚ	tf_rotateÚtf_offset_negs                 r   Ú_parse_transform_substrr[   7   sÏ  € ð ×Ñ˜cÓ" aÒ'ÜÐA×HÑHÐIYÓZÓ[Ð[à*×0Ñ0°Ó5Ñ€Hˆið �~‰~˜jÓ)€HØ×Ñ˜s CÓ(×.Ñ.Ó0€FÜÑ3©FÓ3Ô3ÜÐA×HÑHÐIYÓZÓ[Ð[Ù &Ó'¡˜1Œe�A�h €FÐ'äÑ0©Ó0Ô0ÜÐM×TÑTÐUeÓfÓgÐgä—‘˜A“€IØ�8ÒÜ  ¨!¨Ð.>Ô?ä Ÿh™h¨¨q°°1¨u©°v¸aÀÀ!¸e±}Ð'EÓFˆ	�!�A�#�q˜�s�(Ñð\ ÐðY 
�[Ò	 Ü  ¨!¨Q¨Ð1AÔBà  ™)ˆ	�$‰Üˆv‹;˜Š?Ø$ Q™iˆI�d‰OðN ÐðK 
�WÒ	Ü  ¨!¨Q¨Ð1AÔBà˜‘)ˆÜ # F£¨a¢�&˜’)°gˆØ!ˆ	�$‰Ø!ˆ	�$‰ð> Ðð; 
�XÓ	Ü  ¨!¨Q¨Ð1AÔBà�q‘	œBŸE™EÑ! EÑ)ˆÜˆv‹;˜!ÒØ˜A˜a�[‰FàˆFÜ—K‘K “Nˆ	Ü Ÿh™h¨°©¨°f¸Q±i°[Ð'AÓBˆ	�!�A�#�q˜�s�(ÑÜ—K‘K “Nˆ	Ü Ÿh™h¬¯©°«¼¿¹À»¸Ð(GÌ"Ï&É&ÐQVË-ÔY[×Y_ÑY_Ð`eÓYfÐIgÐ'hÓiˆ	�!�A�#�q˜�s�(ÑÜŸ™ A›ˆÜ"$§(¡(¨f°Q©i¨Z¨L¸FÀ1¹I¸:¸,Ð+GÓ"Hˆ�a˜�c˜1˜Q˜3�hÑà—M‘M )Ó,×0Ñ0°Ó?ˆ	ð Ðð 
�WÒ	Ü  ¨!¨Ð.>Ô?äŸ&™& ¨¡¬R¯U©UÑ!2°UÑ!:Ó;ˆ	�$‰ð Ðð 
�WÒ	Ü  ¨!¨Ð.>Ô?äŸ&™& ¨¡¬R¯U©UÑ!2°UÑ!:Ó;ˆ	�$‰ð Ðô Ð:×AÑAÀ(ÓKÓLÐLùòk (s   Â$N2Útransform_strÚstrictc                 ó¦  — | �| dk(  rt        j                  d«      S t        | t        «      st	        d«      ‚| j                  «       dk(  rt        j                  d«      S | j                  d«      }|j                  «       }|j                  d«      rE|rt        dj                  |«      «      ‚t        j                  d	j                  |«      t        «       t        j                  d«      }|D ]  }	 |j                  t        |«      «      }Œ |S # t        $ r7}|r‚ t        j                  d
j                  ||«      t        «       Y d}~Œ]d}~ww xY w)a  
    Convert a valid SVG transformation string into a 3x3 matrix.

    If the string is empty, null, or 'none', this returns a 3x3
    identity matrix.  By default each invalid transform substring is
    skipped (i.e. contributes an identity matrix) with a warning.  If
    `strict` is true, a ValueError is raised on invalid transform
    syntax instead.

    The warnings use the SVGSyntaxWarning category, so they can be
    silenced or escalated selectively, e.g.
    `warnings.simplefilter('error', SVGSyntaxWarning)`.
    NÚ r9   zMust provide a string to parseÚnoneÚ)r-   r,   z/Skipping invalid SVG transform substring: {0!r}z3Skipping invalid SVG transform substring {0!r}: {1})rH   rI   Ú
isinstanceÚstrÚ	TypeErrorrD   rC   Úpopr'   r(   ÚwarningsÚwarnr   rN   r[   )r\   r]   Útransform_substrsÚtrailingÚtotal_transformÚsubstrÚes          r   Úparse_transformrm   ‚   s4  € ð Ð °Ò 3Ü�{‰{˜1‹~ÐÜ˜¤sÔ+ÜÐ8Ó9Ð9ð ×ÑÓ Ò&Ü�{‰{˜1‹~Ðà%×+Ñ+¨CÓ0Ðð !×$Ñ$Ó&€HØ‡~�~�jÔ!ÙÜÐE×LÑLÈXÓVÓWÐWÜ�‰ÐG×NÑNÈxÓXÜ&ô	(ô —k‘k !“n€OÛ#ˆð	,Ø-×1Ñ1Ô2IÈ&Ó2QÓR‰Oð $ð Ðøô ò 	,ÙØÜ�M‰MÐO×VÑVÐW]Ð_`ÓaÜ*÷,ñ ,ûð	,ús   Ã2DÄ	EÄ-EÅE)y                N)F) r   Ú
__future__r   r   r   Útypingr   r   r   r6   ÚreÚnumpyrH   rf   Úpathr   Úxml.etree.ElementTreer   Úcompiler1   ÚUserWarningr   rc   Úcomplexr   rG   Úintr)   Úndarrayr[   Úboolrm   r   r   r   Ú<module>rz      só   ðñ÷ AÑ @ß 4Ñ 4Û Û 	Û Û õ áå-ð ˆR�Z‰ZÐPÓQ€
ôL�{ô Lð 57Ø37ñM˜ð M¨'ð MØ% iÑ0ðMØ<@óMðM X¨e¡_ð M¸xÈ¹}ð MØ/2ðMØ7;óMðH¨cð H°b·j±jó HñV, 8¨C¡=ð ,¸$ð ,È2Ï:É:ô ,r   