
    `i                        d dl mZ d dlmZ d dlmZ d dlmZ d dl	m
Z d dlmZ erddlmZ eefZd!dZd"dZd#dZ	 d$d%dZ	 d$d&dZd'd(dZd'd)dZd*d ZdS )+    )annotations)	b64decode)	b64encode)encodebytes)Error)TYPE_CHECKING   )Bufferflagsintreturnstrc                    | dk    sJ dS )Nr   fallback )r   s    f/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/pybase64/_fallback.py_get_simd_namer      s    A:::::    c                     dS )Nr   r   r   r   r   _get_simd_pathr      s    1r   sstr | Bufferbytes | bytearrayc                   t          | t                    r6	 |                     d          S # t          $ r d}t	          |          d w xY wt          | t
                    r| S 	 t          |           }|j        s| j        j	        dd}t          |          |                                S # t          $ r! d| j        j	        d}t          |          d w xY w)Nasciiz4string argument should contain only ASCII charactersr   ': underlying buffer is not C-contiguousz<argument should be a bytes-like object or ASCII string, not )
isinstancer   encodeUnicodeEncodeError
ValueError_bytes_types
memoryviewc_contiguous	__class____name__BufferErrortobytes	TypeError)r   msgmvs      r   
_get_bytesr+      s   !S ,	,88G$$$! 	, 	, 	,HCS//t+	, !\"" ']] 	#[)VVVVCc"""zz|| ' ' '6;/56 6 	 nn$&'s   , A	$AB- -+CNFaltcharsstr | Buffer | Nonevalidateboolbytesc                   t          |           } |t          |          }|rt          |           dz  dk    rd}t          |          t          | |d          }d}t          |           dk    r<d}| d         dk    r|d	z  }| d
         dk    r|d	z  }dt          |           dz  z  |z
  }|t          |          k    rd}t          |          |S t          | |d          S )a  Decode bytes encoded with the standard Base64 alphabet.

    Argument ``s`` is a :term:`bytes-like object` or ASCII string to
    decode.

    Optional ``altchars`` must be a :term:`bytes-like object` or ASCII
    string of length 2 which specifies the alternative alphabet used instead
    of the '+' and '/' characters.

    If ``validate`` is ``False`` (the default), characters that are neither in
    the normal base-64 alphabet nor the alternative alphabet are discarded
    prior to the padding check.
    If ``validate`` is ``True``, these non-alphabet characters in the input
    result in a :exc:`binascii.Error`.

    The result is returned as a :class:`bytes` object.

    A :exc:`binascii.Error` is raised if ``s`` is incorrectly padded.
    N   r   zIncorrect paddingF)r.   =   r	      zNon-base64 digit found)r+   lenBinAsciiErrorbuiltin_decode)r   r,   r.   r)   resultexpected_lenpaddings          r   r   r   /   s   , 	1Ah'' q66A:??%C$$$8e<<< q66A::Gu{{1u{{1A!,w6L3v;;&&*C$$$!X6666r   	bytearrayc                @    t          t          | ||                    S )a  Decode bytes encoded with the standard Base64 alphabet.

    Argument ``s`` is a :term:`bytes-like object` or ASCII string to
    decode.

    Optional ``altchars`` must be a :term:`bytes-like object` or ASCII
    string of length 2 which specifies the alternative alphabet used instead
    of the '+' and '/' characters.

    If ``validate`` is ``False`` (the default), characters that are neither in
    the normal base-64 alphabet nor the alternative alphabet are discarded
    prior to the padding check.
    If ``validate`` is ``True``, these non-alphabet characters in the input
    result in a :exc:`binascii.Error`.

    The result is returned as a :class:`bytearray` object.

    A :exc:`binascii.Error` is raised if ``s`` is incorrectly padded.
    )r,   r.   )r=   r   )r   r,   r.   s      r   b64decode_as_bytearrayr?   _   s!    , Yq8hGGGHHHr   r
   c                    t          |           }|j        s| j        j        dd}t	          |          |t          |          }t          | |          S )a  Encode bytes using the standard Base64 alphabet.

    Argument ``s`` is a :term:`bytes-like object` to encode.

    Optional ``altchars`` must be a byte string of length 2 which specifies
    an alternative alphabet for the '+' and '/' characters.  This allows an
    application to e.g. generate url or filesystem safe Base64 strings.

    The result is returned as a :class:`bytes` object.
    r   r   )r"   r#   r$   r%   r&   r+   builtin_encode)r   r,   r*   r)   s       r   r   r   x   s`     
AB? %RRRR#h''!X&&&r   c                H    t          | |                              d          S )a  Encode bytes using the standard Base64 alphabet.

    Argument ``s`` is a :term:`bytes-like object` to encode.

    Optional ``altchars`` must be a byte string of length 2 which specifies
    an alternative alphabet for the '+' and '/' characters.  This allows an
    application to e.g. generate url or filesystem safe Base64 strings.

    The result is returned as a :class:`str` object.
    r   )r   decode)r   r,   s     r   b64encode_as_stringrD      s"     Q!!((111r   c                    t          |           }|j        s| j        j        dd}t	          |          t          |           S )a-  Encode bytes into a bytes object with newlines (b'\\n') inserted after
    every 76 bytes of output, and ensuring that there is a trailing newline,
    as per :rfc:`2045` (MIME).

    Argument ``s`` is a :term:`bytes-like object` to encode.

    The result is returned as a :class:`bytes` object.
    r   r   )r"   r#   r$   r%   r&   builtin_encodebytes)r   r*   r)   s      r   r   r      sK     
AB? %RRRR#q!!!r   )r   r   r   r   )r   r   )r   r   r   r   )NF)r   r   r,   r-   r.   r/   r   r0   )r   r   r,   r-   r.   r/   r   r=   )N)r   r
   r,   r-   r   r0   )r   r
   r,   r-   r   r   )r   r
   r   r0   )
__future__r   base64r   r9   r   rA   r   rF   binasciir   r8   typingr   _typingr
   r0   r=   r!   r   r   r+   r?   rD   r   r   r   <module>rL      sg   " " " " " " . . . . . . . . . . . . 5 5 5 5 5 5 + + + + + +              y!   
   ' ' ' '0 MR-7 -7 -7 -7 -7b MRI I I I I2' ' ' ' '(2 2 2 2 2" " " " " "r   