<!DOCTYPE html>
<html lang="en">

<head>
    <base href="{{it.basePath}}">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
    <title>txAdmin Login</title>
    <meta name="description" content="Remotely Manage & Monitor your GTA5 FiveM Server with txAdmin v{{it.txAdminVersion}} atop FXServer {{it.fxServerVersion}}">
    <meta name="author" content="André Tabarra">
    <meta name="robots" content="noindex">
    <!-- Open Graph Meta Tags -->
    <meta property="og:url" content="https://github.com/tabarra/txAdmin">
    <meta property="og:type" content="website">
    <meta property="og:title" content="txAdmin - {{it.serverName}}">
    <meta property="og:description" content="Remotely Manage & Monitor your GTA5 FiveM Server with txAdmin v{{it.txAdminVersion}} atop FXServer {{it.fxServerVersion}}">
    <meta property="og:image" content="https://i.imgur.com/Z3S9q6J.png">
    <!--style-->
    <!-- <link rel="stylesheet" href="css/simple-line-icons.css"> -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/simple-line-icons/2.4.0/css/simple-line-icons.min.css" 
        integrity="sha512-yxSQDoat2NPQ9U4mKdYra2YNenVsnRuGxVvyrirmrDKzwOdxKJVqkDEvQ17pL/PJ6B7n2n77Xm6d62bMjCBqCQ==" 
        crossorigin="anonymous" referrerpolicy="no-referrer" />
    <link href="css/coreui.min.css" rel="stylesheet">
    <link rel="shortcut icon" type="image/png" href="img/favicon_default.png" id="favicon" />
    <link rel="stylesheet" href="css/txAdmin.css">
    <link rel="stylesheet" href="css/dark.css">

    <style>
        .logo-image svg{
            height: 25px;
            width: 25px;
            transform: scale(-1, 1);
            text-align: center;
            fill: #fff;
        }

        .profile-pic{
            height: 100px;
            -moz-box-shadow: 2px 4px 8px rgb(143, 143, 143);
            -webkit-box-shadow: 2px 4px 8px rgb(143, 143, 143);
            box-shadow: 2px 4px 8px rgb(143, 143, 143);
            border-radius: 50em;
        }

        .zapAdContainer{
            width: 100%;
            display: flex;
            color: unset !important;
        }
        .zapLogo {
            /* background-color: salmon; */
            height: 44px;
            margin-top: auto;
            margin-bottom: auto;
        }
        .zapText {
            /* background-color: royalblue; */
            font-size: 1.25em;
            font-weight: 700;
            width: 100%;
            padding-left: 8px;
            align-self: center;
        }
        .zapTextIcon {
            margin-top: -0.25em;
            width: 0.9rem !important;
            height: 0.9rem !important;
            font-size: 0.9rem !important;
        }
    </style>
    {{@if(it.isMatrix)}}
        <style>
            * {
                font-family: Consolas, monospace, serif;
                color: lawngreen;
            }
            .c-app{
                background-color: #23282c;
            }
            pre{
                margin-bottom: -15px;
            }
            .card{
                background-color: #23282c;
                border: 4px solid lawngreen;
            }
            .alert-secondary{
                background-color: #23282c;
                border: 2px solid lawngreen;
            }
            .btn-primary {
                color: lawngreen;
                border: 2px solid lawngreen;
                background-color: transparent;
            }
            .btn-primary:hover {
                border: 2px solid black;
                color: black;
                font-weight: 700;
                background-color: lawngreen;
            }
            .hrsep::before, .hrsep::after {
                border-top: 1px dashed lawngreen;
            }
            .hrsep{
                color: lawngreen;
            }

            .card-footer {
                background-color: darkgreen;
                border-top: 2px solid lawngreen;
            }

            input,
            .btn-stack-overflow,
            .btn-linkedin,
            input:-webkit-autofill,
            input:-webkit-autofill:hover,
            input:-webkit-autofill:focus,
            .input-group-text{
                background-color: transparent !important;
                border: 1px solid lawngreen !important;
                -webkit-text-fill-color: #fff;
                transition: background-color 5000s ease-in-out 0s;
            }

        </style>
    {{/if}}

    <!-- injected consts -->
    <script>{{it.jsInjection|safe}}</script>
    
</head>

