ó
    �®žj±0  ã            
       óÖ  • S r SSKrSSKJrJr  SSKJrJrJrJ	r	  \" S5      r
 " S S\5      r " S S	\5      r " S
 S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r\\-  \	-  r  " S S\5      r\R(                  \R*                  S.r Sr Sr Sr \R4                  " S\R6                  5      r SrS\S\4S jrS\ \   S\!\S4   4S  jr"S\S\S\ \   4S! jr#S\S"\$S\S-  4S# jr%S$\S%\$S\S\!\S4   4S& jr&S'\ \!\$\
4      S(\$S\
S-  4S) jr'S*\S-  S\!\\$S-  4   4S+ jr(S,\S-  S\S\4S- jr)S.\ \   S\ \   4S/ jr*S0\+\   S1\S-  S\S-  4S2 jr,g)3u  The content a Pages document holds, however its container spells it.

Both container generations describe the same things â€” paragraphs made of runs,
lists, tables, pictures, page furniture, comments â€” so they are modelled once
here and read into that model by :mod:`docling.backend.iwork.pages_iwa` and
:mod:`docling.backend.iwork.pages_xml`. Turning the result into a
:class:`~docling_core.types.doc.DoclingDocument` is the backend's job, which is
what keeps the two readers from having to agree on anything else.
é    N)Ú
NamedTupleÚTypeVar)ÚDocItemLabelÚ
FormattingÚScriptÚ	TableDataÚ_Tc                   óH   • \ rS rSr% Sr\\S'   \S-  \S'   Sr\S-  \S'   Sr	g)ÚRuné   z;A stretch of text sharing one character style and one link.ÚtextNÚ
formattingÚ	hyperlink© )
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__ÚstrÚ__annotations__r   r   Ú__static_attributes__r   ó    ÚZ/home/mande/repo/quber/.venv/lib/python3.13/site-packages/docling/backend/iwork/content.pyr   r      s#   ‡ ÙEà
ƒIØ˜TÑ!Ó!Ø €Iˆs�T‰zÖ r   r   c                   ó8   • \ rS rSr% Sr\\S'   \\S'   \\S'   Sr	g)Ú	ListLabelé#   zCHow Pages labels one list item: its depth, and the marker it shows.ÚdepthÚ
enumeratedÚmarkerr   N)
r   r   r   r   r   Úintr   Úboolr   r   r   r   r   r   r   #   s   ‡ ÙMàƒJØÓØ†Kr   r   c                   óZ   • \ rS rSr% Sr\\S4   \S'   \\S4   \S'   S\S\	S-  4S	 jr
S
rg)Ú	ListStyleé+   zÏA Pages list style: what each nesting depth is labelled with.

