<?php

use Twig\Environment;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Extension\SandboxExtension;
use Twig\Markup;
use Twig\Sandbox\SecurityError;
use Twig\Sandbox\SecurityNotAllowedTagError;
use Twig\Sandbox\SecurityNotAllowedFilterError;
use Twig\Sandbox\SecurityNotAllowedFunctionError;
use Twig\Source;
use Twig\Template;

/* _includes/forms/elementSelect.twig */
class __TwigTemplate_c4f6253aea93c7014a47881f0d2e90192897c5d880546421e3cb2565913ff240 extends Template
{
    private $source;
    private $macros = [];

    public function __construct(Environment $env)
    {
        parent::__construct($env);

        $this->source = $this->getSourceContext();

        $this->parent = false;

        $this->blocks = [
        ];
    }

    protected function doDisplay(array $context, array $blocks = [])
    {
        $macros = $this->macros;
        craft\helpers\Template::beginProfile("template", "_includes/forms/elementSelect.twig");
        // line 1
        if ((($context["name"]) ?? (false))) {
            // line 2
            echo "    ";
            echo craft\helpers\Html::hiddenInput((isset($context["name"]) || array_key_exists("name", $context) ? $context["name"] : (function () { throw new RuntimeError('Variable "name" does not exist.', 2, $this->source); })()), "");
            echo "
";
        }
        // line 5
        $context["id"] = (($context["id"]) ?? (("elementselect" . twig_random($this->env))));
        // line 6
        $context["elements"] = (($context["elements"]) ?? ([]));
        // line 7
        $context["jsClass"] = (($context["jsClass"]) ?? ("Craft.BaseElementSelectInput"));
        // line 8
        $context["sources"] = (($context["sources"]) ?? (null));
        // line 9
        $context["condition"] = (($context["condition"]) ?? (null));
        // line 10
        $context["criteria"] = (($context["criteria"]) ?? (null));
        // line 11
        $context["sourceElementId"] = (($context["sourceElementId"]) ?? (null));
        // line 12
        $context["storageKey"] = (($context["storageKey"]) ?? (null));
        // line 13
        $context["viewMode"] = (($context["viewMode"]) ?? ("list"));
        // line 14
        $context["sortable"] = (($context["sortable"]) ?? (true));
        // line 15
        $context["prevalidate"] = (($context["prevalidate"]) ?? (false));
        // line 16
        $context["fieldId"] = (($context["fieldId"]) ?? (null));
        // line 17
        $context["single"] = (($context["single"]) ?? (false));
        // line 18
        $context["limit"] = (((isset($context["single"]) || array_key_exists("single", $context) ? $context["single"] : (function () { throw new RuntimeError('Variable "single" does not exist.', 18, $this->source); })())) ? (1) : ((($context["limit"]) ?? (null))));
        // line 19
        $context["disabled"] = (((($context["disabled"]) ?? (false))) ? (true) : (false));
        // line 20
        $context["maintainHierarchy"] = (($context["maintainHierarchy"]) ?? (false));
        // line 21
        echo "
";
        // line 22
        $context["containerAttributes"] = $this->extensions['craft\web\twig\Extension']->mergeFilter(["id" =>         // line 23
(isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 23, $this->source); })()), "class" => $this->extensions['craft\web\twig\Extension']->mergeFilter([0 => "elementselect"], craft\helpers\Html::explodeClass(((        // line 24
$context["class"]) ?? ([]))))], ((        // line 25
$context["containerAttributes"]) ?? ([])), true);
        // line 26
        echo "
