<div class="wp-oauth2-client">
    <div class="container">
        <div class="card card-license shadow-sm position-relative">
            <div class="fs-5 card-header d-flex align-items-center bg-orange text-white py-4">
                <i class="bi bi-hdd-network d-block me-3" style="font-size: 2rem"></i>
                <span>WP-oAuth2 Client</span>
            </div>
            <div class="card-body pb-4">
                <div class="col-12 mx-auto">
                    <div class="card shadow-sm">
                        <div class="card-header bg-light d-flex align-items-center">
                            <div class="fs-5 py-3">
                                Client und Server Settings
                            </div>
                            <div class="ms-auto">
                                <div class="plugin-settings ms-auto ajax-status-spinner"></div>
                            </div>
                        </div>
                        <div class="card-body" style="min-height: 62vh">
                            <div class="d-flex flex-wrap align-items-center">
                                <button data-type="oauth_settings" data-target="#colOauthSettings"
                                        class="btn-action btn-toggle btn btn-blue-outline me-1 my-1"
                                        disabled>
                                    <i class="bi bi-fingerprint me-1"></i>Client-Einstellungen
                                </button>
                                <button data-type="plugin_settings" data-target="#colPluginSettings"
                                        class="btn-action btn-toggle btn btn-blue-outline me-1 my-1">
                                    <i class="bi bi-tools me-1"></i>Plugin Einstellungen
                                </button>
                            </div>
                            <hr>
                            {% if error %}
                                <h5 class="text-center text-danger">{{ error }}</h5>
                                <hr>
                            {% endif %}

                            <div id="collParent">
                                <div id="colOauthSettings" data-bs-parent="#collParent" class="collapse show">
                                    <form class="instagram-autosafe-form" data-target=".plugin-settings">
                                        <input type="hidden" name="method" value="oauth_settings_handle">
                                        <div class="row g-3">
                                            <div class="col-11">
                                                <div class="form-floating readonly">
                                                    <input type="url" name="callback_url"
                                                           class="form-control no-blur dblclick"
                                                           value="{% if s.callback_url is defined %}{{ s.callback_url }}{% else %}https://license.hu-ku.com/{% endif %}"
                                                           id="inputOauthUrl"
                                                           placeholder="Callback Url" required readonly>
                                                    <label for="inputOauthUrl">oAuth Callback Url</label>
                                                </div>
                                            </div>
                                            <div class="position-relative d-flex col-1">
                                                <button data-target="#inputOauthUrl" title="Kopieren"
                                                        class="mt-2 btn copy-action copy-clipboard text-body"
                                                        type="button">
                                                    <i class="bi bi-files"></i>
                                                </button>
                                                <span class="small-lg copy-client copied position-absolute text-danger ms-1">Kopiert!</span>
                                            </div>
                                            <div class="col-xl-6 col-12">
                                                <div class="form-floating readonly">
                                                    <input type="url" class="form-control no-blur"
                                                           value="{% if s.server_url is defined %}{{ s.server_url }}{% endif %}"
                                                           name="server_url" id="inputServerUrl"
                                                           placeholder="Server Url" required>
                                                    <label for="inputServerUrl">Server Url <sup>*</sup></label>
                                                </div>
                                            </div>
                                            <div class="col-xl-6 col-12"></div>

                                            <div class="col-xl-6 col-12">
                                                <div class="form-floating readonly">
                                                    <input type="text" name="authorize_uri"
                                                           class="dblclick form-control no-blur"
                                                           value="{% if s.authorize_uri is defined %}{{ s.authorize_uri }}{% endif %}"
                                                           id="inputAuthorizeUri"
                                                           placeholder="Callback Url" readonly required>
                                                    <label for="inputAuthorizeUri">Authorize Uri</label>
                                                </div>
                                            </div>
                                            <div class="col-xl-6 col-12">
                                                <div class="form-floating readonly">
                                                    <input type="text" name="token_uri"
                                                           class="dblclick form-control no-blur"
                                                           value="{% if s.token_uri is defined %}{{ s.token_uri }}{% endif %}"
                                                           id="inputTokenUri"
                                                           placeholder="Callback Url" readonly required>
                                                    <label for="inputTokenUri">Token Uri</label>
                                                </div>
                                            </div>
                                            <div class="col-xl-6 col-12">
                                                <div class="form-floating">
                                                    <input type="text" class="form-control no-blur"
                                                           value="{% if s.app_id is defined %}{{ s.app_id }}{% endif %}"
                                                           name="app_id" id="inputAppId"
                                                           placeholder="APP ID">
                                                    <label for="inputAppId">App ID</label>
                                                </div>
                                            </div>
                                            <div class="col-xl-6 col-12">
                                                <div class="form-floating">
                                                    <input type="text" class="form-control no-blur"
                                                           value="{% if s.app_secret is defined %}{{ s.app_secret }}{% endif %}"
                                                           name="app_secret" id="inputAppSecret"
                                                           placeholder="APP SECRET">
                                                    <label for="inputAppSecret">App Secret</label>
                                                </div>
                                            </div>
                                            <div class="col-12">
                                                <div class="pb-2 fw-semibold">Berechtigungen:</div>
                                                <div class="btn-group overflow-hidden" role="group"
                                                     aria-label="Basic checkbox toggle button group">
                                                    <input type="checkbox" class="btn-check"
                                                           id="btnCheckBasic"
                                                           autocomplete="off"
                                                           {% if s.checked_basis %}checked{% endif %} disabled>
                                                    <label data-type="checkScope"
                                                           class="btn btn-blue-check btn-action{% if s.checked_basis %} active{% endif %}"
                                                           for="btnCheckBasic">
                                                        Basic</label>
                                                    <input type="checkbox" class="btn-check"
                                                           id="btnCheckProduct"
                                                           autocomplete="off"
                                                           {% if s.checked_product %}checked{% endif %} disabled>
                                                    <label data-type="checkScope"
                                                           class="btn btn-blue-check btn-action{% if s.checked_product %} active{% endif %}"
                                                           for="btnCheckProduct">
                                                        Produkt</label>

                                                    {% if s.checked_admin %}
                                                        <input type="checkbox" class="btn-check"
                                                               id="btnCheckAdmin"
                                                               autocomplete="off"
                                                               {% if s.checked_admin %}checked{% endif %}>
                                                        <label data-type="checkScope"
                                                               class="btn btn-blue-check btn-action{% if s.checked_admin %} active{% endif %}"
                                                               for="btnCheckAdmin">
                                                            Admin</label>
                                                    {% endif %}
                                                    {% if s.checked_super_admin %}
                                                        <input type="checkbox" class="btn-check"
                                                               id="btnCheckSu"
                                                               autocomplete="off"
                                                               {% if s.checked_super_admin %}checked{% endif %}>
                                                        <label data-type="checkScope"
                                                               class="btn btn-blue-check btn-action{% if s.checked_super_admin %} active{% endif %}"
                                                               for="btnCheckSu">
                                                            Super Admin</label>
                                                    {% endif %}
                                                </div>
                                            </div>
                                        </div>
                                    </form>
                                    <hr>
                                    <div class="d-flex flex-wrap align-items-center">
                                        {# <div>
                                            <button data-type="api_update_scope" type="button"
                                                    class="btn-action btn btn-outline-secondary btn-sm">
                                                Update Berechtigungen
                                            </button>
                                        </div> #}
                                        {% if error_title %}
                                            <div>
                                                <h5 class="text-danger">{{ error_title }}</h5>
                                                <p class="text-danger">{{ error_msg }}</p>
                                            </div>
                                        {% endif %}
                                        <div class="scope-update ms-2 wait-update"></div>
                                        {% if isAuthentifiziert %}
                                            <div class="ms-auto">
                                                <button type="button" data-type="api_client_reset"
                                                        class="btn-action btn btn-outline-danger btn-sm">
                                                    Alle Einstellungen zurücksetzen
                                                </button>
                                            </div>
                                        {% endif %}
                                    </div>
                                    <div id="authInfo" class="{% if not s.server_url %}d-none{% endif %}">
                                        <hr>
                                        <div class="pt-2 fw-semibold text-orange">Authorize URL: <br>
                                            <span id="authorizeUrl"
                                                  class="fw-normal text-body">{{ s.server_url }}/{{ s.authorize_uri }}</span>
                                        </div>
                                        <div class="fw-semibold text-orange pt-1">Token URL:<br>
                                            <span id="tokenUrl"
                                                  class="fw-normal text-body">{{ s.server_url }}/{{ s.token_uri }}</span>
                                        </div>
                                    </div>
                                </div>
                                <div id="colPluginSettings" data-bs-parent="#collParent" class="collapse">
                                    <form class="instagram-autosafe-form" data-target=".plugin-settings">
                                        <input type="hidden" name="method" value="oauth_plugin_settings">
                                        <div class="row g-3">
                                            <div class="col-xl-5 col-lg-6 col-12">
                                                <div class="py-2">Mindestvoraussetzung für die Verwendung dieses
                                                    Plugins
                                                </div>
                                                <div class="form-floating">
                                                    <select class="form-select no-blur mw-100" name="plugin_min_role"
                                                            id="selectUserRole"
                                                            aria-label="select mindestanforderung">
                                                        {% for ur in select %}
                                                            <option value="{{ ur.value }}"
                                                                    {% if s.selected_user_role == ur.value %}selected{% endif %}>{{ ur.name }}</option>
                                                        {% endfor %}
                                                    </select>
                                                    <label for="selectUserRole">Benutzerrolle</label>
                                                </div>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="bottom-0 end-0 position-absolute my-1 me-3 text-end">
                {#  <small class="small-xl">
                    DB: <span class="text-danger">v{{ db }}</span>
                    | </small> #}
                <small class="small-xl">
                    Version: <span class="text-danger">v{{ version }}</span>
                </small>
            </div>
            <div class="bottom-0 start-0-0 position-absolute my-1 ms-3 text-start">
                <small class="small-xl">
                    Theme: {{ theme }}
                </small>
            </div>
        </div>
    </div>
</div>
<div id="snackbar-success"></div>
<div id="snackbar-warning"></div>
