
    ,iV8                     Z   d dl Z d dlmZmZ d dlmZmZmZ d dlm	Z	 d dl
mZ  G d d      Z G d d	      Ze G d
 d             Ze G d d             Ze G d d             Ze G d d             Ze G d d             Ze G d d             Ze G d d             Ze G d d             Ze G d d             Ze G d d             Ze G d d             Ze G d  d!             Ze G d" d#             Ze G d$ d%             Ze G d& d'             Z G d( d)      Z G d* d+      Zy),    N)	dataclassfield)AnyOptionalUnion)command_builder)Sessionc                   &    e Zd ZdZdZdZdZeeehZy)PointerTypez&Represents the possible pointer types.mousepentouchN)__name__
__module____qualname____doc__MOUSEPENTOUCHVALID_TYPES     s/var/www/system.tvplus.app.br/jogos/scrap/venv/lib/python3.12/site-packages/selenium/webdriver/common/bidi/input.pyr   r      s     0E
CE#u%Kr   r   c                       e Zd ZdZdZdZy)Originz%Represents the possible origin types.viewportpointerN)r   r   r   r   VIEWPORTPOINTERr   r   r   r   r   $   s    /HGr   r   c                   >    e Zd ZU dZeed<   eed<   defdZdefdZy)	ElementOriginz/Represents an element origin for input actions.typeelementelement_referencec                      d| _         || _        y )Nr#   r"   r#   )selfr$   s     r   __init__zElementOrigin.__init__2   s    	(r   returnc                 4    | j                   | j                  dS )z*Convert the ElementOrigin to a dictionary.r&   r&   r'   s    r   to_dictzElementOrigin.to_dict6   s    		dll;;r   N)	r   r   r   r   str__annotations__dictr(   r,   r   r   r   r!   r!   +   s'    9
IM)$ )< <r   r!   c                   F    e Zd ZU dZej
                  Zeed<   d Z	de
fdZy)PointerParametersz2Represents pointer parameters for pointer actions.pointer_typec                     | j                   t        j                  vr)t        d| j                    dt        j                         y )NzInvalid pointer type: z. Must be one of )r2   r   r   
ValueErrorr+   s    r   __post_init__zPointerParameters.__post_init__A   sD    K$;$;;5d6G6G5HHYZeZqZqYrstt <r   r)   c                     d| j                   iS )z.Convert the PointerParameters to a dictionary.pointerType)r2   r+   s    r   r,   zPointerParameters.to_dictE   s    t0011r   N)r   r   r   r   r   r   r2   r-   r.   r5   r/   r,   r   r   r   r1   r1   ;   s'    <#))L#)u2 2r   r1   c                       e Zd ZU dZdZeed<   dZeed<   dZe	ed<   dZ
e	ed<   dZeed	<   dZe	ed
<   dZe	ed<   d ZdefdZy)PointerCommonPropertiesz&Common properties for pointer actions.   widthheight        pressuretangential_pressurer   twistaltitude_angleazimuth_anglec                 h   | j                   dk  rt        d      | j                  dk  rt        d      d| j                  cxk  rdk  st        d       t        d      d| j                  cxk  rdk  st        d       t        d      d| j
                  cxk  rd	k  st        d
       t        d
      d| j                  cxk  r t        j                  dz  k  st        d       t        d      d| j                  cxk  r dt        j                  z  k  st        d       t        d      y )Nr:   zwidth must be at least 1zheight must be at least 1r=   g      ?z$pressure must be between 0.0 and 1.0z/tangential_pressure must be between 0.0 and 1.0r   ig  ztwist must be between 0 and 359   u+   altitude_angle must be between 0.0 and π/2u)   azimuth_angle must be between 0.0 and 2π)
r;   r4   r<   r>   r?   r@   rA   mathpirB   r+   s    r   r5   z%PointerCommonProperties.__post_init__V   s1   ::>788;;?899t}}++CDD ,CDDt//636NOO 7NOOTZZ&3&>?? '>??t**9dggk9JKK :JKKt))8Q[8HII 9HII 9r   r)   c                    i }| j                   dk7  r| j                   |d<   | j                  dk7  r| j                  |d<   | j                  dk7  r| j                  |d<   | j                  dk7  r| j                  |d<   | j                  dk7  r| j                  |d<   | j
                  dk7  r| j
                  |d	<   | j                  dk7  r| j                  |d
