{block name='productdetails-attributes'}
{if $showAttributesTable}
    {et_isShopVersionAtLeast value="5.2.0-beta" assign='shopIsAtLeast52'}
    {et_isShopVersionAtLeast value="5.5.0-rc.1" assign='shopIsAtLeast55'}
    {$showProductContents=$showProductContents|default:null}
    {if $showProductContents === null}
        {* Fallback if tabs.tpl was overridden in child and does not provide the parameter $showProductContents *}
        {if !$shopIsAtLeast52 || (isset($Einstellungen.artikeldetails.artikeldetails_inhalt_anzeigen) && $Einstellungen.artikeldetails.artikeldetails_inhalt_anzeigen === 'Y')}
            {if isset($Artikel->cMasseinheitName) && isset($Artikel->fMassMenge) && $Artikel->fMassMenge > 0 && $Artikel->cTeilbar !== 'Y' && ($Artikel->fAbnahmeintervall == 0 || $Artikel->fAbnahmeintervall == 1) && isset($Artikel->cMassMenge)}
                {$showProductContents = true}
            {else}
                {$showProductContents = false}
            {/if}
        {else}
            {$showProductContents = false}
        {/if}
    {/if}
    <div class="product-attributes">
    {block name='productdetails-attributes-table'}
        <table class="{block name='productdetails-attributes-table-class'}table table-sm{/block}">
            {if $shopIsAtLeast55}
                <thead>
                    <tr>
                        <th scope="col" class="sr-only">{lang section="productDetails" key='itemInformation'}</th>
                        <th scope="col" class="sr-only">{lang section="productDetails" key='itemValue'}</th>
                    </tr>
                </thead>
                <tbody>
            {/if}
            {block name='productdetails-attributes-table-inner'}
            {if $Einstellungen.artikeldetails.merkmale_anzeigen === 'Y'}
                {block name='productdetails-attributes-characteristics'}
                    {foreach $Artikel->oMerkmale_arr as $characteristic}
                        <tr>
                            {if $shopIsAtLeast52}
                                <td>{$characteristic->getName()|escape:'html'}:</td>
                                <td class="attr-characteristic">
                                    {strip}
                                        {foreach $characteristic->getCharacteristicValues() as $characteristicValue}
                                            {if $characteristic->getType() === 'TEXT' || $characteristic->getType() === 'SELECTBOX' || $characteristic->getType() === ''}
                                                {block name='productdetails-attributes-badge'}
                                                    <a href="{$characteristicValue->getURL()}">{$characteristicValue->getValue()|escape:'html'}</a>
                                                {/block}
                                            {else}
                                                {block name='productdetails-attributes-image'}
                                                    <a href="{$characteristicValue->getURL()}"
                                                       class="text-decoration-none-util"
                                                       data-toggle="tooltip"
                                                       data-placement="top"
                                                       data-boundary="window"
                                                       title="{$characteristicValue->getValue()|escape:'html'}"
                                                       aria-label="{$characteristicValue->getValue()|escape:'html'}"
                                                    >
                                                        {$img = $characteristicValue->getImage(\JTL\Media\Image::SIZE_XS)}
                                                        {if $img !== null && strpos($img, $smarty.const.BILD_KEIN_MERKMALBILD_VORHANDEN) === false
                                                            && strpos($img, $smarty.const.BILD_KEIN_ARTIKELBILD_VORHANDEN) === false}
                                                            {include file='snippets/image.tpl'
                                                            item=$characteristicValue
                                                            square=false
                                                            srcSize='xs'
                                                            sizes='40px'
                                                            width='40'
                                                            height='40'
                                                            class='img-aspect-ratio'
                                                            alt=$characteristicValue->getValue()}
                                                        {else}
                                                            {$characteristicValue->getValue()|escape:'html'}
                                                        {/if}
                                                    </a>
                                                {/block}
                                            {/if}
                                        {/foreach}
                                    {/strip}
                                </td>
                            {else}
                                <td>{$characteristic->cName|escape:'html'}:</td>
                                <td class="attr-characteristic">
                                    {strip}
                                        {foreach $characteristic->oMerkmalWert_arr as $characteristicValue}
                                            {if $characteristic->cTyp === 'TEXT' || $characteristic->cTyp === 'SELECTBOX' || $characteristic->cTyp === ''}
                                                {block name='productdetails-attributes-badge'}
                                                    <a href="{$characteristicValue->cURLFull}">{$characteristicValue->cWert|escape:'html'}</a>
                                                {/block}
                                            {else}
                                                {block name='productdetails-attributes-image'}
                                                    <a href="{$characteristicValue->cURLFull}"
                                                       class="text-decoration-none-util"
                                                       data-toggle="tooltip"
                                                       data-placement="top"
                                                       data-boundary="window"
                                                       title="{$characteristicValue->cWert|escape:'html'}"
                                                       aria-label="{$characteristicValue->cWert|escape:'html'}"
                                                    >
                                                        {$img = $characteristicValue->getImage(\JTL\Media\Image::SIZE_XS)}
                                                        {if $img !== null && strpos($img, $smarty.const.BILD_KEIN_MERKMALBILD_VORHANDEN) === false
                                                        && strpos($img, $smarty.const.BILD_KEIN_ARTIKELBILD_VORHANDEN) === false}
                                                            {include file='snippets/image.tpl'
                                                            item=$characteristicValue
                                                            square=false
                                                            srcSize='xs'
                                                            sizes='40px'
                                                            width='40'
                                                            height='40'
                                                            class='img-aspect-ratio'
                                                            alt=$characteristicValue->cWert}
                                                        {else}
                                                            {$characteristicValue->cWert|escape:'html'}
                                                        {/if}
                                                    </a>
                                                {/block}
                                            {/if}
                                        {/foreach}
                                    {/strip}
                                </td>
                            {/if}
                        </tr>
                    {/foreach}
                {/block}
            {/if}

            {if $showShippingWeight}
                {block name='productdetails-attributes-shipping-weight'}
                    <tr>
                        <td>{lang key='shippingWeight'}:</td>
                        <td class="weight-unit">
                            {$Artikel->cGewicht} {lang key='weightUnit'}
                        </td>
                    </tr>
                {/block}
            {/if}

            {if $showProductWeight}
                {block name='productdetails-attributes-product-weight'}
                    <tr class="attr-weight">
                        <td>{lang key='productWeight'}:</td>
                        <td class="weight-unit" itemprop="weight" itemscope itemtype="https://schema.org/QuantitativeValue">
                            <span itemprop="value">{$Artikel->cArtikelgewicht}</span> <span itemprop="unitText">{lang key='weightUnit'}
                        </td>
                    </tr>
                {/block}
            {/if}

            {if $showProductContents}
                {block name='productdetails-attributes-unit'}
                    <tr class="attr-contents">
                        <td>{lang key='contents' section='productDetails'}: </td>
                        <td class="attr-value">
                            {$Artikel->cMassMenge} {$Artikel->cMasseinheitName}
                        </td>
                    </tr>
                {/block}
            {/if}

            {if $dimension && $Einstellungen.artikeldetails.artikeldetails_abmessungen_anzeigen === 'Y'}
                {block name='productdetails-attributes-dimensions'}
                    {assign var=dimensionArr value=$Artikel->getDimensionLocalized()}
                    {if count($dimensionArr) > 0}
                        <tr class="attr-dimensions">
                            <td>{lang key='dimensions' section='productDetails'}
                                ({foreach $dimensionArr as $dimkey => $dim}
                                    {$dimkey}{if !$dim@last} &times; {/if}
                                {/foreach}):
                            </td>
                            <td class="attr-value">
                                {foreach $dimensionArr as $dim}
                                    {$dim}{if $dim@last} cm {else} &times; {/if}
                                {/foreach}
                            </td>
                        </tr>
                    {/if}
                {/block}
            {/if}

            {if $Einstellungen.artikeldetails.artikeldetails_attribute_anhaengen === 'Y'
            || $Artikel->FunktionsAttribute[$smarty.const.FKT_ATTRIBUT_ATTRIBUTEANHAENGEN]|default:0 == 1}
                {block name='productdetails-attributes-shop-attributes'}
                    {foreach $Artikel->Attribute as $Attribut}
                        <tr class="attr-custom">
                            <td>{$Attribut->cName}: </td>
                            <td class="attr-value">{$Attribut->cWert}</td>
                        </tr>
                    {/foreach}
                {/block}
            {/if}
            {/block}
            {if $shopIsAtLeast55}
                </tbody>
            {/if}
        </table>
    {/block}
    </div>
{/if}
{/block}
