
    /_i=7                     R   d dl Z d dlmZmZ d dl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)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     c/var/www/html/land_sniper/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 )r0   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)r0   r)   s    r   r*   zPointerParameters.to_dictE   s    t0011r   N)r   r   r   r   r	   r   r0   r+   r,   r3   r-   r*   r   r   r   r/   r/   ;   s'    <#))L#)u2 2r   r/   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 )Nr8   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π)
r9   r2   r:   r<   r=   r>   r?   mathpir@   r)   s    r   r3   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.r8   r9   r:   r;   r<   tangentialPressurer   r>   altitudeAngleazimuthAngle)r9   r:   r<   r=   r>   r?   r@   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   r9   intr,   r:   r<   floatr=   r>   r?   r@   r3   r-   r*   r   r   r   r7   r7   J   s[    0E3NFCOHe!$$E3NNEM5J  r   r7   c                   H    e Zd ZU dZdZedz  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    rO   )r    rO   rI   s     r   r*   zPauseAction.to_dict   s-    "($))!4==$!%F:r   )r   r   r   r   rO   rK   r,   propertyr+   r    r-   r*   r   r   r   rN   rN   {   s8    $HcDjc   r   rN   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    rX   r]   r)   s    r   r*   zKeyDownAction.to_dict       		DJJ77r   Nr   r   r   r   rX   r+   r,   rT   r    r-   r*   r   r   r   rV   rV      s3    'E3Oc  8 8r   rV   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.rW   rX   r'   c                      y)NkeyUpr   r)   s    r   r    zKeyUpAction.type   rR   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   Nr_   r   r   r   ra   ra      s3    %E3Oc  8 8r   ra   c                   V    e Zd ZU dZdZeed<   dZedz  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    rg   )r    rg   rh   updater*   rI   s     r   r*   zPointerDownAction.to_dict   s9    *.))t{{!K??MM$//1134r   )r   r   r   r   rg   rK   r,   rh   r7   rT   r+   r    r-   r*   r   r   r   rf   rf      sC    +FCO15J'$.5c   r   rf   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   rg   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.rm   rm   r)   s    r   r*   zPointerUpAction.to_dict   s    		T[[99r   N)r   r   r   r   rg   rK   r,   rT   r+   r    r-   r*   r   r   r   rp   rp      s3    )FCOc  : :r   rp   c                       e Zd ZU dZdZeed<   dZeed<   dZe	dz  ed<   dZ
eez  dz  ed<   dZedz  ed<   ed	efd
       Zd	efdZy)PointerMoveActionz!Represents a pointer move action.r   xyNrO   originrh   r'   c                      y)NpointerMover   r)   s    r   r    zPointerMoveAction.type   rk   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    rv   rw   rO   rx   )
r    rv   rw   rO   rx   
isinstancer   r*   rh   rn   rI   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   rv   rL   r,   rw   rO   rK   rx   r+   r   rh   r7   rT   r    r-   r*   r   r   r   ru   ru      sn    +AuLAuLHcDj)-FC-$&-15J'$.5c   r   ru   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dz  ed<   ej                  Zeez  dz  ed	<   ed
efd       Zd
efdZy)WheelScrollActionz!Represents a wheel scroll action.r   rv   rw   delta_xdelta_yNrO   rx   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    rv   rw   deltaXdeltaYrO   rx   )
r    rv   rw   r   r   rO   rx   r|   r   r*   rI   s     r   r*   zWheelScrollAction.to_dict   s     IIllll"
 ==$!%F:;;"$++}5#';;#6#6#8x   $(;;x r   )r   r   r   r   rv   rK   r,   rw   r   r   rO   r   r   rx   r+   r   rT   r    r-   r*   r   r   r   r~   r~      sv    +AsJAsJGSGSHcDj)/FC-$&8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.rW   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   rN   rT   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z  ez     ed<   edefd       ZdefdZy	)
KeySourceActionsz%Represents a sequence of key actions.rW   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   rN   rV   ra   rT   r    r-   r*   r   r   r   r   r     sT    /BL?DUY?ZGT+-;<Zc  l lr   r   c                       e Zd ZU dZdZeed<   dZedz  ed<    e	e
      Ze
eez  ez  ez     ed<   d Zed	efd
       Zd	efdZy)PointerSourceActionsz)Represents a sequence of pointer actions.rW   r   N
parametersr   r   c                 <    | j                   t               | _         y y N)r   r/   r)   s    r   r3   z"PointerSourceActions.__post_init__5  s    ??"/1DO #r   r'   c                      y)Nr   r   r)   s    r   r    zPointerSourceActions.type9  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   rJ   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/   r   r   r   rN   rf   rp   ru   r3   rT   r    r-   r*   r   r   r   r   r   -  sp    3BL+/J!D(/[`qu[vGT+ 11OCFWWXv2 c  	 	r   r   c                   j    e Zd ZU dZdZeed<    ee      Z	ee
ez     ed<   edefd       ZdefdZy	)
WheelSourceActionsz'Represents a sequence of wheel actions.rW   r   r   r   r'   c                      y)Nwheelr   r)   s    r   r    zWheelSourceActions.typeP  rR   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_dictT  r   r   N)r   r   r   r   r   r+   r,   r   r   r   rN   r~   rT   r    r-   r*   r   r   r   r   r   I  sO    1BL5:45PGT+ 112Pc  l lr   r   c                   T    e Zd ZU dZeed<   eed<   dZedz  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 )zCreates a FileDialogInfo instance from a dictionary.

        Args:
            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_dicta  s&     4	?T*5EtxxXaObccr   )r   r   r   r   r+   r,   boolr!   r-   classmethodr   r   r   r   r   r   Y  sB    OLNGTD[	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_jsont  s     ''--r   N)r   r   r   r   event_classr   r   r   r   r   r   r   o  s    7*K. .r   r   c                       e Zd ZdZd Zdedeeez  e	z  e
z     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efdZdeddfdZy)Inputz(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.

        Args:
            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.

        Args:
            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.

        Args:
            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 )zAdd a handler for file dialog opened events.

        Args:
            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.

        Args:
            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   rK   r   r   r   r   r   r   r   z  s    2
KK '*::=QQTffgK 
	KKs Kt K	E 	Et 	EDI 	E$ 	E# .Ac Ad Ar   r   )rC   dataclassesr   r   typingr   %selenium.webdriver.common.bidi.commonr   &selenium.webdriver.common.bidi.sessionr   r	   r   r   r/   r7   rN   rV   ra   rf   rp   ru   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   6 l l l d d d*. .TA TAr   