
    F j)                        S r SSKrSSKJr  SSKJr  SSKJrJrJ	r	J
r
JrJrJrJrJr  \(       a  SSKJr  SSKJr  \\\\	S	\S4   r\\\	S	\4r\S
S	\\	\S4   r\" SS
S9r\\\\R:                  4   r\\\R:                  4r\" S\\5      r  " S S\5      r!S\"S\S\S\"4S jr#\S\S\4S j5       r$\S\S\4S j5       r$S\ S\ 4S jr$S\\\4   S\4S jr%S\\
\   -  S\\\4   S\\\4   S\\\&\S4   4   4S jr'S \S\4S! jr(S"r)S#\S\4S$ jr*S#\S\4S% jr+S\4S& jr,S.S'\S(\S\4S) jjr-S*\\\\-  \&\\4   -     -  S\.\   4S+ jr/ " S, S-5      r0g)/a  
Various utilities that could not be gathered logically in a specific module.

The contents of this module are internal to fpdf2, and not part of the public API.
They may change at any time without prior warning or any deprecation period,
in non-backward-compatible ways.
    N)	resources)Path)	TYPE_CHECKINGAnyBinaryIOIterable
NamedTupleSequenceTypeVarUnionoverload)Image   )	SVGObjectPILImager   SVGObjectType)bound	_StrBytesc                   |    \ rS rSr% Sr\\S'   Sr\\S'   Sr\\S'   Sr	\\S'   \
S\\\\   S 4   SS 4S	 j5       rS
rg)Padding(   r   toprightbottomleftpaddingreturnc           	         [        U[        5      (       a2  [        [        U5      [        U5      [        U5      [        U5      5      $ [	        U5      S:X  a>  [        [        US   5      [        US   5      [        US   5      [        US   5      5      $ [	        U5      S:X  a>  [        [        US   5      [        US   5      [        US   5      [        US   5      5      $ [	        U5      S:X  a>  [        [        US   5      [        US   5      [        US   5      [        US   5      5      $ [        S[        U5       35      e)zbReturn a 4-tuple of padding values from a single value or a 2, 3 or 4-tuple according to CSS rules   r   r         zBpadding shall be a number or a sequence of 2, 3 or 4 numbers, got )
isinstanceNumberClassr   floatlen
ValueErrorstr)clsr   s     Z/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/fpdf/util.pynewPadding.new.   s9    g{++gggg  w<1gaj!gaj!gaj!gaj!	  w<1gaj!gaj!gaj!gaj!	  w<1gaj!gaj!gaj!gaj!	  PQTU\Q]P^_
 	
     N)__name__
__module____qualname____firstlineno__r   r$   __annotations__r   r   r   classmethodr   Numberr
   r*   __static_attributes__r-   r,   r)   r   r   (   sY    CNE5FED%O
%(8) CD 
 
 
r,   r   bufferplaceholdervaluer   c                     [        U 5      n[        U5      [        U5      :X  d   SU SU 35       eU R                  UR                  5       UR                  5       S5      n [        U 5      U:X  d   eU $ )Nzplaceholder=z value=r   )r%   replaceencode)r6   r7   r8   buffer_sizes       r)   buffer_substr=   P   sl    f+K{s5z)U\+geW+UU)^^K..0%,,.!DFv;+%%%Mr,   sc                     g Nr-   r>   s    r)   escape_parensrB   X   s    "%r,   c                     g r@   r-   rA   s    r)   rB   rB   \   s    &)r,   c                 4   [        U [        5      (       aB  U R                  SS5      R                  SS5      R                  SS5      R                  SS5      $ U R                  S	S
5      R                  SS5      R                  SS5      R                  SS5      $ )z*Add a backslash character before , ( and )\z\\)z\)(z\(z\r   \s   \\   )s   \)   (s   \(   s   \r)r"   r'   r:   rA   s    r)   rB   rB   `   s    !SIIdF#WS% WS% WT5!		
 	
		%!	v		v				r,   unitc                     [        U [        5      (       a  [        U 5      $ U S:X  a  gU S:X  a  gU S:X  a  gU S:X  a  g[        S	U  35      e)
z
Get how many pts are in a unit. (k)

Args:
    unit (str, float, int): Any of "pt", "mm", "cm", "in", or a number.
Returns:
    float: The number of points in that unit (assuming 72dpi)
Raises:
    ValueError
ptr   mmgjZ@cmgbX<@ing      R@zIncorrect unit: )r"   r#   r$   r&   )rM   s    r)   get_scale_factorrS   q   sV     $$$T{t|t|t|t|
'v.
//r,   
to_convertold_unitnew_unit.c                    ^ [        U5      [        U5      -  m[        U [        5      (       a  [        U4S jU  5       5      $ [	        U 5      T-  $ )a  
 Convert a number or sequence of numbers from one unit to another.

 If either unit is a number it will be treated as the number of points per unit.  So 72 would mean 1 inch.

 Args:
    to_convert (float, int, Iterable): The number / list of numbers, or points, to convert
    old_unit (str, float, int): A unit accepted by `fpdf.fpdf.FPDF` or a number
    new_unit (str, float, int): A unit accepted by `fpdf.fpdf.FPDF` or a number
Returns:
    (float, tuple): to_convert converted from old_unit to new_unit or a tuple of the same
c              3   >   >#    U  H  n[        US T5      v   M     g7f)r   N)convert_unit).0iunit_conversion_factors     r)   	<genexpr>convert_unit.<locals>.<genexpr>   s     TA\!Q(>??s   )rS   r"   r   tupler$   )rT   rU   rV   r\   s      @r)   rY   rY      sJ    " .h7:J8:TT*h''TTTT555r,   numberc                 F    U S R                  S5      R                  S5      $ )z
Convert a decimal number to a minimal string representation (no trailing 0 or .).

Args:
    number (Number): the number to be converted to a string.

Returns:
    The number's string representation.
z.4f0.)rstrip)r`   s    r)   number_to_strre      s$     S\!!#&--c22r,   ))Mi  )CMi  )Di  )CDi  )Cd   )XCZ   )L2   )XLr   )X
   )IX	   )V   )IVr!   )Ir   nc                 ^    SnU c  U$ [          H  u  p#X:  d  M  X-  nX-  n X:  a  M  M     U$ )z#Convert an integer to Roman numeral )ROMAN_NUMERAL_MAP)ry   resultnumeralintegers       r)   	int2romanr      s@    Fy-lFLA l . Mr,   c                     U S:  a)  [        [        U S-  S-
  5      5      [        U S-  5      -   $ [        U [        S5      -   5      $ )zXConvert an integer to a letter value (A to Z for the first 26, then AA to ZZ, and so on)      r   A)int_to_lettersintchrord)ry   s    r)   r   r      sB    2vc1r6Q,/0>!b&3IIIq3s8|r,   c                  T    Sn [         R                  " U 5      S-  R                  5       $ )Nzfpdf.data.color_profileszsRGB2014.icc)r   files
read_bytes)pkgs    r)   builtin_srgb2014_bytesr      s$    
$COOC >1==??r,   xdigitsc                    [        U 5      S:  a  Sn U SU S3 nSU;   a   UR                  S5      R                  S5      nUS:X  a  SnUR                  S5      (       a  SU-   nUR                  S5      (       a  UR                  SSS	5      nU$ )
Ng-q=g        rc   frb   z-0z-.z-0.r   )absrd   
startswithr:   )r   r   r>   s      r)   format_numberr      s    
1v~QvhaK.A
axHHSM  %Dy||C!G||DIIdE1%Hr,   unicode_rangec           	         U b  [        U 5      S:X  a  [        S5      e[        5       n[        U [        5      (       a.  U R                  S5       Vs/ s H  o"R                  5       PM     n nU  GH  n[        U[        5      (       a  [        U5      S:w  a  [        SU 35      eUu  p4[        U[        5      (       a,  [        UR                  SS5      R                  SS5      S	5      n[        U[        5      (       a,  [        UR                  SS5      R                  SS5      S	5      nX4:  a  [        S
U SU S35      eUR                  [        X4S-   5      5        M  [        U[        5      (       Ga!  UR                  5       R                  SS5      nSU;   a  UR                  S5      (       d  UR                  S5      n[        U5      S:w  a  [        SU 35      e[        US   R                  SS5      S	5      n[        US   R                  SS5      S	5      nX4:  a$  [        S
[        U5       S[        U5       S35      eUR                  [        X4S-   5      5        GM  [        UR                  SS5      S	5      nUR                  U5        GM)  [        U[        5      (       a)  US:  a  [        SU S35      eUR                  U5        GMg  [        S[        U5      R                    35      e   U$ s  snf )a  
Parse unicode_range parameter into a set of codepoints.

Supports CSS-style formats:

- String with comma-separated ranges: "U+1F600-1F64F, U+2600-26FF, U+2615"
- List of strings: ["U+1F600-1F64F", "U+2600", "U+26FF"]
- List of tuples: [(0x1F600, 0x1F64F), (0x2600, 0x26FF)]
- List of integers: [0x1F600, 0x2600, 128512]
- Mixed formats: [(0x1F600, 0x1F64F), "U+2600", 128512]

Returns a set of integer codepoints.
r   zunicode_range cannot be empty,r   z$Tuple must have exactly 2 elements: zU+r{   zu+   zInvalid range: start (z	) > end (rF   r   -zInvalid range format: zInvalid codepoint: z (must be non-negative)z%Unsupported unicode_range item type: )r%   r&   setr"   r'   splitstripr_   r   r:   updateranger   hexaddtyper.   )r   
codepointsitemstartenditem_strippedparts	codepoints           r)   get_parsed_unicode_ranger      s      S%71%<8995J-%%2?2E2Ec2JK2J$2JKdE""4yA~ #Gv!NOOJE%%%EMM$3;;D"ErJ#s###++dB/77bA2F{ #9%	#a!PQQeE734c"" JJL00t<Mm#M,D,DS,I,I%++C0u:?$'=m_%MNNE!H,,T26;%(**44b9;$0UIc#hZqQ  !!%Qw"78 5 5dB ?D	y)c""ax #6tf<S!TUUNN4  7T
8K8K7LM W ^ c Ls   K9c                       \ rS rSrSrSr\S\S\S\4S j5       r	\S\S\S\4S j5       r
\S\S\4S	 j5       r\S\S\S\4S
 j5       r\S\S\S\4S j5       r\S\S\S\4S j5       r\S\S\S\4S j5       rSrg)FloatTolerancei3  z?Utility class for floating point math with a defined tolerance.g&.>abr   c                 6    [        X-
  5      U R                  :*  $ )zBCheck if two floats are almost equal within the defined tolerance.r   	TOLERANCEr(   r   r   s      r)   equalFloatTolerance.equal8  s     15zS]]**r,   c                 .    U R                  X5      (       + $ )zFCheck if two floats are not almost equal within the defined tolerance.)r   r   s      r)   	not_equalFloatTolerance.not_equal=  s     99Q?""r,   c                 2    [        U5      U R                  :*  $ )z=Check if a float is almost zero within the defined tolerance.r   )r(   r   s     r)   is_zeroFloatTolerance.is_zeroB  s     1v&&r,   c                 $    X!-
  U R                   :  $ )z<Check if a is less than b considering the defined tolerance.r   r   s      r)   	less_thanFloatTolerance.less_thanG       &&r,   c                 $    X-
  U R                   :  $ )z?Check if a is greater than b considering the defined tolerance.r   r   s      r)   greater_thanFloatTolerance.greater_thanL  r   r,   c                 T    U R                  X5      =(       d    U R                  X5      $ )zOCheck if a is less than or almost equal to b considering the defined tolerance.)r   r   r   s      r)   
less_equalFloatTolerance.less_equalQ  s      }}Q"5ciio5r,   c                 T    U R                  X5      =(       d    U R                  X5      $ )zRCheck if a is greater than or almost equal to b considering the defined tolerance.)r   r   r   s      r)   greater_equalFloatTolerance.greater_equalV  s"     %818r,   r-   N)r.   r/   r0   r1   __doc__r   r3   r$   boolr   r   r   r   r   r   r   r5   r-   r,   r)   r   r   3  s    II+e + +$ + + #% #E #d # # ' '$ ' ' '% 'E 'd ' ' 'U 'u ' ' ' 65 6U 6t 6 6 9e 9 9$ 9 9r,   r   )   )1r   decimal	importlibr   pathlibr   typingr   r   r   r   r	   r
   r   r   r   	PIL.Imager   r   svgr   r'   bytes	ImageType
ImageClass	ImageDatar   r   r$   Decimalr4   r#   r   r   	bytearrayr=   rB   rS   r_   rY   re   r|   r   r   r   r   r   r   r   r-   r,   r)   <module>r      s@      
 
 
 +#uh
D$>?	5(J5
+z5(D$FG	{;	sE7??*	+E7??+Ke,	%
j %
P  S Y  
 %S %S % 
 % 
 )U )u ) 
 )Y 9 "05f- 0% 026#&6CK 6 CK 6 5%S/!"	6.3& 3S 3 "	 	 	c c @ @
U C   G#)eCHo"=>>GXGT&9 &9r,   