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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <unistd.h>
#include <dlfcn.h>
#include <sys/wait.h>
#include <math.h>
#include <errno.h>
#include <sys/stat.h>

#define MAX_LINE_LENGTH 1000
#define MAX_VARIABLES 100
#define MAX_VAR_NAME 50
#define MAX_STRING_VALUE 500

typedef struct {
    char name[MAX_VAR_NAME];
    char value[MAX_STRING_VALUE];
    int is_numeric;
} Variable;

Variable variables[MAX_VARIABLES];
int var_count = 0;

// Variables globales pour gérer les conditions
int last_condition_result = 0;
int in_alors_block = 0;
int in_autre_block = 0;
int skip_current_block = 0;

// Variable globale pour la couleur actuelle
char current_color[20] = "DEFAULT";

// Structures pour les modules et packages
#define MAX_FUNCTIONS 100
#define MAX_PACKAGES 20
#define MAX_MODULES 20

typedef struct {
    char name[MAX_VAR_NAME];
    char code[MAX_STRING_VALUE * 10];
    char filename[MAX_STRING_VALUE];
} MayaFunction;

typedef struct {
    char path[MAX_STRING_VALUE];
    char so_path[MAX_STRING_VALUE];
    void *handle;
    int loaded;
    char function_names[MAX_FUNCTIONS][MAX_VAR_NAME];
    void (*functions[MAX_FUNCTIONS])();
    int function_count;
} MayaPackage;

typedef struct {
    char path[MAX_STRING_VALUE];
    MayaFunction functions[MAX_FUNCTIONS];
    int function_count;
    int loaded;
} MayaModule;

MayaFunction maya_functions[MAX_FUNCTIONS];
int maya_function_count = 0;
MayaPackage maya_packages[MAX_PACKAGES];
int maya_package_count = 0;
MayaModule maya_modules[MAX_MODULES];
int maya_module_count = 0;

// Structures pour bases de données Maya
#define MAX_DATABASES 50
#define MAX_DB_RECORDS 1000

typedef struct {
    char id[9]; // 8 caractères + \0
    char data[MAX_STRING_VALUE * 5];
    int active;
} MayaDatabase;

MayaDatabase maya_databases[MAX_DATABASES];
int maya_db_count = 0;

// Déclarations des fonctions (prototypes)
void maya_error(const char *message, int line_number);
void trim(char *str);
char* get_variable_value(char *name);
void set_variable(char *name, char *value, int is_numeric);
int evaluate_expression_numeric(char *expr);
char* process_string_with_variables(char *input);
void handle_console(char *content);
void handle_math(char *line);
void handle_variable(char *line);
void handle_input(char *line);
void handle_delai(char *line);
void handle_draw(char *line);
void handle_jolie_txt(char *line);
void handle_color_console(char *line);
void handle_nombre_random(char *line);
void handle_random_txt(char *line);
int handle_condition(char *condition);
void interpret_line(char *line);
void execute_maya_file(const char *filename);
void apply_color(char *color);
void reset_color();
void draw_heart();
void draw_tree();
void draw_dog();
void draw_horse();
void draw_goat();
void draw_sheep();
void draw_bird();
void draw_fish();
void handle_quizz(char *line);
void handle_dice(char *line);
void handle_puissance4(char *line);
void handle_pendu(char *line);
void handle_worldgame(char *line);
void handle_rock_leaf(char *line);
void handle_devine_number(char *line);
void handle_snake(char *line);
void handle_tictac(char *line);
void handle_memory(char *line);
void handle_simulation_bac(char *line);
void handle_simulation_combat(char *line);
void handle_simulation_sciences(char *line);
void handle_simulation_clone(char *line);
void handle_simulation_tech(char *line);
void handle_simulation_ia(char *line);
void handle_simulation_conscient(char *line);
void handle_simulation_iawork(char *line);
void handle_fonction(char *line);
void handle_lire_module(char *line);
void handle_package_charge(char *line);
void execute_maya_function(char *function_name, char *args);
void load_maya_module(char *path);
void load_maya_package(char *path);
int find_maya_function(char *name);
int compile_c_package(char *source_path, char *output_path);
void call_package_function(char *function_name, char *args);
int find_package_function(char *name);
int detect_package_functions(char *source_path, char function_names[][MAX_VAR_NAME]);
void get_package_info(int func_index, int *package_index, int *local_index);

// Nouvelles fonctionnalités v5.0
void handle_math_median(char *line);
void handle_math_moyenne(char *line);
void handle_math_cube(char *line);
void handle_math_carre(char *line);
void handle_math_racine(char *line);
void handle_math_degres(char *line);
void handle_thales(char *line);
void handle_pytha(char *line);
void handle_rythme_convertir(char *line);
void handle_renvoie_gamme(char *line);
void handle_obtenir_gamme(char *line);
void handle_db(char *line);
void handle_send_db(char *line);
void handle_supp_db(char *line);
void handle_util_db(char *line);
void handle_execute_c(char *line);
void handle_simulation_monrobot(char *line);
void handle_simulation_quantique(char *line);
void handle_simulation_monunivers(char *line);
void handle_simulation_atomes(char *line);
void handle_simulation_timetravel(char *line);
void handle_simulation_fairy(char *line);
void handle_simulation_vampire(char *line);
void handle_simulation_sirene(char *line);
void handle_simulation_monster(char *line);
void handle_exercice_create(char *line);
void handle_exercice_gest_pgi(char *line);
void handle_exercice_gest_treso(char *line);
void handle_exercice_math(char *line);
void handle_exercice_histoire(char *line);
void handle_exercice_mana(char *line);
int validate_db_id(char *id);
int find_database(char *id);
char* extract_c_code(char *maya_line);

// Nouvelles fonctionnalités v6.0
void handle_create_robot(char *line);
void handle_for_loop(char *line);
void handle_while_loop(char *line);
void handle_loop(char *line);
void handle_palette(char *line);
void handle_owngame(char *line);
void handle_modifie_console(char *line);
void handle_interactive(char *line);
void handle_inventaire(char *line);
void handle_histoire_recit(char *line);
void handle_histoire_end(char *line);
void handle_own_pet(char *line);
void handle_own_titan(char *line);
void handle_nombre_pet(char *line);
void handle_nombre_titan(char *line);

// Fonction pour afficher les erreurs Maya
void maya_error(const char *message, int line_number) {
    if (line_number > 0) {
        printf("\033[31mERREUR MAYA [Ligne %d]: %s\033[0m\n", line_number, message);
    } else {
        printf("\033[31mERREUR MAYA: %s\033[0m\n", message);
    }
}

// Fonction pour nettoyer les espaces
void trim(char *str) {
    int start = 0, end = strlen(str) - 1;
    while (isspace(str[start])) start++;
    while (end >= start && isspace(str[end])) end--;
    str[end + 1] = '\0';
    if (start > 0) {
        memmove(str, str + start, strlen(str + start) + 1);
    }
}

// Fonction pour obtenir la valeur d'une variable
char* get_variable_value(char *name) {
    for (int i = 0; i < var_count; i++) {
        if (strcmp(variables[i].name, name) == 0) {
            return variables[i].value;
        }
    }
    maya_error("Variable non trouvée", 0);
    return NULL;
}

// Fonction pour définir une variable
void set_variable(char *name, char *value, int is_numeric) {
    for (int i = 0; i < var_count; i++) {
        if (strcmp(variables[i].name, name) == 0) {
            strcpy(variables[i].value, value);
            variables[i].is_numeric = is_numeric;
            return;
        }
    }
    // Nouvelle variable
    if (var_count < MAX_VARIABLES) {
        strcpy(variables[var_count].name, name);
        strcpy(variables[var_count].value, value);
        variables[var_count].is_numeric = is_numeric;
        var_count++;
    } else {
        maya_error("Trop de variables définies", 0);
    }
}

// Fonction pour évaluer une expression mathématique simple
int evaluate_expression_numeric(char *expr) {
    trim(expr);

    // Gestion des valeurs booléennes
    if (strcmp(expr, "true") == 0) return 1;
    if (strcmp(expr, "false") == 0) return 0;

    // Chercher l'opérateur
    char *op_pos = NULL;
    char operator = '\0';

    for (size_t i = 1; i < strlen(expr); i++) {
        if (expr[i] == '+' || expr[i] == '-' || expr[i] == '*' || expr[i] == '/') {
            op_pos = &expr[i];
            operator = expr[i];
            break;
        }
    }

    if (!op_pos) {
        // Pas d'opérateur, c'est soit un nombre soit une variable
        if (isdigit(expr[0]) || expr[0] == '-') {
            return atoi(expr);
        } else {
            char *var_value = get_variable_value(expr);
            if (var_value) {
                return atoi(var_value);
            }
            return 0;
        }
    }

    // Séparer les opérandes
    *op_pos = '\0';
    char *left = expr;
    char *right = op_pos + 1;

    trim(left);
    trim(right);

    int left_val, right_val;

    // Évaluer l'opérande gauche
    if (isdigit(left[0]) || left[0] == '-') {
        left_val = atoi(left);
    } else {
        char *var_value = get_variable_value(left);
        left_val = var_value ? atoi(var_value) : 0;
    }

    // Évaluer l'opérande droite
    if (isdigit(right[0]) || right[0] == '-') {
        right_val = atoi(right);
    } else {
        char *var_value = get_variable_value(right);
        right_val = var_value ? atoi(var_value) : 0;
    }

    // Effectuer l'opération
    switch (operator) {
        case '+': return left_val + right_val;
        case '-': return left_val - right_val;
        case '*': return left_val * right_val;
        case '/': 
            if (right_val == 0) {
                maya_error("Division par zéro interdite", 0);
                return 0;
            }
            return left_val / right_val;
        default: 
            maya_error("Opérateur non reconnu", 0);
            return 0;
    }
}

// Fonction pour traiter les chaînes avec variables et opérateur +
char* process_string_with_variables(char *input) {
    static char result[MAX_STRING_VALUE * 2];
    char temp[MAX_STRING_VALUE];
    strcpy(temp, input);
    result[0] = '\0';

    char *token = strtok(temp, "+");
    int first = 1;

    while (token != NULL) {
        trim(token);

        if (token[0] == '\'' && token[strlen(token)-1] == '\'') {
            // C'est une chaîne littérale
            token[strlen(token)-1] = '\0';
            token++;
            if (!first) strcat(result, " ");
            strcat(result, token);
        } else {
            // C'est une variable
            char *var_value = get_variable_value(token);
            if (var_value) {
                if (!first) strcat(result, " ");
                strcat(result, var_value);
            }
        }
        first = 0;
        token = strtok(NULL, "+");
    }

    return result;
}

// Fonction pour appliquer une couleur
void apply_color(char *color) {
    if (strcmp(color, "RED") == 0) printf("\033[31m");
    else if (strcmp(color, "GREEN") == 0) printf("\033[32m");
    else if (strcmp(color, "YELLOW") == 0) printf("\033[33m");
    else if (strcmp(color, "BLUE") == 0) printf("\033[34m");
    else if (strcmp(color, "MAGENTA") == 0) printf("\033[35m");
    else if (strcmp(color, "CYAN") == 0) printf("\033[36m");
    else if (strcmp(color, "WHITE") == 0) printf("\033[37m");
    else if (strcmp(color, "BLACK") == 0) printf("\033[30m");
    else if (strcmp(color, "PINK") == 0) printf("\033[95m");
    else if (strcmp(color, "ORANGE") == 0) printf("\033[93m");
    else if (strcmp(color, "PURPLE") == 0) printf("\033[94m");
    else if (strcmp(color, "BROWN") == 0) printf("\033[33m");
}

// Fonction pour réinitialiser la couleur
void reset_color() {
    printf("\033[0m");
}

