{% comment %}
  Renders a list advertising banner

   Accepts:
  - blocks: {Array} block product
  - color_scheme_chosen: {Object} Color scheme for product card

  Usage:
  {% render 'banner-advertise-v3'%}
{% endcomment %}

<xo-animate xo-cascade class='banner-advertise-v3'>
  {% case section.settings.advertise_align %}
    {% when 'left' %}
      {% assign justify = 'flex-start' %}
    {% when 'center' %}
      {% assign justify = 'center' %}
    {% else %}
      {% assign justify = 'flex-end' %}
  {% endcase %}
  <div class='banner-advertise-v3__heading' style='--justify:{{justify}}'>
    <h3 class='banner-advertise-v3__title'>{{ section.settings.advertise_title }}</h3>
  </div>
  {% if blocks.size > 1 %}
    {% assign columns = 2 %}
  {% else %}
    {% assign columns = 1 %}
  {% endif %}
  <xo-grid style='--xs:1;--sm:2;--xl:{{columns}}'>
    {% for block in blocks %}
      {%- assign placeholder_image_index = forloop.index0 | modulo: 4 | plus: 1 -%}
      {%- assign placeholder_image = 'product-apparel-' | append: placeholder_image_index -%}
      {% assign product = block.settings.product %}
      {% if distinct_color_scheme == true %}
        {% assign color_scheme_chosen = product_card_color_scheme %}
      {% else %}
        {% assign color_scheme_chosen = settings.card_color_scheme %}
      {% endif %}
      <div>
        {% case settings.product_card_style_layout %}
          {% when 'style9' %}
            {% render 'product-card-style9',
              product: product,
              show_image: settings.product_card_show_image,
              show_secondary_image: settings.product_card_show_secondary_image,
              show_vendor: settings.product_card_show_vendor,
              show_description: settings.product_card_show_description,
              show_quick_add: settings.product_card_show_quick_add,
              show_quick_view: settings.product_card_show_quick_view,
              show_price: settings.product_card_show_price,
              show_badge: settings.product_card_show_badge,
              media_aspect_ratio: settings.product_card_aspect_ratio,
              color_scheme: color_scheme_chosen,
              placeholder_image: placeholder_image
            %}

          {% when 'style8' %}
            {% render 'product-card-style8',
              product: product,
              show_image: settings.product_card_show_image,
              show_secondary_image: settings.product_card_show_secondary_image,
              show_vendor: settings.product_card_show_vendor,
              show_description: settings.product_card_show_description,
              show_quick_add: settings.product_card_show_quick_add,
              show_quick_view: settings.product_card_show_quick_view,
              show_price: settings.product_card_show_price,
              show_badge: settings.product_card_show_badge,
              media_aspect_ratio: settings.product_card_aspect_ratio,
              color_scheme: color_scheme_chosen,
              placeholder_image: placeholder_image
            %}

          {% when 'style7' %}
            {% render 'product-card-style7',
              product: product,
              show_image: settings.product_card_show_image,
              show_secondary_image: settings.product_card_show_secondary_image,
              show_vendor: settings.product_card_show_vendor,
              show_description: settings.product_card_show_description,
              show_quick_add: settings.product_card_show_quick_add,
              show_quick_view: settings.product_card_show_quick_view,
              show_price: settings.product_card_show_price,
              show_badge: settings.product_card_show_badge,
              media_aspect_ratio: settings.product_card_aspect_ratio,
              color_scheme: color_scheme_chosen,
              placeholder_image: placeholder_image
            %}

          {% when 'style6' %}
            {% render 'product-card-style6',
              product: product,
              show_image: settings.product_card_show_image,
              show_secondary_image: settings.product_card_show_secondary_image,
              show_vendor: settings.product_card_show_vendor,
              show_description: settings.product_card_show_description,
              show_quick_add: settings.product_card_show_quick_add,
              show_quick_view: settings.product_card_show_quick_view,
              show_price: settings.product_card_show_price,
              show_badge: settings.product_card_show_badge,
              media_aspect_ratio: settings.product_card_aspect_ratio,
              color_scheme: color_scheme_chosen,
              placeholder_image: placeholder_image
            %}

          {% when 'style5' %}
            {% render 'product-card-style5',
              product: product,
              show_image: settings.product_card_show_image,
              show_secondary_image: settings.product_card_show_secondary_image,
              show_vendor: settings.product_card_show_vendor,
              show_description: settings.product_card_show_description,
              show_quick_add: settings.product_card_show_quick_add,
              show_quick_view: settings.product_card_show_quick_view,
              show_price: settings.product_card_show_price,
              show_badge: settings.product_card_show_badge,
              media_aspect_ratio: settings.product_card_aspect_ratio,
              color_scheme: color_scheme_chosen,
              placeholder_image: placeholder_image
            %}

          {% when 'style4' %}
            {% render 'product-card-style4',
              product: product,
              show_image: settings.product_card_show_image,
              show_secondary_image: settings.product_card_show_secondary_image,
              show_vendor: settings.product_card_show_vendor,
              show_description: settings.product_card_show_description,
              show_quick_add: settings.product_card_show_quick_add,
              show_quick_view: settings.product_card_show_quick_view,
              show_price: settings.product_card_show_price,
              show_badge: settings.product_card_show_badge,
              media_aspect_ratio: settings.product_card_aspect_ratio,
              color_scheme: color_scheme_chosen,
              placeholder_image: placeholder_image
            %}

          {% when 'style3' %}
            {% render 'product-card-style3',
              product: product,
              show_image: settings.product_card_show_image,
              show_secondary_image: settings.product_card_show_secondary_image,
              show_vendor: settings.product_card_show_vendor,
              show_description: settings.product_card_show_description,
              show_quick_add: settings.product_card_show_quick_add,
              show_quick_view: settings.product_card_show_quick_view,
              show_price: settings.product_card_show_price,
              show_badge: settings.product_card_show_badge,
              media_aspect_ratio: settings.product_card_aspect_ratio,
              color_scheme: color_scheme_chosen,
              placeholder_image: placeholder_image
            %}

          {% when 'style2' %}
            {% render 'product-card-style2',
              product: product,
              show_image: settings.product_card_show_image,
              show_secondary_image: settings.product_card_show_secondary_image,
              show_vendor: settings.product_card_show_vendor,
              show_description: settings.product_card_show_description,
              show_quick_add: settings.product_card_show_quick_add,
              show_quick_view: settings.product_card_show_quick_view,
              show_price: settings.product_card_show_price,
              show_badge: settings.product_card_show_badge,
              media_aspect_ratio: settings.product_card_aspect_ratio,
              color_scheme: color_scheme_chosen,
              placeholder_image: placeholder_image
            %}

          {% when 'style1' %}
            {% render 'product-card-style1',
              product: product,
              show_image: settings.product_card_show_image,
              show_secondary_image: settings.product_card_show_secondary_image,
              show_vendor: settings.product_card_show_vendor,
              show_description: settings.product_card_show_description,
              show_quick_add: settings.product_card_show_quick_add,
              show_quick_view: settings.product_card_show_quick_view,
              show_price: settings.product_card_show_price,
              show_badge: settings.product_card_show_badge,
              media_aspect_ratio: settings.product_card_aspect_ratio,
              color_scheme: color_scheme_chosen,
              placeholder_image: placeholder_image
            %}
        {% endcase %}
        {% render 'countdown',
          title: block.settings.countdown_title,
          subtitle: block.settings.countdown_subtitle,
          time: block.settings.countdown_time,
          show_days: block.settings.show_days,
          show_hours: block.settings.show_hours,
          show_minutes: block.settings.show_minutes,
          show_seconds: block.settings.show_seconds
        %}
      </div>
    {% endfor %}
  </xo-grid>
</xo-animate>
