§
    ¡”jJ  ã                   ó´   — d dl mZ ddlmZmZmZmZ ddlmZ dd„Z	d„ Z
dd„Zdd	„Zd
„ Zdd„Zd„ Zd„ Zdd„Zdd„Zdd„Zdd„Zdd„Zd„ Zd„ Zd„ Z	 	 dd„ZdS )é    )Úchainé   )ÚAtRuleÚDeclarationÚ
ParseErrorÚQualifiedRule)Úparse_component_value_listFc                 ój   — t          | t          ¦  «        rt          | |¦  «        } t          | ¦  «        S )aq  Iterate component values out of string or component values iterable.

    :type input: :obj:`str` or :term:`iterable`
    :param input: A string or an iterable of :term:`component values`.
    :type skip_comments: :obj:`bool`
    :param skip_comments: If the input is a string, ignore all CSS comments.
    :returns: An iterator yielding :term:`component values`.

    )Ú
isinstanceÚstrr	   Úiter)ÚinputÚskip_commentss     ú^/var/www/finuniver-perm.ru/html/portfolio/venv/lib/python3.11/site-packages/tinycss2/parser.pyÚ_to_token_iteratorr      s2   € õ �%�ÑÔð AÝ*¨5°-Ñ@Ô@ˆÝ�‰;Œ;Ðó    c                 ó*   — | D ]}|j         dvr|c S ŒdS )zçReturn the next significant (neither whitespace or comment) token.

    :type tokens: :term:`iterator`
    :param tokens: An iterator yielding :term:`component values`.
    :returns: A :term:`component value`, or :obj:`None`.

    ©Ú
whitespaceÚcommentN)Útype)ÚtokensÚtokens     r   Ú_next_significantr      s9   € ð ð ð ˆØŒ:Ð6Ð6Ð6ØˆLˆLˆLð 7ðð r   c                 óÆ   — t          | |¦  «        }t          |¦  «        }t          |¦  «        }|€t          dddd¦  «        S |�t          |j        |j        dd¦  «        S |S )aú  Parse a single :diagram:`component value`.

    This is used e.g. for an attribute value
    referred to by ``attr(foo length)``.

    :type input: :obj:`str` or :term:`iterable`
    :param input: A string or an iterable of :term:`component values`.
    :type skip_comments: :obj:`bool`
    :param skip_comments: If the input is a string, ignore all CSS comments.
    :returns:
        A :term:`component value` (that is neither whitespace or comment),
        or a :class:`~tinycss2.ast.ParseError`.

    Nr   ÚemptyúInput is emptyúextra-inputzGot more than one token)r   r   r   Úsource_lineÚsource_column)r   r   r   ÚfirstÚseconds        r   Úparse_one_component_valuer#   #   sv   € õ    }Ñ5Ô5€FÝ˜fÑ%Ô%€EÝ˜vÑ&Ô&€FØ€}Ý˜!˜Q Ð)9Ñ:Ô:Ð:ØÐÝØÔ Ô 4°mØ%ñ'ô 'ð 	'ð ˆr   c                 óˆ   — t          | |¦  «        }t          |¦  «        }|€t          dddd¦  «        S t          ||¦  «        S )a?  Parse a single :diagram:`declaration`.

    This is used e.g. for a declaration in an `@supports
    <https://drafts.csswg.org/css-conditional/#at-supports>`_ test.

    :type input: :obj:`str` or :term:`iterable`
    :param input: A string or an iterable of :term:`component values`.
    :type skip_comments: :obj:`bool`
    :param skip_comments: If the input is a string, ignore all CSS comments.
    :returns:
        A :class:`~tinycss2.ast.Declaration`
        or :class:`~tinycss2.ast.ParseError`.

    Any whitespace or comment before the ``:`` colon is dropped.

    Nr   r   r   )r   r   r   Ú_parse_declaration)r   r   r   Úfirst_tokens       r   Úparse_one_declarationr'   ?   sK   € õ"    }Ñ5Ô5€FÝ# FÑ+Ô+€KØÐÝ˜!˜Q Ð)9Ñ:Ô:Ð:Ý˜k¨6Ñ2Ô2Ð2r   c                 ó8   — | D ]}|dk    r d S |r	|dk    r d S Œd S )Nú;Ú}© )r   Únestedr   s      r   Ú_consume_remnantsr-   W   sC   € Øð ð ˆØ�CŠ<ˆ<ØˆFˆFØð 	˜ š˜ØˆFˆFøð	ð r   Tc           	      ó  — | }|j         dk    r5t          ||¦  «         t          |j        |j        dd|j         › d�¦  «        S t          |¦  «        }|€,t          ||¦  «         t          |j        |j        dd¦  «        S |dk    r,t          ||¦  «         t          |j        |j        dd¦  «        S g }d	}d
}d
}t          |¦  «        D ]j\  }	}
|d	k    r|
dk    rd}|	}n?|dk    r|
j         dk    r|
j        dk    rd}n |
j         dvrd	}|
j         dk    r|rd}nd}nd}|                     |
¦  «         Œk|dk    r||d…= |r|rt          |j        |j        dd¦  «        S t          |j        |j        |j
        |j        ||dk    ¦  «        S )a  Parse a declaration.

    Consume :obj:`tokens` until the end of the declaration or the first error.

    :type first_token: :term:`component value`
    :param first_token: The first component value of the rule.
    :type tokens: :term:`iterator`
    :param tokens: An iterator yielding :term:`component values`.
    :type nested: :obj:`bool`
    :param nested: Whether the declaration is nested or top-level.
    :returns:
        A :class:`~tinycss2.ast.Declaration`
        or :class:`~tinycss2.ast.ParseError`.

    ÚidentÚinvalidz+Expected <ident> for declaration name, got ú.Nz,Expected ':' after declaration name, got EOFú:z6Expected ':' after declaration name, got {colon.type}.ÚvalueFú!ÚbangÚ	importantr   ú{} blockTzDeclaration contains {} block)r   r-   r   r   r    r   Ú	enumerateÚlower_valueÚappendr   r3   )r&   r   r,   ÚnameÚcolonr3   ÚstateÚcontains_non_whitespaceÚcontains_simple_blockÚir   Úbang_positions               r   r%   r%   _   s,  € ð  €DØ„y�GÒÐÝ˜& &Ñ)Ô)Ð)ÝØÔ˜dÔ0°)ØF¸$¼)ÐFÐFÐFñHô Hð 	Hõ ˜fÑ%Ô%€EØ€}Ý˜& &Ñ)Ô)Ð)ÝØÔ˜dÔ0°)Ø:ñ<ô <ð 	<ð 
