<html>
   <head>
      <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600">
      <link rel="stylesheet" href="../../main.css">
   </head>
   <body>
      <div class="container">
         <div class="header"></div>
         <div class="content">
            <div class="button-container">
               <a href="../index.html">
                  <div class="button"><img src="../../back.svg"></div>
                  <span>Back to collections</span>
               </a>
            </div>
            <h1>{{ heading }}</h1>
            {% for item in data.collection_items %}
            <div class="item-section">
               <h2>{{ item.heading }}</h2>
               <div class="table">
                  <div class="table-row">
                     <div class="table-cell">Field</div>
                     <div class="table-cell">Value</div>
                  </div>
                  {% for field, value in item.data.items() %}
                  <div class="table-row">
                     <div class="table-cell">{{ field }}</div>
                     <div class="table-cell">
                        {% set _is_attachment_block = false %}
                        {% if value is mapping and value|length > 0 %}
                           {% set _first_key = (value.keys() | list)[0] %}
                           {% if value[_first_key] is mapping and ('url' in value[_first_key]) %}
                               {% set _is_attachment_block = true %}
                           {% endif %}
                        {% endif %}

                        {% if _is_attachment_block %}
                           <p class="expiration-notice">Note: All download links will expire in 7 days.</p>
                           <div class="table table-hover">
                              <div class="table-row">
                                 <div class="table-cell" style="text-align: left;">File Name</div>
                                 <div class="table-cell" style="text-align: left;">Size</div>
                              </div>
                              {% for attachment_name, attachment_info in value.items() %}
                              <a href="{{ attachment_info.url }}" class="table-row" target="_blank">
                                 <div class="table-cell" style="text-align: left;">{{ attachment_name }}</div>
                                 <div class="table-cell" style="text-align: left;">{{ attachment_info.size }}</div>
                              </a>
                              {% endfor %}
                           </div>
                        {% else %}
                           <pre>{{ value | pretty_print }}</pre>
                        {% endif %}
                     </div>
                  </div>
                  {% endfor %}
               </div>
            </div>
            {% endfor %}
         </div>
      </div>
   </body>
</html>
