
    g:                       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
  G d de      Z G d	 d
e      Ze G d d             Ze G d d             Ze G d d             Ze G d d             Z G d de      Z	 	 	 	 d$dZd%dZd%dZ	 	 	 	 d&dZ	 	 	 	 d'dZ	 	 	 d(	 	 	 	 	 	 	 	 	 d)dZ	 	 	 	 d*dZ	 	 	 d(	 	 	 	 	 	 	 	 	 d+dZ	 	 	 	 d,dZ ed      e G d d                     Z ed!      e G d" d#                    Zy)-    )annotations   )event_classT_JSON_DICT)	dataclassN)domc                  <     e Zd ZdZddZedd       Z fdZ xZS )LayerIdz"
    Unique Layer identifier.
    c                    | S N selfs    e/var/www/html/venv/lib/python3.12/site-packages/selenium/webdriver/common/devtools/v129/layer_tree.pyto_jsonzLayerId.to_json           c                     | |      S r   r   clsjsons     r   	from_jsonzLayerId.from_json       4yr   c                >    dj                  t        | 	               S )NzLayerId({})formatsuper__repr__r   	__class__s    r   r   zLayerId.__repr__   s    ##EG$4$677r   returnstr)r   r#   r"   r
   	__name__
__module____qualname____doc__r   classmethodr   r   __classcell__r    s   @r   r
   r
      s+      8 8r   r
   c                  <     e Zd ZdZddZedd       Z fdZ xZS )
SnapshotIdz%
    Unique snapshot identifier.
    c                    | S r   r   r   s    r   r   zSnapshotId.to_json"   r   r   c                     | |      S r   r   r   s     r   r   zSnapshotId.from_json%   r   r   c                >    dj                  t        | 	               S )NzSnapshotId({})r   r   s    r   r   zSnapshotId.__repr__)   s    &&uw'7'9::r   r!   )r   r#   r"   r-   r$   r+   s   @r   r-   r-      s+      ; ;r   r-   c                  <    e Zd ZU dZded<   ded<   d Zed        Zy)	
ScrollRectz?
    Rectangle where scrolling happens on the main thread.
    dom.Rectrectr#   type_c                r    t               }| j                  j                         |d<   | j                  |d<   |S )Nr4   type)dictr4   r   r5   r   r   s     r   r   zScrollRect.to_json8   s1    vyy((*VzzVr   c                n     | t         j                  j                  |d         t        |d               S )Nr4   r7   )r4   r5   )r   Rectr   r#   r   s     r   r   zScrollRect.from_json>   s1    ##DL1d6l#
 	
r   Nr%   r&   r'   r(   __annotations__r   r)   r   r   r   r   r2   r2   -   s.     N J 
 
r   r2   c                  X    e Zd ZU dZded<   ded<   dZded<   dZded<   d	 Zed
        Z	y)StickyPositionConstraintz&
    Sticky position constraints.
    r3   sticky_box_rectcontaining_block_rectNtyping.Optional[LayerId]!nearest_layer_shifting_sticky_box'nearest_layer_shifting_containing_blockc                2   t               }| j                  j                         |d<   | j                  j                         |d<   | j                  | j                  j                         |d<   | j
                  | j
                  j                         |d<   |S )NstickyBoxRectcontainingBlockRectnearestLayerShiftingStickyBox#nearestLayerShiftingContainingBlock)r8   r@   r   rA   rC   rD   r9   s     r   r   z StickyPositionConstraint.to_jsonW   s    v $ 4 4 < < >_&*&@&@&H&H&J"#11=484Z4Z4b4b4dD0177C:>:f:f:n:n:pD67r   c           	         | t         j                  j                  |d         t         j                  j                  |d         d|v rt        j                  |d         nd d|v rt        j                  |d               S d       S )NrF   rG   rH   rI   )r@   rA   rC   rD   )r   r;   r   r
   r   s     r   r   z"StickyPositionConstraint.from_jsona   s    HH..tO/DE"%(("4"4T:O5P"Q kJ  NR  kRg.?.?Ed@e.f  X\ w\  `d  wdG4E4EdKpFq4r	
 	
 jn	
 	
r   )
r%   r&   r'   r(   r=   rC   rD   r   r)   r   r   r   r   r?   r?   F   sP      $# CG%'?F IM+-EL 
 
r   r?   c                  F    e Zd ZU dZded<   ded<   ded<   d Zed        Zy	)
PictureTilezV
    Serialized fragment of layer picture along with its offset within the layer.
    floatxyr#   picturec                t    t               }| j                  |d<   | j                  |d<   | j                  |d<   |S )NrN   rO   rP   )r8   rN   rO   rP   r9   s     r   r   zPictureTile.to_jsony   s5    vFFS	FFS	,,Yr   c                `     | t        |d         t        |d         t        |d               S )NrN   rO   rP   )rN   rO   rP   )rM   r#   r   s     r   r   zPictureTile.from_json   s3    DIDIY(
 	
