
    ,i                     t    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
 G d	 d
      Zy)    )AnyOptional)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     u/var/www/system.tvplus.app.br/jogos/scrap/venv/lib/python3.12/site-packages/selenium/webdriver/common/bidi/browser.pyr	   r	      s'    $JIIF	9f=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 )zGets 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_state:        zzr   c                     | j                   S )z|Gets the client window identifier.

        Returns:
        -------
            str: The client window identifier.
        )r   r*   s    r   get_client_windowz"ClientWindowInfo.get_client_windowC   s     !!!r   c                     | j                   S )zGets the width of the client window.

        Returns:
        -------
            int: The width of the client window.
        )r   r*   s    r   	get_widthzClientWindowInfo.get_widthL   r,   r   c                     | j                   S )zGets the height of the client window.

        Returns:
        -------
            int: The height of the client window.
        )r   r*   s    r   
get_heightzClientWindowInfo.get_heightU        {{r   c                     | j                   S )zGets the x coordinate of the client window.

        Returns:
        -------
            int: The x coordinate of the client window.
        )r    r*   s    r   get_xzClientWindowInfo.get_x^        vvr   c                     | j                   S )zGets the y coordinate of the client window.

        Returns:
        -------
            int: The y coordinate of the client window.
        )r!   r*   s    r   get_yzClientWindowInfo.get_yg   r6   r   c                     | j                   S )zChecks 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_activep   r3   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)a  Creates a ClientWindowInfo instance from a dictionary.

        Parameters:
        -----------
            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_dicty   s    )	O 0MmS1 !@AAMEeS) !9::-::: ?5'9JK\KiKiJj!kllMEeS)UQY #MeW!UVV(^Ffc*fqj #Nvh!WXXS	Aa% #=d1g>N>N=O!PQQS	Aa% #=d1g>N>N=O!PQQ(^Ffd+ !;<<+  )$ 	OI!MNN	Os   EE F -E;;F N)r   r   r   r   r?   rA   rC   r'   r+   r.   r0   r2   r5   r8   r:   classmethoddictrH   r   r   r   r   r   %   s    1  	
    $3 "3 "3 C s s 4  8OT 8O&8 8O 8Or   r   c            	       |    e Zd ZdZd Z	 	 	 ddee   dee   dee   de	fdZ
dee	   fd	Zd
e	ddfdZdee   fdZy)Browserz4
    BiDi implementation of the browser module.
    c                     || _         y r$   )conn)r&   rN   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 )a  Creates a new user context.

        Parameters:
        -----------
            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.
        acceptInsecureCertsrP   unhandledPromptBehaviorzbrowser.createUserContextuserContext)to_bidi_dictto_dictrN   executer   )r&   rO   rP   rQ   paramsresults         r   create_user_contextzBrowser.create_user_context   st    $ "$ ,,AF()#002F7O$00I0Q0Q0SF,-""?3NPV#WXm$$r   c                     | j                   j                  t        di             }|d   D cg c]  }|d   	 c}S c c}w )zuGets all user contexts.

        Returns:
        -------
            List[str]: A list of user context IDs.
        zbrowser.getUserContextsuserContextsrU   )rN   rX   r   )r&   rZ   context_infos      r   get_user_contextszBrowser.get_user_contexts   s>     ""?3Lb#QR@F~@VW]+WWWs   <user_context_idc                 v    |dk(  rt        d      d|i}| j                  j                  t        d|             y)zRemoves a user context.

        Parameters:
        -----------
            user_context_id: The ID of the user context to remove.

        Raises:
        ------
            Exception: If the user context ID is "default" or does not exist.
        defaultz&Cannot remove the default user contextrU   zbrowser.removeUserContextN)	ExceptionrN   rX   r   )r&   r`   rY   s      r   remove_user_contextzBrowser.remove_user_context   s<     i'DEE1		/*EvNOr   c                     | j                   j                  t        di             }|d   D cg c]  }t        j	                  |       c}S c c}w )zGets all client windows.

        Returns:
        -------
            List[ClientWindowInfo]: A list of client window information.
        zbrowser.getClientWindowsclientWindows)rN   rX   r   r   rH   )r&   rZ   windows      r   get_client_windowszBrowser.get_client_windows   sE     ""?3Mr#RSAGAXYv **62YYYs   A)NNN)r   r   r   r   r'   r   rC   r   r   r?   r[   listr_   rd   r   rh   r   r   r   rL   rL      s    
 15!%AE	%'~% % $,,=#>	%
 
%@X49 XP3 P4 P"ZD)9$: Zr   rL   N)typingr   r   %selenium.webdriver.common.bidi.commonr   &selenium.webdriver.common.bidi.sessionr   selenium.webdriver.common.proxyr   r	   r   rL   r   r   r   <module>rn      s:   & ! A D 1> >MO MO`KZ KZr   