
    'h/.                     L    S SK Jr   " S S5      r " S S5      r " S S5      rg)	    )command_builderc                   .    \ rS rSrSrS r\S 5       rSrg)NetworkEvent   zRepresents a network event.c                     Xl         X l        g Nevent_classparams)selfr
   kwargss      o/var/www/home/psychics-availability/venv/lib/python3.13/site-packages/selenium/webdriver/common/bidi/network.py__init__NetworkEvent.__init__   s    &    c                 4    U " SSUR                  S5      0UD6$ )Nr
    )get)clsjsons     r   	from_jsonNetworkEvent.from_json   s    ?txx6?$??r   r	   N)	__name__
__module____qualname____firstlineno____doc__r   classmethodr   __static_attributes__r   r   r   r   r      s     % @ @r   r   c                   |    \ rS rSrSSSSSSSS	.rS
SSS.rS r/ SS4S jrSS jrS r	SS jr
S rS rS rS rSrg)Network!   znetwork.beforeRequestSentznetwork.responseStartedznetwork.responseCompletedznetwork.authRequiredznetwork.fetchErrornetwork.continueRequestnetwork.continueWithAuth)before_requestresponse_startedresponse_completedauth_requiredfetch_errorcontinue_requestcontinue_authbeforeRequestSentresponseStartedauthRequired)r%   r&   r(   c                 :    Xl         / U l        0 U l        0 U l        g r   )conn
intercepts	callbackssubscriptions)r   r0   s     r   r   Network.__init__2   s    	r   Nc                     0 nUb  X$S'   Ub  X4S'   [        U5      S:  a  XS'   OS/US'   [        SU5      nU R                  R                  U5      nU R                  R                  US   5        U$ )aw  Add an intercept to the network.

Parameters:
----------
    phases (list, optional): A list of phases to intercept.
        Default is empty list.
    contexts (list, optional): A list of contexts to intercept.
        Default is None.
    url_patterns (list, optional): A list of URL patterns to intercept.
        Default is None.

Returns:
-------
    str : intercept id
contextsurlPatternsr   phasesr,   znetwork.addIntercept	intercept)lenr   r0   executer1   append)r   r8   r6   url_patternsr   cmdresults          r   _add_interceptNetwork._add_intercept8   s      !):#$0=!v;?%8 34F84f=""3'vk23r   c                    Ucf  U R                   R                  5       nU HE  nU R                  R                  [	        SSU05      5        U R                   R                  U5        MG     g U R                  R                  [	        SSU05      5        U R                   R                  U5        g! [         a  n[        SU 35      eSnAff = f)a  Remove a specific intercept, or all intercepts.

Parameters:
----------
    intercept (str, optional): The intercept to remove.
        Default is None.

Raises:
------
    Exception: If intercept is not found.

Notes:
-----
    If intercept is None, all intercepts will be removed.
Nznetwork.removeInterceptr9   zException: )r1   copyr0   r;   r   remove	Exception)r   r9   intercepts_to_removeintercept_ides        r   _remove_interceptNetwork._remove_interceptW   s      #'??#7#7#9  4		!!/2Kk[gMh"ij&&|4 !53		!!/2Kk[dMe"fg&&y1 3+aS 1223s   +AB. .
C8CCc                    ^ ^ [        U5      nUU 4S jnT R                  R                  X45      nUT R                  ;   a   T R                  U   R	                  U5        U$ U/T R                  U'   U$ )a  Set a callback function to subscribe to a network event.

Parameters:
----------
    event_name (str): The event to subscribe to.
    callback (function): The callback function to execute on event.
        Takes Request object as argument.

Returns:
-------
    int : callback id
c                   > [        TU R                  S   R                  SS 5      U R                  S   R                  SS 5      U R                  S   R                  SS 5      U R                  S   R                  SS 5      U R                  S   R                  SS 5      U R                  S   R                  SS 5      U R                  S   R                  SS 5      U R                  S   R                  SS 5      S	9	nT" U5        g )
NrequestbodySizecookieszgoog:resourceTypeheadersheadersSizetimingsurl)	network
request_id	body_sizerO   resource_typerP   headers_sizerR   rS   )Requestr   r   )
event_datarM   callbackr   s     r   	_callback&Network._on_request.<locals>._callback   s    %,,Y7;;ItL$++I6:::tL")))488DI(//	:>>?RTXY")))488DI'..y9==mTR")))488DI%%i044UDA
G Wr   )r   r0   add_callbackr2   r<   )r   
event_namer[   eventr\   callback_ids   ` `   r   _on_requestNetwork._on_requests   sm     Z(	 ii,,U>'NN:&--k:  +6DNN:&r   c                     U R                   U   nU R                  U   nU R	                  U/X4S9nU R                  XR5      nXPR                  ;   a  U R                  U   R                  U5        O=0 n	U/U	S'   U R                  R                  [        SU	5      5        U/U R                  U'   US   U R                  U'   U$ ! [         a    [        SU S35      ef = f)a  Add a request handler to the network.

Parameters:
----------
    event (str): The event to subscribe to.
    url_patterns (list, optional): A list of URL patterns to intercept.
        Default is None.
    contexts (list, optional): A list of contexts to intercept.
        Default is None.
    callback (function): The callback function to execute on request interception
        Takes Request object as argument.

Returns:
-------
    int : callback id
Event 
 not found)r8   r=   r6   eventszsession.subscriber9   )EVENTSPHASESKeyErrorrE   r@   rb   r3   r<   r0   r;   r   r2   )
r   r`   r[   r=   r6   r_   
phase_namer?   ra   r   s
             r   add_request_handlerNetwork.add_request_handler   s    $	8U+JU+J $$ZL|$g&&z<+++z*11+>F *|F8IIo.A6JK.9]Dz*&,[&9{#  	8fUG:677	8s   C Cc                     U R                   U   n[        U5      nU R                  R                  XB5        U R                  U R                  U   5        U R                  U	 U R                  U   R                  U5        [        U R                  U   5      S:X  a;  0 nU/US'   U R                  R                  [        SU5      5        U R                  U	 gg! [         a    [        SU S35      ef = f)zRemove a request handler from the network.

Parameters:
----------
    event_name (str): The event to unsubscribe from.
    callback_id (int): The callback id to remove.
re   rf   r   rg   session.unsubscribeN)rh   rj   rE   r   r0   remove_callbackrI   r2   r3   rD   r:   r;   r   )r   r`   ra   r_   	net_eventr   s         r   remove_request_handlerNetwork.remove_request_handler   s    	8U+J !,			!!)9t~~k:;NN;':&--k:t!!*-.!3F *|F8IIo.CVLM"":.	 4  	8fUG:677	8s   C C2c                 `   U R                    H  n[        U5      nU R                   U    HI  nU R                  R                  X#5        U R	                  U R
                  U   5        U R
                  U	 MK     0 nU/US'   U R                  R                  [        SU5      5        M     0 U l         g)z,Clear all request handlers from the network.rg   ro   N)r3   r   r0   rp   rI   r2   r;   r   )r   r_   rq   ra   r   s        r   clear_request_handlersNetwork.clear_request_handlers   s     ,,J$Z0I#11*=		)))A&&t~~k'BCNN;/  > F *|F8IIo.CVLM -  r   c                 :   ^^ SnUU4S jnU R                  X45      $ )zAdd an authentication handler to the network.

