<?php if (!function_exists('renderBlocks')):
  function renderBlocks($context, $item) {
    $journal3 = $context['journal3'];
    ?>
    <?php if ($item['blockLink']['href']): ?>
      <a class="slide-link" href="<?php echo $item['blockLink']['href']; ?>" <?php echo $journal3->linkAttrs($item['blockLink']); ?> aria-hidden="true" tabindex="-1"></a>
    <?php endif; ?>
    <?php if ($context['display'] == 'grid' && $context['titlePosition'] == 'block' && $item['title']): ?>
      <h3 class="title module-title block-title"><?php echo $item['title']; ?></h3>
    <?php endif; ?>
    <div class="block-body expand-block">
      <?php if ($item['header'] == 'image' || $item['header'] == 'category_image'): ?>
        <?php if ($journal3->get('performanceLazyLoadImagesStatus') && $context['lazyLoad']): ?>
          <div class="block-header block-head-image">
          <?php if ($item['blockHeaderLink']['href']): ?>
            <a class="slide-link" href="<?php echo $item['blockHeaderLink']['href']; ?>" <?php echo $journal3->linkAttrs($item['blockHeaderLink']); ?> aria-hidden="true" tabindex="-1">
              <img src="<?php echo $context['dummy_image']; ?>" data-src="<?php echo $item['image']; ?>" <?php if (isset($item['image2x']) && $item['image2x']): ?>data-srcset="<?php echo $item['image']; ?> 1x, <?php echo $item['image2x']; ?> 2x" <?php endif; ?> alt="<?php echo $item['alt']; ?>" width="<?php echo $context['imageDimensions']['width']; ?>" height="<?php echo $context['imageDimensions']['height']; ?>" class="block-image lazyload"/>
            </a>
          <?php else: ?>
            <img src="<?php echo $context['dummy_image']; ?>" data-src="<?php echo $item['image']; ?>" <?php if (isset($item['image2x']) && $item['image2x']): ?>data-srcset="<?php echo $item['image']; ?> 1x, <?php echo $item['image2x']; ?> 2x" <?php endif; ?> alt="<?php echo $item['alt']; ?>" width="<?php echo $context['imageDimensions']['width']; ?>" height="<?php echo $context['imageDimensions']['height']; ?>" class="block-image lazyload"/>
          <?php endif; ?>
         <?php if ($context['display'] == 'grid' && $context['titlePosition'] == 'header' && $item['title']): ?>
           <h3 class="title module-title block-title"><?php echo $item['title']; ?></h3>
         <?php endif; ?>
          </div>
        <?php else: ?>
          <div class="block-header block-head-image">
            <?php if ($item['blockHeaderLink']['href']): ?>
              <a class="slide-link" href="<?php echo $item['blockHeaderLink']['href']; ?>" <?php echo $journal3->linkAttrs($item['blockHeaderLink']); ?> aria-hidden="true" tabindex="-1">
                <img src="<?php echo $item['image']; ?>" <?php if (isset($item['image2x']) && $item['image2x']): ?>srcset="<?php echo $item['image']; ?> 1x, <?php echo $item['image2x']; ?> 2x" <?php endif; ?> alt="<?php echo $item['alt']; ?>" width="<?php echo $context['imageDimensions']['width']; ?>" height="<?php echo $context['imageDimensions']['height']; ?>" class="block-image"/>
              </a>
            <?php else: ?>
            <img src="<?php echo $item['image']; ?>" <?php if (isset($item['image2x']) && $item['image2x']): ?>srcset="<?php echo $item['image']; ?> 1x, <?php echo $item['image2x']; ?> 2x" <?php endif; ?> alt="<?php echo $item['alt']; ?>" width="<?php echo $context['imageDimensions']['width']; ?>" height="<?php echo $context['imageDimensions']['height']; ?>" class="block-image"/>
            <?php endif; ?>
          <?php if ($context['display'] == 'grid' && $context['titlePosition'] == 'header' && $item['title']): ?>
            <h3 class="title module-title block-title"><?php echo $item['title']; ?></h3>
          <?php endif; ?>
          </div>
        <?php endif; ?>
      <?php elseif ($item['header'] == 'icon'): ?>
        <div class="block-header block-header-icon">
        <em class="icon icon-block"></em>
         <?php if ($context['display'] == 'grid' && $context['titlePosition'] == 'header' && $item['title']): ?>
           <h3 class="title module-title block-title"><?php echo $item['title']; ?></h3>
         <?php endif; ?>
        </div>
      <?php elseif ($item['text'] == 'text'): ?>
        <div class="block-header block-header-text">
        <span class="block-header-text"><?php echo $item['text']; ?></span>
        <?php if ($context['display'] == 'grid' && $context['titlePosition'] == 'header' && $item['title']): ?>
         <h3 class="title module-title block-title"><?php echo $item['title']; ?></h3>
        <?php endif; ?>
        </div>
      <?php endif; ?>
      <div class="block-wrapper">
        <?php if ($context['display'] == 'grid' && $context['titlePosition'] == 'after' && $item['title']): ?>
           <h3 class="title module-title block-title"><?php echo $item['title']; ?></h3>
        <?php endif; ?>
        <div class="block-content <?php if ($item['expandButton']): ?>expand-content<?php endif; ?> block-<?php echo $item['contentType']; ?>">
          <?php echo $item['content']; ?>
          <?php if ($item['expandButton']): ?>
            <div class="block-expand-overlay"><a class="block-expand btn" href="javascript:;" aria-hidden="true"></a></div>
          <?php endif; ?>
          <?php if (!empty($item['gallery'])) { ?>
          <div class="block-gallery"><?php echo $item['gallery']; ?></div>
          <?php } ?>
        </div>
        <?php if ($item['footer'] == 'text'): ?>
          <div class="block-footer"><?php echo $item['footerText']; ?></div>
        <?php elseif ($item['footer'] == 'button'): ?>
          <div class="block-footer"><a class="btn" href="<?php echo $item['footerButtonLink']['href']; ?>" <?php echo $journal3->linkAttrs($item['footerButtonLink']); ?>><?php echo $item['footerButton']; ?></a></div>
        <?php endif; ?>
      </div>
    </div>
    <?php
  }
