o
    M,h3                     @   s   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G d	d
 d
Z	G dd dZ
G dd dZG dd dZG dd dZG dd d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ZdZdZdZdS )SameSitez5Represents the possible same site values for cookies.strictlaxnonedefaultN)__name__
__module____qualname____doc__STRICTLAXNONEDEFAULT r   r   r/var/www/www-root/data/www/bot.pdev.uz/venv/lib/python3.10/site-packages/selenium/webdriver/common/bidi/storage.pyr      s    r   c                   @   s8   e Zd ZdZdZdZdedefddZdefd	d
Z	dS )
BytesValuezRepresents a bytes value.base64stringtypevaluec                 C      || _ || _d S Nr   r   )selfr   r   r   r   r   __init__&      
zBytesValue.__init__returnc                 C      | j | jdS )zConverts the BytesValue to a dictionary.

        Returns:
        -------
            Dict: A dictionary representation of the BytesValue.
        r   r   r   r   r   r   to_dict*      zBytesValue.to_dictN)
r   r   r   r   TYPE_BASE64TYPE_STRINGstrr   dictr#   r   r   r   r   r       s    r   c                   @   sz   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 d
ee dee fddZ	e
dedd fddZdS )CookiezRepresents a cookie.Nnamer   domainpathsize	http_onlysecure	same_siteexpiryc
           
      C   :   || _ || _|| _|| _|| _|| _|| _|| _|	| _d S r   	r*   r   r+   r,   r-   r.   r/   r0   r1   
r   r*   r   r+   r,   r-   r.   r/   r0   r1   r   r   r   r   7      
zCookie.__init__datar    c                 C   s   | d}|std| d}|stdt| di  d| di  d}| t||t|| d| d| d	| d
| d| dd	S )zCreates a Cookie instance from a dictionary.

        Parameters:
        -----------
            data: A dictionary containing the cookie information.

        Returns:
        -------
            Cookie: A new instance of Cookie.
        r*   z$name is required and cannot be emptyr+   z&domain is required and cannot be emptyr   r   r,   r-   httpOnlyr/   sameSiter1   r3   )get
ValueErrorr   r'   )clsr6   r*   r+   r   r   r   r   	from_dictM   s$   

&zCookie.from_dict)NNNNNN)r   r   r   r   r'   r   r   intboolr   classmethodr(   r<   r   r   r   r   r)   4   s:    	

r)   c                   @   s   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 d	ee d
ee dee fddZ	de
eef fddZdS )CookieFilterz Represents a filter for cookies.Nr*   r   r+   r,   r-   r.   r/   r0   r1   c
           
      C   r2   r   r3   r4   r   r   r   r   r   r5   zCookieFilter.__init__r    c                 C   s   i }| j dur| j |d< | jdur| j |d< | jdur"| j|d< | jdur,| j|d< | jdur6| j|d< | jdur@| j|d< | jdurJ| j|d< | jdurT| j|d	< | j	dur^| j	|d
< |S )zConverts the CookieFilter to a dictionary.

        Returns:
        -------
            Dict: A dictionary representation of the CookieFilter.
        Nr*   r   r+   r,   r-   r7   r/   r8   r1   )
r*   r   r#   r+   r,   r-   r.   r/   r0   r1   r   resultr   r   r   r#      s(   
















zCookieFilter.to_dict)	NNNNNNNNN)r   r   r   r   r   r'   r   r=   r>   r   r(   r   r#   r   r   r   r   r@   o   s>    	

r@   c                   @   sB   e Zd ZdZddee dee fddZededd fd	d
Z	dS )PartitionKeyz#Represents a storage partition key.Nuser_contextsource_originc                 C   r   r   rD   rE   r   rD   rE   r   r   r   r      r   zPartitionKey.__init__r6   r    c                 C   s   | | d| ddS )a	  Creates a PartitionKey instance from a dictionary.

        Parameters:
        -----------
            data: A dictionary containing the partition key information.

        Returns:
        -------
            PartitionKey: A new instance of PartitionKey.
        userContextsourceOriginrF   )r9   )r;   r6   r   r   r   r<      s   zPartitionKey.from_dictNN)
r   r   r   r   r   r'   r   r?   r(   r<   r   r   r   r   rC      s
    rC   c                   @   s,   e Zd ZdZdefddZdefddZdS )	"BrowsingContextPartitionDescriptorz3Represents a browsing context partition descriptor.contextc                 C   s   d| _ || _d S )NrL   r   rL   )r   rL   r   r   r   r      r   z+BrowsingContextPartitionDescriptor.__init__r    c                 C   r!   )zConverts the BrowsingContextPartitionDescriptor to a dictionary.

        Returns:
        -------
            Dict: A dictionary representation of the BrowsingContextPartitionDescriptor.
        rM   rM   r"   r   r   r   r#      r$   z*BrowsingContextPartitionDescriptor.to_dictN)r   r   r   r   r'   r   r(   r#   r   r   r   r   rK      s    rK   c                   @   s:   e Zd ZdZd
dee dee fddZdefdd	ZdS )StorageKeyPartitionDescriptorz.Represents a storage key partition descriptor.NrD   rE   c                 C   s   d| _ || _|| _d S )N
storageKeyr   rD   rE   rG   r   r   r   r      s   
z&StorageKeyPartitionDescriptor.__init__r    c                 C   s6   d| j i}| jdur| j|d< | jdur| j|d< |S )zConverts the StorageKeyPartitionDescriptor to a dictionary.

        Returns:
        -------
            Dict: A dictionary representation of the StorageKeyPartitionDescriptor.
        r   NrH   rI   rP   rA   r   r   r   r#      s   




