o
    ҷhL                     @  sB  d dl mZ ddlmZmZ d dlmZ d dlZd dlZeG dd dZ	G dd	 d	ej
ZG d
d dej
ZG dd deZ														dVdWd%d&ZdXd'd(Z								dYdZd4d5Z		d[d\d8d9Z					d]d^d;d<Zd_d?d@Z		d[d`dEdFZ										dadbdPdQZ			dcdddTdUZdS )e    )annotations   )event_classT_JSON_DICT)	dataclassNc                   @  sn   e Zd ZU ded< ded< dZded< dZded< dZded< dZded	< dZded
< dd Z	e
dd ZdS )
TouchPointfloatxyNtyping.Optional[float]radius_xradius_yrotation_angleforceid_c                 C  s   t  }| j|d< | j|d< | jd ur| j|d< | jd ur!| j|d< | jd ur+| j|d< | jd ur5| j|d< | jd ur?| j|d< |S )Nr	   r
   radiusXradiusYrotationAngler   id)dictr	   r
   r   r   r   r   r   )selfjson r   `/var/www/html/venv/lib/python3.10/site-packages/selenium/webdriver/common/devtools/v85/input_.pyto_json%   s   











zTouchPoint.to_jsonc              
   C  s   | t |d t |d d|v rt |d nd d|v r t |d nd d|v r+t |d nd d|v r6t |d nd d|v rCt |d dS d dS )	Nr	   r
   r   r   r   r   r   )r	   r
   r   r   r   r   r   )r   clsr   r   r   r   	from_json5   s   

zTouchPoint.from_json)__name__
__module____qualname____annotations__r   r   r   r   r   r   classmethodr   r   r   r   r   r      s   
 r   c                   @  s,   e Zd ZdZdZdZdd Zedd ZdS )	GestureSourceTypedefaulttouchmousec                 C     | j S Nvaluer   r   r   r   r   G      zGestureSourceType.to_jsonc                 C     | |S r(   r   r   r   r   r   r   J      zGestureSourceType.from_jsonN)	r   r   r    DEFAULTTOUCHMOUSEr   r"   r   r   r   r   r   r#   B   s    r#   c                   @  s8   e Zd ZdZdZdZdZdZdZdd Z	e
d	d
 ZdS )MouseButtonnoneleftmiddlerightbackforwardc                 C  r'   r(   r)   r+   r   r   r   r   W   r,   zMouseButton.to_jsonc                 C  r-   r(   r   r   r   r   r   r   Z   r.   zMouseButton.from_jsonN)r   r   r    NONELEFTMIDDLERIGHTBACKFORWARDr   r"   r   r   r   r   r   r2   O   s    r2   c                      s8   e Zd ZdZdddZedddZ fd	d
Z  ZS )TimeSinceEpochz<
    UTC time in seconds, counted from January 1, 1970.
    returnr   c                 C  s   | S r(   r   r+   r   r   r   r   c   s   zTimeSinceEpoch.to_jsonr   c                 C  r-   r(   r   r   r   r   r   r   f   r.   zTimeSinceEpoch.from_jsonc                   s   d t  S )NzTimeSinceEpoch({}))formatsuper__repr__r+   	__class__r   r   rC   j   s   zTimeSinceEpoch.__repr__)r@   r   )r   r   r@   r?   )	r   r   r    __doc__r   r"   r   rC   __classcell__r   r   rD   r   r?   _   s    
r?   type_str	modifierstyping.Optional[int]	timestamptyping.Optional[TimeSinceEpoch]texttyping.Optional[str]unmodified_textkey_identifiercodekeywindows_virtual_key_codenative_virtual_key_codeauto_repeattyping.Optional[bool]	is_keypadis_system_keylocationcommands!typing.Optional[typing.List[str]]r@   0typing.Generator[T_JSON_DICT, T_JSON_DICT, None]c                 c  s   t  }| |d< |dur||d< |dur| |d< |dur"||d< |dur*||d< |dur2||d< |dur:||d< |durB||d	< |durJ||d
< |	durR|	|d< |
durZ|
|d< |durb||d< |durj||d< |durr||d< |durdd |D |d< d|d}|V }dS )a-  
    Dispatches a key event to the page.

    :param type_: Type of the key event.
    :param modifiers: *(Optional)* Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).
    :param timestamp: *(Optional)* Time at which the event occurred.
    :param text: *(Optional)* Text as generated by processing a virtual key code with a keyboard layout. Not needed for for ```keyUp```` and ````rawKeyDown```` events (default: "")
    :param unmodified_text: *(Optional)* Text that would have been generated by the keyboard if no modifiers were pressed (except for shift). Useful for shortcut (accelerator) key handling (default: "").
    :param key_identifier: *(Optional)* Unique key identifier (e.g., 'U+0041') (default: "").
    :param code: *(Optional)* Unique DOM defined string value for each physical key (e.g., 'KeyA') (default: "").
    :param key: *(Optional)* Unique DOM defined string value describing the meaning of the key in the context of active modifiers, keyboard layout, etc (e.g., 'AltGr') (default: "").
    :param windows_virtual_key_code: *(Optional)* Windows virtual key code (default: 0).
    :param native_virtual_key_code: *(Optional)* Native virtual key code (default: 0).
    :param auto_repeat: *(Optional)* Whether the event was generated from auto repeat (default: false).
    :param is_keypad: *(Optional)* Whether the event was generated from the keypad (default: false).
    :param is_system_key: *(Optional)* Whether the event was a system key event (default: false).
    :param location: *(Optional)* Whether the event was from the left or right side of the keyboard. 1=Left, 2=Right (default: 0).
    :param commands: **(EXPERIMENTAL)** *(Optional)* Editing commands to send with the key event (e.g., 'selectAll') (default: []). These are related to but not equal the command names used in ````document.execCommand``` and NSStandardKeyBindingResponding. See https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/core/editing/commands/editor_command_names.h for valid command names.
    typeNrJ   rL   rN   unmodifiedTextkeyIdentifierrR   rS   windowsVirtualKeyCodenativeVirtualKeyCode
autoRepeatisKeypadisSystemKeyrZ   c                 S  s   g | ]}|qS r   r   .0ir   r   r   
<listcomp>   s    z&dispatch_key_event.<locals>.<listcomp>r[   zInput.dispatchKeyEventmethodparamsr   r   )rH   rJ   rL   rN   rP   rQ   rR   rS   rT   rU   rV   rX   rY   rZ   r[   rl   cmd_dictr   r   r   r   dispatch_key_eventn   sF   $
ro   c                 c  $    t  }| |d< d|d}|V }dS )z
    This method emulates inserting text that doesn't come from a key press,
    for example an emoji keyboard or an IME.

    **EXPERIMENTAL**

    :param text: The text to insert.
    rN   zInput.insertTextrj   Nr   )rN   rl   rn   r   r   r   r   insert_text   s   
rr   r	   r   r
   buttontyping.Optional[MouseButton]buttonsclick_countdelta_xr   delta_ypointer_typec                 c  s    t  }| |d< ||d< ||d< |dur||d< |dur"| |d< |dur,| |d< |dur4||d< |dur<||d	< |durD||d
< |	durL|	|d< |
durT|
|d< d|d}|V }dS )a  
    Dispatches a mouse event to the page.

    :param type_: Type of the mouse event.
    :param x: X coordinate of the event relative to the main frame's viewport in CSS pixels.
    :param y: Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to the top of the viewport and Y increases as it proceeds towards the bottom of the viewport.
    :param modifiers: *(Optional)* Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).
    :param timestamp: *(Optional)* Time at which the event occurred.
    :param button: *(Optional)* Mouse button (default: "none").
    :param buttons: *(Optional)* A number indicating which buttons are pressed on the mouse when a mouse event is triggered. Left=1, Right=2, Middle=4, Back=8, Forward=16, None=0.
    :param click_count: *(Optional)* Number of times the mouse button was clicked (default: 0).
    :param delta_x: *(Optional)* X delta in CSS pixels for mouse wheel event (default: 0).
    :param delta_y: *(Optional)* Y delta in CSS pixels for mouse wheel event (default: 0).
    :param pointer_type: *(Optional)* Pointer type (default: "mouse").
    r^   r	   r
   NrJ   rL   rs   ru   
clickCountdeltaXdeltaYpointerTypezInput.dispatchMouseEventrj   rm   )rH   r	   r
   rJ   rL   rs   ru   rv   rw   rx   ry   rl   rn   r   r   r   r   dispatch_mouse_event   s2   
r~   touch_pointstyping.List[TouchPoint]c                 c  sZ    t  }| |d< dd |D |d< |dur||d< |dur#| |d< d|d	}|V }dS )
au  
    Dispatches a touch event to the page.

    :param type_: Type of the touch event. TouchEnd and TouchCancel must not contain any touch points, while TouchStart and TouchMove must contains at least one.
    :param touch_points: Active touch points on the touch device. One event per any changed point (compared to previous touch event in a sequence) is generated, emulating pressing/moving/releasing points one by one.
    :param modifiers: *(Optional)* Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).
    :param timestamp: *(Optional)* Time at which the event occurred.
    r^   c                 S  s   g | ]}|  qS r   )r   rf   r   r   r   ri     s    z(dispatch_touch_event.<locals>.<listcomp>touchPointsNrJ   rL   zInput.dispatchTouchEventrj   rm   )rH   r   rJ   rL   rl   rn   r   r   r   r   dispatch_touch_event  s   
r   intc	                 c  s    t  }	| |	d< ||	d< ||	d< | |	d< |dur | |	d< |dur(||	d< |dur0||	d< |dur8||	d	< |dur@||	d
< d|	d}
|
V }dS )a)  
    Emulates touch event from the mouse event parameters.

    **EXPERIMENTAL**

    :param type_: Type of the mouse event.
    :param x: X coordinate of the mouse pointer in DIP.
    :param y: Y coordinate of the mouse pointer in DIP.
    :param button: Mouse button. Only "none", "left", "right" are supported.
    :param timestamp: *(Optional)* Time at which the event occurred (default: current time).
    :param delta_x: *(Optional)* X delta in DIP for mouse wheel event (default: 0).
    :param delta_y: *(Optional)* Y delta in DIP for mouse wheel event (default: 0).
    :param modifiers: *(Optional)* Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).
    :param click_count: *(Optional)* Number of times the mouse button was clicked (default: 0).
    r^   r	   r
   rs   NrL   r{   r|   rJ   rz   z Input.emulateTouchFromMouseEventrj   rm   )rH   r	   r
   rs   rL   rw   rx   rJ   rv   rl   rn   r   r   r   r   emulate_touch_from_mouse_event  s(   
r   ignoreboolc                 c  rp   )z
    Ignores input events (useful while auditing page).

    :param ignore: Ignores input events processing when set to true.
    r   zInput.setIgnoreInputEventsrj   Nrq   )r   rl   rn   r   r   r   r   set_ignore_input_eventsN  s   
r   scale_factorrelative_speedgesture_source_type"typing.Optional[GestureSourceType]c                 c  sX    t  }| |d< ||d< ||d< |dur||d< |dur"| |d< d|d}|V }dS )	ai  
    Synthesizes a pinch gesture over a time period by issuing appropriate touch events.

    **EXPERIMENTAL**

    :param x: X coordinate of the start of the gesture in CSS pixels.
    :param y: Y coordinate of the start of the gesture in CSS pixels.
    :param scale_factor: Relative scale factor after zooming (>1.0 zooms in, <1.0 zooms out).
    :param relative_speed: *(Optional)* Relative pointer speed in pixels per second (default: 800).
    :param gesture_source_type: *(Optional)* Which type of input events to be generated (default: 'default', which queries the platform for the preferred input type).
    r	   r
   scaleFactorNrelativeSpeedgestureSourceTypezInput.synthesizePinchGesturerj   rm   )r	   r
   r   r   r   rl   rn   r   r   r   r   synthesize_pinch_gesture_  s   
r   
x_distance
y_distancex_overscrolly_overscrollprevent_flingspeedrepeat_countrepeat_delay_msinteraction_marker_namec                 c  s    t  }| |d< ||d< |dur||d< |dur||d< |dur$||d< |dur,||d< |dur4||d< |dur<||d	< |durF| |d
< |	durN|	|d< |
durV|
|d< |dur^||d< d|d}|V }dS )ai  
    Synthesizes a scroll gesture over a time period by issuing appropriate touch events.

    **EXPERIMENTAL**

    :param x: X coordinate of the start of the gesture in CSS pixels.
    :param y: Y coordinate of the start of the gesture in CSS pixels.
    :param x_distance: *(Optional)* The distance to scroll along the X axis (positive to scroll left).
    :param y_distance: *(Optional)* The distance to scroll along the Y axis (positive to scroll up).
    :param x_overscroll: *(Optional)* The number of additional pixels to scroll back along the X axis, in addition to the given distance.
    :param y_overscroll: *(Optional)* The number of additional pixels to scroll back along the Y axis, in addition to the given distance.
    :param prevent_fling: *(Optional)* Prevent fling (default: true).
    :param speed: *(Optional)* Swipe speed in pixels per second (default: 800).
    :param gesture_source_type: *(Optional)* Which type of input events to be generated (default: 'default', which queries the platform for the preferred input type).
    :param repeat_count: *(Optional)* The number of times to repeat the gesture (default: 0).
    :param repeat_delay_ms: *(Optional)* The number of milliseconds delay between each repeat. (default: 250).
    :param interaction_marker_name: *(Optional)* The name of the interaction markers to generate, if not empty (default: "").
    r	   r
   N	xDistance	yDistancexOverscrollyOverscrollpreventFlingr   r   repeatCountrepeatDelayMsinteractionMarkerNamezInput.synthesizeScrollGesturerj   rm   )r	   r
   r   r   r   r   r   r   r   r   r   r   rl   rn   r   r   r   r   synthesize_scroll_gesture  s8    
r   duration	tap_countc                 c  s`    t  }| |d< ||d< |dur||d< |dur||d< |dur&| |d< d|d}|V }dS )	au  
    Synthesizes a tap gesture over a time period by issuing appropriate touch events.

    **EXPERIMENTAL**

    :param x: X coordinate of the start of the gesture in CSS pixels.
    :param y: Y coordinate of the start of the gesture in CSS pixels.
    :param duration: *(Optional)* Duration between touchdown and touchup events in ms (default: 50).
    :param tap_count: *(Optional)* Number of times to perform the tap (e.g. 2 for double tap, default: 1).
    :param gesture_source_type: *(Optional)* Which type of input events to be generated (default: 'default', which queries the platform for the preferred input type).
    r	   r
   Nr   tapCountr   zInput.synthesizeTapGesturerj   rm   )r	   r
   r   r   r   rl   rn   r   r   r   r   synthesize_tap_gesture  s   