r   Nr<   r   r   r   rL   rL   k   s5     H H L 
 
r   rL   c                      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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Z
ded<   dZded<   dZded<   dZded<   d Zed        Zy) Layerz0
    Information about a compositing layer.
    r
   layer_idrM   offset_xoffset_ywidthheightintpaint_countbooldraws_contentNrB   parent_layer_idz"typing.Optional[dom.BackendNodeId]backend_node_idz#typing.Optional[typing.List[float]]	transformtyping.Optional[float]anchor_xanchor_yanchor_zztyping.Optional[bool]	invisiblez(typing.Optional[typing.List[ScrollRect]]scroll_rectsz)typing.Optional[StickyPositionConstraint]sticky_position_constraintc                   t               }| j                  j                         |d<   | j                  |d<   | j                  |d<   | j
                  |d<   | j                  |d<   | j                  |d<   | j                  |d<   | j                  | j                  j                         |d<   | j                  | j                  j                         |d	<   | j                  | j                  D cg c]  }| c}|d
<   | j                  | j                  |d<   | j                  | j                  |d<   | j                  | j                  |d<   | j                  | j                  |d<   | j                   +| j                   D cg c]  }|j                          c}|d<   | j"                  | j"                  j                         |d<   |S c c}w c c}w )NlayerIdoffsetXoffsetYrX   rY   
paintCountdrawsContentparentLayerIdbackendNodeIdr`   anchorXanchorYanchorZre   scrollRectsstickyPositionConstraint)r8   rU   r   rV   rW   rX   rY   r[   r]   r^   r_   r`   rb   rc   rd   re   rf   rg   )r   r   is      r   r   zLayer.to_json   s   v--//1Y--Y--Y

