
    iK                        d dl mZ d dlmZ d dlmZmZmZ d dlm	Z	 erd dl
mZ  G d de      Z G d d	e      Z ed
ee      ZddZ G d d      Z G d d      Z G d d      Z G d d      Zy)    )annotations)Enum)TYPE_CHECKINGAnyTypeVar)command_builder)WebSocketConnectionc                      e Zd ZdZdZdZy)ScreenOrientationNaturalzNatural screen orientation.portrait	landscapeN)__name__
__module____qualname____doc__PORTRAIT	LANDSCAPE     d/var/www/html/BatchJob/venv/lib/python3.12/site-packages/selenium/webdriver/common/bidi/emulation.pyr   r      s    %HIr   r   c                       e Zd ZdZdZdZdZdZy)ScreenOrientationTypezScreen orientation type.zportrait-primaryzportrait-secondaryzlandscape-primaryzlandscape-secondaryN)r   r   r   r   PORTRAIT_PRIMARYPORTRAIT_SECONDARYLANDSCAPE_PRIMARYLANDSCAPE_SECONDARYr   r   r   r   r   #   s    ")-+/r   r   Ec                    t        | |      r| S t        | t              sJ 	  || j                               S # t        $ r t        d|        w xY w)NzInvalid orientation: )
isinstancestrlower
ValueError)value
enum_classs     r   _convert_to_enumr%   /   sY    %$eS!!!:%++-(( :0899:s	   8 Ac                  (    e Zd ZdZ	 	 	 	 ddZddZy)ScreenOrientationz,Represents screen orientation configuration.c                X    t        |t              | _        t        |t              | _        y)ag  Initialize ScreenOrientation.

        Args:
            natural: Natural screen orientation ("portrait" or "landscape").
            type: Screen orientation type ("portrait-primary", "portrait-secondary",
                "landscape-primary", or "landscape-secondary").

        Raises:
            ValueError: If natural or type values are invalid.
        N)r%   r   naturalr   type)selfr)   r*   s      r   __init__zScreenOrientation.__init__<   s"      (1IJ$T+@A	r   c                \    | j                   j                  | j                  j                  dS )N)r)   r*   )r)   r#   r*   r+   s    r   to_dictzScreenOrientation.to_dictO   s$    ||))IIOO
 	
r   N)r)   zScreenOrientationNatural | strr*   zScreenOrientationType | strreturnzdict[str, str])r   r   r   r   r,   r/   r   r   r   r'   r'   9   s$    6B/B *B&
r   r'   c                     e Zd ZdZ	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 ddZedd       Zej                  dd       Zedd       Zej                  dd       Zedd       Z	e	j                  dd	       Z	edd
       Z
e
j                  dd       Z
edd       Zej                  dd       Zedd       Zej                  dd       Zedd       Zej                  dd       ZddZy)GeolocationCoordinatesz#Represents geolocation coordinates.Nc                f    || _         || _        || _        || _        || _        || _        || _        y)a  Initialize GeolocationCoordinates.

        Args:
            latitude: Latitude coordinate (-90.0 to 90.0).
            longitude: Longitude coordinate (-180.0 to 180.0).
            accuracy: Accuracy in meters (>= 0.0), defaults to 1.0.
            altitude: Altitude in meters or None, defaults to None.
            altitude_accuracy: Altitude accuracy in meters (>= 0.0) or None, defaults to None.
            heading: Heading in degrees (0.0 to 360.0) or None, defaults to None.
            speed: Speed in meters per second (>= 0.0) or None, defaults to None.

        Raises:
            ValueError: If coordinates are out of valid range or if altitude_accuracy is provided without altitude.
        Nlatitude	longitudeaccuracyaltitudealtitude_accuracyheadingspeed)r+   r6   r7   r8   r9   r:   r;   r<   s           r   r,   zGeolocationCoordinates.__init__Y   s6    0 !"  !2
