tmex-cli 0.12.0 → 0.12.2
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 +9 -23
- package/dist/runtime/server.js +69 -9
- package/package.json +1 -1
- package/resources/fe-dist/assets/DevicePage-B0fQ6yWB.js +25 -0
- package/resources/fe-dist/assets/{DevicesPage-Bm7E9QAf.js → DevicesPage-C7THDzTX.js} +2 -2
- package/resources/fe-dist/assets/{FilePage-DtXS6Krk.js → FilePage-D8V8P2IA.js} +2 -2
- package/resources/fe-dist/assets/{SettingsPage-Bxat-d_V.js → SettingsPage-BOTyBhHH.js} +8 -8
- package/resources/fe-dist/assets/{arc-CWkT1O24.js → arc-DcujnLz7.js} +2 -2
- package/resources/fe-dist/assets/architectureDiagram-3BPJPVTR-i8499Wfc.js +37 -0
- package/resources/fe-dist/assets/{blockDiagram-GPEHLZMM-DLFLNzT_.js → blockDiagram-GPEHLZMM-BFh4xZY2.js} +2 -2
- package/resources/fe-dist/assets/{c4Diagram-AAUBKEIU-BE8aWxc1.js → c4Diagram-AAUBKEIU-nUyGK7Ke.js} +2 -2
- package/resources/fe-dist/assets/{card-Duis2VHj.js → card-BkRqR9zz.js} +2 -2
- package/resources/fe-dist/assets/channel-DqmfsuLY.js +2 -0
- package/resources/fe-dist/assets/{chunk-2J33WTMH-Dlc3MV0y.js → chunk-2J33WTMH-z2oMKYMn.js} +2 -2
- package/resources/fe-dist/assets/{chunk-4BX2VUAB-E9XGobks.js → chunk-4BX2VUAB-CCD_pyAh.js} +2 -2
- package/resources/fe-dist/assets/{chunk-55IACEB6-Bp7ueFZf.js → chunk-55IACEB6-Dx2_9d-z.js} +2 -2
- package/resources/fe-dist/assets/{chunk-727SXJPM-CQrvyHfQ.js → chunk-727SXJPM-DA36poir.js} +2 -2
- package/resources/fe-dist/assets/{chunk-AQP2D5EJ-c0B1XNZr.js → chunk-AQP2D5EJ-CQoXkVd4.js} +2 -2
- package/resources/fe-dist/assets/{chunk-FMBD7UC4-BWQBkKWs.js → chunk-FMBD7UC4-A6Yn7A44.js} +2 -2
- package/resources/fe-dist/assets/{chunk-ND2GUHAM-D9TROogS.js → chunk-ND2GUHAM-BsNl2EMT.js} +2 -2
- package/resources/fe-dist/assets/{chunk-QZHKN3VN-DRXr6zVP.js → chunk-QZHKN3VN-BM_QNxf6.js} +2 -2
- package/resources/fe-dist/assets/classDiagram-4FO5ZUOK-D3Z9BeOE.js +2 -0
- package/resources/fe-dist/assets/classDiagram-v2-Q7XG4LA2-D3Z9BeOE.js +2 -0
- package/resources/fe-dist/assets/cose-bilkent-S5V4N54A-1lMO_Dod.js +2 -0
- package/resources/fe-dist/assets/{dagre-BM42HDAG-ClYznWvX.js → dagre-BM42HDAG-C9Up3ckQ.js} +2 -2
- package/resources/fe-dist/assets/{diagram-2AECGRRQ-Br_41uIc.js → diagram-2AECGRRQ-CtuDndmY.js} +2 -2
- package/resources/fe-dist/assets/{diagram-5GNKFQAL-BD9o1BrS.js → diagram-5GNKFQAL-BQfskK8S.js} +2 -2
- package/resources/fe-dist/assets/{diagram-KO2AKTUF-Diq2zS9Y.js → diagram-KO2AKTUF-CGJi8q81.js} +2 -2
- package/resources/fe-dist/assets/{diagram-LMA3HP47-CLaOalPy.js → diagram-LMA3HP47-DAMQIoLQ.js} +2 -2
- package/resources/fe-dist/assets/{diagram-OG6HWLK6-BcSlvdPy.js → diagram-OG6HWLK6-D2s__dFc.js} +2 -2
- package/resources/fe-dist/assets/{erDiagram-TEJ5UH35-BNlad0c4.js → erDiagram-TEJ5UH35-_UJYLIQN.js} +2 -2
- package/resources/fe-dist/assets/{flowDiagram-I6XJVG4X-Zb1FLY00.js → flowDiagram-I6XJVG4X-DN-qktDh.js} +2 -2
- package/resources/fe-dist/assets/ganttDiagram-6RSMTGT7-CNuuuhXX.js +293 -0
- package/resources/fe-dist/assets/{gitGraphDiagram-PVQCEYII-BENU2uEN.js → gitGraphDiagram-PVQCEYII-Qar2sVRo.js} +2 -2
- package/resources/fe-dist/assets/index-BhU3LRKb.css +1 -0
- package/resources/fe-dist/assets/{index-Den36xcn.js → index-Ra6pj0rt.js} +116 -116
- package/resources/fe-dist/assets/{infoDiagram-5YYISTIA-NfMlH21e.js → infoDiagram-5YYISTIA-2e6tU_v9.js} +2 -2
- package/resources/fe-dist/assets/{ishikawaDiagram-YF4QCWOH-CzK9-7uY.js → ishikawaDiagram-YF4QCWOH-BghKvoM4.js} +2 -2
- package/resources/fe-dist/assets/{journeyDiagram-JHISSGLW-CIX5Ahuw.js → journeyDiagram-JHISSGLW-D-cHSGb_.js} +2 -2
- package/resources/fe-dist/assets/{kanban-definition-UN3LZRKU-C5Ccl5Cw.js → kanban-definition-UN3LZRKU-BE6Cb-OK.js} +2 -2
- package/resources/fe-dist/assets/{linear-CBC08yeS.js → linear-CwDBnUH0.js} +2 -2
- package/resources/fe-dist/assets/{markdown-preview-Drd503bU.js → markdown-preview-BlQiC8ND.js} +4 -4
- package/resources/fe-dist/assets/{mermaid.core-DYl6mxS0.js → mermaid.core-DDMkLXrp.js} +6 -6
- package/resources/fe-dist/assets/{mindmap-definition-RKZ34NQL-ACR2SUDm.js → mindmap-definition-RKZ34NQL-C9xVR7Ut.js} +2 -2
- package/resources/fe-dist/assets/{pieDiagram-4H26LBE5-BuDDdwwy.js → pieDiagram-4H26LBE5-DW_4RcBv.js} +2 -2
- package/resources/fe-dist/assets/{quadrantDiagram-W4KKPZXB-CzM2Ydhy.js → quadrantDiagram-W4KKPZXB-DoIrZmk2.js} +2 -2
- package/resources/fe-dist/assets/{requirementDiagram-4Y6WPE33-BveKh_kW.js → requirementDiagram-4Y6WPE33-CYcJSuPe.js} +2 -2
- package/resources/fe-dist/assets/{sankeyDiagram-5OEKKPKP-BGQ6jtyE.js → sankeyDiagram-5OEKKPKP-CrIkKM6h.js} +2 -2
- package/resources/fe-dist/assets/{sequenceDiagram-3UESZ5HK-D2fdqire.js → sequenceDiagram-3UESZ5HK-DgzGHhGk.js} +2 -2
- package/resources/fe-dist/assets/{stateDiagram-AJRCARHV-DtuVBIq9.js → stateDiagram-AJRCARHV-C6Dhr3fY.js} +2 -2
- package/resources/fe-dist/assets/stateDiagram-v2-BHNVJYJU-BiSh2azE.js +2 -0
- package/resources/fe-dist/assets/terminal-settings-panel-CpnmWQtf.js +9 -0
- package/resources/fe-dist/assets/{timeline-definition-PNZ67QCA-Dslo0JFS.js → timeline-definition-PNZ67QCA-jJ1iauQ0.js} +2 -2
- package/resources/fe-dist/assets/{vennDiagram-CIIHVFJN-BLcoN4xU.js → vennDiagram-CIIHVFJN-DLRoaoJ9.js} +2 -2
- package/resources/fe-dist/assets/{wardley-L42UT6IY-OsbD5r1L.js → wardley-L42UT6IY-CykeHWp8.js} +2 -2
- package/resources/fe-dist/assets/{wardleyDiagram-YWT4CUSO-B_33zIif.js → wardleyDiagram-YWT4CUSO-U22jzD8a.js} +2 -2
- package/resources/fe-dist/assets/{xychartDiagram-2RQKCTM6-DcB27Ap1.js → xychartDiagram-2RQKCTM6-CiXS9PJ2.js} +2 -2
- package/resources/fe-dist/fonts/generated/blex-mono/blex-mono-bold.woff2 +0 -0
- package/resources/fe-dist/fonts/generated/blex-mono/blex-mono-regular.woff2 +0 -0
- package/resources/fe-dist/fonts/generated/fira-code/fira-code-bold.woff2 +0 -0
- package/resources/fe-dist/fonts/generated/fira-code/fira-code-regular.woff2 +0 -0
- package/resources/fe-dist/fonts/generated/jetbrains-mono/jetbrains-mono-bold.woff2 +0 -0
- package/resources/fe-dist/fonts/generated/jetbrains-mono/jetbrains-mono-regular.woff2 +0 -0
- package/resources/fe-dist/fonts/generated/noto-sans-mono/noto-sans-mono-bold.woff2 +0 -0
- package/resources/fe-dist/fonts/generated/noto-sans-mono/noto-sans-mono-regular.woff2 +0 -0
- package/resources/fe-dist/fonts/generated/victor-mono/victor-mono-bold.woff2 +0 -0
- package/resources/fe-dist/fonts/generated/victor-mono/victor-mono-regular.woff2 +0 -0
- package/resources/fe-dist/fonts/generated/zed-mono/zed-mono-bold.woff2 +0 -0
- package/resources/fe-dist/fonts/generated/zed-mono/zed-mono-regular.woff2 +0 -0
- package/resources/fe-dist/index.html +2 -2
- package/resources/fe-dist/assets/DevicePage-B2xsa-ys.js +0 -21
- package/resources/fe-dist/assets/architectureDiagram-3BPJPVTR-nu1LX68y.js +0 -37
- package/resources/fe-dist/assets/channel-zKL2OH3S.js +0 -2
- package/resources/fe-dist/assets/classDiagram-4FO5ZUOK-Drw216KI.js +0 -2
- package/resources/fe-dist/assets/classDiagram-v2-Q7XG4LA2-Drw216KI.js +0 -2
- package/resources/fe-dist/assets/cose-bilkent-S5V4N54A-CBgJRn7g.js +0 -2
- package/resources/fe-dist/assets/ganttDiagram-6RSMTGT7-DPRPR5Is.js +0 -293
- package/resources/fe-dist/assets/index-CRCD4gPw.css +0 -1
- package/resources/fe-dist/assets/refresh-cw-DhzvbVDA.js +0 -7
- package/resources/fe-dist/assets/stateDiagram-v2-BHNVJYJU-gun__PvU.js +0 -2
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
var Yt=Object.defineProperty;var Ft=(t,e,n)=>e in t?Yt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var m=(t,e,n)=>Ft(t,typeof e!="symbol"?e+"":e,n);import{Y as tt,$ as zt,a0 as ot,a1 as Wt,a2 as jt,a3 as Ut,a4 as Gt,a5 as lt,a6 as Vt,a7 as vt,u as Fe,j as h,a8 as Kt,a9 as $t,r as d,d as Q,aa as Rt,ab as Mt,ac as Xt,ad as at,ae as qt,o as ye,af as Qt,ag as nt,ah as Jt,b as _t,ai as it,aj as ae,ak as Zt,c as At,al as Dt,am as xe,an as en,ao as Ue,ap as tn,B as he,T as nn,aq as ct,ar as sn,as as rn,at as on,A as ln,f as an,g as cn,i as dn,k as un,l as hn,m as fn,n as mn,au as pn,av as wn}from"./index-Den36xcn.js";import{R as gn}from"./refresh-cw-DhzvbVDA.js";/**
|
|
2
|
-
* @license lucide-react v0.564.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const Sn=[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]],xn=tt("arrow-down-to-line",Sn);/**
|
|
7
|
-
* @license lucide-react v0.564.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const yn=[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]],bn=tt("clipboard-paste",yn);/**
|
|
12
|
-
* @license lucide-react v0.564.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const Tn=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Cn=tt("smartphone",Tn);function En(t){return`rgb(${t.r} ${t.g} ${t.b})`}const vn=new Map([[9622,4],[9623,8],[9624,1],[9625,13],[9626,9],[9627,7],[9628,11],[9629,2],[9630,6],[9631,14]]),Rn=new Map([[9617,.25],[9618,.5],[9619,.75]]);function Mn(t){return t>=9600&&t<=9631}function Ge(t){const e=t.getContext("2d");if(!e)throw new Error("2d canvas context unavailable");return e}class _n{constructor(e){m(this,"kind","canvas");m(this,"mainCanvas");m(this,"selectionCanvas");m(this,"cursorCanvas");m(this,"mainContext");m(this,"selectionContext");m(this,"cursorContext");m(this,"theme");m(this,"fontFamily");m(this,"fontSize");m(this,"cellDimensions",{width:9,height:17});m(this,"deviceCellWidth",9);m(this,"deviceCellHeight",17);m(this,"deviceFontSize",13);m(this,"textTopGap",0);m(this,"textBaselineY",0);m(this,"glyphBoxHeight",0);m(this,"dpr",1);m(this,"cols",0);m(this,"rows",0);m(this,"lastCursor",null);m(this,"frameCount",0);m(this,"lastDrawnRows",[]);m(this,"colorCache",new Map);m(this,"fontCache",new Map);m(this,"cursorBlinkVisible",!0);m(this,"cursorBlinkTimer",null);this.theme=e.theme,this.fontFamily=e.fontFamily,this.fontSize=e.fontSize,e.screenElement.style.position="relative",e.screenElement.style.overflow="hidden",this.mainCanvas=document.createElement("canvas"),this.selectionCanvas=document.createElement("canvas"),this.cursorCanvas=document.createElement("canvas");for(const[n,i]of[[this.mainCanvas,"main"],[this.selectionCanvas,"selection"],[this.cursorCanvas,"cursor"]])n.dataset.layer=i,n.style.position="absolute",n.style.inset="0",n.style.width="100%",n.style.height="100%",n.style.pointerEvents="none",e.screenElement.appendChild(n);this.mainContext=Ge(this.mainCanvas),this.selectionContext=Ge(this.selectionCanvas),this.cursorContext=Ge(this.cursorCanvas)}setTheme(e){this.theme=e,this.colorCache.clear()}render(e){if(this.frameCount+=1,this.lastDrawnRows=[],this.cellDimensions=e.cellDimensions,this.resize(e.meta.cols,e.meta.rows),this.drawSelection(e.selectionRects??[],e.selectionColor??this.theme.selectionBackground),e.meta.dirty==="clean"){this.drawCursor(e.meta);return}const n=e.meta.dirty==="full",i=n?e.rows:e.rows.filter(s=>s.dirty);let r;if(n)r=e.rows;else{const s=new Set;for(const o of i)s.add(o.y-1),s.add(o.y),s.add(o.y+1);r=e.rows.filter(o=>s.has(o.y))}for(const s of r)this.drawRowBackground(s,e.meta.colors);for(const s of r)this.drawRowForeground(s,e.meta.colors);for(const s of i)this.lastDrawnRows.push(s.y);this.drawCursor(e.meta)}getDebugState(){return{kind:this.kind,frameCount:this.frameCount,lastDrawnRows:[...this.lastDrawnRows]}}dispose(){this.mainCanvas.remove(),this.selectionCanvas.remove(),this.cursorCanvas.remove(),this.colorCache.clear(),this.fontCache.clear(),this.lastCursor=null,this.stopCursorBlink()}startCursorBlink(){this.cursorBlinkTimer||(this.cursorBlinkTimer=setInterval(()=>{this.cursorBlinkVisible=!this.cursorBlinkVisible,this.cursorCanvas.style.opacity=this.cursorBlinkVisible?"1":"0"},1e3))}stopCursorBlink(){this.cursorBlinkTimer&&(clearInterval(this.cursorBlinkTimer),this.cursorBlinkTimer=null),this.cursorBlinkVisible=!0,this.cursorCanvas.style.opacity="1"}resize(e,n){const i=Math.max(1,e),r=Math.max(1,n),s=Math.max(1,globalThis.devicePixelRatio??1),o=Math.max(1,Math.round(this.cellDimensions.width*s)),l=Math.max(1,Math.round(this.cellDimensions.height*s));if(this.cols===i&&this.rows===r&&this.dpr===s&&this.deviceCellWidth===o&&this.deviceCellHeight===l)return;this.cols=i,this.rows=r,this.dpr=s,this.deviceCellWidth=o,this.deviceCellHeight=l,this.deviceFontSize=this.fontSize*s,this.mainContext.font=`${this.deviceFontSize}px ${this.fontFamily}`;const u=this.mainContext.measureText("Mg|qyÅ");let f=u.fontBoundingBoxAscent,a=u.fontBoundingBoxDescent;Number.isFinite(f)&&Number.isFinite(a)&&f>0||(f=this.deviceFontSize*.8,a=this.deviceFontSize*.2),this.glyphBoxHeight=f+a,this.textTopGap=Math.round((l-this.glyphBoxHeight)/2),this.textBaselineY=Math.round(this.textTopGap+f);const T=i*o,A=r*l;for(const I of[this.mainCanvas,this.selectionCanvas,this.cursorCanvas])I.width=T,I.height=A,I.style.width=`${T/s}px`,I.style.height=`${A/s}px`;for(const I of[this.mainContext,this.selectionContext,this.cursorContext])I.setTransform(1,0,0,1,0,0),I.textBaseline="alphabetic",I.imageSmoothingEnabled=!1}drawSelection(e,n){if(this.selectionContext.clearRect(0,0,this.selectionCanvas.width,this.selectionCanvas.height),e.length!==0){this.selectionContext.fillStyle=n;for(const i of e)this.selectionContext.fillRect(i.x*this.deviceCellWidth,i.row*this.deviceCellHeight,i.width*this.deviceCellWidth,this.deviceCellHeight)}}drawRowBackground(e,n){const i=e.y*this.deviceCellHeight,r=this.cols*this.deviceCellWidth,s=this.toCss(n.background);this.mainContext.clearRect(0,i,r,this.deviceCellHeight),this.mainContext.fillStyle=s,this.mainContext.fillRect(0,i,r,this.deviceCellHeight);for(const o of e.cells){if(o.widthKind==="spacer-tail"||o.widthKind==="spacer-head")continue;const l=o.style.inverse?o.fgColor??n.foreground:o.bgColor??n.background;if(l.r!==n.background.r||l.g!==n.background.g||l.b!==n.background.b){const u=o.x*this.deviceCellWidth,f=o.widthKind==="wide"?this.deviceCellWidth*2:this.deviceCellWidth;this.mainContext.fillStyle=this.toCss(l),this.mainContext.fillRect(u,i,f,this.deviceCellHeight)}}}drawRowForeground(e,n){const i=e.y*this.deviceCellHeight,r=Math.max(1,Math.round(this.dpr));for(const s of e.cells){if(s.widthKind==="spacer-tail"||s.widthKind==="spacer-head"||!s.text||s.style.invisible)continue;const o=s.x*this.deviceCellWidth,l=s.style.inverse?s.bgColor??n.background:s.fgColor??n.foreground,u=s.widthKind==="wide"?this.deviceCellWidth*2:this.deviceCellWidth;this.mainContext.fillStyle=this.toCss(l);const f=s.codepoints.length===1&&Mn(s.codepoints[0])?s.codepoints[0]:null;f!==null?this.drawBlockElement(f,o,i,u,this.deviceCellHeight):(this.mainContext.font=this.resolveFont(s.style),this.mainContext.fillText(s.text,o,i+this.textBaselineY));const a=i+this.textTopGap,T=i+this.textTopGap+this.glyphBoxHeight;s.style.underline>0&&this.mainContext.fillRect(o,Math.min(Math.round(T-r),i+this.deviceCellHeight-r),Math.max(u-r,r),r),s.style.strikethrough&&this.mainContext.fillRect(o,Math.round(i+this.textTopGap+this.glyphBoxHeight/2),Math.max(u-r,r),r),s.style.overline&&this.mainContext.fillRect(o,Math.max(i,Math.round(a)),Math.max(u-r,r),r)}}drawBlockElement(e,n,i,r,s){const o=this.mainContext,l=k=>Math.round(r*k/8),u=k=>Math.round(s*k/8),f=(k,v,V,w)=>{o.fillRect(n+k,i+v,V-k,w-v)};if(e===9600){f(0,0,r,u(4));return}if(e>=9601&&e<=9608){f(0,u(8-(e-9600)),r,s);return}if(e>=9609&&e<=9615){f(0,0,l(9616-e),s);return}if(e===9616){f(l(4),0,r,s);return}const a=Rn.get(e);if(a!==void 0){const k=o.globalAlpha;o.globalAlpha=k*a,f(0,0,r,s),o.globalAlpha=k;return}if(e===9620){f(0,0,r,u(1));return}if(e===9621){f(l(7),0,r,s);return}const T=vn.get(e)??0,A=l(4),I=u(4);T&1&&f(0,0,A,I),T&2&&f(A,0,r,I),T&4&&f(0,I,A,s),T&8&&f(A,I,r,s)}drawCursor(e){const n=e.colors,i=e.cursor,r=this.lastCursor;if(this.cursorContext.clearRect(0,0,this.cursorCanvas.width,this.cursorCanvas.height),!i.visible||i.x===null||i.y===null){this.lastCursor=null,this.stopCursorBlink();return}const s=i.x*this.deviceCellWidth,o=i.y*this.deviceCellHeight,l=i.wideTail?this.deviceCellWidth*2:this.deviceCellWidth,u=Math.max(1,Math.round(this.dpr)),f=n.cursor??n.foreground,a=this.toCss(f);this.cursorContext.fillStyle=a,this.cursorContext.strokeStyle=a,this.cursorContext.globalAlpha=.7,this.cursorContext.fillRect(s,o+this.deviceCellHeight-2*u,Math.max(l-u,u),2*u),this.cursorContext.globalAlpha=1,this.startCursorBlink(),this.lastCursor={x:i.x,y:i.y,style:i.style},r&&(r.x!==this.lastCursor.x||r.y!==this.lastCursor.y||r.style!==this.lastCursor.style)&&this.lastDrawnRows.push(r.y)}resolveFont(e){const n=this.deviceFontSize,i=[e.italic?"italic":"normal",e.bold?"700":"400",`${n}px`,this.fontFamily].join("|"),r=this.fontCache.get(i);if(r)return r;const s=`${e.italic?"italic ":""}${e.bold?"700 ":""}${n}px ${this.fontFamily}`;return this.fontCache.set(i,s),s}toCss(e){const n=`${e.r},${e.g},${e.b}`,i=this.colorCache.get(n);if(i)return i;const r=En(e);return this.colorCache.set(n,r),r}}const be=0,An=-2,Dn=1,kn=2,Hn=3,In=10,Ln=11,Nn=12,Bn=13,On=14,Pn=15,Yn=16,Fn=17,zn=1,Wn=2,jn=1,Un=2,Gn=3,Vn=4,Kn=5,$n=6,Xn=1,qn=2,Qn=3,Jn=4;function st(t){if(t.disposed||t.renderStateHandle===0)throw new Error("render state resources already disposed")}function Zn(t){switch(t){case 2:return"full";case 1:return"partial";default:return"clean"}}function ei(t){switch(t){case 0:return"bar";case 2:return"underline";case 3:return"block-hollow";default:return"block"}}function ti(t){switch(t){case 1:return"wide";case 2:return"spacer-tail";case 3:return"spacer-head";default:return"narrow"}}function Ee(t,e){return{r:t.view().getUint8(e),g:t.view().getUint8(e+1),b:t.view().getUint8(e+2)}}function dt(t,e){const n=t.bindings.allocStruct("GhosttyColorRgb");try{const i=e(n.ptr);if(i===An)return null;if(i!==be)throw new Error(`ghostty optional color read failed with result ${i}`);return Ee(t.bindings,n.ptr)}finally{n.free()}}function ce(t,e){const n=t.bindings.allocU8();try{const i=e(n);if(typeof i=="number"&&i!==be)throw new Error(`ghostty bool read failed with result ${i}`);return t.bindings.readU8(n)!==0}finally{t.bindings.freeU8(n)}}function He(t,e){const n=t.bindings.allocBytes(2);try{const i=e(n);if(typeof i=="number"&&i!==be)throw new Error(`ghostty u16 read failed with result ${i}`);return t.bindings.view().getUint16(n,!0)}finally{t.bindings.freeBytes(n,2)}}function ni(t,e){const n=t.bindings.allocBytes(4);try{const i=e(n);if(typeof i=="number"&&i!==be)throw new Error(`ghostty u32 read failed with result ${i}`);return t.bindings.view().getUint32(n,!0)}finally{t.bindings.freeBytes(n,4)}}function Je(t,e){const n=t.bindings.allocBytes(4);try{const i=e(n);if(typeof i=="number"&&i!==be)throw new Error(`ghostty enum read failed with result ${i}`);return t.bindings.view().getInt32(n,!0)}finally{t.bindings.freeBytes(n,4)}}function ut(t,e){const n=t.bindings.allocBytes(8);try{const i=e(n);if(typeof i=="number"&&i!==be)throw new Error(`ghostty u64 read failed with result ${i}`);return t.bindings.readU64(n)}finally{t.bindings.freeBytes(n,8)}}function ii(t){const e=t.bindings.allocStruct("GhosttyStyle");try{t.bindings.setField(e.view,"GhosttyStyle","size",t.bindings.typeSize("GhosttyStyle")),t.bindings.getRenderStateRowCellValue(t.rowCellsHandle,Un,e.ptr);const n=i=>t.bindings.field("GhosttyStyle",i).offset;return{bold:e.view.getUint8(n("bold"))!==0,italic:e.view.getUint8(n("italic"))!==0,faint:e.view.getUint8(n("faint"))!==0,blink:e.view.getUint8(n("blink"))!==0,inverse:e.view.getUint8(n("inverse"))!==0,invisible:e.view.getUint8(n("invisible"))!==0,strikethrough:e.view.getUint8(n("strikethrough"))!==0,overline:e.view.getUint8(n("overline"))!==0,underline:e.view.getInt32(n("underline"),!0)}}finally{e.free()}}function si(t){const e=ni(t,i=>t.bindings.getRenderStateRowCellValueResult(t.rowCellsHandle,Gn,i));if(e===0)return[];const n=t.bindings.allocBytes(e*4);try{t.bindings.getRenderStateRowCellValue(t.rowCellsHandle,Vn,n);const i=[];for(let r=0;r<e;r+=1)i.push(t.bindings.view().getUint32(n+r*4,!0));return i}finally{t.bindings.freeBytes(n,e*4)}}function ri(t){if(t.length===0)return"";try{return String.fromCodePoint(...t)}catch{return""}}function oi(t){let e="";for(const n of t)if(!(n.widthKind==="spacer-tail"||n.widthKind==="spacer-head")){if(n.text){e+=n.text;continue}n.widthKind==="narrow"&&(e+=" ")}return e}function li(t){const e=t.bindings.allocStruct("GhosttyRenderStateColors");try{t.bindings.setField(e.view,"GhosttyRenderStateColors","size",t.bindings.typeSize("GhosttyRenderStateColors")),t.bindings.getRenderStateColors(t.renderStateHandle,e.ptr);const n=t.bindings.field("GhosttyRenderStateColors","palette").offset,i=[];for(let o=0;o<256;o+=1){const l=e.ptr+n+o*3;i.push(Ee(t.bindings,l))}const r=e.view.getUint8(t.bindings.field("GhosttyRenderStateColors","cursor_has_value").offset)!==0,s=ce(t,o=>t.bindings.getRenderStateValueResult(t.renderStateHandle,On,o));return{cols:He(t,o=>t.bindings.getRenderStateValueResult(t.renderStateHandle,Dn,o)),rows:He(t,o=>t.bindings.getRenderStateValueResult(t.renderStateHandle,kn,o)),dirty:Zn(Je(t,o=>t.bindings.getRenderStateValueResult(t.renderStateHandle,Hn,o))),colors:{background:Ee(t.bindings,e.ptr+t.bindings.field("GhosttyRenderStateColors","background").offset),foreground:Ee(t.bindings,e.ptr+t.bindings.field("GhosttyRenderStateColors","foreground").offset),cursor:r?Ee(t.bindings,e.ptr+t.bindings.field("GhosttyRenderStateColors","cursor").offset):null,palette:i},cursor:{style:ei(Je(t,o=>t.bindings.getRenderStateValueResult(t.renderStateHandle,In,o))),visible:ce(t,o=>t.bindings.getRenderStateValueResult(t.renderStateHandle,Ln,o)),blinking:ce(t,o=>t.bindings.getRenderStateValueResult(t.renderStateHandle,Nn,o)),passwordInput:ce(t,o=>t.bindings.getRenderStateValueResult(t.renderStateHandle,Bn,o)),x:s?He(t,o=>t.bindings.getRenderStateValueResult(t.renderStateHandle,Pn,o)):null,y:s?He(t,o=>t.bindings.getRenderStateValueResult(t.renderStateHandle,Yn,o)):null,wideTail:s?ce(t,o=>t.bindings.getRenderStateValueResult(t.renderStateHandle,Fn,o)):!1}}}finally{e.free()}}function ai(t,e){const n=ut(t,s=>t.bindings.getRenderStateRowValueResult(t.rowIteratorHandle,Wn,s));t.bindings.bindRenderStateRowCells(t.rowIteratorHandle,t.rowCellsHandle);const i=[];let r=0;for(;t.bindings.nextRenderStateRowCell(t.rowCellsHandle);){const s=ut(t,f=>t.bindings.getRenderStateRowCellValueResult(t.rowCellsHandle,jn,f)),o=si(t),l=ti(Je(t,f=>t.bindings.getRawCellValueResult(s,Qn,f))),u={x:r,text:ri(o),codepoints:o,widthKind:l,hasText:ce(t,f=>t.bindings.getRawCellValueResult(s,Jn,f)),style:ii(t),fgColor:dt(t,f=>t.bindings.getRenderStateRowCellValueResult(t.rowCellsHandle,$n,f)),bgColor:dt(t,f=>t.bindings.getRenderStateRowCellValueResult(t.rowCellsHandle,Kn,f))};i.push(u),r+=1}return{y:e,dirty:ce(t,s=>t.bindings.getRenderStateRowValueResult(t.rowIteratorHandle,zn,s)),wrap:ce(t,s=>t.bindings.getRawRowValueResult(n,Xn,s)),wrapContinuation:ce(t,s=>t.bindings.getRawRowValueResult(n,qn,s)),text:oi(i),cells:i}}function ht(t){return{bindings:t,renderStateHandle:t.createRenderState(),rowIteratorHandle:t.createRenderStateRowIterator(),rowCellsHandle:t.createRenderStateRowCells(),snapshotVersion:0,disposed:!1,cachedMeta:null}}function ft(t,e){st(t),t.bindings.updateRenderState(t.renderStateHandle,e),t.bindings.bindRenderStateRowIterator(t.renderStateHandle,t.rowIteratorHandle),t.snapshotVersion+=1,t.cachedMeta=null}function Ze(t){return st(t),t.cachedMeta||(t.cachedMeta=li(t)),t.cachedMeta}function*ci(t){st(t);const e=Ze(t);t.bindings.bindRenderStateRowIterator(t.renderStateHandle,t.rowIteratorHandle);let n=0;for(;n<e.rows&&t.bindings.nextRenderStateRowIterator(t.rowIteratorHandle);)yield ai(t,n),n+=1}function Ve(t){t.disposed||(t.disposed=!0,t.rowCellsHandle!==0&&(t.bindings.freeRenderStateRowCells(t.rowCellsHandle),t.rowCellsHandle=0),t.rowIteratorHandle!==0&&(t.bindings.freeRenderStateRowIterator(t.rowIteratorHandle),t.rowIteratorHandle=0),t.renderStateHandle!==0&&(t.bindings.freeRenderState(t.renderStateHandle),t.renderStateHandle=0),t.cachedMeta=null)}const di={colChars:[],contentCols:0,wrappedToNext:!1};function ui(t){for(let e=t.length-1;e>=0;e-=1){const n=t[e];if(n!==null&&n!==""&&n!==" ")return e+1}return 0}function mt(t,e=!1){const n=[];for(const i of t){if(i.widthKind==="spacer-tail"){n.push(null);continue}if(i.widthKind==="spacer-head"){n.push("");continue}n.push(i.text||" ")}return{colChars:n,contentCols:ui(n),wrappedToNext:e}}function hi(t,e){return Math.max(0,Math.min(Math.max(t.colChars.length-1,0),Math.floor(e)))}function rt(t,e){let n=hi(t,e);for(;n>0&&t.colChars[n]===null;)n-=1;return n}function Ke(t,e){let n=e;for(;n>0&&t.colChars[n]===null;)n-=1;return t.colChars[n]||""}function pt(t,e){let n=e;for(;n+1<t.colChars.length&&t.colChars[n+1]===null;)n+=1;return n}function fi(t,e){return t.line<e.line?{start:t,end:e}:t.line>e.line?{start:e,end:t}:t.col<=e.col?{start:t,end:e}:{start:e,end:t}}function mi(t,e,n){if(n.colChars.length===0)return{start:{line:t,col:0},end:{line:t,col:0}};const i=rt(n,e),r=l=>/[\p{L}\p{N}_-]/u.test(l);if(!r(Ke(n,i)))return{start:{line:t,col:i},end:{line:t,col:i}};let s=i,o=i;for(;s>0&&r(Ke(n,s-1));)s-=1;for(;o+1<n.colChars.length&&r(Ke(n,o+1));)o+=1;return{start:{line:t,col:s},end:{line:t,col:o}}}function kt(t,e){const n=Math.max(e.contentCols-1,0);return{start:{line:t,col:0},end:{line:t,col:n}}}function Ht(t,e,n){const i=n(t.line);switch(e){case"word":return mi(t.line,t.col,i);case"line":return kt(t.line,i);default:{const r=rt(i,t.col);return{start:{line:t.line,col:r},end:{line:t.line,col:r}}}}}function It(){return{anchor:null,focus:null,mode:"character"}}function wt(t){return!!(t.anchor&&t.focus)}function pi(){return It()}function wi(t,e,n){const i=Ht(e,e.mode,n);return{anchor:i.start,focus:i.end,mode:e.mode}}function gt(t,e,n){return t.anchor?t.mode==="line"?{...t,focus:kt(e.line,n(e.line)).end}:t.mode==="word"?{...t,focus:Ht(e,"word",n).end}:{...t,focus:{line:e.line,col:rt(n(e.line),e.col)}}:t}function Lt(t){return!t.anchor||!t.focus?null:fi(t.anchor,t.focus)}function gi(t,e,n){const i=t.wrappedToNext?t.colChars.length-1:t.contentCols-1,r=Math.min(n,i);let s=Math.max(0,e);for(;s>0&&t.colChars[s]===null;)s-=1;if(s>r)return"";let o="";for(let l=s;l<=r;l+=1)o+=t.colChars[l]??"";return o}function Si(t,e){const n=Lt(t);if(!n)return null;let i="";for(let r=n.start.line;r<=n.end.line;r+=1){const s=e(r),o=r===n.start.line?n.start.col:0,l=r===n.end.line?n.end.col:s.colChars.length-1;i+=gi(s,o,l),r<n.end.line&&!s.wrappedToNext&&(i+=`
|
|
17
|
-
`)}return i}function xi(t,e,n,i){const r=Lt(t);if(!r)return[];const s=e+n-1,o=[];for(let l=Math.max(r.start.line,e);l<=Math.min(r.end.line,s);l+=1){const u=l-e;if(l===r.start.line&&l===r.end.line){const a=i==null?void 0:i(l),T=a?pt(a,r.end.col):r.end.col;o.push({row:u,x:r.start.col,width:T-r.start.col+1});continue}if(l===r.start.line){const a=i?Math.max(i(l).colChars.length-r.start.col,0):Number.MAX_SAFE_INTEGER;o.push({row:u,x:r.start.col,width:a});continue}if(l===r.end.line){const a=i==null?void 0:i(l),T=a?pt(a,r.end.col):r.end.col;o.push({row:u,x:0,width:T+1});continue}const f=i?i(l).colChars.length:Number.MAX_SAFE_INTEGER;o.push({row:u,x:0,width:f})}return o}const $e=/https?:\/\/[^\s"'`<>()[\]{}]+/g,yi=/[.,;:!?]+$/;function bi(t){let e="";const n=[],i=t.colChars.length;for(let r=0;r<i;r+=1){const s=t.colChars[r];if(!(s===null||s===""))for(let o=0;o<s.length;o+=1)e+=s[o],n.push(r)}return{text:e,colOf:n}}function Ti(t){let e="";const n=[],i=[];for(let o=0;o<t.length;o+=1){const l=bi(t[o]);for(let u=0;u<l.text.length;u+=1)e+=l.text[u],n.push(o),i.push(l.colOf[u])}const r=[];$e.lastIndex=0;let s=$e.exec(e);for(;s!==null;){const o=s[0].replace(yi,"");if(o.length>0){const l=s.index,u=l+o.length-1;let f=l;for(let a=l;a<=u;a+=1)(a===u||n[a+1]!==n[a])&&(r.push({lineIndex:n[f],startCol:i[f],endCol:i[a],url:o}),f=a+1)}s=$e.exec(e)}return r}const St=80,ve=24,Xe=9,qe=17,xt=1.2,Ci=48,Nt="ghostty-official",Be=9,Oe=1e3,Pe=1002,Ye=1003,Qe=1007,Ie=1047,Le=1049,Ei=[Be,Oe,Pe,Ye],yt=1,bt=3,Tt=2,vi=4,Ri=5;class Mi{constructor(e){this.content=e}translateToString(e){return e?this.content.replace(/\s+$/u,""):this.content}}class _i{constructor(){m(this,"active",{baseY:0,viewportY:0,length:ve,getLine:e=>{const n=e-this.active.viewportY,i=this.visibleLines[n];return typeof i=="string"?new Mi(i):null}});m(this,"visibleLines",Array.from({length:ve},()=>""))}setViewport(e,n,i,r){this.active.viewportY=e,this.active.baseY=n,this.active.length=i,this.visibleLines=r}}const Ai={deleteContentBackward:"Backspace",deleteContentForward:"Delete",insertLineBreak:"Enter",insertParagraph:"Enter"};function Di(t){return!(t.key.length===1&&!t.ctrlKey&&!t.altKey&&!t.metaKey)}function ki(t,e){const n=t.slice(0,e).map(i=>i.text);for(;n.length<e;)n.push("");return n}function Ne(t){return vt({shiftKey:!!t.shiftKey,ctrlKey:!!t.ctrlKey,altKey:!!t.altKey,metaKey:!!t.metaKey,getModifierState:()=>!1})}class Hi{constructor(){m(this,"terminal",null)}activate(e){this.terminal=e instanceof ze?e:null}fit(){const e=this.proposeDimensions();!this.terminal||!e||this.terminal.resize(e.cols,e.rows)}proposeDimensions(){var e;return((e=this.terminal)==null?void 0:e.measureSizeFromElement())??null}dispose(){this.terminal=null}}class ze{constructor(e,n,i,r,s,o){m(this,"buffer",new _i);m(this,"_core",{_renderService:{dimensions:{css:{cell:{width:Xe,height:qe}}}}});m(this,"options");m(this,"element",null);m(this,"textarea",null);m(this,"cols",St);m(this,"rows",ve);m(this,"bindings");m(this,"terminalHandle");m(this,"keyEncoderHandle");m(this,"mouseEncoderHandle");m(this,"renderState");m(this,"dataListeners",new Set);m(this,"selectionListeners",new Set);m(this,"linkListeners",new Set);m(this,"linkCursorActive",!1);m(this,"lastNotifiedSelectionText",null);m(this,"addons",new Set);m(this,"screenElement",null);m(this,"renderer",null);m(this,"renderRaf",null);m(this,"disposed",!1);m(this,"disableStdin");m(this,"customKeyEventHandler",()=>!0);m(this,"imeIsComposing",!1);m(this,"lastCompositionCommit",null);m(this,"selectionState",It());m(this,"lineCache",new Map);m(this,"lastViewportOffset",0);m(this,"lastViewportRows",ve);m(this,"lastRenderedRows",[]);m(this,"pointerDrag",{active:!1,moved:!1,mode:"character",lastClientX:null,lastClientY:null});m(this,"autoScrollTimer",null);m(this,"domEventDisposers",[]);m(this,"copyShortcutSuppressed",!1);m(this,"scrollbarThumb",null);m(this,"scrollbarFadeTimer",null);m(this,"pressedMouseButtons",new Set);m(this,"wheelPixelDelta",0);m(this,"mouseDragActive",!1);this.bindings=e,this.terminalHandle=n,this.keyEncoderHandle=i,this.mouseEncoderHandle=r,this.renderState=s,this.options=o,this.disableStdin=!!o.disableStdin}static async create(e){const n=await zt(),i=n.createTerminal(St,ve,e.scrollback);let r=0,s=0,o=null;try{return n.setTerminalTheme(i,e.theme),r=n.createKeyEncoder(),s=n.createMouseEncoder(),o=ht(n),new ze(n,i,r,s,o,e)}catch(l){throw o&&Ve(o),r!==0&&n.freeKeyEncoder(r),s!==0&&n.freeMouseEncoder(s),n.freeTerminal(i),l}}open(e){if(this.disposed||this.element)return;const n=document.createElement("div");n.className="xterm",n.style.position="absolute",n.style.inset="0",n.style.overflow="hidden",n.style.width="100%",n.style.height="100%",n.style.backgroundColor=this.options.theme.background,n.style.color=this.options.theme.foreground,n.style.fontFamily=this.options.fontFamily,n.style.fontSize=`${this.options.fontSize}px`,n.style.lineHeight=String(xt);const i=document.createElement("div");i.className="xterm-viewport",i.style.width="100%",i.style.height="100%",i.style.overflow="hidden",i.style.position="relative";const r=document.createElement("div");r.className="xterm-screen",r.style.width="100%",r.style.height="100%",r.style.position="relative",r.style.userSelect="none",r.style.webkitUserSelect="none",r.style.backgroundColor=this.options.theme.background;const s=document.createElement("div");s.className="xterm-helper-textarea",s.setAttribute("aria-label","Terminal Input"),s.setAttribute("role","textbox"),s.setAttribute("contenteditable","true"),s.setAttribute("autocorrect","off"),s.setAttribute("autocapitalize","off"),s.setAttribute("spellcheck","false"),s.style.position="absolute",s.style.opacity="1",s.style.pointerEvents="none",s.style.left="0",s.style.top="0",s.style.minWidth="1px",s.style.minHeight="1px",s.style.whiteSpace="pre",s.style.border="0",s.style.padding="0",s.style.margin="0",s.style.color=this.options.theme.foreground,s.style.backgroundColor="transparent",s.style.caretColor="transparent",s.style.overflow="visible",s.style.outline="none",s.style.boxShadow="none",s.style.fontFamily=this.options.fontFamily,s.style.fontSize=`${this.options.fontSize}px`,s.style.userSelect="text",s.style.webkitUserSelect="text";const o=document.createElement("div");o.className="xterm-scrollbar-track",o.style.position="absolute",o.style.top="0",o.style.right="0",o.style.width="8px",o.style.height="100%",o.style.backgroundColor="transparent",o.style.pointerEvents="none";const l=document.createElement("div");l.className="xterm-scrollbar-thumb",l.style.position="absolute",l.style.top="0",l.style.right="0",l.style.width="6px",l.style.marginRight="1px",l.style.borderRadius="3px",l.style.backgroundColor="rgba(128, 128, 128, 0.5)",l.style.pointerEvents="none",l.style.transition="opacity 0.15s ease",l.style.opacity="0",o.appendChild(l),i.appendChild(r),n.appendChild(i),n.appendChild(s),n.appendChild(o),e.appendChild(n),this.element=n,this.screenElement=r,this.textarea=s,this.scrollbarThumb=l,this.renderer=new _n({screenElement:r,theme:this.options.theme,fontFamily:this.options.fontFamily,fontSize:this.options.fontSize}),this.syncInputState(),this.bindDomEvents(),this.updateCellDimensions();const u=this.measureSizeFromElement();u?this.resize(u.cols,u.rows):this.render()}loadAddon(e){e.activate(this),this.addons.add(e)}onData(e){return this.dataListeners.add(e),{dispose:()=>{this.dataListeners.delete(e)}}}attachCustomKeyEventHandler(e){this.customKeyEventHandler=e}onSelectionChange(e){return this.selectionListeners.add(e),{dispose:()=>{this.selectionListeners.delete(e)}}}onLinkActivated(e){return this.linkListeners.add(e),{dispose:()=>{this.linkListeners.delete(e)}}}hasSelection(){return wt(this.selectionState)}getSelection(){return this.getSelectionText()??""}clearSelection(){this.disposed||this.clearSelectionState()}startTouchSelection(e,n,i="word"){return this.disposed?!1:this.beginSelectionAt(e,n,i)}updateTouchSelection(e,n){this.disposed||this.updateSelectionDrag(e,n)}endTouchSelection(){this.disposed||!this.pointerDrag.active||(this.stopAutoScroll(),this.pointerDrag.active=!1,this.render())}write(e){if(this.disposed)return;const n=this.isAltScreenActive();this.bindings.writeVt(this.terminalHandle,e);const i=this.isAltScreenActive();n&&!i&&this.clearMouseTrackingModes(),this.scheduleRender()}clearMouseTrackingModes(){if(!this.disposed){for(const e of Ei)this.bindings.setTerminalMode(this.terminalHandle,e,!1);this.bindings.resetMouseEncoder(this.mouseEncoderHandle),this.pressedMouseButtons.clear(),this.mouseDragActive=!1}}isAltScreenActive(){return this.isModeEnabled(Ie)||this.isModeEnabled(Le)}reset(){this.disposed||(this.lineCache.clear(),this.clearSelectionState(!1),this.bindings.resetTerminal(this.terminalHandle),this.scheduleRender())}refresh(){this.disposed||this.render()}resize(e,n){if(this.disposed)return;const i=Math.max(2,Math.floor(e)),r=Math.max(2,Math.floor(n));this.cols=i,this.rows=r,this.clearSelectionState(!1),this.bindings.resizeTerminal(this.terminalHandle,i,r,this.cellDimensions()),this.bindings.resetMouseEncoder(this.mouseEncoderHandle),this.scheduleRender()}scrollLines(e){this.disposed||e===0||(this.bindings.scrollViewportDelta(this.terminalHandle,e),this.render())}scrollToTop(){this.disposed||(this.bindings.scrollViewportTop(this.terminalHandle),this.render())}scrollToBottom(){this.disposed||(this.bindings.scrollViewportBottom(this.terminalHandle),this.render())}exportModeSnapshot(){return{mouseX10:this.isModeEnabled(Be),mouseNormal:this.isModeEnabled(Oe),mouseButton:this.isModeEnabled(Pe),mouseAny:this.isModeEnabled(Ye),mouseUtf8:this.isModeEnabled(1005),mouseSgr:this.isModeEnabled(1006),mouseSgrPixels:this.isModeEnabled(1016),mouseUrxvt:this.isModeEnabled(1015),altScroll:this.isModeEnabled(Qe),altScreen1047:this.isModeEnabled(Ie),altScreen1049:this.isModeEnabled(Le)}}restoreModeSnapshot(e){this.bindings.setTerminalMode(this.terminalHandle,Be,e.mouseX10),this.bindings.setTerminalMode(this.terminalHandle,Oe,e.mouseNormal),this.bindings.setTerminalMode(this.terminalHandle,Pe,e.mouseButton),this.bindings.setTerminalMode(this.terminalHandle,Ye,e.mouseAny),this.bindings.setTerminalMode(this.terminalHandle,1005,e.mouseUtf8),this.bindings.setTerminalMode(this.terminalHandle,1006,e.mouseSgr),this.bindings.setTerminalMode(this.terminalHandle,1016,e.mouseSgrPixels),this.bindings.setTerminalMode(this.terminalHandle,1015,e.mouseUrxvt),this.bindings.setTerminalMode(this.terminalHandle,Qe,e.altScroll),this.bindings.setTerminalMode(this.terminalHandle,Ie,e.altScreen1047),this.bindings.setTerminalMode(this.terminalHandle,Le,e.altScreen1049),this.bindings.resetMouseEncoder(this.mouseEncoderHandle)}handleViewportGesture(e){if(this.disposed||e.deltaY===0)return!1;const n=this.gestureToLines(e);if(n===0)return!1;const i=this.getInputRoutingState();if(i.mouseReporting){const r=n<0?vi:Ri;let s=!1;for(let o=0;o<Math.abs(n);o+=1)s=this.emitMouseInput({action:"press",button:r,clientX:e.clientX,clientY:e.clientY,mods:Ne(e),anyButtonPressed:this.pressedMouseButtons.size>0})||s;return s}return i.altScroll?this.emitAltScrollInput(n):(this.scrollLines(n),!0)}paste(e){if(this.disposed||this.disableStdin||!e)return;const n=this.bindings.encodePaste(this.terminalHandle,e);n&&this.emitData(n)}focus(){var e;(e=this.textarea)==null||e.focus({preventScroll:!0})}getRendererKind(){var e;return((e=this.renderer)==null?void 0:e.kind)??"unknown"}setTheme(e){var n;this.bindings.setTerminalTheme(this.terminalHandle,e),this.options.theme=e,this.element&&(this.element.style.backgroundColor=e.background,this.element.style.color=e.foreground),this.screenElement&&(this.screenElement.style.backgroundColor=e.background),(n=this.renderer)==null||n.setTheme(e),this.scheduleRender()}setDisableStdin(e){this.disableStdin=e,this.syncInputState()}measureSizeFromElement(){const e=this.element;if(!e)return null;const n=e.getBoundingClientRect(),{width:i,height:r}=this.cellDimensions();return n.width===0||n.height===0||i<=0||r<=0?null:{cols:Math.max(2,Math.floor(n.width/i)),rows:Math.max(2,Math.floor(n.height/r))}}dispose(){var e,n;if(!this.disposed){this.disposed=!0,this.renderRaf!==null&&(cancelAnimationFrame(this.renderRaf),this.renderRaf=null),this.stopAutoScroll(),this.updateSelectionTextProbe(null),this.clearDomEventListeners(),this.scrollbarFadeTimer&&(clearTimeout(this.scrollbarFadeTimer),this.scrollbarFadeTimer=null);for(const i of this.addons)i.dispose();this.addons.clear(),(e=this.renderer)==null||e.dispose(),this.renderer=null,(n=this.element)==null||n.remove(),this.element=null,this.screenElement=null,this.textarea=null,this.scrollbarThumb=null,Ve(this.renderState),this.bindings.freeMouseEncoder(this.mouseEncoderHandle),this.bindings.freeKeyEncoder(this.keyEncoderHandle),this.bindings.freeTerminal(this.terminalHandle)}}cellDimensions(){return this._core._renderService.dimensions.css.cell}syncInputState(){this.textarea&&(this.textarea.readOnly=this.disableStdin,this.textarea.tabIndex=this.disableStdin?-1:0,this.disableStdin&&document.activeElement===this.textarea&&this.textarea.blur())}bindDomEvents(){const e=this.element,n=this.textarea;if(!e||!n)return;e.addEventListener("click",()=>{this.disableStdin||this.focus()});const i=this.screenElement??e;i.addEventListener("mousedown",s=>{if(s instanceof MouseEvent){if(this.disableStdin||this.focus(),this.getInputRoutingState().mouseReporting){const o=this.mouseButtonFromEvent(s);if(o===null)return;this.clearSelectionState(),this.pressedMouseButtons.add(o),this.mouseDragActive=!0,this.emitMouseInput({action:"press",button:o,clientX:s.clientX,clientY:s.clientY,mods:Ne(s),anyButtonPressed:!0}),s.preventDefault();return}if(s.button===0&&ot(s)){const o=this.linkAtClient(s.clientX,s.clientY);if(o){this.emitLinkActivated(o),s.preventDefault();return}}s.button===0&&(this.mouseDragActive=!0,this.beginPointerSelection(s),s.preventDefault())}}),i.addEventListener("mousemove",s=>{if(!(!(s instanceof MouseEvent)||this.mouseDragActive)){if(this.getInputRoutingState().mouseReporting){this.setLinkCursor(!1);return}this.setLinkCursor(ot(s)&&this.linkAtClient(s.clientX,s.clientY)!==null)}}),i.addEventListener("mouseleave",()=>{this.setLinkCursor(!1)}),e.addEventListener("wheel",s=>{this.handleViewportGesture({source:"wheel",deltaY:s.deltaY,deltaMode:s.deltaMode,clientX:s.clientX,clientY:s.clientY,shiftKey:s.shiftKey,ctrlKey:s.ctrlKey,altKey:s.altKey,metaKey:s.metaKey})&&s.preventDefault()},{passive:!1});const r=typeof window<"u"&&typeof window.addEventListener=="function"?window:null;if(r){const s=l=>{if(this.mouseDragActive){if(this.getInputRoutingState().mouseReporting){this.emitMouseInput({action:"motion",button:this.mouseButtonFromButtons(l.buttons),clientX:l.clientX,clientY:l.clientY,mods:Ne(l),anyButtonPressed:this.pressedMouseButtons.size>0||l.buttons>0});return}this.updatePointerSelection(l)}},o=l=>{if(this.mouseDragActive){if(this.mouseDragActive=!1,this.getInputRoutingState().mouseReporting){const u=this.mouseButtonFromEvent(l);u!==null&&this.pressedMouseButtons.delete(u),this.emitMouseInput({action:"release",button:u,clientX:l.clientX,clientY:l.clientY,mods:Ne(l),anyButtonPressed:this.pressedMouseButtons.size>0});return}this.finishPointerSelection(l)}};r.addEventListener("mousemove",s),r.addEventListener("mouseup",o),this.domEventDisposers.push(()=>{r.removeEventListener("mousemove",s),r.removeEventListener("mouseup",o)})}n.addEventListener("keydown",s=>{const o=this.getSelectionText();if(o&&Wt(s)){s.preventDefault(),jt(o).catch(()=>{}),this.clearSelectionState(),this.copyShortcutSuppressed=!0,this.clearTextarea();return}if(!this.customKeyEventHandler(s)||this.disableStdin||this.imeIsComposing||s.keyCode===229||Ut(s)||!Di(s))return;const l=this.encodeKeyboardEvent(s,s.repeat?"repeat":"press");l&&(s.preventDefault(),this.emitData(l),this.clearTextarea())}),n.addEventListener("keyup",s=>{if(this.copyShortcutSuppressed){const l=s.key.toLowerCase();if(l==="c"){s.preventDefault();return}if(l==="control"||l==="meta"||l==="os"){this.copyShortcutSuppressed=!1,s.preventDefault();return}}if(this.disableStdin||this.imeIsComposing)return;const o=this.encodeKeyboardEvent(s,"release");o&&(s.preventDefault(),this.emitData(o),this.clearTextarea())}),n.addEventListener("compositionstart",()=>{this.imeIsComposing=!0,this.lastCompositionCommit=null,this.syncTextareaPositionToCursor()}),n.addEventListener("compositionupdate",()=>{this.syncTextareaPositionToCursor()}),n.addEventListener("compositionend",s=>{this.imeIsComposing=!1;const o=s.data??"";o&&(this.lastCompositionCommit={data:o,at:Date.now()},this.emitData(o),this.clearTextarea())}),n.addEventListener("beforeinput",s=>{if(this.disableStdin||s.inputType==="insertFromPaste"||s.isComposing||this.imeIsComposing)return;const o=Ai[s.inputType??""];if(o){s.preventDefault();const f=this.encodeSyntheticKey(o);f&&this.emitData(f),this.clearTextarea();return}const l=s.data??"";if(!l)return;const u=this.lastCompositionCommit;if(u&&u.data===l&&Date.now()-u.at<40){this.lastCompositionCommit=null,s.preventDefault(),this.clearTextarea();return}this.lastCompositionCommit=null,s.preventDefault(),this.emitData(l),this.clearTextarea()}),n.addEventListener("paste",s=>{var l;if(this.disableStdin)return;const o=((l=s.clipboardData)==null?void 0:l.getData("text/plain"))??"";o&&(s.preventDefault(),this.paste(o),this.clearTextarea())}),n.addEventListener("copy",s=>{const o=this.getSelectionText();o&&Gt(s,o)}),n.addEventListener("input",()=>{if(this.disableStdin||this.imeIsComposing)return;const s=n.textContent??"";if(!s){this.clearTextarea();return}const o=this.lastCompositionCommit;if(o&&o.data===s&&Date.now()-o.at<40){this.lastCompositionCommit=null,this.clearTextarea();return}this.lastCompositionCommit=null,this.emitData(s),this.clearTextarea()})}encodeKeyboardEvent(e,n){const i=lt(e.code);if(i===0)return null;const r=e.key.length===1&&!e.ctrlKey&&!e.metaKey?e.key:null;return this.bindings.encodeKeyEvent(this.keyEncoderHandle,this.terminalHandle,{action:n,keyCode:i,mods:vt(e),composing:e.isComposing,utf8:r,unshiftedCodepoint:Vt(e.code)})}encodeSyntheticKey(e){const n={code:e,key:e,shiftKey:!1,ctrlKey:!1,altKey:!1,metaKey:!1,repeat:!1,isComposing:!1,getModifierState:()=>!1};return this.encodeKeyboardEvent(n,"press")}getInputRoutingState(){const e=this.isModeEnabled(Be)||this.isModeEnabled(Oe)||this.isModeEnabled(Pe)||this.isModeEnabled(Ye),n=this.isModeEnabled(Ie)||this.isModeEnabled(Le);return{mouseReporting:e,altScroll:!e&&n&&this.isModeEnabled(Qe)}}gestureToLines(e){const n=this.cellDimensions().height||qe;if(e.source==="wheel"){if(e.deltaMode===1)return this.wheelPixelDelta=0,e.deltaY>0?Math.ceil(e.deltaY):Math.floor(e.deltaY);if(e.deltaMode===2){this.wheelPixelDelta=0;const r=Math.max(1,this.rows),s=e.deltaY*r;return s>0?Math.ceil(s):Math.floor(s)}this.wheelPixelDelta+=e.deltaY;const i=this.wheelPixelDelta>0?Math.floor(this.wheelPixelDelta/n):Math.ceil(this.wheelPixelDelta/n);return i!==0&&(this.wheelPixelDelta-=i*n),i}return e.deltaY>0?Math.ceil(e.deltaY/n):Math.floor(e.deltaY/n)}isModeEnabled(e){return this.bindings.isTerminalModeEnabled(this.terminalHandle,e)}mouseButtonFromEvent(e){switch(e.button){case 0:return yt;case 1:return bt;case 2:return Tt;default:return null}}mouseButtonFromButtons(e){return e&1?yt:e&4?bt:e&2?Tt:null}pointerPositionFromClient(e,n){var o;const i=(o=this.screenElement)==null?void 0:o.getBoundingClientRect();if(!i)return null;const r=Math.max(1,i.width),s=Math.max(1,i.height);return{x:Math.max(0,Math.min(r-1,e-i.left)),y:Math.max(0,Math.min(s-1,n-i.top))}}emitMouseInput(e){var o;if(this.disableStdin)return!1;const n=this.pointerPositionFromClient(e.clientX,e.clientY);if(!n)return!1;const i=this.cellDimensions(),r=(o=this.screenElement)==null?void 0:o.getBoundingClientRect();if(!r)return!1;const s=this.bindings.encodeMouseEvent(this.mouseEncoderHandle,this.terminalHandle,{action:e.action,button:e.button,mods:e.mods,x:n.x,y:n.y,anyButtonPressed:e.anyButtonPressed,screenWidth:Math.max(1,Math.round(r.width)),screenHeight:Math.max(1,Math.round(r.height)),cellWidth:Math.max(1,Math.round(i.width||Xe)),cellHeight:Math.max(1,Math.round(i.height||qe))});return s?(this.emitData(s),!0):!1}emitAltScrollInput(e){const n=lt(e<0?"ArrowUp":"ArrowDown");if(n===0)return!1;let i=!1;for(let r=0;r<Math.abs(e);r+=1){const s=this.bindings.encodeKeyEvent(this.keyEncoderHandle,this.terminalHandle,{action:"press",keyCode:n,mods:0,composing:!1,utf8:null,unshiftedCodepoint:null});s&&(this.emitData(s),i=!0)}return i}emitData(e){for(const n of this.dataListeners)n(e)}clearTextarea(){this.textarea&&(this.textarea.textContent="")}syncTextareaPositionToCursor(){const e=this.textarea,n=this.screenElement;if(!e||!n)return;const{width:i,height:r}=this.cellDimensions();if(i<=0||r<=0)return;const s=ht(this.bindings);let o=0,l=0;try{ft(s,this.terminalHandle);const a=Ze(s);a.cursor.x!==null&&a.cursor.y!==null&&(o=a.cursor.x,l=a.cursor.y)}finally{Ve(s)}const u=o*i,f=l*r;e.style.left=`${u}px`,e.style.top=`${f}px`,e.style.width=`${Math.max(1,i)}px`,e.style.height=`${Math.max(1,r)}px`,e.style.lineHeight=`${r}px`,e.style.fontFamily=this.options.fontFamily,e.style.fontSize=`${this.options.fontSize}px`}scheduleRender(){this.renderRaf===null&&(this.renderRaf=requestAnimationFrame(()=>{this.renderRaf=null,this.render()}))}render(){if(this.disposed||!this.screenElement||!this.renderer)return;const e=this.bindings.readScrollbar(this.terminalHandle),n=Math.max(1,e.len||this.rows);ft(this.renderState,this.terminalHandle);const i=Ze(this.renderState),r=Array.from(ci(this.renderState));this.cols=Math.max(2,i.cols),this.rows=Math.max(2,i.rows||n),this.lastViewportOffset=e.offset,this.lastViewportRows=this.rows,this.lastRenderedRows=r;for(const f of r)this.lineCache.set(e.offset+f.y,mt(f.cells,f.wrap));const s=xi(this.selectionState,this.lastViewportOffset,this.lastViewportRows,f=>this.getLineModel(f)),o=this.getSelectionText();this.renderer.render({meta:i,rows:r,cellDimensions:this.cellDimensions(),selectionRects:s,selectionColor:this.options.theme.selectionBackground});const l=ki(r,this.rows),u=Math.max(0,e.total-e.len);this.buffer.setViewport(e.offset,u,e.total,l),this.updateSelectionTextProbe(o),this.updateScrollbar(e)}updateScrollbar(e){var u;const n=this.scrollbarThumb;if(!n)return;const i=((u=this.screenElement)==null?void 0:u.clientHeight)??0;if(i===0||e.total<=e.len){n.style.opacity="0";return}const r=e.len/e.total,s=Math.max(20,r*i),l=e.offset/Math.max(1,e.total-e.len)*(i-s);n.style.height=`${s}px`,n.style.transform=`translateY(${l}px)`,n.style.opacity="1",this.scrollbarFadeTimer&&clearTimeout(this.scrollbarFadeTimer),this.scrollbarFadeTimer=setTimeout(()=>{n.style.opacity="0"},800)}updateCellDimensions(){if(!this.element)return;const e=document.createElement("span");e.textContent="WWWWWWWWWW",e.style.position="absolute",e.style.visibility="hidden",e.style.whiteSpace="pre",e.style.fontFamily=this.options.fontFamily,e.style.fontSize=`${this.options.fontSize}px`,this.element.appendChild(e);const n=e.getBoundingClientRect();e.remove();const i=Math.max(1,globalThis.devicePixelRatio??1),r=n.width>0?n.width/10:Xe,s=this.options.fontSize*xt;this._core._renderService.dimensions.css.cell.width=Math.max(1,Math.round(r*i))/i,this._core._renderService.dimensions.css.cell.height=Math.max(1,Math.round(s*i))/i}clearSelectionState(e=!0){this.selectionState=pi(),this.pressedMouseButtons.clear(),this.wheelPixelDelta=0,this.pointerDrag={active:!1,moved:!1,mode:"character",lastClientX:null,lastClientY:null},this.copyShortcutSuppressed=!1,this.stopAutoScroll(),this.updateSelectionTextProbe(null),e&&this.screenElement&&this.renderer&&this.render()}beginSelectionAt(e,n,i){const r=this.hitTest(e,n);return r?(this.pointerDrag={active:!0,moved:!1,mode:i,lastClientX:e,lastClientY:n},this.selectionState=wi(this.selectionState,{...r,mode:i},s=>this.getLineModel(s)),this.updateAutoScroll(),this.render(),!0):!1}updateSelectionDrag(e,n){if(!this.pointerDrag.active)return;const i=this.hitTest(e,n);this.pointerDrag.lastClientX=e,this.pointerDrag.lastClientY=n,i&&(this.pointerDrag.moved=!0,this.selectionState=gt(this.selectionState,i,r=>this.getLineModel(r)),this.render()),this.updateAutoScroll()}beginPointerSelection(e){this.beginSelectionAt(e.clientX,e.clientY,this.selectionModeFromClickDetail(e.detail))}updatePointerSelection(e){this.updateSelectionDrag(e.clientX,e.clientY)}finishPointerSelection(e){var i,r,s,o;if(!this.pointerDrag.active||e.button!==0)return;this.pointerDrag.lastClientX=e.clientX,this.pointerDrag.lastClientY=e.clientY,this.stopAutoScroll();const n=this.pointerDrag.mode==="character"&&!this.pointerDrag.moved&&((i=this.selectionState.anchor)==null?void 0:i.line)===((r=this.selectionState.focus)==null?void 0:r.line)&&((s=this.selectionState.anchor)==null?void 0:s.col)===((o=this.selectionState.focus)==null?void 0:o.col);if(this.pointerDrag.active=!1,n){this.clearSelectionState();return}this.render()}selectionModeFromClickDetail(e){return e>=3?"line":e===2?"word":"character"}hitTest(e,n){var A;const i=(A=this.screenElement)==null?void 0:A.getBoundingClientRect();if(!i)return null;const{width:r,height:s}=this.cellDimensions();if(r<=0||s<=0)return null;const o=e-i.left,l=n-i.top,u=Math.max(this.cols-1,0),f=Math.max(this.lastViewportRows-1,0),a=Math.max(0,Math.min(u,Math.floor(o/r))),T=Math.max(0,Math.min(f,Math.floor(l/s)));return{line:this.lastViewportOffset+T,col:a}}getLineModel(e){const n=this.lineCache.get(e);if(n)return n;const i=e-this.lastViewportOffset,r=this.lastRenderedRows[i];return r?mt(r.cells,r.wrap):di}emitLinkActivated(e){for(const n of this.linkListeners)n(e)}setLinkCursor(e){this.linkCursorActive!==e&&(this.linkCursorActive=e,this.screenElement&&(this.screenElement.style.cursor=e?"pointer":""))}linkAtClient(e,n){const i=this.hitTest(e,n);return i?this.linkAtPoint(i.line,i.col):null}linkAtPoint(e,n){if(this.getLineModel(e).colChars.length===0)return null;let i=e;for(;this.getLineModel(i-1).wrappedToNext;)i-=1;let r=e;for(;this.getLineModel(r).wrappedToNext;)r+=1;const s=[];for(let l=i;l<=r;l+=1)s.push(this.getLineModel(l));const o=e-i;for(const l of Ti(s))if(l.lineIndex===o&&n>=l.startCol&&n<=l.endCol)return l.url;return null}getSelectionText(){return wt(this.selectionState)?Si(this.selectionState,e=>this.getLineModel(e)):null}updateSelectionTextProbe(e){if(globalThis.__tmexE2eTerminalSelectionText=e,e!==this.lastNotifiedSelectionText){this.lastNotifiedSelectionText=e;for(const n of this.selectionListeners)n(e)}}updateAutoScroll(){var i;if(!this.pointerDrag.active||this.pointerDrag.lastClientY===null){this.stopAutoScroll();return}const e=(i=this.screenElement)==null?void 0:i.getBoundingClientRect();if(!e){this.stopAutoScroll();return}if(!(this.pointerDrag.lastClientY<e.top||this.pointerDrag.lastClientY>e.bottom)){this.stopAutoScroll();return}this.autoScrollTimer===null&&(this.autoScrollTimer=setInterval(()=>{this.stepAutoScroll()},Ci))}stepAutoScroll(){var r;if(!this.pointerDrag.active||this.pointerDrag.lastClientX===null||this.pointerDrag.lastClientY===null){this.stopAutoScroll();return}const e=(r=this.screenElement)==null?void 0:r.getBoundingClientRect();if(!e){this.stopAutoScroll();return}let n=0;if(this.pointerDrag.lastClientY<e.top?n=-1:this.pointerDrag.lastClientY>e.bottom&&(n=1),n===0){this.stopAutoScroll();return}this.bindings.scrollViewportDelta(this.terminalHandle,n),this.render();const i=this.hitTest(this.pointerDrag.lastClientX,this.pointerDrag.lastClientY);i&&(this.selectionState=gt(this.selectionState,i,s=>this.getLineModel(s)),this.pointerDrag.moved=!0,this.render())}stopAutoScroll(){this.autoScrollTimer!==null&&(clearInterval(this.autoScrollTimer),this.autoScrollTimer=null)}clearDomEventListeners(){for(;this.domEventDisposers.length>0;){const e=this.domEventDisposers.pop();e==null||e()}}}async function Ii(t){return ze.create(t)}function Li({visible:t,canPaste:e,onCopy:n,onPaste:i,onDismiss:r}){const{t:s}=Fe();if(!t)return null;const o=l=>{l.preventDefault()};return h.jsxs("div",{className:"absolute top-2 left-1/2 z-20 flex -translate-x-1/2 items-center gap-1 rounded-lg border bg-background/95 p-1 shadow-md backdrop-blur","data-testid":"terminal-selection-toolbar",children:[h.jsxs("button",{type:"button",className:"flex h-9 items-center gap-1.5 rounded-md px-3 text-sm font-medium hover:bg-accent hover:text-accent-foreground",onMouseDown:o,onClick:n,"data-testid":"terminal-selection-copy",children:[h.jsx(Kt,{className:"h-4 w-4"}),s("terminal.copy")]}),e&&h.jsxs("button",{type:"button",className:"flex h-9 items-center gap-1.5 rounded-md px-3 text-sm font-medium hover:bg-accent hover:text-accent-foreground",onMouseDown:o,onClick:i,"data-testid":"terminal-selection-paste",children:[h.jsx(bn,{className:"h-4 w-4"}),s("terminal.paste")]}),h.jsx("button",{type:"button",className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-accent-foreground",onMouseDown:o,onClick:r,"aria-label":s("terminal.clearSelection"),"data-testid":"terminal-selection-dismiss",children:h.jsx($t,{className:"h-4 w-4"})})]})}function Bt(t){if(!t)return t;const e=t.replace(/\r\n/g,`
|
|
18
|
-
`);return(e.endsWith(`
|
|
19
|
-
`)?e.slice(0,-1):e).replace(/\n/g,`\r
|
|
20
|
-
`)}const Ni="\x1B[?1049h\x1B[H\x1B[2J";function Bi(t){return Ni+Bt(t)}function Ct(t,e){let n=e,i=0;for(const l of t)l===10&&!n&&(i+=1),n=l===13;const r=n;if(i===0)return{normalized:t,endedWithCR:r};const s=new Uint8Array(t.length+i);let o=0;n=e;for(const l of t)l===10&&!n&&(s[o]=13,o+=1),s[o]=l,o+=1,n=l===13;return{normalized:s,endedWithCR:r}}const Oi=1.3,Pi=36,Yi=500,Fi=12;function zi(t,e){const n=d.useRef(!1);return d.useEffect(()=>{const i=t.current;if(!i||!(window.innerWidth<768||navigator.maxTouchPoints>0||"ontouchstart"in window))return;n.current=!0;let s=0,o=null,l=!1,u=0,f=0,a=0,T=null,A=!1;const I=()=>{T!==null&&(clearTimeout(T),T=null)},k=b=>b?!!(b.closest(".scrollbar")||b.closest(".slider")||b.closest(".xterm-scroll-area")):!1,v=(b,C,N)=>{const F=N instanceof Element?N:null;if(k(F))return!0;const q=document.elementFromPoint(b,C);if(k(q))return!0;const y=i.querySelector(".xterm");if(!(y instanceof HTMLElement))return!1;const E=y.getBoundingClientRect(),P=b>=E.left&&b<=E.right,G=C>=E.top&&C<=E.bottom;return!P||!G?!1:b>=E.right-Pi},V=()=>[i.querySelector(".xterm-viewport"),i.querySelector(".xterm-scrollable-element")].filter(C=>C instanceof HTMLElement),w=b=>{if(o===null)return null;for(let C=0;C<b.length;C+=1){const N=b.item(C);if(N&&N.identifier===o)return N}return null},H=b=>{if(I(),b.touches.length!==1)return;const C=b.touches.item(0);C&&(o=C.identifier,s=C.clientY,u=0,l=v(C.clientX,C.clientY,b.target),f=C.clientX,a=C.clientY,A=!1,l||(T=setTimeout(()=>{var F;T=null;const N=(e==null?void 0:e())??null;(F=N==null?void 0:N.startTouchSelection)!=null&&F.call(N,f,a,"word")&&(A=!0)},Yi)))},z=b=>{var P,G,R,X,$,ee,te,M,ie;const C=w(b.touches)??b.touches.item(0);if(!C)return;if(A){const B=(e==null?void 0:e())??null;(P=B==null?void 0:B.updateTouchSelection)==null||P.call(B,C.clientX,C.clientY),b.cancelable&&b.preventDefault();return}if(T!==null&&Math.hypot(C.clientX-f,C.clientY-a)>Fi&&I(),l||(l=v(C.clientX,C.clientY,b.target),l&&(u=0)),l)return;const N=C.clientY,F=s-N;if(s=N,F===0)return;let q=!1,y=!1;const E=(e==null?void 0:e())??null;if(E){const B=E==null?void 0:E._core,j=(($=(X=(R=(G=B==null?void 0:B._renderService)==null?void 0:G.dimensions)==null?void 0:R.css)==null?void 0:X.cell)==null?void 0:$.height)??18;u+=F*Oi;const O=u>0?Math.floor(u/j):Math.ceil(u/j);if(typeof E.handleViewportGesture=="function")O!==0&&(q=E.handleViewportGesture({source:"touch",deltaY:O*j,clientX:C.clientX,clientY:C.clientY}),u-=O*j);else if(O!==0){const K=((te=(ee=E.buffer)==null?void 0:ee.active)==null?void 0:te.viewportY)??0;E.scrollLines(O);const oe=((ie=(M=E.buffer)==null?void 0:M.active)==null?void 0:ie.viewportY)??0;q=K!==oe,y=O<0&&K<=0&&oe<=0,u-=O*j}}else{const B=V();if(B.length===0)return;for(const j of B){const O=j.scrollTop;j.scrollTop+=F;const K=j.scrollTop;Math.abs(K-O)>0&&(q=!0),F<0&&K<=0&&(y=!0)}if(!q){const j=i.querySelector(".xterm");if(j instanceof HTMLElement){const O=new WheelEvent("wheel",{bubbles:!0,cancelable:!0,deltaMode:WheelEvent.DOM_DELTA_PIXEL,deltaY:F}),K=j.dispatchEvent(O);q=O.defaultPrevented||!K}}}b.cancelable&&(q||y)&&b.preventDefault()},W=b=>{var N;if(I(),!(o===null||!w(b.changedTouches))&&(o=null,u=0,l=!1,A)){A=!1;const F=(e==null?void 0:e())??null;(N=F==null?void 0:F.endTouchSelection)==null||N.call(F)}},L=b=>{A&&b.preventDefault()};return i.addEventListener("touchstart",H,{passive:!0}),i.addEventListener("touchmove",z,{passive:!1}),i.addEventListener("touchend",W,{passive:!0}),i.addEventListener("touchcancel",W,{passive:!0}),i.addEventListener("contextmenu",L),()=>{n.current=!1,I(),i.removeEventListener("touchstart",H),i.removeEventListener("touchmove",z),i.removeEventListener("touchend",W),i.removeEventListener("touchcancel",W),i.removeEventListener("contextmenu",L)}},[t,e]),n}function Wi({now:t,remoteSize:e,pendingLocalSize:n,ttlMs:i=2e3}){return!n||t-n.at>i?!0:n.cols===e.cols&&n.rows===e.rows}function ji({currentSize:t,containerSize:e,force:n=!1}){return n?!0:t.cols!==e.cols||t.rows!==e.rows}function Ui({deviceId:t,paneId:e,deviceConnected:n,isSelectionInvalid:i,onResize:r,onSync:s,getContainerRect:o}){const l=d.useRef(null),u=d.useRef(null),f=d.useRef(null),a=d.useRef(null),T=d.useRef(0),A=d.useRef([]),I=d.useRef(null),k=d.useRef(null),v=d.useRef(o),V=d.useRef(!1),w=d.useRef(r),H=d.useRef(s);d.useEffect(()=>{w.current=r},[r]),d.useEffect(()=>{H.current=s},[s]),d.useEffect(()=>{v.current=o},[o]);const z=d.useCallback(()=>{var ee,te,M,ie,B,j,O,K,oe,x;const y=k.current,E=I.current;if(!y||!E||!y.element)return null;let P;try{const S=E.proposeDimensions();if(!S)throw new Error("fitAddon.proposeDimensions() returned null");P=Math.max(2,S.cols)}catch{const S=y._core,D=((ie=(M=(te=(ee=S==null?void 0:S._renderService)==null?void 0:ee.dimensions)==null?void 0:te.css)==null?void 0:M.cell)==null?void 0:ie.width)??9,U=(B=v.current)==null?void 0:B.call(v);if(!U||U.width===0)return null;P=Math.max(2,Math.floor(U.width/D))}const G=(j=v.current)==null?void 0:j.call(v);if(!G||G.height===0)return null;const R=y._core,X=((x=(oe=(K=(O=R==null?void 0:R._renderService)==null?void 0:O.dimensions)==null?void 0:K.css)==null?void 0:oe.cell)==null?void 0:x.height)??17,$=Math.max(2,Math.floor(G.height/X));return{cols:P,rows:$}},[]),W=d.useCallback((y,E)=>{const P=k.current;P&&(P.cols===y&&P.rows===E||P.resize(y,E))},[]),L=d.useCallback((y,E=!1)=>{if(!t||!e||!n||i&&y!=="sync"||!E&&Date.now()<T.current||!k.current)return!1;const G=z();if(!G)return!1;const{cols:R,rows:X}=G,$=f.current;return!E&&$&&$.cols===R&&$.rows===X?(W(R,X),!0):(W(R,X),y==="sync"?H.current(R,X):w.current(R,X),f.current={cols:R,rows:X},a.current={cols:R,rows:X,at:Date.now()},!0)},[W,n,t,i,z,e]),b=d.useCallback((y="resize",E={})=>{const{immediate:P=!1,force:G=!1}=E;u.current!==null&&(window.clearTimeout(u.current),u.current=null),l.current!==null&&(cancelAnimationFrame(l.current),l.current=null);const R=()=>{l.current=requestAnimationFrame(()=>{l.current=null,L(y,G)})};if(P){R();return}u.current=window.setTimeout(()=>{u.current=null,R()},150)},[L]),C=d.useCallback(()=>{for(const y of A.current)window.clearTimeout(y);A.current=[]},[]),N=d.useCallback(()=>{var E;C(),b("sync",{immediate:!0,force:!0});const y=window.setTimeout(()=>{b("sync",{immediate:!0,force:!0})},60);A.current.push(y),typeof document<"u"&&"fonts"in document&&((E=document.fonts)!=null&&E.ready)&&document.fonts.ready.then(()=>{b("sync",{immediate:!0,force:!0})}).catch(()=>{})},[C,b]);d.useEffect(()=>{let y=null;const E=()=>{y!==null&&cancelAnimationFrame(y),y=requestAnimationFrame(()=>{y=null,b("resize")})};return window.addEventListener("resize",E),()=>{window.removeEventListener("resize",E),y!==null&&cancelAnimationFrame(y)}},[b]),d.useEffect(()=>{const y=()=>{var ee;const R=k.current,X=z();if(!R||!X)return;if(!ji({currentSize:{cols:Math.max(2,R.cols),rows:Math.max(2,R.rows)},containerSize:X})){(ee=R.refresh)==null||ee.call(R);return}b("sync",{force:!0})},E=()=>{if(document.visibilityState!=="visible"){V.current=!0;return}V.current&&(V.current=!1,y())},P=()=>{V.current=!0},G=()=>{V.current&&(V.current=!1,y())};return document.addEventListener("visibilitychange",E),window.addEventListener("blur",P),window.addEventListener("focus",G),()=>{document.removeEventListener("visibilitychange",E),window.removeEventListener("blur",P),window.removeEventListener("focus",G)}},[z,b]),d.useEffect(()=>()=>{C(),u.current!==null&&window.clearTimeout(u.current),l.current!==null&&cancelAnimationFrame(l.current)},[C]);const F=d.useCallback(y=>{I.current=y},[]),q=d.useCallback(y=>{k.current=y},[]);return{scheduleResize:b,runPostSelectResize:N,clearPostSelectResizeTimers:C,setFitAddon:F,setTerminal:q,lastReportedSize:f,pendingLocalSize:a,suppressLocalResizeUntil:T}}const Gi={fontFamily:Qt,fontSize:13,scrollback:1e4},et="tmex:terminal-mode-cache";function Vi(t,e){try{const n=sessionStorage.getItem(et);return n?JSON.parse(n)[`${t}:${e}`]??null:null}catch{return null}}function Ki(t,e,n){try{const i=sessionStorage.getItem(et),r=i?JSON.parse(i):{},s=`${t}:${e}`;n?r[s]=n:delete r[s],sessionStorage.setItem(et,JSON.stringify(r))}catch{}}function $i(){return{mouseX10:!1,mouseNormal:!0,mouseButton:!1,mouseAny:!1,mouseUtf8:!1,mouseSgr:!0,mouseSgrPixels:!1,mouseUrxvt:!1,altScroll:!0,altScreen1047:!1,altScreen1049:!1}}function Xi(t,e){if(!e)return t?{...t,mouseX10:!1,mouseNormal:!1,mouseButton:!1,mouseAny:!1,mouseUtf8:!1,mouseSgrPixels:!1,mouseUrxvt:!1,altScreen1047:!1,altScreen1049:!1}:null;const n=$i();if(!t)return n;const i=t.mouseNormal||t.mouseButton||t.mouseAny;return{...t,mouseX10:!1,mouseUtf8:!1,mouseSgr:!0,mouseSgrPixels:!1,mouseUrxvt:!1,altScroll:!0,altScreen1047:!1,altScreen1049:!1,mouseNormal:i?t.mouseNormal:n.mouseNormal}}function qi(t){var n;const e=globalThis;e.__tmexE2eXterm=t,e.__tmexE2eTerminal=t,e.__tmexE2eTerminalEngine=Nt,e.__tmexE2eTerminalRenderer=((n=t.getRendererKind)==null?void 0:n.call(t))??null}function Qi(t){if(!t)return;const e=globalThis;e.__tmexE2eTerminal!==t&&e.__tmexE2eXterm!==t||(e.__tmexE2eXterm=null,e.__tmexE2eTerminal=null,e.__tmexE2eTerminalEngine=null,e.__tmexE2eTerminalRenderer=null,e.__tmexE2eTerminalSelectionText=null)}const Ot=d.forwardRef(({deviceId:t,paneId:e,theme:n,inputMode:i,deviceConnected:r,isSelectionInvalid:s,onResize:o,onSync:l,children:u},f)=>{const[a,T]=d.useState(null),[A,I]=d.useState(!1),k=Q(x=>x.sendInput),{t:v}=Fe(),V=d.useMemo(()=>{switch(n){case"light":return Mt;default:return Rt}},[n]),w=d.useRef(null),H=d.useRef(null),z=d.useRef(null),W=d.useRef(t),L=d.useRef(e),b=d.useRef(t),C=d.useRef(e),N=d.useRef(r&&!s),F=d.useRef(i),q=d.useRef(V),y=d.useRef(!1),E=d.useRef(!1),P=d.useRef(null),G=d.useRef(!1),R=d.useCallback((x,S,D)=>{!(x!=null&&x.exportModeSnapshot)||!S||!D||Ki(S,D,x.exportModeSnapshot())},[]),X=d.useCallback(()=>a,[a]);zi(w,X),d.useEffect(()=>{W.current=t,L.current=e,E.current=!1},[t,e]),d.useEffect(()=>{N.current=r&&!s},[r,s]),d.useEffect(()=>{F.current=i},[i]),d.useEffect(()=>{q.current=V},[V]);const $=d.useCallback(x=>{if(!x||i!=="direct"||!N.current)return;const S=W.current,D=L.current;!S||!D||k(S,D,x,!1)},[i,k]),{pendingLocalSize:ee,scheduleResize:te,runPostSelectResize:M,setFitAddon:ie,setTerminal:B}=Ui({deviceId:t,paneId:e,deviceConnected:r,isSelectionInvalid:s,onResize:o,onSync:l,getContainerRect:()=>{const x=w.current;if(!x)return null;const S=x.getBoundingClientRect();return{width:S.width,height:S.height}}});d.useEffect(()=>{let x=!1,S=null;return(async()=>{if(await Xt(),x)return;const D=await Ii({...Gi,theme:q.current,disableStdin:F.current==="editor"});if(x){D.dispose();return}S=D,H.current&&D.open(H.current),qi(D),T(D)})(),()=>{x=!0,T(null),Qi(S),S==null||S.dispose()}},[]),d.useEffect(()=>{!a||!("setTheme"in a)||a.setTheme(V)},[a,V]),d.useEffect(()=>{!a||!("setDisableStdin"in a)||a.setDisableStdin(i==="editor")},[a,i]),d.useEffect(()=>{!a||i!=="direct"||window.innerWidth<768||"ontouchstart"in window||a.focus()},[a,i]);const j=d.useMemo(()=>a?{onResetTerminal:x=>{W.current===x&&(R(a,b.current,C.current),G.current=!0,a.reset(),y.current=!1,M())},onApplyHistory:(x,S,D)=>{var se;if(W.current!==x)return;const U=Xi(Vi(W.current,L.current),D);U&&((se=a.restoreModeSnapshot)==null||se.call(a,U));const Y=D?Bi(S):Bt(S);E.current=!0,a.write(Y),G.current=!1,b.current=W.current,C.current=L.current,R(a,W.current,L.current)},onFlushBuffer:(x,S)=>{if(W.current===x){for(const D of S){const U=Ct(D,y.current);y.current=U.endedWithCR,a.write(U.normalized)}E.current&&(a.buffer.active.baseY<=1&&a.scrollToTop(),E.current=!1),b.current=W.current,C.current=L.current,R(a,W.current,L.current)}},onOutput:(x,S,D)=>{if(W.current!==x||L.current!==S)return;const U=Ct(D,y.current);y.current=U.endedWithCR,a.write(U.normalized),E.current&&(a.buffer.active.baseY<=1&&a.scrollToTop(),E.current=!1),b.current=W.current,C.current=L.current,R(a,W.current,L.current)}}:{},[a,R,M]);d.useEffect(()=>{a?P.current!==a&&(y.current=!1,b.current=W.current,C.current=L.current,P.current=a):P.current=null},[a]),d.useEffect(()=>{if(!(!a||!t||!e))return()=>{if(G.current){G.current=!1;return}R(a,b.current,C.current)}},[t,a,e,R]),d.useEffect(()=>{at(j)},[j]),d.useEffect(()=>()=>{at({})},[]),d.useEffect(()=>{if(!a){z.current=null,ie(null),B(null);return}const x=new Hi;return a.loadAddon(x),z.current=x,ie(x),B(a),M(),()=>{try{x.dispose()}finally{z.current=null,ie(null),B(null)}}},[a,M,ie,B]),d.useEffect(()=>{const x=w.current;if(!x)return;let S=null;const D=new ResizeObserver(()=>{S!==null&&cancelAnimationFrame(S),S=requestAnimationFrame(()=>{S=null,te("resize")})});return D.observe(x),()=>{D.disconnect(),S!==null&&cancelAnimationFrame(S)}},[te]),d.useEffect(()=>{if(!a||!t||!e)return;const x=a.onData(S=>{!r||s||$(S)});return a.attachCustomKeyEventHandler(S=>!r||s||S.type!=="keydown"||i!=="direct"?!0:S.shiftKey&&S.key==="Enter"?(S.preventDefault(),$("\x1B[13;2u"),!1):!0),()=>{x.dispose(),a.attachCustomKeyEventHandler(()=>!0)}},[a,r,s,i,$,t,e]),d.useEffect(()=>{if(!(a!=null&&a.onLinkActivated))return;const x=a.onLinkActivated(S=>{window.open(S,"_blank","noopener,noreferrer")});return()=>x.dispose()},[a]),d.useEffect(()=>{if(!(a!=null&&a.onSelectionChange)){I(!1);return}const x=a.onSelectionChange(S=>{I(!!S)});return()=>{x.dispose(),I(!1)}},[a]);const O=d.useCallback(()=>{var S;if(!a)return;const x=((S=a.getSelection)==null?void 0:S.call(a))??"";x&&qt(x).then(()=>{ye.success(v("terminal.copied"))}).catch(()=>{ye.error(v("terminal.copyFailed"))}).finally(()=>{var D;(D=a.clearSelection)==null||D.call(a),a.focus()})},[a,v]),K=d.useCallback(()=>{var S;if(!a)return;((S=navigator.clipboard)!=null&&S.readText?navigator.clipboard.readText():Promise.reject(new Error("clipboard unavailable"))).then(D=>{var U;D&&a.paste(D),(U=a.clearSelection)==null||U.call(a),a.focus()}).catch(()=>{ye.error(v("terminal.pasteFailed"))})},[a,v]),oe=d.useCallback(()=>{var x;(x=a==null?void 0:a.clearSelection)==null||x.call(a),a==null||a.focus()},[a]);return d.useImperativeHandle(f,()=>({write:x=>a==null?void 0:a.write(x),reset:()=>{a==null||a.reset(),y.current=!1},scrollToBottom:()=>a==null?void 0:a.scrollToBottom(),resize:(x,S)=>a==null?void 0:a.resize(x,S),getTerminal:()=>a??null,getSize:()=>a?{cols:Math.max(2,a.cols),rows:Math.max(2,a.rows)}:null,runPostSelectResize:()=>M(),scheduleResize:(x,S)=>te(x,S),calculateSizeFromContainer:()=>{var Me,re,we,de,le,J,ge,ue,Se,Te,_e,Ae,De,ke,Ce,c;const x=w.current,S=a,D=z.current;if(!x||!S)return null;const U=x.getBoundingClientRect();if(U.width===0||U.height===0)return null;const Y=S._core;let se;if(D)try{const p=D.proposeDimensions();if(p)se=Math.max(2,p.cols);else{const g=((de=(we=(re=(Me=Y==null?void 0:Y._renderService)==null?void 0:Me.dimensions)==null?void 0:re.css)==null?void 0:we.cell)==null?void 0:de.width)??9;se=Math.max(2,Math.floor(U.width/g))}}catch{const p=((ue=(ge=(J=(le=Y==null?void 0:Y._renderService)==null?void 0:le.dimensions)==null?void 0:J.css)==null?void 0:ge.cell)==null?void 0:ue.width)??9;se=Math.max(2,Math.floor(U.width/p))}else{const p=((Ae=(_e=(Te=(Se=Y==null?void 0:Y._renderService)==null?void 0:Se.dimensions)==null?void 0:Te.css)==null?void 0:_e.cell)==null?void 0:Ae.width)??9;se=Math.max(2,Math.floor(U.width/p))}const me=((c=(Ce=(ke=(De=Y==null?void 0:Y._renderService)==null?void 0:De.dimensions)==null?void 0:ke.css)==null?void 0:Ce.cell)==null?void 0:c.height)??17,We=Math.max(2,Math.floor(U.height/me));return{cols:se,rows:We}},getPendingLocalSize:()=>ee.current}),[a,ee,M,te]),h.jsxs("div",{className:"flex h-full w-full flex-col",style:{backgroundColor:V.background},"data-terminal-engine":Nt,children:[h.jsxs("div",{ref:w,className:"relative min-h-0 w-full flex-1",children:[h.jsx("div",{ref:H,className:"absolute inset-0"}),h.jsx(Li,{visible:A,canPaste:i==="direct"&&r&&!s,onCopy:O,onPaste:K,onDismiss:oe})]}),u]})});Ot.displayName="Terminal";const Ji=1200,Zi=2e3;function fe(t,e){return!t||!e?!1:t.windowId===e.windowId&&t.paneId===e.paneId}function Pt(t,e){const n=t.filter(i=>e-i.at<Ji);return n.length===0?null:n.reduce((i,r)=>r.at>i.at?r:i)}function Re(t,e=Date.now()){return!t||e-t.at>Zi?null:t}function es(t){const e=t.now??Date.now(),n=Pt(t.recentSelectRequests,e);if(n&&!fe(n,t.activePaneFromEvent)||fe(t.currentRoute,t.activePaneFromEvent)||fe(t.lastHandledActive,t.activePaneFromEvent))return!0;const i=Re(t.pendingUserSelection,e);return!!(i&&!fe(i,t.activePaneFromEvent))}function ts(t){const e=t.now??Date.now(),n=Pt(t.recentSelectRequests,e),i=Re(t.pendingUserSelection,e);return!!(i&&!fe(i,t.snapshotActive)||n&&!fe(n,t.snapshotActive))}function ns(t){const e=t.now??Date.now(),n=Re(t.pendingUserSelection,e);return!(n&&fe(n,t.routeTarget)||t.snapshotActive&&fe(t.snapshotActive,t.routeTarget))}const is=[{key:"enter",label:"ENTER",payload:"\r"},{key:"ctrl-c",label:"CTRL-C",payload:""},{key:"ctrl-d",label:"CTRL-D",payload:""},{key:"up",label:"↑",payload:"\x1B[A"},{key:"down",label:"↓",payload:"\x1B[B"},{key:"left",label:"←",payload:"\x1B[D"},{key:"right",label:"→",payload:"\x1B[C"},{key:"shift-enter",label:"SHIFT+ENTER",payload:"\x1B[13;2u"},{key:"tab",label:"TAB",payload:" "},{key:"backspace",label:"BACKSPACE",payload:"\b"},{key:"esc",label:"ESC",payload:"\x1B"},{key:"delete",label:"DELETE",payload:""},{key:":",label:":",payload:":"},{key:"/",label:"/",payload:"/"},{key:"'",label:"'",payload:"'"},{key:'"',label:'"',payload:'"'},{key:"`",label:"`",payload:"`"}],Et=d.memo(function({onSend:e,onFocusEditor:n,disabled:i,isMobile:r,inputMode:s}){return h.jsx("div",{className:"terminal-shortcuts-strip","data-testid":"terminal-shortcuts-strip",children:h.jsx("div",{className:"shortcut-row flex items-center gap-1.5 py-2 overflow-x-auto scrollbar-thin","data-testid":"editor-shortcuts-row",children:is.map(o=>h.jsx(he,{variant:"ghost",size:"sm",className:"terminal-shortcut-btn h-7 min-w-9 px-2.5 rounded-full text-[11px] font-medium tracking-wide shrink-0 [@media(any-pointer:coarse)]:h-9 [@media(any-pointer:coarse)]:min-w-10 [@media(any-pointer:coarse)]:px-3",title:o.label,"aria-label":o.label,"data-testid":`editor-shortcut-${o.key}`,onMouseDown:l=>l.preventDefault(),onClick:()=>{e(o.payload),r&&s==="editor"&&(n==null||n())},disabled:i,children:o.label},o.key))})})});function ls(){var Ce;const{t}=Fe(),{deviceId:e,windowId:n,paneId:i}=nt(),r=Jt(),s=d.useRef(null),o=d.useRef(null),l=d.useRef(null),u=d.useRef(null),f=d.useRef(!1),a=d.useRef(!1),T=d.useRef(null),A=Q(c=>c.selectPane),I=Q(c=>e?c.snapshots[e]:void 0),k=Q(c=>{var p;return e?(p=c.deviceErrors)==null?void 0:p[e]:void 0}),v=Q(c=>{var p;return e?((p=c.deviceConnected)==null?void 0:p[e])??!1:!1}),V=_t(c=>{var p;return((p=c.settings)==null?void 0:p.siteName)??"tmex"}),w=d.useMemo(()=>it(i),[i]),H=d.useMemo(()=>e&&w?`${e}:${w}`:null,[e,w]),[z,W]=d.useState(!1),[L,b]=d.useState(""),C=d.useRef(!1),N=!v||!w,[F,q]=d.useState(!1),y=ae(c=>c.inputMode),E=ae(c=>c.theme),P=ae(c=>c.editorSendWithEnter),G=ae(c=>c.setEditorSendWithEnter),R=ae(c=>c.addEditorHistory),X=ae(c=>c.setEditorDraft),$=ae(c=>c.removeEditorDraft),ee=ae(c=>H?c.editorDrafts[H]??"":""),te=d.useMemo(()=>Zt(),[]),M=(Ce=I==null?void 0:I.session)==null?void 0:Ce.windows,ie=E==="light"?Mt:Rt,{data:B}=At({queryKey:["devices"],queryFn:async()=>{const c=await fetch("/api/devices");if(!c.ok)throw new Error("Failed to fetch devices");return c.json()},throwOnError:!1}),j=d.useMemo(()=>{if(e)return B==null?void 0:B.devices.find(c=>c.id===e)},[e,B==null?void 0:B.devices]),O=d.useMemo(()=>{if(!(!n||!M))return M.find(c=>c.id===n)},[n,M]),K=d.useMemo(()=>{if(!(!w||!O))return O.panes.find(c=>c.id===w)},[w,O]),oe=!!M,U=!!(oe&&!!n&&!O||oe&&!!n&&!!w&&!!O&&!K?t("wsError.checkGateway"):null),Y=!!(v&&w&&!U),se=d.useMemo(()=>{if(!O||!K)return null;const c=(j==null?void 0:j.name)??e;return Dt({paneIdx:K.index,windowIdx:O.index,paneTitle:K.title,windowName:O.name,windowCustomName:O.customName,deviceName:c})},[j==null?void 0:j.name,e,K,O]),me=d.useMemo(()=>{if(!M||M.length===0)return null;const c=M.find(g=>g.active),p=c==null?void 0:c.panes.find(g=>g.active);return!c||!p?null:{windowId:c.id,paneId:p.id}},[M]),We=d.useCallback((c,p)=>{!e||!w||Q.getState().resizePane(e,w,c,p)},[e,w]),Me=d.useCallback((c,p)=>{!e||!w||Q.getState().syncPaneSize(e,w,c,p)},[e,w]),re=d.useCallback((c,p)=>{const g=u.current,_=(g==null?void 0:g.calculateSizeFromContainer())??(g==null?void 0:g.getSize())??void 0;if(_)return _;if(!c||!p||!M)return;const Z=M.find(pe=>pe.id===c),ne=Z==null?void 0:Z.panes.find(pe=>pe.id===p);if(!(!ne||ne.width<=1||ne.height<=1))return{cols:ne.width,rows:ne.height}},[M]);d.useEffect(()=>{const c=()=>{W(window.innerWidth<768||"ontouchstart"in window)};return c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[]),d.useEffect(()=>{if(!z||!te||a.current)return;a.current=!0;const c=()=>{window.scrollTo(0,1)},p=window.requestAnimationFrame(c),g=window.setTimeout(c,120),_=window.setTimeout(c,420);return()=>{window.cancelAnimationFrame(p),window.clearTimeout(g),window.clearTimeout(_)}},[te,z]),d.useEffect(()=>{e&&(f.current=!1,ge.current=null,ue.current=null,T.current=null,de.current=[])},[e]),d.useEffect(()=>{v||(f.current=!1)},[v]),d.useEffect(()=>{if(!e||!v||!n||!M)return;if(M.length===0){r("/devices",{replace:!0});return}const c=M.find(g=>g.id===n);if(!c)return;if(!w){const g=c.panes.find(_=>_.active)??c.panes[0];g&&r(`/devices/${e}/windows/${n}/panes/${xe(g.id)}`,{replace:!0});return}if(!c.panes.find(g=>g.id===w)){const g=c.panes.find(_=>_.active)??c.panes[0];g&&r(`/devices/${e}/windows/${n}/panes/${xe(g.id)}`,{replace:!0});return}},[e,v,M,n,w,r]),d.useEffect(()=>{if(!e||!v||!M||M.length===0||n&&w||f.current)return;const c=M.find(g=>g.active)??M[0],p=c.panes.find(g=>g.active)??c.panes[0];p&&(f.current=!0,r(`/devices/${e}/windows/${c.id}/panes/${xe(p.id)}`,{replace:!0}))},[v,e,r,w,n,M]);const we=d.useRef(null);d.useEffect(()=>{we.current=null},[e,w]),d.useEffect(()=>{if(!e||!n||!w||N||!v)return;const c=`${e}:${n}:${w}`;if(we.current===c)return;we.current=c;const p=re(n,w);le(n,w),A(e,n,w,p)},[v,e,re,N,w,A,n]),d.useEffect(()=>{if(!e||!v||!n||!w)return;const c={windowId:n,paneId:w};ns({routeTarget:c,snapshotActive:me,pendingUserSelection:T.current})&&(T.current={windowId:c.windowId,paneId:c.paneId,at:Date.now()})},[v,e,w,me,n]);const de=d.useRef([]),le=d.useCallback((c,p)=>{const g=Date.now(),_=[...de.current.filter(Z=>g-Z.at<2e3),{windowId:c,paneId:p,at:g}];de.current=_.slice(-8)},[]),J=Q(c=>e?c.activePaneFromEvent[e]:void 0),ge=d.useRef(null);d.useEffect(()=>{if(!e||!v||!n||!w||!J)return;const c=Date.now(),p=Re(T.current,c);if(T.current=p,es({now:c,pendingUserSelection:p,activePaneFromEvent:J,currentRoute:{windowId:n,paneId:w},recentSelectRequests:de.current,lastHandledActive:ge.current}))return;ge.current={...J},p&&p.windowId===J.windowId&&p.paneId===J.paneId&&(T.current=null);const g=re(J.windowId,J.paneId);le(J.windowId,J.paneId),A(e,J.windowId,J.paneId,g),r(`/devices/${e}/windows/${J.windowId}/panes/${xe(J.paneId)}`,{replace:!0})},[e,v,n,w,J,le,re,A,r]);const ue=d.useRef(null);d.useEffect(()=>{if(!e||!v||!M||M.length===0)return;const c=de.current,p=M.find(je=>je.active);if(!p)return;const g=p.panes.find(je=>je.active);if(!g)return;const _={windowId:p.id,paneId:g.id},Z=Date.now(),ne=Re(T.current,Z);if(T.current=ne,ts({now:Z,pendingUserSelection:ne,snapshotActive:_,recentSelectRequests:c})||ue.current&&ue.current.windowId===_.windowId&&ue.current.paneId===_.paneId||(ue.current={..._},ne&&ne.windowId===_.windowId&&ne.paneId===_.paneId&&(T.current=null),n===_.windowId&&w===_.paneId))return;const pe=re(_.windowId,_.paneId);le(_.windowId,_.paneId),A(e,_.windowId,_.paneId,pe),r(`/devices/${e}/windows/${_.windowId}/panes/${xe(_.paneId)}`,{replace:!0})},[e,v,M,n,w,le,re,A,r]);const Se=Q(c=>e?c.pendingCreateWindowAt[e]:void 0);d.useEffect(()=>{if(!e||!v||!Se)return;const c=5e3,p=Date.now()-Se;if(p>c){Q.getState().clearPendingCreateWindow(e);return}if(!me){const Z=window.setTimeout(()=>{Q.getState().clearPendingCreateWindow(e)},c-p);return()=>window.clearTimeout(Z)}const g=me;if(n===g.windowId&&w===g.paneId){const Z=window.setTimeout(()=>{Q.getState().clearPendingCreateWindow(e)},c-p);return()=>window.clearTimeout(Z)}T.current={windowId:g.windowId,paneId:g.paneId,at:Date.now()};const _=re(g.windowId,g.paneId);le(g.windowId,g.paneId),A(e,g.windowId,g.paneId,_),r(`/devices/${e}/windows/${g.windowId}/panes/${xe(g.paneId)}`,{replace:!0}),Q.getState().clearPendingCreateWindow(e)},[e,v,Se,me,n,w,le,re,A,r]),d.useEffect(()=>{if(!Y||!K||N)return;const c=u.current,p=c==null?void 0:c.getTerminal();if(!p)return;const g=Math.max(2,Math.floor(K.width||0)),_=Math.max(2,Math.floor(K.height||0));if(!g||!_)return;const Z=Date.now(),ne={cols:g,rows:_},pe=(c==null?void 0:c.getPendingLocalSize())??null;Wi({now:Z,remoteSize:ne,pendingLocalSize:pe})&&(p.cols===g&&p.rows===_||p.resize(g,_))},[Y,N,K]),d.useEffect(()=>{const c=window.requestAnimationFrame(()=>{var g;(g=u.current)==null||g.scrollToBottom()}),p=window.setTimeout(()=>{var g;(g=u.current)==null||g.scrollToBottom()},120);return()=>{window.cancelAnimationFrame(c),window.clearTimeout(p)}},[y]),d.useEffect(()=>{k!=null&&k.message&&ye.error(k.message)},[k==null?void 0:k.message]),d.useEffect(()=>(document.title=en(se),()=>{document.title=V}),[V,se]),d.useEffect(()=>{const c=()=>{var p;(p=u.current)==null||p.scrollToBottom()};return window.addEventListener("tmex:jump-to-latest",c),()=>{window.removeEventListener("tmex:jump-to-latest",c)}},[]),d.useEffect(()=>{const c=p=>{const{deviceId:g,windowId:_,paneId:Z}=p.detail;g===e&&(T.current={windowId:_,paneId:Z,at:Date.now()})};return window.addEventListener("tmex:user-initiated-selection",c),()=>{window.removeEventListener("tmex:user-initiated-selection",c)}},[e]),d.useEffect(()=>{b(ee)},[ee]);const Te=d.useCallback(c=>{if(!e||!w||!Y)return;Q.getState().sendInput(e,w,c,!1)},[Y,e,w]),_e=d.useCallback(()=>{if(!Y){ye.error(t("wsError.checkGateway"));return}if(!e||!w||!L.trim())return;q(!0),window.setTimeout(()=>q(!1),150);const c=P?`${L}\r`:L;Q.getState().sendInput(e,w,c,!1),R(L),H&&$(H),b("")},[R,Y,e,H,P,L,$,w,t]),Ae=d.useCallback(()=>{if(!Y){ye.error(t("wsError.checkGateway"));return}if(!e||!w||!L.trim())return;q(!0),window.setTimeout(()=>q(!1),150);const c=L.split(/\r?\n/),p=Q.getState();for(const g of c)g.trim()&&p.sendInput(e,w,`${g}\r`,!1);R(L),H&&$(H),b("")},[R,Y,e,H,L,$,w,t]),De=d.useCallback(()=>{var c;(c=l.current)==null||c.focus({preventScroll:!0})},[]);if(!e)return h.jsx("div",{className:"flex h-full items-center justify-center p-4",children:h.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-3 text-sm text-muted-foreground",children:t("device.noDevices")})});const ke=!v&&!k;return h.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background","data-testid":"device-page",children:[h.jsxs("div",{className:`flex-1 relative overflow-hidden min-h-0 min-w-0 ${z&&y==="editor"?"pb-1":""}`,children:[h.jsx("div",{className:"h-full px-3 py-1 min-h-0 min-w-0 w-full relative flex rounded-xl",style:{backgroundColor:ie.background},children:v&&w?h.jsx("div",{ref:s,className:"flex-1 h-full min-h-0 w-full","data-virtual-keyboard-avoid":!0,children:h.jsx(Ot,{ref:u,deviceId:e,paneId:w,theme:E,inputMode:y,deviceConnected:v,isSelectionInvalid:U,onResize:We,onSync:Me,children:y==="direct"&&h.jsx(Et,{onSend:Te,disabled:!Y,isMobile:z,inputMode:y})},`${e}:${w}`)}):h.jsx("div",{className:"absolute inset-0 flex flex-col items-center justify-center p-8 text-center",children:h.jsx("div",{className:"max-w-sm space-y-4",children:v?n?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:h.jsx(Ue,{className:"h-6 w-6 text-muted-foreground animate-spin"})}),h.jsx("h3",{className:"text-lg font-medium",children:t("terminal.connecting")})]}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:h.jsx("span",{className:"text-2xl text-muted-foreground",children:"📋"})}),h.jsx("h3",{className:"text-lg font-medium",children:t("window.noWindowSelected")}),h.jsx("p",{className:"text-sm text-muted-foreground",children:t("window.selectWindowToStart")})]}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:h.jsx("span",{className:"text-2xl text-muted-foreground",children:"🔌"})}),h.jsx("h3",{className:"text-lg font-medium",children:t("device.disconnected")}),h.jsx("p",{className:"text-sm text-muted-foreground",children:t("device.connectToStart")})]})})})}),ke&&h.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/85 backdrop-blur-sm","data-testid":"terminal-status-overlay",children:h.jsxs("div",{className:"flex flex-col items-center gap-2 rounded-lg border border-border bg-card/90 px-4 py-3 shadow-sm",children:[h.jsx("div",{className:"h-7 w-7 rounded-full border-2 border-primary border-t-transparent animate-spin"}),h.jsx("span",{className:"text-xs text-muted-foreground","data-testid":"terminal-status-text",children:t("terminal.connecting")})]})})]}),y==="editor"&&h.jsxs("div",{ref:o,"data-virtual-keyboard-avoid":!0,className:"editor-mode-input bg-card/85 backdrop-blur-sm",children:[z&&h.jsx(Et,{onSend:Te,onFocusEditor:De,disabled:!Y,isMobile:z,inputMode:y}),h.jsx("textarea",{ref:l,"data-testid":"editor-input",className:"min-h-[88px] max-h-[28vh] w-full resize-y rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground shadow-xs outline-none transition-colors focus:border-ring",value:L,onChange:c=>{const p=c.target.value;if(b(p),!!H){if(p){X(H,p);return}$(H)}},placeholder:t("terminal.inputPlaceholder"),onCompositionStart:()=>{C.current=!0},onCompositionEnd:()=>{C.current=!1}}),h.jsx("div",{className:"actions mt-2",children:h.jsxs("div",{className:"send-row flex flex-wrap items-center justify-end gap-2","data-testid":"editor-send-row",children:[h.jsxs("div",{className:"send-with-enter-toggle mr-auto flex items-center gap-2 text-xs text-muted-foreground","data-testid":"editor-send-with-enter-toggle",children:[h.jsx(tn,{size:"sm",checked:P,onCheckedChange:c=>G(!!c)}),h.jsx("span",{children:t("terminal.editorSendWithEnter")})]}),h.jsxs(he,{variant:"outline",size:"sm","data-testid":"editor-clear",onMouseDown:c=>c.preventDefault(),onClick:()=>{var c;b(""),H&&$(H),z&&y==="editor"&&((c=l.current)==null||c.focus({preventScroll:!0}))},title:t("terminal.clear"),children:[h.jsx(nn,{className:"h-4 w-4"}),t("terminal.clear")]}),h.jsxs(he,{variant:"secondary",size:"sm","data-testid":"editor-send-line-by-line",onMouseDown:c=>c.preventDefault(),onClick:()=>{var c;Ae(),z&&y==="editor"&&((c=l.current)==null||c.focus({preventScroll:!0}))},disabled:!Y||F,children:[F?h.jsx(Ue,{className:"h-4 w-4 animate-spin"}):h.jsx(ct,{className:"h-4 w-4"}),t("terminal.editorSendLineByLine")]}),h.jsxs(he,{variant:"default",size:"sm","data-testid":"editor-send",onMouseDown:c=>c.preventDefault(),onClick:()=>{var c;_e(),z&&y==="editor"&&((c=l.current)==null||c.focus({preventScroll:!0}))},disabled:!Y||F,children:[F?h.jsx(Ue,{className:"h-4 w-4 animate-spin"}):h.jsx(ct,{className:"h-4 w-4"}),t("common.send")]})]})})]})]})}function as(){const{deviceId:t,windowId:e,paneId:n}=nt(),i=n?it(n):void 0,r=Q(a=>a.snapshots),s=_t(a=>{var T;return((T=a.settings)==null?void 0:T.siteName)??"tmex"}),o=t?r[t]:void 0,l=d.useMemo(()=>{var a;if(!(!e||!((a=o==null?void 0:o.session)!=null&&a.windows)))return o.session.windows.find(T=>T.id===e)},[e,o]),u=d.useMemo(()=>{if(!(!i||!l))return l.panes.find(a=>a.id===i)},[i,l]),f=d.useMemo(()=>l&&u?Dt({paneIdx:u.index,windowIdx:l.index,paneTitle:u.title,windowName:l.name,windowCustomName:l.customName,deviceName:s}):t??"",[l,u,s,t]);return h.jsx(h.Fragment,{children:f})}function cs(){const{t}=Fe(),{deviceId:e,paneId:n}=nt(),i=n?it(n):void 0,r=ae(H=>H.inputMode),s=ae(H=>H.setInputMode),o=Q(H=>{var z;return e?((z=H.deviceConnected)==null?void 0:z[e])??!1:!1}),[l,u]=d.useState(!1),[f,a]=d.useState(!1),T=!!(i&&o),I=(At({queryKey:wn(e??"",i??""),queryFn:()=>pn(e??"",i??""),enabled:!!(e&&i),throwOnError:!1}).data??[]).some(H=>H.enabled),k=()=>{s(r==="direct"?"editor":"direct")},v=()=>{window.dispatchEvent(new CustomEvent("tmex:jump-to-latest"))},V=()=>{u(!0)},w=()=>{window.location.reload()};return h.jsxs(h.Fragment,{children:[h.jsx(he,{variant:"ghost",size:"icon-sm",onClick:V,"aria-label":t("nav.refreshPage"),title:t("nav.refreshPage"),children:h.jsx(gn,{className:"h-4 w-4"})}),h.jsx(he,{variant:"ghost",size:"icon-sm",onClick:k,disabled:!T,"data-testid":"terminal-input-mode-toggle","aria-label":t(r==="direct"?"nav.switchToEditor":"nav.switchToDirect"),title:t(r==="direct"?"nav.switchToEditor":"nav.switchToDirect"),children:r==="direct"?h.jsx(sn,{className:"h-4 w-4"}):h.jsx(Cn,{className:"h-4 w-4"})}),h.jsx(he,{variant:"ghost",size:"icon-sm",onClick:v,disabled:!T,"aria-label":t("nav.jumpToLatest"),title:t("nav.jumpToLatest"),children:h.jsx(xn,{className:"h-4 w-4"})}),h.jsxs(he,{variant:"ghost",size:"icon-sm",className:"relative",onClick:()=>a(!0),disabled:!i,"data-testid":"watch-open-button","aria-label":t("watch.title"),title:t("watch.title"),children:[h.jsx(rn,{className:"h-4 w-4"}),I&&h.jsx("span",{className:"absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-primary","data-testid":"watch-active-indicator"})]}),e&&i&&h.jsx(on,{open:f,onOpenChange:a,deviceId:e,paneId:i}),h.jsx(ln,{open:l,onOpenChange:u,children:h.jsxs(an,{children:[h.jsxs(cn,{children:[h.jsx(dn,{children:t("nav.refreshPage")}),h.jsx(un,{children:t("nav.refreshPageConfirm")})]}),h.jsxs(hn,{children:[h.jsx(fn,{onClick:()=>u(!1),children:t("common.cancel")}),h.jsx(mn,{onClick:w,children:t("common.confirm")})]})]})})]})}export{cs as PageActions,as as PageTitle,ls as default};
|
|
21
|
-
//# sourceMappingURL=DevicePage-B2xsa-ys.js.map
|