o
    jV.                     @   s  U d dl Z d dlZd dlmZ d dlmZmZmZmZ ddl	m
Z
 ddlmZmZ ddlmZmZmZmZmZmZ ddlmZ dd	lmZ d
dlmZmZ e jdd dkr]d dlmZ nd dlmZ ee e f Z!ee"d< de#e! defddZ$G dd deeZ%G dd de%Z&G dd de%Z'G dd de%Z(G dd de%Z)G dd de%Z*G dd  d e%Z+G d!d" d"e%Z,G d#d$ d$e%Z-dS )%    N)ABC)AnyLiteralOptionalUnion   )AnnotationFlag)ArrayObjectDictionaryObject)BooleanObjectFloatObjectIndirectObject
NameObjectNumberObjectTextStringObject)RectangleObject)
hex_to_rgb   )NO_FLAGSAnnotationDictionary)   
   )	TypeAliasVertexverticesreturnc                 C   sz   | d d | d d }}| d d | d d }}| D ]\}}t ||}t ||}t||}t||}qt||||fS )Nr   r   )minmaxr   )r   x_miny_minx_maxy_maxxy r$   k/var/www/html/fyndo/pharma/fyndo/venv/lib/python3.10/site-packages/pypdf/annotations/_markup_annotations.py_get_bounding_rectangle   s   


r&   c                   @   sR   e Zd ZdZddddddee deeeef  de	d d	ee d
df
ddZ
dS )MarkupAnnotationa  
    Base class for all markup annotations.

    Args:
        title_bar: Text to be displayed in the title bar of the annotation;
            by convention this is the name of the author
        in_reply_to: The annotation that this annotation is "in reply to"
            (PDF 1.5). Can be either an annotation (previously added using
            :meth:`~pypdf.PdfWriter.add_annotation`) or a reference to the
            target annotation.
        reply_type: The relationship between this annotation and the one
            specified by ``in_reply_to``. Either ``"R"`` (a reply, default)
            or ``"Group"`` (grouped with the parent annotation). Raises
            ``ValueError`` if a non-default value is provided without
            ``in_reply_to``.
        annotation_name: A text string uniquely identifying this annotation
            among all annotations on its page. Automatically generated when
            ``in_reply_to`` is set and no name is provided. Raises
            ``ValueError`` if provided without ``in_reply_to``.

    NR)	title_barin_reply_to
reply_typeannotation_namer)   r*   r+   )r(   Groupr,   r   c                C   s   |d urt || td< |d ur|d u rtd|dkr$|d u r$td|d urft|tr0|}nt|dd }t|ts?td|}|| td< td| | td	< |d u r\tt }t || td
< d S d S )Nz/Tz9annotation_name is only supported when in_reply_to is setr(   z5reply_type is only meaningful when in_reply_to is setindirect_referencezUin_reply_to must be a registered annotation (added via writer.add_annotation() first)z/IRT/z/RTz/NM)	r   r   
ValueError
isinstancer   getattrstruuiduuid4)selfr)   r*   r+   r,   refindirect_refr$   r$   r%   __init__A   s2   

zMarkupAnnotation.__init__)__name__
__module____qualname____doc__r   r3   r   r
   r   r   r9   r$   r$   r$   r%   r'   *   s"    r'   c                       sV   e Zd ZdZdeddeeeeeeef f de	de
deded	d
f fddZ  ZS )Textz
    A text annotation.

    Args:
        rect: array of four integers ``[xLL, yLL, xUR, yUR]``
            specifying the clickable rectangular area
        text: The text that is added to the document
        open:
        flags:

    F)openflagsrecttextr?   r@   kwargsr   Nc                   sf   t  jdi | td| td< t|| td< t|| td< t|| td< t|| td< d S )Nz/Text/Subtype/Rect	/Contentsz/Openz/Flagsr$   )superr9   r   r   r   r   r   )r6   rA   rB   r?   r@   rC   	__class__r$   r%   r9   r   s   	zText.__init__)r:   r;   r<   r=   r   r   r   tuplefloatr3   boolintr   r9   __classcell__r$   r$   rH   r%   r>   e   s"    r>   c                       s|   e Zd ZdZddddddddded	eeeeeeef f d
ede	de	dedede
e de
e deddf fddZ  ZS )FreeTextzA FreeText annotation	HelveticaF14pt000000ffffff)fontbolditalic	font_size
font_colorborder_colorbackground_colorrB   rA   rT   rU   rV   rW   rX   rY   rZ   rC   r   Nc       	            sP  t  jdi |
 td| td< t|| td< d}|r#| d}n| d}|r0| d}n| d}| | d| }| d	| }d
}|r\t|D ]	}| | d}qM| d}| tdtdtdt|tdt|tdt|tdt|i |d u rttdtdi| td< |	d urt	dd t|	D | td< d S d S )Nz	/FreeTextrD   rE   zfont: zitalic znormal zbold  z;text-align:left;color:# rgrF   z/DSz/DAz/Wr   z/BSc                 S      g | ]}t |qS r$   r   .0nr$   r$   r%   
<listcomp>       z%FreeText.__init__.<locals>.<listcomp>/Cr$   )
rG   r9   r   r   r   updater   r
   r   r	   )r6   rB   rA   rT   rU   rV   rW   rX   rY   rZ   rC   font_strdefault_appearance_stringstrH   r$   r%   r9      sF   