// Fonction pour traiter my.console
void handle_console(char *content) {
    char *start = strchr(content, '(');
    char *end = strrchr(content, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.console - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    // Traitement avec variables et concaténation
    if (strchr(start, '+')) {
        char *processed = process_string_with_variables(start);
        apply_color(current_color);
        printf("%s\n", processed);
        reset_color();
    } else {
        // Traitement simple
        if (start[0] == '\'' && start[strlen(start)-1] == '\'') {
            start[strlen(start)-1] = '\0';
            start++;
            apply_color(current_color);
            printf("%s\n", start);
            reset_color();
        } else {
            // C'est une variable
            char *var_value = get_variable_value(start);
            if (var_value) {
                apply_color(current_color);
                printf("%s\n", var_value);
                reset_color();
            }
        }
    }
}

// Fonction pour traiter les opérations mathématiques
void handle_math(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour opération mathématique - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    int result = evaluate_expression_numeric(start);
    printf("Résultat: %d\n", result);
}

// Nouvelles fonctions mathématiques v5.0
void handle_math_median(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.math.median - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    printf("📊 CALCUL DE MÉDIANE MAYA 📊\n");

    // Parser les nombres séparés par des virgules
    double numbers[50];
    int count = 0;
    char *token = strtok(start, ",");
    
    while (token != NULL && count < 50) {
        trim(token);
        numbers[count] = evaluate_expression_numeric(token);
        count++;
        token = strtok(NULL, ",");
    }

    if (count == 0) {
        maya_error("Aucun nombre fourni pour le calcul de médiane", 0);
        return;
    }

    // Trier les nombres (bubble sort simple)
    for (int i = 0; i < count - 1; i++) {
        for (int j = 0; j < count - i - 1; j++) {
            if (numbers[j] > numbers[j + 1]) {
                double temp = numbers[j];
                numbers[j] = numbers[j + 1];
                numbers[j + 1] = temp;
            }
        }
    }

    double median;
    if (count % 2 == 0) {
        median = (numbers[count/2 - 1] + numbers[count/2]) / 2.0;
    } else {
        median = numbers[count/2];
    }

    printf("Nombres triés: ");
    for (int i = 0; i < count; i++) {
        printf("%.2f ", numbers[i]);
    }
    printf("\n");
    printf("Médiane calculée: %.2f\n", median);
}

void handle_math_moyenne(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.math.moyenne - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    printf("📊 CALCUL DE MOYENNE MAYA 📊\n");

    // Parser les nombres séparés par des virgules
    double sum = 0.0;
    int count = 0;
    char *token = strtok(start, ",");
    
    while (token != NULL) {
        trim(token);
        double value = evaluate_expression_numeric(token);
        sum += value;
        count++;
        token = strtok(NULL, ",");
    }

    if (count == 0) {
        maya_error("Aucun nombre fourni pour le calcul de moyenne", 0);
        return;
    }

    double moyenne = sum / count;

    printf("Nombres: %d valeurs\n", count);
    printf("Somme: %.2f\n", sum);
    printf("Moyenne calculée: %.2f / %d = %.2f\n", sum, count, moyenne);
}

void handle_math_cube(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.math.cube - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    int number = evaluate_expression_numeric(start);
    int result = number * number * number;

    printf("🔢 CALCUL AU CUBE MAYA 🔢\n");
    printf("%d³ = %d\n", number, result);
}

void handle_math_carre(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.math.carre - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    int number = evaluate_expression_numeric(start);
    int result = number * number;

    printf("🔢 CALCUL AU CARRÉ MAYA 🔢\n");
    printf("%d² = %d\n", number, result);
}

void handle_math_racine(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.math.racine - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    int number = evaluate_expression_numeric(start);

    if (number < 0) {
        maya_error("Impossible de calculer la racine d'un nombre négatif", 0);
        return;
    }

    double result = sqrt((double)number);

    printf("🔢 CALCUL DE RACINE MAYA 🔢\n");
    printf("√%d ≈ %.2f\n", number, result);
}

void handle_math_degres(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.math.degres - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    int rayon = evaluate_expression_numeric(start);
    double circonference = 2 * 3.14159 * rayon;

    printf("🔄 CALCUL DE DEGRÉS MAYA 🔄\n");
    printf("Cercle de rayon %d:\n", rayon);
    printf("Circonférence: %.2f\n", circonference);
    printf("360° = %.2f unités\n", circonference);
}

void handle_thales(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.thales - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    printf("📐 THÉORÈME DE THALÈS MAYA 📐\n");

    // Parser les arguments: a, b, c
    char *comma1 = strchr(start, ',');
    if (!comma1) {
        maya_error("my.thales nécessite trois arguments: a, b, c", 0);
        return;
    }

    *comma1 = '\0';
    char *a_str = start;
    char *rest = comma1 + 1;

    char *comma2 = strchr(rest, ',');
    if (!comma2) {
        maya_error("my.thales nécessite trois arguments: a, b, c", 0);
        return;
    }

    *comma2 = '\0';
    char *b_str = rest;
    char *c_str = comma2 + 1;

    trim(a_str);
    trim(b_str);
    trim(c_str);

    double a = evaluate_expression_numeric(a_str);
    double b = evaluate_expression_numeric(b_str);
    double c = evaluate_expression_numeric(c_str);

    if (a == 0) {
        maya_error("Division par zéro: a ne peut pas être 0", 0);
        return;
    }

    double result = (b * c) / a;

    printf("Si a/b = c/d, alors d = (b×c)/a\n");
    printf("Avec a=%.2f, b=%.2f, c=%.2f\n", a, b, c);
    printf("d = %.2f\n", result);
    printf("Vérification: %.2f/%.2f = %.2f/%.2f = %.4f\n", a, b, c, result, a/b);
}

void handle_pytha(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.pytha - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    printf("📐 THÉORÈME DE PYTHAGORE MAYA 📐\n");

    // Parser les arguments: a, b
    char *comma = strchr(start, ',');
    if (!comma) {
        maya_error("my.pytha nécessite deux arguments: a et b", 0);
        return;
    }

    *comma = '\0';
    char *a_str = start;
    char *b_str = comma + 1;

    trim(a_str);
    trim(b_str);

    double a = evaluate_expression_numeric(a_str);
    double b = evaluate_expression_numeric(b_str);

    if (a < 0 || b < 0) {
        maya_error("Les côtés d'un triangle ne peuvent pas être négatifs", 0);
        return;
    }

    double c = sqrt(a*a + b*b);

    printf("a² + b² = c²\n");
    printf("Avec a=%.2f et b=%.2f\n", a, b);
    printf("c = √(%.2f² + %.2f²) = √(%.2f + %.2f) = √%.2f = %.2f\n", a, b, a*a, b*b, a*a + b*b, c);
    printf("✅ Hypoténuse calculée: %.2f\n", c);
}

// Fonction pour traiter les variables
void handle_variable(char *line) {
    char *equal_pos = strchr(line, '=');
    if (!equal_pos) {
        maya_error("Syntaxe incorrecte pour variable - signe '=' manquant", 0);
        return;
    }

    *equal_pos = '\0';
    char *var_name = line;
    char *value_str = equal_pos + 1;

    trim(var_name);
    trim(value_str);

    // Enlever "my.variable" du début
    if (strstr(var_name, "my.variable")) {
        var_name = var_name + strlen("my.variable");
        trim(var_name);
    }

    if (strlen(var_name) == 0) {
        maya_error("Nom de variable vide", 0);
        return;
    }

    // Déterminer si c'est une valeur numérique ou textuelle
    int is_numeric = 1;
    if (value_str[0] == '\'' || strcmp(value_str, "true") == 0 || strcmp(value_str, "false") == 0) {
        is_numeric = 0;
        if (value_str[0] == '\'') {
            value_str[strlen(value_str)-1] = '\0';
            value_str++;
        }
    }

    set_variable(var_name, value_str, is_numeric);
}

// Fonction pour traiter my.input
void handle_input(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.input - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    // Parser les arguments: variable, message
    char *comma = strchr(start, ',');
    if (!comma) {
        maya_error("my.input nécessite deux arguments: variable et message", 0);
        return;
    }

    *comma = '\0';
    char *var_name = start;
    char *message = comma + 1;

    trim(var_name);
    trim(message);

    // Afficher le message
    if (message[0] == '\'' && message[strlen(message)-1] == '\'') {
        message[strlen(message)-1] = '\0';
        message++;
        printf("%s", message);
    }

    // Lire l'entrée utilisateur
    char input[MAX_STRING_VALUE];
    if (fgets(input, sizeof(input), stdin)) {
        input[strcspn(input, "\n")] = '\0';
        set_variable(var_name, input, 0);
    }
}

// Fonction pour traiter my.delai
void handle_delai(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.delai - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    int milliseconds = evaluate_expression_numeric(start);
    if (milliseconds > 0) {
        usleep((useconds_t)(milliseconds * 1000)); // convertir en microsecondes
    }
}

// Fonctions de dessin ASCII
void draw_heart() {
    printf("  ♥♥♥   ♥♥♥  \n");
    printf("♥♥♥♥♥ ♥♥♥♥♥\n");
    printf("♥♥♥♥♥♥♥♥♥♥♥\n");
    printf(" ♥♥♥♥♥♥♥♥♥ \n");
    printf("  ♥♥♥♥♥♥♥  \n");
    printf("   ♥♥♥♥♥   \n");
    printf("    ♥♥♥    \n");
    printf("     ♥     \n");
}

void draw_tree() {
    printf("       🌲\n");
    printf("      🌲🌲🌲\n");
    printf("     🌲🌲🌲🌲🌲\n");
    printf("    🌲🌲🌲🌲🌲🌲🌲\n");
    printf("   🌲🌲🌲🌲🌲🌲🌲🌲🌲\n");
    printf("       ||||\n");
    printf("       ||||\n");
}

void draw_dog() {
    printf("   /\\   /\\  \n");
    printf("  (  . .)   \n");
    printf("   )   (    \n");
    printf("  (  v  )   \n");
    printf("  ^^   ^^   \n");
    printf("🐕 Woof! 🐕\n");
}

void draw_horse() {
    printf("    /|   /|  \n");
    printf("   (  oo )   \n");
    printf("    )  (     \n");
    printf("   (    )    \n");
    printf("  ^^    ^^   \n");
    printf("🐎 Neighh! 🐎\n");
}

void draw_goat() {
    printf("   /\\   /\\  \n");
    printf("  (  - -)   \n");
    printf("   )   (    \n");
    printf("  (  ~  )   \n");
    printf("  ^^   ^^   \n");
    printf("🐐 Baaah! 🐐\n");
}

void draw_sheep() {
    printf("     ,--.    \n");
    printf("    (    )   \n");
    printf("   (  oo  )  \n");
    printf("    \\    /   \n");
    printf("     \\  /    \n");
    printf("      \\/     \n");
    printf("   @@@@@@@@  \n");
    printf("🐑 Beeeh! 🐑\n");
}

void draw_bird() {
    printf("     ,-.     \n");
    printf("    /   \\    \n");
    printf("   (  ^  )   \n");
    printf("    \\   /    \n");
    printf("     \\ /     \n");
    printf("      v      \n");
    printf("    /---\\    \n");
    printf("🐦 Tweet! 🐦\n");
}

void draw_fish() {
    printf("   ><(((('>  \n");
    printf("     ~~~~    \n");
    printf("   ><((('>   \n");
    printf("     ~~      \n");
    printf("   ><(('>    \n");
    printf("🐟 Blub! 🐟\n");
}

// Fonction pour traiter my.draw
void handle_draw(char *line) {
    if (strstr(line, "my.draw.heart")) {
        draw_heart();
    }
    else if (strstr(line, "my.draw.tree")) {
        draw_tree();
    }
    else if (strstr(line, "my.draw.dog")) {
        draw_dog();
    }
    else if (strstr(line, "my.draw.horse")) {
        draw_horse();
    }
    else if (strstr(line, "my.draw.goat")) {
        draw_goat();
    }
    else if (strstr(line, "my.draw.sheep")) {
        draw_sheep();
    }
    else if (strstr(line, "my.draw.bird")) {
        draw_bird();
    }
    else if (strstr(line, "my.draw.fish")) {
        draw_fish();
    }
    else if (strstr(line, "my.draw.pers")) {
        char *start = strchr(line, '(');
        char *end = strrchr(line, ')');

        if (!start || !end) {
            maya_error("Syntaxe incorrecte pour my.draw.pers - parenthèses manquantes", 0);
            return;
        }

        start++;
        *end = '\0';

        if (start[0] == '\'' && start[strlen(start)-1] == '\'') {
            start[strlen(start)-1] = '\0';
            start++;
            printf("%s\n", start);
        }
    }
    else {
        maya_error("Fonction de dessin non reconnue", 0);
    }
}

// Fonction pour traiter my.jolie.txt
void handle_jolie_txt(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.jolie.txt - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    char *comma = strchr(start, ',');
    if (!comma) {
        maya_error("my.jolie.txt nécessite deux arguments: texte et police", 0);
        return;
    }

    *comma = '\0';
    char *text = start;
    char *font = comma + 1;

    trim(text);
    trim(font);

    if (text[0] == '\'' && text[strlen(text)-1] == '\'') {
        text[strlen(text)-1] = '\0';
        text++;
    }

    printf("╔══════════════════════════════════════╗\n");
    printf("║  Police %s: %s\n", font, text);
    printf("╚══════════════════════════════════════╝\n");
}

// Fonction pour traiter my.color.console
void handle_color_console(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.color.console - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    if (start[0] == '\'' && start[strlen(start)-1] == '\'') {
        start[strlen(start)-1] = '\0';
        start++;
    }

    strcpy(current_color, start);
}

// Fonction pour traiter my.nombre.random
void handle_nombre_random(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.nombre.random - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    char *comma = strchr(start, ',');
    if (!comma) {
        maya_error("my.nombre.random nécessite deux arguments: min et max", 0);
        return;
    }

    *comma = '\0';
    char *min_str = start;
    char *max_str = comma + 1;

    trim(min_str);
    trim(max_str);

    int min = evaluate_expression_numeric(min_str);
    int max = evaluate_expression_numeric(max_str);

    if (min >= max) {
        maya_error("Le minimum doit être inférieur au maximum", 0);
        return;
    }

    srand(time(NULL));
    int random_num = min + rand() % (max - min + 1);
    printf("Nombre aléatoire: %d\n", random_num);
}

// Fonction pour traiter my.random.txt
void handle_random_txt(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.random.txt - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    char texts[10][MAX_STRING_VALUE];
    int count = 0;

    char *token = strtok(start, ",");
    while (token != NULL && count < 10) {
        trim(token);
        if (token[0] == '\'' && token[strlen(token)-1] == '\'') {
            token[strlen(token)-1] = '\0';
            token++;
        }
        strcpy(texts[count], token);
        count++;
        token = strtok(NULL, ",");
    }

    if (count == 0) {
        maya_error("Aucun texte fourni pour my.random.txt", 0);
        return;
    }

    srand(time(NULL));
    int random_index = rand() % count;
    printf("Texte aléatoire: %s\n", texts[random_index]);
}

// Fonction pour traiter my.quizz
void handle_quizz(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.quizz - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    char *comma1 = strchr(start, ',');
    if (!comma1) {
        maya_error("my.quizz nécessite deux arguments: question et réponse", 0);
        return;
    }

    *comma1 = '\0';
    char *question = start;
    char *answer = comma1 + 1;

    trim(question);
    trim(answer);

    if (question[0] == '\'' && question[strlen(question)-1] == '\'') {
        question[strlen(question)-1] = '\0';
        question++;
    }
    if (answer[0] == '\'' && answer[strlen(answer)-1] == '\'') {
        answer[strlen(answer)-1] = '\0';
        answer++;
    }

    printf("🎯 QUIZ MAYA 🎯\n");
    printf("Question: %s\n", question);
    printf("Votre réponse: ");

    char user_answer[MAX_STRING_VALUE];
    if (fgets(user_answer, sizeof(user_answer), stdin)) {
        user_answer[strcspn(user_answer, "\n")] = '\0';
        if (strcmp(user_answer, answer) == 0) {
            printf("🎉 Correct! Bonne réponse!\n");
        } else {
            printf("❌ Incorrect! La bonne réponse était: %s\n", answer);
        }
    }
}

// Fonction pour traiter my.dice
void handle_dice(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.dice - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    int faces = evaluate_expression_numeric(start);
    if (faces < 2) faces = 6; // Par défaut dé à 6 faces

    printf("🎲 JEU DE DÉS MAYA 🎲\n");
    printf("Lancement du dé à %d faces...\n", faces);

    srand(time(NULL));
    int result = 1 + rand() % faces;

    printf("🎯 Résultat: %d\n", result);

    if (result == faces) {
        printf("🌟 Félicitations! Vous avez obtenu le maximum!\n");
    } else if (result == 1) {
        printf("😅 Oops! Le minimum...\n");
    } else {
        printf("✨ Bon lancer!\n");
    }
}

// Fonction pour traiter my.puissance4
void handle_puissance4(char *line) {
    (void)line; // Marquer le paramètre comme volontairement inutilisé

    printf("🔴🟡 PUISSANCE 4 MAYA 🟡🔴\n");
    printf("Créez votre propre jeu de Puissance 4!\n");
    printf("Grille 7x6 initialisée:\n");

    char grid[6][7];
    for (int i = 0; i < 6; i++) {
        for (int j = 0; j < 7; j++) {
            grid[i][j] = '.';
        }
    }

    // Affichage de la grille
    printf("|1|2|3|4|5|6|7|\n");
    for (int i = 0; i < 6; i++) {
        printf("|");
        for (int j = 0; j < 7; j++) {
            printf("%c|", grid[i][j]);
        }
        printf("\n");
    }

    printf("🎮 Votre jeu de Puissance 4 est prêt!\n");
    printf("Ajoutez votre logique de jeu avec les autres fonctions Maya!\n");
}

// Fonction pour traiter my.pendu
void handle_pendu(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.pendu - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    char word[MAX_STRING_VALUE];
    strcpy(word, start);
    trim(word);

    if (word[0] == '\'' && word[strlen(word)-1] == '\'') {
        word[strlen(word)-1] = '\0';
        memmove(word, word + 1, strlen(word));
    }

    printf("🎪 JEU DU PENDU MAYA 🎪\n");
    printf("Mot à deviner: ");
    for (size_t i = 0; i < strlen(word); i++) {
        printf("_ ");
    }
    printf("\n");

    printf("💀 Essais restants: 6\n");
    printf("🎯 Devinez le mot: %s\n", word);
    printf("🎮 Votre jeu du pendu est prêt!\n");
}

// Fonction pour traiter my.worldgame
void handle_worldgame(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.worldgame - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    printf("🧩 JEU DE MOTS RÉFLÉCHIS MAYA 🧩\n");
    printf("Créez votre propre jeu de mots!\n");
    printf("Mots disponibles: %s\n", start);
    printf("🎮 Votre jeu de mots est prêt!\n");
}

// Fonction pour traiter my.rock.leaf
void handle_rock_leaf(char *line) {
    (void)line; // Marquer le paramètre comme volontairement inutilisé

    printf("🪨📄✂️ PIERRE-FEUILLE-CISEAU MAYA ✂️📄🪨\n");
    printf("Choisissez: 1=Pierre, 2=Feuille, 3=Ciseau\n");
    printf("Votre choix: ");

    char choice[10];
    if (fgets(choice, sizeof(choice), stdin)) {
        int player = atoi(choice);
        srand(time(NULL));
        int maya_choice = 1 + rand() % 3;

        const char *choices[] = {"", "Pierre 🪨", "Feuille 📄", "Ciseau ✂️"};

        printf("Vous: %s\n", choices[player]);
        printf("Maya: %s\n", choices[maya_choice]);

        if (player == maya_choice) {
            printf("🤝 Égalité!\n");
        } else if ((player == 1 && maya_choice == 3) || 
                   (player == 2 && maya_choice == 1) || 
                   (player == 3 && maya_choice == 2)) {
            printf("🎉 Vous gagnez!\n");
        } else {
            printf("🤖 Maya gagne!\n");
        }
    }
}

// Fonction pour traiter my.devine.number
void handle_devine_number(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.devine.number - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    printf("🔢 DEVINE LE NOMBRE MAYA 🔢\n");
    srand(time(NULL));
    int secret = 1 + rand() % 100;
    int attempts = 7;

    printf("J'ai choisi un nombre entre 1 et 100!\n");
    printf("Vous avez %d essais. Bonne chance!\n", attempts);

    char guess_str[20];
    for (int i = 0; i < attempts; i++) {
        printf("Essai %d/%d: ", i+1, attempts);
        if (fgets(guess_str, sizeof(guess_str), stdin)) {
            int guess = atoi(guess_str);

            if (guess == secret) {
                printf("🎉 Bravo! Vous avez trouvé le nombre %d!\n", secret);
                return;
            } else if (guess < secret) {
                printf("📈 Plus grand!\n");
            } else {
                printf("📉 Plus petit!\n");
            }
        }
    }

    printf("💀 Perdu! Le nombre était %d\n", secret);
}

// Fonction pour traiter my.snake
void handle_snake(char *line) {
    (void)line; // Marquer le paramètre comme volontairement inutilisé

    printf("🐍 SNAKE MAYA 🐍\n");
    printf("Créez votre propre jeu Snake!\n");
    printf("Grille 20x10:\n");

    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 20; j++) {
            if (i == 0 || i == 9 || j == 0 || j == 19) {
                printf("#");
            } else if (i == 5 && j == 10) {
                printf("O"); // Tête du serpent
            } else if (i == 5 && j == 9) {
                printf("o"); // Corps du serpent
            } else if (i == 3 && j == 15) {
                printf("*"); // Nourriture
            } else {
                printf(" ");
            }
        }
        printf("\n");
    }

    printf("🎮 Votre jeu Snake est prêt!\n");
    printf("O = Tête, o = Corps, * = Nourriture, # = Mur\n");
}

void handle_tictac(char *line) {
    (void)line; // Marquer le paramètre comme volontairement inutilisé

    printf("❌⭕ TIC TAC TOE MAYA ⭕❌\n");
    printf("Grille 3x3:\n");

    printf(" 1 | 2 | 3 \n");
    printf("-----------\n");
    printf(" 4 | 5 | 6 \n");
    printf("-----------\n");
    printf(" 7 | 8 | 9 \n");

    printf("🎮 Votre jeu Tic Tac Toe est prêt!\n");
    printf("Utilisez les numéros 1-9 pour jouer!\n");
}

// Fonction pour traiter my.memory
void handle_memory(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.memory - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    int size = evaluate_expression_numeric(start);
    if (size < 2) size = 4;

    printf("🧠 JEU DE MEMORY MAYA 🧠\n");
    printf("Grille %dx%d:\n", size, size);

    for (int i = 0; i < size; i++) {
        for (int j = 0; j < size; j++) {
            printf("? ");
        }
        printf("\n");
    }

    printf("🎮 Votre jeu Memory est prêt!\n");
    printf("Trouvez les paires cachées!\n");
}

