@visulima/string 1.2.3 → 1.4.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/CHANGELOG.md +17 -0
- package/README.md +46 -0
- package/dist/case/camel-case.cjs +1 -59
- package/dist/case/camel-case.mjs +1 -57
- package/dist/case/capital-case.cjs +1 -51
- package/dist/case/capital-case.mjs +1 -49
- package/dist/case/constant-case.cjs +1 -11
- package/dist/case/constant-case.mjs +1 -9
- package/dist/case/dot-case.cjs +1 -11
- package/dist/case/dot-case.mjs +1 -9
- package/dist/case/flat-case.cjs +1 -11
- package/dist/case/flat-case.mjs +1 -9
- package/dist/case/flip-case.cjs +1 -61
- package/dist/case/flip-case.mjs +1 -57
- package/dist/case/identify-case.cjs +1 -69
- package/dist/case/identify-case.mjs +1 -67
- package/dist/case/index.cjs +1 -47
- package/dist/case/index.mjs +1 -20
- package/dist/case/kebab-case.cjs +1 -61
- package/dist/case/kebab-case.mjs +1 -57
- package/dist/case/lower-first.cjs +1 -13
- package/dist/case/lower-first.mjs +1 -11
- package/dist/case/no-case.cjs +1 -11
- package/dist/case/no-case.mjs +1 -9
- package/dist/case/pascal-case.cjs +1 -52
- package/dist/case/pascal-case.mjs +1 -50
- package/dist/case/pascal-snake-case.cjs +1 -32
- package/dist/case/pascal-snake-case.mjs +1 -30
- package/dist/case/path-case.cjs +1 -11
- package/dist/case/path-case.mjs +1 -9
- package/dist/case/sentence-case.cjs +1 -58
- package/dist/case/sentence-case.mjs +1 -56
- package/dist/case/snake-case.cjs +1 -11
- package/dist/case/snake-case.mjs +1 -9
- package/dist/case/split-by-case.cjs +1 -641
- package/dist/case/split-by-case.mjs +1 -637
- package/dist/case/title-case.cjs +1 -47
- package/dist/case/title-case.mjs +1 -45
- package/dist/case/train-case.cjs +1 -44
- package/dist/case/train-case.mjs +1 -42
- package/dist/case/upper-first.cjs +1 -13
- package/dist/case/upper-first.mjs +1 -11
- package/dist/get-string-truncated-width.cjs +1 -422
- package/dist/get-string-truncated-width.mjs +1 -418
- package/dist/get-string-width.cjs +1 -11
- package/dist/get-string-width.mjs +1 -7
- package/dist/index.cjs +1 -66
- package/dist/index.d.cts +13 -3
- package/dist/index.d.mts +13 -3
- package/dist/index.d.ts +13 -3
- package/dist/index.mjs +1 -29
- package/dist/outdent.cjs +1 -125
- package/dist/outdent.mjs +1 -121
- package/dist/packem_shared/LRUCache-Bjo6gsbC.mjs +1 -0
- package/dist/packem_shared/LRUCache-TYqfUYE5.cjs +1 -0
- package/dist/packem_shared/WrapMode-BZ3jkEf1.mjs +8 -0
- package/dist/packem_shared/WrapMode-DR7vv3px.cjs +8 -0
- package/dist/packem_shared/alignText-BCKbnqhC.mjs +2 -0
- package/dist/packem_shared/alignText-CLZJuPP6.cjs +2 -0
- package/dist/packem_shared/constants-Cd17VNEv.mjs +1 -0
- package/dist/packem_shared/constants-D3K8u3G8.cjs +1 -0
- package/dist/packem_shared/generate-cache-key-BZf0GiMs.cjs +1 -0
- package/dist/packem_shared/generate-cache-key-DPByFaMH.mjs +1 -0
- package/dist/packem_shared/joinSegments-CDHNMXsF.cjs +1 -0
- package/dist/packem_shared/joinSegments-H7QJ7rwJ.mjs +1 -0
- package/dist/packem_shared/normalize-german-eszett-4k1qRtEP.mjs +1 -0
- package/dist/packem_shared/normalize-german-eszett-Bop4wOp9.cjs +1 -0
- package/dist/packem_shared/replaceString-Ce8TI_-L.cjs +1 -0
- package/dist/packem_shared/replaceString-D7R-5VFX.mjs +1 -0
- package/dist/packem_shared/slugify-B1vlQQO1.mjs +1 -0
- package/dist/packem_shared/slugify-CH3GI7E5.cjs +1 -0
- package/dist/packem_shared/transliterate-BXaP38Sh.mjs +5 -0
- package/dist/packem_shared/transliterate-CToQ-aeM.cjs +5 -0
- package/dist/slice.cjs +1 -419
- package/dist/slice.mjs +1 -415
- package/dist/test/utils.cjs +13 -74
- package/dist/test/utils.mjs +14 -69
- package/dist/test/vitest.cjs +1 -11
- package/dist/test/vitest.mjs +1 -7
- package/dist/truncate.cjs +1 -101
- package/dist/truncate.mjs +1 -97
- package/dist/utils.cjs +1 -65
- package/dist/utils.mjs +1 -56
- package/package.json +8 -1
- package/dist/packem_shared/LRUCache-Crb-m7cw.cjs +0 -53
- package/dist/packem_shared/LRUCache-udNErhWw.mjs +0 -51
- package/dist/packem_shared/WrapMode-BCVbMqYK.mjs +0 -545
- package/dist/packem_shared/WrapMode-DebG_Nll.cjs +0 -550
- package/dist/packem_shared/constants-6-GJ6zA-.cjs +0 -150
- package/dist/packem_shared/constants-CKdlkHVU.mjs +0 -99
- package/dist/packem_shared/generate-cache-key-D8f1auDB.cjs +0 -10
- package/dist/packem_shared/generate-cache-key-YSju5pj2.mjs +0 -8
- package/dist/packem_shared/joinSegments-BfSDBmPF.mjs +0 -46
- package/dist/packem_shared/joinSegments-HYXurfoq.cjs +0 -48
- package/dist/packem_shared/normalize-german-eszett-DJK0S2qj.cjs +0 -11
- package/dist/packem_shared/normalize-german-eszett-fpJ4lZL6.mjs +0 -9
- package/dist/packem_shared/replaceString-C7Dp5vAg.mjs +0 -200
- package/dist/packem_shared/replaceString-iYo1cDfZ.cjs +0 -202
- package/dist/packem_shared/slugify-SKjCL8DF.cjs +0 -50
- package/dist/packem_shared/slugify-pbxTlzeQ.mjs +0 -48
- package/dist/packem_shared/transliterate-4P32b49d.mjs +0 -47780
- package/dist/packem_shared/transliterate-CtOTNpLs.cjs +0 -47782
|
@@ -1,641 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
4
|
-
|
|
5
|
-
const node_util = require('node:util');
|
|
6
|
-
const constants = require('../packem_shared/constants-6-GJ6zA-.cjs');
|
|
7
|
-
const LRUCache = require('../packem_shared/LRUCache-Crb-m7cw.cjs');
|
|
8
|
-
|
|
9
|
-
var __defProp$2 = Object.defineProperty;
|
|
10
|
-
var __name$2 = (target, value) => __defProp$2(target, "name", { value, configurable: true });
|
|
11
|
-
const regexCache = new LRUCache(1e3);
|
|
12
|
-
const getSeparatorsRegex = /* @__PURE__ */ __name$2((separators) => {
|
|
13
|
-
const key = separators.join("");
|
|
14
|
-
if (regexCache.has(key)) {
|
|
15
|
-
return regexCache.get(key);
|
|
16
|
-
}
|
|
17
|
-
const pattern = separators.map((s) => s.replaceAll(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
18
|
-
const regex = new RegExp(pattern, "g");
|
|
19
|
-
regexCache.set(key, regex);
|
|
20
|
-
return regex;
|
|
21
|
-
}, "getSeparatorsRegex");
|
|
22
|
-
|
|
23
|
-
var __defProp$1 = Object.defineProperty;
|
|
24
|
-
var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
|
|
25
|
-
const splitByEmoji = /* @__PURE__ */ __name$1((text) => {
|
|
26
|
-
const segments = [];
|
|
27
|
-
let lastIndex = 0;
|
|
28
|
-
let match;
|
|
29
|
-
constants.RE_EMOJI.lastIndex = 0;
|
|
30
|
-
while ((match = constants.RE_EMOJI.exec(text)) !== null) {
|
|
31
|
-
if (match.index > lastIndex) {
|
|
32
|
-
segments.push(text.slice(lastIndex, match.index));
|
|
33
|
-
}
|
|
34
|
-
segments.push(match[0]);
|
|
35
|
-
lastIndex = constants.RE_EMOJI.lastIndex;
|
|
36
|
-
}
|
|
37
|
-
if (lastIndex < text.length) {
|
|
38
|
-
segments.push(text.slice(lastIndex));
|
|
39
|
-
}
|
|
40
|
-
return segments.filter(Boolean);
|
|
41
|
-
}, "splitByEmoji");
|
|
42
|
-
|
|
43
|
-
var __defProp = Object.defineProperty;
|
|
44
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
45
|
-
const isUpperCode = new Uint8Array(128);
|
|
46
|
-
const isLowerCode = new Uint8Array(128);
|
|
47
|
-
const isDigitCode = new Uint8Array(128);
|
|
48
|
-
for (let index = 0; index < 128; index++) {
|
|
49
|
-
isUpperCode[index] = index >= 65 && index <= 90 ? 1 : 0;
|
|
50
|
-
isLowerCode[index] = index >= 97 && index <= 122 ? 1 : 0;
|
|
51
|
-
isDigitCode[index] = index >= 48 && index <= 57 ? 1 : 0;
|
|
52
|
-
}
|
|
53
|
-
const isUpper = /* @__PURE__ */ __name((code) => isUpperCode[code], "isUpper");
|
|
54
|
-
const isLower = /* @__PURE__ */ __name((code) => isLowerCode[code], "isLower");
|
|
55
|
-
const isDigit = /* @__PURE__ */ __name((code) => isDigitCode[code], "isDigit");
|
|
56
|
-
const handleScriptTransitions = /* @__PURE__ */ __name((s, scriptDetectors, caseSensitive, locale, customSplitLogic) => {
|
|
57
|
-
if (s.length === 0) {
|
|
58
|
-
return [];
|
|
59
|
-
}
|
|
60
|
-
let hasDetectedScript = false;
|
|
61
|
-
for (const detector of Object.values(scriptDetectors)) {
|
|
62
|
-
if (detector(s[0])) {
|
|
63
|
-
hasDetectedScript = true;
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
if (!hasDetectedScript && !caseSensitive) {
|
|
68
|
-
return [s];
|
|
69
|
-
}
|
|
70
|
-
const chars = [...s];
|
|
71
|
-
const result = [];
|
|
72
|
-
let currentSegment = chars[0];
|
|
73
|
-
let previousType = "other";
|
|
74
|
-
for (const [type, detector] of Object.entries(scriptDetectors)) {
|
|
75
|
-
if (detector(chars[0])) {
|
|
76
|
-
previousType = type;
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
let previousIsUpper = caseSensitive && locale ? chars[0] === chars[0].toLocaleUpperCase(locale) : false;
|
|
81
|
-
for (let index = 1; index < chars.length; index++) {
|
|
82
|
-
const char = chars[index];
|
|
83
|
-
let currentType = "other";
|
|
84
|
-
for (const [type, detector] of Object.entries(scriptDetectors)) {
|
|
85
|
-
if (detector(char)) {
|
|
86
|
-
currentType = type;
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
const isUpperCaseChar = caseSensitive && locale ? char === char.toLocaleUpperCase(locale) : false;
|
|
91
|
-
let shouldSplit = false;
|
|
92
|
-
if (customSplitLogic) {
|
|
93
|
-
shouldSplit = customSplitLogic(previousType, currentType, previousIsUpper, isUpperCaseChar, char, index, chars);
|
|
94
|
-
} else {
|
|
95
|
-
if (previousType !== currentType && previousType !== "other" && currentType !== "other") {
|
|
96
|
-
shouldSplit = true;
|
|
97
|
-
}
|
|
98
|
-
if (caseSensitive && currentType !== "other" && !previousIsUpper && isUpperCaseChar) {
|
|
99
|
-
shouldSplit = true;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
if (shouldSplit) {
|
|
103
|
-
result.push(currentSegment);
|
|
104
|
-
currentSegment = char;
|
|
105
|
-
} else {
|
|
106
|
-
currentSegment += char;
|
|
107
|
-
}
|
|
108
|
-
previousType = currentType;
|
|
109
|
-
if (caseSensitive) {
|
|
110
|
-
previousIsUpper = isUpperCaseChar;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
if (currentSegment && currentSegment.length > 0) {
|
|
114
|
-
result.push(currentSegment);
|
|
115
|
-
}
|
|
116
|
-
return result.length > 0 ? result : [s];
|
|
117
|
-
}, "handleScriptTransitions");
|
|
118
|
-
const splitCamelCaseFast = /* @__PURE__ */ __name((s, knownAcronyms = /* @__PURE__ */ new Set()) => {
|
|
119
|
-
if (s.length === 0) {
|
|
120
|
-
return [];
|
|
121
|
-
}
|
|
122
|
-
if (s.toUpperCase() === s) {
|
|
123
|
-
return [s];
|
|
124
|
-
}
|
|
125
|
-
let start = 0;
|
|
126
|
-
const tokens = [];
|
|
127
|
-
const width = s.length;
|
|
128
|
-
for (let index = 1; index < width; index++) {
|
|
129
|
-
const previousCode = s.codePointAt(index - 1);
|
|
130
|
-
const currentCode = s.codePointAt(index);
|
|
131
|
-
if (knownAcronyms.size > 0) {
|
|
132
|
-
for (const acronym of knownAcronyms) {
|
|
133
|
-
if (s.startsWith(acronym, start)) {
|
|
134
|
-
tokens.push(acronym);
|
|
135
|
-
start += acronym.length;
|
|
136
|
-
index = start - 1;
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
if (index < start) {
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
const previousIsUpper = previousCode && previousCode < 128 && isUpper(previousCode);
|
|
145
|
-
const currentIsUpper = currentCode && currentCode < 128 && isUpper(currentCode);
|
|
146
|
-
const previousIsLower = previousCode && previousCode < 128 && isLower(previousCode);
|
|
147
|
-
const previousIsDigit = previousCode && previousCode < 128 && isDigit(previousCode);
|
|
148
|
-
const currentIsDigit = currentCode && currentCode < 128 && isDigit(currentCode);
|
|
149
|
-
if (previousIsLower && currentIsUpper) {
|
|
150
|
-
tokens.push(s.slice(start, index));
|
|
151
|
-
start = index;
|
|
152
|
-
continue;
|
|
153
|
-
}
|
|
154
|
-
if (previousIsDigit && !currentIsDigit || !previousIsDigit && currentIsDigit) {
|
|
155
|
-
tokens.push(s.slice(start, index));
|
|
156
|
-
start = index;
|
|
157
|
-
continue;
|
|
158
|
-
}
|
|
159
|
-
if (currentIsDigit && !previousIsDigit) {
|
|
160
|
-
let isNextUpper = false;
|
|
161
|
-
let isNextDigit = false;
|
|
162
|
-
if (index + 1 < width) {
|
|
163
|
-
const nextCode = s.codePointAt(index + 1);
|
|
164
|
-
isNextUpper = nextCode && nextCode < 128 && isUpper(nextCode);
|
|
165
|
-
isNextDigit = nextCode && nextCode < 128 && isDigit(nextCode);
|
|
166
|
-
}
|
|
167
|
-
if (!isNextDigit && isNextUpper) {
|
|
168
|
-
tokens.push(s.slice(start, index), s.slice(index, index + 1));
|
|
169
|
-
start = index + 1;
|
|
170
|
-
continue;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
if (index + 1 < width) {
|
|
174
|
-
const nextCode = s.codePointAt(index + 1);
|
|
175
|
-
const nextIsLower = nextCode && nextCode < 128 && isLower(nextCode);
|
|
176
|
-
if (previousIsUpper && currentIsUpper && nextIsLower) {
|
|
177
|
-
const candidate = s.slice(start, index + 1);
|
|
178
|
-
if (!knownAcronyms.has(candidate)) {
|
|
179
|
-
tokens.push(s.slice(start, index));
|
|
180
|
-
start = index;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
if (start < width) {
|
|
186
|
-
tokens.push(s.slice(start));
|
|
187
|
-
}
|
|
188
|
-
return tokens.filter((token) => token !== "");
|
|
189
|
-
}, "splitCamelCaseFast");
|
|
190
|
-
const splitCamelCaseLocale = /* @__PURE__ */ __name((s, locale, knownAcronyms) => {
|
|
191
|
-
if (s.length === 0) {
|
|
192
|
-
return [];
|
|
193
|
-
}
|
|
194
|
-
const isUpperCase = s === s.toLocaleUpperCase(locale);
|
|
195
|
-
if (locale.startsWith("de")) {
|
|
196
|
-
if (!isUpperCase && s.replaceAll("ß", "SS") === s.toLocaleUpperCase(locale)) {
|
|
197
|
-
return [s];
|
|
198
|
-
}
|
|
199
|
-
const chars2 = [...s];
|
|
200
|
-
const width_2 = chars2.length;
|
|
201
|
-
const result2 = [];
|
|
202
|
-
let currentSegment2 = chars2[0];
|
|
203
|
-
let previousIsUpper2 = chars2[0] === chars2[0].toLocaleUpperCase(locale);
|
|
204
|
-
let isInUpperSequence = previousIsUpper2;
|
|
205
|
-
let upperSequenceStart = previousIsUpper2 ? 0 : -1;
|
|
206
|
-
for (let index = 1; index < width_2; index++) {
|
|
207
|
-
const char = chars2[index];
|
|
208
|
-
const isUpperCaseChar = char === char.toLocaleUpperCase(locale);
|
|
209
|
-
if (isUpperCaseChar === previousIsUpper2) {
|
|
210
|
-
currentSegment2 += char;
|
|
211
|
-
} else if (isUpperCaseChar) {
|
|
212
|
-
if (currentSegment2 && currentSegment2.length > 0) {
|
|
213
|
-
result2.push(currentSegment2);
|
|
214
|
-
currentSegment2 = char;
|
|
215
|
-
}
|
|
216
|
-
isInUpperSequence = true;
|
|
217
|
-
upperSequenceStart = index;
|
|
218
|
-
} else {
|
|
219
|
-
if (isInUpperSequence && index - upperSequenceStart > 1) {
|
|
220
|
-
const lastUpperChar = chars2[index - 1];
|
|
221
|
-
const withoutLastUpper = currentSegment2.slice(0, -1);
|
|
222
|
-
if (withoutLastUpper && withoutLastUpper.length > 0) {
|
|
223
|
-
result2.push(withoutLastUpper);
|
|
224
|
-
}
|
|
225
|
-
currentSegment2 = lastUpperChar + char;
|
|
226
|
-
} else {
|
|
227
|
-
currentSegment2 += char;
|
|
228
|
-
}
|
|
229
|
-
isInUpperSequence = false;
|
|
230
|
-
upperSequenceStart = -1;
|
|
231
|
-
}
|
|
232
|
-
previousIsUpper2 = isUpperCaseChar;
|
|
233
|
-
}
|
|
234
|
-
if (currentSegment2 && currentSegment2.length > 0) {
|
|
235
|
-
result2.push(currentSegment2);
|
|
236
|
-
}
|
|
237
|
-
return result2;
|
|
238
|
-
}
|
|
239
|
-
if (locale.startsWith("uk") || locale.startsWith("ru") || locale.startsWith("bg") || locale.startsWith("sr") || locale.startsWith("mk") || locale.startsWith("be")) {
|
|
240
|
-
if (!constants.RE_CYRILLIC.test(s) && !constants.RE_LATIN.test(s)) {
|
|
241
|
-
return [s];
|
|
242
|
-
}
|
|
243
|
-
const chars2 = [...s];
|
|
244
|
-
const width_2 = chars2.length;
|
|
245
|
-
const result2 = [];
|
|
246
|
-
let currentSegment2 = chars2[0];
|
|
247
|
-
let previousType = constants.RE_CYRILLIC.test(chars2[0]) ? 1 : constants.RE_LATIN.test(chars2[0]) ? 2 : 0;
|
|
248
|
-
let previousIsUpper2 = chars2[0] === chars2[0].toLocaleUpperCase(locale);
|
|
249
|
-
for (let index = 1; index < width_2; index++) {
|
|
250
|
-
const char = chars2[index];
|
|
251
|
-
const currentType = constants.RE_CYRILLIC.test(char) ? 1 : constants.RE_LATIN.test(char) ? 2 : 0;
|
|
252
|
-
const isUpperCaseChar = char === char.toLocaleUpperCase(locale);
|
|
253
|
-
if (previousType !== currentType && (previousType === 1 || previousType === 2) && (currentType === 1 || currentType === 2) || currentType === previousType && !previousIsUpper2 && isUpperCaseChar) {
|
|
254
|
-
result2.push(currentSegment2);
|
|
255
|
-
currentSegment2 = char;
|
|
256
|
-
} else {
|
|
257
|
-
currentSegment2 += char;
|
|
258
|
-
}
|
|
259
|
-
previousType = currentType;
|
|
260
|
-
previousIsUpper2 = isUpperCaseChar;
|
|
261
|
-
}
|
|
262
|
-
if (currentSegment2 && currentSegment2.length > 0) {
|
|
263
|
-
result2.push(currentSegment2);
|
|
264
|
-
}
|
|
265
|
-
const finalResult = [];
|
|
266
|
-
for (let index = 0; index < result2.length; index++) {
|
|
267
|
-
if (index < result2.length - 1 && // eslint-disable-next-line security/detect-object-injection
|
|
268
|
-
result2[index].length === 1 && // eslint-disable-next-line security/detect-object-injection
|
|
269
|
-
constants.RE_LATIN.test(result2[index]) && constants.RE_CYRILLIC.test(result2[index + 1][0])) {
|
|
270
|
-
finalResult.push(result2[index] + result2[index + 1]);
|
|
271
|
-
index++;
|
|
272
|
-
} else {
|
|
273
|
-
finalResult.push(result2[index]);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
return finalResult;
|
|
277
|
-
}
|
|
278
|
-
if (locale.startsWith("el")) {
|
|
279
|
-
if (!constants.RE_GREEK.test(s) && !constants.RE_LATIN.test(s)) {
|
|
280
|
-
return [s];
|
|
281
|
-
}
|
|
282
|
-
const parts = s.match(constants.RE_GREEK_LATIN_SPLIT) ?? [s];
|
|
283
|
-
const result2 = [];
|
|
284
|
-
const width = parts.length;
|
|
285
|
-
if (width === 1) {
|
|
286
|
-
const part = parts[0];
|
|
287
|
-
if (!part || !constants.RE_GREEK.test(part[0]) || part.length === 1) {
|
|
288
|
-
return [part || s];
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
for (const part of parts) {
|
|
292
|
-
if (!part) {
|
|
293
|
-
continue;
|
|
294
|
-
}
|
|
295
|
-
if (!constants.RE_GREEK.test(part[0]) || part.length === 1) {
|
|
296
|
-
result2.push(part);
|
|
297
|
-
continue;
|
|
298
|
-
}
|
|
299
|
-
const partLength = part.length;
|
|
300
|
-
let word = part[0];
|
|
301
|
-
let previousIsUpper2 = part[0] === part[0].toLocaleUpperCase(locale);
|
|
302
|
-
for (let index = 1; index < partLength; index++) {
|
|
303
|
-
const char = part[index];
|
|
304
|
-
const isUpperCaseChar = char === char.toLocaleUpperCase(locale);
|
|
305
|
-
if (!previousIsUpper2 && isUpperCaseChar) {
|
|
306
|
-
result2.push(word);
|
|
307
|
-
word = char;
|
|
308
|
-
} else {
|
|
309
|
-
word += char;
|
|
310
|
-
}
|
|
311
|
-
previousIsUpper2 = isUpperCaseChar;
|
|
312
|
-
}
|
|
313
|
-
if (word) {
|
|
314
|
-
result2.push(word);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
return result2;
|
|
318
|
-
}
|
|
319
|
-
if (locale.startsWith("ja") || locale.startsWith("ko")) {
|
|
320
|
-
const isJapanese = locale.startsWith("ja");
|
|
321
|
-
const scriptDetectors = isJapanese ? {
|
|
322
|
-
hiragana: /* @__PURE__ */ __name((char) => constants.RE_HIRAGANA.test(char), "hiragana"),
|
|
323
|
-
kanji: /* @__PURE__ */ __name((char) => constants.RE_KANJI.test(char), "kanji"),
|
|
324
|
-
katakana: /* @__PURE__ */ __name((char) => constants.RE_KATAKANA.test(char), "katakana"),
|
|
325
|
-
latin: /* @__PURE__ */ __name((char) => constants.RE_LATIN.test(char), "latin")
|
|
326
|
-
} : {
|
|
327
|
-
hangul: /* @__PURE__ */ __name((char) => constants.RE_HANGUL.test(char), "hangul"),
|
|
328
|
-
latin: /* @__PURE__ */ __name((char) => constants.RE_LATIN.test(char), "latin")
|
|
329
|
-
};
|
|
330
|
-
const particles = /* @__PURE__ */ new Set(["と", "に", "へ", "を", "は", "が", "の", "で", "や", "も"]);
|
|
331
|
-
if (isJapanese) {
|
|
332
|
-
const baseSegments = handleScriptTransitions(
|
|
333
|
-
s,
|
|
334
|
-
scriptDetectors,
|
|
335
|
-
false,
|
|
336
|
-
locale,
|
|
337
|
-
(previousType, currentType) => previousType === "hiragana" && currentType === "katakana" || // hiragana -> katakana
|
|
338
|
-
previousType === "katakana" && currentType === "hiragana" || // katakana -> hiragana
|
|
339
|
-
previousType === "hiragana" && currentType === "latin" || // hiragana -> latin
|
|
340
|
-
previousType === "katakana" && currentType === "latin" || // katakana -> latin
|
|
341
|
-
previousType === "kanji" && currentType === "latin" || // kanji -> latin
|
|
342
|
-
previousType === "latin" && (currentType === "hiragana" || currentType === "katakana" || currentType === "kanji")
|
|
343
|
-
// latin -> japanese
|
|
344
|
-
);
|
|
345
|
-
const result2 = [];
|
|
346
|
-
for (const segment of baseSegments) {
|
|
347
|
-
if (segment.length === 1 && particles.has(segment) && result2.length > 0) {
|
|
348
|
-
result2[result2.length - 1] += segment;
|
|
349
|
-
} else {
|
|
350
|
-
result2.push(segment);
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
return result2.length > 0 ? result2 : [s];
|
|
354
|
-
}
|
|
355
|
-
return handleScriptTransitions(
|
|
356
|
-
s,
|
|
357
|
-
scriptDetectors,
|
|
358
|
-
false,
|
|
359
|
-
locale,
|
|
360
|
-
(previousType, currentType) => previousType === "hangul" && currentType === "latin" || // hangul -> latin
|
|
361
|
-
previousType === "latin" && currentType === "hangul"
|
|
362
|
-
// latin -> hangul
|
|
363
|
-
);
|
|
364
|
-
}
|
|
365
|
-
if (locale.startsWith("sl")) {
|
|
366
|
-
const chars2 = [...s];
|
|
367
|
-
const width_2 = chars2.length;
|
|
368
|
-
const result2 = [];
|
|
369
|
-
let currentSegment2 = chars2[0];
|
|
370
|
-
let previousIsUpper2 = chars2[0] === chars2[0].toLocaleUpperCase(locale);
|
|
371
|
-
for (let index = 1; index < width_2; index++) {
|
|
372
|
-
const char = chars2[index];
|
|
373
|
-
const isUpperCaseChar = char === char.toLocaleUpperCase(locale);
|
|
374
|
-
const isSpecialChar = /[ČŠŽĐ]/i.test(char);
|
|
375
|
-
const nextIsUpper = index < width_2 - 1 && chars2[index + 1] === chars2[index + 1].toLocaleUpperCase(locale);
|
|
376
|
-
if (!previousIsUpper2 && isUpperCaseChar || isSpecialChar && nextIsUpper) {
|
|
377
|
-
result2.push(currentSegment2);
|
|
378
|
-
currentSegment2 = char;
|
|
379
|
-
if (isSpecialChar && nextIsUpper) {
|
|
380
|
-
result2.push(currentSegment2);
|
|
381
|
-
currentSegment2 = "";
|
|
382
|
-
}
|
|
383
|
-
} else {
|
|
384
|
-
currentSegment2 += char;
|
|
385
|
-
}
|
|
386
|
-
previousIsUpper2 = isUpperCaseChar;
|
|
387
|
-
}
|
|
388
|
-
if (currentSegment2 && currentSegment2.length > 0) {
|
|
389
|
-
result2.push(currentSegment2);
|
|
390
|
-
}
|
|
391
|
-
return result2;
|
|
392
|
-
}
|
|
393
|
-
if (locale.startsWith("zh")) {
|
|
394
|
-
return handleScriptTransitions(
|
|
395
|
-
s,
|
|
396
|
-
{
|
|
397
|
-
han: /* @__PURE__ */ __name((char) => constants.RE_KANJI.test(char), "han"),
|
|
398
|
-
latin: /* @__PURE__ */ __name((char) => constants.RE_LATIN.test(char), "latin")
|
|
399
|
-
},
|
|
400
|
-
false,
|
|
401
|
-
locale
|
|
402
|
-
);
|
|
403
|
-
}
|
|
404
|
-
if (["ar", "fa", "he", "ur"].includes(locale.split("-")[0])) {
|
|
405
|
-
const isRtlChar = /* @__PURE__ */ __name((ch) => constants.RE_HEBREW.test(ch) || constants.RE_ARABIC.test(ch), "isRtlChar");
|
|
406
|
-
return handleScriptTransitions(
|
|
407
|
-
s,
|
|
408
|
-
{
|
|
409
|
-
latin: /* @__PURE__ */ __name((char) => constants.RE_LATIN.test(char), "latin"),
|
|
410
|
-
rtl: /* @__PURE__ */ __name((char) => isRtlChar(char), "rtl")
|
|
411
|
-
},
|
|
412
|
-
false,
|
|
413
|
-
locale
|
|
414
|
-
);
|
|
415
|
-
}
|
|
416
|
-
if ([
|
|
417
|
-
"am",
|
|
418
|
-
// Amharic
|
|
419
|
-
"bn",
|
|
420
|
-
// Bengali
|
|
421
|
-
"gu",
|
|
422
|
-
// Gujarati
|
|
423
|
-
"hi",
|
|
424
|
-
// Hindi
|
|
425
|
-
"km",
|
|
426
|
-
// Khmer
|
|
427
|
-
"kn",
|
|
428
|
-
// Kannada
|
|
429
|
-
"lo",
|
|
430
|
-
// Lao
|
|
431
|
-
"ml",
|
|
432
|
-
// Malayalam
|
|
433
|
-
"mr",
|
|
434
|
-
// Marathi
|
|
435
|
-
"ne",
|
|
436
|
-
// Nepali
|
|
437
|
-
"or",
|
|
438
|
-
// Oriya
|
|
439
|
-
"pa",
|
|
440
|
-
// Punjabi
|
|
441
|
-
"si",
|
|
442
|
-
// Sinhala
|
|
443
|
-
"ta",
|
|
444
|
-
// Tamil
|
|
445
|
-
"te",
|
|
446
|
-
// Telugu
|
|
447
|
-
"th"
|
|
448
|
-
// Thai
|
|
449
|
-
].includes(locale.split("-")[0])) {
|
|
450
|
-
const isIndicChar = /* @__PURE__ */ __name((ch) => constants.RE_DEVANAGARI.test(ch) || constants.RE_BENGALI.test(ch) || constants.RE_GUJARATI.test(ch) || constants.RE_GURMUKHI.test(ch) || constants.RE_KANNADA.test(ch) || constants.RE_TAMIL.test(ch) || constants.RE_TELUGU.test(ch) || constants.RE_MALAYALAM.test(ch) || constants.RE_SINHALA.test(ch) || constants.RE_THAI.test(ch) || constants.RE_LAO.test(ch) || constants.RE_TIBETAN.test(ch) || constants.RE_MYANMAR.test(ch) || constants.RE_ETHIOPIC.test(ch) || constants.RE_KHMER.test(ch) || constants.RE_ORIYA.test(ch), "isIndicChar");
|
|
451
|
-
return handleScriptTransitions(
|
|
452
|
-
s,
|
|
453
|
-
{
|
|
454
|
-
indic: /* @__PURE__ */ __name((char) => isIndicChar(char), "indic"),
|
|
455
|
-
latin: /* @__PURE__ */ __name((char) => constants.RE_LATIN.test(char), "latin")
|
|
456
|
-
},
|
|
457
|
-
false,
|
|
458
|
-
locale
|
|
459
|
-
);
|
|
460
|
-
}
|
|
461
|
-
if (["be", "bg", "ru", "sr", "uk"].includes(locale)) {
|
|
462
|
-
return handleScriptTransitions(
|
|
463
|
-
s,
|
|
464
|
-
{
|
|
465
|
-
cyrillic: /* @__PURE__ */ __name((char) => constants.RE_CYRILLIC.test(char), "cyrillic"),
|
|
466
|
-
latin: /* @__PURE__ */ __name((char) => constants.RE_LATIN.test(char), "latin")
|
|
467
|
-
},
|
|
468
|
-
true,
|
|
469
|
-
// Enable case-sensitive splitting
|
|
470
|
-
locale
|
|
471
|
-
);
|
|
472
|
-
}
|
|
473
|
-
if (["ar", "fa", "he"].includes(locale)) {
|
|
474
|
-
return handleScriptTransitions(
|
|
475
|
-
s,
|
|
476
|
-
{
|
|
477
|
-
latin: /* @__PURE__ */ __name((char) => constants.RE_LATIN.test(char), "latin"),
|
|
478
|
-
rtl: /* @__PURE__ */ __name((char) => constants.RE_HEBREW.test(char) || constants.RE_ARABIC.test(char), "rtl")
|
|
479
|
-
},
|
|
480
|
-
false,
|
|
481
|
-
locale
|
|
482
|
-
);
|
|
483
|
-
}
|
|
484
|
-
if (locale.startsWith("ko")) {
|
|
485
|
-
return handleScriptTransitions(
|
|
486
|
-
s,
|
|
487
|
-
{
|
|
488
|
-
hangul: /* @__PURE__ */ __name((char) => constants.RE_HANGUL.test(char), "hangul"),
|
|
489
|
-
latin: /* @__PURE__ */ __name((char) => constants.RE_LATIN.test(char), "latin")
|
|
490
|
-
},
|
|
491
|
-
false,
|
|
492
|
-
locale
|
|
493
|
-
);
|
|
494
|
-
}
|
|
495
|
-
if (locale.startsWith("uz")) {
|
|
496
|
-
if (!constants.RE_CYRILLIC.test(s) && !constants.RE_LATIN.test(s)) {
|
|
497
|
-
return [s];
|
|
498
|
-
}
|
|
499
|
-
const chars2 = [...s];
|
|
500
|
-
const width_2 = chars2.length;
|
|
501
|
-
const result2 = [];
|
|
502
|
-
let currentSegment2 = chars2[0];
|
|
503
|
-
let previousIsUpper2 = chars2[0] === chars2[0].toLocaleUpperCase(locale);
|
|
504
|
-
for (let index = 1; index < width_2; index++) {
|
|
505
|
-
const char = chars2[index];
|
|
506
|
-
const isUpperCaseChar = char === char.toLocaleUpperCase(locale);
|
|
507
|
-
if (constants.RE_UZBEK_LATIN_MODIFIER.test(char) || constants.RE_UZBEK_LATIN_MODIFIER.test(chars2[index - 1])) {
|
|
508
|
-
currentSegment2 += char;
|
|
509
|
-
continue;
|
|
510
|
-
}
|
|
511
|
-
if (!previousIsUpper2 && isUpperCaseChar) {
|
|
512
|
-
result2.push(currentSegment2);
|
|
513
|
-
currentSegment2 = char;
|
|
514
|
-
} else {
|
|
515
|
-
currentSegment2 += char;
|
|
516
|
-
}
|
|
517
|
-
previousIsUpper2 = isUpperCaseChar;
|
|
518
|
-
}
|
|
519
|
-
if (currentSegment2 && currentSegment2.length > 0) {
|
|
520
|
-
result2.push(currentSegment2);
|
|
521
|
-
}
|
|
522
|
-
return result2;
|
|
523
|
-
}
|
|
524
|
-
const chars = [...s];
|
|
525
|
-
const width_ = chars.length;
|
|
526
|
-
const result = [];
|
|
527
|
-
let currentSegment = chars[0];
|
|
528
|
-
let previousIsUpper = chars[0] === chars[0].toLocaleUpperCase(locale);
|
|
529
|
-
for (const acronym of knownAcronyms) {
|
|
530
|
-
if (s.startsWith(acronym)) {
|
|
531
|
-
result.push(acronym);
|
|
532
|
-
currentSegment = chars[acronym.length];
|
|
533
|
-
previousIsUpper = currentSegment === currentSegment.toLocaleUpperCase(locale);
|
|
534
|
-
break;
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
for (let index = 1; index < width_; index++) {
|
|
538
|
-
const char = chars[index];
|
|
539
|
-
const isUpperCaseChar = char === char.toLocaleUpperCase(locale);
|
|
540
|
-
let isAcronym = false;
|
|
541
|
-
for (const acronym of knownAcronyms) {
|
|
542
|
-
if (s.startsWith(acronym, index)) {
|
|
543
|
-
result.push(currentSegment, acronym);
|
|
544
|
-
index += acronym.length - 1;
|
|
545
|
-
currentSegment = "";
|
|
546
|
-
isAcronym = true;
|
|
547
|
-
break;
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
if (isAcronym) {
|
|
551
|
-
continue;
|
|
552
|
-
}
|
|
553
|
-
if (!previousIsUpper && isUpperCaseChar) {
|
|
554
|
-
result.push(currentSegment);
|
|
555
|
-
currentSegment = char;
|
|
556
|
-
} else {
|
|
557
|
-
currentSegment += char;
|
|
558
|
-
}
|
|
559
|
-
previousIsUpper = isUpperCaseChar;
|
|
560
|
-
}
|
|
561
|
-
if (currentSegment) {
|
|
562
|
-
result.push(currentSegment);
|
|
563
|
-
}
|
|
564
|
-
return result;
|
|
565
|
-
}, "splitCamelCaseLocale");
|
|
566
|
-
const processTextWithAnsiEmoji = /* @__PURE__ */ __name((text, locale, knownAcronyms) => {
|
|
567
|
-
const result = [];
|
|
568
|
-
const segments = constants.RE_FAST_ANSI.test(text) ? text.split(constants.RE_FAST_ANSI).filter(Boolean) : [text];
|
|
569
|
-
for (const seg of segments) {
|
|
570
|
-
if (constants.RE_FAST_ANSI.test(seg)) {
|
|
571
|
-
result.push(seg);
|
|
572
|
-
} else {
|
|
573
|
-
const subs = constants.RE_EMOJI.test(seg) ? splitByEmoji(seg).filter(Boolean) : [seg];
|
|
574
|
-
for (const sub of subs) {
|
|
575
|
-
if (constants.RE_EMOJI.test(sub)) {
|
|
576
|
-
result.push(sub);
|
|
577
|
-
} else {
|
|
578
|
-
if (locale) {
|
|
579
|
-
const normalizedLocale = locale.toLowerCase().split("-")[0];
|
|
580
|
-
result.push(...splitCamelCaseLocale(sub, normalizedLocale, knownAcronyms));
|
|
581
|
-
} else {
|
|
582
|
-
result.push(...splitCamelCaseFast(sub, knownAcronyms));
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
return result;
|
|
589
|
-
}, "processTextWithAnsiEmoji");
|
|
590
|
-
const splitByCase = /* @__PURE__ */ __name((input, options = {}) => {
|
|
591
|
-
if (!input || typeof input !== "string") {
|
|
592
|
-
return [];
|
|
593
|
-
}
|
|
594
|
-
const {
|
|
595
|
-
handleAnsi = false,
|
|
596
|
-
handleEmoji = false,
|
|
597
|
-
knownAcronyms = [],
|
|
598
|
-
locale,
|
|
599
|
-
normalize = false,
|
|
600
|
-
separators,
|
|
601
|
-
stripAnsi: stripAnsiOption = false,
|
|
602
|
-
stripEmoji: stripEmojiOption = false
|
|
603
|
-
} = options;
|
|
604
|
-
const acronymSet = new Set([...knownAcronyms].sort((a, b) => b.length - a.length));
|
|
605
|
-
let cleanedInput = input;
|
|
606
|
-
if (stripAnsiOption) {
|
|
607
|
-
cleanedInput = node_util.stripVTControlCharacters(cleanedInput);
|
|
608
|
-
}
|
|
609
|
-
if (stripEmojiOption) {
|
|
610
|
-
cleanedInput = constants.stripEmoji(cleanedInput);
|
|
611
|
-
}
|
|
612
|
-
const separatorRegex = Array.isArray(separators) ? getSeparatorsRegex(separators) : separators instanceof RegExp ? separators : constants.RE_SEPARATORS;
|
|
613
|
-
const parts = cleanedInput.split(separatorRegex).filter(Boolean);
|
|
614
|
-
let tokens = [];
|
|
615
|
-
for (const part of parts) {
|
|
616
|
-
if (handleAnsi || handleEmoji) {
|
|
617
|
-
tokens.push(...processTextWithAnsiEmoji(part, locale, acronymSet));
|
|
618
|
-
} else if (locale) {
|
|
619
|
-
tokens.push(...splitCamelCaseLocale(part, locale, acronymSet));
|
|
620
|
-
} else {
|
|
621
|
-
tokens.push(...splitCamelCaseFast(part, acronymSet));
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
if (normalize) {
|
|
625
|
-
tokens = tokens.map((token) => {
|
|
626
|
-
if (acronymSet.has(token)) {
|
|
627
|
-
return token;
|
|
628
|
-
}
|
|
629
|
-
if (locale && token === token.toLocaleUpperCase(locale)) {
|
|
630
|
-
return token[0] + token.slice(1).toLocaleLowerCase(locale);
|
|
631
|
-
}
|
|
632
|
-
if (token.toUpperCase() === token && !acronymSet.has(token)) {
|
|
633
|
-
return token.slice(0, 1) + token.slice(1).toLowerCase();
|
|
634
|
-
}
|
|
635
|
-
return token;
|
|
636
|
-
});
|
|
637
|
-
}
|
|
638
|
-
return tokens;
|
|
639
|
-
}, "splitByCase");
|
|
640
|
-
|
|
641
|
-
exports.splitByCase = splitByCase;
|
|
1
|
+
"use strict";var R=Object.defineProperty;var A=(e,s)=>R(e,"name",{value:s,configurable:!0});Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const I=require("node:util"),r=require("../packem_shared/constants-D3K8u3G8.cjs"),q=require("../packem_shared/LRUCache-TYqfUYE5.cjs");var z=Object.defineProperty,M=A((e,s)=>z(e,"name",{value:s,configurable:!0}),"g");const y=new q(1e3),T=M(e=>{const s=e.join("");if(y.has(s))return y.get(s);const p=e.map(k=>k.replaceAll(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),g=new RegExp(p,"g");return y.set(s,g),g},"getSeparatorsRegex");var _=Object.defineProperty,D=A((e,s)=>_(e,"name",{value:s,configurable:!0}),"t");const $=D(e=>{const s=[];let p=0,g;for(r.j.lastIndex=0;(g=r.j.exec(e))!==null;)g.index>p&&s.push(e.slice(p,g.index)),s.push(g[0]),p=r.j.lastIndex;return p<e.length&&s.push(e.slice(p)),s.filter(Boolean)},"splitByEmoji");var F=Object.defineProperty,C=A((e,s)=>F(e,"name",{value:s,configurable:!0}),"u");const E=new Uint8Array(128),B=new Uint8Array(128),S=new Uint8Array(128);for(let e=0;e<128;e++)E[e]=e>=65&&e<=90?1:0,B[e]=e>=97&&e<=122?1:0,S[e]=e>=48&&e<=57?1:0;const w=C(e=>E[e],"isUpper"),x=C(e=>B[e],"isLower"),v=C(e=>S[e],"isDigit"),j=C((e,s,p,g,k)=>{if(e.length===0)return[];let h=!1;for(const l of Object.values(s))if(l(e[0])){h=!0;break}if(!h&&!p)return[e];const m=[...e],u=[];let U=m[0],t="other";for(const[l,a]of Object.entries(s))if(a(m[0])){t=l;break}let o=p&&g?m[0]===m[0].toLocaleUpperCase(g):!1;for(let l=1;l<m.length;l++){const a=m[l];let i="other";for(const[f,d]of Object.entries(s))if(d(a)){i=f;break}const c=p&&g?a===a.toLocaleUpperCase(g):!1;let n=!1;k?n=k(t,i,o,c,a,l,m):(t!==i&&t!=="other"&&i!=="other"&&(n=!0),p&&i!=="other"&&!o&&c&&(n=!0)),n?(u.push(U),U=a):U+=a,t=i,p&&(o=c)}return U&&U.length>0&&u.push(U),u.length>0?u:[e]},"handleScriptTransitions"),O=C((e,s=new Set)=>{if(e.length===0)return[];if(e.toUpperCase()===e)return[e];let p=0;const g=[],k=e.length;for(let h=1;h<k;h++){const m=e.codePointAt(h-1),u=e.codePointAt(h);if(s.size>0){for(const i of s)if(e.startsWith(i,p)){g.push(i),p+=i.length,h=p-1;break}if(h<p)continue}const U=m&&m<128&&w(m),t=u&&u<128&&w(u),o=m&&m<128&&x(m),l=m&&m<128&&v(m),a=u&&u<128&&v(u);if(o&&t){g.push(e.slice(p,h)),p=h;continue}if(l&&!a||!l&&a){g.push(e.slice(p,h)),p=h;continue}if(a&&!l){let i=!1,c=!1;if(h+1<k){const n=e.codePointAt(h+1);i=n&&n<128&&w(n),c=n&&n<128&&v(n)}if(!c&&i){g.push(e.slice(p,h),e.slice(h,h+1)),p=h+1;continue}}if(h+1<k){const i=e.codePointAt(h+1),c=i&&i<128&&x(i);if(U&&t&&c){const n=e.slice(p,h+1);s.has(n)||(g.push(e.slice(p,h)),p=h)}}}return p<k&&g.push(e.slice(p)),g.filter(h=>h!=="")},"splitCamelCaseFast"),P=C((e,s,p)=>{if(e.length===0)return[];const g=e===e.toLocaleUpperCase(s);if(s.startsWith("de")){if(!g&&e.replaceAll("ß","SS")===e.toLocaleUpperCase(s))return[e];const t=[...e],o=t.length,l=[];let a=t[0],i=t[0]===t[0].toLocaleUpperCase(s),c=i,n=i?0:-1;for(let f=1;f<o;f++){const d=t[f],L=d===d.toLocaleUpperCase(s);if(L===i)a+=d;else if(L)a&&a.length>0&&(l.push(a),a=d),c=!0,n=f;else{if(c&&f-n>1){const b=t[f-1],W=a.slice(0,-1);W&&W.length>0&&l.push(W),a=b+d}else a+=d;c=!1,n=-1}i=L}return a&&a.length>0&&l.push(a),l}if(s.startsWith("uk")||s.startsWith("ru")||s.startsWith("bg")||s.startsWith("sr")||s.startsWith("mk")||s.startsWith("be")){if(!r.l.test(e)&&!r.m.test(e))return[e];const t=[...e],o=t.length,l=[];let a=t[0],i=r.l.test(t[0])?1:r.m.test(t[0])?2:0,c=t[0]===t[0].toLocaleUpperCase(s);for(let f=1;f<o;f++){const d=t[f],L=r.l.test(d)?1:r.m.test(d)?2:0,b=d===d.toLocaleUpperCase(s);i!==L&&(i===1||i===2)&&(L===1||L===2)||L===i&&!c&&b?(l.push(a),a=d):a+=d,i=L,c=b}a&&a.length>0&&l.push(a);const n=[];for(let f=0;f<l.length;f++)f<l.length-1&&l[f].length===1&&r.m.test(l[f])&&r.l.test(l[f+1][0])?(n.push(l[f]+l[f+1]),f++):n.push(l[f]);return n}if(s.startsWith("el")){if(!r.n.test(e)&&!r.m.test(e))return[e];const t=e.match(r.o)??[e],o=[];if(t.length===1){const l=t[0];if(!l||!r.n.test(l[0])||l.length===1)return[l||e]}for(const l of t){if(!l)continue;if(!r.n.test(l[0])||l.length===1){o.push(l);continue}const a=l.length;let i=l[0],c=l[0]===l[0].toLocaleUpperCase(s);for(let n=1;n<a;n++){const f=l[n],d=f===f.toLocaleUpperCase(s);!c&&d?(o.push(i),i=f):i+=f,c=d}i&&o.push(i)}return o}if(s.startsWith("ja")||s.startsWith("ko")){const t=s.startsWith("ja"),o=t?{hiragana:C(a=>r.r.test(a),"hiragana"),kanji:C(a=>r.q.test(a),"kanji"),katakana:C(a=>r.p.test(a),"katakana"),latin:C(a=>r.m.test(a),"latin")}:{hangul:C(a=>r.t.test(a),"hangul"),latin:C(a=>r.m.test(a),"latin")},l=new Set(["と","に","へ","を","は","が","の","で","や","も"]);if(t){const a=j(e,o,!1,s,(c,n)=>c==="hiragana"&&n==="katakana"||c==="katakana"&&n==="hiragana"||c==="hiragana"&&n==="latin"||c==="katakana"&&n==="latin"||c==="kanji"&&n==="latin"||c==="latin"&&(n==="hiragana"||n==="katakana"||n==="kanji")),i=[];for(const c of a)c.length===1&&l.has(c)&&i.length>0?i[i.length-1]+=c:i.push(c);return i.length>0?i:[e]}return j(e,o,!1,s,(a,i)=>a==="hangul"&&i==="latin"||a==="latin"&&i==="hangul")}if(s.startsWith("sl")){const t=[...e],o=t.length,l=[];let a=t[0],i=t[0]===t[0].toLocaleUpperCase(s);for(let c=1;c<o;c++){const n=t[c],f=n===n.toLocaleUpperCase(s),d=/[ČŠŽĐ]/i.test(n),L=c<o-1&&t[c+1]===t[c+1].toLocaleUpperCase(s);!i&&f||d&&L?(l.push(a),a=n,d&&L&&(l.push(a),a="")):a+=n,i=f}return a&&a.length>0&&l.push(a),l}if(s.startsWith("zh"))return j(e,{han:C(t=>r.q.test(t),"han"),latin:C(t=>r.m.test(t),"latin")},!1,s);if(["ar","fa","he","ur"].includes(s.split("-")[0])){const t=C(o=>r.u.test(o)||r.v.test(o),"isRtlChar");return j(e,{latin:C(o=>r.m.test(o),"latin"),rtl:C(o=>t(o),"rtl")},!1,s)}if(["am","bn","gu","hi","km","kn","lo","ml","mr","ne","or","pa","si","ta","te","th"].includes(s.split("-")[0])){const t=C(o=>r.w.test(o)||r.x.test(o)||r.y.test(o)||r.z.test(o)||r.A.test(o)||r.B.test(o)||r.C.test(o)||r.D.test(o)||r.E.test(o)||r.F.test(o)||r.G.test(o)||r.H.test(o)||r.I.test(o)||r.J.test(o)||r.K.test(o)||r.L.test(o),"isIndicChar");return j(e,{indic:C(o=>t(o),"indic"),latin:C(o=>r.m.test(o),"latin")},!1,s)}if(["be","bg","ru","sr","uk"].includes(s))return j(e,{cyrillic:C(t=>r.l.test(t),"cyrillic"),latin:C(t=>r.m.test(t),"latin")},!0,s);if(["ar","fa","he"].includes(s))return j(e,{latin:C(t=>r.m.test(t),"latin"),rtl:C(t=>r.u.test(t)||r.v.test(t),"rtl")},!1,s);if(s.startsWith("ko"))return j(e,{hangul:C(t=>r.t.test(t),"hangul"),latin:C(t=>r.m.test(t),"latin")},!1,s);if(s.startsWith("uz")){if(!r.l.test(e)&&!r.m.test(e))return[e];const t=[...e],o=t.length,l=[];let a=t[0],i=t[0]===t[0].toLocaleUpperCase(s);for(let c=1;c<o;c++){const n=t[c],f=n===n.toLocaleUpperCase(s);if(r.M.test(n)||r.M.test(t[c-1])){a+=n;continue}!i&&f?(l.push(a),a=n):a+=n,i=f}return a&&a.length>0&&l.push(a),l}const k=[...e],h=k.length,m=[];let u=k[0],U=k[0]===k[0].toLocaleUpperCase(s);for(const t of p)if(e.startsWith(t)){m.push(t),u=k[t.length],U=u===u.toLocaleUpperCase(s);break}for(let t=1;t<h;t++){const o=k[t],l=o===o.toLocaleUpperCase(s);let a=!1;for(const i of p)if(e.startsWith(i,t)){m.push(u,i),t+=i.length-1,u="",a=!0;break}a||(!U&&l?(m.push(u),u=o):u+=o,U=l)}return u&&m.push(u),m},"splitCamelCaseLocale"),G=C((e,s,p)=>{const g=[],k=r.R.test(e)?e.split(r.R).filter(Boolean):[e];for(const h of k)if(r.R.test(h))g.push(h);else{const m=r.j.test(h)?$(h).filter(Boolean):[h];for(const u of m)if(r.j.test(u))g.push(u);else if(s){const U=s.toLowerCase().split("-")[0];g.push(...P(u,U,p))}else g.push(...O(u,p))}return g},"processTextWithAnsiEmoji"),H=C((e,s={})=>{if(!e||typeof e!="string")return[];const{handleAnsi:p=!1,handleEmoji:g=!1,knownAcronyms:k=[],locale:h,normalize:m=!1,separators:u,stripAnsi:U=!1,stripEmoji:t=!1}=s,o=new Set([...k].sort((n,f)=>f.length-n.length));let l=e;U&&(l=I.stripVTControlCharacters(l)),t&&(l=r.s(l));const a=Array.isArray(u)?T(u):u instanceof RegExp?u:r.k,i=l.split(a).filter(Boolean);let c=[];for(const n of i)p||g?c.push(...G(n,h,o)):h?c.push(...P(n,h,o)):c.push(...O(n,o));return m&&(c=c.map(n=>o.has(n)?n:h&&n===n.toLocaleUpperCase(h)?n[0]+n.slice(1).toLocaleLowerCase(h):n.toUpperCase()===n&&!o.has(n)?n.slice(0,1)+n.slice(1).toLowerCase():n)),c},"splitByCase");exports.splitByCase=H;
|