ó
    pyüio  ã                   ó|   • S r SSKrSSKJr  SSKJr  SSKJr	  SSKJ
r
  SSKJr  S r " S S\	R                  5      rg)	)ÚPdfAttachmenté    N)Údecode)ÚFPDF_WCHAR_size)ÚPdfiumErrorc                 ó˜   • [        U [        5      (       a  U S-   R                  S5      $ [        S[	        U 5      R
                   S35      e)NÚ zutf-8zKey must be str, but z was given.)Ú
isinstanceÚstrÚencodeÚ	TypeErrorÚtypeÚ__name__)Úkeys    ÚZ/home/mande/repo/quber/.venv/lib/python3.13/site-packages/pypdfium2/_helpers/attachment.pyÚ_encode_keyr      sD   € Ü�#”s×ÑØ�f‘×$Ñ$ WÓ-Ð-äÐ/´°S³	×0BÑ0BÐ/CÀ;ÐOÓPÐPó    c                   óH   • \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rSrg)r   é   a.  
Attachment helper class.
See PDF 1.7, Section 7.11 "File Specifications".

Attributes:
    raw (FPDF_ATTACHMENT):
        The underlying PDFium attachment handle.
    pdf (PdfDocument):
        Reference to the document this attachment belongs to. Must remain valid as long as the attachment is used.
