{block name='account-index'}
    {$lazyLoadImages=$lazyLoadImages|default:true}
    {et_isShopVersionAtLeast value="5.2.0-beta" assign='shopIsAtLeast52'}
    {et_isShopVersionAtLeast value="5.2.3" assign='shopIsAtLeast523'}
    {et_isShopVersionAtLeast value="5.4.0-rc.1" assign='shopIsAtLeast54'}
    {block name='include-header'}
        {include file='layout/header.tpl'}
    {/block}

    {block name='account-index-content'}
        {if isset($smarty.get.reg)}
            {block name='account-index-alert'}
                <div class="container{if isset($Link) && $Link->getIsFluid() === true}-fluid{/if}">
                    <div role="alert" class="alert alert-success">
                        {lang key='accountCreated' section='global'}
                    </div>
                </div>
            {/block}
        {/if}
        {block name='account-index-include-extension'}
            {include file='snippets/extension.tpl'}
        {/block}

        {if isset($nWarenkorb2PersMerge) && $nWarenkorb2PersMerge === 1}
            {block name='account-index-script-basket-merge'}
                {inline_script}<script>
                    eModal.addLabel('{lang key='yes' section='global' addslashes=true}', '{lang key='no' section='global' addslashes=true}');
                    var options = {
                        message: '{lang key='basket2PersMerge' section='login' addslashes=true}',
                        label: '{lang key='yes' section='global' addslashes=true}',
                        title: '{lang key='basket' section='global' addslashes=true}'
                    };
                    eModal.confirm(options).then(
                        function() {
                            window.location = "{get_static_route id='bestellvorgang.php'}?basket2Pers=1&token={$smarty.session.jtl_token}"
                        }{if $shopIsAtLeast523},
                        function() {
                            window.location = "{get_static_route id='jtl.php'}?updatePersCart=1&token={$smarty.session.jtl_token}"
                        }{/if}
                    );
                </script>{/inline_script}
            {/block}
        {/if}

        {if isset($Link) && $Link->getID() > 0 && $Link->getLinkType() === $smarty.const.LINKTYP_LOGIN && $step === 'mein Konto'}
            {* Load the my account grid *}
            {* Render the title separately *}
            {block name='account-index-heading'}
                {opcMountPoint id='opc_before_heading' inContainer=false}
                <div class="container{if isset($Link) && $Link->getIsFluid() === true}-fluid{/if}">
                    <div class="h2">{lang key='welcome' section='login'} {$smarty.session.Kunde->cVorname} {$smarty.session.Kunde->cNachname}</div>
                </div>
            {/block}
            {* Actual content will come in from the cms_content.tpl which includes account/my_account.tpl, if we are not a real cms link or embedded in checkout, we render the normal content *}
            {et_renderGrid id="cms_{$Link->getID()}" fallbackId="cms_main"}
        {else}
            <div class="container{if isset($Link) && $Link->getIsFluid() === true}-fluid{/if}">
                {opcMountPoint id='opc_before_account'}
                <div class="row" id="account">
                    <div class="col col-12">
                        {if $step === 'login'}
                            {block name='account-index-include-login'}
                                {include file='account/login.tpl'}
                            {/block}
                        {elseif $step === 'mein Konto'}
                            {block name='account-index-include-my-account'}
                                {include file='account/my_account.tpl'}
                            {/block}
                        {elseif $step === 'rechnungsdaten'}
                            {block name='account-index-include-address-form'}
                                {include file='account/address_form.tpl'}
                            {/block}
                        {elseif $shopIsAtLeast52 && $step === 'lieferadressen'}
                            {block name='account-index-include-shippingaddress-form'}
                                {include file='account/shipping_address_form.tpl'}
                            {/block}
                        {elseif $step === 'passwort aendern'}
                            {block name='account-index-include-change-password'}
                                {include file='account/change_password.tpl'}
                            {/block}
                        {elseif $shopIsAtLeast54 && $step === 'manageTwoFA'}
                            {block name='account-index-include-manage-two-fa'}
                                {include file='account/two_fa.tpl'}
                            {/block}
                        {elseif $step === 'bestellung'}
                            {block name='account-index-include-order-details'}
                                {include file='account/order_details.tpl' lazyLoadImages=$lazyLoadImages}
                            {/block}
                        {elseif $step === 'bestellungen'}
                            {block name='account-index-include-orders'}
                                {include file='account/orders.tpl'}
                            {/block}
                        {elseif $step === 'account loeschen'}
                            {block name='account-index-include-delete-account'}
                                {include file='account/delete_account.tpl'}
                            {/block}
                        {elseif $step === 'kunden_werben_kunden'}
                            {block name='account-index-include-customers-recruiting'}
                                {include file='account/customers_recruiting.tpl'}
                            {/block}
                        {elseif $step === 'bewertungen'}
                            {block name='account-index-include-feedback'}
                                {include file='account/feedback.tpl'}
                            {/block}
                        {elseif $step === 'newRMA'}
                            {block name='account-index-include-new-rma'}
                                {if isset($Einstellungen.global.global_rma_enabled) && $Einstellungen.global.global_rma_enabled === 'Y'}
                                    {include file='account/rma.tpl'}
                                {/if}
                            {/block}
                        {elseif $step === 'showRMA'}
                            {block name='account-index-include-show-rma'}
                                {if isset($Einstellungen.global.global_rma_enabled) && $Einstellungen.global.global_rma_enabled === 'Y'}
                                    {include file='account/rma_summary.tpl' showButtons=false}
                                {/if}
                            {/block}
                        {elseif $step === 'rmas'}
                            {block name='account-index-include-rmalist'}
                                {if isset($Einstellungen.global.global_rma_enabled) && $Einstellungen.global.global_rma_enabled === 'Y'}
                                    {include file='account/rma_list.tpl'}
                                {/if}
                            {/block}
                        {else}
                            {block name='account-index-include-my-account-default'}
                                {include file='account/my_account.tpl'}
                            {/block}
                        {/if}
                    </div>
                </div>
            </div>
        {/if}
    {/block}

    {block name='account-index-include-footer'}
        {include file='layout/footer.tpl'}
    {/block}
{/block}
