<?php
namespace Claromentis\Search\TopSearch\DataSource;

$GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"] ?: array()) + array("_e0211f088b6e9e119a314" . "53e966a26ee" => base64_decode("c2VhcmNoLmFkbWluLnRvcF9zZWFyY2guc2VhcmNoX3Rlcm" . "0="), "k" . "e" . "y" => base64_decode("a" . "2" . "V" . "5"), "_076f3e98f928db837454d4" . "7aec322bdd" => base64_decode("YnVja2V0cw" . "=="), "_f889ecdf0e64e91a6d612fe68" . "8d8e035" => base64_decode("c2VhcmNoLmFkbWluLnRvcF9zZWFyY2gub" . "m8="), "_57a0fc29322c7f596b9913d199e" . "913a4" => base64_decode("dW5pcXVlX2tleX" . "dvcmRz"), "_f0e5d0f9c49f660a9" . "23d84a8ea543cc6" => base64_decode("ZG9j" . "X2Nv" . "dW50"), "v" . "a" . "l" . "u" . "e" => base64_decode("dmFsdWU" . "="), "t" . "o" => base64_decode("dG" . "8="), "_da39f80aa510d1e712470ee6" . "68da1f3b" => base64_decode("c2VhcmNoLmFkbWluLnRvcF9zZWFyY" . "2guY291bnQ="), "_4d8a37305a" . "4dbe7fb6fea" . "6f7c3021fdd" => base64_decode("c3RydG90aW" . "1l"), "_f53d35a1a1e233d98d9" . "ce73d92ab3bb1" => base64_decode("Y291bnQ" . "="), "ke" . "yw" . "or" . "ds" => base64_decode("a2V5d" . "29yZH" . "M="), "_ccc4f42c270d41" . "4d9dfd976f30477" . "ae0" => base64_decode("b" . "m" . "8" . "="), "f" . "r" . "o" . "m" => base64_decode("ZnJ" . "vbQ" . "=="), "_5d27acd607f3485334f07edd9f" . "cad392" => base64_decode("KzEgZGF" . "5"));
use Claromentis\Core\Admin\AdminPanel;
use Claromentis\Core\DataTable;
use Claromentis\Core\DataTable\Column;
use Claromentis\Core\DataTable\Contract\DataSource;
use Claromentis\Core\DataTable\Contract\Parameters;
use Claromentis\Core\Localization\Lmsg;
use Claromentis\Core\Security\SecurityContext;
use Claromentis\Search\Client\ElasticsearchClient;
use Claromentis\Search\History\HistoryAggregation;
use Claromentis\Search\History\HistoryParameters;
class TopSearchDataSource implements DataSource
{
    
    
    
    
    use DataTable\Shared\ColumnHelper;
    protected AdminPanel $admin_panel;
    protected Lmsg $lmsg;
    protected ElasticsearchClient $searcher;
    protected int $total_tokens = 0;
    public function __construct(AdminPanel $_34142f0805685e788bb54a01fb3e222c, Lmsg $lmsg, ElasticsearchClient $searcher)
    {
        $this->admin_panel = $_34142f0805685e788bb54a01fb3e222c;
        $this->lmsg = $lmsg;
        $this->searcher = $searcher;
    }
    
    
    
    
    
    
    
    
    
