@nebulaaa/grapheme 0.0.0-stage → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/grapheme.cjs +443 -0
- package/dist/grapheme.d.ts +69 -0
- package/dist/grapheme.min.cjs +1 -0
- package/dist/grapheme.min.mjs +1 -0
- package/dist/grapheme.mjs +434 -0
- package/dist/package.json +35 -0
- package/package.json +68 -6
- package/README.md +0 -3
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 字素断点属性数据(Unicode 16.0.0)
|
|
5
|
+
* 由 scripts/gen-break-data.mjs 生成,请勿手工修改。
|
|
6
|
+
* 原始 Unicode 数据存档:scripts/GraphemeBreakProperty.txt, scripts/emoji-data.txt
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* 字素断点属性区间表:BREAK_TABLE
|
|
10
|
+
* 由 scripts/gen-break-data.mjs 从 Unicode 16.0.0 官方数据生成,请勿手工修改。
|
|
11
|
+
* 扁平结构 [start, end, type, ...],按 start 升序,类型编号见 src/feature.ts 常量。
|
|
12
|
+
*/
|
|
13
|
+
const BREAK_TABLE = [0, 9, 3, 10, 10, 2, 11, 12, 3, 13, 13, 1, 14, 31, 3, 127, 159, 3, 173, 173, 3, 768, 879, 4, 1155, 1161, 4, 1425, 1469, 4, 1471, 1471, 4, 1473, 1474, 4, 1476, 1477, 4, 1479, 1479, 4, 1536, 1541, 7, 1552, 1562, 4, 1564, 1564, 3, 1611, 1631, 4, 1648, 1648, 4, 1750, 1756, 4, 1757, 1757, 7, 1759, 1764, 4, 1767, 1768, 4, 1770, 1773, 4, 1807, 1807, 7, 1809, 1809, 4, 1840, 1866, 4, 1958, 1968, 4, 2027, 2035, 4, 2045, 2045, 4, 2070, 2073, 4, 2075, 2083, 4, 2085, 2087, 4, 2089, 2093, 4, 2137, 2139, 4, 2192, 2193, 7, 2199, 2207, 4, 2250, 2273, 4, 2274, 2274, 7, 2275, 2306, 4, 2307, 2307, 8, 2362, 2362, 4, 2363, 2363, 8, 2364, 2364, 4, 2366, 2368, 8, 2369, 2376, 4, 2377, 2380, 8, 2381, 2381, 4, 2382, 2383, 8, 2385, 2391, 4, 2402, 2403, 4, 2433, 2433, 4, 2434, 2435, 8, 2492, 2492, 4, 2494, 2494, 4, 2495, 2496, 8, 2497, 2500, 4, 2503, 2504, 8, 2507, 2508, 8, 2509, 2509, 4, 2519, 2519, 4, 2530, 2531, 4, 2558, 2558, 4, 2561, 2562, 4, 2563, 2563, 8, 2620, 2620, 4, 2622, 2624, 8, 2625, 2626, 4, 2631, 2632, 4, 2635, 2637, 4, 2641, 2641, 4, 2672, 2673, 4, 2677, 2677, 4, 2689, 2690, 4, 2691, 2691, 8, 2748, 2748, 4, 2750, 2752, 8, 2753, 2757, 4, 2759, 2760, 4, 2761, 2761, 8, 2763, 2764, 8, 2765, 2765, 4, 2786, 2787, 4, 2810, 2815, 4, 2817, 2817, 4, 2818, 2819, 8, 2876, 2876, 4, 2878, 2879, 4, 2880, 2880, 8, 2881, 2884, 4, 2887, 2888, 8, 2891, 2892, 8, 2893, 2893, 4, 2901, 2903, 4, 2914, 2915, 4, 2946, 2946, 4, 3006, 3006, 4, 3007, 3007, 8, 3008, 3008, 4, 3009, 3010, 8, 3014, 3016, 8, 3018, 3020, 8, 3021, 3021, 4, 3031, 3031, 4, 3072, 3072, 4, 3073, 3075, 8, 3076, 3076, 4, 3132, 3132, 4, 3134, 3136, 4, 3137, 3140, 8, 3142, 3144, 4, 3146, 3149, 4, 3157, 3158, 4, 3170, 3171, 4, 3201, 3201, 4, 3202, 3203, 8, 3260, 3260, 4, 3262, 3262, 8, 3263, 3264, 4, 3265, 3265, 8, 3266, 3266, 4, 3267, 3268, 8, 3270, 3272, 4, 3274, 3277, 4, 3285, 3286, 4, 3298, 3299, 4, 3315, 3315, 8, 3328, 3329, 4, 3330, 3331, 8, 3387, 3388, 4, 3390, 3390, 4, 3391, 3392, 8, 3393, 3396, 4, 3398, 3400, 8, 3402, 3404, 8, 3405, 3405, 4, 3406, 3406, 7, 3415, 3415, 4, 3426, 3427, 4, 3457, 3457, 4, 3458, 3459, 8, 3530, 3530, 4, 3535, 3535, 4, 3536, 3537, 8, 3538, 3540, 4, 3542, 3542, 4, 3544, 3550, 8, 3551, 3551, 4, 3570, 3571, 8, 3633, 3633, 4, 3635, 3635, 8, 3636, 3642, 4, 3655, 3662, 4, 3761, 3761, 4, 3763, 3763, 8, 3764, 3772, 4, 3784, 3790, 4, 3864, 3865, 4, 3893, 3893, 4, 3895, 3895, 4, 3897, 3897, 4, 3902, 3903, 8, 3953, 3966, 4, 3967, 3967, 8, 3968, 3972, 4, 3974, 3975, 4, 3981, 3991, 4, 3993, 4028, 4, 4038, 4038, 4, 4141, 4144, 4, 4145, 4145, 8, 4146, 4151, 4, 4153, 4154, 4, 4155, 4156, 8, 4157, 4158, 4, 4182, 4183, 8, 4184, 4185, 4, 4190, 4192, 4, 4209, 4212, 4, 4226, 4226, 4, 4228, 4228, 8, 4229, 4230, 4, 4237, 4237, 4, 4253, 4253, 4, 4352, 4447, 9, 4448, 4519, 10, 4520, 4607, 11, 4957, 4959, 4, 5906, 5909, 4, 5938, 5940, 4, 5970, 5971, 4, 6002, 6003, 4, 6068, 6069, 4, 6070, 6070, 8, 6071, 6077, 4, 6078, 6085, 8, 6086, 6086, 4, 6087, 6088, 8, 6089, 6099, 4, 6109, 6109, 4, 6155, 6157, 4, 6158, 6158, 3, 6159, 6159, 4, 6277, 6278, 4, 6313, 6313, 4, 6432, 6434, 4, 6435, 6438, 8, 6439, 6440, 4, 6441, 6443, 8, 6448, 6449, 8, 6450, 6450, 4, 6451, 6456, 8, 6457, 6459, 4, 6679, 6680, 4, 6681, 6682, 8, 6683, 6683, 4, 6741, 6741, 8, 6742, 6742, 4, 6743, 6743, 8, 6744, 6750, 4, 6752, 6752, 4, 6754, 6754, 4, 6757, 6764, 4, 6765, 6770, 8, 6771, 6780, 4, 6783, 6783, 4, 6832, 6862, 4, 6912, 6915, 4, 6916, 6916, 8, 6964, 6973, 4, 6974, 6977, 8, 6978, 6980, 4, 7019, 7027, 4, 7040, 7041, 4, 7042, 7042, 8, 7073, 7073, 8, 7074, 7077, 4, 7078, 7079, 8, 7080, 7085, 4, 7142, 7142, 4, 7143, 7143, 8, 7144, 7145, 4, 7146, 7148, 8, 7149, 7149, 4, 7150, 7150, 8, 7151, 7155, 4, 7204, 7211, 8, 7212, 7219, 4, 7220, 7221, 8, 7222, 7223, 4, 7376, 7378, 4, 7380, 7392, 4, 7393, 7393, 8, 7394, 7400, 4, 7405, 7405, 4, 7412, 7412, 4, 7415, 7415, 8, 7416, 7417, 4, 7616, 7679, 4, 8203, 8203, 3, 8204, 8204, 4, 8205, 8205, 5, 8206, 8207, 3, 8232, 8238, 3, 8288, 8303, 3, 8400, 8432, 4, 11503, 11505, 4, 11647, 11647, 4, 11744, 11775, 4, 12330, 12335, 4, 12441, 12442, 4, 42607, 42610, 4, 42612, 42621, 4, 42654, 42655, 4, 42736, 42737, 4, 43010, 43010, 4, 43014, 43014, 4, 43019, 43019, 4, 43043, 43044, 8, 43045, 43046, 4, 43047, 43047, 8, 43052, 43052, 4, 43136, 43137, 8, 43188, 43203, 8, 43204, 43205, 4, 43232, 43249, 4, 43263, 43263, 4, 43302, 43309, 4, 43335, 43345, 4, 43346, 43346, 8, 43347, 43347, 4, 43360, 43388, 9, 43392, 43394, 4, 43395, 43395, 8, 43443, 43443, 4, 43444, 43445, 8, 43446, 43449, 4, 43450, 43451, 8, 43452, 43453, 4, 43454, 43455, 8, 43456, 43456, 4, 43493, 43493, 4, 43561, 43566, 4, 43567, 43568, 8, 43569, 43570, 4, 43571, 43572, 8, 43573, 43574, 4, 43587, 43587, 4, 43596, 43596, 4, 43597, 43597, 8, 43644, 43644, 4, 43696, 43696, 4, 43698, 43700, 4, 43703, 43704, 4, 43710, 43711, 4, 43713, 43713, 4, 43755, 43755, 8, 43756, 43757, 4, 43758, 43759, 8, 43765, 43765, 8, 43766, 43766, 4, 44003, 44004, 8, 44005, 44005, 4, 44006, 44007, 8, 44008, 44008, 4, 44009, 44010, 8, 44012, 44012, 8, 44013, 44013, 4, 44032, 44032, 12, 44033, 44059, 13, 44060, 44060, 12, 44061, 44087, 13, 44088, 44088, 12, 44089, 44115, 13, 44116, 44116, 12, 44117, 44143, 13, 44144, 44144, 12, 44145, 44171, 13, 44172, 44172, 12, 44173, 44199, 13, 44200, 44200, 12, 44201, 44227, 13, 44228, 44228, 12, 44229, 44255, 13, 44256, 44256, 12, 44257, 44283, 13, 44284, 44284, 12, 44285, 44311, 13, 44312, 44312, 12, 44313, 44339, 13, 44340, 44340, 12, 44341, 44367, 13, 44368, 44368, 12, 44369, 44395, 13, 44396, 44396, 12, 44397, 44423, 13, 44424, 44424, 12, 44425, 44451, 13, 44452, 44452, 12, 44453, 44479, 13, 44480, 44480, 12, 44481, 44507, 13, 44508, 44508, 12, 44509, 44535, 13, 44536, 44536, 12, 44537, 44563, 13, 44564, 44564, 12, 44565, 44591, 13, 44592, 44592, 12, 44593, 44619, 13, 44620, 44620, 12, 44621, 44647, 13, 44648, 44648, 12, 44649, 44675, 13, 44676, 44676, 12, 44677, 44703, 13, 44704, 44704, 12, 44705, 44731, 13, 44732, 44732, 12, 44733, 44759, 13, 44760, 44760, 12, 44761, 44787, 13, 44788, 44788, 12, 44789, 44815, 13, 44816, 44816, 12, 44817, 44843, 13, 44844, 44844, 12, 44845, 44871, 13, 44872, 44872, 12, 44873, 44899, 13, 44900, 44900, 12, 44901, 44927, 13, 44928, 44928, 12, 44929, 44955, 13, 44956, 44956, 12, 44957, 44983, 13, 44984, 44984, 12, 44985, 45011, 13, 45012, 45012, 12, 45013, 45039, 13, 45040, 45040, 12, 45041, 45067, 13, 45068, 45068, 12, 45069, 45095, 13, 45096, 45096, 12, 45097, 45123, 13, 45124, 45124, 12, 45125, 45151, 13, 45152, 45152, 12, 45153, 45179, 13, 45180, 45180, 12, 45181, 45207, 13, 45208, 45208, 12, 45209, 45235, 13, 45236, 45236, 12, 45237, 45263, 13, 45264, 45264, 12, 45265, 45291, 13, 45292, 45292, 12, 45293, 45319, 13, 45320, 45320, 12, 45321, 45347, 13, 45348, 45348, 12, 45349, 45375, 13, 45376, 45376, 12, 45377, 45403, 13, 45404, 45404, 12, 45405, 45431, 13, 45432, 45432, 12, 45433, 45459, 13, 45460, 45460, 12, 45461, 45487, 13, 45488, 45488, 12, 45489, 45515, 13, 45516, 45516, 12, 45517, 45543, 13, 45544, 45544, 12, 45545, 45571, 13, 45572, 45572, 12, 45573, 45599, 13, 45600, 45600, 12, 45601, 45627, 13, 45628, 45628, 12, 45629, 45655, 13, 45656, 45656, 12, 45657, 45683, 13, 45684, 45684, 12, 45685, 45711, 13, 45712, 45712, 12, 45713, 45739, 13, 45740, 45740, 12, 45741, 45767, 13, 45768, 45768, 12, 45769, 45795, 13, 45796, 45796, 12, 45797, 45823, 13, 45824, 45824, 12, 45825, 45851, 13, 45852, 45852, 12, 45853, 45879, 13, 45880, 45880, 12, 45881, 45907, 13, 45908, 45908, 12, 45909, 45935, 13, 45936, 45936, 12, 45937, 45963, 13, 45964, 45964, 12, 45965, 45991, 13, 45992, 45992, 12, 45993, 46019, 13, 46020, 46020, 12, 46021, 46047, 13, 46048, 46048, 12, 46049, 46075, 13, 46076, 46076, 12, 46077, 46103, 13, 46104, 46104, 12, 46105, 46131, 13, 46132, 46132, 12, 46133, 46159, 13, 46160, 46160, 12, 46161, 46187, 13, 46188, 46188, 12, 46189, 46215, 13, 46216, 46216, 12, 46217, 46243, 13, 46244, 46244, 12, 46245, 46271, 13, 46272, 46272, 12, 46273, 46299, 13, 46300, 46300, 12, 46301, 46327, 13, 46328, 46328, 12, 46329, 46355, 13, 46356, 46356, 12, 46357, 46383, 13, 46384, 46384, 12, 46385, 46411, 13, 46412, 46412, 12, 46413, 46439, 13, 46440, 46440, 12, 46441, 46467, 13, 46468, 46468, 12, 46469, 46495, 13, 46496, 46496, 12, 46497, 46523, 13, 46524, 46524, 12, 46525, 46551, 13, 46552, 46552, 12, 46553, 46579, 13, 46580, 46580, 12, 46581, 46607, 13, 46608, 46608, 12, 46609, 46635, 13, 46636, 46636, 12, 46637, 46663, 13, 46664, 46664, 12, 46665, 46691, 13, 46692, 46692, 12, 46693, 46719, 13, 46720, 46720, 12, 46721, 46747, 13, 46748, 46748, 12, 46749, 46775, 13, 46776, 46776, 12, 46777, 46803, 13, 46804, 46804, 12, 46805, 46831, 13, 46832, 46832, 12, 46833, 46859, 13, 46860, 46860, 12, 46861, 46887, 13, 46888, 46888, 12, 46889, 46915, 13, 46916, 46916, 12, 46917, 46943, 13, 46944, 46944, 12, 46945, 46971, 13, 46972, 46972, 12, 46973, 46999, 13, 47000, 47000, 12, 47001, 47027, 13, 47028, 47028, 12, 47029, 47055, 13, 47056, 47056, 12, 47057, 47083, 13, 47084, 47084, 12, 47085, 47111, 13, 47112, 47112, 12, 47113, 47139, 13, 47140, 47140, 12, 47141, 47167, 13, 47168, 47168, 12, 47169, 47195, 13, 47196, 47196, 12, 47197, 47223, 13, 47224, 47224, 12, 47225, 47251, 13, 47252, 47252, 12, 47253, 47279, 13, 47280, 47280, 12, 47281, 47307, 13, 47308, 47308, 12, 47309, 47335, 13, 47336, 47336, 12, 47337, 47363, 13, 47364, 47364, 12, 47365, 47391, 13, 47392, 47392, 12, 47393, 47419, 13, 47420, 47420, 12, 47421, 47447, 13, 47448, 47448, 12, 47449, 47475, 13, 47476, 47476, 12, 47477, 47503, 13, 47504, 47504, 12, 47505, 47531, 13, 47532, 47532, 12, 47533, 47559, 13, 47560, 47560, 12, 47561, 47587, 13, 47588, 47588, 12, 47589, 47615, 13, 47616, 47616, 12, 47617, 47643, 13, 47644, 47644, 12, 47645, 47671, 13, 47672, 47672, 12, 47673, 47699, 13, 47700, 47700, 12, 47701, 47727, 13, 47728, 47728, 12, 47729, 47755, 13, 47756, 47756, 12, 47757, 47783, 13, 47784, 47784, 12, 47785, 47811, 13, 47812, 47812, 12, 47813, 47839, 13, 47840, 47840, 12, 47841, 47867, 13, 47868, 47868, 12, 47869, 47895, 13, 47896, 47896, 12, 47897, 47923, 13, 47924, 47924, 12, 47925, 47951, 13, 47952, 47952, 12, 47953, 47979, 13, 47980, 47980, 12, 47981, 48007, 13, 48008, 48008, 12, 48009, 48035, 13, 48036, 48036, 12, 48037, 48063, 13, 48064, 48064, 12, 48065, 48091, 13, 48092, 48092, 12, 48093, 48119, 13, 48120, 48120, 12, 48121, 48147, 13, 48148, 48148, 12, 48149, 48175, 13, 48176, 48176, 12, 48177, 48203, 13, 48204, 48204, 12, 48205, 48231, 13, 48232, 48232, 12, 48233, 48259, 13, 48260, 48260, 12, 48261, 48287, 13, 48288, 48288, 12, 48289, 48315, 13, 48316, 48316, 12, 48317, 48343, 13, 48344, 48344, 12, 48345, 48371, 13, 48372, 48372, 12, 48373, 48399, 13, 48400, 48400, 12, 48401, 48427, 13, 48428, 48428, 12, 48429, 48455, 13, 48456, 48456, 12, 48457, 48483, 13, 48484, 48484, 12, 48485, 48511, 13, 48512, 48512, 12, 48513, 48539, 13, 48540, 48540, 12, 48541, 48567, 13, 48568, 48568, 12, 48569, 48595, 13, 48596, 48596, 12, 48597, 48623, 13, 48624, 48624, 12, 48625, 48651, 13, 48652, 48652, 12, 48653, 48679, 13, 48680, 48680, 12, 48681, 48707, 13, 48708, 48708, 12, 48709, 48735, 13, 48736, 48736, 12, 48737, 48763, 13, 48764, 48764, 12, 48765, 48791, 13, 48792, 48792, 12, 48793, 48819, 13, 48820, 48820, 12, 48821, 48847, 13, 48848, 48848, 12, 48849, 48875, 13, 48876, 48876, 12, 48877, 48903, 13, 48904, 48904, 12, 48905, 48931, 13, 48932, 48932, 12, 48933, 48959, 13, 48960, 48960, 12, 48961, 48987, 13, 48988, 48988, 12, 48989, 49015, 13, 49016, 49016, 12, 49017, 49043, 13, 49044, 49044, 12, 49045, 49071, 13, 49072, 49072, 12, 49073, 49099, 13, 49100, 49100, 12, 49101, 49127, 13, 49128, 49128, 12, 49129, 49155, 13, 49156, 49156, 12, 49157, 49183, 13, 49184, 49184, 12, 49185, 49211, 13, 49212, 49212, 12, 49213, 49239, 13, 49240, 49240, 12, 49241, 49267, 13, 49268, 49268, 12, 49269, 49295, 13, 49296, 49296, 12, 49297, 49323, 13, 49324, 49324, 12, 49325, 49351, 13, 49352, 49352, 12, 49353, 49379, 13, 49380, 49380, 12, 49381, 49407, 13, 49408, 49408, 12, 49409, 49435, 13, 49436, 49436, 12, 49437, 49463, 13, 49464, 49464, 12, 49465, 49491, 13, 49492, 49492, 12, 49493, 49519, 13, 49520, 49520, 12, 49521, 49547, 13, 49548, 49548, 12, 49549, 49575, 13, 49576, 49576, 12, 49577, 49603, 13, 49604, 49604, 12, 49605, 49631, 13, 49632, 49632, 12, 49633, 49659, 13, 49660, 49660, 12, 49661, 49687, 13, 49688, 49688, 12, 49689, 49715, 13, 49716, 49716, 12, 49717, 49743, 13, 49744, 49744, 12, 49745, 49771, 13, 49772, 49772, 12, 49773, 49799, 13, 49800, 49800, 12, 49801, 49827, 13, 49828, 49828, 12, 49829, 49855, 13, 49856, 49856, 12, 49857, 49883, 13, 49884, 49884, 12, 49885, 49911, 13, 49912, 49912, 12, 49913, 49939, 13, 49940, 49940, 12, 49941, 49967, 13, 49968, 49968, 12, 49969, 49995, 13, 49996, 49996, 12, 49997, 50023, 13, 50024, 50024, 12, 50025, 50051, 13, 50052, 50052, 12, 50053, 50079, 13, 50080, 50080, 12, 50081, 50107, 13, 50108, 50108, 12, 50109, 50135, 13, 50136, 50136, 12, 50137, 50163, 13, 50164, 50164, 12, 50165, 50191, 13, 50192, 50192, 12, 50193, 50219, 13, 50220, 50220, 12, 50221, 50247, 13, 50248, 50248, 12, 50249, 50275, 13, 50276, 50276, 12, 50277, 50303, 13, 50304, 50304, 12, 50305, 50331, 13, 50332, 50332, 12, 50333, 50359, 13, 50360, 50360, 12, 50361, 50387, 13, 50388, 50388, 12, 50389, 50415, 13, 50416, 50416, 12, 50417, 50443, 13, 50444, 50444, 12, 50445, 50471, 13, 50472, 50472, 12, 50473, 50499, 13, 50500, 50500, 12, 50501, 50527, 13, 50528, 50528, 12, 50529, 50555, 13, 50556, 50556, 12, 50557, 50583, 13, 50584, 50584, 12, 50585, 50611, 13, 50612, 50612, 12, 50613, 50639, 13, 50640, 50640, 12, 50641, 50667, 13, 50668, 50668, 12, 50669, 50695, 13, 50696, 50696, 12, 50697, 50723, 13, 50724, 50724, 12, 50725, 50751, 13, 50752, 50752, 12, 50753, 50779, 13, 50780, 50780, 12, 50781, 50807, 13, 50808, 50808, 12, 50809, 50835, 13, 50836, 50836, 12, 50837, 50863, 13, 50864, 50864, 12, 50865, 50891, 13, 50892, 50892, 12, 50893, 50919, 13, 50920, 50920, 12, 50921, 50947, 13, 50948, 50948, 12, 50949, 50975, 13, 50976, 50976, 12, 50977, 51003, 13, 51004, 51004, 12, 51005, 51031, 13, 51032, 51032, 12, 51033, 51059, 13, 51060, 51060, 12, 51061, 51087, 13, 51088, 51088, 12, 51089, 51115, 13, 51116, 51116, 12, 51117, 51143, 13, 51144, 51144, 12, 51145, 51171, 13, 51172, 51172, 12, 51173, 51199, 13, 51200, 51200, 12, 51201, 51227, 13, 51228, 51228, 12, 51229, 51255, 13, 51256, 51256, 12, 51257, 51283, 13, 51284, 51284, 12, 51285, 51311, 13, 51312, 51312, 12, 51313, 51339, 13, 51340, 51340, 12, 51341, 51367, 13, 51368, 51368, 12, 51369, 51395, 13, 51396, 51396, 12, 51397, 51423, 13, 51424, 51424, 12, 51425, 51451, 13, 51452, 51452, 12, 51453, 51479, 13, 51480, 51480, 12, 51481, 51507, 13, 51508, 51508, 12, 51509, 51535, 13, 51536, 51536, 12, 51537, 51563, 13, 51564, 51564, 12, 51565, 51591, 13, 51592, 51592, 12, 51593, 51619, 13, 51620, 51620, 12, 51621, 51647, 13, 51648, 51648, 12, 51649, 51675, 13, 51676, 51676, 12, 51677, 51703, 13, 51704, 51704, 12, 51705, 51731, 13, 51732, 51732, 12, 51733, 51759, 13, 51760, 51760, 12, 51761, 51787, 13, 51788, 51788, 12, 51789, 51815, 13, 51816, 51816, 12, 51817, 51843, 13, 51844, 51844, 12, 51845, 51871, 13, 51872, 51872, 12, 51873, 51899, 13, 51900, 51900, 12, 51901, 51927, 13, 51928, 51928, 12, 51929, 51955, 13, 51956, 51956, 12, 51957, 51983, 13, 51984, 51984, 12, 51985, 52011, 13, 52012, 52012, 12, 52013, 52039, 13, 52040, 52040, 12, 52041, 52067, 13, 52068, 52068, 12, 52069, 52095, 13, 52096, 52096, 12, 52097, 52123, 13, 52124, 52124, 12, 52125, 52151, 13, 52152, 52152, 12, 52153, 52179, 13, 52180, 52180, 12, 52181, 52207, 13, 52208, 52208, 12, 52209, 52235, 13, 52236, 52236, 12, 52237, 52263, 13, 52264, 52264, 12, 52265, 52291, 13, 52292, 52292, 12, 52293, 52319, 13, 52320, 52320, 12, 52321, 52347, 13, 52348, 52348, 12, 52349, 52375, 13, 52376, 52376, 12, 52377, 52403, 13, 52404, 52404, 12, 52405, 52431, 13, 52432, 52432, 12, 52433, 52459, 13, 52460, 52460, 12, 52461, 52487, 13, 52488, 52488, 12, 52489, 52515, 13, 52516, 52516, 12, 52517, 52543, 13, 52544, 52544, 12, 52545, 52571, 13, 52572, 52572, 12, 52573, 52599, 13, 52600, 52600, 12, 52601, 52627, 13, 52628, 52628, 12, 52629, 52655, 13, 52656, 52656, 12, 52657, 52683, 13, 52684, 52684, 12, 52685, 52711, 13, 52712, 52712, 12, 52713, 52739, 13, 52740, 52740, 12, 52741, 52767, 13, 52768, 52768, 12, 52769, 52795, 13, 52796, 52796, 12, 52797, 52823, 13, 52824, 52824, 12, 52825, 52851, 13, 52852, 52852, 12, 52853, 52879, 13, 52880, 52880, 12, 52881, 52907, 13, 52908, 52908, 12, 52909, 52935, 13, 52936, 52936, 12, 52937, 52963, 13, 52964, 52964, 12, 52965, 52991, 13, 52992, 52992, 12, 52993, 53019, 13, 53020, 53020, 12, 53021, 53047, 13, 53048, 53048, 12, 53049, 53075, 13, 53076, 53076, 12, 53077, 53103, 13, 53104, 53104, 12, 53105, 53131, 13, 53132, 53132, 12, 53133, 53159, 13, 53160, 53160, 12, 53161, 53187, 13, 53188, 53188, 12, 53189, 53215, 13, 53216, 53216, 12, 53217, 53243, 13, 53244, 53244, 12, 53245, 53271, 13, 53272, 53272, 12, 53273, 53299, 13, 53300, 53300, 12, 53301, 53327, 13, 53328, 53328, 12, 53329, 53355, 13, 53356, 53356, 12, 53357, 53383, 13, 53384, 53384, 12, 53385, 53411, 13, 53412, 53412, 12, 53413, 53439, 13, 53440, 53440, 12, 53441, 53467, 13, 53468, 53468, 12, 53469, 53495, 13, 53496, 53496, 12, 53497, 53523, 13, 53524, 53524, 12, 53525, 53551, 13, 53552, 53552, 12, 53553, 53579, 13, 53580, 53580, 12, 53581, 53607, 13, 53608, 53608, 12, 53609, 53635, 13, 53636, 53636, 12, 53637, 53663, 13, 53664, 53664, 12, 53665, 53691, 13, 53692, 53692, 12, 53693, 53719, 13, 53720, 53720, 12, 53721, 53747, 13, 53748, 53748, 12, 53749, 53775, 13, 53776, 53776, 12, 53777, 53803, 13, 53804, 53804, 12, 53805, 53831, 13, 53832, 53832, 12, 53833, 53859, 13, 53860, 53860, 12, 53861, 53887, 13, 53888, 53888, 12, 53889, 53915, 13, 53916, 53916, 12, 53917, 53943, 13, 53944, 53944, 12, 53945, 53971, 13, 53972, 53972, 12, 53973, 53999, 13, 54000, 54000, 12, 54001, 54027, 13, 54028, 54028, 12, 54029, 54055, 13, 54056, 54056, 12, 54057, 54083, 13, 54084, 54084, 12, 54085, 54111, 13, 54112, 54112, 12, 54113, 54139, 13, 54140, 54140, 12, 54141, 54167, 13, 54168, 54168, 12, 54169, 54195, 13, 54196, 54196, 12, 54197, 54223, 13, 54224, 54224, 12, 54225, 54251, 13, 54252, 54252, 12, 54253, 54279, 13, 54280, 54280, 12, 54281, 54307, 13, 54308, 54308, 12, 54309, 54335, 13, 54336, 54336, 12, 54337, 54363, 13, 54364, 54364, 12, 54365, 54391, 13, 54392, 54392, 12, 54393, 54419, 13, 54420, 54420, 12, 54421, 54447, 13, 54448, 54448, 12, 54449, 54475, 13, 54476, 54476, 12, 54477, 54503, 13, 54504, 54504, 12, 54505, 54531, 13, 54532, 54532, 12, 54533, 54559, 13, 54560, 54560, 12, 54561, 54587, 13, 54588, 54588, 12, 54589, 54615, 13, 54616, 54616, 12, 54617, 54643, 13, 54644, 54644, 12, 54645, 54671, 13, 54672, 54672, 12, 54673, 54699, 13, 54700, 54700, 12, 54701, 54727, 13, 54728, 54728, 12, 54729, 54755, 13, 54756, 54756, 12, 54757, 54783, 13, 54784, 54784, 12, 54785, 54811, 13, 54812, 54812, 12, 54813, 54839, 13, 54840, 54840, 12, 54841, 54867, 13, 54868, 54868, 12, 54869, 54895, 13, 54896, 54896, 12, 54897, 54923, 13, 54924, 54924, 12, 54925, 54951, 13, 54952, 54952, 12, 54953, 54979, 13, 54980, 54980, 12, 54981, 55007, 13, 55008, 55008, 12, 55009, 55035, 13, 55036, 55036, 12, 55037, 55063, 13, 55064, 55064, 12, 55065, 55091, 13, 55092, 55092, 12, 55093, 55119, 13, 55120, 55120, 12, 55121, 55147, 13, 55148, 55148, 12, 55149, 55175, 13, 55176, 55176, 12, 55177, 55203, 13, 55216, 55238, 10, 55243, 55291, 11, 64286, 64286, 4, 65024, 65039, 4, 65056, 65071, 4, 65279, 65279, 3, 65438, 65439, 4, 65520, 65531, 3, 66045, 66045, 4, 66272, 66272, 4, 66422, 66426, 4, 68097, 68099, 4, 68101, 68102, 4, 68108, 68111, 4, 68152, 68154, 4, 68159, 68159, 4, 68325, 68326, 4, 68900, 68903, 4, 68969, 68973, 4, 69291, 69292, 4, 69372, 69375, 4, 69446, 69456, 4, 69506, 69509, 4, 69632, 69632, 8, 69633, 69633, 4, 69634, 69634, 8, 69688, 69702, 4, 69744, 69744, 4, 69747, 69748, 4, 69759, 69761, 4, 69762, 69762, 8, 69808, 69810, 8, 69811, 69814, 4, 69815, 69816, 8, 69817, 69818, 4, 69821, 69821, 7, 69826, 69826, 4, 69837, 69837, 7, 69888, 69890, 4, 69927, 69931, 4, 69932, 69932, 8, 69933, 69940, 4, 69957, 69958, 8, 70003, 70003, 4, 70016, 70017, 4, 70018, 70018, 8, 70067, 70069, 8, 70070, 70078, 4, 70079, 70079, 8, 70080, 70080, 4, 70082, 70083, 7, 70089, 70092, 4, 70094, 70094, 8, 70095, 70095, 4, 70188, 70190, 8, 70191, 70193, 4, 70194, 70195, 8, 70196, 70199, 4, 70206, 70206, 4, 70209, 70209, 4, 70367, 70367, 4, 70368, 70370, 8, 70371, 70378, 4, 70400, 70401, 4, 70402, 70403, 8, 70459, 70460, 4, 70462, 70462, 4, 70463, 70463, 8, 70464, 70464, 4, 70465, 70468, 8, 70471, 70472, 8, 70475, 70476, 8, 70477, 70477, 4, 70487, 70487, 4, 70498, 70499, 8, 70502, 70508, 4, 70512, 70516, 4, 70584, 70584, 4, 70585, 70586, 8, 70587, 70592, 4, 70594, 70594, 4, 70597, 70597, 4, 70599, 70601, 4, 70602, 70602, 8, 70604, 70605, 8, 70606, 70608, 4, 70609, 70609, 7, 70610, 70610, 4, 70625, 70626, 4, 70709, 70711, 8, 70712, 70719, 4, 70720, 70721, 8, 70722, 70724, 4, 70725, 70725, 8, 70726, 70726, 4, 70750, 70750, 4, 70832, 70832, 4, 70833, 70834, 8, 70835, 70840, 4, 70841, 70841, 8, 70842, 70842, 4, 70843, 70844, 8, 70845, 70845, 4, 70846, 70846, 8, 70847, 70848, 4, 70849, 70849, 8, 70850, 70851, 4, 71087, 71087, 4, 71088, 71089, 8, 71090, 71093, 4, 71096, 71099, 8, 71100, 71101, 4, 71102, 71102, 8, 71103, 71104, 4, 71132, 71133, 4, 71216, 71218, 8, 71219, 71226, 4, 71227, 71228, 8, 71229, 71229, 4, 71230, 71230, 8, 71231, 71232, 4, 71339, 71339, 4, 71340, 71340, 8, 71341, 71341, 4, 71342, 71343, 8, 71344, 71351, 4, 71453, 71453, 4, 71454, 71454, 8, 71455, 71455, 4, 71458, 71461, 4, 71462, 71462, 8, 71463, 71467, 4, 71724, 71726, 8, 71727, 71735, 4, 71736, 71736, 8, 71737, 71738, 4, 71984, 71984, 4, 71985, 71989, 8, 71991, 71992, 8, 71995, 71998, 4, 71999, 71999, 7, 72000, 72000, 8, 72001, 72001, 7, 72002, 72002, 8, 72003, 72003, 4, 72145, 72147, 8, 72148, 72151, 4, 72154, 72155, 4, 72156, 72159, 8, 72160, 72160, 4, 72164, 72164, 8, 72193, 72202, 4, 72243, 72248, 4, 72249, 72249, 8, 72250, 72250, 7, 72251, 72254, 4, 72263, 72263, 4, 72273, 72278, 4, 72279, 72280, 8, 72281, 72283, 4, 72324, 72329, 7, 72330, 72342, 4, 72343, 72343, 8, 72344, 72345, 4, 72751, 72751, 8, 72752, 72758, 4, 72760, 72765, 4, 72766, 72766, 8, 72767, 72767, 4, 72850, 72871, 4, 72873, 72873, 8, 72874, 72880, 4, 72881, 72881, 8, 72882, 72883, 4, 72884, 72884, 8, 72885, 72886, 4, 73009, 73014, 4, 73018, 73018, 4, 73020, 73021, 4, 73023, 73029, 4, 73030, 73030, 7, 73031, 73031, 4, 73098, 73102, 8, 73104, 73105, 4, 73107, 73108, 8, 73109, 73109, 4, 73110, 73110, 8, 73111, 73111, 4, 73459, 73460, 4, 73461, 73462, 8, 73472, 73473, 4, 73474, 73474, 7, 73475, 73475, 8, 73524, 73525, 8, 73526, 73530, 4, 73534, 73535, 8, 73536, 73538, 4, 73562, 73562, 4, 78896, 78911, 3, 78912, 78912, 4, 78919, 78933, 4, 90398, 90409, 4, 90410, 90412, 8, 90413, 90415, 4, 92912, 92916, 4, 92976, 92982, 4, 93539, 93539, 10, 93543, 93546, 10, 94031, 94031, 4, 94033, 94087, 8, 94095, 94098, 4, 94180, 94180, 4, 94192, 94193, 4, 113821, 113822, 4, 113824, 113827, 3, 118528, 118573, 4, 118576, 118598, 4, 119141, 119145, 4, 119149, 119154, 4, 119155, 119162, 3, 119163, 119170, 4, 119173, 119179, 4, 119210, 119213, 4, 119362, 119364, 4, 121344, 121398, 4, 121403, 121452, 4, 121461, 121461, 4, 121476, 121476, 4, 121499, 121503, 4, 121505, 121519, 4, 122880, 122886, 4, 122888, 122904, 4, 122907, 122913, 4, 122915, 122916, 4, 122918, 122922, 4, 123023, 123023, 4, 123184, 123190, 4, 123566, 123566, 4, 123628, 123631, 4, 124140, 124143, 4, 124398, 124399, 4, 125136, 125142, 4, 125252, 125258, 4, 127462, 127487, 6, 127995, 127999, 4, 917504, 917535, 3, 917536, 917631, 4, 917632, 917759, 3, 917760, 917999, 4, 918000, 921599, 3];
|
|
14
|
+
/**
|
|
15
|
+
* 字素断点属性区间表:EXT_PICT_TABLE
|
|
16
|
+
* 由 scripts/gen-break-data.mjs 从 Unicode 16.0.0 官方数据生成,请勿手工修改。
|
|
17
|
+
* 扁平结构 [start, end, type, ...],按 start 升序,类型编号见 src/feature.ts 常量。
|
|
18
|
+
*/
|
|
19
|
+
const EXT_PICT_TABLE = [169, 169, 1, 174, 174, 1, 8252, 8252, 1, 8265, 8265, 1, 8482, 8482, 1, 8505, 8505, 1, 8596, 8601, 1, 8617, 8618, 1, 8986, 8987, 1, 9000, 9000, 1, 9096, 9096, 1, 9167, 9167, 1, 9193, 9203, 1, 9208, 9210, 1, 9410, 9410, 1, 9642, 9643, 1, 9654, 9654, 1, 9664, 9664, 1, 9723, 9726, 1, 9728, 9733, 1, 9735, 9746, 1, 9748, 9861, 1, 9872, 9989, 1, 9992, 10002, 1, 10004, 10004, 1, 10006, 10006, 1, 10013, 10013, 1, 10017, 10017, 1, 10024, 10024, 1, 10035, 10036, 1, 10052, 10052, 1, 10055, 10055, 1, 10060, 10060, 1, 10062, 10062, 1, 10067, 10069, 1, 10071, 10071, 1, 10083, 10087, 1, 10133, 10135, 1, 10145, 10145, 1, 10160, 10160, 1, 10175, 10175, 1, 10548, 10549, 1, 11013, 11015, 1, 11035, 11036, 1, 11088, 11088, 1, 11093, 11093, 1, 12336, 12336, 1, 12349, 12349, 1, 12951, 12951, 1, 12953, 12953, 1, 126976, 127231, 1, 127245, 127247, 1, 127279, 127279, 1, 127340, 127345, 1, 127358, 127359, 1, 127374, 127374, 1, 127377, 127386, 1, 127405, 127461, 1, 127489, 127503, 1, 127514, 127514, 1, 127535, 127535, 1, 127538, 127546, 1, 127548, 127551, 1, 127561, 127994, 1, 128000, 128317, 1, 128326, 128591, 1, 128640, 128767, 1, 128884, 128895, 1, 128981, 129023, 1, 129036, 129039, 1, 129096, 129103, 1, 129114, 129119, 1, 129160, 129167, 1, 129198, 129279, 1, 129292, 129338, 1, 129340, 129349, 1, 129351, 129791, 1, 130048, 131069, 1];
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 字素簇分割(Unicode UAX #29 extended grapheme clusters)
|
|
23
|
+
*
|
|
24
|
+
* 断点规则按 GB1-GB999 顺序短路判定:
|
|
25
|
+
* GB3 CR × LF
|
|
26
|
+
* GB4 (Control | CR | LF) ÷
|
|
27
|
+
* GB5 ÷ (Control | CR | LF)
|
|
28
|
+
* GB6 L × (L | V | LV | LVT)
|
|
29
|
+
* GB7 (LV | V) × (V | T)
|
|
30
|
+
* GB8 (LVT | T) × T
|
|
31
|
+
* GB9 × (Extend | ZWJ)
|
|
32
|
+
* GB9a × SpacingMark
|
|
33
|
+
* GB9b Prepend ×
|
|
34
|
+
* GB11 ExtPict Extend* ZWJ × ExtPict
|
|
35
|
+
* GB12 sot (RI RI)* RI × RI
|
|
36
|
+
* GB13 [^RI] (RI RI)* RI × RI
|
|
37
|
+
* GB999 Any ÷ Any
|
|
38
|
+
*
|
|
39
|
+
* 属性数据来自 Unicode 16.0.0 官方文件,由 scripts/gen-break-data.mjs
|
|
40
|
+
* 生成 src/data.ts(Unicode 版本升级时重新运行脚本即可)。
|
|
41
|
+
*/
|
|
42
|
+
// Grapheme_Cluster_Break 属性编号(与 scripts/gen-break-data.mjs 的 TYPE_IDS 一致)
|
|
43
|
+
const OTHER = 0;
|
|
44
|
+
const CR = 1;
|
|
45
|
+
const LF = 2;
|
|
46
|
+
const CONTROL = 3;
|
|
47
|
+
const EXTEND = 4;
|
|
48
|
+
const ZWJ = 5;
|
|
49
|
+
const REGIONAL_INDICATOR = 6;
|
|
50
|
+
const PREPEND = 7;
|
|
51
|
+
const SPACINGMARK = 8;
|
|
52
|
+
const HANGUL_L = 9;
|
|
53
|
+
const HANGUL_V = 10;
|
|
54
|
+
const HANGUL_T = 11;
|
|
55
|
+
const HANGUL_LV = 12;
|
|
56
|
+
const HANGUL_LVT = 13;
|
|
57
|
+
function lookupType(table, codePoint) {
|
|
58
|
+
let lo = 0;
|
|
59
|
+
let hi = table.length / 3 - 1;
|
|
60
|
+
while (lo <= hi) {
|
|
61
|
+
const mid = (lo + hi) >> 1;
|
|
62
|
+
if (codePoint < table[mid * 3])
|
|
63
|
+
hi = mid - 1;
|
|
64
|
+
else if (codePoint > table[mid * 3 + 1])
|
|
65
|
+
lo = mid + 1;
|
|
66
|
+
else
|
|
67
|
+
return table[mid * 3 + 2];
|
|
68
|
+
}
|
|
69
|
+
return OTHER;
|
|
70
|
+
}
|
|
71
|
+
function getGraphemeType(codePoint) {
|
|
72
|
+
return lookupType(BREAK_TABLE, codePoint);
|
|
73
|
+
}
|
|
74
|
+
function isExtendedPictographic(codePoint) {
|
|
75
|
+
return lookupType(EXT_PICT_TABLE, codePoint) === 1;
|
|
76
|
+
}
|
|
77
|
+
function codePointAt(str, index) {
|
|
78
|
+
const char = str.charCodeAt(index);
|
|
79
|
+
if (char >= 0xd800 && char <= 0xdbff && index + 1 < str.length) {
|
|
80
|
+
const next = str.charCodeAt(index + 1);
|
|
81
|
+
if (next >= 0xdc00 && next <= 0xdfff)
|
|
82
|
+
return (char - 0xd800) * 0x400 + (next - 0xdc00) + 0x10000;
|
|
83
|
+
}
|
|
84
|
+
return char;
|
|
85
|
+
}
|
|
86
|
+
function codePointLength(str, index) {
|
|
87
|
+
const char = str.charCodeAt(index);
|
|
88
|
+
if (char >= 0xd800 && char <= 0xdbff && index + 1 < str.length) {
|
|
89
|
+
const next = str.charCodeAt(index + 1);
|
|
90
|
+
if (next >= 0xdc00 && next <= 0xdfff)
|
|
91
|
+
return 2;
|
|
92
|
+
}
|
|
93
|
+
return 1;
|
|
94
|
+
}
|
|
95
|
+
function prevCodePointStart(str, index) {
|
|
96
|
+
const prev = str.charCodeAt(index - 1);
|
|
97
|
+
if (prev >= 0xdc00 && prev <= 0xdfff && index >= 2) {
|
|
98
|
+
const before = str.charCodeAt(index - 2);
|
|
99
|
+
if (before >= 0xd800 && before <= 0xdbff)
|
|
100
|
+
return index - 2;
|
|
101
|
+
}
|
|
102
|
+
return index - 1;
|
|
103
|
+
}
|
|
104
|
+
function isControlLike(type) {
|
|
105
|
+
return type === CR || type === LF || type === CONTROL;
|
|
106
|
+
}
|
|
107
|
+
function isBoundary(prevType, riOdd, pictZwj, currCP, currType) {
|
|
108
|
+
if (prevType === CR && currType === LF)
|
|
109
|
+
return false; // GB3
|
|
110
|
+
if (isControlLike(prevType))
|
|
111
|
+
return true; // GB4
|
|
112
|
+
if (isControlLike(currType))
|
|
113
|
+
return true; // GB5
|
|
114
|
+
if (prevType === HANGUL_L && (currType === HANGUL_L || currType === HANGUL_V || currType === HANGUL_LV || currType === HANGUL_LVT))
|
|
115
|
+
return false; // GB6
|
|
116
|
+
if ((prevType === HANGUL_LV || prevType === HANGUL_V) && (currType === HANGUL_V || currType === HANGUL_T))
|
|
117
|
+
return false; // GB7
|
|
118
|
+
if ((prevType === HANGUL_LVT || prevType === HANGUL_T) && currType === HANGUL_T)
|
|
119
|
+
return false; // GB8
|
|
120
|
+
if (currType === EXTEND || currType === ZWJ)
|
|
121
|
+
return false; // GB9
|
|
122
|
+
if (currType === SPACINGMARK)
|
|
123
|
+
return false; // GB9a
|
|
124
|
+
if (prevType === PREPEND)
|
|
125
|
+
return false; // GB9b
|
|
126
|
+
if (pictZwj && isExtendedPictographic(currCP))
|
|
127
|
+
return false; // GB11
|
|
128
|
+
if (prevType === REGIONAL_INDICATOR && currType === REGIONAL_INDICATOR && riOdd)
|
|
129
|
+
return false; // GB12/13
|
|
130
|
+
return true; // GB999
|
|
131
|
+
}
|
|
132
|
+
/** 统一 GB11 状态推进(正向/回溯复用) */
|
|
133
|
+
function advanceGB11State(state, currCP, currType) {
|
|
134
|
+
const pictZwj = state.pictChain && currType === ZWJ;
|
|
135
|
+
const pictChain = (isExtendedPictographic(currCP) && currType !== ZWJ) || (state.pictChain && currType === EXTEND);
|
|
136
|
+
return { pictChain, pictZwj };
|
|
137
|
+
}
|
|
138
|
+
function initialState(cp, type) {
|
|
139
|
+
return {
|
|
140
|
+
riOdd: type === REGIONAL_INDICATOR,
|
|
141
|
+
pictChain: isExtendedPictographic(cp),
|
|
142
|
+
pictZwj: false,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function advanceState(state, prevType, currCP, currType) {
|
|
146
|
+
const riOdd = currType === REGIONAL_INDICATOR && (prevType !== REGIONAL_INDICATOR || !state.riOdd);
|
|
147
|
+
const gb11 = advanceGB11State(state, currCP, currType);
|
|
148
|
+
return Object.assign({ riOdd }, gb11);
|
|
149
|
+
}
|
|
150
|
+
/** 通过正向重放统一状态机计算 GB11 状态(用于回溯镜像判定) */
|
|
151
|
+
function computeGB11StateAtBoundary(str, from, toExclusive) {
|
|
152
|
+
if (from >= toExclusive)
|
|
153
|
+
return { pictChain: false, pictZwj: false };
|
|
154
|
+
let i = from;
|
|
155
|
+
const cp0 = codePointAt(str, i);
|
|
156
|
+
const t0 = getGraphemeType(cp0);
|
|
157
|
+
let state = { pictChain: isExtendedPictographic(cp0), pictZwj: false };
|
|
158
|
+
let prevType = t0;
|
|
159
|
+
i += codePointLength(str, i);
|
|
160
|
+
while (i < toExclusive) {
|
|
161
|
+
const cp = codePointAt(str, i);
|
|
162
|
+
const t = getGraphemeType(cp);
|
|
163
|
+
// 若期间出现断点,GB11 链应在新簇语境下重置;但 findClusterStart 只在已确定非断点的边界附近调用
|
|
164
|
+
if (isBoundary(prevType, false, state.pictZwj, cp, t)) {
|
|
165
|
+
state = { pictChain: isExtendedPictographic(cp), pictZwj: false };
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
state = advanceGB11State(state, cp, t);
|
|
169
|
+
}
|
|
170
|
+
prevType = t;
|
|
171
|
+
i += codePointLength(str, i);
|
|
172
|
+
}
|
|
173
|
+
return state;
|
|
174
|
+
}
|
|
175
|
+
function normalizeIndexToCodePointStart(str, index) {
|
|
176
|
+
if (index <= 0)
|
|
177
|
+
return 0;
|
|
178
|
+
if (index >= str.length)
|
|
179
|
+
return str.length;
|
|
180
|
+
const prev = str.charCodeAt(index - 1);
|
|
181
|
+
if (prev >= 0xd800 && prev <= 0xdbff) {
|
|
182
|
+
const curr = str.charCodeAt(index);
|
|
183
|
+
if (curr >= 0xdc00 && curr <= 0xdfff)
|
|
184
|
+
return index - 1;
|
|
185
|
+
}
|
|
186
|
+
return index;
|
|
187
|
+
}
|
|
188
|
+
function findClusterStart(str, start) {
|
|
189
|
+
while (start > 0) {
|
|
190
|
+
const prevStart = prevCodePointStart(str, start);
|
|
191
|
+
const prevCP = codePointAt(str, prevStart);
|
|
192
|
+
const prevType = getGraphemeType(prevCP);
|
|
193
|
+
const currCP = codePointAt(str, start);
|
|
194
|
+
const currType = getGraphemeType(currCP);
|
|
195
|
+
let isStart;
|
|
196
|
+
if (prevType === CR && currType === LF)
|
|
197
|
+
isStart = false; // GB3
|
|
198
|
+
else if (isControlLike(prevType))
|
|
199
|
+
isStart = true; // GB4
|
|
200
|
+
else if (isControlLike(currType))
|
|
201
|
+
isStart = true; // GB5
|
|
202
|
+
else if (prevType === HANGUL_L && (currType === HANGUL_L || currType === HANGUL_V || currType === HANGUL_LV || currType === HANGUL_LVT))
|
|
203
|
+
isStart = false; // GB6
|
|
204
|
+
else if ((prevType === HANGUL_LV || prevType === HANGUL_V) && (currType === HANGUL_V || currType === HANGUL_T))
|
|
205
|
+
isStart = false; // GB7
|
|
206
|
+
else if ((prevType === HANGUL_LVT || prevType === HANGUL_T) && currType === HANGUL_T)
|
|
207
|
+
isStart = false; // GB8
|
|
208
|
+
else if (currType === EXTEND || currType === ZWJ)
|
|
209
|
+
isStart = false; // GB9
|
|
210
|
+
else if (currType === SPACINGMARK)
|
|
211
|
+
isStart = false; // GB9a
|
|
212
|
+
else if (prevType === PREPEND)
|
|
213
|
+
isStart = false; // GB9b
|
|
214
|
+
else if (currType === REGIONAL_INDICATOR && prevType === REGIONAL_INDICATOR) {
|
|
215
|
+
// GB12/13:向左统计连续 RI(含 prev)个数,奇数表示 prev 未配对
|
|
216
|
+
let count = 1;
|
|
217
|
+
let k = prevCodePointStart(str, prevStart);
|
|
218
|
+
while (k >= 0 && getGraphemeType(codePointAt(str, k)) === REGIONAL_INDICATOR) {
|
|
219
|
+
count++;
|
|
220
|
+
k = prevCodePointStart(str, k);
|
|
221
|
+
}
|
|
222
|
+
isStart = count % 2 === 0;
|
|
223
|
+
}
|
|
224
|
+
else if (isExtendedPictographic(currCP) && prevType === ZWJ) {
|
|
225
|
+
// GB11:用统一状态机从簇起点候选正向重放到 prevStart(含)以得到 pictZwj
|
|
226
|
+
// 先找到不受 GB9/GB11 链影响的一个安全起点候选:向左跳过 Extend/ZWJ/ExtPict 相关链的可能起点不现实,
|
|
227
|
+
// 这里从 prevStart 继续向左直到遇到 GB4/GB5/GB999 强断点候选,再从该点正向重放。
|
|
228
|
+
let anchor = prevStart;
|
|
229
|
+
while (anchor > 0) {
|
|
230
|
+
const aPrev = prevCodePointStart(str, anchor);
|
|
231
|
+
const aPrevCP = codePointAt(str, aPrev);
|
|
232
|
+
const aPrevType = getGraphemeType(aPrevCP);
|
|
233
|
+
const aCurrCP = codePointAt(str, anchor);
|
|
234
|
+
const aCurrType = getGraphemeType(aCurrCP);
|
|
235
|
+
if (isControlLike(aPrevType) || isControlLike(aCurrType))
|
|
236
|
+
break;
|
|
237
|
+
// 简化:遇到明显非链延续且非 RI/Hangul 复杂组合时可停;为安全起见继续回退一段
|
|
238
|
+
if (aCurrType !== EXTEND && aCurrType !== ZWJ && aCurrType !== SPACINGMARK && !isExtendedPictographic(aCurrCP) && aPrevType !== PREPEND)
|
|
239
|
+
break;
|
|
240
|
+
anchor = aPrev;
|
|
241
|
+
}
|
|
242
|
+
const st = computeGB11StateAtBoundary(str, anchor, start);
|
|
243
|
+
isStart = !st.pictZwj;
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
isStart = true; // GB999
|
|
247
|
+
}
|
|
248
|
+
if (isStart)
|
|
249
|
+
return start;
|
|
250
|
+
start = prevStart;
|
|
251
|
+
}
|
|
252
|
+
return start;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* 计算字符串的字素数量
|
|
256
|
+
* @param str - 要计算的字符串
|
|
257
|
+
* @returns 字素数量
|
|
258
|
+
*/
|
|
259
|
+
function GetLength(str) {
|
|
260
|
+
if (!str)
|
|
261
|
+
return 0;
|
|
262
|
+
let count = 0;
|
|
263
|
+
let index = 0;
|
|
264
|
+
while (index < str.length) {
|
|
265
|
+
index = NextBreak(str, index);
|
|
266
|
+
count++;
|
|
267
|
+
}
|
|
268
|
+
return count;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* 查找下一个字素边界位置(UTF-16 索引,严格大于 index 的最小边界)
|
|
272
|
+
*
|
|
273
|
+
* 语义说明(修复问题1):
|
|
274
|
+
* - `index` 为 UTF-16 索引,允许落在代理对中间或字素簇中间。
|
|
275
|
+
* - 若 `index` 落在簇中间,会先回溯到包含该索引的字素簇起点,再返回该簇的结束边界。
|
|
276
|
+
* 因此返回值始终是「覆盖 index 的那个字素簇」的终点(`> index`,除非已到字符串末尾)。
|
|
277
|
+
* - 内部 `Split/Iterate/GetLength/Slice/Pick` 始终传入已知簇边界,不会触发回溯歧义。
|
|
278
|
+
*
|
|
279
|
+
* @param str - 字符串
|
|
280
|
+
* @param index - UTF-16 起始索引(默认 0)
|
|
281
|
+
* @returns 下一个字素边界(UTF-16 索引)
|
|
282
|
+
*/
|
|
283
|
+
function NextBreak(str, index = 0) {
|
|
284
|
+
if (!str)
|
|
285
|
+
return 0;
|
|
286
|
+
if (!Number.isFinite(index) || index < 0)
|
|
287
|
+
return 0;
|
|
288
|
+
index = Math.floor(index);
|
|
289
|
+
if (index >= str.length)
|
|
290
|
+
return str.length;
|
|
291
|
+
let start = normalizeIndexToCodePointStart(str, index);
|
|
292
|
+
start = findClusterStart(str, start);
|
|
293
|
+
const firstCP = codePointAt(str, start);
|
|
294
|
+
const firstType = getGraphemeType(firstCP);
|
|
295
|
+
let prevType = firstType;
|
|
296
|
+
let state = initialState(firstCP, firstType);
|
|
297
|
+
let i = start + codePointLength(str, start);
|
|
298
|
+
while (i < str.length) {
|
|
299
|
+
const currCP = codePointAt(str, i);
|
|
300
|
+
const currType = getGraphemeType(currCP);
|
|
301
|
+
if (isBoundary(prevType, state.riOdd, state.pictZwj, currCP, currType))
|
|
302
|
+
return i;
|
|
303
|
+
state = advanceState(state, prevType, currCP, currType);
|
|
304
|
+
prevType = currType;
|
|
305
|
+
i += codePointLength(str, i);
|
|
306
|
+
}
|
|
307
|
+
return str.length;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* 将字符串拆分为字素数组
|
|
311
|
+
* @param str - 要拆分的字符串
|
|
312
|
+
* @returns 字素数组
|
|
313
|
+
*/
|
|
314
|
+
function Split(str) {
|
|
315
|
+
const result = [];
|
|
316
|
+
let index = 0;
|
|
317
|
+
while (index < str.length) {
|
|
318
|
+
const breakIndex = NextBreak(str, index);
|
|
319
|
+
result.push(str.slice(index, breakIndex));
|
|
320
|
+
index = breakIndex;
|
|
321
|
+
}
|
|
322
|
+
return result;
|
|
323
|
+
}
|
|
324
|
+
function normalizeGraphemeIndex(index, len) {
|
|
325
|
+
if (!Number.isFinite(index))
|
|
326
|
+
index = 0;
|
|
327
|
+
index = Math.trunc(index);
|
|
328
|
+
if (index < 0)
|
|
329
|
+
index = len + index;
|
|
330
|
+
if (index < 0)
|
|
331
|
+
index = 0;
|
|
332
|
+
if (index > len)
|
|
333
|
+
index = len;
|
|
334
|
+
return index;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* 按字素索引截取字符串
|
|
338
|
+
*
|
|
339
|
+
* 单位说明:
|
|
340
|
+
* - `start` / `end` 均为**字素索引**(0-based,按用户可见字符计数),不是 UTF-16 索引。
|
|
341
|
+
* - 支持负索引(如 -1 表示最后一个字素位置,与 `Array.prototype.slice` 类似)。
|
|
342
|
+
* - `end` 省略时截取到末尾。
|
|
343
|
+
*
|
|
344
|
+
* @param str - 字符串
|
|
345
|
+
* @param start - 起始字素索引
|
|
346
|
+
* @param end - 结束字素索引(不包含)
|
|
347
|
+
* @returns 截取的字符串
|
|
348
|
+
*/
|
|
349
|
+
function Slice(str, start = 0, end) {
|
|
350
|
+
if (!str)
|
|
351
|
+
return str !== null && str !== void 0 ? str : '';
|
|
352
|
+
const graphemes = Split(str);
|
|
353
|
+
const len = graphemes.length;
|
|
354
|
+
const s = normalizeGraphemeIndex(start, len);
|
|
355
|
+
const e = end === undefined ? len : normalizeGraphemeIndex(end, len);
|
|
356
|
+
if (e <= s)
|
|
357
|
+
return '';
|
|
358
|
+
return graphemes.slice(s, e).join('');
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* 获取字符串的字素迭代器
|
|
362
|
+
* @param str - 字符串
|
|
363
|
+
* @returns 可迭代的字素迭代器
|
|
364
|
+
*/
|
|
365
|
+
function Iterate(str) {
|
|
366
|
+
let index = 0;
|
|
367
|
+
return {
|
|
368
|
+
next() {
|
|
369
|
+
var _a;
|
|
370
|
+
if (index >= ((_a = str === null || str === void 0 ? void 0 : str.length) !== null && _a !== void 0 ? _a : 0))
|
|
371
|
+
return { value: undefined, done: true };
|
|
372
|
+
const breakIndex = NextBreak(str, index);
|
|
373
|
+
const value = str.slice(index, breakIndex);
|
|
374
|
+
index = breakIndex;
|
|
375
|
+
return { value, done: false };
|
|
376
|
+
},
|
|
377
|
+
[Symbol.iterator]() {
|
|
378
|
+
return this;
|
|
379
|
+
},
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* 遍历字符串的每个字素
|
|
384
|
+
* @param str - 字符串
|
|
385
|
+
* @param callback - 回调函数
|
|
386
|
+
*/
|
|
387
|
+
function Each(str, callback) {
|
|
388
|
+
let i = 0;
|
|
389
|
+
for (const grapheme of Iterate(str))
|
|
390
|
+
callback(grapheme, i++);
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* 获取字符串指定位置的字素
|
|
394
|
+
* @param str - 字符串
|
|
395
|
+
* @param index - 字素索引(支持负索引;非整数会被截断)
|
|
396
|
+
* @returns 指定位置的字素,如果不存在则返回 undefined
|
|
397
|
+
*/
|
|
398
|
+
function Pick(str, index) {
|
|
399
|
+
if (!str)
|
|
400
|
+
return undefined;
|
|
401
|
+
if (!Number.isFinite(index))
|
|
402
|
+
return undefined;
|
|
403
|
+
index = Math.trunc(index);
|
|
404
|
+
if (index < 0) {
|
|
405
|
+
const arr = Split(str);
|
|
406
|
+
const i = arr.length + index;
|
|
407
|
+
return i >= 0 ? arr[i] : undefined;
|
|
408
|
+
}
|
|
409
|
+
let count = 0;
|
|
410
|
+
for (const grapheme of Iterate(str)) {
|
|
411
|
+
if (count === index)
|
|
412
|
+
return grapheme;
|
|
413
|
+
count++;
|
|
414
|
+
}
|
|
415
|
+
return undefined;
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* 截断字符串的字素
|
|
419
|
+
* @param str - 字符串
|
|
420
|
+
* @param length - 最大保留字素数(非负整数;负数/NaN 视为 0)
|
|
421
|
+
* @param ellipsis - 省略号,默认为 "...";仅在实际发生截断时追加
|
|
422
|
+
* @returns 截断后的字符串
|
|
423
|
+
*/
|
|
424
|
+
function Truncate(str, length, ellipsis = '...') {
|
|
425
|
+
if (!str)
|
|
426
|
+
return str !== null && str !== void 0 ? str : '';
|
|
427
|
+
if (!Number.isFinite(length))
|
|
428
|
+
length = 0;
|
|
429
|
+
length = Math.max(0, Math.trunc(length));
|
|
430
|
+
const graphemes = Split(str);
|
|
431
|
+
if (graphemes.length <= length)
|
|
432
|
+
return str;
|
|
433
|
+
return graphemes.slice(0, length).join('') + ellipsis;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
exports.Each = Each;
|
|
437
|
+
exports.GetLength = GetLength;
|
|
438
|
+
exports.Iterate = Iterate;
|
|
439
|
+
exports.NextBreak = NextBreak;
|
|
440
|
+
exports.Pick = Pick;
|
|
441
|
+
exports.Slice = Slice;
|
|
442
|
+
exports.Split = Split;
|
|
443
|
+
exports.Truncate = Truncate;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 计算字符串的字素数量
|
|
3
|
+
* @param str - 要计算的字符串
|
|
4
|
+
* @returns 字素数量
|
|
5
|
+
*/
|
|
6
|
+
declare function GetLength(str: string): number;
|
|
7
|
+
/**
|
|
8
|
+
* 查找下一个字素边界位置(UTF-16 索引,严格大于 index 的最小边界)
|
|
9
|
+
*
|
|
10
|
+
* 语义说明(修复问题1):
|
|
11
|
+
* - `index` 为 UTF-16 索引,允许落在代理对中间或字素簇中间。
|
|
12
|
+
* - 若 `index` 落在簇中间,会先回溯到包含该索引的字素簇起点,再返回该簇的结束边界。
|
|
13
|
+
* 因此返回值始终是「覆盖 index 的那个字素簇」的终点(`> index`,除非已到字符串末尾)。
|
|
14
|
+
* - 内部 `Split/Iterate/GetLength/Slice/Pick` 始终传入已知簇边界,不会触发回溯歧义。
|
|
15
|
+
*
|
|
16
|
+
* @param str - 字符串
|
|
17
|
+
* @param index - UTF-16 起始索引(默认 0)
|
|
18
|
+
* @returns 下一个字素边界(UTF-16 索引)
|
|
19
|
+
*/
|
|
20
|
+
declare function NextBreak(str: string, index?: number): number;
|
|
21
|
+
/**
|
|
22
|
+
* 将字符串拆分为字素数组
|
|
23
|
+
* @param str - 要拆分的字符串
|
|
24
|
+
* @returns 字素数组
|
|
25
|
+
*/
|
|
26
|
+
declare function Split(str: string): string[];
|
|
27
|
+
/**
|
|
28
|
+
* 按字素索引截取字符串
|
|
29
|
+
*
|
|
30
|
+
* 单位说明:
|
|
31
|
+
* - `start` / `end` 均为**字素索引**(0-based,按用户可见字符计数),不是 UTF-16 索引。
|
|
32
|
+
* - 支持负索引(如 -1 表示最后一个字素位置,与 `Array.prototype.slice` 类似)。
|
|
33
|
+
* - `end` 省略时截取到末尾。
|
|
34
|
+
*
|
|
35
|
+
* @param str - 字符串
|
|
36
|
+
* @param start - 起始字素索引
|
|
37
|
+
* @param end - 结束字素索引(不包含)
|
|
38
|
+
* @returns 截取的字符串
|
|
39
|
+
*/
|
|
40
|
+
declare function Slice(str: string, start?: number, end?: number): string;
|
|
41
|
+
/**
|
|
42
|
+
* 获取字符串的字素迭代器
|
|
43
|
+
* @param str - 字符串
|
|
44
|
+
* @returns 可迭代的字素迭代器
|
|
45
|
+
*/
|
|
46
|
+
declare function Iterate(str: string): IterableIterator<string>;
|
|
47
|
+
/**
|
|
48
|
+
* 遍历字符串的每个字素
|
|
49
|
+
* @param str - 字符串
|
|
50
|
+
* @param callback - 回调函数
|
|
51
|
+
*/
|
|
52
|
+
declare function Each(str: string, callback: (grapheme: string, index: number) => void): void;
|
|
53
|
+
/**
|
|
54
|
+
* 获取字符串指定位置的字素
|
|
55
|
+
* @param str - 字符串
|
|
56
|
+
* @param index - 字素索引(支持负索引;非整数会被截断)
|
|
57
|
+
* @returns 指定位置的字素,如果不存在则返回 undefined
|
|
58
|
+
*/
|
|
59
|
+
declare function Pick(str: string, index: number): string | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* 截断字符串的字素
|
|
62
|
+
* @param str - 字符串
|
|
63
|
+
* @param length - 最大保留字素数(非负整数;负数/NaN 视为 0)
|
|
64
|
+
* @param ellipsis - 省略号,默认为 "...";仅在实际发生截断时追加
|
|
65
|
+
* @returns 截断后的字符串
|
|
66
|
+
*/
|
|
67
|
+
declare function Truncate(str: string, length: number, ellipsis?: string): string;
|
|
68
|
+
|
|
69
|
+
export { Each, GetLength, Iterate, NextBreak, Pick, Slice, Split, Truncate };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t=[0,9,3,10,10,2,11,12,3,13,13,1,14,31,3,127,159,3,173,173,3,768,879,4,1155,1161,4,1425,1469,4,1471,1471,4,1473,1474,4,1476,1477,4,1479,1479,4,1536,1541,7,1552,1562,4,1564,1564,3,1611,1631,4,1648,1648,4,1750,1756,4,1757,1757,7,1759,1764,4,1767,1768,4,1770,1773,4,1807,1807,7,1809,1809,4,1840,1866,4,1958,1968,4,2027,2035,4,2045,2045,4,2070,2073,4,2075,2083,4,2085,2087,4,2089,2093,4,2137,2139,4,2192,2193,7,2199,2207,4,2250,2273,4,2274,2274,7,2275,2306,4,2307,2307,8,2362,2362,4,2363,2363,8,2364,2364,4,2366,2368,8,2369,2376,4,2377,2380,8,2381,2381,4,2382,2383,8,2385,2391,4,2402,2403,4,2433,2433,4,2434,2435,8,2492,2492,4,2494,2494,4,2495,2496,8,2497,2500,4,2503,2504,8,2507,2508,8,2509,2509,4,2519,2519,4,2530,2531,4,2558,2558,4,2561,2562,4,2563,2563,8,2620,2620,4,2622,2624,8,2625,2626,4,2631,2632,4,2635,2637,4,2641,2641,4,2672,2673,4,2677,2677,4,2689,2690,4,2691,2691,8,2748,2748,4,2750,2752,8,2753,2757,4,2759,2760,4,2761,2761,8,2763,2764,8,2765,2765,4,2786,2787,4,2810,2815,4,2817,2817,4,2818,2819,8,2876,2876,4,2878,2879,4,2880,2880,8,2881,2884,4,2887,2888,8,2891,2892,8,2893,2893,4,2901,2903,4,2914,2915,4,2946,2946,4,3006,3006,4,3007,3007,8,3008,3008,4,3009,3010,8,3014,3016,8,3018,3020,8,3021,3021,4,3031,3031,4,3072,3072,4,3073,3075,8,3076,3076,4,3132,3132,4,3134,3136,4,3137,3140,8,3142,3144,4,3146,3149,4,3157,3158,4,3170,3171,4,3201,3201,4,3202,3203,8,3260,3260,4,3262,3262,8,3263,3264,4,3265,3265,8,3266,3266,4,3267,3268,8,3270,3272,4,3274,3277,4,3285,3286,4,3298,3299,4,3315,3315,8,3328,3329,4,3330,3331,8,3387,3388,4,3390,3390,4,3391,3392,8,3393,3396,4,3398,3400,8,3402,3404,8,3405,3405,4,3406,3406,7,3415,3415,4,3426,3427,4,3457,3457,4,3458,3459,8,3530,3530,4,3535,3535,4,3536,3537,8,3538,3540,4,3542,3542,4,3544,3550,8,3551,3551,4,3570,3571,8,3633,3633,4,3635,3635,8,3636,3642,4,3655,3662,4,3761,3761,4,3763,3763,8,3764,3772,4,3784,3790,4,3864,3865,4,3893,3893,4,3895,3895,4,3897,3897,4,3902,3903,8,3953,3966,4,3967,3967,8,3968,3972,4,3974,3975,4,3981,3991,4,3993,4028,4,4038,4038,4,4141,4144,4,4145,4145,8,4146,4151,4,4153,4154,4,4155,4156,8,4157,4158,4,4182,4183,8,4184,4185,4,4190,4192,4,4209,4212,4,4226,4226,4,4228,4228,8,4229,4230,4,4237,4237,4,4253,4253,4,4352,4447,9,4448,4519,10,4520,4607,11,4957,4959,4,5906,5909,4,5938,5940,4,5970,5971,4,6002,6003,4,6068,6069,4,6070,6070,8,6071,6077,4,6078,6085,8,6086,6086,4,6087,6088,8,6089,6099,4,6109,6109,4,6155,6157,4,6158,6158,3,6159,6159,4,6277,6278,4,6313,6313,4,6432,6434,4,6435,6438,8,6439,6440,4,6441,6443,8,6448,6449,8,6450,6450,4,6451,6456,8,6457,6459,4,6679,6680,4,6681,6682,8,6683,6683,4,6741,6741,8,6742,6742,4,6743,6743,8,6744,6750,4,6752,6752,4,6754,6754,4,6757,6764,4,6765,6770,8,6771,6780,4,6783,6783,4,6832,6862,4,6912,6915,4,6916,6916,8,6964,6973,4,6974,6977,8,6978,6980,4,7019,7027,4,7040,7041,4,7042,7042,8,7073,7073,8,7074,7077,4,7078,7079,8,7080,7085,4,7142,7142,4,7143,7143,8,7144,7145,4,7146,7148,8,7149,7149,4,7150,7150,8,7151,7155,4,7204,7211,8,7212,7219,4,7220,7221,8,7222,7223,4,7376,7378,4,7380,7392,4,7393,7393,8,7394,7400,4,7405,7405,4,7412,7412,4,7415,7415,8,7416,7417,4,7616,7679,4,8203,8203,3,8204,8204,4,8205,8205,5,8206,8207,3,8232,8238,3,8288,8303,3,8400,8432,4,11503,11505,4,11647,11647,4,11744,11775,4,12330,12335,4,12441,12442,4,42607,42610,4,42612,42621,4,42654,42655,4,42736,42737,4,43010,43010,4,43014,43014,4,43019,43019,4,43043,43044,8,43045,43046,4,43047,43047,8,43052,43052,4,43136,43137,8,43188,43203,8,43204,43205,4,43232,43249,4,43263,43263,4,43302,43309,4,43335,43345,4,43346,43346,8,43347,43347,4,43360,43388,9,43392,43394,4,43395,43395,8,43443,43443,4,43444,43445,8,43446,43449,4,43450,43451,8,43452,43453,4,43454,43455,8,43456,43456,4,43493,43493,4,43561,43566,4,43567,43568,8,43569,43570,4,43571,43572,8,43573,43574,4,43587,43587,4,43596,43596,4,43597,43597,8,43644,43644,4,43696,43696,4,43698,43700,4,43703,43704,4,43710,43711,4,43713,43713,4,43755,43755,8,43756,43757,4,43758,43759,8,43765,43765,8,43766,43766,4,44003,44004,8,44005,44005,4,44006,44007,8,44008,44008,4,44009,44010,8,44012,44012,8,44013,44013,4,44032,44032,12,44033,44059,13,44060,44060,12,44061,44087,13,44088,44088,12,44089,44115,13,44116,44116,12,44117,44143,13,44144,44144,12,44145,44171,13,44172,44172,12,44173,44199,13,44200,44200,12,44201,44227,13,44228,44228,12,44229,44255,13,44256,44256,12,44257,44283,13,44284,44284,12,44285,44311,13,44312,44312,12,44313,44339,13,44340,44340,12,44341,44367,13,44368,44368,12,44369,44395,13,44396,44396,12,44397,44423,13,44424,44424,12,44425,44451,13,44452,44452,12,44453,44479,13,44480,44480,12,44481,44507,13,44508,44508,12,44509,44535,13,44536,44536,12,44537,44563,13,44564,44564,12,44565,44591,13,44592,44592,12,44593,44619,13,44620,44620,12,44621,44647,13,44648,44648,12,44649,44675,13,44676,44676,12,44677,44703,13,44704,44704,12,44705,44731,13,44732,44732,12,44733,44759,13,44760,44760,12,44761,44787,13,44788,44788,12,44789,44815,13,44816,44816,12,44817,44843,13,44844,44844,12,44845,44871,13,44872,44872,12,44873,44899,13,44900,44900,12,44901,44927,13,44928,44928,12,44929,44955,13,44956,44956,12,44957,44983,13,44984,44984,12,44985,45011,13,45012,45012,12,45013,45039,13,45040,45040,12,45041,45067,13,45068,45068,12,45069,45095,13,45096,45096,12,45097,45123,13,45124,45124,12,45125,45151,13,45152,45152,12,45153,45179,13,45180,45180,12,45181,45207,13,45208,45208,12,45209,45235,13,45236,45236,12,45237,45263,13,45264,45264,12,45265,45291,13,45292,45292,12,45293,45319,13,45320,45320,12,45321,45347,13,45348,45348,12,45349,45375,13,45376,45376,12,45377,45403,13,45404,45404,12,45405,45431,13,45432,45432,12,45433,45459,13,45460,45460,12,45461,45487,13,45488,45488,12,45489,45515,13,45516,45516,12,45517,45543,13,45544,45544,12,45545,45571,13,45572,45572,12,45573,45599,13,45600,45600,12,45601,45627,13,45628,45628,12,45629,45655,13,45656,45656,12,45657,45683,13,45684,45684,12,45685,45711,13,45712,45712,12,45713,45739,13,45740,45740,12,45741,45767,13,45768,45768,12,45769,45795,13,45796,45796,12,45797,45823,13,45824,45824,12,45825,45851,13,45852,45852,12,45853,45879,13,45880,45880,12,45881,45907,13,45908,45908,12,45909,45935,13,45936,45936,12,45937,45963,13,45964,45964,12,45965,45991,13,45992,45992,12,45993,46019,13,46020,46020,12,46021,46047,13,46048,46048,12,46049,46075,13,46076,46076,12,46077,46103,13,46104,46104,12,46105,46131,13,46132,46132,12,46133,46159,13,46160,46160,12,46161,46187,13,46188,46188,12,46189,46215,13,46216,46216,12,46217,46243,13,46244,46244,12,46245,46271,13,46272,46272,12,46273,46299,13,46300,46300,12,46301,46327,13,46328,46328,12,46329,46355,13,46356,46356,12,46357,46383,13,46384,46384,12,46385,46411,13,46412,46412,12,46413,46439,13,46440,46440,12,46441,46467,13,46468,46468,12,46469,46495,13,46496,46496,12,46497,46523,13,46524,46524,12,46525,46551,13,46552,46552,12,46553,46579,13,46580,46580,12,46581,46607,13,46608,46608,12,46609,46635,13,46636,46636,12,46637,46663,13,46664,46664,12,46665,46691,13,46692,46692,12,46693,46719,13,46720,46720,12,46721,46747,13,46748,46748,12,46749,46775,13,46776,46776,12,46777,46803,13,46804,46804,12,46805,46831,13,46832,46832,12,46833,46859,13,46860,46860,12,46861,46887,13,46888,46888,12,46889,46915,13,46916,46916,12,46917,46943,13,46944,46944,12,46945,46971,13,46972,46972,12,46973,46999,13,47e3,47e3,12,47001,47027,13,47028,47028,12,47029,47055,13,47056,47056,12,47057,47083,13,47084,47084,12,47085,47111,13,47112,47112,12,47113,47139,13,47140,47140,12,47141,47167,13,47168,47168,12,47169,47195,13,47196,47196,12,47197,47223,13,47224,47224,12,47225,47251,13,47252,47252,12,47253,47279,13,47280,47280,12,47281,47307,13,47308,47308,12,47309,47335,13,47336,47336,12,47337,47363,13,47364,47364,12,47365,47391,13,47392,47392,12,47393,47419,13,47420,47420,12,47421,47447,13,47448,47448,12,47449,47475,13,47476,47476,12,47477,47503,13,47504,47504,12,47505,47531,13,47532,47532,12,47533,47559,13,47560,47560,12,47561,47587,13,47588,47588,12,47589,47615,13,47616,47616,12,47617,47643,13,47644,47644,12,47645,47671,13,47672,47672,12,47673,47699,13,47700,47700,12,47701,47727,13,47728,47728,12,47729,47755,13,47756,47756,12,47757,47783,13,47784,47784,12,47785,47811,13,47812,47812,12,47813,47839,13,47840,47840,12,47841,47867,13,47868,47868,12,47869,47895,13,47896,47896,12,47897,47923,13,47924,47924,12,47925,47951,13,47952,47952,12,47953,47979,13,47980,47980,12,47981,48007,13,48008,48008,12,48009,48035,13,48036,48036,12,48037,48063,13,48064,48064,12,48065,48091,13,48092,48092,12,48093,48119,13,48120,48120,12,48121,48147,13,48148,48148,12,48149,48175,13,48176,48176,12,48177,48203,13,48204,48204,12,48205,48231,13,48232,48232,12,48233,48259,13,48260,48260,12,48261,48287,13,48288,48288,12,48289,48315,13,48316,48316,12,48317,48343,13,48344,48344,12,48345,48371,13,48372,48372,12,48373,48399,13,48400,48400,12,48401,48427,13,48428,48428,12,48429,48455,13,48456,48456,12,48457,48483,13,48484,48484,12,48485,48511,13,48512,48512,12,48513,48539,13,48540,48540,12,48541,48567,13,48568,48568,12,48569,48595,13,48596,48596,12,48597,48623,13,48624,48624,12,48625,48651,13,48652,48652,12,48653,48679,13,48680,48680,12,48681,48707,13,48708,48708,12,48709,48735,13,48736,48736,12,48737,48763,13,48764,48764,12,48765,48791,13,48792,48792,12,48793,48819,13,48820,48820,12,48821,48847,13,48848,48848,12,48849,48875,13,48876,48876,12,48877,48903,13,48904,48904,12,48905,48931,13,48932,48932,12,48933,48959,13,48960,48960,12,48961,48987,13,48988,48988,12,48989,49015,13,49016,49016,12,49017,49043,13,49044,49044,12,49045,49071,13,49072,49072,12,49073,49099,13,49100,49100,12,49101,49127,13,49128,49128,12,49129,49155,13,49156,49156,12,49157,49183,13,49184,49184,12,49185,49211,13,49212,49212,12,49213,49239,13,49240,49240,12,49241,49267,13,49268,49268,12,49269,49295,13,49296,49296,12,49297,49323,13,49324,49324,12,49325,49351,13,49352,49352,12,49353,49379,13,49380,49380,12,49381,49407,13,49408,49408,12,49409,49435,13,49436,49436,12,49437,49463,13,49464,49464,12,49465,49491,13,49492,49492,12,49493,49519,13,49520,49520,12,49521,49547,13,49548,49548,12,49549,49575,13,49576,49576,12,49577,49603,13,49604,49604,12,49605,49631,13,49632,49632,12,49633,49659,13,49660,49660,12,49661,49687,13,49688,49688,12,49689,49715,13,49716,49716,12,49717,49743,13,49744,49744,12,49745,49771,13,49772,49772,12,49773,49799,13,49800,49800,12,49801,49827,13,49828,49828,12,49829,49855,13,49856,49856,12,49857,49883,13,49884,49884,12,49885,49911,13,49912,49912,12,49913,49939,13,49940,49940,12,49941,49967,13,49968,49968,12,49969,49995,13,49996,49996,12,49997,50023,13,50024,50024,12,50025,50051,13,50052,50052,12,50053,50079,13,50080,50080,12,50081,50107,13,50108,50108,12,50109,50135,13,50136,50136,12,50137,50163,13,50164,50164,12,50165,50191,13,50192,50192,12,50193,50219,13,50220,50220,12,50221,50247,13,50248,50248,12,50249,50275,13,50276,50276,12,50277,50303,13,50304,50304,12,50305,50331,13,50332,50332,12,50333,50359,13,50360,50360,12,50361,50387,13,50388,50388,12,50389,50415,13,50416,50416,12,50417,50443,13,50444,50444,12,50445,50471,13,50472,50472,12,50473,50499,13,50500,50500,12,50501,50527,13,50528,50528,12,50529,50555,13,50556,50556,12,50557,50583,13,50584,50584,12,50585,50611,13,50612,50612,12,50613,50639,13,50640,50640,12,50641,50667,13,50668,50668,12,50669,50695,13,50696,50696,12,50697,50723,13,50724,50724,12,50725,50751,13,50752,50752,12,50753,50779,13,50780,50780,12,50781,50807,13,50808,50808,12,50809,50835,13,50836,50836,12,50837,50863,13,50864,50864,12,50865,50891,13,50892,50892,12,50893,50919,13,50920,50920,12,50921,50947,13,50948,50948,12,50949,50975,13,50976,50976,12,50977,51003,13,51004,51004,12,51005,51031,13,51032,51032,12,51033,51059,13,51060,51060,12,51061,51087,13,51088,51088,12,51089,51115,13,51116,51116,12,51117,51143,13,51144,51144,12,51145,51171,13,51172,51172,12,51173,51199,13,51200,51200,12,51201,51227,13,51228,51228,12,51229,51255,13,51256,51256,12,51257,51283,13,51284,51284,12,51285,51311,13,51312,51312,12,51313,51339,13,51340,51340,12,51341,51367,13,51368,51368,12,51369,51395,13,51396,51396,12,51397,51423,13,51424,51424,12,51425,51451,13,51452,51452,12,51453,51479,13,51480,51480,12,51481,51507,13,51508,51508,12,51509,51535,13,51536,51536,12,51537,51563,13,51564,51564,12,51565,51591,13,51592,51592,12,51593,51619,13,51620,51620,12,51621,51647,13,51648,51648,12,51649,51675,13,51676,51676,12,51677,51703,13,51704,51704,12,51705,51731,13,51732,51732,12,51733,51759,13,51760,51760,12,51761,51787,13,51788,51788,12,51789,51815,13,51816,51816,12,51817,51843,13,51844,51844,12,51845,51871,13,51872,51872,12,51873,51899,13,51900,51900,12,51901,51927,13,51928,51928,12,51929,51955,13,51956,51956,12,51957,51983,13,51984,51984,12,51985,52011,13,52012,52012,12,52013,52039,13,52040,52040,12,52041,52067,13,52068,52068,12,52069,52095,13,52096,52096,12,52097,52123,13,52124,52124,12,52125,52151,13,52152,52152,12,52153,52179,13,52180,52180,12,52181,52207,13,52208,52208,12,52209,52235,13,52236,52236,12,52237,52263,13,52264,52264,12,52265,52291,13,52292,52292,12,52293,52319,13,52320,52320,12,52321,52347,13,52348,52348,12,52349,52375,13,52376,52376,12,52377,52403,13,52404,52404,12,52405,52431,13,52432,52432,12,52433,52459,13,52460,52460,12,52461,52487,13,52488,52488,12,52489,52515,13,52516,52516,12,52517,52543,13,52544,52544,12,52545,52571,13,52572,52572,12,52573,52599,13,52600,52600,12,52601,52627,13,52628,52628,12,52629,52655,13,52656,52656,12,52657,52683,13,52684,52684,12,52685,52711,13,52712,52712,12,52713,52739,13,52740,52740,12,52741,52767,13,52768,52768,12,52769,52795,13,52796,52796,12,52797,52823,13,52824,52824,12,52825,52851,13,52852,52852,12,52853,52879,13,52880,52880,12,52881,52907,13,52908,52908,12,52909,52935,13,52936,52936,12,52937,52963,13,52964,52964,12,52965,52991,13,52992,52992,12,52993,53019,13,53020,53020,12,53021,53047,13,53048,53048,12,53049,53075,13,53076,53076,12,53077,53103,13,53104,53104,12,53105,53131,13,53132,53132,12,53133,53159,13,53160,53160,12,53161,53187,13,53188,53188,12,53189,53215,13,53216,53216,12,53217,53243,13,53244,53244,12,53245,53271,13,53272,53272,12,53273,53299,13,53300,53300,12,53301,53327,13,53328,53328,12,53329,53355,13,53356,53356,12,53357,53383,13,53384,53384,12,53385,53411,13,53412,53412,12,53413,53439,13,53440,53440,12,53441,53467,13,53468,53468,12,53469,53495,13,53496,53496,12,53497,53523,13,53524,53524,12,53525,53551,13,53552,53552,12,53553,53579,13,53580,53580,12,53581,53607,13,53608,53608,12,53609,53635,13,53636,53636,12,53637,53663,13,53664,53664,12,53665,53691,13,53692,53692,12,53693,53719,13,53720,53720,12,53721,53747,13,53748,53748,12,53749,53775,13,53776,53776,12,53777,53803,13,53804,53804,12,53805,53831,13,53832,53832,12,53833,53859,13,53860,53860,12,53861,53887,13,53888,53888,12,53889,53915,13,53916,53916,12,53917,53943,13,53944,53944,12,53945,53971,13,53972,53972,12,53973,53999,13,54e3,54e3,12,54001,54027,13,54028,54028,12,54029,54055,13,54056,54056,12,54057,54083,13,54084,54084,12,54085,54111,13,54112,54112,12,54113,54139,13,54140,54140,12,54141,54167,13,54168,54168,12,54169,54195,13,54196,54196,12,54197,54223,13,54224,54224,12,54225,54251,13,54252,54252,12,54253,54279,13,54280,54280,12,54281,54307,13,54308,54308,12,54309,54335,13,54336,54336,12,54337,54363,13,54364,54364,12,54365,54391,13,54392,54392,12,54393,54419,13,54420,54420,12,54421,54447,13,54448,54448,12,54449,54475,13,54476,54476,12,54477,54503,13,54504,54504,12,54505,54531,13,54532,54532,12,54533,54559,13,54560,54560,12,54561,54587,13,54588,54588,12,54589,54615,13,54616,54616,12,54617,54643,13,54644,54644,12,54645,54671,13,54672,54672,12,54673,54699,13,54700,54700,12,54701,54727,13,54728,54728,12,54729,54755,13,54756,54756,12,54757,54783,13,54784,54784,12,54785,54811,13,54812,54812,12,54813,54839,13,54840,54840,12,54841,54867,13,54868,54868,12,54869,54895,13,54896,54896,12,54897,54923,13,54924,54924,12,54925,54951,13,54952,54952,12,54953,54979,13,54980,54980,12,54981,55007,13,55008,55008,12,55009,55035,13,55036,55036,12,55037,55063,13,55064,55064,12,55065,55091,13,55092,55092,12,55093,55119,13,55120,55120,12,55121,55147,13,55148,55148,12,55149,55175,13,55176,55176,12,55177,55203,13,55216,55238,10,55243,55291,11,64286,64286,4,65024,65039,4,65056,65071,4,65279,65279,3,65438,65439,4,65520,65531,3,66045,66045,4,66272,66272,4,66422,66426,4,68097,68099,4,68101,68102,4,68108,68111,4,68152,68154,4,68159,68159,4,68325,68326,4,68900,68903,4,68969,68973,4,69291,69292,4,69372,69375,4,69446,69456,4,69506,69509,4,69632,69632,8,69633,69633,4,69634,69634,8,69688,69702,4,69744,69744,4,69747,69748,4,69759,69761,4,69762,69762,8,69808,69810,8,69811,69814,4,69815,69816,8,69817,69818,4,69821,69821,7,69826,69826,4,69837,69837,7,69888,69890,4,69927,69931,4,69932,69932,8,69933,69940,4,69957,69958,8,70003,70003,4,70016,70017,4,70018,70018,8,70067,70069,8,70070,70078,4,70079,70079,8,70080,70080,4,70082,70083,7,70089,70092,4,70094,70094,8,70095,70095,4,70188,70190,8,70191,70193,4,70194,70195,8,70196,70199,4,70206,70206,4,70209,70209,4,70367,70367,4,70368,70370,8,70371,70378,4,70400,70401,4,70402,70403,8,70459,70460,4,70462,70462,4,70463,70463,8,70464,70464,4,70465,70468,8,70471,70472,8,70475,70476,8,70477,70477,4,70487,70487,4,70498,70499,8,70502,70508,4,70512,70516,4,70584,70584,4,70585,70586,8,70587,70592,4,70594,70594,4,70597,70597,4,70599,70601,4,70602,70602,8,70604,70605,8,70606,70608,4,70609,70609,7,70610,70610,4,70625,70626,4,70709,70711,8,70712,70719,4,70720,70721,8,70722,70724,4,70725,70725,8,70726,70726,4,70750,70750,4,70832,70832,4,70833,70834,8,70835,70840,4,70841,70841,8,70842,70842,4,70843,70844,8,70845,70845,4,70846,70846,8,70847,70848,4,70849,70849,8,70850,70851,4,71087,71087,4,71088,71089,8,71090,71093,4,71096,71099,8,71100,71101,4,71102,71102,8,71103,71104,4,71132,71133,4,71216,71218,8,71219,71226,4,71227,71228,8,71229,71229,4,71230,71230,8,71231,71232,4,71339,71339,4,71340,71340,8,71341,71341,4,71342,71343,8,71344,71351,4,71453,71453,4,71454,71454,8,71455,71455,4,71458,71461,4,71462,71462,8,71463,71467,4,71724,71726,8,71727,71735,4,71736,71736,8,71737,71738,4,71984,71984,4,71985,71989,8,71991,71992,8,71995,71998,4,71999,71999,7,72e3,72e3,8,72001,72001,7,72002,72002,8,72003,72003,4,72145,72147,8,72148,72151,4,72154,72155,4,72156,72159,8,72160,72160,4,72164,72164,8,72193,72202,4,72243,72248,4,72249,72249,8,72250,72250,7,72251,72254,4,72263,72263,4,72273,72278,4,72279,72280,8,72281,72283,4,72324,72329,7,72330,72342,4,72343,72343,8,72344,72345,4,72751,72751,8,72752,72758,4,72760,72765,4,72766,72766,8,72767,72767,4,72850,72871,4,72873,72873,8,72874,72880,4,72881,72881,8,72882,72883,4,72884,72884,8,72885,72886,4,73009,73014,4,73018,73018,4,73020,73021,4,73023,73029,4,73030,73030,7,73031,73031,4,73098,73102,8,73104,73105,4,73107,73108,8,73109,73109,4,73110,73110,8,73111,73111,4,73459,73460,4,73461,73462,8,73472,73473,4,73474,73474,7,73475,73475,8,73524,73525,8,73526,73530,4,73534,73535,8,73536,73538,4,73562,73562,4,78896,78911,3,78912,78912,4,78919,78933,4,90398,90409,4,90410,90412,8,90413,90415,4,92912,92916,4,92976,92982,4,93539,93539,10,93543,93546,10,94031,94031,4,94033,94087,8,94095,94098,4,94180,94180,4,94192,94193,4,113821,113822,4,113824,113827,3,118528,118573,4,118576,118598,4,119141,119145,4,119149,119154,4,119155,119162,3,119163,119170,4,119173,119179,4,119210,119213,4,119362,119364,4,121344,121398,4,121403,121452,4,121461,121461,4,121476,121476,4,121499,121503,4,121505,121519,4,122880,122886,4,122888,122904,4,122907,122913,4,122915,122916,4,122918,122922,4,123023,123023,4,123184,123190,4,123566,123566,4,123628,123631,4,124140,124143,4,124398,124399,4,125136,125142,4,125252,125258,4,127462,127487,6,127995,127999,4,917504,917535,3,917536,917631,4,917632,917759,3,917760,917999,4,918e3,921599,3],n=[169,169,1,174,174,1,8252,8252,1,8265,8265,1,8482,8482,1,8505,8505,1,8596,8601,1,8617,8618,1,8986,8987,1,9e3,9e3,1,9096,9096,1,9167,9167,1,9193,9203,1,9208,9210,1,9410,9410,1,9642,9643,1,9654,9654,1,9664,9664,1,9723,9726,1,9728,9733,1,9735,9746,1,9748,9861,1,9872,9989,1,9992,10002,1,10004,10004,1,10006,10006,1,10013,10013,1,10017,10017,1,10024,10024,1,10035,10036,1,10052,10052,1,10055,10055,1,10060,10060,1,10062,10062,1,10067,10069,1,10071,10071,1,10083,10087,1,10133,10135,1,10145,10145,1,10160,10160,1,10175,10175,1,10548,10549,1,11013,11015,1,11035,11036,1,11088,11088,1,11093,11093,1,12336,12336,1,12349,12349,1,12951,12951,1,12953,12953,1,126976,127231,1,127245,127247,1,127279,127279,1,127340,127345,1,127358,127359,1,127374,127374,1,127377,127386,1,127405,127461,1,127489,127503,1,127514,127514,1,127535,127535,1,127538,127546,1,127548,127551,1,127561,127994,1,128e3,128317,1,128326,128591,1,128640,128767,1,128884,128895,1,128981,129023,1,129036,129039,1,129096,129103,1,129114,129119,1,129160,129167,1,129198,129279,1,129292,129338,1,129340,129349,1,129351,129791,1,130048,131069,1],e=10,r=11;function i(t,n){let e=0,r=t.length/3-1;for(;e<=r;){const i=e+r>>1;if(n<t[3*i])r=i-1;else{if(!(n>t[3*i+1]))return t[3*i+2];e=i+1}}return 0}function o(n){return i(t,n)}function c(t){return 1===i(n,t)}function u(t,n){const e=t.charCodeAt(n);if(e>=55296&&e<=56319&&n+1<t.length){const r=t.charCodeAt(n+1);if(r>=56320&&r<=57343)return 1024*(e-55296)+(r-56320)+65536}return e}function f(t,n){const e=t.charCodeAt(n);if(e>=55296&&e<=56319&&n+1<t.length){const e=t.charCodeAt(n+1);if(e>=56320&&e<=57343)return 2}return 1}function s(t,n){const e=t.charCodeAt(n-1);if(e>=56320&&e<=57343&&n>=2){const e=t.charCodeAt(n-2);if(e>=55296&&e<=56319)return n-2}return n-1}function l(t){return 1===t||2===t||3===t}function h(t,n,i,o,u){return(1!==t||2!==u)&&(!!l(t)||(!!l(u)||(9!==t||9!==u&&u!==e&&12!==u&&13!==u)&&((12!==t&&t!==e||u!==e&&u!==r)&&((13!==t&&t!==r||u!==r)&&(4!==u&&5!==u&&(8!==u&&(7!==t&&((!i||!c(o))&&(6!==t||6!==u||!n)))))))))}function a(t,n,e){const r=t.pictChain&&5===e;return{pictChain:c(n)&&5!==e||t.pictChain&&4===e,pictZwj:r}}function p(t,n,e,r){const i=6===r&&(6!==n||!t.riOdd),o=a(t,e,r);return Object.assign({riOdd:i},o)}function d(t,n,e){if(n>=e)return{pictChain:!1,pictZwj:!1};let r=n;const i=u(t,r),s=o(i);let l={pictChain:c(i),pictZwj:!1},p=s;for(r+=f(t,r);r<e;){const n=u(t,r),e=o(n);l=h(p,!1,l.pictZwj,n,e)?{pictChain:c(n),pictZwj:!1}:a(l,n,e),p=e,r+=f(t,r)}return l}function g(t,n=0){if(!t)return 0;if(!Number.isFinite(n)||n<0)return 0;if((n=Math.floor(n))>=t.length)return t.length;let i=function(t,n){if(n<=0)return 0;if(n>=t.length)return t.length;const e=t.charCodeAt(n-1);if(e>=55296&&e<=56319){const e=t.charCodeAt(n);if(e>=56320&&e<=57343)return n-1}return n}(t,n);i=function(t,n){for(;n>0;){const i=s(t,n),f=o(u(t,i)),h=u(t,n),a=o(h);let p;if(1===f&&2===a)p=!1;else if(l(f))p=!0;else if(l(a))p=!0;else if(9!==f||9!==a&&a!==e&&12!==a&&13!==a)if(12!==f&&f!==e||a!==e&&a!==r)if(13!==f&&f!==r||a!==r)if(4===a||5===a)p=!1;else if(8===a)p=!1;else if(7===f)p=!1;else if(6===a&&6===f){let n=1,e=s(t,i);for(;e>=0&&6===o(u(t,e));)n++,e=s(t,e);p=n%2==0}else if(c(h)&&5===f){let e=i;for(;e>0;){const n=s(t,e),r=o(u(t,n)),i=u(t,e),f=o(i);if(l(r)||l(f))break;if(4!==f&&5!==f&&8!==f&&!c(i)&&7!==r)break;e=n}p=!d(t,e,n).pictZwj}else p=!0;else p=!1;else p=!1;else p=!1;if(p)return n;n=i}return n}(t,i);const a=u(t,i),g=o(a);let C=g,j={riOdd:6===g,pictChain:c(a),pictZwj:!1};let x=i+f(t,i);for(;x<t.length;){const n=u(t,x),e=o(n);if(h(C,j.riOdd,j.pictZwj,n,e))return x;j=p(j,C,n,e),C=e,x+=f(t,x)}return t.length}function C(t){const n=[];let e=0;for(;e<t.length;){const r=g(t,e);n.push(t.slice(e,r)),e=r}return n}function j(t,n){return Number.isFinite(t)||(t=0),(t=Math.trunc(t))<0&&(t=n+t),t<0&&(t=0),t>n&&(t=n),t}function x(t){let n=0;return{next(){var e;if(n>=(null!==(e=null==t?void 0:t.length)&&void 0!==e?e:0))return{value:void 0,done:!0};const r=g(t,n),i=t.slice(n,r);return n=r,{value:i,done:!1}},[Symbol.iterator](){return this}}}exports.Each=function(t,n){let e=0;for(const r of x(t))n(r,e++)},exports.GetLength=function(t){if(!t)return 0;let n=0,e=0;for(;e<t.length;)e=g(t,e),n++;return n},exports.Iterate=x,exports.NextBreak=g,exports.Pick=function(t,n){if(!t)return;if(!Number.isFinite(n))return;if((n=Math.trunc(n))<0){const e=C(t),r=e.length+n;return r>=0?e[r]:void 0}let e=0;for(const r of x(t)){if(e===n)return r;e++}},exports.Slice=function(t,n=0,e){if(!t)return null!=t?t:"";const r=C(t),i=r.length,o=j(n,i),c=void 0===e?i:j(e,i);return c<=o?"":r.slice(o,c).join("")},exports.Split=C,exports.Truncate=function(t,n,e="..."){if(!t)return null!=t?t:"";Number.isFinite(n)||(n=0),n=Math.max(0,Math.trunc(n));const r=C(t);return r.length<=n?t:r.slice(0,n).join("")+e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t=[0,9,3,10,10,2,11,12,3,13,13,1,14,31,3,127,159,3,173,173,3,768,879,4,1155,1161,4,1425,1469,4,1471,1471,4,1473,1474,4,1476,1477,4,1479,1479,4,1536,1541,7,1552,1562,4,1564,1564,3,1611,1631,4,1648,1648,4,1750,1756,4,1757,1757,7,1759,1764,4,1767,1768,4,1770,1773,4,1807,1807,7,1809,1809,4,1840,1866,4,1958,1968,4,2027,2035,4,2045,2045,4,2070,2073,4,2075,2083,4,2085,2087,4,2089,2093,4,2137,2139,4,2192,2193,7,2199,2207,4,2250,2273,4,2274,2274,7,2275,2306,4,2307,2307,8,2362,2362,4,2363,2363,8,2364,2364,4,2366,2368,8,2369,2376,4,2377,2380,8,2381,2381,4,2382,2383,8,2385,2391,4,2402,2403,4,2433,2433,4,2434,2435,8,2492,2492,4,2494,2494,4,2495,2496,8,2497,2500,4,2503,2504,8,2507,2508,8,2509,2509,4,2519,2519,4,2530,2531,4,2558,2558,4,2561,2562,4,2563,2563,8,2620,2620,4,2622,2624,8,2625,2626,4,2631,2632,4,2635,2637,4,2641,2641,4,2672,2673,4,2677,2677,4,2689,2690,4,2691,2691,8,2748,2748,4,2750,2752,8,2753,2757,4,2759,2760,4,2761,2761,8,2763,2764,8,2765,2765,4,2786,2787,4,2810,2815,4,2817,2817,4,2818,2819,8,2876,2876,4,2878,2879,4,2880,2880,8,2881,2884,4,2887,2888,8,2891,2892,8,2893,2893,4,2901,2903,4,2914,2915,4,2946,2946,4,3006,3006,4,3007,3007,8,3008,3008,4,3009,3010,8,3014,3016,8,3018,3020,8,3021,3021,4,3031,3031,4,3072,3072,4,3073,3075,8,3076,3076,4,3132,3132,4,3134,3136,4,3137,3140,8,3142,3144,4,3146,3149,4,3157,3158,4,3170,3171,4,3201,3201,4,3202,3203,8,3260,3260,4,3262,3262,8,3263,3264,4,3265,3265,8,3266,3266,4,3267,3268,8,3270,3272,4,3274,3277,4,3285,3286,4,3298,3299,4,3315,3315,8,3328,3329,4,3330,3331,8,3387,3388,4,3390,3390,4,3391,3392,8,3393,3396,4,3398,3400,8,3402,3404,8,3405,3405,4,3406,3406,7,3415,3415,4,3426,3427,4,3457,3457,4,3458,3459,8,3530,3530,4,3535,3535,4,3536,3537,8,3538,3540,4,3542,3542,4,3544,3550,8,3551,3551,4,3570,3571,8,3633,3633,4,3635,3635,8,3636,3642,4,3655,3662,4,3761,3761,4,3763,3763,8,3764,3772,4,3784,3790,4,3864,3865,4,3893,3893,4,3895,3895,4,3897,3897,4,3902,3903,8,3953,3966,4,3967,3967,8,3968,3972,4,3974,3975,4,3981,3991,4,3993,4028,4,4038,4038,4,4141,4144,4,4145,4145,8,4146,4151,4,4153,4154,4,4155,4156,8,4157,4158,4,4182,4183,8,4184,4185,4,4190,4192,4,4209,4212,4,4226,4226,4,4228,4228,8,4229,4230,4,4237,4237,4,4253,4253,4,4352,4447,9,4448,4519,10,4520,4607,11,4957,4959,4,5906,5909,4,5938,5940,4,5970,5971,4,6002,6003,4,6068,6069,4,6070,6070,8,6071,6077,4,6078,6085,8,6086,6086,4,6087,6088,8,6089,6099,4,6109,6109,4,6155,6157,4,6158,6158,3,6159,6159,4,6277,6278,4,6313,6313,4,6432,6434,4,6435,6438,8,6439,6440,4,6441,6443,8,6448,6449,8,6450,6450,4,6451,6456,8,6457,6459,4,6679,6680,4,6681,6682,8,6683,6683,4,6741,6741,8,6742,6742,4,6743,6743,8,6744,6750,4,6752,6752,4,6754,6754,4,6757,6764,4,6765,6770,8,6771,6780,4,6783,6783,4,6832,6862,4,6912,6915,4,6916,6916,8,6964,6973,4,6974,6977,8,6978,6980,4,7019,7027,4,7040,7041,4,7042,7042,8,7073,7073,8,7074,7077,4,7078,7079,8,7080,7085,4,7142,7142,4,7143,7143,8,7144,7145,4,7146,7148,8,7149,7149,4,7150,7150,8,7151,7155,4,7204,7211,8,7212,7219,4,7220,7221,8,7222,7223,4,7376,7378,4,7380,7392,4,7393,7393,8,7394,7400,4,7405,7405,4,7412,7412,4,7415,7415,8,7416,7417,4,7616,7679,4,8203,8203,3,8204,8204,4,8205,8205,5,8206,8207,3,8232,8238,3,8288,8303,3,8400,8432,4,11503,11505,4,11647,11647,4,11744,11775,4,12330,12335,4,12441,12442,4,42607,42610,4,42612,42621,4,42654,42655,4,42736,42737,4,43010,43010,4,43014,43014,4,43019,43019,4,43043,43044,8,43045,43046,4,43047,43047,8,43052,43052,4,43136,43137,8,43188,43203,8,43204,43205,4,43232,43249,4,43263,43263,4,43302,43309,4,43335,43345,4,43346,43346,8,43347,43347,4,43360,43388,9,43392,43394,4,43395,43395,8,43443,43443,4,43444,43445,8,43446,43449,4,43450,43451,8,43452,43453,4,43454,43455,8,43456,43456,4,43493,43493,4,43561,43566,4,43567,43568,8,43569,43570,4,43571,43572,8,43573,43574,4,43587,43587,4,43596,43596,4,43597,43597,8,43644,43644,4,43696,43696,4,43698,43700,4,43703,43704,4,43710,43711,4,43713,43713,4,43755,43755,8,43756,43757,4,43758,43759,8,43765,43765,8,43766,43766,4,44003,44004,8,44005,44005,4,44006,44007,8,44008,44008,4,44009,44010,8,44012,44012,8,44013,44013,4,44032,44032,12,44033,44059,13,44060,44060,12,44061,44087,13,44088,44088,12,44089,44115,13,44116,44116,12,44117,44143,13,44144,44144,12,44145,44171,13,44172,44172,12,44173,44199,13,44200,44200,12,44201,44227,13,44228,44228,12,44229,44255,13,44256,44256,12,44257,44283,13,44284,44284,12,44285,44311,13,44312,44312,12,44313,44339,13,44340,44340,12,44341,44367,13,44368,44368,12,44369,44395,13,44396,44396,12,44397,44423,13,44424,44424,12,44425,44451,13,44452,44452,12,44453,44479,13,44480,44480,12,44481,44507,13,44508,44508,12,44509,44535,13,44536,44536,12,44537,44563,13,44564,44564,12,44565,44591,13,44592,44592,12,44593,44619,13,44620,44620,12,44621,44647,13,44648,44648,12,44649,44675,13,44676,44676,12,44677,44703,13,44704,44704,12,44705,44731,13,44732,44732,12,44733,44759,13,44760,44760,12,44761,44787,13,44788,44788,12,44789,44815,13,44816,44816,12,44817,44843,13,44844,44844,12,44845,44871,13,44872,44872,12,44873,44899,13,44900,44900,12,44901,44927,13,44928,44928,12,44929,44955,13,44956,44956,12,44957,44983,13,44984,44984,12,44985,45011,13,45012,45012,12,45013,45039,13,45040,45040,12,45041,45067,13,45068,45068,12,45069,45095,13,45096,45096,12,45097,45123,13,45124,45124,12,45125,45151,13,45152,45152,12,45153,45179,13,45180,45180,12,45181,45207,13,45208,45208,12,45209,45235,13,45236,45236,12,45237,45263,13,45264,45264,12,45265,45291,13,45292,45292,12,45293,45319,13,45320,45320,12,45321,45347,13,45348,45348,12,45349,45375,13,45376,45376,12,45377,45403,13,45404,45404,12,45405,45431,13,45432,45432,12,45433,45459,13,45460,45460,12,45461,45487,13,45488,45488,12,45489,45515,13,45516,45516,12,45517,45543,13,45544,45544,12,45545,45571,13,45572,45572,12,45573,45599,13,45600,45600,12,45601,45627,13,45628,45628,12,45629,45655,13,45656,45656,12,45657,45683,13,45684,45684,12,45685,45711,13,45712,45712,12,45713,45739,13,45740,45740,12,45741,45767,13,45768,45768,12,45769,45795,13,45796,45796,12,45797,45823,13,45824,45824,12,45825,45851,13,45852,45852,12,45853,45879,13,45880,45880,12,45881,45907,13,45908,45908,12,45909,45935,13,45936,45936,12,45937,45963,13,45964,45964,12,45965,45991,13,45992,45992,12,45993,46019,13,46020,46020,12,46021,46047,13,46048,46048,12,46049,46075,13,46076,46076,12,46077,46103,13,46104,46104,12,46105,46131,13,46132,46132,12,46133,46159,13,46160,46160,12,46161,46187,13,46188,46188,12,46189,46215,13,46216,46216,12,46217,46243,13,46244,46244,12,46245,46271,13,46272,46272,12,46273,46299,13,46300,46300,12,46301,46327,13,46328,46328,12,46329,46355,13,46356,46356,12,46357,46383,13,46384,46384,12,46385,46411,13,46412,46412,12,46413,46439,13,46440,46440,12,46441,46467,13,46468,46468,12,46469,46495,13,46496,46496,12,46497,46523,13,46524,46524,12,46525,46551,13,46552,46552,12,46553,46579,13,46580,46580,12,46581,46607,13,46608,46608,12,46609,46635,13,46636,46636,12,46637,46663,13,46664,46664,12,46665,46691,13,46692,46692,12,46693,46719,13,46720,46720,12,46721,46747,13,46748,46748,12,46749,46775,13,46776,46776,12,46777,46803,13,46804,46804,12,46805,46831,13,46832,46832,12,46833,46859,13,46860,46860,12,46861,46887,13,46888,46888,12,46889,46915,13,46916,46916,12,46917,46943,13,46944,46944,12,46945,46971,13,46972,46972,12,46973,46999,13,47e3,47e3,12,47001,47027,13,47028,47028,12,47029,47055,13,47056,47056,12,47057,47083,13,47084,47084,12,47085,47111,13,47112,47112,12,47113,47139,13,47140,47140,12,47141,47167,13,47168,47168,12,47169,47195,13,47196,47196,12,47197,47223,13,47224,47224,12,47225,47251,13,47252,47252,12,47253,47279,13,47280,47280,12,47281,47307,13,47308,47308,12,47309,47335,13,47336,47336,12,47337,47363,13,47364,47364,12,47365,47391,13,47392,47392,12,47393,47419,13,47420,47420,12,47421,47447,13,47448,47448,12,47449,47475,13,47476,47476,12,47477,47503,13,47504,47504,12,47505,47531,13,47532,47532,12,47533,47559,13,47560,47560,12,47561,47587,13,47588,47588,12,47589,47615,13,47616,47616,12,47617,47643,13,47644,47644,12,47645,47671,13,47672,47672,12,47673,47699,13,47700,47700,12,47701,47727,13,47728,47728,12,47729,47755,13,47756,47756,12,47757,47783,13,47784,47784,12,47785,47811,13,47812,47812,12,47813,47839,13,47840,47840,12,47841,47867,13,47868,47868,12,47869,47895,13,47896,47896,12,47897,47923,13,47924,47924,12,47925,47951,13,47952,47952,12,47953,47979,13,47980,47980,12,47981,48007,13,48008,48008,12,48009,48035,13,48036,48036,12,48037,48063,13,48064,48064,12,48065,48091,13,48092,48092,12,48093,48119,13,48120,48120,12,48121,48147,13,48148,48148,12,48149,48175,13,48176,48176,12,48177,48203,13,48204,48204,12,48205,48231,13,48232,48232,12,48233,48259,13,48260,48260,12,48261,48287,13,48288,48288,12,48289,48315,13,48316,48316,12,48317,48343,13,48344,48344,12,48345,48371,13,48372,48372,12,48373,48399,13,48400,48400,12,48401,48427,13,48428,48428,12,48429,48455,13,48456,48456,12,48457,48483,13,48484,48484,12,48485,48511,13,48512,48512,12,48513,48539,13,48540,48540,12,48541,48567,13,48568,48568,12,48569,48595,13,48596,48596,12,48597,48623,13,48624,48624,12,48625,48651,13,48652,48652,12,48653,48679,13,48680,48680,12,48681,48707,13,48708,48708,12,48709,48735,13,48736,48736,12,48737,48763,13,48764,48764,12,48765,48791,13,48792,48792,12,48793,48819,13,48820,48820,12,48821,48847,13,48848,48848,12,48849,48875,13,48876,48876,12,48877,48903,13,48904,48904,12,48905,48931,13,48932,48932,12,48933,48959,13,48960,48960,12,48961,48987,13,48988,48988,12,48989,49015,13,49016,49016,12,49017,49043,13,49044,49044,12,49045,49071,13,49072,49072,12,49073,49099,13,49100,49100,12,49101,49127,13,49128,49128,12,49129,49155,13,49156,49156,12,49157,49183,13,49184,49184,12,49185,49211,13,49212,49212,12,49213,49239,13,49240,49240,12,49241,49267,13,49268,49268,12,49269,49295,13,49296,49296,12,49297,49323,13,49324,49324,12,49325,49351,13,49352,49352,12,49353,49379,13,49380,49380,12,49381,49407,13,49408,49408,12,49409,49435,13,49436,49436,12,49437,49463,13,49464,49464,12,49465,49491,13,49492,49492,12,49493,49519,13,49520,49520,12,49521,49547,13,49548,49548,12,49549,49575,13,49576,49576,12,49577,49603,13,49604,49604,12,49605,49631,13,49632,49632,12,49633,49659,13,49660,49660,12,49661,49687,13,49688,49688,12,49689,49715,13,49716,49716,12,49717,49743,13,49744,49744,12,49745,49771,13,49772,49772,12,49773,49799,13,49800,49800,12,49801,49827,13,49828,49828,12,49829,49855,13,49856,49856,12,49857,49883,13,49884,49884,12,49885,49911,13,49912,49912,12,49913,49939,13,49940,49940,12,49941,49967,13,49968,49968,12,49969,49995,13,49996,49996,12,49997,50023,13,50024,50024,12,50025,50051,13,50052,50052,12,50053,50079,13,50080,50080,12,50081,50107,13,50108,50108,12,50109,50135,13,50136,50136,12,50137,50163,13,50164,50164,12,50165,50191,13,50192,50192,12,50193,50219,13,50220,50220,12,50221,50247,13,50248,50248,12,50249,50275,13,50276,50276,12,50277,50303,13,50304,50304,12,50305,50331,13,50332,50332,12,50333,50359,13,50360,50360,12,50361,50387,13,50388,50388,12,50389,50415,13,50416,50416,12,50417,50443,13,50444,50444,12,50445,50471,13,50472,50472,12,50473,50499,13,50500,50500,12,50501,50527,13,50528,50528,12,50529,50555,13,50556,50556,12,50557,50583,13,50584,50584,12,50585,50611,13,50612,50612,12,50613,50639,13,50640,50640,12,50641,50667,13,50668,50668,12,50669,50695,13,50696,50696,12,50697,50723,13,50724,50724,12,50725,50751,13,50752,50752,12,50753,50779,13,50780,50780,12,50781,50807,13,50808,50808,12,50809,50835,13,50836,50836,12,50837,50863,13,50864,50864,12,50865,50891,13,50892,50892,12,50893,50919,13,50920,50920,12,50921,50947,13,50948,50948,12,50949,50975,13,50976,50976,12,50977,51003,13,51004,51004,12,51005,51031,13,51032,51032,12,51033,51059,13,51060,51060,12,51061,51087,13,51088,51088,12,51089,51115,13,51116,51116,12,51117,51143,13,51144,51144,12,51145,51171,13,51172,51172,12,51173,51199,13,51200,51200,12,51201,51227,13,51228,51228,12,51229,51255,13,51256,51256,12,51257,51283,13,51284,51284,12,51285,51311,13,51312,51312,12,51313,51339,13,51340,51340,12,51341,51367,13,51368,51368,12,51369,51395,13,51396,51396,12,51397,51423,13,51424,51424,12,51425,51451,13,51452,51452,12,51453,51479,13,51480,51480,12,51481,51507,13,51508,51508,12,51509,51535,13,51536,51536,12,51537,51563,13,51564,51564,12,51565,51591,13,51592,51592,12,51593,51619,13,51620,51620,12,51621,51647,13,51648,51648,12,51649,51675,13,51676,51676,12,51677,51703,13,51704,51704,12,51705,51731,13,51732,51732,12,51733,51759,13,51760,51760,12,51761,51787,13,51788,51788,12,51789,51815,13,51816,51816,12,51817,51843,13,51844,51844,12,51845,51871,13,51872,51872,12,51873,51899,13,51900,51900,12,51901,51927,13,51928,51928,12,51929,51955,13,51956,51956,12,51957,51983,13,51984,51984,12,51985,52011,13,52012,52012,12,52013,52039,13,52040,52040,12,52041,52067,13,52068,52068,12,52069,52095,13,52096,52096,12,52097,52123,13,52124,52124,12,52125,52151,13,52152,52152,12,52153,52179,13,52180,52180,12,52181,52207,13,52208,52208,12,52209,52235,13,52236,52236,12,52237,52263,13,52264,52264,12,52265,52291,13,52292,52292,12,52293,52319,13,52320,52320,12,52321,52347,13,52348,52348,12,52349,52375,13,52376,52376,12,52377,52403,13,52404,52404,12,52405,52431,13,52432,52432,12,52433,52459,13,52460,52460,12,52461,52487,13,52488,52488,12,52489,52515,13,52516,52516,12,52517,52543,13,52544,52544,12,52545,52571,13,52572,52572,12,52573,52599,13,52600,52600,12,52601,52627,13,52628,52628,12,52629,52655,13,52656,52656,12,52657,52683,13,52684,52684,12,52685,52711,13,52712,52712,12,52713,52739,13,52740,52740,12,52741,52767,13,52768,52768,12,52769,52795,13,52796,52796,12,52797,52823,13,52824,52824,12,52825,52851,13,52852,52852,12,52853,52879,13,52880,52880,12,52881,52907,13,52908,52908,12,52909,52935,13,52936,52936,12,52937,52963,13,52964,52964,12,52965,52991,13,52992,52992,12,52993,53019,13,53020,53020,12,53021,53047,13,53048,53048,12,53049,53075,13,53076,53076,12,53077,53103,13,53104,53104,12,53105,53131,13,53132,53132,12,53133,53159,13,53160,53160,12,53161,53187,13,53188,53188,12,53189,53215,13,53216,53216,12,53217,53243,13,53244,53244,12,53245,53271,13,53272,53272,12,53273,53299,13,53300,53300,12,53301,53327,13,53328,53328,12,53329,53355,13,53356,53356,12,53357,53383,13,53384,53384,12,53385,53411,13,53412,53412,12,53413,53439,13,53440,53440,12,53441,53467,13,53468,53468,12,53469,53495,13,53496,53496,12,53497,53523,13,53524,53524,12,53525,53551,13,53552,53552,12,53553,53579,13,53580,53580,12,53581,53607,13,53608,53608,12,53609,53635,13,53636,53636,12,53637,53663,13,53664,53664,12,53665,53691,13,53692,53692,12,53693,53719,13,53720,53720,12,53721,53747,13,53748,53748,12,53749,53775,13,53776,53776,12,53777,53803,13,53804,53804,12,53805,53831,13,53832,53832,12,53833,53859,13,53860,53860,12,53861,53887,13,53888,53888,12,53889,53915,13,53916,53916,12,53917,53943,13,53944,53944,12,53945,53971,13,53972,53972,12,53973,53999,13,54e3,54e3,12,54001,54027,13,54028,54028,12,54029,54055,13,54056,54056,12,54057,54083,13,54084,54084,12,54085,54111,13,54112,54112,12,54113,54139,13,54140,54140,12,54141,54167,13,54168,54168,12,54169,54195,13,54196,54196,12,54197,54223,13,54224,54224,12,54225,54251,13,54252,54252,12,54253,54279,13,54280,54280,12,54281,54307,13,54308,54308,12,54309,54335,13,54336,54336,12,54337,54363,13,54364,54364,12,54365,54391,13,54392,54392,12,54393,54419,13,54420,54420,12,54421,54447,13,54448,54448,12,54449,54475,13,54476,54476,12,54477,54503,13,54504,54504,12,54505,54531,13,54532,54532,12,54533,54559,13,54560,54560,12,54561,54587,13,54588,54588,12,54589,54615,13,54616,54616,12,54617,54643,13,54644,54644,12,54645,54671,13,54672,54672,12,54673,54699,13,54700,54700,12,54701,54727,13,54728,54728,12,54729,54755,13,54756,54756,12,54757,54783,13,54784,54784,12,54785,54811,13,54812,54812,12,54813,54839,13,54840,54840,12,54841,54867,13,54868,54868,12,54869,54895,13,54896,54896,12,54897,54923,13,54924,54924,12,54925,54951,13,54952,54952,12,54953,54979,13,54980,54980,12,54981,55007,13,55008,55008,12,55009,55035,13,55036,55036,12,55037,55063,13,55064,55064,12,55065,55091,13,55092,55092,12,55093,55119,13,55120,55120,12,55121,55147,13,55148,55148,12,55149,55175,13,55176,55176,12,55177,55203,13,55216,55238,10,55243,55291,11,64286,64286,4,65024,65039,4,65056,65071,4,65279,65279,3,65438,65439,4,65520,65531,3,66045,66045,4,66272,66272,4,66422,66426,4,68097,68099,4,68101,68102,4,68108,68111,4,68152,68154,4,68159,68159,4,68325,68326,4,68900,68903,4,68969,68973,4,69291,69292,4,69372,69375,4,69446,69456,4,69506,69509,4,69632,69632,8,69633,69633,4,69634,69634,8,69688,69702,4,69744,69744,4,69747,69748,4,69759,69761,4,69762,69762,8,69808,69810,8,69811,69814,4,69815,69816,8,69817,69818,4,69821,69821,7,69826,69826,4,69837,69837,7,69888,69890,4,69927,69931,4,69932,69932,8,69933,69940,4,69957,69958,8,70003,70003,4,70016,70017,4,70018,70018,8,70067,70069,8,70070,70078,4,70079,70079,8,70080,70080,4,70082,70083,7,70089,70092,4,70094,70094,8,70095,70095,4,70188,70190,8,70191,70193,4,70194,70195,8,70196,70199,4,70206,70206,4,70209,70209,4,70367,70367,4,70368,70370,8,70371,70378,4,70400,70401,4,70402,70403,8,70459,70460,4,70462,70462,4,70463,70463,8,70464,70464,4,70465,70468,8,70471,70472,8,70475,70476,8,70477,70477,4,70487,70487,4,70498,70499,8,70502,70508,4,70512,70516,4,70584,70584,4,70585,70586,8,70587,70592,4,70594,70594,4,70597,70597,4,70599,70601,4,70602,70602,8,70604,70605,8,70606,70608,4,70609,70609,7,70610,70610,4,70625,70626,4,70709,70711,8,70712,70719,4,70720,70721,8,70722,70724,4,70725,70725,8,70726,70726,4,70750,70750,4,70832,70832,4,70833,70834,8,70835,70840,4,70841,70841,8,70842,70842,4,70843,70844,8,70845,70845,4,70846,70846,8,70847,70848,4,70849,70849,8,70850,70851,4,71087,71087,4,71088,71089,8,71090,71093,4,71096,71099,8,71100,71101,4,71102,71102,8,71103,71104,4,71132,71133,4,71216,71218,8,71219,71226,4,71227,71228,8,71229,71229,4,71230,71230,8,71231,71232,4,71339,71339,4,71340,71340,8,71341,71341,4,71342,71343,8,71344,71351,4,71453,71453,4,71454,71454,8,71455,71455,4,71458,71461,4,71462,71462,8,71463,71467,4,71724,71726,8,71727,71735,4,71736,71736,8,71737,71738,4,71984,71984,4,71985,71989,8,71991,71992,8,71995,71998,4,71999,71999,7,72e3,72e3,8,72001,72001,7,72002,72002,8,72003,72003,4,72145,72147,8,72148,72151,4,72154,72155,4,72156,72159,8,72160,72160,4,72164,72164,8,72193,72202,4,72243,72248,4,72249,72249,8,72250,72250,7,72251,72254,4,72263,72263,4,72273,72278,4,72279,72280,8,72281,72283,4,72324,72329,7,72330,72342,4,72343,72343,8,72344,72345,4,72751,72751,8,72752,72758,4,72760,72765,4,72766,72766,8,72767,72767,4,72850,72871,4,72873,72873,8,72874,72880,4,72881,72881,8,72882,72883,4,72884,72884,8,72885,72886,4,73009,73014,4,73018,73018,4,73020,73021,4,73023,73029,4,73030,73030,7,73031,73031,4,73098,73102,8,73104,73105,4,73107,73108,8,73109,73109,4,73110,73110,8,73111,73111,4,73459,73460,4,73461,73462,8,73472,73473,4,73474,73474,7,73475,73475,8,73524,73525,8,73526,73530,4,73534,73535,8,73536,73538,4,73562,73562,4,78896,78911,3,78912,78912,4,78919,78933,4,90398,90409,4,90410,90412,8,90413,90415,4,92912,92916,4,92976,92982,4,93539,93539,10,93543,93546,10,94031,94031,4,94033,94087,8,94095,94098,4,94180,94180,4,94192,94193,4,113821,113822,4,113824,113827,3,118528,118573,4,118576,118598,4,119141,119145,4,119149,119154,4,119155,119162,3,119163,119170,4,119173,119179,4,119210,119213,4,119362,119364,4,121344,121398,4,121403,121452,4,121461,121461,4,121476,121476,4,121499,121503,4,121505,121519,4,122880,122886,4,122888,122904,4,122907,122913,4,122915,122916,4,122918,122922,4,123023,123023,4,123184,123190,4,123566,123566,4,123628,123631,4,124140,124143,4,124398,124399,4,125136,125142,4,125252,125258,4,127462,127487,6,127995,127999,4,917504,917535,3,917536,917631,4,917632,917759,3,917760,917999,4,918e3,921599,3],n=[169,169,1,174,174,1,8252,8252,1,8265,8265,1,8482,8482,1,8505,8505,1,8596,8601,1,8617,8618,1,8986,8987,1,9e3,9e3,1,9096,9096,1,9167,9167,1,9193,9203,1,9208,9210,1,9410,9410,1,9642,9643,1,9654,9654,1,9664,9664,1,9723,9726,1,9728,9733,1,9735,9746,1,9748,9861,1,9872,9989,1,9992,10002,1,10004,10004,1,10006,10006,1,10013,10013,1,10017,10017,1,10024,10024,1,10035,10036,1,10052,10052,1,10055,10055,1,10060,10060,1,10062,10062,1,10067,10069,1,10071,10071,1,10083,10087,1,10133,10135,1,10145,10145,1,10160,10160,1,10175,10175,1,10548,10549,1,11013,11015,1,11035,11036,1,11088,11088,1,11093,11093,1,12336,12336,1,12349,12349,1,12951,12951,1,12953,12953,1,126976,127231,1,127245,127247,1,127279,127279,1,127340,127345,1,127358,127359,1,127374,127374,1,127377,127386,1,127405,127461,1,127489,127503,1,127514,127514,1,127535,127535,1,127538,127546,1,127548,127551,1,127561,127994,1,128e3,128317,1,128326,128591,1,128640,128767,1,128884,128895,1,128981,129023,1,129036,129039,1,129096,129103,1,129114,129119,1,129160,129167,1,129198,129279,1,129292,129338,1,129340,129349,1,129351,129791,1,130048,131069,1],e=10,r=11;function i(t,n){let e=0,r=t.length/3-1;for(;e<=r;){const i=e+r>>1;if(n<t[3*i])r=i-1;else{if(!(n>t[3*i+1]))return t[3*i+2];e=i+1}}return 0}function o(n){return i(t,n)}function c(t){return 1===i(n,t)}function u(t,n){const e=t.charCodeAt(n);if(e>=55296&&e<=56319&&n+1<t.length){const r=t.charCodeAt(n+1);if(r>=56320&&r<=57343)return 1024*(e-55296)+(r-56320)+65536}return e}function f(t,n){const e=t.charCodeAt(n);if(e>=55296&&e<=56319&&n+1<t.length){const e=t.charCodeAt(n+1);if(e>=56320&&e<=57343)return 2}return 1}function l(t,n){const e=t.charCodeAt(n-1);if(e>=56320&&e<=57343&&n>=2){const e=t.charCodeAt(n-2);if(e>=55296&&e<=56319)return n-2}return n-1}function s(t){return 1===t||2===t||3===t}function h(t,n,i,o,u){return(1!==t||2!==u)&&(!!s(t)||(!!s(u)||(9!==t||9!==u&&u!==e&&12!==u&&13!==u)&&((12!==t&&t!==e||u!==e&&u!==r)&&((13!==t&&t!==r||u!==r)&&(4!==u&&5!==u&&(8!==u&&(7!==t&&((!i||!c(o))&&(6!==t||6!==u||!n)))))))))}function a(t,n,e){const r=t.pictChain&&5===e;return{pictChain:c(n)&&5!==e||t.pictChain&&4===e,pictZwj:r}}function d(t,n,e,r){const i=6===r&&(6!==n||!t.riOdd),o=a(t,e,r);return Object.assign({riOdd:i},o)}function p(t,n,e){if(n>=e)return{pictChain:!1,pictZwj:!1};let r=n;const i=u(t,r),l=o(i);let s={pictChain:c(i),pictZwj:!1},d=l;for(r+=f(t,r);r<e;){const n=u(t,r),e=o(n);s=h(d,!1,s.pictZwj,n,e)?{pictChain:c(n),pictZwj:!1}:a(s,n,e),d=e,r+=f(t,r)}return s}function g(t){if(!t)return 0;let n=0,e=0;for(;e<t.length;)e=C(t,e),n++;return n}function C(t,n=0){if(!t)return 0;if(!Number.isFinite(n)||n<0)return 0;if((n=Math.floor(n))>=t.length)return t.length;let i=function(t,n){if(n<=0)return 0;if(n>=t.length)return t.length;const e=t.charCodeAt(n-1);if(e>=55296&&e<=56319){const e=t.charCodeAt(n);if(e>=56320&&e<=57343)return n-1}return n}(t,n);i=function(t,n){for(;n>0;){const i=l(t,n),f=o(u(t,i)),h=u(t,n),a=o(h);let d;if(1===f&&2===a)d=!1;else if(s(f))d=!0;else if(s(a))d=!0;else if(9!==f||9!==a&&a!==e&&12!==a&&13!==a)if(12!==f&&f!==e||a!==e&&a!==r)if(13!==f&&f!==r||a!==r)if(4===a||5===a)d=!1;else if(8===a)d=!1;else if(7===f)d=!1;else if(6===a&&6===f){let n=1,e=l(t,i);for(;e>=0&&6===o(u(t,e));)n++,e=l(t,e);d=n%2==0}else if(c(h)&&5===f){let e=i;for(;e>0;){const n=l(t,e),r=o(u(t,n)),i=u(t,e),f=o(i);if(s(r)||s(f))break;if(4!==f&&5!==f&&8!==f&&!c(i)&&7!==r)break;e=n}d=!p(t,e,n).pictZwj}else d=!0;else d=!1;else d=!1;else d=!1;if(d)return n;n=i}return n}(t,i);const a=u(t,i),g=o(a);let C=g,j={riOdd:6===g,pictChain:c(a),pictZwj:!1};let b=i+f(t,i);for(;b<t.length;){const n=u(t,b),e=o(n);if(h(C,j.riOdd,j.pictZwj,n,e))return b;j=d(j,C,n,e),C=e,b+=f(t,b)}return t.length}function j(t){const n=[];let e=0;for(;e<t.length;){const r=C(t,e);n.push(t.slice(e,r)),e=r}return n}function b(t,n){return Number.isFinite(t)||(t=0),(t=Math.trunc(t))<0&&(t=n+t),t<0&&(t=0),t>n&&(t=n),t}function v(t,n=0,e){if(!t)return null!=t?t:"";const r=j(t),i=r.length,o=b(n,i),c=void 0===e?i:b(e,i);return c<=o?"":r.slice(o,c).join("")}function w(t){let n=0;return{next(){var e;if(n>=(null!==(e=null==t?void 0:t.length)&&void 0!==e?e:0))return{value:void 0,done:!0};const r=C(t,n),i=t.slice(n,r);return n=r,{value:i,done:!1}},[Symbol.iterator](){return this}}}function A(t,n){let e=0;for(const r of w(t))n(r,e++)}function Z(t,n){if(!t)return;if(!Number.isFinite(n))return;if((n=Math.trunc(n))<0){const e=j(t),r=e.length+n;return r>=0?e[r]:void 0}let e=0;for(const r of w(t)){if(e===n)return r;e++}}function m(t,n,e="..."){if(!t)return null!=t?t:"";Number.isFinite(n)||(n=0),n=Math.max(0,Math.trunc(n));const r=j(t);return r.length<=n?t:r.slice(0,n).join("")+e}export{A as Each,g as GetLength,w as Iterate,C as NextBreak,Z as Pick,v as Slice,j as Split,m as Truncate};
|
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 字素断点属性数据(Unicode 16.0.0)
|
|
3
|
+
* 由 scripts/gen-break-data.mjs 生成,请勿手工修改。
|
|
4
|
+
* 原始 Unicode 数据存档:scripts/GraphemeBreakProperty.txt, scripts/emoji-data.txt
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* 字素断点属性区间表:BREAK_TABLE
|
|
8
|
+
* 由 scripts/gen-break-data.mjs 从 Unicode 16.0.0 官方数据生成,请勿手工修改。
|
|
9
|
+
* 扁平结构 [start, end, type, ...],按 start 升序,类型编号见 src/feature.ts 常量。
|
|
10
|
+
*/
|
|
11
|
+
const BREAK_TABLE = [0, 9, 3, 10, 10, 2, 11, 12, 3, 13, 13, 1, 14, 31, 3, 127, 159, 3, 173, 173, 3, 768, 879, 4, 1155, 1161, 4, 1425, 1469, 4, 1471, 1471, 4, 1473, 1474, 4, 1476, 1477, 4, 1479, 1479, 4, 1536, 1541, 7, 1552, 1562, 4, 1564, 1564, 3, 1611, 1631, 4, 1648, 1648, 4, 1750, 1756, 4, 1757, 1757, 7, 1759, 1764, 4, 1767, 1768, 4, 1770, 1773, 4, 1807, 1807, 7, 1809, 1809, 4, 1840, 1866, 4, 1958, 1968, 4, 2027, 2035, 4, 2045, 2045, 4, 2070, 2073, 4, 2075, 2083, 4, 2085, 2087, 4, 2089, 2093, 4, 2137, 2139, 4, 2192, 2193, 7, 2199, 2207, 4, 2250, 2273, 4, 2274, 2274, 7, 2275, 2306, 4, 2307, 2307, 8, 2362, 2362, 4, 2363, 2363, 8, 2364, 2364, 4, 2366, 2368, 8, 2369, 2376, 4, 2377, 2380, 8, 2381, 2381, 4, 2382, 2383, 8, 2385, 2391, 4, 2402, 2403, 4, 2433, 2433, 4, 2434, 2435, 8, 2492, 2492, 4, 2494, 2494, 4, 2495, 2496, 8, 2497, 2500, 4, 2503, 2504, 8, 2507, 2508, 8, 2509, 2509, 4, 2519, 2519, 4, 2530, 2531, 4, 2558, 2558, 4, 2561, 2562, 4, 2563, 2563, 8, 2620, 2620, 4, 2622, 2624, 8, 2625, 2626, 4, 2631, 2632, 4, 2635, 2637, 4, 2641, 2641, 4, 2672, 2673, 4, 2677, 2677, 4, 2689, 2690, 4, 2691, 2691, 8, 2748, 2748, 4, 2750, 2752, 8, 2753, 2757, 4, 2759, 2760, 4, 2761, 2761, 8, 2763, 2764, 8, 2765, 2765, 4, 2786, 2787, 4, 2810, 2815, 4, 2817, 2817, 4, 2818, 2819, 8, 2876, 2876, 4, 2878, 2879, 4, 2880, 2880, 8, 2881, 2884, 4, 2887, 2888, 8, 2891, 2892, 8, 2893, 2893, 4, 2901, 2903, 4, 2914, 2915, 4, 2946, 2946, 4, 3006, 3006, 4, 3007, 3007, 8, 3008, 3008, 4, 3009, 3010, 8, 3014, 3016, 8, 3018, 3020, 8, 3021, 3021, 4, 3031, 3031, 4, 3072, 3072, 4, 3073, 3075, 8, 3076, 3076, 4, 3132, 3132, 4, 3134, 3136, 4, 3137, 3140, 8, 3142, 3144, 4, 3146, 3149, 4, 3157, 3158, 4, 3170, 3171, 4, 3201, 3201, 4, 3202, 3203, 8, 3260, 3260, 4, 3262, 3262, 8, 3263, 3264, 4, 3265, 3265, 8, 3266, 3266, 4, 3267, 3268, 8, 3270, 3272, 4, 3274, 3277, 4, 3285, 3286, 4, 3298, 3299, 4, 3315, 3315, 8, 3328, 3329, 4, 3330, 3331, 8, 3387, 3388, 4, 3390, 3390, 4, 3391, 3392, 8, 3393, 3396, 4, 3398, 3400, 8, 3402, 3404, 8, 3405, 3405, 4, 3406, 3406, 7, 3415, 3415, 4, 3426, 3427, 4, 3457, 3457, 4, 3458, 3459, 8, 3530, 3530, 4, 3535, 3535, 4, 3536, 3537, 8, 3538, 3540, 4, 3542, 3542, 4, 3544, 3550, 8, 3551, 3551, 4, 3570, 3571, 8, 3633, 3633, 4, 3635, 3635, 8, 3636, 3642, 4, 3655, 3662, 4, 3761, 3761, 4, 3763, 3763, 8, 3764, 3772, 4, 3784, 3790, 4, 3864, 3865, 4, 3893, 3893, 4, 3895, 3895, 4, 3897, 3897, 4, 3902, 3903, 8, 3953, 3966, 4, 3967, 3967, 8, 3968, 3972, 4, 3974, 3975, 4, 3981, 3991, 4, 3993, 4028, 4, 4038, 4038, 4, 4141, 4144, 4, 4145, 4145, 8, 4146, 4151, 4, 4153, 4154, 4, 4155, 4156, 8, 4157, 4158, 4, 4182, 4183, 8, 4184, 4185, 4, 4190, 4192, 4, 4209, 4212, 4, 4226, 4226, 4, 4228, 4228, 8, 4229, 4230, 4, 4237, 4237, 4, 4253, 4253, 4, 4352, 4447, 9, 4448, 4519, 10, 4520, 4607, 11, 4957, 4959, 4, 5906, 5909, 4, 5938, 5940, 4, 5970, 5971, 4, 6002, 6003, 4, 6068, 6069, 4, 6070, 6070, 8, 6071, 6077, 4, 6078, 6085, 8, 6086, 6086, 4, 6087, 6088, 8, 6089, 6099, 4, 6109, 6109, 4, 6155, 6157, 4, 6158, 6158, 3, 6159, 6159, 4, 6277, 6278, 4, 6313, 6313, 4, 6432, 6434, 4, 6435, 6438, 8, 6439, 6440, 4, 6441, 6443, 8, 6448, 6449, 8, 6450, 6450, 4, 6451, 6456, 8, 6457, 6459, 4, 6679, 6680, 4, 6681, 6682, 8, 6683, 6683, 4, 6741, 6741, 8, 6742, 6742, 4, 6743, 6743, 8, 6744, 6750, 4, 6752, 6752, 4, 6754, 6754, 4, 6757, 6764, 4, 6765, 6770, 8, 6771, 6780, 4, 6783, 6783, 4, 6832, 6862, 4, 6912, 6915, 4, 6916, 6916, 8, 6964, 6973, 4, 6974, 6977, 8, 6978, 6980, 4, 7019, 7027, 4, 7040, 7041, 4, 7042, 7042, 8, 7073, 7073, 8, 7074, 7077, 4, 7078, 7079, 8, 7080, 7085, 4, 7142, 7142, 4, 7143, 7143, 8, 7144, 7145, 4, 7146, 7148, 8, 7149, 7149, 4, 7150, 7150, 8, 7151, 7155, 4, 7204, 7211, 8, 7212, 7219, 4, 7220, 7221, 8, 7222, 7223, 4, 7376, 7378, 4, 7380, 7392, 4, 7393, 7393, 8, 7394, 7400, 4, 7405, 7405, 4, 7412, 7412, 4, 7415, 7415, 8, 7416, 7417, 4, 7616, 7679, 4, 8203, 8203, 3, 8204, 8204, 4, 8205, 8205, 5, 8206, 8207, 3, 8232, 8238, 3, 8288, 8303, 3, 8400, 8432, 4, 11503, 11505, 4, 11647, 11647, 4, 11744, 11775, 4, 12330, 12335, 4, 12441, 12442, 4, 42607, 42610, 4, 42612, 42621, 4, 42654, 42655, 4, 42736, 42737, 4, 43010, 43010, 4, 43014, 43014, 4, 43019, 43019, 4, 43043, 43044, 8, 43045, 43046, 4, 43047, 43047, 8, 43052, 43052, 4, 43136, 43137, 8, 43188, 43203, 8, 43204, 43205, 4, 43232, 43249, 4, 43263, 43263, 4, 43302, 43309, 4, 43335, 43345, 4, 43346, 43346, 8, 43347, 43347, 4, 43360, 43388, 9, 43392, 43394, 4, 43395, 43395, 8, 43443, 43443, 4, 43444, 43445, 8, 43446, 43449, 4, 43450, 43451, 8, 43452, 43453, 4, 43454, 43455, 8, 43456, 43456, 4, 43493, 43493, 4, 43561, 43566, 4, 43567, 43568, 8, 43569, 43570, 4, 43571, 43572, 8, 43573, 43574, 4, 43587, 43587, 4, 43596, 43596, 4, 43597, 43597, 8, 43644, 43644, 4, 43696, 43696, 4, 43698, 43700, 4, 43703, 43704, 4, 43710, 43711, 4, 43713, 43713, 4, 43755, 43755, 8, 43756, 43757, 4, 43758, 43759, 8, 43765, 43765, 8, 43766, 43766, 4, 44003, 44004, 8, 44005, 44005, 4, 44006, 44007, 8, 44008, 44008, 4, 44009, 44010, 8, 44012, 44012, 8, 44013, 44013, 4, 44032, 44032, 12, 44033, 44059, 13, 44060, 44060, 12, 44061, 44087, 13, 44088, 44088, 12, 44089, 44115, 13, 44116, 44116, 12, 44117, 44143, 13, 44144, 44144, 12, 44145, 44171, 13, 44172, 44172, 12, 44173, 44199, 13, 44200, 44200, 12, 44201, 44227, 13, 44228, 44228, 12, 44229, 44255, 13, 44256, 44256, 12, 44257, 44283, 13, 44284, 44284, 12, 44285, 44311, 13, 44312, 44312, 12, 44313, 44339, 13, 44340, 44340, 12, 44341, 44367, 13, 44368, 44368, 12, 44369, 44395, 13, 44396, 44396, 12, 44397, 44423, 13, 44424, 44424, 12, 44425, 44451, 13, 44452, 44452, 12, 44453, 44479, 13, 44480, 44480, 12, 44481, 44507, 13, 44508, 44508, 12, 44509, 44535, 13, 44536, 44536, 12, 44537, 44563, 13, 44564, 44564, 12, 44565, 44591, 13, 44592, 44592, 12, 44593, 44619, 13, 44620, 44620, 12, 44621, 44647, 13, 44648, 44648, 12, 44649, 44675, 13, 44676, 44676, 12, 44677, 44703, 13, 44704, 44704, 12, 44705, 44731, 13, 44732, 44732, 12, 44733, 44759, 13, 44760, 44760, 12, 44761, 44787, 13, 44788, 44788, 12, 44789, 44815, 13, 44816, 44816, 12, 44817, 44843, 13, 44844, 44844, 12, 44845, 44871, 13, 44872, 44872, 12, 44873, 44899, 13, 44900, 44900, 12, 44901, 44927, 13, 44928, 44928, 12, 44929, 44955, 13, 44956, 44956, 12, 44957, 44983, 13, 44984, 44984, 12, 44985, 45011, 13, 45012, 45012, 12, 45013, 45039, 13, 45040, 45040, 12, 45041, 45067, 13, 45068, 45068, 12, 45069, 45095, 13, 45096, 45096, 12, 45097, 45123, 13, 45124, 45124, 12, 45125, 45151, 13, 45152, 45152, 12, 45153, 45179, 13, 45180, 45180, 12, 45181, 45207, 13, 45208, 45208, 12, 45209, 45235, 13, 45236, 45236, 12, 45237, 45263, 13, 45264, 45264, 12, 45265, 45291, 13, 45292, 45292, 12, 45293, 45319, 13, 45320, 45320, 12, 45321, 45347, 13, 45348, 45348, 12, 45349, 45375, 13, 45376, 45376, 12, 45377, 45403, 13, 45404, 45404, 12, 45405, 45431, 13, 45432, 45432, 12, 45433, 45459, 13, 45460, 45460, 12, 45461, 45487, 13, 45488, 45488, 12, 45489, 45515, 13, 45516, 45516, 12, 45517, 45543, 13, 45544, 45544, 12, 45545, 45571, 13, 45572, 45572, 12, 45573, 45599, 13, 45600, 45600, 12, 45601, 45627, 13, 45628, 45628, 12, 45629, 45655, 13, 45656, 45656, 12, 45657, 45683, 13, 45684, 45684, 12, 45685, 45711, 13, 45712, 45712, 12, 45713, 45739, 13, 45740, 45740, 12, 45741, 45767, 13, 45768, 45768, 12, 45769, 45795, 13, 45796, 45796, 12, 45797, 45823, 13, 45824, 45824, 12, 45825, 45851, 13, 45852, 45852, 12, 45853, 45879, 13, 45880, 45880, 12, 45881, 45907, 13, 45908, 45908, 12, 45909, 45935, 13, 45936, 45936, 12, 45937, 45963, 13, 45964, 45964, 12, 45965, 45991, 13, 45992, 45992, 12, 45993, 46019, 13, 46020, 46020, 12, 46021, 46047, 13, 46048, 46048, 12, 46049, 46075, 13, 46076, 46076, 12, 46077, 46103, 13, 46104, 46104, 12, 46105, 46131, 13, 46132, 46132, 12, 46133, 46159, 13, 46160, 46160, 12, 46161, 46187, 13, 46188, 46188, 12, 46189, 46215, 13, 46216, 46216, 12, 46217, 46243, 13, 46244, 46244, 12, 46245, 46271, 13, 46272, 46272, 12, 46273, 46299, 13, 46300, 46300, 12, 46301, 46327, 13, 46328, 46328, 12, 46329, 46355, 13, 46356, 46356, 12, 46357, 46383, 13, 46384, 46384, 12, 46385, 46411, 13, 46412, 46412, 12, 46413, 46439, 13, 46440, 46440, 12, 46441, 46467, 13, 46468, 46468, 12, 46469, 46495, 13, 46496, 46496, 12, 46497, 46523, 13, 46524, 46524, 12, 46525, 46551, 13, 46552, 46552, 12, 46553, 46579, 13, 46580, 46580, 12, 46581, 46607, 13, 46608, 46608, 12, 46609, 46635, 13, 46636, 46636, 12, 46637, 46663, 13, 46664, 46664, 12, 46665, 46691, 13, 46692, 46692, 12, 46693, 46719, 13, 46720, 46720, 12, 46721, 46747, 13, 46748, 46748, 12, 46749, 46775, 13, 46776, 46776, 12, 46777, 46803, 13, 46804, 46804, 12, 46805, 46831, 13, 46832, 46832, 12, 46833, 46859, 13, 46860, 46860, 12, 46861, 46887, 13, 46888, 46888, 12, 46889, 46915, 13, 46916, 46916, 12, 46917, 46943, 13, 46944, 46944, 12, 46945, 46971, 13, 46972, 46972, 12, 46973, 46999, 13, 47000, 47000, 12, 47001, 47027, 13, 47028, 47028, 12, 47029, 47055, 13, 47056, 47056, 12, 47057, 47083, 13, 47084, 47084, 12, 47085, 47111, 13, 47112, 47112, 12, 47113, 47139, 13, 47140, 47140, 12, 47141, 47167, 13, 47168, 47168, 12, 47169, 47195, 13, 47196, 47196, 12, 47197, 47223, 13, 47224, 47224, 12, 47225, 47251, 13, 47252, 47252, 12, 47253, 47279, 13, 47280, 47280, 12, 47281, 47307, 13, 47308, 47308, 12, 47309, 47335, 13, 47336, 47336, 12, 47337, 47363, 13, 47364, 47364, 12, 47365, 47391, 13, 47392, 47392, 12, 47393, 47419, 13, 47420, 47420, 12, 47421, 47447, 13, 47448, 47448, 12, 47449, 47475, 13, 47476, 47476, 12, 47477, 47503, 13, 47504, 47504, 12, 47505, 47531, 13, 47532, 47532, 12, 47533, 47559, 13, 47560, 47560, 12, 47561, 47587, 13, 47588, 47588, 12, 47589, 47615, 13, 47616, 47616, 12, 47617, 47643, 13, 47644, 47644, 12, 47645, 47671, 13, 47672, 47672, 12, 47673, 47699, 13, 47700, 47700, 12, 47701, 47727, 13, 47728, 47728, 12, 47729, 47755, 13, 47756, 47756, 12, 47757, 47783, 13, 47784, 47784, 12, 47785, 47811, 13, 47812, 47812, 12, 47813, 47839, 13, 47840, 47840, 12, 47841, 47867, 13, 47868, 47868, 12, 47869, 47895, 13, 47896, 47896, 12, 47897, 47923, 13, 47924, 47924, 12, 47925, 47951, 13, 47952, 47952, 12, 47953, 47979, 13, 47980, 47980, 12, 47981, 48007, 13, 48008, 48008, 12, 48009, 48035, 13, 48036, 48036, 12, 48037, 48063, 13, 48064, 48064, 12, 48065, 48091, 13, 48092, 48092, 12, 48093, 48119, 13, 48120, 48120, 12, 48121, 48147, 13, 48148, 48148, 12, 48149, 48175, 13, 48176, 48176, 12, 48177, 48203, 13, 48204, 48204, 12, 48205, 48231, 13, 48232, 48232, 12, 48233, 48259, 13, 48260, 48260, 12, 48261, 48287, 13, 48288, 48288, 12, 48289, 48315, 13, 48316, 48316, 12, 48317, 48343, 13, 48344, 48344, 12, 48345, 48371, 13, 48372, 48372, 12, 48373, 48399, 13, 48400, 48400, 12, 48401, 48427, 13, 48428, 48428, 12, 48429, 48455, 13, 48456, 48456, 12, 48457, 48483, 13, 48484, 48484, 12, 48485, 48511, 13, 48512, 48512, 12, 48513, 48539, 13, 48540, 48540, 12, 48541, 48567, 13, 48568, 48568, 12, 48569, 48595, 13, 48596, 48596, 12, 48597, 48623, 13, 48624, 48624, 12, 48625, 48651, 13, 48652, 48652, 12, 48653, 48679, 13, 48680, 48680, 12, 48681, 48707, 13, 48708, 48708, 12, 48709, 48735, 13, 48736, 48736, 12, 48737, 48763, 13, 48764, 48764, 12, 48765, 48791, 13, 48792, 48792, 12, 48793, 48819, 13, 48820, 48820, 12, 48821, 48847, 13, 48848, 48848, 12, 48849, 48875, 13, 48876, 48876, 12, 48877, 48903, 13, 48904, 48904, 12, 48905, 48931, 13, 48932, 48932, 12, 48933, 48959, 13, 48960, 48960, 12, 48961, 48987, 13, 48988, 48988, 12, 48989, 49015, 13, 49016, 49016, 12, 49017, 49043, 13, 49044, 49044, 12, 49045, 49071, 13, 49072, 49072, 12, 49073, 49099, 13, 49100, 49100, 12, 49101, 49127, 13, 49128, 49128, 12, 49129, 49155, 13, 49156, 49156, 12, 49157, 49183, 13, 49184, 49184, 12, 49185, 49211, 13, 49212, 49212, 12, 49213, 49239, 13, 49240, 49240, 12, 49241, 49267, 13, 49268, 49268, 12, 49269, 49295, 13, 49296, 49296, 12, 49297, 49323, 13, 49324, 49324, 12, 49325, 49351, 13, 49352, 49352, 12, 49353, 49379, 13, 49380, 49380, 12, 49381, 49407, 13, 49408, 49408, 12, 49409, 49435, 13, 49436, 49436, 12, 49437, 49463, 13, 49464, 49464, 12, 49465, 49491, 13, 49492, 49492, 12, 49493, 49519, 13, 49520, 49520, 12, 49521, 49547, 13, 49548, 49548, 12, 49549, 49575, 13, 49576, 49576, 12, 49577, 49603, 13, 49604, 49604, 12, 49605, 49631, 13, 49632, 49632, 12, 49633, 49659, 13, 49660, 49660, 12, 49661, 49687, 13, 49688, 49688, 12, 49689, 49715, 13, 49716, 49716, 12, 49717, 49743, 13, 49744, 49744, 12, 49745, 49771, 13, 49772, 49772, 12, 49773, 49799, 13, 49800, 49800, 12, 49801, 49827, 13, 49828, 49828, 12, 49829, 49855, 13, 49856, 49856, 12, 49857, 49883, 13, 49884, 49884, 12, 49885, 49911, 13, 49912, 49912, 12, 49913, 49939, 13, 49940, 49940, 12, 49941, 49967, 13, 49968, 49968, 12, 49969, 49995, 13, 49996, 49996, 12, 49997, 50023, 13, 50024, 50024, 12, 50025, 50051, 13, 50052, 50052, 12, 50053, 50079, 13, 50080, 50080, 12, 50081, 50107, 13, 50108, 50108, 12, 50109, 50135, 13, 50136, 50136, 12, 50137, 50163, 13, 50164, 50164, 12, 50165, 50191, 13, 50192, 50192, 12, 50193, 50219, 13, 50220, 50220, 12, 50221, 50247, 13, 50248, 50248, 12, 50249, 50275, 13, 50276, 50276, 12, 50277, 50303, 13, 50304, 50304, 12, 50305, 50331, 13, 50332, 50332, 12, 50333, 50359, 13, 50360, 50360, 12, 50361, 50387, 13, 50388, 50388, 12, 50389, 50415, 13, 50416, 50416, 12, 50417, 50443, 13, 50444, 50444, 12, 50445, 50471, 13, 50472, 50472, 12, 50473, 50499, 13, 50500, 50500, 12, 50501, 50527, 13, 50528, 50528, 12, 50529, 50555, 13, 50556, 50556, 12, 50557, 50583, 13, 50584, 50584, 12, 50585, 50611, 13, 50612, 50612, 12, 50613, 50639, 13, 50640, 50640, 12, 50641, 50667, 13, 50668, 50668, 12, 50669, 50695, 13, 50696, 50696, 12, 50697, 50723, 13, 50724, 50724, 12, 50725, 50751, 13, 50752, 50752, 12, 50753, 50779, 13, 50780, 50780, 12, 50781, 50807, 13, 50808, 50808, 12, 50809, 50835, 13, 50836, 50836, 12, 50837, 50863, 13, 50864, 50864, 12, 50865, 50891, 13, 50892, 50892, 12, 50893, 50919, 13, 50920, 50920, 12, 50921, 50947, 13, 50948, 50948, 12, 50949, 50975, 13, 50976, 50976, 12, 50977, 51003, 13, 51004, 51004, 12, 51005, 51031, 13, 51032, 51032, 12, 51033, 51059, 13, 51060, 51060, 12, 51061, 51087, 13, 51088, 51088, 12, 51089, 51115, 13, 51116, 51116, 12, 51117, 51143, 13, 51144, 51144, 12, 51145, 51171, 13, 51172, 51172, 12, 51173, 51199, 13, 51200, 51200, 12, 51201, 51227, 13, 51228, 51228, 12, 51229, 51255, 13, 51256, 51256, 12, 51257, 51283, 13, 51284, 51284, 12, 51285, 51311, 13, 51312, 51312, 12, 51313, 51339, 13, 51340, 51340, 12, 51341, 51367, 13, 51368, 51368, 12, 51369, 51395, 13, 51396, 51396, 12, 51397, 51423, 13, 51424, 51424, 12, 51425, 51451, 13, 51452, 51452, 12, 51453, 51479, 13, 51480, 51480, 12, 51481, 51507, 13, 51508, 51508, 12, 51509, 51535, 13, 51536, 51536, 12, 51537, 51563, 13, 51564, 51564, 12, 51565, 51591, 13, 51592, 51592, 12, 51593, 51619, 13, 51620, 51620, 12, 51621, 51647, 13, 51648, 51648, 12, 51649, 51675, 13, 51676, 51676, 12, 51677, 51703, 13, 51704, 51704, 12, 51705, 51731, 13, 51732, 51732, 12, 51733, 51759, 13, 51760, 51760, 12, 51761, 51787, 13, 51788, 51788, 12, 51789, 51815, 13, 51816, 51816, 12, 51817, 51843, 13, 51844, 51844, 12, 51845, 51871, 13, 51872, 51872, 12, 51873, 51899, 13, 51900, 51900, 12, 51901, 51927, 13, 51928, 51928, 12, 51929, 51955, 13, 51956, 51956, 12, 51957, 51983, 13, 51984, 51984, 12, 51985, 52011, 13, 52012, 52012, 12, 52013, 52039, 13, 52040, 52040, 12, 52041, 52067, 13, 52068, 52068, 12, 52069, 52095, 13, 52096, 52096, 12, 52097, 52123, 13, 52124, 52124, 12, 52125, 52151, 13, 52152, 52152, 12, 52153, 52179, 13, 52180, 52180, 12, 52181, 52207, 13, 52208, 52208, 12, 52209, 52235, 13, 52236, 52236, 12, 52237, 52263, 13, 52264, 52264, 12, 52265, 52291, 13, 52292, 52292, 12, 52293, 52319, 13, 52320, 52320, 12, 52321, 52347, 13, 52348, 52348, 12, 52349, 52375, 13, 52376, 52376, 12, 52377, 52403, 13, 52404, 52404, 12, 52405, 52431, 13, 52432, 52432, 12, 52433, 52459, 13, 52460, 52460, 12, 52461, 52487, 13, 52488, 52488, 12, 52489, 52515, 13, 52516, 52516, 12, 52517, 52543, 13, 52544, 52544, 12, 52545, 52571, 13, 52572, 52572, 12, 52573, 52599, 13, 52600, 52600, 12, 52601, 52627, 13, 52628, 52628, 12, 52629, 52655, 13, 52656, 52656, 12, 52657, 52683, 13, 52684, 52684, 12, 52685, 52711, 13, 52712, 52712, 12, 52713, 52739, 13, 52740, 52740, 12, 52741, 52767, 13, 52768, 52768, 12, 52769, 52795, 13, 52796, 52796, 12, 52797, 52823, 13, 52824, 52824, 12, 52825, 52851, 13, 52852, 52852, 12, 52853, 52879, 13, 52880, 52880, 12, 52881, 52907, 13, 52908, 52908, 12, 52909, 52935, 13, 52936, 52936, 12, 52937, 52963, 13, 52964, 52964, 12, 52965, 52991, 13, 52992, 52992, 12, 52993, 53019, 13, 53020, 53020, 12, 53021, 53047, 13, 53048, 53048, 12, 53049, 53075, 13, 53076, 53076, 12, 53077, 53103, 13, 53104, 53104, 12, 53105, 53131, 13, 53132, 53132, 12, 53133, 53159, 13, 53160, 53160, 12, 53161, 53187, 13, 53188, 53188, 12, 53189, 53215, 13, 53216, 53216, 12, 53217, 53243, 13, 53244, 53244, 12, 53245, 53271, 13, 53272, 53272, 12, 53273, 53299, 13, 53300, 53300, 12, 53301, 53327, 13, 53328, 53328, 12, 53329, 53355, 13, 53356, 53356, 12, 53357, 53383, 13, 53384, 53384, 12, 53385, 53411, 13, 53412, 53412, 12, 53413, 53439, 13, 53440, 53440, 12, 53441, 53467, 13, 53468, 53468, 12, 53469, 53495, 13, 53496, 53496, 12, 53497, 53523, 13, 53524, 53524, 12, 53525, 53551, 13, 53552, 53552, 12, 53553, 53579, 13, 53580, 53580, 12, 53581, 53607, 13, 53608, 53608, 12, 53609, 53635, 13, 53636, 53636, 12, 53637, 53663, 13, 53664, 53664, 12, 53665, 53691, 13, 53692, 53692, 12, 53693, 53719, 13, 53720, 53720, 12, 53721, 53747, 13, 53748, 53748, 12, 53749, 53775, 13, 53776, 53776, 12, 53777, 53803, 13, 53804, 53804, 12, 53805, 53831, 13, 53832, 53832, 12, 53833, 53859, 13, 53860, 53860, 12, 53861, 53887, 13, 53888, 53888, 12, 53889, 53915, 13, 53916, 53916, 12, 53917, 53943, 13, 53944, 53944, 12, 53945, 53971, 13, 53972, 53972, 12, 53973, 53999, 13, 54000, 54000, 12, 54001, 54027, 13, 54028, 54028, 12, 54029, 54055, 13, 54056, 54056, 12, 54057, 54083, 13, 54084, 54084, 12, 54085, 54111, 13, 54112, 54112, 12, 54113, 54139, 13, 54140, 54140, 12, 54141, 54167, 13, 54168, 54168, 12, 54169, 54195, 13, 54196, 54196, 12, 54197, 54223, 13, 54224, 54224, 12, 54225, 54251, 13, 54252, 54252, 12, 54253, 54279, 13, 54280, 54280, 12, 54281, 54307, 13, 54308, 54308, 12, 54309, 54335, 13, 54336, 54336, 12, 54337, 54363, 13, 54364, 54364, 12, 54365, 54391, 13, 54392, 54392, 12, 54393, 54419, 13, 54420, 54420, 12, 54421, 54447, 13, 54448, 54448, 12, 54449, 54475, 13, 54476, 54476, 12, 54477, 54503, 13, 54504, 54504, 12, 54505, 54531, 13, 54532, 54532, 12, 54533, 54559, 13, 54560, 54560, 12, 54561, 54587, 13, 54588, 54588, 12, 54589, 54615, 13, 54616, 54616, 12, 54617, 54643, 13, 54644, 54644, 12, 54645, 54671, 13, 54672, 54672, 12, 54673, 54699, 13, 54700, 54700, 12, 54701, 54727, 13, 54728, 54728, 12, 54729, 54755, 13, 54756, 54756, 12, 54757, 54783, 13, 54784, 54784, 12, 54785, 54811, 13, 54812, 54812, 12, 54813, 54839, 13, 54840, 54840, 12, 54841, 54867, 13, 54868, 54868, 12, 54869, 54895, 13, 54896, 54896, 12, 54897, 54923, 13, 54924, 54924, 12, 54925, 54951, 13, 54952, 54952, 12, 54953, 54979, 13, 54980, 54980, 12, 54981, 55007, 13, 55008, 55008, 12, 55009, 55035, 13, 55036, 55036, 12, 55037, 55063, 13, 55064, 55064, 12, 55065, 55091, 13, 55092, 55092, 12, 55093, 55119, 13, 55120, 55120, 12, 55121, 55147, 13, 55148, 55148, 12, 55149, 55175, 13, 55176, 55176, 12, 55177, 55203, 13, 55216, 55238, 10, 55243, 55291, 11, 64286, 64286, 4, 65024, 65039, 4, 65056, 65071, 4, 65279, 65279, 3, 65438, 65439, 4, 65520, 65531, 3, 66045, 66045, 4, 66272, 66272, 4, 66422, 66426, 4, 68097, 68099, 4, 68101, 68102, 4, 68108, 68111, 4, 68152, 68154, 4, 68159, 68159, 4, 68325, 68326, 4, 68900, 68903, 4, 68969, 68973, 4, 69291, 69292, 4, 69372, 69375, 4, 69446, 69456, 4, 69506, 69509, 4, 69632, 69632, 8, 69633, 69633, 4, 69634, 69634, 8, 69688, 69702, 4, 69744, 69744, 4, 69747, 69748, 4, 69759, 69761, 4, 69762, 69762, 8, 69808, 69810, 8, 69811, 69814, 4, 69815, 69816, 8, 69817, 69818, 4, 69821, 69821, 7, 69826, 69826, 4, 69837, 69837, 7, 69888, 69890, 4, 69927, 69931, 4, 69932, 69932, 8, 69933, 69940, 4, 69957, 69958, 8, 70003, 70003, 4, 70016, 70017, 4, 70018, 70018, 8, 70067, 70069, 8, 70070, 70078, 4, 70079, 70079, 8, 70080, 70080, 4, 70082, 70083, 7, 70089, 70092, 4, 70094, 70094, 8, 70095, 70095, 4, 70188, 70190, 8, 70191, 70193, 4, 70194, 70195, 8, 70196, 70199, 4, 70206, 70206, 4, 70209, 70209, 4, 70367, 70367, 4, 70368, 70370, 8, 70371, 70378, 4, 70400, 70401, 4, 70402, 70403, 8, 70459, 70460, 4, 70462, 70462, 4, 70463, 70463, 8, 70464, 70464, 4, 70465, 70468, 8, 70471, 70472, 8, 70475, 70476, 8, 70477, 70477, 4, 70487, 70487, 4, 70498, 70499, 8, 70502, 70508, 4, 70512, 70516, 4, 70584, 70584, 4, 70585, 70586, 8, 70587, 70592, 4, 70594, 70594, 4, 70597, 70597, 4, 70599, 70601, 4, 70602, 70602, 8, 70604, 70605, 8, 70606, 70608, 4, 70609, 70609, 7, 70610, 70610, 4, 70625, 70626, 4, 70709, 70711, 8, 70712, 70719, 4, 70720, 70721, 8, 70722, 70724, 4, 70725, 70725, 8, 70726, 70726, 4, 70750, 70750, 4, 70832, 70832, 4, 70833, 70834, 8, 70835, 70840, 4, 70841, 70841, 8, 70842, 70842, 4, 70843, 70844, 8, 70845, 70845, 4, 70846, 70846, 8, 70847, 70848, 4, 70849, 70849, 8, 70850, 70851, 4, 71087, 71087, 4, 71088, 71089, 8, 71090, 71093, 4, 71096, 71099, 8, 71100, 71101, 4, 71102, 71102, 8, 71103, 71104, 4, 71132, 71133, 4, 71216, 71218, 8, 71219, 71226, 4, 71227, 71228, 8, 71229, 71229, 4, 71230, 71230, 8, 71231, 71232, 4, 71339, 71339, 4, 71340, 71340, 8, 71341, 71341, 4, 71342, 71343, 8, 71344, 71351, 4, 71453, 71453, 4, 71454, 71454, 8, 71455, 71455, 4, 71458, 71461, 4, 71462, 71462, 8, 71463, 71467, 4, 71724, 71726, 8, 71727, 71735, 4, 71736, 71736, 8, 71737, 71738, 4, 71984, 71984, 4, 71985, 71989, 8, 71991, 71992, 8, 71995, 71998, 4, 71999, 71999, 7, 72000, 72000, 8, 72001, 72001, 7, 72002, 72002, 8, 72003, 72003, 4, 72145, 72147, 8, 72148, 72151, 4, 72154, 72155, 4, 72156, 72159, 8, 72160, 72160, 4, 72164, 72164, 8, 72193, 72202, 4, 72243, 72248, 4, 72249, 72249, 8, 72250, 72250, 7, 72251, 72254, 4, 72263, 72263, 4, 72273, 72278, 4, 72279, 72280, 8, 72281, 72283, 4, 72324, 72329, 7, 72330, 72342, 4, 72343, 72343, 8, 72344, 72345, 4, 72751, 72751, 8, 72752, 72758, 4, 72760, 72765, 4, 72766, 72766, 8, 72767, 72767, 4, 72850, 72871, 4, 72873, 72873, 8, 72874, 72880, 4, 72881, 72881, 8, 72882, 72883, 4, 72884, 72884, 8, 72885, 72886, 4, 73009, 73014, 4, 73018, 73018, 4, 73020, 73021, 4, 73023, 73029, 4, 73030, 73030, 7, 73031, 73031, 4, 73098, 73102, 8, 73104, 73105, 4, 73107, 73108, 8, 73109, 73109, 4, 73110, 73110, 8, 73111, 73111, 4, 73459, 73460, 4, 73461, 73462, 8, 73472, 73473, 4, 73474, 73474, 7, 73475, 73475, 8, 73524, 73525, 8, 73526, 73530, 4, 73534, 73535, 8, 73536, 73538, 4, 73562, 73562, 4, 78896, 78911, 3, 78912, 78912, 4, 78919, 78933, 4, 90398, 90409, 4, 90410, 90412, 8, 90413, 90415, 4, 92912, 92916, 4, 92976, 92982, 4, 93539, 93539, 10, 93543, 93546, 10, 94031, 94031, 4, 94033, 94087, 8, 94095, 94098, 4, 94180, 94180, 4, 94192, 94193, 4, 113821, 113822, 4, 113824, 113827, 3, 118528, 118573, 4, 118576, 118598, 4, 119141, 119145, 4, 119149, 119154, 4, 119155, 119162, 3, 119163, 119170, 4, 119173, 119179, 4, 119210, 119213, 4, 119362, 119364, 4, 121344, 121398, 4, 121403, 121452, 4, 121461, 121461, 4, 121476, 121476, 4, 121499, 121503, 4, 121505, 121519, 4, 122880, 122886, 4, 122888, 122904, 4, 122907, 122913, 4, 122915, 122916, 4, 122918, 122922, 4, 123023, 123023, 4, 123184, 123190, 4, 123566, 123566, 4, 123628, 123631, 4, 124140, 124143, 4, 124398, 124399, 4, 125136, 125142, 4, 125252, 125258, 4, 127462, 127487, 6, 127995, 127999, 4, 917504, 917535, 3, 917536, 917631, 4, 917632, 917759, 3, 917760, 917999, 4, 918000, 921599, 3];
|
|
12
|
+
/**
|
|
13
|
+
* 字素断点属性区间表:EXT_PICT_TABLE
|
|
14
|
+
* 由 scripts/gen-break-data.mjs 从 Unicode 16.0.0 官方数据生成,请勿手工修改。
|
|
15
|
+
* 扁平结构 [start, end, type, ...],按 start 升序,类型编号见 src/feature.ts 常量。
|
|
16
|
+
*/
|
|
17
|
+
const EXT_PICT_TABLE = [169, 169, 1, 174, 174, 1, 8252, 8252, 1, 8265, 8265, 1, 8482, 8482, 1, 8505, 8505, 1, 8596, 8601, 1, 8617, 8618, 1, 8986, 8987, 1, 9000, 9000, 1, 9096, 9096, 1, 9167, 9167, 1, 9193, 9203, 1, 9208, 9210, 1, 9410, 9410, 1, 9642, 9643, 1, 9654, 9654, 1, 9664, 9664, 1, 9723, 9726, 1, 9728, 9733, 1, 9735, 9746, 1, 9748, 9861, 1, 9872, 9989, 1, 9992, 10002, 1, 10004, 10004, 1, 10006, 10006, 1, 10013, 10013, 1, 10017, 10017, 1, 10024, 10024, 1, 10035, 10036, 1, 10052, 10052, 1, 10055, 10055, 1, 10060, 10060, 1, 10062, 10062, 1, 10067, 10069, 1, 10071, 10071, 1, 10083, 10087, 1, 10133, 10135, 1, 10145, 10145, 1, 10160, 10160, 1, 10175, 10175, 1, 10548, 10549, 1, 11013, 11015, 1, 11035, 11036, 1, 11088, 11088, 1, 11093, 11093, 1, 12336, 12336, 1, 12349, 12349, 1, 12951, 12951, 1, 12953, 12953, 1, 126976, 127231, 1, 127245, 127247, 1, 127279, 127279, 1, 127340, 127345, 1, 127358, 127359, 1, 127374, 127374, 1, 127377, 127386, 1, 127405, 127461, 1, 127489, 127503, 1, 127514, 127514, 1, 127535, 127535, 1, 127538, 127546, 1, 127548, 127551, 1, 127561, 127994, 1, 128000, 128317, 1, 128326, 128591, 1, 128640, 128767, 1, 128884, 128895, 1, 128981, 129023, 1, 129036, 129039, 1, 129096, 129103, 1, 129114, 129119, 1, 129160, 129167, 1, 129198, 129279, 1, 129292, 129338, 1, 129340, 129349, 1, 129351, 129791, 1, 130048, 131069, 1];
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 字素簇分割(Unicode UAX #29 extended grapheme clusters)
|
|
21
|
+
*
|
|
22
|
+
* 断点规则按 GB1-GB999 顺序短路判定:
|
|
23
|
+
* GB3 CR × LF
|
|
24
|
+
* GB4 (Control | CR | LF) ÷
|
|
25
|
+
* GB5 ÷ (Control | CR | LF)
|
|
26
|
+
* GB6 L × (L | V | LV | LVT)
|
|
27
|
+
* GB7 (LV | V) × (V | T)
|
|
28
|
+
* GB8 (LVT | T) × T
|
|
29
|
+
* GB9 × (Extend | ZWJ)
|
|
30
|
+
* GB9a × SpacingMark
|
|
31
|
+
* GB9b Prepend ×
|
|
32
|
+
* GB11 ExtPict Extend* ZWJ × ExtPict
|
|
33
|
+
* GB12 sot (RI RI)* RI × RI
|
|
34
|
+
* GB13 [^RI] (RI RI)* RI × RI
|
|
35
|
+
* GB999 Any ÷ Any
|
|
36
|
+
*
|
|
37
|
+
* 属性数据来自 Unicode 16.0.0 官方文件,由 scripts/gen-break-data.mjs
|
|
38
|
+
* 生成 src/data.ts(Unicode 版本升级时重新运行脚本即可)。
|
|
39
|
+
*/
|
|
40
|
+
// Grapheme_Cluster_Break 属性编号(与 scripts/gen-break-data.mjs 的 TYPE_IDS 一致)
|
|
41
|
+
const OTHER = 0;
|
|
42
|
+
const CR = 1;
|
|
43
|
+
const LF = 2;
|
|
44
|
+
const CONTROL = 3;
|
|
45
|
+
const EXTEND = 4;
|
|
46
|
+
const ZWJ = 5;
|
|
47
|
+
const REGIONAL_INDICATOR = 6;
|
|
48
|
+
const PREPEND = 7;
|
|
49
|
+
const SPACINGMARK = 8;
|
|
50
|
+
const HANGUL_L = 9;
|
|
51
|
+
const HANGUL_V = 10;
|
|
52
|
+
const HANGUL_T = 11;
|
|
53
|
+
const HANGUL_LV = 12;
|
|
54
|
+
const HANGUL_LVT = 13;
|
|
55
|
+
function lookupType(table, codePoint) {
|
|
56
|
+
let lo = 0;
|
|
57
|
+
let hi = table.length / 3 - 1;
|
|
58
|
+
while (lo <= hi) {
|
|
59
|
+
const mid = (lo + hi) >> 1;
|
|
60
|
+
if (codePoint < table[mid * 3])
|
|
61
|
+
hi = mid - 1;
|
|
62
|
+
else if (codePoint > table[mid * 3 + 1])
|
|
63
|
+
lo = mid + 1;
|
|
64
|
+
else
|
|
65
|
+
return table[mid * 3 + 2];
|
|
66
|
+
}
|
|
67
|
+
return OTHER;
|
|
68
|
+
}
|
|
69
|
+
function getGraphemeType(codePoint) {
|
|
70
|
+
return lookupType(BREAK_TABLE, codePoint);
|
|
71
|
+
}
|
|
72
|
+
function isExtendedPictographic(codePoint) {
|
|
73
|
+
return lookupType(EXT_PICT_TABLE, codePoint) === 1;
|
|
74
|
+
}
|
|
75
|
+
function codePointAt(str, index) {
|
|
76
|
+
const char = str.charCodeAt(index);
|
|
77
|
+
if (char >= 0xd800 && char <= 0xdbff && index + 1 < str.length) {
|
|
78
|
+
const next = str.charCodeAt(index + 1);
|
|
79
|
+
if (next >= 0xdc00 && next <= 0xdfff)
|
|
80
|
+
return (char - 0xd800) * 0x400 + (next - 0xdc00) + 0x10000;
|
|
81
|
+
}
|
|
82
|
+
return char;
|
|
83
|
+
}
|
|
84
|
+
function codePointLength(str, index) {
|
|
85
|
+
const char = str.charCodeAt(index);
|
|
86
|
+
if (char >= 0xd800 && char <= 0xdbff && index + 1 < str.length) {
|
|
87
|
+
const next = str.charCodeAt(index + 1);
|
|
88
|
+
if (next >= 0xdc00 && next <= 0xdfff)
|
|
89
|
+
return 2;
|
|
90
|
+
}
|
|
91
|
+
return 1;
|
|
92
|
+
}
|
|
93
|
+
function prevCodePointStart(str, index) {
|
|
94
|
+
const prev = str.charCodeAt(index - 1);
|
|
95
|
+
if (prev >= 0xdc00 && prev <= 0xdfff && index >= 2) {
|
|
96
|
+
const before = str.charCodeAt(index - 2);
|
|
97
|
+
if (before >= 0xd800 && before <= 0xdbff)
|
|
98
|
+
return index - 2;
|
|
99
|
+
}
|
|
100
|
+
return index - 1;
|
|
101
|
+
}
|
|
102
|
+
function isControlLike(type) {
|
|
103
|
+
return type === CR || type === LF || type === CONTROL;
|
|
104
|
+
}
|
|
105
|
+
function isBoundary(prevType, riOdd, pictZwj, currCP, currType) {
|
|
106
|
+
if (prevType === CR && currType === LF)
|
|
107
|
+
return false; // GB3
|
|
108
|
+
if (isControlLike(prevType))
|
|
109
|
+
return true; // GB4
|
|
110
|
+
if (isControlLike(currType))
|
|
111
|
+
return true; // GB5
|
|
112
|
+
if (prevType === HANGUL_L && (currType === HANGUL_L || currType === HANGUL_V || currType === HANGUL_LV || currType === HANGUL_LVT))
|
|
113
|
+
return false; // GB6
|
|
114
|
+
if ((prevType === HANGUL_LV || prevType === HANGUL_V) && (currType === HANGUL_V || currType === HANGUL_T))
|
|
115
|
+
return false; // GB7
|
|
116
|
+
if ((prevType === HANGUL_LVT || prevType === HANGUL_T) && currType === HANGUL_T)
|
|
117
|
+
return false; // GB8
|
|
118
|
+
if (currType === EXTEND || currType === ZWJ)
|
|
119
|
+
return false; // GB9
|
|
120
|
+
if (currType === SPACINGMARK)
|
|
121
|
+
return false; // GB9a
|
|
122
|
+
if (prevType === PREPEND)
|
|
123
|
+
return false; // GB9b
|
|
124
|
+
if (pictZwj && isExtendedPictographic(currCP))
|
|
125
|
+
return false; // GB11
|
|
126
|
+
if (prevType === REGIONAL_INDICATOR && currType === REGIONAL_INDICATOR && riOdd)
|
|
127
|
+
return false; // GB12/13
|
|
128
|
+
return true; // GB999
|
|
129
|
+
}
|
|
130
|
+
/** 统一 GB11 状态推进(正向/回溯复用) */
|
|
131
|
+
function advanceGB11State(state, currCP, currType) {
|
|
132
|
+
const pictZwj = state.pictChain && currType === ZWJ;
|
|
133
|
+
const pictChain = (isExtendedPictographic(currCP) && currType !== ZWJ) || (state.pictChain && currType === EXTEND);
|
|
134
|
+
return { pictChain, pictZwj };
|
|
135
|
+
}
|
|
136
|
+
function initialState(cp, type) {
|
|
137
|
+
return {
|
|
138
|
+
riOdd: type === REGIONAL_INDICATOR,
|
|
139
|
+
pictChain: isExtendedPictographic(cp),
|
|
140
|
+
pictZwj: false,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function advanceState(state, prevType, currCP, currType) {
|
|
144
|
+
const riOdd = currType === REGIONAL_INDICATOR && (prevType !== REGIONAL_INDICATOR || !state.riOdd);
|
|
145
|
+
const gb11 = advanceGB11State(state, currCP, currType);
|
|
146
|
+
return Object.assign({ riOdd }, gb11);
|
|
147
|
+
}
|
|
148
|
+
/** 通过正向重放统一状态机计算 GB11 状态(用于回溯镜像判定) */
|
|
149
|
+
function computeGB11StateAtBoundary(str, from, toExclusive) {
|
|
150
|
+
if (from >= toExclusive)
|
|
151
|
+
return { pictChain: false, pictZwj: false };
|
|
152
|
+
let i = from;
|
|
153
|
+
const cp0 = codePointAt(str, i);
|
|
154
|
+
const t0 = getGraphemeType(cp0);
|
|
155
|
+
let state = { pictChain: isExtendedPictographic(cp0), pictZwj: false };
|
|
156
|
+
let prevType = t0;
|
|
157
|
+
i += codePointLength(str, i);
|
|
158
|
+
while (i < toExclusive) {
|
|
159
|
+
const cp = codePointAt(str, i);
|
|
160
|
+
const t = getGraphemeType(cp);
|
|
161
|
+
// 若期间出现断点,GB11 链应在新簇语境下重置;但 findClusterStart 只在已确定非断点的边界附近调用
|
|
162
|
+
if (isBoundary(prevType, false, state.pictZwj, cp, t)) {
|
|
163
|
+
state = { pictChain: isExtendedPictographic(cp), pictZwj: false };
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
state = advanceGB11State(state, cp, t);
|
|
167
|
+
}
|
|
168
|
+
prevType = t;
|
|
169
|
+
i += codePointLength(str, i);
|
|
170
|
+
}
|
|
171
|
+
return state;
|
|
172
|
+
}
|
|
173
|
+
function normalizeIndexToCodePointStart(str, index) {
|
|
174
|
+
if (index <= 0)
|
|
175
|
+
return 0;
|
|
176
|
+
if (index >= str.length)
|
|
177
|
+
return str.length;
|
|
178
|
+
const prev = str.charCodeAt(index - 1);
|
|
179
|
+
if (prev >= 0xd800 && prev <= 0xdbff) {
|
|
180
|
+
const curr = str.charCodeAt(index);
|
|
181
|
+
if (curr >= 0xdc00 && curr <= 0xdfff)
|
|
182
|
+
return index - 1;
|
|
183
|
+
}
|
|
184
|
+
return index;
|
|
185
|
+
}
|
|
186
|
+
function findClusterStart(str, start) {
|
|
187
|
+
while (start > 0) {
|
|
188
|
+
const prevStart = prevCodePointStart(str, start);
|
|
189
|
+
const prevCP = codePointAt(str, prevStart);
|
|
190
|
+
const prevType = getGraphemeType(prevCP);
|
|
191
|
+
const currCP = codePointAt(str, start);
|
|
192
|
+
const currType = getGraphemeType(currCP);
|
|
193
|
+
let isStart;
|
|
194
|
+
if (prevType === CR && currType === LF)
|
|
195
|
+
isStart = false; // GB3
|
|
196
|
+
else if (isControlLike(prevType))
|
|
197
|
+
isStart = true; // GB4
|
|
198
|
+
else if (isControlLike(currType))
|
|
199
|
+
isStart = true; // GB5
|
|
200
|
+
else if (prevType === HANGUL_L && (currType === HANGUL_L || currType === HANGUL_V || currType === HANGUL_LV || currType === HANGUL_LVT))
|
|
201
|
+
isStart = false; // GB6
|
|
202
|
+
else if ((prevType === HANGUL_LV || prevType === HANGUL_V) && (currType === HANGUL_V || currType === HANGUL_T))
|
|
203
|
+
isStart = false; // GB7
|
|
204
|
+
else if ((prevType === HANGUL_LVT || prevType === HANGUL_T) && currType === HANGUL_T)
|
|
205
|
+
isStart = false; // GB8
|
|
206
|
+
else if (currType === EXTEND || currType === ZWJ)
|
|
207
|
+
isStart = false; // GB9
|
|
208
|
+
else if (currType === SPACINGMARK)
|
|
209
|
+
isStart = false; // GB9a
|
|
210
|
+
else if (prevType === PREPEND)
|
|
211
|
+
isStart = false; // GB9b
|
|
212
|
+
else if (currType === REGIONAL_INDICATOR && prevType === REGIONAL_INDICATOR) {
|
|
213
|
+
// GB12/13:向左统计连续 RI(含 prev)个数,奇数表示 prev 未配对
|
|
214
|
+
let count = 1;
|
|
215
|
+
let k = prevCodePointStart(str, prevStart);
|
|
216
|
+
while (k >= 0 && getGraphemeType(codePointAt(str, k)) === REGIONAL_INDICATOR) {
|
|
217
|
+
count++;
|
|
218
|
+
k = prevCodePointStart(str, k);
|
|
219
|
+
}
|
|
220
|
+
isStart = count % 2 === 0;
|
|
221
|
+
}
|
|
222
|
+
else if (isExtendedPictographic(currCP) && prevType === ZWJ) {
|
|
223
|
+
// GB11:用统一状态机从簇起点候选正向重放到 prevStart(含)以得到 pictZwj
|
|
224
|
+
// 先找到不受 GB9/GB11 链影响的一个安全起点候选:向左跳过 Extend/ZWJ/ExtPict 相关链的可能起点不现实,
|
|
225
|
+
// 这里从 prevStart 继续向左直到遇到 GB4/GB5/GB999 强断点候选,再从该点正向重放。
|
|
226
|
+
let anchor = prevStart;
|
|
227
|
+
while (anchor > 0) {
|
|
228
|
+
const aPrev = prevCodePointStart(str, anchor);
|
|
229
|
+
const aPrevCP = codePointAt(str, aPrev);
|
|
230
|
+
const aPrevType = getGraphemeType(aPrevCP);
|
|
231
|
+
const aCurrCP = codePointAt(str, anchor);
|
|
232
|
+
const aCurrType = getGraphemeType(aCurrCP);
|
|
233
|
+
if (isControlLike(aPrevType) || isControlLike(aCurrType))
|
|
234
|
+
break;
|
|
235
|
+
// 简化:遇到明显非链延续且非 RI/Hangul 复杂组合时可停;为安全起见继续回退一段
|
|
236
|
+
if (aCurrType !== EXTEND && aCurrType !== ZWJ && aCurrType !== SPACINGMARK && !isExtendedPictographic(aCurrCP) && aPrevType !== PREPEND)
|
|
237
|
+
break;
|
|
238
|
+
anchor = aPrev;
|
|
239
|
+
}
|
|
240
|
+
const st = computeGB11StateAtBoundary(str, anchor, start);
|
|
241
|
+
isStart = !st.pictZwj;
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
isStart = true; // GB999
|
|
245
|
+
}
|
|
246
|
+
if (isStart)
|
|
247
|
+
return start;
|
|
248
|
+
start = prevStart;
|
|
249
|
+
}
|
|
250
|
+
return start;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* 计算字符串的字素数量
|
|
254
|
+
* @param str - 要计算的字符串
|
|
255
|
+
* @returns 字素数量
|
|
256
|
+
*/
|
|
257
|
+
function GetLength(str) {
|
|
258
|
+
if (!str)
|
|
259
|
+
return 0;
|
|
260
|
+
let count = 0;
|
|
261
|
+
let index = 0;
|
|
262
|
+
while (index < str.length) {
|
|
263
|
+
index = NextBreak(str, index);
|
|
264
|
+
count++;
|
|
265
|
+
}
|
|
266
|
+
return count;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* 查找下一个字素边界位置(UTF-16 索引,严格大于 index 的最小边界)
|
|
270
|
+
*
|
|
271
|
+
* 语义说明(修复问题1):
|
|
272
|
+
* - `index` 为 UTF-16 索引,允许落在代理对中间或字素簇中间。
|
|
273
|
+
* - 若 `index` 落在簇中间,会先回溯到包含该索引的字素簇起点,再返回该簇的结束边界。
|
|
274
|
+
* 因此返回值始终是「覆盖 index 的那个字素簇」的终点(`> index`,除非已到字符串末尾)。
|
|
275
|
+
* - 内部 `Split/Iterate/GetLength/Slice/Pick` 始终传入已知簇边界,不会触发回溯歧义。
|
|
276
|
+
*
|
|
277
|
+
* @param str - 字符串
|
|
278
|
+
* @param index - UTF-16 起始索引(默认 0)
|
|
279
|
+
* @returns 下一个字素边界(UTF-16 索引)
|
|
280
|
+
*/
|
|
281
|
+
function NextBreak(str, index = 0) {
|
|
282
|
+
if (!str)
|
|
283
|
+
return 0;
|
|
284
|
+
if (!Number.isFinite(index) || index < 0)
|
|
285
|
+
return 0;
|
|
286
|
+
index = Math.floor(index);
|
|
287
|
+
if (index >= str.length)
|
|
288
|
+
return str.length;
|
|
289
|
+
let start = normalizeIndexToCodePointStart(str, index);
|
|
290
|
+
start = findClusterStart(str, start);
|
|
291
|
+
const firstCP = codePointAt(str, start);
|
|
292
|
+
const firstType = getGraphemeType(firstCP);
|
|
293
|
+
let prevType = firstType;
|
|
294
|
+
let state = initialState(firstCP, firstType);
|
|
295
|
+
let i = start + codePointLength(str, start);
|
|
296
|
+
while (i < str.length) {
|
|
297
|
+
const currCP = codePointAt(str, i);
|
|
298
|
+
const currType = getGraphemeType(currCP);
|
|
299
|
+
if (isBoundary(prevType, state.riOdd, state.pictZwj, currCP, currType))
|
|
300
|
+
return i;
|
|
301
|
+
state = advanceState(state, prevType, currCP, currType);
|
|
302
|
+
prevType = currType;
|
|
303
|
+
i += codePointLength(str, i);
|
|
304
|
+
}
|
|
305
|
+
return str.length;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* 将字符串拆分为字素数组
|
|
309
|
+
* @param str - 要拆分的字符串
|
|
310
|
+
* @returns 字素数组
|
|
311
|
+
*/
|
|
312
|
+
function Split(str) {
|
|
313
|
+
const result = [];
|
|
314
|
+
let index = 0;
|
|
315
|
+
while (index < str.length) {
|
|
316
|
+
const breakIndex = NextBreak(str, index);
|
|
317
|
+
result.push(str.slice(index, breakIndex));
|
|
318
|
+
index = breakIndex;
|
|
319
|
+
}
|
|
320
|
+
return result;
|
|
321
|
+
}
|
|
322
|
+
function normalizeGraphemeIndex(index, len) {
|
|
323
|
+
if (!Number.isFinite(index))
|
|
324
|
+
index = 0;
|
|
325
|
+
index = Math.trunc(index);
|
|
326
|
+
if (index < 0)
|
|
327
|
+
index = len + index;
|
|
328
|
+
if (index < 0)
|
|
329
|
+
index = 0;
|
|
330
|
+
if (index > len)
|
|
331
|
+
index = len;
|
|
332
|
+
return index;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* 按字素索引截取字符串
|
|
336
|
+
*
|
|
337
|
+
* 单位说明:
|
|
338
|
+
* - `start` / `end` 均为**字素索引**(0-based,按用户可见字符计数),不是 UTF-16 索引。
|
|
339
|
+
* - 支持负索引(如 -1 表示最后一个字素位置,与 `Array.prototype.slice` 类似)。
|
|
340
|
+
* - `end` 省略时截取到末尾。
|
|
341
|
+
*
|
|
342
|
+
* @param str - 字符串
|
|
343
|
+
* @param start - 起始字素索引
|
|
344
|
+
* @param end - 结束字素索引(不包含)
|
|
345
|
+
* @returns 截取的字符串
|
|
346
|
+
*/
|
|
347
|
+
function Slice(str, start = 0, end) {
|
|
348
|
+
if (!str)
|
|
349
|
+
return str !== null && str !== void 0 ? str : '';
|
|
350
|
+
const graphemes = Split(str);
|
|
351
|
+
const len = graphemes.length;
|
|
352
|
+
const s = normalizeGraphemeIndex(start, len);
|
|
353
|
+
const e = end === undefined ? len : normalizeGraphemeIndex(end, len);
|
|
354
|
+
if (e <= s)
|
|
355
|
+
return '';
|
|
356
|
+
return graphemes.slice(s, e).join('');
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* 获取字符串的字素迭代器
|
|
360
|
+
* @param str - 字符串
|
|
361
|
+
* @returns 可迭代的字素迭代器
|
|
362
|
+
*/
|
|
363
|
+
function Iterate(str) {
|
|
364
|
+
let index = 0;
|
|
365
|
+
return {
|
|
366
|
+
next() {
|
|
367
|
+
var _a;
|
|
368
|
+
if (index >= ((_a = str === null || str === void 0 ? void 0 : str.length) !== null && _a !== void 0 ? _a : 0))
|
|
369
|
+
return { value: undefined, done: true };
|
|
370
|
+
const breakIndex = NextBreak(str, index);
|
|
371
|
+
const value = str.slice(index, breakIndex);
|
|
372
|
+
index = breakIndex;
|
|
373
|
+
return { value, done: false };
|
|
374
|
+
},
|
|
375
|
+
[Symbol.iterator]() {
|
|
376
|
+
return this;
|
|
377
|
+
},
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* 遍历字符串的每个字素
|
|
382
|
+
* @param str - 字符串
|
|
383
|
+
* @param callback - 回调函数
|
|
384
|
+
*/
|
|
385
|
+
function Each(str, callback) {
|
|
386
|
+
let i = 0;
|
|
387
|
+
for (const grapheme of Iterate(str))
|
|
388
|
+
callback(grapheme, i++);
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* 获取字符串指定位置的字素
|
|
392
|
+
* @param str - 字符串
|
|
393
|
+
* @param index - 字素索引(支持负索引;非整数会被截断)
|
|
394
|
+
* @returns 指定位置的字素,如果不存在则返回 undefined
|
|
395
|
+
*/
|
|
396
|
+
function Pick(str, index) {
|
|
397
|
+
if (!str)
|
|
398
|
+
return undefined;
|
|
399
|
+
if (!Number.isFinite(index))
|
|
400
|
+
return undefined;
|
|
401
|
+
index = Math.trunc(index);
|
|
402
|
+
if (index < 0) {
|
|
403
|
+
const arr = Split(str);
|
|
404
|
+
const i = arr.length + index;
|
|
405
|
+
return i >= 0 ? arr[i] : undefined;
|
|
406
|
+
}
|
|
407
|
+
let count = 0;
|
|
408
|
+
for (const grapheme of Iterate(str)) {
|
|
409
|
+
if (count === index)
|
|
410
|
+
return grapheme;
|
|
411
|
+
count++;
|
|
412
|
+
}
|
|
413
|
+
return undefined;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* 截断字符串的字素
|
|
417
|
+
* @param str - 字符串
|
|
418
|
+
* @param length - 最大保留字素数(非负整数;负数/NaN 视为 0)
|
|
419
|
+
* @param ellipsis - 省略号,默认为 "...";仅在实际发生截断时追加
|
|
420
|
+
* @returns 截断后的字符串
|
|
421
|
+
*/
|
|
422
|
+
function Truncate(str, length, ellipsis = '...') {
|
|
423
|
+
if (!str)
|
|
424
|
+
return str !== null && str !== void 0 ? str : '';
|
|
425
|
+
if (!Number.isFinite(length))
|
|
426
|
+
length = 0;
|
|
427
|
+
length = Math.max(0, Math.trunc(length));
|
|
428
|
+
const graphemes = Split(str);
|
|
429
|
+
if (graphemes.length <= length)
|
|
430
|
+
return str;
|
|
431
|
+
return graphemes.slice(0, length).join('') + ellipsis;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
export { Each, GetLength, Iterate, NextBreak, Pick, Slice, Split, Truncate };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nebulaaa/grapheme",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "字素操作扩展包",
|
|
5
|
+
"author": "doooreyn",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"grapheme",
|
|
9
|
+
"nebulaaa"
|
|
10
|
+
],
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=16.0.0",
|
|
13
|
+
"npm": ">=10.0.0"
|
|
14
|
+
},
|
|
15
|
+
"main": "./grapheme.cjs",
|
|
16
|
+
"module": "./grapheme.mjs",
|
|
17
|
+
"types": "./grapheme.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./grapheme.d.ts",
|
|
21
|
+
"require": "./grapheme.cjs",
|
|
22
|
+
"import": "./grapheme.mjs",
|
|
23
|
+
"default": "./grapheme.cjs"
|
|
24
|
+
},
|
|
25
|
+
"./min": {
|
|
26
|
+
"types": "./grapheme.d.ts",
|
|
27
|
+
"require": "./grapheme.min.cjs",
|
|
28
|
+
"import": "./grapheme.min.mjs"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"registry": "https://registry.npmjs.org/",
|
|
33
|
+
"access": "public"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,68 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@nebulaaa/grapheme",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@nebulaaa/grapheme",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "字素操作扩展包",
|
|
5
|
+
"main": "./dist/grapheme.cjs",
|
|
6
|
+
"module": "./dist/grapheme.mjs",
|
|
7
|
+
"types": "./dist/grapheme.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/grapheme.d.ts",
|
|
11
|
+
"import": "./dist/grapheme.mjs",
|
|
12
|
+
"require": "./dist/grapheme.cjs",
|
|
13
|
+
"default": "./dist/grapheme.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./min": {
|
|
16
|
+
"types": "./dist/grapheme.d.ts",
|
|
17
|
+
"import": "./dist/grapheme.min.mjs",
|
|
18
|
+
"require": "./dist/grapheme.min.cjs",
|
|
19
|
+
"default": "./dist/grapheme.min.cjs"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
27
|
+
"build": "npm run clean && rollup -c rollup.config.mjs && node ../scripts/write-dist-package.mjs grapheme",
|
|
28
|
+
"test": "jest"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"grapheme",
|
|
32
|
+
"nebulaaa"
|
|
33
|
+
],
|
|
34
|
+
"author": "doooreyn",
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"devEngines": {
|
|
37
|
+
"packageManager": {
|
|
38
|
+
"name": "npm",
|
|
39
|
+
"version": ">=10.0.0",
|
|
40
|
+
"onFail": "warn"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=16.0.0",
|
|
45
|
+
"npm": ">=10.0.0"
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"registry": "https://registry.npmjs.org/",
|
|
49
|
+
"access": "public"
|
|
50
|
+
},
|
|
51
|
+
"allowScripts": {
|
|
52
|
+
"unrs-resolver@1.12.2": true,
|
|
53
|
+
"@parcel/watcher@2.6.0": true
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@rollup/plugin-terser": "^1.0.2",
|
|
57
|
+
"@rollup/plugin-typescript": "^12.1.2",
|
|
58
|
+
"@types/jest": "^30.0.0",
|
|
59
|
+
"@types/node": "^22.10.2",
|
|
60
|
+
"jest": "^30.5.2",
|
|
61
|
+
"rollup": "^4.28.1",
|
|
62
|
+
"rollup-plugin-dts": "^6.1.1",
|
|
63
|
+
"ts-jest": "^29.1.2",
|
|
64
|
+
"ts-node": "^10.9.2",
|
|
65
|
+
"typescript": "5.7.3"
|
|
66
|
+
},
|
|
67
|
+
"dependencies": {}
|
|
68
|
+
}
|
package/README.md
DELETED