ó
    ‰*£h¸+  ã                  ó|   • S r SSKJr  SSKrSSKJr  SSKJr  SSKJ	r	  \(       a  SSK
Jr  SSKJr   " S	 S
\5      rg)zHCustom element class for rendered page-break (CT_LastRenderedPageBreak).é    )ÚannotationsN)ÚTYPE_CHECKING)ÚBaseOxmlElement)Úlazyproperty)ÚCT_Hyperlink)ÚCT_Pc                  ó  • \ rS rSrSr\SS j5       r\SS j5       r\SS j5       r\SS j5       r	SS jr
\SS j5       rSS	 jr\SS
 j5       r\SS j5       r\SS j5       r\SS j5       r\SS j5       r\SS j5       rSrg)ÚCT_LastRenderedPageBreaké   aÎ  `<w:lastRenderedPageBreak>` element, indicating page break inserted by renderer.

A rendered page-break is one inserted by the renderer when it runs out of room on a
page. It is an empty element (no attrs or children) and is a child of CT_R, peer to
CT_Text.

NOTE: this complex-type name does not exist in the schema, where
`w:lastRenderedPageBreak` maps to `CT_Empty`. This name was added to give it
distinguished behavior. CT_Empty is used for many elements.
c                ó¦   • X R                  U R                  5      :X  d  [        S5      eU R                  (       a  U R                  $ U R
                  $ )aq  A "loose" `CT_P` containing only the paragraph content before this break.

Raises `ValueError` if this `w:lastRenderedPageBreak` is not the first rendered
page-break in its paragraph.

The returned `CT_P` is a "clone" (deepcopy) of the `w:p` ancestor of this
page-break with this `w:lastRenderedPageBreak` element and all content preceding
it removed.

NOTE: this `w:p` can itself contain one or more `w:renderedPageBreak` elements
(when the paragraph contained more than one). While this is rare, the caller
should treat this paragraph the same as other paragraphs and split it if
necessary in a folloing step or recursion.
ú6only defined on first rendered page-break in paragraph)Ú_first_lrpb_in_pÚ_enclosing_pÚ
ValueErrorÚ_is_in_hyperlinkÚ_following_frag_in_hlinkÚ_following_frag_in_run©Úselfs    ÚU/home/mande/repo/quber/.venv/lib/python3.13/site-packages/docx/oxml/text/pagebreak.pyÚfollowing_fragment_pÚ-CT_LastRenderedPageBreak.following_fragment_p   sM   € ð  ×,Ñ,¨T×->Ñ->Ó?Ó?ÜÐUÓVÐVð .2×-B×-BˆD×)Ñ)ð	
ØHL×HcÑHcð	
ó    c                óŠ   • U R                   (       a  g[        U R                  R                  SU R                   S35      5      $ )zÕTrue when this page-break element is the last "content" in the paragraph.

This is very uncommon case and may only occur in contrived or cases where the
XML is edited by hand, but it is not precluded by the spec.
FzA(./w:r)[last()]/w:lastRenderedPageBreak[not(following-sibling::*[ú])]©r   Úboolr   ÚxpathÚ_run_inner_content_xpathr   s    r   Úfollows_all_contentÚ,CT_LastRenderedPageBreak.follows_all_content4   sL   € ð × × Øäà×Ñ×#Ñ#ð-ð .2×-JÑ-JÐ,KÈ3ð	Póó

ð 
	
r   c                óŠ   • U R                   (       a  g[        U R                  R                  SU R                   S35      5      $ )z True when a `w:lastRenderedPageBreak` precedes all paragraph content.

This is a common case; it occurs whenever the page breaks on an even paragraph
boundary.
Fz:./w:r[1]/w:lastRenderedPageBreak[not(preceding-sibling::*[r   r   r   s    r   Úprecedes_all_contentÚ-CT_LastRenderedPageBreak.precedes_all_contentM   sL   € ð × × Øäà×Ñ×#Ñ#ð-ð .2×-JÑ-JÐ,KÈ3ð	Póó

ð 
	
r   c                ó¦   • X R                  U R                  5      :X  d  [        S5      eU R                  (       a  U R                  $ U R
                  $ )aa  A "loose" `CT_P` containing only the paragraph content before this break.

Raises `ValueError` if this `w:lastRenderedPageBreak` is not the first rendered
paragraph in its paragraph.

The returned `CT_P` is a "clone" (deepcopy) of the `w:p` ancestor of this
page-break with this `w:lastRenderedPageBreak` element and all its following
siblings removed.
r   )r   r   r   r   Ú_preceding_frag_in_hlinkÚ_preceding_frag_in_runr   s    r   Úpreceding_fragment_pÚ-CT_LastRenderedPageBreak.preceding_fragment_pe   sM   € ð ×,Ñ,¨T×->Ñ->Ó?Ó?ÜÐUÓVÐVð .2×-B×-BˆD×)Ñ)ð	
ØHL×HcÑHcð	
r   c                ó*   • UR                  S5      S   $ )z³The `w:hyperlink` grandparent of this `w:lastRenderedPageBreak`.

Raises `IndexError` when this page-break has a `w:p` grandparent, so only call
when `._is_in_hyperlink` is True.
ú!./parent::w:r/parent::w:hyperlinkr   ©r   )r   Úlrpbs     r   Ú_enclosing_hyperlinkÚ-CT_LastRenderedPageBreak._enclosing_hyperlinkx   s   € ð �z‰zÐ=Ó>¸qÑAÐAr   c                ó*   • U R                  S5      S   $ )zJThe `w:p` element parent or grandparent of this `w:lastRenderedPageBreak`.z./ancestor::w:p[1]r   r,   r   s    r   r   Ú%CT_LastRenderedPageBreak._enclosing_p€   s   € ð �z‰zÐ.Ó/°Ñ2Ð2r   c                óR   • UR                  S5      nU(       d  [        S5      eUS   $ )zvThe first `w:lastRenderedPageBreak` element in `p`.

Raises `ValueError` if there are no rendered page-breaks in `p`.
zI./w:r/w:lastRenderedPageBreak | ./w:hyperlink/w:r/w:lastRenderedPageBreakz,no rendered page-breaks in paragraph elementr   )r   r   )r   ÚpÚlrpbss      r   r   Ú)CT_LastRenderedPageBreak._first_lrpb_in_p…   s+   € ð
 —‘ÐcÓdˆÞÜÐKÓLÐLØ�Q‰xˆr   c                óR  • U R                   (       d  [        S5      e[        R                  " U R                  5      nU R                  U5      nUR                  U5      nUR                  S5       H  nUR                  U5        M     UR                  5       R                  U5        U$ )z“Following CT_P fragment when break occurs within a hyperlink.

Note this is a *partial-function* and raises when `lrpb` is not inside a
hyperlink.
ú4only defined on a rendered page-break in a hyperlinkú(./preceding-sibling::*[not(self::w:pPr)]©
r   r   ÚcopyÚdeepcopyr   r   r.   r   ÚremoveÚ	getparent©r   r3   r-   Ú	hyperlinkÚes        r   r   Ú1CT_LastRenderedPageBreak._following_frag_in_hlink�   s•   € ð ×$×$ÜÐSÓTÐTô �MŠM˜$×+Ñ+Ó,ˆð ×$Ñ$ QÓ'ˆð ×-Ñ-¨dÓ3ˆ	ð —‘Ð!KÖLˆAØ�H‰H�QŽKñ Mð 	×ÑÓ×$Ñ$ YÔ/ð ˆr   c                óŽ  • U R                   (       a  [        S5      e[        R                  " U R                  5      nU R                  U5      nUR                  S5      S   nUR                  S5       H  nUR                  U5        M     UR                  S5       H  nUR                  U5        M     UR                  U5        U$ )z“following CT_P fragment when break does not occur in a hyperlink.

Note this is a *partial-function* and raises when `lrpb` is inside a hyperlink.
ú8only defined on a rendered page-break not in a hyperlinkú./parent::w:rr   r8   z(./preceding-sibling::*[not(self::w:rPr)]©r   r   r:   r;   r   r   r   r<   ©r   r3   r-   Úenclosing_rr@   s        r   r   Ú/CT_LastRenderedPageBreak._following_frag_in_run¬   s²   € ð × × ÜÐWÓXÐXô �MŠM˜$×+Ñ+Ó,ˆð ×$Ñ$ QÓ'ˆð —j‘j Ó1°!Ñ4ˆð ×"Ñ"Ð#MÖNˆAØ�H‰H�QŽKñ Oð
 —‘ÐFÖGˆAØ×Ñ˜qÖ!ñ Hà×Ñ˜4Ô àˆr   c                ó6   • [        U R                  S5      5      $ )z9True when this page-break is embedded in a hyperlink run.r+   )r   r   r   s    r   r   Ú)CT_LastRenderedPageBreak._is_in_hyperlinkÊ   s   € ô �D—J‘JÐBÓCÓDÐDr   c                óR  • U R                   (       d  [        S5      e[        R                  " U R                  5      nU R                  U5      nUR                  U5      nUR                  S5       H  nUR                  U5        M     UR                  5       R                  U5        U$ )z“Preceding CT_P fragment when break occurs within a hyperlink.

Note this is a *partial-function* and raises when `lrpb` is not inside a
hyperlink.
r7   ú./following-sibling::*r9   r>   s        r   r&   Ú1CT_LastRenderedPageBreak._preceding_frag_in_hlinkÏ   s’   € ð ×$×$ÜÐSÓTÐTô �MŠM˜$×+Ñ+Ó,ˆð ×$Ñ$ QÓ'ˆð ×-Ñ-¨dÓ3ˆ	ð —‘Ð!9Ö:ˆAØ�H‰H�QŽKñ ;ð 	�‰Ó×Ñ Ô%ð ˆr   c                óŽ  • U R                   (       a  [        S5      e[        R                  " U R                  5      nU R                  U5      nUR                  S5      S   nUR                  S5       H  nUR                  U5        M     UR                  S5       H  nUR                  U5        M     UR                  U5        U$ )z“Preceding CT_P fragment when break does not occur in a hyperlink.

Note this is a *partial-function* and raises when `lrpb` is inside a hyperlink.
rC   rD   r   rL   rE   rF   s        r   r'   Ú/CT_LastRenderedPageBreak._preceding_frag_in_runí   s°   € ð × × ÜÐWÓXÐXô �MŠM˜$×+Ñ+Ó,ˆð ×$Ñ$ QÓ'ˆð —j‘j Ó1°!Ñ4ˆð ×"Ñ"Ð#;Ö<ˆAØ�H‰H�QŽKñ =ð
 —‘Ð4Ö5ˆAØ×Ñ˜qÖ!ñ 6à×Ñ˜4Ô àˆr   c                ó   •  g)z7XPath fragment matching any run inner-content elements.zjself::w:br | self::w:cr | self::w:drawing | self::w:noBreakHyphen | self::w:ptab | self::w:t | self::w:tab© r   s    r   r   Ú1CT_LastRenderedPageBreak._run_inner_content_xpath  s   € ðð	
r   rQ   N)Úreturnr   )rS   r   )r-   r
   rS   r   )r3   r   rS   r
   )rS   Ústr)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Úpropertyr   r    r#   r(   r.   r   r   r   r   r   r   r&   r'   r   Ú__static_attributes__rQ   r   r   r
   r
      sð   † ñ	ð ó
ó ð
ð. ó
ó ð
ð0 ó
ó ð
ð. ó
ó ð
ô$Bð ó3ó ð3ôð óó ðð8 óó ðð: óEó ðEð óó ðð: óó ðð: ó

ó ó

r   r
   )rY   Ú
__future__r   r:   Útypingr   Údocx.oxml.xmlchemyr   Údocx.sharedr   Údocx.oxml.text.hyperlinkr   Údocx.oxml.text.paragraphr   r
   rQ   r   r   Ú<module>rb      s.   ðÙ Nå "ã Ý  å .Ý $æÝ5Ý-ôF
˜õ F
r   