Ë
    £ëi,5  ã                   óX   — d dl mZ d dlmZ d dlmZ ddlmZmZ  G d„ d«      Z	d„ Z
d	„ Zy
)é    )Úcached_property)Úwarn)Úascii_loweré   )Úcompile_selector_listÚsplit_whitespacec                   ó>  — e Zd ZdZedd„«       Zedd„«       Zedd„«       Z	 dd„Zd„ Z	d„ Z
d	„ Zd
„ Zed„ «       Zed„ «       Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zed„ «       Zd„ Zd„ Zd„ Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Z ed„ «       Z!ed„ «       Z"y) ÚElementWrapperaí  Wrapper of :class:`xml.etree.ElementTree.Element` for Selector matching.

    This class should not be instanciated directly. :meth:`from_xml_root` or
    :meth:`from_html_root` should be used for the root element of a document,
    and other elements should be accessed (and wrappers generated) using
    methods such as :meth:`iter_children` and :meth:`iter_subtree`.

    :class:`ElementWrapper` objects compare equal if their underlying
    :class:`xml.etree.ElementTree.Element` do.

    Nc                 ó*   — | j                  ||d¬«      S )a.  Wrap for selector matching the root of an XML or XHTML document.

        :param root:
            An ElementTree :class:`xml.etree.ElementTree.Element`
            for the root element of a document.
            If the given element is not the root,
            selector matching will behave is if it were.
            In other words, selectors will be not be `scoped`_
            to the subtree rooted at that element.
        :returns:
            A new :class:`ElementWrapper`

        .. _scoped: https://drafts.csswg.org/selectors-4/#scoping

        F©Úin_html_document©Ú
_from_root©ÚclsÚrootÚcontent_languages      úO/var/www/html/chat/reports/venv/lib/python3.12/site-packages/cssselect2/tree.pyÚfrom_xml_rootzElementWrapper.from_xml_root   s   € ð" �~‰~˜dÐ$4Àuˆ~ÓMÐMó    c                 ó*   — | j                  ||d¬«      S )zæSame as :meth:`from_xml_root` with case-insensitive attribute names.

        Useful for documents parsed with an HTML parser like html5lib, which
        should be the case of documents with the ``text/html`` MIME type.

        Tr   r   r   s      r   Úfrom_html_rootzElementWrapper.from_html_root(   s   € ð �~‰~˜dÐ$4Àtˆ~ÓLÐLr   c                 óV   — t        |d«      r|j                  «       } | |d dd ||¬«      S )NÚgetrootr   )ÚparentÚindexÚpreviousr   r   )Úhasattrr   )r   r   r   r   s       r   r   zElementWrapper._from_root2   s5   € ä�4˜Ô#Ø—<‘<“>ˆDÙØ˜ Q°Ø-Ð@PôRð 	Rr   c                 ó¬   — || _         || _        || _        |�|j                  | _        n|g| _        || _        || _        || _        d | _        d | _	        y ©N)
Úetree_elementr   r   Úetree_childrenÚetree_siblingsr   r   Útransport_content_languageÚ
_ancestorsÚ_previous_siblings)Úselfr!   r   r   r   r   r   s          r   Ú__init__zElementWrapper.__init__:   sh   € ð +ˆÔð ˆŒð !ˆŒØÐð
 #)×"7Ñ"7ˆDÕà#0 /ˆDÔð ˆŒ