r   c                    | j                   S N)	_latituder.   s    r   r6   zGeolocationCoordinates.latitudey       ~~r   c                V    d|cxk  rdk  st        d       t        d      || _        y )Ng     Vg     V@z'latitude must be between -90.0 and 90.0)r"   r?   r+   r#   s     r   r6   zGeolocationCoordinates.latitude}   s3    &$&FGG 'FGGr   c                    | j                   S r>   )
_longituder.   s    r   r7   z GeolocationCoordinates.longitude   s    r   c                V    d|cxk  rdk  st        d       t        d      || _        y )Ng     fg     f@z*longitude must be between -180.0 and 180.0)r"   rD   rB   s     r   r7   z GeolocationCoordinates.longitude   s3    %(5(IJJ )IJJr   c                    | j                   S r>   )	_accuracyr.   s    r   r8   zGeolocationCoordinates.accuracy   r@   r   c                2    |dk  rt        d      || _        y )N        zaccuracy must be >= 0.0)r"   rG   rB   s     r   r8   zGeolocationCoordinates.accuracy   s    3;677r   c                    | j                   S r>   	_altituder.   s    r   r9   zGeolocationCoordinates.altitude   r@   r   c                    || _         y r>   rK   rB   s     r   r9   zGeolocationCoordinates.altitude   s	    r   c                    | j                   S r>   )_altitude_accuracyr.   s    r   r:   z(GeolocationCoordinates.altitude_accuracy   s    &&&r   c                h    || j                   t        d      ||dk  rt        d      || _        y )Nz0altitude_accuracy cannot be set without altituderI   z altitude_accuracy must be >= 0.0)r9   r"   rO   rB   s     r   r:   z(GeolocationCoordinates.altitude_accuracy   s=    !6OPP?@@"'r   c                    | j                   S r>   )_headingr.   s    r   r;   zGeolocationCoordinates.heading   s    }}r   c                Z    |"d|cxk  rdk  st        d       t        d      || _        y )NrI   g     v@z%heading must be between 0.0 and 360.0)r"   rR   rB   s     r   r;   zGeolocationCoordinates.heading   s8    cU&:U&:DEE ';DEEr   c                    | j                   S r>   )_speedr.   s    r   r<   zGeolocationCoordinates.speed   s    {{r   c                6    ||dk  rt        d      || _        y )NrI   zspeed must be >= 0.0)r"   rU   rB   s     r   r<   zGeolocationCoordinates.speed   s!    344r   c                &   | j                   | j                  | j                  d}| j                  | j                  |d<   | j                  | j                  |d<   | j
                  | j
                  |d<   | j                  | j                  |d<   |S )N)r6   r7   r8   r9   altitudeAccuracyr;   r<   r5   )r+   results     r   r/   zGeolocationCoordinates.to_dict   s    +
 ==$!%F:!!-)-)?)?F%&<<# $F9::!"jjF7Or   )g      ?NNNN)r6   floatr7   rZ   r8   rZ   r9   float | Noner:   r[   r;   r[   r<   r[   )r1   rZ   )r#   rZ   r1   None)r1   r[   )r#   r[   r1   r\   )r1   zdict[str, float | None])r   r   r   r   r,   propertyr6   setterr7   r8   r9   r:   r;   r<   r/   r   r   r   r3   r3   V   s   - !%*. $"  	
  (  @   __ 
      
   __ 
   __  ' ' ( (   ^^ 
   \\ 
r   r3   c                  (    e Zd ZdZdZefddZddZy)GeolocationPositionErrorz(Represents a geolocation position error.positionUnavailablec                b    || j                   k7  rt        d| j                    d      || _        y )Nztype must be "")TYPE_POSITION_UNAVAILABLEr"   r*   )r+   r*   s     r   r,   z!GeolocationPositionError.__init__   s2    4111~d.L.L-MQOPP	r   c                    d| j                   iS )Nr*   )r*   r.   s    r   r/   z GeolocationPositionError.to_dict   s    		""r   N)r*   r    r0   )r   r   r   r   rd   r,   r/   r   r   r   r`   r`      s    2 5#< 
#r   r`   c                     e Zd ZdZddZ	 	 	 	 d	 	 	 	 	 	 	 	 	 ddZ	 	 	 d	 	 	 	 	 	 	 ddZ	 	 	 d	 	 	 	 	 	 	 ddZ	 	 	 d	 	 	 	 	 	 	 ddZ	 	 	 d	 	 	 	 	 	 	 ddZ		 	 	 d	 	 	 	 	 	 	 dd	Z
	 	 	 d	 	 	 	 	 	 	 dd
Z	 	 	 	 d	 	 	 	 	 	 	 	 	 ddZy)	Emulationz,BiDi implementation of the emulation module.c                    || _         y r>   )conn)r+   ri   s     r   r,   zEmulation.__init__   s	    	r   Nc                    ||t        d      ||t        d      ||t        d      i }||j                         |d<   n||j                         |d<   |||d<   n|||d<   | j                  j                  t	        d	|             y)
aT  Set geolocation override for the given contexts or user contexts.

        Args:
            coordinates: Geolocation coordinates to emulate, or None.
            error: Geolocation error to emulate, or None.
            contexts: List of browsing context IDs to apply the override to.
            user_contexts: List of user context IDs to apply the override to.

        Raises:
            ValueError: If both coordinates and error are provided, or if both contexts
                and user_contexts are provided, or if neither contexts nor
                user_contexts are provided.
        Nz)Cannot specify both coordinates and error-Cannot specify both contexts and userContexts,Must specify either contexts or userContextscoordinateserrorcontextsuserContextsz emulation.setGeolocationOverrider"   r/   ri   executer   )r+   rm   rn   ro   user_contextsparamss         r   set_geolocation_overridez"Emulation.set_geolocation_override   s    ( "u'8HIIM$=LMM 5KLL!#"$/$7$7$9F=!#mmoF7O!)F:&%2F>"		/*LfUVr   c                    ||t        d      ||t        d      d|i}|||d<   n|||d<   | j                  j                  t        d|             y)a   Set timezone override for the given contexts or user contexts.

        Args:
            timezone: Timezone identifier (IANA timezone name or offset string like '+01:00'),
                or None to clear the override.
            contexts: List of browsing context IDs to apply the override to.
            user_contexts: List of user context IDs to apply the override to.

        Raises:
            ValueError: If both contexts and user_contexts are provided, or if neither
                contexts nor user_contexts are provided.
        N.Cannot specify both contexts and user_contexts-Must specify either contexts or user_contextstimezonero   rp   zemulation.setTimezoneOverrider"   ri   rr   r   )r+   ry   ro   rs   rt   s        r   set_timezone_overridezEmulation.set_timezone_override  sv    $ M$=MNN 5LMM",h!7!)F:&%2F>"		/*I6RSr   c                    ||t        d      ||t        d      d|i}|||d<   n|||d<   | j                  j                  t        d|             y)a  Set locale override for the given contexts or user contexts.

        Args:
            locale: Locale string as per BCP 47, or None to clear override.
            contexts: List of browsing context IDs to apply the override to.
            user_contexts: List of user context IDs to apply the override to.

        Raises:
            ValueError: If both contexts and user_contexts are provided, or if neither
                contexts nor user_contexts are provided, or if locale is invalid.
        Nrk   rl   localero   rp   zemulation.setLocaleOverriderz   )r+   r}   ro   rs   rt   s        r   set_locale_overridezEmulation.set_locale_override5  sv    " M$=LMM 5KLL"*F!3!)F:&%2F>"		/*GPQr   c                    |rt        d      ||t        d      ||t        d      d|i}|||d<   n|||d<   | j                  j                  t        d|             y)	aI  Set scripting enabled override for the given contexts or user contexts.

        Args:
            enabled: False to disable scripting, None to clear the override.
                Note: Only emulation of disabled JavaScript is supported.
            contexts: List of browsing context IDs to apply the override to.
            user_contexts: List of user context IDs to apply the override to.

        Raises:
            ValueError: If both contexts and user_contexts are provided, or if neither
                contexts nor user_contexts are provided, or if enabled is True.
        zROnly emulation of disabled JavaScript is supported (enabled must be False or None)Nrk   rl   enabledro   rp   zemulation.setScriptingEnabledrz   )r+   r   ro   rs   rt   s        r   set_scripting_enabledzEmulation.set_scripting_enabledU  s    $ qrrM$=LMM 5KLL"+W!5!)F:&%2F>"		/*I6RSr   c                    ||t        d      ||t        d      d||j                         ndi}|||d<   n|||d<   | j                  j                  t	        d|             y)a   Set screen orientation override for the given contexts or user contexts.

        Args:
            screen_orientation: ScreenOrientation object to emulate, or None to clear the override.
            contexts: List of browsing context IDs to apply the override to.
            user_contexts: List of user context IDs to apply the override to.

        Raises:
            ValueError: If both contexts and user_contexts are provided, or if neither
                contexts nor user_contexts are provided.
        Nrk   rl   screenOrientationro   rp   z&emulation.setScreenOrientationOverriderq   )r+   screen_orientationro   rs   rt   s        r   set_screen_orientation_overridez)Emulation.set_screen_orientation_overridey  s    " M$=LMM 5KLL  ASA_!3!;!;!=ei"
 !)F:&%2F>"		/*RTZ[\r   c                    ||t        d      ||t        d      d|i}|||d<   n|||d<   | j                  j                  t        d|             y)a  Set user agent override for the given contexts or user contexts.

        Args:
            user_agent: User agent string to emulate, or None to clear the override.
            contexts: List of browsing context IDs to apply the override to.
            user_contexts: List of user context IDs to apply the override to.

        Raises:
            ValueError: If both contexts and user_contexts are provided, or if neither
                contexts nor user_contexts are provided.
        Nrw   rx   	userAgentro   rp   zemulation.setUserAgentOverriderz   )r+   
user_agentro   rs   rt   s        r   set_user_agent_overridez!Emulation.set_user_agent_override  sv    " M$=MNN 5LMM"-z!:!)F:&%2F>"		/*JFSTr   c                    ||t        d      ||t        d      i }|rddi|d<   nd|d<   |||d<   n|||d<   | j                  j                  t        d	|             y)
a  Set network conditions for the given contexts or user contexts.

        Args:
            offline: True to emulate offline network conditions, False to clear the override.
            contexts: List of browsing context IDs to apply the conditions to.
            user_contexts: List of user context IDs to apply the conditions to.

        Raises:
            ValueError: If both contexts and user_contexts are provided, or if neither
                contexts nor user_contexts are provided.
        Nrw   rx   r*   offlinenetworkConditionsro   rp   zemulation.setNetworkConditionsrz   )r+   r   ro   rs   rt   s        r   set_network_conditionsz Emulation.set_network_conditions  s    " M$=MNN 5LMM!#+19*=F&' +/F&'!)F:&%2F>"		/*JFSTr   c                n   |du |du k7  rt        d      ||t        d      ||t        d      d}|G|Et        |t              rt        |t              st        d      |dk  s|dk  rt        d      ||d}d	|i}|||d
<   n|||d<   | j                  j	                  t        d|             y)aG  Set screen settings override for the given contexts or user contexts.

        Args:
            width: Screen width in pixels (>= 0). None to clear the override.
            height: Screen height in pixels (>= 0). None to clear the override.
            contexts: List of browsing context IDs to apply the override to.
            user_contexts: List of user context IDs to apply the override to.

        Raises:
            ValueError: If only one of width/height is provided, or if both contexts
                and user_contexts are provided, or if neither is provided.
        NzDMust provide both width and height, or neither to clear the overriderw   rx   z!width and height must be integersr   zwidth and height must be >= 0)widthheight
screenArearo   rp   z#emulation.setScreenSettingsOverride)r"   r   intri   rr   r   )r+   r   r   ro   rs   screen_areart   s          r   set_screen_settings_overridez&Emulation.set_screen_settings_override  s    & TMv~.cddM$=MNN 5LMM!3eS)FC1H !DEEqyFQJ !@AA$)V<K".!<!)F:&%2F>"		/*OQWXYr   )ri   r	   r1   r\   )NNNN)
rm   zGeolocationCoordinates | Nonern   zGeolocationPositionError | Nonero   list[str] | Noners   r   r1   r\   )NNN)ry   
str | Nonero   r   rs   r   r1   r\   )r}   r   ro   r   rs   r   r1   r\   )FNN)r   zbool | Nonero   r   rs   r   r1   r\   )r   zScreenOrientation | Nonero   r   rs   r   r1   r\   )r   r   ro   r   rs   r   r1   r\   )r   boolro   r   rs   r   r1   r\   )
r   
int | Noner   r   ro   r   rs   r   r1   r\   )r   r   r   r   r,   ru   r{   r~   r   r   r   r   r   r   r   r   rg   rg      s   6
 6:15%)*.)W2)W /)W #	)W
 ()W 
)WZ  $%)*.	TT #T (	T
 
TF "%)*.	RR #R (	R
 
RD  %%)*.	"T"T #"T (	"T
 
"TL 8<%)*.	 ]4 ] # ] (	 ]
 
 ]H "&%)*.	UU #U (	U
 
UD %)*.	$U$U #$U (	$U
 
$UP !!%)*.+Z+Z +Z #	+Z
 (+Z 
+Zr   rg   N)r#   zE | strr$   ztype[E]r1   r   )
__future__r   enumr   typingr   r   r   %selenium.webdriver.common.bidi.commonr   .selenium.webdriver.remote.websocket_connectionr	   r   r   r   r%   r'   r3   r`   rg   r   r   r   <module>r      sz   " #  . . ARt 0D 0 C)+@A:
 
:| |~# #iZ iZr   