
    ^i+                        d Z 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 ddlmZ ddlmZ ddlmZ dd	lmZmZ dd
lmZ ddlmZ ddlmZ ddlm Z  ddl!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z' erddl(m)Z) ddl*m+Z+ ddl,m-Z- dgZ. G d de      Z/y)z4Module contains the class to create an input prompt.    )TYPE_CHECKINGAnyCallableDictListOptionalTupleUnion)ValidationState)NestedCompleter)	Completer)	Condition)Keys)SimpleLexer)CompleteStylePromptSession)ValidationError)BaseSimplePrompt)INQUIRERPY_POINTER_SEQUENCE)InvalidArgument)InquirerPyDefaultInquirerPyKeybindingsInquirerPyMessageInquirerPySessionResultInquirerPyStyleInquirerPyValidate)Input)KeyPressEvent)OutputInputPromptc            3           e Zd ZdZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d(dedee   dedede	de	d	e	d
e	dee
ee	ee	   f   df      dededee   de	deee	gef      deee	gef      dee   dedededede	dee   ded   ded   ddf2 fdZde	ddfd Zd)d!Zd*d"Z	 	 d+d#eee	e	f      d$eee	e	f      deee	e	f      f fd%Zde	fd&Zdefd'Z xZS ),r    u  Create a text prompt that accepts user input.

    A wrapper class around :class:`~prompt_toolkit.shortcuts.PromptSession`.

    Args:
        message: The question to ask the user.
            Refer to :ref:`pages/dynamic:message` documentation for more details.
        style: An :class:`InquirerPyStyle` instance.
            Refer to :ref:`Style <pages/style:Alternate Syntax>` documentation for more details.
        vi_mode: Use vim keybinding for the prompt.
            Refer to :ref:`pages/kb:Keybindings` documentation for more details.
        default: Set the default text value of the prompt.
            Refer to :ref:`pages/dynamic:default` documentation for more details.
        qmark: Question mark symbol. Custom symbol that will be displayed infront of the question before its answered.
        amark: Answer mark symbol. Custom symbol that will be displayed infront of the question after its answered.
        instruction: Short instruction to display next to the question.
        long_instruction: Long instructions to display at the bottom of the prompt.
        completer: Add auto completion to the prompt.
            Refer to :ref:`pages/prompts/input:Auto Completion` documentation for more details.
        multicolumn_complete: Change the auto-completion UI to a multi column display.
        multiline: Enable multiline edit. While multiline edit is active, pressing `enter` won't complete the answer.
            and will create a new line. Use `esc` followd by `enter` to complete the question.
        validate: Add validation to user input.
            Refer to :ref:`pages/validator:Validator` documentation for more details.
        invalid_message: Error message to display when user input is invalid.
            Refer to :ref:`pages/validator:Validator` documentation for more details.
        transformer: A function which performs additional transformation on the value that gets printed to the terminal.
            Different than `filter` parameter, this is only visual effect and won’t affect the actual value returned by :meth:`~InquirerPy.base.simple.BaseSimplePrompt.execute`.
            Refer to :ref:`pages/dynamic:transformer` documentation for more details.
        filter: A function which performs additional transformation on the result.
            This affects the actual value returned by :meth:`~InquirerPy.base.simple.BaseSimplePrompt.execute`.
            Refer to :ref:`pages/dynamic:filter` documentation for more details.
        keybindings: Customise the builtin keybindings.
            Refer to :ref:`pages/kb:Keybindings` for more details.
        wrap_lines: Soft wrap question lines when question exceeds the terminal width.
        raise_keyboard_interrupt: Raise the :class:`KeyboardInterrupt` exception when `ctrl-c` is pressed. If false, the result
            will be `None` and the question is skiped.
        is_password: Used internally for :class:`~InquirerPy.prompts.secret.SecretPrompt`.
        mandatory: Indicate if the prompt is mandatory. If True, then the question cannot be skipped.
        mandatory_message: Error message to show when user attempts to skip mandatory prompt.
        session_result: Used internally for :ref:`index:Classic Syntax (PyInquirer)`.
        input: Used internally and will be removed in future updates.
        output: Used internally and will be removed in future updates.

    Examples:
        >>> from InquirerPy import inquirer
        >>> result = inquirer.text(message="Enter your name:").execute()
        >>> print(f"Name: {result}")
        Name: Michael
    Nmessagestylevi_modedefaultqmarkamarkinstructionlong_instruction	completerr   multicolumn_complete	multilinevalidateinvalid_messagetransformerfilterkeybindings