    public function Columns(SecurityContext $context, DataTable\Contract\Parameters $params = null) : array
    {
        $_a42c86642011ef739b88ee80672c387d = [[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_ccc4f42c2" . "70d414d9df" . "d976f30477" . "ae0"], ($this->lmsg)($GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_f889ecd" . "f0e64e91" . "a6d612fe" . "688d8e03" . "5"]), null, false], [$GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["keywo" . "rds"], ($this->lmsg)($GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_e0211f088b6e9e119a31453e9" . "66a26ee"]), null, false], [$GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_f53d35a1a1e" . "233d98d9ce73" . "d92ab3bb1"], ($this->lmsg)($GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_da39f80aa510d" . "1e712470ee668d" . "a1f3b"]), null, false]];
        return $this->CreateWithColumns($_a42c86642011ef739b88ee80672c387d);
    }
    
    
    
    
    
    
    
    
    
    
    public function Data(SecurityContext $context, DataTable\Contract\Parameters $params, DataTable\Contract\TableFilter $filter) : array
    {
        if (!$this->admin_panel->IsAccessible($context)) {
            return [];
        }
        $_a3f52992e28454dec4052b8870d2db43 = new HistoryParameters();
        $_a3f52992e28454dec4052b8870d2db43->SetPagesize($params->GetLimit());
        $_a3f52992e28454dec4052b8870d2db43->SetStart($params->GetOffset());
        $_a3f52992e28454dec4052b8870d2db43->SetKeywords($params->GetKeywords());
        $_e60e1a002ae182bc589ef514ef645c10 = [];
        if (isset($params->GetFilters()[0]) && $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_4d8a37305a4dbe7fb6fea6" . "f7c3021fdd"]($params->GetFilters()[0])) {
            $_e60e1a002ae182bc589ef514ef645c10[$GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["fro" . "m"]] = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_4d8a37305a4dbe7fb6fea6f7c3021f" . "dd"]($params->GetFilters()[0]);
        }
        if (isset($params->GetFilters()[1]) && $GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_4d8a37305a4dbe7fb6" . "fea6f7c3021fdd"]($params->GetFilters()[1])) {
            $_e60e1a002ae182bc589ef514ef645c10[$GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["t" . "o"]] = $GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_4d8a37305a4dbe7" . "fb6fea6f7c3021fd" . "d"]($GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_5d27acd607f3" . "485334f07edd9" . "fcad392"], $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_4d8a3730" . "5a4dbe7fb" . "6fea6f7c3" . "021fdd"]($params->GetFilters()[1]));
        }
        $_a3f52992e28454dec4052b8870d2db43->SetCreated($_e60e1a002ae182bc589ef514ef645c10);
        $_a3f52992e28454dec4052b8870d2db43->SetIncludeAggregationCount(true);
        $_e4764ab6a1df120b5283082131b9ed66 = new HistoryAggregation($_a3f52992e28454dec4052b8870d2db43);
        $data = $this->searcher->Search($_e4764ab6a1df120b5283082131b9ed66);
        $_a0006f2e6058ce959e86bebdcded2da8 = [];
        $_d96b572510a4b2ffefb08e7fd4c0786a = $data->GetAggregations();
        foreach ($_d96b572510a4b2ffefb08e7fd4c0786a[$GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["key" . "wor" . "ds"]][$GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_076f3e98f928db837454d47aec3" . "22bdd"]] as $key => $_ea50e3facb857230426d6d1b5d653971) {
            $_a0006f2e6058ce959e86bebdcded2da8[] = [$GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_ccc4f42c270d414d9dfd97" . "6f30477ae0"] => $params->GetOffset() + $key + 1, $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["ke" . "yw" . "or" . "ds"] => $_ea50e3facb857230426d6d1b5d653971[$GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["ke" . "y"]], $GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_f53d35a1a1e233d" . "98d9ce73d92ab3bb" . "1"] => $_ea50e3facb857230426d6d1b5d653971[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_f0e5d0f9c49f660a923d84a8ea543" . "cc6"]]];
        }
        $this->total_tokens = $_d96b572510a4b2ffefb08e7fd4c0786a[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_57a0fc29322c7f59" . "6b9913d199e913a4"]][$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["valu" . "e"]];
        return $_a0006f2e6058ce959e86bebdcded2da8;
    }
    
    
    
    
    
    
    
    
    
    
    public function Count(SecurityContext $context, DataTable\Contract\Parameters $params, DataTable\Contract\TableFilter $_e0bd284b1527841bc9c635873b56303b) : int
    {
        if (!$this->admin_panel->IsAccessible($context)) {
            return 0;
        }
        return $this->total_tokens;
    }
    
    
    
    
    
    
    public function Filters() : array
    {
        
        
        return [];
    }
}