
     j"6              
         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
r
S SKJr  S SKJr  S SKrSSKJr  \
R$                  (       a  SSKJr  SS	S
.r\R-                  \" S5       V s0 s H"  o S:w  d  M
  \" U 5      SR3                  U 5      _M$     sn 5        \R4                  " SR7                  \R9                  5        V s/ s H  n \R;                  U 5      PM     sn 5      5      r S*       S+S jjrS*S,S jjr S-S jr!S.S jr"S/S jr#S0S jr$S1S jr%S2S jr&SS1r'    S3S jr(S4S jr)S5S jr*S6S jr+S7S jr,S8S9S jjr-S8S:S jjr.S;S  jr/S<S! jr0S=S" jr1S>S# jr2 " S$ S%5      r3 " S& S'5      r4S?S( jr5S?S) jr6gs  sn f s  sn f )@    )annotationsN)Path)
getproxies   )PrimitiveDataURLz%22z\\)"\       z%{:02X}|c                    [        U [        5      (       a  U nOU R                  U=(       d    S5      nU(       a  UR                  5       $ U$ )z=
Coerce str/bytes into a strictly byte-wise HTTP header key.
ascii)
isinstancebytesencodelower)valuer   encodingbytes_values       V/home/ubuntu/second-brain/public-api/venv/lib/python3.13/site-packages/httpx/_utils.pynormalize_header_keyr      s?     %ll8#6w7"';8[8    c                d    [        U [        5      (       a  U $ U R                  U=(       d    S5      $ )z?
Coerce str/bytes into a strictly byte-wise HTTP header value.
r   )r   r   r   r   r   s     r   normalize_header_valuer   /   s*     %<<+G,,r   c                8    U SL a  gU SL a  gU c  g[        U 5      $ )z{
Coerce a primitive data type into a string value.

Note that we prefer JSON-style 'true'/'false' for boolean values here.
TtrueFfalse )strr   s    r   primitive_value_to_strr$   8   s*     }	%	u:r   c                R     [         R                  " U 5        g! [         a     gf = f)z/
Return `True` if `encoding` is a known codec.
FT)codecslookupLookupError)r   s    r   is_known_encodingr)   G   s,    h   s    
&&c                b    SS jn[         R                  X!5      nU  SU S3R                  5       $ )z3
Encode a name/value pair within a multipart form.
c                2    [         U R                  S5         $ )Nr   )!_HTML5_FORM_ENCODING_REPLACEMENTSgroup)matchs    r   replacer#format_form_param.<locals>.replacerW   s    0Q@@r   z="r
   )r.   ztyping.Match[str]returnr"   )_HTML5_FORM_ENCODING_REsubr   )namer   r/   s      r   format_form_paramr5   R   s6    
A $''8EV2eWA%%''r   c                 D   S[         R                  ;   a<  [        [         R                  S   5      n U R                  5       (       a  [	        U 5      $ S[         R                  ;   a<  [        [         R                  S   5      nUR                  5       (       a  [	        U5      $ g )NSSL_CERT_FILESSL_CERT_DIR)osenvironr   is_filer"   is_dir)ssl_filessl_paths     r   get_ca_bundle_from_envr?   ^   ss    "**$

?34x= #

>23??x= r   c                   / nSnU R                  U5      n U (       d  U$ [        R                  " SU 5       H  n UR                  SS5      u  pESUR                  S5      0nUR                  S5       H9  n UR                  S5      u  pU R                  U5      XhR                  U5      '   M;     UR	                  U5        M     U$ ! [         a    USpT Nf = f! [         a       M8  f = f)	a  
Returns a list of parsed link headers, for more info see:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Link
The generic syntax of those is:
Link: < uri-reference >; param1=value1; param2="value2"
So for instance:
Link; '<http:/.../front.jpeg>; type="image/jpeg",<http://.../back.jpeg>;'
would return
    [
        {"url": "http:/.../front.jpeg", "type": "image/jpeg"},
        {"url": "http://.../back.jpeg"},
    ]
:param value: HTTP Link entity-header field
:return: list of parsed link headers
z '"z, *<;r   r!   urlz<> '"=)stripresplit
ValueErrorappend)	r   linksreplace_charsvalrB   paramslinkparamkeys	            r   parse_header_linksrP   j   s      #%EMKK&Exx&	"))C+KC syy*+\\#&E"[[-
 .3[[-GD=)* ' 	T ' L  	"r	"  s#   C6CCC
C('C(c                d    [         R                  R                  5       nXS'   UR                  S S9$ )Nzcontent-type)failobj)emailmessageMessageget_content_charset)content_typemsgs     r   parse_content_type_charsetrY      s2     --


!C&""4"00r   authorizationzproxy-authorizationc              #     #    U  H5  u  p[        UR                  5       5      [        ;   a
  [        SUS9nX4v   M7     g 7f)Nz[secure])match_type_of)to_strr   SENSITIVE_HEADERSto_bytes_or_str)itemskvs      r   obfuscate_sensitive_headersrc      s:      !'') 11
!<Ad
 s   =?c                p    U R                   b  U R                   $ SSS.R                  U R                  5      $ )NP     )httphttps)portgetscheme)rB   s    r   port_or_defaultrl      s/    
