<?php
//Video
$thumbnail = mb_get_block_field("simple_video_thumbnail");
$default_thumb = mb_get_block_field("simple_video_default_thumb_url");

$video_play_icon = mb_get_block_field("simple_video_play_icon") ?? '';
$play_button_icon = reset($video_play_icon);
if($video_play_icon ){
  $play_button_icon_url = wp_get_attachment_url($play_button_icon["ID"]);
}
else{
  $play_button_icon_url = null;
}


$play_text = mb_get_block_field("simple_video_play_text");
$src = mb_get_block_field("simple_video_src");

$config = Inoby_Config::component("video");

$has_custom_icon = mb_get_block_field("is_custom_play_btn_v");

$custom_icon_url = $config["cutsom-icon-enable"] ?? '';
?>
<section <?= inoby_block_attrs($attributes, ["class" => "video"]) ?>>
  <div class="container">
    <div class="row">
      <div class="col-12">
        <div class="video-wrap">
          <?php
          if ($default_thumb) {
            if ($thumbnail) {
              echo mb_inoby_picture($thumbnail, "h-12");
            } else {
              echo "<img src='$default_thumb' alt='Video...' />";
            }
          }
          if ($play_button_icon_url) {
            echo '<a class="play-button glightbox-item" href="' . $src . '">';
            echo '<img class="play-icon" src="' . $play_button_icon_url . '" alt="play icon">';
            if ($play_text) {
              echo isset($play_text) ? "<span>" . $play_text . "</span>" : "";
            }
            echo "</a>";
          } else {
            echo '<a class="link link-play glightbox-item" href="' .
              $src .
              '"><svg width="68" height="68" viewBox="0 0 68 68" fill="none" xmlns="http://www.w3.org/2000/svg">
              <rect width="68" height="68" rx="34" fill="#05A597"/>
              <path d="M33.0048 38.0096C32.6824 38.2822 32.1881 38.0572 32.182 37.6351L32.0647 29.5514C32.0585 29.1213 32.5622 28.8846 32.8893 29.1639L37.7043 33.2747C37.9388 33.4749 37.938 33.8376 37.7025 34.0367L33.0048 38.0096Z" fill="white"/>
              </svg>' .
              $play_text .
              "</a>";
          }
          ?>
        </div>
      </div>
    </div>
  </div>
</section>