<?php
namespace Claromentis\Core\Ai\Parts;

$GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"] ?: array()) + array("_cc3d6d1784d664e35a1a82275c4" . "5b630" => base64_decode("IiBwcm92aWRlZCBmb3IgaW1hZ2UgcGFydC4gQWNjZXB0ZWQgTUlNRSB0eXBlcyBhcmU" . "6IA=="), "_5159b3572969eca46acd1b2" . "e1418459c" => base64_decode("aW1wbG9" . "kZQ=="), "_811cca7a13b3032607a4cbe" . "c695e902d" => base64_decode("SW52YWxpZCBNSU1" . "FIHR5cGUgIg=="), "_653be37390c48a200701e4" . "322c116779" => base64_decode("c3RyX3N0YXJ0c193aXR" . "o"), "_75b243bff4b4067f5adeaf3dfa11c12" . "6" => base64_decode("aW" . "1h" . "Z2" . "Uv"), "_01f117db6" . "7aa749d3ec" . "8da7eb4787" . "30c" => base64_decode("L" . "C" . "A" . "="), "_bd71c3b5c201f" . "c11db82ed14ce4" . "24de5" => base64_decode("aW5fYXJyYXk" . "="));
use Claromentis\Core\Ai\Exceptions\InvalidImageException;
use InvalidArgumentException;






abstract class AbstractFilePart implements PartInterface
{
    
    
    
    
    protected const MIME_TYPES = ['png' => 'image/png', 'jpg' => 'image/jpeg', 'webp' => 'image/webp', 'pdf' => 'application/pdf', 'html' => 'text/html'];
    
    
    
    
    protected string $data;
    
    
    
    
    
    
    
    protected string $role;
    
    
    
    
    
    
    protected string $mimeType;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    public function __construct(string $data, string $_e15567441c24cf597f085689c722c660 = self::MIME_TYPES['png'], string $_d1071a032215f0eb5c4a8ef175f7049d = PartInterface::PART_ROLE_USER)
    {
        if (!$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_bd71c3b5c" . "201fc11db8" . "2ed14ce424" . "de5"]($_e15567441c24cf597f085689c722c660, $this->getValidMimeTypes())) {
            throw new InvalidArgumentException($GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_811cca7a13b303260" . "7a4cbec695e902d"] . $_e15567441c24cf597f085689c722c660 . $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_cc3d6d1784d664e35a1a8227" . "5c45b630"] . $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_5159b3572969e" . "ca46acd1b2e141" . "8459c"]($GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_01f117db67aa749d3" . "ec8da7eb478730c"], self::MIME_TYPES));
        }
        $this->mimeType = $_e15567441c24cf597f085689c722c660;
        $this->data = $data;
        $this->role = $_d1071a032215f0eb5c4a8ef175f7049d;
        if ($this->isImage()) {
            $this->validateImage();
        }
    }
    
    
    
    
    
    
    public function getMimeType() : string
    {
        return $this->mimeType;
    }
    
    
    
    
    
    
    public function getValue() : string
    {
        return $this->data;
    }
    public function getRole() : string
    {
        return $this->role;
    }
    
    
    
    
    
    
    
    
    
    
    public function isImage()
    {
        return $GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_653be37390c48a200701e" . "4322c116779"]($this->mimeType, $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_75b243bff4b4067f5adeaf3dfa1" . "1c126"]);
    }
    
    
    
    
    
    
    
    
    
    private function getValidMimeTypes() : array
    {
        return self::MIME_TYPES;
    }
    
    
    
    
    
    
    protected abstract function validateImage();
}