
    )i                        S SK Jr  S SKJrJr  S SKrS SKJrJ	r	  S SK
r
S
S jr\R                  " SS9 " S S	5      5       rg)    )annotations)CallableMutableMappingN)AnyLiteralc                X    U (       d  0 $ [        U [        5      (       a  [        U 5      $ U $ )zConvert Token.attrs set as ``None`` or ``[[key, value], ...]`` to a dict.

This improves compatibility with upstream markdown-it.
)
isinstancelistdict)values    Q/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/markdown_it/token.pyconvert_attrsr   	   s(    
 	%E{L    T)slotsc                     \ rS rSr% S\S'    S\S'    S\S'    \R                  " \S9rS\S	'    S
r	S\S'    Sr
S\S'    S
rS\S'    SrS\S'    SrS\S'    SrS\S'    \R                  " \S9rS\S'    SrS\S'    SrS\S'    S)S jrS*S jrS+S jrS,S jrS-S  jrS.S! jrS/S" jrS0S# jrS$S$S
S
\S%.           S1S& jjr\S2S' j5       rS(rg
)3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hiddenc                8    [        U R                  5      U l        g N)r   r   selfs    r   __post_init__Token.__post_init__M   s    "4::.
r   c                    [         R                  " S[        5        XR                  ;  a  g[	        U R                  R                  5       5      R                  U5      $ )NzEToken.attrIndex should not be used, since Token.attrs is a dictionary)warningswarnUserWarningr   r
   keysindexr)   names     r   	attrIndexToken.attrIndexP   sD    S	
 zz!DJJOO%&,,T22r   c                H    [        U R                  R                  5       5      $ )zGet (key, value) list of attrs.)r
   r   itemsr(   s    r   	attrItemsToken.attrItemsY   s    DJJ$$&''r   c                .    Uu  p#U R                  X#5        g)zAAdd `[ name, value ]` attribute to list. Init attrs if necessary.N)attrSet)r)   attrDatar4   r   s       r   attrPushToken.attrPush]   s    T!r   c                     X R                   U'   g)z>Set `name` attribute to `value`. Override old value if exists.Nr   )r)   r4   r   s      r   r<   Token.attrSetb   s     

4r   c                :    U R                   R                  US5      $ )z@Get the value of attribute `name`, or null if it does not exist.N)r   getr3   s     r   attrGetToken.attrGetf   s    zz~~dD))r   c                    XR                   ;   aT  U R                   U   n[        U[        5      (       d  [        SU R                   U    35      eU SU 3U R                   U'   gX R                   U'   g)zyJoin 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)   r4   r   currents       r   attrJoinToken.attrJoinj   sq    
 ::jj&Ggs++9$**T:J9KL  #*!E73DJJt$JJtr   c                0    [         R                  " U 40 UD6$ )z&Return a shallow copy of the instance.)dcreplace)r)   changess     r   copy
Token.copyy   s    zz$*'**r   T)r   as_upstreammeta_serializerfilterdict_factoryc               
  ^ ^ U" U 4S j[         R                  " T 5       5       5      nT(       a   U" U4S jUR                  5        5       5      nU(       a>  SU;   a8  US   (       d  SO(US   R                  5        VVs/ s H  u  pxXx/PM
     snnUS'   U(       a  SU;   a  U" US   5      US'   U(       aA  UR                  SS5      (       a*  US    V	s/ s H  n	U	R	                  UTUUUS9PM     sn	US'   U$ s  snnf s  sn	f )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  f   >#    U  H&  oR                   [        TUR                   5      4v   M(     g 7fr'   )r4   getattr).0fr)   s     r   	<genexpr> Token.as_dict.<locals>.<genexpr>   s#     X1aff(=>s   .1c              3  L   >#    U  H  u  pT" X5      (       d  M  X4v   M     g 7fr'    )rZ   kvrU   s      r   r\   r]      s     "VodaPQ6A6os   $
$r   Nr"   r   )r   rU   rV   rS   rT   )rN   fieldsr8   rD   as_dict)
r)   r   rS   rT   rU   rV   mappingr`   ra   childs
   `   `     r   rc   Token.as_dict}   s   . X		RVXX""Vgmmo"VVG7g- w' )0)9)?)?)AB)Aqf)AB G
 v0-gfo>GFOJ55 %Z0	# 1E %!!- +$3   1	#GJ  C
	#s   ?C:D c                    U " S0 UD6nUR                   (       a0  UR                    Vs/ s H  o0R                  U5      PM     snUl         U$ s  snf )zConvert a dict to a Token.r_   )r   	from_dict)clsdcttokencs       r   rh   Token.from_dict   sB     
c
>>8=G1mmA.GEN Hs   ArA   )returnNone)r4   r   rn   r   )rn   z#list[tuple[str, str | int | float]])r=   ztuple[str, str | int | float]rn   ro   )r4   r   r   zstr | int | floatrn   ro   )r4   r   rn   zNone | str | int | float)r4   r   r   r   rn   ro   )rP   r   rn   r   )r   r#   rS   r#   rT   z&Callable[[dict[Any, Any]], Any] | NonerU   z!Callable[[str, Any], bool] | NonerV   z'Callable[..., MutableMapping[str, Any]]rn   MutableMapping[str, Any])rj   rp   rn   r   )__name__
__module____qualname____firstlineno____annotations__rN   fieldr   r   r   r   r   r   r    r!   r"   r$   r%   r*   r5   r9   r>   r<   rE   rK   rQ   rc   classmethodrh   __static_attributes__r_   r   r   r   r      sR   
I;	H! +-((4*HE'H
 !C	 =E3N2#'H '7GSUFC?D#N 88D9D.99E4 FD/3("
!*%+  BF48@D- - 	-
 @- 2- >- 
"-^  r   r   )r   r   rn   r   )
__future__r   collections.abcr   r   dataclassesrN   typingr   r   r.   r   	dataclassr   r_   r   r   <module>r~      s>    " 4   	 D\ \ \r   