Parameters:
----------
    username (str): The username to authenticate with.
    password (str): The password to authenticate with.

Returns:
-------
    int : callback id
r(   c                 *   > U R                  TT5        g r   )_continue_with_auth)rM   passwordusernames    r   r\   +Network.add_auth_handler.<locals>._callback   s    ''(;r   )rl   )r   r{   rz   r`   r\   s    ``  r   add_auth_handlerNetwork.add_auth_handler   s"      	< ''99r   c                 *    SnU R                  X!5        g)z}Remove an authentication handler from the network.

Parameters:
----------
    callback_id (int): The callback id to remove.
r(   N)rr   )r   ra   r`   s      r   remove_auth_handlerNetwork.remove_auth_handler   s      ##E7r   )r2   r0   r1   r3   r   NN)r   r   r   r   rh   ri   r   r@   rI   rb   rl   rr   ru   r}   r   r   r   r   r   r!   r!   !   sh    559/+53F .-'F  %'D >38%N$L/2 :&8r   r!   c                   T    \ rS rSrSr        S
S\4S jjrS rSS jrSS jr	S	r
g)rY   i  z*Represents an intercepted network request.NrT   c                 |    Xl         X l        X0l        X@l        XPl        X`l        Xpl        Xl        Xl        Xl	        g r   )
rT   rU   rV   rO   rW   rP   rX   methodrR   rS   )r   rT   rU   rV   rO   rW   rP   rX   r   rR   rS   s              r   r   Request.__init__  s8     $"*(r   c                     U R                   (       d  [        S5      eSU R                   0nU R                  R                  R	                  [        SU5      5        g)zFail this request.Request not found.rM   znetwork.failRequestNrU   
ValueErrorrT   r0   r;   r   )r   r   s     r   fail_requestRequest.fail_request   sE     122T__-!!/2G"PQr   c                     U R                   (       d  [        S5      eSU R                   0nUb  XS'   Ub  X&S'   Ub  X6S'   Ub  XFS'   Ub  XVS'   U R                  R                  R	                  [        S	U5      5        g)
z)Continue after intercepting this request.r   rM   Nbodyr   rP   rO   rS   r#   r   )r   r   r   rP   rO   rS   r   s          r   r*   Request.continue_request)  s     122T__-!6N%8 '9 '9?5M!!/2KV"TUr   c                     0 nU R                   US'   U(       a  U(       d  SUS'   OSUS'   SXS.US'   U R                  R                  R                  [	        SU5      5        g	)
a1  Continue with authentication.

Parameters:
----------
    request (Request): The request to continue with.
    username (str): The username to authenticate with.
    password (str): The password to authenticate with.

Notes:
-----
    If username or password is None, it attempts auth with no credentials
rM   defaultactionprovideCredentialsrz   )typer{   rz   credentialsr$   N)rU   rT   r0   r;   r   )r   r{   rz   r   s       r   ry   Request._continue_with_auth=  s_      OOyx(F83F8-7X$dF=!!!/2Lf"UVr   )
rV   rO   rP   rX   r   rT   rU   rW   rR   rS   )NNNNNNNN)NNNNNr   )r   r   r   r   r   r!   r   r   r*   ry   r   r   r   r   rY   rY     s>    4 0RV(Wr   rY   N)%selenium.webdriver.common.bidi.commonr   r   r!   rY   r   r   r   <module>r      s2   $ B	@ 	@a8 a8HOW OWr   