
    qh#                       S SK Jr  S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SK	J
r
  S SKJr  S SKJrJrJrJr  S SKrS SKrSSKJrJrJr  SrS	r\R4                  " S
5      rS rS rS r S#       S$S jjrS%S jr S%S jr!S r"S r#S r$S r%S r&S rS&S jr'S r(S'S jr)S(S jr*S r+S r,S r-S r.S r/S  r0 " S! S"5      r1g))    )annotationsN)Any)parse_qs)unquote	urlencodeurlparse
urlunparse   )AuthCanceledAuthForbiddenAuthUnreachableProviderSOCIAL_AUTHpartial_pipeline_tokensocialc                >    [        U 5        [        R                  U    $ N)
__import__sysmodules)names    C/var/www/html/env/lib/python3.13/site-packages/social_core/utils.pyimport_moduler      s    t;;t    c                V    U R                  SS5      u  p[        U5      n[        X25      $ )N.r
   )rsplitr   getattr)r   modmembermodules       r   module_memberr!   !   s)    ++c1%KC3F6""r   c                 (    S[         R                  -   $ )z5Builds a simple User-Agent string to send in requestszsocial-auth-)social_core__version__ r   r   
user_agentr&   '   s    K3333r   c                    U(       ad  [        [        U 5      5      n[        US   5      nUR                  U5        [	        U5      US'   U(       a  [        US   5      US'   [        U5      n U $ )zEAdds parameters to URL, parameter will be repeated if already present   )listr   r   updater   r   r	   )urlparams_unquote_query	fragmentsvalues        r   url_add_parametersr0   ,   sa     #'	1&V '	!"9Q<0IaL#Jr   c            	         SR                  U  Vs/ s H+  o(       d  M  UR                  5       R                  SS5      PM-     sn5      $ s  snf )N_-)joinupperreplace)namesr   s     r   to_setting_namer8   ;   s;    88N3TZZ\))#s3NOONs
   
A	$A	c                 "    [        [        /U Q76 $ r   )r8   SETTING_PREFIX)r7   s    r   setting_namer;   ?   s    n5u577r   c                    U(       a'  [        US5      (       a  UR                  S5      (       a  g [        U5      S   =(       d    U S   nX ;   a  U$ g! [        [        4 a     gf = f)z
Given a list of hostnames and an untrusted URL to redirect to,
this method tests it to make sure it isn't garbage/harmful
and returns it, else returns None, similar as how's it done
on django.contrib.auth.views.

startswithz///Nr
   r   )hasattrr=   r   	TypeErrorAttributeError)hostsredirect_tonetlocs      r   sanitize_redirectrD   C   sp     {L11!!%((+&q)5U1X ?  ~& s   A A&%A&c                    U (       aL  [        U S5      (       a;  [        U R                  5      (       a  U R                  5       nU$ U R                  n U$ U (       a  SnU$ SnU$ )Nis_authenticatedTF)r>   callablerF   )userauthenticateds     r   user_is_authenticatedrJ   \   sm    011D))** 113M  !11M
 	 
  r   c                    U (       aK  [        U S5      (       a:  [        U R                  5      (       a  U R                  5       nU$ U R                  nU$ U (       a  SnU$ SnU$ )N	is_activeTF)r>   rG   rL   )rH   rL   s     r   user_is_activerM   i   sg    k**(0(@(@DNN$	
  GKnn	
 	 
	  	r   c                   [         R                  " S[        U 5      5      R                  SS5      R	                  S5      n [
        R                  " SSU 5      R                  5       R                  5       n [
        R                  " SSU 5      $ )zConverts to lowercase, removes non-word characters (alphanumerics
and underscores) and converts spaces to hyphens. Also strips leading
and trailing whitespace.NFKDasciiignorez[^\w\s-] z[-\s]+r3   )	unicodedata	normalizestrencodedecoderesubstriplowerr/   s    r   slugifyr]   t   sk    
 	fc%j1		"	 

 FF;E*00288:E66)S%((r   c                8    U H  nU " U5      (       d  M  Us  $    g)z<Return the first item in the list for what func returns TrueNr%   )funcitemsitems      r   firstrb      s    ::K  r   c                *    [        [        U 5      5      $ )z@Like urlparse.parse_qs but transform list values to single items)
drop_listsbattery_parse_qsr\   s    r   r   r      s    &u-..r   c                >    [        [        U 5      R                  5      $ r   )r   r   queryr+   s    r   get_querystringri      s    HSM''((r   c                    0 nU R                  5        HP  u  p#US   n[        U[        5      (       a  [        US5      n[        U[        5      (       a  [        US5      nX1U'   MR     U$ )Nr   utf-8)r`   
isinstancebytesrU   )r/   outkeyvals       r   rd   rd      sb    
CKKM!fc5!!c7#Cc5!!c7#CC " Jr   c                   U R                   R                  5       nU R                  SS5      nU=(       d8    UR                  U5      =(       d     U R                   R	                  [
        S 5      nU(       a  U R                   R                  U5      nSnU(       az  UR                  U R                  :X  a`  SnU R                  (       aM  U R                  U;   a=  UR                  R                  S5      n	UR                  U R                  5      n
X:w  a  SnU(       a>  U(       a  UR                  SU5        UR                  SU5        UR                  U5        U$ U R                   R                  U5        g g )NPARTIAL_PIPELINE_TOKEN_NAMEpartial_tokenFTuidrH   request)strategyrequest_datasettinggetsession_getPARTIAL_TOKEN_SESSION_NAMEpartial_loadbackendr   ID_KEYkwargs
setdefaultextend_kwargsclean_partial_pipeline)r}   rH   rs   argsr   rw   partial_argument_namepartialpartial_matches_requestid_from_partialid_from_requests              r   partial_pipeline_datar      s:   ##002L#OO% 	 	J12	J''(BDI  ""//>"'w',,6&*#
 ~~'..L"@").."4"4U";"."2"27>>"B"5.3+"!!&$/i6!!&)N//>r   c                    U=(       d    SnUR                  S5      (       a  U$ U R                  S5      (       a  UR                  S5      (       a  USS nX-   $ )z-Build absolute URI with given (optional) pathrR   )http://https:///r
   N)r=   endswith)host_urlpaths     r   build_absolute_urir      sR    :2D.//$//#"6"6ABx?r   c                    [        U [        5      (       a  U R                  S5      n [        U[        5      (       a  UR                  S5      n[        R                  " X5      $ )zDCompare two values and prevent timing attacks for cryptographic use.rk   )rl   rU   rV   hmaccompare_digest)val1val2s     r   constant_time_comparer      sI    ${{7#${{7#t**r   c                6    U =(       a    U R                  S5      $ )N)r   r   r   )r=   r\   s    r   is_urlr      s    Ee&&'CDEr   c                    U H<  n[        U5      (       a  Us  $ U R                  U5      n[        U5      (       d  M:  Us  $    g r   )r   rx   )r}   r7   r   r/   s       r   setting_urlr      s;    $<<K%%==L  r   c                F   ^  [         R                  " T 5      U 4S j5       nU$ )Nc                   >  T" U 0 UD6$ ! [         R                   a  n[        R                  SUR                  R
                  UR                  R                  5        UR                  R
                  S:X  a  [        U S   UR                  S9eUR                  R
                  S:X  a  [        U S   5      eUR                  R
                  S:X  a  [        U S   5      ee S nAff = f)NzRequest failed with %d: %si  r   )responsei  i  )
requests	HTTPErrorsocial_logger	exceptionr   status_codetextr   r   r   )r   r   errr_   s      r   wrapper#handle_http_errors.<locals>.wrapper   s    	(((!! 	##,((!! ||''3."47S\\BB||''3.#DG,,||''3.-d1g66	s    C%CC  C%)	functoolswraps)r_   r   s   ` r   handle_http_errorsr      s%    __T $ Nr   c                J    U (       a  U R                  S5      (       d  U  S3n U $ )zMake sure we append a slash at the end of the URL otherwise we
have issues with urljoin Example:
>>> urlparse.urljoin('http://www.example.com/api/v3', 'user/1/')
'http://www.example.com/api/user/1/'
r   )r   rh   s    r   append_slashr      s%     3<<$$QiJr   c                F    [        U 5      n[        U5      nU" U/UQ70 UD6$ r   )r!   )rv   storager   r   StrategyStorages         r   get_strategyr   	  s+    X&HG$GG-d-f--r   c                  .    \ rS rSrSrSS jrS rS rSrg)	cachei  z
Cache decorator that caches the return value of a method for a
specified time.

It maintains a cache per class, so subclasses have a different cache entry
for the same cached method.

Does not work for methods with arguments.
c                    Xl         0 U l        g r   )ttlr   )selfr   s     r   __init__cache.__init__  s    &(
r   c                :   ^ ^ UU 4S jnT R                   Ul        U$ )Nc                `  > [         R                   " 5       nS nS nU R                  TR                  ;   a  TR                  U R                     u  p#U(       a  U(       a  X-
  TR                  :  a%   T" U 5      nX4TR                  U R                  '   U$ U$ ! [         a    U(       d  e  U$ f = fr   )time	__class__r   r   	Exception)thisnowlast_updatedcached_valuefnr   s       r   wrappedcache.__call__.<locals>.wrapped  s    ))+CLL~~+-1ZZ-G*  |s7IDHH7T#%d8L251DDJJt~~.
  <	 ! ' (	s   1"B B-,B-)_invalidate
invalidate)r   r   r   s   `` r   __call__cache.__call__  s    	 & "--r   c                8    U R                   R                  5         g r   )r   clear)r   s    r   r   cache._invalidate5  s    

r   )r   r   N)r   int)	__name__
__module____qualname____firstlineno____doc__r   r   r   __static_attributes__r%   r   r   r   r     s    ).r   r   )F)r+   rU   r,   zdict[str, str] | Noner-   boolreturnrU   )r7   rU   r   rU   )r+   rU   )NNr   )2
__future__r   r   r   loggingrX   r   r   rS   typingr   urllib.parser   re   r   r   r   r	   r   r#   
exceptionsr   r   r   r:   r{   	getLoggerr   r   r!   r&   r0   r8   r;   rD   rJ   rM   r]   rb   ri   rd   r   r   r   r   r   r   r   r   r   r%   r   r   <module>r      s    "    	 
    5 A A   L L5  !!(+
#4 EJ	+=AP82

)/
)	%P+F..' 'r   