Ë
    ¹ûàgæ!  ã                   ó
  — d dl Z d dlZd dlmZ d dlmZmZ d dlmZ d dl	m
Z
 d dlmZmZ  G d„ dej                  «      Z G d	„ d
ej                   «      Z G d„ d«      Z G d„ d«      Z G d„ d«      Z G d„ de«      Zd„ Zd„ Zy)é    N)Úsettings)ÚBaseStorageÚMessage)Úsigning)ÚSimpleCookie)ÚSafeDataÚ	mark_safec                   ó&   ‡ — e Zd ZdZdZˆ fd„Zˆ xZS )ÚMessageEncoderzI
    Compactly serialize instances of the ``Message`` class as JSON.
    Ú__json_messagec                 ó  •— t        |t        «      rkt        |j                  t        «      rdnd}| j                  ||j
                  |j                  g}|j                  �|j                  |j                  «       |S t        ‰| �%  |«      S )Né   r   )
Ú
isinstancer   Úmessager   Úmessage_keyÚlevelÚ
extra_tagsÚappendÚsuperÚdefault)ÚselfÚobjÚis_safedatar   Ú	__class__s       €úd/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/django/contrib/messages/storage/cookie.pyr   zMessageEncoder.default   sk   ø€ Ü�cœ7Ô#ä)¨#¯+©+´xÔ@™!ÀaˆKØ×'Ñ'¨°c·i±iÀÇÁÐMˆGØ�~‰~Ð)Ø—‘˜sŸ~™~Ô.ØˆNÜ‰w‰˜sÓ#Ð#ó    )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__classcell__©r   s   @r   r   r      s   ø„ ñð #€K÷$ð $r   r   c                   ó(   ‡ — e Zd ZdZd„ Zˆ fd„Zˆ xZS )ÚMessageDecoderzE
    Decode JSON that includes serialized ``Message`` instances.
    c                 ór  — t        |t        «      rX|rV|d   t        j                  k(  r!|d   rt	        |d   «      |d<   t        |dd  Ž S |D �cg c]  }| j                  |«      ‘Œ c}S t        |t        «      r3|j                  «       D ��ci c]  \  }}|| j                  |«      “Œ c}}S |S c c}w c c}}w )Nr   r   é   é   )	r   Úlistr   r   r	   r   Úprocess_messagesÚdictÚitems)r   r   ÚitemÚkeyÚvalues        r   r)   zMessageDecoder.process_messages"   s©   € Ü�cœ4Ô ¡SØ�1‰vœ×3Ñ3Ò3Ø�q’6Ü& s¨1¡vÓ.�C˜‘FÜ  A B Ð(Ð(Ø<?Ö@°D�D×)Ñ)¨$Õ/Ò@Ð@Ü�cœ4Ô ØHKÏ	É	Ë×T¹*¸#¸u�C˜×.Ñ.¨uÓ5Ñ5ÓTÐTØˆ
ùò AùãTs   ÁB.ÂB3c                 óF   •— t        ‰| �  |fi |¤Ž}| j                  |«      S ©N)r   Údecoder)   )r   ÚsÚkwargsÚdecodedr   s       €r   r1   zMessageDecoder.decode-   s'   ø€ Ü‘'‘. Ñ- fÑ-ˆØ×$Ñ$ WÓ-Ð-r   )r   r   r   r    r)   r1   r!   r"   s   @r   r$   r$      s   ø„ ñò	÷.ð .r   r$   c                   ó   — e Zd Zd„ Zy)ÚMessagePartSerializerc                 ó`   — |D �cg c]  }t        j                  |dt        ¬«      ‘Œ  c}S c c}w )N)ú,ú:)Ú
separatorsÚcls)ÚjsonÚdumpsr   )r   r   Úos      r   r=   zMessagePartSerializer.dumps3   s8   € ð ö
ð ô �J‰JØØ%Ü"öò
ð 	
ùò 
s   …#+N©r   r   r   r=   © r   r   r6   r6   2   s   „ ó
r   r6   c                   ó   — e Zd Zd„ Zy)ÚMessagePartGatherSerializerc                 óN   — ddj                  |«      z   dz   j                  d«      S )z£
        The parameter is an already serialized list of Message objects. No need
        to serialize it again, only join the list together and encode it.
        ú[r8   ú]úlatin-1)ÚjoinÚencode)r   r   s     r   r=   z!MessagePartGatherSerializer.dumps?   s'   € ð
 �c—h‘h˜s“mÑ# cÑ)×1Ñ1°)Ó<Ð<r   Nr?   r@   r   r   rB   rB   >   s   „ ó=r   rB   c                   ó   — e Zd Zd„ Zy)ÚMessageSerializerc                 óV   — t        j                  |j                  d«      t        ¬«      S )NrF   )r;   )r<   Úloadsr1   r$   ©r   Údatas     r   rL   zMessageSerializer.loadsH   s   € Ü�z‰z˜$Ÿ+™+ iÓ0´nÔEÐEr   N)r   r   r   rL   r@   r   r   rJ   rJ   G   s   „ óFr   rJ   c                   ó€   ‡ — e Zd ZdZdZdZdZ ej                  d«      Z	dZ
