
    @wg6'                        U d dl Z d dlmZ d dl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 ddl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,y)%    N)ABC)AnyListOptionalTupleUnion   )deprecate_with_replacement)AnnotationFlag)ArrayObjectDictionaryObject)BooleanObjectFloatObject
NameObjectNumberObjectTextStringObject)RectangleObject)
hex_to_rgb   )NO_FLAGSAnnotationDictionary)   
   )	TypeAliasVertexverticesreturnc                     | d   d   | d   d   }}| d   d   | d   d   }}| D ]5  \  }}t        ||      }t        ||      }t        ||      }t        ||      }7 t        ||||f      }|S )Nr   r   )minmaxr   )r   x_miny_minx_maxy_maxxyrects           \/var/www/horilla/myenv/lib/python3.12/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8DK    c                   (    e Zd ZdZdddee   fdZy)MarkupAnnotationz
    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

    N)	title_barr-   c                8    |t        |      | t        d      <   y y )Nz/T)r   r   )selfr-   s     r(   __init__zMarkupAnnotation.__init__4   s!     %5i%@DD!" !r*   )__name__
__module____qualname____doc__r   strr0    r*   r(   r,   r,   *   s     6: AXc] Ar*   r,   c                   X     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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flagsr'   textr9   r:   kwargsc                
   t        |   di | t        d      | t        d      <   t        |      | t        d      <   t	        |      | t        d      <   t        |      | t        d      <   t        |      | t        d      <   y )Nz/Text/Subtype/Rect	/Contentsz/Openz/Flagsr6   )superr0   r   r   r   r   r   )r/   r'   r;   r9   r:   r<   	__class__s         r(   r0   zText.__init__F   sy     	"6"'1'':Z
