
    BPc                         d Z ddlZddlmZ  G d dej                  Zedk    r e                                             dS dS )z>
An Inkscape extension to assist with importing AI SVG files.
    N)unitsc                       e Zd ZdZd ZdS )DocAiConverta  
    Main class of the doc_ai_convert extension

    This extension performs the following two actions:
    1) Recognize intended dimensions of original document.
        - If the AI document was set up with a size given in picas, cm, mm, or in,
          and then exported to SVG, no conversion is needed.
        - If the AI document was set up with any other dimensions,
          (point, yard, px, ft/in, ft, or m), then the exported SVG
          will be in units of 72 DPI pixels. This causes an issue,
          as Inkscape uses CSS pixels (px) which are at 96 DPI.
          In this case, we re-interpret the size as 72 DPI points (pt),
          which will convert the artwork to appear at the correct size.
    2) Recognize Adobe Illustrator layers.
        - Group (<g>) elements with non-empty data-name attributes are
          groups in an Illustrator SVG document.
        - We re-label these as layers such that Inkscape will recognize them.

    c                 b   | j                             d          }| j                             d          }|r|rt          j        |          \  }}t          j        |          \  }}|r4|dk    r.| j                             dt          j        |d                     |r4|dk    r.| j                             dt          j        |d                     | j                             d          D ]A}|                    dd           |                    d|                    d	                     Bd
S )zB
        Main entry point of the doc_ai_convert extension
        widthheightpxptz//svg:g[@data-name]zinkscape:groupmodelayerzinkscape:labelz	data-nameN)svggetr   
parse_unitsetrender_unitxpathpop)selfwidth_stringheight_string	width_numwidth_units
height_numheight_unitsnodes           0/usr/share/inkscape/extensions/doc_ai_convert.pyeffectzDocAiConvert.effect2   s8   
 x||G,,X.. 	PM 	P%*%5l%C%C"I{','7'F'F$J
  N$&&HLL%*;It*L*LMMM P4''HLL5+<Z+N+NOOO HNN#899 	> 	>DHH)7333HH%txx'<'<====	> 	>    N)__name__
__module____qualname____doc__r    r   r   r   r      s-         (> > > > >r   r   __main__)r!   inkexr   EffectExtensionr   r   runr"   r   r   <module>r'      s   *        .> .> .> .> .>5( .> .> .>b zLNN r   