<?php
namespace Claromentis\Core\Filesystem;

$GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"] = (@$GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"] ?: array()) + array("_f73dab606630b3886" . "45c4f7d3fbb13bb" => base64_decode("YXJyYXlf" . "bWVyZ2U="), "d" . "a" . "t" . "a" => base64_decode("ZGF0YQ" . "=="), "_33eb931581b031fdb2a1937880fb" . "89cd" => base64_decode("Zmls" . "ZXN5" . "c3Rl" . "bQ=="), "_5d12fbd7bb86f9fced74c352" . "3d44298b" => base64_decode("Q0xBUk9fR" . "lNfUEFUSF" . "M="), "defa" . "ult" => base64_decode("ZGVmY" . "XVsdA" . "=="), "_e19bbeb93cd681dc17" . "d9990d870e9e7c" => base64_decode("Q0xBUk9fRlNfRU5BQk" . "xFRA=="), "_d9331700" . "a1bec8c38" . "4cdb20bff" . "eb3998" => base64_decode("TEFSR0VfV" . "EVNUF9ESV" . "I="), "_7843717" . "852c5000" . "97e3e7dc" . "5c6c6684" . "8" => base64_decode("Q0xBUk9fRlN" . "fTU9VTlRT"), "_8680a301ad0c7888a3e753dce7a1f5" . "d9" => base64_decode("Oi" . "8v"), "con" . "fig" => base64_decode("Y2" . "9u" . "Zm" . "ln"), "_aa0553266235d1e7c43a6e8" . "869464820" => base64_decode("REF" . "UQV" . "9ES" . "VI="));
use Claromentis\Core\Application;
use Claromentis\Core\Config\Config;
use Claromentis\Core\Config\WritableConfig;
use Claromentis\Core\Util\FilesystemUtil;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Silex\Api\BootableProviderInterface;




class FilesystemServiceProvider implements ServiceProviderInterface, BootableProviderInterface
{
    public function register(Container $app)
    {
        $app->extend($GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["conf" . "ig"], function (WritableConfig $config) {
            static::setDefaults($config);
            return $config;
        });
        $app[$GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_33eb931581b031fd" . "b2a1937880fb89cd"]] = FilesystemInterface::class;
        $app[FilesystemFactory::class] = function (Application $app) {
            $_d9331700a1bec8c384cdb20bffeb3998 = $app->config[$GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_d9331700a1bec8c3" . "84cdb20bffeb3998"]];
            
            
            $_3389854e2a89e45be309b4bc626ee1e0 = $app[FilesystemUtil::class];
            return new FilesystemFactory($app->config, $_3389854e2a89e45be309b4bc626ee1e0->getLocalPath($_d9331700a1bec8c384cdb20bffeb3998));
        };
        $app[FilesystemInterface::class] = function (Application $app) {
            
            
            $factory = $app[FilesystemFactory::class];
            $_5776026a088f72b6abc144f60bb8309e = $app->config->get($GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_7843717852c50" . "0097e3e7dc5c6c" . "66848"]);
            $_20e1864263bd4e305bf1b9fe343fa83b = [];
            
            
            foreach ($_5776026a088f72b6abc144f60bb8309e as $name => $options) {
                $_20e1864263bd4e305bf1b9fe343fa83b[$name] = $factory->CreateFromArray($options, $name);
            }
            
            
            $_e5ebded0460fbbae4c4109745014e9c2 = new MountManager($_20e1864263bd4e305bf1b9fe343fa83b);
            return new Filesystem($_e5ebded0460fbbae4c4109745014e9c2);
        };
        $app[StreamWrapperProvider::class] = function (Application $app) {
            return $app->create(StreamWrapperProvider::class);
        };
        
        
        
        static::registerStreamWrapper($app);
    }
    public function boot(\Silex\Application $app)
    {
        if (isset($app[FilesystemUtil::class])) {
            
            
            
            
            
            
            $_3389854e2a89e45be309b4bc626ee1e0 = $app[FilesystemUtil::class];
            $_3389854e2a89e45be309b4bc626ee1e0->setFilesystem($app[FilesystemInterface::class]);
        }
    }
    
    
    
    
    
    
    
    public static function setDefaults(WritableConfig $config)
    {
        
        
        $_5776026a088f72b6abc144f60bb8309e = $config->get($GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_7843717852c" . "500097e3e7dc" . "5c6c66848"]) ?? [];
        $_5f732a7aa66d170ea356ba72b5bd9204 = $config->get($GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_5d12fbd7bb86f9fce" . "d74c3523d44298b"]) ?? [];
        $config->set($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_7843717852c500097e3e" . "7dc5c6c66848"], $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_f73dab606630" . "b388645c4f7d3" . "fbb13bb"](FilesystemDefaults::GetDefaultMounts($config), $_5776026a088f72b6abc144f60bb8309e));
        $config->set($GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_5d12fbd7bb86f9fced74c3523d44298" . "b"], $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_f73dab606630b388645c4f7d3fbb" . "13bb"](FilesystemDefaults::PATHS, $_5f732a7aa66d170ea356ba72b5bd9204));
        
        
        
        if (static::streamWrapperEnabled($config)) {
            $_5f732a7aa66d170ea356ba72b5bd9204 = $config->get($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_5d12fbd7b" . "b86f9fced7" . "4c3523d442" . "98b"]);
            $_21f5dd11309da4af2e51660e6f110a91 = FilesystemDefaults::PROTOCOL;
            $data = FilesystemUtil::normalizePath($_21f5dd11309da4af2e51660e6f110a91 . $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_8680a30" . "1ad0c788" . "8a3e753d" . "ce7a1f5d" . "9"] . $_5f732a7aa66d170ea356ba72b5bd9204[$GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["defaul" . "t"]][$GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["dat" . "a"]]);
            
            
            
            
            $config->setMany([
                
                
                $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_aa0553266235" . "d1e7c43a6e886" . "9464820"] => $data,
            ]);
        }
    }
    
    
    
    
    
    
    public static function registerStreamWrapper(Container $app)
    {
        
        
        $config = $app[Config::class];
        if (static::streamWrapperEnabled($config)) {
            
            
            $_a12c8da0f19064827eae63fd854c04e5 = $app[StreamWrapperProvider::class];
            $_a12c8da0f19064827eae63fd854c04e5->provide($app);
        }
    }
    
    
    
    
    
    
    
    protected static function streamWrapperEnabled(Config $config) : bool
    {
        return $config->get($GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_e19bbeb93cd681dc17d9990d870" . "e9e7c"]) ?? false;
    }
}