<% chapter_id = "chapter-#{chapter.position.to_s}" %>
<% unless chapter.posted? || @preview_mode %>

<%= ts("This chapter is a draft and hasn't been posted yet!") %>

<% end %> <% if chapter.user_has_creator_invite?(current_user) %>

<%= ts("You've been invited to become a co-creator of this chapter. To accept or reject the request, visit your %{creator_requests_page}.", creator_requests_page: link_to(ts("Co-Creator Requests page"), user_creatorships_path(current_user))).html_safe %>

<% end %> <% if logged_in? && is_author_of?(@work) && !@preview_mode%> <%= render "chapters/chapter_management", chapter: chapter, work: @work %> <% end %> <%# Both Entire Work and Chapter by Chapter mode write to and read from this cache. Only content needed for both modes should be included here. %> <% cache_if(!@preview_mode, "#{@work.cache_key}/#{chapter.cache_key}-show-v7", skip_digest: true) do %>

<%= link_to chapter.chapter_header, [chapter.work, chapter] %><% unless chapter.title.blank? %>: <%= chapter.title.html_safe %><% end %>

<% if (!chapter.pseuds.blank? && (chapter.pseuds.sort != @work.pseuds.sort) && (!@work.anonymous?)) || @preview_mode %> <% end %> <% if (@work.number_of_posted_chapters > 1) || @work.chaptered? %> <% unless chapter.summary.blank? %>

<%= ts('Summary:') %>

<%=raw sanitize_field(chapter, :summary) %>
<% end %> <% unless chapter.notes.blank? && chapter.endnotes.blank? %>

<%=h ts('Notes:') %>

<% if chapter.notes.blank? %>

(<%= ts("See the end of the chapter for ") %> <%= link_to(h(ts("notes")), "#chapter_#{chapter.position.to_s}_endnotes") %>.)

<% else %>
<%=raw sanitize_field(chapter, :notes) %>
<% unless chapter.endnotes.blank? %>

(<%= ts("See the end of the chapter for ") %> <%= link_to(h(ts("more notes")), "#chapter_#{chapter.position.to_s}_endnotes") %>.)

<% end %> <% end %>
<% end %> <% end %>

<%= ts("Chapter Text") %>

<%=raw sanitize_field(chapter, :content) %>
<% unless chapter.endnotes.blank? %>

<%=h ts('Notes:') %>

<%=raw sanitize_field(chapter, :endnotes) %>
<% end %>
<% end %>