
    ]h>                        d dl mZmZmZmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZ ddlmZ d d	lZd d	lZd d	lZ	  e eed
            ZdZdZdZej8                  d    dk\  reZd dlmZ  d dl!m"Z# ne$Zd dl%mZ  d dl&m"Z# ej8                  dk  reZ' ejP                         Z)e  e       a* ee)      Z+dZ, G d de-      Z.ej^                  ja                  de.       d Z1e
jb                  jd                  e1_2        d Z3e
jf                  jd                  e3_2        d Z4e
jh                  jd                  e4_2        d Z5e
jj                  jd                  e5_2        d Z6d Z7d dZ8d!dZ9e:dk(  r	 e;e2       y	y	)"    )unicode_literalsdivisionabsolute_importprint_function   )Profiles)CSSSerializer)	CSSParser)css)errorhandler)VERSIONN)r   stylesheetsr
   r	   restructuredtextz4Christof Hoeke with contributions by Walter Doerwaldz0$LastChangedDate::                            $:   )urlsplit)pathname2url)      )logc                   0    e Zd ZdZg dZd Zd Zd Zd Zy)DOMImplementationCSSad  This interface allows the DOM user to create a CSSStyleSheet
    outside the context of a document. There is no way to associate
    the new CSSStyleSheet with a document in DOM Level 2.

    This class is its *own factory*, as it is given to
    xml.dom.registerDOMImplementation which simply calls it and receives
    an instance of this class then.
    ))r   1.0)r   2.0)r   r   )r   r   c                 h    ddl }d}|j                  |t               t        j                  ||      S )a(  
        Creates a new CSSStyleSheet.

        title of type DOMString
            The advisory title. See also the Style Sheet Interfaces
            section.
        media of type DOMString
            The comma-separated list of media associated with the new style
            sheet. See also the Style Sheet Interfaces section.

        returns
            CSSStyleSheet: A new CSS style sheet.

        TODO: DOMException
            SYNTAX_ERR: Raised if the specified media string value has a
            syntax error and is unparsable.
        r   NzSDeprecated, see https://bitbucket.org/cthedot/css_parser/issues/69#comment-30669799)titlemedia)warningswarnDeprecationWarningr   CSSStyleSheet)selfr   r   r   warnings        /home/pod-website-builder.sw7ft.com/pod-website-builder/website-analyzer/venv/lib/python3.12/site-packages/css_parser/__init__.pycreateCSSStyleSheetz(DOMImplementationCSS.createCSSStyleSheet   s1    $ 	Yg12  uE::    c                 T    dd l mc m}  |j                         j                  |i |S Nr   )xml.dom.minidomdomminidomDOMImplementationcreateDocumentr"   argskwargsr+   s       r$   r-   z#DOMImplementationCSS.createDocument   s+     	*)9w((*994J6JJr&   c                 T    dd l mc m}  |j                         j                  |i |S r(   )r)   r*   r+   r,   createDocumentTyper.   s       r$   r2   z'DOMImplementationCSS.createDocumentType   s+     	*)=w((*==tNvNNr&   c                 P    |j                         t        |      f| j                  v S N)lower	text_type	_features)r"   featureversions      r$   
hasFeaturezDOMImplementationCSS.hasFeature   s!    7!34FFr&   N)	__name__
__module____qualname____doc__r7   r%   r-   r2   r:    r&   r$   r   r      s%    I;0KOGr&   r   
css_parserc                  6     t               j                  | i |S r4   )r
   parseStringaks     r$   rB   rB      s    "9;""A+++r&   c                  6     t               j                  | i |S r4   )r
   	parseFilerC   s     r$   rG   rG      s     9;  !)q))r&   c                  6     t               j                  | i |S r4   )r
   parseUrlrC   s     r$   rI   rI      s    9;(a((r&   c                  6     t               j                  | i |S r4   )r
   
parseStylerC   s     r$   rK   rK      s    !9;!!1***r&   c                     | a y)z:Set the global serializer used by all class in css_parser.N)ser)
serializers    r$   setSerializerrO      s	     Cr&   c              #      K   d | D        D ]  }|j                     fd |       D ]H  }|j                  d      D ]1  }|j                  D ]   }|j                  dk(  s|j                   " 3 J yw)a  Retrieve all ``url(urlstring)`` values (in e.g.
    :class:`css_parser.css.CSSImportRule` or :class:`css_parser.css.CSSValue`
    objects of given `sheet`.

    :param sheet:
        :class:`css_parser.css.CSSStyleSheet` object whose URLs are yielded

    This function is a generator. The generated URL values exclude ``url(`` and
    ``)`` and surrounding single or double quotes.
    c              3   T   K   | ]   }|j                   |j                  k(  s| " y wr4   typeIMPORT_RULE.0rs     r$   	<genexpr>zgetUrls.<locals>.<genexpr>   s     CQ166Q]]+BqC   ((c              3      K   t        | d      r#| j                  D ]  } |      D ]  }|   yt        | d      r| j                   yywz4recursive generator to find all CSSStyleDeclarationscssRulesstyleN)hasattrr\   r]   )baserulesstyleDeclarationss      r$   rb   z"getUrls.<locals>.styleDeclarations   sX     4$ *40 AG T7#** $s   AATallURIN)hrefgetPropertiespropertyValuerS   uri)sheet
importruler]   pvrb   s        @r$   getUrlsrn      s      D%C 
oo #5)  $$$. 	 A__  66U?%%K 	  s   A A9$A9c                 b    |s?t         t        j                        s%d  D        D ]  } ||j                        |_          fd        D ][  }|j	                  d      D ]D  }|j
                  D ]3  }|j                  |j                  k(  s ||j                        |_        5 F ] y)a`  Replace all URLs in :class:`css_parser.css.CSSImportRule` or
    :class:`css_parser.css.CSSValue` objects of given `sheetOrStyle`.

    :param sheetOrStyle:
        a :class:`css_parser.css.CSSStyleSheet` or a
        :class:`css_parser.css.CSSStyleDeclaration` which is changed in place
    :param replacer:
        a function which is called with a single argument `url` which
        is the current value of each url() excluding ``url(``, ``)`` and
        surrounding (single or double) quotes.
    :param ignoreImportRules:
        if ``True`` does not call `replacer` with URLs from @import rules.
    c              3   T   K   | ]   }|j                   |j                  k(  s| " y wr4   rR   rU   s     r$   rX   zreplaceUrls.<locals>.<genexpr>  s     Naff6M1NrY   c              3      K   t        | d      r#| j                  D ]  } |      D ]  }|   yt        | d      r| j                   yt        t        j
                        r|  yywr[   )r^   r\   r]   
isinstancer   CSSStyleDeclaration)r_   r`   ra   sheetOrStylerb   s      r$   rb   z&replaceUrls.<locals>.styleDeclarations  sm     4$ *40 AG T7#**c&=&=>J ?s   A+A.Trc   N)	rr   r   rs   rf   rg   rh   rS   re   ri   )rt   replacerignoreImportRulesrk   r]   rl   rm   rb   s   `      @r$   replaceUrlsrw     s     Z030G0G&INlN 	8J&z7JO	8
 #<0 ,$$$. 	,A__ ,66QUU?$QUUOAE,	,,r&   c                    |s6t        j                  | j                  | j                  | j                        }d }| j
                  D ]h  }|j                  |j                  k(  r|j                  |j                  k(  r t        j                  d|j                  z  d       |j                  r|j                  t        j                  d|j                  z               	 t        |j                        }t        j                  d|j                  z  d       t!        | ||j                        d	       |j                  j"                  d
k(  rd}nd}|D ]5  }|j                  |j$                  |j&                  |j                  fvs3d} n |r:t        j)                  dd|j*                  d       |j                  |       t        j                  d|j                  j"                  z  d       t        j,                  |j                  j"                        }|D ]'  }|r|j                  |       |j                  |       ) |s|j                  |       !t        j5                  d|j                  z  d       |j                  |       X|j                  |       k |S # t.        j0                  j2                  $ r6}t        j)                  d|z  d       |j                  |       Y d}~d}~ww xY w)a  Recurcively combine all rules in given `sheet` into a `target` sheet.
    @import rules which use media information are tried to be wrapped into
    @media rules so keeping the media information. This may not work in
    all instances (if e.g. an @import rule itself contains an @import rule
    with different media infos or if it contains rules which may not be
    used inside an @media block like @namespace rules.). In these cases
    the @import rule is kept as in the original sheet and a WARNING is issued.

    :param sheet:
        in this given :class:`css_parser.css.CSSStyleSheet` all import rules are
        resolved and added to a resulting *flat* sheet.
    :param target:
        A :class:`css_parser.css.CSSStyleSheet` object which will be the
        resulting *flat* sheet if given
    :returns: given `target` or a new :class:`css_parser.css.CSSStyleSheet`
        object
    )rf   r   r   c                 x    t        |       \  }}}}t        j                  j                        \  }fd}|S )z9Return a replacer which uses base to return adjusted URLsc                 *   t        |       \  }}}}}|s~|s||j                  d      skt        j                  j	                  |      \  }}t        j                  j                  t        j                  j                  ||            }t        |      S | S )N/)urllib_urlsplit
