
    eg',                        d dl mZmZmZmZmZmZmZmZ ddl	m
Z
 ddlmZ ddlmZmZ  ed      Z ed      Z G d d	e      Z G d
 de      Z G d dee         Z G d dee         Z G d dee         Z G d dee         Z G d dee         Zedk(  rd dlmZ ejA                  dd      r	 ejA                  dd      Z!e!dk\  re!dk  rn	 ed       ' ede!        	 ejA                  d d!      Z" e#e"      dk\  rn	 ed"       ( ed#e"       ejA                  d$g d%&      Z$ ed'e$       y) ed(       y)y))*    )AnyGenericListOptionalTextIOTypeVarUnionoverload   )get_console)Console)TextTextType
PromptTypeDefaultTypec                       e Zd ZdZy)PromptErrorz/Exception base class for prompt related errors.N)__name__
__module____qualname____doc__     t/var/www/html/FastMealFinder_FlaskServer-InitialRelease/venv/lib/python3.12/site-packages/pip/_vendor/rich/prompt.pyr   r      s    9r   r   c                   ,    e Zd ZdZdeddfdZdefdZy)InvalidResponsezException to indicate a response was invalid. Raise this within process_response() to indicate an error
    and provide an error message.

    Args:
        message (Union[str, Text]): Error message.
    messagereturnNc                     || _         y Nr   )selfr   s     r   __init__zInvalidResponse.__init__   s	    r   c                     | j                   S r    r!   r"   s    r   __rich__zInvalidResponse.__rich__   s    ||r   )r   r   r   r   r   r#   r&   r   r   r   r   r      s&     T ( r   r   c                      e Zd ZU dZeZeed<   dZdZ	dZ
dZeee      ed<   	 d(dddd	d	d
dedee   dedeee      dededdfdZee	 d(dddd	d	dddedee   dedeee      dedededee   deeef   fd              Zee	 d(dddd	d	dddedee   dedeee      dededee   defd              Ze	 d(dddd	d	ddddedee   dedeee      dedededee   defd       ZdedefdZdedefdZe	 d)dedededee   def
d       ZdedefdZdedefdZded e ddfd!Z!d*d"Z"edd#dee   defd$       Z#edd#dedee   deeef   fd%       Z#ddd&dedee   defd'Z#y)+
PromptBasea  Ask the user for input until a valid response is received. This is the base class, see one of
    the concrete classes for examples.

    Args:
        prompt (TextType, optional): Prompt text. Defaults to "".
        console (Console, optional): A Console instance or None to use global console. Defaults to None.
        password (bool, optional): Enable password input. Defaults to False.
        choices (List[str], optional): A list of valid choices. Defaults to None.
        show_default (bool, optional): Show default in prompt. Defaults to True.
        show_choices (bool, optional): Show choices in prompt. Defaults to True.
    response_typez*[prompt.invalid]Please enter a valid valuezA[prompt.invalid.choice]Please select one of the available optionsz: NchoicesFTconsolepasswordr*   show_defaultshow_choicespromptr,   r-   r.   r/   r   c                    |xs
 t               | _        t        |t              rt	        j
                  |d      n|| _        || _        ||| _        || _	        || _
        y )Nr0   style)r   r,   
isinstancestrr   from_markupr0   r-   r*   r.   r/   )r"   r0   r,   r-   r*   r.   r/   s          r   r#   zPromptBase.__init__5   s`     /+- &#& V84 	
 !"DL((r   )r,   r-   r*   r.   r/   streamdefaultr7   c                     y r    r   )	clsr0   r,   r-   r*   r.   r/   r8   r7   s	            r   askzPromptBase.askK   s     	r   c                     y r    r   )r:   r0   r,   r-   r*   r.   r/   r7   s           r   r;   zPromptBase.ask[   s     	r   .)r,   r-   r*   r.   r/   r8   r7   c                2     | ||||||      }	 |	||      S )a  Shortcut to construct and run a prompt loop and return the result.

        Example:
            >>> filename = Prompt.ask("Enter a filename")

        Args:
            prompt (TextType, optional): Prompt text. Defaults to "".
            console (Console, optional): A Console instance or None to use global console. Defaults to None.
            password (bool, optional): Enable password input. Defaults to False.
            choices (List[str], optional): A list of valid choices. Defaults to None.
            show_default (bool, optional): Show default in prompt. Defaults to True.
            show_choices (bool, optional): Show choices in prompt. Defaults to True.
            stream (TextIO, optional): Optional text file open for reading to get input. Defaults to None.
        r+   r8   r7   r   )
