
    Bh<u                        S r SSKrSSKJr  SSKJrJrJrJrJ	r	J
r
  SSKJr  SSKJr  SSKJr  S	S
KJrJr  S	SKJrJrJrJrJr  S	SKJrJr  S	SKJr  S	SKJrJ r J!r!J"r"J#r#J$r$  S	SK%J%r%  S	SK&J'r'J&r&J(r(J)r)  S	SK*J+r+J,r,J-r-J.r.J/r/J0r0J1r1J2r2  \%\\\ \\!\\#\"\$\\%\%\%\S.r3\4" S5      r5\4" S5      r6\4" S5      r7 " S S5      r8 " S S5      r9 " S S\95      r:g)zRender SVG images.    N)suppress)coshypotpiradianssinsqrt)ElementTree)ElementWrapper   get_url_attribute   )parse_declarationsparse_stylesheets)apply_filters	clip_pathdraw_gradient_or_pattern
paint_maskuse)imagesvg)path)circleellipselinepolygonpolylinerect)text)EMPTY_BOUNDING_BOXbounding_boxextend_bounding_boxis_valid_bounding_box)
PointErroralpha_valuecolor	normalize	parse_urlpreserve_ratiosize	transform)ar   clipPathr   r   r   r   r   r   r   r   r    textPathtspanr   )clip	clip-pathfilterheightidmaskopacityoverflowrotate
stop-colorzstop-opacitystyler,   ztransform-originviewBoxwidthxydxdy"{http://www.w3.org/1999/xlink}hrefhref)fillzflood-colorzlighting-colorr:   stroke)	r.   r3   gradientr   markerr6   r   patternsymbolc                       \ rS rSrSrS rS rSS jr\S 5       r	\S 5       r
\S	 5       r\S
 5       r\S 5       rS rS rS rS rS r\S 5       rS rSS jrS rS rS rS rSrg)NodeX   zAn SVG document node.c                     Xl         UR                  U l        X l        UR                  R                  R                  5       U l        / U l        S U l        g N)_wrapperetree_element_etree_node_styleattribcopyverticesr"   )selfwrapperr;   s      I/var/www/html/env/lib/python3.13/site-packages/weasyprint/svg/__init__.py__init__Node.__init__[   sE    "00++22779     c                 B    [        U R                  U R                  5      $ )z<Create a deep copy of the node as it was when first created.)rK   rO   rR   rV   s    rX   rT   	Node.copye   s    DMM4;;//r[   Nc                 8    U R                   R                  X5      $ )zGet attribute.)rS   get)rV   keydefaults      rX   r`   Node.geti   s    {{s,,r[   c                 T    U R                   R                  R                  SS5      S   $ )zXML tag name with no namespace.}r   )rQ   tagsplitr]   s    rX   rg   Node.tagm   s(     ##))#q1"55r[   c                 .    U R                   R                  $ )zXML node text.)rQ   r    r]   s    rX   r    	Node.textr        $$$r[   c                 .    U R                   R                  $ )zText after the XML node.)rQ   tailr]   s    rX   rn   	Node.tailw   rl   r[   c                 *    U R                  S5      S:g  $ )z!Whether node should be displayed.displaynone)r`   r]   s    rX   rq   Node.display|   s     xx	"f,,r[   c                 P    U R                   =(       a    U R                  S5      S:g  $ )zWhether node is visible.
