Ë
    `§1hI  ã                   óÂ  — U 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 dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlZd dlmZ d dlmZ  ej2                  d«      Z ed«      ZdZdadad„ Z e j@                  d«      a!e j@                  e"d<    e j@                  d«      a#e j@                  e"d<   d„ Z$d„ Z%e
d„ «       Z&e
d„ «       Z'd„ Z(d„ Z) G d„ de*«      Z+ G d„ de«      Z, G d „ d!e*«      Z-e G d"„ d#«      «       Z. G d$„ d%«      Z/ G d&„ d'e/«      Z0 G d(„ d)e/ejb                  jd                  «      Z3e	d*ee3   fd+„«       Z4d*e3fd,„Z5y)-é    N)Údefaultdict)Úasynccontextmanager)Úcontextmanager)Ú	dataclass)ÚAny)ÚAsyncGenerator)ÚAsyncIterator)Ú	Generator)ÚType)ÚTypeVar)ÚConnectionClosed)Úconnect_websocket_urlÚtrio_cdpÚTi   c                 óÊ  — | a d}	 t        j                  |› | › �«      at        S # t        $ r´ t        j                  t        «      j                  d   j                  d«      }t        d„ |j                  «       D «       «      }t        d„ |D «       «      }t        j                  t        «      }|j!                  d|«       t        j                  |› |› �«      at        cY S w xY w)z^Attempt to load the current latest available devtools into the module
    cache for use later.z$selenium.webdriver.common.devtools.vé   Údevtoolsc              3   óV   K  — | ]!  }|j                  «       sŒ|j                  –— Œ# y ­w©N)Úis_dirÚname)Ú.0Úfs     ú`/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/selenium/webdriver/common/bidi/cdp.pyú	<genexpr>z"import_devtools.<locals>.<genexpr>F   s   è ø€ ÒO AÀAÇHÁHÅJ˜Ÿ�ÑOùs   ‚)˜)c              3   ó8   K  — | ]  }t        |d d «      –— Œ y­w)r   N)Úint)r   Úxs     r   r   z"import_devtools.<locals>.<genexpr>G   s   è ø€ Ò2 A”S˜˜1˜2˜—ZÑ2ùs   ‚z'Falling back to loading `devtools`: v%s)ÚversionÚ	importlibÚimport_moduler   ÚModuleNotFoundErrorÚpathlibÚPathÚ__file__ÚparentsÚjoinpathÚtupleÚiterdirÚmaxÚloggingÚ	getLoggerÚ__name__Údebug)ÚverÚbaseÚdevtools_pathÚversionsÚlatestÚselenium_loggers         r   Úimport_devtoolsr5   8   sÍ   € ð
 €GØ1€DðÜ×*Ñ*¨d¨V°C°5¨>Ó:ˆÜˆøÜò 	ô  Ÿ™¤XÓ.×6Ñ6°qÑ9×BÑBÀ:ÓNˆÜÑO¨×)>Ñ)>Ó)@ÔOÓOˆÜÑ2¨Ô2Ó2ˆÜ!×+Ñ+¬HÓ5ˆØ×ÑÐGÈÔPÜ×*Ñ*¨d¨V°F°8Ð+<Ó=ˆÜŠð	ús   †% ¥B:C"Ã!C"Úconnection_contextÚ_connection_contextÚsession_contextÚ_session_contextc                 ób   — 	 t         j                  «       S # t        $ r t        | › d�«      ‚w xY w)z�Look up the current connection.

    If there is no current connection, raise a ``RuntimeError`` with a
    helpful message.
    z*() must be called in a connection context.)r7   ÚgetÚLookupErrorÚRuntimeError©Úfn_names    r   Úget_connection_contextr@   R   s;   € ðSÜ"×&Ñ&Ó(Ð(øÜò SÜ˜g˜YÐ&PÐQÓRÐRðSúó   ‚ –.c                 ób   — 	 t         j                  «       S # t        $ r t        | › d�«      ‚w xY w)z{Look up the current session.

    If there is no current session, raise a ``RuntimeError`` with a
    helpful message.
    z'() must be called in a session context.)r9   r;   r<   r=   r>   s    r   Úget_session_contextrC   ^   s;   € ðPÜ×#Ñ#Ó%Ð%øÜò PÜ˜g˜YÐ&MÐNÓOÐOðPúrA   c              #   óž   K  — t         j                  | «      }	 d–— t         j                  |«       y# t         j                  |«       w xY w­w)zbThis context manager installs ``connection`` as the session context for
    the current Trio task.N)r7   ÚsetÚreset)Ú