Ø 0ˆÔØ*:ˆÔ'ð ˆŒØ"&ˆÕr   c                 ód   — t        | «      t        |«      u xr | j                  |j                  k(  S r    )Útyper!   ©r'   Úothers     r   Ú__eq__zElementWrapper.__eq__V   s0   € ä�‹Jœ$˜u›+Ð%ò 6Ø×Ñ %×"5Ñ"5Ñ5ð	7r   c                 ó   — | |k(   S r    © r+   s     r   Ú__ne__zElementWrapper.__ne__[   s   € Ø˜E‘MÐ"Ð"r   c                 óB   — t        t        | «      | j                  f«      S r    )Úhashr*   r!   ©r'   s    r   Ú__hash__zElementWrapper.__hash__^   s   € Ü”T˜$“Z ×!3Ñ!3Ð4Ó5Ð5r   c              #   ó@   K  — | j                  «       E d {  –—†  y 7 Œ­wr    )Úiter_childrenr3   s    r   Ú__iter__zElementWrapper.__iter__a   s   è ø€ Ø×%Ñ%Ó'×'Ò'ús   ‚–—c                 ó¢   — | j                   €8| j                  €dn$g | j                  j                  ¢| j                  ‘­| _         | j                   S )uÂ   Tuple of existing ancestors.

        Tuple of existing :class:`ElementWrapper` objects for this elementâ€™s
        ancestors, in reversed tree order, from :attr:`parent` to the root.

        r/   )r%   r   Ú	ancestorsr3   s    r   r9   zElementWrapper.ancestorsd   sF   € ð �?‰?Ð"à—k‘kÐ)‘Ð/T°·±×1FÑ1FÐ/TÈÏÉÑ/Tð ŒOà�‰Ðr   c                 ó¢   — | j                   €8| j                  €dn$g | j                  j                  ¢| j                  ‘­| _         | j                   S )u¨   Tuple of previous siblings.

        Tuple of existing :class:`ElementWrapper` objects for this elementâ€™s
        previous siblings, in reversed tree order.

        r/   )r&   r   Úprevious_siblingsr3   s    r   r;   z ElementWrapper.previous_siblingsq   sM   € ð ×"Ñ"Ð*à—m‘mÐ+‘ØA�$—-‘-×1Ñ1ÐA°4·=±=ÑAð Ô#ð ×&Ñ&Ð&r   c              #   óX   K  — t        dt        «       | j                  E d{  –—†  y7 Œ­w)u¨  Iterate over ancestors.

        Return an iterator of existing :class:`ElementWrapper` objects for this
        elementâ€™s ancestors, in reversed tree order (from :attr:`parent` to the
        root).

        The element itself is not included, this is an empty sequence for the
        root element.

        This method is deprecated and will be removed in version 0.7.0. Use
        :attr:`ancestors` instead.

        zfThis method is deprecated and will be removed in version 0.7.0. Use the "ancestors" attribute instead.N)r   ÚDeprecationWarningr9   r3   s    r   Úiter_ancestorszElementWrapper.iter_ancestors   s'   è ø€ ô 	ð5äô	 ð —>‘>×!Ò!úó   ‚ *¢(£*c              #   óX   K  — t        dt        «       | j                  E d{  –—†  y7 Œ­w)u§  Iterate over previous siblings.

        Return an iterator of existing :class:`ElementWrapper` objects for this
        elementâ€™s previous siblings, in reversed tree order.

        The element itself is not included, this is an empty sequence for a
        first child or the root element.

        This method is deprecated and will be removed in version 0.7.0. Use
        :attr:`previous_siblings` instead.

        znThis method is deprecated and will be removed in version 0.7.0. Use the "previous_siblings" attribute instead.N)r   r=   r;   r3   s    r   Úiter_previous_siblingsz%ElementWrapper.iter_previous_siblings“   s)   è ø€ ô 	ð=äô	 ð ×)Ñ)×)Ò)úr?   c              #   óv   K  — | j                   €| –— y| j                   j                  «       E d{  –—†  y7 Œ­w)u£   Iterate over siblings.

        Return an iterator of newly-created :class:`ElementWrapper` objects for
        this elementâ€™s siblings, in tree order.

        N)r   r6   r3   s    r   Úiter_siblingszElementWrapper.iter_siblings¦   s-   è ø€ ð �;‰;ÐØ‹Jà—{‘{×0Ñ0Ó2×2Ò2ús   ‚/9±7²9c              #   óV   K  — d}| j                  «       D ]  }|r|–— || k(  sŒd}Œ y­w)u­   Iterate over next siblings.

        Return an iterator of newly-created :class:`ElementWrapper` objects for
        this elementâ€™s next siblings, in tree order.

        FTN)rC   )r'   ÚfoundÚsiblings      r   Úiter_next_siblingsz!ElementWrapper.iter_next_siblings²   s9   è ø€ ð ˆØ×)Ñ)Ó+ò 	ˆGÙØ’Ø˜$‹Ø‘ñ		ùs   ‚!)¤)c              #   ó’   K  — d}t        | j                  «      D ])  \  }} t        | «      || ||| j                  ¬«      }|–— Œ+ y­w)u©   Iterate over children.

        Return an iterator of newly-created :class:`ElementWrapper` objects for
        this elementâ€™s child elements, in tree order.

        N)r   r   r   r   )Ú	enumerater"   r*   r   )r'   ÚchildÚiÚetree_childs       r   r6   zElementWrapper.iter_childrenÀ   sT   è ø€ ð ˆÜ'¨×(;Ñ(;Ó<ò 	‰NˆAˆ{Ø”D˜“JØ D°¸EØ!%×!6Ñ!6ô8ˆEð ‹Kñ		ùs   ‚AAc              #   ó¼   K  — t        | g«      g}|rIt        |d   d«      }|€|j                  «        n#|–— |j                  |j	                  «       «       |rŒHyy­w)a¨  Iterate over subtree.

        Return an iterator of newly-created :class:`ElementWrapper` objects for
        the entire subtree rooted at this element, in tree order.

        Unlike in other methods, the element itself *is* included.

        This loops over an entire document:

        .. code-block:: python

            for element in ElementWrapper.from_root(root_etree).iter_subtree():
                ...

        éÿÿÿÿN)ÚiterÚnextÚpopÚappendr6   )r'   ÚstackÚelements      r   Úiter_subtreezElementWrapper.iter_subtreeÎ   sU   è ø€ ô  �t�f“�ˆÙÜ˜5 ™9 dÓ+ˆGØˆØ—	‘	•à’Ø—‘˜W×2Ñ2Ó4Ô5ô ùs   ‚AAÁAc                 ó´   — | D ��cg c]E  }t        |d«      r|gn
