<h3>
  <% case @report.item %>
  <% when User %>
    <%= t('reports.new_report_title.user', user: report_item_link(@report)).html_safe %>
  <% when Comment %>
    <%= t('reports.new_report_title.comment', user: render_user(@report.item.poster, @report.item.poster_id)).html_safe %>
  <% when Message %>
    <%= t('reports.new_report_title.message', user: render_user(@report.item.poster, @report.item.poster_id)).html_safe %>
  <% when Script %>
    <%= t('reports.new_report_title.script', script: report_item_link(@report)).html_safe %>
  <% end %>
</h3>

<% if @report.item.is_a?(Comment) %>
  <div class="user-content">
    <%= format_user_text(@report.item.text, @report.item.text_markup) %>
  </div>
<% end %>

<% if @report.item.is_a?(User) %>
  <%= t('reports.new_user_report_notes_html') %>
<% elsif @report.item.is_a?(Script) %>
  <%= it('reports.new_script_report_notes_html', feedback_link: feedback_script_path(@report.item), rules_link: help_code_rules_path, site_name: site_name) %>
<% else %>
  <%= t('reports.new_report_notes_html') %>
<% end %>

<%= form_with(model: @report) do |f| %>
  <%= render partial: 'shared/errors', locals: { resource: @report } %>

  <div class="form-control radio-group">
    <%= f.label :reason %><br>
    <% if @report.item.is_a?(Script) %>
      <div>
        <%= f.radio_button(:reason, 'non_functional', required: true) %> <%= f.label :reason, t('reports.reason.non_functional'), class: 'radio-label', value: 'non_functional' %><br>
        <div class="after-radio-chosen alert"><%= it('reports.non_functional_feedback', feedback_link: feedback_script_path(@report.item)) %></div>
      </div>
      <div>
        <%= f.radio_button(:reason, 'paid_benefits', required: true) %> <%= f.label :reason, t('reports.reason.paid_benefits'), class: 'radio-label', value: 'paid_benefits' %><br>
        <div class="after-radio-chosen alert"><%= it('reports.paid_benefits_feedback', feedback_link: feedback_script_path(@report.item), site_name: site_name) %></div>
      </div>
    <% end %>
    <% @report.possible_reasons.each do |reason| %>
      <div>
        <%= f.radio_button(:reason, reason, required: true) %> <%= f.label :reason, it("reports.reason.#{reason}", antifeature_link: help_antifeatures_path), class: 'radio-label', value: reason %>
        <% case reason %>
        <% when Report::REASON_UNAUTHORIZED_CODE %>
          <div class="after-radio-chosen">
            <%= f.url_field :script_url, placeholder: t('reports.unauthorized_code_original_placeholder'), maxlength: 255, size: nil %>
          </div>
        <% when Report::REASON_WRONG_CATEGORY %>
          <div class="after-radio-chosen">
            <label class="subselection-radio-title">What is the proper category?</label>
            <% DiscussionCategory.where(moderators_only: false).non_script.where.not(id: @report.item.discussion_category_id).each do |discussion_category| %>
              <%= f.radio_button :discussion_category_id, discussion_category.id %>
              <%= f.label :discussion_category_id, discussion_category.localized_name, value: discussion_category.id, class: 'radio-label' %>
              <br>
            <% end %>
          </div>
        <% end %>
      </div>
    <% end %>
  </div>

  <%= with_user_text_preview_for_form(form: f, markup_name: :explanation_markup) do
    f.text_area :explanation, placeholder: t('reports.explanation_placeholder'), maxlength: 50_000
  end %>

  <div class="report-screenshot-control">
    <%= render partial: 'screenshots/entry', locals: { f: f } %>
  </div>

  <%= hidden_field_tag :item_class, @report.item.class.name.downcase %>
  <%= hidden_field_tag :item_id, @report.item.id %>
  <p>
    <%= f.submit t('reports.create_button') %>
  </p>
<% end %>
