<?php
namespace Claromentis\Design\Style;

$GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"] = (@$GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"] ?: array()) + array("_075c6c4172eaf58cfa84828a3582d1" . "9a" => base64_decode("YXJyYX" . "lfdW5p" . "cXVl"), "_e9290c53fb0919bab827e3" . "ece4ee2ada" => base64_decode("ZGlybmFtZQ=" . "="), "_7f628626dd1d55c71" . "b1fc0932ffd1d2c" => base64_decode("aXNfYXJyYX" . "k="));
use Claromentis\Core\Services;
use Claromentis\Core\Util\FilesystemUtil;
use Claromentis\Design\Facade\AssetsStorage;
use Claromentis\Design\Model\StyleAsset;




class InheritableStyle implements StyleOptionsEditable
{
    protected $defaults;
    protected $data;
    
    
    
    
    private ?array $background_assets = null;
    
    
    
    
    private ?array $favicon_assets = null;
    private ?StyleAsset $logo_asset = null;
    public function __construct($data, StyleOptions $_7c7a0774c7447eed1a9b0b8aba163b8f)
    {
        $this->data = $data;
        $this->defaults = $_7c7a0774c7447eed1a9b0b8aba163b8f;
    }
    
    
    
    
    
    
    
    
    
    public function Get($option_name)
    {
        if (isset($this->data[$option_name])) {
            return $this->data[$option_name];
        }
        return $this->defaults->Get($option_name);
    }
    
    
    
    
    
    
    
    public function Set($option_name, $value)
    {
        if ($value === null) {
            unset($this->data[$option_name]);
        } else {
            $this->data[$option_name] = $value;
        }
    }
    public function SetAll(array $options)
    {
        $this->data = $options;
        $this->Cleanup();
    }
    public function HasOwn($option_name)
    {
        return isset($this->data[$option_name]);
    }
    protected function Cleanup()
    {
        if ($this->data === null) {
            return;
        }
        foreach ($this->data as $key => $value) {
            if ($value === null) {
                unset($this->data[$key]);
            }
        }
    }
    public function GetAllOwn()
    {
        
        
        return $this->data;
    }
    public function SaveAssets(AssetsStorage $storage)
    {
        
        
        $_3e9dd802f6570205386040c44f4fa34c = Services::I()->{FilesystemUtil::class};
        $_8f9dbd0745297f098d3d11185c959790 = [];
        if ($_1eea70b8049eb80fd8c497efaf8f0761 = $this->GetBackgroundAssets()) {
            foreach ($_1eea70b8049eb80fd8c497efaf8f0761 as $_9829f2dacbc7c277ce3d4200e60fa87d) {
                $_8f9dbd0745297f098d3d11185c959790[] = $GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_e9290c53fb0919bab827e3ece4ee2" . "ada"]($_9829f2dacbc7c277ce3d4200e60fa87d->GetTemporaryFilePath());
                $_9829f2dacbc7c277ce3d4200e60fa87d->SaveTo($storage);
            }
        }
        if ($_e52cebdf2fee07e5ae251f937629ced8 = $this->GetFaviconAssets()) {
            foreach ($_e52cebdf2fee07e5ae251f937629ced8 as $_9829f2dacbc7c277ce3d4200e60fa87d) {
                $_8f9dbd0745297f098d3d11185c959790[] = $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_e9290c5" . "3fb0919b" . "ab827e3e" . "ce4ee2ad" . "a"]($_9829f2dacbc7c277ce3d4200e60fa87d->GetTemporaryFilePath());
                $_9829f2dacbc7c277ce3d4200e60fa87d->SaveTo($storage);
            }
        }
        if ($_1272bfb58dee7f0fedddd1445ca563c7 = $this->GetLogoAsset()) {
            $_1272bfb58dee7f0fedddd1445ca563c7->SaveTo($storage);
            $_8f9dbd0745297f098d3d11185c959790[] = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_e9290c53fb0919bab827e3ece4e" . "e2ada"]($_1272bfb58dee7f0fedddd1445ca563c7->GetTemporaryFilePath());
        }
        
        
        $_8f9dbd0745297f098d3d11185c959790 = $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_075c6c4172eaf58c" . "fa84828a3582d19a"]($_8f9dbd0745297f098d3d11185c959790);
        foreach ($_8f9dbd0745297f098d3d11185c959790 as $_e4d48f6fbc845d252bc7e52a66bcb424) {
            $_3e9dd802f6570205386040c44f4fa34c->DeleteDir($_e4d48f6fbc845d252bc7e52a66bcb424);
        }
    }
    
    
    public function GetBackgrounds() : array
    {
        $_98b5bf442751a5222466711febc29fc7 = $this->Get(Option::PAGE_BG_IMAGE);
        if (!$GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_7f628626dd1d" . "55c71b1fc0932" . "ffd1d2c"]($_98b5bf442751a5222466711febc29fc7)) {
            $_98b5bf442751a5222466711febc29fc7 = [];
        }
        return $_98b5bf442751a5222466711febc29fc7;
    }
    
    
    
    
    public function GetLogo() : ?string
    {
        return $this->Get(Option::LOGO_URL);
    }
    
    
    
    
    public function IsLogoEnabled() : bool
    {
        return (bool) $this->Get(Option::LOGO_SHOW);
    }
    
    
    
    
    public function GetFavicons() : array
    {
        return $this->Get(Option::FAVICON);
    }
    
    
    
    
    public function GetBackgroundAssets() : ?array
    {
        return $this->background_assets;
    }
    
    
    
    
    public function GetFaviconAssets() : ?array
    {
        return $this->favicon_assets;
    }
    
    
    
    
    public function GetLogoAsset() : ?StyleAsset
    {
        return $this->logo_asset;
    }
    
    
    
    
    
    
    public function SetBackgrounds(array $_98b5bf442751a5222466711febc29fc7) : void
    {
        $this->Set(Option::PAGE_BG_IMAGE, $_98b5bf442751a5222466711febc29fc7);
    }
    
    
    
    
    public function SetLogo(?string $_2ab616fbc64767c41faa6bdb336b98db) : void
    {
        $this->Set(Option::LOGO_URL, $_2ab616fbc64767c41faa6bdb336b98db);
    }
    
    
    
    
    public function SetLogoHidden(bool $_91b6b94e8c0d8ad855cbdb53d686069b) : void
    {
        $this->Set(Option::LOGO_SHOW, !$_91b6b94e8c0d8ad855cbdb53d686069b);
    }
    
    
    
    
    public function SetFavicons(array $_82ddae69c475563934e7e1df41e98f82) : void
    {
        $this->Set(Option::FAVICON, $_82ddae69c475563934e7e1df41e98f82);
    }
    
    
    
    
    public function SetBackgroundAssets(?array $_b395d109970c43a908616c11d4eb6947) : void
    {
        $this->background_assets = $_b395d109970c43a908616c11d4eb6947;
    }
    
    
    
    
    public function SetFaviconAssets(?array $_b395d109970c43a908616c11d4eb6947) : void
    {
        $this->favicon_assets = $_b395d109970c43a908616c11d4eb6947;
    }
    
    
    
    
    public function SetLogoAsset(?StyleAsset $_a1862e99a03ebef7e301227576153906) : void
    {
        $this->logo_asset = $_a1862e99a03ebef7e301227576153906;
    }
    
    
}