<?php
namespace Claromentis\Search;

$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"] ?: array()) + array("_d706c160e45bf7434fff" . "82a5976f0e19" => base64_decode("YXJyYXlfa2V5" . "cw=="), "_6fd29f1ce82" . "d5e2d09a2d80" . "6c2e2b1d5" => base64_decode("aXNfY2Fs" . "bGFibGU="), "_bd71c3b5c201" . "fc11db82ed14c" . "e424de5" => base64_decode("aW5fYXJyY" . "Xk="), "_075c6c4172ea" . "f58cfa84828a3" . "582d19a" => base64_decode("YXJyYXlfdW5p" . "cXVl"), "_f73dab606630b388645c4f7d3fbb13" . "bb" => base64_decode("YXJyYXlf" . "bWVyZ2U="), "_8f7dd777fdeec4a63087bff8b5c757b" . "f" => base64_decode("VW5zdXBwb3J0ZWQgb2JqZWN0IHR5cGUgL" . "SA="), "_c8d1809bdc783b9698165309f" . "e704327" => base64_decode("VGhlIHNlY29uZCBwYXJhbWV0ZXIgb2Y" . "g"), "_5306cb5e" . "8985434a2" . "a638b90f8" . "97940d" => base64_decode("IGlzIG5vdCBjYWxsYWJsZ" . "Q=="));
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 $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);
        }
        if ($_f44467aacb8a4520c7382769d24aa422 instanceof CacheableInterface) {
            $_a18bef7ab1ad0a4c0171b3201caa8064 = $_f44467aacb8a4520c7382769d24aa422->getCacheableTypes();
            foreach ($_a18bef7ab1ad0a4c0171b3201caa8064 as $type) {
                $this->RegisterCacheableType($type);
            }
        }
    }
    
    
    
    
    
    
    
    public function RegisterType($type, $_06e5839e14e1bc203f750e67ef402284)
    {
        if (!$GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_6fd29f1ce82d5" . "e2d09a2d806c2e" . "2b1d5"]($_06e5839e14e1bc203f750e67ef402284)) {
            throw new IndexingException($GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_c8d1809bdc" . "783b9698165" . "309fe704327"] . __METHOD__ . $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_5306cb5e8985434a" . "2a638b90f897940d"], 1);
        }
        $this->search_item_types[$type] = $_06e5839e14e1bc203f750e67ef402284;
    }
    
    
    
    
    
    
    public function RegisterCacheableType($type)
    {
        if (!$GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_bd71c3b5" . "c201fc11d" . "b82ed14ce" . "424de5"]($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["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_8f7dd777" . "fdeec4a63" . "087bff8b5" . "c757bf"] . $type);
            $e->item_type = $type;
            throw $e;
        }
    }
    
    
    
    
    
    
    public function GetAllIndexingTypes()
    {
        return $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_075c6c4172eaf58cfa84828a3582" . "d19a"]($GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_f73dab606630b388645c4f7d3f" . "bb13bb"]($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_d706c160e45bf7434fff82a5976f0e" . "19"]($this->search_item_types), $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_d706c160e45bf7434fff8" . "2a5976f0e19"]($this->indexing_types)));
    }
    
    
    
    
    
    
    public function GetCacheableIndexingTypes() : array
    {
        return $this->cacheable_item_types;
    }
    
    
    
    
    
    
    
    public function RegisterIndexingType($_90a9b1825557bb7e0aff3dc1a7962296, $_06e5839e14e1bc203f750e67ef402284)
    {
        if (!$GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_6fd29f1ce82d5e2d09a" . "2d806c2e2b1d5"]($_06e5839e14e1bc203f750e67ef402284)) {
            throw new IndexingException($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_c8d1809bdc783" . "b9698165309fe7" . "04327"] . __METHOD__ . $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_5306cb5e8985434a2a638b" . "90f897940d"], 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();
        }
    }
}