Every field is a parallel array indexed by depth, so a style describes the
whole ladder of nine levels at once rather than one level at a time.
.Úlabel_typesÚstringsr   ÚreturnNc                 ó  • U[        U R                  5      :¼  a  gU R                  U   nU[        :X  a  gU[        :X  a  [	        USS5      $ U[        U R
                  5      :  a  U R
                  U   OSn[	        USU=(       d    S5      $ )ua  Return how a paragraph at ``depth`` is labelled, or None if plain.

Args:
    depth: The paragraph's nesting depth, counted from zero.

Returns:
    The label, or None when this style leaves the depth unlabelled â€”
    which is what Pages' "None" style does at every depth, and is how a
    paragraph that merely inherits a list style stays body text.
NTÚ FÚ-)Úlenr&   ÚLABEL_TYPE_NONEÚLABEL_TYPE_NUMBERr   r'   )Úselfr   Ú
label_typer    s       r   ÚlabelÚListStyle.label5   s‚   € ð ”C˜×(Ñ(Ó)Ó)ØØ×%Ñ% eÑ,ˆ
ØœÓ(ØØÔ*Ó*Ü˜U D¨"Ó-Ð-Ø(-´°D·L±LÓ0AÓ(A�—‘˜eÒ$Àrˆô ˜  v§}°Ó5Ð5r   r   )r   r   r   r   r   Útupler!   r   r   r   r1   r   r   r   r   r$   r$   +   s=   ‡ ñð �s˜C�x‘Ó Ø�3˜�8‰_Óð6˜3ð 6 9¨tÑ#3÷ 6r   r$   c                   ó.   • \ rS rSr% Sr\\S'   \\S'   Srg)ÚCommentéM   z@One comment thread, and the identifier of the text it annotates.r   Úanchorr   N)r   r   r   r   r   r   r   r   r   r   r   r5   r5   M   s   ‡ ÙJà
ƒIØ†Kr   r5   c                   óŒ   • \ rS rSr% Sr\\S4   \S'   \\S'   \	S-  \S'   Sr
\S-  \S'   S	r\\S4   \S
'   \S\4S j5       rS	rg)Ú	ParagraphéT   a  One block of body text with the label its Pages style implies.

A paragraph is kept as runs rather than a single string because Pages
applies character styles to arbitrary stretches of it, and a bold phrase in
the middle of a sentence has to stay attached to that phrase.
.Úrunsr1   NÚlevelÚ
list_labelr   Úanchorsr(   c                 óF   • SR                  S U R                   5       5      $ )z>The paragraph's full text, with its runs joined back together.r*   c              3   ó8   #   • U  H  oR                   v •  M     g 7f)N©r   )Ú.0Úruns     r   Ú	<genexpr>Ú!Paragraph.text.<locals>.<genexpr>e   s   é € Ð5ª9 C—x–xª9ùs   ‚)Újoinr;   )r/   s    r   r   ÚParagraph.textb   s   € ð �w‰wÑ5¨4¯9ª9Ó5Ó5Ð5r   )r   r   r   r   r   r3   r   r   r   r!   r=   r   r>   r   Úpropertyr   r   r   r   r   r9   r9   T   sa   ‡ ñð ��S�‰/ÓØÓØ�‰:ÓØ#'€J�	˜DÑ Ó'Ø!€GˆU�3˜�8‰_Ó!àð6�có 6ó ó6r   r9   c                   ó4   • \ rS rSr% Sr\S-  \S'   \\S'   Srg)ÚPictureéh   uà   An image anchored in the text flow.

``data`` is None when the image's bytes are not in the container â€” Pages
writes a placeholder for media it has not downloaded â€” so the picture is
still placed, just without an image.
NÚdataÚnamer   )	r   r   r   r   r   Úbytesr   r   r   r   r   r   rJ   rJ   h   s   ‡ ñð �$‰,ÓØ
†Ir   rJ   c                   óÈ   • \ rS rSr% Sr/ r\\\\	S-  4      \
S'   / r\\\\S-  4      \
S'   / r\\\\S-  4      \
S'   / r\\\\4      \
S'   / r\\\\	S-  4      \
S'   S	rg)
ÚStorageRunsét   zÕThe run tables of one ``TSWP.StorageArchive``.

Each table pairs a character index with the value that applies from there
until the next entry, so they are read together when the storage is split
into paragraphs.
NÚstylesÚ
charactersÚlistsÚdepthsÚlinksr   )r   r   r   r   r   rR   Úlistr3   r!   r   r   rS   r   rT   r$   rU   rV   r   r   r   r   rP   rP   t   s”   ‡ ñð ,.€FˆD��s˜C $™J�Ñ'Ñ(Ó-Ø68€J��U˜3 
¨TÑ 1Ð1Ñ2Ñ3Ó8Ø02€Eˆ4��c˜9 tÑ+Ð+Ñ,Ñ-Ó2Ø$&€FˆD��s˜C�x‘Ñ!Ó&Ø*,€Eˆ4��c˜3 ™:�oÑ&Ñ'Ö,r   rP   c                   óz   • \ rS rSr% Sr\\   \S'   / r\\	   \S'   / r
\\	   \S'   / r\\	   \S'   / r\\   \S'   Srg	)
ÚContenté‡   a  Everything one Pages document holds.

Page furniture is kept apart from the body flow rather than interleaved with
it: a header belongs to every page a page master covers, not to one point in
the text, so there is no position in ``blocks`` that would be right for it.
ÚblocksÚheadersÚfootersÚ	footnotesÚcommentsr   N)r   r   r   r   r   rW   ÚBlockr   r\   r9   r]   r^   r_   r5   r   r   r   r   rY   rY   ‡   sK   ‡ ñð �‰KÓØ!€GˆT�)‰_Ó!Ø!€GˆT�)‰_Ó!Ø!#€Iˆt�I‰Ó#Ø €Hˆd�7‰mÖ r   rY   )é   é   rb   é   z^heading\s*(\d+)?$u   ï¿¼r   r(   c                 ó.   • U R                  [        S5      $ )a"  Drop the placeholders Apple writes where an inline attachment sits.