�#ŠˆÝ˜& &Ñ)Ô)Ð)ÝØÔ˜uÔ2°IØDñFô Fð 	Fð €EØ€EØ#ÐØ!ÐÝ˜fÑ%Ô%ð ð ‰ˆˆ5Ø�GÒÐ ¨¢ ØˆEØˆMˆMØ�vŠoˆo %¤*°Ò"7Ð"7ØÔ%¨Ò4Ð4ØˆEˆEØŒZÐ8Ð8Ð8ØˆEØŒz˜ZÒ'Ð'Ø*ð 3Ø,0Ð)Ð)à.2Ð+Ð+à*.Ð'Ø�Š�UÑÔÐÐà�ÒÐØ�-�.�.Ð!ð ð -Ð!8ð -ÝØÔ˜uÔ2°IØ+ñ-ô -ð 	-õ ØÔ˜$Ô,¨d¬j¸$Ô:JØˆu˜Ò#ñ%ô %ð %r   c                 óT  — g }g }| dk    rO| j         dk    rD|D ]A}|dk    r|                     |¦  «          n#|                     |¦  «         |j         dk    r nŒBt          | t          |¦  «        d¬¦  «        }|j         dk    r|S t	          |||¦  «        }t          | |dd¬¦  «        S )z#Consume declaration or nested rule.r)   r7   T)r,   Údeclaration)Ú
stop_tokenr,   )r   r:   r%   r   r   Ú_consume_qualified_rule)r&   r   Údeclaration_tokensÚsemicolon_tokenr   rC   s         r   Ú_consume_blocks_contentrH   ©   sã   € àÐØ€OØ�cÒÐ˜kÔ.°*Ò<Ð<Øð 	ð 	ˆEØ˜Š|ˆ|Ø×&Ò& uÑ-Ô-Ð-Ø�Ø×%Ò% eÑ,Ô,Ð,ØŒz˜ZÒ'Ð'Ø�ð (å$Ø•TÐ,Ñ-Ô-°dð<ñ <ô <€KàÔ˜=Ò(Ð(ØÐåÐ)¨?¸FÑCÔCˆÝ& {°FÀsÐSWÐXÑXÔXÐXr   c                 ó„   — g }|D ]}|dk    r n|                      |¦  «         Œ t          | t          |¦  «        ¦  «        S )z�Like :func:`_parse_declaration`, but stop at the first ``;``.

    Deprecated, use :func:`_consume_blocks_content` instead.

    r)   )r:   r%   r   )r&   r   Úother_declaration_tokensr   s       r   Ú_consume_declaration_in_listrK   ¾   sW   € ð  "ÐØð /ð /ˆØ�CŠ<ˆ<ØˆEØ ×'Ò'¨Ñ.Ô.Ð.Ð.Ý˜k­4Ð0HÑ+IÔ+IÑJÔJÐJr   c                 óp  — t          | |¦  «        }g }|D ] }|j        dk    r|s|                     |¦  «         Œ%|j        dk    r|s|                     |¦  «         ŒH|j        dk    r$|                     t          ||¦  «        ¦  «         Œw|dk    r#|                     t	          ||¦  «        ¦  «         Œ¡|S )u–  Parse a blockâ€™s contents.

    This is used e.g. for the :attr:`~tinycss2.ast.QualifiedRule.content`
    of a style rule or ``@page`` rule, or for the ``style`` attribute of an
    HTML element.

    In contexts that donâ€™t expect any at-rule and/or qualified rule,
    all :class:`~tinycss2.ast.AtRule` and/or
    :class:`~tinycss2.ast.QualifiedRule` objects should simply be rejected as
    invalid.

    :type input: :obj:`str` or :term:`iterable`
    :param input: A string or an iterable of :term:`component values`.
    :type skip_comments: :obj:`bool`
    :param skip_comments:
        Ignore CSS comments at the top-level of the list.
        If the input is a string, ignore all comments.
    :type skip_whitespace: :obj:`bool`
    :param skip_whitespace:
        Ignore whitespace at the top-level of the list.
        Whitespace is still preserved
        in the :attr:`~tinycss2.ast.Declaration.value` of declarations
        and the :attr:`~tinycss2.ast.AtRule.prelude`
        and :attr:`~tinycss2.ast.AtRule.content` of at-rules.
    :returns:
        A list of
        :class:`~tinycss2.ast.Declaration`,
        :class:`~tinycss2.ast.AtRule`,
        :class:`~tinycss2.ast.QualifiedRule`,
        :class:`~tinycss2.ast.Comment` (if ``skip_comments`` is false),
        :class:`~tinycss2.ast.WhitespaceToken`
        (if ``skip_whitespace`` is false),
        and :class:`~tinycss2.ast.ParseError` objects

    r   r   ú