c                 ó   • Xl         X l        g )N)ÚrawÚpdf)Úselfr   r   s      r   Ú__init__ÚPdfAttachment.__init__(   s   € ØŒØ�r   c                 óÜ   • [         R                  " U SS5      nU[        * -  * n[         R                  U-  " 5       n[         R                  " XU5        [	        [        U5      SUS-
   S5      $ )z+
Returns:
    str: Name of the attachment.
Nr   é   ú	utf-16-le)Úpdfium_cÚFPDFAttachment_GetNamer   Ú
FPDF_WCHARr   Ú
memoryview)r   Ún_bytesÚn_unitsÚbuffers       r   Úget_nameÚPdfAttachment.get_name-   sh   € ô
 ×1Ò1°$¸¸aÓ@ˆØ¤Ð/Ñ/Ð0ˆÜ×%Ñ%¨Ò/Ó2ˆÜ×'Ò'¨°gÔ>Ü”j Ó(¨¨'°!©)Ð4°kÓBÐBr   c                 ó’  • [         R                  " 5       n[        R                  " U SSU5        UR                  nUS:X  a  [        SU S35      e[         R                  " U5      n[         R                  " 5       n[        R                  " XX5      nUR                  nU(       d  [        S5      eX:  a  [        SU SU S35      eU$ )z[
Returns:
    ctypes.Array: The attachment's file data (as :class:`~ctypes.c_char` array).
Nr   z,Failed to extract attachment (buffer length z).z,Failed to extract attachment (error status).z'Failed to extract attachment (expected z bytes, but got )ÚctypesÚc_ulongr   ÚFPDFAttachment_GetFileÚvaluer   Úcreate_string_buffer)r   r"   r$   Ú
out_buflenÚoks        r   Úget_dataÚPdfAttachment.get_data9   s¼   € ô —.’.Ó"ˆÜ×'Ò'¨¨d°A°wÔ?Ø—-‘-ˆØ�a‹<ÜÐ LÈWÈIÐUWÐXÓYÐYä×,Ò,¨WÓ5ˆÜ—^’^Ó%ˆ
Ü×,Ò,¨T¸7ÓOˆØ×%Ñ%ˆ
ÞÜÐLÓMÐMØÓÜÐ GÈÀyÐP`ÐakÐ`lÐlnÐoÓpÐpàˆr   c                 ó~   • [         R                  " X R                  U[        U5      5      nU(       d  [	        S5      eg)a}  
Set the attachment's file data.
If this function is called on an existing attachment, it will be changed to point at the new data,
but the previous data will not be removed from the file (as of PDFium 5418).

Parameters:
    data (bytes | ctypes.Array):
        New file data for the attachment. May be any data type that can be implicitly converted to :class:`~ctypes.c_void_p`.
zFailed to set attachment data.N)r   ÚFPDFAttachment_SetFiler   Úlenr   )r   Údatar.   s      r   Úset_dataÚPdfAttachment.set_dataQ   s4   € ô ×,Ò,¨T·8±8¸TÄ3ÀtÃ9ÓMˆÞÜÐ>Ó?Ð?ð r   c                 óB   • [         R                  " U [        U5      5      $ )z¶
Parameters:
    key (str):
        A key to look for in the attachment's params dictionary.
Returns:
    bool: True if *key* is contained in the params dictionary, False otherwise.
)r   ÚFPDFAttachment_HasKeyr   ©r   r   s     r   Úhas_keyÚPdfAttachment.has_key`   s   € ô ×-Ò-¨d´KÀÓ4DÓEÐEr   c                 óB   • [         R                  " U [        U5      5      $ )z`
Returns:
    int: Type of the value of *key* in the params dictionary (:attr:`FPDF_OBJECT_*`).
)r   ÚFPDFAttachment_GetValueTyper   r9   s     r   Úget_value_typeÚPdfAttachment.get_value_typek   s   € ô
 ×3Ò3°D¼+ÀcÓ:JÓKÐKr   c                 ó  • [        U5      n[        R                  " XSS5      nUS::  a  [        SU S35      eU[        * -  * n[        R
                  U-  " 5       n[        R                  " XXS5        [        [        U5      SUS-
   S5      $ )z¼
Returns:
    str: The value of *key* in the params dictionary, if it is a string or name.
    Otherwise, an empty string will be returned. On other failures, an exception will be raised.
Nr   zFailed to get value of key 'ú'.r   r   )r   r   ÚFPDFAttachment_GetStringValuer   r   r    r   r!   )r   r   Úenc_keyr"   r#   r$   s         r   Úget_str_valueÚPdfAttachment.get_str_values   sŽ   € ô ˜cÓ"ˆÜ×8Ò8¸ÈÈaÓPˆØ�a‹<ÜÐ <¸S¸EÀÐDÓEÐEà¤Ð/Ñ/Ð0ˆÜ×%Ñ%¨Ò/Ó2ˆÜ×.Ò.¨t¸fÔNä”j Ó(¨¨'°!©)Ð4°kÓBÐBr   c                 óê   • US-   R                  S5      n[        R                  " U[        R                  5      n[        R
                  " U [        U5      U5      nU(       d  [        SU SU S35      eg)z
Set the attribute specified by *key* to the string *value*.

Parameters:
    value (str): New string value for the attribute.
r   r   z Failed to set attachment param 'z' to 'rA   N)r   r(   Úcastr   ÚFPDF_WIDESTRINGÚFPDFAttachment_SetStringValuer   r   )r   r   r+   Ú	enc_valueÚenc_value_ptrr.   s         r   Úset_str_valueÚPdfAttachment.set_str_value†   sk   € ð ˜V‘^×+Ñ+¨KÓ8ˆ	ÜŸš I¬x×/GÑ/GÓHˆÜ×3Ò3°D¼+ÀcÓ:JÈMÓZˆÞÜÐ @ÀÀÀVÈEÈ7ÐRTÐUÓVÐVð r   )r   r   N)r   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r%   r/   r5   r:   r>   rD   rL   Ú__static_attributes__© r   r   r   r      s5   † ñ	ò$ò
	Còò0@òFòLòCõ&Wr   r   )Ú__all__r(   Úcodecsr   Úpypdfium2.rawr   r   Úpypdfium2.internalÚinternalÚpdfium_ir   Úpypdfium2._helpers.miscr   r   ÚAutoCastabler   rS   r   r   Ú<module>r\      s:   ðð €ã Ý Ý  Ý %Ý .Ý /òQô|W�X×*Ñ*õ |Wr   