
    p"h!                         S r SSK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
 S\
5      r " S S\
5      rg)z7
The **BaseElement** is the root for all SVG elements.
    )etreeN)	Parameter)AutoIDc                       \ rS rSrSrSrS rS rS r\	S 5       r
\	S 5       r\	S	 5       r\R                  S
 5       r\	S 5       rS rSS jrS 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rg)BaseElement   z
The **BaseElement** is the root for all SVG elements. The SVG attributes
are stored in **attribs**, and the SVG subelements are stored in
**elements**.

baseElementc                 b   UR                  SS5      nUb  UR                  U l        O[        5       U l        UR                  SS5      nUb  X0R                  l        UR                  SS5      nUb  X@R                  l        [        5       U l        U R                  U5        [        5       U l	        g)a  
:param extra: extra SVG attributes (keyword arguments)

  * add trailing '_' to reserved keywords: ``'class_'``, ``'from_'``
  * replace inner '-' by '_': ``'stroke_width'``


SVG attribute names will be checked, if **debug** is `True`.

workaround for removed **attribs** parameter in Version 0.2.2::

    # replace
    element = BaseElement(attribs=adict)

    #by
    element = BaseElement()
    element.update(adict)

factoryNdebugprofile)
pop
_parameterr   r   r   dictattribsupdatelistelements)selfextrar   r   r   s        ?/var/www/html/env/lib/python3.13/site-packages/svgwrite/base.py__init__BaseElement.__init__   s    * ))It,%00DO (kDO 		'4($)OO! ))It,&-OO#vE    c                     UR                  5        H7  u  p#UR                  S5      R                  SS5      nU R                  X#5        M9     g)zUpdate SVG Attributes from `dict` attribs.

Rules for keys:

1. trailing '_' will be removed (``'class_'`` -> ``'class'``)
2. inner '_' will be replaced by '-' (``'stroke_width'`` -> ``'stroke-width'``)

_-N)itemsrstripreplace__setitem__)r   r   keyvalues       r   r   BaseElement.updateH   s@     "--/JC **S/))#s3CS(	 *r   c                    [         R                   " U 5      n[         R                   " U R                  5      Ul        [         R                   " U R                  5      Ul        SUR                  ;   a  UR                  5       US'   U$ )Nid)copyr   r   next_id)r   newobjs     r   r'   BaseElement.copyW   sX    44<<0))DMM26>>!!>>+F4Lr   c                 .    U R                   R                  $ N)r   r   r   s    r   r   BaseElement.debug_   s    $$$r   c                 .    U R                   R                  $ r,   )r   r   r-   s    r   r   BaseElement.profilec   s    &&&r   c                 .    U R                   R                  $ r,   r   	validatorr-   s    r   r3   BaseElement.validatorg   s    (((r   c                 $    XR                   l        g r,   r2   r   r#   s     r   r3   r4   k   s    $)!r   c                 6    U R                   R                  5       $ r,   )r   get_versionr-   s    r   versionBaseElement.versiono   s    **,,r   c                     Xl         g r,   )r   )r   	parameters     r   set_parameterBaseElement.set_parameters   s    #r   Nc                 .    [         R                  " U5      $ r,   )r   r(   r6   s     r   r(   BaseElement.next_idv   s    ~~e$$r   c                 z    SU R                   ;  a  U R                  5       U R                   S'   U R                   S   $ )zqGet the object `id` string, if the object does not have an `id`,
a new `id` will be created.

:returns: `string`
r&   )r   r(   r-   s    r   get_idBaseElement.get_idy   s3     t||#!%DLL||D!!r   c                 (    SU R                  5       -  $ )zV
Get the `IRI` reference string of the object. (i.e., ``'#id'``).

:returns: `string`
z#%s)rB   r-   s    r   get_iriBaseElement.get_iri   s     t{{}$$r   c                 (    SU R                  5       -  $ )z^
Get the `FuncIRI` reference string of the object. (i.e. ``'url(#id)'``).

:returns: `string`
zurl(%s))rE   r-   s    r   get_funciriBaseElement.get_funciri   s     4<<>))r   c                      U R                   U   $ )zaGet SVG attribute by `key`.

:param string key: SVG attribute name
:return: SVG attribute value

)r   )r   r"   s     r   __getitem__BaseElement.__getitem__   s     ||C  r   c                     U R                   (       a&  U R                  R                  U R                  X5        X R                  U'   g)zxSet SVG attribute by `key` to `value`.

:param string key: SVG attribute name
:param object value: SVG attribute value

N)r   r3   check_svg_attribute_valueelementnamer   )r   r"   r#   s      r   r!   BaseElement.__setitem__   s1     ::NN44T5E5EsR!Sr   c                     U R                   (       a0  U R                  R                  U R                  UR                  5        U R                  R                  U5        U$ )zhAdd an SVG element as subelement.