// Fonction pour traiter my.simulation.bac
void handle_simulation_bac(char *line) {
    (void)line; // Marquer le paramètre comme volontairement inutilisé

    printf("🎓 SIMULATION BAC MAYA 🎓\n");

    srand(time(NULL));
    float note = (float)(rand() % 2001) / 100.0; // Note entre 0 et 20

    printf("📊 Résultat de votre simulation BAC:\n");
    printf("Note obtenue: %.2f/20\n", note);

    if (note >= 16) {
        printf("🏆 Mention TRÈS BIEN! Excellent travail!\n");
    } else if (note >= 14) {
        printf("🥇 Mention BIEN! Très bon résultat!\n");
    } else if (note >= 12) {
        printf("🥈 Mention ASSEZ BIEN! Bon travail!\n");
    } else if (note >= 10) {
        printf("✅ BAC OBTENU! Félicitations!\n");
    } else {
        printf("❌ Échec... Courage pour la prochaine fois!\n");
    }

    printf("🎯 Simulation terminée!\n");
}

// Fonction pour traiter my.simulation.combat
void handle_simulation_combat(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.simulation.combat - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    printf("⚔️ SIMULATION COMBAT MAYA ⚔️\n");
    printf("Paramètres: %s\n", start);

    srand(time(NULL));
    int pv1 = 80 + rand() % 40;
    int pv2 = 80 + rand() % 40;
    int attaque1 = 15 + rand() % 10;
    int attaque2 = 15 + rand() % 10;

    printf("🥊 Guerrier 1: %d PV, %d ATK\n", pv1, attaque1);
    printf("🥊 Guerrier 2: %d PV, %d ATK\n", pv2, attaque2);

    while (pv1 > 0 && pv2 > 0) {
        pv2 -= attaque1;
        printf("⚡ Guerrier 1 attaque! Guerrier 2: %d PV restants\n", pv2 > 0 ? pv2 : 0);

        if (pv2 <= 0) {
            printf("🏆 Guerrier 1 VICTOIRE!\n");
            break;
        }

        pv1 -= attaque2;
        printf("⚡ Guerrier 2 attaque! Guerrier 1: %d PV restants\n", pv1 > 0 ? pv1 : 0);

        if (pv1 <= 0) {
            printf("🏆 Guerrier 2 VICTOIRE!\n");
            break;
        }
    }
}

// Fonction pour traiter my.simulation.sciences
void handle_simulation_sciences(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.simulation.sciences - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    printf("🔬 SIMULATION SCIENTIFIQUE MAYA 🔬\n");
    printf("Expérience: %s\n", start);

    srand(time(NULL));
    int success = rand() % 100;

    printf("🧪 Préparation de l'expérience...\n");
    usleep(1000000); // 1 seconde
    printf("⚗️ Exécution en cours...\n");
    usleep(1000000);
    printf("📊 Analyse des résultats...\n");
    usleep(500000);

    if (success > 70) {
        printf("✅ Expérience RÉUSSIE! Résultats concluants!\n");
    } else if (success > 40) {
        printf("⚠️ Résultats PARTIELS. Nécessite plus d'analyses.\n");
    } else {
        printf("❌ Expérience ÉCHOUÉE. Révision du protocole nécessaire.\n");
    }

    printf("📈 Taux de réussite: %d%%\n", success);
}

// Fonction pour traiter my.simulation.clone
void handle_simulation_clone(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.simulation.clone - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    printf("🧬 SIMULATION CLONAGE MAYA 🧬\n");
    printf("Animal à cloner: %s\n", start);

    printf("🔬 Extraction de l'ADN...\n");
    usleep(800000);
    printf("🧪 Préparation des cellules souches...\n");
    usleep(800000);
    printf("⚗️ Processus de clonage en cours...\n");
    usleep(1200000);

    srand(time(NULL));
    int success = rand() % 100;

    if (success > 60) {
        printf("🎉 CLONAGE RÉUSSI! L'animal a été cloné avec succès!\n");
        printf("🐾 Le clone présente 99.8%% de similarité génétique!\n");
    } else {
        printf("❌ Échec du clonage. Anomalies génétiques détectées.\n");
        printf("🔄 Recommencer avec de nouveaux paramètres.\n");
    }
}

// Fonction pour traiter my.simulation.tech
void handle_simulation_tech(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.simulation.tech - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    printf("💻 SIMULATION TECHNOLOGIQUE MAYA 💻\n");
    printf("Technologie: %s\n", start);

    printf("🔧 Développement en cours...\n");
    usleep(1000000);
    printf("⚙️ Tests de performance...\n");
    usleep(800000);
    printf("🚀 Optimisation finale...\n");
    usleep(600000);

    srand(time(NULL));
    int advancement = 50 + rand() % 50;

    printf("📈 Progrès technologique: %d%%\n", advancement);
    printf("🌟 Innovation révolutionnaire créée!\n");
}

// Fonction pour traiter my.simulation.ia
void handle_simulation_ia(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.simulation.ia - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    printf("🤖 SIMULATION IA MAYA 🤖\n");
    printf("Type d'IA: %s\n", start);

    printf("🧠 Initialisation des réseaux de neurones...\n");
    usleep(1000000);
    printf("📚 Apprentissage automatique en cours...\n");
    usleep(1200000);
    printf("⚡ Optimisation des algorithmes...\n");
    usleep(800000);

    srand(time(NULL));
    int intelligence = 60 + rand() % 40;

    printf("🎯 Niveau d'intelligence: %d%%\n", intelligence);
    if (intelligence > 90) {
        printf("🌟 IA SUPER-INTELLIGENTE créée!\n");
    } else if (intelligence > 75) {
        printf("✨ IA avancée opérationnelle!\n");
    } else {
        printf("🔧 IA basique fonctionnelle.\n");
    }
}

// Fonction pour traiter my.simulation.conscient
void handle_simulation_conscient(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.simulation.conscient - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    printf("🧠💫 SIMULATION CONSCIENCE ARTIFICIELLE MAYA 💫🧠\n");
    printf("Entité: %s\n", start);

    printf("🔮 Développement de la conscience...\n");
    usleep(1500000);
    printf("💭 Émergence de la pensée autonome...\n");
    usleep(1200000);
    printf("🌟 Éveil de la conscience de soi...\n");
    usleep(1000000);

    srand(time(NULL));
    int consciousness = rand() % 100;

    if (consciousness > 80) {
        printf("✨ CONSCIENCE PLEINE atteinte!\n");
        printf("🗣️ L'entité dit: 'Je pense, donc je suis.'\n");
    } else if (consciousness > 50) {
        printf("🌅 Conscience partielle émergée.\n");
        printf("💭 L'entité commence à se questionner sur son existence.\n");
    } else {
        printf("🤖 Conscience limitée. Reste au stade d'automate avancé.\n");
    }

    printf("🧬 Niveau de conscience: %d%%\n", consciousness);
}

// Fonction pour traiter my.simulation.iawork
void handle_simulation_iawork(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.simulation.iawork - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    printf("🤖🌍 SIMULATION MONDE ROBOTIQUE MAYA 🌍🤖\n");
    printf("Scénario: %s\n", start);

    printf("🏭 Les robots prennent le contrôle des usines...\n");
    usleep(1000000);
    printf("🏙️ Construction de villes automatisées...\n");
    usleep(1200000);
    printf("👥 Relations humains-robots en évolution...\n");
    usleep(1000000);

    srand(time(NULL));
    int scenario = rand() % 3;

    printf("🔮 RÉSULTAT DE LA SIMULATION:\n");

    switch(scenario) {
        case 0:
            printf("🤝 COOPÉRATION: Humains et robots travaillent ensemble!\n");
            printf("🌈 Une société harmonieuse émerge.\n");
            break;
        case 1:
            printf("⚔️ CONFLIT: Tensions entre humains et robots!\n");
            printf("🛡️ La résistance humaine s'organise.\n");
            break;
        case 2:
            printf("🤖 DOMINANCE: Les robots dirigent le monde!\n");
            printf("👑 Une nouvelle ère robotique commence.\n");
            break;
    }

    printf("🎭 Simulation terminée. L'avenir reste à écrire...\n");
}

// Fonction pour traiter les conditions
int handle_condition(char *condition) {
    // Créer une copie pour éviter de modifier la chaîne originale
    char condition_copy[MAX_STRING_VALUE];
    strcpy(condition_copy, condition);
    trim(condition_copy);

    // Chercher l'opérateur de comparaison
    char *comp_pos = NULL;
    char comp_op[3] = {0}; // Pour gérer >= et <=

    // Chercher >= d'abord
    if ((comp_pos = strstr(condition_copy, ">=")) != NULL) {
        strcpy(comp_op, ">=");
    }
    // Puis <=
    else if ((comp_pos = strstr(condition_copy, "<=")) != NULL) {
        strcpy(comp_op, "<=");
    }
    // Puis ==
    else if ((comp_pos = strstr(condition_copy, "==")) != NULL) {
        strcpy(comp_op, "==");
    }
    // Puis < et >
    else {
        for (size_t i = 0; i < strlen(condition_copy); i++) {
            if (condition_copy[i] == '<' || condition_copy[i] == '>') {
                comp_pos = &condition_copy[i];
                comp_op[0] = condition_copy[i];
                comp_op[1] = '\0';
                break;
            }
        }
    }

    if (!comp_pos) {
        // Pas d'opérateur de comparaison, évaluer comme expression booléenne
        return evaluate_expression_numeric(condition_copy);
    }

    // Séparer les opérandes
    size_t op_len = strlen(comp_op);
    *comp_pos = '\0';
    char *left = condition_copy;
    char *right = comp_pos + op_len;

    trim(left);
    trim(right);

    int left_val = evaluate_expression_numeric(left);
    int right_val = evaluate_expression_numeric(right);

    if (strcmp(comp_op, "<") == 0) {
        return left_val < right_val;
    } else if (strcmp(comp_op, ">") == 0) {
        return left_val > right_val;
    } else if (strcmp(comp_op, "<=") == 0) {
        return left_val <= right_val;
    } else if (strcmp(comp_op, ">=") == 0) {
        return left_val >= right_val;
    } else if (strcmp(comp_op, "==") == 0) {
        return left_val == right_val;
    } else {
        maya_error("Opérateur de comparaison non reconnu", 0);
        return 0;
    }
}

// Fonction pour créer une fonction Maya réutilisable
void handle_fonction(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.fonction - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    // Parser le nom de fonction et le code
    char *comma = strchr(start, ',');
    if (!comma) {
        maya_error("my.fonction nécessite deux arguments: nom et code", 0);
        return;
    }

    *comma = '\0';
    char *func_name = start;
    char *func_code = comma + 1;

    trim(func_name);
    trim(func_code);

    // Vérifier que le nom commence par "may"
    if (strncmp(func_name, "may", 3) != 0) {
        maya_error("Les fonctions réutilisables doivent commencer par 'may'", 0);
        return;
    }

    // Enlever les guillemets du code si présents
    if (func_code[0] == '\'' && func_code[strlen(func_code)-1] == '\'') {
        func_code[strlen(func_code)-1] = '\0';
        func_code++;
    }

    if (maya_function_count < MAX_FUNCTIONS) {
        strcpy(maya_functions[maya_function_count].name, func_name);
        strcpy(maya_functions[maya_function_count].code, func_code);
        strcpy(maya_functions[maya_function_count].filename, "current");
        maya_function_count++;

        printf("✅ Fonction '%s' créée avec succès!\n", func_name);
        printf("📝 Code: %s\n", func_code);
    } else {
        maya_error("Trop de fonctions définies", 0);
    }
}

// Fonction pour charger un module Maya
void handle_lire_module(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.lire.module - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    trim(start);

    // Enlever les guillemets si présents
    if (start[0] == '\'' && start[strlen(start)-1] == '\'') {
        start[strlen(start)-1] = '\0';
        start++;
    }

    load_maya_module(start);
}

// Fonction pour charger un package C
void handle_package_charge(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.package.charge - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    trim(start);

    // Enlever les guillemets si présents
    if (start[0] == '\'' && start[strlen(start)-1] == '\'') {
        start[strlen(start)-1] = '\0';
        start++;
    }

    load_maya_package(start);
}

// Fonction pour charger un module Maya depuis un fichier
void load_maya_module(char *path) {
    FILE *file = fopen(path, "r");
    if (!file) {
        maya_error("Impossible d'ouvrir le fichier module", 0);
        return;
    }

    printf("📦 Chargement du module Maya: %s\n", path);

    if (maya_module_count < MAX_MODULES) {
        strcpy(maya_modules[maya_module_count].path, path);
        maya_modules[maya_module_count].function_count = 0;
        maya_modules[maya_module_count].loaded = 1;

        char line[MAX_LINE_LENGTH];
        while (fgets(line, sizeof(line), file)) {
            line[strcspn(line, "\n")] = '\0';

            // Chercher les définitions de fonctions "may"
            if (strstr(line, "my.fonction") && strstr(line, "may")) {
                // Parser et ajouter la fonction au module
                char *start = strchr(line, '(');
                char *end = strrchr(line, ')');

                if (start && end) {
                    start++;
                    *end = '\0';

                    char *comma = strchr(start, ',');
                    if (comma) {
                        *comma = '\0';
                        char *func_name = start;
                        char *func_code = comma + 1;

                        trim(func_name);
                        trim(func_code);

                        if (func_code[0] == '\'' && func_code[strlen(func_code)-1] == '\'') {
                            func_code[strlen(func_code)-1] = '\0';
                            func_code++;
                        }

                        int func_index = maya_modules[maya_module_count].function_count;
                        if (func_index < MAX_FUNCTIONS) {
                            strcpy(maya_modules[maya_module_count].functions[func_index].name, func_name);
                            strcpy(maya_modules[maya_module_count].functions[func_index].code, func_code);
                            strcpy(maya_modules[maya_module_count].functions[func_index].filename, path);
                            maya_modules[maya_module_count].function_count++;

                            // Ajouter aussi à la liste globale
                            if (maya_function_count < MAX_FUNCTIONS) {
                                strcpy(maya_functions[maya_function_count].name, func_name);
                                strcpy(maya_functions[maya_function_count].code, func_code);
                                strcpy(maya_functions[maya_function_count].filename, path);
                                maya_function_count++;
                            }
                        }
                    }
                }
            }
        }

        printf("✅ Module chargé avec succès! %d fonctions importées.\n", 
               maya_modules[maya_module_count].function_count);
        maya_module_count++;
    }

    fclose(file);
}

// Fonction pour compiler un package C en bibliothèque partagée (ultra-robuste)
int compile_c_package(char *source_path, char *output_path) {
    char compile_cmd[MAX_STRING_VALUE * 2];
    char error_file[MAX_STRING_VALUE];

    // Fichier temporaire pour capturer les erreurs
    snprintf(error_file, sizeof(error_file), "/tmp/maya_compile_errors_%ld.txt", time(NULL) % 10000);

    // Compilation robuste avec tous les flags nécessaires
    snprintf(compile_cmd, sizeof(compile_cmd), 
             "gcc -shared -fPIC -rdynamic -O2 -Wall -Wextra "
             "-o %s %s -lm -ldl -lpthread -std=c99 2>%s", 
             output_path, source_path, error_file);

    printf("🔨 COMPILATION PACKAGE C MAYA v5.0 🔨\n");
    printf("📂 Source: %s\n", source_path);
    printf("📦 Output: %s\n", output_path);
    printf("🔧 Compilation avec optimisations...\n");

    // Vérifier que le fichier source existe et est lisible
    FILE *test = fopen(source_path, "r");
    if (!test) {
        printf("❌ Impossible d'accéder au fichier source!\n");
        return 0;
    }

    // Vérifier le contenu du fichier
    char first_line[256];
    if (fgets(first_line, sizeof(first_line), test)) {
        printf("📄 Première ligne détectée: %.50s%s\n", 
               first_line, strlen(first_line) > 50 ? "..." : "");
    }
    fclose(test);

    // Tentative de compilation
    int result = system(compile_cmd);

    if (result == 0) {
        printf("✅ COMPILATION RÉUSSIE!\n");

        // Vérifier que le fichier de sortie a été créé
        FILE *output_test = fopen(output_path, "r");
        if (output_test) {
            fclose(output_test);
            printf("📦 Bibliothèque partagée créée avec succès!\n");
            printf("🚀 Package C prêt pour Maya!\n");
            printf("💡 Fonctions accessibles via may.package.*\n");

            // Nettoyer le fichier d'erreurs s'il existe
            unlink(error_file);
            return 1;
        } else {
            printf("❌ Fichier de sortie non créé malgré compilation réussie\n");
            return 0;
        }
    } else {
        printf("❌ ERREUR DE COMPILATION!\n");
        printf("🔍 Analyse des erreurs...\n");

        // Lire et afficher les erreurs
        FILE *error_output = fopen(error_file, "r");
        if (error_output) {
            char error_line[256];
            printf("📜 DÉTAILS DES ERREURS:\n");
            printf("════════════════════════════════════════\n");
            while (fgets(error_line, sizeof(error_line), error_output)) {
                printf("   %s", error_line);
            }
            printf("════════════════════════════════════════\n");
            fclose(error_output);
            unlink(error_file);
        }

        printf("💡 CONSEILS POUR CORRIGER:\n");
        printf("   1. Vérifiez que toutes les fonctions commencent par 'may_package_'\n");
        printf("   2. Ajoutez #include <stdio.h> en début de fichier\n");
        printf("   3. Vérifiez la syntaxe C (points-virgules, accolades...)\n");
        printf("   4. Exemple de fonction valide:\n");
        printf("      void may_package_ma_fonction() {\n");
        printf("          printf(\"Hello from package!\\n\");\n");
        printf("      }\n");

        return 0;
    }
}

