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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CMD Ingaze Reveal Animation</title>
    <style>
        body {
            background-color: #000000; /* Black background */
            color: #00FF00; /* Bright green text */
            font-family: 'Courier New', Courier, monospace; /* Classic CMD font */
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh; /* Make body fill viewport height */
            margin: 0;
            overflow: hidden; /* Prevent scrollbars */
        }
        #cmd-animation-container {
            padding: 20px;
            border: 2px solid #00AA00; /* Darker green border */
            background-color: #080808; /* Slightly off-black for the "screen" */
            box-shadow: 0 0 15px #00FF00; /* Green glow effect */
            border-radius: 8px; /* Rounded corners for the container */
            /* Ensure the container doesn't exceed viewport width if content is too wide */
            max-width: 95vw; 
            box-sizing: border-box; /* Include padding and border in the element's total width and height */
        }
        pre#cmd-animation {
            white-space: pre; /* Preserve whitespace and newlines */
            text-align: left;
            font-size: 14px; /* Adjusted for better fit */
            line-height: 1.1; /* Compact lines */
            margin: 0;
            overflow-x: auto; /* Add scroll if content is wider than container */
        }
    </style>
</head>
<body>
    <div id="cmd-animation-container">
        <pre id="cmd-animation"></pre>
    </div>

    <script>
        // --- Configuration ---
        const scene_width = 65; // Characters, increased for Ingaze logo
        const scene_height = 22; // Lines
        const frameDuration = 150; // Milliseconds per frame
        const MAX_DATA_PARTICLES = 150;
        const FLOOR_LEVEL = scene_height - 1;

        // --- ASCII Art Definitions ---
        const stick_man_art_normal = ["   O   ", "  /|\\  ", "  / \\  "];
        const stick_man_art_walk_1 = ["   O   ", "  /|\\  ", "  / >  "];
        const stick_man_art_walk_2 = ["   O   ", "  /|\\  ", " < \\  "];
        const stick_man_art_surprise = ["  \\O/  ", "   |   ", "  / \\  "]; // Stickman surprised by lightning/explosion
        const stick_man_art_gone = ["       ", "       ", "       "]; // For when stickman disappears

        const linked_in_art = ["+----+", "|i n |", "+----+"];
        const linked_in_art_hit = ["x----x", "|BOOM|", "x----x"]; // When hit by lightning

        const lightning_strike_segment = "\\"; // Simple segment for descending lightning

        const explosion_symbols = ['*', '#', '@', '!', '%', '&', 'X', 'O', '$', '+', '~'];
        const explosion_art_frames = [
            // Frame 1: Small impact
            [
                "   * ",
                "  *#* ",
                "   * "
            ],
            // Frame 2: Expanding
            [
                "  @!%  ",
                " @*#*& ",
                "  X%O  "
            ],
            // Frame 3: Larger and more chaotic
            [
                " $*~+@ ",
                "$#@!%*&",
                " X*O#~ ",
                "  !+%$ "
            ],
            // Frame 4: Fading / contracting
            [
                "   ~   ",
                "  +*%  ",
                "   $   "
            ]
        ];

        const ingaze_logo_art = [
            "IIIII N   N  GGG   AAA   ZZZZZ EEEEE",
            "  I   NN  N G     A   A    Z   E    ",
            "  I   N N N G  GG AAAAA   Z    EEE  ",
            "  I   N  NN G   G A   A  Z     E    ",
            "IIIII N   N  GGG  A   A ZZZZZ EEEEE"
        ];
        const ingaze_logo_width = ingaze_logo_art[0].length;
        const ingaze_logo_height = ingaze_logo_art.length;


        // --- Global State ---
        let data_particles = []; // {char, x, y, vy, active}
        let current_lightning_y = -1; // Y position of the lightning tip, -1 means not active

        // --- Helper Functions ---
        function overlay(baseLines, artLines, startX, startY, ignoreSpaces = true) {
            artLines.forEach((artLine, i) => {
                const y = startY + i;
                if (y >= 0 && y < baseLines.length && artLine) {
                    let baseLineArr = baseLines[y].split('');
                    for (let j = 0; j < artLine.length; j++) {
                        const x = startX + j;
                        if (x >= 0 && x < baseLineArr.length) {
                            if (ignoreSpaces && artLine[j] === ' ') continue;
                            baseLineArr[x] = artLine[j];
                        }
                    }
                    baseLines[y] = baseLineArr.join('');
                }
            });
        }

        function drawLightningBolt(sceneLines, tipX, tipY, length) {
            for (let i = 0; i < length; i++) {
                const y = tipY - i;
                const x = tipX + (i % 2 === 0 ? 0 : (i % 4 === 1 ? -1 : 1)); // Simple zig-zag
                if (y >= 0 && y < scene_height && x >= 0 && x < scene_width) {
                    if (sceneLines[y][x] === ' ') { // Avoid overwriting other elements if possible
                        let lineArr = sceneLines[y].split('');
                        lineArr[x] = lightning_strike_segment;
                        sceneLines[y] = lineArr.join('');
                    }
                }
            }
        }


        function buildScene(stickmanArt, stickmanPos, showLogo, currentLogoArt, currentLogoPos,
                              showLightningBolt, lightningTipX, lightningTipY, lightningLength,
                              currentExplosionArt, explosionPos,
                              showIngazeLogo, ingazeArt, ingazePos) {
            let sceneLines = Array(scene_height).fill(" ".repeat(scene_width));

            // 1. Data particles (drawn first, can be overwritten)
            data_particles.forEach(p => {
                const px = Math.round(p.x);
                const py = Math.round(p.y);
                if (py >= 0 && py < sceneLines.length && px >= 0 && px < scene_width) {
                    if (sceneLines[py][px] === ' ') {
                         let lineArr = sceneLines[py].split('');
                         lineArr[px] = p.char;
                         sceneLines[py] = lineArr.join('');
                    }
                }
            });

            // 2. Stickman
            overlay(sceneLines, stickmanArt, stickmanPos.x, stickmanPos.y);

            // 3. LinkedIn Logo
            if (showLogo) {
                overlay(sceneLines, currentLogoArt, currentLogoPos.x, currentLogoPos.y);
            }

            // 4. Lightning Bolt
            if (showLightningBolt && lightningTipY >=0) {
                drawLightningBolt(sceneLines, lightningTipX, lightningTipY, lightningLength);
            }

            // 5. Explosion
            if (currentExplosionArt && currentExplosionArt.length > 0) {
                overlay(sceneLines, currentExplosionArt, explosionPos.x, explosionPos.y, false); // false: allow spaces in explosion art
            }

            // 6. Ingaze Logo
            if (showIngazeLogo) {
                overlay(sceneLines, ingazeArt, ingazePos.x, ingazePos.y);
            }

            return sceneLines.join('\n');
        }

        function spawnDataParticle(logoX, logoY, logoWidth) {
            if (data_particles.length >= MAX_DATA_PARTICLES) return;
            const char = Math.random() > 0.5 ? '1' : '0';
            const x = logoX + 1 + Math.floor(Math.random() * (logoWidth - 2));
            const y = logoY + linked_in_art.length;
            const vy = 0.2 + Math.random() * 0.3;
            data_particles.push({ char, x, y, vy, active: true });
        }

        // --- Animation Sequence Generation ---
        // This function generates all frames once and stores them.
        function generateAnimationFrames() {
            const sequence = [];
            // Reset global state that might persist across generations if this is called multiple times
            data_particles = [];
            current_lightning_y = -1;


            const stickman_height = stick_man_art_normal.length;
            const stickman_width = stick_man_art_normal[0].length;
            const logo_width = linked_in_art[0].length;
            const logo_height = linked_in_art.length;

            const stickman_base_y = FLOOR_LEVEL - stickman_height;
            const logo_base_y = stickman_base_y; 

            const stickman_initial_pos = { x: 2, y: stickman_base_y };
            // Adjusted logo_initial_pos to be more to the right to give stickman space
            const logo_initial_pos = { x: scene_width - logo_width - 20, y: logo_base_y }; 
            const stickman_walk_target_x = logo_initial_pos.x - stickman_width - 1;


            const ingaze_pos = {
                x: Math.floor((scene_width - ingaze_logo_width) / 2),
                y: Math.floor((scene_height - ingaze_logo_height) / 2)
            };
            const explosion_center_x = logo_initial_pos.x + Math.floor(logo_width / 2);
            const explosion_center_y = logo_initial_pos.y + Math.floor(logo_height / 2);


            // Phase 0: Stickman Walks to Logo
            // Ensure stickman_walk_target_x is not less than initial_pos.x if logo is too far left
            const target_x_for_walk = Math.max(stickman_initial_pos.x + 1, stickman_walk_target_x);
            const walk_frames = Math.max(10, Math.floor(Math.abs(target_x_for_walk - stickman_initial_pos.x) / 1.2) );

            let current_stickman_x = stickman_initial_pos.x;
             // Ensure walk_step_x is not NaN if walk_frames is 0 (though it's max(10, ...))
            const walk_step_x = walk_frames > 0 ? (target_x_for_walk - stickman_initial_pos.x) / walk_frames : 0;

            for (let i = 0; i < walk_frames; i++) {
                current_stickman_x += walk_step_x;
                const walk_art = (i % 4 < 2) ? stick_man_art_walk_1 : stick_man_art_walk_2;
                sequence.push(buildScene(walk_art, { x: Math.round(current_stickman_x), y: stickman_base_y }, true, linked_in_art, logo_initial_pos, false,0,0,0, [], {}, false, [], {}));
            }
            current_stickman_x = target_x_for_walk;
            let current_stickman_pos = { x: current_stickman_x, y: stickman_base_y };

            // Phase 1: Pause before shake
            for (let i = 0; i < 3; i++) {
                sequence.push(buildScene(stick_man_art_normal, current_stickman_pos, true, linked_in_art, logo_initial_pos, false,0,0,0, [], {}, false, [], {}));
            }

            // Phase 2: Shaking LinkedIn & Data Fall
            let current_logo_pos_phase2 = { ...logo_initial_pos };
            const shake_frames = 25;
            for (let i = 0; i < shake_frames; i++) {
                let logoAdj = { x: 0, y: 0 };
                if (i % 6 < 2) logoAdj = { x: 1, y: 0 }; else if (i % 6 < 4) logoAdj = { x: -1, y: 0 };
                current_logo_pos_phase2.x = logo_initial_pos.x + logoAdj.x;
                if (i % 2 === 0) spawnDataParticle(current_logo_pos_phase2.x, current_logo_pos_phase2.y, logo_width);
                
                // Create a new array for data_particles to update positions for this frame
                let next_frame_particles = [];
                data_particles.forEach(p => {
                    let new_p = {...p};
                    if (new_p.active) { 
                        new_p.y += new_p.vy; 
                        if (new_p.y >= FLOOR_LEVEL) { 
                            new_p.y = FLOOR_LEVEL; 
                            new_p.vy = 0; 
                            new_p.active = false; 
                        } 
                    }
                    next_frame_particles.push(new_p);
                });
                data_particles = next_frame_particles; // Update global particles for next frame generation

                sequence.push(buildScene(stick_man_art_normal, current_stickman_pos, true, linked_in_art, current_logo_pos_phase2, false,0,0,0, [], {}, false, [], {}));
            }
            current_logo_pos_phase2 = { ...logo_initial_pos }; // Reset logo position

            // Phase 3: Data Settles, Stickman gets ready for impact
            const settle_frames = 10;
            for (let i = 0; i < settle_frames; i++) {
                let stickmanArtPhase3 = (i < settle_frames / 2) ? stick_man_art_normal : stick_man_art_surprise;
                
                let next_frame_particles_settle = [];
                data_particles.forEach(p => { // Ensure all particles settle
                    let new_p = {...p};
                    if (new_p.active) { 
                        new_p.y += new_p.vy; 
                        if (new_p.y >= FLOOR_LEVEL) { 
                            new_p.y = FLOOR_LEVEL; 
                            new_p.vy = 0; 
                            new_p.active = false; 
                        } 
                    }
                    next_frame_particles_settle.push(new_p);
                });
                data_particles = next_frame_particles_settle;

                sequence.push(buildScene(stickmanArtPhase3, current_stickman_pos, true, linked_in_art, logo_initial_pos, false,0,0,0, [], {}, false, [], {}));
            }

            // Phase 4: Lightning Strike
            const lightning_target_y = logo_initial_pos.y; 
            const lightning_strike_frames = lightning_target_y + 3; 
            const lightning_bolt_length = 5; 
            const lightning_tip_x_strike = logo_initial_pos.x + Math.floor(logo_width / 2);
            let frame_lightning_y = 0; 

            for (let i = 0; i < lightning_strike_frames; i++) {
                frame_lightning_y = i;
                let logo_art_to_use = linked_in_art;
                if (frame_lightning_y >= lightning_target_y) {
                    logo_art_to_use = linked_in_art_hit; 
                    frame_lightning_y = lightning_target_y; 
                }
                // Update current_lightning_y for buildScene to use
                current_lightning_y = frame_lightning_y;
                sequence.push(buildScene(stick_man_art_surprise, current_stickman_pos, true, logo_art_to_use, logo_initial_pos, true, lightning_tip_x_strike, current_lightning_y, lightning_bolt_length, [], {}, false, [], {}));
            }
            current_lightning_y = -1; // Lightning done for buildScene logic

            // Phase 5: Explosion
            const explosion_duration_per_frame = 2; 
            let stickman_art_explosion = stick_man_art_surprise; 
            for (let i = 0; i < explosion_art_frames.length; i++) {
                const explosion_art = explosion_art_frames[i];
                const explosion_art_width = Math.max(...explosion_art.map(l => l.length));
                const explosion_art_height = explosion_art.length;
                const current_explosion_pos = {
                    x: explosion_center_x - Math.floor(explosion_art_width / 2),
                    y: explosion_center_y - Math.floor(explosion_art_height / 2)
                };

                for (let j = 0; j < explosion_duration_per_frame; j++) {
                    if (i === 0 && j === 0) { 
                        data_particles = []; // Clear all data particles for buildScene
                        stickman_art_explosion = stick_man_art_gone; 
                    }
                    sequence.push(buildScene(stickman_art_explosion, current_stickman_pos, false, [], {}, false,0,0,0, explosion_art, current_explosion_pos, false, [], {}));
                }
            }

            // Phase 6: "Ingaze" Logo Reveal
            const ingaze_reveal_pause_frames = 5; 
            for(let i=0; i < ingaze_reveal_pause_frames; i++) {
                sequence.push(buildScene(stick_man_art_gone, current_stickman_pos, false, [], {}, false,0,0,0, [], {}, false, [], {}));
            }

            const ingaze_display_frames = 30; 
            for (let i = 0; i < ingaze_display_frames; i++) {
                sequence.push(buildScene(stick_man_art_gone, current_stickman_pos, false, [], {}, false,0,0,0, [], {}, true, ingaze_logo_art, ingaze_pos));
            }
            return sequence;
        }


        // --- Animation Player ---
        const animationElement = document.getElementById('cmd-animation');
        let currentFrame = 0;
        let animationInterval;
        let staticAnimationFrames = []; // Will hold the pre-generated frames

        function playAnimation() {
            // Ensure frames are generated before playing
            if (staticAnimationFrames.length === 0) {
                console.error("Animation frames not generated yet!");
                if(animationElement) animationElement.textContent = "Error: Animation frames missing.";
                return;
            }

            animationInterval = setInterval(() => {
                if (animationElement && staticAnimationFrames[currentFrame]) {
                    animationElement.textContent = staticAnimationFrames[currentFrame];
                }
                currentFrame++;
                if (currentFrame >= staticAnimationFrames.length) {
                    currentFrame = 0; // Loop animation
                    // Re-initialize particle state for a clean loop if it's not handled by generation
                    // The generateAnimationFrames function now resets particles at its start.
                    // For a true visual loop, we might need to call generateAnimationFrames() again
                    // or design the particle logic to reset cleanly on loop.
                    // For now, a simple frame loop is implemented.
                    // If generateAnimationFrames is heavy, avoid calling it every loop.
                    // The current logic in generateAnimationFrames resets data_particles at the beginning.
                    // To make the loop truly seamless with dynamic particles, the generation logic
                    // would need to be part of the loop or the state reset more carefully.
                    // Given the current structure, we'll loop the pre-generated sequence.
                }
            }, frameDuration);
        }

        // Initialize and start animation
        // Using a self-invoking function or ensuring DOM is ready
        (function() {
            // Check if the DOM is already loaded
            if (document.readyState === "complete" || document.readyState === "interactive") {
                initAnimation();
            } else {
                window.addEventListener('DOMContentLoaded', initAnimation);
            }
        })();

        function initAnimation() {
            if (!animationElement) {
                console.error("Animation element not found");
                return;
            }
            try {
                staticAnimationFrames = generateAnimationFrames(); // Generate all frames
                if (staticAnimationFrames.length > 0) {
                    animationElement.textContent = staticAnimationFrames[0]; // Show first frame
                    playAnimation();
                } else {
                    animationElement.textContent = "Error: Could not generate animation.";
                }
            } catch (error) {
                console.error("Error during animation setup:", error);
                if(animationElement) animationElement.textContent = "Error initializing animation: " + error.message;
            }
        }

        // Clean up interval when the window/iframe is unloaded (optional, good practice)
        window.addEventListener('unload', () => {
            if (animationInterval) {
                clearInterval(animationInterval);
            }
        });
    </script>
</body>
</html>