� ]�gS� ��ddlZddlmZddlmZddlmZmZmZm Z ej dkrddlm Z nddl m Z Gd�de ��Z d ed e e d eefd �Zd ed eedeedeed eef d�Z dd ed eedeeed eefd�ZedkraddlmZeGd�d����Zededdd��eddd��eddd��g��Zeee����dSdS)�N)�Fraction)�ceil)�cast�List�Optional�Sequence)��)�Protocolc�J�eZdZUdZdZeeed<dZeed<dZ eed<dS)�Edgez1Any object that defines an edge (such as Layout).N�size��ratio� minimum_size) �__name__� __module__� __qualname__�__doc__rr�int�__annotations__rr���[/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/rich/_ratio.pyr r sI�������;�;��D�(�3�-�����E�3�N�N�N��L�#�����rr �total�edges�returnc�@�d�|D��}t}d|vr�d�tt||����D��}|td�|D����z }|dkrd�t||��D��S||td�|D������}|D]$\}}||jz|jkr |j||<n8�%|d��} |D](\}}t ||jz| zd��\} } | ||<�)nd|v��ttt|��S) a�Divide total space to satisfy size, ratio, and minimum_size, constraints. The returned list of integers should add up to total in most cases, unless it is impossible to satisfy all the constraints. For instance, if there are two edges with a minimum size of 20 each and `total` is 30 then the returned list will be greater than total. In practice, this would mean that a Layout object would clip the rows that would overflow the screen height. Args: total (int): Total number of characters. edges (List[Edge]): Edges within total space. Returns: List[int]: Number of characters for each edge. c� �g|] }|jpd�� S�N)r)�.0�edges r� <listcomp>z!ratio_resolve.<locals>.<listcomp>%s�� 3� 3� 3�T�d�i��4� 3� 3� 3rNc�&�g|]\}\}}|� ||f��Sr r)r!�indexrr"s rr#z!ratio_resolve.<locals>.<listcomp>,s1�� � � �#��|��d��|��D�M��|�|rc3�K�|]}|pdV�� dS)rNr)r!rs r� <genexpr>z ratio_resolve.<locals>.<genexpr>2s&����<�<�d�� ��<�<�<�<�<�<rrc�.�g|]\}}|� |jpdn|��S)Nr)r)r!rr"s rr#z!ratio_resolve.<locals>.<listcomp>5s;������D�$�.2�\�$�#�(�q��t���rc3�.K�|]\}}|jpdV��dS)rN)r)r!�_r"s rr'z ratio_resolve.<locals>.<genexpr>;s,����K�K���D�D�J�O�!�K�K�K�K�K�Krr) r� enumerate�zip�sumrr�divmodrrr) rr�sizes� _Fraction�flexible_edges� remaining�portionr%r"� remainderrs r� ratio_resolver5s���" 4� 3�U� 3� 3� 3�E��I� �%�-�-� � �'0��U�E�1B�1B�'C�'C� � � �� �C�<�<�e�<�<�<�<�<�<� � ��>�>���"%�e�U�"3�"3���� � �)� �s�K�K�N�K�K�K�K�K� � �� *� � �K�E�4����#�t�'8�8�8�#�0��e� ���9�"� �!� � �I�-� $� $� ��t�"(��4�:�)=� �)I�1�"M�"M���i�#��e� � � �E �%�-�-�H ��S� �5� !� !�!r�ratios�maximums�valuesc�T�d�t||��D��}t|��}|s |dd�S|}g}|j}t|||��D]U\}} } |rB|dkr<t| t ||z|z ����} || | z ��|| z}||z}�J|| ���V|S)adDivide an integer total in to parts based on ratios. Args: total (int): The total to divide. ratios (List[int]): A list of integer ratios. maximums (List[int]): List of maximums values for each slot. values (List[int]): List of values Returns: List[int]: A list of integers guaranteed to sum to total. c� �g|] \}}|r|nd�� S�rr)r!r�_maxs rr#z ratio_reduce.<locals>.<listcomp>_s%�� L� L� L�{�u�d�t�"�e�e�� L� L� LrNr)r,r-�append�min�round) rr6r7r8� total_ratio�total_remaining�resultr=r�maximum�value� distributeds r� ratio_reducerFQs���M� L�c�&�(�6K�6K� L� L� L�F��f�+�+�K� ���a�a�a�y���O��F� �]�F�!$�V�X�v�!>�!>�����w�� � �[�1�_�_��g�u�U�_�-D�{�-R�'S�'S�T�T�K� �F�5�;�&� '� '� '� �{� *�O� �5� �K�K� �F�5�M�M�M�M� �Mr�minimumsc�p�|rd�t||��D��}t|��}|dks Jd���|}g}|j}|�dgt|��z}n|}t||��D]F\}} |dkr$t | t ||z|z ����} n|} || ��||z}|| z}�G|S)a<Distribute an integer total in to parts based on ratios. Args: total (int): The total to divide. ratios (List[int]): A list of integer ratios. minimums (List[int]): List of minimum values for each slot. Returns: List[int]: A list of integers guaranteed to sum to total. c� �g|] \}}|r|nd�� Sr;r)r!r�_mins rr#z$ratio_distribute.<locals>.<listcomp>s%��P�P�P�;�5�$�4�&�%�%�Q�P�P�PrrzSum of ratios must be > 0)r,r-r=�len�maxr) rr6rGr@rA�distributed_totalr=� _minimumsr�minimumrEs r�ratio_distributerPqs����Q�P�P�#�f�h�:O�:O�P�P�P���f�+�+�K� ��?�?�?�7�?�?�?��O�#%�� � %�F����C�#�f�+�+�%� � �� ��f�i�0�0�'�'���w� ��?�?��g�t�E�O�,C�k�,Q�'R�'R�S�S�K�K�)�K���{�����u�� ��;�&��� �r�__main__)� dataclassc�F�eZdZUdZeeed<dZeed<dZeed<dS)�ENrrrr) rrrrrrrrrrrrrTrT�sC�������"��h�s�m�"�"�"���s����� �c�����rrT�nrr )�sys� fractionsr�mathr�typingrrrr� version_infor �typing_extensionsr rr5rFrPr� dataclassesrRrT�resolved�printr-rrr�<module>r_s;�� � � � �������������1�1�1�1�1�1�1�1�1�1�1�1���v����������*�*�*�*�*�*������8����:"��:"�X�d�^�:"��S� �:"�:"�:"�:"�z� ���S� ��-1�#�Y��@D�S� �� �#�Y�����BDH�!�!� �!��S� �!�-5�d�3�i�-@�!� �#�Y�!�!�!�!�H �z���%�%�%�%�%�%����������Y�� �}�S�1�1�T�1�a�=�=�!�!�D�!�Q�-�-���4��A���"O�P�P�H� �E�#�#�h�-�-�������r
Memory