<?php

if (!function_exists('remCalc')) {
  function remCalc($value) {
    $value = is_numeric($value) ? $value : 0;
    return ($value / 16) . 'rem';
  }
}

if (!function_exists('useVar')) {
  function useVar($source, $var, $defaultValue) {
    if (isset($source[$var])) {
      return $source[$var];
    } else {
      return $defaultValue;
    }
  }
}

if (!function_exists('classnames')) {
  function classnames() {
    $classes = [];

    $classesArray = func_get_args();
    if ($classesArray) {
      foreach ($classesArray as $index => $class) {
        if (is_array($class)) {
          foreach ($class as $conditionalClass => $condition) {
            if ($condition) {
              array_push($classes, $conditionalClass);
            }
          }
        } else {
          array_push($classes, $class);
        }
      }
    }

    $classes = join(' ', $classes);
    return $classes;
  }
}

include 'text.php';
include 'floform.php';
include 'button.php';
include 'shape.php';
include 'image.php';
include 'video.php';
include 'line.php';
include 'vector.php';
include 'embed.php';
include 'logo.php';
include 'countdown.php';
include 'menuElement.php';
include 'socialLinks.php';
include 'search.php';
include 'accordion.php';
include 'instagram.php';
include 'tabsElement.php';
include 'lottie.php';
include 'popupToggle.php';
include 'popupCloseButton.php';
include 'tabsSwitcher.php';
include 'tabs2.php';
include 'anchor.php';
include 'imageComparison.php';
include 'closeBlock.php';
include 'tabs2Arrow.php';
include 'tabs2Text.php';
include 'scrollTop.php';

function elementTypesRenderElement($type, $b, $element, $custom_classes, $elStyles, $colors, $viewport, $data) {
  if ($type === 'floform') {
    return renderFloFormElement($b, $element, $custom_classes, $elStyles, $colors, $viewport);
  }
  if ($type === 'text') {
    return renderTextElement($b, $element, $custom_classes, $elStyles, $colors, $viewport);
  }
  if ($type === 'button') {
    return renderButtonElement($b, $element, $custom_classes, $elStyles, $colors, $viewport);
  }
  if ($type === 'shape') {
    return renderShapeElement($b, $element, $custom_classes, $elStyles, $colors, $viewport);
  }
  if ($type === 'image') {
    return renderImageElement($b, $element, $custom_classes, $elStyles, $colors, $viewport);
  }
  if ($type === 'video') {
    return renderVideoElement($b, $element, $custom_classes, $elStyles, $colors, $viewport);
  }
  if ($type === 'line') {
    return renderLineElement($b, $element, $custom_classes, $elStyles, $colors, $viewport);
  }
  if ($type === 'vector') {
    return renderVectorElement($b, $element, $custom_classes, $elStyles, $colors, $viewport);
  }
  if ($type === 'embed') {
    return renderEmbedElement($b, $element, $custom_classes, $elStyles, $colors, $viewport);
  }
  if ($type === 'logo') {
    return renderLogoElement($b, $element, $custom_classes, $elStyles, $colors, $viewport);
  }
  if ($type === 'countdown') {
    return renderCountdownElement($b, $element, $custom_classes, $elStyles, $colors, $viewport);
  }
  if ($type === 'menu') {
    return renderMenuElement($b, $element, $custom_classes, $elStyles, $colors, $viewport, $data);
  }
  if ($type === 'socialLinks') {
    return renderSocialLinksElement($b, $element, $custom_classes, $elStyles, $colors, $viewport);
  }
  if ($type === 'search') {
    return renderSearchElement($b, $element, $custom_classes, $elStyles, $colors, $viewport);
  }
  if ($type === 'accordion') {
    return renderAccordionElement($b, $element, $custom_classes, $elStyles, $colors, $viewport);
  }
  if ($type === 'instagram') {
    return renderImageGridElement($b, $element, $custom_classes, $elStyles, $colors, $viewport);
  }
  if ($type === 'tabs') {
    return renderTabsElement($b, $element, $custom_classes, $elStyles, $colors, $viewport);
  }
  if ($type === 'lottie') {
    return renderLottieElement($b, $element, $custom_classes, $elStyles, $colors, $viewport);
  }
  if ($type === 'popupToggle') {
    return renderPopupToggleElement($b, $element, $custom_classes, $elStyles, $colors, $viewport);
  }
  if ($type === 'popupCloseButton') {
    return renderPopupCloseButtonElement($b, $element, $custom_classes, $elStyles, $colors, $viewport);
  }
  if ($type === 'tabsSwitcher' || $type === 'tabs2CategorySwitcher') {
    return renderTabsSwitcherElement($b, $element, $custom_classes, $elStyles, $colors, $viewport, $data['current_block']);
  }
  if ($type === 'tabs2' || $type === 'tabs2Slideshow') {
    return renderTabs2Element($b, $element, $custom_classes, $elStyles, $colors, $viewport);
  }
  if ($type === 'anchor') {
    return renderAnchorElement($b, $element, $custom_classes, $elStyles, $colors, $viewport);
  }
  if ($type === 'imageComparison') {
    return renderImageComparisonElement($b, $element, $custom_classes, $elStyles, $colors, $viewport);
  }
  if ($type === 'closeBlock') {
    return renderCloseBlockElement($b, $element, $custom_classes, $elStyles, $colors, $viewport);
  }
  if ($type === 'tabs2Arrow' || $type === 'tabs2ArrowNext' || $type === 'tabs2ArrowPrev') {
    return renderTabs2Arrow($b, $element, $custom_classes, $elStyles, $colors, $viewport);
  }
  if ($type === 'tabs2Text') {
    return renderTabs2TextElement($b, $element, $custom_classes, $elStyles, $colors, $viewport);
  }
  if ($type === 'scrollTop') {
    return renderScrollTopElement($b, $element, $custom_classes, $elStyles, $colors, $viewport);
  }
}
