<?php
namespace Claromentis\Core\Widget;

$GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"] = (@$GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"] ?: array()) + array("_81a63d58717daa2360187cde20" . "12676c" => base64_decode("b25Qcm" . "VSZW5k" . "ZXI="), "_185e8f6cf311bab4c7f2" . "caa19d756e87" => base64_decode("aW5" . "0cm" . "FuZ" . "XQ="), "_a24c9587" . "a26d1e050" . "4604fa0ce" . "491c2c" => base64_decode("Y3VycmVudF9hZG1pbl9wY" . "W5lbA=="), "_87daa84e346f642" . "0a3f3426e05d16a7" . "b" => base64_decode("Lw" . "=="), "_05115cfa48" . "499314e2f56" . "0897214e356" => base64_decode("Y3VycmVudF9hcHBsaWNhdGlvbg=" . "="), "_cf1147f375327c8e8e02acd08" . "5df1aa6" => base64_decode("b25Ud2lnUHJlUmV" . "uZGVy"), "_dd6e57b90ccb4d0af3e836cf6f7f" . "e4c9" => base64_decode("YXBwX2dvX3RvX2FkbWlua" . "XN0cmF0aW9uX25hbWUuYX" . "BwX25hbWU="), "_f7d939bf6" . "73c147304c" . "82e8e46f1c" . "3c4" => base64_decode("YWRtaW5fcmV0dXJuX3RvX2FwcGxpY2F0aW9uX25hbWUuYXBwX25hbW" . "U="), "_1bee3d4d1d0df49e0f" . "cf8b9ed2ecb8fa" => base64_decode("ZXhwbG9" . "kZQ=="));
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["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_81a63d58717daa2360187cde20126" . "76c"], TwigEvents::PRE_RENDER => $GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_cf1147f" . "375327c8" . "e8e02acd" . "085df1aa" . "6"]];
    }
    public function onPreRender(TemplaterPreRenderEvent $event)
    {
        $args = $event->GetArgs();
        $args[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_f7d939bf673c14" . "7304c82e8e46f1c" . "3c4"]] = $this->current_panel->Get();
        $args[$GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_dd6e57b90ccb4d" . "0af3e836cf6f7fe" . "4c9"]] = $this->getApplicationName($this->app->request);
        $event->SetArgs($args);
    }
    public function onTwigPreRender(TwigPreRenderEvent $event)
    {
        $event->addArguments([$GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_a24c9587a26d1e0504604fa0ce4" . "91c2c"] => $this->current_panel->Get(), $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_05115cfa48" . "499314e2f56" . "0897214e356"] => $this->getApplicationName($this->app->request)]);
    }
    
    
    
    
    
    
    
    private function getApplicationName(Request $request)
    {
        $path = $request->getUri()->getPath();
        $_57b751eff299d8e776ac71a0f76781cd = $GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_1bee3d4d" . "1d0df49e0" . "fcf8b9ed2" . "ecb8fa"]($GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_87daa84e346f6420a3f3426e0" . "5d16a7b"], $path);
        $_8e8b612ee6d95dd763c14b4c52a5063e = $_57b751eff299d8e776ac71a0f76781cd[1] ?? null;
        if ($_8e8b612ee6d95dd763c14b4c52a5063e === $GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_185e8f6cf311bab4c7f2caa19d756e" . "87"]) {
            $_8e8b612ee6d95dd763c14b4c52a5063e = $_57b751eff299d8e776ac71a0f76781cd[2] ?? null;
        }
        return $_8e8b612ee6d95dd763c14b4c52a5063e;
    }
}