at-keywordr)   )r   r   r:   Ú_consume_at_rulerH   ©r   r   Úskip_whitespacer   Úresultr   s         r   Úparse_blocks_contentsrR   Ì   sÓ   € õH    }Ñ5Ô5€FØ€FØð 
Bð 
BˆØŒ:˜Ò%Ð%Ø"ð %Ø—’˜eÑ$Ô$Ð$øØŒZ˜9Ò$Ð$Ø ð %Ø—’˜eÑ$Ô$Ð$øØŒZ˜<Ò'Ð'Ø�MŠMÕ*¨5°&Ñ9Ô9Ñ:Ô:Ð:Ð:Ø�cŠ\ˆ\Ø�MŠMÕ1°%¸Ñ@Ô@ÑAÔAÐAøØ€Mr   c                 óp  — t          | |¦  «        }g }|D ] }|j        dk    r|s|                     |¦  «         Œ%|j        dk    r|s|                     |¦  «         ŒH|j        dk    r$|                     t          ||¦  «        ¦  «         Œw|dk    r#|                     t	          ||¦  «        ¦  «         Œ¡|S )u­  Parse a :diagram:`declaration list` (which may also contain at-rules).

    Deprecated and removed from CSS Syntax Level 3. Use
    :func:`parse_blocks_contents` instead.

    This is used e.g. for the :attr:`~tinycss2.ast.QualifiedRule.content`
    of a style rule or ``@page`` rule, or for the ``style`` attribute of an
    HTML element.

    In contexts that donâ€™t expect any at-rule, all
    :class:`~tinycss2.ast.AtRule` objects should simply be rejected as invalid.

    :type input: :obj:`str` or :term:`iterable`
    :param input: A string or an iterable of :term:`component values`.
    :type skip_comments: :obj:`bool`
    :param skip_comments:
        Ignore CSS comments at the top-level of the list.
        If the input is a string, ignore all comments.
    :type skip_whitespace: :obj:`bool`
    :param skip_whitespace:
        Ignore whitespace at the top-level of the list.
        Whitespace is still preserved
        in the :attr:`~tinycss2.ast.Declaration.value` of declarations
        and the :attr:`~tinycss2.ast.AtRule.prelude`
        and :attr:`~tinycss2.ast.AtRule.content` of at-rules.
    :returns:
        A list of
        :class:`~tinycss2.ast.Declaration`,
        :class:`~tinycss2.ast.AtRule`,
        :class:`~tinycss2.ast.Comment` (if ``skip_comments`` is false),
        :class:`~tinycss2.ast.WhitespaceToken`
        (if ``skip_whitespace`` is false),
        and :class:`~tinycss2.ast.ParseError` objects

    r   r   rM   r)   )r   r   r:   rN   rK   rO   s         r   Úparse_declaration_listrT      sÓ   € õH    }Ñ5Ô5€FØ€FØð 
