
    X j                        S SK r S SKJr  S SKJr  S SKJr  S SKJr  S SK	J
r
  S SKJr  \" S5      r " S	 S
5      r " S S5      r " S S5      r " S S5      r " S S\5      r " S S5      r " S S5      r " S S5      r " S S\5      r " S S\5      r " S S5      r " S S 5      r " S! S"5      r " S# S$5      r " S% S&5      r " S' S(5      r " S) S*5      r " S+ S,5      r " S- S.5      r  " S/ S05      r! " S1 S25      r" " S3 S45      r# " S5 S65      r$ " S7 S85      r% " S9 S:5      r&\ " S; S<5      5       r' " S= S>5      r( " S? S@5      r)g)A    N)Callable)	dataclass)Any)Sentinel)command_builder)Session	UNDEFINEDc                   $    \ rS rSrSrSrSrSrSrg)ReadinessState   zSRepresents the stage of document loading at which a navigation command will return.noneinteractivecomplete N)	__name__
__module____qualname____firstlineno____doc__NONEINTERACTIVECOMPLETE__static_attributes__r       ڀ/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/selenium/webdriver/common/bidi/browsing_context.pyr   r      s    ]DKHr   r   c                   (    \ rS rSrSrSrSrSrSrSr	g)	UserPromptType'   z*Represents the possible user prompt types.alertbeforeunloadconfirmpromptr   N)
r   r   r   r   r   ALERTBEFORE_UNLOADCONFIRMPROMPTr   r   r   r   r   r   '   s    4E"MGFr   r   c                   T    \ rS rSrSrS\S\S-  S\S\4S jr\S	\	S
S 4S j5       r
Srg)NavigationInfo0   z*Provides details of an ongoing navigation.context
navigationN	timestampurlc                 4    Xl         X l        X0l        X@l        g Nr*   r+   r,   r-   )selfr*   r+   r,   r-   s        r   __init__NavigationInfo.__init__3   s     $"r   jsonreturnc                    UR                  S5      nUb  [        U[        5      (       d  [        S5      eUR                  S5      nUb   [        U[        5      (       d  [        S5      eUR                  S5      nUb  [        U[        5      (       a  US:  a  [        S5      eUR                  S5      nUb  [        U[        5      (       d  [        S	5      eU " X#XE5      $ )
zCreates a NavigationInfo instance from a dictionary.

Args:
    json: A dictionary containing the navigation information.

Returns:
    A new instance of NavigationInfo.
