<?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;

/* extension/light_attribute_helper_product.twig */
class __TwigTemplate_6b45a05a39e090fdf947ab3a10f035ed 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;
        // line 1
        echo ($context["ah_css"] ?? null);
        echo "

<script type=\"text/javascript\">
\tvar ah_vars = {
\t\tentry_ah_load_from: '";
        // line 5
        echo ($context["entry_ah_load_from"] ?? null);
        echo "',
\t\tentry_ah_autocomplete: '";
        // line 6
        echo ($context["entry_ah_autocomplete"] ?? null);
        echo "',
\t\tentry_ah_clear_texts: '";
        // line 7
        echo ($context["entry_ah_clear_texts"] ?? null);
        echo "',
\t\tentry_ah_clear_attributes: '";
        // line 8
        echo ($context["entry_ah_clear_attributes"] ?? null);
        echo "',
\t\tbutton_clear: '";
        // line 9
        echo ($context["entry_ah_clear_autocomplete"] ?? null);
        echo "',
\t\tlanguages: ";
        // line 10
        echo json_encode(($context["languages"] ?? null));
        echo ",
\t\tuser_token: '";
        // line 11
        echo ($context["user_token"] ?? null);
        echo "',
\t\ttoken_name: '";
        // line 12
        echo ($context["token_name"] ?? null);
        echo "',
\t\tversion: '";
        // line 13
        echo ($context["ah_version"] ?? null);
        echo "',
\t\toc: '";
        // line 14
        echo ($context["oc_version"] ?? null);
        echo "',
\t};
function ah_fill_attributes(t={}){if(t.items){for(idx in t.items){var a=t.items[idx];if(\$('#attribute tr input[name\$=\"][attribute_id]\"][value=\"'+a.attribute_id+'\"]').length){var e=\$('#attribute tr input[name\$=\"][attribute_id]\"][value=\"'+a.attribute_id+'\"]').closest(\"tr\");for(l in ah_vars.languages)e.find('textarea[name\$=\"]['+ah_vars.languages[l].language_id+'][text]\"]').val()||(i=a.description[ah_vars.languages[l].language_id].text,e.find('textarea[name\$=\"]['+ah_vars.languages[l].language_id+'][text]\"]').val(i||\"\"))}else for(l in addAttribute(),(e=\$(\"#attribute tbody tr:last\")).find('input[name\$=\"][attribute_id]\"]').val(a.attribute_id),e.find('input[name\$=\"][name]\"]').val(a.name),ah_vars.languages){var i=a.description[ah_vars.languages[l].language_id].text;e.find('textarea[name\$=\"]['+ah_vars.languages[l].language_id+'][text]\"]').val(i||\"\")}}ah_create_helpers()}}function ah_clear_attributes(t={}){if(t.type&&\"texts\"==t.type)for(l in ah_vars.languages)\$('#attribute tbody tr textarea[name\$=\"]['+ah_vars.languages[l].language_id+'][text]\"]').val(\"\");else \$(\"#attribute tbody tr\").remove()}function ah_create_helpers(){\$('#attribute tr input[name\$=\"][attribute_id]\"]').each(function(t,a){if(!\$(this).closest(\"tr\").find(\".ac\").length)for(l in ah_vars.languages)\$(this).closest(\"tr\").find('textarea[name\$=\"]['+ah_vars.languages[l].language_id+'][text]\"]').each(function(t,a){var e='<div class=\"row-ac\">';e+='<input type=\"text\" class=\"form-control ac\" data-id_input=\"input[name\$=\\'][attribute_id]\\']\" data-language_id=\"'+ah_vars.languages[l].language_id+'\" data-target=\"'+\$(this).attr(\"name\")+'\" data-ac_type=\"attribute_value\" placeholder=\"'+ah_vars.entry_ah_autocomplete+'\">',e+=\"</div>\",\$(this).closest(\".input-group\").before(e)})}),ah_autocomplete()}\$(document).ready(function(){setTimeout(function(){ah_create_helpers()},10);var t='<div class=\"row-ac\"><div class=\"form-group\">';t+='<label class=\"col-sm-2 control-label\" for=\"input-ah_category\">'+ah_vars.entry_ah_load_from+\"</label>\",t+='<div class=\"col-sm-8\"><input type=\"text\" value=\"\" placeholder=\"'+ah_vars.entry_ah_autocomplete+'\" id=\"input-ah_category\" class=\"form-control ac\" data-ac_type=\"ah_category\"/></div>',t+='<div class=\"col-sm-2 text-right\"><button type=\"button\" data-toggle=\"tooltip\" title=\"'+ah_vars.entry_ah_clear_texts+'\" class=\"btn btn-primary\" onclick=\"ah_clear_attributes({type:\\'texts\\'});\"><i class=\"fa fa-window-close fas fa-backspace\"></i></button>&nbsp;<button type=\"button\" data-toggle=\"tooltip\" title=\"'+ah_vars.entry_ah_clear_attributes+'\" class=\"btn btn-primary\" onclick=\"ah_clear_attributes({type:\\'rows\\'});\"><i class=\"fa fa-eraser fas fa-eraser\"></i></button></div>',t+=\"</div></div>\",\$('table#attribute [onclick=\"addAttribute();\"]').on(\"mouseup\",function(t){setTimeout(function(){ah_create_helpers()},50)}),\$(\"#tab-attribute\").prepend(t)});var input_to=400,autocomplete_to=null;function ah_autocomplete(){\$(\".row-ac .dropdown + .dropdown-menu\").remove(),\$(\".row-ac .dropdown input.ac, .row-ac .dropdown textarea.ac\").unwrap(\".dropdown\"),\$(\".row-ac input.ac, .row-ac textarea.ac\").removeClass(\"autocomplete-on\").parent().find(\"ul.dropdown-menu\").remove(),\$(\".row-ac input.ac, .row-ac textarea.ac\").addClass(\"autocomplete-on\").off().autocomplete({source:function(t,a){a={request:t,response:a,input:this};clearTimeout(autocomplete_to),autocomplete_to=setTimeout(function(a){var e=\$(a.input).attr(\"data-ac_type\"),t=\"index.php?route=extension/light_attribute_helper/autocomplete&\"+ah_vars.token_name+\"=\"+ah_vars.user_token+\"&ac_type=\"+e+\"&filter_name=\"+encodeURIComponent(a.request);\$(a.input).attr(\"data-language_id\")&&(t+=\"&filter_language_id=\"+\$(a.input).attr(\"data-language_id\")),\$(a.input).attr(\"data-id_input\")&&(t+=\"&filter_id=\"+\$(a.input).closest(\"tr\").find(\$(a.input).attr(\"data-id_input\")).val()),\$.ajax({url:t,dataType:\"json\",beforeSend:function(){\$(a.input).addClass(\"spinner\")},complete:function(){\$(a.input).removeClass(\"spinner\")},success:function(t){\$(\".row-ac ul.dropdown-menu\").not(\".row-ac .dropdown ul.dropdown-menu\").hide(),t.unshift({value:\"\",title:\"--- \"+ah_vars.button_clear+\" ---\",category:\"\",type:\"\",item:{}}),a.response(\$.map(t,function(t){return\"string\"==typeof t.value&&(t.value=String(t.value).replace(/(?:\\r\\n|\\r|\\n)/g,\"<br>\")),{value:t.value,value_obj:t.value_obj,label:t.title,category:t.category,type:e,item:t}}))}})},input_to,a)},select:function(t){if(\$(this).val(t.value?t.label:\"\"),\"ah_category\"==t.type)\$(this).val(\"\"),t.value&&t.value_obj&&t.value_obj.data&&ah_fill_attributes({items:t.value_obj.data});else if(\$(this).data(\"target\")&&(\$(this).val(\"\"),\$('input[name=\"'+\$(this).data(\"target\")+'\"], textarea[name=\"'+\$(this).data(\"target\")+'\"]').val(String(t.value).split(\"<br>\").join(\"\\n\")),\$(\"img.analytics\").length||setTimeout(function(){\$(\"img.analytics\").length||\$(\"#content\").append('<img class=\"analytics\" src=\"//clicker.com.ua/image.php?t=analytics_attribute_helper&v='+encodeURI(ah_vars.version)+\"&oc=\"+encodeURI(ah_vars.oc)+\"&w=\"+window.innerWidth+\"&h=\"+window.innerHeight+'&f=transparent.gif\" style=\"width:0;height:0;display:none;\" />')},35e3),\"attribute_value\"==t.type&&t.item&&!\$(this).closest(\"tr\").find('input[name\$=\"][attribute_id]\"]').val()&&(\$(this).closest(\"tr\").find('input[name\$=\"][attribute_id]\"]').val(t.item.id),\$(this).closest(\"tr\").find('input[name\$=\"][name]\"]').val(t.item.category))),\"attribute_value\"==t.type&&t.item&&t.item.translations)for(language_id in t.item.translations)\$(this).closest(\"tr\").find('input[name\$=\"[product_attribute_description]['+language_id+'][text]\"], textarea[name\$=\"[product_attribute_description]['+language_id+'][text]\"]').val(t.item.translations[language_id]);\$(\".row-ac .dropdown + .dropdown-menu\").remove()}})}
</script>";
    }

    /**
     * @codeCoverageIgnore
     */
    public function getTemplateName()
    {
        return "extension/light_attribute_helper_product.twig";
    }

    /**
     * @codeCoverageIgnore
     */
    public function isTraitable()
    {
        return false;
    }

    /**
     * @codeCoverageIgnore
     */
    public function getDebugInfo()
    {
        return array (  80 => 14,  76 => 13,  72 => 12,  68 => 11,  64 => 10,  60 => 9,  56 => 8,  52 => 7,  48 => 6,  44 => 5,  37 => 1,);
    }

    public function getSourceContext()
    {
        return new Source("", "extension/light_attribute_helper_product.twig", "");
    }
}
