{% extends "swan/components/swan_tab.jinja" %}
{% block title %}Settings{% endblock %}
{% set tab = 'settings' %}
{% block content %}
    <br/>
    <style>
        {# TODO: Remove these classes after Swan exits Beta #}
        .big_option {
            display: inline-block;
            width: 14em;
            padding: 1em;
            vertical-align: middle;
            height: 3.5em;
            border: 4px solid var(--cmap-border);
            border-radius: 0.5em;
            background-color: var(--cmap-bg-lighter);
            font-size: 1.5em;
            margin: 1em;
            position: relative;
            
        }
        .big_option:hover {
            background-color: var(--cmap-bg-lightest);
            border: 4px solid var(--main-color);
            cursor: pointer;
        }

        .big_option_text {
            margin: 0;
            position: absolute;
            top: 50%;
            left: 50%;
            -ms-transform: translate(-50%, -50%);
            transform: translate(-50%, -50%);
        }

        .instructions {
            color: #999;
            font-style: italic;
        }
        {# TODO: End Remove #}

        .css-1rbd7t8 {
            box-sizing: border-box;
            margin: 60px 0px 24px;
            min-width: 0px;
        }
        .css-yn7azs {
            box-sizing: border-box;
            margin: 0px;
            min-width: 0px;
            -moz-box-pack: justify;
            justify-content: space-between;
            position: relative;
            font-family: "Source Serif Pro", serif;
            font-weight: 600;
            line-height: 1.5;
            letter-spacing: -0.02em;
            font-variant: common-ligatures;
            text-rendering: optimizelegibility;
            font-size: 16px;
            display: flex;
        }
    </style>

    <div class="card">
        <h1>{{ _("Configure Auto-Withdrawal") }}</h1>
        <br>

        <div class="note">
            {{ _("- Specter will send {} unused addresses to Swan").format(num_reserved_addrs) }}<br/>
            {{ _("- Your wallet will show them pre-labeled as \"reserved\" for Swan") }}<br/>
            {{ _("- Specter will check these addresses each time you log in to Specter") }}<br/>
            {{ _("- Specter will send more unused addresses to Swan as needed") }}<br/>
        </div>
        <br/>

        <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() }}"/>
            
            {{ _("Withdraw to wallet") }}:<br>
            <select name="destination_wallet">
                {% for wallet in wallets %}
                    <option value="{{ wallet.alias }}" {% if associated_wallet == wallet %}selected{% endif %}>{{ wallet.name }}</option>
                {% endfor %}
            </select>
            <br/>
            <br/>
            <br/>

            <div>Auto-withdrawal threshold:</div>
            <select name="threshold">
                <option value="0"     {% if threshold == '0' %}selected{% endif %}>Weekly</option>
                <option value="0.01"  {% if threshold == '0.01' %}selected{% endif %}>0.010 BTC</option>
                <option value="0.025" {% if threshold == '0.025' %}selected{% endif %}>0.025 BTC</option>
                <option value="0.05"  {% if threshold == '0.05' %}selected{% endif %}>0.050 BTC</option>
            </select>
            <br/>
            <br/>
            <br/>
            
            <div class="row">
                <button type="submit" class="btn">{{ _("Update Auto-withdrawal") }}</button>
            </div>

        </form>
    </div>
    <br/>
    <br/>
    <br/>


    <div class="card">
        <h1>{{ _("Remove Swan Integration") }}</h1>
        <br/>
        <div class="note">
            {{ _("- Halts Swan auto-withdrawals to your Specter wallet") }}<br/>
            {{ _("- Clears Swan data from Specter") }}<br/>
        </div>
        <br/>

        <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() }}"/>
            <div class="row">
                <button type="submit" class="btn danger">{{ _("Remove Swan Integration") }}</button>
            </div>
        </form>
    </div>
    <br/>
    <br/>
    <br/>

{% endblock %}