{% block component_line_item_quantity %}
    {% if redirectTo is not defined %}
        {% set redirectTo = 'frontend.checkout.cart.page' %}
    {% endif %}

    {% if formAction is not defined %}
        {% set formAction = path('frontend.checkout.line-item.change-quantity', { 'id': lineItem.id }) %}
    {% endif %}

    {% if showQuantitySelect is not defined %}
        {% set showQuantitySelect = true %}
    {% endif %}

    {# @var quantityInformation \Shopware\Core\Checkout\Cart\LineItem\QuantityInformation #}
    {% set quantityInformation = lineItem.quantityInformation %}
    {% if quantityInformation.maxPurchase %}
        {% set maxQuantity = quantityInformation.maxPurchase %}
    {% else %}
        {% set maxQuantity = config('core.cart.maxQuantity') %}
    {% endif %}

    {% set DOWNLOAD_STATE = constant('Shopware\\Core\\Content\\Product\\State::IS_DOWNLOAD') %}
    {% set isDigital = lineItem.states is defined and DOWNLOAD_STATE in lineItem.states and (DOWNLOAD_STATE not in lineItem.states or quantityInformation.maxPurchase === 1) %}

    {% block component_line_item_quantity_inner %}
        <div class="row line-item-quantity-row">

            {% block component_line_item_quantity_label %}
                <div class="line-item-quantity-label">
                    {{ "checkout.cartHeaderQuantity"|trans|sw_sanitize }}
                </div>
            {% endblock %}

            {% block component_line_item_quantity_select_wrapper %}
                <div class="line-item-quantity-select-wrapper">

                    {% if showQuantitySelect and lineItem.quantityInformation and lineItem.stackable and nestingLevel < 1 %}
                        {% block component_line_item_quantity_select_form %}
                            {% set autoSubmitOptions = {
                                delayChangeEvent: 800,
                            } %}
                            <form action="{{ formAction }}"
                                  class="line-item-quantity-container {% if isDigital %}disabled{% endif %}"
                                  method="post"
                                  {% if displayMode == 'default' %}
                                  data-form-auto-submit="true"
                                  data-form-auto-submit-options="{{ autoSubmitOptions|json_encode }}"
                                  {% endif %}
                            >

                                {% block component_line_item_quantity_redirect %}
                                    <input type="hidden"
                                           name="redirectTo"
                                           value="{{ redirectTo }}">
                                    <input type="hidden"
                                           name="redirectParameters"
                                           value="{{ redirectParameters }}">
                                {% endblock %}

                                {% set selectQuantityThreshold = 100 %}
                                {% block component_line_item_quantity_select %}
                                    {% block component_line_item_quantity_select_input %}
                                        <div class="input-group line-item-quantity-group quantity-selector-group" data-quantity-selector="true">
                                            <button
                                                {% if isDigital %}disabled="disabled"{% endif %}
                                                type="button"
                                                class="btn btn-outline-light btn-minus js-btn-minus"
                                                aria-label="{{ "component.product.quantitySelect.decrease"|trans|striptags }}"
                                            >
                                                {% sw_icon 'minus' style {'size': 'xs'} %}
                                            </button>
                                            <input
                                                {% if isDigital %}disabled="disabled"{% endif %}
                                                type="number"
                                                name="quantity"
                                                class="form-control js-quantity-selector quantity-selector-group-input quantity-input-{{ lineItem.id }} {% if displayMode === 'offcanvas' %} js-offcanvas-cart-change-quantity-number{% endif %}"
                                                min="{{ quantityInformation.minPurchase }}"
                                                max="{{ maxQuantity }}"
                                                step="{{ quantityInformation.purchaseSteps }}"
                                                value="{{ lineItem.quantity }}"
                                                aria-label="{{ "component.product.quantitySelect.label"|trans|striptags }}"
                                            />
                                            <button
                                                {% if isDigital %}disabled="disabled"{% endif %}
                                                type="button"
                                                class="btn btn-outline-light btn-plus js-btn-plus"
                                                aria-label="{{ "component.product.quantitySelect.increase"|trans|striptags }}"
                                            >
                                                {% sw_icon 'plus' style {'size': 'xs'} %}
                                            </button>
                                        </div>
                                    {% endblock %}
                                {% endblock %}
                            </form>
                        {% endblock %}
                    {% else %}
                        {% block component_line_item_quantity_display %}
                            <div class="d-flex justify-content-sm-center justify-content-end">
                                {{ lineItem.quantity }}
                            </div>
                        {% endblock %}
                    {% endif %}
                </div>
            {% endblock %}
        </div>
    {% endblock %}
{% endblock %}
