
    ]j                    $   d dl mZ ddlmZmZ d dlmZ d dlZd dlZ G d dej                        Z
e G d d	             Z	 	 	 	 	 	 dd
Z	 d	 	 	 	 	 ddZddZ	 	 	 	 ddZ	 d	 	 	 	 	 	 	 ddZ	 	 	 	 	 	 	 	 ddZ	 	 	 	 	 	 ddZ	 	 	 	 	 	 	 	 ddZy)    )annotations   )event_classT_JSON_DICT)	dataclassNc                  6    e Zd ZdZdZdZdZdZd Ze	d        Z
y)	StorageAreaz
    Storage areas.
    sessionlocalsyncmanagedc                    | j                   S N)value)selfs    f/home/ubuntu/.local/lib/python3.12/site-packages/selenium/webdriver/common/devtools/v148/extensions.pyto_jsonzStorageArea.to_json   s    zz    c                     | |      S r    clsjsons     r   	from_jsonzStorageArea.from_json   s    4yr   N)__name__
__module____qualname____doc__SESSIONLOCALSYNCMANAGEDr   classmethodr   r   r   r   r	   r	      s6     GEDG  r   r	   c                  Z    e Zd ZU dZded<   ded<   ded<   ded<   ded<   d	 Zed
        Zy)ExtensionInfoz2
    Detailed information about an extension.
    strid_nameversionpathboolenabledc                    t               }| j                  |d<   | j                  |d<   | j                  |d<   | j                  |d<   | j
                  |d<   |S )Nidr(   r)   r*   r,   )dictr'   r(   r)   r*   r,   )r   r   s     r   r   zExtensionInfo.to_json2   sO    vXXT
yyV,,YyyV,,Yr   c           
          | t        |d         t        |d         t        |d         t        |d         t        |d               S )Nr.   r(   r)   r*   r,   )r'   r(   r)   r*   r,   )r&   r+   r   s     r   r   zExtensionInfo.from_json;   sJ    DJT&\"Y(T&\"i)
 	
r   N)r   r   r   r   __annotations__r   r#   r   r   r   r   r%   r%      sC     
H I L I M 
 
r   r%   c              #  F   K   t               }| |d<   ||d<   d|d}|}yw)a)  
    Runs an extension default action.
    Available if the client is connected using the --remote-debugging-pipe
    flag and the --enable-unsafe-extension-debugging flag is set.

    :param id_: Extension id.
    :param target_id: A tab target ID to trigger the default extension action on.
    r.   targetIdzExtensions.triggerActionmethodparamsNr/   )r'   	target_idr6   cmd_dictr   s        r   trigger_actionr:   F   s8      &FF4L"F:,H >Ds   !c              #  d   K   t               }| |d<   |||d<   d|d}|}t        |d         S w)a  
    Installs an unpacked extension from the filesystem similar to
    --load-extension CLI flags. Returns extension ID once the extension
    has been installed. Available if the client is connected using the
    --remote-debugging-pipe flag and the --enable-unsafe-extension-debugging
    flag is set.

    :param path: Absolute file path.
    :param enable_in_incognito: *(Optional)* Enable the extension in incognito
    :returns: Extension id.
    r*   enableInIncognitozExtensions.loadUnpackedr4   r.   )r/   r&   )r*   enable_in_incognitor6   r9   r   s        r   load_unpackedr>   \   sM      &FF6N&&9"#+H >DtDz?s   .0c               #  p   K   ddi} | }|d   D cg c]  }t         j                  |       c}S c c}w w)z
    Gets a list of all unpacked extensions.
    Available if the client is connected using the --remote-debugging-pipe flag
    and the --enable-unsafe-extension-debugging flag is set.

    :returns: 
    r5   zExtensions.getExtensions
extensions)r%   r   )r9   r   is      r   get_extensionsrB   w   sB      	,H >D04\0BC1M##A&CCCs   616c              #  <   K   t               }| |d<   d|d}|}yw)z
    Uninstalls an unpacked extension (others not supported) from the profile.
    Available if the client is connected using the --remote-debugging-pipe flag
    and the --enable-unsafe-extension-debugging.

    :param id_: Extension id.
    r.   zExtensions.uninstallr4   Nr7   )r'   r6   r9   r   s       r   	uninstallrD      s.      &FF4L(H >Ds   c              #     K   t               }| |d<   |j                         |d<   ||D cg c]  }| c}|d<   d|d}|}t        |d         S c c}w w)a(  
    Gets data from extension storage in the given ``storageArea``. If ``keys`` is
    specified, these are used to filter the result.

    :param id_: ID of extension.
    :param storage_area: StorageArea to retrieve data from.
    :param keys: *(Optional)* Keys to retrieve.
    :returns: 
    r.   storageAreakeyszExtensions.getStorageItemsr4   datar/   r   r'   storage_arearG   r6   rA   r9   r   s          r   get_storage_itemsrL      so      &FF4L(002F=%)*!*v.H >DV +s   )A	A"Ac              #     K   t               }| |d<   |j                         |d<   |D cg c]  }| c}|d<   d|d}|}yc c}w w)z
    Removes ``keys`` from extension storage in the given ``storageArea``.

    :param id_: ID of extension.
    :param storage_area: StorageArea to remove data from.
    :param keys: Keys to remove.
    r.   rF   rG   zExtensions.removeStorageItemsr4   NrI   rJ   s          r   remove_storage_itemsrN      sZ      &FF4L(002F=!%&Aa&F6N1H >D 's   'A	AAc              #  b   K   t               }| |d<   |j                         |d<   d|d}|}yw)z
    Clears extension storage in the given ``storageArea``.

    :param id_: ID of extension.
    :param storage_area: StorageArea to remove data from.
    r.   rF   zExtensions.clearStorageItemsr4   NrI   )r'   rK   r6   r9   r   s        r   clear_storage_itemsrP      sA      &FF4L(002F=0H >Ds   -/c              #  l   K   t               }| |d<   |j                         |d<   ||d<   d|d}|}yw)a  
    Sets ``values`` in extension storage in the given ``storageArea``. The provided ``values``
    will be merged with existing values in the storage area.

    :param id_: ID of extension.
    :param storage_area: StorageArea to set data in.
    :param values: Values to set.
    r.   rF   valueszExtensions.setStorageItemsr4   NrI   )r'   rK   rR   r6   r9   r   s         r   set_storage_itemsrS      sK      &FF4L(002F=F8.H >Ds   24)r'   r&   r8   r&   return0typing.Generator[T_JSON_DICT, T_JSON_DICT, None]r   )r*   r&   r=   ztyping.Optional[bool]rT   z/typing.Generator[T_JSON_DICT, T_JSON_DICT, str])rT   zFtyping.Generator[T_JSON_DICT, T_JSON_DICT, typing.List[ExtensionInfo]])r'   r&   rT   rU   )r'   r&   rK   r	   rG   z!typing.Optional[typing.List[str]]rT   z0typing.Generator[T_JSON_DICT, T_JSON_DICT, dict])r'   r&   rK   r	   rG   ztyping.List[str]rT   rU   )r'   r&   rK   r	   rT   rU   )r'   r&   rK   r	   rR   r/   rT   rU   )
__future__r   utilr   r   dataclassesr   enumtypingEnumr	   r%   r:   r>   rB   rD   rL   rN   rP   rS   r   r   r   <module>r\      s=   # * !  $)) " $
 $
 $
N 
80 6:2 
76D	7, 37! 0 
8	6!  
8	.! 
8(!  
8	r   