o
    B_i                     @   sh   d dl Z d dlmZ ddlmZ ddlmZmZ ddlm	Z	 de
d	e
fd
dZdede
d	dfddZdS )    N)Page   )shot)log_steppause   )handle_terminate_sessionsargreturnc                 C   s(   | r|   S tdddd tj   S )NzEnter 6-digit MFA code:  T)endflush)stripprintsysstdinreadline)r	    r   N/var/www/html/flask_server/apps/aroflo_connector_app/ui_automation/auth/mfa.pyprompt_mfa_code   s   r   pagemfa_code_argc                 C   sH  | j ddd t| |d td|  |jrt|d t|}t|dks(| s,td| 	d}|
 dk r;td	|d
  | jj|t|jdd t| |d td|  | 	d}|
 ri|jjdd t| |d td|  | 	d}|
 std|j  | j ddd t| | | 	d
 rtd| d d S )Nz() => {
            const t = document.body?.innerText || '';
            const p = document.querySelector('#postLoginType');
            return t.includes('Verify Your Account') || (p && p.value === 'verifyMFA');
        }i0u  )timeoutzstep4-mfa-blankzMFA screen detected   zInvalid MFA codez6input.af-otpInput-input, input[id^="otpInput__input-"]zMFA inputs not foundr   (   )delayzstep5-mfa-filledzlabel[for="mfa_trust_device"]T)forcezstep6-mfa-trustz3button:has-text("Verify"), form#frmPostLogin buttonzVerify button not founda
  () => {
            const t = document.body?.innerText || '';
            const p = document.querySelector('#postLoginType')?.value || '';
            return t.includes('MFA code is invalid') || p === 'terminateSessions' || location.href.includes('/ims/');
        }i`  ztext=MFA code is invalidzMFA rejectediX  )wait_for_functionr   r   pause_on_mfar   r   lenisdigitRuntimeErrorlocatorcountnthclickkeyboardtypemax
slow_mo_msfirstr   wait_for_timeout)r   cfgrun_dirr   codeinputslblbtnr   r   r   
handle_mfa   sF   	








	r2   )r   playwright.sync_apir   core.artifactsr   core.logr   r   
post_loginr   strr   r2   r   r   r   r   <module>   s   