+
    Ri                        R t ^ RIHt ^ RIHtHt ^ RIHt ^ RIH	t	 ^RI
Ht ^RIHtHt . ROt ! R R]4      t ! R R	]R7      t ! R R]4      t ! R R
]4      t ! R R]4      t ! R R]4      t ! R R]4      tR# )zV
Input validation for a `Buffer`.
(Validators will be called before accepting input.)
)annotations)ABCMetaabstractmethod)Callablerun_in_executor_with_context)Document)FilterOrBool	to_filterConditionalValidatorValidationError	ValidatorThreadedValidatorDummyValidatorDynamicValidatorc                  B   a  ] tR t^tRtRR V 3R llltR R ltRtV ;t# )r   z
Error raised by :meth:`.Validator.validate`.

:param cursor_position: The cursor position where the error occurred.
:param message: Text.
c               $    V ^8  d   QhRRRRRR/# )   cursor_positionintmessagestrreturnNone )formats   "X/home/ubuntu/hermes-agent/venv/lib/python3.14/site-packages/prompt_toolkit/validation.py__annotate__ValidationError.__annotate__"   s!       # t     c                	>   < \         SV `  V4       Wn        W n        R # N)super__init__r   r   )selfr   r   	__class__s   &&&r   r#   ValidationError.__init__"   s    !.r   c                   V ^8  d   QhRR/# r   r   r   r   )r   s   "r   r   r   '   s     p p# pr   c                	l    V P                   P                   R V P                  : RV P                  : R2# )z(cursor_position=z
, message=))r%   __name__r   r   r$   s   &r   __repr__ValidationError.__repr__'   s8    ..))**;D<P<P;SS]^b^j^j]mmnoor   r   r   )     )	r+   
__module____qualname____firstlineno____doc__r#   r-   __static_attributes____classcell__)r%   s   @r   r   r      s     
p pr   c                  V    ] tR t^+tRt]R R l4       tR R lt]R
R R ll4       t	Rt
R	# )r   az  
Abstract base class for an input validator.

A validator is typically created in one of the following two ways:

- Either by overriding this class and implementing the `validate` method.
- Or by passing a callable to `Validator.from_callable`.

If the validation takes some time and needs to happen in a background
thread, this can be wrapped in a :class:`.ThreadedValidator`.
c                    V ^8  d   QhRRRR/# r   documentr   r   r   r   )r   s   "r   r   Validator.__annotate__9   s       d r   c                    R# )z
Validate the input.
If invalid, this should raise a :class:`.ValidationError`.

:param document: :class:`~prompt_toolkit.document.Document` instance.
Nr   r$   r;   s   &&r   validateValidator.validate8   s     	r   c                    V ^8  d   QhRRRR/# r:   r   )r   s   "r   r   r<   B   s     	 	X 	$ 	r   c                R   "    V P                  V4       R#   \         d    h i ; i5i)z
Return a `Future` which is set when the validation is ready.
This function can be overloaded in order to provide an asynchronous
implementation.
N)r?   r   r>   s   &&r   validate_asyncValidator.validate_asyncB   s'     	MM(# 		s   ' '$'c               (    V ^8  d   QhRRRRRRRR/# )	r   validate_funcCallable[[str], bool]error_messager   move_cursor_to_endboolr   r   r   )r   s   "r   r   r<   N   s8     X X,X X !	X
 
Xr   c                    \        WV4      # )a  
Create a validator from a simple validate callable. E.g.:

.. code:: python

    def is_valid(text):
        return text in ['hello', 'world']
    Validator.from_callable(is_valid, error_message='Invalid input')

:param validate_func: Callable that takes the input string, and returns
    `True` if the input is valid input.
:param error_message: Message to be displayed if the input is invalid.
:param move_cursor_to_end: Move the cursor to the end of the input, if
    the input is invalid.
)_ValidatorFromCallable)clsrF   rH   rI   s   &&&&r   from_callableValidator.from_callableM   s    , &mDVWWr   r   N)zInvalid inputF)r+   r2   r3   r4   r5   r   r?   rC   classmethodrN   r6   r   r   r   r   r   +   s6    
  	 X Xr   )	metaclassc                  >    ] tR t^ftRtR R ltR R ltR R ltRtR	# )
