o
    'h	                     @  s   d dl mZ d dlZd dl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 dd	lmZ dd
lmZ G dd dee ZG dd deee ZG dd deee ZdS )    )annotationsN   )_CompactJSON)base64_decode)base64_encode)
BadPayload)_PDataSerializer)
Serializer)TimedSerializerc                      sD   e Zd ZU dZeZded< ddd fddZd fddZ  Z	S )URLSafeSerializerMixinzMixed in with a regular serializer it will attempt to zlib
    compress the string to make it shorter if necessary. It will also
    base64 encode the string so that it can safely be placed in a URL.
    z_PDataSerializer[str]default_serializerN)
serializerpayloadbytesargst.Anyr   t.Any | Nonekwargsreturnc             
     s   d}| dr|dd  }d}zt|}W n ty( } ztd|d|d }~ww |rFzt|}W n tyE } ztd|d|d }~ww t j|g|R i |S )NF   .r   Tz;Could not base64 decode the payload because of an exception)original_errorzACould not zlib decompress the payload before decoding the payload)
startswithr   	Exceptionr   zlib
decompresssuperload_payload)selfr   r   r   r   r   jsone	__class__ Q/var/www/html/olx_land/venv/lib/python3.10/site-packages/itsdangerous/url_safe.pyr      s8   
z#URLSafeSerializerMixin.load_payloadobjc                   sN   t  |}d}t|}t|t|d k r|}d}t|}|r%d| }|S )NFr   Tr   )r   dump_payloadr   compresslenr   )r   r$   r   is_compressed
compressedbase64dr    r"   r#   r%   7   s   
z#URLSafeSerializerMixin.dump_payload)
r   r   r   r   r   r   r   r   r   r   )r$   r   r   r   )
__name__
__module____qualname____doc__r   r   __annotations__r   r%   __classcell__r"   r"   r    r#   r      s   
  r   c                   @     e Zd ZdZdS )URLSafeSerializerzWorks like :class:`.Serializer` but dumps and loads into a URL
    safe string consisting of the upper and lowercase character of the
    alphabet as well as ``'_'``, ``'-'`` and ``'.'``.
    Nr+   r,   r-   r.   r"   r"   r"   r#   r2   H       r2   c                   @  r1   )URLSafeTimedSerializerzWorks like :class:`.TimedSerializer` but dumps and loads into a
    URL safe string consisting of the upper and lowercase character of
    the alphabet as well as ``'_'``, ``'-'`` and ``'.'``.
    Nr3   r"   r"   r"   r#   r5   O   r4   r5   )
__future__r   typingtr   _jsonr   encodingr   r   excr   r   r   r	   timedr
   strr   r2   r5   r"   r"   r"   r#   <module>   s    9