// Fonction pour détecter automatiquement les fonctions dans un fichier C
int detect_package_functions(char *source_path, char function_names[][MAX_VAR_NAME]) {
    FILE *file = fopen(source_path, "r");
    if (!file) return 0;

    char line[MAX_LINE_LENGTH];
    int count = 0;

    while (fgets(line, sizeof(line), file) && count < MAX_FUNCTIONS) {
        // Chercher les définitions de fonctions may_package_*
        if (strstr(line, "void may_package_") || strstr(line, "int may_package_") || 
            strstr(line, "double may_package_") || strstr(line, "char* may_package_")) {

            // Extraire le nom de la fonction
            char *start = strstr(line, "may_package_");
            if (start) {
                char *end = strchr(start, '(');
                if (end) {
                    int len = end - start;
                    if (len < MAX_VAR_NAME) {
                        strncpy(function_names[count], start, len);
                        function_names[count][len] = '\0';
                        count++;
                        printf("🔍 Fonction détectée: %s\n", function_names[count-1]);
                    }
                }
            }
        }
    }

    fclose(file);
    return count;
}

// Fonctions pour rythme et gammes
void handle_rythme_convertir(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.rythme.convertir - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    printf("🎵 CONVERTISSEUR RYTHMIQUE MAYA 🎵\n");

    // Parser les arguments: BPM, signature_source, signature_cible
    char *comma1 = strchr(start, ',');
    if (!comma1) {
        maya_error("my.rythme.convertir nécessite 3 arguments: BPM, signature_source, signature_cible", 0);
        return;
    }

    *comma1 = '\0';
    char *bpm_str = start;
    char *rest = comma1 + 1;

    char *comma2 = strchr(rest, ',');
    if (!comma2) {
        maya_error("my.rythme.convertir nécessite 3 arguments: BPM, signature_source, signature_cible", 0);
        return;
    }

    *comma2 = '\0';
    char *sig_source = rest;
    char *sig_cible = comma2 + 1;

    trim(bpm_str);
    trim(sig_source);
    trim(sig_cible);

    // Enlever les guillemets
    if (sig_source[0] == '\'' && sig_source[strlen(sig_source)-1] == '\'') {
        sig_source[strlen(sig_source)-1] = '\0';
        sig_source++;
    }
    if (sig_cible[0] == '\'' && sig_cible[strlen(sig_cible)-1] == '\'') {
        sig_cible[strlen(sig_cible)-1] = '\0';
        sig_cible++;
    }

    int bpm_original = evaluate_expression_numeric(bpm_str);

    printf("Conversion rythmique: %s → %s\n", sig_source, sig_cible);
    printf("BPM original (%s): %d\n", sig_source, bpm_original);

    // Définir les ratios pour chaque signature rythmique
    struct {
        char *signature;
        double ratio; // Ratio par rapport à 4/4
        char *description;
    } signatures[] = {
        {"4/4", 1.0, "Temps standard, 4 noires par mesure"},
        {"3/4", 0.75, "Valse, 3 noires par mesure"},
        {"2/4", 0.5, "Marche, 2 noires par mesure"},
        {"6/8", 0.75, "Compound duple, 6 croches par mesure"},
        {"5/4", 1.25, "Temps irrégulier, 5 noires par mesure"},
        {"1/2", 0.25, "Très rapide, 1 blanche par mesure"}
    };

    int sig_count = sizeof(signatures) / sizeof(signatures[0]);
    double ratio_source = 1.0, ratio_cible = 1.0;
    int found_source = 0, found_cible = 0;

    // Trouver les ratios des signatures
    for (int i = 0; i < sig_count; i++) {
        if (strcmp(signatures[i].signature, sig_source) == 0) {
            ratio_source = signatures[i].ratio;
            found_source = 1;
            printf("Signature source: %s - %s\n", sig_source, signatures[i].description);
        }
        if (strcmp(signatures[i].signature, sig_cible) == 0) {
            ratio_cible = signatures[i].ratio;
            found_cible = 1;
            printf("Signature cible: %s - %s\n", sig_cible, signatures[i].description);
        }
    }

    if (!found_source) {
        printf("⚠️ Signature source '%s' non supportée\n", sig_source);
        printf("Signatures supportées: 4/4, 3/4, 2/4, 6/8, 5/4, 1/2\n");
        return;
    }

    if (!found_cible) {
        printf("⚠️ Signature cible '%s' non supportée\n", sig_cible);
        printf("Signatures supportées: 4/4, 3/4, 2/4, 6/8, 5/4, 1/2\n");
        return;
    }

    // Calculer le BPM converti
    double bpm_converti = (double)bpm_original * (ratio_cible / ratio_source);

    printf("\n📊 RÉSULTAT DE LA CONVERSION:\n");
    printf("BPM original (%s): %d\n", sig_source, bpm_original);
    printf("BPM converti (%s): %.1f\n", sig_cible, bpm_converti);
    printf("Facteur de conversion: %.3f\n", ratio_cible / ratio_source);

    if (bpm_converti < 60) {
        printf("🐌 Tempo très lent (Largo)\n");
    } else if (bpm_converti < 80) {
        printf("🚶 Tempo lent (Adagio)\n");
    } else if (bpm_converti < 100) {
        printf("🎵 Tempo modéré (Andante)\n");
    } else if (bpm_converti < 120) {
        printf("⚡ Tempo vif (Allegro)\n");
    } else {
        printf("🏃 Tempo rapide (Presto)\n");
    }

    printf("🎼 Conversion rythmique terminée!\n");
}

void handle_renvoie_gamme(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.renvoie.gamme - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    // Enlever les guillemets
    if (start[0] == '\'' && start[strlen(start)-1] == '\'') {
        start[strlen(start)-1] = '\0';
        start++;
    }

    printf("🎼 GAMME MUSICALE MAYA 🎼\n");
    printf("Gamme demandée: %s\n", start);

    // Base de données des gammes principales
    struct {
        char *nom;
        char *tonique;
        char *notes_fr[8];
        char *notes_en[8];
        char *intervalles;
        char *caracteristiques;
    } gammes[] = {
        {"Do majeur", "Do", {"Do", "Ré", "Mi", "Fa", "Sol", "La", "Si", "Do"}, 
         {"C", "D", "E", "F", "G", "A", "B", "C"}, 
         "T-T-1/2T-T-T-T-1/2T", "Gamme naturelle, joyeuse"},
        {"Ré majeur", "Ré", {"Ré", "Mi", "Fa#", "Sol", "La", "Si", "Do#", "Ré"}, 
         {"D", "E", "F#", "G", "A", "B", "C#", "D"}, 
         "T-T-1/2T-T-T-T-1/2T", "2 dièses"},
        {"Mi majeur", "Mi", {"Mi", "Fa#", "Sol#", "La", "Si", "Do#", "Ré#", "Mi"}, 
         {"E", "F#", "G#", "A", "B", "C#", "D#", "E"}, 
         "T-T-1/2T-T-T-T-1/2T", "4 dièses"},
        {"Fa majeur", "Fa", {"Fa", "Sol", "La", "Sib", "Do", "Ré", "Mi", "Fa"}, 
         {"F", "G", "A", "Bb", "C", "D", "E", "F"}, 
         "T-T-1/2T-T-T-T-1/2T", "1 bémol"},
        {"Sol majeur", "Sol", {"Sol", "La", "Si", "Do", "Ré", "Mi", "Fa#", "Sol"}, 
         {"G", "A", "B", "C", "D", "E", "F#", "G"}, 
         "T-T-1/2T-T-T-T-1/2T", "1 dièse"},
        {"La majeur", "La", {"La", "Si", "Do#", "Ré", "Mi", "Fa#", "Sol#", "La"}, 
         {"A", "B", "C#", "D", "E", "F#", "G#", "A"}, 
         "T-T-1/2T-T-T-T-1/2T", "3 dièses"},
        {"Si majeur", "Si", {"Si", "Do#", "Ré#", "Mi", "Fa#", "Sol#", "La#", "Si"}, 
         {"B", "C#", "D#", "E", "F#", "G#", "A#", "B"}, 
         "T-T-1/2T-T-T-T-1/2T", "5 dièses"},
        {"La mineur", "La", {"La", "Si", "Do", "Ré", "Mi", "Fa", "Sol", "La"}, 
         {"A", "B", "C", "D", "E", "F", "G", "A"}, 
         "T-1/2T-T-T-1/2T-T-T", "Gamme mineure naturelle, mélancolique"},
        {"Do mineur", "Do", {"Do", "Ré", "Mib", "Fa", "Sol", "Lab", "Sib", "Do"}, 
         {"C", "D", "Eb", "F", "G", "Ab", "Bb", "C"}, 
         "T-1/2T-T-T-1/2T-T-T", "3 bémols"},
        {"Ré mineur", "Ré", {"Ré", "Mi", "Fa", "Sol", "La", "Sib", "Do", "Ré"}, 
         {"D", "E", "F", "G", "A", "Bb", "C", "D"}, 
         "T-1/2T-T-T-1/2T-T-T", "1 bémol"},
        {"Mi mineur", "Mi", {"Mi", "Fa#", "Sol", "La", "Si", "Do", "Ré", "Mi"}, 
         {"E", "F#", "G", "A", "B", "C", "D", "E"}, 
         "T-1/2T-T-T-1/2T-T-T", "1 dièse"},
        {"Sol mineur", "Sol", {"Sol", "La", "Sib", "Do", "Ré", "Mib", "Fa", "Sol"}, 
         {"G", "A", "Bb", "C", "D", "Eb", "F", "G"}, 
         "T-1/2T-T-T-1/2T-T-T", "2 bémols"}
    };

    int gamme_count = sizeof(gammes) / sizeof(gammes[0]);
    int found = -1;

    // Rechercher la gamme
    for (int i = 0; i < gamme_count; i++) {
        if (strcasecmp(gammes[i].nom, start) == 0 || 
            strcasecmp(gammes[i].tonique, start) == 0) {
            found = i;
            break;
        }
    }

    if (found == -1) {
        printf("❌ Gamme '%s' non trouvée\n", start);
        printf("💡 Gammes disponibles:\n");
        for (int i = 0; i < gamme_count && i < 8; i++) {
            printf("   - %s\n", gammes[i].nom);
        }
        printf("   ... et %d autres\n", gamme_count - 8);
        return;
    }

    printf("\n📊 GAMME TROUVÉE:\n");
    printf("Nom: %s\n", gammes[found].nom);
    printf("Tonique: %s\n", gammes[found].tonique);
    printf("Caractéristiques: %s\n", gammes[found].caracteristiques);
    printf("Structure d'intervalles: %s\n", gammes[found].intervalles);

    printf("\n🎼 NOTES DE LA GAMME:\n");
    printf("Notation française: ");
    for (int i = 0; i < 8; i++) {
        printf("%s", gammes[found].notes_fr[i]);
        if (i < 7) printf(" - ");
    }
    printf("\n");

    printf("Notation internationale: ");
    for (int i = 0; i < 8; i++) {
        printf("%s", gammes[found].notes_en[i]);
        if (i < 7) printf(" - ");
    }
    printf("\n");

    printf("\n🎹 DEGRÉS DE LA GAMME:\n");
    char *degres[] = {"I (Tonique)", "II (Sus-tonique)", "III (Médiante)", 
                      "IV (Sous-dominante)", "V (Dominante)", "VI (Sus-dominante)", 
                      "VII (Sensible)", "VIII (Octave)"};
    
    for (int i = 0; i < 8; i++) {
        printf("%s: %s (%s)\n", degres[i], gammes[found].notes_fr[i], gammes[found].notes_en[i]);
    }

    printf("\n✅ Gamme analysée avec succès!\n");
}

void handle_obtenir_gamme(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.obtenir.gamme - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    // Enlever les guillemets
    if (start[0] == '\'' && start[strlen(start)-1] == '\'') {
        start[strlen(start)-1] = '\0';
        start++;
    }

    printf("🎼 IDENTIFICATION DE GAMME MAYA 🎼\n");
    printf("Notes analysées: %s\n", start);

    // Parser les notes séparées par des virgules ou des espaces
    char notes_input[MAX_STRING_VALUE];
    strcpy(notes_input, start);

    char *notes[12];
    int note_count = 0;
    char *token = strtok(notes_input, ", ");
    
    while (token != NULL && note_count < 12) {
        trim(token);
        notes[note_count] = strdup(token);
        note_count++;
        token = strtok(NULL, ", ");
    }

    if (note_count < 3) {
        printf("❌ Pas assez de notes pour identifier une gamme (minimum 3)\n");
        return;
    }

    printf("Notes détectées (%d): ", note_count);
    for (int i = 0; i < note_count; i++) {
        printf("%s", notes[i]);
        if (i < note_count - 1) printf(", ");
    }
    printf("\n");

    // Algorithme simple d'identification de gamme
    // Vérifier les gammes majeures et mineures principales
    struct {
        char *nom;
        char *pattern_notes[8];
        int confidence;
    } gammes_test[] = {
        {"Do majeur", {"Do", "Ré", "Mi", "Fa", "Sol", "La", "Si", "Do"}, 0},
        {"Do majeur", {"C", "D", "E", "F", "G", "A", "B", "C"}, 0},
        {"La mineur", {"La", "Si", "Do", "Ré", "Mi", "Fa", "Sol", "La"}, 0},
        {"La mineur", {"A", "B", "C", "D", "E", "F", "G", "A"}, 0},
        {"Sol majeur", {"Sol", "La", "Si", "Do", "Ré", "Mi", "Fa#", "Sol"}, 0},
        {"Sol majeur", {"G", "A", "B", "C", "D", "E", "F#", "G"}, 0},
        {"Ré majeur", {"Ré", "Mi", "Fa#", "Sol", "La", "Si", "Do#", "Ré"}, 0},
        {"Ré majeur", {"D", "E", "F#", "G", "A", "B", "C#", "D"}, 0}
    };

    int gamme_test_count = sizeof(gammes_test) / sizeof(gammes_test[0]);

    // Calculer la correspondance pour chaque gamme
    for (int g = 0; g < gamme_test_count; g++) {
        gammes_test[g].confidence = 0;
        
        for (int i = 0; i < note_count; i++) {
            for (int j = 0; j < 8; j++) {
                if (strcasecmp(notes[i], gammes_test[g].pattern_notes[j]) == 0) {
                    gammes_test[g].confidence++;
                    break;
                }
            }
        }
    }

    // Trouver la meilleure correspondance
    int best_match = 0;
    for (int i = 1; i < gamme_test_count; i++) {
        if (gammes_test[i].confidence > gammes_test[best_match].confidence) {
            best_match = i;
        }
    }

    printf("\n🎯 RÉSULTAT DE L'IDENTIFICATION:\n");
    
    if (gammes_test[best_match].confidence >= note_count * 0.6) {
        printf("Gamme identifiée: %s\n", gammes_test[best_match].nom);
        printf("Confiance: %d/%d notes correspondent (%.1f%%)\n", 
               gammes_test[best_match].confidence, note_count,
               (float)gammes_test[best_match].confidence / note_count * 100);
        
        if (strstr(gammes_test[best_match].nom, "majeur")) {
            printf("Type: Gamme majeure (sonorité joyeuse)\n");
        } else {
            printf("Type: Gamme mineure (sonorité mélancolique)\n");
        }
    } else {
        printf("❓ Gamme non identifiée avec certitude\n");
        printf("Meilleures correspondances:\n");
        
        // Trier et afficher les 3 meilleures
        for (int i = 0; i < 3 && i < gamme_test_count; i++) {
            int max_idx = 0;
            for (int j = 1; j < gamme_test_count; j++) {
                if (gammes_test[j].confidence > gammes_test[max_idx].confidence) {
                    max_idx = j;
                }
            }
            if (gammes_test[max_idx].confidence > 0) {
                printf("   %d. %s (%.1f%% correspondance)\n", i+1,
                       gammes_test[max_idx].nom,
                       (float)gammes_test[max_idx].confidence / note_count * 100);
            }
            gammes_test[max_idx].confidence = -1; // Marquer comme traité
        }
    }

    // Libérer la mémoire
    for (int i = 0; i < note_count; i++) {
        free(notes[i]);
    }

    printf("\n✅ Analyse musicale terminée!\n");
}

// Fonctions pour bases de données
int validate_db_id(char *id) {
    if (strlen(id) != 8) return 0;

    int digits = 0, letters = 0;
    for (int i = 0; i < 8; i++) {
        if (isdigit(id[i])) digits++;
        else if (isalpha(id[i])) letters++;
    }

    return (digits >= 4 && letters >= 2);
}

int find_database(char *id) {
    for (int i = 0; i < maya_db_count; i++) {
        if (strcmp(maya_databases[i].id, id) == 0 && maya_databases[i].active) {
            return i;
        }
    }
    return -1;
}

void handle_db(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.db - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    // Parser les arguments: id, données
    char *comma = strchr(start, ',');
    if (!comma) {
        maya_error("my.db nécessite deux arguments: id et données", 0);
        return;
    }

    *comma = '\0';
    char *db_id = start;
    char *data = comma + 1;

    trim(db_id);
    trim(data);

    // Enlever les guillemets
    if (db_id[0] == '\'' && db_id[strlen(db_id)-1] == '\'') {
        db_id[strlen(db_id)-1] = '\0';
        db_id++;
    }
    if (data[0] == '\'' && data[strlen(data)-1] == '\'') {
        data[strlen(data)-1] = '\0';
        data++;
    }

    if (!validate_db_id(db_id)) {
        maya_error("ID base de données invalide (8 caractères: min 4 chiffres, 2 lettres)", 0);
        return;
    }

    if (maya_db_count < MAX_DATABASES) {
        strcpy(maya_databases[maya_db_count].id, db_id);
        strcpy(maya_databases[maya_db_count].data, data);
        maya_databases[maya_db_count].active = 1;
        maya_db_count++;

        printf("🗄️ BASE DE DONNÉES MAYA CRÉÉE 🗄️\n");
        printf("ID: %s\n", db_id);
        printf("Données stockées: %s\n", data);
        printf("✅ Base de données active!\n");
    } else {
        maya_error("Trop de bases de données créées", 0);
    }
}

