tmex-cli 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (19) hide show
  1. package/dist/runtime/server.js +150 -10
  2. package/package.json +1 -1
  3. package/resources/fe-dist/assets/DevicePage-BGPoxSI1.js +36 -0
  4. package/resources/fe-dist/assets/DevicePage-BGPoxSI1.js.map +1 -0
  5. package/resources/fe-dist/assets/{DevicesPage-_g8yXgKX.js → DevicesPage-ImyBiwEt.js} +2 -2
  6. package/resources/fe-dist/assets/{DevicesPage-_g8yXgKX.js.map → DevicesPage-ImyBiwEt.js.map} +1 -1
  7. package/resources/fe-dist/assets/{SettingsPage-Bi8Kez5a.js → SettingsPage-CyMAR4ec.js} +2 -2
  8. package/resources/fe-dist/assets/{SettingsPage-Bi8Kez5a.js.map → SettingsPage-CyMAR4ec.js.map} +1 -1
  9. package/resources/fe-dist/assets/{index-kXpemMRY.js → index-qxM5NVWd.js} +3 -3
  10. package/resources/fe-dist/assets/{index-kXpemMRY.js.map → index-qxM5NVWd.js.map} +1 -1
  11. package/resources/fe-dist/assets/{select-v4N0NzCz.js → select-CALI7PWC.js} +2 -2
  12. package/resources/fe-dist/assets/{select-v4N0NzCz.js.map → select-CALI7PWC.js.map} +1 -1
  13. package/resources/fe-dist/assets/{switch-BJu9baQM.js → switch-CkhOAzoZ.js} +2 -2
  14. package/resources/fe-dist/assets/{switch-BJu9baQM.js.map → switch-CkhOAzoZ.js.map} +1 -1
  15. package/resources/fe-dist/assets/{useValueChanged-D47LrxaP.js → useValueChanged-WtzSkCNQ.js} +2 -2
  16. package/resources/fe-dist/assets/{useValueChanged-D47LrxaP.js.map → useValueChanged-WtzSkCNQ.js.map} +1 -1
  17. package/resources/fe-dist/index.html +1 -1
  18. package/resources/fe-dist/assets/DevicePage-CQuQ0yeD.js +0 -36
  19. package/resources/fe-dist/assets/DevicePage-CQuQ0yeD.js.map +0 -1
@@ -22493,6 +22493,7 @@ var config = {
22493
22493
  notificationThrottleSecondsDefault: Number.parseInt(getEnv("TMEX_NOTIFICATION_THROTTLE_SECONDS", "3"), 10),
22494
22494
  tmuxAllowPassthrough: getBooleanEnv("TMEX_TMUX_ALLOW_PASSTHROUGH", false),
22495
22495
  tmuxTermProgram: getEnv("TMEX_TMUX_TERM_PROGRAM", "ghostty"),
22496
+ tmuxWindowStyle: getEnv("TMEX_TMUX_WINDOW_STYLE", "fg=#d0d0d0,bg=#262626"),
22496
22497
  sshReconnectMaxRetriesDefault: Number.parseInt(getEnv("TMEX_SSH_RECONNECT_MAX_RETRIES", "2"), 10),
22497
22498
  sshReconnectDelaySecondsDefault: Number.parseInt(getEnv("TMEX_SSH_RECONNECT_DELAY_SECONDS", "10"), 10),
22498
22499
  languageDefault: getEnv("TMEX_DEFAULT_LANGUAGE", "en_US"),
@@ -52530,6 +52531,39 @@ function buildLocalTmuxEnv(resolvedPath, baseEnv = process.env) {
52530
52531
  return nextEnv;
52531
52532
  }
52532
52533
 
52534
+ // ../../apps/gateway/src/tmux-client/capture-history.ts
52535
+ var PANE_SCREEN_INFO_FORMAT = "#{alternate_on} #{cursor_x} #{cursor_y} #{pane_height}";
52536
+ function parsePaneScreenInfo(stdout) {
52537
+ const parts = stdout.trim().split(/\s+/);
52538
+ const toInt = (value) => {
52539
+ if (value === undefined) {
52540
+ return null;
52541
+ }
52542
+ const parsed = Number.parseInt(value, 10);
52543
+ return Number.isNaN(parsed) || parsed < 0 ? null : parsed;
52544
+ };
52545
+ return {
52546
+ alternateScreen: parts[0] === "1",
52547
+ cursorX: toInt(parts[1]),
52548
+ cursorY: toInt(parts[2]),
52549
+ paneHeight: toInt(parts[3])
52550
+ };
52551
+ }
52552
+ function appendCursorRestore(history, info) {
52553
+ const { cursorX, cursorY, paneHeight } = info;
52554
+ if (cursorX === null || cursorY === null || paneHeight === null || paneHeight < 1) {
52555
+ return history;
52556
+ }
52557
+ const trimmed = history.endsWith(`
52558
+ `) ? history.slice(0, -1) : history;
52559
+ if (info.alternateScreen) {
52560
+ return `${trimmed}\x1B[${cursorY + 1};${cursorX + 1}H`;
52561
+ }
52562
+ const up = Math.min(Math.max(0, paneHeight - 1 - cursorY), paneHeight - 1);
52563
+ const moveUp = up > 0 ? `\x1B[${up}A` : "";
52564
+ return `${trimmed}${moveUp}\x1B[${cursorX + 1}G`;
52565
+ }
52566
+
52533
52567
  // ../../apps/gateway/src/tmux-client/control-mode-parser.ts
52534
52568
  var decoder = new TextDecoder;
52535
52569
  var MAX_LINE_BYTES = 4 * 1024 * 1024;
@@ -53359,6 +53393,20 @@ function isControlModeSupported(version2) {
53359
53393
  return version2.minor >= MIN_CONTROL_MODE_VERSION.minor;
53360
53394
  }
53361
53395
 
53396
+ // ../../apps/gateway/src/tmux-client/window-style.ts
53397
+ var WINDOW_STYLE_PATTERN = /^[A-Za-z0-9#=,]+$/;
53398
+ function resolveTmuxWindowStyle(value) {
53399
+ const style = value.trim();
53400
+ if (!style || style.toLowerCase() === "off") {
53401
+ return null;
53402
+ }
53403
+ if (!WINDOW_STYLE_PATTERN.test(style)) {
53404
+ console.warn(`[tmex] ignoring invalid TMEX_TMUX_WINDOW_STYLE: ${style}`);
53405
+ return null;
53406
+ }
53407
+ return style;
53408
+ }
53409
+
53362
53410
  // ../../apps/gateway/src/tmux-client/local-external-connection.ts
53363
53411
  var CONTROL_MAX_RESTARTS = 3;
53364
53412
  var CONTROL_RESTART_DELAY_MS = 500;
@@ -53623,6 +53671,52 @@ class LocalExternalTmuxConnection {
53623
53671
  ]);
53624
53672
  }
53625
53673
  }
53674
+ await this.runTmuxAllowFailure([
53675
+ "set-environment",
53676
+ "-t",
53677
+ this.sessionName,
53678
+ "COLORTERM",
53679
+ "truecolor"
53680
+ ]);
53681
+ await this.configureWindowStyle();
53682
+ }
53683
+ async configureWindowStyle() {
53684
+ const windowStyle = resolveTmuxWindowStyle(config.tmuxWindowStyle);
53685
+ if (!windowStyle) {
53686
+ return;
53687
+ }
53688
+ await this.runTmuxAllowFailure([
53689
+ "set-hook",
53690
+ "-t",
53691
+ this.sessionName,
53692
+ "after-new-window",
53693
+ `set-option -w window-style '${windowStyle}'`
53694
+ ]);
53695
+ const windows = await this.runTmuxAllowFailure([
53696
+ "list-windows",
53697
+ "-t",
53698
+ this.sessionName,
53699
+ "-F",
53700
+ "#{window_id}"
53701
+ ]);
53702
+ if (windows.exitCode !== 0) {
53703
+ return;
53704
+ }
53705
+ for (const line of windows.stdout.split(`
53706
+ `)) {
53707
+ const windowId = line.trim();
53708
+ if (!windowId) {
53709
+ continue;
53710
+ }
53711
+ await this.runTmuxAllowFailure([
53712
+ "set-option",
53713
+ "-w",
53714
+ "-t",
53715
+ windowId,
53716
+ "window-style",
53717
+ windowStyle
53718
+ ]);
53719
+ }
53626
53720
  }
53627
53721
  async assertControlModeSupport() {
53628
53722
  const result = await this.runTmuxAllowFailure(["-V"]);
@@ -53861,13 +53955,13 @@ class LocalExternalTmuxConnection {
53861
53955
  await this.requestSnapshotInternal();
53862
53956
  }
53863
53957
  async capturePaneHistory(paneId) {
53864
- const mode = (await this.runTmux(["display-message", "-p", "-t", paneId, "#{alternate_on}"], true)).stdout.trim();
53865
- const alternateScreen = mode === "1";
53866
- const normal = (await this.runTmux(["capture-pane", "-t", paneId, "-S", "-", "-E", "-", "-e", "-N", "-p"], true)).stdout;
53867
- const alternate = (await this.runTmux(["capture-pane", "-t", paneId, "-a", "-S", "-", "-E", "-", "-e", "-N", "-p", "-q"], true)).stdout;
53958
+ const screenInfo = parsePaneScreenInfo((await this.runTmux(["display-message", "-p", "-t", paneId, PANE_SCREEN_INFO_FORMAT], true)).stdout);
53959
+ const alternateScreen = screenInfo.alternateScreen;
53960
+ const normal = (await this.runTmux(["capture-pane", "-t", paneId, "-S", "-", "-E", "-", "-e", "-J", "-N", "-p"], true)).stdout;
53961
+ const alternate = (await this.runTmux(["capture-pane", "-t", paneId, "-a", "-S", "-", "-E", "-", "-e", "-J", "-N", "-p", "-q"], true)).stdout;
53868
53962
  const history = alternateScreen ? hasRenderableTerminalContent(normal) ? normal : alternate : normal || alternate;
53869
53963
  if (history) {
53870
- this.callbacks.onTerminalHistory(paneId, history, alternateScreen);
53964
+ this.callbacks.onTerminalHistory(paneId, appendCursorRestore(history, screenInfo), alternateScreen);
53871
53965
  }
53872
53966
  }
53873
53967
  async requestSnapshotInternal() {
@@ -54806,6 +54900,52 @@ class SshExternalTmuxConnection {
54806
54900
  ]);
54807
54901
  }
54808
54902
  }
54903
+ await this.runTmuxAllowFailure([
54904
+ "set-environment",
54905
+ "-t",
54906
+ this.sessionName,
54907
+ "COLORTERM",
54908
+ "truecolor"
54909
+ ]);
54910
+ await this.configureWindowStyle();
54911
+ }
54912
+ async configureWindowStyle() {
54913
+ const windowStyle = resolveTmuxWindowStyle(config.tmuxWindowStyle);
54914
+ if (!windowStyle) {
54915
+ return;
54916
+ }
54917
+ await this.runTmuxAllowFailure([
54918
+ "set-hook",
54919
+ "-t",
54920
+ this.sessionName,
54921
+ "after-new-window",
54922
+ `set-option -w window-style '${windowStyle}'`
54923
+ ]);
54924
+ const windows = await this.runTmuxAllowFailure([
54925
+ "list-windows",
54926
+ "-t",
54927
+ this.sessionName,
54928
+ "-F",
54929
+ "#{window_id}"
54930
+ ]);
54931
+ if (windows.exitCode !== 0) {
54932
+ return;
54933
+ }
54934
+ for (const line of windows.stdout.split(`
54935
+ `)) {
54936
+ const windowId = line.trim();
54937
+ if (!windowId) {
54938
+ continue;
54939
+ }
54940
+ await this.runTmuxAllowFailure([
54941
+ "set-option",
54942
+ "-w",
54943
+ "-t",
54944
+ windowId,
54945
+ "window-style",
54946
+ windowStyle
54947
+ ]);
54948
+ }
54809
54949
  }
