File size: 32,306 Bytes
f1b1560
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
65
66
67
68
69
70
71
72
73
74
75
76
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
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
<!DOCTYPE html>
<html lang="ru">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Neurobox AI - Детекция износа деталей</title>
    <script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
    <script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
    <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
    <script src="https://cdn.tailwindcss.com"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
        }
        @keyframes pulse-yellow {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.6; }
        }
        .animate-pulse-yellow {
            animation: pulse-yellow 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
        }
    </style>
</head>
<body>
    <div id="root"></div>

    <script type="text/babel">
        const { useState, useEffect, useRef } = React;

        // Icons
        const Activity = ({ size = 24, className = "" }) => (
            <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className={className}>
                <polyline points="22 12 18 12 15 21 9 3 6 12 2 12"/>
            </svg>
        );

        const AlertTriangle = ({ size = 24, className = "" }) => (
            <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className={className}>
                <path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/>
                <line x1="12" y1="9" x2="12" y2="13"/>
                <line x1="12" y1="17" x2="12.01" y2="17"/>
            </svg>
        );

        const TrendingUp = ({ size = 24, className = "" }) => (
            <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className={className}>
                <polyline points="23 6 13.5 15.5 8.5 10.5 1 18"/>
                <polyline points="17 6 23 6 23 12"/>
            </svg>
        );

        const Clock = ({ size = 24, className = "" }) => (
            <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className={className}>
                <circle cx="12" cy="12" r="10"/>
                <polyline points="12 6 12 12 16 14"/>
            </svg>
        );

        const Eye = ({ size = 24, className = "" }) => (
            <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className={className}>
                <path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/>
                <circle cx="12" cy="12" r="3"/>
            </svg>
        );

        const Camera = ({ size = 24, className = "" }) => (
            <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className={className}>
                <path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/>
                <circle cx="12" cy="13" r="4"/>
            </svg>
        );

        const Settings = ({ size = 24, className = "" }) => (
            <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className={className}>
                <circle cx="12" cy="12" r="3"/>
                <path d="M12 1v6m0 6v6m9.22-9.22l-4.24 4.24m-5.96 0L6.78 9.78m12.44 0l-4.24 4.24m-5.96 0L6.78 14.22"/>
            </svg>
        );

        const Zap = ({ size = 24, className = "" }) => (
            <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className={className}>
                <polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/>
            </svg>
        );

        const CheckCircle = ({ size = 24, className = "" }) => (
            <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className={className}>
                <path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/>
                <polyline points="22 4 12 14.01 9 11.01"/>
            </svg>
        );

        const Tool = ({ size = 24, className = "" }) => (
            <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className={className}>
                <path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/>
            </svg>
        );

        const Brain = ({ size = 24, className = "" }) => (
            <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className={className}>
                <path d="M9.5 2A2.5 2.5 0 0 1 12 4.5v15a2.5 2.5 0 0 1-4.96.44 2.5 2.5 0 0 1-2.96-3.08 3 3 0 0 1-.34-5.58 2.5 2.5 0 0 1 1.32-4.24 2.5 2.5 0 0 1 1.98-3A2.5 2.5 0 0 1 9.5 2Z"/>
                <path d="M14.5 2A2.5 2.5 0 0 0 12 4.5v15a2.5 2.5 0 0 0 4.96.44 2.5 2.5 0 0 0 2.96-3.08 3 3 0 0 0 .34-5.58 2.5 2.5 0 0 0-1.32-4.24 2.5 2.5 0 0 0-1.98-3A2.5 2.5 0 0 0 14.5 2Z"/>
            </svg>
        );

        const PredictiveMaintenanceDashboard = () => {
          const [currentTime, setCurrentTime] = useState(new Date());
          const [status, setStatus] = useState('warning');
          const [wearLevel, setWearLevel] = useState(68);
          const [timeToFailure, setTimeToFailure] = useState('72-96');
          const [wearHistory, setWearHistory] = useState([]);
          const [currentWear, setCurrentWear] = useState(68);
          
          const visualCanvasRef = useRef(null);
          const chartCanvasRef = useRef(null);

          useEffect(() => {
            const timer = setInterval(() => {
              setCurrentTime(new Date());
            }, 1000);
            return () => clearInterval(timer);
          }, []);

          // Generate wear history data
          useEffect(() => {
            const generateData = () => {
              const data = [];
              const now = Date.now();
              const dayInMs = 24 * 60 * 60 * 1000;
              
              for (let i = 7; i >= 0; i--) {
                const baseWear = 45;
                const wearIncrease = Math.max(0, 7 - i) * 3;
                const wear = baseWear + wearIncrease + Math.random() * 2;
                data.push({
                  time: new Date(now - i * dayInMs),
                  wear: wear
                });
              }
              return data;
            };
            
            setWearHistory(generateData());
            
            const wearInterval = setInterval(() => {
              setCurrentWear(prev => {
                const newWear = prev + (Math.random() - 0.3) * 0.2;
                return Math.max(65, Math.min(70, newWear));
              });
            }, 2000);
            
            return () => clearInterval(wearInterval);
          }, []);

          // Draw visual inspection view
          useEffect(() => {
            const canvas = visualCanvasRef.current;
            if (!canvas) return;
            
            const ctx = canvas.getContext('2d');
            let animationFrame;
            let scanLine = 0;

            const animate = () => {
              // Background
              const bgGradient = ctx.createLinearGradient(0, 0, 0, canvas.height);
              bgGradient.addColorStop(0, '#1e293b');
              bgGradient.addColorStop(1, '#0f172a');
              ctx.fillStyle = bgGradient;
              ctx.fillRect(0, 0, canvas.width, canvas.height);

              // Draw bearing/part visualization
              const centerX = canvas.width / 2;
              const centerY = canvas.height / 2;
              
              // Main bearing circle
              const bearingGradient = ctx.createRadialGradient(centerX, centerY, 50, centerX, centerY, 120);
              bearingGradient.addColorStop(0, '#475569');
              bearingGradient.addColorStop(0.7, '#334155');
              bearingGradient.addColorStop(1, '#1e293b');
              
              ctx.fillStyle = bearingGradient;
              ctx.beginPath();
              ctx.arc(centerX, centerY, 120, 0, Math.PI * 2);
              ctx.fill();
              
              // Inner circle
              ctx.fillStyle = '#1e293b';
              ctx.beginPath();
              ctx.arc(centerX, centerY, 50, 0, Math.PI * 2);
              ctx.fill();
              
              // Bearing segments
              ctx.strokeStyle = '#64748b';
              ctx.lineWidth = 2;
              for (let i = 0; i < 8; i++) {
                const angle = (Math.PI * 2 / 8) * i;
                ctx.beginPath();
                ctx.moveTo(centerX + Math.cos(angle) * 50, centerY + Math.sin(angle) * 50);
                ctx.lineTo(centerX + Math.cos(angle) * 120, centerY + Math.sin(angle) * 120);
                ctx.stroke();
              }

              // Draw wear zones
              const drawWearZone = (angle, radius, severity) => {
                let colors;
                if (severity === 'critical') {
                  colors = ['rgba(239, 68, 68, 0.8)', 'rgba(220, 38, 38, 0.4)'];
                } else if (severity === 'warning') {
                  colors = ['rgba(234, 179, 8, 0.8)', 'rgba(202, 138, 4, 0.4)'];
                } else {
                  colors = ['rgba(34, 197, 94, 0.6)', 'rgba(22, 163, 74, 0.3)'];
                }
                
                const gradient = ctx.createRadialGradient(
                  centerX + Math.cos(angle) * radius,
                  centerY + Math.sin(angle) * radius,
                  0,
                  centerX + Math.cos(angle) * radius,
                  centerY + Math.sin(angle) * radius,
                  35
                );
                gradient.addColorStop(0, colors[0]);
                gradient.addColorStop(1, colors[1]);
                ctx.fillStyle = gradient;
                ctx.beginPath();
                ctx.arc(
                  centerX + Math.cos(angle) * radius,
                  centerY + Math.sin(angle) * radius,
                  35,
                  0,
                  Math.PI * 2
                );
                ctx.fill();
              };

              // Normal wear zones
              drawWearZone(0, 85, 'normal');
              drawWearZone(Math.PI / 2, 85, 'normal');
              drawWearZone(Math.PI, 85, 'normal');
              
              // Critical wear zone (bottom right)
              const criticalAngle = -Math.PI / 4;
              drawWearZone(criticalAngle, 85, 'critical');
              
              // Detection box around critical zone
              const boxX = centerX + Math.cos(criticalAngle) * 85;
              const boxY = centerY + Math.sin(criticalAngle) * 85;
              
              ctx.strokeStyle = '#ef4444';
              ctx.lineWidth = 4;
              ctx.setLineDash([10, 5]);
              ctx.strokeRect(boxX - 50, boxY - 50, 100, 100);
              ctx.setLineDash([]);
              
              // Warning badge
              ctx.fillStyle = '#ef4444';
              ctx.beginPath();
              ctx.arc(boxX + 45, boxY - 45, 20, 0, Math.PI * 2);
              ctx.fill();
              ctx.fillStyle = '#ffffff';
              ctx.font = 'bold 24px Arial';
              ctx.fillText('!', boxX + 40, boxY - 37);
              
              // Wear percentage label
              ctx.fillStyle = '#ef4444';
              ctx.font = 'bold 18px Arial';
              ctx.fillText(`${currentWear.toFixed(0)}% износ`, boxX - 40, boxY + 70);

              // AI scanning line
              scanLine = (scanLine + 3) % canvas.height;
              const scanGradient = ctx.createLinearGradient(0, scanLine - 2, 0, scanLine + 2);
              scanGradient.addColorStop(0, 'rgba(59, 130, 246, 0)');
              scanGradient.addColorStop(0.5, 'rgba(59, 130, 246, 0.8)');
              scanGradient.addColorStop(1, 'rgba(59, 130, 246, 0)');
              ctx.fillStyle = scanGradient;
              ctx.fillRect(0, scanLine - 2, canvas.width, 4);

              // Camera overlay
              ctx.fillStyle = 'rgba(255, 255, 255, 0.9)';
              ctx.font = 'bold 14px monospace';
              ctx.fillText('CAMERA 1', 10, 25);
              ctx.font = '12px monospace';
              ctx.fillText('Computer Vision Analysis', 10, 45);
              
              // Status indicator
              ctx.fillStyle = '#ef4444';
              ctx.beginPath();
              ctx.arc(canvas.width - 15, 15, 8, 0, Math.PI * 2);
              ctx.fill();
              
              // Grid overlay
              ctx.strokeStyle = 'rgba(59, 130, 246, 0.2)';
              ctx.lineWidth = 1;
              const gridSize = 50;
              for (let x = 0; x < canvas.width; x += gridSize) {
                ctx.beginPath();
                ctx.moveTo(x, 0);
                ctx.lineTo(x, canvas.height);
                ctx.stroke();
              }
              for (let y = 0; y < canvas.height; y += gridSize) {
                ctx.beginPath();
                ctx.moveTo(0, y);
                ctx.lineTo(canvas.width, y);
                ctx.stroke();
              }

              animationFrame = requestAnimationFrame(animate);
            };

            animate();
            return () => cancelAnimationFrame(animationFrame);
          }, [currentWear]);

          // Draw wear progression chart
          useEffect(() => {
            const canvas = chartCanvasRef.current;
            if (!canvas || wearHistory.length === 0) return;
            
            const ctx = canvas.getContext('2d');
            
            ctx.fillStyle = '#f8fafc';
            ctx.fillRect(0, 0, canvas.width, canvas.height);
            
            ctx.strokeStyle = '#e2e8f0';
            ctx.lineWidth = 1;
            
            for (let i = 0; i <= 5; i++) {
              const y = (canvas.height - 40) * (i / 5) + 20;
              ctx.beginPath();
              ctx.moveTo(50, y);
              ctx.lineTo(canvas.width - 20, y);
              ctx.stroke();
              
              const wear = 100 - (i * 10);
              ctx.fillStyle = '#64748b';
              ctx.font = '11px Arial';
              ctx.fillText(`${wear}%`, 10, y + 4);
            }
            
            for (let i = 0; i <= 7; i++) {
              const x = 50 + (canvas.width - 70) * (i / 7);
              ctx.beginPath();
              ctx.moveTo(x, 20);
              ctx.lineTo(x, canvas.height - 20);
              ctx.stroke();
              
              if (i % 2 === 0) {
                ctx.fillStyle = '#64748b';
                ctx.font = '10px Arial';
                ctx.fillText(`-${7-i}д`, x - 10, canvas.height - 5);
              }
            }
            
            const normalThreshold = 50;
            const thresholdY = canvas.height - 20 - ((normalThreshold) / 100) * (canvas.height - 40);
            ctx.strokeStyle = '#22c55e';
            ctx.lineWidth = 2;
            ctx.setLineDash([5, 5]);
            ctx.beginPath();
            ctx.moveTo(50, thresholdY);
            ctx.lineTo(canvas.width - 20, thresholdY);
            ctx.stroke();
            ctx.setLineDash([]);
            
            ctx.fillStyle = '#22c55e';
            ctx.font = '10px Arial';
            ctx.fillText('Норма: 50%', canvas.width - 100, thresholdY - 5);
            
            ctx.beginPath();
            ctx.strokeStyle = '#3b82f6';
            ctx.lineWidth = 3;
            
            wearHistory.forEach((point, index) => {
              const x = 50 + (canvas.width - 70) * (index / 7);
              const y = canvas.height - 20 - ((point.wear) / 100) * (canvas.height - 40);
              
              if (index === 0) {
                ctx.moveTo(x, y);
              } else {
                ctx.lineTo(x, y);
              }
            });
            ctx.stroke();
            
            wearHistory.forEach((point, index) => {
              const x = 50 + (canvas.width - 70) * (index / 7);
              const y = canvas.height - 20 - ((point.wear) / 100) * (canvas.height - 40);
              
              if (point.wear >= 65) {
                ctx.fillStyle = '#ef4444';
              } else if (point.wear >= 50) {
                ctx.fillStyle = '#eab308';
              } else {
                ctx.fillStyle = '#3b82f6';
              }
              
              ctx.beginPath();
              ctx.arc(x, y, 5, 0, Math.PI * 2);
              ctx.fill();
              ctx.strokeStyle = '#fff';
              ctx.lineWidth = 2;
              ctx.stroke();
            });
            
            const lastPoint = wearHistory[wearHistory.length - 1];
            const lastX = 50 + (canvas.width - 70) * (7 / 7);
            const lastY = canvas.height - 20 - ((lastPoint.wear) / 100) * (canvas.height - 40);
            
            ctx.fillStyle = '#ef4444';
            ctx.font = 'bold 12px Arial';
            ctx.fillText('⚠ КРИТИЧЕСКИЙ ИЗНОС', lastX - 120, lastY - 15);
            
            ctx.strokeStyle = '#ef4444';
            ctx.fillStyle = '#ef4444';
            ctx.lineWidth = 2;
            ctx.beginPath();
            ctx.moveTo(lastX - 20, lastY - 10);
            ctx.lineTo(lastX - 10, lastY);
            ctx.lineTo(lastX - 20, lastY + 10);
            ctx.fill();
            
          }, [wearHistory]);

          const getStatusConfig = () => {
            switch(status) {
              case 'critical':
                return {
                  color: 'from-red-500 to-red-700',
                  borderColor: 'border-red-400',
                  textColor: 'text-red-600',
                  bgColor: 'bg-red-50',
                  icon: AlertTriangle,
                  label: 'КРИТИЧНО'
                };
              case 'warning':
                return {
                  color: 'from-yellow-500 to-orange-600',
                  borderColor: 'border-yellow-400',
                  textColor: 'text-yellow-600',
                  bgColor: 'bg-yellow-50',
                  icon: AlertTriangle,
                  label: 'ПРЕДУПРЕЖДЕНИЕ'
                };
              default:
                return {
                  color: 'from-green-500 to-green-700',
                  borderColor: 'border-green-400',
                  textColor: 'text-green-600',
                  bgColor: 'bg-green-50',
                  icon: CheckCircle,
                  label: 'НОРМА'
                };
            }
          };

          const statusConfig = getStatusConfig();
          const StatusIcon = statusConfig.icon;

          return (
            <div className="min-h-screen bg-gradient-to-br from-slate-50 via-white to-blue-50 p-6">
              <div className="max-w-7xl mx-auto">
                <div className={`bg-gradient-to-r ${statusConfig.color} rounded-xl shadow-xl p-6 mb-6 border-2 ${statusConfig.borderColor}`}>
                  <div className="flex justify-between items-center">
                    <div className="flex items-center gap-4">
                      <div className="bg-white p-2 rounded-lg">
                        <Eye size={32} className={statusConfig.textColor} />
                      </div>
                      <div>
                        <h1 className="text-3xl font-bold text-white">Компьютерное зрение • Детекция износа</h1>
                        <p className="text-white text-sm font-medium">Оборудование: Двигатель ДП-45 • Подшипник №2</p>
                      </div>
                    </div>
                    <div className="flex items-center gap-4">
                      <div className="bg-white px-4 py-2 rounded-lg shadow-md">
                        <Clock size={20} className={`inline ${statusConfig.textColor} mr-2`} />
                        <span className="font-mono text-lg text-gray-800 font-semibold">
                          {currentTime.toLocaleTimeString('ru-RU')}
                        </span>
                      </div>
                    </div>
                  </div>
                </div>

                <div className="grid grid-cols-3 gap-6">
                  <div className="col-span-2 space-y-6">
                    <div className="bg-white rounded-xl shadow-xl p-6 border-2 border-blue-200">
                      <div className="flex items-center justify-between mb-4">
                        <h2 className="text-xl font-bold text-gray-800 flex items-center gap-2">
                          <Camera className="text-blue-600" />
                          Визуальная инспекция в реальном времени
                        </h2>
                        <span className="text-sm bg-blue-100 text-blue-700 px-3 py-1 rounded-full font-semibold flex items-center gap-2">
                          <span className="w-2 h-2 bg-blue-500 rounded-full animate-pulse"></span>
                          AI Анализ
                        </span>
                      </div>
                      <div className="bg-slate-900 rounded-lg overflow-hidden border-2 border-slate-700">
                        <canvas
                          ref={visualCanvasRef}
                          width={800}
                          height={400}
                          className="w-full"
                        />
                      </div>
                      <div className="mt-4 grid grid-cols-4 gap-3">
                        <div className="bg-blue-50 p-3 rounded-lg border border-blue-200">
                          <p className="text-xs text-gray-600 mb-1">Сектор 1</p>
                          <p className="text-xl font-bold text-blue-600">28%</p>
                          <p className="text-xs text-green-600">✓ Норма</p>
                        </div>
                        <div className={`${statusConfig.bgColor} p-3 rounded-lg border-2 ${statusConfig.borderColor} animate-pulse-yellow`}>
                          <p className="text-xs text-gray-600 mb-1">Сектор 2</p>
                          <p className={`text-xl font-bold ${statusConfig.textColor}`}>{currentWear.toFixed(0)}%</p>
                          <p className={`text-xs ${statusConfig.textColor}`}>⚠ Износ</p>
                        </div>
                        <div className="bg-blue-50 p-3 rounded-lg border border-blue-200">
                          <p className="text-xs text-gray-600 mb-1">Сектор 3</p>
                          <p className="text-xl font-bold text-blue-600">32%</p>
                          <p className="text-xs text-green-600">✓ Норма</p>
                        </div>
                        <div className="bg-green-50 p-3 rounded-lg border border-green-200">
                          <p className="text-xs text-gray-600 mb-1">Сектор 4</p>
                          <p className="text-xl font-bold text-green-600">25%</p>
                          <p className="text-xs text-green-600">✓ Норма</p>
                        </div>
                      </div>
                    </div>

                    <div className="bg-white rounded-xl shadow-xl p-6 border-2 border-blue-200">
                      <h2 className="text-xl font-bold text-gray-800 mb-4 flex items-center gap-2">
                        <TrendingUp className="text-red-600" />
                        График износа (Подшипник №2) за 7 дней
                      </h2>
                      <div className="bg-white rounded-lg border-2 border-gray-200">
                        <canvas
                          ref={chartCanvasRef}
                          width={800}
                          height={300}
                          className="w-full"
                        />
                      </div>
                    </div>

                    <div className="bg-white rounded-xl shadow-xl p-6 border-2 border-blue-200">
                      <h2 className="text-xl font-bold text-gray-800 mb-4 flex items-center gap-2">
                        <Settings className="text-blue-600" />
                        Эффективность системы
                      </h2>
                      <div className="grid grid-cols-3 gap-4">
                        <div className="bg-gradient-to-br from-green-500 to-green-600 rounded-xl p-5 shadow-lg">
                          <p className="text-green-50 text-sm mb-1 font-semibold">Предотвращено аварий</p>
                          <p className="text-4xl font-bold text-white">8/10</p>
                          <p className="text-green-100 text-xs mt-1">80% успешности</p>
                        </div>
                        <div className="bg-gradient-to-br from-blue-500 to-blue-600 rounded-xl p-5 shadow-lg">
                          <p className="text-blue-50 text-sm mb-1 font-semibold">Точность детекции</p>
                          <p className="text-4xl font-bold text-white">95%</p>
                          <p className="text-blue-100 text-xs mt-1">Computer Vision</p>
                        </div>
                        <div className="bg-gradient-to-br from-purple-500 to-purple-600 rounded-xl p-5 shadow-lg">
                          <p className="text-purple-50 text-sm mb-1 font-semibold">Время анализа</p>
                          <p className="text-4xl font-bold text-white">0.3с</p>
                          <p className="text-purple-100 text-xs mt-1">На изображение</p>
                        </div>
                      </div>
                    </div>
                  </div>

                  <div className="col-span-1 space-y-6">
                    <div className={`bg-gradient-to-br ${statusConfig.color} rounded-xl shadow-2xl p-6 border-4 ${statusConfig.borderColor}`}>
                      <div className="flex items-center gap-3 mb-4">
                        <StatusIcon size={32} className="text-white" />
                        <h2 className="text-2xl font-bold text-white">СТАТУС</h2>
                      </div>
                      <div className="bg-white rounded-lg p-4 space-y-4">
                        <div>
                          <p className={`text-2xl font-bold ${statusConfig.textColor}`}>
                            {statusConfig.label}
                          </p>
                        </div>
                        <div className="border-t-2 border-gray-200 pt-3">
                          <p className="text-xs text-gray-600 font-semibold mb-1">Обнаружено:</p>
                          <p className="text-sm font-bold text-gray-800">
                            Критический износ поверхности
                          </p>
                        </div>
                        <div className="border-t-2 border-gray-200 pt-3">
                          <p className="text-xs text-gray-600 font-semibold mb-1">Прогноз отказа:</p>
                          <p className={`text-lg font-bold ${statusConfig.textColor}`}>
                            {timeToFailure} часов
                          </p>
                        </div>
                        <div className="border-t-2 border-gray-200 pt-3">
                          <p className="text-xs text-gray-600 font-semibold mb-1">Уровень износа:</p>
                          <p className="text-2xl font-bold text-red-600">
                            {currentWear.toFixed(0)}%
                          </p>
                        </div>
                      </div>
                    </div>

                    <div className="bg-white rounded-xl shadow-xl p-6 border-2 border-purple-200">
                      <div className="flex items-center gap-2 mb-4">
                        <Brain className="text-purple-600" size={24} />
                        <h2 className="text-lg font-bold text-gray-800">Рекомендация Neurobox AI</h2>
                      </div>
                      <div className="bg-purple-50 rounded-lg p-4 border-2 border-purple-200">
                        <p className="text-gray-800 text-sm leading-relaxed">
                          "Обнаружен критический износ поверхности подшипника №2 (сектор 2). 
                          Рекомендуется срочная замена подшипника в течение 48-72 часов для предотвращения аварийного отказа."
                        </p>
                      </div>
                      <div className="mt-4 space-y-2">
                        <button className="w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 px-4 rounded-lg flex items-center justify-center gap-2 transition-colors">
                          <Tool size={18} />
                          Создать заявку на ремонт
                        </button>
                        <button className="w-full bg-green-600 hover:bg-green-700 text-white font-bold py-3 px-4 rounded-lg flex items-center justify-center gap-2 transition-colors">
                          <Zap size={18} />
                          Запланировать техпаузу
                        </button>
                      </div>
                    </div>

                    <div className="bg-white rounded-xl shadow-xl p-6 border-2 border-gray-200">
                      <h2 className="text-lg font-bold text-gray-800 mb-4">Информация об оборудовании</h2>
                      <div className="space-y-3 text-sm">
                        <div className="flex justify-between">
                          <span className="text-gray-600">Модель:</span>
                          <span className="font-semibold">ДП-45</span>
                        </div>
                        <div className="flex justify-between">
                          <span className="text-gray-600">Компонент:</span>
                          <span className="font-semibold">Подшипник №2</span>
                        </div>
                        <div className="flex justify-between">
                          <span className="text-gray-600">Наработка:</span>
                          <span className="font-semibold">18,420 ч</span>
                        </div>
                        <div className="flex justify-between">
                          <span className="text-gray-600">Последнее ТО:</span>
                          <span className="font-semibold">15.09.2024</span>
                        </div>
                        <div className="flex justify-between">
                          <span className="text-gray-600">Метод контроля:</span>
                          <span className="font-semibold text-blue-600">Computer Vision</span>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          );
        };

        const root = ReactDOM.createRoot(document.getElementById('root'));
        root.render(<PredictiveMaintenanceDashboard />);
    </script>
</body>
</html>