visibilityhidden)rq   r`   r]   s    rX   visibleNode.visible   s!     ||B 6( BBr[   c                 F   UR                   nU R                  R                  5        H0  u  p4U[        ;  d  M  X1R                  ;  d  M"  XAR                  U'   M2     UR	                  S5      =n(       a  [        U5      u  pgO/ / pvU R                  u  pUR                  U5       V
s/ s H  oS   PM	     nn
U	R                  U5       V
s/ s H  oS   PM	     nn
X/X/4 H4  nU H+  nU H"  u  pUR                  5       UR                  U'   M$     M-     M6     [         H9  nUR	                  U5      S:X  d  M  UR	                  SS5      UR                  U'   M;     UR                  R                  5       R                  5        H>  u  p4US:X  d  M  U R	                  U5      nUc  UR                  U	 M0  XAR                  U'   M@     UR                  S;   a@  UR                  US	S	S
9u  nnU Vs/ s H  oR                  PM     snWR                   l        ggs  sn
f s  sn
f s  snf )z>Apply CSS cascade and other related operations to given child.r;   rf   currentColorr'   blackinheritNr    r/   r-   T)trailing_space	text_root)rO   rS   itemsNOT_INHERITED_ATTRIBUTESr`   r   rR   matchstripCOLOR_ATTRIBUTESrT   rg   text_childrenrQ   etree_children)rV   childrW   ra   value
style_attrnormal_attrimportant_attrnormal_matcherimportant_matcherrulenormal	importantdeclarations_listdeclarationsnamechildren_s                     rX   cascadeNode.cascade   s   .. ++++-JC22ll*(-LL% . 7++:+*<Z*H'K*,b,0KK)'5';';G'DE'Dtr('DE*;*A*A'*JK*J$"X*J	K"(-DT!U 1#/KD).ELL& $0 !2 "V $Cyy~/$)IIgw$?S! $
  ,,++-335JC	!=S)(-LL% 6 9911-- . >KHa 08-9/7e!!x-9ENN) 2- FK0-9s   %HH+Hc              #      #    U R                    H-  n[        XR                  5      nU R                  U5        Uv   M/     g7f)z&Yield node children, handling cascade.N)rO   rK   rR   r   )rV   rW   r   s      rX   __iter__Node.__iter__   s2     }}G++.ELLK %s   ?Ac                     U R                  S5      nU(       a)  [        S [        U5      R                  5        5       5      $ g)z&Get node viewBox as a tuple of floats.r<   c              3   8   #    U  H  n[        U5      v   M     g 7frN   float).0numbers     rX   	<genexpr>#Node.get_viewbox.<locals>.<genexpr>   s     P5O6v5O   N)r`   tupler(   rh   )rV   viewboxs     rX   get_viewboxNode.get_viewbox   s7    ((9%PYw5G5M5M5OPPP r[   c                 B    S H  n[        XUSS9=n(       d  M  Us  $    g)z4Get the href attribute, with or without a namespace.rB   rC   T)allow_relativeNr   )rV   base_url	attr_nameurls       rX   get_hrefNode.get_href   s'    GI'RVWWsW
 Hr[   c                 N    S H  nU R                   R                  US5        M!     g)z8Remove the href attributes, with or without a namespace.r   N)rS   pop)rV   r   s     rX   del_hrefNode.del_href   s    GIKKOOIt, Hr[   c                     U (       d  gU(       a  [         R                  " SSU 5      $ [         R                  " SSU 5      n [         R                  " SSU 5      n [         R                  " SSU 5      $ )z>Replace newlines by spaces, and merge spaces if not preserved. z[
	] z[
]	z +)resub)stringpreserves     rX   process_whitespaceNode.process_whitespace   sW     66*c622VVHb&1FVVD#v.F66$V,,r[   c                     U  H8  nUR                  S5      U:X  a  Us  $ UR                  U5      nU(       d  M6  Us  $    g)z2Get a child with given id in the whole child tree.r5   N)r`   	get_child)rV   id_r   
grandchilds       rX   r   Node.get_child   s:    Eyy#%-Jz!! r[   c                    / nSnU R                  U5      S:H  nU R                  UR                  R                  U5      U R                  l        U(       a1  U(       d*  U R                  R                  S5      U R                  l        [        U R                  S5      5      R                  5       R                  S5       Vs/ s H  nU(       d  M  [        U5      PM     nnUR                  5       n	U(       a  U R                  X5        U R                  (       a  U R                  R                  S5      n[        UR                  5       5      n
U
 GHi  nUR                  nUR                  S;   ah  [!        XR"                  5      nSUR                  l        UR                  nUR%                  5       UR                  l        [&        R(                  " U5      nO[!        XR"                  5      nUR                  U5      S:H  nU R                  UR                  U5      UR                  l        UR+                  X5      u  Ul        nUR                  R                  S5      nU(       a  SU;  a  UR                  X5        UR/                  U5        U R                  UR0                  U5      nU(       a  XS   L a  U(       d  UR3                  S5      nU(       d  GM  [4        R6                  " S5      n[!        [&        R(                  " U5      U R"                  5      nUUR                  l        U(       a  UR                  X5        U(       a1  U(       d*  UR                  R                  S5      UR                  l        UR                  (       a  UR                  R                  S5      nUR/                  U5        GMl     U(       a8  U(       d1  U(       d*  U R                  R3                  S5      U R                  l        XB4$ s  snf )	z<Handle text node by fixing whitespaces and flattening tails.z+{http://www.w3.org/XML/1998/namespace}spacer   r   r9   )z {http://www.w3.org/2000/svg}treftrefr0   rf   z!{http://www.w3.org/2000/svg}tspan)r`   r   rP   r    rQ   lstripr(   r   rh   r   rT   pop_rotationendswithr   iter_childrenrg   rK   rR   flattenr   from_xml_rootr   r   appendrn   rstripr
   Element)rV   elementr~   r   r   spacer   ioriginal_rotater9   element_childrenchild_elementr   
child_nodechild_preservern   anonymous_etree	anonymouss                     rX   r   Node.text_children   s   =88E?j0 $ 7 7!!&&!2($(II$4$4S$9D! dhhx()//177<C< @A E!H< 	 C !%%'o699!YY//4N !6!6!89-M!//EyyHH!-=
-4
&&* #..).!!& . < <U C!-=
'^^E2j@N*.*A*A

N+,J""'2<2J2J3//J'__55c:N8:#=''@OOJ'**5::x@D]r.BB;;s+Dt"-"5"57#9 "00A4;;P	-1	%%*"**?C!(1:1F1Fs1KI)).>>%.^^%<%<S%AN	*K .N Xh$(II$4$4S$9D!''gCs   ?O>O>c                    U R                   =(       d    S/n[        U 5       HW  nUR                  UR                  5       5        UR                  UR                  =(       d    S5        U R                  U5        MY     SR                  U5      $ )z)Flatten text in node and in its children.r   )r    listr   r   rn   removejoin)rV   flattened_textr   s      rX   r   Node.flatten   sh    ))/r*$ZE!!%--/2!!%**"23KK   ww~&&r[   c                    ^^ SR                  UU4S j[        [        U R                  5      5       5       5      U R                  S'   g)zMerge nested letter rotations.r   c              3   p   >#    U  H+  n[        T(       a  TR                  S 5      OTS   5      v   M-     g7f)r   rf   N)strr   )r   r   r   r9   s     rX   r   $Node.pop_rotation.<locals>.<genexpr>+  s1      ),* 

1_R-@AA*s   36r9   N)r   rangelenr    rS   )rV   r   r9   s    ``rX   r   Node.pop_rotation)  s4     # ),3tyy>*), !,Hr[   c                 @   ^ [        S[        4SU4S j05      U l        g)u$   Override node’s children iterator.rK   r   c                    > T$ rN    )r   iterators    rX   <lambda>$Node.override_iter.<locals>.<lambda>4  s    Hr[   N)typerK   	__class__)rV   r   s    `rX   override_iterNode.override_iter/  s      TGj*<=?r[   c                 V   X!l         X1l        [        X#5      [        S5      -  Ul        U R                  5       =n(       a  US   US   sUl        Ul        O#UR                   UR                  sUl        Ul        [        UR                  UR                  5      [        S5      -  Ul        g)z="Set SVG concrete and inner widths and heights from svg node.r      N)	concrete_widthconcrete_heightr   r	   normalized_diagonalr   inner_widthinner_heightinner_diagonal)rV   r   r   r   r   s        rX   set_svg_sizeNode.set_svg_size6  s    +-"'"H4PQ7"R&&((7(07
GAJ-COS-030B0BCDWDW-COS-"3??C4D4DEQOr[   )r   rQ   rR   rO   rS   r"   rU   rN   F)__name__
__module____qualname____firstlineno____doc__rY   rT   r`   propertyrg   r    rn   rq   rw   r   r   r   r   r   staticmethodr   r   r   r   r   r   r   __static_attributes__r   r[   rX   rK   rK   X   s    !0- 6 6 % % % % - - C C*9ZQ-
 
- 
-"=(~',?
Pr[   rK   c                       \ rS rSrSrS rS rS rS rS r	S r
SS	 jrS
 r\S 5       rSS jrS rS rS rS rSS jrSrg)SVGiD  zAn SVG document.c                    [         R                  " U5      n[        X25      n[        X45      U l        X l        0 U l        0 U l        0 U l        0 U l	        0 U l
        0 U l        0 U l        0 U l        0 U l        SS/U l        SS/U l        SU l        U R                  R%                  U R                  5        U R'                  U R                  5        U R)                  5         g )Nr   )r   r   r   rK   treer   filters	gradientsimagesmarkersmaskspatternspathssymbols	use_cachecursor_positioncursor_d_positiontext_path_widthr   
parse_defsinherit_defs)rV   r  r   rW   r;   s        rX   rY   SVG.__init__G  s     ..t4!'/(	

 !1v"#Q 		$))$		"r[   c                     U R                   R                  SS5      nSU;   a  SnO[        X!5      nU R                   R                  SS5      nSU;   a  SnX#4$ [        X15      nX#4$ )z Get intrinsic size of the image.r=   z100%%Nr4   )r  r`   r+   )rV   	font_sizeintrinsic_widthintrinsic_heights       rX   get_intrinsic_sizeSVG.get_intrinsic_size_  ss    ))--8/!"O"?>O99==6:""# 00  $$4@00r[   c                 6    U R                   R                  5       $ )z*Get document viewBox as a tuple of floats.)r  r   r]   s    rX   r   SVG.get_viewboxo  s    yy$$&&r[   c                 Z    [        XU R                  5      [        X#U R                  5      4$ )z.Compute size of an x/y or width/height couple.)r+   r   r   )rV   r>   r?   r  s       rX   point	SVG.points  s.     t//0t0013 	3r[   c                 .    [        XU R                  5      $ )z'Compute size of an arbirtary attribute.)r+   r   )rV   lengthr  s      rX   r#  
SVG.lengthy  s    Ft':':;;r[   c                     Xl         U R                  R                  XU5        X@l        XPl        X`l        U R                  U R                  [        S5      5        g)zDraw image on a stream.12ptN)streamr  r   r   url_fetchercontext	draw_noder+   )rV   r'  r   r   r   r(  r)  s          rX   drawSVG.draw}  sC     		t_E &tyy$v,/r[   c                 R   UR                   S:X  a  g[        UR                  SS5      X"5      n/ nU(       a  U R                  R	                  5         U R
                  R                  [        UR                  S5      5      R                  5      nU(       a  [        XXR5        U R                  UR                  S5      U5        [        UR                  SS5      5      nU(       a  S	Us=::  a  S:  aw  O  OtUR                  U R                  5        U R                  X5      n[        U5      (       d  S	S	U R                  U R                  4nU R                  R                   " U6 U l        [        UR                  S
5      5      R                  nU(       Ga  XR"                  ;   Ga  U R                  R$                  n	U R"                  U   nUR                  " S5      S:X  a  U R'                  UR                  S5      UR                  S5      U5      u  pU R'                  UR                  S5      UR                  S5      U5      u  pU R                  R                  XXS9  UR(                  R                   nSUR(                  l         U R+                  XSS9  XR(                  l         U R                  R-                  S	S	S	S	5        U R                  R/                  5         U R                  R1                  5         U R                  R$                  nUR2                  (       a/  U R                  R                  " XR4                  -  R6                  6   SnUR8                  (       a  [:        R                  UR                   5      [<        :X  ad  UR                  S5      =nS;   aB  SnU R                  R!                  S	S	S	S	5      nUR                  U R                  5        UU l        [>        Ul         UR                   S:X  a  U RB                  nU RD                  nURF                  (       aF  UR                   [:        ;   a2  [I        [J        5         [:        UR                      " XU5        SSS5        UR8                  (       Ga  UR                   [L        ;  Gao  U GHh  nU=(       a;    UR                   S:H  =(       d%    SURN                  ;   =(       d    SURN                  ;   nU(       a  U R                  nUS   U l        U R+                  UX#5        U(       a  WU l        [:        R                  UR                   5      [<        :H  =(       a9    [:        R                  UR                   5      [<        :H  =(       a    URF                  nU(       d  M  [        UR@                  5      (       d  GM  UR@                  SS u  nnUUR@                  S   -   nUUR@                  S   -   n[Q        UR@                  UU4UU445      Ul         GMk     UR                   S:X  a!  U RR                  RU                  [V        WW5        U(       Ga  U R                  RX                  nUR[                  5       U l        U R                  R	                  5         [        UR@                  5      (       a  UR@                  u  ppX-
  X-
  X-   U-   X-   U-   4WR\                  S   SS& WS:X  a  US-  OUnUR                   S:X  d   SURN                  ;   d  SURN                  ;   a  U R                  R                  U* S9  U R                  R_                  U5        U R                  Ra                  5         U Rb                  R                  [        UR                  S 5      5      R                  5      nU(       a  [e        XUU5        U(       a  U Rg                  X5        U Ri                  XU5        U(       aq  S	Us=::  a  S:  ad  O  OaU R                  RX                  nUR[                  5       U l        U R                  Rk                  USSS!9  U R                  R_                  U5        UR                   S:X  a  S	S	/U l6        S	S	/U l7        S	U l8        U(       a  U R                  Ra                  5         gg! , (       d  f       GN;= f)"zDraw a node.defsNz	font-size1emr3   r,   r7   r   r   r2   clipPathUnitsobjectBoundingBoxr>   r?   r=   r4   )r-   defgFfill_strokeztext-anchor)middleendTr   r    rf   r   r   BBoxr8  )r3  r6   )rE   rD   )9rg   r+   r`   r'  
push_stater  r)   fragmentr   r,   r&   r   calculate_bounding_boxr$   r   r   	add_groupr  ctmr   rQ   r*  	rectangler1   r9  determinantinvertvaluesrq   TAGSr    r!   text_bounding_boxr   r   rw   r   r%   	DEF_TYPESrS   r#   r  r   r   r5   r   extradraw_x_object	pop_stater  r   r7  draw_markers	set_alphar  r  r  ) rV   noder  r7  original_streamsfilter_r7   boxr   old_ctmr>   r?   r=   r4   original_tagnew_ctmtext_anchor_shifttext_anchorgroupr   r   r   	new_chunk
new_streamvisible_text_childx1y1x2y2group_idx_alignr6   s                                    rX   r*  SVG.draw_node  s   88v +u5yL	KK""$ ,,""9TXXh-?#@#I#IJ$g9 	txx,i8 dhhy!451+!+##DKK0--d>C(--!T--t/@/@A++//5DK dhh{34==	jj0kkooG

9-I}}_-1DDzz$((3-#	J $

HHW%txx'99!F%%1%B$0044L(+I!!%NN9UNC(4!!% KK!!!Q1-KKKKOOkkooG""%%..(@'H'HI "<<DHHTXX.$6#xx66;LL$(!--aAq9 ''4#%7D" 88u!00N"22O <<DHH,*%TXXt95 & <<<DHHI5- WII'U3%,,+>U#BU !%J"22"6DKui=",DKHHTXX&$. "HHUYY'4/"MM # &%01H1HII "44Ra8FBe55a88Be55a88B-@.."bB80D.FD*' . 88uII""3H {{~~H*..0DKKK""$$T%;%;<<&*&<&<#e M1=I	)1:	+A*CF#A& (3h'>%!)E88v%);sdkk?QKK))WH)5KK%%h/KK!!# zz~~i(89BBCt41 T- 	$;7 1+!+{{~~H*..0DKKK!!'$T!BKK%%h/ 88v$%q6D &'VD"#$D KK!!# S &%s   b
b&c           
         UR                   (       d  g0 n[        UR                  S5      5      R                  nS HA  nSU 3nXqR                  ;   a&  [        UR                  U   5      R                  XF'   M=  XTU'   MC     Su  pSnUR                   (       Ga  UR                   R                  S5      n
UR                   (       a  UR                   R                  S5      OSnU(       a*  US:X  a  [        US   -
  nOU	[        -   US   -
  S-  nUu  pOU	nS	nU R                  R                  XF   5      =n(       d  U(       a  S
OSnM  U R                  UR                  S5      UR                  S5      U5      u  pU R                  UR                  SS5      UR                  SS5      U5      u  nnSUR                  ;   a  [        XUUU5      u  nn  nUR                  5       u  nnnnUR                  SS5      R                  S5      S   nUS:X  a  S=nnO&USS R                  5       nUSS R                  5       nUS
:X  a  UUUU-  -
  S-  -  nOUS:X  a  UUUU-  -
  -  nUS
:X  a  UUUU-  -
  S-  -  nOUS:X  a  UUUU-  -
  -  nUUUU-  UU-  4nO
S=nnSSUU4nUR                  S5      S:w  a,  U R                  UR                  SS5      U5      nUU-  nUU-  nUR                  SS5      nUS;  a  [        [        U5      5      nOUS:X  a  US:X  a  U[        S 5      -  nU GH  nU R                   R#                  5         U R                   R$                  " U['        U5      -  U[)        U5      -  U* [)        U5      -  U['        U5      -  /U
Q76   U R                   R%                  U* U* S!9  UR                  S"S#5      n U S$;   aM  U R                   R*                  " U6   U R                   R-                  5         U R                   R/                  5         U R1                  UX#5        U R                   R3                  5         GM     U(       a  S
OSnUR                   (       a  GM  gg)%zDraw markers defined in a node.NrG   )startmidr9  zmarker-NNra  r   r   r9  rb  refXrefYmarkerWidthr   markerHeightr<   preserveAspectRatioxMidYMidr   rr   minr         maxmarkerUnitsuserSpaceOnUsestroke-widthorient)autoauto-start-reversers     )r3  r4  r8   rv   )rv   scroll)rU   r)   r`   r<  rS   r   r   r
  r   r*   r   rh   lowerr#  r   r   r'  r;  r,   r   r   r@  r1   r9  r*  rI  )!rV   rL  r  r7  r
  common_markerposition	attributeangle1angle2r   anglesanglemarker_nodetranslate_xtranslate_ymarker_widthmarker_heightscale_xscale_yr   clip_xclip_yviewbox_widthviewbox_heightalign
x_position
y_positionclip_boxscale
node_angler   r8   s!                                    rX   rJ  SVG.draw_markers  so   }}!$((8"45>>/H!(,IKK'$-dkk).D$E$N$N!$1! 0 $mmmMM%%a(E-1]]T]]&&q)Fw&NE#b[6!949E!'  $(<<#3#3G4E#FFKF$*5 (,zz')@($K +/**q12+'L- K...)7y,*O&!Q  ++- >~ $):77<uSz!EF?.33J!&q!1!1!3J!&qr!2J&}|g/EEJJF5(mlW.DDDF&&)@@AF FF5(n}w/FFFF F 7*MG,CE %&%'q,> }-1AADHH^Q$?K5 5  %15J!??j 1233G8K% %&&(%%c%j('CJ*>Hs5z)7SZ+?  %%%E&??:x@33KK))84KK$$&KKOO%ui=%%'! %$ !'uGHy mmmr[   c                 8   U (       a  U S:X  a  gU R                  5       n [        R                  " S5      R                  U 5      nU(       aA  [	        UR                  S5      5      R                  nUR                  S5      =(       d    SnX#4$ SnU =(       d    SnX#4$ )z9Get paint fill or stroke attribute with a color or a URL.rr   rc  z(url\(.+\)) *(.*)r   r   N)r   r   compilesearchr)   rU  r<  )r   r   sourcer'   s       rX   	get_paintSVG.get_paint  s     

/077>u{{1~.77FKKN*dE
 } FMTE}r[   c           	      Z  ^ ^ UR                   S;   a  U(       d  gT R                  UR                  SS5      5      u  pE[        UR                  SS5      5      n[	        T XTUSS9nU(       aB  U(       d;  [        U5      nU=R                  U-  sl        T R                  R                  U5        U=(       d    Un	T R                  UR                  S	5      5      u  p[        UR                  S
S5      5      n[	        T XTUSS9nU(       aA  U(       d:  [        U5      nU=R                  U-  sl        T R                  R                  USS9  U=(       d    UnT R                  UR                  SS5      T5      nU(       a  T R                  R                  U5        OSn[        UU 4S j[        UR                  S5      5      R                  5        5       5      nU=(       a5    [        S U 5       5      (       + =(       a    [        S U 5       5      (       + nU(       af  T R                  UR                  S5      T5      nUS:  a#  [!        S U 5       5      nU[#        U5      U-  -
  nT R                  R%                  UU5        UR                  SS5      nUS:X  a  SnOUS:X  a  SnOSnT R                  R'                  U5        UR                  SS5      nUS:X  a  SnOUS:X  a  SnOSnT R                  R)                  U5        [+        UR                  SS5      5      nUS:  a  SnT R                  R-                  U5        UR                  S5      S :H  nU(       aC  U(       a
  U	(       a  SnOU(       a  SnOU	(       a  SnOS!nT R                  R/                  U5        gU	(       a#  U(       a  T R                  R1                  U5        gU(       a  T R                  R3                  5         gU	(       a  T R                  R5                  U5        gT R                  R7                  5         g)"z!Paint fill and stroke for a node.r}   NrD   r{   zfill-opacityr   F)rE   rE   zstroke-opacityTrp  1pxc              3   X   >#    U  H  nUS :w  d  M  TR                  UT5      v   M!     g7f)rr   N)r#  )r   r   r  rV   s     rX   r   "SVG.fill_stroke.<locals>.<genexpr>  s3      P; /4?D *DKKy));s   
**zstroke-dasharrayc              3   *   #    U  H	  oS :H  v   M     g7fr   Nr   r   r   s     rX   r   r    s     7J5QJJ   c              3   *   #    U  H	  oS :  v   M     g7fr  r   r  s     rX   r   r    s     6:%AI:r  zstroke-dashoffsetr   c              3   8   #    U  H  n[        U5      v   M     g 7frN   r   r  s     rX   r   r    s      F:%u:r   zstroke-linecapbuttroundsquarer   zstroke-linejoinmiterbevelzstroke-miterlimitrk  z	fill-ruleevenoddr   )rg   r  r`   r&   r   r'   alphar'  	set_colorr#  set_line_widthr   r(   rh   allanysumabsset_dashset_line_capset_line_joinr   set_miter_limitset_text_renderingfill_and_strokerE   rD   r9  )rV   rL  r  r    fill_source
fill_colorfill_opacity
fill_drawnstream_colorrD   stroke_sourcestroke_colorstroke_opacitystroke_drawnrE   stroke_width
dash_arraydash_conditionoffset
sum_dashesline_cap	line_joinmiter_limiteven_oddtext_renderings   ` `                      rX   r7  SVG.fill_stroke  ss   8800 #'..&'1J"K"488NA#>?-$YUL
j ,L,.KK!!,/'Z '+nnTXXh5G&H#$TXX.>%BC/$y.O .L.0KK!!,t!<-{{488NE#BINKK&&|4F  Pdhh12399;P P
  77J77776:666 	 [[*=!>	JFz  F: FF
#c&kJ&>>KK  V4 88,f5wH!HH  * HH.8	I'!II!!), DHH%8!<=?K##K0 88K(I5$!"!"!"!"KK**>:++H5""$  *!r[   c                     U(       d  g[        XU R                  5      nUR                  (       a$  U R                  R                   " UR                  6   gg)z*Apply a transformation string to the node.N)r,   r   rA  r'  rC  )rV   transform_stringr  matrixs       rX   r,   SVG.transform  s?    +8K8KLKK!!6==1 r[   c                     [          HR  nX!R                  R                  5       ;   d  M"  SUR                  ;   d  M4  U[	        X S35      UR                  S   '   MT     U H  nU R                  U5        M     g)zParse defs included in a tree.r5   sN)rF  rg   rv  rS   getattrr  )rV   rL  def_typer   s       rX   r  SVG.parse_defs  s^    !H88>>++0CCG
!n-dkk$.?@ " EOOE" r[   c                     U R                   U R                  4 H+  nUR                  5        H  nU R                  X!5        M     M-     g)z7Handle inheritance of different defined elements lists.N)r  r  rC  inherit_element)rV   r.  r   s      rX   r  SVG.inherit_defs  s7    ^^T]]3D;;=$$W3 ) 4r[   c                    UR                  U R                  5      nU(       d  gUR                  5         UR                  [	        U5      R
                  5      nU(       d  gU R                  XB5        UR                  R                  5        H$  u  pVXQR                  ;  d  M  XaR                  U'   M&     [        [        U5      S5      c   UR                  UR                  5       5        gg)z2Recursively handle inheritance of defined element.N)r   r   r   r`   r)   r<  r  rS   r   nextiterr   r   )rV   r   r.  rC   parentra   r   s          rX   r  SVG.inherit_element  s    ))D/223V* ----/JC..(&+s# 0 Wt$,!!&//"34 -r[   c                     U(       d  UR                   c4  [        XX#5      n[        U5      (       a  SUSS ;  a  U(       a  U$ XAl         UR                   $ )z%Calculate the bounding box of a node.Nr   r   )r"   r$   )rV   rL  r  rE   rO  s        rX   r=  SVG.calculate_bounding_box"  sN    T&&.t9=C$S))as12w.>J$'!   r[   )r   r)  r  r  r  r  r	  r
  r  r  r  r'  r  r  r  r   r(  r  NTr   )r   r   r   r   r   rY   r  r   r   r#  r+  r*  rJ  r  r  r7  r,   r  r  r  r=  r  r   r[   rX   r  r  D  se    01 '3<0P$dm4^   ]"~2#45 !r[   r  c                   <   ^  \ rS rSrSrU 4S jrSU 4S jjrSrU =r$ )Patterni-  zSVG node applied as a pattern.c                 f   > [         TU ]  UR                  UR                  5        X l        Xl        g rN   )superrY   rQ   r   r   r  )rV   r  r   r   s      rX   rY   Pattern.__init__/  s&    ))3773	r[   c                 v   > XR                   :X  a  U R                  R                   U l         [        TU ]  XSS9  g )NTr6  )r  r   r  r*  )rV   rL  r  r7  r   s       rX   r*  Pattern.draw_node4  s0     99DI$t<r[   )r   r  r  )	r   r   r   r   r   rY   r*  r  __classcell__)r   s   @rX   r  r  -  s    (
= =r[   r  );r   r   
contextlibr   mathr   r   r   r   r   r	   	xml.etreer
   
cssselect2r   urlsr   cssr   r   r.  r   r   r   r   r   r	  r   r   r   shapesr   r   r   r   r   r   r    r"   r!   r#   r$   utilsr%   r&   r'   r(   r)   r*   r+   r,   rD  	frozensetr   r   rF  rK   r  r  r   r[   rX   <module>r     s     	  3 3 ! % $ 6 U U   B B R R  
 
$ % &  2      
 
	hP hPXf! f!R=c =r[   