+
    Ĝi8                        ^ RI HtHtHt ^ RIHt ^RIHtHtH	t	 Rt
R]! ]4      R3R]! ]]	R,          R30,          4      R3R]! ]]	R,          R	3]	R,          R
30,          4      R3R]! ]	R,          R3]	R,          R3.4      R3R]! ]	R,          R3]	R,          R3.4      R3/t ! R R]4      t ! R R]4      t ! R R]4      tR# )    )absolute_importdivisionunicode_literals)	text_type)scopingElementstableInsertModeElements
namespacesNFbuttonhtmllistolultableselectoptgroupoptionTc                   d   a  ] tR t^t o RtR tR tR tR tRR lt	R t
R	 tR
 tR tR tRtV tR# )NodezRepresents an item in the treec                X    Wn         RV n        RV n        / V n        . V n        . V n        R# )zBCreates a Node

:arg name: The tag name associated with the node

N)nameparentvalue
attributes
childNodes_flags)selfr   s   &&c/Users/mibo/.openclaw/workspace/.venv-ak/lib/python3.14/site-packages/html5lib/treebuilders/base.py__init__Node.__init__   s.     	
     c           
         R P                  V P                  P                  4        UUu. uF  w  rV: RV: R2NK  	  upp4      pV'       d   RV P                  : R V: R2# RV P                  ,          # u uppi ) z=""<><%s>)joinr   itemsr   )r   r   r   attributesStrs   &   r   __str__Node.__str__-   sl    "&//"7"7"9";"9 '2d 26u"="9"; < = $		=99TYY''";s   A6
c                (    R V P                   ,          # )r&   )r   r   s   &r   __repr__Node.__repr__6   s    ##r    c                    \         h)zKInsert node as a child of the current node

:arg node: the node to insert

NotImplementedErrorr   nodes   &&r   appendChildNode.appendChild9   
     "!r    Nc                    \         h)a  Insert data as text in the current node, positioned before the
start of node insertBefore or to the end of the node's text.

:arg data: the data to insert

:arg insertBefore: True if you want to insert the text before the node
    and False if you want to insert it after the node

r1   )r   datainsertBefores   &&&r   
insertTextNode.insertTextA   
     "!r    c                    \         h)zInsert node as a child of the current node, before refNode in the
list of child nodes. Raises ValueError if refNode is not a child of
the current node

:arg node: the node to insert

:arg refNode: the child node to insert the node before

r1   )r   r4   refNodes   &&&r   r:   Node.insertBeforeM   r=   r    c                    \         h)zXRemove node from the children of the current node

:arg node: the child node to remove

r1   r3   s   &&r   removeChildNode.removeChildY   r7   r    c                \    V P                    F  pVP                  V4       K  	  . V n         R# )zMove all the children of the current node to newParent.
This is needed so that trees that don't store text as nodes move the
text in the correct way

:arg newParent: the node to move all this node's children to

N)r   r5   )r   	newParentchilds   && r   reparentChildrenNode.reparentChildrena   s'     __E!!%( %r    c                    \         h)zzReturn a shallow copy of the current node i.e. a node with the same
name and attributes but with no parent or child nodes
r1   r-   s   &r   	cloneNodeNode.cloneNoden   s
     "!r    c                    \         h)zFReturn true if the node has children or text, false otherwise
        r1   r-   s   &r   
hasContentNode.hasContentt   s
     "!r    )r   r   r   r   r   r   N)__name__
