§
    eŠtj{  ã                  óà   — d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 dd	lm
Z
 dd
lmZ ddlmZ ddlmZ ddlmZ  ede¬¦  «        Zg d¢Zd'd„Z	 d(d)d„Zd*d!„Zd+d%„Zd&S ),zTopological sorting algorithms.é    )Úannotations)ÚAny)Ú
Collection)ÚDefaultDict)ÚIterable)ÚIterator)ÚSequence)ÚSet)ÚTuple)ÚTypeVaré   )Úutil)ÚCircularDependencyErrorÚ_T)Úbound)ÚsortÚsort_as_subsetsÚfind_cyclesÚtuplesúCollection[Tuple[_T, _T]]ÚallitemsúCollection[_T]ÚreturnúIterator[Sequence[_T]]c              #  óä  ‡K  — t          j        t          ¦  «        }| D ] \  }}||                              |¦  «         Œ!t	          |¦  «        }t          |¦  «        Š‰r�g }|D ]2}‰                     ||         ¦  «        r|                     |¦  «         Œ3|s,t          dt          | |¦  «        t          |¦  «        ¦  «        ‚‰ 
                    |¦  «         ˆfd„|D ¦   «         }|V — ‰°Žd S d S )NzCircular dependency detected.c                ó   •— g | ]}|‰v ¯|‘Œ	S © r   )Ú.0ÚtÚtodo_sets     €úY/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/sqlalchemy/util/topological.pyú
<listcomp>z#sort_as_subsets.<locals>.<listcomp>6   s   ø€ Ð1Ð1Ð1�a 1¨ = =� = = =ó    )r   ÚdefaultdictÚsetÚaddÚlistÚ
isdisjointÚappendr   r   Ú
_gen_edgesÚdifference_update)	r   r   ÚedgesÚparentÚchildÚtodoÚoutputÚnoder    s	           @r!   r   r      s1  øè è € õ '+Ô&6µsÑ&;Ô&;€EØð !ð !‰ˆ�ØˆeŒ×Ò˜Ñ Ô Ð Ð å�‰>Œ>€DÝ�8‰}Œ}€Hà
ð ØˆØð 	$ð 	$ˆDØ×"Ò" 5¨¤;Ñ/Ô/ð $Ø—’˜dÑ#Ô#Ð#øàð 	Ý)Ø/Ý˜F HÑ-Ô-Ý˜5Ñ!Ô!ñô ð ð 	×"Ò" 6Ñ*Ô*Ð*Ø1Ð1Ð1Ð1˜4Ð1Ñ1Ô1ˆØˆˆˆð ð ð ð ð ð r#   TÚdeterministic_orderÚboolúIterator[_T]c              #  ó@   K  — t          | |¦  «        D ]
}|E d{V —† ŒdS )a,  sort the given list of items by dependency.

    'tuples' is a list of tuples representing a partial ordering.

    deterministic_order is no longer used, the order is now always
    deterministic given the order of "allitems".    the flag is there
    for backwards compatibility with Alembic.

    N)r   )r   r   r2   Úset_s       r!   r   r   :   s>   è è € õ   ¨Ñ1Ô1ð ð ˆØˆˆˆˆˆˆˆˆðð r#   úIterable[Tuple[_T, _T]]úIterable[_T]úSet[_T]c                ó>  — t          j        t          ¦  «        }| D ] \  }}||                              |¦  «         Œ!t          |¦  «        }t          ¦   «         }|D ]À}|g}|                     |¦  «        }	|r¤|d         }
||
         D ]}}||v rG||                     |¦  «        d …         }|	                     |¦  «         |                     |¦  «         ||	v r,|                     |¦  «         |	 	                    |¦  «          nŒ~| 
                    ¦   «          |°¤ŒÁ|S )Néÿÿÿÿ)r   r$   r%   r&   Ú
differenceÚindexr+   Úupdater)   ÚremoveÚpop)r   r   r,   r-   r.   Únodes_to_testr0   r1   Ústackr/   ÚtopÚcycs               r!   r   r   M   sH  € õ '+Ô&6µsÑ&;Ô&;€EØð !ð !‰ˆ�ØˆfŒ×Ò˜%Ñ Ô Ð Ð Ý˜‘J”J€Må‰UŒU€Fð ð ð ˆØ�ˆØ×'Ò'¨Ñ.Ô.ˆØð 	Ø˜”)ˆCØ˜cœ
ð ð �Ø˜5�=�=Ø §¢¨DÑ 1Ô 1Ð 3Ð 3Ô4�CØ×*Ò*¨3Ñ/Ô/Ð/Ø—M’M #Ñ&Ô&Ð&à˜4�<�<Ø—L’L Ñ&Ô&Ð&Ø—K’K Ñ%Ô%Ð%Ø�Eð  ð
 —	’	‘”�ð ð 	øð €Mr#   r,   úDefaultDict[_T, Set[_T]]úSet[Tuple[_T, _T]]c                ó    ‡ — ˆ fd„‰ D ¦   «         S )Nc                ó.   •— h | ]}‰|         D ]}||f’ŒŒS r   r   )r   ÚleftÚrightr,   s      €r!   ú	<setcomp>z_gen_edges.<locals>.<setcomp>x   s.   ø€ ÐEÐEÐE˜d¸¸t¼ÐEÐE°ˆU�DˆMÐEÐEÐEÐEr#   r   )r,   s   `r!   r*   r*   w   s   ø€ ØEÐEÐEÐE eÐEÑEÔEÐEr#   N)r   r   r   r   r   r   )T)r   r   r   r   r2   r3   r   r4   )r   r7   r   r8   r   r9   )r,   rE   r   rF   )Ú__doc__Ú
__future__r   Útypingr   r   r   r   r   r	   r
   r   r   Ú r   Úexcr   r   Ú__all__r   r   r   r*   r   r#   r!   ú<module>rR      so  ðð &Ð %à "Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à Ð Ð Ð Ð Ð Ø )Ð )Ð )Ð )Ð )Ð )à€WˆT˜ÐÑÔ€à
4Ð
4Ð
4€ðð ð ð ð> !%ðð ð ð ð ð&'ð 'ð 'ð 'ðTFð Fð Fð Fð Fð Fr#   