�
l\�g�
� �� � d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z dd lm
Z
dd
lmZ ddlmZ dd
l
mZ ddlmZ ede�� � Zg d�Zd'd�Z d(d)d�Zd*d!�Zd+d%�Zd&S ),zTopological 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 dt | |� � t |� � � � ���
|� � �fd�|D � � }|V � ���d S d S )NzCircular dependency detected.c � �� g | ]}|�v �|�� S � r )�.0�t�todo_sets ��k/home/asafur/pinokio/api/open-webui.git/app/env/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 �� �dS )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>