
    ibW              <          % 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  S SKJ	r	  S SKJ
r
  S SKJr  S SKrS SKJr  S S	KJr  S S
KJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SK J!r!  S SK J"r"  S SK#J$r$  S SK#J%r%  S SK&J'r'  S SK(J)r)  S SK*J+r+  Sr,Sr-\.\/S'   Sr0\.\/S'   S r1\.\/S'   S \.4S! jr2S"\3S S4S# jr4\+" \%5      S$\5S \.4S% j5       r6\+" \!5      S$\5S \.4S& j5       r7\+" \5      S$\S \.4S' j5       r8SS(\\3   S S4S) jjr9\Rt                  " S*S+S,S-S-S.S//S0.S19r;\;Ry                  S-S+S29                SS3\Rz                  S4\\>\R~                  " S5S65      4   S7\\\3   \R~                  " S8S9S-S:94   S;\\\3   \R~                  " S<S=S>S-S:94   S?\\\3   \R~                  " S@S-S:94   SA\\\>   \R~                  " SBS-S:94   SC\\\>   \R~                  " SDSES-S:94   SF\\\3   \R~                  " SGS-S:94   SH\\\3   \R~                  " SIS-S:94   SJ\\\3   \R~                  " SKSLS-S:94   SM\\\3   \R~                  " SNS-S:94   SO\\\>   \R~                  " SPSQS-S:94   SR\\\>   \R~                  " SSSTS-S:94   SU\\\3   \R~                  " SVSWS-S:94   SX\\\>   \R~                  " SYSZS-S:94   S[\\\>   \R~                  " S\S]S^S-S:94   S_\\\
\3      \R                  " S-S`Sa94   S S4$Sb jj5       rA\;R                  Sc5         SSd\\>\R~                  " 5       4   Se\\\>   \R~                  " Sf5      4   S(\\\3   \R~                  " 5       4   S S4Sg jj5       rC\;R                  ShSi9SS(\\\3   \R~                  " 5       4   S S4Sj jj5       rD\;R                  SkSi9SS(\\\3   \R~                  " 5       4   S S4Sl jj5       rE\;R                  SmSi9SS(\\\3   \R~                  " 5       4   S S4Sn jj5       rF\Rt                  " SoS+SpS-S-S.S//S0.S19rG\GR                  SqSi9SSr j5       rH\GR                  SsSi9   SSt\\\3   \R                  " SuSv94   Sw\\\>   \R~                  " SxSySv94   Sz\\>\R~                  " S{Sv94   S S4S| jj5       rI SSo\S}\\>   S~\>S S4S jjrJ                         SS3\Rz                  S\\\3   \R~                  " SSv94   S7\\\3   \R~                  " SSv94   S\\>\R~                  " SSv94   S\\\3   \R~                  " S\'" 5        3Sv94   S\\\3   \R~                  " S-S:94   S\\\3   \R~                  " S-S:94   S\\\3   \R~                  " S-S:94   Se\\\>   \R~                  " Sf5      4   S\\\>   \R~                  " S5      4   S\\\3   \R~                  " SSv94   S\\\3   \R~                  " S-S:94   S\\\3   \R~                  " S-S:94   S\\\3   \R~                  " S-S:94   S\\\3   \R~                  " S-S:94   S\\\3   \R~                  " S-S:94   S\\\3   \R~                  " S-S:94   S\\\>   \R~                  " S5      4   S\\\>   \R~                  " SS-S:94   S\\\3   \R~                  " SSv94   S\\\3   \R~                  " 5       4   S\\\3   \R~                  " 5       4   S\\\>   \R~                  " S5      4   S\\\>   \R~                  " S5      4   S\\\>   \R~                  " SSv94   S}\\\>   \R~                  " SSSSv94   S S46S jjrK\GR                  SS-S\'" 5        3S9" \K5      rL\GR                  SS-S\'" 5        3S9" \K5      rM\GR                  SUS-S9 SSt\\3\R                  " SSv94   S}\\\>   \R~                  " SSSSv94   S S4S jj5       rNg)    N)dedent)	Annotated)Any)Dict)List)Optional)	HTTPError)JSONDecodeError)Confirm)Syntax)Table)__version__)login)logout)
BaseClient)AnacondaAuthSite)AnacondaAuthSitesConfig)TokenExpiredError)UnknownSiteName)	TokenInfo)TokenNotFoundError)anaconda_config_path)console)register_error_handleru   [bold green]✔︎[/bold green]   PROGRAM_ERROR   ARGUMENT_ERRORSUCCESSreturnc                  l   [         R                  R                  5       (       a  [        R                  " SSS/S9n U (       a  [        5         g[        R                  " [        S5      5        [        R                  " [        [        S5      SS S	95        [        R                  " S
[        5        35        g)Nz Continue with interactive login?yn)choicesa  
                To configure your credentials you can run
                  [green]anaconda login --at anaconda.com[/green]

                or set your API key using the [green]ANACONDA_AUTH_API_KEY[/green] env var

                or set
                zl                        [plugin.auth]
                        api_key = "<api-key>"
                        toml)background_colorzin r   )sysstdoutisattyr   askr   r   printr   r   r   )do_logins    1lib/python3.13/site-packages/anaconda_auth/cli.py_continue_with_loginr/   (   s    
zz;;ACQT:VGMM  	 MM %)	 MMC 4 6789    error_classifierc                 8    [         R                  " SU  S35        g )N[bold][red]z9[/red][/bold]: Login is required to complete this action.)r   r,   )r1   s    r.   _login_required_messager4   I   s    MM
&''`ar0   ec                 T    [        U R                  R                  5        [        5       $ N)r4   	__class____name__r/   r5   s    r.   login_requiredr;   O   s    AKK001!!r0   c                 r    [         R                  " SU R                  R                   S35        [	        5       $ )Nr3   z+[/red][/bold]: Your login token has expired)r   r,   r8   r9   r/   r:   s    r.   token_expiredr=   U   s1    MM
akk**++VW  !!r0   c                     U R                   R                  5       R                  S0 5      R                  SS5      nUS:X  aO  SU R                  R
                  ;   a   [        R                  " S5        [        5       $ [        S5        [        5       $ [        R                  " SU R                  R                   S	U  35        g
! [         a    Sn Nf = f)Nerrorcode auth_requiredAuthorizationz^[bold][red]InvalidAuthentication:[/red][/bold] Your provided API Key or login token is invalidAuthenticationMissingErrorr3   z:[/red][/bold] r   )responsejsongetr
   requestheadersr   r,   r4   r/   r8   r9   )r5   
error_codes     r.   
http_errorrK   ^   s    ZZ__&**7B7;;FBG
 _$aii///MMp
 $%% $$@A#%%AKK$8$8#9LM  
s   :C CCatc                 :    U (       a  U [         R                  S'   g g )NANACONDA_DEFAULT_SITE)osenvironrL   s    r.   _override_default_siterR   r   s    	.0

*+ 
r0   authFz#Manage your Anaconda authenticationTz--helpz-h)allow_extra_argsignore_unknown_optionshelp_option_names)nameadd_completionhelpcontext_settings)invoke_without_commandno_args_is_helpctxversionz-Vz	--versionrW   z-nz--name)hiddenorganizationz-oz--orgz--organizationstrengthz
--strengthstrongz--strongweakz-wz--weakurlz--urlmax_agez	--max-agescopesz-sz--scopesoutz--outlist_scopesz-xz--list-scopeslist_tokensz-lz--listremovez-rz--removecreatez-cz--createinfoz-iz--infoz--current-info
extra_argsrA   )r_   metavarc                    U(       a5  [         R                  " S[         S3SS9  [        R                  " [
        S9eU=(       d    / nU(       a  US   nOS n[        U R                  S0 5      nUR                  U5      =n(       a  UR                  USS  US	U S
9  g [        S UUUUUUUU	U
UUUUU4 5       5      nU(       d  U(       aQ   SSKJ	n  [         R                  " S5        [        R                  " S[         5        U" ["        R$                  SS  S	S9  g [         R                  " U R'                  5       5        g ! [        [        4 a     g f = f)Nzanaconda-auth, version [cyan]z[/cyan]
bold green)styler@   r   commandsr   F)	prog_namestandalone_modeparentc              3   *   #    U  H	  nUS Lv   M     g 7fr7    ).0values     r.   	<genexpr>main.<locals>.<genexpr>  s       
E 	T
s   )mainz[yellow]DeprecationWarning[/yellow]: Please use [cyan]anaconda org auth[/cyan] instead for explicit management of anaconda.org auth tokens
zZPlease use `anaconda org auth` instead for explicit management of anaconda.org auth tokens)allow_plugin_main)r   r,   r   typerExitr   getattrcommandrG   r}   anybinstar_client.scripts.cliImportErrorModuleNotFoundErrorwarningswarnDeprecationWarningr(   argvget_help)r]   r^   rW   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   rl   rm   subcommand_namesubcommands_dictcmdhas_legacy_optionsbinstar_mains                         r.   r}   r}      sh   p +K=@	
 jjg&& !rJ$Q- s{{J; ""?33s3qrNouUX 	 	
 	  
 ( _	G 	 [	
 	h	

 	SXXab\U; MM#,,.! 01 		s   E   EEr   force
ssl_verifyz--ssl-verify/--no-ssl-verifyc                    [        U5         [        R                  " 5       nUR                  nUR                  (       a;  [
        R                  " SU 35        [        SUS9  [        R                  " [        S9e U =(       d    [        R                  " SU S3SS9n U (       d  [        R                  " [        S9e [        XS9  g	! [         a     Nf = f)
Loginz'Your API key has expired, logging into T)r   r   rr   z&You are already logged into Anaconda (z'). Would you like to force a new login?F)defaultN)rR   r   loaddomainexpiredr   r,   r   r   r   r   r   r+   r   )r   r   rL   
token_infor   s        r.   
auth_loginr   A  s     2+^^%
""MMCF8LM4**'**   
4VH<cd
 **'**  
-  s   A-C 
CCwhoamirW   c                    [        U 5        [        5       nUR                  S5      nUR                  5         [        R
                  " SUR                  R                   S35        [        R                  " UR                  5       SSS9  g)z6Display information about the currently signed-in userz/api/accountzYour info (z):r   T)dataindent	sort_keysN)
rR   r   rG   raise_for_statusr   r,   configr   
print_jsonrF   )rL   clientrE   s      r.   	auth_infor   _  se     2\Fzz.)HMMK 4 45R89HMMOAFr0   zapi-keyc                     [        U 5        [        R                  " 5       nUR                  (       d  [	        UR
                  5        g[        5       e)z"Display API Key for signed-in userN)rR   r   r   r   r,   api_keyr   )rL   r   s     r.   auth_keyr   j  s;     2!Jj  !!!r0   r   c                 .    [        U 5        [        5         g)LogoutN)rR   r   rQ   s    r.   auth_logoutr   v  s     2
Hr0   sitesz'Manage your Anaconda site configurationlistc                  4   [        5       n [        SSSSS9nU R                  R                  5        H8  u  p#X R                  :X  a  [
        OSnUR                  X#R                  U5        M:     [        R                  " U5        [        R                  " S5        g)	z)List configured sites by name and domain.z	Site namezDomain namezDefault siterp   )header_stylerA   z_[dim italic]To view full site details use[/] [dim bold]anaconda sites show \[name or domain][/]N)
r   r   r   itemsdefault_site
CHECK_MARKadd_rowr   r   r,   )sites_configtablerW   site
is_defaults        r.   
sites_listr     sx     +,L+}n<XE"((..0
#'+D+D#DZ"
dKK4 1 MM%MMjr0   showr   zaChoose configured site name or domain name. If unspecified will show the configured default site.)rY   allz--allzShow all site configurationsshow_hiddenzShow hidden fieldsc                    1 SknU(       a  SOUnU(       ak  [        5       nUR                  R                  R                  5        Vs0 s H  nUR                  UR                  US9_M     nn[        R                  " US9  g[         R                  " U S9nUR                  US9nSUR                  0UEn[        R                  " US9  gs  snf )z[Show the site configuration for the default site or look up by the provided name or domain.>   r   keyring	client_idredirect_urihash_hostnamelogin_error_pathlogin_success_pathopenid_config_pathauth_domain_overrideoidc_request_headerspreferred_token_storageN)exclude)r   )r   r   )	r   r   rootvaluesr   
model_dumpr   r   	load_site)	r   r   r   r_   r   r   r   	all_sitesr   s	            r.   
sites_showr     s    F "dvG
')  ++**113
3 KK**7*;;3 	 
 		*(22=   1,t,%
s   $C
yespreserve_existing_keysc                     USL a  U R                  US9  g USL a  U R                  SUS9  g U R                  SUS9  [        R                  " S5      (       a  U R                  US9  g g )NTr   F)dry_runr   zConfirm:)write_configr   r+   )r   r   r   s      r.   _confirm_writer     sr    
 d{2HI	4@VW4@VW;;z""6LM #r0   r   z0Domain name for site, defaults to 'anaconda.com'z1Name for site, defaults to domain if not suppliedr   zSet this site as defaultr   z4API key for site. CAUTION: this will get written to r   r   r   use_truststorez$--use-truststore/--no-use-truststoreextra_headersz4Extra headers in JSON format to use for all requestsr   r   r   r   r   r   use_unified_repo_api_keyz8--use-unified-repo-api-key/--no-use-unified-repo-api-keyr   z$--hash-host-name/--no-hash-host-nameproxy_serversz#JSON string of proxy server mappingclient_certclient_cert_keyuse_device_flowz&--use-device-flow/--no-use-device-flowdisable_conda_auto_configz:--disable-conda-auto-config/--no-disable-conda-auto-configremove_anaconda_comz/Remove the site named 'anaconda.com' if presentz--yes/--dry-runz-yzGConfirm changes and write, use --dry-run to print diff but do not writec                    0 nUc  U	c  OaU(       d  Uc  U	(       a  SUS'   OJUSL a5  U	(       a.  [         R                  " S5        [        R                  " [        S9eUSL a  SUS'   OSUS'   Ub  UUS'   Ub  UUS'   Ub)  S	[        5        S
3n[         R                  " U5        UUS'   U
b   [        R                  " U
5      nUUS'   Ub   [        R                  " U5      nUUS'   Ub  UUS'   Ub  UUS'   Ub  UUS'   Ub  UUS'   Ub  UUS'   Ub  UUS'   Ub  UUS'   Ub@  S[        5        S
3n[         R                  " U5         [        R                  " U5      nUUS'   Ub  UUS'   Ub  UUS'   Ub  UUS'   Ub  UUS'   Ub  UUS'   Ub  UUS '   Ub  UUS!'   [        5       nU R                  R                  S":X  Ga  Uc.  [         R                  " S#5        [        R                  " [        S9eUc  UnUUR                  ;   a2  [         R                  " S$U S%35        [        R                  " [        S9eU(       a1  S&UR                  R                  ;   a  UR                  R                  S&	 [        S,0 UD6n UR!                  U U R"                  S'9  U(       d  [%        UR                  5      S(:X  a  U R"                  Ul        OU R                  R                  S):X  a  Uc1  Uc.  [         R                  " S*5        [        R                  " [        S9eUR                  R)                  U=(       d    U5      n!UR                  R                  U!   n U R+                  US+9n UR!                  U U R"                  S'9  U(       a  U R"                  Ul        [-        UU5        g ! [        R                   a3    [         R                  " SU
 S35        [        R                  " [        S9ef = f! [        R                   a3    [         R                  " SU S35        [        R                  " [        S9ef = f! [        R                   a/    [         R                  " S5        [        R                  " [        S9ef = f)-N
truststorer   Fz4Cannot set both --use-truststore and --no-ssl-verifyrr   Tr   r   zC[bold yellow]WARNING:[/bold yellow] Your API Key will be stored in z and may not be securer   r   zextra-headers=z could not be parsed as JSONr   zproxy-servers=r   r   r   r   r   r   r   zL[bold yellow]WARNING:[/bold yellow] Your Keyring contents will be stored in r   z0The keyring argument could not be parsed as JSONr   r   r   r   r   r   r   addz5You must supply at least --domain to a add a new sitezA site with name z6 already exists, use the modify subcommand to alter itzanaconda.comr   r   modifyzCYou must supply at least one of --domain or --name to modify a site)updaterx   )r   r,   r   r   r   r   rF   loadsr
   r   r   rW   r   r   r   r   r   r   lenr   _find_at
model_copyr   )"r]   r   rW   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   kwargsmsgparsed_extra_headersparsed_proxy_serversparsed_keyringr   r   keys"                                     r.   _sites_add_or_modifyr     s   J  Fn4

*+|	u	LMjjn--	u	$|#|v!x..B.D-EE[] 	 	c#y 	2#'::m#< &:F?#  	2#'::m#< &:F?#  +}"$3 !"$3 !+-E)* ,.G*+*,C()')=%&77K7M6NNdf 	 	c	2!ZZ0N .F9 '{!-~%'9#$')=%&%'9#$#%5!" "/#%E
{{5 >MMQR**.11<D5;;MM#D6)_` **-00>U[[5E5E#E  0!+F+		&v{{	+c%++&!+!'E			X	%>dlMMU **.11kk""4>62!!#&""&"1		&v{{	+!'E5#y ## 	2MMN=/9UVW**.11	2 ## 	2MMN=/9UVW**.11	24 ## 	2MMLM**.11	2s'   +N 
O' P1 AO$'AP.1AQ4r   zAdd new site configuration to )rW   r\   rY   r   zModify site configuration in )rW   r\   z#Site name or domain name to remove.zFConfirm changes and write, use --dry-run to print diff but do no writec                    [        5       n[        UR                  5      S:X  a  U /[        UR                  5      :X  d9  U /UR                  R	                  5        Vs/ s H  o3R
                  PM     sn:X  a1  [        R                  " U  S35        [        R                  " [        S9e UR                  U    nUR                  U 5        UR                  UR                  :X  a#  [!        [#        UR                  5      5      Ul        [%        X!SS9  gs  snf ! [         a@  n[        R                  " UR                  S   5        [        R                  " [        S9eSnAff = f)z,Remove site configuration by name or domain.r   z2 is the only configured site and cannot be removedrr   r   NFr   )r   r   r   r   r   r   r   r,   r   r   r   r   argsrj   r   r   nextiterr   )r   r   r   sr   r5   s         r.   sites_remover     s    $%E 	EKKAVtEKK((F););)=>)=Axx)=>>PQRjjm,,-T"
 
LLV[[(!$u{{"345e< ?  -affQi jjm,,-s   D)D 
E  ;EE r7   )FNNNNNNNNNNNNNNN)FNN)r    N)NFF)T)NNFNNNNNNNNNNNNNNNNNNNNTN)OrF   rO   r(   r   textwrapr   typingr   r   r   r   r   r   requests.exceptionsr	   r
   rich.promptr   rich.syntaxr   
rich.tabler   anaconda_authr   anaconda_auth.actionsr   r   anaconda_auth.clientr   anaconda_auth.configr   r   anaconda_auth.exceptionsr   r   anaconda_auth.tokenr   r   anaconda_cli_base.configr   anaconda_cli_base.consoler   anaconda_cli_base.exceptionsr   r   r   int__annotations__r   r   r/   strr4   	Exceptionr;   r=   rK   rR   TyperappcallbackContextboolOptionArgumentr}   r   r   r   r   r   	sites_appr   r   r   r   	sites_addsites_modifyr   rx   r0   r.   <module>r     s    	 
         ) /    % ' ( + 1 8 6 4 ) 2 9 - ?.
s   c Bc d  *+"i "C " ,"
 )*"Y "3 " +" 	")   #&1x} 1 1
 kk		. "&&-		    AF 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	ew"	w"tU\\$<<=w" 	
	w" 		
	w"( 	
	)w"6 	
	7w"D 	
	Ew"T 
	
	