connectionÚtokens     r   r6   r6   j   s=   è ø€ ô  ×#Ñ# JÓ/€Eð)Ûä×!Ñ! %Õ(øÔ×!Ñ! %Õ(üó   ‚A™3 �A³A
Á
Ac              #   óž   K  — t         j                  | «      }	 d–— t         j                  |«       y# t         j                  |«       w xY w­w)z_This context manager installs ``session`` as the session context for the
    current Trio task.N)r9   rE   rF   )ÚsessionrH   s     r   r8   r8   u   s=   è ø€ ô × Ñ  Ó)€Eð&Ûä×Ñ˜uÕ%øÔ×Ñ˜uÕ%ürI   c                 ó2   — t        j                  d| ¬«      ay)zõInstall ``connection`` in the root context so that it will become the
    default connection for all tasks.

    This is generally not recommended, except it may be necessary in
    certain use cases such as running inside Jupyter notebook.
    r7   ©ÚdefaultN)ÚcontextvarsÚ
ContextVarr7   )rG   s    r   Úset_global_connectionrQ   €   s   € ô &×0Ñ0Ð1FÐPZÔ[Ñó    c                 ó2   — t        j                  d| ¬«      ay)zïInstall ``session`` in the root context so that it will become the
    default session for all tasks.

    This is generally not recommended, except it may be necessary in
    certain use cases such as running inside Jupyter notebook.
    r9   rM   N)rO   rP   r9   )rK   s    r   Úset_global_sessionrT   ‹   s   € ô #×-Ñ-Ð.@È'ÔRÑrR   c                   ó   — e Zd ZdZd„ Zd„ Zy)ÚBrowserErrorzgThis exception is raised when the browser's response to a command
    indicates that an error occurred.c                 óˆ   — |j                  d«      | _        |j                  d«      | _        |j                  d«      | _        y )NÚcodeÚmessageÚdata)r;   rX   rY   Údetail)ÚselfÚobjs     r   Ú__init__zBrowserError.__init__š   s0   € Ø—G‘G˜F“OˆŒ	Ø—w‘w˜yÓ)ˆŒØ—g‘g˜f“oˆ�rR   c                 óT   — d| j                   › d| j                  › d| j                  › �S )NzBrowserError<code=z	 message=z> )rX   rY   r[   ©r\   s    r   Ú__str__zBrowserError.__str__Ÿ   s'   € Ø# D§I¡I ;¨i¸¿¹°~ÀRÈÏÉÀ}ÐUÐUrR   N)r-   Ú
__module__Ú__qualname__Ú__doc__r^   ra   © rR   r   rV   rV   –   s   „ ñ)ò&ó
VrR   rV   c                   ó   — e Zd ZdZd„ Zd„ Zy)ÚCdpConnectionClosedzARaised when a public method is called on a closed CDP connection.c                 ó   — || _         y)zfConstructor.

        :param reason:
        :type reason: wsproto.frame_protocol.CloseReason
        N)Úreason)r\   ri   s     r   r^   zCdpConnectionClosed.__init__¦   s   € ð ˆ�rR   c                 óN   — | j                   j                  › d| j                  › d�S )zReturn representation.ú<ú>)Ú	__class__r-   ri   r`   s    r   Ú__repr__zCdpConnectionClosed.__repr__®   s$   € à—.‘.×)Ñ)Ð*¨!¨D¯K©K¨=¸Ð:Ð:rR   N)r-   rb   rc   rd   r^   rn   re   rR   r   rg   rg   £   s   „ ÙKòó;rR   rg   c                   ó   — e Zd ZdZy)ÚInternalErrorzfThis exception is only raised when there is faulty logic in TrioCDP or
    the integration with PyCDP.N)r-   rb   rc   rd   re   rR   r   rp   rp   ³   s   „ ò#rR   rp   c                   ó    — e Zd ZU dZdZeed<   y)ÚCmEventProxyz³A proxy object returned by :meth:`CdpBase.wait_for()``.

    After the context manager executes, this proxy object will have a
    value set that contains the returned event.
    NÚvalue)r-   rb   rc   rd   rs   r   Ú__annotations__re   rR   r   rr   rr   ¸   s   … ñð €Eˆ3ÔrR   rr   c                   óx   — e Zd Zd„ Zdeeeef   defd„Zddœd„Z	e