WX!--\#11^+$($8$8$@$@$BD!+$($8$8$@$@$BD!>>%,0NN ;q ;D==$"mmDO==$"mmDO==$"mmDO>>% $D(8<8I8I"J1199;"JD**6/3/N/N/V/V/XD+, !< #Ks   .	GGc                "    | di dt         j                  |d         dt        |d         dt        |d         dt        |d         dt        |d         d	t        |d
         dt	        |d         dd|v rt         j                  |d         nd dd|v r"t
        j                  j                  |d         nd dd|v r|d   D cg c]  }t        |       c}nd dd|v rt        |d         nd dd|v rt        |d         nd dd|v rt        |d         nd dd|v rt	        |d         nd dd|v r&|d   D cg c]  }t        j                  |       c}nd dd|v rt        j                  |d         S d S c c}w c c}w )NrU   ri   rV   rj   rW   rk   rX   rY   r[   rl   r]   rm   r^   rn   r_   ro   r`   rb   rp   rc   rq   rd   rr   re   rf   rs   rg   rt   r   )	r
   r   rM   rZ   r\   r   BackendNodeIdr2   r?   r   r   ru   s      r   r   zLayer.from_json   s    
&&tI7
4	?+
 4	?+
 W&	

 h(
 D./
 tN34
 IX[_H_G--d?.CDei
 SbeiRiC--77_8MNos
 @Kd?Rk):;AuQx;X\
 09D/@U4	?+d
 09D/@U4	?+d
 09D/@U4	?+d
 2=1Dd4,-$
 TadhSh4;NOa*..q1Onr
  pJ  NR  pR'?'I'I$OiJj'k!
 	
  X\!
 	
 <
 Ps   FF)r%   r&   r'   r(   r=   r^   r_   r`   rb   rc   rd   re   rf   rg   r   r)   r   r   r   r   rT   rT      s      O O L M   15O-4 ;?O7> 6:I29 (,H$+ (,H$+ (,H$+ (,I$+ >BL:A MQ IP: 
 
r   rT   c                  <     e Zd ZdZddZedd       Z fdZ xZS )PaintProfilez/
    Array of timings, one per paint step.
    c                    | S r   r   r   s    r   r   zPaintProfile.to_json   r   r   c                     | |      S r   r   r   s     r   r   zPaintProfile.from_json   r   r   c                >    dj                  t        | 	               S )NzPaintProfile({})r   r   s    r   r   zPaintProfile.__repr__   s    !(()9);<<r   )r"   typing.List[float])r   r~   r"   rz   r$   r+   s   @r   rz   rz      s+      = =r   rz   c              #     K   t               }| j                         |d<   d|d}|}|d   D cg c]  }t        |       c}|d   D cg c]  }t        |       c}fS c c}w c c}w w)a  
    Provides the reasons why the given layer was composited.

    :param layer_id: The id of the layer for which we want to get the reasons it was composited.
    :returns: A tuple with the following items:

        0. **compositingReasons** - A list of strings specifying reasons for the given layer to become composited.
        1. **compositingReasonIds** - A list of strings specifying reason IDs for the given layer to become composited.
    ri   zLayerTree.compositingReasonsmethodparamscompositingReasonscompositingReasonIdsr8   r   r#   )rU   r   cmd_dictr   ru   s        r   compositing_reasonsr     sx      &F ((*F90H >D234AQ4456AQ6 46s   .A+A!	A+A&A+c               #     K   ddi} | }yw)z/
    Disables compositing tree inspection.
    r   zLayerTree.disableNr   r   r   s     r   disabler     s     
 	%H >D   
c               #     K   ddi} | }yw)z.
    Enables compositing tree inspection.
    r   zLayerTree.enableNr   r   s     r   enabler   $  s     
 	$H >Dr   c              #     K   t               }| D cg c]  }|j                          c}|d<   d|d}|}t        j                  |d         S c c}w w)z
    Returns the snapshot identifier.

    :param tiles: An array of tiles composing the snapshot.
    :returns: The id of the snapshot.
    tileszLayerTree.loadSnapshotr   
snapshotIdr8   r   r-   r   )r   r   ru   r   r   s        r   load_snapshotr   .  sZ      &F,12qqyy{2F7O*H >D\ 233 3s   AA,Ac              #     K   t               }| j                         |d<   d|d}|}t        j                  |d         S w)z
    Returns the layer snapshot identifier.

    :param layer_id: The id of the layer.
    :returns: The id of the layer snapshot.
    ri   zLayerTree.makeSnapshotr   r   r   )rU   r   r   r   s       r   make_snapshotr   A  sN      &F ((*F9*H >D\ 233s   ?Ac              #     K   t               }| j                         |d<   |||d<   |||d<   ||j                         |d<   d|d}|}|d   D cg c]  }t        j                  |       c}S c c}w w)a  
    :param snapshot_id: The id of the layer snapshot.
    :param min_repeat_count: *(Optional)* The maximum number of times to replay the snapshot (1, if not specified).
    :param min_duration: *(Optional)* The minimum duration (in seconds) to replay the snapshot.
    :param clip_rect: *(Optional)* The clip rectangle to apply when replaying the snapshot.
    :returns: The array of paint profiles, one per run.
    r   minRepeatCountminDurationclipRectzLayerTree.profileSnapshotr   timings)r8   r   rz   r   )snapshot_idmin_repeat_countmin_duration	clip_rectr   r   r   ru   s           r   profile_snapshotr   T  s      &F&..0F<##3  ,}&..0z-H >D/3I?!L""1%???s   AA7A2/A7c              #  X   K   t               }| j                         |d<   d|d}|}yw)zr
    Releases layer snapshot captured by the back-end.

    :param snapshot_id: The id of the layer snapshot.
    r   zLayerTree.releaseSnapshotr   Nr8   r   )r   r   r   r   s       r   release_snapshotr   q  s8      &F&..0F<-H >Ds   (*c              #     K   t               }| j                         |d<   |||d<   |||d<   |||d<   d|d}|}t        |d         S w)a  
    Replays the layer snapshot and returns the resulting bitmap.

    :param snapshot_id: The id of the layer snapshot.
    :param from_step: *(Optional)* The first step to replay from (replay from the very start if not specified).
    :param to_step: *(Optional)* The last step to replay to (replay till the end if not specified).
    :param scale: *(Optional)* The scale to apply while replaying (defaults to 1).
    :returns: A data: URL for resulting image.
    r   fromSteptoStepscalezLayerTree.replaySnapshotr   dataURLr   )r   	from_stepto_stepr   r   r   r   s          r   replay_snapshotr     sv      &F&..0F<&z"xw,H >DtIs   A
