Ë
    #åhi©$  ã                   óx   — d dl Z d dl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
 G d
„ d«      Zy)é    N)ÚAny)Úcommand_builder)ÚUserPromptHandler)ÚProxyc                   ó,   — e Zd ZdZdZdZdZdZeeeehZy)ÚClientWindowStatezRepresents a window state.Ú
fullscreenÚ	maximizedÚ	minimizedÚnormalN)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
FULLSCREENÚ	MAXIMIZEDÚ	MINIMIZEDÚNORMALÚVALID_STATES© ó    úRC:\des-py\Monitor\venv\Lib\site-packages\selenium/webdriver/common/bidi/browser.pyr   r      s'   „ Ù$à€JØ€IØ€IØ€Fà 	¨9°fÐ=�Lr   r   c                   ó¢   — e Zd ZdZdededededededefd	„Zd
efd„Zd
efd„Z	d
efd„Z
d
efd„Zd
efd„Zd
efd„Zd
efd„Zeded
d fd„«       Zy)ÚClientWindowInfoz'Represents a client window information.Úclient_windowÚstateÚwidthÚheightÚxÚyÚactivec                 óf   — || _         || _        || _        || _        || _        || _        || _        y ©N©r   r   r   r   r   r    r!   )Úselfr   r   r   r   r   r    r!   s           r   Ú__init__zClientWindowInfo.__init__'   s6   € ð +ˆÔØˆŒ
ØˆŒ
ØˆŒØˆŒØˆŒØˆ�r   Úreturnc                 ó   — | j                   S )z™Gets the state of the client window.

        Returns:
            str: The state of the client window (one of the ClientWindowState constants).
        )r   ©r%   s    r   Ú	get_statezClientWindowInfo.get_state9   ó   € ð �z‰zÐr   c                 ó   — | j                   S )zlGets the client window identifier.

        Returns:
            str: The client window identifier.
        )r   r)   s    r   Úget_client_windowz"ClientWindowInfo.get_client_windowA   s   € ð ×!Ñ!Ð!r   c                 ó   — | j                   S )zpGets the width of the client window.

        Returns:
            int: The width of the client window.
        )r   r)   s    r   Ú	get_widthzClientWindowInfo.get_widthI   r+   r   c                 ó   — | j                   S )zrGets the height of the client window.

        Returns:
            int: The height of the client window.
        )r   r)   s    r   Ú
get_heightzClientWindowInfo.get_heightQ   ó   € ð �{‰{Ðr   c                 ó   — | j                   S )z~Gets the x coordinate of the client window.

        Returns:
            int: The x coordinate of the client window.
        )r   r)   s    r   Úget_xzClientWindowInfo.get_xY   ó   € ð �v‰vˆr   c                 ó   — | j                   S )z~Gets the y coordinate of the client window.

        Returns:
            int: The y coordinate of the client window.
        )r    r)   s    r   Úget_yzClientWindowInfo.get_ya   r5   r   c                 ó   — | j                   S )z‰Checks if the client window is active.

        Returns:
            bool: True if the client window is active, False otherwise.
        )r!   r)   s    r   Ú	is_activezClientWindowInfo.is_activei   r2   r   Údatac           	      ó  — 	 |d   }t        |t        «      st        d«      ‚|d   }t        |t        «      st        d«      ‚|t        j                  vrt        d|› dt        j                  › �«      ‚|d   }t        |t
        «      r|dk  rt        d	|› �«      ‚|d
   }t        |t
        «      r|dk  rt        d|› �«      ‚|d   }t        |t
        «      s!t        dt        |«      j                  › �«      ‚|d   }t        |t
        «      s!t        dt        |«      j                  › �«      ‚|d   }t        |t        «      st        d«      ‚ | |||||||¬«      S # t        t        f$ r}	t        d|	› �«      |	‚d}	~	ww xY w)aJ  Creates a ClientWindowInfo instance from a dictionary.

        Args:
            data: A dictionary containing the client window information.

        Returns:
            ClientWindowInfo: A new instance of ClientWindowInfo.

        Raises:
            ValueError: If required fields are missing or have invalid types.
        ÚclientWindowzclientWindow must be a stringr   zstate must be a stringzInvalid state: z. Must be one of r   r   z*width must be a non-negative integer, got r   z+height must be a non-negative integer, got r   zx must be an integer, got r    zy must be an integer, got r!   zactive must be a booleanr$   z*Invalid data format for ClientWindowInfo: N)Ú
