
    ͚h                     P    d Z ddlZddlZddlmZmZ ddlmZ  G d d          ZdS )z
Press Enter Primitive Operation

This module provides realistic Enter key press functionality for browser automation.
Simulates human-like key press with natural timing.
    N)DictAny)Pagec            	       >    e Zd ZdZd Zd	dededeee	f         fdZ
dS )

PressEntera:  
    Press Enter Key with Human-like Timing

    Implements realistic Enter key press behavior:
    - Small pre-press delay (hesitation)
    - Natural key press duration
    - Post-press delay for UI response

    Usage:
        presser = PressEnter()
        result = await presser.press(page, base_delay=50)
    c                 $    t          d           dS )z#Initialize the press enter handler.u   ⏎ PressEnter initializedN)print)selfs    >/home/byschii/byschiidev/penelope/lib/primitive/press_enter.py__init__zPressEnter.__init__   s    *+++++    2   page
base_delayreturnc                   K   	 t          d           |t          j        dd          z  }t          j        |dz             d{V  |j                            d           d{V  |t          j        dd          z  }t          j        |dz             d{V  d	d|j        d
}t          d           |S # t          $ r0}dt          |          d}t          d|            |cY d}~S d}~ww xY w)a  
        Press the Enter key at the currently focused element.

        IMPORTANT: The target element should already be clicked/focused before calling this method.

        Args:
            page (Page): Playwright page to use
            base_delay (int): Base delay in milliseconds for timing (default: 50)

        Returns:
            Dict containing press result and timing information
        u   ⏎ Pressing Enter keyg      ?g      ?i  NEnterg      ?g       @T)successkeyurlu   ✅ Enter key pressedF)r   erroru   ❌ Enter key press failed: )
r	   randomuniformasynciosleepkeyboardpressr   	Exceptionstr)r
   r   r   	pre_delay
post_delayresulteerror_results           r   r   zPressEnter.press!   sV     	 *+++ #V^C%=%==I-	D 0111111111 -%%g......... $fnS#&>&>>J-
T 1222222222  x F )***M 	  	  	  Q L 444555	 s   B4B9 9
C3%C.(C3.C3N)r   )__name__
__module____qualname____doc__r   r   intr   r   r   r    r   r   r   r      sc         , , ,*  *  * # * tCH~ *  *  *  *  *  * r   r   )	r(   r   r   typingr   r   patchright.async_apir   r   r*   r   r   <module>r-      s               & & & & & &<  <  <  <  <  <  <  <  <  < r   