
    є jV.                        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Z$ G d dee          Z% G d de%          Z& G d de%          Z' G d de%          Z( G d de%          Z) G d de%          Z* G d de%          Z+ G d  d!e%          Z, G 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                 (   | d         d         | d         d         }}| d         d         | d         d         }}| D ]E\  }}t          ||          }t          ||          }t          ||          }t          ||          }Ft          ||||f          S )Nr   r   )minmaxr   )r   x_miny_minx_maxy_maxxys          yC:\Users\Terasoftware\OneDrive\Desktop\faahhh\fyndo\fyndo\venv\Lib\site-packages\pypdf/annotations/_markup_annotations.py_get_bounding_rectangler'      s    A;q>8A;q>5EA;q>8A;q>5E  1E1E1E1E1E5%7888    c                   z    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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                ,   |t          |          | t          d          <   ||t          d          |dk    r|t          d          |t          |t                    r|}n7t          |dd           }t          |t                    st          d          |}|| t          d          <   t          d|           | t          d	          <   | t          t          j                              }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_refs          r&   __init__zMarkupAnnotation.__init__A   sY     	A%5i%@%@DD!!" 	; 	K    	 	G    	H+~66 	#&1&{4H$OO!,?? $D   #'*DF##$&01AZ1A1A&B&BDE""# 4"%djll"3"3&6&G&GDE""###	H 	Hr(   )__name__
__module____qualname____doc__r   r7   r   r   r   r   r=    r(   r&   r*   r*   *   s         2 $(IM,/)-!H !H !H C=!H e$4n$DEF	!H
 L)!H "#!H 
!H !H !H !H !H !Hr(   r*   c                   h     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Z x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textrE   rF   kwargsr   Nc                p    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/FlagsrB   )superr=   r   r   r   r   r   )r:   rG   rH   rE   rF   rI   	__class__s         r&   r=   zText.__init__r   s     	""6"""'1'':':Z
##$$3D$9$9Z  !(8(>(>Z$$%$1$$7$7Z  !%1%%8%8Z!!"""r(   )r>   r?   r@   rA   r   r   r   tuplefloatr7   boolintr   r=   __classcell__rO   s   @r&   rD   rD   e   s        
 
" 9 9 9 OU5%+E%FFG9 	9
 9 9 9 
9 9 9 9 9 9 9 9 9 9r(   rD   c                        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Z xZS )FreeTextzA FreeText annotation	HelveticaF14pt000000ffffff)fontbolditalic	font_size
font_colorborder_colorbackground_colorrH   rG   r\   r]   r^   r_   r`   ra   rb   rI   r   Nc       	             t                      j        di |
 t          d          | t          d          <   t          |          | t          d          <   d}|r| d}n| d}|r| d}n| d}| | d| }| d	| }d
}|rt	          |          D ]	}| | d}
| d}|                     t          d          t          d          t          d          t          |          t          d          t          |          t          d          t          |          t          d          t          |          i           |;t          t          d          t          d          i          | t          d          <   |	8t          d t	          |	          D                       | t          d          <   d S d S )Nz	/FreeTextrK   rL   zfont: zitalic znormal zbold  z;text-align:left;color:# rgrM   z/DSz/DAz/Wr   z/BSc                 ,    g | ]}t          |          S rB   r   .0ns     r&   
<listcomp>z%FreeText.__init__.<locals>.<listcomp>   s    FFFAQFFFr(   /CrB   )
rN   r=   r   r   r   updater   r   r   r
   )r:   rH   rG   r\   r]   r^   r_   r`   ra   rb   rI   font_strdefault_appearance_stringstrO   s                 r&   r=   zFreeText.__init__   s:    	""6"""'1+'>'>Z
##$$3D$9$9Z  !  	,"+++HH"+++H 	,")))HH"+++H2	22D22DD
DD$&! 	I .. P P/H,O",O,O,O))+D(H(H(H%:&&
;(?(?7##_T%:%:;'')9$)?)?5!!#3H#=#=5!!#34M#N#N		
 		
 		
  	&6 t$$l1oo' 'DE""#  	%0FF4D)E)EFFF& &DD!!"""	 	r(   )r>   r?   r@   rA   r7   r   r   rP   rQ   rR   r   r   r=   rT   rU   s   @r&   rW   rW      s          "&.*2: : : : OU5%+E%FFG	:
 : : : : : sm: #3-: : 
