o
    M,h                     @   sF   d dl mZ d dlmZ G dd dZG dd dZG dd dZd	S )
    )Optionalcommand_builderc                   @   s&   e Zd ZdZdZdZdZeeehZdS )UserPromptHandlerTypez3Represents the behavior of the user prompt handler.acceptdismissignoreN)__name__
__module____qualname____doc__ACCEPTDISMISSIGNOREVALID_TYPES r   r   r/var/www/www-root/data/www/bot.pdev.uz/venv/lib/python3.10/site-packages/selenium/webdriver/common/bidi/session.pyr      s    r   c                   @   sn   e Zd ZdZ						ddee dee dee dee dee dee fd	d
Zdeeef fddZdS )UserPromptHandlerz8Represents the configuration of the user prompt handler.Nalertbefore_unloadconfirmdefaultfilepromptc           	      C   s   d|fd|fd|fd|fd|fd|ffD ]\}}|dur/|t jvr/td| d	| d
t j q|| _|| _|| _|| _|| _|| _dS )a  Initialize UserPromptHandler.

        Parameters:
        -----------
            alert: Handler type for alert prompts
            before_unload: Handler type for beforeUnload prompts
            confirm: Handler type for confirm prompts
            default: Default handler type for all prompts
            file: Handler type for file picker prompts
            prompt: Handler type for prompt dialogs

        Raises:
        ------
            ValueError: If any handler type is not valid
        r   r   r   r   r   r   NzInvalid z handler type: z. Must be one of )	r   r   
ValueErrorr   r   r   r   r   r   )	selfr   r   r   r   r   r   
field_namevaluer   r   r   __init__$   s$   
zUserPromptHandler.__init__returnc                 C   sF   ddddddd}i }|  D ]\}}t| |}|dur |||< q|S )	zConvert the UserPromptHandler to a dictionary for BiDi protocol.

        Returns:
        -------
            Dict[str, str]: Dictionary representation suitable for BiDi protocol
        r   beforeUnloadr   r   r   r   )r   r   r   r   r   r   N)itemsgetattr)r   field_mappingresult	attr_namedict_keyr   r   r   r   to_dictP   s   	
zUserPromptHandler.to_dict)NNNNNN)	r	   r
   r   r   r   strr   dictr'   r   r   r   r   r   !   s,    
,r   c                   @   s8   e Zd Zdd ZddddZddddZd	d
 ZdS )Sessionc                 C   s
   || _ d S )N)conn)r   r+   r   r   r   r   i   s   
zSession.__init__N)browsing_contextsc                G   *   d|i}|d u r
g }|r||d< t d|S )NeventsbrowsingContextszsession.subscriber   r   r,   r.   paramsr   r   r   	subscribel      
zSession.subscribec                G   r-   )Nr.   r/   zsession.unsubscriber   r0   r   r   r   unsubscribev   r3   zSession.unsubscribec                 C   s   t di }| j|S )a5  
        The session.status command returns information about the remote end's readiness
        to create new sessions and may include implementation-specific metadata.

        Returns
        -------
        dict
            Dictionary containing the ready state (bool), message (str) and metadata
        zsession.status)r   r+   execute)r   cmdr   r   r   status   s   

zSession.status)r	   r
   r   r   r2   r4   r7   r   r   r   r   r*   h   s
    

r*   N)typingr   %selenium.webdriver.common.bidi.commonr   r   r   r*   r   r   r   r   <module>   s
   
G