rL   z(
Validate input from a simple callable.
c               (    V ^8  d   QhRRRRRRRR/# )	r   funcrG   rH   r   rI   rJ   r   r   r   )r   s   "r   r   #_ValidatorFromCallable.__annotate__k   s,     5 5)5:=5SW5	5r   c                	*    Wn         W n        W0n        R # r!   )rT   rH   rI   )r$   rT   rH   rI   s   &&&&r   r#   _ValidatorFromCallable.__init__k   s     	*"4r   c                   V ^8  d   QhRR/# r(   r   )r   s   "r   r   rU   r   s     9 9# 9r   c                	$    R V P                   : R2# )zValidator.from_callable(r*   )rT   r,   s   &r   r-   _ValidatorFromCallable.__repr__r   s    )$))a88r   c                    V ^8  d   QhRRRR/# r:   r   )r   s   "r   r   rU   u   s     U U Ud Ur   c                	    V P                  VP                  4      '       gA   V P                  '       d   \        VP                  4      pM^ p\	        W P
                  R7      hR# )r0   r/   N)rT   textrI   lenr   rH   )r$   r;   indexs   && r   r?   _ValidatorFromCallable.validateu   sJ    yy''&&&HMM*!%ASASTT (r   )rH   rT   rI   N)	r+   r2   r3   r4   r5   r#   r-   r?   r6   r   r   r   rL   rL   f   s    59U Ur   rL   c                  >    ] tR t^tRtR R ltR R ltR R ltRtR	# )
r   z
Wrapper that runs input validation in a thread.
(Use this to prevent the user interface from becoming unresponsive if the
input validation takes too much time.)
c                    V ^8  d   QhRRRR/# )r   	validatorr   r   r   r   )r   s   "r   r   ThreadedValidator.__annotate__   s     # #) # #r   c                	    Wn         R # r!   rc   )r$   rc   s   &&r   r#   ThreadedValidator.__init__   s    "r   c                    V ^8  d   QhRRRR/# r:   r   )r   s   "r   r   rd      s     * * *d *r   c                	<    V P                   P                  V4       R # r!   )rc   r?   r>   s   &&r   r?   ThreadedValidator.validate   s    )r   c                    V ^8  d   QhRRRR/# r:   r   )r   s   "r   r   rd      s     B BX B$ Br   c                P   a a"   R VV 3R llp\        V4      G Rj  xL
  R#  L5i)z*
Run the `validate` function in a thread.
c                   V ^8  d   QhRR/# )r   r   r   r   )r   s   "r   r   6ThreadedValidator.validate_async.<locals>.__annotate__   s     	+ 	+t 	+r   c                 &   < SP                  S 4      # r!   )r?   )r;   r$   s   r   run_validation_thread?ThreadedValidator.validate_async.<locals>.run_validation_thread   s    ==**r   Nr   )r$   r;   rp   s   ff r   rC    ThreadedValidator.validate_async   s!     
	+ 	+ ++@AAAs   &$&rf   N	r+   r2   r3   r4   r5   r#   r?   rC   r6   r   r   r   r   r      s    #*B Br   c                  &    ] tR t^tRtR R ltRtR# )r   z)
Validator class that accepts any input.
c                    V ^8  d   QhRRRR/# r:   r   )r   s   "r   r   DummyValidator.__annotate__   s       d r   c                	    R # r!   r   r>   s   &&r   r?   DummyValidator.validate   s    r   r   N)r+   r2   r3   r4   r5   r?   r6   r   r   r   r   r      s     r   c                  2    ] tR t^tRtR R ltR R ltRtR# )r   ze
Validator that can be switched on/off according to
a filter. (This wraps around another validator.)
c               $    V ^8  d   QhRRRRRR/# )r   rc   r   filterr	   r   r   r   )r   s   "r   r   !ConditionalValidator.__annotate__   s!     ( () (\ (d (r   c                	2    Wn         \        V4      V n        R # r!   )rc   r
   r{   )r$   rc   r{   s   &&&r   r#   ConditionalValidator.__init__   s    "'r   c                    V ^8  d   QhRRRR/# r:   r   )r   s   "r   r   r|      s     . . .d .r   c                	l    V P                  4       '       d   V P                  P                  V4       R # R # r!   )r{   rc   r?   r>   s   &&r   r?   ConditionalValidator.validate   s$    ;;==NN##H- r   )r{   rc   N)r+   r2   r3   r4   r5   r#   r?   r6   r   r   r   r   r      s    
(. .r   c                  >    ] tR t^tRtR R ltR R ltR R ltRtR	# )
r   z
Validator class that can dynamically returns any Validator.

:param get_validator: Callable that returns a :class:`.Validator` instance.
c                    V ^8  d   QhRRRR/# )r   get_validatorzCallable[[], Validator | None]r   r   r   )r   s   "r   r   DynamicValidator.__annotate__   s     + +&D + +r   c                	    Wn         R # r!   r   )r$   r   s   &&r   r#   DynamicValidator.__init__   s    *r   c                    V ^8  d   QhRRRR/# r:   r   )r   s   "r   r   r      s     % % %d %r   c                	l    V P                  4       ;'       g    \        4       pVP                  V4       R # r!   )r   r   r?   r$   r;   rc   s   && r   r?   DynamicValidator.validate   s)    &&(<<N,<	8$r   c                    V ^8  d   QhRRRR/# r:   r   )r   s   "r   r   r      s     1 1X 1$ 1r   c                	   "   V P                  4       ;'       g    \        4       pVP                  V4      G R j  xL
  R #  L5ir!   )r   r   rC   r   s   && r   rC   DynamicValidator.validate_async   s2     &&(<<N,<	&&x000s   7AA Ar   Nrs   r   r   r   r   r      s    +%1 1r   N)r   r   r   r   r   r   )r5   
__future__r   abcr   r   typingr   prompt_toolkit.eventloopr   r;   r   filtersr	   r
   __all__	Exceptionr   r   rL   r   r   r   r   r   r   r   <module>r      s   
 # '  A  ,pi p"8X' 8XvUY U2B	 B0Y .9 . 1y 1r   