@softwarefactory-project/re-ansi 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,919 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+ 'use strict';
3
+
4
+ var Belt_List = require("rescript/lib/js/belt_List.js");
5
+ var Js_string = require("rescript/lib/js/js_string.js");
6
+ var Core__List = require("@rescript/core/src/Core__List.res.js");
7
+ var Caml_option = require("rescript/lib/js/caml_option.js");
8
+ var Core__Option = require("@rescript/core/src/Core__Option.res.js");
9
+ var JsxRuntime = require("react/jsx-runtime");
10
+
11
+ function fourBitColors(code) {
12
+ switch (code) {
13
+ case 0 :
14
+ return "black";
15
+ case 1 :
16
+ return "red";
17
+ case 2 :
18
+ return "green";
19
+ case 3 :
20
+ return "yellow";
21
+ case 4 :
22
+ return "blue";
23
+ case 5 :
24
+ return "magenta";
25
+ case 6 :
26
+ return "cyan";
27
+ case 9 :
28
+ return "initial";
29
+ case 10 :
30
+ return "grey";
31
+ case 11 :
32
+ return "#DA2647";
33
+ case 12 :
34
+ return "#87FF2A";
35
+ case 13 :
36
+ return "#FFF700";
37
+ case 14 :
38
+ return "#5DADEC";
39
+ case 15 :
40
+ return "#FF3399";
41
+ case 16 :
42
+ return "#8DD9CC";
43
+ case 7 :
44
+ case 17 :
45
+ return "white";
46
+ default:
47
+ console.log("Unknown color value:", code);
48
+ return ;
49
+ }
50
+ }
51
+
52
+ function threeBitColors(code) {
53
+ switch (code) {
54
+ case 0 :
55
+ return "grey";
56
+ case 1 :
57
+ return "red";
58
+ case 2 :
59
+ return "green";
60
+ case 3 :
61
+ return "yellow";
62
+ case 4 :
63
+ return "blue";
64
+ case 5 :
65
+ return "magenta";
66
+ case 6 :
67
+ return "cyan";
68
+ case 7 :
69
+ return "white";
70
+ default:
71
+ console.log("Unknown color value:", code);
72
+ return ;
73
+ }
74
+ }
75
+
76
+ function combine(css1, css2) {
77
+ return Object.assign({}, css1, css2);
78
+ }
79
+
80
+ function addWeight(fontWeight) {
81
+ return {
82
+ fontWeight: fontWeight
83
+ };
84
+ }
85
+
86
+ function addStyle(fontStyle) {
87
+ return {
88
+ fontStyle: fontStyle
89
+ };
90
+ }
91
+
92
+ function addDecoration(textDecoration) {
93
+ return {
94
+ textDecoration: textDecoration
95
+ };
96
+ }
97
+
98
+ function int_of_cp(c) {
99
+ return c - 48 | 0;
100
+ }
101
+
102
+ function getColorStyle(colorMode, colorValue) {
103
+ switch (colorMode) {
104
+ case 3 :
105
+ return {
106
+ TAG: "Foreground",
107
+ _0: colorValue
108
+ };
109
+ case 0 :
110
+ case 4 :
111
+ return {
112
+ TAG: "Background",
113
+ _0: colorValue
114
+ };
115
+ case 9 :
116
+ return {
117
+ TAG: "BrightForeground",
118
+ _0: colorValue
119
+ };
120
+ default:
121
+
122
+ }
123
+ console.log("Unknown color code:", colorMode, colorValue);
124
+ }
125
+
126
+ function getColorStyleCss(color) {
127
+ switch (color.TAG) {
128
+ case "Foreground" :
129
+ return Core__Option.flatMap(fourBitColors(color._0), (function (color) {
130
+ return {
131
+ color: color
132
+ };
133
+ }));
134
+ case "BrightForeground" :
135
+ return Core__Option.flatMap(threeBitColors(color._0), (function (color) {
136
+ return {
137
+ color: color,
138
+ fontWeight: "bold"
139
+ };
140
+ }));
141
+ case "Background" :
142
+ return Core__Option.flatMap(fourBitColors(color._0), (function (background) {
143
+ return {
144
+ background: background
145
+ };
146
+ }));
147
+
148
+ }
149
+ }
150
+
151
+ function get(colorMode, colorValue) {
152
+ return Core__Option.flatMap(getColorStyle(colorMode - 48 | 0, colorValue - 48 | 0), getColorStyleCss);
153
+ }
154
+
155
+ var ColorCss = {
156
+ getColorStyle: getColorStyle,
157
+ getColorStyleCss: getColorStyleCss,
158
+ get: get
159
+ };
160
+
161
+ function getFontStyle(fontMode) {
162
+ switch (fontMode) {
163
+ case 1 :
164
+ return {
165
+ TAG: "FontStyle",
166
+ _0: addWeight("bold")
167
+ };
168
+ case 2 :
169
+ return {
170
+ TAG: "FontStyle",
171
+ _0: addWeight("lighter")
172
+ };
173
+ case 3 :
174
+ return {
175
+ TAG: "FontStyle",
176
+ _0: addStyle("italic")
177
+ };
178
+ case 4 :
179
+ return {
180
+ TAG: "FontStyle",
181
+ _0: addDecoration("underline")
182
+ };
183
+ case 0 :
184
+ case 7 :
185
+ return "Regular";
186
+ case 9 :
187
+ return {
188
+ TAG: "FontStyle",
189
+ _0: addDecoration("line-through")
190
+ };
191
+ default:
192
+ return ;
193
+ }
194
+ }
195
+
196
+ function getFontStyleCss(font) {
197
+ if (typeof font !== "object") {
198
+ return ;
199
+ } else {
200
+ return font._0;
201
+ }
202
+ }
203
+
204
+ function get$1(fontMode) {
205
+ return Core__Option.flatMap(getFontStyle(fontMode - 48 | 0), getFontStyleCss);
206
+ }
207
+
208
+ var FontCss = {
209
+ getFontStyle: getFontStyle,
210
+ getFontStyleCss: getFontStyleCss,
211
+ get: get$1
212
+ };
213
+
214
+ var linkRe = new RegExp("^(http(s)?:\\/\\/[^\\s]+)");
215
+
216
+ function get$2(txt) {
217
+ return Core__Option.getOr(Core__Option.flatMap(Caml_option.nullable_to_opt(linkRe.exec(txt)), (function (res) {
218
+ return Core__Option.flatMap(res[0], (function (url) {
219
+ return [
220
+ url.length,
221
+ {
222
+ TAG: "HRef",
223
+ _0: url
224
+ }
225
+ ];
226
+ }));
227
+ })), [
228
+ 1,
229
+ undefined
230
+ ]);
231
+ }
232
+
233
+ var HttpLink = {
234
+ linkRe: linkRe,
235
+ get: get$2
236
+ };
237
+
238
+ function parse(txt, pos) {
239
+ var match = Js_string.codePointAt(pos, txt);
240
+ var exit = 0;
241
+ if (match === undefined) {
242
+ return [
243
+ 0,
244
+ undefined
245
+ ];
246
+ }
247
+ if (match >= 14) {
248
+ if (match !== 27) {
249
+ if (match !== 104) {
250
+ return [
251
+ 0,
252
+ undefined
253
+ ];
254
+ } else {
255
+ return get$2(Js_string.slice(pos, 512, txt));
256
+ }
257
+ }
258
+ exit = 1;
259
+ } else {
260
+ if (match === 10) {
261
+ return [
262
+ 1,
263
+ "CarriageReturn"
264
+ ];
265
+ }
266
+ if (match < 13) {
267
+ return [
268
+ 0,
269
+ undefined
270
+ ];
271
+ }
272
+ exit = 1;
273
+ }
274
+ if (exit === 1) {
275
+ var codePoints = [];
276
+ var readCodePoints = function (_idx) {
277
+ while(true) {
278
+ var idx = _idx;
279
+ var match = idx > 10;
280
+ var match$1 = Js_string.codePointAt(pos + idx | 0, txt);
281
+ if (match) {
282
+ return ;
283
+ }
284
+ if (match$1 === undefined) {
285
+ return ;
286
+ }
287
+ if (match$1 === 109) {
288
+ return ;
289
+ }
290
+ codePoints.push(match$1);
291
+ _idx = idx + 1 | 0;
292
+ continue ;
293
+ };
294
+ };
295
+ readCodePoints(1);
296
+ var length = codePoints.length + 2 | 0;
297
+ var exit$1 = 0;
298
+ var colorMode;
299
+ var colorValue;
300
+ var xs;
301
+ var colorMode$1;
302
+ var colorValue$1;
303
+ var style;
304
+ var style$1;
305
+ var cm1;
306
+ var cv1;
307
+ var cm2;
308
+ var cv2;
309
+ var xs$1;
310
+ if (codePoints[0] === 10 && codePoints[1] === 27 && codePoints[2] === 91 && codePoints[3] === 49 && codePoints[4] === 65 && codePoints[5] === 27 && codePoints[6] === 91 && codePoints[7] === 74) {
311
+ return [
312
+ 9,
313
+ "EraseLine"
314
+ ];
315
+ }
316
+ if (codePoints[0] === 91 && codePoints[2] === 75) {
317
+ return [
318
+ 4,
319
+ "EraseLine"
320
+ ];
321
+ }
322
+ if (codePoints[0] === 91 && codePoints[1] === 75) {
323
+ return [
324
+ 3,
325
+ "EraseLine"
326
+ ];
327
+ }
328
+ var len = codePoints.length;
329
+ if (len >= 11) {
330
+ return [
331
+ 1,
332
+ undefined
333
+ ];
334
+ }
335
+ switch (len) {
336
+ case 1 :
337
+ var match$1 = codePoints[0];
338
+ if (match$1 !== 91) {
339
+ return [
340
+ 1,
341
+ undefined
342
+ ];
343
+ } else {
344
+ return [
345
+ length,
346
+ "Clear"
347
+ ];
348
+ }
349
+ case 2 :
350
+ var match$2 = codePoints[0];
351
+ if (match$2 !== 91) {
352
+ return [
353
+ 1,
354
+ undefined
355
+ ];
356
+ }
357
+ var style$2 = codePoints[1];
358
+ if (style$2 !== 48) {
359
+ return [
360
+ length,
361
+ Core__Option.flatMap(get$1(style$2), (function (style) {
362
+ return {
363
+ TAG: "Style",
364
+ _0: style
365
+ };
366
+ }))
367
+ ];
368
+ } else {
369
+ return [
370
+ length,
371
+ "Clear"
372
+ ];
373
+ }
374
+ case 3 :
375
+ var match$3 = codePoints[0];
376
+ if (match$3 !== 91) {
377
+ return [
378
+ 1,
379
+ undefined
380
+ ];
381
+ }
382
+ var colorMode$2 = codePoints[1];
383
+ var exit$2 = 0;
384
+ if (colorMode$2 !== 48) {
385
+ exit$2 = 5;
386
+ } else {
387
+ var match$4 = codePoints[2];
388
+ if (match$4 === 48) {
389
+ return [
390
+ length,
391
+ "Clear"
392
+ ];
393
+ }
394
+ exit$2 = 5;
395
+ }
396
+ if (exit$2 === 5) {
397
+ var colorValue$2 = codePoints[2];
398
+ colorMode = colorMode$2;
399
+ colorValue = colorValue$2;
400
+ xs = codePoints;
401
+ exit$1 = 2;
402
+ }
403
+ break;
404
+ case 4 :
405
+ var match$5 = codePoints[0];
406
+ if (match$5 !== 91) {
407
+ return [
408
+ 1,
409
+ undefined
410
+ ];
411
+ }
412
+ var match$6 = codePoints[1];
413
+ if (match$6 !== 49) {
414
+ return [
415
+ 1,
416
+ undefined
417
+ ];
418
+ }
419
+ var colorMode$3 = codePoints[2];
420
+ var colorValue$3 = codePoints[3];
421
+ colorMode = colorMode$3;
422
+ colorValue = colorValue$3;
423
+ xs = codePoints;
424
+ exit$1 = 2;
425
+ break;
426
+ case 5 :
427
+ var match$7 = codePoints[0];
428
+ if (match$7 !== 91) {
429
+ return [
430
+ 1,
431
+ undefined
432
+ ];
433
+ }
434
+ var colorMode$4 = codePoints[1];
435
+ var colorValue$4 = codePoints[2];
436
+ var match$8 = codePoints[3];
437
+ if (match$8 !== 59) {
438
+ if (colorValue$4 !== 59) {
439
+ return [
440
+ 1,
441
+ undefined
442
+ ];
443
+ }
444
+ var colorMode$5 = codePoints[3];
445
+ var colorValue$5 = codePoints[4];
446
+ colorMode$1 = colorMode$5;
447
+ colorValue$1 = colorValue$5;
448
+ style = colorMode$4;
449
+ exit$1 = 3;
450
+ } else {
451
+ var style$3 = codePoints[4];
452
+ colorMode$1 = colorMode$4;
453
+ colorValue$1 = colorValue$4;
454
+ style = style$3;
455
+ exit$1 = 3;
456
+ }
457
+ break;
458
+ case 6 :
459
+ var match$9 = codePoints[0];
460
+ if (match$9 !== 91) {
461
+ return [
462
+ 1,
463
+ undefined
464
+ ];
465
+ }
466
+ var match$10 = codePoints[1];
467
+ if (match$10 !== 48) {
468
+ return [
469
+ 1,
470
+ undefined
471
+ ];
472
+ }
473
+ var style$4 = codePoints[2];
474
+ var match$11 = codePoints[3];
475
+ if (match$11 !== 59) {
476
+ return [
477
+ 1,
478
+ undefined
479
+ ];
480
+ }
481
+ var colorMode$6 = codePoints[4];
482
+ var colorValue$6 = codePoints[5];
483
+ colorMode$1 = colorMode$6;
484
+ colorValue$1 = colorValue$6;
485
+ style = style$4;
486
+ exit$1 = 3;
487
+ break;
488
+ case 0 :
489
+ case 7 :
490
+ return [
491
+ 1,
492
+ undefined
493
+ ];
494
+ case 8 :
495
+ var match$12 = codePoints[0];
496
+ if (match$12 !== 91) {
497
+ return [
498
+ 1,
499
+ undefined
500
+ ];
501
+ }
502
+ var style$5 = codePoints[1];
503
+ var match$13 = codePoints[2];
504
+ if (match$13 !== 59) {
505
+ return [
506
+ 1,
507
+ undefined
508
+ ];
509
+ }
510
+ var cm1$1 = codePoints[3];
511
+ var cv1$1 = codePoints[4];
512
+ var match$14 = codePoints[5];
513
+ if (match$14 !== 59) {
514
+ return [
515
+ 1,
516
+ undefined
517
+ ];
518
+ }
519
+ var cm2$1 = codePoints[6];
520
+ var cv2$1 = codePoints[7];
521
+ style$1 = style$5;
522
+ cm1 = cm1$1;
523
+ cv1 = cv1$1;
524
+ cm2 = cm2$1;
525
+ cv2 = cv2$1;
526
+ xs$1 = codePoints;
527
+ exit$1 = 4;
528
+ break;
529
+ case 9 :
530
+ var match$15 = codePoints[0];
531
+ if (match$15 !== 91) {
532
+ return [
533
+ 1,
534
+ undefined
535
+ ];
536
+ }
537
+ var style$6 = codePoints[1];
538
+ var exit$3 = 0;
539
+ if (style$6 !== 48) {
540
+ exit$3 = 5;
541
+ } else {
542
+ var style$7 = codePoints[2];
543
+ var match$16 = codePoints[3];
544
+ if (match$16 !== 59) {
545
+ exit$3 = 5;
546
+ } else {
547
+ var cm1$2 = codePoints[4];
548
+ var cv1$2 = codePoints[5];
549
+ var match$17 = codePoints[6];
550
+ if (match$17 !== 59) {
551
+ exit$3 = 5;
552
+ } else {
553
+ var cm2$2 = codePoints[7];
554
+ var cv2$2 = codePoints[8];
555
+ style$1 = style$7;
556
+ cm1 = cm1$2;
557
+ cv1 = cv1$2;
558
+ cm2 = cm2$2;
559
+ cv2 = cv2$2;
560
+ xs$1 = codePoints;
561
+ exit$1 = 4;
562
+ }
563
+ }
564
+ }
565
+ if (exit$3 === 5) {
566
+ var match$18 = codePoints[2];
567
+ if (match$18 !== 59) {
568
+ return [
569
+ 1,
570
+ undefined
571
+ ];
572
+ }
573
+ var cm1$3 = codePoints[3];
574
+ var cv1$3 = codePoints[4];
575
+ var match$19 = codePoints[5];
576
+ if (match$19 !== 59) {
577
+ return [
578
+ 1,
579
+ undefined
580
+ ];
581
+ }
582
+ var match$20 = codePoints[6];
583
+ if (match$20 !== 49) {
584
+ return [
585
+ 1,
586
+ undefined
587
+ ];
588
+ }
589
+ var cm2$3 = codePoints[7];
590
+ var cv2$3 = codePoints[8];
591
+ style$1 = style$6;
592
+ cm1 = cm1$3;
593
+ cv1 = cv1$3;
594
+ cm2 = cm2$3;
595
+ cv2 = cv2$3;
596
+ xs$1 = codePoints;
597
+ exit$1 = 4;
598
+ }
599
+ break;
600
+ case 10 :
601
+ var match$21 = codePoints[0];
602
+ if (match$21 !== 91) {
603
+ return [
604
+ 1,
605
+ undefined
606
+ ];
607
+ }
608
+ var match$22 = codePoints[1];
609
+ if (match$22 !== 48) {
610
+ return [
611
+ 1,
612
+ undefined
613
+ ];
614
+ }
615
+ var style$8 = codePoints[2];
616
+ var match$23 = codePoints[3];
617
+ if (match$23 !== 59) {
618
+ return [
619
+ 1,
620
+ undefined
621
+ ];
622
+ }
623
+ var cm1$4 = codePoints[4];
624
+ var cv1$4 = codePoints[5];
625
+ var match$24 = codePoints[6];
626
+ if (match$24 !== 59) {
627
+ return [
628
+ 1,
629
+ undefined
630
+ ];
631
+ }
632
+ var match$25 = codePoints[7];
633
+ if (match$25 !== 49) {
634
+ return [
635
+ 1,
636
+ undefined
637
+ ];
638
+ }
639
+ var cm2$4 = codePoints[8];
640
+ var cv2$4 = codePoints[9];
641
+ style$1 = style$8;
642
+ cm1 = cm1$4;
643
+ cv1 = cv1$4;
644
+ cm2 = cm2$4;
645
+ cv2 = cv2$4;
646
+ xs$1 = codePoints;
647
+ exit$1 = 4;
648
+ break;
649
+
650
+ }
651
+ switch (exit$1) {
652
+ case 2 :
653
+ return [
654
+ length,
655
+ Core__Option.flatMap(get(colorMode, colorValue + (
656
+ xs.length === 4 ? 10 : 0
657
+ ) | 0), (function (colorCss) {
658
+ return {
659
+ TAG: "Style",
660
+ _0: colorCss
661
+ };
662
+ }))
663
+ ];
664
+ case 3 :
665
+ return [
666
+ length,
667
+ Core__Option.flatMap(get(colorMode$1, colorValue$1), (function (colorCss) {
668
+ var fontCss = get$1(style);
669
+ if (fontCss !== undefined) {
670
+ return {
671
+ TAG: "Style",
672
+ _0: Object.assign({}, colorCss, fontCss)
673
+ };
674
+ } else {
675
+ return {
676
+ TAG: "Style",
677
+ _0: colorCss
678
+ };
679
+ }
680
+ }))
681
+ ];
682
+ case 4 :
683
+ return [
684
+ length,
685
+ Core__Option.flatMap(get(cm1, cv1), (function (colorCss1) {
686
+ return Core__Option.flatMap(get(cm2, cv2 + (
687
+ xs$1.length === 9 ? 10 : 0
688
+ ) | 0), (function (colorCss2) {
689
+ var css = Object.assign({}, colorCss1, colorCss2);
690
+ var fontCss = get$1(style$1);
691
+ if (fontCss !== undefined) {
692
+ return {
693
+ TAG: "Style",
694
+ _0: Object.assign({}, css, fontCss)
695
+ };
696
+ } else {
697
+ return {
698
+ TAG: "Style",
699
+ _0: css
700
+ };
701
+ }
702
+ }));
703
+ }))
704
+ ];
705
+
706
+ }
707
+ }
708
+
709
+ }
710
+
711
+ var AnsiCode = {
712
+ fourBitColors: fourBitColors,
713
+ threeBitColors: threeBitColors,
714
+ combine: combine,
715
+ addWeight: addWeight,
716
+ addStyle: addStyle,
717
+ addDecoration: addDecoration,
718
+ int_of_cp: int_of_cp,
719
+ ColorCss: ColorCss,
720
+ FontCss: FontCss,
721
+ HttpLink: HttpLink,
722
+ parse: parse
723
+ };
724
+
725
+ function text(txt, from, to_) {
726
+ return {
727
+ TAG: "Text",
728
+ _0: Js_string.slice(from, to_, txt)
729
+ };
730
+ }
731
+
732
+ function parse$1(txt, length, pos) {
733
+ var go = function (_pos, _prev) {
734
+ while(true) {
735
+ var prev = _prev;
736
+ var pos = _pos;
737
+ var match = pos === length;
738
+ var match$1 = parse(txt, pos);
739
+ if (match) {
740
+ return [
741
+ pos,
742
+ {
743
+ hd: text(txt, prev, pos),
744
+ tl: /* [] */0
745
+ }
746
+ ];
747
+ }
748
+ var code = match$1[1];
749
+ if (code !== undefined) {
750
+ var prevElem = text(txt, prev, pos);
751
+ var pos$1 = pos + match$1[0] | 0;
752
+ if (typeof code !== "object") {
753
+ switch (code) {
754
+ case "Clear" :
755
+ return [
756
+ pos$1,
757
+ {
758
+ hd: prevElem,
759
+ tl: /* [] */0
760
+ }
761
+ ];
762
+ case "EraseLine" :
763
+ _prev = pos$1;
764
+ _pos = pos$1;
765
+ continue ;
766
+ case "CarriageReturn" :
767
+ return [
768
+ pos$1,
769
+ {
770
+ hd: prevElem,
771
+ tl: {
772
+ hd: "LineBreak",
773
+ tl: /* [] */0
774
+ }
775
+ }
776
+ ];
777
+
778
+ }
779
+ } else {
780
+ if (code.TAG === "HRef") {
781
+ return [
782
+ pos$1,
783
+ {
784
+ hd: prevElem,
785
+ tl: {
786
+ hd: {
787
+ TAG: "Link",
788
+ _0: code._0
789
+ },
790
+ tl: /* [] */0
791
+ }
792
+ }
793
+ ];
794
+ }
795
+ var match$2 = go(pos$1, pos$1);
796
+ var styled = match$2[1];
797
+ if (styled !== undefined) {
798
+ return [
799
+ match$2[0],
800
+ {
801
+ hd: prevElem,
802
+ tl: {
803
+ hd: {
804
+ TAG: "DocStyle",
805
+ _0: code._0,
806
+ _1: styled
807
+ },
808
+ tl: /* [] */0
809
+ }
810
+ }
811
+ ];
812
+ } else {
813
+ return [
814
+ pos$1,
815
+ undefined
816
+ ];
817
+ }
818
+ }
819
+ } else {
820
+ _pos = pos + 1 | 0;
821
+ continue ;
822
+ }
823
+ };
824
+ };
825
+ return go(pos, pos);
826
+ }
827
+
828
+ var $$Document = {
829
+ text: text,
830
+ parse: parse$1
831
+ };
832
+
833
+ function parse$2(txt) {
834
+ var go = function (_txt, _acc) {
835
+ while(true) {
836
+ var acc = _acc;
837
+ var txt = _txt;
838
+ var length = txt.length;
839
+ var match = parse$1(txt, length, 0);
840
+ var doc = match[1];
841
+ var pos = match[0];
842
+ if (doc === undefined) {
843
+ return acc;
844
+ }
845
+ if (pos === length) {
846
+ return Core__List.add(acc, doc);
847
+ }
848
+ _acc = Core__List.add(acc, doc);
849
+ _txt = Js_string.sliceToEnd(pos, txt);
850
+ continue ;
851
+ };
852
+ };
853
+ return Belt_List.flatten(Belt_List.reverse(go(txt, /* [] */0)));
854
+ }
855
+
856
+ function render(doc) {
857
+ var go = function (_xs, _idx, _acc) {
858
+ while(true) {
859
+ var acc = _acc;
860
+ var idx = _idx;
861
+ var xs = _xs;
862
+ if (!xs) {
863
+ return Core__List.toArray(Core__List.reverse(acc));
864
+ }
865
+ var txt = xs.hd;
866
+ if (typeof txt !== "object") {
867
+ _acc = Core__List.add(acc, JsxRuntime.jsx("br", {}, String(idx)));
868
+ _idx = idx + 1 | 0;
869
+ _xs = xs.tl;
870
+ continue ;
871
+ }
872
+ switch (txt.TAG) {
873
+ case "Text" :
874
+ _acc = Core__List.add(acc, txt._0);
875
+ _idx = idx + 1 | 0;
876
+ _xs = xs.tl;
877
+ continue ;
878
+ case "Link" :
879
+ var href = txt._0;
880
+ _acc = Core__List.add(acc, JsxRuntime.jsx("a", {
881
+ children: href,
882
+ href: href
883
+ }, String(idx)));
884
+ _idx = idx + 1 | 0;
885
+ _xs = xs.tl;
886
+ continue ;
887
+ case "DocStyle" :
888
+ _acc = Core__List.add(acc, JsxRuntime.jsx("span", {
889
+ children: go(txt._1, 0, /* [] */0),
890
+ style: txt._0
891
+ }, String(idx)));
892
+ _idx = idx + 1 | 0;
893
+ _xs = xs.tl;
894
+ continue ;
895
+
896
+ }
897
+ };
898
+ };
899
+ return go(doc, 0, /* [] */0);
900
+ }
901
+
902
+ function Ansi(props) {
903
+ return JsxRuntime.jsx("div", {
904
+ children: render(parse$2(props.log))
905
+ });
906
+ }
907
+
908
+ var make = Ansi;
909
+
910
+ var $$default = Ansi;
911
+
912
+ exports.AnsiCode = AnsiCode;
913
+ exports.$$Document = $$Document;
914
+ exports.parse = parse$2;
915
+ exports.render = render;
916
+ exports.make = make;
917
+ exports.default = $$default;
918
+ exports.__esModule = true;
919
+ /* linkRe Not a pure module */