<?php $_shouldextend[1]=1; ?>

<?php $this->startSection('content'); ?>
 <?php echo $this->runChild('parts.back', ['hash' => 'list-item-' . $res->id]); ?>

 <div class="item-page flex">
 <div class="photos">
 <?php if(isset($res->productGallery)): ?>
 <?php $__currentLoopData = $res->productGallery; $this->addLoop($__currentLoopData);$this->getFirstLoop();
 foreach($__currentLoopData as $galleryItem): $loop = $this->incrementLoopIndices();  ?>
 <a class="item gallery-item" href="<?php echo \htmlentities(assetsUserfiles($galleryItem['img'])??'', ENT_QUOTES, 'UTF-8', false); ?>">
 <img alt="<?php echo \htmlentities($galleryItem['title']??'', ENT_QUOTES, 'UTF-8', false); ?>" src="<?php echo \htmlentities(thumb($galleryItem['img'])??'', ENT_QUOTES, 'UTF-8', false); ?>">
 </a>
 <?php endforeach; $this->popLoop(); $loop = $this->getFirstLoop(); ?>
 <?php endif; ?>
 </div>

 <div class="info">
 <?php if(isset($res->productArticul)): ?>
 <div class="articul">
 <?php echo \htmlentities($res->productArticul??'', ENT_QUOTES, 'UTF-8', false); ?>

 </div>
 <?php endif; ?>

 <h1>
 <?php echo \htmlentities($res->pagetitle??'', ENT_QUOTES, 'UTF-8', false); ?>

 </h1>

 <?php 
 $priceTv = getPriceTv('productPrice');
 $oldPriceTv = getPriceTv('productOldPrice');
 ?>

 <div class="price">
 <?php if(isset($res->$oldPriceTv) && $res->$oldPriceTv != ''): ?>
 <span class="old">
 <?php echo \htmlentities($res->$oldPriceTv??'', ENT_QUOTES, 'UTF-8', false); ?>

 <?php echo \htmlentities(__('site.currency')??'', ENT_QUOTES, 'UTF-8', false); ?>

 </span>

 <div class="new">
 <?php echo \htmlentities($res->$priceTv??'', ENT_QUOTES, 'UTF-8', false); ?>

 <?php echo \htmlentities(__('site.currency')??'', ENT_QUOTES, 'UTF-8', false); ?>

 </div>
 <?php elseif(isset($res->$priceTv) && $res->$priceTv != ''): ?>
 <?php echo \htmlentities($res->$priceTv??'', ENT_QUOTES, 'UTF-8', false); ?>

 <?php echo \htmlentities(__('site.currency')??'', ENT_QUOTES, 'UTF-8', false); ?>

 <?php endif; ?>
 </div>

 <div x-data="{
 articul: '<?php echo $res->productArticul . '_' . currLang(); ?>',
 price: '<?php echo \htmlentities($res->$priceTv??'', ENT_QUOTES, 'UTF-8', false); ?>',
 currency: '<?php echo \htmlentities(currency()??'', ENT_QUOTES, 'UTF-8', false); ?>',
 }">
 <form x-bind="form" x-data="addCart" x-ref="addCartForm">
 <input name="productId" type="hidden" value="<?php echo \htmlentities($res->id??'', ENT_QUOTES, 'UTF-8', false); ?>">

 <?php if(isset($res->productColor)): ?>
 <?php ($productColor = current($res->productColor)); ?>

 <?php if(isset($productColor['key'])): ?>
 <script>
 const productColor = "<?php echo \htmlentities($productColor['key']??'', ENT_QUOTES, 'UTF-8', false); ?>"
 </script>

 <div class="colors-title">
 <?php echo \htmlentities($productColor['title']??'', ENT_QUOTES, 'UTF-8', false); ?>

 </div>

 <div class="colors">
 <?php ($colorId = "product-color-{$productColor['key']}"); ?>

 <input checked class="checkbox" id="<?php echo \htmlentities($colorId??'', ENT_QUOTES, 'UTF-8', false); ?>" name="color" type="radio"
 value="<?php echo \htmlentities($productColor['key']??'', ENT_QUOTES, 'UTF-8', false); ?>" x-model="color">

 <div class="color-item active"
 for="<?php echo \htmlentities($colorId??'', ENT_QUOTES, 'UTF-8', false); ?>"
 title="<?php echo \htmlentities($productColor['title']??'', ENT_QUOTES, 'UTF-8', false); ?>"
 x-bind="options"
 style="background: <?php echo \htmlentities($productColor['options']['background']??'', ENT_QUOTES, 'UTF-8', false); ?>;">
 </div>

 <?php if(isset($groupItems)): ?>
 <?php $__currentLoopData = $groupItems; $this->addLoop($__currentLoopData);$this->getFirstLoop();
 foreach($__currentLoopData as $item): $loop = $this->incrementLoopIndices();  ?>
 <?php ($productGroupColor = current($item->productColor)); ?>
 <a class="color-item"
 title="<?php echo \htmlentities($productGroupColor['title']??'', ENT_QUOTES, 'UTF-8', false); ?>"
 href="<?php echo \htmlentities(makeUrl($item->id, $_GET)??'', ENT_QUOTES, 'UTF-8', false); ?>"
 x-bind="color"
 data-color="<?php echo \htmlentities($productGroupColor['key']??'', ENT_QUOTES, 'UTF-8', false); ?>"
 style="background: <?php echo \htmlentities($productGroupColor['options']['background']??'', ENT_QUOTES, 'UTF-8', false); ?>;">
 </a>
 <?php endforeach; $this->popLoop(); $loop = $this->getFirstLoop(); ?>
 <?php endif; ?>
 </div>
 <?php endif; ?>
 <?php endif; ?>

 <p>
 <?php ($text = isset($categoryOptions['otherColorsText']) ? $categoryOptions['otherColorsText'] : 'product_text_other_color'); ?>

 <?php echo \htmlentities(__('site.' . $text)??'', ENT_QUOTES, 'UTF-8', false); ?>

 </p>

 <?php if(isset($res->productSize)): ?>
 <div class="sizes-outer">
 <div class="sizes-stock-out load-invisible" x-show="stockOut" x-transition.duration.500ms>
 <?php echo \htmlentities(__('site.size_stock_out')??'', ENT_QUOTES, 'UTF-8', false); ?>

 </div>

 <div @mouseout="stockOut=false" class="sizes flex">
 <?php $__currentLoopData = $res->productSize; $this->addLoop($__currentLoopData);$this->getFirstLoop();
 foreach($__currentLoopData as $sizeItem): $loop = $this->incrementLoopIndices();  ?>
 <?php 
 $productStockSize = $res->productStockSize ?? [];
 $sizeId = "product-size-$sizeItem";
 $disabled = array_search($sizeItem, $productStockSize) === false ? 'disabled' : '';
 ?>

 <input <?php echo \htmlentities($disabled??'', ENT_QUOTES, 'UTF-8', false); ?> class="checkbox <?php echo \htmlentities($disabled??'', ENT_QUOTES, 'UTF-8', false); ?>" id="<?php echo \htmlentities($sizeId??'', ENT_QUOTES, 'UTF-8', false); ?>"
 name="size" type="radio" value="<?php echo \htmlentities($sizeItem??'', ENT_QUOTES, 'UTF-8', false); ?>" x-model="size">

 <label @mouseover="stockOutToggle()" class="<?php echo \htmlentities($disabled ? 'not-qty' : 'with-qty'??'', ENT_QUOTES, 'UTF-8', false); ?>"
 for="<?php echo \htmlentities($sizeId??'', ENT_QUOTES, 'UTF-8', false); ?>" title="<?php echo \htmlentities($sizeItem??'', ENT_QUOTES, 'UTF-8', false); ?>">
 <?php echo \htmlentities($sizeItem??'', ENT_QUOTES, 'UTF-8', false); ?>

 </label>
 <?php endforeach; $this->popLoop(); $loop = $this->getFirstLoop(); ?>
 </div>
 </div>
 <?php endif; ?>

 <?php if (empty($categoryOptions['tableSizeHide'])): ?>
 <div class="sizes-link">
 <a @click.prevent="$store.modalStore.open('size')" href="<?php echo \htmlentities(resUrl('size-table')??'', ENT_QUOTES, 'UTF-8', false); ?>"
 id="product-table-size-link" x-data>
 <?php echo \htmlentities(__('site.size_table')??'', ENT_QUOTES, 'UTF-8', false); ?>

 </a>
 </div>

 <div class="size popup" data-key="size" x-bind="modal" x-data="modal">
 <div class="window">
 <a class="close" x-bind="close"></a>

 <img alt="" id="table-size-img" src="<?php echo \htmlentities(assetsUserfiles('size/size.jpg')??'', ENT_QUOTES, 'UTF-8', false); ?>">
 </div>
 </div>
 <?php endif; ?>

 <?php if(isset($res->productSize)): ?>
 <div class="relative">
 <div class="add-button-message form__error" x-text="errorMessage"></div>

 <div class="add" x-bind="button">
 <?php echo \htmlentities(__('cart.add_to_cart')??'', ENT_QUOTES, 'UTF-8', false); ?>

 </div>
 </div>
 <?php endif; ?>
 </form>
 </div>

 <?php 
 $links = [
 'site.details' => $res->content,
 'site.delivery' => resParameter('productDeliveryContent', 'home'),
 'site.payment' => resParameter('productPaymentContent', 'home'),
 'site.return_exchange' => resParameter('productExchangeContent', 'home'),
 ];
 ?>

 <div class="links">
 <?php $__currentLoopData = $links; $this->addLoop($__currentLoopData);$this->getFirstLoop();
 foreach($__currentLoopData as $titleLink => $contentLink): $loop = $this->incrementLoopIndices();  ?>
 <div x-data="{ open: false }">
 <button :class="open && 'open'" @click="open = open ? false : true" class="links-title">
 <?php echo \htmlentities(__($titleLink)??'', ENT_QUOTES, 'UTF-8', false); ?>

 </button>

 <div :class="open && 'open'" class="links-content" x-show="open">
 <?php echo $contentLink; ?>

 </div>
 </div>
 <?php endforeach; $this->popLoop(); $loop = $this->getFirstLoop(); ?>
 </div>

 <?php if (empty($categoryOptions['atelierBlockHide'])): ?>
 <div class="atelier-block">
 <div class="atelier-block__title">
 <?php echo \htmlentities(__('site.atelier_block_title')??'', ENT_QUOTES, 'UTF-8', false); ?>

 </div>

 <a class="atelier-block__link" href="<?php echo \htmlentities(resUrl('atelier')??'', ENT_QUOTES, 'UTF-8', false); ?>">
 <?php echo \htmlentities(__('site.atelier_block_link')??'', ENT_QUOTES, 'UTF-8', false); ?>

 </a>

 <div class="atelier-block__text">
 <?php echo \htmlentities(__('site.atelier_block_text')??'', ENT_QUOTES, 'UTF-8', false); ?>

 </div>
 </div>
 <?php endif; ?>

 <?php if(isset($categoryOptions['oneclickDisplay'])): ?>
 <?php echo $this->runChild('oneclick.oneclick', [
 'text' => isset($categoryOptions['oneclickText']) ? $categoryOptions['oneclickText'] : null,
 ]); ?>
 <?php endif; ?>
 </div>
