§
    ¯õiû  ã                   ó^   — d dl Z d dlZd dlmZmZmZ d dlmZ d dlm	Z	  G d„ de	¦  «        Z
dS )é    N)ÚBinaryIOÚOptionalÚUnion)ÚDesiredCapabilities)Ú
ArgOptionsc            	       óÂ  ‡ — e Zd ZdZdˆ fd„Zedefd„¦   «         Zej        deddfd„¦   «         Zede	e         fd„¦   «         Z
e
j        deddfd	„¦   «         Z
edee         fd
„¦   «         Zdeddfd„Zdeddfd„Zedefd„¦   «         Zdedeeeeee         f         ddfd„Zedefd„¦   «         Zej        deddfd„¦   «         Zdefd„Zedefd„¦   «         Zˆ xZS )ÚChromiumOptionszgoog:chromeOptionsÚreturnNc                 óœ   •— t          ¦   «                              ¦   «          d| _        g | _        g | _        i | _        d| _        d| _        dS )z1Initialize ChromiumOptions with default settings.Ú NF)ÚsuperÚ__init__Ú_binary_locationÚ_extension_filesÚ_extensionsÚ_experimental_optionsÚ_debugger_addressÚ_enable_webextensions)ÚselfÚ	__class__s    €úo/var/www/html/nodeJS/PythonScripts/venv3.11/lib/python3.11/site-packages/selenium/webdriver/chromium/options.pyr   zChromiumOptions.__init__   sO   ø€ å‰Œ×ÒÑÔÐØ%'ˆÔØ+-ˆÔØ&(ˆÔØRTˆÔ"Ø04ˆÔØ+0ˆÔ"Ð"Ð"ó    c                 ó   — | j         S )z]
        Returns:
            The location of the binary, otherwise an empty string.
        )r   ©r   s    r   Úbinary_locationzChromiumOptions.binary_location'   s   € ð Ô$Ð$r   Úvaluec                 óf   — t          |t          ¦  «        st          | j        ¦  «        ‚|| _        dS )zzAllows you to set where the chromium binary lives.

        Args:
            value: Path to the Chromium binary.
        N)Ú
isinstanceÚstrÚ	TypeErrorÚBINARY_LOCATION_ERRORr   ©r   r   s     r   r   zChromiumOptions.binary_location/   s5   € õ ˜%¥Ñ%Ô%ð 	8Ý˜DÔ6Ñ7Ô7Ð7Ø %ˆÔÐÐr   c                 ó   — | j         S )zS
        Returns:
            The address of the remote devtools instance.
        )r   r   s    r   Údebugger_addressz ChromiumOptions.debugger_address:   s   € ð Ô%Ð%r   c                 ó\   — t          |t          ¦  «        st          d¦  «        ‚|| _        dS )zûAllows you to set the address of the remote devtools instance that
        the ChromeDriver instance will try to connect to during an active wait.

        Args:
            value: Address of remote devtools instance if any (hostname[:port]).
        z!Debugger Address must be a stringN)r   r   r    r   r"   s     r   r$   z ChromiumOptions.debugger_addressB   s4   € õ ˜%¥Ñ%Ô%ð 	AÝÐ?Ñ@Ô@Ð@Ø!&ˆÔÐÐr   c                 óÞ   — dt           dt          fd„}g }| j        D ]H}t          |d¦  «        5 }|                      ||¦  «        ¦  «         ddd¦  «         n# 1 swxY w Y   ŒI|| j        z   S )zX
        Returns:
            A list of encoded extensions that will be loaded.
        Ú	file_datar
   c                 ót   — t          j        |                      ¦   «         ¦  «                             d¦  «        S )Nzutf-8)Úbase64Ú	b64encodeÚreadÚdecode)r'   s    r   Ú_decodez+ChromiumOptions.extensions.<locals>._decodeU   s-   € õ Ô# I§N¢NÑ$4Ô$4Ñ5Ô5×<Ò<¸WÑEÔEÐEr   ÚrbN)r   r   r   ÚopenÚappendr   )r   r-   Úencoded_extensionsÚ	extensionÚfs        r   Ú