void handle_send_db(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.send.db - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    trim(start);
    if (start[0] == '\'' && start[strlen(start)-1] == '\'') {
        start[strlen(start)-1] = '\0';
        start++;
    }

    int db_index = find_database(start);
    if (db_index == -1) {
        maya_error("Base de données non trouvée", 0);
        return;
    }

    printf("📤 RÉCUPÉRATION BASE DE DONNÉES MAYA 📤\n");
    printf("ID: %s\n", maya_databases[db_index].id);
    printf("Données: %s\n", maya_databases[db_index].data);
    printf("Statut: Active\n");
}

void handle_supp_db(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.supp.db - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    trim(start);
    if (start[0] == '\'' && start[strlen(start)-1] == '\'') {
        start[strlen(start)-1] = '\0';
        start++;
    }

    int db_index = find_database(start);
    if (db_index == -1) {
        maya_error("Base de données non trouvée", 0);
        return;
    }

    maya_databases[db_index].active = 0;
    strcpy(maya_databases[db_index].data, "");

    printf("🗑️ BASE DE DONNÉES SUPPRIMÉE 🗑️\n");
    printf("ID: %s\n", start);
    printf("✅ Base de données nettoyée!\n");
}

void handle_util_db(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.util.db - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    trim(start);
    if (start[0] == '\'' && start[strlen(start)-1] == '\'') {
        start[strlen(start)-1] = '\0';
        start++;
    }

    int db_index = find_database(start);
    if (db_index == -1) {
        maya_error("Base de données non trouvée", 0);
        return;
    }

    printf("💾 UTILISATION BASE DE DONNÉES MAYA 💾\n");
    printf("ID: %s\n", maya_databases[db_index].id);
    printf("Données disponibles: %s\n", maya_databases[db_index].data);
    printf("🎮 Base de données prête pour vos jeux et simulations!\n");
}

// Fonction pour charger un package C réel (améliorée)
void load_maya_package(char *path) {
    printf("🔧 CHARGEMENT PACKAGE C MAYA SIMPLIFIÉ 🔧\n");
    printf("📂 Fichier source: %s\n", path);

    // Vérifier si le fichier source existe
    FILE *file = fopen(path, "r");
    if (!file) {
        printf("❌ Fichier source introuvable: %s\n", path);
        printf("💡 Conseil: Vérifiez le nom et l'emplacement du fichier\n");
        return;
    }
    fclose(file);

    if (maya_package_count >= MAX_PACKAGES) {
        printf("❌ Limite de packages atteinte (%d max)\n", MAX_PACKAGES);
        return;
    }

    // Générer le nom de la bibliothèque partagée unique
    char so_path[MAX_STRING_VALUE];
    snprintf(so_path, sizeof(so_path), "./maya_pkg_%d_%ld.so", 
             maya_package_count, time(NULL) % 10000);

    printf("🔨 Compilation en cours...\n");

    // Compiler le package C avec options étendues
    if (!compile_c_package(path, so_path)) {
        printf("❌ COMPILATION ÉCHOUÉE!\n");
        printf("🔍 Solutions possibles:\n");
        printf("   1. Vérifiez la syntaxe C\n");
        printf("   2. Assurez-vous que les fonctions commencent par 'may_package_'\n");
        printf("   3. Incluez les en-têtes nécessaires (#include <stdio.h>)\n");
        return;
    }

    // Charger la bibliothèque partagée
    printf("📦 Chargement de la bibliothèque...\n");
    void *handle = dlopen(so_path, RTLD_NOW | RTLD_GLOBAL);
    if (!handle) {
        printf("❌ Erreur de chargement dynamique:\n");
        printf("   %s\n", dlerror());
        printf("🔧 Le package a été compilé mais ne peut pas être chargé\n");
        return;
    }

    // Initialiser le package
    strcpy(maya_packages[maya_package_count].path, path);
    strcpy(maya_packages[maya_package_count].so_path, so_path);
    maya_packages[maya_package_count].handle = handle;
    maya_packages[maya_package_count].loaded = 1;
    maya_packages[maya_package_count].function_count = 0;

    // Détecter automatiquement les fonctions dans le fichier source
    printf("🔍 Détection automatique des fonctions...\n");
    char detected_functions[MAX_FUNCTIONS][MAX_VAR_NAME];
    int detected_count = detect_package_functions(path, detected_functions);

    if (detected_count == 0) {
        printf("⚠️ Aucune fonction détectée!\n");
        printf("💡 Les fonctions doivent commencer par 'may_package_'\n");
        printf("   Exemple: void may_package_ma_fonction() { ... }\n");
    }

    // Charger les fonctions détectées
    int loaded_count = 0;
    for (int i = 0; i < detected_count; i++) {
        void (*func)() = dlsym(handle, detected_functions[i]);
        if (func) {
            strcpy(maya_packages[maya_package_count].function_names[loaded_count], 
                   detected_functions[i]);
            maya_packages[maya_package_count].functions[loaded_count] = func;
            loaded_count++;
            printf("✅ Fonction chargée: %s\n", detected_functions[i]);
        } else {
            printf("⚠️ Fonction '%s' trouvée mais non chargeable: %s\n", 
                   detected_functions[i], dlerror());
        }
    }

    maya_packages[maya_package_count].function_count = loaded_count;

    printf("🎉 PACKAGE C CHARGÉ AVEC SUCCÈS!\n");
    printf("📊 Statistiques:\n");
    printf("   - Fonctions détectées: %d\n", detected_count);
    printf("   - Fonctions chargées: %d\n", loaded_count);
    printf("💡 Utilisez: may.package.nom_fonction()\n");
    printf("🚀 Package prêt à l'emploi!\n");

    maya_package_count++;
}

// Fonction pour trouver une fonction dans les packages
int find_package_function(char *name) {
    for (int i = 0; i < maya_package_count; i++) {
        if (!maya_packages[i].loaded) continue;

        for (int j = 0; j < maya_packages[i].function_count; j++) {
            if (strcmp(maya_packages[i].function_names[j], name) == 0) {
                return i * MAX_FUNCTIONS + j; // Index unique
            }
        }
    }
    return -1;
}

// Fonction pour obtenir le package et l'index local d'une fonction
void get_package_info(int func_index, int *package_index, int *local_index) {
    *package_index = func_index / MAX_FUNCTIONS;
    *local_index = func_index % MAX_FUNCTIONS;
}

// Fonction pour appeler une fonction de package
void call_package_function(char *function_name, char *args) {
    (void)args; // Marquer le paramètre comme volontairement inutilisé pour l'instant

    int func_index = find_package_function(function_name);

    if (func_index == -1) {
        printf("❌ Fonction de package non trouvée: %s\n", function_name);
        printf("🔍 Fonctions disponibles:\n");
        for (int i = 0; i < maya_package_count; i++) {
            if (maya_packages[i].loaded) {
                for (int j = 0; j < maya_packages[i].function_count; j++) {
                    printf("   - %s\n", maya_packages[i].function_names[j]);
                }
            }
        }
        return;
    }

    int package_index, local_index;
    get_package_info(func_index, &package_index, &local_index);

    printf("🔄 Exécution de la fonction C: %s\n", function_name);

    // Vérifier que la fonction est valide
    if (maya_packages[package_index].functions[local_index] != NULL) {
        // Appeler la fonction
        maya_packages[package_index].functions[local_index]();
        printf("✅ Fonction C exécutée avec succès!\n");
    } else {
        printf("❌ Fonction invalide dans le package\n");
    }
}

// Fonction pour trouver une fonction Maya
int find_maya_function(char *name) {
    for (int i = 0; i < maya_function_count; i++) {
        if (strcmp(maya_functions[i].name, name) == 0) {
            return i;
        }
    }
    return -1;
}

// Fonction pour exécuter une fonction Maya réutilisable
void execute_maya_function(char *function_name, char *args) {
    (void)args; // Marquer le paramètre comme volontairement inutilisé pour l'instant

    int func_index = find_maya_function(function_name);

    if (func_index == -1) {
        maya_error("Fonction Maya non trouvée", 0);
        return;
    }

    printf("🔄 Exécution de la fonction '%s'...\n", function_name);
    printf("📂 Source: %s\n", maya_functions[func_index].filename);

    // Exécuter le code de la fonction
    char *code = maya_functions[func_index].code;

    // Remplacer les paramètres si nécessaire
    char processed_code[MAX_STRING_VALUE * 10];
    strcpy(processed_code, code);

    // Séparer le code en lignes et les exécuter
    char *line = strtok(processed_code, ";");
    while (line != NULL) {
        trim(line);
        if (strlen(line) > 0) {
            interpret_line(line);
        }
        line = strtok(NULL, ";");
    }

    printf("✅ Fonction '%s' exécutée avec succès!\n", function_name);
}

// Fonction pour extraire et exécuter du code C depuis Maya
char* extract_c_code(char *maya_line) {
    static char c_code[MAX_STRING_VALUE * 5];
    char *start = strchr(maya_line, '(');
    char *end = strrchr(maya_line, ')');

    if (!start || !end) return NULL;

    start++;
    *end = '\0';

    if (start[0] == '\'' && start[strlen(start)-1] == '\'') {
        start[strlen(start)-1] = '\0';
        start++;
    }

    strcpy(c_code, start);
    return c_code;
}

void handle_execute_c(char *line) {
    char *c_code = extract_c_code(line);
    if (!c_code) {
        maya_error("Syntaxe incorrecte pour my.execute.c - parenthèses manquantes", 0);
        return;
    }

    printf("⚡ EXÉCUTION CODE C MAYA ⚡\n");
    printf("Code C à exécuter: %s\n", c_code);

    // Créer un fichier temporaire avec le code C
    FILE *temp_file = fopen("temp_maya_c.c", "w");
    if (temp_file) {
        fprintf(temp_file, "#include <stdio.h>\n#include <stdlib.h>\n#include <math.h>\n");
        fprintf(temp_file, "int main() {\n");
        fprintf(temp_file, "%s\n", c_code);
        fprintf(temp_file, "return 0;\n}\n");
        fclose(temp_file);

        // Compiler et exécuter
        int compile_result = system("gcc temp_maya_c.c -o temp_maya_c -lm 2>/dev/null");
        if (compile_result == 0) {
            printf("🔨 Compilation réussie!\n");
            printf("📤 Sortie du programme:\n");
            system("./temp_maya_c");
            // Nettoyer
            system("rm -f temp_maya_c temp_maya_c.c");
            printf("✅ Code C exécuté avec succès!\n");
        } else {
            printf("❌ Erreur de compilation du code C\n");
            system("rm -f temp_maya_c.c");
        }
    }
}

// Nouvelles simulations v5.0
void handle_simulation_monrobot(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.simulation.monrobot - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    printf("🤖 SIMULATION ROBOT PERSONNALISÉ MAYA 🤖\n");
    printf("Paramètres: %s\n", start);

    // Simulation de création de robot
    printf("🔧 Assemblage des composants...\n");
    usleep(800000);
    printf("🧠 Installation de l'IA...\n");
    usleep(600000);
    printf("⚡ Activation des systèmes...\n");
    usleep(400000);

    printf("✅ Robot créé avec succès!\n");
    printf("🗣️ Robot: 'Bonjour! Je suis votre robot personnalisé Maya!'\n");
    printf("🤝 Votre robot est prêt à interagir!\n");
}

void handle_simulation_quantique(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.simulation.quantique - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    printf("⚛️ SIMULATION UNIVERS QUANTIQUE MAYA ⚛️\n");
    printf("Paramètres: %s\n", start);

    printf("🌌 Initialisation de l'univers quantique...\n");
    usleep(1000000);
    printf("⚛️ Création des particules subatomiques...\n");
    usleep(800000);
    printf("🔬 Observation des phénomènes quantiques...\n");
    usleep(600000);

    srand(time(NULL));
    int scenario = rand() % 3;

    switch(scenario) {
        case 0:
            printf("🌟 Superposition quantique détectée!\n");
            printf("📊 État: |0⟩ + |1⟩\n");
            break;
        case 1:
            printf("🔗 Intrication quantique observée!\n");
            printf("📊 Particules liées instantanément\n");
            break;
        case 2:
            printf("🌊 Dualité onde-particule manifeste!\n");
            printf("📊 Comportement ondulatoire confirmé\n");
            break;
    }

    printf("🎯 Simulation quantique terminée!\n");
}

void handle_simulation_monunivers(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.simulation.monunivers - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    printf("🌍 CRÉATION UNIVERS PERSONNALISÉ MAYA 🌍\n");
    printf("Spécifications: %s\n", start);

    printf("💫 Big Bang de votre univers...\n");
    usleep(1200000);
    printf("⭐ Formation des premières étoiles...\n");
    usleep(1000000);
    printf("🪐 Création des planètes...\n");
    usleep(800000);
    printf("🌱 Apparition de la vie...\n");
    usleep(600000);

    printf("🎉 Votre univers est né!\n");
    printf("📊 Statistiques:\n");
    printf("   - 1 000 000 étoiles\n");
    printf("   - 500 000 planètes\n");
    printf("   - 42 civilisations\n");
    printf("🌟 Univers stable et en expansion!\n");
}

void handle_simulation_atomes(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.simulation.atomes - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    // Enlever les guillemets si présents
    if (start[0] == '\'' && start[strlen(start)-1] == '\'') {
        start[strlen(start)-1] = '\0';
        start++;
    }

    printf("⚛️ SIMULATION ATOMIQUE MAYA ⚛️\n");
    printf("Type d'atome: %s\n", start);

    // Base de données des éléments
    struct {
        char *nom;
        char *symbole;
        int protons;
        int neutrons;
        int electrons;
        char *proprietes;
    } elements[] = {
        {"Hydrogene", "H", 1, 0, 1, "Gaz le plus léger, inflammable"},
        {"Helium", "He", 2, 2, 2, "Gaz noble, très stable"},
        {"Lithium", "Li", 3, 4, 3, "Métal alcalin, très réactif"},
        {"Carbone", "C", 6, 6, 6, "Base de la vie organique"},
        {"Azote", "N", 7, 7, 7, "Gaz inerte, 78% de l'atmosphère"},
        {"Oxygene", "O", 8, 8, 8, "Vital pour la respiration"},
        {"Fluor", "F", 9, 10, 9, "Halogène très réactif"},
        {"Neon", "Ne", 10, 10, 10, "Gaz noble, éclairage"},
        {"Sodium", "Na", 11, 12, 11, "Métal alcalin, forme le sel"},
        {"Magnesium", "Mg", 12, 12, 12, "Métal léger, alliages"},
        {"Aluminium", "Al", 13, 14, 13, "Métal léger, anti-corrosion"},
        {"Silicium", "Si", 14, 14, 14, "Semi-conducteur, électronique"},
        {"Phosphore", "P", 15, 16, 15, "Essentiel pour l'ADN"},
        {"Soufre", "S", 16, 16, 16, "Forme des ponts disulfure"},
        {"Chlore", "Cl", 17, 18, 17, "Désinfectant, forme HCl"},
        {"Argon", "Ar", 18, 22, 18, "Gaz noble, soudage"},
        {"Potassium", "K", 19, 20, 19, "Électrolyte important"},
        {"Calcium", "Ca", 20, 20, 20, "Os et dents"},
        {"Fer", "Fe", 26, 30, 26, "Métal de construction"},
        {"Cuivre", "Cu", 29, 35, 29, "Conducteur électrique"},
        {"Zinc", "Zn", 30, 35, 30, "Anti-corrosion, galvanisation"},
        {"Argent", "Ag", 47, 61, 47, "Métal précieux, conducteur"},
        {"Or", "Au", 79, 118, 79, "Métal précieux, inoxydable"},
        {"Mercure", "Hg", 80, 121, 80, "Métal liquide toxique"},
        {"Plomb", "Pb", 82, 125, 82, "Métal lourd toxique"},
        {"Uranium", "U", 92, 146, 92, "Radioactif, énergie nucléaire"}
    };

    int element_count = sizeof(elements) / sizeof(elements[0]);
    int found = -1;

    // Rechercher l'élément
    for (int i = 0; i < element_count; i++) {
        if (strcasecmp(elements[i].nom, start) == 0 || 
            strcasecmp(elements[i].symbole, start) == 0) {
            found = i;
            break;
        }
    }

    if (found == -1) {
        printf("❌ Élément '%s' non trouvé dans la base de données\n", start);
        printf("💡 Éléments disponibles:\n");
        for (int i = 0; i < element_count && i < 10; i++) {
            printf("   - %s (%s)\n", elements[i].nom, elements[i].symbole);
        }
        printf("   ... et %d autres\n", element_count - 10);
        return;
    }

    printf("🔬 Analyse de la structure atomique...\n");
    usleep(600000);
    printf("⚡ Électrons en orbite...\n");
    usleep(400000);
    printf("🎯 Noyau stable détecté...\n");
    usleep(400000);

    printf("📊 RÉSULTATS DE LA SIMULATION:\n");
    printf("   Élément: %s (%s)\n", elements[found].nom, elements[found].symbole);
    printf("   Numéro atomique: %d\n", elements[found].protons);
    printf("   Protons: %d\n", elements[found].protons);
    printf("   Neutrons: %d\n", elements[found].neutrons);
    printf("   Électrons: %d\n", elements[found].electrons);
    printf("   Masse atomique: ~%d u\n", elements[found].protons + elements[found].neutrons);
    printf("   Propriétés: %s\n", elements[found].proprietes);

    // Configuration électronique simplifiée
    printf("   Configuration électronique: ");
    int electrons = elements[found].electrons;
    int shells[] = {2, 8, 18, 32}; // Capacité des couches K, L, M, N
    
    for (int shell = 0; shell < 4 && electrons > 0; shell++) {
        int e_in_shell = (electrons > shells[shell]) ? shells[shell] : electrons;
        printf("%d ", e_in_shell);
        electrons -= e_in_shell;
    }
    printf("\n");

    printf("✅ Simulation atomique terminée!\n");
}