wrap_linesraise_keyboard_interruptis_password	mandatorymandatory_messagesession_resultinputr   outputr   returnc                     t            ||||||||||||||||       t         j                  t              s!t        t               j                   d      d  _        t        |	t              rt        j                  |	       _        nt        |	t              r|	 _        | _        |
st        j                  nt        j                    _        t$         fd       }|si }t&        j(                  | dt&        j*                  t&        j(                  g|dgddigd| _        dd	 j.                  igi _         j3                          t5         j6                   j8                   j:                   j                   j<                  d
|| j>                  tA         jB                        | j                   j"                  ||rd|fgnd        _"        y )N)r$   r&   r'   r(   r-   r.   r/   r0   r7   r%   r2   r5   r6   r3   z) argument 'default' should be type of strc                       j                   S )N)
_multilineselfs   b/mnt/e/genesis-system/.venvs/browser-army/lib/python3.12/site-packages/InquirerPy/prompts/input.pyis_multilinez*InputPrompt.__init__.<locals>.is_multiline   s    ??"    )keyr0   rC   zc-space)answer
completionrE   funcFzclass:long_instruction)r"   key_bindingsr#   r*   	validatorvalidate_while_typingr8   r9   editing_modelexerr4   r,   complete_styler2   bottom_toolbar)#super__init__
isinstance_defaultstrr   type__name__
_completerdictr   from_nested_dictr   r=   r   COLUMNMULTI_COLUMN_complete_styler   r   EnterEscapekb_maps_handle_completionkb_func_lookup_keybinding_factoryr   _get_prompt_message_kb_style
_validator_editing_moder   _lexer_session)r?   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   rA   	__class__s   `                         r@   rO   zInputPrompt.__init__U   s   6 	#+#)!/%=! 	 	
$ $---!:&&''PQ  i&->>yIDO	9-'DO# (   ++ 	 
	# 
	# K 

|m<djj1\J "9-.
 
  ,vt7N7N.O-PQ  "%,,++oooo"'++dkk*#oo//! 67GHI#
rB   c                     t         j                  | j                  j                  _        t        |      | j                  j                  _        y )N)r"   )r   INVALIDrg   default_buffervalidation_stater   validation_error)r?   r"   s     r@   
_set_errorzInputPrompt._set_error   s2    8G8O8O$$58GPW8X$$5rB   c                    	 | j                   j                  j                  | j                   j                         d| j                  d<   | j                   j                  j
                  | j                  d<   d| j                   j                  _        |j                  j                  | j                  d          y # t        $ r' | j                   j                  j                          Y y w xY w)NTansweredresult )rq   )
rg   rH   r-   rk   statustextappexitr   validate_and_handle)r?   events     r@   _handle_enterzInputPrompt._handle_enter   s    	9MM##,,T]]-I-IJ '+DKK
#$(MM$@$@$E$EDKK!02DMM((-IINN$++h"7N8  	?MM((<<>	?s   9B< <-C,+C,c                     | j                   y |j                  j                  }|j                  r|j	                          y |j                  d       y )NF)select_first)rU   ru   current_buffercomplete_statecomplete_nextstart_completion)r?   rx   buffs      r@   r^   zInputPrompt._handle_completion   sD    ??"yy'' !!u!5rB   
pre_answerpost_answerc                 J   |s:| j                   r| j                  sd}nd| j                  rd| j                  z  ndf}|s| j                   r~| j                  d   ro| j                  d   j	                  d      }t        |      dkD  r8t        dj                  |dd	             }|d
xx   d|d|dkD  rdnddz  cc<   dd|d
   z  f}ndd| j                  d   z  f}t        | !  ||      }| j                  d   s&| j                   r|j                  ddt        z  f       |S )a;  Get message to display infront of the input buffer.

        Args:
            pre_answer: The formatted text to display before answering the question.
            post_answer: The formatted text to display after answering the question.

        Returns:
            Formatted text in list of tuple format.
        )class:instructionz ESC + Enter to finish inputr   z %s  rq   
   rr   Nr   z...[z chars]zclass:answerz %srp   zclass:questionmarkz
%s )r=   _instructionr(   rs   splitlenjoinrN   ra   appendr   )r?   r   r   linesnumber_of_charsformatted_messagerh   s         r@   ra   zInputPrompt._get_prompt_message   s.    t'8'8R
 (151A1AFT---s
 4;;x#8H-33D9u:>&)"''%)*<&=O!H'.2:! H  .uuQx/?@-ut{{87L/LM!G7
KP{{:&4??$$%w1L'LM ! rB   c                 N    | j                   j                  | j                        S N)r%   )rg   promptrQ   r>   s    r@   _runzInputPrompt._run   s    }}##DMM#::rB   c                 j   K   | j                   j                  | j                         d {   S 7 wr   )rg   prompt_asyncrQ   r>   s    r@   
_run_asynczInputPrompt._run_async   s(     ]]///FFFFs   *313)NFrr   ?r   rr   rr   NFFNzInvalid inputNNNTTFTzMandatory promptNNN)rx   r   r:   N)r:   N)NN)rT   
__module____qualname____doc__r   r   r   boolr   rR   r
   r   r   r   r   r   r   rO   rn   ry   r^   r	   r   ra   r   r   __classcell__)rh   s   @r@   r    r    !   sQ   1l ,0%' "LP%*15.6:157;)-!!3<@#'%)3`
"`
 (`
 	`

 #`
 `
 `
 `
 `
 E$sHSM'9":K"GHI`
 #`
 `
 -.`
 `
 hucz23`
  3%*-.!`
" 34#`
$ %`
& #''`
( )`
* +`
, -`
. !!89/`
0  1`
2 "3`
4 
5`
DY# Y$ Y	96 1515(!U38_-(! eCHo.(! 
eCHo		(!T;c ;G# GrB   N)0r   typingr   r   r   r   r   r   r	   r
   prompt_toolkit.bufferr   prompt_toolkit.completionr   prompt_toolkit.completion.baser   prompt_toolkit.filters.baser   prompt_toolkit.keysr   prompt_toolkit.lexersr   prompt_toolkit.shortcuts.promptr   r   prompt_toolkit.validationr   InquirerPy.baser   InquirerPy.enumr   InquirerPy.exceptionsr   InquirerPy.utilsr   r   r   r   r   r   prompt_toolkit.input.baser   (prompt_toolkit.key_binding.key_processorr   prompt_toolkit.output.baser   __all__r     rB   r@   <module>r      sb    : S S S 1 5 4 1 $ - H 5 , 7 1  /F1/\G" \GrB   