<?php
namespace Claromentis\Core\Widget;

$GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"] = (@$GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"] ?: array()) + array("_87daa84e3" . "46f6420a3f" . "3426e05d16" . "a7b" => base64_decode("Lw" . "=="), "_185e8f6cf311bab4c7f2caa19d756" . "e87" => base64_decode("aW50cmFuZX" . "Q="), "_81a63d58717daa2360187cde" . "2012676c" => base64_decode("b25QcmVSZW5k" . "ZXI="), "_05115cfa4849931" . "4e2f560897214e35" . "6" => base64_decode("Y3VycmVudF9hcHBsaWNhd" . "Glvbg=="), "_f7d939bf673c147304c" . "82e8e46f1c3c4" => base64_decode("YWRtaW5fcmV0dXJuX3RvX2FwcGxpY2F0aW9uX25hbWUu" . "YXBwX25hbWU="), "_a24c9587a" . "26d1e05046" . "04fa0ce491" . "c2c" => base64_decode("Y3VycmVudF9hZG1pbl9w" . "YW5lbA=="), "_1bee3d4d1d0df49" . "e0fcf8b9ed2ecb8f" . "a" => base64_decode("ZXhwbG9k" . "ZQ=="), "_dd6e57b9" . "0ccb4d0af" . "3e836cf6f" . "7fe4c9" => base64_decode("YXBwX2dvX3RvX2Fkb" . "WluaXN0cmF0aW9uX2" . "5hbWUuYXBwX25hbWU" . "="), "_cf1147f375327c8" . "e8e02acd085df1aa" . "6" => base64_decode("b25Ud2lnUHJ" . "lUmVuZGVy"));
use Claromentis\Core\Admin\CurrentPanel;
use Claromentis\Core\Application;
use Claromentis\Core\Event\EventSubscriberInterface;
use Claromentis\Core\Templater\Events\TemplaterPreRenderEvent;
use Claromentis\Core\Templater\TemplaterEvents;
use Claromentis\Core\Twig\Events\TwigPreRenderEvent;
use Claromentis\Core\Twig\TwigEvents;
use Psr\Http\Message\ServerRequestInterface as Request;




class WidgetRenderSubscriber implements EventSubscriberInterface
{
    
    
    
    
    protected $app;
    
    
    
    
    protected $current_panel;
    public function __construct(Application $app, CurrentPanel $current_panel)
    {
        $this->app = $app;
        $this->current_panel = $current_panel;
    }
    
    
    
    
    public static function getSubscribedEvents()
    {
        return [TemplaterEvents::PRE_RENDER => $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_81a63d5871" . "7daa2360187" . "cde2012676c"], TwigEvents::PRE_RENDER => $GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_cf1147f375327c8e8e02acd0" . "85df1aa6"]];
    }
    public function onPreRender(TemplaterPreRenderEvent $event)
    {
        $args = $event->GetArgs();
        $args[$GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_f7d939bf673c14730" . "4c82e8e46f1c3c4"]] = $this->current_panel->Get();
        $args[$GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_dd6e57b90ccb4d0af3e836cf" . "6f7fe4c9"]] = $this->getApplicationName($this->app->request);
        $event->SetArgs($args);
    }
    public function onTwigPreRender(TwigPreRenderEvent $event)
    {
        $event->addArguments([$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_a24c9587a26d1e0504604" . "fa0ce491c2c"] => $this->current_panel->Get(), $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_05115cfa" . "48499314e" . "2f5608972" . "14e356"] => $this->getApplicationName($this->app->request)]);
    }
    
    
    
    
    
    
    
    private function getApplicationName(Request $request)
    {
        $path = $request->getUri()->getPath();
        $_57b751eff299d8e776ac71a0f76781cd = $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_1bee3d4d1d0df4" . "9e0fcf8b9ed2ecb" . "8fa"]($GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_87daa84" . "e346f642" . "0a3f3426" . "e05d16a7" . "b"], $path);
        $_8e8b612ee6d95dd763c14b4c52a5063e = $_57b751eff299d8e776ac71a0f76781cd[1] ?? null;
        if ($_8e8b612ee6d95dd763c14b4c52a5063e === $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_185e8f6cf311bab4c7f2caa19d756e8" . "7"]) {
            $_8e8b612ee6d95dd763c14b4c52a5063e = $_57b751eff299d8e776ac71a0f76781cd[2] ?? null;
        }
        return $_8e8b612ee6d95dd763c14b4c52a5063e;
    }
}