extensionszChromiumOptions.extensionsN   sÓ   € ð	F�xð 	F­Cð 	Fð 	Fð 	Fð 	Fð  ÐØÔ.ð 	6ð 	6ˆIÝ�i Ñ&Ô&ð 6¨!Ø"×)Ò)¨'¨'°!©*¬*Ñ5Ô5Ð5ð6ð 6ð 6ñ 6ô 6ð 6ð 6ð 6ð 6ð 6ð 6øøøð 6ð 6ð 6ð 6øð " DÔ$4Ñ4Ð4s   ®AÁA	Á A	r2   c                 ó0  — |r†t           j                             t           j                             |¦  «        ¦  «        }t           j                             |¦  «        r| j                             |¦  «         dS t          d¦  «        ‚t          d¦  «        ‚)z­Adds the path to the extension to a list that will be used to
        extract it to the ChromeDriver.

        Args:
            extension: Path to the \*.crx file.
        z#Path to the extension doesn't existúargument can not be nullN)	ÚosÚpathÚabspathÚ
expanduserÚexistsr   r0   ÚOSErrorÚ
ValueError)r   r2   Úextension_to_adds      r   Úadd_extensionzChromiumOptions.add_extensionb   s„   € ð ð 	9Ý!œwŸš­r¬w×/AÒ/AÀ)Ñ/LÔ/LÑMÔMÐÝŒw�~Š~Ð.Ñ/Ô/ð EØÔ%×,Ò,Ð-=Ñ>Ô>Ð>Ð>Ð>åÐCÑDÔDÐDåÐ7Ñ8Ô8Ð8r   c                 ó\   — |r| j                              |¦  «         dS t          d¦  «        ‚)zÏAdds Base64 encoded string with extension data to a list that will
        be used to extract it to the ChromeDriver.

        Args:
            extension: Base64 encoded string with extension data.
        r6   N)r   r0   r=   )r   r2   s     r   Úadd_encoded_extensionz%ChromiumOptions.add_encoded_extensionr   s8   € ð ð 	9ØÔ×#Ò# IÑ.Ô.Ð.Ð.Ð.åÐ7Ñ8Ô8Ð8r   c                 ó   — | j         S )zY
        Returns:
            A dictionary of experimental options for chromium.
        ©r   r   s    r   Úexperimental_optionsz$ChromiumOptions.experimental_options~   s   € ð Ô)Ð)r   Únamec                 ó   — || j         |<   dS )z¥Adds an experimental option which is passed to chromium.

        Args:
            name: The experimental option name.
            value: The option value.
        NrC   )r   rE   r   s      r   Úadd_experimental_optionz'ChromiumOptions.add_experimental_option†   s   € ð ,1ˆÔ" 4Ñ(Ð(Ð(r   c                 ó   — | j         S )z±
        Returns:
            Whether webextension support is enabled for Chromium-based browsers.
            True if webextension support is enabled, False otherwise.
        )r   r   s    r   Úenable_webextensionsz$ChromiumOptions.enable_webextensions�   s   € ð Ô)Ð)r   c                 óÂ   — || _         |r)ddg}|D ] }|| j        vr|                      |¦  «         Œ!dS ddg}|D ]%}|| j        v r| j                             |¦  «         Œ&dS )aÜ  Enables or disables webextension support for Chromium-based browsers.

        Args:
            value: True to enable webextension support, False to disable.

        Notes:
            - When enabled, this automatically adds the required Chromium flags:
                - --enable-unsafe-extension-debugging
                - --remote-debugging-pipe
            - When disabled, this removes BOTH flags listed above, even if they were manually added via add_argument()
              before enabling webextensions.
            - Enabling --remote-debugging-pipe makes the connection b/w chromedriver
              and the browser use a pipe instead of a port, disabling many CDP functionalities
              like devtools
        z#--enable-unsafe-extension-debuggingz--remote-debugging-pipeN)r   Ú
