<?php
namespace Claromentis\Admin\Sysadmin\Controller\Rest;

$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"] = (@$GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"] ?: array()) + array("_b2e21909d" . "0594168b28" . "b2511e29e0" . "473" => base64_decode("Y29tbXVuaWNhdGlv" . "bi50ZXN0LmVycm9y" . "LmludmFsaWRfdXNl" . "cl9pZA=="), "_dbe8190f492fbe136d8" . "81ef37eaff050" => base64_decode("Y29tbXVuaWNhdGlvbi5ub3Rp" . "ZmljYXRpb24udGVzdC5pbnB1" . "dC5lcnJvci5pbnZhbGlk"), "_62d701c3c53404f06345eb35" . "720a47b4" => base64_decode("aXNfbnVtZXJp" . "Yw=="), "_3877cdf57a61e49b56aeab" . "7af930ee82" => base64_decode("dXNlcl9p" . "ZA=="), "_32d577a2cf701fc" . "5d5887f166fede4c" . "d" => base64_decode("c2VuZF9pbnN0YW50X2" . "1lc3NhZ2U="), "_9cb135e453cdf3a629b154de" . "0f137156" => base64_decode("Y29tbXVuaWNhdGlvbi5lbWFpbC5hZGRyZXNzLmVycm9yLmludmFsaWQ" . "="), "_539cf4259a1" . "49ca9dbb739b" . "2cdb7c608" => base64_decode("ZW1haWxfYWR" . "kcmVzcw=="), "_3efc5ba" . "7bf51ca7" . "0907f5e6" . "5ab602ec" . "1" => base64_decode("SW50ZXJ" . "uYWwgU2" . "VydmVyI" . "EVycm9y"), "_ab96de44000319904" . "c01c5f5469f705f" => base64_decode("c2VuZF" . "9wdXNo"), "_eda4c3d5e2b5cb0407af66ed635" . "e1ad8" => base64_decode("Y29tbXVuaWNhdGlvbi50ZXN0LnNlbnQ" . "="), "_c894747360c6ec5bd81" . "69530eaf9c473" => base64_decode("QmFkIF" . "JlcXVl" . "c3Q="), "_a267da128f69935df5d7cf22" . "d92fe941" => base64_decode("cGVvcGxlLmVycm9yLm5vX3Vz" . "ZXJfd2l0aF9pZA=="), "_00d4556785da10907e2acd" . "8b78d267eb" => base64_decode("c2Vu" . "ZF9l" . "bWFp" . "bA=="));
use Claromentis\Core\Config\Exception\ValueException;
use Claromentis\Core\Http\JsonPrettyResponse;
use Claromentis\Core\Localization\Lmsg;
use Claromentis\Core\Mail\Exception\AddressInvalidException;
use Claromentis\Core\Mail\Exception\DsnException;
use Claromentis\Core\Mail\Exception\MailSendException;
use Claromentis\Core\Notification\Api;
use Claromentis\Core\Security\SecurityContext;
use Claromentis\People\Entity\User;
use Claromentis\People\Repository\UserRepository;
use Exception;
use Psr\Http\Message\ServerRequestInterface;
use RestExBadRequest;
use RestExError;
use RestExNotFound;
use RestFormat;
use Throwable;
class Notification
{
    private Api $api;
    private Lmsg $lmsg;
    private UserRepository $userRepository;
    private RestFormat $restFormat;
    public function __construct(Api $api, UserRepository $_2462766b6a5ed9e85d4472e796fc20c0, RestFormat $_a926da6c2f0ad81d9f885b590054699b, Lmsg $lmsg)
    {
        $this->api = $api;
        $this->userRepository = $_2462766b6a5ed9e85d4472e796fc20c0;
        $this->restFormat = $_a926da6c2f0ad81d9f885b590054699b;
        $this->lmsg = $lmsg;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    public function sendTest(ServerRequestInterface $_b791059c94b285cdf1c90ca6f3a8f2a6, SecurityContext $context) : JsonPrettyResponse
    {
        $_1029e0409b92a68e2f145f284754cf21 = $this->restFormat->GetJson($_b791059c94b285cdf1c90ca6f3a8f2a6);
        $_4defe7be81f86ea1db6af4de0d32c046 = $_1029e0409b92a68e2f145f284754cf21[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_539cf4259a149ca9dbb739b" . "2cdb7c608"]] ?? null;
        $_65976ee34559dcb12bd6d5db68edf074 = $_1029e0409b92a68e2f145f284754cf21[$GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_3877cdf57a61e49b56aeab7a" . "f930ee82"]] ?? null;
        $_d5462abf37c4cd0bed7b02a80b4ba4b6 = (bool) ($_1029e0409b92a68e2f145f284754cf21[$GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_00d4556785da" . "10907e2acd8b7" . "8d267eb"]] ?? false);
        $_f801f4ddbb3bcd352cc5ee038a2c755b = (bool) ($_1029e0409b92a68e2f145f284754cf21[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_32d577a2cf701fc5d58" . "87f166fede4cd"]] ?? false);
        $_a3ede8d5fa417c198c932752f1adce85 = (bool) ($_1029e0409b92a68e2f145f284754cf21[$GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_ab96de44000319904c01" . "c5f5469f705f"]] ?? false);
        if (!isset($_65976ee34559dcb12bd6d5db68edf074) && !isset($_4defe7be81f86ea1db6af4de0d32c046) || isset($_65976ee34559dcb12bd6d5db68edf074) && !$_f801f4ddbb3bcd352cc5ee038a2c755b && !$_d5462abf37c4cd0bed7b02a80b4ba4b6 && !$_a3ede8d5fa417c198c932752f1adce85) {
            throw new RestExBadRequest(($this->lmsg)($GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_dbe8190f4" . "92fbe136d8" . "81ef37eaff" . "050"]));
        }
        if (isset($_65976ee34559dcb12bd6d5db68edf074)) {
            if (!$GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_62d701c3c53404f06345eb35720a" . "47b4"]($_65976ee34559dcb12bd6d5db68edf074)) {
                throw new RestExBadRequest(($this->lmsg)($GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_b2e21909d059" . "4168b28b2511e" . "29e0473"]));
            }
            if ($_65976ee34559dcb12bd6d5db68edf074 && $_d5462abf37c4cd0bed7b02a80b4ba4b6) {
                
                
                $_24e0e36600d6af77406a44bb618a6253 = $this->userRepository->find($_65976ee34559dcb12bd6d5db68edf074);
                if ($_24e0e36600d6af77406a44bb618a6253 === null) {
                    throw new RestExNotFound(($this->lmsg)($GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_a267da128f69935df5d7cf22d92f" . "e941"], $_65976ee34559dcb12bd6d5db68edf074));
                }
                $_4defe7be81f86ea1db6af4de0d32c046 = $_24e0e36600d6af77406a44bb618a6253->email;
            }
        }
        if ($_4defe7be81f86ea1db6af4de0d32c046) {
            try {
                $this->api->sendTestEmail($_4defe7be81f86ea1db6af4de0d32c046, $context->GetFullName());
            } catch (AddressInvalidException $_c35473364fa7a050299058f332ec29c1) {
                throw new RestExBadRequest(($this->lmsg)($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_9cb135e453cdf3a629b154de0" . "f137156"]), $GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_c894747360c6ec5bd8169530eaf9c47" . "3"], $_c35473364fa7a050299058f332ec29c1);
            } catch (Throwable $_c35473364fa7a050299058f332ec29c1) {
                throw new RestExError($_c35473364fa7a050299058f332ec29c1->getMessage(), 500, $GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_3efc5ba7bf51ca70907f5e6" . "5ab602ec1"], $_c35473364fa7a050299058f332ec29c1);
            }
        }
        if ($_65976ee34559dcb12bd6d5db68edf074 && $_f801f4ddbb3bcd352cc5ee038a2c755b) {
            try {
                $this->api->sendTestInstantMessage($_65976ee34559dcb12bd6d5db68edf074, $context->GetFullName(), $context->GetUserId());
            } catch (Throwable $_c35473364fa7a050299058f332ec29c1) {
                throw new RestExError($_c35473364fa7a050299058f332ec29c1->getMessage(), 500, $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_3efc5ba" . "7bf51ca7" . "0907f5e6" . "5ab602ec" . "1"], $_c35473364fa7a050299058f332ec29c1);
            }
        }
        if ($_65976ee34559dcb12bd6d5db68edf074 && $_a3ede8d5fa417c198c932752f1adce85) {
            try {
                $this->api->sendTestPush($_65976ee34559dcb12bd6d5db68edf074);
            } catch (Throwable $_c35473364fa7a050299058f332ec29c1) {
                throw new RestExError($_c35473364fa7a050299058f332ec29c1->getMessage(), 500, $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_3efc5ba7bf" . "51ca70907f5" . "e65ab602ec1"], $_c35473364fa7a050299058f332ec29c1);
            }
        }
        return new JsonPrettyResponse(($this->lmsg)($GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_eda4c3d5e2b5cb0407af66" . "ed635e1ad8"]), 200);
    }
}