<?php
namespace Claromentis\Search;

$GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"] ?: array()) + array("titl" . "e" => base64_decode("dG" . "l0" . "bG" . "U="), "_5306cb5e8985434a" . "2a638b90f897940d" => base64_decode("IGlzIG5vdCBjYWxsY" . "WJsZQ=="), "_6fd29f1ce82d5e2d09" . "a2d806c2e2b1d5" => base64_decode("aXNfY2FsbGFib" . "GU="), "_8f7dd777fd" . "eec4a63087b" . "ff8b5c757bf" => base64_decode("VW5zdXBwb3J0" . "ZWQgb2JqZWN0" . "IHR5cGUgLSA="), "_d706c160e45b" . "f7434fff82a59" . "76f0e19" => base64_decode("YXJyYX" . "lfa2V5" . "cw=="), "c" . "o" . "d" . "e" => base64_decode("Y29k" . "ZQ=="), "_f73dab606630b388645c4f7d3fbb" . "13bb" => base64_decode("YXJyYXlfbWV" . "yZ2U="), "_075c6c4172eaf58" . "cfa84828a3582d19" . "a" => base64_decode("YXJyYXlf" . "dW5pcXVl"), "_bd71c3b5c201" . "fc11db82ed14c" . "e424de5" => base64_decode("aW5fYXJyY" . "Xk="), "_c8d1809b" . "dc783b969" . "8165309fe" . "704327" => base64_decode("VGhlIHNlY29uZCBwYXJh" . "bWV0ZXIgb2Yg"));
use Claromentis\Search\Application\CacheableInterface;
use Claromentis\Search\Exception\UnsupportedItemTypeException;
use ErrorHandler;
use Exception;
use Claromentis\Search\Indexing\Exception\IndexingException;




class ItemTypeFactory extends ErrorHandler
{
    
    
    
    
    protected $search_item_types = [];
    
    
    
    
    protected $indexing_types = [];
    protected $item_types_application_code = [];
    
    
    
    
    protected $cacheable_item_types = [];
    
    
    
    
    
    
    public function __construct()
    {
        $_a56d3cb9419f5f513e6d57bbcaaf3397 = new Config\Applications();
        $_f3e72c5e54a6dd0fb5c5005cd9574e42 = $_a56d3cb9419f5f513e6d57bbcaaf3397->GetAll();
        foreach ($_f3e72c5e54a6dd0fb5c5005cd9574e42 as $_f44467aacb8a4520c7382769d24aa422) {
            $this->RegisterApplication($_f44467aacb8a4520c7382769d24aa422);
        }
        \ClaPlugins::I()->RegisterIndexingObjectType($this);
    }
    
    
    
    
    
    
    public function RegisterApplication(Application\ApplicationInterface $_f44467aacb8a4520c7382769d24aa422)
    {
        $_17728688d370dbb69c53d9e641c4b0e0 = $_f44467aacb8a4520c7382769d24aa422->GetTypes();
        foreach ($_17728688d370dbb69c53d9e641c4b0e0 as $type => $_ef7e3c851590d142b4d780e7b9043897) {
            $this->RegisterType($type, $_ef7e3c851590d142b4d780e7b9043897);
            $this->item_types_application_code[$type] = [$GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["titl" . "e"] => $_f44467aacb8a4520c7382769d24aa422->GetName(), $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["cod" . "e"] => $_f44467aacb8a4520c7382769d24aa422->GetCode()];
        }
        if ($_f44467aacb8a4520c7382769d24aa422 instanceof CacheableInterface) {
            $_a18bef7ab1ad0a4c0171b3201caa8064 = $_f44467aacb8a4520c7382769d24aa422->getCacheableTypes();
            foreach ($_a18bef7ab1ad0a4c0171b3201caa8064 as $type) {
                $this->RegisterCacheableType($type);
            }
        }
    }
    
    
    
    
    
    
    
    public function RegisterType($type, $_06e5839e14e1bc203f750e67ef402284)
    {
        if (!$GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_6fd29f1c" . "e82d5e2d0" . "9a2d806c2" . "e2b1d5"]($_06e5839e14e1bc203f750e67ef402284)) {
            throw new IndexingException($GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_c8d1809bdc783b969816" . "5309fe704327"] . __METHOD__ . $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_5306cb5e8985434a2a6" . "38b90f897940d"], 1);
        }
        $this->search_item_types[$type] = $_06e5839e14e1bc203f750e67ef402284;
    }
    
    
    
    
    
    
    public function RegisterCacheableType($type)
    {
        if (!$GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_bd71c3b5c2" . "01fc11db82e" . "d14ce424de5"]($type, $this->cacheable_item_types)) {
            $this->cacheable_item_types[] = $type;
        }
    }
    
    
    
    
    
    
    
    public function Get($type)
    {
        if (isset($this->search_item_types[$type])) {
            return $this->search_item_types[$type]();
        } else {
            $e = new UnsupportedItemTypeException($GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_8f7dd777fd" . "eec4a63087b" . "ff8b5c757bf"] . $type);
            $e->item_type = $type;
            throw $e;
        }
    }
    
    
    
    
    
    
    public function GetAllIndexingTypes()
    {
        return $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_075c6c4" . "172eaf58" . "cfa84828" . "a3582d19" . "a"]($GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_f73dab606" . "630b388645" . "c4f7d3fbb1" . "3bb"]($GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_d706c16" . "0e45bf74" . "34fff82a" . "5976f0e1" . "9"]($this->search_item_types), $GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_d706c160e" . "45bf7434ff" . "f82a5976f0" . "e19"]($this->indexing_types)));
    }
    
    
    
    
    
    
    public function GetCacheableIndexingTypes() : array
    {
        return $this->cacheable_item_types;
    }
    
    
    
    
    
    
    
    public function RegisterIndexingType($_90a9b1825557bb7e0aff3dc1a7962296, $_06e5839e14e1bc203f750e67ef402284)
    {
        if (!$GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_6fd29f1ce82d5e2d" . "09a2d806c2e2b1d5"]($_06e5839e14e1bc203f750e67ef402284)) {
            throw new IndexingException($GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_c8d1809bdc783b9698" . "165309fe704327"] . __METHOD__ . $GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_5306cb5e8985434a2a638b90f897" . "940d"], 1);
        }
        $this->indexing_types[$_90a9b1825557bb7e0aff3dc1a7962296] = $_06e5839e14e1bc203f750e67ef402284;
    }
    
    
    
    
    
    
    public function GetIndexingObject($type)
    {
        if (isset($this->indexing_types[$type])) {
            $_68ffaaa31e3ba49ed9d6159fbee9f043 = $this->indexing_types[$type]();
            return $_68ffaaa31e3ba49ed9d6159fbee9f043;
        } else {
            return $this->Get($type)->GetIndexingObject();
        }
    }
    public function getApplicationCodes()
    {
        return $this->item_types_application_code;
    }
}