<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Firebase Token Retrieval</title>
    <style>
        html, body {
            height: 100%;
            margin: 0;
            padding: 0;
            overflow-x: hidden;
            background: linear-gradient(135deg, #1e1e1e, #3a3a3a);
            font-family: Arial, Helvetica, sans-serif;
        }
        body {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: flex-start;
            min-height: 100vh;
            overflow-y: auto;
        }
        .container {
            width: 100%;
            max-width: 400px;
            padding: 20px;
            box-sizing: border-box;
        }
        .gradient-text {
            font-size: 64px;
            font-weight: bold;
            background: linear-gradient(90deg, white, #4d4d4d, white);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            margin: 20px 0;
            text-align: center;
        }
        .card {
            background-color: #e0e0e0;
            border-radius: 12px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            width: 100%;
            padding: 20px;
            text-align: center;
            box-sizing: border-box;
            margin-bottom: 20px;
        }
        .card h2 {
            margin: 0 0 20px;
            color: #333;
        }
        .card .details {
            margin-bottom: 20px;
            color: #555;
            font-size: 14px;
            text-align: center;
        }
        .install-button {
            background-color: #6c63ff;
            color: white;
            border: none;
            border-radius: 8px;
            padding: 15px 20px;
            cursor: pointer;
            font-size: 16px;
            font-weight: bold;
            width: 100%;
            text-align: center;
            box-sizing: border-box;
            max-width: 400px;
            margin: 0 auto 20px;
            text-decoration: none;
            display: block;
        }
        .install-button:hover {
            background-color: #5753d6;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="gradient-text">NOTIX</div>
        <div class="card">
            <h2 id="app-name">Device Token</h2>
            <div class="details">
                <p><strong>Developer:</strong> NotixDev</p>
                <p><strong>Version:</strong> <span id="app-version">1</span></p>
                <p><strong>Token:</strong> <span id="device-token">Loading...</span></p>
            </div>
            <div class="install-button" id="copy-button">Copy Token</div>
        </div>
    </div>
    <script src="https://www.gstatic.com/firebasejs/9.16.0/firebase-app.js"></script>
    <script src="https://www.gstatic.com/firebasejs/9.16.0/firebase-messaging.js"></script>
    <script>
        const firebaseConfig = {
            apiKey: "AIzaSyCi_8yjwFA5XWnqG4-DvTP1G-BE-e6pDVs",
            authDomain: "projectnotix.firebaseapp.com",
            projectId: "projectnotix",
            storageBucket: "projectnotix.appspot.com",
            messagingSenderId: "633354009108",
            appId: "1:633354009108:web:6987b56d261a84aae98501",
            measurementId: "G-PWWK25TF8W"
        };

        // Initialize Firebase
        const app = firebase.initializeApp(firebaseConfig);
        const messaging = firebase.messaging();

        // Request Notification permission and get the token
        messaging.requestPermission()
            .then(() => {
                console.log('Notification permission granted.');
                return messaging.getToken();
            })
            .then((token) => {
                console.log('Device token:', token);
                document.getElementById('device-token').textContent = token;
            })
            .catch((error) => {
                console.error('Error retrieving device token:', error);
                document.getElementById('device-token').textContent = 'Error retrieving token';
            });

        // Copy Token to Clipboard
        document.getElementById('copy-button').addEventListener('click', () => {
            const tokenElement = document.getElementById('device-token');
            const token = tokenElement.textContent;

            if (token !== 'Loading...' && token !== 'Error retrieving token') {
                navigator.clipboard.writeText(token)
                    .then(() => {
                        alert('Token copied to clipboard!');
                    })
                    .catch((error) => {
                        console.error('Error copying token:', error);
                        alert('Failed to copy token.');
                    });
            } else {
                alert('No token available to copy.');
            }
        });
    </script>
</body>
</html>