File size: 2,029 Bytes
9a5585c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
class AnomalyVisualizer extends HTMLElement {
    constructor() {
        super();
        this.attachShadow({ mode: 'open' });
        this.anomalies = [];
    }

    connectedCallback() {
        this.render();
        document.addEventListener('quantumAnomaly', (e) => {
            this.addAnomaly(e.detail);
        });
    }

    addAnomaly(anomaly) {
        this.anomalies.push(anomaly);
        this.renderAnomaly(anomaly);
        
        // Remove after animation
        setTimeout(() => {
            this.anomalies = this.anomalies.filter(a => a !== anomaly);
        }, 3000);
    }

    render() {
        this.shadowRoot.innerHTML = `
            <style>
                :host {
                    position: fixed;
                    top: 0;
                    left: 0;
                    width: 100%;
                    height: 100%;
                    pointer-events: none;
                    z-index: 9999;
                }
                .anomaly {
                    position: absolute;
                    width: 16px;
                    height: 16px;
                    background: radial-gradient(circle, rgba(239,68,68,0.8) 0%, rgba(239,68,68,0) 70%);
                    border-radius: 50%;
                    transform: translate(-50%, -50%);
                    animation: pulse 2s infinite;
                }
                @keyframes pulse {
                    0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
                    100% { transform: translate(-50%, -50%) scale(3); opacity: 0; }
                }
            </style>
        `;
    }

    renderAnomaly(anomaly) {
        const element = document.createElement('div');
        element.className = 'anomaly';
        element.style.left = `${Math.random() * 100}%`;
        element.style.top = `${Math.random() * 100}%`;
        element.style.animationDelay = `${Math.random() * 0.5}s`;
        this.shadowRoot.appendChild(element);
    }
}

customElements.define('anomaly-visualizer', AnomalyVisualizer);