U
    g6                     @  s  d dl mZ ddlmZmZ d dlmZ d dlZd dlZddl	m
Z
 ddl	mZ eG dd	 d	ZeG d
d dZeG dd dZeG dd dZeG dd dZddddZddddZdddddZddddZddd d!d"Zdd#d$d%d&Zdd'dd(d)d*Zdd+dd,d-d.Zd'dd/d0d1Zdd'd'dd2d3d4Zed5eG d6d7 d7Zed8eG d9d: d:Zed;eG d<d= d=Zed>eG d?d@ d@ZdS )A    )annotations   )event_classT_JSON_DICT)	dataclassN)dom)runtimec                   @  s   e Zd ZU dZded< ded< ded< ded< ded	< ded
< ded< ded< dZded< dZded< dZded< dd Ze	dd Z
dS )	Animationz
    Animation instance.
    strid_nameboolpaused_state
play_statefloatplayback_rate
start_timecurrent_timetype_Nz typing.Optional[AnimationEffect]sourcetyping.Optional[str]css_idz%typing.Optional[ViewOrScrollTimeline]view_or_scroll_timelinec                 C  s   t  }| j|d< | j|d< | j|d< | j|d< | j|d< | j|d< | j|d< | j|d< | j	d k	rn| j	
 |d	< | jd k	r| j|d
< | jd k	r| j
 |d< |S )Nidr   pausedState	playStateplaybackRate	startTimecurrentTimetyper   cssIdviewOrScrollTimeline)dictr   r   r   r   r   r   r   r   r   to_jsonr   r   selfjson r'   U/tmp/pip-unpacked-wheel-3ysq0mf8/selenium/webdriver/common/devtools/v129/animation.pyr#   :   s     











zAnimation.to_jsonc                 C  s   | t |d t |d t|d t |d t|d t|d t|d t |d d	|krht|d	 nd d
|kr~t |d
 nd d|krt|d nd dS )Nr   r   r   r   r   r   r   r   r   r    r!   )r   r   r   r   r   r   r   r   r   r   r   )r
   r   r   AnimationEffect	from_jsonViewOrScrollTimelineclsr&   r'   r'   r(   r*   L   s    







zAnimation.from_json)__name__
__module____qualname____doc____annotations__r   r   r   r#   classmethodr*   r'   r'   r'   r(   r	      s   
r	   c                   @  s^   e Zd ZU dZded< dZded< dZded< dZded	< dZded
< dd Z	e
dd ZdS )r+   z
    Timeline instance
    zdom.ScrollOrientationaxisN"typing.Optional[dom.BackendNodeId]source_node_idztyping.Optional[float]start_offset
end_offsetsubject_node_idc                 C  sp   t  }| j |d< | jd k	r,| j |d< | jd k	r@| j|d< | jd k	rT| j|d< | jd k	rl| j |d< |S )Nr4   sourceNodeIdstartOffset	endOffsetsubjectNodeId)r"   r4   r#   r6   r7   r8   r9   r$   r'   r'   r(   r#   u   s    





zViewOrScrollTimeline.to_jsonc              	   C  sv   | t j|d d|kr(t j|d nd d|kr>t|d nd d|krTt|d nd d|krnt j|d nd dS )Nr4   r:   r;   r<   r=   )r4   r6   r7   r8   r9   )r   ZScrollOrientationr*   BackendNodeIdr   r,   r'   r'   r(   r*      s    zViewOrScrollTimeline.from_json)r.   r/   r0   r1   r2   r6   r7   r8   r9   r#   r3   r*   r'   r'   r'   r(   r+   ]   s   
r+   c                   @  s~   e Zd ZU dZded< ded< ded< ded< ded< ded	< ded
< ded< dZded< dZded< dd Zedd Z	dS )r)   z"
    AnimationEffect instance
    r   delay	end_delayiteration_start
iterationsdurationr
   	directionfilleasingNr5   backend_node_idztyping.Optional[KeyframesRule]keyframes_rulec                 C  s   t  }| j|d< | j|d< | j|d< | j|d< | j|d< | j|d< | j|d< | j|d< | j	d k	rn| j	
 |d	< | jd k	r| j
 |d
