@visulima/tui 1.0.0-alpha.8 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (549) hide show
  1. package/CHANGELOG.md +654 -0
  2. package/LICENSE.md +2414 -187
  3. package/README.md +49 -4
  4. package/dist/components/accordion.d.ts +59 -0
  5. package/dist/components/accordion.js +1 -0
  6. package/dist/components/alert.d.ts +26 -0
  7. package/dist/components/alert.js +1 -0
  8. package/dist/components/animate-presence.d.ts +18 -0
  9. package/dist/components/animate-presence.js +1 -0
  10. package/dist/components/approval-prompt.d.ts +65 -0
  11. package/dist/components/approval-prompt.js +1 -0
  12. package/dist/components/area-chart.d.ts +66 -0
  13. package/dist/components/area-chart.js +1 -0
  14. package/dist/components/badge.d.ts +22 -0
  15. package/dist/components/badge.js +1 -0
  16. package/dist/components/bar-chart.d.ts +67 -0
  17. package/dist/components/bar-chart.js +1 -0
  18. package/dist/components/big-text.d.ts +81 -0
  19. package/dist/components/big-text.js +1 -0
  20. package/dist/components/blink-dot.d.ts +36 -0
  21. package/dist/components/blink-dot.js +1 -0
  22. package/dist/components/box.d.ts +62 -0
  23. package/dist/components/box.js +1 -0
  24. package/dist/components/breadcrumb.d.ts +33 -0
  25. package/dist/components/breadcrumb.js +1 -0
  26. package/dist/components/button.d.ts +45 -0
  27. package/dist/components/button.js +1 -0
  28. package/dist/components/calendar.d.ts +72 -0
  29. package/dist/components/calendar.js +1 -0
  30. package/dist/components/canvas.d.ts +44 -0
  31. package/dist/components/canvas.js +1 -0
  32. package/dist/components/card.d.ts +57 -0
  33. package/dist/components/card.js +1 -0
  34. package/dist/components/checkbox.d.ts +48 -0
  35. package/dist/components/checkbox.js +1 -0
  36. package/dist/components/code.d.ts +48 -0
  37. package/dist/components/code.js +2 -0
  38. package/dist/components/collapsible.d.ts +53 -0
  39. package/dist/components/collapsible.js +1 -0
  40. package/dist/components/command-block.d.ts +47 -0
  41. package/dist/components/command-block.js +4 -0
  42. package/dist/components/command-palette.d.ts +82 -0
  43. package/dist/components/command-palette.js +1 -0
  44. package/dist/components/confirm-dialog.d.ts +75 -0
  45. package/dist/components/confirm-dialog.js +1 -0
  46. package/dist/components/confirm-input.d.ts +38 -0
  47. package/dist/components/confirm-input.js +1 -0
  48. package/dist/components/console-overlay.d.ts +54 -0
  49. package/dist/components/console-overlay.js +1 -0
  50. package/dist/components/content-switcher.d.ts +57 -0
  51. package/dist/components/content-switcher.js +1 -0
  52. package/dist/components/controlled-scroll-view.d.ts +61 -0
  53. package/dist/components/controlled-scroll-view.js +1 -0
  54. package/dist/components/cursor.d.ts +62 -0
  55. package/dist/components/cursor.js +1 -0
  56. package/dist/components/date-picker.d.ts +65 -0
  57. package/dist/components/date-picker.js +1 -0
  58. package/dist/components/definition-list.d.ts +44 -0
  59. package/dist/components/definition-list.js +1 -0
  60. package/dist/components/dialog.d.ts +117 -0
  61. package/dist/components/dialog.js +1 -0
  62. package/dist/components/diff-view.d.ts +85 -0
  63. package/dist/components/diff-view.js +1 -0
  64. package/dist/components/divider.d.ts +49 -0
  65. package/dist/components/divider.js +1 -0
  66. package/dist/components/file-picker-entry.d.ts +104 -0
  67. package/dist/components/file-picker-entry.js +1 -0
  68. package/dist/components/form.d.ts +81 -0
  69. package/dist/components/form.js +1 -0
  70. package/dist/components/gauge.d.ts +87 -0
  71. package/dist/components/gauge.js +1 -0
  72. package/dist/components/gradient.d.ts +42 -0
  73. package/dist/components/gradient.js +1 -0
  74. package/dist/components/heading.d.ts +33 -0
  75. package/dist/components/heading.js +1 -0
  76. package/dist/components/heatmap.d.ts +62 -0
  77. package/dist/components/heatmap.js +1 -0
  78. package/dist/components/help.d.ts +52 -0
  79. package/dist/components/help.js +1 -0
  80. package/dist/components/histogram.d.ts +62 -0
  81. package/dist/components/histogram.js +1 -0
  82. package/dist/components/kbd.d.ts +31 -0
  83. package/dist/components/kbd.js +1 -0
  84. package/dist/components/line-chart.d.ts +109 -0
  85. package/dist/components/line-chart.js +1 -0
  86. package/dist/components/link.d.ts +38 -0
  87. package/dist/components/link.js +1 -0
  88. package/dist/components/loading-indicator.d.ts +29 -0
  89. package/dist/components/loading-indicator.js +1 -0
  90. package/dist/components/markdown.d.ts +40 -0
  91. package/dist/components/markdown.js +1 -0
  92. package/dist/components/masked-input.d.ts +50 -0
  93. package/dist/components/masked-input.js +1 -0
  94. package/dist/components/menu.d.ts +78 -0
  95. package/dist/components/menu.js +1 -0
  96. package/dist/components/message-bubble.d.ts +43 -0
  97. package/dist/components/message-bubble.js +1 -0
  98. package/dist/components/model-badge.d.ts +39 -0
  99. package/dist/components/model-badge.js +1 -0
  100. package/dist/components/multi-select.d.ts +65 -0
  101. package/dist/components/multi-select.js +1 -0
  102. package/dist/components/newline.d.ts +15 -0
  103. package/dist/components/newline.js +2 -0
  104. package/dist/components/operation-tree.d.ts +49 -0
  105. package/dist/components/operation-tree.js +1 -0
  106. package/dist/components/option-list.d.ts +47 -0
  107. package/dist/components/option-list.js +1 -0
  108. package/dist/components/ordered-list.d.ts +24 -0
  109. package/dist/components/ordered-list.js +1 -0
  110. package/dist/components/paginator.d.ts +69 -0
  111. package/dist/components/paginator.js +1 -0
  112. package/dist/components/paragraph.d.ts +38 -0
  113. package/dist/components/paragraph.js +1 -0
  114. package/dist/components/placeholder.d.ts +55 -0
  115. package/dist/components/placeholder.js +1 -0
  116. package/dist/components/progress-bar.d.ts +56 -0
  117. package/dist/components/progress-bar.js +1 -0
  118. package/dist/components/radio-group.d.ts +74 -0
  119. package/dist/components/radio-group.js +1 -0
  120. package/dist/components/scatter-plot.d.ts +35 -0
  121. package/dist/components/scatter-plot.js +1 -0
  122. package/dist/components/scroll-bar-box.d.ts +37 -0
  123. package/dist/components/scroll-bar-box.js +1 -0
  124. package/dist/components/scroll-bar.d.ts +25 -0
  125. package/dist/components/scroll-bar.js +1 -0
  126. package/dist/components/scroll-list.d.ts +20 -0
  127. package/dist/components/scroll-list.js +1 -0
  128. package/dist/components/scroll-view.d.ts +10 -0
  129. package/dist/components/scroll-view.js +1 -0
  130. package/dist/components/search-input.d.ts +55 -0
  131. package/dist/components/search-input.js +1 -0
  132. package/dist/components/select-input-indicator.d.ts +32 -0
  133. package/dist/components/select-input-indicator.js +1 -0
  134. package/dist/components/select-input-item.d.ts +41 -0
  135. package/dist/components/select-input-item.js +1 -0
  136. package/dist/components/select-input.d.ts +110 -0
  137. package/dist/components/select-input.js +1 -0
  138. package/dist/components/shimmer-text.d.ts +47 -0
  139. package/dist/components/shimmer-text.js +1 -0
  140. package/dist/components/slider.d.ts +103 -0
  141. package/dist/components/slider.js +1 -0
  142. package/dist/components/spacer.d.ts +8 -0
  143. package/dist/components/spacer.js +1 -0
  144. package/dist/components/sparkline.d.ts +35 -0
  145. package/dist/components/sparkline.js +1 -0
  146. package/dist/components/spinner.d.ts +17 -0
  147. package/dist/components/spinner.js +1 -0
  148. package/dist/components/static-render.d.ts +55 -0
  149. package/dist/components/static-render.js +1 -0
  150. package/dist/components/static.d.ts +29 -0
  151. package/dist/components/static.js +1 -0
  152. package/dist/components/status-line.d.ts +37 -0
  153. package/dist/components/status-line.js +1 -0
  154. package/dist/components/status-message.d.ts +21 -0
  155. package/dist/components/status-message.js +1 -0
  156. package/dist/components/stepper.d.ts +48 -0
  157. package/dist/components/stepper.js +1 -0
  158. package/dist/components/stopwatch.d.ts +49 -0
  159. package/dist/components/stopwatch.js +1 -0
  160. package/dist/components/streaming-text.d.ts +46 -0
  161. package/dist/components/streaming-text.js +1 -0
  162. package/dist/components/switch.d.ts +55 -0
  163. package/dist/components/switch.js +1 -0
  164. package/dist/components/tab.d.ts +19 -0
  165. package/dist/components/tab.js +1 -0
  166. package/dist/components/table.d.ts +119 -0
  167. package/dist/components/table.js +1 -0
  168. package/dist/components/tabs.d.ts +107 -0
  169. package/dist/components/tabs.js +1 -0
  170. package/dist/components/tag.d.ts +35 -0
  171. package/dist/components/tag.js +1 -0
  172. package/dist/components/text-input.d.ts +48 -0
  173. package/dist/components/text-input.js +1 -0
  174. package/dist/components/text.d.ts +79 -0
  175. package/dist/components/text.js +1 -0
  176. package/dist/components/textarea.d.ts +68 -0
  177. package/dist/components/textarea.js +2 -0
  178. package/dist/components/timer.d.ts +59 -0
  179. package/dist/components/timer.js +1 -0
  180. package/dist/components/toast.d.ts +49 -0
  181. package/dist/components/toast.js +1 -0
  182. package/dist/components/tooltip.d.ts +43 -0
  183. package/dist/components/tooltip.js +1 -0
  184. package/dist/components/transform.d.ts +21 -0
  185. package/dist/components/transform.js +1 -0
  186. package/dist/components/transition.d.ts +74 -0
  187. package/dist/components/transition.js +1 -0
  188. package/dist/components/tree-view-entry.d.ts +357 -0
  189. package/dist/components/tree-view-entry.js +1 -0
  190. package/dist/components/unordered-list.d.ts +30 -0
  191. package/dist/components/unordered-list.js +1 -0
  192. package/dist/core/index.d.ts +2 -2
  193. package/dist/core/index.js +1 -1
  194. package/dist/ink/hooks/use-animation.d.ts +41 -0
  195. package/dist/ink/hooks/use-animation.js +1 -0
  196. package/dist/ink/hooks/use-app.d.ts +38 -0
  197. package/dist/ink/hooks/use-app.js +1 -0
  198. package/dist/ink/hooks/use-box-metrics.d.ts +66 -0
  199. package/dist/ink/hooks/use-box-metrics.js +1 -0
  200. package/dist/ink/hooks/use-clipboard.d.ts +30 -0
  201. package/dist/ink/hooks/use-clipboard.js +1 -0
  202. package/dist/ink/hooks/use-color-blindness.d.ts +33 -0
  203. package/dist/ink/hooks/use-color-blindness.js +1 -0
  204. package/dist/ink/hooks/use-console-capture.d.ts +43 -0
  205. package/dist/ink/hooks/use-console-capture.js +1 -0
  206. package/dist/ink/hooks/use-cursor.d.ts +13 -0
  207. package/dist/ink/hooks/use-cursor.js +1 -0
  208. package/dist/ink/hooks/use-focus-manager.d.ts +57 -0
  209. package/dist/ink/hooks/use-focus-manager.js +1 -0
  210. package/dist/ink/hooks/use-focus.d.ts +34 -0
  211. package/dist/ink/hooks/use-focus.js +1 -0
  212. package/dist/ink/hooks/use-form.d.ts +68 -0
  213. package/dist/ink/hooks/use-form.js +1 -0
  214. package/dist/ink/hooks/use-hotkey.d.ts +37 -0
  215. package/dist/ink/hooks/use-hotkey.js +1 -0
  216. package/dist/ink/hooks/use-input.d.ts +149 -0
  217. package/dist/ink/hooks/use-input.js +2 -0
  218. package/dist/ink/hooks/use-interval.d.ts +25 -0
  219. package/dist/ink/hooks/use-interval.js +1 -0
  220. package/dist/ink/hooks/use-is-screen-reader-enabled.d.ts +6 -0
  221. package/dist/ink/hooks/use-is-screen-reader-enabled.js +1 -0
  222. package/dist/ink/hooks/use-key-bindings.d.ts +59 -0
  223. package/dist/ink/hooks/use-key-bindings.js +1 -0
  224. package/dist/ink/hooks/use-key-chord.d.ts +25 -0
  225. package/dist/ink/hooks/use-key-chord.js +1 -0
  226. package/dist/ink/hooks/use-linked-scroll.d.ts +49 -0
  227. package/dist/ink/hooks/use-linked-scroll.js +1 -0
  228. package/dist/ink/hooks/use-paste.d.ts +45 -0
  229. package/dist/ink/hooks/use-paste.js +1 -0
  230. package/dist/ink/hooks/use-persistent-state.d.ts +65 -0
  231. package/dist/ink/hooks/use-persistent-state.js +2 -0
  232. package/dist/ink/hooks/use-scroll-acceleration.d.ts +47 -0
  233. package/dist/ink/hooks/use-scroll-acceleration.js +1 -0
  234. package/dist/ink/hooks/use-scroll-input.d.ts +34 -0
  235. package/dist/ink/hooks/use-scroll-input.js +1 -0
  236. package/dist/ink/hooks/use-stderr.d.ts +16 -0
  237. package/dist/ink/hooks/use-stderr.js +1 -0
  238. package/dist/ink/hooks/use-stdin.d.ts +30 -0
  239. package/dist/ink/hooks/use-stdin.js +1 -0
  240. package/dist/ink/hooks/use-stdout.d.ts +16 -0
  241. package/dist/ink/hooks/use-stdout.js +1 -0
  242. package/dist/ink/hooks/use-stopwatch.d.ts +39 -0
  243. package/dist/ink/hooks/use-stopwatch.js +1 -0
  244. package/dist/ink/hooks/use-terminal-palette.d.ts +20 -0
  245. package/dist/ink/hooks/use-terminal-palette.js +1 -0
  246. package/dist/ink/hooks/use-text-buffer.d.ts +42 -0
  247. package/dist/ink/hooks/use-text-buffer.js +4 -0
  248. package/dist/ink/hooks/use-text-selection.d.ts +45 -0
  249. package/dist/ink/hooks/use-text-selection.js +1 -0
  250. package/dist/ink/hooks/use-timeout.d.ts +24 -0
  251. package/dist/ink/hooks/use-timeout.js +1 -0
  252. package/dist/ink/hooks/use-timer.d.ts +48 -0
  253. package/dist/ink/hooks/use-timer.js +1 -0
  254. package/dist/ink/hooks/use-window-size.d.ts +18 -0
  255. package/dist/ink/hooks/use-window-size.js +1 -0
  256. package/dist/ink/index.d.ts +30 -6251
  257. package/dist/ink/index.js +1 -1
  258. package/dist/ink/mouse/use-element-position.d.ts +31 -0
  259. package/dist/ink/mouse/use-element-position.js +1 -0
  260. package/dist/ink/mouse/use-mouse-action.d.ts +5 -0
  261. package/dist/ink/mouse/use-mouse-action.js +1 -0
  262. package/dist/ink/mouse/use-mouse-position.d.ts +5 -0
  263. package/dist/ink/mouse/use-mouse-position.js +1 -0
  264. package/dist/ink/mouse/use-mouse.d.ts +5 -0
  265. package/dist/ink/mouse/use-mouse.js +1 -0
  266. package/dist/ink/mouse/use-on-mouse-click.d.ts +16 -0
  267. package/dist/ink/mouse/use-on-mouse-click.js +1 -0
  268. package/dist/ink/mouse/use-on-mouse-hover.d.ts +10 -0
  269. package/dist/ink/mouse/use-on-mouse-hover.js +1 -0
  270. package/dist/ink/mouse/use-on-mouse-state.d.ts +13 -0
  271. package/dist/ink/mouse/use-on-mouse-state.js +1 -0
  272. package/dist/packem_chunks/devtools.js +1 -1
  273. package/dist/packem_shared/COLOR_BLINDNESS_COMPENSATION-Ilnoyeqc.js +1 -0
  274. package/dist/packem_shared/ControlledScrollView-Cn4byU2n.js +1 -0
  275. package/dist/packem_shared/DevTools-k6uiVzqv.js +1 -0
  276. package/dist/packem_shared/FilePicker-BLS9nOPz.js +1 -0
  277. package/dist/packem_shared/FocusContext-C2Sosxa4.js +1 -0
  278. package/dist/packem_shared/Fullscreen-BRhuBLBh.js +1 -0
  279. package/dist/packem_shared/IMECompositionBuffer-VhC9HRCv.js +1 -0
  280. package/dist/packem_shared/InputParser-CtwkCbrQ.js +2 -0
  281. package/dist/packem_shared/KEY-C--kOw41.js +1 -0
  282. package/dist/packem_shared/LayoutNode-LPYsuzBg.js +1 -0
  283. package/dist/packem_shared/MouseProvider-DUqQ3Eaa.js +1 -0
  284. package/dist/packem_shared/NAMED_COLORS-82DpREQV.js +1 -0
  285. package/dist/packem_shared/Range-BsVYNWtg.js +1 -0
  286. package/dist/packem_shared/Renderer-DsskdkUd.js +1 -0
  287. package/dist/packem_shared/ResizeObserver-BI9bDy-j.js +1 -0
  288. package/dist/packem_shared/ScrollBar-qa1IzDDv.js +1 -0
  289. package/dist/packem_shared/ScrollBarBox-DchESZWv.js +1 -0
  290. package/dist/packem_shared/ScrollList-BBAnRsrC.js +1 -0
  291. package/dist/packem_shared/ScrollView-CHAo7Epj.js +1 -0
  292. package/dist/packem_shared/Static-DSzsElz4.js +1 -0
  293. package/dist/packem_shared/TreeNodeMap-cJlYqckB.js +1 -0
  294. package/dist/packem_shared/TreeView-BsvLCsf0.js +1 -0
  295. package/dist/packem_shared/TuiApp-BPL8v1i1.js +1 -0
  296. package/dist/packem_shared/TuiContext-BNmP0lMY.js +3 -0
  297. package/dist/packem_shared/ansi-parser-DlgLtOYO.js +1 -0
  298. package/dist/packem_shared/ansi-tokenizer-BU67A126.js +1 -0
  299. package/dist/packem_shared/braille-ch3O5D7I.js +1 -0
  300. package/dist/packem_shared/buffer.d-EJkZr8uH.d.ts +39 -0
  301. package/dist/packem_shared/calculateScroll-D4Y_JR4H.js +1 -0
  302. package/dist/packem_shared/{measureElement-DA8WqFP_.js → calculateScrollbarLayout-Lf6i24c9.js} +1 -1
  303. package/dist/packem_shared/clearOsc52-BUpnQOav.js +1 -0
  304. package/dist/packem_shared/clearStringWidthCache-DKFjfJuB.js +1 -0
  305. package/dist/packem_shared/clipboard.d-D6lZTQ21.d.ts +23 -0
  306. package/dist/packem_shared/color-matrix.d-DSXLsB64.d.ts +50 -0
  307. package/dist/packem_shared/colorize-DU4YZkp3.js +1 -0
  308. package/dist/packem_shared/controlled-scroll-view-BVg7ywNW.js +1 -0
  309. package/dist/packem_shared/createInlineLoop-BT40Wpmx.js +2 -0
  310. package/dist/packem_shared/createScreen-DoYpyL0V.js +3 -0
  311. package/dist/packem_shared/cursor-helpers.d-BONB9tky.d.ts +12 -0
  312. package/dist/packem_shared/dom-rphpG0kf.js +1 -0
  313. package/dist/packem_shared/dom.d-B4kXbaVY.d.ts +449 -0
  314. package/dist/packem_shared/format-time-fjoQHMxD.js +1 -0
  315. package/dist/packem_shared/{getPathToRoot-B2tKmx3i.js → getPathToRoot-PDJeqiEH.js} +1 -1
  316. package/dist/packem_shared/input-utils-BSWCb4F_.js +1 -0
  317. package/dist/packem_shared/{input.d-Bfq7oc06.d.ts → input.d-CgxV2e8U.d.ts} +1 -1
  318. package/dist/packem_shared/isIntersecting-Bo2npvMR.js +1 -0
  319. package/dist/packem_shared/isTerminalPaletteQuerySupported-BYzmqq9-.js +1 -0
  320. package/dist/packem_shared/kittyFlags-g8ALyoCU.js +1 -0
  321. package/dist/packem_shared/line-chart-C7CUrvVs.js +1 -0
  322. package/dist/packem_shared/load-native-root-binding-DDikxNox.js +1 -0
  323. package/dist/packem_shared/measure-element-D4M9iSYp.js +1 -0
  324. package/dist/packem_shared/measure-text-B7juNq4Y.js +3 -0
  325. package/dist/packem_shared/mouse-context.d-BfL9xGk_.d.ts +30 -0
  326. package/dist/packem_shared/parseSgrMouse-bUrqPrh-.js +1 -0
  327. package/dist/packem_shared/processLayout-I83k6vXE.js +2 -0
  328. package/dist/packem_shared/reconciler-CFyBVf7l.js +1 -0
  329. package/dist/packem_shared/reconciler-ClpU7Y-V.js +1 -0
  330. package/dist/packem_shared/render-CuQecTAs.js +24 -0
  331. package/dist/packem_shared/render-DFZ8NHlG.js +1 -0
  332. package/dist/packem_shared/render.d-CBnYBDk2.d.ts +417 -0
  333. package/dist/packem_shared/renderToString-DwXFY8Qh.js +4 -0
  334. package/dist/packem_shared/renderToString-L_bpw4OQ.js +2 -0
  335. package/dist/packem_shared/renderTreeToBuffer-C8lS0lJ2.js +2 -0
  336. package/dist/packem_shared/renderer-k-xShm1P.js +17 -0
  337. package/dist/packem_shared/scroll-view.d-DtpsgHLg.d.ts +119 -0
  338. package/dist/packem_shared/selection.d-CI3_p8wg.d.ts +62 -0
  339. package/dist/packem_shared/squashTextNodesWithMap-BmUSBPfc.js +1 -0
  340. package/dist/packem_shared/stderr-context-Bvnik0hL.js +1 -0
  341. package/dist/packem_shared/stdin-context-88AhuztD.js +1 -0
  342. package/dist/packem_shared/styles.d-cMo36xQz.d.ts +396 -0
  343. package/dist/packem_shared/terminal-palette.d-D2SQjfn-.d.ts +19 -0
  344. package/dist/packem_shared/text-width-e49vlbQH.js +2 -0
  345. package/dist/packem_shared/token-to-elements-D6J6-P2A.js +1 -0
  346. package/dist/packem_shared/treeViewTheme-Dq3ekRAC.js +1 -0
  347. package/dist/packem_shared/useTreeView-D5ifGwG3.js +1 -0
  348. package/dist/packem_shared/useTreeViewState-BiTJakkh.js +1 -0
  349. package/dist/packem_shared/utils-Bup8lyK8.js +1 -0
  350. package/dist/packem_shared/variant-config.d-D5NnrrQK.d.ts +2 -0
  351. package/dist/packem_shared/waitFor-CTAki32d.js +4 -0
  352. package/dist/packem_shared/wrapOrTruncateStyledLine-46W8bTtv.js +3 -0
  353. package/dist/react/index.d.ts +2 -2
  354. package/dist/react/index.js +1 -1
  355. package/dist/testing/index.d.ts +5 -1
  356. package/dist/testing/index.js +1 -1
  357. package/index.js +550 -692
  358. package/package.json +583 -32
  359. package/dist/packem_shared/Accordion-BXsqchV-.js +0 -1
  360. package/dist/packem_shared/Alert-BhYVMHtR.js +0 -1
  361. package/dist/packem_shared/AnimatePresence-Eu7Z8KHc.js +0 -1
  362. package/dist/packem_shared/ApprovalPrompt-BSn0FT1g.js +0 -1
  363. package/dist/packem_shared/AreaChart-Chy-frI7.js +0 -1
  364. package/dist/packem_shared/Badge-B8WPyRsK.js +0 -1
  365. package/dist/packem_shared/BarChart-rpZtlMcF.js +0 -1
  366. package/dist/packem_shared/BigText-CRpwUzrt.js +0 -1
  367. package/dist/packem_shared/BlinkDot-BvnRuWP8.js +0 -1
  368. package/dist/packem_shared/Box-BwqSvWuq.js +0 -1
  369. package/dist/packem_shared/Breadcrumb-D0hClbRV.js +0 -1
  370. package/dist/packem_shared/Button-B89Yvbc6.js +0 -1
  371. package/dist/packem_shared/COLOR_BLINDNESS_SIMULATION-DqErf7XX.js +0 -1
  372. package/dist/packem_shared/Calendar-Dmflvm2S.js +0 -1
  373. package/dist/packem_shared/Canvas-CKg6WV47.js +0 -1
  374. package/dist/packem_shared/Card-B_9fXdtU.js +0 -1
  375. package/dist/packem_shared/Checkbox-BN71eCWU.js +0 -1
  376. package/dist/packem_shared/Code-HhevcyiH.js +0 -2
  377. package/dist/packem_shared/Collapsible-u6uf_FdV.js +0 -1
  378. package/dist/packem_shared/CommandBlock-B-nslpCv.js +0 -4
  379. package/dist/packem_shared/CommandPalette-CEFdaURo.js +0 -1
  380. package/dist/packem_shared/ConfirmDialog-5Jje_Xpu.js +0 -1
  381. package/dist/packem_shared/ConfirmInput-D44Mb9oo.js +0 -1
  382. package/dist/packem_shared/ConsoleOverlay-CM3APfgP.js +0 -1
  383. package/dist/packem_shared/ContentSwitcher-Dm5BkrCt.js +0 -1
  384. package/dist/packem_shared/ControlledScrollView-DI8KZOQB.js +0 -1
  385. package/dist/packem_shared/Cursor-BoLFIMol.js +0 -1
  386. package/dist/packem_shared/DatePicker-CnSrFFAE.js +0 -1
  387. package/dist/packem_shared/DefinitionList-v8RDuF_R.js +0 -1
  388. package/dist/packem_shared/DevTools-O8EbCfHa.js +0 -1
  389. package/dist/packem_shared/Dialog-CTaL8pn0.js +0 -1
  390. package/dist/packem_shared/DiffView-BUIFqUB0.js +0 -1
  391. package/dist/packem_shared/Divider-C47bKmqu.js +0 -1
  392. package/dist/packem_shared/FilePicker-CUo7R5Qb.js +0 -1
  393. package/dist/packem_shared/FocusContext-Xy0cwJpO.js +0 -1
  394. package/dist/packem_shared/FormField-af3aUpRL.js +0 -1
  395. package/dist/packem_shared/Fullscreen-CuJ8y0s0.js +0 -1
  396. package/dist/packem_shared/Gauge-Dz-usH__.js +0 -1
  397. package/dist/packem_shared/Gradient-DYNc0GZA.js +0 -1
  398. package/dist/packem_shared/Heading-mwEYza3Y.js +0 -1
  399. package/dist/packem_shared/Heatmap-ChL97U1-.js +0 -1
  400. package/dist/packem_shared/Help-Zcelyw_U.js +0 -1
  401. package/dist/packem_shared/Histogram-FIf2F83d.js +0 -1
  402. package/dist/packem_shared/IMECompositionBuffer-C89PhiOu.js +0 -1
  403. package/dist/packem_shared/InputParser-rZKjY_7Y.js +0 -2
  404. package/dist/packem_shared/KEY-Bk8B-3h_.js +0 -1
  405. package/dist/packem_shared/Kbd-DpkPp4jB.js +0 -1
  406. package/dist/packem_shared/LayoutNode-rxblE317.js +0 -1
  407. package/dist/packem_shared/LineChart-BXE_girm.js +0 -1
  408. package/dist/packem_shared/Link-i2o2EG4-.js +0 -1
  409. package/dist/packem_shared/LoadingIndicator-TC1Fjwyt.js +0 -1
  410. package/dist/packem_shared/Markdown-R1XqK63D.js +0 -1
  411. package/dist/packem_shared/MaskedInput-J01phOZs.js +0 -1
  412. package/dist/packem_shared/Menu-CfrH4ymk.js +0 -1
  413. package/dist/packem_shared/MessageBubble-BmBBU2Rm.js +0 -1
  414. package/dist/packem_shared/ModelBadge-D3wrXncu.js +0 -1
  415. package/dist/packem_shared/MouseProvider-pjza-lpc.js +0 -1
  416. package/dist/packem_shared/MultiSelect-Dqmn-bVo.js +0 -1
  417. package/dist/packem_shared/NAMED_COLORS-B9fJsYdg.js +0 -1
  418. package/dist/packem_shared/Newline-BSG4iUqp.js +0 -2
  419. package/dist/packem_shared/OperationTree-DksxjMIV.js +0 -1
  420. package/dist/packem_shared/OptionList-CNx7r9yN.js +0 -1
  421. package/dist/packem_shared/OrderedList-BeDy035w.js +0 -1
  422. package/dist/packem_shared/Paginator-B56s6bhS.js +0 -1
  423. package/dist/packem_shared/Paragraph-BqJlH0R-.js +0 -1
  424. package/dist/packem_shared/Placeholder-GMpHRGC8.js +0 -1
  425. package/dist/packem_shared/ProgressBar-Bj3fmORR.js +0 -1
  426. package/dist/packem_shared/RadioGroup-Br8BeEwS.js +0 -1
  427. package/dist/packem_shared/Renderer-DJXooAsp.js +0 -1
  428. package/dist/packem_shared/ResizeObserverEntry-Dq0dk8Kq.js +0 -1
  429. package/dist/packem_shared/ScatterPlot-OhfYco5l.js +0 -1
  430. package/dist/packem_shared/ScrollBar-Da5Y3z7N.js +0 -1
  431. package/dist/packem_shared/ScrollBarBox-Dz6F-Eat.js +0 -1
  432. package/dist/packem_shared/ScrollList-DiVGyEjv.js +0 -1
  433. package/dist/packem_shared/ScrollView-BojONotI.js +0 -1
  434. package/dist/packem_shared/SearchInput-BoPTRbhV.js +0 -1
  435. package/dist/packem_shared/SelectInput-CAJ7SCBq.js +0 -1
  436. package/dist/packem_shared/SelectInputIndicator-N1n8ULHs.js +0 -1
  437. package/dist/packem_shared/SelectInputItem-BEkbmobs.js +0 -1
  438. package/dist/packem_shared/ShimmerText-CuGQ2NDC.js +0 -1
  439. package/dist/packem_shared/Slider-Cg_tJpKa.js +0 -1
  440. package/dist/packem_shared/Spacer-eT3HOrXk.js +0 -1
  441. package/dist/packem_shared/Sparkline-T6_FPVET.js +0 -1
  442. package/dist/packem_shared/Spinner-B0-A50pu.js +0 -1
  443. package/dist/packem_shared/Static-DLynr5pn.js +0 -1
  444. package/dist/packem_shared/Static-jzLPaHJF.js +0 -1
  445. package/dist/packem_shared/StaticRender-BgD61E7x.js +0 -1
  446. package/dist/packem_shared/StatusLine-Ch4jjef1.js +0 -1
  447. package/dist/packem_shared/StatusMessage-B1qfKeMM.js +0 -1
  448. package/dist/packem_shared/Stepper-CNPAqxiU.js +0 -1
  449. package/dist/packem_shared/Stopwatch-CAx2EWwq.js +0 -1
  450. package/dist/packem_shared/StreamingText-BYOKSB2T.js +0 -1
  451. package/dist/packem_shared/Switch-DzSpKYu7.js +0 -1
  452. package/dist/packem_shared/Tab-BcXzSUdj.js +0 -1
  453. package/dist/packem_shared/Table-DJp1TLrR.js +0 -1
  454. package/dist/packem_shared/Tabs-D68z0SOt.js +0 -1
  455. package/dist/packem_shared/Tag-BvLHnYRn.js +0 -1
  456. package/dist/packem_shared/Text-mTAve9R2.js +0 -1
  457. package/dist/packem_shared/TextInput-C_gYQlnF.js +0 -1
  458. package/dist/packem_shared/Textarea-C2ET_oMb.js +0 -2
  459. package/dist/packem_shared/Timer-CI3aQX65.js +0 -1
  460. package/dist/packem_shared/Toast-Drvc8XfG.js +0 -1
  461. package/dist/packem_shared/Tooltip-C5UnQlLd.js +0 -1
  462. package/dist/packem_shared/Transform-fYmcdqRT.js +0 -1
  463. package/dist/packem_shared/Transition-CJDBKYUB.js +0 -1
  464. package/dist/packem_shared/TreeNodeMap-CspqSCpb.js +0 -1
  465. package/dist/packem_shared/TreeView-DjhacGJ5.js +0 -1
  466. package/dist/packem_shared/TuiApp-DrjI_i-R.js +0 -1
  467. package/dist/packem_shared/TuiContext-BoJvG3NN.js +0 -3
  468. package/dist/packem_shared/UnorderedList-BnfqexZs.js +0 -1
  469. package/dist/packem_shared/ansi-parser-B6uXaq65.js +0 -1
  470. package/dist/packem_shared/ansi-tokenizer-DqX9nJuk.js +0 -1
  471. package/dist/packem_shared/boxes-DyY_LXCi.js +0 -1
  472. package/dist/packem_shared/braille-BBjIoaN0.js +0 -1
  473. package/dist/packem_shared/colorize-DbTZMrJO.js +0 -1
  474. package/dist/packem_shared/comparePoints-C85EsmNz.js +0 -1
  475. package/dist/packem_shared/controlled-scroll-view-CmrAEvJk.js +0 -1
  476. package/dist/packem_shared/createInlineLoop-DRNZ7jqH.js +0 -2
  477. package/dist/packem_shared/createLinkedScrollGroup-BMTJ7rAj.js +0 -1
  478. package/dist/packem_shared/createMemoryStorage-QVZNXbWz.js +0 -2
  479. package/dist/packem_shared/createScreen-CrLrxA6t.js +0 -3
  480. package/dist/packem_shared/dom-4y__5fWB.js +0 -1
  481. package/dist/packem_shared/format-time-C7Q-hQZq.js +0 -1
  482. package/dist/packem_shared/getScrollHeight-BTEY8ewu.js +0 -1
  483. package/dist/packem_shared/input-utils-fAxzSlNh.js +0 -1
  484. package/dist/packem_shared/isIntersecting-B3KbKTmu.js +0 -1
  485. package/dist/packem_shared/isOsc52Supported-DKK7Uee6.js +0 -1
  486. package/dist/packem_shared/isTerminalPaletteQuerySupported-Dn2hFAZ_.js +0 -1
  487. package/dist/packem_shared/kittyFlags-C3rZLbcK.js +0 -1
  488. package/dist/packem_shared/line-chart-DrM8PwnI.js +0 -1
  489. package/dist/packem_shared/measure-element-DSp7YDus.js +0 -2
  490. package/dist/packem_shared/measure-text-DDjHT1jD.js +0 -3
  491. package/dist/packem_shared/parseSgrMouse-Ccj70ijb.js +0 -1
  492. package/dist/packem_shared/processLayout-DXDfFb_d.js +0 -1
  493. package/dist/packem_shared/reconciler-BuOP-TZ6.js +0 -1
  494. package/dist/packem_shared/reconciler-DSYCrIZs.js +0 -1
  495. package/dist/packem_shared/render-DDqtMAFN.js +0 -1
  496. package/dist/packem_shared/render-_r0K9K11.js +0 -28
  497. package/dist/packem_shared/render.d-BR3gA-N8.d.ts +0 -1257
  498. package/dist/packem_shared/renderToString-DeqOWRP8.js +0 -4
  499. package/dist/packem_shared/renderToString-IYYPyASm.js +0 -2
  500. package/dist/packem_shared/renderTreeToBuffer-DPkoCgP2.js +0 -2
  501. package/dist/packem_shared/renderer-D2p6av2X.js +0 -17
  502. package/dist/packem_shared/setEnableStyledLineCache-D2gZbwFM.js +0 -1
  503. package/dist/packem_shared/squashTextNodesWithMap-Cpqmc45i.js +0 -1
  504. package/dist/packem_shared/stderr-context-BzEaUICS.js +0 -1
  505. package/dist/packem_shared/stdin-context-BTaaFagk.js +0 -1
  506. package/dist/packem_shared/text-width-CZ9vPvM0.js +0 -2
  507. package/dist/packem_shared/token-to-elements-BYxT6J_Q.js +0 -1
  508. package/dist/packem_shared/treeViewTheme-1RIZyB4M.js +0 -1
  509. package/dist/packem_shared/useAnimation-B9we6ZzL.js +0 -1
  510. package/dist/packem_shared/useApp-B6fvM42d.js +0 -1
  511. package/dist/packem_shared/useBoxMetrics-D5pkIr6P.js +0 -1
  512. package/dist/packem_shared/useClipboard-CBxy0hT8.js +0 -1
  513. package/dist/packem_shared/useColorBlindness-BvWcu2Bb.js +0 -1
  514. package/dist/packem_shared/useConsoleCapture-BxiG8iLJ.js +0 -1
  515. package/dist/packem_shared/useCursor-CPu8T5Db.js +0 -1
  516. package/dist/packem_shared/useElementDimensions-qJ_WXFZ9.js +0 -1
  517. package/dist/packem_shared/useFocus-DSmziO_x.js +0 -1
  518. package/dist/packem_shared/useFocusManager-Uapn3LQo.js +0 -1
  519. package/dist/packem_shared/useForm-CzV-Oext.js +0 -1
  520. package/dist/packem_shared/useHotkey-D0dGey14.js +0 -1
  521. package/dist/packem_shared/useInput-D1_jG26Z.js +0 -2
  522. package/dist/packem_shared/useInterval-AobjZT3u.js +0 -1
  523. package/dist/packem_shared/useIsScreenReaderEnabled-DjWHh-II.js +0 -1
  524. package/dist/packem_shared/useKeyBindings-zabkEJQs.js +0 -1
  525. package/dist/packem_shared/useKeyChord-CICQIxXj.js +0 -1
  526. package/dist/packem_shared/useMouseAction-2dRfU1vE.js +0 -1
  527. package/dist/packem_shared/useMouseContext-C746G7kY.js +0 -1
  528. package/dist/packem_shared/useMousePosition-BTWfV4JK.js +0 -1
  529. package/dist/packem_shared/useOnMouseClick-nY8xLZmt.js +0 -1
  530. package/dist/packem_shared/useOnMouseHover-D3DczIol.js +0 -1
  531. package/dist/packem_shared/useOnMouseState-cRK8QvzD.js +0 -1
  532. package/dist/packem_shared/usePaste-CKKB9H-Z.js +0 -1
  533. package/dist/packem_shared/useScrollAcceleration-NrY1oVMs.js +0 -1
  534. package/dist/packem_shared/useScrollInput-Caghtn-Q.js +0 -1
  535. package/dist/packem_shared/useStderr-BDZb6InG.js +0 -1
  536. package/dist/packem_shared/useStdin-DKa4h35k.js +0 -1
  537. package/dist/packem_shared/useStdout-B-2lX4C5.js +0 -1
  538. package/dist/packem_shared/useStopwatch-DffK7iMh.js +0 -1
  539. package/dist/packem_shared/useTerminalPalette-Cv7tSduR.js +0 -1
  540. package/dist/packem_shared/useTextBuffer-DekkGLxI.js +0 -4
  541. package/dist/packem_shared/useTextSelection-CGT0GLDR.js +0 -1
  542. package/dist/packem_shared/useTimeout-7LEFYTnG.js +0 -1
  543. package/dist/packem_shared/useTimer-DyoqSyGi.js +0 -1
  544. package/dist/packem_shared/useTreeView-8UlTK6sW.js +0 -1
  545. package/dist/packem_shared/useTreeViewState-CRPCUWrb.js +0 -1
  546. package/dist/packem_shared/useWindowSize-yDZsXF8z.js +0 -1
  547. package/dist/packem_shared/utils-THUhYKG2.js +0 -1
  548. package/dist/packem_shared/waitFor-Dj5zfL5s.js +0 -4
  549. package/dist/packem_shared/wrapOrTruncateStyledLine-BZ00SM8i.js +0 -3