#$$3D$9Z !(8(>Z$%$1$$7Z !%1%%8Z!"r*   )r1   r2   r3   r4   r   r   r   r   floatr5   boolintr   r0   __classcell__rB   s   @r(   r8   r8   9   sd    
" 9 OU5%+E%FFG9 	9
 9 9 9 9r*   r8   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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_colorr;   r'   rN   rO   rP   rQ   rR   rS   rT   r<   c       	            t        |   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}| j                  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        t	        |	      D cg c]  }t        |       c}      | t        d      <   y y c c}w )Nz	/FreeTextr>   r?   zfont: zitalic znormal zbold  z;text-align:left;color:# rgr@   z/DSz/DAz/Wr   z/BS/Cr6   )rA   r0   r   r   r   updater   r   r   r   r   )r/   r;   r'   rN   rO   rP   rQ   rR   rS   rT   r<   font_strdefault_appearance_stringstnrB   s                  r(   r0   zFreeText.__init__Z   s    	"6"'1+'>Z
#$$3D$9Z ! "7+H"7+H"5)H"7+HZ	{!D62Z7
|D$&! . P/H.I"Q,O)P+D*ER(H%:&
;(?7#_T%:;')9$)?5!#3H#=5!#34M#N		
 &6 t$l1o'DE"# '%0)34D)EFAQF&DD!" (Fs   E()r1   r2   r3   r4   r5   r   r   r   rC   rD   r   r   r0   rF   rG   s   @r(   rI   rI   W   s      "&.*2: : OU5%+E%FFG	:
 : : : : : sm: #3-: : :r*   rI   c                   P     e Zd Z	 ddededeeeeeeef   f   dede	f
 fdZ
 xZS )Linep1p2r'   r;   r<   c                    t        |   di | | j                  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       y )Nr>   z/Liner?   z/Lr   r   z/LEz/None/ICg      ?r@   r6   )rA   r0   rZ   r   r   r   r   r   )r/   ra   rb   r'   r;   r<   rB   s         r(   r0   zLine.__init__   s     	"6":&
7(;7#_T%:4 +#BqE*#BqE*#BqE*#BqE*	# 5!;"7+"7+$ 5!;#C(#C(#C($ ;')9$)?1	
r*   )rW   )r1   r2   r3   r   r   r   r   rC   r5   r   r0   rF   rG   s   @r(   r`   r`      sZ     $
$
 $
 OU5%+E%FFG	$

 $
 $
 $
r*   r`   c                   .     e Zd Zdee   def fdZ xZS )PolyLiner   r<   c                    t        |   di | t        |      dk(  rt        d      g }|D ]9  \  }}|j	                  t        |             |j	                  t        |             ; | j                  t        d      t        d      t        d      t        |      t        d      t        t        |            i       y )Nr   6A polygon needs at least 1 vertex with two coordinatesr>   z	/PolyLine	/Verticesr?   r6   rA   r0   len
ValueErrorappendr   rZ   r   r   r   r)   r/   r   r<   
coord_listr%   r&   rB   s         r(   r0   zPolyLine.__init__   s    
 	"6"x=AUVV
 	/DAql1o.l1o.	/ 	:&
;(?;'Z)@7#_5LX5V%W	
r*   )r1   r2   r3   r   r   r   r0   rF   rG   s   @r(   rf   rf      s#    
v,
 
 
r*   rf   c            	       P     e Zd Zdddeeeeeeef   f   dee   de	f fdZ
 xZS )	RectangleNinterior_colorr'   rs   r<   c          
      n   d|v rt        ddd       |d   }|d= t        |   d
i | | j                  t	        d      t	        d      t	        d      t	        d      t	        d      t        |      i       |r8t        t        |      D cg c]  }t        |       c}      | t	        d	      <   y y c c}w )Ninteriour_colorrs   6.0.0/Type/Annotr>   z/Squarer?   rd   r6   	r
   rA   r0   rZ   r   r   r   r   r   r/   r'   rs   r<   r^   rB   s        r(   r0   zRectangle.__init__   s     &&'8:JGT#$56N()"6"7#Z%9:&
9(=7#_T%:	
 &1)3N)CDAQD'DE"# D   B2r1   r2   r3   r   r   r   rC   r   r5   r   r0   rF   rG   s   @r(   rq   rq      sJ    
 )-	OU5%+E%FFG !	
  r*   rq   c                   T     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
f
 fd	Z xZS )
	Highlightff0000F)highlight_colorprintingr'   quad_pointsr   r   r<   c                N   t        |   di | | j                  t        d      t        d      t        d      t	        |      t        d      |t        d      t        t        |      D cg c]  }t        |       c}      i       |rt        j                  | _
        y y c c}w )Nr>   z
/Highlightr?   z/QuadPointsrY   r6   )rA   r0   rZ   r   r   r   r   r   r   PRINTr:   )r/   r'   r   r   r   r<   r^   rB   s          r(   r0   zHighlight.__init__   s     	"6":&
<(@7#_T%:=);4 +-7-HI[^I#			
 '--DJ 	 Js   +B")r1   r2   r3   r   r   r   rC   r   r5   rD   r   r0   rF   rG   s   @r(   r~   r~      s_      (. OU5%+E%FFG. !	.
 . . . .r*   r~   c            	       P     e Zd Zdddeeeeeeef   f   dee   de	f fdZ
 xZS )EllipseNrr   r'   rs   r<   c          
      n   d|v rt        ddd       |d   }|d= t        |   d
i | | j                  t	        d      t	        d      t	        d      t	        d      t	        d      t        |      i       |r8t        t        |      D cg c]  }t        |       c}      | t	        d	      <   y y c c}w )Nru   rs   rv   rw   rx   r>   z/Circler?   rd   r6   ry   rz   s        r(   r0   zEllipse.__init__
  s     &&'8:JGT#$56N()"6"7#Z%9:&
9(=7#_T%:	
 &1)3N)CDAQD'DE"# Dr{   r|   rG   s   @r(   r   r   	  sJ    
 )-	OU5%+E%FFG !	
  r*   r   c                   8     e Zd Zdeeeef      def fdZ xZS )Polygonr   r<   c                    t        |   di | t        |      dk(  rt        d      g }|D ]9  \  }}|j	                  t        |             |j	                  t        |             ; | j                  t        d      t        d      t        d      t        d      t        d      t        |      t        d      t        d	      t        d
      t        t        |            i       y )Nr   rh   rw   rx   r>   z/Polygonri   z/ITz/PolygonCloudr?   r6   rj   rn   s         r(   r0   zPolygon.__init__&  s    
 	"6"x=AUVV
 	/DAql1o.l1o.	/ 	7#Z%9:&
:(>;'Z)@5!:o#>7#_5LX5V%W	
r*   )	r1   r2   r3   r   r   rC   r   r0   rF   rG   s   @r(   r   r   %  s-    
uUE\*+
 
 
r*   r   )-sysabcr   typingr   r   r   r   r   _utilsr
   	constantsr   genericr   r   generic._baser   r   r   r   r   generic._rectangler   generic._utilsr   _baser   r   version_infor   typing_extensionsrC   r   __annotations__r)   r,   r8   rI   r`   rf   rq   r~   r   r   r6   r*   r(   <module>r      s    
  4 4 / & 3  1 ' 1BQ7"  , %,'	 '	d6l 	 	A+S A9 9<= =@%
 %
P
 
,  6.  .2 8
 
r*   