Ë
    `§1h¦5  ã                   óÈ   — d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
mZ d dlmZ d dlmZ d dlmZ dZ ed«       G d„ d	e«      «       Z G d
„ d«      Zy)é    N)ÚBytesIO)Úminidom)Ú
deprecated)ÚWebDriverExceptionzwebdriver_prefs.jsonú/Addons must be added after starting the sessionc                   ó   — e Zd ZdZy)ÚAddonFormatErrorz4Exception for not well-formed add-on manifest files.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    úh/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/selenium/webdriver/firefox/firefox_profile.pyr	   r	   &   s   „ â>r   r	   c                   óÎ  — e Zd ZdZdd„Zd„ Z ed«      dd„«       Zd„ Ze	d„ «       Z
e	 ed«      d	„ «       «       Zej                   ed«      dd„«       «       Ze	 ed«      d„ «       «       Zej                   ed«      dd„«       «       Ze	 ed«      d„ «       «       Zej                   ed«      dd„«       «       Ze	d
efd„«       Zd„ Z ed«      dd„«       Z ed«      d„ «       Zy)ÚFirefoxProfileNc           	      óB  — i | _         |r‡t        j                  j                  t	        j
                  «       d«      }t        j                  ||t        j                  ddd«      ¬«       || _	        t        j                  | j                  d«       y	t	        j
                  «       | _	        t        j                  swt        t        j                  j                  t        j                  j                  t        «      t         «      d¬«      5 }t#        j$                  |«      t        _        d	d	d	«       t'        j(                  t        j                  d
   «      | _         t        j                  d   j+                  «       D ]  \  }}|| j                   |<   Œ y	# 1 sw Y   ŒmxY w)a�  Initialises a new instance of a Firefox Profile.

        :args:
         - profile_directory: Directory of profile that you want to use. If a
           directory is passed in it will be cloned and the cloned directory
           will be used by the driver when instantiated.
           This defaults to None and will create a new
           directory when object is created.
        zwebdriver-py-profilecopyzparent.lockÚlockz.parentlock)Úignoreéí  úutf-8©ÚencodingNÚmutableÚfrozen)Ú_desired_preferencesÚosÚpathÚjoinÚtempfileÚmkdtempÚshutilÚcopytreeÚignore_patternsÚ_profile_dirÚchmodr   ÚDEFAULT_PREFERENCESÚopenÚdirnameÚ__file__ÚWEBDRIVER_PREFERENCESÚjsonÚloadÚcopyÚdeepcopyÚitems)ÚselfÚprofile_directoryÚnewprofÚdefault_prefsÚkeyÚvalues         r   Ú__init__zFirefoxProfile.__init__.   s7  € ð %'ˆÔ!ÙÜ—g‘g—l‘l¤8×#3Ñ#3Ó#5Ð7QÓRˆGÜ�O‰OØ! 7´6×3IÑ3IÈ-ÐY_ÐanÓ3oõð !(ˆDÔÜ�H‰H�T×&Ñ&¨Õ.ä (× 0Ñ 0Ó 2ˆDÔÜ!×5Ò5ÜÜ—G‘G—L‘L¤§¡§¡´Ó!:Ô<QÓRÐ]dôð Rà"Ü9=¿¹À=Ó9Q”NÔ6÷Rô
 )-¯©´n×6XÑ6XÐYbÑ6cÓ(dˆDÔ%Ü,×@Ñ@ÀÑJ×PÑPÓRò 7‘
��UØ16�×)Ñ)¨#Ò.ñ7÷Rð Rús   Ä
FÆFc                 ó"   — || j                   |<   y)z0Sets the preference that we want in the profile.N©r   )r1   r5   r6   s      r   Úset_preferencezFirefoxProfile.set_preferenceM   s   € à).ˆ×!Ñ! #Ò&r   r   c                 ó&   — | j                  |«       y ©N)Ú_install_extension)r1   Ú	extensions     r   Úadd_extensionzFirefoxProfile.add_extensionQ   s   € à×Ñ 	Õ*r   c           
      óÆ  — t         j                  j                  | j                  d«      }t         j                  j	                  |«      r't        j
                  |d«       | j                  |«       t        |dd¬«      5 }| j                  j                  «       D ]0  \  }}|j                  d|› dt        j                  |«      › d�«       Œ2 	 d	d	d	«       y	# 1 sw Y   y	xY w)
z&Writes the desired user prefs to disk.zuser.jsi¤  Úwr   r   zuser_pref("z", z);
N)r   r   r   r%   Úisfiler&   Ú_read_existing_userjsr(   r   r0   Úwriter,   Údumps)r1   Ú
user_prefsÚfr5   r6   s        r   Úupdate_preferencesz!FirefoxProfile.update_preferencesU   s¸   € ä—W‘W—\‘\ $×"3Ñ"3°YÓ?ˆ
Ü�7‰7�>‰>˜*Ô%Ü�H‰H�Z Ô'Ø×&Ñ& zÔ2Ü�*˜c¨GÔ4ð 	G¸Ø"×7Ñ7×=Ñ=Ó?ò G‘
��UØ—‘˜+ c U¨#¬d¯j©j¸Ó.?Ð-@ÀÐEÕFñG÷	G÷ 	Gñ 	Gús   Á?ACÃC c                 ó   — | j                   S )z8Gets the profile directory that is currently being used.)r%   ©r1   s    r   r   zFirefoxProfile.patha   s   € ð × Ñ Ð r   z'The port is stored in the Service classc                 ó   — | j                   S )z+Gets the port that WebDriver is working on.)Ú_portrJ   s    r   ÚportzFirefoxProfile.portf   s   € ð �z‰zÐr   Úreturnc                 ó   — t        |t        «      st        d«      ‚	 t        |«      }|dk  s|dkD  rt        d«      ‚	 || _        | j                  d| j
                  «       y# t        t        f$ r t        d«      ‚w xY w)z0Sets the port that WebDriver will be running on.zPort needs to be an integeré   iÿÿ  z)Port number must be in the range 1..65535Úwebdriver_firefox_portN)Ú
isinstanceÚintr   Ú
ValueErrorÚ	TypeErrorrL   r:   )r1   rM   s     r   rM   zFirefoxProfile.portl   s‰   € ô ˜$¤Ô$Ü$Ð%BÓCÐCð	DÜ�t“9ˆDØ�aŠx˜4 %š<Ü(Ð)TÓUÐUð (ð ˆŒ
Ø×ÑÐ4°d·j±jÕAøô œIÐ&ò 	DÜ$Ð%BÓCÐCð	Dús   � A" Á"A=z8Allowing untrusted certs is toggled in the Options classc                 ó    — | j                   d   S )NÚ webdriver_accept_untrusted_certsr9   rJ   s    r   Úaccept_untrusted_certsz%FirefoxProfile.accept_untrusted_certs{   s   € ð ×(Ñ(Ð)KÑLÐLr   c                 ó^   — t        |t        «      st        d«      ‚| j                  d|«       y )Nú%Please pass in a Boolean to this callrW   ©rR   Úboolr   r:   ©r1   r6   s     r   rX   z%FirefoxProfile.accept_untrusted_certs€   s+   € ô ˜%¤Ô&Ü$Ð%LÓMÐMØ×ÑÐ>ÀÕFr   c                 ó    — | j                   d   S )NÚ!webdriver_assume_untrusted_issuerr9   rJ   s    r   Úassume_untrusted_cert_issuerz+FirefoxProfile.assume_untrusted_cert_issuer‡   s   € ð ×(Ñ(Ð)LÑMÐMr   c                 ó^   — t        |t        «      st        d«      ‚| j                  d|«       y )NrZ   r_   r[   r]   s     r   r`   z+FirefoxProfile.assume_untrusted_cert_issuerŒ   s+   € ô ˜%¤Ô&Ü$Ð%LÓMÐMà×ÑÐ?ÀÕGr   c           	      ó$  — | j                   r| j                  «        t        «       }t        j                  |dt        j
                  d¬«      5 }t        | j                  «      dz   }t        j                  | j                  «      D ]B  \  }}}|D ]7  }t        j                  j                  ||«      }|j                  |||d «       Œ9 ŒD 	 ddd«       t        j                  |j                  «       «      j                  d«      S # 1 sw Y   Œ;xY w)z]Updates preferences and creates a zipped, base64 encoded string of
        profile directory.rA   F)Ústrict_timestampsrP   NzUTF-8)r   rH   r   ÚzipfileÚZipFileÚZIP_DEFLATEDÚlenr   r   Úwalkr   rD   Úbase64Ú	b64encodeÚgetvalueÚdecode)	r1   ÚfpÚzippedÚ	path_rootÚbaseÚ_ÚfilesÚfyleÚfilenames	            r   ÚencodedzFirefoxProfile.encoded”   sè   € ð ×$Ò$Ø×#Ñ#Ô%Ü‹YˆÜ�_‰_˜R ¤g×&:Ñ&:ÈeÔTð 	AÐX^Ü˜DŸI™I›¨Ñ*ˆIÜ"$§'¡'¨$¯)©)Ó"4ò A‘��a˜Ø!ò A�DÜ!Ÿw™wŸ|™|¨D°$Ó7�HØ—L‘L ¨8°I°JÐ+?Õ@ñAñA÷	Aô ×Ñ §¡£Ó.×5Ñ5°gÓ>Ð>÷	Að 	Aús   ÁA=DÄDc           
      ó¶  — t        j                  d«      }t        |d¬«      5 }|D ]T  }|j                  |«      }	 t	        j
                  |j                  d«      «      | j                  |j                  d«      <   ŒV 	 ddd«       y# t        $ r< t        j                  d|j                  d«      |j                  d«      z   › �«       Y Œ¥w xY w# 1 sw Y   yxY w)zRReads existing preferences and adds them to desired preference
        dictionary.zuser_pref\("(.*)",\s(.*)\)r   r   é   rP   z5(skipping) failed to json.loads existing preference: N)ÚreÚcompiler(   Úsearchr,   ÚloadsÚgroupr   Ú	ExceptionÚwarningsÚwarn)r1   ÚuserjsÚpref_patternrG   ÚusrÚmatchess         r   rC   z$FirefoxProfile._read_existing_userjs£   sÐ   € ô —z‘zÐ"?Ó@ˆÜ�& 7Ô+ð 	¨qØò �Ø&×-Ñ-¨cÓ2�ðÜBFÇ*Á*ÈWÏ]É]Ð[\ÓM]ÓB^�D×-Ñ-¨g¯m©m¸AÓ.>Ò?ñ÷	ð 	øô
 !ò Ü—M‘MØOÐPW×P]ÑP]Ð^_ÓP`Ðcj×cpÑcpÐqrÓcsÑPsÐOtÐuöðú÷	ð 	ús0   £C»A BÁ;CÂACÃ	CÃCÃCÃCc           	      óŠ  — d}d}|j                  d«      �rìt        j                  dt        j                  j                  |«      d   z   ¬«      }t        j                  |d«      }|j                  «       D �]…  }|j                  d«      rrt        j                  j                  t        j                  j                  ||«      «      rŒSt        j                  t        j                  j                  ||«      «       Œ‡t        j                  j                  t        j                  j                  t        j                  j                  ||«      «      «      sPt        j                  t        j                  j                  t        j                  j                  ||«      «      «       |j                  |«      }t        t        j                  j                  ||«      d«      5 }|j                  |«       ddd«       �Œˆ |}|}| j!                  |«      }	|	j#                  d	«      }
|
s
J d
|› �«       ‚t        j                  j                  | j$                  d«      }t        j                  j                  ||
«      }|sk|	d   sf|rdt        j                  j'                  |«      s+t        j                  |«       t        j(                  |d«       t+        j,                  ||dz   «       n7t        j                  j'                  |«      st+        j.                  ||d¬«       |rt+        j0                  |«       yy# 1 sw Y   �ŒÌxY w)zñInstalls addon from a filepath, url or directory of addons in the
        profile.

        - path: url, absolute path to .xpi, or directory of addons
        - unpack: whether to unpack unless specified otherwise in the install.rdf
        Nz.xpiú.éÿÿÿÿ)ÚsuffixÚrú/ÚwbÚidz!The addon id could not be found: Ú
extensionsÚunpackr   T)Úsymlinks)Úendswithr    r!   r   r   Úsplitrd   re   ÚnamelistÚisdirr   Úmakedirsr)   Úreadr(   rD   Ú_addon_detailsÚgetr%   Úexistsr&   r"   r.   r#   Úrmtree)r1   Úaddonr�   ÚtmpdirÚxpifileÚcompressed_fileÚnameÚdatarG   Úaddon_detailsÚaddon_idÚextensions_dirÚ
addon_paths                r   r=   z!FirefoxProfile._install_extension±   sE  € ð ˆØˆØ�>‰>˜&Õ!Ü×%Ñ%¨S´2·7±7·=±=ÀÓ3GÈÑ3KÑ-KÔLˆFÜ%Ÿo™o¨e°SÓ9ˆOØ'×0Ñ0Ó2ó 	&�Ø—=‘= Ô%ÜŸ7™7Ÿ=™=¬¯©¯©°f¸dÓ)CÕDÜŸ™¤B§G¡G§L¡L°¸Ó$>Õ?äŸ7™7Ÿ=™=¬¯©¯©¼¿¹¿¹ÀfÈdÓ9SÓ)TÔUÜŸ™¤B§G¡G§O¡O´B·G±G·L±LÀÈÓ4NÓ$OÔPØ*×/Ñ/°Ó5�DÜœbŸg™gŸl™l¨6°4Ó8¸$Ó?ð &À1ØŸ™ œ÷&ñ &ð	&ð ˆGØˆEð ×+Ñ+¨EÓ2ˆØ ×$Ñ$ TÓ*ˆÙÐDÐ<¸U¸GÐDÓDˆxô Ÿ™Ÿ™ d×&7Ñ&7¸ÓFˆÜ—W‘W—\‘\ .°(Ó;ˆ
Ù˜m¨HÒ5¹'Ü—7‘7—>‘> .Ô1Ü—‘˜NÔ+Ü—‘˜¨Ô/Ü�K‰K˜ ¨fÑ!4Õ5ä—7‘7—>‘> *Ô-Ü—‘  z¸DÕAñ Ü�M‰M˜&Õ!ð ÷/&ñ &ús   Ç"L8Ì8M	c                 ót  — dddddœ}d„ }d„ }d„ }t         j                  j                  |«      st        d|› �«      ‚	 t	        j
                  |«      rct	        j                  |d«      5 }d	|j                  «       v r  ||j                  d	«      «      cddd«       S |j                  d
«      }ddd«       nÞt         j                  j                  |«      r±t         j                  j                  |d	«      }t         j                  j                  |«      r-t        |d¬«      5 }	 ||	j                  «       «      cddd«       S t        t         j                  j                  |d
«      d¬«      5 }	|	j                  «       }ddd«       nt        d|› �«      ‚	 t#        j$                  «      } ||d«      } ||d«      }|j'                  |dz   «      j)                  d«      }|s |j'                  d«      j)                  d«      }|j*                  D ]<  }|j,                  j/                  |d«      }||v sŒ$|j1                  | ||«      i«       Œ> |j3                  d«      sot5        |j6                  j8                  «      D ]M  }|j6                  j)                  |«      }|j:                  |dz   k(  sŒ1|j1                  d|j<                  i«       ŒO tA        |d   t        «      r|d   jC                  «       dk(  |d<   |j3                  d«      st        d«      ‚|S # 1 sw Y   �ŒŒxY w# 1 sw Y   �ŒìxY w# 1 sw Y   �Œ¦xY w# t        t        f$ r/}
t        t        |
«      t        j                   «       d   «      ‚d}
~
ww xY w# t>        $ r/}
t        t        |
«      t        j                   «       d   «      ‚d}
~
ww xY w)aš  Returns a dictionary of details about the addon.

        :param addon_path: path to the add-on directory or XPI

        Returns::

            {
                "id": "rainbow@colors.org",  # id of the addon
                "version": "1.4",  # version of the addon
                "name": "Rainbow",  # name of the addon
                "unpack": False,
            }  # whether to unpack the addon
        NF)r‹   r�   r�   Úversionc                 óH  — | j                   j                  }d}t        |j                  «      D ]q  }|j	                  |«      j
                  |k(  sŒ"d|j	                  |«      j                  v sŒ@|j	                  |«      j                  j                  d«      d   dz   } |S  |S )NÚ ú:rP   )ÚdocumentElementÚ
attributesÚrangeÚlengthÚitemr6   r�   r�   )ÚdocÚurlr©   Ú	namespaceÚis        r   Úget_namespace_idz7FirefoxProfile._addon_details.<locals>.get_namespace_idò   sš   € Ø×,Ñ,×7Ñ7ˆJØˆIÜ˜:×,Ñ,Ó-ò �Ø—?‘? 1Ó%×+Ñ+¨sÓ2Ø˜jŸo™o¨aÓ0×5Ñ5Ò5à$.§O¡O°AÓ$6×$;Ñ$;×$AÑ$AÀ#Ó$FÀqÑ$IÈCÑ$O˜	ØØÐðð Ðr   c                 óÐ   — g }| j                   D ]7  }|j                  |j                  k(  sŒ|j                  |j                  «       Œ9 dj                  |«      j                  «       S )z(Retrieve the text value of a given node.r¦   )Ú
childNodesÚnodeTypeÚ	TEXT_NODEÚappendrž   r   Ústrip)ÚelementÚrcÚnodes      r   Úget_textz/FirefoxProfile._addon_details.<locals>.get_textý   sU   € àˆBØ×*Ñ*ò )�Ø—=‘= D§N¡NÓ2Ø—I‘I˜dŸi™iÕ(ð)ð —7‘7˜2“;×$Ñ$Ó&Ð&r   c                 ó¸   — t        j                  | «      }	 |d   d   d   }||d   |d   d	d
œS # t        $ r! |d   j                  dd«      dz   |d   z   }Y Œ6w xY w)z[Extracts the details from the contents of a WebExtensions
            `manifest.json` file.ÚapplicationsÚgeckor‹   r�   ú r¦   ú@r¤   F)r‹   r¤   r�   r�   )r,   r{   ÚKeyErrorÚreplace)ÚcontentÚmanifestr‹   s      r   Úparse_manifest_jsonz:FirefoxProfile._addon_details.<locals>.parse_manifest_json  s‡   € ô —z‘z 'Ó*ˆHðSØ˜nÑ-¨gÑ6°tÑ<�ð Ø# IÑ.Ø  Ñ+Øñ	ð øô ò SØ˜fÑ%×-Ñ-¨c°2Ó6¸Ñ<¸xÈ	Ñ?RÑR’ðSús   —/ ¯'AÁAzAdd-on path does not exist: rˆ   zmanifest.jsonzinstall.rdfr   r   z/Add-on path is neither an XPI nor a directory: rw   z#http://www.mozilla.org/2004/em-rdf#z+http://www.w3.org/1999/02/22-rdf-syntax-ns#ÚDescriptionr   r¦   r‹   r�   ÚtruezAdd-on id could not be found.)"r   r   r—   ÚOSErrorrd   Ú
is_zipfilere   r‘   r”   r’   r   r(   rÁ   r	   ÚstrÚsysÚexc_infor   ÚparseStringÚgetElementsByTagNamer¬   r³   ÚnodeNamerÂ   Úupdater–   rª   r©   r«   r�   r6   r}   rR   Úlower)r1   r¢   Údetailsr±   r»   rÅ   rœ   rÄ   Úmanifest_json_filenamerG   Úer­   ÚemÚrdfÚdescriptionrº   Úentryr°   Ú	attributes                      r   r•   zFirefoxProfile._addon_detailsà   s_  € ð  ¨¸ÈÑNˆò		ò	'ò	ô �w‰w�~‰~˜jÔ)ÜÐ8¸¸ÐEÓFÐFð	>Ü×!Ñ! *Ô-Ü—_‘_ Z°Ó5ð C¸Ø&¨/×*BÑ*BÓ*DÑDÙ2°?×3GÑ3GÈÓ3XÓY÷Cñ Cð  /×3Ñ3°MÓB�H÷	Cð Cô
 —‘—‘˜zÔ*Ü)+¯©¯©°jÀ/Ó)RÐ&Ü—7‘7—>‘>Ð"8Ô9ÜÐ4¸wÔGð =È1Ù2°1·6±6³8Ó<÷=ñ =ô œ"Ÿ'™'Ÿ,™, z°=ÓAÈGÔTð (ÐXYØ Ÿv™v›x�H÷(ð (ô Ð OÐPZÈ|Ð\Ó]Ð]ð	>Ü×%Ñ% hÓ/ˆCñ " #Ð'LÓMˆBÙ" 3Ð(UÓVˆCà×2Ñ2°3¸Ñ3FÓG×LÑLÈQÓOˆKÙØ!×6Ñ6°}ÓE×JÑJÈ1ÓM�Ø#×.Ñ.ò <�àŸ™×-Ñ-¨b°"Ó5�Ø˜GÒ#Ø—N‘N E©8°D«>Ð#:Õ;ð	<ð
 —;‘;˜tÔ$Ü˜{×5Ñ5×<Ñ<Ó=ò @�AØ +× 6Ñ 6× ;Ñ ;¸AÓ >�IØ —~‘~¨¨d©Ó2ØŸ™¨¨i¯o©oÐ'>Õ?ð@ô �g˜hÑ'¬Ô-Ø '¨Ñ 1× 7Ñ 7Ó 9¸VÑ CˆG�HÑð �{‰{˜4Ô Ü"Ð#BÓCÐCàˆ÷cCñ Cú÷=ñ =ú÷(ñ (ûô œÐ"ò 	>Ü"¤3 q£6¬3¯<©<«>¸!Ñ+<Ó=Ð=ûð	>ûô. ò 	>Ü"¤3 q£6¬3¯<©<«>¸!Ñ+<Ó=Ð=ûð	>ús˜   ¿+L> Á*)LÂ	L> ÂLÂ.A4L> Ä"L$Ä8	L> Å+L> Å-L1Å>L> ÆBM? È2A;M? Ê.M? ÌL!ÌL> Ì$L.Ì)L> Ì1L;Ì6L> Ì>M<Í*M7Í7M<Í?	N7Î*N2Î2N7r<   )rN   N)T)r
   r   r   r'   r7   r:   r   r?   rH   Úpropertyr   rM   ÚsetterrX   r`   rÊ   ru   rC   r=   r•   r   r   r   r   r   +   sŠ  „ ØÐó7ò>/ñ ÐAÓBò+ó Cð+òGð ñ!ó ð!ð ÙÐ9Ó:ñó ;ó ðð 
‡[�[ÙÐ9Ó:òBó ;ó ðBð ÙÐJÓKñMó Ló ðMð ×"Ñ"ÙÐJÓKòGó Ló #ðGð
 ÙÐJÓKñNó Ló ðNð "×(Ñ(ÙÐJÓKòHó Ló )ðHð ð?˜ò ?ó ð?òñ ÐAÓBò,"ó Cð,"ñ\ ÐAÓBñió Cñir   r   )ri   r.   r,   r   rx   r"   rË   r    r~   rd   Úior   Úxml.domr   Útyping_extensionsr   Úselenium.common.exceptionsr   r+   r}   r	   r   r   r   r   ú<module>rà      sd   ðó$ Û Û Û 	Û 	Û Û 
Û Û Û Ý Ý å (å 9à.Ð ñ Ð=Ó>ô?�yó ?ó ?ð?÷_ò _r   