Whitespace is deliberately left alone: a run boundary can fall mid-sentence,
so the space on either side of a formatted phrase belongs to the paragraph
and is trimmed once, by :func:`trim`, rather than at every boundary.
r*   )ÚreplaceÚOBJECT_REPLACEMENTrA   s    r   Úcleanrg   ²   s   € ð �<‰<Ô*¨BÓ/Ð/r   r;   .c                 óø  • U  Vs/ s H  oR                   (       d  M  UPM     nnU(       a]  US   R                  US   R                   R                  5       S9nUR                   (       a  X2S'   OUR                  S5        U(       a  M]  U(       a\  US   R                  US   R                   R	                  5       S9nUR                   (       a  XBS'   OUR                  5         U(       a  M\  [        U5      $ s  snf )a%  Trim a paragraph's outer whitespace without disturbing its run boundaries.

Args:
    runs: The paragraph's runs, in document order.

Returns:
    The runs with leading and trailing whitespace removed and empty ones
    dropped, which is empty when the paragraph holds nothing but whitespace.
r   rA   éÿÿÿÿ)r   Ú_replaceÚlstripÚpopÚrstripr3   )r;   rC   ÚkeptÚheadÚtails        r   Útrimrq   ¼   sÉ   € ñ  Ó,š4�C§8¥8�C™4€DÐ,æ
Ø�A‰w×Ñ T¨!¡W§\¡\×%8Ñ%8Ó%:ÐÐ;ˆØ�9�9Ø�‰GØØ�‰�Œ÷ ˆ$ö Ø�B‰x× Ñ  d¨2¡h§m¡m×&:Ñ&:Ó&<Ð Ð=ˆØ�9�9Ø�‰HØØ�‰Œ
÷ ˆ$ô �‹;Ðùò! -s
   …C7�C7c                 ó  • / nSnU R                  S5       Hm  n[        XCU5      nU(       aF  [        [        UR                  U5      5      u  pgUR                  [        XVU[        X5      5      5        U[        U5      S-   -  nMo     U$ )aã  Split a TSWP text run into labelled paragraphs of formatted runs.

Apple separates paragraphs with newlines and pads empty ones, so blank
results are dropped rather than emitted as empty text items. Every run table
is keyed by character index into ``text``, and each entry stays in force
until the next one begins.

Args:
    text: The concatenated text of the storage.
    runs: The storage's run tables.

Returns:
    The non-empty paragraphs, each labelled and carrying its runs.
r   Ú
ra   )	ÚsplitÚruns_forÚlabel_for_styleÚvalue_atrR   Úappendr9   Úlist_label_atr,   )r   r;   Ú
paragraphsÚoffsetÚlineÚpiecesr1   r<   s           r   Úsplit_paragraphsr~   Ù   s‚   € ð #%€JØ€Fà—
‘
˜4Ö ˆÜ˜$¨Ó-ˆÞÜ*¬8°D·K±KÀÓ+HÓI‰LˆEØ×ÑÜ˜&¨´¸dÓ0KÓLôð 	”#�d“)˜a‘-ÑŠñ !ð Ðr   r{   c                 ó’   • [        U R                  U5      nUc  gUR                  [        U R                  U5      =(       d    S5      $ )zKReturn how the paragraph starting at ``offset`` is labelled as a list item.Nr   )rw   rT   r1   rU   )r;   r{   Ústyles      r   ry   ry   ÷   s9   € ä�T—Z‘Z Ó(€EØ�}ØØ�;‰;”x §¡¨VÓ4×9¸Ó:Ð:r   r|   Ústartc                 ó¨  • UR                   (       d0  UR                  (       d  [        [        [	        U 5      S5      /5      $ UR                   UR                  4 VVVs1 s H/  nU  H%  u  pEXs=:  a  U[        U 5      -   :  d  M  O  M#  UiM'     M1     nnnnU/[        U5      Qn/ n[        U5       H‹  u  pšU	S-   [        U5      :  a  XyS-      OU[        U 5      -   n[	        X
U-
  X±-
   5      nU(       d  MG  UR                  [        U[        UR                   U
5      [        UR                  U
5      5      5        M�     [        U5      $ s  snnnf )a  Cut one line into runs at the style and link boundaries inside it.

Args:
    line: One paragraph of the storage's text.
    start: The paragraph's character index into the storage.
    runs: The storage's run tables.

Returns:
    The paragraph's runs, trimmed, in document order.
Nra   )
rS   rV   rq   r   rg   r,   ÚsortedÚ	enumeraterx   rw   )r|   r�   r;   ÚtableÚindexÚ_ÚinsideÚ
boundariesr}   ÚpositionÚbeginÚendr   s                r   ru   ru   ÿ   s>  € ð �?�? 4§:§:Ü”Sœ˜t› dÓ+Ð,Ó-Ð-ð
 —o‘o t§z¡zÑ2õâ2ˆEÜ‰HˆEØÕ,˜5¤3 t£9Ñ,Ñ,ó 	ñ -õ 	áñ 	Ù2ð ò ð Ð)œ& ›.Ð)€JØ€Fä$ ZÖ0‰ˆð ˜!‰|œc *›oÓ-ð  !‘|Ò$àœ˜T›Ñ"ð 	ô
 �T %™-¨#©+Ð6Ó7ˆßˆ4Ø�M‰MÜØÜ˜TŸ_™_¨eÓ4Ü˜TŸZ™Z¨Ó/óöñ 1ô  �‹<Ðùô3s   Á$EÂEÂ

Er…   r†   c                 ó4   • SnU  H  u  p4X1:”  a    U$ UnM     U$ )a  Return the value a run table puts in force at ``index``.

Args:
    table: Character index and value pairs, in document order.
    index: The character index to look up.

Returns:
    The value of the last entry at or before ``index``, or None when the
    table starts after it.
Nr   )r…   r†   ÚcurrentrŠ   Úvalues        r   rw   rw   *  s1   € ð €GÛ ‰ˆØÓØà€Nð Šñ !ð €Nr   Ú
style_namec                 óÌ  • U (       d  [         R                  S4$ U R                  5       nUR                  5       nUS:X  a  [         R                  S4$ US;   a  [         R
                  S4$ [        R                  U5      nU(       aN  UR                  S5      (       a  [        UR                  S5      5      OSn[         R
                  [        US5      4$ [         R                  S4$ )aÍ  Map an iWork paragraph style name onto a Docling label.

Pages names its built-in styles the same way in both container generations
("Title", "Heading 1", "Subheading", "Body"), so one mapping serves the IWA
and XML readers alike. Custom styles are unknown to us and stay body text.

Args:
    style_name: The paragraph style name, or None when the run inherits one.

Returns:
    The label to use, and the heading level when the label is a section
    header.
NÚtitle>   ÚsubtitleÚ
subheadingrb   ra   é   )r   ÚTEXTÚstripÚcasefoldÚTITLEÚSECTION_HEADERÚHEADING_PATTERNÚmatchÚgroupr!   Úmin)r�   rM   Úloweredrœ   r<   s        r   rv   rv   =  sÁ   € ö Ü× Ñ  $Ð&Ð&à×ÑÓ€DØ�m‰m‹o€Gà�'ÓÜ×!Ñ! 4Ð'Ð'ØÐ,Ó,Ü×*Ñ*¨AÐ-Ð-ä×!Ñ! $Ó'€EÞð (-§{¡{°1§~¡~”�E—K‘K “NÔ#¸1ˆÜ×*Ñ*¬C°°q«MÐ9Ð9ä×Ñ˜dÐ"Ð"r   Úauthorc                 ó$   • U (       a  SU  SU 3$ U$ )zGPrefix a comment with its author, the way the Word backend renders one.z	[author: z]: r   )r    r   s     r   Úauthoredr¢   `  s   € æ,2ˆY�v�h˜c $ Ð(Ð<¸Ð<r   rz   c                 ó¬   • [        5       n/ nU  HA  nUR                  U;   a  M  UR                  UR                  5        UR                  U5        MC     U$ )z<Drop repeats, keeping the first of each, without reordering.)Úsetr   Úaddrx   )rz   ÚseenÚuniqueÚ	paragraphs       r   Úunique_paragraphsr©   e  sJ   € ä“U€DØ €FÛˆ	Ø�>‰>˜TÓ!ÙØ�‰�—‘Ô Ø�‰�iÖ ñ	  ð
 €Mr   ÚactiveÚscriptc                 óx   • U (       d  Uc  g[        SU ;   SU ;   SU ;   SU ;   U=(       d    [        R                  S9$ )a  Build a ``Formatting`` from the character properties in force.

Args:
    active: The names of the boolean properties that are set.
    script: The script setting, or None for ordinary text.

Returns:
    The formatting, or None when the style says nothing Docling records.
NÚboldÚitalicÚ	underlineÚstrikethrough)r­   r®   r¯   r°   r«   )r   r   ÚBASELINE)rª   r«   s     r   Úbuild_formattingr²   q  sG   € ö �f‘nØÜØ�vÑØ˜6Ñ!Ø Ñ'Ø%¨Ñ/Ø×(œŸ™ñð r   )-r   ÚreÚtypingr   r   Údocling_core.types.docr   r   r   r   r	   r   r   r$   r5   r9   rJ   rP   r`   rY   ÚSUPERÚSUBÚSCRIPTSr-   ÚLABEL_TYPE_STRINGr.   ÚcompileÚ
IGNORECASEr›   rf   r   rg   rW   r3   rq   r~   r!   ry   ru   rw   rv   r¢   r©   r¤   r²   r   r   r   Ú<module>r¼      s?  ðñó 
ß &÷ó ñ ˆTƒ]€ô!ˆ*ô !ô�
ô ô6�
ô 6ôDˆjô ô6�
ô 6ô(	ˆjô 	ô-�*ô -ð 	�GÑ˜iÑ'€Ø Dô!ˆjô !ð �l‰l˜vŸz™zÑ
*€ðð
 €Ø PàÐ ðð Ð Ø Hà—*’*Ð2°B·M±MÓB€Ø Qð Ð ð0�ð 0˜ô 0ðˆt�C‰yð ˜U 3¨ 8™_ô ð:˜3ð  kð °d¸9±oô ð<;˜ð ;¨Sð ;°YÀÑ5Eô ;ð(�3ð (˜sð (¨+ð (¸%ÀÀSÀ¹/ô (ðV�D˜˜s B˜w™Ñ(ð °ð ¸¸d¹ô ð& #  d¡
ð  #¨u°\À3ÈÁ:Ð5MÑ/Nô  #ðF=�S˜4‘Zð = sð =¨sô =ð
	 $ y¡/ð 	°d¸9±oô 	ð˜S ™Xð ¨v¸©}ð ÀÈdÑARõ r   