< |S )Nr?   endDelayiterationStartrB   rC   rD   rE   rF   backendNodeIdkeyframesRule)r"   r?   r@   rA   rB   rC   rD   rE   rF   rG   r#   rH   r$   r'   r'   r(   r#      s    









zAnimationEffect.to_jsonc                 C  s   | t |d t |d t |d t |d t |d t|d t|d t|d d	|krjtj|d	 nd d
|krt|d
 nd d
S )Nr?   rI   rJ   rB   rC   rD   rE   rF   rK   rL   )
r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   )r   r
   r   r>   r*   KeyframesRuler,   r'   r'   r(   r*      s    







zAnimationEffect.from_json)
r.   r/   r0   r1   r2   rG   rH   r#   r3   r*   r'   r'   r'   r(   r)      s   
r)   c                   @  s:   e Zd ZU dZded< dZded< dd Zed	d
 ZdS )rM   z
    Keyframes Rule
    ztyping.List[KeyframeStyle]	keyframesNr   r   c                 C  s2   t  }dd | jD |d< | jd k	r.| j|d< |S )Nc                 S  s   g | ]}|  qS r'   )r#   .0ir'   r'   r(   
<listcomp>   s     z)KeyframesRule.to_json.<locals>.<listcomp>rN   r   )r"   rN   r   r$   r'   r'   r(   r#      s
    

zKeyframesRule.to_jsonc                 C  s.   | dd |d D d|kr&t |d nd dS )Nc                 S  s   g | ]}t |qS r'   )KeyframeStyler*   rO   r'   r'   r(   rR      s     z+KeyframesRule.from_json.<locals>.<listcomp>rN   r   )rN   r   r
   r,   r'   r'   r(   r*      s    zKeyframesRule.from_json)	r.   r/   r0   r1   r2   r   r#   r3   r*   r'   r'   r'   r(   rM      s   
rM   c                   @  s6   e Zd ZU dZded< ded< dd Zedd Zd	S )
rS   z
    Keyframe Style
    r
   offsetrF   c                 C  s   t  }| j|d< | j|d< |S )NrU   rF   )r"   rU   rF   r$   r'   r'   r(   r#      s    

zKeyframeStyle.to_jsonc                 C  s   | t |d t |d dS )NrU   rF   )rU   rF   rT   r,   r'   r'   r(   r*      s    

zKeyframeStyle.from_jsonN)r.   r/   r0   r1   r2   r#   r3   r*   r'   r'   r'   r(   rS      s   
rS   z0typing.Generator[T_JSON_DICT, T_JSON_DICT, None])returnc                  c  s   ddi} | V }dS )z2
    Disables animation domain notifications.
    methodzAnimation.disableNr'   cmd_dictr&   r'   r'   r(   disable  s     rZ   c                  c  s   ddi} | V }dS )z1
    Enables animation domain notifications.
    rW   zAnimation.enableNr'   rX   r'   r'   r(   enable  s     r[   r
   z1typing.Generator[T_JSON_DICT, T_JSON_DICT, float])r   rV   c                 c  s*   t  }| |d< d|d}|V }t|d S )z
    Returns the current time of the an animation.

    :param id_: Id of animation.
    :returns: Current time of the page.
    r   zAnimation.getCurrentTimerW   paramsr   )r"   r   )r   r]   rY   r&   r'   r'   r(   get_current_time  s    	r^   c                  c  s   ddi} | V }t |d S )zo
    Gets the playback rate of the document timeline.

    :returns: Playback rate for animations on page.
    rW   zAnimation.getPlaybackRater   )r   rX   r'   r'   r(   get_playback_rate-  s
     r_   ztyping.List[str])