z%StorageKeyPartitionDescriptor.to_dictrJ   )	r   r   r   r   r   r'   r   r(   r#   r   r   r   r   rN      s    rN   c                   @   sp   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 d
ee fddZ	de
eef fddZdS )PartialCookiez(Represents a partial cookie for setting.Nr*   r   r+   r,   r.   r/   r0   r1   c	           	      C   s4   || _ || _|| _|| _|| _|| _|| _|| _d S r   )r*   r   r+   r,   r.   r/   r0   r1   )	r   r*   r   r+   r,   r.   r/   r0   r1   r   r   r   r      s   
zPartialCookie.__init__r    c                 C   s~   | 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r3| j|d< | jdur=| j|d< |S )zConverts the PartialCookie to a dictionary.

        Returns:
        -------
            Dict: A dictionary representation of the PartialCookie.
        )r*   r   r+   Nr,   r7   r/   r8   r1   )	r*   r   r#   r+   r,   r.   r/   r0   r1   rA   r   r   r   r#      s   









zPartialCookie.to_dict)NNNNN)r   r   r   r   r'   r   r   r>   r=   r   r(   r   r#   r   r   r   r   rQ      s2    	
rQ   c                   @   s<   e Zd ZdZdee defddZede	dd fdd	Z
d
S )GetCookiesResultz.Represents the result of a getCookies command.cookiespartition_keyc                 C   r   r   rS   rT   )r   rS   rT   r   r   r   r     r   zGetCookiesResult.__init__r6   r    c                 C   s4   dd | dg D }t| di }| ||dS )a  Creates a GetCookiesResult instance from a dictionary.

        Parameters:
        -----------
            data: A dictionary containing the get cookies result information.

        Returns:
        -------
            GetCookiesResult: A new instance of GetCookiesResult.
        c                 S   s   g | ]}t |qS r   )r)   r<   ).0cookier   r   r   
<listcomp>)  s    z.GetCookiesResult.from_dict.<locals>.<listcomp>rS   partitionKeyrU   )r9   rC   r<   )r;   r6   rS   rT   r   r   r   r<     s   zGetCookiesResult.from_dictN)r   r   r   r   listr)   rC   r   r?   r(   r<   r   r   r   r   rR     s
    rR   c                   @   4   e Zd ZdZdefddZededd fddZd	S )
SetCookieResultz-Represents the result of a setCookie command.rT   c                 C   
   || _ d S r   rT   r   rT   r   r   r   r   1     
zSetCookieResult.__init__r6   r    c                 C      t |di }| |dS )a  Creates a SetCookieResult instance from a dictionary.

        Parameters:
        -----------
            data: A dictionary containing the set cookie result information.

        Returns:
        -------
            SetCookieResult: A new instance of SetCookieResult.
        rY   r^   rC   r<   r9   r;   r6   rT   r   r   r   r<   4     
zSetCookieResult.from_dictN	r   r   r   r   rC   r   r?   r(   r<   r   r   r   r   r\   .  
    r\   c                   @   r[   )
DeleteCookiesResultz1Represents the result of a deleteCookies command.rT   c                 C   r]   r   r^   r_   r   r   r   r   G  r`   zDeleteCookiesResult.__init__r6   r    c                 C   ra   )a&  Creates a DeleteCookiesResult instance from a dictionary.

        Parameters:
        -----------
            data: A dictionary containing the delete cookies result information.

        Returns:
        -------
            DeleteCookiesResult: A new instance of DeleteCookiesResult.
        rY   r^   rb   rc   r   r   r   r<   J  rd   zDeleteCookiesResult.from_dictNre   r   r   r   r   rg   D  rf   rg   c                   @   s   e Zd ZdZdd Z		ddee deeee	f  de
fdd	Z	dd
edeeee	f  defddZ		ddee deeee	f  defddZdS )Storagez*BiDi implementation of the storage module.c                 C   r]   r   )conn)r   ri   r   r   r   r   ]  r`   zStorage.__init__Nfilter	partitionr    c                 C   H   i }|dur|  |d< |dur|  |d< | jtd|}t|S )a7  Retrieves cookies that match the given parameters.

        Parameters:
        -----------
            filter: Optional filter to match cookies.
            partition: Optional partition descriptor.

        Returns:
        -------
            GetCookiesResult: The result of the get cookies command.
        Nrj   rk   zstorage.getCookies)r#   ri   executer   rR   r<   r   rj   rk   paramsrB   r   r   r   get_cookies`     
zStorage.get_cookiesrW   c                 C   s<   d|  i}|dur|  |d< | jtd|}t|S )a  Sets a cookie in the browser.

        Parameters:
        -----------
            cookie: The cookie to set.
            partition: Optional partition descriptor.

        Returns:
        -------
            SetCookieResult: The result of the set cookie command.
        rW   Nrk   zstorage.setCookie)r#   ri   rm   r   r\   r<   )r   rW   rk   ro   rB   r   r   r   
set_cookiey  s
   
zStorage.set_cookiec                 C   rl   )aE  Deletes cookies that match the given parameters.

        Parameters:
        -----------
            filter: Optional filter to match cookies to delete.
            partition: Optional partition descriptor.

        Returns:
        -------
            DeleteCookiesResult: The result of the delete cookies command.
        Nrj   rk   zstorage.deleteCookies)r#   ri   rm   r   rg   r<   rn   r   r   r   delete_cookies  rq   zStorage.delete_cookiesrJ   r   )r   r   r   r   r   r   r@   r   rK   rN   rR   rp   rQ   r\   rr   rg   rs   r   r   r   r   rh   Z  s:    

rh   N)typingr   r   r   %selenium.webdriver.common.bidi.commonr   r   r   r)   r@   rC   rK   rN   rQ   rR   r\   rg   rh   r   r   r   r   <module>   s   	;60