<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>MATRIX MD Verification Check</title>
  <style>
    body {
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100vh;
      margin: 0;
      font-family: Arial, sans-serif;
      background: url('https://files.catbox.moe/omgszj.jpg') no-repeat center center fixed;
      background-size: cover;
      overflow: hidden;
    }
    .container {
      display: flex;
      flex-direction: column;
      align-items: center;
      width: 100%;
      max-width: 400px;
      padding: 20px;
      border-radius: 15px;
      box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
      background: rgba(0, 0, 0, 0.6);
      color: #fff;
    }
    .input-container {
      display: flex;
      flex-direction: column;
      width: 100%;
      margin-bottom: 15px;
    }
    input[type="text"] {
      padding: 10px;
      border: none;
      border-radius: 5px;
      font-size: 16px;
      width: 100%;
    }
    button {
      padding: 10px 20px;
      border: none;
      border-radius: 5px;
      cursor: pointer;
      font-weight: bold;
      color: #fff;
      background-color: #007bff;
      margin-top: 10px;
    }
    button:hover {
      background-color: #0056b3;
    }
  </style>
</head>
<body>
  <div class="container">
    <h2>MATRIX-MD VERIFICATION</h2>
    <h4>Enter Your Valid GitHub Username</h4>
    <div class="input-container">
      <input type="text" id="username" placeholder="GitHub Username" required>
    </div>
    <button onclick="verify()">Verify</button>
  </div>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.js"></script>
  <script>
    async function verify() {
      const username = document.getElementById('username').value.trim();

      if (!username) {
        alert("Please enter a valid GitHub username.");
        return;
      }

      try {
        // Check if the forked repo exists
        const forkedRepo = await axios.get(`https://api.github.com/repos/${username}/MATRIX-XMD`);
        // If fork exists, redirect to Heroku deployment
        location.replace(`https://dashboard.heroku.com/new?template=https://github.com/${username}/MATRIX-XMD`);
      } catch (error) {
        if (error.response && error.response.status === 404) {
          // If fork does not exist, redirect to original repo
          alert("You haven't forked the main repo. Tap OK to open the main repo and fork it.");
          window.open('https://github.com/Trevley/MATRIX-XMD', '_blank');
        } else {
          alert("An error occurred. Please try again.");
        }
      }
    }
  </script>
</body>
</html>