<   |S )z4Convert the PointerCommonProperties to a dictionary.r:   r;   r<   r=   r>   tangentialPressurer   r@   altitudeAngleazimuthAngle)r;   r<   r>   r?   r@   rA   rB   r'   results     r   r,   zPointerCommonProperties.to_dictf   s    !#::?"jjF7O;;!#{{F8==C!%F:##s*+/+C+CF'(::?"jjF7O#%&*&9&9F?#$%)%7%7F>"r   N)r   r   r   r   r;   intr.   r<   r>   floatr?   r@   rA   rB   r5   r/   r,   r   r   r   r9   r9   J   s[    0E3NFCOHe!$$E3NNEM5J  r   r9   c                   H    e Zd ZU dZdZee   ed<   ede	fd       Z
defdZy)PauseActionzRepresents a pause action.Ndurationr)   c                      y)Npauser   r+   s    r   r"   zPauseAction.type       r   c                 X    d| j                   i}| j                  | j                  |d<   |S )z(Convert the PauseAction to a dictionary.r"   rQ   )r"   rQ   rK   s     r   r,   zPauseAction.to_dict   s-    "($))!4==$!%F:r   )r   r   r   r   rQ   r   rM   r.   propertyr-   r"   r/   r,   r   r   r   rP   rP   {   s8    $"Hhsm"c   r   rP   c                   B    e Zd ZU dZdZeed<   edefd       Zde	fdZ
y)KeyDownActionzRepresents a key down action. valuer)   c                      y)NkeyDownr   r+   s    r   r"   zKeyDownAction.type       r   c                 4    | j                   | j                  dS )z*Convert the KeyDownAction to a dictionary.r"   rZ   r_   r+   s    r   r,   zKeyDownAction.to_dict       		DJJ77r   Nr   r   r   r   rZ   r-   r.   rV   r"   r/   r,   r   r   r   rX   rX      s3    'E3Oc  8 8r   rX   c                   B    e Zd ZU dZdZeed<   edefd       Zde	fdZ
y)KeyUpActionzRepresents a key up action.rY   rZ   r)   c                      y)NkeyUpr   r+   s    r   r"   zKeyUpAction.type   rT   r   c                 4    | j                   | j                  dS )z(Convert the KeyUpAction to a dictionary.r_   r_   r+   s    r   r,   zKeyUpAction.to_dict   r`   r   Nra   r   r   r   rc   rc      s3    %E3Oc  8 8r   rc   c                   V    e Zd ZU dZdZeed<   dZee	   ed<   e
defd       ZdefdZy)	PointerDownActionz!Represents a pointer down action.r   buttonN
propertiesr)   c                      y)NpointerDownr   r+   s    r   r"   zPointerDownAction.type       r   c                     | j                   | j                  d}| j                  r)|j                  | j                  j	                                |S )z.Convert the PointerDownAction to a dictionary.r"   ri   )r"   ri   rj   updater,   rK   s     r   r,   zPointerDownAction.to_dict   s9    *.))t{{!K??MM$//1134r   )r   r   r   r   ri   rM   r.   rj   r   r9   rV   r-   r"   r/   r,   r   r   r   rh   rh      sC    +FCO48J018c   r   rh   c                   B    e Zd ZU dZdZeed<   edefd       Z	de
fdZy)PointerUpActionzRepresents a pointer up action.r   ri   r)   c                      y)N	pointerUpr   r+   s    r   r"   zPointerUpAction.type   s    r   c                 4    | j                   | j                  dS )z,Convert the PointerUpAction to a dictionary.ro   ro   r+   s    r   r,   zPointerUpAction.to_dict   s    		T[[99r   N)r   r   r   r   ri   rM   r.   rV   r-   r"   r/   r,   r   r   r   rr   rr      s3    )FCOc  : :r   rr   c                       e Zd ZU dZdZeed<   dZeed<   dZe	e
   ed<   dZe	eeef      ed<   dZe	e   ed<   ed	efd
       Zd	efdZy)PointerMoveActionz!Represents a pointer move action.r   xyNrQ   originrj   r)   c                      y)NpointerMover   r+   s    r   r"   zPointerMoveAction.type   rm   r   c                    | j                   | j                  | j                  d}| j                  | j                  |d<   | j                  Gt        | j                  t              r| j                  j                         |d<   n| j                  |d<   | j                  r)|j                  | j                  j                                |S )z.Convert the PointerMoveAction to a dictionary.)r"   rx   ry   rQ   rz   )
r"   rx   ry   rQ   rz   
isinstancer!   r,   rj   rp   rK   s     r   r,   zPointerMoveAction.to_dict   s    *.))$&&tvv!N==$!%F:;;"$++}5#';;#6#6#8x #';;x ??MM$//1134r   )r   r   r   r   rx   rN   r.   ry   rQ   r   rM   rz   r   r-   r!   rj   r9   rV   r"   r/   r,   r   r   r   rw   rw      ss    +AuLAuL"Hhsm"26FHU3-./648J018c   r   rw   c                       e Zd ZU dZdZeed<   dZeed<   dZeed<   dZ	eed<   dZ
ee   ed<   ej                  Zeeeef      ed	<   ed
efd       Zd
efdZy)WheelScrollActionz!Represents a wheel scroll action.r   rx   ry   delta_xdelta_yNrQ   rz   r)   c                      y)Nscrollr   r+   s    r   r"   zWheelScrollAction.type   s    r   c                 X   | j                   | j                  | j                  | j                  | j                  d}| j
                  | j
                  |d<   | j                  Ht        | j                  t              r| j                  j                         |d<   |S | j                  |d<   |S )z.Convert the WheelScrollAction to a dictionary.)r"   rx   ry   deltaXdeltaYrQ   rz   )
