{% load debusine %}
<h2>Request</h2>
<ul>
    <li id="original">
        <b>Original:</b> {{ artifact.data.original }}
    </li>
    <li id="new">
        <b>New:</b> {{ artifact.data.new }}
    </li>
</ul>
{% if debdiff_artifact_error %}
    <div id="error-artifact" class="alert alert-warning">Cannot display debdiff: {{ debdiff_artifact_error }}</div>
{% elif debdiff_parser_error %}
    <div id="error-parsing-debdiff-output"
         class="alert alert-warning"
         role="alert">
        Error parsing debdiff output: <code>{{ debdiff_parser_error }}</code>
    </div>
{% elif not debdiff_differences_reported %}
    <p id="debdiff-report-no-differences">DebDiff did not report any differences.</p>
{% elif debdiff_binary_parsed %}
    {#Binary artifacts#}
    <h4 id="files-in-original-not-in-new">
        Files in <em>original</em> artifacts but not in <em>new</em> artifacts
    </h4>
    {% if debdiff_binary_parsed.removed_files %}
        <pre>{{ debdiff_binary_parsed.removed_files }}</pre>
    {% else %}
        <p>
            All files from the <em>original</em> artifacts are present in the <em>new</em> artifacts.
        </p>
    {% endif %}
    <h4 id="files-in-new-not-in-original">
        Files in <em>new</em> artifacts but not in <em>original</em> artifacts
    </h4>
    {% if debdiff_binary_parsed.added_files %}
        <pre>{{ debdiff_binary_parsed.added_files }}</pre>
    {% else %}
        <p>
            All files from the <em>new</em> artifacts were present in the <em>original</em> artifacts.
        </p>
    {% endif %}
    <h4 id="control-diffs-changes">Control diffs changes</h4>
    {% if debdiff_binary_parsed.control_diffs %}<pre>{{ debdiff_binary_parsed.control_diffs }}</pre>{% endif %}
    {% if debdiff_binary_parsed.control_diffs_packages_items %}
        {% for package, changes in debdiff_binary_parsed.control_diffs_packages_items %}
            <h5>Package: {{ package }}</h5>
            <pre>{{ changes }}</pre>
        {% endfor %}
    {% endif %}
    {% if debdiff_binary_parsed.control_diffs_packages_no_changes %}
        <p>
            No differences were encountered between the control files of package{{ debdiff_binary_parsed.control_diffs_packages_no_changes|length|pluralize }}:
        </p>
        <ul>
            {% for package in debdiff_binary_parsed.control_diffs_packages_no_changes %}<li>{{ package }}</li>{% endfor %}
        </ul>
    {% endif %}
    {% if not debdiff_binary_parsed.control_diffs and not debdiff_binary_parsed.control_diffs_packages_items and not debdiff_binary_parsed.control_diffs_packages_no_changes %}
        <p>No changes reported by debdiff in control files.</p>
    {% endif %}
{% else %}
    {#Source artifacts#}
    <h2 id="source-summary-of-changes">Summary of changes</h2>
    <ul class="list-unstyled">
        {% for file in debdiff_source_summary %}
            <li>
                {% if file.operation == "added" %}
                    <i class="bi bi-file-earmark-plus text-success me-1" title="Added"></i>
                {% elif file.operation == "removed" %}
                    <i class="bi bi-file-earmark-minus text-danger me-1" title="Removed"></i>
                {% elif file.operation == "modified" %}
                    <i class="bi bi-file-earmark-diff text-secondary me-1" title="Modified"></i>
                {% endif %}
                <a href="#L{{ file.diff_line_number }}-{{ debdiff_file_tag }}">{{ file.path }}</a>
            </li>
        {% endfor %}
    </ul>
    <h2 id="debdiff-output">debdiff output</h2>
    {% widget debdiff_source_file_widget %}
{% endif %}
