
{% extends 'base.html' %}
{% block content %}


        <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 mb-3">
            <h1 class="h2"><span style="border-bottom: 3px #e24949 dashed;">{{ library_type_display|title }}</span> <span class="badge bg-primary rounded-pill">{{ playlists.count }}</span></h1>


            {% if playlists %}
            <div class="btn-toolbar mb-2 mb-md-0">
                <!--
                <div class="btn-group me-2">
                    <button type="button" class="btn btn-outline-info">Grid</button>
                    <button type="button" class="btn btn-outline-info">List</button>
                </div>
                <div class="btn-group">
                  <button type="button" class="btn btn-success dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
                    Sort By
                  </button>
                  <ul class="dropdown-menu">
                    <li class="dropdown-item"><a hx-get="{% url 'order_playlists_by' library_type 'playlist-duration-in-seconds' %}" hx-trigger="click" hx-target="#search-results">Duration</a></li>
                    <li class="dropdown-item"><a hx-get="{% url 'order_playlists_by' library_type 'video-count' %}" hx-trigger="click" hx-target="#search-results"># Videos</a></li>
                    <li class="dropdown-item"><a hx-get="{% url 'order_playlists_by' library_type 'recently-accessed' %}" hx-trigger="click" hx-target="#search-results">Recently Accessed</a></li>
                  </ul>
                </div>
                -->
            </div>
            {% endif %}

        </div>

        {% if playlists %}
            <input   class="form-control border border-secondary" type="text"
                   name="search" placeholder="Begin to search playlists..."
                   hx-post="{% url 'search_library' library_type %}"
                   hx-trigger="keyup changed delay:700ms"
                   hx-target="#search-results"
                   hx-indicator=".htmx-indicator"
                    aria-describedby="searchHelp">
            <div id="searchHelp" class="form-text">For a more extensive playlist search and filtering, <a href="{% url 'search' %}?mode=playlists&type={{ library_type }}">click here</a>.</div>

            <br>

        <div id="search-results" class="row row-cols-1 row-cols-md-4 g-4">
            {% include 'intercooler/playlists.html' with show_controls=True %}
        </div>
        {% else %}
              <div class="card bg-dark text-white mb-3">
            <div class="card-body">
                <div class="d-flex justify-content-center h3">
                    Nothing here!
                </div>
                <div class="d-flex justify-content-center h5">
                    {% if library_type == "watching" %}
                        You can mark a playlist as watching by heading over to the playlist and marking it from the dropdown.
                    {% elif library_type == "all" %}
                        There's no playlists in your UnTube right now.
                    {% elif library_type == "imported" %}
                        To import public playlists into your UnTube collection you can head over to <a href="{% url 'manage_view_page' 'import' %}" class="btn btn-sm btn-primary ms-2">Import</a>
                    {% elif library_type == "plan-to-watch" %}
                        You can mark a playlist as plan to watch by heading over to the playlist and marking it from the dropdown.
                    {% elif library_type == "favorites" %}
                        You can mark a playlist as favorite by heading over to the playlist page and pressing the star icon.
                    {% elif library_type == "yt-mix" %}
                        No YouTube mixes imported. Head over to Import to import the ones you like.
                    {% elif library_type == "user-owned" %}
                        {% if user.profile.imported_yt_playlists %}
                            Looks like you have no playlists on YouTube.
                        {% else %}
                            You can always head over to your <a href="{% url 'profile' %}" class="btn btn-sm btn-primary ms-2 me-2">Profile</a> to import all of your public/private YouTube playlists.
                        {% endif %}
                    {% else %}
                        {{ library_type }}
                    {% endif %}
                </div>
            </div>
            </div>

        {% endif %}
        <br>

{% endblock %}