r   )NNNNNNNNNNNNNN) rH   rI   rJ   rK   rL   rM   rN   rO   rP   rO   rQ   rO   rR   rO   rS   rO   rT   rK   rU   rK   rV   rW   rX   rW   rY   rW   rZ   rK   r[   r\   r@   r]   )rN   rI   r@   r]   )NNNNNNNN)rH   rI   r	   r   r
   r   rJ   rK   rL   rM   rs   rt   ru   rK   rv   rK   rw   r   rx   r   ry   rO   r@   r]   )NN)
rH   rI   r   r   rJ   rK   rL   rM   r@   r]   )NNNNN)rH   rI   r	   r   r
   r   rs   r2   rL   rM   rw   r   rx   r   rJ   rK   rv   rK   r@   r]   )r   r   r@   r]   )r	   r   r
   r   r   r   r   rK   r   r   r@   r]   )
NNNNNNNNNN)r	   r   r
   r   r   r   r   r   r   r   r   r   r   rW   r   rK   r   r   r   rK   r   rK   r   rO   r@   r]   )NNN)r	   r   r
   r   r   rK   r   rK   r   r   r@   r]   )
__future__r   utilr   r   dataclassesr   enumtypingr   Enumr#   r2   r   r?   ro   rr   r~   r   r   r   r   r   r   r   r   r   r   <module>   s~   4
I:!
0$A