{# LIBRARIES #}
{{ attach_library('ui_patterns/tweet_carousel.tweet_carousel_lib') }}

{# Extra support for Twitter link #}
{% if items|length %}
  {% set slides = [] %}
  {% for item in items %}
    {% set post = '' %}
    {# Twitter link support #}
    {% if item.entities.urls[0] %}
      {% set post %}
        {% include "@atoms/tm-links/icon-bookended/icon-bookended.twig" with {
          "text": item.entities.urls[0].url,
          "url": item.entities.urls[0].url,
          "icon_right": "fas fa-external-link-square-alt",
          "class": link_class,
          "display": 'inline',
        } only %}
      {% endset %}
    {% endif %}
    {# Mapping #}
    {% set slide_item = {
      meta: item.meta,
      text: item.text,
      link_url:item.link_url,
      link_alt: item.link_alt,
      post: post,
    } %}
    {# Append #}
    {% set slides = slides|merge([slide_item]) %}
  {% endfor %}
{% endif %}

{# VARIABLES #}
{% set main_icon = main_icon|default('fab fa-twitter') %}
{% set meta_icon = meta_icon|default('fas fa-clock') %}

{# TEMPLATE #}
{% include "@organisms/tm-bs/carousel/mini-carousel/mini-carousel.twig" with {
  'items': slides,
  'main_icon': main_icon,
  'meta_icon': meta_icon,
  'cid': 'twitter',
  'text_class': '',
  'meta_class': '',
} only %}
