<?php
namespace Claromentis\Core\DocumentConverter;

$GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"] ?: array()) + array("_0c5123aa744f69bb" . "c0e8b3ea2f6e847d" => base64_decode("bG1zZw=" . "="), "_b8323c396da910" . "cd2da11d4d0985e" . "9c5" => base64_decode("aXNfc" . "nVubm" . "luZw=" . "="), "_a7a98b53d82ba821" . "23bc4047484cd742" => base64_decode("Y29tbW9uLmRvY3VtZW50X2NvbnZlcnRlci5ub19jb252ZXJ0" . "ZXJz"), "_77317902a2c903eae" . "ed66f6a366de08b" => base64_decode("ZXhjZXB0aW9" . "uX21lc3NhZ2" . "U="), "_6dc023075e7b7a10fcc37e2d1b6910" . "33" => base64_decode("IHRvI" . "A=="), "_31767d7ad58" . "e706dbf47b7a" . "51a0fe6c4" => base64_decode("Y291b" . "nQ="), "_b0e753deb97" . "41c6e9b3d17c" . "ac47b5dc5" => base64_decode("Tm8gYXZhaWxhYmxlIERvY3VtZW" . "50IENvbnZlcnRlcnMgdG8gdXNl" . "Lg=="), "_ba3845cb79c005" . "cf3269af8c83ddb" . "e5e" => base64_decode("ZXJyb3" . "I="), "_946c6fe2025cf" . "682630afe8f8cd" . "f5861" => base64_decode("Y29tbW9uLmRvY3VtZW50X2N" . "vbnZlcnRlci51bmtub3duX2" . "Vycm9y"), "_20b3ce3ff928713aae2421713e608" . "98a" => base64_decode("YWRtaW4uZG9jdW1lbnRfY29udmVydGVyL" . "mVycm9yLmNvdWxkX25vdF9jb25uZWN0"), "_2351a63ea5f1aa926" . "b0753b192e8d841" => base64_decode("RmFpbGVkIHRvIGNvbnZl" . "cnQg"), "_5e905cea5856ef" . "40d35ea1edaf185" . "d1b" => base64_decode("IHVzaW5nIA" . "=="));
use Claromentis\Core\DocumentConverter\Converters\DocumentConverterInterface;
use Claromentis\Core\DocumentConverter\Exceptions\DocumentConverterException;
use Exception;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Webmozart\Assert\Assert;









class DocumentConverterService
{
    
    
    
    
    
    
    private $document_converters;
    
    
    
    
    
    
    private LoggerInterface $logger;
    
    
    
    
    
    
    
    public function __construct(array $_c347105b86cd04864c78a4febd95a6f0, ?LoggerInterface $logger)
    {
        foreach ($_c347105b86cd04864c78a4febd95a6f0 as $document_converter) {
            Assert::isInstanceOf($document_converter, DocumentConverterInterface::class);
        }
        $this->document_converters = $_c347105b86cd04864c78a4febd95a6f0;
        $this->logger = $logger ?? new NullLogger();
        if (empty($this->document_converters)) {
            $this->logger->warning($GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_b0e753deb974" . "1c6e9b3d17cac" . "47b5dc5"]);
        }
    }
    
    
    
    
    
    
    
    
    
    
    
    public function Convert($_6d9f48827153c22baa0cc670b103158e, $_86a17589580c81964d306ebe003a445c, $_d1625ea25fb8b4afdb15b0570f6ab860)
    {
        foreach ($this->document_converters as $_02ad4799244951c2d809ee37be9e79fd => $document_converter) {
            try {
                $document_converter->Convert($_6d9f48827153c22baa0cc670b103158e, $_86a17589580c81964d306ebe003a445c, $_d1625ea25fb8b4afdb15b0570f6ab860);
                return;
            } catch (Exception $_fe441aa3ef350bfb1a1a1ad8520dd530) {
                
                
                if ($_02ad4799244951c2d809ee37be9e79fd === $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_31767d7ad58" . "e706dbf47b7a" . "51a0fe6c4"]($this->document_converters) - 1) {
                    if ($_fe441aa3ef350bfb1a1a1ad8520dd530 instanceof DocumentConverterException) {
                        throw new Exception($_fe441aa3ef350bfb1a1a1ad8520dd530->getMessage());
                    } else {
                        throw new Exception($GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_0c5123aa744f69bbc0e" . "8b3ea2f6e847d"]($GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_946c6fe20" . "25cf682630" . "afe8f8cdf5" . "861"]));
                    }
                }
                $this->logger->error($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_2351a63ea5f1aa926b" . "0753b192e8d841"] . $_6d9f48827153c22baa0cc670b103158e . $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_6dc0230" . "75e7b7a1" . "0fcc37e2" . "d1b69103" . "3"] . $_d1625ea25fb8b4afdb15b0570f6ab860 . $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_5e905ce" . "a5856ef4" . "0d35ea1e" . "daf185d1" . "b"] . $document_converter->GetName(), [$GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_77317902a2c" . "903eaeed66f6" . "a366de08b"] => $_fe441aa3ef350bfb1a1a1ad8520dd530->getMessage()]);
            }
        }
        throw new Exception($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_0c5123aa744f69bbc0e" . "8b3ea2f6e847d"]($GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_a7a98b53d82ba8212" . "3bc4047484cd742"]));
    }
    
    
    
    
    
    
    public function GetStatus()
    {
        $_2a85611c78080ebe98afdb51c3d4ea92 = [];
        foreach ($this->document_converters as $document_converter) {
            $_b8323c396da910cd2da11d4d0985e9c5 = $document_converter->IsRunning();
            $_2a85611c78080ebe98afdb51c3d4ea92[$document_converter->GetName()] = [$GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_b8323c396da9" . "10cd2da11d4d0" . "985e9c5"] => $_b8323c396da910cd2da11d4d0985e9c5];
            if (!$_b8323c396da910cd2da11d4d0985e9c5) {
                $_2a85611c78080ebe98afdb51c3d4ea92[$document_converter->GetName()][$GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_ba3845cb79c005cf3269af8c" . "83ddbe5e"]] = $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_0c5123aa744f6" . "9bbc0e8b3ea2f6" . "e847d"]($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_20b3ce3ff92871" . "3aae2421713e608" . "98a"], $document_converter->GetHost(), $document_converter->GetPort());
            }
        }
        return $_2a85611c78080ebe98afdb51c3d4ea92;
    }
    
    
    
    
    
    
    public function IsRunning()
    {
        foreach ($this->document_converters as $document_converter) {
            if ($document_converter->IsRunning()) {
                return true;
            }
        }
        return false;
    }
}