o
    M,öh  ã                   @   sN   d dl mZmZmZ d dlmZ G dd„ dƒZG dd„ dƒZG dd„ dƒZd	S )
é    )ÚAnyÚOptionalÚUnion)Úcommand_builderc                   @   s&  e Zd ZdZ					d%dedededee dee d	ee d
ee f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"eeeedf f fd#d$„ZdS )&ÚGeolocationCoordinatesz#Represents geolocation coordinates.ç      ð?NÚlatitudeÚ	longitudeÚaccuracyÚaltitudeÚaltitude_accuracyÚheadingÚspeedc                 C   s.   || _ || _|| _|| _|| _|| _|| _dS )aí  Initialize GeolocationCoordinates.

        Parameters:
        -----------
            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©r   r	   r
   r   r   r   r   )Úselfr   r	   r
   r   r   r   r   © r   út/var/www/www-root/data/www/bot.pdev.uz/venv/lib/python3.10/site-packages/selenium/webdriver/common/bidi/emulation.pyÚ__init__   s   
zGeolocationCoordinates.__init__c                 C   ó   | j S ©N)Ú	_latitude©r   r   r   r   r   <   ó   zGeolocationCoordinates.latitudec                 C   ó.   d|  krdkst dƒ‚ t dƒ‚|| _d S )Ng     €VÀg     €V@z'latitude must be between -90.0 and 90.0)Ú
ValueErrorr   ©r   Úvaluer   r   r   r   @   ó
   ÿ
c                 C   r   r   )Ú
_longituder   r   r   r   r	   F   r   z GeolocationCoordinates.longitudec                 C   r   )Ng     €fÀg     €f@z*longitude must be between -180.0 and 180.0)r   r   r   r   r   r   r	   J   r   c                 C   r   r   )Ú	_accuracyr   r   r   r   r
   P   r   zGeolocationCoordinates.accuracyc                 C   s   |dk rt dƒ‚|| _d S )Nç        zaccuracy must be >= 0.0)r   r   r   r   r   r   r
   T   s   
c                 C   r   r   ©Ú	_altituder   r   r   r   r   Z   r   zGeolocationCoordinates.altitudec                 C   ó
   || _ d S r   r!   r   r   r   r   r   ^   s   
c                 C   r   r   )Ú_altitude_accuracyr   r   r   r   r   b   r   z(GeolocationCoordinates.altitude_accuracyc                 C   s<   |d ur| j d u rtdƒ‚|d ur|dk rtdƒ‚|| _d S )Nz0altitude_accuracy cannot be set without altituder    z altitude_accuracy must be >= 0.0)r   r   r$   r   r   r   r   r   f   s
   
c                 C   r   r   )Ú_headingr   r   r   r   r   n   r   zGeolocationCoordinates.headingc                 C   s6   |d urd|  krdk st dƒ‚ t dƒ‚|| _d S )Nr    g     €v@z%heading must be between 0.0 and 360.0)r   r%   r   r   r   r   r   r   s
   ÿ
c                 C   r   r   )Ú_speedr   r   r   r   r   x   r   zGeolocationCoordinates.speedc                 C   s"   |d ur|dk rt dƒ‚|| _d S )Nr    zspeed must be >= 0.0)r   r&   r   r   r   r   r   |   s   
Úreturnc                 C   sf   | j | j| jdœ}| jd ur| j|d< | jd ur| j|d< | jd ur'| j|d< | jd ur1| j|d< |S )N)r   r	   r
   r   ÚaltitudeAccuracyr   r   r   )r   Úresultr   r   r   Úto_dict‚   s   ý







zGeolocationCoordinates.to_dict)r   NNNN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úfloatr   r   Úpropertyr   Úsetterr	   r
   r   r   r   r   ÚdictÚstrr   r*   r   r   r   r   r      sf    øþýüûúù
ø"













"r   c                   @   s<   e Zd ZdZdZefdefdd„Zdeeef fdd„Zd	S )
ÚGeolocationPositionErrorz(Represents a geolocation position error.ÚpositionUnavailableÚtypec                 C   s&   || j krtd| j › dƒ‚|| _d S )Nztype must be "ú")ÚTYPE_POSITION_UNAVAILABLEr   r6   )r   r6   r   r   r   r      s   

z!GeolocationPositionError.__init__r'   c                 C   s
   d| j iS )Nr6   )r6   r   r   r   r   r*   ¢   ó   
z GeolocationPositionError.to_dictN)	r+   r,   r-   r.   r8   r3   r   r2   r*   r   r   r   r   r4   ˜   s
    r4   c                   @   sX   e Zd ZdZdd„ Z				ddee dee deee	  deee	  d	df
d
d„Z
dS )Ú	Emulationz6
    BiDi implementation of the emulation module.
    c                 C   r#   r   )Úconn)r   r;   r   r   r   r   «   r9   zEmulation.__init__NÚcoordinatesÚerrorÚcontextsÚuser_contextsr'   c                 C   s®   |dur|durt dƒ‚|dur|durt dƒ‚|du r$|du r$t dƒ‚i }|dur1| ¡ |d< n
|dur;| ¡ |d< |durD||d< n|durL||d< | j td	|ƒ¡ dS )
a‹  Set geolocation override for the given contexts or user contexts.

        Parameters:
        -----------
            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 errorz-Cannot specify both contexts and userContextsz,Must specify either contexts or userContextsr<   r=   r>   ÚuserContextsz emulation.setGeolocationOverride)r   r*   r;   Úexecuter   )r   r<   r=   r>   r?   Úparamsr   r   r   Úset_geolocation_override®   s    
z"Emulation.set_geolocation_override)NNNN)r+   r,   r-   r.   r   r   r   r4   Úlistr3   rC   r   r   r   r   r:   ¦   s$    ûþý
ü
ûúr:   N)	Útypingr   r   r   Ú%selenium.webdriver.common.bidi.commonr   r   r4   r:   r   r   r   r   Ú<module>   s    