<%= render partial: 'subnav' %>

<div class="box wide">
  <h2>
    From
    <% if @message.author %>
      <%= styled_user_link @message.author %>
    <% else %>
      <%= @message.author_username %>
    <% end %>
    <%= @message.hat.to_html_label if @message.hat %>
    to
    <%= styled_user_link @message.recipient %>
    <%= how_long_ago_label(@message.created_at) %>
  </h2>

  <div class="boxline comment_text">
    <%= raw @message.linkified_body %>
  </div>

  <br>

  <div class="boxline">
    <div style="float: left;">
      <%= form_with url: message_path(@message.short_id), method: :delete do |f| %>
        <%= f.submit "Delete Message" %>
      <% end %>
    </div>

    <div style="float: left; padding-left: 1em;">
      <%= form_with url: message_keep_as_new_path(@message.short_id), method: :post do |f| %>
        <%= f.submit "Keep As New" %>
      <% end %>
    </div>

    <% if @user.is_moderator? %>
      <div style="float: left; padding-left: 1em;">
        <%= form_with url: message_mod_note_path(@message.short_id), method: :post do |f| %>
          <%= f.submit "ModNote" %>
        <% end %>
      </div>
    <% end %>
  </div>

  <div style="clear: both;"></div>

  <br>

  <% if @new_message %>
    <p>
      Compose Reply
      <% if @new_message %>
        To <%= @new_message.recipient_username %>
      <% end %>
    </p>

    <%= render partial: 'form', locals: { new_message: @new_message, replying: true } %>
  <% else %>
    For help with this message, contact <%= link_to 'a moderator', moderators_path %>.
  <% end %>
</div>