";
        // line 27
        $context["modalSettings"] = $this->extensions['craft\web\twig\Extension']->mergeFilter(["modalTitle" => ((        // line 28
$context["selectionLabel"]) ?? ($this->extensions['craft\web\twig\Extension']->translateFilter("Choose", "app")))], ((        // line 29
$context["modalSettings"]) ?? ([])), true);
        // line 31
        if (        $this->hasBlock("attr", $context, $blocks)) {
            // line 32
            $context["containerAttributes"] = $this->extensions['craft\web\twig\Extension']->mergeFilter((isset($context["containerAttributes"]) || array_key_exists("containerAttributes", $context) ? $context["containerAttributes"] : (function () { throw new RuntimeError('Variable "containerAttributes" does not exist.', 32, $this->source); })()), $this->extensions['craft\web\twig\Extension']->parseAttrFilter((("<div " .             $this->renderBlock("attr", $context, $blocks)) . ">")), true);
        }
        // line 34
        echo "
";
        // line 35
        ob_start();
        // line 36
        echo "    ";
        if ((isset($context["maintainHierarchy"]) || array_key_exists("maintainHierarchy", $context) ? $context["maintainHierarchy"] : (function () { throw new RuntimeError('Variable "maintainHierarchy" does not exist.', 36, $this->source); })())) {
            // line 37
            echo "        ";
            echo twig_include($this->env, $context, "_elements/structurelist.twig", ["elements" => (isset($context["elements"]) || array_key_exists("elements", $context) ? $context["elements"] : (function () { throw new RuntimeError('Variable "elements" does not exist.', 37, $this->source); })()), "id" => (isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 37, $this->source); })())]);
            echo "
    ";
        } else {
            // line 39
            echo "        ";
            echo twig_include($this->env, $context, "_elements/list.twig", ["elements" => (isset($context["elements"]) || array_key_exists("elements", $context) ? $context["elements"] : (function () { throw new RuntimeError('Variable "elements" does not exist.', 39, $this->source); })()), "viewMode" => (isset($context["viewMode"]) || array_key_exists("viewMode", $context) ? $context["viewMode"] : (function () { throw new RuntimeError('Variable "viewMode" does not exist.', 39, $this->source); })()), "disabled" => (isset($context["disabled"]) || array_key_exists("disabled", $context) ? $context["disabled"] : (function () { throw new RuntimeError('Variable "disabled" does not exist.', 39, $this->source); })())]);
            echo "
    ";
        }
        // line 41
        echo "
    <div class=\"flex flex-nowrap\">
        ";
        // line 43
        echo $this->extensions['craft\web\twig\Extension']->tagFunction("button", ["type" => "button", "class" => $this->extensions['craft\web\twig\Extension']->filterFilter($this->env, [0 => "btn", 1 => "add", 2 => "icon", 3 => "dashed", 4 => ((        // line 50
(isset($context["disabled"]) || array_key_exists("disabled", $context) ? $context["disabled"] : (function () { throw new RuntimeError('Variable "disabled" does not exist.', 50, $this->source); })())) ? ("disabled") : ("")), 5 => (((        // line 51
(isset($context["limit"]) || array_key_exists("limit", $context) ? $context["limit"] : (function () { throw new RuntimeError('Variable "limit" does not exist.', 51, $this->source); })()) && ($this->extensions['craft\web\twig\Extension']->lengthFilter($this->env, (isset($context["elements"]) || array_key_exists("elements", $context) ? $context["elements"] : (function () { throw new RuntimeError('Variable "elements" does not exist.', 51, $this->source); })())) >= (isset($context["limit"]) || array_key_exists("limit", $context) ? $context["limit"] : (function () { throw new RuntimeError('Variable "limit" does not exist.', 51, $this->source); })())))) ? ("hidden") : (""))]), "text" => ((        // line 53
$context["selectionLabel"]) ?? ($this->extensions['craft\web\twig\Extension']->translateFilter("Choose", "app"))), "disabled" =>         // line 54
(isset($context["disabled"]) || array_key_exists("disabled", $context) ? $context["disabled"] : (function () { throw new RuntimeError('Variable "disabled" does not exist.', 54, $this->source); })()), "aria" => ["label" => ((        // line 56
$context["selectionLabel"]) ?? ($this->extensions['craft\web\twig\Extension']->translateFilter("Choose", "app"))), "describedby" => ((        // line 57
$context["describedBy"]) ?? (false))]]);
        // line 59
        echo "
        <div class=\"spinner hidden\"></div>
    </div>
