<% if $canViewArtifacts %>
<% include PageBanner %>
<div class="container-full page-background">
  <div class="container">
    <div class="page">

      <div class="row">
        <% include Breadcrumbs %>
      </div>

      <div class="row">
        <div class="col-lg-12 col-md-12 col-sm-12">

          $Content

          <p><strong>$generator.Description</strong></p>

          <% if not $Favorited %>
            $FavoriteForm
          <% else %>
            $RemoveFavoriteForm
          <% end_if %>

          <% if $ProductInstance %>
          <p class="toggle-link"><i class="fa fa-angle-double-down"></i> <a class="form-toggle collapsed">Show script output</a></p>
          <pre>$ProductInstance.Output</pre>
          <% end_if %>

          <% if $ProductInstance.Exit %>
            <p class="toggle-link error-button"><i class="fa fa-angle-double-down"></i> <a class="form-toggle collapsed">Show script Errors</a></p>
            <pre class="error-msg">$ProductInstance.ExitString<br>$ProductInstance.Errors</pre>
          <% end_if %>

          <p class="toggle-link"><i class="fa fa-angle-double-down"></i> <a class="form-toggle collapsed">Run another instance of this product</a></p>
          $Form
        
          <% if $ProductInstance.OutputInfo || $ProductInstance.OutputWarning || $ProductInstance.OutputError %>
            <hr>
            <% if $ProductInstance.OutputInfo %>
              <p style="background-color: #a1e5f0; padding: 10px; border-radius: 5px; font-size: 0.9em; font-family: monospace;">
                    $ProductInstance.OutputInfo
              </p>
            <% end_if %>
            <% if $ProductInstance.OutputWarning %>
              <p style="background-color: #f2e6c2; padding: 10px; border-radius: 5px; font-size: 0.9em; font-family: monospace;">
                $ProductInstance.OutputWarning
              </p>
            <% end_if %>
            <% if $ProductInstance.OutputError %>
              <p style="background-color: #f2b8be; padding: 10px; border-radius: 5px; font-size: 0.9em; font-family: monospace;">
                $ProductInstance.OutputError
              </p>
            <% end_if %>
          <% end_if %>

          <% if $ProductInstance.Artefacts %>
            <% loop $ProductInstance.Artefacts %>
              <hr>

              <h3>$Title</h3>

              <% if $extension == "pdf" || $extension == "txt" || $extension == "html" %>
                <iframe style="width:100%; min-height:30em;" src="$Link" frameBorder="0"></iframe>
              <% else_if $forTemplate %>
                <a href="$Me.Link()" target="_blank">
                  <% if $Width > 1140 %>
                    $Me.ScaleWidth(1140)
                  <% else %>
                    $Me
                  <% end_if %>
                </a>
              <% end_if %>

              </p><small><a href="$Link" download>download</a></small></p>
          <% end_loop %>
          <% else %>
            <div class="alert alert-danger" role="alert"><% _t('Artifactspage.NOARTEFACTS', 'Sorry, no artifacts were found or they have been deleted.') %></div>
          <% end_if %>
        </div>
      </div>
    </div>
  </div>
</div>
<% else %>
<div class="container">
  <div class="page">
      <div class="alert alert-danger" role="alert">
        <% _t('Artifactspage.NOARTEFACTSVIEWPERMISSION', 'Sorry, you do not have permission to view these artifacts.') %>
      </div>
  </div>
</div>
<% end_if %>
