<div class="entry-container {{ additional_classes if additional_classes else '' }}">
    <div class="entry-container-top">
        <div class="ribbon {{ 'gwa-visible' if entry.favorite else 'gwa-hidden' }}"><span><i class="fas fa-heart"></i></span></div>
        <div class="row no-margin">
            <div class="entry-container-title">
                {{ entry.fcol_title or entry.title }}
            </div>
        </div>
        {% if entry.reddit_created_utc is not none %}
            <div class="row no-margin">
                <div class="extended-reddit-line">
                    {% if entry.reddit_flair %}
                    <div class="flair">{{ entry.reddit_flair or "N/A" }}</div>
                    {% endif %}
                    {% if entry.reddit_upvotes %}
                    <div class="upvotes">
                        <i class="fas fa-thumbs-up upvote-icon"></i>
                        <span style="vertical-align: middle;">{{ entry.reddit_upvotes or "N/A" }}</span>
                    </div>
                    {% endif %}
                </div>
            </div>
        {% endif %}
        <div class="row no-margin">
            <div class="entry-container-rating">
                {% include 'components/entry_rate.html' %}
            </div>
            <div class="entry-container-date">
                {{ entry.date }}
            </div>
            <div class="entry-container-artist">
                {# TODO change this to search for both collection and audio alias? #}
                <a href="{{ url_for('main.search_entries', q='artist:"' + (entry.artist_name if entry.artist_name else entry.alias_name) + '"') }}" title={{ entry.artist_name or entry.alias_name }}>{{ entry.artist_name or entry.alias_name }}</a>
            </div>
            <div class="col mdb-nav-right">
                <a class="entry-container-popout"
                   hx-post={{ url_for('main.listen_later', entry_id=entry.id) }}
                   hx-vals='{"entryId": {{ entry.id }} }'
                   hx-target='this'>
                    <i class="fa{{ 's' if entry.listen_later else 'r' }} fa-clock"></i>
                </a>
                <a class="entry-container-popout" href={{ url_for('main.entry', entry_id=entry.id) }}>
                    <i class="fas fa-external-link-alt"></i>
                </a>
            </div>
        </div>
    </div>
    <div class="entry-expand" style="display:none;">
        <div class="entry-expand-inner">
            <div class="description">
                <strong>Audio page title:</strong> {{ entry.title }}<br/>
                <strong>Local filename:</strong> 
                {{ (audio_path.subpath + '/' + entry.filename) if entry.filename else 'Missing!' }}
                <br/><br/>
                <h2><b>Selftext:</b></h2>
                {% if entry.reddit_selftext %}
                    <a class="text-toggle">Click to toggle...</a>
                    <div class="toggle-text-container">
                        {% for ln in entry.reddit_selftext.strip().splitlines() %}
                            {{ ln }}<br/>
                        {% endfor %}
                    </div>
                {% else %}
                    <span title="Press the text icon on the right to try to embed it from disk!">
                        Missing or not in DB!</span><br/>
                {% endif %}
                <br/><br/>
                <h2><b>Description:</b></h2>
                {% if entry.description %}
                    <a class="text-toggle">Click to toggle...</a>
                    <div class="toggle-text-container">
                        {% for ln in entry.description.splitlines() %}
                            {{ ln }}<br/>
                        {% endfor %}
                    </div>
                {% else %}
                    Missing!<br/>
                {% endif %}
            </div>
            <div class="entry-expand-actions-wrap">
                <div class="entry-expand-actions">
                    Source:<br/>
                    <div class="entry-expand-icons">
                        {% if entry.fcol_url %}
                        <a href={{ entry.fcol_url }} title="Visit reddit thread!"><i class="fab fa-reddit-square"></i></a>
                        {% endif %}
                        <a href={{ entry.url if entry.url else '#' }} title="Visit audio source page!"><i class="fas fa-globe-americas"></i></a>
                    </div>
                    <br/>
                    Embed:<br/>
                    <div class="entry-expand-icons">
                        <a href="#" class="load-audio-embed" title="Embed audio file!"
                            hx-get="{{ url_for('main.embed_audio', subpath=audio_path.subpath, filename=entry.filename) if entry.filename else '' }}"
                            hx-target="next .audio-embed" >
                            <i class="fas fa-file-audio"></i></a>
                        <a href="#" class="load-selftxt-embed" title="Embed local selftext file!"
                            hx-get="{{ url_for('main.embed_selftext', subpath=audio_path.subpath, filename=audio_path.selftext_filename) if audio_path.selftext_filename else '' }}"
                            hx-target="next .selftxt-embed">

                            <i class="fas fa-file-alt"></i></a>
                    </div>
                </div>
                <div class="entry-expand-actions">
                    Artist:<br/>
                    <div class="entry-expand-icons">
                        <a href={{ ('https://reddit.com/user/' + entry.fcol_alias_name) if entry.fcol_alias_name else '#' }} class="artist" title="Visit reddit user!"><i class="fab fa-reddit-square"></i></a>
                    </div>
                    <br/>
                    Actions:<br/>
                    <div class="entry-expand-icons">
                        {# set favIntbool to opposite of what it is 0 or 1 with 1-val #}
                        {# need to account  for entry.favorite being None #}
                        <a href="#" class="set-fav-btn" data-fav-intbool={{ 1 - entry.favorite if entry.favorite is not none else 1 }} data-entry-id={{ entry.id }} title="{{ 'Un-f' if entry.favorite else 'F' }}avorite audio!"><i class="fa{{ 'r' if entry.favorite else 's' }} fa-heart pink-fcolor"></i></a>
                        <a href="#" class="remove-entry-btn"
                            title="Remove audio!"
                            hx-delete="{{ url_for('main.remove_entry', entry_id=entry.id) }}"
                            hx-target="previous .entry-container-title"
                            hx-swap="beforeend"
                            hx-confirm="Are you sure you want to delete this entry from the DB?">
                            <i class="fas fa-trash-alt red-fcolor"></i></a>
                    </div>
                </div>
            </div> {# entry-expand-actions-wrap #}
            <br/>
        </div> {# entry-expand-inner #}
        <div class="embeds-container row no-margin">
            <div class="audio-embed">
            </div>
            <div class="selftxt-embed">
            </div>
        </div>
    </div> {# entry-expand #}
</div> {# entry-container #}