Uw"b 	
	cw"p 	
	qw"@ 
	
	
Aw"N 	
	Ow"^ 	
	_w"n 	
	ow"~ 	
	w"N 		
	Ow"` cU^^4DDaw"f 
gw"	w"t W-2 	37.T5<<>)*.%CDD.
 	(3-/0. 
. .: (G)HSM5<<>9: Gd G G )"8C=%,,.89 "T " " (IhsmU\\^;<    KK		2 "&&-			      	 	LQ)&
t	
	)& 
W3QRR
)& 43G!HHI)& 
)&  )&^ $(N"N	$N !N 
	N( 	 	NS 	SWPTCG 	 	 	EIHLNRPTNRLP 	 	 	<@@D 	 	 	 	G~	~LM	O~ MN	P~ tU\\/IJJK~ GH\H^G_`	
	~" 'x}ell$6O'OP#~$ $HSM5<<t3L$LM%~& x}ell$&??@'~( %CDD)~. %KLL/~4 PQ	S5~< #D(AAB=~> HSM5<<t+DDE?~@ "(3-T1J"JKA~B $HSM5<<t3L$LMC~D "(3-T1J"JKE~F  u||4/H HIG~H (OP	RI~P ;DI	KQ~X u||)NOOY~^ 8C=%,,.89_~` x}elln<=a~b %MNNc~h  )QR	T i~p #KL	Nq~x 
Z	
	
y~H 
I~B 	)*>*@)A	B   		   	()=)?(@	A !  	 $7 	 =
C-RSS
T =	Y	
	
 = 
 = 8 =r0   