{% set video = contentVideo.itemLink ?? null %}
{% if type and video %}
  {% set loopAndAutoplay = contentVideo.loopAndAutoplay ?? null %}
  {% set checkType = '' ~ type ~ ''
    in ['youtube', 'vimeo', 'localStorage'] ?? false
  %}
  {% if loopAndAutoplay %}
    <video autoplay  preload="none"
      muted
      loop
      class="lazyload w-100"
      data-src="{{ video.one().url ?? null }}">
      <source type="video/mp4" data-src="{{ video.one().url ?? null }}" />
      {{ 'Your browser does not implement the element'|t }} <code>video</code>.
    </video>
  {% endif %}

  {% if checkType and not loopAndAutoplay %}
    {% set thumbnail = contentVideo.thumbnailVideo[0].getUrl({
      mode: 'crop',
      width: 700,
      height: 400,
      quality: 95,
      position: 'top-center',
      format: craft.app.images.getSupportsWebP() ? 'webp' : 'jpg'
    })
      ?? null
    %}
    <div class="lazyframe contentVideo videoWrapper {{
      type == 'localStorage'
        ? 'notBefore'
        : null
      }}"
      data-vendor="{{ type != 'localStorage' ? type : null }}"
      data-title="{{ titleVideo }}"
      data-thumbnail="{{ thumbnail ?? null }}"
      autoplay="true"
      data-src="{{
      '' ~ type ~ '' in ['youtube', 'vimeo']
        ? video.getUrl()
        : video.one().url ?? null
      }}">
      {% if type == 'localStorage' %}
        <div class="videoWrapper__bg"></div>
        <img src="/assets/img/play2.svg"
          class="videoWrapper__icon"
          alt="play"
          width="60"
          height="60" />
      {% endif %}
    </div>
  {% endif %}
 
  {% if not checkType and not loopAndAutoplay %}
    {% if video.valid %}
      <div class="videoWrapper">
        {{ video.render() }}
      </div>
    {% endif %}
  {% endif %}
{% endif %}