r*   (context is required and must be a stringr+   znavigation must be a stringr,   r   8timestamp is required and must be a non-negative integerr-   $url is required and must be a stringget
isinstancestr
ValueErrorint)clsr4   r*   r+   r,   r-   s         r   	from_jsonNavigationInfo.from_json?   s     ((9%?*Wc":":GHHXXl+
!*Z*E*E:;;HH[)	Jy#$>$>)a-WXXhhuo;jc22CDD7	77r   r0   r   r   r   r   r   r=   r?   r2   classmethoddictrA   r   r   r   r   r(   r(   0   sW    4

 $J
 	

 
 8T 8&6 8 8r   r(   c                   z    \ rS rSrSr  SS\S\S\S    S-  S\S\S	\S-  S
\S-  4S jjr\S\	SS 4S j5       r
Srg)BrowsingContextInfo\   z)Represents the properties of a navigable.Nr*   r-   childrenclient_windowuser_contextparentoriginal_openerc                 X    Xl         X l        X0l        X`l        XPl        Xpl        X@l        g r/   )r*   r-   rI   rL   rK   rM   rJ   )r1   r*   r-   rI   rJ   rK   rL   rM   s           r   r2   BrowsingContextInfo.__init___   s*      (.*r   r4   r5   c           
         SnUR                  S5      nUb{  [        U[        5      (       d  [        S5      e/ nU HS  n[        U[        5      (       d  [        S[        U5       35      eUR                  [        R                  U5      5        MU     UR                  S5      nUb  [        U[        5      (       d  [        S5      eUR                  S5      nUb  [        U[        5      (       d  [        S5      eUR                  S	5      nUb   [        U[        5      (       d  [        S
5      eUR                  S5      nUb  [        U[        5      (       d  [        S5      eUR                  S5      n	U	b   [        U	[        5      (       d  [        S5      eUR                  S5      n
U
b  [        U
[        5      (       d  [        S5      eU " UUUU
UUU	S9$ )zCreates a BrowsingContextInfo instance from a dictionary.

Args:
    json: A dictionary containing the browsing context information.

Returns:
    A new instance of BrowsingContextInfo.
NrI   z#children must be a list if providedz%Each child must be a dictionary, got r*   r7   r-   r9   rL   z#parent must be a string if provideduserContextz,userContext is required and must be a stringoriginalOpenerz+originalOpener must be a string if providedclientWindowz-clientWindow is required and must be a string)r*   r-   rI   rJ   rK   rL   rM   )
r;   r<   listr>   rE   typeappendrG   rA   r=   )r@   r4   rI   raw_childrenchildr*   r-   rL   rK   rM   rJ   s              r   rA   BrowsingContextInfo.from_jsonq   s    xx
+#lD11 !FGGH%!%..$'LTRW[M%Z[[ 3 = =e DE &
 ((9%?*Wc":":GHHhhuo;jc22CDD(#j&=&=BCCxx.z,'D'DKLL((#34&z/3/O/OJKK0 
=#(F(FLMM'%+
 	
r   )rI   rJ   r*   rM   rL   r-   rK   NN)r   r   r   r   r   r=   rT   r2   rD   rE   rA   r   r   r   r   rG   rG   \   s    3 "&*++ + ,-4	+
 + + d
+ t+$ 5
T 5
&; 5
 5
r   rG   c            
       f   ^  \ rS rSrSrS\S\S-  S\S\S\4
U 4S	 jjr\S
\	SS 4S j5       r
SrU =r$ )DownloadWillBeginParams   z+Parameters for the downloadWillBegin event.r*   r+   Nr,   r-   suggested_filenamec                 2   > [         TU ]  XX45        XPl        g r/   )superr2   r^   )r1   r*   r+   r,   r-   r^   	__class__s         r   r2    DownloadWillBeginParams.__init__   s     	i="4r   r4   r5   c                     [         R                  U5      nUR                  S5      nUb  [        U[        5      (       d  [        S5      eU " UR                  UR                  UR                  UR                  US9$ )NsuggestedFilenamez2suggestedFilename is required and must be a string)r*   r+   r,   r-   r^   )
r(   rA   r;   r<   r=   r>   r*   r+   r,   r-   )r@   r4   nav_infor^   s       r   rA   !DownloadWillBeginParams.from_json   ss    !++D1!XX&9:%Z8JC-P-PQRR$$**((1
 	
r   )r^   )r   r   r   r   r   r=   r?   r2   rD   rE   rA   r   __classcell__ra   s   @r   r\   r\      sb    5	5	5 $J	5 		5
 	5  	5 
T 
&? 
 
r   r\   c                   ^    \ rS rSrSr SS\S\S\S\S\S-  4
S	 jjr\S
\SS 4S j5       r	Sr
g)UserPromptOpenedParams   z*Parameters for the userPromptOpened event.Nr*   handlermessagerU   default_valuec                 @    Xl         X l        X0l        X@l        XPl        g r/   r*   rl   rm   rU   rn   )r1   r*   rl   rm   rU   rn   s         r   r2   UserPromptOpenedParams.__init__   s     	*r   r4   r5   c                    UR                  S5      nUb  [        U[        5      (       d  [        S5      eUR                  S5      nUb  [        U[        5      (       d  [        S5      eUR                  S5      nUb  [        U[        5      (       d  [        S5      eUR                  S5      nUb  [        U[        5      (       d  [        S5      eUR                  S	5      nUb   [        U[        5      (       d  [        S
5      eU " UUUUUS9$ )zCreates a UserPromptOpenedParams instance from a dictionary.

Args:
    json: A dictionary containing the user prompt parameters.

Returns:
    A new instance of UserPromptOpenedParams.
r*   r7   rl   z(handler is required and must be a stringrm   z(message is required and must be a stringrU   %type is required and must be a stringdefaultValuez)defaultValue must be a string if providedrp   )r;   r<   r=   r>   )r@   r4   r*   rl   rm   
type_valuern   s          r   rA    UserPromptOpenedParams.from_json   s     ((9%?*Wc":":GHH((9%?*Wc":":GHH((9%?*Wc":":GHHXXf%
Z
C%@%@DEE0$Zs-K-KHII'
 	
r   )r*   rn   rl   rm   rU   r/   )r   r   r   r   r   r=   r2   rD   rE   rA   r   r   r   r   rj   rj      sf    4 %)++ + 	+
 + Tz+ #
T #
&> #
 #
r   rj   c            
       Z    \ rS rSrSr SS\S\S\S\S-  4S jjr\S	\	S
S 4S j5       r
Srg)UserPromptClosedParamsi  z*Parameters for the userPromptClosed event.Nr*   acceptedrU   	user_textc                 4    Xl         X l        X0l        X@l        g r/   r*   ry   rU   rz   )r1   r*   ry   rU   rz   s        r   r2   UserPromptClosedParams.__init__  s      	"r   r4   r5   c                    UR                  S5      nUb  [        U[        5      (       d  [        S5      eUR                  S5      nUb  [        U[        5      (       d  [        S5      eUR                  S5      nUb  [        U[        5      (       d  [        S5      eUR                  S5      nUb   [        U[        5      (       d  [        S5      eU " UUUUS	9$ )
zCreates a UserPromptClosedParams instance from a dictionary.

Args:
    json: A dictionary containing the user prompt closed parameters.

Returns:
    A new instance of UserPromptClosedParams.
r*   r7   ry   z*accepted is required and must be a booleanrU   rs   userTextz%userText must be a string if providedr|   )r;   r<   r=   r>   bool)r@   r4   r*   ry   ru   rz   s         r   rA    UserPromptClosedParams.from_json  s     ((9%?*Wc":":GHH88J':h#=#=IJJXXf%
Z
C%@%@DEEHHZ(	 Is)C)CDEE	
 	
r   )ry   r*   rU   rz   r/   )r   r   r   r   r   r=   r   r2   rD   rE   rA   r   r   r   r   rx   rx     s\    4 !%
#
# 
# 	
#
 :
# 
T 
&> 
 
r   rx   c                   J    \ rS rSrSrS\S\S\4S jr\S\	SS 4S	 j5       r
S
rg)HistoryUpdatedParamsi2  z(Parameters for the historyUpdated event.r*   r,   r-   c                 (    Xl         X l        X0l        g r/   r*   r,   r-   )r1   r*   r,   r-   s       r   r2   HistoryUpdatedParams.__init__5  s     "r   r4   r5   c                 V   UR                  S5      nUb  [        U[        5      (       d  [        S5      eUR                  S5      nUb  [        U[        5      (       a  US:  a  [        S5      eUR                  S5      nUb  [        U[        5      (       d  [        S5      eU " UUUS9$ )	zCreates a HistoryUpdatedParams instance from a dictionary.

Args:
    json: A dictionary containing the history updated parameters.

Returns:
    A new instance of HistoryUpdatedParams.
r*   r7   r,   r   r8   r-   r9   r   r:   )r@   r4   r*   r,   r-   s        r   rA   HistoryUpdatedParams.from_json?  s     ((9%?*Wc":":GHHHH[)	Jy#$>$>)a-WXXhhuo;jc22CDD
 	
r   r   NrC   r   r   r   r   r   2  sI    2  	 
T 
&< 
 
r   r   c                   h   ^  \ rS rSr SS\S\S-  S\S\S\4
U 4S jjjr\S	\S
S 4S j5       r	Sr
U =r$ )DownloadCanceledParamsi\  r*   r+   Nr,   r-   statusc                 2   > [         TU ]  XX45        XPl        g r/   )r`   r2   r   )r1   r*   r+   r,   r-   r   ra   s         r   r2   DownloadCanceledParams.__init__]  s     	i=r   r4   r5   c                     [         R                  U5      nUR                  S5      nUb  US:w  a  [        S5      eU " UR                  UR
                  UR                  UR                  US9$ )Nr   canceledz)status is required and must be 'canceled')r*   r+   r,   r-   r   )r(   rA   r;   r>   r*   r+   r,   r-   )r@   r4   re   r   s       r   rA    DownloadCanceledParams.from_jsonh  sj    !++D1(#>Vz1HII$$**((
 	
r   )r   )r   r   r   r   r   r=   r?   r2   rD   rE   rA   r   rg   rh   s   @r   r   r   \  si     !		 $J	 		
 	 	 	 
