
    i                         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dS )    )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dS )ClientWindowStatezRepresents a window state.
fullscreen	maximized	minimizednormalN)	__name__
__module____qualname____doc__
FULLSCREEN	MAXIMIZED	MINIMIZEDNORMALVALID_STATES     r/var/www/html/nodeJS/PythonScripts/venv3.11/lib/python3.11/site-packages/selenium/webdriver/common/bidi/browser.pyr	   r	      s6        $$JIIF	9f=LLLr   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dS )ClientWindowInfoz'Represents a client window information.client_windowstatewidthheightxyactivec                 h    || _         || _        || _        || _        || _        || _        || _        d S Nr   r   r   r   r    r!   r"   )selfr   r   r   r   r    r!   r"   s           r   __init__zClientWindowInfo.__init__(   s:     +

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:        z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^        v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1 B !@AAAMEeS)) ; !9:::-::: !k5!k!kK\Ki!k!klllMEeS)) WUQYY !Ue!U!UVVV(^Ffc** Yfqjj !Wv!W!WXXXS	Aa%% R !Pd1gg>N!P!PQQQS	Aa%% R !Pd1gg>N!P!PQQQ(^Ffd++ = !;<<<3+    )$ 	O 	O 	OM!MMNNN	Os   F.F1 1GGGN)r   r   r   r   r?   rA   rC   r'   r+   r.   r0   r2   r5   r8   r:   classmethoddictrH   r   r   r   r   r   %   sf       11  	
       $3    "3 " " " "3    C    s    s    4     8OT 8O&8 8O 8O 8O [8O 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dS )Browserz4
    BiDi implementation of the browser module.
    c                     || _         d S r$   )conn)r&   rN   s     r   r'   zBrowser.__init__   s    			r   Naccept_insecure_certsproxyunhandled_prompt_behaviorr(   c                     i }|||d<   ||                                 |d<   ||                                |d<   | 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.
        N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   s~    $ "$ ,,AF()#0022F7O$00I0Q0Q0S0SF,-""?3NPV#W#WXXm$$r   c                 v    | j                             t          di                     }d |d         D             S )zuGets all user contexts.

        Returns:
        -------
            List[str]: A list of user context IDs.
        zbrowser.getUserContextsc                     g | ]
}|d          S )rU   r   ).0context_infos     r   
<listcomp>z-Browser.get_user_contexts.<locals>.<listcomp>   s    WWW]+WWWr   userContextsrN   rX   r   r&   rZ   s     r   get_user_contextszBrowser.get_user_contexts   s=     ""?3Lb#Q#QRRWW~@VWWWWr   user_context_idc                     |dk    rt          d          d|i}| j                            t          d|                     dS )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&   re   rY   s      r   remove_user_contextzBrowser.remove_user_context   sO     i''DEEE1	/*EvNNOOOOOr   c                 v    | j                             t          di                     }d |d         D             S )zGets all client windows.

        Returns:
        -------
            List[ClientWindowInfo]: A list of client window information.
        zbrowser.getClientWindowsc                 B    g | ]}t                               |          S r   )r   rH   )r^   windows     r   r`   z.Browser.get_client_windows.<locals>.<listcomp>   s'    YYYv **622YYYr   clientWindowsrb   rc   s     r   get_client_windowszBrowser.get_client_windows   s=     ""?3Mr#R#RSSYYAXYYYYr   )NNN)r   r   r   r   r'   r   rC   r   r   r?   r[   listrd   ri   r   rn   r   r   r   rL   rL      s           
 15!%AE	% %'~% % $,,=#>	%
 
% % % %@X49 X X X XP3 P4 P P P P"ZD)9$: Z Z Z Z Z 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>rt      s   & !               A A A A A A D D D D D D 1 1 1 1 1 1> > > > > > > >MO MO MO MO MO MO MO MO`KZ KZ KZ KZ KZ KZ KZ KZ KZ KZr   