o
    ҷh                     @  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G dd dej	Z
G dd	 d	ej	ZeG d
d dZ	d$d%ddZd&ddZd'ddZd(ddZ	d$d)ddZd&dd Zed!eG d"d# d#ZdS )*    )annotations   )event_classT_JSON_DICT)	dataclassNc                   @  s,   e Zd ZdZdZdZdd Zedd ZdS )	
LoginStatez
    Whether this is a sign-up or sign-in action for this account, i.e.
    whether this account has ever been used to sign in to this RP before.
    SignInSignUpc                 C     | j S Nvalueself r   a/var/www/html/venv/lib/python3.10/site-packages/selenium/webdriver/common/devtools/v118/fed_cm.pyto_json      zLoginState.to_jsonc                 C     | |S r   r   clsjsonr   r   r   	from_json      zLoginState.from_jsonN)	__name__
__module____qualname____doc__SIGN_INSIGN_UPr   classmethodr   r   r   r   r   r      s    r   c                   @  s0   e Zd ZdZdZdZdZdd Zedd Z	d	S )

DialogTypez]
    Whether the dialog shown is an account chooser or an auto re-authentication dialog.
    AccountChooserAutoReauthnConfirmIdpSigninc                 C  r
   r   r   r   r   r   r   r   %   r   zDialogType.to_jsonc                 C  r   r   r   r   r   r   r   r   (   r   zDialogType.from_jsonN)
r   r   r   r   ACCOUNT_CHOOSERAUTO_REAUTHNCONFIRM_IDP_SIGNINr   r    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 )Accountz/
    Corresponds to IdentityRequestAccount
    str
account_idemailname
given_namepicture_urlidp_config_urlidp_signin_urlr   login_stateNtyping.Optional[str]terms_of_service_urlprivacy_policy_urlc                 C  s   t  }| j|d< | j|d< | j|d< | j|d< | j|d< | j|d< | j|d< | j	 |d< | j
d ur7| j
|d	< | jd urA| j|d
< |S )N	accountIdr+   r,   	givenName
pictureUrlidpConfigUrlidpSigninUrl
loginStatetermsOfServiceUrlprivacyPolicyUrl)dictr*   r+   r,   r-   r.   r/   r0   r1   r   r3   r4   )r   r   r   r   r   r   G   s   










zAccount.to_jsonc                 C  s   | t |d t |d t |d t |d t |d t |d t |d t|d d	|v r4t |d	 nd d
|v rAt |d
 d
S d d
S )Nr5   r+   r,   r6   r7   r8   r9   r:   r;   r<   )
r*   r+   r,   r-   r.   r/   r0   r1   r3   r4   )r)   r   r   r   r   r   r   r   W   s   







zAccount.from_json)
r   r   r   r   __annotations__r3   r4   r   r    r   r   r   r   r   r(   -   s   
 r(   disable_rejection_delaytyping.Optional[bool]return0typing.Generator[T_JSON_DICT, T_JSON_DICT, None]c                 c  s,    t  }| dur| |d< d|d}|V }dS )z
    :param disable_rejection_delay: *(Optional)* Allows callers to disable the promise rejection delay that would normally happen, if this is unimportant to what's being tested. (step 4 of https://fedidcg.github.io/FedCM/#browser-api-rp-sign-in)
    NdisableRejectionDelayzFedCm.enablemethodparamsr=   )r?   rF   cmd_dictr   r   r   r   enableg   s   
rI   c                  c  s    ddi} | V }d S )NrE   zFedCm.disabler   rH   r   r   r   r   disablew   s   
rK   	dialog_idr)   account_indexintc                 c  s,    t  }| |d< ||d< d|d}|V }dS )z5
    :param dialog_id:
    :param account_index:
    dialogIdaccountIndexzFedCm.selectAccountrD   NrG   )rL   rM   rF   rH   r   r   r   r   select_account   s   
rQ   c                 c  s$    t  }| |d< d|d}|V }dS )z
    Only valid if the dialog type is ConfirmIdpSignin. Acts as if the user had
    clicked the continue button.

    :param dialog_id:
    rO   zFedCm.confirmIdpSigninrD   NrG   )rL   rF   rH   r   r   r   r   confirm_idp_signin   s   	
rR   trigger_cooldownc                 c  s4    t  }| |d< |dur||d< d|d}|V }dS )zE
    :param dialog_id:
    :param trigger_cooldown: *(Optional)*
    rO   NtriggerCooldownzFedCm.dismissDialogrD   rG   )rL   rS   rF   rH   r   r   r   r   dismiss_dialog   s   
rU   c                  c  s    ddi} | V }dS )z
    Resets the cooldown time, if any, to allow the next FedCM call to show
    a dialog even if one was recently dismissed by the user.
    rE   zFedCm.resetCooldownNr   rJ   r   r   r   reset_cooldown   s   
rV   zFedCm.dialogShownc                   @  sD   e Zd ZU ded< ded< ded< ded< ded	< edddZdS )DialogShownr)   rL   r!   dialog_typeztyping.List[Account]accountstitler2   subtitler   r   rA   c                 C  sR   | t |d t|d dd |d D t |d d|v r%t |d dS d dS )	NrO   
dialogTypec                 S  s   g | ]}t |qS r   )r(   r   ).0ir   r   r   
<listcomp>   s    z)DialogShown.from_json.<locals>.<listcomp>rY   rZ   r[   )rL   rX   rY   rZ   r[   )r)   r!   r   r   r   r   r   r      s   

zDialogShown.from_jsonN)r   r   rA   rW   )r   r   r   r>   r    r   r   r   r   r   rW      s   
 rW   r   )r?   r@   rA   rB   )rA   rB   )rL   r)   rM   rN   rA   rB   )rL   r)   rA   rB   )rL   r)   rS   r@   rA   rB   )
__future__r   utilr   r   dataclassesr   enumtypingEnumr   r!   r(   rI   rK   rQ   rR   rU   rV   rW   r   r   r   r   <module>   s(   :



