
     h                     B    d Z ddlZddlZddlmZ d Zd Zd Zd Zd	 Z	y)
z
Handle CSS stylesheets.

    N   )	parse_urlc              #      K   d}| j                   j                         D ]Y  }|j                  dk(  s|j                  d|      dk(  s)|j                  s6t        j                  |j                  dd       [ yw)z*Find the stylesheets included in ``tree``.text/cssz!{http://www.w3.org/2000/svg}styletypeTskip_commentsskip_whitespaceN)xml_treeitertaggettexttinycss2parse_stylesheet)treedefault_typeelements      h/home/developers/rajanand/mypropertyqr-fmb-refixing-v2/venv/lib/python3.12/site-packages/cairosvg/css.pyfind_stylesheetsr      st      L==%%' 	HKK>>FL1Z? ++D$H H	Hs   /A<A<A<'A<c              #     K   |D ]  }|j                   dk(  r|j                  dk(  r|j                  t        j                  |j
                        }|j                   dvr[t        |j                  |      }t        j                  | j                  |d      j                  d            }t        | ||j                               D ]  }|  |j                   dk(  s|  yw)zFind the rules in a stylesheet.zat-ruleimportN)stringurlr   zutf-8qualified-rule)r   lower_at_keywordcontentr   parse_one_component_valuepreluder   valuer   	fetch_urldecodefind_stylesheets_rulesgeturl)r   stylesheet_rulesr   rule	url_tokencss_url
stylesheets          r   r#   r#      s       99	!$$0T\\5I$>>t||L	>>)::#IOOS9%66NN7J7>>wGI
2j'..*:< DJ
 99((J!s   CC%C%c                 R   g }g }t        j                  |       D ]  }|j                  dk(  s|j                  j	                  d      r/t        j
                  |j                        j                         }|j                  r|n|}|j                  |j                  |f        ||fS )Ndeclaration-)r   parse_declaration_listr   name
startswith	serializer    strip	importantappend
lower_name)inputnormal_declarationsimportant_declarationsr+   r    declarationss         r   parse_declarationsr9   3   s    66u= 
A -$$//4&&{'8'89??AE*5*?*?&(  !7!7 ?@
A  666    c                    t        j                         }t        j                         }t        |       D ]  }t        | ||      D ]  }t	        |j
                        \  }}t        j                  |j                        D ]E  }|j                  |j                  r|r|j                  ||       |s4|j                  ||       G   ||fS )zFind and parse the stylesheets in ``tree``.

    Return two :class:`cssselect2.Matcher` objects,
    for normal and !important declarations.

    )
cssselect2Matcherr   r#   r9   r   compile_selector_listr   pseudo_elementnever_matchesadd_selector)	r   r   normal_matcherimportant_matcherr)   r&   r6   r7   selectors	            r   parse_stylesheetsrE   D   s      '')N"**,&t, >
*4SA 	>D:L;7!7&<<T\\J >++3$22*&33$&9;-)66$&<>>	>> ,,,r:   c              #      K   | j                   dk(  ret        j                  | j                  dd      D ]?  }dj	                  d |j
                  D              }|j                  ||j                  f A yyw)z!Get the declarations in ``rule``.r   Tr    c              3   <   K   | ]  }|j                           y w)N)r0   ).0parts     r   	<genexpr>z#get_declarations.<locals>.<genexpr>b   s     KDNN,Ks   N)r   r   r-   r   joinr    r4   r2   )r&   r+   r    s      r   get_declarationsrM   ]   ss     yy$$#::D$H 	GKGGK9J9JKKE((%1F1FFF		G %s   A6A8)
__doc__r<   r   r   r   r   r#   r9   rE   rM    r:   r   <module>rP      s0   
   H .7"-2Gr:   