r:   r0   r,   r-   r*   r.   r/   r8   r7   _prompts
             r   r;   zPromptBase.askj   s/    6 %%
 wv66r   c                 "    t        d| dd      S )zTurn the supplied default in to a Text instance.

        Args:
            default (DefaultType): Default value.

        Returns:
            Text: Text containing rendering of default value.
        ()prompt.default)r   )r"   r8   s     r   render_defaultzPromptBase.render_default   s     ayN$455r   c                    | j                   j                         }d|_        | j                  rP| j                  rDdj                  | j                        }d| d}|j                  d       |j                  |d       |dk7  r[| j                  rOt        |t        | j                  f      r3|j                  d       | j                  |      }|j                  |       |j                  | j                         |S )zMake prompt text.

        Args:
            default (DefaultType): Default value.

        Returns:
            Text: Text to display in prompt.
         /[] zprompt.choices.)r0   copyendr/   r*   joinappendr.   r4   r5   r)   rD   prompt_suffix)r"   r8   r0   _choicesr*   _defaults         r   make_promptzPromptBase.make_prompt   s     !!#
xx-H(1oGMM#MM'#34 sN!!7S$*<*<$=>MM#**73HMM(#d(()r   c                 *    |j                  |||      S )zGet input from user.

        Args:
            console (Console): Console instance.
            prompt (TextType): Prompt text.
            password (bool): Enable password entry.

        Returns:
            str: String from user.
        )r-   r7   )input)r:   r,   r0   r-   r7   s        r   	get_inputzPromptBase.get_input   s    $ }}Vhv}FFr   valuec                 V    | j                   J |j                         | j                   v S )zCheck value is in the list of valid choices.

        Args:
            value (str): Value entered by user.

        Returns:
            bool: True if choice was valid, otherwise False.
        )r*   stripr"   rV   s     r   check_choicezPromptBase.check_choice   s)     ||'''{{},,r   c                     |j                         }	 | j                  |      }| j
                  &| j                  |      st        | j                        |S # t        $ r t        | j                        w xY w)a  Process response from user, convert to prompt type.

        Args:
            value (str): String typed by user.

        Raises:
            InvalidResponse: If ``value`` is invalid.

        Returns:
            PromptType: The value to be returned from ask method.
        )rX   r)   
ValueErrorr   validate_error_messager*   rZ   illegal_choice_message)r"   rV   return_values      r   process_responsezPromptBase.process_response   sv     	?'+'9'9%'@L <<#D,=,=e,D!$"="=>>  	?!$"="=>>	?s   A A6errorc                 :    | j                   j                  |       y)zCalled to handle validation error.

        Args:
            value (str): String entered by user.
            error (InvalidResponse): Exception instance the initiated the error.
        N)r,   print)r"   rV   ra   s      r   on_validate_errorzPromptBase.on_validate_error   s     	5!r   c                      y)z,Hook to display something before the prompt.Nr   r%   s    r   
