{% extends "swan/components/swan_tab.jinja" %}
{% block title %}Balances{% endblock %}
{% set tab = 'withdrawals' %}
{% block content %}

    <style>
        h1 {
            margin-top: 1em;
        }
        .linked_wallet {
            margin-bottom: 3em;
        }
        .no_linked_wallet {
            background-color: var(--cmap-bg-lighter);
            border: 2px solid yellow;
            border-radius: 0.5em;
            padding: 2em 3em 2em 3em;
            margin-bottom: 3em;
        }
        .no_linked_wallet .headline {
            text-align: center;
            font-size: 1.1em;
            margin-bottom: 1em;
        }
        .footnote {
            margin-top: 2em;
            font-style: italic;
            font-size: 0.85em;
            color: #999;
        }
    </style>

    <h1>Swan Auto-Withdrawals to Specter</h1>

    {% if wallet %}
        <div class="linked_wallet">Linked wallet:
            <a class="explorer-link" href="{{ url_for('wallets_endpoint.addresses', wallet_alias=wallet.alias) }}">{{ wallet.name }}</a><br/>
            {% if autowithdrawal_threshold %}
                Auto-withdrawal threshold: {% if autowithdrawal_threshold == "0" %}{{ _("Weekly") }}{% else %}{{ autowithdrawal_threshold }} btc{% endif %}
            {% endif %}
        </div>

    {% else %}
        <div class="no_linked_wallet">
            <div class="headline">{{ _("Auto-Withdrawal Not Configured") }}</div>
            <div class="note">
                {{ _("Go to Settings to set up auto-withdrawal to one of your Specter wallets") }}
            </div>
        </div>
    {% endif %}

    {# TODO: List total withdrawal value? Or just current value of withdrawn utxos? #}

    <div class="table-holder">
        {% include "includes/services-data.html" %}
        {% include "includes/address-label.html" %}
        {% include "includes/tx-row.html" %}
        {% include "includes/tx-data.html" %}
        {% include "includes/explorer-link.html" %}
        {% include "includes/tx-table.html" %}
        <tx-table
            {% if specter.price_check and (specter.alt_rate and specter.alt_symbol) %}
                price="{{ specter.alt_rate }}"
                symbol="{{ specter.alt_symbol }}"
            {% endif %}
            btc-unit="{{ specter.unit }}"
            hide-sensitive-info="{{ specter.hide_sensitive_info | lower }}"
            service-id="{{ swan_id }}"
            type="txlist"
        />
    </div>
    <div id="tx-popup" class="hidden"></div>

    <div class="footnote">
        <sup>*</sup>{{ _("Only shows the withdrawals that this Specter instance is aware of.") }}
    </div>

{% endblock %}