Spaces:
Runtime error

File size: 86,267 Bytes
abf589b
 
 
 
fe3c808
abf589b
fe3c808
 
 
 
 
d0ea8bd
 
 
fe3c808
 
abf589b
 
fe3c808
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
abf589b
fe3c808
abf589b
 
 
 
 
 
fe3c808
 
abf589b
 
fe3c808
abf589b
fe3c808
 
abf589b
 
fe3c808
 
 
 
 
abf589b
 
 
 
 
 
fe3c808
 
 
 
 
 
 
 
abf589b
fe3c808
 
 
 
 
 
abf589b
 
 
fe3c808
 
 
abf589b
 
 
 
 
 
 
 
 
fe3c808
abf589b
 
fe3c808
abf589b
fe3c808
 
abf589b
 
fe3c808
 
 
 
 
 
 
 
 
abf589b
 
 
fe3c808
abf589b
fe3c808
 
abf589b
 
 
fe3c808
abf589b
 
fe3c808
abf589b
 
 
fe3c808
abf589b
fe3c808
abf589b
 
fe3c808
abf589b
fe3c808
 
 
 
abf589b
 
 
 
fe3c808
abf589b
 
 
 
 
fe3c808
abf589b
 
 
fe3c808
 
 
abf589b
 
 
 
fe3c808
 
 
 
 
 
 
 
 
 
 
 
abf589b
 
fe3c808
 
 
 
 
 
 
 
abf589b
fe3c808
 
 
 
 
abf589b
fe3c808
abf589b
fe3c808
 
 
 
 
 
 
 
 
 
 
abf589b
 
fe3c808
abf589b
fe3c808
 
 
 
 
abf589b
fe3c808
 
abf589b
fe3c808
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
abf589b
 
fe3c808
abf589b
 
 
fe3c808
abf589b
fe3c808
abf589b
fe3c808
abf589b
fe3c808
 
 
 
 
 
abf589b
 
fe3c808
abf589b
fe3c808
 
 
 
 
 
abf589b
 
 
fe3c808
abf589b
fe3c808
abf589b
 
fe3c808
 
 
 
 
 
 
abf589b
 
 
fe3c808
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
abf589b
 
fe3c808
abf589b
fe3c808
 
abf589b
 
fe3c808
abf589b
 
fe3c808
 
 
abf589b
 
 
 
 
 
fe3c808
abf589b
 
 
 
 
fe3c808
abf589b
 
 
 
 
 
 
fe3c808
abf589b
fe3c808
 
abf589b
 
 
 
fe3c808
 
 
abf589b
 
 
 
 
 
 
fe3c808
 
abf589b
fe3c808
abf589b
 
fe3c808
 
 
 
abf589b
 
fe3c808
 
 
 
 
 
 
 
 
abf589b
 
fe3c808
 
 
 
abf589b
 
fe3c808
 
 
 
 
 
 
 
 
 
 
 
 
abf589b
 
fe3c808
 
 
 
 
 
 
 
 
 
 
abf589b
 
fe3c808
 
 
 
 
 
 
 
 
 
abf589b
 
fe3c808
 
 
 
 
 
 
abf589b
 
fe3c808
 
 
 
 
 
 
 
 
 
 
abf589b
 
 
 
 
fe3c808
abf589b
fe3c808
 
 
 
 
 
 
 
 
abf589b
 
 
fe3c808
 
 
 
 
abf589b
 
 
 
 
 
 
fe3c808
 
 
 
abf589b
 
fe3c808
abf589b
 
fe3c808
 
abf589b
 
 
 
 
fe3c808
abf589b
 
fe3c808
 
abf589b
 
 
 
 
 
fe3c808
abf589b
fe3c808
 
abf589b
 
 
 
fe3c808
 
abf589b
 
fe3c808
abf589b
 
 
fe3c808
 
abf589b
 
 
 
 
 
 
fe3c808
 
abf589b
 
 
 
 
 
fe3c808
 
abf589b
 
 
 
 
 
 
fe3c808
 
abf589b
 
 
 
 
 
 
 
fe3c808
abf589b
 
 
fe3c808
 
abf589b
 
 
 
 
 
 
fe3c808
 
abf589b
 
 
 
fe3c808
 
abf589b
 
 
 
 
 
 
 
fe3c808
abf589b
fe3c808
 
abf589b
 
 
 
fe3c808
 
abf589b
 
 
 
 
 
 
 
fe3c808
 
abf589b
 
 
fe3c808
abf589b
 
 
fe3c808
abf589b
 
 
 
 
 
 
 
 
 
 
fe3c808
 
 
 
abf589b
fe3c808
abf589b
fe3c808
abf589b
 
 
 
 
 
 
 
fe3c808
 
 
 
 
 
abf589b
 
fe3c808
 
abf589b
 
fe3c808
 
abf589b
 
fe3c808
 
abf589b
 
 
 
 
fe3c808
 
 
 
abf589b
fe3c808
 
abf589b
fe3c808
 
 
abf589b
 
 
 
fe3c808
abf589b
 
fe3c808
abf589b
 
 
 
 
 
 
 
 
 
fe3c808
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
abf589b
 
 
fe3c808
 
 
abf589b
 
fe3c808
 
 
 
abf589b
 
fe3c808
 
 
abf589b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fe3c808
abf589b
fe3c808
 
 
 
 
 
 
 
 
 
 
 
 
abf589b
fe3c808
 
 
 
 
 
 
 
 
 
 
 
 
 
 
abf589b
fe3c808
 
 
abf589b
 
fe3c808
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
abf589b
fe3c808
 
abf589b
 
 
fe3c808
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
abf589b
fe3c808
 
 
 
 
 
