<?php
namespace Claromentis\Search\Indexing;

$GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"] = (@$GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"] ?: array()) + array("_8119bf4c74815128729930a03cc378" . "e5" => base64_decode("U0VMRUNUIGNvdW50KDEpIEZST00gaW5kZX" . "hpbmdfcXVldWUgV0hFUkUgdGltZV9hZGRl" . "ZDw9aW50Om5vdw=="), "_455bf9e238d08c5ce96c1988163" . "b7da1" => base64_decode("UmVnaXN0ZXJlZCBzaHV0ZG93biBo" . "YW5kbGVy"), "_677bc33cfc057a689acf" . "596b15f0ae8f" => base64_decode("Y29yZS" . "5pbnRy" . "YW5ldF" . "9wYXRo"), "indexin" . "g" => base64_decode("aW5kZXhpb" . "mc="), "_0c519e721cc3079fbb25" . "2fbd60fd7904" => base64_decode("dGlt" . "ZQ=="), "_db7b295629faa16027a2c2630" . "95eba70" => base64_decode("cGhwX3Nh" . "cGlfbmFt" . "ZQ=="), "_8fec21706bd243b37" . "ecf62b1caf8fb8a" => base64_decode("Y2x" . "p"), "_1195cc6964b192" . "f19b1c5846d4232" . "f60" => base64_decode("QWRkZWQgaW5kZXhpbmcgaW5zdHJ" . "1Y3Rpb24="), "_d425741cb11ff8823e0edc2cbe72e5e" . "f" => base64_decode("U0VMRUNUICogRlJPTSBpbmRleGluZ19xd" . "WV1ZSBXSEVSRSB0aW1lX2FkZGVkPD1pbn" . "Q6bm93IE9SREVSIEJZIHRpbWVfYWRkZWQ" . "="), "_f9c8f878e1ea6" . "6539588e0db49a" . "ed972" => base64_decode("L21ha" . "W4v"), "_7433ce8aa2237722f2a6d7754f" . "ebc8de" => base64_decode("dGlt" . "ZV9s" . "aW1p" . "dA=="), "_a70aa49d6bc0c29a2998cd558a56c" . "fe0" => base64_decode("U0VMRUNUIGNvdW50KDEpIEZST00gaW5kZXhpbmdfcXVldWUgV0hFUkUgb2JqZWN0X3R5cGU9c3RyOnR5cGUgQU5EIHRp" . "bWVfYWRkZWQ8PWludDpub3c="), "_796782b0c8c" . "a9c81404f41e" . "b2edaa13e" => base64_decode("cmVnaXN0ZXJfc2h1dGRvd25fZnVu" . "Y3Rpb24="), "_dcf86ccc31af7f63af361" . "15aa12b1ee7" => base64_decode("Y2hka" . "XI="));
use Claromentis\Common\ApplicationMiscellany\Finisher;
use Claromentis\Core\DAL;
use Claromentis\Core\Event\EventDispatcher;
use Claromentis\Core\Services;