Gð 
GˆØŒ:˜Ò%Ð%Ø"ð %Ø—’˜eÑ$Ô$Ð$øØŒZ˜9Ò$Ð$Ø ð %Ø—’˜eÑ$Ô$Ð$øØŒZ˜<Ò'Ð'Ø�MŠMÕ*¨5°&Ñ9Ô9Ñ:Ô:Ð:Ð:Ø�cŠ\ˆ\Ø�MŠMÕ6°u¸fÑEÔEÑFÔFÐFøØ€Mr   c                 óö   — t          | |¦  «        }t          |¦  «        }|€t          dddd¦  «        S t          ||¦  «        }t          |¦  «        }|�$t          |j        |j        dd|j        z  ¦  «        S |S )a¬  Parse a single :diagram:`qualified rule` or :diagram:`at-rule`.

    This would be used e.g. by `insertRule()
    <https://drafts.csswg.org/cssom/#dom-cssstylesheet-insertrule>`_
    in an implementation of CSSOM.

    :type input: :obj:`str` or :term:`iterable`
    :param input: A string or an iterable of :term:`component values`.
    :type skip_comments: :obj:`bool`
    :param skip_comments:
        If the input is a string, ignore all CSS comments.
    :returns:
        A :class:`~tinycss2.ast.QualifiedRule`,
        :class:`~tinycss2.ast.AtRule`,
        or :class:`~tinycss2.ast.ParseError` objects.

    Any whitespace or comment before or after the rule is dropped.

    Nr   r   r   r   z4Expected a single rule, got %s after the first rule.)r   r   r   Ú_consume_ruler   r    r   )r   r   r   r!   ÚruleÚnexts         r   Úparse_one_rulerY   4  s�   € õ(    }Ñ5Ô5€FÝ˜fÑ%Ô%€EØ€}Ý˜!˜Q Ð)9Ñ:Ô:Ð:å˜ Ñ'Ô'€DÝ˜VÑ$Ô$€DØÐÝØÔ˜dÔ0°-ØBÀTÄYÑNñPô Pð 	Pð €Kr   c                 ó  — t          | |¦  «        }g }|D ]k}|j        dk    r|s|                     |¦  «         Œ%|j        dk    r|s|                     |¦  «         ŒH|                     t          ||¦  «        ¦  «         Œl|S )a  Parse a non-top-level :diagram:`rule list`.

    Deprecated and removed from CSS Syntax. Use :func:`parse_blocks_contents`
    instead.

    This is used for parsing the :attr:`~tinycss2.ast.AtRule.content`
    of nested rules like ``@media``.
    This differs from :func:`parse_stylesheet` in that
    top-level ``<!--`` and ``-->`` tokens are not ignored.

    :type input: :obj:`str` or :term:`iterable`
    :param input: A string or an iterable of :term:`component values`.
    :type skip_comments: :obj:`bool`
    :param skip_comments:
        Ignore CSS comments at the top-level of the list.
        If the input is a string, ignore all comments.
    :type skip_whitespace: :obj:`bool`
    :param skip_whitespace:
        Ignore whitespace at the top-level of the list.
        Whitespace is still preserved
        in the :attr:`~tinycss2.ast.QualifiedRule.prelude`
        and the :attr:`~tinycss2.ast.QualifiedRule.content` of rules.
    :returns:
        A list of
        :class:`~tinycss2.ast.QualifiedRule`,
        :class:`~tinycss2.ast.AtRule`,
        :class:`~tinycss2.ast.Comment` (if ``skip_comments`` is false),
        :class:`~tinycss2.ast.WhitespaceToken`
        (if ``skip_whitespace`` is false),
        and :class:`~tinycss2.ast.ParseError` objects.

    r   r   ©r   r   r:   rV   rO   s         r   Úparse_rule_listr\   V  sœ   € õB    }Ñ5Ô5€FØ€FØð 8ð 8ˆØŒ:˜Ò%Ð%Ø"ð %Ø—’˜eÑ$Ô$Ð$øØŒZ˜9Ò$Ð$Ø ð %Ø—’˜eÑ$Ô$Ð$øà�MŠM�-¨¨vÑ6Ô6Ñ7Ô7Ð7Ð7Ø€Mr   c                 ó  — t          | |¦  «        }g }|D ]o}|j        dk    r|s|                     |¦  «         Œ%|j        dk    r|s|                     |¦  «         ŒH|dvr#|                     t          ||¦  «        ¦  «         Œp|S )a²  Parse :diagram:`stylesheet` from text.

    This is used e.g. for a ``<style>`` HTML element.

    This differs from :func:`parse_rule_list` in that
    top-level ``<!--`` and ``-->`` tokens are ignored.
    This is a legacy quirk for the ``<style>`` HTML element.

    :type input: :obj:`str` or :term:`iterable`
    :param input: A string or an iterable of :term:`component values`.
    :type skip_comments: :obj:`bool`
    :param skip_comments:
        Ignore CSS comments at the top-level of the stylesheet.
        If the input is a string, ignore all comments.
    :type skip_whitespace: :obj:`bool`
    :param skip_whitespace:
        Ignore whitespace at the top-level of the stylesheet.
        Whitespace is still preserved
        in the :attr:`~tinycss2.ast.QualifiedRule.prelude`
        and the :attr:`~tinycss2.ast.QualifiedRule.content` of rules.
    :returns:
        A list of
        :class:`~tinycss2.ast.QualifiedRule`,
        :class:`~tinycss2.ast.AtRule`,
        :class:`~tinycss2.ast.Comment` (if ``skip_comments`` is false),
        :class:`~tinycss2.ast.WhitespaceToken`
        (if ``skip_whitespace`` is false),
        and :class:`~tinycss2.ast.ParseError` objects.

    r   r   )z<!--z-->r[   rO   s         r   Úparse_stylesheetr^   …  s¤   € õ>    }Ñ5Ô5€FØ€FØð 8ð 8ˆØŒ:˜Ò%Ð%Ø"ð %Ø—’˜eÑ$Ô$Ð$øØŒZ˜9Ò$Ð$Ø ð %Ø—’˜eÑ$Ô$Ð$øØ˜/Ð)Ð)Ø�MŠM�-¨¨vÑ6Ô6Ñ7Ô7Ð7øØ€Mr   c                 óX   — | j         dk    rt          | |¦  «        S t          | |¦  «        S )aÈ  Parse a qualified rule or at-rule.

    Consume just enough of :obj:`tokens` for this rule.

    :type first_token: :term:`component value`
    :param first_token: The first component value of the rule.
    :type tokens: :term:`iterator`
    :param tokens: An iterator yielding :term:`component values`.
    :returns:
        A :class:`~tinycss2.ast.QualifiedRule`,
        :class:`~tinycss2.ast.AtRule`,
        or :class:`~tinycss2.ast.ParseError`.

    rM   )r   rN   rE   )r&   r   s     r   rV   rV   ²  s2   € ð Ô˜<Ò'Ð'Ý ¨VÑ4Ô4Ð4Ý" ;°Ñ7Ô7Ð7r   c                 óÆ   — g }d}|D ]3}|j         dk    r	|j        } n|dk    r n|                     |¦  «         Œ4t          | j        | j        | j        | j        ||¦  «        S )aò  Parse an at-rule.

    Consume just enough of :obj:`tokens` for this rule.

    :type at_keyword: :class:`AtKeywordToken`
    :param at_keyword: The at-rule keyword token starting this rule.
    :type tokens: :term:`iterator`
    :param tokens: An iterator yielding :term:`component values`.
    :type nested: :obj:`bool`
    :param nested: Whether the at-rule is nested or top-level.
    :returns:
        A :class:`~tinycss2.ast.QualifiedRule`,
        or :class:`~tinycss2.ast.ParseError`.

    Nr7   r)   )r   Úcontentr:   r   r   r    r3   r9   )Ú
