<?php
namespace Claromentis\Core\Mail\Send\Driver;

$GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"] = (@$GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"] ?: array()) + array("_1a4b11c94c5e9f01a44ca4b3ec821aa" . "0" => base64_decode("Y2xpZW50X3Nl" . "Y3JldA=="), "_cc947bfa2be27002" . "552dd59168e5a945" => base64_decode("dGVuYW50X2" . "lk"), "_48ff585ffe724986368" . "985db41a811da" => base64_decode("d" . "X" . "B" . "u"), "_4d707fab93bebb00bbe6" . "9e8159697c90" => base64_decode(""), "_aed8da0f190912" . "14b78f803510485" . "17c" => base64_decode("c3RybG" . "Vu"), "_1db7fbca1ae6df9ba" . "c55436bafef3d7f" => base64_decode("c2Nv" . "cGVz"), "_6da449ebfb524a169e1db47b8a529b" . "7d" => base64_decode("cGFuZWxzLnN5c2FkbWluLm1haW" . "wuY29uZmlnLm1pY3Jvc29mdF9n" . "cmFwaC51bmV4cGVjdGVkX3Jlc3" . "BvbnNl"), "_1bee3d4d1d0df49e0f" . "cf8b9ed2ecb8fa" => base64_decode("ZXh" . "wbG" . "9kZ" . "Q=="), "objec" . "t_id" => base64_decode("b2JqZWN0" . "X2lk"), "_b3070ab55f28d79f2731d4aa08" . "1867f4" => base64_decode("cGFuZWxzLnN5c2FkbWluLm1haWwuY29uZmlnLm1pY3Jvc29mdF9ncmFwa" . "C5iYWRfcmVzcG9uc2U="), "_72d59d456b51bd2d4bf2795" . "18d502edc" => base64_decode("Y2xpZW50X" . "2lk"), "_a443e0578c35bef934e85841ef" . "1cac68" => base64_decode("aHR0cHM6Ly9ncmFwaC5taWNyb3NvZnQuY29tLy5kZWZhdWx" . "0"), "_5e9a99dc0dd49b907abf1b35e96965" . "f8" => base64_decode("dHJpb" . "Q=="), "_1ac5cc48c34c5362" . "e94d8667cc7b0ddc" => base64_decode("L" . "A" . "=" . "="));
use Claromentis\Core\Localization\Lmsg;
use Claromentis\Core\Mail\Exception\MailConnectionTestException;
use Claromentis\Core\Mail\Exception\MicrosoftGraphClientException;
use Claromentis\Core\Mail\Send\Transport\MicrosoftGraphTransport;
use Claromentis\Core\MicrosoftGraph\ClientFactory;
use Claromentis\Core\Variable\DbVarService;
use Symfony\Component\Mailer\Exception\TransportException;
use Symfony\Component\Mailer\Transport as SymfonyTransport;
use Exception;
class SendDriverMicrosoftGraph extends AbstractSendDriver
{
    protected string $display_name = '@{panels.sysadmin.mail_driver.microsoft_graph.display_name}';
    protected string $internal = 'microsoft_graph';
    protected string $description = '@{panels.sysadmin.mail_driver.microsoft_graph.description}';
    protected array $params = ['client_id' => ['title' => '@{panels.sysadmin.mail_driver.microsoft_graph.field_title.client_id}', 'type' => 'string', 'description' => '@{panels.sysadmin.mail_driver.microsoft_graph.field_name.client_id}', 'default' => '', 'required' => true], 'object_id' => ['title' => '@{panels.sysadmin.mail_driver.microsoft_graph.field_title.object_id}', 'type' => 'string', 'description' => '@{panels.sysadmin.mail_driver.microsoft_graph.field_name.object_id}', 'default' => '', 'required' => true], 'tenant_id' => ['title' => '@{panels.sysadmin.mail_driver.microsoft_graph.field_title.tenant_id}', 'type' => 'string', 'description' => '@{panels.sysadmin.mail_driver.microsoft_graph.field_name.tenant_id}', 'default' => '', 'required' => true], 'client_secret' => ['title' => '@{panels.sysadmin.mail_driver.microsoft_graph.field_title.client_secret}', 'type' => 'string', 'description' => '@{panels.sysadmin.mail_driver.microsoft_graph.field_name.client_secret}', 'default' => '', 'required' => true, 'secure' => true], 'upn' => ['title' => '@{panels.sysadmin.mail_driver.microsoft_graph.field_title.upn}', 'type' => 'string', 'description' => '@{panels.sysadmin.mail_driver.microsoft_graph.field_name.upn}', 'default' => '', 'required' => true], 'scopes' => ['title' => '@{panels.sysadmin.mail_driver.microsoft_graph.field_title.scopes}', 'type' => 'string', 'description' => '@{panels.sysadmin.mail_driver.microsoft_graph.field_name.scopes}', 'default' => 'https://graph.microsoft.com/.default']];
    
    
    
    
    private ClientFactory $clientFactory;
    
    
    
    
    private Lmsg $lmsg;
    
    
    
    
    
    
    
