{% comment %}
    Preamble intro has lots of extra fields
{% endcomment %}
{% load macros %}

<li
    {% if node.marker %}marker-type="{{node.marker}}"{% endif %}
    {% if node.toc_id %}data-toc-id="{{node.toc_id}}"{% endif %}
    id="{{node.markup_id}}"
    data-permalink-section>
  <div class="node">
    <h4 class="small-header">{{ meta.primary_agency }}</h4>
    <h3>{{ meta.title }}</h3>
    <div class="comment-period-dates">
      {% if meta.comment_state.name == 'OPEN' %}
        <div class="days-remaining open"><strong>{{ meta.days_remaining }}</strong> Days</div>
      {% elif meta.comment_state.name == 'CLOSED' %}
        <div class="days-remaining closed"><strong>0</strong> Days</div>
      {% endif %}

      <div class="explanation">
        {% if meta.comment_state.name == 'PREPUB' %}
          This comment period is not open.
        {% elif meta.comment_state.name == 'OPEN' %}
          Comment period closes on {{ meta.comments_close|date:"F j, Y" }} at 11:59pm EST.
        {% elif meta.comment_state.name == 'CLOSED' %}
          Comment period closed on {{ meta.comments_close|date:"F j, Y" }} at 11:59pm EST.
        {% endif %}{% comment %}No text in the NO_COMMENT state {% endcomment %}
      </div>

      <p class="publish-date">
      {% if meta.comment_state.name == 'PREPUB' %}
        The rule is not yet published in the Federal Register.
      {% else %}
        Rule published {{ meta.publication_date|date:"F j, Y"}}
      {% endif %}
      </P>
    </div>
    {% if meta.supporting_documents %}
    <div class="view-supporting-docs">
      <span class="fa fa-file-text-o"></span>
      <a class="citation internal" href="#supporting-docs">View supporting documents from the docket</a>
    </div>
    {% endif %}
    <p>
      {% for title_info in meta.cfr_refs %}
        {{title_info.title}} CFR Parts {{ title_info.parts|join:", " }}<br />
      {% endfor %}
      {{meta.dockets|join:"; "}}<br />
      RIN {{meta.regulation_id_numbers|join:"; "}}
    </p>
    {% if meta.comment_state.name == 'OPEN' and node.accepts_comments %}
      <div
          class="activate-write"
          data-section="{{ node.full_id }}"
          data-label="{{ node.human_label }}">
        <a href="#">
          <div class="paragraph-comment-icon">
            <span class="fa fa-pencil-square-o" aria-hidden="true"></span>
          </div>
          <div class="paragraph-comment">Write a comment about {{ node.human_label }}</div>
        </a>
      </div>
    {% endif %}
  </div>
</li>
{% for c in node.children %}
  {% with node=c %}
    {% include node.template_name %}
  {% endwith %}
{% endfor %}
{% if meta.supporting_documents %}
  <li>
    <h4 id="supporting-docs">SUPPORTING DOCUMENTS FROM THE DOCKET:</h4>
    <ol class="supporting-docs-list">
      {% for doc in meta.supporting_documents|slice:":3" %}
        <li>
          {% external_link text=doc.title url="https://www.regulations.gov/#!documentDetail;D="|add:doc.regs_id %}
        </li>
      {% endfor %}
      <li>
        {% with url="https://www.regulations.gov/#!docketBrowser;rpp=25;po=0;dct=SR%252BO;D="|add:meta.primary_docket %}
          {% external_link text="View all" classes="view-all" url=url %}
        {% endwith %}
      </li>
    </ol>
  </li>
{% endif %}
