forked from xcratch/xcx-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxcratchExample.mjs
More file actions
1431 lines (1347 loc) · 57.7 KB
/
xcratchExample.mjs
File metadata and controls
1431 lines (1347 loc) · 57.7 KB
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
var img$2 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAAwnpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHjabVDbDcMgDPz3FB0BP3iNQxoqdYOOX4MdFKqexGHfRRdj6J/3Cx4DhAISc0k1paCQKpWaFiUY2mQMMnmCLg93HZZBKrHebG1J/v2l4wqwq2kVb0Hl6caxG1XWBHuQ/4jHRKTF6UHVg5jMQA9o9qyQasn3Jxw97Ch2YBDnmb1CfnvJur0zqshEnZGDMnOxAXicCNy0QGMyuWmflZnRJ9GF/NvTBfgC85BZHr9RmhMAAAGEaUNDUElDQyBwcm9maWxlAAB4nH2RPUjDUBSFT9MWRSoOdhBxyFA72UVFHGsVilAh1AqtOpi89A+aNCQpLo6Ca8HBn8Wqg4uzrg6ugiD4A+IuOCm6SIn3JYUWMV54vI/z7jm8dx8gtGpMs0JJQNNtM5tOifnCqtj3igAEhBBGXGaWMSdJGfjW1z11U90leJZ/3581qBYtBgRE4iQzTJt4g3hm0zY47xNHWUVWic+JJ0y6IPEj1xWP3ziXXRZ4ZtTMZeeJo8RiuYeVHmYVUyOeJo6pmk75Qt5jlfMWZ63WYJ178hdGivrKMtdpjSGNRSxBgggFDVRRg40E7TopFrJ0nvLxj7p+iVwKuapg5FhAHRpk1w/+B79na5WmJr2kSAoIvzjOxzjQtwu0m47zfew47RMg+Axc6V1/vQXMfpLe7GqxI2BoG7i47mrKHnC5A4w8GbIpu1KQllAqAe9n9E0FYPgWGFjz5tY5x+kDkKNZZW6Ag0MgXqbsdZ939/fO7d+ezvx+ABzKcoSTAO0SAAANemlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNC40LjAtRXhpdjIiPgogPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iCiAgICB4bWxuczpzdEV2dD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlRXZlbnQjIgogICAgeG1sbnM6R0lNUD0iaHR0cDovL3d3dy5naW1wLm9yZy94bXAvIgogICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iCiAgICB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iCiAgIHhtcE1NOkRvY3VtZW50SUQ9ImdpbXA6ZG9jaWQ6Z2ltcDpkZWNhYWNiNy04ZTg4LTRmYWItYmRjNC03OTM3NDQ2MjI2YzciCiAgIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6NzY4NTE3YzYtNWQwOC00ZTJlLWJiZGYtNDAzZWYwYzcwOTYzIgogICB4bXBNTTpPcmlnaW5hbERvY3VtZW50SUQ9InhtcC5kaWQ6YTI1MmM0OTctMDM2NS00MWU3LTlmYjItNzM2MzIwODVlMzdhIgogICBHSU1QOkFQST0iMi4wIgogICBHSU1QOlBsYXRmb3JtPSJNYWMgT1MiCiAgIEdJTVA6VGltZVN0YW1wPSIxNzM1NzkxNDY4NTE5NzMwIgogICBHSU1QOlZlcnNpb249IjIuMTAuMzgiCiAgIGRjOkZvcm1hdD0iaW1hZ2UvcG5nIgogICB0aWZmOk9yaWVudGF0aW9uPSIxIgogICB4bXA6Q3JlYXRvclRvb2w9IkdJTVAgMi4xMCIKICAgeG1wOk1ldGFkYXRhRGF0ZT0iMjAyNTowMTowMVQyMDoxNzozMS0wODowMCIKICAgeG1wOk1vZGlmeURhdGU9IjIwMjU6MDE6MDFUMjA6MTc6MzEtMDg6MDAiPgogICA8eG1wTU06SGlzdG9yeT4KICAgIDxyZGY6U2VxPgogICAgIDxyZGY6bGkKICAgICAgc3RFdnQ6YWN0aW9uPSJzYXZlZCIKICAgICAgc3RFdnQ6Y2hhbmdlZD0iLyIKICAgICAgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDozOGZiZjdhYy01ZjFlLTRlZGYtYTczMi02MDE4M2ZiZTYzMTQiCiAgICAgIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkdpbXAgMi4xMCAoTWFjIE9TKSIKICAgICAgc3RFdnQ6d2hlbj0iMjAyNS0wMS0wMVQyMDoxNzo0OC0wODowMCIvPgogICAgPC9yZGY6U2VxPgogICA8L3htcE1NOkhpc3Rvcnk+CiAgPC9yZGY6RGVzY3JpcHRpb24+CiA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgCjw/eHBhY2tldCBlbmQ9InciPz6i0ujuAAAABGdBTUEAALGPC/xhBQAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB+kBAgQRMBj/urEAAAR3SURBVFjD7ZhvaNVlFMc/5/ld7+42vZu7m5QZWv7JqWuNeuGbCEIIwfVPpgVjmIXhq4TAoBe9CDKyVxWhYLRGfy2DoDdREYVmKZIj0GtoZWuluWndu3l33d09pxf7/ebvrt07Z8uk7oEHfjzn/M7zfc6/5zwPXOUk/8aiZiaAC68vIiNXBUAfXHjtAKwH5EUkd9kAQzsHMMBExC4XrA70ikRnQTQe6I0AKiLDU961mcXMrMLMImbm/Llp8UDu4DbRTJ/zdcfMLDIVcJ6ZVZpZ1P92lstMe2gMf9QhlssEICumAjBmZjPMzMv3fiHDH2/8x+J25PAL4ntnhpm5SwEXCYRHkm/IlUoi31PepQL09PzpK5btpvnAioUWVLhDYb/CeYXTCp9qS8tdQSIYfG5gNpq9QRpHFLYq/KhwQeGkwksKDb7OCoVtCqd8/rcKrePW7Q/0BkMbGh4sSECFOoWUwj0GMYU5Co9oPP5kwe6gNgxQYYfCfoNbFaoNblF4UeF2n9+l8InCMoVZCq0KZxTWhAEqLCpSK8eEmhQyCrNKCYYBKiz0rX3thDUOblAYUEiMm39I4XApgH/1O4jCBwq9Bq8pbFFYMYHcGECDNoNDRYvwqLUOTKDjRgW10ZNjYhfDA4G8848Tc3AvcLfBN0AzsFdha6lNTdc5b7BYQILh4J3Jj6FRCyTHzSVCFlyqkDG4psj/CydyscEGhe6puniVwqsKtylUK8z1A7xzXMa2K/wQUt6l8KVCi0GVH8s7Q0nyZpAkBjMV1ij8Fs7kSwKoME+hU+EnhazCzwovK8R9/ocKOYVjCneGQFcpPK/wnf9fr8JOg3qfH1N41i9bwwpHbDSUSpeZUAyWqUxl+t9S2hI2nfreJTuhvrHeP5VI9Mu4qu+ca5nZ19c91cWa7hvqz3usPLqn8sTfBV5wOVHnFtf29Z24mjxV8vb0+46aBc6L7AXmAIOIvR+vObdZ1pEHSGvddoV2ARXYEnfn9pTSV5Wc9zXYzSBqcEDMtWeW9ZwK+LsZ2g60jzZXbFlPbE9BW+1Uj6cTCUsnEpZKJF6ZvTl1smbT2etrNp2tsJGRRZgsS/9Rv/riMSXdKtbokA6QXf1aFy8FMNPYuzLT+EtVJubVi1m3ufzjhRKuW4g1gnWA7XodjZd0sXXOj6Vzg08hthpkPkatiF0X8Gvd2bf8z89SmuiZgS0HvipqwWPzHsasw7L5pTipE7UCi6+nYkzfboZ6ogwtL3m1S48MPgPW5InbmIvZArBdWLE+z6KOSKaYrsrk3FbgCRF72pP8cjE2ICV7xqgRyUQm6cNqEY5Ue9VJG87cZJJvwS626ymtXxKX6p6UDbYJVM6UvmTR7lWkFuzXmF04eD4fnS0RWzX+0eRtskuyVPRUMdQGVDqiyUmeGOQ5jPfSuYHHENmHkZax+wp5wbrSNtDshKOKWyvC2JuKp3K86f7sxfjbmVxx6tHWtiFiZ8Tje5BDofsXhuU9pKuKbLMgR8Fbu44pvtGUqUxlKtN/kP4Egx95ZY5U9OQAAAAASUVORK5CYII=";
var img$1 = "data:image/svg+xml,%3c%3fxml version='1.0' encoding='UTF-8' standalone='no'%3f%3e%3c!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg width='100%25' height='100%25' viewBox='0.0 0.0 53.0 53.0' fill='none' stroke='none' stroke-linecap='square' stroke-miterlimit='10' xmlns:xlink='http://www.w3.org/1999/xlink' xmlns='http://www.w3.org/2000/svg'><clipPath id='p.0'><path d='m0 0l53.0 0l0 53.0l-53.0 0l0 -53.0z' clip-rule='nonzero'/></clipPath><g clip-path='url(#p.0)'><path fill='#000000' fill-opacity='0.0' d='m0 0l53.0 0l0 53.0l-53.0 0z' fill-rule='evenodd'/><path fill='#000000' fill-opacity='0.0' d='m2.9107547 6.515748l47.181103 0l0 39.968506l-47.181103 0z' fill-rule='evenodd'/><path fill='#ff0000' d='m11.035754 13.047623l-3.5468745 0l0 -1.1875q0 -0.578125 -0.0625 -0.671875q-0.0625 -0.09375 -0.203125 -0.09375q-0.15625 0 -0.25 0.15625q-0.09375 0.15625 -0.09375 0.578125q0 0.5625 0.140625 0.84375q0.125 0.25 0.828125 0.65625q2.2499995 1.34375 2.8437495 2.21875q0.625 0.90625 0.625 2.84375q0 1.40625 -0.359375 2.109375q-0.34375 0.703125 -1.3125 1.171875q-0.96875 0.46875 -2.2343745 0.46875q-1.375 0 -2.390625 -0.53125q-1.0 -0.546875 -1.3125 -1.375q-0.3125 -0.84375 -0.3125 -2.3125l0 -1.078125l3.5625 0l0 1.78125q0 0.640625 0.0625 0.765625q0.078125 0.109375 0.265625 0.109375q0.1875 0 0.296875 -0.171875q0.109375 -0.171875 0.109375 -0.609375q0 -1.015625 -0.25 -1.28125q-0.296875 -0.328125 -1.484375 -1.125q-1.25 -0.8125 -1.6875 -1.203125q-0.421875 -0.40625 -0.703125 -1.09375q-0.265625 -0.703125 -0.265625 -1.75q0 -1.515625 0.390625 -2.25q0.40625 -0.734375 1.296875 -1.140625q0.890625 -0.421875 2.125 -0.421875q1.3281245 0 2.2968745 0.453125q0.984375 0.4375 1.296875 1.140625q0.328125 0.703125 0.328125 2.25l0 0.75zm5.8359385 -4.328125l0 8.703125q0 1.921875 -0.046875 2.5q-0.03125 0.578125 -0.40625 1.078125q-0.359375 0.5 -0.96875095 0.6875q-0.59375 0.1875 -1.71875 0.1875l-1.90625 0l0 -2.75q0.5625 0.0625 0.6875 0.0625q0.25 0 0.375 -0.109375q0.140625 -0.109375 0.15625 -0.296875q0.03125 -0.203125 0.03125 -0.90625l0 -9.15625l3.796876 0zm9.453125 6.015625l-3.796875 0l0 -2.453125q0 -0.90625 -0.0625 -1.046875q-0.0625 -0.140625 -0.25 -0.140625q-0.234375 0 -0.3125 0.1875q-0.0625 0.1875 -0.0625 1.109375l0 5.875q0 0.875 0.0625 1.0625q0.078125 0.171875 0.28125 0.171875q0.203125 0 0.265625 -0.171875q0.078125 -0.1875 0.078125 -1.1875l0 -1.828125l3.796875 0l0 0.734375q0 2.015625 -0.3125 2.890625q-0.296875 0.875 -1.3125 1.546875q-1.0 0.65625 -2.46875 0.65625q-1.515625 0 -2.53125 -0.5625q-1.0 -0.5625 -1.328125 -1.546875q-0.328125 -1.0 -0.328125 -2.90625l0 -3.6875q0 -1.390625 0.09375 -2.109375q0.109375 -0.71875 0.609375 -1.40625q0.515625 -0.6875 1.390625 -1.078125q0.875 -0.390625 2.0 -0.390625q1.515625 0 2.53125 0.609375q1.015625 0.59375 1.328125 1.5q0.328125 0.90625 0.328125 2.71875l0 1.453125zm9.1875 1.640625q0 1.921875 -0.09375 2.765625q-0.09375 0.828125 -0.609375 1.546875q-0.515625 0.703125 -1.375 1.078125q-0.859375 0.375 -1.96875 0.375q-1.0625 0 -1.9375 -0.359375q-0.859375 -0.359375 -1.390625 -1.078125q-0.53125 -0.71875 -0.640625 -1.53125q-0.09375 -0.828125 -0.09375 -2.796875l0 -2.15625q0 -1.921875 0.09375 -2.75q0.109375 -0.84375 0.609375 -1.546875q0.515625 -0.71875 1.375 -1.09375q0.859375 -0.375 1.984375 -0.375q1.0625 0 1.921875 0.359375q0.859375 0.359375 1.390625 1.078125q0.53125 0.71875 0.625 1.546875q0.109375 0.8125 0.109375 2.78125l0 2.15625zm-3.78125 -4.15625q0 -0.828125 -0.0625 -0.96875q-0.0625 -0.15625 -0.1875 -0.15625q-0.125 0 -0.203125 0.125q-0.078125 0.109375 -0.078125 1.0l0 5.90625q0 1.0625 0.046875 1.21875q0.0625 0.15625 0.203125 0.15625q0.15625 0 0.21875 -0.1875q0.0625 -0.1875 0.0625 -1.28125l0 -5.8125zm5.0078125 -3.5l5.984375 0l0 3.03125l-2.1875 0l0 1.90625l2.046875 0l0 2.90625l-2.046875 0l0 2.28125l2.40625 0l0 3.03125l-6.203125 0l0 -13.15625z' fill-rule='nonzero'/><path fill='#ff0000' d='m3.5670047 28.419497l5.5781245 0l0 2.53125l-2.2812495 0l0 2.406248l2.0312495 0l0 2.40625l-2.0312495 0l0 5.3125l-3.296875 0l0 -12.656248z' fill-rule='nonzero'/><path fill='#ff9900' d='m12.668567 34.71637l-2.96875 0l0 -0.6875q0 -1.203125 0.28125 -1.859375q0.28125 -0.6562481 1.109375 -1.1562481q0.84375 -0.5 2.171875 -0.5q1.609375 0 2.421875 0.578125q0.81250095 0.5625 0.96875095 1.3906231q0.171875 0.8125 0.171875 3.390625l0 5.203125l-3.078126 0l0 -0.921875q-0.28125 0.546875 -0.75 0.828125q-0.453125 0.28125 -1.078125 0.28125q-0.828125 0 -1.53125 -0.46875q-0.6875 -0.46875 -0.6875 -2.03125l0 -0.859375q0 -1.15625 0.359375 -1.578125q0.375 -0.421875 1.828125 -0.984375q1.5625 -0.609375 1.671875 -0.8125q0.109375 -0.21875 0.109375 -0.875q0 -0.8125 -0.125 -1.046875q-0.125 -0.25 -0.40625 -0.25q-0.3125 0 -0.390625 0.203125q-0.078125 0.203125 -0.078125 1.078125l0 1.078125zm1.0 1.421875q-0.765625 0.5625 -0.890625 0.9375q-0.109375 0.375 -0.109375 1.078125q0 0.796875 0.09375 1.03125q0.109375 0.234375 0.421875 0.234375q0.296875 0 0.390625 -0.171875q0.09375 -0.1875 0.09375 -0.96875l0 -2.140625z' fill-rule='nonzero'/><path fill='#ffff00' d='m21.059193 28.419497l0 3.0q0.390625 -0.453125 0.875 -0.671875q0.484375 -0.234375 1.046875 -0.234375q0.640625 0 1.109375 0.203125q0.484375 0.203125 0.734375 0.578125q0.25 0.359375 0.296875 0.7187481q0.0625 0.34375 0.0625 1.5l0 4.671875q0 1.140625 -0.15625 1.703125q-0.15625 0.546875 -0.71875 0.96875q-0.5625 0.40625 -1.328125 0.40625q-0.5625 0 -1.046875 -0.234375q-0.46875 -0.25 -0.875 -0.734375l-0.203125 0.78125l-2.953125 0l0 -12.656248l3.15625 0zm0.96875 5.234373q0 -0.8125 -0.109375 -1.046875q-0.09375 -0.25 -0.390625 -0.25q-0.296875 0 -0.390625 0.21875q-0.078125 0.203125 -0.078125 1.078125l0 4.46875q0 0.828125 0.09375 1.0625q0.109375 0.234375 0.390625 0.234375q0.296875 0 0.390625 -0.234375q0.09375 -0.25 0.09375 -1.171875l0 -4.359375z' fill-rule='nonzero'/><path fill='#0000ff' d='m29.606068 28.419497l0 10.124998l2.0 0l0 2.53125l-5.296875 0l0 -12.656248l3.296875 0z' fill-rule='nonzero'/><path fill='#00ff00' d='m35.129505 34.71637l-2.96875 0l0 -0.6875q0 -1.203125 0.28125 -1.859375q0.28125 -0.6562481 1.109375 -1.1562481q0.84375 -0.5 2.171875 -0.5q1.609375 0 2.421875 0.578125q0.8125 0.5625 0.96875 1.3906231q0.171875 0.8125 0.171875 3.390625l0 5.203125l-3.078125 0l0 -0.921875q-0.28125 0.546875 -0.75 0.828125q-0.453125 0.28125 -1.078125 0.28125q-0.828125 0 -1.53125 -0.46875q-0.6875 -0.46875 -0.6875 -2.03125l0 -0.859375q0 -1.15625 0.359375 -1.578125q0.375 -0.421875 1.828125 -0.984375q1.5625 -0.609375 1.671875 -0.8125q0.109375 -0.21875 0.109375 -0.875q0 -0.8125 -0.125 -1.046875q-0.125 -0.25 -0.40625 -0.25q-0.3125 0 -0.390625 0.203125q-0.078125 0.203125 -0.078125 1.078125l0 1.078125zm1.0 1.421875q-0.765625 0.5625 -0.890625 0.9375q-0.109375 0.375 -0.109375 1.078125q0 0.796875 0.09375 1.03125q0.109375 0.234375 0.421875 0.234375q0.296875 0 0.390625 -0.171875q0.09375 -0.1875 0.09375 -0.96875l0 -2.140625z' fill-rule='nonzero'/><path fill='#9900ff' d='m43.52013 28.419497l0 3.0q0.390625 -0.453125 0.875 -0.671875q0.484375 -0.234375 1.046875 -0.234375q0.640625 0 1.109375 0.203125q0.484375 0.203125 0.734375 0.578125q0.25 0.359375 0.296875 0.7187481q0.0625 0.34375 0.0625 1.5l0 4.671875q0 1.140625 -0.15625 1.703125q-0.15625 0.546875 -0.71875 0.96875q-0.5625 0.40625 -1.328125 0.40625q-0.5625 0 -1.046875 -0.234375q-0.46875 -0.25 -0.875 -0.734375l-0.203125 0.78125l-2.953125 0l0 -12.656248l3.15625 0zm0.96875 5.234373q0 -0.8125 -0.109375 -1.046875q-0.09375 -0.25 -0.390625 -0.25q-0.296875 0 -0.390625 0.21875q-0.078125 0.203125 -0.078125 1.078125l0 4.46875q0 0.828125 0.09375 1.0625q0.109375 0.234375 0.390625 0.234375q0.296875 0 0.390625 -0.234375q0.09375 -0.25 0.09375 -1.171875l0 -4.359375z' fill-rule='nonzero'";
var en$1 = {
"xcratchExample.entry.name": "Starter FabLab Extension",
"xcratchExample.entry.description": "Capitalize"
};
var ja$1 = {
"xcratchExample.entry.name": "Xcratchの例",
"xcratchExample.entry.description": "JavaScriptを実行する"
};
var translations$1 = {
en: en$1,
ja: ja$1,
"ja-Hira": {
"xcratchExample.entry.name": "エクスクラッチのれい",
"xcratchExample.entry.description": "ジャバスクリプトをじっこうする"
}
};
/**
* This is an extension for Xcratch.
*/
/**
* Formatter to translate the messages in this extension.
* This will be replaced which is used in the React component.
* @param {object} messageData - data for format-message
* @returns {string} - translated message for the current locale
*/
var formatMessage$1 = function formatMessage(messageData) {
return messageData.defaultMessage;
};
var entry = {
get name() {
return formatMessage$1({
id: 'xcratchExample.entry.name',
defaultMessage: 'SJCOE FabLab Example: Capitalize',
description: 'name of the extension'
});
},
extensionId: 'xcratchExample',
extensionURL: 'https://xcratch.github.io/xcx-example/dist/xcratchExample.mjs',
collaborator: 'SJCOE STEM, Workforce Development and Innovation',
iconURL: img$2,
insetIconURL: img$2,
get description() {
return formatMessage$1({
defaultMessage: 'an extension for Xcratch',
description: 'Description for this extension',
id: 'xcratchExample.entry.description'
});
},
featured: true,
disabled: false,
bluetoothRequired: false,
internetConnectionRequired: false,
helpLink: 'https://sjcoefablab.org/',
setFormatMessage: function setFormatMessage(formatter) {
formatMessage$1 = formatter;
},
translationMap: translations$1
};
function _classCallCheck$1(a, n) {
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
}
function _typeof$1(o) {
"@babel/helpers - typeof";
return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
return typeof o;
} : function (o) {
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
}, _typeof$1(o);
}
function toPrimitive$1(t, r) {
if ("object" != _typeof$1(t) || !t) return t;
var e = t[Symbol.toPrimitive];
if (void 0 !== e) {
var i = e.call(t, r );
if ("object" != _typeof$1(i)) return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (String )(t);
}
function toPropertyKey$1(t) {
var i = toPrimitive$1(t, "string");
return "symbol" == _typeof$1(i) ? i : i + "";
}
function _defineProperties$1(e, r) {
for (var t = 0; t < r.length; t++) {
var o = r[t];
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, toPropertyKey$1(o.key), o);
}
}
function _createClass$1(e, r, t) {
return r && _defineProperties$1(e.prototype, r), t && _defineProperties$1(e, t), Object.defineProperty(e, "prototype", {
writable: !1
}), e;
}
function getDefaultExportFromCjs (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}
/**
* Types of block
* @enum {string}
*/
var BlockType = {
/**
* Boolean reporter with hexagonal shape
*/
BOOLEAN: 'Boolean',
/**
* A button (not an actual block) for some special action, like making a variable
*/
BUTTON: 'button',
/**
* Command block
*/
COMMAND: 'command',
/**
* Specialized command block which may or may not run a child branch
* The thread continues with the next block whether or not a child branch ran.
*/
CONDITIONAL: 'conditional',
/**
* Specialized hat block with no implementation function
* This stack only runs if the corresponding event is emitted by other code.
*/
EVENT: 'event',
/**
* Hat block which conditionally starts a block stack
*/
HAT: 'hat',
/**
* Specialized command block which may or may not run a child branch
* If a child branch runs, the thread evaluates the loop block again.
*/
LOOP: 'loop',
/**
* General reporter with numeric or string value
*/
REPORTER: 'reporter'
};
var blockType = BlockType;
var BlockType$1 = /*@__PURE__*/getDefaultExportFromCjs(blockType);
/**
* Block argument types
* @enum {string}
*/
var ArgumentType = {
/**
* Numeric value with angle picker
*/
ANGLE: 'angle',
/**
* Boolean value with hexagonal placeholder
*/
BOOLEAN: 'Boolean',
/**
* Numeric value with color picker
*/
COLOR: 'color',
/**
* Numeric value with text field
*/
NUMBER: 'number',
/**
* String value with text field
*/
STRING: 'string',
/**
* String value with matrix field
*/
MATRIX: 'matrix',
/**
* MIDI note number with note picker (piano) field
*/
NOTE: 'note',
/**
* Inline image on block (as part of the label)
*/
IMAGE: 'image'
};
var argumentType = ArgumentType;
var ArgumentType$1 = /*@__PURE__*/getDefaultExportFromCjs(argumentType);
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _typeof(o) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
return typeof o;
} : function (o) {
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
}, _typeof(o);
}
function toPrimitive(t, r) {
if ("object" != _typeof(t) || !t) return t;
var e = t[Symbol.toPrimitive];
if (void 0 !== e) {
var i = e.call(t, r );
if ("object" != _typeof(i)) return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (String )(t);
}
function toPropertyKey(t) {
var i = toPrimitive(t, "string");
return "symbol" == _typeof(i) ? i : String(i);
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, toPropertyKey(descriptor.key), descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (staticProps) _defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, "prototype", {
writable: false
});
return Constructor;
}
var Color$1 = /*#__PURE__*/function () {
function Color() {
_classCallCheck(this, Color);
}
return _createClass(Color, null, [{
key: "RGB_BLACK",
get:
/**
* @typedef {object} RGBObject - An object representing a color in RGB format.
* @property {number} r - the red component, in the range [0, 255].
* @property {number} g - the green component, in the range [0, 255].
* @property {number} b - the blue component, in the range [0, 255].
*/
/**
* @typedef {object} HSVObject - An object representing a color in HSV format.
* @property {number} h - hue, in the range [0-359).
* @property {number} s - saturation, in the range [0,1].
* @property {number} v - value, in the range [0,1].
*/
/** @type {RGBObject} */
function get() {
return {
r: 0,
g: 0,
b: 0
};
}
/** @type {RGBObject} */
}, {
key: "RGB_WHITE",
get: function get() {
return {
r: 255,
g: 255,
b: 255
};
}
/**
* Convert a Scratch decimal color to a hex string, #RRGGBB.
* @param {number} decimal RGB color as a decimal.
* @return {string} RGB color as #RRGGBB hex string.
*/
}, {
key: "decimalToHex",
value: function decimalToHex(decimal) {
if (decimal < 0) {
decimal += 0xFFFFFF + 1;
}
var hex = Number(decimal).toString(16);
hex = "#".concat('000000'.substr(0, 6 - hex.length)).concat(hex);
return hex;
}
/**
* Convert a Scratch decimal color to an RGB color object.
* @param {number} decimal RGB color as decimal.
* @return {RGBObject} rgb - {r: red [0,255], g: green [0,255], b: blue [0,255]}.
*/
}, {
key: "decimalToRgb",
value: function decimalToRgb(decimal) {
var a = decimal >> 24 & 0xFF;
var r = decimal >> 16 & 0xFF;
var g = decimal >> 8 & 0xFF;
var b = decimal & 0xFF;
return {
r: r,
g: g,
b: b,
a: a > 0 ? a : 255
};
}
/**
* Convert a hex color (e.g., F00, #03F, #0033FF) to an RGB color object.
* CC-BY-SA Tim Down:
* https://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb
* @param {!string} hex Hex representation of the color.
* @return {RGBObject} null on failure, or rgb: {r: red [0,255], g: green [0,255], b: blue [0,255]}.
*/
}, {
key: "hexToRgb",
value: function hexToRgb(hex) {
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
hex = hex.replace(shorthandRegex, function (m, r, g, b) {
return r + r + g + g + b + b;
});
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16)
} : null;
}
/**
* Convert an RGB color object to a hex color.
* @param {RGBObject} rgb - {r: red [0,255], g: green [0,255], b: blue [0,255]}.
* @return {!string} Hex representation of the color.
*/
}, {
key: "rgbToHex",
value: function rgbToHex(rgb) {
return Color.decimalToHex(Color.rgbToDecimal(rgb));
}
/**
* Convert an RGB color object to a Scratch decimal color.
* @param {RGBObject} rgb - {r: red [0,255], g: green [0,255], b: blue [0,255]}.
* @return {!number} Number representing the color.
*/
}, {
key: "rgbToDecimal",
value: function rgbToDecimal(rgb) {
return (rgb.r << 16) + (rgb.g << 8) + rgb.b;
}
/**
* Convert a hex color (e.g., F00, #03F, #0033FF) to a decimal color number.
* @param {!string} hex Hex representation of the color.
* @return {!number} Number representing the color.
*/
}, {
key: "hexToDecimal",
value: function hexToDecimal(hex) {
return Color.rgbToDecimal(Color.hexToRgb(hex));
}
/**
* Convert an HSV color to RGB format.
* @param {HSVObject} hsv - {h: hue [0,360), s: saturation [0,1], v: value [0,1]}
* @return {RGBObject} rgb - {r: red [0,255], g: green [0,255], b: blue [0,255]}.
*/
}, {
key: "hsvToRgb",
value: function hsvToRgb(hsv) {
var h = hsv.h % 360;
if (h < 0) h += 360;
var s = Math.max(0, Math.min(hsv.s, 1));
var v = Math.max(0, Math.min(hsv.v, 1));
var i = Math.floor(h / 60);
var f = h / 60 - i;
var p = v * (1 - s);
var q = v * (1 - s * f);
var t = v * (1 - s * (1 - f));
var r;
var g;
var b;
switch (i) {
default:
case 0:
r = v;
g = t;
b = p;
break;
case 1:
r = q;
g = v;
b = p;
break;
case 2:
r = p;
g = v;
b = t;
break;
case 3:
r = p;
g = q;
b = v;
break;
case 4:
r = t;
g = p;
b = v;
break;
case 5:
r = v;
g = p;
b = q;
break;
}
return {
r: Math.floor(r * 255),
g: Math.floor(g * 255),
b: Math.floor(b * 255)
};
}
/**
* Convert an RGB color to HSV format.
* @param {RGBObject} rgb - {r: red [0,255], g: green [0,255], b: blue [0,255]}.
* @return {HSVObject} hsv - {h: hue [0,360), s: saturation [0,1], v: value [0,1]}
*/
}, {
key: "rgbToHsv",
value: function rgbToHsv(rgb) {
var r = rgb.r / 255;
var g = rgb.g / 255;
var b = rgb.b / 255;
var x = Math.min(Math.min(r, g), b);
var v = Math.max(Math.max(r, g), b);
// For grays, hue will be arbitrarily reported as zero. Otherwise, calculate
var h = 0;
var s = 0;
if (x !== v) {
var f = r === x ? g - b : g === x ? b - r : r - g;
var i = r === x ? 3 : g === x ? 5 : 1;
h = (i - f / (v - x)) * 60 % 360;
s = (v - x) / v;
}
return {
h: h,
s: s,
v: v
};
}
/**
* Linear interpolation between rgb0 and rgb1.
* @param {RGBObject} rgb0 - the color corresponding to fraction1 <= 0.
* @param {RGBObject} rgb1 - the color corresponding to fraction1 >= 1.
* @param {number} fraction1 - the interpolation parameter. If this is 0.5, for example, mix the two colors equally.
* @return {RGBObject} the interpolated color.
*/
}, {
key: "mixRgb",
value: function mixRgb(rgb0, rgb1, fraction1) {
if (fraction1 <= 0) return rgb0;
if (fraction1 >= 1) return rgb1;
var fraction0 = 1 - fraction1;
return {
r: fraction0 * rgb0.r + fraction1 * rgb1.r,
g: fraction0 * rgb0.g + fraction1 * rgb1.g,
b: fraction0 * rgb0.b + fraction1 * rgb1.b
};
}
}]);
}();
var color$3 = Color$1;
var Color = color$3;
/**
* @fileoverview
* Utilities for casting and comparing Scratch data-types.
* Scratch behaves slightly differently from JavaScript in many respects,
* and these differences should be encapsulated below.
* For example, in Scratch, add(1, join("hello", world")) -> 1.
* This is because "hello world" is cast to 0.
* In JavaScript, 1 + Number("hello" + "world") would give you NaN.
* Use when coercing a value before computation.
*/
var Cast = /*#__PURE__*/function () {
function Cast() {
_classCallCheck(this, Cast);
}
return _createClass(Cast, null, [{
key: "toNumber",
value:
/**
* Scratch cast to number.
* Treats NaN as 0.
* In Scratch 2.0, this is captured by `interp.numArg.`
* @param {*} value Value to cast to number.
* @return {number} The Scratch-casted number value.
*/
function toNumber(value) {
// If value is already a number we don't need to coerce it with
// Number().
if (typeof value === 'number') {
// Scratch treats NaN as 0, when needed as a number.
// E.g., 0 + NaN -> 0.
if (Number.isNaN(value)) {
return 0;
}
return value;
}
// Replace full-width numbers with half-width ones.
value = value.replace(/[0-9+.e]/g, function (s) {
return String.fromCharCode(s.charCodeAt(0) - 0xFEE0);
});
value = value.replace(/[--﹣−‐⁃‑‒–—﹘―⎯⏤ーー─━]/g, '-');
var n = Number(value);
if (Number.isNaN(n)) {
// Scratch treats NaN as 0, when needed as a number.
// E.g., 0 + NaN -> 0.
return 0;
}
return n;
}
/**
* Scratch cast to boolean.
* In Scratch 2.0, this is captured by `interp.boolArg.`
* Treats some string values differently from JavaScript.
* @param {*} value Value to cast to boolean.
* @return {boolean} The Scratch-casted boolean value.
*/
}, {
key: "toBoolean",
value: function toBoolean(value) {
// Already a boolean?
if (typeof value === 'boolean') {
return value;
}
if (typeof value === 'string') {
// These specific strings are treated as false in Scratch.
if (value === '' || value === '0' || value.toLowerCase() === 'false') {
return false;
}
// All other strings treated as true.
return true;
}
// Coerce other values and numbers.
return Boolean(value);
}
/**
* Scratch cast to string.
* @param {*} value Value to cast to string.
* @return {string} The Scratch-casted string value.
*/
}, {
key: "toString",
value: function toString(value) {
return String(value).replace(/\\n/g, '\n').replace(/\\t/g, '\t');
}
/**
* Cast any Scratch argument to an RGB color array to be used for the renderer.
* @param {*} value Value to convert to RGB color array.
* @return {Array.<number>} [r,g,b], values between 0-255.
*/
}, {
key: "toRgbColorList",
value: function toRgbColorList(value) {
var color = Cast.toRgbColorObject(value);
return [color.r, color.g, color.b];
}
/**
* Cast any Scratch argument to an RGB color object to be used for the renderer.
* @param {*} value Value to convert to RGB color object.
* @return {RGBOject} [r,g,b], values between 0-255.
*/
}, {
key: "toRgbColorObject",
value: function toRgbColorObject(value) {
var color;
if (typeof value === 'string' && value.substring(0, 1) === '#') {
color = Color.hexToRgb(value);
// If the color wasn't *actually* a hex color, cast to black
if (!color) color = {
r: 0,
g: 0,
b: 0,
a: 255
};
} else {
color = Color.decimalToRgb(Cast.toNumber(value));
}
return color;
}
/**
* Determine if a Scratch argument is a white space string (or null / empty).
* @param {*} val value to check.
* @return {boolean} True if the argument is all white spaces or null / empty.
*/
}, {
key: "isWhiteSpace",
value: function isWhiteSpace(val) {
return val === null || typeof val === 'string' && val.trim().length === 0;
}
/**
* Compare two values, using Scratch cast, case-insensitive string compare, etc.
* In Scratch 2.0, this is captured by `interp.compare.`
* @param {*} v1 First value to compare.
* @param {*} v2 Second value to compare.
* @returns {number} Negative number if v1 < v2; 0 if equal; positive otherwise.
*/
}, {
key: "compare",
value: function compare(v1, v2) {
var n1 = Number(v1);
var n2 = Number(v2);
if (n1 === 0 && Cast.isWhiteSpace(v1)) {
n1 = NaN;
} else if (n2 === 0 && Cast.isWhiteSpace(v2)) {
n2 = NaN;
}
if (isNaN(n1) || isNaN(n2)) {
// At least one argument can't be converted to a number.
// Scratch compares strings as case insensitive.
var s1 = Cast.toString(v1).toLowerCase();
var s2 = Cast.toString(v2).toLowerCase();
if (s1 < s2) {
return -1;
} else if (s1 > s2) {
return 1;
}
return 0;
}
// Handle the special case of Infinity
if (n1 === Infinity && n2 === Infinity || n1 === -Infinity && n2 === -Infinity) {
return 0;
}
// Compare as numbers.
return n1 - n2;
}
/**
* Determine if a Scratch argument number represents a round integer.
* @param {*} val Value to check.
* @return {boolean} True if number looks like an integer.
*/
}, {
key: "isInt",
value: function isInt(val) {
// Values that are already numbers.
if (typeof val === 'number') {
if (isNaN(val)) {
// NaN is considered an integer.
return true;
}
// True if it's "round" (e.g., 2.0 and 2).
return val === parseInt(val, 10);
} else if (typeof val === 'boolean') {
// `True` and `false` always represent integer after Scratch cast.
return true;
} else if (typeof val === 'string') {
// If it contains a decimal point, don't consider it an int.
return val.indexOf('.') < 0;
}
return false;
}
}, {
key: "LIST_INVALID",
get: function get() {
return 'INVALID';
}
}, {
key: "LIST_ALL",
get: function get() {
return 'ALL';
}
/**
* Compute a 1-based index into a list, based on a Scratch argument.
* Two special cases may be returned:
* LIST_ALL: if the block is referring to all of the items in the list.
* LIST_INVALID: if the index was invalid in any way.
* @param {*} index Scratch arg, including 1-based numbers or special cases.
* @param {number} length Length of the list.
* @param {boolean} acceptAll Whether it should accept "all" or not.
* @return {(number|string)} 1-based index for list, LIST_ALL, or LIST_INVALID.
*/
}, {
key: "toListIndex",
value: function toListIndex(index, length, acceptAll) {
if (typeof index !== 'number') {
if (index === 'all') {
return acceptAll ? Cast.LIST_ALL : Cast.LIST_INVALID;
}
if (index === 'last') {
if (length > 0) {
return length;
}
return Cast.LIST_INVALID;
} else if (index === 'random' || index === 'any') {
if (length > 0) {
return 1 + Math.floor(Math.random() * length);
}
return Cast.LIST_INVALID;
}
}
index = Math.floor(Cast.toNumber(index));
if (index < 1 || index > length) {
return Cast.LIST_INVALID;
}
return index;
}
}]);
}();
var cast = Cast;
var Cast$1 = /*@__PURE__*/getDefaultExportFromCjs(cast);
var web = {exports: {}};
var minilog$2 = {exports: {}};
function M() {
this._events = {};
}
M.prototype = {
on: function on(ev, cb) {
this._events || (this._events = {});
var e = this._events;
(e[ev] || (e[ev] = [])).push(cb);
return this;
},
removeListener: function removeListener(ev, cb) {
var e = this._events[ev] || [],
i;
for (i = e.length - 1; i >= 0 && e[i]; i--) {
if (e[i] === cb || e[i].cb === cb) {
e.splice(i, 1);
}
}
},
removeAllListeners: function removeAllListeners(ev) {
if (!ev) {
this._events = {};
} else {
this._events[ev] && (this._events[ev] = []);
}
},
listeners: function listeners(ev) {
return this._events ? this._events[ev] || [] : [];
},
emit: function emit(ev) {
this._events || (this._events = {});
var args = Array.prototype.slice.call(arguments, 1),
i,
e = this._events[ev] || [];
for (i = e.length - 1; i >= 0 && e[i]; i--) {
e[i].apply(this, args);
}
return this;
},
when: function when(ev, cb) {
return this.once(ev, cb, true);
},
once: function once(ev, cb, when) {
if (!cb) return this;
function c() {
if (!when) this.removeListener(ev, c);
if (cb.apply(this, arguments) && when) this.removeListener(ev, c);
}
c.cb = cb;
this.on(ev, c);
return this;
}
};
M.mixin = function (dest) {
var o = M.prototype,
k;
for (k in o) {
o.hasOwnProperty(k) && (dest.prototype[k] = o[k]);
}
};
var microee$1 = M;
var microee = microee$1;
// Implements a subset of Node's stream.Transform - in a cross-platform manner.
function Transform$4() {}
microee.mixin(Transform$4);
// The write() signature is different from Node's
// --> makes it much easier to work with objects in logs.
// One of the lessons from v1 was that it's better to target
// a good browser rather than the lowest common denominator
// internally.
// If you want to use external streams, pipe() to ./stringify.js first.
Transform$4.prototype.write = function (name, level, args) {
this.emit('item', name, level, args);
};
Transform$4.prototype.end = function () {
this.emit('end');
this.removeAllListeners();
};
Transform$4.prototype.pipe = function (dest) {
var s = this;
// prevent double piping
s.emit('unpipe', dest);
// tell the dest that it's being piped to
dest.emit('pipe', s);
function onItem() {
dest.write.apply(dest, Array.prototype.slice.call(arguments));
}
function onEnd() {
!dest._isStdio && dest.end();
}
s.on('item', onItem);
s.on('end', onEnd);
s.when('unpipe', function (from) {
var match = from === dest || typeof from == 'undefined';
if (match) {
s.removeListener('item', onItem);
s.removeListener('end', onEnd);
dest.emit('unpipe');
}
return match;
});
return dest;
};
Transform$4.prototype.unpipe = function (from) {
this.emit('unpipe', from);
return this;
};
Transform$4.prototype.format = function (dest) {
throw new Error(['Warning: .format() is deprecated in Minilog v2! Use .pipe() instead. For example:', 'var Minilog = require(\'minilog\');', 'Minilog', ' .pipe(Minilog.backends.console.formatClean)', ' .pipe(Minilog.backends.console);'].join('\n'));
};
Transform$4.mixin = function (dest) {
var o = Transform$4.prototype,
k;
for (k in o) {
o.hasOwnProperty(k) && (dest.prototype[k] = o[k]);
}
};
var transform = Transform$4;
// default filter
var Transform$3 = transform;
var levelMap = {
debug: 1,
info: 2,
warn: 3,
error: 4
};
function Filter() {
this.enabled = true;
this.defaultResult = true;
this.clear();
}
Transform$3.mixin(Filter);
// allow all matching, with level >= given level
Filter.prototype.allow = function (name, level) {
this._white.push({
n: name,
l: levelMap[level]
});
return this;
};
// deny all matching, with level <= given level
Filter.prototype.deny = function (name, level) {
this._black.push({
n: name,
l: levelMap[level]
});
return this;
};
Filter.prototype.clear = function () {
this._white = [];
this._black = [];
return this;
};
function test(rule, name) {
// use .test for RegExps
return rule.n.test ? rule.n.test(name) : rule.n == name;
}
Filter.prototype.test = function (name, level) {
var i,
len = Math.max(this._white.length, this._black.length);
for (i = 0; i < len; i++) {
if (this._white[i] && test(this._white[i], name) && levelMap[level] >= this._white[i].l) {
return true;
}
if (this._black[i] && test(this._black[i], name) && levelMap[level] <= this._black[i].l) {
return false;
}
}
return this.defaultResult;
};
Filter.prototype.write = function (name, level, args) {
if (!this.enabled || this.test(name, level)) {
return this.emit('item', name, level, args);
}
};
var filter = Filter;
(function (module, exports) {
var Transform = transform,
Filter = filter;
var log = new Transform(),
slice = Array.prototype.slice;
exports = module.exports = function create(name) {
var o = function o() {
log.write(name, undefined, slice.call(arguments));
return o;
};
o.debug = function () {
log.write(name, 'debug', slice.call(arguments));
return o;
};
o.info = function () {
log.write(name, 'info', slice.call(arguments));
return o;
};
o.warn = function () {
log.write(name, 'warn', slice.call(arguments));
return o;
};
o.error = function () {
log.write(name, 'error', slice.call(arguments));
return o;
};
o.log = o.debug; // for interface compliance with Node and browser consoles
o.suggest = exports.suggest;
o.format = log.format;
return o;
};
// filled in separately
exports.defaultBackend = exports.defaultFormatter = null;
exports.pipe = function (dest) {
return log.pipe(dest);
};
exports.end = exports.unpipe = exports.disable = function (from) {
return log.unpipe(from);
};
exports.Transform = Transform;
exports.Filter = Filter;
// this is the default filter that's applied when .enable() is called normally
// you can bypass it completely and set up your own pipes
exports.suggest = new Filter();
exports.enable = function () {
if (exports.defaultFormatter) {
return log.pipe(exports.suggest) // filter
.pipe(exports.defaultFormatter) // formatter
.pipe(exports.defaultBackend); // backend
}
return log.pipe(exports.suggest) // filter
.pipe(exports.defaultBackend); // formatter
};
})(minilog$2, minilog$2.exports);
var minilogExports = minilog$2.exports;
var hex = {
black: '#000',
red: '#c23621',
green: '#25bc26',
yellow: '#bbbb00',
blue: '#492ee1',
magenta: '#d338d3',
cyan: '#33bbc8',
gray: '#808080',
purple: '#708'
};
function color$2(fg, isInverse) {
if (isInverse) {
return 'color: #fff; background: ' + hex[fg] + ';';
} else {
return 'color: ' + hex[fg] + ';';