54810
54950
  async ensureGhosttyTerminfo() {
54811
54951
  try {
@@ -55015,13 +55155,13 @@ class SshExternalTmuxConnection {
55015
55155
  await this.requestSnapshotInternal();
55016
55156
  }
55017
55157
  async capturePaneHistory(paneId) {
55018
- const mode = (await this.runTmux(["display-message", "-p", "-t", paneId, "#{alternate_on}"], true)).stdout.trim();
55019
- const alternateScreen = mode === "1";
55020
- const normal = (await this.runTmux(["capture-pane", "-t", paneId, "-S", "-", "-E", "-", "-e", "-N", "-p"], true, 30000)).stdout;
55021
- const alternate = (await this.runTmux(["capture-pane", "-t", paneId, "-a", "-S", "-", "-E", "-", "-e", "-N", "-p", "-q"], true, 30000)).stdout;
55158
+ const screenInfo = parsePaneScreenInfo((await this.runTmux(["display-message", "-p", "-t", paneId, PANE_SCREEN_INFO_FORMAT], true)).stdout);
55159
+ const alternateScreen = screenInfo.alternateScreen;
55160
+ const normal = (await this.runTmux(["capture-pane", "-t", paneId, "-S", "-", "-E", "-", "-e", "-J", "-N", "-p"], true, 30000)).stdout;
55161
+ const alternate = (await this.runTmux(["capture-pane", "-t", paneId, "-a", "-S", "-", "-E", "-", "-e", "-J", "-N", "-p", "-q"], true, 30000)).stdout;
55022
55162
  const history = alternateScreen ? hasRenderableTerminalContent2(normal) ? normal : alternate : normal || alternate;
55023
55163
  if (history) {
55024
- this.callbacks.onTerminalHistory(paneId, history, alternateScreen);
55164
+ this.callbacks.onTerminalHistory(paneId, appendCursorRestore(history, screenInfo), alternateScreen);
55025
55165
  }
55026
55166
  }
55027
55167
  async requestSnapshotInternal() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tmex-cli",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "tmex": "./bin/tmex.js",
@@ -0,0 +1,36 @@
1
+ var sn=Object.defineProperty;var rn=(n,e,t)=>e in n?sn(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var w=(n,e,t)=>rn(n,typeof e!="symbol"?e+"":e,t);import{c as Te,u as Ke,j as h,X as on,r as d,aN as ee,by as mt,f as xe,b as lt,bz as at,bA as ln,bB as ct,d as he,e as an,bC as be,B as ge}from"./index-qxM5NVWd.js";import{T as cn,A as dn,a as un,b as hn,c as fn,d as mn,e as pn,f as wn,g as yn}from"./useValueChanged-WtzSkCNQ.js";import{L as Xe,S as gn,a as pt}from"./switch-CkhOAzoZ.js";/**
2
+ * @license lucide-react v0.564.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const Sn=[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]],_n=Te("arrow-down-to-line",Sn);/**
7
+ * @license lucide-react v0.564.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const bn=[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]],xn=Te("clipboard-paste",bn);/**
12
+ * @license lucide-react v0.564.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const Tn=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],En=Te("copy",Tn);/**
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 Rn=[["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"}]],Cn=Te("keyboard",Rn);/**
22
+ * @license lucide-react v0.564.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const vn=[["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"}]],Mn=Te("refresh-cw",vn);/**
27
+ * @license lucide-react v0.564.0 - ISC
28
+ *
29
+ * This source code is licensed under the ISC license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */const Dn=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],An=Te("smartphone",Dn);function On(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 kn{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`,a=`${o}px`;if(this.mainCanvas.style.width===u&&this.mainCanvas.style.height===a)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,a=o.style.inverse?o.bgColor??t.background:o.fgColor??t.foreground,S=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,S,this.cellDimensions.height)),!(!o.text||o.style.invisible)&&(this.mainContext.font=this.resolveFont(o.style),this.mainContext.fillStyle=this.toCss(a),this.mainContext.fillText(o.text,l,s),o.style.underline>0&&this.mainContext.fillRect(l,s+this.cellDimensions.height-2,Math.max(S-1,1),1),o.style.strikethrough&&this.mainContext.fillRect(l,s+this.cellDimensions.height*.55,Math.max(S-1,1),1),o.style.overline&&this.mainContext.fillRect(l,s+1,Math.max(S-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,a=this.toCss(u);this.cursorContext.fillStyle=a,this.cursorContext.strokeStyle=a,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=On(e);return this.colorCache.set(t,r),r}}const In=0,Nn={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},dt={Backquote:"`",Backslash:"\\",BracketLeft:"[",BracketRight:"]",Comma:",",Equal:"=",Minus:"-",Period:".",Quote:"'",Semicolon:";",Slash:"/",Space:" ",IntlBackslash:"\\",IntlYen:"¥",IntlRo:"\\"};for(let n=0;n<=9;n+=1)dt[`Digit${n}`]=String(n);for(let n=0;n<26;n+=1){const e=String.fromCharCode(65+n),t=String.fromCharCode(97+n);dt[`Key${e}`]=t}function wt(n){return Nn[n]??In}function Bn(n){const e=dt[n];return e?e.codePointAt(0)??null:null}const Ee=0,Pn=-2,Hn=1,Ln=2,Fn=3,Gn=10,Un=11,zn=12,Yn=13,Vn=14,Kn=15,$n=16,jn=17,Wn=1,qn=2,Xn=1,Jn=2,Qn=3,Zn=4,es=5,ts=6,ns=1,ss=2,rs=3,is=4;function ut(n){if(n.disposed||n.renderStateHandle===0)throw new Error("render state resources already disposed")}function os(n){switch(n){case 2:return"full";case 1:return"partial";default:return"clean"}}function ls(n){switch(n){case 0:return"bar";case 2:return"underline";case 3:return"block-hollow";default:return"block"}}function as(n){switch(n){case 1:return"wide";case 2:return"spacer-tail";case 3:return"spacer-head";default:return"narrow"}}function Me(n,e){return{r:n.view().getUint8(e),g:n.view().getUint8(e+1),b:n.view().getUint8(e+2)}}function yt(n,e){const t=n.bindings.allocStruct("GhosttyColorRgb");try{const s=e(t.ptr);if(s===Pn)return null;if(s!==Ee)throw new Error(`ghostty optional color read failed with result ${s}`);return Me(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!==Ee)throw new Error(`ghostty bool read failed with result ${s}`);return n.bindings.readU8(t)!==0}finally{n.bindings.freeU8(t)}}function Be(n,e){const t=n.bindings.allocBytes(2);try{const s=e(t);if(typeof s=="number"&&s!==Ee)throw new Error(`ghostty u16 read failed with result ${s}`);return n.bindings.view().getUint16(t,!0)}finally{n.bindings.freeBytes(t,2)}}function cs(n,e){const t=n.bindings.allocBytes(4);try{const s=e(t);if(typeof s=="number"&&s!==Ee)throw new Error(`ghostty u32 read failed with result ${s}`);return n.bindings.view().getUint32(t,!0)}finally{n.bindings.freeBytes(t,4)}}function rt(n,e){const t=n.bindings.allocBytes(4);try{const s=e(t);if(typeof s=="number"&&s!==Ee)throw new Error(`ghostty enum read failed with result ${s}`);return n.bindings.view().getInt32(t,!0)}finally{n.bindings.freeBytes(t,4)}}function gt(n,e){const t=n.bindings.allocBytes(8);try{const s=e(t);if(typeof s=="number"&&s!==Ee)throw new Error(`ghostty u64 read failed with result ${s}`);return n.bindings.readU64(t)}finally{n.bindings.freeBytes(t,8)}}function ds(n){const e=n.bindings.allocStruct("GhosttyStyle");try{n.bindings.setField(e.view,"GhosttyStyle","size",n.bindings.typeSize("GhosttyStyle")),n.bindings.getRenderStateRowCellValue(n.rowCellsHandle,Jn,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 us(n){const e=cs(n,s=>n.bindings.getRenderStateRowCellValueResult(n.rowCellsHandle,Qn,s));if(e===0)return[];const t=n.bindings.allocBytes(e*4);try{n.bindings.getRenderStateRowCellValue(n.rowCellsHandle,Zn,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 hs(n){if(n.length===0)return"";try{return String.fromCodePoint(...n)}catch{return""}}function fs(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 ms(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(Me(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,Vn,o));return{cols:Be(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,Hn,o)),rows:Be(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,Ln,o)),dirty:os(rt(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,Fn,o))),colors:{background:Me(n.bindings,e.ptr+n.bindings.field("GhosttyRenderStateColors","background").offset),foreground:Me(n.bindings,e.ptr+n.bindings.field("GhosttyRenderStateColors","foreground").offset),cursor:r?Me(n.bindings,e.ptr+n.bindings.field("GhosttyRenderStateColors","cursor").offset):null,palette:s},cursor:{style:ls(rt(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,Gn,o))),visible:fe(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,Un,o)),blinking:fe(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,zn,o)),passwordInput:fe(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,Yn,o)),x:i?Be(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,Kn,o)):null,y:i?Be(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,$n,o)):null,wideTail:i?fe(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,jn,o)):!1}}}finally{e.free()}}function ps(n,e){const t=gt(n,i=>n.bindings.getRenderStateRowValueResult(n.rowIteratorHandle,qn,i));n.bindings.bindRenderStateRowCells(n.rowIteratorHandle,n.rowCellsHandle);const s=[];let r=0;for(;n.bindings.nextRenderStateRowCell(n.rowCellsHandle);){const i=gt(n,a=>n.bindings.getRenderStateRowCellValueResult(n.rowCellsHandle,Xn,a)),o=us(n),l=as(rt(n,a=>n.bindings.getRawCellValueResult(i,rs,a))),u={x:r,text:hs(o),codepoints:o,widthKind:l,hasText:fe(n,a=>n.bindings.getRawCellValueResult(i,is,a)),style:ds(n),fgColor:yt(n,a=>n.bindings.getRenderStateRowCellValueResult(n.rowCellsHandle,ts,a)),bgColor:yt(n,a=>n.bindings.getRenderStateRowCellValueResult(n.rowCellsHandle,es,a))};s.push(u),r+=1}return{y:e,dirty:fe(n,i=>n.bindings.getRenderStateRowValueResult(n.rowIteratorHandle,Wn,i)),wrap:fe(n,i=>n.bindings.getRawRowValueResult(t,ns,i)),wrapContinuation:fe(n,i=>n.bindings.getRawRowValueResult(t,ss,i)),text:fs(s),cells:s}}function St(n){return{bindings:n,renderStateHandle:n.createRenderState(),rowIteratorHandle:n.createRenderStateRowIterator(),rowCellsHandle:n.createRenderStateRowCells(),snapshotVersion:0,disposed:!1,cachedMeta:null}}function _t(n,e){ut(n),n.bindings.updateRenderState(n.renderStateHandle,e),n.bindings.bindRenderStateRowIterator(n.renderStateHandle,n.rowIteratorHandle),n.snapshotVersion+=1,n.cachedMeta=null}function it(n){return ut(n),n.cachedMeta||(n.cachedMeta=ms(n)),n.cachedMeta}function*ws(n){ut(n);const e=it(n);n.bindings.bindRenderStateRowIterator(n.renderStateHandle,n.rowIteratorHandle);let t=0;for(;t<e.rows&&n.bindings.nextRenderStateRowIterator(n.rowIteratorHandle);)yield ps(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)}const ys={colChars:[],contentCols:0,wrappedToNext:!1};function gs(n){for(let e=n.length-1;e>=0;e-=1){const t=n[e];if(t!==null&&t!==""&&t!==" ")return e+1}return 0}function bt(n,e=!1){const t=[];for(const s of n){if(s.widthKind==="spacer-tail"){t.push(null);continue}if(s.widthKind==="spacer-head"){t.push("");continue}t.push(s.text||" ")}return{colChars:t,contentCols:gs(t),wrappedToNext:e}}function Ss(n,e){return Math.max(0,Math.min(Math.max(n.colChars.length-1,0),Math.floor(e)))}function ht(n,e){let t=Ss(n,e);for(;t>0&&n.colChars[t]===null;)t-=1;return t}function Ze(n,e){let t=e;for(;t>0&&n.colChars[t]===null;)t-=1;return n.colChars[t]||""}function xt(n,e){let t=e;for(;t+1<n.colChars.length&&n.colChars[t+1]===null;)t+=1;return t}function _s(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 bs(n,e,t){if(t.colChars.length===0)return{start:{line:n,col:0},end:{line:n,col:0}};const s=ht(t,e),r=l=>/[\p{L}\p{N}_-]/u.test(l);if(!r(Ze(t,s)))return{start:{line:n,col:s},end:{line:n,col:s}};let i=s,o=s;for(;i>0&&r(Ze(t,i-1));)i-=1;for(;o+1<t.colChars.length&&r(Ze(t,o+1));)o+=1;return{start:{line:n,col:i},end:{line:n,col:o}}}function Bt(n,e){const t=Math.max(e.contentCols-1,0);return{start:{line:n,col:0},end:{line:n,col:t}}}function Pt(n,e,t){const s=t(n.line);switch(e){case"word":return bs(n.line,n.col,s);case"line":return Bt(n.line,s);default:{const r=ht(s,n.col);return{start:{line:n.line,col:r},end:{line:n.line,col:r}}}}}function Ht(){return{anchor:null,focus:null,mode:"character"}}function Tt(n){return!!(n.anchor&&n.focus)}function xs(){return Ht()}function Ts(n,e,t){const s=Pt(e,e.mode,t);return{anchor:s.start,focus:s.end,mode:e.mode}}function Et(n,e,t){return n.anchor?n.mode==="line"?{...n,focus:Bt(e.line,t(e.line)).end}:n.mode==="word"?{...n,focus:Pt(e,"word",t).end}:{...n,focus:{line:e.line,col:ht(t(e.line),e.col)}}:n}function Lt(n){return!n.anchor||!n.focus?null:_s(n.anchor,n.focus)}function Es(n,e,t){const s=n.wrappedToNext?n.colChars.length-1:n.contentCols-1,r=Math.min(t,s);let i=Math.max(0,e);for(;i>0&&n.colChars[i]===null;)i-=1;if(i>r)return"";let o="";for(let l=i;l<=r;l+=1)o+=n.colChars[l]??"";return o}function Rs(n,e){const t=Lt(n);if(!t)return null;let s="";for(let r=t.start.line;r<=t.end.line;r+=1){const i=e(r),o=r===t.start.line?t.start.col:0,l=r===t.end.line?t.end.col:i.colChars.length-1;s+=Es(i,o,l),r<t.end.line&&!i.wrappedToNext&&(s+=`
32
+ `)}return s}function Cs(n,e,t,s){const r=Lt(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){const S=s==null?void 0:s(l),E=S?xt(S,r.end.col):r.end.col;o.push({row:u,x:r.start.col,width:E-r.start.col+1});continue}if(l===r.start.line){const S=s?Math.max(s(l).colChars.length-r.start.col,0):Number.MAX_SAFE_INTEGER;o.push({row:u,x:r.start.col,width:S});continue}if(l===r.end.line){const S=s==null?void 0:s(l),E=S?xt(S,r.end.col):r.end.col;o.push({row:u,x:0,width:E+1});continue}const a=s?s(l).colChars.length:Number.MAX_SAFE_INTEGER;o.push({row:u,x:0,width:a})}return o}function Ft(){var e;if(typeof navigator>"u")return!1;const n=((e=navigator.userAgentData)==null?void 0:e.platform)??navigator.platform??"";return/mac|iphone|ipad|ipod/iu.test(n)?!0:/mac os x/iu.test(navigator.userAgent??"")}function vs(n){return n.altKey?!1:!!(Ft()?n.metaKey:n.ctrlKey)}function Ms(n){return vs(n)&&n.key.toLowerCase()==="c"}function Ds(n){return n.shiftKey&&n.key==="Insert"&&!n.ctrlKey&&!n.altKey&&!n.metaKey?!0:n.altKey||n.key.toLowerCase()!=="v"?!1:!!(Ft()?n.metaKey:n.ctrlKey)}async function Gt(n){var t;if(!n)return;if(typeof navigator<"u"&&((t=navigator.clipboard)!=null&&t.writeText))try{await navigator.clipboard.writeText(n);return}catch{}if(typeof document>"u"||typeof document.execCommand!="function")throw new Error("clipboard unavailable");const e=document.createElement("textarea");e.value=n,e.setAttribute("readonly","true"),e.style.position="fixed",e.style.left="-9999px",e.style.top="0",document.body.appendChild(e);try{if(e.select(),!document.execCommand("copy"))throw new Error("execCommand copy failed")}finally{e.remove()}}async function As(n){n&&await Gt(n)}function Os(n,e){return!e||!n.clipboardData?!1:(n.clipboardData.setData("text/plain",e),n.preventDefault(),!0)}const ks="/assets/ghostty-vt-BKQMf-5X.wasm",Ge=0,Rt=-3,Is=11,Ns=12,Bs=13,Ps=14,Hs=1,Ls=2,Fs=9,Gs=1,Us=0,zs=1,Ys=2,Vs=0,Ks=1,$s=2,js=4,Ws=2004,qs=9,Xs=1e3,Js=1002,Qs=1003,Zs=1005,Ct=1006,er=1015,vt=1016;let et=null;function O(n,e){if(n!==Ge)throw new Error(`${e} failed with result ${n}`)}function Ut(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 tr(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(Ut)],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 nr(n){let e=0;return n&1&&(e+=4),n&4&&(e+=8),n&2&&(e+=16),e}function tt(n){return n<0||n>223?null:String.fromCharCode(n+32)}function sr(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 zt(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 rr{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 ir{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 rr(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 O(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){O(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",Ys),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",Us),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",zs),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=tr(t),l=this.allocBytes(o.length*3),u=(S,E)=>{const[A,N,T]=Ut(E);this.setField(S.view,"GhosttyColorRgb","r",A),this.setField(S.view,"GhosttyColorRgb","g",N),this.setField(S.view,"GhosttyColorRgb","b",T)};u(s,t.foreground),u(r,t.background),u(i,t.cursor);const a=this.bytes(l,o.length*3);o.forEach(([S,E,A],N)=>{const T=N*3;a[T]=S,a[T+1]=E,a[T+2]=A});try{O(this.exports.ghostty_terminal_set(e,Is,s.ptr),"ghostty_terminal_set(foreground)"),O(this.exports.ghostty_terminal_set(e,Ns,r.ptr),"ghostty_terminal_set(background)"),O(this.exports.ghostty_terminal_set(e,Bs,i.ptr),"ghostty_terminal_set(cursor)"),O(this.exports.ghostty_terminal_set(e,Ps,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 O(this.exports.ghostty_terminal_get(e,Hs,t),"ghostty_terminal_get(cols)"),O(this.exports.ghostty_terminal_get(e,Ls,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 O(this.exports.ghostty_terminal_get(e,Fs,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 O(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){O(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")),a=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 S=this.field("GhosttyFormatterTerminalOptions","selection").offset;return r.view.setUint32(S,s.selectionPtr??0,!0),O(this.exports.ghostty_formatter_terminal_new(0,a,e,r.ptr),"ghostty_formatter_terminal_new"),this.readPointer(a)}finally{r.free(),this.freeOpaque(a)}}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",Gs);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)!==Ge?(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 a=i-1;a>=0&&(l=this.resolveViewportGridRef(e,r-1,a),!l);a-=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 a=this.field("GhosttySelection","start").offset,S=this.field("GhosttySelection","end").offset;return this.bytes(u.ptr+a,this.typeSize("GhosttyGridRef")).set(this.bytes(o.ptr,this.typeSize("GhosttyGridRef"))),this.bytes(u.ptr+S,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{O(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 O(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){O(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){O(this.getRenderStateValueResult(e,t,s),"ghostty_render_state_get")}setRenderStateValue(e,t,s){O(this.exports.ghostty_render_state_set(e,t,s),"ghostty_render_state_set")}getRenderStateColors(e,t){O(this.exports.ghostty_render_state_colors_get(e,t),"ghostty_render_state_colors_get")}createRenderStateRowIterator(){const e=this.allocOpaque();try{return O(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){O(this.getRenderStateRowValueResult(e,t,s),"ghostty_render_state_row_get")}setRenderStateRowValue(e,t,s){O(this.exports.ghostty_render_state_row_set(e,t,s),"ghostty_render_state_row_set")}createRenderStateRowCells(){const e=this.allocOpaque();try{return O(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){O(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){O(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){O(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){O(this.getRawCellValueResult(e,t,s),"ghostty_cell_get")}createKeyEncoder(){const e=this.allocOpaque();try{return O(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{O(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,js,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,Qs),i=this.isTerminalModeEnabled(t,Js),o=this.isTerminalModeEnabled(t,Xs),l=this.isTerminalModeEnabled(t,qs);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=sr(s.button);if(u===null)return null;const a=Math.max(1,Math.floor(s.x/Math.max(1,s.cellWidth))+1),S=Math.max(1,Math.floor(s.y/Math.max(1,s.cellHeight))+1),E=Math.round(s.x+1),A=Math.round(s.y+1);let N=s.action==="release"&&!this.isTerminalModeEnabled(t,Ct)&&!this.isTerminalModeEnabled(t,vt)?3:u;if(s.action==="motion"&&(N+=32),N+=nr(s.mods),this.isTerminalModeEnabled(t,vt)){const T=s.action==="release"?"m":"M";return`\x1B[<${N};${E};${A}${T}`}if(this.isTerminalModeEnabled(t,Ct)){const T=s.action==="release"?"m":"M";return`\x1B[<${N};${a};${S}${T}`}if(this.isTerminalModeEnabled(t,er))return`\x1B[${N};${a};${S}M`;if(this.isTerminalModeEnabled(t,Zs)||o||i||r||l){const T=tt(N),b=tt(a),q=tt(S);return!T||!b||!q?null:`\x1B[M${T}${b}${q}`}return null}encodeKeyEvent(e,t,s){if(s.keyCode<=0)return null;const r=this.allocOpaque();let i=0,o=null;try{return O(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"?Vs:s.action==="repeat"?$s:Ks),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!==Rt&&r!==Ge&&O(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{O(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,Ws),o=this.exports.ghostty_paste_encode(s.ptr,s.len,i?1:0,0,0,r);o!==Rt&&o!==Ge&&O(o,"ghostty_paste_encode(size)");const l=Math.max(0,this.readUsize(r));if(l===0)return"";const u=this.allocBytes(l),a=this.allocUsize();try{return O(this.exports.ghostty_paste_encode(s.ptr,s.len,i?1:0,u,l,a),"ghostty_paste_encode"),this.readOwnedUtf8(u,this.readUsize(a))}finally{this.freeBytes(u,l),this.freeUsize(a)}}finally{s.free(),this.freeUsize(r)}}}async function or(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 lr(){return et||(et=(async()=>{const n=await or(ks),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 ir(t,o)})()),et}const Mt=80,De=24,nt=9,Pe=17,ar=48,Yt="ghostty-official",Ue=9,ze=1e3,Ye=1002,Ve=1003,st=1007,He=1047,Le=1049,cr=[Ue,ze,Ye,Ve],Dt=1,At=3,Ot=2,dr=4,ur=5;class hr{constructor(e){this.content=e}translateToString(e){return e?this.content.replace(/\s+$/u,""):this.content}}class fr{constructor(){w(this,"active",{baseY:0,viewportY:0,length:De,getLine:e=>{const t=e-this.active.viewportY,s=this.visibleLines[t];return typeof s=="string"?new hr(s):null}});w(this,"visibleLines",Array.from({length:De},()=>""))}setViewport(e,t,s,r){this.active.viewportY=e,this.active.baseY=t,this.active.length=s,this.visibleLines=r}}function mr(n){return!(n.key.length===1&&!n.ctrlKey&&!n.altKey&&!n.metaKey)}function pr(n,e){const t=n.slice(0,e).map(s=>s.text);for(;t.length<e;)t.push("");return t}function Fe(n){return zt({shiftKey:!!n.shiftKey,ctrlKey:!!n.ctrlKey,altKey:!!n.altKey,metaKey:!!n.metaKey,getModifierState:()=>!1})}class wr{constructor(){w(this,"terminal",null)}activate(e){this.terminal=e instanceof $e?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 $e{constructor(e,t,s,r,i,o){w(this,"buffer",new fr);w(this,"_core",{_renderService:{dimensions:{css:{cell:{width:nt,height:Pe}}}}});w(this,"options");w(this,"element",null);w(this,"textarea",null);w(this,"cols",Mt);w(this,"rows",De);w(this,"bindings");w(this,"terminalHandle");w(this,"keyEncoderHandle");w(this,"mouseEncoderHandle");w(this,"renderState");w(this,"dataListeners",new Set);w(this,"selectionListeners",new Set);w(this,"lastNotifiedSelectionText",null);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",Ht());w(this,"lineCache",new Map);w(this,"lastViewportOffset",0);w(this,"lastViewportRows",De);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 lr(),s=t.createTerminal(Mt,De,e.scrollback);let r=0,i=0,o=null;try{return t.setTerminalTheme(s,e.theme),r=t.createKeyEncoder(),i=t.createMouseEncoder(),o=St(t),new $e(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 kn({screenElement:r,theme:this.options.theme,fontFamily:this.options.fontFamily,fontSize:this.options.fontSize}),this.syncInputState(),this.bindDomEvents(),this.updateCellDimensions();const u=this.measureSizeFromElement();u?this.resize(u.cols,u.rows):this.render()}loadAddon(e){e.activate(this),this.addons.add(e)}onData(e){return this.dataListeners.add(e),{dispose:()=>{this.dataListeners.delete(e)}}}attachCustomKeyEventHandler(e){this.customKeyEventHandler=e}onSelectionChange(e){return this.selectionListeners.add(e),{dispose:()=>{this.selectionListeners.delete(e)}}}hasSelection(){return Tt(this.selectionState)}getSelection(){return this.getSelectionText()??""}clearSelection(){this.disposed||this.clearSelectionState()}startTouchSelection(e,t,s="word"){return this.disposed?!1:this.beginSelectionAt(e,t,s)}updateTouchSelection(e,t){this.disposed||this.updateSelectionDrag(e,t)}endTouchSelection(){this.disposed||!this.pointerDrag.active||(this.stopAutoScroll(),this.pointerDrag.active=!1,this.render())}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 cr)this.bindings.setTerminalMode(this.terminalHandle,e,!1);this.bindings.resetMouseEncoder(this.mouseEncoderHandle),this.pressedMouseButtons.clear(),this.mouseDragActive=!1}}isAltScreenActive(){return this.isModeEnabled(He)||this.isModeEnabled(Le)}reset(){this.disposed||(this.lineCache.clear(),this.clearSelectionState(!1),this.bindings.resetTerminal(this.terminalHandle),this.scheduleRender())}refresh(){this.disposed||this.render()}resize(e,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(Ue),mouseNormal:this.isModeEnabled(ze),mouseButton:this.isModeEnabled(Ye),mouseAny:this.isModeEnabled(Ve),mouseUtf8:this.isModeEnabled(1005),mouseSgr:this.isModeEnabled(1006),mouseSgrPixels:this.isModeEnabled(1016),mouseUrxvt:this.isModeEnabled(1015),altScroll:this.isModeEnabled(st),altScreen1047:this.isModeEnabled(He),altScreen1049:this.isModeEnabled(Le)}}restoreModeSnapshot(e){this.bindings.setTerminalMode(this.terminalHandle,Ue,e.mouseX10),this.bindings.setTerminalMode(this.terminalHandle,ze,e.mouseNormal),this.bindings.setTerminalMode(this.terminalHandle,Ye,e.mouseButton),this.bindings.setTerminalMode(this.terminalHandle,Ve,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,st,e.altScroll),this.bindings.setTerminalMode(this.terminalHandle,He,e.altScreen1047),this.bindings.setTerminalMode(this.terminalHandle,Le,e.altScreen1049),this.bindings.resetMouseEncoder(this.mouseEncoderHandle)}handleViewportGesture(e){if(this.disposed||e.deltaY===0)return!1;const t=this.gestureToLines(e);if(t===0)return!1;const s=this.getInputRoutingState();if(s.mouseReporting){const r=t<0?dr:ur;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:Fe(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:Fe(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:Fe(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:Fe(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&&Ms(i)){i.preventDefault(),As(o).catch(()=>{}),this.clearSelectionState(),this.copyShortcutSuppressed=!0,this.clearTextarea();return}if(!this.customKeyEventHandler(i)||this.disableStdin||this.imeIsComposing||i.keyCode===229||Ds(i)||!mr(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&&Os(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=wt(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:zt(e),composing:e.isComposing,utf8:r,unshiftedCodepoint:Bn(e.code)})}getInputRoutingState(){const e=this.isModeEnabled(Ue)||this.isModeEnabled(ze)||this.isModeEnabled(Ye)||this.isModeEnabled(Ve),t=this.isModeEnabled(He)||this.isModeEnabled(Le);return{mouseReporting:e,altScroll:!e&&t&&this.isModeEnabled(st)}}gestureToLines(e){const t=this.cellDimensions().height||Pe;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 Dt;case 1:return At;case 2:return Ot;default:return null}}mouseButtonFromButtons(e){return e&1?Dt:e&4?At:e&2?Ot: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||nt)),cellHeight:Math.max(1,Math.round(s.height||Pe))});return i?(this.emitData(i),!0):!1}emitAltScrollInput(e){const t=wt(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=St(this.bindings);let o=0,l=0;try{_t(i,this.terminalHandle);const S=it(i);S.cursor.x!==null&&S.cursor.y!==null&&(o=S.cursor.x,l=S.cursor.y)}finally{Qe(i)}const u=o*s,a=l*r;e.style.left=`${u}px`,e.style.top=`${a}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);_t(this.renderState,this.terminalHandle);const s=it(this.renderState),r=Array.from(ws(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 a of r)this.lineCache.set(e.offset+a.y,bt(a.cells,a.wrap));const i=Cs(this.selectionState,this.lastViewportOffset,this.lastViewportRows,a=>this.getLineModel(a)),o=this.getSelectionText();this.renderer.render({meta:s,rows:r,cellDimensions:this.cellDimensions(),selectionRects:i,selectionColor:this.options.theme.selectionBackground});const l=pr(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:nt,this._core._renderService.dimensions.css.cell.height=t.height>0?t.height:Pe}clearSelectionState(e=!0){this.selectionState=xs(),this.pressedMouseButtons.clear(),this.wheelPixelDelta=0,this.pointerDrag={active:!1,moved:!1,mode:"character",lastClientX:null,lastClientY:null},this.copyShortcutSuppressed=!1,this.stopAutoScroll(),this.updateSelectionTextProbe(null),e&&this.screenElement&&this.renderer&&this.render()}beginSelectionAt(e,t,s){const r=this.hitTest(e,t);return r?(this.pointerDrag={active:!0,moved:!1,mode:s,lastClientX:e,lastClientY:t},this.selectionState=Ts(this.selectionState,{...r,mode:s},i=>this.getLineModel(i)),this.updateAutoScroll(),this.render(),!0):!1}updateSelectionDrag(e,t){if(!this.pointerDrag.active)return;const s=this.hitTest(e,t);this.pointerDrag.lastClientX=e,this.pointerDrag.lastClientY=t,s&&(this.pointerDrag.moved=!0,this.selectionState=Et(this.selectionState,s,r=>this.getLineModel(r)),this.render()),this.updateAutoScroll()}beginPointerSelection(e){this.beginSelectionAt(e.clientX,e.clientY,this.selectionModeFromClickDetail(e.detail))}updatePointerSelection(e){this.updateSelectionDrag(e.clientX,e.clientY)}finishPointerSelection(e){var 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 A;const s=(A=this.screenElement)==null?void 0:A.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),a=Math.max(this.lastViewportRows-1,0),S=Math.max(0,Math.min(u,Math.floor(o/r))),E=Math.max(0,Math.min(a,Math.floor(l/i)));return{line:this.lastViewportOffset+E,col:S}}getLineModel(e){const t=this.lineCache.get(e);if(t)return t;const s=e-this.lastViewportOffset,r=this.lastRenderedRows[s];return r?bt(r.cells,r.wrap):ys}getSelectionText(){return Tt(this.selectionState)?Rs(this.selectionState,e=>this.getLineModel(e)):null}updateSelectionTextProbe(e){if(globalThis.__tmexE2eTerminalSelectionText=e,e!==this.lastNotifiedSelectionText){this.lastNotifiedSelectionText=e;for(const t of this.selectionListeners)t(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()},ar))}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=Et(this.selectionState,s,i=>this.getLineModel(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 yr(n){return $e.create(n)}function gr({visible:n,canPaste:e,onCopy:t,onPaste:s,onDismiss:r}){const{t:i}=Ke();if(!n)return null;const o=l=>{l.preventDefault()};return h.jsxs("div",{className:"absolute top-2 left-1/2 z-20 flex -translate-x-1/2 items-center gap-1 rounded-lg border bg-background/95 p-1 shadow-md backdrop-blur","data-testid":"terminal-selection-toolbar",children:[h.jsxs("button",{type:"button",className:"flex h-9 items-center gap-1.5 rounded-md px-3 text-sm font-medium hover:bg-accent hover:text-accent-foreground",onMouseDown:o,onClick:t,"data-testid":"terminal-selection-copy",children:[h.jsx(En,{className:"h-4 w-4"}),i("terminal.copy")]}),e&&h.jsxs("button",{type:"button",className:"flex h-9 items-center gap-1.5 rounded-md px-3 text-sm font-medium hover:bg-accent hover:text-accent-foreground",onMouseDown:o,onClick:s,"data-testid":"terminal-selection-paste",children:[h.jsx(xn,{className:"h-4 w-4"}),i("terminal.paste")]}),h.jsx("button",{type:"button",className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-accent-foreground",onMouseDown:o,onClick:r,"aria-label":i("terminal.clearSelection"),"data-testid":"terminal-selection-dismiss",children:h.jsx(on,{className:"h-4 w-4"})})]})}function Vt(n){if(!n)return n;const e=n.replace(/\r\n/g,`
33
+ `);return(e.endsWith(`
34
+ `)?e.slice(0,-1):e).replace(/\n/g,`\r
35
+ `)}const Sr="\x1B[?1049h\x1B[H\x1B[2J";function _r(n){return Sr+Vt(n)}function kt(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 Kt={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"},$t={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"},br='"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',xr=1.3,Tr=36,Er=500,Rr=12;function Cr(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,a=0,S=0,E=null,A=!1;const N=()=>{E!==null&&(clearTimeout(E),E=null)},T=_=>_?!!(_.closest(".scrollbar")||_.closest(".slider")||_.closest(".xterm-scroll-area")):!1,b=(_,R,B)=>{const U=B instanceof Element?B:null;if(T(U))return!0;const K=document.elementFromPoint(_,R);if(T(K))return!0;const x=s.querySelector(".xterm");if(!(x instanceof HTMLElement))return!1;const C=x.getBoundingClientRect(),L=_>=C.left&&_<=C.right,P=R>=C.top&&R<=C.bottom;return!L||!P?!1:_>=C.right-Tr},q=()=>[s.querySelector(".xterm-viewport"),s.querySelector(".xterm-scrollable-element")].filter(R=>R instanceof HTMLElement),g=_=>{if(o===null)return null;for(let R=0;R<_.length;R+=1){const B=_.item(R);if(B&&B.identifier===o)return B}return null},G=_=>{if(N(),_.touches.length!==1)return;const R=_.touches.item(0);R&&(o=R.identifier,i=R.clientY,u=0,l=b(R.clientX,R.clientY,_.target),a=R.clientX,S=R.clientY,A=!1,l||(E=setTimeout(()=>{var U;E=null;const B=(e==null?void 0:e())??null;(U=B==null?void 0:B.startTouchSelection)!=null&&U.call(B,a,S,"word")&&(A=!0)},Er)))},D=_=>{var L,P,k,z,I,ne,se,oe,re;const R=g(_.touches)??_.touches.item(0);if(!R)return;if(A){const W=(e==null?void 0:e())??null;(L=W==null?void 0:W.updateTouchSelection)==null||L.call(W,R.clientX,R.clientY),_.cancelable&&_.preventDefault();return}if(E!==null&&Math.hypot(R.clientX-a,R.clientY-S)>Rr&&N(),l||(l=b(R.clientX,R.clientY,_.target),l&&(u=0)),l)return;const B=R.clientY,U=i-B;if(i=B,U===0)return;let K=!1,x=!1;const C=(e==null?void 0:e())??null;if(C){const W=C==null?void 0:C._core,Y=((I=(z=(k=(P=W==null?void 0:W._renderService)==null?void 0:P.dimensions)==null?void 0:k.css)==null?void 0:z.cell)==null?void 0:I.height)??18;u+=U*xr;const X=u>0?Math.floor(u/Y):Math.ceil(u/Y);if(typeof C.handleViewportGesture=="function")X!==0&&(K=C.handleViewportGesture({source:"touch",deltaY:X*Y,clientX:R.clientX,clientY:R.clientY}),u-=X*Y);else if(X!==0){const J=((se=(ne=C.buffer)==null?void 0:ne.active)==null?void 0:se.viewportY)??0;C.scrollLines(X);const y=((re=(oe=C.buffer)==null?void 0:oe.active)==null?void 0:re.viewportY)??0;K=J!==y,x=X<0&&J<=0&&y<=0,u-=X*Y}}else{const W=q();if(W.length===0)return;for(const Y of W){const X=Y.scrollTop;Y.scrollTop+=U;const J=Y.scrollTop;Math.abs(J-X)>0&&(K=!0),U<0&&J<=0&&(x=!0)}if(!K){const Y=s.querySelector(".xterm");if(Y instanceof HTMLElement){const X=new WheelEvent("wheel",{bubbles:!0,cancelable:!0,deltaMode:WheelEvent.DOM_DELTA_PIXEL,deltaY:U}),J=Y.dispatchEvent(X);K=X.defaultPrevented||!J}}}_.cancelable&&(K||x)&&_.preventDefault()},j=_=>{var B;if(N(),!(o===null||!g(_.changedTouches))&&(o=null,u=0,l=!1,A)){A=!1;const U=(e==null?void 0:e())??null;(B=U==null?void 0:U.endTouchSelection)==null||B.call(U)}},V=_=>{A&&_.preventDefault()};return s.addEventListener("touchstart",G,{passive:!0}),s.addEventListener("touchmove",D,{passive:!1}),s.addEventListener("touchend",j,{passive:!0}),s.addEventListener("touchcancel",j,{passive:!0}),s.addEventListener("contextmenu",V),()=>{t.current=!1,N(),s.removeEventListener("touchstart",G),s.removeEventListener("touchmove",D),s.removeEventListener("touchend",j),s.removeEventListener("touchcancel",j),s.removeEventListener("contextmenu",V)}},[n,e]),t}function vr({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 Mr({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),a=d.useRef(null),S=d.useRef(null),E=d.useRef(0),A=d.useRef([]),N=d.useRef(null),T=d.useRef(null),b=d.useRef(o),q=d.useRef(!1),g=d.useRef(r),G=d.useRef(i);d.useEffect(()=>{g.current=r},[r]),d.useEffect(()=>{G.current=i},[i]),d.useEffect(()=>{b.current=o},[o]);const D=d.useCallback(()=>{var ne,se,oe,re,W,Y,X,J,y,f;const x=T.current,C=N.current;if(!x||!C||!x.element)return null;let L;try{const v=C.proposeDimensions();if(!v)throw new Error("fitAddon.proposeDimensions() returned null");L=Math.max(2,v.cols)}catch{const v=x._core,H=((re=(oe=(se=(ne=v==null?void 0:v._renderService)==null?void 0:ne.dimensions)==null?void 0:se.css)==null?void 0:oe.cell)==null?void 0:re.width)??9,F=(W=b.current)==null?void 0:W.call(b);if(!F||F.width===0)return null;L=Math.max(2,Math.floor(F.width/H))}const P=(Y=b.current)==null?void 0:Y.call(b);if(!P||P.height===0)return null;const k=x._core,z=((f=(y=(J=(X=k==null?void 0:k._renderService)==null?void 0:X.dimensions)==null?void 0:J.css)==null?void 0:y.cell)==null?void 0:f.height)??17,I=Math.max(2,Math.floor(P.height/z));return{cols:L,rows:I}},[]),j=d.useCallback((x,C)=>{const L=T.current;L&&(L.cols===x&&L.rows===C||L.resize(x,C))},[]),V=d.useCallback((x,C=!1)=>{if(!n||!e||!t||s&&x!=="sync"||!C&&Date.now()<E.current||!T.current)return!1;const P=D();if(!P)return!1;const{cols:k,rows:z}=P,I=a.current;return!C&&I&&I.cols===k&&I.rows===z?(j(k,z),!0):(j(k,z),x==="sync"?G.current(k,z):g.current(k,z),a.current={cols:k,rows:z},S.current={cols:k,rows:z,at:Date.now()},!0)},[j,t,n,s,D,e]),_=d.useCallback((x="resize",C={})=>{const{immediate:L=!1,force:P=!1}=C;u.current!==null&&(window.clearTimeout(u.current),u.current=null),l.current!==null&&(cancelAnimationFrame(l.current),l.current=null);const k=()=>{l.current=requestAnimationFrame(()=>{l.current=null,V(x,P)})};if(L){k();return}u.current=window.setTimeout(()=>{u.current=null,k()},150)},[V]),R=d.useCallback(()=>{for(const x of A.current)window.clearTimeout(x);A.current=[]},[]),B=d.useCallback(()=>{var C;R(),_("sync",{immediate:!0,force:!0});const x=window.setTimeout(()=>{_("sync",{immediate:!0,force:!0})},60);A.current.push(x),typeof document<"u"&&"fonts"in document&&((C=document.fonts)!=null&&C.ready)&&document.fonts.ready.then(()=>{_("sync",{immediate:!0,force:!0})}).catch(()=>{})},[R,_]);d.useEffect(()=>{let x=null;const C=()=>{x!==null&&cancelAnimationFrame(x),x=requestAnimationFrame(()=>{x=null,_("resize")})};return window.addEventListener("resize",C),()=>{window.removeEventListener("resize",C),x!==null&&cancelAnimationFrame(x)}},[_]),d.useEffect(()=>{const x=()=>{var ne;const k=T.current,z=D();if(!k||!z)return;if(!Mr({currentSize:{cols:Math.max(2,k.cols),rows:Math.max(2,k.rows)},containerSize:z})){(ne=k.refresh)==null||ne.call(k);return}_("sync",{force:!0})},C=()=>{if(document.visibilityState!=="visible"){q.current=!0;return}q.current&&(q.current=!1,x())},L=()=>{q.current=!0},P=()=>{q.current&&(q.current=!1,x())};return document.addEventListener("visibilitychange",C),window.addEventListener("blur",L),window.addEventListener("focus",P),()=>{document.removeEventListener("visibilitychange",C),window.removeEventListener("blur",L),window.removeEventListener("focus",P)}},[D,_]),d.useEffect(()=>()=>{R(),u.current!==null&&window.clearTimeout(u.current),l.current!==null&&cancelAnimationFrame(l.current)},[R]);const U=d.useCallback(x=>{N.current=x},[]),K=d.useCallback(x=>{T.current=x},[]);return{scheduleResize:_,runPostSelectResize:B,clearPostSelectResizeTimers:R,setFitAddon:U,setTerminal:K,lastReportedSize:a,pendingLocalSize:S,suppressLocalResizeUntil:E}}const Ar={fontFamily:br,fontSize:13,scrollback:1e4},ot="tmex:terminal-mode-cache";function Or(n,e){try{const t=sessionStorage.getItem(ot);return t?JSON.parse(t)[`${n}:${e}`]??null:null}catch{return null}}function kr(n,e,t){try{const s=sessionStorage.getItem(ot),r=s?JSON.parse(s):{},i=`${n}:${e}`;t?r[i]=t:delete r[i],sessionStorage.setItem(ot,JSON.stringify(r))}catch{}}function Ir(){return{mouseX10:!1,mouseNormal:!0,mouseButton:!1,mouseAny:!1,mouseUtf8:!1,mouseSgr:!0,mouseSgrPixels:!1,mouseUrxvt:!1,altScroll:!0,altScreen1047:!1,altScreen1049:!1}}function Nr(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=Ir();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 Br(n){var t;const e=globalThis;e.__tmexE2eXterm=n,e.__tmexE2eTerminal=n,e.__tmexE2eTerminalEngine=Yt,e.__tmexE2eTerminalRenderer=((t=n.getRendererKind)==null?void 0:t.call(n))??null}function Pr(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 jt=d.forwardRef(({deviceId:n,paneId:e,theme:t,inputMode:s,deviceConnected:r,isSelectionInvalid:i,onResize:o,onSync:l},u)=>{const[a,S]=d.useState(null),[E,A]=d.useState(!1),N=ee(y=>y.sendInput),{t:T}=Ke(),b=d.useMemo(()=>{switch(t){case"light":return Kt;default:return $t}},[t]),q=d.useRef(null),g=d.useRef(null),G=d.useRef(null),D=d.useRef(n),j=d.useRef(e),V=d.useRef(n),_=d.useRef(e),R=d.useRef(r&&!i),B=d.useRef(s),U=d.useRef(b),K=d.useRef(!1),x=d.useRef(!1),C=d.useRef(null),L=d.useRef(!1),P=d.useCallback((y,f,v)=>{!(y!=null&&y.exportModeSnapshot)||!f||!v||kr(f,v,y.exportModeSnapshot())},[]),k=d.useCallback(()=>a,[a]);Cr(q,k),d.useEffect(()=>{D.current=n,j.current=e,x.current=!1},[n,e]),d.useEffect(()=>{R.current=r&&!i},[r,i]),d.useEffect(()=>{B.current=s},[s]),d.useEffect(()=>{U.current=b},[b]);const z=d.useCallback(y=>{if(!y||s!=="direct"||!R.current)return;const f=D.current,v=j.current;!f||!v||N(f,v,y,!1)},[s,N]),{pendingLocalSize:I,scheduleResize:ne,runPostSelectResize:se,setFitAddon:oe,setTerminal:re}=Dr({deviceId:n,paneId:e,deviceConnected:r,isSelectionInvalid:i,onResize:o,onSync:l,getContainerRect:()=>{const y=q.current;if(!y)return null;const f=y.getBoundingClientRect();return{width:f.width,height:f.height}}});d.useEffect(()=>{let y=!1,f=null;return yr({...Ar,theme:U.current,disableStdin:B.current==="editor"}).then(v=>{if(y){v.dispose();return}f=v,g.current&&v.open(g.current),Br(v),S(v)}),()=>{y=!0,S(null),Pr(f),f==null||f.dispose()}},[]),d.useEffect(()=>{!a||!("setTheme"in a)||a.setTheme(b)},[a,b]),d.useEffect(()=>{!a||!("setDisableStdin"in a)||a.setDisableStdin(s==="editor")},[a,s]),d.useEffect(()=>{!a||s!=="direct"||window.innerWidth<768||"ontouchstart"in window||a.focus()},[a,s]);const W=d.useMemo(()=>a?{onResetTerminal:y=>{D.current===y&&(P(a,V.current,_.current),L.current=!0,a.reset(),K.current=!1,se())},onApplyHistory:(y,f,v)=>{var Z;if(D.current!==y)return;const H=Nr(Or(D.current,j.current),v);H&&((Z=a.restoreModeSnapshot)==null||Z.call(a,H));const F=v?_r(f):Vt(f);x.current=!0,a.write(F),L.current=!1,V.current=D.current,_.current=j.current,P(a,D.current,j.current)},onFlushBuffer:(y,f)=>{if(D.current===y){for(const v of f){const H=kt(v,K.current);K.current=H.endedWithCR,a.write(H.normalized)}x.current&&(a.buffer.active.baseY<=1&&a.scrollToTop(),x.current=!1),V.current=D.current,_.current=j.current,P(a,D.current,j.current)}},onOutput:(y,f,v)=>{if(D.current!==y||j.current!==f)return;const H=kt(v,K.current);K.current=H.endedWithCR,a.write(H.normalized),x.current&&(a.buffer.active.baseY<=1&&a.scrollToTop(),x.current=!1),V.current=D.current,_.current=j.current,P(a,D.current,j.current)}}:{},[a,P,se]);d.useEffect(()=>{a?C.current!==a&&(K.current=!1,V.current=D.current,_.current=j.current,C.current=a):C.current=null},[a]),d.useEffect(()=>{if(!(!a||!n||!e))return()=>{if(L.current){L.current=!1;return}P(a,V.current,_.current)}},[n,a,e,P]),d.useEffect(()=>{mt(W)},[W]),d.useEffect(()=>()=>{mt({})},[]),d.useEffect(()=>{if(!a){G.current=null,oe(null),re(null);return}const y=new wr;return a.loadAddon(y),G.current=y,oe(y),re(a),se(),()=>{try{y.dispose()}finally{G.current=null,oe(null),re(null)}}},[a,se,oe,re]),d.useEffect(()=>{const y=q.current;if(!y)return;let f=null;const v=new ResizeObserver(()=>{f!==null&&cancelAnimationFrame(f),f=requestAnimationFrame(()=>{f=null,ne("resize")})});return v.observe(y),()=>{v.disconnect(),f!==null&&cancelAnimationFrame(f)}},[ne]),d.useEffect(()=>{if(!a||!n||!e)return;const y=a.onData(f=>{!r||i||z(f)});return a.attachCustomKeyEventHandler(f=>!r||i||f.type!=="keydown"||s!=="direct"?!0:f.shiftKey&&f.key==="Enter"?(f.preventDefault(),z("\x1B[13;2u"),!1):!0),()=>{y.dispose(),a.attachCustomKeyEventHandler(()=>!0)}},[a,r,i,s,z,n,e]),d.useEffect(()=>{if(!(a!=null&&a.onSelectionChange)){A(!1);return}const y=a.onSelectionChange(f=>{A(!!f)});return()=>{y.dispose(),A(!1)}},[a]);const Y=d.useCallback(()=>{var f;if(!a)return;const y=((f=a.getSelection)==null?void 0:f.call(a))??"";y&&Gt(y).then(()=>{xe.success(T("terminal.copied"))}).catch(()=>{xe.error(T("terminal.copyFailed"))}).finally(()=>{var v;(v=a.clearSelection)==null||v.call(a),a.focus()})},[a,T]),X=d.useCallback(()=>{var f;if(!a)return;((f=navigator.clipboard)!=null&&f.readText?navigator.clipboard.readText():Promise.reject(new Error("clipboard unavailable"))).then(v=>{var H;v&&a.paste(v),(H=a.clearSelection)==null||H.call(a),a.focus()}).catch(()=>{xe.error(T("terminal.pasteFailed"))})},[a,T]),J=d.useCallback(()=>{var y;(y=a==null?void 0:a.clearSelection)==null||y.call(a),a==null||a.focus()},[a]);return d.useImperativeHandle(u,()=>({write:y=>a==null?void 0:a.write(y),reset:()=>{a==null||a.reset(),K.current=!1},scrollToBottom:()=>a==null?void 0:a.scrollToBottom(),resize:(y,f)=>a==null?void 0:a.resize(y,f),getTerminal:()=>a??null,getSize:()=>a?{cols:Math.max(2,a.cols),rows:Math.max(2,a.rows)}:null,runPostSelectResize:()=>se(),scheduleResize:(y,f)=>ne(y,f),calculateSizeFromContainer:()=>{var je,We,qe,Re,ie,Ce,me,ke,Ie,ce,Se,pe,de,te,_e,we;const y=q.current,f=a,v=G.current;if(!y||!f)return null;const H=y.getBoundingClientRect();if(H.width===0||H.height===0)return null;const F=f._core;let Z;if(v)try{const ue=v.proposeDimensions();if(ue)Z=Math.max(2,ue.cols);else{const Ne=((Re=(qe=(We=(je=F==null?void 0:F._renderService)==null?void 0:je.dimensions)==null?void 0:We.css)==null?void 0:qe.cell)==null?void 0:Re.width)??9;Z=Math.max(2,Math.floor(H.width/Ne))}}catch{const ue=((ke=(me=(Ce=(ie=F==null?void 0:F._renderService)==null?void 0:ie.dimensions)==null?void 0:Ce.css)==null?void 0:me.cell)==null?void 0:ke.width)??9;Z=Math.max(2,Math.floor(H.width/ue))}else{const ue=((pe=(Se=(ce=(Ie=F==null?void 0:F._renderService)==null?void 0:Ie.dimensions)==null?void 0:ce.css)==null?void 0:Se.cell)==null?void 0:pe.width)??9;Z=Math.max(2,Math.floor(H.width/ue))}const ae=((we=(_e=(te=(de=F==null?void 0:F._renderService)==null?void 0:de.dimensions)==null?void 0:te.css)==null?void 0:_e.cell)==null?void 0:we.height)??17,Oe=Math.max(2,Math.floor(H.height/ae));return{cols:Z,rows:Oe}},getPendingLocalSize:()=>I.current}),[a,I,se,ne]),h.jsxs("div",{ref:q,className:"h-full w-full relative",style:{backgroundColor:b.background},"data-terminal-engine":Yt,children:[h.jsx("div",{ref:g,className:"absolute inset-0"}),h.jsx(gr,{visible:E,canPaste:s==="direct"&&r&&!i,onCopy:Y,onPaste:X,onDismiss:J})]})});jt.displayName="Terminal";const Hr=1200,Lr=2e3;function ye(n,e){return!n||!e?!1:n.windowId===e.windowId&&n.paneId===e.paneId}function Wt(n,e){const t=n.filter(s=>e-s.at<Hr);return t.length===0?null:t.reduce((s,r)=>r.at>s.at?r:s)}function Ae(n,e=Date.now()){return!n||e-n.at>Lr?null:n}function Fr(n){const e=n.now??Date.now(),t=Wt(n.recentSelectRequests,e);if(t&&!ye(t,n.activePaneFromEvent)||ye(n.currentRoute,n.activePaneFromEvent)||ye(n.lastHandledActive,n.activePaneFromEvent))return!0;const s=Ae(n.pendingUserSelection,e);return!!(s&&!ye(s,n.activePaneFromEvent))}function Gr(n){const e=n.now??Date.now(),t=Wt(n.recentSelectRequests,e),s=Ae(n.pendingUserSelection,e);return!!(s&&!ye(s,n.snapshotActive)||t&&!ye(t,n.snapshotActive))}function Ur(n){const e=n.now??Date.now(),t=Ae(n.pendingUserSelection,e);return!(t&&ye(t,n.routeTarget)||n.snapshotActive&&ye(n.snapshotActive,n.routeTarget))}function zr(){const n=lt.getState().settings;return(n==null?void 0:n.siteName)||"tmex"}function It(n){const e=n==null?void 0:n.trim();return e&&e.length>0?e:"?"}function qt({paneIdx:n,windowIdx:e,paneTitle:t,windowName:s,deviceName:r}){const i=e??"?",o=n??"?",l=It(t??s),u=It(r);return`${i}/${o}: ${l}@${u}`}function Yr(n){const e=zr();return n!=null&&n.trim()?`[${e}]${n}`:e}function Vr(){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 Kr=[{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:"`"}],Nt=d.memo(function({onSend:e,onFocusEditor:t,disabled:s,isMobile:r,inputMode:i}){return h.jsx("div",{className:"terminal-shortcuts-strip my-2 bg-muted rounded-xl","data-testid":"terminal-shortcuts-strip",children:h.jsx("div",{className:"shortcut-row flex items-center gap-1.5 p-2 overflow-x-auto scrollbar-thin","data-testid":"editor-shortcuts-row",children:Kr.map(o=>h.jsx(ge,{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}`,onMouseDown:l=>l.preventDefault(),onClick:()=>{e(o.payload),r&&i==="editor"&&(t==null||t())},disabled:s,children:o.label},o.key))})})});function Xr(){var ft;const{t:n}=Ke(),{deviceId:e,windowId:t,paneId:s}=at(),r=ln(),i=d.useRef(null),o=d.useRef(null),l=d.useRef(null),u=d.useRef(null),a=d.useRef(!1),S=d.useRef(!1),E=d.useRef(null),A=ee(c=>c.selectPane),N=ee(c=>e?c.snapshots[e]:void 0),T=ee(c=>{var p;return e?(p=c.deviceErrors)==null?void 0:p[e]:void 0}),b=ee(c=>{var p;return e?((p=c.deviceConnected)==null?void 0:p[e])??!1:!1}),q=lt(c=>{var p;return((p=c.settings)==null?void 0:p.siteName)??"tmex"}),g=d.useMemo(()=>ct(s),[s]),G=d.useMemo(()=>e&&g?`${e}:${g}`:null,[e,g]),[D,j]=d.useState(!1),[V,_]=d.useState(""),[R,B]=d.useState(!1),U=d.useRef(!1),K=!b||!g,[x,C]=d.useState(0),[L,P]=d.useState(0),[k,z]=d.useState(!1),I=he(c=>c.inputMode),ne=he(c=>c.theme),se=he(c=>c.editorSendWithEnter),oe=he(c=>c.setEditorSendWithEnter),re=he(c=>c.addEditorHistory),W=he(c=>c.setEditorDraft),Y=he(c=>c.removeEditorDraft),X=he(c=>G?c.editorDrafts[G]??"":""),J=d.useMemo(()=>Vr(),[]),y=D&&I==="editor"&&J&&R,f=(ft=N==null?void 0:N.session)==null?void 0:ft.windows,v=ne==="light"?Kt:$t,{data:H}=an({queryKey:["devices"],queryFn:async()=>{const c=await fetch("/api/devices");if(!c.ok)throw new Error("Failed to fetch devices");return c.json()},throwOnError:!1}),F=d.useMemo(()=>{if(e)return H==null?void 0:H.devices.find(c=>c.id===e)},[e,H==null?void 0:H.devices]),Z=d.useMemo(()=>{if(!(!t||!f))return f.find(c=>c.id===t)},[t,f]),ae=d.useMemo(()=>{if(!(!g||!Z))return Z.panes.find(c=>c.id===g)},[g,Z]),Oe=!!f,Re=!!(Oe&&!!t&&!Z||Oe&&!!t&&!!g&&!!Z&&!ae?n("wsError.checkGateway"):null),ie=!!(b&&g&&!Re),Ce=d.useMemo(()=>{if(!Z||!ae)return null;const c=(F==null?void 0:F.name)??e;return qt({paneIdx:ae.index,windowIdx:Z.index,paneTitle:ae.title,windowName:Z.name,deviceName:c})},[F==null?void 0:F.name,e,ae,Z]),me=d.useMemo(()=>{if(!f||f.length===0)return null;const c=f.find(m=>m.active),p=c==null?void 0:c.panes.find(m=>m.active);return!c||!p?null:{windowId:c.id,paneId:p.id}},[f]),ke=d.useCallback((c,p)=>{!e||!g||ee.getState().resizePane(e,g,c,p)},[e,g]),Ie=d.useCallback((c,p)=>{!e||!g||ee.getState().syncPaneSize(e,g,c,p)},[e,g]),ce=d.useCallback((c,p)=>{const m=u.current,M=(m==null?void 0:m.calculateSizeFromContainer())??(m==null?void 0:m.getSize())??void 0;if(M)return M;if(!c||!p||!f)return;const Q=f.find(le=>le.id===c),$=Q==null?void 0:Q.panes.find(le=>le.id===p);if(!(!$||$.width<=1||$.height<=1))return{cols:$.width,rows:$.height}},[f]);d.useEffect(()=>{const c=()=>{j(window.innerWidth<768||"ontouchstart"in window)};return c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[]),d.useEffect(()=>{if(!D||!J||S.current)return;S.current=!0;const c=()=>{window.scrollTo(0,1)},p=window.requestAnimationFrame(c),m=window.setTimeout(c,120),M=window.setTimeout(c,420);return()=>{window.cancelAnimationFrame(p),window.clearTimeout(m),window.clearTimeout(M)}},[J,D]),d.useEffect(()=>{I!=="editor"&&B(!1)},[I]),d.useEffect(()=>{var M,Q;if(!(D&&J&&I==="editor"&&R)){C(0);return}let c=null;const p=()=>{const $=window.visualViewport,le=($==null?void 0:$.height)??window.innerHeight,ve=($==null?void 0:$.offsetTop)??0,nn=Math.max(0,Math.round(window.innerHeight-le-ve));C(nn)},m=()=>{c===null&&(c=window.requestAnimationFrame(()=>{c=null,p()}))};return p(),(M=window.visualViewport)==null||M.addEventListener("resize",m),(Q=window.visualViewport)==null||Q.addEventListener("scroll",m),window.addEventListener("resize",m),()=>{var $,le;($=window.visualViewport)==null||$.removeEventListener("resize",m),(le=window.visualViewport)==null||le.removeEventListener("scroll",m),window.removeEventListener("resize",m),c!==null&&window.cancelAnimationFrame(c)}},[I,R,J,D]),d.useEffect(()=>{if(!y){P(0);return}const c=o.current;if(!c)return;const p=()=>{P(Math.ceil(c.getBoundingClientRect().height))};p();const m=new ResizeObserver(p);return m.observe(c),()=>m.disconnect()},[y]),d.useEffect(()=>{e&&(a.current=!1,_e.current=null,we.current=null,E.current=null,pe.current=[])},[e]),d.useEffect(()=>{b||(a.current=!1)},[b]),d.useEffect(()=>{if(!e||!b||!t||!f)return;if(f.length===0){r("/devices",{replace:!0});return}const c=f.find(m=>m.id===t);if(!c)return;if(!g){const m=c.panes.find(M=>M.active)??c.panes[0];m&&r(`/devices/${e}/windows/${t}/panes/${be(m.id)}`,{replace:!0});return}if(!c.panes.find(m=>m.id===g)){const m=c.panes.find(M=>M.active)??c.panes[0];m&&r(`/devices/${e}/windows/${t}/panes/${be(m.id)}`,{replace:!0});return}},[e,b,f,t,g,r]),d.useEffect(()=>{if(!e||!b||!f||f.length===0||t&&g||a.current)return;const c=f.find(m=>m.active)??f[0],p=c.panes.find(m=>m.active)??c.panes[0];p&&(a.current=!0,r(`/devices/${e}/windows/${c.id}/panes/${be(p.id)}`,{replace:!0}))},[b,e,r,g,t,f]);const Se=d.useRef(null);d.useEffect(()=>{Se.current=null},[e,g]),d.useEffect(()=>{if(!e||!t||!g||K||!b)return;const c=`${e}:${t}:${g}`;if(Se.current===c)return;Se.current=c;const p=ce(t,g);de(t,g),A(e,t,g,p)},[b,e,ce,K,g,A,t]),d.useEffect(()=>{if(!e||!b||!t||!g)return;const c={windowId:t,paneId:g};Ur({routeTarget:c,snapshotActive:me,pendingUserSelection:E.current})&&(E.current={windowId:c.windowId,paneId:c.paneId,at:Date.now()})},[b,e,g,me,t]);const pe=d.useRef([]),de=d.useCallback((c,p)=>{const m=Date.now(),M=[...pe.current.filter(Q=>m-Q.at<2e3),{windowId:c,paneId:p,at:m}];pe.current=M.slice(-8)},[]),te=ee(c=>e?c.activePaneFromEvent[e]:void 0),_e=d.useRef(null);d.useEffect(()=>{if(!e||!b||!t||!g||!te)return;const c=Date.now(),p=Ae(E.current,c);if(E.current=p,Fr({now:c,pendingUserSelection:p,activePaneFromEvent:te,currentRoute:{windowId:t,paneId:g},recentSelectRequests:pe.current,lastHandledActive:_e.current}))return;_e.current={...te},p&&p.windowId===te.windowId&&p.paneId===te.paneId&&(E.current=null);const m=ce(te.windowId,te.paneId);de(te.windowId,te.paneId),A(e,te.windowId,te.paneId,m),r(`/devices/${e}/windows/${te.windowId}/panes/${be(te.paneId)}`,{replace:!0})},[e,b,t,g,te,de,ce,A,r]);const we=d.useRef(null);d.useEffect(()=>{if(!e||!b||!f||f.length===0)return;const c=pe.current,p=f.find(ve=>ve.active);if(!p)return;const m=p.panes.find(ve=>ve.active);if(!m)return;const M={windowId:p.id,paneId:m.id},Q=Date.now(),$=Ae(E.current,Q);if(E.current=$,Gr({now:Q,pendingUserSelection:$,snapshotActive:M,recentSelectRequests:c})||we.current&&we.current.windowId===M.windowId&&we.current.paneId===M.paneId||(we.current={...M},$&&$.windowId===M.windowId&&$.paneId===M.paneId&&(E.current=null),t===M.windowId&&g===M.paneId))return;const le=ce(M.windowId,M.paneId);de(M.windowId,M.paneId),A(e,M.windowId,M.paneId,le),r(`/devices/${e}/windows/${M.windowId}/panes/${be(M.paneId)}`,{replace:!0})},[e,b,f,t,g,de,ce,A,r]);const ue=ee(c=>e?c.pendingCreateWindowAt[e]:void 0);d.useEffect(()=>{if(!e||!b||!ue)return;const c=5e3,p=Date.now()-ue;if(p>c){ee.getState().clearPendingCreateWindow(e);return}if(!me){const Q=window.setTimeout(()=>{ee.getState().clearPendingCreateWindow(e)},c-p);return()=>window.clearTimeout(Q)}const m=me;if(t===m.windowId&&g===m.paneId){const Q=window.setTimeout(()=>{ee.getState().clearPendingCreateWindow(e)},c-p);return()=>window.clearTimeout(Q)}E.current={windowId:m.windowId,paneId:m.paneId,at:Date.now()};const M=ce(m.windowId,m.paneId);de(m.windowId,m.paneId),A(e,m.windowId,m.paneId,M),r(`/devices/${e}/windows/${m.windowId}/panes/${be(m.paneId)}`,{replace:!0}),ee.getState().clearPendingCreateWindow(e)},[e,b,ue,me,t,g,de,ce,A,r]),d.useEffect(()=>{if(!ie||!ae||K)return;const c=u.current,p=c==null?void 0:c.getTerminal();if(!p)return;const m=Math.max(2,Math.floor(ae.width||0)),M=Math.max(2,Math.floor(ae.height||0));if(!m||!M)return;const Q=Date.now(),$={cols:m,rows:M},le=(c==null?void 0:c.getPendingLocalSize())??null;vr({now:Q,remoteSize:$,pendingLocalSize:le})&&(p.cols===m&&p.rows===M||p.resize(m,M))},[ie,K,ae]),d.useEffect(()=>{const c=window.requestAnimationFrame(()=>{var m;(m=u.current)==null||m.scrollToBottom()}),p=window.setTimeout(()=>{var m;(m=u.current)==null||m.scrollToBottom()},120);return()=>{window.cancelAnimationFrame(c),window.clearTimeout(p)}},[I]),d.useEffect(()=>{T!=null&&T.message&&xe.error(T.message)},[T==null?void 0:T.message]),d.useEffect(()=>(document.title=Yr(Ce),()=>{document.title=q}),[q,Ce]),d.useEffect(()=>{const c=()=>{var p;(p=u.current)==null||p.scrollToBottom()};return window.addEventListener("tmex:jump-to-latest",c),()=>{window.removeEventListener("tmex:jump-to-latest",c)}},[]),d.useEffect(()=>{const c=p=>{const{deviceId:m,windowId:M,paneId:Q}=p.detail;m===e&&(E.current={windowId:M,paneId:Q,at:Date.now()})};return window.addEventListener("tmex:user-initiated-selection",c),()=>{window.removeEventListener("tmex:user-initiated-selection",c)}},[e]),d.useEffect(()=>{_(X)},[X]);const Ne=d.useCallback(c=>{if(!e||!g||!ie)return;ee.getState().sendInput(e,g,c,!1)},[ie,e,g]),Xt=d.useCallback(()=>{if(!ie){xe.error(n("wsError.checkGateway"));return}if(!e||!g||!V.trim())return;z(!0),window.setTimeout(()=>z(!1),150);const c=se?`${V}\r`:V;ee.getState().sendInput(e,g,c,!1),re(V),G&&Y(G),_("")},[re,ie,e,G,se,V,Y,g,n]),Jt=d.useCallback(()=>{if(!ie){xe.error(n("wsError.checkGateway"));return}if(!e||!g||!V.trim())return;z(!0),window.setTimeout(()=>z(!1),150);const c=V.split(/\r?\n/),p=ee.getState();for(const m of c)m.trim()&&p.sendInput(e,g,`${m}\r`,!1);re(V),G&&Y(G),_("")},[re,ie,e,G,V,Y,g,n]),Qt=d.useCallback(c=>{if(B(!0),!(D&&J))return;const p=c.currentTarget;window.requestAnimationFrame(()=>{p.scrollIntoView({block:"nearest",inline:"nearest"})}),window.setTimeout(()=>{window.scrollTo(0,1)},60)},[J,D]),Zt=d.useCallback(()=>{B(!1)},[]),en=d.useCallback(()=>{var c;(c=l.current)==null||c.focus({preventScroll:!0})},[]);if(!e)return h.jsx("div",{className:"flex h-full items-center justify-center p-4",children:h.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-3 text-sm text-muted-foreground",children:n("device.noDevices")})});const tn=!b&&!T;return h.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background","data-testid":"device-page",children:[h.jsxs("div",{className:`flex-1 relative overflow-hidden min-h-0 min-w-0 ${D&&I==="editor"&&!y?"pb-1":""}`,style:{paddingBottom:y?`${L+60}px`:void 0},children:[h.jsx("div",{className:"h-full px-3 py-1 min-h-0 min-w-0 w-full relative flex rounded-xl",style:{backgroundColor:v.background},children:b&&g?h.jsx("div",{ref:i,className:"flex-1 h-full min-h-0 w-full",children:h.jsx(jt,{ref:u,deviceId:e,paneId:g,theme:ne,inputMode:I,deviceConnected:b,isSelectionInvalid:Re,onResize:ke,onSync:Ie},`${e}:${g}`)}):h.jsx("div",{className:"absolute inset-0 flex flex-col items-center justify-center p-8 text-center",children:h.jsx("div",{className:"max-w-sm space-y-4",children:b?t?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:h.jsx(Xe,{className:"h-6 w-6 text-muted-foreground animate-spin"})}),h.jsx("h3",{className:"text-lg font-medium",children:n("terminal.connecting")})]}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:h.jsx("span",{className:"text-2xl text-muted-foreground",children:"📋"})}),h.jsx("h3",{className:"text-lg font-medium",children:n("window.noWindowSelected")}),h.jsx("p",{className:"text-sm text-muted-foreground",children:n("window.selectWindowToStart")})]}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:h.jsx("span",{className:"text-2xl text-muted-foreground",children:"🔌"})}),h.jsx("h3",{className:"text-lg font-medium",children:n("device.disconnected")}),h.jsx("p",{className:"text-sm text-muted-foreground",children:n("device.connectToStart")})]})})})}),tn&&h.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/85 backdrop-blur-sm","data-testid":"terminal-status-overlay",children:h.jsxs("div",{className:"flex flex-col items-center gap-2 rounded-lg border border-border bg-card/90 px-4 py-3 shadow-sm",children:[h.jsx("div",{className:"h-7 w-7 rounded-full border-2 border-primary border-t-transparent animate-spin"}),h.jsx("span",{className:"text-xs text-muted-foreground","data-testid":"terminal-status-text",children:n("terminal.connecting")})]})})]}),I==="direct"&&h.jsx("div",{className:"",children:h.jsx(Nt,{onSend:Ne,disabled:!ie,isMobile:D,inputMode:I})}),I==="editor"&&h.jsxs("div",{ref:o,className:`editor-mode-input bg-card/85 backdrop-blur-sm ${y?"fixed left-0 right-0 z-50":""}`,style:y?{bottom:`${x}px`}:void 0,children:[D&&h.jsx(Nt,{onSend:Ne,onFocusEditor:en,disabled:!ie,isMobile:D,inputMode:I}),h.jsx("textarea",{ref:l,"data-testid":"editor-input",className:"min-h-[88px] max-h-[28vh] w-full resize-y rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground shadow-xs outline-none transition-colors focus:border-ring",value:V,onChange:c=>{const p=c.target.value;if(_(p),!!G){if(p){W(G,p);return}Y(G)}},placeholder:n("terminal.inputPlaceholder"),onFocus:Qt,onBlur:Zt,onCompositionStart:()=>{U.current=!0},onCompositionEnd:()=>{U.current=!1}}),h.jsx("div",{className:"actions mt-2",children:h.jsxs("div",{className:"send-row flex flex-wrap items-center justify-end gap-2","data-testid":"editor-send-row",children:[h.jsxs("div",{className:"send-with-enter-toggle mr-auto flex items-center gap-2 text-xs text-muted-foreground","data-testid":"editor-send-with-enter-toggle",children:[h.jsx(gn,{size:"sm",checked:se,onCheckedChange:c=>oe(!!c)}),h.jsx("span",{children:n("terminal.editorSendWithEnter")})]}),h.jsxs(ge,{variant:"outline",size:"sm","data-testid":"editor-clear",onMouseDown:c=>c.preventDefault(),onClick:()=>{var c;_(""),G&&Y(G),D&&I==="editor"&&((c=l.current)==null||c.focus({preventScroll:!0}))},title:n("terminal.clear"),children:[h.jsx(cn,{className:"h-4 w-4"}),n("terminal.clear")]}),h.jsxs(ge,{variant:"secondary",size:"sm","data-testid":"editor-send-line-by-line",onMouseDown:c=>c.preventDefault(),onClick:()=>{var c;Jt(),D&&I==="editor"&&((c=l.current)==null||c.focus({preventScroll:!0}))},disabled:!ie||k,children:[k?h.jsx(Xe,{className:"h-4 w-4 animate-spin"}):h.jsx(pt,{className:"h-4 w-4"}),n("terminal.editorSendLineByLine")]}),h.jsxs(ge,{variant:"default",size:"sm","data-testid":"editor-send",onMouseDown:c=>c.preventDefault(),onClick:()=>{var c;Xt(),D&&I==="editor"&&((c=l.current)==null||c.focus({preventScroll:!0}))},disabled:!ie||k,children:[k?h.jsx(Xe,{className:"h-4 w-4 animate-spin"}):h.jsx(pt,{className:"h-4 w-4"}),n("common.send")]})]})})]})]})}function Jr(){const{deviceId:n,windowId:e,paneId:t}=at(),s=t?ct(t):void 0,r=ee(S=>S.snapshots),i=lt(S=>{var E;return((E=S.settings)==null?void 0:E.siteName)??"tmex"}),o=n?r[n]:void 0,l=d.useMemo(()=>{var S;if(!(!e||!((S=o==null?void 0:o.session)!=null&&S.windows)))return o.session.windows.find(E=>E.id===e)},[e,o]),u=d.useMemo(()=>{if(!(!s||!l))return l.panes.find(S=>S.id===s)},[s,l]),a=d.useMemo(()=>l&&u?qt({paneIdx:u.index,windowIdx:l.index,paneTitle:u.title,windowName:l.name,deviceName:i}):n??"",[l,u,i,n]);return h.jsx(h.Fragment,{children:a})}function Qr(){const{t:n}=Ke(),{deviceId:e,paneId:t}=at(),s=t?ct(t):void 0,r=he(T=>T.inputMode),i=he(T=>T.setInputMode),o=ee(T=>{var b;return e?((b=T.deviceConnected)==null?void 0:b[e])??!1:!1}),[l,u]=d.useState(!1),a=!!(s&&o),S=()=>{i(r==="direct"?"editor":"direct")},E=()=>{window.dispatchEvent(new CustomEvent("tmex:jump-to-latest"))},A=()=>{u(!0)},N=()=>{window.location.reload()};return h.jsxs(h.Fragment,{children:[h.jsx(ge,{variant:"ghost",size:"icon-sm",onClick:A,"aria-label":n("nav.refreshPage"),title:n("nav.refreshPage"),children:h.jsx(Mn,{className:"h-4 w-4"})}),h.jsx(ge,{variant:"ghost",size:"icon-sm",onClick:S,disabled:!a,"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"?h.jsx(Cn,{className:"h-4 w-4"}):h.jsx(An,{className:"h-4 w-4"})}),h.jsx(ge,{variant:"ghost",size:"icon-sm",onClick:E,disabled:!a,"aria-label":n("nav.jumpToLatest"),title:n("nav.jumpToLatest"),children:h.jsx(_n,{className:"h-4 w-4"})}),h.jsx(dn,{open:l,onOpenChange:u,children:h.jsxs(un,{children:[h.jsxs(hn,{children:[h.jsx(fn,{children:n("nav.refreshPage")}),h.jsx(mn,{children:n("nav.refreshPageConfirm")})]}),h.jsxs(pn,{children:[h.jsx(wn,{onClick:()=>u(!1),children:n("common.cancel")}),h.jsx(yn,{onClick:N,children:n("common.confirm")})]})]})})]})}export{Qr as PageActions,Jr as PageTitle,Xr as default};
36
+ //# sourceMappingURL=DevicePage-BGPoxSI1.js.map