@visulima/tui 1.0.0-alpha.26 → 1.0.0-alpha.27

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 (30) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/components/controlled-scroll-view.js +1 -1
  3. package/dist/components/dialog.js +1 -1
  4. package/dist/components/scroll-bar-box.js +1 -1
  5. package/dist/components/scroll-bar.js +1 -1
  6. package/dist/components/scroll-list.js +1 -1
  7. package/dist/components/scroll-view.js +1 -1
  8. package/dist/ink/index.js +1 -1
  9. package/dist/packem_shared/ControlledScrollView-Cn4byU2n.js +1 -0
  10. package/dist/packem_shared/ResizeObserver-BI9bDy-j.js +1 -0
  11. package/dist/packem_shared/{ScrollBar-BKCK8jsb.js → ScrollBar-qa1IzDDv.js} +1 -1
  12. package/dist/packem_shared/ScrollBarBox-DchESZWv.js +1 -0
  13. package/dist/packem_shared/{ScrollList-Dc2LzJFv.js → ScrollList-BBAnRsrC.js} +1 -1
  14. package/dist/packem_shared/{ScrollView-yZyiky7k.js → ScrollView-CHAo7Epj.js} +1 -1
  15. package/dist/packem_shared/{calculateScrollbarLayout--eUVRLw7.js → calculateScrollbarLayout-Lf6i24c9.js} +1 -1
  16. package/dist/packem_shared/{controlled-scroll-view-BQ0JOudw.js → controlled-scroll-view-BVg7ywNW.js} +1 -1
  17. package/dist/packem_shared/measure-element-D4M9iSYp.js +1 -0
  18. package/dist/packem_shared/processLayout-I83k6vXE.js +2 -0
  19. package/dist/packem_shared/{render-DSuj2PjD.js → render-CuQecTAs.js} +1 -1
  20. package/dist/packem_shared/{renderToString-Do8K5Fyk.js → renderToString-DwXFY8Qh.js} +1 -1
  21. package/dist/packem_shared/renderer-k-xShm1P.js +17 -0
  22. package/dist/testing/index.js +1 -1
  23. package/index.js +550 -692
  24. package/package.json +13 -13
  25. package/dist/packem_shared/ControlledScrollView-btYXQFoC.js +0 -1
  26. package/dist/packem_shared/ResizeObserver-aX8XOr2u.js +0 -1
  27. package/dist/packem_shared/ScrollBarBox-CBhLo6eZ.js +0 -1
  28. package/dist/packem_shared/measure-element-Cs7_proT.js +0 -2
  29. package/dist/packem_shared/processLayout-tAee0ytT.js +0 -1
  30. package/dist/packem_shared/renderer-COXHo5Xk.js +0 -17