<body class="c-app flex-row align-items-center {{it.uiTheme}}">
    <svg style="display:none">
        <symbol id="fivem-icon" viewBox="0 0 342 430">
            <g transform="matrix(1,0,0,-1,-124.2,606.4)">
                <path d="m 125.8,215.9 85.1,0 c 1.9,0 7.4,18.3 16.7,54.9 32.3,112.4 50.9,178.1 55.7,197.2 l -54.9,54.1 -1.6,0 C 219.4,499 185.2,397.2 124.2,216.7 l 1.6,-0.8 z m 163.8,275.2 0.8,0 c 1.1,4.5 1.6,7.2 1.6,8 l 0,1.6 c -15.9,16.7 -33.7,34.5 -53.3,53.3 -2.1,-3.2 -3.2,-5.8 -3.2,-8 l 0,-0.8 c 19.9,-20.5 37.9,-38.5 54.1,-54.1 z M 393,429 l 0.8,0 c -10.9,34.5 -17.5,52.2 -19.9,53.3 L 254.6,600.8 c -1.3,0 -4.2,-8.5 -8.7,-25.4 L 393,429 Z m -22.3,65.3 0.8,0 c -24.4,74 -37.4,111.3 -39,112.1 l -73.2,0 0,-0.8 C 286.4,578 323.5,540.9 370.7,494.3 Z m 43.8,-128.1 0.8,0 c -2.7,13 -9,23.1 -19.1,30.2 -31,31.8 -62,62.8 -93,93 l -0.8,0 c 1.9,-10.9 6.1,-19.1 12.7,-24.7 l 99.4,-98.5 z m 50.1,-150.3 1.6,0.8 c -22.8,67.9 -35,102.9 -36.6,105 l -109.8,108.9 0,-0.8 c 4.2,-16.7 24.7,-88 61.2,-213.9 l 83.6,0 z" />
            </g>
        </symbol>
    </svg>
    <div class="container">

        <!-- Logo Row -->
        {{@if(it.isWebInterface)}}
            {{@if(it.isMatrix)}}
                <div class="row justify-content-center mb-4"><pre><b>{{it.ascii}}</b></pre></div>
            {{#else}}
                <div class="row justify-content-center mb-4">
                    <img src="{{it.logoURL}}" alt="txAdmin Logo">
                </div>
            {{/if}}
        {{/if}}

        <!-- Card Row -->
        <div class="row justify-content-center">
            <div class="col-lg-5">
                <div class="card ">
                    <div class="card-body text-center p-4">
                        {{@if(it.template == 'justMessage')}}
                            <h4 class="text-danger">{{it.errorTitle}}</h4>
                            <p class="font-weight-bold">{{it.errorMessage}}</p>
                            <a href="auth" class="btn btn-primary px-4 mt-3" role="submit">Back</a>
                        {{/if}}
                        {{@if(it.template == 'noMaster')}}
                            <h3 class="mb-4">No <code>CitizenFX</code> Account Linked</h3>
                            <div class="mx-auto">
                                <h6>Type the PIN from your terminal and click "Link Account".</h6>
                                <form action="/auth/addMaster/pin" method="post">
                                    <p class="text-success font-weight-bold mb-0 d-none" id="noMaster-autofill">Autofilled</p>
                                    <div class="input-group mx-auto" style="max-width: 140px;" id="noMaster-div">
                                        <input class="form-control form-control-lg text-center mb-3" type="text"
                                        minlength="4" maxlength="4" name="pin" placeholder="0000" 
                                        style="padding-right: 1rem !important;" autocomplete="off"  
                                        id="noMaster-pin" autofocus required>
                                    </div>
                                    <button class="btn btn-primary px-4" 
                                        type="submit">Link Account</button>
                                </form>
                            </div>
                            <script>
                                if(/^#\d{4}$/.test(window.location.hash)) {
                                    const label = document.getElementById('noMaster-autofill');
                                    const pinInput = document.getElementById('noMaster-pin');

                                    label.classList.remove('d-none');
                                    pinInput.value = window.location.hash.substring(1);
                                    pinInput.classList.add('is-valid');
                                    pinInput.onkeydown = (e) => {
                                        pinInput.classList.remove('is-valid');
                                        label.classList.add('d-none');
                                    }
                                }
                            </script>
                        {{/if}}
                        {{@if(it.template == 'callback')}}
                            <img class="profile-pic" src="{{it.addMaster_picture}}" alt="avatar">
                            <h5 class="mt-2 mb-3 text-muted">{{it.addMaster_name}}</h5>

                            <h5>Type in the <i>backup</i> password:</h5>
                            <form action="/auth/addMaster/save" method="post">
                                <div class="input-group mb-2 mx-auto" style="max-width: 280px;">
                                    <div class="input-group-prepend">
                                        <span class="input-group-text">
                                            <i class="icon-lock"></i>
                                        </span>
                                    </div>
                                    <input class="form-control" type="password" name="password" id="password"
                                        placeholder="Password" autocomplete="new-password" minlength="6" maxlength="24" autofocus required>
                                </div>
                                <div class="input-group mx-auto" style="max-width: 280px;">
                                    <div class="input-group-prepend">
                                        <span class="input-group-text">
                                            <i class="icon-lock"></i>
                                        </span>
                                    </div>
                                    <input class="form-control" type="password" name="password2" id="password2"
                                        placeholder="Confirm Password" autocomplete="new-password" required>
                                </div>
                                <span class="form-text text-muted mb-4">
                                    Must be between 6 and 24 characters.
                                </span>
                                <button class="btn btn-primary px-4" type="submit">Save</button>
                            </form>
                            <script>
                                let password = document.getElementById("password")
                                let password2 = document.getElementById("password2");
                                function validatePassword(){
                                    if(password.value != password2.value) {
                                        password2.setCustomValidity("Passwords Don't Match");
                                    } else {
                                        password2.setCustomValidity('');
                                    }
                                }
                                password.onchange = validatePassword;
                                password2.onkeyup = validatePassword;
                            </script>
                        {{/if}}
                        {{@if(it.template == 'normal')}}
                            <h1 class="mb-3">Login</h1>
                            {{@if(it.isWebInterface)}}
                                <a class="btn btn-brand btn-stack-overflow {{it.citizenfxDisabled|isDisabled}}"
                                    role="button" href="auth/citizenfx/redirect">
                                    <i class="logo-image"><svg><use href="#fivem-icon"></use></svg></i>
                                    <span>CitizenFX</span>
                                </a>
                            {{#else}}
                                <h5 class="text-secondary">
                                    Automatic login failed, re-open the menu or login using your username/password below.
                                </h5>
                            {{/if}}
                            <div class="hrsep">OR</div>

                            <form action="auth/password" method="post">
                                <div class="input-group mb-2 mx-auto" style="max-width: 280px;">
                                    <div class="input-group-prepend">
                                        <span class="input-group-text">
                                            <i class="icon-user"></i>
                                        </span>
                                    </div>
                                    <input class="form-control" type="text" name="username" placeholder="Username" required>
                                </div>
                                <div class="input-group mb-4 mx-auto" style="max-width: 280px;">
                                    <div class="input-group-prepend">
                                        <span class="input-group-text">
                                            <i class="icon-lock"></i>
                                        </span>
                                    </div>
                                    <input class="form-control" type="password" name="password" placeholder="Password" required>
                                </div>
                                <div class="row justify-content-center">
                                    <button class="btn btn-primary px-4" type="submit">Login</button>
                                </div>
                            </form>
                        {{/if}}
                    </div>
                    {{@if(it.message && it.template != 'justMessage')}}
                        <div class="card-footer text-center text-danger">
                            <strong>{{it.message}}</strong>
                        </div>
                    {{/if}}
                </div>
            </div>
        </div>

        <!-- Info Row -->
        <div class="row justify-content-center">
            <div class="col-md-4 ">
                <div class="alert alert-secondary text-center small" role="alert">
                    <h5 class="text-muted">
                        <strong>txAdmin</strong> Official Discord: <br>
                        <a href="https://discord.gg/uAmsGa2" target="_blank">
                            <img src="https://discordapp.com/api/guilds/577993482761928734/widget.png?style=shield"></img>
                        </a>
                    </h5>
                    
                    {{@if(it.dynamicAd)}}
                        <div class="hrsep hrsep-small">Ad</div>
                        <a class="zapAdContainer" href="{{it.dynamicAd.link}}" target="_blank" rel="noopener noreferrer">
                            <img class="zapLogo show-dark-mode" alt="zap hosting" src="{{it.dynamicAd.logoDarkMode}}">
                            <img class="zapLogo show-light-mode" alt="zap hosting" src="{{it.dynamicAd.logoLightMode}}">
                            <div class="zapText attentionText">
                                {{it.dynamicAd.text|safe}}
                                <svg class="c-icon zapTextIcon">
                                    <use href="img/coreui_icons.svg#cil-external-link"></use>
                                </svg>
                            </div>
                        </a>
                    {{/if}}

                    <div class="hrsep hrsep-small">Info</div>
                    <div class="text-muted">
                        <strong>Server profile:</strong> {{it.serverProfile}} <br>
                        <strong>txAdmin version:</strong> {{it.txAdminVersion}} <br>
                        <strong>FXServer build:</strong> {{it.fxServerVersion}} 
                    </div>
                </div>

                <!-- Dark/Light mode toggle -->
                {{@if(it.isWebInterface)}}
                    <div style="text-align: center">
                        <svg class="c-sidebar-nav-icon d-none" id="darkToggleLight">
                            <use href="img/coreui_icons.svg#cil-sun"></use>
                        </svg>
                        <svg class="c-sidebar-nav-icon" id="darkToggleDark">
                            <use href="img/coreui_icons.svg#cil-moon"></use>
                        </svg>
                    </div>
                {{/if}}
            </div>
        </div>
        {{@if(it.isMatrix)}}
            <div class="row justify-content-center">
                <div class="col-md-4 text-center pt-3">
                    <h4>The Matrix has you...</h4>
                </div>
            </div>
        {{/if}}


    </div>
    <!-- CoreUI and necessary plugins-->
    <!-- <script src="js/jquery.min.js"></script> -->
    <script src="https://code.jquery.com/jquery-3.6.0.min.js" 
        integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" 
        crossorigin="anonymous"></script>
    <script src="{{it.resourcePath}}js/coreui.bundle.min.js"></script>
    <script src="{{it.resourcePath}}js/txadmin/base.js"></script>
    <script>
        window.history.pushState(null, 'txAdmin', '/auth');
    </script>
</body>

</html>
