§
    ¥”jœ  ã                   óf   — d Z ddlmZ ddlmZmZ ddlmZ ddlmZ ddgZ	d	„ Z
 G d
„ d¦  «        ZdS )z2Utilities common to reading and writing PDF files.é    )ÚTupleé   )ÚgenericÚmisc)ÚDocumentMetadata)ÚPdfErrorÚ
PdfHandlerÚfind_inherited_value_in_treec                 óv   — | }	 	 ||         S # t           $ r 	 ||         }n# t           $ r Y Y nw xY wY nw xY wŒ5d S ©N)ÚKeyError)Úinit_objÚkeyÚ
parent_keyÚobjs       új/var/www/finuniver-perm.ru/html/portfolio/venv/lib/python3.11/site-packages/pyhanko/pdf_utils/rw_common.pyr
   r
      sz   € Ø
€Cðð	Ø�s”8ˆOøÝð 	ð 	ð 	ðØ˜*”o��øÝð ð ð Ø��ðøøøð �ð	øøøðð ˆ4s$   … �
5˜! 5¡
/«5®/¯5´5c                   óü   — e Zd ZdZ	 ddej        defd„Zedej	        fd„¦   «         Z
edefd„¦   «         Zedej        fd	„¦   «         Zedej	        fd
„¦   «         Zedeeef         fd„¦   «         Zd„ Zd„ Zd„ ZdS )r	   zfAbstract class providing a general interface for quering objects
    in PDF readers and writers alike.FÚrefÚas_metadata_streamc                 ó   — t           ‚)aO  
        Retrieve the object associated with the provided reference from
        this PDF handler.

        :param ref:
            An instance of :class:`.generic.Reference`.
        :param as_metadata_stream:
            Whether to dereference the object as an XMP metadata stream.
        :return:
            A PDF object.
        ©ÚNotImplementedError)Úselfr   r   s      r   Ú
get_objectzPdfHandler.get_object   ó
   € õ "Ð!ó    Úreturnc                 ó   — t           ‚)a»  
        Returns a view of the document trailer of the document represented
        by this :class:`.PdfHandler` instance.

        The view is effectively read-only, in the sense that any writes
        will not be reflected in the actual trailer (if the handler supports
        writing, that is).

        :return:
            A :class:`.generic.DictionaryObject` representing the current state
            of the document trailer.
        r   ©r   s    r   Útrailer_viewzPdfHandler.trailer_view-   r   r   c                 ó   — t           ‚r   r   r   s    r   Údocument_meta_viewzPdfHandler.document_meta_view=   ó   € å!Ð!r   c                 ó   — t           ‚)zS
        :return: A reference to the document catalog of this PDF handler.
        r   r   s    r   Úroot_refzPdfHandler.root_refA   s
   € õ
 "Ð!r   c                 óp   — | j                              ¦   «         }t          |t          j        ¦  «        sJ ‚|S )zD
        :return: The document catalog of this PDF handler.
        )r%   r   Ú
isinstancer   ÚDictionaryObject)r   Úroots     r   r)   zPdfHandler.rootH   s5   € ð
 Œ}×'Ò'Ñ)Ô)ˆÝ˜$¥Ô 8Ñ9Ô9Ð9Ð9Ð9Øˆr   c                 ó   — t           ‚r   r   r   s    r   Údocument_idzPdfHandler.document_idQ   r#   r   c                 óÒ  ‡‡‡— | j                              d¦  «        }t          |t          j        ¦  «        sJ ‚|                     ¦   «         }t          |t          j        ¦  «        sJ ‚	 |d         }n## t          $ r t          j        ¦   «         }Y nw xY w|d         }‰dk     r|‰z   Šd‰cxk    r|k     sn t          d¦  «        ‚ˆˆˆfd„Š ‰d||t          ¦   «         ¦  «        S )Nú/Pagesú
/Resourcesú/Countr   zPage index out of rangec                 óî  •— |                      ¦   «         }|d         }	 |                     d¦  «        }n# t          $ r Y nw xY w| }t          |¦  «        D �]\  }}t	          |t
          j        ¦  «        st          j        d¦  «        ‚t	          |t
          j        ¦  «        sJ ‚|j	        |v rt          j        d¦  «        ‚|                      ¦   «         }	|	d         }
