<?php
namespace Claromentis\Core\Filesystem;

$GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"] = (@$GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"] ?: array()) + array("_6e362c89bef3" . "f93b2e7dc8af2" . "d62c1ee" => base64_decode("c2lnb" . "mVkX3" . "VybF9" . "0dGw="), "_0c519e721cc3079fbb252fbd60f" . "d7904" => base64_decode("dGlt" . "ZQ=="), "_6edacb78bd55" . "c5015af27c8ac" . "1fcd9af" => base64_decode("bWV0aG" . "9kX2V4" . "aXN0cw" . "=="), "_62d701c3c53404f06345eb35720" . "a47b4" => base64_decode("aXNfbnVtZX" . "JpYw=="), "_cdaa1e2e0bc63bde" . "897526cad90a8f3e" => base64_decode("Y2ZnX2Nkbl9vcHRpb2" . "5z"), "_3d09d161" . "d7cb0894b" . "7132f1a3d" . "f9cd54" => base64_decode("Z2V0Q" . "WRhcH" . "Rlcg=" . "="), "_1cae05e5ab34cbf7e" . "e7f6e8d56083624" => base64_decode("Z2V0VX" . "Js"), "_2d4443be8" . "a52387964f" . "583e31c27b" . "f83" => base64_decode("c2lnbmVkX3" . "VybHM="));
use Claromentis\Core\CDN;
use Claromentis\Core\Config\Config;
use Claromentis\Core\Filesystem\Exception\FileNotFoundException;
use League\Flysystem\AdapterInterface;
use League\Flysystem\FilesystemInterface;
use League\Flysystem\PluginInterface;




class GetUrlPlugin implements PluginInterface
{
    
    
    
    
    protected $adapter;
    
    
    
    
    protected $filesystem;
    protected bool $use_signed_urls = false;
    protected int $signed_url_ttl = CDN\Constants::SIGNED_URL_DEFAULT_TTL;
    public function __construct(Config $config)
    {
        $options = $config->Get($GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_cdaa1e2e0" . "bc63bde897" . "526cad90a8" . "f3e"]);
        if (($options[$GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_2d4443be8a52" . "387964f583e31" . "c27bf83"]] ?? false) === true) {
            $this->use_signed_urls = true;
        }
        if (isset($options[$GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_6e362c89bef3f93b2e7dc8af2d62c" . "1ee"]]) && $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_62d701c3c53404f06345eb35720" . "a47b4"]($options[$GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_6e362c89bef3f93b2e7dc8af2d62c1e" . "e"]])) {
            $this->signed_url_ttl = (int) $options[$GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_6e362c89bef3f93b2e" . "7dc8af2d62c1ee"]];
        }
    }
    public function getMethod()
    {
        return $GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_1cae05e5ab" . "34cbf7ee7f6" . "e8d56083624"];
    }
    
    
    
    
    
    
    public function handle($path = null)
    {
        if (!$this->filesystem->has($path)) {
            return null;
        }
        if ($this->use_signed_urls) {
            return $this->adapter->getTemporaryUrl($path, $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_0c519e721cc3079f" . "bb252fbd60fd7904"]() + $this->signed_url_ttl * 60);
        } else {
            return $this->adapter->getUrl($path);
        }
    }
    
    
    
    
    
    
    public function setFilesystem(FilesystemInterface $_33eb931581b031fdb2a1937880fb89cd)
    {
        $this->filesystem = $_33eb931581b031fdb2a1937880fb89cd;
        while ($GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_6edacb78bd55c5015af27c8ac1" . "fcd9af"]($_33eb931581b031fdb2a1937880fb89cd, $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_3d09d161d7cb0894b7132f1a3df9cd5" . "4"])) {
            $_33eb931581b031fdb2a1937880fb89cd = $_33eb931581b031fdb2a1937880fb89cd->getAdapter();
        }
        $this->adapter = $_33eb931581b031fdb2a1937880fb89cd;
    }
}