t        |«      D ]&  }|j                  €|j                  s|j                  ‘Œ( ŒG c}}S c c}}w )NÚtest)r   r   Úpseudo_elementÚnever_matchesrW   )Ú	selectorsÚselectorÚcompiled_selectors      r   Ú_compilezElementWrapper._compileç   si   € ð &÷1àä% h°Ô7�‘
Ü*¨8Ó4ò1ð "ð !×/Ñ/Ð7Ø!×/Ò/ð ×"Ó"ð1Ø"ó1ð 	1ùó 1s   †A
Ac                 óJ   ‡ — t        ˆ fd„‰ j                  |«      D «       «      S )zðReturn wether this elememt matches any of the given selectors.

        :param selectors:
            Each given selector is either a :class:`compiler.CompiledSelector`,
            or an argument to :func:`compile_selector_list`.

        c              3   ó.   •K  — | ]  } |‰«      –— Œ y ­wr    r/   )Ú.0rW   r'   s     €r   ú	<genexpr>z)ElementWrapper.matches.<locals>.<genexpr>ú   s   øè ø€ ÒC $‘4˜—:ÑCùó   ƒ)Úanyr]   ©r'   rZ   s   ` r   ÚmatcheszElementWrapper.matchesò   s   ø€ ô ÓC¨$¯-©-¸	Ó*BÔCÓCÐCr   c                 óÈ   ‡— | j                  |«      Št        ‰«      dk(  rt        ‰d   | j                  «       «      S |rˆfd„| j                  «       D «       S t	        d«      S )aÛ  Return elements, in tree order, that match any of given selectors.

        Selectors are `scoped`_ to the subtree rooted at this element.

        .. _scoped: https://drafts.csswg.org/selectors-4/#scoping

        :param selectors:
            Each given selector is either a :class:`compiler.CompiledSelector`,
            or an argument to :func:`compile_selector_list`.
        :returns:
            An iterator of newly-created :class:`ElementWrapper` objects.

        r   r   c              3   óL   •‡K  — | ]  Št        ˆfd „‰D «       «      r‰–— Œ y­w)c              3   ó.   •K  — | ]  } |‰«      –— Œ y ­wr    r/   )r`   rW   rT   s     €r   ra   z5ElementWrapper.query_all.<locals>.<genexpr>.<genexpr>  s   øè ø€ Ò7¨‘t˜G—}Ñ7ùrb   N)rc   )r`   rT   Útestss    @€r   ra   z+ElementWrapper.query_all.<locals>.<genexpr>  s'   ùè ø€ ò 9Ø#ÜÓ7°Ô7Ô7ô ñ9ùs   „ $r/   )r]   ÚlenÚfilterrU   rO   )r'   rZ   ri   s     @r   Ú	query_allzElementWrapper.query_allü   sa   ø€ ð —‘˜iÓ(ˆÜˆu‹:˜Š?Ü˜% ™( D×$5Ñ$5Ó$7Ó8Ð8Ùó9Ø'+×'8Ñ'8Ó':ô9ð 9ô ˜“8ˆOr   c                 ó4   — t         | j                  |Ž d«      S )aj  Return first element that matches any of given selectors.

        :param selectors:
            Each given selector is either a :class:`compiler.CompiledSelector`,
            or an argument to :func:`compile_selector_list`.
        :returns:
            A newly-created :class:`ElementWrapper` object,
            or :obj:`None` if there is no match.

        N)rP   rl   rd   s     r   ÚqueryzElementWrapper.query  s   € ô �N�D—N‘N IÐ.°Ó5Ð5r   c                 ót   — | j                   D �cg c]  }t        |j                  t        «      r|‘Œ  c}S c c}w )a%  Children as a list of :class:`xml.etree.ElementTree.Element`.

        Other ElementTree nodes such as
        :func:`comments <xml.etree.ElementTree.Comment>` and
        :func:`processing instructions
        <xml.etree.ElementTree.ProcessingInstruction>`
        are not included.

        )r!   Ú
isinstanceÚtagÚstr)r'   rT   s     r   r"   zElementWrapper.etree_children!  s8   € ð $(×#5Ñ#5ö-ØÜ˜'Ÿ+™+¤sÔ+ò ò-ð 	-ùò -s   �#5c                 óh   — t        | j                  j                  «      \  }}|| j                  d<   |S )z,The local name of this element, as a string.Únamespace_url©Ú_split_etree_tagr!   rq   Ú__dict__©r'   rt   Ú
local_names      r   ry   zElementWrapper.local_name0  s3   € ô %5°T×5GÑ5G×5KÑ5KÓ$LÑ!ˆ�zØ)6ˆ�‰�oÑ&ØÐr   c                 óh   — t        | j                  j                  «      \  }}|| j                  d<   |S )z/The namespace URL of this element, as a string.ry   ru   rx   s      r   rt   zElementWrapper.namespace_url7  s3   € ô %5°T×5GÑ5G×5KÑ5KÓ$LÑ!ˆ�zØ&0ˆ�‰�lÑ#ØÐr   c                 ó8   — | j                   j                  d«      S )z$The ID of this element, as a string.Úid)r!   Úgetr3   s    r   r|   zElementWrapper.id>  s   € ð ×!Ñ!×%Ñ% dÓ+Ð+r   c                 ó^   — t        t        | j                  j                  dd«      «      «      S )z:The classes of this element, as a :class:`set` of strings.ÚclassÚ )Úsetr   r!   r}   r3   s    r   ÚclasseszElementWrapper.classesC  s(   € ô Ô# D×$6Ñ$6×$:Ñ$:¸7ÀBÓ$GÓHÓIÐIr   c                 ó2  — | j                   j                  d«      }|�t        |«      S | j                  xs | j                  dk(  }|r(| j                   j                  d«      }|�t        |«      S | j
                  �| j
                  j                  S |rld}| j                   j                  d«      }|D ]=  }|j                  dd«      }t        |«      dk(  sŒ$t        |j                  d	«      «      }Œ? |�t        |«      S t        | j                  «      xs dS )
z*The language of this element, as a string.z*{http://www.w3.org/XML/1998/namespace}langNzhttp://www.w3.org/1999/xhtmlÚlangz"{http://www.w3.org/1999/xhtml}metaz
http-equivr€   zcontent-languageÚcontent)
r!   r}   r   r   rt   r   r„   rO   Ú_parse_content_languager$   )r'   Úxml_langÚis_htmlr„   r   ÚiteratorÚmetaÚ
http_equivs           r   r„   zElementWrapper.langH  s"  € ð ×%Ñ%×)Ñ)Ð*VÓWˆØÐÜ˜xÓ(Ð(à×!Ñ!ò AØ×ÑÐ"@Ñ@ð 	ñ Ø×%Ñ%×)Ñ)¨&Ó1ˆDØÐÜ" 4Ó(Ð(Ø�;‰;Ð"Ø—;‘;×#Ñ#Ð#áØ#ÐØ×)Ñ)×.Ñ.Ð/SÓTˆHØ ò T�Ø!ŸX™X l°BÓ7�
Ü˜zÓ*Ð.@Ó@Ü'>¸t¿x¹xÈ	Ó?RÓ'SÑ$ðTð  Ð+Ü"Ð#3Ó4Ð4ä& t×'FÑ'FÓGÒMÈ2ÐMr   c                 óp  ‡— | j                   €yd}dŠ| j                   j                  j                  |k(  xrf | j                   j                  j                  d«      d uxr= | j                  j                  ‰k7  xs" t	        ˆfd„| j                  «       D «       «      }|xs | j                   j                  S )NFz&{http://www.w3.org/1999/xhtml}fieldsetz${http://www.w3.org/1999/xhtml}legendÚdisabledc              3   óP   •K  — | ]  }|j                   j                  ‰k(  –— Œ y ­wr    )r!   rq   )r`   rF   Úlegends     €r   ra   z6ElementWrapper.in_disabled_fieldset.<locals>.<genexpr>n  s,   øè ø€ ò 8Bàð ×)Ñ)×-Ñ-°Õ7ñ8Bùs   ƒ#&)r   r!   rq   r}   rc   rA   Úin_disabled_fieldset)r'   ÚfieldsetÚdisabled_fieldsetr�   s      @r   r�   z#ElementWrapper.in_disabled_fieldsete  s±   ø€ à�;‰;ÐØØ;ˆØ7ˆà�K‰K×%Ñ%×)Ñ)¨XÑ5ò CØ�K‰K×%Ñ%×)Ñ)¨*Ó5¸TÐAòCà×"Ñ"×&Ñ&¨&Ñ0ò B´Có 8Bà#'×#>Ñ#>Ó#@ô8Bó 5Bð 	ð !ÒD D§K¡K×$DÑ$DÐDr   r    )T)#Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úclassmethodr   r   r   r(   r-   r0   r4   r7   Úpropertyr9   r;   r>   rA   rC   rG   r6   rU   Ústaticmethodr]   re   rl   rn   r   r"   ry   rt   r|   r‚   r„   r�   r/   r   r   r
   r
   	   sc  „ ñ
