<?php


namespace OTP\Handler;

if (defined("\101\102\x53\x50\x41\124\110")) {
    goto X6W;
}
die;
X6W:
use OTP\Helper\FormSessionVars;
use OTP\Helper\GatewayFunctions;
use OTP\Helper\MoConstants;
use OTP\Helper\MoMessages;
use OTP\Helper\MoUtility;
use OTP\Helper\SessionUtils;
use OTP\Objects\VerificationLogic;
use OTP\Traits\Instance;
final class EmailVerificationLogic extends VerificationLogic
{
    use Instance;
    public function _handle_logic($te, $j4, $sP, $c2, $DF)
    {
        if (is_email($j4)) {
            goto Z2P;
        }
        $this->_handle_not_matched($j4, $c2, $DF);
        goto PQ8;
        Z2P:
        $this->_handle_matched($te, $j4, $sP, $c2, $DF);
        PQ8:
    }
    public function _handle_matched($te, $j4, $sP, $c2, $DF)
    {
        $Kl = str_replace("\x23\x23\x65\155\x61\151\x6c\x23\x23", $j4, $this->_get_is_blocked_message());
        if ($this->_is_blocked($j4, $sP)) {
            goto tKb;
        }
        $this->_start_otp_verification($te, $j4, $sP, $c2, $DF);
        goto vU9;
        tKb:
        if ($this->_is_ajax_form()) {
            goto PpE;
        }
        miniorange_site_otp_validation_form(null, null, null, $Kl, $c2, $DF);
        goto Ng0;
        PpE:
        wp_send_json(MoUtility::createJson($Kl, MoConstants::ERROR_JSON_TYPE));
        Ng0:
        vU9:
    }
    public function _handle_not_matched($j4, $c2, $DF)
    {
        $Kl = str_replace("\43\x23\145\x6d\141\x69\x6c\43\43", $j4, $this->_get_otp_invalid_format_message());
        if ($this->_is_ajax_form()) {
            goto myk;
        }
        miniorange_site_otp_validation_form(null, null, null, $Kl, $c2, $DF);
        goto jcJ;
        myk:
        wp_send_json(MoUtility::createJson($Kl, MoConstants::ERROR_JSON_TYPE));
        jcJ:
    }
    public function _start_otp_verification($te, $j4, $sP, $c2, $DF)
    {
        $c6 = GatewayFunctions::instance();
        $PA = $c6->mo_send_otp_token("\105\115\101\111\114", $j4, '');
        switch ($PA["\x73\164\x61\164\165\x73"]) {
            case "\123\x55\103\x43\105\x53\123":
                $this->_handle_otp_sent($te, $j4, $sP, $c2, $DF, $PA);
                goto d05;
            default:
                $this->_handle_otp_sent_failed($te, $j4, $sP, $c2, $DF, $PA);
                goto d05;
        }
        qWO:
        d05:
    }
    public function _handle_otp_sent($te, $j4, $sP, $c2, $DF, $PA)
    {
        SessionUtils::setEmailTransactionID($PA["\x74\x78\111\x64"]);
        if (!(MoUtility::micr() && MoUtility::isMG())) {
            goto S9e;
        }
        $Nw = get_mo_option("\x65\x6d\x61\151\x6c\137\164\x72\x61\156\163\x61\143\x74\151\157\156\163\x5f\162\145\x6d\141\151\156\151\x6e\147");
        if (!($Nw > 0)) {
            goto kXh;
        }
        update_mo_option("\145\x6d\x61\x69\154\x5f\x74\x72\141\x6e\163\141\143\164\151\x6f\x6e\163\137\x72\x65\155\x61\151\156\x69\156\147", $Nw - 1);
        kXh:
        S9e:
        $Kl = str_replace("\x23\x23\145\155\141\x69\x6c\x23\43", $j4, $this->_get_otp_sent_message());
        if ($this->_is_ajax_form()) {
            goto hrw;
        }
        miniorange_site_otp_validation_form($te, $j4, $sP, $Kl, $c2, $DF);
        goto DaC;
        hrw:
        wp_send_json(MoUtility::createJson($Kl, MoConstants::SUCCESS_JSON_TYPE));
        DaC:
    }
    public function _handle_otp_sent_failed($te, $j4, $sP, $c2, $DF, $PA)
    {
        $Kl = str_replace("\x23\x23\145\x6d\141\x69\154\43\43", $j4, $this->_get_otp_sent_failed_message());
        if ($this->_is_ajax_form()) {
            goto unx;
        }
        miniorange_site_otp_validation_form(null, null, null, $Kl, $c2, $DF);
        goto mhp;
        unx:
        wp_send_json(MoUtility::createJson($Kl, MoConstants::ERROR_JSON_TYPE));
        mhp:
    }
    public function _get_otp_sent_message()
    {
        $rx = get_mo_option("\x73\165\143\x63\x65\x73\163\x5f\x65\x6d\141\151\x6c\x5f\155\145\x73\x73\x61\x67\145", "\155\x6f\x5f\x6f\x74\160\137");
        return $rx ? $rx : MoMessages::showMessage(MoMessages::OTP_SENT_EMAIL);
    }
    public function _get_otp_sent_failed_message()
    {
        $Yi = get_mo_option("\145\x72\162\x6f\x72\x5f\x65\x6d\x61\151\154\137\x6d\x65\x73\x73\x61\147\x65", "\155\157\137\157\x74\160\137");
        return $Yi ? $Yi : MoMessages::showMessage(MoMessages::ERROR_OTP_EMAIL);
    }
    public function _is_blocked($j4, $sP)
    {
        $x2 = explode("\73", get_mo_option("\142\x6c\157\143\x6b\145\x64\x5f\144\157\x6d\141\151\x6e\x73"));
        $x2 = apply_filters("\155\157\137\142\154\157\x63\153\145\x64\x5f\x65\x6d\x61\151\x6c\x5f\x64\x6f\155\141\x69\x6e\x73", $x2);
        return in_array(MoUtility::getDomain($j4), $x2);
    }
    public function _get_is_blocked_message()
    {
        $nk = get_mo_option("\x62\154\x6f\x63\153\x65\x64\137\145\x6d\141\x69\x6c\137\155\x65\x73\x73\141\x67\145", "\x6d\157\x5f\157\164\x70\x5f");
        return $nk ? $nk : MoMessages::showMessage(MoMessages::ERROR_EMAIL_BLOCKED);
    }
    public function _get_otp_invalid_format_message()
    {
        $Kl = get_mo_option("\151\156\166\x61\154\x69\144\137\x65\155\x61\x69\x6c\137\x6d\145\x73\163\x61\x67\145", "\x6d\157\x5f\x6f\x74\160\137");
        return $Kl ? $Kl : MoMessages::showMessage(MoMessages::ERROR_EMAIL_FORMAT);
    }
}
