{% extends "admin/change_form.html" %}
{% load i18n admin_urls admin_modify static %}

{% block submit_buttons_bottom %}
{{ block.super }}

{% if change and original.pk %}
{% url opts|admin_urlname:'duplicate' original.pk|admin_urlquote as duplicate_url %}

<div id="dup-btn-wrap" style="display: none;">
    <a href="{% add_preserved_filters duplicate_url %}"
       id="dup-btn-link"
       class="button"
       style="background: #417690;
                      color: white;
                      margin-left: 5px;
                      float: left;
                      border-radius: 4px;
                      display: inline-block;
                      text-decoration: none;
                      padding: 10px 15px;">
        {% translate 'Duplicate and continue editing' %}
    </a>
</div>
{% endif %}

{% block admin_change_form_document_ready %}
{{ block.super }}

{% if change and original.pk %}
<script>document.addEventListener("DOMContentLoaded", function () {
    let e = document.getElementById("dup-btn-link"), t = document.querySelector('input[name="_continue"]');
    if (t && e) {
        e.removeAttribute("style"), e.className = t.className;
        let n = t.parentElement;
        if (n && "DIV" === n.tagName && n !== document.body) {
            let l = n.cloneNode(!1);
            l.appendChild(e), n.after(l)
        } else t.after(e);
        let a = document.getElementById("dup-btn-wrap");
        a && a.remove()
    }
});</script>
{% endif %}
{% endblock %}

{% endblock %}