</div>

<?php if(isset($res->productAdditional)): ?>
 <?php 
 $additional = resCollection(['template' => 'товар', 'withTv' => true], ['alias:IN' => $res->productAdditional]);
 ?>

 <div class="more-items-block">
 <div class="block-name">
 <?php echo \htmlentities(__('site.you_may_like_it')??'', ENT_QUOTES, 'UTF-8', false); ?>

 </div>

 <div class="more-items-block-list">
 <?php $__currentLoopData = $additional; $this->addLoop($__currentLoopData);$this->getFirstLoop();
 foreach($__currentLoopData as $item): $loop = $this->incrementLoopIndices();  ?>
 <?php echo $this->runChild('category.item', ['item' => $item]); ?>
 <?php endforeach; $this->popLoop(); $loop = $this->getFirstLoop(); ?>
 </div>
 </div>
<?php endif; ?>

<script>
 const productTableSize = {
 file: "<?php echo \htmlentities(assetsUserfiles('size/')??'', ENT_QUOTES, 'UTF-8', false); ?>",
 parent: "<?php echo \htmlentities(getRes($res->parent)->alias??'', ENT_QUOTES, 'UTF-8', false); ?>",
 }
</script>

<script>
 window.dataLayer = window.dataLayer || [];
 const data = {
 'event': 'review_goodspage',
 'goods_id': '<?php echo \htmlentities($res->id??'', ENT_QUOTES, 'UTF-8', false); ?>'
 };
 window.dataLayer.push(data)
 console.log('dataLayer', data);
</script>
<?php $this->stopSection(); ?>

<?php if (isset($_shouldextend[1])) { echo $this->runChild('layouts.main'); } ?>