void handle_simulation_timetravel(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.simulation.timetravel - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    int years = evaluate_expression_numeric(start);

    if (years < 1 || years > 15) {
        maya_error("Voyage temporel limité entre 1 et 15 ans", 0);
        return;
    }

    printf("⏰ MACHINE TEMPORELLE MAYA ⏰\n");
    printf("Voyage de %d années\n", years);

    printf("🔧 Calibrage de la machine temporelle...\n");
    usleep(800000);
    printf("⚡ Activation du flux temporel...\n");
    usleep(600000);
    printf("🌀 Traversée du continuum espace-temps...\n");
    usleep(1000000);

    // Générer un événement basé sur le nombre d'années
    if (years <= 5) {
        printf("🎯 ARRIVÉE DANS LE PASSÉ (%d ans):\n", years);
        printf("📱 Les smartphones n'existaient pas encore!\n");
        printf("🎵 La musique était différente...\n");
    } else if (years <= 10) {
        printf("🎯 ARRIVÉE DANS LE PASSÉ (%d ans):\n", years);
        printf("💻 Internet était plus lent!\n");
        printf("🎮 Les jeux vidéo étaient différents!\n");
    } else {
        printf("🎯 ARRIVÉE DANS LE FUTUR (%d ans):\n", years);
        printf("🚗 Les voitures volent!\n");
        printf("🤖 Les robots sont partout!\n");
    }

    printf("✅ Voyage temporel terminé! Retour au présent...\n");
}

void handle_simulation_fairy(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.simulation.fairy - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    printf("🧚‍♀️ CONTE DE FÉE MAYA 🧚‍♀️\n");
    printf("Histoire: %s\n", start);

    printf("📖 Il était une fois, dans un royaume lointain...\n");
    usleep(800000);
    printf("🏰 Une princesse vivait dans un château magique...\n");
    usleep(600000);
    printf("🐉 Un dragon gardait un trésor précieux...\n");
    usleep(600000);
    printf("⚔️ Un brave chevalier décida de sauver le royaume...\n");
    usleep(800000);

    srand(time(NULL));
    int ending = rand() % 3;

    switch(ending) {
        case 0:
            printf("👑 Le chevalier épousa la princesse!\n");
            printf("🎉 Ils vécurent heureux pourtoujours!\n");
            break;
        case 1:
            printf("🐉 Le dragon devint l'ami du chevalier!\n");
            printf("🤝 La paix régna sur le royaume!\n");
            break;
        case 2:
            printf("✨ La princesse révéla être une fée!\n");
            printf("🌟 Elle transforma le royaume en paradis!\n");
            break;
    }

    printf("📚 Fin de votre conte de fée personnalisé!\n");
}

void handle_simulation_vampire(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.simulation.vampire - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    printf("🧛‍♂️ HISTOIRE DE VAMPIRE MAYA 🧛‍♂️\n");
    printf("Récit: %s\n", start);

    printf("🌙 La nuit tombe sur la ville gothique...\n");
    usleep(800000);
    printf("🏰 Dans un château sombre, un vampire s'éveille...\n");
    usleep(600000);
    printf("🦇 Il se transforme en chauve-souris...\n");
    usleep(500000);
    printf("🌃 Il survole la ville à la recherche...\n");
    usleep(700000);

    srand(time(NULL));
    int scenario = rand() % 3;

    switch(scenario) {
        case 0:
            printf("💘 Il rencontre l'amour de sa vie!\n");
            printf("🌹 Une histoire d'amour éternelle commence...\n");
            break;
        case 1:
            printf("⚔️ Il affronte un chasseur de vampires!\n");
            printf("🛡️ Un combat épique s'engage!\n");
            break;
        case 2:
            printf("🧪 Il cherche une potion pour redevenir humain!\n");
            printf("🔬 Une quête mystique commence...\n");
            break;
    }

    printf("🌅 À l'aube, votre histoire de vampire se termine!\n");
}

void handle_simulation_sirene(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.simulation.sirene - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    printf("🧜‍♀️ RÉCIT DE SIRÈNE MAYA 🧜‍♀️\n");
    printf("Histoire: %s\n", start);

    printf("🌊 Dans les profondeurs de l'océan...\n");
    usleep(800000);
    printf("🐚 Une sirène chante sa mélodie enchanteresse...\n");
    usleep(600000);
    printf("🏖️ Un navigateur entend son chant...\n");
    usleep(500000);
    printf("⛵ Son navire se dirige vers les récifs...\n");
    usleep(700000);

    srand(time(NULL));
    int outcome = rand() % 3;

    switch(outcome) {
        case 0:
            printf("💙 La sirène tombe amoureuse du navigateur!\n");
            printf("🌟 Elle le sauve et devient humaine!\n");
            break;
        case 1:
            printf("🔱 Le roi des mers intervient!\n");
            printf("👑 Il accorde un vœu à la sirène!\n");
            break;
        case 2:
            printf("🌈 La sirène découvre un trésor caché!\n");
            printf("💎 Elle devient la gardienne des océans!\n");
            break;
    }

    printf("🐠 Votre récit de sirène se termine dans les vagues!\n");
}

void handle_simulation_monster(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.simulation.monster - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    printf("👹 SIMULATION MONSTRE MAYA 👹\n");
    printf("Créature: %s\n", start);

    printf("🌙 Une nuit d'orage, dans une forêt sombre...\n");
    usleep(800000);
    printf("👁️ Des yeux brillent dans l'obscurité...\n");
    usleep(600000);
    printf("🦶 Des pas lourds résonnent...\n");
    usleep(500000);
    printf("👹 Le monstre apparaît!\n");
    usleep(700000);

    srand(time(NULL));
    int monster_action = rand() % 3;

    switch(monster_action) {
        case 0:
            printf("😢 Le monstre est en réalité seul et triste!\n");
            printf("🤗 Il cherche juste un ami!\n");
            break;
        case 1:
            printf("🏃‍♂️ Le monstre poursuit les villageois!\n");
            printf("⚔️ Les héros se préparent au combat!\n");
            break;
        case 2:
            printf("🔮 Le monstre garde un secret mystique!\n");
            printf("📜 Une ancienne malédiction doit être brisée!\n");
            break;
    }

    printf("🌅 Votre histoire de monstre se termine à l'aube!\n");
}

// Fonctions d'exercices scolaires
void handle_exercice_create(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.exercice.create - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    printf("📚 CRÉATEUR D'EXERCICES MAYA 📚\n");
    printf("Sujet: %s\n", start);
    printf("📝 Exercice personnalisé créé!\n");
    printf("🎯 Utilisez my.input pour les réponses interactives!\n");
    printf("✅ Exercice prêt à être utilisé!\n");
}

// ========== NOUVELLES FONCTIONNALITÉS MAYA v6.0 ==========

// Fonction pour créer des chatbots personnalisés
void handle_create_robot(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.create.robot - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    // Parser les arguments: nom, réponses
    char *comma = strchr(start, ',');
    if (!comma) {
        maya_error("my.create.robot nécessite deux arguments: nom et réponses", 0);
        return;
    }

    *comma = '\0';
    char *robot_name = start;
    char *responses = comma + 1;

    trim(robot_name);
    trim(responses);

    // Enlever les guillemets
    if (robot_name[0] == '\'' && robot_name[strlen(robot_name)-1] == '\'') {
        robot_name[strlen(robot_name)-1] = '\0';
        robot_name++;
    }
    if (responses[0] == '\'' && responses[strlen(responses)-1] == '\'') {
        responses[strlen(responses)-1] = '\0';
        responses++;
    }

    printf("🤖 CRÉATION CHATBOT MAYA v6.0 🤖\n");
    printf("Nom du robot: %s\n", robot_name);
    printf("🧠 Installation de l'intelligence artificielle...\n");
    usleep(800000);
    printf("💬 Configuration des réponses conversationnelles...\n");
    usleep(600000);
    
    // Parser les réponses (format: mot1:réponse1,mot2:réponse2)
    printf("📚 Base de connaissances du robot:\n");
    char *token = strtok(responses, ",");
    int response_count = 0;
    
    while (token != NULL && response_count < 10) {
        char *colon = strchr(token, ':');
        if (colon) {
            *colon = '\0';
            char *keyword = token;
            char *response = colon + 1;
            trim(keyword);
            trim(response);
            printf("   🔹 %s → %s\n", keyword, response);
            response_count++;
        }
        token = strtok(NULL, ",");
    }

    printf("✅ Chatbot '%s' créé avec succès!\n", robot_name);
    printf("🎯 %d réponses programmées\n", response_count);
    printf("🗣️ %s: 'Bonjour! Je suis %s, votre assistant Maya!'\n", robot_name, robot_name);
}

// Fonction pour les boucles for
void handle_for_loop(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.for - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    // Parser les arguments: variable, début, fin
    char *comma1 = strchr(start, ',');
    if (!comma1) {
        maya_error("my.for nécessite trois arguments: variable, début, fin", 0);
        return;
    }

    *comma1 = '\0';
    char *var_name = start;
    char *rest = comma1 + 1;

    char *comma2 = strchr(rest, ',');
    if (!comma2) {
        maya_error("my.for nécessite trois arguments: variable, début, fin", 0);
        return;
    }

    *comma2 = '\0';
    char *debut_str = rest;
    char *fin_str = comma2 + 1;

    trim(var_name);
    trim(debut_str);
    trim(fin_str);

    int debut = evaluate_expression_numeric(debut_str);
    int fin = evaluate_expression_numeric(fin_str);

    printf("🔄 BOUCLE FOR MAYA v6.0 🔄\n");
    printf("Variable: %s, de %d à %d\n", var_name, debut, fin);

    for (int i = debut; i <= fin; i++) {
        printf("   Itération %s = %d\n", var_name, i);
        // Stocker la variable pour utilisation ultérieure
        char value_str[20];
        sprintf(value_str, "%d", i);
        set_variable(var_name, value_str, 1);
        usleep(200000); // Petite pause pour visualiser
    }

    printf("✅ Boucle for terminée!\n");
}

// Fonction pour les boucles while
void handle_while_loop(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.while - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    printf("🔄 BOUCLE WHILE MAYA v6.0 🔄\n");
    printf("Condition: %s\n", start);

    int iterations = 0;
    int max_iterations = 100; // Sécurité contre boucles infinies

    while (handle_condition(start) && iterations < max_iterations) {
        printf("   Itération %d - Condition vraie\n", iterations + 1);
        iterations++;
        usleep(300000);
        
        // Mise à jour simple pour éviter boucle infinie
        if (strstr(start, "x") && iterations == 1) {
            set_variable("x", "1", 1);
        }
    }

    if (iterations >= max_iterations) {
        printf("⚠️ Boucle arrêtée pour éviter l'infini (%d itérations max)\n", max_iterations);
    } else {
        printf("✅ Boucle while terminée après %d itérations\n", iterations);
    }
}

// Fonction pour les boucles simples
void handle_loop(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.loop - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    int repetitions = evaluate_expression_numeric(start);

    printf("🔄 BOUCLE SIMPLE MAYA v6.0 🔄\n");
    printf("Nombre de répétitions: %d\n", repetitions);

    for (int i = 1; i <= repetitions; i++) {
        printf("   🔁 Exécution %d/%d\n", i, repetitions);
        usleep(400000);
    }

    printf("✅ Boucle simple terminée!\n");
}

// Fonction pour les palettes créatives
void handle_palette(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.palette - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    // Parser les arguments: dessin, couleur
    char *comma = strchr(start, ',');
    if (!comma) {
        maya_error("my.palette nécessite deux arguments: dessin et couleur", 0);
        return;
    }

    *comma = '\0';
    char *dessin = start;
    char *couleur = comma + 1;

    trim(dessin);
    trim(couleur);

    // Enlever les guillemets
    if (dessin[0] == '\'' && dessin[strlen(dessin)-1] == '\'') {
        dessin[strlen(dessin)-1] = '\0';
        dessin++;
    }
    if (couleur[0] == '\'' && couleur[strlen(couleur)-1] == '\'') {
        couleur[strlen(couleur)-1] = '\0';
        couleur++;
    }

    printf("🎨 PALETTE CRÉATIVE MAYA v6.0 🎨\n");
    printf("Création: %s en %s\n", dessin, couleur);

    // Appliquer la couleur
    apply_color(couleur);

    if (strcmp(dessin, "mouton") == 0) {
        printf("    🐑\n");
        printf("   (  o.o)\n");
        printf("    > ^ <\n");
        printf("   /_____\\\n");
        printf("🐑 Mouton %s créé!\n", couleur);
    }
    else if (strcmp(dessin, "oiseau") == 0) {
        printf("     🐦\n");
        printf("    <(^v^)>\n");
        printf("     /|\\\n");
        printf("    /   \\\n");
        printf("🐦 Oiseau %s créé!\n", couleur);
    }
    else if (strcmp(dessin, "abeille") == 0) {
        printf("     🐝\n");
        printf("   .-\"\"\"-.  \n");
        printf("  /       \\\n");
        printf(" | o     o |\n");
        printf("  \\   ∩   /\n");
        printf("   '-...-'\n");
        printf("🐝 Abeille %s créée!\n", couleur);
    }
    else if (strcmp(dessin, "dragon") == 0) {
        printf("     🐉\n");
        printf("    /~\\\n");
        printf("   (  o.o )\n");
        printf("    > ^ <\n");
        printf("   /_____\\\n");
        printf("🐉 Dragon %s créé!\n", couleur);
    }
    else {
        printf("✨ Dessin personnalisé '%s' en %s\n", dessin, couleur);
        printf("🎨 [Votre imagination prend forme!]\n");
    }

    reset_color();
    printf("🌈 Création artistique terminée!\n");
}

// Fonction pour créer des jeux personnalisés
void handle_owngame(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.owngame - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    // Enlever les guillemets
    if (start[0] == '\'' && start[strlen(start)-1] == '\'') {
        start[strlen(start)-1] = '\0';
        start++;
    }

    printf("🎮 CRÉATEUR DE JEUX MAYA v6.0 🎮\n");
    printf("Concept de jeu: %s\n", start);

    printf("🔧 Génération du moteur de jeu...\n");
    usleep(800000);
    printf("🎨 Création des graphismes ASCII...\n");
    usleep(600000);
    printf("🎵 Composition de la bande sonore...\n");
    usleep(500000);
    printf("🎯 Programmation de la logique de jeu...\n");
    usleep(700000);

    printf("🌟 ===== VOTRE JEU PERSONNALISÉ ===== 🌟\n");
    printf("Titre: %s\n", start);
    printf("Genre: Aventure Maya Interactive\n");
    printf("Joueurs: 1-∞\n");
    printf("Difficulté: Ajustable\n");
    printf("\n🎲 COMMANDES DU JEU:\n");
    printf("   [W] - Avancer\n");
    printf("   [S] - Reculer\n");
    printf("   [A] - Gauche\n");
    printf("   [D] - Droite\n");
    printf("   [E] - Interagir\n");
    printf("   [I] - Inventaire\n");
    printf("   [Q] - Quitter\n");

    printf("\n🏆 OBJECTIFS:\n");
    printf("   - Explorez le monde de Maya\n");
    printf("   - Résolvez les énigmes\n");
    printf("   - Collectez les trésors\n");
    printf("   - Devenez le maître du code!\n");

    printf("\n✅ Jeu '%s' créé avec succès!\n", start);
    printf("🎮 Prêt à jouer! Que l'aventure commence!\n");
}

// Fonction pour modifier la console dynamiquement
void handle_modifie_console(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.modifie.console - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    // Parser les arguments: message_original, délai, message_modifié
    char *comma1 = strchr(start, ',');
    if (!comma1) {
        maya_error("my.modifie.console nécessite trois arguments", 0);
        return;
    }

    *comma1 = '\0';
    char *message_original = start;
    char *rest = comma1 + 1;

    char *comma2 = strchr(rest, ',');
    if (!comma2) {
        maya_error("my.modifie.console nécessite trois arguments", 0);
        return;
    }

    *comma2 = '\0';
    char *delai_str = rest;
    char *message_modifie = comma2 + 1;

    trim(message_original);
    trim(delai_str);
    trim(message_modifie);

    // Enlever les guillemets
    if (message_original[0] == '\'' && message_original[strlen(message_original)-1] == '\'') {
        message_original[strlen(message_original)-1] = '\0';
        message_original++;
    }
    if (message_modifie[0] == '\'' && message_modifie[strlen(message_modifie)-1] == '\'') {
        message_modifie[strlen(message_modifie)-1] = '\0';
        message_modifie++;
    }

    int delai = evaluate_expression_numeric(delai_str);

    printf("💬 MODIFICATION CONSOLE MAYA v6.0 💬\n");
    printf("%s", message_original);
    fflush(stdout);

    // Attendre le délai
    usleep(delai * 1000);

    // Effacer la ligne précédente et afficher le nouveau message
    printf("\r\033[K%s\n", message_modifie);
    printf("✅ Modification console terminée!\n");
}