ddee   deed	f   fd
„«       Zd„ Zd„ Zd„ Zy	)ÚCdpBasec                 ó¤   — || _         || _        || _        t        t        «      | _        t        j                  «       | _        i | _	        i | _
        y r   )ÚwsÚ
session_idÚ	target_idr   rE   ÚchannelsÚ	itertoolsÚcountÚid_iterÚinflight_cmdÚinflight_result)r\   rx   ry   rz   s       r   r^   zCdpBase.__init__Ä   sA   € ØˆŒØ$ˆŒØ"ˆŒÜ#¤CÓ(ˆŒÜ —‘Ó(ˆŒØˆÔØ!ˆÕrR   ÚcmdÚreturnc              ƒ   óÄ  K  — t        | j                  «      }t        j                  «       }||f| j                  |<   t        |«      }||d<   | j
                  r| j
                  |d<   t        j                  |«      }t        j                  t        j                  «      rt        j                  d|› d|› d|› �«       	 | j                  j                  |«      ƒ d{  –—†  |j%                  «       ƒ d{  –—†  | j&                  j)                  |«      }t        j                  t        j                  «      rt        j                  d|› �«       t+        |t,        «      rSt        j                  t        j                  «      r.t        j                  d|› d	t/        |«      j0                  › �«       |‚|S 7 Œ×# t        $ r}t!        |j"                  «      d‚d}~ww xY w7 Œè­w)
z…Execute a command on the server and wait for the result.

        :param cmd: any CDP command
        :returns: a CDP result
        ÚidÚ	sessionIdzSending CDP message: ú z: NzReceived CDP message: zException raised by z
 message: )Únextr~   ÚtrioÚEventr   ry   ÚjsonÚdumpsÚloggerÚisEnabledForr+   ÚDEBUGr.   rx   Úsend_messageÚWsConnectionClosedrg   ri   Úwaitr€   ÚpopÚ
isinstanceÚ	ExceptionÚtyper-   )r\   r�   Úcmd_idÚ	cmd_eventÚrequestÚrequest_strÚwccÚresponses           r   ÚexecutezCdpBase.executeÍ   s{  è ø€ ô �d—l‘lÓ#ˆÜ—J‘J“Lˆ	Ø$'¨ Nˆ×Ñ˜&Ñ!Ü�s“)ˆØˆ�‰Ø�?Š?Ø#'§?¡?ˆG�KÑ Ü—j‘j Ó)ˆÜ×ÑœwŸ}™}Ô-Ü�L‰LÐ0°°¸¸)¸ÀBÀ{ÀmÐTÔUð	<Ø—'‘'×&Ñ& {Ó3×3Ð3ð �n‰nÓ×ÐØ×'Ñ'×+Ñ+¨FÓ3ˆÜ×ÑœwŸ}™}Ô-Ü�L‰LÐ1°(°Ð<Ô=Ü�h¤	Ô*Ü×"Ñ"¤7§=¡=Ô1Ü—‘Ð3°I°;¸jÌÈhË×I`ÑI`ÐHaÐbÔcØˆNØˆð 4ùÜ!ò 	<Ü% c§j¡jÓ1°tÐ;ûð	<úàúsI   ‚B<G Â?F7 ÃF5ÃF7 Ã"G Ã5GÃ6B?G Æ5F7 Æ7	GÇ GÇGÇG é
   )Úbuffer_sizec                ó€   — t        j                  |«      \  }}|D ]   }| j                  |   j                  |«       Œ" |S )zXReturn an async iterator that iterates over events matching the
        indicated types.)rˆ   Úopen_memory_channelr{   Úadd)r\   rž   Úevent_typesÚsenderÚreceiverÚ
