
    h>                        % S 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JrJrJrJrJrJrJrJr  S
SKJrJrJr  S
SKJrJ r   SSK!J"r"J#r#J$r$J%r%  SSK&J'r'  \(       a@  SSK(r(SSK)J*r*  SSKJ+r+J,r,J-r-  SSK.J/r/  S
SK0J1r1J2r2  \3\4\34   r5\6\/   r7\6\/   r8\6\9\/\2\1-  4      r:Sr;S\<S'   Sr=S\<S'   Sr>S\<S'   S-S jr?S.S jr@\@SSSS.                 S/S  jj5       rA\@SSS!.               S0S" jj5       rB\@SSS!.               S0S# jj5       rC\@SSS!.               S0S$ jj5       rD S1         S2S% jjrE        S3S& jrF                S4S' jrGSSSS(.                       S5S) jjrH\@SSSS.                     S6S* jj5       rI\@SSS!.         S7S+ jj5       rJ\@SSS!.                 S8S, jj5       rKg)9z$Render functions for console output.    )annotationsN)Path)TYPE_CHECKING)IS_INTERACTIVE)ArgumentError)Console)Table   )	CIJUPYTER
accept_tosclean_cache	clean_tosget_all_tosget_channelsget_one_tos
reject_tos)CondaToSMissingErrorCondaToSNonInteractiveErrorCondaToSRejectedError)	CACHE_DIRSEARCH_PATH   )	NULL_CHARaccepted_mappinglocation_mappingversion_mapping)FuzzyPrompt)Iterable)AnyCallableFinal)Channel)	LocalPair
RemotePairz+* Terms of Service version(s) are outdated.r"   TOS_OUTDATEDzBy accessing {channel} with auto acceptance enabled (auto_accept_tos=True) for this repository you acknowledge and agree to the Terms of Service:
{tos_text}TOS_AUTO_ACCEPTED_TEMPLATEzoBy accessing {channel} via CI for this repository you acknowledge and agree to the Terms of Service:
{tos_text}TOS_CI_ACCEPTED_TEMPLATEc                     g)zDUse this no-op printer when nothing should be printed to the screen.N )argskwargss     Alib/python3.13/site-packages/conda_anaconda_tos/console/render.pynoop_printerr.   A   s        c                J   ^  [         R                  " T 5      SU 4S jj5       nU$ )zPass console and printer functions to the decorated function.

This instantiates a console for the render functions if not provided and
the console and json printers to pass them to the decorated function.
c            	       > UR                  S[        5       5      nUR                  SS5      nUR                  SU(       a  [        OUR                  5      nUR                  SUR                  5      nT" U 0 UDUUUUS.D6$ )NconsolejsonFprinterjson_printer)r3   r2   r4   r5   )popr   r.   print
print_json)r+   r,   r2   r3   r4   r5   funcs         r-   wrapperprintable.<locals>.wrapperL   s~    **Y	2zz&%(**Y'--Pzz.'2D2DE

 %
 	
r/   )r+   r    r,   r    returnint)	functoolswraps)r9   r:   s   ` r-   	printabler@   E   s'     __T
 
 Nr/   F)r3   verboser2   c           
       ^ [        5       mTR                  S5        TR                  S5        TR                  S5        TR                  S5        U(       a  TR                  S5        TR                  nOU4S jn0 n	Sn
[        UU US.6 GH+  u  pU(       d6  S	XR                  '   U" UR                  [
        [
        [
        [
        5        MC  0 UR                  R                  S
S9E[        UR                  5      [        UR                  5      S.EXR                  '   U
=(       d    [        UR                  5      n
U" UR                  [        UR                  R                  UR                  5      [        UR                  5      UR                  R                  [!        UR                  5      5        GM.     U(       a  U" U	S9  gU" T5        U
(       a  U" S["         35        g)zGDisplay listing of unaccepted, accepted, and rejected Terms of Service.r#   VersionAcceptedSupportLocationc                 (   > TR                   " U S S 6 $ )N)add_row)r+   tables    r-   <lambda>render_list.<locals>.<lambda>s   s    tCRy 9r/   Ftos_rootcache_timeoutNr3   mode)outdatedpathdataz[bold yellow]r   )r	   
add_columnrI   r   base_urlr   metadata
model_dumpboolremotestrrS   r   versionr   supportr   r&   )rN   rO   r3   rA   r2   r4   r5   channelsrI   json_outputrR   channelmetadata_pairrJ   s                @r-   render_listrc   ^   s    GE	Y	Y	Z 	Y$--9"$KH"-	##
 ,0K(()G$$iIyQ-((333@- !5!56M../-K(()
  =4(<(<#=H   6 6 > >@T@TU !7!78&&.. !3!34#. +&
  	mL>23r/   )r3   r2   c                2   0 n[        U6  HR  n [        UU US9R                  n	U	R                  SS9XxR                  '   U" SU S35        U" U	R
                  5        MT     U(       a  U" US9  g	! [         a    SXxR                  '   U" SU 35         M  f = f)
z9Display the Terms of Service text for the given channels.rM   r3   rP   zviewing Terms of Service for :Nzno Terms of Service for rT   r   )r   r   rX   rY   rW   textr   
rN   rO   r3   r2   r4   r5   r_   r`   ra   rX   s
             r-   render_viewrh      s     #%K*	#"!+ h	  -5,?,?V,?,LK(()3G9A>?HMM" + +& $ 	:,0K(().wi89	:s   A//#BBc                   0 n[        U6  H?  n [        UU US9R                  n	U	R                  SS9XxR                  '   U" SU 35        MA     U(       a  U" US9  g! [
         a    SXxR                  '   U" SU 35         Mw  f = f)	zBDisplay acceptance of the Terms of Service for the given channels.rM   r3   rP   zaccepted Terms of Service for NTerms of Service not found for rT   r   )r   r   rX   rY   rW   r   rg   s
             r-   render_acceptrk           #%K*	@!!+ h	  -5,?,?V,?,LK(()4WI>? + +& $ 	A,0K(()5gY?@	A   A#BBc                   0 n[        U6  H?  n [        UU US9R                  n	U	R                  SS9XxR                  '   U" SU 35        MA     U(       a  U" US9  g! [
         a    SXxR                  '   U" SU 35         Mw  f = f)	zADisplay rejection of the Terms of Service for the given channels.rM   r3   rP   zrejected Terms of Service for Nrj   rT   r   )r   r   rX   rY   rW   r   rg   s
             r-   render_rejectro      rl   rm   c                   SnUR                   (       a(  SnUR                  R                  (       a  SnSU  SU S3n[        R                  " U SU  S3UUS	9nUS
:X  a  gUS:X  a  gUR                  UR                  5        [        XUS5      $ )N z[bold red]rejected[/]z[bold green]accepted[/]zThe Terms of Service for z was previously z0. An updated Terms of Service is now available.
z-Do you accept the Terms of Service (ToS) for ?)choicesr2   acceptTrejectF)(a)ccept(r)eject)r[   rX   tos_acceptedr   askr7   latest_text_prompt_acceptance)ra   pairr2   rs   prologuestateresponses          r-   r{   r{      s     H{{'==%%-E'y0@ H> ? 	
 *A'!LH
 8	X	d&&'!':RSSr/   c                   0 n/ n/ n[        U6  H  n [        X`US9nUR                  (       d  [	        UR
                  SS 5      c  UR                  Xg45        MK  UR
                  R                  (       a'  UR
                  R                  SS9X6R                  '   M  UR                  U5        M     X4U4$ ! [         a     M  f = f)NrM   rx   r3   rP   )
r   r   r   r[   getattrrX   appendrx   rY   rW   )rN   rO   r_   acceptedrejectedchannel_pairsra   r|   s           r-   _gather_tosr     s     HHM*	wWD
 ;;'$--FN   '1]]'')-)A)Av)A)NH%%&OOG$ + },, $ 		s   
B55
CCc                "   U(       a$  U" [         R                  U UR                  S9SS9  g[        (       a$  U" [        R                  U UR                  S9SS9  gU(       d  U(       d  [
        (       d  [        (       d  [        e[        XU5      $ )z<Determine if the Terms of Service is accepted for a channel.)ra   tos_textzbold yellow)styleT)	r'   formatrz   r   r(   r   r   r   r{   ra   r|   auto_accept_tos
always_yes	json_moder2   r4   s          r-   _is_tos_acceptedr   1  s     &--)) .   	
  
r$++)) ,   	
  J'')) gW55r/   )r   r   non_interactivec                4   Uc  0 OUnU	c  / OU	n	U
c  / OU
n
U  HX  u  p [        UUUUUUUS9(       a#  [        UUUS9R                  XR                  '   M=  [	        XUS9  U	R                  U5        MZ     XU
4$ ! [         a    U
R                  U5         M~  f = f)z<Iterate over channel pairs and process the Terms of Service.r   rM   )r   r   rX   rW   r   r   r   )r   rN   rO   r   r   r   r2   r4   r   r   r   ra   r|   s                r-   _process_channel_pairsr   Z  s      %r8H%r8H+3bO&	, /%# .8%"/. (	 ))* 7]S(% ', .. + 	,""7+	,s   5A8A88BBc        	           U(       a  U" S5        [        U	U US.6u  pnU(       a  U" S5        U(       a  U" S[        U5       S35        [        U6 e[        (       a	  U" S5        O[        (       a  U" S5        [        U
UUU UUUUUUS9
u  pnU(       a  [        U6 eU(       a  U" S[        U5       S35        [        U6 eU(       d  U
(       a  U" S	[        U
5       S
35        U(       a  U" U
S9  g)z>Prompt user to accept or reject Terms of Service for channels.z [bold blue]Gathering channels...rM   z"[bold yellow]Reviewing channels...z
[bold red]z" channel Terms of Service rejectedz[bold yellow]CI detected...z [bold yellow]Jupyter detected...)
r   r   r   rN   rO   r   r   r   r2   r4   z[bold green]z" channel Terms of Service acceptedrT   r   )r   lenr   r   r   r   r   )rN   rO   r3   rA   r   r   r2   r4   r5   r_   r   r   r   r   s                 r-   render_interactiver     s    23(3	#)%H 45 *S]O+MNO#X..	r-.	23*@##'+'H )?;;	*S]O+MNO#X..(,s8}o-OPQ(#r/   c                ,   0 n[         US'    [        S[        R                  " [        R                  " 5       5      5      n[        U5      US'   U (       a  U" US9  g
[        SS9nUR                  S5        UR                  S5        UR                  5        H\  u  px[        U[        [        45      (       a   S	R                  [        [        U5      5      nO[        U5      nUR                  Xx5        M^     U" U5        g
! [
         a	    [        n Nf = f)z5Display information about the Terms of Service cache.r   ~r   rT   F)show_headerKeyValue
r   )r   r   r   relative_tohome
ValueErrorr\   r	   rV   items
isinstancetuplelistjoinmaprI   )	r3   r2   r4   r5   rU   relative_dirrJ   keyvalues	            r-   render_infor     s     .0D%D!C!6!6tyy{!CD L)D$  %(!**,JC%%//		#c5/2E
MM#% ' 	%  ! !s   3D   DDc                  U(       d  U (       d  U(       d  [        S5      e0 nU(       d  U (       a;  [        [        [        [	        5       5      5      =US'   n	U" S[        U	5       S35        U(       d  U(       a<  [        [        [        [        U5      5      5      =US'   n
U" S[        U
5       S35        U(       a  U" US9  g)	z%Clean the metadata cache directories.zHAt least one removal target must be given. See 'conda tos clean --help'.cachezRemoved z cache files.tosz Terms of Service files.rT   r   )r   r   r   r\   r   r   r   )r   r   allrN   r3   r2   r4   r5   r`   cache_files	tos_filess              r-   render_cleanr     s     5CV
 	
 #%K
e-1#c;=2I-JJG{(3{+,M:;
c)-c#y7J.K)LLEY(3y>**BCD+&r/   )r+   r    r,   r    r<   None)r9   Callable[..., int]r<   r   )r_   str | ChannelrN   str | os.PathLike[str] | PathrO   int | float | Noner3   rZ   rA   rZ   r2   Console | Noner4   Callable[..., None]r5   r   r<   r=   )r_   r   rN   r   rO   r   r3   rZ   r2   r   r4   r   r5   r   r<   r=   ))rv   rw   z(v)iew)
ra   r#   r|   RemotePair | LocalPairr2   r   rs   zIterable[str]r<   rZ   )r_   r   rN   r   rO   r   r<   z3tuple[AcceptedType, RejectedType, ChannelPairsType])ra   r#   r|   r   r   rZ   r   rZ   r   rZ   r2   r   r4   r   r<   rZ   )r   ChannelPairsTyperN   r   rO   r   r   rZ   r   rZ   r   rZ   r2   r   r4   r   r   zAcceptedType | Noner   zRejectedType | Noner   zNonInteractiveType | Noner<   z5tuple[AcceptedType, RejectedType, NonInteractiveType])r_   r   rN   r   rO   r   r3   rZ   rA   rZ   r   rZ   r   rZ   r2   r   r4   r   r5   r   r<   r=   )
r3   rZ   r2   r   r4   r   r5   r   r<   r=   )r   rZ   r   rZ   r   rZ   rN   r   r3   rZ   r2   r   r4   r   r5   r   r<   r=   )L__doc__
__future__r   r>   pathlibr   typingr   conda.common.ior   conda.exceptionsr   rich.consoler   
rich.tabler	   apir   r   r   r   r   r   r   r   r   
exceptionsr   r   r   rS   r   r   mappersr   r   r   r   promptr   oscollections.abcr   r    r!   r"   conda.models.channelr#   modelsr$   r%   dictr\   AcceptedTyper   RejectedTypeNonInteractiveTyper   r   r&   __annotations__r'   r(   r.   r@   rc   rh   rk   ro   r{   r   r   r   r   r   r   r*   r/   r-   <module>r      s   + "     * *   
 
 
 
 * S S (++,.T	?L=LgE':	+A"ABC De C E  % O2 
 "55+5 &5 	5
 5 5 !5 &5 	5 5p 
 "+ & 	
  ! & 	 > 
 "+ & 	
  ! & 	 < 
 "+ & 	
  ! & 	 D @	TT
 T T 	T
 
T<--+- &-	-<&6&6 !&6 	&6
 &6 &6 &6 !&6 
&6h %)$(15*/#*/ ,*/ &	*/
 */ */ */ */ !*/ "*/ "*/ /*/ ;*/Z 
  #;;+; &; 	;
 ; ; ; ; !; &; 	; ;|  "
  !	
 & 	 B  "	 

 ,   ! & 	 r/   