{% if (chapter is not defined or chapter is null) and contents is defined and contents is not empty %}
{% set chapter = contents|first|first.findMainVerse().chapter %}
{% endif %}
{% set sLinkTarget = "" %}
{% if bInFrame %}
{% set sLinkTarget = " target=_top " %}
{% endif %}
{% set bOnMobile = app.session.get('is_on_mobile') %}
{% set bMulticolumn = false %}
{% if multicolumn is defined and multicolumn %}
{% set bMulticolumn = true %}
{% endif %}
{# Previous chapter link #}
{% if prev_chapter is defined and prev_chapter is not empty %}
{% set sPrevBookName = "" %}
{% if bMulticolumn or bOnMobile %}
{% set sPrevBookName = app.session.get('ui_str')["bible.chapternav.prev"] %}
{% else %}
{% set sPrevBookName = app.session.get('ui_str')["bible.chapternav.bookchapter"]|replace({'_8100_': prev_chapter.book_name, '_8200_': prev_chapter.chapter_order})|raw %}
{% endif %}
{% if bMulticolumn %}
{% if column_num == 1 and chapter_explanation_page is defined and chapter_explanation_page and chapter_explanations[prev_chapter.id] is defined %}
{% set href = path(multicolumn_path, multicolumn_route_params|merge({('column'~column_num~'Details'): prev_chapter.chapter_multi_spec, ('column2Details'): chapter_explanations[prev_chapter.id]['explanation_spec']}) ) %}
{% else %}
{% set href = path(multicolumn_path, multicolumn_route_params|merge({('column'~column_num~'Details'): prev_chapter.chapter_multi_spec}) ) %}
{% endif %}
{% else %}
{% if bInFrame %}
{% set href = path('bible_new', {'translationUrl': prev_chapter.translation_url, 'bookUrl': prev_chapter.book_url, 'chapterIndex': prev_chapter.chapter_order}) %}
{% else %}
{% set href = path('bible_chapter', {'translationUrl': prev_chapter.translation_url, 'bookUrl': prev_chapter.book_url, 'chapterIndex': prev_chapter.chapter_order}) %}
{% endif %}
{% endif %}
<a class="nav_link" href="{{ href }}" {{ sLinkTarget }} alt="← {{ sPrevBookName }}" title= "← {{ sPrevBookName }}"><i class="fa-duotone fa-circle-arrow-left" style="--fa-secondary-opacity: 0.3;"></i></a>
{% endif %}
{# "show full chapter" link, or links for single full chapters if we have multiple chapters showing #}
{% if verses is not defined and contents is defined and contents|length == 1 %}
{# The code should work out the same way if all our content is in the same chapter, whether it has been defined as "verses" or "contents" #}
{% set verses = contents|first %}
{% endif %}
{% if verses is defined %}
{# Test whether we're showing the entire chapter (if we are, then no need for a "show full chapter" link) #}
{% if verses|first != chapter.verses|first or verses|last != chapter.verses|last %}
{% if bMulticolumn %}
{% if column_num == 1 and chapter_explanation_page is defined and chapter_explanation_page and chapter_explanations[chapter.getId()] is defined %}
{% set href = path(multicolumn_path, multicolumn_route_params|merge({('column'~column_num~'Details'): column_replace_uri(chapter), ('column2Details'): chapter_explanations[chapter.getId()]['explanation_spec']}) ) %}
{% else %}
{% set href = path(multicolumn_path, multicolumn_route_params|merge({('column'~column_num~'Details'): column_replace_uri(chapter)}) ) %}
{% endif %}
{% else %}
{% set href = uri(chapter) %}
{% endif %}
<a href="{{ href }}" title="{{ app.session.get('ui_str')["bible.chapternav.fullchapter"] }}"><i class="fas fa-align-justify"></i></a>
{% endif %}
{% elseif contents is defined %}
{% for chapter_contents in contents %}
{% set chapter = chapter_contents|first.findMainVerse().chapter %}
{% if bMulticolumn %}
{% if column_num == 1 and chapter_explanation_page is defined and chapter_explanation_page and chapter_explanations[chapter.getId()] is defined %}
{% set href = path(multicolumn_path, multicolumn_route_params|merge({('column'~column_num~'Details'): column_replace_uri(chapter), ('column2Details'): chapter_explanations[chapter.getId()]['explanation_spec']}) ) %}
{% else %}
{% set href = path(multicolumn_path, multicolumn_route_params|merge({('column'~column_num~'Details'): column_replace_uri(chapter)}) ) %}
{% endif %}
{% else %}
{% set href = uri(chapter) %}
{% endif %}
<a class="btn btn-outline-dark btn-sm" href="{{ href }}">{{ app.session.get('ui_str')["bible.chapternav.bookchapter"]|replace({'_8100_': chapter.book.name, '_8200_': chapter.ordering})|raw }}</a>
{% endfor %}
{% endif %}
{# Next chapter link #}
{% if next_chapter is defined and next_chapter is not empty %}
{% set sNextBookName = "" %}
{% if bMulticolumn or bOnMobile %}
{% set sNextBookName = app.session.get('ui_str')["bible.chapternav.next"] %}
{% else %}
{% set sNextBookName = app.session.get('ui_str')["bible.chapternav.bookchapter"]|replace({'_8100_': next_chapter.book_name, '_8200_': next_chapter.chapter_order})|raw %}
{% endif %}
{% if bMulticolumn %}
{% if column_num == 1 and chapter_explanation_page is defined and chapter_explanation_page and chapter_explanations[next_chapter.id] is defined %}
{% set href = path(multicolumn_path, multicolumn_route_params|merge({('column'~column_num~'Details'): next_chapter.chapter_multi_spec, ('column2Details'): chapter_explanations[next_chapter.id]['explanation_spec']}) ) %}
{% else %}
{% set href = path(multicolumn_path, multicolumn_route_params|merge({('column'~column_num~'Details'): next_chapter.chapter_multi_spec}) ) %}
{% endif %}
{% else %}
{% if bInFrame %}
{% set href = path('bible_new', {'translationUrl': next_chapter.translation_url, 'bookUrl': next_chapter.book_url, 'chapterIndex': next_chapter.chapter_order}) %}
{% else %}
{% set href = path('bible_chapter', {'translationUrl': next_chapter.translation_url, 'bookUrl': next_chapter.book_url, 'chapterIndex': next_chapter.chapter_order}) %}
{% endif %}
{% endif %}
<a class="nav_link" style="padding-left:5px;" href="{{ href }}" {{ sLinkTarget }} alt="{{ sNextBookName }} →" title="{{ sNextBookName }} →"><i class="fa-duotone fa-circle-arrow-right" style="--fa-secondary-opacity: 0.3;"></i></a>
<script>
addPrefetchHead("{{ href }}");
</script>
{% endif %}