xxxx%))#**55r   c                    U R                   UR                   :H  =(       a7    U R                  UR                  :H  =(       a    [        U 5      [        U5      :H  $ )z8
Return 'True' if the given URLs share the same origin.
)rk   hostrl   )rB   others     r   same_originrp      sE    
 	

ell" 	;HH

"	;C OE$::r   c                    U R                   UR                   :w  a  gU R                  S:H  =(       a9    [        U 5      S:H  =(       a$    UR                  S:H  =(       a    [        U5      S:H  $ )z9
Return 'True' if 'location' is a HTTPS upgrade of 'url'
Frg   re   rh   rf   )rn   rk   rl   )rB   locations     r   is_https_redirectrs      sa     xx8==  	

f 	-C B&	-OOw&	- H%,	r   c                    [        5       n 0 nS H1  nU R                  U5      (       d  M  X   nSU;   a  UOSU 3X S3'   M3     U R                  SS5      R                  S5       Vs/ s H  oDR                  5       PM     nnU H}  nUS:X  a  0 s  $ U(       d  M  SU;   a  SX'   M"  [	        U5      (       a
  SUS	U 3'   M<  [        U5      (       a  SUS
U S3'   MW  UR                  5       S:X  a
  SUS	U 3'   Mu  SUSU 3'   M     U$ s  snf )z+Gets proxy information from the environment)rg   rh   allz://zhttp://nor!   ,*Nzall://zall://[]	localhostzall://*)r   rj   rF   rD   is_ipv4_hostnameis_ipv6_hostnamer   )
proxy_infomountsrk   hostnamern   no_proxy_hostss         r   get_environment_proxiesr      s-    J$&F*>>&!!!)H!X-WXJ3G XS>" + 0:~~dB/G/M/Mc/RS/Rtjjl/RNS" s?
 IX  #' !(++.2z*+!(++04