zFreeText.__init__)r:   r;   r<   r=   r3   r   r   rJ   rK   rL   r   r   r9   rN   r$   r$   rH   r%   rO      s@    	
rO   c                       sN   e Zd Z	ddededeeeeeeef f dede	ddf fd	d
Z
  ZS )Liner\   p1p2rA   rB   rC   r   Nc                    s   t  jdi | | tdtdtdt|tdtt|d t|d t|d t|d gtdttdtdgtd	ttd
td
td
gtdt|i d S )NrD   z/LinerE   z/Lr   r   z/LEz/None/ICg      ?rF   r$   )rG   r9   rf   r   r   r	   r   r   )r6   rk   rl   rA   rB   rC   rH   r$   r%   r9      s2   



zLine.__init__)r\   )r:   r;   r<   r   r   r   rJ   rK   r3   r   r9   rN   r$   r$   rH   r%   rj      s    rj   c                       s.   e Zd Zdee deddf fddZ  ZS )PolyLiner   rC   r   Nc              
      s   t  jdi | t|dkrtdg }|D ]\}}|t| |t| q| tdtdtdt|tdt	t
|i d S )Nr   z7A polyline needs at least 1 vertex with two coordinatesrD   z	/PolyLine	/VerticesrE   r$   rG   r9   lenr0   appendr   rf   r   r	   r   r&   r6   r   rC   
coord_listr"   r#   rH   r$   r%   r9      s   zPolyLine.__init__)r:   r;   r<   listr   r   r9   rN   r$   r$   rH   r%   rn      s    rn   c                	       L   e Zd Zdddeeeeeeef f dee de	ddf fddZ
  ZS )		RectangleNinterior_colorrA   ry   rC   r   c             	      j   t  jd	i | | tdtdtdtdtdt|i |r3tdd t|D | td< d S d S )
N/Type/AnnotrD   z/SquarerE   c                 S   r^   r$   r_   r`   r$   r$   r%   rc     rd   z&Rectangle.__init__.<locals>.<listcomp>rm   r$   rG   r9   rf   r   r   r	   r   r6   rA   ry   rC   rH   r$   r%   r9     s   zRectangle.__init__r:   r;   r<   r   r   rJ   rK   r   r3   r   r9   rN   r$   r$   rH   r%   rw         rw   c                       sR   e Zd Zddddeeeeeeef f dedede	de
d	d
f fddZ  ZS )	Highlightff0000F)highlight_colorprintingrA   quad_pointsr   r   rC   r   Nc                   sj   t  jdi | | tdtdtdt|td|tdtdd t|D i |r3tj| _	d S d S )	NrD   z
/HighlightrE   z/QuadPointsre   c                 S   r^   r$   r_   r`   r$   r$   r%   rc   )  rd   z&Highlight.__init__.<locals>.<listcomp>r$   )
rG   r9   rf   r   r   r	   r   r   PRINTr@   )r6   rA   r   r   r   rC   rH   r$   r%   r9     s   	
zHighlight.__init__)r:   r;   r<   r   r   rJ   rK   r	   r3   rL   r   r9   rN   r$   r$   rH   r%   r     s     r   c                	       rv   )	EllipseNrx   rA   ry   rC   r   c             	      rz   )
Nr{   r|   rD   z/CirclerE   c                 S   r^   r$   r_   r`   r$   r$   r%   rc   E  rd   z$Ellipse.__init__.<locals>.<listcomp>rm   r$   r}   r~   rH   r$   r%   r9   2  s   zEllipse.__init__r   r$   r$   rH   r%   r   1  r   r   c                       s6   e Zd Zdeeeef  deddf fddZ  ZS )Polygonr   rC   r   Nc                    s   t  jdi | t|dkrtdg }|D ]\}}|t| |t| q| tdtdtdtdtdt|tdtd	td
t	t
|i d S )Nr   z6A polygon needs at least 1 vertex with two coordinatesr{   r|   rD   z/Polygonro   z/ITz/PolygonCloudrE   r$   rp   rs   rH   r$   r%   r9   J  s   zPolygon.__init__)	r:   r;   r<   ru   rJ   rK   r   r9   rN   r$   r$   rH   r%   r   I  s    r   ).sysr4   abcr   typingr   r   r   r   	constantsr   genericr	   r
   generic._baser   r   r   r   r   r   generic._rectangler   generic._utilsr   _baser   r   version_infor   typing_extensionsrJ   rK   r   __annotations__ru   r&   r'   r>   rO   rj   rn   rw   r   r   r   r$   r$   r$   r%   <module>   s0   
  ;@(