
    ,hf                     l    d dl mZ d dlZd dlmZmZmZmZmZ d Z	 ed      Z
 ed      Zd Zd Zd	 Zy)
    )unicode_literalsN)binary_type	text_typebyte2int	iterbytesunichrc                 N   t        | t              s| S g g fd}| D ]j  }dt        |      cxk  rdk  rCn n@ |       |dk(  rj                  d       9j                  |j	                  d             Zj                  |       l  |       dj                        S )zEncode a folder name using IMAP modified UTF-7 encoding.

    Input is unicode; output is bytes (Python 3) or str (Python 2). If
    non-unicode input is provided, the input is returned unchanged.
    c                 P    r#j                  dt        |       dg       | dd= yy)z
        Consume the buffer by encoding it into a modified base 64 representation
        and surround it with shift characters & and -
           &   -N)extendbase64_utf7_encode)buf
b64_bufferress    V/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/imapclient/imap_utf7.pyconsume_b64_bufferz"encode.<locals>.consume_b64_buffer   s-    
 JJ05t<=A         ~   &s   &-asciir   )
isinstancer   ordappendencodejoin)sr   cr   r   s      @@r   r   r      s     a#
CJ  !3q6!T!z*Cx

5!

188G,-
 a !  z"88C=r   r   r   c                    t        | t              s| S g }t               }t        |       D ]  }|t        k(  r|s|j                  |        |t        k(  rJ|rHt        |      dk(  r|j                  d       n|j                  t        |dd              t               }s|r|j                  |       |j                  t        |              |r|j                  t        |dd              dj                  |      S )zDecode a folder name from IMAP modified UTF-7 encoding to unicode.

    Input is bytes (Python 3) or str (Python 2); output is always
    unicode. If non-bytes/str input is provided, the input is returned
    unchanged.
       r   N )r   r   	bytearrayr   AMPERSAND_ORDr   DASH_ORDlenbase64_utf7_decoder   r   )r   r   r   r   s       r   decoder(   <   s     a%
CJq\ "ja (]z:!#

3

-jn=>"Ja  JJvay!#"( 

%jn56773<r   c                     dj                  |       j                  d      }t        j                  |      j	                  d      j                  dd      S )Nr"   zutf-16bes   
=   /   ,)r   r   binascii
b2a_base64rstripreplace)bufferr   s     r   r   r   c   sC    
z*Aq!((088tDDr   c                 T    d| j                  dd      z   dz   }|j                  d      S )N   +r+   r*   r   zutf-7)r/   r(   )r   s_utf7s     r   r'   r'   h   s+    AIIdD))D0F==!!r   )
__future__r   r,   sixr   r   r   r   r   r   r$   r%   r(   r   r'    r   r   <module>r7      s>    (  C C&R D>$NE
"r   