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

$GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"] ?: array()) + array("_653be373" . "90c48a200" . "701e4322c" . "116779" => base64_decode("c3RyX" . "3N0YX" . "J0c19" . "3aXRo"), "_bd71c3b5c201" . "fc11db82ed14c" . "e424de5" => base64_decode("aW5" . "fYX" . "JyY" . "Xk="), "_cc3d6d1784d664e35a1a82275" . "c45b630" => base64_decode("IiBwcm92aWRlZCBmb3IgaW1hZ2UgcGFydC4g" . "QWNjZXB0ZWQgTUlNRSB0eXBlcyBhcmU6IA=="), "_75b243bff4b4067f5adeaf3dfa11" . "c126" => base64_decode("aW1hZ" . "2Uv"), "_01f117db67aa749d3" . "ec8da7eb478730c" => base64_decode("LC" . "A="), "_5159b3572969eca46acd1" . "b2e1418459c" => base64_decode("aW1" . "wbG" . "9kZ" . "Q=="), "_811cca7a13b3032607a4cbec695e" . "902d" => base64_decode("SW52YWxpZCBNSU1FIHR5cGUgIg=" . "="));
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["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_bd71c3b5c" . "201fc11db8" . "2ed14ce424" . "de5"]($_e15567441c24cf597f085689c722c660, $this->getValidMimeTypes())) {
            throw new InvalidArgumentException($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_811cca7" . "a13b3032" . "607a4cbe" . "c695e902" . "d"] . $_e15567441c24cf597f085689c722c660 . $GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_cc3d6d1784d664e35a1a82" . "275c45b630"] . $GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_5159b3572969eca46acd1b2e141" . "8459c"]($GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_01f117db67aa749d3ec8da7e" . "b478730c"], 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["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_653be37390c" . "48a200701e43" . "22c116779"]($this->mimeType, $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_75b243bff4b4" . "067f5adeaf3df" . "a11c126"]);
    }
    
    
    
    
    
    
    
    
    
    private function getValidMimeTypes() : array
    {
        return self::MIME_TYPES;
    }
    
    
    
    
    
    
    protected abstract function validateImage();
}