
    Kxh`                        d dl Z d dlmZ d dlmZ d dlmZmZmZm	Z	 e j
        dk    rd dlmZ nd dlmZ  G d de          Zd	ed
e	e         dee         fdZd	edee         dee         dee         dee         f
dZ	 dd	edee         deee                  dee         fdZedk    rad dlmZ e G d d                      Z ed eddd           eddd           eddd          g          Z e ee                     dS dS )    N)Fraction)ceil)castListOptionalSequence)      )Protocolc                   J    e Zd ZU dZdZee         ed<   dZeed<   dZ	eed<   dS )Edgez1Any object that defines an edge (such as Layout).Nsize   ratiominimum_size)
__name__
__module____qualname____doc__r   r   int__annotations__r   r        J/var/www/html/what/lib/python3.11/site-packages/pip/_vendor/rich/_ratio.pyr   r      sI         ;;D(3-E3NNNL#r   r   totaledgesreturnc                 @   d |D             }t           }d|v rd t          t          ||                    D             }| t          d |D                       z
  }|dk    rd t          ||          D             S  ||t          d |D                                 }|D ]$\  }}||j        z  |j        k    r|j        ||<    n8% |d          }	|D ](\  }}t          ||j        z  |	z   d          \  }
}	|
||<   )nd|v t          t          t                   |          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 | ]}|j         pd S N)r   ).0edges     r   
<listcomp>z!ratio_resolve.<locals>.<listcomp>%   s    333Tdi4333r   Nc                 &    g | ]\  }\  }}|
||fS r    r   )r!   indexr   r"   s       r   r#   z!ratio_resolve.<locals>.<listcomp>,   s1     
 
 
#|d| DM||r   c              3      K   | ]}|pd V  	dS )r   Nr   )r!   r   s     r   	<genexpr>z ratio_resolve.<locals>.<genexpr>2   s&      <<d	<<<<<<r   r   c                 .    g | ]\  }}|	|j         pdn|S )Nr   )r   )r!   r   r"   s      r   r#   z!ratio_resolve.<locals>.<listcomp>5   s;       D$ .2\$#(qt  r   c              3   .   K   | ]\  }}|j         pd V  dS )r   N)r   )r!   _r"   s      r   r'   z ratio_resolve.<locals>.<genexpr>;   s,      KKDDJO!KKKKKKr   r   )
r   	enumeratezipsumr   r   divmodr   r   r   )r   r   sizes	_Fractionflexible_edges	remainingportionr%   r"   	remainderr   s              r   ratio_resolver5      s   " 43U333EI %--
 
'0UE1B1B'C'C
 
 
 C<<e<<<<<<	>> "%eU"3"3   
 )sKKNKKKKK
 

 * 	 	KE4#t'888#0e 9 "	!I- $ $t"(4:)=	)I1"M"Mi#eE %--H S	5!!!r   ratiosmaximumsvaluesc                 T   d t          ||          D             }t          |          }|s
|dd         S | }g }|j        }t          |||          D ]U\  }}	}
|rB|dk    r<t          |	t	          ||z  |z                      } ||
|z
             ||z  }||z  }J ||
           V|S )ad  Divide 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|nd S r   r   )r!   r   _maxs      r   r#   z ratio_reduce.<locals>.<listcomp>_   s%    LLL{udt"eeLLLr   Nr   )r,   r-   appendminround)r   r6   r7   r8   total_ratiototal_remainingresultr=   r   maximumvaluedistributeds               r   ratio_reducerF   Q   s     MLc&(6K6KLLLFf++K aaayOF]F!$VXv!>!>  w 	[1__guU_-D{-R'S'STTKF5;&'''{*O5 KKF5MMMMMr   minimumsc                 p   |rd t          ||          D             }t          |          }|dk    s
J d            | }g }|j        }|dgt          |          z  }n|}t          ||          D ]F\  }}	|dk    r$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|nd S r;   r   )r!   r   _mins      r   r#   z$ratio_distribute.<locals>.<listcomp>   s%    PPP;5$4&%%QPPPr   r   zSum of ratios must be > 0)r,   r-   r=   lenmaxr   )r   r6   rG   r@   rA   distributed_totalr=   	_minimumsr   minimumrE   s              r   ratio_distributerP   q   s      QPP#fh:O:OPPPf++K???7???O#%%FC#f++%			fi00 ' 'w??gtEO,Ck,Q'R'RSSKK)K{u;&r   __main__)	dataclassc                   F    e Zd ZU dZee         ed<   dZeed<   dZeed<   dS )ENr   r   r   r   )	r   r   r   r   r   r   r   r   r   r   r   r   rT   rT      sE          #hsm"""scr   rT   n   r   r    )sys	fractionsr   mathr   typingr   r   r   r   version_infor   pip._vendor.typing_extensionsr   r   r5   rF   rP   r   dataclassesrR   rT   resolvedprintr-   r   r   r   <module>r_      s;   



             1 1 1 1 1 1 1 1 1 1 1 1v666666    8   :" :"Xd^ :"S	 :" :" :" :"zS	-1#Y@DS		#Y   B DH! !!S	!-5d3i-@!	#Y! ! ! !H z%%%%%%       Y }S11T1a==!!D!Q--4A"OPPH	E##h-- r   