
    si                     L    S r SSKJr  SSKJr  \" \5      rS rS r	S r
S	S jrg)
z#Topological sorting implementation.    )reduce)	getLoggerc           	   #   @  #    [        U 5      S:X  a  gU R                  5        H  u  pUR                  U5        M     [        [        R
                  U R                  5       5      [	        U R                  5       5      -
  nU R                  U Vs0 s H  oD[	        5       _M     sn5         [        U R                  5        VVs1 s H  u  pE[        U5      S:X  d  M  UiM     snn5      nU(       d  OOU H  nUv   U R                  US5        M     [        U R                  5       5       H  nU[	        U5      -  nM     M  [        U 5      S:w  aC  SSKJn  SnU" UR                  SR                  S U R                  5        5       5      5      5      egs  snf s  snnf 7f)a'  Dependencies are expressed as a dictionary whose keys are items
and whose values are a set of dependent items. Output is a list of
sets in topological order. The first set consists of items with no
dependences, each subsequent set consists of items that depend upon
items in the preceding sets.
r   N   )CondaValueErrorz/Cyclic dependencies exist among these items: {}z -> c              3   8   #    U  H  n[        U5      v   M     g 7f)N)repr).0xs     5lib/python3.13/site-packages/conda/common/toposort.py	<genexpr>_toposort.<locals>.<genexpr>-   s     4RkT!WWks   )lenitemsdiscard_reducesetunionvalueskeysupdatesortedpop
exceptionsr   formatjoin)	datakvextra_items_in_depsitemdeporderedr   msgs	            r   	_toposortr%      sE     4yA~ 

			!  "#))T[[];c$))+>NNKK)<=)<su)<=>


N94CA$NODJHHT4   $++-(C3w<C )  4yA~0?cjj4Rdiik4R)RSTT	  >Ns%   BFF" FF
F
!B=Fc                     [        U R                  5       S S9nUS   S   nU R                  U5        U R                  5        H  nUR	                  U5        M     U$ )z|
Pop an item from the graph that has the fewest dependencies in the case of a tie
The winners will be sorted alphabetically
c                 (    [        U S   5      U S   4$ )N   r   )r   )r!   s    r   <lambda>pop_key.<locals>.<lambda>5   s    3tAw<a2I    )keyr   )r   r   r   r   r   )r   r   r,   r"   s       r   pop_keyr-   0   sR    
 4::<%IJE
(1+CHHSM{{}C  Jr+   c              #   8  #    [        U 5      S:X  a  g[        U 5      n  [        U5      nUv   M  ! [         aQ  n[        R                  UR                  S   5        U (       d   SnAg[        U 5      v   [        U 5      n SnAMi  SnAf[         a     gf = f7f)a(  Dependencies are expressed as a dictionary whose keys are items
and whose values are a set of dependent items. Output is a list of
sets in topological order. The first set consists of items with no
dependencies, each subsequent set consists of items that depend upon
items in the preceding sets.
r   N)	r   r%   next
ValueErrorlogdebugargsr-   StopIteration)r   tvalueerrs       r   _safe_toposortr8   @   s      4yA~$A
	GEK   
	IIchhqk"$-$A 		sB   B1 B
B)B$B)BBBBBBc                     U R                  5        VVs0 s H  u  p#U[        U5      _M     n nnSU ;   a  U S   R                  S5        U(       a  [        [	        U 5      5      $ [        [        U 5      5      $ s  snnf )Npythonpip)r   r   r   listr8   r%   )r   safer   r   s       r   toposortr>   `   si    "&**,/,$!As1vI,D/4 	Xu%N4())IdO$$ 0s   A8N)T)__doc__	functoolsr   r   loggingr   __name__r1   r%   r-   r8   r>    r+   r   <module>rD      s1    * ' "UJ @%r+   