<!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
{% block sw_order_create %}
<sw-card-view>
    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_order_create_address_modal %}
    <sw-order-create-address-modal
        v-if="showAddressModal"
        :address="address"
        :add-address-modal-title="addAddressModalTitle"
        :edit-address-modal-title="editAddressModalTitle"
        :customer="customer"
        :cart="cart"
        @close-modal="closeModal"
        @set-customer-address="setCustomerAddress"
    />
    {% endblock %}

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_order_create_promotion_modal %}
    <sw-order-create-promotion-modal
        v-if="showPromotionModal"
        :is-loading="isLoading"
        :currency="currency"
        :sales-channel-id="customer.salesChannelId"
        @close="onClosePromotionModal"
        @save="onSavePromotionModal"
    />
    {% endblock %}

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_order_create_details %}
    <sw-card
        :title="$tc('sw-order.createBase.labelDetailsCard')"
        :is-loading="isLoadingDetail"
        position-identifier="sw-order-create-base-details"
        class="sw-order-create__card"
    >
        <template #grid>
            <sw-container
                type="row"
                class="sw-order-user-card"
            >
                <sw-card-section>
                    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                    {% block sw_order_create_details_header %}
                    <sw-order-create-details-header
                        :customer="customer"
                        :order-date="orderDate"
                        :cart-price="cartPrice"
                        :currency="currency"
                        @on-select-existing-customer="onSelectExistingCustomer"
                    />
                    {% endblock %}
                    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                    {% block sw_order_create_details_body %}
                    <sw-order-create-details-body
                        :customer="customer"
                        :is-customer-active="isCustomerActive"
                        @on-edit-billing-address="onEditBillingAddress"
                        @on-edit-shipping-address="onEditShippingAddress"
                    />
                    {% endblock %}
                </sw-card-section>
                <sw-card-section
                    secondary
                    divider="top"
                >
                    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                    {% block sw_order_create_details_footer %}
                    <sw-order-create-details-footer
                        :customer="customer"
                        :is-customer-active="isCustomerActive"
                        :cart="cart"
                        @loading-change="updateLoading"
                    />
                    {% endblock %}
                </sw-card-section>
            </sw-container>
        </template>
    </sw-card>
    {% endblock %}

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_order_create_base_line_items_card %}
    <sw-card
        :title="$tc('sw-order.createBase.cardTitleLineItems')"
        :is-loading="isLoading"
        position-identifier="sw-order-create-base-line-items"
        class="sw-order-create__card sw-order-create-base__line-item-grid-card"
    >
        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_order_create_base_line_items_card_rows %}
        <template #grid>
            <sw-container type="row">
                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                {% block sw_order_create_base_line_items_grid %}
                <sw-order-line-items-grid-sales-channel
                    ref="sw-order-line-item-grid-sales-channel"
                    :cart="cart"
                    :currency="currency"
                    :sales-channel-id="salesChannelId"
                    :is-loading="isLoading"
                    :is-customer-active="isCustomerActive"
                    editable
                    @on-save-item="onSaveItem"
                    @on-remove-items="onRemoveItems"
                />
                {% endblock %}

                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                {% block sw_order_create_base_line_items_summary %}
                <sw-card-section
                    v-show="cartLineItems.length"
                    divider="top"
                    secondary
                    slim
                >
                    <sw-container
                        columns="1fr 1fr"
                        class="sw-order-create-summary"
                    >
                        <div>
                            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                            {% block sw_order_create_base_line_items_switch_promotions %}
                            <sw-switch-field
                                v-model:value="disabledAutoPromotionVisibility"
                                class="sw-order-create-summary__switch-promotions"
                                :label="$tc('sw-order.promotionModal.labelTitle')"
                            />
                            {% endblock %}
                            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                            {% block sw_order_create_base_line_items_voucher_field %}
                            <sw-order-promotion-tag-field
                                v-model:value="promotionCodeTags"
                                :disabled="!hasLineItem"
                                :currency="currency"
                                :label="$tc('sw-order.createBase.labelAddPromotion')"
                                :placeholder="$tc('sw-order.createBase.placeholderAddPromotion')"
                                :error="promotionError"
                                @on-remove-code="onRemoveExistingCode"
                            />
                            {% endblock %}
                        </div>
                        <sw-description-list
                            grid="1fr 1fr"
                            class="sw-order-create-summary__data"
                        >
                            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                            {% block sw_order_create_base_line_items_summary_entries %}
                            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                            {% block sw_order_create_base_line_items_summary_amount %}
                            <dt>{{ $tc('sw-order.createBase.summaryLabelAmount') }}</dt>
                            <dd>{{ currencyFilter(cartPrice ? cartPrice.positionPrice : 0, currency.isoCode) }}</dd>
                            {% endblock %}

                            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                            {% block sw_order_create_base_line_items_summary_shipping_cost %}
                            <template v-if="cartDelivery">
                                <dt>{{ $tc('sw-order.createBase.summaryLabelShippingCosts') }}</dt>
                                <dd>
                                    <sw-order-saveable-field
                                        v-tooltip="{
                                            showDelay: 300,
                                            message: shippingCostsDetail,
                                            disabled: taxStatus === 'tax-free'
                                        }"
                                        type="number"
                                        editable
                                        :value="cartDelivery.shippingCosts.totalPrice"
                                        @value-change="onShippingChargeEdited"
                                        @update:value="onShippingChargeUpdated"
                                    >
                                        {{ currencyFilter(cartDelivery.shippingCosts.totalPrice, currency.isoCode) }}
                                    </sw-order-saveable-field>
                                </dd>
                            </template>
                            <template
                                v-for="(_, index) in cartDeliveryDiscounts"
                                :key="index"
                            >
                                <dt>
                                    {{ $tc('sw-order.createBase.discountLabelShippingCosts') }}
                                </dt>
                                <dd>
                                    {{ currencyFilter(delivery.shippingCosts.totalPrice, currency.isoCode) }}
                                </dd>
                            </template>
                            {% endblock %}

                            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                            {% block sw_order_create_base_line_items_summary_amount_without_tax %}
                            <template v-if="taxStatus !== 'tax-free'">
                                <dt><strong>{{ $tc('sw-order.createBase.summaryLabelAmountWithoutTaxes') }}</strong></dt>
                                <dd><strong>{{ currencyFilter(cartPrice ? cartPrice.netPrice : 0, currency.isoCode) }}</strong></dd>
                            </template>
                            {% endblock %}

                            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                            {% block sw_order_create_base_line_items_summary_taxes %}
                            <template v-if="taxStatus !== 'tax-free'">
                                <template
                                    v-for="(calculatedTax, index) in filteredCalculatedTaxes"
                                    :key="index"
                                >
                                    <dt>
                                        {{ $tc('sw-order.createBase.summaryLabelTaxes', 1, { taxRate: calculatedTax.taxRate }) }}
                                    </dt>
                                    <dd>
                                        {{ currencyFilter(calculatedTax.tax, currency.isoCode) }}
                                    </dd>
                                </template>
                            </template>
                            {% endblock %}

                            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                            {% block sw_order_create_base_line_items_summary_amount_total %}
                            <template v-if="taxStatus !== 'tax-free'">
                                <dt><strong>{{ $tc('sw-order.createBase.summaryLabelAmountTotal') }}</strong></dt>
                                <dd><strong>{{ currencyFilter(orderTotal, currency.isoCode) }}</strong></dd>
                                <template v-if="displayRounded">
                                    <dt><strong>{{ $tc('sw-order.createBase.summaryLabelAmountTotalRounded') }}</strong></dt>
                                    <dd><strong>{{ currencyFilter(cart.price.totalPrice, currency.isoCode) }}</strong></dd>
                                </template>
                            </template>
                            {% endblock %}

                            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                            {% block sw_order_create_base_line_items_summary_amount_free_tax %}
                            <template v-if="taxStatus === 'tax-free'">
                                <dt><strong>{{ $tc('sw-order.detailBase.summaryLabelAmount') }}</strong></dt>
                                <dd><strong>{{ currencyFilter(cart.price.totalPrice, currency.isoCode) }}</strong></dd>
                            </template>
                            {% endblock %}
                            {% endblock %}
                        </sw-description-list>
                    </sw-container>
                </sw-card-section>
                {% endblock %}
            </sw-container>
        </template>
        {% endblock %}
    </sw-card>
    {% endblock %}
</sw-card-view>
{% endblock %}