T 
&> 
 
r   r   c                   t   ^  \ rS rSr  SS\S\S-  S\S\S\S\S-  4U 4S	 jjjr\S
\SS 4S j5       r	Sr
U =r$ )DownloadCompleteParamsiy  Nr*   r+   r,   r-   r   filepathc                 >   > [         TU ]  XX45        XPl        X`l        g r/   )r`   r2   r   r   )r1   r*   r+   r,   r-   r   r   ra   s          r   r2   DownloadCompleteParams.__init__z  s     	i= r   r4   r5   c           	      D   [         R                  U5      nUR                  S5      nUb  US:w  a  [        S5      eUR                  S5      nUb   [	        U[
        5      (       d  [        S5      eU " UR                  UR                  UR                  UR                  UUS9$ )Nr   r   z)status is required and must be 'complete'r   z%filepath must be a string if provided)r*   r+   r,   r-   r   r   )
r(   rA   r;   r>   r<   r=   r*   r+   r,   r-   )r@   r4   re   r   r   s        r   rA    DownloadCompleteParams.from_json  s    !++D1(#>Vz1HII88J'
8S(A(ADEE$$**((
 	
r   )r   r   )r   Nr   rh   s   @r   r   r   y  sz     !#!! $J! 	!
 ! ! *! ! 
T 
&> 
 
r   r   c                   H    \ rS rSrSrS\\-  4S jr\S\	SS 4S j5       r
Srg	)
DownloadEndParamsi  z%Parameters for the downloadEnd event.download_paramsc                     Xl         g r/   r   )r1   r   s     r   r2   DownloadEndParams.__init__  s
      /r   r4   r5   c                     UR                  S5      nUS:X  a  U " [        R                  U5      5      $ US:X  a  U " [        R                  U5      5      $ [	        S5      e)Nr   r   r   z.status must be either 'canceled' or 'complete')r;   r   rA   r   r>   )r@   r4   r   s      r   rA   DownloadEndParams.from_json  sZ    (#Z-77=>>z!-77=>>MNNr   r   N)r   r   r   r   r   r   r   r2   rD   rE   rA   r   r   r   r   r   r     s?    ///2HH/ OT O&9 O Or   r   c                   4    \ rS rSrSrSr\S\4S j5       rSr	g)ContextCreatedi  z5Event class for browsingContext.contextCreated event.browsingContext.contextCreatedr4   c                 Z    [        U[        5      (       a  U$ [        R                  U5      $ r/   r<   rG   rA   r@   r4   s     r   rA   ContextCreated.from_json  &    d/00K",,T22r   r   N
r   r   r   r   r   event_classrD   rE   rA   r   r   r   r   r   r     s#    ?2K3T 3 3r   r   c                   4    \ rS rSrSrSr\S\4S j5       rSr	g)ContextDestroyedi  z7Event class for browsingContext.contextDestroyed event. browsingContext.contextDestroyedr4   c                 Z    [        U[        5      (       a  U$ [        R                  U5      $ r/   r   r   s     r   rA   ContextDestroyed.from_json  r   r   r   Nr   r   r   r   r   r     s#    A4K3T 3 3r   r   c                   4    \ rS rSrSrSr\S\4S j5       rSr	g)NavigationStartedi  z8Event class for browsingContext.navigationStarted event.!browsingContext.navigationStartedr4   c                 Z    [        U[        5      (       a  U$ [        R                  U5      $ r/   r<   r(   rA   r   s     r   rA   NavigationStarted.from_json  %    dN++K''--r   r   Nr   r   r   r   r   r     #    B5K.T . .r   r   c                   4    \ rS rSrSrSr\S\4S j5       rSr	g)NavigationCommittedi  z:Event class for browsingContext.navigationCommitted event.#browsingContext.navigationCommittedr4   c                 Z    [        U[        5      (       a  U$ [        R                  U5      $ r/   r   r   s     r   rA   NavigationCommitted.from_json  r   r   r   Nr   r   r   r   r   r     s#    D7K.T . .r   r   c                   4    \ rS rSrSrSr\S\4S j5       rSr	g)NavigationFailedi  z7Event class for browsingContext.navigationFailed event. browsingContext.navigationFailedr4   c                 Z    [        U[        5      (       a  U$ [        R                  U5      $ r/   r   r   s     r   rA   NavigationFailed.from_json  r   r   r   Nr   r   r   r   r   r     #    A4K.T . .r   r   c                   4    \ rS rSrSrSr\S\4S j5       rSr	g)NavigationAbortedi  z8Event class for browsingContext.navigationAborted event.!browsingContext.navigationAbortedr4   c                 Z    [        U[        5      (       a  U$ [        R                  U5      $ r/   r   r   s     r   rA   NavigationAborted.from_json  r   r   r   Nr   r   r   r   r   r     r   r   r   c                   4    \ rS rSrSrSr\S\4S j5       rSr	g)DomContentLoadedi  z7Event class for browsingContext.domContentLoaded event. browsingContext.domContentLoadedr4   c                 Z    [        U[        5      (       a  U$ [        R                  U5      $ r/   r   r   s     r   rA   DomContentLoaded.from_json  r   r   r   Nr   r   r   r   r   r     r   r   r   c                   4    \ rS rSrSrSr\S\4S j5       rSr	g)Loadi  z+Event class for browsingContext.load event.browsingContext.loadr4   c                 Z    [        U[        5      (       a  U$ [        R                  U5      $ r/   r   r   s     r   rA   Load.from_json
  r   r   r   Nr   r   r   r   r   r     s#    5(K.T . .r   r   c                   4    \ rS rSrSrSr\S\4S j5       rSr	g)FragmentNavigatedi  z8Event class for browsingContext.fragmentNavigated event.!browsingContext.fragmentNavigatedr4   c                 Z    [        U[        5      (       a  U$ [        R                  U5      $ r/   r   r   s     r   rA   FragmentNavigated.from_json  r   r   r   Nr   r   r   r   r   r     r   r   r   c                   4    \ rS rSrSrSr\S\4S j5       rSr	g)DownloadWillBegini  z8Event class for browsingContext.downloadWillBegin event.!browsingContext.downloadWillBeginr4   c                 ,    [         R                  U5      $ r/   )r\   rA   r   s     r   rA   DownloadWillBegin.from_json"  s    &0066r   r   Nr   r   r   r   r   r     s#    B5K7T 7 7r   r   c                   4    \ rS rSrSrSr\S\4S j5       rSr	g)UserPromptOpenedi'  z7Event class for browsingContext.userPromptOpened event. browsingContext.userPromptOpenedr4   c                 ,    [         R                  U5      $ r/   )rj   rA   r   s     r   rA   UserPromptOpened.from_json,      %//55r   r   Nr   r   r   r   r   r   '  #    A4K6T 6 6r   r   c                   4    \ rS rSrSrSr\S\4S j5       rSr	g)UserPromptClosedi1  z7Event class for browsingContext.userPromptClosed event. browsingContext.userPromptClosedr4   c                 ,    [         R                  U5      $ r/   )rx   rA   r   s     r   rA   UserPromptClosed.from_json6  r   r   r   Nr   r   r   r   r   r   1  r   r   r   c                   4    \ rS rSrSrSr\S\4S j5       rSr	g)HistoryUpdatedi;  z5Event class for browsingContext.historyUpdated event.browsingContext.historyUpdatedr4   c                 ,    [         R                  U5      $ r/   )r   rA   r   s     r   rA   HistoryUpdated.from_json@  s    #--d33r   r   Nr   r   r   r   r   r   ;  s#    ?2K4T 4 4r   r   c                   4    \ rS rSrSrSr\S\4S j5       rSr	g)DownloadEndiE  z2Event class for browsingContext.downloadEnd event.browsingContext.downloadEndr4   c                 ,    [         R                  U5      $ r/   )r   rA   r   s     r   rA   DownloadEnd.from_jsonJ  s     **400r   r   Nr   r   r   r   r   r   E  s#    </K1T 1 1r   r   c                   4    \ rS rSr% \\S'   \\S'   \\S'   Srg)EventConfigiO  	event_key
bidi_eventr   r   N)r   r   r   r   r=   __annotations__rU   r   r   r   r   r   r   O  s    NOr   r   c            	           \ rS rSrSrS\\\4   4S jrS\S\4S jr	SS	\S
\
\   S-  SS4S jjrS	\SS4S jrS	\S\SS4S jrS	\S\SS4S jrSS\S\S
\
\   S-  S\4S jjrS\S\SS4S jrSS jrSrg)_EventManageriV  zFClass to manage event subscriptions and callbacks for BrowsingContext.event_configsc                 6   Xl         X l        0 U l        UR                  5        Vs0 s H  o3R                  UR
                  _M     snU l        SR                  [        UR                  5       5      5      U l
        [        R                  " 5       U l        g s  snf )Nz, )connr   subscriptionsvaluesr   r   _bidi_to_classjoinsortedkeys_available_events	threadingLock_subscription_lock)r1   r   r   configs       r   r2   _EventManager.__init__Y  sz    	*#%S`SgSgSijSi00&2D2DDSij!%6-2D2D2F+G!H"+.."2 ks    Beventr5   c                     U R                   R                  U5      nU(       d  [        SU SU R                   35      eU$ )NzEvent 'z' not found. Available events: )r   r;   r>   r  )r1   r  event_configs      r   validate_event_EventManager.validate_eventb  sA    ))--e4wug-LTMcMcLdeffr   Nr   contextsc                    U R                      XR                  ;  aL  [        U R                  5      nU R                  R	                  UR                  XS95        / U R                  U'   SSS5        g! , (       d  f       g= f)zSubscribe to a BiDi event if not already subscribed.

Args:
    bidi_event: The BiDi event name.
    contexts: Optional browsing context IDs to subscribe to.
)browsing_contextsN)r  r   r   r   execute	subscribe)r1   r   r  sessions       r   subscribe_to_event _EventManager.subscribe_to_eventh  sc     $$!3!33!$)),		!!'"3"3J"3"[\13"":.	 %$$s   AA22
B c                 2   U R                      U R                  R                  U5      nUbS  U(       dL  [        U R                  5      nU R                  R                  UR                  U5      5        U R                  U	 SSS5        g! , (       d  f       g= f)zfUnsubscribe from a BiDi event if no more callbacks exist.

Args:
    bidi_event: The BiDi event name.
N)r  r   r;   r   r   r  unsubscribe)r1   r   callback_listr  s       r   unsubscribe_from_event$_EventManager.unsubscribe_from_eventu  sp     $$ ..22:>M(!$)),		!!'"5"5j"AB&&z2 %$$s   A2B
Bcallback_idc                     U R                      U R                  U   R                  U5        S S S 5        g ! , (       d  f       g = fr/   )r  r   rV   )r1   r   r  s      r   add_callback_to_tracking&_EventManager.add_callback_to_tracking  s0    $$z*11+> %$$s	   5
Ac                     U R                      U R                  R                  U5      nU(       a  X#;   a  UR                  U5        S S S 5        g ! , (       d  f       g = fr/   )r  r   r;   remove)r1   r   r  r  s       r   remove_callback_from_tracking+_EventManager.remove_callback_from_tracking  sC    $$ ..22:>M!=$$[1 %$$s   9A
Acallbackc                     U R                  U5      nU R                  R                  UR                  U5      nU R	                  UR
                  U5        U R                  UR
                  U5        U$ r/   )r  r   add_callbackr   r  r   r  )r1   r  r"  r  r
  r  s         r   add_event_handler_EventManager.add_event_handler  sd    **51ii,,\-E-ExP 	 7 7B 	%%l&=&={Kr   c                     U R                  U5      nU R                  R                  UR                  U5        U R	                  UR
                  U5        U R                  UR
                  5        g r/   )r  r   remove_callbackr   r   r   r  )r1   r  r  r
  s       r   remove_event_handler"_EventManager.remove_event_handler  s\    **51 			!!,":":KH 	**<+B+BKP 	##L$;$;<r   c                     U R                      U R                  (       d
   SSS5        g[        U R                  5      n[	        U R                  R                  5       5       Hw  u  p#U R                  R                  U5      nU(       d  M)  U H  nU R                  R                  XE5        M      U R                  R                  UR                  U5      5        My     U R                  R                  5         SSS5        g! , (       d  f       g= fz3Clear all event handlers from the browsing context.N)r  r   r   r   rT   itemsr   r;   r(  r  r  clear)r1   r  r   callback_idsr   r  s         r   clear_event_handlers"_EventManager.clear_event_handlers  s    $$%% %$ dii(G,01C1C1I1I1K,L(
"1155jA;'3		11+K (4 II%%g&9&9*&EF -M $$& %$$s   C?AC?
A,C??
D)r  r   r  r   r   r   r/   r5   N)r   r   r   r   r   rE   r=   r   r2   r  rT   r  r  r?   r  r   r   r%  r)  r0  r   r   r   r   r   r   V  s    P3Dk1A,B 3C K 4S 4DI<L 4X\ 43 3 3?3 ?S ?T ?2 2# 2RV 2s h $s)VZJZ fi 
=# 
=C 
=D 
='r   r   c                      \ rS rSrSr\" SS\5      \" SS\5      \" SS\5      \" S	S
\	5      \" SS\
5      \" SS\5      \" SS\5      \" SS\5      \" SS\5      \" SS\5      \" SS\5      \" SS\5      \" SS\5      \" SS\5      S.rS  r\S!\\   4S" j5       rS#\S!S$4S% jr   SVS#\S'\S(\S$-  S)\S$-  S!\4
S* jjrSWS#\S+\S!S$4S, jjr   SXS-\S.\S$-  S/\S0\S$-  S!\4
S1 jjr  SYS2\ S$-  S3\S$-  S!\\!   4S4 jjr"  SYS#\S5\S$-  S6\S$-  S!S$4S7 jjr#   SZS#\S8\S9\ S$-  S:\S$-  S;\\   S$-  S!\\   4S< jjr$ S[S#\S=\S>\S$-  S!\4S? jjr%       S\S#\S/\S@\S$-  SA\SB\S$-  SC\\ \-     S$-  SD\&SE\S!\4SF jjr'  SYS#\SG\S$-  S>\S$-  S!\4SH jjr(S$\)\)S$4S#\S$-  S&\S$-  \*-  SI\&S$-  \*-  SJ\\   S$-  S!S$4
SK jjr+S#\SL\ S!\4SM jr,S[SN\SO\-SP\\   S$-  S!\ 4SQ jjr.SN\SR\ S!S$4SS jr/S]ST jr0SUr1g$)^BrowsingContexti  z2BiDi implementation of the browsingContext module.context_createdr   context_destroyedr   dom_content_loadedr   download_endr   download_will_beginr   fragment_navigatedr   history_updatedr   loadr   navigation_abortedr   navigation_committedr   navigation_failedr   navigation_startedr   user_prompt_closedr   user_prompt_openedr   )r5  r6  r7  r8  r9  r:  r;  r<  r=  r>  r?  r@  rA  rB  c                 D    Xl         [        XR                  5      U l        g r/   )r   r   EVENT_CONFIGS_event_manager)r1   r   s     r   r2   BrowsingContext.__init__  s    	+D2D2DEr   r5   c                 H    [        U R                  R                  5       5      $ )zsGet a list of all available event names.

