
    kj                        d Z ddlZddlmZ ddlmZmZmZmZ ee	df         Z
 G d de          Z G d dej        	          Z G d
 de          Z G d de          Zdee         dedefdZdeee	                  dee         defdZdeeef         defdZ G d de          Z ed          e_        	  ed          e_        	  ed          e_        	  ed          e_        dS )aN  
This module contains anything related to separators. Currently, it contains an
implementation of "row sep policies", e.g. components that decide if and how to
add an extra separator/spacing between the rows of a definition list (only for
tabular layout). In the future, it may be expanded with something analogous for
help sections.
    N)zip_longest)OptionalProtocolSequenceUnionSepGeneratorc                   "    e Zd ZdZdedefdZdS )r   a  Generate a separator given a width. When used as ``row_sep``, this ``width``
    corresponds to ``HelpFormatter.available_width``, i.e. the line width excluding
    the current indentation width.

    Note: the length of the returned separator may differ from ``width``.
    widthreturnc                     d S N )selfr
   s     O/home/agentuser/manim-venv/lib/python3.11/site-packages/cloup/formatting/sep.py__call__zSepGenerator.__call__   s        N)__name__
__module____qualname____doc__intstrr   r   r   r   r   r      s@         c c      r   c            
       t    e Zd ZdZej        deee                  dee         dede	e         fd            Z
dS )RowSepPolicya  A callable that can be passed as ``row_sep`` to  :class:`HelpFormatter` in
    order to decide *if* a definition list should get a row separator (in
    addition to ``\n``) and *which* separator.

    In practice, the row separator should be the same for all definition lists
    that satisfy a given condition. That's why :class:`RowSepIf`
    exists, you probably want to use that.

    Nonetheless, this protocol exists mainly for one reason: it leaves open the
    door to policies that can decide a row separator for each individual row
    (feature I'm personally against to for now), without breaking changes.
    This would make possible to implement the old Click 7.2 behavior, which
    inserted an empty line only after options with a long help. Adding this
    feature would be possible without breaking changes, by extending the return
    type to ``Union[None, str, Sequence[str]]``.
    rows
col_widthscol_spacingr   c                     dS )zYDecide which row separator to use (eventually none) in the given
        definition list.Nr   r   r   r   r   s       r   r   zRowSepPolicy.__call__-         r   N)r   r   r   r   abcabstractmethodr   r   r   r   r   r   r   r   r   r      sw         " 	Xc]+SM  
#	     r   r   )	metaclassc                   N    e Zd ZdZdeee                  dee         dedefdZdS )RowSepConditionz=Determines when a definition list should use a row separator.r   r   r   r   c                     dS )zrReturn ``True`` if the input definition list should use a row
        separator (in addition to the usual ``\n``).Nr   r   s       r   r   zRowSepCondition.__call__;   r    r   N)	r   r   r   r   r   r   r   boolr   r   r   r   r%   r%   7   s_        GG9Xc]+9SM9 9 
	9 9 9 9 9 9r   r%   c            	       ~    e Zd ZdZ	 ddedeeef         fdZde	e	e                  de	e
         de
d	ee         fd
ZdS )RowSepIfa  
    Inserts a row separator between the rows of a definition list only if a
    condition is satisfied. This class implements the ``RowSepPolicy``
    protocol and does two things:

    - enforces the use of a single row separator for all rows of a
        definition lists and for all definition lists; note that
        ``RowSepPolicy`` doesn't for implementation reasons but it's probably
        what you want;
    - allows you to implement different conditions (see type
        :data:`RowSepCondition`) without worrying about the generation part,
        which is always the same.

    :param condition:
        a :class:`RowSepCondition` that determines when to add the (extra)
        row separator.
    :param sep:
        either a string or a ``SepGenerator``,
        i.e. a function ``(width: int) -> str`` (e.g. :class:`Hline`).
        The empty string corresponds to an empty line separator.
     	conditionsepc                     t          |t                    r$|                    d          rt          d          || _        || _        d S )N