class IndexingQueue
{
    
    
    
    
    
    
    protected static $handler_registered = false;
    public static function Index($_9af3bede112581634a69e04b194cfa21, $object_id, $_f19d55a3cc79997bcb33f250cc2ee482 = 0, $_4a033bdf0ce701c6255d5238633ab2d0 = null)
    {
        self::AddInstruction(new IndexingInstruction($_9af3bede112581634a69e04b194cfa21, $object_id, $_f19d55a3cc79997bcb33f250cc2ee482, IndexingInstruction::INDEX, $_4a033bdf0ce701c6255d5238633ab2d0));
    }
    public static function Reindex($_9af3bede112581634a69e04b194cfa21, $object_id, $_f19d55a3cc79997bcb33f250cc2ee482 = 0, $_4a033bdf0ce701c6255d5238633ab2d0 = null)
    {
        self::AddInstruction(new IndexingInstruction($_9af3bede112581634a69e04b194cfa21, $object_id, $_f19d55a3cc79997bcb33f250cc2ee482, IndexingInstruction::REINDEX, $_4a033bdf0ce701c6255d5238633ab2d0));
    }
    public static function DeleteIndex($_9af3bede112581634a69e04b194cfa21, $object_id, $_f19d55a3cc79997bcb33f250cc2ee482 = 0, $_4a033bdf0ce701c6255d5238633ab2d0 = null)
    {
        self::AddInstruction(new IndexingInstruction($_9af3bede112581634a69e04b194cfa21, $object_id, $_f19d55a3cc79997bcb33f250cc2ee482, IndexingInstruction::DELETE, $_4a033bdf0ce701c6255d5238633ab2d0));
    }
    
    
    
    
    
    
    public static function AddInstruction(IndexingInstruction $_8c5f17e2e918145535955f8a633b6c7b)
    {
        $db = Services::I()->GetDb();
        $db->DisableTokenCheck();
        $_8c5f17e2e918145535955f8a633b6c7b->SaveNew();
        $logger = Services::I()->GetLogger($GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["index" . "ing"]);
        $logger->notice($GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_1195cc6964b192f19" . "b1c5846d4232f60"], array($_8c5f17e2e918145535955f8a633b6c7b));
        $db->EnableTokenCheck();
        if (!self::$handler_registered && $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_db7b295629fa" . "a16027a2c2630" . "95eba70"]() !== $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_8fec21706bd243b37ecf62b" . "1caf8fb8a"]) {
            self::RegisterHandler();
            $logger->notice($GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_455bf9e238d08c5c" . "e96c1988163b7da1"]);
            self::$handler_registered = true;
        }
    }
    public static function GetLength()
    {
        $db = Services::I()->GetDb();
        list($_3ce61d3a8a385e00d1583b95ce3eacb0) = $db->query_row($GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_8119bf4c748" . "15128729930a" . "03cc378e5"], $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_0c519e721cc3079" . "fbb252fbd60fd790" . "4"]());
        return (int) $_3ce61d3a8a385e00d1583b95ce3eacb0;
    }
    public static function GetLengthForType(string $_942796048cf5446754af6e1ef675295a)
    {
        $db = Services::I()->GetDb();
        list($_3ce61d3a8a385e00d1583b95ce3eacb0) = $db->query_row($GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_a70aa49" . "d6bc0c29" . "a2998cd5" . "58a56cfe" . "0"], $_942796048cf5446754af6e1ef675295a, $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_0c519e721cc3079fbb252fbd6" . "0fd7904"]());
        return (int) $_3ce61d3a8a385e00d1583b95ce3eacb0;
    }
    
    
    
    
    
    
    
    public static function GetFirst($_07ccde2e1abe46a6e90b9fa1767bb33a = true)
    {
        $db = Services::I()->GetDb();
        return $db->DoTransaction(function ($db) use($_07ccde2e1abe46a6e90b9fa1767bb33a) {
            $_d88b50ddb42db648a9c7ac08065b9409 = new DAL\Query($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_d425741cb" . "11ff8823e0" . "edc2cbe72e" . "5ef"], $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_0c519e72" . "1cc3079fb" . "b252fbd60" . "fd7904"]());
            $_d88b50ddb42db648a9c7ac08065b9409->setLimit(1);
            $_189840d11056515e52402d1412a0b6e4 = $db->query($_d88b50ddb42db648a9c7ac08065b9409);
            if (!$_189840d11056515e52402d1412a0b6e4->hasData()) {
                return null;
            }
            $data = $_189840d11056515e52402d1412a0b6e4->fetchArray();
            $_8c5f17e2e918145535955f8a633b6c7b = IndexingInstruction::CreateFromArray($data);
            if ($_07ccde2e1abe46a6e90b9fa1767bb33a) {
                $db->DisableTokenCheck();
                $_8c5f17e2e918145535955f8a633b6c7b->Delete();
                $db->EnableTokenCheck();
            }
            return $_8c5f17e2e918145535955f8a633b6c7b;
        });
    }
    protected static function RegisterHandler()
    {
        $GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_796782b0c8ca9c814" . "04f41eb2edaa13e"](function () {
            Finisher::FinishRequest();
            global $g_application;
            $GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_dcf86cc" . "c31af7f6" . "3af36115" . "aa12b1ee" . "7"]($g_application[$GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_677bc33cfc057a689acf596b15f0ae8" . "f"]] . $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_f9c8f878" . "e1ea66539" . "588e0db49" . "aed972"]);
            $_b6535dc63d208e74b51638ccc365cbd1 = Runner::CreateDefault();
            $_b6535dc63d208e74b51638ccc365cbd1->RunLoop(array($GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_7433ce8aa2237722f2a6d7754feb" . "c8de"] => 0.5));
            
            
        });
    }
}