event_types         r   ÚlistenzCdpBase.listenë   sD   € ô  ×3Ñ3°KÓ@Ñˆ�Ø%ò 	2ˆJØ�M‰M˜*Ñ%×)Ñ)¨&Õ1ð	2àˆrR   r¥   Nc                óN  K  — t        j                  |«      \  }}| j                  |   j                  |«       t	        «       }|­–— |4 ƒd{  –—†  |j                  «       ƒ d{  –—† }ddd«      ƒd{  –—†  ||_        y7 Œ47 Œ7 Œ# 1 ƒd{  –—†7  sw Y   |_        yxY w­w)zçWait for an event of the given type and return it.

        This is an async context manager, so you should open it inside
        an async with block. The block will not exit until the indicated
        event is received.
        N)rˆ   r    r{   r¡   rr   Úreceivers   )r\   r¥   rž   r£   r¤   ÚproxyÚevents          r   Úwait_forzCdpBase.wait_foró   s•   è ø€ ô  ×3Ñ3°KÓ@Ñˆ�Ø�‰�jÑ!×%Ñ% fÔ-Ü“ˆØ‹Ø÷ 	-ñ 	-Ø"×*Ñ*Ó,×,ˆE÷	-÷ 	-àˆ�ð	-øØ,øð	-ø÷ 	-÷ 	-ð 	-àˆ�üsZ   ‚AB%ÁBÁB%ÁB	Á&BÁ'B	Á+B%Á6BÁ7B%ÂB	ÂB%Â	B"ÂBÂB"ÂB%c                 óR   — d|v r| j                  |«       y| j                  |«       y)zUHandle incoming WebSocket data.

        :param dict data: a JSON dictionary
        r„   N)Ú_handle_cmd_responseÚ_handle_event)r\   rZ   s     r   Ú_handle_datazCdpBase._handle_data  s'   € ð
 �4‰<Ø×%Ñ% dÕ+à×Ñ˜tÕ$rR   c                 óš  — |d   }	 | j                   j                  |«      \  }}d|v rt        |d   «      | j                  |<   n 	 |j                  |d   «      }t        d«      ‚|j                  «        y# t        $ r t        j	                  d|«       Y yw xY w# t        $ r}|j                  }Y d}~nd}~ww xY w|| j                  |<   Œh)zÃHandle a response to a command. This will set an event flag that
        will return control to the task that called the command.

        :param dict data: response as a JSON dictionary
        r„   z7Got a message with a command ID that does not exist: %sNÚerrorÚresultz<The command's generator function did not exit when expected!)r   r’   ÚKeyErrorrŒ   ÚwarningrV   r€   Úsendrp   ÚStopIterationrs   rE   )r\   rZ   r–   r�   rª   Ú_ÚexitÚreturn_s           r   r­   zCdpBase._handle_cmd_response  sÍ   € ð �d‘ˆð	Ø×*Ñ*×.Ñ.¨vÓ6‰JˆC�ð �d‰?ô ,8¸¸W¹Ó+FˆD× Ñ  Ò(ð%Ø—H‘H˜T (™^Ó,�Ü#Ð$bÓcÐcð 	�	‰	�øô! ò 	Ü�N‰NÐTÐVZÔ[Ùð	ûô !ò %ØŸ*™*•ûð%úà+2ˆD× Ñ  Ñ(øs)   ‡A6 ÁB Á6BÂBÂ	B:Â$B5Â5B:c                 óÐ  — t         j                  j                  |«      }t        j	                  d|«       t        «       }| j                  t        |«         D ]  }	 |j                  |«       Œ |r!| j                  t        |«      xx   |z  cc<   yy# t        j                  $ r t        j                  d||«       Y Œgt        j                  $ r |j                  |«       Y ŒŒw xY w)zOHandle an event.

        :param dict data: event as a JSON dictionary
        zReceived event: %sz0Unable to send event "%r" due to full channel %sN)r   ÚutilÚparse_json_eventrŒ   r.   rE   r{   r•   Úsend_nowaitrˆ   Ú
WouldBlockr±   ÚBrokenResourceErrorr¡   )r\   rZ   rª   Ú	to_remover£   s        r   r®   zCdpBase._handle_event*  sÂ   € ô —‘×.Ñ.¨tÓ4ˆÜ�‰Ð)¨5Ô1Ü“Eˆ	Ø—m‘m¤D¨£KÑ0ò 	&ˆFð&Ø×"Ñ" 5Õ)ð	&ñ Ø�M‰Mœ$˜u›+Ó&¨)Ñ3Ô&ð øô	 —?‘?ò `Ü—‘ÐOÐQVÐX^Ö_Ü×+Ñ+ò &Ø—‘˜fÖ%ð&ús   ÁBÂ*C%Â?#C%Ã$C%)r�   )r-   rb   rc   r^   r
   Údictr   r   rœ   r¦   r   r   r   rr   r«   r¯   r­   r®   re   rR   r   rv   rv   Ã   sp   „ ò"ð ¨4°°C¨<Ñ!8ð ¸Qó ð< 02ô ð ñ¨¨a©ð À^ÐT`ÐbfÐTfÑEgò ó ðò"%òó64rR   rv   c                   óB   ‡ — e Zd ZdZˆ fd„Zed„ «       Zed„ «       Zˆ xZS )Ú