animationsrV   c                 c  s,   t  }dd | D |d< d|d}|V }dS )zz
    Releases a set of animations to no longer be manipulated.

    :param animations: List of animation ids to seek.
    c                 S  s   g | ]}|qS r'   r'   rO   r'   r'   r(   rR   C  s     z&release_animations.<locals>.<listcomp>r`   zAnimation.releaseAnimationsr\   Nr"   )r`   r]   rY   r&   r'   r'   r(   release_animations:  s    rb   z@typing.Generator[T_JSON_DICT, T_JSON_DICT, runtime.RemoteObject])animation_idrV   c                 c  s.   t  }| |d< d|d}|V }tj|d S )z
    Gets the remote object of the Animation.

    :param animation_id: Animation id.
    :returns: Corresponding remote object.
    animationIdzAnimation.resolveAnimationr\   ZremoteObject)r"   r   ZRemoteObjectr*   )rc   r]   rY   r&   r'   r'   r(   resolve_animationK  s    	re   r   )r`   r   rV   c                 c  s4   t  }dd | D |d< ||d< d|d}|V }dS )z
    Seek a set of animations to a particular time within each animation.

    :param animations: List of animation ids to seek.
    :param current_time: Set the current time of each animation.
    c                 S  s   g | ]}|qS r'   r'   rO   r'   r'   r(   rR   i  s     z#seek_animations.<locals>.<listcomp>r`   r   zAnimation.seekAnimationsr\   Nra   )r`   r   r]   rY   r&   r'   r'   r(   seek_animations^  s    
rf   r   )r`   pausedrV   c                 c  s4   t  }dd | D |d< ||d< d|d}|V }dS )z
    Sets the paused state of a set of animations.

    :param animations: Animations to set the pause state of.
    :param paused: Paused state to set to.
    c                 S  s   g | ]}|qS r'   r'   rO   r'   r'   r(   rR   }  s     zset_paused.<locals>.<listcomp>r`   rg   zAnimation.setPausedr\   Nra   )r`   rg   r]   rY   r&   r'   r'   r(   
set_pausedr  s    
rh   )r   rV   c                 c  s"   t  }| |d< d|d}|V }dS )zz
    Sets the playback rate of the document timeline.

    :param playback_rate: Playback rate for animations on page
    r   zAnimation.setPlaybackRater\   Nra   )r   r]   rY   r&   r'   r'   r(   set_playback_rate  s    ri   )rc   rC   r?   rV   c                 c  s2   t  }| |d< ||d< ||d< d|d}|V }dS )z
    Sets the timing of an animation node.

    :param animation_id: Animation id.
    :param duration: Duration of the animation.
    :param delay: Delay of the animation.
    rd   rC   r?   zAnimation.setTimingr\   Nra   )rc   rC   r?   r]   rY   r&   r'   r'   r(   
set_timing  s    rj   zAnimation.animationCanceledc                   @  s.   e Zd ZU dZded< edd dddZdS )	AnimationCanceledz9
    Event for when an animation has been cancelled.
    r
   r   r   r&   rV   c                 C  s   | t |d dS Nr   )r   rT   r,   r'   r'   r(   r*     s    
zAnimationCanceled.from_jsonNr.   r/   r0   r1   r2   r3   r*   r'   r'   r'   r(   rk     s   
rk   zAnimation.animationCreatedc                   @  s.   e Zd ZU dZded< edd dddZdS )	AnimationCreatedz9
    Event for each animation that has been created.
    r
   r   r   rl   c                 C  s   | t |d dS rm   rT   r,   r'   r'   r(   r*     s    
zAnimationCreated.from_jsonNrn   r'   r'   r'   r(   ro     s   
ro   zAnimation.animationStartedc                   @  s.   e Zd ZU dZded< edd dddZdS )	AnimationStartedz4
    Event for animation that has been started.
    r	   	animationr   rl   c                 C  s   | t |d dS Nrq   )rq   r	   r*   r,   r'   r'   r(   r*     s    zAnimationStarted.from_jsonNrn   r'   r'   r'   r(   rp     s   
rp   zAnimation.animationUpdatedc                   @  s.   e Zd ZU dZded< edd dddZdS )	AnimationUpdatedz4
    Event for animation that has been updated.
    r	   rq   r   rl   c                 C  s   | t |d dS rr   rs   r,   r'   r'   r(   r*     s    zAnimationUpdated.from_jsonNrn   r'   r'   r'   r(   rt     s   
rt   )
__future__r   utilr   r   Zdataclassesr   enumtyping r   r   r	   r+   r)   rM   rS   rZ   r[   r^   r_   rb   re   rf   rh   ri   rj   rk   ro   rp   rt   r'   r'   r'   r(   <module>   sL   L/E

