@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.
- package/CHANGELOG.md +34 -0
- package/dist/components/controlled-scroll-view.js +1 -1
- package/dist/components/dialog.js +1 -1
- package/dist/components/scroll-bar-box.js +1 -1
- package/dist/components/scroll-bar.js +1 -1
- package/dist/components/scroll-list.js +1 -1
- package/dist/components/scroll-view.js +1 -1
- package/dist/ink/index.js +1 -1
- package/dist/packem_shared/ControlledScrollView-Cn4byU2n.js +1 -0
- package/dist/packem_shared/ResizeObserver-BI9bDy-j.js +1 -0
- package/dist/packem_shared/{ScrollBar-BKCK8jsb.js → ScrollBar-qa1IzDDv.js} +1 -1
- package/dist/packem_shared/ScrollBarBox-DchESZWv.js +1 -0
- package/dist/packem_shared/{ScrollList-Dc2LzJFv.js → ScrollList-BBAnRsrC.js} +1 -1
- package/dist/packem_shared/{ScrollView-yZyiky7k.js → ScrollView-CHAo7Epj.js} +1 -1
- package/dist/packem_shared/{calculateScrollbarLayout--eUVRLw7.js → calculateScrollbarLayout-Lf6i24c9.js} +1 -1
- package/dist/packem_shared/{controlled-scroll-view-BQ0JOudw.js → controlled-scroll-view-BVg7ywNW.js} +1 -1
- package/dist/packem_shared/measure-element-D4M9iSYp.js +1 -0
- package/dist/packem_shared/processLayout-I83k6vXE.js +2 -0
- package/dist/packem_shared/{render-DSuj2PjD.js → render-CuQecTAs.js} +1 -1
- package/dist/packem_shared/{renderToString-Do8K5Fyk.js → renderToString-DwXFY8Qh.js} +1 -1
- package/dist/packem_shared/renderer-k-xShm1P.js +17 -0
- package/dist/testing/index.js +1 -1
- package/index.js +550 -692
- package/package.json +13 -13
- package/dist/packem_shared/ControlledScrollView-btYXQFoC.js +0 -1
- package/dist/packem_shared/ResizeObserver-aX8XOr2u.js +0 -1
- package/dist/packem_shared/ScrollBarBox-CBhLo6eZ.js +0 -1
- package/dist/packem_shared/measure-element-Cs7_proT.js +0 -2
- package/dist/packem_shared/processLayout-tAee0ytT.js +0 -1
- package/dist/packem_shared/renderer-COXHo5Xk.js +0 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/tui",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.27",
|
|
4
4
|
"description": "React-based TUI library powered by a native Rust diff engine, drop-in Ink-compatible API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -593,11 +593,11 @@
|
|
|
593
593
|
"LICENSE.md"
|
|
594
594
|
],
|
|
595
595
|
"dependencies": {
|
|
596
|
-
"@visulima/ansi": "4.0.0-alpha.
|
|
597
|
-
"@visulima/colorize": "2.0.0-alpha.
|
|
598
|
-
"@visulima/error": "6.0.0-alpha.
|
|
596
|
+
"@visulima/ansi": "4.0.0-alpha.18",
|
|
597
|
+
"@visulima/colorize": "2.0.0-alpha.15",
|
|
598
|
+
"@visulima/error": "6.0.0-alpha.35",
|
|
599
599
|
"@visulima/spinner": "1.0.0-alpha.4",
|
|
600
|
-
"@visulima/string": "3.0.0-alpha.
|
|
600
|
+
"@visulima/string": "3.0.0-alpha.18",
|
|
601
601
|
"cli-boxes": "^4.0.1",
|
|
602
602
|
"code-excerpt": "^4.0.0",
|
|
603
603
|
"is-in-ci": "^2.0.0",
|
|
@@ -651,14 +651,14 @@
|
|
|
651
651
|
}
|
|
652
652
|
},
|
|
653
653
|
"optionalDependencies": {
|
|
654
|
-
"@visulima/tui-binding-darwin-arm64": "1.0.0-alpha.
|
|
655
|
-
"@visulima/tui-binding-linux-arm64-
|
|
656
|
-
"@visulima/tui-binding-
|
|
657
|
-
"@visulima/tui-binding-
|
|
658
|
-
"@visulima/tui-binding-linux-x64-gnu": "1.0.0-alpha.
|
|
659
|
-
"@visulima/tui-binding-linux-x64-musl": "1.0.0-alpha.
|
|
660
|
-
"@visulima/tui-binding-win32-arm64-msvc": "1.0.0-alpha.
|
|
661
|
-
"@visulima/tui-binding-win32-x64-msvc": "1.0.0-alpha.
|
|
654
|
+
"@visulima/tui-binding-darwin-arm64": "1.0.0-alpha.27",
|
|
655
|
+
"@visulima/tui-binding-linux-arm64-gnu": "1.0.0-alpha.27",
|
|
656
|
+
"@visulima/tui-binding-darwin-x64": "1.0.0-alpha.27",
|
|
657
|
+
"@visulima/tui-binding-linux-arm64-musl": "1.0.0-alpha.27",
|
|
658
|
+
"@visulima/tui-binding-linux-x64-gnu": "1.0.0-alpha.27",
|
|
659
|
+
"@visulima/tui-binding-linux-x64-musl": "1.0.0-alpha.27",
|
|
660
|
+
"@visulima/tui-binding-win32-arm64-msvc": "1.0.0-alpha.27",
|
|
661
|
+
"@visulima/tui-binding-win32-x64-msvc": "1.0.0-alpha.27"
|
|
662
662
|
},
|
|
663
663
|
"engines": {
|
|
664
664
|
"node": "^22.14.0 || >=24.10.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"react/jsx-runtime";import"react";import"./measure-element-Cs7_proT.js";import"../components/box.js";import{C as l}from"./controlled-scroll-view-BQ0JOudw.js";export{l as ControlledScrollView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
class d{constructor(e,s){this.target=e,this.contentRect=s}target;contentRect}class l{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()),t=Math.round(e.yogaNode.getComputedHeight());!Number.isNaN(i)&&!Number.isNaN(t)&&(s={height:t,width:i},e.internal_lastMeasuredSize=s)}if(s){const i=new d(e,s);try{this.callback([i],this)}catch(t){console.error(t)}}}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 h(r,e,s=!1){const i=r.resizeObservers&&r.resizeObservers.size>0;if((i||s)&&r.yogaNode){const t=Math.round(r.yogaNode.getComputedWidth()),o=Math.round(r.yogaNode.getComputedHeight());if(!Number.isNaN(t)&&!Number.isNaN(o)){const a=r.internal_lastMeasuredSize;if((a?.width!==t||a.height!==o)&&(r.internal_lastMeasuredSize={height:o,width:t},i)){const c=new d(r,{height:o,width:t});for(const n of r.resizeObservers)e.has(n)||e.set(n,[]),e.get(n).push(c)}}}}function b(r,e=!1){const s=new Map;function i(t){if(h(t,s,e),!t.internal_static)for(const o of t.childNodes)o.nodeName!=="#text"&&i(o)}i(r);for(const[t,o]of s)t.internalTrigger(o)}export{d as ResizeObserverEntry,l as default,h as measureAndExtractObservers,b as triggerResizeObservers};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsxs as D,jsx as l}from"react/jsx-runtime";import{Box as a}from"../components/box.js";import{ScrollBar as b}from"./ScrollBar-BKCK8jsb.js";const L=({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:f,...B})=>{const o=w==="left",c=o?"left":"right",m=o?g??r:p??r,n=o?C??e:H??e;return D(a,{flexDirection:"row",height:x,...B,children:[o&&l(b,{autoHide:h,color:m,contentHeight:i,dimColor:n,placement:c,scrollOffset:d,style:t,thumbChar:s,viewportHeight:f}),l(a,{borderColor:r,borderDimColor:e,borderLeft:!o,borderRight:o,borderStyle:t,flexGrow:1,overflow:"hidden",children:u}),!o&&l(b,{autoHide:h,color:m,contentHeight:i,dimColor:n,placement:c,scrollOffset:d,style:t,thumbChar:s,viewportHeight:f})]})};export{L as ScrollBarBox,L as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import i from"yoga-layout";import{getScrollTop as P,getScrollLeft as R}from"./calculateScroll-D4Y_JR4H.js";import X from"./squashTextNodesWithMap-BmUSBPfc.js";const G=t=>{let e=t,o=0,r=0;for(;e?.parentNode;){if(!e.yogaNode)return;o+=e.yogaNode.getComputedLeft(),r+=e.yogaNode.getComputedTop(),e=e.parentNode}return{x:o,y:r}},k=t=>G(t),z=t=>{const e=G(t);if(!(!e||!t.yogaNode))return{x:e.x+t.yogaNode.getComputedBorder(i.EDGE_LEFT)+t.yogaNode.getComputedPadding(i.EDGE_LEFT),y:e.y+t.yogaNode.getComputedBorder(i.EDGE_TOP)+t.yogaNode.getComputedPadding(i.EDGE_TOP)}},A=(t,e)=>{const{initialState:o,onNewline:r,onSpace:s,onText:n}=e;if(t.nodeName!=="ink-box"&&t.nodeName!=="ink-root"&&t.nodeName!=="ink-text"&&t.nodeName!=="ink-virtual-text"||!t.yogaNode)return{lineBottom:0,state:o()};const{fragments:l}=W(t),a=o();a.currentX=0,a.lineBottom=0,a.yieldedContent=!1;for(const d of l){if(d.y>=a.lineBottom){const g=d.y-a.lineBottom,u=a.yieldedContent?1+g:g;u>0&&(r(u,a),a.currentX=0),a.lineBottom=d.y}if(d.x>a.currentX){const g=d.x-a.currentX;s(g,a),a.currentX=d.x}if(d.text.length>0&&(a.yieldedContent=!0,n(d,a)),(d.text.match(/\n/g)??[]).length>0){const g=d.text.lastIndexOf(`
|
|
2
|
-
`);a.currentX=d.text.length-g-1}else a.currentX+=d.text.length;a.lineBottom=Math.max(a.lineBottom,d.y+d.height)}return{lineBottom:a.lineBottom,state:a}},U=t=>{const e=k(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)}},j=t=>{const{yogaNode:e}=t;if(!e)return 0;const o=e.getComputedWidth()??0,r=e.getComputedBorder(i.EDGE_LEFT),s=e.getComputedBorder(i.EDGE_RIGHT);return Math.round(o-r-s)},q=t=>{const{yogaNode:e}=t;if(!e)return 0;const o=e.getComputedHeight()??0,r=e.getComputedBorder(i.EDGE_TOP),s=e.getComputedBorder(i.EDGE_BOTTOM);return Math.round(o-r-s)},S=t=>{const{yogaNode:e}=t;if(!e)return{height:0,width:0,x:0,y:0};const o=e.getComputedWidth()??0,r=e.getComputedHeight()??0;let s=e.getComputedLeft(),n=e.getComputedTop(),l=t.parentNode;for(;l?.yogaNode;){if(s+=l.yogaNode.getComputedLeft(),n+=l.yogaNode.getComputedTop(),l.nodeName==="ink-box"){const a=l.style.overflow??"visible",d=l.style.overflowX??a;(l.style.overflowY??a)==="scroll"&&(n-=P(l)),d==="scroll"&&(s-=R(l))}l=l.parentNode}return{height:Math.round(r),width:Math.round(o),x:Math.round(s),y:Math.round(n)}},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:r,scrollDimension:s,scrollPosition:n}=t,l=r*2,a=Math.max(e==="vertical"?2:1,Math.round(o/s*l)),d=s-o,g=l-a,u=d>0?Math.round(n/d*g):0,h=u,m=u+a,c=Math.floor(h/2);return{endIndex:Math.min(r,Math.ceil(m/2)),startIndex:c,thumbEndHalf:m,thumbStartHalf:h}},b=t=>{const{axis:e,clientDimension:o,hasOppositeScrollbar:r,height:s,marginBottom:n,marginRight:l,scrollDimension:a,scrollPosition:d,width:g,x:u,y:h}=t;if(a<=o)return;if(e==="vertical"){const{endIndex:C,startIndex:x,thumbEndHalf:D,thumbStartHalf:T}=H({axis:e,clientDimension:o,scrollbarDimension:s,scrollDimension:a,scrollPosition:d}),f=u+g-1-l;return{height:s,thumb:{end:C,endHalf:D,height:C-x,start:x,startHalf:T,width:1,x:f,y:h+x},width:1,x:f,y:h}}const m=g-(r?1:0),{endIndex:c,startIndex:p,thumbEndHalf:N,thumbStartHalf:y}=H({axis:e,clientDimension:o,scrollbarDimension:m,scrollDimension:a,scrollPosition:d}),B=h+s-1-n;return{height:1,thumb:{end:c,endHalf:N,height:1,start:p,startHalf:y,width:c-p,x:u+p,y:B},width:m,x:u,y:B}},K=(t,e)=>{const{yogaNode:o}=t;if(!o)return;const r=t.style.overflow??"visible";if((t.style.overflowY??r)!=="scroll")return;const s=t.internal_scrollState?.clientHeight??0,n=t.internal_scrollState?.scrollHeight??0;if(n<=s)return;const{x:l,y:a}=e??S(t),d=o.getComputedHeight()-o.getComputedBorder(i.EDGE_TOP)-o.getComputedBorder(i.EDGE_BOTTOM);return b({axis:"vertical",clientDimension:s,hasOppositeScrollbar:!1,height:d,marginBottom:o.getComputedBorder(i.EDGE_BOTTOM),marginRight:o.getComputedBorder(i.EDGE_RIGHT),scrollDimension:n,scrollPosition:t.internal_scrollState?.scrollTop??0,width:o.getComputedWidth()-o.getComputedBorder(i.EDGE_LEFT),x:l+o.getComputedBorder(i.EDGE_LEFT),y:a+o.getComputedBorder(i.EDGE_TOP)})},Q=(t,e)=>{const{yogaNode:o}=t;if(!o)return;const r=t.style.overflow??"visible";if((t.style.overflowX??r)!=="scroll")return;const s=t.internal_scrollState?.clientWidth??0,n=t.internal_scrollState?.scrollWidth??0;if(n<=s)return;const{x:l,y:a}=e??S(t),d=t.style.overflowY??r,g=t.internal_scrollState?.clientHeight??0,u=t.internal_scrollState?.scrollHeight??0,h=d==="scroll"&&u>g;return b({axis:"horizontal",clientDimension:s,hasOppositeScrollbar:h,height:o.getComputedHeight()-o.getComputedBorder(i.EDGE_TOP),marginBottom:o.getComputedBorder(i.EDGE_BOTTOM),marginRight:o.getComputedBorder(i.EDGE_RIGHT),scrollDimension:n,scrollPosition:t.internal_scrollState?.scrollLeft??0,width:o.getComputedWidth()-o.getComputedBorder(i.EDGE_LEFT)-o.getComputedBorder(i.EDGE_RIGHT),x:l+o.getComputedBorder(i.EDGE_LEFT),y:a+o.getComputedBorder(i.EDGE_TOP)})},Z=(t,e)=>{if(!t.yogaNode||t===e)return 0;let o=t.yogaNode.getComputedTop(),r=t.parentNode;for(;r&&r!==e;)r.yogaNode&&(o+=r.yogaNode.getComputedTop()),r=r.parentNode;if(!(e!==void 0&&r!==e))return Math.round(o)},tt=(t,e)=>{if(!t.yogaNode||t===e)return 0;let o=t.yogaNode.getComputedLeft(),r=t.parentNode;for(;r&&r!==e;)r.yogaNode&&(o+=r.yogaNode.getComputedLeft()),r=r.parentNode;if(!(e!==void 0&&r!==e))return Math.round(o)},F=t=>t.nodeName==="#text"?t.nodeValue:t.nodeName==="ink-text"||t.nodeName==="ink-virtual-text"?X(t):"",W=t=>{const e=[],o=(n,l,a)=>{const{visualX:d,visualY:g,x:u,y:h}=l;let m=0,c=0,p=a;const{userSelect:N}=n.style;if(N==="none"?p=!1:(N==="text"||N==="all")&&(p=!0),n.nodeName==="ink-text"||n.nodeName==="ink-virtual-text"){if(p){const y=F(n);return e.push({height:Math.round(n.yogaNode?.getComputedHeight()??0),node:n,text:y,visualX:Math.round(d),visualY:Math.round(g),width:Math.round(n.yogaNode?.getComputedWidth()??0),x:Math.round(u),y:Math.round(h)}),{h:0,hasContent:!0,v:0}}return{h:n.yogaNode?.getComputedWidth()??0,hasContent:!1,v:n.yogaNode?.getComputedHeight()??0}}if(n.nodeName==="ink-box"||n.nodeName==="ink-root"){if(!n.yogaNode||n.yogaNode.getDisplay()===i.DISPLAY_NONE)return{h:0,hasContent:!1,v:0};const y=n.yogaNode.getComputedBorder(i.EDGE_TOP),B=n.yogaNode.getComputedBorder(i.EDGE_BOTTOM),C=n.yogaNode.getComputedBorder(i.EDGE_LEFT),x=n.yogaNode.getComputedBorder(i.EDGE_RIGHT);m+=y+B,c+=C+x;const D=n.yogaNode.getFlexDirection(),T=D===i.FLEX_DIRECTION_COLUMN||D===i.FLEX_DIRECTION_COLUMN_REVERSE;let f=0,_=0,M=!1;for(const E of n.childNodes)if(E.yogaNode){const O=u+E.yogaNode.getComputedLeft()-C-f,L=h+E.yogaNode.getComputedTop()-y-_,w=d+E.yogaNode.getComputedLeft(),I=g+E.yogaNode.getComputedTop(),v=o(E,{visualX:w,visualY:I,x:O,y:L},p);v.hasContent&&(M=!0),T?_+=v.v:f+=v.h}return T?m+=_:c+=f,{h:c,hasContent:M,v:m}}return{h:0,hasContent:!1,v:0}},{h:r,v:s}=o(t,{visualX:0,visualY:0,x:0,y:0},!0);return e.sort((n,l)=>n.y!==l.y?n.y-l.y:n.x-l.x),{fragments:e,removedHorizontal:Math.round(r),removedVertical:Math.round(s)}};export{U as R,H as a,W as b,b as c,S as d,Q as e,q as f,J as g,j as h,tt as i,Z as j,F as k,K as l,A as p,z as x,k as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"yoga-layout";import{x as e,y as i,p as a}from"./measure-element-Cs7_proT.js";export{e as getAbsoluteContentPosition,i as getAbsolutePosition,a as processLayout};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import{l as xe,i as Me}from"./dom-rphpG0kf.js";import{getStringWidth as j,isFullwidthCodePoint as ke,indent as Te}from"@visulima/string";import{B as P,D as H,I as G,U as I,e as z,H as Y,f as q,g as oe,F as $,h as re,S as we,j as Le,p as _e}from"./measure-text-B7juNq4Y.js";import T from"yoga-layout";import{j as A,i as Re,x as ie,c as se}from"./measure-element-Cs7_proT.js";import{g as Be,a as X}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 g=o.getSpans();for(const f of g){const s=f.formatFlags&127,{fgColor:h}=f,{bgColor:a}=f,{link:u}=f,d=s;if(d!==e||h!==r||a!==i||u!==l){if(u!==l&&(l&&(t+=l.startsWith("ST:")?"\x1B]8;;\x1B\\":"\x1B]8;;\x07"),u)){const m=u.startsWith("ST:");t+=`\x1B]8;;${m?u.slice(3):u}${m?"\x1B\\":"\x07"}`}const p=e&(P|H),y=d&(P|H);if(p!==y){const m=e&P&&!(d&P),C=e&H&&!(d&H);(m||C)&&(t+=M([ne])),d&P&&(!(e&P)||C)&&(t+=M([Pe])),d&H&&(!(e&H)||m)&&(t+=M([He]))}d&G&&!(e&G)?t+=M([$e]):!(d&G)&&e&G&&(t+=M([le])),d&I&&!(e&I)?t+=M([Ae]):!(d&I)&&e&I&&(t+=M([ae])),d&z&&!(e&z)?t+=M([Fe]):!(d&z)&&e&z&&(t+=M([de])),d&Y&&!(e&Y)?t+=M([Ge]):!(d&Y)&&e&Y&&(t+=M([he])),d&q&&!(e&q)?t+=M([Ie]):!(d&q)&&e&q&&(t+=M([ue])),h!==r&&(t+=M(h?oe(h,!0):[ce])),a!==i&&(t+=M(a?oe(a,!1):[ge])),n=d!==0||h!==void 0||a!==void 0,e=d,r=h,i=a,l=u}t+=o.getTextRange(c,c+f.length),c+=f.length}return n&&(e&(P|H)&&(t+=M([ne])),e&G&&(t+=M([le])),e&I&&(t+=M([ae])),e&z&&(t+=M([de])),e&Y&&(t+=M([he])),e&q&&(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 U{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):_e(t),this.setCacheEntry(this.styledLines,t,e)),e}getStringWidth(t){let e=this.widths.get(t);return e===void 0&&(e=j(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 J{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 U,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),g=l.length>0;for(const[f,s]of c.entries()){const h=e+f;if(h<0||h>=this.grid.length||n&&(h<n.y1||h>=n.y2))continue;let a=s;if(g)for(const v of l)a=v(a,f);if(a.length===0)continue;const u=this.grid[h],d=this.caches.getStyledLine(a);let p=t;const y=n?Math.min(n.x2,u.length):1/0,m=d.getSpans();let C=0,L=m[0]?.length??0;for(let v=0;v<d.length;v++){for(;C<m.length&&v>=L;)C++,L+=m[C]?.length??0;if(p>=y)break;if(n&&(p<n.x1||p>=n.x2)){p++,d.getFullWidth(v)&&p++;continue}if(p>=0){p>=u.length&&u.ensureWidth(p+2);const E=m[C],b=d.getFullWidth(v),N=(E?.formatFlags??0)|(b?$:0);u.setCharFast(p,d.getValue(v),N,E?.fgColor,E?.bgColor,E?.link),b&&(p++,p>=u.length&&u.ensureWidth(p+1),u.setCharFast(p,"",N&~$,E?.fgColor,E?.bgColor,E?.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],g=n.getSpans();let f=0,s=g[0]?.length??0;for(let h=0;h<n.length;h++){for(;f<g.length&&h>=s;)f++,s+=g[f]?.length??0;const a=e+h;if(a<0||a>=c.length)continue;const u=n.getValue(h),d=g[f],p=d!==void 0&&(d.formatFlags&~$)!==0||d?.fgColor!==void 0||d?.bgColor!==void 0||d?.link!==void 0;if(u!==" "||p){const y=(d?.formatFlags??0)|(n.getFullWidth(h)?$:0);c.setCharFast(a,u,y,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,g=r.getSpans();let f=0,s=g[0]?.length??0;for(let h=0;h<r.length;h++){for(;f<g.length&&h>=s;)f++,s+=g[f]?.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 a=g[f],u=r.getFullWidth(h),d=(a?.formatFlags??0)|(u?$:0);t.setCharFast(n,r.getValue(h),d,a?.fgColor,a?.bgColor,a?.link),u&&(n++,n>=t.length&&t.ensureWidth(n+1),t.setCharFast(n,"",d&~$,a?.fgColor,a?.bgColor,a?.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,g]of t.entries()){const f=g;if(i&&this.previousLines[c]?.equals(f)){l[c]=this.previousRenderedLines[c]??"";continue}n++;const s=f.trimEnd(),h=Ye(s);l[c]=h,e&&(this.previousRenderedLines[c]=h,this.previousLines[c]=f.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 g=0,f=c[0]?.length??0;for(let s=0;s<n.length&&s<this.width;s++){for(;g<c.length&&s>=f;)g++,f+=c[g]?.length??0;const h=n.getValue(s);if(h.length===0)continue;const a=h.codePointAt(0)??32,u=(l*this.width+s)*2,d=c[g],p=d?.formatFlags??0,y=d?.fgColor,m=d?.bgColor,C=y?re(y):255,L=m?re(m):255,v=(p&255)<<16|(L&255)<<8|C&255;if(r[u]=a,r[u+1]=v,n.getFullWidth(s)&&s+1<this.width){const E=u+2;r[E]=Oe,r[E+1]=v,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(T.EDGE_LEFT)-o.getComputedPadding(T.EDGE_RIGHT)-o.getComputedBorder(T.EDGE_LEFT)-o.getComputedBorder(T.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,g=e.style.borderStyle&&e.style.borderTop!==!1?1:0,f=e.style.borderStyle&&e.style.borderBottom!==!1?1:0,s=i-n-c,h=l-g-f;if(!(s>0&&h>0))return;const a=Be(e.style.backgroundColor);if(!a)return;const u=`${a}${" ".repeat(s)}\x1B[49m`;for(let d=0;d<h;d++)r.write(o+n,t+g+d,u,{transformers:[]})},O=(o,t,e,r)=>{let i=X(o,t,"foreground");return i=X(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 g=e?` ${e} `:"",f=i?` ${i} `:"",s=g.length,h=f.length,a=r??"left";if(s+h>=t){if(s>=t)return`${g.slice(0,t-1)}…`;const y=t-s;return y>3?g+f.slice(0,y):g+O(o.repeat(t-s),l,n,c)}const u=t-s-h;if(a==="left"||i)return g+O(o.repeat(u),l,n,c)+f;if(a==="right"){const y=t-s;return O(o.repeat(y),l,n,c)+g}const d=Math.floor(u/2),p=u-d;return O(o.repeat(d),l,n,c)+g+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,g=e.style.borderBottomColor??e.style.borderColor,f=e.style.borderLeftColor??e.style.borderColor,s=e.style.borderRightColor??e.style.borderColor,h=e.style.borderTopBackgroundColor??e.style.borderBackgroundColor,a=e.style.borderBottomBackgroundColor??e.style.borderBackgroundColor,u=e.style.borderLeftBackgroundColor??e.style.borderBackgroundColor,d=e.style.borderRightBackgroundColor??e.style.borderBackgroundColor,p=e.style.borderTopDimColor??e.style.borderDimColor,y=e.style.borderBottomDimColor??e.style.borderDimColor,m=e.style.borderLeftDimColor??e.style.borderDimColor,C=e.style.borderRightDimColor??e.style.borderDimColor,L=e.style.borderTop!==!1,v=e.style.borderBottom!==!1,E=e.style.borderLeft!==!1,b=e.style.borderRight!==!1,N=Math.max(0,i-(E?1:0)-(b?1:0));let x;if(L){const D=E?O(n.topLeft,c,h,p):"",W=b?O(n.topRight,c,h,p):"",R=fe(n.top,N,e.style.borderTopTitle,e.style.borderTopTitleAlignment,e.style.borderTopRightTitle,c,h,p);x=D+R+W}let k=l;L&&(k-=1),v&&(k-=1),k=Math.max(0,k);let w="";E&&(w=`${O(n.left,f,u,m)}
|
|
6
|
-
`.repeat(k));let S="";b&&(S=`${O(n.right,s,d,C)}
|
|
7
|
-
`.repeat(k));let _;if(v){const D=E?O(n.bottomLeft,g,a,y):"",W=b?O(n.bottomRight,g,a,y):"",R=fe(n.bottom,N,e.style.borderBottomTitle,e.style.borderBottomTitleAlignment,void 0,g,a,y);_=D+R+W}const B=L?1:0;x&&r.write(o,t,x,{transformers:[]}),w&&r.write(o,t+B,w,{transformers:[]}),S&&r.write(o+i-1,t+B,S,{transformers:[]}),_&&r.write(o,t+l-1,_,{transformers:[]})}},pe=[],me=({axis:o,color:t,layout:e,output:r})=>{const{thumb:{end:i,endHalf:l,start:n,startHalf:c},x:g,y:f}=e;if(o==="vertical")for(let s=n;s<i;s++){let h="█";const a=2*s>=c&&2*s<l,u=2*s+1>=c&&2*s+1<l;a&&!u?h="▀":!a&&u&&(h="▄");const d=t?X(h,t,"foreground"):h;r.write(g,f+s,d,{transformers:pe})}else for(let s=n;s<i;s++){let h="█";const a=2*s>=c&&2*s<l,u=2*s+1>=c&&2*s+1<l;a&&!u?h="▌":!a&&u&&(h="▐");const d=t?X(h,t,"foreground"):h;r.write(g+s,f,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[f,s]of o.entries()){const{node:h,type:a}=s;if(!h.yogaNode)continue;const u=A(h,t)??0,d=Math.round(h.yogaNode.getComputedHeight()),p=u+d,y=h.parentNode;let m=0,C=Number.MAX_SAFE_INTEGER;y?.yogaNode&&(m=A(y,t)??0,C=Math.round(y.yogaNode.getComputedHeight())),a==="top"&&u<e&&m+C>e&&(i=s,l=f),a==="bottom"&&Math.floor(p)>Math.floor(r)&&m<r&&(n=s,c=f)}const g=[];if(i){let f;for(let s=l+1;s<o.length;s++){const h=o[s];if(h.type!=="bottom"){f=h;break}}g.push({nextStickyNodeInfo:f,stickyNode:i.node,type:"top"})}if(n){let f;for(let s=c-1;s>=0;s--){const h=o[s];if(h.type==="bottom"){f=h;break}}g.push({nextStickyNodeInfo:f,stickyNode:n.node,type:"bottom"})}return g},Qe=(o,t,e,r,i)=>{const{newTransformers:l,skipStaticElements:n,x:c,y:g}=i,{yogaNode:f}=t;if(!f)return;const s=f.getComputedBorder(T.EDGE_TOP),h=f.getComputedBorder(T.EDGE_LEFT),a=Ce(t),u=t.internal_scrollState?.clientHeight??0;for(const{nextStickyNodeInfo:d,stickyNode:p,type:y}of o){if(!p.yogaNode)continue;const m=A(p,t)??0,C=Math.round(p.yogaNode.getComputedHeight()),L=c+(Re(p,t)??0),v=p.parentNode;let E=0,b=Number.MAX_SAFE_INTEGER;v?.yogaNode&&(E=A(v,t)??0,b=Math.round(v.yogaNode.getComputedHeight()));let N;if(y==="top"){const w=v?.yogaNode?.getComputedBorder(T.EDGE_BOTTOM)??0,S=E+b-w;let _=g-a+S-C;const B=g-a+m,D=g+s;if(d?.node?.yogaNode){const W=A(d.node,t)??0,R=g-a+W-C;R<_&&(_=R)}N=Math.min(Math.max(D,B),_)}else{const w=v?.yogaNode?.getComputedBorder(T.EDGE_TOP)??0;let S=g-a+E+w;const _=g-a+m,B=g+s+u-C;if(d?.node?.yogaNode){const D=Math.round(d.node.yogaNode.getComputedHeight()),W=A(d.node,t)??0,R=g-a+W+D;R>S&&(S=R)}N=Math.max(Math.min(B,_),S)}const x=r({height:C,width:Math.round(p.yogaNode.getComputedWidth())});K(p,x,{offsetX:-Math.round(p.yogaNode.getComputedLeft()),offsetY:-Math.round(p.yogaNode.getComputedTop()),skipStaticElements:n,transformers:l});const k=x.get().output.split(`
|
|
8
|
-
`);for(const[w,S]of k.entries())S&&S.length>0&&e.write(L-(c+h),N-(g+s)+w,S,{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)+Te(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||ke(i)||(e++,e>t))return!0}return!1},st=o=>(o.internal_hidden??!1)||o.yogaNode?.getDisplay()===T.DISPLAY_NONE,nt=o=>{let t=o;for(;t;){if(st(t))return!0;t=t.parentNode}return!1},V=(o,t={})=>{if(t.skipStaticElements&&o.internal_static||o.internal_hidden||o.internal_stickyAlternate||o.yogaNode?.getDisplay()===T.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=>V(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},K=(o,t,e)=>{const{absoluteOffsetX:r,absoluteOffsetY:i,offsetX:l=0,offsetY:n=0,renderState:c,skipStaticElements:g,transformers:f=[]}=e;if(g&&o.internal_static||o.internal_hidden)return;if(o.cachedRender){const h=Math.round(l+(o.yogaNode?.getComputedLeft()??0)),a=Math.round(n+(o.yogaNode?.getComputedTop()??0));t.addRegionTree(o.cachedRender,h,a);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 a=h.anchorRef?h.anchorRef.current:o.parentNode;if(!a){c.cursorPosition=void 0;return}if(h.anchorRef&&nt(a)){c.cursorPosition=void 0;return}const u=ie(a);if(!u){c.cursorPosition=void 0;return}c.cursorPosition={x:u.x+h.x,y:u.y+h.y};return}const{yogaNode:s}=o;if(s){if(s.getDisplay()===T.DISPLAY_NONE)return;const h=s.getComputedLeft(),a=s.getComputedTop(),u=Math.round(l+h),d=Math.round(n+a),p=Math.round((r??l)+h),y=Math.round((i??n)+a),m=t.getCurrentClip();if(m){const b=Math.round(s.getComputedWidth()),N=Math.round(s.getComputedHeight()),x=p+b,k=y+N,w=m.x1??-1/0,S=m.x2??1/0,_=m.y1??-1/0,B=m.y2??1/0;if(x<=w||p>=S||k<=_||y>=B)return}let C=f;if(typeof o.internal_transform=="function"&&(C=[o.internal_transform,...f]),o.nodeName==="ink-text"){let b=be(o);if(b.length>0){const N=je(s);if(it(b,N)&&Math.max(...b.split(`
|
|
12
|
-
`).map(x=>j(x)))>N){const x=o.style.textWrap??"wrap";b=xe(b,Math.floor(N),x)}if(b=Ze(o,b),t.write(u,d,b,{transformers:C}),c){const x=b.split(`
|
|
13
|
-
`),k=x.at(-1)??"";c.lastTextWriteEnd={x:u+j(k),y:d+x.length-1}}}return}let L=!1,v=0,E=0;if(o.nodeName==="ink-box"){Ve(u,d,o,t),Ue(u,d,o,t);const b=o.style.overflow??"visible",N=o.style.overflowX??b,x=o.style.overflowY??b,k=N==="hidden"||N==="scroll",w=x==="hidden"||x==="scroll";if(k||w){const S=Math.round(s.getComputedWidth()),_=Math.round(s.getComputedHeight()),B=k?u+s.getComputedBorder(T.EDGE_LEFT):u,D=k?S-s.getComputedBorder(T.EDGE_LEFT)-s.getComputedBorder(T.EDGE_RIGHT):S,W=w?d+s.getComputedBorder(T.EDGE_TOP):d,R=w?_-s.getComputedBorder(T.EDGE_TOP)-s.getComputedBorder(T.EDGE_BOTTOM):_;t.startChildRegion(B,W,Math.max(0,D),Math.max(0,R)),L=!0,x==="scroll"&&o.internal_scrollState&&(E=-o.internal_scrollState.scrollTop),N==="scroll"&&o.internal_scrollState&&(v=-o.internal_scrollState.scrollLeft)}}if(o.nodeName==="ink-root"||o.nodeName==="ink-box"||o.nodeName==="ink-static-render"){for(const b of o.childNodes)K(b,t,{absoluteOffsetX:p+v,absoluteOffsetY:y+E,offsetX:u+v,offsetY:d+E,renderState:c,skipStaticElements:g,transformers:C});if(o.nodeName==="ink-box"&&o.internal_scrollState){const b=ve(o);if(b.length>0){const N=Ce(o),x=o.internal_scrollState.clientHeight,k=N+x,w=Je(b,o,N,k);w.length>0&&Qe(w,o,t,S=>new J(S),{newTransformers:C,skipStaticElements:g,x:u,y:d})}}if(o.nodeName==="ink-box"&&o.internal_scrollState){const b=o.style.overflow??"visible",N=o.style.overflowX??b,x=o.style.overflowY??b,k=s.getComputedBorder(T.EDGE_LEFT),w=s.getComputedBorder(T.EDGE_RIGHT),S=s.getComputedBorder(T.EDGE_TOP),_=s.getComputedBorder(T.EDGE_BOTTOM),B=Math.round(s.getComputedWidth()-k-w),D=Math.round(s.getComputedHeight()-S-_),{clientHeight:W,clientWidth:R,scrollHeight:Q,scrollLeft:Ne,scrollTop:Se,scrollWidth:Z}=o.internal_scrollState,ee=x==="scroll"&&Q>W,Ee=N==="scroll"&&Z>R,te=o.internal_scrollbar!==!1;if(ee&&te){const F=se({axis:"vertical",clientDimension:W,hasOppositeScrollbar:!1,height:D,marginBottom:0,marginRight:0,scrollDimension:Q,scrollPosition:Se,width:B,x:u+k,y:d+S});F&&me({axis:"vertical",color:o.style.scrollbarThumbColor,layout:F,output:t})}if(Ee&&te){const F=se({axis:"horizontal",clientDimension:R,hasOppositeScrollbar:ee,height:D,marginBottom:0,marginRight:0,scrollDimension:Z,scrollPosition:Ne,width:B,x:u+k,y:d+S});F&&me({axis:"horizontal",color:o.style.scrollbarThumbColor,layout:F,output:t})}}L&&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 J({height:r,width:e});for(const c of o.childNodes)K(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 g=!1,f=!1;const s=(a,u,d,p,y,m)=>{if(a.nodeName==="#text"){const{length:C}=a.nodeValue;n===a&&(y.value=!0,d.value=u.value+c),i===a&&(m.value=!0,p.value=u.value+l),u.value+=C}else if("childNodes"in a){for(const C of a.childNodes)a===n&&(y.value=!0,d.value=u.value),a===i&&(m.value=!0,p.value=u.value),s(C,u,d,p,y,m);a===n&&c===a.childNodes.length&&(y.value=!0,d.value=u.value),a===i&&l===a.childNodes.length&&(m.value=!0,p.value=u.value)}},h=a=>{if(a.nodeName==="ink-text"){if(!Me(a))return;const u={value:0},d={value:-1},p={value:-1},y={value:!1},m={value:!1};for(const C of a.childNodes)a===n&&(y.value=!0,d.value=u.value),a===i&&(m.value=!0,p.value=u.value),s(C,u,d,p,y,m);if(a===n&&c===a.childNodes.length&&(y.value=!0,d.value=u.value),a===i&&l===a.childNodes.length&&(m.value=!0,p.value=u.value),(g||y.value)&&(!f||m.value)){const C=y.value?d.value:0,L=m.value?p.value:u.value;C!==-1&&L!==-1&&C<L&&e.set(a,{end:L,start:C})}y.value&&(g=!0),m.value&&(f=!0)}else{const{childNodes:u}=a;if(u){for(const d of u)a===n&&(g=!0),a===i&&(f=!0),h(d);a===n&&c===u.length&&(g=!0),a===i&&l===u.length&&(f=!0)}}};return h(o),e},at=new U,dt=new U,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 J({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 g=V(o,{skipStaticElements:!0}),f=g===""?0:g.split(`
|
|
14
|
-
`).length;let s="";return o.staticNode&&(s=V(o.staticNode,{skipStaticElements:!1})),{cursorPosition:void 0,cursorRequested:!1,cursorShape:void 0,output:g,outputHeight:f,staticOutput:s?`${s}
|
|
15
|
-
`:""}}e?.selection&&e.selection.rangeCount>0&<(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};K(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()}),K(o.staticNode,l,{skipStaticElements:!1})),e?.useNativeRenderer){const{buffer:g,height:f}=r.getBuffer();return{cursorPosition:i.cursorPosition,cursorRequested:i.cursorRequested,cursorShape:i.cursorShape,output:"",outputBuffer:g,outputHeight:f,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,J as I,St as r,K as v};
|