isinstanceÚstrÚ
ValueErrorr   r   ÚintÚtyper   ÚboolÚKeyErrorÚ	TypeError)
Úclsr:   r   r   r   r   r   r    r!   Úes
             r   Ú	from_dictzClientWindowInfo.from_dictq   s¡  € ð)	VØ  Ñ0ˆMÜ˜m¬SÔ1Ü Ð!@ÓAÐAà˜‘MˆEÜ˜e¤SÔ)Ü Ð!9Ó:Ð:ØÔ-×:Ñ:Ñ:Ü  ?°5°'Ð9JÔK\×KiÑKiÐJjÐ!kÓlÐlà˜‘MˆEÜ˜e¤SÔ)¨U°QªYÜ Ð#MÈeÈWÐ!UÓVÐVà˜(‘^ˆFÜ˜f¤cÔ*¨f°qªjÜ Ð#NÈvÈhÐ!WÓXÐXà�S‘	ˆAÜ˜a¤Ô%Ü Ð#=¼dÀ1»g×>NÑ>NÐ=OÐ!PÓQÐQà�S‘	ˆAÜ˜a¤Ô%Ü Ð#=¼dÀ1»g×>NÑ>NÐ=OÐ!PÓQÐQà˜(‘^ˆFÜ˜f¤dÔ+Ü Ð!;Ó<Ð<áØ+ØØØØØØôð øô œ)Ð$ò 	VÜÐIÈ!ÈÐMÓNÐTUÐUûð	Vús   ‚EE ÅFÅ-E<Å<FN)r   r   r   r   r>   r@   rB   r&   r*   r-   r/   r1   r4   r7   r9   ÚclassmethodÚdictrG   r   r   r   r   r   $   sÉ   „ Ù1ðàðð ðð ð	ð
 ðð ðð ðð óð$˜3ó ð" 3ó "ð˜3ó ð˜Có ð�só ð�só ð˜4ó ð ð5V˜Tð 5VÐ&8ò 5Vó ñ5Vr   r   c            	       óÐ   — e Zd ZdZd„ Z	 	 	 ddedz  dedz  dedz  defd„Z	de
e   fd	„Zd
eddfd„Zde
e   fd„Zddddœdedz  deej                   z  dz  de
e   dz  ddfd„Zy)ÚBrowserz*BiDi implementation of the browser module.c                 ó   — || _         y r#   )Úconn)r%   rM   s     r   r&   zBrowser.__init__­   s	   € Øˆ�	r   NÚaccept_insecure_certsÚproxyÚunhandled_prompt_behaviorr'   c                 ó¼   — i }|�||d<   |�|j                  «       |d<   |�|j                  «       |d<   | j                  j                  t	        d|«      «      }|d   S )ao  Creates a new user context.

        Args:
            accept_insecure_certs: Optional flag to accept insecure TLS certificates.
            proxy: Optional proxy configuration for the user context.
            unhandled_prompt_behavior: Optional configuration for handling user prompts.

        Returns:
            str: The ID of the created user context.
        ÚacceptInsecureCertsrO   ÚunhandledPromptBehaviorzbrowser.createUserContextÚuserContext)Úto_bidi_dictÚto_dictrM   Úexecuter   )r%   rN   rO   rP   ÚparamsÚresults         r   Úcreate_user_contextzBrowser.create_user_context°   st   € ð  "$ˆà Ð,Ø,AˆFÐ(Ñ)àÐØ#×0Ñ0Ó2ˆF�7‰Oà$Ð0Ø0I×0QÑ0QÓ0SˆFÐ,Ñ-à—‘×"Ñ"¤?Ð3NÐPVÓ#WÓXˆØ�mÑ$Ð$r   c                 ó‚   — | j                   j                  t        di «      «      }|d   D �cg c]  }|d   ‘Œ	 c}S c c}w )zeGets all user contexts.

        Returns:
            List[str]: A list of user context IDs.
        zbrowser.getUserContextsÚuserContextsrT   )rM   rW   r   )r%   rY   Úcontext_infos      r   Úget_user_contextszBrowser.get_user_contextsÎ   s>   € ð —‘×"Ñ"¤?Ð3LÈbÓ#QÓRˆØ@FÀ~Ñ@VÖW°�˜]Ó+ÒWÐWùÒWs   ­<Úuser_context_idc                 óv   — |dk(  rt        d«      ‚d|i}| j                  j                  t        d|«      «       y)zÒRemoves a user context.

        Args:
            user_context_id: The ID of the user context to remove.

        Raises:
            ValueError: If the user context ID is "default" or does not exist.
        Údefaultz&Cannot remove the default user contextrT   zbrowser.removeUserContextN)r?   rM   rW   r   )r%   r_   rX   s      r   Úremove_user_contextzBrowser.remove_user_context×   s<   € ð ˜iÒ'ÜÐEÓFÐFà Ð1ˆØ�	‰	×Ñœ/Ð*EÀvÓNÕOr   c                 ó¢   — | j                   j                  t        di «      «      }|d   D �cg c]  }t        j	                  |«      ‘Œ c}S c c}w )z|Gets all client windows.

        Returns:
            List[ClientWindowInfo]: A list of client window information.
        zbrowser.getClientWindowsÚclientWindows)rM   rW   r   r   rG   )r%   rY   Úwindows      r   Úget_client_windowszBrowser.get_client_windowsæ   sE   € ð —‘×"Ñ"¤?Ð3MÈrÓ#RÓSˆØAGÈÑAXÖY°vÔ ×*Ñ*¨6Õ2ÒYÐYùÒYs   ­A)ÚallowedÚdestination_folderÚuser_contextsrg   rh   ri   c                óî   — i }|€d|d<   n?|r)|st        d«      ‚dt        j                  |«      dœ|d<   n|rt        d«      ‚ddi|d<   |�||d	<   | j                  j	                  t        d
