/**
 * Security Protection Script
 * Lightweight version - Only essential protections for better performance
 */

(function() {
    'use strict';
    
    // Disable right-click context menu
    document.addEventListener('contextmenu', function(e) {
        e.preventDefault();
        return false;
    });
    
    // Disable keyboard shortcuts for DevTools
    document.addEventListener('keydown', function(e) {
        // F12 - Developer Tools
        if (e.keyCode === 123) {
            e.preventDefault();
            return false;
        }
        // Ctrl+Shift+I - Inspect Element
        if (e.ctrlKey && e.shiftKey && e.keyCode === 73) {
            e.preventDefault();
            return false;
        }
        // Ctrl+U - View Source
        if (e.ctrlKey && e.keyCode === 85) {
            e.preventDefault();
            return false;
        }
    });
    
    // DevTools Detection - Window size method only (Desktop only)
    // Skip detection on mobile devices to prevent false positives
    var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
    
    if (!isMobile) {
        var devtoolsOpen = false;
        
        var checkDevTools = function() {
            var threshold = 200;
            var widthThreshold = window.outerWidth - window.innerWidth > threshold;
            var heightThreshold = window.outerHeight - window.innerHeight > threshold;
            
            if (widthThreshold || heightThreshold) {
                if (!devtoolsOpen) {
                    devtoolsOpen = true;
                    // Close window immediately
                    window.location.href = 'about:blank';
                    window.close();
                }
            }
        };
        
        // Check on page load
        checkDevTools();
        
        // Check periodically (every 500ms)
        setInterval(checkDevTools, 500);
    }
    
    console.log('Security protection: ENABLED');
    
})();