at_keywordr   Úpreludera   r   s        r   rN   rN   Æ  s‡   € ð  €GØ€GØð ð ˆØŒ:˜Ò#Ð#ð ”mˆGØˆEØ�cŠ\ˆ\ØˆEØ�Š�uÑÔÐÐÝØÔ 
Ô 8¸*Ô:JØÔ ¨ñ2ô 2ð 2r   c                 ó@   — t          | j        | j        d|› d�¦  «        S )z6Create rule parse error raised because of given token.r0   z. reached before {} block for a qualified rule.)r   r   r    )r   r;   s     r   Ú_rule_errorre   æ  s0   € åØÔ˜5Ô.°	ØÐAÐAÐAñCô Cð Cr   Nc                 óD  — | |k    rt          | d¦  «        S | j        dk    rg }| }nZ| g}|D ]>}||k    rt          |d¦  «        c S |j        dk    r|} n,|                     |¦  «         Œ?t          |d         d¦  «        S t          | j        | j        ||j        ¦  «        S )aø  Consume a qualified rule.

    Consume just enough of :obj:`tokens` for this rule.

    :type first_token: :term:`component value`
    :param first_token: The first component value of the rule.
    :type tokens: :term:`iterator`
    :param tokens: An iterator yielding :term:`component values`.
    :type nested: :obj:`bool`
    :param nested: Whether the rule is nested or top-level.
    :type stop_token: :class:`~tinycss2.ast.Node`
    :param stop_token: A token that ends rule parsing when met.

    z
