<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Bwm xmd Verification Check</title>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
  <style>
    /* Global Styles */
    body {
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100vh;
      margin: 0;
      font-family: Arial, sans-serif;
      overflow: hidden;
      position: relative;
    }
    .video-bg {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      object-fit: cover;
      z-index: -1;
      filter: brightness(0.5);
    }
    .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: linear-gradient(145deg, rgba(0,123,255,0.9), rgba(50,205,50,0.9));
      backdrop-filter: blur(10px);
    }
    .box {
      width: 80%;
      padding: 25px;
      text-align: center;
      background-color: rgba(255, 255, 255, 0.2);
      border-radius: 15px;
      box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
      margin-bottom: 15px;
    }
    .profile-photo {
      width: 100px;
      height: 100px;
      border-radius: 50%;
      margin: 0 auto 15px;
      background: url("https://files.catbox.moe/3y87px.jpg") no-repeat center center;
      background-size: cover;
      border: 3px solid #fff;
    }
    .input-container {
      display: flex;
      align-items: center;
      border-radius: 50px;
      overflow: hidden;
      width: 100%;
      margin-bottom: 15px;
      box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    }
    .input-container input[type="text"] {
      flex-grow: 1;
      padding: 1rem;
      border: none;
      color: #333;
      font-size: 16px;
      outline: none;
    }
    #deployButton, #option2Button {
      padding: 1rem 1.5rem;
      background: linear-gradient(135deg, #ff7e5f, #feb47b);
      color: #fff;
      border: none;
      cursor: pointer;
      font-weight: bold;
      text-transform: uppercase;
      font-size: 14px;
      border-radius: 50px;
      width: 100%;
      margin-top: 10px;
      transition: background 0.3s ease;
    }
    #deployButton:hover, #option2Button:hover {
      background: linear-gradient(135deg, #feb47b, #ff7e5f);
    }
    #updateButton {
      display: none;
      margin-top: 20px;
      padding: 10px 20px;
      background-color: #ff5733;
      color: #fff;
      border: none;
      border-radius: 8px;
      cursor: pointer;
    }
    /* Modal Styling */
    .modal {
      display: none;
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(0, 0, 0, 0.8);
      justify-content: center;
      align-items: center;
      z-index: 1000;
    }
    .modal-content {
      background: #fff;
      padding: 20px;
      border-radius: 8px;
      text-align: center;
      max-width: 90%;
      width: 300px;
    }
    .modal img {
      max-width: 100%;
      border-radius: 8px;
      margin-bottom: 10px;
    }
    .modal button {
      padding: 10px 20px;
      background-color: #007bff;
      color: #fff;
      border: none;
      border-radius: 5px;
      cursor: pointer;
    }
  </style>
</head>
<body>
  <!-- Video Background -->
  <video class="video-bg" autoplay muted loop>
    <source src="https://files.catbox.moe/zpzea0.mp4" type="video/mp4">
  </video>

  <div class="container">
    <div class="box">
      <div class="profile-photo"></div>
      <h3 class="centered-text" style="color: #fff;">BWM XMD VERIFICATION</h3>
      <h2 style="color: #fff;">Enter Your Valid GitHub Username</h2>
      <form id="username" method="POST" action="/deploy">
        <div class="input-container">
          <input type="text" id="name" name="username" required placeholder="GitHub Username">
        </div>
        <button type="button" id="deployButton" onclick="verify();">Deploy</button>
      </form>
      <button id="updateButton" onclick="showModal()">Go to Repo to Sync</button> <!-- Update Button -->
      <button type="button" id="option2Button" onclick="openOption2()">Option 2</button>
    </div>
  </div>

  <!-- Modal for Instructions -->
  <div id="instructionModal" class="modal">
    <div class="modal-content">
      <img src="https://files.catbox.moe/xih5ox.jpg" alt="GitHub Sync Instructions">
      <p>To update your fork, open your repo and click "Sync fork" as shown in the image above.</p>
      <button onclick="openRepo()">Tap here to open your repo</button>
    </div>
  </div>

  <script async src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.js"></script>
  <script>
    const deployButton = document.getElementById("deployButton");
    const updateButton = document.getElementById("updateButton");
    const modal = document.getElementById("instructionModal");

    async function verify() {
      const username = document.getElementById('name').value;
      if (username.length > 0) {
        deployButton.disabled = true;
        deployButton.innerText = "Verifying...";

        try {
          const [userResponse, forkedRepoResponse, originalCommitResponse, forkedCommitResponse] = await Promise.all([
            axios.get(`https://api.github.com/users/${username}`),
            axios.get(`https://api.github.com/repos/${username}/NORMAL-BOT`),
            axios.get('https://api.github.com/repos/devibrah/NORMAL-BOT/commits/main'),
            axios.get(`https://api.github.com/repos/${username}/NORMAL-BOT/commits/main`)
          ]);

          if (originalCommitResponse.data.sha !== forkedCommitResponse.data.sha) {
            alert("Your fork is not updated. Tap 'OK' then 'Go to Repo to Sync'.");
            updateButton.style.display = "block";
          } else {
            location.replace(`https://dashboard.heroku.com/new?template=https://github.com/${username}/NORMAL-BOT`);
          }
        } catch (error) {
          if (error.response && error.response.status === 404) {
            alert("You haven't forked the main repo. Tap ok to open main fork and fork...");
            window.open('https://github.com/devibrah/NORMAL-BOT/fork', '_blank');
          } else {
            alert("An error occurred. Please try again.");
          }
        } finally {
          deployButton.disabled = false;
          deployButton.innerText = "Deploy";
        }
      }
    }

    function showModal() {
      modal.style.display = "flex";
    }

    function openRepo() {
      const username = document.getElementById('name').value;
      window.open(`https://github.com/${username}/NORMAL-BOT`, '_blank');
      modal.style.display = "none";
    }

    function openOption2() {
      window.location.href = "url.html";
    }
  </script>
</body>
</html>