<!doctype html>
<html lang="en">
<% include ampViewerHead.ejs %>
<% let currentSlide = ampStory.cuts.find(cut => cut.position === +current) %>
<% include ./main.ejs %>

<body>
<% include ./single-page-scripts.ejs %>
<% include ./override-amp-styles.ejs %>
<div class="guid-lines-container">
  <div class="guid-line guid-line-y guid-left"></div>
  <div class="guid-line guid-line-y guid-right"></div>
  <div class="guid-line guid-line-x guid-top"></div>
  <div class="guid-line guid-line-x guid-bottom"></div>
  <div class="guid-line guid-line-x guid-center-x"></div>
  <div class="guid-line guid-line-y guid-center-y"></div>
</div>
<amp-story class="single-slide" standalone poster-portrait-src="" publisher-logo-src="" style="background-color: #eeeeee!important;">
  <amp-story-page style="text-rendering: auto;background: #eeeeee" id='story' auto-advance-after="10s" class="container">
  <amp-story-grid-layer template="fill"><div class="bg-wrapper" style="background: <%=getBgColor(currentSlide)%>;"></div></amp-story-grid-layer>
    <% let preview = false;
    if (currentSlide) {
      currentSlide.layers.sort((first, second) => {
        var keyA = first.position,
          keyB = second.position;
        if(keyA < keyB) return -1;
        if(keyA > keyB) return 1;
        return 0;
      })
    } %>
    <% if (currentSlide) { %>
      <% currentSlide && currentSlide.layers && currentSlide.layers.map((layer, layerIndex) => { %>
        <% var page = null
          switch (layer.type) {
          case 'text':
          case 'html': %>
            <amp-story-grid-layer template="horizontal">
              <%- include('./components/text-layer.ejs', {withEvent: true, withAnimations: false, layer, currentSlide, preview})%>
            </amp-story-grid-layer>
            <% break;

          case 'shape': %>
            <amp-story-grid-layer template="horizontal">
              <%- include('./components/shape-layer.ejs', {withEvent: true, withAnimations: false, layer, currentSlide, preview})%>
            </amp-story-grid-layer>
            <% break;

          case 'image':
          case 'gifs': %>
            <% if (layer.content.image && layer.content.image.url) { %>
            <amp-story-grid-layer template="horizontal">
              <%- include('./components/dirty-image-layer.ejs', {withEvent: true, withAnimations: false, layer, currentSlide, preview})%>
            </amp-story-grid-layer>
            <% } %>
            <% break

          case 'video': %>
            <% if (layer.content.video && layer.content.video.url) { %>
            <amp-story-grid-layer template="horizontal">
              <%- include('./components/dirty-video-layer.ejs', {withEvent: true, withAnimations: false, layer, currentSlide, preview})%>
            </amp-story-grid-layer>
            <% } %>
            <% break
          case 'cta-link': %>
            <%- include('./components/dirty-cta-layer.ejs', {withEvent: true, layer, currentSlide})%>
            <% break } %>
        <% }) %>
      <% } %>
  </amp-story-page>
</amp-story>

<script type="text/javascript" src="/resize-files?path=amp-to-html/dist/js/subjx.js"></script>
</body>

</html>