Stop tokenr7   éÿÿÿÿÚEOF)re   r   r:   r   r   r    ra   )r&   r   r,   rD   rc   Úblockr   s          r   rE   rE   í  sØ   € ð  �jÒ Ð Ý˜;¨Ñ5Ô5Ð5ØÔ˜:Ò%Ð%ØˆØˆˆà�-ˆØð 
	3ð 
	3ˆEØ˜
Ò"Ð"Ý" 5¨,Ñ7Ô7Ð7Ð7Ð7ØŒz˜ZÒ'Ð'Ø�ð �Ø�NŠN˜5Ñ!Ô!Ð!Ð!å˜w rœ{¨EÑ2Ô2Ð2ÝØÔ Ô!:¸GÀUÄ]ñTô Tð Tr   )F)T)FF)FN)Ú	itertoolsr   Úastr   r   r   r   Ú	tokenizerr	   r   r   r#   r'   r-   r%   rH   rK   rR   rT   rY   r\   r^   rV   rN   re   rE   r+   r   r   ú<module>rm      sª  ðØ Ð Ð Ð Ð Ð à ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1ðð ð ð ð
ð 
ð 
ðð ð ð ð83ð 3ð 3ð 3ð0ð ð ðG%ð G%ð G%ð G%ðTYð Yð Yð*Kð Kð Kð1ð 1ð 1ð 1ðh1ð 1ð 1ð 1ðhð ð ð ðD,ð ,ð ,ð ,ð^*ð *ð *ð *ðZ8ð 8ð 8ð(2ð 2ð 2ð@Cð Cð Cð 9>Ø'+ð#Tð #Tð #Tð #Tð #Tð #Tr   