Ac              #     K   t               }| j                         |d<   d|d}|}|d   D cg c]  }t        |       c}S c c}w w)z
    Replays the layer snapshot and returns canvas log.

    :param snapshot_id: The id of the layer snapshot.
    :returns: The array of canvas function calls.
    r   zLayerTree.snapshotCommandLogr   
commandLogr   )r   r   r   r   ru   s        r   snapshot_command_logr     sU      &F&..0F<0H >D!,/0DG000s   .A
AA
zLayerTree.layerPaintedc                  4    e Zd ZU ded<   ded<   edd       Zy)LayerPaintedr
   rU   r3   clipc                     | t         j                  |d         t        j                  j                  |d               S )Nri   r   )rU   r   )r
   r   r   r;   r   s     r   r   zLayerPainted.from_json  s7    &&tI7##DL1
 	
r   N)r   r   r"   r   r%   r&   r'   r=   r)   r   r   r   r   r   r     s!     
N
 
r   r   zLayerTree.layerTreeDidChangec                  *    e Zd ZU ded<   edd       Zy)LayerTreeDidChangez#typing.Optional[typing.List[Layer]]layersc                |     | d|v r+|d   D cg c]  }t         j                  |       c}      S d       S c c}w )Nr   )r   )rT   r   rx   s      r   r   zLayerTreeDidChange.from_json  sA    CKtCSX?1EOOA&?
 	
Y]
 	
?s   9N)r   r   r"   r   r   r   r   r   r   r     s     0/
 
r   r   )rU   r
   r"   z\typing.Generator[T_JSON_DICT, T_JSON_DICT, typing.Tuple[typing.List[str], typing.List[str]]])r"   0typing.Generator[T_JSON_DICT, T_JSON_DICT, None])r   ztyping.List[PictureTile]r"   6typing.Generator[T_JSON_DICT, T_JSON_DICT, SnapshotId])rU   r
   r"   r   )NNN)
r   r-   r   typing.Optional[int]r   ra   r   ztyping.Optional[dom.Rect]r"   zEtyping.Generator[T_JSON_DICT, T_JSON_DICT, typing.List[PaintProfile]])r   r-   r"   r   )
r   r-   r   r   r   r   r   ra   r"   z/typing.Generator[T_JSON_DICT, T_JSON_DICT, str])r   r-   r"   z=typing.Generator[T_JSON_DICT, T_JSON_DICT, typing.List[dict]])
__future__r   utilr   r   dataclassesr   enumtyping r   r#   r
   r-   r2   r?   rL   rT   listrz   r   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>r      s   # * !   8c 8; ; 
 
 
0 !
 !
 !
H 
 
 
: e
 e
 e
P=4 =	c24'4	=4&44	=4* 26/3/3	@@.@ -@ -	@
 
M@:	7& +/(,(,	  '  &  &	 
 
7 >11	D1& %&

 
  '
 +,

 
  -
r   