<% provide :title do %><%= @proposal.title %><% end %>
<% provide :social_media_meta_tags do %>
<%= render "shared/social_media_meta_tags",
            social_url: proposal_url(@proposal),
            social_title: @proposal.title,
            social_description: @proposal.summary %>
<% end %>
<% cache [locale_and_user_status(@proposal), @proposal, @proposal.author, Flag.flagged?(current_user, @proposal), @proposal_votes] do %>

  <section class="proposal-show">
    <div id="<%= dom_id(@proposal) %>" class="row">
      <div class="small-12 medium-9 column">
        <%= render "shared/back_link" %>

        <% if current_user && @proposal.editable_by?(current_user) %>
          <%= link_to edit_proposal_path(@proposal), class: 'edit-proposal button hollow float-right' do %>
            <%= t("proposals.show.edit_proposal_link") %>
          <% end %>
        <% end %>

        <h1><%= @proposal.title %></h1>
        <% if @proposal.retired? %>
          <div data-alert class="callout alert margin-top proposal-retired">
            <strong>
              <%= t("proposals.show.retired_warning") %><br>
              <%= link_to t("proposals.show.retired_warning_link_to_explanation"), "#retired_explanation" %>
            </strong>
          </div>
        <% elsif @proposal.conflictive? %>
          <div data-alert class="callout alert margin-top">
            <strong><%= t("proposals.show.flag") %></strong>
          </div>
        <% end %>

        <div class="proposal-info">
          <%= render '/shared/author_info', resource: @proposal %>

          <span class="bullet">&nbsp;&bull;&nbsp;</span>
          <%= l @proposal.created_at.to_date %>
          <span class="bullet">&nbsp;&bull;&nbsp;</span>
          <span class="icon-comments"></span>&nbsp;
          <%= link_to t("proposals.show.comments", count: @proposal.comments_count), "#comments" %>
          <span class="bullet">&nbsp;&bull;&nbsp;</span>
          <span class="js-flag-actions">
            <%= render 'proposals/flag_actions', proposal: @proposal %>
          </span>
        </div>

        <br>
        <p>
          <%= t("proposals.show.code") %>
          <strong><%= @proposal.code %></strong>
        </p>

        <blockquote><%= @proposal.summary %></blockquote>

        <% if @proposal.video_url.present? %>
          <div class="small-12 medium-7 small-centered">
            <div class="flex-video">
              <div id="js-embedded-video" data-video-code="<%= embedded_video_code %>"></div>
            </div>
          </div>
        <% end %>

        <%= safe_html_with_links @proposal.description %>

        <% if @proposal.external_url.present? %>
          <div class="document-link">
            <%= text_with_links @proposal.external_url %>
          </div>
        <% end %>

        <% if @proposal.video_url.present? %>
          <div class="video-link">
            <%= text_with_links @proposal.video_url %>
          </div>
        <% end %>

        <h4><%= @proposal.question %></h4>

        <% if @proposal.retired? %>
          <div id="retired_explanation" class="callout">
            <h2><%= t('proposals.show.retired') %>: <%= t("proposals.retire_options.#{@proposal.retired_reason}") unless @proposal.retired_reason == 'other' %></h2>
            <%= simple_format text_with_links(@proposal.retired_explanation), {}, sanitize: false %>
          </div>
        <% end %>

        <%= render 'shared/tags', taggable: @proposal %>

        <%= render 'shared/geozone', geozonable: @proposal %>

        <div class="js-moderator-proposal-actions margin">
          <%= render 'proposals/actions', proposal: @proposal %>
        </div>
      </div>

      <aside class="small-12 medium-3 column">
        <div class="sidebar-divider"></div>
        <h3><%= t("votes.supports") %></h3>
        <div class="text-center">
          <div id="<%= dom_id(@proposal) %>_votes">
           <%= render 'votes',
                      { proposal: @proposal, vote_url: vote_proposal_path(@proposal, value: 'yes') } %>
          </div>
        </div>
        <div id="social-share" class="sidebar-divider"></div>
        <h3><%= t("proposals.show.share") %></h3>
        <div class="social-share-full">
          <%= social_share_button_tag("#{@proposal.title} #{setting['twitter_hashtag']}") %>
          <% if browser.device.mobile? %>
            <a href="whatsapp://send?text=<%= @proposal.title %> <%= proposal_url(@proposal) %>" data-action="share/whatsapp/share">
              <span class="icon-whatsapp whatsapp"></span>
            </a>
          <% end %>
        </div>
      </aside>
    </div>
  </section>
<% end %>

<div class="tabs-content" data-tabs-content="example-tabs">
  <% if @notifications.present? %>
    <%= render "proposals/filter_subnav" %>
    <%= render "proposals/notifications" %>
  <% end %>

  <div class="tabs-panel is-active" id="tab-comments">
    <%= render "proposals/comments" %>
  </div>
</div>
