@simon_he/vue-tui 0.0.8 → 1.0.0-rc.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.
Files changed (210) hide show
  1. package/README.md +130 -27
  2. package/dist/TSelect-BmSkar0D.js +8697 -0
  3. package/dist/ansi-palette-Bv5Vqr4k.js +1499 -0
  4. package/dist/ansi-styles.d.ts +200 -0
  5. package/dist/cli/headless-renderer.d.ts +29 -0
  6. package/dist/cli/input.d.ts +49 -0
  7. package/dist/cli/node-file-writers.d.ts +12 -0
  8. package/dist/cli/node-module.d.ts +2 -0
  9. package/dist/cli/parse-kitty.d.ts +2 -0
  10. package/dist/cli/parse-mouse.d.ts +2 -0
  11. package/dist/cli/parse-utils.d.ts +14 -0
  12. package/dist/cli/parse-xterm.d.ts +2 -0
  13. package/dist/cli/path-provider-types.d.ts +1 -0
  14. package/dist/cli/path-provider.d.ts +4 -0
  15. package/dist/cli/path-suggest-core.d.ts +1 -0
  16. package/dist/cli/path-suggest.d.ts +15 -0
  17. package/dist/cli/recording.d.ts +4 -0
  18. package/dist/cli/stdin-buffer.d.ts +33 -0
  19. package/dist/cli.cjs +10664 -0
  20. package/dist/cli.d.cts +22 -0
  21. package/dist/cli.d.ts +22 -0
  22. package/dist/cli.js +9521 -0
  23. package/dist/core/ansi/capability.d.ts +20 -0
  24. package/dist/core/ansi/colors.d.ts +41 -0
  25. package/dist/core/ansi/sgr.d.ts +7 -0
  26. package/dist/core/ansi/theme.d.ts +6 -0
  27. package/dist/core/ansi-palette.d.ts +14 -0
  28. package/dist/core/buffer/buffer.d.ts +54 -0
  29. package/dist/core/buffer/width.d.ts +4 -0
  30. package/dist/core/debug-logger.d.ts +18 -0
  31. package/dist/core/hyperlink.d.ts +9 -0
  32. package/dist/core/index.d.ts +4 -0
  33. package/dist/core/path-provider-types.d.ts +24 -0
  34. package/dist/core/path-suggest.d.ts +35 -0
  35. package/dist/core/render-plane.d.ts +3 -0
  36. package/dist/core/terminal/create-terminal.d.ts +7 -0
  37. package/dist/core/terminal/emitter.d.ts +7 -0
  38. package/dist/core/types.d.ts +107 -0
  39. package/dist/core.cjs +3072 -0
  40. package/dist/core.d.cts +14 -0
  41. package/dist/core.d.ts +14 -0
  42. package/dist/core.js +422 -0
  43. package/dist/create-terminal-app.d.ts +34 -0
  44. package/dist/dom-renderer-CDVQIcIL.js +1172 -0
  45. package/dist/events/index.d.ts +6 -0
  46. package/dist/events/manager/cli-event-manager.d.ts +22 -0
  47. package/dist/events/manager/event-manager.d.ts +30 -0
  48. package/dist/events/manager/selection-suppression.d.ts +3 -0
  49. package/dist/events/manager/types.d.ts +108 -0
  50. package/dist/events/recording.d.ts +44 -0
  51. package/dist/experimental.cjs +1777 -1244
  52. package/dist/experimental.d.cts +39 -0
  53. package/dist/experimental.d.ts +39 -825
  54. package/dist/experimental.js +492 -343
  55. package/dist/frame-perf-C-w8mjJL.js +98 -0
  56. package/dist/hyperlink-B5PD7a3Q.js +331 -0
  57. package/dist/index.cjs +13133 -19960
  58. package/dist/index.d.cts +13 -0
  59. package/dist/index.d.ts +13 -1528
  60. package/dist/index.js +13 -20026
  61. package/dist/markdown.cjs +8728 -7359
  62. package/dist/markdown.d.cts +10 -0
  63. package/dist/markdown.d.ts +10 -112
  64. package/dist/markdown.js +169 -101
  65. package/dist/observability/cli-latency-node.d.ts +3 -0
  66. package/dist/observability/cli-latency-types.d.ts +41 -0
  67. package/dist/observability/cli-latency.d.ts +3 -0
  68. package/dist/observability/frame-perf-store.d.ts +13 -0
  69. package/dist/observability/frame-perf.d.ts +40 -0
  70. package/dist/observability/trace.d.ts +40 -0
  71. package/dist/observability/tui-profiler.d.ts +33 -0
  72. package/dist/observability.cjs +99 -0
  73. package/dist/observability.d.cts +6 -0
  74. package/dist/observability.d.ts +6 -0
  75. package/dist/observability.js +3 -0
  76. package/dist/path-DDiSCXrQ.js +99 -0
  77. package/dist/path-suggest-0Q2BDsuj.js +274 -0
  78. package/dist/path-suggest-Dk9TRLh5.js +3 -0
  79. package/dist/{path-suggest-DmrmeueH.js → path-suggest-bvR9SY6Q.js} +86 -18
  80. package/dist/renderer/capabilities.d.ts +13 -0
  81. package/dist/renderer/cli/index.d.ts +2 -0
  82. package/dist/renderer/cli/stdout-metrics.d.ts +18 -0
  83. package/dist/renderer/cli/stdout-renderer.d.ts +48 -0
  84. package/dist/renderer/dom/dom-renderer.d.ts +157 -0
  85. package/dist/renderer/dom/index.d.ts +2 -0
  86. package/dist/renderer/index.d.ts +2 -0
  87. package/dist/renderer-dom.cjs +1511 -0
  88. package/dist/renderer-dom.d.cts +4 -0
  89. package/dist/renderer-dom.d.ts +4 -0
  90. package/dist/renderer-dom.js +6 -0
  91. package/dist/runtime/index.d.ts +36 -0
  92. package/dist/runtime/osc52.d.ts +9 -0
  93. package/dist/runtime-DtrcQidD.js +1197 -0
  94. package/dist/runtime.cjs +1697 -0
  95. package/dist/runtime.d.cts +9 -0
  96. package/dist/runtime.d.ts +9 -0
  97. package/dist/runtime.js +4 -0
  98. package/dist/selection/terminal-selection.d.ts +122 -0
  99. package/dist/sgr-DMK2AvuT.js +304 -0
  100. package/dist/style-cache-i0ZABZRq.js +178 -0
  101. package/dist/terminal-selection-BCOh9jsL.js +329 -0
  102. package/dist/utils/env.d.ts +3 -0
  103. package/dist/utils/newlines.d.ts +1 -0
  104. package/dist/utils/path.d.ts +7 -0
  105. package/dist/utils/url-safety.d.ts +2 -0
  106. package/dist/vue/components/TAnchor.d.ts +108 -0
  107. package/dist/vue/components/TBox.d.ts +144 -0
  108. package/dist/vue/components/TDebugOverlay.d.ts +43 -0
  109. package/dist/vue/components/TDialog.d.ts +256 -0
  110. package/dist/vue/components/TFlow.d.ts +85 -0
  111. package/dist/vue/components/TInput.d.ts +554 -0
  112. package/dist/vue/components/TInputBox.d.ts +158 -0
  113. package/dist/vue/components/TJsonEditor.d.ts +165 -0
  114. package/dist/vue/components/TList.d.ts +119 -0
  115. package/dist/vue/components/TLogLinksPanel.d.ts +238 -0
  116. package/dist/vue/components/TLogMinimap.d.ts +263 -0
  117. package/dist/vue/components/TLogScrollbar.d.ts +236 -0
  118. package/dist/vue/components/TLogSearchBar.d.ts +267 -0
  119. package/dist/vue/components/TLogSearchPager.d.ts +162 -0
  120. package/dist/vue/components/TLogSearchResults.d.ts +200 -0
  121. package/dist/vue/components/TLogView.d.ts +502 -0
  122. package/dist/vue/components/TLogVirtualLinksPanel.d.ts +141 -0
  123. package/dist/vue/components/TLogVirtualSearchResults.d.ts +146 -0
  124. package/dist/vue/components/TMarkdownText.d.ts +134 -0
  125. package/dist/vue/components/TMultilineModal.d.ts +62 -0
  126. package/dist/vue/components/TPathPicker.d.ts +213 -0
  127. package/dist/vue/components/TRenderLayer.d.ts +16 -0
  128. package/dist/vue/components/TRenderPlane.d.ts +17 -0
  129. package/dist/vue/components/TSelect.d.ts +215 -0
  130. package/dist/vue/components/TText.d.ts +116 -0
  131. package/dist/vue/components/TTransition.d.ts +83 -0
  132. package/dist/vue/components/TView.d.ts +127 -0
  133. package/dist/vue/components/TVirtualList.d.ts +182 -0
  134. package/dist/vue/components/TVirtualMarkdown.d.ts +168 -0
  135. package/dist/vue/components/TerminalProvider.d.ts +195 -0
  136. package/dist/vue/components/input/host.d.ts +17 -0
  137. package/dist/vue/components/input/plugins/hostPlugin.d.ts +7 -0
  138. package/dist/vue/components/input/plugins/hostPlugin.node.d.ts +15 -0
  139. package/dist/vue/components/input/plugins/mentionUtils.d.ts +17 -0
  140. package/dist/vue/components/input/plugins/nodeMentionPathProvider.d.ts +2 -0
  141. package/dist/vue/components/input/plugins/promptMentionPlugin.d.ts +8 -0
  142. package/dist/vue/components/input/plugins/promptMentionState.d.ts +98 -0
  143. package/dist/vue/components/input/plugins/restrictText.d.ts +27 -0
  144. package/dist/vue/components/input/plugins/types.d.ts +90 -0
  145. package/dist/vue/components/input/utils/inlineText.d.ts +57 -0
  146. package/dist/vue/components/input/utils/inlineTextTokens.d.ts +34 -0
  147. package/dist/vue/components/input/utils/primitives.d.ts +3 -0
  148. package/dist/vue/components/input/utils/wordNavigation.d.ts +6 -0
  149. package/dist/vue/components/list/list-geometry.d.ts +16 -0
  150. package/dist/vue/components/list/list-paint.d.ts +1 -0
  151. package/dist/vue/components/list/scroll-state.d.ts +25 -0
  152. package/dist/vue/components/list/selection-state.d.ts +6 -0
  153. package/dist/vue/components/terminal-provider/copy-toast.d.ts +6 -0
  154. package/dist/vue/components/terminal-provider/portals.d.ts +17 -0
  155. package/dist/vue/components/terminal-provider/scheduler.d.ts +29 -0
  156. package/dist/vue/components/terminal-provider/selection-config.d.ts +15 -0
  157. package/dist/vue/components/terminal-provider/utils.d.ts +5 -0
  158. package/dist/vue/composables/use-layout.d.ts +2 -0
  159. package/dist/vue/composables/use-render-node.d.ts +19 -0
  160. package/dist/vue/composables/use-render-stack.d.ts +3 -0
  161. package/dist/vue/composables/use-runtime.d.ts +5 -0
  162. package/dist/vue/composables/use-terminal-node.d.ts +14 -0
  163. package/dist/vue/composables/use-terminal.d.ts +2 -0
  164. package/dist/vue/composables/use-visibility.d.ts +12 -0
  165. package/dist/vue/context.d.ts +153 -0
  166. package/dist/vue/index.d.ts +39 -0
  167. package/dist/vue/injection-key.d.ts +2 -0
  168. package/dist/vue/log/append-only-log-store.d.ts +2 -0
  169. package/dist/vue/log/tlog-keymap.d.ts +28 -0
  170. package/dist/vue/log/tlog-plugins.d.ts +144 -0
  171. package/dist/vue/log/tlog-session.d.ts +81 -0
  172. package/dist/vue/log/tlog-theme.d.ts +68 -0
  173. package/dist/vue/log/types.d.ts +43 -0
  174. package/dist/vue/log/use-tlog-link-controller.d.ts +31 -0
  175. package/dist/vue/log/use-tlog-retained-index.d.ts +26 -0
  176. package/dist/vue/log/use-tlog-search-controller.d.ts +51 -0
  177. package/dist/vue/log/use-tlog-search-results-page.d.ts +31 -0
  178. package/dist/vue/log/use-tlog-virtual-search-results.d.ts +22 -0
  179. package/dist/vue/markdown/ast.d.ts +3 -0
  180. package/dist/vue/markdown/block-source.d.ts +22 -0
  181. package/dist/vue/markdown/document.d.ts +18 -0
  182. package/dist/vue/markdown/layout.d.ts +16 -0
  183. package/dist/vue/markdown/parser.d.ts +11 -0
  184. package/dist/vue/markdown/render.d.ts +10 -0
  185. package/dist/vue/markdown/theme.d.ts +186 -0
  186. package/dist/vue/markdown/types.d.ts +47 -0
  187. package/dist/vue/render/context.d.ts +3 -0
  188. package/dist/vue/render/render-manager.d.ts +94 -0
  189. package/dist/vue/router/RouterView.d.ts +25 -0
  190. package/dist/vue/router/composables.d.ts +4 -0
  191. package/dist/vue/router/context.d.ts +4 -0
  192. package/dist/vue/router/router.d.ts +7 -0
  193. package/dist/vue/router/types.d.ts +29 -0
  194. package/dist/vue/scheduler/frame-mailbox.d.ts +55 -0
  195. package/dist/vue/scheduler/frame-scheduler.d.ts +51 -0
  196. package/dist/vue/utils/frame-task.d.ts +6 -0
  197. package/dist/vue/utils/rect.d.ts +4 -0
  198. package/dist/vue/utils/style-cache.d.ts +3 -0
  199. package/dist/vue/utils/text.d.ts +26 -0
  200. package/dist/vue/utils/wheel-scroll.d.ts +18 -0
  201. package/dist/vue.cjs +18882 -0
  202. package/dist/vue.d.cts +3 -0
  203. package/dist/vue.d.ts +3 -0
  204. package/dist/vue.js +3066 -0
  205. package/dist/{wheel-scroll-CiNsasLf.js → wheel-scroll-B-WlFuNB.js} +361 -367
  206. package/package.json +165 -35
  207. package/dist/path-suggest-BeV6n7m-.js +0 -3
  208. package/dist/sgr-Tko2EQ0U.js +0 -484
  209. package/dist/theme-Bsm65g8k.d.ts +0 -32
  210. package/dist/types-ClIV2h1o.d.ts +0 -103
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -39,6 +40,7 @@ __export(experimental_exports, {
39
40
  createTLogUrlPlugin: () => createTLogUrlPlugin,
40
41
  createTLogViewSessionStore: () => createTLogViewSessionStore,
41
42
  deserializeTLogViewSessionState: () => deserializeTLogViewSessionState,
43
+ detectTLogUrls: () => detectTLogUrls,
42
44
  dispatchTLogPluginLinkAction: () => dispatchTLogPluginLinkAction,
43
45
  getTLogPluginMetadata: () => getTLogPluginMetadata,
44
46
  handleTLogKeymapEvent: () => handleTLogKeymapEvent,
@@ -52,6 +54,7 @@ __export(experimental_exports, {
52
54
  resolveTLogSearchResultsTheme: () => resolveTLogSearchResultsTheme,
53
55
  resolveTLogViewTheme: () => resolveTLogViewTheme,
54
56
  restoreTLogViewSessionState: () => restoreTLogViewSessionState,
57
+ sanitizeTerminalHref: () => sanitizeTerminalHref,
55
58
  serializeTLogViewSessionState: () => serializeTLogViewSessionState,
56
59
  stripTLogAnsiText: () => stripTLogAnsiText,
57
60
  tlogDarkPreset: () => tlogDarkPreset,
@@ -72,27 +75,27 @@ __export(experimental_exports, {
72
75
  module.exports = __toCommonJS(experimental_exports);
73
76
 
74
77
  // src/vue/components/TVirtualList.ts
75
- var import_vue7 = require("vue");
78
+ var import_vue8 = require("vue");
76
79
 
77
80
  // src/vue/composables/use-layout.ts
78
81
  var import_vue = require("vue");
79
82
 
83
+ // src/vue/injection-key.ts
84
+ var VUE_TUI_INJECTION_PROTOCOL = "v1";
85
+ function injectionKey(name) {
86
+ return Symbol.for(`@simon_he/vue-tui:${VUE_TUI_INJECTION_PROTOCOL}:${name}`);
87
+ }
88
+
80
89
  // src/vue/context.ts
81
- var TerminalContextKey = Symbol("TerminalContext");
82
- var LayoutContextKey = Symbol("LayoutContext");
83
- var VisibilityContextKey = Symbol("VisibilityContext");
84
- var EventZIndexContextKey = Symbol("EventZIndex");
85
- var RenderPlaneContextKey = Symbol(
86
- "RenderPlane"
87
- );
88
- var ImeAnchorContextKey = Symbol(
89
- "ImeAnchor"
90
- );
91
- var TInputPluginsContextKey = Symbol(
92
- "TInputPlugins"
93
- );
94
- var TPathPickerProviderContextKey = Symbol("TPathPickerProvider");
95
- var DialogContextKey = Symbol("DialogContext");
90
+ var TerminalContextKey = injectionKey("TerminalContext");
91
+ var LayoutContextKey = injectionKey("LayoutContext");
92
+ var VisibilityContextKey = injectionKey("VisibilityContext");
93
+ var EventZIndexContextKey = injectionKey("EventZIndex");
94
+ var RenderPlaneContextKey = injectionKey("RenderPlane");
95
+ var ImeAnchorContextKey = injectionKey("ImeAnchor");
96
+ var TInputPluginsContextKey = injectionKey("TInputPlugins");
97
+ var TPathPickerProviderContextKey = injectionKey("TPathPickerProvider");
98
+ var DialogContextKey = injectionKey("DialogContext");
96
99
 
97
100
  // src/vue/composables/use-layout.ts
98
101
  function useLayout() {
@@ -109,7 +112,7 @@ var import_vue4 = require("vue");
109
112
  var import_vue2 = require("vue");
110
113
 
111
114
  // src/vue/render/context.ts
112
- var RenderStackKey = Symbol("RenderStack");
115
+ var RenderStackKey = injectionKey("RenderStack");
113
116
 
114
117
  // src/vue/composables/use-render-stack.ts
115
118
  function useRenderStack() {
@@ -128,788 +131,1067 @@ function useTerminal() {
128
131
  return ctx;
129
132
  }
130
133
 
131
- // src/vue/composables/use-render-node.ts
132
- var pendingInvalidateByScheduler = /* @__PURE__ */ new WeakMap();
133
- function mergePriority(prev, next) {
134
- if (prev === "high" || next === "high")
135
- return "high";
136
- if (prev === "normal" || next === "normal")
137
- return "normal";
138
- return "low";
139
- }
140
- function requestBatchedInvalidate(scheduler, plane, priority) {
141
- let state = pendingInvalidateByScheduler.get(scheduler);
142
- if (!state) {
143
- state = { queued: false, plane: null, priority: "low" };
144
- pendingInvalidateByScheduler.set(scheduler, state);
134
+ // src/core/buffer/width.ts
135
+ var fullWidthRanges = [
136
+ [4352, 4447],
137
+ [9001, 9002],
138
+ [11904, 42191],
139
+ [44032, 55203],
140
+ [63744, 64255],
141
+ [65040, 65049],
142
+ [65072, 65135],
143
+ [65280, 65376],
144
+ [65504, 65510]
145
+ ];
146
+ var ambiguousWidthRanges = [
147
+ [161, 161],
148
+ [164, 164],
149
+ [167, 168],
150
+ [170, 170],
151
+ [173, 174],
152
+ [176, 180],
153
+ [182, 186],
154
+ [188, 191],
155
+ [198, 198],
156
+ [208, 208],
157
+ [215, 216],
158
+ [222, 225],
159
+ [230, 230],
160
+ [232, 234],
161
+ [236, 237],
162
+ [240, 240],
163
+ [242, 243],
164
+ [247, 250],
165
+ [252, 252],
166
+ [254, 254],
167
+ [257, 257],
168
+ [273, 273],
169
+ [275, 275],
170
+ [283, 283],
171
+ [294, 295],
172
+ [299, 299],
173
+ [305, 307],
174
+ [312, 312],
175
+ [319, 322],
176
+ [324, 324],
177
+ [328, 331],
178
+ [333, 333],
179
+ [338, 339],
180
+ [358, 359],
181
+ [363, 363],
182
+ [462, 462],
183
+ [464, 464],
184
+ [466, 466],
185
+ [468, 468],
186
+ [470, 470],
187
+ [472, 472],
188
+ [474, 474],
189
+ [476, 476],
190
+ [593, 593],
191
+ [609, 609],
192
+ [708, 708],
193
+ [711, 711],
194
+ [713, 715],
195
+ [717, 717],
196
+ [720, 720],
197
+ [728, 731],
198
+ [733, 733],
199
+ [735, 735],
200
+ [913, 929],
201
+ [931, 937],
202
+ [945, 961],
203
+ [963, 969],
204
+ [1025, 1025],
205
+ [1040, 1103],
206
+ [1105, 1105],
207
+ [8208, 8213],
208
+ [8216, 8217],
209
+ [8220, 8221],
210
+ [8224, 8226],
211
+ [8228, 8231],
212
+ [8240, 8240],
213
+ [8242, 8243],
214
+ [8245, 8245],
215
+ [8251, 8251],
216
+ [8254, 8254],
217
+ [8308, 8308],
218
+ [8319, 8319],
219
+ [8321, 8324],
220
+ [8364, 8364],
221
+ [8451, 8451],
222
+ [8453, 8453],
223
+ [8457, 8457],
224
+ [8467, 8467],
225
+ [8470, 8470],
226
+ [8481, 8482],
227
+ [8486, 8486],
228
+ [8491, 8491],
229
+ [8531, 8532],
230
+ [8539, 8542],
231
+ [8544, 8555],
232
+ [8560, 8569],
233
+ [8585, 8585],
234
+ [8592, 8601],
235
+ [8632, 8633],
236
+ [8658, 8658],
237
+ [8660, 8660],
238
+ [8679, 8679],
239
+ [8704, 8704],
240
+ [8706, 8707],
241
+ [8711, 8712],
242
+ [8715, 8715],
243
+ [8719, 8719],
244
+ [8721, 8721],
245
+ [8725, 8725],
246
+ [8730, 8730],
247
+ [8733, 8736],
248
+ [8739, 8739],
249
+ [8741, 8741],
250
+ [8743, 8748],
251
+ [8750, 8750],
252
+ [8756, 8759],
253
+ [8764, 8765],
254
+ [8776, 8776],
255
+ [8780, 8780],
256
+ [8786, 8786],
257
+ [8800, 8801],
258
+ [8804, 8807],
259
+ [8810, 8811],
260
+ [8814, 8815],
261
+ [8834, 8835],
262
+ [8838, 8839],
263
+ [8853, 8853],
264
+ [8857, 8857],
265
+ [8869, 8869],
266
+ [8895, 8895],
267
+ [8978, 8978],
268
+ [9312, 9449],
269
+ [9451, 9471],
270
+ [9600, 9615],
271
+ [9618, 9621],
272
+ [9632, 9633],
273
+ [9635, 9641],
274
+ [9650, 9651],
275
+ [9654, 9655],
276
+ [9660, 9661],
277
+ [9664, 9665],
278
+ [9670, 9672],
279
+ [9675, 9675],
280
+ [9678, 9681],
281
+ [9698, 9701],
282
+ [9711, 9711],
283
+ [9733, 9734],
284
+ [9737, 9737],
285
+ [9742, 9743],
286
+ [9756, 9756],
287
+ [9758, 9758],
288
+ [9792, 9792],
289
+ [9794, 9794],
290
+ [9824, 9825],
291
+ [9827, 9829],
292
+ [9831, 9834],
293
+ [9836, 9837],
294
+ [9839, 9839],
295
+ [10045, 10045],
296
+ [10102, 10111],
297
+ [11094, 11094],
298
+ [57344, 63743],
299
+ [65533, 65533]
300
+ ];
301
+ function isFullWidthCodePoint(codePoint) {
302
+ if (codePoint < 4352 || codePoint > 65510)
303
+ return false;
304
+ for (const [start, end] of fullWidthRanges) {
305
+ if (codePoint < start)
306
+ return false;
307
+ if (codePoint <= end)
308
+ return true;
145
309
  }
146
- if (state.queued) {
147
- if (state.plane !== null && state.plane !== plane)
148
- state.plane = null;
149
- state.priority = mergePriority(state.priority, priority);
150
- return;
310
+ return false;
311
+ }
312
+ function isAmbiguousWidthCodePoint(codePoint) {
313
+ if (codePoint < 161 || codePoint > 65533)
314
+ return false;
315
+ for (const [start, end] of ambiguousWidthRanges) {
316
+ if (codePoint < start)
317
+ return false;
318
+ if (codePoint <= end)
319
+ return true;
151
320
  }
152
- state.plane = plane;
153
- state.priority = priority;
154
- state.queued = true;
155
- queueMicrotask(() => {
156
- state.queued = false;
157
- const queuedPlane = state.plane;
158
- const queuedPriority = state.priority;
159
- state.plane = null;
160
- state.priority = "low";
161
- scheduler.invalidate({
162
- plane: queuedPlane ?? void 0,
163
- priority: queuedPriority
164
- });
165
- });
321
+ return false;
166
322
  }
167
- function useRenderNode(getOptions) {
168
- const { scheduler, render } = useTerminal();
169
- const parentStack = useRenderStack();
170
- const plane = (0, import_vue4.inject)(RenderPlaneContextKey, (0, import_vue4.ref)("default"));
171
- const id = (0, import_vue4.ref)(null);
172
- const lastPlane = (0, import_vue4.ref)(plane.value);
173
- const options = (0, import_vue4.computed)(() => getOptions());
174
- const stop = (0, import_vue4.watchEffect)(() => {
175
- const opt = options.value;
176
- void opt.deps;
177
- const stack = opt.stack ?? parentStack.value;
178
- const nextPlane = plane.value;
179
- if (!stack)
180
- return;
181
- if (!id.value) {
182
- const node = render.register({
183
- stack,
184
- zIndex: opt.zIndex,
185
- rect: opt.rect,
186
- plane: nextPlane,
187
- paint: opt.paint
188
- });
189
- id.value = node.id;
190
- lastPlane.value = nextPlane;
191
- requestBatchedInvalidate(scheduler, nextPlane, opt.priority ?? "normal");
192
- return;
193
- }
194
- const prevPlane = lastPlane.value;
195
- const updatePayload = {
196
- stack,
197
- zIndex: opt.zIndex ?? 0,
198
- dirtyRowsHint: opt.dirtyRowsHint,
199
- plane: nextPlane,
200
- paint: opt.paint
201
- };
202
- if (Object.prototype.hasOwnProperty.call(opt, "rect"))
203
- updatePayload.rect = opt.rect ?? null;
204
- render.update(id.value, updatePayload);
205
- lastPlane.value = nextPlane;
206
- const priority = opt.priority ?? "normal";
207
- requestBatchedInvalidate(scheduler, prevPlane, priority);
208
- if (prevPlane !== nextPlane)
209
- requestBatchedInvalidate(scheduler, nextPlane, priority);
210
- });
211
- (0, import_vue4.onBeforeUnmount)(() => {
212
- stop();
213
- if (id.value) {
214
- render.unregister(id.value);
215
- requestBatchedInvalidate(scheduler, lastPlane.value, "normal");
216
- }
217
- });
218
- return { id };
323
+ function isEmojiLike(codePoint) {
324
+ return codePoint >= 127744 && codePoint <= 129791 || codePoint >= 127462 && codePoint <= 127487;
219
325
  }
220
-
221
- // src/vue/composables/use-terminal-node.ts
222
- var import_vue5 = require("vue");
223
- function useTerminalNode(getOptions) {
224
- const { events } = useTerminal();
225
- const id = (0, import_vue5.ref)(null);
226
- const options = (0, import_vue5.computed)(() => getOptions());
227
- const stop = (0, import_vue5.watchEffect)(() => {
228
- const manager = events.value;
229
- if (!manager)
230
- return;
231
- const opt = options.value;
232
- if (!id.value) {
233
- const node = manager.register({
234
- rect: opt.rect,
235
- zIndex: opt.zIndex ?? 0,
236
- visible: opt.visible,
237
- focusable: opt.focusable,
238
- selectable: opt.selectable,
239
- handlers: opt.handlers ?? {}
240
- });
241
- id.value = node.id;
242
- return;
243
- }
244
- manager.update(id.value, {
245
- rect: opt.rect,
246
- zIndex: opt.zIndex ?? 0,
247
- visible: opt.visible,
248
- focusable: opt.focusable,
249
- selectable: opt.selectable,
250
- handlers: opt.handlers ?? {}
251
- });
252
- });
253
- (0, import_vue5.onBeforeUnmount)(() => {
254
- stop();
255
- const manager = events.value;
256
- if (manager && id.value)
257
- manager.unregister(id.value);
258
- });
259
- return { id };
326
+ var extendedPictographicRe = null;
327
+ try {
328
+ extendedPictographicRe = new RegExp("\\p{Extended_Pictographic}", "u");
329
+ } catch {
330
+ extendedPictographicRe = null;
331
+ }
332
+ var emojiPresentationRe = null;
333
+ try {
334
+ emojiPresentationRe = new RegExp("\\p{Emoji_Presentation}", "u");
335
+ } catch {
336
+ emojiPresentationRe = null;
337
+ }
338
+ var emojiRe = null;
339
+ try {
340
+ emojiRe = new RegExp("\\p{Emoji}", "u");
341
+ } catch {
342
+ emojiRe = null;
343
+ }
344
+ function normalizeCustomWidth(width) {
345
+ return width === 2 ? 2 : 1;
346
+ }
347
+ function charCellWidth(text, provider = "default") {
348
+ if (!text)
349
+ return 1;
350
+ if (typeof provider === "function")
351
+ return normalizeCustomWidth(provider(text));
352
+ if (provider !== "cjk" && text.length === 1) {
353
+ const code = text.charCodeAt(0);
354
+ if (code < 4352)
355
+ return 1;
356
+ }
357
+ const codePoint = text.codePointAt(0);
358
+ if (codePoint == null)
359
+ return 1;
360
+ const hasVs16 = text.includes("\uFE0F");
361
+ if (isFullWidthCodePoint(codePoint))
362
+ return 2;
363
+ if (provider === "cjk" && isAmbiguousWidthCodePoint(codePoint))
364
+ return 2;
365
+ if (isEmojiLike(codePoint))
366
+ return 2;
367
+ if (emojiPresentationRe?.test(text))
368
+ return 2;
369
+ if (text.includes("\u20E3"))
370
+ return 2;
371
+ if (hasVs16 && emojiRe?.test(text))
372
+ return 2;
373
+ if (extendedPictographicRe?.test(text)) {
374
+ if (codePoint <= 65535)
375
+ return hasVs16 ? 2 : 1;
376
+ return 2;
377
+ }
378
+ return 1;
260
379
  }
261
380
 
262
- // src/vue/composables/use-visibility.ts
263
- var import_vue6 = require("vue");
264
- var VUE_TERMINAL_SHOW_CB = "__vueTerminalOnShow";
265
- var vShowPatched = false;
266
- function patchVShow() {
267
- if (vShowPatched)
268
- return;
269
- vShowPatched = true;
270
- const dir = import_vue6.vShow;
271
- const origBeforeMount = dir.beforeMount;
272
- const origUpdated = dir.updated;
273
- const origBeforeUnmount = dir.beforeUnmount;
274
- const notify = (el, value) => {
275
- if (!el || typeof el !== "object")
276
- return;
277
- const cb = el[VUE_TERMINAL_SHOW_CB];
278
- cb == null ? void 0 : cb(Boolean(value));
279
- };
280
- if (typeof origBeforeMount === "function") {
281
- dir.beforeMount = (el, binding, vnode) => {
282
- origBeforeMount(el, binding, vnode);
283
- notify(el, binding == null ? void 0 : binding.value);
284
- };
381
+ // src/vue/utils/text.ts
382
+ var renderPassDepth = 0;
383
+ var renderPassTextWidthCache = /* @__PURE__ */ new Map();
384
+ var textWidthProviderStack = [];
385
+ function currentTextWidthProvider() {
386
+ return textWidthProviderStack[textWidthProviderStack.length - 1] ?? "default";
387
+ }
388
+ function hasAsciiFastPath(provider) {
389
+ return typeof provider !== "function";
390
+ }
391
+ function canUseDefaultTextCache(provider) {
392
+ return provider === "default" || provider === "narrow-ambiguous";
393
+ }
394
+ function withTextWidthProvider(provider, fn) {
395
+ textWidthProviderStack.push(provider ?? "default");
396
+ try {
397
+ return fn();
398
+ } finally {
399
+ textWidthProviderStack.pop();
285
400
  }
286
- if (typeof origUpdated === "function") {
287
- dir.updated = (el, binding, vnode) => {
288
- origUpdated(el, binding, vnode);
289
- notify(el, binding == null ? void 0 : binding.value);
290
- };
401
+ }
402
+ function isAscii(text) {
403
+ for (let i = 0; i < text.length; i++) {
404
+ if (text.charCodeAt(i) > 127)
405
+ return false;
291
406
  }
292
- if (typeof origBeforeUnmount === "function") {
293
- dir.beforeUnmount = (el, binding, vnode) => {
294
- origBeforeUnmount(el, binding, vnode);
295
- notify(el, binding == null ? void 0 : binding.value);
296
- };
407
+ return true;
408
+ }
409
+ function needsGraphemeSegmentation(text) {
410
+ for (const ch of text) {
411
+ const cp = ch.codePointAt(0);
412
+ if (cp === 8205)
413
+ return true;
414
+ if (cp >= 65024 && cp <= 65039 || cp >= 917760 && cp <= 917999)
415
+ return true;
416
+ if (cp >= 768 && cp <= 879 || cp >= 6832 && cp <= 6911 || cp >= 7616 && cp <= 7679 || cp >= 8400 && cp <= 8447 || cp >= 65056 && cp <= 65071) {
417
+ return true;
418
+ }
419
+ if (cp >= 127995 && cp <= 127999)
420
+ return true;
421
+ if (cp >= 127462 && cp <= 127487)
422
+ return true;
297
423
  }
424
+ return false;
298
425
  }
299
- var PLACEHOLDER_STYLE = Object.freeze({
300
- position: "absolute",
301
- left: "-9999px",
302
- top: "0",
303
- width: "0",
304
- height: "0",
305
- overflow: "hidden"
306
- });
307
- function useVisibility(options) {
308
- patchVShow();
309
- const { scheduler } = useTerminal();
310
- const parentVisible = (0, import_vue6.inject)(VisibilityContextKey, (0, import_vue6.ref)(true));
311
- const localVisible = (0, import_vue6.ref)(true);
312
- const visible = (0, import_vue6.computed)(() => parentVisible.value && localVisible.value);
313
- if (options == null ? void 0 : options.provide)
314
- (0, import_vue6.provide)(VisibilityContextKey, visible);
315
- const onShow = (value) => {
316
- localVisible.value = value;
317
- scheduler.invalidate();
318
- };
319
- const rootProps = {
320
- style: PLACEHOLDER_STYLE,
321
- onVnodeBeforeMount: (vnode) => {
322
- const el = vnode.el;
323
- if (el && typeof el === "object")
324
- el[VUE_TERMINAL_SHOW_CB] = onShow;
325
- },
326
- onVnodeBeforeUnmount: (vnode) => {
327
- const el = vnode.el;
328
- if (el && typeof el === "object" && el[VUE_TERMINAL_SHOW_CB] === onShow)
329
- delete el[VUE_TERMINAL_SHOW_CB];
330
- }
331
- };
332
- return { visible, rootProps };
426
+ var graphemeSegmenter = null;
427
+ try {
428
+ const Segmenter = typeof Intl !== "undefined" ? Intl.Segmenter : void 0;
429
+ graphemeSegmenter = Segmenter ? new Segmenter(void 0, { granularity: "grapheme" }) : null;
430
+ } catch {
431
+ graphemeSegmenter = null;
333
432
  }
334
-
335
- // src/vue/scheduler/frame-mailbox.ts
336
- var EMPTY = Symbol("frame-mailbox-empty");
337
- function createFrameMailbox(options) {
338
- let disposed = false;
339
- let hasPending = false;
340
- let pending = EMPTY;
341
- let queued = 0;
342
- let pendingTaskId = null;
343
- function clearPending() {
344
- hasPending = false;
345
- pending = EMPTY;
346
- queued = 0;
347
- pendingTaskId = null;
348
- }
349
- function currentTaskId() {
350
- if (pendingTaskId)
351
- return pendingTaskId;
352
- const id = typeof options.id === "function" ? options.id() : options.id;
353
- if (!id) {
354
- throw new Error("createFrameMailbox requires a non-empty task id");
433
+ function forEachGrapheme(text, cb) {
434
+ if (!text)
435
+ return;
436
+ const seg = graphemeSegmenter;
437
+ if (!seg || !needsGraphemeSegmentation(text)) {
438
+ for (const ch of text) {
439
+ const r = cb(ch);
440
+ if (r === false)
441
+ return;
355
442
  }
356
- pendingTaskId = id;
357
- return pendingTaskId;
443
+ return;
358
444
  }
359
- function queue(value) {
360
- var _a, _b;
361
- if (disposed)
362
- return false;
363
- const wasPending = hasPending;
364
- const taskId = wasPending ? pendingTaskId : currentTaskId();
365
- let nextPending;
366
- try {
367
- nextPending = hasPending && options.merge ? options.merge(pending, value) : value;
368
- } catch (error) {
369
- clearPending();
370
- if (wasPending)
371
- (_b = (_a = options.scheduler).cancelFrameTask) == null ? void 0 : _b.call(_a, taskId);
372
- throw error;
373
- }
374
- pending = nextPending;
375
- hasPending = true;
376
- queued++;
377
- if (wasPending)
378
- return true;
379
- let accepted;
380
- try {
381
- accepted = options.scheduler.queueFrameTask({
382
- id: taskId,
383
- reason: options.reason,
384
- priority: options.priority,
385
- sync: options.sync,
386
- run(ctx) {
387
- var _a2, _b2;
388
- if (disposed || !hasPending)
389
- return;
390
- const value2 = pending;
391
- const count = queued;
392
- const dropped = Math.max(0, count - 1);
393
- clearPending();
394
- (_a2 = ctx.reportMailboxDeliveryAttempt) == null ? void 0 : _a2.call(ctx, {
395
- id: taskId,
396
- queued: count,
397
- dropped
398
- });
399
- options.apply(value2, ctx, {
400
- queued: count,
401
- dropped
402
- });
403
- (_b2 = ctx.reportDroppedUpdates) == null ? void 0 : _b2.call(ctx, dropped);
404
- }
445
+ for (const part of seg.segment(text)) {
446
+ const r = cb(part.segment);
447
+ if (r === false)
448
+ return;
449
+ }
450
+ }
451
+ function forEachTextCellSegment(text, cb, provider = currentTextWidthProvider()) {
452
+ if (!text)
453
+ return;
454
+ const seg = graphemeSegmenter;
455
+ if (!seg || !needsGraphemeSegmentation(text)) {
456
+ let index2 = 0;
457
+ for (const ch of text) {
458
+ const next = index2 + ch.length;
459
+ const result = cb({
460
+ text: ch,
461
+ cells: charCellWidth(ch, provider),
462
+ start: index2,
463
+ end: next
405
464
  });
406
- } catch (error) {
407
- clearPending();
408
- throw error;
409
- }
410
- if (accepted === false) {
411
- clearPending();
412
- return false;
465
+ if (result === false)
466
+ return;
467
+ index2 = next;
413
468
  }
414
- return true;
415
- }
416
- function replacePending(value) {
417
- if (disposed)
418
- return false;
419
- if (!hasPending)
420
- return queue(value);
421
- pending = value;
422
- return true;
423
- }
424
- function cancel() {
425
- var _a, _b;
426
- const taskId = pendingTaskId;
427
- clearPending();
428
- if (taskId)
429
- (_b = (_a = options.scheduler).cancelFrameTask) == null ? void 0 : _b.call(_a, taskId);
469
+ return;
430
470
  }
431
- function dispose() {
432
- cancel();
433
- disposed = true;
471
+ let index = 0;
472
+ for (const part of seg.segment(text)) {
473
+ const start = part.index ?? index;
474
+ const end = start + part.segment.length;
475
+ const result = cb({
476
+ text: part.segment,
477
+ cells: charCellWidth(part.segment, provider),
478
+ start,
479
+ end
480
+ });
481
+ if (result === false)
482
+ return;
483
+ index = end;
434
484
  }
435
- return {
436
- queue,
437
- replacePending,
438
- cancel,
439
- dispose,
440
- hasPending: () => hasPending,
441
- // Ambiguous when T includes undefined. Pair with hasPending() to
442
- // distinguish "pending undefined" from "no pending value".
443
- peek: () => hasPending ? pending : void 0
444
- };
445
- }
446
-
447
- // src/vue/utils/rect.ts
448
- function intersectRect(a, b) {
449
- const x0 = Math.max(a.x, b.x);
450
- const y0 = Math.max(a.y, b.y);
451
- const x1 = Math.min(a.x + a.w, b.x + b.w);
452
- const y1 = Math.min(a.y + a.h, b.y + b.h);
453
- if (x1 <= x0 || y1 <= y0)
454
- return null;
455
- return { x: x0, y: y0, w: x1 - x0, h: y1 - y0 };
456
- }
457
- function translateRect(rect, dx, dy) {
458
- return { x: rect.x + dx, y: rect.y + dy, w: rect.w, h: rect.h };
459
485
  }
460
- function normalizeCellRect(rect) {
461
- const x0 = Math.floor(rect.x);
462
- const y0 = Math.floor(rect.y);
463
- const x1 = Math.floor(rect.x + rect.w);
464
- const y1 = Math.floor(rect.y + rect.h);
465
- return {
466
- x: x0,
467
- y: y0,
468
- w: Math.max(0, x1 - x0),
469
- h: Math.max(0, y1 - y0)
470
- };
486
+ function sanitizeInlineText(text) {
487
+ if (!text)
488
+ return "";
489
+ if (!/[\n\r\t]/.test(text))
490
+ return text;
491
+ return text.replace(/[\n\r\t]/g, " ");
471
492
  }
472
-
473
- // src/vue/utils/style-cache.ts
474
- var EMPTY_STYLE = Object.freeze({});
475
- var inverseStyleCache = /* @__PURE__ */ new WeakMap();
476
- function cacheBase(base) {
477
- for (const key in base) {
478
- if (Object.prototype.hasOwnProperty.call(base, key))
479
- return base;
493
+ function textCellWidth(text, provider = currentTextWidthProvider()) {
494
+ if (!text)
495
+ return 0;
496
+ if (hasAsciiFastPath(provider) && isAscii(text))
497
+ return text.length;
498
+ const useCache = canUseDefaultTextCache(provider);
499
+ if (useCache && renderPassDepth > 0) {
500
+ const cached = renderPassTextWidthCache.get(text);
501
+ if (cached != null)
502
+ return cached;
480
503
  }
481
- return EMPTY_STYLE;
482
- }
483
- function cacheable(base) {
484
- return Object.isFrozen(base);
485
- }
486
- function defaultActiveStyle(base) {
487
- if (base.inverse)
488
- return base;
489
- base = cacheBase(base);
490
- if (!cacheable(base))
491
- return { ...base, inverse: true };
492
- let cached = inverseStyleCache.get(base);
493
- if (!cached) {
494
- cached = Object.freeze({ ...base, inverse: true });
495
- inverseStyleCache.set(base, cached);
504
+ if (useCache) {
505
+ const cached = textWidthCacheGet(text);
506
+ if (cached != null)
507
+ return cached;
496
508
  }
497
- return cached;
509
+ let cells = 0;
510
+ forEachGrapheme(text, (g) => {
511
+ cells += charCellWidth(g, provider);
512
+ });
513
+ if (useCache && renderPassDepth > 0)
514
+ renderPassTextWidthCache.set(text, cells);
515
+ if (useCache)
516
+ textWidthCacheSet(text, cells);
517
+ return cells;
498
518
  }
499
-
500
- // src/core/buffer/width.ts
501
- var fullWidthRanges = [
502
- [4352, 4447],
503
- [9001, 9002],
504
- [11904, 42191],
505
- [44032, 55203],
506
- [63744, 64255],
507
- [65040, 65049],
508
- [65072, 65135],
509
- [65280, 65376],
510
- [65504, 65510]
511
- ];
512
- function isFullWidthCodePoint(codePoint) {
513
- if (codePoint < 4352 || codePoint > 65510)
514
- return false;
515
- for (const [start, end] of fullWidthRanges) {
516
- if (codePoint < start)
517
- return false;
518
- if (codePoint <= end)
519
- return true;
520
- }
521
- return false;
519
+ var spaceCache = /* @__PURE__ */ new Map();
520
+ var MAX_CACHED_SPACES = 256;
521
+ function spaces(count) {
522
+ count = Math.max(0, Math.floor(count));
523
+ if (count === 0)
524
+ return "";
525
+ const cached = spaceCache.get(count);
526
+ if (cached)
527
+ return cached;
528
+ const v = " ".repeat(count);
529
+ if (spaceCache.size >= MAX_CACHED_SPACES)
530
+ spaceCache.clear();
531
+ spaceCache.set(count, v);
532
+ return v;
522
533
  }
523
- function isEmojiLike(codePoint) {
524
- return codePoint >= 127744 && codePoint <= 129791 || codePoint >= 127462 && codePoint <= 127487;
534
+ function sliceByCells(text, maxCells, provider = currentTextWidthProvider()) {
535
+ maxCells = Math.max(0, Math.floor(maxCells));
536
+ if (maxCells <= 0)
537
+ return "";
538
+ if (text && hasAsciiFastPath(provider) && isAscii(text))
539
+ return text.slice(0, maxCells);
540
+ const out = [];
541
+ let cells = 0;
542
+ forEachGrapheme(text, (g) => {
543
+ const w = charCellWidth(g, provider);
544
+ if (cells + w > maxCells)
545
+ return false;
546
+ out.push(g);
547
+ cells += w;
548
+ return void 0;
549
+ });
550
+ return out.length ? out.join("") : "";
525
551
  }
526
- var extendedPictographicRe = null;
527
- try {
528
- extendedPictographicRe = new RegExp("\\p{Extended_Pictographic}", "u");
529
- } catch {
530
- extendedPictographicRe = null;
552
+ function sliceByCellsRange(text, startCells, endCells, provider = currentTextWidthProvider()) {
553
+ startCells = Math.max(0, Math.floor(startCells));
554
+ endCells = Math.max(0, Math.floor(endCells));
555
+ if (endCells <= startCells)
556
+ return "";
557
+ if (!text)
558
+ return "";
559
+ if (hasAsciiFastPath(provider) && isAscii(text))
560
+ return text.slice(startCells, endCells);
561
+ const out = [];
562
+ let cells = 0;
563
+ forEachGrapheme(text, (g) => {
564
+ const w = charCellWidth(g, provider);
565
+ const next = cells + w;
566
+ if (cells >= endCells)
567
+ return false;
568
+ if (next <= startCells) {
569
+ cells = next;
570
+ return void 0;
571
+ }
572
+ if (cells < startCells && next > startCells) {
573
+ out.push(spaces(Math.min(next, endCells) - startCells));
574
+ cells = next;
575
+ return void 0;
576
+ }
577
+ if (next > endCells) {
578
+ out.push(spaces(endCells - cells));
579
+ return false;
580
+ }
581
+ out.push(g);
582
+ cells = next;
583
+ return void 0;
584
+ });
585
+ return out.length ? out.join("") : "";
531
586
  }
532
- var emojiPresentationRe = null;
533
- try {
534
- emojiPresentationRe = new RegExp("\\p{Emoji_Presentation}", "u");
535
- } catch {
536
- emojiPresentationRe = null;
587
+ function padEndByCells(text, width, provider = currentTextWidthProvider()) {
588
+ width = Math.max(0, Math.floor(width));
589
+ const cells = text && hasAsciiFastPath(provider) && isAscii(text) ? text.length : textCellWidth(text, provider);
590
+ if (cells >= width)
591
+ return text;
592
+ return `${text}${spaces(width - cells)}`;
537
593
  }
538
- var emojiRe = null;
539
- try {
540
- emojiRe = new RegExp("\\p{Emoji}", "u");
541
- } catch {
542
- emojiRe = null;
594
+ var inlineLineCacheByWidth = /* @__PURE__ */ new Map();
595
+ var MAX_INLINE_LINE_CACHE_BUCKETS = 32;
596
+ var MAX_INLINE_LINE_CACHE_PER_WIDTH = 512;
597
+ function getInlineLineBucket(width) {
598
+ let bucket = inlineLineCacheByWidth.get(width);
599
+ if (bucket)
600
+ return bucket;
601
+ if (inlineLineCacheByWidth.size >= MAX_INLINE_LINE_CACHE_BUCKETS)
602
+ inlineLineCacheByWidth.clear();
603
+ bucket = /* @__PURE__ */ new Map();
604
+ inlineLineCacheByWidth.set(width, bucket);
605
+ return bucket;
543
606
  }
544
- function charCellWidth(text) {
607
+ function formatInlineCellLine(text, width, provider = currentTextWidthProvider()) {
608
+ width = Math.max(0, Math.floor(width));
609
+ if (width === 0)
610
+ return "";
545
611
  if (!text)
546
- return 1;
547
- if (text.length === 1) {
548
- const code = text.charCodeAt(0);
549
- if (code < 4352)
550
- return 1;
612
+ return spaces(width);
613
+ const useCache = canUseDefaultTextCache(provider);
614
+ const bucket = useCache ? getInlineLineBucket(width) : null;
615
+ const cached = bucket?.get(text);
616
+ if (cached != null)
617
+ return cached;
618
+ const sanitized = sanitizeInlineText(text);
619
+ if (sanitized && hasAsciiFastPath(provider) && isAscii(sanitized)) {
620
+ const out2 = sanitized.length >= width ? sanitized.slice(0, width) : `${sanitized}${spaces(width - sanitized.length)}`;
621
+ if (bucket) {
622
+ if (bucket.size >= MAX_INLINE_LINE_CACHE_PER_WIDTH)
623
+ bucket.clear();
624
+ bucket.set(text, out2);
625
+ }
626
+ return out2;
551
627
  }
552
- const codePoint = text.codePointAt(0);
553
- if (codePoint == null)
554
- return 1;
555
- const hasVs16 = text.includes("\uFE0F");
556
- if (isFullWidthCodePoint(codePoint))
557
- return 2;
558
- if (isEmojiLike(codePoint))
559
- return 2;
560
- if (emojiPresentationRe == null ? void 0 : emojiPresentationRe.test(text))
561
- return 2;
562
- if (text.includes("\u20E3"))
563
- return 2;
564
- if (hasVs16 && (emojiRe == null ? void 0 : emojiRe.test(text)))
565
- return 2;
566
- if (extendedPictographicRe == null ? void 0 : extendedPictographicRe.test(text)) {
567
- if (codePoint <= 65535)
568
- return hasVs16 ? 2 : 1;
569
- return 2;
628
+ const out = padEndByCells(sliceByCells(sanitized, width, provider), width, provider);
629
+ if (bucket) {
630
+ if (bucket.size >= MAX_INLINE_LINE_CACHE_PER_WIDTH)
631
+ bucket.clear();
632
+ bucket.set(text, out);
570
633
  }
571
- return 1;
634
+ return out;
572
635
  }
573
-
574
- // src/vue/utils/text.ts
575
- var renderPassDepth = 0;
576
- var renderPassTextWidthCache = /* @__PURE__ */ new Map();
577
- function isAscii(text) {
578
- for (let i = 0; i < text.length; i++) {
579
- if (text.charCodeAt(i) > 127)
580
- return false;
636
+ var wrapCacheByWidth = /* @__PURE__ */ new Map();
637
+ var MAX_WRAP_CACHE_BUCKETS = 32;
638
+ var MAX_WRAP_CACHE_PER_WIDTH = 256;
639
+ function getWrapBucket(width) {
640
+ let bucket = wrapCacheByWidth.get(width);
641
+ if (bucket)
642
+ return bucket;
643
+ if (wrapCacheByWidth.size >= MAX_WRAP_CACHE_BUCKETS)
644
+ wrapCacheByWidth.clear();
645
+ bucket = /* @__PURE__ */ new Map();
646
+ wrapCacheByWidth.set(width, bucket);
647
+ return bucket;
648
+ }
649
+ var textWidthCache = /* @__PURE__ */ new Map();
650
+ var MAX_TEXT_WIDTH_CACHE = 1024;
651
+ function textWidthCacheGet(text) {
652
+ const cached = textWidthCache.get(text);
653
+ if (cached == null)
654
+ return null;
655
+ textWidthCache.delete(text);
656
+ textWidthCache.set(text, cached);
657
+ return cached;
658
+ }
659
+ function textWidthCacheSet(text, cells) {
660
+ textWidthCache.set(text, cells);
661
+ if (textWidthCache.size > MAX_TEXT_WIDTH_CACHE) {
662
+ const firstKey = textWidthCache.keys().next().value;
663
+ if (firstKey != null)
664
+ textWidthCache.delete(firstKey);
581
665
  }
582
- return true;
583
666
  }
584
- function needsGraphemeSegmentation(text) {
585
- for (const ch of text) {
586
- const cp = ch.codePointAt(0);
587
- if (cp === 8205)
588
- return true;
589
- if (cp >= 65024 && cp <= 65039 || cp >= 917760 && cp <= 917999)
590
- return true;
591
- if (cp >= 768 && cp <= 879 || cp >= 6832 && cp <= 6911 || cp >= 7616 && cp <= 7679 || cp >= 8400 && cp <= 8447 || cp >= 65056 && cp <= 65071) {
592
- return true;
667
+ function wrapByCells(text, width, provider = currentTextWidthProvider()) {
668
+ width = Math.max(1, Math.floor(width));
669
+ const useCache = canUseDefaultTextCache(provider);
670
+ const bucket = useCache ? getWrapBucket(width) : null;
671
+ if (text && hasAsciiFastPath(provider) && isAscii(text)) {
672
+ const cached2 = bucket?.get(text);
673
+ if (cached2)
674
+ return cached2;
675
+ const out2 = [];
676
+ for (const rawLine of text.replace(/\r/g, "").split("\n")) {
677
+ if (rawLine.length === 0) {
678
+ out2.push("");
679
+ continue;
680
+ }
681
+ for (let i = 0; i < rawLine.length; i += width)
682
+ out2.push(rawLine.slice(i, i + width));
593
683
  }
594
- if (cp >= 127995 && cp <= 127999)
595
- return true;
596
- if (cp >= 127462 && cp <= 127487)
597
- return true;
684
+ if (bucket) {
685
+ if (bucket.size >= MAX_WRAP_CACHE_PER_WIDTH)
686
+ bucket.clear();
687
+ bucket.set(text, out2);
688
+ }
689
+ return out2;
598
690
  }
599
- return false;
691
+ const cached = bucket?.get(text);
692
+ if (cached)
693
+ return cached;
694
+ const out = [];
695
+ for (const rawLine of text.replace(/\r/g, "").split("\n")) {
696
+ if (rawLine.length === 0) {
697
+ out.push("");
698
+ continue;
699
+ }
700
+ const seg = graphemeSegmenter;
701
+ if (seg && needsGraphemeSegmentation(rawLine)) {
702
+ let lineStart = 0;
703
+ let cells = 0;
704
+ for (const part of seg.segment(rawLine)) {
705
+ const g = part.segment;
706
+ const gIdx = part.index;
707
+ const w = charCellWidth(g, provider);
708
+ if (cells > 0 && cells + w > width) {
709
+ out.push(rawLine.slice(lineStart, gIdx));
710
+ lineStart = gIdx;
711
+ cells = 0;
712
+ }
713
+ cells += w;
714
+ if (cells >= width) {
715
+ const end = gIdx + g.length;
716
+ out.push(rawLine.slice(lineStart, end));
717
+ lineStart = end;
718
+ cells = 0;
719
+ }
720
+ }
721
+ if (lineStart < rawLine.length)
722
+ out.push(rawLine.slice(lineStart));
723
+ } else {
724
+ let lineStart = 0;
725
+ let pos = 0;
726
+ let cells = 0;
727
+ for (const ch of rawLine) {
728
+ const w = charCellWidth(ch, provider);
729
+ if (cells > 0 && cells + w > width) {
730
+ out.push(rawLine.slice(lineStart, pos));
731
+ lineStart = pos;
732
+ cells = 0;
733
+ }
734
+ pos += ch.length;
735
+ cells += w;
736
+ if (cells >= width) {
737
+ out.push(rawLine.slice(lineStart, pos));
738
+ lineStart = pos;
739
+ cells = 0;
740
+ }
741
+ }
742
+ if (lineStart < rawLine.length)
743
+ out.push(rawLine.slice(lineStart));
744
+ }
745
+ }
746
+ const res = out.length ? out : [""];
747
+ if (bucket) {
748
+ if (bucket.size >= MAX_WRAP_CACHE_PER_WIDTH)
749
+ bucket.clear();
750
+ bucket.set(text, res);
751
+ }
752
+ return res;
600
753
  }
601
- var graphemeSegmenter = null;
602
- try {
603
- graphemeSegmenter = typeof Intl !== "undefined" && "Segmenter" in Intl ? new Intl.Segmenter(void 0, { granularity: "grapheme" }) : null;
604
- } catch {
605
- graphemeSegmenter = null;
754
+
755
+ // src/vue/composables/use-render-node.ts
756
+ var pendingInvalidateByScheduler = /* @__PURE__ */ new WeakMap();
757
+ function mergePriority(prev, next) {
758
+ if (prev === "high" || next === "high")
759
+ return "high";
760
+ if (prev === "normal" || next === "normal")
761
+ return "normal";
762
+ return "low";
606
763
  }
607
- function forEachGrapheme(text, cb) {
608
- if (!text)
609
- return;
610
- const seg = graphemeSegmenter;
611
- if (!seg || !needsGraphemeSegmentation(text)) {
612
- for (const ch of text) {
613
- const r = cb(ch);
614
- if (r === false)
615
- return;
616
- }
764
+ function requestBatchedInvalidate(scheduler, plane, priority) {
765
+ let state = pendingInvalidateByScheduler.get(scheduler);
766
+ if (!state) {
767
+ state = { queued: false, plane: null, priority: "low" };
768
+ pendingInvalidateByScheduler.set(scheduler, state);
769
+ }
770
+ if (state.queued) {
771
+ if (state.plane !== null && state.plane !== plane)
772
+ state.plane = null;
773
+ state.priority = mergePriority(state.priority, priority);
617
774
  return;
618
775
  }
619
- for (const part of seg.segment(text)) {
620
- const r = cb(part.segment);
621
- if (r === false)
776
+ state.plane = plane;
777
+ state.priority = priority;
778
+ state.queued = true;
779
+ queueMicrotask(() => {
780
+ state.queued = false;
781
+ const queuedPlane = state.plane;
782
+ const queuedPriority = state.priority;
783
+ state.plane = null;
784
+ state.priority = "low";
785
+ scheduler.invalidate({
786
+ plane: queuedPlane ?? void 0,
787
+ priority: queuedPriority
788
+ });
789
+ });
790
+ }
791
+ function useRenderNode(getOptions) {
792
+ const { scheduler, render, widthProvider } = useTerminal();
793
+ const parentStack = useRenderStack();
794
+ const plane = (0, import_vue4.inject)(RenderPlaneContextKey, (0, import_vue4.ref)("default"));
795
+ const id = (0, import_vue4.ref)(null);
796
+ const lastPlane = (0, import_vue4.ref)(plane.value);
797
+ const options = (0, import_vue4.computed)(() => withTextWidthProvider(widthProvider, getOptions));
798
+ const stop = (0, import_vue4.watchEffect)(() => {
799
+ const opt = options.value;
800
+ void opt.deps;
801
+ const stack = opt.stack ?? parentStack.value;
802
+ const nextPlane = plane.value;
803
+ if (!stack)
804
+ return;
805
+ if (!id.value) {
806
+ const node = render.register({
807
+ stack,
808
+ zIndex: opt.zIndex,
809
+ rect: opt.rect,
810
+ plane: nextPlane,
811
+ paint: opt.paint
812
+ });
813
+ id.value = node.id;
814
+ lastPlane.value = nextPlane;
815
+ requestBatchedInvalidate(scheduler, nextPlane, opt.priority ?? "normal");
622
816
  return;
817
+ }
818
+ const prevPlane = lastPlane.value;
819
+ const updatePayload = {
820
+ stack,
821
+ zIndex: opt.zIndex ?? 0,
822
+ dirtyRowsHint: opt.dirtyRowsHint,
823
+ plane: nextPlane,
824
+ paint: opt.paint
825
+ };
826
+ if (Object.prototype.hasOwnProperty.call(opt, "rect"))
827
+ updatePayload.rect = opt.rect ?? null;
828
+ render.update(id.value, updatePayload);
829
+ lastPlane.value = nextPlane;
830
+ const priority = opt.priority ?? "normal";
831
+ requestBatchedInvalidate(scheduler, prevPlane, priority);
832
+ if (prevPlane !== nextPlane)
833
+ requestBatchedInvalidate(scheduler, nextPlane, priority);
834
+ });
835
+ (0, import_vue4.onBeforeUnmount)(() => {
836
+ stop();
837
+ if (id.value) {
838
+ render.unregister(id.value);
839
+ requestBatchedInvalidate(scheduler, lastPlane.value, "normal");
840
+ }
841
+ });
842
+ return { id };
843
+ }
844
+
845
+ // src/vue/composables/use-terminal-node.ts
846
+ var import_vue5 = require("vue");
847
+ function wrapHandlers(handlers, widthProvider) {
848
+ if (!handlers)
849
+ return {};
850
+ const out = {};
851
+ for (const key of Object.keys(handlers)) {
852
+ const handler = handlers[key];
853
+ if (!handler)
854
+ continue;
855
+ out[key] = (event) => withTextWidthProvider(widthProvider, () => handler(event));
623
856
  }
857
+ return out;
624
858
  }
625
- function forEachTextCellSegment(text, cb) {
626
- if (!text)
627
- return;
628
- const seg = graphemeSegmenter;
629
- if (!seg || !needsGraphemeSegmentation(text)) {
630
- let index2 = 0;
631
- for (const ch of text) {
632
- const next = index2 + ch.length;
633
- const result = cb({
634
- text: ch,
635
- cells: charCellWidth(ch),
636
- start: index2,
637
- end: next
859
+ function useTerminalNode(getOptions) {
860
+ const { events, widthProvider } = useTerminal();
861
+ const id = (0, import_vue5.ref)(null);
862
+ const options = (0, import_vue5.computed)(() => withTextWidthProvider(widthProvider, getOptions));
863
+ const stop = (0, import_vue5.watchEffect)(() => {
864
+ const manager = events.value;
865
+ if (!manager)
866
+ return;
867
+ const opt = options.value;
868
+ if (!id.value) {
869
+ const node = manager.register({
870
+ rect: opt.rect,
871
+ zIndex: opt.zIndex ?? 0,
872
+ visible: opt.visible,
873
+ focusable: opt.focusable,
874
+ selectable: opt.selectable,
875
+ selectionScrollBy: opt.selectionScrollBy,
876
+ handlers: wrapHandlers(opt.handlers, widthProvider)
638
877
  });
639
- if (result === false)
640
- return;
641
- index2 = next;
878
+ id.value = node.id;
879
+ return;
642
880
  }
643
- return;
644
- }
645
- let index = 0;
646
- for (const part of seg.segment(text)) {
647
- const start = part.index ?? index;
648
- const end = start + part.segment.length;
649
- const result = cb({
650
- text: part.segment,
651
- cells: charCellWidth(part.segment),
652
- start,
653
- end
881
+ manager.update(id.value, {
882
+ rect: opt.rect,
883
+ zIndex: opt.zIndex ?? 0,
884
+ visible: opt.visible,
885
+ focusable: opt.focusable,
886
+ selectable: opt.selectable,
887
+ selectionScrollBy: opt.selectionScrollBy,
888
+ handlers: wrapHandlers(opt.handlers, widthProvider)
654
889
  });
655
- if (result === false)
890
+ });
891
+ (0, import_vue5.onBeforeUnmount)(() => {
892
+ stop();
893
+ const manager = events.value;
894
+ if (manager && id.value)
895
+ manager.unregister(id.value);
896
+ });
897
+ return { id };
898
+ }
899
+
900
+ // src/vue/composables/use-visibility.ts
901
+ var import_vue6 = require("vue");
902
+ var VUE_TERMINAL_SHOW_CB = "__vueTerminalOnShow";
903
+ var vShowPatched = false;
904
+ function patchVShow() {
905
+ if (vShowPatched)
906
+ return;
907
+ vShowPatched = true;
908
+ const dir = import_vue6.vShow;
909
+ const origBeforeMount = dir.beforeMount;
910
+ const origUpdated = dir.updated;
911
+ const origBeforeUnmount = dir.beforeUnmount;
912
+ const notify = (el, value) => {
913
+ if (!el || typeof el !== "object")
656
914
  return;
657
- index = end;
915
+ const cb = el[VUE_TERMINAL_SHOW_CB];
916
+ cb?.(Boolean(value));
917
+ };
918
+ if (typeof origBeforeMount === "function") {
919
+ dir.beforeMount = (el, binding, vnode) => {
920
+ origBeforeMount(el, binding, vnode);
921
+ notify(el, binding?.value);
922
+ };
658
923
  }
659
- }
660
- function sanitizeInlineText(text) {
661
- if (!text)
662
- return "";
663
- if (!/[\n\r\t]/.test(text))
664
- return text;
665
- return text.replace(/[\n\r\t]/g, " ");
666
- }
667
- function textCellWidth(text) {
668
- if (!text)
669
- return 0;
670
- if (isAscii(text))
671
- return text.length;
672
- if (renderPassDepth > 0) {
673
- const cached2 = renderPassTextWidthCache.get(text);
674
- if (cached2 != null)
675
- return cached2;
924
+ if (typeof origUpdated === "function") {
925
+ dir.updated = (el, binding, vnode) => {
926
+ origUpdated(el, binding, vnode);
927
+ notify(el, binding?.value);
928
+ };
929
+ }
930
+ if (typeof origBeforeUnmount === "function") {
931
+ dir.beforeUnmount = (el, binding, vnode) => {
932
+ origBeforeUnmount(el, binding, vnode);
933
+ notify(el, binding?.value);
934
+ };
676
935
  }
677
- const cached = textWidthCacheGet(text);
678
- if (cached != null)
679
- return cached;
680
- let cells = 0;
681
- forEachGrapheme(text, (g) => {
682
- cells += charCellWidth(g);
683
- });
684
- if (renderPassDepth > 0)
685
- renderPassTextWidthCache.set(text, cells);
686
- textWidthCacheSet(text, cells);
687
- return cells;
688
- }
689
- var spaceCache = /* @__PURE__ */ new Map();
690
- var MAX_CACHED_SPACES = 256;
691
- function spaces(count) {
692
- count = Math.max(0, Math.floor(count));
693
- if (count === 0)
694
- return "";
695
- const cached = spaceCache.get(count);
696
- if (cached)
697
- return cached;
698
- const v = " ".repeat(count);
699
- if (spaceCache.size >= MAX_CACHED_SPACES)
700
- spaceCache.clear();
701
- spaceCache.set(count, v);
702
- return v;
703
936
  }
704
- function sliceByCells(text, maxCells) {
705
- maxCells = Math.max(0, Math.floor(maxCells));
706
- if (maxCells <= 0)
707
- return "";
708
- if (text && isAscii(text))
709
- return text.slice(0, maxCells);
710
- const out = [];
711
- let cells = 0;
712
- forEachGrapheme(text, (g) => {
713
- const w = charCellWidth(g);
714
- if (cells + w > maxCells)
715
- return false;
716
- out.push(g);
717
- cells += w;
718
- return void 0;
719
- });
720
- return out.length ? out.join("") : "";
937
+ var PLACEHOLDER_STYLE = Object.freeze({
938
+ position: "absolute",
939
+ left: "-9999px",
940
+ top: "0",
941
+ width: "0",
942
+ height: "0",
943
+ overflow: "hidden"
944
+ });
945
+ function useVisibility(options) {
946
+ patchVShow();
947
+ const { scheduler } = useTerminal();
948
+ const parentVisible = (0, import_vue6.inject)(VisibilityContextKey, (0, import_vue6.ref)(true));
949
+ const localVisible = (0, import_vue6.ref)(true);
950
+ const visible = (0, import_vue6.computed)(() => parentVisible.value && localVisible.value);
951
+ if (options?.provide)
952
+ (0, import_vue6.provide)(VisibilityContextKey, visible);
953
+ const onShow = (value) => {
954
+ localVisible.value = value;
955
+ scheduler.invalidate();
956
+ };
957
+ const rootProps = {
958
+ style: PLACEHOLDER_STYLE,
959
+ onVnodeBeforeMount: (vnode) => {
960
+ const el = vnode.el;
961
+ if (el && typeof el === "object")
962
+ el[VUE_TERMINAL_SHOW_CB] = onShow;
963
+ },
964
+ onVnodeBeforeUnmount: (vnode) => {
965
+ const el = vnode.el;
966
+ if (el && typeof el === "object" && el[VUE_TERMINAL_SHOW_CB] === onShow)
967
+ delete el[VUE_TERMINAL_SHOW_CB];
968
+ }
969
+ };
970
+ return { visible, rootProps };
721
971
  }
722
- function sliceByCellsRange(text, startCells, endCells) {
723
- startCells = Math.max(0, Math.floor(startCells));
724
- endCells = Math.max(0, Math.floor(endCells));
725
- if (endCells <= startCells)
726
- return "";
727
- if (!text)
728
- return "";
729
- if (isAscii(text))
730
- return text.slice(startCells, endCells);
731
- const out = [];
732
- let cells = 0;
733
- forEachGrapheme(text, (g) => {
734
- const w = charCellWidth(g);
735
- const next = cells + w;
736
- if (cells >= endCells)
972
+
973
+ // src/vue/scheduler/frame-mailbox.ts
974
+ var EMPTY = Symbol("frame-mailbox-empty");
975
+ function createFrameMailbox(options) {
976
+ let disposed = false;
977
+ let hasPending = false;
978
+ let pending = EMPTY;
979
+ let queued = 0;
980
+ let pendingTaskId = null;
981
+ function clearPending() {
982
+ hasPending = false;
983
+ pending = EMPTY;
984
+ queued = 0;
985
+ pendingTaskId = null;
986
+ }
987
+ function currentTaskId() {
988
+ if (pendingTaskId)
989
+ return pendingTaskId;
990
+ const id = typeof options.id === "function" ? options.id() : options.id;
991
+ if (!id) {
992
+ throw new Error("createFrameMailbox requires a non-empty task id");
993
+ }
994
+ pendingTaskId = id;
995
+ return pendingTaskId;
996
+ }
997
+ function queue(value) {
998
+ if (disposed)
737
999
  return false;
738
- if (next <= startCells) {
739
- cells = next;
740
- return void 0;
1000
+ const wasPending = hasPending;
1001
+ const taskId = wasPending ? pendingTaskId : currentTaskId();
1002
+ let nextPending;
1003
+ try {
1004
+ nextPending = hasPending && options.merge ? options.merge(pending, value) : value;
1005
+ } catch (error) {
1006
+ clearPending();
1007
+ if (wasPending)
1008
+ options.scheduler.cancelFrameTask?.(taskId);
1009
+ throw error;
741
1010
  }
742
- if (cells < startCells && next > startCells) {
743
- out.push(spaces(Math.min(next, endCells) - startCells));
744
- cells = next;
745
- return void 0;
1011
+ pending = nextPending;
1012
+ hasPending = true;
1013
+ queued++;
1014
+ if (wasPending)
1015
+ return true;
1016
+ let accepted;
1017
+ try {
1018
+ accepted = options.scheduler.queueFrameTask({
1019
+ id: taskId,
1020
+ reason: options.reason,
1021
+ priority: options.priority,
1022
+ sync: options.sync,
1023
+ run(ctx) {
1024
+ if (disposed || !hasPending)
1025
+ return;
1026
+ const value2 = pending;
1027
+ const count = queued;
1028
+ const dropped = Math.max(0, count - 1);
1029
+ clearPending();
1030
+ ctx.reportMailboxDeliveryAttempt?.({
1031
+ id: taskId,
1032
+ queued: count,
1033
+ dropped
1034
+ });
1035
+ options.apply(value2, ctx, {
1036
+ queued: count,
1037
+ dropped
1038
+ });
1039
+ ctx.reportDroppedUpdates?.(dropped);
1040
+ }
1041
+ });
1042
+ } catch (error) {
1043
+ clearPending();
1044
+ throw error;
746
1045
  }
747
- if (next > endCells) {
748
- out.push(spaces(endCells - cells));
1046
+ if (accepted === false) {
1047
+ clearPending();
749
1048
  return false;
750
1049
  }
751
- out.push(g);
752
- cells = next;
753
- return void 0;
754
- });
755
- return out.length ? out.join("") : "";
1050
+ return true;
1051
+ }
1052
+ function replacePending(value) {
1053
+ if (disposed)
1054
+ return false;
1055
+ if (!hasPending)
1056
+ return queue(value);
1057
+ pending = value;
1058
+ return true;
1059
+ }
1060
+ function cancel() {
1061
+ const taskId = pendingTaskId;
1062
+ clearPending();
1063
+ if (taskId)
1064
+ options.scheduler.cancelFrameTask?.(taskId);
1065
+ }
1066
+ function dispose() {
1067
+ cancel();
1068
+ disposed = true;
1069
+ }
1070
+ return {
1071
+ queue,
1072
+ replacePending,
1073
+ cancel,
1074
+ dispose,
1075
+ hasPending: () => hasPending,
1076
+ // Ambiguous when T includes undefined. Pair with hasPending() to
1077
+ // distinguish "pending undefined" from "no pending value".
1078
+ peek: () => hasPending ? pending : void 0
1079
+ };
756
1080
  }
757
- function padEndByCells(text, width) {
758
- width = Math.max(0, Math.floor(width));
759
- const cells = text && isAscii(text) ? text.length : textCellWidth(text);
760
- if (cells >= width)
761
- return text;
762
- return `${text}${spaces(width - cells)}`;
1081
+
1082
+ // src/selection/terminal-selection.ts
1083
+ var import_vue7 = require("vue");
1084
+ var EMPTY_STATE = Object.freeze({
1085
+ active: false,
1086
+ anchor: null,
1087
+ focus: null,
1088
+ text: "",
1089
+ hasRange: false
1090
+ });
1091
+ function clampPoint(point, cols, rows) {
1092
+ return {
1093
+ x: Math.max(0, Math.min(Math.max(0, cols - 1), Math.floor(point.x))),
1094
+ y: Math.max(0, Math.min(Math.max(0, rows - 1), Math.floor(point.y)))
1095
+ };
763
1096
  }
764
- var inlineLineCacheByWidth = /* @__PURE__ */ new Map();
765
- var MAX_INLINE_LINE_CACHE_BUCKETS = 32;
766
- var MAX_INLINE_LINE_CACHE_PER_WIDTH = 512;
767
- function getInlineLineBucket(width) {
768
- let bucket = inlineLineCacheByWidth.get(width);
769
- if (bucket)
770
- return bucket;
771
- if (inlineLineCacheByWidth.size >= MAX_INLINE_LINE_CACHE_BUCKETS)
772
- inlineLineCacheByWidth.clear();
773
- bucket = /* @__PURE__ */ new Map();
774
- inlineLineCacheByWidth.set(width, bucket);
775
- return bucket;
1097
+ function comparePoints(a, b) {
1098
+ return a.y - b.y || a.x - b.x;
776
1099
  }
777
- function formatInlineCellLine(text, width) {
778
- width = Math.max(0, Math.floor(width));
779
- if (width === 0)
780
- return "";
781
- if (!text)
782
- return spaces(width);
783
- const bucket = getInlineLineBucket(width);
784
- const cached = bucket.get(text);
785
- if (cached != null)
786
- return cached;
787
- const sanitized = sanitizeInlineText(text);
788
- if (sanitized && isAscii(sanitized)) {
789
- const out2 = sanitized.length >= width ? sanitized.slice(0, width) : `${sanitized}${spaces(width - sanitized.length)}`;
790
- if (bucket.size >= MAX_INLINE_LINE_CACHE_PER_WIDTH)
791
- bucket.clear();
792
- bucket.set(text, out2);
793
- return out2;
794
- }
795
- const out = padEndByCells(sliceByCells(sanitized, width), width);
796
- if (bucket.size >= MAX_INLINE_LINE_CACHE_PER_WIDTH)
797
- bucket.clear();
798
- bucket.set(text, out);
799
- return out;
1100
+ function pointKey(point) {
1101
+ return `${point.x}:${point.y}`;
800
1102
  }
801
- var wrapCacheByWidth = /* @__PURE__ */ new Map();
802
- var MAX_WRAP_CACHE_BUCKETS = 32;
803
- var MAX_WRAP_CACHE_PER_WIDTH = 256;
804
- function getWrapBucket(width) {
805
- let bucket = wrapCacheByWidth.get(width);
806
- if (bucket)
807
- return bucket;
808
- if (wrapCacheByWidth.size >= MAX_WRAP_CACHE_BUCKETS)
809
- wrapCacheByWidth.clear();
810
- bucket = /* @__PURE__ */ new Map();
811
- wrapCacheByWidth.set(width, bucket);
812
- return bucket;
1103
+ function terminalSelectionRowSpans(range, cols, rows) {
1104
+ if (cols <= 0 || rows <= 0)
1105
+ return [];
1106
+ const anchor = clampPoint(range.anchor, cols, rows);
1107
+ const focus = clampPoint(range.focus, cols, rows);
1108
+ if (pointKey(anchor) === pointKey(focus))
1109
+ return [];
1110
+ const start = comparePoints(anchor, focus) <= 0 ? anchor : focus;
1111
+ const end = start === anchor ? focus : anchor;
1112
+ const spans = [];
1113
+ for (let y = start.y; y <= end.y; y++) {
1114
+ const x0 = y === start.y ? start.x : 0;
1115
+ const x1 = y === end.y ? end.x + 1 : cols;
1116
+ if (x1 > x0)
1117
+ spans.push({ y, x0, x1 });
1118
+ }
1119
+ return spans;
1120
+ }
1121
+ function terminalSelectionVisibleRowSpans(range, cols, rows, visibleStartY, visibleEndY) {
1122
+ if (cols <= 0 || rows <= 0)
1123
+ return [];
1124
+ const anchor = clampPoint(range.anchor, cols, rows);
1125
+ const focus = clampPoint(range.focus, cols, rows);
1126
+ if (pointKey(anchor) === pointKey(focus))
1127
+ return [];
1128
+ const start = comparePoints(anchor, focus) <= 0 ? anchor : focus;
1129
+ const end = start === anchor ? focus : anchor;
1130
+ const fromY = Math.max(start.y, Math.floor(visibleStartY), 0);
1131
+ const toY = Math.min(end.y, Math.ceil(visibleEndY) - 1, rows - 1);
1132
+ if (toY < fromY)
1133
+ return [];
1134
+ const spans = [];
1135
+ for (let y = fromY; y <= toY; y++) {
1136
+ const x0 = y === start.y ? start.x : 0;
1137
+ const x1 = y === end.y ? end.x + 1 : cols;
1138
+ if (x1 > x0)
1139
+ spans.push({ y, x0, x1 });
1140
+ }
1141
+ return spans;
813
1142
  }
814
- var textWidthCache = /* @__PURE__ */ new Map();
815
- var MAX_TEXT_WIDTH_CACHE = 1024;
816
- function textWidthCacheGet(text) {
817
- const cached = textWidthCache.get(text);
818
- if (cached == null)
1143
+
1144
+ // src/vue/utils/rect.ts
1145
+ function intersectRect(a, b) {
1146
+ const x0 = Math.max(a.x, b.x);
1147
+ const y0 = Math.max(a.y, b.y);
1148
+ const x1 = Math.min(a.x + a.w, b.x + b.w);
1149
+ const y1 = Math.min(a.y + a.h, b.y + b.h);
1150
+ if (x1 <= x0 || y1 <= y0)
819
1151
  return null;
820
- textWidthCache.delete(text);
821
- textWidthCache.set(text, cached);
822
- return cached;
1152
+ return { x: x0, y: y0, w: x1 - x0, h: y1 - y0 };
823
1153
  }
824
- function textWidthCacheSet(text, cells) {
825
- textWidthCache.set(text, cells);
826
- if (textWidthCache.size > MAX_TEXT_WIDTH_CACHE) {
827
- const firstKey = textWidthCache.keys().next().value;
828
- if (firstKey != null)
829
- textWidthCache.delete(firstKey);
830
- }
1154
+ function translateRect(rect, dx, dy) {
1155
+ return { x: rect.x + dx, y: rect.y + dy, w: rect.w, h: rect.h };
831
1156
  }
832
- function wrapByCells(text, width) {
833
- width = Math.max(1, Math.floor(width));
834
- const bucket = getWrapBucket(width);
835
- if (text && isAscii(text)) {
836
- const cached2 = bucket.get(text);
837
- if (cached2)
838
- return cached2;
839
- const out2 = [];
840
- for (const rawLine of text.replace(/\r/g, "").split("\n")) {
841
- if (rawLine.length === 0) {
842
- out2.push("");
843
- continue;
844
- }
845
- for (let i = 0; i < rawLine.length; i += width)
846
- out2.push(rawLine.slice(i, i + width));
847
- }
848
- if (bucket.size >= MAX_WRAP_CACHE_PER_WIDTH)
849
- bucket.clear();
850
- bucket.set(text, out2);
851
- return out2;
1157
+ function normalizeCellRect(rect) {
1158
+ const x0 = Math.floor(rect.x);
1159
+ const y0 = Math.floor(rect.y);
1160
+ const x1 = Math.floor(rect.x + rect.w);
1161
+ const y1 = Math.floor(rect.y + rect.h);
1162
+ return {
1163
+ x: x0,
1164
+ y: y0,
1165
+ w: Math.max(0, x1 - x0),
1166
+ h: Math.max(0, y1 - y0)
1167
+ };
1168
+ }
1169
+
1170
+ // src/vue/utils/style-cache.ts
1171
+ var EMPTY_STYLE = Object.freeze({});
1172
+ var inverseStyleCache = /* @__PURE__ */ new WeakMap();
1173
+ function cacheBase(base) {
1174
+ for (const key in base) {
1175
+ if (Object.prototype.hasOwnProperty.call(base, key))
1176
+ return base;
852
1177
  }
853
- const cached = bucket.get(text);
854
- if (cached)
855
- return cached;
856
- const out = [];
857
- for (const rawLine of text.replace(/\r/g, "").split("\n")) {
858
- if (rawLine.length === 0) {
859
- out.push("");
860
- continue;
861
- }
862
- const seg = graphemeSegmenter;
863
- if (seg && needsGraphemeSegmentation(rawLine)) {
864
- let lineStart = 0;
865
- let cells = 0;
866
- for (const part of seg.segment(rawLine)) {
867
- const g = part.segment;
868
- const gIdx = part.index;
869
- const w = charCellWidth(g);
870
- if (cells > 0 && cells + w > width) {
871
- out.push(rawLine.slice(lineStart, gIdx));
872
- lineStart = gIdx;
873
- cells = 0;
874
- }
875
- cells += w;
876
- if (cells >= width) {
877
- const end = gIdx + g.length;
878
- out.push(rawLine.slice(lineStart, end));
879
- lineStart = end;
880
- cells = 0;
881
- }
882
- }
883
- if (lineStart < rawLine.length)
884
- out.push(rawLine.slice(lineStart));
885
- } else {
886
- let lineStart = 0;
887
- let pos = 0;
888
- let cells = 0;
889
- for (const ch of rawLine) {
890
- const w = charCellWidth(ch);
891
- if (cells > 0 && cells + w > width) {
892
- out.push(rawLine.slice(lineStart, pos));
893
- lineStart = pos;
894
- cells = 0;
895
- }
896
- pos += ch.length;
897
- cells += w;
898
- if (cells >= width) {
899
- out.push(rawLine.slice(lineStart, pos));
900
- lineStart = pos;
901
- cells = 0;
902
- }
903
- }
904
- if (lineStart < rawLine.length)
905
- out.push(rawLine.slice(lineStart));
906
- }
1178
+ return EMPTY_STYLE;
1179
+ }
1180
+ function cacheable(base) {
1181
+ return Object.isFrozen(base);
1182
+ }
1183
+ function defaultActiveStyle(base) {
1184
+ if (base.inverse)
1185
+ return base;
1186
+ base = cacheBase(base);
1187
+ if (!cacheable(base))
1188
+ return { ...base, inverse: true };
1189
+ let cached = inverseStyleCache.get(base);
1190
+ if (!cached) {
1191
+ cached = Object.freeze({ ...base, inverse: true });
1192
+ inverseStyleCache.set(base, cached);
907
1193
  }
908
- const res = out.length ? out : [""];
909
- if (bucket.size >= MAX_WRAP_CACHE_PER_WIDTH)
910
- bucket.clear();
911
- bucket.set(text, res);
912
- return res;
1194
+ return cached;
913
1195
  }
914
1196
 
915
1197
  // src/vue/utils/wheel-scroll.ts
@@ -1033,7 +1315,7 @@ function getWheelScrollInput(e) {
1033
1315
  return { deltaY, mode: "auto" };
1034
1316
  }
1035
1317
  var virtualListInstanceSeq = 0;
1036
- var TVirtualList = (0, import_vue7.defineComponent)({
1318
+ var TVirtualList = (0, import_vue8.defineComponent)({
1037
1319
  name: "TVirtualList",
1038
1320
  props: {
1039
1321
  x: { type: Number, required: true },
@@ -1053,6 +1335,11 @@ var TVirtualList = (0, import_vue7.defineComponent)({
1053
1335
  style: { type: Object, default: void 0 },
1054
1336
  activeStyle: { type: Object, default: void 0 },
1055
1337
  autoFocus: { type: Boolean, default: false },
1338
+ selectionText: {
1339
+ type: Function,
1340
+ default: void 0
1341
+ },
1342
+ selectable: { type: Boolean, default: false },
1056
1343
  rowScrollMode: {
1057
1344
  type: String,
1058
1345
  default: "off"
@@ -1069,34 +1356,35 @@ var TVirtualList = (0, import_vue7.defineComponent)({
1069
1356
  "keydown"
1070
1357
  ],
1071
1358
  setup(props, { emit }) {
1072
- const { terminal, scheduler, render, defaultStyle, events } = useTerminal();
1073
- const instance = (0, import_vue7.getCurrentInstance)();
1359
+ const { terminal, scheduler, render, defaultStyle, events, selection } = useTerminal();
1360
+ const instance = (0, import_vue8.getCurrentInstance)();
1074
1361
  const layout = useLayout();
1075
1362
  const { visible, rootProps } = useVisibility();
1076
- const plane = (0, import_vue7.inject)(RenderPlaneContextKey, (0, import_vue7.ref)("default"));
1077
- const parentEventZ = (0, import_vue7.inject)(EventZIndexContextKey, (0, import_vue7.computed)(() => 0));
1078
- const eventZ = (0, import_vue7.computed)(() => (parentEventZ.value ?? 0) + (props.zIndex ?? 0));
1363
+ const plane = (0, import_vue8.inject)(RenderPlaneContextKey, (0, import_vue8.ref)("default"));
1364
+ const parentEventZ = (0, import_vue8.inject)(EventZIndexContextKey, (0, import_vue8.computed)(() => 0));
1365
+ const eventZ = (0, import_vue8.computed)(() => (parentEventZ.value ?? 0) + (props.zIndex ?? 0));
1079
1366
  const virtualListInstanceId = ++virtualListInstanceSeq;
1080
1367
  const wheelTaskId = `TVirtualList:${virtualListInstanceId}:wheel`;
1081
- const focused = (0, import_vue7.ref)(false);
1082
- const active = (0, import_vue7.ref)(props.modelValue);
1083
- const scrollTop = (0, import_vue7.ref)(0);
1368
+ const focused = (0, import_vue8.ref)(false);
1369
+ const active = (0, import_vue8.ref)(props.modelValue);
1370
+ const scrollTop = (0, import_vue8.ref)(0);
1084
1371
  let dirtyRowsHint;
1085
1372
  let renderNodeId = null;
1086
1373
  let warnedGetItemIdentity = false;
1087
1374
  let warnedRenderItemIdentity = false;
1088
1375
  let alive = true;
1089
1376
  let pendingWheelTop = null;
1377
+ let pendingSelectionScrollFocusRemap = false;
1090
1378
  const wheelState = createWheelScrollState();
1091
- const itemCount = (0, import_vue7.computed)(() => {
1379
+ const itemCount = (0, import_vue8.computed)(() => {
1092
1380
  const n = Math.floor(Number(props.itemCount));
1093
1381
  return Number.isFinite(n) ? Math.max(0, n) : 0;
1094
1382
  });
1095
- const fullRect = (0, import_vue7.computed)(() => {
1383
+ const fullRect = (0, import_vue8.computed)(() => {
1096
1384
  const raw = { x: props.x, y: props.y, w: props.w, h: props.h };
1097
1385
  return translateRect(raw, layout.originX, layout.originY);
1098
1386
  });
1099
- const absRect = (0, import_vue7.computed)(() => {
1387
+ const absRect = (0, import_vue8.computed)(() => {
1100
1388
  const translated = fullRect.value;
1101
1389
  if (!layout.clipRect)
1102
1390
  return translated;
@@ -1144,9 +1432,9 @@ var TVirtualList = (0, import_vue7.defineComponent)({
1144
1432
  return visible.value && r.w > 0 && r.h > 0;
1145
1433
  }
1146
1434
  function isScrollControlled() {
1147
- return Object.prototype.hasOwnProperty.call((instance == null ? void 0 : instance.vnode.props) ?? {}, "scrollTop");
1435
+ return Object.prototype.hasOwnProperty.call(instance?.vnode.props ?? {}, "scrollTop");
1148
1436
  }
1149
- const visibleWindow = (0, import_vue7.computed)(() => {
1437
+ const visibleWindow = (0, import_vue8.computed)(() => {
1150
1438
  const clip = normalizedRect();
1151
1439
  const { y: clipY } = clipOffsets();
1152
1440
  const top = clampScrollTop(scrollTop.value);
@@ -1175,7 +1463,10 @@ var TVirtualList = (0, import_vue7.defineComponent)({
1175
1463
  nextTop = clamp2(active.value - clipY, 0, maxTop);
1176
1464
  else if (active.value > visibleEnd)
1177
1465
  nextTop = clamp2(active.value - (clipY + clip.h - 1), 0, maxTop);
1178
- return applyScrollTop(nextTop, options);
1466
+ const result = applyScrollTop(nextTop, options);
1467
+ if (result.changed)
1468
+ selection.refresh();
1469
+ return result;
1179
1470
  }
1180
1471
  function normalizedModelValue() {
1181
1472
  return normalizeIndex(props.modelValue, itemCount.value);
@@ -1200,6 +1491,7 @@ var TVirtualList = (0, import_vue7.defineComponent)({
1200
1491
  resetWheelScrollState(wheelState);
1201
1492
  return;
1202
1493
  }
1494
+ selection.refresh();
1203
1495
  if (changed.dirty)
1204
1496
  ctx.invalidate({ priority: "high", plane: plane.value, reason: "scroll" });
1205
1497
  }
@@ -1234,7 +1526,7 @@ var TVirtualList = (0, import_vue7.defineComponent)({
1234
1526
  let initializedModel = false;
1235
1527
  let initializedGeometry = false;
1236
1528
  let initializedScrollTop = false;
1237
- (0, import_vue7.watch)(
1529
+ (0, import_vue8.watch)(
1238
1530
  () => props.modelValue,
1239
1531
  () => {
1240
1532
  const emitScroll = initializedModel;
@@ -1250,7 +1542,7 @@ var TVirtualList = (0, import_vue7.defineComponent)({
1250
1542
  },
1251
1543
  { immediate: true }
1252
1544
  );
1253
- (0, import_vue7.watch)(
1545
+ (0, import_vue8.watch)(
1254
1546
  [
1255
1547
  () => itemCount.value,
1256
1548
  () => fullRect.value.y,
@@ -1265,6 +1557,8 @@ var TVirtualList = (0, import_vue7.defineComponent)({
1265
1557
  active.value = normalizedModelValue();
1266
1558
  const nextTop = clampScrollTop(scrollTop.value);
1267
1559
  const changed = applyScrollTop(nextTop, { emitScroll });
1560
+ if (changed.changed)
1561
+ selection.refresh();
1268
1562
  if (!changed.changed)
1269
1563
  markViewportDirty();
1270
1564
  if (pendingWheelTop !== null && !hasPaintableViewport()) {
@@ -1281,7 +1575,7 @@ var TVirtualList = (0, import_vue7.defineComponent)({
1281
1575
  },
1282
1576
  { immediate: true }
1283
1577
  );
1284
- (0, import_vue7.watch)(
1578
+ (0, import_vue8.watch)(
1285
1579
  () => props.scrollTop,
1286
1580
  () => {
1287
1581
  if (!isScrollControlled())
@@ -1294,12 +1588,15 @@ var TVirtualList = (0, import_vue7.defineComponent)({
1294
1588
  scrollTop.value = nextTop;
1295
1589
  if (!wasInitialized || !changed)
1296
1590
  return;
1591
+ const remap = pendingSelectionScrollFocusRemap;
1592
+ pendingSelectionScrollFocusRemap = false;
1593
+ selection.refresh(remap ? { remapFocus: true } : void 0);
1297
1594
  markViewportDirty();
1298
1595
  invalidateSelf("high", "scroll");
1299
1596
  },
1300
1597
  { immediate: true }
1301
1598
  );
1302
- (0, import_vue7.watch)(
1599
+ (0, import_vue8.watch)(
1303
1600
  () => props.getItem,
1304
1601
  (next, prev) => {
1305
1602
  if (next === prev || warnedGetItemIdentity || !globalThis.__VT_DEBUG_PERF__)
@@ -1310,7 +1607,7 @@ var TVirtualList = (0, import_vue7.defineComponent)({
1310
1607
  );
1311
1608
  }
1312
1609
  );
1313
- (0, import_vue7.watch)(
1610
+ (0, import_vue8.watch)(
1314
1611
  () => props.renderItem,
1315
1612
  (next, prev) => {
1316
1613
  if (next === prev || warnedRenderItemIdentity || !globalThis.__VT_DEBUG_PERF__)
@@ -1321,10 +1618,19 @@ var TVirtualList = (0, import_vue7.defineComponent)({
1321
1618
  );
1322
1619
  }
1323
1620
  );
1621
+ (0, import_vue8.watch)(
1622
+ () => props.itemVersion,
1623
+ () => {
1624
+ selection.refresh();
1625
+ }
1626
+ );
1324
1627
  function itemText(index) {
1325
1628
  const item = props.getItem(index);
1629
+ if (props.selectionText) {
1630
+ return String(props.selectionText(item, index) ?? "");
1631
+ }
1326
1632
  const raw = props.renderItem ? props.renderItem(item, index) : item;
1327
- return String(raw ?? "");
1633
+ return typeof raw === "string" || typeof raw === "number" || typeof raw === "boolean" ? String(raw) : "";
1328
1634
  }
1329
1635
  function commit(index) {
1330
1636
  if (itemCount.value <= 0)
@@ -1390,11 +1696,102 @@ var TVirtualList = (0, import_vue7.defineComponent)({
1390
1696
  commit(active.value);
1391
1697
  }
1392
1698
  }
1699
+ function scrollSelectionBy(delta) {
1700
+ const n = Math.trunc(Number(delta));
1701
+ if (!Number.isFinite(n) || n === 0)
1702
+ return false;
1703
+ cancelWheelScrollFrame();
1704
+ if (isScrollControlled()) {
1705
+ const nextTop = clampScrollTop(scrollTop.value + n);
1706
+ if (nextTop === scrollTop.value)
1707
+ return false;
1708
+ if (pendingSelectionScrollFocusRemap)
1709
+ return false;
1710
+ pendingSelectionScrollFocusRemap = true;
1711
+ emit("update:scrollTop", nextTop);
1712
+ emit("scroll", nextTop);
1713
+ return true;
1714
+ }
1715
+ const changed = applyScrollTop(scrollTop.value + n, {
1716
+ emitScroll: true,
1717
+ emitUpdate: true,
1718
+ priority: "high",
1719
+ reason: "scroll"
1720
+ });
1721
+ if (!changed.changed)
1722
+ return false;
1723
+ selection.refresh({ remapFocus: true });
1724
+ return true;
1725
+ }
1726
+ function selectionPointForCell(point) {
1727
+ const r = normalizedRect();
1728
+ if (point.x < r.x || point.y < r.y || point.x >= r.x + r.w || point.y >= r.y + r.h) {
1729
+ return null;
1730
+ }
1731
+ const { x: clipX, y: clipY } = clipOffsets();
1732
+ const virtualY = scrollTop.value + clipY + (point.y - r.y);
1733
+ if (virtualY < 0 || virtualY >= itemCount.value)
1734
+ return null;
1735
+ return {
1736
+ x: clamp2(clipX + (point.x - r.x), 0, Math.max(0, props.w - 1)),
1737
+ y: virtualY
1738
+ };
1739
+ }
1740
+ function canHandleSelectionRange(range) {
1741
+ return Boolean(selectionPointForCell(range.anchor) && selectionPointForCell(range.focus));
1742
+ }
1743
+ function textForSelectionRange(range) {
1744
+ const cols = Math.max(1, Math.floor(props.w));
1745
+ return terminalSelectionRowSpans(range, cols, itemCount.value).map((span) => {
1746
+ const text = sliceByCellsRange(itemText(span.y), span.x0, span.x1);
1747
+ return span.x1 >= cols ? text.trimEnd() : text;
1748
+ }).join("\n");
1749
+ }
1750
+ function visibleSpansForSelectionRange(providerRange, _screenRange) {
1751
+ const r = normalizedRect();
1752
+ const { x: clipX, y: clipY } = clipOffsets();
1753
+ const cols = Math.max(1, Math.floor(props.w));
1754
+ const top = scrollTop.value + clipY;
1755
+ const bottom = top + r.h;
1756
+ const providerSpans = terminalSelectionVisibleRowSpans(
1757
+ providerRange,
1758
+ cols,
1759
+ itemCount.value,
1760
+ top,
1761
+ bottom
1762
+ );
1763
+ const result = [];
1764
+ for (const span of providerSpans) {
1765
+ const screenY = r.y + (span.y - top);
1766
+ const screenX0 = r.x + span.x0 - clipX;
1767
+ const screenX1 = r.x + span.x1 - clipX;
1768
+ const x0 = Math.max(r.x, screenX0);
1769
+ const x1 = Math.min(r.x + r.w, screenX1);
1770
+ if (screenY >= r.y && screenY < r.y + r.h && x1 > x0) {
1771
+ result.push({ y: screenY, x0, x1 });
1772
+ }
1773
+ }
1774
+ return result;
1775
+ }
1776
+ const selectionTextProvider = {
1777
+ id: `TVirtualList:${virtualListInstanceId}:selection-text`,
1778
+ get rect() {
1779
+ return normalizedRect();
1780
+ },
1781
+ canHandle: canHandleSelectionRange,
1782
+ pointForCell: selectionPointForCell,
1783
+ getText: textForSelectionRange,
1784
+ getVisibleSpans: visibleSpansForSelectionRange
1785
+ };
1786
+ const unregisterSelectionTextProvider = selection.registerTextProvider(selectionTextProvider);
1787
+ (0, import_vue8.onBeforeUnmount)(unregisterSelectionTextProvider);
1393
1788
  const eventNode = useTerminalNode(() => ({
1394
1789
  rect: normalizedRect(),
1395
1790
  zIndex: eventZ.value,
1396
1791
  visible: visible.value,
1397
1792
  focusable: true,
1793
+ selectable: props.selectable,
1794
+ selectionScrollBy: scrollSelectionBy,
1398
1795
  handlers: {
1399
1796
  click: (e) => {
1400
1797
  cancelWheelScrollFrame();
@@ -1418,7 +1815,6 @@ var TVirtualList = (0, import_vue7.defineComponent)({
1418
1815
  commit(idx);
1419
1816
  },
1420
1817
  wheel: (e) => {
1421
- var _a;
1422
1818
  const { deltaY, mode } = getWheelScrollInput(e);
1423
1819
  if (!deltaY)
1424
1820
  return;
@@ -1440,7 +1836,7 @@ var TVirtualList = (0, import_vue7.defineComponent)({
1440
1836
  return;
1441
1837
  if (!requestWheelScroll(nextTop))
1442
1838
  return;
1443
- (_a = e.preventDefault) == null ? void 0 : _a.call(e);
1839
+ e.preventDefault?.();
1444
1840
  },
1445
1841
  focus: () => {
1446
1842
  focused.value = true;
@@ -1455,7 +1851,7 @@ var TVirtualList = (0, import_vue7.defineComponent)({
1455
1851
  keydown: onKeydown
1456
1852
  }
1457
1853
  }));
1458
- (0, import_vue7.watchEffect)(() => {
1854
+ (0, import_vue8.watchEffect)(() => {
1459
1855
  if (!props.autoFocus)
1460
1856
  return;
1461
1857
  if (!visible.value)
@@ -1468,14 +1864,14 @@ var TVirtualList = (0, import_vue7.defineComponent)({
1468
1864
  return;
1469
1865
  manager.focus(nodeId);
1470
1866
  });
1471
- (0, import_vue7.watch)(
1867
+ (0, import_vue8.watch)(
1472
1868
  () => visible.value,
1473
1869
  (nextVisible) => {
1474
1870
  if (!nextVisible)
1475
1871
  cancelWheelScrollFrame();
1476
1872
  }
1477
1873
  );
1478
- (0, import_vue7.onBeforeUnmount)(() => {
1874
+ (0, import_vue8.onBeforeUnmount)(() => {
1479
1875
  alive = false;
1480
1876
  pendingWheelTop = null;
1481
1877
  resetWheelScrollState(wheelState);
@@ -1489,7 +1885,7 @@ var TVirtualList = (0, import_vue7.defineComponent)({
1489
1885
  return rows;
1490
1886
  }
1491
1887
  function unionDirtyRows(nextRows) {
1492
- if (!(dirtyRowsHint == null ? void 0 : dirtyRowsHint.length))
1888
+ if (!dirtyRowsHint?.length)
1493
1889
  return nextRows.slice().sort((a, b) => a - b);
1494
1890
  const rows = new Set(dirtyRowsHint);
1495
1891
  for (const y of nextRows)
@@ -1523,19 +1919,19 @@ var TVirtualList = (0, import_vue7.defineComponent)({
1523
1919
  if (!delta)
1524
1920
  return { changed: false, dirty: false, top: scrollTop.value, controlled };
1525
1921
  if (controlled) {
1526
- if ((options == null ? void 0 : options.emitUpdate) ?? true)
1922
+ if (options?.emitUpdate ?? true)
1527
1923
  emit("update:scrollTop", clampedTop);
1528
- if (options == null ? void 0 : options.emitScroll)
1924
+ if (options?.emitScroll)
1529
1925
  emit("scroll", clampedTop);
1530
1926
  return { changed: true, dirty: false, top: clampedTop, controlled };
1531
1927
  }
1532
1928
  scrollTop.value = clampedTop;
1533
- if (options == null ? void 0 : options.emitUpdate)
1929
+ if (options?.emitUpdate)
1534
1930
  emit("update:scrollTop", clampedTop);
1535
1931
  const dirty = markViewportDirty();
1536
- if (options == null ? void 0 : options.emitScroll)
1932
+ if (options?.emitScroll)
1537
1933
  emit("scroll", clampedTop);
1538
- if ((options == null ? void 0 : options.priority) && dirty)
1934
+ if (options?.priority && dirty)
1539
1935
  invalidateSelf(options.priority, options.reason ?? "scroll");
1540
1936
  return { changed: true, dirty, top: clampedTop, controlled };
1541
1937
  }
@@ -1581,7 +1977,7 @@ var TVirtualList = (0, import_vue7.defineComponent)({
1581
1977
  terminal.write(line, { x: r.x, y, style });
1582
1978
  };
1583
1979
  const rows = dirtyRows;
1584
- if (rows == null ? void 0 : rows.length) {
1980
+ if (rows?.length) {
1585
1981
  for (const y of rows)
1586
1982
  paintRow(y);
1587
1983
  return;
@@ -1590,10 +1986,10 @@ var TVirtualList = (0, import_vue7.defineComponent)({
1590
1986
  paintRow(y);
1591
1987
  }
1592
1988
  }));
1593
- (0, import_vue7.watchEffect)(() => {
1989
+ (0, import_vue8.watchEffect)(() => {
1594
1990
  renderNodeId = renderNode.id.value;
1595
1991
  });
1596
- return () => (0, import_vue7.h)("span", rootProps);
1992
+ return () => (0, import_vue8.h)("span", rootProps);
1597
1993
  }
1598
1994
  });
1599
1995
 
@@ -1802,8 +2198,100 @@ function parseAnsiSgr(input, baseStyle = {}) {
1802
2198
  return segments;
1803
2199
  }
1804
2200
 
2201
+ // src/utils/url-safety.ts
2202
+ var ENCODED_ASCII_CONTROL_RE = /%(?:0[0-9a-f]|1[0-9a-f]|7f)/i;
2203
+ function hasControlCodePoint(value) {
2204
+ for (let i = 0; i < value.length; i++) {
2205
+ const code = value.charCodeAt(i);
2206
+ if (code <= 31 || code >= 127 && code <= 159)
2207
+ return true;
2208
+ }
2209
+ return false;
2210
+ }
2211
+ function hasEncodedControl(value) {
2212
+ let current = String(value ?? "");
2213
+ for (let depth = 0; depth < 3; depth++) {
2214
+ if (ENCODED_ASCII_CONTROL_RE.test(current))
2215
+ return true;
2216
+ let decoded;
2217
+ try {
2218
+ decoded = decodeURIComponent(current);
2219
+ } catch {
2220
+ return true;
2221
+ }
2222
+ if (hasControlCodePoint(decoded))
2223
+ return true;
2224
+ if (decoded === current)
2225
+ return false;
2226
+ current = decoded;
2227
+ }
2228
+ return ENCODED_ASCII_CONTROL_RE.test(current) || hasControlCodePoint(current);
2229
+ }
2230
+
2231
+ // src/core/hyperlink.ts
2232
+ var BLOCKED_SCHEME_RE = /^(?:javascript|data|vbscript):/i;
2233
+ function normalizeRawHref(value) {
2234
+ if (typeof value !== "string")
2235
+ return null;
2236
+ const raw = value.trim();
2237
+ if (!raw)
2238
+ return null;
2239
+ if (raw !== value)
2240
+ return null;
2241
+ for (let i = 0; i < value.length; i++) {
2242
+ const code = value.charCodeAt(i);
2243
+ if (code <= 31 || code >= 127 && code <= 159)
2244
+ return null;
2245
+ }
2246
+ if (/\s/u.test(raw))
2247
+ return null;
2248
+ if (raw.startsWith("//"))
2249
+ return null;
2250
+ if (BLOCKED_SCHEME_RE.test(raw))
2251
+ return null;
2252
+ if (hasEncodedControl(raw))
2253
+ return null;
2254
+ return raw;
2255
+ }
2256
+ function parseSafeAbsoluteUrl(raw) {
2257
+ if (raw.includes("\\"))
2258
+ return null;
2259
+ try {
2260
+ return new URL(raw);
2261
+ } catch {
2262
+ return null;
2263
+ }
2264
+ }
2265
+ function sanitizeAbsoluteHref(raw, options = {}) {
2266
+ const url = parseSafeAbsoluteUrl(raw);
2267
+ if (!url)
2268
+ return null;
2269
+ if (url.protocol === "http:" || url.protocol === "https:") {
2270
+ if (!/^https?:\/\//i.test(raw))
2271
+ return null;
2272
+ return options.preserveHttpHref ? raw : url.toString();
2273
+ }
2274
+ if (url.protocol === "mailto:")
2275
+ return raw;
2276
+ return null;
2277
+ }
2278
+ function sanitizeTerminalHref(value, options = {}) {
2279
+ const raw = normalizeRawHref(value);
2280
+ if (!raw)
2281
+ return null;
2282
+ const sanitized = sanitizeAbsoluteHref(raw, { preserveHttpHref: true });
2283
+ if (sanitized)
2284
+ return sanitized;
2285
+ if (options.allowFileUrls) {
2286
+ const url = parseSafeAbsoluteUrl(raw);
2287
+ if (url?.protocol === "file:")
2288
+ return url.toString();
2289
+ }
2290
+ return null;
2291
+ }
2292
+
1805
2293
  // src/vue/components/TLogView.ts
1806
- var import_vue8 = require("vue");
2294
+ var import_vue9 = require("vue");
1807
2295
  var nextTLogViewTaskId = 0;
1808
2296
  var DEFAULT_LOG_RENDER_CACHE_SIZE = 2e3;
1809
2297
  var DEFAULT_LOG_WRAP_CACHE_SIZE = 2e3;
@@ -1979,7 +2467,7 @@ function parseAnsiLineToSegments(text, baseStyle, links, linkStyle) {
1979
2467
  flush(i);
1980
2468
  const parts = osc.body.split(";");
1981
2469
  if (parts[0] === "8" && parts.length >= 3) {
1982
- href = parts.slice(2).join(";") || void 0;
2470
+ href = sanitizeTerminalHref(parts.slice(2).join(";")) ?? void 0;
1983
2471
  }
1984
2472
  i = osc.end;
1985
2473
  textStart = osc.end + 1;
@@ -2169,7 +2657,7 @@ function wrapStyledSegmentsByCells(segments, width) {
2169
2657
  }
2170
2658
  return rows;
2171
2659
  }
2172
- var TLogView = (0, import_vue8.defineComponent)({
2660
+ var TLogView = (0, import_vue9.defineComponent)({
2173
2661
  name: "TLogView",
2174
2662
  props: {
2175
2663
  x: { type: Number, required: true },
@@ -2198,6 +2686,7 @@ var TLogView = (0, import_vue8.defineComponent)({
2198
2686
  default: void 0
2199
2687
  },
2200
2688
  autoFocus: { type: Boolean, default: false },
2689
+ selectable: { type: Boolean, default: true },
2201
2690
  autoStickToBottom: { type: Boolean, default: true },
2202
2691
  overscan: { type: Number, default: 2 },
2203
2692
  wrap: { type: Boolean, default: false },
@@ -2261,20 +2750,21 @@ var TLogView = (0, import_vue8.defineComponent)({
2261
2750
  "keydown"
2262
2751
  ],
2263
2752
  setup(props, { emit, expose }) {
2264
- const { terminal, scheduler, render, rendererCapabilities, defaultStyle, events } = useTerminal();
2753
+ const { terminal, scheduler, render, rendererCapabilities, defaultStyle, events, selection } = useTerminal();
2265
2754
  const layout = useLayout();
2266
2755
  const { visible, rootProps } = useVisibility();
2267
- const plane = (0, import_vue8.inject)(RenderPlaneContextKey, (0, import_vue8.ref)("default"));
2268
- const parentEventZ = (0, import_vue8.inject)(EventZIndexContextKey, (0, import_vue8.computed)(() => 0));
2269
- const eventZ = (0, import_vue8.computed)(() => (parentEventZ.value ?? 0) + (props.zIndex ?? 0));
2270
- const focused = (0, import_vue8.ref)(false);
2271
- const innerScrollTop = (0, import_vue8.ref)(0);
2272
- const stickToBottom = (0, import_vue8.ref)(true);
2756
+ const plane = (0, import_vue9.inject)(RenderPlaneContextKey, (0, import_vue9.ref)("default"));
2757
+ const parentEventZ = (0, import_vue9.inject)(EventZIndexContextKey, (0, import_vue9.computed)(() => 0));
2758
+ const eventZ = (0, import_vue9.computed)(() => (parentEventZ.value ?? 0) + (props.zIndex ?? 0));
2759
+ const focused = (0, import_vue9.ref)(false);
2760
+ const innerScrollTop = (0, import_vue9.ref)(0);
2761
+ const stickToBottom = (0, import_vue9.ref)(true);
2273
2762
  const frameTaskId = `TLogView:${nextTLogViewTaskId++}`;
2274
2763
  let dirtyRowsHint;
2275
2764
  let renderNodeId = null;
2276
2765
  let alive = true;
2277
2766
  let pendingWheelTop = null;
2767
+ let pendingSelectionScrollFocusRemap = false;
2278
2768
  let initializedScrollTop = false;
2279
2769
  let lastLineCount = 0;
2280
2770
  let lastFirstLineIndex = 0;
@@ -2287,7 +2777,7 @@ var TLogView = (0, import_vue8.defineComponent)({
2287
2777
  const ansiRowCache = /* @__PURE__ */ new Map();
2288
2778
  const searchLineCache = /* @__PURE__ */ new Map();
2289
2779
  const visibleLinksByRow = /* @__PURE__ */ new Map();
2290
- const focusedVisibleLinkIndex = (0, import_vue8.ref)(-1);
2780
+ const focusedVisibleLinkIndex = (0, import_vue9.ref)(-1);
2291
2781
  let focusedLinkTarget = null;
2292
2782
  let searchGeneration = 0;
2293
2783
  let searchCursor = 0;
@@ -2320,11 +2810,11 @@ var TLogView = (0, import_vue8.defineComponent)({
2320
2810
  let measuredLineCount = 0;
2321
2811
  let measuredVisualRows = 0;
2322
2812
  let lastVisualIndexPayloadKey = "";
2323
- const fullRect = (0, import_vue8.computed)(() => {
2813
+ const fullRect = (0, import_vue9.computed)(() => {
2324
2814
  const raw = { x: props.x, y: props.y, w: props.w, h: props.h };
2325
2815
  return translateRect(raw, layout.originX, layout.originY);
2326
2816
  });
2327
- const absRect = (0, import_vue8.computed)(() => {
2817
+ const absRect = (0, import_vue9.computed)(() => {
2328
2818
  const translated = fullRect.value;
2329
2819
  if (!layout.clipRect)
2330
2820
  return translated;
@@ -2360,13 +2850,11 @@ var TLogView = (0, import_vue8.defineComponent)({
2360
2850
  return Number.isFinite(n) ? Math.max(0, n) : 0;
2361
2851
  }
2362
2852
  function firstLineIndex() {
2363
- var _a, _b;
2364
- const n = Math.floor(Number(((_b = (_a = props.source).firstLineIndex) == null ? void 0 : _b.call(_a)) ?? 0));
2853
+ const n = Math.floor(Number(props.source.firstLineIndex?.() ?? 0));
2365
2854
  return Number.isFinite(n) ? Math.max(0, n) : 0;
2366
2855
  }
2367
2856
  function lineKey(index) {
2368
- var _a, _b;
2369
- return ((_b = (_a = props.source).getLineKey) == null ? void 0 : _b.call(_a, index)) ?? `v:${props.version}:i:${index}`;
2857
+ return props.source.getLineKey?.(index) ?? `v:${props.version}:i:${index}`;
2370
2858
  }
2371
2859
  function renderCacheKey(key, fullW, clipX, visibleW) {
2372
2860
  return JSON.stringify([key, fullW, clipX, visibleW]);
@@ -2632,49 +3120,43 @@ var TLogView = (0, import_vue8.defineComponent)({
2632
3120
  return query.trim() ? query : "";
2633
3121
  }
2634
3122
  function maxSearchMatches() {
2635
- var _a;
2636
- const n = Math.floor(Number(((_a = props.searchOptions) == null ? void 0 : _a.maxMatches) ?? DEFAULT_SEARCH_MAX_MATCHES));
3123
+ const n = Math.floor(Number(props.searchOptions?.maxMatches ?? DEFAULT_SEARCH_MAX_MATCHES));
2637
3124
  if (!Number.isFinite(n))
2638
3125
  return DEFAULT_SEARCH_MAX_MATCHES;
2639
3126
  return Math.max(0, n);
2640
3127
  }
2641
3128
  function searchScanBudgetMs() {
2642
- var _a;
2643
- const n = Number(((_a = props.searchOptions) == null ? void 0 : _a.scanBudgetMs) ?? DEFAULT_SEARCH_SCAN_BUDGET_MS);
3129
+ const n = Number(props.searchOptions?.scanBudgetMs ?? DEFAULT_SEARCH_SCAN_BUDGET_MS);
2644
3130
  if (!Number.isFinite(n))
2645
3131
  return DEFAULT_SEARCH_SCAN_BUDGET_MS;
2646
3132
  return Math.max(0, n);
2647
3133
  }
2648
3134
  function searchMode() {
2649
- var _a;
2650
- return ((_a = props.searchOptions) == null ? void 0 : _a.mode) === "regex" ? "regex" : "text";
3135
+ return props.searchOptions?.mode === "regex" ? "regex" : "text";
2651
3136
  }
2652
3137
  function normalizedMaxMatchesPerLine() {
2653
- var _a;
2654
3138
  const n = Math.floor(
2655
- Number(((_a = props.searchOptions) == null ? void 0 : _a.maxMatchesPerLine) ?? DEFAULT_SEARCH_MAX_MATCHES_PER_LINE)
3139
+ Number(props.searchOptions?.maxMatchesPerLine ?? DEFAULT_SEARCH_MAX_MATCHES_PER_LINE)
2656
3140
  );
2657
3141
  if (!Number.isFinite(n))
2658
3142
  return DEFAULT_SEARCH_MAX_MATCHES_PER_LINE;
2659
3143
  return Math.max(0, n);
2660
3144
  }
2661
3145
  function normalizeRegexFlags() {
2662
- var _a, _b;
2663
3146
  const flags = /* @__PURE__ */ new Set();
2664
- for (const ch of ((_a = props.searchOptions) == null ? void 0 : _a.regexFlags) ?? "") {
3147
+ for (const ch of props.searchOptions?.regexFlags ?? "") {
2665
3148
  if (ch === "g" || ch === "y")
2666
3149
  continue;
2667
3150
  flags.add(ch);
2668
3151
  }
2669
- if (((_b = props.searchOptions) == null ? void 0 : _b.caseSensitive) !== true)
3152
+ if (props.searchOptions?.caseSensitive !== true)
2670
3153
  flags.add("i");
2671
3154
  flags.add("g");
2672
3155
  return Array.from(flags).join("");
2673
3156
  }
2674
3157
  function compileTextSearch(query) {
2675
- var _a, _b;
2676
- const caseSensitive = ((_a = props.searchOptions) == null ? void 0 : _a.caseSensitive) === true;
2677
- const wholeWord = ((_b = props.searchOptions) == null ? void 0 : _b.wholeWord) === true;
3158
+ const caseSensitive = props.searchOptions?.caseSensitive === true;
3159
+ const wholeWord = props.searchOptions?.wholeWord === true;
2678
3160
  const haystackQuery = caseSensitive ? query : query.toLowerCase();
2679
3161
  return {
2680
3162
  key: JSON.stringify(["text", query, caseSensitive ? 1 : 0, wholeWord ? 1 : 0]),
@@ -3076,7 +3558,7 @@ var TLogView = (0, import_vue8.defineComponent)({
3076
3558
  if (!props.highlightMatches || !searchMatches.length)
3077
3559
  return segments;
3078
3560
  const lineMatches = matchesByLine.get(lineIndex);
3079
- if (!(lineMatches == null ? void 0 : lineMatches.length))
3561
+ if (!lineMatches?.length)
3080
3562
  return segments;
3081
3563
  const out = [];
3082
3564
  let cursor = visibleStartCell;
@@ -3160,15 +3642,13 @@ var TLogView = (0, import_vue8.defineComponent)({
3160
3642
  return Math.max(1, normalizedFullRect().w);
3161
3643
  }
3162
3644
  function visualIndexMeasureBudgetMs() {
3163
- var _a;
3164
- const raw = Number((_a = props.visualIndexOptions) == null ? void 0 : _a.measureBudgetMs);
3645
+ const raw = Number(props.visualIndexOptions?.measureBudgetMs);
3165
3646
  if (!Number.isFinite(raw))
3166
3647
  return DEFAULT_VISUAL_INDEX_MEASURE_BUDGET_MS;
3167
3648
  return Math.max(0, raw);
3168
3649
  }
3169
3650
  function visualIndexMaxMeasuredLines(count = lineCount()) {
3170
- var _a;
3171
- const raw = (_a = props.visualIndexOptions) == null ? void 0 : _a.maxMeasuredLines;
3651
+ const raw = props.visualIndexOptions?.maxMeasuredLines;
3172
3652
  if (raw == null)
3173
3653
  return count;
3174
3654
  const n = Math.floor(Number(raw));
@@ -3639,7 +4119,7 @@ var TLogView = (0, import_vue8.defineComponent)({
3639
4119
  const href = seg.style.href;
3640
4120
  if (href) {
3641
4121
  const previous = rowLinks[rowLinks.length - 1];
3642
- if ((previous == null ? void 0 : previous.href) === href && previous.endX === x && previous.endCell === cell && previous.index === lineIndex) {
4122
+ if (previous?.href === href && previous.endX === x && previous.endCell === cell && previous.index === lineIndex) {
3643
4123
  rowLinks[rowLinks.length - 1] = {
3644
4124
  ...previous,
3645
4125
  endX: x + seg.cells,
@@ -3690,7 +4170,7 @@ var TLogView = (0, import_vue8.defineComponent)({
3690
4170
  return out;
3691
4171
  }
3692
4172
  function focusedLinkMatches(link) {
3693
- return (focusedLinkTarget == null ? void 0 : focusedLinkTarget.href) === link.href && focusedLinkTarget.absoluteLineIndex === link.absoluteLineIndex && focusedLinkTarget.index === link.index && focusedLinkTarget.startCell === link.startCell && focusedLinkTarget.endCell === link.endCell;
4173
+ return focusedLinkTarget?.href === link.href && focusedLinkTarget.absoluteLineIndex === link.absoluteLineIndex && focusedLinkTarget.index === link.index && focusedLinkTarget.startCell === link.startCell && focusedLinkTarget.endCell === link.endCell;
3694
4174
  }
3695
4175
  function emitLinkFocusPayload(link, focusedLinkIndex) {
3696
4176
  emit("linkFocus", {
@@ -3783,11 +4263,10 @@ var TLogView = (0, import_vue8.defineComponent)({
3783
4263
  clearLinkFocus();
3784
4264
  }
3785
4265
  function emitLinkClick(e) {
3786
- var _a, _b;
3787
- const link = (_a = visibleLinksByRow.get(e.cellY)) == null ? void 0 : _a.find((candidate) => e.cellX >= candidate.startX && e.cellX < candidate.endX);
4266
+ const link = visibleLinksByRow.get(e.cellY)?.find((candidate) => e.cellX >= candidate.startX && e.cellX < candidate.endX);
3788
4267
  if (!link)
3789
4268
  return;
3790
- (_b = e.preventDefault) == null ? void 0 : _b.call(e);
4269
+ e.preventDefault?.();
3791
4270
  emit("linkClick", {
3792
4271
  href: link.href,
3793
4272
  text: link.text,
@@ -3819,6 +4298,7 @@ var TLogView = (0, import_vue8.defineComponent)({
3819
4298
  resetWheelScrollState(wheelState);
3820
4299
  return;
3821
4300
  }
4301
+ selection.refresh();
3822
4302
  ctx.invalidate({ priority: "high", plane: plane.value, reason: "scroll" });
3823
4303
  }
3824
4304
  });
@@ -3857,14 +4337,14 @@ var TLogView = (0, import_vue8.defineComponent)({
3857
4337
  if (delta > 0) {
3858
4338
  for (let y = y0; y < y1 - delta; y++) {
3859
4339
  const links = visibleLinksByRow.get(y + delta);
3860
- if (links == null ? void 0 : links.length)
4340
+ if (links?.length)
3861
4341
  next.set(y, links);
3862
4342
  }
3863
4343
  } else {
3864
4344
  const n = -delta;
3865
4345
  for (let y = y0 + n; y < y1; y++) {
3866
4346
  const links = visibleLinksByRow.get(y + delta);
3867
- if (links == null ? void 0 : links.length)
4347
+ if (links?.length)
3868
4348
  next.set(y, links);
3869
4349
  }
3870
4350
  }
@@ -3880,7 +4360,7 @@ var TLogView = (0, import_vue8.defineComponent)({
3880
4360
  return rows;
3881
4361
  }
3882
4362
  function unionDirtyRows(nextRows) {
3883
- if (!(dirtyRowsHint == null ? void 0 : dirtyRowsHint.length))
4363
+ if (!dirtyRowsHint?.length)
3884
4364
  return nextRows.slice().sort((a, b) => a - b);
3885
4365
  const rows = new Set(dirtyRowsHint);
3886
4366
  for (const y of nextRows)
@@ -3982,58 +4462,57 @@ var TLogView = (0, import_vue8.defineComponent)({
3982
4462
  return null;
3983
4463
  if (prevCount <= 0 || nextCount <= prevCount)
3984
4464
  return null;
3985
- if ((lastPaintedBottom == null ? void 0 : lastPaintedBottom.index) !== prevCount - 1)
4465
+ if (lastPaintedBottom?.index !== prevCount - 1)
3986
4466
  return null;
3987
4467
  if (lineKey(prevCount - 1) === lastPaintedBottom.lineKey)
3988
4468
  return null;
3989
4469
  return r.y + r.h - delta - 1;
3990
4470
  }
3991
4471
  function applyScrollTop(nextTop, strategy = "auto", options) {
3992
- var _a;
3993
4472
  const r = normalizedRect();
3994
4473
  const full = normalizedFullRect();
3995
4474
  const h11 = r.h;
3996
4475
  if (h11 <= 0 || full.h <= 0)
3997
4476
  return false;
3998
- if ((options == null ? void 0 : options.stickToBottom) === true && props.wrap)
4477
+ if (options?.stickToBottom === true && props.wrap)
3999
4478
  ensureBottomMeasured();
4000
4479
  const prevTop = rawScrollTop();
4001
4480
  const clampedTop = normalizeScrollTop(nextTop);
4002
4481
  const delta = clampedTop - prevTop;
4003
4482
  if (!delta) {
4004
- if ((options == null ? void 0 : options.stickToBottom) != null)
4483
+ if (options?.stickToBottom != null)
4005
4484
  stickToBottom.value = options.stickToBottom;
4006
4485
  return false;
4007
4486
  }
4008
4487
  const uncontrolled = !isScrollControlled();
4009
4488
  if (uncontrolled) {
4010
4489
  innerScrollTop.value = clampedTop;
4011
- stickToBottom.value = (options == null ? void 0 : options.stickToBottom) ?? isAtBottom(clampedTop);
4490
+ stickToBottom.value = options?.stickToBottom ?? isAtBottom(clampedTop);
4012
4491
  }
4013
- if ((options == null ? void 0 : options.emitUpdate) !== false)
4492
+ if (options?.emitUpdate !== false)
4014
4493
  emit("update:scrollTop", clampedTop);
4015
4494
  if (!uncontrolled) {
4016
4495
  markViewportDirty();
4017
- if (options == null ? void 0 : options.emitScroll)
4496
+ if (options?.emitScroll)
4018
4497
  emitScroll(clampedTop);
4019
4498
  return true;
4020
4499
  }
4021
4500
  const size = terminal.size();
4022
4501
  const ownsFullRows = Math.floor(r.x) === 0 && Math.floor(r.w) >= size.cols;
4023
4502
  const withinTerminalRows = r.y >= 0 && r.y + h11 <= size.rows;
4024
- const canUseScrollPlane = strategy === "auto" && props.rowScrollMode === "unsafe-full-row" && rendererCapabilities.value.scrollOperations && !props.wrap && ownsFullRows && withinTerminalRows && !isClipped() && Math.abs(delta) < h11 && !(dirtyRowsHint == null ? void 0 : dirtyRowsHint.length);
4503
+ const canUseScrollPlane = strategy === "auto" && props.rowScrollMode === "unsafe-full-row" && rendererCapabilities.value.scrollOperations && !props.wrap && ownsFullRows && withinTerminalRows && !isClipped() && Math.abs(delta) < h11 && !dirtyRowsHint?.length;
4025
4504
  if (canUseScrollPlane) {
4026
4505
  render.unsafeScrollPlaneRows(plane.value, r.y, r.y + h11, delta);
4027
4506
  shiftVisibleLinksForScrollRegion(r.y, r.y + h11, delta);
4028
4507
  markRowsDirty(
4029
- ((_a = options == null ? void 0 : options.extraDirtyRows) == null ? void 0 : _a.length) ? [...exposedRowsForDelta(r.y, h11, delta), ...options.extraDirtyRows] : exposedRowsForDelta(r.y, h11, delta)
4508
+ options?.extraDirtyRows?.length ? [...exposedRowsForDelta(r.y, h11, delta), ...options.extraDirtyRows] : exposedRowsForDelta(r.y, h11, delta)
4030
4509
  );
4031
- if (options == null ? void 0 : options.emitScroll)
4510
+ if (options?.emitScroll)
4032
4511
  emitScroll(clampedTop);
4033
4512
  return true;
4034
4513
  }
4035
4514
  markViewportDirty();
4036
- if (options == null ? void 0 : options.emitScroll)
4515
+ if (options?.emitScroll)
4037
4516
  emitScroll(clampedTop);
4038
4517
  return true;
4039
4518
  }
@@ -4058,7 +4537,7 @@ var TLogView = (0, import_vue8.defineComponent)({
4058
4537
  }
4059
4538
  function handleSourceVersionChanged(payload) {
4060
4539
  const prevCount = lastLineCount;
4061
- const nextCount = (payload == null ? void 0 : payload.lineCount) ?? lineCount();
4540
+ const nextCount = payload?.lineCount ?? lineCount();
4062
4541
  const prevFirst = lastFirstLineIndex;
4063
4542
  const nextFirst = firstLineIndex();
4064
4543
  const droppedHeadLines = Math.max(0, nextFirst - prevFirst);
@@ -4099,6 +4578,8 @@ var TLogView = (0, import_vue8.defineComponent)({
4099
4578
  emitScroll: true,
4100
4579
  stickToBottom: false
4101
4580
  });
4581
+ if (changed)
4582
+ selection.refresh();
4102
4583
  if (!changed)
4103
4584
  markViewportDirty();
4104
4585
  resumeVisualMeasurement();
@@ -4110,6 +4591,8 @@ var TLogView = (0, import_vue8.defineComponent)({
4110
4591
  emitScroll: true,
4111
4592
  stickToBottom: stickToBottom.value && nextTop >= maxScrollTop()
4112
4593
  });
4594
+ if (changed)
4595
+ selection.refresh();
4113
4596
  if (!changed)
4114
4597
  markViewportDirty();
4115
4598
  resumeVisualMeasurement();
@@ -4130,6 +4613,8 @@ var TLogView = (0, import_vue8.defineComponent)({
4130
4613
  extraDirtyRows: extraDirtyRow == null ? void 0 : [extraDirtyRow]
4131
4614
  }
4132
4615
  );
4616
+ if (changed)
4617
+ selection.refresh();
4133
4618
  if (!changed) {
4134
4619
  if (sameCountTailDirtyRows.length)
4135
4620
  markRowsDirty(sameCountTailDirtyRows);
@@ -4152,6 +4637,8 @@ var TLogView = (0, import_vue8.defineComponent)({
4152
4637
  emitScroll: true,
4153
4638
  stickToBottom: isAtBottom()
4154
4639
  });
4640
+ if (changed)
4641
+ selection.refresh();
4155
4642
  if (!changed)
4156
4643
  markViewportDirty();
4157
4644
  resumeVisualMeasurement();
@@ -4242,8 +4729,10 @@ var TLogView = (0, import_vue8.defineComponent)({
4242
4729
  });
4243
4730
  if (!changed && nextStick != null)
4244
4731
  stickToBottom.value = nextStick;
4245
- if (changed)
4732
+ if (changed) {
4733
+ selection.refresh();
4246
4734
  invalidateSelf("high", "input");
4735
+ }
4247
4736
  }
4248
4737
  function scrollToBottom() {
4249
4738
  cancelWheelScrollFrame();
@@ -4251,8 +4740,10 @@ var TLogView = (0, import_vue8.defineComponent)({
4251
4740
  emitScroll: true,
4252
4741
  stickToBottom: true
4253
4742
  });
4254
- if (changed)
4743
+ if (changed) {
4744
+ selection.refresh();
4255
4745
  invalidateSelf("high", "scroll");
4746
+ }
4256
4747
  }
4257
4748
  function scrollToTop() {
4258
4749
  cancelWheelScrollFrame();
@@ -4260,8 +4751,10 @@ var TLogView = (0, import_vue8.defineComponent)({
4260
4751
  emitScroll: true,
4261
4752
  stickToBottom: false
4262
4753
  });
4263
- if (changed)
4754
+ if (changed) {
4755
+ selection.refresh();
4264
4756
  invalidateSelf("high", "scroll");
4757
+ }
4265
4758
  }
4266
4759
  function scrollToVisualRow(row) {
4267
4760
  cancelWheelScrollFrame();
@@ -4270,13 +4763,126 @@ var TLogView = (0, import_vue8.defineComponent)({
4270
4763
  emitScroll: true,
4271
4764
  stickToBottom: target >= maxScrollTop()
4272
4765
  });
4273
- if (changed)
4766
+ if (changed) {
4767
+ selection.refresh();
4274
4768
  invalidateSelf("high", "scroll");
4769
+ }
4275
4770
  }
4276
4771
  function scrollBy(delta) {
4277
4772
  const n = Math.trunc(Number(delta));
4278
4773
  scrollToVisualRow(currentScrollTop() + (Number.isFinite(n) ? n : 0));
4279
4774
  }
4775
+ function scrollSelectionBy(delta) {
4776
+ const n = Math.trunc(Number(delta));
4777
+ if (!Number.isFinite(n) || n === 0)
4778
+ return false;
4779
+ cancelWheelScrollFrame();
4780
+ if (isScrollControlled()) {
4781
+ const target2 = currentScrollTop() + n;
4782
+ const clampedTop = normalizeScrollTop(target2);
4783
+ if (clampedTop === currentScrollTop())
4784
+ return false;
4785
+ if (pendingSelectionScrollFocusRemap)
4786
+ return false;
4787
+ pendingSelectionScrollFocusRemap = true;
4788
+ emit("update:scrollTop", clampedTop);
4789
+ emit("scroll", scrollPayload(clampedTop));
4790
+ invalidateSelf("high", "scroll");
4791
+ return true;
4792
+ }
4793
+ const target = currentScrollTop() + n;
4794
+ const changed = applyScrollTop(target, "viewport-repaint", {
4795
+ emitScroll: true,
4796
+ stickToBottom: target >= maxScrollTop()
4797
+ });
4798
+ if (!changed)
4799
+ return false;
4800
+ selection.refresh({ remapFocus: true });
4801
+ invalidateSelf("high", "scroll");
4802
+ return true;
4803
+ }
4804
+ function selectionPointForCell(point) {
4805
+ const r = normalizedRect();
4806
+ if (point.x < r.x || point.y < r.y || point.x >= r.x + r.w || point.y >= r.y + r.h) {
4807
+ return null;
4808
+ }
4809
+ const { x: clipX, y: clipY } = clipOffsets();
4810
+ const visualY = currentScrollTop() + clipY + (point.y - r.y);
4811
+ if (visualY < 0 || visualY >= estimatedVisualRowCount())
4812
+ return null;
4813
+ return {
4814
+ x: clamp3(clipX + (point.x - r.x), 0, Math.max(0, currentWrapWidth() - 1)),
4815
+ y: visualY
4816
+ };
4817
+ }
4818
+ function canHandleSelectionRange(range) {
4819
+ return Boolean(selectionPointForCell(range.anchor) && selectionPointForCell(range.focus));
4820
+ }
4821
+ function textForVisualRow(visualRow) {
4822
+ const count = lineCount();
4823
+ if (!props.wrap) {
4824
+ if (visualRow < 0 || visualRow >= count)
4825
+ return "";
4826
+ if (!props.ansi)
4827
+ return sanitizeInlineText(props.source.getLine(visualRow));
4828
+ const base2 = props.style ?? defaultStyle.value;
4829
+ return ansiSegmentsForLine(visualRow, count, base2, styleCacheKey(base2)).map((segment) => segment.text).join("");
4830
+ }
4831
+ const located = locateVisualRow(visualRow);
4832
+ if (!located)
4833
+ return "";
4834
+ if (!props.ansi) {
4835
+ return wrappedRowsForLine(located.lineIndex, count, currentWrapWidth())[located.partIndex] ?? "";
4836
+ }
4837
+ const base = props.style ?? defaultStyle.value;
4838
+ const rows = ansiWrappedRowsForLine(
4839
+ located.lineIndex,
4840
+ count,
4841
+ currentWrapWidth(),
4842
+ base,
4843
+ styleCacheKey(base)
4844
+ );
4845
+ return (rows[located.partIndex] ?? []).map((segment) => segment.text).join("");
4846
+ }
4847
+ function textForSelectionRange(range) {
4848
+ const cols = currentWrapWidth();
4849
+ const rows = estimatedVisualRowCount();
4850
+ return terminalSelectionRowSpans(range, cols, rows).map((span) => {
4851
+ const text = sliceByCellsRange(textForVisualRow(span.y), span.x0, span.x1);
4852
+ return span.x1 >= cols ? text.trimEnd() : text;
4853
+ }).join("\n");
4854
+ }
4855
+ function visibleSpansForSelectionRange(providerRange, _screenRange) {
4856
+ const r = normalizedRect();
4857
+ const { x: clipX, y: clipY } = clipOffsets();
4858
+ const cols = currentWrapWidth();
4859
+ const totalRows = Math.max(
4860
+ estimatedVisualRowCount(),
4861
+ providerRange.anchor.y + 1,
4862
+ providerRange.focus.y + 1
4863
+ );
4864
+ const top = currentScrollTop() + clipY;
4865
+ const bottom = top + r.h;
4866
+ const providerSpans = terminalSelectionVisibleRowSpans(
4867
+ providerRange,
4868
+ cols,
4869
+ totalRows,
4870
+ top,
4871
+ bottom
4872
+ );
4873
+ const result = [];
4874
+ for (const span of providerSpans) {
4875
+ const screenY = r.y + (span.y - top);
4876
+ const screenX0 = r.x + span.x0 - clipX;
4877
+ const screenX1 = r.x + span.x1 - clipX;
4878
+ const x0 = Math.max(r.x, screenX0);
4879
+ const x1 = Math.min(r.x + r.w, screenX1);
4880
+ if (screenY >= r.y && screenY < r.y + r.h && x1 > x0) {
4881
+ result.push({ y: screenY, x0, x1 });
4882
+ }
4883
+ }
4884
+ return result;
4885
+ }
4280
4886
  function scrollToLine(index, options) {
4281
4887
  const count = lineCount();
4282
4888
  if (count <= 0)
@@ -4291,9 +4897,9 @@ var TLogView = (0, import_vue8.defineComponent)({
4291
4897
  visualCount = visualCounts[lineIndex] ?? 1;
4292
4898
  }
4293
4899
  const h11 = viewportHeight();
4294
- if ((options == null ? void 0 : options.align) === "center") {
4900
+ if (options?.align === "center") {
4295
4901
  target -= Math.floor((h11 - visualCount) / 2);
4296
- } else if ((options == null ? void 0 : options.align) === "end") {
4902
+ } else if (options?.align === "end") {
4297
4903
  target += visualCount - h11;
4298
4904
  }
4299
4905
  scrollToVisualRow(target);
@@ -4304,6 +4910,8 @@ var TLogView = (0, import_vue8.defineComponent)({
4304
4910
  emitScroll: true,
4305
4911
  stickToBottom: stickToBottom.value && nextTop >= maxScrollTop()
4306
4912
  });
4913
+ if (changed)
4914
+ selection.refresh();
4307
4915
  if (!changed)
4308
4916
  markViewportDirty();
4309
4917
  invalidateSelf("normal", "data");
@@ -4376,7 +4984,7 @@ var TLogView = (0, import_vue8.defineComponent)({
4376
4984
  return index2 >= 0 ? index2 : 0;
4377
4985
  }
4378
4986
  const located = locateVisualRow(visibleLineRange().start);
4379
- const firstVisibleLine = (located == null ? void 0 : located.lineIndex) ?? 0;
4987
+ const firstVisibleLine = located?.lineIndex ?? 0;
4380
4988
  const index = searchMatches.findIndex((match) => match.index >= firstVisibleLine);
4381
4989
  return index >= 0 ? index : 0;
4382
4990
  }
@@ -4392,7 +5000,7 @@ var TLogView = (0, import_vue8.defineComponent)({
4392
5000
  return searchMatches.length - 1;
4393
5001
  }
4394
5002
  const located = locateVisualRow(Math.max(0, visibleLineRange().end - 1));
4395
- const lastVisibleLine = (located == null ? void 0 : located.lineIndex) ?? lineCount() - 1;
5003
+ const lastVisibleLine = located?.lineIndex ?? lineCount() - 1;
4396
5004
  for (let i = searchMatches.length - 1; i >= 0; i--) {
4397
5005
  if (searchMatches[i].index <= lastVisibleLine)
4398
5006
  return i;
@@ -4420,8 +5028,8 @@ var TLogView = (0, import_vue8.defineComponent)({
4420
5028
  emitSearchMatch();
4421
5029
  invalidateSearchMarkers();
4422
5030
  emitSearchMarkers(true);
4423
- if ((options == null ? void 0 : options.scroll) !== false) {
4424
- scrollToMatch(searchMatches[index], (options == null ? void 0 : options.align) ?? "center");
5031
+ if (options?.scroll !== false) {
5032
+ scrollToMatch(searchMatches[index], options?.align ?? "center");
4425
5033
  }
4426
5034
  markViewportDirty();
4427
5035
  invalidateSelf("high", "data");
@@ -4445,11 +5053,11 @@ var TLogView = (0, import_vue8.defineComponent)({
4445
5053
  return match ? copySearchMatch(match) : null;
4446
5054
  }
4447
5055
  function getSearchResults(options) {
4448
- const rawOffset = Number((options == null ? void 0 : options.offset) ?? 0);
4449
- const rawLimit = Number((options == null ? void 0 : options.limit) ?? searchMatches.length);
5056
+ const rawOffset = Number(options?.offset ?? 0);
5057
+ const rawLimit = Number(options?.limit ?? searchMatches.length);
4450
5058
  const offset = Number.isFinite(rawOffset) ? Math.max(0, Math.floor(rawOffset)) : 0;
4451
5059
  const limit = Number.isFinite(rawLimit) ? Math.max(0, Math.floor(rawLimit)) : searchMatches.length;
4452
- const includePreview = (options == null ? void 0 : options.includePreview) === true;
5060
+ const includePreview = options?.includePreview === true;
4453
5061
  if (!includePreview) {
4454
5062
  return searchMatches.slice(offset, offset + limit).map((match, index) => ({
4455
5063
  matchIndex: offset + index,
@@ -4459,8 +5067,8 @@ var TLogView = (0, import_vue8.defineComponent)({
4459
5067
  const count = lineCount();
4460
5068
  const base = props.style ?? defaultStyle.value;
4461
5069
  const baseStyleKey = styleCacheKey(base);
4462
- const previewWidth = normalizeSearchResultPreviewWidth(options == null ? void 0 : options.previewWidth);
4463
- const contextCells = normalizeSearchResultContextCells(options == null ? void 0 : options.contextCells);
5070
+ const previewWidth = normalizeSearchResultPreviewWidth(options?.previewWidth);
5071
+ const contextCells = normalizeSearchResultContextCells(options?.contextCells);
4464
5072
  return searchMatches.slice(offset, offset + limit).map((match, index) => ({
4465
5073
  matchIndex: offset + index,
4466
5074
  match: copySearchMatch(match),
@@ -4586,14 +5194,27 @@ var TLogView = (0, import_vue8.defineComponent)({
4586
5194
  keyboardScroll(bottomScrollTop(), true);
4587
5195
  }
4588
5196
  }
5197
+ const selectionTextProvider = {
5198
+ id: `${frameTaskId}:selection-text`,
5199
+ get rect() {
5200
+ return normalizedRect();
5201
+ },
5202
+ canHandle: canHandleSelectionRange,
5203
+ pointForCell: selectionPointForCell,
5204
+ getText: textForSelectionRange,
5205
+ getVisibleSpans: visibleSpansForSelectionRange
5206
+ };
5207
+ const unregisterSelectionTextProvider = selection.registerTextProvider(selectionTextProvider);
5208
+ (0, import_vue9.onBeforeUnmount)(unregisterSelectionTextProvider);
4589
5209
  const eventNode = useTerminalNode(() => ({
4590
5210
  rect: normalizedRect(),
4591
5211
  zIndex: eventZ.value,
4592
5212
  visible: visible.value,
4593
5213
  focusable: true,
5214
+ selectable: props.selectable,
5215
+ selectionScrollBy: scrollSelectionBy,
4594
5216
  handlers: {
4595
5217
  wheel: (e) => {
4596
- var _a;
4597
5218
  const { deltaY, mode } = getWheelScrollInput2(e);
4598
5219
  if (!deltaY)
4599
5220
  return;
@@ -4615,7 +5236,7 @@ var TLogView = (0, import_vue8.defineComponent)({
4615
5236
  return;
4616
5237
  if (!requestWheelScroll(nextTop))
4617
5238
  return;
4618
- (_a = e.preventDefault) == null ? void 0 : _a.call(e);
5239
+ e.preventDefault?.();
4619
5240
  },
4620
5241
  focus: () => {
4621
5242
  focused.value = true;
@@ -4631,7 +5252,7 @@ var TLogView = (0, import_vue8.defineComponent)({
4631
5252
  keydown: onKeydown
4632
5253
  }
4633
5254
  }));
4634
- (0, import_vue8.watchEffect)(() => {
5255
+ (0, import_vue9.watchEffect)(() => {
4635
5256
  if (!props.autoFocus)
4636
5257
  return;
4637
5258
  if (!visible.value)
@@ -4644,7 +5265,7 @@ var TLogView = (0, import_vue8.defineComponent)({
4644
5265
  return;
4645
5266
  manager.focus(nodeId);
4646
5267
  });
4647
- (0, import_vue8.watch)(
5268
+ (0, import_vue9.watch)(
4648
5269
  [
4649
5270
  () => visible.value,
4650
5271
  () => absRect.value.x,
@@ -4669,7 +5290,7 @@ var TLogView = (0, import_vue8.defineComponent)({
4669
5290
  }
4670
5291
  }
4671
5292
  );
4672
- (0, import_vue8.watch)(
5293
+ (0, import_vue9.watch)(
4673
5294
  () => props.version,
4674
5295
  () => {
4675
5296
  resetWheelScrollState(wheelState);
@@ -4677,7 +5298,7 @@ var TLogView = (0, import_vue8.defineComponent)({
4677
5298
  requestSearchScan();
4678
5299
  }
4679
5300
  );
4680
- (0, import_vue8.watch)(
5301
+ (0, import_vue9.watch)(
4681
5302
  () => [props.ansi, props.links],
4682
5303
  ([ansi, links]) => {
4683
5304
  if (ansi && links)
@@ -4685,28 +5306,25 @@ var TLogView = (0, import_vue8.defineComponent)({
4685
5306
  clearLinkFocus();
4686
5307
  }
4687
5308
  );
4688
- (0, import_vue8.watch)(
5309
+ (0, import_vue9.watch)(
4689
5310
  () => props.scrollTop,
4690
5311
  () => {
4691
5312
  cancelWheelScrollFrame();
4692
5313
  syncStickFromCurrentScrollTop();
5314
+ const remap = pendingSelectionScrollFocusRemap;
5315
+ pendingSelectionScrollFocusRemap = false;
5316
+ selection.refresh(remap ? { remapFocus: true } : void 0);
4693
5317
  markViewportDirty();
4694
5318
  invalidateSelf("high", "scroll");
4695
5319
  }
4696
5320
  );
4697
- (0, import_vue8.watch)(
5321
+ (0, import_vue9.watch)(
4698
5322
  [
4699
5323
  () => props.source,
4700
5324
  () => props.wrap,
4701
5325
  () => props.visualIndexMode,
4702
- () => {
4703
- var _a;
4704
- return (_a = props.visualIndexOptions) == null ? void 0 : _a.measureBudgetMs;
4705
- },
4706
- () => {
4707
- var _a;
4708
- return (_a = props.visualIndexOptions) == null ? void 0 : _a.maxMeasuredLines;
4709
- },
5326
+ () => props.visualIndexOptions?.measureBudgetMs,
5327
+ () => props.visualIndexOptions?.maxMeasuredLines,
4710
5328
  () => props.ansi,
4711
5329
  () => props.links,
4712
5330
  () => props.linkStyle,
@@ -4725,33 +5343,15 @@ var TLogView = (0, import_vue8.defineComponent)({
4725
5343
  },
4726
5344
  { immediate: true }
4727
5345
  );
4728
- (0, import_vue8.watch)(
5346
+ (0, import_vue9.watch)(
4729
5347
  [
4730
5348
  () => props.searchQuery,
4731
- () => {
4732
- var _a;
4733
- return (_a = props.searchOptions) == null ? void 0 : _a.mode;
4734
- },
4735
- () => {
4736
- var _a;
4737
- return (_a = props.searchOptions) == null ? void 0 : _a.caseSensitive;
4738
- },
4739
- () => {
4740
- var _a;
4741
- return (_a = props.searchOptions) == null ? void 0 : _a.wholeWord;
4742
- },
4743
- () => {
4744
- var _a;
4745
- return (_a = props.searchOptions) == null ? void 0 : _a.regexFlags;
4746
- },
4747
- () => {
4748
- var _a;
4749
- return (_a = props.searchOptions) == null ? void 0 : _a.maxMatchesPerLine;
4750
- },
4751
- () => {
4752
- var _a;
4753
- return (_a = props.searchOptions) == null ? void 0 : _a.maxMatches;
4754
- },
5349
+ () => props.searchOptions?.mode,
5350
+ () => props.searchOptions?.caseSensitive,
5351
+ () => props.searchOptions?.wholeWord,
5352
+ () => props.searchOptions?.regexFlags,
5353
+ () => props.searchOptions?.maxMatchesPerLine,
5354
+ () => props.searchOptions?.maxMatches,
4755
5355
  () => props.ansi,
4756
5356
  () => props.links,
4757
5357
  () => props.source
@@ -4761,14 +5361,14 @@ var TLogView = (0, import_vue8.defineComponent)({
4761
5361
  },
4762
5362
  { immediate: true }
4763
5363
  );
4764
- (0, import_vue8.watch)(
5364
+ (0, import_vue9.watch)(
4765
5365
  [() => props.highlightMatches, () => props.matchStyle, () => props.currentMatchStyle],
4766
5366
  () => {
4767
5367
  markViewportDirty();
4768
5368
  invalidateSelf("normal", "data");
4769
5369
  }
4770
5370
  );
4771
- (0, import_vue8.watch)(
5371
+ (0, import_vue9.watch)(
4772
5372
  [
4773
5373
  () => props.source,
4774
5374
  () => props.wrap,
@@ -4800,13 +5400,15 @@ var TLogView = (0, import_vue8.defineComponent)({
4800
5400
  emitUpdate: wasInitialized,
4801
5401
  stickToBottom: nextStick
4802
5402
  });
5403
+ if (changed)
5404
+ selection.refresh();
4803
5405
  if (!changed)
4804
5406
  markViewportDirty();
4805
5407
  invalidateSelf("normal", "data");
4806
5408
  },
4807
5409
  { immediate: true }
4808
5410
  );
4809
- (0, import_vue8.onBeforeUnmount)(() => {
5411
+ (0, import_vue9.onBeforeUnmount)(() => {
4810
5412
  alive = false;
4811
5413
  searchGeneration++;
4812
5414
  visualMeasureGeneration++;
@@ -4967,7 +5569,7 @@ var TLogView = (0, import_vue8.defineComponent)({
4967
5569
  terminal.write(line, { x: r.x, y, style: base });
4968
5570
  };
4969
5571
  const rows = dirtyRows;
4970
- if (rows == null ? void 0 : rows.length) {
5572
+ if (rows?.length) {
4971
5573
  for (const y of rows)
4972
5574
  paintRow(y);
4973
5575
  syncFocusedVisibleLinkFromViewport();
@@ -4988,17 +5590,17 @@ var TLogView = (0, import_vue8.defineComponent)({
4988
5590
  trimAnsiRowCache();
4989
5591
  }
4990
5592
  }));
4991
- (0, import_vue8.watchEffect)(() => {
5593
+ (0, import_vue9.watchEffect)(() => {
4992
5594
  renderNodeId = renderNode.id.value;
4993
5595
  });
4994
5596
  lastLineCount = lineCount();
4995
5597
  lastFirstLineIndex = firstLineIndex();
4996
- return () => (0, import_vue8.h)("span", rootProps);
5598
+ return () => (0, import_vue9.h)("span", rootProps);
4997
5599
  }
4998
5600
  });
4999
5601
 
5000
5602
  // src/vue/components/TLogScrollbar.ts
5001
- var import_vue9 = require("vue");
5603
+ var import_vue10 = require("vue");
5002
5604
  var EMPTY_RECT = Object.freeze({ x: 0, y: 0, w: 0, h: 0 });
5003
5605
  var SCROLLBAR_WIDTH = 1;
5004
5606
  var TRACK_CHAR = "\u2502";
@@ -5085,7 +5687,7 @@ function collectMarkersByRow(markers, metrics, height, showArrows) {
5085
5687
  function mergeStyle(base, overlay) {
5086
5688
  return overlay ? { ...base, ...overlay } : base;
5087
5689
  }
5088
- var TLogScrollbar = (0, import_vue9.defineComponent)({
5690
+ var TLogScrollbar = (0, import_vue10.defineComponent)({
5089
5691
  name: "TLogScrollbar",
5090
5692
  props: {
5091
5693
  x: { type: Number, required: true },
@@ -5120,9 +5722,9 @@ var TLogScrollbar = (0, import_vue9.defineComponent)({
5120
5722
  const { terminal, defaultStyle } = useTerminal();
5121
5723
  const parent = useLayout();
5122
5724
  const { visible, rootProps } = useVisibility();
5123
- const parentEventZ = (0, import_vue9.inject)(EventZIndexContextKey, (0, import_vue9.computed)(() => 0));
5124
- const eventZ = (0, import_vue9.computed)(() => (parentEventZ.value ?? 0) + (props.zIndex ?? 0));
5125
- const fullRect = (0, import_vue9.computed)(
5725
+ const parentEventZ = (0, import_vue10.inject)(EventZIndexContextKey, (0, import_vue10.computed)(() => 0));
5726
+ const eventZ = (0, import_vue10.computed)(() => (parentEventZ.value ?? 0) + (props.zIndex ?? 0));
5727
+ const fullRect = (0, import_vue10.computed)(
5126
5728
  () => translateRect(
5127
5729
  {
5128
5730
  x: normalizeInt(props.x),
@@ -5134,14 +5736,13 @@ var TLogScrollbar = (0, import_vue9.defineComponent)({
5134
5736
  parent.originY
5135
5737
  )
5136
5738
  );
5137
- const rect = (0, import_vue9.computed)(() => {
5739
+ const rect = (0, import_vue10.computed)(() => {
5138
5740
  const translated = fullRect.value;
5139
5741
  if (!parent.clipRect)
5140
5742
  return translated;
5141
5743
  return intersectRect(translated, parent.clipRect) ?? EMPTY_RECT;
5142
5744
  });
5143
5745
  function emitTrackScroll(e) {
5144
- var _a, _b, _c, _d;
5145
5746
  const metrics = props.metrics;
5146
5747
  if (!metrics)
5147
5748
  return;
@@ -5153,12 +5754,12 @@ var TLogScrollbar = (0, import_vue9.defineComponent)({
5153
5754
  if (arrowRows) {
5154
5755
  if (localY === 0) {
5155
5756
  emit("scrollBy", -Math.max(1, normalizeInt(metrics.viewportRows)));
5156
- (_a = e.preventDefault) == null ? void 0 : _a.call(e);
5757
+ e.preventDefault?.();
5157
5758
  return;
5158
5759
  }
5159
5760
  if (localY === full.h - 1) {
5160
5761
  emit("scrollBy", Math.max(1, normalizeInt(metrics.viewportRows)));
5161
- (_b = e.preventDefault) == null ? void 0 : _b.call(e);
5762
+ e.preventDefault?.();
5162
5763
  return;
5163
5764
  }
5164
5765
  }
@@ -5175,14 +5776,14 @@ var TLogScrollbar = (0, import_vue9.defineComponent)({
5175
5776
  cellX: e.cellX,
5176
5777
  cellY: e.cellY
5177
5778
  });
5178
- (_c = e.preventDefault) == null ? void 0 : _c.call(e);
5779
+ e.preventDefault?.();
5179
5780
  return;
5180
5781
  }
5181
5782
  const pos = clamp4(localY - trackTop, 0, trackHeight - 1);
5182
5783
  const ratio = trackHeight <= 1 ? 0 : pos / (trackHeight - 1);
5183
5784
  const target = Math.round(ratio * Math.max(0, normalizeInt(metrics.maxScrollTop)));
5184
5785
  emit("scrollTo", target);
5185
- (_d = e.preventDefault) == null ? void 0 : _d.call(e);
5786
+ e.preventDefault?.();
5186
5787
  }
5187
5788
  useTerminalNode(() => ({
5188
5789
  rect: rect.value,
@@ -5192,12 +5793,11 @@ var TLogScrollbar = (0, import_vue9.defineComponent)({
5192
5793
  handlers: {
5193
5794
  click: emitTrackScroll,
5194
5795
  wheel: (e) => {
5195
- var _a;
5196
5796
  const dir = Math.sign(Number(e.deltaY ?? 0));
5197
5797
  if (!dir)
5198
5798
  return;
5199
5799
  emit("scrollBy", dir);
5200
- (_a = e.preventDefault) == null ? void 0 : _a.call(e);
5800
+ e.preventDefault?.();
5201
5801
  }
5202
5802
  }
5203
5803
  }));
@@ -5241,7 +5841,6 @@ var TLogScrollbar = (0, import_vue9.defineComponent)({
5241
5841
  const markersByRow = props.showMarkers ? collectMarkersByRow(props.markers, props.metrics, full.h, props.showArrows) : /* @__PURE__ */ new Map();
5242
5842
  const { arrowRows } = trackGeometry(full.h, props.showArrows);
5243
5843
  const paintRow = (y) => {
5244
- var _a, _b;
5245
5844
  if (y < r.y || y >= r.y + r.h)
5246
5845
  return;
5247
5846
  const localY = y - full.y;
@@ -5261,10 +5860,10 @@ var TLogScrollbar = (0, import_vue9.defineComponent)({
5261
5860
  }
5262
5861
  }
5263
5862
  if (thumb && localY >= thumb.top && localY < thumb.top + thumb.size) {
5264
- if (((_a = props.metrics) == null ? void 0 : _a.visualIndexStatus) === "measuring") {
5863
+ if (props.metrics?.visualIndexStatus === "measuring") {
5265
5864
  char = MEASURING_THUMB_CHAR;
5266
5865
  style = measuringThumbStyle;
5267
- } else if (((_b = props.metrics) == null ? void 0 : _b.visualIndexStatus) === "estimated") {
5866
+ } else if (props.metrics?.visualIndexStatus === "estimated") {
5268
5867
  char = ESTIMATED_THUMB_CHAR;
5269
5868
  style = estimatedThumbStyle;
5270
5869
  } else {
@@ -5283,12 +5882,12 @@ var TLogScrollbar = (0, import_vue9.defineComponent)({
5283
5882
  paintRow(y);
5284
5883
  }
5285
5884
  }));
5286
- return () => (0, import_vue9.h)("span", rootProps);
5885
+ return () => (0, import_vue10.h)("span", rootProps);
5287
5886
  }
5288
5887
  });
5289
5888
 
5290
5889
  // src/vue/components/TLogMinimap.ts
5291
- var import_vue10 = require("vue");
5890
+ var import_vue11 = require("vue");
5292
5891
  var EMPTY_RECT2 = Object.freeze({ x: 0, y: 0, w: 0, h: 0 });
5293
5892
  var CURRENT_MARKER_CHAR2 = "\u25C6";
5294
5893
  var MARKER_CHAR2 = "\u2022";
@@ -5405,7 +6004,7 @@ function densityChar(value) {
5405
6004
  return DENSITY_LOW_CHAR;
5406
6005
  return " ";
5407
6006
  }
5408
- var TLogMinimap = (0, import_vue10.defineComponent)({
6007
+ var TLogMinimap = (0, import_vue11.defineComponent)({
5409
6008
  name: "TLogMinimap",
5410
6009
  props: {
5411
6010
  x: { type: Number, required: true },
@@ -5440,9 +6039,9 @@ var TLogMinimap = (0, import_vue10.defineComponent)({
5440
6039
  const { terminal, defaultStyle } = useTerminal();
5441
6040
  const parent = useLayout();
5442
6041
  const { visible, rootProps } = useVisibility();
5443
- const parentEventZ = (0, import_vue10.inject)(EventZIndexContextKey, (0, import_vue10.computed)(() => 0));
5444
- const eventZ = (0, import_vue10.computed)(() => (parentEventZ.value ?? 0) + (props.zIndex ?? 0));
5445
- const fullRect = (0, import_vue10.computed)(
6042
+ const parentEventZ = (0, import_vue11.inject)(EventZIndexContextKey, (0, import_vue11.computed)(() => 0));
6043
+ const eventZ = (0, import_vue11.computed)(() => (parentEventZ.value ?? 0) + (props.zIndex ?? 0));
6044
+ const fullRect = (0, import_vue11.computed)(
5446
6045
  () => translateRect(
5447
6046
  {
5448
6047
  x: normalizeInt2(props.x),
@@ -5454,14 +6053,13 @@ var TLogMinimap = (0, import_vue10.defineComponent)({
5454
6053
  parent.originY
5455
6054
  )
5456
6055
  );
5457
- const rect = (0, import_vue10.computed)(() => {
6056
+ const rect = (0, import_vue11.computed)(() => {
5458
6057
  const translated = fullRect.value;
5459
6058
  if (!parent.clipRect)
5460
6059
  return translated;
5461
6060
  return intersectRect(translated, parent.clipRect) ?? EMPTY_RECT2;
5462
6061
  });
5463
6062
  function onClick(e) {
5464
- var _a, _b;
5465
6063
  const metrics = props.metrics;
5466
6064
  if (!metrics)
5467
6065
  return;
@@ -5478,7 +6076,7 @@ var TLogMinimap = (0, import_vue10.defineComponent)({
5478
6076
  cellX: e.cellX,
5479
6077
  cellY: e.cellY
5480
6078
  });
5481
- (_a = e.preventDefault) == null ? void 0 : _a.call(e);
6079
+ e.preventDefault?.();
5482
6080
  return;
5483
6081
  }
5484
6082
  emit("scrollTo", {
@@ -5486,7 +6084,7 @@ var TLogMinimap = (0, import_vue10.defineComponent)({
5486
6084
  cellX: e.cellX,
5487
6085
  cellY: e.cellY
5488
6086
  });
5489
- (_b = e.preventDefault) == null ? void 0 : _b.call(e);
6087
+ e.preventDefault?.();
5490
6088
  }
5491
6089
  useTerminalNode(() => ({
5492
6090
  rect: rect.value,
@@ -5599,12 +6197,12 @@ var TLogMinimap = (0, import_vue10.defineComponent)({
5599
6197
  paintRow(y);
5600
6198
  }
5601
6199
  }));
5602
- return () => (0, import_vue10.h)("span", rootProps);
6200
+ return () => (0, import_vue11.h)("span", rootProps);
5603
6201
  }
5604
6202
  });
5605
6203
 
5606
6204
  // src/vue/components/TLogSearchBar.ts
5607
- var import_vue11 = require("vue");
6205
+ var import_vue12 = require("vue");
5608
6206
  var EMPTY_RECT3 = Object.freeze({ x: 0, y: 0, w: 0, h: 0 });
5609
6207
  var PREVIOUS_CHAR = "\u25C0";
5610
6208
  var NEXT_CHAR = "\u25B6";
@@ -5643,11 +6241,11 @@ function cellToStringIndex(text, cell) {
5643
6241
  return text.length;
5644
6242
  }
5645
6243
  function errorLabel(error) {
5646
- if ((error == null ? void 0 : error.kind) === "invalid-regex")
6244
+ if (error?.kind === "invalid-regex")
5647
6245
  return "Invalid regex";
5648
6246
  return "Search error";
5649
6247
  }
5650
- var TLogSearchBar = (0, import_vue11.defineComponent)({
6248
+ var TLogSearchBar = (0, import_vue12.defineComponent)({
5651
6249
  name: "TLogSearchBar",
5652
6250
  props: {
5653
6251
  x: { type: Number, required: true },
@@ -5701,13 +6299,13 @@ var TLogSearchBar = (0, import_vue11.defineComponent)({
5701
6299
  const { terminal, scheduler, defaultStyle, events } = useTerminal();
5702
6300
  const parent = useLayout();
5703
6301
  const { visible, rootProps } = useVisibility();
5704
- const parentEventZ = (0, import_vue11.inject)(EventZIndexContextKey, (0, import_vue11.computed)(() => 0));
5705
- const eventZ = (0, import_vue11.computed)(() => (parentEventZ.value ?? 0) + (props.zIndex ?? 0));
5706
- const focused = (0, import_vue11.ref)(false);
5707
- const cursor = (0, import_vue11.ref)(0);
5708
- const scrollCellOffset = (0, import_vue11.ref)(0);
5709
- const pendingUpdate = (0, import_vue11.ref)(null);
5710
- const fullRect = (0, import_vue11.computed)(
6302
+ const parentEventZ = (0, import_vue12.inject)(EventZIndexContextKey, (0, import_vue12.computed)(() => 0));
6303
+ const eventZ = (0, import_vue12.computed)(() => (parentEventZ.value ?? 0) + (props.zIndex ?? 0));
6304
+ const focused = (0, import_vue12.ref)(false);
6305
+ const cursor = (0, import_vue12.ref)(0);
6306
+ const scrollCellOffset = (0, import_vue12.ref)(0);
6307
+ const pendingUpdate = (0, import_vue12.ref)(null);
6308
+ const fullRect = (0, import_vue12.computed)(
5711
6309
  () => translateRect(
5712
6310
  {
5713
6311
  x: normalizeInt3(props.x),
@@ -5719,7 +6317,7 @@ var TLogSearchBar = (0, import_vue11.defineComponent)({
5719
6317
  parent.originY
5720
6318
  )
5721
6319
  );
5722
- const rect = (0, import_vue11.computed)(() => {
6320
+ const rect = (0, import_vue12.computed)(() => {
5723
6321
  const translated = fullRect.value;
5724
6322
  if (!parent.clipRect)
5725
6323
  return translated;
@@ -5748,7 +6346,7 @@ var TLogSearchBar = (0, import_vue11.defineComponent)({
5748
6346
  nextScroll = cursorCell - inputWidth + 1;
5749
6347
  scrollCellOffset.value = clamp6(nextScroll, 0, maxScroll);
5750
6348
  }
5751
- const statusText = (0, import_vue11.computed)(() => {
6349
+ const statusText = (0, import_vue12.computed)(() => {
5752
6350
  if (props.state.status === "error")
5753
6351
  return errorLabel(props.state.error);
5754
6352
  if (props.state.status === "scanning") {
@@ -5763,7 +6361,7 @@ var TLogSearchBar = (0, import_vue11.defineComponent)({
5763
6361
  const current = props.state.matchCount > 0 && props.state.currentMatchIndex >= 0 ? props.state.currentMatchIndex + 1 : 0;
5764
6362
  return `${current}/${props.state.matchCount}`;
5765
6363
  });
5766
- const rowLayout = (0, import_vue11.computed)(() => {
6364
+ const rowLayout = (0, import_vue12.computed)(() => {
5767
6365
  const width = Math.max(0, normalizeInt3(props.w));
5768
6366
  const base = props.style ?? defaultStyle.value;
5769
6367
  const toggleBase = mergeStyle3(base, props.toggleStyle);
@@ -5854,10 +6452,9 @@ var TLogSearchBar = (0, import_vue11.defineComponent)({
5854
6452
  };
5855
6453
  });
5856
6454
  function focusSelf() {
5857
- var _a;
5858
6455
  const nodeId = eventNode.id.value;
5859
6456
  if (nodeId)
5860
- (_a = events.value) == null ? void 0 : _a.focus(nodeId);
6457
+ events.value?.focus(nodeId);
5861
6458
  }
5862
6459
  function applyUpdate(next, field) {
5863
6460
  pendingUpdate.value = next;
@@ -5909,7 +6506,6 @@ var TLogSearchBar = (0, import_vue11.defineComponent)({
5909
6506
  ensureCursorVisible(nextQuery, rowLayout.value.inputWidth);
5910
6507
  }
5911
6508
  function onClick(e) {
5912
- var _a, _b;
5913
6509
  const full = fullRect.value;
5914
6510
  if (e.cellY !== full.y)
5915
6511
  return;
@@ -5929,12 +6525,12 @@ var TLogSearchBar = (0, import_vue11.defineComponent)({
5929
6525
  toggleWholeWord();
5930
6526
  else
5931
6527
  emitNavigation(hit.action);
5932
- (_a = e.preventDefault) == null ? void 0 : _a.call(e);
6528
+ e.preventDefault?.();
5933
6529
  return;
5934
6530
  }
5935
6531
  if (localX >= layout.inputStart && localX < layout.inputStart + layout.inputWidth) {
5936
6532
  setCursorFromLocalX(localX);
5937
- (_b = e.preventDefault) == null ? void 0 : _b.call(e);
6533
+ e.preventDefault?.();
5938
6534
  }
5939
6535
  }
5940
6536
  function onKeydown(e) {
@@ -6021,7 +6617,7 @@ var TLogSearchBar = (0, import_vue11.defineComponent)({
6021
6617
  );
6022
6618
  }
6023
6619
  }
6024
- (0, import_vue11.watch)(
6620
+ (0, import_vue12.watch)(
6025
6621
  () => [
6026
6622
  props.state.query,
6027
6623
  props.state.mode,
@@ -6142,7 +6738,7 @@ var TLogSearchBar = (0, import_vue11.defineComponent)({
6142
6738
  }
6143
6739
  }
6144
6740
  }));
6145
- return () => (0, import_vue11.h)(
6741
+ return () => (0, import_vue12.h)(
6146
6742
  "div",
6147
6743
  {
6148
6744
  ...rootProps,
@@ -6154,7 +6750,7 @@ var TLogSearchBar = (0, import_vue11.defineComponent)({
6154
6750
  });
6155
6751
 
6156
6752
  // src/vue/components/TLogSearchResults.ts
6157
- var import_vue12 = require("vue");
6753
+ var import_vue13 = require("vue");
6158
6754
  var EMPTY_RECT4 = Object.freeze({ x: 0, y: 0, w: 0, h: 0 });
6159
6755
  function clamp7(n, min, max) {
6160
6756
  return Math.max(min, Math.min(max, n));
@@ -6176,7 +6772,7 @@ function normalizeActiveIndex(value, count) {
6176
6772
  return -1;
6177
6773
  return clamp7(n, 0, count - 1);
6178
6774
  }
6179
- var TLogSearchResults = (0, import_vue12.defineComponent)({
6775
+ var TLogSearchResults = (0, import_vue13.defineComponent)({
6180
6776
  name: "TLogSearchResults",
6181
6777
  props: {
6182
6778
  x: { type: Number, required: true },
@@ -6210,11 +6806,11 @@ var TLogSearchResults = (0, import_vue12.defineComponent)({
6210
6806
  const { terminal, scheduler, defaultStyle, events } = useTerminal();
6211
6807
  const parent = useLayout();
6212
6808
  const { visible, rootProps } = useVisibility();
6213
- const parentEventZ = (0, import_vue12.inject)(EventZIndexContextKey, (0, import_vue12.computed)(() => 0));
6214
- const eventZ = (0, import_vue12.computed)(() => (parentEventZ.value ?? 0) + (props.zIndex ?? 0));
6215
- const focused = (0, import_vue12.ref)(false);
6216
- const internalActiveIndex = (0, import_vue12.ref)(-1);
6217
- const fullRect = (0, import_vue12.computed)(
6809
+ const parentEventZ = (0, import_vue13.inject)(EventZIndexContextKey, (0, import_vue13.computed)(() => 0));
6810
+ const eventZ = (0, import_vue13.computed)(() => (parentEventZ.value ?? 0) + (props.zIndex ?? 0));
6811
+ const focused = (0, import_vue13.ref)(false);
6812
+ const internalActiveIndex = (0, import_vue13.ref)(-1);
6813
+ const fullRect = (0, import_vue13.computed)(
6218
6814
  () => translateRect(
6219
6815
  {
6220
6816
  x: normalizeInt4(props.x),
@@ -6226,19 +6822,19 @@ var TLogSearchResults = (0, import_vue12.defineComponent)({
6226
6822
  parent.originY
6227
6823
  )
6228
6824
  );
6229
- const rect = (0, import_vue12.computed)(() => {
6825
+ const rect = (0, import_vue13.computed)(() => {
6230
6826
  const translated = fullRect.value;
6231
6827
  if (!parent.clipRect)
6232
6828
  return translated;
6233
6829
  return intersectRect(translated, parent.clipRect) ?? EMPTY_RECT4;
6234
6830
  });
6235
- const lineNumberDigits = (0, import_vue12.computed)(
6831
+ const lineNumberDigits = (0, import_vue13.computed)(
6236
6832
  () => props.showLineNumbers ? props.results.reduce(
6237
6833
  (max, result) => Math.max(max, String(result.absoluteLineIndex).length),
6238
6834
  1
6239
6835
  ) : 0
6240
6836
  );
6241
- (0, import_vue12.watch)(
6837
+ (0, import_vue13.watch)(
6242
6838
  [() => props.activeIndex, () => props.results.length],
6243
6839
  () => {
6244
6840
  internalActiveIndex.value = normalizeActiveIndex(props.activeIndex, props.results.length);
@@ -6302,7 +6898,6 @@ var TLogSearchResults = (0, import_vue12.defineComponent)({
6302
6898
  }
6303
6899
  }
6304
6900
  function onClick(e) {
6305
- var _a, _b;
6306
6901
  const full = fullRect.value;
6307
6902
  const localY = e.cellY - full.y;
6308
6903
  if (localY < 0 || localY >= full.h)
@@ -6312,10 +6907,10 @@ var TLogSearchResults = (0, import_vue12.defineComponent)({
6312
6907
  return;
6313
6908
  const nodeId = eventNode.id.value;
6314
6909
  if (props.focusable && nodeId)
6315
- (_a = events.value) == null ? void 0 : _a.focus(nodeId);
6910
+ events.value?.focus(nodeId);
6316
6911
  setActiveIndex(localY);
6317
6912
  emitSelect(localY);
6318
- (_b = e.preventDefault) == null ? void 0 : _b.call(e);
6913
+ e.preventDefault?.();
6319
6914
  }
6320
6915
  const eventNode = useTerminalNode(() => ({
6321
6916
  rect: rect.value,
@@ -6435,12 +7030,12 @@ var TLogSearchResults = (0, import_vue12.defineComponent)({
6435
7030
  }
6436
7031
  }
6437
7032
  }));
6438
- return () => (0, import_vue12.h)("span", rootProps);
7033
+ return () => (0, import_vue13.h)("span", rootProps);
6439
7034
  }
6440
7035
  });
6441
7036
 
6442
7037
  // src/vue/components/TLogSearchPager.ts
6443
- var import_vue13 = require("vue");
7038
+ var import_vue14 = require("vue");
6444
7039
  var EMPTY_RECT5 = Object.freeze({ x: 0, y: 0, w: 0, h: 0 });
6445
7040
  var PREVIOUS_CHAR2 = "\u25C0";
6446
7041
  var NEXT_CHAR2 = "\u25B6";
@@ -6458,11 +7053,11 @@ function formatCount(matchCount) {
6458
7053
  return `${matchCount} ${matchCount === 1 ? "match" : "matches"}`;
6459
7054
  }
6460
7055
  function errorLabel2(error) {
6461
- if ((error == null ? void 0 : error.kind) === "invalid-regex")
7056
+ if (error?.kind === "invalid-regex")
6462
7057
  return "Invalid regex";
6463
7058
  return "Search error";
6464
7059
  }
6465
- var TLogSearchPager = (0, import_vue13.defineComponent)({
7060
+ var TLogSearchPager = (0, import_vue14.defineComponent)({
6466
7061
  name: "TLogSearchPager",
6467
7062
  props: {
6468
7063
  x: { type: Number, required: true },
@@ -6490,10 +7085,10 @@ var TLogSearchPager = (0, import_vue13.defineComponent)({
6490
7085
  const { terminal, scheduler, defaultStyle, events } = useTerminal();
6491
7086
  const parent = useLayout();
6492
7087
  const { visible, rootProps } = useVisibility();
6493
- const parentEventZ = (0, import_vue13.inject)(EventZIndexContextKey, (0, import_vue13.computed)(() => 0));
6494
- const eventZ = (0, import_vue13.computed)(() => (parentEventZ.value ?? 0) + (props.zIndex ?? 0));
6495
- const focused = (0, import_vue13.ref)(false);
6496
- const fullRect = (0, import_vue13.computed)(
7088
+ const parentEventZ = (0, import_vue14.inject)(EventZIndexContextKey, (0, import_vue14.computed)(() => 0));
7089
+ const eventZ = (0, import_vue14.computed)(() => (parentEventZ.value ?? 0) + (props.zIndex ?? 0));
7090
+ const focused = (0, import_vue14.ref)(false);
7091
+ const fullRect = (0, import_vue14.computed)(
6497
7092
  () => translateRect(
6498
7093
  {
6499
7094
  x: normalizeInt5(props.x),
@@ -6505,14 +7100,14 @@ var TLogSearchPager = (0, import_vue13.defineComponent)({
6505
7100
  parent.originY
6506
7101
  )
6507
7102
  );
6508
- const rect = (0, import_vue13.computed)(() => {
7103
+ const rect = (0, import_vue14.computed)(() => {
6509
7104
  const translated = fullRect.value;
6510
7105
  if (!parent.clipRect)
6511
7106
  return translated;
6512
7107
  return intersectRect(translated, parent.clipRect) ?? EMPTY_RECT5;
6513
7108
  });
6514
- const viewState = (0, import_vue13.computed)(() => props.state);
6515
- const segments = (0, import_vue13.computed)(() => {
7109
+ const viewState = (0, import_vue14.computed)(() => props.state);
7110
+ const segments = (0, import_vue14.computed)(() => {
6516
7111
  const base = props.style ?? defaultStyle.value;
6517
7112
  const active = mergeStyle5(base, props.activeStyle);
6518
7113
  const disabled = mergeStyle5(base, props.disabledStyle);
@@ -6568,10 +7163,9 @@ var TLogSearchPager = (0, import_vue13.defineComponent)({
6568
7163
  scheduler.invalidate({ reason: "input" });
6569
7164
  }
6570
7165
  function focusSelf() {
6571
- var _a;
6572
7166
  const nodeId = eventNode.id.value;
6573
7167
  if (nodeId)
6574
- (_a = events.value) == null ? void 0 : _a.focus(nodeId);
7168
+ events.value?.focus(nodeId);
6575
7169
  }
6576
7170
  function actionAt(cellX) {
6577
7171
  const full = fullRect.value;
@@ -6588,7 +7182,6 @@ var TLogSearchPager = (0, import_vue13.defineComponent)({
6588
7182
  return null;
6589
7183
  }
6590
7184
  function onClick(e) {
6591
- var _a;
6592
7185
  const full = fullRect.value;
6593
7186
  if (e.cellY !== full.y)
6594
7187
  return;
@@ -6597,7 +7190,7 @@ var TLogSearchPager = (0, import_vue13.defineComponent)({
6597
7190
  if (!action)
6598
7191
  return;
6599
7192
  emitPage(action);
6600
- (_a = e.preventDefault) == null ? void 0 : _a.call(e);
7193
+ e.preventDefault?.();
6601
7194
  }
6602
7195
  function onKeydown(e) {
6603
7196
  if (e.key === "ArrowLeft" || e.key === "PageUp") {
@@ -6669,7 +7262,7 @@ var TLogSearchPager = (0, import_vue13.defineComponent)({
6669
7262
  }
6670
7263
  }
6671
7264
  }));
6672
- return () => (0, import_vue13.h)(
7265
+ return () => (0, import_vue14.h)(
6673
7266
  "div",
6674
7267
  {
6675
7268
  ...rootProps,
@@ -6681,7 +7274,7 @@ var TLogSearchPager = (0, import_vue13.defineComponent)({
6681
7274
  });
6682
7275
 
6683
7276
  // src/vue/components/TLogLinksPanel.ts
6684
- var import_vue14 = require("vue");
7277
+ var import_vue15 = require("vue");
6685
7278
  var EMPTY_RECT6 = Object.freeze({ x: 0, y: 0, w: 0, h: 0 });
6686
7279
  var EMPTY_LABEL = "No visible links";
6687
7280
  function clamp9(n, min, max) {
@@ -6704,7 +7297,7 @@ function normalizeActiveIndex2(value, count) {
6704
7297
  return -1;
6705
7298
  return clamp9(n, 0, count - 1);
6706
7299
  }
6707
- var TLogLinksPanel = (0, import_vue14.defineComponent)({
7300
+ var TLogLinksPanel = (0, import_vue15.defineComponent)({
6708
7301
  name: "TLogLinksPanel",
6709
7302
  props: {
6710
7303
  x: { type: Number, required: true },
@@ -6743,11 +7336,11 @@ var TLogLinksPanel = (0, import_vue14.defineComponent)({
6743
7336
  const { terminal, scheduler, defaultStyle, events } = useTerminal();
6744
7337
  const parent = useLayout();
6745
7338
  const { visible, rootProps } = useVisibility();
6746
- const parentEventZ = (0, import_vue14.inject)(EventZIndexContextKey, (0, import_vue14.computed)(() => 0));
6747
- const eventZ = (0, import_vue14.computed)(() => (parentEventZ.value ?? 0) + (props.zIndex ?? 0));
6748
- const focused = (0, import_vue14.ref)(false);
6749
- const internalActiveIndex = (0, import_vue14.ref)(-1);
6750
- const fullRect = (0, import_vue14.computed)(
7339
+ const parentEventZ = (0, import_vue15.inject)(EventZIndexContextKey, (0, import_vue15.computed)(() => 0));
7340
+ const eventZ = (0, import_vue15.computed)(() => (parentEventZ.value ?? 0) + (props.zIndex ?? 0));
7341
+ const focused = (0, import_vue15.ref)(false);
7342
+ const internalActiveIndex = (0, import_vue15.ref)(-1);
7343
+ const fullRect = (0, import_vue15.computed)(
6751
7344
  () => translateRect(
6752
7345
  {
6753
7346
  x: normalizeInt6(props.x),
@@ -6759,16 +7352,16 @@ var TLogLinksPanel = (0, import_vue14.defineComponent)({
6759
7352
  parent.originY
6760
7353
  )
6761
7354
  );
6762
- const rect = (0, import_vue14.computed)(() => {
7355
+ const rect = (0, import_vue15.computed)(() => {
6763
7356
  const translated = fullRect.value;
6764
7357
  if (!parent.clipRect)
6765
7358
  return translated;
6766
7359
  return intersectRect(translated, parent.clipRect) ?? EMPTY_RECT6;
6767
7360
  });
6768
- const lineNumberDigits = (0, import_vue14.computed)(
7361
+ const lineNumberDigits = (0, import_vue15.computed)(
6769
7362
  () => props.showLineNumbers ? props.links.reduce((max, link) => Math.max(max, String(link.absoluteLineIndex).length), 1) : 0
6770
7363
  );
6771
- (0, import_vue14.watch)(
7364
+ (0, import_vue15.watch)(
6772
7365
  [() => props.activeIndex, () => props.links.length],
6773
7366
  () => {
6774
7367
  internalActiveIndex.value = normalizeActiveIndex2(props.activeIndex, props.links.length);
@@ -6851,7 +7444,6 @@ var TLogLinksPanel = (0, import_vue14.defineComponent)({
6851
7444
  }
6852
7445
  }
6853
7446
  function onClick(e) {
6854
- var _a, _b;
6855
7447
  const full = fullRect.value;
6856
7448
  const localY = e.cellY - full.y;
6857
7449
  if (localY < 0 || localY >= full.h)
@@ -6861,10 +7453,10 @@ var TLogLinksPanel = (0, import_vue14.defineComponent)({
6861
7453
  return;
6862
7454
  const nodeId = eventNode.id.value;
6863
7455
  if (props.focusable && nodeId)
6864
- (_a = events.value) == null ? void 0 : _a.focus(nodeId);
7456
+ events.value?.focus(nodeId);
6865
7457
  setActiveIndex(localY);
6866
7458
  emitSelect(localY);
6867
- (_b = e.preventDefault) == null ? void 0 : _b.call(e);
7459
+ e.preventDefault?.();
6868
7460
  }
6869
7461
  const eventNode = useTerminalNode(() => ({
6870
7462
  rect: rect.value,
@@ -6980,12 +7572,12 @@ var TLogLinksPanel = (0, import_vue14.defineComponent)({
6980
7572
  }
6981
7573
  }
6982
7574
  }));
6983
- return () => (0, import_vue14.h)("span", rootProps);
7575
+ return () => (0, import_vue15.h)("span", rootProps);
6984
7576
  }
6985
7577
  });
6986
7578
 
6987
7579
  // src/vue/components/TLogVirtualSearchResults.ts
6988
- var import_vue15 = require("vue");
7580
+ var import_vue16 = require("vue");
6989
7581
  function sliceByCells2(text, start, end) {
6990
7582
  let cells = 0;
6991
7583
  let out = "";
@@ -7011,7 +7603,7 @@ function formatItem(item, width, showLineNumbers) {
7011
7603
  const formatted = `${currentPrefix}${linePrefix}${before}[${match}]${after}`;
7012
7604
  return formatted.slice(0, Math.max(0, width));
7013
7605
  }
7014
- var TLogVirtualSearchResults = (0, import_vue15.defineComponent)({
7606
+ var TLogVirtualSearchResults = (0, import_vue16.defineComponent)({
7015
7607
  name: "TLogVirtualSearchResults",
7016
7608
  props: {
7017
7609
  x: { type: Number, required: true },
@@ -7036,7 +7628,7 @@ var TLogVirtualSearchResults = (0, import_vue15.defineComponent)({
7036
7628
  },
7037
7629
  emits: ["update:modelValue", "activeChange", "select", "focus", "blur", "keydown", "scroll"],
7038
7630
  setup(props, { emit }) {
7039
- const model = (0, import_vue15.computed)({
7631
+ const model = (0, import_vue16.computed)({
7040
7632
  get: () => props.modelValue,
7041
7633
  set: (value) => {
7042
7634
  emit("update:modelValue", value);
@@ -7046,7 +7638,7 @@ var TLogVirtualSearchResults = (0, import_vue15.defineComponent)({
7046
7638
  });
7047
7639
  }
7048
7640
  });
7049
- return () => (0, import_vue15.h)(TVirtualList, {
7641
+ return () => (0, import_vue16.h)(TVirtualList, {
7050
7642
  x: props.x,
7051
7643
  y: props.y,
7052
7644
  w: props.w,
@@ -7088,7 +7680,7 @@ var TLogVirtualSearchResults = (0, import_vue15.defineComponent)({
7088
7680
  });
7089
7681
 
7090
7682
  // src/vue/components/TLogVirtualLinksPanel.ts
7091
- var import_vue16 = require("vue");
7683
+ var import_vue17 = require("vue");
7092
7684
  function formatItem2(item, width, showLineNumbers) {
7093
7685
  if (!item)
7094
7686
  return "";
@@ -7097,7 +7689,7 @@ function formatItem2(item, width, showLineNumbers) {
7097
7689
  const formatted = `${currentPrefix}${linePrefix}${item.text} -> ${item.href}`;
7098
7690
  return formatted.slice(0, Math.max(0, width));
7099
7691
  }
7100
- var TLogVirtualLinksPanel = (0, import_vue16.defineComponent)({
7692
+ var TLogVirtualLinksPanel = (0, import_vue17.defineComponent)({
7101
7693
  name: "TLogVirtualLinksPanel",
7102
7694
  props: {
7103
7695
  x: { type: Number, required: true },
@@ -7129,7 +7721,7 @@ var TLogVirtualLinksPanel = (0, import_vue16.defineComponent)({
7129
7721
  "scroll"
7130
7722
  ],
7131
7723
  setup(props, { emit }) {
7132
- const model = (0, import_vue16.computed)({
7724
+ const model = (0, import_vue17.computed)({
7133
7725
  get: () => props.modelValue,
7134
7726
  set: (value) => {
7135
7727
  emit("update:modelValue", value);
@@ -7139,7 +7731,7 @@ var TLogVirtualLinksPanel = (0, import_vue16.defineComponent)({
7139
7731
  });
7140
7732
  }
7141
7733
  });
7142
- return () => (0, import_vue16.h)(TVirtualList, {
7734
+ return () => (0, import_vue17.h)(TVirtualList, {
7143
7735
  x: props.x,
7144
7736
  y: props.y,
7145
7737
  w: props.w,
@@ -7181,7 +7773,7 @@ var TLogVirtualLinksPanel = (0, import_vue16.defineComponent)({
7181
7773
  });
7182
7774
 
7183
7775
  // src/vue/log/append-only-log-store.ts
7184
- var import_vue17 = require("vue");
7776
+ var import_vue18 = require("vue");
7185
7777
  function normalizeMaxLines(value) {
7186
7778
  if (value == null)
7187
7779
  return null;
@@ -7192,8 +7784,8 @@ function normalizeMaxLines(value) {
7192
7784
  }
7193
7785
  function createAppendOnlyLogStore(options) {
7194
7786
  const lines = [];
7195
- const version = (0, import_vue17.ref)(0);
7196
- const maxLines = normalizeMaxLines(options == null ? void 0 : options.maxLines);
7787
+ const version = (0, import_vue18.ref)(0);
7788
+ const maxLines = normalizeMaxLines(options?.maxLines);
7197
7789
  let head = 0;
7198
7790
  let firstLineIndex = 0;
7199
7791
  let tail = "";
@@ -7240,19 +7832,17 @@ function createAppendOnlyLogStore(options) {
7240
7832
  lineCount: () => retainedLineCount(),
7241
7833
  firstLineIndex: () => firstLineIndex,
7242
7834
  getLine(index) {
7243
- var _a;
7244
7835
  const completedCount = retainedCompletedCount();
7245
7836
  if (index >= 0 && index < completedCount)
7246
- return ((_a = completedAt(index)) == null ? void 0 : _a.text) ?? "";
7837
+ return completedAt(index)?.text ?? "";
7247
7838
  if (index === completedCount && tail)
7248
7839
  return tail;
7249
7840
  return "";
7250
7841
  },
7251
7842
  getLineKey(index) {
7252
- var _a;
7253
7843
  const completedCount = retainedCompletedCount();
7254
7844
  if (index >= 0 && index < completedCount)
7255
- return ((_a = completedAt(index)) == null ? void 0 : _a.id) ?? `missing:${firstLineIndex}:${index}`;
7845
+ return completedAt(index)?.id ?? `missing:${firstLineIndex}:${index}`;
7256
7846
  if (index === completedCount && tail)
7257
7847
  return `tail:${tailVersion}`;
7258
7848
  return `empty:${firstLineIndex}:${index}`;
@@ -7316,7 +7906,7 @@ function createAppendOnlyLogStore(options) {
7316
7906
  }
7317
7907
 
7318
7908
  // src/vue/log/use-tlog-link-controller.ts
7319
- var import_vue18 = require("vue");
7909
+ var import_vue19 = require("vue");
7320
7910
 
7321
7911
  // src/vue/log/tlog-plugins.ts
7322
7912
  function escapeRegExp(value) {
@@ -7325,6 +7915,12 @@ function escapeRegExp(value) {
7325
7915
  function stringIndexToCell3(text, index) {
7326
7916
  return textCellWidth(text.slice(0, Math.max(0, index)));
7327
7917
  }
7918
+ function testRegex(pattern, text) {
7919
+ pattern.lastIndex = 0;
7920
+ const ok = pattern.test(text);
7921
+ pattern.lastIndex = 0;
7922
+ return ok;
7923
+ }
7328
7924
  function stripTLogAnsiText(text) {
7329
7925
  return parseTLogAnnotatedText(text).plainText;
7330
7926
  }
@@ -7359,8 +7955,9 @@ function parseTLogAnnotatedText(text) {
7359
7955
  out.push(ch);
7360
7956
  plainLength += ch.length;
7361
7957
  if (currentHref) {
7362
- if ((activeLink == null ? void 0 : activeLink.href) === currentHref)
7363
- activeLink.endIndex += ch.length;
7958
+ const link = activeLink;
7959
+ if (link && link.href === currentHref)
7960
+ link.endIndex += ch.length;
7364
7961
  else
7365
7962
  activeLink = {
7366
7963
  href: currentHref,
@@ -7405,7 +8002,7 @@ function parseTLogAnnotatedText(text) {
7405
8002
  const parts = body.split(";");
7406
8003
  if (parts[0] === "8" && parts.length >= 3) {
7407
8004
  flushLink();
7408
- currentHref = parts.slice(2).join(";") || void 0;
8005
+ currentHref = sanitizeTerminalHref(parts.slice(2).join(";")) ?? void 0;
7409
8006
  }
7410
8007
  i = j;
7411
8008
  continue;
@@ -7418,17 +8015,24 @@ function parseTLogAnnotatedText(text) {
7418
8015
  };
7419
8016
  }
7420
8017
  function detectTLogUrls(text, options = {}) {
7421
- const pattern = options.pattern ?? /\b(?:https?:\/\/|file:\/\/)[^\s<>"'`]+/giu;
8018
+ const pattern = options.pattern ?? (options.allowFileUrls ? /\b(?:https?:\/\/|mailto:|file:\/\/)[^\s<>"'`]+/giu : /\b(?:https?:\/\/|mailto:)[^\s<>"'`]+/giu);
7422
8019
  const flags = pattern.flags.includes("g") ? pattern.flags : `${pattern.flags}g`;
7423
8020
  const regex = new RegExp(pattern.source, flags);
7424
8021
  const links = [];
7425
8022
  let match;
7426
8023
  while ((match = regex.exec(text)) != null) {
7427
- const href = match[0] ?? "";
8024
+ const rawHref = match[0] ?? "";
8025
+ if (rawHref.length === 0) {
8026
+ regex.lastIndex = Math.max(regex.lastIndex, match.index + 1);
8027
+ continue;
8028
+ }
8029
+ const href = sanitizeTerminalHref(rawHref, {
8030
+ allowFileUrls: options.allowFileUrls === true
8031
+ });
7428
8032
  if (!href)
7429
8033
  continue;
7430
8034
  const startIndex = match.index;
7431
- const endIndex = startIndex + href.length;
8035
+ const endIndex = startIndex + rawHref.length;
7432
8036
  const startCell = stringIndexToCell3(text, startIndex);
7433
8037
  const endCell = stringIndexToCell3(text, endIndex);
7434
8038
  if (endCell <= startCell)
@@ -7440,8 +8044,6 @@ function detectTLogUrls(text, options = {}) {
7440
8044
  endCell,
7441
8045
  source: "url"
7442
8046
  });
7443
- if (!href.length)
7444
- regex.lastIndex += 1;
7445
8047
  }
7446
8048
  return links;
7447
8049
  }
@@ -7449,11 +8051,11 @@ function detectTLogLevel(text, options = {}) {
7449
8051
  const errorPattern = options.errorPattern ?? /\b(?:ERROR|FATAL|ERR)\b/u;
7450
8052
  const warningPattern = options.warningPattern ?? /\b(?:WARN|WARNING)\b/u;
7451
8053
  const infoPattern = options.infoPattern ?? /\bINFO\b/u;
7452
- if (errorPattern.test(text))
8054
+ if (testRegex(errorPattern, text))
7453
8055
  return "error";
7454
- if (warningPattern.test(text))
8056
+ if (testRegex(warningPattern, text))
7455
8057
  return "warning";
7456
- if (options.includeInfo !== false && infoPattern.test(text))
8058
+ if (options.includeInfo !== false && testRegex(infoPattern, text))
7457
8059
  return "info";
7458
8060
  return null;
7459
8061
  }
@@ -7483,13 +8085,11 @@ function createTLogDensityBucketsFromMarkers(markers, totalVisualRows2, bucketCo
7483
8085
  }).filter((bucket) => bucket != null);
7484
8086
  }
7485
8087
  function getTLogPluginMetadata(line, pluginName) {
7486
- var _a;
7487
- return ((_a = line.results.find((result) => result.pluginName === pluginName)) == null ? void 0 : _a.metadata) ?? null;
8088
+ return line.results.find((result) => result.pluginName === pluginName)?.metadata ?? null;
7488
8089
  }
7489
8090
  function dispatchTLogPluginLinkAction(plugins, action) {
7490
- var _a;
7491
8091
  for (const plugin of plugins ?? [])
7492
- (_a = plugin.onLinkAction) == null ? void 0 : _a.call(plugin, action);
8092
+ plugin.onLinkAction?.(action);
7493
8093
  }
7494
8094
  function createTLogLevelPlugin(options = {}) {
7495
8095
  return {
@@ -7501,7 +8101,7 @@ function createTLogLevelPlugin(options = {}) {
7501
8101
  getMarkers(ctx) {
7502
8102
  return ctx.lines.flatMap((line) => {
7503
8103
  const metadata = getTLogPluginMetadata(line, "tlog-levels");
7504
- const level = metadata == null ? void 0 : metadata.level;
8104
+ const level = metadata?.level;
7505
8105
  if (!level || level === "info" && options.includeInfo === false)
7506
8106
  return [];
7507
8107
  return [
@@ -7521,7 +8121,7 @@ function createTLogLevelPlugin(options = {}) {
7521
8121
  getDensityBuckets(ctx) {
7522
8122
  const markers = ctx.lines.flatMap((line) => {
7523
8123
  const metadata = getTLogPluginMetadata(line, "tlog-levels");
7524
- const level = metadata == null ? void 0 : metadata.level;
8124
+ const level = metadata?.level;
7525
8125
  if (!level || level === "info" && options.includeInfo === false)
7526
8126
  return [];
7527
8127
  return [
@@ -7549,15 +8149,25 @@ function createTLogOsc8LinkPlugin() {
7549
8149
  parseLine(ctx) {
7550
8150
  if (!ctx.osc8Links.length)
7551
8151
  return;
7552
- return {
7553
- externalLinks: ctx.osc8Links.map((link, index) => ({
7554
- id: `osc8:${ctx.absoluteLineIndex}:${index}:${link.href}`,
7555
- href: link.href,
8152
+ const links = [];
8153
+ for (let index = 0; index < ctx.osc8Links.length; index++) {
8154
+ const link = ctx.osc8Links[index];
8155
+ const href = sanitizeTerminalHref(link.href);
8156
+ if (!href)
8157
+ continue;
8158
+ links.push({
8159
+ id: `osc8:${ctx.absoluteLineIndex}:${index}:${href}`,
8160
+ href,
7556
8161
  text: link.text,
7557
8162
  startCell: link.startCell,
7558
8163
  endCell: link.endCell,
7559
8164
  source: "osc8"
7560
- }))
8165
+ });
8166
+ }
8167
+ if (!links.length)
8168
+ return;
8169
+ return {
8170
+ externalLinks: links
7561
8171
  };
7562
8172
  }
7563
8173
  };
@@ -7594,7 +8204,7 @@ function createTLogLineMatcherPlugin(options) {
7594
8204
  return {
7595
8205
  name: options.name,
7596
8206
  parseLine(ctx) {
7597
- if (!pattern.test(ctx.plainText))
8207
+ if (!testRegex(pattern, ctx.plainText))
7598
8208
  return;
7599
8209
  return {
7600
8210
  markers: [
@@ -7609,7 +8219,7 @@ function createTLogLineMatcherPlugin(options) {
7609
8219
  getMarkers(ctx) {
7610
8220
  return ctx.lines.flatMap((line) => {
7611
8221
  const metadata = getTLogPluginMetadata(line, options.name);
7612
- return ((metadata == null ? void 0 : metadata.markers) ?? []).map((marker, index) => ({
8222
+ return (metadata?.markers ?? []).map((marker, index) => ({
7613
8223
  id: String(marker.id ?? `${options.name}:${line.absoluteLineIndex}:${index}`),
7614
8224
  absoluteLineIndex: line.absoluteLineIndex,
7615
8225
  lineIndex: line.lineIndex,
@@ -7660,12 +8270,11 @@ function actionKey(value) {
7660
8270
  ]);
7661
8271
  }
7662
8272
  function useTLogLinkController(logView, options = {}) {
7663
- const visibleLinks = (0, import_vue18.ref)([]);
7664
- const activeIndex = (0, import_vue18.ref)(-1);
8273
+ const visibleLinks = (0, import_vue19.ref)([]);
8274
+ const activeIndex = (0, import_vue19.ref)(-1);
7665
8275
  let suppressedActivateKey = null;
7666
8276
  function emitAction(action) {
7667
- var _a;
7668
- (_a = options.onAction) == null ? void 0 : _a.call(options, action);
8277
+ options.onAction?.(action);
7669
8278
  dispatchTLogPluginLinkAction(options.plugins, action);
7670
8279
  }
7671
8280
  function suppressProgrammaticActivation(link) {
@@ -7684,32 +8293,27 @@ function useTLogLinkController(logView, options = {}) {
7684
8293
  });
7685
8294
  }
7686
8295
  function refresh() {
7687
- var _a;
7688
- const next = ((_a = logView.value) == null ? void 0 : _a.getVisibleLinks().map(toPanelItem)) ?? [];
8296
+ const next = logView.value?.getVisibleLinks().map(toPanelItem) ?? [];
7689
8297
  visibleLinks.value = next;
7690
8298
  activeIndex.value = next.findIndex((link) => link.current === true);
7691
8299
  }
7692
8300
  function focusVisibleLink(visibleIndex) {
7693
- var _a;
7694
- const focused = ((_a = logView.value) == null ? void 0 : _a.focusVisibleLink(visibleIndex)) === true;
8301
+ const focused = logView.value?.focusVisibleLink(visibleIndex) === true;
7695
8302
  refresh();
7696
8303
  return focused;
7697
8304
  }
7698
8305
  function focusNextLink() {
7699
- var _a;
7700
- const focused = ((_a = logView.value) == null ? void 0 : _a.focusNextLink()) === true;
8306
+ const focused = logView.value?.focusNextLink() === true;
7701
8307
  refresh();
7702
8308
  return focused;
7703
8309
  }
7704
8310
  function focusPreviousLink() {
7705
- var _a;
7706
- const focused = ((_a = logView.value) == null ? void 0 : _a.focusPreviousLink()) === true;
8311
+ const focused = logView.value?.focusPreviousLink() === true;
7707
8312
  refresh();
7708
8313
  return focused;
7709
8314
  }
7710
8315
  function clearFocus() {
7711
- var _a;
7712
- (_a = logView.value) == null ? void 0 : _a.clearLinkFocus();
8316
+ logView.value?.clearLinkFocus();
7713
8317
  refresh();
7714
8318
  }
7715
8319
  function activateVisibleLink(visibleIndex) {
@@ -7769,7 +8373,7 @@ function useTLogLinkController(logView, options = {}) {
7769
8373
  emitAction(action);
7770
8374
  refresh();
7771
8375
  }
7772
- (0, import_vue18.watch)(
8376
+ (0, import_vue19.watch)(
7773
8377
  () => logView.value,
7774
8378
  () => {
7775
8379
  refresh();
@@ -7792,10 +8396,10 @@ function useTLogLinkController(logView, options = {}) {
7792
8396
  }
7793
8397
 
7794
8398
  // src/vue/log/use-tlog-search-controller.ts
7795
- var import_vue20 = require("vue");
8399
+ var import_vue21 = require("vue");
7796
8400
 
7797
8401
  // src/vue/log/use-tlog-search-results-page.ts
7798
- var import_vue19 = require("vue");
8402
+ var import_vue20 = require("vue");
7799
8403
  var DEFAULT_PAGE_SIZE = 20;
7800
8404
  function clamp10(n, min, max) {
7801
8405
  return Math.max(min, Math.min(max, n));
@@ -7832,8 +8436,8 @@ function createEmptyState(pageSize, status = "idle", error = null) {
7832
8436
  function useTLogSearchResultsPage(logView, options = {}) {
7833
8437
  const pageSize = normalizePageSize(options.pageSize);
7834
8438
  const includePreview = options.includePreview === true;
7835
- const currentPage = (0, import_vue19.ref)(0);
7836
- const state = (0, import_vue19.ref)(createEmptyState(pageSize));
8439
+ const currentPage = (0, import_vue20.ref)(0);
8440
+ const state = (0, import_vue20.ref)(createEmptyState(pageSize));
7837
8441
  function clear(status = "idle", error = null) {
7838
8442
  currentPage.value = 0;
7839
8443
  state.value = createEmptyState(pageSize, status, error);
@@ -7858,18 +8462,15 @@ function useTLogSearchResultsPage(logView, options = {}) {
7858
8462
  contextCells: options.contextCells
7859
8463
  }) : [];
7860
8464
  const results = rawResults.map(
7861
- (entry) => {
7862
- var _a, _b, _c;
7863
- return {
7864
- matchIndex: entry.matchIndex,
7865
- absoluteLineIndex: entry.match.absoluteLineIndex,
7866
- lineIndex: entry.match.index,
7867
- text: ((_a = entry.preview) == null ? void 0 : _a.text) ?? "",
7868
- matchStartCell: ((_b = entry.preview) == null ? void 0 : _b.matchStartCell) ?? 0,
7869
- matchEndCell: ((_c = entry.preview) == null ? void 0 : _c.matchEndCell) ?? 0,
7870
- current: entry.matchIndex === search.currentMatchIndex
7871
- };
7872
- }
8465
+ (entry) => ({
8466
+ matchIndex: entry.matchIndex,
8467
+ absoluteLineIndex: entry.match.absoluteLineIndex,
8468
+ lineIndex: entry.match.index,
8469
+ text: entry.preview?.text ?? "",
8470
+ matchStartCell: entry.preview?.matchStartCell ?? 0,
8471
+ matchEndCell: entry.preview?.matchEndCell ?? 0,
8472
+ current: entry.matchIndex === search.currentMatchIndex
8473
+ })
7873
8474
  );
7874
8475
  const activeIndex = search.currentMatchIndex >= offset && search.currentMatchIndex < offset + results.length ? search.currentMatchIndex - offset : -1;
7875
8476
  currentPage.value = page;
@@ -7897,8 +8498,7 @@ function useTLogSearchResultsPage(logView, options = {}) {
7897
8498
  setPage(currentPage.value - 1);
7898
8499
  }
7899
8500
  function syncPageToCurrentMatch() {
7900
- var _a;
7901
- const currentMatchIndex = ((_a = logView.value) == null ? void 0 : _a.getSearchState().currentMatchIndex) ?? -1;
8501
+ const currentMatchIndex = logView.value?.getSearchState().currentMatchIndex ?? -1;
7902
8502
  if (currentMatchIndex >= 0)
7903
8503
  currentPage.value = Math.floor(currentMatchIndex / pageSize);
7904
8504
  refresh();
@@ -7919,7 +8519,7 @@ function useTLogSearchResultsPage(logView, options = {}) {
7919
8519
  refresh();
7920
8520
  return true;
7921
8521
  }
7922
- (0, import_vue19.watch)(
8522
+ (0, import_vue20.watch)(
7923
8523
  () => logView.value,
7924
8524
  () => {
7925
8525
  currentPage.value = 0;
@@ -7960,16 +8560,16 @@ function sameSavedSearch(a, b) {
7960
8560
  return a.query === b.query && a.mode === b.mode && Boolean(a.caseSensitive) === Boolean(b.caseSensitive) && Boolean(a.wholeWord) === Boolean(b.wholeWord) && (a.regexFlags ?? "") === (b.regexFlags ?? "");
7961
8561
  }
7962
8562
  function useTLogSearchController(logView, options = {}) {
7963
- const query = (0, import_vue20.ref)(options.initialQuery ?? "");
7964
- const mode = (0, import_vue20.ref)(options.initialMode === "regex" ? "regex" : "text");
7965
- const caseSensitive = (0, import_vue20.ref)(options.initialCaseSensitive === true);
7966
- const wholeWord = (0, import_vue20.ref)(options.initialWholeWord === true);
7967
- const regexFlags = (0, import_vue20.ref)(options.initialRegexFlags ?? "");
7968
- const searchState = (0, import_vue20.ref)(normalizeSearchState(query.value));
7969
- const markers = (0, import_vue20.ref)([]);
7970
- const metrics = (0, import_vue20.ref)(null);
7971
- const searchHistory = (0, import_vue20.ref)([]);
7972
- const savedSearches = (0, import_vue20.ref)(options.initialSavedSearches ?? []);
8563
+ const query = (0, import_vue21.ref)(options.initialQuery ?? "");
8564
+ const mode = (0, import_vue21.ref)(options.initialMode === "regex" ? "regex" : "text");
8565
+ const caseSensitive = (0, import_vue21.ref)(options.initialCaseSensitive === true);
8566
+ const wholeWord = (0, import_vue21.ref)(options.initialWholeWord === true);
8567
+ const regexFlags = (0, import_vue21.ref)(options.initialRegexFlags ?? "");
8568
+ const searchState = (0, import_vue21.ref)(normalizeSearchState(query.value));
8569
+ const markers = (0, import_vue21.ref)([]);
8570
+ const metrics = (0, import_vue21.ref)(null);
8571
+ const searchHistory = (0, import_vue21.ref)([]);
8572
+ const savedSearches = (0, import_vue21.ref)(options.initialSavedSearches ?? []);
7973
8573
  const historyLimit = normalizeHistoryLimit(options.maxHistory);
7974
8574
  const resultsPage = useTLogSearchResultsPage(logView, options);
7975
8575
  let nextSavedSearchId = 0;
@@ -7980,7 +8580,7 @@ function useTLogSearchController(logView, options = {}) {
7980
8580
  } while (savedSearches.value.some((entry) => entry.id === id));
7981
8581
  return id;
7982
8582
  }
7983
- const searchBarState = (0, import_vue20.computed)(() => ({
8583
+ const searchBarState = (0, import_vue21.computed)(() => ({
7984
8584
  query: query.value,
7985
8585
  mode: mode.value,
7986
8586
  caseSensitive: caseSensitive.value,
@@ -8036,25 +8636,22 @@ function useTLogSearchController(logView, options = {}) {
8036
8636
  regexFlags.value = String(value ?? "");
8037
8637
  }
8038
8638
  function nextMatch() {
8039
- var _a;
8040
8639
  recordHistory();
8041
- (_a = logView.value) == null ? void 0 : _a.findNext();
8640
+ logView.value?.findNext();
8042
8641
  resultsPage.syncPageToCurrentMatch();
8043
8642
  refresh();
8044
8643
  }
8045
8644
  function previousMatch() {
8046
- var _a;
8047
8645
  recordHistory();
8048
- (_a = logView.value) == null ? void 0 : _a.findPrevious();
8646
+ logView.value?.findPrevious();
8049
8647
  resultsPage.syncPageToCurrentMatch();
8050
8648
  refresh();
8051
8649
  }
8052
8650
  function clearSearch() {
8053
- var _a;
8054
8651
  query.value = "";
8055
8652
  searchState.value = normalizeSearchState("");
8056
8653
  markers.value = [];
8057
- metrics.value = ((_a = logView.value) == null ? void 0 : _a.getScrollMetrics()) ?? null;
8654
+ metrics.value = logView.value?.getScrollMetrics() ?? null;
8058
8655
  resultsPage.clear();
8059
8656
  }
8060
8657
  function selectMatch(matchIndex) {
@@ -8069,7 +8666,7 @@ function useTLogSearchController(logView, options = {}) {
8069
8666
  return null;
8070
8667
  recordHistory(normalizedQuery);
8071
8668
  const candidate = {
8072
- label: (label == null ? void 0 : label.trim()) || void 0,
8669
+ label: label?.trim() || void 0,
8073
8670
  query: normalizedQuery,
8074
8671
  mode: mode.value,
8075
8672
  caseSensitive: caseSensitive.value,
@@ -8108,20 +8705,17 @@ function useTLogSearchController(logView, options = {}) {
8108
8705
  searchHistory.value = value.map((entry) => String(entry ?? "").trim()).filter(Boolean).slice(0, historyLimit);
8109
8706
  }
8110
8707
  function setSavedSearches(value) {
8111
- savedSearches.value = value.map((entry) => {
8112
- var _a;
8113
- return {
8114
- id: String(entry.id),
8115
- label: ((_a = entry.label) == null ? void 0 : _a.trim()) || void 0,
8116
- query: String(entry.query ?? ""),
8117
- mode: entry.mode === "regex" ? "regex" : "text",
8118
- caseSensitive: entry.caseSensitive === true,
8119
- wholeWord: entry.wholeWord === true,
8120
- regexFlags: entry.regexFlags || void 0
8121
- };
8122
- });
8708
+ savedSearches.value = value.map((entry) => ({
8709
+ id: String(entry.id),
8710
+ label: entry.label?.trim() || void 0,
8711
+ query: String(entry.query ?? ""),
8712
+ mode: entry.mode === "regex" ? "regex" : "text",
8713
+ caseSensitive: entry.caseSensitive === true,
8714
+ wholeWord: entry.wholeWord === true,
8715
+ regexFlags: entry.regexFlags || void 0
8716
+ }));
8123
8717
  }
8124
- (0, import_vue20.watch)(
8718
+ (0, import_vue21.watch)(
8125
8719
  () => logView.value,
8126
8720
  () => {
8127
8721
  refresh();
@@ -8159,13 +8753,13 @@ function useTLogSearchController(logView, options = {}) {
8159
8753
  }
8160
8754
 
8161
8755
  // src/vue/log/use-tlog-virtual-search-results.ts
8162
- var import_vue21 = require("vue");
8756
+ var import_vue22 = require("vue");
8163
8757
  function normalizeInt8(value, fallback = 0) {
8164
8758
  const n = Math.floor(Number(value));
8165
8759
  return Number.isFinite(n) ? n : fallback;
8166
8760
  }
8167
8761
  function useTLogVirtualSearchResults(logView, options = {}) {
8168
- const state = (0, import_vue21.ref)({
8762
+ const state = (0, import_vue22.ref)({
8169
8763
  itemCount: 0,
8170
8764
  itemVersion: 0,
8171
8765
  activeIndex: -1,
@@ -8179,22 +8773,21 @@ function useTLogVirtualSearchResults(logView, options = {}) {
8179
8773
  }
8180
8774
  function refresh() {
8181
8775
  const handle = logView.value;
8182
- const search = handle == null ? void 0 : handle.getSearchState();
8183
- const itemCount = Math.max(0, normalizeInt8((search == null ? void 0 : search.matchCount) ?? 0));
8184
- const currentMatchIndex = normalizeInt8((search == null ? void 0 : search.currentMatchIndex) ?? -1, -1);
8776
+ const search = handle?.getSearchState();
8777
+ const itemCount = Math.max(0, normalizeInt8(search?.matchCount ?? 0));
8778
+ const currentMatchIndex = normalizeInt8(search?.currentMatchIndex ?? -1, -1);
8185
8779
  const nextState = {
8186
8780
  itemCount,
8187
8781
  itemVersion: state.value.itemVersion + 1,
8188
8782
  activeIndex: currentMatchIndex >= 0 ? currentMatchIndex : -1,
8189
8783
  currentMatchIndex,
8190
- status: (search == null ? void 0 : search.status) ?? "idle",
8191
- error: (search == null ? void 0 : search.error) ?? null
8784
+ status: search?.status ?? "idle",
8785
+ error: search?.error ?? null
8192
8786
  };
8193
8787
  clearCache();
8194
8788
  state.value = nextState;
8195
8789
  }
8196
8790
  function getItem(index) {
8197
- var _a, _b, _c;
8198
8791
  const normalizedIndex = normalizeInt8(index, -1);
8199
8792
  if (normalizedIndex < 0 || normalizedIndex >= state.value.itemCount)
8200
8793
  return null;
@@ -8217,9 +8810,9 @@ function useTLogVirtualSearchResults(logView, options = {}) {
8217
8810
  matchIndex: entry.matchIndex,
8218
8811
  absoluteLineIndex: entry.match.absoluteLineIndex,
8219
8812
  lineIndex: entry.match.index,
8220
- text: ((_a = entry.preview) == null ? void 0 : _a.text) ?? entry.match.text,
8221
- matchStartCell: ((_b = entry.preview) == null ? void 0 : _b.matchStartCell) ?? 0,
8222
- matchEndCell: ((_c = entry.preview) == null ? void 0 : _c.matchEndCell) ?? Math.max(0, entry.match.text.length),
8813
+ text: entry.preview?.text ?? entry.match.text,
8814
+ matchStartCell: entry.preview?.matchStartCell ?? 0,
8815
+ matchEndCell: entry.preview?.matchEndCell ?? Math.max(0, entry.match.text.length),
8223
8816
  current: entry.matchIndex === state.value.currentMatchIndex
8224
8817
  };
8225
8818
  cache.set(normalizedIndex, item);
@@ -8233,7 +8826,7 @@ function useTLogVirtualSearchResults(logView, options = {}) {
8233
8826
  refresh();
8234
8827
  return selected;
8235
8828
  }
8236
- (0, import_vue21.watch)(() => logView.value, refresh, { immediate: true });
8829
+ (0, import_vue22.watch)(() => logView.value, refresh, { immediate: true });
8237
8830
  return {
8238
8831
  state,
8239
8832
  refresh,
@@ -8243,7 +8836,7 @@ function useTLogVirtualSearchResults(logView, options = {}) {
8243
8836
  }
8244
8837
 
8245
8838
  // src/vue/log/use-tlog-retained-index.ts
8246
- var import_vue22 = require("vue");
8839
+ var import_vue23 = require("vue");
8247
8840
  var DEFAULT_BUDGET_MS = 4;
8248
8841
  var DEFAULT_MAX_ITEMS = 1e4;
8249
8842
  function clamp11(n, min, max) {
@@ -8257,17 +8850,20 @@ function normalizeMaxItems(value) {
8257
8850
  const n = Math.floor(Number(value ?? DEFAULT_MAX_ITEMS));
8258
8851
  return Number.isFinite(n) ? Math.max(1, n) : DEFAULT_MAX_ITEMS;
8259
8852
  }
8853
+ function sanitizeIndexedExternalHref(value, options = {}) {
8854
+ return sanitizeTerminalHref(value, options);
8855
+ }
8260
8856
  function useTLogRetainedIndex(logView, source, version, options = {}) {
8261
- const status = (0, import_vue22.ref)("idle");
8262
- const links = (0, import_vue22.ref)([]);
8263
- const diagnostics = (0, import_vue22.ref)([]);
8264
- const density = (0, import_vue22.ref)([]);
8265
- const plugins = (0, import_vue22.computed)(() => {
8857
+ const status = (0, import_vue23.ref)("idle");
8858
+ const links = (0, import_vue23.ref)([]);
8859
+ const diagnostics = (0, import_vue23.ref)([]);
8860
+ const density = (0, import_vue23.ref)([]);
8861
+ const plugins = (0, import_vue23.computed)(() => {
8266
8862
  const builtins = [];
8267
8863
  if (options.links)
8268
8864
  builtins.push(createTLogOsc8LinkPlugin());
8269
8865
  if (options.urls)
8270
- builtins.push(createTLogUrlPlugin());
8866
+ builtins.push(createTLogUrlPlugin({ allowFileUrls: options.allowFileUrls }));
8271
8867
  if (options.levels)
8272
8868
  builtins.push(createTLogLevelPlugin({ bucketCount: options.bucketCount }));
8273
8869
  return [...builtins, ...options.plugins ?? []];
@@ -8284,11 +8880,10 @@ function useTLogRetainedIndex(logView, source, version, options = {}) {
8284
8880
  return { kind: "timer", id: setTimeout(cb, 16) };
8285
8881
  }
8286
8882
  function cancelFrame(handle) {
8287
- var _a;
8288
8883
  if (!handle)
8289
8884
  return;
8290
8885
  if (handle.kind === "raf") {
8291
- (_a = globalThis.cancelAnimationFrame) == null ? void 0 : _a.call(globalThis, handle.id);
8886
+ globalThis.cancelAnimationFrame?.(handle.id);
8292
8887
  return;
8293
8888
  }
8294
8889
  clearTimeout(handle.id);
@@ -8302,8 +8897,7 @@ function useTLogRetainedIndex(logView, source, version, options = {}) {
8302
8897
  status.value = "idle";
8303
8898
  }
8304
8899
  function estimateVisualRow(lineIndex) {
8305
- var _a;
8306
- const metrics = (_a = logView.value) == null ? void 0 : _a.getScrollMetrics();
8900
+ const metrics = logView.value?.getScrollMetrics();
8307
8901
  if (!metrics)
8308
8902
  return Math.max(0, lineIndex);
8309
8903
  const lineCount = Math.max(1, metrics.lineCount);
@@ -8315,22 +8909,20 @@ function useTLogRetainedIndex(logView, source, version, options = {}) {
8315
8909
  );
8316
8910
  }
8317
8911
  function currentMatchLineIndex() {
8318
- var _a;
8319
8912
  const handle = logView.value;
8320
8913
  if (!handle)
8321
8914
  return null;
8322
8915
  const current = handle.getSearchState().currentMatchIndex;
8323
8916
  if (current < 0)
8324
8917
  return null;
8325
- return ((_a = handle.getSearchMatch(current)) == null ? void 0 : _a.index) ?? null;
8918
+ return handle.getSearchMatch(current)?.index ?? null;
8326
8919
  }
8327
8920
  function finalize(generationAtStart) {
8328
- var _a, _b, _c, _d;
8329
8921
  if (generationAtStart !== generation)
8330
8922
  return;
8331
8923
  const totalVisualRows2 = Math.max(
8332
- ((_a = logView.value) == null ? void 0 : _a.getScrollMetrics().visualRowCount) ?? indexedLines.length,
8333
- ((_b = logView.value) == null ? void 0 : _b.getScrollMetrics().viewportRows) ?? 0,
8924
+ logView.value?.getScrollMetrics().visualRowCount ?? indexedLines.length,
8925
+ logView.value?.getScrollMetrics().viewportRows ?? 0,
8334
8926
  indexedLines.length,
8335
8927
  1
8336
8928
  );
@@ -8344,10 +8936,10 @@ function useTLogRetainedIndex(logView, source, version, options = {}) {
8344
8936
  const nextDiagnostics = [];
8345
8937
  const nextDensity = [];
8346
8938
  for (const plugin of plugins.value) {
8347
- const markers = (_c = plugin.getMarkers) == null ? void 0 : _c.call(plugin, markerCtx);
8939
+ const markers = plugin.getMarkers?.(markerCtx);
8348
8940
  if (Array.isArray(markers) && markers.length)
8349
8941
  nextDiagnostics.push(...markers);
8350
- const buckets = (_d = plugin.getDensityBuckets) == null ? void 0 : _d.call(plugin, markerCtx);
8942
+ const buckets = plugin.getDensityBuckets?.(markerCtx);
8351
8943
  if (Array.isArray(buckets) && buckets.length)
8352
8944
  nextDensity.push(...buckets);
8353
8945
  }
@@ -8357,13 +8949,12 @@ function useTLogRetainedIndex(logView, source, version, options = {}) {
8357
8949
  status.value = "done";
8358
8950
  }
8359
8951
  function schedule() {
8360
- var _a;
8361
8952
  const generationAtStart = generation;
8362
8953
  const sourceValue = source.value;
8363
8954
  const budgetMs = normalizeBudgetMs(options.budgetMs);
8364
8955
  const maxItems = normalizeMaxItems(options.maxItems);
8365
8956
  const lineCount = Math.max(0, Math.floor(Number(sourceValue.lineCount())));
8366
- const firstLineIndex = Math.max(0, Math.floor(Number(((_a = sourceValue.firstLineIndex) == null ? void 0 : _a.call(sourceValue)) ?? 0)));
8957
+ const firstLineIndex = Math.max(0, Math.floor(Number(sourceValue.firstLineIndex?.() ?? 0)));
8367
8958
  const activePlugins = plugins.value;
8368
8959
  if (!lineCount) {
8369
8960
  links.value = [];
@@ -8373,20 +8964,19 @@ function useTLogRetainedIndex(logView, source, version, options = {}) {
8373
8964
  return;
8374
8965
  }
8375
8966
  const runFrame = () => {
8376
- var _a2, _b;
8377
8967
  if (generationAtStart !== generation)
8378
8968
  return;
8379
8969
  const start = Date.now();
8380
8970
  while (cursor < lineCount && Date.now() - start < budgetMs) {
8381
8971
  const lineIndex = cursor++;
8382
8972
  const text = sourceValue.getLine(lineIndex);
8383
- const lineKey = ((_a2 = sourceValue.getLineKey) == null ? void 0 : _a2.call(sourceValue, lineIndex)) ?? `line:${version.value}:${lineIndex}`;
8973
+ const lineKey = sourceValue.getLineKey?.(lineIndex) ?? `line:${version.value}:${lineIndex}`;
8384
8974
  const parsed = parseTLogAnnotatedText(text);
8385
8975
  const results = [];
8386
8976
  const externalLinks = [];
8387
8977
  const seenLinks = /* @__PURE__ */ new Set();
8388
8978
  for (const plugin of activePlugins) {
8389
- const metadata = (_b = plugin.parseLine) == null ? void 0 : _b.call(plugin, {
8979
+ const metadata = plugin.parseLine?.({
8390
8980
  lineIndex,
8391
8981
  absoluteLineIndex: firstLineIndex + lineIndex,
8392
8982
  lineKey,
@@ -8398,15 +8988,20 @@ function useTLogRetainedIndex(logView, source, version, options = {}) {
8398
8988
  continue;
8399
8989
  results.push({ pluginName: plugin.name, metadata });
8400
8990
  for (const link of metadata.externalLinks ?? []) {
8991
+ const href = sanitizeIndexedExternalHref(link.href, {
8992
+ allowFileUrls: options.allowFileUrls === true
8993
+ });
8994
+ if (!href)
8995
+ continue;
8401
8996
  const id = String(
8402
- link.id ?? `${plugin.name}:${firstLineIndex + lineIndex}:${link.startCell}:${link.endCell}:${link.href}`
8997
+ link.id ?? `${plugin.name}:${firstLineIndex + lineIndex}:${link.startCell}:${link.endCell}:${href}`
8403
8998
  );
8404
8999
  if (seenLinks.has(id) || externalLinks.length >= maxItems)
8405
9000
  continue;
8406
9001
  seenLinks.add(id);
8407
9002
  externalLinks.push({
8408
9003
  id,
8409
- href: link.href,
9004
+ href,
8410
9005
  text: link.text,
8411
9006
  absoluteLineIndex: firstLineIndex + lineIndex,
8412
9007
  lineIndex,
@@ -8448,7 +9043,7 @@ function useTLogRetainedIndex(logView, source, version, options = {}) {
8448
9043
  status.value = "indexing";
8449
9044
  schedule();
8450
9045
  }
8451
- (0, import_vue22.watch)([() => source.value, () => version.value, () => logView.value], refresh, {
9046
+ (0, import_vue23.watch)([() => source.value, () => version.value, () => logView.value], refresh, {
8452
9047
  immediate: true
8453
9048
  });
8454
9049
  return {
@@ -8462,7 +9057,7 @@ function useTLogRetainedIndex(logView, source, version, options = {}) {
8462
9057
  }
8463
9058
 
8464
9059
  // src/vue/log/tlog-session.ts
8465
- var import_vue23 = require("vue");
9060
+ var import_vue24 = require("vue");
8466
9061
  function clamp12(n, min, max) {
8467
9062
  return Math.max(min, Math.min(max, n));
8468
9063
  }
@@ -8484,19 +9079,19 @@ function deserializeTLogViewSessionState(value) {
8484
9079
  function createTLogViewSessionStore(options = {}) {
8485
9080
  const storageKey = options.storageKey ?? "@simon_he/vue-tui:tlog-session";
8486
9081
  const storage = options.storage ?? globalThis.localStorage ?? null;
8487
- const state = (0, import_vue23.ref)(null);
9082
+ const state = (0, import_vue24.ref)(null);
8488
9083
  function load() {
8489
- const next = deserializeTLogViewSessionState(storage == null ? void 0 : storage.getItem(storageKey));
9084
+ const next = deserializeTLogViewSessionState(storage?.getItem(storageKey));
8490
9085
  state.value = next;
8491
9086
  return next;
8492
9087
  }
8493
9088
  function save(nextState) {
8494
9089
  state.value = nextState;
8495
- storage == null ? void 0 : storage.setItem(storageKey, serializeTLogViewSessionState(nextState));
9090
+ storage?.setItem(storageKey, serializeTLogViewSessionState(nextState));
8496
9091
  }
8497
9092
  function clear() {
8498
9093
  state.value = null;
8499
- storage == null ? void 0 : storage.removeItem(storageKey);
9094
+ storage?.removeItem(storageKey);
8500
9095
  }
8501
9096
  return {
8502
9097
  state,
@@ -8506,36 +9101,34 @@ function createTLogViewSessionStore(options = {}) {
8506
9101
  };
8507
9102
  }
8508
9103
  function captureTLogViewSessionState(bindings) {
8509
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
8510
- const metrics = (_a = bindings.logView.value) == null ? void 0 : _a.getScrollMetrics();
9104
+ const metrics = bindings.logView.value?.getScrollMetrics();
8511
9105
  if (!metrics)
8512
9106
  return null;
8513
9107
  return {
8514
9108
  scrollTop: metrics.scrollTop,
8515
9109
  firstLineIndex: metrics.firstLineIndex,
8516
- visualIndexMode: ((_b = bindings.visualIndexMode) == null ? void 0 : _b.value) ?? "estimated",
9110
+ visualIndexMode: bindings.visualIndexMode?.value ?? "estimated",
8517
9111
  search: bindings.search ? {
8518
9112
  query: bindings.search.query.value,
8519
9113
  mode: bindings.search.mode.value,
8520
9114
  caseSensitive: bindings.search.caseSensitive.value,
8521
9115
  wholeWord: bindings.search.wholeWord.value,
8522
9116
  regexFlags: bindings.search.regexFlags.value || void 0,
8523
- currentMatchIndex: ((_c = bindings.logView.value) == null ? void 0 : _c.getSearchState().currentMatchIndex) ?? -1,
8524
- history: ((_d = bindings.search.searchHistory) == null ? void 0 : _d.value) ?? [],
8525
- savedSearches: ((_e = bindings.search.savedSearches) == null ? void 0 : _e.value) ?? []
9117
+ currentMatchIndex: bindings.logView.value?.getSearchState().currentMatchIndex ?? -1,
9118
+ history: bindings.search.searchHistory?.value ?? [],
9119
+ savedSearches: bindings.search.savedSearches?.value ?? []
8526
9120
  } : void 0,
8527
9121
  ui: {
8528
- resultsPage: (_g = (_f = bindings.search) == null ? void 0 : _f.resultsPage) == null ? void 0 : _g.state.value.page,
8529
- linksPanelActiveIndex: (_h = bindings.linkController) == null ? void 0 : _h.activeIndex.value,
8530
- wrap: (_i = bindings.wrap) == null ? void 0 : _i.value,
8531
- ansi: (_j = bindings.ansi) == null ? void 0 : _j.value,
8532
- links: (_k = bindings.links) == null ? void 0 : _k.value,
8533
- keyboardLinks: (_l = bindings.keyboardLinks) == null ? void 0 : _l.value
9122
+ resultsPage: bindings.search?.resultsPage?.state.value.page,
9123
+ linksPanelActiveIndex: bindings.linkController?.activeIndex.value,
9124
+ wrap: bindings.wrap?.value,
9125
+ ansi: bindings.ansi?.value,
9126
+ links: bindings.links?.value,
9127
+ keyboardLinks: bindings.keyboardLinks?.value
8534
9128
  }
8535
9129
  };
8536
9130
  }
8537
9131
  function restoreTLogViewSessionState(bindings, state) {
8538
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
8539
9132
  if (!state)
8540
9133
  return false;
8541
9134
  if (bindings.visualIndexMode)
@@ -8556,15 +9149,15 @@ function restoreTLogViewSessionState(bindings, state) {
8556
9149
  bindings.search.updateCaseSensitive(state.search.caseSensitive);
8557
9150
  bindings.search.updateWholeWord(state.search.wholeWord);
8558
9151
  bindings.search.updateRegexFlags(state.search.regexFlags ?? "");
8559
- (_b = (_a = bindings.search).setSearchHistory) == null ? void 0 : _b.call(_a, state.search.history ?? []);
8560
- (_d = (_c = bindings.search).setSavedSearches) == null ? void 0 : _d.call(_c, state.search.savedSearches ?? []);
8561
- if (((_e = state.ui) == null ? void 0 : _e.resultsPage) != null)
8562
- (_f = bindings.search.resultsPage) == null ? void 0 : _f.setPage(state.ui.resultsPage);
9152
+ bindings.search.setSearchHistory?.(state.search.history ?? []);
9153
+ bindings.search.setSavedSearches?.(state.search.savedSearches ?? []);
9154
+ if (state.ui?.resultsPage != null)
9155
+ bindings.search.resultsPage?.setPage(state.ui.resultsPage);
8563
9156
  if (!state.search.query)
8564
9157
  bindings.search.clearSearch();
8565
9158
  }
8566
9159
  const handle = bindings.logView.value;
8567
- const metrics = handle == null ? void 0 : handle.getScrollMetrics();
9160
+ const metrics = handle?.getScrollMetrics();
8568
9161
  if (handle && metrics) {
8569
9162
  const firstLineDelta = metrics.firstLineIndex - state.firstLineIndex;
8570
9163
  const restoredScrollTop = clamp12(
@@ -8573,14 +9166,14 @@ function restoreTLogViewSessionState(bindings, state) {
8573
9166
  metrics.maxScrollTop
8574
9167
  );
8575
9168
  handle.scrollToVisualRow(restoredScrollTop);
8576
- if ((((_g = state.search) == null ? void 0 : _g.currentMatchIndex) ?? -1) >= 0) {
8577
- (_h = bindings.search) == null ? void 0 : _h.selectMatch(state.search.currentMatchIndex);
9169
+ if ((state.search?.currentMatchIndex ?? -1) >= 0) {
9170
+ bindings.search?.selectMatch(state.search.currentMatchIndex);
8578
9171
  }
8579
9172
  }
8580
- if (((_i = state.ui) == null ? void 0 : _i.linksPanelActiveIndex) != null) {
8581
- const restored = ((_j = bindings.linkController) == null ? void 0 : _j.focusVisibleLink(state.ui.linksPanelActiveIndex)) === true;
9173
+ if (state.ui?.linksPanelActiveIndex != null) {
9174
+ const restored = bindings.linkController?.focusVisibleLink(state.ui.linksPanelActiveIndex) === true;
8582
9175
  if (!restored && state.ui.linksPanelActiveIndex < 0)
8583
- (_k = bindings.linkController) == null ? void 0 : _k.clearFocus();
9176
+ bindings.linkController?.clearFocus();
8584
9177
  }
8585
9178
  return true;
8586
9179
  }
@@ -8615,44 +9208,43 @@ function eventSignature(event) {
8615
9208
  return parts.join("+");
8616
9209
  }
8617
9210
  function matchesTLogKeyBinding(event, bindings) {
8618
- if (!(bindings == null ? void 0 : bindings.length))
9211
+ if (!bindings?.length)
8619
9212
  return false;
8620
9213
  const signature = eventSignature(event);
8621
9214
  return bindings.some((binding) => normalizeKeyToken(binding) === signature);
8622
9215
  }
8623
9216
  function handleTLogKeymapEvent(event, keymap, actions) {
8624
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
8625
9217
  if (matchesTLogKeyBinding(event, keymap.searchNext)) {
8626
- (_a = actions.searchNext) == null ? void 0 : _a.call(actions);
8627
- (_b = event.preventDefault) == null ? void 0 : _b.call(event);
9218
+ actions.searchNext?.();
9219
+ event.preventDefault?.();
8628
9220
  return true;
8629
9221
  }
8630
9222
  if (matchesTLogKeyBinding(event, keymap.searchPrevious)) {
8631
- (_c = actions.searchPrevious) == null ? void 0 : _c.call(actions);
8632
- (_d = event.preventDefault) == null ? void 0 : _d.call(event);
9223
+ actions.searchPrevious?.();
9224
+ event.preventDefault?.();
8633
9225
  return true;
8634
9226
  }
8635
9227
  if (matchesTLogKeyBinding(event, keymap.clearSearch)) {
8636
- (_e = actions.clearSearch) == null ? void 0 : _e.call(actions);
8637
- (_f = event.preventDefault) == null ? void 0 : _f.call(event);
9228
+ actions.clearSearch?.();
9229
+ event.preventDefault?.();
8638
9230
  return true;
8639
9231
  }
8640
9232
  if (matchesTLogKeyBinding(event, keymap.nextLink)) {
8641
- const handled = ((_g = actions.nextLink) == null ? void 0 : _g.call(actions)) === true;
9233
+ const handled = actions.nextLink?.() === true;
8642
9234
  if (handled)
8643
- (_h = event.preventDefault) == null ? void 0 : _h.call(event);
9235
+ event.preventDefault?.();
8644
9236
  return handled;
8645
9237
  }
8646
9238
  if (matchesTLogKeyBinding(event, keymap.previousLink)) {
8647
- const handled = ((_i = actions.previousLink) == null ? void 0 : _i.call(actions)) === true;
9239
+ const handled = actions.previousLink?.() === true;
8648
9240
  if (handled)
8649
- (_j = event.preventDefault) == null ? void 0 : _j.call(event);
9241
+ event.preventDefault?.();
8650
9242
  return handled;
8651
9243
  }
8652
9244
  if (matchesTLogKeyBinding(event, keymap.activateLink)) {
8653
- const handled = ((_k = actions.activateLink) == null ? void 0 : _k.call(actions)) === true;
9245
+ const handled = actions.activateLink?.() === true;
8654
9246
  if (handled)
8655
- (_l = event.preventDefault) == null ? void 0 : _l.call(event);
9247
+ event.preventDefault?.();
8656
9248
  return handled;
8657
9249
  }
8658
9250
  return false;
@@ -8728,120 +9320,61 @@ var tlogHighContrastPreset = Object.freeze({
8728
9320
  keymap: tlogHighContrastKeymap
8729
9321
  });
8730
9322
  function resolveTLogViewTheme(theme) {
8731
- var _a, _b, _c, _d;
8732
9323
  return {
8733
9324
  style: theme.base,
8734
- linkStyle: (_a = theme.links) == null ? void 0 : _a.link,
8735
- linkFocusStyle: (_b = theme.links) == null ? void 0 : _b.focused,
8736
- matchStyle: (_c = theme.search) == null ? void 0 : _c.match,
8737
- currentMatchStyle: (_d = theme.search) == null ? void 0 : _d.currentMatch
9325
+ linkStyle: theme.links?.link,
9326
+ linkFocusStyle: theme.links?.focused,
9327
+ matchStyle: theme.search?.match,
9328
+ currentMatchStyle: theme.search?.currentMatch
8738
9329
  };
8739
9330
  }
8740
9331
  function resolveTLogSearchBarTheme(theme) {
8741
- var _a, _b, _c, _d;
8742
9332
  return {
8743
9333
  style: theme.base,
8744
- inputStyle: (_a = theme.search) == null ? void 0 : _a.input,
8745
- activeStyle: (_b = theme.search) == null ? void 0 : _b.active,
8746
- errorStyle: (_c = theme.search) == null ? void 0 : _c.error,
8747
- disabledStyle: (_d = theme.search) == null ? void 0 : _d.disabled,
9334
+ inputStyle: theme.search?.input,
9335
+ activeStyle: theme.search?.active,
9336
+ errorStyle: theme.search?.error,
9337
+ disabledStyle: theme.search?.disabled,
8748
9338
  toggleStyle: theme.base
8749
9339
  };
8750
9340
  }
8751
9341
  function resolveTLogSearchResultsTheme(theme) {
8752
- var _a;
8753
9342
  return {
8754
9343
  style: theme.base,
8755
- activeStyle: (_a = theme.search) == null ? void 0 : _a.active
9344
+ activeStyle: theme.search?.active
8756
9345
  };
8757
9346
  }
8758
9347
  function resolveTLogSearchPagerTheme(theme) {
8759
- var _a, _b, _c;
8760
9348
  return {
8761
9349
  style: theme.base,
8762
- activeStyle: (_a = theme.search) == null ? void 0 : _a.active,
8763
- disabledStyle: (_b = theme.search) == null ? void 0 : _b.disabled,
8764
- errorStyle: (_c = theme.search) == null ? void 0 : _c.error
9350
+ activeStyle: theme.search?.active,
9351
+ disabledStyle: theme.search?.disabled,
9352
+ errorStyle: theme.search?.error
8765
9353
  };
8766
9354
  }
8767
9355
  function resolveTLogLinksPanelTheme(theme) {
8768
- var _a;
8769
9356
  return {
8770
9357
  style: theme.base,
8771
- activeStyle: (_a = theme.links) == null ? void 0 : _a.active
9358
+ activeStyle: theme.links?.active
8772
9359
  };
8773
9360
  }
8774
9361
  function resolveTLogScrollbarTheme(theme) {
8775
- var _a, _b, _c, _d, _e;
8776
9362
  return {
8777
9363
  style: theme.base,
8778
- trackStyle: (_a = theme.scrollbar) == null ? void 0 : _a.track,
8779
- thumbStyle: (_b = theme.scrollbar) == null ? void 0 : _b.thumb,
8780
- measuringStyle: (_c = theme.scrollbar) == null ? void 0 : _c.measuring,
8781
- markerStyle: (_d = theme.scrollbar) == null ? void 0 : _d.marker,
8782
- currentMarkerStyle: (_e = theme.scrollbar) == null ? void 0 : _e.currentMarker
9364
+ trackStyle: theme.scrollbar?.track,
9365
+ thumbStyle: theme.scrollbar?.thumb,
9366
+ measuringStyle: theme.scrollbar?.measuring,
9367
+ markerStyle: theme.scrollbar?.marker,
9368
+ currentMarkerStyle: theme.scrollbar?.currentMarker
8783
9369
  };
8784
9370
  }
8785
9371
  function resolveTLogMinimapTheme(theme) {
8786
- var _a, _b, _c, _d, _e;
8787
9372
  return {
8788
9373
  style: theme.base,
8789
- densityStyle: (_a = theme.minimap) == null ? void 0 : _a.density,
8790
- viewportStyle: (_b = theme.minimap) == null ? void 0 : _b.viewport,
8791
- markerStyle: (_c = theme.minimap) == null ? void 0 : _c.marker,
8792
- currentMarkerStyle: (_d = theme.minimap) == null ? void 0 : _d.currentMarker,
8793
- estimatedStyle: (_e = theme.minimap) == null ? void 0 : _e.estimated
9374
+ densityStyle: theme.minimap?.density,
9375
+ viewportStyle: theme.minimap?.viewport,
9376
+ markerStyle: theme.minimap?.marker,
9377
+ currentMarkerStyle: theme.minimap?.currentMarker,
9378
+ estimatedStyle: theme.minimap?.estimated
8794
9379
  };
8795
9380
  }
8796
- // Annotate the CommonJS export names for ESM import in node:
8797
- 0 && (module.exports = {
8798
- TLogLinksPanel,
8799
- TLogMinimap,
8800
- TLogScrollbar,
8801
- TLogSearchBar,
8802
- TLogSearchPager,
8803
- TLogSearchResults,
8804
- TLogView,
8805
- TLogVirtualLinksPanel,
8806
- TLogVirtualSearchResults,
8807
- TVirtualList,
8808
- captureTLogViewSessionState,
8809
- createAppendOnlyLogStore,
8810
- createTLogDensityBucketsFromMarkers,
8811
- createTLogLevelPlugin,
8812
- createTLogLineMatcherPlugin,
8813
- createTLogLinkActionPlugin,
8814
- createTLogOsc8LinkPlugin,
8815
- createTLogUrlPlugin,
8816
- createTLogViewSessionStore,
8817
- deserializeTLogViewSessionState,
8818
- dispatchTLogPluginLinkAction,
8819
- getTLogPluginMetadata,
8820
- handleTLogKeymapEvent,
8821
- matchesTLogKeyBinding,
8822
- parseTLogAnnotatedText,
8823
- resolveTLogLinksPanelTheme,
8824
- resolveTLogMinimapTheme,
8825
- resolveTLogScrollbarTheme,
8826
- resolveTLogSearchBarTheme,
8827
- resolveTLogSearchPagerTheme,
8828
- resolveTLogSearchResultsTheme,
8829
- resolveTLogViewTheme,
8830
- restoreTLogViewSessionState,
8831
- serializeTLogViewSessionState,
8832
- stripTLogAnsiText,
8833
- tlogDarkPreset,
8834
- tlogDarkTheme,
8835
- tlogDefaultKeymap,
8836
- tlogDefaultPreset,
8837
- tlogDefaultTheme,
8838
- tlogHighContrastKeymap,
8839
- tlogHighContrastPreset,
8840
- tlogHighContrastTheme,
8841
- toTLogExternalLinkFromVisibleLink,
8842
- useTLogLinkController,
8843
- useTLogRetainedIndex,
8844
- useTLogSearchController,
8845
- useTLogSearchResultsPage,
8846
- useTLogVirtualSearchResults
8847
- });