public function folder(ServerRequestInterface $request, Tree $tree, Filesystem $filesystem): ResponseInterface
    {
        $query = $request->get('query', '');

        $prefix = $tree->getPreference('MEDIA_DIRECTORY', '');

        $media_filesystem = new Filesystem(new ChrootAdapter($filesystem, $prefix));

        $contents = new Collection($media_filesystem->listContents('', true));

        $folders = $contents
            ->filter(static function (array $object) use ($query): bool {
                return $object['type'] === 'dir' && Str::contains($object['path'], $query);
            })
            ->map(static function (array $object): array {
                return ['value' => $object['path']];
            });

        return response($folders);
    }