|«      «       y)aœ  Set the download behavior for the browser or specific user contexts.

        Args:
            allowed: True to allow downloads, False to deny downloads, or None to
                clear download behavior (revert to default).
            destination_folder: Required when allowed is True. Specifies the folder
                to store downloads in.
            user_contexts: Optional list of user context IDs to apply this
                behavior to. If omitted, updates the default behavior.

        Raises:
            ValueError: If allowed=True and destination_folder is missing, or if
                allowed=False and destination_folder is provided.
        NÚdownloadBehaviorz1destination_folder is required when allowed=True.rg   )rA   ÚdestinationFolderz=destination_folder should not be provided when allowed=False.rA   Údeniedr\   zbrowser.setDownloadBehavior)r?   ÚosÚfspathrM   rW   r   )r%   rg   rh   ri   rX   s        r   Úset_download_behaviorzBrowser.set_download_behaviorï   s“   € ð* "$ˆàˆ?Ø)-ˆFÐ%Ò&áÙ)Ü$Ð%XÓYÐYà%Ü)+¯©Ð3EÓ)Fñ.�Ð)Ò*ñ
 &Ü$Ð%dÓeÐeØ.4°hÐ-?�Ð)Ñ*àÐ$Ø%2ˆF�>Ñ"à�	‰	×Ñœ/Ð*GÈÓPÕQr   )NNN)r   r   r   r   r&   rB   r   r   r>   rZ   Úlistr^   rb   r   rf   rn   ÚPathLikerp   r   r   r   rK   rK   ª   sá   „ Ù4òð
 .2Ø"Ø>Bñ	%à# d™{ð%ð �t‰|ð%ð $5°tÑ#;ð	%ð
 
ó%ð<X 4¨¡9ó XðP°3ð P¸4ó PðZ DÐ)9Ñ$:ó Zð  $Ø7;Ø*.ò)Rð ˜‘ð)Rð   "§+¡+Ñ-°Ñ4ð	)Rð
 ˜C‘y 4Ñ'ð)Rð 
ô)Rr   rK   )rn   Útypingr   Ú%selenium.webdriver.common.bidi.commonr   Ú&selenium.webdriver.common.bidi.sessionr   Úselenium.webdriver.common.proxyr   r   r   rK   r   r   r   ú<module>rw      s=   ðó" 
Ý å AÝ DÝ 1÷>ñ >÷CVñ CV÷LnRò nRr   