@alchemy.run/sigil 0.0.0-alpha.1 → 0.0.0-alpha.11

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.
Files changed (223) hide show
  1. package/README.md +499 -313
  2. package/THIRD_PARTY_NOTICES.md +98 -23
  3. package/dist/Text-DV9CuzAT.d.ts +452 -0
  4. package/dist/ansi.d.ts +217 -0
  5. package/dist/ansi.js +87 -0
  6. package/dist/capabilities.d.ts +5 -0
  7. package/dist/capabilities.js +3 -0
  8. package/dist/cell-_ZVhbfl0.js +44 -0
  9. package/dist/color-CkbalRqK.js +2 -0
  10. package/dist/color-policy-BAC9-TZX.js +592 -0
  11. package/dist/color-policy-CCxuHIdD.d.ts +22 -0
  12. package/dist/color-profile-CyeHnG1T.d.ts +97 -0
  13. package/dist/color-profile-DHhQHY55.js +36 -0
  14. package/dist/color.d.ts +21 -0
  15. package/dist/color.js +3 -0
  16. package/dist/cursor-position-D2LAkRG0.d.ts +7 -0
  17. package/dist/detect-B3dL4Q11.js +374 -0
  18. package/dist/detect-Db6GbKOm.d.ts +195 -0
  19. package/dist/{devtools-QpCMm9JH.mjs → devtools-DbthxoD1.js} +23 -24
  20. package/dist/env-YVw64yZS.js +9 -0
  21. package/dist/escapes-CB_6CWOE.d.ts +72 -0
  22. package/dist/geometry-BxXOzJgo.d.ts +11 -0
  23. package/dist/index-D48vQhhe.d.ts +21 -0
  24. package/dist/index-DDVME65c.d.ts +919 -0
  25. package/dist/index.d.ts +1310 -0
  26. package/dist/index.js +3211 -0
  27. package/dist/jsx-dev-runtime.d.ts +2 -0
  28. package/dist/jsx-dev-runtime.js +227 -0
  29. package/dist/jsx-runtime-XtwIVFsg.js +255 -0
  30. package/dist/jsx-runtime.d.ts +2 -0
  31. package/dist/jsx-runtime.js +8 -0
  32. package/dist/osc-BFKKSqpg.js +71 -0
  33. package/dist/osc-Cn0fw77g.d.ts +23 -0
  34. package/dist/paint-Cx-zC_sX.d.ts +81 -0
  35. package/dist/query-BNc2B8GD.d.ts +152 -0
  36. package/dist/react-CTZ_8dwh.js +1197 -0
  37. package/dist/react.d.ts +2 -0
  38. package/dist/react.js +49 -0
  39. package/dist/router.d.ts +392 -0
  40. package/dist/router.js +711 -0
  41. package/dist/sample-Cqw1bjUL.js +445 -0
  42. package/dist/screen-CgC2WlVM.d.ts +49 -0
  43. package/dist/screen-CiPytswf.js +342 -0
  44. package/dist/screen.d.ts +5 -0
  45. package/dist/screen.js +5 -0
  46. package/dist/semantic-text-style-DIMzC7xt.js +91 -0
  47. package/dist/serialize-BTkAZgw1.js +79 -0
  48. package/dist/session-DDQ5V300.js +723 -0
  49. package/dist/sgr-BhwaWAJB.js +246 -0
  50. package/dist/store-C1P5fOUi.d.ts +72 -0
  51. package/dist/string-width-CijQwpIk.js +69 -0
  52. package/dist/strip-BvU4toXG.js +6 -0
  53. package/dist/terminal.d.ts +121 -0
  54. package/dist/terminal.js +2 -0
  55. package/dist/tokenize-AjqbvtiT.js +1242 -0
  56. package/dist/tokenize-Dx1y_l5H.d.ts +57 -0
  57. package/dist/truncate-D31fhU6i.js +562 -0
  58. package/dist/use-focus-B5npZrJU.js +18736 -0
  59. package/dist/yoga-5jKhYCJC.js +3465 -0
  60. package/dist/yoga.d.ts +2 -0
  61. package/dist/yoga.js +2 -0
  62. package/package.json +89 -29
  63. package/src/ansi/chalk.ts +138 -0
  64. package/src/ansi/cursor.ts +46 -0
  65. package/src/ansi/east-asian-width.ts +259 -0
  66. package/src/ansi/escapes.ts +120 -0
  67. package/src/ansi/graphemes.ts +8 -0
  68. package/src/ansi/hyperlink.ts +44 -0
  69. package/src/ansi/index.ts +27 -0
  70. package/src/ansi/osc.ts +77 -0
  71. package/src/ansi/sgr.ts +234 -0
  72. package/src/ansi/slice.ts +43 -0
  73. package/src/ansi/string-width.ts +121 -0
  74. package/src/ansi/strip.ts +13 -0
  75. package/src/ansi/tokenize.ts +380 -0
  76. package/src/ansi/truncate.ts +196 -0
  77. package/src/ansi/wrap.ts +765 -0
  78. package/src/ansi-tokenizer.ts +510 -0
  79. package/src/capabilities/color-policy.ts +34 -0
  80. package/src/capabilities/detect.ts +608 -0
  81. package/src/capabilities/index.ts +37 -0
  82. package/src/capabilities/query.ts +679 -0
  83. package/src/capabilities/store.ts +394 -0
  84. package/src/code-excerpt.ts +39 -0
  85. package/src/color/index.ts +3 -0
  86. package/src/color/paint.ts +169 -0
  87. package/src/color/palette.ts +48 -0
  88. package/src/color/sample.ts +323 -0
  89. package/src/color.ts +1 -0
  90. package/src/components/AccessibilityContext.ts +5 -0
  91. package/src/components/AnimationContext.ts +24 -0
  92. package/src/components/AnsiText.tsx +42 -0
  93. package/src/components/App.tsx +878 -0
  94. package/src/components/AppContext.ts +111 -0
  95. package/src/components/BackgroundContext.ts +7 -0
  96. package/src/components/Box.tsx +100 -0
  97. package/src/components/CursorContext.ts +19 -0
  98. package/src/components/ErrorBoundary.tsx +39 -0
  99. package/src/components/ErrorOverview.tsx +135 -0
  100. package/src/components/FocusContext.ts +30 -0
  101. package/src/components/Hyperlink.tsx +56 -0
  102. package/src/components/Newline.tsx +16 -0
  103. package/src/components/Spacer.tsx +11 -0
  104. package/src/components/Static.tsx +60 -0
  105. package/src/components/StderrContext.ts +24 -0
  106. package/src/components/StdinContext.ts +48 -0
  107. package/src/components/StdoutContext.ts +26 -0
  108. package/src/components/TerminalOscContext.ts +25 -0
  109. package/src/components/Text.tsx +122 -0
  110. package/src/components/Transform.tsx +38 -0
  111. package/src/components/VirtualList.tsx +128 -0
  112. package/src/cursor-position.ts +103 -0
  113. package/src/devtools.ts +103 -0
  114. package/src/dom.ts +301 -0
  115. package/src/env.ts +12 -0
  116. package/src/get-max-width.ts +11 -0
  117. package/src/global.d.ts +38 -0
  118. package/src/glyphs.ts +99 -0
  119. package/src/hooks/use-animation.ts +142 -0
  120. package/src/hooks/use-app.ts +8 -0
  121. package/src/hooks/use-box-metrics.ts +134 -0
  122. package/src/hooks/use-capabilities.ts +73 -0
  123. package/src/hooks/use-cursor.ts +33 -0
  124. package/src/hooks/use-focus-manager.ts +62 -0
  125. package/src/hooks/use-focus.ts +82 -0
  126. package/src/hooks/use-input.ts +267 -0
  127. package/src/hooks/use-is-screen-reader-enabled.ts +12 -0
  128. package/src/hooks/use-paste.ts +78 -0
  129. package/src/hooks/use-stderr.ts +8 -0
  130. package/src/hooks/use-stdin.ts +10 -0
  131. package/src/hooks/use-stdout.ts +8 -0
  132. package/src/hooks/use-terminal-osc.ts +59 -0
  133. package/src/hooks/use-virtual-scroll.ts +84 -0
  134. package/src/hooks/use-window-size.ts +37 -0
  135. package/src/index.ts +96 -0
  136. package/src/ink.tsx +1452 -0
  137. package/src/input-parser.ts +303 -0
  138. package/src/instances.ts +9 -0
  139. package/src/jsx-dev-runtime.ts +3 -0
  140. package/src/jsx-runtime.ts +6 -0
  141. package/src/kitty-keyboard.ts +185 -0
  142. package/src/measure-element.ts +62 -0
  143. package/src/measure-text.ts +31 -0
  144. package/src/paint-tree.ts +220 -0
  145. package/src/parse-keypress.ts +515 -0
  146. package/src/parse-stack-line.ts +138 -0
  147. package/src/patch-console.ts +106 -0
  148. package/src/quick-lru.ts +85 -0
  149. package/src/react.ts +53 -0
  150. package/src/reconciler.ts +476 -0
  151. package/src/render-background.ts +59 -0
  152. package/src/render-border.ts +167 -0
  153. package/src/render-frame.ts +83 -0
  154. package/src/render-to-string.ts +146 -0
  155. package/src/render.ts +284 -0
  156. package/src/router/components.tsx +343 -0
  157. package/src/router/context.ts +41 -0
  158. package/src/router/history.ts +194 -0
  159. package/src/router/hooks.tsx +391 -0
  160. package/src/router/index.ts +34 -0
  161. package/src/router/matcher.ts +571 -0
  162. package/src/sanitize-ansi.ts +33 -0
  163. package/src/screen/ansi.ts +184 -0
  164. package/src/screen/canvas.ts +160 -0
  165. package/src/screen/cell.ts +138 -0
  166. package/src/screen/color-profile.ts +47 -0
  167. package/src/screen/geometry.ts +9 -0
  168. package/src/screen/index.ts +6 -0
  169. package/src/screen/screen.ts +305 -0
  170. package/src/screen/serialize.ts +129 -0
  171. package/src/screen.ts +1 -0
  172. package/src/semantic-text-style.ts +118 -0
  173. package/src/signal-exit.ts +106 -0
  174. package/src/squash-text-nodes.ts +37 -0
  175. package/src/stream.ts +28 -0
  176. package/src/structured-text.ts +325 -0
  177. package/src/styles.ts +753 -0
  178. package/src/terminal/index.ts +2 -0
  179. package/src/terminal/inline-presenter.ts +120 -0
  180. package/src/terminal/input.ts +92 -0
  181. package/src/terminal/render-scheduler.ts +37 -0
  182. package/src/terminal/screen-presenter.ts +242 -0
  183. package/src/terminal/session.ts +408 -0
  184. package/src/terminal-size.ts +58 -0
  185. package/src/terminal.ts +1 -0
  186. package/src/testing/browser.ts +588 -0
  187. package/src/testing/emulators.ts +205 -0
  188. package/src/testing/explorer-app/index.html +12 -0
  189. package/src/testing/explorer-app/main.ts +381 -0
  190. package/src/testing/explorer-app/style.css +194 -0
  191. package/src/testing/explorer-app/tsconfig.json +15 -0
  192. package/src/testing/explorer-app/vite-env.d.ts +1 -0
  193. package/src/testing/index.ts +26 -0
  194. package/src/testing/keys.ts +56 -0
  195. package/src/testing/live.ts +85 -0
  196. package/src/testing/matchers.ts +70 -0
  197. package/src/testing/public.ts +94 -0
  198. package/src/testing/terminal.ts +361 -0
  199. package/src/testing/vitest.ts +157 -0
  200. package/src/throttle.ts +73 -0
  201. package/src/transform-adapter.ts +14 -0
  202. package/src/types.ts +10 -0
  203. package/src/virtual-scroll.ts +133 -0
  204. package/src/wrap-text.ts +54 -0
  205. package/src/yoga/config.ts +57 -0
  206. package/src/yoga/core/absoluteLayout.ts +626 -0
  207. package/src/yoga/core/baseline.ts +66 -0
  208. package/src/yoga/core/cache.ts +136 -0
  209. package/src/yoga/core/calculateLayout.ts +2926 -0
  210. package/src/yoga/core/config.ts +104 -0
  211. package/src/yoga/core/flexLine.ts +177 -0
  212. package/src/yoga/core/helpers.ts +293 -0
  213. package/src/yoga/core/layoutResults.ts +167 -0
  214. package/src/yoga/core/node.ts +611 -0
  215. package/src/yoga/core/numeric.ts +44 -0
  216. package/src/yoga/core/pixelGrid.ts +151 -0
  217. package/src/yoga/core/style.ts +887 -0
  218. package/src/yoga/core/types.ts +224 -0
  219. package/src/yoga/generated/YGEnums.ts +263 -0
  220. package/src/yoga/index.ts +19 -0
  221. package/src/yoga/node.ts +1140 -0
  222. package/dist/index.d.mts +0 -2379
  223. package/dist/index.mjs +0 -10072
