{ifmodule PRODUCTS_VARIATIONS}
{foreach $body.dynamic_filter.variations as $id => $label}
   {if $label.convertor}
      {$values = $dynamic_filter->getSizeConvertionVariation($label.convertor)}
   {else}
      {$values = $dynamic_filter->getVariation($id)}
   {/if}
   {$body.dynamic_filter.variations[$id].values = $values.values scope="global"}
{/foreach}
{ifmodule INDEXED_FILTER}
{$selectedVariations = $body.dynamic_filter.filterParams->getVariations()}
{$selectedVariationsSizeConvertion = $body.dynamic_filter.filterParams->getVariationsSizeConvertion()}
{/ifmodule}

{foreach $body.dynamic_filter.variations as $id_label => $label}
   {if $label.values}
      {$inputId = $label.name|strip_accent}
      {$indexed = $body.dynamic_filter.variations[$id_label].indexing == 'Y'}
      {if $label.convertor}
         {ifmodule CONVERTORS}
            {$inputId = $label.name|cat:'-size-convertion'|strip_accent}
            {include "filter/block.filter.variations.size-convertion.tpl" focus=$focus filter_openers=$filter_openers isPrimary=true id_convertor=$label.convertor}
         {/ifmodule}
      {else}
         <div{if $focus} class="tab-pane{if !$filterFocusTabIsActive} active{/if}" id="variation-{$id_label}" role="tabpanel"{else} class="filter-row filter-variations"{/if}>
            {if $filter_openers}
               <button type="button" class="filter-label"
                       data-opener="[data-opener-var-{$label.id}]">{$label.name}</button>
            {else}
               <p class="filter-label">{$label.name}</p>
            {/if}
            <div {if $filter_openers}class="opener-content"
                 data-opener-var-{$label.id}{/if}{if $focus} data-simplebar data-simplebar-auto-hide="true"{/if}>
               {foreach $label.values as $id => $value}
                  <label class="custom-control custom-checkbox" for="filter_variant[{$id_label}][{$id}]">
                     <input type="checkbox" name="dynamic_filter[variations][{$id_label}][value][]" value="{$id}"
                            id="filter_variant[{$id_label}][{$id}]" class="custom-control-input" data-filter-input="{$inputId}"
                            {if in_array($id, $selectedVariations[$id_label])}checked{/if}
                            data-tracking-filter='{get_gtm_data encode=true type='ecommerce' method='ApplyFilterVariations' data=['id' => $id, 'label' => $label]}'
                     />
                     <span class="custom-control-indicator"></span>
                     <span class="custom-control-text">

                        {if $indexed and $urlGenerator}
                           {$generated = $urlGenerator->getVariationUrl($id_label, $id, $value.filter_url)}
                           <a href="{$generated.url}">{$value.name}</a>
                        {else}
                           {$value.name}
                        {/if}

                        <small>(<span class="filter-count" data-filter-count="{$id}">{$value.count}</span>)</small>
                       </span>
                  </label>
               {/foreach}
            </div>
         </div>
      {/if}
      {$filterFocusTabIsActive = true scope="global"}
   {/if}
{/foreach}
{/ifmodule}
