<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <link rel="stylesheet" type="text/css" href="css/transbeam.css"/>
    <link rel="apple-touch-icon" href="images/site-icons/transbeam-apple.png"/>
    <link rel="manifest" href="manifest.json"/>
    <script src="js/util.js"></script>
    <script type="text/javascript">
      const CODE = "{{ code }}";
    </script>
    <script src="js/download.js"></script>
    <title>{{ file.name }} - transbeam</title>
  </head>
  <body>
    <div id="header">
      <img src="images/site-icons/transbeam.svg" height="128">
      <h1>transbeam</h1>
    </div>
    <div id="download_toplevel" class="section">
      <div class="file_name">{{ file.name }}</div>
      <div class="file_size">{{ bytesize::to_string(file.size.clone(), false).replace(" ", "") }}</div>
      <div class="file_download"><a class="download_button" href="download?code={{ code }}&download=all"></a></div>
    </div>
    {% match file.contents %}
      {% when Some with (files) %}
        <div id="download_contents" class="section">
          <details>
            <summary>Show file list</summary>
            <table><tbody>
              {% let offsets = offsets.as_ref().unwrap() %}
              {% for f in files %}
                <tr class="{% if offsets.get(loop.index0.clone()).unwrap().clone() > available %}unavailable{% endif %}">
                  <td class="file_size">{{ bytesize::to_string(f.size.clone(), false).replace(" ", "") }}</td>
                  <td class="file_name">{{ f.name }}</td>
                  <td class="file_download"><a class="download_button" href="download?code={{ code }}&download={{ loop.index0 }}"></a></td>
                  <td class="file_unavailable"></td>
                </tr>
              {% endfor %}
            </tbody></table>
          </details>
        </div>
      {% else %}
    {% endmatch %}
    <div id="footer">
      <h5>(c) 2022 xenofem, MIT licensed</h5>
      <h5><a target="_blank" href="https://git.xeno.science/xenofem/transbeam">source</a></h5>
    </div>
  </body>
</html>