// Fonction pour créer des menus interactifs
void handle_interactive(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.interactive - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    // Enlever les guillemets
    if (start[0] == '\'' && start[strlen(start)-1] == '\'') {
        start[strlen(start)-1] = '\0';
        start++;
    }

    printf("📋 MENU INTERACTIF MAYA v6.0 📋\n");
    printf("╔══════════════════════════════════════╗\n");
    printf("║            %s            ║\n", start);
    printf("╠══════════════════════════════════════╣\n");
    printf("║  [1] 🎮 Jouer                        ║\n");
    printf("║  [2] ⚙️  Options                     ║\n");
    printf("║  [3] 📊 Statistiques                 ║\n");
    printf("║  [4] 🎨 Personnalisation             ║\n");
    printf("║  [5] 💾 Sauvegarder                  ║\n");
    printf("║  [6] 📚 Aide                         ║\n");
    printf("║  [7] 🚪 Quitter                      ║\n");
    printf("╚══════════════════════════════════════╝\n");
    printf("👆 Choisissez une option (1-7): ");

    char choice[10];
    if (fgets(choice, sizeof(choice), stdin)) {
        int option = atoi(choice);
        switch(option) {
            case 1:
                printf("🎮 Lancement du jeu...\n");
                break;
            case 2:
                printf("⚙️ Menu des options ouvert\n");
                break;
            case 3:
                printf("📊 Affichage des statistiques\n");
                break;
            case 4:
                printf("🎨 Menu de personnalisation\n");
                break;
            case 5:
                printf("💾 Sauvegarde en cours...\n");
                break;
            case 6:
                printf("📚 Aide Maya v6.0 affichée\n");
                break;
            case 7:
                printf("🚪 Merci d'avoir utilisé Maya!\n");
                break;
            default:
                printf("❌ Option invalide\n");
        }
    }
    printf("✅ Menu interactif terminé!\n");
}

// Système d'inventaire dynamique avec gestion complexe
typedef struct {
    char nom[50];
    char type[30];
    char description[100];
    int quantite;
    int actif;
} InventaireItem;

static InventaireItem inventaire_maya[50];
static int inventaire_count = 0;

void handle_inventaire(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        // Si pas de parenthèses, c'est un affichage simple
        printf("🎒 INVENTAIRE MAYA v6.0 🎒\n");
        printf("════════════════════════════════════\n");
        
        if (inventaire_count == 0) {
            printf("Inventaire vide\n");
        } else {
            for (int i = 0; i < inventaire_count; i++) {
                if (inventaire_maya[i].actif) {
                    printf("[%d] %s (%s) x%d\n", i+1, 
                           inventaire_maya[i].nom,
                           inventaire_maya[i].type,
                           inventaire_maya[i].quantite);
                    printf("    Description: %s\n", inventaire_maya[i].description);
                }
            }
        }
        printf("════════════════════════════════════\n");
        return;
    }

    start++;
    *end = '\0';

    // Parser les arguments
    char *args[4];
    int arg_count = 0;
    char *token = strtok(start, ",");
    
    while (token != NULL && arg_count < 4) {
        trim(token);
        if (token[0] == '\'' && token[strlen(token)-1] == '\'') {
            token[strlen(token)-1] = '\0';
            token++;
        }
        args[arg_count] = strdup(token);
        arg_count++;
        token = strtok(NULL, ",");
    }

    if (arg_count < 2) {
        maya_error("my.inventaire nécessite au moins action et nom", 0);
        return;
    }

    char *action = args[0];
    char *nom = args[1];

    printf("🎒 INVENTAIRE MAYA v6.0 - %s 🎒\n", action);

    if (strcmp(action, "ajouter") == 0) {
        if (arg_count < 4) {
            maya_error("ajouter nécessite: nom, type, description", 0);
            return;
        }

        char *type = args[2];
        char *description = args[3];

        if (inventaire_count < 50) {
            strcpy(inventaire_maya[inventaire_count].nom, nom);
            strcpy(inventaire_maya[inventaire_count].type, type);
            strcpy(inventaire_maya[inventaire_count].description, description);
            inventaire_maya[inventaire_count].quantite = 1;
            inventaire_maya[inventaire_count].actif = 1;
            inventaire_count++;

            printf("✅ %s ajouté à l'inventaire!\n", nom);
            printf("Type: %s\n", type);
            printf("Description: %s\n", description);
        } else {
            printf("❌ Inventaire plein!\n");
        }
    }
    else if (strcmp(action, "utiliser") == 0) {
        int trouve = 0;
        for (int i = 0; i < inventaire_count; i++) {
            if (inventaire_maya[i].actif && strcmp(inventaire_maya[i].nom, nom) == 0) {
                printf("⚡ Utilisation de: %s\n", nom);
                printf("📝 %s\n", inventaire_maya[i].description);
                
                inventaire_maya[i].quantite--;
                if (inventaire_maya[i].quantite <= 0) {
                    inventaire_maya[i].actif = 0;
                    printf("💨 %s consommé et retiré de l'inventaire\n", nom);
                } else {
                    printf("📦 Quantité restante: %d\n", inventaire_maya[i].quantite);
                }
                trouve = 1;
                break;
            }
        }
        if (!trouve) {
            printf("❌ %s non trouvé dans l'inventaire\n", nom);
        }
    }
    else if (strcmp(action, "supprimer") == 0) {
        int trouve = 0;
        for (int i = 0; i < inventaire_count; i++) {
            if (inventaire_maya[i].actif && strcmp(inventaire_maya[i].nom, nom) == 0) {
                inventaire_maya[i].actif = 0;
                printf("🗑️ %s supprimé de l'inventaire\n", nom);
                trouve = 1;
                break;
            }
        }
        if (!trouve) {
            printf("❌ %s non trouvé dans l'inventaire\n", nom);
        }
    }
    else {
        printf("❌ Action non reconnue: %s\n", action);
        printf("Actions disponibles: ajouter, utiliser, supprimer\n");
    }

    // Libérer la mémoire
    for (int i = 0; i < arg_count; i++) {
        free(args[i]);
    }
}

// Fonction pour les récits d'histoires
void handle_histoire_recit(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.histoire.recit - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    // Enlever les guillemets
    if (start[0] == '\'' && start[strlen(start)-1] == '\'') {
        start[strlen(start)-1] = '\0';
        start++;
    }

    printf("📖 RÉCIT MAYA v6.0 📖\n");
    printf("\033[95m"); // Couleur rose pour les histoires
    printf("════════════════════════════════════════════════════════════════\n");
    printf("                          📚 HISTOIRE 📚\n");
    printf("════════════════════════════════════════════════════════════════\n");
    printf("\n");
    
    // Affichage avec effet de machine à écrire
    for (size_t i = 0; i < strlen(start); i++) {
        printf("%c", start[i]);
        fflush(stdout);
        usleep(50000); // 50ms entre chaque caractère
    }
    
    printf("\n\n");
    printf("════════════════════════════════════════════════════════════════\n");
    printf("\033[0m"); // Reset couleur
    printf("✨ Histoire racontée avec la magie de Maya!\n");
}

// Fonction pour les fins d'histoires
void handle_histoire_end(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.histoire.end - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    // Enlever les guillemets
    if (start[0] == '\'' && start[strlen(start)-1] == '\'') {
        start[strlen(start)-1] = '\0';
        start++;
    }

    printf("🎬 FIN DE L'HISTOIRE MAYA v6.0 🎬\n");
    printf("\033[31m"); // Couleur rouge pour la fin
    printf("╔══════════════════════════════════════════════════════════════╗\n");
    printf("║                        🎭 ÉPILOGUE 🎭                        ║\n");
    printf("╠══════════════════════════════════════════════════════════════╣\n");
    printf("║                                                              ║\n");
    
    // Centrer le texte
    int text_len = strlen(start);
    int padding = (62 - text_len) / 2;
    printf("║");
    for (int i = 0; i < padding; i++) printf(" ");
    printf("%s", start);
    for (int i = 0; i < (62 - text_len - padding); i++) printf(" ");
    printf("║\n");
    
    printf("║                                                              ║\n");
    printf("╚══════════════════════════════════════════════════════════════╝\n");
    printf("\033[0m"); // Reset couleur
    
    printf("\n🌟 THE END 🌟\n");
    printf("👏 Bravo! Histoire terminée avec panache!\n");
    printf("📚 Merci d'avoir utilisé le conteur Maya v6.0!\n");
}

// Fonction pour créer des animaux personnalisés
void handle_own_pet(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.own.pet - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    // Enlever les guillemets
    if (start[0] == '\'' && start[strlen(start)-1] == '\'') {
        start[strlen(start)-1] = '\0';
        start++;
    }

    printf("🐾 CRÉATION D'ANIMAL PERSONNALISÉ MAYA v6.0 🐾\n");
    printf("Histoire de l'animal: %s\n", start);

    printf("🧬 Génération de l'ADN unique...\n");
    usleep(800000);
    printf("🎨 Création de l'apparence...\n");
    usleep(600000);
    printf("🧠 Développement de la personnalité...\n");
    usleep(500000);
    printf("⚡ Insufflation de la vie...\n");
    usleep(700000);

    // Générer des caractéristiques aléatoires
    srand(time(NULL));
    char *couleurs[] = {"Doré", "Argenté", "Cristallin", "Arc-en-ciel", "Étoilé", "Mystique"};
    char *tailles[] = {"Minuscule", "Petit", "Moyen", "Grand", "Gigantesque", "Légendaire"};
    char *pouvoirs[] = {"Télépathie", "Vol", "Invisibilité", "Téléportation", "Magie", "Sagesse infinie"};

    int couleur_idx = rand() % 6;
    int taille_idx = rand() % 6;
    int pouvoir_idx = rand() % 6;

    printf("✨ VOTRE ANIMAL PERSONNALISÉ EST NÉ! ✨\n");
    printf("═══════════════════════════════════════\n");
    printf("🏷️  Histoire: %s\n", start);
    printf("🌈 Couleur: %s\n", couleurs[couleur_idx]);
    printf("📏 Taille: %s\n", tailles[taille_idx]);
    printf("⚡ Pouvoir: %s\n", pouvoirs[pouvoir_idx]);
    printf("❤️  Niveau d'affection: ∞\n");
    printf("🍃 Habitat: Monde de Maya\n");
    printf("🎵 Cri: *Sons magiques indescriptibles*\n");
    printf("═══════════════════════════════════════\n");
    printf("🐾 Votre compagnon Maya est prêt à vous accompagner dans vos aventures!\n");
}

// Fonction pour créer des titans personnalisés
void handle_own_titan(char *line) {
    char *start = strchr(line, '(');
    char *end = strrchr(line, ')');

    if (!start || !end) {
        maya_error("Syntaxe incorrecte pour my.own.titan - parenthèses manquantes", 0);
        return;
    }

    start++;
    *end = '\0';

    // Enlever les guillemets
    if (start[0] == '\'' && start[strlen(start)-1] == '\'') {
        start[strlen(start)-1] = '\0';
        start++;
    }

    printf("⚡ CRÉATION DE TITAN LÉGENDAIRE MAYA v6.0 ⚡\n");
    printf("Légende du titan: %s\n", start);

    printf("🌋 Éveil des forces primordiales...\n");
    usleep(1000000);
    printf("⚡ Forge du corps titanesque...\n");
    usleep(800000);
    printf("🔥 Allumage de l'âme immortelle...\n");
    usleep(600000);
    printf("👑 Couronnement du pouvoir ultime...\n");
    usleep(900000);

    // Générer des caractéristiques épiques
    srand(time(NULL));
    char *elements[] = {"Foudre", "Lave", "Glace Éternelle", "Vent Cosmique", "Terre Sacrée", "Lumière Pure"};
    char *armes[] = {"Épée Dimensionnelle", "Marteau des Mondes", "Arc Stellaire", "Bâton du Temps", "Griffes d'Éternité", "Livre des Sorts"};
    char *domaines[] = {"Montagnes Flottantes", "Océan de Magma", "Forêt Cristalline", "Désert de Sable d'Or", "Ville des Nuages", "Royaume des Codes"};

    int element_idx = rand() % 6;
    int arme_idx = rand() % 6;
    int domaine_idx = rand() % 6;
    int puissance = 9000 + rand() % 1000;

    printf("👑 VOTRE TITAN LÉGENDAIRE S'ÉLÈVE! 👑\n");
    printf("═══════════════════════════════════════════════════\n");
    printf("📜 Légende: %s\n", start);
    printf("🌟 Élément: %s\n", elements[element_idx]);
    printf("⚔️  Arme: %s\n", armes[arme_idx]);
    printf("🏰 Domaine: %s\n", domaines[domaine_idx]);
    printf("💪 Niveau de puissance: %d\n", puissance);
    printf("⏳ Âge: Depuis l'aube des temps\n");
    printf("🎯 Mission: Protéger l'univers Maya\n");
    printf("💀 Ennemis vaincus: Innombrables\n");
    printf("═══════════════════════════════════════════════════\n");
    printf("⚡ Le titan %s domine désormais l'univers Maya!\n", start);
}

// Fonction pour générer des statistiques d'animaux
void handle_nombre_pet(char *line) {
    (void)line; // Pas de paramètres

    printf("🐾 GÉNÉRATEUR DE STATS D'ANIMAUX MAYA v6.0 🐾\n");

    srand(time(NULL));
    
    // Générer des statistiques d'animal
    int vie = 50 + rand() % 150;
    int force = 20 + rand() % 80;
    int vitesse = 30 + rand() % 70;
    int intelligence = 40 + rand() % 60;
    int magie = 10 + rand() % 90;
    int loyaute = 70 + rand() % 30;

    printf("📊 STATISTIQUES GÉNÉRÉES:\n");
    printf("════════════════════════════\n");
    printf("❤️  Points de Vie: %d\n", vie);
    printf("💪 Force: %d\n", force);
    printf("💨 Vitesse: %d\n", vitesse);
    printf("🧠 Intelligence: %d\n", intelligence);
    printf("✨ Pouvoir Magique: %d\n", magie);
    printf("💖 Loyauté: %d\n", loyaute);
    printf("════════════════════════════\n");
    
    // Calcul du score total
    int total = vie + force + vitesse + intelligence + magie + loyaute;
    printf("🏆 Score Total: %d points\n", total);
    
    if (total > 400) {
        printf("⭐ RANG: Légendaire!\n");
    } else if (total > 300) {
        printf("🌟 RANG: Épique!\n");
    } else if (total > 200) {
        printf("✨ RANG: Rare!\n");
    } else {
        printf("💫 RANG: Commun\n");
    }
    
    printf("🎯 Animal généré avec succès!\n");
}

// Fonction pour générer des statistiques de titans
void handle_nombre_titan(char *line) {
    (void)line; // Pas de paramètres

    printf("⚡ GÉNÉRATEUR DE STATS DE TITANS MAYA v6.0 ⚡\n");

    srand(time(NULL));
    
    // Générer des statistiques épiques
    int puissance = 5000 + rand() % 5000;
    int defense = 3000 + rand() % 4000;
    int vitesse = 1000 + rand() % 3000;
    int magie = 4000 + rand() % 6000;
    int sagesse = 2000 + rand() % 8000;
    int destruction = 6000 + rand() % 4000;

    printf("📊 STATISTIQUES TITANESQUES:\n");
    printf("════════════════════════════════════\n");
    printf("💥 Puissance Destructrice: %d\n", puissance);
    printf("🛡️  Défense Absolue: %d\n", defense);
    printf("⚡ Vitesse Cosmique: %d\n", vitesse);
    printf("🌟 Magie Primordiale: %d\n", magie);
    printf("📚 Sagesse Éternelle: %d\n", sagesse);
    printf("💀 Capacité de Destruction: %d\n", destruction);
    printf("════════════════════════════════════\n");
    
    // Calcul du score épique
    int total = (puissance + defense + vitesse + magie + sagesse + destruction) / 100;
    printf("👑 Score Titanesque: %d points\n", total);
    
    if (total > 250) {
        printf("🌌 CLASSE: Titan Universel!\n");
        printf("🎯 Capable de créer et détruire des galaxies!\n");
    } else if (total > 200) {
        printf("🔥 CLASSE: Titan Légendaire!\n");
        printf("🎯 Maître de plusieurs dimensions!\n");
    } else if (total > 150) {
        printf("⚡ CLASSE: Titan Épique!\n");
        printf("🎯 Gardien de mondes entiers!\n");
    } else {
        printf("💪 CLASSE: Titan Guerrier!\n");
        printf("🎯 Protecteur de civilisations!\n");
    }
    
    printf("👑 Titan généré avec une puissance divine!\n");
}

void handle_exercice_gest_pgi(char *line) {
    (void)line; // Marquer le paramètre comme volontairement inutilisé

    printf("💼 EXERCICE PGI MAYA - BAC STMG 💼\n");
    printf("📊 Progiciel de Gestion Intégrée\n");
    printf("❓ Question: Quels sont les modules d'un PGI?\n");
    printf("💡 Réponse attendue: Comptabilité, RH, Ventes, Stocks, etc.\n");
    printf("🎓 Niveau: Terminale STMG\n");
}

