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

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Abyss - Documentation</title>
    <link rel="icon" href="Static/IcoAbyssLogo.png" type="image/png">
    <meta content="Abyss" property="og:title">
    <meta content="Transforming Ideas into Reality\nWe push the boundaries of what's typical." property="og:description">
    <meta content="#43B581" name="theme-color">
    <link href="https://fonts.googleapis.com/css?family=Poppins" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/daisyui@4.4.22/dist/full.min.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="Style.css">
    <style>
        #Key {
            user-select: text;
        }
    </style>
</head>

<body class="dark:bg-[#19151c] bg-gray-100 transition-colors select-none text-white font-['Poppins', sans-serif]">
    <div id="loading">
        <span id="loadingText"></span>
        <span class="caret"></span>
    </div>

    <div style="position: relative; z-index: 10;">
        <nav class="nav-container" id="main-nav">
            <div class="nav-content transition-all">
                <div class="flex items-center justify-between">
                    <div class="flex items-center space-x-4">
                        <img src="Static/AbyssLogo.png" alt="Logo" class="logo" style="height: 50px;">
                    </div>
                    <div class="flex items-center space-x-6 invisible sm:visible">
                        <a href="https://abyssrbx.netlify.app/index.html" class="nav-button">Home</a>
                        <a href="https://abyssrbx.netlify.app/documentation.html" class="nav-button">Documentation</a>
                        <a href="https://github.com/DaCoderMane/AbyssDir/raw/refs/heads/main/Abyss.zip" class="nav-button">Download</a>
                    </div>
                    <div class="dropdown dropdown-end visible sm:invisible sm:hidden">
                        <label tabindex="0" class="btn btn-ghost btn-circle">
                            <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24"
                                stroke="currentColor">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                                    d="M4 6h16M4 12h16M4 18h7"></path>
                            </svg>
                        </label>
                    </div>
                </div>
            </div>
        </nav>

        <div class="page-content">
            <main class="flex items-center justify-center min-h-screen px-4 md:px-8 flex-col">
                <section id="introduction" class="text-center max-w-full md:max-w-4xl content">
                    <h1 class="neon-text">Abyss Key System</h1>
                    <a href="https://link-target.net/1271954/diddy-mode" class="btn btn-primary mt-4">Get Key</a>
                    <!-- Key Box -->
                    <div id="key-box" class="mt-6 p-6 bg-gray-800 rounded-xl shadow-md max-w-md mx-auto">
                        <p id="Key" class="text-lg font-semibold">^ Claim your key above ^</p>
                    </div>
                </section>
                
                <p class="footer-text mt-16">
                    Abyss <span class="version-tag text-gray-500">v2.0.0</span>
                </p>
            </main>
        </div>
    </div>
    <canvas id="SnowflakeCanvas" style="position: fixed; top: 0; left: 0; z-index: 0;"></canvas>

    <script src="Download.js"></script>
    <script src="Loading.js"></script>
    <script src="Snowflakes.js"></script>
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2"></script>

    <script>
        const { createClient } = supabase;
        const supabaseClient = createClient(
            'https://cgymanfbfwofvtijxdoa.supabase.co',
            'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNneW1hbmZiZndvZnZ0aWp4ZG9hIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MzU0MjA5NzYsImV4cCI6MjA1MDk5Njk3Nn0.3P2uCniKZqkAO_IkhNkKU6pGYeKyaPYIC3thssXZYJs'
        );

        function generateRandomKey() {
            const prefix = "Abyss";
            const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
            let randomPart = '';
            
            for (let i = 0; i < 20; i++) {
                randomPart += characters.charAt(Math.floor(Math.random() * characters.length));
            }

            return `${prefix}-${randomPart.slice(0, 6)}-${randomPart.slice(6, 12)}-${randomPart.slice(12, 18)}-${randomPart.slice(18)}`;
        }

        const generated_key = generateRandomKey();

        // Function to set a cookie
        function setCookie(name, value, days) {
            const date = new Date();
            date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
            const expires = "expires=" + date.toUTCString();
            document.cookie = name + "=" + value + ";" + expires + ";path=/";
        }

        // Function to get a cookie by name
        function getCookie(name) {
            const nameEQ = name + "=";
            const ca = document.cookie.split(';');
            for (let i = 0; i < ca.length; i++) {
                let c = ca[i];
                while (c.charAt(0) == ' ') c = c.substring(1, c.length);
                if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
            }
            return null;
        }

        window.onload = async function() {
            // Check if the page has already been visited from Linkvertise using cookies
            if (getCookie('visitedFromLinkvertise') && document.referrer.includes("linkvertise.com")) {
                console.log("Already visited from Linkvertise");
                document.getElementById('Key').textContent = "Key already claimed for today";
            } else if (!getCookie('visitedFromLinkvertise') && document.referrer.includes("linkvertise.com")) {
                console.log("Redirected from Linkvertise!");
                alert("You came from Linkvertise!");

                // Set the cookie to prevent showing the message again
                setCookie('visitedFromLinkvertise', 'true', 1); // Cookie expires after 1 day

                try {
                    const { error } = await supabaseClient
                    .from('hwid_keys')
                    .insert({ key: generated_key, key_type: 'day'})

                    if (error) throw error;
                    document.getElementById('Key').textContent = `Your key is: ${generated_key}`;
                } catch (error) {
                    console.error("Error inserting key: ", error.message);
                }
            } else {
                console.log("This page was not reached through Linkvertise.");
            }
        };
    </script>
</body>
</html>