<tr{{ attributes }} is="monitor-list-row" id="monitor_{{ monitor.id }}"  class="dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-900 cursor-pointer"
   monitor-id="{{ monitor.id }}"
   parent-id="{{ monitor.parent.id ?? null }}"
   imdb-id="{{ monitor.imdbId }}"
   media-title="{{ monitor.title }}"
   season="{{ monitor.season }}"
   episode="{{ monitor.episode ?? '-' }}"
   status="{{ monitor.status }}"
   search-count="{{ monitor.searchCount }}"
   media-type="{{ monitor.monitorType|monitor_type }}"
   episode-id="{{ monitor|monitor_media_id }}"
   created-at="{{ monitor.createdAt|date('m/d/Y g:i a') }}"
   last-search="{{ monitor.lastSearch|date('m/d/Y g:i a') }}"
   downloaded-at="{{null != monitor.downloadedAt ? monitor.downloadedAt|date('m/d/Y g:i a') : '-' }}"
   air-date="{{ null != monitor.airDate ? monitor.airDate|date('m/d/Y g:i a') : '-' }}"
>
    <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-stone-800 truncate">
        <a href="{{ path('app_search_result', {imdbId: monitor.imdbId, mediaType: monitor.monitorType|as_download_type}) }}"
           class="mr-1 hover:underline rounded-md">
            {% set episodeIdDto = extract_from_episode_id(monitor|monitor_media_id) %}
            {% set routeParams = {imdbId: monitor.imdbId, mediaType: monitor.monitorType|as_download_type, season: episodeIdDto.season} %}
            <a href="{{ path('app_search_result', routeParams) }}"
               class="mr-1 hover:underline rounded-md max-w-[10ch] md:max-w-[unset] truncate dark:text-white">
                {{ monitor.title }}
            </a>
        </a>
    </td>
    <td class="px-6 py-4 whitespace-nowrap text-sm">
        {{ monitor|monitor_media_id }}
    </td>
    {# Monitor is a CHILD monitor #}
    {% if null != monitor.parent %}
    <td class="hidden md:table-cell px-6 py-4 whitespace-nowrap text-sm">
        {{ monitor.searchCount }}
    </td>
    {% else %}
    {# Monitor is a PARENT monitor #}
    <td class="hidden md:table-cell px-6 py-4 whitespace-nowrap text-sm">
        {{ monitor.children|length }}
    </td>
    {% endif %}
    <td class="hidden md:table-cell px-6 py-4 whitespace-nowrap text-sm">
        {{ monitor.createdAt|date('m/d/Y h:i a') }}
    </td>
    <td class="hidden md:table-cell px-6 py-4 whitespace-nowrap text-sm">
        {{ monitor.lastSearch|date('m/d/Y h:i a') }}
    </td>
    <td class="hidden md:table-cell px-6 py-4 whitespace-nowrap text-sm">
        {% if monitor.monitorType == "tvshow" %}
            <twig:StatusBadge color="blue" number="300" text="black" status="{{ monitor.monitorType|monitor_type }}" />
        {% elseif monitor.monitorType == "tvseason" %}
            <twig:StatusBadge color="orange" number="300" text="black" status="{{ monitor.monitorType|monitor_type }}" />
        {% else %}
            <twig:StatusBadge color="fuchsia" number="300" text="black" status="{{ monitor.monitorType|monitor_type }}" />
        {% endif %}
    </td>
    <td class="px-6 py-4 whitespace-nowrap text-sm">
        {% if monitor.status == "New" %}
            <twig:StatusBadge color="orange" status="{{ monitor.status }}" />
        {% elseif monitor.status == "In Progress" or monitor.status == "Active" %}
            <twig:StatusBadge color="purple" status="{{ monitor.status }}" />
        {% else %}
            <twig:StatusBadge color="green" status="{{ monitor.status }}" />
        {% endif %}
    </td>
    <td class="hidden md:table-cell px-6 py-4 flex flex-row align-middle justify-center">
        {% set delete_button = component('ux:icon', {name: 'ic:twotone-cancel', width: '18px', class: 'rounded-full align-middle text-red-600' }) %}
        <twig:Modal heading="But wait!" button_text="{{ delete_button }}" submit_action="{{ stimulus_action('monitor_list', 'deleteMonitor', 'click', {id: monitor.id}) }}" show_cancel show_submit>
            Are you sure you want to delete this monitor?<br />
            <div class="mt-2 border-2 border-orange-500 overflow-hidden rounded-lg">
                <table class="table-auto">
                    <tr>
                        <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-stone-800 truncate">
                            {{ monitor.title }}
                        </td>
                        {% if monitor|monitor_media_id != "-" %}
                            <td class="px-6 py-4 whitespace-nowrap text-sm">
                                {{ monitor|monitor_media_id }}
                            </td>
                        {% endif %}
                        <td class="px-6 py-4 whitespace-nowrap text-sm">
                            {% if monitor.monitorType == "tvshow" %}
                                <twig:StatusBadge color="blue" number="300" text="black" status="{{ monitor.monitorType|monitor_type }}" />
                            {% elseif monitor.monitorType == "tvseason" %}
                                <twig:StatusBadge color="orange" number="300" text="black" status="{{ monitor.monitorType|monitor_type }}" />
                            {% else %}
                                <twig:StatusBadge color="fuchsia" number="300" text="black" status="{{ monitor.monitorType|monitor_type }}" />
                            {% endif %}
                        </td>
                        <td class="px-6 py-4 whitespace-nowrap text-sm">
                            {% if monitor.status == "New" %}
                                <twig:StatusBadge color="orange" status="{{ monitor.status }}" />
                            {% elseif monitor.status == "In Progress" or monitor.status == "Active" %}
                                <twig:StatusBadge color="purple" status="{{ monitor.status }}" />
                            {% else %}
                                <twig:StatusBadge color="green" status="{{ monitor.status }}" />
                            {% endif %}
                        </td>
                    </tr>
                </table>
            </div>
        </twig:Modal>
    </td>
</tr>