CdpSessionz¢Contains the state for a CDP session.

    Generally you should not instantiate this object yourself; you should call
    :meth:`CdpConnection.open_session`.
    c                 ó¨   •— t         ‰| �  |||«       d| _        t        j                  «       | _        d| _        t        j                  «       | _        y)z´Constructor.

        :param trio_websocket.WebSocketConnection ws:
        :param devtools.target.SessionID session_id:
        :param devtools.target.TargetID target_id:
        r   N)Úsuperr^   Ú_dom_enable_countrˆ   ÚLockÚ_dom_enable_lockÚ_page_enable_countÚ_page_enable_lock)r\   rx   ry   rz   rm   s       €r   r^   zCdpSession.__init__E  sB   ø€ ô 	‰Ñ˜˜Z¨Ô3à!"ˆÔÜ $§	¡	£ˆÔØ"#ˆÔÜ!%§¡£ˆÕrR   c                óz  K  — | j                   4 ƒd{  –—†  | xj                  dz  c_        | j                  dk(  r5| j                  t        j                  j                  «       «      ƒ d{  –—†  ddd«      ƒd{  –—†  d­–— | j                   4 ƒd{  –—†  | xj                  dz  c_        | j                  dk(  r5| j                  t        j                  j                  «       «      ƒ d{  –—†  ddd«      ƒd{  –—†  y7 Œñ7 Œš7 ŒŒ# 1 ƒd{  –—†7  sw Y   ŒœxY w7 Œ‰7 Œ27 Œ$# 1 ƒd{  –—†7  sw Y   yxY w­w)zåA context manager that executes ``dom.enable()`` when it enters and
        then calls ``dom.disable()``.

        This keeps track of concurrent callers and only disables DOM
        events when all callers have exited.
        Nr   r   )rÈ   rÆ   rœ   r   ÚdomÚenableÚdisabler`   s    r   Ú
dom_enablezCdpSession.dom_enableS  s  è ø€ ð ×(Ñ(÷ 	:ñ 	:Ø×"Ò" aÑ'Õ"Ø×%Ñ%¨Ò*Ø—l‘l¤8§<¡<×#6Ñ#6Ó#8Ó9×9Ð9÷	:÷ 	:ô
 	à×(Ñ(÷ 	;ñ 	;Ø×"Ò" aÑ'Õ"Ø×%Ñ%¨Ò*Ø—l‘l¤8§<¡<×#7Ñ#7Ó#9Ó:×:Ð:÷	;÷ 	;ð 	;ð	:øð :øð	:ø÷ 	:÷ 	:ñ 	:úð	;øð ;øð	;ø÷ 	;÷ 	;ñ 	;üó¬   ‚D;“D”D;—ADÁ,DÁ-DÁ1D;Á<D	Á=D;ÂD ÂD;ÂAD&Ã/D"Ã0D&Ã4D;Ã?D$Ä D;ÄDÄ	D;ÄDÄDÄDÄD;Ä"D&Ä$D;Ä&D8Ä,D/Ä-D8Ä4D;c                óz  K  — | j                   4 ƒd{  –—†  | xj                  dz  c_        | j                  dk(  r5| j                  t        j                  j                  «       «      ƒ d{  –—†  ddd«      ƒd{  –—†  d­–— | j                   4 ƒd{  –—†  | xj                  dz  c_        | j                  dk(  r5| j                  t        j                  j                  «       «      ƒ d{  –—†  ddd«      ƒd{  –—†  y7 Œñ7 Œš7 ŒŒ# 1 ƒd{  –—†7  sw Y   ŒœxY w7 Œ‰7 Œ27 Œ$# 1 ƒd{  –—†7  sw Y   yxY w­w)zöA context manager that executes ``page.enable()`` when it enters and
        then calls ``page.disable()`` when it exits.

        This keeps track of concurrent callers and only disables page
        events when all callers have exited.
        Nr   r   )rÊ   rÉ   rœ   r   ÚpagerÍ   rÎ   r`   s    r   Úpage_enablezCdpSession.page_enableh  s  è ø€ ð ×)Ñ)÷ 	;ñ 	;Ø×#Ò# qÑ(Õ#Ø×&Ñ&¨!Ò+Ø—l‘l¤8§=¡=×#7Ñ#7Ó#9Ó:×:Ð:÷	;÷ 	;ô
 	à×)Ñ)÷ 	<ñ 	<Ø×#Ò# qÑ(Õ#Ø×&Ñ&¨!Ò+Ø—l‘l¤8§=¡=×#8Ñ#8Ó#:Ó;×;Ð;÷	<÷ 	<ð 	<ð	;øð ;øð	;ø÷ 	;÷ 	;ñ 	;úð	<øð <øð	<ø÷ 	<÷ 	<ñ 	<ürÐ   )	r-   rb   rc   rd   r^   r   rÏ   rÓ   Ú__classcell__©rm   s   @r   rÃ   rÃ   >  s5   ø„ ñô-ð ñ;ó ð;ð( ñ<ó ô<rR   rÃ   c                   óR   ‡ — e Zd ZdZˆ fd„Zd„ Zedee   fd„«       Z	dd„Z
