<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Cheat Detected</title>
    <link rel="stylesheet" href="style-detected.css" />
    <script src="qwebchannel.js"></script>
    <script>
        let bridge;
        let remainingSeconds = 0;

        // Подключение WebChannel
        new QWebChannel(qt.webChannelTransport, function(channel) {
            bridge = channel.objects.bridge;
        });

        function initBanData() {
            const bannedUntil = parseInt(localStorage.getItem("banned_until") || "0");
            const serverTime = parseInt(localStorage.getItem("server_time") || "0");
            const attempts = parseInt(localStorage.getItem("ban_attempts") || "1");
            const readable = localStorage.getItem("ban_remaining") || "";

            const now = Math.floor(Date.now() / 1000);
            const timePassed = now - serverTime;
            remainingSeconds = bannedUntil - (serverTime + timePassed);

            const readableElement = document.getElementById("readable-time");
            const attemptsElement = document.getElementById("attempts-info");
            const nextBanElement = document.getElementById("next-ban-info");

            readableElement.innerText = readable ? `Original Ban: ${readable}` : "";

            attemptsElement.innerText = `❗ Current bans: ${attempts}`;
            const nextBanMap = {
                1: "2nd ban → 24 hours",
                2: "3rd ban → 7 days",
                3: "4th ban → 30 days",
                4: "5+ bans → Permanent ban"
            };
            nextBanElement.innerText = nextBanMap[attempts] || "Permanent ban on next detection.";
        }

        function updateRemainingTime() {
            const timeElement = document.getElementById("remaining-time");

            if (remainingSeconds > 0) {
                const hours = Math.floor(remainingSeconds / 3600);
                const minutes = Math.floor((remainingSeconds % 3600) / 60);
                const seconds = remainingSeconds % 60;
                timeElement.innerText = `⏳ Time left: ${hours}h ${minutes}m ${seconds}s`;
                remainingSeconds--;
            } else {
                timeElement.innerText = "✅ You are no longer banned. Restart the launcher.";
            }
        }

        function contactAdmin() {
            if (bridge && bridge.openSupport) {
                bridge.openSupport();
            } else {
                window.open("https://discord.com/invite/99THRqBGhZ", "_blank");
            }
        }

        window.onload = function () {
            initBanData();
            updateRemainingTime();
            setInterval(updateRemainingTime, 1000);
        };
    </script>
</head>
<body>
    <div class="container">
        <div class="warning-box">
            <img src="../images/icon_acoff.png" alt="Alert" class="icon" />
            <h1>❌ Cheat Detected</h1>
            <p>Your session has been terminated due to detection of forbidden software.</p>
            <p>Please close all cheat-related programs and restart the launcher.</p>

            <p id="remaining-time">Loading remaining ban time...</p>
            <p id="readable-time" style="color: #888; font-size: 14px;"></p>
            <p id="attempts-info" style="color: #ff9999; font-weight: bold;"></p>
            <p id="next-ban-info" style="color: #ffaa00;"></p>

            <button class="contact-button" onclick="contactAdmin()">Contact Admin</button>
            <p class="note">If you believe this is a mistake, contact server staff.</p>
        </div>
    </div>
</body>
</html>