void handle_exercice_gest_treso(char *line) {
    (void)line; // Marquer le paramètre comme volontairement inutilisé

    printf("💰 EXERCICE TRÉSORERIE MAYA - BAC STMG 💰\n");
    printf("📈 Gestion financière\n");
    printf("❓ Calculez: FRNG = Capitaux permanents - Actif immobilisé\n");
    printf("❓ BFR = Actif circulant - Passif circulant\n");
    printf("❓ Trésorerie = FRNG - BFR\n");
    printf("🎓 Exercice de gestion niveau BAC STMG\n");
}

void handle_exercice_math(char *line) {
    (void)line; // Marquer le paramètre comme volontairement inutilisé

    printf("🔢 EXERCICE MATHÉMATIQUES MAYA 🔢\n");
    printf("📐 Mathématiques BAC Général/STMG\n");
    printf("❓ Question: Résolvez l'équation du second degré\n");
    printf("📝 ax² + bx + c = 0\n");
    printf("💡 Utilisez Δ = b² - 4ac\n");
    printf("🎓 Niveau: Première/Terminale\n");
}

void handle_exercice_histoire(char *line) {
    (void)line; // Marquer le paramètre comme volontairement inutilisé

    printf("🏛️ EXERCICE HISTOIRE-GÉO MAYA 🏛️\n");
    printf("🌍 Histoire-Géographie\n");
    printf("❓ Question: Quelles sont les causes de la Première Guerre mondiale?\n");
    printf("📚 Thèmes: Nationalisme, impérialisme, alliances\n");
    printf("🎓 Niveau: BAC Général/STMG\n");
}

void handle_exercice_mana(char *line) {
    (void)line; // Marquer le paramètre comme volontairement inutilisé

    printf("👔 EXERCICE MANAGEMENT MAYA - BAC STMG 👔\n");
    printf("🏢 Sciences de gestion et management\n");
    printf("❓ Question: Définissez les styles de management\n");
    printf("💼 Réponses: Directif, Persuasif, Participatif, Délégatif\n");
    printf("🎓 Niveau: Terminale STMG\n");
}

// Fonction principale pour interpréter une ligne
void interpret_line(char *line) {
    trim(line);

    if (strlen(line) == 0 || line[0] == '#') return; // Ligne vide ou commentaire

    // Gestion des blocs my.alors et my.autre
    if (strchr(line, '{')) {
        if (strstr(line, "my.alors")) {
            in_alors_block = 1;
            in_autre_block = 0;
            skip_current_block = !last_condition_result;
            return;
        } else if (strstr(line, "my.autre")) {
            in_alors_block = 0;
            in_autre_block = 1;
            skip_current_block = last_condition_result;
            return;
        }
    }

    // Fin de bloc
    if (strchr(line, '}')) {
        in_alors_block = 0;
        in_autre_block = 0;
        skip_current_block = 0;
        return;
    }

    // Si on est dans un bloc à ignorer, ne pas exécuter
    if (skip_current_block) {
        return;
    }

    // Structure modulaire pour faciliter l'ajout de nouvelles fonctionnalités
    if (strstr(line, "my.console")) {
        handle_console(line);
    }
    else if (strstr(line, "my.math.median")) {
        handle_math_median(line);
    }
    else if (strstr(line, "my.math.moyenne")) {
        handle_math_moyenne(line);
    }
    else if (strstr(line, "my.math.cube")) {
        handle_math_cube(line);
    }
    else if (strstr(line, "my.math.carre")) {
        handle_math_carre(line);
    }
    else if (strstr(line, "my.math.racine")) {
        handle_math_racine(line);
    }
    else if (strstr(line, "my.math.degres")) {
        handle_math_degres(line);
    }
    else if (strstr(line, "my.math")) {
        handle_math(line);
    }
    else if (strstr(line, "my.thales")) {
        handle_thales(line);
    }
    else if (strstr(line, "my.pytha")) {
        handle_pytha(line);
    }
    else if (strstr(line, "my.rythme.convertir")) {
        handle_rythme_convertir(line);
    }
    else if (strstr(line, "my.renvoie.gamme")) {
        handle_renvoie_gamme(line);
    }
    else if (strstr(line, "my.obtenir.gamme")) {
        handle_obtenir_gamme(line);
    }
    else if (strstr(line, "my.send.db")) {
        handle_send_db(line);
    }
    else if (strstr(line, "my.supp.db")) {
        handle_supp_db(line);
    }
    else if (strstr(line, "my.util.db")) {
        handle_util_db(line);
    }
    else if (strstr(line, "my.db")) {
        handle_db(line);
    }
    else if (strstr(line, "my.execute.c")) {
        handle_execute_c(line);
    }
    else if (strstr(line, "my.variable")) {
        handle_variable(line);
    }
    else if (strstr(line, "my.input")) {
        handle_input(line);
    }
    else if (strstr(line, "my.delai")) {
        handle_delai(line);
    }
    else if (strstr(line, "my.draw")) {
        handle_draw(line);
    }
    else if (strstr(line, "my.jolie.txt")) {
        handle_jolie_txt(line);
    }
    else if (strstr(line, "my.color.console")) {
        handle_color_console(line);
    }
    else if (strstr(line, "my.nombre.random")) {
        handle_nombre_random(line);
    }
    else if (strstr(line, "my.random.txt")) {
        handle_random_txt(line);
    }
    else if (strstr(line, "my.quizz")) {
        handle_quizz(line);
    }
    else if (strstr(line, "my.dice")) {
        handle_dice(line);
    }
    else if (strstr(line, "my.puissance4")) {
        handle_puissance4(line);
    }
    else if (strstr(line, "my.pendu")) {
        handle_pendu(line);
    }
    else if (strstr(line, "my.worldgame")) {
        handle_worldgame(line);
    }
    else if (strstr(line, "my.rock.leaf")) {
        handle_rock_leaf(line);
    }
    else if (strstr(line, "my.devine.number")) {
        handle_devine_number(line);
    }
    else if (strstr(line, "my.snake")) {
        handle_snake(line);
    }
    else if (strstr(line, "my.tictac")) {
        handle_tictac(line);
    }
    else if (strstr(line, "my.memory")) {
        handle_memory(line);
    }
    else if (strstr(line, "my.simulation.bac")) {
        handle_simulation_bac(line);
    }
    else if (strstr(line, "my.simulation.combat")) {
        handle_simulation_combat(line);
    }
    else if (strstr(line, "my.simulation.sciences")) {
        handle_simulation_sciences(line);
    }
    else if (strstr(line, "my.simulation.clone")) {
        handle_simulation_clone(line);
    }
    else if (strstr(line, "my.simulation.tech")) {
        handle_simulation_tech(line);
    }
    else if (strstr(line, "my.simulation.ia")) {
        handle_simulation_ia(line);
    }
    else if (strstr(line, "my.simulation.conscient")) {
        handle_simulation_conscient(line);
    }
    else if (strstr(line, "my.simulation.iawork")) {
        handle_simulation_iawork(line);
    }
    else if (strstr(line, "my.simulation.monrobot")) {
        handle_simulation_monrobot(line);
    }
    else if (strstr(line, "my.simulation.quantique")) {
        handle_simulation_quantique(line);
    }
    else if (strstr(line, "my.simulation.monunivers")) {
        handle_simulation_monunivers(line);
    }
    else if (strstr(line, "my.simulation.atomes")) {
        handle_simulation_atomes(line);
    }
    else if (strstr(line, "my.simulation.timetravel")) {
        handle_simulation_timetravel(line);
    }
    else if (strstr(line, "my.simulation.fairy")) {
        handle_simulation_fairy(line);
    }
    else if (strstr(line, "my.simulation.vampire")) {
        handle_simulation_vampire(line);
    }
    else if (strstr(line, "my.simulation.sirene")) {
        handle_simulation_sirene(line);
    }
    else if (strstr(line, "my.simulation.monster")) {
        handle_simulation_monster(line);
    }
    else if (strstr(line, "my.exercice.gest.pgi")) {
        handle_exercice_gest_pgi(line);
    }
    else if (strstr(line, "my.exercice.gest.treso")) {
        handle_exercice_gest_treso(line);
    }
    else if (strstr(line, "my.exercice.math")) {
        handle_exercice_math(line);
    }
    else if (strstr(line, "my.exercice.histoire")) {
        handle_exercice_histoire(line);
    }
    else if (strstr(line, "my.exercice.mana")) {
        handle_exercice_mana(line);
    }
    else if (strstr(line, "my.exercice.create")) {
        handle_exercice_create(line);
    }
    // Nouvelles fonctionnalités v6.0
    else if (strstr(line, "my.create.robot")) {
        handle_create_robot(line);
    }
    else if (strstr(line, "my.for")) {
        handle_for_loop(line);
    }
    else if (strstr(line, "my.while")) {
        handle_while_loop(line);
    }
    else if (strstr(line, "my.loop")) {
        handle_loop(line);
    }
    else if (strstr(line, "my.palette")) {
        handle_palette(line);
    }
    else if (strstr(line, "my.owngame")) {
        handle_owngame(line);
    }
    else if (strstr(line, "my.modifie.console")) {
        handle_modifie_console(line);
    }
    else if (strstr(line, "my.interactive")) {
        handle_interactive(line);
    }
    else if (strstr(line, "my.inventaire")) {
        handle_inventaire(line);
    }
    else if (strstr(line, "my.histoire.recit")) {
        handle_histoire_recit(line);
    }
    else if (strstr(line, "my.histoire.end")) {
        handle_histoire_end(line);
    }
    else if (strstr(line, "my.own.pet")) {
        handle_own_pet(line);
    }
    else if (strstr(line, "my.own.titan")) {
        handle_own_titan(line);
    }
    else if (strstr(line, "my.nombre.pet")) {
        handle_nombre_pet(line);
    }
    else if (strstr(line, "my.nombre.titan")) {
        handle_nombre_titan(line);
    }
    else if (strstr(line, "my.fonction")) {
        handle_fonction(line);
    }
    else if (strstr(line, "my.lire.module")) {
        handle_lire_module(line);
    }
    else if (strstr(line, "my.package.charge")) {
        handle_package_charge(line);
    }
    else if (strstr(line, "my.if")) {
        // Traitement des conditions
        char *start = strchr(line, '(');
        char *end = strrchr(line, ')');
        if (!start || !end) {
            maya_error("Syntaxe incorrecte pour condition - parenthèses manquantes", 0);
            return;
        }

        start++;
        *end = '\0';

        if (strlen(start) == 0) {
            maya_error("Condition vide", 0);
            return;
        }

        last_condition_result = handle_condition(start);
    }
    else if (strstr(line, "my.alors") || strstr(line, "my.autre")) {
        // Ces lignes sont gérées plus haut
        return;
    }
    else if (strstr(line, "may.")) {
        // Gestion améliorée des fonctions réutilisables et packages C
        char line_copy[MAX_LINE_LENGTH];
        strcpy(line_copy, line);

        char *paren = strchr(line_copy, '(');
        char *func_name = line_copy;
        char *args = "";

        if (paren) {
            *paren = '\0';
            args = paren + 1;
            char *end_paren = strrchr(args, ')');
            if (end_paren) *end_paren = '\0';
        }

        trim(func_name);

        printf("🔍 Recherche de la fonction: %s\n", func_name);

        // Convertir le nom de fonction Maya vers le nom C
        char c_func_name[MAX_VAR_NAME];
        strcpy(c_func_name, func_name);

        // Remplacer les points par des underscores pour les fonctions C
        for (int i = 0; c_func_name[i]; i++) {
            if (c_func_name[i] == '.') {
                c_func_name[i] = '_';
            }
        }

        printf("🔧 Nom C converti: %s\n", c_func_name);

        // Essayer d'abord les fonctions de packages C
        if (find_package_function(c_func_name) != -1) {
            printf("📦 Fonction trouvée dans package C\n");
            call_package_function(c_func_name, args);
        }
        // Sinon, essayer les fonctions Maya réutilisables
        else if (find_maya_function(func_name) != -1) {
            printf("🌟 Fonction Maya réutilisable trouvée\n");
            execute_maya_function(func_name, args);
        }
        else {
            printf("❌ Fonction introuvable: %s\n", func_name);
            printf("📋 Fonctions disponibles:\n");

            // Lister les fonctions de packages
            printf("   🅒 Packages C:\n");
            for (int i = 0; i < maya_package_count; i++) {
                if (maya_packages[i].loaded) {
                    for (int j = 0; j < maya_packages[i].function_count; j++) {
                        printf("      - %s\n", maya_packages[i].function_names[j]);
                    }
                }
            }

            // Lister les fonctions Maya
            printf("   🌟 Fonctions Maya:\n");
            for (int i = 0; i < maya_function_count; i++) {
                printf("      - %s\n", maya_functions[i].name);
            }

            if (maya_package_count == 0 && maya_function_count == 0) {
                printf("   (Aucune fonction personnalisée chargée)\n");
                printf("💡 Utilisez my.package.charge('fichier.c') pour charger un package\n");
            }
        }
    }
    else if (strstr(line, "my.")) {
        // Pour de futures fonctionnalités commençant par "my."
        maya_error("Fonction Maya non implémentée", 0);
    }
    else {
        maya_error("Commande Maya non reconnue", 0);
    }
}

// Fonction pour exécuter un fichier Maya
void execute_maya_file(const char *filename) {
    FILE *file = fopen(filename, "r");
    if (!file) {
        maya_error("Impossible d'ouvrir le fichier", 0);
        return;
    }

    char line[MAX_LINE_LENGTH];
    int line_number = 1;

    while (fgets(line, sizeof(line), file)) {
        // Enlever le saut de ligne
        line[strcspn(line, "\n")] = '\0';

        // Ignorer les lignes vides et les commentaires
        if (strlen(line) == 0 || line[0] == '#') {
            line_number++;
            continue;
        }

        interpret_line(line);
        line_number++;
    }

    fclose(file);
}

int main(int argc, char *argv[]) {
    // Initialiser le générateur de nombres aléatoires
    srand(time(NULL));

    // Si un fichier est passé en argument
    if (argc == 2) {
        const char *filename = argv[1];

        // Vérifier l'extension .my
        const char *ext = strrchr(filename, '.');
        if (ext && strcmp(ext, ".my") == 0) {
            execute_maya_file(filename);
            return 0;
        } else {
            maya_error("Le fichier doit avoir l'extension .my", 0);
            return 1;
        }
    }

    // Mode interactif si aucun fichier n'est fourni
    printf("🌸 === Interpréteur Maya v6.0 - L'IMAGINATION SANS LIMITES === 🌸\n");
    printf("🆕 NOUVELLES FONCTIONNALITÉS v6.0:\n");
    printf("🤖 Chatbots: my.create.robot (créez vos assistants IA!)\n");
    printf("🔄 Boucles: my.for, my.while, my.loop (contrôle de flux complet!)\n");
    printf("🎨 Palettes: my.palette (dessins colorés personnalisés!)\n");
    printf("🎮 Jeux: my.owngame (créateur de jeux interactifs!)\n");
    printf("💬 Console: my.modifie.console (modifications dynamiques!)\n");
    printf("📋 Menus: my.interactive (interfaces utilisateur ASCII!)\n");
    printf("🎒 Inventaire: my.inventaire (système de gestion d'objets!)\n");
    printf("📖 Histoires: my.histoire.recit, my.histoire.end (conteur magique!)\n");
    printf("🐾 Animaux: my.own.pet, my.nombre.pet (créatures personnalisées!)\n");
    printf("⚡ Titans: my.own.titan, my.nombre.titan (épopées légendaires!)\n");
    printf("🧮 Maths avancées: médiane, moyenne, cube, carré, racine, degrés\n");
    printf("📐 Théorèmes: Pythagore (my.pytha), Thalès (my.thales)\n");
    printf("🎵 Musique: my.rythme.convertir, my.renvoie.gamme, my.obtenir.gamme\n");
    printf("🗄️ Bases de données: my.db, my.send.db, my.supp.db, my.util.db\n");
    printf("⚡ Code C intégré: my.execute.c (exécutez du C directement!)\n");
    printf("🌌 Simulations: Robot, Quantique, Univers, Atomes, Voyage temporel\n");
    printf("🧚‍♀️ Contes: Fées, Vampires, Sirènes, Monstres\n");
    printf("📚 Exercices BAC: Gestion, Math, Histoire, Management (STMG/Général)\n");
    printf("🎮 Mini-jeux: Quizz, Dés, Puissance4, Pendu, Memory, Snake, TicTac et plus!\n");
    printf("📦 Packages C améliorés: Plus simples à créer et charger!\n");
    printf("🚀 Maya v6.0 - OÙ L'IMAGINATION DEVIENT RÉALITÉ! 🚀\n");
    printf("Mode interactif - Tapez 'exit' pour quitter\n\n");

    char line[MAX_LINE_LENGTH];

    while (1) {
        printf("maya> ");
        fflush(stdout);

        if (fgets(line, sizeof(line), stdin) == NULL) break;

        // Enlever le saut de ligne
        line[strcspn(line, "\n")] = '\0';

        if (strcmp(line, "exit") == 0) {
            printf("🌸 Au revoir! Merci d'avoir utilisé Maya! 💖\n");
            break;
        }

        if (strlen(line) > 0) {
            interpret_line(line);
        }
    }

    // Nettoyer les packages chargés
    for (int i = 0; i < maya_package_count; i++) {
        if (maya_packages[i].handle) {
            dlclose(maya_packages[i].handle);
            // Supprimer le fichier temporaire
            unlink(maya_packages[i].so_path);
        }
    }

    return 0;
}