
    <6h                         d dl mZ d dlmZmZmZmZmZ ddlm	Z	 ddl
mZmZ er
ddlmZmZmZ  G d de      Zd	d
ddded   ddfdZy)    )
itemgetter)TYPE_CHECKINGCallable
NamedTupleOptionalSequence   )errors)is_renderable	rich_cast)ConsoleConsoleOptionsRenderableTypec                       e Zd ZU dZeed<   	 eed<   	 edefd       ZddZdedd fdZ	dedd fd	Z
	 ddee   dee   dd fdZe	 	 	 	 	 	 	 	 dd       Zy
)MeasurementzSStores the minimum and maximum widths (in characters) required to render an object.minimummaximumreturnc                 4    | j                   | j                  z
  S )z+Get difference between maximum and minimum.)r   r   )selfs    ]/var/www/panel.atabookie.online/venv/lib/python3.12/site-packages/pip/_vendor/rich/measure.pyspanzMeasurement.span   s     ||dll**    c           
          | \  }}t        t        d|      |      }t        t        d|      t        dt        ||                  S )zGet measurement that ensures that minimum <= maximum and minimum >= 0

        Returns:
            Measurement: A normalized measurement.
        r   )minmaxr   )r   r   r   s      r   	normalizezMeasurement.normalize   sA      c!Wow/3q'?C3w3H,IJJr   widthc                 L    | \  }}t        t        ||      t        ||            S )zGet a RenderableWith where the widths are <= width.

        Args:
            width (int): Maximum desired width.

        Returns:
            Measurement: New Measurement object.
        )r   r   r   r   r   r   s       r   with_maximumzMeasurement.with_maximum"   s)      3w.GU0CDDr   c                 d    | \  }}t        d|      }t        t        ||      t        ||            S )zGet a RenderableWith where the widths are >= width.

        Args:
            width (int): Minimum desired width.

        Returns:
            Measurement: New Measurement object.
        r   )r   r   r    s       r   with_minimumzMeasurement.with_minimum.   s4      Au3w.GU0CDDr   N	min_width	max_widthc                 V    | }||j                  |      }||j                  |      }|S )aN  Clamp a measurement within the specified range.

        Args:
            min_width (int): Minimum desired width, or ``None`` for no minimum. Defaults to None.
            max_width (int): Maximum desired width, or ``None`` for no maximum. Defaults to None.

        Returns:
            Measurement: New Measurement object.
        )r#   r!   )r   r$   r%   measurements       r   clampzMeasurement.clamp;   s;      %229=K %229=Kr   c                    |j                   }|dk  rt        dd      S t        |t              r|j	                  ||j
                  d      }t        |      }t        |      rlt        |dd      }|Q |||      j                         j                  |      }|j                  dk  rt        dd      S |j                         S t        d|      S t        j                  d|d      )	a  Get a measurement for a renderable.

        Args:
            console (~rich.console.Console): Console instance.
            options (~rich.console.ConsoleOptions): Console options.
            renderable (RenderableType): An object that may be rendered with Rich.

        Raises:
            errors.NotRenderableError: If the object is not renderable.

        Returns:
            Measurement: Measurement object containing range of character widths required to render the object.
        r	   r   F)markup	highlight__rich_measure__NzUnable to get render width for zD; a str, Segment, or object with __rich_console__ method is required)r%   r   
isinstancestr
render_strr*   r   r   getattrr   r!   r   r
   NotRenderableError)clsconsoleoptions
renderable
_max_widthget_console_widthrender_widths          r   getzMeasurement.getN   s    " &&
>q!$$j#& ++7>>U , J z*
$ 
$6=  !,%gw7Y[!\*- 
  ''!+&q!,,#--//"1j11++1* @U U r   )r   r   )NN)r3   r   r4   r   r5   r   r   r   )__name__
__module____qualname____doc__int__annotations__propertyr   r   r!   r#   r   r(   classmethodr9    r   r   r   r      s    ]L5L5+c + +K
E# 
E- 
EE# E- E KO!#:B3-	& ++*:+HX+	+ +r   r   r3   r   r4   r   renderablesr   r   c           	      
   |st        dd      S t         j                  }|D cg c]  } || ||       }}t        t        |t        d            j                  t        |t        d            j
                        }|S c c}w )a  Get a measurement that would fit a number of renderables.

    Args:
        console (~rich.console.Console): Console instance.
        options (~rich.console.ConsoleOptions): Console options.
        renderables (Iterable[RenderableType]): One or more renderable objects.

    Returns:
        Measurement: Measurement object containing range of character widths required to
            contain all given renderables.
    r   )keyr	   )r   r9   r   r   r   r   )r3   r4   rC   get_measurementr5   measurementsmeasured_widths          r   measure_renderablesrI   }   s      1a  !ooOHS:D*5L  !Ljm,44Ljm,44N s   B N)operatorr   typingr   r   r   r   r    r
   protocolr   r   r3   r   r   r   r   rI   rB   r   r   <module>rN      s[     J J  .@@o* od *+ 	r   