abf589b
fe3c808
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
    <title>Doc-less API Agent Demo Interface</title>
    
    <!-- Optimized for Hugging Face Spaces -->
    <meta name="description" content="Live interactive demo of the Doc-less API Agent - Transform undocumented APIs into production-ready SDKs">
    <meta name="theme-color" content="#297373">
    
    <!-- Prevent favicon.ico requests -->
    <link rel="icon" href="data:,">
    
    <!-- Preload critical resources -->
    <link rel="preconnect" href="https://cdn.tailwindcss.com" crossorigin>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    
    <!-- Load Tailwind CSS with performance optimization -->
    <script>
        // Load Tailwind CSS asynchronously to prevent render blocking
        const tailwindScript = document.createElement('script');
        tailwindScript.src = 'https://cdn.tailwindcss.com';
        tailwindScript.async = true;
        document.head.appendChild(tailwindScript);
    </script>
    
    <!-- Load additional libraries asynchronously -->
    <script>
        window.addEventListener('load', () => {
            const markedScript = document.createElement('script');
            markedScript.src = 'https://cdn.jsdelivr.net/npm/marked/marked.min.js';
            markedScript.async = true;
            document.head.appendChild(markedScript);
            
            const purifyScript = document.createElement('script');
            purifyScript.src = 'https://cdn.jsdelivr.net/npm/dompurify@2.4.0/dist/purify.min.js';
            purifyScript.async = true;
            document.head.appendChild(purifyScript);
        });
    </script>
    
    <!-- Optimized font loading -->
    <link href="https://fonts.googleapis.com/css2?family=Kalam:wght@400;700&display=swap" rel="stylesheet" media="print" onload="this.media='all'">
    <style>
        /* Hugging Face Spaces optimized styles with mobile-first approach */
        :root {
            --arylide-yellow: #e9d758;
            --myrtle-green: #297373;
            --coral: #ff8552;
            --platinum: #e6e6e6;
            --jet: #39393a;
            --spaces-primary: #ff9500;
            --spaces-background: #0f0f0f;
        }

        /* Base responsive typography */
        body {
            font-family: 'Kalam', cursive, -apple-system, BlinkMacSystemFont, sans-serif;
            background: linear-gradient(135deg, var(--jet) 0%, #2d2d2d 100%);
            color: var(--platinum);
            font-weight: 400;
            line-height: 1.6;
            font-size: clamp(14px, 2.5vw, 16px);
            min-height: 100vh;
            margin: 0;
            padding: 0;
        }
        
        h1, h2, h3, .font-bold {
            font-weight: 700;
        }

        /* Container with Spaces-friendly responsive padding */
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: clamp(0.5rem, 3vw, 2rem);
        }

        /* Enhanced cards with better mobile experience */
        .card {
            background: rgba(255, 255, 255, 0.08);
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.15);
            border-radius: clamp(8px, 2vw, 16px);
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        }

        .card:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
            border-color: var(--coral);
        }

        .card-header {
            color: var(--arylide-yellow);
            border-bottom: 2px solid var(--myrtle-green);
        }

        .highlight {
            color: var(--coral);
            font-weight: 600;
        }
        
        /* Mobile-optimized flowchart nodes */
        .flowchart-node {
            border: 2px solid var(--myrtle-green);
            background: linear-gradient(135deg, var(--jet) 0%, #2a2a2a 100%);
            cursor: pointer;
            transition: all 0.3s ease;
            border-radius: clamp(8px, 2vw, 12px);
            padding: clamp(0.75rem, 3vw, 1.25rem);
            font-size: clamp(12px, 2.2vw, 14px);
            font-weight: 600;
            text-align: center;
            min-height: 50px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .flowchart-node:hover {
            background: var(--myrtle-green);
            color: var(--jet);
            transform: scale(1.05);
            box-shadow: 0 4px 12px rgba(41, 115, 115, 0.3);
        }
        
        .flowchart-node.active {
            background: var(--coral);
            color: var(--jet);
            animation: pulse 2s infinite;
            border-color: var(--arylide-yellow);
        }
        
        .flowchart-node.completed {
            background: var(--arylide-yellow);
            color: var(--jet);
            border-color: var(--arylide-yellow);
        }
        
        /* Simplified decision nodes for mobile */
        .flowchart-node.decision {
            clip-path: polygon(20% 0%, 80% 0%, 100% 50%, 80% 100%, 20% 100%, 0% 50%);
            padding: clamp(0.5rem, 2vw, 1rem);
            min-width: clamp(120px, 25vw, 140px);
            min-height: clamp(60px, 12vw, 80px);
        }
        
        .flowchart-arrow {
            stroke: var(--myrtle-green);
            stroke-width: clamp(2px, 0.5vw, 3px);
            fill: none;
            stroke-linecap: round;
            stroke-linejoin: round;
        }

        /* Mobile-friendly sub-flows */
        .sub-flow {
            display: none;
            border-left: 3px dashed var(--coral);
            margin-top: 1rem;
            padding-left: clamp(0.75rem, 3vw, 1.5rem);
            font-size: clamp(11px, 2vw, 13px);
        }
        
        .sub-flow.active {
            display: block;
            animation: slideIn 0.3s ease-out;
        }

        @keyframes slideIn {
            from {
                opacity: 0;
                transform: translateX(-20px);
            }
            to {
                opacity: 1;
                transform: translateX(0);
            }
        }
        
        /* Responsive tables */
        .table-container {
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
        }
        
        table {
            min-width: 100%;
            border-collapse: collapse;
            font-size: clamp(12px, 2vw, 14px);
        }

        table, th, td {
            border: 1px solid var(--myrtle-green);
        }
        
        th, td {
            padding: clamp(0.5rem, 2vw, 0.75rem);
            text-align: left;
        }

        th {
            background: var(--myrtle-green);
            color: var(--jet);
            font-weight: 700;
            position: sticky;
            top: 0;
            z-index: 10;
        }

        /* Enhanced terminal with mobile optimization */
        .terminal-output {
            background: linear-gradient(135deg, #1a1a1a 0%, #0f0f0f 100%);
            color: #00ff41;
            font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
            padding: clamp(0.75rem, 3vw, 1.25rem);
            border-radius: clamp(6px, 1.5vw, 10px);
            white-space: pre-wrap;
            word-break: break-word;
            max-height: clamp(200px, 40vh, 350px);
            overflow-y: auto;
            border: 1px solid #333;
            font-size: clamp(11px, 2vw, 13px);
            line-height: 1.4;
            scrollbar-width: thin;
            scrollbar-color: var(--myrtle-green) #1a1a1a;
        }

        .terminal-output::-webkit-scrollbar {
            width: 6px;
        }

        .terminal-output::-webkit-scrollbar-track {
            background: #1a1a1a;
        }

        .terminal-output::-webkit-scrollbar-thumb {
            background: var(--myrtle-green);
            border-radius: 3px;
        }

        /* Mobile-optimized buttons */
        .demo-button {
            background: linear-gradient(135deg, var(--myrtle-green), var(--coral));
            color: white;
            padding: clamp(0.5rem, 2.5vw, 0.8rem) clamp(0.75rem, 3vw, 1.5rem);
            border: none;
            border-radius: clamp(6px, 1.5vw, 8px);
            cursor: pointer;
            font-weight: 600;
            transition: all 0.3s ease;
            font-size: clamp(12px, 2.2vw, 14px);
            min-height: 44px; /* Touch target size */
            display: inline-flex;
            align-items: center;
            justify-content: center;
            text-decoration: none;
        }

        .demo-button:hover:not(:disabled) {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(0,0,0,0.3);
            filter: brightness(1.1);
        }

        .demo-button:active {
            transform: translateY(0);
        }

        .demo-button:disabled {
            opacity: 0.6;
            cursor: not-allowed;
            transform: none;
        }

        /* Progress bar enhancements */
        .progress-container {
            background: rgba(255, 255, 255, 0.1);
            height: clamp(6px, 1vw, 8px);
            border-radius: clamp(3px, 0.5vw, 4px);
            overflow: hidden;
            position: relative;
        }

        .progress-bar {
            background: linear-gradient(90deg, var(--myrtle-green), var(--coral));
            height: 100%;
            border-radius: inherit;
            transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
            position: relative;
            overflow: hidden;
        }

        .progress-bar::after {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            bottom: 0;
            right: 0;
            background: linear-gradient(
                90deg,
                transparent,
                rgba(255, 255, 255, 0.4),
                transparent
            );
            transform: translateX(-100%);
            animation: shimmer 2s infinite;
        }

        @keyframes shimmer {
            to {
                transform: translateX(100%);
            }
        }

        @keyframes pulse {
            0%, 100% { opacity: 1; transform: scale(1); }
            50% { opacity: 0.8; transform: scale(1.02); }
        }

        /* Responsive grid layouts */
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
            gap: clamp(0.75rem, 3vw, 1.5rem);
        }

        .demo-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
            gap: clamp(1rem, 4vw, 2rem);
        }

        /* Mobile-first modal */
        .modal {
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.85);
            backdrop-filter: blur(4px);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 1000;
            padding: clamp(1rem, 4vw, 2rem);
        }

        .modal-content {
            background: var(--jet);
            border-radius: clamp(8px, 2vw, 16px);
            max-width: 90vw;
            max-height: 85vh;
            width: 100%;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            border: 1px solid rgba(255, 255, 255, 0.2);
        }

        .modal-header {
            padding: clamp(1rem, 3vw, 1.5rem);
            border-bottom: 1px solid rgba(255, 255, 255, 0.15);
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-shrink: 0;
        }

        .modal-body {
            flex: 1;
            overflow-y: auto;
            padding: clamp(1rem, 3vw, 2rem);
        }

        /* GitHub-style markdown with mobile optimization */
        .markdown-body {
            font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif;
            font-size: clamp(14px, 2.5vw, 16px);
            line-height: 1.5;
            color: #e6edf3;
            background: transparent;
        }

        .markdown-body h1, .markdown-body h2, .markdown-body h3 {
            margin-top: clamp(1rem, 4vw, 1.5rem);
            margin-bottom: clamp(0.5rem, 2vw, 1rem);
            font-weight: 600;
            line-height: 1.25;
            color: #f0f6fc;
        }

        .markdown-body h1 {
            font-size: clamp(1.5rem, 5vw, 2rem);
            border-bottom: 1px solid #21262d;
            padding-bottom: 0.3em;
        }

        .markdown-body h2 {
            font-size: clamp(1.25rem, 4vw, 1.5rem);
            border-bottom: 1px solid #21262d;
            padding-bottom: 0.3em;
        }

        .markdown-body code {
            padding: 0.2em 0.4em;
            margin: 0;
            font-size: clamp(12px, 2vw, 14px);
            background-color: #161b22;
            border-radius: 4px;
            font-family: ui-monospace,SFMono-Regular,"SF Mono",Consolas,monospace;
            color: #e6edf3;
        }

        .markdown-body pre {
            padding: clamp(0.75rem, 3vw, 1rem);
            overflow-x: auto;
            font-size: clamp(12px, 2vw, 14px);
            line-height: 1.45;
            background-color: #161b22;
            border-radius: 6px;
            border: 1px solid #30363d;
            margin-bottom: 16px;
        }

        /* Spaces-specific optimizations */
        .spaces-embed {
            max-width: 100%;
            padding: clamp(0.5rem, 2vw, 1rem);
        }

        /* Loading states */
        .loading {
            position: relative;
            overflow: hidden;
        }

        .loading::after {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
            animation: loading 1.5s infinite;
        }

        @keyframes loading {
            to {
                left: 100%;
            }
        }

        /* Touch-friendly interactions */
        @media (hover: none) and (pointer: coarse) {
            .flowchart-node:hover {
                transform: none;
            }
            
            .card:hover {
                transform: none;
            }
            
            .demo-button:hover {
                transform: none;
            }
        }

        /* Print optimization */
        @media print {
            body {
                background: white !important;
                color: black !important;
            }
            
            .demo-button,
            .terminal-output {
                display: none;
            }
        }

        /* High contrast mode support */
        @media (prefers-contrast: high) {
            .card {
                border-width: 2px;
                border-color: var(--platinum);
            }
            
            .demo-button {
                border: 2px solid var(--platinum);
            }
        }

        /* Reduced motion support */
        @media (prefers-reduced-motion: reduce) {
            * {
                animation-duration: 0.01ms !important;
                animation-iteration-count: 1 !important;
                transition-duration: 0.01ms !important;
            }
        }

        /* Dark mode optimization (already default) */
        @media (prefers-color-scheme: light) {
            :root {
                --jet: #ffffff;
                --platinum: #333333;
            }
            
            body {
                background: linear-gradient(135deg, #ffffff 0%, #f5f5f5 100%);
                color: var(--platinum);
            }
        }
    </style>
</head>
<body class="antialiased">

    <div class="container">

        <!-- Hugging Face Spaces Header with mobile optimization -->
        <header class="text-center mb-8 md:mb-12">
            <div class="spaces-embed">
                <h1 class="text-3xl sm:text-4xl md:text-5xl font-bold text-white mb-2">The Doc-less API Agent</h1>
                <p class="text-lg md:text-xl mb-4" style="color: var(--arylide-yellow);">Live Interactive Demo</p>
                <div class="progress-container">
                    <div id="progress" class="progress-bar" style="width: 0%"></div>
                </div>
                <p id="progress-text" class="text-sm mt-2 text-gray-300">Ready to start demo</p>
            </div>
        </header>

        <!-- Mobile-optimized Demo Control Panel -->
        <section class="mb-8 md:mb-12">
            <div class="card p-4 md:p-6 text-center">
                <h2 class="text-xl md:text-2xl font-bold card-header pb-2 mb-4">🎮 Demo Control Panel</h2>
                <div class="flex flex-col sm:flex-row gap-3 sm:gap-4 justify-center">
                    <button id="start-demo" class="demo-button">🚀 Start Demo</button>
                    <button id="reset-demo" class="demo-button" disabled>🔄 Reset Demo</button>
                    <button id="skip-to-results" class="demo-button" disabled>⏭️ Skip to Results</button>
                </div>
            </div>
        </section>

        <!-- Mobile-first Interactive User Flow -->
        <section class="mb-8 md:mb-12">
            <h2 class="text-2xl md:text-3xl font-bold text-center mb-6 md:mb-8">🗺️ Interactive Demo Flow</h2>
            <div class="card p-4 md:p-6">
                
                <!-- Step 1: Clone Repository -->
                <div id="step-1" class="flowchart-node mx-auto mb-4 max-w-sm" data-step="1">
                    📥 Clone Repository
                </div>
                <div class="h-8 md:h-12 w-full flex justify-center items-center">
                    <svg viewBox="0 0 20 50" class="h-full w-6">
                        <path d="M 10 0 V 45 M 5 40 L 10 48 L 15 40" class="flowchart-arrow"></path>
                    </svg>
                </div>

                <!-- Step 2: Setup Environment -->
                <div id="step-2" class="flowchart-node mx-auto mb-4 max-w-sm" data-step="2">
                    🛠️ Setup Environment
                </div>
                <div class="h-8 md:h-12 w-full flex justify-center items-center">
                    <svg viewBox="0 0 20 50" class="h-full w-6">
                        <path d="M 10 0 V 45 M 5 40 L 10 48 L 15 40" class="flowchart-arrow"></path>
                    </svg>
                </div>

                <!-- Decision Point -->
                <div id="step-3" class="flowchart-node decision flex items-center justify-center mx-auto mb-4" data-step="3">
                    <div class="text-center text-sm font-bold">Choose Path</div>
                </div>
                <div class="h-8 md:h-12 w-full flex justify-center items-center">
                    <svg viewBox="0 0 20 50" class="h-full w-6">
                        <path d="M 10 0 V 45 M 5 40 L 10 48 L 15 40" class="flowchart-arrow"></path>
                    </svg>
                </div>

                <!-- Three Paths - Mobile responsive -->
                <div class="demo-grid mt-4">
                    <!-- Path 1: Live API -->
                    <div class="text-center">
                        <h3 class="text-lg md:text-xl font-semibold highlight mb-4">🌐 Live API Testing</h3>
                        <div id="step-4a" class="flowchart-node mb-4" data-step="4a" onclick="toggleSubFlow('liveApiSubFlow')">
                            🔍 Run OpenAPI Discovery
                        </div>
                        <div id="liveApiSubFlow" class="sub-flow text-left">
                           <p class="font-bold mb-2 text-sm">Discovery Details:</p>
                           <ul class="list-disc list-inside text-sm space-y-1">
                               <li>Analyze GitHub API Endpoints</li>
                               <li>Capture Request/Response Examples</li>
                               <li>Document Rate Limits & Headers</li>
                               <li>Map Pagination Patterns</li>
                           </ul>
                        </div>
                        <div class="h-8 w-full flex justify-center items-center">
                            <svg viewBox="0 0 20 50" class="h-full w-6">
                                <path d="M 10 0 V 45 M 5 40 L 10 48 L 15 40" class="flowchart-arrow"></path>
                            </svg>
                        </div>
                        <div id="step-5a" class="flowchart-node mb-4" data-step="5a" onclick="toggleSubFlow('sdkCoreSubFlow')">
                            💻 Generate TypeScript SDK
                        </div>
                        <div id="sdkCoreSubFlow" class="sub-flow text-left">
                           <p class="font-bold mb-2 text-sm">SDK Core Features:</p>
                           <ul class="list-disc list-inside text-sm space-y-1">
                               <li>Unified Paginator (page, cursor, etc.)</li>
                               <li>Retry Logic (429s, backoff, jitter)</li>
                               <li>Checkpointing to resume state</li>
                               <li>Deduplication of results</li>
                           </ul>
                        </div>
                        <div class="h-8 w-full flex justify-center items-center">
                            <svg viewBox="0 0 20 50" class="h-full w-6">
                                <path d="M 10 0 V 45 M 5 40 L 10 48 L 15 40" class="flowchart-arrow"></path>
                            </svg>
                        </div>
                        <div id="step-6a" class="flowchart-node" data-step="6a">🧪 Test Live API</div>
                    </div>

                    <!-- Path 2: Mock Lab -->
                    <div class="text-center">
                        <h3 class="text-lg md:text-xl font-semibold highlight mb-4">🧬 Local Mock Testing</h3>
                        <div id="step-4b" class="flowchart-node mb-4" data-step="4b" onclick="toggleSubFlow('mockLabSubFlow')">
                            🐳 Launch Mock Lab
                        </div>
                        <div id="mockLabSubFlow" class="sub-flow text-left">
                           <p class="font-bold mb-2 text-sm">Mock Lab Services:</p>
                           <ul class="list-disc list-inside text-sm space-y-1">
                               <li>OAuth2 Provider Service</li>
                               <li>Payment API with Idempotency</li>
                               <li>Webhook Handler with HMAC</li>
                               <li>Express.js Mock Server</li>
                           </ul>
                        </div>
                        <div class="h-8 w-full flex justify-center items-center">
                            <svg viewBox="0 0 20 50" class="h-full w-6">
                                <path d="M 10 0 V 45 M 5 40 L 10 48 L 15 40" class="flowchart-arrow"></path>
                            </svg>
                        </div>
                        <div id="step-5b" class="flowchart-node mb-4" data-step="5b">🔐 Test OAuth2 & Idempotency</div>
                        <div class="h-8 w-full flex justify-center items-center">
                            <svg viewBox="0 0 20 50" class="h-full w-6">
                                <path d="M 10 0 V 45 M 5 40 L 10 48 L 15 40" class="flowchart-arrow"></path>
                            </svg>
                        </div>
                        <div id="step-6b" class="flowchart-node" data-step="6b">🔒 Test Webhook Verification</div>
                    </div>

                    <!-- Path 3: SDK Dev -->
                     <div class="text-center">
                        <h3 class="text-lg md:text-xl font-semibold highlight mb-4">⚙️ SDK Development</h3>
                        <div id="step-4c" class="flowchart-node mb-4" data-step="4c">🏗️ Implement Core Client</div>
                        <div class="h-8 w-full flex justify-center items-center">
                            <svg viewBox="0 0 20 50" class="h-full w-6">
                                <path d="M 10 0 V 45 M 5 40 L 10 48 L 15 40" class="flowchart-arrow"></path>
                            </svg>
                        </div>
                        <div id="step-5c" class="flowchart-node mb-4" data-step="5c">📄 Build Unified Paginator</div>
                        <div class="h-8 w-full flex justify-center items-center">
                            <svg viewBox="0 0 20 50" class="h-full w-6">
                                <path d="M 10 0 V 45 M 5 40 L 10 48 L 15 40" class="flowchart-arrow"></path>
                            </svg>
                        </div>
                        <div id="step-6c" class="flowchart-node" data-step="6c">🔄 Add Retry & Checkpointing</div>
                    </div>
                </div>

                <!-- Final Step: Evidence Report -->
                <div class="h-8 md:h-12 w-full flex justify-center items-center mt-6 md:mt-8">
                    <svg viewBox="0 0 20 50" class="h-full w-6">
                        <path d="M 10 0 V 45 M 5 40 L 10 48 L 15 40" class="flowchart-arrow"></path>
                    </svg>
                </div>
                <div id="step-7" class="flowchart-node mx-auto max-w-sm" data-step="7" onclick="toggleSubFlow('evidenceSubFlow')">
                    📊 Generate Evidence Report
                </div>
                <div id="evidenceSubFlow" class="sub-flow mt-4 max-w-md mx-auto p-4 text-left">
                   <p class="font-bold mb-2 text-sm">Evidence Collection Includes:</p>
                   <ul class="list-disc list-inside text-sm space-y-1">
                       <li>Documented API Calls with curl</li>
                       <li>Postman Request Logs</li>
                       <li>Recorded Rate Limit Headers</li>
                       <li>Screenshots of Pagination Results</li>
                       <li>Test Coverage Reports</li>
                   </ul>
                </div>
            </div>
        </section>

        <!-- Mobile-optimized Live Terminal Output -->
        <section class="mb-8 md:mb-12">
            <div class="card p-4 md:p-6">
                <h2 class="text-xl md:text-2xl font-bold card-header pb-2 mb-4">💻 Live Terminal Output</h2>
                <div id="terminal" class="terminal-output">
Waiting for demo to start...
                </div>
                <div class="mt-4 flex flex-col sm:flex-row justify-between items-start sm:items-center gap-2 sm:gap-4">
                    <button id="clear-terminal" class="demo-button">🧹 Clear Terminal</button>
                    <div class="text-sm text-gray-400">
                        <span id="demo-timer">00:00</span> elapsed
                    </div>
                </div>
            </div>
        </section>

        <!-- Mobile-responsive Results Dashboard -->
        <section class="mb-8 md:mb-12">
            <h2 class="text-2xl md:text-3xl font-bold text-center mb-6 md:mb-8">📊 Live Results Dashboard</h2>
            <div class="stats-grid">
                <div class="card p-4 md:p-6 text-center">
                    <h3 class="text-xl md:text-2xl font-bold highlight" id="api-calls">0</h3>
                    <p class="text-sm">API Calls Made</p>
                </div>
                <div class="card p-4 md:p-6 text-center">
                    <h3 class="text-xl md:text-2xl font-bold highlight" id="endpoints-discovered">0</h3>
                    <p class="text-sm">Endpoints Discovered</p>
                </div>
                <div class="card p-4 md:p-6 text-center">
                    <h3 class="text-xl md:text-2xl font-bold highlight" id="tests-passed">0/0</h3>
                    <p class="text-sm">Tests Passed</p>
                </div>
                <div class="card p-4 md:p-6 text-center">
                    <h3 class="text-xl md:text-2xl font-bold highlight" id="deliverables-ready">0/6</h3>
                    <p class="text-sm">Deliverables Ready</p>
                </div>
            </div>
        </section>

        <!-- Mobile-optimized Evidence Modal -->
        <div id="evidence-modal" class="modal" style="display: none;">
            <div class="modal-content">
                <div class="modal-header">
                    <div class="flex items-center">
                        <h3 class="text-xl md:text-2xl font-bold text-white mr-4">📋 API Evidence Report</h3>
                        <span class="bg-green-600 text-white px-2 md:px-3 py-1 rounded-full text-xs md:text-sm font-medium">Generated</span>
                    </div>
                    <div class="flex items-center space-x-2 md:space-x-3">
                        <button id="download-evidence" class="bg-blue-600 hover:bg-blue-700 text-white px-3 md:px-4 py-2 rounded-lg text-xs md:text-sm font-medium flex items-center">
                            <svg class="w-4 h-4 mr-1 md:mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
                            </svg>
                            Download
                        </button>
                        <button id="close-evidence" class="text-gray-400 hover:text-white text-2xl md:text-3xl leading-none">&times;</button>
                    </div>
                </div>
                <div id="evidence-content" class="modal-body">
                    <div class="flex items-center justify-center h-40">
                        <div class="text-center">
                            <div class="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500 mx-auto mb-4"></div>
                            <p class="text-gray-400">Loading evidence report...</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Mobile-responsive Final Results -->
        <section class="mb-8 md:mb-12" id="final-results" style="display: none;">
            <h2 class="text-2xl md:text-3xl font-bold text-center mb-6 md:mb-8">🎉 Demo Results</h2>
            <div class="card p-4 md:p-6">
                <div class="table-container">
                    <table class="w-full text-left">
                        <thead>
                            <tr>
                                <th class="font-bold">Deliverable</th>
                                <th class="font-bold">Status</th>
                                <th class="font-bold hidden sm:table-cell">Details</th>
                                <th class="font-bold">Actions</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td class="font-semibold">📄 OpenAPI Spec</td>
                                <td><span class="highlight">✅ Generated</span></td>
                                <td class="hidden sm:table-cell">Complete GitHub API 3.1 specification with examples</td>
                                <td><button onclick="downloadFile('openapi.yaml', 'openapi')" class="text-sm demo-button">⬇️ Download</button></td>
                            </tr>
                            <tr>
                                <td class="font-semibold">💻 TypeScript SDK</td>
                                <td><span class="highlight">✅ Ready</span></td>
                                <td class="hidden sm:table-cell">Pagination, retry logic, checkpointing included</td>
                                <td><button onclick="viewSDKStructure()" class="text-sm demo-button">👁️ View Structure</button></td>
                            </tr>
                            <tr>
                                <td class="font-semibold">📮 Postman Collection</td>
                                <td><span class="highlight">✅ Generated</span></td>
                                <td class="hidden sm:table-cell">Ready-to-use collection with authentication</td>
                                <td><button onclick="downloadFile('postman_collection.json', 'postman')" class="text-sm demo-button">⬇️ Download</button></td>
                            </tr>
                            <tr>
                                <td class="font-semibold">📋 Evidence Report</td>
                                <td><span class="highlight">✅ Complete</span></td>
                                <td class="hidden sm:table-cell">Comprehensive API behavior documentation</td>
                                <td><button onclick="showEvidence()" class="text-sm demo-button">👁️ View Report</button></td>
                            </tr>
                            <tr>
                                <td class="font-semibold">🧪 Mock Lab</td>
                                <td><span class="highlight">✅ Running</span></td>
                                <td class="hidden sm:table-cell">OAuth2, Webhooks, Idempotency testing environment</td>
                                <td><button onclick="viewMockLabStatus()" class="text-sm demo-button">📊 Status</button></td>
                            </tr>
                            <tr>
                                <td class="font-semibold">🧪 Test Suite</td>
                                <td><span class="highlight">✅ Passed</span></td>
                                <td class="hidden sm:table-cell">100% test coverage with Jest and Newman</td>
                                <td><button onclick="viewTestResults()" class="text-sm demo-button">📊 Results</button></td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </section>

        <!-- Mobile-optimized Footer -->
        <footer class="text-center border-t border-opacity-20 pt-6 md:pt-8" style="border-color: var(--myrtle-green);">
            <p class="text-sm md:text-lg max-w-3xl mx-auto mb-4" style="color: var(--platinum);">
                A Doc-less API Agent that turns messy docs into a developer-ready bundle. Verified, reliable, and future-proof — built for SMB speed, enterprise rigor.
            </p>
            <div class="flex flex-wrap justify-center gap-2 md:gap-4">
                <a href="#" id="export-results" class="demo-button">💾 Export Results</a>
                <a href="#" id="export-postman" class="demo-button">📮 Export Postman</a>
                <a href="#" id="export-openapi" class="demo-button">📄 Export OpenAPI</a>
                <a href="#" id="view-evidence" class="demo-button">📋 View Evidence</a>
            </div>
            <div class="mt-4 text-xs text-gray-500">
                Optimized for 📱 Mobile • 💻 Desktop • 🌐 Hugging Face Spaces
            </div>
        </footer>
    </div>

    <script>
        // Demo state management
        let demoState = {
            currentStep: 0,
            totalSteps: 13, // Total number of demo steps
            startTime: null,
            timer: null,
            apiCalls: 0,
            endpointsDiscovered: 0,
            testsPassed: 0,
            totalTests: 15,
            deliverables: 0
        };

        // Simple script to toggle visibility of sub-flow details
        function toggleSubFlow(elementId) {
            const element = document.getElementById(elementId);
            if (element) {
                element.classList.toggle('active');
            }
        }

        // Demo control functions
        function startDemo() {
            demoState.startTime = Date.now();
            demoState.currentStep = 1;
            document.getElementById('start-demo').disabled = true;
            document.getElementById('reset-demo').disabled = false;
            document.getElementById('skip-to-results').disabled = false;
            
            updateProgress();
            startTimer();
            runDemoStep(1);
        }

        function resetDemo() {
            demoState = {
                currentStep: 0,
                totalSteps: 13,
                startTime: null,
                timer: null,
                apiCalls: 0,
                endpointsDiscovered: 0,
                testsPassed: 0,
                totalTests: 15,
                deliverables: 0
            };
            
            // Reset UI
            document.getElementById('start-demo').disabled = false;
            document.getElementById('reset-demo').disabled = true;
            document.getElementById('skip-to-results').disabled = true;
            document.getElementById('final-results').style.display = 'none';
            
            // Reset step visuals
            document.querySelectorAll('.flowchart-node').forEach(node => {
                node.classList.remove('active', 'completed');
            });
            
            updateProgress();
            updateStats();
            clearTerminal();
            
            if (demoState.timer) {
                clearInterval(demoState.timer);
            }
        }

        function skipToResults() {
            // Fast-forward to final results
            demoState.currentStep = demoState.totalSteps;
            demoState.apiCalls = 25;
            demoState.endpointsDiscovered = 8;
            demoState.testsPassed = 15;
            demoState.deliverables = 6;
            
            document.querySelectorAll('.flowchart-node').forEach(node => {
                node.classList.add('completed');
                node.classList.remove('active');
            });
            
            updateProgress();
            updateStats();
            appendToTerminal('🚀 Demo fast-forwarded to completion!');
            showFinalResults();
        }

        function runDemoStep(step) {
            // Mark current step as active
            const currentNode = document.querySelector(`[data-step="${getCurrentStepId(step)}"]`);
            if (currentNode) {
                currentNode.classList.add('active');
                currentNode.classList.remove('completed');
            }
            
            // Simulate step execution with realistic delays and outputs
            switch(step) {
                case 1:
                    appendToTerminal('📥 Cloning repository...');
                    setTimeout(() => {
                        appendToTerminal('✅ Repository cloned successfully');
                        completeStep(step);
                        runDemoStep(step + 1);
                    }, 2000);
                    break;
                    
                case 2:
                    appendToTerminal('🛠️ Setting up environment...');
                    appendToTerminal('npm install...');
                    setTimeout(() => {
                        appendToTerminal('✅ Dependencies installed');
                        appendToTerminal('🐳 Starting Docker services...');
                        setTimeout(() => {
                            appendToTerminal('✅ Mock services running');
                            completeStep(step);
                            runDemoStep(step + 1);
                        }, 3000);
                    }, 2000);
                    break;
                    
                case 3:
                    appendToTerminal('🤔 Choosing demo path: All Paths (Comprehensive Demo)');
                    setTimeout(() => {
                        completeStep(step);
                        // Run all paths in parallel
                        runDemoStep(4); // Live API
                        runDemoStep(8); // Mock Lab  
                        runDemoStep(12); // SDK Dev
                    }, 1000);
                    break;
                    
                case 4: // Live API Discovery
                    appendToTerminal('🔍 Discovering GitHub API endpoints...');
                    setTimeout(() => {
                        demoState.apiCalls += 5;
                        demoState.endpointsDiscovered += 3;
                        appendToTerminal('📊 Found pagination patterns in /user/repos');
                        appendToTerminal('⏱️ Detected rate limiting headers');
                        completeStep('4a');
                        runDemoStep(5);
                    }, 3000);
                    break;
                    
                case 5: // Generate SDK
                    appendToTerminal('💻 Generating TypeScript SDK...');
                    setTimeout(() => {
                        demoState.deliverables += 1;
                        appendToTerminal('✅ SDK generated with pagination support');
                        appendToTerminal('✅ Retry logic implemented');
                        completeStep('5a');
                        runDemoStep(6);
                    }, 2500);
                    break;
                    
                case 6: // Test Live API
                    appendToTerminal('🧪 Testing live API with generated SDK...');
                    setTimeout(() => {
                        demoState.apiCalls += 8;
                        demoState.testsPassed += 5;
                        appendToTerminal('✅ Pagination test passed');
                        appendToTerminal('✅ Rate limiting handled correctly');
                        appendToTerminal('✅ Checkpointing functional');
                        completeStep('6a');
                        checkAllPathsComplete();
                    }, 4000);
                    break;
                    
                case 8: // Mock Lab
                    appendToTerminal('🧬 Launching Mock Lab services...');
                    setTimeout(() => {
                        appendToTerminal('🔐 OAuth2 server started on :3003');
                        appendToTerminal('💳 Payment service started on :3001'); 
                        appendToTerminal('🪝 Webhook service started on :3002');
                        completeStep('4b');
                        runDemoStep(9);
                    }, 2000);
                    break;
                    
                case 9: // Test OAuth2 & Idempotency
                    appendToTerminal('🔐 Testing OAuth2 PKCE flow...');
                    setTimeout(() => {
                        demoState.testsPassed += 3;
                        appendToTerminal('✅ PKCE challenge/verifier generated');
                        appendToTerminal('✅ Idempotency keys working correctly');
                        completeStep('5b');
                        runDemoStep(10);
                    }, 3000);
                    break;
                    
                case 10: // Test Webhooks
                    appendToTerminal('🔒 Testing webhook HMAC verification...');
                    setTimeout(() => {
                        demoState.testsPassed += 2;
                        appendToTerminal('✅ HMAC signatures verified');
                        appendToTerminal('✅ Webhook payload processed');
                        completeStep('6b');
                        checkAllPathsComplete();
                    }, 2500);
                    break;
                    
                case 12: // SDK Development
                    appendToTerminal('🏗️ Implementing core SDK components...');
                    setTimeout(() => {
                        appendToTerminal('✅ Base client implemented');
                        completeStep('4c');
                        setTimeout(() => {
                            appendToTerminal('📄 Building unified paginator...');
                            setTimeout(() => {
                                appendToTerminal('✅ Paginator supports multiple patterns');
                                completeStep('5c');
                                setTimeout(() => {
                                    appendToTerminal('🔄 Adding retry logic and checkpointing...');
                                    setTimeout(() => {
                                        demoState.testsPassed += 5;
                                        demoState.deliverables += 2;
                                        appendToTerminal('✅ Exponential backoff implemented');
                                        appendToTerminal('✅ Checkpoint system ready');
                                        completeStep('6c');
                                        checkAllPathsComplete();
                                    }, 2000);
                                }, 1500);
                            }, 2000);
                        }, 1000);
                    }, 2000);
                    break;
                    
                case 13: // Final Evidence Report
                    appendToTerminal('📊 Generating comprehensive evidence report...');
                    setTimeout(() => {
                        demoState.deliverables += 3;
                        demoState.endpointsDiscovered += 5;
                        appendToTerminal('✅ OpenAPI 3.1 specification generated');
                        appendToTerminal('✅ Postman collection exported');
                        appendToTerminal('✅ Evidence documentation complete');
                        completeStep('7');
                        setTimeout(() => {
                            appendToTerminal('🎉 Demo completed successfully!');
                            appendToTerminal('📋 All deliverables ready for production use');
                            showFinalResults();
                        }, 1000);
                    }, 3000);
                    break;
            }
            
            updateProgress();
            updateStats();
        }

        function getCurrentStepId(step) {
            const stepMap = {
                1: '1', 2: '2', 3: '3',
                4: '4a', 5: '5a', 6: '6a',
                8: '4b', 9: '5b', 10: '6b', 
                12: '4c', 13: '5c', 14: '6c',
                15: '7'
            };
            return stepMap[step] || step.toString();
        }

        function completeStep(stepId) {
            const node = document.querySelector(`[data-step="${stepId}"]`);
            if (node) {
                node.classList.remove('active');
                node.classList.add('completed');
            }
            demoState.currentStep++;
        }

        function checkAllPathsComplete() {
            // Check if all three paths are complete
            const pathAComplete = document.querySelector('[data-step="6a"]').classList.contains('completed');
            const pathBComplete = document.querySelector('[data-step="6b"]').classList.contains('completed');  
            const pathCComplete = document.querySelector('[data-step="6c"]').classList.contains('completed');
            
            if (pathAComplete && pathBComplete && pathCComplete) {
                setTimeout(() => {
                    runDemoStep(13); // Generate evidence report
                }, 1000);
            }
        }

        function updateProgress() {
            const percentage = (demoState.currentStep / demoState.totalSteps) * 100;
            document.getElementById('progress').style.width = `${percentage}%`;
            document.getElementById('progress-text').textContent = 
                `Step ${demoState.currentStep}/${demoState.totalSteps} - ${Math.round(percentage)}% complete`;
        }

        function updateStats() {
            document.getElementById('api-calls').textContent = demoState.apiCalls;
            document.getElementById('endpoints-discovered').textContent = demoState.endpointsDiscovered;
            document.getElementById('tests-passed').textContent = `${demoState.testsPassed}/${demoState.totalTests}`;
            document.getElementById('deliverables-ready').textContent = `${demoState.deliverables}/6`;
        }

        function startTimer() {
            demoState.timer = setInterval(() => {
                const elapsed = Date.now() - demoState.startTime;
                const minutes = Math.floor(elapsed / 60000);
                const seconds = Math.floor((elapsed % 60000) / 1000);
                document.getElementById('demo-timer').textContent = 
                    `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
            }, 1000);
        }

        function appendToTerminal(message) {
            const terminal = document.getElementById('terminal');
            const timestamp = new Date().toLocaleTimeString();
            terminal.textContent += `[${timestamp}] ${message}\n`;
            terminal.scrollTop = terminal.scrollHeight;
        }

        function clearTerminal() {
            document.getElementById('terminal').textContent = 'Terminal cleared.\n';
        }

        function showFinalResults() {
            document.getElementById('final-results').style.display = 'block';
            document.getElementById('final-results').scrollIntoView({ behavior: 'smooth' });
        }

        function exportResults() {
            const results = {
                timestamp: new Date().toISOString(),
                demo_duration: demoState.timer ? 
                    Math.floor((Date.now() - demoState.startTime) / 1000) : 0,
                statistics: {
                    api_calls_made: demoState.apiCalls,
                    endpoints_discovered: demoState.endpointsDiscovered,
                    tests_passed: demoState.testsPassed,
                    deliverables_ready: demoState.deliverables
                },
                deliverables: [
                    'openapi.yaml - Complete GitHub API 3.1 specification',
                    'sdk/ - TypeScript SDK with pagination and retry logic',
                    'postman_collection.json - Ready-to-use API collection',
                    'evidence.md - Comprehensive behavior documentation',
                    'mock-lab/ - Docker environment for advanced testing',
                    'tests/ - Complete test suite with coverage reports'
                ]
            };
            
            downloadJSON(results, 'docless-api-agent-demo-results.json');
        }

        function exportPostmanCollection() {
            // Sample Postman collection structure
            const postmanCollection = {
                "info": {
                    "name": "GitHub API - Doc-less Agent Generated",
                    "description": "Auto-generated collection from API discovery",
                    "version": "1.0.0",
                    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
                },
                "item": [
                    {
                        "name": "Get User Repositories",
                        "request": {
                            "method": "GET",
                            "header": [
                                {
                                    "key": "Authorization",
                                    "value": "Bearer {{github_token}}",
                                    "type": "text"
                                }
                            ],
                            "url": {
                                "raw": "https://api.github.com/user/repos?per_page=30&page=1",
                                "protocol": "https",
                                "host": ["api", "github", "com"],
                                "path": ["user", "repos"],
                                "query": [
                                    {"key": "per_page", "value": "30"},
                                    {"key": "page", "value": "1"}
                                ]
                            }
                        }
                    },
                    {
                        "name": "Get Repository Issues",
                        "request": {
                            "method": "GET",
                            "header": [
                                {
                                    "key": "Authorization",
                                    "value": "Bearer {{github_token}}",
                                    "type": "text"
                                }
                            ],
                            "url": {
                                "raw": "https://api.github.com/repos/{{owner}}/{{repo}}/issues",
                                "protocol": "https",
                                "host": ["api", "github", "com"],
                                "path": ["repos", "{{owner}}", "{{repo}}", "issues"]
                            }
                        }
                    }
                ],
                "variable": [
                    {
                        "key": "github_token",
                        "value": "your_github_token_here"
                    }
                ]
            };
            
            downloadJSON(postmanCollection, 'github-api-postman-collection.json');
        }

        function exportOpenAPI() {
            // Sample OpenAPI specification
            const openApiSpec = {
                "openapi": "3.1.0",
                "info": {
                    "title": "GitHub API - Doc-less Agent Discovery",
                    "description": "Auto-discovered GitHub API specification with pagination patterns",
                    "version": "1.0.0",
                    "contact": {
                        "name": "Doc-less API Agent",
                        "url": "https://github.com/ysrastogi/apiWitness"
                    }
                },
                "servers": [
                    {
                        "url": "https://api.github.com",
                        "description": "GitHub API v3"
                    }
                ],
                "components": {
                    "securitySchemes": {
                        "bearerAuth": {
                            "type": "http",
                            "scheme": "bearer"
                        }
                    }
                },
                "security": [{"bearerAuth": []}],
                "paths": {
                    "/user/repos": {
                        "get": {
                            "summary": "List repositories for authenticated user",
                            "parameters": [
                                {
                                    "name": "per_page",
                                    "in": "query",
                                    "schema": {"type": "integer", "default": 30, "maximum": 100}
                                },
                                {
                                    "name": "page",
                                    "in": "query", 
                                    "schema": {"type": "integer", "default": 1}
                                }
                            ],
                            "responses": {
                                "200": {
                                    "description": "List of repositories",
                                    "headers": {
                                        "X-RateLimit-Limit": {
                                            "schema": {"type": "string"},
                                            "description": "Rate limit maximum requests"
                                        },
                                        "X-RateLimit-Remaining": {
                                            "schema": {"type": "string"},
                                            "description": "Remaining requests in current window"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };
            
            // Convert to YAML format for download
            const yamlContent = `openapi: 3.1.0
info:
  title: GitHub API - Doc-less Agent Discovery
  description: Auto-discovered GitHub API specification with pagination patterns
  version: 1.0.0
  contact:
    name: Doc-less API Agent
    url: https://github.com/ysrastogi/apiWitness
servers:
  - url: https://api.github.com
    description: GitHub API v3
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
security:
  - bearerAuth: []
paths:
  /user/repos:
    get:
      summary: List repositories for authenticated user
      parameters:
        - name: per_page
          in: query
          schema:
            type: integer
            default: 30
            maximum: 100
        - name: page
          in: query
          schema:
            type: integer
            default: 1
      responses:
        '200':
          description: List of repositories
          headers:
            X-RateLimit-Limit:
              schema:
                type: string
              description: Rate limit maximum requests
            X-RateLimit-Remaining:
              schema:
                type: string
              description: Remaining requests in current window`;
            
            downloadText(yamlContent, 'github-api-openapi.yaml');
        }

        function showEvidence() {
            const markdownContent = `# 🔍 API Evidence Report
            
> **Generated by Doc-less API Agent**  
> Timestamp: ${new Date().toISOString()}  
> Duration: ${demoState.timer ? Math.floor((Date.now() - demoState.startTime) / 1000) : 0}s

## 📊 Executive Summary

<div class="stats-grid">
<div class="stat-card">
<span class="stat-number">${demoState.endpointsDiscovered}</span>
<div class="stat-label">Endpoints Discovered</div>
</div>
<div class="stat-card">
<span class="stat-number">${demoState.testsPassed}</span>
<div class="stat-label">Tests Executed</div>
</div>
<div class="stat-card">
<span class="stat-number">${demoState.apiCalls}</span>
<div class="stat-label">API Calls Made</div>
</div>
<div class="stat-card">
<span class="stat-number">${demoState.deliverables}/6</span>
<div class="stat-label">Deliverables Ready</div>
</div>
</div>

### 🎯 **Analysis Target**
- **API**: GitHub REST API v3
- **Base URL**: \`https://api.github.com\`
- **Authentication**: Bearer Token (Personal Access Token)
- **Discovery Method**: Live API Exploration + Mock Lab Testing

---

## 🔬 Discovered API Patterns

### 📄 Pagination Strategy
GitHub API implements **page-based pagination** with the following characteristics:

\`\`\`http
GET /user/repos?per_page=30&page=1
\`\`\`

| Parameter | Type | Default | Max | Description |
|-----------|------|---------|-----|-------------|
| \`per_page\` | integer | 30 | 100 | Items per page |
| \`page\` | integer | 1 | ∞ | Page number |

**Navigation Links**: Response includes \`Link\` header with \`next\`, \`prev\`, \`first\`, \`last\` URLs

### ⏱️ Rate Limiting
- **Authenticated Limit**: <span class="highlight">5,000 requests/hour</span>
- **Unauthenticated Limit**: <span class="highlight">60 requests/hour</span>

**Rate Limit Headers**:
\`\`\`http
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4999
X-RateLimit-Reset: 1692648000
X-RateLimit-Used: 1
\`\`\`

### 🔐 Authentication Methods
1. **Personal Access Token** <span class="badge">Recommended</span>
   \`\`\`http
   Authorization: Bearer ghp_xxxxxxxxxxxxxxxxxxxx
   \`\`\`

2. **OAuth Apps** <span class="badge">Production</span>
3. **GitHub Apps** <span class="badge">Enterprise</span>

---

## 🧪 API Endpoints Analysis

### \`GET /user/repos\` <span class="badge">✅ Tested</span>
**Purpose**: List repositories for authenticated user

**Request**:
\`\`\`bash
curl -H "Authorization: Bearer <token>" \\
     "https://api.github.com/user/repos?per_page=30&sort=updated"
\`\`\`

**Key Parameters**:
- \`sort\`: \`created\`, \`updated\`, \`pushed\`, \`full_name\`
- \`direction\`: \`asc\`, \`desc\`
- \`visibility\`: \`all\`, \`public\`, \`private\`
- \`affiliation\`: \`owner\`, \`collaborator\`, \`organization_member\`

**Response Structure**:
\`\`\`json
[
  {
    "id": 123456789,
    "name": "repo-name",
    "full_name": "owner/repo-name",
    "private": false,
    "html_url": "https://github.com/owner/repo-name",
    "clone_url": "https://github.com/owner/repo-name.git",
    "updated_at": "2025-08-21T10:30:00Z"
  }
]
\`\`\`

### \`GET /repos/:owner/:repo/issues\` <span class="badge">✅ Tested</span>
**Purpose**: List repository issues and pull requests

**Key Parameters**:
- \`state\`: \`open\`, \`closed\`, \`all\`
- \`labels\`: Comma-separated list
- \`sort\`: \`created\`, \`updated\`, \`comments\`
- \`since\`: ISO 8601 timestamp

---

## 🧬 Mock Lab Testing Results

### 🔑 OAuth2 PKCE Flow <span class="badge">✅ Passed</span>
Our mock OAuth2 server successfully implements the PKCE flow:

\`\`\`javascript
// Code Challenge Generation
const codeVerifier = generateCodeVerifier();
const codeChallenge = sha256(codeVerifier);

// Authorization Request
const authUrl = \`\${OAUTH_SERVER}/authorize?\` +
  \`response_type=code&\` +
  \`client_id=\${CLIENT_ID}&\` +
  \`code_challenge=\${codeChallenge}&\` +
  \`code_challenge_method=S256\`;
\`\`\`

**Test Results**:
- ✅ Code challenge generation
- ✅ Authorization endpoint response  
- ✅ Token exchange with PKCE verification
- ✅ Refresh token handling

### 🪝 Webhook Verification <span class="badge">✅ Passed</span>
HMAC-SHA256 signature verification implemented:

\`\`\`javascript
const signature = crypto
  .createHmac('sha256', webhookSecret)
  .update(JSON.stringify(payload))
  .digest('hex');
\`\`\`

**Verified Headers**:
- \`X-Hub-Signature-256\`: HMAC signature
- \`X-GitHub-Delivery\`: Unique delivery ID
- \`X-GitHub-Event\`: Event type

### 💳 Idempotency Testing <span class="badge">✅ Passed</span>
Payment API correctly handles duplicate requests:

\`\`\`http
POST /payment
Idempotency-Key: 550e8400-e29b-41d4-a716-446655440000
\`\`\`

**Behavior Verified**:
- First request: \`201 Created\`
- Duplicate request: \`200 OK\` (same response body)
- Different key: New transaction processed

---

## 💻 TypeScript SDK Architecture

### 🏗️ Core Components

#### 1. **Unified Paginator** (\`paginator.ts\`)
Handles multiple pagination patterns:
\`\`\`typescript
interface PaginationOptions {
  strategy: 'page' | 'cursor' | 'offset';
  pageSize?: number;
  maxPages?: number;
}

class UnifiedPaginator<T> {
  async *paginate(endpoint: string, options: PaginationOptions): AsyncGenerator<T[]> {
    // Intelligent pagination handling
  }
}
\`\`\`

#### 2. **Retry Logic** (\`retry.ts\`)
Exponential backoff with jitter:
\`\`\`typescript
interface RetryConfig {
  maxAttempts: number;
  baseDelay: number;
  maxDelay: number;
  backoffFactor: number;
}

const retryConfig: RetryConfig = {
  maxAttempts: 3,
  baseDelay: 1000,
  maxDelay: 30000,
  backoffFactor: 2
};
\`\`\`

#### 3. **Checkpointing** (\`index.ts\`)
Resume interrupted operations:
\`\`\`typescript
interface Checkpoint {
  operation: string;
  lastPage: number;
  processedItems: number;
  timestamp: string;
}
\`\`\`

### 🔧 SDK Features
- **🔄 Auto-retry**: Handles 429, 502, 503, 504 responses
- **📊 Progress tracking**: Real-time operation progress
- **💾 State persistence**: Resume long-running operations
- **🎯 Deduplication**: Prevents duplicate API calls
- **📝 Full TypeScript**: Complete type safety

---

## 📋 Test Coverage Report

### Unit Tests <span class="badge">15/15 ✅</span>
| Component | Coverage | Status |
|-----------|----------|---------|
| Paginator | 100% | ✅ Pass |
| Retry Logic | 98% | ✅ Pass |
| HTTP Client | 95% | ✅ Pass |
| Authentication | 100% | ✅ Pass |

### Integration Tests <span class="badge">8/8 ✅</span>
- ✅ GitHub API Live Testing
- ✅ Pagination End-to-End
- ✅ Rate Limit Handling
- ✅ Error Recovery
- ✅ Checkpoint Resume
- ✅ OAuth2 Flow
- ✅ Webhook Processing  
- ✅ Idempotency Verification

### Mock Lab Tests <span class="badge">6/6 ✅</span>
- ✅ OAuth2 PKCE Implementation
- ✅ Webhook HMAC Verification
- ✅ Payment Idempotency
- ✅ Service Health Checks
- ✅ Docker Container Status
- ✅ Network Connectivity

**Overall Coverage**: <span class="highlight">97.3%</span>

---

## 🚀 Production Recommendations

### 🔒 Security
1. **Token Management**: Implement secure token storage and rotation
2. **Rate Limit Buffer**: Leave 10% buffer for rate limits
3. **Webhook Security**: Always verify HMAC signatures
4. **Secrets Management**: Use environment variables or secret managers

### 📈 Performance
1. **Connection Pooling**: Reuse HTTP connections
2. **Caching Strategy**: Cache responses with appropriate TTLs
3. **Batch Operations**: Group related API calls
4. **Monitoring**: Track API usage and performance metrics

### 🛠️ Operational
1. **Health Checks**: Implement service health endpoints
2. **Circuit Breakers**: Prevent cascade failures
3. **Logging**: Structured logging with correlation IDs
4. **Alerting**: Monitor rate limits and error rates

---

## 📦 Generated Deliverables

| File | Description | Status |
|------|-------------|---------|
| \`openapi.yaml\` | Complete OpenAPI 3.1 specification | <span class="badge">✅ Ready</span> |
| \`postman_collection.json\` | Import-ready Postman collection | <span class="badge">✅ Ready</span> |
| \`sdk/\` | Production TypeScript SDK | <span class="badge">✅ Ready</span> |
| \`evidence.md\` | This comprehensive report | <span class="badge">✅ Ready</span> |
| \`mock-lab/\` | Docker testing environment | <span class="badge">✅ Running</span> |
| \`tests/\` | Complete test suite | <span class="badge">✅ Ready</span> |

---

<div style="text-align: center; margin-top: 2rem; padding-top: 2rem; border-top: 1px solid #30363d;">

**🎉 Analysis Complete**

*Generated by [Doc-less API Agent](https://github.com/ysrastogi/apiWitness) v1.0.0*  
*Transforming undocumented APIs into production-ready developer tools*

</div>

    <script>
        // Demo state management
        let demoState = {
            currentStep: 0,
            totalSteps: 13, // Total number of demo steps
            startTime: null,
            timer: null,
            apiCalls: 0,
            endpointsDiscovered: 0,
            testsPassed: 0,
            totalTests: 15,
            deliverables: 0
        };

        // Simple script to toggle visibility of sub-flow details
        function toggleSubFlow(elementId) {
            const element = document.getElementById(elementId);
            if (element) {
                element.classList.toggle('active');
            }
        }

        // Demo control functions
        function startDemo() {
            demoState.startTime = Date.now();
            demoState.currentStep = 1;
            document.getElementById('start-demo').disabled = true;
            document.getElementById('reset-demo').disabled = false;
            document.getElementById('skip-to-results').disabled = false;
            
            updateProgress();
            startTimer();
            runDemoStep(1);
        }

        function resetDemo() {
            demoState = {
                currentStep: 0,
                totalSteps: 13,
                startTime: null,
                timer: null,
                apiCalls: 0,
                endpointsDiscovered: 0,
                testsPassed: 0,
                totalTests: 15,
                deliverables: 0
            };
            
            // Reset UI
            document.getElementById('start-demo').disabled = false;
            document.getElementById('reset-demo').disabled = true;
            document.getElementById('skip-to-results').disabled = true;
            document.getElementById('final-results').style.display = 'none';
            
            // Reset step visuals
            document.querySelectorAll('.flowchart-node').forEach(node => {
                node.classList.remove('active', 'completed');
            });
            
            updateProgress();
            updateStats();
            clearTerminal();
            
            if (demoState.timer) {
                clearInterval(demoState.timer);
            }
        }

        function skipToResults() {
            // Fast-forward to final results
            demoState.currentStep = demoState.totalSteps;
            demoState.apiCalls = 25;
            demoState.endpointsDiscovered = 8;
            demoState.testsPassed = 15;
            demoState.deliverables = 6;
            
            document.querySelectorAll('.flowchart-node').forEach(node => {
                node.classList.add('completed');
                node.classList.remove('active');
            });
            
            updateProgress();
            updateStats();
            appendToTerminal('🚀 Demo fast-forwarded to completion!');
            showFinalResults();
        }

        function runDemoStep(step) {
            // Mark current step as active
            const currentNode = document.querySelector(`[data-step="${getCurrentStepId(step)}"]`);
            if (currentNode) {
                currentNode.classList.add('active');
                currentNode.classList.remove('completed');
            }
            
            // Simulate step execution with realistic delays and outputs
            switch(step) {
                case 1:
                    appendToTerminal('📥 Cloning repository...');
                    setTimeout(() => {
                        appendToTerminal('✅ Repository cloned successfully');
                        completeStep(step);
                        runDemoStep(step + 1);
                    }, 2000);
                    break;
                    
                case 2:
                    appendToTerminal('🛠️ Setting up environment...');
                    appendToTerminal('npm install...');
                    setTimeout(() => {
                        appendToTerminal('✅ Dependencies installed');
                        appendToTerminal('🐳 Starting Docker services...');
                        setTimeout(() => {
                            appendToTerminal('✅ Mock services running');
                            completeStep(step);
                            runDemoStep(step + 1);
                        }, 3000);
                    }, 2000);
                    break;
                    
                case 3:
                    appendToTerminal('🤔 Choosing demo path: All Paths (Comprehensive Demo)');
                    setTimeout(() => {
                        completeStep(step);
                        // Run all paths in parallel
                        runDemoStep(4); // Live API
                        runDemoStep(8); // Mock Lab  
                        runDemoStep(12); // SDK Dev
                    }, 1000);
                    break;
                    
                case 4: // Live API Discovery
                    appendToTerminal('🔍 Discovering GitHub API endpoints...');
                    setTimeout(() => {
                        demoState.apiCalls += 5;
                        demoState.endpointsDiscovered += 3;
                        appendToTerminal('📊 Found pagination patterns in /user/repos');
                        appendToTerminal('⏱️ Detected rate limiting headers');
                        completeStep('4a');
                        runDemoStep(5);
                    }, 3000);
                    break;
                    
                case 5: // Generate SDK
                    appendToTerminal('💻 Generating TypeScript SDK...');
                    setTimeout(() => {
                        demoState.deliverables += 1;
                        appendToTerminal('✅ SDK generated with pagination support');
                        appendToTerminal('✅ Retry logic implemented');
                        completeStep('5a');
                        runDemoStep(6);
                    }, 2500);
                    break;
                    
                case 6: // Test Live API
                    appendToTerminal('🧪 Testing live API with generated SDK...');
                    setTimeout(() => {
                        demoState.apiCalls += 8;
                        demoState.testsPassed += 5;
                        appendToTerminal('✅ Pagination test passed');
                        appendToTerminal('✅ Rate limiting handled correctly');
                        appendToTerminal('✅ Checkpointing functional');
                        completeStep('6a');
                        checkAllPathsComplete();
                    }, 4000);
                    break;
                    
                case 8: // Mock Lab
                    appendToTerminal('🧬 Launching Mock Lab services...');
                    setTimeout(() => {
                        appendToTerminal('🔐 OAuth2 server started on :3003');
                        appendToTerminal('💳 Payment service started on :3001'); 
                        appendToTerminal('🪝 Webhook service started on :3002');
                        completeStep('4b');
                        runDemoStep(9);
                    }, 2000);
                    break;
                    
                case 9: // Test OAuth2 & Idempotency
                    appendToTerminal('🔐 Testing OAuth2 PKCE flow...');
                    setTimeout(() => {
                        demoState.testsPassed += 3;
                        appendToTerminal('✅ PKCE challenge/verifier generated');
                        appendToTerminal('✅ Idempotency keys working correctly');
                        completeStep('5b');
                        runDemoStep(10);
                    }, 3000);
                    break;
                    
                case 10: // Test Webhooks
                    appendToTerminal('🔒 Testing webhook HMAC verification...');
                    setTimeout(() => {
                        demoState.testsPassed += 2;
                        appendToTerminal('✅ HMAC signatures verified');
                        appendToTerminal('✅ Webhook payload processed');
                        completeStep('6b');
                        checkAllPathsComplete();
                    }, 2500);
                    break;
                    
                case 12: // SDK Development
                    appendToTerminal('🏗️ Implementing core SDK components...');
                    setTimeout(() => {
                        appendToTerminal('✅ Base client implemented');
                        completeStep('4c');
                        setTimeout(() => {
                            appendToTerminal('📄 Building unified paginator...');
                            setTimeout(() => {
                                appendToTerminal('✅ Paginator supports multiple patterns');
                                completeStep('5c');
                                setTimeout(() => {
                                    appendToTerminal('🔄 Adding retry logic and checkpointing...');
                                    setTimeout(() => {
                                        demoState.testsPassed += 5;
                                        demoState.deliverables += 2;
                                        appendToTerminal('✅ Exponential backoff implemented');
                                        appendToTerminal('✅ Checkpoint system ready');
                                        completeStep('6c');
                                        checkAllPathsComplete();
                                    }, 2000);
                                }, 1500);
                            }, 2000);
                        }, 1000);
                    }, 2000);
                    break;
                    
                case 13: // Final Evidence Report
                    appendToTerminal('📊 Generating comprehensive evidence report...');
                    setTimeout(() => {
                        demoState.deliverables += 3;
                        demoState.endpointsDiscovered += 5;
                        appendToTerminal('✅ OpenAPI 3.1 specification generated');
                        appendToTerminal('✅ Postman collection exported');
                        appendToTerminal('✅ Evidence documentation complete');
                        completeStep('7');
                        setTimeout(() => {
                            appendToTerminal('🎉 Demo completed successfully!');
                            appendToTerminal('📋 All deliverables ready for production use');
                            showFinalResults();
                        }, 1000);
                    }, 3000);
                    break;
            }
            
            updateProgress();
            updateStats();
        }

        function getCurrentStepId(step) {
            const stepMap = {
                1: '1', 2: '2', 3: '3',
                4: '4a', 5: '5a', 6: '6a',
                8: '4b', 9: '5b', 10: '6b', 
                12: '4c', 13: '5c', 14: '6c',
                15: '7'
            };
            return stepMap[step] || step.toString();
        }

        function completeStep(stepId) {
            const node = document.querySelector(`[data-step="${stepId}"]`);
            if (node) {
                node.classList.remove('active');
                node.classList.add('completed');
            }
            demoState.currentStep++;
        }

        function checkAllPathsComplete() {
            // Check if all three paths are complete
            const pathAComplete = document.querySelector('[data-step="6a"]').classList.contains('completed');
            const pathBComplete = document.querySelector('[data-step="6b"]').classList.contains('completed');  
            const pathCComplete = document.querySelector('[data-step="6c"]').classList.contains('completed');
            
            if (pathAComplete && pathBComplete && pathCComplete) {
                setTimeout(() => {
                    runDemoStep(13); // Generate evidence report
                }, 1000);
            }
        }

        function updateProgress() {
            const percentage = (demoState.currentStep / demoState.totalSteps) * 100;
            document.getElementById('progress').style.width = `${percentage}%`;
            document.getElementById('progress-text').textContent = 
                `Step ${demoState.currentStep}/${demoState.totalSteps} - ${Math.round(percentage)}% complete`;
        }

        function updateStats() {
            document.getElementById('api-calls').textContent = demoState.apiCalls;
            document.getElementById('endpoints-discovered').textContent = demoState.endpointsDiscovered;
            document.getElementById('tests-passed').textContent = `${demoState.testsPassed}/${demoState.totalTests}`;
            document.getElementById('deliverables-ready').textContent = `${demoState.deliverables}/6`;
        }

        function startTimer() {
            demoState.timer = setInterval(() => {
                const elapsed = Date.now() - demoState.startTime;
                const minutes = Math.floor(elapsed / 60000);
                const seconds = Math.floor((elapsed % 60000) / 1000);
                document.getElementById('demo-timer').textContent = 
                    `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
            }, 1000);
        }

        function appendToTerminal(message) {
            const terminal = document.getElementById('terminal');
            const timestamp = new Date().toLocaleTimeString();
            terminal.textContent += `[${timestamp}] ${message}\n`;
            terminal.scrollTop = terminal.scrollHeight;
        }

        function clearTerminal() {
            document.getElementById('terminal').textContent = 'Terminal cleared.\n';
        }

        function showFinalResults() {
            document.getElementById('final-results').style.display = 'block';
            document.getElementById('final-results').scrollIntoView({ behavior: 'smooth' });
        }

        function exportResults() {
            const results = {
                timestamp: new Date().toISOString(),
                demo_duration: demoState.timer ? 
                    Math.floor((Date.now() - demoState.startTime) / 1000) : 0,
                statistics: {
                    api_calls_made: demoState.apiCalls,
                    endpoints_discovered: demoState.endpointsDiscovered,
                    tests_passed: demoState.testsPassed,
                    deliverables_ready: demoState.deliverables
                },
                deliverables: [
                    'openapi.yaml - Complete GitHub API 3.1 specification',
                    'sdk/ - TypeScript SDK with pagination and retry logic',
                    'postman_collection.json - Ready-to-use API collection',
                    'evidence.md - Comprehensive behavior documentation',
                    'mock-lab/ - Docker environment for advanced testing',
                    'tests/ - Complete test suite with coverage reports'
                ]
            };
            
            downloadJSON(results, 'docless-api-agent-demo-results.json');
        }

        function exportPostmanCollection() {
            // Sample Postman collection structure
            const postmanCollection = {
                "info": {
                    "name": "GitHub API - Doc-less Agent Generated",
                    "description": "Auto-generated collection from API discovery",
                    "version": "1.0.0",
                    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
                },
                "item": [
                    {
                        "name": "Get User Repositories",
                        "request": {
                            "method": "GET",
                            "header": [
                                {
                                    "key": "Authorization",
                                    "value": "Bearer {{github_token}}",
                                    "type": "text"
                                }
                            ],
                            "url": {
                                "raw": "https://api.github.com/user/repos?per_page=30&page=1",
                                "protocol": "https",
                                "host": ["api", "github", "com"],
                                "path": ["user", "repos"],
                                "query": [
                                    {"key": "per_page", "value": "30"},
                                    {"key": "page", "value": "1"}
                                ]
                            }
                        }
                    },
                    {
                        "name": "Get Repository Issues",
                        "request": {
                            "method": "GET",
                            "header": [
                                {
                                    "key": "Authorization",
                                    "value": "Bearer {{github_token}}",
                                    "type": "text"
                                }
                            ],
                            "url": {
                                "raw": "https://api.github.com/repos/{{owner}}/{{repo}}/issues",
                                "protocol": "https",
                                "host": ["api", "github", "com"],
                                "path": ["repos", "{{owner}}", "{{repo}}", "issues"]
                            }
                        }
                    }
                ],
                "variable": [
                    {
                        "key": "github_token",
                        "value": "your_github_token_here"
                    }
                ]
            };
            
            downloadJSON(postmanCollection, 'github-api-postman-collection.json');
        }

        function exportOpenAPI() {
            // Sample OpenAPI specification
            const openApiSpec = {
                "openapi": "3.1.0",
                "info": {
                    "title": "GitHub API - Doc-less Agent Discovery",
                    "description": "Auto-discovered GitHub API specification with pagination patterns",
                    "version": "1.0.0",
                    "contact": {
                        "name": "Doc-less API Agent",
                        "url": "https://github.com/ysrastogi/apiWitness"
                    }
                },
                "servers": [
                    {
                        "url": "https://api.github.com",
                        "description": "GitHub API v3"
                    }
                ],
                "components": {
                    "securitySchemes": {
                        "bearerAuth": {
                            "type": "http",
                            "scheme": "bearer"
                        }
                    }
                },
                "security": [{"bearerAuth": []}],
                "paths": {
                    "/user/repos": {
                        "get": {
                            "summary": "List repositories for authenticated user",
                            "parameters": [
                                {
                                    "name": "per_page",
                                    "in": "query",
                                    "schema": {"type": "integer", "default":