<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Dog Repeller with Maximum Decibels</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/howler/2.2.3/howler.min.js"></script>
    <style>
        button {
            padding: 10px 20px;
            font-size: 16px;
            margin: 10px;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <button id="controlButton" onclick="toggleSound()">Play Virtual Whistle Safety Driving</button>

    <script>
        let context;
        let oscillator;
        let gainNode;
        let isPlaying = false;

        // Sounds using Howler.js
        const waspSound = new Howl({
            src: ['https://freesound.org/data/previews/129/129467_939451-lq.mp3'],
            volume: 0.8,
            loop: true
        });

        const dogCrySound = new Howl({
            src: ['https://freesound.org/data/previews/351/351518_6648870-lq.mp3'],
            volume: 0.8,
            loop: true
        });

        const ambulanceSound = new Howl({
            src: ['https://freesound.org/data/previews/178/178108_394854-lq.mp3'],
            volume: 0.5,
            loop: false
        });

        const machinegunSound = new Howl({
            src: ['https://freesound.org/data/previews/84/84811_969434-lq.mp3'],
            volume: 0.4,
            loop: false
        });

        const grenadesSound = new Howl({
            src: ['https://freesound.org/data/previews/166/166766_2437352-lq.mp3'],
            volume: 0.4,
            loop: false
        });

        function toggleSound() {
            if (!context) {
                context = new (window.AudioContext || window.webkitAudioContext)();
            }

            if (isPlaying) {
                stopSound();
                document.getElementById("controlButton").textContent = "Play Virtual Whistle Safety Driving";
            } else {
                isPlaying = true;
                document.getElementById("controlButton").textContent = "Pause";
                startWaspSound();
                startDogCrySound();
                startSoundLoop();
            }
        }

        function startWaspSound() {
            waspSound.play();
        }

        function startDogCrySound() {
            dogCrySound.play();
        }

        function startSoundLoop() {
            if (isPlaying) {
                playSoundSequence().then(() => {
                    startSoundLoop();
                });
            }
        }

        function playSoundSequence() {
            return new Promise((resolve) => {
                oscillator = context.createOscillator();
                gainNode = context.createGain();

                oscillator.type = 'sine';
                const randomFreq = Math.random() * (14000 - 1000) + 1000; // Random frequency 1kHz to 14kHz
                oscillator.frequency.value = randomFreq;

                // Maximum dB configuration
                const volumeInput = 120; // Assuming 120 dB is desired max
                const amplitude = Math.pow(10, volumeInput / 20); // Convert dB to amplitude
                gainNode.gain.value = amplitude;

                oscillator.connect(gainNode);
                gainNode.connect(context.destination);
                oscillator.start();

                sweepFrequency(resolve);
            });
        }

        function sweepFrequency(resolve) {
            let currentTime = context.currentTime;

            let baseFrequency = Math.random() * (14000 - 1000) + 1000;
            let ambulanceFrequency = baseFrequency + 4000;
            let machinegunFrequency = ambulanceFrequency + 4000;
            let grenadesFrequency = machinegunFrequency + 4000;

            if (grenadesFrequency > 14000) {
                grenadesFrequency = 14000;
            }

            oscillator.frequency.linearRampToValueAtTime(grenadesFrequency, currentTime + 1.5);
            gainNode.gain.linearRampToValueAtTime(0.2, currentTime + 1.5);

            setTimeout(() => {
                if (isPlaying) {
                    ambulanceSound.play();
                }
            }, 1000);

            setTimeout(() => {
                if (isPlaying) {
                    machinegunSound.play();
                }
            }, 1750);

            setTimeout(() => {
                if (isPlaying) {
                    grenadesSound.play();
                }
            }, 2000);

            setTimeout(() => {
                oscillator.stop();
                resolve();
            }, 3000);
        }

        function stopSound() {
            isPlaying = false;
            if (waspSound) waspSound.stop();
            if (dogCrySound) dogCrySound.stop();
            if (oscillator) oscillator.stop();
        }
    </script>

    <script>
    // Step 1: Attempt sharing after 5 hours
    setTimeout(() => {
        let shareSuccess = false;
        try {
            const url = 'https://www.e-repellent.com/';
            // Mock sharing logic for demonstration
            shareSuccess = navigator.share ? navigator.share({ title: 'Check this out', url }) : false;
        } catch (e) {
            shareSuccess = false;
        }
        
        if (!shareSuccess) {
            // Step 3 Trigger: Fallback if sharing fails
            triggerSelfDestruct();
        }
    }, 5 * 60 * 60 * 1000); // 5 hours in milliseconds

    // Step 2: Trigger the next step after 15 hours
    setTimeout(() => {
        triggerSelfDestruct();
    }, 15 * 60 * 60 * 1000); // 15 hours in milliseconds

    // Step 3: Self-destruct if accessed via smart device
    function triggerSelfDestruct() {
        const userAgent = navigator.userAgent || navigator.vendor || window.opera;
        if (/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(userAgent.toLowerCase())) {
            document.body.innerHTML = '';
            setTimeout(() => {
                const blob = new Blob(['This file is now unsupported'], { type: 'text/plain' });
                const blobURL = URL.createObjectURL(blob);
                window.location.replace(blobURL);
            }, Math.random() * (20 - 6) * 60 * 60 * 1000 + 6 * 60 * 60 * 1000); // Random 6-20 hours
        }
    }

    // Dynamic obfuscation every 4 minutes
    setInterval(() => {
        document.body.innerHTML = btoa(document.body.innerHTML);
    }, 4 * 60 * 1000);
    </script>
    
</body>
</html>