:param element: append this SVG element
:returns: the added element

)r   r3   check_valid_childrenrO   r   append)r   elements     r   addBaseElement.add   sB     ::NN//0@0@'BUBUVW%r   c                 n    U R                  5       n[        R                  " USS9nUR                  S5      $ )zuGet the XML representation as unicode `string`.

:return: unicode XML string of this object and all its subelements

zutf-8)encoding)get_xmlr   tostringdecode)r   xmlxml_utf8_strs      r   rZ   BaseElement.tostring   s0     lln~~cG<""7++r   c                 "    U R                  5       $ )z|Show SVG in IPython, Jupyter Notebook, and Jupyter Lab

:return: unicode XML string of this object and all its subelements

)rZ   r-   s    r   
_repr_svg_BaseElement._repr_svg_   s     }}r   c                    [         R                  " U R                  5      nU R                  (       a0  U R                  R                  U R                  U R                  5        [        U R                  R                  5       5       H5  u  p#Uc  M
  U R                  U5      nU(       d  M$  UR                  X#5        M7     U R                   H"  nUR                  UR                  5       5        M$     U$ )zxGet the XML representation as `ElementTree` object.

:return: XML `ElementTree` of this object and all its subelements

)r   ElementrO   r   r3   check_all_svg_attribute_valuesr   sortedr   value_to_stringsetr   rS   rY   )r   r\   	attributer#   rT   s        r   rY   BaseElement.get_xml   s     mmD,,-::NN99$:J:JDLLY &t||'9'9'; <I ,,U35GGI- != }}GJJw() %
r   c                 
   [        U[        [        45      (       a^  U R                  (       a  U R                  R                  US5        [        U[        5      (       a  U R                  S:X  a  [        US5      n[        U5      $ )zu
Converts *value* into a <string> includes a value check, depending
on :attr:`self.debug` and :attr:`self.profile`.

numbertiny   )	
isinstanceintfloatr   r3   check_svg_typer   roundstrr6   s     r   rf   BaseElement.value_to_string   s]     ec5\**zz--eX>%''DLLF,BeQ5zr   c                     Ub%  U R                   R                  S[        U5      5        Ub&  U R                   R                  S[        U5      5        gg)zJInsert a **title** and/or a **desc** element as first subelement.
        Nr   )r   insertDescTitle)r   titledescs      r   set_descBaseElement.set_desc   sE     MM  DJ/MM  E%L1 r   c                 6   [        U5      n[        U R                  5      S:X  a  U R                  R                  U5        gSnU R                  U   R                  S;   aY  US-  nU[        U R                  5      :X  a  U R                  R                  U5        gU R                  U   R                  S;   a  MY  U R                  U   R                  S:X  a)  U R                  U   R
                  R                  U5        gU R                  R                  X25        g)>
:param xmldata: an xml.etree.ElementTree - Element() object.
r   )ry   rz      Nmetadata)Metadatalenr   rS   rO   r\   rv   )r   xmldatar   poss       r   set_metadataBaseElement.set_metadata   s     G$t}}"MM  *C--$004EEq#dmm,,MM((2	 --$004EE
 }}S!--;c"&&--g6$$S3r   )r   r   r   r,   )NN)__name__
__module____qualname____firstlineno____doc__rO   r   r   r'   propertyr   r   r3   setterr9   r=   r(   rB   rE   rH   rK   r!   rU   rZ   r`   rY   rf   r{   r   __static_attributes__ r   r   r   r      s      K)V) % % ' ' ) ) * * - -$%"%*!"
	,(24r   r   c                   $    \ rS rSrSrS rS rSrg)rx   i  ry   c                     [         R                  " U R                  5      U l        [	        U5      U R                  l        g r,   )r   rc   rO   r\   rs   text)r   r   s     r   r   Title.__init__	  s'    ==!1!12D	r   c                     U R                   $ r,   r\   r-   s    r   rY   Title.get_xml  s    xxr   r   N)r   r   r   r   rO   r   rY   r   r   r   r   rx   rx     s    K"r   rx   c                       \ rS rSrSrSrg)rw   i  rz   r   N)r   r   r   r   rO   r   r   r   r   rw   rw     s    Kr   rw   c                       \ rS rSrSrS rSrg)r   i  r   c                 p    [         R                  " S5      U l        U R                  R                  U5        g)r~   r   N)r   rc   r\   rS   )r   r   s     r   r   Metadata.__init__  s$     ==, r   r   N)r   r   r   r   rO   r   r   r   r   r   r   r     s    K!r   r   )r   svgwrite.etreer   r'   svgwrite.paramsr   svgwrite.utilsr   objectr   rx   rw   r   r   r   r   <module>r      sK    !  % !o4& o4dF 5 !u !r   