@@ -0,0 +1 @@
1
+ import{createContext as C}from"react";import y from"react-reconciler";import{NoEventPriority as h,DiscreteEventPriority as v,DefaultEventPriority as b}from"react-reconciler/constants.js";import{unstable_shouldYield as T,unstable_scheduleCallback as x,unstable_now as k,unstable_cancelCallback as I}from"scheduler";import{LayoutNode as c}from"./LayoutNode-LPYsuzBg.js";import{applyStyles as m,resolveColor as f}from"./NAMED_COLORS-82DpREQV.js";import{g as P}from"./text-width-e49vlbQH.js";let u=null;function H(e){u=e}let d=h;function p(e){const t=f(e.fg===void 0?e.color===void 0?void 0:e.color:e.fg),n=f(e.bg===void 0?e.backgroundColor===void 0?void 0:e.backgroundColor:e.bg);let r;return e.styles===void 0?(r=0,e.bold&&(r|=1),(e.dim||e.dimColor)&&(r|=2),e.italic&&(r|=4),e.underline&&(r|=8),e.blink&&(r|=16),e.inverse&&(r|=32),e.hidden&&(r|=64),e.strikethrough&&(r|=128)):r=e.styles,{bg:n,fg:t,styles:r}}const N={afterActiveInstanceBlur:()=>{},appendChild(e,t){e.insertChild(t,e.children.length)},appendChildToContainer(e,t){e.insertChild(t,e.children.length)},appendInitialChild(e,t){e.insertChild(t,e.children.length)},beforeActiveInstanceBlur:()=>{},cancelCallback:I,cancelTimeout:clearTimeout,clearContainer(e){},commitTextUpdate(e,t,n){e.text=n,e.yogaNode.markDirty()},commitUpdate(e,t,n,r,s){m(e.yogaNode,r);const{bg:o,fg:i,styles:a}=p(r);e.fg=i,e.bg=o,e.styles=a,e._style=r,e.transform=typeof r.transform=="function"?r.transform:void 0},createInstance(e,t,n,r,s){const o=new c,i={...t};i.flexDirection===void 0&&(i.flexDirection="row"),i.flexShrink===void 0&&(i.flexShrink=1),m(o.yogaNode,i);const{bg:a,fg:l,styles:g}=p(t);return o.fg=l,o.bg=a,o.styles=g,o._style=t,typeof t.transform=="function"&&(o.transform=t.transform),o},createTextInstance(e,t,n,r){const s=new c;return s.text=e,s.yogaNode.setWidth(P(e)),s.yogaNode.setHeight(1),s},detachDeletedInstance:e=>{e.destroy()},finalizeInitialChildren(e,t,n,r,s){return!1},getChildHostContext(e,t,n){return{isInsideText:t==="text"}},getCurrentEventPriority:()=>v,getCurrentUpdatePriority:()=>d,getInstanceFromNode:()=>null,getPublicInstance(e){return e},getRootHostContext(e){return{isInsideText:!1}},hideInstance(e){e._hidden=!0},hideTextInstance(e){e._hidden=!0},HostTransitionContext:C(null),insertBefore(e,t,n){t.parent&&t.remove();const r=e.children.indexOf(n);e.insertChild(t,r)},isPrimaryRenderer:!0,maySuspendCommit:()=>!0,noTimeout:-1,NotPendingTransition:void 0,now:k,preloadInstance:()=>!0,prepareForCommit(e){return null},preparePortalMount:()=>{},prepareScopeUpdate:()=>{},prepareUpdate(e,t,n,r,s,o){if(n===r)return null;let i=0;for(const l of Object.keys(n))l!=="children"&&(i+=1);let a=0;for(const l of Object.keys(r))if(l!=="children"&&(a+=1,n[l]!==r[l]))return!0;return i===a?null:!0},removeChild(e,t){t.remove()},removeChildFromContainer(e,t){t.remove()},requestPostPaintCallback:()=>{},resetAfterCommit(e){typeof u=="function"&&u()},resolveEventTimeStamp:()=>-1.1,resolveEventType:()=>null,resolveUpdatePriority(){return d!==h?d:b},scheduleCallback:x,scheduleMicrotask:queueMicrotask,scheduleTimeout:setTimeout,setCurrentUpdatePriority(e){d=e},shouldAttemptEagerTransition:()=>!1,shouldSetTextContent(e,t){return!1},shouldYield:T,startSuspendingCommit:()=>{},supportsHydration:!1,supportsMicrotasks:!0,supportsMutation:!0,supportsPersistence:!1,suspendInstance:()=>{},trackSchedulerEvent:()=>{},unhideInstance(e,t){e._hidden=!1},unhideTextInstance(e,t){e._hidden=!1},waitForCommitToBeReady:()=>null,warnsIfNotActing:!0},M=y(N);export{M as T,H as s};
@@ -0,0 +1,24 @@
1
+ import{createRequire as we}from"node:module";import{jsxs as W,jsx as x}from"react/jsx-runtime";import{cursorShow as nt,setMode as Vt,BracketedPasteMode as Xt,resetMode as Zt,cursorUp as yt,cursorTo as Ct,cursorHide as q,cursorDown as Te,setCursorStyle as Re,eraseLines as j,cursorNextLine as Se,eraseLineEnd as Ee,createDecMode as Oe,ALT_SCREEN_ON as Pe,clearScreenAndHomeCursor as Ne,ALT_SCREEN_OFF as ke}from"@visulima/ansi";import{wordWrap as De}from"@visulima/string";import Jt from"is-in-ci";import Le from"patch-console";import{ConcurrentRoot as Ie,LegacyRoot as We}from"react-reconciler/constants.js";import{onExit as $e}from"signal-exit";import A from"yoga-layout";import{a as Me}from"./accessibility-context-DDyHTwmA.js";import{PureComponent as Ae,useState as ct,useRef as $,useCallback as y,useEffect as vt,useMemo as F}from"react";import{e as Be}from"./animation-context-DW3p-vpk.js";import{t as He}from"./app-context-BVpKlG1z.js";import{o as Ue}from"./cursor-context-CFviBqPX.js";import{parseStacktrace as Ye}from"@visulima/error/stacktrace";import je from"code-excerpt";import{Box as _}from"../components/box.js";import{Text as M}from"../components/text.js";import{o as qe}from"./focus-context-CsT69klR.js";import{t as ze}from"./stderr-context-Bvnik0hL.js";import{e as Ge}from"./stdin-context-88AhuztD.js";import{t as Ve}from"./stdout-context-BnblEPez.js";import{I as Xe,_ as Ze,r as Je,H as Qe}from"./renderer-k-xShm1P.js";import{c as ti,e as ei}from"./dom-rphpG0kf.js";import{resolveFlags as ii}from"./kittyFlags-g8ALyoCU.js";import{p as ri}from"./load-native-root-binding-DDikxNox.js";import{a as si}from"./measure-text-B7juNq4Y.js";import{j as L,c as oi}from"./reconciler-CFyBVf7l.js";import{measureAndExtractObservers as ni}from"./ResizeObserver-BI9bDy-j.js";import{calculateScroll as ui}from"./calculateScroll-D4Y_JR4H.js";import{g as X}from"./utils-Bup8lyK8.js";const be=we(import.meta.url),Q=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ot=e=>{if(typeof Q<"u"&&Q.versions&&Q.versions.node){const[t,i]=Q.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return Q.getBuiltinModule(e)}return be(e)},k=Q,{cwd:ye}=k,{Stream:xe}=ot("node:stream"),{Buffer:Ht}=ot("node:buffer"),{Console:Ce}=ot("node:console"),{EventEmitter:_e}=ot("node:events"),{existsSync:Ke,readFileSync:Fe}=ot("node:fs"),Qt="\x1B[200~",Ut="\x1B[201~",ai=e=>e>=48&&e<=63,li=e=>e>=32&&e<=47,te=e=>e>=64&&e<=126,di=(e,t,i)=>{const r=t+i+1;let o=r;for(;o<e.length;o++){const u=e.codePointAt(o);if(u===void 0)return"pending";if(!(ai(u)||li(u))&&!(u===91&&o===r))return te(u)?{nextIndex:o+1,sequence:e.slice(t,o+1)}:void 0}return"pending"},ci=(e,t,i)=>{const r=t+i+2;if(r>e.length)return"pending";const o=e.codePointAt(r-1);if(!(o===void 0||!te(o)))return{nextIndex:r,sequence:e.slice(t,r)}},Kt=(e,t,i)=>{const r=e[t+i];if(r===void 0)return"pending";if(r==="[")return di(e,t,i);if(r==="O")return ci(e,t,i)},hi=(e,t)=>{const i=e.codePointAt(t+1),r=i!==void 0&&i>65535?2:1,o=t+1+r;return{nextIndex:o,sequence:e.slice(t,o)}},fi=(e,t)=>{if(t===e.length-1)return"pending";if(e[t+1]==="\x1B"){if(t+2>=e.length)return"pending";const r=Kt(e,t,2);return r==="pending"?"pending":r||{nextIndex:t+2,sequence:e.slice(t,t+2)}}const i=Kt(e,t,1);return i==="pending"?"pending":i||hi(e,t)},Ft=(e,t)=>{let i=0;for(let r=0;r<e.length;r++){const o=e[r];(o===""||o==="\b")&&(r>i&&t.push(e.slice(i,r)),t.push(o),i=r+1)}i<e.length&&t.push(e.slice(i))},pi=e=>{const t=[];let i=0;const r=o=>({events:t,pending:e.slice(o)});for(;i<e.length;){const o=e.indexOf("\x1B",i);if(o===-1)return Ft(e.slice(i),t),{events:t,pending:""};o>i&&Ft(e.slice(i,o),t);const u=fi(e,o);if(u==="pending")return r(o);if(u.sequence===Qt){const l=u.nextIndex,n=e.indexOf(Ut,l);if(n===-1)return r(o);t.push({paste:e.slice(l,n)}),i=n+Ut.length;continue}t.push(u.sequence),i=u.nextIndex}return{events:t,pending:""}},mi=()=>{let e="";return{flushPendingEscape(){if(!e.startsWith("\x1B"))return;const t=e;return e="",t},hasPendingEscape(){return e.startsWith("\x1B")&&!e.startsWith(Qt)&&e!=="\x1B[200"},push(t){const i=pi(e+t);return e=i.pending,i.events},reset(){e=""}}},wt=e=>{if(!e)return e;const t=ye();return e.replace(`file://${t}/`,"").replace(`${t}/`,"")};function gi({error:e}){const t=Ye(e),i=new Map,r=t.map(s=>{const a=!s.methodName&&!s.file?`raw:${s.raw}`:`${wt(s.file)??""}:${s.line}:${s.column}:${s.methodName??""}`,p=i.get(a)??0;return i.set(a,p+1),{key:`${a}#${p}`,trace:s}}),o=t[0],u=wt(o?.file);let l,n=0;if(u&&o?.line&&Ke(u)){const s=Fe(u,"utf8");if(l=je(s,o.line),l)for(const{line:a}of l)n=Math.max(n,String(a).length)}return W(_,{flexDirection:"column",padding:1,children:[W(_,{children:[W(M,{backgroundColor:"red",color:"white",children:[" ","ERROR"," "]}),W(M,{children:[" ",e.message]})]}),o&&u?x(_,{marginTop:1,children:W(M,{dimColor:!0,children:[u,":",o.line,":",o.column]})}):null,o&&l?x(_,{flexDirection:"column",marginTop:1,children:l.map(({line:s,value:a})=>W(_,{children:[x(_,{width:n+1,children:W(M,{"aria-label":s===o.line?`Line ${s}, error`:`Line ${s}`,backgroundColor:s===o.line?"red":void 0,color:s===o.line?"white":void 0,dimColor:s!==o.line,children:[String(s).padStart(n," "),":"]})}),x(M,{backgroundColor:s===o.line?"red":void 0,color:s===o.line?"white":void 0,children:` ${a}`})]},`excerpt-${s}`))}):null,t.length>0?x(_,{flexDirection:"column",marginTop:1,children:r.map(({key:s,trace:a})=>{const p=wt(a.file)??"";return!a.methodName&&!a.file?W(_,{children:[x(M,{dimColor:!0,children:"- "}),x(M,{bold:!0,dimColor:!0,children:a.raw})]},s):W(_,{children:[x(M,{dimColor:!0,children:"- "}),x(M,{bold:!0,dimColor:!0,children:a.methodName??"<anonymous>"}),W(M,{"aria-label":`at ${p} line ${a.line} column ${a.column}`,color:"gray",dimColor:!0,children:[" ","(",p,":",a.line,":",a.column,")"]})]},s)})}):null]})}class vi extends Ae{static displayName="InternalErrorBoundary";static getDerivedStateFromError(t){return{error:t}}state={error:void 0};componentDidCatch(t){this.props.onError(t)}render(){return this.state.error?x(gi,{error:this.state.error}):this.props.children}}const wi=" ",bi="\x1B[Z",yi="\x1B",xi=Vt(Xt),Yt=Zt(Xt),ee=({children:e,exitOnCtrlC:t,interactive:i,onExit:r,onWaitUntilRenderFlush:o,renderThrottleMs:u,setCursorPosition:l,stderr:n,stdin:s,stdout:a,writeToStderr:p,writeToStdout:w})=>{const[g,d]=ct(!0),[h,v]=ct(void 0),[,b]=ct([]),P=$(0),T=$(new Map),D=$(void 0),N=$(0),I=$(!1),E=$(0),[S]=ct(()=>{const c=new _e;return c.setMaxListeners(1/0),c}),K=$(void 0),R=$(void 0);R.current??=mi();const B=$(void 0),Tt=$(!1),ae=20,z=y(()=>{B.current&&(clearTimeout(B.current),B.current=void 0)},[]),G=y(()=>{D.current&&(clearTimeout(D.current),D.current=void 0)},[]),ut=y(()=>{if(G(),T.current.size===0)return;let c=Number.POSITIVE_INFINITY;for(const f of T.current.values())c=Math.min(c,f.nextDueTime);const m=Math.max(0,c-performance.now());D.current=setTimeout(()=>{D.current=void 0;const f=performance.now(),C=[...T.current.values()];for(const O of C){if(f<O.nextDueTime)continue;O.callback(f);const ge=f-O.startTime,ve=Math.floor(ge/O.interval)+1;O.nextDueTime=O.startTime+ve*O.interval}ut()},m)},[G]),Rt=y((c,m)=>{const f=performance.now();return T.current.set(c,{callback:c,interval:m,nextDueTime:f+m,startTime:f}),ut(),{startTime:f,unsubscribe(){if(T.current.delete(c),T.current.size===0){G();return}ut()}}},[G,ut]);vt(()=>()=>{G()},[G]);const H=s.isTTY,St=y(()=>{K.current&&(s.removeListener("readable",K.current),K.current=void 0)},[s]),at=y(()=>{R.current?.reset(),z(),St()},[z,St]),V=y(()=>{I.current=!1,s.setRawMode(!1),s.unref(),N.current=0,at()},[s,at]),et=y(c=>{H&&(N.current>0||I.current)&&V(),r(c)},[H,V,r]),Et=y(c=>{if(c.includes("")&&t){et();return}c===yi&&g&&v(m=>{if(!m)return m})},[t,et,g]),it=y(c=>{Et(c),S.emit("input",c)},[Et,S]),Ot=y(()=>{z(),B.current=setTimeout(()=>{B.current=void 0;const c=R.current.flushPendingEscape();c&&it(c)},ae)},[z,it]),gt=y(()=>{z();let c;for(;(c=s.read())!==null;){const m=R.current.push(c);for(const f of m)if(typeof f=="string")it(f);else{if(S.listenerCount("paste")===0){Tt.current||(Tt.current=!0,p(`Warning: useInput() received bracketed paste because no usePaste() handler is active. This fallback is deprecated and will be removed in the next major version. Migrate paste handling to usePaste().
2
+ `)),it(f.paste);continue}S.emit("paste",f.paste)}}R.current.hasPendingEscape()&&Ot()},[s,it,z,Ot,p,S]),Pt=y(()=>{K.current||(K.current=gt,s.addListener("readable",gt))},[s,gt]),Nt=y(c=>{if(!H)throw s===k.stdin?new Error(`Raw mode is not supported on the current process.stdin, which Ink uses as input stream by default.
3
+ Read about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported`):new Error(`Raw mode is not supported on the stdin provided to Ink.
4
+ Read about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported`);if(s.setEncoding("utf8"),c){if(N.current===0){const m=I.current;I.current=!1,m||(s.ref(),s.setRawMode(!0)),Pt()}N.current++;return}N.current!==0&&--N.current===0&&(at(),I.current=!0,queueMicrotask(()=>{I.current&&V()}))},[H,s,Pt,at,V]),kt=y(c=>{if(a.isTTY){if(c){E.current===0&&a.write(xi),E.current++;return}E.current!==0&&--E.current===0&&a.write(Yt)}},[a]),Dt=y((c,m)=>{const f=c.findIndex(C=>C.id===m);for(let C=f+1;C<c.length;C++){const O=c[C];if(O?.isActive)return O.id}},[]),Lt=y((c,m)=>{const f=c.findIndex(C=>C.id===m);for(let C=f-1;C>=0;C--){const O=c[C];if(O?.isActive)return O.id}},[]),lt=y(()=>{b(c=>(v(m=>{const f=c.find(C=>C.isActive)?.id;return Dt(c,m)??f}),c))},[Dt]),dt=y(()=>{b(c=>(v(m=>{const f=c.findLast(C=>C.isActive)?.id;return Lt(c,m)??f}),c))},[Lt]);vt(()=>{const c=f=>{!g||P.current===0||(f===wi&&lt(),f===bi&&dt())};S.on("input",c);const m=S;return()=>{m.off("input",c)}},[g,lt,dt,S]);const It=y(()=>{d(!0)},[]),Wt=y(()=>{d(!1)},[]),$t=y(c=>{b(m=>(m.some(f=>f?.id===c)&&v(c),m))},[]),Mt=y((c,{autoFocus:m})=>{b(f=>(P.current=f.length+1,[...f,{id:c,isActive:!0}])),m&&v(f=>f||c)},[]),_t=y(c=>{v(m=>{if(m!==c)return m}),b(m=>{const f=m.filter(C=>C.id!==c);return P.current=f.length,f})},[]),At=y(c=>{b(m=>m.map(f=>f.id!==c?f:{id:c,isActive:!0}))},[]),Bt=y(c=>{v(m=>{if(m!==c)return m}),b(m=>m.map(f=>f.id!==c?f:{id:c,isActive:!1}))},[]);vt(()=>()=>{const c=!a.destroyed&&!a.writableEnded;i&&c&&a.write(nt),H&&(N.current>0||I.current)&&V(),E.current>0&&(a.isTTY&&c&&a.write(Yt),E.current=0)},[a,H,V,i]);const le=F(()=>({exit:et,waitUntilRenderFlush:o}),[et,o]),de=F(()=>({internal_eventEmitter:S,internal_exitOnCtrlC:t,isRawModeSupported:H,setBracketedPasteMode:kt,setRawMode:Nt,stdin:s}),[s,Nt,kt,H,t,S]),ce=F(()=>({stdout:a,write:w}),[a,w]),he=F(()=>({stderr:n,write:p}),[n,p]),fe=F(()=>({setCursorPosition:l}),[l]),pe=F(()=>({activate:At,activeId:h,add:Mt,deactivate:Bt,disableFocus:Wt,enableFocus:It,focus:$t,focusNext:lt,focusPrevious:dt,remove:_t}),[h,Mt,_t,At,Bt,It,Wt,lt,dt,$t]),me=F(()=>({renderThrottleMs:u,subscribe:Rt}),[Rt,u]);return x(He.Provider,{value:le,children:x(Ge.Provider,{value:de,children:x(Ve.Provider,{value:ce,children:x(ze.Provider,{value:he,children:x(qe.Provider,{value:pe,children:x(Be.Provider,{value:me,children:x(Ue.Provider,{value:fe,children:x(vi,{onError:et,children:e})})})})})})})})};ee.displayName="InternalApp";const Ci=(e,t,i)=>{if(i<=0||!e.yogaNode)return"";const{yogaNode:r}=e,o=r.getComputedBorder(A.EDGE_LEFT),u=r.getComputedBorder(A.EDGE_RIGHT),l=r.getComputedBorder(A.EDGE_TOP),n=r.getComputedPadding(A.EDGE_LEFT),s=r.getComputedPadding(A.EDGE_RIGHT),a=r.getComputedPadding(A.EDGE_TOP),p=Math.round(r.getComputedWidth()-o-u-n-s);if(p<=0)return"";const w=new Xe({height:i,width:p}),g=-(e.internal_scrollState?.scrollLeft??0)-o-n,d=-t-l-a;for(const h of e.childNodes)Ze(h,w,{absoluteOffsetX:g,absoluteOffsetY:d,offsetX:g,offsetY:d,skipStaticElements:!1});return w.get().output},xt=new WeakMap,Ti={bar:6,"blinking-bar":5,"blinking-block":1,"blinking-underline":3,block:2,default:0,underline:4},jt=e=>Re(Ti[e]),ft=(e,t)=>e?.x!==t?.x||e?.y!==t?.y,tt=(e,t)=>{if(!t)return"";const i=e-t.y;return(i>0?yt(i):"")+Ct(t.x)+nt},ie=(e,t)=>{if(!t)return"";const i=e-1-t.y;return(i>0?Te(i):"")+Ct(0)},re=e=>{const t=e.cursorWasShown?q:"",i=ie(e.previousLineCount,e.previousCursorPosition),r=tt(e.visibleLineCount,e.cursorPosition);return t+i+r},pt=(e,t,i)=>e?q+ie(t,i):"",Z=e=>e??"default",se=()=>{let e,t;return{consumeDelta:()=>{if(Z(t)===Z(e))return"";const i=Z(t);return e=t,jt(i)},consumeRestoreOnDone:()=>{const i=Z(e)!=="default";return e=void 0,t=void 0,i?jt("default"):""},isDirty:()=>Z(t)!==Z(e),setPending:i=>{t=i}}},st=(e,t)=>t.endsWith(`
5
+ `)?e.length-1:e.length,oe=e=>e.rows||1/0,mt=(e,t)=>Math.min(e,oe(t)),Ri=(e,{showCursor:t=!1}={})=>{let i=0,r="",o=!1,u,l=!1,n,s=!1;const a=se(),p=()=>l?u:void 0,w=(d,h)=>{const v=ft(h,n);return d!==r||v||a.isDirty()},g=d=>{!t&&!o&&(e.write(q),o=!0);const h=p();l=!1;const v=ft(h,n);if(!w(d,h))return!1;const b=a.consumeDelta(),P=d.split(`
6
+ `),T=st(P,d),D=tt(T,h);if(d===r&&v)e.write(b+re({cursorPosition:h,cursorWasShown:s,previousCursorPosition:n,previousLineCount:i,visibleLineCount:T}));else if(d===r&&b!=="")e.write(b);else{r=d;const N=pt(s,i,n);e.write(b+N+j(mt(i,e))+d+D),i=P.length}return n=h?{...h}:void 0,s=h!==void 0,!0};return g.clear=()=>{const d=pt(s,i,n);e.write(d+j(mt(i,e))),r="",i=0,n=void 0,s=!1},g.done=()=>{r="",i=0,n=void 0,s=!1;const d=a.consumeRestoreOnDone();d!==""&&e.write(d),t||(e.write(nt),o=!1)},g.reset=()=>{r="",i=0,n=void 0,s=!1},g.sync=d=>{const h=l?u:void 0;l=!1;const v=d.split(`
7
+ `);r=d,i=v.length;const b=a.consumeDelta();b!==""&&e.write(b),!h&&s&&e.write(q),h&&e.write(tt(st(v,d),h)),n=h?{...h}:void 0,s=h!==void 0},g.setCursorPosition=d=>{u=d,l=!0},g.setCursorShape=a.setPending,g.isCursorDirty=()=>l||a.isDirty(),g.willRender=d=>w(d,p()),g},Si=(e,{showCursor:t=!1}={})=>{let i=[],r="",o=!1,u,l=!1,n,s=!1;const a=se(),p=()=>l?u:void 0,w=(d,h)=>{const v=ft(h,n);return d!==r||v||a.isDirty()},g=d=>{!t&&!o&&(e.write(q),o=!0);const h=p();l=!1;const v=ft(h,n);if(!w(d,h))return!1;const b=a.consumeDelta(),P=d.split(`
8
+ `),T=st(P,d),D=st(i,r);if(d===r&&v)return e.write(b+re({cursorPosition:h,cursorWasShown:s,previousCursorPosition:n,previousLineCount:i.length,visibleLineCount:T})),n=h?{...h}:void 0,s=h!==void 0,!0;if(d===r&&b!=="")return e.write(b),!0;const N=pt(s,i.length,n);if(d===`
9
+ `||r.length===0){const R=tt(T,h);return e.write(b+N+j(mt(i.length,e))+d+R),s=h!==void 0,n=h?{...h}:void 0,r=d,i=P,!0}const I=d.endsWith(`
10
+ `),E=[b,N],S=oe(e);if(T<D){const R=r.endsWith(`
11
+ `)?1:0;E.push(j(Math.min(D-T+R,S)),yt(Math.min(T,S-1)))}else E.push(yt(Math.min(D-1,S-1)));for(let R=0;R<T;R++){const B=R===T-1;if(P[R]===i[R]){(!B||I)&&E.push(Se());continue}E.push(Ct(0)+P[R]+Ee+(B&&!I?"":`
12
+ `))}const K=tt(T,h);return E.push(K),e.write(E.join("")),s=h!==void 0,n=h?{...h}:void 0,r=d,i=P,!0};return g.clear=()=>{const d=pt(s,i.length,n);e.write(d+j(mt(i.length,e))),r="",i=[],n=void 0,s=!1},g.done=()=>{r="",i=[],n=void 0,s=!1;const d=a.consumeRestoreOnDone();d!==""&&e.write(d),t||(e.write(nt),o=!1)},g.reset=()=>{r="",i=[],n=void 0,s=!1},g.sync=d=>{const h=l?u:void 0;l=!1;const v=d.split(`
13
+ `);r=d,i=v;const b=a.consumeDelta();b!==""&&e.write(b),!h&&s&&e.write(q),h&&e.write(tt(st(v,d),h)),n=h?{...h}:void 0,s=h!==void 0},g.setCursorPosition=d=>{u=d,l=!0},g.setCursorShape=a.setPending,g.isCursorDirty=()=>l||a.isDirty(),g.willRender=d=>w(d,p()),g},Ei=(e,{incremental:t=!1,showCursor:i=!1}={})=>t?Si(e,{showCursor:i}):Ri(e,{showCursor:i}),Oi={create:Ei},ne=Oe(2026),Y=Vt(ne),U=Zt(ne);function Pi(e,t){return"isTTY"in e&&e.isTTY&&(t??!Jt)}let J;const Ni=()=>{if(J!==!1){if(J!==void 0)return J;try{return J=ri(import.meta.url).Renderer,J}catch{J=!1;return}}},ki=e=>{const t=Ni();if(!t)return;let i,r=0,o=0;const u=(l,n)=>{(!i||r!==l||o!==n)&&(i?i.resize(l,n):i=new t(l,n),r=l,o=n)};return{clear(){if(i){const l=new Uint32Array(r*o*2),n=65535;for(let s=0;s<l.length;s+=2)l[s]=32,l[s+1]=n;i.render(l)}},destroy(){i=void 0},render(l,n,s){if(u(n,s),!!i){e.isTTY&&i.writeRaw(Y);try{i.render(l)}finally{e.isTTY&&i.writeRaw(U)}}},resize(l,n){u(l,n)}}};function qt(e,t=0,i={}){const r=i.leading??!0,o=i.trailing??!0;let u,l,n,s;const a=()=>{if(l===void 0)return;const h=l;l=void 0,s=e(...h)},p=()=>{u!==void 0&&(clearTimeout(u),u=void 0)},w=()=>{u=void 0,o&&a(),l=void 0,n=void 0},g=()=>{p(),u=setTimeout(w,t)},d=function(...h){const v=Date.now();if(n??=v,v-n>=t)return l=h,a(),n=v,g(),s;l=h;const b=u===void 0;return g(),r&&b&&a(),s};return d.cancel=()=>{p(),l=void 0,n=void 0},d.flush=()=>(p(),a(),n=void 0,s),d}console.Console||(console.Console=Ce);const rt=()=>{},zt=async()=>new Promise(e=>{setImmediate(e)}),Di=27,Li=91,Ii=63,Wi=117,$i=48,Mi=57,_i=e=>e>=$i&&e<=Mi,ue=(e,t)=>{if(e[t]!==Di||e[t+1]!==Li||e[t+2]!==Ii)return;let i=t+3;const r=i;for(;i<e.length&&_i(e[i]);)i++;if(i!==r){if(i===e.length)return{state:"partial"};if(e[i]===Wi)return{endIndex:i,state:"complete"}}},Ai=e=>{for(let t=0;t<e.length;t++)if(ue(e,t)?.state==="complete")return!0;return!1},Bi=e=>{const t=[];let i=0;for(;i<e.length;){const r=ue(e,i);if(r?.state==="complete"){i=r.endIndex+1;continue}if(r?.state==="partial")break;t.push(e[i]),i++}return t},Hi=({isTty:e,isUnmounting:t,isWindows:i,nextOutputHeight:r,previousOutputHeight:o,viewportRows:u})=>{if(!e)return!1;const l=o>0,n=o>=u,s=r>=u,a=o>u,p=r>u,w=n&&r<u;return a||p&&l||w||t&&n||i&&(s||n)},bt=e=>e instanceof Error||Object.prototype.toString.call(e)==="[object Error]",Gt=e=>{const t=!e.destroyed&&!e.writableEnded&&(e.writable??!0),i=e._writableState!==void 0||e.writableLength!==void 0;return{canWriteToStdout:t,hasWritableState:i}},ht=(e,t)=>{if(!e||typeof e.flush!="function")return;const i=e;t?i.flush():typeof i.cancel=="function"&&i.cancel()};class Ui{isConcurrent;options;log;manualCursorPosition;renderedCursorPosition;renderedCursorRequested;throttledLog;isScreenReaderEnabled;interactive;renderThrottleMs;alternateScreen;isUnmounted;isUnmounting;lastOutput;lastOutputToRender;lastOutputHeight;lastTerminalWidth;nativeLog;useNativeRenderer;container;rootNode;fullStaticOutput;backbufferNode;backbufferMultiWarned=!1;exitPromise;exitResult;beforeExitHandler;restoreConsole;unsubscribeResize;throttledOnRender;hasPendingThrottledRender=!1;kittyProtocolEnabled=!1;cancelKittyDetection;nextRenderCommit;deferredInitDone=!1;constructor(t){this.options=t,this.rootNode=ti("ink-root"),this.rootNode.onComputeLayout=this.calculateLayout,this.isScreenReaderEnabled=t.isScreenReaderEnabled??k.env.INK_SCREEN_READER==="true",this.interactive=this.resolveInteractiveOption(t.interactive),this.alternateScreen=!1;const i=t.debug||this.isScreenReaderEnabled,r=t.maxFps??30,o=r>0?Math.max(1,Math.ceil(1e3/r)):0;this.renderThrottleMs=i?0:o;const u=i?this.onRender:(()=>{const n=qt(this.onRender,o,{leading:!0,trailing:!0});return this.throttledOnRender=n,()=>{this.hasPendingThrottledRender=!0,n()}})();if(i&&(this.throttledOnRender=void 0),t.standardReactLayoutTiming){let n=!1;const s=()=>{n||(n=!0,queueMicrotask(()=>{n=!1,this.onRender()}))};this.rootNode.onRender=s,this.rootNode.onImmediateRender=s}else this.rootNode.onRender=u,this.rootNode.onImmediateRender=this.onRender;this.rootNode.onStaticChange=this.handleStaticChange,this.log=Oi.create(t.stdout,{incremental:t.incrementalRendering}),this.useNativeRenderer=t.useNativeRenderer??!1,this.useNativeRenderer&&(this.nativeLog=ki(t.stdout),this.nativeLog||(this.useNativeRenderer=!1)),this.manualCursorPosition=void 0,this.renderedCursorPosition=void 0,this.renderedCursorRequested=!1,this.throttledLog=i?this.log:qt(n=>{const s=this.log.willRender(n),a=this.shouldSync();a&&s&&this.options.stdout.write(Y),this.log(n),a&&s&&this.options.stdout.write(U)},void 0,{leading:!0,trailing:!0}),this.isUnmounted=!1,this.isUnmounting=!1,this.isConcurrent=t.concurrent??!1,this.lastOutput="",this.lastOutputToRender="",this.lastOutputHeight=0,this.lastTerminalWidth=X(this.options.stdout).columns,this.fullStaticOutput="";const l=t.concurrent?Ie:We;this.container=L.createContainer(this.rootNode,l,null,!1,null,"id",()=>{},()=>{},()=>{},()=>{}),this.unsubscribeExit=$e(this.unmount,{alwaysLast:!1}),this.setAlternateScreen(!!t.alternateScreen),t.patchConsole&&this.patchConsole(),this.interactive&&(t.stdout.on("resize",this.resized),this.unsubscribeResize=()=>{t.stdout.off("resize",this.resized)}),this.initImmediateKittyKeyboard(),k.env.DEV==="true"&&L.injectIntoDevTools(),this.exitPromise=new Promise((n,s)=>{this.resolveExitPromise=n,this.rejectExitPromise=s}),this.exitPromise.catch(rt)}runDeferredInit(){this.deferredInitDone||(this.deferredInitDone=!0,this.initDeferredKittyKeyboard())}resized=()=>{const t=X(this.options.stdout).columns;t<this.lastTerminalWidth&&(this.log.clear(),this.lastOutput="",this.lastOutputToRender=""),si(),this.calculateLayout(),ei(this.rootNode),this.onRender(),this.lastTerminalWidth=t};resolveExitPromise=()=>{};rejectExitPromise=()=>{};unsubscribeExit=()=>{};handleAppExit=t=>{if(!(this.isUnmounted||this.isUnmounting)){if(bt(t)){this.unmount(t);return}this.exitResult=t,this.unmount()}};getActiveCursorPosition=()=>this.renderedCursorRequested?this.renderedCursorPosition:this.manualCursorPosition;setCursorPosition=t=>{this.manualCursorPosition=t,this.log.setCursorPosition(this.getActiveCursorPosition())};restoreLastOutput=()=>{this.interactive&&(this.log.setCursorPosition(this.getActiveCursorPosition()),this.log(this.lastOutputToRender||`${this.lastOutput}
14
+ `))};calculateLayout=()=>{const t=r=>{const o=new Map;this.calculateScrollAndTriggerObservers(r,o);for(const[u,l]of o)u.internalTrigger(l)};this.backbufferNode=void 0,this.prepareYogaTree(this.rootNode,t);const i=X(this.options.stdout).columns;this.rootNode.yogaNode.setWidth(i),this.rootNode.yogaNode.calculateLayout(void 0,void 0,A.DIRECTION_LTR),t(this.rootNode)};calculateScrollAndTriggerObservers(t,i){if(t.nodeName==="ink-box"){const{style:r}=t,o=r.overflow??"visible",u=r.overflowX??o,l=r.overflowY??o;u==="scroll"||l==="scroll"?(ui(t),r.overflowToBackbuffer&&(this.backbufferNode&&this.backbufferNode!==t&&!this.backbufferMultiWarned&&(this.backbufferMultiWarned=!0,console.warn("[@visulima/tui] Multiple scrollable regions have `overflowToBackbuffer` enabled; only one is supported. The last one in render order wins.")),this.backbufferNode=t)):t.internal_scrollState&&delete t.internal_scrollState}if(ni(t,i),!t.internal_static)for(const r of t.childNodes)r.nodeName!=="#text"&&this.calculateScrollAndTriggerObservers(r,i)}recalculateLayout(){this.markAllTextNodesDirty(this.rootNode),this.calculateLayout(),this.onRender()}prepareYogaTree(t,i){if(t.isYogaTreeDetached&&!t.cachedRender&&t.yogaNode){for(t.yogaNode.setWidthAuto(),t.yogaNode.setHeightAuto(),oi(t.yogaNode,t.style);t.yogaNode.getChildCount()>0;)t.yogaNode.getChild(0).remove();let r=0;for(const o of t.childNodes){const u=o;o.nodeName!=="#text"&&u.yogaNode&&(t.yogaNode.insertChild(u.yogaNode,r),r++)}t.isYogaTreeDetached=!1,this.markAllTextNodesDirty(t)}for(const r of t.childNodes)r.nodeName!=="#text"&&this.prepareYogaTree(r,i);if(t.nodeName==="ink-static-render"&&!t.cachedRender){const r=X(this.options.stdout).columns,{width:o}=t.style;t.yogaNode&&(t.yogaNode.setWidth(typeof o=="number"?o:r),t.yogaNode.calculateLayout(void 0,void 0,A.DIRECTION_LTR)),i(t),Je(t,{skipStaticElements:!1}),t.internal_onRendered?.()}}markAllTextNodesDirty(t){if(!t.cachedRender){t.nodeName==="ink-text"&&t.yogaNode&&t.yogaNode.markDirty();for(const i of t.childNodes)i.nodeName!=="#text"&&this.markAllTextNodesDirty(i)}}handleStaticChange=()=>{this.fullStaticOutput=""};computeBackbufferOutput(){const t=this.backbufferNode;if(!t?.internal_scrollState||!this.interactive||!this.options.stdout.isTTY||this.alternateScreen||this.isScreenReaderEnabled||this.options.debug)return"";const i=Math.round(t.internal_scrollState.scrollTop),r=t.yogaNode?.getComputedPadding(A.EDGE_TOP)??0,o=Math.max(0,i-Math.round(r)),u=t.internal_maxPushedScrollTop??0,{maxScrollbackLength:l}=t.style,n=l===void 0?u:Math.max(u,o-Math.max(0,l)),s=o-n;if(s<=0)return"";const a=Ci(t,n,s);return a===""?"":(t.internal_maxPushedScrollTop=o,`${a}\x1B[0m
15
+ `)}onRender=()=>{if(this.hasPendingThrottledRender=!1,this.isUnmounted)return;this.deferredInitDone||this.runDeferredInit(),this.nextRenderCommit&&(this.nextRenderCommit.resolve(),this.nextRenderCommit=void 0);const t=Qe(this.rootNode,this.isScreenReaderEnabled,{useNativeRenderer:this.useNativeRenderer}),{cursorPosition:i,cursorRequested:r,cursorShape:o,output:u,outputBuffer:l,outputHeight:n,outputWidth:s,staticOutput:a}=t;this.renderedCursorRequested=r,this.renderedCursorPosition=i,this.log.setCursorShape(r?o:void 0);const p=this.computeBackbufferOutput();if(this.useNativeRenderer&&this.nativeLog&&l&&s){a&&a!==`
16
+ `&&this.options.stdout.write(a),p&&this.options.stdout.write(p),this.nativeLog.render(l,s,n),this.lastOutputHeight=n;return}r&&this.log.setCursorPosition(this.getActiveCursorPosition());const w=a&&a!==`
17
+ `;if(this.options.debug){w&&(this.fullStaticOutput+=a),this.lastOutput=u,this.lastOutputToRender=u,this.lastOutputHeight=n,this.options.stdout.write(this.fullStaticOutput+u);return}if(!this.interactive){w&&this.options.stdout.write(a),this.lastOutput=u,this.lastOutputToRender=`${u}
18
+ `,this.lastOutputHeight=n;return}if(this.isScreenReaderEnabled){const g=this.shouldSync();if(g&&this.options.stdout.write(Y),w){const v=this.lastOutputHeight>0?j(this.lastOutputHeight):"";this.options.stdout.write(v+a),this.lastOutputHeight=0}if(u===this.lastOutput&&!w){g&&this.options.stdout.write(U);return}const d=X(this.options.stdout).columns,h=De(u,{trim:!1,width:d,wrapMode:"BREAK_WORDS"}).replace(/\n$/,"");if(w)this.options.stdout.write(h);else{const v=this.lastOutputHeight>0?j(this.lastOutputHeight):"";this.options.stdout.write(v+h)}this.lastOutput=u,this.lastOutputToRender=h,this.lastOutputHeight=h===""?0:h.split(`
19
+ `).length,g&&this.options.stdout.write(U);return}w&&(this.fullStaticOutput+=a),this.renderInteractiveFrame(u,n,w?a:"",p)};accessibilityContextValue;render(t){this.accessibilityContextValue??={isScreenReaderEnabled:this.isScreenReaderEnabled};const i=x(Me.Provider,{value:this.accessibilityContextValue,children:x(ee,{exitOnCtrlC:this.options.exitOnCtrlC,interactive:this.interactive,onExit:this.handleAppExit,onWaitUntilRenderFlush:this.waitUntilRenderFlush,renderThrottleMs:this.renderThrottleMs,setCursorPosition:this.setCursorPosition,stderr:this.options.stderr,stdin:this.options.stdin,stdout:this.options.stdout,writeToStderr:this.writeToStderr,writeToStdout:this.writeToStdout,children:t})});this.options.concurrent?L.updateContainer(i,this.container,null,rt):(L.updateContainerSync(i,this.container,null,rt),L.flushSyncWork())}writeToStdout=t=>{if(this.isUnmounted)return;if(this.options.debug){this.options.stdout.write(t+this.fullStaticOutput+this.lastOutput);return}if(!this.interactive){this.options.stdout.write(t);return}const i=this.shouldSync();i&&this.options.stdout.write(Y),this.log.clear(),this.options.stdout.write(t),this.restoreLastOutput(),i&&this.options.stdout.write(U)};writeToStderr=t=>{if(this.isUnmounted)return;if(this.options.debug){this.options.stderr.write(t),this.options.stdout.write(this.fullStaticOutput+this.lastOutput);return}if(!this.interactive){this.options.stderr.write(t);return}const i=this.shouldSync();i&&this.options.stdout.write(Y),this.log.clear(),this.options.stderr.write(t),this.restoreLastOutput(),i&&this.options.stdout.write(U)};unmount=t=>{if(this.isUnmounted||this.isUnmounting)return;this.isUnmounting=!0,this.beforeExitHandler&&(k.off("beforeExit",this.beforeExitHandler),this.beforeExitHandler=void 0);const i=this.options.stdout,{canWriteToStdout:r,hasWritableState:o}=Gt(i);ht(this.throttledOnRender,r),r&&!this.alternateScreen&&(!this.throttledOnRender||!this.hasPendingThrottledRender&&this.fullStaticOutput==="")&&(this.calculateLayout(),this.onRender()),this.isUnmounted=!0,this.unsubscribeExit(),ht(this.throttledLog,r),typeof this.restoreConsole=="function"&&this.restoreConsole();const u=()=>{typeof this.unsubscribeResize=="function"&&this.unsubscribeResize(),this.cancelKittyDetection&&this.cancelKittyDetection(),r&&(this.kittyProtocolEnabled&&this.writeBestEffort(this.options.stdout,"\x1B[<u"),this.alternateScreen?(this.log.clear(),this.log.done(),this.lastOutput="",this.lastOutputToRender="",this.lastOutputHeight=0,this.fullStaticOutput="",this.writeBestEffort(this.options.stdout,ke),this.writeBestEffort(this.options.stdout,nt),this.alternateScreen=!1):this.interactive?this.options.debug||this.log.done():this.options.stdout.write(this.options.debug?`
20
+ `:`${this.lastOutput}
21
+ `)),this.kittyProtocolEnabled=!1,xt.delete(this.options.stdout);const{exitResult:n}=this,s=()=>{bt(t)?this.rejectExitPromise(t):this.resolveExitPromise(n)};t!==void 0&&!bt(t)?s():r&&o?this.options.stdout.write("",s):setImmediate(s)},l=L;this.options.concurrent?(L.updateContainerSync(null,this.container,null,rt),L.flushSyncWork(),l.flushPassiveEffects?.(),u()):(L.updateContainerSync(null,this.container,null,rt),L.flushSyncWork(),u())};async waitUntilExit(){return this.beforeExitHandler||(this.beforeExitHandler=()=>{this.unmount()},k.on("beforeExit",this.beforeExitHandler)),this.exitPromise}async waitUntilRenderFlush(){if(this.isUnmounted||this.isUnmounting){await this.awaitExit();return}if(await zt(),this.isUnmounted||this.isUnmounting){await this.awaitExit();return}if(this.isConcurrent&&this.hasPendingConcurrentWork()&&(await Promise.race([this.awaitNextRender(),this.awaitExit()]),this.isUnmounted||this.isUnmounting)){this.nextRenderCommit=void 0,await this.awaitExit();return}L.flushSyncWork();const t=this.options.stdout,{canWriteToStdout:i,hasWritableState:r}=Gt(t);if(ht(this.throttledOnRender,i),ht(this.throttledLog,i),i&&r){await new Promise(o=>{this.options.stdout.write("",()=>{o()})});return}await zt()}clear(){this.interactive&&!this.options.debug&&(this.log.clear(),this.log.sync(this.lastOutputToRender||`${this.lastOutput}
22
+ `))}patchConsole(){this.options.debug||(this.restoreConsole=Le((t,i)=>{t==="stdout"&&this.writeToStdout(i),t==="stderr"&&(i.startsWith("The above error occurred")||this.writeToStderr(i))}))}setAlternateScreen(t){this.alternateScreen=this.resolveAlternateScreenOption(t,this.interactive),this.alternateScreen&&(this.writeBestEffort(this.options.stdout,Pe),this.writeBestEffort(this.options.stdout,q))}resolveInteractiveOption(t){return t??(!Jt&&!!this.options.stdout.isTTY)}resolveAlternateScreenOption(t,i){return!!t&&i&&!!this.options.stdout.isTTY}shouldSync(){return Pi(this.options.stdout,this.interactive)}writeBestEffort(t,i){try{t.write(i)}catch{}}async awaitExit(){try{await this.exitPromise}catch{}}hasPendingConcurrentWork(){const t=this.container;return(t.pendingLanes??0)!==0&&t.callbackNode!==void 0&&t.callbackNode!==null}async awaitNextRender(){if(!this.nextRenderCommit){let t;const i=new Promise(r=>{t=r});this.nextRenderCommit={promise:i,resolve:t}}return this.nextRenderCommit.promise}renderInteractiveFrame(t,i,r,o=""){const u=r+o,l=u!=="",n=this.options.stdout.isTTY,s=n?X(this.options.stdout).rows:24,a=n&&i>=s,p=a?t:`${t}
23
+ `,w=k.platform==="win32",g=n&&w&&(a||this.lastOutputHeight>=s);if(Hi({isTty:n,isUnmounting:this.isUnmounting,isWindows:w,nextOutputHeight:i,previousOutputHeight:this.lastOutputHeight,viewportRows:s})){if(this.options.incrementalRendering&&!g){l&&(this.log.clear(),this.options.stdout.write(u)),(t!==this.lastOutput||this.log.isCursorDirty()||l)&&this.throttledLog(p),this.lastOutput=t,this.lastOutputToRender=p,this.lastOutputHeight=i;return}const d=this.shouldSync();d&&this.options.stdout.write(Y),this.options.stdout.write(Ne+this.fullStaticOutput+o+t),this.lastOutput=t,this.lastOutputToRender=p,this.lastOutputHeight=i,this.log.sync(p),d&&this.options.stdout.write(U);return}if(l){const d=this.shouldSync();d&&this.options.stdout.write(Y),this.log.clear(),this.options.stdout.write(u),this.log(p),d&&this.options.stdout.write(U)}else(t!==this.lastOutput||this.log.isCursorDirty())&&this.throttledLog(p);this.lastOutput=t,this.lastOutputToRender=p,this.lastOutputHeight=i}initImmediateKittyKeyboard(){if(!this.options.kittyKeyboard)return;const t=this.options.kittyKeyboard;if((t.mode??"auto")!=="enabled")return;const i=t.flags??["disambiguateEscapeCodes"];this.options.stdin.isTTY&&this.options.stdout.isTTY&&this.enableKittyProtocol(i)}initDeferredKittyKeyboard(){if(!this.options.kittyKeyboard)return;const t=this.options.kittyKeyboard;if((t.mode??"auto")!=="auto")return;const i=t.flags??["disambiguateEscapeCodes"];!this.interactive||!this.options.stdin.isTTY||!this.options.stdout.isTTY||this.confirmKittySupport(i)}confirmKittySupport(t){const{stdin:i,stdout:r}=this.options;let o=[];const u=()=>{this.cancelKittyDetection=void 0,clearTimeout(n),i.removeListener("data",l);const s=Bi(o);o=[],s.length>0&&i.unshift(Ht.from(s))},l=s=>{const a=typeof s=="string"?Ht.from(s):s;for(const p of a)o.push(p);Ai(o)&&(u(),this.isUnmounted||this.enableKittyProtocol(t))};i.on("data",l);const n=setTimeout(u,200);this.cancelKittyDetection=u,r.write("\x1B[?u")}enableKittyProtocol(t){this.options.stdout.write(`\x1B[>${ii(t)}u`),this.kittyProtocolEnabled=!0}}const xr=(e,t)=>{const i={alternateScreen:!1,concurrent:!1,debug:!1,exitOnCtrlC:!0,incrementalRendering:!1,maxFps:30,patchConsole:!0,stderr:k.stderr,stdin:k.stdin,stdout:k.stdout,...Ki(t)},r=Fi(i.stdout,()=>new Ui(i));return r.render(e),{cleanup(){r.unmount()},clear(){r.clear()},rerender(o){r.render(o)},rootNode:r.rootNode,unmount(){r.unmount()},waitUntilExit(){return r.waitUntilExit()},waitUntilRenderFlush(){return r.waitUntilRenderFlush()}}},Ki=(e={})=>e instanceof xe?{stdin:k.stdin,stdout:e}:e,Fi=(e,t)=>{const i=xt.get(e);if(i===void 0){const r=t();return xt.set(e,r),r}return k.stderr.write(`Warning: render() was called again for the same stdout before the previous Ink instance was unmounted. Reusing stdout across multiple render() calls is unsupported. Call unmount() first.
24
+ `),i};export{xr as default};
@@ -0,0 +1 @@
1
+ import i from"react";import{FocusProvider as y,useFocusManager as W}from"./FocusContext-C2Sosxa4.js";import{TuiContext as I,useInput as z}from"./TuiContext-BNmP0lMY.js";import{LayoutNode as v}from"./LayoutNode-LPYsuzBg.js";import{T as f,s as P}from"./reconciler-ClpU7Y-V.js";import{renderTreeToBuffer as F}from"./renderTreeToBuffer-C8lS0lJ2.js";import{TuiApp as L}from"./TuiApp-BPL8v1i1.js";import{InputParser as T}from"./InputParser-CtwkCbrQ.js";import{terminalSize as G}from"./Renderer-DsskdkUd.js";import{createInlineLoop as M}from"./createInlineLoop-BT40Wpmx.js";const R=n=>i.createElement("box",n,n.children),K=n=>i.createElement("text",n,n.children),Q=()=>i.createElement(R,{flexGrow:1}),b=({children:n})=>{const{disableFocus:c,enableFocus:e,focusNext:a,focusPrevious:o}=W();return z((w,s)=>{s.tab&&!s.shift&&a(),s.tab&&s.shift&&o(),s.escape&&(c(),e())}),i.createElement(i.Fragment,null,n)};function V(n,c){const e=new L,a=new T(process.stdin),o=new v,{height:w,width:s}=e.getSize();o.yogaNode.setWidth(s),o.yogaNode.setHeight(w);const u=f.createContainer(o,0,null,!1,null,"",t=>console.error(t),null),p=t=>i.createElement(I.Provider,{value:{app:e,input:a,writeStderr:l=>e.writeStderr(l),writeStdout:l=>e.writeStdout(l)}},i.createElement(y,null,i.createElement(b,null,t)));f.updateContainer(p(n),u,null,()=>{});const h=(t,l)=>o.calculateLayout(t,l),x=(t,l,H)=>F(o,t,l,H),g=()=>e.paintNow(h,x);let S=!1;P(()=>{S=!0});const d=Math.round(1e3/(c?.maxFps??60)),E=setInterval(()=>{S&&(S=!1,g())},d);let N;const r=new Promise(t=>{N=t}),m=()=>{clearInterval(E),f.updateContainer(null,u,null,()=>{}),o.destroy(),e.stop(),a.stop(),process.off("SIGWINCH",C),N()};a.on("exit",()=>{m(),process.exit(0)}),e.on("quit",()=>{m(),process.exit(0)}),a.start(),e.start();const C=()=>{const t=process.stdout.columns||80,l=process.stdout.rows||24;e.resize(t,l),o.yogaNode.setWidth(t),o.yogaNode.setHeight(l),e.emit("resize"),g()};return process.on("SIGWINCH",C),g(),{app:e,input:a,rerender(t){f.updateContainer(p(t),u,null,()=>{})},unmount(){m()},waitUntilExit(){return r}}}function X(n,c){const e=G(),a=c?.rows??10,{cols:o}=e,w=Math.min(a,e.rows),s=new T(process.stdin),u=new v;u.yogaNode.setWidth(o),u.yogaNode.setHeight(w);const p=[],h=[],x={quit:()=>d.stop(),writeStderr:r=>h.push(r),writeStdout:r=>p.push(r)},g=f.createContainer(u,0,null,!1,null,"",r=>console.error(r),null),S=r=>i.createElement(I.Provider,{value:{app:x,input:s,writeStderr:x.writeStderr,writeStdout:x.writeStdout}},i.createElement(y,null,i.createElement(b,null,r)));f.updateContainer(S(n),g,null,()=>{}),P(()=>{});const d=M((r,m,C)=>{u.calculateLayout(m,C),F(u,r,m,C)},{...c,fps:c?.maxFps??c?.fps??60,rows:w});s.on("exit",()=>d.stop());let E;const N=new Promise(r=>{E=r});return process.on("exit",()=>{p.length>0&&process.stdout.write(p.join("")),h.length>0&&process.stderr.write(h.join("")),E()}),d.start(),s.start(),{unmount(){d.stop()},waitUntilExit(){return N}}}export{R as _Box,Q as _Spacer,K as _Text,V as render,X as renderInline};
@@ -0,0 +1,417 @@
1
+ import { ReactNode } from 'react';
2
+ import { D as DOMElement } from "./dom.d-B4kXbaVY.js";
3
+ import 'node:stream';
4
+ import { a as CursorPosition } from "./cursor-helpers.d-BONB9tky.js";
5
+ declare const kittyFlags: {
6
+ readonly disambiguateEscapeCodes: 1;
7
+ readonly reportAllKeysAsEscapeCodes: 8;
8
+ readonly reportAlternateKeys: 4;
9
+ readonly reportAssociatedText: 16;
10
+ readonly reportEventTypes: 2;
11
+ };
12
+ type KittyFlagName = keyof typeof kittyFlags;
13
+ declare const kittyModifiers: {
14
+ readonly alt: 2;
15
+ readonly capsLock: 64;
16
+ readonly ctrl: 4;
17
+ readonly hyper: 16;
18
+ readonly meta: 32;
19
+ readonly numLock: 128;
20
+ readonly shift: 1;
21
+ readonly super: 8;
22
+ };
23
+ type KittyKeyboardOptions = {
24
+ flags?: KittyFlagName[];
25
+ mode?: "auto" | "enabled" | "disabled";
26
+ };
27
+ /**
28
+ * Performance metrics for a render operation.
29
+ */
30
+ type RenderMetrics = {
31
+ /**
32
+ * Time spent rendering in milliseconds.
33
+ */
34
+ renderTime: number;
35
+ };
36
+ type Options = {
37
+ /**
38
+ * Render the app in the terminal's alternate screen buffer. When enabled, the app renders on a separate screen, and the original terminal content is restored when the app exits. This is the same mechanism used by programs like vim, htop, and less.
39
+ *
40
+ * Note: The terminal's scrollback buffer is not available while in the alternate screen. This is standard terminal behavior; programs like vim use the alternate screen specifically to avoid polluting the user's scrollback history.
41
+ *
42
+ * Note: Ink intentionally treats alternate-screen teardown output as disposable. It does not preserve or replay teardown-time frames, hook writes, or `console.*` output after restoring the primary screen.
43
+ *
44
+ Only works in interactive mode. Ignored when `interactive` is `false` or in a non-interactive environment (CI, piped stdout).
45
+
46
+ Note: Reusing the same stdout across multiple `render()` calls without unmounting is unsupported. Call `unmount()` first if you need to change this option or create a fresh instance.
47
+
48
+ @default false
49
+
50
+ @see {@link RenderOptions.alternateScreen}
51
+ */
52
+ alternateScreen?: boolean;
53
+ /**
54
+ * Enable React Concurrent Rendering mode.
55
+ *
56
+ * When enabled:
57
+ * - Suspense boundaries work correctly with async data
58
+ * - `useTransition` and `useDeferredValue` are fully functional
59
+ - Updates can be interrupted for higher priority work
60
+
61
+ Note: Concurrent mode changes the timing of renders. Some tests may need to use `act()` to properly await updates. Reusing the same stdout across multiple `render()` calls without unmounting is unsupported. Call `unmount()` first if you need to change the rendering mode or create a fresh instance.
62
+
63
+ @default false
64
+ @experimental
65
+ */
66
+ concurrent?: boolean;
67
+ debug: boolean;
68
+ exitOnCtrlC: boolean;
69
+ incrementalRendering?: boolean;
70
+ /**
71
+ * Override automatic interactive mode detection.
72
+ *
73
+ * By default, Ink detects whether the environment is interactive based on CI detection (via [`is-in-ci`](https://github.com/sindresorhus/is-in-ci)) and `stdout.isTTY`. Most users should not need to set this.
74
+ *
75
+ * When non-interactive, Ink disables ANSI erase sequences, cursor manipulation, synchronized output, resize handling, and kitty keyboard auto-detection, writing only the final frame at unmount.
76
+ *
77
+ Set to `false` to force non-interactive mode or `true` to force interactive mode when the automatic detection doesn't suit your use case.
78
+
79
+ Note: Reusing the same stdout across multiple `render()` calls without unmounting is unsupported. Call `unmount()` first if you need to change this option or create a fresh instance.
80
+
81
+ @default true (false if in CI or `stdout.isTTY` is falsy)
82
+
83
+ @see {@link RenderOptions.interactive}
84
+ */
85
+ interactive?: boolean;
86
+ isScreenReaderEnabled?: boolean;
87
+ kittyKeyboard?: KittyKeyboardOptions;
88
+ maxFps?: number;
89
+ onRender?: (metrics: RenderMetrics) => void;
90
+ patchConsole: boolean;
91
+ standardReactLayoutTiming?: boolean;
92
+ stderr: NodeJS.WriteStream;
93
+ stdin: NodeJS.ReadStream;
94
+ stdout: NodeJS.WriteStream;
95
+ /**
96
+ * Whether to track text selection state during rendering.
97
+ *
98
+ * @default false
99
+ */
100
+ trackSelection?: boolean;
101
+ /**
102
+ * Use the native Rust cell-diff renderer instead of ANSI string-based log-update.
103
+ * Produces a Uint32Array buffer that the Rust renderer diffs cell-by-cell,
104
+ * generating minimal ANSI escape sequences. Significantly reduces GC pressure
105
+ * and improves rendering performance for complex UIs.
106
+ *
107
+ * Falls back to the string-based path if native bindings are not available.
108
+ * @default false
109
+ */
110
+ useNativeRenderer?: boolean;
111
+ waitUntilExit?: () => Promise<unknown>;
112
+ };
113
+ declare class Ink {
114
+ /**
115
+ * Whether this instance is using concurrent rendering mode.
116
+ */
117
+ readonly isConcurrent: boolean;
118
+ private readonly options;
119
+ private readonly log;
120
+ private manualCursorPosition;
121
+ private renderedCursorPosition;
122
+ private renderedCursorRequested;
123
+ private readonly throttledLog;
124
+ private readonly isScreenReaderEnabled;
125
+ private readonly interactive;
126
+ private readonly renderThrottleMs;
127
+ private alternateScreen;
128
+ private isUnmounted;
129
+ private isUnmounting;
130
+ private lastOutput;
131
+ private lastOutputToRender;
132
+ private lastOutputHeight;
133
+ private lastTerminalWidth;
134
+ private readonly nativeLog;
135
+ private readonly useNativeRenderer;
136
+ private readonly container;
137
+ readonly rootNode: DOMElement;
138
+ private fullStaticOutput;
139
+ private backbufferNode;
140
+ private backbufferMultiWarned;
141
+ private readonly exitPromise!;
142
+ private exitResult;
143
+ private beforeExitHandler?;
144
+ private restoreConsole?;
145
+ private unsubscribeResize?;
146
+ private readonly throttledOnRender?;
147
+ private hasPendingThrottledRender;
148
+ private kittyProtocolEnabled;
149
+ private cancelKittyDetection?;
150
+ private nextRenderCommit?;
151
+ private deferredInitDone;
152
+ constructor(options: Options);
153
+ /**
154
+ * Perform deferred initialization on the first render frame.
155
+ * Kitty keyboard auto-detection is deferred here because the CSI ? u
156
+ * query sets up a synchronous stdin listener with a 200ms timeout.
157
+ * "enabled" mode runs immediately in the constructor (it's just a write).
158
+ */
159
+ private runDeferredInit;
160
+ resized: () => void;
161
+ resolveExitPromise: (result?: unknown) => void;
162
+ rejectExitPromise: (reason?: Error) => void;
163
+ unsubscribeExit: () => void;
164
+ handleAppExit: (errorOrResult?: unknown) => void;
165
+ getActiveCursorPosition: () => CursorPosition | undefined;
166
+ setCursorPosition: (position: CursorPosition | undefined) => void;
167
+ restoreLastOutput: () => void;
168
+ calculateLayout: () => void;
169
+ private calculateScrollAndTriggerObservers;
170
+ /**
171
+ * Force a full layout recalculation by marking all text nodes dirty.
172
+ * Useful when the string width function changes or terminal font changes.
173
+ */
174
+ recalculateLayout(): void;
175
+ /**
176
+ * Walks the DOM tree before Yoga layout to handle StaticRender nodes.
177
+ *
178
+ * - Re-attach Yoga children if a cached render was invalidated.
179
+ * - Pre-render ink-static-render nodes that don't have a cached render yet.
180
+ */
181
+ private prepareYogaTree;
182
+ private markAllTextNodesDirty;
183
+ handleStaticChange: () => void;
184
+ /**
185
+ * Compute the slice of lines that newly scrolled off the top of the single
186
+ * `overflowToBackbuffer` region and have not yet been flushed into the
187
+ * terminal's real scrollback. Advances the monotonic
188
+ * `internal_maxPushedScrollTop` bookkeeping so each line is emitted exactly
189
+ * once and scrolling back up is a no-op. Returns a newline-terminated
190
+ * string to write above the live frame, or "" when there is nothing to do.
191
+ *
192
+ * No-op outside inline mode (alternate-screen / non-TTY / non-interactive /
193
+ * screen-reader / debug), since terminal scrollback only exists for an
194
+ * inline, in-place-updated live region. Debug mode is excluded because it
195
+ * re-dumps the full grid every frame and never writes this slice — running
196
+ * it there would advance the monotonic pointer past lines that were never
197
+ * emitted.
198
+ */
199
+ private computeBackbufferOutput;
200
+ onRender: () => void;
201
+ private accessibilityContextValue;
202
+ render(node: ReactNode): void;
203
+ writeToStdout: (data: string) => void;
204
+ writeToStderr: (data: string) => void;
205
+ unmount: (error?: Error | number | null) => void;
206
+ waitUntilExit(): Promise<unknown>;
207
+ waitUntilRenderFlush(): Promise<void>;
208
+ clear(): void;
209
+ patchConsole(): void;
210
+ private setAlternateScreen;
211
+ private resolveInteractiveOption;
212
+ private resolveAlternateScreenOption;
213
+ private shouldSync;
214
+ private writeBestEffort;
215
+ private awaitExit;
216
+ private hasPendingConcurrentWork;
217
+ private awaitNextRender;
218
+ private renderInteractiveFrame;
219
+ /**
220
+ * Handle kitty keyboard "enabled" mode immediately (just a stdout.write).
221
+ * Called from the constructor.
222
+ */
223
+ private initImmediateKittyKeyboard;
224
+ /**
225
+ * Handle kitty keyboard "auto" mode detection. Deferred to first render
226
+ * because the CSI ? u query sets up a stdin listener with a 200ms timeout.
227
+ */
228
+ private initDeferredKittyKeyboard;
229
+ private confirmKittySupport;
230
+ private enableKittyProtocol;
231
+ }
232
+ type RenderOptions = {
233
+ /**
234
+ * Render the app in the terminal's alternate screen buffer. When enabled, the app renders on a separate screen, and the original terminal content is restored when the app exits. This is the same mechanism used by programs like vim, htop, and less.
235
+ *
236
+ * Note: The terminal's scrollback buffer is not available while in the alternate screen. This is standard terminal behavior; programs like vim use the alternate screen specifically to avoid polluting the user's scrollback history.
237
+ *
238
+ * Note: Ink intentionally treats alternate-screen teardown output as disposable. It does not preserve or replay teardown-time frames, hook writes, or `console.*` output after restoring the primary screen.
239
+ *
240
+ * Only works in interactive mode. Ignored when `interactive` is `false` or in a non-interactive environment (CI, piped stdout).
241
+ *
242
+ *Note: Reusing the same stdout across multiple `render()` calls without unmounting is unsupported. Call `unmount()` first if you need to change this option or create a fresh instance.
243
+ * @default false
244
+ */
245
+ alternateScreen?: boolean;
246
+ /**
247
+ * Enable React Concurrent Rendering mode.
248
+ *
249
+ * When enabled:
250
+ * - Suspense boundaries work correctly with async data
251
+ * - `useTransition` and `useDeferredValue` are fully functional
252
+ * - Updates can be interrupted for higher priority work
253
+ *
254
+ *Note: Concurrent mode changes the timing of renders. Some tests may need to use `act()` to properly await updates. Reusing the same stdout across multiple `render()` calls without unmounting is unsupported. Call `unmount()` first if you need to change the rendering mode or create a fresh instance.
255
+ * @default false
256
+ */
257
+ concurrent?: boolean;
258
+ /**
259
+ * If true, each update will be rendered as separate output, without replacing the previous one.
260
+ * @default false
261
+ */
262
+ debug?: boolean;
263
+ /**
264
+ * Configure whether Ink should listen for Ctrl+C keyboard input and exit the app. This is needed in case `process.stdin` is in raw mode, because then Ctrl+C is ignored by default and the process is expected to handle it manually.
265
+ * @default true
266
+ */
267
+ exitOnCtrlC?: boolean;
268
+ /**
269
+ * Enable incremental rendering mode which only updates changed lines instead of redrawing the entire output.
270
+ *This can reduce flickering and improve performance for frequently updating UIs.
271
+ * @default false
272
+ */
273
+ incrementalRendering?: boolean;
274
+ /**
275
+ * Override automatic interactive mode detection.
276
+ *
277
+ * By default, Ink detects whether the environment is interactive based on CI detection (via [`is-in-ci`](https://github.com/sindresorhus/is-in-ci)) and `stdout.isTTY`. Most users should not need to set this.
278
+ *
279
+ * When non-interactive, Ink disables ANSI erase sequences, cursor manipulation, synchronized output, resize handling, and kitty keyboard auto-detection, writing only the final frame at unmount.
280
+ *
281
+ * Set to `false` to force non-interactive mode or `true` to force interactive mode when the automatic detection doesn't suit your use case.
282
+ *
283
+ *Note: Reusing the same stdout across multiple `render()` calls without unmounting is unsupported. Call `unmount()` first if you need to change this option or create a fresh instance.
284
+ * @default true (false if in CI or `stdout.isTTY` is falsy)
285
+ */
286
+ interactive?: boolean;
287
+ /**
288
+ * Enable screen reader support. See https://github.com/vadimdemedes/ink/blob/master/readme.md#screen-reader-support
289
+ * @default process.env['INK_SCREEN_READER'] === 'true'
290
+ */
291
+ isScreenReaderEnabled?: boolean;
292
+ /**
293
+ * Configure kitty keyboard protocol support for enhanced keyboard input.
294
+ * Enables additional modifiers (super, hyper, capsLock, numLock) and
295
+ *disambiguated key events in terminals that support the protocol.
296
+ * @see https://sw.kovidgoyal.net/kitty/keyboard-protocol/
297
+ */
298
+ kittyKeyboard?: KittyKeyboardOptions;
299
+ /**
300
+ * Maximum frames per second for render updates.
301
+ * This controls how frequently the UI can update to prevent excessive re-rendering.
302
+ *Higher values allow more frequent updates but may impact performance.
303
+ * @default 30
304
+ */
305
+ maxFps?: number;
306
+ /**
307
+ * Runs the given callback after each render and re-render with render metrics.
308
+ *
309
+ * Note: this callback runs after Ink commits a frame, but it does not wait for `stdout`/`stderr` stream callbacks.
310
+ * To run code after output is flushed, use `waitUntilRenderFlush()`.
311
+ */
312
+ onRender?: (metrics: RenderMetrics) => void;
313
+ /**
314
+ * Patch console methods to ensure console output doesn't mix with Ink's output.
315
+ *
316
+ *Note: Once unmount starts, Ink restores the native console before React cleanup runs. Teardown-time `console.*` output then follows the normal console behavior instead of being rerouted through Ink.
317
+ * @default true
318
+ */
319
+ patchConsole?: boolean;
320
+ /**
321
+ * If true, Ink defers frame output until after React's commit phase completes,
322
+ * ensuring `useLayoutEffect` hooks run before the frame is written to the terminal.
323
+ *
324
+ * This eliminates the one-frame flicker when components measure layout
325
+ * (e.g., scroll position, element size) in `useLayoutEffect` and adjust state.
326
+ *
327
+ * **Warning:** Incompatible with the `&lt;Static>` component, which relies on
328
+ * immediate render timing to append output.
329
+ * @default false
330
+ */
331
+ standardReactLayoutTiming?: boolean;
332
+ /**
333
+ * Error stream.
334
+ * @default process.stderr
335
+ */
336
+ stderr?: NodeJS.WriteStream;
337
+ /**
338
+ * Input stream where app will listen for input.
339
+ * @default process.stdin
340
+ */
341
+ stdin?: NodeJS.ReadStream;
342
+ /**
343
+ * Output stream where the app will be rendered.
344
+ * @default process.stdout
345
+ */
346
+ stdout?: NodeJS.WriteStream;
347
+ /**
348
+ * Use the native Rust cell-diff renderer for terminal output.
349
+ * Produces a Uint32Array buffer that the Rust renderer diffs cell-by-cell,
350
+ * generating minimal ANSI escape sequences. Reduces GC pressure and
351
+ * improves rendering performance for complex UIs.
352
+ *
353
+ * Falls back to string-based rendering if native bindings are not available.
354
+ * @default false
355
+ */
356
+ useNativeRenderer?: boolean;
357
+ };
358
+ type Instance = {
359
+ /**
360
+ * Unmount the current app and remove the internal Ink instance for this stdout.
361
+ *
362
+ * This is mostly useful for advanced cases where you need `render()` to create a fresh instance for the same stream without leaving terminal state such as the alternate screen behind.
363
+ */
364
+ cleanup: () => void;
365
+ /**
366
+ * Clear output.
367
+ */
368
+ clear: () => void;
369
+ /**
370
+ * Replace the previous root node with a new one or update props of the current root node.
371
+ */
372
+ rerender: Ink["render"];
373
+ /**
374
+ * The root DOM element of the rendered tree.
375
+ * Useful for programmatic DOM inspection and advanced measurement.
376
+ */
377
+ rootNode: DOMElement;
378
+ /**
379
+ * Manually unmount the whole Ink app.
380
+ */
381
+ unmount: Ink["unmount"];
382
+ /**
383
+ * Returns a promise that settles when the app is unmounted.
384
+ *
385
+ * It resolves with the value passed to `exit(value)` and rejects with the error passed to `exit(error)`.
386
+ *When `unmount()` is called manually, it settles after unmount-related stdout writes complete.
387
+ * @example
388
+ * ```jsx
389
+ * const {unmount, waitUntilExit} = render(<MyApp />);
390
+ *
391
+ * setTimeout(unmount, 1000);
392
+ *
393
+ * await waitUntilExit(); // resolves after `unmount()` is called
394
+ * ```
395
+ */
396
+ waitUntilExit: Ink["waitUntilExit"];
397
+ /**
398
+ * Returns a promise that settles after pending render output is flushed to stdout.
399
+ *
400
+ *This can be used after `rerender()` when you need to run code only after the frame is written.
401
+ * @example
402
+ * ```jsx
403
+ * const {rerender, waitUntilRenderFlush} = render(<MyApp step="loading" />);
404
+ *
405
+ * rerender(<MyApp step="ready" />);
406
+ * await waitUntilRenderFlush(); // output for "ready" is flushed
407
+ *
408
+ * runNextCommand();
409
+ * ```
410
+ */
411
+ waitUntilRenderFlush: Ink["waitUntilRenderFlush"];
412
+ };
413
+ /**
414
+ * Mount a component and render the output.
415
+ */
416
+ declare const render: (node: ReactNode, options?: NodeJS.WriteStream | RenderOptions) => Instance;
417
+ export { Instance as I, KittyFlagName as K, RenderOptions as R, KittyKeyboardOptions as a, kittyModifiers as b, kittyFlags as k, render as r };
@@ -0,0 +1,4 @@
1
+ import{LegacyRoot as p}from"react-reconciler/constants.js";import N from"yoga-layout";import{c as g}from"./dom-rphpG0kf.js";import{j as l}from"./reconciler-CFyBVf7l.js";import{H as i}from"./renderer-k-xShm1P.js";import{calculateScroll as v}from"./calculateScroll-D4Y_JR4H.js";const L=(f,u)=>{const d=u?.columns??80,e=g("ink-root");let a="";e.onComputeLayout=()=>{e.yogaNode.setWidth(d),e.yogaNode.calculateLayout(void 0,void 0,N.DIRECTION_LTR);const o=t=>{if(t.nodeName==="ink-box"){const n=t.style.overflow??"visible",m=t.style.overflowX??n,y=t.style.overflowY??n;(m==="scroll"||y==="scroll")&&v(t)}for(const n of t.childNodes)n.nodeName!=="#text"&&o(n)};o(e)},e.onImmediateRender=()=>{const{staticOutput:o}=i(e,!1);o&&o!==`
2
+ `&&(a+=o)};let r;const c=l.createContainer(e,p,null,!1,null,"render-to-string",o=>{r??=o},()=>{},()=>{},()=>{});let s=!1;try{l.updateContainerSync(f,c,null,()=>{}),l.flushSyncWork();const{output:o}=i(e,!1);if(l.updateContainerSync(null,c,null,()=>{}),l.flushSyncWork(),s=!0,e.yogaNode.free(),r!==void 0)throw r instanceof Error?r:new Error(String(r));const t=a.endsWith(`
3
+ `)?a.slice(0,-1):a;return t&&o?`${t}
4
+ ${o}`:t||o}finally{if(!s&&e.yogaNode)try{e.yogaNode.freeRecursive()}catch{}}};export{L as default};
@@ -0,0 +1,2 @@
1
+ import s from"react";import{FocusProvider as S}from"./FocusContext-C2Sosxa4.js";import{TuiContext as h}from"./TuiContext-BNmP0lMY.js";import{LayoutNode as T}from"./LayoutNode-LPYsuzBg.js";import{T as l}from"./reconciler-ClpU7Y-V.js";import{renderTreeToBuffer as C}from"./renderTreeToBuffer-C8lS0lJ2.js";import{Cell as w}from"./Cell-BrXn3jxY.js";function P(p,u){const r=u?.columns??80,o=u?.rows??24,e=new T;e.yogaNode.setWidth(r),e.yogaNode.setHeight(o);const d={app:null,input:null,writeStderr:n=>{},writeStdout:n=>{}},y=s.createElement(h.Provider,{value:d},s.createElement(S,null,p)),a=l.createContainer(e,0,null,!1,null,"renderToString",()=>{},null);l.updateContainerSync(y,a,null,()=>{}),l.flushSyncWork(),e.calculateLayout(r,o);const c=new Uint32Array(r*o*2);C(e,c,r,o);const t=[];for(let n=0;n<o;n++){let m="";for(let i=0;i<r;i++){const g=c[(n*r+i)*2],f=w.getChar(g);m+=f===""?" ":f}t.push(m.trimEnd())}for(;t.length>0&&t.at(-1)==="";)t.pop();return l.updateContainerSync(null,a,null,()=>{}),l.flushSyncWork(),e.destroy(),t.join(`
2
+ `)}export{P as renderToString};
@@ -0,0 +1,2 @@
1
+ import q from"cli-boxes";import{resolveColor as O}from"./NAMED_COLORS-82DpREQV.js";import{a as z}from"./text-width-e49vlbQH.js";const D=1114112,E=9608,F=9600,H=9604;function k(o){const t=o?.borderStyle?1:0;return{bottom:o?.borderBottom===!1?0:t,left:o?.borderLeft===!1?0:t,right:o?.borderRight===!1?0:t,top:o?.borderTop===!1?0:t}}function I(o){let t=0;for(const i of o.children){const b=i.getLayout(),e=b.top+b.height;e>t&&(t=e)}const n=o._style,l=n?.paddingBottom??n?.paddingY??n?.padding??0;return t+l}function N(o,t,n,l,i,b,e,m,_,R,p,u){const r=k(u),a=m-r.top-r.bottom,d=u.scrollTop??0,g=I(o),M=a;if(g<=M||a<=0)return;const s=a*2,y=Math.max(2,Math.round(M/g*s)),f=g-M,x=s-y,A=f>0?Math.round(d/f*x):0,c=typeof u.scrollbarThumbColor=="string"?O(u.scrollbarThumbColor):_,h=i+e-1-r.right,w=R<<16|65280|c;for(let B=0;B<a;B++){const T=B*2,Y=T+1,S=T>=A&&T<A+y,L=Y>=A&&Y<A+y;if(!S&&!L)continue;let v=E;S&&!L?v=F:!S&&L&&(v=H),C(t,n,l,h,b+r.top+B,v,w,p)}}function V(o,t,n,l,i,b,e,m,_,R,p,u,r,a){const d=k(a),g=a.scrollTop??0,M=b+d.top;for(const s of o.children){if(!s._style?.sticky)continue;const y=s.getLayout();if(y.top>=g)continue;const f=s.parent;if(f&&f!==o){const w=f.getLayout();if(w.top+w.height<=g)continue}const x=M,A=s.fg===255?_:s.fg,c=s.bg===255?R:s.bg,h=s.styles===0?p:s.styles;X(s,t,n,l,i-y.left,x-y.top,A,c,h,u,r)}}function Q(o,t,n,l){for(let e=0;e<t.length;e+=2)t[e]=32,t[e+1]=65535;const i=[],b={x0:0,x1:n,y0:0,y1:l};try{X(o,t,n,l,0,0,o.fg,o.bg,o.styles,i,b);for(const e of i)W(e.node,t,n,l,e.absX,e.absY,e.w,e.h,e.fg,e.bg,e.styles,e.clip)}catch(e){console.error("Renderer Error:",e)}}function C(o,t,n,l,i,b,e,m){if(l<m.x0||l>=m.x1||i<m.y0||i>=m.y1||l<0||l>=t||i<0||i>=n)return;const _=(i*t+l)*2;o[_]=b,o[_+1]=e}function W(o,t,n,l,i,b,e,m,_,R,p,u){if(!o._style?.borderStyle||e<=0||m<=0)return;const r=q[o._style.borderStyle],a=o._style.borderColor===void 0?_:O(o._style.borderColor),d=p<<16|R<<8|a,g=o._style.borderTop!==!1,M=o._style.borderBottom!==!1,s=o._style.borderLeft!==!1,y=o._style.borderRight!==!1,f=M&&(m>1||!g);if(g)for(let c=0;c<e;c++){let h;e===1?h=s&&y?r.left:s?r.topLeft:y?r.topRight:r.top:c===0&&s?h=r.topLeft:c===e-1&&y?h=r.topRight:h=r.top,C(t,n,l,i+c,b,h.codePointAt(0),d,u)}if(f)for(let c=0;c<e;c++){let h;e===1?h=s&&y?r.left:s?r.bottomLeft:y?r.bottomRight:r.bottom:c===0&&s?h=r.bottomLeft:c===e-1&&y?h=r.bottomRight:h=r.bottom,C(t,n,l,i+c,b+m-1,h.codePointAt(0),d,u)}const x=g?1:0,A=f?m-1:m;for(let c=x;c<A;c++)s&&C(t,n,l,i,b+c,r.left.codePointAt(0),d,u),y&&C(t,n,l,i+e-1,b+c,r.right.codePointAt(0),d,u)}function U(o){if(o._hidden)return"";if(o.text!==void 0)return o.text;const t=o.children.map(U).join("");return typeof o.transform=="function"?o.transform(t,0):t}function j(o,t,n,l,i,b,e,m,_,R){if(e<=0||m<=0)return;let p=0,u=0;for(const r of o){if(r===`
2
+ `){p=0,u++;continue}const a=r.codePointAt(0)??32,d=z(r);if(p+d>e&&(p=0,u++),u>=m)break;if(d>e){C(t,n,l,i+p,b+u,32,_,R),p+=1;continue}C(t,n,l,i+p,b+u,a,_,R),d===2&&p+1<e&&C(t,n,l,i+p+1,b+u,D,_,R),p+=d}}function X(o,t,n,l,i,b,e,m,_,R,p){if(o._hidden)return;const u=o.getLayout(),r=Math.round(i+u.left),a=Math.round(b+u.top),d=Math.round(u.width),g=Math.round(u.height),M=o.fg===255?e:o.fg,s=o.bg===255?m:o.bg,y=o.styles===0?_:o.styles,f={x0:Math.max(p.x0,r),x1:Math.min(p.x1,r+d),y0:Math.max(p.y0,a),y1:Math.min(p.y1,a+g)};if(f.x0>=f.x1||f.y0>=f.y1)return;if(typeof o.transform=="function"){const L=U(o),v=o.transform(L,0),P=y<<16|s<<8|M;j(v,t,n,l,r,a,d,g,P,f);return}if(o.text===void 0){if(s!==255||y!==0){const L=y<<16|s<<8|M;for(let v=0;v<g;v++)for(let P=0;P<d;P++)C(t,n,l,r+P,a+v,32,L,f)}o._style?.borderStyle&&R.push({absX:r,absY:a,bg:s,clip:f,fg:M,h:g,node:o,styles:y,w:d})}else{const L=y<<16|s<<8|M;if(o.bg!==255)for(let v=0;v<g;v++)for(let P=0;P<d;P++)C(t,n,l,r+P,a+v,32,L,f);j(o.text,t,n,l,r,a,d,g,L,f)}const x=o._style,A=x?.overflow??"visible",c=x?.overflowX??A,h=x?.overflowY??A,w=c==="hidden"||c==="scroll",B=h==="hidden"||h==="scroll";let T=f,Y=0,S=0;if(w||B){const L=k(x);T={x0:w?Math.max(f.x0,r+L.left):f.x0,x1:w?Math.min(f.x1,r+d-L.right):f.x1,y0:B?Math.max(f.y0,a+L.top):f.y0,y1:B?Math.min(f.y1,a+g-L.bottom):f.y1},h==="scroll"&&typeof x?.scrollTop=="number"&&(S=-x.scrollTop),c==="scroll"&&typeof x?.scrollLeft=="number"&&(Y=-x.scrollLeft)}for(const L of o.children)L._style?.internalStickyAlternate||X(L,t,n,l,r+Y,a+S,M,s,y,R,T);(h==="scroll"||c==="scroll")&&x?.scrollbar!==!1&&N(o,t,n,l,r,a,d,g,M,y,f,x),h==="scroll"&&typeof x?.scrollTop=="number"&&V(o,t,n,l,r,a,d,g,M,s,y,R,T,x)}export{Q as renderTreeToBuffer};
@@ -0,0 +1,17 @@
1
+ import{l as Me,i as xe}from"./dom-rphpG0kf.js";import{getStringWidth as V,isFullwidthCodePoint as Te,indent as ke}from"@visulima/string";import{B as H,D as $,I,U as z,e as Y,H as q,f as K,g as oe,F as A,h as re,S as we,j as Le,p as Re}from"./measure-text-B7juNq4Y.js";import x from"yoga-layout";import{j as F,i as _e,u as ie,c as se}from"./measure-element-D4M9iSYp.js";import{g as Be,a as j}from"./colorize-DU4YZkp3.js";import De from"@visulima/colorize";import We from"cli-boxes";import{getScrollTop as Ce}from"./calculateScroll-D4Y_JR4H.js";import be from"./squashTextNodesWithMap-BmUSBPfc.js";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
2
+ const require = __cjs_mod__.createRequire(import.meta.url);
3
+ const Oe=1114112,Pe=1,He=2,$e=3,Ae=4,Fe=7,Ge=8,Ie=9,ne=22,le=23,ae=24,de=27,he=28,ue=29,ce=39,ge=49,ze="\x1B[",M=o=>o.length===0?"":`${ze}${o.join(";")}m`,Ye=o=>{if(o.length===0)return"";let t="",e=0,r,i,l,n=!1,c=0;const f=o.getSpans();for(const g of f){const s=g.formatFlags&127,{fgColor:h}=g,{bgColor:u}=g,{link:a}=g,d=s;if(d!==e||h!==r||u!==i||a!==l){if(a!==l&&(l&&(t+=l.startsWith("ST:")?"\x1B]8;;\x1B\\":"\x1B]8;;\x07"),a)){const y=a.startsWith("ST:");t+=`\x1B]8;;${y?a.slice(3):a}${y?"\x1B\\":"\x07"}`}const p=e&(H|$),m=d&(H|$);if(p!==m){const y=e&H&&!(d&H),b=e&$&&!(d&$);(y||b)&&(t+=M([ne])),d&H&&(!(e&H)||b)&&(t+=M([Pe])),d&$&&(!(e&$)||y)&&(t+=M([He]))}d&I&&!(e&I)?t+=M([$e]):!(d&I)&&e&I&&(t+=M([le])),d&z&&!(e&z)?t+=M([Ae]):!(d&z)&&e&z&&(t+=M([ae])),d&Y&&!(e&Y)?t+=M([Fe]):!(d&Y)&&e&Y&&(t+=M([de])),d&q&&!(e&q)?t+=M([Ge]):!(d&q)&&e&q&&(t+=M([he])),d&K&&!(e&K)?t+=M([Ie]):!(d&K)&&e&K&&(t+=M([ue])),h!==r&&(t+=M(h?oe(h,!0):[ce])),u!==i&&(t+=M(u?oe(u,!1):[ge])),n=d!==0||h!==void 0||u!==void 0,e=d,r=h,i=u,l=a}t+=o.getTextRange(c,c+g.length),c+=g.length}return n&&(e&(H|$)&&(t+=M([ne])),e&I&&(t+=M([le])),e&z&&(t+=M([ae])),e&Y&&(t+=M([de])),e&q&&(t+=M([he])),e&K&&(t+=M([ue])),r!==void 0&&(t+=M([ce])),i!==void 0&&(t+=M([ge]))),l&&(t+=l.startsWith("ST:")?"\x1B]8;;\x1B\\":"\x1B]8;;\x07"),t};class J{widths=new Map;blockWidths=new Map;styledLines=new Map;lines=new Map;maxEntries;pruneToFactor;constructor(t={}){const{maxEntries:e=3e4,pruneToFactor:r=.8}=t;this.maxEntries=Math.max(1,e),this.pruneToFactor=Math.min(.99,Math.max(.1,r))}getStyledLine(t){let e=this.styledLines.get(t);return e===void 0&&(e=this.hasAnsiControlMarker(t)?Le(t):Re(t),this.setCacheEntry(this.styledLines,t,e)),e}getStringWidth(t){let e=this.widths.get(t);return e===void 0&&(e=V(t),this.setCacheEntry(this.widths,t,e)),e}getWidestLine(t){let e=this.blockWidths.get(t);if(e===void 0){let r=0;for(const i of this.getLines(t))r=Math.max(r,this.getStringWidth(i));e=r,this.setCacheEntry(this.blockWidths,t,e)}return e}getLines(t){let e=this.lines.get(t);return e===void 0&&(e=t.split(`
4
+ `),this.setCacheEntry(this.lines,t,e)),e}hasAnsiControlMarker(t){for(const e of t){const r=e.codePointAt(0);if(qe.has(r))return!0}return!1}setCacheEntry(t,e,r){!t.has(e)&&t.size>=this.maxEntries&&this.pruneCache(t),t.set(e,r)}pruneCache(t){const e=Math.floor(this.maxEntries*this.pruneToFactor);for(const r of t.keys())if(t.delete(r),t.size<=e)break}}const qe=new Set([27,144,152,155,157,158,159]),Ke=.6,Xe=30;class Q{width;height;caches;grid;clipStack=[];previousLines=[];previousRenderedLines=[];lineMemoizationEnabled=!0;memoizationProbeCountdown=0;constructor(t){const{caches:e,height:r,width:i}=t;this.width=Math.round(i),this.height=Math.round(r),this.caches=e??new J,this.grid=this.createGrid(this.width,this.height)}reset(t,e){this.width=Math.round(t),this.height=Math.round(e),this.clipStack.length=0,this.grid=this.createGrid(this.width,this.height)}startChildRegion(t,e,r,i){const l=Math.round(t),n=Math.round(e);this.clipStack.push({x1:l,x2:l+Math.round(r),y1:n,y2:n+Math.round(i)})}endChildRegion(){this.clipStack.pop()}write(t,e,r,i){if(!r)return;const{transformers:l}=i,n=this.clipStack.at(-1),c=this.caches.getLines(r),f=l.length>0;for(const[g,s]of c.entries()){const h=e+g;if(h<0||h>=this.grid.length||n&&(h<n.y1||h>=n.y2))continue;let u=s;if(f)for(const k of l)u=k(u,g);if(u.length===0)continue;const a=this.grid[h],d=this.caches.getStyledLine(u);let p=t;const m=n?Math.min(n.x2,a.length):1/0,y=d.getSpans();let b=0,T=y[0]?.length??0;for(let k=0;k<d.length;k++){for(;b<y.length&&k>=T;)b++,T+=y[b]?.length??0;if(p>=m)break;if(n&&(p<n.x1||p>=n.x2)){p++,d.getFullWidth(k)&&p++;continue}if(p>=0){p>=a.length&&a.ensureWidth(p+2);const v=y[b],C=d.getFullWidth(k),S=(v?.formatFlags??0)|(C?A:0);a.setCharFast(p,d.getValue(k),S,v?.fgColor,v?.bgColor,v?.link),C&&(p++,p>=a.length&&a.ensureWidth(p+1),a.setCharFast(p,"",S&~A,v?.fgColor,v?.bgColor,v?.link))}p++}}}writeStyledLine(t,e,r){if(r.length===0||e<0||e>=this.grid.length)return;const i=this.clipStack.at(-1);i&&(e<i.y1||e>=i.y2)||this.writeStyledLineToRow(this.grid[e],t,r,this.width,i)}getRootLines(){return this.grid}getCurrentClip(){return this.clipStack.at(-1)}addRegionTree(t,e,r){for(let i=0;i<t.height;i++){const l=r+i;if(l<0||l>=this.grid.length)continue;const n=t.lines[i];if(!n)continue;const c=this.grid[l],f=n.getSpans();let g=0,s=f[0]?.length??0;for(let h=0;h<n.length;h++){for(;g<f.length&&h>=s;)g++,s+=f[g]?.length??0;const u=e+h;if(u<0||u>=c.length)continue;const a=n.getValue(h),d=f[g],p=d!==void 0&&(d.formatFlags&~A)!==0||d?.fgColor!==void 0||d?.bgColor!==void 0||d?.link!==void 0;if(a!==" "||p){const m=(d?.formatFlags??0)|(n.getFullWidth(h)?A:0);c.setCharFast(u,a,m,d?.fgColor,d?.bgColor,d?.link)}}}for(const i of t.children)this.addRegionTree(i,e+i.x,r+i.y)}writeStyledLineToRow(t,e,r,i,l){let n=e;const c=l?Math.min(l.x2,i):1/0,f=r.getSpans();let g=0,s=f[0]?.length??0;for(let h=0;h<r.length;h++){for(;g<f.length&&h>=s;)g++,s+=f[g]?.length??0;if(n>=c)break;if(l&&(n<l.x1||n>=l.x2)){n++,r.getFullWidth(h)&&n++;continue}if(n>=0){n>=t.length&&t.ensureWidth(n+2);const u=f[g],a=r.getFullWidth(h),d=(u?.formatFlags??0)|(a?A:0);t.setCharFast(n,r.getValue(h),d,u?.fgColor,u?.bgColor,u?.link),a&&(n++,n>=t.length&&t.ensureWidth(n+1),t.setCharFast(n,"",d&~A,u?.fgColor,u?.bgColor,u?.link))}n++}}get(){const t=this.grid;this.lineMemoizationEnabled||(this.memoizationProbeCountdown>0?this.memoizationProbeCountdown--:this.lineMemoizationEnabled=!0);const e=this.lineMemoizationEnabled,r=this.previousLines.length>0,i=e&&r&&this.previousLines.length===t.length&&this.previousRenderedLines.length===t.length;this.previousLines.length>t.length&&(this.previousLines.length=t.length),this.previousRenderedLines.length>t.length&&(this.previousRenderedLines.length=t.length);const l=Array.from({length:t.length});let n=0;for(const[c,f]of t.entries()){const g=f;if(i&&this.previousLines[c]?.equals(g)){l[c]=this.previousRenderedLines[c]??"";continue}n++;const s=g.trimEnd(),h=Ye(s);l[c]=h,e&&(this.previousRenderedLines[c]=h,this.previousLines[c]=g.clone())}return e&&i&&t.length>0&&n/t.length>Ke&&this.disableLineMemoization(),{height:t.length,output:l.join(`
5
+ `)}}getBuffer(){const t=this.grid,e=t.length,r=new Uint32Array(this.width*e*2),i=65535;for(let l=0;l<r.length;l+=2)r[l]=32,r[l+1]=i;for(let l=0;l<e;l++){const n=t[l],c=n.getSpans();let f=0,g=c[0]?.length??0;for(let s=0;s<n.length&&s<this.width;s++){for(;f<c.length&&s>=g;)f++,g+=c[f]?.length??0;const h=n.getValue(s);if(h.length===0)continue;const u=h.codePointAt(0)??32,a=(l*this.width+s)*2,d=c[f],p=d?.formatFlags??0,m=d?.fgColor,y=d?.bgColor,b=m?re(m):255,T=y?re(y):255,k=(p&255)<<16|(T&255)<<8|b&255;if(r[a]=u,r[a+1]=k,n.getFullWidth(s)&&s+1<this.width){const v=a+2;r[v]=Oe,r[v+1]=k,s++}}}return{buffer:r,height:e}}createGrid(t,e){const r=[];for(let i=0;i<e;i++)r.push(we.empty(t));return r}disableLineMemoization(){this.lineMemoizationEnabled=!1,this.memoizationProbeCountdown=Xe,this.previousLines.length=0,this.previousRenderedLines.length=0}}const je=o=>Math.round(o.getComputedWidth()-Math.max(0,o.getComputedLeft()+o.getComputedWidth()-(o.getParent()?.getComputedWidth()??o.getComputedWidth()))-o.getComputedPadding(x.EDGE_LEFT)-o.getComputedPadding(x.EDGE_RIGHT)-o.getComputedBorder(x.EDGE_LEFT)-o.getComputedBorder(x.EDGE_RIGHT)),Ve=(o,t,e,r)=>{if(!e.style.backgroundColor)return;const i=Math.round(e.yogaNode.getComputedWidth()),l=Math.round(e.yogaNode.getComputedHeight()),n=e.style.borderStyle&&e.style.borderLeft!==!1?1:0,c=e.style.borderStyle&&e.style.borderRight!==!1?1:0,f=e.style.borderStyle&&e.style.borderTop!==!1?1:0,g=e.style.borderStyle&&e.style.borderBottom!==!1?1:0,s=i-n-c,h=l-f-g;if(!(s>0&&h>0))return;const u=Be(e.style.backgroundColor);if(!u)return;const a=`${u}${" ".repeat(s)}\x1B[49m`;for(let d=0;d<h;d++)r.write(o+n,t+f+d,a,{transformers:[]})},O=(o,t,e,r)=>{let i=j(o,t,"foreground");return i=j(i,e,"background"),r&&(i=De.dim(i)),i},fe=(o,t,e,r,i,l,n,c)=>{if(!e&&!i)return O(o.repeat(t),l,n,c);const f=e?` ${e} `:"",g=i?` ${i} `:"",s=f.length,h=g.length,u=r??"left";if(s+h>=t){if(s>=t)return`${f.slice(0,t-1)}…`;const m=t-s;return m>3?f+g.slice(0,m):f+O(o.repeat(t-s),l,n,c)}const a=t-s-h;if(u==="left"||i)return f+O(o.repeat(a),l,n,c)+g;if(u==="right"){const m=t-s;return O(o.repeat(m),l,n,c)+f}const d=Math.floor(a/2),p=a-d;return O(o.repeat(d),l,n,c)+f+O(o.repeat(p),l,n,c)},Ue=(o,t,e,r)=>{if(e.style.borderStyle){const i=Math.round(e.yogaNode.getComputedWidth()),l=Math.round(e.yogaNode.getComputedHeight()),n=typeof e.style.borderStyle=="string"?We[e.style.borderStyle]:e.style.borderStyle,c=e.style.borderTopColor??e.style.borderColor,f=e.style.borderBottomColor??e.style.borderColor,g=e.style.borderLeftColor??e.style.borderColor,s=e.style.borderRightColor??e.style.borderColor,h=e.style.borderTopBackgroundColor??e.style.borderBackgroundColor,u=e.style.borderBottomBackgroundColor??e.style.borderBackgroundColor,a=e.style.borderLeftBackgroundColor??e.style.borderBackgroundColor,d=e.style.borderRightBackgroundColor??e.style.borderBackgroundColor,p=e.style.borderTopDimColor??e.style.borderDimColor,m=e.style.borderBottomDimColor??e.style.borderDimColor,y=e.style.borderLeftDimColor??e.style.borderDimColor,b=e.style.borderRightDimColor??e.style.borderDimColor,T=e.style.borderTop!==!1,k=e.style.borderBottom!==!1,v=e.style.borderLeft!==!1,C=e.style.borderRight!==!1,S=Math.max(0,i-(v?1:0)-(C?1:0));let N;if(T){const B=v?O(n.topLeft,c,h,p):"",D=C?O(n.topRight,c,h,p):"",W=fe(n.top,S,e.style.borderTopTitle,e.style.borderTopTitleAlignment,e.style.borderTopRightTitle,c,h,p);N=B+W+D}let E=l;T&&(E-=1),k&&(E-=1),E=Math.max(0,E);let R="";v&&(R=`${O(n.left,g,a,y)}
6
+ `.repeat(E));let w="";C&&(w=`${O(n.right,s,d,b)}
7
+ `.repeat(E));let L;if(k){const B=v?O(n.bottomLeft,f,u,m):"",D=C?O(n.bottomRight,f,u,m):"",W=fe(n.bottom,S,e.style.borderBottomTitle,e.style.borderBottomTitleAlignment,void 0,f,u,m);L=B+W+D}const _=T?1:0;N&&r.write(o,t,N,{transformers:[]}),R&&r.write(o,t+_,R,{transformers:[]}),w&&r.write(o+i-1,t+_,w,{transformers:[]}),L&&r.write(o,t+l-1,L,{transformers:[]})}},pe=[],me=({axis:o,color:t,layout:e,output:r})=>{const{thumb:{end:i,endHalf:l,start:n,startHalf:c},x:f,y:g}=e;if(o==="vertical")for(let s=n;s<i;s++){let h="█";const u=2*s>=c&&2*s<l,a=2*s+1>=c&&2*s+1<l;u&&!a?h="▀":!u&&a&&(h="▄");const d=t?j(h,t,"foreground"):h;r.write(f,g+s,d,{transformers:pe})}else for(let s=n;s<i;s++){let h="█";const u=2*s>=c&&2*s<l,a=2*s+1>=c&&2*s+1<l;u&&!a?h="▌":!u&&a&&(h="▐");const d=t?j(h,t,"foreground"):h;r.write(f+s,g,d,{transformers:pe})}},ve=(o,t=[])=>{for(const e of o.childNodes){if(e.nodeName==="#text")continue;const r=e;if(!r.internal_stickyAlternate)if(r.internal_sticky)t.push({node:r,type:r.internal_sticky==="bottom"?"bottom":"top"});else{const i=r.style.overflow??"visible",l=r.style.overflowX??i,n=r.style.overflowY??i;!(l==="scroll"||n==="scroll")&&r.childNodes&&ve(r,t)}}return t},Je=(o,t,e,r)=>{let i,l=-1,n,c=-1;for(const[g,s]of o.entries()){const{node:h,type:u}=s;if(!h.yogaNode)continue;const a=F(h,t)??0,d=Math.round(h.yogaNode.getComputedHeight()),p=a+d,m=h.parentNode;let y=0,b=Number.MAX_SAFE_INTEGER;m?.yogaNode&&(y=F(m,t)??0,b=Math.round(m.yogaNode.getComputedHeight())),u==="top"&&a<e&&y+b>e&&(i=s,l=g),u==="bottom"&&Math.floor(p)>Math.floor(r)&&y<r&&(n=s,c=g)}const f=[];if(i){let g;for(let s=l+1;s<o.length;s++){const h=o[s];if(h.type!=="bottom"){g=h;break}}f.push({nextStickyNodeInfo:g,stickyNode:i.node,type:"top"})}if(n){let g;for(let s=c-1;s>=0;s--){const h=o[s];if(h.type==="bottom"){g=h;break}}f.push({nextStickyNodeInfo:g,stickyNode:n.node,type:"bottom"})}return f},Qe=(o,t,e,r,i)=>{const{newTransformers:l,renderNodeToOutput:n,skipStaticElements:c,x:f,y:g}=i,{yogaNode:s}=t;if(!s)return;const h=s.getComputedBorder(x.EDGE_TOP),u=s.getComputedBorder(x.EDGE_LEFT),a=Ce(t),d=t.internal_scrollState?.clientHeight??0;for(const{nextStickyNodeInfo:p,stickyNode:m,type:y}of o){if(!m.yogaNode)continue;const b=F(m,t)??0,T=Math.round(m.yogaNode.getComputedHeight()),k=f+(_e(m,t)??0),v=m.parentNode;let C=0,S=Number.MAX_SAFE_INTEGER;v?.yogaNode&&(C=F(v,t)??0,S=Math.round(v.yogaNode.getComputedHeight()));let N;if(y==="top"){const w=v?.yogaNode?.getComputedBorder(x.EDGE_BOTTOM)??0,L=C+S-w;let _=g-a+L-T;const B=g-a+b,D=g+h;if(p?.node?.yogaNode){const W=F(p.node,t)??0,P=g-a+W-T;P<_&&(_=P)}N=Math.min(Math.max(D,B),_)}else{const w=v?.yogaNode?.getComputedBorder(x.EDGE_TOP)??0;let L=g-a+C+w;const _=g-a+b,B=g+h+d-T;if(p?.node?.yogaNode){const D=Math.round(p.node.yogaNode.getComputedHeight()),W=F(p.node,t)??0,P=g-a+W+D;P>L&&(L=P)}N=Math.max(Math.min(B,_),L)}const E=r({height:T,width:Math.round(m.yogaNode.getComputedWidth())});n(m,E,{offsetX:-Math.round(m.yogaNode.getComputedLeft()),offsetY:-Math.round(m.yogaNode.getComputedTop()),skipStaticElements:c,transformers:l});const R=E.get().output.split(`
8
+ `);for(const[w,L]of R.entries())L&&L.length>0&&e.write(k-(f+u),N-(g+h)+w,L,{transformers:[]})}},Ze=(o,t)=>{const e=o.childNodes[0]?.yogaNode;if(e){const r=Math.round(e.getComputedLeft()),i=Math.round(e.getComputedTop());t=`
9
+ `.repeat(i)+ke(t,r)}return t},et=31,tt=127,ot=128,rt=159,it=(o,t)=>{if(!Number.isFinite(t))return!1;if(t<0)return!0;let e=0;for(const r of o){if(r===`
10
+ `){if(e>t)return!0;e=0;continue}const i=r.codePointAt(0);if(i<=et||i===tt||i>=ot&&i<=rt||Te(i)||(e++,e>t))return!0}return!1},st=o=>(o.internal_hidden??!1)||o.yogaNode?.getDisplay()===x.DISPLAY_NONE,nt=o=>{let t=o;for(;t;){if(st(t))return!0;t=t.parentNode}return!1},U=(o,t={})=>{if(t.skipStaticElements&&o.internal_static||o.internal_hidden||o.internal_stickyAlternate||o.yogaNode?.getDisplay()===x.DISPLAY_NONE)return"";let e="";if(o.nodeName==="ink-text")e=be(o);else if(o.nodeName==="ink-box"||o.nodeName==="ink-root"){const r=o.style.flexDirection==="row"||o.style.flexDirection==="row-reverse"?" ":`
11
+ `;e=(o.style.flexDirection==="row-reverse"||o.style.flexDirection==="column-reverse"?o.childNodes.toReversed():[...o.childNodes]).map(i=>U(i,{parentRole:o.internal_accessibility?.role,skipStaticElements:t.skipStaticElements})).filter(Boolean).join(r)}if(o.internal_accessibility){const{role:r,state:i}=o.internal_accessibility;if(i){const l=Object.keys(i).filter(n=>i[n]).join(", ");l&&(e=`(${l}) ${e}`)}r&&r!==t.parentRole&&(e=`${r}: ${e}`)}return e},X=(o,t,e)=>{const{absoluteOffsetX:r,absoluteOffsetY:i,offsetX:l=0,offsetY:n=0,renderState:c,skipStaticElements:f,transformers:g=[]}=e;if(f&&o.internal_static||o.internal_hidden)return;if(o.cachedRender){const h=Math.round(l+(o.yogaNode?.getComputedLeft()??0)),u=Math.round(n+(o.yogaNode?.getComputedTop()??0));t.addRegionTree(o.cachedRender,h,u);return}if(o.nodeName==="ink-cursor"){if(!c)return;c.cursorRequested=!0;const h=o.internal_cursor;if(!h){c.cursorPosition=void 0;return}if(c.cursorShape=h.shape,h.inline){if(c.lastTextWriteEnd)c.cursorPosition={x:c.lastTextWriteEnd.x,y:c.lastTextWriteEnd.y};else{const d=o.parentNode?ie(o.parentNode):void 0;c.cursorPosition=d?{x:d.x,y:d.y}:void 0}return}const u=h.anchorRef?h.anchorRef.current:o.parentNode;if(!u){c.cursorPosition=void 0;return}if(h.anchorRef&&nt(u)){c.cursorPosition=void 0;return}const a=ie(u);if(!a){c.cursorPosition=void 0;return}c.cursorPosition={x:a.x+h.x,y:a.y+h.y};return}const{yogaNode:s}=o;if(s){if(s.getDisplay()===x.DISPLAY_NONE)return;const h=s.getComputedLeft(),u=s.getComputedTop(),a=Math.round(l+h),d=Math.round(n+u),p=Math.round((r??l)+h),m=Math.round((i??n)+u),y=t.getCurrentClip();if(y){const C=Math.round(s.getComputedWidth()),S=Math.round(s.getComputedHeight()),N=p+C,E=m+S,R=y.x1??-1/0,w=y.x2??1/0,L=y.y1??-1/0,_=y.y2??1/0;if(N<=R||p>=w||E<=L||m>=_)return}let b=g;if(typeof o.internal_transform=="function"&&(b=[o.internal_transform,...g]),o.nodeName==="ink-text"){let C=be(o);if(C.length>0){const S=je(s);if(it(C,S)&&Math.max(...C.split(`
12
+ `).map(N=>V(N)))>S){const N=o.style.textWrap??"wrap";C=Me(C,Math.floor(S),N)}if(C=Ze(o,C),t.write(a,d,C,{transformers:b}),c){const N=C.split(`
13
+ `),E=N.at(-1)??"";c.lastTextWriteEnd={x:a+V(E),y:d+N.length-1}}}return}let T=!1,k=0,v=0;if(o.nodeName==="ink-box"){Ve(a,d,o,t),Ue(a,d,o,t);const C=o.style.overflow??"visible",S=o.style.overflowX??C,N=o.style.overflowY??C,E=S==="hidden"||S==="scroll",R=N==="hidden"||N==="scroll";if(E||R){const w=Math.round(s.getComputedWidth()),L=Math.round(s.getComputedHeight()),_=E?a+s.getComputedBorder(x.EDGE_LEFT):a,B=E?w-s.getComputedBorder(x.EDGE_LEFT)-s.getComputedBorder(x.EDGE_RIGHT):w,D=R?d+s.getComputedBorder(x.EDGE_TOP):d,W=R?L-s.getComputedBorder(x.EDGE_TOP)-s.getComputedBorder(x.EDGE_BOTTOM):L;t.startChildRegion(_,D,Math.max(0,B),Math.max(0,W)),T=!0,N==="scroll"&&o.internal_scrollState&&(v=-o.internal_scrollState.scrollTop),S==="scroll"&&o.internal_scrollState&&(k=-o.internal_scrollState.scrollLeft)}}if(o.nodeName==="ink-root"||o.nodeName==="ink-box"||o.nodeName==="ink-static-render"){for(const C of o.childNodes)X(C,t,{absoluteOffsetX:p+k,absoluteOffsetY:m+v,offsetX:a+k,offsetY:d+v,renderState:c,skipStaticElements:f,transformers:b});if(o.nodeName==="ink-box"&&o.internal_scrollState){const C=ve(o);if(C.length>0){const S=Ce(o),N=o.internal_scrollState.clientHeight,E=S+N,R=Je(C,o,S,E);R.length>0&&Qe(R,o,t,w=>new Q(w),{newTransformers:b,renderNodeToOutput:X,skipStaticElements:f,x:a,y:d})}}if(o.nodeName==="ink-box"&&o.internal_scrollState){const C=o.style.overflow??"visible",S=o.style.overflowX??C,N=o.style.overflowY??C,E=s.getComputedBorder(x.EDGE_LEFT),R=s.getComputedBorder(x.EDGE_RIGHT),w=s.getComputedBorder(x.EDGE_TOP),L=s.getComputedBorder(x.EDGE_BOTTOM),_=Math.round(s.getComputedWidth()-E-R),B=Math.round(s.getComputedHeight()-w-L),{clientHeight:D,clientWidth:W,scrollHeight:P,scrollLeft:Ne,scrollTop:Se,scrollWidth:Z}=o.internal_scrollState,ee=N==="scroll"&&P>D,Ee=S==="scroll"&&Z>W,te=o.internal_scrollbar!==!1;if(ee&&te){const G=se({axis:"vertical",clientDimension:D,hasOppositeScrollbar:!1,height:B,marginBottom:0,marginRight:0,scrollDimension:P,scrollPosition:Se,width:_,x:a+E,y:d+w});G&&me({axis:"vertical",color:o.style.scrollbarThumbColor,layout:G,output:t})}if(Ee&&te){const G=se({axis:"horizontal",clientDimension:W,hasOppositeScrollbar:ee,height:B,marginBottom:0,marginRight:0,scrollDimension:Z,scrollPosition:Ne,width:_,x:a+E,y:d+w});G&&me({axis:"horizontal",color:o.style.scrollbarThumbColor,layout:G,output:t})}}T&&t.endChildRegion()}}},St=(o,t)=>{if(!o.yogaNode)return;const e=Math.round(o.yogaNode.getComputedWidth()),r=Math.round(o.yogaNode.getComputedHeight());if(e<=0||r<=0)return;const{setCachedRender:i}=require("./dom"),l=new Q({height:r,width:e});for(const c of o.childNodes)X(c,l,{skipStaticElements:t?.skipStaticElements});const n={children:[],cursorPosition:void 0,height:r,id:o.internalId??"static",isScrollable:!1,lines:[...l.getRootLines()],selectableSpans:[],stickyHeaders:[],styledOutput:[...l.getRootLines()],width:e,x:0,y:0};i(o,n)},lt=(o,t)=>{const e=new Map;if(t.rangeCount===0)return e;const r=t.getRangeAt(0),{endContainer:i,endOffset:l,startContainer:n,startOffset:c}=r;if(!n||!i)return e;let f=!1,g=!1;const s=(u,a,d,p,m,y)=>{if(u.nodeName==="#text"){const{length:b}=u.nodeValue;n===u&&(m.value=!0,d.value=a.value+c),i===u&&(y.value=!0,p.value=a.value+l),a.value+=b}else if("childNodes"in u){for(const b of u.childNodes)u===n&&(m.value=!0,d.value=a.value),u===i&&(y.value=!0,p.value=a.value),s(b,a,d,p,m,y);u===n&&c===u.childNodes.length&&(m.value=!0,d.value=a.value),u===i&&l===u.childNodes.length&&(y.value=!0,p.value=a.value)}},h=u=>{if(u.nodeName==="ink-text"){if(!xe(u))return;const a={value:0},d={value:-1},p={value:-1},m={value:!1},y={value:!1};for(const b of u.childNodes)u===n&&(m.value=!0,d.value=a.value),u===i&&(y.value=!0,p.value=a.value),s(b,a,d,p,m,y);if(u===n&&c===u.childNodes.length&&(m.value=!0,d.value=a.value),u===i&&l===u.childNodes.length&&(y.value=!0,p.value=a.value),(f||m.value)&&(!g||y.value)){const b=m.value?d.value:0,T=y.value?p.value:a.value;b!==-1&&T!==-1&&b<T&&e.set(u,{end:T,start:b})}m.value&&(f=!0),y.value&&(g=!0)}else{const{childNodes:a}=u;if(a){for(const d of a)u===n&&(f=!0),u===i&&(g=!0),h(d);u===n&&c===a.length&&(f=!0),u===i&&l===a.length&&(g=!0)}}};return h(o),e},at=new J,dt=new J,ht=new WeakMap,ut=new WeakMap,ye=({caches:o,height:t,node:e,outputs:r,width:i})=>{let l=r.get(e);return l||(l=new Q({caches:o,height:t,width:i}),r.set(e,l)),l.reset(i,t),l},Et=(o,t,e)=>{if(o.yogaNode){if(t){const f=U(o,{skipStaticElements:!0}),g=f===""?0:f.split(`
14
+ `).length;let s="";return o.staticNode&&(s=U(o.staticNode,{skipStaticElements:!1})),{cursorPosition:void 0,cursorRequested:!1,cursorShape:void 0,output:f,outputHeight:g,staticOutput:s?`${s}
15
+ `:""}}e?.selection&&e.selection.rangeCount>0&&lt(o,e.selection);const r=ye({caches:at,height:o.yogaNode.getComputedHeight(),node:o,outputs:ht,width:o.yogaNode.getComputedWidth()}),i={cursorPosition:void 0,cursorRequested:!1,cursorShape:void 0};X(o,r,{renderState:i,skipStaticElements:!0});let l;if(o.staticNode?.yogaNode&&(l=ye({caches:dt,height:o.staticNode.yogaNode.getComputedHeight(),node:o,outputs:ut,width:o.staticNode.yogaNode.getComputedWidth()}),X(o.staticNode,l,{skipStaticElements:!1})),e?.useNativeRenderer){const{buffer:f,height:g}=r.getBuffer();return{cursorPosition:i.cursorPosition,cursorRequested:i.cursorRequested,cursorShape:i.cursorShape,output:"",outputBuffer:f,outputHeight:g,outputWidth:r.width,staticOutput:l?`${l.get().output}
16
+ `:""}}const{height:n,output:c}=r.get();return{cursorPosition:i.cursorPosition,cursorRequested:i.cursorRequested,cursorShape:i.cursorShape,output:c,outputHeight:n,staticOutput:l?`${l.get().output}
17
+ `:""}}return{cursorPosition:void 0,cursorRequested:!1,cursorShape:void 0,output:"",outputHeight:0,staticOutput:""}};export{Et as H,Q as I,X as _,St as r};