
    vKg'                     l    S SK r S SKrS SKJr   " S S5      r\" 5       r " S S5      r " S S\5      rg)	    N)
exceptionsc                   *    \ rS rSrSrS rS rS rSrg)Channel   zo
The only way for the mitmproxy server to communicate with the master
is to use the channel it has been given.
c                 (    Xl         X l        X0l        g N)masterloopshould_exit)selfr	   r
   r   s       l/var/www/highfloat_scraper/venv/lib/python3.13/site-packages/seleniumwire/thirdparty/mitmproxy/controller.py__init__Channel.__init__   s    	&    c                    U R                   R                  5       (       d  [        U5      Ul        [        R
                  " U R                  R                  R                  X5      U R                  5        UR                  R                  R                  5       nU[        R                  :X  a  [        R                  " 5       eU$ g)z
Decorate a message with a reply attribute, and send it to the master.
Then wait for a response.

Raises:
    exceptions.Kill: All connections should be closed immediately.
N)r   is_setReplyreplyasynciorun_coroutine_threadsafer	   addonshandle_lifecycler
   qgetr   Kill)r   mtypemgs       r   askChannel.ask   s     &&((AhAG,,""33E=		 		AJOO# oo''H )r   c                     U R                   R                  5       (       dT  [        5       Ul        [        R
                  " U R                  R                  R                  X5      U R                  5        gg)zb
Decorate a message with a dummy reply attribute, send it to the master,
then return immediately.
N)
r   r   
DummyReplyr   r   r   r	   r   r   r
   )r   r   r   s      r   tellChannel.tell$   sT    
 &&(( lAG,,""33E=		 )r   )r
   r	   r   N)	__name__
__module____qualname____firstlineno____doc__r   r   r#   __static_attributes__ r   r   r   r      s    '
&
r   r   c                   n    \ rS rSrSrS r\S 5       r\S 5       rS r	S r
SS jrSS	 jrSS
 jrS rSrg)r   4   z
Messages sent through a channel are decorated with a "reply" attribute. This
object is used to respond to the message through the return channel.
c                 h    Xl         [        R                  " 5       U l        SU l        [
        U l        g Nstart)objqueueQueuer   _stateNO_REPLYvalue)r   r1   s     r   r   Reply.__init__9   s$     
r   c                     U R                   $ )ax  
The state the reply is currently in. A normal reply object goes
sequentially through the following lifecycle:

    1. start: Initial State.
    2. taken: The reply object has been taken to be committed.
    3. committed: The reply has been sent back to the requesting party.

This attribute is read-only and can only be modified by calling one of
state transition functions.
)r4   r   s    r   stateReply.stateC   s     {{r   c                 (    U R                   [        :g  $ r   )r6   r5   r9   s    r   has_messageReply.has_messageR   s    zzX%%r   c                     U R                   S:w  a/  [        R                  " SR                  U R                   5      5      eSU l        g)z
Scripts or other parties make "take" a reply out of a normal flow.
For example, intercepted flows are taken out so that the connection thread does not proceed.
r0   z)Reply is {}, but expected it to be start.takenN)r:   r   ControlExceptionformatr4   r9   s    r   take
Reply.takeV   s>    
 :: --;BB4::N  r   c                 (   U R                   S:w  a/  [        R                  " SR                  U R                   5      5      eU R                  (       d  [        R                  " S5      eSU l        U R                  R                  U R                  5        g)z
Ultimately, messages are committed. This is done either automatically by
the handler if the message is not taken or manually by the entity which
called .take().
r@   z)Reply is {}, but expected it to be taken.zThere is no reply message.	committedN)	r:   r   rA   rB   r=   r4   r   putr6   r9   s    r   commitReply.commita   sm     :: --;BB4::N  --.JKK!

4::r   c                 <    U R                  U R                  U5        g r   )sendr1   r   forces     r   ack	Reply.ackp   s    		$((E"r   c                     U R                  [        R                  U5        U R                  S:X  a  U R	                  5         g g )Nr@   )rK   r   r   r4   rH   rL   s     r   kill
Reply.kills   s.    		*//5);;'!KKM "r   c                     U R                   S;  a/  [        R                  " SR                  U R                   5      5      eU R                  (       a  U(       d  [        R                  " S5      eXl        g )N>   r0   r@   z2Reply is {}, but expected it to be start or taken.z!There is already a reply message.)r:   r   rA   rB   r=   r6   )r   msgrM   s      r   rK   
Reply.sendx   sX    :://--DKKDJJW  E--.QRR
r   c                 j    U R                   S:w  a#  [        R                  " SU R                  -  5      eg )NrF   Uncommitted reply: %s)r:   r   rA   r1   r9   s    r   __del__Reply.__del__   s.    ::$--.E.PQQ %r   )r4   r1   r   r6   N)F)r%   r&   r'   r(   r)   r   propertyr:   r=   rC   rH   rN   rQ   rK   rX   r*   r+   r   r   r   r   4   sS       & &	#
Rr   r   c                   >   ^  \ rS rSrSrU 4S jrS rS rS rSr	U =r
$ )r"      a  
A reply object that is not connected to anything. In contrast to regular
Reply objects, DummyReply objects are reset to "start" at the end of an
handler so that they can be used multiple times. Useful when we need an
object to seem like it has a channel, and during testing.
c                 2   > [         TU ]  S 5        SU l        g )NF)superr   _should_reset)r   	__class__s    r   r   DummyReply.__init__   s    "r   c                 x    U R                   S:w  a#  [        R                  " SU R                  -  5      eSU l        g )NrF   rW   T)r:   r   rA   r1   r_   r9   s    r   
mark_resetDummyReply.mark_reset   s1    ::$--.E.PQQ!r   c                 L    U R                   (       a  SU l        [        U l        g g r/   )r_   r4   r5   r6   r9   s    r   resetDummyReply.reset   s    !DK!DJ r   c                     g r   r+   r9   s    r   rX   DummyReply.__del__   s    r   )r_   r4   r6   )r%   r&   r'   r(   r)   r   rc   rf   rX   r*   __classcell__)r`   s   @r   r"   r"      s!    #"
"
 r   r"   )	r   r2   !seleniumwire.thirdparty.mitmproxyr   r   objectr5   r   r"   r+   r   r   <module>rm      s=      8' 'T 8PR PRf r   