ˆ fd„Zd„ Zd„ Zdd	„Zdd
„Zdd„Zd„ Zˆ xZS )ÚCookieStoragez%
    Store messages in a cookie.
    Úmessagesi   Ú__messagesnotfinished__zdjango.contrib.messagesc                 ón   •— t        ‰| �  |i |¤Ž t        j                  | j                  ¬«      | _        y )N)Úsalt)r   Ú__init__r   Úget_cookie_signerÚkey_saltÚsigner)r   Úargsr3   r   s      €r   rU   zCookieStorage.__init__Z   s+   ø€ Ü‰Ñ˜$Ð) &Ò)Ü×/Ñ/°T·]±]ÔCˆ�r   c                 óà   — | j                   j                  j                  | j                  «      }| j	                  |«      }|xr |d   | j
                  k(   }|r|s|j                  «        ||fS )a
  
        Retrieve a list of messages from the messages cookie. If the
        not_finished sentinel value is found at the end of the message list,
        remove it and return a result indicating that not all messages were
        retrieved by this storage.
        éÿÿÿÿ)ÚrequestÚCOOKIESÚgetÚcookie_nameÚ_decodeÚnot_finishedÚpop)r   rY   r3   rN   rQ   Úall_retrieveds         r   Ú_getzCookieStorage._get^   sg   € ð �|‰|×#Ñ#×'Ñ'¨×(8Ñ(8Ó9ˆØ—<‘< Ó%ˆØ%ÒK¨(°2©,¸$×:KÑ:KÑ*KÐLˆÙ™Mà�L‰LŒNØ˜Ð&Ð&r   c                 ó@  — |rb|j                  | j                  |t        j                  t        j                  xs dt        j
                  xs dt        j                  ¬«       y|j                  | j                  t        j                  t        j                  ¬«       y)zz
        Either set the cookie with the encoded data if there is any data to
        store, or delete the cookie.
        N)ÚdomainÚsecureÚhttponlyÚsamesite)rf   ri   )Ú
set_cookier_   r   ÚSESSION_COOKIE_DOMAINÚSESSION_COOKIE_SECUREÚSESSION_COOKIE_HTTPONLYÚSESSION_COOKIE_SAMESITEÚdelete_cookie)r   Úencoded_dataÚresponses      r   Ú_update_cookiezCookieStorage._update_cookiem   s„   € ñ
 Ø×ÑØ× Ñ ØÜ×5Ñ5Ü×5Ñ5Ò=¸Ü!×9Ñ9ÒA¸TÜ!×9Ñ9ð  õ ð ×"Ñ"Ø× Ñ Ü×5Ñ5Ü!×9Ñ9ð #õ r   c                 óf  ‡ ‡
‡‡— g }t        «       j                  |«      }‰ j                  |«      }‰ j                  rbt	        «       Šˆˆ fd„Šˆ fd„Š
 ‰|«      rE|r"t        |ˆ
ˆfd„¬«      }	|d|	 } ‰
||	d «      }n!t        |ˆ
ˆfd„¬«      }	||	d } ‰
|d|	 «      }‰ j                  ||«       |S )aT  
        Store the messages to a cookie and return a list of any messages which
        could not be stored.

        If the encoded data is larger than ``max_cookie_size``, remove
        messages until the data fits (these are the messages which are
        returned), and add the not_finished sentinel value to indicate as much.
        c                 ó`   •— | xr* t        ‰j                  | «      d   «      ‰j                  kD  S )Nr   )ÚlenÚvalue_encodeÚmax_cookie_size)rN   Úcookier   s    €€r   Úis_too_large_for_cookiez5CookieStorage._store.<locals>.is_too_large_for_cookie“   s.   ø€ ØÒX¤ F×$7Ñ$7¸Ó$=¸aÑ$@Ó AÀD×DXÑDXÑ XÐXr   c                 óF   •— ‰j                  | ‰j                  gz   d¬«      S )NT©Úencode_empty)Ú_encode_partsÚnot_finished_json)Úsome_serialized_msgr   s    €r   Úcompute_msgz)CookieStorage._store.<locals>.compute_msg–   s/   ø€ Ø×)Ñ)Ø'¨4×+AÑ+AÐ*BÑBØ!%ð *ó ð r   c                 ó    •—  ‰ ‰| «      «      S r0   r@   ©Úmr€   ry   s    €€r   ú<lambda>z&CookieStorage._store.<locals>.<lambda>    ó   ø€ Ñ%<¹[È»^Ó%L€ r   )ÚfnNc                 ó    •—  ‰ ‰| «      «      S r0   r@   r‚   s    €€r   r„   z&CookieStorage._store.<locals>.<lambda>§   r…   r   )r6   r=   r}   rw   r   Úbisect_keep_rightÚbisect_keep_leftrr   )r   rQ   rq   Úremove_oldestrY   r3   Úunstored_messagesÚserialized_messagesrp   Úidxr€   rx   ry   s   `         @@@r   Ú_storezCookieStorage._store‚   sÐ   û€ ð ÐÜ3Ó5×;Ñ;¸HÓEÐØ×)Ñ)Ð*=Ó>ˆØ×Òô "“^ˆFõYôñ ' |Ô4Ù Ü+Ø+ÜLô�Cð )1°°#¨Ð%Ù#.Ð/BÀ3À4Ð/HÓ#I‘Lä*Ø+ÜLô�Cð )1°°¨Ð%Ù#.Ð/BÀ4ÀCÐ/HÓ#I�Là×Ñ˜L¨(Ô3Ø Ð r   c                 óP   — |s|r"| j                   j                  |t        d¬«      S y)a  
        Return an encoded version of the serialized messages list which can be
        stored as plain text.

        Since the data will be retrieved from the client-side, the encoded data
        also contains a hash to ensure that the data was not tampered with.
        T)Ú
