<!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>
  <style>
    body {
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100vh;
      margin: 0;
      font-family: Arial, sans-serif;
      background-color: #f4f4f4;
    }
    .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);
    }
    .input-container input, button {
      width: 100%;
      padding: 10px;
      margin: 10px 0;
      border-radius: 50px;
      box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    }
    button {
      background: linear-gradient(135deg, #ff7e5f, #feb47b);
      color: #fff;
      cursor: pointer;
      border-radius: 50px;

      
      
    }
</style>
</head>
<body>
  <!-- Video Background -->
  <video class="video-bg" autoplay muted loop>
    <source src="https://files.catbox.moe/ks39u0.mp4" type="video/mp4">
  </video>
  <div class="container">
    <h2>Enter Forked Repo URL</h2>
    <div class="input-container">
      <input type="text" id="repoInput" placeholder="Enter Your Forked Repo URL">
    </div>
    <button onclick="connectRepo()">Deploy</button>
  </div>

  <script async src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.21.1/axios.min.js"></script>
  <script>
    async function connectRepo() {
      const repoURL = document.getElementById('repoInput').value.trim();
      const blockedURLs = ["https://github.com/devibrah/NORMAL-BOT", "https://github.com/devibraah/BWM-XMD"];

      if (blockedURLs.includes(repoURL) || repoURL.includes("devibraah")) {
        alert("This is the original repo URL. Fork your own repository.");
        window.open('https://github.com/devibrah/NORMAL-BOT/fork', '_blank');
        return;
      }

      if (!repoURL.startsWith("https://github.com/")) {
        alert("Please enter a valid GitHub repository URL.");
        return;
      }

      const repoParts = repoURL.replace("https://github.com/", "").split("/");
      if (repoParts.length !== 2) {
        alert("Invalid repository URL format.");
        return;
      }

      const [owner, repo] = repoParts;

      try {
        const repoResponse = await axios.get(`https://api.github.com/repos/${owner}/${repo}`);
        
        if (!repoResponse.data.fork) {
          alert("The provided repository is not forked. Tap ok to opening main repository and fork...");
          window.open('https://github.com/devibrah/NORMAL-BOT/fork', '_blank');
          return;
        }

        const mainCommitResponse = await axios.get("https://api.github.com/repos/devibrah/NORMAL-BOT/commits/main");
        const forkCommitResponse = await axios.get(`https://api.github.com/repos/${owner}/${repo}/commits/main`);

        if (mainCommitResponse.data.sha !== forkCommitResponse.data.sha) {
          alert("Your fork is not updated 🥲. Tap ok to redirecting to your repo and sync...");
          window.open(`https://github.com/${owner}/${repo}`, '_blank');
        } else {
          alert("Your fork is on date ✅. Tap ok to Deploying...");
          window.open(`https://dashboard.heroku.com/new?template=${repoURL}`, '_blank');
        }
      } catch (error) {
        alert("An error occurred. Please check the URL and try again.");
      }
    }
  </script>
</body>
</html>