{% extends "swan/components/swan_tab.jinja" %}
{% block title %}Settings{% endblock %}
{% set tab = 'settings' %}
{% block content %}
    <div class="flex-col">
        <div class="flex p-4 mt-3 mb-4 bg-dark-600 rounded-lg">
            {{ _("- Specter initially sends {} unused addresses to Swan").format(num_reserved_addrs) }}{{ _(" and it will send more as needed.") }}<br/> 
            {{ _("- Your wallet in Specter will show them pre-labeled as \"reserved\" for Swan.") }}<br/>
            {% if not associated_wallet %} {{ _("- If you save a withdrawal plan here, you will get an e-mail from Swan to confirm it.") }} {% endif %} 
        </div>
        <form action="{{ url_for(service.get_blueprint_name() + '.update_autowithdrawal') }}" method="POST" role="form">
            <input type="hidden" class="csrf-token" name="csrf_token" value="{{ csrf_token() }}"/>
            <div id="destination-wallet-wrapper" class="floating-wrapper">
                <select id="destination-wallet" name="destination_wallet" class="floating-input peer">
                    {% for wallet in wallets %}
                        <option value="{{ wallet.alias }}" {% if associated_wallet == wallet %}selected{% endif %}>{{ wallet.name }}</option>
                    {% endfor %}
                </select>
                <label for="destination-wallet" class="floating-label">Wallet to use</label>
            </div>
            <div id="threshold-wrapper" class="floating-wrapper">
                <select id="autowithdrawal-threshold" name="threshold" class="floating-input peer">
                    <option value="0"     {% if autowithdrawal_threshold == '0' %}selected{% endif %}>Weekly</option>
                    <option value="0.01"  {% if autowithdrawal_threshold == '0.01' %}selected{% endif %}>0.010 BTC</option>
                    <option value="0.025" {% if autowithdrawal_threshold == '0.025' %}selected{% endif %}>0.025 BTC</option>
                    <option value="0.05"  {% if autowithdrawal_threshold == '0.05' %}selected{% endif %}>0.050 BTC</option>
                </select>
                <label for="autowithdrawal-threshold" class="floating-label">Auto-withdrawal threshold</label>
            </div>
            {% if associated_wallet %}
                <button type="submit" class="mt-4 button bg-accent">{{ _("Update Auto-withdrawal") }}</button>
            {% else %}
                <p class="mt-4">
                    {{ _("No Auto-withdrawal plan saved yet") }}<br>
                </p>
                <button type="submit" class="mt-4 button bg-accent">{{ _("Save Auto-withdrawal") }}</button>
            {% endif %}
        </form>
    <div class="flex p-4 mt-16 mb-4 bg-dark-600 rounded-lg">
        {{ _("- Halts auto-withdrawals to your Specter wallet from your Swan account") }}<br>
        {{ _("- Clears Swan data from Specter but does not delete the Specter wallet in your Swan account") }}<br>
    </div>
    <form action="{{ url_for(service.get_blueprint_name() + '.oauth2_delete_token') }}" method="POST" role="form">
        <input type="hidden" class="csrf-token" name="csrf_token" value="{{ csrf_token() }}"/>
        <button type="submit" class="button bg-red-800 text-white">{{ _("Remove Swan Integration") }}</button>
    </form>
</div>
{% endblock %}