o
     e                     @   s   d dl mZmZmZmZ d dlmZ d dlmZ d dl	m
Z
 deeef defddZd	edefd
dZdeeeef  dee fddZdedefddZdedee fddZdedefddZdS )    )AnyListOptionalUnion)	PDFObjRef)	PSLiteralPDFDocEncodingsreturnc                 C   sJ   t | tr| drt| dd ddS dd | D }dd	d |D S )
zg
    Decodes a PDFDocEncoding string to Unicode.
    Adds py3 compatibility to pdfminer's version.
    s      Nzutf-16beignorec                 s   s&    | ]}t |trt|n|V  qd S N)
isinstancestrord).0c r   P/var/www/html/venv/lib/python3.10/site-packages/pdfplumber/utils/pdfinternals.py	<genexpr>   s   $ zdecode_text.<locals>.<genexpr> c                 s   s    | ]}t | V  qd S r   r   )r   or   r   r   r          )r   bytes
startswithr   join)r
   ordsr   r   r   decode_text   s   r   objc                 C   s   t | dr	|  } t| trttt| S t| trt| jS t| t	t
fr*t| S t| tr@|  D ]
\}}t|| |< q3| S | S )z(Recursively resolve the metadata values.resolve)hasattrr    r   listmapresolve_and_decoder   r   namer   r   dictitems)r   kvr   r   r   r$      s   




r$   _listc                 C   s   dd | D S )Nc                 S   s$   g | ]}t |trt|jn|qS r   )r   r   r   r%   )r   valuer   r   r   
<listcomp>&   s    z#decode_psl_list.<locals>.<listcomp>r   )r*   r   r   r   decode_psl_list%   s   r-   xc                 C   s   t | tr	|  S | S r   )r   r   r    )r.   r   r   r   r    ,   s   
r    dc                 C   s0   t | tsd S | d}t |trt|jS |S )NType)r   r&   getr   r   r%   )r/   tr   r   r   get_dict_type3   s   



r3   c                    s   t | tr|  }t|dkr| S t|S t | ttfr't| dd | D S t | trBt| dkr5dgng   fdd| 	 D S | S )zF
    Recursively resolves the given object and all the internals.
    Pagec                 s   s    | ]}t |V  qd S r   resolve_all)r   r)   r   r   r   r   J   r   zresolve_all.<locals>.<genexpr>AnnotParentc                    s&   i | ]\}}|| v r|nt |qS r   r5   )r   r(   r)   
exceptionsr   r   
<dictcomp>M   s   & zresolve_all.<locals>.<dictcomp>)
r   r   r    r3   r6   r"   tupletyper&   r'   )r.   resolvedr   r9   r   r6   =   s   

r6   N)typingr   r   r   r   pdfminer.pdftypesr   pdfminer.psparserr   pdfminer.utilsr	   r   r   r   r$   r-   r    r3   r6   r   r   r   r   <module>   s    "
