{% block element_image_slider %}
    {% set sliderConfig = element.fieldConfig.elements %}

    <div class="cms-element-{{ element.type }}{% if sliderConfig.displayMode.value == "standard" and sliderConfig.verticalAlign.value %} has-vertical-alignment{% endif %}">
        {% set baseSliderOptions = {
            slider: {
                navPosition: 'bottom',
                speed: sliderConfig.speed.value,
                autoplayTimeout: sliderConfig.autoplayTimeout.value,
                autoplay: sliderConfig.autoSlide.value,
                autoplayButtonOutput: false,
                nav: sliderConfig.navigationDots.value ? true : false,
                controls: sliderConfig.navigationArrows.value ? true : false,
                autoHeight: (sliderConfig.displayMode.value == "standard") ? true : false
            }
        } %}

        {% block element_image_slider_alignment %}
            {% if config.verticalAlign.value %}
                <div class="cms-element-alignment{% if sliderConfig.verticalAlign.value == "center" %} align-self-center{% elseif sliderConfig.verticalAlign.value == "flex-end" %} align-self-end{% else %} align-self-start{% endif %}">
            {% endif %}
                <div class="base-slider image-slider{% if sliderConfig.navigationArrows.value == "outside" %} has-nav-outside{% endif %}{% if sliderConfig.navigationDots.value == "outside" %} has-dots-outside{% endif %}"
                     data-base-slider="true"
                     data-base-slider-options='{{ baseSliderOptions|json_encode }}'>

                    {% block element_image_slider_inner %}
                        <div class="image-slider-container"
                             data-base-slider-container="true">
                            {% for image in element.data.sliderItems %}

                                {% set imageElement %}
                                    <div class="image-slider-item{% if loop.first != true %} is-not-first{% endif %} is-{{ sliderConfig.displayMode.value }}"{% if sliderConfig.minHeight.value and sliderConfig.displayMode.value == "cover" %} style="min-height: {{ sliderConfig.minHeight.value|trim|replace({' ':''}) }}"{% endif %}>
                                        {% set attributes = {
                                            'class': 'img-fluid image-slider-image',
                                            'alt': (image.media.translated.alt ?: ''),
                                            'title': (image.media.translated.title ?: '')
                                        } %}

                                        {% if element.config.displayMode.value == 'cover' or element.config.displayMode.value == 'contain' %}
                                            {% set attributes = attributes|merge({ 'data-object-fit': element.config.displayMode.value }) %}
                                        {% endif %}

                                        {% sw_thumbnails 'cms-image-slider-thumbnails' with {
                                            media: image.media
                                        } %}
                                    </div>
                                {% endset %}

                                {% block element_image_slider_inner_item %}
                                    <div class="image-slider-item-container">
                                        {% if image.url %}
                                            <a href="{{ image.url }}"
                                               class="image-slider-link"
                                               {% if image.newTab %}target="_blank" rel="noopener"{% endif %}>
                                                {{ imageElement }}
                                            </a>
                                        {% else %}
                                            {{ imageElement }}
                                        {% endif %}
                                    </div>
                                {% endblock %}
                            {% endfor %}
                        </div>

                        {% block element_image_slider_controls %}
                            {% if sliderConfig.navigationArrows.value %}
                                <div class="image-slider-controls-container">
                                    <div class="base-slider-controls"
                                        data-base-slider-controls="true">
                                        {% block element_image_slider_controls_items %}
                                            {% block element_image_slider_controls_items_arrows %}
                                                <button class="base-slider-controls-prev image-slider-controls-prev{% if sliderConfig.navigationArrows.value == "outside" %} is-nav-prev-outside{% elseif sliderConfig.navigationArrows.value == "inside" %} is-nav-prev-inside{% endif %}">
                                                    {% block element_image_slider_controls_items_prev_icon %}
                                                        {% sw_icon 'arrow-head-left' %}
                                                    {% endblock %}
                                                </button>
                                                <button class="base-slider-controls-next image-slider-controls-next{% if sliderConfig.navigationArrows.value == "outside" %} is-nav-next-outside{% elseif sliderConfig.navigationArrows.value == "inside" %} is-nav-next-inside{% endif %}">
                                                    {% block element_image_slider_controls_items_next_icon %}
                                                        {% sw_icon 'arrow-head-right' %}
                                                    {% endblock %}
                                                </button>
                                            {% endblock %}
                                        {% endblock %}
                                    </div>
                                </div>
                            {% endif %}
                        {% endblock %}
                    {% endblock %}
                </div>
            {% if config.verticalAlign.value %}
                </div>
            {% endif %}
        {% endblock %}
    </div>
{% endblock %}
