<?php
namespace Claromentis\Core\Tree;

$GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"] = (@$GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"] ?: array()) + array("_a591754a8ddcdbda9c80f1db4d911" . "e14" => base64_decode("aXNfb" . "nVsbA" . "=="), "_b13aec0775985a26001b6b287477f3f" . "e" => base64_decode("RGVwdGggZmlsdGVyIGlzIG5vdCBjY" . "WxsYWJsZQ=="), "_6fd29f1ce82d5e2d09a2d806c2e2b1" . "d5" => base64_decode("aXNfY2FsbGF" . "ibGU="));
use RecursiveIterator;























abstract class FolderIdsIterator implements RecursiveIterator
{
    const LEAVES_FIRST = 1;
    const FOLDERS_FIRST = 2;
    protected $folder_id;
    protected $include_deleted;
    protected $mode;
    protected $children;
    protected $pos = 0;
    protected $cache_all;
    protected $children_iterators = null;
    
    
    
    
    protected $depth_filter = null;
    
    
    
    
    
    
    
    public function __construct($folder_id, $_9217945053dcf5f2b8e7f005e1025e64 = false, $_601a171d59986f7c15972b586685671b = self::LEAVES_FIRST, $_25467b9c95c4c672788507e4e0284f32 = false)
    {
        $this->folder_id = $folder_id;
        $this->include_deleted = $_9217945053dcf5f2b8e7f005e1025e64;
        $this->mode = $_601a171d59986f7c15972b586685671b;
        $this->children = null;
        $this->pos = 0;
        $this->cache_all = $_25467b9c95c4c672788507e4e0284f32;
    }
    
    
    
    
    
    
    
    
    
    public function SetDepthFilter($_93871b54f3f55af06dbe4cdc98bd678f)
    {
        if (!$GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_6fd29f1ce8" . "2d5e2d09a2d" . "806c2e2b1d5"]($_93871b54f3f55af06dbe4cdc98bd678f) && !$GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_a591754a8ddcdb" . "da9c80f1db4d911" . "e14"]($_93871b54f3f55af06dbe4cdc98bd678f)) {
            throw new \InvalidArgumentException($GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_b13aec0775985a" . "26001b6b287477f" . "3fe"]);
        }
        $this->depth_filter = $_93871b54f3f55af06dbe4cdc98bd678f;
    }
    public function current()
    {
        $this->FillChildrenArray();
        return $this->children[$this->pos];
    }
    public function next()
    {
        $this->pos++;
    }
    public function key()
    {
        return $this->pos;
    }
    public function valid()
    {
        $this->FillChildrenArray();
        return isset($this->children[$this->pos]);
    }
    public function rewind()
    {
        $this->pos = 0;
    }
    
    
    
    
    
    
    public function hasChildren()
    {
        if ($this->depth_filter) {
            $_03e9164d0a343b742df4793268b80767 = $this->depth_filter;
            if (!$_03e9164d0a343b742df4793268b80767($this->current())) {
                return false;
            }
        }
        
        
        
        
        return true;
    }
    
    
    
    
    
    
    public function getChildren()
    {
        if (isset($this->children_iterators[$this->pos])) {
            return $this->children_iterators[$this->pos];
        }
        $_a4b4fe29a876bd36f8024f56a625bf4c = $this->children[$this->pos];
        $_3974247ae4b1054a37517e9579770287 = new static($_a4b4fe29a876bd36f8024f56a625bf4c[1], $this->include_deleted, $this->mode, $this->cache_all);
        if ($this->cache_all) {
            $this->children_iterators[$this->pos] = $_3974247ae4b1054a37517e9579770287;
        } else {
            $this->children_iterators = array($this->pos => $_3974247ae4b1054a37517e9579770287);
        }
        return $_3974247ae4b1054a37517e9579770287;
    }
    protected function FillChildrenArray()
    {
        if ($GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_a591754a8ddcdbda9c80" . "f1db4d911e14"]($this->children)) {
            $this->children = $this->GetAllChildrenArray($this->folder_id);
        }
    }
    
    
    
    
    
    
    protected abstract function GetAllChildrenArray($folder_id);
}