_argumentsÚadd_argumentÚremove)r   r   Úrequired_flagsÚflagÚflags_to_removes        r   rI   z$ChromiumOptions.enable_webextensions˜   s¥   € ð" &+ˆÔ"Øð 	1àCÐE^Ð_ˆNØ&ð ,ð ,�Ø˜tœÐ.Ð.Ø×%Ò% dÑ+Ô+Ð+øð,ð ,ð
  EÐF_Ð`ˆOØ'ð 1ð 1�Ø˜4œ?Ð*Ð*Ø”O×*Ò*¨4Ñ0Ô0Ð0øð1ð 1r   c                 ó  — | j         }| j                             ¦   «         }| j        r|                     | j        ¦  «         | j        |d<   | j        r
| j        |d<   | j        |d<   | j        r
| j        |d<   ||| j	        <   |S )z‰Creates a capabilities with all the options that have been set.

        Returns:
            A dictionary with all set options.
        r4   ÚbinaryÚargsÚdebuggerAddress)
Ú_capsrD   ÚcopyÚmobile_optionsÚupdater4   r   rK   r$   ÚKEY)r   ÚcapsÚchrome_optionss      r   Úto_capabilitieszChromiumOptions.to_capabilities·   s›   € ð ŒzˆØÔ2×7Ò7Ñ9Ô9ˆØÔð 	7Ø×!Ò! $Ô"5Ñ6Ô6Ð6Ø'+¤ˆ�|Ñ$ØÔð 	<Ø'+Ô';ˆN˜8Ñ$Ø!%¤ˆ�vÑØÔ ð 	FØ04Ô0EˆNÐ,Ñ-à'ˆˆTŒX‰àˆr   c                 ó>   — t           j                             ¦   «         S )N)r   ÚCHROMErV   r   s    r   Údefault_capabilitiesz$ChromiumOptions.default_capabilitiesÌ   s   € å"Ô)×.Ò.Ñ0Ô0Ð0r   )r
   N)Ú__name__Ú
__module__Ú__qualname__rY   r   Úpropertyr   r   Úsetterr   r$   Úlistr4   r?   rA   ÚdictrD   r   ÚintrG   ÚboolrI   r\   r_   Ú__classcell__)r   s   @r   r	   r	      sf  ø€ € € € € Ø
€Cð1ð 1ð 1ð 1ð 1ð 1ð ð% ð %ð %ð %ñ „Xð%ð Ôð& Sð &¨Tð &ð &ð &ñ Ôð&ð ð& (¨3¤-ð &ð &ð &ñ „Xð&ð Ôð	' cð 	'¨dð 	'ð 	'ð 	'ñ Ôð	'ð ð5˜D œIð 5ð 5ð 5ñ „Xð5ð&9 sð 9¨tð 9ð 9ð 9ð 9ð 
9¨sð 
9°tð 
9ð 
9ð 
9ð 
9ð ð* dð *ð *ð *ñ „Xð*ð1¨Cð 1¸¸cÀ3ÈÈdÐSVÌiÐ>WÔ8Xð 1Ð]að 1ð 1ð 1ð 1ð ð* dð *ð *ð *ñ „Xð*ð Ô ð1¨$ð 1°4ð 1ð 1ð 1ñ !Ô ð1ð< ð ð ð ð ð* ð1 dð 1ð 1ð 1ñ „Xð1ð 1ð 1ð 1ð 1r   r	   )r)   r7   Útypingr   r   r   Ú.selenium.webdriver.common.desired_capabilitiesr   Ú!selenium.webdriver.common.optionsr   r	   © r   r   ú<module>rn      s™   ðð$ €€€Ø 	€	€	€	Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,à NÐ NÐ NÐ NÐ NÐ NØ 8Ð 8Ð 8Ð 8Ð 8Ð 8ðt1ð t1ð t1ð t1ð t1�jñ t1ô t1ð t1ð t1ð t1r   