o
    ҷhm                     @  s  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eG dd dZeG dd dZ	dpdqddZ														drdsd/d0Zdtd1d2Z		dudvd8d9Z													dwdxdGdHZ		dudydKdLZdzdMdNZ					d{d|dOdPZd}dSdTZd~dVdWZ		dudd\d]Z										dddgdhZ			dddkdlZedmeG dndo doZdS )    )annotations   )event_classT_JSON_DICT)	dataclassNc                   @  s   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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tangential_pressuretyping.Optional[int]tilt_xtilt_ytwist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< | jd urI| j|d< | j	d urS| j	|d	< | j
d ur]| j
|d
< | jd urg| j|d< |S )Nr	   r
   radiusXradiusYrotationAngler   tangentialPressuretiltXtiltYr   id)dictr	   r
   r   r   r   r   r   r   r   r   r   selfjson r!   a/var/www/html/venv/lib/python3.10/site-packages/selenium/webdriver/common/devtools/v119/input_.pyto_json1   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 rAt |d nd d|v rLt|d nd d	|v rWt|d	 nd d
|v rbt|d
 nd d|v rot |d dS d dS )Nr	   r
   r   r   r   r   r   r   r   r   r   )r	   r
   r   r   r   r   r   r   r   r   r   )r   intclsr    r!   r!   r"   	from_jsonI   s   

zTouchPoint.from_json)__name__
__module____qualname____annotations__r   r   r   r   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#   _      zGestureSourceType.to_jsonc                 C     | |S r2   r!   r%   r!   r!   r"   r'   b      zGestureSourceType.from_jsonN)	r(   r)   r*   DEFAULTTOUCHMOUSEr#   r,   r'   r!   r!   r!   r"   r-   Z   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  r1   r2   r3   r5   r!   r!   r"   r#   o   r6   zMouseButton.to_jsonc                 C  r7   r2   r!   r%   r!   r!   r"   r'   r   r8   zMouseButton.from_jsonN)r(   r)   r*   NONELEFTMIDDLERIGHTBACKFORWARDr#   r,   r'   r!   r!   r!   r"   r<   g   s    r<   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 r2   r!   r5   r!   r!   r"   r#   {   s   zTimeSinceEpoch.to_jsonr    c                 C  r7   r2   r!   r%   r!   r!   r"   r'   ~   r8   zTimeSinceEpoch.from_jsonc                   s   d t  S )NzTimeSinceEpoch({}))formatsuper__repr__r5   	__class__r!   r"   rM      s   zTimeSinceEpoch.__repr__)rJ   r   )r    r   rJ   rI   )	r(   r)   r*   __doc__r#   r,   r'   rM   __classcell__r!   r!   rN   r"   rI   w   s    
rI   c                   @  sJ   e Zd ZU ded< ded< dZded< dZded< dd	 Zed
d ZdS )DragDataItemstr	mime_typedataNtyping.Optional[str]titlebase_urlc                 C  sF   t  }| j|d< | j|d< | jd ur| j|d< | jd ur!| j|d< |S )NmimeTyperU   rW   baseURL)r   rT   rU   rW   rX   r   r!   r!   r"   r#      s   





zDragDataItem.to_jsonc                 C  sL   | t |d t |d d|v rt |d nd d|v r"t |d dS d dS )NrY   rU   rW   rZ   )rT   rU   rW   rX   rS   r%   r!   r!   r"   r'      s   

zDragDataItem.from_json)	r(   r)   r*   r+   rW   rX   r#   r,   r'   r!   r!   r!   r"   rR      s   
 
rR   c                   @  s>   e Zd ZU ded< ded< dZded< dd	 Zed
d ZdS )DragDataztyping.List[DragDataItem]itemsr$   drag_operations_maskN!typing.Optional[typing.List[str]]filesc                 C  sF   t  }dd | jD |d< | j|d< | jd ur!dd | jD |d< |S )Nc                 S     g | ]}|  qS r!   r#   .0ir!   r!   r"   
<listcomp>       z$DragData.to_json.<locals>.<listcomp>r]   dragOperationsMaskc                 S     g | ]}|qS r!   r!   rc   r!   r!   r"   rf          r`   )r   r]   r^   r`   r   r!   r!   r"   r#      s   

