{% assign nameArr = categorie_fullname | remove: '['  | split: "]" %}
{%  assign categorie_name = nameArr[1] %} 

<div class="categorie_section np-homepage-feature np-max-width" data-categories="{{categorie_name  | remove:" " }}">
  <div class="np-homepage-feature-text">
    <div class="np-homepage-headline">  
      {{categorie_name }} 
    </div>
    <div class="controls_{{categorie_name | remove:" "  }} feature-carousel-controls np-hidden-mobile">
      <div class="prev-arrow carousel-control"><i class="far fa-chevron-left"></i></div>
      <div class="next-arrow carousel-control"><i class="far fa-chevron-right"></i></div>
    </div>
  </div>
  {% if courses.in_catalog.size > 0 %}
    {% assign courseids = "" %}
    {% for course in courses.in_catalog %}
      {% for cat in course.categories %}            
        {% if cat.name contains categorie_fullname %}
          {% assign courseids = courseids | append: course.id | append: ":" %}           
        {% endif %}
      {% endfor %}  
    {% endfor %}
    {% assign tempArr = courseids  | split: ":" %}
    {% assign idArr = tempArr  | uniq %}
    {% assign courses_count = 0 %}
    <div class="feature-courses-wrapper">
      <div class="slider_{{categorie_name  | remove:" " }} feature-courses-slider">
        {% for course in courses.in_catalog %}
          {% for id in idArr %}
            {% if course.id == id %}
              {% assign courses_count = courses_count | plus: 1 %}
              <div class="slide_{{course.id | remove:"-"  }} showCourse feature-course-slide">
                  {% include "cards_course" with course %}
              </div>
            {% endif %} 
          {% endfor %}  
        {% endfor %}   
      </div>
    </div>

    {% if courses_count > 0 %}
      {% comment %} <div class="feature-see-more-wrapper">
        <a href="/app/dashboard">See more</a>
      </div> {% endcomment %}
    {% else %}
      <script>console.log("{{courses_count}}")</script>
      <div class="np-homepage-featured-empty">
        <div class="np-zero-state-text">
          You don't have any {{categorie_name}} training at this moment.
        </div>
        <img class="np-zero-state-courses" alt="Yikes! You don't have any feature training at this moment." />
        <div class="zero-state-cta" style="margin-top:32px;">
          {% comment %} <a href="/app/catalog" class="np-button">Explore Catalog</a> {% endcomment %}
        </div>
      </div>
    {% endif %}
  {% else %}
    <div class="np-homepage-featured-empty">
      <div class="np-zero-state-text">
       You don't have any {{categorie_name}} training at this moment.
      </div>
      <img class="np-zero-state-courses" alt="Yikes! You don't have any feature training at this moment." />
      <div class="zero-state-cta" style="margin-top:32px;">
        {% comment %} <a href="/app/catalog" class="np-button">Explore Catalog</a> {% endcomment %}
      </div>
    </div>
  {% endif %}
</div>


<script>

  window.addEventListener("DOMContentLoaded", (event) => {

    var featureSlider = tns({
      container: '.slider_{{categorie_name | remove:" "  }}',
      items: 1,
      slideBy: 'page',
      autoplay: false,
      gutter: 8,
      controls: false,
      navPosition: "bottom",
      loop: false,
      mouseDrag: true,
      speed: 500,
      controlsContainer: document.querySelector('.controls_{{categorie_name | remove:" "  }}'),
      responsive: {
        600: {
          items: 2,
        },
        768: {
          items: 3,
          gutter: 16,
          controls: true
        }
      }
    });
  });


</script>


<style>
  .feature-courses-wrapper {
    margin: 0 -8px;
  }

  .np-homepage-feature {
    padding: 0 16px;
    margin-bottom: 56px;
  }

  .np-homepage-feature-text {
    padding: 0 0 32px;
    text-align: left;
    display: flex;
  }

  .np-homepage-feature-text .np-homepage-headline {
    font-weight: 400;
    font-size: 24px;
    line-height: 32px;
    color: #333;
    align-self: flex-start;
  }

  .feature-carousel-controls {
    align-self: flex-end;
    display: flex;
  }

  .feature-carousel-controls .carousel-control {
    margin: 0 8px;
    background-color: #ebe8f3;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #3c228a;
    cursor: pointer;
    transition: opacity 0.2s;
  }

  .feature-carousel-controls .carousel-control[aria-disabled='true'] {
    opacity: 0.3;
    cursor: default;
  }

  .feature-carousel-controls .carousel-control.next-arrow {
    margin-right: 0;
  }

  .feature-courses-slider {
    display: flex;
  }

  .feature-course-slide {
    margin-bottom: 12px;
  }

  .feature-course-slide .np-card {
    margin: 0 auto;
    padding: 0;
    height: 100%;
  }

  .feature-course-slide .np-card-container {
    height: 100%;
    margin: 0 8px;
  }

  .feature-see-more-wrapper {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
  }

  .feature-see-more-wrapper a {
    color: #3C228A;
  }

  @media (min-width:768px) {
    .np-homepage-feature-text {
      flex-direction: row;
      justify-content: space-between;
    }

    .np-homepage-feature-text .np-homepage-headline {
      font-size: 32px;
      line-height: 40px;
    }

    .feature-see-more-wrapper {
      margin-top: 12px;
    }
  }
</style>