    public function __construct(ClientFactory $_666780a07d4106d3c725738ed19d65d5, Lmsg $lmsg)
    {
        $this->clientFactory = $_666780a07d4106d3c725738ed19d65d5;
        $this->lmsg = $lmsg;
    }
    public function testConnection(array $_4c4d12d3e4f6cac68e3eecffe9887915) : bool
    {
        $_91a468bbc68e21fc4b13e6636d0fc1fd = $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_5e9a99d" . "c0dd49b9" . "07abf1b3" . "5e96965f" . "8"]($_4c4d12d3e4f6cac68e3eecffe9887915[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_72d59d456b51bd2d4bf279518d50" . "2edc"]] ?? $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_4d707fab93bebb00bbe69" . "e8159697c90"]);
        $_bb8231658988b86cadf5751e75c5e01d = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_5e9a99dc0dd" . "49b907abf1b3" . "5e96965f8"]($_4c4d12d3e4f6cac68e3eecffe9887915[$GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_cc947bf" . "a2be2700" . "2552dd59" . "168e5a94" . "5"]] ?? $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_4d707fab93bebb00bbe69e81596" . "97c90"]);
        $_2a3aee1600c02ac512ca28fdfc058486 = $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_5e9a99dc0dd49b907abf1b35e96" . "965f8"]($_4c4d12d3e4f6cac68e3eecffe9887915[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["object_i" . "d"]] ?? $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_4d707fab9" . "3bebb00bbe" . "69e8159697" . "c90"]);
        $_112420d805889e4b2adf4053a6821ec9 = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_5e9a99dc0dd49b9" . "07abf1b35e96965f" . "8"]($_4c4d12d3e4f6cac68e3eecffe9887915[$GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_1a4b11c94c5" . "e9f01a44ca4b" . "3ec821aa0"]] ?? $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_4d707fab93bebb00bbe69e8159697" . "c90"]);
        $_1db7fbca1ae6df9bac55436bafef3d7f = $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_1bee3d4d1d0df4" . "9e0fcf8b9ed2ecb" . "8fa"]($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_1ac5cc48c34c5362e94d8" . "667cc7b0ddc"], $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_5e9a99dc0dd49b907abf1b35e969" . "65f8"]($_4c4d12d3e4f6cac68e3eecffe9887915[$GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_1db7fbca1ae6df9bac" . "55436bafef3d7f"]] ?? $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_a443e0578c35bef934e85841e" . "f1cac68"]));
        $_7c9e0d2e03cbc953d1e0172764de6743 = $_4c4d12d3e4f6cac68e3eecffe9887915[$GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_48ff585ff" . "e724986368" . "985db41a81" . "1da"]] ?? $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_4d707fa" . "b93bebb0" . "0bbe69e8" . "159697c9" . "0"];
        try {
            $this->clientFactory->clearAccessToken();
            return (new MicrosoftGraphTransport(($this->clientFactory)($_91a468bbc68e21fc4b13e6636d0fc1fd, $_bb8231658988b86cadf5751e75c5e01d, $_112420d805889e4b2adf4053a6821ec9, $_1db7fbca1ae6df9bac55436bafef3d7f), $_7c9e0d2e03cbc953d1e0172764de6743, $this->lmsg, null, $this->logger))->testConnection($_2a3aee1600c02ac512ca28fdfc058486);
        } catch (MicrosoftGraphClientException $_fe441aa3ef350bfb1a1a1ad8520dd530) {
            $this->logger->error($_fe441aa3ef350bfb1a1a1ad8520dd530);
            throw new MailConnectionTestException(($this->lmsg)($GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_b3070ab55f2" . "8d79f2731d4a" . "a081867f4"], $_fe441aa3ef350bfb1a1a1ad8520dd530->getMessage()), 0, $_fe441aa3ef350bfb1a1a1ad8520dd530);
        } catch (MailConnectionTestException $_fe441aa3ef350bfb1a1a1ad8520dd530) {
            throw $_fe441aa3ef350bfb1a1a1ad8520dd530;
        } catch (Exception $_fe441aa3ef350bfb1a1a1ad8520dd530) {
            $this->logger->error($_fe441aa3ef350bfb1a1a1ad8520dd530);
            throw new MailConnectionTestException(($this->lmsg)($GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_6da449ebfb524a169e1d" . "b47b8a529b7d"]), 0, $_fe441aa3ef350bfb1a1a1ad8520dd530);
        }
        return false;
    }
    public function getTransport() : SymfonyTransport\TransportInterface
    {
        $_91a468bbc68e21fc4b13e6636d0fc1fd = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_5e9a99dc0dd49b907abf1" . "b35e96965f8"]($this->getParamValue($this->params, $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_72d59d456b51" . "bd2d4bf279518" . "d502edc"]));
        $_bb8231658988b86cadf5751e75c5e01d = $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_5e9a99dc" . "0dd49b907" . "abf1b35e9" . "6965f8"]($this->getParamValue($this->params, $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_cc947bfa2b" . "e27002552dd" . "59168e5a945"]));
        $_112420d805889e4b2adf4053a6821ec9 = $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_5e9a99dc0dd49b907abf1b" . "35e96965f8"]($this->getParamValue($this->params, $GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_1a4b11c94c5e9f01a44" . "ca4b3ec821aa0"]));
        $_1db7fbca1ae6df9bac55436bafef3d7f = $this->getParamValue($this->params, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_1db7fbca1ae6df9bac55436b" . "afef3d7f"]);
        $_48ff585ffe724986368985db41a811da = $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_5e9a99dc0dd49" . "b907abf1b35e96" . "965f8"]($this->getParamValue($this->params, $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_48ff585" . "ffe72498" . "6368985d" . "b41a811d" . "a"]));
        if ($GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_aed8da0f" . "19091214b" . "78f803510" . "48517c"]($_1db7fbca1ae6df9bac55436bafef3d7f)) {
            $_1db7fbca1ae6df9bac55436bafef3d7f = $GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_1bee3d4d1d0df49e0fcf8b" . "9ed2ecb8fa"]($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_1ac5cc48c34c5362e94" . "d8667cc7b0ddc"], $GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_5e9a99dc0dd49b9" . "07abf1b35e96965f" . "8"]($_1db7fbca1ae6df9bac55436bafef3d7f));
        } else {
            $_1db7fbca1ae6df9bac55436bafef3d7f = [$GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_a443e0578c35bef" . "934e85841ef1cac6" . "8"]];
        }
        try {
            return new MicrosoftGraphTransport(($this->clientFactory)($_91a468bbc68e21fc4b13e6636d0fc1fd, $_bb8231658988b86cadf5751e75c5e01d, $_112420d805889e4b2adf4053a6821ec9, $_1db7fbca1ae6df9bac55436bafef3d7f), $_48ff585ffe724986368985db41a811da, $this->lmsg, null, $this->logger);
        } catch (MicrosoftGraphClientException $_fe441aa3ef350bfb1a1a1ad8520dd530) {
            $this->logger->error($_fe441aa3ef350bfb1a1a1ad8520dd530);
            throw new TransportException(($this->lmsg)($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_b3070ab55f28d79f2731d4aa0818" . "67f4"], $_fe441aa3ef350bfb1a1a1ad8520dd530->getMessage()), 0, $_fe441aa3ef350bfb1a1a1ad8520dd530);
        } catch (Exception $_fe441aa3ef350bfb1a1a1ad8520dd530) {
            $this->logger->error($_fe441aa3ef350bfb1a1a1ad8520dd530);
            throw new TransportException(($this->lmsg)($GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_6da449ebfb524a" . "169e1db47b8a529" . "b7d"]), 0, $_fe441aa3ef350bfb1a1a1ad8520dd530);
        }
    }
}