<?php
namespace Claromentis\Core\Ai\Adapters\Vertex\Responses\Image;

$GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"] = (@$GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"] ?: array()) + array("_e4fcbbd" . "cee4b953" . "ccb6192d" . "d1cbb267" . "1" => base64_decode("cmFpRmlsdGVyZWRSZW" . "Fzb24="), "_c36d11ec61d549064ca5997745729b1" . "c" => base64_decode("cHJlZGljdGlvbn" . "M="), "_e15567441c24cf597f085689c72" . "2c660" => base64_decode("bWltZVR5cG" . "U="), "_31767d7ad58e706dbf47" . "b7a51a0fe6c4" => base64_decode("Y291bnQ" . "="), "_f3cd33ffc" . "40bfb37206" . "b0dcff170c" . "c96" => base64_decode("RXJyb3IgaGFuZGxp" . "bmcgaW1hZ2UgZ2Vu" . "ZXJhdGlvbiByZXNw" . "b25zZTog"), "_ea8229a1212" . "85ee649a72fd" . "880bac39b" => base64_decode("YXJyYXl" . "fZmlsdG" . "Vy"), "_8b39dd03274720b4ed9a06cd" . "930f29cc" => base64_decode("Ynl0ZXNCYXNlNjRF" . "bmNvZGVk"), "_9338add06f" . "ebdd668e802" . "34d1c857b0c" => base64_decode("SW52YWxpZCBpb" . "WFnZSByZWNlaX" . "ZlZCBmcm9tIEF" . "JIHNlcnZpY2U="), "_72849b91ed" . "a4dfd944fd8" . "067caf54eb2" => base64_decode("Tm8gaW1hZ2VzIHJlY2VpdmVkIG" . "Zyb20gQUkgc2VydmljZQ=="));
use Claromentis\Core\Ai\Adapters\Vertex\Requests\Image\VertexAiImageGenerationConfig;
use Claromentis\Core\Ai\AiResponseInterface;
use Claromentis\Core\Ai\Exceptions\AiContentFilterException;
use Claromentis\Core\Ai\Exceptions\AiInvalidResponseException;
use Claromentis\Core\Ai\Parts\FilePart;
use Claromentis\Core\Ai\Parts\PartInterface;
use Webmozart\Assert\Assert;






class VertexAiGenerateImageResponse implements AiResponseInterface
{
    
    
    
    
    
    
    private array $parts;
    
    
    
    
    public function __construct(array $_9961f986823b4be7f5c4cc8379c6b228)
    {
        Assert::allIsInstanceOf($_9961f986823b4be7f5c4cc8379c6b228, FilePart::class);
        foreach ($_9961f986823b4be7f5c4cc8379c6b228 as $_d962cfd1735adb2dfba46f69c7f15cb8) {
            if (!$_d962cfd1735adb2dfba46f69c7f15cb8->isImage()) {
                throw new AiInvalidResponseException($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_9338add06febdd668e80234d1c" . "857b0c"]);
            }
        }
        $this->parts = $_9961f986823b4be7f5c4cc8379c6b228;
    }
    
    
    
    
    
    
    
    
    
    
    public static function fromArray(array $_fd62bc4eaaf7d58dea9bada3e30443b9) : self
    {
        
        
        
        if (empty($_fd62bc4eaaf7d58dea9bada3e30443b9) || empty($_fd62bc4eaaf7d58dea9bada3e30443b9[$GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_c36d11ec" . "61d549064" . "ca5997745" . "729b1c"]])) {
            throw new AiInvalidResponseException($GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_72849b91eda4d" . "fd944fd8067caf" . "54eb2"]);
        }
        $_c36d11ec61d549064ca5997745729b1c = $_fd62bc4eaaf7d58dea9bada3e30443b9[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_c36d11ec61d549064ca5997745729b" . "1c"]];
        $_6d727fd055d857128f471e61917a3e94 = $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_31767d7ad58e70" . "6dbf47b7a51a0fe" . "6c4"]($GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_ea8229a121285ee649a72fd8" . "80bac39b"]($_c36d11ec61d549064ca5997745729b1c, function ($p) {
            return isset($p[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_e4fcbbdce" . "e4b953ccb6" . "192dd1cbb2" . "671"]]);
        }));
        if ($_6d727fd055d857128f471e61917a3e94 === $GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_31767d7ad58e70" . "6dbf47b7a51a0fe" . "6c4"]($_c36d11ec61d549064ca5997745729b1c)) {
            throw new AiContentFilterException();
        }
        $_9961f986823b4be7f5c4cc8379c6b228 = [];
        foreach ($_c36d11ec61d549064ca5997745729b1c as $_c60329b6b53016ba8929aff2f19abcc6) {
            if (empty($_c60329b6b53016ba8929aff2f19abcc6[$GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_8b39dd03274720b4ed9a06cd93" . "0f29cc"]]) || isset($_c60329b6b53016ba8929aff2f19abcc6[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_e4fcbbdcee4b953ccb61" . "92dd1cbb2671"]])) {
                
                
                continue;
            }
            try {
                $_31958d0b40348d4ca7900c41684e4adc = new FilePart($_c60329b6b53016ba8929aff2f19abcc6[$GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_8b39dd03274720b4ed9a06cd9" . "30f29cc"]], $_c60329b6b53016ba8929aff2f19abcc6[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_e15567441c24cf597f085689c722" . "c660"]] ?? VertexAiImageGenerationConfig::DEFAULT_MIME_TYPE, PartInterface::PART_ROLE_MODEL);
            } catch (\Throwable $_3a16c5fe1a78b54b69e204ec07dcf670) {
                throw new AiInvalidResponseException($GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_f3cd33ff" . "c40bfb372" . "06b0dcff1" . "70cc96"] . $_3a16c5fe1a78b54b69e204ec07dcf670->getMessage(), $_3a16c5fe1a78b54b69e204ec07dcf670->getCode(), $_3a16c5fe1a78b54b69e204ec07dcf670);
            }
            $_9961f986823b4be7f5c4cc8379c6b228[] = $_31958d0b40348d4ca7900c41684e4adc;
        }
        return new self($_9961f986823b4be7f5c4cc8379c6b228);
    }
    public function hasTerminated() : bool
    {
        return false;
    }
    public function getParts() : array
    {
        return $this->parts;
    }
    
    
    
    
    
    
    public function getGeneratedImages() : array
    {
        return $this->parts;
    }
}