-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
2747 lines (2734 loc) · 97.7 KB
/
index.js
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
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var ast = /*#__PURE__*/Object.freeze({
__proto__: null
});
const latestEcmaVersion = 2024;
let largeIdStartRanges = undefined;
let largeIdContinueRanges = undefined;
function isIdStart(cp) {
if (cp < 0x41)
return false;
if (cp < 0x5b)
return true;
if (cp < 0x61)
return false;
if (cp < 0x7b)
return true;
return isLargeIdStart(cp);
}
function isIdContinue(cp) {
if (cp < 0x30)
return false;
if (cp < 0x3a)
return true;
if (cp < 0x41)
return false;
if (cp < 0x5b)
return true;
if (cp === 0x5f)
return true;
if (cp < 0x61)
return false;
if (cp < 0x7b)
return true;
return isLargeIdStart(cp) || isLargeIdContinue(cp);
}
function isLargeIdStart(cp) {
return isInRange(cp, largeIdStartRanges !== null && largeIdStartRanges !== void 0 ? largeIdStartRanges : (largeIdStartRanges = initLargeIdStartRanges()));
}
function isLargeIdContinue(cp) {
return isInRange(cp, largeIdContinueRanges !== null && largeIdContinueRanges !== void 0 ? largeIdContinueRanges : (largeIdContinueRanges = initLargeIdContinueRanges()));
}
function initLargeIdStartRanges() {
return restoreRanges("4q 0 b 0 5 0 6 m 2 u 2 cp 5 b f 4 8 0 2 0 3m 4 2 1 3 3 2 0 7 0 2 2 2 0 2 j 2 2a 2 3u 9 4l 2 11 3 0 7 14 20 q 5 3 1a 16 10 1 2 2q 2 0 g 1 8 1 b 2 3 0 h 0 2 t u 2g c 0 p w a 1 5 0 6 l 5 0 a 0 4 0 o o 8 a 6 n 2 5 i 15 1n 1h 4 0 j 0 8 9 g f 5 7 3 1 3 l 2 6 2 0 4 3 4 0 h 0 e 1 2 2 f 1 b 0 9 5 5 1 3 l 2 6 2 1 2 1 2 1 w 3 2 0 k 2 h 8 2 2 2 l 2 6 2 1 2 4 4 0 j 0 g 1 o 0 c 7 3 1 3 l 2 6 2 1 2 4 4 0 v 1 2 2 g 0 i 0 2 5 4 2 2 3 4 1 2 0 2 1 4 1 4 2 4 b n 0 1h 7 2 2 2 m 2 f 4 0 r 2 3 0 3 1 v 0 5 7 2 2 2 m 2 9 2 4 4 0 w 1 2 1 g 1 i 8 2 2 2 14 3 0 h 0 6 2 9 2 p 5 6 h 4 n 2 8 2 0 3 6 1n 1b 2 1 d 6 1n 1 2 0 2 4 2 n 2 0 2 9 2 1 a 0 3 4 2 0 m 3 x 0 1s 7 2 z s 4 38 16 l 0 h 5 5 3 4 0 4 1 8 2 5 c d 0 i 11 2 0 6 0 3 16 2 98 2 3 3 6 2 0 2 3 3 14 2 3 3 w 2 3 3 6 2 0 2 3 3 e 2 1k 2 3 3 1u 12 f h 2d 3 5 4 h7 3 g 2 p 6 22 4 a 8 h e i f h f c 2 2 g 1f 10 0 5 0 1w 2g 8 14 2 0 6 1x b u 1e t 3 4 c 17 5 p 1j m a 1g 2b 0 2m 1a i 7 1j t e 1 b 17 r z 16 2 b z 3 8 8 16 3 2 16 3 2 5 2 1 4 0 6 5b 1t 7p 3 5 3 11 3 5 3 7 2 0 2 0 2 0 2 u 3 1g 2 6 2 0 4 2 2 6 4 3 3 5 5 c 6 2 2 6 39 0 e 0 h c 2u 0 5 0 3 9 2 0 3 5 7 0 2 0 2 0 2 f 3 3 6 4 5 0 i 14 22g 6c 7 3 4 1 d 11 2 0 6 0 3 1j 8 0 h m a 6 2 6 2 6 2 6 2 6 2 6 2 6 2 6 fb 2 q 8 8 4 3 4 5 2d 5 4 2 2h 2 3 6 16 2 2l i v 1d f e9 533 1t h3g 1w 19 3 7g 4 f b 1 l 1a h u 3 27 14 8 3 2u 3 1r 6 1 2 0 2 4 p f 2 2 2 3 2 m u 1f f 1d 1r 5 4 0 2 1 c r b m q s 8 1a t 0 h 4 2 9 b 4 2 14 o 2 2 7 l m 4 0 4 1d 2 0 4 1 3 4 3 0 2 0 p 2 3 a 8 2 d 5 3 5 3 5 a 6 2 6 2 16 2 d 7 36 u 8mb d m 5 1c 6it a5 3 2x 13 6 d 4 6 0 2 9 2 c 2 4 2 0 2 1 2 1 2 2z y a2 j 1r 3 1h 15 b 39 4 2 3q 11 p 7 p c 2g 4 5 3 5 3 5 3 2 10 b 2 p 2 i 2 1 2 e 3 d z 3e 1y 1g 7g s 4 1c 1c v e t 6 11 b t 3 z 5 7 2 4 17 4d j z 5 z 5 13 9 1f d a 2 e 2 6 2 1 2 a 2 e 2 6 2 1 1w 8m a l b 7 p 5 2 15 2 8 1y 5 3 0 2 17 2 1 4 0 3 m b m a u 1u i 2 1 b l b p 1z 1j 7 1 1t 0 g 3 2 2 2 s 17 s 4 s 10 7 2 r s 1h b l b i e h 33 20 1k 1e e 1e e z 9p 15 7 1 27 s b 0 9 l 17 h 1b k s m d 1g 1m 1 3 0 e 18 x o r z u 0 3 0 9 y 4 0 d 1b f 3 m 0 2 0 10 h 2 o k 1 1s 6 2 0 2 3 2 e 2 9 8 1a 13 7 3 1 3 l 2 6 2 1 2 4 4 0 j 0 d 4 4f 1g j 3 l 2 v 1b l 1 2 0 55 1a 16 3 11 1b l 0 1o 16 e 0 20 q 12 6 56 17 39 1r w 7 3 0 3 7 2 1 2 n g 0 2 0 2n 7 3 12 h 0 2 0 t 0 b 13 8 0 m 0 c 19 k 0 j 20 7c 8 2 10 i 0 1e t 35 6 2 1 2 11 m 0 q 5 2 1 2 v f 0 94 i g 0 2 c 2 x 3h 0 28 pl 2v 32 i 5f 219 2o g tr i 5 33u g6 6nu fs 8 u i 26 i t j 1b h 3 w k 6 i j5 1r 3l 22 6 0 1v c 1t 1 2 0 t 4qf 9 yd 17 8 6w8 3 2 6 2 1 2 82 g 0 u 2 3 0 f 3 9 az 1s5 2y 6 c 4 8 8 9 4mf 2c 2 1y 2 1 3 0 3 1 3 3 2 b 2 0 2 6 2 1s 2 3 3 7 2 6 2 r 2 3 2 4 2 0 4 6 2 9f 3 o 2 o 2 u 2 o 2 u 2 o 2 u 2 o 2 u 2 o 2 7 1f9 u 7 5 7a 1p 43 18 b 6 h 0 8y t j 17 dh r l1 6 2 3 2 1 2 e 2 5g 1o 1v 8 0 xh 3 2 q 2 1 2 0 3 0 2 9 2 3 2 0 2 0 7 0 5 0 2 0 2 0 2 2 2 1 2 0 3 0 2 0 2 0 2 0 2 0 2 1 2 0 3 3 2 6 2 3 2 3 2 0 2 9 2 g 6 2 2 4 2 g 3et wyn x 37d 7 65 3 4g1 f 5rk g h9 1wj f1 15v 3t6 6 38f");
}
function initLargeIdContinueRanges() {
return restoreRanges("53 0 g9 33 o 0 70 4 7e 18 2 0 2 1 2 1 2 0 21 a 1d u 7 0 2u 6 3 5 3 1 2 3 3 9 o 0 v q 2k a g 9 y 8 a 0 p 3 2 8 2 2 2 4 18 2 1p 7 17 n 2 w 1j 2 2 h 2 6 b 1 3 9 i 2 1l 0 2 6 3 1 3 2 a 0 b 1 3 9 f 0 3 2 1l 0 2 4 5 1 3 2 4 0 l b 4 0 c 2 1l 0 2 7 2 2 2 2 l 1 3 9 b 5 2 2 1l 0 2 6 3 1 3 2 8 2 b 1 3 9 j 0 1o 4 4 2 2 3 a 0 f 9 h 4 1k 0 2 6 2 2 2 3 8 1 c 1 3 9 i 2 1l 0 2 6 2 2 2 3 8 1 c 1 3 9 4 0 d 3 1k 1 2 6 2 2 2 3 a 0 b 1 3 9 i 2 1z 0 5 5 2 0 2 7 7 9 3 1 1q 0 3 6 d 7 2 9 2g 0 3 8 c 6 2 9 1r 1 7 9 c 0 2 0 2 0 5 1 1e j 2 1 6 a 2 z a 0 2t j 2 9 d 3 5 2 2 2 3 6 4 3 e b 2 e jk 2 a 8 pt 3 t 2 u 1 v 1 1t v a 0 3 9 y 2 2 a 40 0 3b b 5 b b 9 3l a 1p 4 1m 9 2 s 3 a 7 9 n d 2 f 1e 4 1c g c 9 i 8 d 2 v c 3 9 19 d 1d j 9 9 7 9 3b 2 2 k 5 0 7 0 3 2 5j 1r el 1 1e 1 k 0 3g c 5 0 4 b 2db 2 3y 0 2p v ff 5 2y 1 2p 0 n51 9 1y 0 5 9 x 1 29 1 7l 0 4 0 5 0 o 4 5 0 2c 1 1f h b 9 7 h e a t 7 q c 19 3 1c d g 9 c 0 b 9 1c d d 0 9 1 3 9 y 2 1f 0 2 2 3 1 6 1 2 0 16 4 6 1 6l 7 2 1 3 9 fmt 0 ki f h f 4 1 p 2 5d 9 12 0 12 0 ig 0 6b 0 46 4 86 9 120 2 2 1 6 3 15 2 5 0 4m 1 fy 3 9 9 aa 1 29 2 1z a 1e 3 3f 2 1i e w a 3 1 b 3 1a a 8 0 1a 9 7 2 11 d 2 9 6 1 19 0 d 2 1d d 9 3 2 b 2b b 7 0 3 0 4e b 6 9 7 3 1k 1 2 6 3 1 3 2 a 0 b 1 3 6 4 4 5d h a 9 5 0 2a j d 9 5y 6 3 8 s 1 2b g g 9 2a c 9 9 2c e 5 9 6r e 4m 9 1z 5 2 1 3 3 2 0 2 1 d 9 3c 6 3 6 4 0 t 9 15 6 2 3 9 0 a a 1b f ba 7 2 7 h 9 1l l 2 d 3f 5 4 0 2 1 2 6 2 0 9 9 1d 4 2 1 2 4 9 9 96 3 a 1 2 0 1d 6 4 4 e 9 44n 0 7 e aob 9 2f 9 13 4 1o 6 q 9 s6 0 2 1i 8 3 2a 0 c 1 f58 1 3mq 19 3 m f3 4 4 5 9 7 3 6 v 3 45 2 13e 1d e9 1i 5 1d 9 0 f 0 n 4 2 e 11t 6 2 g 3 6 2 1 2 4 2t 0 4h 6 a 9 9x 0 1q d dv d rb 6 32 6 6 9 3o7 9 gvt3 6n");
}
function isInRange(cp, ranges) {
let l = 0, r = (ranges.length / 2) | 0, i = 0, min = 0, max = 0;
while (l < r) {
i = ((l + r) / 2) | 0;
min = ranges[2 * i];
max = ranges[2 * i + 1];
if (cp < min) {
r = i;
}
else if (cp > max) {
l = i + 1;
}
else {
return true;
}
}
return false;
}
function restoreRanges(data) {
let last = 0;
return data.split(" ").map((s) => (last += parseInt(s, 36) | 0));
}
class DataSet {
constructor(raw2018, raw2019, raw2020, raw2021, raw2022, raw2023, raw2024) {
this._raw2018 = raw2018;
this._raw2019 = raw2019;
this._raw2020 = raw2020;
this._raw2021 = raw2021;
this._raw2022 = raw2022;
this._raw2023 = raw2023;
this._raw2024 = raw2024;
}
get es2018() {
var _a;
return ((_a = this._set2018) !== null && _a !== void 0 ? _a : (this._set2018 = new Set(this._raw2018.split(" "))));
}
get es2019() {
var _a;
return ((_a = this._set2019) !== null && _a !== void 0 ? _a : (this._set2019 = new Set(this._raw2019.split(" "))));
}
get es2020() {
var _a;
return ((_a = this._set2020) !== null && _a !== void 0 ? _a : (this._set2020 = new Set(this._raw2020.split(" "))));
}
get es2021() {
var _a;
return ((_a = this._set2021) !== null && _a !== void 0 ? _a : (this._set2021 = new Set(this._raw2021.split(" "))));
}
get es2022() {
var _a;
return ((_a = this._set2022) !== null && _a !== void 0 ? _a : (this._set2022 = new Set(this._raw2022.split(" "))));
}
get es2023() {
var _a;
return ((_a = this._set2023) !== null && _a !== void 0 ? _a : (this._set2023 = new Set(this._raw2023.split(" "))));
}
get es2024() {
var _a;
return ((_a = this._set2024) !== null && _a !== void 0 ? _a : (this._set2024 = new Set(this._raw2024.split(" "))));
}
}
const gcNameSet = new Set(["General_Category", "gc"]);
const scNameSet = new Set(["Script", "Script_Extensions", "sc", "scx"]);
const gcValueSets = new DataSet("C Cased_Letter Cc Cf Close_Punctuation Cn Co Combining_Mark Connector_Punctuation Control Cs Currency_Symbol Dash_Punctuation Decimal_Number Enclosing_Mark Final_Punctuation Format Initial_Punctuation L LC Letter Letter_Number Line_Separator Ll Lm Lo Lowercase_Letter Lt Lu M Mark Math_Symbol Mc Me Mn Modifier_Letter Modifier_Symbol N Nd Nl No Nonspacing_Mark Number Open_Punctuation Other Other_Letter Other_Number Other_Punctuation Other_Symbol P Paragraph_Separator Pc Pd Pe Pf Pi Po Private_Use Ps Punctuation S Sc Separator Sk Sm So Space_Separator Spacing_Mark Surrogate Symbol Titlecase_Letter Unassigned Uppercase_Letter Z Zl Zp Zs cntrl digit punct", "", "", "", "", "", "");
const scValueSets = new DataSet("Adlam Adlm Aghb Ahom Anatolian_Hieroglyphs Arab Arabic Armenian Armi Armn Avestan Avst Bali Balinese Bamu Bamum Bass Bassa_Vah Batak Batk Beng Bengali Bhaiksuki Bhks Bopo Bopomofo Brah Brahmi Brai Braille Bugi Buginese Buhd Buhid Cakm Canadian_Aboriginal Cans Cari Carian Caucasian_Albanian Chakma Cham Cher Cherokee Common Copt Coptic Cprt Cuneiform Cypriot Cyrillic Cyrl Deseret Deva Devanagari Dsrt Dupl Duployan Egyp Egyptian_Hieroglyphs Elba Elbasan Ethi Ethiopic Geor Georgian Glag Glagolitic Gonm Goth Gothic Gran Grantha Greek Grek Gujarati Gujr Gurmukhi Guru Han Hang Hangul Hani Hano Hanunoo Hatr Hatran Hebr Hebrew Hira Hiragana Hluw Hmng Hung Imperial_Aramaic Inherited Inscriptional_Pahlavi Inscriptional_Parthian Ital Java Javanese Kaithi Kali Kana Kannada Katakana Kayah_Li Khar Kharoshthi Khmer Khmr Khoj Khojki Khudawadi Knda Kthi Lana Lao Laoo Latin Latn Lepc Lepcha Limb Limbu Lina Linb Linear_A Linear_B Lisu Lyci Lycian Lydi Lydian Mahajani Mahj Malayalam Mand Mandaic Mani Manichaean Marc Marchen Masaram_Gondi Meetei_Mayek Mend Mende_Kikakui Merc Mero Meroitic_Cursive Meroitic_Hieroglyphs Miao Mlym Modi Mong Mongolian Mro Mroo Mtei Mult Multani Myanmar Mymr Nabataean Narb Nbat New_Tai_Lue Newa Nko Nkoo Nshu Nushu Ogam Ogham Ol_Chiki Olck Old_Hungarian Old_Italic Old_North_Arabian Old_Permic Old_Persian Old_South_Arabian Old_Turkic Oriya Orkh Orya Osage Osge Osma Osmanya Pahawh_Hmong Palm Palmyrene Pau_Cin_Hau Pauc Perm Phag Phags_Pa Phli Phlp Phnx Phoenician Plrd Prti Psalter_Pahlavi Qaac Qaai Rejang Rjng Runic Runr Samaritan Samr Sarb Saur Saurashtra Sgnw Sharada Shavian Shaw Shrd Sidd Siddham SignWriting Sind Sinh Sinhala Sora Sora_Sompeng Soyo Soyombo Sund Sundanese Sylo Syloti_Nagri Syrc Syriac Tagalog Tagb Tagbanwa Tai_Le Tai_Tham Tai_Viet Takr Takri Tale Talu Tamil Taml Tang Tangut Tavt Telu Telugu Tfng Tglg Thaa Thaana Thai Tibetan Tibt Tifinagh Tirh Tirhuta Ugar Ugaritic Vai Vaii Wara Warang_Citi Xpeo Xsux Yi Yiii Zanabazar_Square Zanb Zinh Zyyy", "Dogr Dogra Gong Gunjala_Gondi Hanifi_Rohingya Maka Makasar Medefaidrin Medf Old_Sogdian Rohg Sogd Sogdian Sogo", "Elym Elymaic Hmnp Nand Nandinagari Nyiakeng_Puachue_Hmong Wancho Wcho", "Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi", "Cpmn Cypro_Minoan Old_Uyghur Ougr Tangsa Tnsa Toto Vith Vithkuqi", "Hrkt Katakana_Or_Hiragana Kawi Nag_Mundari Nagm Unknown Zzzz", "");
const binPropertySets = new DataSet("AHex ASCII ASCII_Hex_Digit Alpha Alphabetic Any Assigned Bidi_C Bidi_Control Bidi_M Bidi_Mirrored CI CWCF CWCM CWKCF CWL CWT CWU Case_Ignorable Cased Changes_When_Casefolded Changes_When_Casemapped Changes_When_Lowercased Changes_When_NFKC_Casefolded Changes_When_Titlecased Changes_When_Uppercased DI Dash Default_Ignorable_Code_Point Dep Deprecated Dia Diacritic Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Ext Extender Gr_Base Gr_Ext Grapheme_Base Grapheme_Extend Hex Hex_Digit IDC IDS IDSB IDST IDS_Binary_Operator IDS_Trinary_Operator ID_Continue ID_Start Ideo Ideographic Join_C Join_Control LOE Logical_Order_Exception Lower Lowercase Math NChar Noncharacter_Code_Point Pat_Syn Pat_WS Pattern_Syntax Pattern_White_Space QMark Quotation_Mark RI Radical Regional_Indicator SD STerm Sentence_Terminal Soft_Dotted Term Terminal_Punctuation UIdeo Unified_Ideograph Upper Uppercase VS Variation_Selector White_Space XIDC XIDS XID_Continue XID_Start space", "Extended_Pictographic", "", "EBase EComp EMod EPres ExtPict", "", "", "");
const binPropertyOfStringsSets = new DataSet("", "", "", "", "", "", "Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji RGI_Emoji_Flag_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence");
function isValidUnicodeProperty(version, name, value) {
if (gcNameSet.has(name)) {
return version >= 2018 && gcValueSets.es2018.has(value);
}
if (scNameSet.has(name)) {
return ((version >= 2018 && scValueSets.es2018.has(value)) ||
(version >= 2019 && scValueSets.es2019.has(value)) ||
(version >= 2020 && scValueSets.es2020.has(value)) ||
(version >= 2021 && scValueSets.es2021.has(value)) ||
(version >= 2022 && scValueSets.es2022.has(value)) ||
(version >= 2023 && scValueSets.es2023.has(value)));
}
return false;
}
function isValidLoneUnicodeProperty(version, value) {
return ((version >= 2018 && binPropertySets.es2018.has(value)) ||
(version >= 2019 && binPropertySets.es2019.has(value)) ||
(version >= 2021 && binPropertySets.es2021.has(value)));
}
function isValidLoneUnicodePropertyOfString(version, value) {
return version >= 2024 && binPropertyOfStringsSets.es2024.has(value);
}
const BACKSPACE = 0x08;
const CHARACTER_TABULATION = 0x09;
const LINE_FEED = 0x0a;
const LINE_TABULATION = 0x0b;
const FORM_FEED = 0x0c;
const CARRIAGE_RETURN = 0x0d;
const EXCLAMATION_MARK = 0x21;
const NUMBER_SIGN = 0x23;
const DOLLAR_SIGN = 0x24;
const PERCENT_SIGN = 0x25;
const AMPERSAND = 0x26;
const LEFT_PARENTHESIS = 0x28;
const RIGHT_PARENTHESIS = 0x29;
const ASTERISK = 0x2a;
const PLUS_SIGN = 0x2b;
const COMMA = 0x2c;
const HYPHEN_MINUS = 0x2d;
const FULL_STOP = 0x2e;
const SOLIDUS = 0x2f;
const DIGIT_ZERO = 0x30;
const DIGIT_ONE = 0x31;
const DIGIT_SEVEN = 0x37;
const DIGIT_NINE = 0x39;
const COLON = 0x3a;
const SEMICOLON = 0x3b;
const LESS_THAN_SIGN = 0x3c;
const EQUALS_SIGN = 0x3d;
const GREATER_THAN_SIGN = 0x3e;
const QUESTION_MARK = 0x3f;
const COMMERCIAL_AT = 0x40;
const LATIN_CAPITAL_LETTER_A = 0x41;
const LATIN_CAPITAL_LETTER_B = 0x42;
const LATIN_CAPITAL_LETTER_D = 0x44;
const LATIN_CAPITAL_LETTER_F = 0x46;
const LATIN_CAPITAL_LETTER_P = 0x50;
const LATIN_CAPITAL_LETTER_S = 0x53;
const LATIN_CAPITAL_LETTER_W = 0x57;
const LATIN_CAPITAL_LETTER_Z = 0x5a;
const LOW_LINE = 0x5f;
const LATIN_SMALL_LETTER_A = 0x61;
const LATIN_SMALL_LETTER_B = 0x62;
const LATIN_SMALL_LETTER_C = 0x63;
const LATIN_SMALL_LETTER_D = 0x64;
const LATIN_SMALL_LETTER_F = 0x66;
const LATIN_SMALL_LETTER_G = 0x67;
const LATIN_SMALL_LETTER_I = 0x69;
const LATIN_SMALL_LETTER_K = 0x6b;
const LATIN_SMALL_LETTER_M = 0x6d;
const LATIN_SMALL_LETTER_N = 0x6e;
const LATIN_SMALL_LETTER_P = 0x70;
const LATIN_SMALL_LETTER_Q = 0x71;
const LATIN_SMALL_LETTER_R = 0x72;
const LATIN_SMALL_LETTER_S = 0x73;
const LATIN_SMALL_LETTER_T = 0x74;
const LATIN_SMALL_LETTER_U = 0x75;
const LATIN_SMALL_LETTER_V = 0x76;
const LATIN_SMALL_LETTER_W = 0x77;
const LATIN_SMALL_LETTER_X = 0x78;
const LATIN_SMALL_LETTER_Y = 0x79;
const LATIN_SMALL_LETTER_Z = 0x7a;
const LEFT_SQUARE_BRACKET = 0x5b;
const REVERSE_SOLIDUS = 0x5c;
const RIGHT_SQUARE_BRACKET = 0x5d;
const CIRCUMFLEX_ACCENT = 0x5e;
const GRAVE_ACCENT = 0x60;
const LEFT_CURLY_BRACKET = 0x7b;
const VERTICAL_LINE = 0x7c;
const RIGHT_CURLY_BRACKET = 0x7d;
const TILDE = 0x7e;
const ZERO_WIDTH_NON_JOINER = 0x200c;
const ZERO_WIDTH_JOINER = 0x200d;
const LINE_SEPARATOR = 0x2028;
const PARAGRAPH_SEPARATOR = 0x2029;
const MIN_CODE_POINT = 0x00;
const MAX_CODE_POINT = 0x10ffff;
function isLatinLetter(code) {
return ((code >= LATIN_CAPITAL_LETTER_A && code <= LATIN_CAPITAL_LETTER_Z) ||
(code >= LATIN_SMALL_LETTER_A && code <= LATIN_SMALL_LETTER_Z));
}
function isDecimalDigit(code) {
return code >= DIGIT_ZERO && code <= DIGIT_NINE;
}
function isOctalDigit(code) {
return code >= DIGIT_ZERO && code <= DIGIT_SEVEN;
}
function isHexDigit(code) {
return ((code >= DIGIT_ZERO && code <= DIGIT_NINE) ||
(code >= LATIN_CAPITAL_LETTER_A && code <= LATIN_CAPITAL_LETTER_F) ||
(code >= LATIN_SMALL_LETTER_A && code <= LATIN_SMALL_LETTER_F));
}
function isLineTerminator(code) {
return (code === LINE_FEED ||
code === CARRIAGE_RETURN ||
code === LINE_SEPARATOR ||
code === PARAGRAPH_SEPARATOR);
}
function isValidUnicode(code) {
return code >= MIN_CODE_POINT && code <= MAX_CODE_POINT;
}
function digitToInt(code) {
if (code >= LATIN_SMALL_LETTER_A && code <= LATIN_SMALL_LETTER_F) {
return code - LATIN_SMALL_LETTER_A + 10;
}
if (code >= LATIN_CAPITAL_LETTER_A && code <= LATIN_CAPITAL_LETTER_F) {
return code - LATIN_CAPITAL_LETTER_A + 10;
}
return code - DIGIT_ZERO;
}
function isLeadSurrogate(code) {
return code >= 0xd800 && code <= 0xdbff;
}
function isTrailSurrogate(code) {
return code >= 0xdc00 && code <= 0xdfff;
}
function combineSurrogatePair(lead, trail) {
return (lead - 0xd800) * 0x400 + (trail - 0xdc00) + 0x10000;
}
const legacyImpl = {
at(s, end, i) {
return i < end ? s.charCodeAt(i) : -1;
},
width(c) {
return 1;
},
};
const unicodeImpl = {
at(s, end, i) {
return i < end ? s.codePointAt(i) : -1;
},
width(c) {
return c > 0xffff ? 2 : 1;
},
};
class Reader {
constructor() {
this._impl = legacyImpl;
this._s = "";
this._i = 0;
this._end = 0;
this._cp1 = -1;
this._w1 = 1;
this._cp2 = -1;
this._w2 = 1;
this._cp3 = -1;
this._w3 = 1;
this._cp4 = -1;
}
get source() {
return this._s;
}
get index() {
return this._i;
}
get currentCodePoint() {
return this._cp1;
}
get nextCodePoint() {
return this._cp2;
}
get nextCodePoint2() {
return this._cp3;
}
get nextCodePoint3() {
return this._cp4;
}
reset(source, start, end, uFlag) {
this._impl = uFlag ? unicodeImpl : legacyImpl;
this._s = source;
this._end = end;
this.rewind(start);
}
rewind(index) {
const impl = this._impl;
this._i = index;
this._cp1 = impl.at(this._s, this._end, index);
this._w1 = impl.width(this._cp1);
this._cp2 = impl.at(this._s, this._end, index + this._w1);
this._w2 = impl.width(this._cp2);
this._cp3 = impl.at(this._s, this._end, index + this._w1 + this._w2);
this._w3 = impl.width(this._cp3);
this._cp4 = impl.at(this._s, this._end, index + this._w1 + this._w2 + this._w3);
}
advance() {
if (this._cp1 !== -1) {
const impl = this._impl;
this._i += this._w1;
this._cp1 = this._cp2;
this._w1 = this._w2;
this._cp2 = this._cp3;
this._w2 = impl.width(this._cp2);
this._cp3 = this._cp4;
this._w3 = impl.width(this._cp3);
this._cp4 = impl.at(this._s, this._end, this._i + this._w1 + this._w2 + this._w3);
}
}
eat(cp) {
if (this._cp1 === cp) {
this.advance();
return true;
}
return false;
}
eat2(cp1, cp2) {
if (this._cp1 === cp1 && this._cp2 === cp2) {
this.advance();
this.advance();
return true;
}
return false;
}
eat3(cp1, cp2, cp3) {
if (this._cp1 === cp1 && this._cp2 === cp2 && this._cp3 === cp3) {
this.advance();
this.advance();
this.advance();
return true;
}
return false;
}
}
class RegExpSyntaxError extends SyntaxError {
constructor(message, index) {
super(message);
this.index = index;
}
}
function newRegExpSyntaxError(srcCtx, flags, index, message) {
let source = "";
if (srcCtx.kind === "literal") {
const literal = srcCtx.source.slice(srcCtx.start, srcCtx.end);
if (literal) {
source = `: ${literal}`;
}
}
else if (srcCtx.kind === "pattern") {
const pattern = srcCtx.source.slice(srcCtx.start, srcCtx.end);
const flagsText = `${flags.unicode ? "u" : ""}${flags.unicodeSets ? "v" : ""}`;
source = `: /${pattern}/${flagsText}`;
}
return new RegExpSyntaxError(`Invalid regular expression${source}: ${message}`, index);
}
const SYNTAX_CHARACTER = new Set([
CIRCUMFLEX_ACCENT,
DOLLAR_SIGN,
REVERSE_SOLIDUS,
FULL_STOP,
ASTERISK,
PLUS_SIGN,
QUESTION_MARK,
LEFT_PARENTHESIS,
RIGHT_PARENTHESIS,
LEFT_SQUARE_BRACKET,
RIGHT_SQUARE_BRACKET,
LEFT_CURLY_BRACKET,
RIGHT_CURLY_BRACKET,
VERTICAL_LINE,
]);
const CLASS_SET_RESERVED_DOUBLE_PUNCTUATOR_CHARACTER = new Set([
AMPERSAND,
EXCLAMATION_MARK,
NUMBER_SIGN,
DOLLAR_SIGN,
PERCENT_SIGN,
ASTERISK,
PLUS_SIGN,
COMMA,
FULL_STOP,
COLON,
SEMICOLON,
LESS_THAN_SIGN,
EQUALS_SIGN,
GREATER_THAN_SIGN,
QUESTION_MARK,
COMMERCIAL_AT,
CIRCUMFLEX_ACCENT,
GRAVE_ACCENT,
TILDE,
]);
const CLASS_SET_SYNTAX_CHARACTER = new Set([
LEFT_PARENTHESIS,
RIGHT_PARENTHESIS,
LEFT_SQUARE_BRACKET,
RIGHT_SQUARE_BRACKET,
LEFT_CURLY_BRACKET,
RIGHT_CURLY_BRACKET,
SOLIDUS,
HYPHEN_MINUS,
REVERSE_SOLIDUS,
VERTICAL_LINE,
]);
const CLASS_SET_RESERVED_PUNCTUATOR = new Set([
AMPERSAND,
HYPHEN_MINUS,
EXCLAMATION_MARK,
NUMBER_SIGN,
PERCENT_SIGN,
COMMA,
COLON,
SEMICOLON,
LESS_THAN_SIGN,
EQUALS_SIGN,
GREATER_THAN_SIGN,
COMMERCIAL_AT,
GRAVE_ACCENT,
TILDE,
]);
function isSyntaxCharacter(cp) {
return SYNTAX_CHARACTER.has(cp);
}
function isClassSetReservedDoublePunctuatorCharacter(cp) {
return CLASS_SET_RESERVED_DOUBLE_PUNCTUATOR_CHARACTER.has(cp);
}
function isClassSetSyntaxCharacter(cp) {
return CLASS_SET_SYNTAX_CHARACTER.has(cp);
}
function isClassSetReservedPunctuator(cp) {
return CLASS_SET_RESERVED_PUNCTUATOR.has(cp);
}
function isIdentifierStartChar(cp) {
return isIdStart(cp) || cp === DOLLAR_SIGN || cp === LOW_LINE;
}
function isIdentifierPartChar(cp) {
return (isIdContinue(cp) ||
cp === DOLLAR_SIGN ||
cp === ZERO_WIDTH_NON_JOINER ||
cp === ZERO_WIDTH_JOINER);
}
function isUnicodePropertyNameCharacter(cp) {
return isLatinLetter(cp) || cp === LOW_LINE;
}
function isUnicodePropertyValueCharacter(cp) {
return isUnicodePropertyNameCharacter(cp) || isDecimalDigit(cp);
}
class RegExpValidator {
constructor(options) {
this._reader = new Reader();
this._unicodeMode = false;
this._unicodeSetsMode = false;
this._nFlag = false;
this._lastIntValue = 0;
this._lastRange = {
min: 0,
max: Number.POSITIVE_INFINITY,
};
this._lastStrValue = "";
this._lastAssertionIsQuantifiable = false;
this._numCapturingParens = 0;
this._groupNames = new Set();
this._backreferenceNames = new Set();
this._srcCtx = null;
this._options = options !== null && options !== void 0 ? options : {};
}
validateLiteral(source, start = 0, end = source.length) {
this._srcCtx = { source, start, end, kind: "literal" };
this._unicodeSetsMode = this._unicodeMode = this._nFlag = false;
this.reset(source, start, end);
this.onLiteralEnter(start);
if (this.eat(SOLIDUS) && this.eatRegExpBody() && this.eat(SOLIDUS)) {
const flagStart = this.index;
const unicode = source.includes("u", flagStart);
const unicodeSets = source.includes("v", flagStart);
this.validateFlagsInternal(source, flagStart, end);
this.validatePatternInternal(source, start + 1, flagStart - 1, {
unicode,
unicodeSets,
});
}
else if (start >= end) {
this.raise("Empty");
}
else {
const c = String.fromCodePoint(this.currentCodePoint);
this.raise(`Unexpected character '${c}'`);
}
this.onLiteralLeave(start, end);
}
validateFlags(source, start = 0, end = source.length) {
this._srcCtx = { source, start, end, kind: "flags" };
this.validateFlagsInternal(source, start, end);
}
validatePattern(source, start = 0, end = source.length, uFlagOrFlags = undefined) {
this._srcCtx = { source, start, end, kind: "pattern" };
this.validatePatternInternal(source, start, end, uFlagOrFlags);
}
validatePatternInternal(source, start = 0, end = source.length, uFlagOrFlags = undefined) {
const mode = this._parseFlagsOptionToMode(uFlagOrFlags, end);
this._unicodeMode = mode.unicodeMode;
this._nFlag = mode.nFlag;
this._unicodeSetsMode = mode.unicodeSetsMode;
this.reset(source, start, end);
this.consumePattern();
if (!this._nFlag &&
this.ecmaVersion >= 2018 &&
this._groupNames.size > 0) {
this._nFlag = true;
this.rewind(start);
this.consumePattern();
}
}
validateFlagsInternal(source, start, end) {
const existingFlags = new Set();
let global = false;
let ignoreCase = false;
let multiline = false;
let sticky = false;
let unicode = false;
let dotAll = false;
let hasIndices = false;
let unicodeSets = false;
for (let i = start; i < end; ++i) {
const flag = source.charCodeAt(i);
if (existingFlags.has(flag)) {
this.raise(`Duplicated flag '${source[i]}'`, { index: start });
}
existingFlags.add(flag);
if (flag === LATIN_SMALL_LETTER_G) {
global = true;
}
else if (flag === LATIN_SMALL_LETTER_I) {
ignoreCase = true;
}
else if (flag === LATIN_SMALL_LETTER_M) {
multiline = true;
}
else if (flag === LATIN_SMALL_LETTER_U &&
this.ecmaVersion >= 2015) {
unicode = true;
}
else if (flag === LATIN_SMALL_LETTER_Y &&
this.ecmaVersion >= 2015) {
sticky = true;
}
else if (flag === LATIN_SMALL_LETTER_S &&
this.ecmaVersion >= 2018) {
dotAll = true;
}
else if (flag === LATIN_SMALL_LETTER_D &&
this.ecmaVersion >= 2022) {
hasIndices = true;
}
else if (flag === LATIN_SMALL_LETTER_V &&
this.ecmaVersion >= 2024) {
unicodeSets = true;
}
else {
this.raise(`Invalid flag '${source[i]}'`, { index: start });
}
}
this.onRegExpFlags(start, end, {
global,
ignoreCase,
multiline,
unicode,
sticky,
dotAll,
hasIndices,
unicodeSets,
});
}
_parseFlagsOptionToMode(uFlagOrFlags, sourceEnd) {
let unicode = false;
let unicodeSets = false;
if (uFlagOrFlags && this.ecmaVersion >= 2015) {
if (typeof uFlagOrFlags === "object") {
unicode = Boolean(uFlagOrFlags.unicode);
if (this.ecmaVersion >= 2024) {
unicodeSets = Boolean(uFlagOrFlags.unicodeSets);
}
}
else {
unicode = uFlagOrFlags;
}
}
if (unicode && unicodeSets) {
this.raise("Invalid regular expression flags", {
index: sourceEnd + 1,
unicode,
unicodeSets,
});
}
const unicodeMode = unicode || unicodeSets;
const nFlag = (unicode && this.ecmaVersion >= 2018) ||
unicodeSets ||
Boolean(this._options.strict && this.ecmaVersion >= 2023);
const unicodeSetsMode = unicodeSets;
return { unicodeMode, nFlag, unicodeSetsMode };
}
get strict() {
return Boolean(this._options.strict) || this._unicodeMode;
}
get ecmaVersion() {
var _a;
return (_a = this._options.ecmaVersion) !== null && _a !== void 0 ? _a : latestEcmaVersion;
}
onLiteralEnter(start) {
if (this._options.onLiteralEnter) {
this._options.onLiteralEnter(start);
}
}
onLiteralLeave(start, end) {
if (this._options.onLiteralLeave) {
this._options.onLiteralLeave(start, end);
}
}
onRegExpFlags(start, end, flags) {
if (this._options.onRegExpFlags) {
this._options.onRegExpFlags(start, end, flags);
}
if (this._options.onFlags) {
this._options.onFlags(start, end, flags.global, flags.ignoreCase, flags.multiline, flags.unicode, flags.sticky, flags.dotAll, flags.hasIndices);
}
}
onPatternEnter(start) {
if (this._options.onPatternEnter) {
this._options.onPatternEnter(start);
}
}
onPatternLeave(start, end) {
if (this._options.onPatternLeave) {
this._options.onPatternLeave(start, end);
}
}
onDisjunctionEnter(start) {
if (this._options.onDisjunctionEnter) {
this._options.onDisjunctionEnter(start);
}
}
onDisjunctionLeave(start, end) {
if (this._options.onDisjunctionLeave) {
this._options.onDisjunctionLeave(start, end);
}
}
onAlternativeEnter(start, index) {
if (this._options.onAlternativeEnter) {
this._options.onAlternativeEnter(start, index);
}
}
onAlternativeLeave(start, end, index) {
if (this._options.onAlternativeLeave) {
this._options.onAlternativeLeave(start, end, index);
}
}
onGroupEnter(start) {
if (this._options.onGroupEnter) {
this._options.onGroupEnter(start);
}
}
onGroupLeave(start, end) {
if (this._options.onGroupLeave) {
this._options.onGroupLeave(start, end);
}
}
onCapturingGroupEnter(start, name) {
if (this._options.onCapturingGroupEnter) {
this._options.onCapturingGroupEnter(start, name);
}
}
onCapturingGroupLeave(start, end, name) {
if (this._options.onCapturingGroupLeave) {
this._options.onCapturingGroupLeave(start, end, name);
}
}
onQuantifier(start, end, min, max, greedy) {
if (this._options.onQuantifier) {
this._options.onQuantifier(start, end, min, max, greedy);
}
}
onLookaroundAssertionEnter(start, kind, negate) {
if (this._options.onLookaroundAssertionEnter) {
this._options.onLookaroundAssertionEnter(start, kind, negate);
}
}
onLookaroundAssertionLeave(start, end, kind, negate) {
if (this._options.onLookaroundAssertionLeave) {
this._options.onLookaroundAssertionLeave(start, end, kind, negate);
}
}
onEdgeAssertion(start, end, kind) {
if (this._options.onEdgeAssertion) {
this._options.onEdgeAssertion(start, end, kind);
}
}
onWordBoundaryAssertion(start, end, kind, negate) {
if (this._options.onWordBoundaryAssertion) {
this._options.onWordBoundaryAssertion(start, end, kind, negate);
}
}
onAnyCharacterSet(start, end, kind) {
if (this._options.onAnyCharacterSet) {
this._options.onAnyCharacterSet(start, end, kind);
}
}
onEscapeCharacterSet(start, end, kind, negate) {
if (this._options.onEscapeCharacterSet) {
this._options.onEscapeCharacterSet(start, end, kind, negate);
}
}
onUnicodePropertyCharacterSet(start, end, kind, key, value, negate, strings) {
if (this._options.onUnicodePropertyCharacterSet) {
this._options.onUnicodePropertyCharacterSet(start, end, kind, key, value, negate, strings);
}
}
onCharacter(start, end, value) {
if (this._options.onCharacter) {
this._options.onCharacter(start, end, value);
}
}
onBackreference(start, end, ref) {
if (this._options.onBackreference) {
this._options.onBackreference(start, end, ref);
}
}
onCharacterClassEnter(start, negate, unicodeSets) {
if (this._options.onCharacterClassEnter) {
this._options.onCharacterClassEnter(start, negate, unicodeSets);
}
}
onCharacterClassLeave(start, end, negate) {
if (this._options.onCharacterClassLeave) {
this._options.onCharacterClassLeave(start, end, negate);
}
}
onCharacterClassRange(start, end, min, max) {
if (this._options.onCharacterClassRange) {
this._options.onCharacterClassRange(start, end, min, max);
}
}
onClassIntersection(start, end) {
if (this._options.onClassIntersection) {
this._options.onClassIntersection(start, end);
}
}
onClassSubtraction(start, end) {
if (this._options.onClassSubtraction) {
this._options.onClassSubtraction(start, end);
}
}
onClassStringDisjunctionEnter(start) {
if (this._options.onClassStringDisjunctionEnter) {
this._options.onClassStringDisjunctionEnter(start);
}
}
onClassStringDisjunctionLeave(start, end) {
if (this._options.onClassStringDisjunctionLeave) {
this._options.onClassStringDisjunctionLeave(start, end);
}
}
onStringAlternativeEnter(start, index) {
if (this._options.onStringAlternativeEnter) {
this._options.onStringAlternativeEnter(start, index);
}
}
onStringAlternativeLeave(start, end, index) {
if (this._options.onStringAlternativeLeave) {
this._options.onStringAlternativeLeave(start, end, index);
}
}
get index() {
return this._reader.index;
}
get currentCodePoint() {
return this._reader.currentCodePoint;
}
get nextCodePoint() {
return this._reader.nextCodePoint;
}
get nextCodePoint2() {
return this._reader.nextCodePoint2;
}
get nextCodePoint3() {
return this._reader.nextCodePoint3;
}
reset(source, start, end) {
this._reader.reset(source, start, end, this._unicodeMode);
}
rewind(index) {
this._reader.rewind(index);
}
advance() {
this._reader.advance();
}
eat(cp) {
return this._reader.eat(cp);
}
eat2(cp1, cp2) {
return this._reader.eat2(cp1, cp2);
}
eat3(cp1, cp2, cp3) {
return this._reader.eat3(cp1, cp2, cp3);
}
raise(message, context) {
var _a, _b, _c;
throw newRegExpSyntaxError(this._srcCtx, {
unicode: (_a = context === null || context === void 0 ? void 0 : context.unicode) !== null && _a !== void 0 ? _a : (this._unicodeMode && !this._unicodeSetsMode),
unicodeSets: (_b = context === null || context === void 0 ? void 0 : context.unicodeSets) !== null && _b !== void 0 ? _b : this._unicodeSetsMode,
}, (_c = context === null || context === void 0 ? void 0 : context.index) !== null && _c !== void 0 ? _c : this.index, message);
}
eatRegExpBody() {
const start = this.index;
let inClass = false;
let escaped = false;
for (;;) {
const cp = this.currentCodePoint;
if (cp === -1 || isLineTerminator(cp)) {
const kind = inClass ? "character class" : "regular expression";
this.raise(`Unterminated ${kind}`);
}
if (escaped) {
escaped = false;
}
else if (cp === REVERSE_SOLIDUS) {
escaped = true;
}
else if (cp === LEFT_SQUARE_BRACKET) {
inClass = true;
}
else if (cp === RIGHT_SQUARE_BRACKET) {
inClass = false;
}
else if ((cp === SOLIDUS && !inClass) ||
(cp === ASTERISK && this.index === start)) {
break;
}
this.advance();
}
return this.index !== start;
}
consumePattern() {
const start = this.index;
this._numCapturingParens = this.countCapturingParens();
this._groupNames.clear();
this._backreferenceNames.clear();
this.onPatternEnter(start);
this.consumeDisjunction();
const cp = this.currentCodePoint;
if (this.currentCodePoint !== -1) {
if (cp === RIGHT_PARENTHESIS) {
this.raise("Unmatched ')'");
}
if (cp === REVERSE_SOLIDUS) {
this.raise("\\ at end of pattern");
}
if (cp === RIGHT_SQUARE_BRACKET || cp === RIGHT_CURLY_BRACKET) {
this.raise("Lone quantifier brackets");
}
const c = String.fromCodePoint(cp);
this.raise(`Unexpected character '${c}'`);
}
for (const name of this._backreferenceNames) {
if (!this._groupNames.has(name)) {
this.raise("Invalid named capture referenced");
}
}
this.onPatternLeave(start, this.index);
}
countCapturingParens() {
const start = this.index;
let inClass = false;
let escaped = false;
let count = 0;
let cp = 0;
while ((cp = this.currentCodePoint) !== -1) {
if (escaped) {
escaped = false;
}
else if (cp === REVERSE_SOLIDUS) {
escaped = true;
}
else if (cp === LEFT_SQUARE_BRACKET) {
inClass = true;
}
else if (cp === RIGHT_SQUARE_BRACKET) {
inClass = false;
}
else if (cp === LEFT_PARENTHESIS &&
!inClass &&
(this.nextCodePoint !== QUESTION_MARK ||
(this.nextCodePoint2 === LESS_THAN_SIGN &&
this.nextCodePoint3 !== EQUALS_SIGN &&
this.nextCodePoint3 !== EXCLAMATION_MARK))) {
count += 1;
}
this.advance();
}
this.rewind(start);
return count;
}
consumeDisjunction() {
const start = this.index;
let i = 0;
this.onDisjunctionEnter(start);
do {
this.consumeAlternative(i++);
} while (this.eat(VERTICAL_LINE));
if (this.consumeQuantifier(true)) {
this.raise("Nothing to repeat");
}
if (this.eat(LEFT_CURLY_BRACKET)) {
this.raise("Lone quantifier brackets");
}
this.onDisjunctionLeave(start, this.index);
}
consumeAlternative(i) {
const start = this.index;
this.onAlternativeEnter(start, i);
while (this.currentCodePoint !== -1 && this.consumeTerm()) {
}
this.onAlternativeLeave(start, this.index, i);
}
consumeTerm() {
if (this._unicodeMode || this.strict) {
return (this.consumeAssertion() ||
(this.consumeAtom() && this.consumeOptionalQuantifier()));
}
return ((this.consumeAssertion() &&
(!this._lastAssertionIsQuantifiable ||
this.consumeOptionalQuantifier())) ||
(this.consumeExtendedAtom() && this.consumeOptionalQuantifier()));
}
consumeOptionalQuantifier() {
this.consumeQuantifier();
return true;
}
consumeAssertion() {
const start = this.index;
this._lastAssertionIsQuantifiable = false;
if (this.eat(CIRCUMFLEX_ACCENT)) {
this.onEdgeAssertion(start, this.index, "start");
return true;
}
if (this.eat(DOLLAR_SIGN)) {
this.onEdgeAssertion(start, this.index, "end");
return true;
}
if (this.eat2(REVERSE_SOLIDUS, LATIN_CAPITAL_LETTER_B)) {
this.onWordBoundaryAssertion(start, this.index, "word", true);
return true;
}
if (this.eat2(REVERSE_SOLIDUS, LATIN_SMALL_LETTER_B)) {
this.onWordBoundaryAssertion(start, this.index, "word", false);
return true;
}
if (this.eat2(LEFT_PARENTHESIS, QUESTION_MARK)) {
const lookbehind = this.ecmaVersion >= 2018 && this.eat(LESS_THAN_SIGN);
let negate = false;
if (this.eat(EQUALS_SIGN) ||
(negate = this.eat(EXCLAMATION_MARK))) {
const kind = lookbehind ? "lookbehind" : "lookahead";
this.onLookaroundAssertionEnter(start, kind, negate);
this.consumeDisjunction();
if (!this.eat(RIGHT_PARENTHESIS)) {
this.raise("Unterminated group");
}
this._lastAssertionIsQuantifiable = !lookbehind && !this.strict;