package/CHANGELOG.md CHANGED
@@ -1,3 +1,37 @@
1
+ ## @visulima/tui [1.0.0-alpha.27](https://github.com/visulima/visulima/compare/@visulima/tui@1.0.0-alpha.26...@visulima/tui@1.0.0-alpha.27) (2026-06-30)
2
+
3
+ ### Styles
4
+
5
+ * cs fixes ([2a960bb](https://github.com/visulima/visulima/commit/2a960bb1772c9dc70080e2d75d3a0d827034e294))
6
+
7
+ ### Miscellaneous Chores
8
+
9
+ * add fallow code-intelligence across all packages ([a3b4821](https://github.com/visulima/visulima/commit/a3b48215002e86fed20f2973038b5d4a0aa1ce04))
10
+ * **fallow:** resolve dead-code findings ([c4125d5](https://github.com/visulima/visulima/commit/c4125d53e03ac9d90115399634535991927a96cc))
11
+
12
+ ### Code Refactoring
13
+
14
+ * **tui:** resolve fallow dead-code findings ([24fc8ad](https://github.com/visulima/visulima/commit/24fc8ad90face6d37f02edb4e87d18a7f2eb7900))
15
+
16
+ ### Tests
17
+
18
+ * fix failing and flaky package tests ([3f2894e](https://github.com/visulima/visulima/commit/3f2894e816e99f465abb0d3b7d5161af69bbb4ec))
19
+ * **tui:** de-flake same-interval animation sync on slow ci ([d8418de](https://github.com/visulima/visulima/commit/d8418de0831740b473cdfde665811fe0eeccebdc))
20
+ * **tui:** gate ink input emits on the readable listener ([3c45fc6](https://github.com/visulima/visulima/commit/3c45fc666349d4c2983f92ed028ed65e1cb671a3))
21
+
22
+ ### Continuous Integration
23
+
24
+ * **fallow:** make fallow:health advisory (--report-only) ([d57148e](https://github.com/visulima/visulima/commit/d57148ea0e3556b4c24d8d336b9fa14987f5dc7d))
25
+
26
+
27
+ ### Dependencies
28
+
29
+ * **@visulima/ansi:** upgraded to 4.0.0-alpha.18
30
+ * **@visulima/colorize:** upgraded to 2.0.0-alpha.15
31
+ * **@visulima/error:** upgraded to 6.0.0-alpha.35
32
+ * **@visulima/string:** upgraded to 3.0.0-alpha.18
33
+ * **@visulima/boxen:** upgraded to 3.0.0-alpha.15
34
+
1
35
  ## @visulima/tui [1.0.0-alpha.26](https://github.com/visulima/visulima/compare/@visulima/tui@1.0.0-alpha.25...@visulima/tui@1.0.0-alpha.26) (2026-06-19)
2
36
 
3
37
  ### Bug Fixes
@@ -1 +1 @@
1
- import{C as r}from"../packem_shared/controlled-scroll-view-BQ0JOudw.js";export{r as ControlledScrollView};
1
+ import{C as r}from"../packem_shared/controlled-scroll-view-BVg7ywNW.js";export{r as ControlledScrollView};
@@ -1 +1 @@
1
- import{jsx as r,jsxs as j}from"react/jsx-runtime";import{useRef as M}from"react";import H from"../ink/hooks/use-terminal-palette.js";import I from"../ink/hooks/use-window-size.js";import{Box as o}from"./box.js";import{Text as R}from"./text.js";import{ScrollView as T}from"../packem_shared/ScrollView-yZyiky7k.js";const A=({backgroundColor:u,borderColor:l="cyan",borderStyle:f="round",children:h,columns:g,footer:d,maxHeight:e=.8,paddingX:i=2,paddingY:p=1,rows:b,scrollbarStyle:x="block",scrollRef:k,title:n,visible:C=!0,width:S=60})=>{const c=I(),{isLoading:w,palette:y}=H(),B=M(null),D=k??B;if(!C)return null;const a=g??(c.columns||80),t=b??(c.rows||24),s=u??(w?"black":y?.background??"black"),X=e<=1?Math.floor(t*e):Math.min(e,t-2),m=typeof n=="string"?r(o,{marginBottom:1,children:r(R,{bold:!0,color:l,children:n})}):n??null;return r(o,{alignItems:"center",height:t,justifyContent:"center",position:"absolute",width:a,children:j(o,{backgroundColor:s,borderBackgroundColor:s,borderColor:l,borderStyle:f,flexDirection:"column",maxHeight:X,opaque:!0,paddingY:p,width:Math.min(S,a-4),children:[m!=null&&r(o,{flexShrink:0,paddingX:i,children:m}),r(T,{flexGrow:1,flexShrink:1,paddingX:i,ref:D,scrollbar:!0,scrollbarColor:l,scrollbarStyle:x,children:h}),d!=null&&r(o,{alignItems:"center",flexDirection:"column",flexShrink:0,marginTop:1,paddingX:i,children:d})]})})};export{A as Dialog,A as default};
1
+ import{jsx as r,jsxs as j}from"react/jsx-runtime";import{useRef as M}from"react";import H from"../ink/hooks/use-terminal-palette.js";import I from"../ink/hooks/use-window-size.js";import{Box as o}from"./box.js";import{Text as R}from"./text.js";import{ScrollView as T}from"../packem_shared/ScrollView-CHAo7Epj.js";const A=({backgroundColor:u,borderColor:l="cyan",borderStyle:f="round",children:h,columns:g,footer:d,maxHeight:e=.8,paddingX:i=2,paddingY:p=1,rows:b,scrollbarStyle:x="block",scrollRef:k,title:n,visible:C=!0,width:S=60})=>{const c=I(),{isLoading:w,palette:y}=H(),B=M(null),D=k??B;if(!C)return null;const a=g??(c.columns||80),t=b??(c.rows||24),s=u??(w?"black":y?.background??"black"),X=e<=1?Math.floor(t*e):Math.min(e,t-2),m=typeof n=="string"?r(o,{marginBottom:1,children:r(R,{bold:!0,color:l,children:n})}):n??null;return r(o,{alignItems:"center",height:t,justifyContent:"center",position:"absolute",width:a,children:j(o,{backgroundColor:s,borderBackgroundColor:s,borderColor:l,borderStyle:f,flexDirection:"column",maxHeight:X,opaque:!0,paddingY:p,width:Math.min(S,a-4),children:[m!=null&&r(o,{flexShrink:0,paddingX:i,children:m}),r(T,{flexGrow:1,flexShrink:1,paddingX:i,ref:D,scrollbar:!0,scrollbarColor:l,scrollbarStyle:x,children:h}),d!=null&&r(o,{alignItems:"center",flexDirection:"column",flexShrink:0,marginTop:1,paddingX:i,children:d})]})})};export{A as Dialog,A as default};
@@ -1 +1 @@
1
- import{ScrollBarBox as l}from"../packem_shared/ScrollBarBox-CBhLo6eZ.js";export{l as ScrollBarBox};
1
+ import{ScrollBarBox as l}from"../packem_shared/ScrollBarBox-DchESZWv.js";export{l as ScrollBarBox};
@@ -1 +1 @@
1
- import{ScrollBar as l}from"../packem_shared/ScrollBar-BKCK8jsb.js";export{l as ScrollBar};
1
+ import{ScrollBar as l}from"../packem_shared/ScrollBar-qa1IzDDv.js";export{l as ScrollBar};
@@ -1 +1 @@
1
- import{ScrollList as l}from"../packem_shared/ScrollList-Dc2LzJFv.js";export{l as ScrollList};
1
+ import{ScrollList as l}from"../packem_shared/ScrollList-BBAnRsrC.js";export{l as ScrollList};
@@ -1 +1 @@
1
- import{ScrollView as e}from"../packem_shared/ScrollView-yZyiky7k.js";export{e as ScrollView};
1
+ import{ScrollView as e}from"../packem_shared/ScrollView-CHAo7Epj.js";export{e as ScrollView};
package/dist/ink/index.js CHANGED
@@ -1 +1 @@
1
- import{clearOsc52 as o,isOsc52Supported as r,writeOsc52 as a}from"../packem_shared/clearOsc52-BUpnQOav.js";import{COLOR_BLINDNESS_COMPENSATION as l,COLOR_BLINDNESS_SIMULATION as i,IDENTITY_MATRIX as n,applyColorMatrix as u,hexToRgb as f,rgbToHex as p,transformHexColor as c}from"../packem_shared/COLOR_BLINDNESS_COMPENSATION-Ilnoyeqc.js";import{g as m,i as x}from"../packem_shared/dom-rphpG0kf.js";import{IMECompositionBuffer as S,isIMEInput as h}from"../packem_shared/IMECompositionBuffer-VhC9HRCv.js";import{kittyFlags as M,kittyModifiers as O}from"../packem_shared/kittyFlags-g8ALyoCU.js";import{c as I,a as L,b,g as C,d as E,e as R,f as N,h as B,i as P,j as H,k as v,l as W,R as k,p as A}from"../packem_shared/measure-element-Cs7_proT.js";import{c as D,a as F,i as z,s as q,b as w,t as j}from"../packem_shared/measure-text-B7juNq4Y.js";import{default as U}from"../packem_shared/render-DSuj2PjD.js";import{default as X}from"../packem_shared/renderToString-Do8K5Fyk.js";import{default as G,ResizeObserverEntry as J}from"../packem_shared/ResizeObserver-aX8XOr2u.js";import{calculateScroll as Z,getScrollHeight as $,getScrollLeft as ee,getScrollTop as te,getScrollWidth as oe}from"../packem_shared/calculateScroll-D4Y_JR4H.js";import{Range as ae,Selection as se,applySelectionToStyledLine as le,comparePoints as ie}from"../packem_shared/Range-BsVYNWtg.js";import{squashTextNodesWithMap as ue}from"../packem_shared/squashTextNodesWithMap-BmUSBPfc.js";import{isTerminalPaletteQuerySupported as pe,queryTerminalPalette as ce}from"../packem_shared/isTerminalPaletteQuerySupported-BYzmqq9-.js";import{wrapOrTruncateStyledLine as me}from"../packem_shared/wrapOrTruncateStyledLine-46W8bTtv.js";import{default as ge}from"../packem_shared/Fullscreen-BRhuBLBh.js";import{default as he}from"../packem_shared/MouseProvider-DUqQ3Eaa.js";import{default as Me}from"../packem_shared/isIntersecting-Bo2npvMR.js";import{default as ye}from"./mouse/use-mouse-action.js";import{default as Le}from"./mouse/use-mouse.js";import{default as Ce}from"./mouse/use-mouse-position.js";import{default as Re}from"./mouse/use-on-mouse-hover.js";import{default as Be}from"./mouse/use-on-mouse-state.js";import{d as He}from"../packem_shared/ansi-parser-DlgLtOYO.js";import{useElementDimensions as We,useElementPosition as ke}from"./mouse/use-element-position.js";import{useOnMouseClick as _e}from"./mouse/use-on-mouse-click.js";export{l as COLOR_BLINDNESS_COMPENSATION,i as COLOR_BLINDNESS_SIMULATION,ge as Fullscreen,n as IDENTITY_MATRIX,S as IMECompositionBuffer,he as MouseProvider,ae as Range,G as ResizeObserver,J as ResizeObserverEntry,se as Selection,u as applyColorMatrix,le as applySelectionToStyledLine,Z as calculateScroll,I as calculateScrollbarLayout,L as calculateScrollbarThumb,o as clearOsc52,D as clearStringWidthCache,F as clearStyledLineCache,b as collectSortedFragments,ie as comparePoints,C as getAddedScrollHeight,E as getBoundingBox,R as getHorizontalScrollbarBoundingBox,N as getInnerHeight,B as getInnerWidth,m as getPathToRoot,P as getRelativeLeft,H as getRelativeTop,$ as getScrollHeight,ee as getScrollLeft,te as getScrollTop,oe as getScrollWidth,v as getText,W as getVerticalScrollbarBoundingBox,f as hexToRgb,z as inkCharacterWidth,h as isIMEInput,Me as isIntersecting,x as isNodeSelectable,r as isOsc52Supported,pe as isTerminalPaletteQuerySupported,M as kittyFlags,O as kittyModifiers,k as measureElement,He as parseSgrMouse,A as processLayout,ce as queryTerminalPalette,U as render,X as renderToString,p as rgbToHex,q as setEnableStyledLineCache,w as setStringWidthFunction,ue as squashTextNodesWithMap,j as toStyledLine,c as transformHexColor,We as useElementDimensions,ke as useElementPosition,ye as useMouseAction,Le as useMouseContext,Ce as useMousePosition,_e as useOnMouseClick,Re as useOnMouseHover,Be as useOnMouseState,me as wrapOrTruncateStyledLine,a as writeOsc52};
1
+ import{clearOsc52 as o,isOsc52Supported as r,writeOsc52 as a}from"../packem_shared/clearOsc52-BUpnQOav.js";import{COLOR_BLINDNESS_COMPENSATION as l,COLOR_BLINDNESS_SIMULATION as i,IDENTITY_MATRIX as n,applyColorMatrix as u,hexToRgb as f,rgbToHex as p,transformHexColor as c}from"../packem_shared/COLOR_BLINDNESS_COMPENSATION-Ilnoyeqc.js";import{g as d,i as x}from"../packem_shared/dom-rphpG0kf.js";import{IMECompositionBuffer as S,isIMEInput as h}from"../packem_shared/IMECompositionBuffer-VhC9HRCv.js";import{kittyFlags as M,kittyModifiers as O}from"../packem_shared/kittyFlags-g8ALyoCU.js";import{processLayout as I}from"../packem_shared/processLayout-I83k6vXE.js";import{c as b,a as C,b as E,g as R,d as N,e as B,f as P,h as H,i as v,j as W,k,l as A,R as _}from"../packem_shared/measure-element-D4M9iSYp.js";import{c as F,a as z,i as q,s as w,b as j,t as Q}from"../packem_shared/measure-text-B7juNq4Y.js";import{default as V}from"../packem_shared/render-CuQecTAs.js";import{default as Y}from"../packem_shared/renderToString-DwXFY8Qh.js";import{default as J,ResizeObserverEntry as K}from"../packem_shared/ResizeObserver-BI9bDy-j.js";import{calculateScroll as $,getScrollHeight as ee,getScrollLeft as te,getScrollTop as oe,getScrollWidth as re}from"../packem_shared/calculateScroll-D4Y_JR4H.js";import{Range as se,Selection as le,applySelectionToStyledLine as ie,comparePoints as ne}from"../packem_shared/Range-BsVYNWtg.js";import{squashTextNodesWithMap as fe}from"../packem_shared/squashTextNodesWithMap-BmUSBPfc.js";import{isTerminalPaletteQuerySupported as ce,queryTerminalPalette as me}from"../packem_shared/isTerminalPaletteQuerySupported-BYzmqq9-.js";import{wrapOrTruncateStyledLine as xe}from"../packem_shared/wrapOrTruncateStyledLine-46W8bTtv.js";import{default as Se}from"../packem_shared/Fullscreen-BRhuBLBh.js";import{default as Te}from"../packem_shared/MouseProvider-DUqQ3Eaa.js";import{default as Oe}from"../packem_shared/isIntersecting-Bo2npvMR.js";import{default as Ie}from"./mouse/use-mouse-action.js";import{default as be}from"./mouse/use-mouse.js";import{default as Ee}from"./mouse/use-mouse-position.js";import{default as Ne}from"./mouse/use-on-mouse-hover.js";import{default as Pe}from"./mouse/use-on-mouse-state.js";import{d as ve}from"../packem_shared/ansi-parser-DlgLtOYO.js";import{useElementDimensions as ke,useElementPosition as Ae}from"./mouse/use-element-position.js";import{useOnMouseClick as De}from"./mouse/use-on-mouse-click.js";export{l as COLOR_BLINDNESS_COMPENSATION,i as COLOR_BLINDNESS_SIMULATION,Se as Fullscreen,n as IDENTITY_MATRIX,S as IMECompositionBuffer,Te as MouseProvider,se as Range,J as ResizeObserver,K as ResizeObserverEntry,le as Selection,u as applyColorMatrix,ie as applySelectionToStyledLine,$ as calculateScroll,b as calculateScrollbarLayout,C as calculateScrollbarThumb,o as clearOsc52,F as clearStringWidthCache,z as clearStyledLineCache,E as collectSortedFragments,ne as comparePoints,R as getAddedScrollHeight,N as getBoundingBox,B as getHorizontalScrollbarBoundingBox,P as getInnerHeight,H as getInnerWidth,d as getPathToRoot,v as getRelativeLeft,W as getRelativeTop,ee as getScrollHeight,te as getScrollLeft,oe as getScrollTop,re as getScrollWidth,k as getText,A as getVerticalScrollbarBoundingBox,f as hexToRgb,q as inkCharacterWidth,h as isIMEInput,Oe as isIntersecting,x as isNodeSelectable,r as isOsc52Supported,ce as isTerminalPaletteQuerySupported,M as kittyFlags,O as kittyModifiers,_ as measureElement,ve as parseSgrMouse,I as processLayout,me as queryTerminalPalette,V as render,Y as renderToString,p as rgbToHex,w as setEnableStyledLineCache,j as setStringWidthFunction,fe as squashTextNodesWithMap,Q as toStyledLine,c as transformHexColor,ke as useElementDimensions,Ae as useElementPosition,Ie as useMouseAction,be as useMouseContext,Ee as useMousePosition,De as useOnMouseClick,Ne as useOnMouseHover,Pe as useOnMouseState,xe as wrapOrTruncateStyledLine,a as writeOsc52};
@@ -0,0 +1 @@
1
+ import"react/jsx-runtime";import"react";import"./measure-element-D4M9iSYp.js";import"../components/box.js";import{C as l}from"./controlled-scroll-view-BVg7ywNW.js";export{l as ControlledScrollView};
@@ -0,0 +1 @@
1
+ class d{constructor(e,s){this.target=e,this.contentRect=s}target;contentRect}class c{callback;observedElements=new Set;constructor(e){this.callback=e}observe(e){if(this.observedElements.has(e))return;this.observedElements.add(e),e.resizeObservers??=new Set,e.resizeObservers.add(this);let s=e.internal_lastMeasuredSize;if(s===void 0&&e.yogaNode){const i=Math.round(e.yogaNode.getComputedWidth()),r=Math.round(e.yogaNode.getComputedHeight());!Number.isNaN(i)&&!Number.isNaN(r)&&(s={height:r,width:i},e.internal_lastMeasuredSize=s)}if(s){const i=new d(e,s);try{this.callback([i],this)}catch(r){console.error(r)}}}unobserve(e){this.observedElements.delete(e),e.resizeObservers?.delete(this)}disconnect(){for(const e of this.observedElements)e.resizeObservers?.delete(this);this.observedElements.clear()}internalTrigger(e){try{this.callback(e,this)}catch(s){console.error(s)}}}function l(t,e,s=!1){const i=t.resizeObservers&&t.resizeObservers.size>0;if((i||s)&&t.yogaNode){const r=Math.round(t.yogaNode.getComputedWidth()),o=Math.round(t.yogaNode.getComputedHeight());if(!Number.isNaN(r)&&!Number.isNaN(o)){const n=t.internal_lastMeasuredSize;if((n?.width!==r||n.height!==o)&&(t.internal_lastMeasuredSize={height:o,width:r},i)){const h=new d(t,{height:o,width:r});for(const a of t.resizeObservers)e.has(a)||e.set(a,[]),e.get(a).push(h)}}}}export{d as ResizeObserverEntry,c as default,l as measureAndExtractObservers};
@@ -1 +1 @@
1
- import{jsx as i,jsxs as F}from"react/jsx-runtime";import{useMemo as I}from"react";import{Box as H}from"../components/box.js";import{Text as n}from"../components/text.js";const S={arrow:{lowerThumb:"╽",thumb:"┃",track:"|",upperThumb:"╿"},block:{thumb:"█",track:"░"},bold:{lowerThumb:"╿",thumb:"│",track:"┃",upperThumb:"╽"},classic:{thumb:"┃",track:"|"},dots:{thumb:"●",track:"·"},double:{thumb:"┃",track:"║"},doubleSingle:{lowerThumb:"╽",thumb:"┃",track:"│",upperThumb:"╿"},line:{thumb:"│",track:" "},round:{lowerThumb:"╽",thumb:"┃",track:"│",upperThumb:"╿"},single:{lowerThumb:"╽",thumb:"┃",track:"│",upperThumb:"╿"},singleDouble:{thumb:"┃",track:"║"},thick:{thumb:"┃",track:"╏"}},B={arrow:{bottomLeft:"└",bottomRight:"┘",topLeft:"┌",topRight:"┐"},bold:{bottomLeft:"┗",bottomRight:"┛",topLeft:"┏",topRight:"┓"},classic:{bottomLeft:"+",bottomRight:"+",topLeft:"+",topRight:"+"},double:{bottomLeft:"╚",bottomRight:"╝",topLeft:"╔",topRight:"╗"},doubleSingle:{bottomLeft:"╘",bottomRight:"╛",topLeft:"╒",topRight:"╕"},round:{bottomLeft:"╰",bottomRight:"╯",topLeft:"╭",topRight:"╮"},single:{bottomLeft:"└",bottomRight:"┘",topLeft:"┌",topRight:"┐"},singleDouble:{bottomLeft:"╙",bottomRight:"╜",topLeft:"╓",topRight:"╖"}},Y=t=>S[typeof t=="string"?t:"single"]??S.single??{thumb:"┃",track:"│"},_=t=>B[typeof t=="string"?t:"single"]??B.single??{bottomLeft:"└",bottomRight:"┘",topLeft:"┌",topRight:"┐"},N=({autoHide:t=!1,color:m,contentHeight:L,dimColor:l,placement:p="right",scrollOffset:R,style:c,thumbChar:k,trackChar:x,viewportHeight:e})=>{const a=I(()=>{const r=Math.max(L,e);if(t&&r<=e)return null;const o=Y(c),f=k??o.thumb,q=x??o.track,w=e*2,v=Math.min(e/r,1),T=Math.max(2,Math.round(w*v)),M=r-e,A=M>0?Math.min(Math.max(R/M,0),1):0,E=w-T,s=Math.round(A*E),C=s+T,h=[];for(let b=0;b<e;b+=1){const D=b*2,y=b*2+1,g=D>=s&&D<C,d=y>=s&&y<C;g&&d?h.push(f):g&&!d?h.push(o.lowerThumb??f):!g&&d?h.push(o.upperThumb??f):h.push(q)}return h},[L,e,R,c,k,x,t]);if(a===null)return null;if(p==="inset")return i(H,{flexDirection:"column",flexShrink:0,width:1,children:a.map((r,o)=>i(n,{color:m,dimColor:l,children:r},o))});const u=_(c),j=p==="left"?u.topLeft:u.topRight,O=p==="left"?u.bottomLeft:u.bottomRight;return F(H,{flexDirection:"column",flexShrink:0,width:1,children:[i(n,{color:m,dimColor:l,children:j}),a.map((r,o)=>i(n,{color:m,dimColor:l,children:r},o)),i(n,{color:m,dimColor:l,children:O})]})};export{N as ScrollBar,N as default};
1
+ import{jsx as i,jsxs as I}from"react/jsx-runtime";import{useMemo as N}from"react";import{Box as H}from"../components/box.js";import{Text as p}from"../components/text.js";const S={arrow:{lowerThumb:"╽",thumb:"┃",track:"|",upperThumb:"╿"},block:{thumb:"█",track:"░"},bold:{lowerThumb:"╿",thumb:"│",track:"┃",upperThumb:"╽"},classic:{thumb:"┃",track:"|"},dots:{thumb:"●",track:"·"},double:{thumb:"┃",track:"║"},doubleSingle:{lowerThumb:"╽",thumb:"┃",track:"│",upperThumb:"╿"},line:{thumb:"│",track:" "},round:{lowerThumb:"╽",thumb:"┃",track:"│",upperThumb:"╿"},single:{lowerThumb:"╽",thumb:"┃",track:"│",upperThumb:"╿"},singleDouble:{thumb:"┃",track:"║"},thick:{thumb:"┃",track:"╏"}},B={arrow:{bottomLeft:"└",bottomRight:"┘",topLeft:"┌",topRight:"┐"},bold:{bottomLeft:"┗",bottomRight:"┛",topLeft:"┏",topRight:"┓"},classic:{bottomLeft:"+",bottomRight:"+",topLeft:"+",topRight:"+"},double:{bottomLeft:"╚",bottomRight:"╝",topLeft:"╔",topRight:"╗"},doubleSingle:{bottomLeft:"╘",bottomRight:"╛",topLeft:"╒",topRight:"╕"},round:{bottomLeft:"╰",bottomRight:"╯",topLeft:"╭",topRight:"╮"},single:{bottomLeft:"└",bottomRight:"┘",topLeft:"┌",topRight:"┐"},singleDouble:{bottomLeft:"╙",bottomRight:"╜",topLeft:"╓",topRight:"╖"}},Y=t=>S[typeof t=="string"?t:"single"]??S.single??{thumb:"┃",track:"│"},_=t=>B[typeof t=="string"?t:"single"]??B.single??{bottomLeft:"└",bottomRight:"┘",topLeft:"┌",topRight:"┐"},K=({autoHide:t=!1,color:m,contentHeight:L,dimColor:l,placement:n="right",scrollOffset:R,style:c,thumbChar:k,trackChar:x,viewportHeight:e})=>{const a=N(()=>{const r=Math.max(L,e);if(t&&r<=e)return null;const o=Y(c),f=k??o.thumb,q=x??o.track,w=e*2,v=Math.min(e/r,1),T=Math.max(2,Math.round(w*v)),M=r-e,A=M>0?Math.min(Math.max(R/M,0),1):0,E=w-T,s=Math.round(A*E),C=s+T,h=[];for(let b=0;b<e;b+=1){const D=b*2,y=b*2+1,g=D>=s&&D<C,d=y>=s&&y<C;g&&d?h.push(f):g&&!d?h.push(o.lowerThumb??f):!g&&d?h.push(o.upperThumb??f):h.push(q)}return h},[L,e,R,c,k,x,t]);if(a===null)return null;if(n==="inset")return i(H,{flexDirection:"column",flexShrink:0,width:1,children:a.map((r,o)=>i(p,{color:m,dimColor:l,children:r},o))});const u=_(c),j=n==="left"?u.topLeft:u.topRight,O=n==="left"?u.bottomLeft:u.bottomRight;return I(H,{flexDirection:"column",flexShrink:0,width:1,children:[i(p,{color:m,dimColor:l,children:j}),a.map((r,o)=>i(p,{color:m,dimColor:l,children:r},o)),i(p,{color:m,dimColor:l,children:O})]})};export{K as ScrollBar};
@@ -0,0 +1 @@
1
+ import{jsxs as D,jsx as l}from"react/jsx-runtime";import{Box as b}from"../components/box.js";import{ScrollBar as a}from"./ScrollBar-qa1IzDDv.js";const S=({borderColor:r,borderDimColor:e,borderLeftColor:g,borderLeftDimColor:C,borderRightColor:p,borderRightDimColor:H,borderStyle:t="single",children:u,contentHeight:i,height:x,scrollBarAutoHide:h=!1,scrollBarPosition:w="right",scrollOffset:d,thumbChar:s,viewportHeight:c,...B})=>{const o=w==="left",f=o?"left":"right",m=o?g??r:p??r,n=o?C??e:H??e;return D(b,{flexDirection:"row",height:x,...B,children:[o&&l(a,{autoHide:h,color:m,contentHeight:i,dimColor:n,placement:f,scrollOffset:d,style:t,thumbChar:s,viewportHeight:c}),l(b,{borderColor:r,borderDimColor:e,borderLeft:!o,borderRight:o,borderStyle:t,flexGrow:1,overflow:"hidden",children:u}),!o&&l(a,{autoHide:h,color:m,contentHeight:i,dimColor:n,placement:f,scrollOffset:d,style:t,thumbChar:s,viewportHeight:c})]})};export{S as ScrollBarBox};
@@ -1 +1 @@
1
- import{jsx as Y}from"react/jsx-runtime";import{useRef as d,useState as K,useEffect as y,useCallback as g,useImperativeHandle as N}from"react";import Q from"../ink/hooks/use-scroll-input.js";import{C as U}from"./controlled-scroll-view-BQ0JOudw.js";const et=O=>{const{children:P,keyboard:A=!1,onContentHeightChange:V,onItemHeightChange:B,onScroll:T,onViewportSizeChange:b,overscan:E,ref:L,scrollAlignment:h="auto",selectedIndex:p,vimBindings:R=!1,virtualize:j,...q}=O,n=d(null),[s,D]=K(0),C=d(0);y(()=>{C.current=s},[s]);const o=g(t=>{t!==C.current&&(D(t),T?.(t))},[T]),a=d(p);a.current=p;const S=g(()=>{const t=a.current;if(t===void 0||t<0)return null;const e=n.current?.getItemPosition(t);if(!e)return null;const i=n.current?.getViewportHeight()??0,l=n.current?.getContentHeight()??0;let r=e.top+e.height-i,c=e.top;r>c&&([r,c]=[c,r]);const M=Math.max(0,l-i);return{max:Math.min(M,c),min:Math.max(0,r)}},[]),u=g(t=>{const e=n.current?.getContentHeight()??0,i=n.current?.getViewportHeight()??0,l=Math.max(0,e-i);let r=Math.max(0,Math.min(t,l));const c=S();return c&&(r=Math.max(c.min,Math.min(r,c.max))),r},[S]),m=g((t,e,i,l)=>{const r=n.current?.getItemPosition(t);if(!r)return e;const c=l??n.current?.getViewportHeight()??0,M=n.current?.getContentHeight()??0;let f=e;switch(i){case"bottom":{f=r.top+r.height-c;break}case"center":{f=r.top+r.height/2-c/2;break}case"top":{f=r.top;break}default:{const w=r.top+r.height;r.top<=e&&w>=e+c?f=e:r.top<e?f=r.top:w>e+c&&(f=w-c)}}const X=Math.max(0,M-c);return Math.max(0,Math.min(f,X))},[]);let H=s;p!==void 0&&p>=0&&(H=m(p,s,h)),y(()=>{H!==s&&o(H)},[H,s,o]);const k=g((t,e)=>{if(a.current!==void 0&&a.current>=0){const i=m(a.current,s,h,t.height);o(i)}b?.(t,e)},[b,m,s,h,o]),F=g((t,e,i)=>{const l=a.current;if(l!==void 0&&l>=0){if(t<l){const r=u(s+(e-i));o(r)}else if(t===l){const r=m(t,s,h);o(r)}}B?.(t,e,i)},[B,m,h,s,u,o]),G=g((t,e)=>{if(a.current!==void 0&&a.current>=0){const i=m(a.current,s,h);o(i)}V?.(t,e)},[V,m,s,h,o]),z=d(0),x=g(t=>{const e=C.current,i=u(e+t);o(i)},[u,o]),v=g(()=>{const t=n.current?.getContentHeight()??0,e=n.current?.getViewportHeight()??0,i=Math.max(0,t-e),l=u(i);o(l)},[u,o]),I=g(()=>{const t=u(0);o(t)},[u,o]),J=g(()=>z.current,[]);Q({getViewportHeight:J,isActive:A,scrollBy:x,scrollToBottom:v,scrollToTop:I,vimBindings:R}),N(L,()=>({getBottomOffset:()=>n.current?.getBottomOffset()??0,getContentHeight:()=>n.current?.getContentHeight()??0,getItemHeight:t=>n.current?.getItemHeight(t)??0,getItemPosition:t=>n.current?.getItemPosition(t)??null,getScrollOffset:()=>C.current,getViewportHeight:()=>n.current?.getViewportHeight()??0,remeasure:()=>n.current?.remeasure(),remeasureItem:t=>n.current?.remeasureItem(t),scrollBy:x,scrollTo:t=>{const e=u(t);o(e)},scrollToBottom:v,scrollToTop:I}),[u,o,x,v,I]);const W=g((t,e)=>{z.current=t.height,k(t,e)},[k]);return Y(U,{onContentHeightChange:G,onItemHeightChange:F,onViewportSizeChange:W,overscan:E,ref:n,scrollOffset:H,virtualize:j,...q,children:P})};export{et as ScrollList};
1
+ import{jsx as Y}from"react/jsx-runtime";import{useRef as d,useState as K,useEffect as y,useCallback as g,useImperativeHandle as N}from"react";import Q from"../ink/hooks/use-scroll-input.js";import{C as U}from"./controlled-scroll-view-BVg7ywNW.js";const et=O=>{const{children:P,keyboard:A=!1,onContentHeightChange:V,onItemHeightChange:B,onScroll:T,onViewportSizeChange:b,overscan:E,ref:L,scrollAlignment:h="auto",selectedIndex:p,vimBindings:R=!1,virtualize:j,...q}=O,n=d(null),[s,D]=K(0),C=d(0);y(()=>{C.current=s},[s]);const o=g(t=>{t!==C.current&&(D(t),T?.(t))},[T]),a=d(p);a.current=p;const S=g(()=>{const t=a.current;if(t===void 0||t<0)return null;const e=n.current?.getItemPosition(t);if(!e)return null;const i=n.current?.getViewportHeight()??0,l=n.current?.getContentHeight()??0;let r=e.top+e.height-i,c=e.top;r>c&&([r,c]=[c,r]);const M=Math.max(0,l-i);return{max:Math.min(M,c),min:Math.max(0,r)}},[]),u=g(t=>{const e=n.current?.getContentHeight()??0,i=n.current?.getViewportHeight()??0,l=Math.max(0,e-i);let r=Math.max(0,Math.min(t,l));const c=S();return c&&(r=Math.max(c.min,Math.min(r,c.max))),r},[S]),m=g((t,e,i,l)=>{const r=n.current?.getItemPosition(t);if(!r)return e;const c=l??n.current?.getViewportHeight()??0,M=n.current?.getContentHeight()??0;let f=e;switch(i){case"bottom":{f=r.top+r.height-c;break}case"center":{f=r.top+r.height/2-c/2;break}case"top":{f=r.top;break}default:{const w=r.top+r.height;r.top<=e&&w>=e+c?f=e:r.top<e?f=r.top:w>e+c&&(f=w-c)}}const X=Math.max(0,M-c);return Math.max(0,Math.min(f,X))},[]);let H=s;p!==void 0&&p>=0&&(H=m(p,s,h)),y(()=>{H!==s&&o(H)},[H,s,o]);const k=g((t,e)=>{if(a.current!==void 0&&a.current>=0){const i=m(a.current,s,h,t.height);o(i)}b?.(t,e)},[b,m,s,h,o]),F=g((t,e,i)=>{const l=a.current;if(l!==void 0&&l>=0){if(t<l){const r=u(s+(e-i));o(r)}else if(t===l){const r=m(t,s,h);o(r)}}B?.(t,e,i)},[B,m,h,s,u,o]),G=g((t,e)=>{if(a.current!==void 0&&a.current>=0){const i=m(a.current,s,h);o(i)}V?.(t,e)},[V,m,s,h,o]),z=d(0),x=g(t=>{const e=C.current,i=u(e+t);o(i)},[u,o]),v=g(()=>{const t=n.current?.getContentHeight()??0,e=n.current?.getViewportHeight()??0,i=Math.max(0,t-e),l=u(i);o(l)},[u,o]),I=g(()=>{const t=u(0);o(t)},[u,o]),J=g(()=>z.current,[]);Q({getViewportHeight:J,isActive:A,scrollBy:x,scrollToBottom:v,scrollToTop:I,vimBindings:R}),N(L,()=>({getBottomOffset:()=>n.current?.getBottomOffset()??0,getContentHeight:()=>n.current?.getContentHeight()??0,getItemHeight:t=>n.current?.getItemHeight(t)??0,getItemPosition:t=>n.current?.getItemPosition(t)??null,getScrollOffset:()=>C.current,getViewportHeight:()=>n.current?.getViewportHeight()??0,remeasure:()=>n.current?.remeasure(),remeasureItem:t=>n.current?.remeasureItem(t),scrollBy:x,scrollTo:t=>{const e=u(t);o(e)},scrollToBottom:v,scrollToTop:I}),[u,o,x,v,I]);const W=g((t,e)=>{z.current=t.height,k(t,e)},[k]);return Y(U,{onContentHeightChange:G,onItemHeightChange:F,onViewportSizeChange:W,overscan:E,ref:n,scrollOffset:H,virtualize:j,...q,children:P})};export{et as ScrollList};
@@ -1 +1 @@
1
- import{jsxs as X,jsx as v}from"react/jsx-runtime";import{useRef as h,useState as E,useCallback as o,useImperativeHandle as _}from"react";import $ from"../ink/hooks/use-scroll-input.js";import{Box as ee}from"../components/box.js";import{f as re,C as F}from"./controlled-scroll-view-BQ0JOudw.js";import{ScrollBar as te}from"./ScrollBar-BKCK8jsb.js";const se=({children:I,debug:B=!1,followOutput:M=!1,followThreshold:T=3,keyboard:W=!1,onContentHeightChange:z,onItemHeightChange:y,onReachEnd:g,onReachStart:p,onScroll:V,onViewportSizeChange:N,overscan:O,reachThreshold:a=5,ref:Y,scrollbar:Z=!1,scrollbarColor:q,scrollbarStyle:J="line",vimBindings:K=!1,virtualize:G,...m})=>{const[d,k,n]=re(0),c=h(null),s=h(0),l=h(0),[D,L]=E(0),[x,Q]=E(0),C=h(!1),w=h(!1),i=o(()=>Math.max(0,s.current-l.current),[]),P=o(e=>{const t=i();g&&e>=t-a&&!C.current?(C.current=!0,g()):e<t-a&&(C.current=!1),p&&e<=a&&!w.current?(w.current=!0,p()):e>a&&(w.current=!1)},[g,p,a,i]),r=o(e=>{e!==n()&&(k(e),V?.(e),P(e))},[n,k,V,P]),j=o((e,t)=>{const u=n()>=i()-T;if(s.current=e,L(e),z?.(e,t),M&&u&&e>t){const f=Math.max(0,e-l.current);r(f)}else{const f=Math.max(0,e-l.current);n()>f&&r(f)}},[z,M,T,n,i,r]),A=o((e,t)=>{l.current=e.height,Q(e.height),N?.(e,t)},[N]),H=o(e=>{if(typeof e!="number"||Number.isNaN(e))return;const t=Math.max(0,s.current-l.current),u=Math.max(0,Math.min(n()+e,t));r(u)},[n,r]),R=o(e=>{if(typeof e!="number"||Number.isNaN(e))return;const t=Math.max(0,s.current-l.current),u=Math.max(0,Math.min(e,t));r(u)},[r]),b=o(()=>{const e=i();r(e)},[i,r]),S=o(()=>{r(0)},[r]),U=o(()=>l.current,[]);return $({getViewportHeight:U,isActive:W,scrollBy:H,scrollToBottom:b,scrollToTop:S,vimBindings:K}),_(Y,()=>({getBottomOffset:i,getContentHeight:()=>s.current,getItemHeight:e=>c.current?.getItemHeight(e)??0,getItemPosition:e=>c.current?.getItemPosition(e)??null,getScrollOffset:n,getViewportHeight:()=>l.current,remeasure:()=>c.current?.remeasure(),remeasureItem:e=>c.current?.remeasureItem(e),scrollBy:H,scrollTo:R,scrollToBottom:b,scrollToTop:S}),[i,n,H,R,b,S]),Z&&D>x&&x>0?X(ee,{flexDirection:"row",flexGrow:m.flexGrow,flexShrink:m.flexShrink,overflow:"hidden",children:[v(F,{children:I,debug:B,onContentHeightChange:j,onItemHeightChange:y,onViewportSizeChange:A,overscan:O,ref:c,scrollOffset:d,virtualize:G,...m,flexGrow:1}),v(te,{color:q,contentHeight:D,placement:"inset",scrollOffset:d,style:J,viewportHeight:x})]}):v(F,{children:I,debug:B,onContentHeightChange:j,onItemHeightChange:y,onViewportSizeChange:A,overscan:O,ref:c,scrollOffset:d,virtualize:G,...m})};export{se as ScrollView};
1
+ import{jsxs as X,jsx as v}from"react/jsx-runtime";import{useRef as h,useState as q,useCallback as o,useImperativeHandle as _}from"react";import $ from"../ink/hooks/use-scroll-input.js";import{Box as ee}from"../components/box.js";import{f as re,C as E}from"./controlled-scroll-view-BVg7ywNW.js";import{ScrollBar as te}from"./ScrollBar-qa1IzDDv.js";const se=({children:I,debug:B=!1,followOutput:M=!1,followThreshold:T=3,keyboard:F=!1,onContentHeightChange:z,onItemHeightChange:y,onReachEnd:g,onReachStart:p,onScroll:V,onViewportSizeChange:N,overscan:O,reachThreshold:a=5,ref:W,scrollbar:Y=!1,scrollbarColor:Z,scrollbarStyle:J="line",vimBindings:K=!1,virtualize:G,...m})=>{const[d,k,n]=re(0),c=h(null),s=h(0),l=h(0),[P,L]=q(0),[x,Q]=q(0),C=h(!1),w=h(!1),i=o(()=>Math.max(0,s.current-l.current),[]),j=o(e=>{const t=i();g&&e>=t-a&&!C.current?(C.current=!0,g()):e<t-a&&(C.current=!1),p&&e<=a&&!w.current?(w.current=!0,p()):e>a&&(w.current=!1)},[g,p,a,i]),r=o(e=>{e!==n()&&(k(e),V?.(e),j(e))},[n,k,V,j]),A=o((e,t)=>{const u=n()>=i()-T;if(s.current=e,L(e),z?.(e,t),M&&u&&e>t){const f=Math.max(0,e-l.current);r(f)}else{const f=Math.max(0,e-l.current);n()>f&&r(f)}},[z,M,T,n,i,r]),D=o((e,t)=>{l.current=e.height,Q(e.height),N?.(e,t)},[N]),H=o(e=>{if(typeof e!="number"||Number.isNaN(e))return;const t=Math.max(0,s.current-l.current),u=Math.max(0,Math.min(n()+e,t));r(u)},[n,r]),R=o(e=>{if(typeof e!="number"||Number.isNaN(e))return;const t=Math.max(0,s.current-l.current),u=Math.max(0,Math.min(e,t));r(u)},[r]),b=o(()=>{const e=i();r(e)},[i,r]),S=o(()=>{r(0)},[r]),U=o(()=>l.current,[]);return $({getViewportHeight:U,isActive:F,scrollBy:H,scrollToBottom:b,scrollToTop:S,vimBindings:K}),_(W,()=>({getBottomOffset:i,getContentHeight:()=>s.current,getItemHeight:e=>c.current?.getItemHeight(e)??0,getItemPosition:e=>c.current?.getItemPosition(e)??null,getScrollOffset:n,getViewportHeight:()=>l.current,remeasure:()=>c.current?.remeasure(),remeasureItem:e=>c.current?.remeasureItem(e),scrollBy:H,scrollTo:R,scrollToBottom:b,scrollToTop:S}),[i,n,H,R,b,S]),Y&&P>x&&x>0?X(ee,{flexDirection:"row",flexGrow:m.flexGrow,flexShrink:m.flexShrink,overflow:"hidden",children:[v(E,{children:I,debug:B,onContentHeightChange:A,onItemHeightChange:y,onViewportSizeChange:D,overscan:O,ref:c,scrollOffset:d,virtualize:G,...m,flexGrow:1}),v(te,{color:Z,contentHeight:P,placement:"inset",scrollOffset:d,style:J,viewportHeight:x})]}):v(E,{children:I,debug:B,onContentHeightChange:A,onItemHeightChange:y,onViewportSizeChange:D,overscan:O,ref:c,scrollOffset:d,virtualize:G,...m})};export{se as ScrollView};
@@ -1 +1 @@
1
- import"yoga-layout";import{c as r,a as g,b as i,R as s,g as c,d as n,e as d,f as u,h as b,i as m,j as B,k as S,l as h}from"./measure-element-Cs7_proT.js";import"./calculateScroll-D4Y_JR4H.js";import"./squashTextNodesWithMap-BmUSBPfc.js";export{r as calculateScrollbarLayout,g as calculateScrollbarThumb,i as collectSortedFragments,s as default,c as getAddedScrollHeight,n as getBoundingBox,d as getHorizontalScrollbarBoundingBox,u as getInnerHeight,b as getInnerWidth,m as getRelativeLeft,B as getRelativeTop,S as getText,h as getVerticalScrollbarBoundingBox};
1
+ import"yoga-layout";import{c as r,a as g,b as i,R as s,g as c,d as n,e as d,f as u,h as b,i as m,j as B,k as S,l as h}from"./measure-element-D4M9iSYp.js";import"./calculateScroll-D4Y_JR4H.js";import"./squashTextNodesWithMap-BmUSBPfc.js";export{r as calculateScrollbarLayout,g as calculateScrollbarThumb,i as collectSortedFragments,s as default,c as getAddedScrollHeight,n as getBoundingBox,d as getHorizontalScrollbarBoundingBox,u as getInnerHeight,b as getInnerWidth,m as getRelativeLeft,B as getRelativeTop,S as getText,h as getVerticalScrollbarBoundingBox};
@@ -1 +1 @@
1
- import{jsx as H,jsxs as rr}from"react/jsx-runtime";import{useState as K,useRef as d,useCallback as j,useLayoutEffect as T,isValidElement as z,useImperativeHandle as tr,Fragment as G}from"react";import{R as N}from"./measure-element-Cs7_proT.js";import{Box as M}from"../components/box.js";const J=u=>{const[g,m]=K(u),l=d(u),k=j(C=>{const E=typeof C=="function"?C(l.current):C;l.current=E,m(E)},[]),x=j(()=>l.current,[]);return[g,k,x]},er=({children:u,index:g,measureKey:m,onMeasure:l,width:k})=>{const x=d(null);return T(()=>{if(x.current){const{height:C}=N(x.current);l(g,C)}},[g,l,k,m,u]),H(M,{flexDirection:"column",flexShrink:0,ref:x,width:"100%",children:u})},B=u=>{if(u==null)return[];if(Array.isArray(u)){const g=[];for(let m=0;m<u.length;m+=1){const l=u[m];z(l)&&l.type===G?g.push(...B(l.props.children)):g.push(l)}return g}return z(u)&&u.type===G?B(u.props.children):[u]},hr=({children:u,debug:g=!1,onContentHeightChange:m,onItemHeightChange:l,onViewportSizeChange:k,overscan:x=3,ref:C,scrollOffset:E,virtualize:Q=!1,...U})=>{const D=d(!1),[$,q,S]=J({height:0,width:0}),[I,O,R]=J(0),[W,X]=K({}),V=d(null),b=d(0);T(()=>{I!==b.current&&(m?.(I,b.current),b.current=I)},[I,m]);const o=d({}),i=d([]),p=d([]),f=d(0),Y=j((r,t)=>{const e=i.current[r]??r;if(o.current[e]!==t){const h=o.current[e]??0;o.current={...o.current,[e]:t};let n=0;for(let s=0;s<i.current.length;s+=1){const y=i.current[s];y!=null&&(n+=o.current[y]??0)}const c=R();n!==c&&O(n),l?.(r,t,h),f.current=Math.min(f.current,r+1)}},[l,R,O]),F=j(()=>{if(V.current){const{height:r,width:t}=N(V.current),e=S();(t!==e.width||r!==e.height)&&(k?.({height:r,width:t},e),q({height:r,width:t}))}},[V,k,S,q]);T(()=>{F()});const Z=d(null);if(Z.current!==u){Z.current=u;const r=[],t={};B(u).forEach((n,c)=>{if(!n)return;const s=(z(n)?n.key:null)??c;r[c]=s;const y=o.current[s]??0;t[s]=y}),o.current=t,i.current=r,p.current=Array.from({length:r.length}).fill(0),f.current=0;let e=0;r.forEach(n=>{e+=t[n]??0});const h=R();e!==h&&O(e)}tr(C,()=>({getBottomOffset:()=>Math.max(0,R()-S().height),getContentHeight:R,getItemHeight:r=>{const t=i.current[r]??r;return o.current[t]??0},getItemPosition:r=>{if(r<0||r>=i.current.length)return null;if(r>=f.current){let h=0,n=0;if(f.current>0){n=f.current;const c=n-1,s=i.current[c]??c,y=o.current[s]??0;h=(p.current[c]??0)+y}for(let c=n;c<=r;c+=1){p.current[c]=h;const s=i.current[c]??c,y=o.current[s]??0;h+=y}f.current=r+1}const t=p.current[r]??0,e=i.current[r]??r;return{height:o.current[e]??0,top:t}},getViewportHeight:()=>S().height,remeasure:F,remeasureItem:r=>{X(t=>({...t,[r]:(t[r]??0)+1}))}}),[F,R,S,X]);const v=B(u);!D.current&&I>0&&(D.current=!0);let w=0,a=v.length-1,L=0,P=0;const _=v.length>0&&v.every((r,t)=>{const e=i.current[t]??t;return(o.current[e]??0)>0}),A=Q&&D.current&&_;if(A){const r=i.current.length;if(f.current<r){let e=0,h=0;if(f.current>0){h=f.current;const n=h-1,c=i.current[n]??n,s=o.current[c]??0;e=(p.current[n]??0)+s}for(let n=h;n<r;n+=1){p.current[n]=e;const c=i.current[n]??n;e+=o.current[c]??0}f.current=r}const t=E+$.height;w=v.length,a=-1;for(let e=0;e<r;e+=1){const h=p.current[e]??0,n=i.current[e]??e,c=o.current[n]??0;h+c>E&&h<t&&(e<w&&(w=e),a=e)}if(w>a&&(w=0,a=-1),w=Math.max(0,w-x),a=Math.min(v.length-1,Math.max(-1,a)+x),L=p.current[w]??0,a<v.length-1){const e=i.current[a]??a,h=(p.current[a]??0)+(o.current[e]??0);P=I-h}}return H(M,{...U,children:H(M,{ref:V,width:"100%",children:H(M,{overflow:g?void 0:"hidden",width:"100%",children:rr(M,{flexDirection:"column",marginTop:-E,width:"100%",children:[A&&L>0&&H(M,{height:L}),v.map((r,t)=>!r||A&&(t<w||t>a)?null:H(er,{index:t,measureKey:W[t],onMeasure:Y,width:$.width,children:r},z(r)?r.key??t:t)),A&&P>0&&H(M,{height:P})]})})})})};export{hr as C,J as f};
1
+ import{jsx as H,jsxs as rr}from"react/jsx-runtime";import{useState as K,useRef as d,useCallback as j,useLayoutEffect as T,isValidElement as z,useImperativeHandle as tr,Fragment as G}from"react";import{R as N}from"./measure-element-D4M9iSYp.js";import{Box as M}from"../components/box.js";const J=u=>{const[g,m]=K(u),l=d(u),k=j(C=>{const E=typeof C=="function"?C(l.current):C;l.current=E,m(E)},[]),x=j(()=>l.current,[]);return[g,k,x]},er=({children:u,index:g,measureKey:m,onMeasure:l,width:k})=>{const x=d(null);return T(()=>{if(x.current){const{height:C}=N(x.current);l(g,C)}},[g,l,k,m,u]),H(M,{flexDirection:"column",flexShrink:0,ref:x,width:"100%",children:u})},B=u=>{if(u==null)return[];if(Array.isArray(u)){const g=[];for(let m=0;m<u.length;m+=1){const l=u[m];z(l)&&l.type===G?g.push(...B(l.props.children)):g.push(l)}return g}return z(u)&&u.type===G?B(u.props.children):[u]},hr=({children:u,debug:g=!1,onContentHeightChange:m,onItemHeightChange:l,onViewportSizeChange:k,overscan:x=3,ref:C,scrollOffset:E,virtualize:Q=!1,...U})=>{const D=d(!1),[$,q,S]=J({height:0,width:0}),[I,O,R]=J(0),[W,X]=K({}),V=d(null),b=d(0);T(()=>{I!==b.current&&(m?.(I,b.current),b.current=I)},[I,m]);const o=d({}),i=d([]),p=d([]),f=d(0),Y=j((r,t)=>{const e=i.current[r]??r;if(o.current[e]!==t){const h=o.current[e]??0;o.current={...o.current,[e]:t};let n=0;for(let s=0;s<i.current.length;s+=1){const y=i.current[s];y!=null&&(n+=o.current[y]??0)}const c=R();n!==c&&O(n),l?.(r,t,h),f.current=Math.min(f.current,r+1)}},[l,R,O]),F=j(()=>{if(V.current){const{height:r,width:t}=N(V.current),e=S();(t!==e.width||r!==e.height)&&(k?.({height:r,width:t},e),q({height:r,width:t}))}},[V,k,S,q]);T(()=>{F()});const Z=d(null);if(Z.current!==u){Z.current=u;const r=[],t={};B(u).forEach((n,c)=>{if(!n)return;const s=(z(n)?n.key:null)??c;r[c]=s;const y=o.current[s]??0;t[s]=y}),o.current=t,i.current=r,p.current=Array.from({length:r.length}).fill(0),f.current=0;let e=0;r.forEach(n=>{e+=t[n]??0});const h=R();e!==h&&O(e)}tr(C,()=>({getBottomOffset:()=>Math.max(0,R()-S().height),getContentHeight:R,getItemHeight:r=>{const t=i.current[r]??r;return o.current[t]??0},getItemPosition:r=>{if(r<0||r>=i.current.length)return null;if(r>=f.current){let h=0,n=0;if(f.current>0){n=f.current;const c=n-1,s=i.current[c]??c,y=o.current[s]??0;h=(p.current[c]??0)+y}for(let c=n;c<=r;c+=1){p.current[c]=h;const s=i.current[c]??c,y=o.current[s]??0;h+=y}f.current=r+1}const t=p.current[r]??0,e=i.current[r]??r;return{height:o.current[e]??0,top:t}},getViewportHeight:()=>S().height,remeasure:F,remeasureItem:r=>{X(t=>({...t,[r]:(t[r]??0)+1}))}}),[F,R,S,X]);const v=B(u);!D.current&&I>0&&(D.current=!0);let w=0,a=v.length-1,L=0,P=0;const _=v.length>0&&v.every((r,t)=>{const e=i.current[t]??t;return(o.current[e]??0)>0}),A=Q&&D.current&&_;if(A){const r=i.current.length;if(f.current<r){let e=0,h=0;if(f.current>0){h=f.current;const n=h-1,c=i.current[n]??n,s=o.current[c]??0;e=(p.current[n]??0)+s}for(let n=h;n<r;n+=1){p.current[n]=e;const c=i.current[n]??n;e+=o.current[c]??0}f.current=r}const t=E+$.height;w=v.length,a=-1;for(let e=0;e<r;e+=1){const h=p.current[e]??0,n=i.current[e]??e,c=o.current[n]??0;h+c>E&&h<t&&(e<w&&(w=e),a=e)}if(w>a&&(w=0,a=-1),w=Math.max(0,w-x),a=Math.min(v.length-1,Math.max(-1,a)+x),L=p.current[w]??0,a<v.length-1){const e=i.current[a]??a,h=(p.current[a]??0)+(o.current[e]??0);P=I-h}}return H(M,{...U,children:H(M,{ref:V,width:"100%",children:H(M,{overflow:g?void 0:"hidden",width:"100%",children:rr(M,{flexDirection:"column",marginTop:-E,width:"100%",children:[A&&L>0&&H(M,{height:L}),v.map((r,t)=>!r||A&&(t<w||t>a)?null:H(er,{index:t,measureKey:W[t],onMeasure:Y,width:$.width,children:r},z(r)?r.key??t:t)),A&&P>0&&H(M,{height:P})]})})})})};export{hr as C,J as f};
@@ -0,0 +1 @@
1
+ import d from"yoga-layout";import{getScrollTop as P,getScrollLeft as R}from"./calculateScroll-D4Y_JR4H.js";import F from"./squashTextNodesWithMap-BmUSBPfc.js";const G=t=>{let e=t,o=0,n=0;for(;e?.parentNode;){if(!e.yogaNode)return;o+=e.yogaNode.getComputedLeft(),n+=e.yogaNode.getComputedTop(),e=e.parentNode}return{x:o,y:n}},W=t=>G(t),V=t=>{const e=G(t);if(!(!e||!t.yogaNode))return{x:e.x+t.yogaNode.getComputedBorder(d.EDGE_LEFT)+t.yogaNode.getComputedPadding(d.EDGE_LEFT),y:e.y+t.yogaNode.getComputedBorder(d.EDGE_TOP)+t.yogaNode.getComputedPadding(d.EDGE_TOP)}},z=t=>{const e=W(t);return{height:Math.round(t.yogaNode?.getComputedHeight()??0),width:Math.round(t.yogaNode?.getComputedWidth()??0),x:Math.round(e?.x??0),y:Math.round(e?.y??0)}},A=t=>{const{yogaNode:e}=t;if(!e)return 0;const o=e.getComputedWidth()??0,n=e.getComputedBorder(d.EDGE_LEFT),i=e.getComputedBorder(d.EDGE_RIGHT);return Math.round(o-n-i)},U=t=>{const{yogaNode:e}=t;if(!e)return 0;const o=e.getComputedHeight()??0,n=e.getComputedBorder(d.EDGE_TOP),i=e.getComputedBorder(d.EDGE_BOTTOM);return Math.round(o-n-i)},S=t=>{const{yogaNode:e}=t;if(!e)return{height:0,width:0,x:0,y:0};const o=e.getComputedWidth()??0,n=e.getComputedHeight()??0;let i=e.getComputedLeft(),r=e.getComputedTop(),a=t.parentNode;for(;a?.yogaNode;){if(i+=a.yogaNode.getComputedLeft(),r+=a.yogaNode.getComputedTop(),a.nodeName==="ink-box"){const l=a.style.overflow??"visible",s=a.style.overflowX??l;(a.style.overflowY??l)==="scroll"&&(r-=P(a)),s==="scroll"&&(i-=R(a))}a=a.parentNode}return{height:Math.round(n),width:Math.round(o),x:Math.round(i),y:Math.round(r)}},j=t=>{const e=t.internal_scrollState?.scrollHeight??0,o=t.internal_scrollState?.actualScrollHeight??0;return Math.max(0,e-o)},H=t=>{const{axis:e,clientDimension:o,scrollbarDimension:n,scrollDimension:i,scrollPosition:r}=t,a=n*2,l=Math.max(e==="vertical"?2:1,Math.round(o/i*a)),s=i-o,h=a-l,g=s>0?Math.round(r/s*h):0,u=g,m=g+l,c=Math.floor(u/2);return{endIndex:Math.min(n,Math.ceil(m/2)),startIndex:c,thumbEndHalf:m,thumbStartHalf:u}},b=t=>{const{axis:e,clientDimension:o,hasOppositeScrollbar:n,height:i,marginBottom:r,marginRight:a,scrollDimension:l,scrollPosition:s,width:h,x:g,y:u}=t;if(l<=o)return;if(e==="vertical"){const{endIndex:N,startIndex:x,thumbEndHalf:T,thumbStartHalf:_}=H({axis:e,clientDimension:o,scrollbarDimension:i,scrollDimension:l,scrollPosition:s}),E=g+h-1-a;return{height:i,thumb:{end:N,endHalf:T,height:N-x,start:x,startHalf:_,width:1,x:E,y:u+x},width:1,x:E,y:u}}const m=h-(n?1:0),{endIndex:c,startIndex:p,thumbEndHalf:C,thumbStartHalf:y}=H({axis:e,clientDimension:o,scrollbarDimension:m,scrollDimension:l,scrollPosition:s}),D=u+i-1-r;return{height:1,thumb:{end:c,endHalf:C,height:1,start:p,startHalf:y,width:c-p,x:g+p,y:D},width:m,x:g,y:D}},q=(t,e)=>{const{yogaNode:o}=t;if(!o)return;const n=t.style.overflow??"visible";if((t.style.overflowY??n)!=="scroll")return;const i=t.internal_scrollState?.clientHeight??0,r=t.internal_scrollState?.scrollHeight??0;if(r<=i)return;const{x:a,y:l}=e??S(t),s=o.getComputedHeight()-o.getComputedBorder(d.EDGE_TOP)-o.getComputedBorder(d.EDGE_BOTTOM);return b({axis:"vertical",clientDimension:i,hasOppositeScrollbar:!1,height:s,marginBottom:o.getComputedBorder(d.EDGE_BOTTOM),marginRight:o.getComputedBorder(d.EDGE_RIGHT),scrollDimension:r,scrollPosition:t.internal_scrollState?.scrollTop??0,width:o.getComputedWidth()-o.getComputedBorder(d.EDGE_LEFT),x:a+o.getComputedBorder(d.EDGE_LEFT),y:l+o.getComputedBorder(d.EDGE_TOP)})},J=(t,e)=>{const{yogaNode:o}=t;if(!o)return;const n=t.style.overflow??"visible";if((t.style.overflowX??n)!=="scroll")return;const i=t.internal_scrollState?.clientWidth??0,r=t.internal_scrollState?.scrollWidth??0;if(r<=i)return;const{x:a,y:l}=e??S(t),s=t.style.overflowY??n,h=t.internal_scrollState?.clientHeight??0,g=t.internal_scrollState?.scrollHeight??0,u=s==="scroll"&&g>h;return b({axis:"horizontal",clientDimension:i,hasOppositeScrollbar:u,height:o.getComputedHeight()-o.getComputedBorder(d.EDGE_TOP),marginBottom:o.getComputedBorder(d.EDGE_BOTTOM),marginRight:o.getComputedBorder(d.EDGE_RIGHT),scrollDimension:r,scrollPosition:t.internal_scrollState?.scrollLeft??0,width:o.getComputedWidth()-o.getComputedBorder(d.EDGE_LEFT)-o.getComputedBorder(d.EDGE_RIGHT),x:a+o.getComputedBorder(d.EDGE_LEFT),y:l+o.getComputedBorder(d.EDGE_TOP)})},K=(t,e)=>{if(!t.yogaNode||t===e)return 0;let o=t.yogaNode.getComputedTop(),n=t.parentNode;for(;n&&n!==e;)n.yogaNode&&(o+=n.yogaNode.getComputedTop()),n=n.parentNode;if(!(e!==void 0&&n!==e))return Math.round(o)},Q=(t,e)=>{if(!t.yogaNode||t===e)return 0;let o=t.yogaNode.getComputedLeft(),n=t.parentNode;for(;n&&n!==e;)n.yogaNode&&(o+=n.yogaNode.getComputedLeft()),n=n.parentNode;if(!(e!==void 0&&n!==e))return Math.round(o)},k=t=>t.nodeName==="#text"?t.nodeValue:t.nodeName==="ink-text"||t.nodeName==="ink-virtual-text"?F(t):"",Z=t=>{const e=[],o=(r,a,l)=>{const{visualX:s,visualY:h,x:g,y:u}=a;let m=0,c=0,p=l;const{userSelect:C}=r.style;if(C==="none"?p=!1:(C==="text"||C==="all")&&(p=!0),r.nodeName==="ink-text"||r.nodeName==="ink-virtual-text"){if(p){const y=k(r);return e.push({height:Math.round(r.yogaNode?.getComputedHeight()??0),node:r,text:y,visualX:Math.round(s),visualY:Math.round(h),width:Math.round(r.yogaNode?.getComputedWidth()??0),x:Math.round(g),y:Math.round(u)}),{h:0,hasContent:!0,v:0}}return{h:r.yogaNode?.getComputedWidth()??0,hasContent:!1,v:r.yogaNode?.getComputedHeight()??0}}if(r.nodeName==="ink-box"||r.nodeName==="ink-root"){if(!r.yogaNode||r.yogaNode.getDisplay()===d.DISPLAY_NONE)return{h:0,hasContent:!1,v:0};const y=r.yogaNode.getComputedBorder(d.EDGE_TOP),D=r.yogaNode.getComputedBorder(d.EDGE_BOTTOM),N=r.yogaNode.getComputedBorder(d.EDGE_LEFT),x=r.yogaNode.getComputedBorder(d.EDGE_RIGHT);m+=y+D,c+=N+x;const T=r.yogaNode.getFlexDirection(),_=T===d.FLEX_DIRECTION_COLUMN||T===d.FLEX_DIRECTION_COLUMN_REVERSE;let E=0,v=0,M=!1;for(const f of r.childNodes)if(f.yogaNode){const O=g+f.yogaNode.getComputedLeft()-N-E,L=u+f.yogaNode.getComputedTop()-y-v,w=s+f.yogaNode.getComputedLeft(),I=h+f.yogaNode.getComputedTop(),B=o(f,{visualX:w,visualY:I,x:O,y:L},p);B.hasContent&&(M=!0),_?v+=B.v:E+=B.h}return _?m+=v:c+=E,{h:c,hasContent:M,v:m}}return{h:0,hasContent:!1,v:0}},{h:n,v:i}=o(t,{visualX:0,visualY:0,x:0,y:0},!0);return e.sort((r,a)=>r.y!==a.y?r.y-a.y:r.x-a.x),{fragments:e,removedHorizontal:Math.round(n),removedVertical:Math.round(i)}};export{z as R,H as a,Z as b,b as c,S as d,J as e,U as f,j as g,A as h,Q as i,K as j,k,q as l,V as u};
@@ -0,0 +1,2 @@
1
+ import{b as x}from"./measure-element-D4M9iSYp.js";const u=(o,l)=>{const{initialState:r,onNewline:a,onSpace:c,onText:m}=l;if(o.nodeName!=="ink-box"&&o.nodeName!=="ink-root"&&o.nodeName!=="ink-text"&&o.nodeName!=="ink-virtual-text"||!o.yogaNode)return{lineBottom:0,state:r()};const{fragments:s}=x(o),t=r();t.currentX=0,t.lineBottom=0,t.yieldedContent=!1;for(const e of s){if(e.y>=t.lineBottom){const n=e.y-t.lineBottom,i=t.yieldedContent?1+n:n;i>0&&(a(i,t),t.currentX=0),t.lineBottom=e.y}if(e.x>t.currentX){const n=e.x-t.currentX;c(n,t),t.currentX=e.x}if(e.text.length>0&&(t.yieldedContent=!0,m(e,t)),(e.text.match(/\n/g)??[]).length>0){const n=e.text.lastIndexOf(`
2
+ `);t.currentX=e.text.length-n-1}else t.currentX+=e.text.length;t.lineBottom=Math.max(t.lineBottom,e.y+e.height)}return{lineBottom:t.lineBottom,state:t}};export{u as processLayout};
@@ -1,4 +1,4 @@
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,v as Ze,r as Je,H as Qe}from"./renderer-COXHo5Xk.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-aX8XOr2u.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().
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
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
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
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(`
@@ -1,4 +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-COXHo5Xk.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!==`
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
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
3
  `)?a.slice(0,-1):a;return t&&o?`${t}
4
4
  ${o}`:t||o}finally{if(!s&&e.yogaNode)try{e.yogaNode.freeRecursive()}catch{}}};export{L as default};
@@ -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};
@@ -1 +1 @@
1
- import{createRequire as _}from"node:module";import F from"../packem_shared/render-DSuj2PjD.js";import{createKeySender as x}from"../packem_shared/KEY-C--kOw41.js";import{KEY as K}from"../packem_shared/KEY-C--kOw41.js";import{createScreen as y}from"../packem_shared/createScreen-DoYpyL0V.js";import{waitFor as T}from"../packem_shared/waitFor-CTAki32d.js";const g=_(import.meta.url),a=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,w=t=>{if(typeof a<"u"&&a.versions&&a.versions.node){const[e,n]=a.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return a.getBuiltinModule(t)}return g(t)},m=w("node:events");class b extends m{columns;_lastFrame;_frames=[];constructor(e=100){super(),this.columns=e}get frames(){return this._frames}lastFrame(){return this._lastFrame}write=e=>(this._frames.push(e),this._lastFrame=e,!0)}class v extends m{columns;_lastFrame;_frames=[];constructor(e=100){super(),this.columns=e}get frames(){return this._frames}lastFrame(){return this._lastFrame}write=e=>(this._frames.push(e),this._lastFrame=e,!0)}class j extends m{isTTY=!0;pendingData;write=e=>(this.pendingData=e,this.emit("readable"),this.emit("data",e),!0);read(){const{pendingData:e}=this;return this.pendingData=void 0,e}setEncoding(){return this}setRawMode(){return this}resume(){return this}pause(){return this}ref(){return this}unref(){return this}}const u=[],P=(t,e={})=>{const{columns:n,options:d}=e,s=new b(n),c=new v(n),o=new j,i=F(t,{debug:!0,exitOnCtrlC:!1,patchConsole:!1,stderr:c,stdin:o,stdout:s,...d});u.push(i);const l=y(()=>s.lastFrame(),s.frames),p=x(r=>o.write(r)),f=async()=>{await new Promise(r=>{setTimeout(r,0)}),await new Promise(r=>{setTimeout(r,0)})};return{cleanup:i.cleanup,flush:f,get frames(){return s.frames},keys:p,lastFrame:()=>s.lastFrame(),rerender:i.rerender,screen:l,stderr:c,stdin:o,stdout:s,unmount:i.unmount,async waitFor(r,h){await T(r,()=>l.text(),h)}}},S=()=>{for(const t of u)t.cleanup();u.length=0};export{K as KEY,S as cleanup,x as createKeySender,y as createScreen,P as render,T as waitFor};
1
+ import{createRequire as _}from"node:module";import F from"../packem_shared/render-CuQecTAs.js";import{createKeySender as x}from"../packem_shared/KEY-C--kOw41.js";import{KEY as K}from"../packem_shared/KEY-C--kOw41.js";import{createScreen as y}from"../packem_shared/createScreen-DoYpyL0V.js";import{waitFor as T}from"../packem_shared/waitFor-CTAki32d.js";const g=_(import.meta.url),a=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,w=t=>{if(typeof a<"u"&&a.versions&&a.versions.node){const[e,n]=a.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return a.getBuiltinModule(t)}return g(t)},m=w("node:events");class b extends m{columns;_lastFrame;_frames=[];constructor(e=100){super(),this.columns=e}get frames(){return this._frames}lastFrame(){return this._lastFrame}write=e=>(this._frames.push(e),this._lastFrame=e,!0)}class v extends m{columns;_lastFrame;_frames=[];constructor(e=100){super(),this.columns=e}get frames(){return this._frames}lastFrame(){return this._lastFrame}write=e=>(this._frames.push(e),this._lastFrame=e,!0)}class j extends m{isTTY=!0;pendingData;write=e=>(this.pendingData=e,this.emit("readable"),this.emit("data",e),!0);read(){const{pendingData:e}=this;return this.pendingData=void 0,e}setEncoding(){return this}setRawMode(){return this}resume(){return this}pause(){return this}ref(){return this}unref(){return this}}const u=[],P=(t,e={})=>{const{columns:n,options:d}=e,s=new b(n),c=new v(n),o=new j,i=F(t,{debug:!0,exitOnCtrlC:!1,patchConsole:!1,stderr:c,stdin:o,stdout:s,...d});u.push(i);const l=y(()=>s.lastFrame(),s.frames),p=x(r=>o.write(r)),f=async()=>{await new Promise(r=>{setTimeout(r,0)}),await new Promise(r=>{setTimeout(r,0)})};return{cleanup:i.cleanup,flush:f,get frames(){return s.frames},keys:p,lastFrame:()=>s.lastFrame(),rerender:i.rerender,screen:l,stderr:c,stdin:o,stdout:s,unmount:i.unmount,async waitFor(r,h){await T(r,()=>l.text(),h)}}},S=()=>{for(const t of u)t.cleanup();u.length=0};export{K as KEY,S as cleanup,x as createKeySender,y as createScreen,P as render,T as waitFor};