@@ -0,0 +1,1242 @@
1
+ import { a as foreground, i as codes, n as background, p as styles } from "./sgr-BhwaWAJB.js";
2
+ //#region src/ansi/east-asian-width.ts
3
+ const isInRange = (ranges, codePoint) => {
4
+ let low = 0;
5
+ let high = Math.floor(ranges.length / 2) - 1;
6
+ while (low <= high) {
7
+ const mid = Math.floor((low + high) / 2);
8
+ const i = mid * 2;
9
+ if (codePoint < ranges[i]) high = mid - 1;
10
+ else if (codePoint > ranges[i + 1]) low = mid + 1;
11
+ else return true;
12
+ }
13
+ return false;
14
+ };
15
+ const ambiguousMinimalCodePoint = 161;
16
+ const ambiguousMaximumCodePoint = 1114109;
17
+ const ambiguousRanges = [
18
+ 161,
19
+ 161,
20
+ 164,
21
+ 164,
22
+ 167,
23
+ 168,
24
+ 170,
25
+ 170,
26
+ 173,
27
+ 174,
28
+ 176,
29
+ 180,
30
+ 182,
31
+ 186,
32
+ 188,
33
+ 191,
34
+ 198,
35
+ 198,
36
+ 208,
37
+ 208,
38
+ 215,
39
+ 216,
40
+ 222,
41
+ 225,
42
+ 230,
43
+ 230,
44
+ 232,
45
+ 234,
46
+ 236,
47
+ 237,
48
+ 240,
49
+ 240,
50
+ 242,
51
+ 243,
52
+ 247,
53
+ 250,
54
+ 252,
55
+ 252,
56
+ 254,
57
+ 254,
58
+ 257,
59
+ 257,
60
+ 273,
61
+ 273,
62
+ 275,
63
+ 275,
64
+ 283,
65
+ 283,
66
+ 294,
67
+ 295,
68
+ 299,
69
+ 299,
70
+ 305,
71
+ 307,
72
+ 312,
73
+ 312,
74
+ 319,
75
+ 322,
76
+ 324,
77
+ 324,
78
+ 328,
79
+ 331,
80
+ 333,
81
+ 333,
82
+ 338,
83
+ 339,
84
+ 358,
85
+ 359,
86
+ 363,
87
+ 363,
88
+ 462,
89
+ 462,
90
+ 464,
91
+ 464,
92
+ 466,
93
+ 466,
94
+ 468,
95
+ 468,
96
+ 470,
97
+ 470,
98
+ 472,
99
+ 472,
100
+ 474,
101
+ 474,
102
+ 476,
103
+ 476,
104
+ 593,
105
+ 593,
106
+ 609,
107
+ 609,
108
+ 708,
109
+ 708,
110
+ 711,
111
+ 711,
112
+ 713,
113
+ 715,
114
+ 717,
115
+ 717,
116
+ 720,
117
+ 720,
118
+ 728,
119
+ 731,
120
+ 733,
121
+ 733,
122
+ 735,
123
+ 735,
124
+ 768,
125
+ 879,
126
+ 913,
127
+ 929,
128
+ 931,
129
+ 937,
130
+ 945,
131
+ 961,
132
+ 963,
133
+ 969,
134
+ 1025,
135
+ 1025,
136
+ 1040,
137
+ 1103,
138
+ 1105,
139
+ 1105,
140
+ 8208,
141
+ 8208,
142
+ 8211,
143
+ 8214,
144
+ 8216,
145
+ 8217,
146
+ 8220,
147
+ 8221,
148
+ 8224,
149
+ 8226,
150
+ 8228,
151
+ 8231,
152
+ 8240,
153
+ 8240,
154
+ 8242,
155
+ 8243,
156
+ 8245,
157
+ 8245,
158
+ 8251,
159
+ 8251,
160
+ 8254,
161
+ 8254,
162
+ 8308,
163
+ 8308,
164
+ 8319,
165
+ 8319,
166
+ 8321,
167
+ 8324,
168
+ 8364,
169
+ 8364,
170
+ 8451,
171
+ 8451,
172
+ 8453,
173
+ 8453,
174
+ 8457,
175
+ 8457,
176
+ 8467,
177
+ 8467,
178
+ 8470,
179
+ 8470,
180
+ 8481,
181
+ 8482,
182
+ 8486,
183
+ 8486,
184
+ 8491,
185
+ 8491,
186
+ 8531,
187
+ 8532,
188
+ 8539,
189
+ 8542,
190
+ 8544,
191
+ 8555,
192
+ 8560,
193
+ 8569,
194
+ 8585,
195
+ 8585,
196
+ 8592,
197
+ 8601,
198
+ 8632,
199
+ 8633,
200
+ 8658,
201
+ 8658,
202
+ 8660,
203
+ 8660,
204
+ 8679,
205
+ 8679,
206
+ 8704,
207
+ 8704,
208
+ 8706,
209
+ 8707,
210
+ 8711,
211
+ 8712,
212
+ 8715,
213
+ 8715,
214
+ 8719,
215
+ 8719,
216
+ 8721,
217
+ 8721,
218
+ 8725,
219
+ 8725,
220
+ 8730,
221
+ 8730,
222
+ 8733,
223
+ 8736,
224
+ 8739,
225
+ 8739,
226
+ 8741,
227
+ 8741,
228
+ 8743,
229
+ 8748,
230
+ 8750,
231
+ 8750,
232
+ 8756,
233
+ 8759,
234
+ 8764,
235
+ 8765,
236
+ 8776,
237
+ 8776,
238
+ 8780,
239
+ 8780,
240
+ 8786,
241
+ 8786,
242
+ 8800,
243
+ 8801,
244
+ 8804,
245
+ 8807,
246
+ 8810,
247
+ 8811,
248
+ 8814,
249
+ 8815,
250
+ 8834,
251
+ 8835,
252
+ 8838,
253
+ 8839,
254
+ 8853,
255
+ 8853,
256
+ 8857,
257
+ 8857,
258
+ 8869,
259
+ 8869,
260
+ 8895,
261
+ 8895,
262
+ 8978,
263
+ 8978,
264
+ 9312,
265
+ 9449,
266
+ 9451,
267
+ 9547,
268
+ 9552,
269
+ 9587,
270
+ 9600,
271
+ 9615,
272
+ 9618,
273
+ 9621,
274
+ 9632,
275
+ 9633,
276
+ 9635,
277
+ 9641,
278
+ 9650,
279
+ 9651,
280
+ 9654,
281
+ 9655,
282
+ 9660,
283
+ 9661,
284
+ 9664,
285
+ 9665,
286
+ 9670,
287
+ 9672,
288
+ 9675,
289
+ 9675,
290
+ 9678,
291
+ 9681,
292
+ 9698,
293
+ 9701,
294
+ 9711,
295
+ 9711,
296
+ 9733,
297
+ 9734,
298
+ 9737,
299
+ 9737,
300
+ 9742,
301
+ 9743,
302
+ 9756,
303
+ 9756,
304
+ 9758,
305
+ 9758,
306
+ 9792,
307
+ 9792,
308
+ 9794,
309
+ 9794,
310
+ 9824,
311
+ 9825,
312
+ 9827,
313
+ 9829,
314
+ 9831,
315
+ 9834,
316
+ 9836,
317
+ 9837,
318
+ 9839,
319
+ 9839,
320
+ 9886,
321
+ 9887,
322
+ 9919,
323
+ 9919,
324
+ 9926,
325
+ 9933,
326
+ 9935,
327
+ 9939,
328
+ 9941,
329
+ 9953,
330
+ 9955,
331
+ 9955,
332
+ 9960,
333
+ 9961,
334
+ 9963,
335
+ 9969,
336
+ 9972,
337
+ 9972,
338
+ 9974,
339
+ 9977,
340
+ 9979,
341
+ 9980,
342
+ 9982,
343
+ 9983,
344
+ 10045,
345
+ 10045,
346
+ 10102,
347
+ 10111,
348
+ 11094,
349
+ 11097,
350
+ 12872,
351
+ 12879,
352
+ 57344,
353
+ 63743,
354
+ 65024,
355
+ 65039,
356
+ 65533,
357
+ 65533,
358
+ 127232,
359
+ 127242,
360
+ 127248,
361
+ 127277,
362
+ 127280,
363
+ 127337,
364
+ 127344,
365
+ 127373,
366
+ 127375,
367
+ 127376,
368
+ 127387,
369
+ 127404,
370
+ 917760,
371
+ 917999,
372
+ 983040,
373
+ 1048573,
374
+ 1048576,
375
+ 1114109
376
+ ];
377
+ const fullwidthMinimalCodePoint = 12288;
378
+ const fullwidthMaximumCodePoint = 65510;
379
+ const fullwidthRanges = [
380
+ 12288,
381
+ 12288,
382
+ 65281,
383
+ 65376,
384
+ 65504,
385
+ 65510
386
+ ];
387
+ const halfwidthMinimalCodePoint = 8361;
388
+ const halfwidthMaximumCodePoint = 65518;
389
+ const halfwidthRanges = [
390
+ 8361,
391
+ 8361,
392
+ 65377,
393
+ 65470,
394
+ 65474,
395
+ 65479,
396
+ 65482,
397
+ 65487,
398
+ 65490,
399
+ 65495,
400
+ 65498,
401
+ 65500,
402
+ 65512,
403
+ 65518
404
+ ];
405
+ const narrowMinimalCodePoint = 32;
406
+ const narrowMaximumCodePoint = 10630;
407
+ const narrowRanges = [
408
+ 32,
409
+ 126,
410
+ 162,
411
+ 163,
412
+ 165,
413
+ 166,
414
+ 172,
415
+ 172,
416
+ 175,
417
+ 175,
418
+ 10214,
419
+ 10221,
420
+ 10629,
421
+ 10630
422
+ ];
423
+ const wideMinimalCodePoint = 4352;
424
+ const wideMaximumCodePoint = 262141;
425
+ const wideRanges = [
426
+ 4352,
427
+ 4447,
428
+ 8986,
429
+ 8987,
430
+ 9001,
431
+ 9002,
432
+ 9193,
433
+ 9196,
434
+ 9200,
435
+ 9200,
436
+ 9203,
437
+ 9203,
438
+ 9725,
439
+ 9726,
440
+ 9748,
441
+ 9749,
442
+ 9776,
443
+ 9783,
444
+ 9800,
445
+ 9811,
446
+ 9855,
447
+ 9855,
448
+ 9866,
449
+ 9871,
450
+ 9875,
451
+ 9875,
452
+ 9889,
453
+ 9889,
454
+ 9898,
455
+ 9899,
456
+ 9917,
457
+ 9918,
458
+ 9924,
459
+ 9925,
460
+ 9934,
461
+ 9934,
462
+ 9940,
463
+ 9940,
464
+ 9962,
465
+ 9962,
466
+ 9970,
467
+ 9971,
468
+ 9973,
469
+ 9973,
470
+ 9978,
471
+ 9978,
472
+ 9981,
473
+ 9981,
474
+ 9989,
475
+ 9989,
476
+ 9994,
477
+ 9995,
478
+ 10024,
479
+ 10024,
480
+ 10060,
481
+ 10060,
482
+ 10062,
483
+ 10062,
484
+ 10067,
485
+ 10069,
486
+ 10071,
487
+ 10071,
488
+ 10133,
489
+ 10135,
490
+ 10160,
491
+ 10160,
492
+ 10175,
493
+ 10175,
494
+ 11035,
495
+ 11036,
496
+ 11088,
497
+ 11088,
498
+ 11093,
499
+ 11093,
500
+ 11904,
501
+ 11929,
502
+ 11931,
503
+ 12019,
504
+ 12032,
505
+ 12245,
506
+ 12272,
507
+ 12287,
508
+ 12289,
509
+ 12350,
510
+ 12353,
511
+ 12438,
512
+ 12441,
513
+ 12543,
514
+ 12549,
515
+ 12591,
516
+ 12593,
517
+ 12686,
518
+ 12688,
519
+ 12773,
520
+ 12783,
521
+ 12830,
522
+ 12832,
523
+ 12871,
524
+ 12880,
525
+ 42124,
526
+ 42128,
527
+ 42182,
528
+ 43360,
529
+ 43388,
530
+ 44032,
531
+ 55203,
532
+ 63744,
533
+ 64255,
534
+ 65040,
535
+ 65049,
536
+ 65072,
537
+ 65106,
538
+ 65108,
539
+ 65126,
540
+ 65128,
541
+ 65131,
542
+ 94176,
543
+ 94180,
544
+ 94192,
545
+ 94198,
546
+ 94208,
547
+ 101589,
548
+ 101631,
549
+ 101662,
550
+ 101760,
551
+ 101874,
552
+ 110576,
553
+ 110579,
554
+ 110581,
555
+ 110587,
556
+ 110589,
557
+ 110590,
558
+ 110592,
559
+ 110882,
560
+ 110898,
561
+ 110898,
562
+ 110928,
563
+ 110930,
564
+ 110933,
565
+ 110933,
566
+ 110948,
567
+ 110951,
568
+ 110960,
569
+ 111355,
570
+ 119552,
571
+ 119638,
572
+ 119648,
573
+ 119670,
574
+ 126980,
575
+ 126980,
576
+ 127183,
577
+ 127183,
578
+ 127374,
579
+ 127374,
580
+ 127377,
581
+ 127386,
582
+ 127488,
583
+ 127490,
584
+ 127504,
585
+ 127547,
586
+ 127552,
587
+ 127560,
588
+ 127568,
589
+ 127569,
590
+ 127584,
591
+ 127589,
592
+ 127744,
593
+ 127776,
594
+ 127789,
595
+ 127797,
596
+ 127799,
597
+ 127868,
598
+ 127870,
599
+ 127891,
600
+ 127904,
601
+ 127946,
602
+ 127951,
603
+ 127955,
604
+ 127968,
605
+ 127984,
606
+ 127988,
607
+ 127988,
608
+ 127992,
609
+ 128062,
610
+ 128064,
611
+ 128064,
612
+ 128066,
613
+ 128252,
614
+ 128255,
615
+ 128317,
616
+ 128331,
617
+ 128334,
618
+ 128336,
619
+ 128359,
620
+ 128378,
621
+ 128378,
622
+ 128405,
623
+ 128406,
624
+ 128420,
625
+ 128420,
626
+ 128507,
627
+ 128591,
628
+ 128640,
629
+ 128709,
630
+ 128716,
631
+ 128716,
632
+ 128720,
633
+ 128722,
634
+ 128725,
635
+ 128728,
636
+ 128732,
637
+ 128735,
638
+ 128747,
639
+ 128748,
640
+ 128756,
641
+ 128764,
642
+ 128992,
643
+ 129003,
644
+ 129008,
645
+ 129008,
646
+ 129292,
647
+ 129338,
648
+ 129340,
649
+ 129349,
650
+ 129351,
651
+ 129535,
652
+ 129648,
653
+ 129660,
654
+ 129664,
655
+ 129674,
656
+ 129678,
657
+ 129734,
658
+ 129736,
659
+ 129736,
660
+ 129741,
661
+ 129756,
662
+ 129759,
663
+ 129770,
664
+ 129775,
665
+ 129784,
666
+ 131072,
667
+ 196605,
668
+ 196608,
669
+ 262141
670
+ ];
671
+ const commonCjkCodePoint = 19968;
672
+ const [wideFastPathStart, wideFastPathEnd] = /* #__PURE__ */ findWideFastPathRange(wideRanges);
673
+ function findWideFastPathRange(ranges) {
674
+ let fastPathStart = ranges[0];
675
+ let fastPathEnd = ranges[1];
676
+ for (let index = 0; index < ranges.length; index += 2) {
677
+ const start = ranges[index];
678
+ const end = ranges[index + 1];
679
+ if (commonCjkCodePoint >= start && commonCjkCodePoint <= end) return [start, end];
680
+ if (end - start > fastPathEnd - fastPathStart) {
681
+ fastPathStart = start;
682
+ fastPathEnd = end;
683
+ }
684
+ }
685
+ return [fastPathStart, fastPathEnd];
686
+ }
687
+ const isAmbiguous = (codePoint) => {
688
+ if (codePoint < 161 || codePoint > 1114109) return false;
689
+ return isInRange(ambiguousRanges, codePoint);
690
+ };
691
+ const isFullWidth = (codePoint) => {
692
+ if (codePoint < 12288 || codePoint > 65510) return false;
693
+ return isInRange(fullwidthRanges, codePoint);
694
+ };
695
+ const isHalfWidth = (codePoint) => {
696
+ if (codePoint < 8361 || codePoint > 65518) return false;
697
+ return isInRange(halfwidthRanges, codePoint);
698
+ };
699
+ const isNarrow = (codePoint) => {
700
+ if (codePoint < 32 || codePoint > 10630) return false;
701
+ return isInRange(narrowRanges, codePoint);
702
+ };
703
+ const isWide = (codePoint) => {
704
+ if (codePoint >= wideFastPathStart && codePoint <= wideFastPathEnd) return true;
705
+ if (codePoint < 4352 || codePoint > 262141) return false;
706
+ return isInRange(wideRanges, codePoint);
707
+ };
708
+ function getCategory(codePoint) {
709
+ if (isAmbiguous(codePoint)) return "ambiguous";
710
+ if (isFullWidth(codePoint)) return "fullwidth";
711
+ if (isHalfWidth(codePoint)) return "halfwidth";
712
+ if (isNarrow(codePoint)) return "narrow";
713
+ if (isWide(codePoint)) return "wide";
714
+ return "neutral";
715
+ }
716
+ function eastAsianWidthType(codePoint) {
717
+ return getCategory(codePoint);
718
+ }
719
+ function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
720
+ if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) return 2;
721
+ return 1;
722
+ }
723
+ /**
724
+ Grapheme-cluster width test shared by the tokenizer (slice/clip path): the
725
+ base code point's East Asian Width, plus emoji presentation rules.
726
+ */
727
+ function isFullwidthGrapheme(grapheme, baseCodePoint) {
728
+ if (isFullwidthCodePoint(baseCodePoint)) return true;
729
+ if (grapheme.includes("️")) return true;
730
+ if (baseCodePoint >= 127462 && baseCodePoint <= 127487) return true;
731
+ return false;
732
+ }
733
+ /**
734
+ Wide code points not covered by string-width's CJKT script regex or emoji
735
+ regex — the fallback bucket of its block parser. A disjoint decomposition of
736
+ the `wide` table above, kept alongside it so the width data lives in one
737
+ module.
738
+ */
739
+ const isWideNotCJKTNotEmoji = (x) => {
740
+ return x === 8987 || x === 9001 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
741
+ };
742
+ function isFullwidthCodePoint(codePoint) {
743
+ if (!Number.isInteger(codePoint)) return false;
744
+ return isFullWidth(codePoint) || isWide(codePoint);
745
+ }
746
+ //#endregion
747
+ //#region src/ansi-tokenizer.ts
748
+ const bellCharacter = "\x07";
749
+ const escapeCharacter = "\x1B";
750
+ const stringTerminatorCharacter = "œ";
751
+ const csiCharacter = "›";
752
+ const oscCharacter = "";
753
+ const dcsCharacter = "";
754
+ const pmCharacter = "ž";
755
+ const apcCharacter = "Ÿ";
756
+ const sosCharacter = "˜";
757
+ const isCsiParameterCharacter = (character) => {
758
+ const codePoint = character.codePointAt(0);
759
+ return codePoint !== void 0 && codePoint >= 48 && codePoint <= 63;
760
+ };
761
+ const isCsiIntermediateCharacter = (character) => {
762
+ const codePoint = character.codePointAt(0);
763
+ return codePoint !== void 0 && codePoint >= 32 && codePoint <= 47;
764
+ };
765
+ const isCsiFinalCharacter = (character) => {
766
+ const codePoint = character.codePointAt(0);
767
+ return codePoint !== void 0 && codePoint >= 64 && codePoint <= 126;
768
+ };
769
+ const isEscapeIntermediateCharacter = (character) => {
770
+ const codePoint = character.codePointAt(0);
771
+ return codePoint !== void 0 && codePoint >= 32 && codePoint <= 47;
772
+ };
773
+ const isEscapeFinalCharacter = (character) => {
774
+ const codePoint = character.codePointAt(0);
775
+ return codePoint !== void 0 && codePoint >= 48 && codePoint <= 126;
776
+ };
777
+ const isC1ControlCharacter = (character) => {
778
+ const codePoint = character.codePointAt(0);
779
+ return codePoint !== void 0 && codePoint >= 128 && codePoint <= 159;
780
+ };
781
+ const readCsiSequence = (text, fromIndex) => {
782
+ let index = fromIndex;
783
+ while (index < text.length) {
784
+ const character = text[index];
785
+ if (!isCsiParameterCharacter(character)) break;
786
+ index++;
787
+ }
788
+ const parameterString = text.slice(fromIndex, index);
789
+ const intermediateStartIndex = index;
790
+ while (index < text.length) {
791
+ const character = text[index];
792
+ if (!isCsiIntermediateCharacter(character)) break;
793
+ index++;
794
+ }
795
+ const intermediateString = text.slice(intermediateStartIndex, index);
796
+ const finalCharacter = text[index];
797
+ if (finalCharacter === void 0 || !isCsiFinalCharacter(finalCharacter)) return;
798
+ return {
799
+ endIndex: index + 1,
800
+ parameterString,
801
+ intermediateString,
802
+ finalCharacter
803
+ };
804
+ };
805
+ const findControlStringTerminatorIndex = (text, fromIndex, allowBellTerminator) => {
806
+ for (let index = fromIndex; index < text.length; index++) {
807
+ const character = text[index];
808
+ if (allowBellTerminator && character === bellCharacter) return index + 1;
809
+ if (character === stringTerminatorCharacter) return index + 1;
810
+ if (character === escapeCharacter) {
811
+ const followingCharacter = text[index + 1];
812
+ if (followingCharacter === escapeCharacter) {
813
+ index++;
814
+ continue;
815
+ }
816
+ if (followingCharacter === "\\") return index + 2;
817
+ }
818
+ }
819
+ };
820
+ const readEscapeSequence = (text, fromIndex) => {
821
+ let index = fromIndex;
822
+ while (index < text.length) {
823
+ const character = text[index];
824
+ if (!isEscapeIntermediateCharacter(character)) break;
825
+ index++;
826
+ }
827
+ const intermediateString = text.slice(fromIndex, index);
828
+ const finalCharacter = text[index];
829
+ if (finalCharacter === void 0 || !isEscapeFinalCharacter(finalCharacter)) return;
830
+ return {
831
+ endIndex: index + 1,
832
+ intermediateString,
833
+ finalCharacter
834
+ };
835
+ };
836
+ const getControlStringFromEscapeIntroducer = (character) => {
837
+ switch (character) {
838
+ case "]": return {
839
+ type: "osc",
840
+ allowBellTerminator: true
841
+ };
842
+ case "P": return {
843
+ type: "dcs",
844
+ allowBellTerminator: false
845
+ };
846
+ case "^": return {
847
+ type: "pm",
848
+ allowBellTerminator: false
849
+ };
850
+ case "_": return {
851
+ type: "apc",
852
+ allowBellTerminator: false
853
+ };
854
+ case "X": return {
855
+ type: "sos",
856
+ allowBellTerminator: false
857
+ };
858
+ default: return;
859
+ }
860
+ };
861
+ const getControlStringFromC1Introducer = (character) => {
862
+ switch (character) {
863
+ case oscCharacter: return {
864
+ type: "osc",
865
+ allowBellTerminator: true
866
+ };
867
+ case dcsCharacter: return {
868
+ type: "dcs",
869
+ allowBellTerminator: false
870
+ };
871
+ case pmCharacter: return {
872
+ type: "pm",
873
+ allowBellTerminator: false
874
+ };
875
+ case apcCharacter: return {
876
+ type: "apc",
877
+ allowBellTerminator: false
878
+ };
879
+ case sosCharacter: return {
880
+ type: "sos",
881
+ allowBellTerminator: false
882
+ };
883
+ default: return;
884
+ }
885
+ };
886
+ const hasAnsiControlCharacters = (text) => {
887
+ if (text.includes(escapeCharacter)) return true;
888
+ for (const character of text) if (isC1ControlCharacter(character)) return true;
889
+ return false;
890
+ };
891
+ const malformedFromIndex = (tokens, text, textStartIndex, fromIndex) => {
892
+ if (fromIndex > textStartIndex) tokens.push({
893
+ type: "text",
894
+ value: text.slice(textStartIndex, fromIndex)
895
+ });
896
+ tokens.push({
897
+ type: "invalid",
898
+ value: text.slice(fromIndex)
899
+ });
900
+ return tokens;
901
+ };
902
+ const tokenizeAnsi = (text) => {
903
+ if (!hasAnsiControlCharacters(text)) return [{
904
+ type: "text",
905
+ value: text
906
+ }];
907
+ const tokens = [];
908
+ let textStartIndex = 0;
909
+ for (let index = 0; index < text.length;) {
910
+ const character = text[index];
911
+ if (character === void 0) break;
912
+ if (character === escapeCharacter) {
913
+ const followingCharacter = text[index + 1];
914
+ if (followingCharacter === void 0) return malformedFromIndex(tokens, text, textStartIndex, index);
915
+ if (followingCharacter === "[") {
916
+ const csiSequence = readCsiSequence(text, index + 2);
917
+ if (csiSequence === void 0) return malformedFromIndex(tokens, text, textStartIndex, index);
918
+ if (index > textStartIndex) tokens.push({
919
+ type: "text",
920
+ value: text.slice(textStartIndex, index)
921
+ });
922
+ tokens.push({
923
+ type: "csi",
924
+ value: text.slice(index, csiSequence.endIndex),
925
+ parameterString: csiSequence.parameterString,
926
+ intermediateString: csiSequence.intermediateString,
927
+ finalCharacter: csiSequence.finalCharacter
928
+ });
929
+ index = csiSequence.endIndex;
930
+ textStartIndex = index;
931
+ continue;
932
+ }
933
+ const escapeControlString = getControlStringFromEscapeIntroducer(followingCharacter);
934
+ if (escapeControlString !== void 0) {
935
+ const controlStringTerminatorIndex = findControlStringTerminatorIndex(text, index + 2, escapeControlString.allowBellTerminator);
936
+ if (controlStringTerminatorIndex === void 0) return malformedFromIndex(tokens, text, textStartIndex, index);
937
+ if (index > textStartIndex) tokens.push({
938
+ type: "text",
939
+ value: text.slice(textStartIndex, index)
940
+ });
941
+ tokens.push({
942
+ type: escapeControlString.type,
943
+ value: text.slice(index, controlStringTerminatorIndex)
944
+ });
945
+ index = controlStringTerminatorIndex;
946
+ textStartIndex = index;
947
+ continue;
948
+ }
949
+ const escapeSequence = readEscapeSequence(text, index + 1);
950
+ if (escapeSequence === void 0) {
951
+ if (isEscapeIntermediateCharacter(followingCharacter)) return malformedFromIndex(tokens, text, textStartIndex, index);
952
+ if (index > textStartIndex) tokens.push({
953
+ type: "text",
954
+ value: text.slice(textStartIndex, index)
955
+ });
956
+ index++;
957
+ textStartIndex = index;
958
+ continue;
959
+ }
960
+ if (index > textStartIndex) tokens.push({
961
+ type: "text",
962
+ value: text.slice(textStartIndex, index)
963
+ });
964
+ tokens.push({
965
+ type: "esc",
966
+ value: text.slice(index, escapeSequence.endIndex),
967
+ intermediateString: escapeSequence.intermediateString,
968
+ finalCharacter: escapeSequence.finalCharacter
969
+ });
970
+ index = escapeSequence.endIndex;
971
+ textStartIndex = index;
972
+ continue;
973
+ }
974
+ if (character === csiCharacter) {
975
+ const csiSequence = readCsiSequence(text, index + 1);
976
+ if (csiSequence === void 0) return malformedFromIndex(tokens, text, textStartIndex, index);
977
+ if (index > textStartIndex) tokens.push({
978
+ type: "text",
979
+ value: text.slice(textStartIndex, index)
980
+ });
981
+ tokens.push({
982
+ type: "csi",
983
+ value: text.slice(index, csiSequence.endIndex),
984
+ parameterString: csiSequence.parameterString,
985
+ intermediateString: csiSequence.intermediateString,
986
+ finalCharacter: csiSequence.finalCharacter
987
+ });
988
+ index = csiSequence.endIndex;
989
+ textStartIndex = index;
990
+ continue;
991
+ }
992
+ const c1ControlString = getControlStringFromC1Introducer(character);
993
+ if (c1ControlString !== void 0) {
994
+ const controlStringTerminatorIndex = findControlStringTerminatorIndex(text, index + 1, c1ControlString.allowBellTerminator);
995
+ if (controlStringTerminatorIndex === void 0) return malformedFromIndex(tokens, text, textStartIndex, index);
996
+ if (index > textStartIndex) tokens.push({
997
+ type: "text",
998
+ value: text.slice(textStartIndex, index)
999
+ });
1000
+ tokens.push({
1001
+ type: c1ControlString.type,
1002
+ value: text.slice(index, controlStringTerminatorIndex)
1003
+ });
1004
+ index = controlStringTerminatorIndex;
1005
+ textStartIndex = index;
1006
+ continue;
1007
+ }
1008
+ if (character === stringTerminatorCharacter) {
1009
+ if (index > textStartIndex) tokens.push({
1010
+ type: "text",
1011
+ value: text.slice(textStartIndex, index)
1012
+ });
1013
+ tokens.push({
1014
+ type: "st",
1015
+ value: character
1016
+ });
1017
+ index++;
1018
+ textStartIndex = index;
1019
+ continue;
1020
+ }
1021
+ if (isC1ControlCharacter(character)) {
1022
+ if (index > textStartIndex) tokens.push({
1023
+ type: "text",
1024
+ value: text.slice(textStartIndex, index)
1025
+ });
1026
+ tokens.push({
1027
+ type: "c1",
1028
+ value: character
1029
+ });
1030
+ index++;
1031
+ textStartIndex = index;
1032
+ continue;
1033
+ }
1034
+ index++;
1035
+ }
1036
+ if (textStartIndex < text.length) tokens.push({
1037
+ type: "text",
1038
+ value: text.slice(textStartIndex)
1039
+ });
1040
+ return tokens;
1041
+ };
1042
+ //#endregion
1043
+ //#region src/ansi/graphemes.ts
1044
+ const segmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
1045
+ /** The canonical grapheme segmentation service for measurement and rasterization. */
1046
+ function* graphemes(text) {
1047
+ for (const { segment } of segmenter.segment(text)) yield segment;
1048
+ }
1049
+ //#endregion
1050
+ //#region src/ansi/tokenize.ts
1051
+ const BACKSLASH = "\\";
1052
+ const CSI = "[";
1053
+ const OSC = "]";
1054
+ const linkCodePrefix = `${OSC}8;`;
1055
+ const linkCodeSuffix = "\x07";
1056
+ const linkEndCode = `${OSC}8;;`;
1057
+ const linkEndCodeST = `${OSC}8;;${BACKSLASH}`;
1058
+ const linkEndCodeC1ST = `${OSC}8;;œ`;
1059
+ const endCodesSet = /* @__PURE__ */ new Set();
1060
+ const endCodesMap = /* @__PURE__ */ new Map();
1061
+ for (const [start, end] of codes) {
1062
+ endCodesSet.add(foreground.ansi(end));
1063
+ endCodesMap.set(foreground.ansi(start), foreground.ansi(end));
1064
+ }
1065
+ function getLinkStartCode(url, params) {
1066
+ const paramsString = params ? Object.entries(params).map(([key, value]) => `${key}=${value}`).join(":") : "";
1067
+ return `${linkCodePrefix}${paramsString};${url}${linkCodeSuffix}`;
1068
+ }
1069
+ function getEndCode(code) {
1070
+ if (endCodesSet.has(code)) return code;
1071
+ if (endCodesMap.has(code)) return endCodesMap.get(code);
1072
+ if (code.startsWith(linkCodePrefix)) {
1073
+ if (code.endsWith(`${BACKSLASH}`)) return linkEndCodeST;
1074
+ if (code.endsWith("œ")) return linkEndCodeC1ST;
1075
+ return linkEndCode;
1076
+ }
1077
+ code = code.slice(2);
1078
+ if (code.startsWith("38")) return foreground.close;
1079
+ if (code.startsWith("48")) return background.close;
1080
+ if (code.startsWith("58")) return ``;
1081
+ const endCode = codes.get(Number.parseInt(code, 10));
1082
+ if (endCode !== void 0) return foreground.ansi(endCode);
1083
+ return styles.reset.open;
1084
+ }
1085
+ function ansiCodesToString(codes) {
1086
+ return [...new Set(codes.map((code) => code.code))].join("");
1087
+ }
1088
+ /**
1089
+ Check if a code is an intensity code (bold or dim) — these share the end code
1090
+ `22m` but can coexist.
1091
+ */
1092
+ function isIntensityCode(code) {
1093
+ return code.code === styles.bold.open || code.code === styles.dim.open;
1094
+ }
1095
+ /**
1096
+ Splits compound SGR sequences like `\u001B[1;3;31m` into individual components.
1097
+ */
1098
+ function splitCompoundSgrSequences(code) {
1099
+ if (!code.includes(";")) return [code];
1100
+ const codeParts = code.slice(2, -1).split(";");
1101
+ const result = [];
1102
+ for (let index = 0; index < codeParts.length; index++) {
1103
+ const rawCode = codeParts[index];
1104
+ if (rawCode === "38" || rawCode === "48" || rawCode === "58") {
1105
+ if (index + 2 < codeParts.length && codeParts[index + 1] === "5") {
1106
+ result.push(codeParts.slice(index, index + 3).join(";"));
1107
+ index += 2;
1108
+ continue;
1109
+ } else if (index + 4 < codeParts.length && codeParts[index + 1] === "2") {
1110
+ result.push(codeParts.slice(index, index + 5).join(";"));
1111
+ index += 4;
1112
+ continue;
1113
+ }
1114
+ }
1115
+ result.push(rawCode);
1116
+ }
1117
+ return result.map((part) => `[${part}m`);
1118
+ }
1119
+ const SGR_PARAMETERS_RE = /^[\d;:]*$/;
1120
+ const c1LinkCodePrefix = "8;";
1121
+ function tokenize(string, endChar = Number.POSITIVE_INFINITY) {
1122
+ const result = [];
1123
+ let visible = 0;
1124
+ outer: for (const ansiToken of tokenizeAnsi(string)) {
1125
+ if (ansiToken.type === "text") {
1126
+ for (const segment of graphemes(ansiToken.value)) {
1127
+ const fullWidth = isFullwidthGrapheme(segment, segment.codePointAt(0));
1128
+ result.push({
1129
+ type: "char",
1130
+ value: segment,
1131
+ fullWidth
1132
+ });
1133
+ visible += fullWidth ? 2 : 1;
1134
+ if (visible >= endChar) break outer;
1135
+ }
1136
+ continue;
1137
+ }
1138
+ if (ansiToken.type === "csi") {
1139
+ if (ansiToken.finalCharacter === "m" && ansiToken.intermediateString === "" && SGR_PARAMETERS_RE.test(ansiToken.parameterString)) {
1140
+ const code = `${CSI}${ansiToken.parameterString}m`;
1141
+ for (const individualCode of splitCompoundSgrSequences(code)) result.push({
1142
+ type: "ansi",
1143
+ code: individualCode,
1144
+ endCode: getEndCode(individualCode)
1145
+ });
1146
+ } else result.push({
1147
+ type: "control",
1148
+ code: ansiToken.value
1149
+ });
1150
+ continue;
1151
+ }
1152
+ if (ansiToken.type === "osc") {
1153
+ const { value } = ansiToken;
1154
+ const prefix = value.startsWith(linkCodePrefix) ? linkCodePrefix : value.startsWith(c1LinkCodePrefix) ? c1LinkCodePrefix : void 0;
1155
+ if (prefix !== void 0 && value.includes(";", prefix.length)) {
1156
+ const code = prefix === linkCodePrefix ? value : `${linkCodePrefix}${value.slice(prefix.length)}`;
1157
+ result.push({
1158
+ type: "ansi",
1159
+ code,
1160
+ endCode: getEndCode(code)
1161
+ });
1162
+ } else result.push({
1163
+ type: "control",
1164
+ code: value
1165
+ });
1166
+ continue;
1167
+ }
1168
+ result.push({
1169
+ type: "control",
1170
+ code: ansiToken.value
1171
+ });
1172
+ }
1173
+ return result;
1174
+ }
1175
+ /**
1176
+ Reduces the given array of ANSI codes to the minimum necessary to render with
1177
+ the same style.
1178
+ */
1179
+ function reduceAnsiCodes(codes) {
1180
+ return reduceAnsiCodesIncremental([], codes);
1181
+ }
1182
+ /**
1183
+ Like {@link reduceAnsiCodes}, but assumes that `codes` is already reduced.
1184
+ Further reductions are only done for the items in `newCodes`.
1185
+ */
1186
+ function reduceAnsiCodesIncremental(codes, newCodes) {
1187
+ let result = [...codes];
1188
+ for (const code of newCodes) if (code.code === styles.reset.open) result = [];
1189
+ else if (endCodesSet.has(code.code)) result = result.filter((existing) => existing.endCode !== code.code);
1190
+ else if (isIntensityCode(code)) {
1191
+ if (!result.some((existing) => existing.code === code.code && existing.endCode === code.endCode)) result.push(code);
1192
+ } else {
1193
+ result = result.filter((existing) => existing.endCode !== code.endCode);
1194
+ result.push(code);
1195
+ }
1196
+ return result;
1197
+ }
1198
+ /**
1199
+ Returns the combination of ANSI codes needed to undo the given ANSI codes.
1200
+ */
1201
+ function undoAnsiCodes(codes) {
1202
+ return reduceAnsiCodes(codes).toReversed().map((code) => ({
1203
+ ...code,
1204
+ code: code.endCode
1205
+ }));
1206
+ }
1207
+ /**
1208
+ Returns the minimum amount of ANSI codes necessary to get from the compound
1209
+ style `from` to `to`. Both are expected to be reduced.
1210
+ */
1211
+ function diffAnsiCodes(from, to) {
1212
+ const endCodesInTo = new Set(to.map((code) => code.endCode));
1213
+ const startCodesInTo = new Set(to.map((code) => code.code));
1214
+ const startCodesInFrom = new Set(from.map((code) => code.code));
1215
+ return [...undoAnsiCodes(from.filter((code) => {
1216
+ if (isIntensityCode(code)) return !startCodesInTo.has(code.code);
1217
+ return !endCodesInTo.has(code.endCode);
1218
+ })), ...to.filter((code) => !startCodesInFrom.has(code.code))];
1219
+ }
1220
+ function styledCharsFromTokens(tokens) {
1221
+ let codes = [];
1222
+ const result = [];
1223
+ for (const token of tokens) if (token.type === "ansi") codes = reduceAnsiCodesIncremental(codes, [token]);
1224
+ else if (token.type === "char") result.push({
1225
+ ...token,
1226
+ styles: [...codes]
1227
+ });
1228
+ return result;
1229
+ }
1230
+ function styledCharsToString(chars) {
1231
+ let result = "";
1232
+ for (let index = 0; index < chars.length; index++) {
1233
+ const char = chars[index];
1234
+ if (index === 0) result += ansiCodesToString(char.styles);
1235
+ else result += ansiCodesToString(diffAnsiCodes(chars[index - 1].styles, char.styles));
1236
+ result += char.value;
1237
+ if (index === chars.length - 1) result += ansiCodesToString(diffAnsiCodes(char.styles, []));
1238
+ }
1239
+ return result;
1240
+ }
1241
+ //#endregion
1242
+ export { isFullwidthCodePoint as A, fullwidthRanges as C, halfwidthRanges as D, halfwidthMinimalCodePoint as E, narrowMinimalCodePoint as F, narrowRanges as I, wideMaximumCodePoint as L, isWide as M, isWideNotCJKTNotEmoji as N, isAmbiguous as O, narrowMaximumCodePoint as P, wideMinimalCodePoint as R, fullwidthMinimalCodePoint as S, halfwidthMaximumCodePoint as T, ambiguousMinimalCodePoint as _, getLinkStartCode as a, eastAsianWidthType as b, reduceAnsiCodesIncremental as c, tokenize as d, undoAnsiCodes as f, ambiguousMaximumCodePoint as g, tokenizeAnsi as h, getEndCode as i, isFullwidthGrapheme as j, isFullWidth as k, styledCharsFromTokens as l, hasAnsiControlCharacters as m, diffAnsiCodes as n, isIntensityCode as o, graphemes as p, endCodesSet as r, reduceAnsiCodes as s, ansiCodesToString as t, styledCharsToString as u, ambiguousRanges as v, getCategory as w, fullwidthMaximumCodePoint as x, eastAsianWidth as y, wideRanges as z };