!,-![0.2z*+/3
+,5 #8 M; Ts   'Dc                R    [        U [        5      (       a  U R                  U5      $ U $ Nr   r"   r   r   s     r   to_bytesr      s"    %/s%;%;5<<!FFr   c                R    [        U [        5      (       a  U $ U R                  U5      $ r   )r   r"   decoder   s     r   r]   r]      s"    uc**5FX0FFr   c                P    [        U[        5      (       a  U $ U R                  5       $ r   r   )r   r\   s     r   r_   r_      s    }c225FFr   c                <    U S   U S   s=:X  a  S:X  a  O  OU SS $ U $ )Nr   r
   r    r#   s    r   unquoter      s'    (eBi63652;AEAr   c                V    U (       a"  [         R                  " U 5      S   =(       d    S$ g )Nr   zapplication/octet-stream)	mimetypes
guess_type)filenames    r   guess_content_typer     s$    ##H-a0N4NNr   c                H    U R                  5       n[        R                  " U5      R                  nU$ ! [        [
        4 a]     U R                  5       nU R                  S[        R                  5      nU R                  U5         U$ ! [        [
        4 a      gf = ff = f)zg
Given a file-like stream object, return its length in number of bytes
without reading it into memory.
r   N)	filenor9   fstatst_sizeAttributeErrorOSErrortellseekSEEK_END)streamfdlengthoffsets       r   peek_filelike_lengthr   
  s    
]]_"%% M G$ 
	 [[]F[[BKK0FKK
 M	 ( 		
s(   04 B!AB		BB!BB!c                  F    \ rS rSrS	S jrS
S jrS
S jrS	S jrS	S jrSr	g)Timeri#  c                   #    [         R                  " 5       nUS:X  a  SS KnUR                  5       $ SS KnUR                  5       R                  5       $ 7f)Ntrior   )sniffiocurrent_async_libraryr   current_timeasyncioget_event_looptime)selflibraryr   r   s       r   	_get_timeTimer._get_time$  sH     //1f$$&&))+0022s   AAc                8    [         R                  " 5       U l        g r   r   perf_counterstartedr   s    r   
sync_startTimer.sync_start/  s    ((*r   c                J   #    U R                  5       I S h  vN U l        g  N
7fr   r   r   r   s    r   async_startTimer.async_start2  s     !^^---s   #!#c                H    [         R                  " 5       nXR                  -
  $ r   r   r   nows     r   sync_elapsedTimer.sync_elapsed5  s    !\\!!r   c                Z   #    U R                  5       I S h  vN nXR                  -
  $  N7fr   r   r   s     r   async_elapsedTimer.async_elapsed9  s&     NN$$\\!! %s   +)+)r   N)r1   float)r1   None)
__name__
__module____qualname____firstlineno__r   r   r   r   r   __static_attributes__r   r   r   r   r   #  s    	3+.""r   r   c                  ^    \ rS rSrSrSS jrSS jr\SS j5       rSS jr	SS jr
SS jrS	rg
)
URLPatterni>  aC  
A utility class currently used for making lookups against proxy keys...

# Wildcard matching...
>>> pattern = URLPattern("all://")
>>> pattern.matches(httpx.URL("http://example.com"))
True

# Witch scheme matching...
>>> pattern = URLPattern("https://")
>>> pattern.matches(httpx.URL("https://example.com"))
True
>>> pattern.matches(httpx.URL("http://example.com"))
False

# With domain matching...
>>> pattern = URLPattern("https://example.com")
>>> pattern.matches(httpx.URL("https://example.com"))
True
>>> pattern.matches(httpx.URL("http://example.com"))
False
>>> pattern.matches(httpx.URL("https://other.com"))
False

# Wildcard scheme, with domain matching...
>>> pattern = URLPattern("all://example.com")
>>> pattern.matches(httpx.URL("https://example.com"))
True
>>> pattern.matches(httpx.URL("http://example.com"))
True
>>> pattern.matches(httpx.URL("https://other.com"))
False

