� l\�g� ����dZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z dd lm Z dd lm Z dd lm Z d d l mZd dlmZe de���Zgd�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�tjt��}|D] \}}||�|���!t |��}t|����r�g}|D]2}��||��r|�|���3|s,tdt||��t|������� |���fd�|D��}|V����dSdS)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>6s���1�1�1�a�1��=�=��=�=�=�) r� defaultdict�set�add�list� isdisjoint�appendrr� _gen_edges�difference_update) rr�edges�parent�child�todo�output�noder s @r!rrs1�����'+�&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] }|Ed{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)rrr2�set_s r!rr:s>���� ���1�1��������������r#�Iterable[Tuple[_T, _T]]� Iterable[_T]�Set[_T]c�>�tjt��}|D] \}}||�|���!t|��}t��}|D]�}|g}|�|��} |r�|d} || D]}}||vrG||�|��d�} | �| ��|�| ��|| vr,|�|��| � |��n�~|� ��}|����|S)N�����) rr$r%r&� difference�indexr+�updater)�remove�pop) rrr,r-r.� nodes_to_testr0r1�stackr/�top�cycs r!rrMsH�� '+�&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� � �y�y�{�{��� #�� �Mr#r,�DefaultDict[_T, Set[_T]]�Set[Tuple[_T, _T]]c� ���fd��D��S)Nc�.��h|]}�|D]}||f���Srr)r�left�rightr,s �r!� <setcomp>z_gen_edges.<locals>.<setcomp>xs.��� E� E� E�d��t�� E� E��U�D�M� E� E� E� Er#r)r,s`r!r*r*ws��� E� E� E� E�e� E� E� E�Er#N)rrrrrr)T)rrrrr2r3rr4)rr7rr8rr9)r,rErrF)�__doc__� __future__r�typingrrrrrr r r r �r�excrr�__all__rrrr*rr#r!�<module>rRso��&�%�"�"�"�"�"�"�������������������������������������������������������������)�)�)�)�)�)� �W�T������ 4� 4� 4������>!%������&'�'�'�'�TF�F�F�F�F�Fr#
Memory