<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Beta Host - Nitro Generator</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      margin: 0;
      padding: 0;
      background-color: #2c2f33;
      color: #fff;
    }
    header {
      background-color: #23272a;
      padding: 20px;
      text-align: center;
    }
    header h1 {
      margin: 0;
      font-size: 24px;
    }
    header p {
      margin: 5px 0 0;
      font-size: 14px;
    }
    .container {
      padding: 20px;
      max-width: 600px;
      margin: 20px auto;
      background-color: #36393f;
      border-radius: 8px;
      box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    }
    .container h2 {
      text-align: center;
      margin-bottom: 20px;
    }
    label {
      display: block;
      margin-bottom: 10px;
      font-weight: bold;
    }
    input[type="number"], input[type="text"] {
      width: 100%;
      padding: 10px;
      margin-bottom: 20px;
      border: none;
      border-radius: 5px;
    }
    button {
      width: 100%;
      padding: 10px;
      background-color: #5865f2;
      border: none;
      border-radius: 5px;
      color: white;
      font-size: 16px;
      cursor: pointer;
    }
    button:hover {
      background-color: #4752c4;
    }
    .output {
      margin-top: 20px;
      padding: 10px;
      background-color: #23272a;
      border-radius: 5px;
      overflow-y: auto;
      max-height: 200px;
    }
    .output pre {
      white-space: pre-wrap;
      word-wrap: break-word;
    }
    #languageSelector {
      margin-bottom: 20px;
      display: flex;
      justify-content: center;
    }
    #languageSelector select {
      padding: 10px;
      font-size: 16px;
      border: none;
      border-radius: 5px;
    }
  </style>
</head>
<body>
  <header>
    <h1 id="headerTitle">Beta Host</h1>
    <p id="headerSubtitle">
      <span id="supportText">Support Server:</span>
      <a href="https://discord.gg/sSC6SHqyPC" target="_blank" style="color: #7289da;">Join Here</a>
    </p>
  </header>

  <div id="languageSelector">
    <select id="language" onchange="changeLanguage()">
      <option value="en">English</option>
      <option value="ar">العربية</option>
    </select>
  </div>

  <div class="container">
    <h2 id="title">Discord Nitro Code Generator</h2>
    <label id="labelNumCodes" for="numCodes">Number of Codes:</label>
    <input type="number" id="numCodes" placeholder="Enter number of codes" min="1">
    
    <label id="labelWebhook" for="webhook">Discord Webhook URL:</label>
    <input type="text" id="webhook" placeholder="Enter Discord Webhook URL">
    
    <button id="generateBtn" onclick="generateCodes()">Generate Codes</button>
    <button id="copyBtn" onclick="copyToClipboard()">Copy Codes</button>
    <button id="downloadBtn" onclick="downloadTxt()">Download as .txt</button>
    <button id="sendBtn" onclick="sendToWebhook()">Send to Webhook</button>
    
    <div class="output" id="output">
      <pre id="generatedCodes"></pre>
    </div>
  </div>

  <script>
    const translations = {
      en: {
        headerTitle: "Beta Host",
        supportText: "Support Server:",
        title: "Discord Nitro Code Generator",
        labelNumCodes: "Number of Codes:",
        labelWebhook: "Discord Webhook URL:",
        generateBtn: "Generate Codes",
        copyBtn: "Copy Codes",
        downloadBtn: "Download as .txt",
        sendBtn: "Send to Webhook"
      },
      ar: {
        headerTitle: "بيتا هوست",
        supportText: "سيرفر الدعم:",
        title: "مولد أكواد نيترو",
        labelNumCodes: "عدد الأكواد:",
        labelWebhook: "رابط الوِب هوك:",
        generateBtn: "إنشاء الأكواد",
        copyBtn: "نسخ الأكواد",
        downloadBtn: "تحميل كملف .txt",
        sendBtn: "إرسال إلى الوِب هوك"
      }
    };

    function changeLanguage() {
      const language = document.getElementById("language").value;
      const t = translations[language];
      
      document.getElementById("headerTitle").textContent = t.headerTitle;
      document.getElementById("supportText").textContent = t.supportText;
      document.getElementById("title").textContent = t.title;
      document.getElementById("labelNumCodes").textContent = t.labelNumCodes;
      document.getElementById("labelWebhook").textContent = t.labelWebhook;
      document.getElementById("generateBtn").textContent = t.generateBtn;
      document.getElementById("copyBtn").textContent = t.copyBtn;
      document.getElementById("downloadBtn").textContent = t.downloadBtn;
      document.getElementById("sendBtn").textContent = t.sendBtn;
    }

    let generatedCodes = [];

    function generateRandomCode() {
      const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
      let code = '';
      for (let i = 0; i < 16; i++) {
        code += characters.charAt(Math.floor(Math.random() * characters.length));
      }
      return `https://discord.gift/${code}`;
    }

    function generateCodes() {
      const numCodes = document.getElementById('numCodes').value;
      const output = document.getElementById('generatedCodes');
      generatedCodes = [];
      
      if (!numCodes || numCodes < 1) {
        alert('Please enter a valid number of codes.');
        return;
      }
      
      for (let i = 0; i < numCodes; i++) {
        generatedCodes.push(generateRandomCode());
      }
      
      output.textContent = generatedCodes.join('\n');
    }

    function copyToClipboard() {
      if (generatedCodes.length === 0) {
        alert('No codes to copy. Generate codes first!');
        return;
      }
      
      navigator.clipboard.writeText(generatedCodes.join('\n'))
        .then(() => alert('Codes copied to clipboard!'))
        .catch(err => alert('Failed to copy codes: ' + err));
    }

    function downloadTxt() {
      if (generatedCodes.length === 0) {
        alert('No codes to download. Generate codes first!');
        return;
      }
      
      const blob = new Blob(["Nitros Maded By Beta Host:\n" + generatedCodes.join('\n')], { type: 'text/plain' });
      const link = document.createElement('a');
      link.href = URL.createObjectURL(blob);
      link.download = 'nitro_codes.txt';
      link.click();
    }

    function sendToWebhook() {
      const webhookURL = document.getElementById('webhook').value;
      
      if (!webhookURL) {
        alert('Please enter a Discord webhook URL.');
        return;
      }
      
      if (generatedCodes.length === 0) {
        alert('No codes to send. Generate codes first!');
        return;
      }

      fetch(webhookURL, {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({
          content: `Here are your generated codes:\n${generatedCodes.join('\n')}`
        })
      })
      .then(response => {
        if (response.ok) {
          alert('Codes sent to webhook successfully!');
        } else {
          alert('Failed to send to webhook. Check the URL.');
        }
      })
      .catch(err => alert('Error sending to webhook: ' + err));
    }
  </script>
</body>
</html>