zDragData.to_jsonc                 C  sB   | dd |d D t |d d|v rdd |d D dS d dS )Nc                 S  s   g | ]}t |qS r!   )rR   r'   rc   r!   r!   r"   rf      s    z&DragData.from_json.<locals>.<listcomp>r]   rh   r`   c                 S  s   g | ]}t |qS r!   r[   rc   r!   r!   r"   rf      rg   )r]   r^   r`   )r$   r%   r!   r!   r"   r'      s   
zDragData.from_json)r(   r)   r*   r+   r`   r#   r,   r'   r!   r!   r!   r"   r\      s   
 r\   type_rS   r	   r   r
   rU   	modifiersr   rJ   0typing.Generator[T_JSON_DICT, T_JSON_DICT, None]c                 c  sP    t  }| |d< ||d< ||d< | |d< |dur||d< d|d}|V }dS )	a)  
    Dispatches a drag event into the page.

    **EXPERIMENTAL**

    :param type_: Type of the drag 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 data:
    :param modifiers: *(Optional)* Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).
    typer	   r
   rU   Nrl   zInput.dispatchDragEventmethodparamsr   r#   )rk   r	   r
   rU   rl   rq   cmd_dictr    r!   r!   r"   dispatch_drag_event   s   
rt   	timestamptyping.Optional[TimeSinceEpoch]textrV   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commandsr_   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/+/main:third_party/blink/renderer/core/editing/commands/editor_command_names.h for valid command names.
    rn   Nrl   ru   rw   unmodifiedTextkeyIdentifierrz   r{   windowsVirtualKeyCodenativeVirtualKeyCode
autoRepeatisKeypadisSystemKeyr   c                 S  ri   r!   r!   rc   r!   r!   r"   rf   &  rj   z&dispatch_key_event.<locals>.<listcomp>r   zInput.dispatchKeyEventro   rr   )rk   rl   ru   rw   rx   ry   rz   r{   r|   r}   r~   r   r   r   r   rq   rs   r    r!   r!   r"   dispatch_key_event   sF   $
r   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.
    rw   zInput.insertTextro   Nr   )rw   rq   rs   r    r!   r!   r"   insert_text.     
r   selection_startr$   selection_endreplacement_startreplacement_endc                 c  sT    t  }| |d< ||d< ||d< |dur||d< |dur ||d< d|d}|V }dS )	a  
    This method sets the current candidate text for ime.
    Use imeCommitComposition to commit the final text.
    Use imeSetComposition with empty string as text to cancel composition.

    **EXPERIMENTAL**

    :param text: The text to insert
    :param selection_start: selection start
    :param selection_end: selection end
    :param replacement_start: *(Optional)* replacement start
    :param replacement_end: *(Optional)* replacement end
    rw   selectionStartselectionEndNreplacementStartreplacementEndzInput.imeSetCompositionro   r   )rw   r   r   r   r   rq   rs   r    r!   r!   r"   ime_set_compositionB  s   
r   buttontyping.Optional[MouseButton]buttonsclick_countr   r   r   r   r   r   delta_x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ur\||d< |durd||d< |durl||d< |durt||d< |dur|||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 force: **(EXPERIMENTAL)** *(Optional)* The normalized pressure, which has a range of [0,1] (default: 0).
    :param tangential_pressure: **(EXPERIMENTAL)** *(Optional)* The normalized tangential pressure, which has a range of [-1,1] (default: 0).
    :param tilt_x: **(EXPERIMENTAL)** *(Optional)* The plane angle between the Y-Z plane and the plane containing both the stylus axis and the Y axis, in degrees of the range [-90,90], a positive tiltX is to the right (default: 0).
    :param tilt_y: **(EXPERIMENTAL)** *(Optional)* The plane angle between the X-Z plane and the plane containing both the stylus axis and the X axis, in degrees of the range [-90,90], a positive tiltY is towards the user (default: 0).
    :param twist: **(EXPERIMENTAL)** *(Optional)* The clockwise rotation of a pen stylus around its own major axis, in degrees in the range [0,359] (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").
    rn   r	   r
   Nrl   ru   r   r   
clickCountr   r   r   r   r   deltaXdeltaYpointerTypezInput.dispatchMouseEventro   rr   )rk   r	   r
   rl   ru   r   r   r   r   r   r   r   r   r   r   r   rq   rs   r    r!   r!   r"   dispatch_mouse_evente  sF   &
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.
    rn   c                 S  ra   r!   rb   rc   r!   r!   r"   rf     rg   z(dispatch_touch_event.<locals>.<listcomp>touchPointsNrl   ru   zInput.dispatchTouchEventro   rr   )rk   r   rl   ru   rq   rs   r    r!   r!   r"   dispatch_touch_event  s   
r   c                  c  s    ddi} | V }dS )z2
    Cancels any active dragging in the page.
    rp   zInput.cancelDraggingNr!   )rs   r    r!   r!   r"   cancel_dragging  s   
r   c	                 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).
    rn   r	   r
   r   Nru   r   r   rl   r   z Input.emulateTouchFromMouseEventro   rr   )rk   r	   r
   r   ru   r   r   rl   r   rq   rs   r    r!   r!   r"   emulate_touch_from_mouse_event  s(   
r   ignoreboolc                 c  r   )z
    Ignores input events (useful while auditing page).

    :param ignore: Ignores input events processing when set to true.
    r   zInput.setIgnoreInputEventsro   Nr   )r   rq   rs   r    r!   r!   r"   set_ignore_input_events  s   
r   enabledc                 c  r   )z
    Prevents default drag and drop behavior and instead emits ``Input.dragIntercepted`` events.
    Drag and drop behavior can be directly controlled via ``Input.dispatchDragEvent``.

    **EXPERIMENTAL**

    :param enabled:
    r   zInput.setInterceptDragsro   Nr   )r   rq   rs   r    r!   r!   r"   set_intercept_drags  r   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.synthesizePinchGesturero   rr   )r	   r
   r   r   r   rq   rs   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.synthesizeScrollGesturero   rr   )r	   r
   r   r   r   r   r   r   r   r   r   r   rq   rs   r    r!   r!   r"   synthesize_scroll_gestureL  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.synthesizeTapGesturero   rr   )r	   r
   r   r   r   rq   rs   r    r!   r!   r"   synthesize_tap_gesture  s   
r   zInput.dragInterceptedc                   @  s(   e Zd ZU dZded< ed
ddZd	S )DragInterceptedz
    **EXPERIMENTAL**

    Emitted only when ``Input.setInterceptDrags`` is enabled. Use this data with ``Input.dispatchDragEvent`` to
    restore normal drag and drop behavior.
    r\   rU   r    r   rJ   c                 C  s   | t |d dS )NrU   )rU   )r\   r'   r%   r!   r!   r"   r'     s   zDragIntercepted.from_jsonN)r    r   rJ   r   )r(   r)   r*   rP   r+   r,   r'   r!   r!   r!   r"   r     s
   
 r   r2   )rk   rS   r	   r   r
   r   rU   r\   rl   r   rJ   rm   )NNNNNNNNNNNNNN) rk   rS   rl   r   ru   rv   rw   rV   rx   rV   ry   rV   rz   rV   r{   rV   r|   r   r}   r   r~   r   r   r   r   r   r   r   r   r_   rJ   rm   )rw   rS   rJ   rm   )NN)rw   rS   r   r$   r   r$   r   r   r   r   rJ   rm   )NNNNNNNNNNNNN)"rk   rS   r	   r   r
   r   rl   r   ru   rv   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rV   rJ   rm   )
rk   rS   r   r   rl   r   ru   rv   rJ   rm   )rJ   rm   )NNNNN)rk   rS   r	   r$   r
   r$   r   r<   ru   rv   r   r   r   r   rl   r   r   r   rJ   rm   )r   r   rJ   rm   )r   r   rJ   rm   )r	   r   r
   r   r   r   r   r   r   r   rJ   rm   )
NNNNNNNNNN)r	   r   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rV   rJ   rm   )NNN)r	   r   r
   r   r   r   r   r   r   r   rJ   rm   )
__future__r   utilr   r   dataclassesr   enumtypingr   Enumr-   r<   r   rI   rR   r\   rt   r   r   r   r   r   r   r   r   r   r   r   r   r   r!   r!   r!   r"   <module>   s   L#"
I'N

0
$A"