ó
    EñiÍ  ã                   óz  • S SK Jr  S SKJr  S SKJrJrJrJrJ	r	   " S S\	5      r
S\S\\
   S\\   4S	 jrS\S
\\   S\\   S\\   S\\   4
S jr SS\S
\\   S\\\      S\\   4S jjr\S:X  aH  S SKJr  \ " S S5      5       r\" S\" SSS5      \" SSS5      \" SSS5      /5      r\" \" \5      5        gg)é    )ÚFraction)Úceil)ÚcastÚListÚOptionalÚSequenceÚProtocolc                   óJ   • \ rS rSr% SrSr\\   \S'   Sr	\\S'   Sr
\\S'   Srg)	ÚEdgeé   z1Any object that defines an edge (such as Layout).NÚsizeé   ÚratioÚminimum_size© )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   ÚintÚ__annotations__r   r   Ú__static_attributes__r   ó    ÚH/home/mande/repo/quber/.venv/lib/python3.13/site-packages/rich/_ratio.pyr   r      s&   ‡ Ù;à€Dˆ(�3‰-ÓØ€Eˆ3ƒNØ€L�#Ör   r   ÚtotalÚedgesÚreturnc                 óÞ  • U Vs/ s H  o"R                   =(       d    SPM     nn[        nSU;   Ga  [        [        X15      5       VVVs/ s H  u  nu  pbUb  M  XR4PM     nnnnU [	        S U 5       5      -
  nUS::  a8  [        X15       VVs/ s H  u  pbUc  UR
                  =(       d    SOUPM!     snn$ U" U[	        S U 5       5      5      n	U H1  u  pRX’R                  -  UR
                  ::  d  M#  UR
                  X5'     O7   U" S5      n
U H&  u  pR[        X’R                  -  U
-   S5      u  pjXcU'   M(     O	SU;   a  GM  [        [        [           U5      $ s  snf s  snnnf s  snnf )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.
Nc              3   ó6   #   • U  H  o=(       d    S v •  M     g7f)r   Nr   )Ú.0r   s     r   Ú	<genexpr>Ú ratio_resolve.<locals>.<genexpr>,   s   é € Ð<²e¨d§	¨¤	²eùs   ‚r   r   c              3   óP   #   • U  H  u  pUR                   =(       d    S v •  M     g7f)r   N)r   )r!   Ú_Úedges      r   r"   r#   5   s   é € ÐKºN±°˜DŸJ™JŸO¨!œOºNùs   ‚$&)r   r   Ú	enumerateÚzipÚsumr   r   Údivmodr   r   r   )r   r   r&   ÚsizesÚ	_FractionÚindexr   Úflexible_edgesÚ	remainingÚportionÚ	remainders              r   Úratio_resolver2      s€  € ñ" .3Ó3ªU T�i‰i×˜4Ò©U€EÐ3ä€Ið �%Œ-ô (1´°UÓ1BÔ'Cõ
â'CÑ#�‘|˜Øó ˆU‹MÙ'Cð 	ò 
ð œCÑ<±eÓ<Ó<Ñ<ˆ	Ø˜‹>ô #& eÔ"3ôâ"3‘J�Dð .2©\�$×#Ñ#×( qø¸tÒCÙ"3òð ñ
 Ø”sÑK¹NÓKÓKó
ˆó
 *‰KˆEØŸ™Ñ# t×'8Ñ'8Õ8Ø#×0Ñ0�‘áñ	 *ñ " !›ˆIÛ-‘�Ü"(¨·:±:Ñ)=À	Ñ)IÈ1Ó"M‘�Ø#�e“ñ  .ð ðE �%Ž-ôH ””S‘	˜5Ó!Ð!ùòS 4ùô
ùós   …EÁ
E"ÁE"Â&E)ÚratiosÚmaximumsÚvaluesc                 ób  • [        X5       VVs/ s H  u  pEU(       a  UOSPM     nnn[        U5      nU(       d  USS $ U n/ nUR                  n	[        XU5       HI  u  pJnU(       a4  US:”  a.  [        U
[	        XG-  U-  5      5      nU	" X¼-
  5        X|-  nXd-  nMA  U	" U5        MK     U$ s  snnf )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.
r   N)r(   r)   ÚappendÚminÚround)r   r3   r4   r5   r   Ú_maxÚtotal_ratioÚtotal_remainingÚresultr7   ÚmaximumÚvalueÚdistributeds                r   Úratio_reducerA   K   s¸   € ô 7:¸&Ô6KÔLÒ6K¡{ u–t‰e Ò"Ñ6K€FÑLÜ�f“+€KÞØ‘aˆyÐØ€OØ€FØ�]‰]€FÜ!$ V°vÖ!>Ñˆ˜Þ�[ 1“_Ü˜g¤u¨UÑ-DÀ{Ñ-RÓ'SÓTˆKÙ�5Ñ&Ô'ØÑ*ˆOØÑ ŠKá�5ŽMñ "?ð €Mùó Ms   �B+NÚminimumsc                 óx  • U(       a(  [        X5       VVs/ s H  u  p4U(       a  UOSPM     nnn[        U5      nUS:”  d   S5       eU n/ nUR                  nUc  S/[        U5      -  n	OUn	[        X5       H8  u  p:US:”  a  [	        U
[        X6-  U-  5      5      nOUnU" U5        XS-  nXk-  nM:     U$ s  snnf )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.
r   zSum of ratios must be > 0)r(   r)   r7   ÚlenÚmaxr   )r   r3   rB   r   Ú_minr;   r<   Údistributed_totalr7   Ú	_minimumsÚminimumr@   s               r   Úratio_distributerJ   k   sÓ   € ö Ü:=¸fÔ:OÔPÒ:O©;¨5ž4‘% QÒ&Ñ:OˆÑPÜ�f“+€KØ˜‹?Ð7Ð7Ó7ˆ?à€OØ#%ÐØ×%Ñ%€FØÑØ�Cœ#˜f›+Ñ%‰	àˆ	Ü˜fÖ0‰ˆØ˜‹?Ü˜g¤t¨EÑ,CÀkÑ,QÓ'RÓS‰Kà)ˆKÙˆ{ÔØÑˆØÑ&Šñ 1ð Ðùó' Qs   –B6Ú__main__)Ú	dataclassc                   óF   • \ rS rSr% Sr\\   \S'   Sr\\S'   Sr	\\S'   Sr
g)ÚEé’   Nr   r   r   r   r   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   rN   rN   ’   s#   ‡ à"ˆˆh�s‰mÓ"Øˆˆs‹Øˆ�cÖr   rN   én   r   )N)Ú	fractionsr   Úmathr   Útypingr   r   r   r   r	   r   r   r2   rA   rJ   r   ÚdataclassesrL   rN   ÚresolvedÚprintr)   r   r   r   Ú<module>rW      s  ðÝ Ý ß ;Õ ;ôˆ8ô ð:"˜ð :" X¨d¡^ð :"¸¸S¹	ô :"ðzØðØ˜S™	ðØ-1°#©YðØ@DÀSÁ	ðà	ˆ#�YôðB DHñ!Øð!Ø˜S™	ð!Ø-5°d¸3±iÑ-@ð!à	ˆ#�Yõ!ðH ˆzÓÝ%à÷ð ó ðñ
 ˜S¡1 T¨1¨a£=±!°D¸!¸Q³-ÁÀ4ÈÈAÃÐ"OÓP€HÙ	‰#ˆh‹-Õð r   