d„ Zˆ xZS )	ÚCdpConnectiona%  Contains the connection state for a Chrome DevTools Protocol server.

    CDP can multiplex multiple "sessions" over a single connection. This
    class corresponds to the "root" session, i.e. the implicitly created
    session that has no session ID. This class is responsible for
    reading incoming WebSocket messages and forwarding them to the
    corresponding session, as well as handling messages targeted at the
    root session itself. You should generally call the
    :func:`open_cdp()` instead of instantiating this class directly.
    c                 ó8   •— t         ‰| �  |dd¬«       i | _        y)zLConstructor.

        :param trio_websocket.WebSocketConnection ws:
        N)ry   rz   )rÅ   r^   Úsessions)r\   rx   rm   s     €r   r^   zCdpConnection.__init__Š  s    ø€ ô
 	‰Ñ˜¨¸ÐÔ=Øˆ�rR   c              ƒ   óT   K  — | j                   j                  «       ƒ d{  –—†  y7 Œ­w)at  Close the underlying WebSocket connection.

        This will cause the reader task to gracefully exit when it tries
        to read the next message from the WebSocket. All of the public
        APIs (``execute()``, ``listen()``, etc.) will raise
        ``CdpConnectionClosed`` after the CDP connection is closed. It
        is safe to call this multiple times.
        N)rx   Úacloser`   s    r   rÛ   zCdpConnection.aclose’  s   è ø€ ð �g‰g�n‰nÓ×Òús   ‚( &¡(r‚   c                óŒ   K  — | j                  |«      ƒ d{  –—† }t        |«      5  |­–— ddd«       y7 Œ# 1 sw Y   yxY w­w)a  This context manager opens a session and enables the "simple" style
        of calling CDP APIs.

        For example, inside a session context, you can call ``await
        dom.get_document()`` and it will execute on the current session
        automatically.
        N)Úconnect_sessionr8   )r\   rz   rK   s      r   Úopen_sessionzCdpConnection.open_session�  sG   è ø€ ð ×,Ñ,¨YÓ7×7ˆÜ˜WÓ%ñ 	Ø‹M÷	ð 	ð 8ø÷	ð 	üs!   ‚A—6˜A§8­
A¸A½Ac              ƒ   óÌ   K  — | j                  t        j                  j                  |d«      «      ƒ d{  –—† }t	        | j
                  ||«      }|| j                  |<   |S 7 Œ,­w)zLReturns a new :class:`CdpSession` connected to the specified
        target.TN)rœ   r   ÚtargetÚattach_to_targetrÃ   rx   rÙ   )r\   rz   ry   rK   s       r   rÝ   zCdpConnection.connect_sessionª  sV   è ø€ ð  Ÿ<™<¬¯©×(HÑ(HÈÐTXÓ(YÓZ×Zˆ
Ü˜TŸW™W j°)Ó<ˆØ$+ˆ�‰�jÑ!Øˆð [ús   ‚3A$µA"¶-A$c              ƒ   ó¾  K  — 	 	 | j                   j                  «       ƒ d{  –—† }	 t        j                  |«      }t        j                  d|«       d|v rDt        j                  j                  |d   «      }	 | j                  |   }|j                  |«       n| j                  |«       Œ©7 ŒŠ# t        $ r Y nGw xY w# t        j
                  $ r t        dd|dœ«      ‚w xY w# t        $ r t        dd|›dœ«      ‚w xY w| j                  j                  «       D ]>  \  }}|j                   j                  «       D ]  \  }}|D ]  }|j#                  «        Œ Œ Œ@ y­w)zxRuns in the background and handles incoming messages: dispatching
        responses to commands and events to listeners.NiD€ÿÿzClient received invalid JSON)rX   rY   rZ   zReceived message %rr…   z-Browser sent a message for an invalid session)rx   Úget_messager�   rŠ   ÚloadsÚJSONDecodeErrorrV   rŒ   r.   r   rà   Ú	SessionIDrÙ   r³   r¯   Úitemsr{   Úclose)r\   rY   rZ   ry   rK   r·   Úsendersr£   s           r   Ú_reader_taskzCdpConnection._reader_task³  sm  è ø€ ð ðØ $§¡× 3Ñ 3Ó 5×5�ðqÜ—z‘z 'Ó*�ô �L‰LÐ.°Ô5Ø˜dÑ"Ü%Ÿ_™_×6Ñ6°t¸KÑ7HÓI�
ð	Ø"Ÿm™m¨JÑ7�Gð ×$Ñ$ TÕ*à×!Ñ! $Ô'ð9 à5ùÜ%ò ñ
 ðûô ×'Ñ'ò qÜ"¨FÐ?]ÐgnÑ#oÓpÐpðqûô  ò Ü&à$*Ø'VØ'1 nñóð ðúð Ÿ-™-×-Ñ-Ó/ò 	#‰JˆAˆwØ%×.Ñ.×4Ñ4Ó6ò #‘
��7Ø%ò #�FØ—L‘L•Nñ#ñ#ñ	#ùsa   ‚E…B/ ¢B-£B/ ¨B> ½<EÁ:C$ Â	$EÂ-B/ Â/	B;Â8EÂ:B;Â;EÂ>#C!Ã!EÃ$C>Ã>AE)r‚   rÃ   )r-   rb   rc   rd   r^   rÛ   r   r	   rÃ   rÞ   rÝ   rê   rÔ   rÕ   s   @r   r×   r×   ~  s<   ø„ ñ	ôò	ð ð
¨}¸ZÑ/Hò 
ó ð
óö%#rR   r×   r‚   c                ó€  K  — t        j                  «       4 ƒd{  –—† }t        || «      ƒ d{  –—† }	 t        |«      5  |­–— ddd«       |j	                  «       ƒ d{  –—†  ddd«      ƒd{  –—†  y7 Œ[7 ŒI# 1 sw Y   Œ6xY w7 Œ%# |j	                  «       ƒ d{  –—†7   w xY w7 Œ5# 1 ƒd{  –—†7  sw Y   yxY w­w)aè  This async context manager opens a connection to the browser specified
    by ``url`` before entering the block, then closes the connection when the
    block exits.

    The context manager also sets the connection as the default
    connection for the current task, so that commands like ``await
    target.get_targets()`` will run on this connection automatically. If
    you want to use multiple connections concurrently, it is recommended
    to open each on in a separate task.
    N)rˆ   Úopen_nurseryÚconnect_cdpr6   rÛ   )ÚurlÚnurseryÚconns      r   Úopen_cdprñ   Û  s¥   è ø€ ô × Ñ Ó"÷  ð   gÜ  ¨#Ó.×.ˆð	 Ü# DÓ)ñ Ø“
÷ð —+‘+“-×Ð÷ ÷  ñ  øØ.ø÷ð úð  ù�$—+‘+“-×Òúð ø÷  ÷  ñ  üs¡   ‚B>›A7œB>ŸB)¯A9°B)µB	Á A;ÁB	ÁB)Á!BÁ"B)Á&B>Á1B'Á2B>Á9B)Á;B	Â B	ÂB)Â	B$ÂB 
ÂB$Â$B)Â'B>Â)B;Â/B2Â0B;Â7B>c              ƒ   ó’   K  — t        | |t        ¬«      ƒ d{  –—† }t        |«      }| j                  |j                  «       |S 7 Œ,­w)a¯  Connect to the browser specified by ``url`` and spawn a background task
    in the specified nursery.

    The ``open_cdp()`` context manager is preferred in most situations.
    You should only use this function if you need to specify a custom
    nursery. This connection is not automatically closed! You can either
    use the connection object as a context manager (``async with
    conn:``) or else call ``await conn.aclose()`` on it when you are
    done with it. If ``set_context`` is True, then the returned
    connection will be installed as the default connection for the
    current task. This argument is for unusual use cases, such as
    running inside of a notebook.
    )Úmax_message_sizeN)r   ÚMAX_WS_MESSAGE_SIZEr×   Ú
start_soonrê   )rï   rî   rx   Úcdp_conns       r   rí   rí   ñ  sC   è ø€ ô % W¨cÔDWÔX×	X€BÜ˜RÓ €HØ×Ñ�x×,Ñ,Ô-Ø€Oð 
Yús   ‚A˜A™-A)6rO   r    r|   rŠ   r+   r#   Úcollectionsr   Ú
contextlibr   r   Údataclassesr   Útypingr   r   r	   r
   r   r   rˆ   Útrio_websocketr   r�   r   r,   rŒ   r   rô   r   r   r5   rP   r7   rt   r9   r@   rC   r6   r8   rQ   rT   r”   rV   rg   rp   rr   rv   rÃ   ÚabcÚAsyncResourcer×   rñ   rí   re   rR   r   ú<module>rþ      s’  ðô6 Û Û Û Û Û Ý #Ý *Ý %Ý !Ý Ý !Ý  Ý Ý Ý ã Ý AÝ 0à	ˆ×	Ñ	˜:Ó	&€ÙˆCƒL€ØÐ à€Ø
€òð, /E¨k×.DÑ.DÐEYÓ.ZÐ �[×+Ñ+Ó ZØ+A¨;×+AÑ+AÐBSÓ+TÐ �+×(Ñ(Ó Tò	Sò	Pð ñ)ó ð)ð ñ&ó ð&ò\òSô
V�9ô 
Vô;Ð,ô ;ô #�Iô #ð
 ÷ð ó ð÷x4ñ x4ôv=<�ô =<ô@Z#�G˜TŸX™X×3Ñ3ô Z#ðz ð ˜=¨Ñ7ò  ó ð ð* }ô rR   