Ë
    F<kP  ã            	       óò   — d dl mZmZ ddlmZ ddlmZmZmZm	Z	m
Z
mZ erddlmZ ddlmZ ddlmZ  G d	„ d
«      Z G d„ d«      Zeez  Zdddddeeeef      fd„Zdedddedz  fd„Zde	dddedz  fd„Zy)é    )ÚTYPE_CHECKINGÚcasté   )Úlogger_warningé   )ÚArrayObjectÚDictionaryObjectÚIndirectObjectÚ	PdfObjectÚTextStringObjectÚis_null_or_none)Ú
PageObject)Ú	PdfReader)Ú	PdfWriterc            	       ó`   — e Zd ZdZdeddddfd„Zdedz  fd„Zdd	œd
ddedee	   dz  ddfd„Z
y)ÚNamedReferenceLinkzGNamed reference link being preserved until we can resolve it correctly.Ú	referenceÚ
source_pdfr   ÚreturnNc                 ó    — || _         || _        y)z0reference: TextStringObject with named referenceN)Ú
_referenceÚ_source_pdf)Úselfr   r   s      úV/var/www/tapir-food/flask_app/venv/lib/python3.12/site-packages/pypdf/generic/_link.pyÚ__init__zNamedReferenceLink.__init__-   s   € à#ˆŒØ%ˆÕó    c                 ó’   — | j                   j                  j                  t        | j                  «      «      }|r|j
                  S d S ©N)r   Únamed_destinationsÚgetÚstrr   Úpage)r   Údestinations     r   Úfind_referenced_pagez'NamedReferenceLink.find_referenced_page2   s:   € Ø×&Ñ&×9Ñ9×=Ñ=¼cÀ$Ç/Á/Ó>RÓSˆÙ#.ˆ{×ÑÐ8°DÐ8r   )Úknown_namesÚ
target_pdfr   Únew_pager%   c                óÀ   — t        | j                  «      }|€t        |j                  «      }||vr.|j	                  ||j
                  «       |j                  |«       yy)aä  
        Add the named destination of the link to the new page, unless it exists.

        Args:
            target_pdf: PdfWriter which the new link went into.
            new_page: IndirectObject representing the new page in the target PDF.
            known_names: Names of the named destinations of target_pdf, kept up to
                date by this method. Collecting them from target_pdf is expensive,
                thus callers patching many links should pass them.
        N)r!   r   Úsetr   Úadd_named_destinationÚpage_numberÚadd)r   r&   r'   r%   Únames        r   Úpatch_referencez"NamedReferenceLink.patch_reference6   sW   € ô" �4—?‘?Ó#ˆØÐÜ˜j×;Ñ;Ó<ˆKà�{Ñ"Ø×,Ñ,¨T°8×3GÑ3GÔHØ�O‰O˜DÕ!ð #r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r
   r$   r)   r!   r.   © r   r   r   r   *   sj   „ ÙQð&Ð"2ð &Àð &ÐPTó &ð
9 n°tÑ&;ó 9ð (,ò"àð"ð !ð"ð
 ˜‘X ‘_ð"ð 
ô"r   r   c                   óF   — e Zd ZdZdeddfd„Zdedz  fd„Zddd	eddfd
„Zy)ÚDirectReferenceLinkzHDirect reference link being preserved until we can resolve it correctly.r   r   Nc                 ó   — || _         y)zIreference: an ArrayObject whose first element is the Page indirect objectN©r   )r   r   s     r   r   zDirectReferenceLink.__init__S   s	   € à#ˆ�r   c                 óV   — | j                   sy t        t        | j                   d   «      S )Nr   )r   r   r
   )r   s    r   r$   z(DirectReferenceLink.find_referenced_pageW   s"   € Ø�ŠØÜ”N D§O¡O°AÑ$6Ó7Ð7r   r&   r   r'   c                 ó"   — || j                   d<   y)z2target_pdf: PdfWriter which the new link went intor   Nr7   )r   r&   r'   s      r   r.   z#DirectReferenceLink.patch_reference\   s   € à%ˆ�‰˜Òr   )	r/   r0   r1   r2   r   r   r
   r$   r.   r3   r   r   r5   r5   P   sD   „ ÙRð$ +ð $°$ó $ð8 n°tÑ&;ó 8ð
&¨+ð &Àð &ÐTXô &r   r5   r'   r   Úold_pager   c                 óþ  — | j                  dt        «       «      j                  «       }|j                  dt        «       «      j                  «       }t        |«      r
t        «       }t        |«      r
t        «       }t	        |t        «      rt	        |t        «      sOt	        |t        «      r|n|}|j
                  }t        dt        |€dnd|› �t        |«      j                  ¬«       g S |D �cg c]  }t        || «      x}�|‘Œ }}|D �cg c]  }t        ||«      x}�|‘Œ }	}t        |«      t        |	«      k7  r%t        dt        t        |	«      t        |«      ¬«       t        t        ||	«      «      S c c}w c c}w )a!  Extracts links from two pages on the assumption that the two pages are
    the same. Produces one list of (new link, old link) tuples.

    Non-link annotations are ignored before pairing to avoid dropping valid
    links when one page includes additional non-link annotation entries.
    z/AnnotszTIgnoring the links on %(page)s: its /Annots is a %(annotations_type)s, not an array.za pagezthe page with index )Úsourcer"   Úannotations_typez8Annotation sizes differ: %(old_count)d vs. %(new_count)d)r<   Ú	old_countÚ	new_count)r    r   Ú
get_objectr   Ú
isinstancer+   r   r/   ÚtypeÚ_build_linkÚlenÚlistÚzip)
r'   r:   Únew_annotationsÚold_annotationsÚ	malformedÚ
page_indexÚ
annotationÚlinkÚ	new_linksÚ	old_linkss
             r   Úextract_linksrO   d   sj  € ð —l‘l 9¬k«mÓ<×GÑGÓI€OØ—l‘l 9¬k«mÓ<×GÑGÓI€OÜ�Ô'Ü%›-ˆÜ�Ô'Ü%›-ˆÜ�o¤{Ô3¼:ÀoÔWbÔ;cÜ'1°/Ä;Ô'O‘OÐUdˆ	Ø×)Ñ)ˆ
ÜØbÜØ'Ð/‘Ð7KÈJÈ<Ð5XÜ! )›_×5Ñ5õ		
ð ˆ	ð *öàÜ 
¨HÓ5Ð5ˆDÐBò 	ð€Ið ð *öàÜ 
¨HÓ5Ð5ˆDÐBò 	ð€Ið ô ˆ9ƒ~œ˜Y›Ò'ÜØFÜÜ˜)“nÜ˜)“nõ		
ô ”�I˜yÓ)Ó*Ð*ùò'ùò
s   Ã.E5ÄE:Úindirect_objectr"   Nc                 ó\  — t        d|j                  «      }t        t        | j                  «       «      }t	        |t        «      r|j                  d«      dk7  ry d|v r<t        t        |d   «      }|j                  d«      dk7  ry d|vry t        |d   |«      S d|v rt        |d   |«      S y )	Nr   z/Subtypez/Linkz/Az/Sz/GoToz/Dz/Dest)r   Úpdfr	   r@   rA   r    Ú_create_link)rP   r"   ÚsrcrL   Úactions        r   rC   rC   ‘   s©   € Ü
ˆ{˜DŸH™HÓ
%€CÜÔ  /×"<Ñ"<Ó">Ó?€DÜ�tÔ-Ô.°4·8±8¸JÓ3GÈ7Ò3RØàˆt�|ÜÔ&¨¨T©
Ó3ˆØ�:‰:�dÓ˜wÒ&Øà�vÑØÜ˜F 4™L¨#Ó.Ð.à�$�Ü˜D ™M¨3Ó/Ð/àr   r   r   r   c                 ór   — t        | t        «      rt        | |«      S t        | t        «      rt	        | «      S y r   )rA   r   r   r   r5   )r   r   s     r   rS   rS   ¦   s2   € Ü�)Ô-Ô.Ü! )¨ZÓ8Ð8Ü�)œ[Ô)Ü" 9Ó-Ð-Ør   )Útypingr   r   Ú_utilsr   Ú r   r	   r
   r   r   r   Ú_pager   Ú_readerr   Ú_writerr   r   r5   ÚReferenceLinkrE   ÚtuplerO   rC   rS   r3   r   r   ú<module>r_      s­   ð÷> 'å #ß i× iáÝ"Ý#Ý#÷#"ñ #"÷L&ñ &ð" #Ð%8Ñ8€ð*+˜Lð *+°Lð *+ÀTÈ%ÐP]Ð_lÐPlÑJmÑEnó *+ðZ ð °|ð ÈÐX\ÑH\ó ð*˜Ið °;ð À=ÐSWÑCWô r   