
    eh                        d dl mZ d dlmZmZ d dlZd dlmZm	Z	 d dl
Z
ddZ ej        d	
           G d d                      ZdS )    )annotations)CallableMutableMappingN)AnyLiteralvaluer   returnc                V    | si S t          | t                    rt          |           S | S )zConvert Token.attrs set as ``None`` or ``[[key, value], ...]`` to a dict.

    This improves compatibility with upstream markdown-it.
    )
isinstancelistdict)r   s    a/home/jenkins/workspace/simtester-sanitize/venv/lib/python3.11/site-packages/markdown_it/token.pyconvert_attrsr   	   s4    
  	% E{{L    T)slotsc                  ~   e Zd ZU ded<   	 ded<   	 ded<   	  ej        e          Zded<   	 d	Zd
ed<   	 dZ	ded<   	 d	Z
ded<   	 dZded<   	 dZded<   	 dZded<   	  ej        e          Zded<   	 dZded<   	 dZded<   	 d;dZd<dZd=d!Zd>d$Zd?d'Zd@d)ZdAd*ZdBd-Zd.d.d	d	ed/dCd8ZedDd:            Zd	S )ETokenstrtypetagzLiteral[-1, 0, 1]nesting)default_factoryzdict[str, str | int | float]attrsNzlist[int] | Nonemapr   intlevelzlist[Token] | Nonechildren contentmarkupinfozdict[Any, Any]metaFboolblockhiddenr	   Nonec                8    t          | j                  | _        d S N)r   r   selfs    r   __post_init__zToken.__post_init__M   s    "4:..


r   namec                    t          j        dt                     || j        vrdS t	          | j                                                                      |          S )NzEToken.attrIndex should not be used, since Token.attrs is a dictionary)warningswarnUserWarningr   r   keysindexr*   r,   s     r   	attrIndexzToken.attrIndexP   sX    S	
 	
 	
 tz!!2DJOO%%&&,,T222r   #list[tuple[str, str | int | float]]c                N    t          | j                                                  S )zGet (key, value) list of attrs.)r   r   itemsr)   s    r   	attrItemszToken.attrItemsY   s    DJ$$&&'''r   attrDatatuple[str, str | int | float]c                <    |\  }}|                      ||           dS )zAAdd `[ name, value ]` attribute to list. Init attrs if necessary.N)attrSet)r*   r:   r,   r   s       r   attrPushzToken.attrPush]   s%    eT5!!!!!r   r   str | int | floatc                    || j         |<   dS )z>Set `name` attribute to `value`. Override old value if exists.N)r   )r*   r,   r   s      r   r=   zToken.attrSetb   s     
4r   None | str | int | floatc                8    | j                             |d          S )z@Get the value of attribute `name`, or null if it does not exist.N)r   getr4   s     r   attrGetzToken.attrGetf   s    z~~dD)))r   c                    || j         v rP| j         |         }t          |t                    st          d| j         |                    | d| | j         |<   dS || j         |<   dS )zJoin value to existing attribute via space.
        Or create new attribute if not exists.
        Useful to operate with token classes.
        z#existing attr 'name' is not a str:  N)r   r   r   	TypeError)r*   r,   r   currents       r   attrJoinzToken.attrJoinj   s    
 4:j&Ggs++ L$*T:JLL   #*33E33DJt$DJtr   changesr   c                &    t          j        | fi |S )z&Return a shallow copy of the instance.)dcreplace)r*   rJ   s     r   copyz
Token.copyy   s    z$**'***r   T)r   as_upstreammeta_serializerfilterdict_factoryrO   rP   &Callable[[dict[Any, Any]], Any] | NonerQ   !Callable[[str, Any], bool] | NonerR   'Callable[..., MutableMapping[str, Any]]MutableMapping[str, Any]c                     fdt          j                   D                       }r) fd|                                D                       }r5d|v r1|d         sdn#d |d                                         D             |d<   rd|v r |d                   |d<   r1|                    dd          rfd|d         D             |d<   |S )	a  Return the token as a dictionary.

        :param children: Also convert children to dicts
        :param as_upstream: Ensure the output dictionary is equal to that created by markdown-it
            For example, attrs are converted to null or lists
        :param meta_serializer: hook for serializing ``Token.meta``
        :param filter: A callable whose return code determines whether an
            attribute or element is included (``True``) or dropped (``False``).
            Is called with the (key, value) pair.
        :param dict_factory: A callable to produce dictionaries from.
            For example, to produce ordered dictionaries instead of normal Python
            dictionaries, pass in ``collections.OrderedDict``.

        c              3  P   K   | ] }|j         t          |j                   fV  !d S r(   )r,   getattr).0fr*   s     r   	<genexpr>z Token.as_dict.<locals>.<genexpr>   s6      XX1af(=(=>XXXXXXr   c              3  >   K   | ]\  }} ||          ||fV  d S r(    )rZ   kvrQ   s      r   r\   z Token.as_dict.<locals>.<genexpr>   s<      "V"VdaPQST"VAq6"V"V"V"V"V"Vr   r   Nc                    g | ]	\  }}||g
S r^   r^   )rZ   r_   r`   s      r   
<listcomp>z!Token.as_dict.<locals>.<listcomp>   s     BBBAq!fBBBr   r"   r   c           	     D    g | ]}|                                S ))r   rQ   rR   rO   rP   )as_dict)rZ   childrO   r   rR   rQ   rP   s     r   rb   z!Token.as_dict.<locals>.<listcomp>   sM     	# 	# 	#  %!!- +$3   	# 	# 	#r   )rL   fieldsr8   rC   )r*   r   rO   rP   rQ   rR   mappings   `````` r   rd   zToken.as_dict}   sU   . ,XXXX	RVXXXXX 	W"l"V"V"V"Vgmmoo"V"V"VVVG 	7g-- w'CBB)9)?)?)A)ABBB G
  	?v00-ogfo>>GFO 
	J55 
		# 	# 	# 	# 	# 	# 	# 	# %Z0	# 	# 	#GJ r   dctc                V       di |}|j         r fd|j         D             |_         |S )zConvert a dict to a Token.c                :    g | ]}                     |          S r^   )	from_dict)rZ   cclss     r   rb   z#Token.from_dict.<locals>.<listcomp>   s%    GGG1cmmA..GGGr   r^   )r   )rm   rh   tokens   `  r   rk   zToken.from_dict   sC     

c

> 	HGGGGGGGENr   )r	   r&   )r,   r   r	   r   )r	   r6   )r:   r;   r	   r&   )r,   r   r   r?   r	   r&   )r,   r   r	   rA   )r,   r   r   r   r	   r&   )rJ   r   r	   r   )r   r#   rO   r#   rP   rS   rQ   rT   rR   rU   r	   rV   )rh   rV   r	   r   )__name__
__module____qualname____annotations__rL   fieldr   r   r   r   r   r   r    r!   r"   r$   r%   r+   r5   r9   r>   r=   rD   rI   rN   rd   classmethodrk   r^   r   r   r   r      s        III;HHH! +3"(4*H*H*HEHHHH
 !C    =ENNNN2#'H''''7GUF?DNNNN $28D999D99999E F/ / / /3 3 3 3( ( ( (" " " "
! ! ! !* * * *% % % %+ + + +  BF48@D- - - - - -^    [  r   r   )r   r   r	   r   )
__future__r   collections.abcr   r   dataclassesrL   typingr   r   r/   r   	dataclassr   r^   r   r   <module>rz      s    " " " " " " 4 4 4 4 4 4 4 4             	 	 	 	 D\ \ \ \ \ \ \ \ \ \r   