pre_promptzPromptBase.pre_prompt   s    r   r7   c                     y r    r   )r"   r7   s     r   __call__zPromptBase.__call__   s    r   c                     y r    r   )r"   r8   r7   s      r   ri   zPromptBase.__call__   s     	r   r>   c                (   	 | j                          | j                  |      }| j                  | j                  || j                  |      }|dk(  r|dk7  r|S 	 | j                  |      }|S # t        $ r}| j                  ||       Y d}~d}~ww xY w)zRun the prompt loop.

        Args:
            default (Any, optional): Optional default value.

        Returns:
            PromptType: Processed value.
        rg   rF   .N)rf   rR   rU   r,   r-   r`   r   rd   )r"   r8   r7   r0   rV   r_   ra   s          r   ri   zPromptBase.__call__  s     OO%%g.FNN4<<vNVE{w#~$#44U;
 $#	 # &&ue4s   A, ,	B5BB)rF   r    )r   N)$r   r   r   r   r5   r)   type__annotations__r]   r^   rO   r*   r   r   r   r   boolr#   classmethodr
   r   r   r	   r   r;   r   r   rD   rR   rU   rZ   r`   r   rd   rf   ri   r   r   r   r(   r(      s   
 M4IK  M#'GXd3i ' ) &*'+!!)) '"	)
 ) $s)$) ) ) 
),   &*'+!!#' '"	
  $s)$      
{J&	'     &*'+!!#' '"	
  $s)$     
    "7 &*'+!!#'"7"7 '"	"7
 "7 $s)$"7 "7 "7 "7  "7 
"7 "7H	6k 	6d 	6; 4 >  $(GG G 	G
  G 
G G&
-# 
-$ 
-c j ."s "? "t "; 59 (6"2 j   BF%/7/?	z;&	' 
 *- $3 $hv6F $RU $r   r(   c                       e Zd ZdZeZy)PromptzbA prompt that returns a str.

    Example:
        >>> name = Prompt.ask("Enter your name")


    N)r   r   r   r   r5   r)   r   r   r   rq   rq     s     Mr   rq   c                       e Zd ZdZeZdZy)	IntPromptzA prompt that returns an integer.

    Example:
        >>> burrito_count = IntPrompt.ask("How many burritos do you want to order")

    z3[prompt.invalid]Please enter a valid integer numberN)r   r   r   r   intr)   r]   r   r   r   rs   rs   *  s     MRr   rs   c                       e Zd ZdZeZdZy)FloatPromptzyA prompt that returns a float.

    Example:
        >>> temperature = FloatPrompt.ask("Enter desired temperature")

    z%[prompt.invalid]Please enter a numberN)r   r   r   r   floatr)   r]   r   r   r   rv   rv   6  s     MDr   rv   c                   R    e Zd ZU dZeZdZddgZee	   e
d<   dedefdZd	e	defd
Zy)ConfirmzuA yes / no confirmation prompt.

    Example:
        >>> if Confirm.ask("Continue"):
                run_job()

    z#[prompt.invalid]Please enter Y or Nynr*   r8   r   c                 ^    | j                   \  }}t        |rd| dd      S d| dd      S )z8Render the default as (y) or (n) rather than True/False.rA   rB   rC   r2   )r*   r   )r"   r8   yesnos       r   rD   zConfirm.render_defaultO  s:    ,,R'auAJ@PQQ2$ay@PQQr   rV   c                     |j                         j                         }|| j                  vrt        | j                        || j                  d   k(  S )zConvert choices to a bool.r   )rX   lowerr*   r   r]   rY   s     r   r`   zConfirm.process_responseT  sF    ##%$!$"="=>>Q''r   N)r   r   r   r   rn   r)   r]   r*   r   r5   rm   r   r   rD   r`   r   r   r   ry   ry   B  sO     MBsGT#Y#Rk Rd R
(c (d (r   ry   __main__)rc   zRun [i]prompt[/i] tests?T)r8   z6:rocket: Enter a number between [b]1[/b] and [b]10[/b]   
   z=:pile_of_poo: [prompt.invalid]Number must be between 1 and 10znumber=z=Please enter a password [cyan](must be at least 5 characters))r-   z"[prompt.invalid]password too shortz	password=zEnter a fruit)appleorangepear)r*   zfruit=z[b]OK :loudly_crying_face:N)%typingr   r   r   r   r   r   r	   r
   rF   r   r,   r   textr   r   r   r   	Exceptionr   r   r(   r5   rq   rt   rs   rv   rn   ry   r   pip._vendor.richrc   r;   resultr-   lenfruitr   r   r   <module>r      s   Q Q Q    \"
m$:) :k }$$ }$@	Z_ 		S
3 	S	E*S/ 	E(j (4 z&{{-t{<]]HRS # F {v|QR  	x !zzO " H 8}!67  		(&'

?4O
Pui ! 	*+9 r   