r"   rx   ry   r   r   rQ   rz   r~   r!   r,   rK   s     r   r,   zWheelScrollAction.to_dict   s     IIllll"
 ==$!%F:;;"$++}5#';;#6#6#8x   $(;;x r   )r   r   r   r   rx   rM   r.   ry   r   r   rQ   r   r   r   rz   r   r-   r!   rV   r"   r/   r,   r   r   r   r   r      s{    +AsJAsJGSGS"Hhsm"28//FHU3-./Ac   r   r   c                   d    e Zd ZU dZdZeed<    ee      Z	ee
   ed<   edefd       ZdefdZy	)
NoneSourceActionsz&Represents a sequence of none actions.rY   iddefault_factoryactionsr)   c                      y)Nnoner   r+   s    r   r"   zNoneSourceActions.type  s    r   c                     | j                   | j                  | j                  D cg c]  }|j                          c}dS c c}w )z.Convert the NoneSourceActions to a dictionary.r"   r   r   r"   r   r   r,   r'   actions     r   r,   zNoneSourceActions.to_dict  4    		]a]i]i=jSYfnn>N=jkk=j   AN)r   r   r   r   r   r-   r.   r   listr   rP   rV   r"   r/   r,   r   r   r   r   r     sI    0BL!&t!<GT+<c  l lr   r   c                   p    e Zd ZU dZdZeed<    ee      Z	ee
eeef      ed<   edefd       ZdefdZy	)
KeySourceActionsz%Represents a sequence of key actions.rY   r   r   r   r)   c                      y)Nkeyr   r+   s    r   r"   zKeySourceActions.type$  s    r   c                     | j                   | j                  | j                  D cg c]  }|j                          c}dS c c}w )z-Convert the KeySourceActions to a dictionary.r   r   r   s     r   r,   zKeySourceActions.to_dict(  r   r   N)r   r   r   r   r   r-   r.   r   r   r   r   rP   rX   rc   rV   r"   r/   r,   r   r   r   r   r     sV    /BLDIZ^D_GT%]K?@A_c  l lr   r   c                       e Zd ZU dZdZeed<   dZee	   ed<    e
e      Zeeeeeef      ed<   d Zed	efd
       Zd	efdZy)PointerSourceActionsz)Represents a sequence of pointer actions.rY   r   N
parametersr   r   c                 <    | j                   t               | _         y y N)r   r1   r+   s    r   r5   z"PointerSourceActions.__post_init__7  s    ??"/1DO #r   r)   c                      y)Nr   r   r+   s    r   r"   zPointerSourceActions.type;  r]   r   c                     | j                   | j                  | j                  D cg c]  }|j                          c}d}| j                  r| j                  j                         |d<   |S c c}w )z1Convert the PointerSourceActions to a dictionary.r   r   )r"   r   r   r,   r   )r'   r   rL   s      r   r,   zPointerSourceActions.to_dict?  s]     II''7;||DV(D"

 ??#'??#:#:#<F< 	 Es   A,)r   r   r   r   r   r-   r.   r   r   r1   r   r   r   r   rP   rh   rr   rw   r5   rV   r"   r/   r,   r   r   r   r   r   -  st    3BL.2J*+2_d`GT%%6IZZ[\ 2 c  	 	r   r   c                   n    e Zd ZU dZdZeed<    ee      Z	ee
eef      ed<   edefd       ZdefdZy	)
WheelSourceActionsz'Represents a sequence of wheel actions.rY   r   r   r   r)   c                      y)Nwheelr   r+   s    r   r"   zWheelSourceActions.typeR  rT   r   c                     | j                   | j                  | j                  D cg c]  }|j                          c}dS c c}w )z/Convert the WheelSourceActions to a dictionary.r   r   r   s     r   r,   zWheelSourceActions.to_dictV  r   r   N)r   r   r   r   r   r-   r.   r   r   r   r   rP   r   rV   r"   r/   r,   r   r   r   r   r   K  sU    1BL;@QU;VGT%%6678Vc  l lr   r   c                   T    e Zd ZU dZeed<   eed<   dZee	   ed<   e
de	dd fd       Zy)	FileDialogInfozERepresents file dialog information from input.fileDialogOpened event.contextmultipleNr#   datar)   c                 B     | |d   |d   |j                  d            S )a  Creates a FileDialogInfo instance from a dictionary.

        Parameters:
        -----------
            data: A dictionary containing the file dialog information.

        Returns:
        -------
            FileDialogInfo: A new instance of FileDialogInfo.
        r   r   r#   )r   r   r#   )get)clsr   s     r   	from_dictzFileDialogInfo.from_dictc  s&     4	?T*5EtxxXaObccr   )r   r   r   r   r-   r.   boolr#   r   r/   classmethodr   r   r   r   r   r   [  sB    OLN"GXd^"dT d&6 d dr   r   c                   $    e Zd ZdZdZed        Zy)FileDialogOpenedz-Event class for input.fileDialogOpened event.zinput.fileDialogOpenedc                 ,    t         j                  |      S )z%Create FileDialogInfo from JSON data.)r   r   )r   jsons     r   	from_jsonzFileDialogOpened.from_jsonx  s     ''--r   N)r   r   r   r   event_classr   r   r   r   r   r   r   s  s    7*K. .r   r   c            	           e Zd ZdZd Zdedeeee	e