";
        echo craft\helpers\Html::tag("div", ob_get_clean(),         // line 35
(isset($context["containerAttributes"]) || array_key_exists("containerAttributes", $context) ? $context["containerAttributes"] : (function () { throw new RuntimeError('Variable "containerAttributes" does not exist.', 35, $this->source); })()));
        // line 63
        echo "
";
        // line 64
        if ( !(isset($context["disabled"]) || array_key_exists("disabled", $context) ? $context["disabled"] : (function () { throw new RuntimeError('Variable "disabled" does not exist.', 64, $this->source); })())) {
            // line 65
            echo "    ";
            $context["jsSettings"] = ["id" => $this->env->getFilter('namespaceInputId')->getCallable()(            // line 66
(isset($context["id"]) || array_key_exists("id", $context) ? $context["id"] : (function () { throw new RuntimeError('Variable "id" does not exist.', 66, $this->source); })())), "name" => $this->env->getFilter('namespaceInputName')->getCallable()(            // line 67
(isset($context["name"]) || array_key_exists("name", $context) ? $context["name"] : (function () { throw new RuntimeError('Variable "name" does not exist.', 67, $this->source); })())), "elementType" =>             // line 68
(isset($context["elementType"]) || array_key_exists("elementType", $context) ? $context["elementType"] : (function () { throw new RuntimeError('Variable "elementType" does not exist.', 68, $this->source); })()), "sources" =>             // line 69
(isset($context["sources"]) || array_key_exists("sources", $context) ? $context["sources"] : (function () { throw new RuntimeError('Variable "sources" does not exist.', 69, $this->source); })()), "condition" => ((            // line 70
(isset($context["condition"]) || array_key_exists("condition", $context) ? $context["condition"] : (function () { throw new RuntimeError('Variable "condition" does not exist.', 70, $this->source); })())) ? (craft\helpers\Template::attribute($this->env, $this->source, (isset($context["condition"]) || array_key_exists("condition", $context) ? $context["condition"] : (function () { throw new RuntimeError('Variable "condition" does not exist.', 70, $this->source); })()), "getConfig", [], "method")) : (null)), "referenceElementId" => (((craft\helpers\Template::attribute($this->env, $this->source,             // line 71
($context["referenceElement"] ?? null), "id", [], "any", true, true) &&  !(null === craft\helpers\Template::attribute($this->env, $this->source, ($context["referenceElement"] ?? null), "id", [])))) ? (craft\helpers\Template::attribute($this->env, $this->source, ($context["referenceElement"] ?? null), "id", [])) : (null)), "referenceElementSiteId" => (((craft\helpers\Template::attribute($this->env, $this->source,             // line 72
($context["referenceElement"] ?? null), "siteId", [], "any", true, true) &&  !(null === craft\helpers\Template::attribute($this->env, $this->source, ($context["referenceElement"] ?? null), "siteId", [])))) ? (craft\helpers\Template::attribute($this->env, $this->source, ($context["referenceElement"] ?? null), "siteId", [])) : (null)), "criteria" =>             // line 73
(isset($context["criteria"]) || array_key_exists("criteria", $context) ? $context["criteria"] : (function () { throw new RuntimeError('Variable "criteria" does not exist.', 73, $this->source); })()), "allowSelfRelations" => ((            // line 74
$context["allowSelfRelations"]) ?? (false)), "maintainHierarchy" =>             // line 75
(isset($context["maintainHierarchy"]) || array_key_exists("maintainHierarchy", $context) ? $context["maintainHierarchy"] : (function () { throw new RuntimeError('Variable "maintainHierarchy" does not exist.', 75, $this->source); })()), "branchLimit" => ((            // line 76
$context["branchLimit"]) ?? (null)), "sourceElementId" =>             // line 77
(isset($context["sourceElementId"]) || array_key_exists("sourceElementId", $context) ? $context["sourceElementId"] : (function () { throw new RuntimeError('Variable "sourceElementId" does not exist.', 77, $this->source); })()), "disabledElementIds" => ((            // line 78
$context["disabledElementIds"]) ?? (null)), "viewMode" =>             // line 79
(isset($context["viewMode"]) || array_key_exists("viewMode", $context) ? $context["viewMode"] : (function () { throw new RuntimeError('Variable "viewMode" does not exist.', 79, $this->source); })()), "single" =>             // line 80
(isset($context["single"]) || array_key_exists("single", $context) ? $context["single"] : (function () { throw new RuntimeError('Variable "single" does not exist.', 80, $this->source); })()), "limit" =>             // line 81
(isset($context["limit"]) || array_key_exists("limit", $context) ? $context["limit"] : (function () { throw new RuntimeError('Variable "limit" does not exist.', 81, $this->source); })()), "showSiteMenu" => ((            // line 82
$context["showSiteMenu"]) ?? (false)), "modalStorageKey" =>             // line 83
(isset($context["storageKey"]) || array_key_exists("storageKey", $context) ? $context["storageKey"] : (function () { throw new RuntimeError('Variable "storageKey" does not exist.', 83, $this->source); })()), "fieldId" =>             // line 84
(isset($context["fieldId"]) || array_key_exists("fieldId", $context) ? $context["fieldId"] : (function () { throw new RuntimeError('Variable "fieldId" does not exist.', 84, $this->source); })()), "sortable" =>             // line 85
(isset($context["sortable"]) || array_key_exists("sortable", $context) ? $context["sortable"] : (function () { throw new RuntimeError('Variable "sortable" does not exist.', 85, $this->source); })()), "prevalidate" =>             // line 86
(isset($context["prevalidate"]) || array_key_exists("prevalidate", $context) ? $context["prevalidate"] : (function () { throw new RuntimeError('Variable "prevalidate" does not exist.', 86, $this->source); })()), "modalSettings" => ((            // line 87
$context["modalSettings"]) ?? ([]))];
            // line 89
            echo "
    ";
            // line 90
            ob_start();
            // line 91
            echo "        new ";
            echo twig_escape_filter($this->env, (isset($context["jsClass"]) || array_key_exists("jsClass", $context) ? $context["jsClass"] : (function () { throw new RuntimeError('Variable "jsClass" does not exist.', 91, $this->source); })()), "html", null, true);
            echo "(";
            echo $this->extensions['craft\web\twig\Extension']->jsonEncodeFilter((isset($context["jsSettings"]) || array_key_exists("jsSettings", $context) ? $context["jsSettings"] : (function () { throw new RuntimeError('Variable "jsSettings" does not exist.', 91, $this->source); })()));
            echo ");
    ";
            craft\helpers\Template::js(ob_get_clean(), ['position' => 3]);
        }
        craft\helpers\Template::endProfile("template", "_includes/forms/elementSelect.twig");
    }

    public function getTemplateName()
    {
        return "_includes/forms/elementSelect.twig";
    }

    public function isTraitable()
    {
        return false;
    }

    public function getDebugInfo()
    {
        return array (  172 => 91,  170 => 90,  167 => 89,  165 => 87,  164 => 86,  163 => 85,  162 => 84,  161 => 83,  160 => 82,  159 => 81,  158 => 80,  157 => 79,  156 => 78,  155 => 77,  154 => 76,  153 => 75,  152 => 74,  151 => 73,  150 => 72,  149 => 71,  148 => 70,  147 => 69,  146 => 68,  145 => 67,  144 => 66,  142 => 65,  140 => 64,  137 => 63,  135 => 35,  130 => 59,  128 => 57,  127 => 56,  126 => 54,  125 => 53,  124 => 51,  123 => 50,  122 => 43,  118 => 41,  112 => 39,  106 => 37,  103 => 36,  101 => 35,  98 => 34,  95 => 32,  93 => 31,  91 => 29,  90 => 28,  89 => 27,  86 => 26,  84 => 25,  83 => 24,  82 => 23,  81 => 22,  78 => 21,  76 => 20,  74 => 19,  72 => 18,  70 => 17,  68 => 16,  66 => 15,  64 => 14,  62 => 13,  60 => 12,  58 => 11,  56 => 10,  54 => 9,  52 => 8,  50 => 7,  48 => 6,  46 => 5,  40 => 2,  38 => 1,);
    }

    public function getSourceContext()
    {
        return new Source("{% if name ?? false %}
    {{ hiddenInput(name, '') }}
{% endif -%}

{% set id = id ?? \"elementselect#{random()}\" -%}
{% set elements = elements ?? [] -%}
{% set jsClass = jsClass ?? 'Craft.BaseElementSelectInput' -%}
{% set sources = sources ?? null -%}
{% set condition = condition ?? null -%}
{% set criteria = criteria ?? null -%}
{% set sourceElementId = sourceElementId ?? null -%}
{% set storageKey = storageKey ?? null -%}
{% set viewMode = viewMode ?? 'list' %}
{% set sortable = sortable ?? true %}
{% set prevalidate = prevalidate ?? false %}
{% set fieldId = fieldId ?? null %}
{% set single = single ?? false %}
{% set limit = single ? 1 : (limit ?? null) %}
{% set disabled = (disabled ?? false) ? true : false %}
{% set maintainHierarchy = maintainHierarchy ?? false %}

{% set containerAttributes = {
    id: id,
    class: ['elementselect']|merge((class ?? [])|explodeClass),
}|merge(containerAttributes ?? [], recursive=true) %}

{% set modalSettings = {
    modalTitle: selectionLabel ?? 'Choose'|t('app'),
}|merge(modalSettings ?? [], recursive=true) %}

{%- if block('attr') is defined %}
    {%- set containerAttributes = containerAttributes|merge(('<div ' ~ block('attr') ~ '>')|parseAttr, recursive=true) %}
{% endif %}

{% tag 'div' with containerAttributes %}
    {% if maintainHierarchy %}
        {{ include('_elements/structurelist.twig', { elements, id })}}
    {% else %}
        {{ include('_elements/list.twig', { elements, viewMode, disabled }) }}
    {% endif %}

    <div class=\"flex flex-nowrap\">
        {{ tag('button', {
            type: 'button',
            class: [
                'btn',
                'add',
                'icon',
                'dashed',
                disabled ? 'disabled',
                limit and elements|length >= limit ? 'hidden',
            ]|filter,
            text: selectionLabel ?? 'Choose'|t('app'),
            disabled: disabled,
            aria: {
                label: selectionLabel ?? 'Choose'|t('app'),
                describedby: describedBy ?? false,
            }
        }) }}
        <div class=\"spinner hidden\"></div>
    </div>
{% endtag %}

{% if not disabled %}
    {% set jsSettings = {
        id: id|namespaceInputId,
        name: name|namespaceInputName,
        elementType: elementType,
        sources: sources,
        condition: condition ? condition.getConfig() : null,
        referenceElementId: referenceElement.id ?? null,
        referenceElementSiteId: referenceElement.siteId ?? null,
        criteria: criteria,
        allowSelfRelations: allowSelfRelations ?? false,
        maintainHierarchy: maintainHierarchy,
        branchLimit: branchLimit ?? null,
        sourceElementId: sourceElementId,
        disabledElementIds: disabledElementIds ?? null,
        viewMode: viewMode,
        single: single,
        limit: limit,
        showSiteMenu: showSiteMenu ?? false,
        modalStorageKey: storageKey,
        fieldId: fieldId,
        sortable: sortable,
        prevalidate: prevalidate,
        modalSettings: modalSettings ?? {},
    } %}

    {% js %}
        new {{ jsClass }}({{ jsSettings|json_encode|raw }});
    {% endjs %}
{% endif %}
", "_includes/forms/elementSelect.twig", "/home/addons/atweb.space/sub/craft-demo/cms/vendor/craftcms/cms/src/templates/_includes/forms/elementSelect.twig");
    }
}