: : : : : : : : : :r(   rW   c                   `     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	Z
 xZS )Linere   p1p2rG   rH   rI   r   Nc                     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 )NrK   z/LinerL   z/Lr   r   z/LEz/None/ICg      ?rM   rB   )rN   r=   rn   r   r   r
   r   r   )r:   rt   ru   rG   rH   rI   rO   s         r&   r=   zLine.__init__   sT    	""6""":&&
7(;(;7##_T%:%:4  +#BqE**#BqE**#BqE**#BqE**	# # 5!!;"7++"7++$ $ 5!!;#C((#C((#C(($ $ ;'')9$)?)?1	
 	
 	
 	
 	
r(   )re   )r>   r?   r@   r   r   r   rP   rQ   r7   r   r=   rT   rU   s   @r&   rs   rs      s         $
 $
$
 $
 OU5%+E%FFG	$

 $
 $
 
$
 $
 $
 $
 $
 $
 $
 $
 $
 $
r(   rs   c                   8     e Zd Zdee         deddf fdZ xZS )PolyLiner   rI   r   Nc                     t                      j        di | t          |          dk    rt          d          g }|D ]I\  }}|                    t          |                     |                    t          |                     J|                     t          d          t          d          t          d          t          |          t          d          t          t          |                    i           d S )Nr   z7A polyline needs at least 1 vertex with two coordinatesrK   z	/PolyLine	/VerticesrL   rB   rN   r=   lenr4   appendr   rn   r   r
   r   r'   r:   r   rI   
coord_listr$   r%   rO   s         r&   r=   zPolyLine.__init__   s   
 	""6"""x==A 	XVWWW
 	/ 	/DAql1oo...l1oo....:&&
;(?(?;''Z)@)@7##_5LX5V5V%W%W	
 	
 	
 	
 	
r(   )r>   r?   r@   listr   r   r=   rT   rU   s   @r&   ry   ry      s]        
v,
 
 
	
 
 
 
 
 
 
 
 
 
r(   ry   c            	       f     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Z
 xZS )	RectangleNinterior_colorrG   r   rI   r   c          
          t                      j        di | |                     t          d          t          d          t          d          t          d          t          d          t	          |          i           |r8t          d t          |          D                       | t          d          <   d S d S )	N/Type/AnnotrK   z/SquarerL   c                 ,    g | ]}t          |          S rB   rh   ri   s     r&   rl   z&Rectangle.__init__.<locals>.<listcomp>      DDDAQDDDr(   rw   rB   rN   r=   rn   r   r   r
   r   r:   rG   r   rI   rO   s       r&   r=   zRectangle.__init__  s     	""6"""7##Z%9%9:&&
9(=(=7##_T%:%:	
 	
 	
  	&1DDN)C)CDDD' 'DE""###	 	r(   r>   r?   r@   r   r   rP   rQ   r   r7   r   r=   rT   rU   s   @r&   r   r     s        
 )-	  OU5%+E%FFG !	
  
         r(   r   c                   d     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Z xZS )	Highlightff0000F)highlight_colorprintingrG   quad_pointsr   r   rI   r   Nc                    t                      j        di | |                     t          d          t          d          t          d          t	          |          t          d          |t          d          t          d t          |          D                       i           |rt          j        | _	        d S d S )NrK   z
/HighlightrL   z/QuadPointsrm   c                 ,    g | ]}t          |          S rB   rh   ri   s     r&   rl   z&Highlight.__init__.<locals>.<listcomp>)  s    III[^^IIIr(   rB   )
rN   r=   rn   r   r   r
   r   r	   PRINTrF   )r:   rG   r   r   r   rI   rO   s         r&   r=   zHighlight.__init__  s     	""6""":&&
<(@(@7##_T%:%:=));4  +IIZ-H-HIII# #			
 		
 		
  	.'-DJJJ	. 	.r(   )r>   r?   r@   r   r   rP   rQ   r
   r7   rR   r   r=   rT   rU   s   @r&   r   r     s          (. . . OU5%+E%FFG. !	.
 . . . 
. . . . . . . . . .r(   r   c            	       f     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Z
 xZS )EllipseNr   rG   r   rI   r   c          
          t                      j        di | |                     t          d          t          d          t          d          t          d          t          d          t	          |          i           |r8t          d t          |          D                       | t          d          <   d S d S )	Nr   r   rK   z/CirclerL   c                 ,    g | ]}t          |          S rB   rh   ri   s     r&   rl   z$Ellipse.__init__.<locals>.<listcomp>E  r   r(   rw   rB   r   r   s       r&   r=   zEllipse.__init__2  s     	""6"""7##Z%9%9:&&
9(=(=7##_T%:%:	
 	
 	
  	&1DDN)C)CDDD' 'DE""###	 	r(   r   rU   s   @r&   r   r   1  s        
 )-	  OU5%+E%FFG !	
  
         r(   r   c                   H     e Zd Zdeeeef                  deddf fdZ xZS )Polygonr   rI   r   Nc                 v    t                      j        di | t          |          dk    rt          d          g }|D ]I\  }}|                    t          |                     |                    t          |                     J|                     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   rK   z/Polygonr{   z/ITz/PolygonCloudrL   rB   r|   r   s         r&   r=   zPolygon.__init__J  s+   
 	""6"""x==A 	WUVVV
 	/ 	/DAql1oo...l1oo....7##Z%9%9:&&
:(>(>;''Z)@)@5!!:o#>#>7##_5LX5V5V%W%W	
 	
 	
 	
 	
r(   )	r>   r?   r@   r   rP   rQ   r   r=   rT   rU   s   @r&   r   r   I  sg        
uUE\*+
 
 
	
 
 
 
 
 
 
 
 
 
r(   r   ).sysr8   abcr   typingr   r   r   r   	constantsr	   genericr
   r   generic._baser   r   r   r   r   r   generic._rectangler   generic._utilsr   _baser   r   version_infor   typing_extensionsrP   rQ   r   __annotations__r   r'   r*   rD   rW   rs   ry   r   r   r   r   rB   r(   r&   <module>r      s$   




        0 0 0 0 0 0 0 0 0 0 0 0 & & & & & & 3 3 3 3 3 3 3 3                1 0 0 0 0 0 ' ' ' ' ' ' 1 1 1 1 1 1 1 1BQB7" ,        ,+++++ %,'	 ' ' '9d6l 9 9 9 9 98H 8H 8H 8H 8H+S 8H 8H 8Hv9 9 9 9 9 9 9 9<= = = = = = = =@%
 %
 %
 %
 %
 %
 %
 %
P
 
 
 
 
 
 
 
,        .. . . . .  . . .2       0
 
 
 
 
 
 
 
 
 
r(   