public function dispatchAssets(): ?ResponseInterface
    {
        $asset = $_GET['_tracy_bar'] ?? null;
        if ($asset === 'js') {
            \ob_start();
            $this->renderAssets();
            $body = \ob_get_clean();

            return Factory::response(200, $body, [
                'Content-Type' => 'application/javascript',
                'Cache-Control' => 'max-age=864000',
            ]);
        }

        $this->useSession = \session_status() === PHP_SESSION_ACTIVE;

        $headers = [];
        if ($this->useSession && Helpers::isAjax()) {
            $headers['X-Tracy-Ajax'] = '1'; // session must be already locked
        }

        if ($this->useSession && $asset && \preg_match('#^content(-ajax)?\.(\w+)$#', $asset, $m)) {
            $session = &$_SESSION['_tracy']['bar'][$m[2] . $m[1]];
            $headers['Content-Type'] = 'application/javascript';
            $headers['Cache-Control'] = 'max-age=60';

            \ob_start();
            if (!$m[1]) {
                $this->renderAssets();
            }

            if ($session) {
                $method = $m[1] ? 'loadAjax' : 'init';
                echo "Tracy.Debug.$method(", \json_encode($session['content']), ', ', \json_encode($session['dumps']), ');';
                $session = null;
            }

            $session = &$_SESSION['_tracy']['bluescreen'][$m[2]];
            if ($session) {
                echo 'Tracy.BlueScreen.loadAjax(', \json_encode($session['content']), ', ', \json_encode($session['dumps']), ');';
                $session = null;
            }

            $body = \ob_get_clean();

            return Factory::response(200, $body, $headers);
        }

        return null;
    }