
    ]j%              	      >   d 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
mZmZ  G d d      Ze G d	 d
             ZddiZ G d d      Z e       j%                  d
e      Z e       Zd e
ddej%                  d      rej%                  de      ne      ie_        y)z
WebDriver BiDi speculation module.

Provides events for observing the status of Speculation Rules prefetch
requests initiated by the browser (e.g. via <script type='speculationrules'>).
    )annotations)Callable)	dataclass)Any)EventConfig_EventWrapper_EventManagerc                       e Zd ZdZdZdZdZdZy)PreloadingStatusa6  
    Status values for a speculation-rules prefetch operation.

    PENDING: The prefetch has been queued but not yet attempted.
    READY:   The prefetch succeeded and the resource is cached.
    SUCCESS: The prefetched navigation was used successfully.
    FAILURE: The prefetch failed or was cancelled.
    pendingreadysuccessfailureN)__name__
__module____qualname____doc__PENDINGREADYSUCCESSFAILURE     ^/home/ubuntu/.local/lib/python3.12/site-packages/selenium/webdriver/common/bidi/speculation.pyr   r      s     GEGGr   r   c                  <    e Zd ZU dZdZded<   dZded<   dZded<   y)PrefetchStatusUpdatedParametersa   
    Event payload emitted when a prefetch status changes.

    Attributes:
        context: The browsing context ID that owns the speculation rule.
        url: The URL being prefetched.
        status: The new prefetch status (see PreloadingStatus).
    Nz
str | Nonecontexturlz
Any | Nonestatus)r   r   r   r   r   __annotations__r   r   r   r   r   r   r   &   s'     GZCFJr   r   prefetch_status_updatedz!speculation.prefetchStatusUpdatedc                  B    e Zd ZU dZi Zded<   d	dZd
ddZddZd	dZ	y)SpeculationzABiDi interface for observing Speculation Rules prefetch activity.zdict[str, EventConfig]EVENT_CONFIGSc                H    || _         t        || j                        | _        y N)_connr	   r$   _event_manager)selfconns     r   __init__zSpeculation.__init__?   s    
+D$2D2DEr   Nc                <    | j                   j                  |||      S )a  Add an event handler.

        Args:
            event: The event to subscribe to.
            callback: The callback function to execute on event.
            contexts: The context IDs to subscribe to (optional).

        Returns:
            The callback ID.
        )r(   add_event_handler)r)   eventcallbackcontextss       r   r-   zSpeculation.add_event_handlerD   s     ""44UHhOOr   c                :    | j                   j                  ||      S )zRemove an event handler.

        Args:
            event: The event to unsubscribe from.
            callback_id: The callback ID.
        )r(   remove_event_handler)r)   r.   callback_ids      r   r2   z Speculation.remove_event_handlerQ   s     ""77{KKr   c                6    | j                   j                         S )zClear all event handlers.)r(   clear_event_handlers)r)   s    r   r5   z Speculation.clear_event_handlersZ   s    ""7799r   )returnNoner&   )r.   strr/   r   r0   zlist[str] | Noner6   int)r.   r8   r3   r9   r6   r7   )
r   r   r   r   r$   r    r+   r-   r2   r5   r   r   r   r#   r#   ;   s'    K,.M).F
PL:r   r#   PrefetchStatusUpdatedN)r   
__future__r   collections.abcr   dataclassesr   typingr   -selenium.webdriver.common.bidi._event_managerr   r   r	   r   r   EVENT_NAME_MAPPINGr#   globalsgetdictr:   _globalsr$   r   r   r   <module>rE      s    # $ !  c c     " B !: !:J  	&GN  9{!+7?||D[7\,d3bf  r   