ef      ddfdZdeddfdZded	ed
ee   ddfdZd ZdeddfdZy)Inputz2
    BiDi implementation of the input module.
    c                 .    || _         i | _        i | _        y r   )connsubscriptions	callbacks)r'   r   s     r   r(   zInput.__init__  s    	r   r   r   r)   Nc                     ||D cg c]  }|j                          c}d}| j                  j                  t        d|             yc c}w )zPerforms a sequence of user input actions.

        Parameters:
        -----------
            context: The browsing context ID where actions should be performed.
            actions: A list of source actions to perform.
        )r   r   zinput.performActionsN)r,   r   executer   )r'   r   r   r   paramss        r   perform_actionszInput.perform_actions  sA     %QX1Yv&..2B1YZ		/*@&IJ 2Zs   Ac                 V    d|i}| j                   j                  t        d|             y)zReleases all input state for the given context.

        Parameters:
        -----------
            context: The browsing context ID to release actions for.
        r   zinput.releaseActionsNr   r   r   )r'   r   r   s      r   release_actionszInput.release_actions  s(     W%		/*@&IJr   r#   filesc                 Z    |||d}| j                   j                  t        d|             y)zSets files for a file input element.

        Parameters:
        -----------
            context: The browsing context ID.
            element: The element reference (script.SharedReference).
            files: A list of file paths to set.
        )r   r#   r   zinput.setFilesNr   )r'   r   r#   r   r   s        r   	set_fileszInput.set_files  s*     %5I		/*:FCDr   c                    t         j                  | j                  vrjt        | j                        }| j                  j                  |j                  t         j                               g | j                  t         j                  <   | j                  j                  t         |      }| j                  t         j                     j                  |       || j                  |<   |S )a	  Add a handler for file dialog opened events.

        Parameters:
        -----------
            handler: Callback function that takes a FileDialogInfo object.

        Returns:
        --------
            int: Callback ID for removing the handler later.
        )
r   r   r   r	   r   r   	subscribeadd_callbackappendr   )r'   handlersessioncallback_ids       r   add_file_dialog_handlerzInput.add_file_dialog_handler  s     ''t/A/AAdii(GIIg//0@0L0LMN?AD/;;< ii,,-=wG+778??L&-{#r   r   c                 R   || j                   v r| j                   |= t        j                  | j                  v r|| j                  t        j                     v r,| j                  t        j                     j	                  |       | j                  t        j                     sht        | j                        }| j                  j                  |j                  t        j                               | j                  t        j                  = | j                  j                  t        |       y)zRemove a file dialog handler.

        Parameters:
        -----------
            callback_id: The callback ID returned by add_file_dialog_handler.
        N)
r   r   r   r   remover	   r   r   unsubscriberemove_callback)r'   r   r   s      r   remove_file_dialog_handlerz Input.remove_file_dialog_handler  s     $..({+''4+=+==d001A1M1MNN""#3#?#?@GGT %%&6&B&BC!$)),		!!'"5"56F6R6R"ST&&'7'C'CD		!!"2K@r   )r   r   r   r   r(   r-   r   r   r   r   r   r   r   r   r/   r   r   rM   r   r   r   r   r   r   ~  s    
KK e-/?AUWiijkK 
	KKs Kt K
E 
Et 
EDI 
E$ 
E2Ac Ad Ar   r   )rE   dataclassesr   r   typingr   r   r   %selenium.webdriver.common.bidi.commonr   &selenium.webdriver.common.bidi.sessionr	   r   r   r!   r1   r9   rP   rX   rc   rh   rr   rw   r   r   r   r   r   r   r   r   r   r   r   <module>r      s  $  ( ' ' A :& &  < < < 2 2 2 , , ,`   " 8 8 8 8 8 8   $ : : :   8   D l l l l l l   : l l l d d d.. .\A \Ar   