|
dk    r:|	d         }|‰cxk    r	||z   k     rn n ‰|||||j	        hz  ¦  «        c S ||z  }ŒÉ|
dk    rA|‰k    r6‰r|||fc S 	 |	                     d¦  «        }n# t          $ r Y nw xY w||fc S |d	z  }�Œt          d
¦  «        ‚)Nz/Kidsr.   z0Page tree node children must be indirect objectszCircular reference in page treez/Typer-   r/   z/Pager   zPage not found)r   Úraw_getr   Ú	enumerater'   r   ÚIndirectObjectr   ÚPdfReadErrorÚ	referencer   )Úfirst_page_ixÚpages_obj_refÚlast_rsrc_dictÚ	refs_seenÚ	pages_objÚkidsÚcur_page_ixÚ	kid_indexÚkid_refÚkidÚ	node_typeÚ
desc_countÚ_recurseÚpage_ixÚretrieve_parents               €€€r   rB   z,PdfHandler._walk_page_tree.<locals>._recurseg   s  ø€ Ø%×0Ò0Ñ2Ô2ˆIØ˜WÔ%ˆDðØ!*×!2Ò!2°<Ñ!@Ô!@��øÝð ð ð Ø�ðøøøð (ˆKÝ&/°¡o¤oð #)ñ #)Ñ"�	˜7Ý! '­7Ô+AÑBÔBð ÝÔ+ØJñô ð õ " '­7Ô+AÑBÔBÐBÐBÐBØÔ$¨	Ð1Ð1ÝÔ+Ð,MÑNÔNÐNà×(Ò(Ñ*Ô*�à œL�	Ø Ò(Ð(ð "% X¤�JØ" gÐHÐHÒHÐH°¸jÑ0HÒHÐHÐHÐHÐHØ'˜xØ'Ø#Ø*Ø%¨Ô):Ð(;Ñ;ñ	 ô  ð ð ð ð   :Ñ-�K�KØ 'Ò)Ð)Ø" gÒ-Ð-Ø*ð ;Ø$1°9¸nÐ#MÐMÐMÐMð%Ø14·²¸\Ñ1JÔ1J  øÝ#+ð %ð %ð %Ø $ ð%øøøà#*¨NÐ#:Ð:Ð:Ð:à# qÑ(˜ùåÐ+Ñ,Ô,Ð,s!   Ÿ5 µ
AÁAÄ5EÅ
EÅE)
r)   r1   r'   r   r3   r   r(   r   r   Úset)r   rC   rD   Úpage_tree_root_refÚpage_tree_rootÚroot_resourcesÚ
page_countrB   s    ``    @r   Ú_walk_page_treezPdfHandler._walk_page_treeV   s+  øøø€ à!œY×.Ò.¨xÑ8Ô8ÐÝÐ,­gÔ.DÑEÔEÐEÐEÐEØ+×6Ò6Ñ8Ô8ˆÝ˜.­'Ô*BÑCÔCÐCÐCÐCð	8Ø+¨LÔ9ˆNˆNøÝð 	8ð 	8ð 	8Ý$Ô5Ñ7Ô7ˆNˆNˆNð	8øøøð $ HÔ-ˆ
Ø�QŠ;ˆ;Ø  7Ñ*ˆGØ�WÐ)Ð)Ò)Ð)˜zÒ)Ð)Ð)Ð)ÝÐ4Ñ5Ô5Ð5ð.	-ð .	-ð .	-ð .	-ð .	-ð .	-ð .	-ð` ˆx˜Ð-¨~½s¹u¼uÑEÔEÐEs   Á+A4 Á4BÂBc                 ó0   — |                       |d¬¦  «        S )aŸ  
        Retrieve the node in the page tree containing the
        page with index ``page_ix``, along with the necessary objects
        to modify it in an incremental update scenario.

        :param page_ix:
            The (zero-indexed) number of the page for which we want to
            retrieve the parent.
            A negative number counts pages from the back of the document,
            with index ``-1`` referring to the last page.
        :return:
            A triple with the ``/Pages`` object (or a reference to it),
            the index of the target page in said ``/Pages`` object, and a
            (possibly inherited) resource dictionary.
        T©rD   ©rJ   ©r   rC   s     r   Úfind_page_containerzPdfHandler.find_page_container™   s   € ð  ×#Ò# G¸TÐ#ÑBÔBÐBr   c                 ó0   — |                       |d¬¦  «        S )a  
        Retrieve the page with index ``page_ix`` from the page tree, along with
        the necessary objects to modify it in an incremental update scenario.

        :param page_ix:
            The (zero-indexed) number of the page to retrieve.
            A negative number counts pages from the back of the document,
            with index ``-1`` referring to the last page.
        :return:
            A tuple with a reference to the page object and a
            (possibly inherited) resource dictionary.
        FrL   rM   rN   s     r   Úfind_page_for_modificationz%PdfHandler.find_page_for_modification«   s   € ð ×#Ò# G¸UÐ#ÑCÔCÐCr   N)F)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú	ReferenceÚboolr   Úpropertyr(   r    r   r"   r%   r)   r   Úbytesr+   rJ   rO   rQ   © r   r   r	   r	      sc  € € € € € ð)ð )ð BGð"ð "ØÔ$ð"Ø:>ð"ð "ð "ð "ð  ð"˜gÔ6ð "ð "ð "ñ „Xð"ð ð"Ð$4ð "ð "ð "ñ „Xð"ð ð"˜'Ô+ð "ð "ð "ñ „Xð"ð ð�gÔ.ð ð ð ñ „Xðð ð"˜U 5¨% <Ô0ð "ð "ð "ñ „Xð"ðAFð AFð AFðFCð Cð Cð$Dð Dð Dð Dð Dr   N)rU   Útypingr   Ú r   r   Úmetadata.modelr   r   Ú__all__r
   r	   rZ   r   r   ú<module>r_      s¹   ðØ 8Ð 8à Ð Ð Ð Ð Ð à Ð Ð Ð Ð Ð Ð Ð Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø Ð Ð Ð Ð Ð àÐ7Ð
8€ð
ð 
ð 
ð_Dð _Dð _Dð _Dð _Dñ _Dô _Dð _Dð _Dð _Dr   