ð òNó ðNð$ òMó ðMð òRó ðRð 59ó'ò87ò
#ò6ò(ð ñ
ó ð
ð ñ'ó ð'ò"ò(*ò&
3òòò6ð2 ñ1ó ð1òDòò06ð ñ-ó ð-ð ñó ðð ñó ðð ñ,ó ð,ð ñJó ðJð ñNó ðNð8 ñEó ñEr   r
   c                 ó`   — | j                  d«      }|dk(  s| d   dk7  rd| fS | d| | |dz   d  fS )Nú}rN   r   ú{r€   r   )Úrfind)rq   Úpositions     r   rv   rv   t  sE   € Ø�y‰y˜‹~€HØ�2‚~˜˜Q™ 3šØ�3ˆwˆà�1�Xˆ  H¨Q¡J KÐ 0Ð0Ð0r   c                 óP   — | �$d| vrt        | «      }t        |«      dk(  r|d   S y y y )Nú,r   r   )r   rj   )ÚvalueÚpartss     r   r†   r†   |  s:   € ØÐ˜S¨Ñ-Ü  Ó'ˆÜˆu‹:˜Š?Ø˜‘8ˆOð ð .Ðr   N)Ú	functoolsr   Úwarningsr   Úwebencodingsr   Úcompilerr   r   r
   rv   r†   r/   r   r   ú<module>r§      s*   ðÝ %Ý å $ç =÷hEñ hEòV1ór   