startswithospathsplitnormpathjoinurllib_pathname2url)	ri   schemelocationr   queryfragmentfilenamecombinedbasepaths	           r$   ru   z5resolveImports.<locals>.getReplacer.<locals>.replacerF  su    6Ec6J3FHdE8(4??33G!#t!4h77++BGGLL4,RS*844 
r&   )r|   r~   r   r   )
targetbasebaseschbaseloc	basequerybasefragbasepathfilenameru   r   s          @r$   getReplacerz#resolveImports.<locals>.getReplacerA  s<    :I*:U7(Ix%'WW]]8%<""		 r&   zProcessing @import %rT)
neverraisez/* START @import "%s" */)cssTextz@import: Adjusting paths for %r)rv   rd   NFz`Cannot combine imported sheet with given media as other rules then comments or stylerules found z
, keeping z9@import: Wrapping some rules in @media  to keep media: %sz0@import: Cannot resolve target, keeping rule: %sz1Cannot get referenced stylesheet %r, keeping rule)r   r!   rf   r   r   r\   rS   CHARSET_RULErT   r   info	hrefFoundadd
CSSCommentresolveImports
styleSheetrw   	mediaTextCOMMENT
STYLE_RULEr   r   CSSMediaRulexmlr*   HierarchyRequestErrerror)	rj   targetr   r`   importedSheet
mediaproxy
keepimportrW   es	            r$   r   r   *  s   $ ""

).).6$  H99)))YY$***HH,tyy8THJ~~

3>>2L,0II36 7 84/$24??$CM HH>J(,  . +DII 6268
 zz++u4%)
%*
!. &A  !vvaii./ll./mm.=  = .2
 %& &HH 786:ll	&D
 15 % 6 #JJt,$  "6#'::#7#7"8DH ! J &)%5%5djj6J6J%K
* *%&NN1- #JJqM* "

:. 		M II&26  8

4  JJtQHT My ww22 %HHO !-1  3JJt$$%s   $J66L	+LL	__main__)Fr4   )<
__future__r   r   r   r   profilesr   	serializer	   parser
    r   r   r9   r   xml.domr   os.pathr~   syslistmapstr__all____docformat__
__author____date__version_infor6   urllib.parser   r|   urllib.requestr   r   unicodeurlparseurllibbytesErrorHandlerr   rM   profile_ANYNSobjectr   r*   registerDOMImplementationrB   r>   rG   rI   rK   rO   rn   rw   r   r;   printr?   r&   r$   <module>r      sz   R R  $       
Xt s3LM
N"C
= A!I8BI4:fE  l! o
s
 
7G6 7Gt  ! !,0D E,  ++33 * ''//	 ) %%-- + ))11
 
 <#,Lsl z	'N r&   