__module____qualname____firstlineno____doc__r   r*   r.   r5   r;   r:   rB   rG   rJ   rM   __static_attributes____classdictcell____classdict__s   @r   r   r      s?     ((($"
"
"""" "r    r   c                   ,   a  ] tR t^zt o R tR tRtV tR# )ActiveFormattingElementsc                    ^ pV\         8w  d[   V RRR1,           FJ  pV\         8X  d    M>V P                  W14      '       d
   V^,          pV^8X  g   K9  V P                  V4        M	  \        P	                  W4       R# )r   N)Marker
nodesEqualremover   append)r   r4   
equalCountelements   &&  r   r`   ActiveFormattingElements.append{   si    
6>"::f$??711!OJ?KK( & 	Dr    c                z    VP                   VP                   8X  g   R # VP                  VP                  8X  g   R # R# )FT)	nameTupler   )r   node1node2s   &&&r   r^   #ActiveFormattingElements.nodesEqual   s/    %//15#3#33r     N)rP   rQ   rR   rS   r`   r^   rU   rV   rW   s   @r   rZ   rZ   z   s       r    rZ   c                      a  ] tR t^t o RtRtRtRtRtRt	R t
R tRR ltR tR tR tR	 tR
 tRR ltR tR tR t]! ]]4      tR tR tRR ltR tRR ltR tR tR tRt V t!R# )TreeBuilderzBase treebuilder implementation

* documentClass - the class to use for the bottommost node of a document
* elementClass - the class to use for HTML Elements
* commentClass - the class to use for comments
* doctypeClass - the class to use for doctypes

Nc                T    V'       d	   RV n         MRV n         V P                  4        R# )z]Create a TreeBuilder

:arg namespaceHTMLElements: whether or not to namespace HTML elements

zhttp://www.w3.org/1999/xhtmlN)defaultNamespacereset)r   namespaceHTMLElementss   &&r   r   TreeBuilder.__init__   s      !$BD!$(D!

r    c                    . V n         \        4       V n        R V n        R V n        RV n        V P                  4       V n        R # )NF)openElementsrZ   activeFormattingElementsheadPointerformPointerinsertFromTabledocumentClassdocumentr-   s   &r   rn   TreeBuilder.reset   s?    (@(B%  $**,r    c                   \        VR 4      pV'       g>   \        V\        4      '       d   \        R,          V3p\        V\        4      '       g   Q h\
        V,          w  rE\        V P                  4       FN  pV'       d
   Wa8X  d    R# V'       g   VP                  V8X  d    R# WVP                  V9   ,          '       g   KM   R# 	  Q h)re   r   TF)	hasattr
isinstancer   r	   tuplelistElementsMapreversedrr   re   )r   targetvariant	exactNodelistElementsinvertr4   s   &&&    r   elementInScopeTreeBuilder.elementInScope   s     FK0	&),,$V,f5fe,,,,.w7T../DT^4>>V#;NNl:;; 0 	ur    c           
     b   V P                   '       g   R # \        V P                   4      ^,
          pV P                   V,          pV\        8X  g   W P                  9   d   R # V\        8w  d9   W P                  9  d)   V^ 8X  d   RpMV^,          pV P                   V,          pKC   V^,          pV P                   V,          pVP	                  4       pV P                  RRRVP                  RVP                  RVP                  /4      pW@P                   V&   W@P                   R,          8X  g   K  R # )NtypeStartTagr   	namespacer9   r\   )	rs   lenr]   rr   rJ   insertElementr   r   r   )r   ientryclonerb   s   &    r   #reconstructActiveFormattingElements/TreeBuilder.reconstructActiveFormattingElements   s    ,,, --.2--a0F?e'8'88 vo%/@/@"@AvFA11!4EFA 11!4EOO%E ((&**0%***5u*0%2B2B*D EG 07))!, 77;;r    c                    V P                   P                  4       pV P                   '       d*   V\        8w  d   V P                   P                  4       pK9  R # R # rO   )rs   popr]   )r   r   s   & r   clearActiveFormattingElements)TreeBuilder.clearActiveFormattingElements  sE    --113+++11557E 1@+r    c                    V P                   RRR1,           F&  pV\        8X  d    R# VP                  V8X  g   K$  Vu # 	  R# )zCheck if an element exists between the end of the active
formatting elements and the last marker. If it does, return it, else
return falseNFr\   )rs   r]   r   )r   r   items   && r   !elementInActiveFormattingElements-TreeBuilder.elementInActiveFormattingElements  sI    
 11$B$77D v~  d" 8 r    c                    V P                  V4      pV P                  P                  V4       V P                  P	                  V4       R # rO   )createElementrr   r`   rx   r5   )r   tokenrb   s   && r   
insertRootTreeBuilder.insertRoot  s8    $$U+  )!!'*r    c                    VR ,          pVR,          pVR,          pV P                  W#V4      pV P                  P                  V4       R# )r   publicIdsystemIdN)doctypeClassrx   r5   )r   r   r   r   r   doctypes   &&    r   insertDoctypeTreeBuilder.insertDoctype   sC    V}$$##DH=!!'*r    c                    Vf   V P                   R,          pVP                  V P                  VR,          4      4       R # )Nr9   r\   )rr   r5   commentClass)r   r   r   s   &&&r   insertCommentTreeBuilder.insertComment(  s4    >&&r*F4,,U6];<r    c                    VR,          pVP                  RV P                  4      pV P                  W#4      pVR,          Vn        V# )z.Create an element but don't insert it anywherer   r   r9   )getrm   elementClassr   r   r   r   r   rb   s   &&   r   r   TreeBuilder.createElement-  sB    V}IIk4+@+@A	##D4"6]r    c                    V P                   # rO   )_insertFromTabler-   s   &r   _getInsertFromTableTreeBuilder._getInsertFromTable5  s    $$$r    c                j    Wn         V'       d   V P                  V n        R# V P                  V n        R# )zkSwitch the function used to insert an element from the
normal one to the misnested table one and back againN)r   insertElementTabler   insertElementNormal)r   r   s   &&r   _setInsertFromTableTreeBuilder._setInsertFromTable8  s)     !&!%!8!8D!%!9!9Dr    c                P   VR ,          p\        V\        4      '       g   Q RV,          4       hVP                  RV P                  4      pV P	                  W#4      pVR,          Vn        V P                  R,          P                  V4       V P                  P                  V4       V# )r   zElement %s not unicoder   r9   r\   )	r|   r   r   rm   r   r   rr   r5   r`   r   s   &&   r   r   TreeBuilder.insertElementNormalC  s    V}$	**K,Dt,KK*IIk4+@+@A	##D4"6]"))'2  )r    c                >   V P                  V4      pV P                  R,          P                  \        9  d   V P	                  V4      # V P                  4       w  r4Vf   VP                  V4       MVP                  W$4       V P                  P                  V4       V# )z-Create an element and insert it into the treer\   )	r   rr   r   r   r   getTableMisnestedNodePositionr5   r:   r`   )r   r   rb   r   r:   s   &&   r   r   TreeBuilder.insertElementTableM  s    $$U+R %%-DD++E22 $(#E#E#G F#""7+##G:$$W-r    c                4   Vf   V P                   R,          pV P                  '       d9   V P                  '       d:   V P                   R,          P                  \        9  d   VP	                  V4       R# V P                  4       w  r#VP	                  W4       R# )zInsert text data.Nr\   )rr   rv   r   r   r;   r   )r   r9   r   r:   s   &&& r   r;   TreeBuilder.insertText]  sz    >&&r*F$$$)=)=)=)-):):2)>)C)C0G*Hd# $(#E#E#G Fd1r    c                b   RpRpRpV P                   RRR1,           F  pVP                  R8X  g   K  Tp M	  V'       d[   VP                  '       d   VP                  pTpW#3# V P                   V P                   P                  V4      ^,
          ,          p W#3# V P                   ^ ,          pW#3# )zkGet the foster parent element, and sibling to insert before
(or None) when inserting a misnested table nodeNr   r\   )rr   r   r   index)r   	lastTablefosterParentr:   elms   &    r   r   )TreeBuilder.getTableMisnestedNodePositionl  s     	$$TrT**Cxx7"	 +  (//( ))	  $00%%++I6: < ))  ,,Q/L))r    c                    V P                   R,          P                  pV\        R4      9   d6   W!8w  d.   V P                   P                  4        V P	                  V4       R# R# R# )   Nr\   )dddtlir   r   prprt)rr   r   	frozensetr   generateImpliedEndTags)r   excluder   s   && r   r   "TreeBuilder.generateImpliedEndTags  sX      $))IWXX!!# ''0	   Yr    c                    V P                   # )zReturn the final tree)rx   r-   s   &r   getDocumentTreeBuilder.getDocument  s    }}r    c                j    V P                  4       pV P                  ^ ,          P                  V4       V# )zReturn the final fragment)fragmentClassrr   rG   )r   fragments   & r   getFragmentTreeBuilder.getFragment  s0     %%'!--h7r    c                    \         h)zySerialize the subtree of node in the format required by unit tests

:arg node: the node from which to start serializing

r1   r3   s   &&r   testSerializerTreeBuilder.testSerializer  r7   r    )	r   rs   rm   rx   ru   rt   r   rv   rr   rO   )"rP   rQ   rR   rS   rT   rw   r   r   r   r   r   rn   r   r   r   r   r   r   r   r   r   r   propertyrv   r   r   r;   r   r   r   r   r   rU   rV   rW   s   @r   rk   rk      s      M L L L M

-,,\8
+
+=
%: 24GHO 2*41" "r    rk   )
__future__r   r   r   sixr   	constantsr   r   r	   r]   r   r~   objectr   r   rZ   rk   ri   r    r   <module>r      s   B B  L L
 
 	9_%u
-yZ-?,J+KKLeT
Y:f+=t*D+5f+=t*D*F F GHMOi*V,f5$V,g68 9:?Ay:f-z:%f-x8: ;<@B	`"6 `"Ft 0O"& O"r    