tmex-cli 0.4.1 → 0.4.3
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/dist/runtime/server.js +414 -88
- package/package.json +1 -1
- package/resources/fe-dist/assets/DevicePage-B9rZioAr.js +26 -0
- package/resources/fe-dist/assets/{DevicePage-n4JoyDed.js.map → DevicePage-B9rZioAr.js.map} +1 -1
- package/resources/fe-dist/assets/DevicesPage-Bco831ry.js +17 -0
- package/resources/fe-dist/assets/DevicesPage-Bco831ry.js.map +1 -0
- package/resources/fe-dist/assets/SettingsPage-BRs8Unfx.js +17 -0
- package/resources/fe-dist/assets/{SettingsPage-hS99lHcp.js.map → SettingsPage-BRs8Unfx.js.map} +1 -1
- package/resources/fe-dist/assets/index-40zyi_9K.css +1 -0
- package/resources/fe-dist/assets/index-BhBqXsZI.js +215 -0
- package/resources/fe-dist/assets/index-BhBqXsZI.js.map +1 -0
- package/resources/fe-dist/assets/select-D70hG6p7.js +17 -0
- package/resources/fe-dist/assets/{select-DGBwxGiK.js.map → select-D70hG6p7.js.map} +1 -1
- package/resources/fe-dist/assets/switch-DsyIGzyC.js +12 -0
- package/resources/fe-dist/assets/{switch-CWUBjs7N.js.map → switch-DsyIGzyC.js.map} +1 -1
- package/resources/fe-dist/assets/useValueChanged-CBb-JR7o.js +7 -0
- package/resources/fe-dist/assets/{useValueChanged-DwJ_SDCu.js.map → useValueChanged-CBb-JR7o.js.map} +1 -1
- package/resources/fe-dist/index.html +2 -2
- package/resources/gateway-drizzle/0003_glamorous_lizard.sql +1 -0
- package/resources/gateway-drizzle/meta/0003_snapshot.json +542 -0
- package/resources/gateway-drizzle/meta/_journal.json +7 -0
- package/resources/fe-dist/assets/DevicePage-n4JoyDed.js +0 -26
- package/resources/fe-dist/assets/DevicesPage-BwLKaiUR.js +0 -17
- package/resources/fe-dist/assets/DevicesPage-BwLKaiUR.js.map +0 -1
- package/resources/fe-dist/assets/SettingsPage-hS99lHcp.js +0 -17
- package/resources/fe-dist/assets/index-CJaX5rlK.css +0 -1
- package/resources/fe-dist/assets/index-CJyFlAt8.js +0 -449
- package/resources/fe-dist/assets/index-CJyFlAt8.js.map +0 -1
- package/resources/fe-dist/assets/select-DGBwxGiK.js +0 -17
- package/resources/fe-dist/assets/switch-CWUBjs7N.js +0 -12
- package/resources/fe-dist/assets/useValueChanged-DwJ_SDCu.js +0 -7
package/package.json
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var Xt=Object.defineProperty;var Jt=(n,e,t)=>e in n?Xt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var w=(n,e,t)=>Jt(n,typeof e!="symbol"?e+"":e,t);import{c as Fe,r as d,aN as j,by as ut,j as m,b as st,u as Dt,bz as rt,bA as Qt,bB as it,d as ue,e as Zt,bC as ge,f as Ke,B as we}from"./index-BhBqXsZI.js";import{T as en,A as tn,a as nn,b as sn,c as rn,d as on,e as ln,f as an,g as cn}from"./useValueChanged-CBb-JR7o.js";import{L as We,S as dn,a as ht}from"./switch-DsyIGzyC.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 un=[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]],hn=Fe("arrow-down-to-line",un);/**
|
|
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 fn=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],mn=Fe("keyboard",fn);/**
|
|
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 pn=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],wn=Fe("refresh-cw",pn);/**
|
|
17
|
+
* @license lucide-react v0.564.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const gn=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],yn=Fe("smartphone",gn);function Sn(n){return`rgb(${n.r} ${n.g} ${n.b})`}function je(n){const e=n.getContext("2d");if(!e)throw new Error("2d canvas context unavailable");return e}class _n{constructor(e){w(this,"kind","canvas");w(this,"mainCanvas");w(this,"selectionCanvas");w(this,"cursorCanvas");w(this,"mainContext");w(this,"selectionContext");w(this,"cursorContext");w(this,"theme");w(this,"fontFamily");w(this,"fontSize");w(this,"cellDimensions",{width:9,height:17});w(this,"cols",0);w(this,"rows",0);w(this,"lastCursor",null);w(this,"frameCount",0);w(this,"lastDrawnRows",[]);w(this,"colorCache",new Map);w(this,"fontCache",new Map);w(this,"cursorBlinkVisible",!0);w(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[t,s]of[[this.mainCanvas,"main"],[this.selectionCanvas,"selection"],[this.cursorCanvas,"cursor"]])t.dataset.layer=s,t.style.position="absolute",t.style.inset="0",t.style.width="100%",t.style.height="100%",t.style.pointerEvents="none",e.screenElement.appendChild(t);this.mainContext=je(this.mainCanvas),this.selectionContext=je(this.selectionCanvas),this.cursorContext=je(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 s=e.meta.dirty==="full"?e.rows:e.rows.filter(r=>r.dirty);for(const r of s)this.drawRow(r,e.meta.colors),this.lastDrawnRows.push(r.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,t){const s=Math.max(1,e),r=Math.max(1,t),i=s*this.cellDimensions.width,o=r*this.cellDimensions.height,l=Math.max(1,globalThis.devicePixelRatio??1);if(this.cols===s&&this.rows===r){const u=`${i}px`,c=`${o}px`;if(this.mainCanvas.style.width===u&&this.mainCanvas.style.height===c)return}this.cols=s,this.rows=r;for(const u of[this.mainCanvas,this.selectionCanvas,this.cursorCanvas])u.width=Math.max(1,Math.ceil(i*l)),u.height=Math.max(1,Math.ceil(o*l)),u.style.width=`${i}px`,u.style.height=`${o}px`;for(const u of[this.mainContext,this.selectionContext,this.cursorContext])u.setTransform(l,0,0,l,0,0),u.textBaseline="top",u.imageSmoothingEnabled=!1}drawSelection(e,t){if(this.selectionContext.clearRect(0,0,this.cols*this.cellDimensions.width,this.rows*this.cellDimensions.height),e.length!==0){this.selectionContext.fillStyle=t;for(const s of e)this.selectionContext.fillRect(s.x*this.cellDimensions.width,s.row*this.cellDimensions.height,s.width*this.cellDimensions.width,this.cellDimensions.height)}}drawRow(e,t){const s=e.y*this.cellDimensions.height,r=this.cols*this.cellDimensions.width,i=this.toCss(t.background);this.mainContext.clearRect(0,s,r,this.cellDimensions.height),this.mainContext.fillStyle=i,this.mainContext.fillRect(0,s,r,this.cellDimensions.height);for(const o of e.cells){if(o.widthKind==="spacer-tail"||o.widthKind==="spacer-head")continue;const l=o.x*this.cellDimensions.width,u=o.style.inverse?o.fgColor??t.foreground:o.bgColor??t.background,c=o.style.inverse?o.bgColor??t.background:o.fgColor??t.foreground,y=o.widthKind==="wide"?this.cellDimensions.width*2:this.cellDimensions.width;(u.r!==t.background.r||u.g!==t.background.g||u.b!==t.background.b)&&(this.mainContext.fillStyle=this.toCss(u),this.mainContext.fillRect(l,s,y,this.cellDimensions.height)),!(!o.text||o.style.invisible)&&(this.mainContext.font=this.resolveFont(o.style),this.mainContext.fillStyle=this.toCss(c),this.mainContext.fillText(o.text,l,s),o.style.underline>0&&this.mainContext.fillRect(l,s+this.cellDimensions.height-2,Math.max(y-1,1),1),o.style.strikethrough&&this.mainContext.fillRect(l,s+this.cellDimensions.height*.55,Math.max(y-1,1),1),o.style.overline&&this.mainContext.fillRect(l,s+1,Math.max(y-1,1),1))}}drawCursor(e){const t=e.colors,s=e.cursor,r=this.lastCursor;if(this.cursorContext.clearRect(0,0,this.cols*this.cellDimensions.width,this.rows*this.cellDimensions.height),!s.visible||s.x===null||s.y===null){this.lastCursor=null,this.stopCursorBlink();return}const i=s.x*this.cellDimensions.width,o=s.y*this.cellDimensions.height,l=s.wideTail?this.cellDimensions.width*2:this.cellDimensions.width,u=t.cursor??t.foreground,c=this.toCss(u);this.cursorContext.fillStyle=c,this.cursorContext.strokeStyle=c,this.cursorContext.globalAlpha=.7,this.cursorContext.fillRect(i,o+this.cellDimensions.height-2,Math.max(l-1,1),2),this.cursorContext.globalAlpha=1,this.startCursorBlink(),this.lastCursor={x:s.x,y:s.y,style:s.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 t=[e.italic?"italic":"normal",e.bold?"700":"400",`${this.fontSize}px`,this.fontFamily].join("|"),s=this.fontCache.get(t);if(s)return s;const r=`${e.italic?"italic ":""}${e.bold?"700 ":""}${this.fontSize}px ${this.fontFamily}`;return this.fontCache.set(t,r),r}toCss(e){const t=`${e.r},${e.g},${e.b}`,s=this.colorCache.get(t);if(s)return s;const r=Sn(e);return this.colorCache.set(t,r),r}}const Tn=0,bn={Backquote:1,Backslash:2,BracketLeft:3,BracketRight:4,Comma:5,Digit0:6,Digit1:7,Digit2:8,Digit3:9,Digit4:10,Digit5:11,Digit6:12,Digit7:13,Digit8:14,Digit9:15,Equal:16,IntlBackslash:17,IntlRo:18,IntlYen:19,KeyA:20,KeyB:21,KeyC:22,KeyD:23,KeyE:24,KeyF:25,KeyG:26,KeyH:27,KeyI:28,KeyJ:29,KeyK:30,KeyL:31,KeyM:32,KeyN:33,KeyO:34,KeyP:35,KeyQ:36,KeyR:37,KeyS:38,KeyT:39,KeyU:40,KeyV:41,KeyW:42,KeyX:43,KeyY:44,KeyZ:45,Minus:46,Period:47,Quote:48,Semicolon:49,Slash:50,AltLeft:51,AltRight:52,Backspace:53,CapsLock:54,ContextMenu:55,ControlLeft:56,ControlRight:57,Enter:58,MetaLeft:59,MetaRight:60,ShiftLeft:61,ShiftRight:62,Space:63,Tab:64,Convert:65,KanaMode:66,NonConvert:67,Delete:68,End:69,Help:70,Home:71,Insert:72,PageDown:73,PageUp:74,ArrowDown:75,ArrowLeft:76,ArrowRight:77,ArrowUp:78,NumLock:79,Numpad0:80,Numpad1:81,Numpad2:82,Numpad3:83,Numpad4:84,Numpad5:85,Numpad6:86,Numpad7:87,Numpad8:88,Numpad9:89,NumpadAdd:90,NumpadBackspace:91,NumpadClear:92,NumpadClearEntry:93,NumpadComma:94,NumpadDecimal:95,NumpadDivide:96,NumpadEnter:97,NumpadEqual:98,NumpadMemoryAdd:99,NumpadMemoryClear:100,NumpadMemoryRecall:101,NumpadMemoryStore:102,NumpadMemorySubtract:103,NumpadMultiply:104,NumpadParenLeft:105,NumpadParenRight:106,NumpadSubtract:107,NumpadSeparator:108,NumpadUp:109,NumpadDown:110,NumpadRight:111,NumpadLeft:112,NumpadBegin:113,NumpadHome:114,NumpadEnd:115,NumpadInsert:116,NumpadDelete:117,NumpadPageUp:118,NumpadPageDown:119,Escape:120,F1:121,F2:122,F3:123,F4:124,F5:125,F6:126,F7:127,F8:128,F9:129,F10:130,F11:131,F12:132,F13:133,F14:134,F15:135,F16:136,F17:137,F18:138,F19:139,F20:140,F21:141,F22:142,F23:143,F24:144,F25:145,Fn:146,FnLock:147,PrintScreen:148,ScrollLock:149,Pause:150,BrowserBack:151,BrowserFavorites:152,BrowserForward:153,BrowserHome:154,BrowserRefresh:155,BrowserSearch:156,BrowserStop:157,Eject:158,LaunchApp1:159,LaunchApp2:160,LaunchMail:161,MediaPlayPause:162,MediaSelect:163,MediaStop:164,MediaTrackNext:165,MediaTrackPrevious:166,Power:167,Sleep:168,AudioVolumeDown:169,AudioVolumeMute:170,AudioVolumeUp:171,WakeUp:172,Copy:173,Cut:174,Paste:175},ot={Backquote:"`",Backslash:"\\",BracketLeft:"[",BracketRight:"]",Comma:",",Equal:"=",Minus:"-",Period:".",Quote:"'",Semicolon:";",Slash:"/",Space:" ",IntlBackslash:"\\",IntlYen:"¥",IntlRo:"\\"};for(let n=0;n<=9;n+=1)ot[`Digit${n}`]=String(n);for(let n=0;n<26;n+=1){const e=String.fromCharCode(65+n),t=String.fromCharCode(97+n);ot[`Key${e}`]=t}function ft(n){return bn[n]??Tn}function xn(n){const e=ot[n];return e?e.codePointAt(0)??null:null}const ye=0,En=-2,Rn=1,Cn=2,vn=3,Mn=10,Dn=11,An=12,On=13,kn=14,In=15,Bn=16,Hn=17,Pn=1,Ln=2,Nn=1,Fn=2,Gn=3,Un=4,zn=5,Yn=6,Vn=1,$n=2,Kn=3,Wn=4;function lt(n){if(n.disposed||n.renderStateHandle===0)throw new Error("render state resources already disposed")}function jn(n){switch(n){case 2:return"full";case 1:return"partial";default:return"clean"}}function qn(n){switch(n){case 0:return"bar";case 2:return"underline";case 3:return"block-hollow";default:return"block"}}function Xn(n){switch(n){case 1:return"wide";case 2:return"spacer-tail";case 3:return"spacer-head";default:return"narrow"}}function Ee(n,e){return{r:n.view().getUint8(e),g:n.view().getUint8(e+1),b:n.view().getUint8(e+2)}}function mt(n,e){const t=n.bindings.allocStruct("GhosttyColorRgb");try{const s=e(t.ptr);if(s===En)return null;if(s!==ye)throw new Error(`ghostty optional color read failed with result ${s}`);return Ee(n.bindings,t.ptr)}finally{t.free()}}function fe(n,e){const t=n.bindings.allocU8();try{const s=e(t);if(typeof s=="number"&&s!==ye)throw new Error(`ghostty bool read failed with result ${s}`);return n.bindings.readU8(t)!==0}finally{n.bindings.freeU8(t)}}function De(n,e){const t=n.bindings.allocBytes(2);try{const s=e(t);if(typeof s=="number"&&s!==ye)throw new Error(`ghostty u16 read failed with result ${s}`);return n.bindings.view().getUint16(t,!0)}finally{n.bindings.freeBytes(t,2)}}function Jn(n,e){const t=n.bindings.allocBytes(4);try{const s=e(t);if(typeof s=="number"&&s!==ye)throw new Error(`ghostty u32 read failed with result ${s}`);return n.bindings.view().getUint32(t,!0)}finally{n.bindings.freeBytes(t,4)}}function et(n,e){const t=n.bindings.allocBytes(4);try{const s=e(t);if(typeof s=="number"&&s!==ye)throw new Error(`ghostty enum read failed with result ${s}`);return n.bindings.view().getInt32(t,!0)}finally{n.bindings.freeBytes(t,4)}}function pt(n,e){const t=n.bindings.allocBytes(8);try{const s=e(t);if(typeof s=="number"&&s!==ye)throw new Error(`ghostty u64 read failed with result ${s}`);return n.bindings.readU64(t)}finally{n.bindings.freeBytes(t,8)}}function Qn(n){const e=n.bindings.allocStruct("GhosttyStyle");try{n.bindings.setField(e.view,"GhosttyStyle","size",n.bindings.typeSize("GhosttyStyle")),n.bindings.getRenderStateRowCellValue(n.rowCellsHandle,Fn,e.ptr);const t=s=>n.bindings.field("GhosttyStyle",s).offset;return{bold:e.view.getUint8(t("bold"))!==0,italic:e.view.getUint8(t("italic"))!==0,faint:e.view.getUint8(t("faint"))!==0,blink:e.view.getUint8(t("blink"))!==0,inverse:e.view.getUint8(t("inverse"))!==0,invisible:e.view.getUint8(t("invisible"))!==0,strikethrough:e.view.getUint8(t("strikethrough"))!==0,overline:e.view.getUint8(t("overline"))!==0,underline:e.view.getInt32(t("underline"),!0)}}finally{e.free()}}function Zn(n){const e=Jn(n,s=>n.bindings.getRenderStateRowCellValueResult(n.rowCellsHandle,Gn,s));if(e===0)return[];const t=n.bindings.allocBytes(e*4);try{n.bindings.getRenderStateRowCellValue(n.rowCellsHandle,Un,t);const s=[];for(let r=0;r<e;r+=1)s.push(n.bindings.view().getUint32(t+r*4,!0));return s}finally{n.bindings.freeBytes(t,e*4)}}function es(n){if(n.length===0)return"";try{return String.fromCodePoint(...n)}catch{return""}}function ts(n){let e="";for(const t of n)if(!(t.widthKind==="spacer-tail"||t.widthKind==="spacer-head")){if(t.text){e+=t.text;continue}t.widthKind==="narrow"&&(e+=" ")}return e}function ns(n){const e=n.bindings.allocStruct("GhosttyRenderStateColors");try{n.bindings.setField(e.view,"GhosttyRenderStateColors","size",n.bindings.typeSize("GhosttyRenderStateColors")),n.bindings.getRenderStateColors(n.renderStateHandle,e.ptr);const t=n.bindings.field("GhosttyRenderStateColors","palette").offset,s=[];for(let o=0;o<256;o+=1){const l=e.ptr+t+o*3;s.push(Ee(n.bindings,l))}const r=e.view.getUint8(n.bindings.field("GhosttyRenderStateColors","cursor_has_value").offset)!==0,i=fe(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,kn,o));return{cols:De(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,Rn,o)),rows:De(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,Cn,o)),dirty:jn(et(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,vn,o))),colors:{background:Ee(n.bindings,e.ptr+n.bindings.field("GhosttyRenderStateColors","background").offset),foreground:Ee(n.bindings,e.ptr+n.bindings.field("GhosttyRenderStateColors","foreground").offset),cursor:r?Ee(n.bindings,e.ptr+n.bindings.field("GhosttyRenderStateColors","cursor").offset):null,palette:s},cursor:{style:qn(et(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,Mn,o))),visible:fe(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,Dn,o)),blinking:fe(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,An,o)),passwordInput:fe(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,On,o)),x:i?De(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,In,o)):null,y:i?De(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,Bn,o)):null,wideTail:i?fe(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,Hn,o)):!1}}}finally{e.free()}}function ss(n,e){const t=pt(n,i=>n.bindings.getRenderStateRowValueResult(n.rowIteratorHandle,Ln,i));n.bindings.bindRenderStateRowCells(n.rowIteratorHandle,n.rowCellsHandle);const s=[];let r=0;for(;n.bindings.nextRenderStateRowCell(n.rowCellsHandle);){const i=pt(n,c=>n.bindings.getRenderStateRowCellValueResult(n.rowCellsHandle,Nn,c)),o=Zn(n),l=Xn(et(n,c=>n.bindings.getRawCellValueResult(i,Kn,c))),u={x:r,text:es(o),codepoints:o,widthKind:l,hasText:fe(n,c=>n.bindings.getRawCellValueResult(i,Wn,c)),style:Qn(n),fgColor:mt(n,c=>n.bindings.getRenderStateRowCellValueResult(n.rowCellsHandle,Yn,c)),bgColor:mt(n,c=>n.bindings.getRenderStateRowCellValueResult(n.rowCellsHandle,zn,c))};s.push(u),r+=1}return{y:e,dirty:fe(n,i=>n.bindings.getRenderStateRowValueResult(n.rowIteratorHandle,Pn,i)),wrap:fe(n,i=>n.bindings.getRawRowValueResult(t,Vn,i)),wrapContinuation:fe(n,i=>n.bindings.getRawRowValueResult(t,$n,i)),text:ts(s),cells:s}}function wt(n){return{bindings:n,renderStateHandle:n.createRenderState(),rowIteratorHandle:n.createRenderStateRowIterator(),rowCellsHandle:n.createRenderStateRowCells(),snapshotVersion:0,disposed:!1,cachedMeta:null}}function gt(n,e){lt(n),n.bindings.updateRenderState(n.renderStateHandle,e),n.bindings.bindRenderStateRowIterator(n.renderStateHandle,n.rowIteratorHandle),n.snapshotVersion+=1,n.cachedMeta=null}function tt(n){return lt(n),n.cachedMeta||(n.cachedMeta=ns(n)),n.cachedMeta}function*rs(n){lt(n);const e=tt(n);n.bindings.bindRenderStateRowIterator(n.renderStateHandle,n.rowIteratorHandle);let t=0;for(;t<e.rows&&n.bindings.nextRenderStateRowIterator(n.rowIteratorHandle);)yield ss(n,t),t+=1}function qe(n){n.disposed||(n.disposed=!0,n.rowCellsHandle!==0&&(n.bindings.freeRenderStateRowCells(n.rowCellsHandle),n.rowCellsHandle=0),n.rowIteratorHandle!==0&&(n.bindings.freeRenderStateRowIterator(n.rowIteratorHandle),n.rowIteratorHandle=0),n.renderStateHandle!==0&&(n.bindings.freeRenderState(n.renderStateHandle),n.renderStateHandle=0),n.cachedMeta=null)}function at(n,e){return Math.max(0,Math.min(Math.max(n.length-1,0),Math.floor(e)))}function is(n,e){return n.line<e.line?{start:n,end:e}:n.line>e.line?{start:e,end:n}:n.col<=e.col?{start:n,end:e}:{start:e,end:n}}function os(n,e,t){if(!t)return{start:{line:n,col:0},end:{line:n,col:0}};const s=at(t,e),r=u=>/[\p{L}\p{N}_-]/u.test(u),i=t[s]??"";if(!r(i))return{start:{line:n,col:s},end:{line:n,col:s}};let o=s,l=s;for(;o>0&&r(t[o-1]??"");)o-=1;for(;l+1<t.length&&r(t[l+1]??"");)l+=1;return{start:{line:n,col:o},end:{line:n,col:l}}}function At(n,e){const t=Math.max(e.length-1,0);return{start:{line:n,col:0},end:{line:n,col:t}}}function Ot(n,e,t){const s=t(n.line);switch(e){case"word":return os(n.line,n.col,s);case"line":return At(n.line,s);default:{const r=at(s,n.col);return{start:{line:n.line,col:r},end:{line:n.line,col:r}}}}}function kt(){return{anchor:null,focus:null,mode:"character"}}function ls(n){return!!(n.anchor&&n.focus)}function as(){return kt()}function cs(n,e,t){const s=Ot(e,e.mode,t);return{anchor:s.start,focus:s.end,mode:e.mode}}function yt(n,e,t){return n.anchor?n.mode==="line"?{...n,focus:At(e.line,t(e.line)).end}:n.mode==="word"?{...n,focus:Ot(e,"word",t).end}:{...n,focus:{line:e.line,col:at(t(e.line),e.col)}}:n}function It(n){return!n.anchor||!n.focus?null:is(n.anchor,n.focus)}function ds(n,e){const t=It(n);if(!t)return null;const s=[];for(let r=t.start.line;r<=t.end.line;r+=1){const i=e(r);if(r===t.start.line&&r===t.end.line){s.push(i.slice(t.start.col,t.end.col+1));continue}if(r===t.start.line){s.push(i.slice(t.start.col));continue}if(r===t.end.line){s.push(i.slice(0,t.end.col+1));continue}s.push(i)}return s.join(`
|
|
22
|
+
`)}function us(n,e,t,s){const r=It(n);if(!r)return[];const i=e+t-1,o=[];for(let l=Math.max(r.start.line,e);l<=Math.min(r.end.line,i);l+=1){const u=l-e;if(l===r.start.line&&l===r.end.line){o.push({row:u,x:r.start.col,width:r.end.col-r.start.col+1});continue}if(l===r.start.line){const y=s?Math.max(s(l).length-r.start.col,0):Number.MAX_SAFE_INTEGER;o.push({row:u,x:r.start.col,width:y});continue}if(l===r.end.line){o.push({row:u,x:0,width:r.end.col+1});continue}const c=s?s(l).length:Number.MAX_SAFE_INTEGER;o.push({row:u,x:0,width:c})}return o}function hs(n){return(n.metaKey||n.ctrlKey)&&!n.altKey}function fs(n){return hs(n)&&n.key.toLowerCase()==="c"}async function ms(n){var e;n&&typeof navigator<"u"&&(e=navigator.clipboard)!=null&&e.writeText&&await navigator.clipboard.writeText(n)}function ps(n,e){return!e||!n.clipboardData?!1:(n.clipboardData.setData("text/plain",e),n.preventDefault(),!0)}const ws="/assets/ghostty-vt-BKQMf-5X.wasm",Be=0,St=-3,gs=11,ys=12,Ss=13,_s=14,Ts=1,bs=2,xs=9,Es=1,Rs=0,Cs=1,vs=2,Ms=0,Ds=1,As=2,Os=4,ks=2004,Is=9,Bs=1e3,Hs=1002,Ps=1003,Ls=1005,_t=1006,Ns=1015,Tt=1016;let Xe=null;function I(n,e){if(n!==Be)throw new Error(`${e} failed with result ${n}`)}function Bt(n){const e=n.trim().replace(/^#/,"");if(e.length!==6)throw new Error(`expected #RRGGBB color, received: ${n}`);return[Number.parseInt(e.slice(0,2),16),Number.parseInt(e.slice(2,4),16),Number.parseInt(e.slice(4,6),16)]}function Fs(n){const t=[...[n.black,n.red,n.green,n.yellow,n.blue,n.magenta,n.cyan,n.white,n.brightBlack,n.brightRed,n.brightGreen,n.brightYellow,n.brightBlue,n.brightMagenta,n.brightCyan,n.brightWhite].map(Bt)],s=[0,95,135,175,215,255];for(const r of s)for(const i of s)for(const o of s)t.push([r,i,o]);for(let r=0;r<24;r+=1){const i=8+r*10;t.push([i,i,i])}return t}function Gs(n){let e=0;return n&1&&(e+=4),n&4&&(e+=8),n&2&&(e+=16),e}function Je(n){return n<0||n>223?null:String.fromCharCode(n+32)}function Us(n){switch(n){case 1:return 0;case 3:return 1;case 2:return 2;case 4:return 64;case 5:return 65;case 6:return 66;case 7:return 67;case 8:return 128;case 9:return 129;case null:case void 0:return 3;default:return null}}function Ht(n){var t,s;let e=0;return n.shiftKey&&(e|=1),n.ctrlKey&&(e|=2),n.altKey&&(e|=4),n.metaKey&&(e|=8),(t=n.getModifierState)!=null&&t.call(n,"CapsLock")&&(e|=16),(s=n.getModifierState)!=null&&s.call(n,"NumLock")&&(e|=32),e}class zs{constructor(e,t,s){this.bindings=e,this.typeName=t,this.ptr=s}get view(){return this.bindings.view(this.ptr,this.bindings.typeSize(this.typeName))}free(){this.bindings.freeBytes(this.ptr,this.bindings.typeSize(this.typeName))}}class Ys{constructor(e,t){w(this,"exports");w(this,"layout");w(this,"decoder",new TextDecoder);w(this,"encoder",new TextEncoder);this.exports=e,this.layout=t}buffer(){return this.exports.memory.buffer}bytes(e=0,t=this.buffer().byteLength-e){return new Uint8Array(this.buffer(),e,t)}view(e=0,t=this.buffer().byteLength-e){return new DataView(this.buffer(),e,t)}typeSize(e){const t=this.layout[e];if(!t)throw new Error(`unknown ghostty type: ${e}`);return t.size}field(e,t){const s=this.layout[e],r=s==null?void 0:s.fields[t];if(!s||!r)throw new Error(`unknown ghostty field: ${e}.${t}`);return r}allocStruct(e){const t=this.allocBytes(this.typeSize(e));return this.bytes(t,this.typeSize(e)).fill(0),new zs(this,e,t)}allocBytes(e){return this.exports.ghostty_wasm_alloc_u8_array(e)}freeBytes(e,t){this.exports.ghostty_wasm_free_u8_array(e,t)}allocOpaque(){return this.exports.ghostty_wasm_alloc_opaque()}freeOpaque(e){this.exports.ghostty_wasm_free_opaque(e)}allocU8(){return this.exports.ghostty_wasm_alloc_u8()}freeU8(e){this.exports.ghostty_wasm_free_u8(e)}allocUsize(){return this.exports.ghostty_wasm_alloc_usize()}freeUsize(e){this.exports.ghostty_wasm_free_usize(e)}readPointer(e){return this.view().getUint32(e,!0)}readU8(e){return this.view().getUint8(e)}readUsize(e){return this.view().getUint32(e,!0)}readU64(e){return this.view().getBigUint64(e,!0)}setField(e,t,s,r){const i=this.field(t,s),o=i.offset;switch(i.type){case"u8":case"bool":e.setUint8(o,Number(r));return;case"u16":e.setUint16(o,Number(r),!0);return;case"u32":e.setUint32(o,Number(r),!0);return;case"u64":e.setBigUint64(o,BigInt(r),!0);return;case"usize":{e.setUint32(o,Number(r),!0);return}case"i32":case"enum":e.setInt32(o,Number(r),!0);return;default:throw new Error(`unsupported field type ${t}.${s}: ${i.type}`)}}writeString(e){const t=this.encoder.encode(e),s=this.allocBytes(t.length);return this.bytes(s,t.length).set(t),{ptr:s,len:t.length,free:()=>this.freeBytes(s,t.length)}}writeBytes(e){const t=this.allocBytes(e.length);return this.bytes(t,e.length).set(e),{ptr:t,len:e.length,free:()=>this.freeBytes(t,e.length)}}readOwnedUtf8(e,t){return this.decoder.decode(this.bytes(e,t))}createTerminal(e,t,s){const r=this.allocStruct("GhosttyTerminalOptions");this.setField(r.view,"GhosttyTerminalOptions","cols",e),this.setField(r.view,"GhosttyTerminalOptions","rows",t),this.setField(r.view,"GhosttyTerminalOptions","max_scrollback",s);const i=this.allocOpaque();try{return I(this.exports.ghostty_terminal_new(0,i,r.ptr),"ghostty_terminal_new"),this.readPointer(i)}finally{r.free(),this.freeOpaque(i)}}freeTerminal(e){this.exports.ghostty_terminal_free(e)}writeVt(e,t){const s=typeof t=="string"?this.encoder.encode(t):t,r=this.writeBytes(s);try{this.exports.ghostty_terminal_vt_write(e,r.ptr,r.len)}finally{r.free()}}resetTerminal(e){this.exports.ghostty_terminal_reset(e)}resizeTerminal(e,t,s,r){I(this.exports.ghostty_terminal_resize(e,t,s,Math.max(1,Math.round(r.width)),Math.max(1,Math.round(r.height))),"ghostty_terminal_resize")}scrollViewportDelta(e,t){const s=this.allocStruct("GhosttyTerminalScrollViewport");try{this.setField(s.view,"GhosttyTerminalScrollViewport","tag",vs),s.view.setBigInt64(this.field("GhosttyTerminalScrollViewport","value").offset,BigInt(t),!0),this.exports.ghostty_terminal_scroll_viewport(e,s.ptr)}finally{s.free()}}scrollViewportTop(e){const t=this.allocStruct("GhosttyTerminalScrollViewport");try{this.setField(t.view,"GhosttyTerminalScrollViewport","tag",Rs),this.exports.ghostty_terminal_scroll_viewport(e,t.ptr)}finally{t.free()}}scrollViewportBottom(e){const t=this.allocStruct("GhosttyTerminalScrollViewport");try{this.setField(t.view,"GhosttyTerminalScrollViewport","tag",Cs),this.exports.ghostty_terminal_scroll_viewport(e,t.ptr)}finally{t.free()}}setTerminalTheme(e,t){const s=this.allocStruct("GhosttyColorRgb"),r=this.allocStruct("GhosttyColorRgb"),i=this.allocStruct("GhosttyColorRgb"),o=Fs(t),l=this.allocBytes(o.length*3),u=(y,M)=>{const[O,P,x]=Bt(M);this.setField(y.view,"GhosttyColorRgb","r",O),this.setField(y.view,"GhosttyColorRgb","g",P),this.setField(y.view,"GhosttyColorRgb","b",x)};u(s,t.foreground),u(r,t.background),u(i,t.cursor);const c=this.bytes(l,o.length*3);o.forEach(([y,M,O],P)=>{const x=P*3;c[x]=y,c[x+1]=M,c[x+2]=O});try{I(this.exports.ghostty_terminal_set(e,gs,s.ptr),"ghostty_terminal_set(foreground)"),I(this.exports.ghostty_terminal_set(e,ys,r.ptr),"ghostty_terminal_set(background)"),I(this.exports.ghostty_terminal_set(e,Ss,i.ptr),"ghostty_terminal_set(cursor)"),I(this.exports.ghostty_terminal_set(e,_s,l),"ghostty_terminal_set(palette)")}finally{s.free(),r.free(),i.free(),this.freeBytes(l,o.length*3)}}readTerminalSize(e){const t=this.allocBytes(2),s=this.allocBytes(2);try{return I(this.exports.ghostty_terminal_get(e,Ts,t),"ghostty_terminal_get(cols)"),I(this.exports.ghostty_terminal_get(e,bs,s),"ghostty_terminal_get(rows)"),{cols:this.view().getUint16(t,!0),rows:this.view().getUint16(s,!0)}}finally{this.freeBytes(t,2),this.freeBytes(s,2)}}readScrollbar(e){const t=this.allocStruct("GhosttyTerminalScrollbar");try{return I(this.exports.ghostty_terminal_get(e,xs,t.ptr),"ghostty_terminal_get(scrollbar)"),{total:Number(t.view.getBigUint64(this.field("GhosttyTerminalScrollbar","total").offset,!0)),offset:Number(t.view.getBigUint64(this.field("GhosttyTerminalScrollbar","offset").offset,!0)),len:Number(t.view.getBigUint64(this.field("GhosttyTerminalScrollbar","len").offset,!0))}}finally{t.free()}}isTerminalModeEnabled(e,t){const s=this.allocU8();try{return I(this.exports.ghostty_terminal_mode_get(e,t,s),"ghostty_terminal_mode_get"),this.readU8(s)!==0}finally{this.freeU8(s)}}setTerminalMode(e,t,s){I(this.exports.ghostty_terminal_mode_set(e,t,s?1:0),"ghostty_terminal_mode_set")}createFormatter(e,t,s){const r=this.allocStruct("GhosttyFormatterTerminalOptions"),i=this.field("GhosttyFormatterTerminalOptions","extra").offset,o=this.view(r.ptr+i,this.typeSize("GhosttyFormatterTerminalExtra")),l=this.field("GhosttyFormatterTerminalExtra","screen").offset,u=this.view(r.ptr+i+l,this.typeSize("GhosttyFormatterScreenExtra")),c=this.allocOpaque();try{this.setField(r.view,"GhosttyFormatterTerminalOptions","size",this.typeSize("GhosttyFormatterTerminalOptions")),this.setField(r.view,"GhosttyFormatterTerminalOptions","emit",t),this.setField(r.view,"GhosttyFormatterTerminalOptions","unwrap",s.unwrap),this.setField(r.view,"GhosttyFormatterTerminalOptions","trim",s.trim),this.setField(o,"GhosttyFormatterTerminalExtra","size",this.typeSize("GhosttyFormatterTerminalExtra")),this.setField(o,"GhosttyFormatterTerminalExtra","palette",s.includePalette),this.setField(u,"GhosttyFormatterScreenExtra","size",this.typeSize("GhosttyFormatterScreenExtra"));const y=this.field("GhosttyFormatterTerminalOptions","selection").offset;return r.view.setUint32(y,s.selectionPtr??0,!0),I(this.exports.ghostty_formatter_terminal_new(0,c,e,r.ptr),"ghostty_formatter_terminal_new"),this.readPointer(c)}finally{r.free(),this.freeOpaque(c)}}freeFormatter(e){this.exports.ghostty_formatter_free(e)}resolveViewportGridRef(e,t,s){const r=this.allocStruct("GhosttyPoint"),i=this.allocStruct("GhosttyGridRef");try{this.setField(r.view,"GhosttyPoint","tag",Es);const o=this.field("GhosttyPoint","value").offset,l=this.view(r.ptr+o,this.typeSize("GhosttyPointCoordinate"));return this.setField(l,"GhosttyPointCoordinate","x",t),this.setField(l,"GhosttyPointCoordinate","y",s),this.exports.ghostty_terminal_grid_ref(e,r.ptr,i.ptr)!==Be?(i.free(),null):i}finally{r.free()}}createViewportSelection(e,t,s){const r=Math.max(1,Math.floor(t)),i=Math.max(1,Math.floor(s)),o=this.resolveViewportGridRef(e,0,0);if(!o)return null;let l=null;for(let c=i-1;c>=0&&(l=this.resolveViewportGridRef(e,r-1,c),!l);c-=1);if(!l)return o.free(),null;const u=this.allocStruct("GhosttySelection");try{this.setField(u.view,"GhosttySelection","size",this.typeSize("GhosttySelection")),this.setField(u.view,"GhosttySelection","rectangle",!1);const c=this.field("GhosttySelection","start").offset,y=this.field("GhosttySelection","end").offset;return this.bytes(u.ptr+c,this.typeSize("GhosttyGridRef")).set(this.bytes(o.ptr,this.typeSize("GhosttyGridRef"))),this.bytes(u.ptr+y,this.typeSize("GhosttyGridRef")).set(this.bytes(l.ptr,this.typeSize("GhosttyGridRef"))),u}finally{o.free(),l.free()}}formatViewport(e,t,s,r){const i=this.readTerminalSize(e),o=this.createViewportSelection(e,Math.max(1,Math.min(i.cols,r.cols)),Math.max(1,Math.min(i.rows,r.rows))),l=this.createFormatter(e,t,{...s,selectionPtr:(o==null?void 0:o.ptr)??null});try{return this.formatFormatter(l)}finally{this.freeFormatter(l),o==null||o.free()}}formatFormatter(e){const t=this.allocOpaque(),s=this.allocUsize();try{I(this.exports.ghostty_formatter_format_alloc(e,0,t,s),"ghostty_formatter_format_alloc");const r=this.readPointer(t),i=this.readUsize(s),o=this.buffer().byteLength;try{if(i===0||r===0)return"";if(r<0||r>o||i>o-r)throw new Error(`ghostty_formatter_format_alloc returned invalid slice ptr=${r} len=${i} mem=${o}`);return this.readOwnedUtf8(r,i)}finally{i>0&&r!==0&&this.exports.ghostty_free(0,r,i)}}finally{this.freeOpaque(t),this.freeUsize(s)}}createRenderState(){const e=this.allocOpaque();try{return I(this.exports.ghostty_render_state_new(0,e),"ghostty_render_state_new"),this.readPointer(e)}finally{this.freeOpaque(e)}}freeRenderState(e){this.exports.ghostty_render_state_free(e)}updateRenderState(e,t){I(this.exports.ghostty_render_state_update(e,t),"ghostty_render_state_update")}getRenderStateValueResult(e,t,s){return this.exports.ghostty_render_state_get(e,t,s)}getRenderStateValue(e,t,s){I(this.getRenderStateValueResult(e,t,s),"ghostty_render_state_get")}setRenderStateValue(e,t,s){I(this.exports.ghostty_render_state_set(e,t,s),"ghostty_render_state_set")}getRenderStateColors(e,t){I(this.exports.ghostty_render_state_colors_get(e,t),"ghostty_render_state_colors_get")}createRenderStateRowIterator(){const e=this.allocOpaque();try{return I(this.exports.ghostty_render_state_row_iterator_new(0,e),"ghostty_render_state_row_iterator_new"),this.readPointer(e)}finally{this.freeOpaque(e)}}freeRenderStateRowIterator(e){this.exports.ghostty_render_state_row_iterator_free(e)}bindRenderStateRowIterator(e,t){const s=this.allocOpaque();try{this.view(s,4).setUint32(0,t,!0),this.getRenderStateValue(e,4,s)}finally{this.freeOpaque(s)}}nextRenderStateRowIterator(e){return this.exports.ghostty_render_state_row_iterator_next(e)!==0}getRenderStateRowValueResult(e,t,s){return this.exports.ghostty_render_state_row_get(e,t,s)}getRenderStateRowValue(e,t,s){I(this.getRenderStateRowValueResult(e,t,s),"ghostty_render_state_row_get")}setRenderStateRowValue(e,t,s){I(this.exports.ghostty_render_state_row_set(e,t,s),"ghostty_render_state_row_set")}createRenderStateRowCells(){const e=this.allocOpaque();try{return I(this.exports.ghostty_render_state_row_cells_new(0,e),"ghostty_render_state_row_cells_new"),this.readPointer(e)}finally{this.freeOpaque(e)}}freeRenderStateRowCells(e){this.exports.ghostty_render_state_row_cells_free(e)}bindRenderStateRowCells(e,t){const s=this.allocOpaque();try{this.view(s,4).setUint32(0,t,!0),this.getRenderStateRowValue(e,3,s)}finally{this.freeOpaque(s)}}nextRenderStateRowCell(e){return this.exports.ghostty_render_state_row_cells_next(e)!==0}selectRenderStateRowCell(e,t){I(this.exports.ghostty_render_state_row_cells_select(e,t),"ghostty_render_state_row_cells_select")}getRenderStateRowCellValueResult(e,t,s){return this.exports.ghostty_render_state_row_cells_get(e,t,s)}getRenderStateRowCellValue(e,t,s){I(this.getRenderStateRowCellValueResult(e,t,s),"ghostty_render_state_row_cells_get")}getRawRowValueResult(e,t,s){return this.exports.ghostty_row_get(e,t,s)}getRawRowValue(e,t,s){I(this.getRawRowValueResult(e,t,s),"ghostty_row_get")}getRawCellValueResult(e,t,s){return this.exports.ghostty_cell_get(e,t,s)}getRawCellValue(e,t,s){I(this.getRawCellValueResult(e,t,s),"ghostty_cell_get")}createKeyEncoder(){const e=this.allocOpaque();try{return I(this.exports.ghostty_key_encoder_new(0,e),"ghostty_key_encoder_new"),this.readPointer(e)}finally{this.freeOpaque(e)}}freeKeyEncoder(e){this.exports.ghostty_key_encoder_free(e)}createMouseEncoder(){const e=this.allocOpaque(),t=this.allocU8();try{I(this.exports.ghostty_mouse_encoder_new(0,e),"ghostty_mouse_encoder_new");const s=this.readPointer(e);return this.view().setUint8(t,1),this.exports.ghostty_mouse_encoder_setopt(s,Os,t),s}finally{this.freeU8(t),this.freeOpaque(e)}}freeMouseEncoder(e){this.exports.ghostty_mouse_encoder_free(e)}resetMouseEncoder(e){this.exports.ghostty_mouse_encoder_reset(e)}encodeMouseEvent(e,t,s){const r=this.isTerminalModeEnabled(t,Ps),i=this.isTerminalModeEnabled(t,Hs),o=this.isTerminalModeEnabled(t,Bs),l=this.isTerminalModeEnabled(t,Is);if(!r&&!i&&!o&&!l||s.action==="motion"&&!(r||i&&s.anyButtonPressed)||l&&s.action!=="press"||!r&&!i&&!l&&s.action==="motion")return null;const u=Us(s.button);if(u===null)return null;const c=Math.max(1,Math.floor(s.x/Math.max(1,s.cellWidth))+1),y=Math.max(1,Math.floor(s.y/Math.max(1,s.cellHeight))+1),M=Math.round(s.x+1),O=Math.round(s.y+1);let P=s.action==="release"&&!this.isTerminalModeEnabled(t,_t)&&!this.isTerminalModeEnabled(t,Tt)?3:u;if(s.action==="motion"&&(P+=32),P+=Gs(s.mods),this.isTerminalModeEnabled(t,Tt)){const x=s.action==="release"?"m":"M";return`\x1B[<${P};${M};${O}${x}`}if(this.isTerminalModeEnabled(t,_t)){const x=s.action==="release"?"m":"M";return`\x1B[<${P};${c};${y}${x}`}if(this.isTerminalModeEnabled(t,Ns))return`\x1B[${P};${c};${y}M`;if(this.isTerminalModeEnabled(t,Ls)||o||i||r||l){const x=Je(P),T=Je(c),g=Je(y);return!x||!T||!g?null:`\x1B[M${x}${T}${g}`}return null}encodeKeyEvent(e,t,s){if(s.keyCode<=0)return null;const r=this.allocOpaque();let i=0,o=null;try{return I(this.exports.ghostty_key_event_new(0,r),"ghostty_key_event_new"),i=this.readPointer(r),this.exports.ghostty_key_encoder_setopt_from_terminal(e,t),this.exports.ghostty_key_event_set_action(i,s.action==="release"?Ms:s.action==="repeat"?As:Ds),this.exports.ghostty_key_event_set_key(i,s.keyCode),this.exports.ghostty_key_event_set_mods(i,s.mods),this.exports.ghostty_key_event_set_consumed_mods(i,0),this.exports.ghostty_key_event_set_composing(i,s.composing?1:0),s.utf8&&(o=this.writeString(s.utf8),this.exports.ghostty_key_event_set_utf8(i,o.ptr,o.len)),typeof s.unshiftedCodepoint=="number"&&this.exports.ghostty_key_event_set_unshifted_codepoint(i,s.unshiftedCodepoint),this.encodeKeyHandle(e,i)}finally{o==null||o.free(),i!==0&&this.exports.ghostty_key_event_free(i),this.freeOpaque(r)}}encodeKeyHandle(e,t){const s=this.allocUsize();try{const r=this.exports.ghostty_key_encoder_encode(e,t,0,0,s);r!==St&&r!==Be&&I(r,"ghostty_key_encoder_encode(size)");const i=Math.max(0,this.readUsize(s));if(i===0)return null;const o=this.allocBytes(i),l=this.allocUsize();try{I(this.exports.ghostty_key_encoder_encode(e,t,o,i,l),"ghostty_key_encoder_encode");const u=this.readUsize(l);return u===0?null:this.readOwnedUtf8(o,u)}finally{this.freeBytes(o,i),this.freeUsize(l)}}finally{this.freeUsize(s)}}encodePaste(e,t){const s=this.writeString(t),r=this.allocUsize();try{const i=this.isTerminalModeEnabled(e,ks),o=this.exports.ghostty_paste_encode(s.ptr,s.len,i?1:0,0,0,r);o!==St&&o!==Be&&I(o,"ghostty_paste_encode(size)");const l=Math.max(0,this.readUsize(r));if(l===0)return"";const u=this.allocBytes(l),c=this.allocUsize();try{return I(this.exports.ghostty_paste_encode(s.ptr,s.len,i?1:0,u,l,c),"ghostty_paste_encode"),this.readOwnedUtf8(u,this.readUsize(c))}finally{this.freeBytes(u,l),this.freeUsize(c)}}finally{s.free(),this.freeUsize(r)}}}async function Vs(n){if((n.startsWith("/")||n.startsWith("./")||n.startsWith("../")||/^[A-Za-z]:[\\/]/.test(n))&&typeof Bun<"u")return Bun.file(n).arrayBuffer();const t=await fetch(n);if(!t.ok)throw new Error(`failed to load ghostty wasm: ${t.status} ${t.statusText}`);return t.arrayBuffer()}async function $s(){return Xe||(Xe=(async()=>{const n=await Vs(ws),t=(await WebAssembly.instantiate(n,{env:{log(){}}})).instance.exports,s=new Uint8Array(t.memory.buffer),r=t.ghostty_type_json();let i=r;for(;s[i]!==0;)i+=1;const o=JSON.parse(new TextDecoder().decode(s.subarray(r,i)));return new Ys(t,o)})()),Xe}const bt=80,Re=24,Qe=9,Ae=17,Ks=48,Pt="ghostty-official",He=9,Pe=1e3,Le=1002,Ne=1003,Ze=1007,Oe=1047,ke=1049,Ws=[He,Pe,Le,Ne],xt=1,Et=3,Rt=2,js=4,qs=5;class Xs{constructor(e){this.content=e}translateToString(e){return e?this.content.replace(/\s+$/u,""):this.content}}class Js{constructor(){w(this,"active",{baseY:0,viewportY:0,length:Re,getLine:e=>{const t=e-this.active.viewportY,s=this.visibleLines[t];return typeof s=="string"?new Xs(s):null}});w(this,"visibleLines",Array.from({length:Re},()=>""))}setViewport(e,t,s,r){this.active.viewportY=e,this.active.baseY=t,this.active.length=s,this.visibleLines=r}}function Qs(n){return!(n.key.length===1&&!n.ctrlKey&&!n.altKey&&!n.metaKey)}function Zs(n,e){const t=n.slice(0,e).map(s=>s.text);for(;t.length<e;)t.push("");return t}function Ie(n){return Ht({shiftKey:!!n.shiftKey,ctrlKey:!!n.ctrlKey,altKey:!!n.altKey,metaKey:!!n.metaKey,getModifierState:()=>!1})}class er{constructor(){w(this,"terminal",null)}activate(e){this.terminal=e instanceof Ge?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 Ge{constructor(e,t,s,r,i,o){w(this,"buffer",new Js);w(this,"_core",{_renderService:{dimensions:{css:{cell:{width:Qe,height:Ae}}}}});w(this,"options");w(this,"element",null);w(this,"textarea",null);w(this,"cols",bt);w(this,"rows",Re);w(this,"bindings");w(this,"terminalHandle");w(this,"keyEncoderHandle");w(this,"mouseEncoderHandle");w(this,"renderState");w(this,"dataListeners",new Set);w(this,"addons",new Set);w(this,"screenElement",null);w(this,"renderer",null);w(this,"renderRaf",null);w(this,"disposed",!1);w(this,"disableStdin");w(this,"customKeyEventHandler",()=>!0);w(this,"imeIsComposing",!1);w(this,"lastCompositionCommit",null);w(this,"selectionState",kt());w(this,"lineCache",new Map);w(this,"lastViewportOffset",0);w(this,"lastViewportRows",Re);w(this,"lastRenderedRows",[]);w(this,"pointerDrag",{active:!1,moved:!1,mode:"character",lastClientX:null,lastClientY:null});w(this,"autoScrollTimer",null);w(this,"domEventDisposers",[]);w(this,"copyShortcutSuppressed",!1);w(this,"scrollbarThumb",null);w(this,"scrollbarFadeTimer",null);w(this,"pressedMouseButtons",new Set);w(this,"wheelPixelDelta",0);w(this,"mouseDragActive",!1);this.bindings=e,this.terminalHandle=t,this.keyEncoderHandle=s,this.mouseEncoderHandle=r,this.renderState=i,this.options=o,this.disableStdin=!!o.disableStdin}static async create(e){const t=await $s(),s=t.createTerminal(bt,Re,e.scrollback);let r=0,i=0,o=null;try{return t.setTerminalTheme(s,e.theme),r=t.createKeyEncoder(),i=t.createMouseEncoder(),o=wt(t),new Ge(t,s,r,i,o,e)}catch(l){throw o&&qe(o),r!==0&&t.freeKeyEncoder(r),i!==0&&t.freeMouseEncoder(i),t.freeTerminal(s),l}}open(e){if(this.disposed||this.element)return;const t=document.createElement("div");t.className="xterm",t.style.position="absolute",t.style.inset="0",t.style.overflow="hidden",t.style.width="100%",t.style.height="100%",t.style.backgroundColor=this.options.theme.background,t.style.color=this.options.theme.foreground,t.style.fontFamily=this.options.fontFamily,t.style.fontSize=`${this.options.fontSize}px`,t.style.lineHeight="1.2";const s=document.createElement("div");s.className="xterm-viewport",s.style.width="100%",s.style.height="100%",s.style.overflow="hidden",s.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 i=document.createElement("div");i.className="xterm-helper-textarea",i.setAttribute("aria-label","Terminal Input"),i.setAttribute("role","textbox"),i.setAttribute("contenteditable","true"),i.setAttribute("autocorrect","off"),i.setAttribute("autocapitalize","off"),i.setAttribute("spellcheck","false"),i.style.position="absolute",i.style.opacity="1",i.style.pointerEvents="none",i.style.left="0",i.style.top="0",i.style.minWidth="1px",i.style.minHeight="1px",i.style.whiteSpace="pre",i.style.border="0",i.style.padding="0",i.style.margin="0",i.style.color=this.options.theme.foreground,i.style.backgroundColor="transparent",i.style.caretColor="transparent",i.style.overflow="visible",i.style.outline="none",i.style.boxShadow="none",i.style.fontFamily=this.options.fontFamily,i.style.fontSize=`${this.options.fontSize}px`,i.style.userSelect="text",i.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),s.appendChild(r),t.appendChild(s),t.appendChild(i),t.appendChild(o),e.appendChild(t),this.element=t,this.screenElement=r,this.textarea=i,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}write(e){if(this.disposed)return;const t=this.isAltScreenActive();this.bindings.writeVt(this.terminalHandle,e);const s=this.isAltScreenActive();t&&!s&&this.clearMouseTrackingModes(),this.scheduleRender()}clearMouseTrackingModes(){if(!this.disposed){for(const e of Ws)this.bindings.setTerminalMode(this.terminalHandle,e,!1);this.bindings.resetMouseEncoder(this.mouseEncoderHandle),this.pressedMouseButtons.clear(),this.mouseDragActive=!1}}isAltScreenActive(){return this.isModeEnabled(Oe)||this.isModeEnabled(ke)}reset(){this.disposed||(this.lineCache.clear(),this.clearSelectionState(!1),this.bindings.resetTerminal(this.terminalHandle),this.scheduleRender())}refresh(){this.disposed||this.render()}resize(e,t){if(this.disposed)return;const s=Math.max(2,Math.floor(e)),r=Math.max(2,Math.floor(t));this.cols=s,this.rows=r,this.clearSelectionState(!1),this.bindings.resizeTerminal(this.terminalHandle,s,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(He),mouseNormal:this.isModeEnabled(Pe),mouseButton:this.isModeEnabled(Le),mouseAny:this.isModeEnabled(Ne),mouseUtf8:this.isModeEnabled(1005),mouseSgr:this.isModeEnabled(1006),mouseSgrPixels:this.isModeEnabled(1016),mouseUrxvt:this.isModeEnabled(1015),altScroll:this.isModeEnabled(Ze),altScreen1047:this.isModeEnabled(Oe),altScreen1049:this.isModeEnabled(ke)}}restoreModeSnapshot(e){this.bindings.setTerminalMode(this.terminalHandle,He,e.mouseX10),this.bindings.setTerminalMode(this.terminalHandle,Pe,e.mouseNormal),this.bindings.setTerminalMode(this.terminalHandle,Le,e.mouseButton),this.bindings.setTerminalMode(this.terminalHandle,Ne,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,Ze,e.altScroll),this.bindings.setTerminalMode(this.terminalHandle,Oe,e.altScreen1047),this.bindings.setTerminalMode(this.terminalHandle,ke,e.altScreen1049),this.bindings.resetMouseEncoder(this.mouseEncoderHandle)}handleViewportGesture(e){if(this.disposed||e.deltaY===0)return!1;const t=this.gestureToLines(e);if(t===0)return!1;const s=this.getInputRoutingState();if(s.mouseReporting){const r=t<0?js:qs;let i=!1;for(let o=0;o<Math.abs(t);o+=1)i=this.emitMouseInput({action:"press",button:r,clientX:e.clientX,clientY:e.clientY,mods:Ie(e),anyButtonPressed:this.pressedMouseButtons.size>0})||i;return i}return s.altScroll?this.emitAltScrollInput(t):(this.scrollLines(t),!0)}paste(e){if(this.disposed||this.disableStdin||!e)return;const t=this.bindings.encodePaste(this.terminalHandle,e);t&&this.emitData(t)}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 t;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),(t=this.renderer)==null||t.setTheme(e),this.scheduleRender()}setDisableStdin(e){this.disableStdin=e,this.syncInputState()}measureSizeFromElement(){const e=this.element;if(!e)return null;const t=e.getBoundingClientRect(),{width:s,height:r}=this.cellDimensions();return t.width===0||t.height===0||s<=0||r<=0?null:{cols:Math.max(2,Math.floor(t.width/s)),rows:Math.max(2,Math.floor(t.height/r))}}dispose(){var e,t;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 s of this.addons)s.dispose();this.addons.clear(),(e=this.renderer)==null||e.dispose(),this.renderer=null,(t=this.element)==null||t.remove(),this.element=null,this.screenElement=null,this.textarea=null,this.scrollbarThumb=null,qe(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,t=this.textarea;if(!e||!t)return;e.addEventListener("click",()=>{this.disableStdin||this.focus()}),(this.screenElement??e).addEventListener("mousedown",i=>{if(i instanceof MouseEvent){if(this.disableStdin||this.focus(),this.getInputRoutingState().mouseReporting){const o=this.mouseButtonFromEvent(i);if(o===null)return;this.clearSelectionState(),this.pressedMouseButtons.add(o),this.mouseDragActive=!0,this.emitMouseInput({action:"press",button:o,clientX:i.clientX,clientY:i.clientY,mods:Ie(i),anyButtonPressed:!0}),i.preventDefault();return}i.button===0&&(this.mouseDragActive=!0,this.beginPointerSelection(i),i.preventDefault())}}),e.addEventListener("wheel",i=>{this.handleViewportGesture({source:"wheel",deltaY:i.deltaY,deltaMode:i.deltaMode,clientX:i.clientX,clientY:i.clientY,shiftKey:i.shiftKey,ctrlKey:i.ctrlKey,altKey:i.altKey,metaKey:i.metaKey})&&i.preventDefault()},{passive:!1});const r=typeof window<"u"&&typeof window.addEventListener=="function"?window:null;if(r){const i=l=>{if(this.mouseDragActive){if(this.getInputRoutingState().mouseReporting){this.emitMouseInput({action:"motion",button:this.mouseButtonFromButtons(l.buttons),clientX:l.clientX,clientY:l.clientY,mods:Ie(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:Ie(l),anyButtonPressed:this.pressedMouseButtons.size>0});return}this.finishPointerSelection(l)}};r.addEventListener("mousemove",i),r.addEventListener("mouseup",o),this.domEventDisposers.push(()=>{r.removeEventListener("mousemove",i),r.removeEventListener("mouseup",o)})}t.addEventListener("keydown",i=>{const o=this.getSelectionText();if(o&&fs(i)){this.copyShortcutSuppressed=!0,i.preventDefault(),ms(o).catch(()=>{}),this.clearTextarea();return}if(!this.customKeyEventHandler(i)||this.disableStdin||this.imeIsComposing||i.keyCode===229||!Qs(i))return;const l=this.encodeKeyboardEvent(i,i.repeat?"repeat":"press");l&&(i.preventDefault(),this.emitData(l),this.clearTextarea())}),t.addEventListener("keyup",i=>{if(this.copyShortcutSuppressed){const l=i.key.toLowerCase();if(l==="c"){i.preventDefault();return}if(l==="control"||l==="meta"||l==="os"){this.copyShortcutSuppressed=!1,i.preventDefault();return}}if(this.disableStdin||this.imeIsComposing)return;const o=this.encodeKeyboardEvent(i,"release");o&&(i.preventDefault(),this.emitData(o),this.clearTextarea())}),t.addEventListener("compositionstart",()=>{this.imeIsComposing=!0,this.lastCompositionCommit=null,this.syncTextareaPositionToCursor()}),t.addEventListener("compositionupdate",()=>{this.syncTextareaPositionToCursor()}),t.addEventListener("compositionend",i=>{this.imeIsComposing=!1;const o=i.data??"";o&&(this.lastCompositionCommit={data:o,at:Date.now()},this.emitData(o),this.clearTextarea())}),t.addEventListener("beforeinput",i=>{if(this.disableStdin||i.inputType==="insertFromPaste")return;const o=i.data??"";if(!o||i.isComposing||this.imeIsComposing)return;const l=this.lastCompositionCommit;if(l&&l.data===o&&Date.now()-l.at<40){this.lastCompositionCommit=null,i.preventDefault(),this.clearTextarea();return}this.lastCompositionCommit=null,i.preventDefault(),this.emitData(o),this.clearTextarea()}),t.addEventListener("paste",i=>{var l;if(this.disableStdin)return;const o=((l=i.clipboardData)==null?void 0:l.getData("text/plain"))??"";o&&(i.preventDefault(),this.paste(o),this.clearTextarea())}),t.addEventListener("copy",i=>{const o=this.getSelectionText();o&&ps(i,o)}),t.addEventListener("input",()=>{if(this.disableStdin||this.imeIsComposing)return;const i=t.textContent??"";if(!i){this.clearTextarea();return}const o=this.lastCompositionCommit;if(o&&o.data===i&&Date.now()-o.at<40){this.lastCompositionCommit=null,this.clearTextarea();return}this.lastCompositionCommit=null,this.emitData(i),this.clearTextarea()})}encodeKeyboardEvent(e,t){const s=ft(e.code);if(s===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:t,keyCode:s,mods:Ht(e),composing:e.isComposing,utf8:r,unshiftedCodepoint:xn(e.code)})}getInputRoutingState(){const e=this.isModeEnabled(He)||this.isModeEnabled(Pe)||this.isModeEnabled(Le)||this.isModeEnabled(Ne),t=this.isModeEnabled(Oe)||this.isModeEnabled(ke);return{mouseReporting:e,altScroll:!e&&t&&this.isModeEnabled(Ze)}}gestureToLines(e){const t=this.cellDimensions().height||Ae;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),i=e.deltaY*r;return i>0?Math.ceil(i):Math.floor(i)}this.wheelPixelDelta+=e.deltaY;const s=this.wheelPixelDelta>0?Math.floor(this.wheelPixelDelta/t):Math.ceil(this.wheelPixelDelta/t);return s!==0&&(this.wheelPixelDelta-=s*t),s}return e.deltaY>0?Math.ceil(e.deltaY/t):Math.floor(e.deltaY/t)}isModeEnabled(e){return this.bindings.isTerminalModeEnabled(this.terminalHandle,e)}mouseButtonFromEvent(e){switch(e.button){case 0:return xt;case 1:return Et;case 2:return Rt;default:return null}}mouseButtonFromButtons(e){return e&1?xt:e&4?Et:e&2?Rt:null}pointerPositionFromClient(e,t){var o;const s=(o=this.screenElement)==null?void 0:o.getBoundingClientRect();if(!s)return null;const r=Math.max(1,s.width),i=Math.max(1,s.height);return{x:Math.max(0,Math.min(r-1,e-s.left)),y:Math.max(0,Math.min(i-1,t-s.top))}}emitMouseInput(e){var o;if(this.disableStdin)return!1;const t=this.pointerPositionFromClient(e.clientX,e.clientY);if(!t)return!1;const s=this.cellDimensions(),r=(o=this.screenElement)==null?void 0:o.getBoundingClientRect();if(!r)return!1;const i=this.bindings.encodeMouseEvent(this.mouseEncoderHandle,this.terminalHandle,{action:e.action,button:e.button,mods:e.mods,x:t.x,y:t.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(s.width||Qe)),cellHeight:Math.max(1,Math.round(s.height||Ae))});return i?(this.emitData(i),!0):!1}emitAltScrollInput(e){const t=ft(e<0?"ArrowUp":"ArrowDown");if(t===0)return!1;let s=!1;for(let r=0;r<Math.abs(e);r+=1){const i=this.bindings.encodeKeyEvent(this.keyEncoderHandle,this.terminalHandle,{action:"press",keyCode:t,mods:0,composing:!1,utf8:null,unshiftedCodepoint:null});i&&(this.emitData(i),s=!0)}return s}emitData(e){for(const t of this.dataListeners)t(e)}clearTextarea(){this.textarea&&(this.textarea.textContent="")}syncTextareaPositionToCursor(){const e=this.textarea,t=this.screenElement;if(!e||!t)return;const{width:s,height:r}=this.cellDimensions();if(s<=0||r<=0)return;const i=wt(this.bindings);let o=0,l=0;try{gt(i,this.terminalHandle);const y=tt(i);y.cursor.x!==null&&y.cursor.y!==null&&(o=y.cursor.x,l=y.cursor.y)}finally{qe(i)}const u=o*s,c=l*r;e.style.left=`${u}px`,e.style.top=`${c}px`,e.style.width=`${Math.max(1,s)}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),t=Math.max(1,e.len||this.rows);gt(this.renderState,this.terminalHandle);const s=tt(this.renderState),r=Array.from(rs(this.renderState));this.cols=Math.max(2,s.cols),this.rows=Math.max(2,s.rows||t),this.lastViewportOffset=e.offset,this.lastViewportRows=this.rows,this.lastRenderedRows=r;for(const c of r)this.lineCache.set(e.offset+c.y,c.text);const i=us(this.selectionState,this.lastViewportOffset,this.lastViewportRows,c=>this.getLineText(c)),o=this.getSelectionText();this.renderer.render({meta:s,rows:r,cellDimensions:this.cellDimensions(),selectionRects:i,selectionColor:this.options.theme.selectionBackground});const l=Zs(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 t=this.scrollbarThumb;if(!t)return;const s=((u=this.screenElement)==null?void 0:u.clientHeight)??0;if(s===0||e.total<=e.len){t.style.opacity="0";return}const r=e.len/e.total,i=Math.max(20,r*s),l=e.offset/Math.max(1,e.total-e.len)*(s-i);t.style.height=`${i}px`,t.style.transform=`translateY(${l}px)`,t.style.opacity="1",this.scrollbarFadeTimer&&clearTimeout(this.scrollbarFadeTimer),this.scrollbarFadeTimer=setTimeout(()=>{t.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`,e.style.lineHeight="1.2",this.element.appendChild(e);const t=e.getBoundingClientRect();e.remove(),this._core._renderService.dimensions.css.cell.width=t.width>0?t.width/10:Qe,this._core._renderService.dimensions.css.cell.height=t.height>0?t.height:Ae}clearSelectionState(e=!0){this.selectionState=as(),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()}beginPointerSelection(e){const t=this.hitTest(e.clientX,e.clientY);if(!t)return;const s=this.selectionModeFromClickDetail(e.detail);this.pointerDrag={active:!0,moved:!1,mode:s,lastClientX:e.clientX,lastClientY:e.clientY},this.selectionState=cs(this.selectionState,{...t,mode:s},r=>this.getLineText(r)),this.updateAutoScroll(),this.render()}updatePointerSelection(e){if(!this.pointerDrag.active)return;const t=this.hitTest(e.clientX,e.clientY);this.pointerDrag.lastClientX=e.clientX,this.pointerDrag.lastClientY=e.clientY,t&&(this.pointerDrag.moved=!0,this.selectionState=yt(this.selectionState,t,s=>this.getLineText(s)),this.render()),this.updateAutoScroll()}finishPointerSelection(e){var s,r,i,o;if(!this.pointerDrag.active||e.button!==0)return;this.pointerDrag.lastClientX=e.clientX,this.pointerDrag.lastClientY=e.clientY,this.stopAutoScroll();const t=this.pointerDrag.mode==="character"&&!this.pointerDrag.moved&&((s=this.selectionState.anchor)==null?void 0:s.line)===((r=this.selectionState.focus)==null?void 0:r.line)&&((i=this.selectionState.anchor)==null?void 0:i.col)===((o=this.selectionState.focus)==null?void 0:o.col);if(this.pointerDrag.active=!1,t){this.clearSelectionState();return}this.render()}selectionModeFromClickDetail(e){return e>=3?"line":e===2?"word":"character"}hitTest(e,t){var O;const s=(O=this.screenElement)==null?void 0:O.getBoundingClientRect();if(!s)return null;const{width:r,height:i}=this.cellDimensions();if(r<=0||i<=0)return null;const o=e-s.left,l=t-s.top,u=Math.max(this.cols-1,0),c=Math.max(this.lastViewportRows-1,0),y=Math.max(0,Math.min(u,Math.floor(o/r))),M=Math.max(0,Math.min(c,Math.floor(l/i)));return{line:this.lastViewportOffset+M,col:y}}getLineText(e){const t=this.lineCache.get(e);if(typeof t=="string")return t;const s=e-this.lastViewportOffset,r=this.lastRenderedRows[s];return(r==null?void 0:r.text)??""}getSelectionText(){return ls(this.selectionState)?ds(this.selectionState,e=>this.getLineText(e)):null}updateSelectionTextProbe(e){globalThis.__tmexE2eTerminalSelectionText=e}updateAutoScroll(){var s;if(!this.pointerDrag.active||this.pointerDrag.lastClientY===null){this.stopAutoScroll();return}const e=(s=this.screenElement)==null?void 0:s.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()},Ks))}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 t=0;if(this.pointerDrag.lastClientY<e.top?t=-1:this.pointerDrag.lastClientY>e.bottom&&(t=1),t===0){this.stopAutoScroll();return}this.bindings.scrollViewportDelta(this.terminalHandle,t),this.render();const s=this.hitTest(this.pointerDrag.lastClientX,this.pointerDrag.lastClientY);s&&(this.selectionState=yt(this.selectionState,s,i=>this.getLineText(i)),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 tr(n){return Ge.create(n)}const Lt={background:"#e1e1e1",foreground:"#616161",cursor:"#616161",selectionBackground:"rgba(97, 97, 97, 0.25)",black:"#171717",red:"#bf2172",green:"#009799",yellow:"#9a7200",blue:"#007299",magenta:"#9b1d72",cyan:"#007173",white:"#d9d9d9",brightBlack:"#4e4e4e",brightRed:"#e12672",brightGreen:"#00bddf",brightYellow:"#ffdd00",brightBlue:"#7299bc",brightMagenta:"#e17899",brightCyan:"#6fbcbd",brightWhite:"#f1f1f1"},Nt={background:"#262626",foreground:"#d0d0d0",cursor:"#c5c5c5",selectionBackground:"rgba(197, 197, 197, 0.25)",black:"#000000",red:"#ba3c3c",green:"#5d876d",yellow:"#d5a54e",blue:"#887c8d",magenta:"#cd6d6d",cyan:"#618484",white:"#cfcdc3",brightBlack:"#000000",brightRed:"#ea7171",brightGreen:"#7aab7a",brightYellow:"#d1d194",brightBlue:"#afa3b5",brightMagenta:"#e29f9f",brightCyan:"#a0aea3",brightWhite:"#d0d0d0"},nr='"JetBrains Mono", "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Noto Sans Mono CJK SC", "Source Han Mono SC", "Sarasa Mono SC", "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", monospace';function Ft(n){if(!n)return n;const e=n.replace(/\r\n/g,`
|
|
23
|
+
`);return(e.endsWith(`
|
|
24
|
+
`)?e.slice(0,-1):e).replace(/\n/g,`\r
|
|
25
|
+
`)}const sr="\x1B[?1049h\x1B[H\x1B[2J";function rr(n){return sr+Ft(n)}function Ct(n,e){let t=e,s=0;for(const l of n)l===10&&!t&&(s+=1),t=l===13;const r=t;if(s===0)return{normalized:n,endedWithCR:r};const i=new Uint8Array(n.length+s);let o=0;t=e;for(const l of n)l===10&&!t&&(i[o]=13,o+=1),i[o]=l,o+=1,t=l===13;return{normalized:i,endedWithCR:r}}const ir=1.3,or=36;function lr(n,e){const t=d.useRef(!1);return d.useEffect(()=>{const s=n.current;if(!s||!(window.innerWidth<768||navigator.maxTouchPoints>0||"ontouchstart"in window))return;t.current=!0;let i=0,o=null,l=!1,u=0;const c=g=>g?!!(g.closest(".scrollbar")||g.closest(".slider")||g.closest(".xterm-scroll-area")):!1,y=(g,h,k)=>{const D=k instanceof Element?k:null;if(c(D))return!0;const q=document.elementFromPoint(g,h);if(c(q))return!0;const F=s.querySelector(".xterm");if(!(F instanceof HTMLElement))return!1;const A=F.getBoundingClientRect(),z=g>=A.left&&g<=A.right,X=h>=A.top&&h<=A.bottom;return!z||!X?!1:g>=A.right-or},M=()=>[s.querySelector(".xterm-viewport"),s.querySelector(".xterm-scrollable-element")].filter(h=>h instanceof HTMLElement),O=g=>{if(o===null)return null;for(let h=0;h<g.length;h+=1){const k=g.item(h);if(k&&k.identifier===o)return k}return null},P=g=>{if(g.touches.length!==1)return;const h=g.touches.item(0);h&&(o=h.identifier,i=h.clientY,u=0,l=y(h.clientX,h.clientY,g.target))},x=g=>{var z,X,oe,Q,b,L,G,V;const h=O(g.touches)??g.touches.item(0);if(!h||(l||(l=y(h.clientX,h.clientY,g.target),l&&(u=0)),l))return;const k=h.clientY,D=i-k;if(i=k,D===0)return;let q=!1,F=!1;const A=(e==null?void 0:e())??null;if(A){const C=A==null?void 0:A._core,v=((Q=(oe=(X=(z=C==null?void 0:C._renderService)==null?void 0:z.dimensions)==null?void 0:X.css)==null?void 0:oe.cell)==null?void 0:Q.height)??18;u+=D*ir;const E=u>0?Math.floor(u/v):Math.ceil(u/v);if(typeof A.handleViewportGesture=="function")E!==0&&(q=A.handleViewportGesture({source:"touch",deltaY:E*v,clientX:h.clientX,clientY:h.clientY}),u-=E*v);else if(E!==0){const Y=((L=(b=A.buffer)==null?void 0:b.active)==null?void 0:L.viewportY)??0;A.scrollLines(E);const te=((V=(G=A.buffer)==null?void 0:G.active)==null?void 0:V.viewportY)??0;q=Y!==te,F=E<0&&Y<=0&&te<=0,u-=E*v}}else{const C=M();if(C.length===0)return;for(const v of C){const E=v.scrollTop;v.scrollTop+=D;const Y=v.scrollTop;Math.abs(Y-E)>0&&(q=!0),D<0&&Y<=0&&(F=!0)}if(!q){const v=s.querySelector(".xterm");if(v instanceof HTMLElement){const E=new WheelEvent("wheel",{bubbles:!0,cancelable:!0,deltaMode:WheelEvent.DOM_DELTA_PIXEL,deltaY:D}),Y=v.dispatchEvent(E);q=E.defaultPrevented||!Y}}}g.cancelable&&(q||F)&&g.preventDefault()},T=g=>{o===null||!O(g.changedTouches)||(o=null,u=0,l=!1)};return s.addEventListener("touchstart",P,{passive:!0}),s.addEventListener("touchmove",x,{passive:!1}),s.addEventListener("touchend",T,{passive:!0}),s.addEventListener("touchcancel",T,{passive:!0}),()=>{t.current=!1,s.removeEventListener("touchstart",P),s.removeEventListener("touchmove",x),s.removeEventListener("touchend",T),s.removeEventListener("touchcancel",T)}},[n,e]),t}function ar({now:n,remoteSize:e,pendingLocalSize:t,ttlMs:s=2e3}){return!t||n-t.at>s?!0:t.cols===e.cols&&t.rows===e.rows}function cr({currentSize:n,containerSize:e,force:t=!1}){return t?!0:n.cols!==e.cols||n.rows!==e.rows}function dr({deviceId:n,paneId:e,deviceConnected:t,isSelectionInvalid:s,onResize:r,onSync:i,getContainerRect:o}){const l=d.useRef(null),u=d.useRef(null),c=d.useRef(null),y=d.useRef(null),M=d.useRef(0),O=d.useRef([]),P=d.useRef(null),x=d.useRef(null),T=d.useRef(o),g=d.useRef(!1),h=d.useRef(r),k=d.useRef(i);d.useEffect(()=>{h.current=r},[r]),d.useEffect(()=>{k.current=i},[i]),d.useEffect(()=>{T.current=o},[o]);const D=d.useCallback(()=>{var Y,te,_,S,B,N,$,K,le,H;const b=x.current,L=P.current;if(!b||!L||!b.element)return null;let G;try{const ae=L.proposeDimensions();if(!ae)throw new Error("fitAddon.proposeDimensions() returned null");G=Math.max(2,ae.cols)}catch{const ae=b._core,ce=((S=(_=(te=(Y=ae==null?void 0:ae._renderService)==null?void 0:Y.dimensions)==null?void 0:te.css)==null?void 0:_.cell)==null?void 0:S.width)??9,ee=(B=T.current)==null?void 0:B.call(T);if(!ee||ee.width===0)return null;G=Math.max(2,Math.floor(ee.width/ce))}const V=(N=T.current)==null?void 0:N.call(T);if(!V||V.height===0)return null;const C=b._core,v=((H=(le=(K=($=C==null?void 0:C._renderService)==null?void 0:$.dimensions)==null?void 0:K.css)==null?void 0:le.cell)==null?void 0:H.height)??17,E=Math.max(2,Math.floor(V.height/v));return{cols:G,rows:E}},[]),q=d.useCallback((b,L)=>{const G=x.current;G&&(G.cols===b&&G.rows===L||G.resize(b,L))},[]),F=d.useCallback((b,L=!1)=>{if(!n||!e||!t||s&&b!=="sync"||!L&&Date.now()<M.current||!x.current)return!1;const V=D();if(!V)return!1;const{cols:C,rows:v}=V,E=c.current;return!L&&E&&E.cols===C&&E.rows===v?(q(C,v),!0):(q(C,v),b==="sync"?k.current(C,v):h.current(C,v),c.current={cols:C,rows:v},y.current={cols:C,rows:v,at:Date.now()},!0)},[q,t,n,s,D,e]),A=d.useCallback((b="resize",L={})=>{const{immediate:G=!1,force:V=!1}=L;u.current!==null&&(window.clearTimeout(u.current),u.current=null),l.current!==null&&(cancelAnimationFrame(l.current),l.current=null);const C=()=>{l.current=requestAnimationFrame(()=>{l.current=null,F(b,V)})};if(G){C();return}u.current=window.setTimeout(()=>{u.current=null,C()},150)},[F]),z=d.useCallback(()=>{for(const b of O.current)window.clearTimeout(b);O.current=[]},[]),X=d.useCallback(()=>{var L;z(),A("sync",{immediate:!0,force:!0});const b=window.setTimeout(()=>{A("sync",{immediate:!0,force:!0})},60);O.current.push(b),typeof document<"u"&&"fonts"in document&&((L=document.fonts)!=null&&L.ready)&&document.fonts.ready.then(()=>{A("sync",{immediate:!0,force:!0})}).catch(()=>{})},[z,A]);d.useEffect(()=>{let b=null;const L=()=>{b!==null&&cancelAnimationFrame(b),b=requestAnimationFrame(()=>{b=null,A("resize")})};return window.addEventListener("resize",L),()=>{window.removeEventListener("resize",L),b!==null&&cancelAnimationFrame(b)}},[A]),d.useEffect(()=>{const b=()=>{var Y;const C=x.current,v=D();if(!C||!v)return;if(!cr({currentSize:{cols:Math.max(2,C.cols),rows:Math.max(2,C.rows)},containerSize:v})){(Y=C.refresh)==null||Y.call(C);return}A("sync",{force:!0})},L=()=>{if(document.visibilityState!=="visible"){g.current=!0;return}g.current&&(g.current=!1,b())},G=()=>{g.current=!0},V=()=>{g.current&&(g.current=!1,b())};return document.addEventListener("visibilitychange",L),window.addEventListener("blur",G),window.addEventListener("focus",V),()=>{document.removeEventListener("visibilitychange",L),window.removeEventListener("blur",G),window.removeEventListener("focus",V)}},[D,A]),d.useEffect(()=>()=>{z(),u.current!==null&&window.clearTimeout(u.current),l.current!==null&&cancelAnimationFrame(l.current)},[z]);const oe=d.useCallback(b=>{P.current=b},[]),Q=d.useCallback(b=>{x.current=b},[]);return{scheduleResize:A,runPostSelectResize:X,clearPostSelectResizeTimers:z,setFitAddon:oe,setTerminal:Q,lastReportedSize:c,pendingLocalSize:y,suppressLocalResizeUntil:M}}const ur={fontFamily:nr,fontSize:13,scrollback:1e4},nt="tmex:terminal-mode-cache";function hr(n,e){try{const t=sessionStorage.getItem(nt);return t?JSON.parse(t)[`${n}:${e}`]??null:null}catch{return null}}function fr(n,e,t){try{const s=sessionStorage.getItem(nt),r=s?JSON.parse(s):{},i=`${n}:${e}`;t?r[i]=t:delete r[i],sessionStorage.setItem(nt,JSON.stringify(r))}catch{}}function mr(){return{mouseX10:!1,mouseNormal:!0,mouseButton:!1,mouseAny:!1,mouseUtf8:!1,mouseSgr:!0,mouseSgrPixels:!1,mouseUrxvt:!1,altScroll:!0,altScreen1047:!1,altScreen1049:!1}}function pr(n,e){if(!e)return n?{...n,mouseX10:!1,mouseNormal:!1,mouseButton:!1,mouseAny:!1,mouseUtf8:!1,mouseSgrPixels:!1,mouseUrxvt:!1,altScreen1047:!1,altScreen1049:!1}:null;const t=mr();if(!n)return t;const s=n.mouseNormal||n.mouseButton||n.mouseAny;return{...n,mouseX10:!1,mouseUtf8:!1,mouseSgr:!0,mouseSgrPixels:!1,mouseUrxvt:!1,altScroll:!0,altScreen1047:!1,altScreen1049:!1,mouseNormal:s?n.mouseNormal:t.mouseNormal}}function wr(n){var t;const e=globalThis;e.__tmexE2eXterm=n,e.__tmexE2eTerminal=n,e.__tmexE2eTerminalEngine=Pt,e.__tmexE2eTerminalRenderer=((t=n.getRendererKind)==null?void 0:t.call(n))??null}function gr(n){if(!n)return;const e=globalThis;e.__tmexE2eTerminal!==n&&e.__tmexE2eXterm!==n||(e.__tmexE2eXterm=null,e.__tmexE2eTerminal=null,e.__tmexE2eTerminalEngine=null,e.__tmexE2eTerminalRenderer=null,e.__tmexE2eTerminalSelectionText=null)}const Gt=d.forwardRef(({deviceId:n,paneId:e,theme:t,inputMode:s,deviceConnected:r,isSelectionInvalid:i,onResize:o,onSync:l},u)=>{const[c,y]=d.useState(null),M=j(_=>_.sendInput),O=d.useMemo(()=>{switch(t){case"light":return Lt;default:return Nt}},[t]),P=d.useRef(null),x=d.useRef(null),T=d.useRef(null),g=d.useRef(n),h=d.useRef(e),k=d.useRef(n),D=d.useRef(e),q=d.useRef(r&&!i),F=d.useRef(s),A=d.useRef(O),z=d.useRef(!1),X=d.useRef(!1),oe=d.useRef(null),Q=d.useRef(!1),b=d.useCallback((_,S,B)=>{!(_!=null&&_.exportModeSnapshot)||!S||!B||fr(S,B,_.exportModeSnapshot())},[]),L=d.useCallback(()=>c,[c]);lr(P,L),d.useEffect(()=>{g.current=n,h.current=e,X.current=!1},[n,e]),d.useEffect(()=>{q.current=r&&!i},[r,i]),d.useEffect(()=>{F.current=s},[s]),d.useEffect(()=>{A.current=O},[O]);const G=d.useCallback(_=>{if(!_||s!=="direct"||!q.current)return;const S=g.current,B=h.current;!S||!B||M(S,B,_,!1)},[s,M]),{pendingLocalSize:V,scheduleResize:C,runPostSelectResize:v,setFitAddon:E,setTerminal:Y}=dr({deviceId:n,paneId:e,deviceConnected:r,isSelectionInvalid:i,onResize:o,onSync:l,getContainerRect:()=>{const _=P.current;if(!_)return null;const S=_.getBoundingClientRect();return{width:S.width,height:S.height}}});d.useEffect(()=>{let _=!1,S=null;return tr({...ur,theme:A.current,disableStdin:F.current==="editor"}).then(B=>{if(_){B.dispose();return}S=B,x.current&&B.open(x.current),wr(B),y(B)}),()=>{_=!0,y(null),gr(S),S==null||S.dispose()}},[]),d.useEffect(()=>{!c||!("setTheme"in c)||c.setTheme(O)},[c,O]),d.useEffect(()=>{!c||!("setDisableStdin"in c)||c.setDisableStdin(s==="editor")},[c,s]);const te=d.useMemo(()=>c?{onResetTerminal:_=>{g.current===_&&(b(c,k.current,D.current),Q.current=!0,c.reset(),z.current=!1,v())},onApplyHistory:(_,S,B)=>{var K;if(g.current!==_)return;const N=pr(hr(g.current,h.current),B);N&&((K=c.restoreModeSnapshot)==null||K.call(c,N));const $=B?rr(S):Ft(S);X.current=!0,c.write($),Q.current=!1,k.current=g.current,D.current=h.current,b(c,g.current,h.current)},onFlushBuffer:(_,S)=>{if(g.current===_){for(const B of S){const N=Ct(B,z.current);z.current=N.endedWithCR,c.write(N.normalized)}X.current&&(c.buffer.active.baseY<=1&&c.scrollToTop(),X.current=!1),k.current=g.current,D.current=h.current,b(c,g.current,h.current)}},onOutput:(_,S,B)=>{if(g.current!==_||h.current!==S)return;const N=Ct(B,z.current);z.current=N.endedWithCR,c.write(N.normalized),X.current&&(c.buffer.active.baseY<=1&&c.scrollToTop(),X.current=!1),k.current=g.current,D.current=h.current,b(c,g.current,h.current)}}:{},[c,b,v]);return d.useEffect(()=>{c?oe.current!==c&&(z.current=!1,k.current=g.current,D.current=h.current,oe.current=c):oe.current=null},[c]),d.useEffect(()=>{if(!(!c||!n||!e))return()=>{if(Q.current){Q.current=!1;return}b(c,k.current,D.current)}},[n,c,e,b]),d.useEffect(()=>{ut(te)},[te]),d.useEffect(()=>()=>{ut({})},[]),d.useEffect(()=>{if(!c){T.current=null,E(null),Y(null);return}const _=new er;return c.loadAddon(_),T.current=_,E(_),Y(c),v(),()=>{try{_.dispose()}finally{T.current=null,E(null),Y(null)}}},[c,v,E,Y]),d.useEffect(()=>{const _=P.current;if(!_)return;let S=null;const B=new ResizeObserver(()=>{S!==null&&cancelAnimationFrame(S),S=requestAnimationFrame(()=>{S=null,C("resize")})});return B.observe(_),()=>{B.disconnect(),S!==null&&cancelAnimationFrame(S)}},[C]),d.useEffect(()=>{if(!c||!n||!e)return;const _=c.onData(S=>{!r||i||G(S)});return c.attachCustomKeyEventHandler(S=>!r||i||S.type!=="keydown"||s!=="direct"?!0:S.shiftKey&&S.key==="Enter"?(S.preventDefault(),G("\x1B[13;2u"),!1):!0),()=>{_.dispose(),c.attachCustomKeyEventHandler(()=>!0)}},[c,r,i,s,G,n,e]),d.useImperativeHandle(u,()=>({write:_=>c==null?void 0:c.write(_),reset:()=>{c==null||c.reset(),z.current=!1},scrollToBottom:()=>c==null?void 0:c.scrollToBottom(),resize:(_,S)=>c==null?void 0:c.resize(_,S),getTerminal:()=>c??null,getSize:()=>c?{cols:Math.max(2,c.cols),rows:Math.max(2,c.rows)}:null,runPostSelectResize:()=>v(),scheduleResize:(_,S)=>C(_,S),calculateSizeFromContainer:()=>{var ae,ce,ee,ne,se,Se,Ue,ze,Ye,_e,J,Te,me,ve,Me,de;const _=P.current,S=c,B=T.current;if(!_||!S)return null;const N=_.getBoundingClientRect();if(N.width===0||N.height===0)return null;const $=S._core;let K;if(B)try{const re=B.proposeDimensions();if(re)K=Math.max(2,re.cols);else{const he=((ne=(ee=(ce=(ae=$==null?void 0:$._renderService)==null?void 0:ae.dimensions)==null?void 0:ce.css)==null?void 0:ee.cell)==null?void 0:ne.width)??9;K=Math.max(2,Math.floor(N.width/he))}}catch{const re=((ze=(Ue=(Se=(se=$==null?void 0:$._renderService)==null?void 0:se.dimensions)==null?void 0:Se.css)==null?void 0:Ue.cell)==null?void 0:ze.width)??9;K=Math.max(2,Math.floor(N.width/re))}else{const re=((Te=(J=(_e=(Ye=$==null?void 0:$._renderService)==null?void 0:Ye.dimensions)==null?void 0:_e.css)==null?void 0:J.cell)==null?void 0:Te.width)??9;K=Math.max(2,Math.floor(N.width/re))}const le=((de=(Me=(ve=(me=$==null?void 0:$._renderService)==null?void 0:me.dimensions)==null?void 0:ve.css)==null?void 0:Me.cell)==null?void 0:de.height)??17,H=Math.max(2,Math.floor(N.height/le));return{cols:K,rows:H}},getPendingLocalSize:()=>V.current}),[c,V,v,C]),m.jsx("div",{ref:P,className:"h-full w-full relative",style:{backgroundColor:O.background},"data-terminal-engine":Pt,children:m.jsx("div",{ref:x,className:"absolute inset-0"})})});Gt.displayName="Terminal";const yr=1200,Sr=2e3;function pe(n,e){return!n||!e?!1:n.windowId===e.windowId&&n.paneId===e.paneId}function Ut(n,e){const t=n.filter(s=>e-s.at<yr);return t.length===0?null:t.reduce((s,r)=>r.at>s.at?r:s)}function Ce(n,e=Date.now()){return!n||e-n.at>Sr?null:n}function _r(n){const e=n.now??Date.now(),t=Ut(n.recentSelectRequests,e);if(t&&!pe(t,n.activePaneFromEvent)||pe(n.currentRoute,n.activePaneFromEvent)||pe(n.lastHandledActive,n.activePaneFromEvent))return!0;const s=Ce(n.pendingUserSelection,e);return!!(s&&!pe(s,n.activePaneFromEvent))}function Tr(n){const e=n.now??Date.now(),t=Ut(n.recentSelectRequests,e),s=Ce(n.pendingUserSelection,e);return!!(s&&!pe(s,n.snapshotActive)||t&&!pe(t,n.snapshotActive))}function br(n){const e=n.now??Date.now(),t=Ce(n.pendingUserSelection,e);return!(t&&pe(t,n.routeTarget)||n.snapshotActive&&pe(n.snapshotActive,n.routeTarget))}function xr(){const n=st.getState().settings;return(n==null?void 0:n.siteName)||"tmex"}function vt(n){const e=n==null?void 0:n.trim();return e&&e.length>0?e:"?"}function zt({paneIdx:n,windowIdx:e,paneTitle:t,windowName:s,deviceName:r}){const i=e??"?",o=n??"?",l=vt(t??s),u=vt(r);return`${i}/${o}: ${l}@${u}`}function Er(n){const e=xr();return n!=null&&n.trim()?`[${e}]${n}`:e}function Rr(){if(typeof navigator>"u")return!1;const n=navigator.userAgent,e=/iPad|iPhone|iPod/.test(n),t=navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1;return e||t}const Cr=[{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:"`"}],Mt=d.memo(function({onSend:e,onFocusEditor:t,disabled:s,isMobile:r,inputMode:i}){return m.jsx("div",{className:"terminal-shortcuts-strip my-2 bg-muted rounded-xl","data-testid":"terminal-shortcuts-strip",children:m.jsx("div",{className:"shortcut-row flex items-center gap-1.5 p-2 overflow-x-auto scrollbar-thin","data-testid":"editor-shortcuts-row",children:Cr.map(o=>m.jsx(we,{variant:"secondary",size:"sm",className:"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}`,onPointerDown:l=>l.preventDefault(),onClick:()=>{e(o.payload),r&&i==="editor"&&(t==null||t())},disabled:s,children:o.label},o.key))})})});function Or(){var dt;const{t:n}=Dt(),{deviceId:e,windowId:t,paneId:s}=rt(),r=Qt(),i=d.useRef(null),o=d.useRef(null),l=d.useRef(null),u=d.useRef(null),c=d.useRef(!1),y=d.useRef(!1),M=d.useRef(null),O=j(a=>a.selectPane),P=j(a=>e?a.snapshots[e]:void 0),x=j(a=>{var p;return e?(p=a.deviceErrors)==null?void 0:p[e]:void 0}),T=j(a=>{var p;return e?((p=a.deviceConnected)==null?void 0:p[e])??!1:!1}),g=st(a=>{var p;return((p=a.settings)==null?void 0:p.siteName)??"tmex"}),h=d.useMemo(()=>it(s),[s]),k=d.useMemo(()=>e&&h?`${e}:${h}`:null,[e,h]),[D,q]=d.useState(!1),[F,A]=d.useState(""),[z,X]=d.useState(!1),oe=d.useRef(!1),Q=!T||!h,[b,L]=d.useState(0),[G,V]=d.useState(0),[C,v]=d.useState(!1),E=ue(a=>a.inputMode),Y=ue(a=>a.theme),te=ue(a=>a.editorSendWithEnter),_=ue(a=>a.setEditorSendWithEnter),S=ue(a=>a.addEditorHistory),B=ue(a=>a.setEditorDraft),N=ue(a=>a.removeEditorDraft),$=ue(a=>k?a.editorDrafts[k]??"":""),K=d.useMemo(()=>Rr(),[]),le=D&&E==="editor"&&K&&z,H=(dt=P==null?void 0:P.session)==null?void 0:dt.windows,ae=Y==="light"?Lt:Nt,{data:ce}=Zt({queryKey:["devices"],queryFn:async()=>{const a=await fetch("/api/devices");if(!a.ok)throw new Error("Failed to fetch devices");return a.json()},throwOnError:!1}),ee=d.useMemo(()=>{if(e)return ce==null?void 0:ce.devices.find(a=>a.id===e)},[e,ce==null?void 0:ce.devices]),ne=d.useMemo(()=>{if(!(!t||!H))return H.find(a=>a.id===t)},[t,H]),se=d.useMemo(()=>{if(!(!h||!ne))return ne.panes.find(a=>a.id===h)},[h,ne]),Se=!!H,_e=!!(Se&&!!t&&!ne||Se&&!!t&&!!h&&!!ne&&!se?n("wsError.checkGateway"):null),J=!!(T&&h&&!_e),Te=d.useMemo(()=>{if(!ne||!se)return null;const a=(ee==null?void 0:ee.name)??e;return zt({paneIdx:se.index,windowIdx:ne.index,paneTitle:se.title,windowName:ne.name,deviceName:a})},[ee==null?void 0:ee.name,e,se,ne]),me=d.useMemo(()=>{if(!H||H.length===0)return null;const a=H.find(f=>f.active),p=a==null?void 0:a.panes.find(f=>f.active);return!a||!p?null:{windowId:a.id,paneId:p.id}},[H]),ve=d.useCallback((a,p)=>{!e||!h||j.getState().resizePane(e,h,a,p)},[e,h]),Me=d.useCallback((a,p)=>{!e||!h||j.getState().syncPaneSize(e,h,a,p)},[e,h]),de=d.useCallback((a,p)=>{const f=u.current,R=(f==null?void 0:f.calculateSizeFromContainer())??(f==null?void 0:f.getSize())??void 0;if(R)return R;if(!a||!p||!H)return;const W=H.find(ie=>ie.id===a),U=W==null?void 0:W.panes.find(ie=>ie.id===p);if(!(!U||U.width<=1||U.height<=1))return{cols:U.width,rows:U.height}},[H]);d.useEffect(()=>{const a=()=>{q(window.innerWidth<768||"ontouchstart"in window)};return a(),window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]),d.useEffect(()=>{if(!D||!K||y.current)return;y.current=!0;const a=()=>{window.scrollTo(0,1)},p=window.requestAnimationFrame(a),f=window.setTimeout(a,120),R=window.setTimeout(a,420);return()=>{window.cancelAnimationFrame(p),window.clearTimeout(f),window.clearTimeout(R)}},[K,D]),d.useEffect(()=>{E!=="editor"&&X(!1)},[E]),d.useEffect(()=>{var R,W;if(!(D&&K&&E==="editor"&&z)){L(0);return}let a=null;const p=()=>{const U=window.visualViewport,ie=(U==null?void 0:U.height)??window.innerHeight,xe=(U==null?void 0:U.offsetTop)??0,qt=Math.max(0,Math.round(window.innerHeight-ie-xe));L(qt)},f=()=>{a===null&&(a=window.requestAnimationFrame(()=>{a=null,p()}))};return p(),(R=window.visualViewport)==null||R.addEventListener("resize",f),(W=window.visualViewport)==null||W.addEventListener("scroll",f),window.addEventListener("resize",f),()=>{var U,ie;(U=window.visualViewport)==null||U.removeEventListener("resize",f),(ie=window.visualViewport)==null||ie.removeEventListener("scroll",f),window.removeEventListener("resize",f),a!==null&&window.cancelAnimationFrame(a)}},[E,z,K,D]),d.useEffect(()=>{if(!le){V(0);return}const a=o.current;if(!a)return;const p=()=>{V(Math.ceil(a.getBoundingClientRect().height))};p();const f=new ResizeObserver(p);return f.observe(a),()=>f.disconnect()},[le]),d.useEffect(()=>{e&&(c.current=!1,Ve.current=null,be.current=null,M.current=null,re.current=[])},[e]),d.useEffect(()=>{T||(c.current=!1)},[T]),d.useEffect(()=>{if(!e||!T||!t||!H)return;if(H.length===0){r("/devices",{replace:!0});return}const a=H.find(f=>f.id===t);if(!a)return;if(!h){const f=a.panes.find(R=>R.active)??a.panes[0];f&&r(`/devices/${e}/windows/${t}/panes/${ge(f.id)}`,{replace:!0});return}if(!a.panes.find(f=>f.id===h)){const f=a.panes.find(R=>R.active)??a.panes[0];f&&r(`/devices/${e}/windows/${t}/panes/${ge(f.id)}`,{replace:!0});return}},[e,T,H,t,h,r]),d.useEffect(()=>{if(!e||!T||!H||H.length===0||t&&h||c.current)return;const a=H.find(f=>f.active)??H[0],p=a.panes.find(f=>f.active)??a.panes[0];p&&(c.current=!0,r(`/devices/${e}/windows/${a.id}/panes/${ge(p.id)}`,{replace:!0}))},[T,e,r,h,t,H]),d.useEffect(()=>{if(!e||!t||!h||Q||!T)return;const a=j.getState().selectedPanes[e];if(a&&a.windowId===t&&a.paneId===h)return;const p=de(t,h);he(t,h),O(e,t,h,p)},[T,e,de,Q,h,O,t]),d.useEffect(()=>{if(!e||!T||!t||!h)return;const a={windowId:t,paneId:h};br({routeTarget:a,snapshotActive:me,pendingUserSelection:M.current})&&(M.current={windowId:a.windowId,paneId:a.paneId,at:Date.now()})},[T,e,h,me,t]);const re=d.useRef([]),he=d.useCallback((a,p)=>{const f=Date.now(),R=[...re.current.filter(W=>f-W.at<2e3),{windowId:a,paneId:p,at:f}];re.current=R.slice(-8)},[]),Z=j(a=>e?a.activePaneFromEvent[e]:void 0),Ve=d.useRef(null);d.useEffect(()=>{if(!e||!T||!t||!h||!Z)return;const a=Date.now(),p=Ce(M.current,a);if(M.current=p,_r({now:a,pendingUserSelection:p,activePaneFromEvent:Z,currentRoute:{windowId:t,paneId:h},recentSelectRequests:re.current,lastHandledActive:Ve.current}))return;Ve.current={...Z},p&&p.windowId===Z.windowId&&p.paneId===Z.paneId&&(M.current=null);const f=de(Z.windowId,Z.paneId);he(Z.windowId,Z.paneId),O(e,Z.windowId,Z.paneId,f),r(`/devices/${e}/windows/${Z.windowId}/panes/${ge(Z.paneId)}`,{replace:!0})},[e,T,t,h,Z,he,de,O,r]);const be=d.useRef(null);d.useEffect(()=>{if(!e||!T||!H||H.length===0)return;const a=re.current,p=H.find(xe=>xe.active);if(!p)return;const f=p.panes.find(xe=>xe.active);if(!f)return;const R={windowId:p.id,paneId:f.id},W=Date.now(),U=Ce(M.current,W);if(M.current=U,Tr({now:W,pendingUserSelection:U,snapshotActive:R,recentSelectRequests:a})||be.current&&be.current.windowId===R.windowId&&be.current.paneId===R.paneId||(be.current={...R},U&&U.windowId===R.windowId&&U.paneId===R.paneId&&(M.current=null),t===R.windowId&&h===R.paneId))return;const ie=de(R.windowId,R.paneId);he(R.windowId,R.paneId),O(e,R.windowId,R.paneId,ie),r(`/devices/${e}/windows/${R.windowId}/panes/${ge(R.paneId)}`,{replace:!0})},[e,T,H,t,h,he,de,O,r]);const $e=j(a=>e?a.pendingCreateWindowAt[e]:void 0);d.useEffect(()=>{if(!e||!T||!$e)return;const a=5e3,p=Date.now()-$e;if(p>a){j.getState().clearPendingCreateWindow(e);return}if(!me){const W=window.setTimeout(()=>{j.getState().clearPendingCreateWindow(e)},a-p);return()=>window.clearTimeout(W)}const f=me;if(t===f.windowId&&h===f.paneId){const W=window.setTimeout(()=>{j.getState().clearPendingCreateWindow(e)},a-p);return()=>window.clearTimeout(W)}M.current={windowId:f.windowId,paneId:f.paneId,at:Date.now()};const R=de(f.windowId,f.paneId);he(f.windowId,f.paneId),O(e,f.windowId,f.paneId,R),r(`/devices/${e}/windows/${f.windowId}/panes/${ge(f.paneId)}`,{replace:!0}),j.getState().clearPendingCreateWindow(e)},[e,T,$e,me,t,h,he,de,O,r]),d.useEffect(()=>{if(!J||!se||Q)return;const a=u.current,p=a==null?void 0:a.getTerminal();if(!p)return;const f=Math.max(2,Math.floor(se.width||0)),R=Math.max(2,Math.floor(se.height||0));if(!f||!R)return;const W=Date.now(),U={cols:f,rows:R},ie=(a==null?void 0:a.getPendingLocalSize())??null;ar({now:W,remoteSize:U,pendingLocalSize:ie})&&(p.cols===f&&p.rows===R||p.resize(f,R))},[J,Q,se]),d.useEffect(()=>{const a=window.requestAnimationFrame(()=>{var f;(f=u.current)==null||f.scrollToBottom()}),p=window.setTimeout(()=>{var f;(f=u.current)==null||f.scrollToBottom()},120);return()=>{window.cancelAnimationFrame(a),window.clearTimeout(p)}},[E]),d.useEffect(()=>{x!=null&&x.message&&Ke.error(x.message)},[x==null?void 0:x.message]),d.useEffect(()=>(document.title=Er(Te),()=>{document.title=g}),[g,Te]),d.useEffect(()=>{const a=()=>{var p;(p=u.current)==null||p.scrollToBottom()};return window.addEventListener("tmex:jump-to-latest",a),()=>{window.removeEventListener("tmex:jump-to-latest",a)}},[]),d.useEffect(()=>{const a=p=>{const{deviceId:f,windowId:R,paneId:W}=p.detail;f===e&&(M.current={windowId:R,paneId:W,at:Date.now()})};return window.addEventListener("tmex:user-initiated-selection",a),()=>{window.removeEventListener("tmex:user-initiated-selection",a)}},[e]),d.useEffect(()=>{A($)},[$]);const ct=d.useCallback(a=>{if(!e||!h||!J)return;j.getState().sendInput(e,h,a,!1)},[J,e,h]),Yt=d.useCallback(()=>{if(!J){Ke.error(n("wsError.checkGateway"));return}if(!e||!h||!F.trim())return;v(!0),window.setTimeout(()=>v(!1),150);const a=te?`${F}\r`:F;j.getState().sendInput(e,h,a,!1),S(F),k&&N(k),A("")},[S,J,e,k,te,F,N,h,n]),Vt=d.useCallback(()=>{if(!J){Ke.error(n("wsError.checkGateway"));return}if(!e||!h||!F.trim())return;v(!0),window.setTimeout(()=>v(!1),150);const a=F.split(/\r?\n/),p=j.getState();for(const f of a)f.trim()&&p.sendInput(e,h,`${f}\r`,!1);S(F),k&&N(k),A("")},[S,J,e,k,F,N,h,n]),$t=d.useCallback(a=>{if(X(!0),!(D&&K))return;const p=a.currentTarget;window.requestAnimationFrame(()=>{p.scrollIntoView({block:"nearest",inline:"nearest"})}),window.setTimeout(()=>{window.scrollTo(0,1)},60)},[K,D]),Kt=d.useCallback(()=>{X(!1)},[]),Wt=d.useCallback(()=>{var a;(a=l.current)==null||a.focus({preventScroll:!0})},[]);if(!e)return m.jsx("div",{className:"flex h-full items-center justify-center p-4",children:m.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-3 text-sm text-muted-foreground",children:n("device.noDevices")})});const jt=!T&&!x;return m.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background","data-testid":"device-page",children:[m.jsxs("div",{className:`flex-1 relative overflow-hidden min-h-0 min-w-0 ${D&&E==="editor"&&!le?"pb-1":""}`,style:{paddingBottom:le?`${G+60}px`:void 0},children:[m.jsx("div",{className:"h-full px-3 py-1 min-h-0 min-w-0 w-full relative flex rounded-xl",style:{backgroundColor:ae.background},children:T&&h?m.jsx("div",{ref:i,className:"flex-1 h-full min-h-0 w-full",children:m.jsx(Gt,{ref:u,deviceId:e,paneId:h,theme:Y,inputMode:E,deviceConnected:T,isSelectionInvalid:_e,onResize:ve,onSync:Me},`${e}:${h}`)}):m.jsx("div",{className:"absolute inset-0 flex flex-col items-center justify-center p-8 text-center",children:m.jsx("div",{className:"max-w-sm space-y-4",children:T?t?m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:m.jsx(We,{className:"h-6 w-6 text-muted-foreground animate-spin"})}),m.jsx("h3",{className:"text-lg font-medium",children:n("terminal.connecting")})]}):m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:m.jsx("span",{className:"text-2xl text-muted-foreground",children:"📋"})}),m.jsx("h3",{className:"text-lg font-medium",children:n("window.noWindowSelected")}),m.jsx("p",{className:"text-sm text-muted-foreground",children:n("window.selectWindowToStart")})]}):m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:m.jsx("span",{className:"text-2xl text-muted-foreground",children:"🔌"})}),m.jsx("h3",{className:"text-lg font-medium",children:n("device.disconnected")}),m.jsx("p",{className:"text-sm text-muted-foreground",children:n("device.connectToStart")})]})})})}),jt&&m.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/85 backdrop-blur-sm","data-testid":"terminal-status-overlay",children:m.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:[m.jsx("div",{className:"h-7 w-7 rounded-full border-2 border-primary border-t-transparent animate-spin"}),m.jsx("span",{className:"text-xs text-muted-foreground","data-testid":"terminal-status-text",children:n("terminal.connecting")})]})})]}),E==="direct"&&m.jsx("div",{className:"",children:m.jsx(Mt,{onSend:ct,disabled:!J,isMobile:D,inputMode:E})}),E==="editor"&&m.jsxs("div",{ref:o,className:`editor-mode-input bg-card/85 backdrop-blur-sm ${le?"fixed left-0 right-0 z-50":""}`,style:le?{bottom:`${b}px`}:void 0,children:[D&&m.jsx(Mt,{onSend:ct,onFocusEditor:Wt,disabled:!J,isMobile:D,inputMode:E}),m.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:F,onChange:a=>{const p=a.target.value;if(A(p),!!k){if(p){B(k,p);return}N(k)}},placeholder:n("terminal.inputPlaceholder"),onFocus:$t,onBlur:Kt,onCompositionStart:()=>{oe.current=!0},onCompositionEnd:()=>{oe.current=!1}}),m.jsx("div",{className:"actions mt-2",children:m.jsxs("div",{className:"send-row flex flex-wrap items-center justify-end gap-2","data-testid":"editor-send-row",children:[m.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:[m.jsx(dn,{size:"sm",checked:te,onCheckedChange:a=>_(!!a)}),m.jsx("span",{children:n("terminal.editorSendWithEnter")})]}),m.jsxs(we,{variant:"outline",size:"sm","data-testid":"editor-clear",onPointerDown:a=>a.preventDefault(),onClick:()=>{var a;A(""),k&&N(k),D&&E==="editor"&&((a=l.current)==null||a.focus({preventScroll:!0}))},title:n("terminal.clear"),children:[m.jsx(en,{className:"h-4 w-4"}),n("terminal.clear")]}),m.jsxs(we,{variant:"secondary",size:"sm","data-testid":"editor-send-line-by-line",onPointerDown:a=>a.preventDefault(),onClick:()=>{var a;Vt(),D&&E==="editor"&&((a=l.current)==null||a.focus({preventScroll:!0}))},disabled:!J||C,children:[C?m.jsx(We,{className:"h-4 w-4 animate-spin"}):m.jsx(ht,{className:"h-4 w-4"}),n("terminal.editorSendLineByLine")]}),m.jsxs(we,{variant:"default",size:"sm","data-testid":"editor-send",onPointerDown:a=>a.preventDefault(),onClick:()=>{var a;Yt(),D&&E==="editor"&&((a=l.current)==null||a.focus({preventScroll:!0}))},disabled:!J||C,children:[C?m.jsx(We,{className:"h-4 w-4 animate-spin"}):m.jsx(ht,{className:"h-4 w-4"}),n("common.send")]})]})})]})]})}function kr(){const{deviceId:n,windowId:e,paneId:t}=rt(),s=t?it(t):void 0,r=j(y=>y.snapshots),i=st(y=>{var M;return((M=y.settings)==null?void 0:M.siteName)??"tmex"}),o=n?r[n]:void 0,l=d.useMemo(()=>{var y;if(!(!e||!((y=o==null?void 0:o.session)!=null&&y.windows)))return o.session.windows.find(M=>M.id===e)},[e,o]),u=d.useMemo(()=>{if(!(!s||!l))return l.panes.find(y=>y.id===s)},[s,l]),c=d.useMemo(()=>l&&u?zt({paneIdx:u.index,windowIdx:l.index,paneTitle:u.title,windowName:l.name,deviceName:i}):n??"",[l,u,i,n]);return m.jsx(m.Fragment,{children:c})}function Ir(){const{t:n}=Dt(),{deviceId:e,paneId:t}=rt(),s=t?it(t):void 0,r=ue(x=>x.inputMode),i=ue(x=>x.setInputMode),o=j(x=>{var T;return e?((T=x.deviceConnected)==null?void 0:T[e])??!1:!1}),[l,u]=d.useState(!1),c=!!(s&&o),y=()=>{i(r==="direct"?"editor":"direct")},M=()=>{window.dispatchEvent(new CustomEvent("tmex:jump-to-latest"))},O=()=>{u(!0)},P=()=>{window.location.reload()};return m.jsxs(m.Fragment,{children:[m.jsx(we,{variant:"ghost",size:"icon-sm",onClick:O,"aria-label":n("nav.refreshPage"),title:n("nav.refreshPage"),children:m.jsx(wn,{className:"h-4 w-4"})}),m.jsx(we,{variant:"ghost",size:"icon-sm",onClick:y,disabled:!c,"data-testid":"terminal-input-mode-toggle","aria-label":n(r==="direct"?"nav.switchToEditor":"nav.switchToDirect"),title:n(r==="direct"?"nav.switchToEditor":"nav.switchToDirect"),children:r==="direct"?m.jsx(mn,{className:"h-4 w-4"}):m.jsx(yn,{className:"h-4 w-4"})}),m.jsx(we,{variant:"ghost",size:"icon-sm",onClick:M,disabled:!c,"aria-label":n("nav.jumpToLatest"),title:n("nav.jumpToLatest"),children:m.jsx(hn,{className:"h-4 w-4"})}),m.jsx(tn,{open:l,onOpenChange:u,children:m.jsxs(nn,{children:[m.jsxs(sn,{children:[m.jsx(rn,{children:n("nav.refreshPage")}),m.jsx(on,{children:n("nav.refreshPageConfirm")})]}),m.jsxs(ln,{children:[m.jsx(an,{onClick:()=>u(!1),children:n("common.cancel")}),m.jsx(cn,{onClick:P,children:n("common.confirm")})]})]})})]})}export{Ir as PageActions,kr as PageTitle,Or as default};
|
|
26
|
+
//# sourceMappingURL=DevicePage-B9rZioAr.js.map
|