Returns:
    A list of event names that can be used with event handlers.
)rT   rD  r  )r@   s    r   get_event_namesBrowsingContext.get_event_names  s     C%%**,--r   r*   Nc                 V    SU0nU R                   R                  [        SU5      5        g)zActivates and focuses the given top-level traversable.

Args:
    context: The browsing context ID to activate.

Raises:
    Exception: If the browsing context is not a top-level traversable.
r*   zbrowsingContext.activateNr   r  r   )r1   r*   paramss      r   activateBrowsingContext.activate  s(     W%		/*DfMNr   viewportoriginformatclipc                 z    XS.nUb  X5S'   Ub  XES'   U R                   R                  [        SU5      5      nUS   $ )a_  Captures an image of the given navigable, and returns it as a Base64-encoded string.

Args:
    context: The browsing context ID to capture.
    origin: The origin of the screenshot, either "viewport" or "document".
    format: The format of the screenshot.
    clip: The clip rectangle of the screenshot.

Returns:
    The Base64-encoded screenshot.
)r*   rP  rQ  rR  z!browsingContext.captureScreenshotdatarK  )r1   r*   rP  rQ  rR  rL  results          r   capture_screenshot"BrowsingContext.capture_screenshot  sN    $ .5!G%8!6N""?3VX^#_`f~r   prompt_unloadc                 V    XS.nU R                   R                  [        SU5      5        g)zCloses a top-level traversable.

Args:
    context: The browsing context ID to close.
    prompt_unload: Whether to prompt to unload.

Raises:
    Exception: If the browsing context is not a top-level traversable.
)r*   promptUnloadzbrowsingContext.closeNrK  )r1   r*   rX  rL  s       r   closeBrowsingContext.close  s&     %D		/*A6JKr   rU   reference_context
backgroundrK   c                     SU0nUb  X%S'   Ub  X5S'   Ub  XES'   U R                   R                  [        SU5      5      nUS   $ )a  Creates a new navigable, either in a new tab or in a new window, and returns its navigable id.

Args:
    type: The type of the new navigable, either "tab" or "window".
    reference_context: The reference browsing context ID.
    background: Whether to create the new navigable in the background.
    user_context: The user context ID.

Returns:
    The browsing context ID of the created navigable.
rU   referenceContextr^  rQ   zbrowsingContext.creater*   rK  )r1   rU   r]  r^  rK   rL  rU  s          r   createBrowsingContext.create  s_    $ #)$():%&!#-< #$0=!""?3KV#TUi  r   	max_depthrootc                     0 nUb  XS'   Ub  X#S'   U R                   R                  [        SU5      5      nUS    Vs/ s H  n[        R	                  U5      PM     sn$ s  snf )ad  Get a tree of all descendent navigables including the given parent itself.

Returns a tree of all descendent navigables including the given parent itself, or all top-level contexts
when no parent is provided.

Args:
    max_depth: The maximum depth of the tree.
    root: The root browsing context ID.

Returns:
    A list of browsing context information.
maxDepthrd  zbrowsingContext.getTreer  )r   r  r   rG   rA   )r1   rc  rd  rL  rU  r*   s         r   get_treeBrowsingContext.get_tree/  sk    " "$ !*:!6N""?3Lf#UVFLZFXYFX7#--g6FXYYYs   Aacceptrz   c                 r    SU0nUb  X$S'   Ub  X4S'   U R                   R                  [        SU5      5        g)zAllows closing an open prompt.

Args:
    context: The browsing context ID.
    accept: Whether to accept the prompt.
    user_text: The text to enter in the prompt.
r*   Nri  r   z browsingContext.handleUserPromptrK  )r1   r*   ri  rz   rL  s        r   handle_user_prompt"BrowsingContext.handle_user_promptI  sD     #,W!5%8 !*:		/*LfUVr   locatormax_node_countserialization_optionsstart_nodesc                     XS.nUb  X6S'   Ub  XFS'   Ub  XVS'   U R                   R                  [        SU5      5      nUS   $ )a<  Returns a list of all nodes matching the specified locator.

Args:
    context: The browsing context ID.
    locator: The locator to use.
    max_node_count: The maximum number of nodes to return.
    serialization_options: The serialization options.
    start_nodes: The start nodes.

Returns:
    A list of nodes.
)r*   rm  maxNodeCountserializationOptions
startNodeszbrowsingContext.locateNodesnodesrK  )r1   r*   rm  rn  ro  rp  rL  rU  s           r   locate_nodesBrowsingContext.locate_nodes^  s^    ( .5!I%%3>" ,-B)*"#.< ""?3PRX#YZgr   r-   waitc                 f    XS.nUb  X4S'   U R                   R                  [        SU5      5      nU$ )zNavigates a navigable to the given URL.

Args:
    context: The browsing context ID.
    url: The URL to navigate to.
    wait: The readiness state to wait for.

Returns:
    A dictionary containing the navigation result.
)r*   r-   rx  zbrowsingContext.navigaterK  )r1   r*   r-   rx  rL  rU  s         r   navigateBrowsingContext.navigate}  s:      %1!6N""?3Mv#VWr   marginorientationpagepage_rangesscaleshrink_to_fitc	                     UUUUUS.n	Ub  X9S'   Ub  XYS'   Ub  XiS'   U R                   R                  [        SU	5      5      n
U
S   $ )a  Create a paginated PDF representation of the document as a Base64-encoded string.

Args:
    context: The browsing context ID.
    background: Whether to include the background.
    margin: The margin parameters.
    orientation: The orientation, either "portrait" or "landscape".
    page: The page parameters.
    page_ranges: The page ranges.
    scale: The scale.
    shrink_to_fit: Whether to shrink to fit.

Returns:
    The Base64-encoded PDF document.
)r*   r^  r}  r  shrinkToFitr|  r~  
pageRangeszbrowsingContext.printrT  rK  )r1   r*   r^  r|  r}  r~  r  r  r  rL  rU  s              r   printBrowsingContext.print  sk    6 $&(
 %8!6N"#.< ""?3JF#STf~r   ignore_cachec                 t    SU0nUb  X$S'   Ub  X4S'   U R                   R                  [        SU5      5      nU$ )zReloads a navigable.

Args:
    context: The browsing context ID.
    ignore_cache: Whether to ignore the cache.
    wait: The readiness state to wait for.

Returns:
    A dictionary containing the navigation result.
r*   ignoreCacherx  zbrowsingContext.reloadrK  )r1   r*   r  rx  rL  rU  s         r   reloadBrowsingContext.reload  sJ      #,W!5#$0=!!6N""?3KV#TUr   device_pixel_ratiouser_contextsc                     Ub  Ub  [        S5      eUc  Uc  [        S5      e0 nUb  XS'   OUb  XES'   U[        La  X%S'   U[        La  X5S'   U R                  R                  [	        SU5      5        g)	a-  Modifies specific viewport characteristics on the given top-level traversable.

Args:
    context: The browsing context ID.
    viewport: The viewport parameters - {"width": <int>, "height": <int>} (`None` resets to default).
    device_pixel_ratio: The device pixel ratio (`None` resets to default).
    user_contexts: The user context IDs.

Raises:
    Exception: If the browsing context is not a top-level traversable
    ValueError: If neither `context` nor `user_contexts` is provided
    ValueError: If both `context` and `user_contexts` are provided
Nz-Cannot specify both context and user_contextsz,Must specify either context or user_contextsr*   userContextsrO  devicePixelRatiozbrowsingContext.setViewport)r>   r	   r   r  r   )r1   r*   rO  r  r  rL  s         r   set_viewportBrowsingContext.set_viewport  s    ( =#<LMM?}4KLL!# '9&%2>"9$!):Y.);%&		/*GPQr   deltac                 X    XS.nU R                   R                  [        SU5      5      nU$ )zTraverses the history of a given navigable by a delta.

Args:
    context: The browsing context ID.
    delta: The delta to traverse by.

Returns:
    A dictionary containing the traverse history result.
)r*   r  zbrowsingContext.traverseHistoryrK  )r1   r*   r  rL  rU  s        r   traverse_history BrowsingContext.traverse_history  s.     %5""?3TV\#]^r   r  r"  r  c                 :    U R                   R                  XU5      $ )zAdd an event handler to the browsing context.

Args:
    event: The event to subscribe to.
    callback: The callback function to execute on event.
    contexts: The browsing context IDs to subscribe to.

Returns:
    Callback id.
)rE  r%  )r1   r  r"  r  s       r   r%  !BrowsingContext.add_event_handler  s     ""44UhOOr   r  c                 :    U R                   R                  X5        g)zRemove an event handler from the browsing context.

Args:
    event: The event to unsubscribe from.
    callback_id: The callback id to remove.
N)rE  r)  )r1   r  r  s      r   r)  $BrowsingContext.remove_event_handler  s     	00Dr   c                 8    U R                   R                  5         gr,  )rE  r0  )r1   s    r   r0  $BrowsingContext.clear_event_handlers"  s    002r   )rE  r   )rO  NN)F)NFNrZ   )NNNr/   )FNportraitNNg      ?Tr2  )2r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rD  r2   rD   rT   r=   rH  rM  rE   rV  r   r[  ra  r?   rG   rg  rk  rv  rz  floatr  r  r	   r   r  r  r   r%  r)  r0  r   r   r   r   r4  r4    sy   < ''8:Z\jk()<>`brs)*>@bdtu#N4QS^_*!#FHY 
 **>@cevw&'8:Z\jkF$:DA)*>@cevw +"$IK^!
 ))<>`brs)*>@cevw)*>@bdtu)*>@bdtu%M*F .S	 . .
O 
O 
O !"   t	
 Tk 
6LS L L$ L  )- #'!! :! 	!
 Dj! 
!> !%Z:Z DjZ 
!	"	Z: # $	WW tW :	W
 
W2 &*-1)-  d
	
  $d{ $Z$& 
dF  	  Dj	
 
4 !"% .2")) ) t	)
 ) Tk) #)_t+) ) ) 
)\ %)	 Tk Dj	
 
6 #+46?*.$Rt$R +($R "DL83	$R
 Cy4'$R 
$RL C D Ps Ph P$s)VZJZ Pfi PE# EC ED E3r   r4  )*r  collections.abcr   dataclassesr   typingr   typing_extensionsr   %selenium.webdriver.common.bidi.commonr   &selenium.webdriver.common.bidi.sessionr   r	   r   r   r(   rG   r\   rj   rx   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r4  r   r   r   <module>r     sb  $  $ !  & A :[!	  )8 )8XK
 K
\
n 
>5
 5
p.
 .
b'
 '
T
^ 
:!
^ !
HO O(	3 	3	3 	3	. 	.	. 	.	. 	.	. 	.	. 	.	. 	.	. 	.7 76 66 64 41 1   `' `'Fk3 k3r   