endif; ?>
<div class="<?php echo $journal3->classes($classes); ?>">
  <button aria-label="Edit" class="admin-edit" type="button" data-edit="<?php echo $edit; ?>"><em class="fa fa-pencil" data-placement="auto" data-toggle="tooltip-hover" data-tooltip-class="admin-edit-tooltip" title="Edit <?php echo $name; ?>"></em></button>
  <?php if ($title): ?>
    <h3 class="title module-title"><?php echo $title; ?></h3>
  <?php endif; ?>
  <div class="module-body">
    <?php /* grid */ ?>
    <?php if ($display == 'grid') { ?>
      <?php if ($gridType == 'ipr' && $carousel) { ?>
        <div class="swiper" data-items-per-row='<?php echo json_encode($itemsPerRow, JSON_FORCE_OBJECT); ?>' data-options='<?php echo json_encode($carouselOptions, JSON_FORCE_OBJECT); ?>'>
          <div class="swiper-container" <?php if ($journal3->is_rtl): ?>dir="rtl"<?php endif; ?>>
            <div class="swiper-wrapper ipr-grid">
              <?php foreach ($items as $item): ?>
                <div class="<?php echo $journal3->classes($item['classes']); ?>">
                  <?php renderBlocks(get_defined_vars(), $item); ?>
                </div>
              <?php endforeach; ?>
            </div>
          </div>
          <div class="swiper-buttons">
            <div class="swiper-button-prev"></div>
            <div class="swiper-button-next"></div>
          </div>
          <div class="swiper-pagination"></div>
        </div>
      <?php } else { ?>
        <div class="blocks-grid no-scroll <?php echo $gridType; ?>-grid">
          <?php if ($gridType == 'auto') { ?>
          <div class="auto-grid-items">
            <?php foreach ($items as $item): ?>
              <div class="<?php echo $journal3->classes($item['classes']); ?>">
                <?php renderBlocks(get_defined_vars(), $item); ?>
              </div>
            <?php endforeach; ?>
          </div>
          <div class="auto-carousel-bar auto-carousel-controls"><div class="auto-carousel-thumb"></div><div class="auto-carousel-fill"></div></div>
          <div class="auto-carousel-buttons auto-carousel-controls"><div class="auto-carousel-prev"><span></span></div><div class="auto-carousel-next"><span></span></div></div>
          <?php } else { ?>
          <?php foreach ($items as $item): ?>
            <div class="<?php echo $journal3->classes($item['classes']); ?>">
              <?php renderBlocks(get_defined_vars(), $item); ?>
            </div>
          <?php endforeach; ?>
          <?php } ?>
        </div>
      <?php } ?>
    <?php } ?>
    <?php /* tabs */ ?>
    <?php if ($display == 'tabs'): ?>
      <div class="tab-container">
        <div class="full-tabs-bg"></div>
        <ul class="nav nav-tabs">
          <?php $index = 1;
          foreach ($items as $item): ?>
            <li class="<?php echo $journal3->classes($item['tab_classes']); ?>">
              <?php if ($item['tabType'] == 'link'): ?>
                <a href="<?php echo $item['link']['href']; ?>" <?php echo $journal3->linkAttrs($item['link']); ?>><?php echo $item['title']; ?></a>
              <?php else: ?>
                <a href="#<?php echo $id; ?>-tab-<?php echo $index; ?>" data-toggle="tab"><?php echo $item['title']; ?></a>
              <?php endif; ?>
            </li>
            <?php $index++; endforeach; ?>
        </ul>
        <div class="tab-content">
          <?php $index = 1;
          foreach ($items as $item): ?>
            <?php if ($item['tabType'] != 'link'): ?>
              <div class="<?php echo $journal3->classes($item['classes']); ?>" id="<?php echo $id; ?>-tab-<?php echo $index; ?>">
                <?php renderBlocks(get_defined_vars(), $item); ?>
              </div>
            <?php endif; ?>
            <?php $index++; endforeach; ?>
        </div>
      </div>
    <?php endif; ?>
    <?php /* accordion */ ?>
    <?php if ($display == 'accordion'): ?>
      <div class="panel-group" id="<?php echo $id; ?>-collapse">
        <?php $index = 0;
        foreach ($items as $item): $index++; ?>
          <div class="<?php echo $journal3->classes($item['classes']); ?>">
            <div class="panel-heading">
              <h4 class="panel-title">
                <a href="#<?php echo $id; ?>-collapse-<?php echo $index; ?>" class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#<?php echo $id; ?>-collapse" aria-expanded="false">
                  <?php echo $item['title']; ?>
                  <i class="fa fa-caret-down"></i>
                </a>
              </h4>
            </div>
            <div class="<?php echo $journal3->classes($item['panel_classes']); ?>" id="<?php echo $id; ?>-collapse-<?php echo $index; ?>">
              <div class="panel-body">
                <?php renderBlocks(get_defined_vars(), $item); ?>
              </div>
            </div>
          </div>
        <?php endforeach; ?>
      </div>
    <?php endif; ?>
  </div>
</div>