serializerÚcompressN)rX   Úsign_objectrB   )r   rQ   r|   s      r   r}   zCookieStorage._encode_parts¯   s2   € ñ ‘|Ø—;‘;×*Ñ*ØÔ%@È4ð +ó ð ð $r   c                 óZ   — t        «       j                  |«      }| j                  ||¬«      S )z¬
        Return an encoded version of the messages list which can be stored as
        plain text.

        Proxies MessagePartSerializer.dumps and _encoded_parts.
        r{   )r6   r=   r}   )r   rQ   r|   rŒ   s       r   Ú_encodezCookieStorage._encode¼   s/   € ô 4Ó5×;Ñ;¸HÓEÐØ×!Ñ!Ð"5ÀLÐ!ÓQÐQr   c                 óÊ   — |sy	 | j                   j                  |t        ¬«      S # t        j                  t
        j                  t        j                  f$ r
 Y d| _	        yw xY w)zÄ
        Safely decode an encoded text stream back into a list of messages.

        If the encoded text stream contained an invalid hash or was in an
        invalid format, return None.
        N)r�   T)
rX   Úunsign_objectrJ   r   ÚBadSignatureÚbinasciiÚErrorr<   ÚJSONDecodeErrorÚusedrM   s     r   r`   zCookieStorage._decodeÆ   s_   € ñ Øð	Ø—;‘;×,Ñ,¨TÔ>OÐ,ÓPÐPøÜ×$Ñ$¤h§n¡n´d×6JÑ6JÐKò 	Øð ˆŒ	Øð	ús   … & ¦2A"Á!A")T)F)r   r   r   r    r_   rw   ra   r<   r=   r~   rW   rU   rd   rr   rŽ   r}   r”   r`   r!   r"   s   @r   rP   rP   L   sX   ø„ ñð €Kð €OØ,€LØ"˜Ÿ
™
Ð#<Ó=ÐØ(€HôDò'òó*+!óZóRör   rP   c                 ór   — d}t        | «      }||k  r$||z   dz  } || d|dz    «      r|}n|dz   }||k  rŒ$|S )z¶
    Find the index of the first element from the start of the array that
    verifies the given condition.
    The function is applied from the start of the array to the pivot.
    r   r'   Nr   ©ru   ©Úar†   ÚloÚhiÚmids        r   r‰   r‰   Ù   sV   € ð 
€BÜ	ˆQ‹€BØ
ˆrŠ'Ø�B‰w˜1‰nˆÙˆa�	�#˜‘'ˆlÔØ‰Bà�q‘ˆBð ˆr‹'ð €Ir   c                 ól   — d}t        | «      }||k  r!||z   dz  } || |d «      r|dz   }n|}||k  rŒ!|S )z®
    Find the index of the first element from the end of the array that verifies
    the given condition.
    The function is applied from the pivot to the end of array.
    r   r'   Nr   r�   rž   s        r   rˆ   rˆ   ê   sQ   € ð 
€BÜ	ˆQ‹€BØ
ˆrŠ'Ø�B‰w˜1‰nˆÙˆa��ˆgŒ;Ø�q‘‰BàˆBð ˆr‹'ð €Ir   )r˜   r<   Údjango.confr   Ú$django.contrib.messages.storage.baser   r   Údjango.corer   Údjango.httpr   Údjango.utils.safestringr   r	   ÚJSONEncoderr   ÚJSONDecoderr$   r6   rB   rJ   rP   r‰   rˆ   r@   r   r   ú<module>r«      sw   ðÛ Û å  ß EÝ Ý $ß 7ô$�T×%Ñ%ô $ô$.�T×%Ñ%ô .÷*	
ñ 	
÷=ñ =÷Fñ Fô
J�Kô JòZó"r   