@anlijiu/markmap 1.0.1 → 1.0.3

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.
@@ -7207,7 +7207,7 @@ function _unsupportedIterableToArray(r, a) {
7207
7207
  }
7208
7208
  __name(_unsupportedIterableToArray, "_unsupportedIterableToArray");
7209
7209
  var _window = typeof window === "undefined" ? null : window;
7210
- var navigator = _window ? _window.navigator : null;
7210
+ var navigator2 = _window ? _window.navigator : null;
7211
7211
  _window ? _window.document : null;
7212
7212
  var typeofstr = _typeof("");
7213
7213
  var typeofobj = _typeof({});
@@ -7285,7 +7285,7 @@ var promise = /* @__PURE__ */ __name(function promise2(obj) {
7285
7285
  return object(obj) && fn$6(obj.then);
7286
7286
  }, "promise");
7287
7287
  var ms = /* @__PURE__ */ __name(function ms2() {
7288
- return navigator && navigator.userAgent.match(/msie|trident|edge/i);
7288
+ return navigator2 && navigator2.userAgent.match(/msie|trident|edge/i);
7289
7289
  }, "ms");
7290
7290
  var memoize = /* @__PURE__ */ __name(function memoize2(fn3, keyFn) {
7291
7291
  if (!keyFn) {
@@ -39458,6 +39458,3757 @@ var updateLows = /* @__PURE__ */ __name((lowY, index, lastLows) => {
39458
39458
  };
39459
39459
  }, "updateLows");
39460
39460
 
39461
+ // ../../node_modules/.pnpm/@chenglou+pretext@0.0.5/node_modules/@chenglou/pretext/dist/generated/bidi-data.js
39462
+ var latin1BidiTypes = [
39463
+ "BN",
39464
+ "BN",
39465
+ "BN",
39466
+ "BN",
39467
+ "BN",
39468
+ "BN",
39469
+ "BN",
39470
+ "BN",
39471
+ "BN",
39472
+ "S",
39473
+ "B",
39474
+ "S",
39475
+ "WS",
39476
+ "B",
39477
+ "BN",
39478
+ "BN",
39479
+ "BN",
39480
+ "BN",
39481
+ "BN",
39482
+ "BN",
39483
+ "BN",
39484
+ "BN",
39485
+ "BN",
39486
+ "BN",
39487
+ "BN",
39488
+ "BN",
39489
+ "BN",
39490
+ "BN",
39491
+ "B",
39492
+ "B",
39493
+ "B",
39494
+ "S",
39495
+ "WS",
39496
+ "ON",
39497
+ "ON",
39498
+ "ET",
39499
+ "ET",
39500
+ "ET",
39501
+ "ON",
39502
+ "ON",
39503
+ "ON",
39504
+ "ON",
39505
+ "ON",
39506
+ "ES",
39507
+ "CS",
39508
+ "ES",
39509
+ "CS",
39510
+ "CS",
39511
+ "EN",
39512
+ "EN",
39513
+ "EN",
39514
+ "EN",
39515
+ "EN",
39516
+ "EN",
39517
+ "EN",
39518
+ "EN",
39519
+ "EN",
39520
+ "EN",
39521
+ "CS",
39522
+ "ON",
39523
+ "ON",
39524
+ "ON",
39525
+ "ON",
39526
+ "ON",
39527
+ "ON",
39528
+ "L",
39529
+ "L",
39530
+ "L",
39531
+ "L",
39532
+ "L",
39533
+ "L",
39534
+ "L",
39535
+ "L",
39536
+ "L",
39537
+ "L",
39538
+ "L",
39539
+ "L",
39540
+ "L",
39541
+ "L",
39542
+ "L",
39543
+ "L",
39544
+ "L",
39545
+ "L",
39546
+ "L",
39547
+ "L",
39548
+ "L",
39549
+ "L",
39550
+ "L",
39551
+ "L",
39552
+ "L",
39553
+ "L",
39554
+ "ON",
39555
+ "ON",
39556
+ "ON",
39557
+ "ON",
39558
+ "ON",
39559
+ "ON",
39560
+ "L",
39561
+ "L",
39562
+ "L",
39563
+ "L",
39564
+ "L",
39565
+ "L",
39566
+ "L",
39567
+ "L",
39568
+ "L",
39569
+ "L",
39570
+ "L",
39571
+ "L",
39572
+ "L",
39573
+ "L",
39574
+ "L",
39575
+ "L",
39576
+ "L",
39577
+ "L",
39578
+ "L",
39579
+ "L",
39580
+ "L",
39581
+ "L",
39582
+ "L",
39583
+ "L",
39584
+ "L",
39585
+ "L",
39586
+ "ON",
39587
+ "ON",
39588
+ "ON",
39589
+ "ON",
39590
+ "BN",
39591
+ "BN",
39592
+ "BN",
39593
+ "BN",
39594
+ "BN",
39595
+ "BN",
39596
+ "B",
39597
+ "BN",
39598
+ "BN",
39599
+ "BN",
39600
+ "BN",
39601
+ "BN",
39602
+ "BN",
39603
+ "BN",
39604
+ "BN",
39605
+ "BN",
39606
+ "BN",
39607
+ "BN",
39608
+ "BN",
39609
+ "BN",
39610
+ "BN",
39611
+ "BN",
39612
+ "BN",
39613
+ "BN",
39614
+ "BN",
39615
+ "BN",
39616
+ "BN",
39617
+ "BN",
39618
+ "BN",
39619
+ "BN",
39620
+ "BN",
39621
+ "BN",
39622
+ "BN",
39623
+ "CS",
39624
+ "ON",
39625
+ "ET",
39626
+ "ET",
39627
+ "ET",
39628
+ "ET",
39629
+ "ON",
39630
+ "ON",
39631
+ "ON",
39632
+ "ON",
39633
+ "L",
39634
+ "ON",
39635
+ "ON",
39636
+ "BN",
39637
+ "ON",
39638
+ "ON",
39639
+ "ET",
39640
+ "ET",
39641
+ "EN",
39642
+ "EN",
39643
+ "ON",
39644
+ "L",
39645
+ "ON",
39646
+ "ON",
39647
+ "ON",
39648
+ "EN",
39649
+ "L",
39650
+ "ON",
39651
+ "ON",
39652
+ "ON",
39653
+ "ON",
39654
+ "ON",
39655
+ "L",
39656
+ "L",
39657
+ "L",
39658
+ "L",
39659
+ "L",
39660
+ "L",
39661
+ "L",
39662
+ "L",
39663
+ "L",
39664
+ "L",
39665
+ "L",
39666
+ "L",
39667
+ "L",
39668
+ "L",
39669
+ "L",
39670
+ "L",
39671
+ "L",
39672
+ "L",
39673
+ "L",
39674
+ "L",
39675
+ "L",
39676
+ "L",
39677
+ "L",
39678
+ "ON",
39679
+ "L",
39680
+ "L",
39681
+ "L",
39682
+ "L",
39683
+ "L",
39684
+ "L",
39685
+ "L",
39686
+ "L",
39687
+ "L",
39688
+ "L",
39689
+ "L",
39690
+ "L",
39691
+ "L",
39692
+ "L",
39693
+ "L",
39694
+ "L",
39695
+ "L",
39696
+ "L",
39697
+ "L",
39698
+ "L",
39699
+ "L",
39700
+ "L",
39701
+ "L",
39702
+ "L",
39703
+ "L",
39704
+ "L",
39705
+ "L",
39706
+ "L",
39707
+ "L",
39708
+ "L",
39709
+ "L",
39710
+ "ON",
39711
+ "L",
39712
+ "L",
39713
+ "L",
39714
+ "L",
39715
+ "L",
39716
+ "L",
39717
+ "L",
39718
+ "L"
39719
+ ];
39720
+ var nonLatin1BidiRanges = [
39721
+ [697, 698, "ON"],
39722
+ [706, 719, "ON"],
39723
+ [722, 735, "ON"],
39724
+ [741, 749, "ON"],
39725
+ [751, 767, "ON"],
39726
+ [768, 879, "NSM"],
39727
+ [884, 885, "ON"],
39728
+ [894, 894, "ON"],
39729
+ [900, 901, "ON"],
39730
+ [903, 903, "ON"],
39731
+ [1014, 1014, "ON"],
39732
+ [1155, 1161, "NSM"],
39733
+ [1418, 1418, "ON"],
39734
+ [1421, 1422, "ON"],
39735
+ [1423, 1423, "ET"],
39736
+ [1424, 1424, "R"],
39737
+ [1425, 1469, "NSM"],
39738
+ [1470, 1470, "R"],
39739
+ [1471, 1471, "NSM"],
39740
+ [1472, 1472, "R"],
39741
+ [1473, 1474, "NSM"],
39742
+ [1475, 1475, "R"],
39743
+ [1476, 1477, "NSM"],
39744
+ [1478, 1478, "R"],
39745
+ [1479, 1479, "NSM"],
39746
+ [1480, 1535, "R"],
39747
+ [1536, 1541, "AN"],
39748
+ [1542, 1543, "ON"],
39749
+ [1544, 1544, "AL"],
39750
+ [1545, 1546, "ET"],
39751
+ [1547, 1547, "AL"],
39752
+ [1548, 1548, "CS"],
39753
+ [1549, 1549, "AL"],
39754
+ [1550, 1551, "ON"],
39755
+ [1552, 1562, "NSM"],
39756
+ [1563, 1610, "AL"],
39757
+ [1611, 1631, "NSM"],
39758
+ [1632, 1641, "AN"],
39759
+ [1642, 1642, "ET"],
39760
+ [1643, 1644, "AN"],
39761
+ [1645, 1647, "AL"],
39762
+ [1648, 1648, "NSM"],
39763
+ [1649, 1749, "AL"],
39764
+ [1750, 1756, "NSM"],
39765
+ [1757, 1757, "AN"],
39766
+ [1758, 1758, "ON"],
39767
+ [1759, 1764, "NSM"],
39768
+ [1765, 1766, "AL"],
39769
+ [1767, 1768, "NSM"],
39770
+ [1769, 1769, "ON"],
39771
+ [1770, 1773, "NSM"],
39772
+ [1774, 1775, "AL"],
39773
+ [1776, 1785, "EN"],
39774
+ [1786, 1808, "AL"],
39775
+ [1809, 1809, "NSM"],
39776
+ [1810, 1839, "AL"],
39777
+ [1840, 1866, "NSM"],
39778
+ [1867, 1957, "AL"],
39779
+ [1958, 1968, "NSM"],
39780
+ [1969, 1983, "AL"],
39781
+ [1984, 2026, "R"],
39782
+ [2027, 2035, "NSM"],
39783
+ [2036, 2037, "R"],
39784
+ [2038, 2041, "ON"],
39785
+ [2042, 2044, "R"],
39786
+ [2045, 2045, "NSM"],
39787
+ [2046, 2069, "R"],
39788
+ [2070, 2073, "NSM"],
39789
+ [2074, 2074, "R"],
39790
+ [2075, 2083, "NSM"],
39791
+ [2084, 2084, "R"],
39792
+ [2085, 2087, "NSM"],
39793
+ [2088, 2088, "R"],
39794
+ [2089, 2093, "NSM"],
39795
+ [2094, 2136, "R"],
39796
+ [2137, 2139, "NSM"],
39797
+ [2140, 2143, "R"],
39798
+ [2144, 2191, "AL"],
39799
+ [2192, 2193, "AN"],
39800
+ [2194, 2198, "AL"],
39801
+ [2199, 2207, "NSM"],
39802
+ [2208, 2249, "AL"],
39803
+ [2250, 2273, "NSM"],
39804
+ [2274, 2274, "AN"],
39805
+ [2275, 2306, "NSM"],
39806
+ [2362, 2362, "NSM"],
39807
+ [2364, 2364, "NSM"],
39808
+ [2369, 2376, "NSM"],
39809
+ [2381, 2381, "NSM"],
39810
+ [2385, 2391, "NSM"],
39811
+ [2402, 2403, "NSM"],
39812
+ [2433, 2433, "NSM"],
39813
+ [2492, 2492, "NSM"],
39814
+ [2497, 2500, "NSM"],
39815
+ [2509, 2509, "NSM"],
39816
+ [2530, 2531, "NSM"],
39817
+ [2546, 2547, "ET"],
39818
+ [2555, 2555, "ET"],
39819
+ [2558, 2558, "NSM"],
39820
+ [2561, 2562, "NSM"],
39821
+ [2620, 2620, "NSM"],
39822
+ [2625, 2626, "NSM"],
39823
+ [2631, 2632, "NSM"],
39824
+ [2635, 2637, "NSM"],
39825
+ [2641, 2641, "NSM"],
39826
+ [2672, 2673, "NSM"],
39827
+ [2677, 2677, "NSM"],
39828
+ [2689, 2690, "NSM"],
39829
+ [2748, 2748, "NSM"],
39830
+ [2753, 2757, "NSM"],
39831
+ [2759, 2760, "NSM"],
39832
+ [2765, 2765, "NSM"],
39833
+ [2786, 2787, "NSM"],
39834
+ [2801, 2801, "ET"],
39835
+ [2810, 2815, "NSM"],
39836
+ [2817, 2817, "NSM"],
39837
+ [2876, 2876, "NSM"],
39838
+ [2879, 2879, "NSM"],
39839
+ [2881, 2884, "NSM"],
39840
+ [2893, 2893, "NSM"],
39841
+ [2901, 2902, "NSM"],
39842
+ [2914, 2915, "NSM"],
39843
+ [2946, 2946, "NSM"],
39844
+ [3008, 3008, "NSM"],
39845
+ [3021, 3021, "NSM"],
39846
+ [3059, 3064, "ON"],
39847
+ [3065, 3065, "ET"],
39848
+ [3066, 3066, "ON"],
39849
+ [3072, 3072, "NSM"],
39850
+ [3076, 3076, "NSM"],
39851
+ [3132, 3132, "NSM"],
39852
+ [3134, 3136, "NSM"],
39853
+ [3142, 3144, "NSM"],
39854
+ [3146, 3149, "NSM"],
39855
+ [3157, 3158, "NSM"],
39856
+ [3170, 3171, "NSM"],
39857
+ [3192, 3198, "ON"],
39858
+ [3201, 3201, "NSM"],
39859
+ [3260, 3260, "NSM"],
39860
+ [3276, 3277, "NSM"],
39861
+ [3298, 3299, "NSM"],
39862
+ [3328, 3329, "NSM"],
39863
+ [3387, 3388, "NSM"],
39864
+ [3393, 3396, "NSM"],
39865
+ [3405, 3405, "NSM"],
39866
+ [3426, 3427, "NSM"],
39867
+ [3457, 3457, "NSM"],
39868
+ [3530, 3530, "NSM"],
39869
+ [3538, 3540, "NSM"],
39870
+ [3542, 3542, "NSM"],
39871
+ [3633, 3633, "NSM"],
39872
+ [3636, 3642, "NSM"],
39873
+ [3647, 3647, "ET"],
39874
+ [3655, 3662, "NSM"],
39875
+ [3761, 3761, "NSM"],
39876
+ [3764, 3772, "NSM"],
39877
+ [3784, 3790, "NSM"],
39878
+ [3864, 3865, "NSM"],
39879
+ [3893, 3893, "NSM"],
39880
+ [3895, 3895, "NSM"],
39881
+ [3897, 3897, "NSM"],
39882
+ [3898, 3901, "ON"],
39883
+ [3953, 3966, "NSM"],
39884
+ [3968, 3972, "NSM"],
39885
+ [3974, 3975, "NSM"],
39886
+ [3981, 3991, "NSM"],
39887
+ [3993, 4028, "NSM"],
39888
+ [4038, 4038, "NSM"],
39889
+ [4141, 4144, "NSM"],
39890
+ [4146, 4151, "NSM"],
39891
+ [4153, 4154, "NSM"],
39892
+ [4157, 4158, "NSM"],
39893
+ [4184, 4185, "NSM"],
39894
+ [4190, 4192, "NSM"],
39895
+ [4209, 4212, "NSM"],
39896
+ [4226, 4226, "NSM"],
39897
+ [4229, 4230, "NSM"],
39898
+ [4237, 4237, "NSM"],
39899
+ [4253, 4253, "NSM"],
39900
+ [4957, 4959, "NSM"],
39901
+ [5008, 5017, "ON"],
39902
+ [5120, 5120, "ON"],
39903
+ [5760, 5760, "WS"],
39904
+ [5787, 5788, "ON"],
39905
+ [5906, 5908, "NSM"],
39906
+ [5938, 5939, "NSM"],
39907
+ [5970, 5971, "NSM"],
39908
+ [6002, 6003, "NSM"],
39909
+ [6068, 6069, "NSM"],
39910
+ [6071, 6077, "NSM"],
39911
+ [6086, 6086, "NSM"],
39912
+ [6089, 6099, "NSM"],
39913
+ [6107, 6107, "ET"],
39914
+ [6109, 6109, "NSM"],
39915
+ [6128, 6137, "ON"],
39916
+ [6144, 6154, "ON"],
39917
+ [6155, 6157, "NSM"],
39918
+ [6158, 6158, "BN"],
39919
+ [6159, 6159, "NSM"],
39920
+ [6277, 6278, "NSM"],
39921
+ [6313, 6313, "NSM"],
39922
+ [6432, 6434, "NSM"],
39923
+ [6439, 6440, "NSM"],
39924
+ [6450, 6450, "NSM"],
39925
+ [6457, 6459, "NSM"],
39926
+ [6464, 6464, "ON"],
39927
+ [6468, 6469, "ON"],
39928
+ [6622, 6655, "ON"],
39929
+ [6679, 6680, "NSM"],
39930
+ [6683, 6683, "NSM"],
39931
+ [6742, 6742, "NSM"],
39932
+ [6744, 6750, "NSM"],
39933
+ [6752, 6752, "NSM"],
39934
+ [6754, 6754, "NSM"],
39935
+ [6757, 6764, "NSM"],
39936
+ [6771, 6780, "NSM"],
39937
+ [6783, 6783, "NSM"],
39938
+ [6832, 6877, "NSM"],
39939
+ [6880, 6891, "NSM"],
39940
+ [6912, 6915, "NSM"],
39941
+ [6964, 6964, "NSM"],
39942
+ [6966, 6970, "NSM"],
39943
+ [6972, 6972, "NSM"],
39944
+ [6978, 6978, "NSM"],
39945
+ [7019, 7027, "NSM"],
39946
+ [7040, 7041, "NSM"],
39947
+ [7074, 7077, "NSM"],
39948
+ [7080, 7081, "NSM"],
39949
+ [7083, 7085, "NSM"],
39950
+ [7142, 7142, "NSM"],
39951
+ [7144, 7145, "NSM"],
39952
+ [7149, 7149, "NSM"],
39953
+ [7151, 7153, "NSM"],
39954
+ [7212, 7219, "NSM"],
39955
+ [7222, 7223, "NSM"],
39956
+ [7376, 7378, "NSM"],
39957
+ [7380, 7392, "NSM"],
39958
+ [7394, 7400, "NSM"],
39959
+ [7405, 7405, "NSM"],
39960
+ [7412, 7412, "NSM"],
39961
+ [7416, 7417, "NSM"],
39962
+ [7616, 7679, "NSM"],
39963
+ [8125, 8125, "ON"],
39964
+ [8127, 8129, "ON"],
39965
+ [8141, 8143, "ON"],
39966
+ [8157, 8159, "ON"],
39967
+ [8173, 8175, "ON"],
39968
+ [8189, 8190, "ON"],
39969
+ [8192, 8202, "WS"],
39970
+ [8203, 8205, "BN"],
39971
+ [8207, 8207, "R"],
39972
+ [8208, 8231, "ON"],
39973
+ [8232, 8232, "WS"],
39974
+ [8233, 8233, "B"],
39975
+ [8234, 8238, "BN"],
39976
+ [8239, 8239, "CS"],
39977
+ [8240, 8244, "ET"],
39978
+ [8245, 8259, "ON"],
39979
+ [8260, 8260, "CS"],
39980
+ [8261, 8286, "ON"],
39981
+ [8287, 8287, "WS"],
39982
+ [8288, 8303, "BN"],
39983
+ [8304, 8304, "EN"],
39984
+ [8308, 8313, "EN"],
39985
+ [8314, 8315, "ES"],
39986
+ [8316, 8318, "ON"],
39987
+ [8320, 8329, "EN"],
39988
+ [8330, 8331, "ES"],
39989
+ [8332, 8334, "ON"],
39990
+ [8352, 8399, "ET"],
39991
+ [8400, 8432, "NSM"],
39992
+ [8448, 8449, "ON"],
39993
+ [8451, 8454, "ON"],
39994
+ [8456, 8457, "ON"],
39995
+ [8468, 8468, "ON"],
39996
+ [8470, 8472, "ON"],
39997
+ [8478, 8483, "ON"],
39998
+ [8485, 8485, "ON"],
39999
+ [8487, 8487, "ON"],
40000
+ [8489, 8489, "ON"],
40001
+ [8494, 8494, "ET"],
40002
+ [8506, 8507, "ON"],
40003
+ [8512, 8516, "ON"],
40004
+ [8522, 8525, "ON"],
40005
+ [8528, 8543, "ON"],
40006
+ [8585, 8587, "ON"],
40007
+ [8592, 8721, "ON"],
40008
+ [8722, 8722, "ES"],
40009
+ [8723, 8723, "ET"],
40010
+ [8724, 9013, "ON"],
40011
+ [9083, 9108, "ON"],
40012
+ [9110, 9257, "ON"],
40013
+ [9280, 9290, "ON"],
40014
+ [9312, 9351, "ON"],
40015
+ [9352, 9371, "EN"],
40016
+ [9450, 9899, "ON"],
40017
+ [9901, 10239, "ON"],
40018
+ [10496, 11123, "ON"],
40019
+ [11126, 11263, "ON"],
40020
+ [11493, 11498, "ON"],
40021
+ [11503, 11505, "NSM"],
40022
+ [11513, 11519, "ON"],
40023
+ [11647, 11647, "NSM"],
40024
+ [11744, 11775, "NSM"],
40025
+ [11776, 11869, "ON"],
40026
+ [11904, 11929, "ON"],
40027
+ [11931, 12019, "ON"],
40028
+ [12032, 12245, "ON"],
40029
+ [12272, 12287, "ON"],
40030
+ [12288, 12288, "WS"],
40031
+ [12289, 12292, "ON"],
40032
+ [12296, 12320, "ON"],
40033
+ [12330, 12333, "NSM"],
40034
+ [12336, 12336, "ON"],
40035
+ [12342, 12343, "ON"],
40036
+ [12349, 12351, "ON"],
40037
+ [12441, 12442, "NSM"],
40038
+ [12443, 12444, "ON"],
40039
+ [12448, 12448, "ON"],
40040
+ [12539, 12539, "ON"],
40041
+ [12736, 12773, "ON"],
40042
+ [12783, 12783, "ON"],
40043
+ [12829, 12830, "ON"],
40044
+ [12880, 12895, "ON"],
40045
+ [12924, 12926, "ON"],
40046
+ [12977, 12991, "ON"],
40047
+ [13004, 13007, "ON"],
40048
+ [13175, 13178, "ON"],
40049
+ [13278, 13279, "ON"],
40050
+ [13311, 13311, "ON"],
40051
+ [19904, 19967, "ON"],
40052
+ [42128, 42182, "ON"],
40053
+ [42509, 42511, "ON"],
40054
+ [42607, 42610, "NSM"],
40055
+ [42611, 42611, "ON"],
40056
+ [42612, 42621, "NSM"],
40057
+ [42622, 42623, "ON"],
40058
+ [42654, 42655, "NSM"],
40059
+ [42736, 42737, "NSM"],
40060
+ [42752, 42785, "ON"],
40061
+ [42888, 42888, "ON"],
40062
+ [43010, 43010, "NSM"],
40063
+ [43014, 43014, "NSM"],
40064
+ [43019, 43019, "NSM"],
40065
+ [43045, 43046, "NSM"],
40066
+ [43048, 43051, "ON"],
40067
+ [43052, 43052, "NSM"],
40068
+ [43064, 43065, "ET"],
40069
+ [43124, 43127, "ON"],
40070
+ [43204, 43205, "NSM"],
40071
+ [43232, 43249, "NSM"],
40072
+ [43263, 43263, "NSM"],
40073
+ [43302, 43309, "NSM"],
40074
+ [43335, 43345, "NSM"],
40075
+ [43392, 43394, "NSM"],
40076
+ [43443, 43443, "NSM"],
40077
+ [43446, 43449, "NSM"],
40078
+ [43452, 43453, "NSM"],
40079
+ [43493, 43493, "NSM"],
40080
+ [43561, 43566, "NSM"],
40081
+ [43569, 43570, "NSM"],
40082
+ [43573, 43574, "NSM"],
40083
+ [43587, 43587, "NSM"],
40084
+ [43596, 43596, "NSM"],
40085
+ [43644, 43644, "NSM"],
40086
+ [43696, 43696, "NSM"],
40087
+ [43698, 43700, "NSM"],
40088
+ [43703, 43704, "NSM"],
40089
+ [43710, 43711, "NSM"],
40090
+ [43713, 43713, "NSM"],
40091
+ [43756, 43757, "NSM"],
40092
+ [43766, 43766, "NSM"],
40093
+ [43882, 43883, "ON"],
40094
+ [44005, 44005, "NSM"],
40095
+ [44008, 44008, "NSM"],
40096
+ [44013, 44013, "NSM"],
40097
+ [64285, 64285, "R"],
40098
+ [64286, 64286, "NSM"],
40099
+ [64287, 64296, "R"],
40100
+ [64297, 64297, "ES"],
40101
+ [64298, 64335, "R"],
40102
+ [64336, 64450, "AL"],
40103
+ [64451, 64466, "ON"],
40104
+ [64467, 64829, "AL"],
40105
+ [64830, 64847, "ON"],
40106
+ [64848, 64911, "AL"],
40107
+ [64912, 64913, "ON"],
40108
+ [64914, 64967, "AL"],
40109
+ [64968, 64975, "ON"],
40110
+ [64976, 65007, "BN"],
40111
+ [65008, 65020, "AL"],
40112
+ [65021, 65023, "ON"],
40113
+ [65024, 65039, "NSM"],
40114
+ [65040, 65049, "ON"],
40115
+ [65056, 65071, "NSM"],
40116
+ [65072, 65103, "ON"],
40117
+ [65104, 65104, "CS"],
40118
+ [65105, 65105, "ON"],
40119
+ [65106, 65106, "CS"],
40120
+ [65108, 65108, "ON"],
40121
+ [65109, 65109, "CS"],
40122
+ [65110, 65118, "ON"],
40123
+ [65119, 65119, "ET"],
40124
+ [65120, 65121, "ON"],
40125
+ [65122, 65123, "ES"],
40126
+ [65124, 65126, "ON"],
40127
+ [65128, 65128, "ON"],
40128
+ [65129, 65130, "ET"],
40129
+ [65131, 65131, "ON"],
40130
+ [65136, 65278, "AL"],
40131
+ [65279, 65279, "BN"],
40132
+ [65281, 65282, "ON"],
40133
+ [65283, 65285, "ET"],
40134
+ [65286, 65290, "ON"],
40135
+ [65291, 65291, "ES"],
40136
+ [65292, 65292, "CS"],
40137
+ [65293, 65293, "ES"],
40138
+ [65294, 65295, "CS"],
40139
+ [65296, 65305, "EN"],
40140
+ [65306, 65306, "CS"],
40141
+ [65307, 65312, "ON"],
40142
+ [65339, 65344, "ON"],
40143
+ [65371, 65381, "ON"],
40144
+ [65504, 65505, "ET"],
40145
+ [65506, 65508, "ON"],
40146
+ [65509, 65510, "ET"],
40147
+ [65512, 65518, "ON"],
40148
+ [65520, 65528, "BN"],
40149
+ [65529, 65533, "ON"],
40150
+ [65534, 65535, "BN"],
40151
+ [65793, 65793, "ON"],
40152
+ [65856, 65932, "ON"],
40153
+ [65936, 65948, "ON"],
40154
+ [65952, 65952, "ON"],
40155
+ [66045, 66045, "NSM"],
40156
+ [66272, 66272, "NSM"],
40157
+ [66273, 66299, "EN"],
40158
+ [66422, 66426, "NSM"],
40159
+ [67584, 67870, "R"],
40160
+ [67871, 67871, "ON"],
40161
+ [67872, 68096, "R"],
40162
+ [68097, 68099, "NSM"],
40163
+ [68100, 68100, "R"],
40164
+ [68101, 68102, "NSM"],
40165
+ [68103, 68107, "R"],
40166
+ [68108, 68111, "NSM"],
40167
+ [68112, 68151, "R"],
40168
+ [68152, 68154, "NSM"],
40169
+ [68155, 68158, "R"],
40170
+ [68159, 68159, "NSM"],
40171
+ [68160, 68324, "R"],
40172
+ [68325, 68326, "NSM"],
40173
+ [68327, 68408, "R"],
40174
+ [68409, 68415, "ON"],
40175
+ [68416, 68863, "R"],
40176
+ [68864, 68899, "AL"],
40177
+ [68900, 68903, "NSM"],
40178
+ [68904, 68911, "AL"],
40179
+ [68912, 68921, "AN"],
40180
+ [68922, 68927, "AL"],
40181
+ [68928, 68937, "AN"],
40182
+ [68938, 68968, "R"],
40183
+ [68969, 68973, "NSM"],
40184
+ [68974, 68974, "ON"],
40185
+ [68975, 69215, "R"],
40186
+ [69216, 69246, "AN"],
40187
+ [69247, 69290, "R"],
40188
+ [69291, 69292, "NSM"],
40189
+ [69293, 69311, "R"],
40190
+ [69312, 69327, "AL"],
40191
+ [69328, 69336, "ON"],
40192
+ [69337, 69369, "AL"],
40193
+ [69370, 69375, "NSM"],
40194
+ [69376, 69423, "R"],
40195
+ [69424, 69445, "AL"],
40196
+ [69446, 69456, "NSM"],
40197
+ [69457, 69487, "AL"],
40198
+ [69488, 69505, "R"],
40199
+ [69506, 69509, "NSM"],
40200
+ [69510, 69631, "R"],
40201
+ [69633, 69633, "NSM"],
40202
+ [69688, 69702, "NSM"],
40203
+ [69714, 69733, "ON"],
40204
+ [69744, 69744, "NSM"],
40205
+ [69747, 69748, "NSM"],
40206
+ [69759, 69761, "NSM"],
40207
+ [69811, 69814, "NSM"],
40208
+ [69817, 69818, "NSM"],
40209
+ [69826, 69826, "NSM"],
40210
+ [69888, 69890, "NSM"],
40211
+ [69927, 69931, "NSM"],
40212
+ [69933, 69940, "NSM"],
40213
+ [70003, 70003, "NSM"],
40214
+ [70016, 70017, "NSM"],
40215
+ [70070, 70078, "NSM"],
40216
+ [70089, 70092, "NSM"],
40217
+ [70095, 70095, "NSM"],
40218
+ [70191, 70193, "NSM"],
40219
+ [70196, 70196, "NSM"],
40220
+ [70198, 70199, "NSM"],
40221
+ [70206, 70206, "NSM"],
40222
+ [70209, 70209, "NSM"],
40223
+ [70367, 70367, "NSM"],
40224
+ [70371, 70378, "NSM"],
40225
+ [70400, 70401, "NSM"],
40226
+ [70459, 70460, "NSM"],
40227
+ [70464, 70464, "NSM"],
40228
+ [70502, 70508, "NSM"],
40229
+ [70512, 70516, "NSM"],
40230
+ [70587, 70592, "NSM"],
40231
+ [70606, 70606, "NSM"],
40232
+ [70608, 70608, "NSM"],
40233
+ [70610, 70610, "NSM"],
40234
+ [70625, 70626, "NSM"],
40235
+ [70712, 70719, "NSM"],
40236
+ [70722, 70724, "NSM"],
40237
+ [70726, 70726, "NSM"],
40238
+ [70750, 70750, "NSM"],
40239
+ [70835, 70840, "NSM"],
40240
+ [70842, 70842, "NSM"],
40241
+ [70847, 70848, "NSM"],
40242
+ [70850, 70851, "NSM"],
40243
+ [71090, 71093, "NSM"],
40244
+ [71100, 71101, "NSM"],
40245
+ [71103, 71104, "NSM"],
40246
+ [71132, 71133, "NSM"],
40247
+ [71219, 71226, "NSM"],
40248
+ [71229, 71229, "NSM"],
40249
+ [71231, 71232, "NSM"],
40250
+ [71264, 71276, "ON"],
40251
+ [71339, 71339, "NSM"],
40252
+ [71341, 71341, "NSM"],
40253
+ [71344, 71349, "NSM"],
40254
+ [71351, 71351, "NSM"],
40255
+ [71453, 71453, "NSM"],
40256
+ [71455, 71455, "NSM"],
40257
+ [71458, 71461, "NSM"],
40258
+ [71463, 71467, "NSM"],
40259
+ [71727, 71735, "NSM"],
40260
+ [71737, 71738, "NSM"],
40261
+ [71995, 71996, "NSM"],
40262
+ [71998, 71998, "NSM"],
40263
+ [72003, 72003, "NSM"],
40264
+ [72148, 72151, "NSM"],
40265
+ [72154, 72155, "NSM"],
40266
+ [72160, 72160, "NSM"],
40267
+ [72193, 72198, "NSM"],
40268
+ [72201, 72202, "NSM"],
40269
+ [72243, 72248, "NSM"],
40270
+ [72251, 72254, "NSM"],
40271
+ [72263, 72263, "NSM"],
40272
+ [72273, 72278, "NSM"],
40273
+ [72281, 72283, "NSM"],
40274
+ [72330, 72342, "NSM"],
40275
+ [72344, 72345, "NSM"],
40276
+ [72544, 72544, "NSM"],
40277
+ [72546, 72548, "NSM"],
40278
+ [72550, 72550, "NSM"],
40279
+ [72752, 72758, "NSM"],
40280
+ [72760, 72765, "NSM"],
40281
+ [72850, 72871, "NSM"],
40282
+ [72874, 72880, "NSM"],
40283
+ [72882, 72883, "NSM"],
40284
+ [72885, 72886, "NSM"],
40285
+ [73009, 73014, "NSM"],
40286
+ [73018, 73018, "NSM"],
40287
+ [73020, 73021, "NSM"],
40288
+ [73023, 73029, "NSM"],
40289
+ [73031, 73031, "NSM"],
40290
+ [73104, 73105, "NSM"],
40291
+ [73109, 73109, "NSM"],
40292
+ [73111, 73111, "NSM"],
40293
+ [73459, 73460, "NSM"],
40294
+ [73472, 73473, "NSM"],
40295
+ [73526, 73530, "NSM"],
40296
+ [73536, 73536, "NSM"],
40297
+ [73538, 73538, "NSM"],
40298
+ [73562, 73562, "NSM"],
40299
+ [73685, 73692, "ON"],
40300
+ [73693, 73696, "ET"],
40301
+ [73697, 73713, "ON"],
40302
+ [78912, 78912, "NSM"],
40303
+ [78919, 78933, "NSM"],
40304
+ [90398, 90409, "NSM"],
40305
+ [90413, 90415, "NSM"],
40306
+ [92912, 92916, "NSM"],
40307
+ [92976, 92982, "NSM"],
40308
+ [94031, 94031, "NSM"],
40309
+ [94095, 94098, "NSM"],
40310
+ [94178, 94178, "ON"],
40311
+ [94180, 94180, "NSM"],
40312
+ [113821, 113822, "NSM"],
40313
+ [113824, 113827, "BN"],
40314
+ [117760, 117973, "ON"],
40315
+ [118e3, 118009, "EN"],
40316
+ [118010, 118012, "ON"],
40317
+ [118016, 118451, "ON"],
40318
+ [118458, 118480, "ON"],
40319
+ [118496, 118512, "ON"],
40320
+ [118528, 118573, "NSM"],
40321
+ [118576, 118598, "NSM"],
40322
+ [119143, 119145, "NSM"],
40323
+ [119155, 119162, "BN"],
40324
+ [119163, 119170, "NSM"],
40325
+ [119173, 119179, "NSM"],
40326
+ [119210, 119213, "NSM"],
40327
+ [119273, 119274, "ON"],
40328
+ [119296, 119361, "ON"],
40329
+ [119362, 119364, "NSM"],
40330
+ [119365, 119365, "ON"],
40331
+ [119552, 119638, "ON"],
40332
+ [120513, 120513, "ON"],
40333
+ [120539, 120539, "ON"],
40334
+ [120571, 120571, "ON"],
40335
+ [120597, 120597, "ON"],
40336
+ [120629, 120629, "ON"],
40337
+ [120655, 120655, "ON"],
40338
+ [120687, 120687, "ON"],
40339
+ [120713, 120713, "ON"],
40340
+ [120745, 120745, "ON"],
40341
+ [120771, 120771, "ON"],
40342
+ [120782, 120831, "EN"],
40343
+ [121344, 121398, "NSM"],
40344
+ [121403, 121452, "NSM"],
40345
+ [121461, 121461, "NSM"],
40346
+ [121476, 121476, "NSM"],
40347
+ [121499, 121503, "NSM"],
40348
+ [121505, 121519, "NSM"],
40349
+ [122880, 122886, "NSM"],
40350
+ [122888, 122904, "NSM"],
40351
+ [122907, 122913, "NSM"],
40352
+ [122915, 122916, "NSM"],
40353
+ [122918, 122922, "NSM"],
40354
+ [123023, 123023, "NSM"],
40355
+ [123184, 123190, "NSM"],
40356
+ [123566, 123566, "NSM"],
40357
+ [123628, 123631, "NSM"],
40358
+ [123647, 123647, "ET"],
40359
+ [124140, 124143, "NSM"],
40360
+ [124398, 124399, "NSM"],
40361
+ [124643, 124643, "NSM"],
40362
+ [124646, 124646, "NSM"],
40363
+ [124654, 124655, "NSM"],
40364
+ [124661, 124661, "NSM"],
40365
+ [124928, 125135, "R"],
40366
+ [125136, 125142, "NSM"],
40367
+ [125143, 125251, "R"],
40368
+ [125252, 125258, "NSM"],
40369
+ [125259, 126063, "R"],
40370
+ [126064, 126143, "AL"],
40371
+ [126144, 126207, "R"],
40372
+ [126208, 126287, "AL"],
40373
+ [126288, 126463, "R"],
40374
+ [126464, 126703, "AL"],
40375
+ [126704, 126705, "ON"],
40376
+ [126706, 126719, "AL"],
40377
+ [126720, 126975, "R"],
40378
+ [126976, 127019, "ON"],
40379
+ [127024, 127123, "ON"],
40380
+ [127136, 127150, "ON"],
40381
+ [127153, 127167, "ON"],
40382
+ [127169, 127183, "ON"],
40383
+ [127185, 127221, "ON"],
40384
+ [127232, 127242, "EN"],
40385
+ [127243, 127247, "ON"],
40386
+ [127279, 127279, "ON"],
40387
+ [127338, 127343, "ON"],
40388
+ [127405, 127405, "ON"],
40389
+ [127584, 127589, "ON"],
40390
+ [127744, 128728, "ON"],
40391
+ [128732, 128748, "ON"],
40392
+ [128752, 128764, "ON"],
40393
+ [128768, 128985, "ON"],
40394
+ [128992, 129003, "ON"],
40395
+ [129008, 129008, "ON"],
40396
+ [129024, 129035, "ON"],
40397
+ [129040, 129095, "ON"],
40398
+ [129104, 129113, "ON"],
40399
+ [129120, 129159, "ON"],
40400
+ [129168, 129197, "ON"],
40401
+ [129200, 129211, "ON"],
40402
+ [129216, 129217, "ON"],
40403
+ [129232, 129240, "ON"],
40404
+ [129280, 129623, "ON"],
40405
+ [129632, 129645, "ON"],
40406
+ [129648, 129660, "ON"],
40407
+ [129664, 129674, "ON"],
40408
+ [129678, 129734, "ON"],
40409
+ [129736, 129736, "ON"],
40410
+ [129741, 129756, "ON"],
40411
+ [129759, 129770, "ON"],
40412
+ [129775, 129784, "ON"],
40413
+ [129792, 129938, "ON"],
40414
+ [129940, 130031, "ON"],
40415
+ [130032, 130041, "EN"],
40416
+ [130042, 130042, "ON"],
40417
+ [131070, 131071, "BN"],
40418
+ [196606, 196607, "BN"],
40419
+ [262142, 262143, "BN"],
40420
+ [327678, 327679, "BN"],
40421
+ [393214, 393215, "BN"],
40422
+ [458750, 458751, "BN"],
40423
+ [524286, 524287, "BN"],
40424
+ [589822, 589823, "BN"],
40425
+ [655358, 655359, "BN"],
40426
+ [720894, 720895, "BN"],
40427
+ [786430, 786431, "BN"],
40428
+ [851966, 851967, "BN"],
40429
+ [917502, 917759, "BN"],
40430
+ [917760, 917999, "NSM"],
40431
+ [918e3, 921599, "BN"],
40432
+ [983038, 983039, "BN"],
40433
+ [1048574, 1048575, "BN"],
40434
+ [1114110, 1114111, "BN"]
40435
+ ];
40436
+
40437
+ // ../../node_modules/.pnpm/@chenglou+pretext@0.0.5/node_modules/@chenglou/pretext/dist/bidi.js
40438
+ function classifyCodePoint(codePoint) {
40439
+ if (codePoint <= 255)
40440
+ return latin1BidiTypes[codePoint];
40441
+ let lo = 0;
40442
+ let hi = nonLatin1BidiRanges.length - 1;
40443
+ while (lo <= hi) {
40444
+ const mid = lo + hi >> 1;
40445
+ const range = nonLatin1BidiRanges[mid];
40446
+ if (codePoint < range[0]) {
40447
+ hi = mid - 1;
40448
+ continue;
40449
+ }
40450
+ if (codePoint > range[1]) {
40451
+ lo = mid + 1;
40452
+ continue;
40453
+ }
40454
+ return range[2];
40455
+ }
40456
+ return "L";
40457
+ }
40458
+ __name(classifyCodePoint, "classifyCodePoint");
40459
+ function computeBidiLevels(str) {
40460
+ const len = str.length;
40461
+ if (len === 0)
40462
+ return null;
40463
+ const types = new Array(len);
40464
+ let sawBidi = false;
40465
+ for (let i = 0; i < len; ) {
40466
+ const first2 = str.charCodeAt(i);
40467
+ let codePoint = first2;
40468
+ let codeUnitLength = 1;
40469
+ if (first2 >= 55296 && first2 <= 56319 && i + 1 < len) {
40470
+ const second = str.charCodeAt(i + 1);
40471
+ if (second >= 56320 && second <= 57343) {
40472
+ codePoint = (first2 - 55296 << 10) + (second - 56320) + 65536;
40473
+ codeUnitLength = 2;
40474
+ }
40475
+ }
40476
+ const t2 = classifyCodePoint(codePoint);
40477
+ if (t2 === "R" || t2 === "AL" || t2 === "AN")
40478
+ sawBidi = true;
40479
+ for (let j = 0; j < codeUnitLength; j++) {
40480
+ types[i + j] = t2;
40481
+ }
40482
+ i += codeUnitLength;
40483
+ }
40484
+ if (!sawBidi)
40485
+ return null;
40486
+ let startLevel = 0;
40487
+ for (let i = 0; i < len; i++) {
40488
+ const t2 = types[i];
40489
+ if (t2 === "L") {
40490
+ startLevel = 0;
40491
+ break;
40492
+ }
40493
+ if (t2 === "R" || t2 === "AL") {
40494
+ startLevel = 1;
40495
+ break;
40496
+ }
40497
+ }
40498
+ const levels = new Int8Array(len);
40499
+ for (let i = 0; i < len; i++)
40500
+ levels[i] = startLevel;
40501
+ const e = startLevel & 1 ? "R" : "L";
40502
+ const sor = e;
40503
+ let lastType = sor;
40504
+ for (let i = 0; i < len; i++) {
40505
+ if (types[i] === "NSM")
40506
+ types[i] = lastType;
40507
+ else
40508
+ lastType = types[i];
40509
+ }
40510
+ lastType = sor;
40511
+ for (let i = 0; i < len; i++) {
40512
+ const t2 = types[i];
40513
+ if (t2 === "EN")
40514
+ types[i] = lastType === "AL" ? "AN" : "EN";
40515
+ else if (t2 === "R" || t2 === "L" || t2 === "AL")
40516
+ lastType = t2;
40517
+ }
40518
+ for (let i = 0; i < len; i++) {
40519
+ if (types[i] === "AL")
40520
+ types[i] = "R";
40521
+ }
40522
+ for (let i = 1; i < len - 1; i++) {
40523
+ if (types[i] === "ES" && types[i - 1] === "EN" && types[i + 1] === "EN") {
40524
+ types[i] = "EN";
40525
+ }
40526
+ if (types[i] === "CS" && (types[i - 1] === "EN" || types[i - 1] === "AN") && types[i + 1] === types[i - 1]) {
40527
+ types[i] = types[i - 1];
40528
+ }
40529
+ }
40530
+ for (let i = 0; i < len; i++) {
40531
+ if (types[i] !== "EN")
40532
+ continue;
40533
+ let j;
40534
+ for (j = i - 1; j >= 0 && types[j] === "ET"; j--)
40535
+ types[j] = "EN";
40536
+ for (j = i + 1; j < len && types[j] === "ET"; j++)
40537
+ types[j] = "EN";
40538
+ }
40539
+ for (let i = 0; i < len; i++) {
40540
+ const t2 = types[i];
40541
+ if (t2 === "WS" || t2 === "ES" || t2 === "ET" || t2 === "CS")
40542
+ types[i] = "ON";
40543
+ }
40544
+ lastType = sor;
40545
+ for (let i = 0; i < len; i++) {
40546
+ const t2 = types[i];
40547
+ if (t2 === "EN")
40548
+ types[i] = lastType === "L" ? "L" : "EN";
40549
+ else if (t2 === "R" || t2 === "L")
40550
+ lastType = t2;
40551
+ }
40552
+ for (let i = 0; i < len; i++) {
40553
+ if (types[i] !== "ON")
40554
+ continue;
40555
+ let end = i + 1;
40556
+ while (end < len && types[end] === "ON")
40557
+ end++;
40558
+ const before = i > 0 ? types[i - 1] : sor;
40559
+ const after = end < len ? types[end] : sor;
40560
+ const bDir = before !== "L" ? "R" : "L";
40561
+ const aDir = after !== "L" ? "R" : "L";
40562
+ if (bDir === aDir) {
40563
+ for (let j = i; j < end; j++)
40564
+ types[j] = bDir;
40565
+ }
40566
+ i = end - 1;
40567
+ }
40568
+ for (let i = 0; i < len; i++) {
40569
+ if (types[i] === "ON")
40570
+ types[i] = e;
40571
+ }
40572
+ for (let i = 0; i < len; i++) {
40573
+ const t2 = types[i];
40574
+ if ((levels[i] & 1) === 0) {
40575
+ if (t2 === "R")
40576
+ levels[i]++;
40577
+ else if (t2 === "AN" || t2 === "EN")
40578
+ levels[i] += 2;
40579
+ } else if (t2 === "L" || t2 === "AN" || t2 === "EN") {
40580
+ levels[i]++;
40581
+ }
40582
+ }
40583
+ return levels;
40584
+ }
40585
+ __name(computeBidiLevels, "computeBidiLevels");
40586
+ function computeSegmentLevels(normalized, segStarts) {
40587
+ const bidiLevels = computeBidiLevels(normalized);
40588
+ if (bidiLevels === null)
40589
+ return null;
40590
+ const segLevels = new Int8Array(segStarts.length);
40591
+ for (let i = 0; i < segStarts.length; i++) {
40592
+ segLevels[i] = bidiLevels[segStarts[i]];
40593
+ }
40594
+ return segLevels;
40595
+ }
40596
+ __name(computeSegmentLevels, "computeSegmentLevels");
40597
+
40598
+ // ../../node_modules/.pnpm/@chenglou+pretext@0.0.5/node_modules/@chenglou/pretext/dist/analysis.js
40599
+ var collapsibleWhitespaceRunRe = /[ \t\n\r\f]+/g;
40600
+ var needsWhitespaceNormalizationRe = /[\t\n\r\f]| {2,}|^ | $/;
40601
+ function getWhiteSpaceProfile(whiteSpace) {
40602
+ const mode = whiteSpace ?? "normal";
40603
+ return mode === "pre-wrap" ? { mode, preserveOrdinarySpaces: true, preserveHardBreaks: true } : { mode, preserveOrdinarySpaces: false, preserveHardBreaks: false };
40604
+ }
40605
+ __name(getWhiteSpaceProfile, "getWhiteSpaceProfile");
40606
+ function normalizeWhitespaceNormal(text2) {
40607
+ if (!needsWhitespaceNormalizationRe.test(text2))
40608
+ return text2;
40609
+ let normalized = text2.replace(collapsibleWhitespaceRunRe, " ");
40610
+ if (normalized.charCodeAt(0) === 32) {
40611
+ normalized = normalized.slice(1);
40612
+ }
40613
+ if (normalized.length > 0 && normalized.charCodeAt(normalized.length - 1) === 32) {
40614
+ normalized = normalized.slice(0, -1);
40615
+ }
40616
+ return normalized;
40617
+ }
40618
+ __name(normalizeWhitespaceNormal, "normalizeWhitespaceNormal");
40619
+ function normalizeWhitespacePreWrap(text2) {
40620
+ if (!/[\r\f]/.test(text2))
40621
+ return text2.replace(/\r\n/g, "\n");
40622
+ return text2.replace(/\r\n/g, "\n").replace(/[\r\f]/g, "\n");
40623
+ }
40624
+ __name(normalizeWhitespacePreWrap, "normalizeWhitespacePreWrap");
40625
+ var sharedWordSegmenter = null;
40626
+ var segmenterLocale;
40627
+ function getSharedWordSegmenter() {
40628
+ if (sharedWordSegmenter === null) {
40629
+ sharedWordSegmenter = new Intl.Segmenter(segmenterLocale, { granularity: "word" });
40630
+ }
40631
+ return sharedWordSegmenter;
40632
+ }
40633
+ __name(getSharedWordSegmenter, "getSharedWordSegmenter");
40634
+ var arabicScriptRe = /\p{Script=Arabic}/u;
40635
+ var combiningMarkRe = /\p{M}/u;
40636
+ var decimalDigitRe = /\p{Nd}/u;
40637
+ function containsArabicScript(text2) {
40638
+ return arabicScriptRe.test(text2);
40639
+ }
40640
+ __name(containsArabicScript, "containsArabicScript");
40641
+ function isCJKCodePoint(codePoint) {
40642
+ return codePoint >= 19968 && codePoint <= 40959 || codePoint >= 13312 && codePoint <= 19903 || codePoint >= 131072 && codePoint <= 173791 || codePoint >= 173824 && codePoint <= 177983 || codePoint >= 177984 && codePoint <= 178207 || codePoint >= 178208 && codePoint <= 183983 || codePoint >= 183984 && codePoint <= 191471 || codePoint >= 191472 && codePoint <= 192093 || codePoint >= 194560 && codePoint <= 195103 || codePoint >= 196608 && codePoint <= 201551 || codePoint >= 201552 && codePoint <= 205743 || codePoint >= 205744 && codePoint <= 210041 || codePoint >= 63744 && codePoint <= 64255 || codePoint >= 12288 && codePoint <= 12351 || codePoint >= 12352 && codePoint <= 12447 || codePoint >= 12448 && codePoint <= 12543 || codePoint >= 44032 && codePoint <= 55215 || codePoint >= 65280 && codePoint <= 65519;
40643
+ }
40644
+ __name(isCJKCodePoint, "isCJKCodePoint");
40645
+ function isCJK(s) {
40646
+ for (let i = 0; i < s.length; i++) {
40647
+ const first2 = s.charCodeAt(i);
40648
+ if (first2 < 12288)
40649
+ continue;
40650
+ if (first2 >= 55296 && first2 <= 56319 && i + 1 < s.length) {
40651
+ const second = s.charCodeAt(i + 1);
40652
+ if (second >= 56320 && second <= 57343) {
40653
+ const codePoint = (first2 - 55296 << 10) + (second - 56320) + 65536;
40654
+ if (isCJKCodePoint(codePoint))
40655
+ return true;
40656
+ i++;
40657
+ continue;
40658
+ }
40659
+ }
40660
+ if (isCJKCodePoint(first2))
40661
+ return true;
40662
+ }
40663
+ return false;
40664
+ }
40665
+ __name(isCJK, "isCJK");
40666
+ function endsWithLineStartProhibitedText(text2) {
40667
+ const last2 = getLastCodePoint(text2);
40668
+ return last2 !== null && (kinsokuStart.has(last2) || leftStickyPunctuation.has(last2));
40669
+ }
40670
+ __name(endsWithLineStartProhibitedText, "endsWithLineStartProhibitedText");
40671
+ var keepAllGlueChars = /* @__PURE__ */ new Set([
40672
+ "\xA0",
40673
+ "\u202F",
40674
+ "\u2060",
40675
+ "\uFEFF"
40676
+ ]);
40677
+ function containsCJKText(text2) {
40678
+ return isCJK(text2);
40679
+ }
40680
+ __name(containsCJKText, "containsCJKText");
40681
+ function endsWithKeepAllGlueText(text2) {
40682
+ const last2 = getLastCodePoint(text2);
40683
+ return last2 !== null && keepAllGlueChars.has(last2);
40684
+ }
40685
+ __name(endsWithKeepAllGlueText, "endsWithKeepAllGlueText");
40686
+ function canContinueKeepAllTextRun(previousText) {
40687
+ return !endsWithLineStartProhibitedText(previousText) && !endsWithKeepAllGlueText(previousText);
40688
+ }
40689
+ __name(canContinueKeepAllTextRun, "canContinueKeepAllTextRun");
40690
+ var kinsokuStart = /* @__PURE__ */ new Set([
40691
+ "\uFF0C",
40692
+ "\uFF0E",
40693
+ "\uFF01",
40694
+ "\uFF1A",
40695
+ "\uFF1B",
40696
+ "\uFF1F",
40697
+ "\u3001",
40698
+ "\u3002",
40699
+ "\u30FB",
40700
+ "\uFF09",
40701
+ "\u3015",
40702
+ "\u3009",
40703
+ "\u300B",
40704
+ "\u300D",
40705
+ "\u300F",
40706
+ "\u3011",
40707
+ "\u3017",
40708
+ "\u3019",
40709
+ "\u301B",
40710
+ "\u30FC",
40711
+ "\u3005",
40712
+ "\u303B",
40713
+ "\u309D",
40714
+ "\u309E",
40715
+ "\u30FD",
40716
+ "\u30FE"
40717
+ ]);
40718
+ var kinsokuEnd = /* @__PURE__ */ new Set([
40719
+ '"',
40720
+ "(",
40721
+ "[",
40722
+ "{",
40723
+ "\u201C",
40724
+ "\u2018",
40725
+ "\xAB",
40726
+ "\u2039",
40727
+ "\uFF08",
40728
+ "\u3014",
40729
+ "\u3008",
40730
+ "\u300A",
40731
+ "\u300C",
40732
+ "\u300E",
40733
+ "\u3010",
40734
+ "\u3016",
40735
+ "\u3018",
40736
+ "\u301A"
40737
+ ]);
40738
+ var forwardStickyGlue = /* @__PURE__ */ new Set([
40739
+ "'",
40740
+ "\u2019"
40741
+ ]);
40742
+ var leftStickyPunctuation = /* @__PURE__ */ new Set([
40743
+ ".",
40744
+ ",",
40745
+ "!",
40746
+ "?",
40747
+ ":",
40748
+ ";",
40749
+ "\u060C",
40750
+ "\u061B",
40751
+ "\u061F",
40752
+ "\u0964",
40753
+ "\u0965",
40754
+ "\u104A",
40755
+ "\u104B",
40756
+ "\u104C",
40757
+ "\u104D",
40758
+ "\u104F",
40759
+ ")",
40760
+ "]",
40761
+ "}",
40762
+ "%",
40763
+ '"',
40764
+ "\u201D",
40765
+ "\u2019",
40766
+ "\xBB",
40767
+ "\u203A",
40768
+ "\u2026"
40769
+ ]);
40770
+ var arabicNoSpaceTrailingPunctuation = /* @__PURE__ */ new Set([
40771
+ ":",
40772
+ ".",
40773
+ "\u060C",
40774
+ "\u061B"
40775
+ ]);
40776
+ var myanmarMedialGlue = /* @__PURE__ */ new Set([
40777
+ "\u104F"
40778
+ ]);
40779
+ var closingQuoteChars = /* @__PURE__ */ new Set([
40780
+ "\u201D",
40781
+ "\u2019",
40782
+ "\xBB",
40783
+ "\u203A",
40784
+ "\u300D",
40785
+ "\u300F",
40786
+ "\u3011",
40787
+ "\u300B",
40788
+ "\u3009",
40789
+ "\u3015",
40790
+ "\uFF09"
40791
+ ]);
40792
+ function isLeftStickyPunctuationSegment(segment) {
40793
+ if (isEscapedQuoteClusterSegment(segment))
40794
+ return true;
40795
+ let sawPunctuation = false;
40796
+ for (const ch of segment) {
40797
+ if (leftStickyPunctuation.has(ch)) {
40798
+ sawPunctuation = true;
40799
+ continue;
40800
+ }
40801
+ if (sawPunctuation && combiningMarkRe.test(ch))
40802
+ continue;
40803
+ return false;
40804
+ }
40805
+ return sawPunctuation;
40806
+ }
40807
+ __name(isLeftStickyPunctuationSegment, "isLeftStickyPunctuationSegment");
40808
+ function isCJKLineStartProhibitedSegment(segment) {
40809
+ for (const ch of segment) {
40810
+ if (!kinsokuStart.has(ch) && !leftStickyPunctuation.has(ch))
40811
+ return false;
40812
+ }
40813
+ return segment.length > 0;
40814
+ }
40815
+ __name(isCJKLineStartProhibitedSegment, "isCJKLineStartProhibitedSegment");
40816
+ function isForwardStickyClusterSegment(segment) {
40817
+ if (isEscapedQuoteClusterSegment(segment))
40818
+ return true;
40819
+ for (const ch of segment) {
40820
+ if (!kinsokuEnd.has(ch) && !forwardStickyGlue.has(ch) && !combiningMarkRe.test(ch))
40821
+ return false;
40822
+ }
40823
+ return segment.length > 0;
40824
+ }
40825
+ __name(isForwardStickyClusterSegment, "isForwardStickyClusterSegment");
40826
+ function isEscapedQuoteClusterSegment(segment) {
40827
+ let sawQuote = false;
40828
+ for (const ch of segment) {
40829
+ if (ch === "\\" || combiningMarkRe.test(ch))
40830
+ continue;
40831
+ if (kinsokuEnd.has(ch) || leftStickyPunctuation.has(ch) || forwardStickyGlue.has(ch)) {
40832
+ sawQuote = true;
40833
+ continue;
40834
+ }
40835
+ return false;
40836
+ }
40837
+ return sawQuote;
40838
+ }
40839
+ __name(isEscapedQuoteClusterSegment, "isEscapedQuoteClusterSegment");
40840
+ function previousCodePointStart(text2, end) {
40841
+ const last2 = end - 1;
40842
+ if (last2 <= 0)
40843
+ return Math.max(last2, 0);
40844
+ const lastCodeUnit = text2.charCodeAt(last2);
40845
+ if (lastCodeUnit < 56320 || lastCodeUnit > 57343)
40846
+ return last2;
40847
+ const maybeHigh = last2 - 1;
40848
+ if (maybeHigh < 0)
40849
+ return last2;
40850
+ const highCodeUnit = text2.charCodeAt(maybeHigh);
40851
+ return highCodeUnit >= 55296 && highCodeUnit <= 56319 ? maybeHigh : last2;
40852
+ }
40853
+ __name(previousCodePointStart, "previousCodePointStart");
40854
+ function getLastCodePoint(text2) {
40855
+ if (text2.length === 0)
40856
+ return null;
40857
+ const start = previousCodePointStart(text2, text2.length);
40858
+ return text2.slice(start);
40859
+ }
40860
+ __name(getLastCodePoint, "getLastCodePoint");
40861
+ function splitTrailingForwardStickyCluster(text2) {
40862
+ const chars = Array.from(text2);
40863
+ let splitIndex = chars.length;
40864
+ while (splitIndex > 0) {
40865
+ const ch = chars[splitIndex - 1];
40866
+ if (combiningMarkRe.test(ch)) {
40867
+ splitIndex--;
40868
+ continue;
40869
+ }
40870
+ if (kinsokuEnd.has(ch) || forwardStickyGlue.has(ch)) {
40871
+ splitIndex--;
40872
+ continue;
40873
+ }
40874
+ break;
40875
+ }
40876
+ if (splitIndex <= 0 || splitIndex === chars.length)
40877
+ return null;
40878
+ return {
40879
+ head: chars.slice(0, splitIndex).join(""),
40880
+ tail: chars.slice(splitIndex).join("")
40881
+ };
40882
+ }
40883
+ __name(splitTrailingForwardStickyCluster, "splitTrailingForwardStickyCluster");
40884
+ function getRepeatableSingleCharRunChar(text2, isWordLike, kind) {
40885
+ return kind === "text" && !isWordLike && text2.length === 1 && text2 !== "-" && text2 !== "\u2014" ? text2 : null;
40886
+ }
40887
+ __name(getRepeatableSingleCharRunChar, "getRepeatableSingleCharRunChar");
40888
+ function materializeDeferredSingleCharRun(texts, chars, lengths, index) {
40889
+ const ch = chars[index];
40890
+ const text2 = texts[index];
40891
+ if (ch == null)
40892
+ return text2;
40893
+ const length2 = lengths[index];
40894
+ if (text2.length === length2)
40895
+ return text2;
40896
+ const materialized = ch.repeat(length2);
40897
+ texts[index] = materialized;
40898
+ return materialized;
40899
+ }
40900
+ __name(materializeDeferredSingleCharRun, "materializeDeferredSingleCharRun");
40901
+ function hasArabicNoSpacePunctuation(containsArabic, lastCodePoint) {
40902
+ return containsArabic && lastCodePoint !== null && arabicNoSpaceTrailingPunctuation.has(lastCodePoint);
40903
+ }
40904
+ __name(hasArabicNoSpacePunctuation, "hasArabicNoSpacePunctuation");
40905
+ function endsWithMyanmarMedialGlue(segment) {
40906
+ const lastCodePoint = getLastCodePoint(segment);
40907
+ return lastCodePoint !== null && myanmarMedialGlue.has(lastCodePoint);
40908
+ }
40909
+ __name(endsWithMyanmarMedialGlue, "endsWithMyanmarMedialGlue");
40910
+ function splitLeadingSpaceAndMarks(segment) {
40911
+ if (segment.length < 2 || segment[0] !== " ")
40912
+ return null;
40913
+ const marks = segment.slice(1);
40914
+ if (/^\p{M}+$/u.test(marks)) {
40915
+ return { space: " ", marks };
40916
+ }
40917
+ return null;
40918
+ }
40919
+ __name(splitLeadingSpaceAndMarks, "splitLeadingSpaceAndMarks");
40920
+ function endsWithClosingQuote(text2) {
40921
+ let end = text2.length;
40922
+ while (end > 0) {
40923
+ const start = previousCodePointStart(text2, end);
40924
+ const ch = text2.slice(start, end);
40925
+ if (closingQuoteChars.has(ch))
40926
+ return true;
40927
+ if (!leftStickyPunctuation.has(ch))
40928
+ return false;
40929
+ end = start;
40930
+ }
40931
+ return false;
40932
+ }
40933
+ __name(endsWithClosingQuote, "endsWithClosingQuote");
40934
+ function classifySegmentBreakChar(ch, whiteSpaceProfile) {
40935
+ if (whiteSpaceProfile.preserveOrdinarySpaces || whiteSpaceProfile.preserveHardBreaks) {
40936
+ if (ch === " ")
40937
+ return "preserved-space";
40938
+ if (ch === " ")
40939
+ return "tab";
40940
+ if (whiteSpaceProfile.preserveHardBreaks && ch === "\n")
40941
+ return "hard-break";
40942
+ }
40943
+ if (ch === " ")
40944
+ return "space";
40945
+ if (ch === "\xA0" || ch === "\u202F" || ch === "\u2060" || ch === "\uFEFF") {
40946
+ return "glue";
40947
+ }
40948
+ if (ch === "\u200B")
40949
+ return "zero-width-break";
40950
+ if (ch === "\xAD")
40951
+ return "soft-hyphen";
40952
+ return "text";
40953
+ }
40954
+ __name(classifySegmentBreakChar, "classifySegmentBreakChar");
40955
+ var breakCharRe = /[\x20\t\n\xA0\xAD\u200B\u202F\u2060\uFEFF]/;
40956
+ function joinTextParts(parts) {
40957
+ return parts.length === 1 ? parts[0] : parts.join("");
40958
+ }
40959
+ __name(joinTextParts, "joinTextParts");
40960
+ function joinReversedPrefixParts(prefixParts, tail) {
40961
+ const parts = [];
40962
+ for (let i = prefixParts.length - 1; i >= 0; i--) {
40963
+ parts.push(prefixParts[i]);
40964
+ }
40965
+ parts.push(tail);
40966
+ return joinTextParts(parts);
40967
+ }
40968
+ __name(joinReversedPrefixParts, "joinReversedPrefixParts");
40969
+ function splitSegmentByBreakKind(segment, isWordLike, start, whiteSpaceProfile) {
40970
+ if (!breakCharRe.test(segment)) {
40971
+ return [{ text: segment, isWordLike, kind: "text", start }];
40972
+ }
40973
+ const pieces = [];
40974
+ let currentKind = null;
40975
+ let currentTextParts = [];
40976
+ let currentStart = start;
40977
+ let currentWordLike = false;
40978
+ let offset = 0;
40979
+ for (const ch of segment) {
40980
+ const kind = classifySegmentBreakChar(ch, whiteSpaceProfile);
40981
+ const wordLike = kind === "text" && isWordLike;
40982
+ if (currentKind !== null && kind === currentKind && wordLike === currentWordLike) {
40983
+ currentTextParts.push(ch);
40984
+ offset += ch.length;
40985
+ continue;
40986
+ }
40987
+ if (currentKind !== null) {
40988
+ pieces.push({
40989
+ text: joinTextParts(currentTextParts),
40990
+ isWordLike: currentWordLike,
40991
+ kind: currentKind,
40992
+ start: currentStart
40993
+ });
40994
+ }
40995
+ currentKind = kind;
40996
+ currentTextParts = [ch];
40997
+ currentStart = start + offset;
40998
+ currentWordLike = wordLike;
40999
+ offset += ch.length;
41000
+ }
41001
+ if (currentKind !== null) {
41002
+ pieces.push({
41003
+ text: joinTextParts(currentTextParts),
41004
+ isWordLike: currentWordLike,
41005
+ kind: currentKind,
41006
+ start: currentStart
41007
+ });
41008
+ }
41009
+ return pieces;
41010
+ }
41011
+ __name(splitSegmentByBreakKind, "splitSegmentByBreakKind");
41012
+ function isTextRunBoundary(kind) {
41013
+ return kind === "space" || kind === "preserved-space" || kind === "zero-width-break" || kind === "hard-break";
41014
+ }
41015
+ __name(isTextRunBoundary, "isTextRunBoundary");
41016
+ var urlSchemeSegmentRe = /^[A-Za-z][A-Za-z0-9+.-]*:$/;
41017
+ function isUrlLikeRunStart(segmentation, index) {
41018
+ const text2 = segmentation.texts[index];
41019
+ if (text2.startsWith("www."))
41020
+ return true;
41021
+ return urlSchemeSegmentRe.test(text2) && index + 1 < segmentation.len && segmentation.kinds[index + 1] === "text" && segmentation.texts[index + 1] === "//";
41022
+ }
41023
+ __name(isUrlLikeRunStart, "isUrlLikeRunStart");
41024
+ function isUrlQueryBoundarySegment(text2) {
41025
+ return text2.includes("?") && (text2.includes("://") || text2.startsWith("www."));
41026
+ }
41027
+ __name(isUrlQueryBoundarySegment, "isUrlQueryBoundarySegment");
41028
+ function mergeUrlLikeRuns(segmentation) {
41029
+ const texts = segmentation.texts.slice();
41030
+ const isWordLike = segmentation.isWordLike.slice();
41031
+ const kinds = segmentation.kinds.slice();
41032
+ const starts = segmentation.starts.slice();
41033
+ for (let i = 0; i < segmentation.len; i++) {
41034
+ if (kinds[i] !== "text" || !isUrlLikeRunStart(segmentation, i))
41035
+ continue;
41036
+ const mergedParts = [texts[i]];
41037
+ let j = i + 1;
41038
+ while (j < segmentation.len && !isTextRunBoundary(kinds[j])) {
41039
+ mergedParts.push(texts[j]);
41040
+ isWordLike[i] = true;
41041
+ const endsQueryPrefix = texts[j].includes("?");
41042
+ kinds[j] = "text";
41043
+ texts[j] = "";
41044
+ j++;
41045
+ if (endsQueryPrefix)
41046
+ break;
41047
+ }
41048
+ texts[i] = joinTextParts(mergedParts);
41049
+ }
41050
+ let compactLen = 0;
41051
+ for (let read = 0; read < texts.length; read++) {
41052
+ const text2 = texts[read];
41053
+ if (text2.length === 0)
41054
+ continue;
41055
+ if (compactLen !== read) {
41056
+ texts[compactLen] = text2;
41057
+ isWordLike[compactLen] = isWordLike[read];
41058
+ kinds[compactLen] = kinds[read];
41059
+ starts[compactLen] = starts[read];
41060
+ }
41061
+ compactLen++;
41062
+ }
41063
+ texts.length = compactLen;
41064
+ isWordLike.length = compactLen;
41065
+ kinds.length = compactLen;
41066
+ starts.length = compactLen;
41067
+ return {
41068
+ len: compactLen,
41069
+ texts,
41070
+ isWordLike,
41071
+ kinds,
41072
+ starts
41073
+ };
41074
+ }
41075
+ __name(mergeUrlLikeRuns, "mergeUrlLikeRuns");
41076
+ function mergeUrlQueryRuns(segmentation) {
41077
+ const texts = [];
41078
+ const isWordLike = [];
41079
+ const kinds = [];
41080
+ const starts = [];
41081
+ for (let i = 0; i < segmentation.len; i++) {
41082
+ const text2 = segmentation.texts[i];
41083
+ texts.push(text2);
41084
+ isWordLike.push(segmentation.isWordLike[i]);
41085
+ kinds.push(segmentation.kinds[i]);
41086
+ starts.push(segmentation.starts[i]);
41087
+ if (!isUrlQueryBoundarySegment(text2))
41088
+ continue;
41089
+ const nextIndex = i + 1;
41090
+ if (nextIndex >= segmentation.len || isTextRunBoundary(segmentation.kinds[nextIndex])) {
41091
+ continue;
41092
+ }
41093
+ const queryParts = [];
41094
+ const queryStart = segmentation.starts[nextIndex];
41095
+ let j = nextIndex;
41096
+ while (j < segmentation.len && !isTextRunBoundary(segmentation.kinds[j])) {
41097
+ queryParts.push(segmentation.texts[j]);
41098
+ j++;
41099
+ }
41100
+ if (queryParts.length > 0) {
41101
+ texts.push(joinTextParts(queryParts));
41102
+ isWordLike.push(true);
41103
+ kinds.push("text");
41104
+ starts.push(queryStart);
41105
+ i = j - 1;
41106
+ }
41107
+ }
41108
+ return {
41109
+ len: texts.length,
41110
+ texts,
41111
+ isWordLike,
41112
+ kinds,
41113
+ starts
41114
+ };
41115
+ }
41116
+ __name(mergeUrlQueryRuns, "mergeUrlQueryRuns");
41117
+ var numericJoinerChars = /* @__PURE__ */ new Set([
41118
+ ":",
41119
+ "-",
41120
+ "/",
41121
+ "\xD7",
41122
+ ",",
41123
+ ".",
41124
+ "+",
41125
+ "\u2013",
41126
+ "\u2014"
41127
+ ]);
41128
+ var asciiPunctuationChainSegmentRe = /^[A-Za-z0-9_]+[,:;]*$/;
41129
+ var asciiPunctuationChainTrailingJoinersRe = /[,:;]+$/;
41130
+ function segmentContainsDecimalDigit(text2) {
41131
+ for (const ch of text2) {
41132
+ if (decimalDigitRe.test(ch))
41133
+ return true;
41134
+ }
41135
+ return false;
41136
+ }
41137
+ __name(segmentContainsDecimalDigit, "segmentContainsDecimalDigit");
41138
+ function isNumericRunSegment(text2) {
41139
+ if (text2.length === 0)
41140
+ return false;
41141
+ for (const ch of text2) {
41142
+ if (decimalDigitRe.test(ch) || numericJoinerChars.has(ch))
41143
+ continue;
41144
+ return false;
41145
+ }
41146
+ return true;
41147
+ }
41148
+ __name(isNumericRunSegment, "isNumericRunSegment");
41149
+ function mergeNumericRuns(segmentation) {
41150
+ const texts = [];
41151
+ const isWordLike = [];
41152
+ const kinds = [];
41153
+ const starts = [];
41154
+ for (let i = 0; i < segmentation.len; i++) {
41155
+ const text2 = segmentation.texts[i];
41156
+ const kind = segmentation.kinds[i];
41157
+ if (kind === "text" && isNumericRunSegment(text2) && segmentContainsDecimalDigit(text2)) {
41158
+ const mergedParts = [text2];
41159
+ let j = i + 1;
41160
+ while (j < segmentation.len && segmentation.kinds[j] === "text" && isNumericRunSegment(segmentation.texts[j])) {
41161
+ mergedParts.push(segmentation.texts[j]);
41162
+ j++;
41163
+ }
41164
+ texts.push(joinTextParts(mergedParts));
41165
+ isWordLike.push(true);
41166
+ kinds.push("text");
41167
+ starts.push(segmentation.starts[i]);
41168
+ i = j - 1;
41169
+ continue;
41170
+ }
41171
+ texts.push(text2);
41172
+ isWordLike.push(segmentation.isWordLike[i]);
41173
+ kinds.push(kind);
41174
+ starts.push(segmentation.starts[i]);
41175
+ }
41176
+ return {
41177
+ len: texts.length,
41178
+ texts,
41179
+ isWordLike,
41180
+ kinds,
41181
+ starts
41182
+ };
41183
+ }
41184
+ __name(mergeNumericRuns, "mergeNumericRuns");
41185
+ function mergeAsciiPunctuationChains(segmentation) {
41186
+ const texts = [];
41187
+ const isWordLike = [];
41188
+ const kinds = [];
41189
+ const starts = [];
41190
+ for (let i = 0; i < segmentation.len; i++) {
41191
+ const text2 = segmentation.texts[i];
41192
+ const kind = segmentation.kinds[i];
41193
+ const wordLike = segmentation.isWordLike[i];
41194
+ if (kind === "text" && wordLike && asciiPunctuationChainSegmentRe.test(text2)) {
41195
+ const mergedParts = [text2];
41196
+ let endsWithJoiners = asciiPunctuationChainTrailingJoinersRe.test(text2);
41197
+ let j = i + 1;
41198
+ while (endsWithJoiners && j < segmentation.len && segmentation.kinds[j] === "text" && segmentation.isWordLike[j] && asciiPunctuationChainSegmentRe.test(segmentation.texts[j])) {
41199
+ const nextText = segmentation.texts[j];
41200
+ mergedParts.push(nextText);
41201
+ endsWithJoiners = asciiPunctuationChainTrailingJoinersRe.test(nextText);
41202
+ j++;
41203
+ }
41204
+ texts.push(joinTextParts(mergedParts));
41205
+ isWordLike.push(true);
41206
+ kinds.push("text");
41207
+ starts.push(segmentation.starts[i]);
41208
+ i = j - 1;
41209
+ continue;
41210
+ }
41211
+ texts.push(text2);
41212
+ isWordLike.push(wordLike);
41213
+ kinds.push(kind);
41214
+ starts.push(segmentation.starts[i]);
41215
+ }
41216
+ return {
41217
+ len: texts.length,
41218
+ texts,
41219
+ isWordLike,
41220
+ kinds,
41221
+ starts
41222
+ };
41223
+ }
41224
+ __name(mergeAsciiPunctuationChains, "mergeAsciiPunctuationChains");
41225
+ function splitHyphenatedNumericRuns(segmentation) {
41226
+ const texts = [];
41227
+ const isWordLike = [];
41228
+ const kinds = [];
41229
+ const starts = [];
41230
+ for (let i = 0; i < segmentation.len; i++) {
41231
+ const text2 = segmentation.texts[i];
41232
+ if (segmentation.kinds[i] === "text" && text2.includes("-")) {
41233
+ const parts = text2.split("-");
41234
+ let shouldSplit = parts.length > 1;
41235
+ for (let j = 0; j < parts.length; j++) {
41236
+ const part = parts[j];
41237
+ if (!shouldSplit)
41238
+ break;
41239
+ if (part.length === 0 || !segmentContainsDecimalDigit(part) || !isNumericRunSegment(part)) {
41240
+ shouldSplit = false;
41241
+ }
41242
+ }
41243
+ if (shouldSplit) {
41244
+ let offset = 0;
41245
+ for (let j = 0; j < parts.length; j++) {
41246
+ const part = parts[j];
41247
+ const splitText = j < parts.length - 1 ? `${part}-` : part;
41248
+ texts.push(splitText);
41249
+ isWordLike.push(true);
41250
+ kinds.push("text");
41251
+ starts.push(segmentation.starts[i] + offset);
41252
+ offset += splitText.length;
41253
+ }
41254
+ continue;
41255
+ }
41256
+ }
41257
+ texts.push(text2);
41258
+ isWordLike.push(segmentation.isWordLike[i]);
41259
+ kinds.push(segmentation.kinds[i]);
41260
+ starts.push(segmentation.starts[i]);
41261
+ }
41262
+ return {
41263
+ len: texts.length,
41264
+ texts,
41265
+ isWordLike,
41266
+ kinds,
41267
+ starts
41268
+ };
41269
+ }
41270
+ __name(splitHyphenatedNumericRuns, "splitHyphenatedNumericRuns");
41271
+ function mergeGlueConnectedTextRuns(segmentation) {
41272
+ const texts = [];
41273
+ const isWordLike = [];
41274
+ const kinds = [];
41275
+ const starts = [];
41276
+ let read = 0;
41277
+ while (read < segmentation.len) {
41278
+ const textParts = [segmentation.texts[read]];
41279
+ let wordLike = segmentation.isWordLike[read];
41280
+ let kind = segmentation.kinds[read];
41281
+ let start = segmentation.starts[read];
41282
+ if (kind === "glue") {
41283
+ const glueParts = [textParts[0]];
41284
+ const glueStart = start;
41285
+ read++;
41286
+ while (read < segmentation.len && segmentation.kinds[read] === "glue") {
41287
+ glueParts.push(segmentation.texts[read]);
41288
+ read++;
41289
+ }
41290
+ const glueText = joinTextParts(glueParts);
41291
+ if (read < segmentation.len && segmentation.kinds[read] === "text") {
41292
+ textParts[0] = glueText;
41293
+ textParts.push(segmentation.texts[read]);
41294
+ wordLike = segmentation.isWordLike[read];
41295
+ kind = "text";
41296
+ start = glueStart;
41297
+ read++;
41298
+ } else {
41299
+ texts.push(glueText);
41300
+ isWordLike.push(false);
41301
+ kinds.push("glue");
41302
+ starts.push(glueStart);
41303
+ continue;
41304
+ }
41305
+ } else {
41306
+ read++;
41307
+ }
41308
+ if (kind === "text") {
41309
+ while (read < segmentation.len && segmentation.kinds[read] === "glue") {
41310
+ const glueParts = [];
41311
+ while (read < segmentation.len && segmentation.kinds[read] === "glue") {
41312
+ glueParts.push(segmentation.texts[read]);
41313
+ read++;
41314
+ }
41315
+ const glueText = joinTextParts(glueParts);
41316
+ if (read < segmentation.len && segmentation.kinds[read] === "text") {
41317
+ textParts.push(glueText, segmentation.texts[read]);
41318
+ wordLike = wordLike || segmentation.isWordLike[read];
41319
+ read++;
41320
+ continue;
41321
+ }
41322
+ textParts.push(glueText);
41323
+ }
41324
+ }
41325
+ texts.push(joinTextParts(textParts));
41326
+ isWordLike.push(wordLike);
41327
+ kinds.push(kind);
41328
+ starts.push(start);
41329
+ }
41330
+ return {
41331
+ len: texts.length,
41332
+ texts,
41333
+ isWordLike,
41334
+ kinds,
41335
+ starts
41336
+ };
41337
+ }
41338
+ __name(mergeGlueConnectedTextRuns, "mergeGlueConnectedTextRuns");
41339
+ function carryTrailingForwardStickyAcrossCJKBoundary(segmentation) {
41340
+ const texts = segmentation.texts.slice();
41341
+ const isWordLike = segmentation.isWordLike.slice();
41342
+ const kinds = segmentation.kinds.slice();
41343
+ const starts = segmentation.starts.slice();
41344
+ for (let i = 0; i < texts.length - 1; i++) {
41345
+ if (kinds[i] !== "text" || kinds[i + 1] !== "text")
41346
+ continue;
41347
+ if (!isCJK(texts[i]) || !isCJK(texts[i + 1]))
41348
+ continue;
41349
+ const split = splitTrailingForwardStickyCluster(texts[i]);
41350
+ if (split === null)
41351
+ continue;
41352
+ texts[i] = split.head;
41353
+ texts[i + 1] = split.tail + texts[i + 1];
41354
+ starts[i + 1] = starts[i] + split.head.length;
41355
+ }
41356
+ return {
41357
+ len: texts.length,
41358
+ texts,
41359
+ isWordLike,
41360
+ kinds,
41361
+ starts
41362
+ };
41363
+ }
41364
+ __name(carryTrailingForwardStickyAcrossCJKBoundary, "carryTrailingForwardStickyAcrossCJKBoundary");
41365
+ function buildMergedSegmentation(normalized, profile, whiteSpaceProfile) {
41366
+ const wordSegmenter = getSharedWordSegmenter();
41367
+ let mergedLen = 0;
41368
+ const mergedTexts = [];
41369
+ const mergedTextParts = [];
41370
+ const mergedWordLike = [];
41371
+ const mergedKinds = [];
41372
+ const mergedStarts = [];
41373
+ const mergedSingleCharRunChars = [];
41374
+ const mergedSingleCharRunLengths = [];
41375
+ const mergedContainsCJK = [];
41376
+ const mergedContainsArabicScript = [];
41377
+ const mergedEndsWithClosingQuote = [];
41378
+ const mergedEndsWithMyanmarMedialGlue = [];
41379
+ const mergedHasArabicNoSpacePunctuation = [];
41380
+ for (const s of wordSegmenter.segment(normalized)) {
41381
+ for (const piece of splitSegmentByBreakKind(s.segment, s.isWordLike ?? false, s.index, whiteSpaceProfile)) {
41382
+ let appendPieceToPrevious2 = function() {
41383
+ if (mergedSingleCharRunChars[prevIndex] !== null) {
41384
+ mergedTextParts[prevIndex] = [
41385
+ materializeDeferredSingleCharRun(mergedTexts, mergedSingleCharRunChars, mergedSingleCharRunLengths, prevIndex)
41386
+ ];
41387
+ mergedSingleCharRunChars[prevIndex] = null;
41388
+ }
41389
+ mergedTextParts[prevIndex].push(piece.text);
41390
+ mergedWordLike[prevIndex] = mergedWordLike[prevIndex] || piece.isWordLike;
41391
+ mergedContainsCJK[prevIndex] = mergedContainsCJK[prevIndex] || pieceContainsCJK;
41392
+ mergedContainsArabicScript[prevIndex] = mergedContainsArabicScript[prevIndex] || pieceContainsArabicScript;
41393
+ mergedEndsWithClosingQuote[prevIndex] = pieceEndsWithClosingQuote;
41394
+ mergedEndsWithMyanmarMedialGlue[prevIndex] = pieceEndsWithMyanmarMedialGlue;
41395
+ mergedHasArabicNoSpacePunctuation[prevIndex] = hasArabicNoSpacePunctuation(mergedContainsArabicScript[prevIndex], pieceLastCodePoint);
41396
+ };
41397
+ var appendPieceToPrevious = appendPieceToPrevious2;
41398
+ __name(appendPieceToPrevious2, "appendPieceToPrevious");
41399
+ const isText = piece.kind === "text";
41400
+ const repeatableSingleCharRunChar = getRepeatableSingleCharRunChar(piece.text, piece.isWordLike, piece.kind);
41401
+ const pieceContainsCJK = isCJK(piece.text);
41402
+ const pieceContainsArabicScript = containsArabicScript(piece.text);
41403
+ const pieceLastCodePoint = getLastCodePoint(piece.text);
41404
+ const pieceEndsWithClosingQuote = endsWithClosingQuote(piece.text);
41405
+ const pieceEndsWithMyanmarMedialGlue = endsWithMyanmarMedialGlue(piece.text);
41406
+ const prevIndex = mergedLen - 1;
41407
+ if (profile.carryCJKAfterClosingQuote && isText && mergedLen > 0 && mergedKinds[prevIndex] === "text" && pieceContainsCJK && mergedContainsCJK[prevIndex] && mergedEndsWithClosingQuote[prevIndex]) {
41408
+ appendPieceToPrevious2();
41409
+ } else if (isText && mergedLen > 0 && mergedKinds[prevIndex] === "text" && isCJKLineStartProhibitedSegment(piece.text) && mergedContainsCJK[prevIndex]) {
41410
+ appendPieceToPrevious2();
41411
+ } else if (isText && mergedLen > 0 && mergedKinds[prevIndex] === "text" && mergedEndsWithMyanmarMedialGlue[prevIndex]) {
41412
+ appendPieceToPrevious2();
41413
+ } else if (isText && mergedLen > 0 && mergedKinds[prevIndex] === "text" && piece.isWordLike && pieceContainsArabicScript && mergedHasArabicNoSpacePunctuation[prevIndex]) {
41414
+ appendPieceToPrevious2();
41415
+ mergedWordLike[prevIndex] = true;
41416
+ } else if (repeatableSingleCharRunChar !== null && mergedLen > 0 && mergedKinds[prevIndex] === "text" && mergedSingleCharRunChars[prevIndex] === repeatableSingleCharRunChar) {
41417
+ mergedSingleCharRunLengths[prevIndex] = (mergedSingleCharRunLengths[prevIndex] ?? 1) + 1;
41418
+ } else if (isText && !piece.isWordLike && mergedLen > 0 && mergedKinds[prevIndex] === "text" && (isLeftStickyPunctuationSegment(piece.text) || piece.text === "-" && mergedWordLike[prevIndex])) {
41419
+ appendPieceToPrevious2();
41420
+ } else {
41421
+ mergedTexts[mergedLen] = piece.text;
41422
+ mergedTextParts[mergedLen] = [piece.text];
41423
+ mergedWordLike[mergedLen] = piece.isWordLike;
41424
+ mergedKinds[mergedLen] = piece.kind;
41425
+ mergedStarts[mergedLen] = piece.start;
41426
+ mergedSingleCharRunChars[mergedLen] = repeatableSingleCharRunChar;
41427
+ mergedSingleCharRunLengths[mergedLen] = repeatableSingleCharRunChar === null ? 0 : 1;
41428
+ mergedContainsCJK[mergedLen] = pieceContainsCJK;
41429
+ mergedContainsArabicScript[mergedLen] = pieceContainsArabicScript;
41430
+ mergedEndsWithClosingQuote[mergedLen] = pieceEndsWithClosingQuote;
41431
+ mergedEndsWithMyanmarMedialGlue[mergedLen] = pieceEndsWithMyanmarMedialGlue;
41432
+ mergedHasArabicNoSpacePunctuation[mergedLen] = hasArabicNoSpacePunctuation(pieceContainsArabicScript, pieceLastCodePoint);
41433
+ mergedLen++;
41434
+ }
41435
+ }
41436
+ }
41437
+ for (let i = 0; i < mergedLen; i++) {
41438
+ if (mergedSingleCharRunChars[i] !== null) {
41439
+ mergedTexts[i] = materializeDeferredSingleCharRun(mergedTexts, mergedSingleCharRunChars, mergedSingleCharRunLengths, i);
41440
+ continue;
41441
+ }
41442
+ mergedTexts[i] = joinTextParts(mergedTextParts[i]);
41443
+ }
41444
+ for (let i = 1; i < mergedLen; i++) {
41445
+ if (mergedKinds[i] === "text" && !mergedWordLike[i] && isEscapedQuoteClusterSegment(mergedTexts[i]) && mergedKinds[i - 1] === "text") {
41446
+ mergedTexts[i - 1] += mergedTexts[i];
41447
+ mergedWordLike[i - 1] = mergedWordLike[i - 1] || mergedWordLike[i];
41448
+ mergedTexts[i] = "";
41449
+ }
41450
+ }
41451
+ const forwardStickyPrefixParts = Array.from({ length: mergedLen }, () => null);
41452
+ let nextLiveIndex = -1;
41453
+ for (let i = mergedLen - 1; i >= 0; i--) {
41454
+ const text2 = mergedTexts[i];
41455
+ if (text2.length === 0)
41456
+ continue;
41457
+ if (mergedKinds[i] === "text" && !mergedWordLike[i] && isForwardStickyClusterSegment(text2) && nextLiveIndex >= 0 && mergedKinds[nextLiveIndex] === "text") {
41458
+ const prefixParts = forwardStickyPrefixParts[nextLiveIndex] ?? [];
41459
+ prefixParts.push(text2);
41460
+ forwardStickyPrefixParts[nextLiveIndex] = prefixParts;
41461
+ mergedStarts[nextLiveIndex] = mergedStarts[i];
41462
+ mergedTexts[i] = "";
41463
+ continue;
41464
+ }
41465
+ nextLiveIndex = i;
41466
+ }
41467
+ for (let i = 0; i < mergedLen; i++) {
41468
+ const prefixParts = forwardStickyPrefixParts[i];
41469
+ if (prefixParts == null)
41470
+ continue;
41471
+ mergedTexts[i] = joinReversedPrefixParts(prefixParts, mergedTexts[i]);
41472
+ }
41473
+ let compactLen = 0;
41474
+ for (let read = 0; read < mergedLen; read++) {
41475
+ const text2 = mergedTexts[read];
41476
+ if (text2.length === 0)
41477
+ continue;
41478
+ if (compactLen !== read) {
41479
+ mergedTexts[compactLen] = text2;
41480
+ mergedWordLike[compactLen] = mergedWordLike[read];
41481
+ mergedKinds[compactLen] = mergedKinds[read];
41482
+ mergedStarts[compactLen] = mergedStarts[read];
41483
+ }
41484
+ compactLen++;
41485
+ }
41486
+ mergedTexts.length = compactLen;
41487
+ mergedWordLike.length = compactLen;
41488
+ mergedKinds.length = compactLen;
41489
+ mergedStarts.length = compactLen;
41490
+ const compacted = mergeGlueConnectedTextRuns({
41491
+ len: compactLen,
41492
+ texts: mergedTexts,
41493
+ isWordLike: mergedWordLike,
41494
+ kinds: mergedKinds,
41495
+ starts: mergedStarts
41496
+ });
41497
+ const withMergedUrls = carryTrailingForwardStickyAcrossCJKBoundary(mergeAsciiPunctuationChains(splitHyphenatedNumericRuns(mergeNumericRuns(mergeUrlQueryRuns(mergeUrlLikeRuns(compacted))))));
41498
+ for (let i = 0; i < withMergedUrls.len - 1; i++) {
41499
+ const split = splitLeadingSpaceAndMarks(withMergedUrls.texts[i]);
41500
+ if (split === null)
41501
+ continue;
41502
+ if (withMergedUrls.kinds[i] !== "space" && withMergedUrls.kinds[i] !== "preserved-space" || withMergedUrls.kinds[i + 1] !== "text" || !containsArabicScript(withMergedUrls.texts[i + 1])) {
41503
+ continue;
41504
+ }
41505
+ withMergedUrls.texts[i] = split.space;
41506
+ withMergedUrls.isWordLike[i] = false;
41507
+ withMergedUrls.kinds[i] = withMergedUrls.kinds[i] === "preserved-space" ? "preserved-space" : "space";
41508
+ withMergedUrls.texts[i + 1] = split.marks + withMergedUrls.texts[i + 1];
41509
+ withMergedUrls.starts[i + 1] = withMergedUrls.starts[i] + split.space.length;
41510
+ }
41511
+ return withMergedUrls;
41512
+ }
41513
+ __name(buildMergedSegmentation, "buildMergedSegmentation");
41514
+ function compileAnalysisChunks(segmentation, whiteSpaceProfile) {
41515
+ if (segmentation.len === 0)
41516
+ return [];
41517
+ if (!whiteSpaceProfile.preserveHardBreaks) {
41518
+ return [{
41519
+ startSegmentIndex: 0,
41520
+ endSegmentIndex: segmentation.len,
41521
+ consumedEndSegmentIndex: segmentation.len
41522
+ }];
41523
+ }
41524
+ const chunks = [];
41525
+ let startSegmentIndex = 0;
41526
+ for (let i = 0; i < segmentation.len; i++) {
41527
+ if (segmentation.kinds[i] !== "hard-break")
41528
+ continue;
41529
+ chunks.push({
41530
+ startSegmentIndex,
41531
+ endSegmentIndex: i,
41532
+ consumedEndSegmentIndex: i + 1
41533
+ });
41534
+ startSegmentIndex = i + 1;
41535
+ }
41536
+ if (startSegmentIndex < segmentation.len) {
41537
+ chunks.push({
41538
+ startSegmentIndex,
41539
+ endSegmentIndex: segmentation.len,
41540
+ consumedEndSegmentIndex: segmentation.len
41541
+ });
41542
+ }
41543
+ return chunks;
41544
+ }
41545
+ __name(compileAnalysisChunks, "compileAnalysisChunks");
41546
+ function mergeKeepAllTextSegments(segmentation) {
41547
+ if (segmentation.len <= 1)
41548
+ return segmentation;
41549
+ const texts = [];
41550
+ const isWordLike = [];
41551
+ const kinds = [];
41552
+ const starts = [];
41553
+ let pendingTextParts = null;
41554
+ let pendingWordLike = false;
41555
+ let pendingStart = 0;
41556
+ let pendingContainsCJK = false;
41557
+ let pendingCanContinue = false;
41558
+ function flushPendingText() {
41559
+ if (pendingTextParts === null)
41560
+ return;
41561
+ texts.push(joinTextParts(pendingTextParts));
41562
+ isWordLike.push(pendingWordLike);
41563
+ kinds.push("text");
41564
+ starts.push(pendingStart);
41565
+ pendingTextParts = null;
41566
+ }
41567
+ __name(flushPendingText, "flushPendingText");
41568
+ for (let i = 0; i < segmentation.len; i++) {
41569
+ const text2 = segmentation.texts[i];
41570
+ const kind = segmentation.kinds[i];
41571
+ const wordLike = segmentation.isWordLike[i];
41572
+ const start = segmentation.starts[i];
41573
+ if (kind === "text") {
41574
+ const textContainsCJK = containsCJKText(text2);
41575
+ const textCanContinue = canContinueKeepAllTextRun(text2);
41576
+ if (pendingTextParts !== null && pendingContainsCJK && pendingCanContinue) {
41577
+ pendingTextParts.push(text2);
41578
+ pendingWordLike = pendingWordLike || wordLike;
41579
+ pendingContainsCJK = pendingContainsCJK || textContainsCJK;
41580
+ pendingCanContinue = textCanContinue;
41581
+ continue;
41582
+ }
41583
+ flushPendingText();
41584
+ pendingTextParts = [text2];
41585
+ pendingWordLike = wordLike;
41586
+ pendingStart = start;
41587
+ pendingContainsCJK = textContainsCJK;
41588
+ pendingCanContinue = textCanContinue;
41589
+ continue;
41590
+ }
41591
+ flushPendingText();
41592
+ texts.push(text2);
41593
+ isWordLike.push(wordLike);
41594
+ kinds.push(kind);
41595
+ starts.push(start);
41596
+ }
41597
+ flushPendingText();
41598
+ return {
41599
+ len: texts.length,
41600
+ texts,
41601
+ isWordLike,
41602
+ kinds,
41603
+ starts
41604
+ };
41605
+ }
41606
+ __name(mergeKeepAllTextSegments, "mergeKeepAllTextSegments");
41607
+ function analyzeText(text2, profile, whiteSpace = "normal", wordBreak = "normal") {
41608
+ const whiteSpaceProfile = getWhiteSpaceProfile(whiteSpace);
41609
+ const normalized = whiteSpaceProfile.mode === "pre-wrap" ? normalizeWhitespacePreWrap(text2) : normalizeWhitespaceNormal(text2);
41610
+ if (normalized.length === 0) {
41611
+ return {
41612
+ normalized,
41613
+ chunks: [],
41614
+ len: 0,
41615
+ texts: [],
41616
+ isWordLike: [],
41617
+ kinds: [],
41618
+ starts: []
41619
+ };
41620
+ }
41621
+ const segmentation = wordBreak === "keep-all" ? mergeKeepAllTextSegments(buildMergedSegmentation(normalized, profile, whiteSpaceProfile)) : buildMergedSegmentation(normalized, profile, whiteSpaceProfile);
41622
+ return {
41623
+ normalized,
41624
+ chunks: compileAnalysisChunks(segmentation, whiteSpaceProfile),
41625
+ ...segmentation
41626
+ };
41627
+ }
41628
+ __name(analyzeText, "analyzeText");
41629
+
41630
+ // ../../node_modules/.pnpm/@chenglou+pretext@0.0.5/node_modules/@chenglou/pretext/dist/measurement.js
41631
+ var measureContext = null;
41632
+ var segmentMetricCaches = /* @__PURE__ */ new Map();
41633
+ var cachedEngineProfile = null;
41634
+ var MAX_PREFIX_FIT_GRAPHEMES = 96;
41635
+ var emojiPresentationRe = /\p{Emoji_Presentation}/u;
41636
+ var maybeEmojiRe = /[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u;
41637
+ var sharedGraphemeSegmenter = null;
41638
+ var emojiCorrectionCache = /* @__PURE__ */ new Map();
41639
+ function getMeasureContext() {
41640
+ if (measureContext !== null)
41641
+ return measureContext;
41642
+ if (typeof OffscreenCanvas !== "undefined") {
41643
+ measureContext = new OffscreenCanvas(1, 1).getContext("2d");
41644
+ return measureContext;
41645
+ }
41646
+ if (typeof document !== "undefined") {
41647
+ measureContext = document.createElement("canvas").getContext("2d");
41648
+ return measureContext;
41649
+ }
41650
+ throw new Error("Text measurement requires OffscreenCanvas or a DOM canvas context.");
41651
+ }
41652
+ __name(getMeasureContext, "getMeasureContext");
41653
+ function getSegmentMetricCache(font) {
41654
+ let cache3 = segmentMetricCaches.get(font);
41655
+ if (!cache3) {
41656
+ cache3 = /* @__PURE__ */ new Map();
41657
+ segmentMetricCaches.set(font, cache3);
41658
+ }
41659
+ return cache3;
41660
+ }
41661
+ __name(getSegmentMetricCache, "getSegmentMetricCache");
41662
+ function getSegmentMetrics(seg, cache3) {
41663
+ let metrics = cache3.get(seg);
41664
+ if (metrics === void 0) {
41665
+ const ctx = getMeasureContext();
41666
+ metrics = {
41667
+ width: ctx.measureText(seg).width,
41668
+ containsCJK: isCJK(seg)
41669
+ };
41670
+ cache3.set(seg, metrics);
41671
+ }
41672
+ return metrics;
41673
+ }
41674
+ __name(getSegmentMetrics, "getSegmentMetrics");
41675
+ function getEngineProfile() {
41676
+ if (cachedEngineProfile !== null)
41677
+ return cachedEngineProfile;
41678
+ if (typeof navigator === "undefined") {
41679
+ cachedEngineProfile = {
41680
+ lineFitEpsilon: 5e-3,
41681
+ carryCJKAfterClosingQuote: false,
41682
+ preferPrefixWidthsForBreakableRuns: false,
41683
+ preferEarlySoftHyphenBreak: false
41684
+ };
41685
+ return cachedEngineProfile;
41686
+ }
41687
+ const ua = navigator.userAgent;
41688
+ const vendor = navigator.vendor;
41689
+ const isSafari = vendor === "Apple Computer, Inc." && ua.includes("Safari/") && !ua.includes("Chrome/") && !ua.includes("Chromium/") && !ua.includes("CriOS/") && !ua.includes("FxiOS/") && !ua.includes("EdgiOS/");
41690
+ const isChromium = ua.includes("Chrome/") || ua.includes("Chromium/") || ua.includes("CriOS/") || ua.includes("Edg/");
41691
+ cachedEngineProfile = {
41692
+ lineFitEpsilon: isSafari ? 1 / 64 : 5e-3,
41693
+ carryCJKAfterClosingQuote: isChromium,
41694
+ preferPrefixWidthsForBreakableRuns: isSafari,
41695
+ preferEarlySoftHyphenBreak: isSafari
41696
+ };
41697
+ return cachedEngineProfile;
41698
+ }
41699
+ __name(getEngineProfile, "getEngineProfile");
41700
+ function parseFontSize(font) {
41701
+ const m = font.match(/(\d+(?:\.\d+)?)\s*px/);
41702
+ return m ? parseFloat(m[1]) : 16;
41703
+ }
41704
+ __name(parseFontSize, "parseFontSize");
41705
+ function getSharedGraphemeSegmenter() {
41706
+ if (sharedGraphemeSegmenter === null) {
41707
+ sharedGraphemeSegmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
41708
+ }
41709
+ return sharedGraphemeSegmenter;
41710
+ }
41711
+ __name(getSharedGraphemeSegmenter, "getSharedGraphemeSegmenter");
41712
+ function isEmojiGrapheme(g) {
41713
+ return emojiPresentationRe.test(g) || g.includes("\uFE0F");
41714
+ }
41715
+ __name(isEmojiGrapheme, "isEmojiGrapheme");
41716
+ function textMayContainEmoji(text2) {
41717
+ return maybeEmojiRe.test(text2);
41718
+ }
41719
+ __name(textMayContainEmoji, "textMayContainEmoji");
41720
+ function getEmojiCorrection(font, fontSize) {
41721
+ let correction = emojiCorrectionCache.get(font);
41722
+ if (correction !== void 0)
41723
+ return correction;
41724
+ const ctx = getMeasureContext();
41725
+ ctx.font = font;
41726
+ const canvasW = ctx.measureText("\u{1F600}").width;
41727
+ correction = 0;
41728
+ if (canvasW > fontSize + 0.5 && typeof document !== "undefined" && document.body !== null) {
41729
+ const span = document.createElement("span");
41730
+ span.style.font = font;
41731
+ span.style.display = "inline-block";
41732
+ span.style.visibility = "hidden";
41733
+ span.style.position = "absolute";
41734
+ span.textContent = "\u{1F600}";
41735
+ document.body.appendChild(span);
41736
+ const domW = span.getBoundingClientRect().width;
41737
+ document.body.removeChild(span);
41738
+ if (canvasW - domW > 0.5) {
41739
+ correction = canvasW - domW;
41740
+ }
41741
+ }
41742
+ emojiCorrectionCache.set(font, correction);
41743
+ return correction;
41744
+ }
41745
+ __name(getEmojiCorrection, "getEmojiCorrection");
41746
+ function countEmojiGraphemes(text2) {
41747
+ let count2 = 0;
41748
+ const graphemeSegmenter = getSharedGraphemeSegmenter();
41749
+ for (const g of graphemeSegmenter.segment(text2)) {
41750
+ if (isEmojiGrapheme(g.segment))
41751
+ count2++;
41752
+ }
41753
+ return count2;
41754
+ }
41755
+ __name(countEmojiGraphemes, "countEmojiGraphemes");
41756
+ function getEmojiCount(seg, metrics) {
41757
+ if (metrics.emojiCount === void 0) {
41758
+ metrics.emojiCount = countEmojiGraphemes(seg);
41759
+ }
41760
+ return metrics.emojiCount;
41761
+ }
41762
+ __name(getEmojiCount, "getEmojiCount");
41763
+ function getCorrectedSegmentWidth(seg, metrics, emojiCorrection) {
41764
+ if (emojiCorrection === 0)
41765
+ return metrics.width;
41766
+ return metrics.width - getEmojiCount(seg, metrics) * emojiCorrection;
41767
+ }
41768
+ __name(getCorrectedSegmentWidth, "getCorrectedSegmentWidth");
41769
+ function getSegmentBreakableFitAdvances(seg, metrics, cache3, emojiCorrection, mode) {
41770
+ if (metrics.breakableFitAdvances !== void 0)
41771
+ return metrics.breakableFitAdvances;
41772
+ const graphemeSegmenter = getSharedGraphemeSegmenter();
41773
+ const graphemes = [];
41774
+ for (const gs of graphemeSegmenter.segment(seg)) {
41775
+ graphemes.push(gs.segment);
41776
+ }
41777
+ if (graphemes.length <= 1) {
41778
+ metrics.breakableFitAdvances = null;
41779
+ return metrics.breakableFitAdvances;
41780
+ }
41781
+ if (mode === "sum-graphemes") {
41782
+ const advances2 = [];
41783
+ for (const grapheme of graphemes) {
41784
+ const graphemeMetrics = getSegmentMetrics(grapheme, cache3);
41785
+ advances2.push(getCorrectedSegmentWidth(grapheme, graphemeMetrics, emojiCorrection));
41786
+ }
41787
+ metrics.breakableFitAdvances = advances2;
41788
+ return metrics.breakableFitAdvances;
41789
+ }
41790
+ if (mode === "pair-context" || graphemes.length > MAX_PREFIX_FIT_GRAPHEMES) {
41791
+ const advances2 = [];
41792
+ let previousGrapheme = null;
41793
+ let previousWidth = 0;
41794
+ for (const grapheme of graphemes) {
41795
+ const graphemeMetrics = getSegmentMetrics(grapheme, cache3);
41796
+ const currentWidth = getCorrectedSegmentWidth(grapheme, graphemeMetrics, emojiCorrection);
41797
+ if (previousGrapheme === null) {
41798
+ advances2.push(currentWidth);
41799
+ } else {
41800
+ const pair = previousGrapheme + grapheme;
41801
+ const pairMetrics = getSegmentMetrics(pair, cache3);
41802
+ advances2.push(getCorrectedSegmentWidth(pair, pairMetrics, emojiCorrection) - previousWidth);
41803
+ }
41804
+ previousGrapheme = grapheme;
41805
+ previousWidth = currentWidth;
41806
+ }
41807
+ metrics.breakableFitAdvances = advances2;
41808
+ return metrics.breakableFitAdvances;
41809
+ }
41810
+ const advances = [];
41811
+ let prefix = "";
41812
+ let prefixWidth = 0;
41813
+ for (const grapheme of graphemes) {
41814
+ prefix += grapheme;
41815
+ const prefixMetrics = getSegmentMetrics(prefix, cache3);
41816
+ const nextPrefixWidth = getCorrectedSegmentWidth(prefix, prefixMetrics, emojiCorrection);
41817
+ advances.push(nextPrefixWidth - prefixWidth);
41818
+ prefixWidth = nextPrefixWidth;
41819
+ }
41820
+ metrics.breakableFitAdvances = advances;
41821
+ return metrics.breakableFitAdvances;
41822
+ }
41823
+ __name(getSegmentBreakableFitAdvances, "getSegmentBreakableFitAdvances");
41824
+ function getFontMeasurementState(font, needsEmojiCorrection) {
41825
+ const ctx = getMeasureContext();
41826
+ ctx.font = font;
41827
+ const cache3 = getSegmentMetricCache(font);
41828
+ const fontSize = parseFontSize(font);
41829
+ const emojiCorrection = needsEmojiCorrection ? getEmojiCorrection(font, fontSize) : 0;
41830
+ return { cache: cache3, fontSize, emojiCorrection };
41831
+ }
41832
+ __name(getFontMeasurementState, "getFontMeasurementState");
41833
+
41834
+ // ../../node_modules/.pnpm/@chenglou+pretext@0.0.5/node_modules/@chenglou/pretext/dist/line-break.js
41835
+ function normalizeSimpleLineStartSegmentIndex(prepared, segmentIndex) {
41836
+ while (segmentIndex < prepared.widths.length) {
41837
+ const kind = prepared.kinds[segmentIndex];
41838
+ if (kind !== "space" && kind !== "zero-width-break" && kind !== "soft-hyphen")
41839
+ break;
41840
+ segmentIndex++;
41841
+ }
41842
+ return segmentIndex;
41843
+ }
41844
+ __name(normalizeSimpleLineStartSegmentIndex, "normalizeSimpleLineStartSegmentIndex");
41845
+ function getTabAdvance(lineWidth, tabStopAdvance) {
41846
+ if (tabStopAdvance <= 0)
41847
+ return 0;
41848
+ const remainder = lineWidth % tabStopAdvance;
41849
+ if (Math.abs(remainder) <= 1e-6)
41850
+ return tabStopAdvance;
41851
+ return tabStopAdvance - remainder;
41852
+ }
41853
+ __name(getTabAdvance, "getTabAdvance");
41854
+ function fitSoftHyphenBreak(graphemeFitAdvances, initialWidth, maxWidth, lineFitEpsilon, discretionaryHyphenWidth) {
41855
+ let fitCount = 0;
41856
+ let fittedWidth = initialWidth;
41857
+ while (fitCount < graphemeFitAdvances.length) {
41858
+ const nextWidth = fittedWidth + graphemeFitAdvances[fitCount];
41859
+ const nextLineWidth = fitCount + 1 < graphemeFitAdvances.length ? nextWidth + discretionaryHyphenWidth : nextWidth;
41860
+ if (nextLineWidth > maxWidth + lineFitEpsilon)
41861
+ break;
41862
+ fittedWidth = nextWidth;
41863
+ fitCount++;
41864
+ }
41865
+ return { fitCount, fittedWidth };
41866
+ }
41867
+ __name(fitSoftHyphenBreak, "fitSoftHyphenBreak");
41868
+ function findChunkIndexForStart(prepared, segmentIndex) {
41869
+ let lo = 0;
41870
+ let hi = prepared.chunks.length;
41871
+ while (lo < hi) {
41872
+ const mid = Math.floor((lo + hi) / 2);
41873
+ if (segmentIndex < prepared.chunks[mid].consumedEndSegmentIndex) {
41874
+ hi = mid;
41875
+ } else {
41876
+ lo = mid + 1;
41877
+ }
41878
+ }
41879
+ return lo < prepared.chunks.length ? lo : -1;
41880
+ }
41881
+ __name(findChunkIndexForStart, "findChunkIndexForStart");
41882
+ function normalizeLineStartInChunk(prepared, chunkIndex, cursor) {
41883
+ let segmentIndex = cursor.segmentIndex;
41884
+ if (cursor.graphemeIndex > 0)
41885
+ return chunkIndex;
41886
+ const chunk = prepared.chunks[chunkIndex];
41887
+ if (chunk.startSegmentIndex === chunk.endSegmentIndex && segmentIndex === chunk.startSegmentIndex) {
41888
+ cursor.segmentIndex = segmentIndex;
41889
+ cursor.graphemeIndex = 0;
41890
+ return chunkIndex;
41891
+ }
41892
+ if (segmentIndex < chunk.startSegmentIndex)
41893
+ segmentIndex = chunk.startSegmentIndex;
41894
+ while (segmentIndex < chunk.endSegmentIndex) {
41895
+ const kind = prepared.kinds[segmentIndex];
41896
+ if (kind !== "space" && kind !== "zero-width-break" && kind !== "soft-hyphen") {
41897
+ cursor.segmentIndex = segmentIndex;
41898
+ cursor.graphemeIndex = 0;
41899
+ return chunkIndex;
41900
+ }
41901
+ segmentIndex++;
41902
+ }
41903
+ if (chunk.consumedEndSegmentIndex >= prepared.widths.length)
41904
+ return -1;
41905
+ cursor.segmentIndex = chunk.consumedEndSegmentIndex;
41906
+ cursor.graphemeIndex = 0;
41907
+ return chunkIndex + 1;
41908
+ }
41909
+ __name(normalizeLineStartInChunk, "normalizeLineStartInChunk");
41910
+ function normalizeLineStartChunkIndex(prepared, cursor) {
41911
+ if (cursor.segmentIndex >= prepared.widths.length)
41912
+ return -1;
41913
+ const chunkIndex = findChunkIndexForStart(prepared, cursor.segmentIndex);
41914
+ if (chunkIndex < 0)
41915
+ return -1;
41916
+ return normalizeLineStartInChunk(prepared, chunkIndex, cursor);
41917
+ }
41918
+ __name(normalizeLineStartChunkIndex, "normalizeLineStartChunkIndex");
41919
+ function walkPreparedLinesSimple(prepared, maxWidth, onLine) {
41920
+ const { widths, kinds, breakableFitAdvances } = prepared;
41921
+ if (widths.length === 0)
41922
+ return 0;
41923
+ const engineProfile = getEngineProfile();
41924
+ const lineFitEpsilon = engineProfile.lineFitEpsilon;
41925
+ const fitLimit = maxWidth + lineFitEpsilon;
41926
+ let lineCount = 0;
41927
+ let lineW = 0;
41928
+ let hasContent = false;
41929
+ let lineStartSegmentIndex = 0;
41930
+ let lineStartGraphemeIndex = 0;
41931
+ let lineEndSegmentIndex = 0;
41932
+ let lineEndGraphemeIndex = 0;
41933
+ let pendingBreakSegmentIndex = -1;
41934
+ let pendingBreakPaintWidth = 0;
41935
+ function clearPendingBreak() {
41936
+ pendingBreakSegmentIndex = -1;
41937
+ pendingBreakPaintWidth = 0;
41938
+ }
41939
+ __name(clearPendingBreak, "clearPendingBreak");
41940
+ function emitCurrentLine(endSegmentIndex = lineEndSegmentIndex, endGraphemeIndex = lineEndGraphemeIndex, width2 = lineW) {
41941
+ lineCount++;
41942
+ onLine?.({
41943
+ startSegmentIndex: lineStartSegmentIndex,
41944
+ startGraphemeIndex: lineStartGraphemeIndex,
41945
+ endSegmentIndex,
41946
+ endGraphemeIndex,
41947
+ width: width2
41948
+ });
41949
+ lineW = 0;
41950
+ hasContent = false;
41951
+ clearPendingBreak();
41952
+ }
41953
+ __name(emitCurrentLine, "emitCurrentLine");
41954
+ function startLineAtSegment(segmentIndex, width2) {
41955
+ hasContent = true;
41956
+ lineStartSegmentIndex = segmentIndex;
41957
+ lineStartGraphemeIndex = 0;
41958
+ lineEndSegmentIndex = segmentIndex + 1;
41959
+ lineEndGraphemeIndex = 0;
41960
+ lineW = width2;
41961
+ }
41962
+ __name(startLineAtSegment, "startLineAtSegment");
41963
+ function startLineAtGrapheme(segmentIndex, graphemeIndex, width2) {
41964
+ hasContent = true;
41965
+ lineStartSegmentIndex = segmentIndex;
41966
+ lineStartGraphemeIndex = graphemeIndex;
41967
+ lineEndSegmentIndex = segmentIndex;
41968
+ lineEndGraphemeIndex = graphemeIndex + 1;
41969
+ lineW = width2;
41970
+ }
41971
+ __name(startLineAtGrapheme, "startLineAtGrapheme");
41972
+ function appendWholeSegment(segmentIndex, width2) {
41973
+ if (!hasContent) {
41974
+ startLineAtSegment(segmentIndex, width2);
41975
+ return;
41976
+ }
41977
+ lineW += width2;
41978
+ lineEndSegmentIndex = segmentIndex + 1;
41979
+ lineEndGraphemeIndex = 0;
41980
+ }
41981
+ __name(appendWholeSegment, "appendWholeSegment");
41982
+ function appendBreakableSegmentFrom(segmentIndex, startGraphemeIndex) {
41983
+ const fitAdvances = breakableFitAdvances[segmentIndex];
41984
+ for (let g = startGraphemeIndex; g < fitAdvances.length; g++) {
41985
+ const gw = fitAdvances[g];
41986
+ if (!hasContent) {
41987
+ startLineAtGrapheme(segmentIndex, g, gw);
41988
+ } else if (lineW + gw > fitLimit) {
41989
+ emitCurrentLine();
41990
+ startLineAtGrapheme(segmentIndex, g, gw);
41991
+ } else {
41992
+ lineW += gw;
41993
+ lineEndSegmentIndex = segmentIndex;
41994
+ lineEndGraphemeIndex = g + 1;
41995
+ }
41996
+ }
41997
+ if (hasContent && lineEndSegmentIndex === segmentIndex && lineEndGraphemeIndex === fitAdvances.length) {
41998
+ lineEndSegmentIndex = segmentIndex + 1;
41999
+ lineEndGraphemeIndex = 0;
42000
+ }
42001
+ }
42002
+ __name(appendBreakableSegmentFrom, "appendBreakableSegmentFrom");
42003
+ let i = 0;
42004
+ while (i < widths.length) {
42005
+ if (!hasContent) {
42006
+ i = normalizeSimpleLineStartSegmentIndex(prepared, i);
42007
+ if (i >= widths.length)
42008
+ break;
42009
+ }
42010
+ const w = widths[i];
42011
+ const kind = kinds[i];
42012
+ const breakAfter = kind === "space" || kind === "preserved-space" || kind === "tab" || kind === "zero-width-break" || kind === "soft-hyphen";
42013
+ if (!hasContent) {
42014
+ if (w > maxWidth && breakableFitAdvances[i] !== null) {
42015
+ appendBreakableSegmentFrom(i, 0);
42016
+ } else {
42017
+ startLineAtSegment(i, w);
42018
+ }
42019
+ if (breakAfter) {
42020
+ pendingBreakSegmentIndex = i + 1;
42021
+ pendingBreakPaintWidth = lineW - w;
42022
+ }
42023
+ i++;
42024
+ continue;
42025
+ }
42026
+ const newW = lineW + w;
42027
+ if (newW > fitLimit) {
42028
+ if (breakAfter) {
42029
+ appendWholeSegment(i, w);
42030
+ emitCurrentLine(i + 1, 0, lineW - w);
42031
+ i++;
42032
+ continue;
42033
+ }
42034
+ if (pendingBreakSegmentIndex >= 0) {
42035
+ if (lineEndSegmentIndex > pendingBreakSegmentIndex || lineEndSegmentIndex === pendingBreakSegmentIndex && lineEndGraphemeIndex > 0) {
42036
+ emitCurrentLine();
42037
+ continue;
42038
+ }
42039
+ emitCurrentLine(pendingBreakSegmentIndex, 0, pendingBreakPaintWidth);
42040
+ continue;
42041
+ }
42042
+ if (w > maxWidth && breakableFitAdvances[i] !== null) {
42043
+ emitCurrentLine();
42044
+ appendBreakableSegmentFrom(i, 0);
42045
+ i++;
42046
+ continue;
42047
+ }
42048
+ emitCurrentLine();
42049
+ continue;
42050
+ }
42051
+ appendWholeSegment(i, w);
42052
+ if (breakAfter) {
42053
+ pendingBreakSegmentIndex = i + 1;
42054
+ pendingBreakPaintWidth = lineW - w;
42055
+ }
42056
+ i++;
42057
+ }
42058
+ if (hasContent)
42059
+ emitCurrentLine();
42060
+ return lineCount;
42061
+ }
42062
+ __name(walkPreparedLinesSimple, "walkPreparedLinesSimple");
42063
+ function walkPreparedLines(prepared, maxWidth, onLine) {
42064
+ if (prepared.simpleLineWalkFastPath) {
42065
+ return walkPreparedLinesSimple(prepared, maxWidth, onLine);
42066
+ }
42067
+ const { widths, lineEndFitAdvances, lineEndPaintAdvances, kinds, breakableFitAdvances, discretionaryHyphenWidth, tabStopAdvance, chunks } = prepared;
42068
+ if (widths.length === 0 || chunks.length === 0)
42069
+ return 0;
42070
+ const engineProfile = getEngineProfile();
42071
+ const lineFitEpsilon = engineProfile.lineFitEpsilon;
42072
+ const fitLimit = maxWidth + lineFitEpsilon;
42073
+ let lineCount = 0;
42074
+ let lineW = 0;
42075
+ let hasContent = false;
42076
+ let lineStartSegmentIndex = 0;
42077
+ let lineStartGraphemeIndex = 0;
42078
+ let lineEndSegmentIndex = 0;
42079
+ let lineEndGraphemeIndex = 0;
42080
+ let pendingBreakSegmentIndex = -1;
42081
+ let pendingBreakFitWidth = 0;
42082
+ let pendingBreakPaintWidth = 0;
42083
+ let pendingBreakKind = null;
42084
+ function clearPendingBreak() {
42085
+ pendingBreakSegmentIndex = -1;
42086
+ pendingBreakFitWidth = 0;
42087
+ pendingBreakPaintWidth = 0;
42088
+ pendingBreakKind = null;
42089
+ }
42090
+ __name(clearPendingBreak, "clearPendingBreak");
42091
+ function emitCurrentLine(endSegmentIndex = lineEndSegmentIndex, endGraphemeIndex = lineEndGraphemeIndex, width2 = lineW) {
42092
+ lineCount++;
42093
+ onLine?.({
42094
+ startSegmentIndex: lineStartSegmentIndex,
42095
+ startGraphemeIndex: lineStartGraphemeIndex,
42096
+ endSegmentIndex,
42097
+ endGraphemeIndex,
42098
+ width: width2
42099
+ });
42100
+ lineW = 0;
42101
+ hasContent = false;
42102
+ clearPendingBreak();
42103
+ }
42104
+ __name(emitCurrentLine, "emitCurrentLine");
42105
+ function startLineAtSegment(segmentIndex, width2) {
42106
+ hasContent = true;
42107
+ lineStartSegmentIndex = segmentIndex;
42108
+ lineStartGraphemeIndex = 0;
42109
+ lineEndSegmentIndex = segmentIndex + 1;
42110
+ lineEndGraphemeIndex = 0;
42111
+ lineW = width2;
42112
+ }
42113
+ __name(startLineAtSegment, "startLineAtSegment");
42114
+ function startLineAtGrapheme(segmentIndex, graphemeIndex, width2) {
42115
+ hasContent = true;
42116
+ lineStartSegmentIndex = segmentIndex;
42117
+ lineStartGraphemeIndex = graphemeIndex;
42118
+ lineEndSegmentIndex = segmentIndex;
42119
+ lineEndGraphemeIndex = graphemeIndex + 1;
42120
+ lineW = width2;
42121
+ }
42122
+ __name(startLineAtGrapheme, "startLineAtGrapheme");
42123
+ function appendWholeSegment(segmentIndex, width2) {
42124
+ if (!hasContent) {
42125
+ startLineAtSegment(segmentIndex, width2);
42126
+ return;
42127
+ }
42128
+ lineW += width2;
42129
+ lineEndSegmentIndex = segmentIndex + 1;
42130
+ lineEndGraphemeIndex = 0;
42131
+ }
42132
+ __name(appendWholeSegment, "appendWholeSegment");
42133
+ function updatePendingBreakForWholeSegment(kind, breakAfter, segmentIndex, segmentWidth) {
42134
+ if (!breakAfter)
42135
+ return;
42136
+ const fitAdvance = kind === "tab" ? 0 : lineEndFitAdvances[segmentIndex];
42137
+ const paintAdvance = kind === "tab" ? segmentWidth : lineEndPaintAdvances[segmentIndex];
42138
+ pendingBreakSegmentIndex = segmentIndex + 1;
42139
+ pendingBreakFitWidth = lineW - segmentWidth + fitAdvance;
42140
+ pendingBreakPaintWidth = lineW - segmentWidth + paintAdvance;
42141
+ pendingBreakKind = kind;
42142
+ }
42143
+ __name(updatePendingBreakForWholeSegment, "updatePendingBreakForWholeSegment");
42144
+ function appendBreakableSegmentFrom(segmentIndex, startGraphemeIndex) {
42145
+ const fitAdvances = breakableFitAdvances[segmentIndex];
42146
+ for (let g = startGraphemeIndex; g < fitAdvances.length; g++) {
42147
+ const gw = fitAdvances[g];
42148
+ if (!hasContent) {
42149
+ startLineAtGrapheme(segmentIndex, g, gw);
42150
+ } else if (lineW + gw > fitLimit) {
42151
+ emitCurrentLine();
42152
+ startLineAtGrapheme(segmentIndex, g, gw);
42153
+ } else {
42154
+ lineW += gw;
42155
+ lineEndSegmentIndex = segmentIndex;
42156
+ lineEndGraphemeIndex = g + 1;
42157
+ }
42158
+ }
42159
+ if (hasContent && lineEndSegmentIndex === segmentIndex && lineEndGraphemeIndex === fitAdvances.length) {
42160
+ lineEndSegmentIndex = segmentIndex + 1;
42161
+ lineEndGraphemeIndex = 0;
42162
+ }
42163
+ }
42164
+ __name(appendBreakableSegmentFrom, "appendBreakableSegmentFrom");
42165
+ function continueSoftHyphenBreakableSegment(segmentIndex) {
42166
+ if (pendingBreakKind !== "soft-hyphen")
42167
+ return false;
42168
+ const fitWidths = breakableFitAdvances[segmentIndex];
42169
+ if (fitWidths == null)
42170
+ return false;
42171
+ const { fitCount, fittedWidth } = fitSoftHyphenBreak(fitWidths, lineW, maxWidth, lineFitEpsilon, discretionaryHyphenWidth);
42172
+ if (fitCount === 0)
42173
+ return false;
42174
+ lineW = fittedWidth;
42175
+ lineEndSegmentIndex = segmentIndex;
42176
+ lineEndGraphemeIndex = fitCount;
42177
+ clearPendingBreak();
42178
+ if (fitCount === fitWidths.length) {
42179
+ lineEndSegmentIndex = segmentIndex + 1;
42180
+ lineEndGraphemeIndex = 0;
42181
+ return true;
42182
+ }
42183
+ emitCurrentLine(segmentIndex, fitCount, fittedWidth + discretionaryHyphenWidth);
42184
+ appendBreakableSegmentFrom(segmentIndex, fitCount);
42185
+ return true;
42186
+ }
42187
+ __name(continueSoftHyphenBreakableSegment, "continueSoftHyphenBreakableSegment");
42188
+ function emitEmptyChunk(chunk) {
42189
+ lineCount++;
42190
+ onLine?.({
42191
+ startSegmentIndex: chunk.startSegmentIndex,
42192
+ startGraphemeIndex: 0,
42193
+ endSegmentIndex: chunk.consumedEndSegmentIndex,
42194
+ endGraphemeIndex: 0,
42195
+ width: 0
42196
+ });
42197
+ clearPendingBreak();
42198
+ }
42199
+ __name(emitEmptyChunk, "emitEmptyChunk");
42200
+ for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
42201
+ const chunk = chunks[chunkIndex];
42202
+ if (chunk.startSegmentIndex === chunk.endSegmentIndex) {
42203
+ emitEmptyChunk(chunk);
42204
+ continue;
42205
+ }
42206
+ hasContent = false;
42207
+ lineW = 0;
42208
+ lineStartSegmentIndex = chunk.startSegmentIndex;
42209
+ lineStartGraphemeIndex = 0;
42210
+ lineEndSegmentIndex = chunk.startSegmentIndex;
42211
+ lineEndGraphemeIndex = 0;
42212
+ clearPendingBreak();
42213
+ let i = chunk.startSegmentIndex;
42214
+ while (i < chunk.endSegmentIndex) {
42215
+ const kind = kinds[i];
42216
+ const breakAfter = kind === "space" || kind === "preserved-space" || kind === "tab" || kind === "zero-width-break" || kind === "soft-hyphen";
42217
+ const w = kind === "tab" ? getTabAdvance(lineW, tabStopAdvance) : widths[i];
42218
+ if (kind === "soft-hyphen") {
42219
+ if (hasContent) {
42220
+ lineEndSegmentIndex = i + 1;
42221
+ lineEndGraphemeIndex = 0;
42222
+ pendingBreakSegmentIndex = i + 1;
42223
+ pendingBreakFitWidth = lineW + discretionaryHyphenWidth;
42224
+ pendingBreakPaintWidth = lineW + discretionaryHyphenWidth;
42225
+ pendingBreakKind = kind;
42226
+ }
42227
+ i++;
42228
+ continue;
42229
+ }
42230
+ if (!hasContent) {
42231
+ if (w > maxWidth && breakableFitAdvances[i] !== null) {
42232
+ appendBreakableSegmentFrom(i, 0);
42233
+ } else {
42234
+ startLineAtSegment(i, w);
42235
+ }
42236
+ updatePendingBreakForWholeSegment(kind, breakAfter, i, w);
42237
+ i++;
42238
+ continue;
42239
+ }
42240
+ const newW = lineW + w;
42241
+ if (newW > fitLimit) {
42242
+ const currentBreakFitWidth = lineW + (kind === "tab" ? 0 : lineEndFitAdvances[i]);
42243
+ const currentBreakPaintWidth = lineW + (kind === "tab" ? w : lineEndPaintAdvances[i]);
42244
+ if (pendingBreakKind === "soft-hyphen" && engineProfile.preferEarlySoftHyphenBreak && pendingBreakFitWidth <= fitLimit) {
42245
+ emitCurrentLine(pendingBreakSegmentIndex, 0, pendingBreakPaintWidth);
42246
+ continue;
42247
+ }
42248
+ if (pendingBreakKind === "soft-hyphen" && continueSoftHyphenBreakableSegment(i)) {
42249
+ i++;
42250
+ continue;
42251
+ }
42252
+ if (breakAfter && currentBreakFitWidth <= fitLimit) {
42253
+ appendWholeSegment(i, w);
42254
+ emitCurrentLine(i + 1, 0, currentBreakPaintWidth);
42255
+ i++;
42256
+ continue;
42257
+ }
42258
+ if (pendingBreakSegmentIndex >= 0 && pendingBreakFitWidth <= fitLimit) {
42259
+ if (lineEndSegmentIndex > pendingBreakSegmentIndex || lineEndSegmentIndex === pendingBreakSegmentIndex && lineEndGraphemeIndex > 0) {
42260
+ emitCurrentLine();
42261
+ continue;
42262
+ }
42263
+ const nextSegmentIndex = pendingBreakSegmentIndex;
42264
+ emitCurrentLine(nextSegmentIndex, 0, pendingBreakPaintWidth);
42265
+ i = nextSegmentIndex;
42266
+ continue;
42267
+ }
42268
+ if (w > maxWidth && breakableFitAdvances[i] !== null) {
42269
+ emitCurrentLine();
42270
+ appendBreakableSegmentFrom(i, 0);
42271
+ i++;
42272
+ continue;
42273
+ }
42274
+ emitCurrentLine();
42275
+ continue;
42276
+ }
42277
+ appendWholeSegment(i, w);
42278
+ updatePendingBreakForWholeSegment(kind, breakAfter, i, w);
42279
+ i++;
42280
+ }
42281
+ if (hasContent) {
42282
+ const finalPaintWidth = pendingBreakSegmentIndex === chunk.consumedEndSegmentIndex ? pendingBreakPaintWidth : lineW;
42283
+ emitCurrentLine(chunk.consumedEndSegmentIndex, 0, finalPaintWidth);
42284
+ }
42285
+ }
42286
+ return lineCount;
42287
+ }
42288
+ __name(walkPreparedLines, "walkPreparedLines");
42289
+ function stepPreparedChunkLineGeometry(prepared, cursor, chunkIndex, maxWidth) {
42290
+ const chunk = prepared.chunks[chunkIndex];
42291
+ if (chunk.startSegmentIndex === chunk.endSegmentIndex) {
42292
+ cursor.segmentIndex = chunk.consumedEndSegmentIndex;
42293
+ cursor.graphemeIndex = 0;
42294
+ return 0;
42295
+ }
42296
+ const { widths, lineEndFitAdvances, lineEndPaintAdvances, kinds, breakableFitAdvances, discretionaryHyphenWidth, tabStopAdvance } = prepared;
42297
+ const engineProfile = getEngineProfile();
42298
+ const lineFitEpsilon = engineProfile.lineFitEpsilon;
42299
+ const fitLimit = maxWidth + lineFitEpsilon;
42300
+ let lineW = 0;
42301
+ let hasContent = false;
42302
+ let lineEndSegmentIndex = cursor.segmentIndex;
42303
+ let lineEndGraphemeIndex = cursor.graphemeIndex;
42304
+ let pendingBreakSegmentIndex = -1;
42305
+ let pendingBreakFitWidth = 0;
42306
+ let pendingBreakPaintWidth = 0;
42307
+ let pendingBreakKind = null;
42308
+ function clearPendingBreak() {
42309
+ pendingBreakSegmentIndex = -1;
42310
+ pendingBreakFitWidth = 0;
42311
+ pendingBreakPaintWidth = 0;
42312
+ pendingBreakKind = null;
42313
+ }
42314
+ __name(clearPendingBreak, "clearPendingBreak");
42315
+ function finishLine(endSegmentIndex = lineEndSegmentIndex, endGraphemeIndex = lineEndGraphemeIndex, width2 = lineW) {
42316
+ if (!hasContent)
42317
+ return null;
42318
+ cursor.segmentIndex = endSegmentIndex;
42319
+ cursor.graphemeIndex = endGraphemeIndex;
42320
+ return width2;
42321
+ }
42322
+ __name(finishLine, "finishLine");
42323
+ function startLineAtSegment(segmentIndex, width2) {
42324
+ hasContent = true;
42325
+ lineEndSegmentIndex = segmentIndex + 1;
42326
+ lineEndGraphemeIndex = 0;
42327
+ lineW = width2;
42328
+ }
42329
+ __name(startLineAtSegment, "startLineAtSegment");
42330
+ function startLineAtGrapheme(segmentIndex, graphemeIndex, width2) {
42331
+ hasContent = true;
42332
+ lineEndSegmentIndex = segmentIndex;
42333
+ lineEndGraphemeIndex = graphemeIndex + 1;
42334
+ lineW = width2;
42335
+ }
42336
+ __name(startLineAtGrapheme, "startLineAtGrapheme");
42337
+ function appendWholeSegment(segmentIndex, width2) {
42338
+ if (!hasContent) {
42339
+ startLineAtSegment(segmentIndex, width2);
42340
+ return;
42341
+ }
42342
+ lineW += width2;
42343
+ lineEndSegmentIndex = segmentIndex + 1;
42344
+ lineEndGraphemeIndex = 0;
42345
+ }
42346
+ __name(appendWholeSegment, "appendWholeSegment");
42347
+ function updatePendingBreakForWholeSegment(kind, breakAfter, segmentIndex, segmentWidth) {
42348
+ if (!breakAfter)
42349
+ return;
42350
+ const fitAdvance = kind === "tab" ? 0 : lineEndFitAdvances[segmentIndex];
42351
+ const paintAdvance = kind === "tab" ? segmentWidth : lineEndPaintAdvances[segmentIndex];
42352
+ pendingBreakSegmentIndex = segmentIndex + 1;
42353
+ pendingBreakFitWidth = lineW - segmentWidth + fitAdvance;
42354
+ pendingBreakPaintWidth = lineW - segmentWidth + paintAdvance;
42355
+ pendingBreakKind = kind;
42356
+ }
42357
+ __name(updatePendingBreakForWholeSegment, "updatePendingBreakForWholeSegment");
42358
+ function appendBreakableSegmentFrom(segmentIndex, startGraphemeIndex) {
42359
+ const fitAdvances = breakableFitAdvances[segmentIndex];
42360
+ for (let g = startGraphemeIndex; g < fitAdvances.length; g++) {
42361
+ const gw = fitAdvances[g];
42362
+ if (!hasContent) {
42363
+ startLineAtGrapheme(segmentIndex, g, gw);
42364
+ } else {
42365
+ if (lineW + gw > fitLimit) {
42366
+ return finishLine();
42367
+ }
42368
+ lineW += gw;
42369
+ lineEndSegmentIndex = segmentIndex;
42370
+ lineEndGraphemeIndex = g + 1;
42371
+ }
42372
+ }
42373
+ if (hasContent && lineEndSegmentIndex === segmentIndex && lineEndGraphemeIndex === fitAdvances.length) {
42374
+ lineEndSegmentIndex = segmentIndex + 1;
42375
+ lineEndGraphemeIndex = 0;
42376
+ }
42377
+ return null;
42378
+ }
42379
+ __name(appendBreakableSegmentFrom, "appendBreakableSegmentFrom");
42380
+ function maybeFinishAtSoftHyphen(segmentIndex) {
42381
+ if (pendingBreakKind !== "soft-hyphen" || pendingBreakSegmentIndex < 0)
42382
+ return null;
42383
+ const fitWidths = breakableFitAdvances[segmentIndex] ?? null;
42384
+ if (fitWidths !== null) {
42385
+ const { fitCount, fittedWidth } = fitSoftHyphenBreak(fitWidths, lineW, maxWidth, lineFitEpsilon, discretionaryHyphenWidth);
42386
+ if (fitCount === fitWidths.length) {
42387
+ lineW = fittedWidth;
42388
+ lineEndSegmentIndex = segmentIndex + 1;
42389
+ lineEndGraphemeIndex = 0;
42390
+ clearPendingBreak();
42391
+ return null;
42392
+ }
42393
+ if (fitCount > 0) {
42394
+ return finishLine(segmentIndex, fitCount, fittedWidth + discretionaryHyphenWidth);
42395
+ }
42396
+ }
42397
+ if (pendingBreakFitWidth <= fitLimit) {
42398
+ return finishLine(pendingBreakSegmentIndex, 0, pendingBreakPaintWidth);
42399
+ }
42400
+ return null;
42401
+ }
42402
+ __name(maybeFinishAtSoftHyphen, "maybeFinishAtSoftHyphen");
42403
+ for (let i = cursor.segmentIndex; i < chunk.endSegmentIndex; i++) {
42404
+ const kind = kinds[i];
42405
+ const breakAfter = kind === "space" || kind === "preserved-space" || kind === "tab" || kind === "zero-width-break" || kind === "soft-hyphen";
42406
+ const startGraphemeIndex = i === cursor.segmentIndex ? cursor.graphemeIndex : 0;
42407
+ const w = kind === "tab" ? getTabAdvance(lineW, tabStopAdvance) : widths[i];
42408
+ if (kind === "soft-hyphen" && startGraphemeIndex === 0) {
42409
+ if (hasContent) {
42410
+ lineEndSegmentIndex = i + 1;
42411
+ lineEndGraphemeIndex = 0;
42412
+ pendingBreakSegmentIndex = i + 1;
42413
+ pendingBreakFitWidth = lineW + discretionaryHyphenWidth;
42414
+ pendingBreakPaintWidth = lineW + discretionaryHyphenWidth;
42415
+ pendingBreakKind = kind;
42416
+ }
42417
+ continue;
42418
+ }
42419
+ if (!hasContent) {
42420
+ if (startGraphemeIndex > 0) {
42421
+ const line2 = appendBreakableSegmentFrom(i, startGraphemeIndex);
42422
+ if (line2 !== null)
42423
+ return line2;
42424
+ } else if (w > maxWidth && breakableFitAdvances[i] !== null) {
42425
+ const line2 = appendBreakableSegmentFrom(i, 0);
42426
+ if (line2 !== null)
42427
+ return line2;
42428
+ } else {
42429
+ startLineAtSegment(i, w);
42430
+ }
42431
+ updatePendingBreakForWholeSegment(kind, breakAfter, i, w);
42432
+ continue;
42433
+ }
42434
+ const newW = lineW + w;
42435
+ if (newW > fitLimit) {
42436
+ const currentBreakFitWidth = lineW + (kind === "tab" ? 0 : lineEndFitAdvances[i]);
42437
+ const currentBreakPaintWidth = lineW + (kind === "tab" ? w : lineEndPaintAdvances[i]);
42438
+ if (pendingBreakKind === "soft-hyphen" && engineProfile.preferEarlySoftHyphenBreak && pendingBreakFitWidth <= fitLimit) {
42439
+ return finishLine(pendingBreakSegmentIndex, 0, pendingBreakPaintWidth);
42440
+ }
42441
+ const softBreakLine = maybeFinishAtSoftHyphen(i);
42442
+ if (softBreakLine !== null)
42443
+ return softBreakLine;
42444
+ if (breakAfter && currentBreakFitWidth <= fitLimit) {
42445
+ appendWholeSegment(i, w);
42446
+ return finishLine(i + 1, 0, currentBreakPaintWidth);
42447
+ }
42448
+ if (pendingBreakSegmentIndex >= 0 && pendingBreakFitWidth <= fitLimit) {
42449
+ if (lineEndSegmentIndex > pendingBreakSegmentIndex || lineEndSegmentIndex === pendingBreakSegmentIndex && lineEndGraphemeIndex > 0) {
42450
+ return finishLine();
42451
+ }
42452
+ return finishLine(pendingBreakSegmentIndex, 0, pendingBreakPaintWidth);
42453
+ }
42454
+ if (w > maxWidth && breakableFitAdvances[i] !== null) {
42455
+ const currentLine = finishLine();
42456
+ if (currentLine !== null)
42457
+ return currentLine;
42458
+ const line2 = appendBreakableSegmentFrom(i, 0);
42459
+ if (line2 !== null)
42460
+ return line2;
42461
+ }
42462
+ return finishLine();
42463
+ }
42464
+ appendWholeSegment(i, w);
42465
+ updatePendingBreakForWholeSegment(kind, breakAfter, i, w);
42466
+ }
42467
+ if (pendingBreakSegmentIndex === chunk.consumedEndSegmentIndex && lineEndGraphemeIndex === 0) {
42468
+ return finishLine(chunk.consumedEndSegmentIndex, 0, pendingBreakPaintWidth);
42469
+ }
42470
+ return finishLine(chunk.consumedEndSegmentIndex, 0, lineW);
42471
+ }
42472
+ __name(stepPreparedChunkLineGeometry, "stepPreparedChunkLineGeometry");
42473
+ function stepPreparedSimpleLineGeometry(prepared, cursor, maxWidth) {
42474
+ const { widths, kinds, breakableFitAdvances } = prepared;
42475
+ const engineProfile = getEngineProfile();
42476
+ const lineFitEpsilon = engineProfile.lineFitEpsilon;
42477
+ const fitLimit = maxWidth + lineFitEpsilon;
42478
+ let lineW = 0;
42479
+ let hasContent = false;
42480
+ let lineEndSegmentIndex = cursor.segmentIndex;
42481
+ let lineEndGraphemeIndex = cursor.graphemeIndex;
42482
+ let pendingBreakSegmentIndex = -1;
42483
+ let pendingBreakPaintWidth = 0;
42484
+ for (let i = cursor.segmentIndex; i < widths.length; i++) {
42485
+ const w = widths[i];
42486
+ const kind = kinds[i];
42487
+ const breakAfter = kind === "space" || kind === "preserved-space" || kind === "tab" || kind === "zero-width-break" || kind === "soft-hyphen";
42488
+ const startGraphemeIndex = i === cursor.segmentIndex ? cursor.graphemeIndex : 0;
42489
+ const breakableFitAdvance = breakableFitAdvances[i];
42490
+ if (!hasContent) {
42491
+ if (startGraphemeIndex > 0 || w > maxWidth && breakableFitAdvance !== null) {
42492
+ const fitAdvances = breakableFitAdvance;
42493
+ const firstGraphemeWidth = fitAdvances[startGraphemeIndex];
42494
+ hasContent = true;
42495
+ lineW = firstGraphemeWidth;
42496
+ lineEndSegmentIndex = i;
42497
+ lineEndGraphemeIndex = startGraphemeIndex + 1;
42498
+ for (let g = startGraphemeIndex + 1; g < fitAdvances.length; g++) {
42499
+ const gw = fitAdvances[g];
42500
+ if (lineW + gw > fitLimit) {
42501
+ cursor.segmentIndex = lineEndSegmentIndex;
42502
+ cursor.graphemeIndex = lineEndGraphemeIndex;
42503
+ return lineW;
42504
+ }
42505
+ lineW += gw;
42506
+ lineEndSegmentIndex = i;
42507
+ lineEndGraphemeIndex = g + 1;
42508
+ }
42509
+ if (lineEndSegmentIndex === i && lineEndGraphemeIndex === fitAdvances.length) {
42510
+ lineEndSegmentIndex = i + 1;
42511
+ lineEndGraphemeIndex = 0;
42512
+ }
42513
+ } else {
42514
+ hasContent = true;
42515
+ lineW = w;
42516
+ lineEndSegmentIndex = i + 1;
42517
+ lineEndGraphemeIndex = 0;
42518
+ }
42519
+ if (breakAfter) {
42520
+ pendingBreakSegmentIndex = i + 1;
42521
+ pendingBreakPaintWidth = lineW - w;
42522
+ }
42523
+ continue;
42524
+ }
42525
+ if (lineW + w > fitLimit) {
42526
+ if (breakAfter) {
42527
+ cursor.segmentIndex = i + 1;
42528
+ cursor.graphemeIndex = 0;
42529
+ return lineW;
42530
+ }
42531
+ if (pendingBreakSegmentIndex >= 0) {
42532
+ if (lineEndSegmentIndex > pendingBreakSegmentIndex || lineEndSegmentIndex === pendingBreakSegmentIndex && lineEndGraphemeIndex > 0) {
42533
+ cursor.segmentIndex = lineEndSegmentIndex;
42534
+ cursor.graphemeIndex = lineEndGraphemeIndex;
42535
+ return lineW;
42536
+ }
42537
+ cursor.segmentIndex = pendingBreakSegmentIndex;
42538
+ cursor.graphemeIndex = 0;
42539
+ return pendingBreakPaintWidth;
42540
+ }
42541
+ cursor.segmentIndex = lineEndSegmentIndex;
42542
+ cursor.graphemeIndex = lineEndGraphemeIndex;
42543
+ return lineW;
42544
+ }
42545
+ lineW += w;
42546
+ lineEndSegmentIndex = i + 1;
42547
+ lineEndGraphemeIndex = 0;
42548
+ if (breakAfter) {
42549
+ pendingBreakSegmentIndex = i + 1;
42550
+ pendingBreakPaintWidth = lineW - w;
42551
+ }
42552
+ }
42553
+ if (!hasContent)
42554
+ return null;
42555
+ cursor.segmentIndex = lineEndSegmentIndex;
42556
+ cursor.graphemeIndex = lineEndGraphemeIndex;
42557
+ return lineW;
42558
+ }
42559
+ __name(stepPreparedSimpleLineGeometry, "stepPreparedSimpleLineGeometry");
42560
+ function layoutNextLineRange(prepared, start, maxWidth) {
42561
+ const end = {
42562
+ segmentIndex: start.segmentIndex,
42563
+ graphemeIndex: start.graphemeIndex
42564
+ };
42565
+ const chunkIndex = normalizeLineStartChunkIndex(prepared, end);
42566
+ if (chunkIndex < 0)
42567
+ return null;
42568
+ const lineStartSegmentIndex = end.segmentIndex;
42569
+ const lineStartGraphemeIndex = end.graphemeIndex;
42570
+ const width2 = prepared.simpleLineWalkFastPath ? stepPreparedSimpleLineGeometry(prepared, end, maxWidth) : stepPreparedChunkLineGeometry(prepared, end, chunkIndex, maxWidth);
42571
+ if (width2 === null)
42572
+ return null;
42573
+ return {
42574
+ startSegmentIndex: lineStartSegmentIndex,
42575
+ startGraphemeIndex: lineStartGraphemeIndex,
42576
+ endSegmentIndex: end.segmentIndex,
42577
+ endGraphemeIndex: end.graphemeIndex,
42578
+ width: width2
42579
+ };
42580
+ }
42581
+ __name(layoutNextLineRange, "layoutNextLineRange");
42582
+
42583
+ // ../../node_modules/.pnpm/@chenglou+pretext@0.0.5/node_modules/@chenglou/pretext/dist/layout.js
42584
+ var sharedGraphemeSegmenter2 = null;
42585
+ var sharedLineTextCaches = /* @__PURE__ */ new WeakMap();
42586
+ function getSharedGraphemeSegmenter2() {
42587
+ if (sharedGraphemeSegmenter2 === null) {
42588
+ sharedGraphemeSegmenter2 = new Intl.Segmenter(void 0, { granularity: "grapheme" });
42589
+ }
42590
+ return sharedGraphemeSegmenter2;
42591
+ }
42592
+ __name(getSharedGraphemeSegmenter2, "getSharedGraphemeSegmenter");
42593
+ function createEmptyPrepared(includeSegments) {
42594
+ if (includeSegments) {
42595
+ return {
42596
+ widths: [],
42597
+ lineEndFitAdvances: [],
42598
+ lineEndPaintAdvances: [],
42599
+ kinds: [],
42600
+ simpleLineWalkFastPath: true,
42601
+ segLevels: null,
42602
+ breakableFitAdvances: [],
42603
+ discretionaryHyphenWidth: 0,
42604
+ tabStopAdvance: 0,
42605
+ chunks: [],
42606
+ segments: []
42607
+ };
42608
+ }
42609
+ return {
42610
+ widths: [],
42611
+ lineEndFitAdvances: [],
42612
+ lineEndPaintAdvances: [],
42613
+ kinds: [],
42614
+ simpleLineWalkFastPath: true,
42615
+ segLevels: null,
42616
+ breakableFitAdvances: [],
42617
+ discretionaryHyphenWidth: 0,
42618
+ tabStopAdvance: 0,
42619
+ chunks: []
42620
+ };
42621
+ }
42622
+ __name(createEmptyPrepared, "createEmptyPrepared");
42623
+ function buildBaseCjkUnits(segText, engineProfile) {
42624
+ const units = [];
42625
+ let unitParts = [];
42626
+ let unitStart = 0;
42627
+ let unitContainsCJK = false;
42628
+ let unitEndsWithClosingQuote = false;
42629
+ let unitIsSingleKinsokuEnd = false;
42630
+ function pushUnit() {
42631
+ if (unitParts.length === 0)
42632
+ return;
42633
+ units.push({
42634
+ text: unitParts.length === 1 ? unitParts[0] : unitParts.join(""),
42635
+ start: unitStart
42636
+ });
42637
+ unitParts = [];
42638
+ unitContainsCJK = false;
42639
+ unitEndsWithClosingQuote = false;
42640
+ unitIsSingleKinsokuEnd = false;
42641
+ }
42642
+ __name(pushUnit, "pushUnit");
42643
+ function startUnit(grapheme, start, graphemeContainsCJK) {
42644
+ unitParts = [grapheme];
42645
+ unitStart = start;
42646
+ unitContainsCJK = graphemeContainsCJK;
42647
+ unitEndsWithClosingQuote = endsWithClosingQuote(grapheme);
42648
+ unitIsSingleKinsokuEnd = kinsokuEnd.has(grapheme);
42649
+ }
42650
+ __name(startUnit, "startUnit");
42651
+ function appendToUnit(grapheme, graphemeContainsCJK) {
42652
+ unitParts.push(grapheme);
42653
+ unitContainsCJK = unitContainsCJK || graphemeContainsCJK;
42654
+ const graphemeEndsWithClosingQuote = endsWithClosingQuote(grapheme);
42655
+ if (grapheme.length === 1 && leftStickyPunctuation.has(grapheme)) {
42656
+ unitEndsWithClosingQuote = unitEndsWithClosingQuote || graphemeEndsWithClosingQuote;
42657
+ } else {
42658
+ unitEndsWithClosingQuote = graphemeEndsWithClosingQuote;
42659
+ }
42660
+ unitIsSingleKinsokuEnd = false;
42661
+ }
42662
+ __name(appendToUnit, "appendToUnit");
42663
+ for (const gs of getSharedGraphemeSegmenter2().segment(segText)) {
42664
+ const grapheme = gs.segment;
42665
+ const graphemeContainsCJK = isCJK(grapheme);
42666
+ if (unitParts.length === 0) {
42667
+ startUnit(grapheme, gs.index, graphemeContainsCJK);
42668
+ continue;
42669
+ }
42670
+ if (unitIsSingleKinsokuEnd || kinsokuStart.has(grapheme) || leftStickyPunctuation.has(grapheme) || engineProfile.carryCJKAfterClosingQuote && graphemeContainsCJK && unitEndsWithClosingQuote) {
42671
+ appendToUnit(grapheme, graphemeContainsCJK);
42672
+ continue;
42673
+ }
42674
+ if (!unitContainsCJK && !graphemeContainsCJK) {
42675
+ appendToUnit(grapheme, graphemeContainsCJK);
42676
+ continue;
42677
+ }
42678
+ pushUnit();
42679
+ startUnit(grapheme, gs.index, graphemeContainsCJK);
42680
+ }
42681
+ pushUnit();
42682
+ return units;
42683
+ }
42684
+ __name(buildBaseCjkUnits, "buildBaseCjkUnits");
42685
+ function mergeKeepAllTextUnits(units) {
42686
+ if (units.length <= 1)
42687
+ return units;
42688
+ const merged = [];
42689
+ let currentTextParts = [units[0].text];
42690
+ let currentStart = units[0].start;
42691
+ let currentContainsCJK = isCJK(units[0].text);
42692
+ let currentCanContinue = canContinueKeepAllTextRun(units[0].text);
42693
+ function flushCurrent() {
42694
+ merged.push({
42695
+ text: currentTextParts.length === 1 ? currentTextParts[0] : currentTextParts.join(""),
42696
+ start: currentStart
42697
+ });
42698
+ }
42699
+ __name(flushCurrent, "flushCurrent");
42700
+ for (let i = 1; i < units.length; i++) {
42701
+ const next3 = units[i];
42702
+ const nextContainsCJK = isCJK(next3.text);
42703
+ const nextCanContinue = canContinueKeepAllTextRun(next3.text);
42704
+ if (currentContainsCJK && currentCanContinue) {
42705
+ currentTextParts.push(next3.text);
42706
+ currentContainsCJK = currentContainsCJK || nextContainsCJK;
42707
+ currentCanContinue = nextCanContinue;
42708
+ continue;
42709
+ }
42710
+ flushCurrent();
42711
+ currentTextParts = [next3.text];
42712
+ currentStart = next3.start;
42713
+ currentContainsCJK = nextContainsCJK;
42714
+ currentCanContinue = nextCanContinue;
42715
+ }
42716
+ flushCurrent();
42717
+ return merged;
42718
+ }
42719
+ __name(mergeKeepAllTextUnits, "mergeKeepAllTextUnits");
42720
+ function measureAnalysis(analysis, font, includeSegments, wordBreak) {
42721
+ const engineProfile = getEngineProfile();
42722
+ const { cache: cache3, emojiCorrection } = getFontMeasurementState(font, textMayContainEmoji(analysis.normalized));
42723
+ const discretionaryHyphenWidth = getCorrectedSegmentWidth("-", getSegmentMetrics("-", cache3), emojiCorrection);
42724
+ const spaceWidth = getCorrectedSegmentWidth(" ", getSegmentMetrics(" ", cache3), emojiCorrection);
42725
+ const tabStopAdvance = spaceWidth * 8;
42726
+ if (analysis.len === 0)
42727
+ return createEmptyPrepared(includeSegments);
42728
+ const widths = [];
42729
+ const lineEndFitAdvances = [];
42730
+ const lineEndPaintAdvances = [];
42731
+ const kinds = [];
42732
+ let simpleLineWalkFastPath = analysis.chunks.length <= 1;
42733
+ const segStarts = includeSegments ? [] : null;
42734
+ const breakableFitAdvances = [];
42735
+ const segments = includeSegments ? [] : null;
42736
+ const preparedStartByAnalysisIndex = Array.from({ length: analysis.len });
42737
+ function pushMeasuredSegment(text2, width2, lineEndFitAdvance, lineEndPaintAdvance, kind, start, breakableFitAdvance) {
42738
+ if (kind !== "text" && kind !== "space" && kind !== "zero-width-break") {
42739
+ simpleLineWalkFastPath = false;
42740
+ }
42741
+ widths.push(width2);
42742
+ lineEndFitAdvances.push(lineEndFitAdvance);
42743
+ lineEndPaintAdvances.push(lineEndPaintAdvance);
42744
+ kinds.push(kind);
42745
+ segStarts?.push(start);
42746
+ breakableFitAdvances.push(breakableFitAdvance);
42747
+ if (segments !== null)
42748
+ segments.push(text2);
42749
+ }
42750
+ __name(pushMeasuredSegment, "pushMeasuredSegment");
42751
+ function pushMeasuredTextSegment(text2, kind, start, wordLike, allowOverflowBreaks) {
42752
+ const textMetrics = getSegmentMetrics(text2, cache3);
42753
+ const width2 = getCorrectedSegmentWidth(text2, textMetrics, emojiCorrection);
42754
+ const lineEndFitAdvance = kind === "space" || kind === "preserved-space" || kind === "zero-width-break" ? 0 : width2;
42755
+ const lineEndPaintAdvance = kind === "space" || kind === "zero-width-break" ? 0 : width2;
42756
+ if (allowOverflowBreaks && wordLike && text2.length > 1) {
42757
+ let fitMode = "sum-graphemes";
42758
+ if (isNumericRunSegment(text2)) {
42759
+ fitMode = "pair-context";
42760
+ } else if (engineProfile.preferPrefixWidthsForBreakableRuns) {
42761
+ fitMode = "segment-prefixes";
42762
+ }
42763
+ const fitAdvances = getSegmentBreakableFitAdvances(text2, textMetrics, cache3, emojiCorrection, fitMode);
42764
+ pushMeasuredSegment(text2, width2, lineEndFitAdvance, lineEndPaintAdvance, kind, start, fitAdvances);
42765
+ return;
42766
+ }
42767
+ pushMeasuredSegment(text2, width2, lineEndFitAdvance, lineEndPaintAdvance, kind, start, null);
42768
+ }
42769
+ __name(pushMeasuredTextSegment, "pushMeasuredTextSegment");
42770
+ for (let mi = 0; mi < analysis.len; mi++) {
42771
+ preparedStartByAnalysisIndex[mi] = widths.length;
42772
+ const segText = analysis.texts[mi];
42773
+ const segWordLike = analysis.isWordLike[mi];
42774
+ const segKind = analysis.kinds[mi];
42775
+ const segStart = analysis.starts[mi];
42776
+ if (segKind === "soft-hyphen") {
42777
+ pushMeasuredSegment(segText, 0, discretionaryHyphenWidth, discretionaryHyphenWidth, segKind, segStart, null);
42778
+ continue;
42779
+ }
42780
+ if (segKind === "hard-break") {
42781
+ pushMeasuredSegment(segText, 0, 0, 0, segKind, segStart, null);
42782
+ continue;
42783
+ }
42784
+ if (segKind === "tab") {
42785
+ pushMeasuredSegment(segText, 0, 0, 0, segKind, segStart, null);
42786
+ continue;
42787
+ }
42788
+ const segMetrics = getSegmentMetrics(segText, cache3);
42789
+ if (segKind === "text" && segMetrics.containsCJK) {
42790
+ const baseUnits = buildBaseCjkUnits(segText, engineProfile);
42791
+ const measuredUnits = wordBreak === "keep-all" ? mergeKeepAllTextUnits(baseUnits) : baseUnits;
42792
+ for (let i = 0; i < measuredUnits.length; i++) {
42793
+ const unit = measuredUnits[i];
42794
+ pushMeasuredTextSegment(unit.text, "text", segStart + unit.start, segWordLike, wordBreak === "keep-all" || !isCJK(unit.text));
42795
+ }
42796
+ continue;
42797
+ }
42798
+ pushMeasuredTextSegment(segText, segKind, segStart, segWordLike, true);
42799
+ }
42800
+ const chunks = mapAnalysisChunksToPreparedChunks(analysis.chunks, preparedStartByAnalysisIndex, widths.length);
42801
+ const segLevels = segStarts === null ? null : computeSegmentLevels(analysis.normalized, segStarts);
42802
+ if (segments !== null) {
42803
+ return {
42804
+ widths,
42805
+ lineEndFitAdvances,
42806
+ lineEndPaintAdvances,
42807
+ kinds,
42808
+ simpleLineWalkFastPath,
42809
+ segLevels,
42810
+ breakableFitAdvances,
42811
+ discretionaryHyphenWidth,
42812
+ tabStopAdvance,
42813
+ chunks,
42814
+ segments
42815
+ };
42816
+ }
42817
+ return {
42818
+ widths,
42819
+ lineEndFitAdvances,
42820
+ lineEndPaintAdvances,
42821
+ kinds,
42822
+ simpleLineWalkFastPath,
42823
+ segLevels,
42824
+ breakableFitAdvances,
42825
+ discretionaryHyphenWidth,
42826
+ tabStopAdvance,
42827
+ chunks
42828
+ };
42829
+ }
42830
+ __name(measureAnalysis, "measureAnalysis");
42831
+ function mapAnalysisChunksToPreparedChunks(chunks, preparedStartByAnalysisIndex, preparedEndSegmentIndex) {
42832
+ const preparedChunks = [];
42833
+ for (let i = 0; i < chunks.length; i++) {
42834
+ const chunk = chunks[i];
42835
+ const startSegmentIndex = chunk.startSegmentIndex < preparedStartByAnalysisIndex.length ? preparedStartByAnalysisIndex[chunk.startSegmentIndex] : preparedEndSegmentIndex;
42836
+ const endSegmentIndex = chunk.endSegmentIndex < preparedStartByAnalysisIndex.length ? preparedStartByAnalysisIndex[chunk.endSegmentIndex] : preparedEndSegmentIndex;
42837
+ const consumedEndSegmentIndex = chunk.consumedEndSegmentIndex < preparedStartByAnalysisIndex.length ? preparedStartByAnalysisIndex[chunk.consumedEndSegmentIndex] : preparedEndSegmentIndex;
42838
+ preparedChunks.push({
42839
+ startSegmentIndex,
42840
+ endSegmentIndex,
42841
+ consumedEndSegmentIndex
42842
+ });
42843
+ }
42844
+ return preparedChunks;
42845
+ }
42846
+ __name(mapAnalysisChunksToPreparedChunks, "mapAnalysisChunksToPreparedChunks");
42847
+ function prepareInternal(text2, font, includeSegments, options2) {
42848
+ const wordBreak = options2?.wordBreak ?? "normal";
42849
+ const analysis = analyzeText(text2, getEngineProfile(), options2?.whiteSpace, wordBreak);
42850
+ return measureAnalysis(analysis, font, includeSegments, wordBreak);
42851
+ }
42852
+ __name(prepareInternal, "prepareInternal");
42853
+ function prepareWithSegments(text2, font, options2) {
42854
+ return prepareInternal(text2, font, true, options2);
42855
+ }
42856
+ __name(prepareWithSegments, "prepareWithSegments");
42857
+ function getInternalPrepared(prepared) {
42858
+ return prepared;
42859
+ }
42860
+ __name(getInternalPrepared, "getInternalPrepared");
42861
+ function getSegmentGraphemes(segmentIndex, segments, cache3) {
42862
+ let graphemes = cache3.get(segmentIndex);
42863
+ if (graphemes !== void 0)
42864
+ return graphemes;
42865
+ graphemes = [];
42866
+ const graphemeSegmenter = getSharedGraphemeSegmenter2();
42867
+ for (const gs of graphemeSegmenter.segment(segments[segmentIndex])) {
42868
+ graphemes.push(gs.segment);
42869
+ }
42870
+ cache3.set(segmentIndex, graphemes);
42871
+ return graphemes;
42872
+ }
42873
+ __name(getSegmentGraphemes, "getSegmentGraphemes");
42874
+ function getLineTextCache(prepared) {
42875
+ let cache3 = sharedLineTextCaches.get(prepared);
42876
+ if (cache3 !== void 0)
42877
+ return cache3;
42878
+ cache3 = /* @__PURE__ */ new Map();
42879
+ sharedLineTextCaches.set(prepared, cache3);
42880
+ return cache3;
42881
+ }
42882
+ __name(getLineTextCache, "getLineTextCache");
42883
+ function lineHasDiscretionaryHyphen(kinds, startSegmentIndex, startGraphemeIndex, endSegmentIndex) {
42884
+ return endSegmentIndex > 0 && kinds[endSegmentIndex - 1] === "soft-hyphen" && !(startSegmentIndex === endSegmentIndex && startGraphemeIndex > 0);
42885
+ }
42886
+ __name(lineHasDiscretionaryHyphen, "lineHasDiscretionaryHyphen");
42887
+ function buildLineTextFromRange(segments, kinds, cache3, startSegmentIndex, startGraphemeIndex, endSegmentIndex, endGraphemeIndex) {
42888
+ let text2 = "";
42889
+ const endsWithDiscretionaryHyphen = lineHasDiscretionaryHyphen(kinds, startSegmentIndex, startGraphemeIndex, endSegmentIndex);
42890
+ for (let i = startSegmentIndex; i < endSegmentIndex; i++) {
42891
+ if (kinds[i] === "soft-hyphen" || kinds[i] === "hard-break")
42892
+ continue;
42893
+ if (i === startSegmentIndex && startGraphemeIndex > 0) {
42894
+ text2 += getSegmentGraphemes(i, segments, cache3).slice(startGraphemeIndex).join("");
42895
+ } else {
42896
+ text2 += segments[i];
42897
+ }
42898
+ }
42899
+ if (endGraphemeIndex > 0) {
42900
+ if (endsWithDiscretionaryHyphen)
42901
+ text2 += "-";
42902
+ text2 += getSegmentGraphemes(endSegmentIndex, segments, cache3).slice(startSegmentIndex === endSegmentIndex ? startGraphemeIndex : 0, endGraphemeIndex).join("");
42903
+ } else if (endsWithDiscretionaryHyphen) {
42904
+ text2 += "-";
42905
+ }
42906
+ return text2;
42907
+ }
42908
+ __name(buildLineTextFromRange, "buildLineTextFromRange");
42909
+ function createLayoutLine(prepared, cache3, width2, startSegmentIndex, startGraphemeIndex, endSegmentIndex, endGraphemeIndex) {
42910
+ return {
42911
+ text: buildLineTextFromRange(prepared.segments, prepared.kinds, cache3, startSegmentIndex, startGraphemeIndex, endSegmentIndex, endGraphemeIndex),
42912
+ width: width2,
42913
+ start: {
42914
+ segmentIndex: startSegmentIndex,
42915
+ graphemeIndex: startGraphemeIndex
42916
+ },
42917
+ end: {
42918
+ segmentIndex: endSegmentIndex,
42919
+ graphemeIndex: endGraphemeIndex
42920
+ }
42921
+ };
42922
+ }
42923
+ __name(createLayoutLine, "createLayoutLine");
42924
+ function toLayoutLineRange(line2) {
42925
+ return {
42926
+ width: line2.width,
42927
+ start: {
42928
+ segmentIndex: line2.startSegmentIndex,
42929
+ graphemeIndex: line2.startGraphemeIndex
42930
+ },
42931
+ end: {
42932
+ segmentIndex: line2.endSegmentIndex,
42933
+ graphemeIndex: line2.endGraphemeIndex
42934
+ }
42935
+ };
42936
+ }
42937
+ __name(toLayoutLineRange, "toLayoutLineRange");
42938
+ function materializeLineRange(prepared, line2) {
42939
+ return createLayoutLine(prepared, getLineTextCache(prepared), line2.width, line2.start.segmentIndex, line2.start.graphemeIndex, line2.end.segmentIndex, line2.end.graphemeIndex);
42940
+ }
42941
+ __name(materializeLineRange, "materializeLineRange");
42942
+ function walkLineRanges(prepared, maxWidth, onLine) {
42943
+ if (prepared.widths.length === 0)
42944
+ return 0;
42945
+ return walkPreparedLines(getInternalPrepared(prepared), maxWidth, (line2) => {
42946
+ onLine(toLayoutLineRange(line2));
42947
+ });
42948
+ }
42949
+ __name(walkLineRanges, "walkLineRanges");
42950
+ function measureNaturalWidth(prepared) {
42951
+ let maxWidth = 0;
42952
+ walkLineRanges(prepared, Number.POSITIVE_INFINITY, (line2) => {
42953
+ if (line2.width > maxWidth)
42954
+ maxWidth = line2.width;
42955
+ });
42956
+ return maxWidth;
42957
+ }
42958
+ __name(measureNaturalWidth, "measureNaturalWidth");
42959
+
42960
+ // ../../node_modules/.pnpm/@chenglou+pretext@0.0.5/node_modules/@chenglou/pretext/dist/rich-inline.js
42961
+ var COLLAPSIBLE_BOUNDARY_RE = /[ \t\n\f\r]+/;
42962
+ var LEADING_COLLAPSIBLE_BOUNDARY_RE = /^[ \t\n\f\r]+/;
42963
+ var TRAILING_COLLAPSIBLE_BOUNDARY_RE = /[ \t\n\f\r]+$/;
42964
+ var EMPTY_LAYOUT_CURSOR = { segmentIndex: 0, graphemeIndex: 0 };
42965
+ var RICH_INLINE_START_CURSOR = {
42966
+ itemIndex: 0,
42967
+ segmentIndex: 0,
42968
+ graphemeIndex: 0
42969
+ };
42970
+ function getInternalPreparedRichInline(prepared) {
42971
+ return prepared;
42972
+ }
42973
+ __name(getInternalPreparedRichInline, "getInternalPreparedRichInline");
42974
+ function cloneCursor(cursor) {
42975
+ return {
42976
+ segmentIndex: cursor.segmentIndex,
42977
+ graphemeIndex: cursor.graphemeIndex
42978
+ };
42979
+ }
42980
+ __name(cloneCursor, "cloneCursor");
42981
+ function isLineStartCursor(cursor) {
42982
+ return cursor.segmentIndex === 0 && cursor.graphemeIndex === 0;
42983
+ }
42984
+ __name(isLineStartCursor, "isLineStartCursor");
42985
+ function getCollapsedSpaceWidth(font, cache3) {
42986
+ const cached = cache3.get(font);
42987
+ if (cached !== void 0)
42988
+ return cached;
42989
+ const joinedWidth = measureNaturalWidth(prepareWithSegments("A A", font));
42990
+ const compactWidth = measureNaturalWidth(prepareWithSegments("AA", font));
42991
+ const collapsedWidth = Math.max(0, joinedWidth - compactWidth);
42992
+ cache3.set(font, collapsedWidth);
42993
+ return collapsedWidth;
42994
+ }
42995
+ __name(getCollapsedSpaceWidth, "getCollapsedSpaceWidth");
42996
+ function prepareWholeItemLine(prepared) {
42997
+ const line2 = layoutNextLineRange(prepared, EMPTY_LAYOUT_CURSOR, Number.POSITIVE_INFINITY);
42998
+ if (line2 === null)
42999
+ return null;
43000
+ return {
43001
+ endGraphemeIndex: line2.endGraphemeIndex,
43002
+ endSegmentIndex: line2.endSegmentIndex,
43003
+ width: line2.width
43004
+ };
43005
+ }
43006
+ __name(prepareWholeItemLine, "prepareWholeItemLine");
43007
+ function endsInsideFirstSegment(segmentIndex, graphemeIndex) {
43008
+ return segmentIndex === 0 && graphemeIndex > 0;
43009
+ }
43010
+ __name(endsInsideFirstSegment, "endsInsideFirstSegment");
43011
+ function prepareRichInline(items) {
43012
+ const preparedItems = [];
43013
+ const itemsBySourceItemIndex = Array.from({ length: items.length });
43014
+ const collapsedSpaceWidthCache = /* @__PURE__ */ new Map();
43015
+ let pendingGapWidth = 0;
43016
+ for (let index = 0; index < items.length; index++) {
43017
+ const item = items[index];
43018
+ const hasLeadingWhitespace = LEADING_COLLAPSIBLE_BOUNDARY_RE.test(item.text);
43019
+ const hasTrailingWhitespace = TRAILING_COLLAPSIBLE_BOUNDARY_RE.test(item.text);
43020
+ const trimmedText = item.text.replace(LEADING_COLLAPSIBLE_BOUNDARY_RE, "").replace(TRAILING_COLLAPSIBLE_BOUNDARY_RE, "");
43021
+ if (trimmedText.length === 0) {
43022
+ if (COLLAPSIBLE_BOUNDARY_RE.test(item.text) && pendingGapWidth === 0) {
43023
+ pendingGapWidth = getCollapsedSpaceWidth(item.font, collapsedSpaceWidthCache);
43024
+ }
43025
+ continue;
43026
+ }
43027
+ const gapBefore = pendingGapWidth > 0 ? pendingGapWidth : hasLeadingWhitespace ? getCollapsedSpaceWidth(item.font, collapsedSpaceWidthCache) : 0;
43028
+ const prepared = prepareWithSegments(trimmedText, item.font);
43029
+ const wholeLine = prepareWholeItemLine(prepared);
43030
+ if (wholeLine === null) {
43031
+ pendingGapWidth = hasTrailingWhitespace ? getCollapsedSpaceWidth(item.font, collapsedSpaceWidthCache) : 0;
43032
+ continue;
43033
+ }
43034
+ const preparedItem = {
43035
+ break: item.break ?? "normal",
43036
+ endGraphemeIndex: wholeLine.endGraphemeIndex,
43037
+ endSegmentIndex: wholeLine.endSegmentIndex,
43038
+ extraWidth: item.extraWidth ?? 0,
43039
+ gapBefore,
43040
+ naturalWidth: wholeLine.width,
43041
+ prepared,
43042
+ sourceItemIndex: index
43043
+ };
43044
+ preparedItems.push(preparedItem);
43045
+ itemsBySourceItemIndex[index] = preparedItem;
43046
+ pendingGapWidth = hasTrailingWhitespace ? getCollapsedSpaceWidth(item.font, collapsedSpaceWidthCache) : 0;
43047
+ }
43048
+ return {
43049
+ items: preparedItems,
43050
+ itemsBySourceItemIndex
43051
+ };
43052
+ }
43053
+ __name(prepareRichInline, "prepareRichInline");
43054
+ function stepRichInlineLine(flow, maxWidth, cursor, collectFragment) {
43055
+ if (flow.items.length === 0 || cursor.itemIndex >= flow.items.length)
43056
+ return null;
43057
+ const safeWidth = Math.max(1, maxWidth);
43058
+ let lineWidth = 0;
43059
+ let remainingWidth = safeWidth;
43060
+ let itemIndex = cursor.itemIndex;
43061
+ const textCursor = {
43062
+ segmentIndex: cursor.segmentIndex,
43063
+ graphemeIndex: cursor.graphemeIndex
43064
+ };
43065
+ lineLoop: while (itemIndex < flow.items.length) {
43066
+ const item = flow.items[itemIndex];
43067
+ if (!isLineStartCursor(textCursor) && textCursor.segmentIndex === item.endSegmentIndex && textCursor.graphemeIndex === item.endGraphemeIndex) {
43068
+ itemIndex++;
43069
+ textCursor.segmentIndex = 0;
43070
+ textCursor.graphemeIndex = 0;
43071
+ continue;
43072
+ }
43073
+ const gapBefore = lineWidth === 0 ? 0 : item.gapBefore;
43074
+ const atItemStart = isLineStartCursor(textCursor);
43075
+ if (item.break === "never") {
43076
+ if (!atItemStart) {
43077
+ itemIndex++;
43078
+ textCursor.segmentIndex = 0;
43079
+ textCursor.graphemeIndex = 0;
43080
+ continue;
43081
+ }
43082
+ const occupiedWidth = item.naturalWidth + item.extraWidth;
43083
+ const totalWidth = gapBefore + occupiedWidth;
43084
+ if (lineWidth > 0 && totalWidth > remainingWidth)
43085
+ break lineLoop;
43086
+ collectFragment?.(item, gapBefore, occupiedWidth, cloneCursor(EMPTY_LAYOUT_CURSOR), {
43087
+ segmentIndex: item.endSegmentIndex,
43088
+ graphemeIndex: item.endGraphemeIndex
43089
+ });
43090
+ lineWidth += totalWidth;
43091
+ remainingWidth = Math.max(0, safeWidth - lineWidth);
43092
+ itemIndex++;
43093
+ textCursor.segmentIndex = 0;
43094
+ textCursor.graphemeIndex = 0;
43095
+ continue;
43096
+ }
43097
+ const reservedWidth = gapBefore + item.extraWidth;
43098
+ if (lineWidth > 0 && reservedWidth >= remainingWidth)
43099
+ break lineLoop;
43100
+ if (atItemStart) {
43101
+ const totalWidth = reservedWidth + item.naturalWidth;
43102
+ if (totalWidth <= remainingWidth) {
43103
+ collectFragment?.(item, gapBefore, item.naturalWidth + item.extraWidth, cloneCursor(EMPTY_LAYOUT_CURSOR), {
43104
+ segmentIndex: item.endSegmentIndex,
43105
+ graphemeIndex: item.endGraphemeIndex
43106
+ });
43107
+ lineWidth += totalWidth;
43108
+ remainingWidth = Math.max(0, safeWidth - lineWidth);
43109
+ itemIndex++;
43110
+ textCursor.segmentIndex = 0;
43111
+ textCursor.graphemeIndex = 0;
43112
+ continue;
43113
+ }
43114
+ }
43115
+ const availableWidth = Math.max(1, remainingWidth - reservedWidth);
43116
+ const line2 = layoutNextLineRange(item.prepared, textCursor, availableWidth);
43117
+ if (line2 === null) {
43118
+ itemIndex++;
43119
+ textCursor.segmentIndex = 0;
43120
+ textCursor.graphemeIndex = 0;
43121
+ continue;
43122
+ }
43123
+ if (textCursor.segmentIndex === line2.endSegmentIndex && textCursor.graphemeIndex === line2.endGraphemeIndex) {
43124
+ itemIndex++;
43125
+ textCursor.segmentIndex = 0;
43126
+ textCursor.graphemeIndex = 0;
43127
+ continue;
43128
+ }
43129
+ if (lineWidth > 0 && atItemStart && gapBefore > 0 && endsInsideFirstSegment(line2.endSegmentIndex, line2.endGraphemeIndex)) {
43130
+ const freshLine = layoutNextLineRange(item.prepared, EMPTY_LAYOUT_CURSOR, Math.max(1, safeWidth - item.extraWidth));
43131
+ if (freshLine !== null && (freshLine.endSegmentIndex > line2.endSegmentIndex || freshLine.endSegmentIndex === line2.endSegmentIndex && freshLine.endGraphemeIndex > line2.endGraphemeIndex)) {
43132
+ break lineLoop;
43133
+ }
43134
+ }
43135
+ collectFragment?.(item, gapBefore, line2.width + item.extraWidth, cloneCursor(textCursor), {
43136
+ segmentIndex: line2.endSegmentIndex,
43137
+ graphemeIndex: line2.endGraphemeIndex
43138
+ });
43139
+ lineWidth += gapBefore + line2.width + item.extraWidth;
43140
+ remainingWidth = Math.max(0, safeWidth - lineWidth);
43141
+ if (line2.endSegmentIndex === item.endSegmentIndex && line2.endGraphemeIndex === item.endGraphemeIndex) {
43142
+ itemIndex++;
43143
+ textCursor.segmentIndex = 0;
43144
+ textCursor.graphemeIndex = 0;
43145
+ continue;
43146
+ }
43147
+ textCursor.segmentIndex = line2.endSegmentIndex;
43148
+ textCursor.graphemeIndex = line2.endGraphemeIndex;
43149
+ break;
43150
+ }
43151
+ if (lineWidth === 0)
43152
+ return null;
43153
+ cursor.itemIndex = itemIndex;
43154
+ cursor.segmentIndex = textCursor.segmentIndex;
43155
+ cursor.graphemeIndex = textCursor.graphemeIndex;
43156
+ return lineWidth;
43157
+ }
43158
+ __name(stepRichInlineLine, "stepRichInlineLine");
43159
+ function layoutNextRichInlineLineRange(prepared, maxWidth, start = RICH_INLINE_START_CURSOR) {
43160
+ const flow = getInternalPreparedRichInline(prepared);
43161
+ const end = {
43162
+ itemIndex: start.itemIndex,
43163
+ segmentIndex: start.segmentIndex,
43164
+ graphemeIndex: start.graphemeIndex
43165
+ };
43166
+ const fragments = [];
43167
+ const width2 = stepRichInlineLine(flow, maxWidth, end, (item, gapBefore, occupiedWidth, fragmentStart, fragmentEnd) => {
43168
+ fragments.push({
43169
+ itemIndex: item.sourceItemIndex,
43170
+ gapBefore,
43171
+ occupiedWidth,
43172
+ start: fragmentStart,
43173
+ end: fragmentEnd
43174
+ });
43175
+ });
43176
+ if (width2 === null)
43177
+ return null;
43178
+ return {
43179
+ fragments,
43180
+ width: width2,
43181
+ end
43182
+ };
43183
+ }
43184
+ __name(layoutNextRichInlineLineRange, "layoutNextRichInlineLineRange");
43185
+ function materializeFragmentText(item, fragment) {
43186
+ const line2 = materializeLineRange(item.prepared, {
43187
+ width: fragment.occupiedWidth - item.extraWidth,
43188
+ start: fragment.start,
43189
+ end: fragment.end
43190
+ });
43191
+ return line2.text;
43192
+ }
43193
+ __name(materializeFragmentText, "materializeFragmentText");
43194
+ function materializeRichInlineLineRange(prepared, line2) {
43195
+ const flow = getInternalPreparedRichInline(prepared);
43196
+ return {
43197
+ fragments: line2.fragments.map((fragment) => {
43198
+ const item = flow.itemsBySourceItemIndex[fragment.itemIndex];
43199
+ if (item === void 0)
43200
+ throw new Error("Missing rich-text inline item for fragment");
43201
+ return {
43202
+ ...fragment,
43203
+ text: materializeFragmentText(item, fragment)
43204
+ };
43205
+ }),
43206
+ width: line2.width,
43207
+ end: line2.end
43208
+ };
43209
+ }
43210
+ __name(materializeRichInlineLineRange, "materializeRichInlineLineRange");
43211
+
39461
43212
  // ../../node_modules/.pnpm/html-void-elements@3.0.0/node_modules/html-void-elements/index.js
39462
43213
  var htmlVoidElements = [
39463
43214
  "area",
@@ -42270,99 +46021,6 @@ function closedDialog(node2) {
42270
46021
  }
42271
46022
  __name(closedDialog, "closedDialog");
42272
46023
 
42273
- // src/splitText.ts
42274
- function splitTextToChars(text2) {
42275
- if (Intl.Segmenter) {
42276
- return [...new Intl.Segmenter().segment(text2)].map((s) => s.segment);
42277
- }
42278
- return [...text2];
42279
- }
42280
- __name(splitTextToChars, "splitTextToChars");
42281
- function splitWordToFitWidth(checkFit, word) {
42282
- const characters3 = splitTextToChars(word.content);
42283
- return splitWordToFitWidthRecursion(checkFit, [], characters3, word.type);
42284
- }
42285
- __name(splitWordToFitWidth, "splitWordToFitWidth");
42286
- function splitWordToFitWidthRecursion(checkFit, usedChars, remainingChars, type) {
42287
- if (remainingChars.length === 0) {
42288
- return [
42289
- { content: usedChars.join(""), type },
42290
- { content: "", type }
42291
- ];
42292
- }
42293
- const [nextChar, ...rest] = remainingChars;
42294
- const newWord = [...usedChars, nextChar];
42295
- if (checkFit({
42296
- type: "text_line",
42297
- words: [{ content: newWord.join(""), type }]
42298
- })) {
42299
- return splitWordToFitWidthRecursion(checkFit, newWord, rest, type);
42300
- }
42301
- if (usedChars.length === 0 && nextChar) {
42302
- usedChars.push(nextChar);
42303
- remainingChars.shift();
42304
- }
42305
- return [
42306
- { content: usedChars.join(""), type },
42307
- { content: remainingChars.join(""), type }
42308
- ];
42309
- }
42310
- __name(splitWordToFitWidthRecursion, "splitWordToFitWidthRecursion");
42311
- function splitLineToFitWidth(line2, checkFit) {
42312
- if (line2.words.some(({ content }) => content.includes("\n"))) {
42313
- throw new Error("splitLineToFitWidth does not support newlines in the line");
42314
- }
42315
- return splitLineToFitWidthRecursion(line2, checkFit);
42316
- }
42317
- __name(splitLineToFitWidth, "splitLineToFitWidth");
42318
- function splitLineToFitWidthRecursion(line2, checkFit, lines = [], newLine = []) {
42319
- let words = line2.words;
42320
- if (words.length === 0) {
42321
- if (newLine.length > 0) {
42322
- lines.push({
42323
- type: "text_line",
42324
- words: newLine
42325
- });
42326
- }
42327
- return lines.length > 0 ? lines : [];
42328
- }
42329
- let joiner = "";
42330
- if (words[0].content === " ") {
42331
- joiner = " ";
42332
- words.shift();
42333
- }
42334
- const nextWord = words.shift() ?? { content: " ", type: "normal" };
42335
- const lineWithNextWord = {
42336
- type: "text_line",
42337
- words: [...newLine]
42338
- };
42339
- if (joiner !== "") {
42340
- lineWithNextWord.words.push({ content: joiner, type: "normal" });
42341
- }
42342
- lineWithNextWord.words.push(nextWord);
42343
- if (checkFit(lineWithNextWord)) {
42344
- return splitLineToFitWidthRecursion(line2, checkFit, lines, lineWithNextWord.words);
42345
- }
42346
- if (newLine.length > 0) {
42347
- lines.push({
42348
- type: "text_line",
42349
- words: [...newLine]
42350
- });
42351
- line2.words.unshift(nextWord);
42352
- } else if (nextWord.content) {
42353
- const [word, rest] = splitWordToFitWidth(checkFit, nextWord);
42354
- lines.push({
42355
- type: "text_line",
42356
- words: [word]
42357
- });
42358
- if (rest.content) {
42359
- line2.words.unshift(rest);
42360
- }
42361
- }
42362
- return splitLineToFitWidthRecursion(line2, checkFit, lines);
42363
- }
42364
- __name(splitLineToFitWidthRecursion, "splitLineToFitWidthRecursion");
42365
-
42366
46024
  // src/utils.ts
42367
46025
  var decodeEntities = /* @__PURE__ */ __name(function(text2) {
42368
46026
  return text2.replace(/fl°°/g, "&#").replace(/fl°/g, "&").replace(/¶ß/g, ";");
@@ -42564,19 +46222,130 @@ var walkTree = /* @__PURE__ */ __name((tree, callback, key2 = "children", ...arg
42564
46222
  }, "walkTree");
42565
46223
 
42566
46224
  // src/text.ts
46225
+ var DEFAULT_FONT_FAMILY = '"trebuchet ms", verdana, arial, sans-serif';
46226
+ var DEFAULT_LINE_HEIGHT_EM = 1.1;
46227
+ function getWordFontStyle(wordType) {
46228
+ return {
46229
+ fontStyle: wordType === "emphasis" ? "italic" : "normal",
46230
+ fontWeight: wordType === "strong" ? "bold" : "normal"
46231
+ };
46232
+ }
46233
+ __name(getWordFontStyle, "getWordFontStyle");
46234
+ function createCanvasFont(word, fontSize, fontFamily) {
46235
+ const { fontStyle, fontWeight } = getWordFontStyle(word.type);
46236
+ return [fontStyle, fontWeight, `${fontSize}px`, fontFamily].join(" ");
46237
+ }
46238
+ __name(createCanvasFont, "createCanvasFont");
46239
+ function splitTextToGraphemes(text2) {
46240
+ if (Intl.Segmenter) {
46241
+ return [...new Intl.Segmenter(void 0, { granularity: "grapheme" }).segment(text2)].map(
46242
+ (segment) => segment.segment
46243
+ );
46244
+ }
46245
+ return [...text2];
46246
+ }
46247
+ __name(splitTextToGraphemes, "splitTextToGraphemes");
46248
+ function measureWordWidth(word, fontSize, fontFamily, content = word.content) {
46249
+ return measureNaturalWidth(prepareWithSegments(content, createCanvasFont(word, fontSize, fontFamily)));
46250
+ }
46251
+ __name(measureWordWidth, "measureWordWidth");
46252
+ function splitOversizedWordWithPretext(word, width2, fontSize, fontFamily) {
46253
+ const graphemes = splitTextToGraphemes(word.content);
46254
+ if (graphemes.length === 0) return [];
46255
+ const lines = [];
46256
+ let current = "";
46257
+ for (const grapheme of graphemes) {
46258
+ const candidate = `${current}${grapheme}`;
46259
+ const candidateWidth = measureWordWidth(word, fontSize, fontFamily, candidate);
46260
+ if (candidateWidth <= width2 || current.length === 0) {
46261
+ current = candidate;
46262
+ continue;
46263
+ }
46264
+ lines.push({
46265
+ fragments: [{
46266
+ gapBefore: 0,
46267
+ text: current,
46268
+ word
46269
+ }],
46270
+ width: measureWordWidth(word, fontSize, fontFamily, current)
46271
+ });
46272
+ current = grapheme;
46273
+ }
46274
+ if (current.length > 0) {
46275
+ lines.push({
46276
+ fragments: [{
46277
+ gapBefore: 0,
46278
+ text: current,
46279
+ word
46280
+ }],
46281
+ width: measureWordWidth(word, fontSize, fontFamily, current)
46282
+ });
46283
+ }
46284
+ return lines;
46285
+ }
46286
+ __name(splitOversizedWordWithPretext, "splitOversizedWordWithPretext");
46287
+ function createRichInlineItems(line2, fontSize, fontFamily) {
46288
+ return line2.words.map((word, index) => ({
46289
+ break: "never",
46290
+ font: createCanvasFont(word, fontSize, fontFamily),
46291
+ text: index === 0 ? word.content : ` ${word.content}`
46292
+ }));
46293
+ }
46294
+ __name(createRichInlineItems, "createRichInlineItems");
46295
+ function layoutTextLineWithPretext(line2, width2, fontSize, fontFamily) {
46296
+ const items = createRichInlineItems(line2, fontSize, fontFamily);
46297
+ if (items.length === 0) return [];
46298
+ const prepared = prepareRichInline(items);
46299
+ const wrappedLines = [];
46300
+ let cursor;
46301
+ while (true) {
46302
+ const lineRange = layoutNextRichInlineLineRange(prepared, width2, cursor);
46303
+ if (!lineRange) break;
46304
+ const materializedLine = materializeRichInlineLineRange(prepared, lineRange);
46305
+ const nextLine = {
46306
+ fragments: materializedLine.fragments.map((fragment) => ({
46307
+ gapBefore: fragment.gapBefore,
46308
+ text: fragment.text,
46309
+ word: line2.words[fragment.itemIndex]
46310
+ })),
46311
+ width: materializedLine.width
46312
+ };
46313
+ if (nextLine.width > width2 && nextLine.fragments.length === 1) {
46314
+ wrappedLines.push(
46315
+ ...splitOversizedWordWithPretext(
46316
+ nextLine.fragments[0].word,
46317
+ width2,
46318
+ fontSize,
46319
+ fontFamily
46320
+ )
46321
+ );
46322
+ } else {
46323
+ wrappedLines.push(nextLine);
46324
+ }
46325
+ cursor = lineRange.end;
46326
+ }
46327
+ return wrappedLines;
46328
+ }
46329
+ __name(layoutTextLineWithPretext, "layoutTextLineWithPretext");
46330
+ function measureTextLineWithPretext(line2, width2, fontSize, fontFamily = DEFAULT_FONT_FAMILY) {
46331
+ const lines = layoutTextLineWithPretext(line2, width2, fontSize, fontFamily);
46332
+ const measuredWidth = lines.reduce((currentWidth, wrappedLine) => {
46333
+ return Math.max(currentWidth, wrappedLine.width);
46334
+ }, 0);
46335
+ return {
46336
+ height: Math.max(
46337
+ DEFAULT_LINE_HEIGHT_EM * fontSize,
46338
+ lines.length * DEFAULT_LINE_HEIGHT_EM * fontSize
46339
+ ),
46340
+ lines,
46341
+ width: measuredWidth
46342
+ };
46343
+ }
46344
+ __name(measureTextLineWithPretext, "measureTextLineWithPretext");
42567
46345
  function createTspan(textElement, lineIndex, lineHeight) {
42568
46346
  return textElement.append("tspan").attr("class", "text-outer-tspan").attr("x", 0).attr("y", lineIndex * lineHeight - 0.1 + "em").attr("dy", lineHeight + "em");
42569
46347
  }
42570
46348
  __name(createTspan, "createTspan");
42571
- function computeWidthOfText(parentNode, lineHeight, line2) {
42572
- const testElement = parentNode.append("text");
42573
- const testSpan = createTspan(testElement, 1, lineHeight);
42574
- updateTextContentAndStyles(testSpan, line2.words);
42575
- const textLength = testSpan.node().getComputedTextLength();
42576
- testElement.remove();
42577
- return textLength;
42578
- }
42579
- __name(computeWidthOfText, "computeWidthOfText");
42580
46349
  function updateTextContentAndStyles(tspan, wrappedLine) {
42581
46350
  tspan.text("");
42582
46351
  wrappedLine.forEach((word, index) => {
@@ -42590,6 +46359,17 @@ function updateTextContentAndStyles(tspan, wrappedLine) {
42590
46359
  });
42591
46360
  }
42592
46361
  __name(updateTextContentAndStyles, "updateTextContentAndStyles");
46362
+ function updateTextContentAndStylesFromFragments(tspan, wrappedLine) {
46363
+ tspan.text("");
46364
+ wrappedLine.forEach((fragment) => {
46365
+ const { fontStyle, fontWeight } = getWordFontStyle(fragment.word.type);
46366
+ const innerTspan = tspan.append("tspan").attr("font-style", fontStyle).attr("class", "text-inner-tspan").attr("font-weight", fontWeight);
46367
+ if (fragment.word.type === "delete") innerTspan.attr("text-decoration", "line-through");
46368
+ if (fragment.gapBefore > 0) innerTspan.attr("dx", fragment.gapBefore);
46369
+ innerTspan.text(fragment.text);
46370
+ });
46371
+ }
46372
+ __name(updateTextContentAndStylesFromFragments, "updateTextContentAndStylesFromFragments");
42593
46373
  function addImageObject(element5, node2, width2, y2) {
42594
46374
  const img = element5.append("image");
42595
46375
  img.attr("href", node2.src);
@@ -42607,6 +46387,11 @@ function addImageObject(element5, node2, width2, y2) {
42607
46387
  let desc = img.append("desc");
42608
46388
  desc.text(node2.alt);
42609
46389
  }
46390
+ return {
46391
+ h: node2.height,
46392
+ node: img.node(),
46393
+ w: node2.width
46394
+ };
42610
46395
  }
42611
46396
  __name(addImageObject, "addImageObject");
42612
46397
  function addHtmlSpan(element5, node2, width2, classes2, y2, addBackground = false) {
@@ -42772,30 +46557,20 @@ var hastToLines = /* @__PURE__ */ __name((contents) => {
42772
46557
  });
42773
46558
  return lines;
42774
46559
  }, "hastToLines");
42775
- function createFormattedText(width2, g, structuredBlocks, addBackground = false, txtColor = "currentColor") {
46560
+ function createFormattedText(width2, g, structuredBlocks, addBackground = false, txtColor = "currentColor", fontSize = 16, fontFamily = DEFAULT_FONT_FAMILY) {
42776
46561
  const labelGroup = g.append("g");
42777
- const lineHeight = 1.1;
46562
+ const lineHeight = DEFAULT_LINE_HEIGHT_EM;
42778
46563
  const bkg = labelGroup.insert("rect").attr("class", "background");
42779
- let textElement = void 0;
42780
- let y2 = -10;
42781
- let maxWidth = width2;
42782
- let i = 0;
46564
+ let y2 = 0;
46565
+ let maxWidth = 0;
46566
+ let usedPretext = true;
42783
46567
  for (const line2 of structuredBlocks) {
42784
46568
  if (line2.type === "image") {
42785
- if (textElement) {
42786
- y2 += 1.5 * textElement.node().getBBox().height;
42787
- } else if (i === 0) {
42788
- y2 = 0;
42789
- }
42790
46569
  const result = addImageObject(labelGroup, line2, width2, y2);
42791
46570
  addBackground = true;
46571
+ maxWidth = Math.max(maxWidth, result.w);
46572
+ y2 += result.h;
42792
46573
  } else if (line2.type === "raw_html") {
42793
- if (textElement) {
42794
- y2 += 1.5 * textElement.node().getBBox().height;
42795
- } else if (i === 0) {
42796
- y2 = 0;
42797
- }
42798
- textElement = void 0;
42799
46574
  const decodedReplacedText = line2.raw;
42800
46575
  const htmlnode = {
42801
46576
  isNode: true,
@@ -42805,29 +46580,41 @@ function createFormattedText(width2, g, structuredBlocks, addBackground = false,
42805
46580
  const result = addHtmlSpan(labelGroup, htmlnode, width2, "", y2, false);
42806
46581
  log.debug("addHtmlSpan result w: ", result.w, ", h:", result.h);
42807
46582
  const { w, h } = result;
42808
- if (w > maxWidth) maxWidth = w;
46583
+ maxWidth = Math.max(maxWidth, w);
46584
+ y2 += h;
42809
46585
  } else {
42810
- if (textElement === void 0) {
42811
- textElement = labelGroup.append("text").attr("y", y2).attr("fill", txtColor);
42812
- }
42813
- ;
42814
- let lineIndex = 0;
42815
- const checkWidth = /* @__PURE__ */ __name((line3) => computeWidthOfText(labelGroup, lineHeight, line3) <= width2, "checkWidth");
42816
- const linesUnderWidth = checkWidth(line2) ? [line2] : splitLineToFitWidth(line2, checkWidth);
42817
- for (const preparedLine of linesUnderWidth) {
42818
- const tspan = createTspan(textElement, lineIndex, lineHeight);
42819
- updateTextContentAndStyles(tspan, preparedLine.words);
42820
- lineIndex++;
46586
+ const textElement = labelGroup.append("text").attr("y", y2).attr("fill", txtColor);
46587
+ try {
46588
+ const measuredText = measureTextLineWithPretext(line2, width2, fontSize, fontFamily);
46589
+ for (const [lineIndex, preparedLine] of measuredText.lines.entries()) {
46590
+ const tspan = createTspan(textElement, lineIndex, lineHeight);
46591
+ updateTextContentAndStylesFromFragments(tspan, preparedLine.fragments);
46592
+ maxWidth = Math.max(maxWidth, preparedLine.width);
46593
+ }
46594
+ y2 += measuredText.height;
46595
+ } catch (error3) {
46596
+ log.warn("pretext layout failed, falling back to DOM text rendering", error3);
46597
+ usedPretext = false;
46598
+ const tspan = createTspan(textElement, 0, lineHeight);
46599
+ updateTextContentAndStyles(tspan, line2.words);
46600
+ const bbox = textElement.node().getBBox();
46601
+ maxWidth = Math.max(maxWidth, bbox.width);
46602
+ y2 += bbox.height;
42821
46603
  }
42822
46604
  }
42823
- ++i;
42824
46605
  }
42825
46606
  if (addBackground) {
42826
- const bbox = labelGroup.node().getBBox();
42827
46607
  const padding = 2;
42828
- bkg.attr("x", -padding).attr("y", -padding).attr("width", bbox.width + 2 * padding).attr("height", bbox.height + 2 * padding);
46608
+ bkg.attr("x", -padding).attr("y", -padding).attr("width", maxWidth + 2 * padding).attr("height", y2 + 2 * padding);
42829
46609
  }
42830
- return labelGroup.node();
46610
+ return {
46611
+ measurement: {
46612
+ height: y2,
46613
+ usedPretext,
46614
+ width: maxWidth
46615
+ },
46616
+ node: labelGroup.node()
46617
+ };
42831
46618
  }
42832
46619
  __name(createFormattedText, "createFormattedText");
42833
46620
  var createText = /* @__PURE__ */ __name((el, text2 = "", contents = [], {
@@ -42838,12 +46625,22 @@ var createText = /* @__PURE__ */ __name((el, text2 = "", contents = [], {
42838
46625
  useHtmlLabels = true,
42839
46626
  isNode: isNode2 = true,
42840
46627
  width: width2 = 300,
42841
- addSvgBackground = false
46628
+ addSvgBackground = false,
46629
+ fontFamily = DEFAULT_FONT_FAMILY,
46630
+ fontSize = 16
42842
46631
  } = {}) => {
42843
46632
  log.info("createText", text2, JSON.stringify(contents, void 0, 2), style3, isTitle, classes2, useHtmlLabels, isNode2, addSvgBackground);
42844
46633
  if (!Array.isArray(contents) || contents.length == 0) return;
42845
46634
  const structuredBlocks = hastToLines(contents);
42846
- const svgLabel = createFormattedText(width2, el, structuredBlocks, addSvgBackground, txtColor);
46635
+ const svgLabel = createFormattedText(
46636
+ width2,
46637
+ el,
46638
+ structuredBlocks,
46639
+ addSvgBackground,
46640
+ txtColor,
46641
+ fontSize,
46642
+ fontFamily
46643
+ );
42847
46644
  log.info("structuredBlocks ", JSON.stringify(structuredBlocks, void 0, 2));
42848
46645
  return svgLabel;
42849
46646
  }, "createText");
@@ -43065,16 +46862,19 @@ var drawNode = /* @__PURE__ */ __name(function(elem, node2, opts, rootSection, i
43065
46862
  nodeElem.attr("class", (node2.class ? node2.class + " " : "") + "mindmap-node " + sectionClass + ` node-level-${node2.level}`);
43066
46863
  const bkgElem = nodeElem.append("g");
43067
46864
  const textElem = nodeElem.append("g");
46865
+ const fontSize = theme_default.fontSize(node2.level);
43068
46866
  const description = node2.descr?.replace(/(<br\/*>)/g, "\n") ?? "";
43069
46867
  const contents = node2.contents;
43070
- const newEl = createText(
46868
+ const textResult = createText(
43071
46869
  textElem,
43072
46870
  description,
43073
46871
  contents,
43074
46872
  {
43075
46873
  useHtmlLabels: htmlLabels,
43076
46874
  width: node2.width,
43077
- classes: "mindmap-node-label"
46875
+ classes: "mindmap-node-label",
46876
+ fontFamily: theme_default.defaultFontFamily,
46877
+ fontSize
43078
46878
  }
43079
46879
  );
43080
46880
  const hasCodeTag = textElem.selectAll("code").size() > 0;
@@ -43084,14 +46884,13 @@ var drawNode = /* @__PURE__ */ __name(function(elem, node2, opts, rootSection, i
43084
46884
  }
43085
46885
  if (hasCodeTag) {
43086
46886
  }
43087
- const fontSize = theme_default.fontSize(node2.level);
43088
46887
  log.debug("fffffffffffffontsize : ", fontSize);
43089
46888
  if (!htmlLabels) {
43090
46889
  textElem.attr("dy", "1em").attr("alignment-baseline", "middle").attr("dominant-baseline", "middle").attr("text-anchor", "middle");
43091
46890
  }
43092
46891
  let tt = textElem.selectAll("text");
43093
46892
  tt.attr("font-size", `${fontSize}px`);
43094
- const bbox = textElem.node().getBBox();
46893
+ const bbox = textResult?.measurement ?? textElem.node().getBBox();
43095
46894
  if (hasImage) {
43096
46895
  node2.height = bbox.height;
43097
46896
  node2.width = bbox.width;
@@ -43266,7 +47065,16 @@ __name(partition, "partition");
43266
47065
 
43267
47066
  // src/markmap-renderer.ts
43268
47067
  cytoscape2.use(import_cytoscape_cose_bilkent.default);
47068
+ function assertMindmapNode(node2) {
47069
+ if (!node2 || typeof node2 !== "object" || Array.isArray(node2)) {
47070
+ throw new TypeError(
47071
+ `Expected a MindmapNode object, received ${typeof node2}: ${JSON.stringify(node2)}`
47072
+ );
47073
+ }
47074
+ }
47075
+ __name(assertMindmapNode, "assertMindmapNode");
43269
47076
  function drawNodes(svg3, mindmap, opts, section, index = 0) {
47077
+ assertMindmapNode(mindmap);
43270
47078
  drawNode(svg3, mindmap, opts, section, index);
43271
47079
  if (mindmap.children) {
43272
47080
  mindmap.children.forEach((child, index2) => {