
    	hN              	          d Z ddlZddlZddlZddlZddlZddlZddlZddl	Zddl
Z
ddlZddlmZmZmZmZ dZdZ ej        d          Z ej        d          Zej                            d          Zd	ed
efdZd	ed
efdZdeeef         d
efdZddddeej        j        ej        j        f         de ded
e!fdZ"deeej#        j$        ej%        j&        f         d
ee         fdZ'deej        j        ej        j        f         d
ee         fdZ(deej        j        ej        j        f         d
ee         fdZ)dS )z9
Email message and address formatting/parsing functions.
    N)ListOptionalTupleUnion)extract_recipientsextract_senderflatten_messageparse_addressquote_addressz
z[][\\()<>@,:;".]z[\\"]zutf-8addressreturnc                 r    t           j                            |           \  }}|p|                                 S )zG
    Parse an email address, falling back to the raw string given.
    )emailutils	parseaddrstrip)r   display_nameparsed_addresss      ]/var/www/html/web-builder-api.evdpl.com/venv/lib/python3.11/site-packages/aiosmtplib/email.pyr
   r
       s1     $);#8#8#A#A L.,W]]__,    c                 ,    t          |           }d| dS )zC
    Quote a subset of the email addresses defined by RFC 821.
    <>)r
   )r   r   s     r   r   r   )   s"     #7++N ~    r   pairc                     | \  }}|r"t                               |          }| d| dS d}t                              |          r)d}t                              d|          }| | | d| dS |S )a}  
    Copied from the standard library, and modified to handle international (UTF-8)
    email addresses.

    The inverse of parseaddr(), this takes a 2-tuple of the form
    (realname, email_address) and returns the string value suitable
    for an RFC 2822 From, To or Cc header.
    If the first element of pair is false, then the second element is
    returned unmodified.
    z <r    "z\\\g<0>)UTF8_CHARSETheader_encodeSPECIALS_REGEXsearchESCAPES_REGEXsub)r   namer   encoded_namequotess        r   
formataddrr'   1   s     MD' 9#11$77,,',,,,  && 	9F $$Z66D8d8F88g8888Nr   F8bit)utf8cte_typemessager)   r*   c                  t          j         |           }|d= |d= t          | t          j        j                  r-t          j        j                            t          ||          }n+t          j        j	                            t          |          }t          j                    5 }t          j                            ||          }|                    |           |                                }d d d            n# 1 swxY w Y   |S )NBcc
Resent-Bcc)linesepr)   r*   )r/   r*   )policy)copy
isinstancer   r+   EmailMessager0   defaultcloneLINE_SEPcompat32ioBytesIO	generatorBytesGeneratorflattengetvalue)r+   r)   r*   message_copyr0   	messageior:   flat_messages           r   r	   r	   J   s)    9W%%LU\"'5=566 
R%++ , 
 
 &,,X,QQ	 ,O229V2LL	,''' ))++, , , , , , , , , , , , , , ,
 s   %AC<<D D headerc          	         g }t          | t          j        j                  rg| j        D ]^}t          |t          j        j                  r|                    |j                   <|                    t          |                     _nt          | t          j	        j
                  r[t          j	                            |           D ]:\  }}|d}|                    t          t          ||                               ;n=|                    d t          j                            | g          D                        |S )zl
    Convert address headers into raw email addresses, suitable for use in
    low level SMTP commands.
    Nascii)encodingc              3       K   | ]	\  }}|V  
d S )N ).0_addrs      r   	<genexpr>z$extract_addresses.<locals>.<genexpr>   s&      PP'!TPPPPPPr   )r2   r   headerregistryAddressHeader	addressesAddressappend	addr_specr
   rA   Headerdecode_headerstrextendr   getaddresses)rA   rM   r   address_bytescharsets        r   extract_addressesrX   j   sE    I&%.<== Q' 	9 	9G '5#7#?@@ 9  !23333  w!7!78888	9 
FEL/	0	0 Q&+l&@&@&H&H 	R 	R"M7!]3}w+O+O+OPPQQQQ	R
 	PPU[-E-Evh-O-OPPPPPPr   c                    |                      d          }|"t          |          dk    rt          d          |rd}d}nd}d}|| v r	| |         }n| |         }|dS t          |          d	         S )
z;
    Extract the sender from the message object given.
    Resent-DateN   0Message has more than one 'Resent-' header blockzResent-SenderzResent-FromSenderFromr   )get_alllen
ValueErrorrX   )r+   resent_datessender_header_namefrom_header_namesender_headers        r   r   r      s     ??=11LC$5$5$9$9KLLL	 ",(%! W$$ 23 01t]++A..r   c                   g }|                      d          }|"t          |          dk    rt          d          |rd}nd}|D ]>}|                      |g           D ]$}|                    t	          |                     %?|S )z?
    Extract the recipients from the message object given.
    rZ   Nr[   r\   )z	Resent-Toz	Resent-Ccr.   )ToCcr-   )failobj)r_   r`   ra   rT   rX   )r+   
recipientsrb   recipient_headersrA   	recipients         r   r   r      s     J??=11LC$5$5$9$9KLLL	 0D/# < < << 	< 	<I/	::;;;;	< r   )*__doc__r1   email.charsetr   email.generatoremail.headeremail.headerregistryemail.messageemail.policyemail.utilsr8   retypingr   r   r   r   __all__r6   compiler    r"   rW   Charsetr   rS   r
   r   r'   r+   r3   Messageboolbytesr	   rK   rL   rA   rQ   rX   r   r   rF   r   r   <module>r}      s                                 				 				 / / / / / / / / / / / / /00
8$$}$$W---3 -3 - - - -!3 !3 ! ! ! !U38_     :   5=-u}/DDE 	
     @#u+95<;NNO 
#Y   8/5=-u}/DDE/ c]/ / / /<5=-u}/DDE 
#Y     r   