# With port matching...
>>> pattern = URLPattern("https://example.com:1234")
>>> pattern.matches(httpx.URL("https://example.com:1234"))
True
>>> pattern.matches(httpx.URL("https://example.com"))
False
c                t   SSK Jn  U(       a  SU;  a  [        SU SU S35      eU" U5      nXl        UR                  S:X  a  SOUR                  U l        UR
                  S	:X  a  SOUR
                  U l        UR                  U l        UR
                  (       a  UR
                  S	:X  a  S U l        g UR
                  R                  S
5      (       aC  [        R                  " UR
                  SS  5      n[        R                  " SU S35      U l        g UR
                  R                  S	5      (       aC  [        R                  " UR
                  SS  5      n[        R                  " SU S35      U l        g [        R                  " UR
                  5      n[        R                  " SU S35      U l        g )Nr   r   :zUProxy keys should use proper URL forms rather than plain scheme strings. Instead of "z", use "z://"ru   r!   rx   z*.   z^.+\.$z^(.+\.)?^)_urlsr	   rG   patternrk   rn   ri   
host_regex
startswithrE   escapecompile)r   r   r	   rB   domains        r   __init__URLPattern.__init__h  sM   s')&ixy>  'lJJ%/bSZZ((c/Bsxx	HH	xx388s?:>DOXX  &&YYsxx|,F jj6&);<DOXX  %%YYsxx|,F jj9VHA)>?DO YYsxx(F jj1VHA7DOr   c                >   U R                   (       a  U R                   UR                   :w  a  gU R                  (       a8  U R                  b+  U R                  R                  UR                  5      (       d  gU R                  b  U R                  UR                  :w  a  gg)NFT)rk   rn   r   r.   ri   r   ro   s     r   matchesURLPattern.matches  sg    ;;4;;%,,6II+OO))%**5599 TYY%**%<r   c                    U R                   b  SOSn[        U R                  5      * n[        U R                  5      * nXU4$ )zu
The priority allows URLPattern instances to be sortable, so that
we can match from most specific to least specific.
r   r   )ri   lenrn   rk   )r   port_priorityhost_priorityscheme_prioritys       r   priorityURLPattern.priority  s?     "YY2TYYt{{++o>>r   c                ,    [        U R                  5      $ r   )hashr   r   s    r   __hash__URLPattern.__hash__  s    DLL!!r   c                4    U R                   UR                   :  $ r   )r   r   s     r   __lt__URLPattern.__lt__  s    }}u~~--r   c                b    [        U[        5      =(       a    U R                  UR                  :H  $ r   )r   r   r   r   s     r   __eq__URLPattern.__eq__  s!    %,N1NNr   )rn   r   r   ri   rk   N)r   r"   r1   r   )ro   r	   r1   bool)r1   ztuple[int, int, int])r1   int)ro   r   r1   r   )ro   
typing.Anyr1   r   )r   r   r   r   __doc__r   r   propertyr   r   r   r   r   r   r   r   r   r   >  s6    'R8< ? ?".Or   r   c                v     [         R                  " U R                  S5      S   5        g! [         a     gf = fN/r   FT)	ipaddressIPv4AddressrF   	Exceptionr   s    r   r{   r{     <    hnnS1!45      (+ 
88c                v     [         R                  " U R                  S5      S   5        g! [         a     gf = fr   )r   IPv6AddressrF   r   r   s    r   r|   r|     r   r   r   )r   str | bytesr   r   r   
str | Noner1   r   )r   r   r   r   r1   r   )r   r   r1   r"   )r   r"   r1   r   )r4   r"   r   r"   r1   r   )r1   r   )r   r"   r1   zlist[dict[str, str]])rW   r"   r1   r   )r`   z4typing.Iterable[tuple[typing.AnyStr, typing.AnyStr]]r1   z4typing.Iterator[tuple[typing.AnyStr, typing.AnyStr]])rB   r	   r1   
int | None)rB   r	   ro   r	   r1   r   )rB   r	   rr   r	   r1   r   )r1   zdict[str, str | None])zutf-8)r   r   r   r"   r1   r   )r   r   r   r"   r1   r"   )r   r"   r\   typing.AnyStrr1   r   )r   r"   r1   r"   )r   r   r1   r   )r   r   r1   r   )r   r"   r1   r   )7
__future__r   r&   email.messagerS   r   r   r9   rE   r   typingpathlibr   urllib.requestr   r   _typesr   TYPE_CHECKINGr   r	   r,   updaterangechrformatr   joinkeysr   r2   r   r   r$   r)   r5   r?   rP   rY   r^   rc   rl   rp   rs   r   r   r]   r_   r   r   r   r   r   r{   r|   )cs   0r   <module>r     s   "     	 	    %  !	 +0v$> ! ! ( (*//G/Q$Y SVYa  /G **II%F%K%K%MN%Mryy|%MNO   999 9 	9 -	(	"J1 %&;< ?96.bGGGB2" "6jO jOZw H Os   .	F;FF