z_sep must not end with '\n'. The formatter writes  a '\n' after it; no other newline is allowed.)
isinstancer   endswith
ValueErrorr+   r,   )r   r+   r,   s      r   __init__zRowSepIf.__init__[   sR    c3 	0CLL$6$6 	0/0 0 0 #r   r   r   r   r   c                     |                      |||          r@t          | j                  r%t          ||          }|                     |          S | j        S d S r   )r+   callabler,   get_total_width)r   r   r   r   total_widths        r   r   zRowSepIf.__call__d   s[     >>$
K88 	!! --j+FFxx,,,8Otr   N)r*   )r   r   r   r   r%   r   r   r   r2   r   r   r   r   r   r   r   r)   r)   D   s         . 24 / C-.   Xc]+9A#UX	#     r   r)   r   r   r   c                 L    t          |           |t          |           dz
  z  z   S )zyReturn the total width of a definition list (or, more generally, a table).
    Useful when implementing a RowSepStrategy.   )sumlen)r   r   s     r   r5   r5   r   s%     z??[C
OOa,?@@@r   r   c                 :    t          fd| D                       S )Nc              3   f   K   | ]+}t          d  t          |          D                       V  ,dS )c              3   B   K   | ]\  }}t          |          |k    V  d S r   )r:   ).0col_text	col_widths      r   	<genexpr>z1count_multiline_rows.<locals>.<genexpr>.<genexpr>}   sM       E E#) MMI% E E E E E Er   N)anyr   )r>   rowr   s     r   rA   z'count_multiline_rows.<locals>.<genexpr>|   sp          	 E E'23
'C'CE E E 	E 	E     r   )r9   )r   r   s    `r   count_multiline_rowsrD   x   s?               r   count_or_percentagec                    | dk    rt          d          t          | t                    rF| dt          t          t                            dt          t                   dt          dt
          ffd}nt          | t                    r_| dk    rt          d	 d
          dt          t          t                            dt          t                   dt          dt
          ffd}nt          d          |S )a  
    Return a ``RowSepStrategy`` that returns a row separator between all rows
    of a definition list, only if the number of rows taking multiple lines is
    greater than or equal to a certain threshold.

    :param count_or_percentage:
        a threshold for multiline rows above which the returned strategy will
        insert a row separator. It can be either an absolute count (`int`) or a
        percentage relative to the total number of rows expressed as a `float`
        between 0 and 1 (0 and 1 excluded).
    r   z!count_or_percentage should be > 0r   r   r   r   c                 0    t          | |          }|k    S r   )rD   )r   r   r   num_multilinecount_thresholds       r   r+   z.multiline_rows_are_at_least.<locals>.condition   s    
 1zBBM O33r   g      ?zlcount_or_percentage must be either an integer or a float in the interval ]0, 1[. You passed a float >= 1.0 (z).c                 T    t          | |          }|t          |           z  }|k    S r   )rD   r:   )r   r   r   rH   percent_multilinepercent_thresholds        r   r+   z.multiline_rows_are_at_least.<locals>.condition   s1    
 1zBBM -D		 9$(999r   z-count_or_percentage must be an int or a float)r1   r/   r   r   r   r'   float	TypeError)rE   r+   rI   rL   s     @@r   multiline_rows_are_at_leastrO      sO    a<===%s++ I-	48C=)	4 	4 	4 		4 	4 	4 	4 	4 	4 	4 
'	/	/ I/s""U?PU U UV V V	:8C=)	: 	: 	: 		: 	: 	: 	: 	: 	: 	: GHHHr   c                   X    e Zd ZU dZd ed<   d ed<   d ed<   d ed<   defdZded	efd
ZdS )Hlineae  Returns a function that generates an horizontal line of a given length.

    This class has different static members for different line styles
    like ``Hline.solid``, ``Hline.dashed``, ``Hline.densely_dashed``
    and  ``Hline.dotted``.

    :param pattern:
        a string (usually a single character) that is repeated to generate
        the line.
    soliddasheddensely_dasheddottedpatternc                     || _         d S r   )rV   )r   rV   s     r   r2   zHline.__init__   s    r   r
   r   c                     | j         }t          |          dk    r||z  S |t          |          z  |t          |          z  }}||z  |d |         z   S )Nr8   )rV   r:   )r   r
   rV   repsrests        r   r   zHline.__call__   sZ    ,w<<1U?"c'll*ECLL,@d~..r   N)	r   r   r   r   __annotations__r   r2   r   r   r   r   r   rQ   rQ      s         	 	 NNNOOOOOO    /c /c / / / / / /r   rQ   u   ─-u   ╌u   ┄)r   r!   	itertoolsr   typingr   r   r   r   r   SepTyper   ABCMetar   r%   r)   r   r5   rD   rM   rO   rQ   rR   rS   rT   rU   r   r   r   <module>ra      s     


 ! ! ! ! ! ! 6 6 6 6 6 6 6 6 6 6 6 6
^#
$	 	 	 	 	8 	 	 	    S[    8
9 
9 
9 
9 
9h 
9 
9 
9( ( ( ( (| ( ( (\A AC AC A A A Ax6 HSM VY    .sEz*.. . . .b/ / / / /L / / /: eEll 6uSzz &uU||  6uU|| 6 6r   